· 10 years ago · Feb 18, 2016, 02:39 AM
1<!DOCTYPE HTML>
2<html><head><meta charset="UTF-8"><title>Test.Dux.Language.Mappings</title><style>html, head, body { padding:0; margin:0; }
3body { font-family: calibri, helvetica, arial, sans-serif; }
4a:link { text-decoration: none; color: rgb(15,102,230); }
5a:visited { text-decoration: none; }
6a:active { text-decoration: none; }
7a:hover { text-decoration: underline; color: rgb(234,21,122); }
8html,body { height: 100%; margin: 0px; }
9</style></head><body><script>var Elm = Elm || { Native: {} };
10Elm.Native.Basics = {};
11Elm.Native.Basics.make = function(localRuntime) {
12 localRuntime.Native = localRuntime.Native || {};
13 localRuntime.Native.Basics = localRuntime.Native.Basics || {};
14 if (localRuntime.Native.Basics.values)
15 {
16 return localRuntime.Native.Basics.values;
17 }
18
19 var Utils = Elm.Native.Utils.make(localRuntime);
20
21 function div(a, b)
22 {
23 return (a / b) | 0;
24 }
25 function rem(a, b)
26 {
27 return a % b;
28 }
29 function mod(a, b)
30 {
31 if (b === 0)
32 {
33 throw new Error('Cannot perform mod 0. Division by zero error.');
34 }
35 var r = a % b;
36 var m = a === 0 ? 0 : (b > 0 ? (a >= 0 ? r : r + b) : -mod(-a, -b));
37
38 return m === b ? 0 : m;
39 }
40 function logBase(base, n)
41 {
42 return Math.log(n) / Math.log(base);
43 }
44 function negate(n)
45 {
46 return -n;
47 }
48 function abs(n)
49 {
50 return n < 0 ? -n : n;
51 }
52
53 function min(a, b)
54 {
55 return Utils.cmp(a, b) < 0 ? a : b;
56 }
57 function max(a, b)
58 {
59 return Utils.cmp(a, b) > 0 ? a : b;
60 }
61 function clamp(lo, hi, n)
62 {
63 return Utils.cmp(n, lo) < 0 ? lo : Utils.cmp(n, hi) > 0 ? hi : n;
64 }
65
66 function xor(a, b)
67 {
68 return a !== b;
69 }
70 function not(b)
71 {
72 return !b;
73 }
74 function isInfinite(n)
75 {
76 return n === Infinity || n === -Infinity;
77 }
78
79 function truncate(n)
80 {
81 return n | 0;
82 }
83
84 function degrees(d)
85 {
86 return d * Math.PI / 180;
87 }
88 function turns(t)
89 {
90 return 2 * Math.PI * t;
91 }
92 function fromPolar(point)
93 {
94 var r = point._0;
95 var t = point._1;
96 return Utils.Tuple2(r * Math.cos(t), r * Math.sin(t));
97 }
98 function toPolar(point)
99 {
100 var x = point._0;
101 var y = point._1;
102 return Utils.Tuple2(Math.sqrt(x * x + y * y), Math.atan2(y, x));
103 }
104
105 return localRuntime.Native.Basics.values = {
106 div: F2(div),
107 rem: F2(rem),
108 mod: F2(mod),
109
110 pi: Math.PI,
111 e: Math.E,
112 cos: Math.cos,
113 sin: Math.sin,
114 tan: Math.tan,
115 acos: Math.acos,
116 asin: Math.asin,
117 atan: Math.atan,
118 atan2: F2(Math.atan2),
119
120 degrees: degrees,
121 turns: turns,
122 fromPolar: fromPolar,
123 toPolar: toPolar,
124
125 sqrt: Math.sqrt,
126 logBase: F2(logBase),
127 negate: negate,
128 abs: abs,
129 min: F2(min),
130 max: F2(max),
131 clamp: F3(clamp),
132 compare: Utils.compare,
133
134 xor: F2(xor),
135 not: not,
136
137 truncate: truncate,
138 ceiling: Math.ceil,
139 floor: Math.floor,
140 round: Math.round,
141 toFloat: function(x) { return x; },
142 isNaN: isNaN,
143 isInfinite: isInfinite
144 };
145};
146
147Elm.Native.Port = {};
148
149Elm.Native.Port.make = function(localRuntime) {
150 localRuntime.Native = localRuntime.Native || {};
151 localRuntime.Native.Port = localRuntime.Native.Port || {};
152 if (localRuntime.Native.Port.values)
153 {
154 return localRuntime.Native.Port.values;
155 }
156
157 var NS;
158
159 // INBOUND
160
161 function inbound(name, type, converter)
162 {
163 if (!localRuntime.argsTracker[name])
164 {
165 throw new Error(
166 'Port Error:\n' +
167 'No argument was given for the port named \'' + name + '\' with type:\n\n' +
168 ' ' + type.split('\n').join('\n ') + '\n\n' +
169 'You need to provide an initial value!\n\n' +
170 'Find out more about ports here <http://elm-lang.org/learn/Ports.elm>'
171 );
172 }
173 var arg = localRuntime.argsTracker[name];
174 arg.used = true;
175
176 return jsToElm(name, type, converter, arg.value);
177 }
178
179
180 function inboundSignal(name, type, converter)
181 {
182 var initialValue = inbound(name, type, converter);
183
184 if (!NS)
185 {
186 NS = Elm.Native.Signal.make(localRuntime);
187 }
188 var signal = NS.input('inbound-port-' + name, initialValue);
189
190 function send(jsValue)
191 {
192 var elmValue = jsToElm(name, type, converter, jsValue);
193 setTimeout(function() {
194 localRuntime.notify(signal.id, elmValue);
195 }, 0);
196 }
197
198 localRuntime.ports[name] = { send: send };
199
200 return signal;
201 }
202
203
204 function jsToElm(name, type, converter, value)
205 {
206 try
207 {
208 return converter(value);
209 }
210 catch(e)
211 {
212 throw new Error(
213 'Port Error:\n' +
214 'Regarding the port named \'' + name + '\' with type:\n\n' +
215 ' ' + type.split('\n').join('\n ') + '\n\n' +
216 'You just sent the value:\n\n' +
217 ' ' + JSON.stringify(value) + '\n\n' +
218 'but it cannot be converted to the necessary type.\n' +
219 e.message
220 );
221 }
222 }
223
224
225 // OUTBOUND
226
227 function outbound(name, converter, elmValue)
228 {
229 localRuntime.ports[name] = converter(elmValue);
230 }
231
232
233 function outboundSignal(name, converter, signal)
234 {
235 var subscribers = [];
236
237 function subscribe(handler)
238 {
239 subscribers.push(handler);
240 }
241 function unsubscribe(handler)
242 {
243 subscribers.pop(subscribers.indexOf(handler));
244 }
245
246 function notify(elmValue)
247 {
248 var jsValue = converter(elmValue);
249 var len = subscribers.length;
250 for (var i = 0; i < len; ++i)
251 {
252 subscribers[i](jsValue);
253 }
254 }
255
256 if (!NS)
257 {
258 NS = Elm.Native.Signal.make(localRuntime);
259 }
260 NS.output('outbound-port-' + name, notify, signal);
261
262 localRuntime.ports[name] = {
263 subscribe: subscribe,
264 unsubscribe: unsubscribe
265 };
266
267 return signal;
268 }
269
270
271 return localRuntime.Native.Port.values = {
272 inbound: inbound,
273 outbound: outbound,
274 inboundSignal: inboundSignal,
275 outboundSignal: outboundSignal
276 };
277};
278
279if (!Elm.fullscreen) {
280 (function() {
281 'use strict';
282
283 var Display = {
284 FULLSCREEN: 0,
285 COMPONENT: 1,
286 NONE: 2
287 };
288
289 Elm.fullscreen = function(module, args)
290 {
291 var container = document.createElement('div');
292 document.body.appendChild(container);
293 return init(Display.FULLSCREEN, container, module, args || {});
294 };
295
296 Elm.embed = function(module, container, args)
297 {
298 var tag = container.tagName;
299 if (tag !== 'DIV')
300 {
301 throw new Error('Elm.node must be given a DIV, not a ' + tag + '.');
302 }
303 return init(Display.COMPONENT, container, module, args || {});
304 };
305
306 Elm.worker = function(module, args)
307 {
308 return init(Display.NONE, {}, module, args || {});
309 };
310
311 function init(display, container, module, args, moduleToReplace)
312 {
313 // defining state needed for an instance of the Elm RTS
314 var inputs = [];
315
316 /* OFFSET
317 * Elm's time traveling debugger lets you pause time. This means
318 * "now" may be shifted a bit into the past. By wrapping Date.now()
319 * we can manage this.
320 */
321 var timer = {
322 programStart: Date.now(),
323 now: function()
324 {
325 return Date.now();
326 }
327 };
328
329 var updateInProgress = false;
330 function notify(id, v)
331 {
332 if (updateInProgress)
333 {
334 throw new Error(
335 'The notify function has been called synchronously!\n' +
336 'This can lead to frames being dropped.\n' +
337 'Definitely report this to <https://github.com/elm-lang/Elm/issues>\n');
338 }
339 updateInProgress = true;
340 var timestep = timer.now();
341 for (var i = inputs.length; i--; )
342 {
343 inputs[i].notify(timestep, id, v);
344 }
345 updateInProgress = false;
346 }
347 function setTimeout(func, delay)
348 {
349 return window.setTimeout(func, delay);
350 }
351
352 var listeners = [];
353 function addListener(relevantInputs, domNode, eventName, func)
354 {
355 domNode.addEventListener(eventName, func);
356 var listener = {
357 relevantInputs: relevantInputs,
358 domNode: domNode,
359 eventName: eventName,
360 func: func
361 };
362 listeners.push(listener);
363 }
364
365 var argsTracker = {};
366 for (var name in args)
367 {
368 argsTracker[name] = {
369 value: args[name],
370 used: false
371 };
372 }
373
374 // create the actual RTS. Any impure modules will attach themselves to this
375 // object. This permits many Elm programs to be embedded per document.
376 var elm = {
377 notify: notify,
378 setTimeout: setTimeout,
379 node: container,
380 addListener: addListener,
381 inputs: inputs,
382 timer: timer,
383 argsTracker: argsTracker,
384 ports: {},
385
386 isFullscreen: function() { return display === Display.FULLSCREEN; },
387 isEmbed: function() { return display === Display.COMPONENT; },
388 isWorker: function() { return display === Display.NONE; }
389 };
390
391 function swap(newModule)
392 {
393 removeListeners(listeners);
394 var div = document.createElement('div');
395 var newElm = init(display, div, newModule, args, elm);
396 inputs = [];
397
398 return newElm;
399 }
400
401 function dispose()
402 {
403 removeListeners(listeners);
404 inputs = [];
405 }
406
407 var Module = {};
408 try
409 {
410 Module = module.make(elm);
411 checkInputs(elm);
412 }
413 catch (error)
414 {
415 if (typeof container.appendChild === "function")
416 {
417 container.appendChild(errorNode(error.message));
418 }
419 else
420 {
421 console.error(error.message);
422 }
423 throw error;
424 }
425
426 if (display !== Display.NONE)
427 {
428 var graphicsNode = initGraphics(elm, Module);
429 }
430
431 var rootNode = { kids: inputs };
432 trimDeadNodes(rootNode);
433 inputs = rootNode.kids;
434 filterListeners(inputs, listeners);
435
436 addReceivers(elm.ports);
437
438 if (typeof moduleToReplace !== 'undefined')
439 {
440 hotSwap(moduleToReplace, elm);
441
442 // rerender scene if graphics are enabled.
443 if (typeof graphicsNode !== 'undefined')
444 {
445 graphicsNode.notify(0, true, 0);
446 }
447 }
448
449 return {
450 swap: swap,
451 ports: elm.ports,
452 dispose: dispose
453 };
454 }
455
456 function checkInputs(elm)
457 {
458 var argsTracker = elm.argsTracker;
459 for (var name in argsTracker)
460 {
461 if (!argsTracker[name].used)
462 {
463 throw new Error(
464 "Port Error:\nYou provided an argument named '" + name +
465 "' but there is no corresponding port!\n\n" +
466 "Maybe add a port '" + name + "' to your Elm module?\n" +
467 "Maybe remove the '" + name + "' argument from your initialization code in JS?"
468 );
469 }
470 }
471 }
472
473 function errorNode(message)
474 {
475 var code = document.createElement('code');
476
477 var lines = message.split('\n');
478 code.appendChild(document.createTextNode(lines[0]));
479 code.appendChild(document.createElement('br'));
480 code.appendChild(document.createElement('br'));
481 for (var i = 1; i < lines.length; ++i)
482 {
483 code.appendChild(document.createTextNode('\u00A0 \u00A0 ' + lines[i].replace(/ /g, '\u00A0 ')));
484 code.appendChild(document.createElement('br'));
485 }
486 code.appendChild(document.createElement('br'));
487 code.appendChild(document.createTextNode('Open the developer console for more details.'));
488 return code;
489 }
490
491
492 //// FILTER SIGNALS ////
493
494 // TODO: move this code into the signal module and create a function
495 // Signal.initializeGraph that actually instantiates everything.
496
497 function filterListeners(inputs, listeners)
498 {
499 loop:
500 for (var i = listeners.length; i--; )
501 {
502 var listener = listeners[i];
503 for (var j = inputs.length; j--; )
504 {
505 if (listener.relevantInputs.indexOf(inputs[j].id) >= 0)
506 {
507 continue loop;
508 }
509 }
510 listener.domNode.removeEventListener(listener.eventName, listener.func);
511 }
512 }
513
514 function removeListeners(listeners)
515 {
516 for (var i = listeners.length; i--; )
517 {
518 var listener = listeners[i];
519 listener.domNode.removeEventListener(listener.eventName, listener.func);
520 }
521 }
522
523 // add receivers for built-in ports if they are defined
524 function addReceivers(ports)
525 {
526 if ('title' in ports)
527 {
528 if (typeof ports.title === 'string')
529 {
530 document.title = ports.title;
531 }
532 else
533 {
534 ports.title.subscribe(function(v) { document.title = v; });
535 }
536 }
537 if ('redirect' in ports)
538 {
539 ports.redirect.subscribe(function(v) {
540 if (v.length > 0)
541 {
542 window.location = v;
543 }
544 });
545 }
546 }
547
548
549 // returns a boolean representing whether the node is alive or not.
550 function trimDeadNodes(node)
551 {
552 if (node.isOutput)
553 {
554 return true;
555 }
556
557 var liveKids = [];
558 for (var i = node.kids.length; i--; )
559 {
560 var kid = node.kids[i];
561 if (trimDeadNodes(kid))
562 {
563 liveKids.push(kid);
564 }
565 }
566 node.kids = liveKids;
567
568 return liveKids.length > 0;
569 }
570
571
572 //// RENDERING ////
573
574 function initGraphics(elm, Module)
575 {
576 if (!('main' in Module))
577 {
578 throw new Error("'main' is missing! What do I display?!");
579 }
580
581 var signalGraph = Module.main;
582
583 // make sure the signal graph is actually a signal & extract the visual model
584 if (!('notify' in signalGraph))
585 {
586 signalGraph = Elm.Signal.make(elm).constant(signalGraph);
587 }
588 var initialScene = signalGraph.value;
589
590 // Figure out what the render functions should be
591 var render;
592 var update;
593 if (initialScene.ctor === 'Element_elm_builtin')
594 {
595 var Element = Elm.Native.Graphics.Element.make(elm);
596 render = Element.render;
597 update = Element.updateAndReplace;
598 }
599 else
600 {
601 var VirtualDom = Elm.Native.VirtualDom.make(elm);
602 render = VirtualDom.render;
603 update = VirtualDom.updateAndReplace;
604 }
605
606 // Add the initialScene to the DOM
607 var container = elm.node;
608 var node = render(initialScene);
609 while (container.firstChild)
610 {
611 container.removeChild(container.firstChild);
612 }
613 container.appendChild(node);
614
615 var _requestAnimationFrame =
616 typeof requestAnimationFrame !== 'undefined'
617 ? requestAnimationFrame
618 : function(cb) { setTimeout(cb, 1000 / 60); }
619 ;
620
621 // domUpdate is called whenever the main Signal changes.
622 //
623 // domUpdate and drawCallback implement a small state machine in order
624 // to schedule only 1 draw per animation frame. This enforces that
625 // once draw has been called, it will not be called again until the
626 // next frame.
627 //
628 // drawCallback is scheduled whenever
629 // 1. The state transitions from PENDING_REQUEST to EXTRA_REQUEST, or
630 // 2. The state transitions from NO_REQUEST to PENDING_REQUEST
631 //
632 // Invariants:
633 // 1. In the NO_REQUEST state, there is never a scheduled drawCallback.
634 // 2. In the PENDING_REQUEST and EXTRA_REQUEST states, there is always exactly 1
635 // scheduled drawCallback.
636 var NO_REQUEST = 0;
637 var PENDING_REQUEST = 1;
638 var EXTRA_REQUEST = 2;
639 var state = NO_REQUEST;
640 var savedScene = initialScene;
641 var scheduledScene = initialScene;
642
643 function domUpdate(newScene)
644 {
645 scheduledScene = newScene;
646
647 switch (state)
648 {
649 case NO_REQUEST:
650 _requestAnimationFrame(drawCallback);
651 state = PENDING_REQUEST;
652 return;
653 case PENDING_REQUEST:
654 state = PENDING_REQUEST;
655 return;
656 case EXTRA_REQUEST:
657 state = PENDING_REQUEST;
658 return;
659 }
660 }
661
662 function drawCallback()
663 {
664 switch (state)
665 {
666 case NO_REQUEST:
667 // This state should not be possible. How can there be no
668 // request, yet somehow we are actively fulfilling a
669 // request?
670 throw new Error(
671 'Unexpected draw callback.\n' +
672 'Please report this to <https://github.com/elm-lang/core/issues>.'
673 );
674
675 case PENDING_REQUEST:
676 // At this point, we do not *know* that another frame is
677 // needed, but we make an extra request to rAF just in
678 // case. It's possible to drop a frame if rAF is called
679 // too late, so we just do it preemptively.
680 _requestAnimationFrame(drawCallback);
681 state = EXTRA_REQUEST;
682
683 // There's also stuff we definitely need to draw.
684 draw();
685 return;
686
687 case EXTRA_REQUEST:
688 // Turns out the extra request was not needed, so we will
689 // stop calling rAF. No reason to call it all the time if
690 // no one needs it.
691 state = NO_REQUEST;
692 return;
693 }
694 }
695
696 function draw()
697 {
698 update(elm.node.firstChild, savedScene, scheduledScene);
699 if (elm.Native.Window)
700 {
701 elm.Native.Window.values.resizeIfNeeded();
702 }
703 savedScene = scheduledScene;
704 }
705
706 var renderer = Elm.Native.Signal.make(elm).output('main', domUpdate, signalGraph);
707
708 // must check for resize after 'renderer' is created so
709 // that changes show up.
710 if (elm.Native.Window)
711 {
712 elm.Native.Window.values.resizeIfNeeded();
713 }
714
715 return renderer;
716 }
717
718 //// HOT SWAPPING ////
719
720 // Returns boolean indicating if the swap was successful.
721 // Requires that the two signal graphs have exactly the same
722 // structure.
723 function hotSwap(from, to)
724 {
725 function similar(nodeOld, nodeNew)
726 {
727 if (nodeOld.id !== nodeNew.id)
728 {
729 return false;
730 }
731 if (nodeOld.isOutput)
732 {
733 return nodeNew.isOutput;
734 }
735 return nodeOld.kids.length === nodeNew.kids.length;
736 }
737 function swap(nodeOld, nodeNew)
738 {
739 nodeNew.value = nodeOld.value;
740 return true;
741 }
742 var canSwap = depthFirstTraversals(similar, from.inputs, to.inputs);
743 if (canSwap)
744 {
745 depthFirstTraversals(swap, from.inputs, to.inputs);
746 }
747 from.node.parentNode.replaceChild(to.node, from.node);
748
749 return canSwap;
750 }
751
752 // Returns false if the node operation f ever fails.
753 function depthFirstTraversals(f, queueOld, queueNew)
754 {
755 if (queueOld.length !== queueNew.length)
756 {
757 return false;
758 }
759 queueOld = queueOld.slice(0);
760 queueNew = queueNew.slice(0);
761
762 var seen = [];
763 while (queueOld.length > 0 && queueNew.length > 0)
764 {
765 var nodeOld = queueOld.pop();
766 var nodeNew = queueNew.pop();
767 if (seen.indexOf(nodeOld.id) < 0)
768 {
769 if (!f(nodeOld, nodeNew))
770 {
771 return false;
772 }
773 queueOld = queueOld.concat(nodeOld.kids || []);
774 queueNew = queueNew.concat(nodeNew.kids || []);
775 seen.push(nodeOld.id);
776 }
777 }
778 return true;
779 }
780 }());
781
782 function F2(fun)
783 {
784 function wrapper(a) { return function(b) { return fun(a,b); }; }
785 wrapper.arity = 2;
786 wrapper.func = fun;
787 return wrapper;
788 }
789
790 function F3(fun)
791 {
792 function wrapper(a) {
793 return function(b) { return function(c) { return fun(a, b, c); }; };
794 }
795 wrapper.arity = 3;
796 wrapper.func = fun;
797 return wrapper;
798 }
799
800 function F4(fun)
801 {
802 function wrapper(a) { return function(b) { return function(c) {
803 return function(d) { return fun(a, b, c, d); }; }; };
804 }
805 wrapper.arity = 4;
806 wrapper.func = fun;
807 return wrapper;
808 }
809
810 function F5(fun)
811 {
812 function wrapper(a) { return function(b) { return function(c) {
813 return function(d) { return function(e) { return fun(a, b, c, d, e); }; }; }; };
814 }
815 wrapper.arity = 5;
816 wrapper.func = fun;
817 return wrapper;
818 }
819
820 function F6(fun)
821 {
822 function wrapper(a) { return function(b) { return function(c) {
823 return function(d) { return function(e) { return function(f) {
824 return fun(a, b, c, d, e, f); }; }; }; }; };
825 }
826 wrapper.arity = 6;
827 wrapper.func = fun;
828 return wrapper;
829 }
830
831 function F7(fun)
832 {
833 function wrapper(a) { return function(b) { return function(c) {
834 return function(d) { return function(e) { return function(f) {
835 return function(g) { return fun(a, b, c, d, e, f, g); }; }; }; }; }; };
836 }
837 wrapper.arity = 7;
838 wrapper.func = fun;
839 return wrapper;
840 }
841
842 function F8(fun)
843 {
844 function wrapper(a) { return function(b) { return function(c) {
845 return function(d) { return function(e) { return function(f) {
846 return function(g) { return function(h) {
847 return fun(a, b, c, d, e, f, g, h); }; }; }; }; }; }; };
848 }
849 wrapper.arity = 8;
850 wrapper.func = fun;
851 return wrapper;
852 }
853
854 function F9(fun)
855 {
856 function wrapper(a) { return function(b) { return function(c) {
857 return function(d) { return function(e) { return function(f) {
858 return function(g) { return function(h) { return function(i) {
859 return fun(a, b, c, d, e, f, g, h, i); }; }; }; }; }; }; }; };
860 }
861 wrapper.arity = 9;
862 wrapper.func = fun;
863 return wrapper;
864 }
865
866 function A2(fun, a, b)
867 {
868 return fun.arity === 2
869 ? fun.func(a, b)
870 : fun(a)(b);
871 }
872 function A3(fun, a, b, c)
873 {
874 return fun.arity === 3
875 ? fun.func(a, b, c)
876 : fun(a)(b)(c);
877 }
878 function A4(fun, a, b, c, d)
879 {
880 return fun.arity === 4
881 ? fun.func(a, b, c, d)
882 : fun(a)(b)(c)(d);
883 }
884 function A5(fun, a, b, c, d, e)
885 {
886 return fun.arity === 5
887 ? fun.func(a, b, c, d, e)
888 : fun(a)(b)(c)(d)(e);
889 }
890 function A6(fun, a, b, c, d, e, f)
891 {
892 return fun.arity === 6
893 ? fun.func(a, b, c, d, e, f)
894 : fun(a)(b)(c)(d)(e)(f);
895 }
896 function A7(fun, a, b, c, d, e, f, g)
897 {
898 return fun.arity === 7
899 ? fun.func(a, b, c, d, e, f, g)
900 : fun(a)(b)(c)(d)(e)(f)(g);
901 }
902 function A8(fun, a, b, c, d, e, f, g, h)
903 {
904 return fun.arity === 8
905 ? fun.func(a, b, c, d, e, f, g, h)
906 : fun(a)(b)(c)(d)(e)(f)(g)(h);
907 }
908 function A9(fun, a, b, c, d, e, f, g, h, i)
909 {
910 return fun.arity === 9
911 ? fun.func(a, b, c, d, e, f, g, h, i)
912 : fun(a)(b)(c)(d)(e)(f)(g)(h)(i);
913 }
914}
915
916Elm.Native = Elm.Native || {};
917Elm.Native.Utils = {};
918Elm.Native.Utils.make = function(localRuntime) {
919 localRuntime.Native = localRuntime.Native || {};
920 localRuntime.Native.Utils = localRuntime.Native.Utils || {};
921 if (localRuntime.Native.Utils.values)
922 {
923 return localRuntime.Native.Utils.values;
924 }
925
926
927 // COMPARISONS
928
929 function eq(l, r)
930 {
931 var stack = [{'x': l, 'y': r}];
932 while (stack.length > 0)
933 {
934 var front = stack.pop();
935 var x = front.x;
936 var y = front.y;
937 if (x === y)
938 {
939 continue;
940 }
941 if (typeof x === 'object')
942 {
943 var c = 0;
944 for (var i in x)
945 {
946 ++c;
947 if (i in y)
948 {
949 if (i !== 'ctor')
950 {
951 stack.push({ 'x': x[i], 'y': y[i] });
952 }
953 }
954 else
955 {
956 return false;
957 }
958 }
959 if ('ctor' in x)
960 {
961 stack.push({'x': x.ctor, 'y': y.ctor});
962 }
963 if (c !== Object.keys(y).length)
964 {
965 return false;
966 }
967 }
968 else if (typeof x === 'function')
969 {
970 throw new Error('Equality error: general function equality is ' +
971 'undecidable, and therefore, unsupported');
972 }
973 else
974 {
975 return false;
976 }
977 }
978 return true;
979 }
980
981 // code in Generate/JavaScript.hs depends on the particular
982 // integer values assigned to LT, EQ, and GT
983 var LT = -1, EQ = 0, GT = 1, ord = ['LT', 'EQ', 'GT'];
984
985 function compare(x, y)
986 {
987 return {
988 ctor: ord[cmp(x, y) + 1]
989 };
990 }
991
992 function cmp(x, y) {
993 var ord;
994 if (typeof x !== 'object')
995 {
996 return x === y ? EQ : x < y ? LT : GT;
997 }
998 else if (x.isChar)
999 {
1000 var a = x.toString();
1001 var b = y.toString();
1002 return a === b
1003 ? EQ
1004 : a < b
1005 ? LT
1006 : GT;
1007 }
1008 else if (x.ctor === '::' || x.ctor === '[]')
1009 {
1010 while (true)
1011 {
1012 if (x.ctor === '[]' && y.ctor === '[]')
1013 {
1014 return EQ;
1015 }
1016 if (x.ctor !== y.ctor)
1017 {
1018 return x.ctor === '[]' ? LT : GT;
1019 }
1020 ord = cmp(x._0, y._0);
1021 if (ord !== EQ)
1022 {
1023 return ord;
1024 }
1025 x = x._1;
1026 y = y._1;
1027 }
1028 }
1029 else if (x.ctor.slice(0, 6) === '_Tuple')
1030 {
1031 var n = x.ctor.slice(6) - 0;
1032 var err = 'cannot compare tuples with more than 6 elements.';
1033 if (n === 0) return EQ;
1034 if (n >= 1) { ord = cmp(x._0, y._0); if (ord !== EQ) return ord;
1035 if (n >= 2) { ord = cmp(x._1, y._1); if (ord !== EQ) return ord;
1036 if (n >= 3) { ord = cmp(x._2, y._2); if (ord !== EQ) return ord;
1037 if (n >= 4) { ord = cmp(x._3, y._3); if (ord !== EQ) return ord;
1038 if (n >= 5) { ord = cmp(x._4, y._4); if (ord !== EQ) return ord;
1039 if (n >= 6) { ord = cmp(x._5, y._5); if (ord !== EQ) return ord;
1040 if (n >= 7) throw new Error('Comparison error: ' + err); } } } } } }
1041 return EQ;
1042 }
1043 else
1044 {
1045 throw new Error('Comparison error: comparison is only defined on ints, ' +
1046 'floats, times, chars, strings, lists of comparable values, ' +
1047 'and tuples of comparable values.');
1048 }
1049 }
1050
1051
1052 // TUPLES
1053
1054 var Tuple0 = {
1055 ctor: '_Tuple0'
1056 };
1057
1058 function Tuple2(x, y)
1059 {
1060 return {
1061 ctor: '_Tuple2',
1062 _0: x,
1063 _1: y
1064 };
1065 }
1066
1067
1068 // LITERALS
1069
1070 function chr(c)
1071 {
1072 var x = new String(c);
1073 x.isChar = true;
1074 return x;
1075 }
1076
1077 function txt(str)
1078 {
1079 var t = new String(str);
1080 t.text = true;
1081 return t;
1082 }
1083
1084
1085 // GUID
1086
1087 var count = 0;
1088 function guid(_)
1089 {
1090 return count++;
1091 }
1092
1093
1094 // RECORDS
1095
1096 function update(oldRecord, updatedFields)
1097 {
1098 var newRecord = {};
1099 for (var key in oldRecord)
1100 {
1101 var value = (key in updatedFields) ? updatedFields[key] : oldRecord[key];
1102 newRecord[key] = value;
1103 }
1104 return newRecord;
1105 }
1106
1107
1108 // MOUSE COORDINATES
1109
1110 function getXY(e)
1111 {
1112 var posx = 0;
1113 var posy = 0;
1114 if (e.pageX || e.pageY)
1115 {
1116 posx = e.pageX;
1117 posy = e.pageY;
1118 }
1119 else if (e.clientX || e.clientY)
1120 {
1121 posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
1122 posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
1123 }
1124
1125 if (localRuntime.isEmbed())
1126 {
1127 var rect = localRuntime.node.getBoundingClientRect();
1128 var relx = rect.left + document.body.scrollLeft + document.documentElement.scrollLeft;
1129 var rely = rect.top + document.body.scrollTop + document.documentElement.scrollTop;
1130 // TODO: figure out if there is a way to avoid rounding here
1131 posx = posx - Math.round(relx) - localRuntime.node.clientLeft;
1132 posy = posy - Math.round(rely) - localRuntime.node.clientTop;
1133 }
1134 return Tuple2(posx, posy);
1135 }
1136
1137
1138 //// LIST STUFF ////
1139
1140 var Nil = { ctor: '[]' };
1141
1142 function Cons(hd, tl)
1143 {
1144 return {
1145 ctor: '::',
1146 _0: hd,
1147 _1: tl
1148 };
1149 }
1150
1151 function list(arr)
1152 {
1153 var out = Nil;
1154 for (var i = arr.length; i--; )
1155 {
1156 out = Cons(arr[i], out);
1157 }
1158 return out;
1159 }
1160
1161 function range(lo, hi)
1162 {
1163 var list = Nil;
1164 if (lo <= hi)
1165 {
1166 do
1167 {
1168 list = Cons(hi, list);
1169 }
1170 while (hi-- > lo);
1171 }
1172 return list;
1173 }
1174
1175 function append(xs, ys)
1176 {
1177 // append Strings
1178 if (typeof xs === 'string')
1179 {
1180 return xs + ys;
1181 }
1182
1183 // append Text
1184 if (xs.ctor.slice(0, 5) === 'Text:')
1185 {
1186 return {
1187 ctor: 'Text:Append',
1188 _0: xs,
1189 _1: ys
1190 };
1191 }
1192
1193
1194 // append Lists
1195 if (xs.ctor === '[]')
1196 {
1197 return ys;
1198 }
1199 var root = Cons(xs._0, Nil);
1200 var curr = root;
1201 xs = xs._1;
1202 while (xs.ctor !== '[]')
1203 {
1204 curr._1 = Cons(xs._0, Nil);
1205 xs = xs._1;
1206 curr = curr._1;
1207 }
1208 curr._1 = ys;
1209 return root;
1210 }
1211
1212
1213 // CRASHES
1214
1215 function crash(moduleName, region)
1216 {
1217 return function(message) {
1218 throw new Error(
1219 'Ran into a `Debug.crash` in module `' + moduleName + '` ' + regionToString(region) + '\n'
1220 + 'The message provided by the code author is:\n\n '
1221 + message
1222 );
1223 };
1224 }
1225
1226 function crashCase(moduleName, region, value)
1227 {
1228 return function(message) {
1229 throw new Error(
1230 'Ran into a `Debug.crash` in module `' + moduleName + '`\n\n'
1231 + 'This was caused by the `case` expression ' + regionToString(region) + '.\n'
1232 + 'One of the branches ended with a crash and the following value got through:\n\n ' + toString(value) + '\n\n'
1233 + 'The message provided by the code author is:\n\n '
1234 + message
1235 );
1236 };
1237 }
1238
1239 function regionToString(region)
1240 {
1241 if (region.start.line == region.end.line)
1242 {
1243 return 'on line ' + region.start.line;
1244 }
1245 return 'between lines ' + region.start.line + ' and ' + region.end.line;
1246 }
1247
1248
1249 // BAD PORTS
1250
1251 function badPort(expected, received)
1252 {
1253 throw new Error(
1254 'Runtime error when sending values through a port.\n\n'
1255 + 'Expecting ' + expected + ' but was given ' + formatValue(received)
1256 );
1257 }
1258
1259 function formatValue(value)
1260 {
1261 // Explicity format undefined values as "undefined"
1262 // because JSON.stringify(undefined) unhelpfully returns ""
1263 return (value === undefined) ? "undefined" : JSON.stringify(value);
1264 }
1265
1266
1267 // TO STRING
1268
1269 var _Array;
1270 var Dict;
1271 var List;
1272
1273 var toString = function(v)
1274 {
1275 var type = typeof v;
1276 if (type === 'function')
1277 {
1278 var name = v.func ? v.func.name : v.name;
1279 return '<function' + (name === '' ? '' : ': ') + name + '>';
1280 }
1281 else if (type === 'boolean')
1282 {
1283 return v ? 'True' : 'False';
1284 }
1285 else if (type === 'number')
1286 {
1287 return v + '';
1288 }
1289 else if ((v instanceof String) && v.isChar)
1290 {
1291 return '\'' + addSlashes(v, true) + '\'';
1292 }
1293 else if (type === 'string')
1294 {
1295 return '"' + addSlashes(v, false) + '"';
1296 }
1297 else if (type === 'object' && 'ctor' in v)
1298 {
1299 if (v.ctor.substring(0, 6) === '_Tuple')
1300 {
1301 var output = [];
1302 for (var k in v)
1303 {
1304 if (k === 'ctor') continue;
1305 output.push(toString(v[k]));
1306 }
1307 return '(' + output.join(',') + ')';
1308 }
1309 else if (v.ctor === '_Array')
1310 {
1311 if (!_Array)
1312 {
1313 _Array = Elm.Array.make(localRuntime);
1314 }
1315 var list = _Array.toList(v);
1316 return 'Array.fromList ' + toString(list);
1317 }
1318 else if (v.ctor === '::')
1319 {
1320 var output = '[' + toString(v._0);
1321 v = v._1;
1322 while (v.ctor === '::')
1323 {
1324 output += ',' + toString(v._0);
1325 v = v._1;
1326 }
1327 return output + ']';
1328 }
1329 else if (v.ctor === '[]')
1330 {
1331 return '[]';
1332 }
1333 else if (v.ctor === 'RBNode_elm_builtin' || v.ctor === 'RBEmpty_elm_builtin' || v.ctor === 'Set_elm_builtin')
1334 {
1335 if (!Dict)
1336 {
1337 Dict = Elm.Dict.make(localRuntime);
1338 }
1339 var list;
1340 var name;
1341 if (v.ctor === 'Set_elm_builtin')
1342 {
1343 if (!List)
1344 {
1345 List = Elm.List.make(localRuntime);
1346 }
1347 name = 'Set';
1348 list = A2(List.map, function(x) {return x._0; }, Dict.toList(v._0));
1349 }
1350 else
1351 {
1352 name = 'Dict';
1353 list = Dict.toList(v);
1354 }
1355 return name + '.fromList ' + toString(list);
1356 }
1357 else if (v.ctor.slice(0, 5) === 'Text:')
1358 {
1359 return '<text>';
1360 }
1361 else if (v.ctor === 'Element_elm_builtin')
1362 {
1363 return '<element>'
1364 }
1365 else if (v.ctor === 'Form_elm_builtin')
1366 {
1367 return '<form>'
1368 }
1369 else
1370 {
1371 var output = '';
1372 for (var i in v)
1373 {
1374 if (i === 'ctor') continue;
1375 var str = toString(v[i]);
1376 var parenless = str[0] === '{' || str[0] === '<' || str.indexOf(' ') < 0;
1377 output += ' ' + (parenless ? str : '(' + str + ')');
1378 }
1379 return v.ctor + output;
1380 }
1381 }
1382 else if (type === 'object' && 'notify' in v && 'id' in v)
1383 {
1384 return '<signal>';
1385 }
1386 else if (type === 'object')
1387 {
1388 var output = [];
1389 for (var k in v)
1390 {
1391 output.push(k + ' = ' + toString(v[k]));
1392 }
1393 if (output.length === 0)
1394 {
1395 return '{}';
1396 }
1397 return '{ ' + output.join(', ') + ' }';
1398 }
1399 return '<internal structure>';
1400 };
1401
1402 function addSlashes(str, isChar)
1403 {
1404 var s = str.replace(/\\/g, '\\\\')
1405 .replace(/\n/g, '\\n')
1406 .replace(/\t/g, '\\t')
1407 .replace(/\r/g, '\\r')
1408 .replace(/\v/g, '\\v')
1409 .replace(/\0/g, '\\0');
1410 if (isChar)
1411 {
1412 return s.replace(/\'/g, '\\\'');
1413 }
1414 else
1415 {
1416 return s.replace(/\"/g, '\\"');
1417 }
1418 }
1419
1420
1421 return localRuntime.Native.Utils.values = {
1422 eq: eq,
1423 cmp: cmp,
1424 compare: F2(compare),
1425 Tuple0: Tuple0,
1426 Tuple2: Tuple2,
1427 chr: chr,
1428 txt: txt,
1429 update: update,
1430 guid: guid,
1431 getXY: getXY,
1432
1433 Nil: Nil,
1434 Cons: Cons,
1435 list: list,
1436 range: range,
1437 append: F2(append),
1438
1439 crash: crash,
1440 crashCase: crashCase,
1441 badPort: badPort,
1442
1443 toString: toString
1444 };
1445};
1446
1447Elm.Basics = Elm.Basics || {};
1448Elm.Basics.make = function (_elm) {
1449 "use strict";
1450 _elm.Basics = _elm.Basics || {};
1451 if (_elm.Basics.values) return _elm.Basics.values;
1452 var _U = Elm.Native.Utils.make(_elm),$Native$Basics = Elm.Native.Basics.make(_elm),$Native$Utils = Elm.Native.Utils.make(_elm);
1453 var _op = {};
1454 var uncurry = F2(function (f,_p0) { var _p1 = _p0;return A2(f,_p1._0,_p1._1);});
1455 var curry = F3(function (f,a,b) { return f({ctor: "_Tuple2",_0: a,_1: b});});
1456 var flip = F3(function (f,b,a) { return A2(f,a,b);});
1457 var snd = function (_p2) { var _p3 = _p2;return _p3._1;};
1458 var fst = function (_p4) { var _p5 = _p4;return _p5._0;};
1459 var always = F2(function (a,_p6) { return a;});
1460 var identity = function (x) { return x;};
1461 _op["<|"] = F2(function (f,x) { return f(x);});
1462 _op["|>"] = F2(function (x,f) { return f(x);});
1463 _op[">>"] = F3(function (f,g,x) { return g(f(x));});
1464 _op["<<"] = F3(function (g,f,x) { return g(f(x));});
1465 _op["++"] = $Native$Utils.append;
1466 var toString = $Native$Utils.toString;
1467 var isInfinite = $Native$Basics.isInfinite;
1468 var isNaN = $Native$Basics.isNaN;
1469 var toFloat = $Native$Basics.toFloat;
1470 var ceiling = $Native$Basics.ceiling;
1471 var floor = $Native$Basics.floor;
1472 var truncate = $Native$Basics.truncate;
1473 var round = $Native$Basics.round;
1474 var not = $Native$Basics.not;
1475 var xor = $Native$Basics.xor;
1476 _op["||"] = $Native$Basics.or;
1477 _op["&&"] = $Native$Basics.and;
1478 var max = $Native$Basics.max;
1479 var min = $Native$Basics.min;
1480 var GT = {ctor: "GT"};
1481 var EQ = {ctor: "EQ"};
1482 var LT = {ctor: "LT"};
1483 var compare = $Native$Basics.compare;
1484 _op[">="] = $Native$Basics.ge;
1485 _op["<="] = $Native$Basics.le;
1486 _op[">"] = $Native$Basics.gt;
1487 _op["<"] = $Native$Basics.lt;
1488 _op["/="] = $Native$Basics.neq;
1489 _op["=="] = $Native$Basics.eq;
1490 var e = $Native$Basics.e;
1491 var pi = $Native$Basics.pi;
1492 var clamp = $Native$Basics.clamp;
1493 var logBase = $Native$Basics.logBase;
1494 var abs = $Native$Basics.abs;
1495 var negate = $Native$Basics.negate;
1496 var sqrt = $Native$Basics.sqrt;
1497 var atan2 = $Native$Basics.atan2;
1498 var atan = $Native$Basics.atan;
1499 var asin = $Native$Basics.asin;
1500 var acos = $Native$Basics.acos;
1501 var tan = $Native$Basics.tan;
1502 var sin = $Native$Basics.sin;
1503 var cos = $Native$Basics.cos;
1504 _op["^"] = $Native$Basics.exp;
1505 _op["%"] = $Native$Basics.mod;
1506 var rem = $Native$Basics.rem;
1507 _op["//"] = $Native$Basics.div;
1508 _op["/"] = $Native$Basics.floatDiv;
1509 _op["*"] = $Native$Basics.mul;
1510 _op["-"] = $Native$Basics.sub;
1511 _op["+"] = $Native$Basics.add;
1512 var toPolar = $Native$Basics.toPolar;
1513 var fromPolar = $Native$Basics.fromPolar;
1514 var turns = $Native$Basics.turns;
1515 var degrees = $Native$Basics.degrees;
1516 var radians = function (t) { return t;};
1517 return _elm.Basics.values = {_op: _op
1518 ,max: max
1519 ,min: min
1520 ,compare: compare
1521 ,not: not
1522 ,xor: xor
1523 ,rem: rem
1524 ,negate: negate
1525 ,abs: abs
1526 ,sqrt: sqrt
1527 ,clamp: clamp
1528 ,logBase: logBase
1529 ,e: e
1530 ,pi: pi
1531 ,cos: cos
1532 ,sin: sin
1533 ,tan: tan
1534 ,acos: acos
1535 ,asin: asin
1536 ,atan: atan
1537 ,atan2: atan2
1538 ,round: round
1539 ,floor: floor
1540 ,ceiling: ceiling
1541 ,truncate: truncate
1542 ,toFloat: toFloat
1543 ,degrees: degrees
1544 ,radians: radians
1545 ,turns: turns
1546 ,toPolar: toPolar
1547 ,fromPolar: fromPolar
1548 ,isNaN: isNaN
1549 ,isInfinite: isInfinite
1550 ,toString: toString
1551 ,fst: fst
1552 ,snd: snd
1553 ,identity: identity
1554 ,always: always
1555 ,flip: flip
1556 ,curry: curry
1557 ,uncurry: uncurry
1558 ,LT: LT
1559 ,EQ: EQ
1560 ,GT: GT};
1561};
1562Elm.Maybe = Elm.Maybe || {};
1563Elm.Maybe.make = function (_elm) {
1564 "use strict";
1565 _elm.Maybe = _elm.Maybe || {};
1566 if (_elm.Maybe.values) return _elm.Maybe.values;
1567 var _U = Elm.Native.Utils.make(_elm);
1568 var _op = {};
1569 var withDefault = F2(function ($default,maybe) { var _p0 = maybe;if (_p0.ctor === "Just") { return _p0._0;} else { return $default;}});
1570 var Nothing = {ctor: "Nothing"};
1571 var oneOf = function (maybes) {
1572 oneOf: while (true) {
1573 var _p1 = maybes;
1574 if (_p1.ctor === "[]") {
1575 return Nothing;
1576 } else {
1577 var _p3 = _p1._0;
1578 var _p2 = _p3;
1579 if (_p2.ctor === "Nothing") {
1580 var _v3 = _p1._1;
1581 maybes = _v3;
1582 continue oneOf;
1583 } else {
1584 return _p3;
1585 }
1586 }
1587 }
1588 };
1589 var andThen = F2(function (maybeValue,callback) {
1590 var _p4 = maybeValue;
1591 if (_p4.ctor === "Just") {
1592 return callback(_p4._0);
1593 } else {
1594 return Nothing;
1595 }
1596 });
1597 var Just = function (a) { return {ctor: "Just",_0: a};};
1598 var map = F2(function (f,maybe) { var _p5 = maybe;if (_p5.ctor === "Just") { return Just(f(_p5._0));} else { return Nothing;}});
1599 var map2 = F3(function (func,ma,mb) {
1600 var _p6 = {ctor: "_Tuple2",_0: ma,_1: mb};
1601 if (_p6.ctor === "_Tuple2" && _p6._0.ctor === "Just" && _p6._1.ctor === "Just") {
1602 return Just(A2(func,_p6._0._0,_p6._1._0));
1603 } else {
1604 return Nothing;
1605 }
1606 });
1607 var map3 = F4(function (func,ma,mb,mc) {
1608 var _p7 = {ctor: "_Tuple3",_0: ma,_1: mb,_2: mc};
1609 if (_p7.ctor === "_Tuple3" && _p7._0.ctor === "Just" && _p7._1.ctor === "Just" && _p7._2.ctor === "Just") {
1610 return Just(A3(func,_p7._0._0,_p7._1._0,_p7._2._0));
1611 } else {
1612 return Nothing;
1613 }
1614 });
1615 var map4 = F5(function (func,ma,mb,mc,md) {
1616 var _p8 = {ctor: "_Tuple4",_0: ma,_1: mb,_2: mc,_3: md};
1617 if (_p8.ctor === "_Tuple4" && _p8._0.ctor === "Just" && _p8._1.ctor === "Just" && _p8._2.ctor === "Just" && _p8._3.ctor === "Just") {
1618 return Just(A4(func,_p8._0._0,_p8._1._0,_p8._2._0,_p8._3._0));
1619 } else {
1620 return Nothing;
1621 }
1622 });
1623 var map5 = F6(function (func,ma,mb,mc,md,me) {
1624 var _p9 = {ctor: "_Tuple5",_0: ma,_1: mb,_2: mc,_3: md,_4: me};
1625 if (_p9.ctor === "_Tuple5" && _p9._0.ctor === "Just" && _p9._1.ctor === "Just" && _p9._2.ctor === "Just" && _p9._3.ctor === "Just" && _p9._4.ctor === "Just")
1626 {
1627 return Just(A5(func,_p9._0._0,_p9._1._0,_p9._2._0,_p9._3._0,_p9._4._0));
1628 } else {
1629 return Nothing;
1630 }
1631 });
1632 return _elm.Maybe.values = {_op: _op
1633 ,andThen: andThen
1634 ,map: map
1635 ,map2: map2
1636 ,map3: map3
1637 ,map4: map4
1638 ,map5: map5
1639 ,withDefault: withDefault
1640 ,oneOf: oneOf
1641 ,Just: Just
1642 ,Nothing: Nothing};
1643};
1644Elm.Native.List = {};
1645Elm.Native.List.make = function(localRuntime) {
1646 localRuntime.Native = localRuntime.Native || {};
1647 localRuntime.Native.List = localRuntime.Native.List || {};
1648 if (localRuntime.Native.List.values)
1649 {
1650 return localRuntime.Native.List.values;
1651 }
1652 if ('values' in Elm.Native.List)
1653 {
1654 return localRuntime.Native.List.values = Elm.Native.List.values;
1655 }
1656
1657 var Utils = Elm.Native.Utils.make(localRuntime);
1658
1659 var Nil = Utils.Nil;
1660 var Cons = Utils.Cons;
1661
1662 var fromArray = Utils.list;
1663
1664 function toArray(xs)
1665 {
1666 var out = [];
1667 while (xs.ctor !== '[]')
1668 {
1669 out.push(xs._0);
1670 xs = xs._1;
1671 }
1672 return out;
1673 }
1674
1675 // f defined similarly for both foldl and foldr (NB: different from Haskell)
1676 // ie, foldl : (a -> b -> b) -> b -> [a] -> b
1677 function foldl(f, b, xs)
1678 {
1679 var acc = b;
1680 while (xs.ctor !== '[]')
1681 {
1682 acc = A2(f, xs._0, acc);
1683 xs = xs._1;
1684 }
1685 return acc;
1686 }
1687
1688 function foldr(f, b, xs)
1689 {
1690 var arr = toArray(xs);
1691 var acc = b;
1692 for (var i = arr.length; i--; )
1693 {
1694 acc = A2(f, arr[i], acc);
1695 }
1696 return acc;
1697 }
1698
1699 function map2(f, xs, ys)
1700 {
1701 var arr = [];
1702 while (xs.ctor !== '[]' && ys.ctor !== '[]')
1703 {
1704 arr.push(A2(f, xs._0, ys._0));
1705 xs = xs._1;
1706 ys = ys._1;
1707 }
1708 return fromArray(arr);
1709 }
1710
1711 function map3(f, xs, ys, zs)
1712 {
1713 var arr = [];
1714 while (xs.ctor !== '[]' && ys.ctor !== '[]' && zs.ctor !== '[]')
1715 {
1716 arr.push(A3(f, xs._0, ys._0, zs._0));
1717 xs = xs._1;
1718 ys = ys._1;
1719 zs = zs._1;
1720 }
1721 return fromArray(arr);
1722 }
1723
1724 function map4(f, ws, xs, ys, zs)
1725 {
1726 var arr = [];
1727 while ( ws.ctor !== '[]'
1728 && xs.ctor !== '[]'
1729 && ys.ctor !== '[]'
1730 && zs.ctor !== '[]')
1731 {
1732 arr.push(A4(f, ws._0, xs._0, ys._0, zs._0));
1733 ws = ws._1;
1734 xs = xs._1;
1735 ys = ys._1;
1736 zs = zs._1;
1737 }
1738 return fromArray(arr);
1739 }
1740
1741 function map5(f, vs, ws, xs, ys, zs)
1742 {
1743 var arr = [];
1744 while ( vs.ctor !== '[]'
1745 && ws.ctor !== '[]'
1746 && xs.ctor !== '[]'
1747 && ys.ctor !== '[]'
1748 && zs.ctor !== '[]')
1749 {
1750 arr.push(A5(f, vs._0, ws._0, xs._0, ys._0, zs._0));
1751 vs = vs._1;
1752 ws = ws._1;
1753 xs = xs._1;
1754 ys = ys._1;
1755 zs = zs._1;
1756 }
1757 return fromArray(arr);
1758 }
1759
1760 function sortBy(f, xs)
1761 {
1762 return fromArray(toArray(xs).sort(function(a, b) {
1763 return Utils.cmp(f(a), f(b));
1764 }));
1765 }
1766
1767 function sortWith(f, xs)
1768 {
1769 return fromArray(toArray(xs).sort(function(a, b) {
1770 var ord = f(a)(b).ctor;
1771 return ord === 'EQ' ? 0 : ord === 'LT' ? -1 : 1;
1772 }));
1773 }
1774
1775 function take(n, xs)
1776 {
1777 var arr = [];
1778 while (xs.ctor !== '[]' && n > 0)
1779 {
1780 arr.push(xs._0);
1781 xs = xs._1;
1782 --n;
1783 }
1784 return fromArray(arr);
1785 }
1786
1787
1788 Elm.Native.List.values = {
1789 Nil: Nil,
1790 Cons: Cons,
1791 cons: F2(Cons),
1792 toArray: toArray,
1793 fromArray: fromArray,
1794
1795 foldl: F3(foldl),
1796 foldr: F3(foldr),
1797
1798 map2: F3(map2),
1799 map3: F4(map3),
1800 map4: F5(map4),
1801 map5: F6(map5),
1802 sortBy: F2(sortBy),
1803 sortWith: F2(sortWith),
1804 take: F2(take)
1805 };
1806 return localRuntime.Native.List.values = Elm.Native.List.values;
1807};
1808
1809Elm.List = Elm.List || {};
1810Elm.List.make = function (_elm) {
1811 "use strict";
1812 _elm.List = _elm.List || {};
1813 if (_elm.List.values) return _elm.List.values;
1814 var _U = Elm.Native.Utils.make(_elm),$Basics = Elm.Basics.make(_elm),$Maybe = Elm.Maybe.make(_elm),$Native$List = Elm.Native.List.make(_elm);
1815 var _op = {};
1816 var sortWith = $Native$List.sortWith;
1817 var sortBy = $Native$List.sortBy;
1818 var sort = function (xs) { return A2(sortBy,$Basics.identity,xs);};
1819 var drop = F2(function (n,list) {
1820 drop: while (true) if (_U.cmp(n,0) < 1) return list; else {
1821 var _p0 = list;
1822 if (_p0.ctor === "[]") {
1823 return list;
1824 } else {
1825 var _v1 = n - 1,_v2 = _p0._1;
1826 n = _v1;
1827 list = _v2;
1828 continue drop;
1829 }
1830 }
1831 });
1832 var take = $Native$List.take;
1833 var map5 = $Native$List.map5;
1834 var map4 = $Native$List.map4;
1835 var map3 = $Native$List.map3;
1836 var map2 = $Native$List.map2;
1837 var any = F2(function (isOkay,list) {
1838 any: while (true) {
1839 var _p1 = list;
1840 if (_p1.ctor === "[]") {
1841 return false;
1842 } else {
1843 if (isOkay(_p1._0)) return true; else {
1844 var _v4 = isOkay,_v5 = _p1._1;
1845 isOkay = _v4;
1846 list = _v5;
1847 continue any;
1848 }
1849 }
1850 }
1851 });
1852 var all = F2(function (isOkay,list) { return $Basics.not(A2(any,function (_p2) { return $Basics.not(isOkay(_p2));},list));});
1853 var foldr = $Native$List.foldr;
1854 var foldl = $Native$List.foldl;
1855 var length = function (xs) { return A3(foldl,F2(function (_p3,i) { return i + 1;}),0,xs);};
1856 var sum = function (numbers) { return A3(foldl,F2(function (x,y) { return x + y;}),0,numbers);};
1857 var product = function (numbers) { return A3(foldl,F2(function (x,y) { return x * y;}),1,numbers);};
1858 var maximum = function (list) {
1859 var _p4 = list;
1860 if (_p4.ctor === "::") {
1861 return $Maybe.Just(A3(foldl,$Basics.max,_p4._0,_p4._1));
1862 } else {
1863 return $Maybe.Nothing;
1864 }
1865 };
1866 var minimum = function (list) {
1867 var _p5 = list;
1868 if (_p5.ctor === "::") {
1869 return $Maybe.Just(A3(foldl,$Basics.min,_p5._0,_p5._1));
1870 } else {
1871 return $Maybe.Nothing;
1872 }
1873 };
1874 var indexedMap = F2(function (f,xs) { return A3(map2,f,_U.range(0,length(xs) - 1),xs);});
1875 var member = F2(function (x,xs) { return A2(any,function (a) { return _U.eq(a,x);},xs);});
1876 var isEmpty = function (xs) { var _p6 = xs;if (_p6.ctor === "[]") { return true;} else { return false;}};
1877 var tail = function (list) { var _p7 = list;if (_p7.ctor === "::") { return $Maybe.Just(_p7._1);} else { return $Maybe.Nothing;}};
1878 var head = function (list) { var _p8 = list;if (_p8.ctor === "::") { return $Maybe.Just(_p8._0);} else { return $Maybe.Nothing;}};
1879 _op["::"] = $Native$List.cons;
1880 var map = F2(function (f,xs) { return A3(foldr,F2(function (x,acc) { return A2(_op["::"],f(x),acc);}),_U.list([]),xs);});
1881 var filter = F2(function (pred,xs) {
1882 var conditionalCons = F2(function (x,xs$) { return pred(x) ? A2(_op["::"],x,xs$) : xs$;});
1883 return A3(foldr,conditionalCons,_U.list([]),xs);
1884 });
1885 var maybeCons = F3(function (f,mx,xs) { var _p9 = f(mx);if (_p9.ctor === "Just") { return A2(_op["::"],_p9._0,xs);} else { return xs;}});
1886 var filterMap = F2(function (f,xs) { return A3(foldr,maybeCons(f),_U.list([]),xs);});
1887 var reverse = function (list) { return A3(foldl,F2(function (x,y) { return A2(_op["::"],x,y);}),_U.list([]),list);};
1888 var scanl = F3(function (f,b,xs) {
1889 var scan1 = F2(function (x,accAcc) {
1890 var _p10 = accAcc;
1891 if (_p10.ctor === "::") {
1892 return A2(_op["::"],A2(f,x,_p10._0),accAcc);
1893 } else {
1894 return _U.list([]);
1895 }
1896 });
1897 return reverse(A3(foldl,scan1,_U.list([b]),xs));
1898 });
1899 var append = F2(function (xs,ys) {
1900 var _p11 = ys;
1901 if (_p11.ctor === "[]") {
1902 return xs;
1903 } else {
1904 return A3(foldr,F2(function (x,y) { return A2(_op["::"],x,y);}),ys,xs);
1905 }
1906 });
1907 var concat = function (lists) { return A3(foldr,append,_U.list([]),lists);};
1908 var concatMap = F2(function (f,list) { return concat(A2(map,f,list));});
1909 var partition = F2(function (pred,list) {
1910 var step = F2(function (x,_p12) {
1911 var _p13 = _p12;
1912 var _p15 = _p13._0;
1913 var _p14 = _p13._1;
1914 return pred(x) ? {ctor: "_Tuple2",_0: A2(_op["::"],x,_p15),_1: _p14} : {ctor: "_Tuple2",_0: _p15,_1: A2(_op["::"],x,_p14)};
1915 });
1916 return A3(foldr,step,{ctor: "_Tuple2",_0: _U.list([]),_1: _U.list([])},list);
1917 });
1918 var unzip = function (pairs) {
1919 var step = F2(function (_p17,_p16) {
1920 var _p18 = _p17;
1921 var _p19 = _p16;
1922 return {ctor: "_Tuple2",_0: A2(_op["::"],_p18._0,_p19._0),_1: A2(_op["::"],_p18._1,_p19._1)};
1923 });
1924 return A3(foldr,step,{ctor: "_Tuple2",_0: _U.list([]),_1: _U.list([])},pairs);
1925 };
1926 var intersperse = F2(function (sep,xs) {
1927 var _p20 = xs;
1928 if (_p20.ctor === "[]") {
1929 return _U.list([]);
1930 } else {
1931 var step = F2(function (x,rest) { return A2(_op["::"],sep,A2(_op["::"],x,rest));});
1932 var spersed = A3(foldr,step,_U.list([]),_p20._1);
1933 return A2(_op["::"],_p20._0,spersed);
1934 }
1935 });
1936 var repeatHelp = F3(function (result,n,value) {
1937 repeatHelp: while (true) if (_U.cmp(n,0) < 1) return result; else {
1938 var _v18 = A2(_op["::"],value,result),_v19 = n - 1,_v20 = value;
1939 result = _v18;
1940 n = _v19;
1941 value = _v20;
1942 continue repeatHelp;
1943 }
1944 });
1945 var repeat = F2(function (n,value) { return A3(repeatHelp,_U.list([]),n,value);});
1946 return _elm.List.values = {_op: _op
1947 ,isEmpty: isEmpty
1948 ,length: length
1949 ,reverse: reverse
1950 ,member: member
1951 ,head: head
1952 ,tail: tail
1953 ,filter: filter
1954 ,take: take
1955 ,drop: drop
1956 ,repeat: repeat
1957 ,append: append
1958 ,concat: concat
1959 ,intersperse: intersperse
1960 ,partition: partition
1961 ,unzip: unzip
1962 ,map: map
1963 ,map2: map2
1964 ,map3: map3
1965 ,map4: map4
1966 ,map5: map5
1967 ,filterMap: filterMap
1968 ,concatMap: concatMap
1969 ,indexedMap: indexedMap
1970 ,foldr: foldr
1971 ,foldl: foldl
1972 ,sum: sum
1973 ,product: product
1974 ,maximum: maximum
1975 ,minimum: minimum
1976 ,all: all
1977 ,any: any
1978 ,scanl: scanl
1979 ,sort: sort
1980 ,sortBy: sortBy
1981 ,sortWith: sortWith};
1982};
1983Elm.Native.Transform2D = {};
1984Elm.Native.Transform2D.make = function(localRuntime) {
1985 localRuntime.Native = localRuntime.Native || {};
1986 localRuntime.Native.Transform2D = localRuntime.Native.Transform2D || {};
1987 if (localRuntime.Native.Transform2D.values)
1988 {
1989 return localRuntime.Native.Transform2D.values;
1990 }
1991
1992 var A;
1993 if (typeof Float32Array === 'undefined')
1994 {
1995 A = function(arr)
1996 {
1997 this.length = arr.length;
1998 this[0] = arr[0];
1999 this[1] = arr[1];
2000 this[2] = arr[2];
2001 this[3] = arr[3];
2002 this[4] = arr[4];
2003 this[5] = arr[5];
2004 };
2005 }
2006 else
2007 {
2008 A = Float32Array;
2009 }
2010
2011 // layout of matrix in an array is
2012 //
2013 // | m11 m12 dx |
2014 // | m21 m22 dy |
2015 // | 0 0 1 |
2016 //
2017 // new A([ m11, m12, dx, m21, m22, dy ])
2018
2019 var identity = new A([1, 0, 0, 0, 1, 0]);
2020 function matrix(m11, m12, m21, m22, dx, dy)
2021 {
2022 return new A([m11, m12, dx, m21, m22, dy]);
2023 }
2024
2025 function rotation(t)
2026 {
2027 var c = Math.cos(t);
2028 var s = Math.sin(t);
2029 return new A([c, -s, 0, s, c, 0]);
2030 }
2031
2032 function rotate(t, m)
2033 {
2034 var c = Math.cos(t);
2035 var s = Math.sin(t);
2036 var m11 = m[0], m12 = m[1], m21 = m[3], m22 = m[4];
2037 return new A([m11 * c + m12 * s, -m11 * s + m12 * c, m[2],
2038 m21 * c + m22 * s, -m21 * s + m22 * c, m[5]]);
2039 }
2040 /*
2041 function move(xy,m) {
2042 var x = xy._0;
2043 var y = xy._1;
2044 var m11 = m[0], m12 = m[1], m21 = m[3], m22 = m[4];
2045 return new A([m11, m12, m11*x + m12*y + m[2],
2046 m21, m22, m21*x + m22*y + m[5]]);
2047 }
2048 function scale(s,m) { return new A([m[0]*s, m[1]*s, m[2], m[3]*s, m[4]*s, m[5]]); }
2049 function scaleX(x,m) { return new A([m[0]*x, m[1], m[2], m[3]*x, m[4], m[5]]); }
2050 function scaleY(y,m) { return new A([m[0], m[1]*y, m[2], m[3], m[4]*y, m[5]]); }
2051 function reflectX(m) { return new A([-m[0], m[1], m[2], -m[3], m[4], m[5]]); }
2052 function reflectY(m) { return new A([m[0], -m[1], m[2], m[3], -m[4], m[5]]); }
2053
2054 function transform(m11, m21, m12, m22, mdx, mdy, n) {
2055 var n11 = n[0], n12 = n[1], n21 = n[3], n22 = n[4], ndx = n[2], ndy = n[5];
2056 return new A([m11*n11 + m12*n21,
2057 m11*n12 + m12*n22,
2058 m11*ndx + m12*ndy + mdx,
2059 m21*n11 + m22*n21,
2060 m21*n12 + m22*n22,
2061 m21*ndx + m22*ndy + mdy]);
2062 }
2063 */
2064 function multiply(m, n)
2065 {
2066 var m11 = m[0], m12 = m[1], m21 = m[3], m22 = m[4], mdx = m[2], mdy = m[5];
2067 var n11 = n[0], n12 = n[1], n21 = n[3], n22 = n[4], ndx = n[2], ndy = n[5];
2068 return new A([m11 * n11 + m12 * n21,
2069 m11 * n12 + m12 * n22,
2070 m11 * ndx + m12 * ndy + mdx,
2071 m21 * n11 + m22 * n21,
2072 m21 * n12 + m22 * n22,
2073 m21 * ndx + m22 * ndy + mdy]);
2074 }
2075
2076 return localRuntime.Native.Transform2D.values = {
2077 identity: identity,
2078 matrix: F6(matrix),
2079 rotation: rotation,
2080 multiply: F2(multiply)
2081 /*
2082 transform: F7(transform),
2083 rotate: F2(rotate),
2084 move: F2(move),
2085 scale: F2(scale),
2086 scaleX: F2(scaleX),
2087 scaleY: F2(scaleY),
2088 reflectX: reflectX,
2089 reflectY: reflectY
2090 */
2091 };
2092};
2093
2094Elm.Transform2D = Elm.Transform2D || {};
2095Elm.Transform2D.make = function (_elm) {
2096 "use strict";
2097 _elm.Transform2D = _elm.Transform2D || {};
2098 if (_elm.Transform2D.values) return _elm.Transform2D.values;
2099 var _U = Elm.Native.Utils.make(_elm),$Native$Transform2D = Elm.Native.Transform2D.make(_elm);
2100 var _op = {};
2101 var multiply = $Native$Transform2D.multiply;
2102 var rotation = $Native$Transform2D.rotation;
2103 var matrix = $Native$Transform2D.matrix;
2104 var translation = F2(function (x,y) { return A6(matrix,1,0,0,1,x,y);});
2105 var scale = function (s) { return A6(matrix,s,0,0,s,0,0);};
2106 var scaleX = function (x) { return A6(matrix,x,0,0,1,0,0);};
2107 var scaleY = function (y) { return A6(matrix,1,0,0,y,0,0);};
2108 var identity = $Native$Transform2D.identity;
2109 var Transform2D = {ctor: "Transform2D"};
2110 return _elm.Transform2D.values = {_op: _op
2111 ,identity: identity
2112 ,matrix: matrix
2113 ,multiply: multiply
2114 ,rotation: rotation
2115 ,translation: translation
2116 ,scale: scale
2117 ,scaleX: scaleX
2118 ,scaleY: scaleY};
2119};
2120
2121// setup
2122Elm.Native = Elm.Native || {};
2123Elm.Native.Graphics = Elm.Native.Graphics || {};
2124Elm.Native.Graphics.Collage = Elm.Native.Graphics.Collage || {};
2125
2126// definition
2127Elm.Native.Graphics.Collage.make = function(localRuntime) {
2128 'use strict';
2129
2130 // attempt to short-circuit
2131 localRuntime.Native = localRuntime.Native || {};
2132 localRuntime.Native.Graphics = localRuntime.Native.Graphics || {};
2133 localRuntime.Native.Graphics.Collage = localRuntime.Native.Graphics.Collage || {};
2134 if ('values' in localRuntime.Native.Graphics.Collage)
2135 {
2136 return localRuntime.Native.Graphics.Collage.values;
2137 }
2138
2139 // okay, we cannot short-ciruit, so now we define everything
2140 var Color = Elm.Native.Color.make(localRuntime);
2141 var List = Elm.Native.List.make(localRuntime);
2142 var NativeElement = Elm.Native.Graphics.Element.make(localRuntime);
2143 var Transform = Elm.Transform2D.make(localRuntime);
2144 var Utils = Elm.Native.Utils.make(localRuntime);
2145
2146 function setStrokeStyle(ctx, style)
2147 {
2148 ctx.lineWidth = style.width;
2149
2150 var cap = style.cap.ctor;
2151 ctx.lineCap = cap === 'Flat'
2152 ? 'butt'
2153 : cap === 'Round'
2154 ? 'round'
2155 : 'square';
2156
2157 var join = style.join.ctor;
2158 ctx.lineJoin = join === 'Smooth'
2159 ? 'round'
2160 : join === 'Sharp'
2161 ? 'miter'
2162 : 'bevel';
2163
2164 ctx.miterLimit = style.join._0 || 10;
2165 ctx.strokeStyle = Color.toCss(style.color);
2166 }
2167
2168 function setFillStyle(redo, ctx, style)
2169 {
2170 var sty = style.ctor;
2171 ctx.fillStyle = sty === 'Solid'
2172 ? Color.toCss(style._0)
2173 : sty === 'Texture'
2174 ? texture(redo, ctx, style._0)
2175 : gradient(ctx, style._0);
2176 }
2177
2178 function trace(ctx, path)
2179 {
2180 var points = List.toArray(path);
2181 var i = points.length - 1;
2182 if (i <= 0)
2183 {
2184 return;
2185 }
2186 ctx.moveTo(points[i]._0, points[i]._1);
2187 while (i--)
2188 {
2189 ctx.lineTo(points[i]._0, points[i]._1);
2190 }
2191 if (path.closed)
2192 {
2193 i = points.length - 1;
2194 ctx.lineTo(points[i]._0, points[i]._1);
2195 }
2196 }
2197
2198 function line(ctx, style, path)
2199 {
2200 if (style.dashing.ctor === '[]')
2201 {
2202 trace(ctx, path);
2203 }
2204 else
2205 {
2206 customLineHelp(ctx, style, path);
2207 }
2208 ctx.scale(1, -1);
2209 ctx.stroke();
2210 }
2211
2212 function customLineHelp(ctx, style, path)
2213 {
2214 var points = List.toArray(path);
2215 if (path.closed)
2216 {
2217 points.push(points[0]);
2218 }
2219 var pattern = List.toArray(style.dashing);
2220 var i = points.length - 1;
2221 if (i <= 0)
2222 {
2223 return;
2224 }
2225 var x0 = points[i]._0, y0 = points[i]._1;
2226 var x1 = 0, y1 = 0, dx = 0, dy = 0, remaining = 0;
2227 var pindex = 0, plen = pattern.length;
2228 var draw = true, segmentLength = pattern[0];
2229 ctx.moveTo(x0, y0);
2230 while (i--)
2231 {
2232 x1 = points[i]._0;
2233 y1 = points[i]._1;
2234 dx = x1 - x0;
2235 dy = y1 - y0;
2236 remaining = Math.sqrt(dx * dx + dy * dy);
2237 while (segmentLength <= remaining)
2238 {
2239 x0 += dx * segmentLength / remaining;
2240 y0 += dy * segmentLength / remaining;
2241 ctx[draw ? 'lineTo' : 'moveTo'](x0, y0);
2242 // update starting position
2243 dx = x1 - x0;
2244 dy = y1 - y0;
2245 remaining = Math.sqrt(dx * dx + dy * dy);
2246 // update pattern
2247 draw = !draw;
2248 pindex = (pindex + 1) % plen;
2249 segmentLength = pattern[pindex];
2250 }
2251 if (remaining > 0)
2252 {
2253 ctx[draw ? 'lineTo' : 'moveTo'](x1, y1);
2254 segmentLength -= remaining;
2255 }
2256 x0 = x1;
2257 y0 = y1;
2258 }
2259 }
2260
2261 function drawLine(ctx, style, path)
2262 {
2263 setStrokeStyle(ctx, style);
2264 return line(ctx, style, path);
2265 }
2266
2267 function texture(redo, ctx, src)
2268 {
2269 var img = new Image();
2270 img.src = src;
2271 img.onload = redo;
2272 return ctx.createPattern(img, 'repeat');
2273 }
2274
2275 function gradient(ctx, grad)
2276 {
2277 var g;
2278 var stops = [];
2279 if (grad.ctor === 'Linear')
2280 {
2281 var p0 = grad._0, p1 = grad._1;
2282 g = ctx.createLinearGradient(p0._0, -p0._1, p1._0, -p1._1);
2283 stops = List.toArray(grad._2);
2284 }
2285 else
2286 {
2287 var p0 = grad._0, p2 = grad._2;
2288 g = ctx.createRadialGradient(p0._0, -p0._1, grad._1, p2._0, -p2._1, grad._3);
2289 stops = List.toArray(grad._4);
2290 }
2291 var len = stops.length;
2292 for (var i = 0; i < len; ++i)
2293 {
2294 var stop = stops[i];
2295 g.addColorStop(stop._0, Color.toCss(stop._1));
2296 }
2297 return g;
2298 }
2299
2300 function drawShape(redo, ctx, style, path)
2301 {
2302 trace(ctx, path);
2303 setFillStyle(redo, ctx, style);
2304 ctx.scale(1, -1);
2305 ctx.fill();
2306 }
2307
2308
2309 // TEXT RENDERING
2310
2311 function fillText(redo, ctx, text)
2312 {
2313 drawText(ctx, text, ctx.fillText);
2314 }
2315
2316 function strokeText(redo, ctx, style, text)
2317 {
2318 setStrokeStyle(ctx, style);
2319 // Use native canvas API for dashes only for text for now
2320 // Degrades to non-dashed on IE 9 + 10
2321 if (style.dashing.ctor !== '[]' && ctx.setLineDash)
2322 {
2323 var pattern = List.toArray(style.dashing);
2324 ctx.setLineDash(pattern);
2325 }
2326 drawText(ctx, text, ctx.strokeText);
2327 }
2328
2329 function drawText(ctx, text, canvasDrawFn)
2330 {
2331 var textChunks = chunkText(defaultContext, text);
2332
2333 var totalWidth = 0;
2334 var maxHeight = 0;
2335 var numChunks = textChunks.length;
2336
2337 ctx.scale(1,-1);
2338
2339 for (var i = numChunks; i--; )
2340 {
2341 var chunk = textChunks[i];
2342 ctx.font = chunk.font;
2343 var metrics = ctx.measureText(chunk.text);
2344 chunk.width = metrics.width;
2345 totalWidth += chunk.width;
2346 if (chunk.height > maxHeight)
2347 {
2348 maxHeight = chunk.height;
2349 }
2350 }
2351
2352 var x = -totalWidth / 2.0;
2353 for (var i = 0; i < numChunks; ++i)
2354 {
2355 var chunk = textChunks[i];
2356 ctx.font = chunk.font;
2357 ctx.fillStyle = chunk.color;
2358 canvasDrawFn.call(ctx, chunk.text, x, maxHeight / 2);
2359 x += chunk.width;
2360 }
2361 }
2362
2363 function toFont(props)
2364 {
2365 return [
2366 props['font-style'],
2367 props['font-variant'],
2368 props['font-weight'],
2369 props['font-size'],
2370 props['font-family']
2371 ].join(' ');
2372 }
2373
2374
2375 // Convert the object returned by the text module
2376 // into something we can use for styling canvas text
2377 function chunkText(context, text)
2378 {
2379 var tag = text.ctor;
2380 if (tag === 'Text:Append')
2381 {
2382 var leftChunks = chunkText(context, text._0);
2383 var rightChunks = chunkText(context, text._1);
2384 return leftChunks.concat(rightChunks);
2385 }
2386 if (tag === 'Text:Text')
2387 {
2388 return [{
2389 text: text._0,
2390 color: context.color,
2391 height: context['font-size'].slice(0, -2) | 0,
2392 font: toFont(context)
2393 }];
2394 }
2395 if (tag === 'Text:Meta')
2396 {
2397 var newContext = freshContext(text._0, context);
2398 return chunkText(newContext, text._1);
2399 }
2400 }
2401
2402 function freshContext(props, ctx)
2403 {
2404 return {
2405 'font-style': props['font-style'] || ctx['font-style'],
2406 'font-variant': props['font-variant'] || ctx['font-variant'],
2407 'font-weight': props['font-weight'] || ctx['font-weight'],
2408 'font-size': props['font-size'] || ctx['font-size'],
2409 'font-family': props['font-family'] || ctx['font-family'],
2410 'color': props['color'] || ctx['color']
2411 };
2412 }
2413
2414 var defaultContext = {
2415 'font-style': 'normal',
2416 'font-variant': 'normal',
2417 'font-weight': 'normal',
2418 'font-size': '12px',
2419 'font-family': 'sans-serif',
2420 'color': 'black'
2421 };
2422
2423
2424 // IMAGES
2425
2426 function drawImage(redo, ctx, form)
2427 {
2428 var img = new Image();
2429 img.onload = redo;
2430 img.src = form._3;
2431 var w = form._0,
2432 h = form._1,
2433 pos = form._2,
2434 srcX = pos._0,
2435 srcY = pos._1,
2436 srcW = w,
2437 srcH = h,
2438 destX = -w / 2,
2439 destY = -h / 2,
2440 destW = w,
2441 destH = h;
2442
2443 ctx.scale(1, -1);
2444 ctx.drawImage(img, srcX, srcY, srcW, srcH, destX, destY, destW, destH);
2445 }
2446
2447 function renderForm(redo, ctx, form)
2448 {
2449 ctx.save();
2450
2451 var x = form.x,
2452 y = form.y,
2453 theta = form.theta,
2454 scale = form.scale;
2455
2456 if (x !== 0 || y !== 0)
2457 {
2458 ctx.translate(x, y);
2459 }
2460 if (theta !== 0)
2461 {
2462 ctx.rotate(theta % (Math.PI * 2));
2463 }
2464 if (scale !== 1)
2465 {
2466 ctx.scale(scale, scale);
2467 }
2468 if (form.alpha !== 1)
2469 {
2470 ctx.globalAlpha = ctx.globalAlpha * form.alpha;
2471 }
2472
2473 ctx.beginPath();
2474 var f = form.form;
2475 switch (f.ctor)
2476 {
2477 case 'FPath':
2478 drawLine(ctx, f._0, f._1);
2479 break;
2480
2481 case 'FImage':
2482 drawImage(redo, ctx, f);
2483 break;
2484
2485 case 'FShape':
2486 if (f._0.ctor === 'Line')
2487 {
2488 f._1.closed = true;
2489 drawLine(ctx, f._0._0, f._1);
2490 }
2491 else
2492 {
2493 drawShape(redo, ctx, f._0._0, f._1);
2494 }
2495 break;
2496
2497 case 'FText':
2498 fillText(redo, ctx, f._0);
2499 break;
2500
2501 case 'FOutlinedText':
2502 strokeText(redo, ctx, f._0, f._1);
2503 break;
2504 }
2505 ctx.restore();
2506 }
2507
2508 function formToMatrix(form)
2509 {
2510 var scale = form.scale;
2511 var matrix = A6( Transform.matrix, scale, 0, 0, scale, form.x, form.y );
2512
2513 var theta = form.theta;
2514 if (theta !== 0)
2515 {
2516 matrix = A2( Transform.multiply, matrix, Transform.rotation(theta) );
2517 }
2518
2519 return matrix;
2520 }
2521
2522 function str(n)
2523 {
2524 if (n < 0.00001 && n > -0.00001)
2525 {
2526 return 0;
2527 }
2528 return n;
2529 }
2530
2531 function makeTransform(w, h, form, matrices)
2532 {
2533 var props = form.form._0._0.props;
2534 var m = A6( Transform.matrix, 1, 0, 0, -1,
2535 (w - props.width ) / 2,
2536 (h - props.height) / 2 );
2537 var len = matrices.length;
2538 for (var i = 0; i < len; ++i)
2539 {
2540 m = A2( Transform.multiply, m, matrices[i] );
2541 }
2542 m = A2( Transform.multiply, m, formToMatrix(form) );
2543
2544 return 'matrix(' +
2545 str( m[0]) + ', ' + str( m[3]) + ', ' +
2546 str(-m[1]) + ', ' + str(-m[4]) + ', ' +
2547 str( m[2]) + ', ' + str( m[5]) + ')';
2548 }
2549
2550 function stepperHelp(list)
2551 {
2552 var arr = List.toArray(list);
2553 var i = 0;
2554 function peekNext()
2555 {
2556 return i < arr.length ? arr[i]._0.form.ctor : '';
2557 }
2558 // assumes that there is a next element
2559 function next()
2560 {
2561 var out = arr[i]._0;
2562 ++i;
2563 return out;
2564 }
2565 return {
2566 peekNext: peekNext,
2567 next: next
2568 };
2569 }
2570
2571 function formStepper(forms)
2572 {
2573 var ps = [stepperHelp(forms)];
2574 var matrices = [];
2575 var alphas = [];
2576 function peekNext()
2577 {
2578 var len = ps.length;
2579 var formType = '';
2580 for (var i = 0; i < len; ++i )
2581 {
2582 if (formType = ps[i].peekNext()) return formType;
2583 }
2584 return '';
2585 }
2586 // assumes that there is a next element
2587 function next(ctx)
2588 {
2589 while (!ps[0].peekNext())
2590 {
2591 ps.shift();
2592 matrices.pop();
2593 alphas.shift();
2594 if (ctx)
2595 {
2596 ctx.restore();
2597 }
2598 }
2599 var out = ps[0].next();
2600 var f = out.form;
2601 if (f.ctor === 'FGroup')
2602 {
2603 ps.unshift(stepperHelp(f._1));
2604 var m = A2(Transform.multiply, f._0, formToMatrix(out));
2605 ctx.save();
2606 ctx.transform(m[0], m[3], m[1], m[4], m[2], m[5]);
2607 matrices.push(m);
2608
2609 var alpha = (alphas[0] || 1) * out.alpha;
2610 alphas.unshift(alpha);
2611 ctx.globalAlpha = alpha;
2612 }
2613 return out;
2614 }
2615 function transforms()
2616 {
2617 return matrices;
2618 }
2619 function alpha()
2620 {
2621 return alphas[0] || 1;
2622 }
2623 return {
2624 peekNext: peekNext,
2625 next: next,
2626 transforms: transforms,
2627 alpha: alpha
2628 };
2629 }
2630
2631 function makeCanvas(w, h)
2632 {
2633 var canvas = NativeElement.createNode('canvas');
2634 canvas.style.width = w + 'px';
2635 canvas.style.height = h + 'px';
2636 canvas.style.display = 'block';
2637 canvas.style.position = 'absolute';
2638 var ratio = window.devicePixelRatio || 1;
2639 canvas.width = w * ratio;
2640 canvas.height = h * ratio;
2641 return canvas;
2642 }
2643
2644 function render(model)
2645 {
2646 var div = NativeElement.createNode('div');
2647 div.style.overflow = 'hidden';
2648 div.style.position = 'relative';
2649 update(div, model, model);
2650 return div;
2651 }
2652
2653 function nodeStepper(w, h, div)
2654 {
2655 var kids = div.childNodes;
2656 var i = 0;
2657 var ratio = window.devicePixelRatio || 1;
2658
2659 function transform(transforms, ctx)
2660 {
2661 ctx.translate( w / 2 * ratio, h / 2 * ratio );
2662 ctx.scale( ratio, -ratio );
2663 var len = transforms.length;
2664 for (var i = 0; i < len; ++i)
2665 {
2666 var m = transforms[i];
2667 ctx.save();
2668 ctx.transform(m[0], m[3], m[1], m[4], m[2], m[5]);
2669 }
2670 return ctx;
2671 }
2672 function nextContext(transforms)
2673 {
2674 while (i < kids.length)
2675 {
2676 var node = kids[i];
2677 if (node.getContext)
2678 {
2679 node.width = w * ratio;
2680 node.height = h * ratio;
2681 node.style.width = w + 'px';
2682 node.style.height = h + 'px';
2683 ++i;
2684 return transform(transforms, node.getContext('2d'));
2685 }
2686 div.removeChild(node);
2687 }
2688 var canvas = makeCanvas(w, h);
2689 div.appendChild(canvas);
2690 // we have added a new node, so we must step our position
2691 ++i;
2692 return transform(transforms, canvas.getContext('2d'));
2693 }
2694 function addElement(matrices, alpha, form)
2695 {
2696 var kid = kids[i];
2697 var elem = form.form._0;
2698
2699 var node = (!kid || kid.getContext)
2700 ? NativeElement.render(elem)
2701 : NativeElement.update(kid, kid.oldElement, elem);
2702
2703 node.style.position = 'absolute';
2704 node.style.opacity = alpha * form.alpha * elem._0.props.opacity;
2705 NativeElement.addTransform(node.style, makeTransform(w, h, form, matrices));
2706 node.oldElement = elem;
2707 ++i;
2708 if (!kid)
2709 {
2710 div.appendChild(node);
2711 }
2712 else
2713 {
2714 div.insertBefore(node, kid);
2715 }
2716 }
2717 function clearRest()
2718 {
2719 while (i < kids.length)
2720 {
2721 div.removeChild(kids[i]);
2722 }
2723 }
2724 return {
2725 nextContext: nextContext,
2726 addElement: addElement,
2727 clearRest: clearRest
2728 };
2729 }
2730
2731
2732 function update(div, _, model)
2733 {
2734 var w = model.w;
2735 var h = model.h;
2736
2737 var forms = formStepper(model.forms);
2738 var nodes = nodeStepper(w, h, div);
2739 var ctx = null;
2740 var formType = '';
2741
2742 while (formType = forms.peekNext())
2743 {
2744 // make sure we have context if we need it
2745 if (ctx === null && formType !== 'FElement')
2746 {
2747 ctx = nodes.nextContext(forms.transforms());
2748 ctx.globalAlpha = forms.alpha();
2749 }
2750
2751 var form = forms.next(ctx);
2752 // if it is FGroup, all updates are made within formStepper when next is called.
2753 if (formType === 'FElement')
2754 {
2755 // update or insert an element, get a new context
2756 nodes.addElement(forms.transforms(), forms.alpha(), form);
2757 ctx = null;
2758 }
2759 else if (formType !== 'FGroup')
2760 {
2761 renderForm(function() { update(div, model, model); }, ctx, form);
2762 }
2763 }
2764 nodes.clearRest();
2765 return div;
2766 }
2767
2768
2769 function collage(w, h, forms)
2770 {
2771 return A3(NativeElement.newElement, w, h, {
2772 ctor: 'Custom',
2773 type: 'Collage',
2774 render: render,
2775 update: update,
2776 model: {w: w, h: h, forms: forms}
2777 });
2778 }
2779
2780 return localRuntime.Native.Graphics.Collage.values = {
2781 collage: F3(collage)
2782 };
2783};
2784
2785Elm.Native.Color = {};
2786Elm.Native.Color.make = function(localRuntime) {
2787 localRuntime.Native = localRuntime.Native || {};
2788 localRuntime.Native.Color = localRuntime.Native.Color || {};
2789 if (localRuntime.Native.Color.values)
2790 {
2791 return localRuntime.Native.Color.values;
2792 }
2793
2794 function toCss(c)
2795 {
2796 var format = '';
2797 var colors = '';
2798 if (c.ctor === 'RGBA')
2799 {
2800 format = 'rgb';
2801 colors = c._0 + ', ' + c._1 + ', ' + c._2;
2802 }
2803 else
2804 {
2805 format = 'hsl';
2806 colors = (c._0 * 180 / Math.PI) + ', ' +
2807 (c._1 * 100) + '%, ' +
2808 (c._2 * 100) + '%';
2809 }
2810 if (c._3 === 1)
2811 {
2812 return format + '(' + colors + ')';
2813 }
2814 else
2815 {
2816 return format + 'a(' + colors + ', ' + c._3 + ')';
2817 }
2818 }
2819
2820 return localRuntime.Native.Color.values = {
2821 toCss: toCss
2822 };
2823};
2824
2825Elm.Color = Elm.Color || {};
2826Elm.Color.make = function (_elm) {
2827 "use strict";
2828 _elm.Color = _elm.Color || {};
2829 if (_elm.Color.values) return _elm.Color.values;
2830 var _U = Elm.Native.Utils.make(_elm),$Basics = Elm.Basics.make(_elm);
2831 var _op = {};
2832 var Radial = F5(function (a,b,c,d,e) { return {ctor: "Radial",_0: a,_1: b,_2: c,_3: d,_4: e};});
2833 var radial = Radial;
2834 var Linear = F3(function (a,b,c) { return {ctor: "Linear",_0: a,_1: b,_2: c};});
2835 var linear = Linear;
2836 var fmod = F2(function (f,n) { var integer = $Basics.floor(f);return $Basics.toFloat(A2($Basics._op["%"],integer,n)) + f - $Basics.toFloat(integer);});
2837 var rgbToHsl = F3(function (red,green,blue) {
2838 var b = $Basics.toFloat(blue) / 255;
2839 var g = $Basics.toFloat(green) / 255;
2840 var r = $Basics.toFloat(red) / 255;
2841 var cMax = A2($Basics.max,A2($Basics.max,r,g),b);
2842 var cMin = A2($Basics.min,A2($Basics.min,r,g),b);
2843 var c = cMax - cMin;
2844 var lightness = (cMax + cMin) / 2;
2845 var saturation = _U.eq(lightness,0) ? 0 : c / (1 - $Basics.abs(2 * lightness - 1));
2846 var hue = $Basics.degrees(60) * (_U.eq(cMax,r) ? A2(fmod,(g - b) / c,6) : _U.eq(cMax,g) ? (b - r) / c + 2 : (r - g) / c + 4);
2847 return {ctor: "_Tuple3",_0: hue,_1: saturation,_2: lightness};
2848 });
2849 var hslToRgb = F3(function (hue,saturation,lightness) {
2850 var hue$ = hue / $Basics.degrees(60);
2851 var chroma = (1 - $Basics.abs(2 * lightness - 1)) * saturation;
2852 var x = chroma * (1 - $Basics.abs(A2(fmod,hue$,2) - 1));
2853 var _p0 = _U.cmp(hue$,0) < 0 ? {ctor: "_Tuple3",_0: 0,_1: 0,_2: 0} : _U.cmp(hue$,1) < 0 ? {ctor: "_Tuple3",_0: chroma,_1: x,_2: 0} : _U.cmp(hue$,
2854 2) < 0 ? {ctor: "_Tuple3",_0: x,_1: chroma,_2: 0} : _U.cmp(hue$,3) < 0 ? {ctor: "_Tuple3",_0: 0,_1: chroma,_2: x} : _U.cmp(hue$,4) < 0 ? {ctor: "_Tuple3"
2855 ,_0: 0
2856 ,_1: x
2857 ,_2: chroma} : _U.cmp(hue$,
2858 5) < 0 ? {ctor: "_Tuple3",_0: x,_1: 0,_2: chroma} : _U.cmp(hue$,6) < 0 ? {ctor: "_Tuple3",_0: chroma,_1: 0,_2: x} : {ctor: "_Tuple3",_0: 0,_1: 0,_2: 0};
2859 var r = _p0._0;
2860 var g = _p0._1;
2861 var b = _p0._2;
2862 var m = lightness - chroma / 2;
2863 return {ctor: "_Tuple3",_0: r + m,_1: g + m,_2: b + m};
2864 });
2865 var toRgb = function (color) {
2866 var _p1 = color;
2867 if (_p1.ctor === "RGBA") {
2868 return {red: _p1._0,green: _p1._1,blue: _p1._2,alpha: _p1._3};
2869 } else {
2870 var _p2 = A3(hslToRgb,_p1._0,_p1._1,_p1._2);
2871 var r = _p2._0;
2872 var g = _p2._1;
2873 var b = _p2._2;
2874 return {red: $Basics.round(255 * r),green: $Basics.round(255 * g),blue: $Basics.round(255 * b),alpha: _p1._3};
2875 }
2876 };
2877 var toHsl = function (color) {
2878 var _p3 = color;
2879 if (_p3.ctor === "HSLA") {
2880 return {hue: _p3._0,saturation: _p3._1,lightness: _p3._2,alpha: _p3._3};
2881 } else {
2882 var _p4 = A3(rgbToHsl,_p3._0,_p3._1,_p3._2);
2883 var h = _p4._0;
2884 var s = _p4._1;
2885 var l = _p4._2;
2886 return {hue: h,saturation: s,lightness: l,alpha: _p3._3};
2887 }
2888 };
2889 var HSLA = F4(function (a,b,c,d) { return {ctor: "HSLA",_0: a,_1: b,_2: c,_3: d};});
2890 var hsla = F4(function (hue,saturation,lightness,alpha) {
2891 return A4(HSLA,hue - $Basics.turns($Basics.toFloat($Basics.floor(hue / (2 * $Basics.pi)))),saturation,lightness,alpha);
2892 });
2893 var hsl = F3(function (hue,saturation,lightness) { return A4(hsla,hue,saturation,lightness,1);});
2894 var complement = function (color) {
2895 var _p5 = color;
2896 if (_p5.ctor === "HSLA") {
2897 return A4(hsla,_p5._0 + $Basics.degrees(180),_p5._1,_p5._2,_p5._3);
2898 } else {
2899 var _p6 = A3(rgbToHsl,_p5._0,_p5._1,_p5._2);
2900 var h = _p6._0;
2901 var s = _p6._1;
2902 var l = _p6._2;
2903 return A4(hsla,h + $Basics.degrees(180),s,l,_p5._3);
2904 }
2905 };
2906 var grayscale = function (p) { return A4(HSLA,0,0,1 - p,1);};
2907 var greyscale = function (p) { return A4(HSLA,0,0,1 - p,1);};
2908 var RGBA = F4(function (a,b,c,d) { return {ctor: "RGBA",_0: a,_1: b,_2: c,_3: d};});
2909 var rgba = RGBA;
2910 var rgb = F3(function (r,g,b) { return A4(RGBA,r,g,b,1);});
2911 var lightRed = A4(RGBA,239,41,41,1);
2912 var red = A4(RGBA,204,0,0,1);
2913 var darkRed = A4(RGBA,164,0,0,1);
2914 var lightOrange = A4(RGBA,252,175,62,1);
2915 var orange = A4(RGBA,245,121,0,1);
2916 var darkOrange = A4(RGBA,206,92,0,1);
2917 var lightYellow = A4(RGBA,255,233,79,1);
2918 var yellow = A4(RGBA,237,212,0,1);
2919 var darkYellow = A4(RGBA,196,160,0,1);
2920 var lightGreen = A4(RGBA,138,226,52,1);
2921 var green = A4(RGBA,115,210,22,1);
2922 var darkGreen = A4(RGBA,78,154,6,1);
2923 var lightBlue = A4(RGBA,114,159,207,1);
2924 var blue = A4(RGBA,52,101,164,1);
2925 var darkBlue = A4(RGBA,32,74,135,1);
2926 var lightPurple = A4(RGBA,173,127,168,1);
2927 var purple = A4(RGBA,117,80,123,1);
2928 var darkPurple = A4(RGBA,92,53,102,1);
2929 var lightBrown = A4(RGBA,233,185,110,1);
2930 var brown = A4(RGBA,193,125,17,1);
2931 var darkBrown = A4(RGBA,143,89,2,1);
2932 var black = A4(RGBA,0,0,0,1);
2933 var white = A4(RGBA,255,255,255,1);
2934 var lightGrey = A4(RGBA,238,238,236,1);
2935 var grey = A4(RGBA,211,215,207,1);
2936 var darkGrey = A4(RGBA,186,189,182,1);
2937 var lightGray = A4(RGBA,238,238,236,1);
2938 var gray = A4(RGBA,211,215,207,1);
2939 var darkGray = A4(RGBA,186,189,182,1);
2940 var lightCharcoal = A4(RGBA,136,138,133,1);
2941 var charcoal = A4(RGBA,85,87,83,1);
2942 var darkCharcoal = A4(RGBA,46,52,54,1);
2943 return _elm.Color.values = {_op: _op
2944 ,rgb: rgb
2945 ,rgba: rgba
2946 ,hsl: hsl
2947 ,hsla: hsla
2948 ,greyscale: greyscale
2949 ,grayscale: grayscale
2950 ,complement: complement
2951 ,linear: linear
2952 ,radial: radial
2953 ,toRgb: toRgb
2954 ,toHsl: toHsl
2955 ,red: red
2956 ,orange: orange
2957 ,yellow: yellow
2958 ,green: green
2959 ,blue: blue
2960 ,purple: purple
2961 ,brown: brown
2962 ,lightRed: lightRed
2963 ,lightOrange: lightOrange
2964 ,lightYellow: lightYellow
2965 ,lightGreen: lightGreen
2966 ,lightBlue: lightBlue
2967 ,lightPurple: lightPurple
2968 ,lightBrown: lightBrown
2969 ,darkRed: darkRed
2970 ,darkOrange: darkOrange
2971 ,darkYellow: darkYellow
2972 ,darkGreen: darkGreen
2973 ,darkBlue: darkBlue
2974 ,darkPurple: darkPurple
2975 ,darkBrown: darkBrown
2976 ,white: white
2977 ,lightGrey: lightGrey
2978 ,grey: grey
2979 ,darkGrey: darkGrey
2980 ,lightCharcoal: lightCharcoal
2981 ,charcoal: charcoal
2982 ,darkCharcoal: darkCharcoal
2983 ,black: black
2984 ,lightGray: lightGray
2985 ,gray: gray
2986 ,darkGray: darkGray};
2987};
2988
2989// setup
2990Elm.Native = Elm.Native || {};
2991Elm.Native.Graphics = Elm.Native.Graphics || {};
2992Elm.Native.Graphics.Element = Elm.Native.Graphics.Element || {};
2993
2994// definition
2995Elm.Native.Graphics.Element.make = function(localRuntime) {
2996 'use strict';
2997
2998 // attempt to short-circuit
2999 localRuntime.Native = localRuntime.Native || {};
3000 localRuntime.Native.Graphics = localRuntime.Native.Graphics || {};
3001 localRuntime.Native.Graphics.Element = localRuntime.Native.Graphics.Element || {};
3002 if ('values' in localRuntime.Native.Graphics.Element)
3003 {
3004 return localRuntime.Native.Graphics.Element.values;
3005 }
3006
3007 var Color = Elm.Native.Color.make(localRuntime);
3008 var List = Elm.Native.List.make(localRuntime);
3009 var Maybe = Elm.Maybe.make(localRuntime);
3010 var Text = Elm.Native.Text.make(localRuntime);
3011 var Utils = Elm.Native.Utils.make(localRuntime);
3012
3013
3014 // CREATION
3015
3016 var createNode =
3017 typeof document === 'undefined'
3018 ?
3019 function(_)
3020 {
3021 return {
3022 style: {},
3023 appendChild: function() {}
3024 };
3025 }
3026 :
3027 function(elementType)
3028 {
3029 var node = document.createElement(elementType);
3030 node.style.padding = '0';
3031 node.style.margin = '0';
3032 return node;
3033 }
3034 ;
3035
3036
3037 function newElement(width, height, elementPrim)
3038 {
3039 return {
3040 ctor: 'Element_elm_builtin',
3041 _0: {
3042 element: elementPrim,
3043 props: {
3044 id: Utils.guid(),
3045 width: width,
3046 height: height,
3047 opacity: 1,
3048 color: Maybe.Nothing,
3049 href: '',
3050 tag: '',
3051 hover: Utils.Tuple0,
3052 click: Utils.Tuple0
3053 }
3054 }
3055 };
3056 }
3057
3058
3059 // PROPERTIES
3060
3061 function setProps(elem, node)
3062 {
3063 var props = elem.props;
3064
3065 var element = elem.element;
3066 var width = props.width - (element.adjustWidth || 0);
3067 var height = props.height - (element.adjustHeight || 0);
3068 node.style.width = (width | 0) + 'px';
3069 node.style.height = (height | 0) + 'px';
3070
3071 if (props.opacity !== 1)
3072 {
3073 node.style.opacity = props.opacity;
3074 }
3075
3076 if (props.color.ctor === 'Just')
3077 {
3078 node.style.backgroundColor = Color.toCss(props.color._0);
3079 }
3080
3081 if (props.tag !== '')
3082 {
3083 node.id = props.tag;
3084 }
3085
3086 if (props.hover.ctor !== '_Tuple0')
3087 {
3088 addHover(node, props.hover);
3089 }
3090
3091 if (props.click.ctor !== '_Tuple0')
3092 {
3093 addClick(node, props.click);
3094 }
3095
3096 if (props.href !== '')
3097 {
3098 var anchor = createNode('a');
3099 anchor.href = props.href;
3100 anchor.style.display = 'block';
3101 anchor.style.pointerEvents = 'auto';
3102 anchor.appendChild(node);
3103 node = anchor;
3104 }
3105
3106 return node;
3107 }
3108
3109 function addClick(e, handler)
3110 {
3111 e.style.pointerEvents = 'auto';
3112 e.elm_click_handler = handler;
3113 function trigger(ev)
3114 {
3115 e.elm_click_handler(Utils.Tuple0);
3116 ev.stopPropagation();
3117 }
3118 e.elm_click_trigger = trigger;
3119 e.addEventListener('click', trigger);
3120 }
3121
3122 function removeClick(e, handler)
3123 {
3124 if (e.elm_click_trigger)
3125 {
3126 e.removeEventListener('click', e.elm_click_trigger);
3127 e.elm_click_trigger = null;
3128 e.elm_click_handler = null;
3129 }
3130 }
3131
3132 function addHover(e, handler)
3133 {
3134 e.style.pointerEvents = 'auto';
3135 e.elm_hover_handler = handler;
3136 e.elm_hover_count = 0;
3137
3138 function over(evt)
3139 {
3140 if (e.elm_hover_count++ > 0) return;
3141 e.elm_hover_handler(true);
3142 evt.stopPropagation();
3143 }
3144 function out(evt)
3145 {
3146 if (e.contains(evt.toElement || evt.relatedTarget)) return;
3147 e.elm_hover_count = 0;
3148 e.elm_hover_handler(false);
3149 evt.stopPropagation();
3150 }
3151 e.elm_hover_over = over;
3152 e.elm_hover_out = out;
3153 e.addEventListener('mouseover', over);
3154 e.addEventListener('mouseout', out);
3155 }
3156
3157 function removeHover(e)
3158 {
3159 e.elm_hover_handler = null;
3160 if (e.elm_hover_over)
3161 {
3162 e.removeEventListener('mouseover', e.elm_hover_over);
3163 e.elm_hover_over = null;
3164 }
3165 if (e.elm_hover_out)
3166 {
3167 e.removeEventListener('mouseout', e.elm_hover_out);
3168 e.elm_hover_out = null;
3169 }
3170 }
3171
3172
3173 // IMAGES
3174
3175 function image(props, img)
3176 {
3177 switch (img._0.ctor)
3178 {
3179 case 'Plain':
3180 return plainImage(img._3);
3181
3182 case 'Fitted':
3183 return fittedImage(props.width, props.height, img._3);
3184
3185 case 'Cropped':
3186 return croppedImage(img, props.width, props.height, img._3);
3187
3188 case 'Tiled':
3189 return tiledImage(img._3);
3190 }
3191 }
3192
3193 function plainImage(src)
3194 {
3195 var img = createNode('img');
3196 img.src = src;
3197 img.name = src;
3198 img.style.display = 'block';
3199 return img;
3200 }
3201
3202 function tiledImage(src)
3203 {
3204 var div = createNode('div');
3205 div.style.backgroundImage = 'url(' + src + ')';
3206 return div;
3207 }
3208
3209 function fittedImage(w, h, src)
3210 {
3211 var div = createNode('div');
3212 div.style.background = 'url(' + src + ') no-repeat center';
3213 div.style.webkitBackgroundSize = 'cover';
3214 div.style.MozBackgroundSize = 'cover';
3215 div.style.OBackgroundSize = 'cover';
3216 div.style.backgroundSize = 'cover';
3217 return div;
3218 }
3219
3220 function croppedImage(elem, w, h, src)
3221 {
3222 var pos = elem._0._0;
3223 var e = createNode('div');
3224 e.style.overflow = 'hidden';
3225
3226 var img = createNode('img');
3227 img.onload = function() {
3228 var sw = w / elem._1, sh = h / elem._2;
3229 img.style.width = ((this.width * sw) | 0) + 'px';
3230 img.style.height = ((this.height * sh) | 0) + 'px';
3231 img.style.marginLeft = ((- pos._0 * sw) | 0) + 'px';
3232 img.style.marginTop = ((- pos._1 * sh) | 0) + 'px';
3233 };
3234 img.src = src;
3235 img.name = src;
3236 e.appendChild(img);
3237 return e;
3238 }
3239
3240
3241 // FLOW
3242
3243 function goOut(node)
3244 {
3245 node.style.position = 'absolute';
3246 return node;
3247 }
3248 function goDown(node)
3249 {
3250 return node;
3251 }
3252 function goRight(node)
3253 {
3254 node.style.styleFloat = 'left';
3255 node.style.cssFloat = 'left';
3256 return node;
3257 }
3258
3259 var directionTable = {
3260 DUp: goDown,
3261 DDown: goDown,
3262 DLeft: goRight,
3263 DRight: goRight,
3264 DIn: goOut,
3265 DOut: goOut
3266 };
3267 function needsReversal(dir)
3268 {
3269 return dir === 'DUp' || dir === 'DLeft' || dir === 'DIn';
3270 }
3271
3272 function flow(dir, elist)
3273 {
3274 var array = List.toArray(elist);
3275 var container = createNode('div');
3276 var goDir = directionTable[dir];
3277 if (goDir === goOut)
3278 {
3279 container.style.pointerEvents = 'none';
3280 }
3281 if (needsReversal(dir))
3282 {
3283 array.reverse();
3284 }
3285 var len = array.length;
3286 for (var i = 0; i < len; ++i)
3287 {
3288 container.appendChild(goDir(render(array[i])));
3289 }
3290 return container;
3291 }
3292
3293
3294 // CONTAINER
3295
3296 function toPos(pos)
3297 {
3298 return pos.ctor === 'Absolute'
3299 ? pos._0 + 'px'
3300 : (pos._0 * 100) + '%';
3301 }
3302
3303 // must clear right, left, top, bottom, and transform
3304 // before calling this function
3305 function setPos(pos, wrappedElement, e)
3306 {
3307 var elem = wrappedElement._0;
3308 var element = elem.element;
3309 var props = elem.props;
3310 var w = props.width + (element.adjustWidth ? element.adjustWidth : 0);
3311 var h = props.height + (element.adjustHeight ? element.adjustHeight : 0);
3312
3313 e.style.position = 'absolute';
3314 e.style.margin = 'auto';
3315 var transform = '';
3316
3317 switch (pos.horizontal.ctor)
3318 {
3319 case 'P':
3320 e.style.right = toPos(pos.x);
3321 e.style.removeProperty('left');
3322 break;
3323
3324 case 'Z':
3325 transform = 'translateX(' + ((-w / 2) | 0) + 'px) ';
3326
3327 case 'N':
3328 e.style.left = toPos(pos.x);
3329 e.style.removeProperty('right');
3330 break;
3331 }
3332 switch (pos.vertical.ctor)
3333 {
3334 case 'N':
3335 e.style.bottom = toPos(pos.y);
3336 e.style.removeProperty('top');
3337 break;
3338
3339 case 'Z':
3340 transform += 'translateY(' + ((-h / 2) | 0) + 'px)';
3341
3342 case 'P':
3343 e.style.top = toPos(pos.y);
3344 e.style.removeProperty('bottom');
3345 break;
3346 }
3347 if (transform !== '')
3348 {
3349 addTransform(e.style, transform);
3350 }
3351 return e;
3352 }
3353
3354 function addTransform(style, transform)
3355 {
3356 style.transform = transform;
3357 style.msTransform = transform;
3358 style.MozTransform = transform;
3359 style.webkitTransform = transform;
3360 style.OTransform = transform;
3361 }
3362
3363 function container(pos, elem)
3364 {
3365 var e = render(elem);
3366 setPos(pos, elem, e);
3367 var div = createNode('div');
3368 div.style.position = 'relative';
3369 div.style.overflow = 'hidden';
3370 div.appendChild(e);
3371 return div;
3372 }
3373
3374
3375 function rawHtml(elem)
3376 {
3377 var html = elem.html;
3378 var align = elem.align;
3379
3380 var div = createNode('div');
3381 div.innerHTML = html;
3382 div.style.visibility = 'hidden';
3383 if (align)
3384 {
3385 div.style.textAlign = align;
3386 }
3387 div.style.visibility = 'visible';
3388 div.style.pointerEvents = 'auto';
3389 return div;
3390 }
3391
3392
3393 // RENDER
3394
3395 function render(wrappedElement)
3396 {
3397 var elem = wrappedElement._0;
3398 return setProps(elem, makeElement(elem));
3399 }
3400
3401 function makeElement(e)
3402 {
3403 var elem = e.element;
3404 switch (elem.ctor)
3405 {
3406 case 'Image':
3407 return image(e.props, elem);
3408
3409 case 'Flow':
3410 return flow(elem._0.ctor, elem._1);
3411
3412 case 'Container':
3413 return container(elem._0, elem._1);
3414
3415 case 'Spacer':
3416 return createNode('div');
3417
3418 case 'RawHtml':
3419 return rawHtml(elem);
3420
3421 case 'Custom':
3422 return elem.render(elem.model);
3423 }
3424 }
3425
3426 function updateAndReplace(node, curr, next)
3427 {
3428 var newNode = update(node, curr, next);
3429 if (newNode !== node)
3430 {
3431 node.parentNode.replaceChild(newNode, node);
3432 }
3433 return newNode;
3434 }
3435
3436
3437 // UPDATE
3438
3439 function update(node, wrappedCurrent, wrappedNext)
3440 {
3441 var curr = wrappedCurrent._0;
3442 var next = wrappedNext._0;
3443 var rootNode = node;
3444 if (node.tagName === 'A')
3445 {
3446 node = node.firstChild;
3447 }
3448 if (curr.props.id === next.props.id)
3449 {
3450 updateProps(node, curr, next);
3451 return rootNode;
3452 }
3453 if (curr.element.ctor !== next.element.ctor)
3454 {
3455 return render(wrappedNext);
3456 }
3457 var nextE = next.element;
3458 var currE = curr.element;
3459 switch (nextE.ctor)
3460 {
3461 case 'Spacer':
3462 updateProps(node, curr, next);
3463 return rootNode;
3464
3465 case 'RawHtml':
3466 if(currE.html.valueOf() !== nextE.html.valueOf())
3467 {
3468 node.innerHTML = nextE.html;
3469 }
3470 updateProps(node, curr, next);
3471 return rootNode;
3472
3473 case 'Image':
3474 if (nextE._0.ctor === 'Plain')
3475 {
3476 if (nextE._3 !== currE._3)
3477 {
3478 node.src = nextE._3;
3479 }
3480 }
3481 else if (!Utils.eq(nextE, currE)
3482 || next.props.width !== curr.props.width
3483 || next.props.height !== curr.props.height)
3484 {
3485 return render(wrappedNext);
3486 }
3487 updateProps(node, curr, next);
3488 return rootNode;
3489
3490 case 'Flow':
3491 var arr = List.toArray(nextE._1);
3492 for (var i = arr.length; i--; )
3493 {
3494 arr[i] = arr[i]._0.element.ctor;
3495 }
3496 if (nextE._0.ctor !== currE._0.ctor)
3497 {
3498 return render(wrappedNext);
3499 }
3500 var nexts = List.toArray(nextE._1);
3501 var kids = node.childNodes;
3502 if (nexts.length !== kids.length)
3503 {
3504 return render(wrappedNext);
3505 }
3506 var currs = List.toArray(currE._1);
3507 var dir = nextE._0.ctor;
3508 var goDir = directionTable[dir];
3509 var toReverse = needsReversal(dir);
3510 var len = kids.length;
3511 for (var i = len; i--; )
3512 {
3513 var subNode = kids[toReverse ? len - i - 1 : i];
3514 goDir(updateAndReplace(subNode, currs[i], nexts[i]));
3515 }
3516 updateProps(node, curr, next);
3517 return rootNode;
3518
3519 case 'Container':
3520 var subNode = node.firstChild;
3521 var newSubNode = updateAndReplace(subNode, currE._1, nextE._1);
3522 setPos(nextE._0, nextE._1, newSubNode);
3523 updateProps(node, curr, next);
3524 return rootNode;
3525
3526 case 'Custom':
3527 if (currE.type === nextE.type)
3528 {
3529 var updatedNode = nextE.update(node, currE.model, nextE.model);
3530 updateProps(updatedNode, curr, next);
3531 return updatedNode;
3532 }
3533 return render(wrappedNext);
3534 }
3535 }
3536
3537 function updateProps(node, curr, next)
3538 {
3539 var nextProps = next.props;
3540 var currProps = curr.props;
3541
3542 var element = next.element;
3543 var width = nextProps.width - (element.adjustWidth || 0);
3544 var height = nextProps.height - (element.adjustHeight || 0);
3545 if (width !== currProps.width)
3546 {
3547 node.style.width = (width | 0) + 'px';
3548 }
3549 if (height !== currProps.height)
3550 {
3551 node.style.height = (height | 0) + 'px';
3552 }
3553
3554 if (nextProps.opacity !== currProps.opacity)
3555 {
3556 node.style.opacity = nextProps.opacity;
3557 }
3558
3559 var nextColor = nextProps.color.ctor === 'Just'
3560 ? Color.toCss(nextProps.color._0)
3561 : '';
3562 if (node.style.backgroundColor !== nextColor)
3563 {
3564 node.style.backgroundColor = nextColor;
3565 }
3566
3567 if (nextProps.tag !== currProps.tag)
3568 {
3569 node.id = nextProps.tag;
3570 }
3571
3572 if (nextProps.href !== currProps.href)
3573 {
3574 if (currProps.href === '')
3575 {
3576 // add a surrounding href
3577 var anchor = createNode('a');
3578 anchor.href = nextProps.href;
3579 anchor.style.display = 'block';
3580 anchor.style.pointerEvents = 'auto';
3581
3582 node.parentNode.replaceChild(anchor, node);
3583 anchor.appendChild(node);
3584 }
3585 else if (nextProps.href === '')
3586 {
3587 // remove the surrounding href
3588 var anchor = node.parentNode;
3589 anchor.parentNode.replaceChild(node, anchor);
3590 }
3591 else
3592 {
3593 // just update the link
3594 node.parentNode.href = nextProps.href;
3595 }
3596 }
3597
3598 // update click and hover handlers
3599 var removed = false;
3600
3601 // update hover handlers
3602 if (currProps.hover.ctor === '_Tuple0')
3603 {
3604 if (nextProps.hover.ctor !== '_Tuple0')
3605 {
3606 addHover(node, nextProps.hover);
3607 }
3608 }
3609 else
3610 {
3611 if (nextProps.hover.ctor === '_Tuple0')
3612 {
3613 removed = true;
3614 removeHover(node);
3615 }
3616 else
3617 {
3618 node.elm_hover_handler = nextProps.hover;
3619 }
3620 }
3621
3622 // update click handlers
3623 if (currProps.click.ctor === '_Tuple0')
3624 {
3625 if (nextProps.click.ctor !== '_Tuple0')
3626 {
3627 addClick(node, nextProps.click);
3628 }
3629 }
3630 else
3631 {
3632 if (nextProps.click.ctor === '_Tuple0')
3633 {
3634 removed = true;
3635 removeClick(node);
3636 }
3637 else
3638 {
3639 node.elm_click_handler = nextProps.click;
3640 }
3641 }
3642
3643 // stop capturing clicks if
3644 if (removed
3645 && nextProps.hover.ctor === '_Tuple0'
3646 && nextProps.click.ctor === '_Tuple0')
3647 {
3648 node.style.pointerEvents = 'none';
3649 }
3650 }
3651
3652
3653 // TEXT
3654
3655 function block(align)
3656 {
3657 return function(text)
3658 {
3659 var raw = {
3660 ctor: 'RawHtml',
3661 html: Text.renderHtml(text),
3662 align: align
3663 };
3664 var pos = htmlHeight(0, raw);
3665 return newElement(pos._0, pos._1, raw);
3666 };
3667 }
3668
3669 function markdown(text)
3670 {
3671 var raw = {
3672 ctor: 'RawHtml',
3673 html: text,
3674 align: null
3675 };
3676 var pos = htmlHeight(0, raw);
3677 return newElement(pos._0, pos._1, raw);
3678 }
3679
3680 var htmlHeight =
3681 typeof document !== 'undefined'
3682 ? realHtmlHeight
3683 : function(a, b) { return Utils.Tuple2(0, 0); };
3684
3685 function realHtmlHeight(width, rawHtml)
3686 {
3687 // create dummy node
3688 var temp = document.createElement('div');
3689 temp.innerHTML = rawHtml.html;
3690 if (width > 0)
3691 {
3692 temp.style.width = width + 'px';
3693 }
3694 temp.style.visibility = 'hidden';
3695 temp.style.styleFloat = 'left';
3696 temp.style.cssFloat = 'left';
3697
3698 document.body.appendChild(temp);
3699
3700 // get dimensions
3701 var style = window.getComputedStyle(temp, null);
3702 var w = Math.ceil(style.getPropertyValue('width').slice(0, -2) - 0);
3703 var h = Math.ceil(style.getPropertyValue('height').slice(0, -2) - 0);
3704 document.body.removeChild(temp);
3705 return Utils.Tuple2(w, h);
3706 }
3707
3708
3709 return localRuntime.Native.Graphics.Element.values = {
3710 render: render,
3711 update: update,
3712 updateAndReplace: updateAndReplace,
3713
3714 createNode: createNode,
3715 newElement: F3(newElement),
3716 addTransform: addTransform,
3717 htmlHeight: F2(htmlHeight),
3718 guid: Utils.guid,
3719
3720 block: block,
3721 markdown: markdown
3722 };
3723};
3724
3725Elm.Native.Text = {};
3726Elm.Native.Text.make = function(localRuntime) {
3727 localRuntime.Native = localRuntime.Native || {};
3728 localRuntime.Native.Text = localRuntime.Native.Text || {};
3729 if (localRuntime.Native.Text.values)
3730 {
3731 return localRuntime.Native.Text.values;
3732 }
3733
3734 var toCss = Elm.Native.Color.make(localRuntime).toCss;
3735 var List = Elm.Native.List.make(localRuntime);
3736
3737
3738 // CONSTRUCTORS
3739
3740 function fromString(str)
3741 {
3742 return {
3743 ctor: 'Text:Text',
3744 _0: str
3745 };
3746 }
3747
3748 function append(a, b)
3749 {
3750 return {
3751 ctor: 'Text:Append',
3752 _0: a,
3753 _1: b
3754 };
3755 }
3756
3757 function addMeta(field, value, text)
3758 {
3759 var newProps = {};
3760 var newText = {
3761 ctor: 'Text:Meta',
3762 _0: newProps,
3763 _1: text
3764 };
3765
3766 if (text.ctor === 'Text:Meta')
3767 {
3768 newText._1 = text._1;
3769 var props = text._0;
3770 for (var i = metaKeys.length; i--; )
3771 {
3772 var key = metaKeys[i];
3773 var val = props[key];
3774 if (val)
3775 {
3776 newProps[key] = val;
3777 }
3778 }
3779 }
3780 newProps[field] = value;
3781 return newText;
3782 }
3783
3784 var metaKeys = [
3785 'font-size',
3786 'font-family',
3787 'font-style',
3788 'font-weight',
3789 'href',
3790 'text-decoration',
3791 'color'
3792 ];
3793
3794
3795 // conversions from Elm values to CSS
3796
3797 function toTypefaces(list)
3798 {
3799 var typefaces = List.toArray(list);
3800 for (var i = typefaces.length; i--; )
3801 {
3802 var typeface = typefaces[i];
3803 if (typeface.indexOf(' ') > -1)
3804 {
3805 typefaces[i] = "'" + typeface + "'";
3806 }
3807 }
3808 return typefaces.join(',');
3809 }
3810
3811 function toLine(line)
3812 {
3813 var ctor = line.ctor;
3814 return ctor === 'Under'
3815 ? 'underline'
3816 : ctor === 'Over'
3817 ? 'overline'
3818 : 'line-through';
3819 }
3820
3821 // setting styles of Text
3822
3823 function style(style, text)
3824 {
3825 var newText = addMeta('color', toCss(style.color), text);
3826 var props = newText._0;
3827
3828 if (style.typeface.ctor !== '[]')
3829 {
3830 props['font-family'] = toTypefaces(style.typeface);
3831 }
3832 if (style.height.ctor !== 'Nothing')
3833 {
3834 props['font-size'] = style.height._0 + 'px';
3835 }
3836 if (style.bold)
3837 {
3838 props['font-weight'] = 'bold';
3839 }
3840 if (style.italic)
3841 {
3842 props['font-style'] = 'italic';
3843 }
3844 if (style.line.ctor !== 'Nothing')
3845 {
3846 props['text-decoration'] = toLine(style.line._0);
3847 }
3848 return newText;
3849 }
3850
3851 function height(px, text)
3852 {
3853 return addMeta('font-size', px + 'px', text);
3854 }
3855
3856 function typeface(names, text)
3857 {
3858 return addMeta('font-family', toTypefaces(names), text);
3859 }
3860
3861 function monospace(text)
3862 {
3863 return addMeta('font-family', 'monospace', text);
3864 }
3865
3866 function italic(text)
3867 {
3868 return addMeta('font-style', 'italic', text);
3869 }
3870
3871 function bold(text)
3872 {
3873 return addMeta('font-weight', 'bold', text);
3874 }
3875
3876 function link(href, text)
3877 {
3878 return addMeta('href', href, text);
3879 }
3880
3881 function line(line, text)
3882 {
3883 return addMeta('text-decoration', toLine(line), text);
3884 }
3885
3886 function color(color, text)
3887 {
3888 return addMeta('color', toCss(color), text);
3889 }
3890
3891
3892 // RENDER
3893
3894 function renderHtml(text)
3895 {
3896 var tag = text.ctor;
3897 if (tag === 'Text:Append')
3898 {
3899 return renderHtml(text._0) + renderHtml(text._1);
3900 }
3901 if (tag === 'Text:Text')
3902 {
3903 return properEscape(text._0);
3904 }
3905 if (tag === 'Text:Meta')
3906 {
3907 return renderMeta(text._0, renderHtml(text._1));
3908 }
3909 }
3910
3911 function renderMeta(metas, string)
3912 {
3913 var href = metas.href;
3914 if (href)
3915 {
3916 string = '<a href="' + href + '">' + string + '</a>';
3917 }
3918 var styles = '';
3919 for (var key in metas)
3920 {
3921 if (key === 'href')
3922 {
3923 continue;
3924 }
3925 styles += key + ':' + metas[key] + ';';
3926 }
3927 if (styles)
3928 {
3929 string = '<span style="' + styles + '">' + string + '</span>';
3930 }
3931 return string;
3932 }
3933
3934 function properEscape(str)
3935 {
3936 if (str.length === 0)
3937 {
3938 return str;
3939 }
3940 str = str //.replace(/&/g, '&')
3941 .replace(/"/g, '"')
3942 .replace(/'/g, ''')
3943 .replace(/</g, '<')
3944 .replace(/>/g, '>');
3945 var arr = str.split('\n');
3946 for (var i = arr.length; i--; )
3947 {
3948 arr[i] = makeSpaces(arr[i]);
3949 }
3950 return arr.join('<br/>');
3951 }
3952
3953 function makeSpaces(s)
3954 {
3955 if (s.length === 0)
3956 {
3957 return s;
3958 }
3959 var arr = s.split('');
3960 if (arr[0] === ' ')
3961 {
3962 arr[0] = ' ';
3963 }
3964 for (var i = arr.length; --i; )
3965 {
3966 if (arr[i][0] === ' ' && arr[i - 1] === ' ')
3967 {
3968 arr[i - 1] = arr[i - 1] + arr[i];
3969 arr[i] = '';
3970 }
3971 }
3972 for (var i = arr.length; i--; )
3973 {
3974 if (arr[i].length > 1 && arr[i][0] === ' ')
3975 {
3976 var spaces = arr[i].split('');
3977 for (var j = spaces.length - 2; j >= 0; j -= 2)
3978 {
3979 spaces[j] = ' ';
3980 }
3981 arr[i] = spaces.join('');
3982 }
3983 }
3984 arr = arr.join('');
3985 if (arr[arr.length - 1] === ' ')
3986 {
3987 return arr.slice(0, -1) + ' ';
3988 }
3989 return arr;
3990 }
3991
3992
3993 return localRuntime.Native.Text.values = {
3994 fromString: fromString,
3995 append: F2(append),
3996
3997 height: F2(height),
3998 italic: italic,
3999 bold: bold,
4000 line: F2(line),
4001 monospace: monospace,
4002 typeface: F2(typeface),
4003 color: F2(color),
4004 link: F2(link),
4005 style: F2(style),
4006
4007 toTypefaces: toTypefaces,
4008 toLine: toLine,
4009 renderHtml: renderHtml
4010 };
4011};
4012
4013Elm.Text = Elm.Text || {};
4014Elm.Text.make = function (_elm) {
4015 "use strict";
4016 _elm.Text = _elm.Text || {};
4017 if (_elm.Text.values) return _elm.Text.values;
4018 var _U = Elm.Native.Utils.make(_elm),
4019 $Color = Elm.Color.make(_elm),
4020 $List = Elm.List.make(_elm),
4021 $Maybe = Elm.Maybe.make(_elm),
4022 $Native$Text = Elm.Native.Text.make(_elm);
4023 var _op = {};
4024 var line = $Native$Text.line;
4025 var italic = $Native$Text.italic;
4026 var bold = $Native$Text.bold;
4027 var color = $Native$Text.color;
4028 var height = $Native$Text.height;
4029 var link = $Native$Text.link;
4030 var monospace = $Native$Text.monospace;
4031 var typeface = $Native$Text.typeface;
4032 var style = $Native$Text.style;
4033 var append = $Native$Text.append;
4034 var fromString = $Native$Text.fromString;
4035 var empty = fromString("");
4036 var concat = function (texts) { return A3($List.foldr,append,empty,texts);};
4037 var join = F2(function (seperator,texts) { return concat(A2($List.intersperse,seperator,texts));});
4038 var defaultStyle = {typeface: _U.list([]),height: $Maybe.Nothing,color: $Color.black,bold: false,italic: false,line: $Maybe.Nothing};
4039 var Style = F6(function (a,b,c,d,e,f) { return {typeface: a,height: b,color: c,bold: d,italic: e,line: f};});
4040 var Through = {ctor: "Through"};
4041 var Over = {ctor: "Over"};
4042 var Under = {ctor: "Under"};
4043 var Text = {ctor: "Text"};
4044 return _elm.Text.values = {_op: _op
4045 ,fromString: fromString
4046 ,empty: empty
4047 ,append: append
4048 ,concat: concat
4049 ,join: join
4050 ,link: link
4051 ,style: style
4052 ,defaultStyle: defaultStyle
4053 ,typeface: typeface
4054 ,monospace: monospace
4055 ,height: height
4056 ,color: color
4057 ,bold: bold
4058 ,italic: italic
4059 ,line: line
4060 ,Style: Style
4061 ,Under: Under
4062 ,Over: Over
4063 ,Through: Through};
4064};
4065Elm.Graphics = Elm.Graphics || {};
4066Elm.Graphics.Element = Elm.Graphics.Element || {};
4067Elm.Graphics.Element.make = function (_elm) {
4068 "use strict";
4069 _elm.Graphics = _elm.Graphics || {};
4070 _elm.Graphics.Element = _elm.Graphics.Element || {};
4071 if (_elm.Graphics.Element.values) return _elm.Graphics.Element.values;
4072 var _U = Elm.Native.Utils.make(_elm),
4073 $Basics = Elm.Basics.make(_elm),
4074 $Color = Elm.Color.make(_elm),
4075 $List = Elm.List.make(_elm),
4076 $Maybe = Elm.Maybe.make(_elm),
4077 $Native$Graphics$Element = Elm.Native.Graphics.Element.make(_elm),
4078 $Text = Elm.Text.make(_elm);
4079 var _op = {};
4080 var DOut = {ctor: "DOut"};
4081 var outward = DOut;
4082 var DIn = {ctor: "DIn"};
4083 var inward = DIn;
4084 var DRight = {ctor: "DRight"};
4085 var right = DRight;
4086 var DLeft = {ctor: "DLeft"};
4087 var left = DLeft;
4088 var DDown = {ctor: "DDown"};
4089 var down = DDown;
4090 var DUp = {ctor: "DUp"};
4091 var up = DUp;
4092 var RawPosition = F4(function (a,b,c,d) { return {horizontal: a,vertical: b,x: c,y: d};});
4093 var Position = function (a) { return {ctor: "Position",_0: a};};
4094 var Relative = function (a) { return {ctor: "Relative",_0: a};};
4095 var relative = Relative;
4096 var Absolute = function (a) { return {ctor: "Absolute",_0: a};};
4097 var absolute = Absolute;
4098 var N = {ctor: "N"};
4099 var bottomLeft = Position({horizontal: N,vertical: N,x: Absolute(0),y: Absolute(0)});
4100 var bottomLeftAt = F2(function (x,y) { return Position({horizontal: N,vertical: N,x: x,y: y});});
4101 var Z = {ctor: "Z"};
4102 var middle = Position({horizontal: Z,vertical: Z,x: Relative(0.5),y: Relative(0.5)});
4103 var midLeft = Position({horizontal: N,vertical: Z,x: Absolute(0),y: Relative(0.5)});
4104 var midBottom = Position({horizontal: Z,vertical: N,x: Relative(0.5),y: Absolute(0)});
4105 var middleAt = F2(function (x,y) { return Position({horizontal: Z,vertical: Z,x: x,y: y});});
4106 var midLeftAt = F2(function (x,y) { return Position({horizontal: N,vertical: Z,x: x,y: y});});
4107 var midBottomAt = F2(function (x,y) { return Position({horizontal: Z,vertical: N,x: x,y: y});});
4108 var P = {ctor: "P"};
4109 var topLeft = Position({horizontal: N,vertical: P,x: Absolute(0),y: Absolute(0)});
4110 var topRight = Position({horizontal: P,vertical: P,x: Absolute(0),y: Absolute(0)});
4111 var bottomRight = Position({horizontal: P,vertical: N,x: Absolute(0),y: Absolute(0)});
4112 var midRight = Position({horizontal: P,vertical: Z,x: Absolute(0),y: Relative(0.5)});
4113 var midTop = Position({horizontal: Z,vertical: P,x: Relative(0.5),y: Absolute(0)});
4114 var topLeftAt = F2(function (x,y) { return Position({horizontal: N,vertical: P,x: x,y: y});});
4115 var topRightAt = F2(function (x,y) { return Position({horizontal: P,vertical: P,x: x,y: y});});
4116 var bottomRightAt = F2(function (x,y) { return Position({horizontal: P,vertical: N,x: x,y: y});});
4117 var midRightAt = F2(function (x,y) { return Position({horizontal: P,vertical: Z,x: x,y: y});});
4118 var midTopAt = F2(function (x,y) { return Position({horizontal: Z,vertical: P,x: x,y: y});});
4119 var justified = $Native$Graphics$Element.block("justify");
4120 var centered = $Native$Graphics$Element.block("center");
4121 var rightAligned = $Native$Graphics$Element.block("right");
4122 var leftAligned = $Native$Graphics$Element.block("left");
4123 var show = function (value) { return leftAligned($Text.monospace($Text.fromString($Basics.toString(value))));};
4124 var Tiled = {ctor: "Tiled"};
4125 var Cropped = function (a) { return {ctor: "Cropped",_0: a};};
4126 var Fitted = {ctor: "Fitted"};
4127 var Plain = {ctor: "Plain"};
4128 var Custom = {ctor: "Custom"};
4129 var RawHtml = {ctor: "RawHtml"};
4130 var Spacer = {ctor: "Spacer"};
4131 var Flow = F2(function (a,b) { return {ctor: "Flow",_0: a,_1: b};});
4132 var Container = F2(function (a,b) { return {ctor: "Container",_0: a,_1: b};});
4133 var Image = F4(function (a,b,c,d) { return {ctor: "Image",_0: a,_1: b,_2: c,_3: d};});
4134 var newElement = $Native$Graphics$Element.newElement;
4135 var image = F3(function (w,h,src) { return A3(newElement,w,h,A4(Image,Plain,w,h,src));});
4136 var fittedImage = F3(function (w,h,src) { return A3(newElement,w,h,A4(Image,Fitted,w,h,src));});
4137 var croppedImage = F4(function (pos,w,h,src) { return A3(newElement,w,h,A4(Image,Cropped(pos),w,h,src));});
4138 var tiledImage = F3(function (w,h,src) { return A3(newElement,w,h,A4(Image,Tiled,w,h,src));});
4139 var container = F4(function (w,h,_p0,e) { var _p1 = _p0;return A3(newElement,w,h,A2(Container,_p1._0,e));});
4140 var spacer = F2(function (w,h) { return A3(newElement,w,h,Spacer);});
4141 var sizeOf = function (_p2) { var _p3 = _p2;var _p4 = _p3._0;return {ctor: "_Tuple2",_0: _p4.props.width,_1: _p4.props.height};};
4142 var heightOf = function (_p5) { var _p6 = _p5;return _p6._0.props.height;};
4143 var widthOf = function (_p7) { var _p8 = _p7;return _p8._0.props.width;};
4144 var above = F2(function (hi,lo) {
4145 return A3(newElement,A2($Basics.max,widthOf(hi),widthOf(lo)),heightOf(hi) + heightOf(lo),A2(Flow,DDown,_U.list([hi,lo])));
4146 });
4147 var below = F2(function (lo,hi) {
4148 return A3(newElement,A2($Basics.max,widthOf(hi),widthOf(lo)),heightOf(hi) + heightOf(lo),A2(Flow,DDown,_U.list([hi,lo])));
4149 });
4150 var beside = F2(function (lft,rht) {
4151 return A3(newElement,widthOf(lft) + widthOf(rht),A2($Basics.max,heightOf(lft),heightOf(rht)),A2(Flow,right,_U.list([lft,rht])));
4152 });
4153 var layers = function (es) {
4154 var hs = A2($List.map,heightOf,es);
4155 var ws = A2($List.map,widthOf,es);
4156 return A3(newElement,A2($Maybe.withDefault,0,$List.maximum(ws)),A2($Maybe.withDefault,0,$List.maximum(hs)),A2(Flow,DOut,es));
4157 };
4158 var empty = A2(spacer,0,0);
4159 var flow = F2(function (dir,es) {
4160 var newFlow = F2(function (w,h) { return A3(newElement,w,h,A2(Flow,dir,es));});
4161 var maxOrZero = function (list) { return A2($Maybe.withDefault,0,$List.maximum(list));};
4162 var hs = A2($List.map,heightOf,es);
4163 var ws = A2($List.map,widthOf,es);
4164 if (_U.eq(es,_U.list([]))) return empty; else {
4165 var _p9 = dir;
4166 switch (_p9.ctor)
4167 {case "DUp": return A2(newFlow,maxOrZero(ws),$List.sum(hs));
4168 case "DDown": return A2(newFlow,maxOrZero(ws),$List.sum(hs));
4169 case "DLeft": return A2(newFlow,$List.sum(ws),maxOrZero(hs));
4170 case "DRight": return A2(newFlow,$List.sum(ws),maxOrZero(hs));
4171 case "DIn": return A2(newFlow,maxOrZero(ws),maxOrZero(hs));
4172 default: return A2(newFlow,maxOrZero(ws),maxOrZero(hs));}
4173 }
4174 });
4175 var Properties = F9(function (a,b,c,d,e,f,g,h,i) { return {id: a,width: b,height: c,opacity: d,color: e,href: f,tag: g,hover: h,click: i};});
4176 var Element_elm_builtin = function (a) { return {ctor: "Element_elm_builtin",_0: a};};
4177 var width = F2(function (newWidth,_p10) {
4178 var _p11 = _p10;
4179 var _p14 = _p11._0.props;
4180 var _p13 = _p11._0.element;
4181 var newHeight = function () {
4182 var _p12 = _p13;
4183 switch (_p12.ctor)
4184 {case "Image": return $Basics.round($Basics.toFloat(_p12._2) / $Basics.toFloat(_p12._1) * $Basics.toFloat(newWidth));
4185 case "RawHtml": return $Basics.snd(A2($Native$Graphics$Element.htmlHeight,newWidth,_p13));
4186 default: return _p14.height;}
4187 }();
4188 return Element_elm_builtin({element: _p13,props: _U.update(_p14,{width: newWidth,height: newHeight})});
4189 });
4190 var height = F2(function (newHeight,_p15) {
4191 var _p16 = _p15;
4192 return Element_elm_builtin({element: _p16._0.element,props: _U.update(_p16._0.props,{height: newHeight})});
4193 });
4194 var size = F3(function (w,h,e) { return A2(height,h,A2(width,w,e));});
4195 var opacity = F2(function (givenOpacity,_p17) {
4196 var _p18 = _p17;
4197 return Element_elm_builtin({element: _p18._0.element,props: _U.update(_p18._0.props,{opacity: givenOpacity})});
4198 });
4199 var color = F2(function (clr,_p19) {
4200 var _p20 = _p19;
4201 return Element_elm_builtin({element: _p20._0.element,props: _U.update(_p20._0.props,{color: $Maybe.Just(clr)})});
4202 });
4203 var tag = F2(function (name,_p21) { var _p22 = _p21;return Element_elm_builtin({element: _p22._0.element,props: _U.update(_p22._0.props,{tag: name})});});
4204 var link = F2(function (href,_p23) {
4205 var _p24 = _p23;
4206 return Element_elm_builtin({element: _p24._0.element,props: _U.update(_p24._0.props,{href: href})});
4207 });
4208 return _elm.Graphics.Element.values = {_op: _op
4209 ,image: image
4210 ,fittedImage: fittedImage
4211 ,croppedImage: croppedImage
4212 ,tiledImage: tiledImage
4213 ,leftAligned: leftAligned
4214 ,rightAligned: rightAligned
4215 ,centered: centered
4216 ,justified: justified
4217 ,show: show
4218 ,width: width
4219 ,height: height
4220 ,size: size
4221 ,color: color
4222 ,opacity: opacity
4223 ,link: link
4224 ,tag: tag
4225 ,widthOf: widthOf
4226 ,heightOf: heightOf
4227 ,sizeOf: sizeOf
4228 ,flow: flow
4229 ,up: up
4230 ,down: down
4231 ,left: left
4232 ,right: right
4233 ,inward: inward
4234 ,outward: outward
4235 ,layers: layers
4236 ,above: above
4237 ,below: below
4238 ,beside: beside
4239 ,empty: empty
4240 ,spacer: spacer
4241 ,container: container
4242 ,middle: middle
4243 ,midTop: midTop
4244 ,midBottom: midBottom
4245 ,midLeft: midLeft
4246 ,midRight: midRight
4247 ,topLeft: topLeft
4248 ,topRight: topRight
4249 ,bottomLeft: bottomLeft
4250 ,bottomRight: bottomRight
4251 ,absolute: absolute
4252 ,relative: relative
4253 ,middleAt: middleAt
4254 ,midTopAt: midTopAt
4255 ,midBottomAt: midBottomAt
4256 ,midLeftAt: midLeftAt
4257 ,midRightAt: midRightAt
4258 ,topLeftAt: topLeftAt
4259 ,topRightAt: topRightAt
4260 ,bottomLeftAt: bottomLeftAt
4261 ,bottomRightAt: bottomRightAt};
4262};
4263Elm.Graphics = Elm.Graphics || {};
4264Elm.Graphics.Collage = Elm.Graphics.Collage || {};
4265Elm.Graphics.Collage.make = function (_elm) {
4266 "use strict";
4267 _elm.Graphics = _elm.Graphics || {};
4268 _elm.Graphics.Collage = _elm.Graphics.Collage || {};
4269 if (_elm.Graphics.Collage.values) return _elm.Graphics.Collage.values;
4270 var _U = Elm.Native.Utils.make(_elm),
4271 $Basics = Elm.Basics.make(_elm),
4272 $Color = Elm.Color.make(_elm),
4273 $Graphics$Element = Elm.Graphics.Element.make(_elm),
4274 $List = Elm.List.make(_elm),
4275 $Native$Graphics$Collage = Elm.Native.Graphics.Collage.make(_elm),
4276 $Text = Elm.Text.make(_elm),
4277 $Transform2D = Elm.Transform2D.make(_elm);
4278 var _op = {};
4279 var Shape = function (a) { return {ctor: "Shape",_0: a};};
4280 var polygon = function (points) { return Shape(points);};
4281 var rect = F2(function (w,h) {
4282 var hh = h / 2;
4283 var hw = w / 2;
4284 return Shape(_U.list([{ctor: "_Tuple2",_0: 0 - hw,_1: 0 - hh}
4285 ,{ctor: "_Tuple2",_0: 0 - hw,_1: hh}
4286 ,{ctor: "_Tuple2",_0: hw,_1: hh}
4287 ,{ctor: "_Tuple2",_0: hw,_1: 0 - hh}]));
4288 });
4289 var square = function (n) { return A2(rect,n,n);};
4290 var oval = F2(function (w,h) {
4291 var hh = h / 2;
4292 var hw = w / 2;
4293 var n = 50;
4294 var t = 2 * $Basics.pi / n;
4295 var f = function (i) { return {ctor: "_Tuple2",_0: hw * $Basics.cos(t * i),_1: hh * $Basics.sin(t * i)};};
4296 return Shape(A2($List.map,f,_U.range(0,n - 1)));
4297 });
4298 var circle = function (r) { return A2(oval,2 * r,2 * r);};
4299 var ngon = F2(function (n,r) {
4300 var m = $Basics.toFloat(n);
4301 var t = 2 * $Basics.pi / m;
4302 var f = function (i) { return {ctor: "_Tuple2",_0: r * $Basics.cos(t * i),_1: r * $Basics.sin(t * i)};};
4303 return Shape(A2($List.map,f,_U.range(0,m - 1)));
4304 });
4305 var Path = function (a) { return {ctor: "Path",_0: a};};
4306 var path = function (ps) { return Path(ps);};
4307 var segment = F2(function (p1,p2) { return Path(_U.list([p1,p2]));});
4308 var collage = $Native$Graphics$Collage.collage;
4309 var Fill = function (a) { return {ctor: "Fill",_0: a};};
4310 var Line = function (a) { return {ctor: "Line",_0: a};};
4311 var FGroup = F2(function (a,b) { return {ctor: "FGroup",_0: a,_1: b};});
4312 var FElement = function (a) { return {ctor: "FElement",_0: a};};
4313 var FImage = F4(function (a,b,c,d) { return {ctor: "FImage",_0: a,_1: b,_2: c,_3: d};});
4314 var FText = function (a) { return {ctor: "FText",_0: a};};
4315 var FOutlinedText = F2(function (a,b) { return {ctor: "FOutlinedText",_0: a,_1: b};});
4316 var FShape = F2(function (a,b) { return {ctor: "FShape",_0: a,_1: b};});
4317 var FPath = F2(function (a,b) { return {ctor: "FPath",_0: a,_1: b};});
4318 var LineStyle = F6(function (a,b,c,d,e,f) { return {color: a,width: b,cap: c,join: d,dashing: e,dashOffset: f};});
4319 var Clipped = {ctor: "Clipped"};
4320 var Sharp = function (a) { return {ctor: "Sharp",_0: a};};
4321 var Smooth = {ctor: "Smooth"};
4322 var Padded = {ctor: "Padded"};
4323 var Round = {ctor: "Round"};
4324 var Flat = {ctor: "Flat"};
4325 var defaultLine = {color: $Color.black,width: 1,cap: Flat,join: Sharp(10),dashing: _U.list([]),dashOffset: 0};
4326 var solid = function (clr) { return _U.update(defaultLine,{color: clr});};
4327 var dashed = function (clr) { return _U.update(defaultLine,{color: clr,dashing: _U.list([8,4])});};
4328 var dotted = function (clr) { return _U.update(defaultLine,{color: clr,dashing: _U.list([3,3])});};
4329 var Grad = function (a) { return {ctor: "Grad",_0: a};};
4330 var Texture = function (a) { return {ctor: "Texture",_0: a};};
4331 var Solid = function (a) { return {ctor: "Solid",_0: a};};
4332 var Form_elm_builtin = function (a) { return {ctor: "Form_elm_builtin",_0: a};};
4333 var form = function (f) { return Form_elm_builtin({theta: 0,scale: 1,x: 0,y: 0,alpha: 1,form: f});};
4334 var fill = F2(function (style,_p0) { var _p1 = _p0;return form(A2(FShape,Fill(style),_p1._0));});
4335 var filled = F2(function (color,shape) { return A2(fill,Solid(color),shape);});
4336 var textured = F2(function (src,shape) { return A2(fill,Texture(src),shape);});
4337 var gradient = F2(function (grad,shape) { return A2(fill,Grad(grad),shape);});
4338 var outlined = F2(function (style,_p2) { var _p3 = _p2;return form(A2(FShape,Line(style),_p3._0));});
4339 var traced = F2(function (style,_p4) { var _p5 = _p4;return form(A2(FPath,style,_p5._0));});
4340 var sprite = F4(function (w,h,pos,src) { return form(A4(FImage,w,h,pos,src));});
4341 var toForm = function (e) { return form(FElement(e));};
4342 var group = function (fs) { return form(A2(FGroup,$Transform2D.identity,fs));};
4343 var groupTransform = F2(function (matrix,fs) { return form(A2(FGroup,matrix,fs));});
4344 var text = function (t) { return form(FText(t));};
4345 var outlinedText = F2(function (ls,t) { return form(A2(FOutlinedText,ls,t));});
4346 var move = F2(function (_p7,_p6) {
4347 var _p8 = _p7;
4348 var _p9 = _p6;
4349 var _p10 = _p9._0;
4350 return Form_elm_builtin(_U.update(_p10,{x: _p10.x + _p8._0,y: _p10.y + _p8._1}));
4351 });
4352 var moveX = F2(function (x,_p11) { var _p12 = _p11;var _p13 = _p12._0;return Form_elm_builtin(_U.update(_p13,{x: _p13.x + x}));});
4353 var moveY = F2(function (y,_p14) { var _p15 = _p14;var _p16 = _p15._0;return Form_elm_builtin(_U.update(_p16,{y: _p16.y + y}));});
4354 var scale = F2(function (s,_p17) { var _p18 = _p17;var _p19 = _p18._0;return Form_elm_builtin(_U.update(_p19,{scale: _p19.scale * s}));});
4355 var rotate = F2(function (t,_p20) { var _p21 = _p20;var _p22 = _p21._0;return Form_elm_builtin(_U.update(_p22,{theta: _p22.theta + t}));});
4356 var alpha = F2(function (a,_p23) { var _p24 = _p23;return Form_elm_builtin(_U.update(_p24._0,{alpha: a}));});
4357 return _elm.Graphics.Collage.values = {_op: _op
4358 ,collage: collage
4359 ,toForm: toForm
4360 ,filled: filled
4361 ,textured: textured
4362 ,gradient: gradient
4363 ,outlined: outlined
4364 ,traced: traced
4365 ,text: text
4366 ,outlinedText: outlinedText
4367 ,move: move
4368 ,moveX: moveX
4369 ,moveY: moveY
4370 ,scale: scale
4371 ,rotate: rotate
4372 ,alpha: alpha
4373 ,group: group
4374 ,groupTransform: groupTransform
4375 ,rect: rect
4376 ,oval: oval
4377 ,square: square
4378 ,circle: circle
4379 ,ngon: ngon
4380 ,polygon: polygon
4381 ,segment: segment
4382 ,path: path
4383 ,solid: solid
4384 ,dashed: dashed
4385 ,dotted: dotted
4386 ,defaultLine: defaultLine
4387 ,LineStyle: LineStyle
4388 ,Flat: Flat
4389 ,Round: Round
4390 ,Padded: Padded
4391 ,Smooth: Smooth
4392 ,Sharp: Sharp
4393 ,Clipped: Clipped};
4394};
4395Elm.Native.Debug = {};
4396Elm.Native.Debug.make = function(localRuntime) {
4397 localRuntime.Native = localRuntime.Native || {};
4398 localRuntime.Native.Debug = localRuntime.Native.Debug || {};
4399 if (localRuntime.Native.Debug.values)
4400 {
4401 return localRuntime.Native.Debug.values;
4402 }
4403
4404 var toString = Elm.Native.Utils.make(localRuntime).toString;
4405
4406 function log(tag, value)
4407 {
4408 var msg = tag + ': ' + toString(value);
4409 var process = process || {};
4410 if (process.stdout)
4411 {
4412 process.stdout.write(msg);
4413 }
4414 else
4415 {
4416 console.log(msg);
4417 }
4418 return value;
4419 }
4420
4421 function crash(message)
4422 {
4423 throw new Error(message);
4424 }
4425
4426 function tracePath(tag, form)
4427 {
4428 if (localRuntime.debug)
4429 {
4430 return localRuntime.debug.trace(tag, form);
4431 }
4432 return form;
4433 }
4434
4435 function watch(tag, value)
4436 {
4437 if (localRuntime.debug)
4438 {
4439 localRuntime.debug.watch(tag, value);
4440 }
4441 return value;
4442 }
4443
4444 function watchSummary(tag, summarize, value)
4445 {
4446 if (localRuntime.debug)
4447 {
4448 localRuntime.debug.watch(tag, summarize(value));
4449 }
4450 return value;
4451 }
4452
4453 return localRuntime.Native.Debug.values = {
4454 crash: crash,
4455 tracePath: F2(tracePath),
4456 log: F2(log),
4457 watch: F2(watch),
4458 watchSummary: F3(watchSummary)
4459 };
4460};
4461
4462Elm.Debug = Elm.Debug || {};
4463Elm.Debug.make = function (_elm) {
4464 "use strict";
4465 _elm.Debug = _elm.Debug || {};
4466 if (_elm.Debug.values) return _elm.Debug.values;
4467 var _U = Elm.Native.Utils.make(_elm),$Graphics$Collage = Elm.Graphics.Collage.make(_elm),$Native$Debug = Elm.Native.Debug.make(_elm);
4468 var _op = {};
4469 var trace = $Native$Debug.tracePath;
4470 var watchSummary = $Native$Debug.watchSummary;
4471 var watch = $Native$Debug.watch;
4472 var crash = $Native$Debug.crash;
4473 var log = $Native$Debug.log;
4474 return _elm.Debug.values = {_op: _op,log: log,crash: crash,watch: watch,watchSummary: watchSummary,trace: trace};
4475};
4476Elm.Result = Elm.Result || {};
4477Elm.Result.make = function (_elm) {
4478 "use strict";
4479 _elm.Result = _elm.Result || {};
4480 if (_elm.Result.values) return _elm.Result.values;
4481 var _U = Elm.Native.Utils.make(_elm),$Maybe = Elm.Maybe.make(_elm);
4482 var _op = {};
4483 var toMaybe = function (result) { var _p0 = result;if (_p0.ctor === "Ok") { return $Maybe.Just(_p0._0);} else { return $Maybe.Nothing;}};
4484 var withDefault = F2(function (def,result) { var _p1 = result;if (_p1.ctor === "Ok") { return _p1._0;} else { return def;}});
4485 var Err = function (a) { return {ctor: "Err",_0: a};};
4486 var andThen = F2(function (result,callback) { var _p2 = result;if (_p2.ctor === "Ok") { return callback(_p2._0);} else { return Err(_p2._0);}});
4487 var Ok = function (a) { return {ctor: "Ok",_0: a};};
4488 var map = F2(function (func,ra) { var _p3 = ra;if (_p3.ctor === "Ok") { return Ok(func(_p3._0));} else { return Err(_p3._0);}});
4489 var map2 = F3(function (func,ra,rb) {
4490 var _p4 = {ctor: "_Tuple2",_0: ra,_1: rb};
4491 if (_p4._0.ctor === "Ok") {
4492 if (_p4._1.ctor === "Ok") {
4493 return Ok(A2(func,_p4._0._0,_p4._1._0));
4494 } else {
4495 return Err(_p4._1._0);
4496 }
4497 } else {
4498 return Err(_p4._0._0);
4499 }
4500 });
4501 var map3 = F4(function (func,ra,rb,rc) {
4502 var _p5 = {ctor: "_Tuple3",_0: ra,_1: rb,_2: rc};
4503 if (_p5._0.ctor === "Ok") {
4504 if (_p5._1.ctor === "Ok") {
4505 if (_p5._2.ctor === "Ok") {
4506 return Ok(A3(func,_p5._0._0,_p5._1._0,_p5._2._0));
4507 } else {
4508 return Err(_p5._2._0);
4509 }
4510 } else {
4511 return Err(_p5._1._0);
4512 }
4513 } else {
4514 return Err(_p5._0._0);
4515 }
4516 });
4517 var map4 = F5(function (func,ra,rb,rc,rd) {
4518 var _p6 = {ctor: "_Tuple4",_0: ra,_1: rb,_2: rc,_3: rd};
4519 if (_p6._0.ctor === "Ok") {
4520 if (_p6._1.ctor === "Ok") {
4521 if (_p6._2.ctor === "Ok") {
4522 if (_p6._3.ctor === "Ok") {
4523 return Ok(A4(func,_p6._0._0,_p6._1._0,_p6._2._0,_p6._3._0));
4524 } else {
4525 return Err(_p6._3._0);
4526 }
4527 } else {
4528 return Err(_p6._2._0);
4529 }
4530 } else {
4531 return Err(_p6._1._0);
4532 }
4533 } else {
4534 return Err(_p6._0._0);
4535 }
4536 });
4537 var map5 = F6(function (func,ra,rb,rc,rd,re) {
4538 var _p7 = {ctor: "_Tuple5",_0: ra,_1: rb,_2: rc,_3: rd,_4: re};
4539 if (_p7._0.ctor === "Ok") {
4540 if (_p7._1.ctor === "Ok") {
4541 if (_p7._2.ctor === "Ok") {
4542 if (_p7._3.ctor === "Ok") {
4543 if (_p7._4.ctor === "Ok") {
4544 return Ok(A5(func,_p7._0._0,_p7._1._0,_p7._2._0,_p7._3._0,_p7._4._0));
4545 } else {
4546 return Err(_p7._4._0);
4547 }
4548 } else {
4549 return Err(_p7._3._0);
4550 }
4551 } else {
4552 return Err(_p7._2._0);
4553 }
4554 } else {
4555 return Err(_p7._1._0);
4556 }
4557 } else {
4558 return Err(_p7._0._0);
4559 }
4560 });
4561 var formatError = F2(function (f,result) { var _p8 = result;if (_p8.ctor === "Ok") { return Ok(_p8._0);} else { return Err(f(_p8._0));}});
4562 var fromMaybe = F2(function (err,maybe) { var _p9 = maybe;if (_p9.ctor === "Just") { return Ok(_p9._0);} else { return Err(err);}});
4563 return _elm.Result.values = {_op: _op
4564 ,withDefault: withDefault
4565 ,map: map
4566 ,map2: map2
4567 ,map3: map3
4568 ,map4: map4
4569 ,map5: map5
4570 ,andThen: andThen
4571 ,toMaybe: toMaybe
4572 ,fromMaybe: fromMaybe
4573 ,formatError: formatError
4574 ,Ok: Ok
4575 ,Err: Err};
4576};
4577Elm.Native.Signal = {};
4578
4579Elm.Native.Signal.make = function(localRuntime) {
4580 localRuntime.Native = localRuntime.Native || {};
4581 localRuntime.Native.Signal = localRuntime.Native.Signal || {};
4582 if (localRuntime.Native.Signal.values)
4583 {
4584 return localRuntime.Native.Signal.values;
4585 }
4586
4587
4588 var Task = Elm.Native.Task.make(localRuntime);
4589 var Utils = Elm.Native.Utils.make(localRuntime);
4590
4591
4592 function broadcastToKids(node, timestamp, update)
4593 {
4594 var kids = node.kids;
4595 for (var i = kids.length; i--; )
4596 {
4597 kids[i].notify(timestamp, update, node.id);
4598 }
4599 }
4600
4601
4602 // INPUT
4603
4604 function input(name, base)
4605 {
4606 var node = {
4607 id: Utils.guid(),
4608 name: 'input-' + name,
4609 value: base,
4610 parents: [],
4611 kids: []
4612 };
4613
4614 node.notify = function(timestamp, targetId, value) {
4615 var update = targetId === node.id;
4616 if (update)
4617 {
4618 node.value = value;
4619 }
4620 broadcastToKids(node, timestamp, update);
4621 return update;
4622 };
4623
4624 localRuntime.inputs.push(node);
4625
4626 return node;
4627 }
4628
4629 function constant(value)
4630 {
4631 return input('constant', value);
4632 }
4633
4634
4635 // MAILBOX
4636
4637 function mailbox(base)
4638 {
4639 var signal = input('mailbox', base);
4640
4641 function send(value) {
4642 return Task.asyncFunction(function(callback) {
4643 localRuntime.setTimeout(function() {
4644 localRuntime.notify(signal.id, value);
4645 }, 0);
4646 callback(Task.succeed(Utils.Tuple0));
4647 });
4648 }
4649
4650 return {
4651 signal: signal,
4652 address: {
4653 ctor: 'Address',
4654 _0: send
4655 }
4656 };
4657 }
4658
4659 function sendMessage(message)
4660 {
4661 Task.perform(message._0);
4662 }
4663
4664
4665 // OUTPUT
4666
4667 function output(name, handler, parent)
4668 {
4669 var node = {
4670 id: Utils.guid(),
4671 name: 'output-' + name,
4672 parents: [parent],
4673 isOutput: true
4674 };
4675
4676 node.notify = function(timestamp, parentUpdate, parentID)
4677 {
4678 if (parentUpdate)
4679 {
4680 handler(parent.value);
4681 }
4682 };
4683
4684 parent.kids.push(node);
4685
4686 return node;
4687 }
4688
4689
4690 // MAP
4691
4692 function mapMany(refreshValue, args)
4693 {
4694 var node = {
4695 id: Utils.guid(),
4696 name: 'map' + args.length,
4697 value: refreshValue(),
4698 parents: args,
4699 kids: []
4700 };
4701
4702 var numberOfParents = args.length;
4703 var count = 0;
4704 var update = false;
4705
4706 node.notify = function(timestamp, parentUpdate, parentID)
4707 {
4708 ++count;
4709
4710 update = update || parentUpdate;
4711
4712 if (count === numberOfParents)
4713 {
4714 if (update)
4715 {
4716 node.value = refreshValue();
4717 }
4718 broadcastToKids(node, timestamp, update);
4719 update = false;
4720 count = 0;
4721 }
4722 };
4723
4724 for (var i = numberOfParents; i--; )
4725 {
4726 args[i].kids.push(node);
4727 }
4728
4729 return node;
4730 }
4731
4732
4733 function map(func, a)
4734 {
4735 function refreshValue()
4736 {
4737 return func(a.value);
4738 }
4739 return mapMany(refreshValue, [a]);
4740 }
4741
4742
4743 function map2(func, a, b)
4744 {
4745 function refreshValue()
4746 {
4747 return A2( func, a.value, b.value );
4748 }
4749 return mapMany(refreshValue, [a, b]);
4750 }
4751
4752
4753 function map3(func, a, b, c)
4754 {
4755 function refreshValue()
4756 {
4757 return A3( func, a.value, b.value, c.value );
4758 }
4759 return mapMany(refreshValue, [a, b, c]);
4760 }
4761
4762
4763 function map4(func, a, b, c, d)
4764 {
4765 function refreshValue()
4766 {
4767 return A4( func, a.value, b.value, c.value, d.value );
4768 }
4769 return mapMany(refreshValue, [a, b, c, d]);
4770 }
4771
4772
4773 function map5(func, a, b, c, d, e)
4774 {
4775 function refreshValue()
4776 {
4777 return A5( func, a.value, b.value, c.value, d.value, e.value );
4778 }
4779 return mapMany(refreshValue, [a, b, c, d, e]);
4780 }
4781
4782
4783 // FOLD
4784
4785 function foldp(update, state, signal)
4786 {
4787 var node = {
4788 id: Utils.guid(),
4789 name: 'foldp',
4790 parents: [signal],
4791 kids: [],
4792 value: state
4793 };
4794
4795 node.notify = function(timestamp, parentUpdate, parentID)
4796 {
4797 if (parentUpdate)
4798 {
4799 node.value = A2( update, signal.value, node.value );
4800 }
4801 broadcastToKids(node, timestamp, parentUpdate);
4802 };
4803
4804 signal.kids.push(node);
4805
4806 return node;
4807 }
4808
4809
4810 // TIME
4811
4812 function timestamp(signal)
4813 {
4814 var node = {
4815 id: Utils.guid(),
4816 name: 'timestamp',
4817 value: Utils.Tuple2(localRuntime.timer.programStart, signal.value),
4818 parents: [signal],
4819 kids: []
4820 };
4821
4822 node.notify = function(timestamp, parentUpdate, parentID)
4823 {
4824 if (parentUpdate)
4825 {
4826 node.value = Utils.Tuple2(timestamp, signal.value);
4827 }
4828 broadcastToKids(node, timestamp, parentUpdate);
4829 };
4830
4831 signal.kids.push(node);
4832
4833 return node;
4834 }
4835
4836
4837 function delay(time, signal)
4838 {
4839 var delayed = input('delay-input-' + time, signal.value);
4840
4841 function handler(value)
4842 {
4843 setTimeout(function() {
4844 localRuntime.notify(delayed.id, value);
4845 }, time);
4846 }
4847
4848 output('delay-output-' + time, handler, signal);
4849
4850 return delayed;
4851 }
4852
4853
4854 // MERGING
4855
4856 function genericMerge(tieBreaker, leftStream, rightStream)
4857 {
4858 var node = {
4859 id: Utils.guid(),
4860 name: 'merge',
4861 value: A2(tieBreaker, leftStream.value, rightStream.value),
4862 parents: [leftStream, rightStream],
4863 kids: []
4864 };
4865
4866 var left = { touched: false, update: false, value: null };
4867 var right = { touched: false, update: false, value: null };
4868
4869 node.notify = function(timestamp, parentUpdate, parentID)
4870 {
4871 if (parentID === leftStream.id)
4872 {
4873 left.touched = true;
4874 left.update = parentUpdate;
4875 left.value = leftStream.value;
4876 }
4877 if (parentID === rightStream.id)
4878 {
4879 right.touched = true;
4880 right.update = parentUpdate;
4881 right.value = rightStream.value;
4882 }
4883
4884 if (left.touched && right.touched)
4885 {
4886 var update = false;
4887 if (left.update && right.update)
4888 {
4889 node.value = A2(tieBreaker, left.value, right.value);
4890 update = true;
4891 }
4892 else if (left.update)
4893 {
4894 node.value = left.value;
4895 update = true;
4896 }
4897 else if (right.update)
4898 {
4899 node.value = right.value;
4900 update = true;
4901 }
4902 left.touched = false;
4903 right.touched = false;
4904
4905 broadcastToKids(node, timestamp, update);
4906 }
4907 };
4908
4909 leftStream.kids.push(node);
4910 rightStream.kids.push(node);
4911
4912 return node;
4913 }
4914
4915
4916 // FILTERING
4917
4918 function filterMap(toMaybe, base, signal)
4919 {
4920 var maybe = toMaybe(signal.value);
4921 var node = {
4922 id: Utils.guid(),
4923 name: 'filterMap',
4924 value: maybe.ctor === 'Nothing' ? base : maybe._0,
4925 parents: [signal],
4926 kids: []
4927 };
4928
4929 node.notify = function(timestamp, parentUpdate, parentID)
4930 {
4931 var update = false;
4932 if (parentUpdate)
4933 {
4934 var maybe = toMaybe(signal.value);
4935 if (maybe.ctor === 'Just')
4936 {
4937 update = true;
4938 node.value = maybe._0;
4939 }
4940 }
4941 broadcastToKids(node, timestamp, update);
4942 };
4943
4944 signal.kids.push(node);
4945
4946 return node;
4947 }
4948
4949
4950 // SAMPLING
4951
4952 function sampleOn(ticker, signal)
4953 {
4954 var node = {
4955 id: Utils.guid(),
4956 name: 'sampleOn',
4957 value: signal.value,
4958 parents: [ticker, signal],
4959 kids: []
4960 };
4961
4962 var signalTouch = false;
4963 var tickerTouch = false;
4964 var tickerUpdate = false;
4965
4966 node.notify = function(timestamp, parentUpdate, parentID)
4967 {
4968 if (parentID === ticker.id)
4969 {
4970 tickerTouch = true;
4971 tickerUpdate = parentUpdate;
4972 }
4973 if (parentID === signal.id)
4974 {
4975 signalTouch = true;
4976 }
4977
4978 if (tickerTouch && signalTouch)
4979 {
4980 if (tickerUpdate)
4981 {
4982 node.value = signal.value;
4983 }
4984 tickerTouch = false;
4985 signalTouch = false;
4986
4987 broadcastToKids(node, timestamp, tickerUpdate);
4988 }
4989 };
4990
4991 ticker.kids.push(node);
4992 signal.kids.push(node);
4993
4994 return node;
4995 }
4996
4997
4998 // DROP REPEATS
4999
5000 function dropRepeats(signal)
5001 {
5002 var node = {
5003 id: Utils.guid(),
5004 name: 'dropRepeats',
5005 value: signal.value,
5006 parents: [signal],
5007 kids: []
5008 };
5009
5010 node.notify = function(timestamp, parentUpdate, parentID)
5011 {
5012 var update = false;
5013 if (parentUpdate && !Utils.eq(node.value, signal.value))
5014 {
5015 node.value = signal.value;
5016 update = true;
5017 }
5018 broadcastToKids(node, timestamp, update);
5019 };
5020
5021 signal.kids.push(node);
5022
5023 return node;
5024 }
5025
5026
5027 return localRuntime.Native.Signal.values = {
5028 input: input,
5029 constant: constant,
5030 mailbox: mailbox,
5031 sendMessage: sendMessage,
5032 output: output,
5033 map: F2(map),
5034 map2: F3(map2),
5035 map3: F4(map3),
5036 map4: F5(map4),
5037 map5: F6(map5),
5038 foldp: F3(foldp),
5039 genericMerge: F3(genericMerge),
5040 filterMap: F3(filterMap),
5041 sampleOn: F2(sampleOn),
5042 dropRepeats: dropRepeats,
5043 timestamp: timestamp,
5044 delay: F2(delay)
5045 };
5046};
5047
5048Elm.Native.Task = {};
5049
5050Elm.Native.Task.make = function(localRuntime) {
5051 localRuntime.Native = localRuntime.Native || {};
5052 localRuntime.Native.Task = localRuntime.Native.Task || {};
5053 if (localRuntime.Native.Task.values)
5054 {
5055 return localRuntime.Native.Task.values;
5056 }
5057
5058 var Result = Elm.Result.make(localRuntime);
5059 var Signal;
5060 var Utils = Elm.Native.Utils.make(localRuntime);
5061
5062
5063 // CONSTRUCTORS
5064
5065 function succeed(value)
5066 {
5067 return {
5068 tag: 'Succeed',
5069 value: value
5070 };
5071 }
5072
5073 function fail(error)
5074 {
5075 return {
5076 tag: 'Fail',
5077 value: error
5078 };
5079 }
5080
5081 function asyncFunction(func)
5082 {
5083 return {
5084 tag: 'Async',
5085 asyncFunction: func
5086 };
5087 }
5088
5089 function andThen(task, callback)
5090 {
5091 return {
5092 tag: 'AndThen',
5093 task: task,
5094 callback: callback
5095 };
5096 }
5097
5098 function catch_(task, callback)
5099 {
5100 return {
5101 tag: 'Catch',
5102 task: task,
5103 callback: callback
5104 };
5105 }
5106
5107
5108 // RUNNER
5109
5110 function perform(task) {
5111 runTask({ task: task }, function() {});
5112 }
5113
5114 function performSignal(name, signal)
5115 {
5116 var workQueue = [];
5117
5118 function onComplete()
5119 {
5120 workQueue.shift();
5121
5122 if (workQueue.length > 0)
5123 {
5124 var task = workQueue[0];
5125
5126 setTimeout(function() {
5127 runTask(task, onComplete);
5128 }, 0);
5129 }
5130 }
5131
5132 function register(task)
5133 {
5134 var root = { task: task };
5135 workQueue.push(root);
5136 if (workQueue.length === 1)
5137 {
5138 runTask(root, onComplete);
5139 }
5140 }
5141
5142 if (!Signal)
5143 {
5144 Signal = Elm.Native.Signal.make(localRuntime);
5145 }
5146 Signal.output('perform-tasks-' + name, register, signal);
5147
5148 register(signal.value);
5149
5150 return signal;
5151 }
5152
5153 function mark(status, task)
5154 {
5155 return { status: status, task: task };
5156 }
5157
5158 function runTask(root, onComplete)
5159 {
5160 var result = mark('runnable', root.task);
5161 while (result.status === 'runnable')
5162 {
5163 result = stepTask(onComplete, root, result.task);
5164 }
5165
5166 if (result.status === 'done')
5167 {
5168 root.task = result.task;
5169 onComplete();
5170 }
5171
5172 if (result.status === 'blocked')
5173 {
5174 root.task = result.task;
5175 }
5176 }
5177
5178 function stepTask(onComplete, root, task)
5179 {
5180 var tag = task.tag;
5181
5182 if (tag === 'Succeed' || tag === 'Fail')
5183 {
5184 return mark('done', task);
5185 }
5186
5187 if (tag === 'Async')
5188 {
5189 var placeHolder = {};
5190 var couldBeSync = true;
5191 var wasSync = false;
5192
5193 task.asyncFunction(function(result) {
5194 placeHolder.tag = result.tag;
5195 placeHolder.value = result.value;
5196 if (couldBeSync)
5197 {
5198 wasSync = true;
5199 }
5200 else
5201 {
5202 runTask(root, onComplete);
5203 }
5204 });
5205 couldBeSync = false;
5206 return mark(wasSync ? 'done' : 'blocked', placeHolder);
5207 }
5208
5209 if (tag === 'AndThen' || tag === 'Catch')
5210 {
5211 var result = mark('runnable', task.task);
5212 while (result.status === 'runnable')
5213 {
5214 result = stepTask(onComplete, root, result.task);
5215 }
5216
5217 if (result.status === 'done')
5218 {
5219 var activeTask = result.task;
5220 var activeTag = activeTask.tag;
5221
5222 var succeedChain = activeTag === 'Succeed' && tag === 'AndThen';
5223 var failChain = activeTag === 'Fail' && tag === 'Catch';
5224
5225 return (succeedChain || failChain)
5226 ? mark('runnable', task.callback(activeTask.value))
5227 : mark('runnable', activeTask);
5228 }
5229 if (result.status === 'blocked')
5230 {
5231 return mark('blocked', {
5232 tag: tag,
5233 task: result.task,
5234 callback: task.callback
5235 });
5236 }
5237 }
5238 }
5239
5240
5241 // THREADS
5242
5243 function sleep(time) {
5244 return asyncFunction(function(callback) {
5245 setTimeout(function() {
5246 callback(succeed(Utils.Tuple0));
5247 }, time);
5248 });
5249 }
5250
5251 function spawn(task) {
5252 return asyncFunction(function(callback) {
5253 var id = setTimeout(function() {
5254 perform(task);
5255 }, 0);
5256 callback(succeed(id));
5257 });
5258 }
5259
5260
5261 return localRuntime.Native.Task.values = {
5262 succeed: succeed,
5263 fail: fail,
5264 asyncFunction: asyncFunction,
5265 andThen: F2(andThen),
5266 catch_: F2(catch_),
5267 perform: perform,
5268 performSignal: performSignal,
5269 spawn: spawn,
5270 sleep: sleep
5271 };
5272};
5273
5274Elm.Task = Elm.Task || {};
5275Elm.Task.make = function (_elm) {
5276 "use strict";
5277 _elm.Task = _elm.Task || {};
5278 if (_elm.Task.values) return _elm.Task.values;
5279 var _U = Elm.Native.Utils.make(_elm),
5280 $List = Elm.List.make(_elm),
5281 $Maybe = Elm.Maybe.make(_elm),
5282 $Native$Task = Elm.Native.Task.make(_elm),
5283 $Result = Elm.Result.make(_elm);
5284 var _op = {};
5285 var sleep = $Native$Task.sleep;
5286 var spawn = $Native$Task.spawn;
5287 var ThreadID = function (a) { return {ctor: "ThreadID",_0: a};};
5288 var onError = $Native$Task.catch_;
5289 var andThen = $Native$Task.andThen;
5290 var fail = $Native$Task.fail;
5291 var mapError = F2(function (f,task) { return A2(onError,task,function (err) { return fail(f(err));});});
5292 var succeed = $Native$Task.succeed;
5293 var map = F2(function (func,taskA) { return A2(andThen,taskA,function (a) { return succeed(func(a));});});
5294 var map2 = F3(function (func,taskA,taskB) {
5295 return A2(andThen,taskA,function (a) { return A2(andThen,taskB,function (b) { return succeed(A2(func,a,b));});});
5296 });
5297 var map3 = F4(function (func,taskA,taskB,taskC) {
5298 return A2(andThen,
5299 taskA,
5300 function (a) {
5301 return A2(andThen,taskB,function (b) { return A2(andThen,taskC,function (c) { return succeed(A3(func,a,b,c));});});
5302 });
5303 });
5304 var map4 = F5(function (func,taskA,taskB,taskC,taskD) {
5305 return A2(andThen,
5306 taskA,
5307 function (a) {
5308 return A2(andThen,
5309 taskB,
5310 function (b) {
5311 return A2(andThen,taskC,function (c) { return A2(andThen,taskD,function (d) { return succeed(A4(func,a,b,c,d));});});
5312 });
5313 });
5314 });
5315 var map5 = F6(function (func,taskA,taskB,taskC,taskD,taskE) {
5316 return A2(andThen,
5317 taskA,
5318 function (a) {
5319 return A2(andThen,
5320 taskB,
5321 function (b) {
5322 return A2(andThen,
5323 taskC,
5324 function (c) {
5325 return A2(andThen,taskD,function (d) { return A2(andThen,taskE,function (e) { return succeed(A5(func,a,b,c,d,e));});});
5326 });
5327 });
5328 });
5329 });
5330 var andMap = F2(function (taskFunc,taskValue) {
5331 return A2(andThen,taskFunc,function (func) { return A2(andThen,taskValue,function (value) { return succeed(func(value));});});
5332 });
5333 var sequence = function (tasks) {
5334 var _p0 = tasks;
5335 if (_p0.ctor === "[]") {
5336 return succeed(_U.list([]));
5337 } else {
5338 return A3(map2,F2(function (x,y) { return A2($List._op["::"],x,y);}),_p0._0,sequence(_p0._1));
5339 }
5340 };
5341 var toMaybe = function (task) { return A2(onError,A2(map,$Maybe.Just,task),function (_p1) { return succeed($Maybe.Nothing);});};
5342 var fromMaybe = F2(function ($default,maybe) { var _p2 = maybe;if (_p2.ctor === "Just") { return succeed(_p2._0);} else { return fail($default);}});
5343 var toResult = function (task) { return A2(onError,A2(map,$Result.Ok,task),function (msg) { return succeed($Result.Err(msg));});};
5344 var fromResult = function (result) { var _p3 = result;if (_p3.ctor === "Ok") { return succeed(_p3._0);} else { return fail(_p3._0);}};
5345 var Task = {ctor: "Task"};
5346 return _elm.Task.values = {_op: _op
5347 ,succeed: succeed
5348 ,fail: fail
5349 ,map: map
5350 ,map2: map2
5351 ,map3: map3
5352 ,map4: map4
5353 ,map5: map5
5354 ,andMap: andMap
5355 ,sequence: sequence
5356 ,andThen: andThen
5357 ,onError: onError
5358 ,mapError: mapError
5359 ,toMaybe: toMaybe
5360 ,fromMaybe: fromMaybe
5361 ,toResult: toResult
5362 ,fromResult: fromResult
5363 ,spawn: spawn
5364 ,sleep: sleep};
5365};
5366Elm.Signal = Elm.Signal || {};
5367Elm.Signal.make = function (_elm) {
5368 "use strict";
5369 _elm.Signal = _elm.Signal || {};
5370 if (_elm.Signal.values) return _elm.Signal.values;
5371 var _U = Elm.Native.Utils.make(_elm),
5372 $Basics = Elm.Basics.make(_elm),
5373 $Debug = Elm.Debug.make(_elm),
5374 $List = Elm.List.make(_elm),
5375 $Maybe = Elm.Maybe.make(_elm),
5376 $Native$Signal = Elm.Native.Signal.make(_elm),
5377 $Task = Elm.Task.make(_elm);
5378 var _op = {};
5379 var send = F2(function (_p0,value) {
5380 var _p1 = _p0;
5381 return A2($Task.onError,_p1._0(value),function (_p2) { return $Task.succeed({ctor: "_Tuple0"});});
5382 });
5383 var Message = function (a) { return {ctor: "Message",_0: a};};
5384 var message = F2(function (_p3,value) { var _p4 = _p3;return Message(_p4._0(value));});
5385 var mailbox = $Native$Signal.mailbox;
5386 var Address = function (a) { return {ctor: "Address",_0: a};};
5387 var forwardTo = F2(function (_p5,f) { var _p6 = _p5;return Address(function (x) { return _p6._0(f(x));});});
5388 var Mailbox = F2(function (a,b) { return {address: a,signal: b};});
5389 var sampleOn = $Native$Signal.sampleOn;
5390 var dropRepeats = $Native$Signal.dropRepeats;
5391 var filterMap = $Native$Signal.filterMap;
5392 var filter = F3(function (isOk,base,signal) {
5393 return A3(filterMap,function (value) { return isOk(value) ? $Maybe.Just(value) : $Maybe.Nothing;},base,signal);
5394 });
5395 var merge = F2(function (left,right) { return A3($Native$Signal.genericMerge,$Basics.always,left,right);});
5396 var mergeMany = function (signalList) {
5397 var _p7 = $List.reverse(signalList);
5398 if (_p7.ctor === "[]") {
5399 return _U.crashCase("Signal",{start: {line: 184,column: 3},end: {line: 189,column: 40}},_p7)("mergeMany was given an empty list!");
5400 } else {
5401 return A3($List.foldl,merge,_p7._0,_p7._1);
5402 }
5403 };
5404 var foldp = $Native$Signal.foldp;
5405 var map5 = $Native$Signal.map5;
5406 var map4 = $Native$Signal.map4;
5407 var map3 = $Native$Signal.map3;
5408 var map2 = $Native$Signal.map2;
5409 var map = $Native$Signal.map;
5410 var constant = $Native$Signal.constant;
5411 var Signal = {ctor: "Signal"};
5412 return _elm.Signal.values = {_op: _op
5413 ,merge: merge
5414 ,mergeMany: mergeMany
5415 ,map: map
5416 ,map2: map2
5417 ,map3: map3
5418 ,map4: map4
5419 ,map5: map5
5420 ,constant: constant
5421 ,dropRepeats: dropRepeats
5422 ,filter: filter
5423 ,filterMap: filterMap
5424 ,sampleOn: sampleOn
5425 ,foldp: foldp
5426 ,mailbox: mailbox
5427 ,send: send
5428 ,message: message
5429 ,forwardTo: forwardTo
5430 ,Mailbox: Mailbox};
5431};
5432Elm.Native.Time = {};
5433
5434Elm.Native.Time.make = function(localRuntime)
5435{
5436 localRuntime.Native = localRuntime.Native || {};
5437 localRuntime.Native.Time = localRuntime.Native.Time || {};
5438 if (localRuntime.Native.Time.values)
5439 {
5440 return localRuntime.Native.Time.values;
5441 }
5442
5443 var NS = Elm.Native.Signal.make(localRuntime);
5444 var Maybe = Elm.Maybe.make(localRuntime);
5445
5446
5447 // FRAMES PER SECOND
5448
5449 function fpsWhen(desiredFPS, isOn)
5450 {
5451 var msPerFrame = 1000 / desiredFPS;
5452 var ticker = NS.input('fps-' + desiredFPS, null);
5453
5454 function notifyTicker()
5455 {
5456 localRuntime.notify(ticker.id, null);
5457 }
5458
5459 function firstArg(x, y)
5460 {
5461 return x;
5462 }
5463
5464 // input fires either when isOn changes, or when ticker fires.
5465 // Its value is a tuple with the current timestamp, and the state of isOn
5466 var input = NS.timestamp(A3(NS.map2, F2(firstArg), NS.dropRepeats(isOn), ticker));
5467
5468 var initialState = {
5469 isOn: false,
5470 time: localRuntime.timer.programStart,
5471 delta: 0
5472 };
5473
5474 var timeoutId;
5475
5476 function update(input, state)
5477 {
5478 var currentTime = input._0;
5479 var isOn = input._1;
5480 var wasOn = state.isOn;
5481 var previousTime = state.time;
5482
5483 if (isOn)
5484 {
5485 timeoutId = localRuntime.setTimeout(notifyTicker, msPerFrame);
5486 }
5487 else if (wasOn)
5488 {
5489 clearTimeout(timeoutId);
5490 }
5491
5492 return {
5493 isOn: isOn,
5494 time: currentTime,
5495 delta: (isOn && !wasOn) ? 0 : currentTime - previousTime
5496 };
5497 }
5498
5499 return A2(
5500 NS.map,
5501 function(state) { return state.delta; },
5502 A3(NS.foldp, F2(update), update(input.value, initialState), input)
5503 );
5504 }
5505
5506
5507 // EVERY
5508
5509 function every(t)
5510 {
5511 var ticker = NS.input('every-' + t, null);
5512 function tellTime()
5513 {
5514 localRuntime.notify(ticker.id, null);
5515 }
5516 var clock = A2(NS.map, fst, NS.timestamp(ticker));
5517 setInterval(tellTime, t);
5518 return clock;
5519 }
5520
5521
5522 function fst(pair)
5523 {
5524 return pair._0;
5525 }
5526
5527
5528 function read(s)
5529 {
5530 var t = Date.parse(s);
5531 return isNaN(t) ? Maybe.Nothing : Maybe.Just(t);
5532 }
5533
5534 return localRuntime.Native.Time.values = {
5535 fpsWhen: F2(fpsWhen),
5536 every: every,
5537 toDate: function(t) { return new Date(t); },
5538 read: read
5539 };
5540};
5541
5542Elm.Time = Elm.Time || {};
5543Elm.Time.make = function (_elm) {
5544 "use strict";
5545 _elm.Time = _elm.Time || {};
5546 if (_elm.Time.values) return _elm.Time.values;
5547 var _U = Elm.Native.Utils.make(_elm),
5548 $Basics = Elm.Basics.make(_elm),
5549 $Native$Signal = Elm.Native.Signal.make(_elm),
5550 $Native$Time = Elm.Native.Time.make(_elm),
5551 $Signal = Elm.Signal.make(_elm);
5552 var _op = {};
5553 var delay = $Native$Signal.delay;
5554 var since = F2(function (time,signal) {
5555 var stop = A2($Signal.map,$Basics.always(-1),A2(delay,time,signal));
5556 var start = A2($Signal.map,$Basics.always(1),signal);
5557 var delaydiff = A3($Signal.foldp,F2(function (x,y) { return x + y;}),0,A2($Signal.merge,start,stop));
5558 return A2($Signal.map,F2(function (x,y) { return !_U.eq(x,y);})(0),delaydiff);
5559 });
5560 var timestamp = $Native$Signal.timestamp;
5561 var every = $Native$Time.every;
5562 var fpsWhen = $Native$Time.fpsWhen;
5563 var fps = function (targetFrames) { return A2(fpsWhen,targetFrames,$Signal.constant(true));};
5564 var inMilliseconds = function (t) { return t;};
5565 var millisecond = 1;
5566 var second = 1000 * millisecond;
5567 var minute = 60 * second;
5568 var hour = 60 * minute;
5569 var inHours = function (t) { return t / hour;};
5570 var inMinutes = function (t) { return t / minute;};
5571 var inSeconds = function (t) { return t / second;};
5572 return _elm.Time.values = {_op: _op
5573 ,millisecond: millisecond
5574 ,second: second
5575 ,minute: minute
5576 ,hour: hour
5577 ,inMilliseconds: inMilliseconds
5578 ,inSeconds: inSeconds
5579 ,inMinutes: inMinutes
5580 ,inHours: inHours
5581 ,fps: fps
5582 ,fpsWhen: fpsWhen
5583 ,every: every
5584 ,timestamp: timestamp
5585 ,delay: delay
5586 ,since: since};
5587};
5588Elm.Task = Elm.Task || {};
5589Elm.Task.Extra = Elm.Task.Extra || {};
5590Elm.Task.Extra.make = function (_elm) {
5591 "use strict";
5592 _elm.Task = _elm.Task || {};
5593 _elm.Task.Extra = _elm.Task.Extra || {};
5594 if (_elm.Task.Extra.values) return _elm.Task.Extra.values;
5595 var _U = Elm.Native.Utils.make(_elm),
5596 $Basics = Elm.Basics.make(_elm),
5597 $Debug = Elm.Debug.make(_elm),
5598 $List = Elm.List.make(_elm),
5599 $Maybe = Elm.Maybe.make(_elm),
5600 $Result = Elm.Result.make(_elm),
5601 $Signal = Elm.Signal.make(_elm),
5602 $Task = Elm.Task.make(_elm),
5603 $Time = Elm.Time.make(_elm);
5604 var _op = {};
5605 var computeLazyAsync = F2(function (address,lazy) {
5606 return A2($Task.andThen,
5607 $Task.spawn(A2($Task.andThen,
5608 $Task.succeed(lazy),
5609 function (f) {
5610 return A2($Task.andThen,$Task.succeed(f({ctor: "_Tuple0"})),function (value) { return A2($Signal.send,address,value);});
5611 })),
5612 function (_p0) {
5613 return $Task.succeed({ctor: "_Tuple0"});
5614 });
5615 });
5616 var interceptError = F2(function (failAddress,task) {
5617 return A2($Task.onError,
5618 task,
5619 function (error) {
5620 return A2($Task.andThen,A2($Signal.send,failAddress,error),function (_p1) { return $Task.fail(error);});
5621 });
5622 });
5623 var interceptSuccess = F2(function (successAddress,task) {
5624 return A2($Task.andThen,
5625 task,
5626 function (value) {
5627 return A2($Task.andThen,A2($Signal.send,successAddress,value),function (_p2) { return $Task.succeed(value);});
5628 });
5629 });
5630 var intercept = F2(function (address,task) {
5631 return A2($Task.andThen,
5632 A2($Task.onError,
5633 task,
5634 function (error) {
5635 return A2($Task.andThen,A2($Signal.send,address,$Result.Err(error)),function (_p3) { return $Task.fail(error);});
5636 }),
5637 function (value) {
5638 return A2($Task.andThen,A2($Signal.send,address,$Result.Ok(value)),function (_p4) { return $Task.succeed(value);});
5639 });
5640 });
5641 var delay = F2(function (time,task) { return A2($Task.andThen,$Task.sleep(time),function (_p5) { return task;});});
5642 var loop = F2(function (every,task) {
5643 return A2($Task.andThen,task,function (_p6) { return A2($Task.andThen,$Task.sleep(every),function (_p7) { return A2(loop,every,task);});});
5644 });
5645 var optional = function (list) {
5646 var _p8 = list;
5647 if (_p8.ctor === "[]") {
5648 return $Task.succeed(_U.list([]));
5649 } else {
5650 var _p10 = _p8._1;
5651 return A2($Task.onError,
5652 A2($Task.andThen,
5653 _p8._0,
5654 function (value) {
5655 return A2($Task.map,F2(function (x,y) { return A2($List._op["::"],x,y);})(value),optional(_p10));
5656 }),
5657 function (_p9) {
5658 return optional(_p10);
5659 });
5660 }
5661 };
5662 var parallel = function (tasks) { return $Task.sequence(A2($List.map,$Task.spawn,tasks));};
5663 var broadcast = F2(function (addresses,value) {
5664 return A2($Task.andThen,
5665 parallel(A2($List.map,function (address) { return A2($Signal.send,address,value);},addresses)),
5666 function (_p11) {
5667 return $Task.succeed({ctor: "_Tuple0"});
5668 });
5669 });
5670 return _elm.Task.Extra.values = {_op: _op
5671 ,parallel: parallel
5672 ,broadcast: broadcast
5673 ,optional: optional
5674 ,loop: loop
5675 ,delay: delay
5676 ,intercept: intercept
5677 ,interceptSuccess: interceptSuccess
5678 ,interceptError: interceptError
5679 ,computeLazyAsync: computeLazyAsync};
5680};
5681/*! @license Firebase v2.3.1
5682 License: https://www.firebase.com/terms/terms-of-service.html */
5683(function() {var g,aa=this;function n(a){return void 0!==a}function ba(){}function ca(a){a.ub=function(){return a.uf?a.uf:a.uf=new a}}
5684function da(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
5685else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function ea(a){return"array"==da(a)}function fa(a){var b=da(a);return"array"==b||"object"==b&&"number"==typeof a.length}function p(a){return"string"==typeof a}function ga(a){return"number"==typeof a}function ha(a){return"function"==da(a)}function ia(a){var b=typeof a;return"object"==b&&null!=a||"function"==b}function ja(a,b,c){return a.call.apply(a.bind,arguments)}
5686function ka(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}}function q(a,b,c){q=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?ja:ka;return q.apply(null,arguments)}var la=Date.now||function(){return+new Date};
5687function ma(a,b){function c(){}c.prototype=b.prototype;a.bh=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.Yg=function(a,c,f){for(var h=Array(arguments.length-2),k=2;k<arguments.length;k++)h[k-2]=arguments[k];return b.prototype[c].apply(a,h)}};function r(a,b){for(var c in a)b.call(void 0,a[c],c,a)}function na(a,b){var c={},d;for(d in a)c[d]=b.call(void 0,a[d],d,a);return c}function oa(a,b){for(var c in a)if(!b.call(void 0,a[c],c,a))return!1;return!0}function pa(a){var b=0,c;for(c in a)b++;return b}function qa(a){for(var b in a)return b}function ra(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b}function sa(a){var b=[],c=0,d;for(d in a)b[c++]=d;return b}function ta(a,b){for(var c in a)if(a[c]==b)return!0;return!1}
5688function ua(a,b,c){for(var d in a)if(b.call(c,a[d],d,a))return d}function va(a,b){var c=ua(a,b,void 0);return c&&a[c]}function wa(a){for(var b in a)return!1;return!0}function xa(a){var b={},c;for(c in a)b[c]=a[c];return b}var ya="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");
5689function za(a,b){for(var c,d,e=1;e<arguments.length;e++){d=arguments[e];for(c in d)a[c]=d[c];for(var f=0;f<ya.length;f++)c=ya[f],Object.prototype.hasOwnProperty.call(d,c)&&(a[c]=d[c])}};function Aa(a){a=String(a);if(/^\s*$/.test(a)?0:/^[\],:{}\s\u2028\u2029]*$/.test(a.replace(/\\["\\\/bfnrtu]/g,"@").replace(/"[^"\\\n\r\u2028\u2029\x00-\x08\x0a-\x1f]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g,"")))try{return eval("("+a+")")}catch(b){}throw Error("Invalid JSON string: "+a);}function Ba(){this.Sd=void 0}
5690function Ca(a,b,c){switch(typeof b){case "string":Da(b,c);break;case "number":c.push(isFinite(b)&&!isNaN(b)?b:"null");break;case "boolean":c.push(b);break;case "undefined":c.push("null");break;case "object":if(null==b){c.push("null");break}if(ea(b)){var d=b.length;c.push("[");for(var e="",f=0;f<d;f++)c.push(e),e=b[f],Ca(a,a.Sd?a.Sd.call(b,String(f),e):e,c),e=",";c.push("]");break}c.push("{");d="";for(f in b)Object.prototype.hasOwnProperty.call(b,f)&&(e=b[f],"function"!=typeof e&&(c.push(d),Da(f,c),
5691c.push(":"),Ca(a,a.Sd?a.Sd.call(b,f,e):e,c),d=","));c.push("}");break;case "function":break;default:throw Error("Unknown type: "+typeof b);}}var Ea={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\u000b"},Fa=/\uffff/.test("\uffff")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g;
5692function Da(a,b){b.push('"',a.replace(Fa,function(a){if(a in Ea)return Ea[a];var b=a.charCodeAt(0),e="\\u";16>b?e+="000":256>b?e+="00":4096>b&&(e+="0");return Ea[a]=e+b.toString(16)}),'"')};function Ga(){return Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^la()).toString(36)};var Ha;a:{var Ia=aa.navigator;if(Ia){var Ja=Ia.userAgent;if(Ja){Ha=Ja;break a}}Ha=""};function Ka(){this.Va=-1};function La(){this.Va=-1;this.Va=64;this.N=[];this.me=[];this.Wf=[];this.Ld=[];this.Ld[0]=128;for(var a=1;a<this.Va;++a)this.Ld[a]=0;this.de=this.ac=0;this.reset()}ma(La,Ka);La.prototype.reset=function(){this.N[0]=1732584193;this.N[1]=4023233417;this.N[2]=2562383102;this.N[3]=271733878;this.N[4]=3285377520;this.de=this.ac=0};
5693function Ma(a,b,c){c||(c=0);var d=a.Wf;if(p(b))for(var e=0;16>e;e++)d[e]=b.charCodeAt(c)<<24|b.charCodeAt(c+1)<<16|b.charCodeAt(c+2)<<8|b.charCodeAt(c+3),c+=4;else for(e=0;16>e;e++)d[e]=b[c]<<24|b[c+1]<<16|b[c+2]<<8|b[c+3],c+=4;for(e=16;80>e;e++){var f=d[e-3]^d[e-8]^d[e-14]^d[e-16];d[e]=(f<<1|f>>>31)&4294967295}b=a.N[0];c=a.N[1];for(var h=a.N[2],k=a.N[3],l=a.N[4],m,e=0;80>e;e++)40>e?20>e?(f=k^c&(h^k),m=1518500249):(f=c^h^k,m=1859775393):60>e?(f=c&h|k&(c|h),m=2400959708):(f=c^h^k,m=3395469782),f=(b<<
56945|b>>>27)+f+l+m+d[e]&4294967295,l=k,k=h,h=(c<<30|c>>>2)&4294967295,c=b,b=f;a.N[0]=a.N[0]+b&4294967295;a.N[1]=a.N[1]+c&4294967295;a.N[2]=a.N[2]+h&4294967295;a.N[3]=a.N[3]+k&4294967295;a.N[4]=a.N[4]+l&4294967295}
5695La.prototype.update=function(a,b){if(null!=a){n(b)||(b=a.length);for(var c=b-this.Va,d=0,e=this.me,f=this.ac;d<b;){if(0==f)for(;d<=c;)Ma(this,a,d),d+=this.Va;if(p(a))for(;d<b;){if(e[f]=a.charCodeAt(d),++f,++d,f==this.Va){Ma(this,e);f=0;break}}else for(;d<b;)if(e[f]=a[d],++f,++d,f==this.Va){Ma(this,e);f=0;break}}this.ac=f;this.de+=b}};var u=Array.prototype,Na=u.indexOf?function(a,b,c){return u.indexOf.call(a,b,c)}:function(a,b,c){c=null==c?0:0>c?Math.max(0,a.length+c):c;if(p(a))return p(b)&&1==b.length?a.indexOf(b,c):-1;for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1},Oa=u.forEach?function(a,b,c){u.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=p(a)?a.split(""):a,f=0;f<d;f++)f in e&&b.call(c,e[f],f,a)},Pa=u.filter?function(a,b,c){return u.filter.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=[],f=0,h=p(a)?
5696a.split(""):a,k=0;k<d;k++)if(k in h){var l=h[k];b.call(c,l,k,a)&&(e[f++]=l)}return e},Qa=u.map?function(a,b,c){return u.map.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=Array(d),f=p(a)?a.split(""):a,h=0;h<d;h++)h in f&&(e[h]=b.call(c,f[h],h,a));return e},Ra=u.reduce?function(a,b,c,d){for(var e=[],f=1,h=arguments.length;f<h;f++)e.push(arguments[f]);d&&(e[0]=q(b,d));return u.reduce.apply(a,e)}:function(a,b,c,d){var e=c;Oa(a,function(c,h){e=b.call(d,e,c,h,a)});return e},Sa=u.every?function(a,b,
5697c){return u.every.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=p(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&!b.call(c,e[f],f,a))return!1;return!0};function Ta(a,b){var c=Ua(a,b,void 0);return 0>c?null:p(a)?a.charAt(c):a[c]}function Ua(a,b,c){for(var d=a.length,e=p(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&b.call(c,e[f],f,a))return f;return-1}function Va(a,b){var c=Na(a,b);0<=c&&u.splice.call(a,c,1)}function Wa(a,b,c){return 2>=arguments.length?u.slice.call(a,b):u.slice.call(a,b,c)}
5698function Xa(a,b){a.sort(b||Ya)}function Ya(a,b){return a>b?1:a<b?-1:0};var Za=-1!=Ha.indexOf("Opera")||-1!=Ha.indexOf("OPR"),$a=-1!=Ha.indexOf("Trident")||-1!=Ha.indexOf("MSIE"),ab=-1!=Ha.indexOf("Gecko")&&-1==Ha.toLowerCase().indexOf("webkit")&&!(-1!=Ha.indexOf("Trident")||-1!=Ha.indexOf("MSIE")),bb=-1!=Ha.toLowerCase().indexOf("webkit");
5699(function(){var a="",b;if(Za&&aa.opera)return a=aa.opera.version,ha(a)?a():a;ab?b=/rv\:([^\);]+)(\)|;)/:$a?b=/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/:bb&&(b=/WebKit\/(\S+)/);b&&(a=(a=b.exec(Ha))?a[1]:"");return $a&&(b=(b=aa.document)?b.documentMode:void 0,b>parseFloat(a))?String(b):a})();var cb=null,db=null,eb=null;function fb(a,b){if(!fa(a))throw Error("encodeByteArray takes an array as a parameter");gb();for(var c=b?db:cb,d=[],e=0;e<a.length;e+=3){var f=a[e],h=e+1<a.length,k=h?a[e+1]:0,l=e+2<a.length,m=l?a[e+2]:0,t=f>>2,f=(f&3)<<4|k>>4,k=(k&15)<<2|m>>6,m=m&63;l||(m=64,h||(k=64));d.push(c[t],c[f],c[k],c[m])}return d.join("")}
5700function gb(){if(!cb){cb={};db={};eb={};for(var a=0;65>a;a++)cb[a]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(a),db[a]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(a),eb[db[a]]=a,62<=a&&(eb["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(a)]=a)}};var hb=hb||"2.3.1";function v(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function w(a,b){if(Object.prototype.hasOwnProperty.call(a,b))return a[b]}function ib(a,b){for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&b(c,a[c])}function jb(a){var b={};ib(a,function(a,d){b[a]=d});return b};function kb(a){var b=[];ib(a,function(a,d){ea(d)?Oa(d,function(d){b.push(encodeURIComponent(a)+"="+encodeURIComponent(d))}):b.push(encodeURIComponent(a)+"="+encodeURIComponent(d))});return b.length?"&"+b.join("&"):""}function lb(a){var b={};a=a.replace(/^\?/,"").split("&");Oa(a,function(a){a&&(a=a.split("="),b[a[0]]=a[1])});return b};function x(a,b,c,d){var e;d<b?e="at least "+b:d>c&&(e=0===c?"none":"no more than "+c);if(e)throw Error(a+" failed: Was called with "+d+(1===d?" argument.":" arguments.")+" Expects "+e+".");}function y(a,b,c){var d="";switch(b){case 1:d=c?"first":"First";break;case 2:d=c?"second":"Second";break;case 3:d=c?"third":"Third";break;case 4:d=c?"fourth":"Fourth";break;default:throw Error("errorPrefix called with argumentNumber > 4. Need to update it?");}return a=a+" failed: "+(d+" argument ")}
5701function A(a,b,c,d){if((!d||n(c))&&!ha(c))throw Error(y(a,b,d)+"must be a valid function.");}function mb(a,b,c){if(n(c)&&(!ia(c)||null===c))throw Error(y(a,b,!0)+"must be a valid context object.");};function nb(a){return"undefined"!==typeof JSON&&n(JSON.parse)?JSON.parse(a):Aa(a)}function B(a){if("undefined"!==typeof JSON&&n(JSON.stringify))a=JSON.stringify(a);else{var b=[];Ca(new Ba,a,b);a=b.join("")}return a};function ob(){this.Wd=C}ob.prototype.j=function(a){return this.Wd.Q(a)};ob.prototype.toString=function(){return this.Wd.toString()};function pb(){}pb.prototype.qf=function(){return null};pb.prototype.ye=function(){return null};var qb=new pb;function rb(a,b,c){this.Tf=a;this.Ka=b;this.Kd=c}rb.prototype.qf=function(a){var b=this.Ka.O;if(sb(b,a))return b.j().R(a);b=null!=this.Kd?new tb(this.Kd,!0,!1):this.Ka.w();return this.Tf.xc(a,b)};rb.prototype.ye=function(a,b,c){var d=null!=this.Kd?this.Kd:ub(this.Ka);a=this.Tf.ne(d,b,1,c,a);return 0===a.length?null:a[0]};function vb(){this.tb=[]}function wb(a,b){for(var c=null,d=0;d<b.length;d++){var e=b[d],f=e.Zb();null===c||f.ca(c.Zb())||(a.tb.push(c),c=null);null===c&&(c=new xb(f));c.add(e)}c&&a.tb.push(c)}function yb(a,b,c){wb(a,c);zb(a,function(a){return a.ca(b)})}function Ab(a,b,c){wb(a,c);zb(a,function(a){return a.contains(b)||b.contains(a)})}
5702function zb(a,b){for(var c=!0,d=0;d<a.tb.length;d++){var e=a.tb[d];if(e)if(e=e.Zb(),b(e)){for(var e=a.tb[d],f=0;f<e.vd.length;f++){var h=e.vd[f];if(null!==h){e.vd[f]=null;var k=h.Vb();Bb&&Cb("event: "+h.toString());Db(k)}}a.tb[d]=null}else c=!1}c&&(a.tb=[])}function xb(a){this.ra=a;this.vd=[]}xb.prototype.add=function(a){this.vd.push(a)};xb.prototype.Zb=function(){return this.ra};function D(a,b,c,d){this.type=a;this.Ja=b;this.Wa=c;this.Ke=d;this.Qd=void 0}function Eb(a){return new D(Fb,a)}var Fb="value";function Gb(a,b,c,d){this.ue=b;this.Zd=c;this.Qd=d;this.ud=a}Gb.prototype.Zb=function(){var a=this.Zd.Ib();return"value"===this.ud?a.path:a.parent().path};Gb.prototype.ze=function(){return this.ud};Gb.prototype.Vb=function(){return this.ue.Vb(this)};Gb.prototype.toString=function(){return this.Zb().toString()+":"+this.ud+":"+B(this.Zd.mf())};function Hb(a,b,c){this.ue=a;this.error=b;this.path=c}Hb.prototype.Zb=function(){return this.path};Hb.prototype.ze=function(){return"cancel"};
5703Hb.prototype.Vb=function(){return this.ue.Vb(this)};Hb.prototype.toString=function(){return this.path.toString()+":cancel"};function tb(a,b,c){this.A=a;this.ea=b;this.Ub=c}function Ib(a){return a.ea}function Jb(a){return a.Ub}function Kb(a,b){return b.e()?a.ea&&!a.Ub:sb(a,E(b))}function sb(a,b){return a.ea&&!a.Ub||a.A.Da(b)}tb.prototype.j=function(){return this.A};function Lb(a){this.gg=a;this.Dd=null}Lb.prototype.get=function(){var a=this.gg.get(),b=xa(a);if(this.Dd)for(var c in this.Dd)b[c]-=this.Dd[c];this.Dd=a;return b};function Mb(a,b){this.Of={};this.fd=new Lb(a);this.ba=b;var c=1E4+2E4*Math.random();setTimeout(q(this.If,this),Math.floor(c))}Mb.prototype.If=function(){var a=this.fd.get(),b={},c=!1,d;for(d in a)0<a[d]&&v(this.Of,d)&&(b[d]=a[d],c=!0);c&&this.ba.Ue(b);setTimeout(q(this.If,this),Math.floor(6E5*Math.random()))};function Nb(){this.Ec={}}function Ob(a,b,c){n(c)||(c=1);v(a.Ec,b)||(a.Ec[b]=0);a.Ec[b]+=c}Nb.prototype.get=function(){return xa(this.Ec)};var Pb={},Qb={};function Rb(a){a=a.toString();Pb[a]||(Pb[a]=new Nb);return Pb[a]}function Sb(a,b){var c=a.toString();Qb[c]||(Qb[c]=b());return Qb[c]};function F(a,b){this.name=a;this.S=b}function Tb(a,b){return new F(a,b)};function Ub(a,b){return Vb(a.name,b.name)}function Wb(a,b){return Vb(a,b)};function Xb(a,b,c){this.type=Yb;this.source=a;this.path=b;this.Ga=c}Xb.prototype.Xc=function(a){return this.path.e()?new Xb(this.source,G,this.Ga.R(a)):new Xb(this.source,H(this.path),this.Ga)};Xb.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" overwrite: "+this.Ga.toString()+")"};function Zb(a,b){this.type=$b;this.source=a;this.path=b}Zb.prototype.Xc=function(){return this.path.e()?new Zb(this.source,G):new Zb(this.source,H(this.path))};Zb.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" listen_complete)"};function ac(a,b){this.La=a;this.wa=b?b:bc}g=ac.prototype;g.Oa=function(a,b){return new ac(this.La,this.wa.Oa(a,b,this.La).Y(null,null,!1,null,null))};g.remove=function(a){return new ac(this.La,this.wa.remove(a,this.La).Y(null,null,!1,null,null))};g.get=function(a){for(var b,c=this.wa;!c.e();){b=this.La(a,c.key);if(0===b)return c.value;0>b?c=c.left:0<b&&(c=c.right)}return null};
5704function cc(a,b){for(var c,d=a.wa,e=null;!d.e();){c=a.La(b,d.key);if(0===c){if(d.left.e())return e?e.key:null;for(d=d.left;!d.right.e();)d=d.right;return d.key}0>c?d=d.left:0<c&&(e=d,d=d.right)}throw Error("Attempted to find predecessor key for a nonexistent key. What gives?");}g.e=function(){return this.wa.e()};g.count=function(){return this.wa.count()};g.Sc=function(){return this.wa.Sc()};g.fc=function(){return this.wa.fc()};g.ia=function(a){return this.wa.ia(a)};
5705g.Xb=function(a){return new dc(this.wa,null,this.La,!1,a)};g.Yb=function(a,b){return new dc(this.wa,a,this.La,!1,b)};g.$b=function(a,b){return new dc(this.wa,a,this.La,!0,b)};g.sf=function(a){return new dc(this.wa,null,this.La,!0,a)};function dc(a,b,c,d,e){this.Ud=e||null;this.Fe=d;this.Pa=[];for(e=1;!a.e();)if(e=b?c(a.key,b):1,d&&(e*=-1),0>e)a=this.Fe?a.left:a.right;else if(0===e){this.Pa.push(a);break}else this.Pa.push(a),a=this.Fe?a.right:a.left}
5706function J(a){if(0===a.Pa.length)return null;var b=a.Pa.pop(),c;c=a.Ud?a.Ud(b.key,b.value):{key:b.key,value:b.value};if(a.Fe)for(b=b.left;!b.e();)a.Pa.push(b),b=b.right;else for(b=b.right;!b.e();)a.Pa.push(b),b=b.left;return c}function ec(a){if(0===a.Pa.length)return null;var b;b=a.Pa;b=b[b.length-1];return a.Ud?a.Ud(b.key,b.value):{key:b.key,value:b.value}}function fc(a,b,c,d,e){this.key=a;this.value=b;this.color=null!=c?c:!0;this.left=null!=d?d:bc;this.right=null!=e?e:bc}g=fc.prototype;
5707g.Y=function(a,b,c,d,e){return new fc(null!=a?a:this.key,null!=b?b:this.value,null!=c?c:this.color,null!=d?d:this.left,null!=e?e:this.right)};g.count=function(){return this.left.count()+1+this.right.count()};g.e=function(){return!1};g.ia=function(a){return this.left.ia(a)||a(this.key,this.value)||this.right.ia(a)};function gc(a){return a.left.e()?a:gc(a.left)}g.Sc=function(){return gc(this).key};g.fc=function(){return this.right.e()?this.key:this.right.fc()};
5708g.Oa=function(a,b,c){var d,e;e=this;d=c(a,e.key);e=0>d?e.Y(null,null,null,e.left.Oa(a,b,c),null):0===d?e.Y(null,b,null,null,null):e.Y(null,null,null,null,e.right.Oa(a,b,c));return hc(e)};function ic(a){if(a.left.e())return bc;a.left.fa()||a.left.left.fa()||(a=jc(a));a=a.Y(null,null,null,ic(a.left),null);return hc(a)}
5709g.remove=function(a,b){var c,d;c=this;if(0>b(a,c.key))c.left.e()||c.left.fa()||c.left.left.fa()||(c=jc(c)),c=c.Y(null,null,null,c.left.remove(a,b),null);else{c.left.fa()&&(c=kc(c));c.right.e()||c.right.fa()||c.right.left.fa()||(c=lc(c),c.left.left.fa()&&(c=kc(c),c=lc(c)));if(0===b(a,c.key)){if(c.right.e())return bc;d=gc(c.right);c=c.Y(d.key,d.value,null,null,ic(c.right))}c=c.Y(null,null,null,null,c.right.remove(a,b))}return hc(c)};g.fa=function(){return this.color};
5710function hc(a){a.right.fa()&&!a.left.fa()&&(a=mc(a));a.left.fa()&&a.left.left.fa()&&(a=kc(a));a.left.fa()&&a.right.fa()&&(a=lc(a));return a}function jc(a){a=lc(a);a.right.left.fa()&&(a=a.Y(null,null,null,null,kc(a.right)),a=mc(a),a=lc(a));return a}function mc(a){return a.right.Y(null,null,a.color,a.Y(null,null,!0,null,a.right.left),null)}function kc(a){return a.left.Y(null,null,a.color,null,a.Y(null,null,!0,a.left.right,null))}
5711function lc(a){return a.Y(null,null,!a.color,a.left.Y(null,null,!a.left.color,null,null),a.right.Y(null,null,!a.right.color,null,null))}function nc(){}g=nc.prototype;g.Y=function(){return this};g.Oa=function(a,b){return new fc(a,b,null)};g.remove=function(){return this};g.count=function(){return 0};g.e=function(){return!0};g.ia=function(){return!1};g.Sc=function(){return null};g.fc=function(){return null};g.fa=function(){return!1};var bc=new nc;function oc(a,b){return a&&"object"===typeof a?(K(".sv"in a,"Unexpected leaf node or priority contents"),b[a[".sv"]]):a}function pc(a,b){var c=new qc;rc(a,new L(""),function(a,e){c.nc(a,sc(e,b))});return c}function sc(a,b){var c=a.C().I(),c=oc(c,b),d;if(a.K()){var e=oc(a.Ca(),b);return e!==a.Ca()||c!==a.C().I()?new tc(e,M(c)):a}d=a;c!==a.C().I()&&(d=d.ga(new tc(c)));a.P(N,function(a,c){var e=sc(c,b);e!==c&&(d=d.U(a,e))});return d};function uc(){this.wc={}}uc.prototype.set=function(a,b){null==b?delete this.wc[a]:this.wc[a]=b};uc.prototype.get=function(a){return v(this.wc,a)?this.wc[a]:null};uc.prototype.remove=function(a){delete this.wc[a]};uc.prototype.wf=!0;function vc(a){this.Fc=a;this.Pd="firebase:"}g=vc.prototype;g.set=function(a,b){null==b?this.Fc.removeItem(this.Pd+a):this.Fc.setItem(this.Pd+a,B(b))};g.get=function(a){a=this.Fc.getItem(this.Pd+a);return null==a?null:nb(a)};g.remove=function(a){this.Fc.removeItem(this.Pd+a)};g.wf=!1;g.toString=function(){return this.Fc.toString()};function wc(a){try{if("undefined"!==typeof window&&"undefined"!==typeof window[a]){var b=window[a];b.setItem("firebase:sentinel","cache");b.removeItem("firebase:sentinel");return new vc(b)}}catch(c){}return new uc}var xc=wc("localStorage"),yc=wc("sessionStorage");function zc(a,b,c,d,e){this.host=a.toLowerCase();this.domain=this.host.substr(this.host.indexOf(".")+1);this.kb=b;this.hc=c;this.Wg=d;this.Od=e||"";this.Ya=xc.get("host:"+a)||this.host}function Ac(a,b){b!==a.Ya&&(a.Ya=b,"s-"===a.Ya.substr(0,2)&&xc.set("host:"+a.host,a.Ya))}
5712function Bc(a,b,c){K("string"===typeof b,"typeof type must == string");K("object"===typeof c,"typeof params must == object");if(b===Cc)b=(a.kb?"wss://":"ws://")+a.Ya+"/.ws?";else if(b===Dc)b=(a.kb?"https://":"http://")+a.Ya+"/.lp?";else throw Error("Unknown connection type: "+b);a.host!==a.Ya&&(c.ns=a.hc);var d=[];r(c,function(a,b){d.push(b+"="+a)});return b+d.join("&")}zc.prototype.toString=function(){var a=(this.kb?"https://":"http://")+this.host;this.Od&&(a+="<"+this.Od+">");return a};var Ec=function(){var a=1;return function(){return a++}}();function K(a,b){if(!a)throw Fc(b);}function Fc(a){return Error("Firebase ("+hb+") INTERNAL ASSERT FAILED: "+a)}
5713function Gc(a){try{var b;if("undefined"!==typeof atob)b=atob(a);else{gb();for(var c=eb,d=[],e=0;e<a.length;){var f=c[a.charAt(e++)],h=e<a.length?c[a.charAt(e)]:0;++e;var k=e<a.length?c[a.charAt(e)]:64;++e;var l=e<a.length?c[a.charAt(e)]:64;++e;if(null==f||null==h||null==k||null==l)throw Error();d.push(f<<2|h>>4);64!=k&&(d.push(h<<4&240|k>>2),64!=l&&d.push(k<<6&192|l))}if(8192>d.length)b=String.fromCharCode.apply(null,d);else{a="";for(c=0;c<d.length;c+=8192)a+=String.fromCharCode.apply(null,Wa(d,c,
5714c+8192));b=a}}return b}catch(m){Cb("base64Decode failed: ",m)}return null}function Hc(a){var b=Ic(a);a=new La;a.update(b);var b=[],c=8*a.de;56>a.ac?a.update(a.Ld,56-a.ac):a.update(a.Ld,a.Va-(a.ac-56));for(var d=a.Va-1;56<=d;d--)a.me[d]=c&255,c/=256;Ma(a,a.me);for(d=c=0;5>d;d++)for(var e=24;0<=e;e-=8)b[c]=a.N[d]>>e&255,++c;return fb(b)}
5715function Jc(a){for(var b="",c=0;c<arguments.length;c++)b=fa(arguments[c])?b+Jc.apply(null,arguments[c]):"object"===typeof arguments[c]?b+B(arguments[c]):b+arguments[c],b+=" ";return b}var Bb=null,Kc=!0;function Cb(a){!0===Kc&&(Kc=!1,null===Bb&&!0===yc.get("logging_enabled")&&Lc(!0));if(Bb){var b=Jc.apply(null,arguments);Bb(b)}}function Mc(a){return function(){Cb(a,arguments)}}
5716function Nc(a){if("undefined"!==typeof console){var b="FIREBASE INTERNAL ERROR: "+Jc.apply(null,arguments);"undefined"!==typeof console.error?console.error(b):console.log(b)}}function Oc(a){var b=Jc.apply(null,arguments);throw Error("FIREBASE FATAL ERROR: "+b);}function O(a){if("undefined"!==typeof console){var b="FIREBASE WARNING: "+Jc.apply(null,arguments);"undefined"!==typeof console.warn?console.warn(b):console.log(b)}}
5717function Pc(a){var b="",c="",d="",e="",f=!0,h="https",k=443;if(p(a)){var l=a.indexOf("//");0<=l&&(h=a.substring(0,l-1),a=a.substring(l+2));l=a.indexOf("/");-1===l&&(l=a.length);b=a.substring(0,l);e="";a=a.substring(l).split("/");for(l=0;l<a.length;l++)if(0<a[l].length){var m=a[l];try{m=decodeURIComponent(m.replace(/\+/g," "))}catch(t){}e+="/"+m}a=b.split(".");3===a.length?(c=a[1],d=a[0].toLowerCase()):2===a.length&&(c=a[0]);l=b.indexOf(":");0<=l&&(f="https"===h||"wss"===h,k=b.substring(l+1),isFinite(k)&&
5718(k=String(k)),k=p(k)?/^\s*-?0x/i.test(k)?parseInt(k,16):parseInt(k,10):NaN)}return{host:b,port:k,domain:c,Tg:d,kb:f,scheme:h,$c:e}}function Qc(a){return ga(a)&&(a!=a||a==Number.POSITIVE_INFINITY||a==Number.NEGATIVE_INFINITY)}
5719function Rc(a){if("complete"===document.readyState)a();else{var b=!1,c=function(){document.body?b||(b=!0,a()):setTimeout(c,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",c,!1),window.addEventListener("load",c,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&c()}),window.attachEvent("onload",c))}}
5720function Vb(a,b){if(a===b)return 0;if("[MIN_NAME]"===a||"[MAX_NAME]"===b)return-1;if("[MIN_NAME]"===b||"[MAX_NAME]"===a)return 1;var c=Sc(a),d=Sc(b);return null!==c?null!==d?0==c-d?a.length-b.length:c-d:-1:null!==d?1:a<b?-1:1}function Tc(a,b){if(b&&a in b)return b[a];throw Error("Missing required key ("+a+") in object: "+B(b));}
5721function Uc(a){if("object"!==typeof a||null===a)return B(a);var b=[],c;for(c in a)b.push(c);b.sort();c="{";for(var d=0;d<b.length;d++)0!==d&&(c+=","),c+=B(b[d]),c+=":",c+=Uc(a[b[d]]);return c+"}"}function Vc(a,b){if(a.length<=b)return[a];for(var c=[],d=0;d<a.length;d+=b)d+b>a?c.push(a.substring(d,a.length)):c.push(a.substring(d,d+b));return c}function Wc(a,b){if(ea(a))for(var c=0;c<a.length;++c)b(c,a[c]);else r(a,b)}
5722function Xc(a){K(!Qc(a),"Invalid JSON number");var b,c,d,e;0===a?(d=c=0,b=-Infinity===1/a?1:0):(b=0>a,a=Math.abs(a),a>=Math.pow(2,-1022)?(d=Math.min(Math.floor(Math.log(a)/Math.LN2),1023),c=d+1023,d=Math.round(a*Math.pow(2,52-d)-Math.pow(2,52))):(c=0,d=Math.round(a/Math.pow(2,-1074))));e=[];for(a=52;a;--a)e.push(d%2?1:0),d=Math.floor(d/2);for(a=11;a;--a)e.push(c%2?1:0),c=Math.floor(c/2);e.push(b?1:0);e.reverse();b=e.join("");c="";for(a=0;64>a;a+=8)d=parseInt(b.substr(a,8),2).toString(16),1===d.length&&
5723(d="0"+d),c+=d;return c.toLowerCase()}var Yc=/^-?\d{1,10}$/;function Sc(a){return Yc.test(a)&&(a=Number(a),-2147483648<=a&&2147483647>=a)?a:null}function Db(a){try{a()}catch(b){setTimeout(function(){O("Exception was thrown by user callback.",b.stack||"");throw b;},Math.floor(0))}}function P(a,b){if(ha(a)){var c=Array.prototype.slice.call(arguments,1).slice();Db(function(){a.apply(null,c)})}};function Ic(a){for(var b=[],c=0,d=0;d<a.length;d++){var e=a.charCodeAt(d);55296<=e&&56319>=e&&(e-=55296,d++,K(d<a.length,"Surrogate pair missing trail surrogate."),e=65536+(e<<10)+(a.charCodeAt(d)-56320));128>e?b[c++]=e:(2048>e?b[c++]=e>>6|192:(65536>e?b[c++]=e>>12|224:(b[c++]=e>>18|240,b[c++]=e>>12&63|128),b[c++]=e>>6&63|128),b[c++]=e&63|128)}return b}function Zc(a){for(var b=0,c=0;c<a.length;c++){var d=a.charCodeAt(c);128>d?b++:2048>d?b+=2:55296<=d&&56319>=d?(b+=4,c++):b+=3}return b};function $c(a){var b={},c={},d={},e="";try{var f=a.split("."),b=nb(Gc(f[0])||""),c=nb(Gc(f[1])||""),e=f[2],d=c.d||{};delete c.d}catch(h){}return{Zg:b,Bc:c,data:d,Qg:e}}function ad(a){a=$c(a).Bc;return"object"===typeof a&&a.hasOwnProperty("iat")?w(a,"iat"):null}function bd(a){a=$c(a);var b=a.Bc;return!!a.Qg&&!!b&&"object"===typeof b&&b.hasOwnProperty("iat")};function cd(a){this.W=a;this.g=a.n.g}function dd(a,b,c,d){var e=[],f=[];Oa(b,function(b){"child_changed"===b.type&&a.g.Ad(b.Ke,b.Ja)&&f.push(new D("child_moved",b.Ja,b.Wa))});ed(a,e,"child_removed",b,d,c);ed(a,e,"child_added",b,d,c);ed(a,e,"child_moved",f,d,c);ed(a,e,"child_changed",b,d,c);ed(a,e,Fb,b,d,c);return e}function ed(a,b,c,d,e,f){d=Pa(d,function(a){return a.type===c});Xa(d,q(a.hg,a));Oa(d,function(c){var d=fd(a,c,f);Oa(e,function(e){e.Kf(c.type)&&b.push(e.createEvent(d,a.W))})})}
5724function fd(a,b,c){"value"!==b.type&&"child_removed"!==b.type&&(b.Qd=c.rf(b.Wa,b.Ja,a.g));return b}cd.prototype.hg=function(a,b){if(null==a.Wa||null==b.Wa)throw Fc("Should only compare child_ events.");return this.g.compare(new F(a.Wa,a.Ja),new F(b.Wa,b.Ja))};function gd(){this.bb={}}
5725function hd(a,b){var c=b.type,d=b.Wa;K("child_added"==c||"child_changed"==c||"child_removed"==c,"Only child changes supported for tracking");K(".priority"!==d,"Only non-priority child changes can be tracked.");var e=w(a.bb,d);if(e){var f=e.type;if("child_added"==c&&"child_removed"==f)a.bb[d]=new D("child_changed",b.Ja,d,e.Ja);else if("child_removed"==c&&"child_added"==f)delete a.bb[d];else if("child_removed"==c&&"child_changed"==f)a.bb[d]=new D("child_removed",e.Ke,d);else if("child_changed"==c&&
5726"child_added"==f)a.bb[d]=new D("child_added",b.Ja,d);else if("child_changed"==c&&"child_changed"==f)a.bb[d]=new D("child_changed",b.Ja,d,e.Ke);else throw Fc("Illegal combination of changes: "+b+" occurred after "+e);}else a.bb[d]=b};function id(a,b,c){this.Rb=a;this.pb=b;this.rb=c||null}g=id.prototype;g.Kf=function(a){return"value"===a};g.createEvent=function(a,b){var c=b.n.g;return new Gb("value",this,new Q(a.Ja,b.Ib(),c))};g.Vb=function(a){var b=this.rb;if("cancel"===a.ze()){K(this.pb,"Raising a cancel event on a listener with no cancel callback");var c=this.pb;return function(){c.call(b,a.error)}}var d=this.Rb;return function(){d.call(b,a.Zd)}};g.gf=function(a,b){return this.pb?new Hb(this,a,b):null};
5727g.matches=function(a){return a instanceof id?a.Rb&&this.Rb?a.Rb===this.Rb&&a.rb===this.rb:!0:!1};g.tf=function(){return null!==this.Rb};function jd(a,b,c){this.ha=a;this.pb=b;this.rb=c}g=jd.prototype;g.Kf=function(a){a="children_added"===a?"child_added":a;return("children_removed"===a?"child_removed":a)in this.ha};g.gf=function(a,b){return this.pb?new Hb(this,a,b):null};
5728g.createEvent=function(a,b){K(null!=a.Wa,"Child events should have a childName.");var c=b.Ib().u(a.Wa);return new Gb(a.type,this,new Q(a.Ja,c,b.n.g),a.Qd)};g.Vb=function(a){var b=this.rb;if("cancel"===a.ze()){K(this.pb,"Raising a cancel event on a listener with no cancel callback");var c=this.pb;return function(){c.call(b,a.error)}}var d=this.ha[a.ud];return function(){d.call(b,a.Zd,a.Qd)}};
5729g.matches=function(a){if(a instanceof jd){if(!this.ha||!a.ha)return!0;if(this.rb===a.rb){var b=pa(a.ha);if(b===pa(this.ha)){if(1===b){var b=qa(a.ha),c=qa(this.ha);return c===b&&(!a.ha[b]||!this.ha[c]||a.ha[b]===this.ha[c])}return oa(this.ha,function(b,c){return a.ha[c]===b})}}}return!1};g.tf=function(){return null!==this.ha};function kd(a){this.g=a}g=kd.prototype;g.G=function(a,b,c,d,e,f){K(a.Jc(this.g),"A node must be indexed if only a child is updated");e=a.R(b);if(e.Q(d).ca(c.Q(d))&&e.e()==c.e())return a;null!=f&&(c.e()?a.Da(b)?hd(f,new D("child_removed",e,b)):K(a.K(),"A child remove without an old child only makes sense on a leaf node"):e.e()?hd(f,new D("child_added",c,b)):hd(f,new D("child_changed",c,b,e)));return a.K()&&c.e()?a:a.U(b,c).lb(this.g)};
5730g.xa=function(a,b,c){null!=c&&(a.K()||a.P(N,function(a,e){b.Da(a)||hd(c,new D("child_removed",e,a))}),b.K()||b.P(N,function(b,e){if(a.Da(b)){var f=a.R(b);f.ca(e)||hd(c,new D("child_changed",e,b,f))}else hd(c,new D("child_added",e,b))}));return b.lb(this.g)};g.ga=function(a,b){return a.e()?C:a.ga(b)};g.Na=function(){return!1};g.Wb=function(){return this};function ld(a){this.Be=new kd(a.g);this.g=a.g;var b;a.ma?(b=md(a),b=a.g.Pc(nd(a),b)):b=a.g.Tc();this.ed=b;a.pa?(b=od(a),a=a.g.Pc(pd(a),b)):a=a.g.Qc();this.Gc=a}g=ld.prototype;g.matches=function(a){return 0>=this.g.compare(this.ed,a)&&0>=this.g.compare(a,this.Gc)};g.G=function(a,b,c,d,e,f){this.matches(new F(b,c))||(c=C);return this.Be.G(a,b,c,d,e,f)};
5731g.xa=function(a,b,c){b.K()&&(b=C);var d=b.lb(this.g),d=d.ga(C),e=this;b.P(N,function(a,b){e.matches(new F(a,b))||(d=d.U(a,C))});return this.Be.xa(a,d,c)};g.ga=function(a){return a};g.Na=function(){return!0};g.Wb=function(){return this.Be};function qd(a){this.sa=new ld(a);this.g=a.g;K(a.ja,"Only valid if limit has been set");this.ka=a.ka;this.Jb=!rd(a)}g=qd.prototype;g.G=function(a,b,c,d,e,f){this.sa.matches(new F(b,c))||(c=C);return a.R(b).ca(c)?a:a.Db()<this.ka?this.sa.Wb().G(a,b,c,d,e,f):sd(this,a,b,c,e,f)};
5732g.xa=function(a,b,c){var d;if(b.K()||b.e())d=C.lb(this.g);else if(2*this.ka<b.Db()&&b.Jc(this.g)){d=C.lb(this.g);b=this.Jb?b.$b(this.sa.Gc,this.g):b.Yb(this.sa.ed,this.g);for(var e=0;0<b.Pa.length&&e<this.ka;){var f=J(b),h;if(h=this.Jb?0>=this.g.compare(this.sa.ed,f):0>=this.g.compare(f,this.sa.Gc))d=d.U(f.name,f.S),e++;else break}}else{d=b.lb(this.g);d=d.ga(C);var k,l,m;if(this.Jb){b=d.sf(this.g);k=this.sa.Gc;l=this.sa.ed;var t=td(this.g);m=function(a,b){return t(b,a)}}else b=d.Xb(this.g),k=this.sa.ed,
5733l=this.sa.Gc,m=td(this.g);for(var e=0,z=!1;0<b.Pa.length;)f=J(b),!z&&0>=m(k,f)&&(z=!0),(h=z&&e<this.ka&&0>=m(f,l))?e++:d=d.U(f.name,C)}return this.sa.Wb().xa(a,d,c)};g.ga=function(a){return a};g.Na=function(){return!0};g.Wb=function(){return this.sa.Wb()};
5734function sd(a,b,c,d,e,f){var h;if(a.Jb){var k=td(a.g);h=function(a,b){return k(b,a)}}else h=td(a.g);K(b.Db()==a.ka,"");var l=new F(c,d),m=a.Jb?ud(b,a.g):vd(b,a.g),t=a.sa.matches(l);if(b.Da(c)){for(var z=b.R(c),m=e.ye(a.g,m,a.Jb);null!=m&&(m.name==c||b.Da(m.name));)m=e.ye(a.g,m,a.Jb);e=null==m?1:h(m,l);if(t&&!d.e()&&0<=e)return null!=f&&hd(f,new D("child_changed",d,c,z)),b.U(c,d);null!=f&&hd(f,new D("child_removed",z,c));b=b.U(c,C);return null!=m&&a.sa.matches(m)?(null!=f&&hd(f,new D("child_added",
5735m.S,m.name)),b.U(m.name,m.S)):b}return d.e()?b:t&&0<=h(m,l)?(null!=f&&(hd(f,new D("child_removed",m.S,m.name)),hd(f,new D("child_added",d,c))),b.U(c,d).U(m.name,C)):b};function wd(a,b){this.je=a;this.fg=b}function xd(a){this.V=a}
5736xd.prototype.ab=function(a,b,c,d){var e=new gd,f;if(b.type===Yb)b.source.we?c=yd(this,a,b.path,b.Ga,c,d,e):(K(b.source.pf,"Unknown source."),f=b.source.af||Jb(a.w())&&!b.path.e(),c=Ad(this,a,b.path,b.Ga,c,d,f,e));else if(b.type===Bd)b.source.we?c=Cd(this,a,b.path,b.children,c,d,e):(K(b.source.pf,"Unknown source."),f=b.source.af||Jb(a.w()),c=Dd(this,a,b.path,b.children,c,d,f,e));else if(b.type===Ed)if(b.Vd)if(b=b.path,null!=c.tc(b))c=a;else{f=new rb(c,a,d);d=a.O.j();if(b.e()||".priority"===E(b))Ib(a.w())?
5737b=c.za(ub(a)):(b=a.w().j(),K(b instanceof R,"serverChildren would be complete if leaf node"),b=c.yc(b)),b=this.V.xa(d,b,e);else{var h=E(b),k=c.xc(h,a.w());null==k&&sb(a.w(),h)&&(k=d.R(h));b=null!=k?this.V.G(d,h,k,H(b),f,e):a.O.j().Da(h)?this.V.G(d,h,C,H(b),f,e):d;b.e()&&Ib(a.w())&&(d=c.za(ub(a)),d.K()&&(b=this.V.xa(b,d,e)))}d=Ib(a.w())||null!=c.tc(G);c=Fd(a,b,d,this.V.Na())}else c=Gd(this,a,b.path,b.Qb,c,d,e);else if(b.type===$b)d=b.path,b=a.w(),f=b.j(),h=b.ea||d.e(),c=Hd(this,new Id(a.O,new tb(f,
5738h,b.Ub)),d,c,qb,e);else throw Fc("Unknown operation type: "+b.type);e=ra(e.bb);d=c;b=d.O;b.ea&&(f=b.j().K()||b.j().e(),h=Jd(a),(0<e.length||!a.O.ea||f&&!b.j().ca(h)||!b.j().C().ca(h.C()))&&e.push(Eb(Jd(d))));return new wd(c,e)};
5739function Hd(a,b,c,d,e,f){var h=b.O;if(null!=d.tc(c))return b;var k;if(c.e())K(Ib(b.w()),"If change path is empty, we must have complete server data"),Jb(b.w())?(e=ub(b),d=d.yc(e instanceof R?e:C)):d=d.za(ub(b)),f=a.V.xa(b.O.j(),d,f);else{var l=E(c);if(".priority"==l)K(1==Kd(c),"Can't have a priority with additional path components"),f=h.j(),k=b.w().j(),d=d.ld(c,f,k),f=null!=d?a.V.ga(f,d):h.j();else{var m=H(c);sb(h,l)?(k=b.w().j(),d=d.ld(c,h.j(),k),d=null!=d?h.j().R(l).G(m,d):h.j().R(l)):d=d.xc(l,
5740b.w());f=null!=d?a.V.G(h.j(),l,d,m,e,f):h.j()}}return Fd(b,f,h.ea||c.e(),a.V.Na())}function Ad(a,b,c,d,e,f,h,k){var l=b.w();h=h?a.V:a.V.Wb();if(c.e())d=h.xa(l.j(),d,null);else if(h.Na()&&!l.Ub)d=l.j().G(c,d),d=h.xa(l.j(),d,null);else{var m=E(c);if(!Kb(l,c)&&1<Kd(c))return b;var t=H(c);d=l.j().R(m).G(t,d);d=".priority"==m?h.ga(l.j(),d):h.G(l.j(),m,d,t,qb,null)}l=l.ea||c.e();b=new Id(b.O,new tb(d,l,h.Na()));return Hd(a,b,c,e,new rb(e,b,f),k)}
5741function yd(a,b,c,d,e,f,h){var k=b.O;e=new rb(e,b,f);if(c.e())h=a.V.xa(b.O.j(),d,h),a=Fd(b,h,!0,a.V.Na());else if(f=E(c),".priority"===f)h=a.V.ga(b.O.j(),d),a=Fd(b,h,k.ea,k.Ub);else{c=H(c);var l=k.j().R(f);if(!c.e()){var m=e.qf(f);d=null!=m?".priority"===Ld(c)&&m.Q(c.parent()).e()?m:m.G(c,d):C}l.ca(d)?a=b:(h=a.V.G(k.j(),f,d,c,e,h),a=Fd(b,h,k.ea,a.V.Na()))}return a}
5742function Cd(a,b,c,d,e,f,h){var k=b;Md(d,function(d,m){var t=c.u(d);sb(b.O,E(t))&&(k=yd(a,k,t,m,e,f,h))});Md(d,function(d,m){var t=c.u(d);sb(b.O,E(t))||(k=yd(a,k,t,m,e,f,h))});return k}function Nd(a,b){Md(b,function(b,d){a=a.G(b,d)});return a}
5743function Dd(a,b,c,d,e,f,h,k){if(b.w().j().e()&&!Ib(b.w()))return b;var l=b;c=c.e()?d:Od(Pd,c,d);var m=b.w().j();c.children.ia(function(c,d){if(m.Da(c)){var I=b.w().j().R(c),I=Nd(I,d);l=Ad(a,l,new L(c),I,e,f,h,k)}});c.children.ia(function(c,d){var I=!sb(b.w(),c)&&null==d.value;m.Da(c)||I||(I=b.w().j().R(c),I=Nd(I,d),l=Ad(a,l,new L(c),I,e,f,h,k))});return l}
5744function Gd(a,b,c,d,e,f,h){if(null!=e.tc(c))return b;var k=Jb(b.w()),l=b.w();if(null!=d.value){if(c.e()&&l.ea||Kb(l,c))return Ad(a,b,c,l.j().Q(c),e,f,k,h);if(c.e()){var m=Pd;l.j().P(Qd,function(a,b){m=m.set(new L(a),b)});return Dd(a,b,c,m,e,f,k,h)}return b}m=Pd;Md(d,function(a){var b=c.u(a);Kb(l,b)&&(m=m.set(a,l.j().Q(b)))});return Dd(a,b,c,m,e,f,k,h)};function Rd(){}var Sd={};function td(a){return q(a.compare,a)}Rd.prototype.Ad=function(a,b){return 0!==this.compare(new F("[MIN_NAME]",a),new F("[MIN_NAME]",b))};Rd.prototype.Tc=function(){return Td};function Ud(a){K(!a.e()&&".priority"!==E(a),"Can't create PathIndex with empty path or .priority key");this.cc=a}ma(Ud,Rd);g=Ud.prototype;g.Ic=function(a){return!a.Q(this.cc).e()};g.compare=function(a,b){var c=a.S.Q(this.cc),d=b.S.Q(this.cc),c=c.Dc(d);return 0===c?Vb(a.name,b.name):c};
5745g.Pc=function(a,b){var c=M(a),c=C.G(this.cc,c);return new F(b,c)};g.Qc=function(){var a=C.G(this.cc,Vd);return new F("[MAX_NAME]",a)};g.toString=function(){return this.cc.slice().join("/")};function Wd(){}ma(Wd,Rd);g=Wd.prototype;g.compare=function(a,b){var c=a.S.C(),d=b.S.C(),c=c.Dc(d);return 0===c?Vb(a.name,b.name):c};g.Ic=function(a){return!a.C().e()};g.Ad=function(a,b){return!a.C().ca(b.C())};g.Tc=function(){return Td};g.Qc=function(){return new F("[MAX_NAME]",new tc("[PRIORITY-POST]",Vd))};
5746g.Pc=function(a,b){var c=M(a);return new F(b,new tc("[PRIORITY-POST]",c))};g.toString=function(){return".priority"};var N=new Wd;function Xd(){}ma(Xd,Rd);g=Xd.prototype;g.compare=function(a,b){return Vb(a.name,b.name)};g.Ic=function(){throw Fc("KeyIndex.isDefinedOn not expected to be called.");};g.Ad=function(){return!1};g.Tc=function(){return Td};g.Qc=function(){return new F("[MAX_NAME]",C)};g.Pc=function(a){K(p(a),"KeyIndex indexValue must always be a string.");return new F(a,C)};g.toString=function(){return".key"};
5747var Qd=new Xd;function Yd(){}ma(Yd,Rd);g=Yd.prototype;g.compare=function(a,b){var c=a.S.Dc(b.S);return 0===c?Vb(a.name,b.name):c};g.Ic=function(){return!0};g.Ad=function(a,b){return!a.ca(b)};g.Tc=function(){return Td};g.Qc=function(){return Zd};g.Pc=function(a,b){var c=M(a);return new F(b,c)};g.toString=function(){return".value"};var $d=new Yd;function ae(){this.Tb=this.pa=this.Lb=this.ma=this.ja=!1;this.ka=0;this.Nb="";this.ec=null;this.xb="";this.bc=null;this.vb="";this.g=N}var be=new ae;function rd(a){return""===a.Nb?a.ma:"l"===a.Nb}function nd(a){K(a.ma,"Only valid if start has been set");return a.ec}function md(a){K(a.ma,"Only valid if start has been set");return a.Lb?a.xb:"[MIN_NAME]"}function pd(a){K(a.pa,"Only valid if end has been set");return a.bc}
5748function od(a){K(a.pa,"Only valid if end has been set");return a.Tb?a.vb:"[MAX_NAME]"}function ce(a){var b=new ae;b.ja=a.ja;b.ka=a.ka;b.ma=a.ma;b.ec=a.ec;b.Lb=a.Lb;b.xb=a.xb;b.pa=a.pa;b.bc=a.bc;b.Tb=a.Tb;b.vb=a.vb;b.g=a.g;return b}g=ae.prototype;g.He=function(a){var b=ce(this);b.ja=!0;b.ka=a;b.Nb="";return b};g.Ie=function(a){var b=ce(this);b.ja=!0;b.ka=a;b.Nb="l";return b};g.Je=function(a){var b=ce(this);b.ja=!0;b.ka=a;b.Nb="r";return b};
5749g.$d=function(a,b){var c=ce(this);c.ma=!0;n(a)||(a=null);c.ec=a;null!=b?(c.Lb=!0,c.xb=b):(c.Lb=!1,c.xb="");return c};g.td=function(a,b){var c=ce(this);c.pa=!0;n(a)||(a=null);c.bc=a;n(b)?(c.Tb=!0,c.vb=b):(c.ah=!1,c.vb="");return c};function de(a,b){var c=ce(a);c.g=b;return c}function ee(a){var b={};a.ma&&(b.sp=a.ec,a.Lb&&(b.sn=a.xb));a.pa&&(b.ep=a.bc,a.Tb&&(b.en=a.vb));if(a.ja){b.l=a.ka;var c=a.Nb;""===c&&(c=rd(a)?"l":"r");b.vf=c}a.g!==N&&(b.i=a.g.toString());return b}
5750function S(a){return!(a.ma||a.pa||a.ja)}function fe(a){return S(a)&&a.g==N}function ge(a){var b={};if(fe(a))return b;var c;a.g===N?c="$priority":a.g===$d?c="$value":a.g===Qd?c="$key":(K(a.g instanceof Ud,"Unrecognized index type!"),c=a.g.toString());b.orderBy=B(c);a.ma&&(b.startAt=B(a.ec),a.Lb&&(b.startAt+=","+B(a.xb)));a.pa&&(b.endAt=B(a.bc),a.Tb&&(b.endAt+=","+B(a.vb)));a.ja&&(rd(a)?b.limitToFirst=a.ka:b.limitToLast=a.ka);return b}g.toString=function(){return B(ee(this))};function he(a,b){this.Bd=a;this.dc=b}he.prototype.get=function(a){var b=w(this.Bd,a);if(!b)throw Error("No index defined for "+a);return b===Sd?null:b};function ie(a,b,c){var d=na(a.Bd,function(d,f){var h=w(a.dc,f);K(h,"Missing index implementation for "+f);if(d===Sd){if(h.Ic(b.S)){for(var k=[],l=c.Xb(Tb),m=J(l);m;)m.name!=b.name&&k.push(m),m=J(l);k.push(b);return je(k,td(h))}return Sd}h=c.get(b.name);k=d;h&&(k=k.remove(new F(b.name,h)));return k.Oa(b,b.S)});return new he(d,a.dc)}
5751function ke(a,b,c){var d=na(a.Bd,function(a){if(a===Sd)return a;var d=c.get(b.name);return d?a.remove(new F(b.name,d)):a});return new he(d,a.dc)}var le=new he({".priority":Sd},{".priority":N});function tc(a,b){this.B=a;K(n(this.B)&&null!==this.B,"LeafNode shouldn't be created with null/undefined value.");this.aa=b||C;me(this.aa);this.Cb=null}var ne=["object","boolean","number","string"];g=tc.prototype;g.K=function(){return!0};g.C=function(){return this.aa};g.ga=function(a){return new tc(this.B,a)};g.R=function(a){return".priority"===a?this.aa:C};g.Q=function(a){return a.e()?this:".priority"===E(a)?this.aa:C};g.Da=function(){return!1};g.rf=function(){return null};
5752g.U=function(a,b){return".priority"===a?this.ga(b):b.e()&&".priority"!==a?this:C.U(a,b).ga(this.aa)};g.G=function(a,b){var c=E(a);if(null===c)return b;if(b.e()&&".priority"!==c)return this;K(".priority"!==c||1===Kd(a),".priority must be the last token in a path");return this.U(c,C.G(H(a),b))};g.e=function(){return!1};g.Db=function(){return 0};g.P=function(){return!1};g.I=function(a){return a&&!this.C().e()?{".value":this.Ca(),".priority":this.C().I()}:this.Ca()};
5753g.hash=function(){if(null===this.Cb){var a="";this.aa.e()||(a+="priority:"+oe(this.aa.I())+":");var b=typeof this.B,a=a+(b+":"),a="number"===b?a+Xc(this.B):a+this.B;this.Cb=Hc(a)}return this.Cb};g.Ca=function(){return this.B};g.Dc=function(a){if(a===C)return 1;if(a instanceof R)return-1;K(a.K(),"Unknown node type");var b=typeof a.B,c=typeof this.B,d=Na(ne,b),e=Na(ne,c);K(0<=d,"Unknown leaf type: "+b);K(0<=e,"Unknown leaf type: "+c);return d===e?"object"===c?0:this.B<a.B?-1:this.B===a.B?0:1:e-d};
5754g.lb=function(){return this};g.Jc=function(){return!0};g.ca=function(a){return a===this?!0:a.K()?this.B===a.B&&this.aa.ca(a.aa):!1};g.toString=function(){return B(this.I(!0))};function R(a,b,c){this.m=a;(this.aa=b)&&me(this.aa);a.e()&&K(!this.aa||this.aa.e(),"An empty node cannot have a priority");this.wb=c;this.Cb=null}g=R.prototype;g.K=function(){return!1};g.C=function(){return this.aa||C};g.ga=function(a){return this.m.e()?this:new R(this.m,a,this.wb)};g.R=function(a){if(".priority"===a)return this.C();a=this.m.get(a);return null===a?C:a};g.Q=function(a){var b=E(a);return null===b?this:this.R(b).Q(H(a))};g.Da=function(a){return null!==this.m.get(a)};
5755g.U=function(a,b){K(b,"We should always be passing snapshot nodes");if(".priority"===a)return this.ga(b);var c=new F(a,b),d,e;b.e()?(d=this.m.remove(a),c=ke(this.wb,c,this.m)):(d=this.m.Oa(a,b),c=ie(this.wb,c,this.m));e=d.e()?C:this.aa;return new R(d,e,c)};g.G=function(a,b){var c=E(a);if(null===c)return b;K(".priority"!==E(a)||1===Kd(a),".priority must be the last token in a path");var d=this.R(c).G(H(a),b);return this.U(c,d)};g.e=function(){return this.m.e()};g.Db=function(){return this.m.count()};
5756var pe=/^(0|[1-9]\d*)$/;g=R.prototype;g.I=function(a){if(this.e())return null;var b={},c=0,d=0,e=!0;this.P(N,function(f,h){b[f]=h.I(a);c++;e&&pe.test(f)?d=Math.max(d,Number(f)):e=!1});if(!a&&e&&d<2*c){var f=[],h;for(h in b)f[h]=b[h];return f}a&&!this.C().e()&&(b[".priority"]=this.C().I());return b};g.hash=function(){if(null===this.Cb){var a="";this.C().e()||(a+="priority:"+oe(this.C().I())+":");this.P(N,function(b,c){var d=c.hash();""!==d&&(a+=":"+b+":"+d)});this.Cb=""===a?"":Hc(a)}return this.Cb};
5757g.rf=function(a,b,c){return(c=qe(this,c))?(a=cc(c,new F(a,b)))?a.name:null:cc(this.m,a)};function ud(a,b){var c;c=(c=qe(a,b))?(c=c.Sc())&&c.name:a.m.Sc();return c?new F(c,a.m.get(c)):null}function vd(a,b){var c;c=(c=qe(a,b))?(c=c.fc())&&c.name:a.m.fc();return c?new F(c,a.m.get(c)):null}g.P=function(a,b){var c=qe(this,a);return c?c.ia(function(a){return b(a.name,a.S)}):this.m.ia(b)};g.Xb=function(a){return this.Yb(a.Tc(),a)};
5758g.Yb=function(a,b){var c=qe(this,b);if(c)return c.Yb(a,function(a){return a});for(var c=this.m.Yb(a.name,Tb),d=ec(c);null!=d&&0>b.compare(d,a);)J(c),d=ec(c);return c};g.sf=function(a){return this.$b(a.Qc(),a)};g.$b=function(a,b){var c=qe(this,b);if(c)return c.$b(a,function(a){return a});for(var c=this.m.$b(a.name,Tb),d=ec(c);null!=d&&0<b.compare(d,a);)J(c),d=ec(c);return c};g.Dc=function(a){return this.e()?a.e()?0:-1:a.K()||a.e()?1:a===Vd?-1:0};
5759g.lb=function(a){if(a===Qd||ta(this.wb.dc,a.toString()))return this;var b=this.wb,c=this.m;K(a!==Qd,"KeyIndex always exists and isn't meant to be added to the IndexMap.");for(var d=[],e=!1,c=c.Xb(Tb),f=J(c);f;)e=e||a.Ic(f.S),d.push(f),f=J(c);d=e?je(d,td(a)):Sd;e=a.toString();c=xa(b.dc);c[e]=a;a=xa(b.Bd);a[e]=d;return new R(this.m,this.aa,new he(a,c))};g.Jc=function(a){return a===Qd||ta(this.wb.dc,a.toString())};
5760g.ca=function(a){if(a===this)return!0;if(a.K())return!1;if(this.C().ca(a.C())&&this.m.count()===a.m.count()){var b=this.Xb(N);a=a.Xb(N);for(var c=J(b),d=J(a);c&&d;){if(c.name!==d.name||!c.S.ca(d.S))return!1;c=J(b);d=J(a)}return null===c&&null===d}return!1};function qe(a,b){return b===Qd?null:a.wb.get(b.toString())}g.toString=function(){return B(this.I(!0))};function M(a,b){if(null===a)return C;var c=null;"object"===typeof a&&".priority"in a?c=a[".priority"]:"undefined"!==typeof b&&(c=b);K(null===c||"string"===typeof c||"number"===typeof c||"object"===typeof c&&".sv"in c,"Invalid priority type found: "+typeof c);"object"===typeof a&&".value"in a&&null!==a[".value"]&&(a=a[".value"]);if("object"!==typeof a||".sv"in a)return new tc(a,M(c));if(a instanceof Array){var d=C,e=a;r(e,function(a,b){if(v(e,b)&&"."!==b.substring(0,1)){var c=M(a);if(c.K()||!c.e())d=
5761d.U(b,c)}});return d.ga(M(c))}var f=[],h=!1,k=a;ib(k,function(a){if("string"!==typeof a||"."!==a.substring(0,1)){var b=M(k[a]);b.e()||(h=h||!b.C().e(),f.push(new F(a,b)))}});if(0==f.length)return C;var l=je(f,Ub,function(a){return a.name},Wb);if(h){var m=je(f,td(N));return new R(l,M(c),new he({".priority":m},{".priority":N}))}return new R(l,M(c),le)}var re=Math.log(2);
5762function se(a){this.count=parseInt(Math.log(a+1)/re,10);this.jf=this.count-1;this.eg=a+1&parseInt(Array(this.count+1).join("1"),2)}function te(a){var b=!(a.eg&1<<a.jf);a.jf--;return b}
5763function je(a,b,c,d){function e(b,d){var f=d-b;if(0==f)return null;if(1==f){var m=a[b],t=c?c(m):m;return new fc(t,m.S,!1,null,null)}var m=parseInt(f/2,10)+b,f=e(b,m),z=e(m+1,d),m=a[m],t=c?c(m):m;return new fc(t,m.S,!1,f,z)}a.sort(b);var f=function(b){function d(b,h){var k=t-b,z=t;t-=b;var z=e(k+1,z),k=a[k],I=c?c(k):k,z=new fc(I,k.S,h,null,z);f?f.left=z:m=z;f=z}for(var f=null,m=null,t=a.length,z=0;z<b.count;++z){var I=te(b),zd=Math.pow(2,b.count-(z+1));I?d(zd,!1):(d(zd,!1),d(zd,!0))}return m}(new se(a.length));
5764return null!==f?new ac(d||b,f):new ac(d||b)}function oe(a){return"number"===typeof a?"number:"+Xc(a):"string:"+a}function me(a){if(a.K()){var b=a.I();K("string"===typeof b||"number"===typeof b||"object"===typeof b&&v(b,".sv"),"Priority must be a string or number.")}else K(a===Vd||a.e(),"priority of unexpected type.");K(a===Vd||a.C().e(),"Priority nodes can't have a priority of their own.")}var C=new R(new ac(Wb),null,le);function ue(){R.call(this,new ac(Wb),C,le)}ma(ue,R);g=ue.prototype;
5765g.Dc=function(a){return a===this?0:1};g.ca=function(a){return a===this};g.C=function(){return this};g.R=function(){return C};g.e=function(){return!1};var Vd=new ue,Td=new F("[MIN_NAME]",C),Zd=new F("[MAX_NAME]",Vd);function Id(a,b){this.O=a;this.Yd=b}function Fd(a,b,c,d){return new Id(new tb(b,c,d),a.Yd)}function Jd(a){return a.O.ea?a.O.j():null}Id.prototype.w=function(){return this.Yd};function ub(a){return a.Yd.ea?a.Yd.j():null};function ve(a,b){this.W=a;var c=a.n,d=new kd(c.g),c=S(c)?new kd(c.g):c.ja?new qd(c):new ld(c);this.Hf=new xd(c);var e=b.w(),f=b.O,h=d.xa(C,e.j(),null),k=c.xa(C,f.j(),null);this.Ka=new Id(new tb(k,f.ea,c.Na()),new tb(h,e.ea,d.Na()));this.Xa=[];this.lg=new cd(a)}function we(a){return a.W}g=ve.prototype;g.w=function(){return this.Ka.w().j()};g.fb=function(a){var b=ub(this.Ka);return b&&(S(this.W.n)||!a.e()&&!b.R(E(a)).e())?b.Q(a):null};g.e=function(){return 0===this.Xa.length};g.Pb=function(a){this.Xa.push(a)};
5766g.jb=function(a,b){var c=[];if(b){K(null==a,"A cancel should cancel all event registrations.");var d=this.W.path;Oa(this.Xa,function(a){(a=a.gf(b,d))&&c.push(a)})}if(a){for(var e=[],f=0;f<this.Xa.length;++f){var h=this.Xa[f];if(!h.matches(a))e.push(h);else if(a.tf()){e=e.concat(this.Xa.slice(f+1));break}}this.Xa=e}else this.Xa=[];return c};
5767g.ab=function(a,b,c){a.type===Bd&&null!==a.source.Hb&&(K(ub(this.Ka),"We should always have a full cache before handling merges"),K(Jd(this.Ka),"Missing event cache, even though we have a server cache"));var d=this.Ka;a=this.Hf.ab(d,a,b,c);b=this.Hf;c=a.je;K(c.O.j().Jc(b.V.g),"Event snap not indexed");K(c.w().j().Jc(b.V.g),"Server snap not indexed");K(Ib(a.je.w())||!Ib(d.w()),"Once a server snap is complete, it should never go back");this.Ka=a.je;return xe(this,a.fg,a.je.O.j(),null)};
5768function ye(a,b){var c=a.Ka.O,d=[];c.j().K()||c.j().P(N,function(a,b){d.push(new D("child_added",b,a))});c.ea&&d.push(Eb(c.j()));return xe(a,d,c.j(),b)}function xe(a,b,c,d){return dd(a.lg,b,c,d?[d]:a.Xa)};function ze(a,b,c){this.type=Bd;this.source=a;this.path=b;this.children=c}ze.prototype.Xc=function(a){if(this.path.e())return a=this.children.subtree(new L(a)),a.e()?null:a.value?new Xb(this.source,G,a.value):new ze(this.source,G,a);K(E(this.path)===a,"Can't get a merge for a child not on the path of the operation");return new ze(this.source,H(this.path),this.children)};ze.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"};function Ae(a,b){this.f=Mc("p:rest:");this.F=a;this.Gb=b;this.Aa=null;this.$={}}function Be(a,b){if(n(b))return"tag$"+b;K(fe(a.n),"should have a tag if it's not a default query.");return a.path.toString()}g=Ae.prototype;
5769g.yf=function(a,b,c,d){var e=a.path.toString();this.f("Listen called for "+e+" "+a.va());var f=Be(a,c),h={};this.$[f]=h;a=ge(a.n);var k=this;Ce(this,e+".json",a,function(a,b){var t=b;404===a&&(a=t=null);null===a&&k.Gb(e,t,!1,c);w(k.$,f)===h&&d(a?401==a?"permission_denied":"rest_error:"+a:"ok",null)})};g.Rf=function(a,b){var c=Be(a,b);delete this.$[c]};g.M=function(a,b){this.Aa=a;var c=$c(a),d=c.data,c=c.Bc&&c.Bc.exp;b&&b("ok",{auth:d,expires:c})};g.ge=function(a){this.Aa=null;a("ok",null)};g.Me=function(){};
5770g.Cf=function(){};g.Jd=function(){};g.put=function(){};g.zf=function(){};g.Ue=function(){};
5771function Ce(a,b,c,d){c=c||{};c.format="export";a.Aa&&(c.auth=a.Aa);var e=(a.F.kb?"https://":"http://")+a.F.host+b+"?"+kb(c);a.f("Sending REST request for "+e);var f=new XMLHttpRequest;f.onreadystatechange=function(){if(d&&4===f.readyState){a.f("REST Response for "+e+" received. status:",f.status,"response:",f.responseText);var b=null;if(200<=f.status&&300>f.status){try{b=nb(f.responseText)}catch(c){O("Failed to parse JSON response for "+e+": "+f.responseText)}d(null,b)}else 401!==f.status&&404!==
5772f.status&&O("Got unsuccessful REST response for "+e+" Status: "+f.status),d(f.status);d=null}};f.open("GET",e,!0);f.send()};function De(a){K(ea(a)&&0<a.length,"Requires a non-empty array");this.Xf=a;this.Oc={}}De.prototype.fe=function(a,b){var c;c=this.Oc[a]||[];var d=c.length;if(0<d){for(var e=Array(d),f=0;f<d;f++)e[f]=c[f];c=e}else c=[];for(d=0;d<c.length;d++)c[d].zc.apply(c[d].Ma,Array.prototype.slice.call(arguments,1))};De.prototype.Eb=function(a,b,c){Ee(this,a);this.Oc[a]=this.Oc[a]||[];this.Oc[a].push({zc:b,Ma:c});(a=this.Ae(a))&&b.apply(c,a)};
5773De.prototype.ic=function(a,b,c){Ee(this,a);a=this.Oc[a]||[];for(var d=0;d<a.length;d++)if(a[d].zc===b&&(!c||c===a[d].Ma)){a.splice(d,1);break}};function Ee(a,b){K(Ta(a.Xf,function(a){return a===b}),"Unknown event: "+b)};var Fe=function(){var a=0,b=[];return function(c){var d=c===a;a=c;for(var e=Array(8),f=7;0<=f;f--)e[f]="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(c%64),c=Math.floor(c/64);K(0===c,"Cannot push at time == 0");c=e.join("");if(d){for(f=11;0<=f&&63===b[f];f--)b[f]=0;b[f]++}else for(f=0;12>f;f++)b[f]=Math.floor(64*Math.random());for(f=0;12>f;f++)c+="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(b[f]);K(20===c.length,"nextPushId: Length should be 20.");
5774return c}}();function Ge(){De.call(this,["online"]);this.kc=!0;if("undefined"!==typeof window&&"undefined"!==typeof window.addEventListener){var a=this;window.addEventListener("online",function(){a.kc||(a.kc=!0,a.fe("online",!0))},!1);window.addEventListener("offline",function(){a.kc&&(a.kc=!1,a.fe("online",!1))},!1)}}ma(Ge,De);Ge.prototype.Ae=function(a){K("online"===a,"Unknown event type: "+a);return[this.kc]};ca(Ge);function He(){De.call(this,["visible"]);var a,b;"undefined"!==typeof document&&"undefined"!==typeof document.addEventListener&&("undefined"!==typeof document.hidden?(b="visibilitychange",a="hidden"):"undefined"!==typeof document.mozHidden?(b="mozvisibilitychange",a="mozHidden"):"undefined"!==typeof document.msHidden?(b="msvisibilitychange",a="msHidden"):"undefined"!==typeof document.webkitHidden&&(b="webkitvisibilitychange",a="webkitHidden"));this.Ob=!0;if(b){var c=this;document.addEventListener(b,
5775function(){var b=!document[a];b!==c.Ob&&(c.Ob=b,c.fe("visible",b))},!1)}}ma(He,De);He.prototype.Ae=function(a){K("visible"===a,"Unknown event type: "+a);return[this.Ob]};ca(He);function L(a,b){if(1==arguments.length){this.o=a.split("/");for(var c=0,d=0;d<this.o.length;d++)0<this.o[d].length&&(this.o[c]=this.o[d],c++);this.o.length=c;this.Z=0}else this.o=a,this.Z=b}function T(a,b){var c=E(a);if(null===c)return b;if(c===E(b))return T(H(a),H(b));throw Error("INTERNAL ERROR: innerPath ("+b+") is not within outerPath ("+a+")");}
5776function Ie(a,b){for(var c=a.slice(),d=b.slice(),e=0;e<c.length&&e<d.length;e++){var f=Vb(c[e],d[e]);if(0!==f)return f}return c.length===d.length?0:c.length<d.length?-1:1}function E(a){return a.Z>=a.o.length?null:a.o[a.Z]}function Kd(a){return a.o.length-a.Z}function H(a){var b=a.Z;b<a.o.length&&b++;return new L(a.o,b)}function Ld(a){return a.Z<a.o.length?a.o[a.o.length-1]:null}g=L.prototype;
5777g.toString=function(){for(var a="",b=this.Z;b<this.o.length;b++)""!==this.o[b]&&(a+="/"+this.o[b]);return a||"/"};g.slice=function(a){return this.o.slice(this.Z+(a||0))};g.parent=function(){if(this.Z>=this.o.length)return null;for(var a=[],b=this.Z;b<this.o.length-1;b++)a.push(this.o[b]);return new L(a,0)};
5778g.u=function(a){for(var b=[],c=this.Z;c<this.o.length;c++)b.push(this.o[c]);if(a instanceof L)for(c=a.Z;c<a.o.length;c++)b.push(a.o[c]);else for(a=a.split("/"),c=0;c<a.length;c++)0<a[c].length&&b.push(a[c]);return new L(b,0)};g.e=function(){return this.Z>=this.o.length};g.ca=function(a){if(Kd(this)!==Kd(a))return!1;for(var b=this.Z,c=a.Z;b<=this.o.length;b++,c++)if(this.o[b]!==a.o[c])return!1;return!0};
5779g.contains=function(a){var b=this.Z,c=a.Z;if(Kd(this)>Kd(a))return!1;for(;b<this.o.length;){if(this.o[b]!==a.o[c])return!1;++b;++c}return!0};var G=new L("");function Je(a,b){this.Qa=a.slice();this.Ha=Math.max(1,this.Qa.length);this.lf=b;for(var c=0;c<this.Qa.length;c++)this.Ha+=Zc(this.Qa[c]);Ke(this)}Je.prototype.push=function(a){0<this.Qa.length&&(this.Ha+=1);this.Qa.push(a);this.Ha+=Zc(a);Ke(this)};Je.prototype.pop=function(){var a=this.Qa.pop();this.Ha-=Zc(a);0<this.Qa.length&&--this.Ha};
5780function Ke(a){if(768<a.Ha)throw Error(a.lf+"has a key path longer than 768 bytes ("+a.Ha+").");if(32<a.Qa.length)throw Error(a.lf+"path specified exceeds the maximum depth that can be written (32) or object contains a cycle "+Le(a));}function Le(a){return 0==a.Qa.length?"":"in property '"+a.Qa.join(".")+"'"};function Me(a,b){this.value=a;this.children=b||Ne}var Ne=new ac(function(a,b){return a===b?0:a<b?-1:1});function Oe(a){var b=Pd;r(a,function(a,d){b=b.set(new L(d),a)});return b}g=Me.prototype;g.e=function(){return null===this.value&&this.children.e()};function Pe(a,b,c){if(null!=a.value&&c(a.value))return{path:G,value:a.value};if(b.e())return null;var d=E(b);a=a.children.get(d);return null!==a?(b=Pe(a,H(b),c),null!=b?{path:(new L(d)).u(b.path),value:b.value}:null):null}
5781function Qe(a,b){return Pe(a,b,function(){return!0})}g.subtree=function(a){if(a.e())return this;var b=this.children.get(E(a));return null!==b?b.subtree(H(a)):Pd};g.set=function(a,b){if(a.e())return new Me(b,this.children);var c=E(a),d=(this.children.get(c)||Pd).set(H(a),b),c=this.children.Oa(c,d);return new Me(this.value,c)};
5782g.remove=function(a){if(a.e())return this.children.e()?Pd:new Me(null,this.children);var b=E(a),c=this.children.get(b);return c?(a=c.remove(H(a)),b=a.e()?this.children.remove(b):this.children.Oa(b,a),null===this.value&&b.e()?Pd:new Me(this.value,b)):this};g.get=function(a){if(a.e())return this.value;var b=this.children.get(E(a));return b?b.get(H(a)):null};
5783function Od(a,b,c){if(b.e())return c;var d=E(b);b=Od(a.children.get(d)||Pd,H(b),c);d=b.e()?a.children.remove(d):a.children.Oa(d,b);return new Me(a.value,d)}function Re(a,b){return Se(a,G,b)}function Se(a,b,c){var d={};a.children.ia(function(a,f){d[a]=Se(f,b.u(a),c)});return c(b,a.value,d)}function Te(a,b,c){return Ue(a,b,G,c)}function Ue(a,b,c,d){var e=a.value?d(c,a.value):!1;if(e)return e;if(b.e())return null;e=E(b);return(a=a.children.get(e))?Ue(a,H(b),c.u(e),d):null}
5784function Ve(a,b,c){var d=G;if(!b.e()){var e=!0;a.value&&(e=c(d,a.value));!0===e&&(e=E(b),(a=a.children.get(e))&&We(a,H(b),d.u(e),c))}}function We(a,b,c,d){if(b.e())return a;a.value&&d(c,a.value);var e=E(b);return(a=a.children.get(e))?We(a,H(b),c.u(e),d):Pd}function Md(a,b){Xe(a,G,b)}function Xe(a,b,c){a.children.ia(function(a,e){Xe(e,b.u(a),c)});a.value&&c(b,a.value)}function Ye(a,b){a.children.ia(function(a,d){d.value&&b(a,d.value)})}var Pd=new Me(null);
5785Me.prototype.toString=function(){var a={};Md(this,function(b,c){a[b.toString()]=c.toString()});return B(a)};function Ze(a,b,c){this.type=Ed;this.source=$e;this.path=a;this.Qb=b;this.Vd=c}Ze.prototype.Xc=function(a){if(this.path.e()){if(null!=this.Qb.value)return K(this.Qb.children.e(),"affectedTree should not have overlapping affected paths."),this;a=this.Qb.subtree(new L(a));return new Ze(G,a,this.Vd)}K(E(this.path)===a,"operationForChild called for unrelated child.");return new Ze(H(this.path),this.Qb,this.Vd)};
5786Ze.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" ack write revert="+this.Vd+" affectedTree="+this.Qb+")"};var Yb=0,Bd=1,Ed=2,$b=3;function af(a,b,c,d){this.we=a;this.pf=b;this.Hb=c;this.af=d;K(!d||b,"Tagged queries must be from server.")}var $e=new af(!0,!1,null,!1),bf=new af(!1,!0,null,!1);af.prototype.toString=function(){return this.we?"user":this.af?"server(queryID="+this.Hb+")":"server"};function cf(a){this.X=a}var df=new cf(new Me(null));function ef(a,b,c){if(b.e())return new cf(new Me(c));var d=Qe(a.X,b);if(null!=d){var e=d.path,d=d.value;b=T(e,b);d=d.G(b,c);return new cf(a.X.set(e,d))}a=Od(a.X,b,new Me(c));return new cf(a)}function ff(a,b,c){var d=a;ib(c,function(a,c){d=ef(d,b.u(a),c)});return d}cf.prototype.Rd=function(a){if(a.e())return df;a=Od(this.X,a,Pd);return new cf(a)};function gf(a,b){var c=Qe(a.X,b);return null!=c?a.X.get(c.path).Q(T(c.path,b)):null}
5787function hf(a){var b=[],c=a.X.value;null!=c?c.K()||c.P(N,function(a,c){b.push(new F(a,c))}):a.X.children.ia(function(a,c){null!=c.value&&b.push(new F(a,c.value))});return b}function jf(a,b){if(b.e())return a;var c=gf(a,b);return null!=c?new cf(new Me(c)):new cf(a.X.subtree(b))}cf.prototype.e=function(){return this.X.e()};cf.prototype.apply=function(a){return kf(G,this.X,a)};
5788function kf(a,b,c){if(null!=b.value)return c.G(a,b.value);var d=null;b.children.ia(function(b,f){".priority"===b?(K(null!==f.value,"Priority writes must always be leaf nodes"),d=f.value):c=kf(a.u(b),f,c)});c.Q(a).e()||null===d||(c=c.G(a.u(".priority"),d));return c};function lf(){this.T=df;this.na=[];this.Mc=-1}function mf(a,b){for(var c=0;c<a.na.length;c++){var d=a.na[c];if(d.kd===b)return d}return null}g=lf.prototype;
5789g.Rd=function(a){var b=Ua(this.na,function(b){return b.kd===a});K(0<=b,"removeWrite called with nonexistent writeId.");var c=this.na[b];this.na.splice(b,1);for(var d=c.visible,e=!1,f=this.na.length-1;d&&0<=f;){var h=this.na[f];h.visible&&(f>=b&&nf(h,c.path)?d=!1:c.path.contains(h.path)&&(e=!0));f--}if(d){if(e)this.T=of(this.na,pf,G),this.Mc=0<this.na.length?this.na[this.na.length-1].kd:-1;else if(c.Ga)this.T=this.T.Rd(c.path);else{var k=this;r(c.children,function(a,b){k.T=k.T.Rd(c.path.u(b))})}return!0}return!1};
5790g.za=function(a,b,c,d){if(c||d){var e=jf(this.T,a);return!d&&e.e()?b:d||null!=b||null!=gf(e,G)?(e=of(this.na,function(b){return(b.visible||d)&&(!c||!(0<=Na(c,b.kd)))&&(b.path.contains(a)||a.contains(b.path))},a),b=b||C,e.apply(b)):null}e=gf(this.T,a);if(null!=e)return e;e=jf(this.T,a);return e.e()?b:null!=b||null!=gf(e,G)?(b=b||C,e.apply(b)):null};
5791g.yc=function(a,b){var c=C,d=gf(this.T,a);if(d)d.K()||d.P(N,function(a,b){c=c.U(a,b)});else if(b){var e=jf(this.T,a);b.P(N,function(a,b){var d=jf(e,new L(a)).apply(b);c=c.U(a,d)});Oa(hf(e),function(a){c=c.U(a.name,a.S)})}else e=jf(this.T,a),Oa(hf(e),function(a){c=c.U(a.name,a.S)});return c};g.ld=function(a,b,c,d){K(c||d,"Either existingEventSnap or existingServerSnap must exist");a=a.u(b);if(null!=gf(this.T,a))return null;a=jf(this.T,a);return a.e()?d.Q(b):a.apply(d.Q(b))};
5792g.xc=function(a,b,c){a=a.u(b);var d=gf(this.T,a);return null!=d?d:sb(c,b)?jf(this.T,a).apply(c.j().R(b)):null};g.tc=function(a){return gf(this.T,a)};g.ne=function(a,b,c,d,e,f){var h;a=jf(this.T,a);h=gf(a,G);if(null==h)if(null!=b)h=a.apply(b);else return[];h=h.lb(f);if(h.e()||h.K())return[];b=[];a=td(f);e=e?h.$b(c,f):h.Yb(c,f);for(f=J(e);f&&b.length<d;)0!==a(f,c)&&b.push(f),f=J(e);return b};
5793function nf(a,b){return a.Ga?a.path.contains(b):!!ua(a.children,function(c,d){return a.path.u(d).contains(b)})}function pf(a){return a.visible}
5794function of(a,b,c){for(var d=df,e=0;e<a.length;++e){var f=a[e];if(b(f)){var h=f.path;if(f.Ga)c.contains(h)?(h=T(c,h),d=ef(d,h,f.Ga)):h.contains(c)&&(h=T(h,c),d=ef(d,G,f.Ga.Q(h)));else if(f.children)if(c.contains(h))h=T(c,h),d=ff(d,h,f.children);else{if(h.contains(c))if(h=T(h,c),h.e())d=ff(d,G,f.children);else if(f=w(f.children,E(h)))f=f.Q(H(h)),d=ef(d,G,f)}else throw Fc("WriteRecord should have .snap or .children");}}return d}function qf(a,b){this.Mb=a;this.X=b}g=qf.prototype;
5795g.za=function(a,b,c){return this.X.za(this.Mb,a,b,c)};g.yc=function(a){return this.X.yc(this.Mb,a)};g.ld=function(a,b,c){return this.X.ld(this.Mb,a,b,c)};g.tc=function(a){return this.X.tc(this.Mb.u(a))};g.ne=function(a,b,c,d,e){return this.X.ne(this.Mb,a,b,c,d,e)};g.xc=function(a,b){return this.X.xc(this.Mb,a,b)};g.u=function(a){return new qf(this.Mb.u(a),this.X)};function rf(){this.ya={}}g=rf.prototype;g.e=function(){return wa(this.ya)};g.ab=function(a,b,c){var d=a.source.Hb;if(null!==d)return d=w(this.ya,d),K(null!=d,"SyncTree gave us an op for an invalid query."),d.ab(a,b,c);var e=[];r(this.ya,function(d){e=e.concat(d.ab(a,b,c))});return e};g.Pb=function(a,b,c,d,e){var f=a.va(),h=w(this.ya,f);if(!h){var h=c.za(e?d:null),k=!1;h?k=!0:(h=d instanceof R?c.yc(d):C,k=!1);h=new ve(a,new Id(new tb(h,k,!1),new tb(d,e,!1)));this.ya[f]=h}h.Pb(b);return ye(h,b)};
5796g.jb=function(a,b,c){var d=a.va(),e=[],f=[],h=null!=sf(this);if("default"===d){var k=this;r(this.ya,function(a,d){f=f.concat(a.jb(b,c));a.e()&&(delete k.ya[d],S(a.W.n)||e.push(a.W))})}else{var l=w(this.ya,d);l&&(f=f.concat(l.jb(b,c)),l.e()&&(delete this.ya[d],S(l.W.n)||e.push(l.W)))}h&&null==sf(this)&&e.push(new U(a.k,a.path));return{Kg:e,mg:f}};function tf(a){return Pa(ra(a.ya),function(a){return!S(a.W.n)})}g.fb=function(a){var b=null;r(this.ya,function(c){b=b||c.fb(a)});return b};
5797function uf(a,b){if(S(b.n))return sf(a);var c=b.va();return w(a.ya,c)}function sf(a){return va(a.ya,function(a){return S(a.W.n)})||null};function vf(a){this.ta=Pd;this.ib=new lf;this.$e={};this.mc={};this.Nc=a}function wf(a,b,c,d,e){var f=a.ib,h=e;K(d>f.Mc,"Stacking an older write on top of newer ones");n(h)||(h=!0);f.na.push({path:b,Ga:c,kd:d,visible:h});h&&(f.T=ef(f.T,b,c));f.Mc=d;return e?xf(a,new Xb($e,b,c)):[]}function yf(a,b,c,d){var e=a.ib;K(d>e.Mc,"Stacking an older merge on top of newer ones");e.na.push({path:b,children:c,kd:d,visible:!0});e.T=ff(e.T,b,c);e.Mc=d;c=Oe(c);return xf(a,new ze($e,b,c))}
5798function zf(a,b,c){c=c||!1;var d=mf(a.ib,b);if(a.ib.Rd(b)){var e=Pd;null!=d.Ga?e=e.set(G,!0):ib(d.children,function(a,b){e=e.set(new L(a),b)});return xf(a,new Ze(d.path,e,c))}return[]}function Af(a,b,c){c=Oe(c);return xf(a,new ze(bf,b,c))}function Bf(a,b,c,d){d=Cf(a,d);if(null!=d){var e=Df(d);d=e.path;e=e.Hb;b=T(d,b);c=new Xb(new af(!1,!0,e,!0),b,c);return Ef(a,d,c)}return[]}
5799function Ff(a,b,c,d){if(d=Cf(a,d)){var e=Df(d);d=e.path;e=e.Hb;b=T(d,b);c=Oe(c);c=new ze(new af(!1,!0,e,!0),b,c);return Ef(a,d,c)}return[]}
5800vf.prototype.Pb=function(a,b){var c=a.path,d=null,e=!1;Ve(this.ta,c,function(a,b){var f=T(a,c);d=b.fb(f);e=e||null!=sf(b);return!d});var f=this.ta.get(c);f?(e=e||null!=sf(f),d=d||f.fb(G)):(f=new rf,this.ta=this.ta.set(c,f));var h;null!=d?h=!0:(h=!1,d=C,Ye(this.ta.subtree(c),function(a,b){var c=b.fb(G);c&&(d=d.U(a,c))}));var k=null!=uf(f,a);if(!k&&!S(a.n)){var l=Gf(a);K(!(l in this.mc),"View does not exist, but we have a tag");var m=Hf++;this.mc[l]=m;this.$e["_"+m]=l}h=f.Pb(a,b,new qf(c,this.ib),d,
5801h);k||e||(f=uf(f,a),h=h.concat(If(this,a,f)));return h};
5802vf.prototype.jb=function(a,b,c){var d=a.path,e=this.ta.get(d),f=[];if(e&&("default"===a.va()||null!=uf(e,a))){f=e.jb(a,b,c);e.e()&&(this.ta=this.ta.remove(d));e=f.Kg;f=f.mg;b=-1!==Ua(e,function(a){return S(a.n)});var h=Te(this.ta,d,function(a,b){return null!=sf(b)});if(b&&!h&&(d=this.ta.subtree(d),!d.e()))for(var d=Jf(d),k=0;k<d.length;++k){var l=d[k],m=l.W,l=Kf(this,l);this.Nc.Xe(Lf(m),Mf(this,m),l.xd,l.H)}if(!h&&0<e.length&&!c)if(b)this.Nc.ae(Lf(a),null);else{var t=this;Oa(e,function(a){a.va();
5803var b=t.mc[Gf(a)];t.Nc.ae(Lf(a),b)})}Nf(this,e)}return f};vf.prototype.za=function(a,b){var c=this.ib,d=Te(this.ta,a,function(b,c){var d=T(b,a);if(d=c.fb(d))return d});return c.za(a,d,b,!0)};function Jf(a){return Re(a,function(a,c,d){if(c&&null!=sf(c))return[sf(c)];var e=[];c&&(e=tf(c));r(d,function(a){e=e.concat(a)});return e})}function Nf(a,b){for(var c=0;c<b.length;++c){var d=b[c];if(!S(d.n)){var d=Gf(d),e=a.mc[d];delete a.mc[d];delete a.$e["_"+e]}}}
5804function Lf(a){return S(a.n)&&!fe(a.n)?a.Ib():a}function If(a,b,c){var d=b.path,e=Mf(a,b);c=Kf(a,c);b=a.Nc.Xe(Lf(b),e,c.xd,c.H);d=a.ta.subtree(d);if(e)K(null==sf(d.value),"If we're adding a query, it shouldn't be shadowed");else for(e=Re(d,function(a,b,c){if(!a.e()&&b&&null!=sf(b))return[we(sf(b))];var d=[];b&&(d=d.concat(Qa(tf(b),function(a){return a.W})));r(c,function(a){d=d.concat(a)});return d}),d=0;d<e.length;++d)c=e[d],a.Nc.ae(Lf(c),Mf(a,c));return b}
5805function Kf(a,b){var c=b.W,d=Mf(a,c);return{xd:function(){return(b.w()||C).hash()},H:function(b){if("ok"===b){if(d){var f=c.path;if(b=Cf(a,d)){var h=Df(b);b=h.path;h=h.Hb;f=T(b,f);f=new Zb(new af(!1,!0,h,!0),f);b=Ef(a,b,f)}else b=[]}else b=xf(a,new Zb(bf,c.path));return b}f="Unknown Error";"too_big"===b?f="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"==b?f="Client doesn't have permission to access the desired data.":"unavailable"==b&&
5806(f="The service is unavailable");f=Error(b+": "+f);f.code=b.toUpperCase();return a.jb(c,null,f)}}}function Gf(a){return a.path.toString()+"$"+a.va()}function Df(a){var b=a.indexOf("$");K(-1!==b&&b<a.length-1,"Bad queryKey.");return{Hb:a.substr(b+1),path:new L(a.substr(0,b))}}function Cf(a,b){var c=a.$e,d="_"+b;return d in c?c[d]:void 0}function Mf(a,b){var c=Gf(b);return w(a.mc,c)}var Hf=1;
5807function Ef(a,b,c){var d=a.ta.get(b);K(d,"Missing sync point for query tag that we're tracking");return d.ab(c,new qf(b,a.ib),null)}function xf(a,b){return Of(a,b,a.ta,null,new qf(G,a.ib))}function Of(a,b,c,d,e){if(b.path.e())return Pf(a,b,c,d,e);var f=c.get(G);null==d&&null!=f&&(d=f.fb(G));var h=[],k=E(b.path),l=b.Xc(k);if((c=c.children.get(k))&&l)var m=d?d.R(k):null,k=e.u(k),h=h.concat(Of(a,l,c,m,k));f&&(h=h.concat(f.ab(b,e,d)));return h}
5808function Pf(a,b,c,d,e){var f=c.get(G);null==d&&null!=f&&(d=f.fb(G));var h=[];c.children.ia(function(c,f){var m=d?d.R(c):null,t=e.u(c),z=b.Xc(c);z&&(h=h.concat(Pf(a,z,f,m,t)))});f&&(h=h.concat(f.ab(b,e,d)));return h};function Qf(){this.children={};this.nd=0;this.value=null}function Rf(a,b,c){this.Gd=a?a:"";this.Zc=b?b:null;this.A=c?c:new Qf}function Sf(a,b){for(var c=b instanceof L?b:new L(b),d=a,e;null!==(e=E(c));)d=new Rf(e,d,w(d.A.children,e)||new Qf),c=H(c);return d}g=Rf.prototype;g.Ca=function(){return this.A.value};function Tf(a,b){K("undefined"!==typeof b,"Cannot set value to undefined");a.A.value=b;Uf(a)}g.clear=function(){this.A.value=null;this.A.children={};this.A.nd=0;Uf(this)};
5809g.wd=function(){return 0<this.A.nd};g.e=function(){return null===this.Ca()&&!this.wd()};g.P=function(a){var b=this;r(this.A.children,function(c,d){a(new Rf(d,b,c))})};function Vf(a,b,c,d){c&&!d&&b(a);a.P(function(a){Vf(a,b,!0,d)});c&&d&&b(a)}function Wf(a,b){for(var c=a.parent();null!==c&&!b(c);)c=c.parent()}g.path=function(){return new L(null===this.Zc?this.Gd:this.Zc.path()+"/"+this.Gd)};g.name=function(){return this.Gd};g.parent=function(){return this.Zc};
5810function Uf(a){if(null!==a.Zc){var b=a.Zc,c=a.Gd,d=a.e(),e=v(b.A.children,c);d&&e?(delete b.A.children[c],b.A.nd--,Uf(b)):d||e||(b.A.children[c]=a.A,b.A.nd++,Uf(b))}};var Xf=/[\[\].#$\/\u0000-\u001F\u007F]/,Yf=/[\[\].#$\u0000-\u001F\u007F]/,Zf=/^[a-zA-Z][a-zA-Z._\-+]+$/;function $f(a){return p(a)&&0!==a.length&&!Xf.test(a)}function ag(a){return null===a||p(a)||ga(a)&&!Qc(a)||ia(a)&&v(a,".sv")}function bg(a,b,c,d){d&&!n(b)||cg(y(a,1,d),b,c)}
5811function cg(a,b,c){c instanceof L&&(c=new Je(c,a));if(!n(b))throw Error(a+"contains undefined "+Le(c));if(ha(b))throw Error(a+"contains a function "+Le(c)+" with contents: "+b.toString());if(Qc(b))throw Error(a+"contains "+b.toString()+" "+Le(c));if(p(b)&&b.length>10485760/3&&10485760<Zc(b))throw Error(a+"contains a string greater than 10485760 utf8 bytes "+Le(c)+" ('"+b.substring(0,50)+"...')");if(ia(b)){var d=!1,e=!1;ib(b,function(b,h){if(".value"===b)d=!0;else if(".priority"!==b&&".sv"!==b&&(e=
5812!0,!$f(b)))throw Error(a+" contains an invalid key ("+b+") "+Le(c)+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');c.push(b);cg(a,h,c);c.pop()});if(d&&e)throw Error(a+' contains ".value" child '+Le(c)+" in addition to actual children.");}}
5813function dg(a,b){var c,d;for(c=0;c<b.length;c++){d=b[c];for(var e=d.slice(),f=0;f<e.length;f++)if((".priority"!==e[f]||f!==e.length-1)&&!$f(e[f]))throw Error(a+"contains an invalid key ("+e[f]+") in path "+d.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');}b.sort(Ie);e=null;for(c=0;c<b.length;c++){d=b[c];if(null!==e&&e.contains(d))throw Error(a+"contains a path "+e.toString()+" that is ancestor of another path "+d.toString());e=d}}
5814function eg(a,b,c){var d=y(a,1,!1);if(!ia(b)||ea(b))throw Error(d+" must be an object containing the children to replace.");var e=[];ib(b,function(a,b){var k=new L(a);cg(d,b,c.u(k));if(".priority"===Ld(k)&&!ag(b))throw Error(d+"contains an invalid value for '"+k.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");e.push(k)});dg(d,e)}
5815function fg(a,b,c){if(Qc(c))throw Error(y(a,b,!1)+"is "+c.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!ag(c))throw Error(y(a,b,!1)+"must be a valid Firebase priority (a string, finite number, server value, or null).");}
5816function gg(a,b,c){if(!c||n(b))switch(b){case "value":case "child_added":case "child_removed":case "child_changed":case "child_moved":break;default:throw Error(y(a,1,c)+'must be a valid event type: "value", "child_added", "child_removed", "child_changed", or "child_moved".');}}function hg(a,b){if(n(b)&&!$f(b))throw Error(y(a,2,!0)+'was an invalid key: "'+b+'". Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").');}
5817function ig(a,b){if(!p(b)||0===b.length||Yf.test(b))throw Error(y(a,1,!1)+'was an invalid path: "'+b+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"');}function jg(a,b){if(".info"===E(b))throw Error(a+" failed: Can't modify data under /.info/");}function kg(a,b){if(!p(b))throw Error(y(a,1,!1)+"must be a valid credential (a string).");}function lg(a,b,c){if(!p(c))throw Error(y(a,b,!1)+"must be a valid string.");}
5818function mg(a,b){lg(a,1,b);if(!Zf.test(b))throw Error(y(a,1,!1)+"'"+b+"' is not a valid authentication provider.");}function ng(a,b,c,d){if(!d||n(c))if(!ia(c)||null===c)throw Error(y(a,b,d)+"must be a valid object.");}function og(a,b,c){if(!ia(b)||!v(b,c))throw Error(y(a,1,!1)+'must contain the key "'+c+'"');if(!p(w(b,c)))throw Error(y(a,1,!1)+'must contain the key "'+c+'" with type "string"');};function pg(){this.set={}}g=pg.prototype;g.add=function(a,b){this.set[a]=null!==b?b:!0};g.contains=function(a){return v(this.set,a)};g.get=function(a){return this.contains(a)?this.set[a]:void 0};g.remove=function(a){delete this.set[a]};g.clear=function(){this.set={}};g.e=function(){return wa(this.set)};g.count=function(){return pa(this.set)};function qg(a,b){r(a.set,function(a,d){b(d,a)})}g.keys=function(){var a=[];r(this.set,function(b,c){a.push(c)});return a};function qc(){this.m=this.B=null}qc.prototype.find=function(a){if(null!=this.B)return this.B.Q(a);if(a.e()||null==this.m)return null;var b=E(a);a=H(a);return this.m.contains(b)?this.m.get(b).find(a):null};qc.prototype.nc=function(a,b){if(a.e())this.B=b,this.m=null;else if(null!==this.B)this.B=this.B.G(a,b);else{null==this.m&&(this.m=new pg);var c=E(a);this.m.contains(c)||this.m.add(c,new qc);c=this.m.get(c);a=H(a);c.nc(a,b)}};
5819function rg(a,b){if(b.e())return a.B=null,a.m=null,!0;if(null!==a.B){if(a.B.K())return!1;var c=a.B;a.B=null;c.P(N,function(b,c){a.nc(new L(b),c)});return rg(a,b)}return null!==a.m?(c=E(b),b=H(b),a.m.contains(c)&&rg(a.m.get(c),b)&&a.m.remove(c),a.m.e()?(a.m=null,!0):!1):!0}function rc(a,b,c){null!==a.B?c(b,a.B):a.P(function(a,e){var f=new L(b.toString()+"/"+a);rc(e,f,c)})}qc.prototype.P=function(a){null!==this.m&&qg(this.m,function(b,c){a(b,c)})};var sg="auth.firebase.com";function tg(a,b,c){this.od=a||{};this.ee=b||{};this.$a=c||{};this.od.remember||(this.od.remember="default")}var ug=["remember","redirectTo"];function vg(a){var b={},c={};ib(a||{},function(a,e){0<=Na(ug,a)?b[a]=e:c[a]=e});return new tg(b,{},c)};function wg(a,b){this.Qe=["session",a.Od,a.hc].join(":");this.be=b}wg.prototype.set=function(a,b){if(!b)if(this.be.length)b=this.be[0];else throw Error("fb.login.SessionManager : No storage options available!");b.set(this.Qe,a)};wg.prototype.get=function(){var a=Qa(this.be,q(this.qg,this)),a=Pa(a,function(a){return null!==a});Xa(a,function(a,c){return ad(c.token)-ad(a.token)});return 0<a.length?a.shift():null};wg.prototype.qg=function(a){try{var b=a.get(this.Qe);if(b&&b.token)return b}catch(c){}return null};
5820wg.prototype.clear=function(){var a=this;Oa(this.be,function(b){b.remove(a.Qe)})};function xg(){return"undefined"!==typeof navigator&&"string"===typeof navigator.userAgent?navigator.userAgent:""}function yg(){return"undefined"!==typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(xg())}function zg(){return"undefined"!==typeof location&&/^file:\//.test(location.href)}
5821function Ag(a){var b=xg();if(""===b)return!1;if("Microsoft Internet Explorer"===navigator.appName){if((b=b.match(/MSIE ([0-9]{1,}[\.0-9]{0,})/))&&1<b.length)return parseFloat(b[1])>=a}else if(-1<b.indexOf("Trident")&&(b=b.match(/rv:([0-9]{2,2}[\.0-9]{0,})/))&&1<b.length)return parseFloat(b[1])>=a;return!1};function Bg(){var a=window.opener.frames,b;for(b=a.length-1;0<=b;b--)try{if(a[b].location.protocol===window.location.protocol&&a[b].location.host===window.location.host&&"__winchan_relay_frame"===a[b].name)return a[b]}catch(c){}return null}function Cg(a,b,c){a.attachEvent?a.attachEvent("on"+b,c):a.addEventListener&&a.addEventListener(b,c,!1)}function Dg(a,b,c){a.detachEvent?a.detachEvent("on"+b,c):a.removeEventListener&&a.removeEventListener(b,c,!1)}
5822function Eg(a){/^https?:\/\//.test(a)||(a=window.location.href);var b=/^(https?:\/\/[\-_a-zA-Z\.0-9:]+)/.exec(a);return b?b[1]:a}function Fg(a){var b="";try{a=a.replace("#","");var c=lb(a);c&&v(c,"__firebase_request_key")&&(b=w(c,"__firebase_request_key"))}catch(d){}return b}function Gg(){var a=Pc(sg);return a.scheme+"://"+a.host+"/v2"}function Hg(a){return Gg()+"/"+a+"/auth/channel"};function Ig(a){var b=this;this.Ac=a;this.ce="*";Ag(8)?this.Rc=this.zd=Bg():(this.Rc=window.opener,this.zd=window);if(!b.Rc)throw"Unable to find relay frame";Cg(this.zd,"message",q(this.jc,this));Cg(this.zd,"message",q(this.Bf,this));try{Jg(this,{a:"ready"})}catch(c){Cg(this.Rc,"load",function(){Jg(b,{a:"ready"})})}Cg(window,"unload",q(this.Bg,this))}function Jg(a,b){b=B(b);Ag(8)?a.Rc.doPost(b,a.ce):a.Rc.postMessage(b,a.ce)}
5823Ig.prototype.jc=function(a){var b=this,c;try{c=nb(a.data)}catch(d){}c&&"request"===c.a&&(Dg(window,"message",this.jc),this.ce=a.origin,this.Ac&&setTimeout(function(){b.Ac(b.ce,c.d,function(a,c){b.dg=!c;b.Ac=void 0;Jg(b,{a:"response",d:a,forceKeepWindowOpen:c})})},0))};Ig.prototype.Bg=function(){try{Dg(this.zd,"message",this.Bf)}catch(a){}this.Ac&&(Jg(this,{a:"error",d:"unknown closed window"}),this.Ac=void 0);try{window.close()}catch(b){}};Ig.prototype.Bf=function(a){if(this.dg&&"die"===a.data)try{window.close()}catch(b){}};function Kg(a){this.pc=Ga()+Ga()+Ga();this.Ef=a}Kg.prototype.open=function(a,b){yc.set("redirect_request_id",this.pc);yc.set("redirect_request_id",this.pc);b.requestId=this.pc;b.redirectTo=b.redirectTo||window.location.href;a+=(/\?/.test(a)?"":"?")+kb(b);window.location=a};Kg.isAvailable=function(){return!zg()&&!yg()};Kg.prototype.Cc=function(){return"redirect"};var Lg={NETWORK_ERROR:"Unable to contact the Firebase server.",SERVER_ERROR:"An unknown server error occurred.",TRANSPORT_UNAVAILABLE:"There are no login transports available for the requested method.",REQUEST_INTERRUPTED:"The browser redirected the page before the login request could complete.",USER_CANCELLED:"The user cancelled authentication."};function Mg(a){var b=Error(w(Lg,a),a);b.code=a;return b};function Ng(a){var b;(b=!a.window_features)||(b=xg(),b=-1!==b.indexOf("Fennec/")||-1!==b.indexOf("Firefox/")&&-1!==b.indexOf("Android"));b&&(a.window_features=void 0);a.window_name||(a.window_name="_blank");this.options=a}
5824Ng.prototype.open=function(a,b,c){function d(a){h&&(document.body.removeChild(h),h=void 0);t&&(t=clearInterval(t));Dg(window,"message",e);Dg(window,"unload",d);if(m&&!a)try{m.close()}catch(b){k.postMessage("die",l)}m=k=void 0}function e(a){if(a.origin===l)try{var b=nb(a.data);"ready"===b.a?k.postMessage(z,l):"error"===b.a?(d(!1),c&&(c(b.d),c=null)):"response"===b.a&&(d(b.forceKeepWindowOpen),c&&(c(null,b.d),c=null))}catch(e){}}var f=Ag(8),h,k;if(!this.options.relay_url)return c(Error("invalid arguments: origin of url and relay_url must match"));
5825var l=Eg(a);if(l!==Eg(this.options.relay_url))c&&setTimeout(function(){c(Error("invalid arguments: origin of url and relay_url must match"))},0);else{f&&(h=document.createElement("iframe"),h.setAttribute("src",this.options.relay_url),h.style.display="none",h.setAttribute("name","__winchan_relay_frame"),document.body.appendChild(h),k=h.contentWindow);a+=(/\?/.test(a)?"":"?")+kb(b);var m=window.open(a,this.options.window_name,this.options.window_features);k||(k=m);var t=setInterval(function(){m&&m.closed&&
5826(d(!1),c&&(c(Mg("USER_CANCELLED")),c=null))},500),z=B({a:"request",d:b});Cg(window,"unload",d);Cg(window,"message",e)}};
5827Ng.isAvailable=function(){var a;if(a="postMessage"in window&&!zg())(a=yg()||"undefined"!==typeof navigator&&(!!xg().match(/Windows Phone/)||!!window.Windows&&/^ms-appx:/.test(location.href)))||(a=xg(),a="undefined"!==typeof navigator&&"undefined"!==typeof window&&!!(a.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i)||a.match(/CriOS/)||a.match(/Twitter for iPhone/)||a.match(/FBAN\/FBIOS/)||window.navigator.standalone)),a=!a;return a&&!xg().match(/PhantomJS/)};Ng.prototype.Cc=function(){return"popup"};function Og(a){a.method||(a.method="GET");a.headers||(a.headers={});a.headers.content_type||(a.headers.content_type="application/json");a.headers.content_type=a.headers.content_type.toLowerCase();this.options=a}
5828Og.prototype.open=function(a,b,c){function d(){c&&(c(Mg("REQUEST_INTERRUPTED")),c=null)}var e=new XMLHttpRequest,f=this.options.method.toUpperCase(),h;Cg(window,"beforeunload",d);e.onreadystatechange=function(){if(c&&4===e.readyState){var a;if(200<=e.status&&300>e.status){try{a=nb(e.responseText)}catch(b){}c(null,a)}else 500<=e.status&&600>e.status?c(Mg("SERVER_ERROR")):c(Mg("NETWORK_ERROR"));c=null;Dg(window,"beforeunload",d)}};if("GET"===f)a+=(/\?/.test(a)?"":"?")+kb(b),h=null;else{var k=this.options.headers.content_type;
5829"application/json"===k&&(h=B(b));"application/x-www-form-urlencoded"===k&&(h=kb(b))}e.open(f,a,!0);a={"X-Requested-With":"XMLHttpRequest",Accept:"application/json;text/plain"};za(a,this.options.headers);for(var l in a)e.setRequestHeader(l,a[l]);e.send(h)};Og.isAvailable=function(){var a;if(a=!!window.XMLHttpRequest)a=xg(),a=!(a.match(/MSIE/)||a.match(/Trident/))||Ag(10);return a};Og.prototype.Cc=function(){return"json"};function Pg(a){this.pc=Ga()+Ga()+Ga();this.Ef=a}
5830Pg.prototype.open=function(a,b,c){function d(){c&&(c(Mg("USER_CANCELLED")),c=null)}var e=this,f=Pc(sg),h;b.requestId=this.pc;b.redirectTo=f.scheme+"://"+f.host+"/blank/page.html";a+=/\?/.test(a)?"":"?";a+=kb(b);(h=window.open(a,"_blank","location=no"))&&ha(h.addEventListener)?(h.addEventListener("loadstart",function(a){var b;if(b=a&&a.url)a:{try{var m=document.createElement("a");m.href=a.url;b=m.host===f.host&&"/blank/page.html"===m.pathname;break a}catch(t){}b=!1}b&&(a=Fg(a.url),h.removeEventListener("exit",
5831d),h.close(),a=new tg(null,null,{requestId:e.pc,requestKey:a}),e.Ef.requestWithCredential("/auth/session",a,c),c=null)}),h.addEventListener("exit",d)):c(Mg("TRANSPORT_UNAVAILABLE"))};Pg.isAvailable=function(){return yg()};Pg.prototype.Cc=function(){return"redirect"};function Qg(a){a.callback_parameter||(a.callback_parameter="callback");this.options=a;window.__firebase_auth_jsonp=window.__firebase_auth_jsonp||{}}
5832Qg.prototype.open=function(a,b,c){function d(){c&&(c(Mg("REQUEST_INTERRUPTED")),c=null)}function e(){setTimeout(function(){window.__firebase_auth_jsonp[f]=void 0;wa(window.__firebase_auth_jsonp)&&(window.__firebase_auth_jsonp=void 0);try{var a=document.getElementById(f);a&&a.parentNode.removeChild(a)}catch(b){}},1);Dg(window,"beforeunload",d)}var f="fn"+(new Date).getTime()+Math.floor(99999*Math.random());b[this.options.callback_parameter]="__firebase_auth_jsonp."+f;a+=(/\?/.test(a)?"":"?")+kb(b);
5833Cg(window,"beforeunload",d);window.__firebase_auth_jsonp[f]=function(a){c&&(c(null,a),c=null);e()};Rg(f,a,c)};
5834function Rg(a,b,c){setTimeout(function(){try{var d=document.createElement("script");d.type="text/javascript";d.id=a;d.async=!0;d.src=b;d.onerror=function(){var b=document.getElementById(a);null!==b&&b.parentNode.removeChild(b);c&&c(Mg("NETWORK_ERROR"))};var e=document.getElementsByTagName("head");(e&&0!=e.length?e[0]:document.documentElement).appendChild(d)}catch(f){c&&c(Mg("NETWORK_ERROR"))}},0)}Qg.isAvailable=function(){return"undefined"!==typeof document&&null!=document.createElement};
5835Qg.prototype.Cc=function(){return"json"};function Sg(a,b,c,d){De.call(this,["auth_status"]);this.F=a;this.df=b;this.Vg=c;this.Le=d;this.sc=new wg(a,[xc,yc]);this.mb=null;this.Se=!1;Tg(this)}ma(Sg,De);g=Sg.prototype;g.xe=function(){return this.mb||null};function Tg(a){yc.get("redirect_request_id")&&Ug(a);var b=a.sc.get();b&&b.token?(Vg(a,b),a.df(b.token,function(c,d){Wg(a,c,d,!1,b.token,b)},function(b,d){Xg(a,"resumeSession()",b,d)})):Vg(a,null)}
5836function Yg(a,b,c,d,e,f){"firebaseio-demo.com"===a.F.domain&&O("Firebase authentication is not supported on demo Firebases (*.firebaseio-demo.com). To secure your Firebase, create a production Firebase at https://www.firebase.com.");a.df(b,function(f,k){Wg(a,f,k,!0,b,c,d||{},e)},function(b,c){Xg(a,"auth()",b,c,f)})}function Zg(a,b){a.sc.clear();Vg(a,null);a.Vg(function(a,d){if("ok"===a)P(b,null);else{var e=(a||"error").toUpperCase(),f=e;d&&(f+=": "+d);f=Error(f);f.code=e;P(b,f)}})}
5837function Wg(a,b,c,d,e,f,h,k){"ok"===b?(d&&(b=c.auth,f.auth=b,f.expires=c.expires,f.token=bd(e)?e:"",c=null,b&&v(b,"uid")?c=w(b,"uid"):v(f,"uid")&&(c=w(f,"uid")),f.uid=c,c="custom",b&&v(b,"provider")?c=w(b,"provider"):v(f,"provider")&&(c=w(f,"provider")),f.provider=c,a.sc.clear(),bd(e)&&(h=h||{},c=xc,"sessionOnly"===h.remember&&(c=yc),"none"!==h.remember&&a.sc.set(f,c)),Vg(a,f)),P(k,null,f)):(a.sc.clear(),Vg(a,null),f=a=(b||"error").toUpperCase(),c&&(f+=": "+c),f=Error(f),f.code=a,P(k,f))}
5838function Xg(a,b,c,d,e){O(b+" was canceled: "+d);a.sc.clear();Vg(a,null);a=Error(d);a.code=c.toUpperCase();P(e,a)}function $g(a,b,c,d,e){ah(a);c=new tg(d||{},{},c||{});bh(a,[Og,Qg],"/auth/"+b,c,e)}
5839function ch(a,b,c,d){ah(a);var e=[Ng,Pg];c=vg(c);"anonymous"===b||"password"===b?setTimeout(function(){P(d,Mg("TRANSPORT_UNAVAILABLE"))},0):(c.ee.window_features="menubar=yes,modal=yes,alwaysRaised=yeslocation=yes,resizable=yes,scrollbars=yes,status=yes,height=625,width=625,top="+("object"===typeof screen?.5*(screen.height-625):0)+",left="+("object"===typeof screen?.5*(screen.width-625):0),c.ee.relay_url=Hg(a.F.hc),c.ee.requestWithCredential=q(a.qc,a),bh(a,e,"/auth/"+b,c,d))}
5840function Ug(a){var b=yc.get("redirect_request_id");if(b){var c=yc.get("redirect_client_options");yc.remove("redirect_request_id");yc.remove("redirect_client_options");var d=[Og,Qg],b={requestId:b,requestKey:Fg(document.location.hash)},c=new tg(c,{},b);a.Se=!0;try{document.location.hash=document.location.hash.replace(/&__firebase_request_key=([a-zA-z0-9]*)/,"")}catch(e){}bh(a,d,"/auth/session",c,function(){this.Se=!1}.bind(a))}}
5841g.se=function(a,b){ah(this);var c=vg(a);c.$a._method="POST";this.qc("/users",c,function(a,c){a?P(b,a):P(b,a,c)})};g.Te=function(a,b){var c=this;ah(this);var d="/users/"+encodeURIComponent(a.email),e=vg(a);e.$a._method="DELETE";this.qc(d,e,function(a,d){!a&&d&&d.uid&&c.mb&&c.mb.uid&&c.mb.uid===d.uid&&Zg(c);P(b,a)})};g.pe=function(a,b){ah(this);var c="/users/"+encodeURIComponent(a.email)+"/password",d=vg(a);d.$a._method="PUT";d.$a.password=a.newPassword;this.qc(c,d,function(a){P(b,a)})};
5842g.oe=function(a,b){ah(this);var c="/users/"+encodeURIComponent(a.oldEmail)+"/email",d=vg(a);d.$a._method="PUT";d.$a.email=a.newEmail;d.$a.password=a.password;this.qc(c,d,function(a){P(b,a)})};g.Ve=function(a,b){ah(this);var c="/users/"+encodeURIComponent(a.email)+"/password",d=vg(a);d.$a._method="POST";this.qc(c,d,function(a){P(b,a)})};g.qc=function(a,b,c){dh(this,[Og,Qg],a,b,c)};
5843function bh(a,b,c,d,e){dh(a,b,c,d,function(b,c){!b&&c&&c.token&&c.uid?Yg(a,c.token,c,d.od,function(a,b){a?P(e,a):P(e,null,b)}):P(e,b||Mg("UNKNOWN_ERROR"))})}
5844function dh(a,b,c,d,e){b=Pa(b,function(a){return"function"===typeof a.isAvailable&&a.isAvailable()});0===b.length?setTimeout(function(){P(e,Mg("TRANSPORT_UNAVAILABLE"))},0):(b=new (b.shift())(d.ee),d=jb(d.$a),d.v="js-"+hb,d.transport=b.Cc(),d.suppress_status_codes=!0,a=Gg()+"/"+a.F.hc+c,b.open(a,d,function(a,b){if(a)P(e,a);else if(b&&b.error){var c=Error(b.error.message);c.code=b.error.code;c.details=b.error.details;P(e,c)}else P(e,null,b)}))}
5845function Vg(a,b){var c=null!==a.mb||null!==b;a.mb=b;c&&a.fe("auth_status",b);a.Le(null!==b)}g.Ae=function(a){K("auth_status"===a,'initial event must be of type "auth_status"');return this.Se?null:[this.mb]};function ah(a){var b=a.F;if("firebaseio.com"!==b.domain&&"firebaseio-demo.com"!==b.domain&&"auth.firebase.com"===sg)throw Error("This custom Firebase server ('"+a.F.domain+"') does not support delegated login.");};var Cc="websocket",Dc="long_polling";function eh(a){this.jc=a;this.Nd=[];this.Sb=0;this.qe=-1;this.Fb=null}function fh(a,b,c){a.qe=b;a.Fb=c;a.qe<a.Sb&&(a.Fb(),a.Fb=null)}function gh(a,b,c){for(a.Nd[b]=c;a.Nd[a.Sb];){var d=a.Nd[a.Sb];delete a.Nd[a.Sb];for(var e=0;e<d.length;++e)if(d[e]){var f=a;Db(function(){f.jc(d[e])})}if(a.Sb===a.qe){a.Fb&&(clearTimeout(a.Fb),a.Fb(),a.Fb=null);break}a.Sb++}};function hh(a,b,c,d){this.re=a;this.f=Mc(a);this.nb=this.ob=0;this.Ua=Rb(b);this.Qf=c;this.Hc=!1;this.Bb=d;this.jd=function(a){return Bc(b,Dc,a)}}var ih,jh;
5846hh.prototype.open=function(a,b){this.hf=0;this.la=b;this.Af=new eh(a);this.zb=!1;var c=this;this.qb=setTimeout(function(){c.f("Timed out trying to connect.");c.gb();c.qb=null},Math.floor(3E4));Rc(function(){if(!c.zb){c.Sa=new kh(function(a,b,d,k,l){lh(c,arguments);if(c.Sa)if(c.qb&&(clearTimeout(c.qb),c.qb=null),c.Hc=!0,"start"==a)c.id=b,c.Gf=d;else if("close"===a)b?(c.Sa.Xd=!1,fh(c.Af,b,function(){c.gb()})):c.gb();else throw Error("Unrecognized command received: "+a);},function(a,b){lh(c,arguments);
5847gh(c.Af,a,b)},function(){c.gb()},c.jd);var a={start:"t"};a.ser=Math.floor(1E8*Math.random());c.Sa.he&&(a.cb=c.Sa.he);a.v="5";c.Qf&&(a.s=c.Qf);c.Bb&&(a.ls=c.Bb);"undefined"!==typeof location&&location.href&&-1!==location.href.indexOf("firebaseio.com")&&(a.r="f");a=c.jd(a);c.f("Connecting via long-poll to "+a);mh(c.Sa,a,function(){})}})};
5848hh.prototype.start=function(){var a=this.Sa,b=this.Gf;a.ug=this.id;a.vg=b;for(a.le=!0;nh(a););a=this.id;b=this.Gf;this.gc=document.createElement("iframe");var c={dframe:"t"};c.id=a;c.pw=b;this.gc.src=this.jd(c);this.gc.style.display="none";document.body.appendChild(this.gc)};
5849hh.isAvailable=function(){return ih||!jh&&"undefined"!==typeof document&&null!=document.createElement&&!("object"===typeof window&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))&&!("object"===typeof Windows&&"object"===typeof Windows.Xg)&&!0};g=hh.prototype;g.Ed=function(){};g.dd=function(){this.zb=!0;this.Sa&&(this.Sa.close(),this.Sa=null);this.gc&&(document.body.removeChild(this.gc),this.gc=null);this.qb&&(clearTimeout(this.qb),this.qb=null)};
5850g.gb=function(){this.zb||(this.f("Longpoll is closing itself"),this.dd(),this.la&&(this.la(this.Hc),this.la=null))};g.close=function(){this.zb||(this.f("Longpoll is being closed."),this.dd())};g.send=function(a){a=B(a);this.ob+=a.length;Ob(this.Ua,"bytes_sent",a.length);a=Ic(a);a=fb(a,!0);a=Vc(a,1840);for(var b=0;b<a.length;b++){var c=this.Sa;c.ad.push({Mg:this.hf,Ug:a.length,kf:a[b]});c.le&&nh(c);this.hf++}};function lh(a,b){var c=B(b).length;a.nb+=c;Ob(a.Ua,"bytes_received",c)}
5851function kh(a,b,c,d){this.jd=d;this.hb=c;this.Pe=new pg;this.ad=[];this.te=Math.floor(1E8*Math.random());this.Xd=!0;this.he=Ec();window["pLPCommand"+this.he]=a;window["pRTLPCB"+this.he]=b;a=document.createElement("iframe");a.style.display="none";if(document.body){document.body.appendChild(a);try{a.contentWindow.document||Cb("No IE domain setting required")}catch(e){a.src="javascript:void((function(){document.open();document.domain='"+document.domain+"';document.close();})())"}}else throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";
5852a.contentDocument?a.eb=a.contentDocument:a.contentWindow?a.eb=a.contentWindow.document:a.document&&(a.eb=a.document);this.Ea=a;a="";this.Ea.src&&"javascript:"===this.Ea.src.substr(0,11)&&(a='<script>document.domain="'+document.domain+'";\x3c/script>');a="<html><body>"+a+"</body></html>";try{this.Ea.eb.open(),this.Ea.eb.write(a),this.Ea.eb.close()}catch(f){Cb("frame writing exception"),f.stack&&Cb(f.stack),Cb(f)}}
5853kh.prototype.close=function(){this.le=!1;if(this.Ea){this.Ea.eb.body.innerHTML="";var a=this;setTimeout(function(){null!==a.Ea&&(document.body.removeChild(a.Ea),a.Ea=null)},Math.floor(0))}var b=this.hb;b&&(this.hb=null,b())};
5854function nh(a){if(a.le&&a.Xd&&a.Pe.count()<(0<a.ad.length?2:1)){a.te++;var b={};b.id=a.ug;b.pw=a.vg;b.ser=a.te;for(var b=a.jd(b),c="",d=0;0<a.ad.length;)if(1870>=a.ad[0].kf.length+30+c.length){var e=a.ad.shift(),c=c+"&seg"+d+"="+e.Mg+"&ts"+d+"="+e.Ug+"&d"+d+"="+e.kf;d++}else break;oh(a,b+c,a.te);return!0}return!1}function oh(a,b,c){function d(){a.Pe.remove(c);nh(a)}a.Pe.add(c,1);var e=setTimeout(d,Math.floor(25E3));mh(a,b,function(){clearTimeout(e);d()})}
5855function mh(a,b,c){setTimeout(function(){try{if(a.Xd){var d=a.Ea.eb.createElement("script");d.type="text/javascript";d.async=!0;d.src=b;d.onload=d.onreadystatechange=function(){var a=d.readyState;a&&"loaded"!==a&&"complete"!==a||(d.onload=d.onreadystatechange=null,d.parentNode&&d.parentNode.removeChild(d),c())};d.onerror=function(){Cb("Long-poll script failed to load: "+b);a.Xd=!1;a.close()};a.Ea.eb.body.appendChild(d)}}catch(e){}},Math.floor(1))};var ph=null;"undefined"!==typeof MozWebSocket?ph=MozWebSocket:"undefined"!==typeof WebSocket&&(ph=WebSocket);function qh(a,b,c,d){this.re=a;this.f=Mc(this.re);this.frames=this.Kc=null;this.nb=this.ob=this.bf=0;this.Ua=Rb(b);a={v:"5"};"undefined"!==typeof location&&location.href&&-1!==location.href.indexOf("firebaseio.com")&&(a.r="f");c&&(a.s=c);d&&(a.ls=d);this.ef=Bc(b,Cc,a)}var rh;
5856qh.prototype.open=function(a,b){this.hb=b;this.zg=a;this.f("Websocket connecting to "+this.ef);this.Hc=!1;xc.set("previous_websocket_failure",!0);try{this.ua=new ph(this.ef)}catch(c){this.f("Error instantiating WebSocket.");var d=c.message||c.data;d&&this.f(d);this.gb();return}var e=this;this.ua.onopen=function(){e.f("Websocket connected.");e.Hc=!0};this.ua.onclose=function(){e.f("Websocket connection was disconnected.");e.ua=null;e.gb()};this.ua.onmessage=function(a){if(null!==e.ua)if(a=a.data,e.nb+=
5857a.length,Ob(e.Ua,"bytes_received",a.length),sh(e),null!==e.frames)th(e,a);else{a:{K(null===e.frames,"We already have a frame buffer");if(6>=a.length){var b=Number(a);if(!isNaN(b)){e.bf=b;e.frames=[];a=null;break a}}e.bf=1;e.frames=[]}null!==a&&th(e,a)}};this.ua.onerror=function(a){e.f("WebSocket error. Closing connection.");(a=a.message||a.data)&&e.f(a);e.gb()}};qh.prototype.start=function(){};
5858qh.isAvailable=function(){var a=!1;if("undefined"!==typeof navigator&&navigator.userAgent){var b=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/);b&&1<b.length&&4.4>parseFloat(b[1])&&(a=!0)}return!a&&null!==ph&&!rh};qh.responsesRequiredToBeHealthy=2;qh.healthyTimeout=3E4;g=qh.prototype;g.Ed=function(){xc.remove("previous_websocket_failure")};function th(a,b){a.frames.push(b);if(a.frames.length==a.bf){var c=a.frames.join("");a.frames=null;c=nb(c);a.zg(c)}}
5859g.send=function(a){sh(this);a=B(a);this.ob+=a.length;Ob(this.Ua,"bytes_sent",a.length);a=Vc(a,16384);1<a.length&&this.ua.send(String(a.length));for(var b=0;b<a.length;b++)this.ua.send(a[b])};g.dd=function(){this.zb=!0;this.Kc&&(clearInterval(this.Kc),this.Kc=null);this.ua&&(this.ua.close(),this.ua=null)};g.gb=function(){this.zb||(this.f("WebSocket is closing itself"),this.dd(),this.hb&&(this.hb(this.Hc),this.hb=null))};g.close=function(){this.zb||(this.f("WebSocket is being closed"),this.dd())};
5860function sh(a){clearInterval(a.Kc);a.Kc=setInterval(function(){a.ua&&a.ua.send("0");sh(a)},Math.floor(45E3))};function uh(a){vh(this,a)}var wh=[hh,qh];function vh(a,b){var c=qh&&qh.isAvailable(),d=c&&!(xc.wf||!0===xc.get("previous_websocket_failure"));b.Wg&&(c||O("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),d=!0);if(d)a.gd=[qh];else{var e=a.gd=[];Wc(wh,function(a,b){b&&b.isAvailable()&&e.push(b)})}}function xh(a){if(0<a.gd.length)return a.gd[0];throw Error("No transports available");};function yh(a,b,c,d,e,f,h){this.id=a;this.f=Mc("c:"+this.id+":");this.jc=c;this.Wc=d;this.la=e;this.Ne=f;this.F=b;this.Md=[];this.ff=0;this.Pf=new uh(b);this.Ta=0;this.Bb=h;this.f("Connection created");zh(this)}
5861function zh(a){var b=xh(a.Pf);a.J=new b("c:"+a.id+":"+a.ff++,a.F,void 0,a.Bb);a.Re=b.responsesRequiredToBeHealthy||0;var c=Ah(a,a.J),d=Bh(a,a.J);a.hd=a.J;a.cd=a.J;a.D=null;a.Ab=!1;setTimeout(function(){a.J&&a.J.open(c,d)},Math.floor(0));b=b.healthyTimeout||0;0<b&&(a.yd=setTimeout(function(){a.yd=null;a.Ab||(a.J&&102400<a.J.nb?(a.f("Connection exceeded healthy timeout but has received "+a.J.nb+" bytes. Marking connection healthy."),a.Ab=!0,a.J.Ed()):a.J&&10240<a.J.ob?a.f("Connection exceeded healthy timeout but has sent "+
5862a.J.ob+" bytes. Leaving connection alive."):(a.f("Closing unhealthy connection after timeout."),a.close()))},Math.floor(b)))}function Bh(a,b){return function(c){b===a.J?(a.J=null,c||0!==a.Ta?1===a.Ta&&a.f("Realtime connection lost."):(a.f("Realtime connection failed."),"s-"===a.F.Ya.substr(0,2)&&(xc.remove("host:"+a.F.host),a.F.Ya=a.F.host)),a.close()):b===a.D?(a.f("Secondary connection lost."),c=a.D,a.D=null,a.hd!==c&&a.cd!==c||a.close()):a.f("closing an old connection")}}
5863function Ah(a,b){return function(c){if(2!=a.Ta)if(b===a.cd){var d=Tc("t",c);c=Tc("d",c);if("c"==d){if(d=Tc("t",c),"d"in c)if(c=c.d,"h"===d){var d=c.ts,e=c.v,f=c.h;a.Nf=c.s;Ac(a.F,f);0==a.Ta&&(a.J.start(),Ch(a,a.J,d),"5"!==e&&O("Protocol version mismatch detected"),c=a.Pf,(c=1<c.gd.length?c.gd[1]:null)&&Dh(a,c))}else if("n"===d){a.f("recvd end transmission on primary");a.cd=a.D;for(c=0;c<a.Md.length;++c)a.Id(a.Md[c]);a.Md=[];Eh(a)}else"s"===d?(a.f("Connection shutdown command received. Shutting down..."),
5864a.Ne&&(a.Ne(c),a.Ne=null),a.la=null,a.close()):"r"===d?(a.f("Reset packet received. New host: "+c),Ac(a.F,c),1===a.Ta?a.close():(Fh(a),zh(a))):"e"===d?Nc("Server Error: "+c):"o"===d?(a.f("got pong on primary."),Gh(a),Hh(a)):Nc("Unknown control packet command: "+d)}else"d"==d&&a.Id(c)}else if(b===a.D)if(d=Tc("t",c),c=Tc("d",c),"c"==d)"t"in c&&(c=c.t,"a"===c?Ih(a):"r"===c?(a.f("Got a reset on secondary, closing it"),a.D.close(),a.hd!==a.D&&a.cd!==a.D||a.close()):"o"===c&&(a.f("got pong on secondary."),
5865a.Mf--,Ih(a)));else if("d"==d)a.Md.push(c);else throw Error("Unknown protocol layer: "+d);else a.f("message on old connection")}}yh.prototype.Fa=function(a){Jh(this,{t:"d",d:a})};function Eh(a){a.hd===a.D&&a.cd===a.D&&(a.f("cleaning up and promoting a connection: "+a.D.re),a.J=a.D,a.D=null)}
5866function Ih(a){0>=a.Mf?(a.f("Secondary connection is healthy."),a.Ab=!0,a.D.Ed(),a.D.start(),a.f("sending client ack on secondary"),a.D.send({t:"c",d:{t:"a",d:{}}}),a.f("Ending transmission on primary"),a.J.send({t:"c",d:{t:"n",d:{}}}),a.hd=a.D,Eh(a)):(a.f("sending ping on secondary."),a.D.send({t:"c",d:{t:"p",d:{}}}))}yh.prototype.Id=function(a){Gh(this);this.jc(a)};function Gh(a){a.Ab||(a.Re--,0>=a.Re&&(a.f("Primary connection is healthy."),a.Ab=!0,a.J.Ed()))}
5867function Dh(a,b){a.D=new b("c:"+a.id+":"+a.ff++,a.F,a.Nf);a.Mf=b.responsesRequiredToBeHealthy||0;a.D.open(Ah(a,a.D),Bh(a,a.D));setTimeout(function(){a.D&&(a.f("Timed out trying to upgrade."),a.D.close())},Math.floor(6E4))}function Ch(a,b,c){a.f("Realtime connection established.");a.J=b;a.Ta=1;a.Wc&&(a.Wc(c,a.Nf),a.Wc=null);0===a.Re?(a.f("Primary connection is healthy."),a.Ab=!0):setTimeout(function(){Hh(a)},Math.floor(5E3))}
5868function Hh(a){a.Ab||1!==a.Ta||(a.f("sending ping on primary."),Jh(a,{t:"c",d:{t:"p",d:{}}}))}function Jh(a,b){if(1!==a.Ta)throw"Connection is not connected";a.hd.send(b)}yh.prototype.close=function(){2!==this.Ta&&(this.f("Closing realtime connection."),this.Ta=2,Fh(this),this.la&&(this.la(),this.la=null))};function Fh(a){a.f("Shutting down all connections");a.J&&(a.J.close(),a.J=null);a.D&&(a.D.close(),a.D=null);a.yd&&(clearTimeout(a.yd),a.yd=null)};function Kh(a,b,c,d){this.id=Lh++;this.f=Mc("p:"+this.id+":");this.xf=this.Ee=!1;this.$={};this.qa=[];this.Yc=0;this.Vc=[];this.oa=!1;this.Za=1E3;this.Fd=3E5;this.Gb=b;this.Uc=c;this.Oe=d;this.F=a;this.sb=this.Aa=this.Ia=this.Bb=this.We=null;this.Ob=!1;this.Td={};this.Lg=0;this.nf=!0;this.Lc=this.Ge=null;Mh(this,0);He.ub().Eb("visible",this.Cg,this);-1===a.host.indexOf("fblocal")&&Ge.ub().Eb("online",this.Ag,this)}var Lh=0,Nh=0;g=Kh.prototype;
5869g.Fa=function(a,b,c){var d=++this.Lg;a={r:d,a:a,b:b};this.f(B(a));K(this.oa,"sendRequest call when we're not connected not allowed.");this.Ia.Fa(a);c&&(this.Td[d]=c)};g.yf=function(a,b,c,d){var e=a.va(),f=a.path.toString();this.f("Listen called for "+f+" "+e);this.$[f]=this.$[f]||{};K(fe(a.n)||!S(a.n),"listen() called for non-default but complete query");K(!this.$[f][e],"listen() called twice for same path/queryId.");a={H:d,xd:b,Ig:a,tag:c};this.$[f][e]=a;this.oa&&Oh(this,a)};
5870function Oh(a,b){var c=b.Ig,d=c.path.toString(),e=c.va();a.f("Listen on "+d+" for "+e);var f={p:d};b.tag&&(f.q=ee(c.n),f.t=b.tag);f.h=b.xd();a.Fa("q",f,function(f){var k=f.d,l=f.s;if(k&&"object"===typeof k&&v(k,"w")){var m=w(k,"w");ea(m)&&0<=Na(m,"no_index")&&O("Using an unspecified index. Consider adding "+('".indexOn": "'+c.n.g.toString()+'"')+" at "+c.path.toString()+" to your security rules for better performance")}(a.$[d]&&a.$[d][e])===b&&(a.f("listen response",f),"ok"!==l&&Ph(a,d,e),b.H&&b.H(l,
5871k))})}g.M=function(a,b,c){this.Aa={ig:a,of:!1,zc:b,md:c};this.f("Authenticating using credential: "+a);Qh(this);(b=40==a.length)||(a=$c(a).Bc,b="object"===typeof a&&!0===w(a,"admin"));b&&(this.f("Admin auth credential detected. Reducing max reconnect time."),this.Fd=3E4)};g.ge=function(a){delete this.Aa;this.oa&&this.Fa("unauth",{},function(b){a(b.s,b.d)})};
5872function Qh(a){var b=a.Aa;a.oa&&b&&a.Fa("auth",{cred:b.ig},function(c){var d=c.s;c=c.d||"error";"ok"!==d&&a.Aa===b&&delete a.Aa;b.of?"ok"!==d&&b.md&&b.md(d,c):(b.of=!0,b.zc&&b.zc(d,c))})}g.Rf=function(a,b){var c=a.path.toString(),d=a.va();this.f("Unlisten called for "+c+" "+d);K(fe(a.n)||!S(a.n),"unlisten() called for non-default but complete query");if(Ph(this,c,d)&&this.oa){var e=ee(a.n);this.f("Unlisten on "+c+" for "+d);c={p:c};b&&(c.q=e,c.t=b);this.Fa("n",c)}};
5873g.Me=function(a,b,c){this.oa?Rh(this,"o",a,b,c):this.Vc.push({$c:a,action:"o",data:b,H:c})};g.Cf=function(a,b,c){this.oa?Rh(this,"om",a,b,c):this.Vc.push({$c:a,action:"om",data:b,H:c})};g.Jd=function(a,b){this.oa?Rh(this,"oc",a,null,b):this.Vc.push({$c:a,action:"oc",data:null,H:b})};function Rh(a,b,c,d,e){c={p:c,d:d};a.f("onDisconnect "+b,c);a.Fa(b,c,function(a){e&&setTimeout(function(){e(a.s,a.d)},Math.floor(0))})}g.put=function(a,b,c,d){Sh(this,"p",a,b,c,d)};
5874g.zf=function(a,b,c,d){Sh(this,"m",a,b,c,d)};function Sh(a,b,c,d,e,f){d={p:c,d:d};n(f)&&(d.h=f);a.qa.push({action:b,Jf:d,H:e});a.Yc++;b=a.qa.length-1;a.oa?Th(a,b):a.f("Buffering put: "+c)}function Th(a,b){var c=a.qa[b].action,d=a.qa[b].Jf,e=a.qa[b].H;a.qa[b].Jg=a.oa;a.Fa(c,d,function(d){a.f(c+" response",d);delete a.qa[b];a.Yc--;0===a.Yc&&(a.qa=[]);e&&e(d.s,d.d)})}
5875g.Ue=function(a){this.oa&&(a={c:a},this.f("reportStats",a),this.Fa("s",a,function(a){"ok"!==a.s&&this.f("reportStats","Error sending stats: "+a.d)}))};
5876g.Id=function(a){if("r"in a){this.f("from server: "+B(a));var b=a.r,c=this.Td[b];c&&(delete this.Td[b],c(a.b))}else{if("error"in a)throw"A server-side error has occurred: "+a.error;"a"in a&&(b=a.a,c=a.b,this.f("handleServerMessage",b,c),"d"===b?this.Gb(c.p,c.d,!1,c.t):"m"===b?this.Gb(c.p,c.d,!0,c.t):"c"===b?Uh(this,c.p,c.q):"ac"===b?(a=c.s,b=c.d,c=this.Aa,delete this.Aa,c&&c.md&&c.md(a,b)):"sd"===b?this.We?this.We(c):"msg"in c&&"undefined"!==typeof console&&console.log("FIREBASE: "+c.msg.replace("\n",
5877"\nFIREBASE: ")):Nc("Unrecognized action received from server: "+B(b)+"\nAre you using the latest client?"))}};g.Wc=function(a,b){this.f("connection ready");this.oa=!0;this.Lc=(new Date).getTime();this.Oe({serverTimeOffset:a-(new Date).getTime()});this.Bb=b;if(this.nf){var c={};c["sdk.js."+hb.replace(/\./g,"-")]=1;yg()&&(c["framework.cordova"]=1);this.Ue(c)}Vh(this);this.nf=!1;this.Uc(!0)};
5878function Mh(a,b){K(!a.Ia,"Scheduling a connect when we're already connected/ing?");a.sb&&clearTimeout(a.sb);a.sb=setTimeout(function(){a.sb=null;Wh(a)},Math.floor(b))}g.Cg=function(a){a&&!this.Ob&&this.Za===this.Fd&&(this.f("Window became visible. Reducing delay."),this.Za=1E3,this.Ia||Mh(this,0));this.Ob=a};g.Ag=function(a){a?(this.f("Browser went online."),this.Za=1E3,this.Ia||Mh(this,0)):(this.f("Browser went offline. Killing connection."),this.Ia&&this.Ia.close())};
5879g.Df=function(){this.f("data client disconnected");this.oa=!1;this.Ia=null;for(var a=0;a<this.qa.length;a++){var b=this.qa[a];b&&"h"in b.Jf&&b.Jg&&(b.H&&b.H("disconnect"),delete this.qa[a],this.Yc--)}0===this.Yc&&(this.qa=[]);this.Td={};Xh(this)&&(this.Ob?this.Lc&&(3E4<(new Date).getTime()-this.Lc&&(this.Za=1E3),this.Lc=null):(this.f("Window isn't visible. Delaying reconnect."),this.Za=this.Fd,this.Ge=(new Date).getTime()),a=Math.max(0,this.Za-((new Date).getTime()-this.Ge)),a*=Math.random(),this.f("Trying to reconnect in "+
5880a+"ms"),Mh(this,a),this.Za=Math.min(this.Fd,1.3*this.Za));this.Uc(!1)};function Wh(a){if(Xh(a)){a.f("Making a connection attempt");a.Ge=(new Date).getTime();a.Lc=null;var b=q(a.Id,a),c=q(a.Wc,a),d=q(a.Df,a),e=a.id+":"+Nh++;a.Ia=new yh(e,a.F,b,c,d,function(b){O(b+" ("+a.F.toString()+")");a.xf=!0},a.Bb)}}g.yb=function(){this.Ee=!0;this.Ia?this.Ia.close():(this.sb&&(clearTimeout(this.sb),this.sb=null),this.oa&&this.Df())};g.rc=function(){this.Ee=!1;this.Za=1E3;this.Ia||Mh(this,0)};
5881function Uh(a,b,c){c=c?Qa(c,function(a){return Uc(a)}).join("$"):"default";(a=Ph(a,b,c))&&a.H&&a.H("permission_denied")}function Ph(a,b,c){b=(new L(b)).toString();var d;n(a.$[b])?(d=a.$[b][c],delete a.$[b][c],0===pa(a.$[b])&&delete a.$[b]):d=void 0;return d}function Vh(a){Qh(a);r(a.$,function(b){r(b,function(b){Oh(a,b)})});for(var b=0;b<a.qa.length;b++)a.qa[b]&&Th(a,b);for(;a.Vc.length;)b=a.Vc.shift(),Rh(a,b.action,b.$c,b.data,b.H)}function Xh(a){var b;b=Ge.ub().kc;return!a.xf&&!a.Ee&&b};var V={og:function(){ih=rh=!0}};V.forceLongPolling=V.og;V.pg=function(){jh=!0};V.forceWebSockets=V.pg;V.Pg=function(a,b){a.k.Ra.We=b};V.setSecurityDebugCallback=V.Pg;V.Ye=function(a,b){a.k.Ye(b)};V.stats=V.Ye;V.Ze=function(a,b){a.k.Ze(b)};V.statsIncrementCounter=V.Ze;V.sd=function(a){return a.k.sd};V.dataUpdateCount=V.sd;V.sg=function(a,b){a.k.De=b};V.interceptServerData=V.sg;V.yg=function(a){new Ig(a)};V.onPopupOpen=V.yg;V.Ng=function(a){sg=a};V.setAuthenticationServer=V.Ng;function Q(a,b,c){this.A=a;this.W=b;this.g=c}Q.prototype.I=function(){x("Firebase.DataSnapshot.val",0,0,arguments.length);return this.A.I()};Q.prototype.val=Q.prototype.I;Q.prototype.mf=function(){x("Firebase.DataSnapshot.exportVal",0,0,arguments.length);return this.A.I(!0)};Q.prototype.exportVal=Q.prototype.mf;Q.prototype.ng=function(){x("Firebase.DataSnapshot.exists",0,0,arguments.length);return!this.A.e()};Q.prototype.exists=Q.prototype.ng;
5882Q.prototype.u=function(a){x("Firebase.DataSnapshot.child",0,1,arguments.length);ga(a)&&(a=String(a));ig("Firebase.DataSnapshot.child",a);var b=new L(a),c=this.W.u(b);return new Q(this.A.Q(b),c,N)};Q.prototype.child=Q.prototype.u;Q.prototype.Da=function(a){x("Firebase.DataSnapshot.hasChild",1,1,arguments.length);ig("Firebase.DataSnapshot.hasChild",a);var b=new L(a);return!this.A.Q(b).e()};Q.prototype.hasChild=Q.prototype.Da;
5883Q.prototype.C=function(){x("Firebase.DataSnapshot.getPriority",0,0,arguments.length);return this.A.C().I()};Q.prototype.getPriority=Q.prototype.C;Q.prototype.forEach=function(a){x("Firebase.DataSnapshot.forEach",1,1,arguments.length);A("Firebase.DataSnapshot.forEach",1,a,!1);if(this.A.K())return!1;var b=this;return!!this.A.P(this.g,function(c,d){return a(new Q(d,b.W.u(c),N))})};Q.prototype.forEach=Q.prototype.forEach;
5884Q.prototype.wd=function(){x("Firebase.DataSnapshot.hasChildren",0,0,arguments.length);return this.A.K()?!1:!this.A.e()};Q.prototype.hasChildren=Q.prototype.wd;Q.prototype.name=function(){O("Firebase.DataSnapshot.name() being deprecated. Please use Firebase.DataSnapshot.key() instead.");x("Firebase.DataSnapshot.name",0,0,arguments.length);return this.key()};Q.prototype.name=Q.prototype.name;Q.prototype.key=function(){x("Firebase.DataSnapshot.key",0,0,arguments.length);return this.W.key()};
5885Q.prototype.key=Q.prototype.key;Q.prototype.Db=function(){x("Firebase.DataSnapshot.numChildren",0,0,arguments.length);return this.A.Db()};Q.prototype.numChildren=Q.prototype.Db;Q.prototype.Ib=function(){x("Firebase.DataSnapshot.ref",0,0,arguments.length);return this.W};Q.prototype.ref=Q.prototype.Ib;function Yh(a,b){this.F=a;this.Ua=Rb(a);this.fd=null;this.da=new vb;this.Hd=1;this.Ra=null;b||0<=("object"===typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)?(this.ba=new Ae(this.F,q(this.Gb,this)),setTimeout(q(this.Uc,this,!0),0)):this.ba=this.Ra=new Kh(this.F,q(this.Gb,this),q(this.Uc,this),q(this.Oe,this));this.Sg=Sb(a,q(function(){return new Mb(this.Ua,this.ba)},this));this.uc=new Rf;
5886this.Ce=new ob;var c=this;this.Cd=new vf({Xe:function(a,b,f,h){b=[];f=c.Ce.j(a.path);f.e()||(b=xf(c.Cd,new Xb(bf,a.path,f)),setTimeout(function(){h("ok")},0));return b},ae:ba});Zh(this,"connected",!1);this.la=new qc;this.M=new Sg(a,q(this.ba.M,this.ba),q(this.ba.ge,this.ba),q(this.Le,this));this.sd=0;this.De=null;this.L=new vf({Xe:function(a,b,f,h){c.ba.yf(a,f,b,function(b,e){var f=h(b,e);Ab(c.da,a.path,f)});return[]},ae:function(a,b){c.ba.Rf(a,b)}})}g=Yh.prototype;
5887g.toString=function(){return(this.F.kb?"https://":"http://")+this.F.host};g.name=function(){return this.F.hc};function $h(a){a=a.Ce.j(new L(".info/serverTimeOffset")).I()||0;return(new Date).getTime()+a}function ai(a){a=a={timestamp:$h(a)};a.timestamp=a.timestamp||(new Date).getTime();return a}
5888g.Gb=function(a,b,c,d){this.sd++;var e=new L(a);b=this.De?this.De(a,b):b;a=[];d?c?(b=na(b,function(a){return M(a)}),a=Ff(this.L,e,b,d)):(b=M(b),a=Bf(this.L,e,b,d)):c?(d=na(b,function(a){return M(a)}),a=Af(this.L,e,d)):(d=M(b),a=xf(this.L,new Xb(bf,e,d)));d=e;0<a.length&&(d=bi(this,e));Ab(this.da,d,a)};g.Uc=function(a){Zh(this,"connected",a);!1===a&&ci(this)};g.Oe=function(a){var b=this;Wc(a,function(a,d){Zh(b,d,a)})};g.Le=function(a){Zh(this,"authenticated",a)};
5889function Zh(a,b,c){b=new L("/.info/"+b);c=M(c);var d=a.Ce;d.Wd=d.Wd.G(b,c);c=xf(a.Cd,new Xb(bf,b,c));Ab(a.da,b,c)}g.Kb=function(a,b,c,d){this.f("set",{path:a.toString(),value:b,$g:c});var e=ai(this);b=M(b,c);var e=sc(b,e),f=this.Hd++,e=wf(this.L,a,e,f,!0);wb(this.da,e);var h=this;this.ba.put(a.toString(),b.I(!0),function(b,c){var e="ok"===b;e||O("set at "+a+" failed: "+b);e=zf(h.L,f,!e);Ab(h.da,a,e);di(d,b,c)});e=ei(this,a);bi(this,e);Ab(this.da,e,[])};
5890g.update=function(a,b,c){this.f("update",{path:a.toString(),value:b});var d=!0,e=ai(this),f={};r(b,function(a,b){d=!1;var c=M(a);f[b]=sc(c,e)});if(d)Cb("update() called with empty data. Don't do anything."),di(c,"ok");else{var h=this.Hd++,k=yf(this.L,a,f,h);wb(this.da,k);var l=this;this.ba.zf(a.toString(),b,function(b,d){var e="ok"===b;e||O("update at "+a+" failed: "+b);var e=zf(l.L,h,!e),f=a;0<e.length&&(f=bi(l,a));Ab(l.da,f,e);di(c,b,d)});b=ei(this,a);bi(this,b);Ab(this.da,a,[])}};
5891function ci(a){a.f("onDisconnectEvents");var b=ai(a),c=[];rc(pc(a.la,b),G,function(b,e){c=c.concat(xf(a.L,new Xb(bf,b,e)));var f=ei(a,b);bi(a,f)});a.la=new qc;Ab(a.da,G,c)}g.Jd=function(a,b){var c=this;this.ba.Jd(a.toString(),function(d,e){"ok"===d&&rg(c.la,a);di(b,d,e)})};function fi(a,b,c,d){var e=M(c);a.ba.Me(b.toString(),e.I(!0),function(c,h){"ok"===c&&a.la.nc(b,e);di(d,c,h)})}function gi(a,b,c,d,e){var f=M(c,d);a.ba.Me(b.toString(),f.I(!0),function(c,d){"ok"===c&&a.la.nc(b,f);di(e,c,d)})}
5892function hi(a,b,c,d){var e=!0,f;for(f in c)e=!1;e?(Cb("onDisconnect().update() called with empty data. Don't do anything."),di(d,"ok")):a.ba.Cf(b.toString(),c,function(e,f){if("ok"===e)for(var l in c){var m=M(c[l]);a.la.nc(b.u(l),m)}di(d,e,f)})}function ii(a,b,c){c=".info"===E(b.path)?a.Cd.Pb(b,c):a.L.Pb(b,c);yb(a.da,b.path,c)}g.yb=function(){this.Ra&&this.Ra.yb()};g.rc=function(){this.Ra&&this.Ra.rc()};
5893g.Ye=function(a){if("undefined"!==typeof console){a?(this.fd||(this.fd=new Lb(this.Ua)),a=this.fd.get()):a=this.Ua.get();var b=Ra(sa(a),function(a,b){return Math.max(b.length,a)},0),c;for(c in a){for(var d=a[c],e=c.length;e<b+2;e++)c+=" ";console.log(c+d)}}};g.Ze=function(a){Ob(this.Ua,a);this.Sg.Of[a]=!0};g.f=function(a){var b="";this.Ra&&(b=this.Ra.id+":");Cb(b,arguments)};
5894function di(a,b,c){a&&Db(function(){if("ok"==b)a(null);else{var d=(b||"error").toUpperCase(),e=d;c&&(e+=": "+c);e=Error(e);e.code=d;a(e)}})};function ji(a,b,c,d,e){function f(){}a.f("transaction on "+b);var h=new U(a,b);h.Eb("value",f);c={path:b,update:c,H:d,status:null,Ff:Ec(),cf:e,Lf:0,ie:function(){h.ic("value",f)},ke:null,Ba:null,pd:null,qd:null,rd:null};d=a.L.za(b,void 0)||C;c.pd=d;d=c.update(d.I());if(n(d)){cg("transaction failed: Data returned ",d,c.path);c.status=1;e=Sf(a.uc,b);var k=e.Ca()||[];k.push(c);Tf(e,k);"object"===typeof d&&null!==d&&v(d,".priority")?(k=w(d,".priority"),K(ag(k),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.")):
5895k=(a.L.za(b)||C).C().I();e=ai(a);d=M(d,k);e=sc(d,e);c.qd=d;c.rd=e;c.Ba=a.Hd++;c=wf(a.L,b,e,c.Ba,c.cf);Ab(a.da,b,c);ki(a)}else c.ie(),c.qd=null,c.rd=null,c.H&&(a=new Q(c.pd,new U(a,c.path),N),c.H(null,!1,a))}function ki(a,b){var c=b||a.uc;b||li(a,c);if(null!==c.Ca()){var d=mi(a,c);K(0<d.length,"Sending zero length transaction queue");Sa(d,function(a){return 1===a.status})&&ni(a,c.path(),d)}else c.wd()&&c.P(function(b){ki(a,b)})}
5896function ni(a,b,c){for(var d=Qa(c,function(a){return a.Ba}),e=a.L.za(b,d)||C,d=e,e=e.hash(),f=0;f<c.length;f++){var h=c[f];K(1===h.status,"tryToSendTransactionQueue_: items in queue should all be run.");h.status=2;h.Lf++;var k=T(b,h.path),d=d.G(k,h.qd)}d=d.I(!0);a.ba.put(b.toString(),d,function(d){a.f("transaction put response",{path:b.toString(),status:d});var e=[];if("ok"===d){d=[];for(f=0;f<c.length;f++){c[f].status=3;e=e.concat(zf(a.L,c[f].Ba));if(c[f].H){var h=c[f].rd,k=new U(a,c[f].path);d.push(q(c[f].H,
5897null,null,!0,new Q(h,k,N)))}c[f].ie()}li(a,Sf(a.uc,b));ki(a);Ab(a.da,b,e);for(f=0;f<d.length;f++)Db(d[f])}else{if("datastale"===d)for(f=0;f<c.length;f++)c[f].status=4===c[f].status?5:1;else for(O("transaction at "+b.toString()+" failed: "+d),f=0;f<c.length;f++)c[f].status=5,c[f].ke=d;bi(a,b)}},e)}function bi(a,b){var c=oi(a,b),d=c.path(),c=mi(a,c);pi(a,c,d);return d}
5898function pi(a,b,c){if(0!==b.length){for(var d=[],e=[],f=Qa(b,function(a){return a.Ba}),h=0;h<b.length;h++){var k=b[h],l=T(c,k.path),m=!1,t;K(null!==l,"rerunTransactionsUnderNode_: relativePath should not be null.");if(5===k.status)m=!0,t=k.ke,e=e.concat(zf(a.L,k.Ba,!0));else if(1===k.status)if(25<=k.Lf)m=!0,t="maxretry",e=e.concat(zf(a.L,k.Ba,!0));else{var z=a.L.za(k.path,f)||C;k.pd=z;var I=b[h].update(z.I());n(I)?(cg("transaction failed: Data returned ",I,k.path),l=M(I),"object"===typeof I&&null!=
5899I&&v(I,".priority")||(l=l.ga(z.C())),z=k.Ba,I=ai(a),I=sc(l,I),k.qd=l,k.rd=I,k.Ba=a.Hd++,Va(f,z),e=e.concat(wf(a.L,k.path,I,k.Ba,k.cf)),e=e.concat(zf(a.L,z,!0))):(m=!0,t="nodata",e=e.concat(zf(a.L,k.Ba,!0)))}Ab(a.da,c,e);e=[];m&&(b[h].status=3,setTimeout(b[h].ie,Math.floor(0)),b[h].H&&("nodata"===t?(k=new U(a,b[h].path),d.push(q(b[h].H,null,null,!1,new Q(b[h].pd,k,N)))):d.push(q(b[h].H,null,Error(t),!1,null))))}li(a,a.uc);for(h=0;h<d.length;h++)Db(d[h]);ki(a)}}
5900function oi(a,b){for(var c,d=a.uc;null!==(c=E(b))&&null===d.Ca();)d=Sf(d,c),b=H(b);return d}function mi(a,b){var c=[];qi(a,b,c);c.sort(function(a,b){return a.Ff-b.Ff});return c}function qi(a,b,c){var d=b.Ca();if(null!==d)for(var e=0;e<d.length;e++)c.push(d[e]);b.P(function(b){qi(a,b,c)})}function li(a,b){var c=b.Ca();if(c){for(var d=0,e=0;e<c.length;e++)3!==c[e].status&&(c[d]=c[e],d++);c.length=d;Tf(b,0<c.length?c:null)}b.P(function(b){li(a,b)})}
5901function ei(a,b){var c=oi(a,b).path(),d=Sf(a.uc,b);Wf(d,function(b){ri(a,b)});ri(a,d);Vf(d,function(b){ri(a,b)});return c}
5902function ri(a,b){var c=b.Ca();if(null!==c){for(var d=[],e=[],f=-1,h=0;h<c.length;h++)4!==c[h].status&&(2===c[h].status?(K(f===h-1,"All SENT items should be at beginning of queue."),f=h,c[h].status=4,c[h].ke="set"):(K(1===c[h].status,"Unexpected transaction status in abort"),c[h].ie(),e=e.concat(zf(a.L,c[h].Ba,!0)),c[h].H&&d.push(q(c[h].H,null,Error("set"),!1,null))));-1===f?Tf(b,null):c.length=f+1;Ab(a.da,b.path(),e);for(h=0;h<d.length;h++)Db(d[h])}};function W(){this.oc={};this.Sf=!1}W.prototype.yb=function(){for(var a in this.oc)this.oc[a].yb()};W.prototype.rc=function(){for(var a in this.oc)this.oc[a].rc()};W.prototype.ve=function(){this.Sf=!0};ca(W);W.prototype.interrupt=W.prototype.yb;W.prototype.resume=W.prototype.rc;function X(a,b){this.bd=a;this.ra=b}X.prototype.cancel=function(a){x("Firebase.onDisconnect().cancel",0,1,arguments.length);A("Firebase.onDisconnect().cancel",1,a,!0);this.bd.Jd(this.ra,a||null)};X.prototype.cancel=X.prototype.cancel;X.prototype.remove=function(a){x("Firebase.onDisconnect().remove",0,1,arguments.length);jg("Firebase.onDisconnect().remove",this.ra);A("Firebase.onDisconnect().remove",1,a,!0);fi(this.bd,this.ra,null,a)};X.prototype.remove=X.prototype.remove;
5903X.prototype.set=function(a,b){x("Firebase.onDisconnect().set",1,2,arguments.length);jg("Firebase.onDisconnect().set",this.ra);bg("Firebase.onDisconnect().set",a,this.ra,!1);A("Firebase.onDisconnect().set",2,b,!0);fi(this.bd,this.ra,a,b)};X.prototype.set=X.prototype.set;
5904X.prototype.Kb=function(a,b,c){x("Firebase.onDisconnect().setWithPriority",2,3,arguments.length);jg("Firebase.onDisconnect().setWithPriority",this.ra);bg("Firebase.onDisconnect().setWithPriority",a,this.ra,!1);fg("Firebase.onDisconnect().setWithPriority",2,b);A("Firebase.onDisconnect().setWithPriority",3,c,!0);gi(this.bd,this.ra,a,b,c)};X.prototype.setWithPriority=X.prototype.Kb;
5905X.prototype.update=function(a,b){x("Firebase.onDisconnect().update",1,2,arguments.length);jg("Firebase.onDisconnect().update",this.ra);if(ea(a)){for(var c={},d=0;d<a.length;++d)c[""+d]=a[d];a=c;O("Passing an Array to Firebase.onDisconnect().update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}eg("Firebase.onDisconnect().update",a,this.ra);A("Firebase.onDisconnect().update",2,b,!0);
5906hi(this.bd,this.ra,a,b)};X.prototype.update=X.prototype.update;function Y(a,b,c,d){this.k=a;this.path=b;this.n=c;this.lc=d}
5907function si(a){var b=null,c=null;a.ma&&(b=nd(a));a.pa&&(c=pd(a));if(a.g===Qd){if(a.ma){if("[MIN_NAME]"!=md(a))throw Error("Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().");if("string"!==typeof b)throw Error("Query: When ordering by key, the argument passed to startAt(), endAt(),or equalTo() must be a string.");}if(a.pa){if("[MAX_NAME]"!=od(a))throw Error("Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().");if("string"!==
5908typeof c)throw Error("Query: When ordering by key, the argument passed to startAt(), endAt(),or equalTo() must be a string.");}}else if(a.g===N){if(null!=b&&!ag(b)||null!=c&&!ag(c))throw Error("Query: When ordering by priority, the first argument passed to startAt(), endAt(), or equalTo() must be a valid priority value (null, a number, or a string).");}else if(K(a.g instanceof Ud||a.g===$d,"unknown index type."),null!=b&&"object"===typeof b||null!=c&&"object"===typeof c)throw Error("Query: First argument passed to startAt(), endAt(), or equalTo() cannot be an object.");
5909}function ti(a){if(a.ma&&a.pa&&a.ja&&(!a.ja||""===a.Nb))throw Error("Query: Can't combine startAt(), endAt(), and limit(). Use limitToFirst() or limitToLast() instead.");}function ui(a,b){if(!0===a.lc)throw Error(b+": You can't combine multiple orderBy calls.");}g=Y.prototype;g.Ib=function(){x("Query.ref",0,0,arguments.length);return new U(this.k,this.path)};
5910g.Eb=function(a,b,c,d){x("Query.on",2,4,arguments.length);gg("Query.on",a,!1);A("Query.on",2,b,!1);var e=vi("Query.on",c,d);if("value"===a)ii(this.k,this,new id(b,e.cancel||null,e.Ma||null));else{var f={};f[a]=b;ii(this.k,this,new jd(f,e.cancel,e.Ma))}return b};
5911g.ic=function(a,b,c){x("Query.off",0,3,arguments.length);gg("Query.off",a,!0);A("Query.off",2,b,!0);mb("Query.off",3,c);var d=null,e=null;"value"===a?d=new id(b||null,null,c||null):a&&(b&&(e={},e[a]=b),d=new jd(e,null,c||null));e=this.k;d=".info"===E(this.path)?e.Cd.jb(this,d):e.L.jb(this,d);yb(e.da,this.path,d)};
5912g.Dg=function(a,b){function c(h){f&&(f=!1,e.ic(a,c),b.call(d.Ma,h))}x("Query.once",2,4,arguments.length);gg("Query.once",a,!1);A("Query.once",2,b,!1);var d=vi("Query.once",arguments[2],arguments[3]),e=this,f=!0;this.Eb(a,c,function(b){e.ic(a,c);d.cancel&&d.cancel.call(d.Ma,b)})};
5913g.He=function(a){O("Query.limit() being deprecated. Please use Query.limitToFirst() or Query.limitToLast() instead.");x("Query.limit",1,1,arguments.length);if(!ga(a)||Math.floor(a)!==a||0>=a)throw Error("Query.limit: First argument must be a positive integer.");if(this.n.ja)throw Error("Query.limit: Limit was already set (by another call to limit, limitToFirst, orlimitToLast.");var b=this.n.He(a);ti(b);return new Y(this.k,this.path,b,this.lc)};
5914g.Ie=function(a){x("Query.limitToFirst",1,1,arguments.length);if(!ga(a)||Math.floor(a)!==a||0>=a)throw Error("Query.limitToFirst: First argument must be a positive integer.");if(this.n.ja)throw Error("Query.limitToFirst: Limit was already set (by another call to limit, limitToFirst, or limitToLast).");return new Y(this.k,this.path,this.n.Ie(a),this.lc)};
5915g.Je=function(a){x("Query.limitToLast",1,1,arguments.length);if(!ga(a)||Math.floor(a)!==a||0>=a)throw Error("Query.limitToLast: First argument must be a positive integer.");if(this.n.ja)throw Error("Query.limitToLast: Limit was already set (by another call to limit, limitToFirst, or limitToLast).");return new Y(this.k,this.path,this.n.Je(a),this.lc)};
5916g.Eg=function(a){x("Query.orderByChild",1,1,arguments.length);if("$key"===a)throw Error('Query.orderByChild: "$key" is invalid. Use Query.orderByKey() instead.');if("$priority"===a)throw Error('Query.orderByChild: "$priority" is invalid. Use Query.orderByPriority() instead.');if("$value"===a)throw Error('Query.orderByChild: "$value" is invalid. Use Query.orderByValue() instead.');ig("Query.orderByChild",a);ui(this,"Query.orderByChild");var b=new L(a);if(b.e())throw Error("Query.orderByChild: cannot pass in empty path. Use Query.orderByValue() instead.");
5917b=new Ud(b);b=de(this.n,b);si(b);return new Y(this.k,this.path,b,!0)};g.Fg=function(){x("Query.orderByKey",0,0,arguments.length);ui(this,"Query.orderByKey");var a=de(this.n,Qd);si(a);return new Y(this.k,this.path,a,!0)};g.Gg=function(){x("Query.orderByPriority",0,0,arguments.length);ui(this,"Query.orderByPriority");var a=de(this.n,N);si(a);return new Y(this.k,this.path,a,!0)};
5918g.Hg=function(){x("Query.orderByValue",0,0,arguments.length);ui(this,"Query.orderByValue");var a=de(this.n,$d);si(a);return new Y(this.k,this.path,a,!0)};g.$d=function(a,b){x("Query.startAt",0,2,arguments.length);bg("Query.startAt",a,this.path,!0);hg("Query.startAt",b);var c=this.n.$d(a,b);ti(c);si(c);if(this.n.ma)throw Error("Query.startAt: Starting point was already set (by another call to startAt or equalTo).");n(a)||(b=a=null);return new Y(this.k,this.path,c,this.lc)};
5919g.td=function(a,b){x("Query.endAt",0,2,arguments.length);bg("Query.endAt",a,this.path,!0);hg("Query.endAt",b);var c=this.n.td(a,b);ti(c);si(c);if(this.n.pa)throw Error("Query.endAt: Ending point was already set (by another call to endAt or equalTo).");return new Y(this.k,this.path,c,this.lc)};
5920g.kg=function(a,b){x("Query.equalTo",1,2,arguments.length);bg("Query.equalTo",a,this.path,!1);hg("Query.equalTo",b);if(this.n.ma)throw Error("Query.equalTo: Starting point was already set (by another call to endAt or equalTo).");if(this.n.pa)throw Error("Query.equalTo: Ending point was already set (by another call to endAt or equalTo).");return this.$d(a,b).td(a,b)};
5921g.toString=function(){x("Query.toString",0,0,arguments.length);for(var a=this.path,b="",c=a.Z;c<a.o.length;c++)""!==a.o[c]&&(b+="/"+encodeURIComponent(String(a.o[c])));return this.k.toString()+(b||"/")};g.va=function(){var a=Uc(ee(this.n));return"{}"===a?"default":a};
5922function vi(a,b,c){var d={cancel:null,Ma:null};if(b&&c)d.cancel=b,A(a,3,d.cancel,!0),d.Ma=c,mb(a,4,d.Ma);else if(b)if("object"===typeof b&&null!==b)d.Ma=b;else if("function"===typeof b)d.cancel=b;else throw Error(y(a,3,!0)+" must either be a cancel callback or a context object.");return d}Y.prototype.ref=Y.prototype.Ib;Y.prototype.on=Y.prototype.Eb;Y.prototype.off=Y.prototype.ic;Y.prototype.once=Y.prototype.Dg;Y.prototype.limit=Y.prototype.He;Y.prototype.limitToFirst=Y.prototype.Ie;
5923Y.prototype.limitToLast=Y.prototype.Je;Y.prototype.orderByChild=Y.prototype.Eg;Y.prototype.orderByKey=Y.prototype.Fg;Y.prototype.orderByPriority=Y.prototype.Gg;Y.prototype.orderByValue=Y.prototype.Hg;Y.prototype.startAt=Y.prototype.$d;Y.prototype.endAt=Y.prototype.td;Y.prototype.equalTo=Y.prototype.kg;Y.prototype.toString=Y.prototype.toString;var Z={};Z.vc=Kh;Z.DataConnection=Z.vc;Kh.prototype.Rg=function(a,b){this.Fa("q",{p:a},b)};Z.vc.prototype.simpleListen=Z.vc.prototype.Rg;Kh.prototype.jg=function(a,b){this.Fa("echo",{d:a},b)};Z.vc.prototype.echo=Z.vc.prototype.jg;Kh.prototype.interrupt=Kh.prototype.yb;Z.Vf=yh;Z.RealTimeConnection=Z.Vf;yh.prototype.sendRequest=yh.prototype.Fa;yh.prototype.close=yh.prototype.close;
5924Z.rg=function(a){var b=Kh.prototype.put;Kh.prototype.put=function(c,d,e,f){n(f)&&(f=a());b.call(this,c,d,e,f)};return function(){Kh.prototype.put=b}};Z.hijackHash=Z.rg;Z.Uf=zc;Z.ConnectionTarget=Z.Uf;Z.va=function(a){return a.va()};Z.queryIdentifier=Z.va;Z.tg=function(a){return a.k.Ra.$};Z.listens=Z.tg;Z.ve=function(a){a.ve()};Z.forceRestClient=Z.ve;function U(a,b){var c,d,e;if(a instanceof Yh)c=a,d=b;else{x("new Firebase",1,2,arguments.length);d=Pc(arguments[0]);c=d.Tg;"firebase"===d.domain&&Oc(d.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead");c&&"undefined"!=c||Oc("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com");d.kb||"undefined"!==typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&O("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");
5925c=new zc(d.host,d.kb,c,"ws"===d.scheme||"wss"===d.scheme);d=new L(d.$c);e=d.toString();var f;!(f=!p(c.host)||0===c.host.length||!$f(c.hc))&&(f=0!==e.length)&&(e&&(e=e.replace(/^\/*\.info(\/|$)/,"/")),f=!(p(e)&&0!==e.length&&!Yf.test(e)));if(f)throw Error(y("new Firebase",1,!1)+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".');if(b)if(b instanceof W)e=b;else if(p(b))e=W.ub(),c.Od=b;else throw Error("Expected a valid Firebase.Context for second argument to new Firebase()");
5926else e=W.ub();f=c.toString();var h=w(e.oc,f);h||(h=new Yh(c,e.Sf),e.oc[f]=h);c=h}Y.call(this,c,d,be,!1)}ma(U,Y);var wi=U,xi=["Firebase"],yi=aa;xi[0]in yi||!yi.execScript||yi.execScript("var "+xi[0]);for(var zi;xi.length&&(zi=xi.shift());)!xi.length&&n(wi)?yi[zi]=wi:yi=yi[zi]?yi[zi]:yi[zi]={};U.goOffline=function(){x("Firebase.goOffline",0,0,arguments.length);W.ub().yb()};U.goOnline=function(){x("Firebase.goOnline",0,0,arguments.length);W.ub().rc()};
5927function Lc(a,b){K(!b||!0===a||!1===a,"Can't turn on custom loggers persistently.");!0===a?("undefined"!==typeof console&&("function"===typeof console.log?Bb=q(console.log,console):"object"===typeof console.log&&(Bb=function(a){console.log(a)})),b&&yc.set("logging_enabled",!0)):a?Bb=a:(Bb=null,yc.remove("logging_enabled"))}U.enableLogging=Lc;U.ServerValue={TIMESTAMP:{".sv":"timestamp"}};U.SDK_VERSION=hb;U.INTERNAL=V;U.Context=W;U.TEST_ACCESS=Z;
5928U.prototype.name=function(){O("Firebase.name() being deprecated. Please use Firebase.key() instead.");x("Firebase.name",0,0,arguments.length);return this.key()};U.prototype.name=U.prototype.name;U.prototype.key=function(){x("Firebase.key",0,0,arguments.length);return this.path.e()?null:Ld(this.path)};U.prototype.key=U.prototype.key;
5929U.prototype.u=function(a){x("Firebase.child",1,1,arguments.length);if(ga(a))a=String(a);else if(!(a instanceof L))if(null===E(this.path)){var b=a;b&&(b=b.replace(/^\/*\.info(\/|$)/,"/"));ig("Firebase.child",b)}else ig("Firebase.child",a);return new U(this.k,this.path.u(a))};U.prototype.child=U.prototype.u;U.prototype.parent=function(){x("Firebase.parent",0,0,arguments.length);var a=this.path.parent();return null===a?null:new U(this.k,a)};U.prototype.parent=U.prototype.parent;
5930U.prototype.root=function(){x("Firebase.ref",0,0,arguments.length);for(var a=this;null!==a.parent();)a=a.parent();return a};U.prototype.root=U.prototype.root;U.prototype.set=function(a,b){x("Firebase.set",1,2,arguments.length);jg("Firebase.set",this.path);bg("Firebase.set",a,this.path,!1);A("Firebase.set",2,b,!0);this.k.Kb(this.path,a,null,b||null)};U.prototype.set=U.prototype.set;
5931U.prototype.update=function(a,b){x("Firebase.update",1,2,arguments.length);jg("Firebase.update",this.path);if(ea(a)){for(var c={},d=0;d<a.length;++d)c[""+d]=a[d];a=c;O("Passing an Array to Firebase.update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}eg("Firebase.update",a,this.path);A("Firebase.update",2,b,!0);this.k.update(this.path,a,b||null)};U.prototype.update=U.prototype.update;
5932U.prototype.Kb=function(a,b,c){x("Firebase.setWithPriority",2,3,arguments.length);jg("Firebase.setWithPriority",this.path);bg("Firebase.setWithPriority",a,this.path,!1);fg("Firebase.setWithPriority",2,b);A("Firebase.setWithPriority",3,c,!0);if(".length"===this.key()||".keys"===this.key())throw"Firebase.setWithPriority failed: "+this.key()+" is a read-only object.";this.k.Kb(this.path,a,b,c||null)};U.prototype.setWithPriority=U.prototype.Kb;
5933U.prototype.remove=function(a){x("Firebase.remove",0,1,arguments.length);jg("Firebase.remove",this.path);A("Firebase.remove",1,a,!0);this.set(null,a)};U.prototype.remove=U.prototype.remove;
5934U.prototype.transaction=function(a,b,c){x("Firebase.transaction",1,3,arguments.length);jg("Firebase.transaction",this.path);A("Firebase.transaction",1,a,!1);A("Firebase.transaction",2,b,!0);if(n(c)&&"boolean"!=typeof c)throw Error(y("Firebase.transaction",3,!0)+"must be a boolean.");if(".length"===this.key()||".keys"===this.key())throw"Firebase.transaction failed: "+this.key()+" is a read-only object.";"undefined"===typeof c&&(c=!0);ji(this.k,this.path,a,b||null,c)};U.prototype.transaction=U.prototype.transaction;
5935U.prototype.Og=function(a,b){x("Firebase.setPriority",1,2,arguments.length);jg("Firebase.setPriority",this.path);fg("Firebase.setPriority",1,a);A("Firebase.setPriority",2,b,!0);this.k.Kb(this.path.u(".priority"),a,null,b)};U.prototype.setPriority=U.prototype.Og;
5936U.prototype.push=function(a,b){x("Firebase.push",0,2,arguments.length);jg("Firebase.push",this.path);bg("Firebase.push",a,this.path,!0);A("Firebase.push",2,b,!0);var c=$h(this.k),c=Fe(c),c=this.u(c);"undefined"!==typeof a&&null!==a&&c.set(a,b);return c};U.prototype.push=U.prototype.push;U.prototype.hb=function(){jg("Firebase.onDisconnect",this.path);return new X(this.k,this.path)};U.prototype.onDisconnect=U.prototype.hb;
5937U.prototype.M=function(a,b,c){O("FirebaseRef.auth() being deprecated. Please use FirebaseRef.authWithCustomToken() instead.");x("Firebase.auth",1,3,arguments.length);kg("Firebase.auth",a);A("Firebase.auth",2,b,!0);A("Firebase.auth",3,b,!0);Yg(this.k.M,a,{},{remember:"none"},b,c)};U.prototype.auth=U.prototype.M;U.prototype.ge=function(a){x("Firebase.unauth",0,1,arguments.length);A("Firebase.unauth",1,a,!0);Zg(this.k.M,a)};U.prototype.unauth=U.prototype.ge;
5938U.prototype.xe=function(){x("Firebase.getAuth",0,0,arguments.length);return this.k.M.xe()};U.prototype.getAuth=U.prototype.xe;U.prototype.xg=function(a,b){x("Firebase.onAuth",1,2,arguments.length);A("Firebase.onAuth",1,a,!1);mb("Firebase.onAuth",2,b);this.k.M.Eb("auth_status",a,b)};U.prototype.onAuth=U.prototype.xg;U.prototype.wg=function(a,b){x("Firebase.offAuth",1,2,arguments.length);A("Firebase.offAuth",1,a,!1);mb("Firebase.offAuth",2,b);this.k.M.ic("auth_status",a,b)};U.prototype.offAuth=U.prototype.wg;
5939U.prototype.Zf=function(a,b,c){x("Firebase.authWithCustomToken",2,3,arguments.length);kg("Firebase.authWithCustomToken",a);A("Firebase.authWithCustomToken",2,b,!1);ng("Firebase.authWithCustomToken",3,c,!0);Yg(this.k.M,a,{},c||{},b)};U.prototype.authWithCustomToken=U.prototype.Zf;U.prototype.$f=function(a,b,c){x("Firebase.authWithOAuthPopup",2,3,arguments.length);mg("Firebase.authWithOAuthPopup",a);A("Firebase.authWithOAuthPopup",2,b,!1);ng("Firebase.authWithOAuthPopup",3,c,!0);ch(this.k.M,a,c,b)};
5940U.prototype.authWithOAuthPopup=U.prototype.$f;U.prototype.ag=function(a,b,c){x("Firebase.authWithOAuthRedirect",2,3,arguments.length);mg("Firebase.authWithOAuthRedirect",a);A("Firebase.authWithOAuthRedirect",2,b,!1);ng("Firebase.authWithOAuthRedirect",3,c,!0);var d=this.k.M;ah(d);var e=[Kg],f=vg(c);"anonymous"===a||"firebase"===a?P(b,Mg("TRANSPORT_UNAVAILABLE")):(yc.set("redirect_client_options",f.od),bh(d,e,"/auth/"+a,f,b))};U.prototype.authWithOAuthRedirect=U.prototype.ag;
5941U.prototype.bg=function(a,b,c,d){x("Firebase.authWithOAuthToken",3,4,arguments.length);mg("Firebase.authWithOAuthToken",a);A("Firebase.authWithOAuthToken",3,c,!1);ng("Firebase.authWithOAuthToken",4,d,!0);p(b)?(lg("Firebase.authWithOAuthToken",2,b),$g(this.k.M,a+"/token",{access_token:b},d,c)):(ng("Firebase.authWithOAuthToken",2,b,!1),$g(this.k.M,a+"/token",b,d,c))};U.prototype.authWithOAuthToken=U.prototype.bg;
5942U.prototype.Yf=function(a,b){x("Firebase.authAnonymously",1,2,arguments.length);A("Firebase.authAnonymously",1,a,!1);ng("Firebase.authAnonymously",2,b,!0);$g(this.k.M,"anonymous",{},b,a)};U.prototype.authAnonymously=U.prototype.Yf;
5943U.prototype.cg=function(a,b,c){x("Firebase.authWithPassword",2,3,arguments.length);ng("Firebase.authWithPassword",1,a,!1);og("Firebase.authWithPassword",a,"email");og("Firebase.authWithPassword",a,"password");A("Firebase.authWithPassword",2,b,!1);ng("Firebase.authWithPassword",3,c,!0);$g(this.k.M,"password",a,c,b)};U.prototype.authWithPassword=U.prototype.cg;
5944U.prototype.se=function(a,b){x("Firebase.createUser",2,2,arguments.length);ng("Firebase.createUser",1,a,!1);og("Firebase.createUser",a,"email");og("Firebase.createUser",a,"password");A("Firebase.createUser",2,b,!1);this.k.M.se(a,b)};U.prototype.createUser=U.prototype.se;U.prototype.Te=function(a,b){x("Firebase.removeUser",2,2,arguments.length);ng("Firebase.removeUser",1,a,!1);og("Firebase.removeUser",a,"email");og("Firebase.removeUser",a,"password");A("Firebase.removeUser",2,b,!1);this.k.M.Te(a,b)};
5945U.prototype.removeUser=U.prototype.Te;U.prototype.pe=function(a,b){x("Firebase.changePassword",2,2,arguments.length);ng("Firebase.changePassword",1,a,!1);og("Firebase.changePassword",a,"email");og("Firebase.changePassword",a,"oldPassword");og("Firebase.changePassword",a,"newPassword");A("Firebase.changePassword",2,b,!1);this.k.M.pe(a,b)};U.prototype.changePassword=U.prototype.pe;
5946U.prototype.oe=function(a,b){x("Firebase.changeEmail",2,2,arguments.length);ng("Firebase.changeEmail",1,a,!1);og("Firebase.changeEmail",a,"oldEmail");og("Firebase.changeEmail",a,"newEmail");og("Firebase.changeEmail",a,"password");A("Firebase.changeEmail",2,b,!1);this.k.M.oe(a,b)};U.prototype.changeEmail=U.prototype.oe;
5947U.prototype.Ve=function(a,b){x("Firebase.resetPassword",2,2,arguments.length);ng("Firebase.resetPassword",1,a,!1);og("Firebase.resetPassword",a,"email");A("Firebase.resetPassword",2,b,!1);this.k.M.Ve(a,b)};U.prototype.resetPassword=U.prototype.Ve;})();
5948
5949
5950/* @flow */
5951/* global Elm, Firebase, F2, F3, F4 */
5952
5953Elm.Native.ElmFire = {};
5954Elm.Native.ElmFire.make = function (localRuntime) {
5955 "use strict";
5956
5957 localRuntime.Native = localRuntime.Native || {};
5958 localRuntime.Native.ElmFire = localRuntime.Native.ElmFire || {};
5959 if (localRuntime.Native.ElmFire.values) {
5960 return localRuntime.Native.ElmFire.values;
5961 }
5962
5963 var Utils = Elm.Native.Utils.make (localRuntime);
5964 var Task = Elm.Native.Task.make (localRuntime);
5965 var List = Elm.Native.List.make (localRuntime);
5966
5967 var pleaseReportThis = ' Should not happen, please report this as a bug in ElmFire!';
5968
5969 function asMaybe (value) {
5970 if (typeof value === 'undefined' || value === null) {
5971 return { ctor: 'Nothing' };
5972 } else {
5973 return { ctor: 'Just', _0: value };
5974 }
5975 }
5976
5977 function fromMaybe (maybe) {
5978 return maybe.ctor === 'Nothing' ? null : maybe._0;
5979 }
5980
5981 function priority2fb (elmPriority) {
5982 return elmPriority.ctor === 'NoPriority' ? null : elmPriority._0;
5983 }
5984
5985 function priority2elm (fbPriority) {
5986 switch (Object.prototype.toString.call (fbPriority)) {
5987 case '[object Number]':
5988 return {ctor: 'NumberPriority', _0: fbPriority};
5989 case '[object String]':
5990 return {ctor: 'StringPriority', _0: fbPriority};
5991 default:
5992 return {ctor: 'NoPriority'};
5993 }
5994 }
5995
5996 function error2elm (tag, description) {
5997 return {
5998 tag: { ctor: tag },
5999 description: description
6000 };
6001 }
6002
6003 var fbErrorMap = {
6004 PERMISSION_DENIED: 'PermissionError',
6005 UNAVAILABLE: 'UnavailableError',
6006 TOO_BIG: 'TooBigError'
6007 };
6008
6009 function fbTaskError (fbError) {
6010 var tag = fbErrorMap [fbError.code];
6011 if (! tag) {
6012 tag = 'OtherFirebaseError';
6013 }
6014 return error2elm (tag, fbError.toString ());
6015 }
6016
6017 function fbTaskFail (fbError) {
6018 return Task.fail (fbTaskError (fbError));
6019 }
6020
6021 function exTaskError (exception) {
6022 return error2elm ('OtherFirebaseError', exception.toString ());
6023 }
6024
6025 function exTaskFail (exception) {
6026 return Task.fail (exTaskError (exception));
6027 }
6028
6029 function onCompleteCallbackRef (callback, res) {
6030 return function (err) {
6031 if (err) {
6032 callback (fbTaskFail (err));
6033 } else {
6034 callback (Task.succeed (res));
6035 }
6036 };
6037 }
6038
6039 function getRefStep (location) {
6040 var ref;
6041 switch (location.ctor) {
6042 case 'UrlLocation':
6043 ref = new Firebase (location._0);
6044 break;
6045 case 'SubLocation':
6046 ref = getRefStep (location._1) .child (location._0);
6047 break;
6048 case 'ParentLocation':
6049 ref = getRefStep (location._0) .parent ();
6050 if (! ref) { throw ('Error: Root has no parent'); }
6051 break;
6052 case 'RootLocation':
6053 ref = getRefStep (location._0) .root ();
6054 break;
6055 case 'PushLocation':
6056 ref = getRefStep (location._0) .push ();
6057 break;
6058 case 'RefLocation':
6059 ref = location._0;
6060 break;
6061 }
6062 if (! ref) {
6063 throw ('Bad Firebase reference.' + pleaseReportThis);
6064 }
6065 return ref;
6066 }
6067
6068 function getRef (location, failureCallback) {
6069 var ref;
6070 try {
6071 ref = getRefStep (location);
6072 }
6073 catch (exception) {
6074 failureCallback (Task.fail (error2elm ('LocationError', exception.toString ())));
6075 }
6076 return ref;
6077 }
6078
6079 function toUrl (reference) {
6080 return reference .toString ();
6081 }
6082
6083 function key (reference) {
6084 var res = reference .key ();
6085 if (res === null) {
6086 res = '';
6087 }
6088 return res;
6089 }
6090
6091 function open (location) {
6092 return Task .asyncFunction (function (callback) {
6093 var ref = getRef (location, callback);
6094 if (ref) {
6095 callback (Task.succeed (ref));
6096 }
6097 });
6098 }
6099
6100 function set (onDisconnect, value, location) {
6101 return Task .asyncFunction (function (callback) {
6102 var ref = getRef (location, callback);
6103 if (ref) {
6104 var onComplete;
6105 if (onDisconnect) {
6106 ref = ref.onDisconnect ();
6107 onComplete = onCompleteCallbackRef (callback, Utils.Tuple0);
6108 } else {
6109 onComplete = onCompleteCallbackRef (callback, ref)
6110 }
6111 try { ref.set (value, onComplete); }
6112 catch (exception) { callback (exTaskFail (exception)); }
6113 }
6114 });
6115 }
6116
6117 function setWithPriority (onDisconnect, value, priority, location) {
6118 return Task .asyncFunction (function (callback) {
6119 var ref = getRef (location, callback);
6120 if (ref) {
6121 var onComplete;
6122 if (onDisconnect) {
6123 ref = ref.onDisconnect ();
6124 onComplete = onCompleteCallbackRef (callback, Utils.Tuple0);
6125 } else {
6126 onComplete = onCompleteCallbackRef (callback, ref)
6127 }
6128 try { ref.setWithPriority (value, priority2fb (priority), onComplete); }
6129 catch (exception) { callback (exTaskFail (exception)); }
6130 }
6131 });
6132 }
6133
6134 function setPriority (priority, location) {
6135 return Task .asyncFunction (function (callback) {
6136 var ref = getRef (location, callback);
6137 if (ref) {
6138 try {
6139 ref.setPriority
6140 (priority2fb (priority), onCompleteCallbackRef (callback, ref));
6141 }
6142 catch (exception) { callback (exTaskFail (exception)); }
6143 }
6144 });
6145 }
6146
6147 function update (onDisconnect, value, location) {
6148 return Task .asyncFunction (function (callback) {
6149 var ref = getRef (location, callback);
6150 if (ref) {
6151 var onComplete;
6152 if (onDisconnect) {
6153 ref = ref.onDisconnect ();
6154 onComplete = onCompleteCallbackRef (callback, Utils.Tuple0);
6155 } else {
6156 onComplete = onCompleteCallbackRef (callback, ref)
6157 }
6158 try { ref.update (value, onComplete); }
6159 catch (exception) { callback (exTaskFail (exception)); }
6160 }
6161 });
6162 }
6163
6164 function remove (onDisconnect, location) {
6165 return Task .asyncFunction (function (callback) {
6166 var ref = getRef (location, callback);
6167 if (ref) {
6168 var onComplete;
6169 if (onDisconnect) {
6170 ref = ref.onDisconnect ();
6171 onComplete = onCompleteCallbackRef (callback, Utils.Tuple0);
6172 } else {
6173 onComplete = onCompleteCallbackRef (callback, ref)
6174 }
6175 try { ref.remove (onComplete); }
6176 catch (exception) { callback (exTaskFail (exception)); }
6177 }
6178 });
6179 }
6180
6181 function onDisconnectCancel (location) {
6182 return Task .asyncFunction (function (callback) {
6183 var ref = getRef (location, callback);
6184 if (ref) {
6185 try { ref.onDisconnect().cancel (onCompleteCallbackRef (callback, Utils.Tuple0)); }
6186 catch (exception) { callback (exTaskFail (exception)); }
6187 }
6188 });
6189 }
6190
6191 function transaction (updateFunc, location, applyLocally) {
6192 return Task .asyncFunction (function (callback) {
6193 var ref = getRef (location, callback);
6194 if (ref) {
6195 var fbUpdateFunc = function (prevVal) {
6196 var action = updateFunc (asMaybe (prevVal));
6197 switch (action.ctor) {
6198 case 'Abort': return;
6199 case 'Remove': return null;
6200 case 'Set': return action._0;
6201 default: throw ('Bad action.' + pleaseReportThis);
6202 }
6203 };
6204 var onComplete = function (err, committed, fbSnapshot) {
6205 if (err) {
6206 callback (fbTaskFail (err));
6207 } else {
6208 var snapshot = snapshot2elm ('_transaction_', fbSnapshot, null);
6209 var res = Utils.Tuple2 (committed, snapshot);
6210 callback (Task.succeed (res));
6211 }
6212 };
6213 try { ref.transaction (fbUpdateFunc, onComplete, applyLocally); }
6214 catch (exception) {
6215 callback (exTaskFail (exception));
6216 }
6217 }
6218 });
6219 }
6220
6221 // Store for current query subscriptions
6222 var sNum = 0;
6223 var subscriptions = {};
6224
6225 function nextSubscriptionId () {
6226 return 'q' + (++sNum);
6227 }
6228
6229 function queryEventType (query) {
6230 var eventType = 'Bad query type.' + pleaseReportThis;
6231 switch (query.ctor) {
6232 case 'ValueChanged': eventType = 'value'; break;
6233 case 'ChildAdded': eventType = 'child_added'; break;
6234 case 'ChildChanged': eventType = 'child_changed'; break;
6235 case 'ChildRemoved': eventType = 'child_removed'; break;
6236 case 'ChildMoved': eventType = 'child_moved'; break;
6237 }
6238 return eventType;
6239 }
6240
6241 function queryOrderPoint (isPrio, filterFn, endPoint, ref) {
6242 if (isPrio) {
6243 var prio = priority2fb (endPoint._0);
6244 var key = fromMaybe (endPoint._1);
6245 if (key === null) {
6246 ref = filterFn.call (ref, prio);
6247 } else {
6248 ref = filterFn.call (ref, prio, key);
6249 }
6250 } else {
6251 ref = filterFn.call (ref, endPoint);
6252 }
6253 return ref;
6254 }
6255
6256 function queryOrderAndFilter (query, ref) {
6257 if (query._0) {
6258 var orderOptions = query._0;
6259 var rangeOptions = null;
6260 var limitOptions = null;
6261 switch (orderOptions.ctor) {
6262 case 'NoOrder':
6263 break;
6264 case 'OrderByChild':
6265 ref = ref.orderByChild (orderOptions._0);
6266 rangeOptions = orderOptions._1;
6267 limitOptions = orderOptions._2;
6268 break;
6269 case 'OrderByValue':
6270 ref = ref.orderByValue ();
6271 rangeOptions = orderOptions._0;
6272 limitOptions = orderOptions._1;
6273 break;
6274 case 'OrderByKey':
6275 ref = ref.orderByKey ();
6276 rangeOptions = orderOptions._0;
6277 limitOptions = orderOptions._1;
6278 break;
6279 case 'OrderByPriority':
6280 ref = ref.orderByPriority ();
6281 rangeOptions = orderOptions._0;
6282 limitOptions = orderOptions._1;
6283 break;
6284 default: throw ('Bad query order option.' + pleaseReportThis);
6285 }
6286 if (rangeOptions) {
6287 var isPrio = orderOptions.ctor === 'OrderByPriority';
6288 switch (rangeOptions.ctor) {
6289 case 'NoRange':
6290 break;
6291 case 'StartAt':
6292 ref = queryOrderPoint (isPrio, ref.startAt, rangeOptions._0, ref);
6293 break;
6294 case 'EndAt':
6295 ref = queryOrderPoint (isPrio, ref.endAt, rangeOptions._0, ref);
6296 break;
6297 case 'Range':
6298 ref = queryOrderPoint (isPrio, ref.startAt, rangeOptions._0, ref);
6299 ref = queryOrderPoint (isPrio, ref.endAt, rangeOptions._1, ref);
6300 break;
6301 case 'EqualTo':
6302 ref = queryOrderPoint (isPrio, ref.equalTo, rangeOptions._0, ref);
6303 break;
6304 default: throw ('Bad query range option.' + pleaseReportThis);
6305 }
6306 }
6307 if (limitOptions) {
6308 switch (limitOptions.ctor) {
6309 case 'NoLimit': break;
6310 case 'LimitToFirst': ref = ref.limitToFirst (limitOptions._0); break;
6311 case 'LimitToLast': ref = ref.limitToLast (limitOptions._0); break;
6312 default: throw ('Bad query limit option.' + pleaseReportThis);
6313 }
6314 }
6315 }
6316 return ref;
6317 }
6318
6319 function snapshot2elm (subscription, fbSnapshot, prevKey) {
6320 var key = fbSnapshot .key ();
6321 if (key === null) {
6322 key = '';
6323 }
6324 var value = fbSnapshot .val ();
6325 return {
6326 subscription: subscription,
6327 key: key,
6328 reference: fbSnapshot .ref (),
6329 existing: value !== null,
6330 value: value,
6331 prevKey: asMaybe (prevKey),
6332 priority: priority2elm (fbSnapshot .getPriority ()),
6333 intern_: fbSnapshot
6334 };
6335 }
6336
6337 function subscribeConditional (createResponseTask, createCancellationTask, query, location) {
6338 return Task .asyncFunction (function (callback) {
6339 var ref = getRef (location, callback);
6340 if (ref) {
6341 var subscriptionId = nextSubscriptionId ();
6342 var onResponse = function (fbSnapshot, prevKey) {
6343 var snapshot = snapshot2elm (subscriptionId, fbSnapshot, prevKey);
6344 var responseTask = fromMaybe (createResponseTask (snapshot));
6345 if (responseTask !== null) {
6346 Task .perform (responseTask);
6347 }
6348 };
6349 var onCancel = function (err) {
6350 var cancellation = {
6351 ctor: 'QueryError',
6352 _0: subscriptionId,
6353 _1: fbTaskError (err)
6354 };
6355 Task .perform (createCancellationTask (cancellation));
6356 };
6357 var eventType = queryEventType (query);
6358 subscriptions [subscriptionId] = {
6359 ref: ref,
6360 eventType: eventType,
6361 callback: onResponse,
6362 createCancellationTask: createCancellationTask
6363 };
6364 try { queryOrderAndFilter (query, ref)
6365 .on (eventType, onResponse, onCancel); }
6366 catch (exception) {
6367 callback (exTaskFail (exception));
6368 return;
6369 }
6370 callback (Task.succeed (subscriptionId));
6371 }
6372 });
6373 }
6374
6375 function unsubscribe (subscription) {
6376 return Task .asyncFunction (function (callback) {
6377 if (subscriptions.hasOwnProperty (subscription)) {
6378 var query = subscriptions [subscription];
6379 delete subscriptions [subscription];
6380 try { query.ref.off (query.eventType, query.callback); }
6381 catch (exception) {
6382 callback (exTaskFail (exception));
6383 return;
6384 }
6385 Task.perform (query.createCancellationTask ({
6386 ctor: 'Unsubscribed', _0: subscription
6387 }));
6388 callback (Task.succeed (Utils.Tuple0));
6389 } else {
6390 callback (Task.fail ({ ctor: 'UnknownSubscription' }));
6391 }
6392 });
6393 }
6394
6395 function once (query, location) {
6396 return Task .asyncFunction (function (callback) {
6397 var ref = getRef (location, callback);
6398 if (ref) {
6399 var onResponse = function (fbSnapshot, prevKey) {
6400 var snapshot = snapshot2elm ('_once_', fbSnapshot, prevKey);
6401 callback (Task.succeed (snapshot));
6402 };
6403 var onCancel = function (err) {
6404 var error = fbTaskFail (err);
6405 callback (error);
6406 };
6407 var eventType = queryEventType (query);
6408 try { queryOrderAndFilter (query, ref)
6409 .once (eventType, onResponse, onCancel); }
6410 catch (exception) {
6411 callback (exTaskFail (exception));
6412 }
6413 }
6414 });
6415 }
6416
6417 function toSnapshotList (snapshot) {
6418 var arr = [], prevKey = '';
6419 snapshot .intern_ .forEach (function (fbChildSnapshot) {
6420 var childSnapshot = snapshot2elm ('_child_', fbChildSnapshot, null);
6421 childSnapshot .prevKey = prevKey;
6422 prevKey = childSnapshot .key;
6423 arr .push (childSnapshot);
6424 });
6425 return List.fromArray (arr);
6426 }
6427
6428 function toListGeneric (snapshot, mapSnapshot) {
6429 var arr = [];
6430 snapshot .intern_ .forEach (function (fbChildSnapshot) {
6431 arr .push (mapSnapshot (fbChildSnapshot));
6432 });
6433 return List.fromArray (arr);
6434 }
6435
6436 function toValueList (snapshot) {
6437 return toListGeneric (snapshot, function (fbChildSnapshot) {
6438 return fbChildSnapshot .val ();
6439 });
6440 }
6441
6442 function toKeyList (snapshot) {
6443 return toListGeneric (snapshot, function (fbChildSnapshot) {
6444 return fbChildSnapshot .key ();
6445 });
6446 }
6447
6448 function toPairList (snapshot) {
6449 return toListGeneric (snapshot, function (fbChildSnapshot) {
6450 return Utils.Tuple2 (fbChildSnapshot .key (), fbChildSnapshot .val ());
6451 });
6452 }
6453
6454 function exportValue (snapshot) {
6455 return snapshot .intern_ .exportVal ();
6456 }
6457
6458 function setOffline (off) {
6459 return Task .asyncFunction (function (callback) {
6460 if (off) {
6461 Firebase.goOffline ();
6462 } else {
6463 Firebase.goOnline ();
6464 }
6465 callback (Task.succeed (Utils.Tuple0));
6466 });
6467 }
6468
6469 var serverTimeStamp = Firebase.ServerValue.TIMESTAMP;
6470
6471 return localRuntime.Native.ElmFire.values =
6472 {
6473 // Values exported to Elm
6474 toUrl: toUrl
6475 , key: key
6476 , open: open
6477 , set: F3 (set)
6478 , setWithPriority: F4 (setWithPriority)
6479 , setPriority: F2 (setPriority)
6480 , update: F3 (update)
6481 , remove: F2 (remove)
6482 , onDisconnectCancel: onDisconnectCancel
6483 , transaction: F3 (transaction)
6484 , subscribeConditional: F4 (subscribeConditional)
6485 , unsubscribe: unsubscribe
6486 , once: F2 (once)
6487 , toSnapshotList: toSnapshotList
6488 , toValueList: toValueList
6489 , toKeyList: toKeyList
6490 , toPairList: toPairList
6491 , exportValue: exportValue
6492 , setOffline: setOffline
6493 , serverTimeStamp: serverTimeStamp
6494
6495 // Utilities for sub-modules
6496 , asMaybe: asMaybe
6497 , getRef: getRef
6498 , pleaseReportThis: pleaseReportThis
6499 };
6500};
6501
6502Elm.Native.Array = {};
6503Elm.Native.Array.make = function(localRuntime) {
6504
6505 localRuntime.Native = localRuntime.Native || {};
6506 localRuntime.Native.Array = localRuntime.Native.Array || {};
6507 if (localRuntime.Native.Array.values)
6508 {
6509 return localRuntime.Native.Array.values;
6510 }
6511 if ('values' in Elm.Native.Array)
6512 {
6513 return localRuntime.Native.Array.values = Elm.Native.Array.values;
6514 }
6515
6516 var List = Elm.Native.List.make(localRuntime);
6517
6518 // A RRB-Tree has two distinct data types.
6519 // Leaf -> "height" is always 0
6520 // "table" is an array of elements
6521 // Node -> "height" is always greater than 0
6522 // "table" is an array of child nodes
6523 // "lengths" is an array of accumulated lengths of the child nodes
6524
6525 // M is the maximal table size. 32 seems fast. E is the allowed increase
6526 // of search steps when concatting to find an index. Lower values will
6527 // decrease balancing, but will increase search steps.
6528 var M = 32;
6529 var E = 2;
6530
6531 // An empty array.
6532 var empty = {
6533 ctor: '_Array',
6534 height: 0,
6535 table: []
6536 };
6537
6538
6539 function get(i, array)
6540 {
6541 if (i < 0 || i >= length(array))
6542 {
6543 throw new Error(
6544 'Index ' + i + ' is out of range. Check the length of ' +
6545 'your array first or use getMaybe or getWithDefault.');
6546 }
6547 return unsafeGet(i, array);
6548 }
6549
6550
6551 function unsafeGet(i, array)
6552 {
6553 for (var x = array.height; x > 0; x--)
6554 {
6555 var slot = i >> (x * 5);
6556 while (array.lengths[slot] <= i)
6557 {
6558 slot++;
6559 }
6560 if (slot > 0)
6561 {
6562 i -= array.lengths[slot - 1];
6563 }
6564 array = array.table[slot];
6565 }
6566 return array.table[i];
6567 }
6568
6569
6570 // Sets the value at the index i. Only the nodes leading to i will get
6571 // copied and updated.
6572 function set(i, item, array)
6573 {
6574 if (i < 0 || length(array) <= i)
6575 {
6576 return array;
6577 }
6578 return unsafeSet(i, item, array);
6579 }
6580
6581
6582 function unsafeSet(i, item, array)
6583 {
6584 array = nodeCopy(array);
6585
6586 if (array.height === 0)
6587 {
6588 array.table[i] = item;
6589 }
6590 else
6591 {
6592 var slot = getSlot(i, array);
6593 if (slot > 0)
6594 {
6595 i -= array.lengths[slot - 1];
6596 }
6597 array.table[slot] = unsafeSet(i, item, array.table[slot]);
6598 }
6599 return array;
6600 }
6601
6602
6603 function initialize(len, f)
6604 {
6605 if (len <= 0)
6606 {
6607 return empty;
6608 }
6609 var h = Math.floor( Math.log(len) / Math.log(M) );
6610 return initialize_(f, h, 0, len);
6611 }
6612
6613 function initialize_(f, h, from, to)
6614 {
6615 if (h === 0)
6616 {
6617 var table = new Array((to - from) % (M + 1));
6618 for (var i = 0; i < table.length; i++)
6619 {
6620 table[i] = f(from + i);
6621 }
6622 return {
6623 ctor: '_Array',
6624 height: 0,
6625 table: table
6626 };
6627 }
6628
6629 var step = Math.pow(M, h);
6630 var table = new Array(Math.ceil((to - from) / step));
6631 var lengths = new Array(table.length);
6632 for (var i = 0; i < table.length; i++)
6633 {
6634 table[i] = initialize_(f, h - 1, from + (i * step), Math.min(from + ((i + 1) * step), to));
6635 lengths[i] = length(table[i]) + (i > 0 ? lengths[i-1] : 0);
6636 }
6637 return {
6638 ctor: '_Array',
6639 height: h,
6640 table: table,
6641 lengths: lengths
6642 };
6643 }
6644
6645 function fromList(list)
6646 {
6647 if (list === List.Nil)
6648 {
6649 return empty;
6650 }
6651
6652 // Allocate M sized blocks (table) and write list elements to it.
6653 var table = new Array(M);
6654 var nodes = [];
6655 var i = 0;
6656
6657 while (list.ctor !== '[]')
6658 {
6659 table[i] = list._0;
6660 list = list._1;
6661 i++;
6662
6663 // table is full, so we can push a leaf containing it into the
6664 // next node.
6665 if (i === M)
6666 {
6667 var leaf = {
6668 ctor: '_Array',
6669 height: 0,
6670 table: table
6671 };
6672 fromListPush(leaf, nodes);
6673 table = new Array(M);
6674 i = 0;
6675 }
6676 }
6677
6678 // Maybe there is something left on the table.
6679 if (i > 0)
6680 {
6681 var leaf = {
6682 ctor: '_Array',
6683 height: 0,
6684 table: table.splice(0, i)
6685 };
6686 fromListPush(leaf, nodes);
6687 }
6688
6689 // Go through all of the nodes and eventually push them into higher nodes.
6690 for (var h = 0; h < nodes.length - 1; h++)
6691 {
6692 if (nodes[h].table.length > 0)
6693 {
6694 fromListPush(nodes[h], nodes);
6695 }
6696 }
6697
6698 var head = nodes[nodes.length - 1];
6699 if (head.height > 0 && head.table.length === 1)
6700 {
6701 return head.table[0];
6702 }
6703 else
6704 {
6705 return head;
6706 }
6707 }
6708
6709 // Push a node into a higher node as a child.
6710 function fromListPush(toPush, nodes)
6711 {
6712 var h = toPush.height;
6713
6714 // Maybe the node on this height does not exist.
6715 if (nodes.length === h)
6716 {
6717 var node = {
6718 ctor: '_Array',
6719 height: h + 1,
6720 table: [],
6721 lengths: []
6722 };
6723 nodes.push(node);
6724 }
6725
6726 nodes[h].table.push(toPush);
6727 var len = length(toPush);
6728 if (nodes[h].lengths.length > 0)
6729 {
6730 len += nodes[h].lengths[nodes[h].lengths.length - 1];
6731 }
6732 nodes[h].lengths.push(len);
6733
6734 if (nodes[h].table.length === M)
6735 {
6736 fromListPush(nodes[h], nodes);
6737 nodes[h] = {
6738 ctor: '_Array',
6739 height: h + 1,
6740 table: [],
6741 lengths: []
6742 };
6743 }
6744 }
6745
6746 // Pushes an item via push_ to the bottom right of a tree.
6747 function push(item, a)
6748 {
6749 var pushed = push_(item, a);
6750 if (pushed !== null)
6751 {
6752 return pushed;
6753 }
6754
6755 var newTree = create(item, a.height);
6756 return siblise(a, newTree);
6757 }
6758
6759 // Recursively tries to push an item to the bottom-right most
6760 // tree possible. If there is no space left for the item,
6761 // null will be returned.
6762 function push_(item, a)
6763 {
6764 // Handle resursion stop at leaf level.
6765 if (a.height === 0)
6766 {
6767 if (a.table.length < M)
6768 {
6769 var newA = {
6770 ctor: '_Array',
6771 height: 0,
6772 table: a.table.slice()
6773 };
6774 newA.table.push(item);
6775 return newA;
6776 }
6777 else
6778 {
6779 return null;
6780 }
6781 }
6782
6783 // Recursively push
6784 var pushed = push_(item, botRight(a));
6785
6786 // There was space in the bottom right tree, so the slot will
6787 // be updated.
6788 if (pushed !== null)
6789 {
6790 var newA = nodeCopy(a);
6791 newA.table[newA.table.length - 1] = pushed;
6792 newA.lengths[newA.lengths.length - 1]++;
6793 return newA;
6794 }
6795
6796 // When there was no space left, check if there is space left
6797 // for a new slot with a tree which contains only the item
6798 // at the bottom.
6799 if (a.table.length < M)
6800 {
6801 var newSlot = create(item, a.height - 1);
6802 var newA = nodeCopy(a);
6803 newA.table.push(newSlot);
6804 newA.lengths.push(newA.lengths[newA.lengths.length - 1] + length(newSlot));
6805 return newA;
6806 }
6807 else
6808 {
6809 return null;
6810 }
6811 }
6812
6813 // Converts an array into a list of elements.
6814 function toList(a)
6815 {
6816 return toList_(List.Nil, a);
6817 }
6818
6819 function toList_(list, a)
6820 {
6821 for (var i = a.table.length - 1; i >= 0; i--)
6822 {
6823 list =
6824 a.height === 0
6825 ? List.Cons(a.table[i], list)
6826 : toList_(list, a.table[i]);
6827 }
6828 return list;
6829 }
6830
6831 // Maps a function over the elements of an array.
6832 function map(f, a)
6833 {
6834 var newA = {
6835 ctor: '_Array',
6836 height: a.height,
6837 table: new Array(a.table.length)
6838 };
6839 if (a.height > 0)
6840 {
6841 newA.lengths = a.lengths;
6842 }
6843 for (var i = 0; i < a.table.length; i++)
6844 {
6845 newA.table[i] =
6846 a.height === 0
6847 ? f(a.table[i])
6848 : map(f, a.table[i]);
6849 }
6850 return newA;
6851 }
6852
6853 // Maps a function over the elements with their index as first argument.
6854 function indexedMap(f, a)
6855 {
6856 return indexedMap_(f, a, 0);
6857 }
6858
6859 function indexedMap_(f, a, from)
6860 {
6861 var newA = {
6862 ctor: '_Array',
6863 height: a.height,
6864 table: new Array(a.table.length)
6865 };
6866 if (a.height > 0)
6867 {
6868 newA.lengths = a.lengths;
6869 }
6870 for (var i = 0; i < a.table.length; i++)
6871 {
6872 newA.table[i] =
6873 a.height === 0
6874 ? A2(f, from + i, a.table[i])
6875 : indexedMap_(f, a.table[i], i == 0 ? from : from + a.lengths[i - 1]);
6876 }
6877 return newA;
6878 }
6879
6880 function foldl(f, b, a)
6881 {
6882 if (a.height === 0)
6883 {
6884 for (var i = 0; i < a.table.length; i++)
6885 {
6886 b = A2(f, a.table[i], b);
6887 }
6888 }
6889 else
6890 {
6891 for (var i = 0; i < a.table.length; i++)
6892 {
6893 b = foldl(f, b, a.table[i]);
6894 }
6895 }
6896 return b;
6897 }
6898
6899 function foldr(f, b, a)
6900 {
6901 if (a.height === 0)
6902 {
6903 for (var i = a.table.length; i--; )
6904 {
6905 b = A2(f, a.table[i], b);
6906 }
6907 }
6908 else
6909 {
6910 for (var i = a.table.length; i--; )
6911 {
6912 b = foldr(f, b, a.table[i]);
6913 }
6914 }
6915 return b;
6916 }
6917
6918 // TODO: currently, it slices the right, then the left. This can be
6919 // optimized.
6920 function slice(from, to, a)
6921 {
6922 if (from < 0)
6923 {
6924 from += length(a);
6925 }
6926 if (to < 0)
6927 {
6928 to += length(a);
6929 }
6930 return sliceLeft(from, sliceRight(to, a));
6931 }
6932
6933 function sliceRight(to, a)
6934 {
6935 if (to === length(a))
6936 {
6937 return a;
6938 }
6939
6940 // Handle leaf level.
6941 if (a.height === 0)
6942 {
6943 var newA = { ctor:'_Array', height:0 };
6944 newA.table = a.table.slice(0, to);
6945 return newA;
6946 }
6947
6948 // Slice the right recursively.
6949 var right = getSlot(to, a);
6950 var sliced = sliceRight(to - (right > 0 ? a.lengths[right - 1] : 0), a.table[right]);
6951
6952 // Maybe the a node is not even needed, as sliced contains the whole slice.
6953 if (right === 0)
6954 {
6955 return sliced;
6956 }
6957
6958 // Create new node.
6959 var newA = {
6960 ctor: '_Array',
6961 height: a.height,
6962 table: a.table.slice(0, right),
6963 lengths: a.lengths.slice(0, right)
6964 };
6965 if (sliced.table.length > 0)
6966 {
6967 newA.table[right] = sliced;
6968 newA.lengths[right] = length(sliced) + (right > 0 ? newA.lengths[right - 1] : 0);
6969 }
6970 return newA;
6971 }
6972
6973 function sliceLeft(from, a)
6974 {
6975 if (from === 0)
6976 {
6977 return a;
6978 }
6979
6980 // Handle leaf level.
6981 if (a.height === 0)
6982 {
6983 var newA = { ctor:'_Array', height:0 };
6984 newA.table = a.table.slice(from, a.table.length + 1);
6985 return newA;
6986 }
6987
6988 // Slice the left recursively.
6989 var left = getSlot(from, a);
6990 var sliced = sliceLeft(from - (left > 0 ? a.lengths[left - 1] : 0), a.table[left]);
6991
6992 // Maybe the a node is not even needed, as sliced contains the whole slice.
6993 if (left === a.table.length - 1)
6994 {
6995 return sliced;
6996 }
6997
6998 // Create new node.
6999 var newA = {
7000 ctor: '_Array',
7001 height: a.height,
7002 table: a.table.slice(left, a.table.length + 1),
7003 lengths: new Array(a.table.length - left)
7004 };
7005 newA.table[0] = sliced;
7006 var len = 0;
7007 for (var i = 0; i < newA.table.length; i++)
7008 {
7009 len += length(newA.table[i]);
7010 newA.lengths[i] = len;
7011 }
7012
7013 return newA;
7014 }
7015
7016 // Appends two trees.
7017 function append(a,b)
7018 {
7019 if (a.table.length === 0)
7020 {
7021 return b;
7022 }
7023 if (b.table.length === 0)
7024 {
7025 return a;
7026 }
7027
7028 var c = append_(a, b);
7029
7030 // Check if both nodes can be crunshed together.
7031 if (c[0].table.length + c[1].table.length <= M)
7032 {
7033 if (c[0].table.length === 0)
7034 {
7035 return c[1];
7036 }
7037 if (c[1].table.length === 0)
7038 {
7039 return c[0];
7040 }
7041
7042 // Adjust .table and .lengths
7043 c[0].table = c[0].table.concat(c[1].table);
7044 if (c[0].height > 0)
7045 {
7046 var len = length(c[0]);
7047 for (var i = 0; i < c[1].lengths.length; i++)
7048 {
7049 c[1].lengths[i] += len;
7050 }
7051 c[0].lengths = c[0].lengths.concat(c[1].lengths);
7052 }
7053
7054 return c[0];
7055 }
7056
7057 if (c[0].height > 0)
7058 {
7059 var toRemove = calcToRemove(a, b);
7060 if (toRemove > E)
7061 {
7062 c = shuffle(c[0], c[1], toRemove);
7063 }
7064 }
7065
7066 return siblise(c[0], c[1]);
7067 }
7068
7069 // Returns an array of two nodes; right and left. One node _may_ be empty.
7070 function append_(a, b)
7071 {
7072 if (a.height === 0 && b.height === 0)
7073 {
7074 return [a, b];
7075 }
7076
7077 if (a.height !== 1 || b.height !== 1)
7078 {
7079 if (a.height === b.height)
7080 {
7081 a = nodeCopy(a);
7082 b = nodeCopy(b);
7083 var appended = append_(botRight(a), botLeft(b));
7084
7085 insertRight(a, appended[1]);
7086 insertLeft(b, appended[0]);
7087 }
7088 else if (a.height > b.height)
7089 {
7090 a = nodeCopy(a);
7091 var appended = append_(botRight(a), b);
7092
7093 insertRight(a, appended[0]);
7094 b = parentise(appended[1], appended[1].height + 1);
7095 }
7096 else
7097 {
7098 b = nodeCopy(b);
7099 var appended = append_(a, botLeft(b));
7100
7101 var left = appended[0].table.length === 0 ? 0 : 1;
7102 var right = left === 0 ? 1 : 0;
7103 insertLeft(b, appended[left]);
7104 a = parentise(appended[right], appended[right].height + 1);
7105 }
7106 }
7107
7108 // Check if balancing is needed and return based on that.
7109 if (a.table.length === 0 || b.table.length === 0)
7110 {
7111 return [a, b];
7112 }
7113
7114 var toRemove = calcToRemove(a, b);
7115 if (toRemove <= E)
7116 {
7117 return [a, b];
7118 }
7119 return shuffle(a, b, toRemove);
7120 }
7121
7122 // Helperfunctions for append_. Replaces a child node at the side of the parent.
7123 function insertRight(parent, node)
7124 {
7125 var index = parent.table.length - 1;
7126 parent.table[index] = node;
7127 parent.lengths[index] = length(node);
7128 parent.lengths[index] += index > 0 ? parent.lengths[index - 1] : 0;
7129 }
7130
7131 function insertLeft(parent, node)
7132 {
7133 if (node.table.length > 0)
7134 {
7135 parent.table[0] = node;
7136 parent.lengths[0] = length(node);
7137
7138 var len = length(parent.table[0]);
7139 for (var i = 1; i < parent.lengths.length; i++)
7140 {
7141 len += length(parent.table[i]);
7142 parent.lengths[i] = len;
7143 }
7144 }
7145 else
7146 {
7147 parent.table.shift();
7148 for (var i = 1; i < parent.lengths.length; i++)
7149 {
7150 parent.lengths[i] = parent.lengths[i] - parent.lengths[0];
7151 }
7152 parent.lengths.shift();
7153 }
7154 }
7155
7156 // Returns the extra search steps for E. Refer to the paper.
7157 function calcToRemove(a, b)
7158 {
7159 var subLengths = 0;
7160 for (var i = 0; i < a.table.length; i++)
7161 {
7162 subLengths += a.table[i].table.length;
7163 }
7164 for (var i = 0; i < b.table.length; i++)
7165 {
7166 subLengths += b.table[i].table.length;
7167 }
7168
7169 var toRemove = a.table.length + b.table.length;
7170 return toRemove - (Math.floor((subLengths - 1) / M) + 1);
7171 }
7172
7173 // get2, set2 and saveSlot are helpers for accessing elements over two arrays.
7174 function get2(a, b, index)
7175 {
7176 return index < a.length
7177 ? a[index]
7178 : b[index - a.length];
7179 }
7180
7181 function set2(a, b, index, value)
7182 {
7183 if (index < a.length)
7184 {
7185 a[index] = value;
7186 }
7187 else
7188 {
7189 b[index - a.length] = value;
7190 }
7191 }
7192
7193 function saveSlot(a, b, index, slot)
7194 {
7195 set2(a.table, b.table, index, slot);
7196
7197 var l = (index === 0 || index === a.lengths.length)
7198 ? 0
7199 : get2(a.lengths, a.lengths, index - 1);
7200
7201 set2(a.lengths, b.lengths, index, l + length(slot));
7202 }
7203
7204 // Creates a node or leaf with a given length at their arrays for perfomance.
7205 // Is only used by shuffle.
7206 function createNode(h, length)
7207 {
7208 if (length < 0)
7209 {
7210 length = 0;
7211 }
7212 var a = {
7213 ctor: '_Array',
7214 height: h,
7215 table: new Array(length)
7216 };
7217 if (h > 0)
7218 {
7219 a.lengths = new Array(length);
7220 }
7221 return a;
7222 }
7223
7224 // Returns an array of two balanced nodes.
7225 function shuffle(a, b, toRemove)
7226 {
7227 var newA = createNode(a.height, Math.min(M, a.table.length + b.table.length - toRemove));
7228 var newB = createNode(a.height, newA.table.length - (a.table.length + b.table.length - toRemove));
7229
7230 // Skip the slots with size M. More precise: copy the slot references
7231 // to the new node
7232 var read = 0;
7233 while (get2(a.table, b.table, read).table.length % M === 0)
7234 {
7235 set2(newA.table, newB.table, read, get2(a.table, b.table, read));
7236 set2(newA.lengths, newB.lengths, read, get2(a.lengths, b.lengths, read));
7237 read++;
7238 }
7239
7240 // Pulling items from left to right, caching in a slot before writing
7241 // it into the new nodes.
7242 var write = read;
7243 var slot = new createNode(a.height - 1, 0);
7244 var from = 0;
7245
7246 // If the current slot is still containing data, then there will be at
7247 // least one more write, so we do not break this loop yet.
7248 while (read - write - (slot.table.length > 0 ? 1 : 0) < toRemove)
7249 {
7250 // Find out the max possible items for copying.
7251 var source = get2(a.table, b.table, read);
7252 var to = Math.min(M - slot.table.length, source.table.length);
7253
7254 // Copy and adjust size table.
7255 slot.table = slot.table.concat(source.table.slice(from, to));
7256 if (slot.height > 0)
7257 {
7258 var len = slot.lengths.length;
7259 for (var i = len; i < len + to - from; i++)
7260 {
7261 slot.lengths[i] = length(slot.table[i]);
7262 slot.lengths[i] += (i > 0 ? slot.lengths[i - 1] : 0);
7263 }
7264 }
7265
7266 from += to;
7267
7268 // Only proceed to next slots[i] if the current one was
7269 // fully copied.
7270 if (source.table.length <= to)
7271 {
7272 read++; from = 0;
7273 }
7274
7275 // Only create a new slot if the current one is filled up.
7276 if (slot.table.length === M)
7277 {
7278 saveSlot(newA, newB, write, slot);
7279 slot = createNode(a.height - 1, 0);
7280 write++;
7281 }
7282 }
7283
7284 // Cleanup after the loop. Copy the last slot into the new nodes.
7285 if (slot.table.length > 0)
7286 {
7287 saveSlot(newA, newB, write, slot);
7288 write++;
7289 }
7290
7291 // Shift the untouched slots to the left
7292 while (read < a.table.length + b.table.length )
7293 {
7294 saveSlot(newA, newB, write, get2(a.table, b.table, read));
7295 read++;
7296 write++;
7297 }
7298
7299 return [newA, newB];
7300 }
7301
7302 // Navigation functions
7303 function botRight(a)
7304 {
7305 return a.table[a.table.length - 1];
7306 }
7307 function botLeft(a)
7308 {
7309 return a.table[0];
7310 }
7311
7312 // Copies a node for updating. Note that you should not use this if
7313 // only updating only one of "table" or "lengths" for performance reasons.
7314 function nodeCopy(a)
7315 {
7316 var newA = {
7317 ctor: '_Array',
7318 height: a.height,
7319 table: a.table.slice()
7320 };
7321 if (a.height > 0)
7322 {
7323 newA.lengths = a.lengths.slice();
7324 }
7325 return newA;
7326 }
7327
7328 // Returns how many items are in the tree.
7329 function length(array)
7330 {
7331 if (array.height === 0)
7332 {
7333 return array.table.length;
7334 }
7335 else
7336 {
7337 return array.lengths[array.lengths.length - 1];
7338 }
7339 }
7340
7341 // Calculates in which slot of "table" the item probably is, then
7342 // find the exact slot via forward searching in "lengths". Returns the index.
7343 function getSlot(i, a)
7344 {
7345 var slot = i >> (5 * a.height);
7346 while (a.lengths[slot] <= i)
7347 {
7348 slot++;
7349 }
7350 return slot;
7351 }
7352
7353 // Recursively creates a tree with a given height containing
7354 // only the given item.
7355 function create(item, h)
7356 {
7357 if (h === 0)
7358 {
7359 return {
7360 ctor: '_Array',
7361 height: 0,
7362 table: [item]
7363 };
7364 }
7365 return {
7366 ctor: '_Array',
7367 height: h,
7368 table: [create(item, h - 1)],
7369 lengths: [1]
7370 };
7371 }
7372
7373 // Recursively creates a tree that contains the given tree.
7374 function parentise(tree, h)
7375 {
7376 if (h === tree.height)
7377 {
7378 return tree;
7379 }
7380
7381 return {
7382 ctor: '_Array',
7383 height: h,
7384 table: [parentise(tree, h - 1)],
7385 lengths: [length(tree)]
7386 };
7387 }
7388
7389 // Emphasizes blood brotherhood beneath two trees.
7390 function siblise(a, b)
7391 {
7392 return {
7393 ctor: '_Array',
7394 height: a.height + 1,
7395 table: [a, b],
7396 lengths: [length(a), length(a) + length(b)]
7397 };
7398 }
7399
7400 function toJSArray(a)
7401 {
7402 var jsArray = new Array(length(a));
7403 toJSArray_(jsArray, 0, a);
7404 return jsArray;
7405 }
7406
7407 function toJSArray_(jsArray, i, a)
7408 {
7409 for (var t = 0; t < a.table.length; t++)
7410 {
7411 if (a.height === 0)
7412 {
7413 jsArray[i + t] = a.table[t];
7414 }
7415 else
7416 {
7417 var inc = t === 0 ? 0 : a.lengths[t - 1];
7418 toJSArray_(jsArray, i + inc, a.table[t]);
7419 }
7420 }
7421 }
7422
7423 function fromJSArray(jsArray)
7424 {
7425 if (jsArray.length === 0)
7426 {
7427 return empty;
7428 }
7429 var h = Math.floor(Math.log(jsArray.length) / Math.log(M));
7430 return fromJSArray_(jsArray, h, 0, jsArray.length);
7431 }
7432
7433 function fromJSArray_(jsArray, h, from, to)
7434 {
7435 if (h === 0)
7436 {
7437 return {
7438 ctor: '_Array',
7439 height: 0,
7440 table: jsArray.slice(from, to)
7441 };
7442 }
7443
7444 var step = Math.pow(M, h);
7445 var table = new Array(Math.ceil((to - from) / step));
7446 var lengths = new Array(table.length);
7447 for (var i = 0; i < table.length; i++)
7448 {
7449 table[i] = fromJSArray_(jsArray, h - 1, from + (i * step), Math.min(from + ((i + 1) * step), to));
7450 lengths[i] = length(table[i]) + (i > 0 ? lengths[i - 1] : 0);
7451 }
7452 return {
7453 ctor: '_Array',
7454 height: h,
7455 table: table,
7456 lengths: lengths
7457 };
7458 }
7459
7460 Elm.Native.Array.values = {
7461 empty: empty,
7462 fromList: fromList,
7463 toList: toList,
7464 initialize: F2(initialize),
7465 append: F2(append),
7466 push: F2(push),
7467 slice: F3(slice),
7468 get: F2(get),
7469 set: F3(set),
7470 map: F2(map),
7471 indexedMap: F2(indexedMap),
7472 foldl: F3(foldl),
7473 foldr: F3(foldr),
7474 length: length,
7475
7476 toJSArray: toJSArray,
7477 fromJSArray: fromJSArray
7478 };
7479
7480 return localRuntime.Native.Array.values = Elm.Native.Array.values;
7481};
7482
7483Elm.Array = Elm.Array || {};
7484Elm.Array.make = function (_elm) {
7485 "use strict";
7486 _elm.Array = _elm.Array || {};
7487 if (_elm.Array.values) return _elm.Array.values;
7488 var _U = Elm.Native.Utils.make(_elm),
7489 $Basics = Elm.Basics.make(_elm),
7490 $List = Elm.List.make(_elm),
7491 $Maybe = Elm.Maybe.make(_elm),
7492 $Native$Array = Elm.Native.Array.make(_elm);
7493 var _op = {};
7494 var append = $Native$Array.append;
7495 var length = $Native$Array.length;
7496 var isEmpty = function (array) { return _U.eq(length(array),0);};
7497 var slice = $Native$Array.slice;
7498 var set = $Native$Array.set;
7499 var get = F2(function (i,array) {
7500 return _U.cmp(0,i) < 1 && _U.cmp(i,$Native$Array.length(array)) < 0 ? $Maybe.Just(A2($Native$Array.get,i,array)) : $Maybe.Nothing;
7501 });
7502 var push = $Native$Array.push;
7503 var empty = $Native$Array.empty;
7504 var filter = F2(function (isOkay,arr) {
7505 var update = F2(function (x,xs) { return isOkay(x) ? A2($Native$Array.push,x,xs) : xs;});
7506 return A3($Native$Array.foldl,update,$Native$Array.empty,arr);
7507 });
7508 var foldr = $Native$Array.foldr;
7509 var foldl = $Native$Array.foldl;
7510 var indexedMap = $Native$Array.indexedMap;
7511 var map = $Native$Array.map;
7512 var toIndexedList = function (array) {
7513 return A3($List.map2,
7514 F2(function (v0,v1) { return {ctor: "_Tuple2",_0: v0,_1: v1};}),
7515 _U.range(0,$Native$Array.length(array) - 1),
7516 $Native$Array.toList(array));
7517 };
7518 var toList = $Native$Array.toList;
7519 var fromList = $Native$Array.fromList;
7520 var initialize = $Native$Array.initialize;
7521 var repeat = F2(function (n,e) { return A2(initialize,n,$Basics.always(e));});
7522 var Array = {ctor: "Array"};
7523 return _elm.Array.values = {_op: _op
7524 ,empty: empty
7525 ,repeat: repeat
7526 ,initialize: initialize
7527 ,fromList: fromList
7528 ,isEmpty: isEmpty
7529 ,length: length
7530 ,push: push
7531 ,append: append
7532 ,get: get
7533 ,set: set
7534 ,slice: slice
7535 ,toList: toList
7536 ,toIndexedList: toIndexedList
7537 ,map: map
7538 ,indexedMap: indexedMap
7539 ,filter: filter
7540 ,foldl: foldl
7541 ,foldr: foldr};
7542};
7543Elm.Native.Json = {};
7544
7545Elm.Native.Json.make = function(localRuntime) {
7546 localRuntime.Native = localRuntime.Native || {};
7547 localRuntime.Native.Json = localRuntime.Native.Json || {};
7548 if (localRuntime.Native.Json.values) {
7549 return localRuntime.Native.Json.values;
7550 }
7551
7552 var ElmArray = Elm.Native.Array.make(localRuntime);
7553 var List = Elm.Native.List.make(localRuntime);
7554 var Maybe = Elm.Maybe.make(localRuntime);
7555 var Result = Elm.Result.make(localRuntime);
7556 var Utils = Elm.Native.Utils.make(localRuntime);
7557
7558
7559 function crash(expected, actual) {
7560 throw new Error(
7561 'expecting ' + expected + ' but got ' + JSON.stringify(actual)
7562 );
7563 }
7564
7565
7566 // PRIMITIVE VALUES
7567
7568 function decodeNull(successValue) {
7569 return function(value) {
7570 if (value === null) {
7571 return successValue;
7572 }
7573 crash('null', value);
7574 };
7575 }
7576
7577
7578 function decodeString(value) {
7579 if (typeof value === 'string' || value instanceof String) {
7580 return value;
7581 }
7582 crash('a String', value);
7583 }
7584
7585
7586 function decodeFloat(value) {
7587 if (typeof value === 'number') {
7588 return value;
7589 }
7590 crash('a Float', value);
7591 }
7592
7593
7594 function decodeInt(value) {
7595 if (typeof value !== 'number') {
7596 crash('an Int', value);
7597 }
7598
7599 if (value < 2147483647 && value > -2147483647 && (value | 0) === value) {
7600 return value;
7601 }
7602
7603 if (isFinite(value) && !(value % 1)) {
7604 return value;
7605 }
7606
7607 crash('an Int', value);
7608 }
7609
7610
7611 function decodeBool(value) {
7612 if (typeof value === 'boolean') {
7613 return value;
7614 }
7615 crash('a Bool', value);
7616 }
7617
7618
7619 // ARRAY
7620
7621 function decodeArray(decoder) {
7622 return function(value) {
7623 if (value instanceof Array) {
7624 var len = value.length;
7625 var array = new Array(len);
7626 for (var i = len; i--; ) {
7627 array[i] = decoder(value[i]);
7628 }
7629 return ElmArray.fromJSArray(array);
7630 }
7631 crash('an Array', value);
7632 };
7633 }
7634
7635
7636 // LIST
7637
7638 function decodeList(decoder) {
7639 return function(value) {
7640 if (value instanceof Array) {
7641 var len = value.length;
7642 var list = List.Nil;
7643 for (var i = len; i--; ) {
7644 list = List.Cons( decoder(value[i]), list );
7645 }
7646 return list;
7647 }
7648 crash('a List', value);
7649 };
7650 }
7651
7652
7653 // MAYBE
7654
7655 function decodeMaybe(decoder) {
7656 return function(value) {
7657 try {
7658 return Maybe.Just(decoder(value));
7659 } catch(e) {
7660 return Maybe.Nothing;
7661 }
7662 };
7663 }
7664
7665
7666 // FIELDS
7667
7668 function decodeField(field, decoder) {
7669 return function(value) {
7670 var subValue = value[field];
7671 if (subValue !== undefined) {
7672 return decoder(subValue);
7673 }
7674 crash("an object with field '" + field + "'", value);
7675 };
7676 }
7677
7678
7679 // OBJECTS
7680
7681 function decodeKeyValuePairs(decoder) {
7682 return function(value) {
7683 var isObject =
7684 typeof value === 'object'
7685 && value !== null
7686 && !(value instanceof Array);
7687
7688 if (isObject) {
7689 var keyValuePairs = List.Nil;
7690 for (var key in value)
7691 {
7692 var elmValue = decoder(value[key]);
7693 var pair = Utils.Tuple2(key, elmValue);
7694 keyValuePairs = List.Cons(pair, keyValuePairs);
7695 }
7696 return keyValuePairs;
7697 }
7698
7699 crash('an object', value);
7700 };
7701 }
7702
7703 function decodeObject1(f, d1) {
7704 return function(value) {
7705 return f(d1(value));
7706 };
7707 }
7708
7709 function decodeObject2(f, d1, d2) {
7710 return function(value) {
7711 return A2( f, d1(value), d2(value) );
7712 };
7713 }
7714
7715 function decodeObject3(f, d1, d2, d3) {
7716 return function(value) {
7717 return A3( f, d1(value), d2(value), d3(value) );
7718 };
7719 }
7720
7721 function decodeObject4(f, d1, d2, d3, d4) {
7722 return function(value) {
7723 return A4( f, d1(value), d2(value), d3(value), d4(value) );
7724 };
7725 }
7726
7727 function decodeObject5(f, d1, d2, d3, d4, d5) {
7728 return function(value) {
7729 return A5( f, d1(value), d2(value), d3(value), d4(value), d5(value) );
7730 };
7731 }
7732
7733 function decodeObject6(f, d1, d2, d3, d4, d5, d6) {
7734 return function(value) {
7735 return A6( f,
7736 d1(value),
7737 d2(value),
7738 d3(value),
7739 d4(value),
7740 d5(value),
7741 d6(value)
7742 );
7743 };
7744 }
7745
7746 function decodeObject7(f, d1, d2, d3, d4, d5, d6, d7) {
7747 return function(value) {
7748 return A7( f,
7749 d1(value),
7750 d2(value),
7751 d3(value),
7752 d4(value),
7753 d5(value),
7754 d6(value),
7755 d7(value)
7756 );
7757 };
7758 }
7759
7760 function decodeObject8(f, d1, d2, d3, d4, d5, d6, d7, d8) {
7761 return function(value) {
7762 return A8( f,
7763 d1(value),
7764 d2(value),
7765 d3(value),
7766 d4(value),
7767 d5(value),
7768 d6(value),
7769 d7(value),
7770 d8(value)
7771 );
7772 };
7773 }
7774
7775
7776 // TUPLES
7777
7778 function decodeTuple1(f, d1) {
7779 return function(value) {
7780 if ( !(value instanceof Array) || value.length !== 1 ) {
7781 crash('a Tuple of length 1', value);
7782 }
7783 return f( d1(value[0]) );
7784 };
7785 }
7786
7787 function decodeTuple2(f, d1, d2) {
7788 return function(value) {
7789 if ( !(value instanceof Array) || value.length !== 2 ) {
7790 crash('a Tuple of length 2', value);
7791 }
7792 return A2( f, d1(value[0]), d2(value[1]) );
7793 };
7794 }
7795
7796 function decodeTuple3(f, d1, d2, d3) {
7797 return function(value) {
7798 if ( !(value instanceof Array) || value.length !== 3 ) {
7799 crash('a Tuple of length 3', value);
7800 }
7801 return A3( f, d1(value[0]), d2(value[1]), d3(value[2]) );
7802 };
7803 }
7804
7805
7806 function decodeTuple4(f, d1, d2, d3, d4) {
7807 return function(value) {
7808 if ( !(value instanceof Array) || value.length !== 4 ) {
7809 crash('a Tuple of length 4', value);
7810 }
7811 return A4( f, d1(value[0]), d2(value[1]), d3(value[2]), d4(value[3]) );
7812 };
7813 }
7814
7815
7816 function decodeTuple5(f, d1, d2, d3, d4, d5) {
7817 return function(value) {
7818 if ( !(value instanceof Array) || value.length !== 5 ) {
7819 crash('a Tuple of length 5', value);
7820 }
7821 return A5( f,
7822 d1(value[0]),
7823 d2(value[1]),
7824 d3(value[2]),
7825 d4(value[3]),
7826 d5(value[4])
7827 );
7828 };
7829 }
7830
7831
7832 function decodeTuple6(f, d1, d2, d3, d4, d5, d6) {
7833 return function(value) {
7834 if ( !(value instanceof Array) || value.length !== 6 ) {
7835 crash('a Tuple of length 6', value);
7836 }
7837 return A6( f,
7838 d1(value[0]),
7839 d2(value[1]),
7840 d3(value[2]),
7841 d4(value[3]),
7842 d5(value[4]),
7843 d6(value[5])
7844 );
7845 };
7846 }
7847
7848 function decodeTuple7(f, d1, d2, d3, d4, d5, d6, d7) {
7849 return function(value) {
7850 if ( !(value instanceof Array) || value.length !== 7 ) {
7851 crash('a Tuple of length 7', value);
7852 }
7853 return A7( f,
7854 d1(value[0]),
7855 d2(value[1]),
7856 d3(value[2]),
7857 d4(value[3]),
7858 d5(value[4]),
7859 d6(value[5]),
7860 d7(value[6])
7861 );
7862 };
7863 }
7864
7865
7866 function decodeTuple8(f, d1, d2, d3, d4, d5, d6, d7, d8) {
7867 return function(value) {
7868 if ( !(value instanceof Array) || value.length !== 8 ) {
7869 crash('a Tuple of length 8', value);
7870 }
7871 return A8( f,
7872 d1(value[0]),
7873 d2(value[1]),
7874 d3(value[2]),
7875 d4(value[3]),
7876 d5(value[4]),
7877 d6(value[5]),
7878 d7(value[6]),
7879 d8(value[7])
7880 );
7881 };
7882 }
7883
7884
7885 // CUSTOM DECODERS
7886
7887 function decodeValue(value) {
7888 return value;
7889 }
7890
7891 function runDecoderValue(decoder, value) {
7892 try {
7893 return Result.Ok(decoder(value));
7894 } catch(e) {
7895 return Result.Err(e.message);
7896 }
7897 }
7898
7899 function customDecoder(decoder, callback) {
7900 return function(value) {
7901 var result = callback(decoder(value));
7902 if (result.ctor === 'Err') {
7903 throw new Error('custom decoder failed: ' + result._0);
7904 }
7905 return result._0;
7906 };
7907 }
7908
7909 function andThen(decode, callback) {
7910 return function(value) {
7911 var result = decode(value);
7912 return callback(result)(value);
7913 };
7914 }
7915
7916 function fail(msg) {
7917 return function(value) {
7918 throw new Error(msg);
7919 };
7920 }
7921
7922 function succeed(successValue) {
7923 return function(value) {
7924 return successValue;
7925 };
7926 }
7927
7928
7929 // ONE OF MANY
7930
7931 function oneOf(decoders) {
7932 return function(value) {
7933 var errors = [];
7934 var temp = decoders;
7935 while (temp.ctor !== '[]') {
7936 try {
7937 return temp._0(value);
7938 } catch(e) {
7939 errors.push(e.message);
7940 }
7941 temp = temp._1;
7942 }
7943 throw new Error('expecting one of the following:\n ' + errors.join('\n '));
7944 };
7945 }
7946
7947 function get(decoder, value) {
7948 try {
7949 return Result.Ok(decoder(value));
7950 } catch(e) {
7951 return Result.Err(e.message);
7952 }
7953 }
7954
7955
7956 // ENCODE / DECODE
7957
7958 function runDecoderString(decoder, string) {
7959 try {
7960 return Result.Ok(decoder(JSON.parse(string)));
7961 } catch(e) {
7962 return Result.Err(e.message);
7963 }
7964 }
7965
7966 function encode(indentLevel, value) {
7967 return JSON.stringify(value, null, indentLevel);
7968 }
7969
7970 function identity(value) {
7971 return value;
7972 }
7973
7974 function encodeObject(keyValuePairs) {
7975 var obj = {};
7976 while (keyValuePairs.ctor !== '[]') {
7977 var pair = keyValuePairs._0;
7978 obj[pair._0] = pair._1;
7979 keyValuePairs = keyValuePairs._1;
7980 }
7981 return obj;
7982 }
7983
7984 return localRuntime.Native.Json.values = {
7985 encode: F2(encode),
7986 runDecoderString: F2(runDecoderString),
7987 runDecoderValue: F2(runDecoderValue),
7988
7989 get: F2(get),
7990 oneOf: oneOf,
7991
7992 decodeNull: decodeNull,
7993 decodeInt: decodeInt,
7994 decodeFloat: decodeFloat,
7995 decodeString: decodeString,
7996 decodeBool: decodeBool,
7997
7998 decodeMaybe: decodeMaybe,
7999
8000 decodeList: decodeList,
8001 decodeArray: decodeArray,
8002
8003 decodeField: F2(decodeField),
8004
8005 decodeObject1: F2(decodeObject1),
8006 decodeObject2: F3(decodeObject2),
8007 decodeObject3: F4(decodeObject3),
8008 decodeObject4: F5(decodeObject4),
8009 decodeObject5: F6(decodeObject5),
8010 decodeObject6: F7(decodeObject6),
8011 decodeObject7: F8(decodeObject7),
8012 decodeObject8: F9(decodeObject8),
8013 decodeKeyValuePairs: decodeKeyValuePairs,
8014
8015 decodeTuple1: F2(decodeTuple1),
8016 decodeTuple2: F3(decodeTuple2),
8017 decodeTuple3: F4(decodeTuple3),
8018 decodeTuple4: F5(decodeTuple4),
8019 decodeTuple5: F6(decodeTuple5),
8020 decodeTuple6: F7(decodeTuple6),
8021 decodeTuple7: F8(decodeTuple7),
8022 decodeTuple8: F9(decodeTuple8),
8023
8024 andThen: F2(andThen),
8025 decodeValue: decodeValue,
8026 customDecoder: F2(customDecoder),
8027 fail: fail,
8028 succeed: succeed,
8029
8030 identity: identity,
8031 encodeNull: null,
8032 encodeArray: ElmArray.toJSArray,
8033 encodeList: List.toArray,
8034 encodeObject: encodeObject
8035
8036 };
8037};
8038
8039Elm.Json = Elm.Json || {};
8040Elm.Json.Encode = Elm.Json.Encode || {};
8041Elm.Json.Encode.make = function (_elm) {
8042 "use strict";
8043 _elm.Json = _elm.Json || {};
8044 _elm.Json.Encode = _elm.Json.Encode || {};
8045 if (_elm.Json.Encode.values) return _elm.Json.Encode.values;
8046 var _U = Elm.Native.Utils.make(_elm),$Array = Elm.Array.make(_elm),$Native$Json = Elm.Native.Json.make(_elm);
8047 var _op = {};
8048 var list = $Native$Json.encodeList;
8049 var array = $Native$Json.encodeArray;
8050 var object = $Native$Json.encodeObject;
8051 var $null = $Native$Json.encodeNull;
8052 var bool = $Native$Json.identity;
8053 var $float = $Native$Json.identity;
8054 var $int = $Native$Json.identity;
8055 var string = $Native$Json.identity;
8056 var encode = $Native$Json.encode;
8057 var Value = {ctor: "Value"};
8058 return _elm.Json.Encode.values = {_op: _op
8059 ,encode: encode
8060 ,string: string
8061 ,$int: $int
8062 ,$float: $float
8063 ,bool: bool
8064 ,$null: $null
8065 ,list: list
8066 ,array: array
8067 ,object: object};
8068};
8069Elm.Native.String = {};
8070
8071Elm.Native.String.make = function(localRuntime) {
8072 localRuntime.Native = localRuntime.Native || {};
8073 localRuntime.Native.String = localRuntime.Native.String || {};
8074 if (localRuntime.Native.String.values)
8075 {
8076 return localRuntime.Native.String.values;
8077 }
8078 if ('values' in Elm.Native.String)
8079 {
8080 return localRuntime.Native.String.values = Elm.Native.String.values;
8081 }
8082
8083
8084 var Char = Elm.Char.make(localRuntime);
8085 var List = Elm.Native.List.make(localRuntime);
8086 var Maybe = Elm.Maybe.make(localRuntime);
8087 var Result = Elm.Result.make(localRuntime);
8088 var Utils = Elm.Native.Utils.make(localRuntime);
8089
8090 function isEmpty(str)
8091 {
8092 return str.length === 0;
8093 }
8094 function cons(chr, str)
8095 {
8096 return chr + str;
8097 }
8098 function uncons(str)
8099 {
8100 var hd = str[0];
8101 if (hd)
8102 {
8103 return Maybe.Just(Utils.Tuple2(Utils.chr(hd), str.slice(1)));
8104 }
8105 return Maybe.Nothing;
8106 }
8107 function append(a, b)
8108 {
8109 return a + b;
8110 }
8111 function concat(strs)
8112 {
8113 return List.toArray(strs).join('');
8114 }
8115 function length(str)
8116 {
8117 return str.length;
8118 }
8119 function map(f, str)
8120 {
8121 var out = str.split('');
8122 for (var i = out.length; i--; )
8123 {
8124 out[i] = f(Utils.chr(out[i]));
8125 }
8126 return out.join('');
8127 }
8128 function filter(pred, str)
8129 {
8130 return str.split('').map(Utils.chr).filter(pred).join('');
8131 }
8132 function reverse(str)
8133 {
8134 return str.split('').reverse().join('');
8135 }
8136 function foldl(f, b, str)
8137 {
8138 var len = str.length;
8139 for (var i = 0; i < len; ++i)
8140 {
8141 b = A2(f, Utils.chr(str[i]), b);
8142 }
8143 return b;
8144 }
8145 function foldr(f, b, str)
8146 {
8147 for (var i = str.length; i--; )
8148 {
8149 b = A2(f, Utils.chr(str[i]), b);
8150 }
8151 return b;
8152 }
8153 function split(sep, str)
8154 {
8155 return List.fromArray(str.split(sep));
8156 }
8157 function join(sep, strs)
8158 {
8159 return List.toArray(strs).join(sep);
8160 }
8161 function repeat(n, str)
8162 {
8163 var result = '';
8164 while (n > 0)
8165 {
8166 if (n & 1)
8167 {
8168 result += str;
8169 }
8170 n >>= 1, str += str;
8171 }
8172 return result;
8173 }
8174 function slice(start, end, str)
8175 {
8176 return str.slice(start, end);
8177 }
8178 function left(n, str)
8179 {
8180 return n < 1 ? '' : str.slice(0, n);
8181 }
8182 function right(n, str)
8183 {
8184 return n < 1 ? '' : str.slice(-n);
8185 }
8186 function dropLeft(n, str)
8187 {
8188 return n < 1 ? str : str.slice(n);
8189 }
8190 function dropRight(n, str)
8191 {
8192 return n < 1 ? str : str.slice(0, -n);
8193 }
8194 function pad(n, chr, str)
8195 {
8196 var half = (n - str.length) / 2;
8197 return repeat(Math.ceil(half), chr) + str + repeat(half | 0, chr);
8198 }
8199 function padRight(n, chr, str)
8200 {
8201 return str + repeat(n - str.length, chr);
8202 }
8203 function padLeft(n, chr, str)
8204 {
8205 return repeat(n - str.length, chr) + str;
8206 }
8207
8208 function trim(str)
8209 {
8210 return str.trim();
8211 }
8212 function trimLeft(str)
8213 {
8214 return str.replace(/^\s+/, '');
8215 }
8216 function trimRight(str)
8217 {
8218 return str.replace(/\s+$/, '');
8219 }
8220
8221 function words(str)
8222 {
8223 return List.fromArray(str.trim().split(/\s+/g));
8224 }
8225 function lines(str)
8226 {
8227 return List.fromArray(str.split(/\r\n|\r|\n/g));
8228 }
8229
8230 function toUpper(str)
8231 {
8232 return str.toUpperCase();
8233 }
8234 function toLower(str)
8235 {
8236 return str.toLowerCase();
8237 }
8238
8239 function any(pred, str)
8240 {
8241 for (var i = str.length; i--; )
8242 {
8243 if (pred(Utils.chr(str[i])))
8244 {
8245 return true;
8246 }
8247 }
8248 return false;
8249 }
8250 function all(pred, str)
8251 {
8252 for (var i = str.length; i--; )
8253 {
8254 if (!pred(Utils.chr(str[i])))
8255 {
8256 return false;
8257 }
8258 }
8259 return true;
8260 }
8261
8262 function contains(sub, str)
8263 {
8264 return str.indexOf(sub) > -1;
8265 }
8266 function startsWith(sub, str)
8267 {
8268 return str.indexOf(sub) === 0;
8269 }
8270 function endsWith(sub, str)
8271 {
8272 return str.length >= sub.length &&
8273 str.lastIndexOf(sub) === str.length - sub.length;
8274 }
8275 function indexes(sub, str)
8276 {
8277 var subLen = sub.length;
8278 var i = 0;
8279 var is = [];
8280 while ((i = str.indexOf(sub, i)) > -1)
8281 {
8282 is.push(i);
8283 i = i + subLen;
8284 }
8285 return List.fromArray(is);
8286 }
8287
8288 function toInt(s)
8289 {
8290 var len = s.length;
8291 if (len === 0)
8292 {
8293 return Result.Err("could not convert string '" + s + "' to an Int" );
8294 }
8295 var start = 0;
8296 if (s[0] === '-')
8297 {
8298 if (len === 1)
8299 {
8300 return Result.Err("could not convert string '" + s + "' to an Int" );
8301 }
8302 start = 1;
8303 }
8304 for (var i = start; i < len; ++i)
8305 {
8306 if (!Char.isDigit(s[i]))
8307 {
8308 return Result.Err("could not convert string '" + s + "' to an Int" );
8309 }
8310 }
8311 return Result.Ok(parseInt(s, 10));
8312 }
8313
8314 function toFloat(s)
8315 {
8316 var len = s.length;
8317 if (len === 0)
8318 {
8319 return Result.Err("could not convert string '" + s + "' to a Float" );
8320 }
8321 var start = 0;
8322 if (s[0] === '-')
8323 {
8324 if (len === 1)
8325 {
8326 return Result.Err("could not convert string '" + s + "' to a Float" );
8327 }
8328 start = 1;
8329 }
8330 var dotCount = 0;
8331 for (var i = start; i < len; ++i)
8332 {
8333 if (Char.isDigit(s[i]))
8334 {
8335 continue;
8336 }
8337 if (s[i] === '.')
8338 {
8339 dotCount += 1;
8340 if (dotCount <= 1)
8341 {
8342 continue;
8343 }
8344 }
8345 return Result.Err("could not convert string '" + s + "' to a Float" );
8346 }
8347 return Result.Ok(parseFloat(s));
8348 }
8349
8350 function toList(str)
8351 {
8352 return List.fromArray(str.split('').map(Utils.chr));
8353 }
8354 function fromList(chars)
8355 {
8356 return List.toArray(chars).join('');
8357 }
8358
8359 return Elm.Native.String.values = {
8360 isEmpty: isEmpty,
8361 cons: F2(cons),
8362 uncons: uncons,
8363 append: F2(append),
8364 concat: concat,
8365 length: length,
8366 map: F2(map),
8367 filter: F2(filter),
8368 reverse: reverse,
8369 foldl: F3(foldl),
8370 foldr: F3(foldr),
8371
8372 split: F2(split),
8373 join: F2(join),
8374 repeat: F2(repeat),
8375
8376 slice: F3(slice),
8377 left: F2(left),
8378 right: F2(right),
8379 dropLeft: F2(dropLeft),
8380 dropRight: F2(dropRight),
8381
8382 pad: F3(pad),
8383 padLeft: F3(padLeft),
8384 padRight: F3(padRight),
8385
8386 trim: trim,
8387 trimLeft: trimLeft,
8388 trimRight: trimRight,
8389
8390 words: words,
8391 lines: lines,
8392
8393 toUpper: toUpper,
8394 toLower: toLower,
8395
8396 any: F2(any),
8397 all: F2(all),
8398
8399 contains: F2(contains),
8400 startsWith: F2(startsWith),
8401 endsWith: F2(endsWith),
8402 indexes: F2(indexes),
8403
8404 toInt: toInt,
8405 toFloat: toFloat,
8406 toList: toList,
8407 fromList: fromList
8408 };
8409};
8410
8411Elm.Native.Char = {};
8412Elm.Native.Char.make = function(localRuntime) {
8413 localRuntime.Native = localRuntime.Native || {};
8414 localRuntime.Native.Char = localRuntime.Native.Char || {};
8415 if (localRuntime.Native.Char.values)
8416 {
8417 return localRuntime.Native.Char.values;
8418 }
8419
8420 var Utils = Elm.Native.Utils.make(localRuntime);
8421
8422 return localRuntime.Native.Char.values = {
8423 fromCode: function(c) { return Utils.chr(String.fromCharCode(c)); },
8424 toCode: function(c) { return c.charCodeAt(0); },
8425 toUpper: function(c) { return Utils.chr(c.toUpperCase()); },
8426 toLower: function(c) { return Utils.chr(c.toLowerCase()); },
8427 toLocaleUpper: function(c) { return Utils.chr(c.toLocaleUpperCase()); },
8428 toLocaleLower: function(c) { return Utils.chr(c.toLocaleLowerCase()); }
8429 };
8430};
8431
8432Elm.Char = Elm.Char || {};
8433Elm.Char.make = function (_elm) {
8434 "use strict";
8435 _elm.Char = _elm.Char || {};
8436 if (_elm.Char.values) return _elm.Char.values;
8437 var _U = Elm.Native.Utils.make(_elm),$Basics = Elm.Basics.make(_elm),$Native$Char = Elm.Native.Char.make(_elm);
8438 var _op = {};
8439 var fromCode = $Native$Char.fromCode;
8440 var toCode = $Native$Char.toCode;
8441 var toLocaleLower = $Native$Char.toLocaleLower;
8442 var toLocaleUpper = $Native$Char.toLocaleUpper;
8443 var toLower = $Native$Char.toLower;
8444 var toUpper = $Native$Char.toUpper;
8445 var isBetween = F3(function (low,high,$char) { var code = toCode($char);return _U.cmp(code,toCode(low)) > -1 && _U.cmp(code,toCode(high)) < 1;});
8446 var isUpper = A2(isBetween,_U.chr("A"),_U.chr("Z"));
8447 var isLower = A2(isBetween,_U.chr("a"),_U.chr("z"));
8448 var isDigit = A2(isBetween,_U.chr("0"),_U.chr("9"));
8449 var isOctDigit = A2(isBetween,_U.chr("0"),_U.chr("7"));
8450 var isHexDigit = function ($char) {
8451 return isDigit($char) || (A3(isBetween,_U.chr("a"),_U.chr("f"),$char) || A3(isBetween,_U.chr("A"),_U.chr("F"),$char));
8452 };
8453 return _elm.Char.values = {_op: _op
8454 ,isUpper: isUpper
8455 ,isLower: isLower
8456 ,isDigit: isDigit
8457 ,isOctDigit: isOctDigit
8458 ,isHexDigit: isHexDigit
8459 ,toUpper: toUpper
8460 ,toLower: toLower
8461 ,toLocaleUpper: toLocaleUpper
8462 ,toLocaleLower: toLocaleLower
8463 ,toCode: toCode
8464 ,fromCode: fromCode};
8465};
8466Elm.String = Elm.String || {};
8467Elm.String.make = function (_elm) {
8468 "use strict";
8469 _elm.String = _elm.String || {};
8470 if (_elm.String.values) return _elm.String.values;
8471 var _U = Elm.Native.Utils.make(_elm),$Maybe = Elm.Maybe.make(_elm),$Native$String = Elm.Native.String.make(_elm),$Result = Elm.Result.make(_elm);
8472 var _op = {};
8473 var fromList = $Native$String.fromList;
8474 var toList = $Native$String.toList;
8475 var toFloat = $Native$String.toFloat;
8476 var toInt = $Native$String.toInt;
8477 var indices = $Native$String.indexes;
8478 var indexes = $Native$String.indexes;
8479 var endsWith = $Native$String.endsWith;
8480 var startsWith = $Native$String.startsWith;
8481 var contains = $Native$String.contains;
8482 var all = $Native$String.all;
8483 var any = $Native$String.any;
8484 var toLower = $Native$String.toLower;
8485 var toUpper = $Native$String.toUpper;
8486 var lines = $Native$String.lines;
8487 var words = $Native$String.words;
8488 var trimRight = $Native$String.trimRight;
8489 var trimLeft = $Native$String.trimLeft;
8490 var trim = $Native$String.trim;
8491 var padRight = $Native$String.padRight;
8492 var padLeft = $Native$String.padLeft;
8493 var pad = $Native$String.pad;
8494 var dropRight = $Native$String.dropRight;
8495 var dropLeft = $Native$String.dropLeft;
8496 var right = $Native$String.right;
8497 var left = $Native$String.left;
8498 var slice = $Native$String.slice;
8499 var repeat = $Native$String.repeat;
8500 var join = $Native$String.join;
8501 var split = $Native$String.split;
8502 var foldr = $Native$String.foldr;
8503 var foldl = $Native$String.foldl;
8504 var reverse = $Native$String.reverse;
8505 var filter = $Native$String.filter;
8506 var map = $Native$String.map;
8507 var length = $Native$String.length;
8508 var concat = $Native$String.concat;
8509 var append = $Native$String.append;
8510 var uncons = $Native$String.uncons;
8511 var cons = $Native$String.cons;
8512 var fromChar = function ($char) { return A2(cons,$char,"");};
8513 var isEmpty = $Native$String.isEmpty;
8514 return _elm.String.values = {_op: _op
8515 ,isEmpty: isEmpty
8516 ,length: length
8517 ,reverse: reverse
8518 ,repeat: repeat
8519 ,cons: cons
8520 ,uncons: uncons
8521 ,fromChar: fromChar
8522 ,append: append
8523 ,concat: concat
8524 ,split: split
8525 ,join: join
8526 ,words: words
8527 ,lines: lines
8528 ,slice: slice
8529 ,left: left
8530 ,right: right
8531 ,dropLeft: dropLeft
8532 ,dropRight: dropRight
8533 ,contains: contains
8534 ,startsWith: startsWith
8535 ,endsWith: endsWith
8536 ,indexes: indexes
8537 ,indices: indices
8538 ,toInt: toInt
8539 ,toFloat: toFloat
8540 ,toList: toList
8541 ,fromList: fromList
8542 ,toUpper: toUpper
8543 ,toLower: toLower
8544 ,pad: pad
8545 ,padLeft: padLeft
8546 ,padRight: padRight
8547 ,trim: trim
8548 ,trimLeft: trimLeft
8549 ,trimRight: trimRight
8550 ,map: map
8551 ,filter: filter
8552 ,foldl: foldl
8553 ,foldr: foldr
8554 ,any: any
8555 ,all: all};
8556};
8557Elm.Dict = Elm.Dict || {};
8558Elm.Dict.make = function (_elm) {
8559 "use strict";
8560 _elm.Dict = _elm.Dict || {};
8561 if (_elm.Dict.values) return _elm.Dict.values;
8562 var _U = Elm.Native.Utils.make(_elm),
8563 $Basics = Elm.Basics.make(_elm),
8564 $List = Elm.List.make(_elm),
8565 $Maybe = Elm.Maybe.make(_elm),
8566 $Native$Debug = Elm.Native.Debug.make(_elm),
8567 $String = Elm.String.make(_elm);
8568 var _op = {};
8569 var foldr = F3(function (f,acc,t) {
8570 foldr: while (true) {
8571 var _p0 = t;
8572 if (_p0.ctor === "RBEmpty_elm_builtin") {
8573 return acc;
8574 } else {
8575 var _v1 = f,_v2 = A3(f,_p0._1,_p0._2,A3(foldr,f,acc,_p0._4)),_v3 = _p0._3;
8576 f = _v1;
8577 acc = _v2;
8578 t = _v3;
8579 continue foldr;
8580 }
8581 }
8582 });
8583 var keys = function (dict) { return A3(foldr,F3(function (key,value,keyList) { return A2($List._op["::"],key,keyList);}),_U.list([]),dict);};
8584 var values = function (dict) { return A3(foldr,F3(function (key,value,valueList) { return A2($List._op["::"],value,valueList);}),_U.list([]),dict);};
8585 var toList = function (dict) {
8586 return A3(foldr,F3(function (key,value,list) { return A2($List._op["::"],{ctor: "_Tuple2",_0: key,_1: value},list);}),_U.list([]),dict);
8587 };
8588 var foldl = F3(function (f,acc,dict) {
8589 foldl: while (true) {
8590 var _p1 = dict;
8591 if (_p1.ctor === "RBEmpty_elm_builtin") {
8592 return acc;
8593 } else {
8594 var _v5 = f,_v6 = A3(f,_p1._1,_p1._2,A3(foldl,f,acc,_p1._3)),_v7 = _p1._4;
8595 f = _v5;
8596 acc = _v6;
8597 dict = _v7;
8598 continue foldl;
8599 }
8600 }
8601 });
8602 var reportRemBug = F4(function (msg,c,lgot,rgot) {
8603 return $Native$Debug.crash($String.concat(_U.list(["Internal red-black tree invariant violated, expected "
8604 ,msg
8605 ," and got "
8606 ,$Basics.toString(c)
8607 ,"/"
8608 ,lgot
8609 ,"/"
8610 ,rgot
8611 ,"\nPlease report this bug to <https://github.com/elm-lang/core/issues>"])));
8612 });
8613 var isBBlack = function (dict) {
8614 var _p2 = dict;
8615 _v8_2: do {
8616 if (_p2.ctor === "RBNode_elm_builtin") {
8617 if (_p2._0.ctor === "BBlack") {
8618 return true;
8619 } else {
8620 break _v8_2;
8621 }
8622 } else {
8623 if (_p2._0.ctor === "LBBlack") {
8624 return true;
8625 } else {
8626 break _v8_2;
8627 }
8628 }
8629 } while (false);
8630 return false;
8631 };
8632 var Same = {ctor: "Same"};
8633 var Remove = {ctor: "Remove"};
8634 var Insert = {ctor: "Insert"};
8635 var sizeHelp = F2(function (n,dict) {
8636 sizeHelp: while (true) {
8637 var _p3 = dict;
8638 if (_p3.ctor === "RBEmpty_elm_builtin") {
8639 return n;
8640 } else {
8641 var _v10 = A2(sizeHelp,n + 1,_p3._4),_v11 = _p3._3;
8642 n = _v10;
8643 dict = _v11;
8644 continue sizeHelp;
8645 }
8646 }
8647 });
8648 var size = function (dict) { return A2(sizeHelp,0,dict);};
8649 var get = F2(function (targetKey,dict) {
8650 get: while (true) {
8651 var _p4 = dict;
8652 if (_p4.ctor === "RBEmpty_elm_builtin") {
8653 return $Maybe.Nothing;
8654 } else {
8655 var _p5 = A2($Basics.compare,targetKey,_p4._1);
8656 switch (_p5.ctor)
8657 {case "LT": var _v14 = targetKey,_v15 = _p4._3;
8658 targetKey = _v14;
8659 dict = _v15;
8660 continue get;
8661 case "EQ": return $Maybe.Just(_p4._2);
8662 default: var _v16 = targetKey,_v17 = _p4._4;
8663 targetKey = _v16;
8664 dict = _v17;
8665 continue get;}
8666 }
8667 }
8668 });
8669 var member = F2(function (key,dict) { var _p6 = A2(get,key,dict);if (_p6.ctor === "Just") { return true;} else { return false;}});
8670 var maxWithDefault = F3(function (k,v,r) {
8671 maxWithDefault: while (true) {
8672 var _p7 = r;
8673 if (_p7.ctor === "RBEmpty_elm_builtin") {
8674 return {ctor: "_Tuple2",_0: k,_1: v};
8675 } else {
8676 var _v20 = _p7._1,_v21 = _p7._2,_v22 = _p7._4;
8677 k = _v20;
8678 v = _v21;
8679 r = _v22;
8680 continue maxWithDefault;
8681 }
8682 }
8683 });
8684 var RBEmpty_elm_builtin = function (a) { return {ctor: "RBEmpty_elm_builtin",_0: a};};
8685 var RBNode_elm_builtin = F5(function (a,b,c,d,e) { return {ctor: "RBNode_elm_builtin",_0: a,_1: b,_2: c,_3: d,_4: e};});
8686 var LBBlack = {ctor: "LBBlack"};
8687 var LBlack = {ctor: "LBlack"};
8688 var empty = RBEmpty_elm_builtin(LBlack);
8689 var isEmpty = function (dict) { return _U.eq(dict,empty);};
8690 var map = F2(function (f,dict) {
8691 var _p8 = dict;
8692 if (_p8.ctor === "RBEmpty_elm_builtin") {
8693 return RBEmpty_elm_builtin(LBlack);
8694 } else {
8695 var _p9 = _p8._1;
8696 return A5(RBNode_elm_builtin,_p8._0,_p9,A2(f,_p9,_p8._2),A2(map,f,_p8._3),A2(map,f,_p8._4));
8697 }
8698 });
8699 var NBlack = {ctor: "NBlack"};
8700 var BBlack = {ctor: "BBlack"};
8701 var Black = {ctor: "Black"};
8702 var ensureBlackRoot = function (dict) {
8703 var _p10 = dict;
8704 if (_p10.ctor === "RBNode_elm_builtin" && _p10._0.ctor === "Red") {
8705 return A5(RBNode_elm_builtin,Black,_p10._1,_p10._2,_p10._3,_p10._4);
8706 } else {
8707 return dict;
8708 }
8709 };
8710 var blackish = function (t) {
8711 var _p11 = t;
8712 if (_p11.ctor === "RBNode_elm_builtin") {
8713 var _p12 = _p11._0;
8714 return _U.eq(_p12,Black) || _U.eq(_p12,BBlack);
8715 } else {
8716 return true;
8717 }
8718 };
8719 var blacken = function (t) {
8720 var _p13 = t;
8721 if (_p13.ctor === "RBEmpty_elm_builtin") {
8722 return RBEmpty_elm_builtin(LBlack);
8723 } else {
8724 return A5(RBNode_elm_builtin,Black,_p13._1,_p13._2,_p13._3,_p13._4);
8725 }
8726 };
8727 var Red = {ctor: "Red"};
8728 var moreBlack = function (color) {
8729 var _p14 = color;
8730 switch (_p14.ctor)
8731 {case "Black": return BBlack;
8732 case "Red": return Black;
8733 case "NBlack": return Red;
8734 default: return $Native$Debug.crash("Can\'t make a double black node more black!");}
8735 };
8736 var lessBlack = function (color) {
8737 var _p15 = color;
8738 switch (_p15.ctor)
8739 {case "BBlack": return Black;
8740 case "Black": return Red;
8741 case "Red": return NBlack;
8742 default: return $Native$Debug.crash("Can\'t make a negative black node less black!");}
8743 };
8744 var lessBlackTree = function (dict) {
8745 var _p16 = dict;
8746 if (_p16.ctor === "RBNode_elm_builtin") {
8747 return A5(RBNode_elm_builtin,lessBlack(_p16._0),_p16._1,_p16._2,_p16._3,_p16._4);
8748 } else {
8749 return RBEmpty_elm_builtin(LBlack);
8750 }
8751 };
8752 var balancedTree = function (col) {
8753 return function (xk) {
8754 return function (xv) {
8755 return function (yk) {
8756 return function (yv) {
8757 return function (zk) {
8758 return function (zv) {
8759 return function (a) {
8760 return function (b) {
8761 return function (c) {
8762 return function (d) {
8763 return A5(RBNode_elm_builtin,
8764 lessBlack(col),
8765 yk,
8766 yv,
8767 A5(RBNode_elm_builtin,Black,xk,xv,a,b),
8768 A5(RBNode_elm_builtin,Black,zk,zv,c,d));
8769 };
8770 };
8771 };
8772 };
8773 };
8774 };
8775 };
8776 };
8777 };
8778 };
8779 };
8780 var redden = function (t) {
8781 var _p17 = t;
8782 if (_p17.ctor === "RBEmpty_elm_builtin") {
8783 return $Native$Debug.crash("can\'t make a Leaf red");
8784 } else {
8785 return A5(RBNode_elm_builtin,Red,_p17._1,_p17._2,_p17._3,_p17._4);
8786 }
8787 };
8788 var balanceHelp = function (tree) {
8789 var _p18 = tree;
8790 _v31_6: do {
8791 _v31_5: do {
8792 _v31_4: do {
8793 _v31_3: do {
8794 _v31_2: do {
8795 _v31_1: do {
8796 _v31_0: do {
8797 if (_p18.ctor === "RBNode_elm_builtin") {
8798 if (_p18._3.ctor === "RBNode_elm_builtin") {
8799 if (_p18._4.ctor === "RBNode_elm_builtin") {
8800 switch (_p18._3._0.ctor)
8801 {case "Red": switch (_p18._4._0.ctor)
8802 {case "Red": if (_p18._3._3.ctor === "RBNode_elm_builtin" && _p18._3._3._0.ctor === "Red") {
8803 break _v31_0;
8804 } else {
8805 if (_p18._3._4.ctor === "RBNode_elm_builtin" && _p18._3._4._0.ctor === "Red") {
8806 break _v31_1;
8807 } else {
8808 if (_p18._4._3.ctor === "RBNode_elm_builtin" && _p18._4._3._0.ctor === "Red") {
8809 break _v31_2;
8810 } else {
8811 if (_p18._4._4.ctor === "RBNode_elm_builtin" && _p18._4._4._0.ctor === "Red") {
8812 break _v31_3;
8813 } else {
8814 break _v31_6;
8815 }
8816 }
8817 }
8818 }
8819 case "NBlack": if (_p18._3._3.ctor === "RBNode_elm_builtin" && _p18._3._3._0.ctor === "Red") {
8820 break _v31_0;
8821 } else {
8822 if (_p18._3._4.ctor === "RBNode_elm_builtin" && _p18._3._4._0.ctor === "Red") {
8823 break _v31_1;
8824 } else {
8825 if (_p18._0.ctor === "BBlack" && _p18._4._3.ctor === "RBNode_elm_builtin" && _p18._4._3._0.ctor === "Black" && _p18._4._4.ctor === "RBNode_elm_builtin" && _p18._4._4._0.ctor === "Black")
8826 {
8827 break _v31_4;
8828 } else {
8829 break _v31_6;
8830 }
8831 }
8832 }
8833 default: if (_p18._3._3.ctor === "RBNode_elm_builtin" && _p18._3._3._0.ctor === "Red") {
8834 break _v31_0;
8835 } else {
8836 if (_p18._3._4.ctor === "RBNode_elm_builtin" && _p18._3._4._0.ctor === "Red") {
8837 break _v31_1;
8838 } else {
8839 break _v31_6;
8840 }
8841 }}
8842 case "NBlack": switch (_p18._4._0.ctor)
8843 {case "Red": if (_p18._4._3.ctor === "RBNode_elm_builtin" && _p18._4._3._0.ctor === "Red") {
8844 break _v31_2;
8845 } else {
8846 if (_p18._4._4.ctor === "RBNode_elm_builtin" && _p18._4._4._0.ctor === "Red") {
8847 break _v31_3;
8848 } else {
8849 if (_p18._0.ctor === "BBlack" && _p18._3._3.ctor === "RBNode_elm_builtin" && _p18._3._3._0.ctor === "Black" && _p18._3._4.ctor === "RBNode_elm_builtin" && _p18._3._4._0.ctor === "Black")
8850 {
8851 break _v31_5;
8852 } else {
8853 break _v31_6;
8854 }
8855 }
8856 }
8857 case "NBlack": if (_p18._0.ctor === "BBlack") {
8858 if (_p18._4._3.ctor === "RBNode_elm_builtin" && _p18._4._3._0.ctor === "Black" && _p18._4._4.ctor === "RBNode_elm_builtin" && _p18._4._4._0.ctor === "Black")
8859 {
8860 break _v31_4;
8861 } else {
8862 if (_p18._3._3.ctor === "RBNode_elm_builtin" && _p18._3._3._0.ctor === "Black" && _p18._3._4.ctor === "RBNode_elm_builtin" && _p18._3._4._0.ctor === "Black")
8863 {
8864 break _v31_5;
8865 } else {
8866 break _v31_6;
8867 }
8868 }
8869 } else {
8870 break _v31_6;
8871 }
8872 default:
8873 if (_p18._0.ctor === "BBlack" && _p18._3._3.ctor === "RBNode_elm_builtin" && _p18._3._3._0.ctor === "Black" && _p18._3._4.ctor === "RBNode_elm_builtin" && _p18._3._4._0.ctor === "Black")
8874 {
8875 break _v31_5;
8876 } else {
8877 break _v31_6;
8878 }}
8879 default: switch (_p18._4._0.ctor)
8880 {case "Red": if (_p18._4._3.ctor === "RBNode_elm_builtin" && _p18._4._3._0.ctor === "Red") {
8881 break _v31_2;
8882 } else {
8883 if (_p18._4._4.ctor === "RBNode_elm_builtin" && _p18._4._4._0.ctor === "Red") {
8884 break _v31_3;
8885 } else {
8886 break _v31_6;
8887 }
8888 }
8889 case "NBlack":
8890 if (_p18._0.ctor === "BBlack" && _p18._4._3.ctor === "RBNode_elm_builtin" && _p18._4._3._0.ctor === "Black" && _p18._4._4.ctor === "RBNode_elm_builtin" && _p18._4._4._0.ctor === "Black")
8891 {
8892 break _v31_4;
8893 } else {
8894 break _v31_6;
8895 }
8896 default: break _v31_6;}}
8897 } else {
8898 switch (_p18._3._0.ctor)
8899 {case "Red": if (_p18._3._3.ctor === "RBNode_elm_builtin" && _p18._3._3._0.ctor === "Red") {
8900 break _v31_0;
8901 } else {
8902 if (_p18._3._4.ctor === "RBNode_elm_builtin" && _p18._3._4._0.ctor === "Red") {
8903 break _v31_1;
8904 } else {
8905 break _v31_6;
8906 }
8907 }
8908 case "NBlack":
8909 if (_p18._0.ctor === "BBlack" && _p18._3._3.ctor === "RBNode_elm_builtin" && _p18._3._3._0.ctor === "Black" && _p18._3._4.ctor === "RBNode_elm_builtin" && _p18._3._4._0.ctor === "Black")
8910 {
8911 break _v31_5;
8912 } else {
8913 break _v31_6;
8914 }
8915 default: break _v31_6;}
8916 }
8917 } else {
8918 if (_p18._4.ctor === "RBNode_elm_builtin") {
8919 switch (_p18._4._0.ctor)
8920 {case "Red": if (_p18._4._3.ctor === "RBNode_elm_builtin" && _p18._4._3._0.ctor === "Red") {
8921 break _v31_2;
8922 } else {
8923 if (_p18._4._4.ctor === "RBNode_elm_builtin" && _p18._4._4._0.ctor === "Red") {
8924 break _v31_3;
8925 } else {
8926 break _v31_6;
8927 }
8928 }
8929 case "NBlack":
8930 if (_p18._0.ctor === "BBlack" && _p18._4._3.ctor === "RBNode_elm_builtin" && _p18._4._3._0.ctor === "Black" && _p18._4._4.ctor === "RBNode_elm_builtin" && _p18._4._4._0.ctor === "Black")
8931 {
8932 break _v31_4;
8933 } else {
8934 break _v31_6;
8935 }
8936 default: break _v31_6;}
8937 } else {
8938 break _v31_6;
8939 }
8940 }
8941 } else {
8942 break _v31_6;
8943 }
8944 } while (false);
8945 return balancedTree(_p18._0)(_p18._3._3._1)(_p18._3._3._2)(_p18._3._1)(_p18._3._2)(_p18._1)(_p18._2)(_p18._3._3._3)(_p18._3._3._4)(_p18._3._4)(_p18._4);
8946 } while (false);
8947 return balancedTree(_p18._0)(_p18._3._1)(_p18._3._2)(_p18._3._4._1)(_p18._3._4._2)(_p18._1)(_p18._2)(_p18._3._3)(_p18._3._4._3)(_p18._3._4._4)(_p18._4);
8948 } while (false);
8949 return balancedTree(_p18._0)(_p18._1)(_p18._2)(_p18._4._3._1)(_p18._4._3._2)(_p18._4._1)(_p18._4._2)(_p18._3)(_p18._4._3._3)(_p18._4._3._4)(_p18._4._4);
8950 } while (false);
8951 return balancedTree(_p18._0)(_p18._1)(_p18._2)(_p18._4._1)(_p18._4._2)(_p18._4._4._1)(_p18._4._4._2)(_p18._3)(_p18._4._3)(_p18._4._4._3)(_p18._4._4._4);
8952 } while (false);
8953 return A5(RBNode_elm_builtin,
8954 Black,
8955 _p18._4._3._1,
8956 _p18._4._3._2,
8957 A5(RBNode_elm_builtin,Black,_p18._1,_p18._2,_p18._3,_p18._4._3._3),
8958 A5(balance,Black,_p18._4._1,_p18._4._2,_p18._4._3._4,redden(_p18._4._4)));
8959 } while (false);
8960 return A5(RBNode_elm_builtin,
8961 Black,
8962 _p18._3._4._1,
8963 _p18._3._4._2,
8964 A5(balance,Black,_p18._3._1,_p18._3._2,redden(_p18._3._3),_p18._3._4._3),
8965 A5(RBNode_elm_builtin,Black,_p18._1,_p18._2,_p18._3._4._4,_p18._4));
8966 } while (false);
8967 return tree;
8968 };
8969 var balance = F5(function (c,k,v,l,r) { var tree = A5(RBNode_elm_builtin,c,k,v,l,r);return blackish(tree) ? balanceHelp(tree) : tree;});
8970 var bubble = F5(function (c,k,v,l,r) {
8971 return isBBlack(l) || isBBlack(r) ? A5(balance,moreBlack(c),k,v,lessBlackTree(l),lessBlackTree(r)) : A5(RBNode_elm_builtin,c,k,v,l,r);
8972 });
8973 var removeMax = F5(function (c,k,v,l,r) {
8974 var _p19 = r;
8975 if (_p19.ctor === "RBEmpty_elm_builtin") {
8976 return A3(rem,c,l,r);
8977 } else {
8978 return A5(bubble,c,k,v,l,A5(removeMax,_p19._0,_p19._1,_p19._2,_p19._3,_p19._4));
8979 }
8980 });
8981 var rem = F3(function (c,l,r) {
8982 var _p20 = {ctor: "_Tuple2",_0: l,_1: r};
8983 if (_p20._0.ctor === "RBEmpty_elm_builtin") {
8984 if (_p20._1.ctor === "RBEmpty_elm_builtin") {
8985 var _p21 = c;
8986 switch (_p21.ctor)
8987 {case "Red": return RBEmpty_elm_builtin(LBlack);
8988 case "Black": return RBEmpty_elm_builtin(LBBlack);
8989 default: return $Native$Debug.crash("cannot have bblack or nblack nodes at this point");}
8990 } else {
8991 var _p24 = _p20._1._0;
8992 var _p23 = _p20._0._0;
8993 var _p22 = {ctor: "_Tuple3",_0: c,_1: _p23,_2: _p24};
8994 if (_p22.ctor === "_Tuple3" && _p22._0.ctor === "Black" && _p22._1.ctor === "LBlack" && _p22._2.ctor === "Red") {
8995 return A5(RBNode_elm_builtin,Black,_p20._1._1,_p20._1._2,_p20._1._3,_p20._1._4);
8996 } else {
8997 return A4(reportRemBug,"Black/LBlack/Red",c,$Basics.toString(_p23),$Basics.toString(_p24));
8998 }
8999 }
9000 } else {
9001 if (_p20._1.ctor === "RBEmpty_elm_builtin") {
9002 var _p27 = _p20._1._0;
9003 var _p26 = _p20._0._0;
9004 var _p25 = {ctor: "_Tuple3",_0: c,_1: _p26,_2: _p27};
9005 if (_p25.ctor === "_Tuple3" && _p25._0.ctor === "Black" && _p25._1.ctor === "Red" && _p25._2.ctor === "LBlack") {
9006 return A5(RBNode_elm_builtin,Black,_p20._0._1,_p20._0._2,_p20._0._3,_p20._0._4);
9007 } else {
9008 return A4(reportRemBug,"Black/Red/LBlack",c,$Basics.toString(_p26),$Basics.toString(_p27));
9009 }
9010 } else {
9011 var _p31 = _p20._0._2;
9012 var _p30 = _p20._0._4;
9013 var _p29 = _p20._0._1;
9014 var l$ = A5(removeMax,_p20._0._0,_p29,_p31,_p20._0._3,_p30);
9015 var _p28 = A3(maxWithDefault,_p29,_p31,_p30);
9016 var k = _p28._0;
9017 var v = _p28._1;
9018 return A5(bubble,c,k,v,l$,r);
9019 }
9020 }
9021 });
9022 var update = F3(function (k,alter,dict) {
9023 var up = function (dict) {
9024 var _p32 = dict;
9025 if (_p32.ctor === "RBEmpty_elm_builtin") {
9026 var _p33 = alter($Maybe.Nothing);
9027 if (_p33.ctor === "Nothing") {
9028 return {ctor: "_Tuple2",_0: Same,_1: empty};
9029 } else {
9030 return {ctor: "_Tuple2",_0: Insert,_1: A5(RBNode_elm_builtin,Red,k,_p33._0,empty,empty)};
9031 }
9032 } else {
9033 var _p44 = _p32._2;
9034 var _p43 = _p32._4;
9035 var _p42 = _p32._3;
9036 var _p41 = _p32._1;
9037 var _p40 = _p32._0;
9038 var _p34 = A2($Basics.compare,k,_p41);
9039 switch (_p34.ctor)
9040 {case "EQ": var _p35 = alter($Maybe.Just(_p44));
9041 if (_p35.ctor === "Nothing") {
9042 return {ctor: "_Tuple2",_0: Remove,_1: A3(rem,_p40,_p42,_p43)};
9043 } else {
9044 return {ctor: "_Tuple2",_0: Same,_1: A5(RBNode_elm_builtin,_p40,_p41,_p35._0,_p42,_p43)};
9045 }
9046 case "LT": var _p36 = up(_p42);
9047 var flag = _p36._0;
9048 var newLeft = _p36._1;
9049 var _p37 = flag;
9050 switch (_p37.ctor)
9051 {case "Same": return {ctor: "_Tuple2",_0: Same,_1: A5(RBNode_elm_builtin,_p40,_p41,_p44,newLeft,_p43)};
9052 case "Insert": return {ctor: "_Tuple2",_0: Insert,_1: A5(balance,_p40,_p41,_p44,newLeft,_p43)};
9053 default: return {ctor: "_Tuple2",_0: Remove,_1: A5(bubble,_p40,_p41,_p44,newLeft,_p43)};}
9054 default: var _p38 = up(_p43);
9055 var flag = _p38._0;
9056 var newRight = _p38._1;
9057 var _p39 = flag;
9058 switch (_p39.ctor)
9059 {case "Same": return {ctor: "_Tuple2",_0: Same,_1: A5(RBNode_elm_builtin,_p40,_p41,_p44,_p42,newRight)};
9060 case "Insert": return {ctor: "_Tuple2",_0: Insert,_1: A5(balance,_p40,_p41,_p44,_p42,newRight)};
9061 default: return {ctor: "_Tuple2",_0: Remove,_1: A5(bubble,_p40,_p41,_p44,_p42,newRight)};}}
9062 }
9063 };
9064 var _p45 = up(dict);
9065 var flag = _p45._0;
9066 var updatedDict = _p45._1;
9067 var _p46 = flag;
9068 switch (_p46.ctor)
9069 {case "Same": return updatedDict;
9070 case "Insert": return ensureBlackRoot(updatedDict);
9071 default: return blacken(updatedDict);}
9072 });
9073 var insert = F3(function (key,value,dict) { return A3(update,key,$Basics.always($Maybe.Just(value)),dict);});
9074 var singleton = F2(function (key,value) { return A3(insert,key,value,empty);});
9075 var union = F2(function (t1,t2) { return A3(foldl,insert,t2,t1);});
9076 var fromList = function (assocs) {
9077 return A3($List.foldl,F2(function (_p47,dict) { var _p48 = _p47;return A3(insert,_p48._0,_p48._1,dict);}),empty,assocs);
9078 };
9079 var filter = F2(function (predicate,dictionary) {
9080 var add = F3(function (key,value,dict) { return A2(predicate,key,value) ? A3(insert,key,value,dict) : dict;});
9081 return A3(foldl,add,empty,dictionary);
9082 });
9083 var intersect = F2(function (t1,t2) { return A2(filter,F2(function (k,_p49) { return A2(member,k,t2);}),t1);});
9084 var partition = F2(function (predicate,dict) {
9085 var add = F3(function (key,value,_p50) {
9086 var _p51 = _p50;
9087 var _p53 = _p51._1;
9088 var _p52 = _p51._0;
9089 return A2(predicate,key,value) ? {ctor: "_Tuple2",_0: A3(insert,key,value,_p52),_1: _p53} : {ctor: "_Tuple2",_0: _p52,_1: A3(insert,key,value,_p53)};
9090 });
9091 return A3(foldl,add,{ctor: "_Tuple2",_0: empty,_1: empty},dict);
9092 });
9093 var remove = F2(function (key,dict) { return A3(update,key,$Basics.always($Maybe.Nothing),dict);});
9094 var diff = F2(function (t1,t2) { return A3(foldl,F3(function (k,v,t) { return A2(remove,k,t);}),t1,t2);});
9095 return _elm.Dict.values = {_op: _op
9096 ,empty: empty
9097 ,singleton: singleton
9098 ,insert: insert
9099 ,update: update
9100 ,isEmpty: isEmpty
9101 ,get: get
9102 ,remove: remove
9103 ,member: member
9104 ,size: size
9105 ,filter: filter
9106 ,partition: partition
9107 ,foldl: foldl
9108 ,foldr: foldr
9109 ,map: map
9110 ,union: union
9111 ,intersect: intersect
9112 ,diff: diff
9113 ,keys: keys
9114 ,values: values
9115 ,toList: toList
9116 ,fromList: fromList};
9117};
9118Elm.Json = Elm.Json || {};
9119Elm.Json.Decode = Elm.Json.Decode || {};
9120Elm.Json.Decode.make = function (_elm) {
9121 "use strict";
9122 _elm.Json = _elm.Json || {};
9123 _elm.Json.Decode = _elm.Json.Decode || {};
9124 if (_elm.Json.Decode.values) return _elm.Json.Decode.values;
9125 var _U = Elm.Native.Utils.make(_elm),
9126 $Array = Elm.Array.make(_elm),
9127 $Dict = Elm.Dict.make(_elm),
9128 $Json$Encode = Elm.Json.Encode.make(_elm),
9129 $List = Elm.List.make(_elm),
9130 $Maybe = Elm.Maybe.make(_elm),
9131 $Native$Json = Elm.Native.Json.make(_elm),
9132 $Result = Elm.Result.make(_elm);
9133 var _op = {};
9134 var tuple8 = $Native$Json.decodeTuple8;
9135 var tuple7 = $Native$Json.decodeTuple7;
9136 var tuple6 = $Native$Json.decodeTuple6;
9137 var tuple5 = $Native$Json.decodeTuple5;
9138 var tuple4 = $Native$Json.decodeTuple4;
9139 var tuple3 = $Native$Json.decodeTuple3;
9140 var tuple2 = $Native$Json.decodeTuple2;
9141 var tuple1 = $Native$Json.decodeTuple1;
9142 var succeed = $Native$Json.succeed;
9143 var fail = $Native$Json.fail;
9144 var andThen = $Native$Json.andThen;
9145 var customDecoder = $Native$Json.customDecoder;
9146 var decodeValue = $Native$Json.runDecoderValue;
9147 var value = $Native$Json.decodeValue;
9148 var maybe = $Native$Json.decodeMaybe;
9149 var $null = $Native$Json.decodeNull;
9150 var array = $Native$Json.decodeArray;
9151 var list = $Native$Json.decodeList;
9152 var bool = $Native$Json.decodeBool;
9153 var $int = $Native$Json.decodeInt;
9154 var $float = $Native$Json.decodeFloat;
9155 var string = $Native$Json.decodeString;
9156 var oneOf = $Native$Json.oneOf;
9157 var keyValuePairs = $Native$Json.decodeKeyValuePairs;
9158 var object8 = $Native$Json.decodeObject8;
9159 var object7 = $Native$Json.decodeObject7;
9160 var object6 = $Native$Json.decodeObject6;
9161 var object5 = $Native$Json.decodeObject5;
9162 var object4 = $Native$Json.decodeObject4;
9163 var object3 = $Native$Json.decodeObject3;
9164 var object2 = $Native$Json.decodeObject2;
9165 var object1 = $Native$Json.decodeObject1;
9166 _op[":="] = $Native$Json.decodeField;
9167 var at = F2(function (fields,decoder) { return A3($List.foldr,F2(function (x,y) { return A2(_op[":="],x,y);}),decoder,fields);});
9168 var decodeString = $Native$Json.runDecoderString;
9169 var map = $Native$Json.decodeObject1;
9170 var dict = function (decoder) { return A2(map,$Dict.fromList,keyValuePairs(decoder));};
9171 var Decoder = {ctor: "Decoder"};
9172 return _elm.Json.Decode.values = {_op: _op
9173 ,decodeString: decodeString
9174 ,decodeValue: decodeValue
9175 ,string: string
9176 ,$int: $int
9177 ,$float: $float
9178 ,bool: bool
9179 ,$null: $null
9180 ,list: list
9181 ,array: array
9182 ,tuple1: tuple1
9183 ,tuple2: tuple2
9184 ,tuple3: tuple3
9185 ,tuple4: tuple4
9186 ,tuple5: tuple5
9187 ,tuple6: tuple6
9188 ,tuple7: tuple7
9189 ,tuple8: tuple8
9190 ,at: at
9191 ,object1: object1
9192 ,object2: object2
9193 ,object3: object3
9194 ,object4: object4
9195 ,object5: object5
9196 ,object6: object6
9197 ,object7: object7
9198 ,object8: object8
9199 ,keyValuePairs: keyValuePairs
9200 ,dict: dict
9201 ,maybe: maybe
9202 ,oneOf: oneOf
9203 ,map: map
9204 ,fail: fail
9205 ,succeed: succeed
9206 ,andThen: andThen
9207 ,value: value
9208 ,customDecoder: customDecoder};
9209};
9210Elm.ElmFire = Elm.ElmFire || {};
9211Elm.ElmFire.make = function (_elm) {
9212 "use strict";
9213 _elm.ElmFire = _elm.ElmFire || {};
9214 if (_elm.ElmFire.values) return _elm.ElmFire.values;
9215 var _U = Elm.Native.Utils.make(_elm),
9216 $Basics = Elm.Basics.make(_elm),
9217 $Debug = Elm.Debug.make(_elm),
9218 $Json$Decode = Elm.Json.Decode.make(_elm),
9219 $Json$Encode = Elm.Json.Encode.make(_elm),
9220 $List = Elm.List.make(_elm),
9221 $Maybe = Elm.Maybe.make(_elm),
9222 $Native$ElmFire = Elm.Native.ElmFire.make(_elm),
9223 $Result = Elm.Result.make(_elm),
9224 $Signal = Elm.Signal.make(_elm),
9225 $Task = Elm.Task.make(_elm),
9226 $Time = Elm.Time.make(_elm);
9227 var _op = {};
9228 var serverTimeStamp = $Native$ElmFire.serverTimeStamp;
9229 var goOnline = $Native$ElmFire.setOffline(false);
9230 var goOffline = $Native$ElmFire.setOffline(true);
9231 var exportValue = $Native$ElmFire.exportValue;
9232 var toPairList = $Native$ElmFire.toPairList;
9233 var toKeyList = $Native$ElmFire.toKeyList;
9234 var toValueList = $Native$ElmFire.toValueList;
9235 var toSnapshotList = $Native$ElmFire.toSnapshotList;
9236 var LimitToLast = function (a) { return {ctor: "LimitToLast",_0: a};};
9237 var limitToLast = LimitToLast;
9238 var LimitToFirst = function (a) { return {ctor: "LimitToFirst",_0: a};};
9239 var limitToFirst = LimitToFirst;
9240 var NoLimit = {ctor: "NoLimit"};
9241 var noLimit = NoLimit;
9242 var EqualTo = function (a) { return {ctor: "EqualTo",_0: a};};
9243 var equalTo = EqualTo;
9244 var Range = F2(function (a,b) { return {ctor: "Range",_0: a,_1: b};});
9245 var range = Range;
9246 var EndAt = function (a) { return {ctor: "EndAt",_0: a};};
9247 var endAt = EndAt;
9248 var StartAt = function (a) { return {ctor: "StartAt",_0: a};};
9249 var startAt = StartAt;
9250 var NoRange = {ctor: "NoRange"};
9251 var noRange = NoRange;
9252 var OrderByPriority = F2(function (a,b) { return {ctor: "OrderByPriority",_0: a,_1: b};});
9253 var orderByPriority = OrderByPriority;
9254 var OrderByKey = F2(function (a,b) { return {ctor: "OrderByKey",_0: a,_1: b};});
9255 var orderByKey = OrderByKey;
9256 var OrderByValue = F2(function (a,b) { return {ctor: "OrderByValue",_0: a,_1: b};});
9257 var orderByValue = OrderByValue;
9258 var OrderByChild = F3(function (a,b,c) { return {ctor: "OrderByChild",_0: a,_1: b,_2: c};});
9259 var orderByChild = OrderByChild;
9260 var NoOrder = {ctor: "NoOrder"};
9261 var noOrder = NoOrder;
9262 var ChildMoved = function (a) { return {ctor: "ChildMoved",_0: a};};
9263 var childMoved = ChildMoved;
9264 var ChildRemoved = function (a) { return {ctor: "ChildRemoved",_0: a};};
9265 var childRemoved = ChildRemoved;
9266 var ChildChanged = function (a) { return {ctor: "ChildChanged",_0: a};};
9267 var childChanged = ChildChanged;
9268 var ChildAdded = function (a) { return {ctor: "ChildAdded",_0: a};};
9269 var childAdded = ChildAdded;
9270 var ValueChanged = function (a) { return {ctor: "ValueChanged",_0: a};};
9271 var valueChanged = ValueChanged;
9272 var once = $Native$ElmFire.once;
9273 var unsubscribe = $Native$ElmFire.unsubscribe;
9274 var subscribeConditional = $Native$ElmFire.subscribeConditional;
9275 var subscribe = function (createResponseTask) { return subscribeConditional(function (_p0) { return $Maybe.Just(createResponseTask(_p0));});};
9276 var onDisconnectCancel = $Native$ElmFire.onDisconnectCancel;
9277 var onDisconnectRemove = $Native$ElmFire.remove(true);
9278 var onDisconnectUpdate = $Native$ElmFire.update(true);
9279 var onDisconnectSetWithPriority = $Native$ElmFire.setWithPriority(true);
9280 var onDisconnectSet = $Native$ElmFire.set(true);
9281 var transaction = $Native$ElmFire.transaction;
9282 var remove = $Native$ElmFire.remove(false);
9283 var update = $Native$ElmFire.update(false);
9284 var setPriority = $Native$ElmFire.setPriority;
9285 var setWithPriority = $Native$ElmFire.setWithPriority(false);
9286 var set = $Native$ElmFire.set(false);
9287 var open = $Native$ElmFire.open;
9288 var key = $Native$ElmFire.key;
9289 var toUrl = $Native$ElmFire.toUrl;
9290 var Set = function (a) { return {ctor: "Set",_0: a};};
9291 var Remove = {ctor: "Remove"};
9292 var Abort = {ctor: "Abort"};
9293 var SnapshotFB = {ctor: "SnapshotFB"};
9294 var Snapshot = F8(function (a,b,c,d,e,f,g,h) { return {subscription: a,key: b,reference: c,existing: d,value: e,prevKey: f,priority: g,intern_: h};});
9295 var QueryError = F2(function (a,b) { return {ctor: "QueryError",_0: a,_1: b};});
9296 var Unsubscribed = function (a) { return {ctor: "Unsubscribed",_0: a};};
9297 var Subscription = {ctor: "Subscription"};
9298 var StringPriority = function (a) { return {ctor: "StringPriority",_0: a};};
9299 var NumberPriority = function (a) { return {ctor: "NumberPriority",_0: a};};
9300 var NoPriority = {ctor: "NoPriority"};
9301 var Reference = {ctor: "Reference"};
9302 var RefLocation = function (a) { return {ctor: "RefLocation",_0: a};};
9303 var location = RefLocation;
9304 var PushLocation = function (a) { return {ctor: "PushLocation",_0: a};};
9305 var push = PushLocation;
9306 var RootLocation = function (a) { return {ctor: "RootLocation",_0: a};};
9307 var root = RootLocation;
9308 var ParentLocation = function (a) { return {ctor: "ParentLocation",_0: a};};
9309 var parent = ParentLocation;
9310 var SubLocation = F2(function (a,b) { return {ctor: "SubLocation",_0: a,_1: b};});
9311 var sub = SubLocation;
9312 var subscribeConnected = F2(function (createResponseTask,location) {
9313 return A4(subscribeConditional,
9314 function (snapshot) {
9315 var _p1 = A2($Json$Decode.decodeValue,$Json$Decode.bool,snapshot.value);
9316 if (_p1.ctor === "Ok") {
9317 return $Maybe.Just(createResponseTask(_p1._0));
9318 } else {
9319 return $Maybe.Nothing;
9320 }
9321 },
9322 $Basics.always($Task.succeed({ctor: "_Tuple0"})),
9323 valueChanged(noOrder),
9324 A2(sub,".info/connected",root(location)));
9325 });
9326 var subscribeServerTimeOffset = F2(function (createResponseTask,location) {
9327 return A4(subscribeConditional,
9328 function (snapshot) {
9329 var _p2 = A2($Json$Decode.decodeValue,$Json$Decode.$float,snapshot.value);
9330 if (_p2.ctor === "Ok") {
9331 return $Maybe.Just(createResponseTask(_p2._0 * $Time.millisecond));
9332 } else {
9333 return $Maybe.Nothing;
9334 }
9335 },
9336 $Basics.always($Task.succeed({ctor: "_Tuple0"})),
9337 valueChanged(noOrder),
9338 A2(sub,".info/serverTimeOffset",root(location)));
9339 });
9340 var UrlLocation = function (a) { return {ctor: "UrlLocation",_0: a};};
9341 var fromUrl = UrlLocation;
9342 var OtherAuthenticationError = {ctor: "OtherAuthenticationError"};
9343 var UserDenied = {ctor: "UserDenied"};
9344 var UserCancelled = {ctor: "UserCancelled"};
9345 var UnknownError = {ctor: "UnknownError"};
9346 var TransportUnavailable = {ctor: "TransportUnavailable"};
9347 var ProviderError = {ctor: "ProviderError"};
9348 var NetworkError = {ctor: "NetworkError"};
9349 var InvalidUser = {ctor: "InvalidUser"};
9350 var InvalidToken = {ctor: "InvalidToken"};
9351 var InvalidProvider = {ctor: "InvalidProvider"};
9352 var InvalidPassword = {ctor: "InvalidPassword"};
9353 var InvalidOrigin = {ctor: "InvalidOrigin"};
9354 var InvalidEmail = {ctor: "InvalidEmail"};
9355 var InvalidCredentials = {ctor: "InvalidCredentials"};
9356 var InvalidConfiguration = {ctor: "InvalidConfiguration"};
9357 var InvalidArguments = {ctor: "InvalidArguments"};
9358 var EmailTaken = {ctor: "EmailTaken"};
9359 var AuthenticationDisabled = {ctor: "AuthenticationDisabled"};
9360 var UnknownSubscription = {ctor: "UnknownSubscription"};
9361 var AuthError = function (a) { return {ctor: "AuthError",_0: a};};
9362 var OtherFirebaseError = {ctor: "OtherFirebaseError"};
9363 var TooBigError = {ctor: "TooBigError"};
9364 var UnavailableError = {ctor: "UnavailableError"};
9365 var PermissionError = {ctor: "PermissionError"};
9366 var LocationError = {ctor: "LocationError"};
9367 var Error = F2(function (a,b) { return {tag: a,description: b};});
9368 return _elm.ElmFire.values = {_op: _op
9369 ,fromUrl: fromUrl
9370 ,sub: sub
9371 ,parent: parent
9372 ,root: root
9373 ,push: push
9374 ,open: open
9375 ,key: key
9376 ,toUrl: toUrl
9377 ,location: location
9378 ,set: set
9379 ,setWithPriority: setWithPriority
9380 ,setPriority: setPriority
9381 ,update: update
9382 ,remove: remove
9383 ,transaction: transaction
9384 ,subscribe: subscribe
9385 ,unsubscribe: unsubscribe
9386 ,once: once
9387 ,valueChanged: valueChanged
9388 ,childAdded: childAdded
9389 ,childChanged: childChanged
9390 ,childRemoved: childRemoved
9391 ,childMoved: childMoved
9392 ,noOrder: noOrder
9393 ,orderByChild: orderByChild
9394 ,orderByValue: orderByValue
9395 ,orderByKey: orderByKey
9396 ,orderByPriority: orderByPriority
9397 ,noRange: noRange
9398 ,startAt: startAt
9399 ,endAt: endAt
9400 ,range: range
9401 ,equalTo: equalTo
9402 ,noLimit: noLimit
9403 ,limitToFirst: limitToFirst
9404 ,limitToLast: limitToLast
9405 ,toSnapshotList: toSnapshotList
9406 ,toValueList: toValueList
9407 ,toKeyList: toKeyList
9408 ,toPairList: toPairList
9409 ,exportValue: exportValue
9410 ,goOffline: goOffline
9411 ,goOnline: goOnline
9412 ,subscribeConnected: subscribeConnected
9413 ,onDisconnectSet: onDisconnectSet
9414 ,onDisconnectSetWithPriority: onDisconnectSetWithPriority
9415 ,onDisconnectUpdate: onDisconnectUpdate
9416 ,onDisconnectRemove: onDisconnectRemove
9417 ,onDisconnectCancel: onDisconnectCancel
9418 ,serverTimeStamp: serverTimeStamp
9419 ,subscribeServerTimeOffset: subscribeServerTimeOffset
9420 ,Snapshot: Snapshot
9421 ,Error: Error
9422 ,NoPriority: NoPriority
9423 ,NumberPriority: NumberPriority
9424 ,StringPriority: StringPriority
9425 ,Abort: Abort
9426 ,Remove: Remove
9427 ,Set: Set
9428 ,Unsubscribed: Unsubscribed
9429 ,QueryError: QueryError
9430 ,LocationError: LocationError
9431 ,PermissionError: PermissionError
9432 ,UnavailableError: UnavailableError
9433 ,TooBigError: TooBigError
9434 ,OtherFirebaseError: OtherFirebaseError
9435 ,AuthError: AuthError
9436 ,UnknownSubscription: UnknownSubscription
9437 ,AuthenticationDisabled: AuthenticationDisabled
9438 ,EmailTaken: EmailTaken
9439 ,InvalidArguments: InvalidArguments
9440 ,InvalidConfiguration: InvalidConfiguration
9441 ,InvalidCredentials: InvalidCredentials
9442 ,InvalidEmail: InvalidEmail
9443 ,InvalidOrigin: InvalidOrigin
9444 ,InvalidPassword: InvalidPassword
9445 ,InvalidProvider: InvalidProvider
9446 ,InvalidToken: InvalidToken
9447 ,InvalidUser: InvalidUser
9448 ,NetworkError: NetworkError
9449 ,ProviderError: ProviderError
9450 ,TransportUnavailable: TransportUnavailable
9451 ,UnknownError: UnknownError
9452 ,UserCancelled: UserCancelled
9453 ,UserDenied: UserDenied
9454 ,OtherAuthenticationError: OtherAuthenticationError};
9455};
9456(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
9457
9458},{}],2:[function(require,module,exports){
9459(function (global){
9460var topLevel = typeof global !== 'undefined' ? global :
9461 typeof window !== 'undefined' ? window : {}
9462var minDoc = require('min-document');
9463
9464if (typeof document !== 'undefined') {
9465 module.exports = document;
9466} else {
9467 var doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
9468
9469 if (!doccy) {
9470 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
9471 }
9472
9473 module.exports = doccy;
9474}
9475
9476}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
9477},{"min-document":1}],3:[function(require,module,exports){
9478"use strict";
9479
9480module.exports = function isObject(x) {
9481 return typeof x === "object" && x !== null;
9482};
9483
9484},{}],4:[function(require,module,exports){
9485var nativeIsArray = Array.isArray
9486var toString = Object.prototype.toString
9487
9488module.exports = nativeIsArray || isArray
9489
9490function isArray(obj) {
9491 return toString.call(obj) === "[object Array]"
9492}
9493
9494},{}],5:[function(require,module,exports){
9495var isObject = require("is-object")
9496var isHook = require("../vnode/is-vhook.js")
9497
9498module.exports = applyProperties
9499
9500function applyProperties(node, props, previous) {
9501 for (var propName in props) {
9502 var propValue = props[propName]
9503
9504 if (propValue === undefined) {
9505 removeProperty(node, propName, propValue, previous);
9506 } else if (isHook(propValue)) {
9507 removeProperty(node, propName, propValue, previous)
9508 if (propValue.hook) {
9509 propValue.hook(node,
9510 propName,
9511 previous ? previous[propName] : undefined)
9512 }
9513 } else {
9514 if (isObject(propValue)) {
9515 patchObject(node, props, previous, propName, propValue);
9516 } else {
9517 node[propName] = propValue
9518 }
9519 }
9520 }
9521}
9522
9523function removeProperty(node, propName, propValue, previous) {
9524 if (previous) {
9525 var previousValue = previous[propName]
9526
9527 if (!isHook(previousValue)) {
9528 if (propName === "attributes") {
9529 for (var attrName in previousValue) {
9530 node.removeAttribute(attrName)
9531 }
9532 } else if (propName === "style") {
9533 for (var i in previousValue) {
9534 node.style[i] = ""
9535 }
9536 } else if (typeof previousValue === "string") {
9537 node[propName] = ""
9538 } else {
9539 node[propName] = null
9540 }
9541 } else if (previousValue.unhook) {
9542 previousValue.unhook(node, propName, propValue)
9543 }
9544 }
9545}
9546
9547function patchObject(node, props, previous, propName, propValue) {
9548 var previousValue = previous ? previous[propName] : undefined
9549
9550 // Set attributes
9551 if (propName === "attributes") {
9552 for (var attrName in propValue) {
9553 var attrValue = propValue[attrName]
9554
9555 if (attrValue === undefined) {
9556 node.removeAttribute(attrName)
9557 } else {
9558 node.setAttribute(attrName, attrValue)
9559 }
9560 }
9561
9562 return
9563 }
9564
9565 if(previousValue && isObject(previousValue) &&
9566 getPrototype(previousValue) !== getPrototype(propValue)) {
9567 node[propName] = propValue
9568 return
9569 }
9570
9571 if (!isObject(node[propName])) {
9572 node[propName] = {}
9573 }
9574
9575 var replacer = propName === "style" ? "" : undefined
9576
9577 for (var k in propValue) {
9578 var value = propValue[k]
9579 node[propName][k] = (value === undefined) ? replacer : value
9580 }
9581}
9582
9583function getPrototype(value) {
9584 if (Object.getPrototypeOf) {
9585 return Object.getPrototypeOf(value)
9586 } else if (value.__proto__) {
9587 return value.__proto__
9588 } else if (value.constructor) {
9589 return value.constructor.prototype
9590 }
9591}
9592
9593},{"../vnode/is-vhook.js":13,"is-object":3}],6:[function(require,module,exports){
9594var document = require("global/document")
9595
9596var applyProperties = require("./apply-properties")
9597
9598var isVNode = require("../vnode/is-vnode.js")
9599var isVText = require("../vnode/is-vtext.js")
9600var isWidget = require("../vnode/is-widget.js")
9601var handleThunk = require("../vnode/handle-thunk.js")
9602
9603module.exports = createElement
9604
9605function createElement(vnode, opts) {
9606 var doc = opts ? opts.document || document : document
9607 var warn = opts ? opts.warn : null
9608
9609 vnode = handleThunk(vnode).a
9610
9611 if (isWidget(vnode)) {
9612 return vnode.init()
9613 } else if (isVText(vnode)) {
9614 return doc.createTextNode(vnode.text)
9615 } else if (!isVNode(vnode)) {
9616 if (warn) {
9617 warn("Item is not a valid virtual dom node", vnode)
9618 }
9619 return null
9620 }
9621
9622 var node = (vnode.namespace === null) ?
9623 doc.createElement(vnode.tagName) :
9624 doc.createElementNS(vnode.namespace, vnode.tagName)
9625
9626 var props = vnode.properties
9627 applyProperties(node, props)
9628
9629 var children = vnode.children
9630
9631 for (var i = 0; i < children.length; i++) {
9632 var childNode = createElement(children[i], opts)
9633 if (childNode) {
9634 node.appendChild(childNode)
9635 }
9636 }
9637
9638 return node
9639}
9640
9641},{"../vnode/handle-thunk.js":11,"../vnode/is-vnode.js":14,"../vnode/is-vtext.js":15,"../vnode/is-widget.js":16,"./apply-properties":5,"global/document":2}],7:[function(require,module,exports){
9642// Maps a virtual DOM tree onto a real DOM tree in an efficient manner.
9643// We don't want to read all of the DOM nodes in the tree so we use
9644// the in-order tree indexing to eliminate recursion down certain branches.
9645// We only recurse into a DOM node if we know that it contains a child of
9646// interest.
9647
9648var noChild = {}
9649
9650module.exports = domIndex
9651
9652function domIndex(rootNode, tree, indices, nodes) {
9653 if (!indices || indices.length === 0) {
9654 return {}
9655 } else {
9656 indices.sort(ascending)
9657 return recurse(rootNode, tree, indices, nodes, 0)
9658 }
9659}
9660
9661function recurse(rootNode, tree, indices, nodes, rootIndex) {
9662 nodes = nodes || {}
9663
9664
9665 if (rootNode) {
9666 if (indexInRange(indices, rootIndex, rootIndex)) {
9667 nodes[rootIndex] = rootNode
9668 }
9669
9670 var vChildren = tree.children
9671
9672 if (vChildren) {
9673
9674 var childNodes = rootNode.childNodes
9675
9676 for (var i = 0; i < tree.children.length; i++) {
9677 rootIndex += 1
9678
9679 var vChild = vChildren[i] || noChild
9680 var nextIndex = rootIndex + (vChild.count || 0)
9681
9682 // skip recursion down the tree if there are no nodes down here
9683 if (indexInRange(indices, rootIndex, nextIndex)) {
9684 recurse(childNodes[i], vChild, indices, nodes, rootIndex)
9685 }
9686
9687 rootIndex = nextIndex
9688 }
9689 }
9690 }
9691
9692 return nodes
9693}
9694
9695// Binary search for an index in the interval [left, right]
9696function indexInRange(indices, left, right) {
9697 if (indices.length === 0) {
9698 return false
9699 }
9700
9701 var minIndex = 0
9702 var maxIndex = indices.length - 1
9703 var currentIndex
9704 var currentItem
9705
9706 while (minIndex <= maxIndex) {
9707 currentIndex = ((maxIndex + minIndex) / 2) >> 0
9708 currentItem = indices[currentIndex]
9709
9710 if (minIndex === maxIndex) {
9711 return currentItem >= left && currentItem <= right
9712 } else if (currentItem < left) {
9713 minIndex = currentIndex + 1
9714 } else if (currentItem > right) {
9715 maxIndex = currentIndex - 1
9716 } else {
9717 return true
9718 }
9719 }
9720
9721 return false;
9722}
9723
9724function ascending(a, b) {
9725 return a > b ? 1 : -1
9726}
9727
9728},{}],8:[function(require,module,exports){
9729var applyProperties = require("./apply-properties")
9730
9731var isWidget = require("../vnode/is-widget.js")
9732var VPatch = require("../vnode/vpatch.js")
9733
9734var render = require("./create-element")
9735var updateWidget = require("./update-widget")
9736
9737module.exports = applyPatch
9738
9739function applyPatch(vpatch, domNode, renderOptions) {
9740 var type = vpatch.type
9741 var vNode = vpatch.vNode
9742 var patch = vpatch.patch
9743
9744 switch (type) {
9745 case VPatch.REMOVE:
9746 return removeNode(domNode, vNode)
9747 case VPatch.INSERT:
9748 return insertNode(domNode, patch, renderOptions)
9749 case VPatch.VTEXT:
9750 return stringPatch(domNode, vNode, patch, renderOptions)
9751 case VPatch.WIDGET:
9752 return widgetPatch(domNode, vNode, patch, renderOptions)
9753 case VPatch.VNODE:
9754 return vNodePatch(domNode, vNode, patch, renderOptions)
9755 case VPatch.ORDER:
9756 reorderChildren(domNode, patch)
9757 return domNode
9758 case VPatch.PROPS:
9759 applyProperties(domNode, patch, vNode.properties)
9760 return domNode
9761 case VPatch.THUNK:
9762 return replaceRoot(domNode,
9763 renderOptions.patch(domNode, patch, renderOptions))
9764 default:
9765 return domNode
9766 }
9767}
9768
9769function removeNode(domNode, vNode) {
9770 var parentNode = domNode.parentNode
9771
9772 if (parentNode) {
9773 parentNode.removeChild(domNode)
9774 }
9775
9776 destroyWidget(domNode, vNode);
9777
9778 return null
9779}
9780
9781function insertNode(parentNode, vNode, renderOptions) {
9782 var newNode = render(vNode, renderOptions)
9783
9784 if (parentNode) {
9785 parentNode.appendChild(newNode)
9786 }
9787
9788 return parentNode
9789}
9790
9791function stringPatch(domNode, leftVNode, vText, renderOptions) {
9792 var newNode
9793
9794 if (domNode.nodeType === 3) {
9795 domNode.replaceData(0, domNode.length, vText.text)
9796 newNode = domNode
9797 } else {
9798 var parentNode = domNode.parentNode
9799 newNode = render(vText, renderOptions)
9800
9801 if (parentNode && newNode !== domNode) {
9802 parentNode.replaceChild(newNode, domNode)
9803 }
9804 }
9805
9806 return newNode
9807}
9808
9809function widgetPatch(domNode, leftVNode, widget, renderOptions) {
9810 var updating = updateWidget(leftVNode, widget)
9811 var newNode
9812
9813 if (updating) {
9814 newNode = widget.update(leftVNode, domNode) || domNode
9815 } else {
9816 newNode = render(widget, renderOptions)
9817 }
9818
9819 var parentNode = domNode.parentNode
9820
9821 if (parentNode && newNode !== domNode) {
9822 parentNode.replaceChild(newNode, domNode)
9823 }
9824
9825 if (!updating) {
9826 destroyWidget(domNode, leftVNode)
9827 }
9828
9829 return newNode
9830}
9831
9832function vNodePatch(domNode, leftVNode, vNode, renderOptions) {
9833 var parentNode = domNode.parentNode
9834 var newNode = render(vNode, renderOptions)
9835
9836 if (parentNode && newNode !== domNode) {
9837 parentNode.replaceChild(newNode, domNode)
9838 }
9839
9840 return newNode
9841}
9842
9843function destroyWidget(domNode, w) {
9844 if (typeof w.destroy === "function" && isWidget(w)) {
9845 w.destroy(domNode)
9846 }
9847}
9848
9849function reorderChildren(domNode, moves) {
9850 var childNodes = domNode.childNodes
9851 var keyMap = {}
9852 var node
9853 var remove
9854 var insert
9855
9856 for (var i = 0; i < moves.removes.length; i++) {
9857 remove = moves.removes[i]
9858 node = childNodes[remove.from]
9859 if (remove.key) {
9860 keyMap[remove.key] = node
9861 }
9862 domNode.removeChild(node)
9863 }
9864
9865 var length = childNodes.length
9866 for (var j = 0; j < moves.inserts.length; j++) {
9867 insert = moves.inserts[j]
9868 node = keyMap[insert.key]
9869 // this is the weirdest bug i've ever seen in webkit
9870 domNode.insertBefore(node, insert.to >= length++ ? null : childNodes[insert.to])
9871 }
9872}
9873
9874function replaceRoot(oldRoot, newRoot) {
9875 if (oldRoot && newRoot && oldRoot !== newRoot && oldRoot.parentNode) {
9876 oldRoot.parentNode.replaceChild(newRoot, oldRoot)
9877 }
9878
9879 return newRoot;
9880}
9881
9882},{"../vnode/is-widget.js":16,"../vnode/vpatch.js":19,"./apply-properties":5,"./create-element":6,"./update-widget":10}],9:[function(require,module,exports){
9883var document = require("global/document")
9884var isArray = require("x-is-array")
9885
9886var domIndex = require("./dom-index")
9887var patchOp = require("./patch-op")
9888module.exports = patch
9889
9890function patch(rootNode, patches) {
9891 return patchRecursive(rootNode, patches)
9892}
9893
9894function patchRecursive(rootNode, patches, renderOptions) {
9895 var indices = patchIndices(patches)
9896
9897 if (indices.length === 0) {
9898 return rootNode
9899 }
9900
9901 var index = domIndex(rootNode, patches.a, indices)
9902 var ownerDocument = rootNode.ownerDocument
9903
9904 if (!renderOptions) {
9905 renderOptions = { patch: patchRecursive }
9906 if (ownerDocument !== document) {
9907 renderOptions.document = ownerDocument
9908 }
9909 }
9910
9911 for (var i = 0; i < indices.length; i++) {
9912 var nodeIndex = indices[i]
9913 rootNode = applyPatch(rootNode,
9914 index[nodeIndex],
9915 patches[nodeIndex],
9916 renderOptions)
9917 }
9918
9919 return rootNode
9920}
9921
9922function applyPatch(rootNode, domNode, patchList, renderOptions) {
9923 if (!domNode) {
9924 return rootNode
9925 }
9926
9927 var newNode
9928
9929 if (isArray(patchList)) {
9930 for (var i = 0; i < patchList.length; i++) {
9931 newNode = patchOp(patchList[i], domNode, renderOptions)
9932
9933 if (domNode === rootNode) {
9934 rootNode = newNode
9935 }
9936 }
9937 } else {
9938 newNode = patchOp(patchList, domNode, renderOptions)
9939
9940 if (domNode === rootNode) {
9941 rootNode = newNode
9942 }
9943 }
9944
9945 return rootNode
9946}
9947
9948function patchIndices(patches) {
9949 var indices = []
9950
9951 for (var key in patches) {
9952 if (key !== "a") {
9953 indices.push(Number(key))
9954 }
9955 }
9956
9957 return indices
9958}
9959
9960},{"./dom-index":7,"./patch-op":8,"global/document":2,"x-is-array":4}],10:[function(require,module,exports){
9961var isWidget = require("../vnode/is-widget.js")
9962
9963module.exports = updateWidget
9964
9965function updateWidget(a, b) {
9966 if (isWidget(a) && isWidget(b)) {
9967 if ("name" in a && "name" in b) {
9968 return a.id === b.id
9969 } else {
9970 return a.init === b.init
9971 }
9972 }
9973
9974 return false
9975}
9976
9977},{"../vnode/is-widget.js":16}],11:[function(require,module,exports){
9978var isVNode = require("./is-vnode")
9979var isVText = require("./is-vtext")
9980var isWidget = require("./is-widget")
9981var isThunk = require("./is-thunk")
9982
9983module.exports = handleThunk
9984
9985function handleThunk(a, b) {
9986 var renderedA = a
9987 var renderedB = b
9988
9989 if (isThunk(b)) {
9990 renderedB = renderThunk(b, a)
9991 }
9992
9993 if (isThunk(a)) {
9994 renderedA = renderThunk(a, null)
9995 }
9996
9997 return {
9998 a: renderedA,
9999 b: renderedB
10000 }
10001}
10002
10003function renderThunk(thunk, previous) {
10004 var renderedThunk = thunk.vnode
10005
10006 if (!renderedThunk) {
10007 renderedThunk = thunk.vnode = thunk.render(previous)
10008 }
10009
10010 if (!(isVNode(renderedThunk) ||
10011 isVText(renderedThunk) ||
10012 isWidget(renderedThunk))) {
10013 throw new Error("thunk did not return a valid node");
10014 }
10015
10016 return renderedThunk
10017}
10018
10019},{"./is-thunk":12,"./is-vnode":14,"./is-vtext":15,"./is-widget":16}],12:[function(require,module,exports){
10020module.exports = isThunk
10021
10022function isThunk(t) {
10023 return t && t.type === "Thunk"
10024}
10025
10026},{}],13:[function(require,module,exports){
10027module.exports = isHook
10028
10029function isHook(hook) {
10030 return hook &&
10031 (typeof hook.hook === "function" && !hook.hasOwnProperty("hook") ||
10032 typeof hook.unhook === "function" && !hook.hasOwnProperty("unhook"))
10033}
10034
10035},{}],14:[function(require,module,exports){
10036var version = require("./version")
10037
10038module.exports = isVirtualNode
10039
10040function isVirtualNode(x) {
10041 return x && x.type === "VirtualNode" && x.version === version
10042}
10043
10044},{"./version":17}],15:[function(require,module,exports){
10045var version = require("./version")
10046
10047module.exports = isVirtualText
10048
10049function isVirtualText(x) {
10050 return x && x.type === "VirtualText" && x.version === version
10051}
10052
10053},{"./version":17}],16:[function(require,module,exports){
10054module.exports = isWidget
10055
10056function isWidget(w) {
10057 return w && w.type === "Widget"
10058}
10059
10060},{}],17:[function(require,module,exports){
10061module.exports = "2"
10062
10063},{}],18:[function(require,module,exports){
10064var version = require("./version")
10065var isVNode = require("./is-vnode")
10066var isWidget = require("./is-widget")
10067var isThunk = require("./is-thunk")
10068var isVHook = require("./is-vhook")
10069
10070module.exports = VirtualNode
10071
10072var noProperties = {}
10073var noChildren = []
10074
10075function VirtualNode(tagName, properties, children, key, namespace) {
10076 this.tagName = tagName
10077 this.properties = properties || noProperties
10078 this.children = children || noChildren
10079 this.key = key != null ? String(key) : undefined
10080 this.namespace = (typeof namespace === "string") ? namespace : null
10081
10082 var count = (children && children.length) || 0
10083 var descendants = 0
10084 var hasWidgets = false
10085 var hasThunks = false
10086 var descendantHooks = false
10087 var hooks
10088
10089 for (var propName in properties) {
10090 if (properties.hasOwnProperty(propName)) {
10091 var property = properties[propName]
10092 if (isVHook(property) && property.unhook) {
10093 if (!hooks) {
10094 hooks = {}
10095 }
10096
10097 hooks[propName] = property
10098 }
10099 }
10100 }
10101
10102 for (var i = 0; i < count; i++) {
10103 var child = children[i]
10104 if (isVNode(child)) {
10105 descendants += child.count || 0
10106
10107 if (!hasWidgets && child.hasWidgets) {
10108 hasWidgets = true
10109 }
10110
10111 if (!hasThunks && child.hasThunks) {
10112 hasThunks = true
10113 }
10114
10115 if (!descendantHooks && (child.hooks || child.descendantHooks)) {
10116 descendantHooks = true
10117 }
10118 } else if (!hasWidgets && isWidget(child)) {
10119 if (typeof child.destroy === "function") {
10120 hasWidgets = true
10121 }
10122 } else if (!hasThunks && isThunk(child)) {
10123 hasThunks = true;
10124 }
10125 }
10126
10127 this.count = count + descendants
10128 this.hasWidgets = hasWidgets
10129 this.hasThunks = hasThunks
10130 this.hooks = hooks
10131 this.descendantHooks = descendantHooks
10132}
10133
10134VirtualNode.prototype.version = version
10135VirtualNode.prototype.type = "VirtualNode"
10136
10137},{"./is-thunk":12,"./is-vhook":13,"./is-vnode":14,"./is-widget":16,"./version":17}],19:[function(require,module,exports){
10138var version = require("./version")
10139
10140VirtualPatch.NONE = 0
10141VirtualPatch.VTEXT = 1
10142VirtualPatch.VNODE = 2
10143VirtualPatch.WIDGET = 3
10144VirtualPatch.PROPS = 4
10145VirtualPatch.ORDER = 5
10146VirtualPatch.INSERT = 6
10147VirtualPatch.REMOVE = 7
10148VirtualPatch.THUNK = 8
10149
10150module.exports = VirtualPatch
10151
10152function VirtualPatch(type, vNode, patch) {
10153 this.type = Number(type)
10154 this.vNode = vNode
10155 this.patch = patch
10156}
10157
10158VirtualPatch.prototype.version = version
10159VirtualPatch.prototype.type = "VirtualPatch"
10160
10161},{"./version":17}],20:[function(require,module,exports){
10162var version = require("./version")
10163
10164module.exports = VirtualText
10165
10166function VirtualText(text) {
10167 this.text = String(text)
10168}
10169
10170VirtualText.prototype.version = version
10171VirtualText.prototype.type = "VirtualText"
10172
10173},{"./version":17}],21:[function(require,module,exports){
10174var isObject = require("is-object")
10175var isHook = require("../vnode/is-vhook")
10176
10177module.exports = diffProps
10178
10179function diffProps(a, b) {
10180 var diff
10181
10182 for (var aKey in a) {
10183 if (!(aKey in b)) {
10184 diff = diff || {}
10185 diff[aKey] = undefined
10186 }
10187
10188 var aValue = a[aKey]
10189 var bValue = b[aKey]
10190
10191 if (aValue === bValue) {
10192 continue
10193 } else if (isObject(aValue) && isObject(bValue)) {
10194 if (getPrototype(bValue) !== getPrototype(aValue)) {
10195 diff = diff || {}
10196 diff[aKey] = bValue
10197 } else if (isHook(bValue)) {
10198 diff = diff || {}
10199 diff[aKey] = bValue
10200 } else {
10201 var objectDiff = diffProps(aValue, bValue)
10202 if (objectDiff) {
10203 diff = diff || {}
10204 diff[aKey] = objectDiff
10205 }
10206 }
10207 } else {
10208 diff = diff || {}
10209 diff[aKey] = bValue
10210 }
10211 }
10212
10213 for (var bKey in b) {
10214 if (!(bKey in a)) {
10215 diff = diff || {}
10216 diff[bKey] = b[bKey]
10217 }
10218 }
10219
10220 return diff
10221}
10222
10223function getPrototype(value) {
10224 if (Object.getPrototypeOf) {
10225 return Object.getPrototypeOf(value)
10226 } else if (value.__proto__) {
10227 return value.__proto__
10228 } else if (value.constructor) {
10229 return value.constructor.prototype
10230 }
10231}
10232
10233},{"../vnode/is-vhook":13,"is-object":3}],22:[function(require,module,exports){
10234var isArray = require("x-is-array")
10235
10236var VPatch = require("../vnode/vpatch")
10237var isVNode = require("../vnode/is-vnode")
10238var isVText = require("../vnode/is-vtext")
10239var isWidget = require("../vnode/is-widget")
10240var isThunk = require("../vnode/is-thunk")
10241var handleThunk = require("../vnode/handle-thunk")
10242
10243var diffProps = require("./diff-props")
10244
10245module.exports = diff
10246
10247function diff(a, b) {
10248 var patch = { a: a }
10249 walk(a, b, patch, 0)
10250 return patch
10251}
10252
10253function walk(a, b, patch, index) {
10254 if (a === b) {
10255 return
10256 }
10257
10258 var apply = patch[index]
10259 var applyClear = false
10260
10261 if (isThunk(a) || isThunk(b)) {
10262 thunks(a, b, patch, index)
10263 } else if (b == null) {
10264
10265 // If a is a widget we will add a remove patch for it
10266 // Otherwise any child widgets/hooks must be destroyed.
10267 // This prevents adding two remove patches for a widget.
10268 if (!isWidget(a)) {
10269 clearState(a, patch, index)
10270 apply = patch[index]
10271 }
10272
10273 apply = appendPatch(apply, new VPatch(VPatch.REMOVE, a, b))
10274 } else if (isVNode(b)) {
10275 if (isVNode(a)) {
10276 if (a.tagName === b.tagName &&
10277 a.namespace === b.namespace &&
10278 a.key === b.key) {
10279 var propsPatch = diffProps(a.properties, b.properties)
10280 if (propsPatch) {
10281 apply = appendPatch(apply,
10282 new VPatch(VPatch.PROPS, a, propsPatch))
10283 }
10284 apply = diffChildren(a, b, patch, apply, index)
10285 } else {
10286 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
10287 applyClear = true
10288 }
10289 } else {
10290 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
10291 applyClear = true
10292 }
10293 } else if (isVText(b)) {
10294 if (!isVText(a)) {
10295 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
10296 applyClear = true
10297 } else if (a.text !== b.text) {
10298 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
10299 }
10300 } else if (isWidget(b)) {
10301 if (!isWidget(a)) {
10302 applyClear = true
10303 }
10304
10305 apply = appendPatch(apply, new VPatch(VPatch.WIDGET, a, b))
10306 }
10307
10308 if (apply) {
10309 patch[index] = apply
10310 }
10311
10312 if (applyClear) {
10313 clearState(a, patch, index)
10314 }
10315}
10316
10317function diffChildren(a, b, patch, apply, index) {
10318 var aChildren = a.children
10319 var orderedSet = reorder(aChildren, b.children)
10320 var bChildren = orderedSet.children
10321
10322 var aLen = aChildren.length
10323 var bLen = bChildren.length
10324 var len = aLen > bLen ? aLen : bLen
10325
10326 for (var i = 0; i < len; i++) {
10327 var leftNode = aChildren[i]
10328 var rightNode = bChildren[i]
10329 index += 1
10330
10331 if (!leftNode) {
10332 if (rightNode) {
10333 // Excess nodes in b need to be added
10334 apply = appendPatch(apply,
10335 new VPatch(VPatch.INSERT, null, rightNode))
10336 }
10337 } else {
10338 walk(leftNode, rightNode, patch, index)
10339 }
10340
10341 if (isVNode(leftNode) && leftNode.count) {
10342 index += leftNode.count
10343 }
10344 }
10345
10346 if (orderedSet.moves) {
10347 // Reorder nodes last
10348 apply = appendPatch(apply, new VPatch(
10349 VPatch.ORDER,
10350 a,
10351 orderedSet.moves
10352 ))
10353 }
10354
10355 return apply
10356}
10357
10358function clearState(vNode, patch, index) {
10359 // TODO: Make this a single walk, not two
10360 unhook(vNode, patch, index)
10361 destroyWidgets(vNode, patch, index)
10362}
10363
10364// Patch records for all destroyed widgets must be added because we need
10365// a DOM node reference for the destroy function
10366function destroyWidgets(vNode, patch, index) {
10367 if (isWidget(vNode)) {
10368 if (typeof vNode.destroy === "function") {
10369 patch[index] = appendPatch(
10370 patch[index],
10371 new VPatch(VPatch.REMOVE, vNode, null)
10372 )
10373 }
10374 } else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) {
10375 var children = vNode.children
10376 var len = children.length
10377 for (var i = 0; i < len; i++) {
10378 var child = children[i]
10379 index += 1
10380
10381 destroyWidgets(child, patch, index)
10382
10383 if (isVNode(child) && child.count) {
10384 index += child.count
10385 }
10386 }
10387 } else if (isThunk(vNode)) {
10388 thunks(vNode, null, patch, index)
10389 }
10390}
10391
10392// Create a sub-patch for thunks
10393function thunks(a, b, patch, index) {
10394 var nodes = handleThunk(a, b)
10395 var thunkPatch = diff(nodes.a, nodes.b)
10396 if (hasPatches(thunkPatch)) {
10397 patch[index] = new VPatch(VPatch.THUNK, null, thunkPatch)
10398 }
10399}
10400
10401function hasPatches(patch) {
10402 for (var index in patch) {
10403 if (index !== "a") {
10404 return true
10405 }
10406 }
10407
10408 return false
10409}
10410
10411// Execute hooks when two nodes are identical
10412function unhook(vNode, patch, index) {
10413 if (isVNode(vNode)) {
10414 if (vNode.hooks) {
10415 patch[index] = appendPatch(
10416 patch[index],
10417 new VPatch(
10418 VPatch.PROPS,
10419 vNode,
10420 undefinedKeys(vNode.hooks)
10421 )
10422 )
10423 }
10424
10425 if (vNode.descendantHooks || vNode.hasThunks) {
10426 var children = vNode.children
10427 var len = children.length
10428 for (var i = 0; i < len; i++) {
10429 var child = children[i]
10430 index += 1
10431
10432 unhook(child, patch, index)
10433
10434 if (isVNode(child) && child.count) {
10435 index += child.count
10436 }
10437 }
10438 }
10439 } else if (isThunk(vNode)) {
10440 thunks(vNode, null, patch, index)
10441 }
10442}
10443
10444function undefinedKeys(obj) {
10445 var result = {}
10446
10447 for (var key in obj) {
10448 result[key] = undefined
10449 }
10450
10451 return result
10452}
10453
10454// List diff, naive left to right reordering
10455function reorder(aChildren, bChildren) {
10456 // O(M) time, O(M) memory
10457 var bChildIndex = keyIndex(bChildren)
10458 var bKeys = bChildIndex.keys
10459 var bFree = bChildIndex.free
10460
10461 if (bFree.length === bChildren.length) {
10462 return {
10463 children: bChildren,
10464 moves: null
10465 }
10466 }
10467
10468 // O(N) time, O(N) memory
10469 var aChildIndex = keyIndex(aChildren)
10470 var aKeys = aChildIndex.keys
10471 var aFree = aChildIndex.free
10472
10473 if (aFree.length === aChildren.length) {
10474 return {
10475 children: bChildren,
10476 moves: null
10477 }
10478 }
10479
10480 // O(MAX(N, M)) memory
10481 var newChildren = []
10482
10483 var freeIndex = 0
10484 var freeCount = bFree.length
10485 var deletedItems = 0
10486
10487 // Iterate through a and match a node in b
10488 // O(N) time,
10489 for (var i = 0 ; i < aChildren.length; i++) {
10490 var aItem = aChildren[i]
10491 var itemIndex
10492
10493 if (aItem.key) {
10494 if (bKeys.hasOwnProperty(aItem.key)) {
10495 // Match up the old keys
10496 itemIndex = bKeys[aItem.key]
10497 newChildren.push(bChildren[itemIndex])
10498
10499 } else {
10500 // Remove old keyed items
10501 itemIndex = i - deletedItems++
10502 newChildren.push(null)
10503 }
10504 } else {
10505 // Match the item in a with the next free item in b
10506 if (freeIndex < freeCount) {
10507 itemIndex = bFree[freeIndex++]
10508 newChildren.push(bChildren[itemIndex])
10509 } else {
10510 // There are no free items in b to match with
10511 // the free items in a, so the extra free nodes
10512 // are deleted.
10513 itemIndex = i - deletedItems++
10514 newChildren.push(null)
10515 }
10516 }
10517 }
10518
10519 var lastFreeIndex = freeIndex >= bFree.length ?
10520 bChildren.length :
10521 bFree[freeIndex]
10522
10523 // Iterate through b and append any new keys
10524 // O(M) time
10525 for (var j = 0; j < bChildren.length; j++) {
10526 var newItem = bChildren[j]
10527
10528 if (newItem.key) {
10529 if (!aKeys.hasOwnProperty(newItem.key)) {
10530 // Add any new keyed items
10531 // We are adding new items to the end and then sorting them
10532 // in place. In future we should insert new items in place.
10533 newChildren.push(newItem)
10534 }
10535 } else if (j >= lastFreeIndex) {
10536 // Add any leftover non-keyed items
10537 newChildren.push(newItem)
10538 }
10539 }
10540
10541 var simulate = newChildren.slice()
10542 var simulateIndex = 0
10543 var removes = []
10544 var inserts = []
10545 var simulateItem
10546
10547 for (var k = 0; k < bChildren.length;) {
10548 var wantedItem = bChildren[k]
10549 simulateItem = simulate[simulateIndex]
10550
10551 // remove items
10552 while (simulateItem === null && simulate.length) {
10553 removes.push(remove(simulate, simulateIndex, null))
10554 simulateItem = simulate[simulateIndex]
10555 }
10556
10557 if (!simulateItem || simulateItem.key !== wantedItem.key) {
10558 // if we need a key in this position...
10559 if (wantedItem.key) {
10560 if (simulateItem && simulateItem.key) {
10561 // if an insert doesn't put this key in place, it needs to move
10562 if (bKeys[simulateItem.key] !== k + 1) {
10563 removes.push(remove(simulate, simulateIndex, simulateItem.key))
10564 simulateItem = simulate[simulateIndex]
10565 // if the remove didn't put the wanted item in place, we need to insert it
10566 if (!simulateItem || simulateItem.key !== wantedItem.key) {
10567 inserts.push({key: wantedItem.key, to: k})
10568 }
10569 // items are matching, so skip ahead
10570 else {
10571 simulateIndex++
10572 }
10573 }
10574 else {
10575 inserts.push({key: wantedItem.key, to: k})
10576 }
10577 }
10578 else {
10579 inserts.push({key: wantedItem.key, to: k})
10580 }
10581 k++
10582 }
10583 // a key in simulate has no matching wanted key, remove it
10584 else if (simulateItem && simulateItem.key) {
10585 removes.push(remove(simulate, simulateIndex, simulateItem.key))
10586 }
10587 }
10588 else {
10589 simulateIndex++
10590 k++
10591 }
10592 }
10593
10594 // remove all the remaining nodes from simulate
10595 while(simulateIndex < simulate.length) {
10596 simulateItem = simulate[simulateIndex]
10597 removes.push(remove(simulate, simulateIndex, simulateItem && simulateItem.key))
10598 }
10599
10600 // If the only moves we have are deletes then we can just
10601 // let the delete patch remove these items.
10602 if (removes.length === deletedItems && !inserts.length) {
10603 return {
10604 children: newChildren,
10605 moves: null
10606 }
10607 }
10608
10609 return {
10610 children: newChildren,
10611 moves: {
10612 removes: removes,
10613 inserts: inserts
10614 }
10615 }
10616}
10617
10618function remove(arr, index, key) {
10619 arr.splice(index, 1)
10620
10621 return {
10622 from: index,
10623 key: key
10624 }
10625}
10626
10627function keyIndex(children) {
10628 var keys = {}
10629 var free = []
10630 var length = children.length
10631
10632 for (var i = 0; i < length; i++) {
10633 var child = children[i]
10634
10635 if (child.key) {
10636 keys[child.key] = i
10637 } else {
10638 free.push(i)
10639 }
10640 }
10641
10642 return {
10643 keys: keys, // A hash of key name to index
10644 free: free, // An array of unkeyed item indices
10645 }
10646}
10647
10648function appendPatch(apply, patch) {
10649 if (apply) {
10650 if (isArray(apply)) {
10651 apply.push(patch)
10652 } else {
10653 apply = [apply, patch]
10654 }
10655
10656 return apply
10657 } else {
10658 return patch
10659 }
10660}
10661
10662},{"../vnode/handle-thunk":11,"../vnode/is-thunk":12,"../vnode/is-vnode":14,"../vnode/is-vtext":15,"../vnode/is-widget":16,"../vnode/vpatch":19,"./diff-props":21,"x-is-array":4}],23:[function(require,module,exports){
10663var VNode = require('virtual-dom/vnode/vnode');
10664var VText = require('virtual-dom/vnode/vtext');
10665var diff = require('virtual-dom/vtree/diff');
10666var patch = require('virtual-dom/vdom/patch');
10667var createElement = require('virtual-dom/vdom/create-element');
10668var isHook = require("virtual-dom/vnode/is-vhook");
10669
10670
10671Elm.Native.VirtualDom = {};
10672Elm.Native.VirtualDom.make = function(elm)
10673{
10674 elm.Native = elm.Native || {};
10675 elm.Native.VirtualDom = elm.Native.VirtualDom || {};
10676 if (elm.Native.VirtualDom.values)
10677 {
10678 return elm.Native.VirtualDom.values;
10679 }
10680
10681 var Element = Elm.Native.Graphics.Element.make(elm);
10682 var Json = Elm.Native.Json.make(elm);
10683 var List = Elm.Native.List.make(elm);
10684 var Signal = Elm.Native.Signal.make(elm);
10685 var Utils = Elm.Native.Utils.make(elm);
10686
10687 var ATTRIBUTE_KEY = 'UniqueNameThatOthersAreVeryUnlikelyToUse';
10688
10689
10690
10691 // VIRTUAL DOM NODES
10692
10693
10694 function text(string)
10695 {
10696 return new VText(string);
10697 }
10698
10699 function node(name)
10700 {
10701 return F2(function(propertyList, contents) {
10702 return makeNode(name, propertyList, contents);
10703 });
10704 }
10705
10706
10707 // BUILD VIRTUAL DOME NODES
10708
10709
10710 function makeNode(name, propertyList, contents)
10711 {
10712 var props = listToProperties(propertyList);
10713
10714 var key, namespace;
10715 // support keys
10716 if (props.key !== undefined)
10717 {
10718 key = props.key;
10719 props.key = undefined;
10720 }
10721
10722 // support namespace
10723 if (props.namespace !== undefined)
10724 {
10725 namespace = props.namespace;
10726 props.namespace = undefined;
10727 }
10728
10729 // ensure that setting text of an input does not move the cursor
10730 var useSoftSet =
10731 (name === 'input' || name === 'textarea')
10732 && props.value !== undefined
10733 && !isHook(props.value);
10734
10735 if (useSoftSet)
10736 {
10737 props.value = SoftSetHook(props.value);
10738 }
10739
10740 return new VNode(name, props, List.toArray(contents), key, namespace);
10741 }
10742
10743 function listToProperties(list)
10744 {
10745 var object = {};
10746 while (list.ctor !== '[]')
10747 {
10748 var entry = list._0;
10749 if (entry.key === ATTRIBUTE_KEY)
10750 {
10751 object.attributes = object.attributes || {};
10752 object.attributes[entry.value.attrKey] = entry.value.attrValue;
10753 }
10754 else
10755 {
10756 object[entry.key] = entry.value;
10757 }
10758 list = list._1;
10759 }
10760 return object;
10761 }
10762
10763
10764
10765 // PROPERTIES AND ATTRIBUTES
10766
10767
10768 function property(key, value)
10769 {
10770 return {
10771 key: key,
10772 value: value
10773 };
10774 }
10775
10776 function attribute(key, value)
10777 {
10778 return {
10779 key: ATTRIBUTE_KEY,
10780 value: {
10781 attrKey: key,
10782 attrValue: value
10783 }
10784 };
10785 }
10786
10787
10788
10789 // NAMESPACED ATTRIBUTES
10790
10791
10792 function attributeNS(namespace, key, value)
10793 {
10794 return {
10795 key: key,
10796 value: new AttributeHook(namespace, key, value)
10797 };
10798 }
10799
10800 function AttributeHook(namespace, key, value)
10801 {
10802 if (!(this instanceof AttributeHook))
10803 {
10804 return new AttributeHook(namespace, key, value);
10805 }
10806
10807 this.namespace = namespace;
10808 this.key = key;
10809 this.value = value;
10810 }
10811
10812 AttributeHook.prototype.hook = function (node, prop, prev)
10813 {
10814 if (prev
10815 && prev.type === 'AttributeHook'
10816 && prev.value === this.value
10817 && prev.namespace === this.namespace)
10818 {
10819 return;
10820 }
10821
10822 node.setAttributeNS(this.namespace, prop, this.value);
10823 };
10824
10825 AttributeHook.prototype.unhook = function (node, prop, next)
10826 {
10827 if (next
10828 && next.type === 'AttributeHook'
10829 && next.namespace === this.namespace)
10830 {
10831 return;
10832 }
10833
10834 node.removeAttributeNS(this.namespace, this.key);
10835 };
10836
10837 AttributeHook.prototype.type = 'AttributeHook';
10838
10839
10840
10841 // EVENTS
10842
10843
10844 function on(name, options, decoder, createMessage)
10845 {
10846 function eventHandler(event)
10847 {
10848 var value = A2(Json.runDecoderValue, decoder, event);
10849 if (value.ctor === 'Ok')
10850 {
10851 if (options.stopPropagation)
10852 {
10853 event.stopPropagation();
10854 }
10855 if (options.preventDefault)
10856 {
10857 event.preventDefault();
10858 }
10859 Signal.sendMessage(createMessage(value._0));
10860 }
10861 }
10862 return property('on' + name, eventHandler);
10863 }
10864
10865 function SoftSetHook(value)
10866 {
10867 if (!(this instanceof SoftSetHook))
10868 {
10869 return new SoftSetHook(value);
10870 }
10871
10872 this.value = value;
10873 }
10874
10875 SoftSetHook.prototype.hook = function (node, propertyName)
10876 {
10877 if (node[propertyName] !== this.value)
10878 {
10879 node[propertyName] = this.value;
10880 }
10881 };
10882
10883
10884
10885 // INTEGRATION WITH ELEMENTS
10886
10887
10888 function ElementWidget(element)
10889 {
10890 this.element = element;
10891 }
10892
10893 ElementWidget.prototype.type = "Widget";
10894
10895 ElementWidget.prototype.init = function init()
10896 {
10897 return Element.render(this.element);
10898 };
10899
10900 ElementWidget.prototype.update = function update(previous, node)
10901 {
10902 return Element.update(node, previous.element, this.element);
10903 };
10904
10905 function fromElement(element)
10906 {
10907 return new ElementWidget(element);
10908 }
10909
10910 function toElement(width, height, html)
10911 {
10912 return A3(Element.newElement, width, height, {
10913 ctor: 'Custom',
10914 type: 'evancz/elm-html',
10915 render: render,
10916 update: update,
10917 model: html
10918 });
10919 }
10920
10921
10922
10923 // RENDER AND UPDATE
10924
10925
10926 function render(model)
10927 {
10928 var element = Element.createNode('div');
10929 element.appendChild(createElement(model));
10930 return element;
10931 }
10932
10933 function update(node, oldModel, newModel)
10934 {
10935 updateAndReplace(node.firstChild, oldModel, newModel);
10936 return node;
10937 }
10938
10939 function updateAndReplace(node, oldModel, newModel)
10940 {
10941 var patches = diff(oldModel, newModel);
10942 var newNode = patch(node, patches);
10943 return newNode;
10944 }
10945
10946
10947
10948 // LAZINESS
10949
10950
10951 function lazyRef(fn, a)
10952 {
10953 function thunk()
10954 {
10955 return fn(a);
10956 }
10957 return new Thunk(fn, [a], thunk);
10958 }
10959
10960 function lazyRef2(fn, a, b)
10961 {
10962 function thunk()
10963 {
10964 return A2(fn, a, b);
10965 }
10966 return new Thunk(fn, [a,b], thunk);
10967 }
10968
10969 function lazyRef3(fn, a, b, c)
10970 {
10971 function thunk()
10972 {
10973 return A3(fn, a, b, c);
10974 }
10975 return new Thunk(fn, [a,b,c], thunk);
10976 }
10977
10978 function Thunk(fn, args, thunk)
10979 {
10980 /* public (used by VirtualDom.js) */
10981 this.vnode = null;
10982 this.key = undefined;
10983
10984 /* private */
10985 this.fn = fn;
10986 this.args = args;
10987 this.thunk = thunk;
10988 }
10989
10990 Thunk.prototype.type = "Thunk";
10991 Thunk.prototype.render = renderThunk;
10992
10993 function shouldUpdate(current, previous)
10994 {
10995 if (current.fn !== previous.fn)
10996 {
10997 return true;
10998 }
10999
11000 // if it's the same function, we know the number of args must match
11001 var cargs = current.args;
11002 var pargs = previous.args;
11003
11004 for (var i = cargs.length; i--; )
11005 {
11006 if (cargs[i] !== pargs[i])
11007 {
11008 return true;
11009 }
11010 }
11011
11012 return false;
11013 }
11014
11015 function renderThunk(previous)
11016 {
11017 if (previous == null || shouldUpdate(this, previous))
11018 {
11019 return this.thunk();
11020 }
11021 else
11022 {
11023 return previous.vnode;
11024 }
11025 }
11026
11027
11028 return elm.Native.VirtualDom.values = Elm.Native.VirtualDom.values = {
11029 node: node,
11030 text: text,
11031 on: F4(on),
11032
11033 property: F2(property),
11034 attribute: F2(attribute),
11035 attributeNS: F3(attributeNS),
11036
11037 lazy: F2(lazyRef),
11038 lazy2: F3(lazyRef2),
11039 lazy3: F4(lazyRef3),
11040
11041 toElement: F3(toElement),
11042 fromElement: fromElement,
11043
11044 render: createElement,
11045 updateAndReplace: updateAndReplace
11046 };
11047};
11048
11049},{"virtual-dom/vdom/create-element":6,"virtual-dom/vdom/patch":9,"virtual-dom/vnode/is-vhook":13,"virtual-dom/vnode/vnode":18,"virtual-dom/vnode/vtext":20,"virtual-dom/vtree/diff":22}]},{},[23]);
11050
11051Elm.VirtualDom = Elm.VirtualDom || {};
11052Elm.VirtualDom.make = function (_elm) {
11053 "use strict";
11054 _elm.VirtualDom = _elm.VirtualDom || {};
11055 if (_elm.VirtualDom.values) return _elm.VirtualDom.values;
11056 var _U = Elm.Native.Utils.make(_elm),
11057 $Basics = Elm.Basics.make(_elm),
11058 $Debug = Elm.Debug.make(_elm),
11059 $Graphics$Element = Elm.Graphics.Element.make(_elm),
11060 $Json$Decode = Elm.Json.Decode.make(_elm),
11061 $List = Elm.List.make(_elm),
11062 $Maybe = Elm.Maybe.make(_elm),
11063 $Native$VirtualDom = Elm.Native.VirtualDom.make(_elm),
11064 $Result = Elm.Result.make(_elm),
11065 $Signal = Elm.Signal.make(_elm);
11066 var _op = {};
11067 var lazy3 = $Native$VirtualDom.lazy3;
11068 var lazy2 = $Native$VirtualDom.lazy2;
11069 var lazy = $Native$VirtualDom.lazy;
11070 var defaultOptions = {stopPropagation: false,preventDefault: false};
11071 var Options = F2(function (a,b) { return {stopPropagation: a,preventDefault: b};});
11072 var onWithOptions = $Native$VirtualDom.on;
11073 var on = F3(function (eventName,decoder,toMessage) { return A4($Native$VirtualDom.on,eventName,defaultOptions,decoder,toMessage);});
11074 var attributeNS = $Native$VirtualDom.attributeNS;
11075 var attribute = $Native$VirtualDom.attribute;
11076 var property = $Native$VirtualDom.property;
11077 var Property = {ctor: "Property"};
11078 var fromElement = $Native$VirtualDom.fromElement;
11079 var toElement = $Native$VirtualDom.toElement;
11080 var text = $Native$VirtualDom.text;
11081 var node = $Native$VirtualDom.node;
11082 var Node = {ctor: "Node"};
11083 return _elm.VirtualDom.values = {_op: _op
11084 ,text: text
11085 ,node: node
11086 ,toElement: toElement
11087 ,fromElement: fromElement
11088 ,property: property
11089 ,attribute: attribute
11090 ,attributeNS: attributeNS
11091 ,on: on
11092 ,onWithOptions: onWithOptions
11093 ,defaultOptions: defaultOptions
11094 ,lazy: lazy
11095 ,lazy2: lazy2
11096 ,lazy3: lazy3
11097 ,Options: Options};
11098};
11099Elm.Html = Elm.Html || {};
11100Elm.Html.make = function (_elm) {
11101 "use strict";
11102 _elm.Html = _elm.Html || {};
11103 if (_elm.Html.values) return _elm.Html.values;
11104 var _U = Elm.Native.Utils.make(_elm),
11105 $Basics = Elm.Basics.make(_elm),
11106 $Debug = Elm.Debug.make(_elm),
11107 $Graphics$Element = Elm.Graphics.Element.make(_elm),
11108 $List = Elm.List.make(_elm),
11109 $Maybe = Elm.Maybe.make(_elm),
11110 $Result = Elm.Result.make(_elm),
11111 $Signal = Elm.Signal.make(_elm),
11112 $VirtualDom = Elm.VirtualDom.make(_elm);
11113 var _op = {};
11114 var fromElement = $VirtualDom.fromElement;
11115 var toElement = $VirtualDom.toElement;
11116 var text = $VirtualDom.text;
11117 var node = $VirtualDom.node;
11118 var body = node("body");
11119 var section = node("section");
11120 var nav = node("nav");
11121 var article = node("article");
11122 var aside = node("aside");
11123 var h1 = node("h1");
11124 var h2 = node("h2");
11125 var h3 = node("h3");
11126 var h4 = node("h4");
11127 var h5 = node("h5");
11128 var h6 = node("h6");
11129 var header = node("header");
11130 var footer = node("footer");
11131 var address = node("address");
11132 var main$ = node("main");
11133 var p = node("p");
11134 var hr = node("hr");
11135 var pre = node("pre");
11136 var blockquote = node("blockquote");
11137 var ol = node("ol");
11138 var ul = node("ul");
11139 var li = node("li");
11140 var dl = node("dl");
11141 var dt = node("dt");
11142 var dd = node("dd");
11143 var figure = node("figure");
11144 var figcaption = node("figcaption");
11145 var div = node("div");
11146 var a = node("a");
11147 var em = node("em");
11148 var strong = node("strong");
11149 var small = node("small");
11150 var s = node("s");
11151 var cite = node("cite");
11152 var q = node("q");
11153 var dfn = node("dfn");
11154 var abbr = node("abbr");
11155 var time = node("time");
11156 var code = node("code");
11157 var $var = node("var");
11158 var samp = node("samp");
11159 var kbd = node("kbd");
11160 var sub = node("sub");
11161 var sup = node("sup");
11162 var i = node("i");
11163 var b = node("b");
11164 var u = node("u");
11165 var mark = node("mark");
11166 var ruby = node("ruby");
11167 var rt = node("rt");
11168 var rp = node("rp");
11169 var bdi = node("bdi");
11170 var bdo = node("bdo");
11171 var span = node("span");
11172 var br = node("br");
11173 var wbr = node("wbr");
11174 var ins = node("ins");
11175 var del = node("del");
11176 var img = node("img");
11177 var iframe = node("iframe");
11178 var embed = node("embed");
11179 var object = node("object");
11180 var param = node("param");
11181 var video = node("video");
11182 var audio = node("audio");
11183 var source = node("source");
11184 var track = node("track");
11185 var canvas = node("canvas");
11186 var svg = node("svg");
11187 var math = node("math");
11188 var table = node("table");
11189 var caption = node("caption");
11190 var colgroup = node("colgroup");
11191 var col = node("col");
11192 var tbody = node("tbody");
11193 var thead = node("thead");
11194 var tfoot = node("tfoot");
11195 var tr = node("tr");
11196 var td = node("td");
11197 var th = node("th");
11198 var form = node("form");
11199 var fieldset = node("fieldset");
11200 var legend = node("legend");
11201 var label = node("label");
11202 var input = node("input");
11203 var button = node("button");
11204 var select = node("select");
11205 var datalist = node("datalist");
11206 var optgroup = node("optgroup");
11207 var option = node("option");
11208 var textarea = node("textarea");
11209 var keygen = node("keygen");
11210 var output = node("output");
11211 var progress = node("progress");
11212 var meter = node("meter");
11213 var details = node("details");
11214 var summary = node("summary");
11215 var menuitem = node("menuitem");
11216 var menu = node("menu");
11217 return _elm.Html.values = {_op: _op
11218 ,node: node
11219 ,text: text
11220 ,toElement: toElement
11221 ,fromElement: fromElement
11222 ,body: body
11223 ,section: section
11224 ,nav: nav
11225 ,article: article
11226 ,aside: aside
11227 ,h1: h1
11228 ,h2: h2
11229 ,h3: h3
11230 ,h4: h4
11231 ,h5: h5
11232 ,h6: h6
11233 ,header: header
11234 ,footer: footer
11235 ,address: address
11236 ,main$: main$
11237 ,p: p
11238 ,hr: hr
11239 ,pre: pre
11240 ,blockquote: blockquote
11241 ,ol: ol
11242 ,ul: ul
11243 ,li: li
11244 ,dl: dl
11245 ,dt: dt
11246 ,dd: dd
11247 ,figure: figure
11248 ,figcaption: figcaption
11249 ,div: div
11250 ,a: a
11251 ,em: em
11252 ,strong: strong
11253 ,small: small
11254 ,s: s
11255 ,cite: cite
11256 ,q: q
11257 ,dfn: dfn
11258 ,abbr: abbr
11259 ,time: time
11260 ,code: code
11261 ,$var: $var
11262 ,samp: samp
11263 ,kbd: kbd
11264 ,sub: sub
11265 ,sup: sup
11266 ,i: i
11267 ,b: b
11268 ,u: u
11269 ,mark: mark
11270 ,ruby: ruby
11271 ,rt: rt
11272 ,rp: rp
11273 ,bdi: bdi
11274 ,bdo: bdo
11275 ,span: span
11276 ,br: br
11277 ,wbr: wbr
11278 ,ins: ins
11279 ,del: del
11280 ,img: img
11281 ,iframe: iframe
11282 ,embed: embed
11283 ,object: object
11284 ,param: param
11285 ,video: video
11286 ,audio: audio
11287 ,source: source
11288 ,track: track
11289 ,canvas: canvas
11290 ,svg: svg
11291 ,math: math
11292 ,table: table
11293 ,caption: caption
11294 ,colgroup: colgroup
11295 ,col: col
11296 ,tbody: tbody
11297 ,thead: thead
11298 ,tfoot: tfoot
11299 ,tr: tr
11300 ,td: td
11301 ,th: th
11302 ,form: form
11303 ,fieldset: fieldset
11304 ,legend: legend
11305 ,label: label
11306 ,input: input
11307 ,button: button
11308 ,select: select
11309 ,datalist: datalist
11310 ,optgroup: optgroup
11311 ,option: option
11312 ,textarea: textarea
11313 ,keygen: keygen
11314 ,output: output
11315 ,progress: progress
11316 ,meter: meter
11317 ,details: details
11318 ,summary: summary
11319 ,menuitem: menuitem
11320 ,menu: menu};
11321};
11322Elm.Native.Lazy = {};
11323Elm.Native.Lazy.make = function(localRuntime) {
11324
11325 localRuntime.Native = localRuntime.Native || {};
11326 localRuntime.Native.Lazy = localRuntime.Native.Lazy || {};
11327 if (localRuntime.Native.Lazy.values) {
11328 return localRuntime.Native.Lazy.values;
11329 }
11330
11331 function memoize(thunk) {
11332 var value;
11333 var isForced = false;
11334 return function(tuple0) {
11335 if (!isForced) {
11336 value = thunk(tuple0);
11337 isForced = true;
11338 }
11339 return value;
11340 };
11341 }
11342
11343 return localRuntime.Native.Lazy.values = {
11344 memoize: memoize
11345 };
11346};
11347
11348Elm.Lazy = Elm.Lazy || {};
11349Elm.Lazy.make = function (_elm) {
11350 "use strict";
11351 _elm.Lazy = _elm.Lazy || {};
11352 if (_elm.Lazy.values) return _elm.Lazy.values;
11353 var _U = Elm.Native.Utils.make(_elm),
11354 $Basics = Elm.Basics.make(_elm),
11355 $Debug = Elm.Debug.make(_elm),
11356 $List = Elm.List.make(_elm),
11357 $Maybe = Elm.Maybe.make(_elm),
11358 $Native$Lazy = Elm.Native.Lazy.make(_elm),
11359 $Result = Elm.Result.make(_elm),
11360 $Signal = Elm.Signal.make(_elm);
11361 var _op = {};
11362 var force = function (_p0) { var _p1 = _p0;return _p1._0({ctor: "_Tuple0"});};
11363 var Lazy = function (a) { return {ctor: "Lazy",_0: a};};
11364 var lazy = function (thunk) { return Lazy($Native$Lazy.memoize(thunk));};
11365 var map = F2(function (f,a) { return lazy(function (_p2) { var _p3 = _p2;return f(force(a));});});
11366 var map2 = F3(function (f,a,b) { return lazy(function (_p4) { var _p5 = _p4;return A2(f,force(a),force(b));});});
11367 var map3 = F4(function (f,a,b,c) { return lazy(function (_p6) { var _p7 = _p6;return A3(f,force(a),force(b),force(c));});});
11368 var map4 = F5(function (f,a,b,c,d) { return lazy(function (_p8) { var _p9 = _p8;return A4(f,force(a),force(b),force(c),force(d));});});
11369 var map5 = F6(function (f,a,b,c,d,e) { return lazy(function (_p10) { var _p11 = _p10;return A5(f,force(a),force(b),force(c),force(d),force(e));});});
11370 var apply = F2(function (f,x) { return lazy(function (_p12) { var _p13 = _p12;return A2(force,f,force(x));});});
11371 var andThen = F2(function (a,callback) { return lazy(function (_p14) { var _p15 = _p14;return force(callback(force(a)));});});
11372 return _elm.Lazy.values = {_op: _op,force: force,lazy: lazy,map: map,map2: map2,map3: map3,map4: map4,map5: map5,apply: apply,andThen: andThen};
11373};
11374Elm.TaskUtil = Elm.TaskUtil || {};
11375Elm.TaskUtil.make = function (_elm) {
11376 "use strict";
11377 _elm.TaskUtil = _elm.TaskUtil || {};
11378 if (_elm.TaskUtil.values) return _elm.TaskUtil.values;
11379 var _U = Elm.Native.Utils.make(_elm),
11380 $Basics = Elm.Basics.make(_elm),
11381 $Debug = Elm.Debug.make(_elm),
11382 $List = Elm.List.make(_elm),
11383 $Maybe = Elm.Maybe.make(_elm),
11384 $Result = Elm.Result.make(_elm),
11385 $Signal = Elm.Signal.make(_elm),
11386 $Task = Elm.Task.make(_elm),
11387 $Task$Extra = Elm.Task.Extra.make(_elm);
11388 var _op = {};
11389 var notify = F3(function (address,tag,result) { return A2($Signal.send,address,tag(result));});
11390 var orDoNothing = $Maybe.withDefault($Task.succeed({ctor: "_Tuple0"}));
11391 var parallel = function (tasks) { return A2($Task.map,$Basics.always({ctor: "_Tuple0"}),$Task$Extra.parallel(tasks));};
11392 var onError = $Basics.flip($Task.onError);
11393 var swallowError = F2(function (errorMessage,task) {
11394 return A2(onError,
11395 $Basics.always($Task.succeed({ctor: "_Tuple0"})),
11396 A2($Task.mapError,$Debug.log(errorMessage),A2($Task.map,$Basics.always({ctor: "_Tuple0"}),task)));
11397 });
11398 var andThen = $Basics.flip($Task.andThen);
11399 return _elm.TaskUtil.values = {_op: _op
11400 ,andThen: andThen
11401 ,onError: onError
11402 ,swallowError: swallowError
11403 ,parallel: parallel
11404 ,orDoNothing: orDoNothing
11405 ,notify: notify};
11406};
11407Elm.FirebaseModel = Elm.FirebaseModel || {};
11408Elm.FirebaseModel.Mapping = Elm.FirebaseModel.Mapping || {};
11409Elm.FirebaseModel.Mapping.make = function (_elm) {
11410 "use strict";
11411 _elm.FirebaseModel = _elm.FirebaseModel || {};
11412 _elm.FirebaseModel.Mapping = _elm.FirebaseModel.Mapping || {};
11413 if (_elm.FirebaseModel.Mapping.values) return _elm.FirebaseModel.Mapping.values;
11414 var _U = Elm.Native.Utils.make(_elm),
11415 $Basics = Elm.Basics.make(_elm),
11416 $Debug = Elm.Debug.make(_elm),
11417 $Dict = Elm.Dict.make(_elm),
11418 $ElmFire = Elm.ElmFire.make(_elm),
11419 $Json$Decode = Elm.Json.Decode.make(_elm),
11420 $Json$Encode = Elm.Json.Encode.make(_elm),
11421 $Lazy = Elm.Lazy.make(_elm),
11422 $List = Elm.List.make(_elm),
11423 $Maybe = Elm.Maybe.make(_elm),
11424 $Result = Elm.Result.make(_elm),
11425 $Signal = Elm.Signal.make(_elm),
11426 $Task = Elm.Task.make(_elm),
11427 $TaskUtil = Elm.TaskUtil.make(_elm);
11428 var _op = {};
11429 _op["+/"] = F2(function (base,suffix) { return A2($Basics._op["++"],base,A2($Basics._op["++"],"/",suffix));});
11430 var valueChangedAt = F2(function (url,remoteEntryEvent) {
11431 if (_U.eq(remoteEntryEvent.url,url)) {
11432 var _p0 = remoteEntryEvent.data;
11433 if (_p0.ctor === "ValueChanged") {
11434 return true;
11435 } else {
11436 return false;
11437 }
11438 } else return false;
11439 });
11440 var Option = F4(function (a,b,c,d) { return {typeName: a,constructor: b,selector: c,mapping: d};});
11441 var valueUrl = function (url) { return A2(_op["+/"],url,"value");};
11442 var typeUrl = function (url) { return A2(_op["+/"],url,"type");};
11443 var Field = F3(function (a,b,c) { return {key: a,get: b,mapping: c};});
11444 var unsubscribe = F2(function (url,cache) {
11445 return $TaskUtil.orDoNothing(A2($Maybe.andThen,
11446 A2($Dict.get,url,cache),
11447 function (entry) {
11448 return A2($Maybe.map,
11449 function (subscription) {
11450 return A2($TaskUtil.swallowError,"ElmFire.unsubscribe failed",$ElmFire.unsubscribe(subscription));
11451 },
11452 $Result.toMaybe(entry.subscription));
11453 }));
11454 });
11455 var updateCache = F3(function (lastEvent,transform,state) { return _U.update(state,{cache: transform(state.cache),lastEvent: lastEvent});});
11456 var updateEntry = F5(function (event,url,entryField,getNewEntry,state) {
11457 return A3(updateCache,
11458 event,
11459 function (cache) {
11460 return A3($Dict.update,
11461 url,
11462 function (maybeEntry) {
11463 var newEntry = getNewEntry(maybeEntry);
11464 var result = function () {
11465 var _p1 = maybeEntry;
11466 if (_p1.ctor === "Nothing") {
11467 return $Maybe.Just(newEntry);
11468 } else {
11469 var _p3 = _p1._0;
11470 return $Maybe.Just(function () {
11471 var _p2 = entryField;
11472 if (_p2.ctor === "FieldMaybeValue") {
11473 return _U.update(_p3,{maybeValue: newEntry.maybeValue});
11474 } else {
11475 return _U.update(_p3,{subscription: newEntry.subscription});
11476 }
11477 }());
11478 }
11479 }();
11480 return result;
11481 },
11482 cache);
11483 },
11484 state);
11485 });
11486 var FieldSubscription = {ctor: "FieldSubscription"};
11487 var FieldMaybeValue = {ctor: "FieldMaybeValue"};
11488 var initialState = {cache: $Dict.empty,previousCache: $Dict.empty,lastEvent: $Maybe.Nothing};
11489 var ValueChanged = function (a) { return {ctor: "ValueChanged",_0: a};};
11490 var Cancelled = function (a) { return {ctor: "Cancelled",_0: a};};
11491 var SubscriptionFailed = function (a) { return {ctor: "SubscriptionFailed",_0: a};};
11492 var Unsubscribed = {ctor: "Unsubscribed"};
11493 var Subscribed = function (a) { return {ctor: "Subscribed",_0: a};};
11494 var subscribe = F2(function (address,url) {
11495 var sendEvent = function (entryEvent) { return A2($Signal.send,address,$Maybe.Just({url: url,data: entryEvent}));};
11496 var task = A4($ElmFire.subscribe,
11497 function (snapshot) {
11498 return sendEvent(ValueChanged(snapshot.value));
11499 },
11500 function (cancellation) {
11501 return sendEvent(Cancelled(cancellation));
11502 },
11503 $ElmFire.valueChanged($ElmFire.noOrder),
11504 $ElmFire.fromUrl(url));
11505 var result = A2($TaskUtil.onError,
11506 function (error) {
11507 return sendEvent(SubscriptionFailed(error));
11508 },
11509 A2($TaskUtil.andThen,function (subscription) { return sendEvent(Subscribed(subscription));},task));
11510 return result;
11511 });
11512 var Entry = F2(function (a,b) { return {maybeValue: a,subscription: b};});
11513 var State = F3(function (a,b,c) { return {cache: a,previousCache: b,lastEvent: c};});
11514 var getFunctions = function (mapping) { var _p4 = mapping;if (_p4.ctor === "Direct") { return _p4._0;} else { return $Lazy.force(_p4._0);}};
11515 var MappingFunctions = F5(function (a,b,c,d,e) { return {transform: a,subscribe: b,unsubscribe: c,handle: d,set: e};});
11516 var Recursive = function (a) { return {ctor: "Recursive",_0: a};};
11517 var fieldToMapping = function (field) {
11518 var mappingFunctions = getFunctions(field.mapping);
11519 var result = Recursive($Lazy.lazy(function (_p5) {
11520 var _p6 = _p5;
11521 return {transform: F2(function (url,cache) { return A2(mappingFunctions.transform,A2(_op["+/"],url,field.key),cache);})
11522 ,subscribe: F2(function (address,url) { return A2(mappingFunctions.subscribe,address,A2(_op["+/"],url,field.key));})
11523 ,unsubscribe: F2(function (url,cache) { return A2(mappingFunctions.unsubscribe,A2(_op["+/"],url,field.key),cache);})
11524 ,handle: F3(function (address,url,state) { return A3(mappingFunctions.handle,address,A2(_op["+/"],url,field.key),state);})
11525 ,set: F2(function (model,url) {
11526 return $TaskUtil.orDoNothing(A2($Maybe.map,
11527 function (fieldModel) {
11528 return A2(mappingFunctions.set,fieldModel,A2(_op["+/"],url,field.key));
11529 },
11530 $Result.toMaybe(function (_) { return _.data;}(field.get(model)))));
11531 })};
11532 }));
11533 return result;
11534 };
11535 var recursive = function (getMapping) {
11536 return Recursive($Lazy.lazy(function (_p7) { var _p8 = _p7;return getFunctions(getMapping({ctor: "_Tuple0"}));}));
11537 };
11538 var Direct = function (a) { return {ctor: "Direct",_0: a};};
11539 var $delete = function (url) { return A2($Task.map,$Basics.always({ctor: "_Tuple0"}),$ElmFire.remove($ElmFire.fromUrl(url)));};
11540 var set = F3(function (mapping,model,url) { return A2(getFunctions(mapping).set,model,url);});
11541 var ElmFireCancellation = function (a) { return {ctor: "ElmFireCancellation",_0: a};};
11542 var ElmFireError = function (a) { return {ctor: "ElmFireError",_0: a};};
11543 var NoSubscription = {ctor: "NoSubscription"};
11544 var update = F2(function (event,state) {
11545 var _p9 = event;
11546 if (_p9.ctor === "Nothing") {
11547 return state;
11548 } else {
11549 var _p11 = _p9._0;
11550 var _p10 = _p11.data;
11551 switch (_p10.ctor)
11552 {case "Subscribed": return A5(updateEntry,
11553 event,
11554 _p11.url,
11555 FieldSubscription,
11556 $Basics.always({maybeValue: $Maybe.Nothing,subscription: $Result.Ok(_p10._0)}),
11557 state);
11558 case "Unsubscribed": return A5(updateEntry,
11559 event,
11560 _p11.url,
11561 FieldSubscription,
11562 $Basics.always({maybeValue: $Maybe.Nothing,subscription: $Result.Err(NoSubscription)}),
11563 state);
11564 case "SubscriptionFailed": return A5(updateEntry,
11565 event,
11566 _p11.url,
11567 FieldSubscription,
11568 $Basics.always({maybeValue: $Maybe.Nothing,subscription: $Result.Err(ElmFireError(_p10._0))}),
11569 state);
11570 case "Cancelled": return A5(updateEntry,
11571 event,
11572 _p11.url,
11573 FieldSubscription,
11574 $Basics.always({maybeValue: $Maybe.Nothing,subscription: $Result.Err(ElmFireCancellation(_p10._0))}),
11575 state);
11576 default: return A5(updateEntry,
11577 event,
11578 _p11.url,
11579 FieldMaybeValue,
11580 $Basics.always({maybeValue: $Maybe.Just(_p10._0),subscription: $Result.Err(NoSubscription)}),
11581 state);}
11582 }
11583 });
11584 var mirror = F2(function (mapping,url) {
11585 var mappingFunctions = getFunctions(mapping);
11586 var eventMailbox = $Signal.mailbox($Maybe.Nothing);
11587 var subscribeTask = A2(mappingFunctions.subscribe,eventMailbox.address,url);
11588 var states = A3($Signal.foldp,update,initialState,eventMailbox.signal);
11589 var result = {model: A2($Signal.map,function (state) { return A2(mappingFunctions.transform,url,state.cache);},states)
11590 ,tasksToRun: $Signal.mergeMany(_U.list([$Signal.constant(subscribeTask)
11591 ,A2($Signal.map,A2(mappingFunctions.handle,eventMailbox.address,url),states)]))};
11592 return result;
11593 });
11594 var SubscriptionError = function (a) { return {ctor: "SubscriptionError",_0: a};};
11595 var DecodingError = function (a) { return {ctor: "DecodingError",_0: a};};
11596 var Loading = {ctor: "Loading"};
11597 var Remote = F2(function (a,b) { return {url: a,data: b};});
11598 var decode = F3(function (decoder,url,cache) {
11599 return A2(Remote,
11600 url,
11601 function () {
11602 var _p12 = A2($Dict.get,url,cache);
11603 if (_p12.ctor === "Nothing") {
11604 return $Result.Err(SubscriptionError(NoSubscription));
11605 } else {
11606 var _p16 = _p12._0;
11607 var _p13 = _p16.maybeValue;
11608 if (_p13.ctor === "Nothing") {
11609 var _p14 = _p16.subscription;
11610 if (_p14.ctor === "Err") {
11611 return $Result.Err(SubscriptionError(_p14._0));
11612 } else {
11613 return $Result.Err(Loading);
11614 }
11615 } else {
11616 var _p15 = A2($Json$Decode.decodeValue,decoder,_p13._0);
11617 if (_p15.ctor === "Err") {
11618 return $Result.Err(DecodingError(_p15._0));
11619 } else {
11620 return $Result.Ok(_p15._0);
11621 }
11622 }
11623 }
11624 }());
11625 });
11626 var fromCodec = F2(function (encoder,decoder) {
11627 return Direct({transform: decode(decoder)
11628 ,subscribe: subscribe
11629 ,unsubscribe: unsubscribe
11630 ,handle: F3(function (address,url,state) { return $Task.succeed({ctor: "_Tuple0"});})
11631 ,set: F2(function (model,url) {
11632 return A2($Task.map,$Basics.always({ctor: "_Tuple0"}),A2($ElmFire.set,encoder(model),$ElmFire.fromUrl(url)));
11633 })});
11634 });
11635 var getTypeName = F2(function (url,cache) { return function (_) { return _.data;}(A3(decode,$Json$Decode.string,typeUrl(url),cache));});
11636 var object = function (constructor) {
11637 return Direct({transform: F2(function (url,cache) { return A2(Remote,url,$Result.Ok(constructor));})
11638 ,subscribe: F2(function (address,url) { return $Task.succeed({ctor: "_Tuple0"});})
11639 ,unsubscribe: F2(function (url,cache) { return $Task.succeed({ctor: "_Tuple0"});})
11640 ,handle: F3(function (address,url,state) { return $Task.succeed({ctor: "_Tuple0"});})
11641 ,set: F2(function (model,url) { return $Task.succeed({ctor: "_Tuple0"});})});
11642 };
11643 var withField = F2(function (functionMapping,field) {
11644 var fieldMappingFunctions = getFunctions(fieldToMapping(field));
11645 var functionMappingFunctions = getFunctions(functionMapping);
11646 var result = Recursive($Lazy.lazy(function (_p17) {
11647 var _p18 = _p17;
11648 return {transform: F2(function (url,cache) {
11649 var storedField = A2(fieldMappingFunctions.transform,url,cache);
11650 var functionResult = function (_) { return _.data;}(A2(functionMappingFunctions.transform,url,cache));
11651 var transformed = A2(Remote,url,A2($Result.map,function ($function) { return $function(storedField);},functionResult));
11652 return transformed;
11653 })
11654 ,subscribe: F2(function (address,url) {
11655 return $TaskUtil.parallel(_U.list([A2(functionMappingFunctions.subscribe,address,url),A2(fieldMappingFunctions.subscribe,address,url)]));
11656 })
11657 ,unsubscribe: F2(function (url,cache) {
11658 return $TaskUtil.parallel(_U.list([A2(functionMappingFunctions.unsubscribe,url,cache),A2(fieldMappingFunctions.unsubscribe,url,cache)]));
11659 })
11660 ,handle: F3(function (address,url,state) {
11661 return $TaskUtil.parallel(_U.list([A3(functionMappingFunctions.handle,address,url,state)
11662 ,A3(fieldMappingFunctions.handle,address,url,state)]));
11663 })
11664 ,set: F2(function (model,url) {
11665 return $TaskUtil.parallel(_U.list([A2(functionMappingFunctions.set,model,url),A2(fieldMappingFunctions.set,model,url)]));
11666 })};
11667 }));
11668 return result;
11669 });
11670 var choice = function () {
11671 var result = Direct({transform: F2(function (url,cache) { return A2(Remote,url,$Result.Err(DecodingError("Choice has no options")));})
11672 ,subscribe: F2(function (address,url) { return A2(subscribe,address,typeUrl(url));})
11673 ,unsubscribe: F2(function (url,cache) { return A2(unsubscribe,typeUrl(url),cache);})
11674 ,handle: F3(function (address,url,state) { return $Task.succeed({ctor: "_Tuple0"});})
11675 ,set: F2(function (model,url) { return $Task.succeed({ctor: "_Tuple0"});})});
11676 return result;
11677 }();
11678 var optionToMapping = function (option) {
11679 var mappingFunctions = getFunctions(option.mapping);
11680 var ifSelected = F3(function (url,cache,valueResult) {
11681 return A2($Result.andThen,
11682 A2($Result.formatError,
11683 function (error) {
11684 return DecodingError(A2($Basics._op["++"],"Failed to get type name: ",$Basics.toString(error)));
11685 },
11686 A2(getTypeName,url,cache)),
11687 function (typeName) {
11688 return _U.eq(option.typeName,typeName) ? valueResult : $Result.Err(DecodingError(A2($Basics._op["++"],"Unsupported type name: ",typeName)));
11689 });
11690 });
11691 var doIfSelected = F3(function (url,cache,task) { return $TaskUtil.orDoNothing($Result.toMaybe(A3(ifSelected,url,cache,$Result.Ok(task))));});
11692 var result = Recursive($Lazy.lazy(function (_p19) {
11693 var _p20 = _p19;
11694 return {transform: F2(function (url,cache) {
11695 return A2(Remote,
11696 url,
11697 A2($Result.andThen,
11698 A3(ifSelected,url,cache,$Result.Ok({ctor: "_Tuple0"})),
11699 function (_p21) {
11700 return A2($Result.map,option.constructor,function (_) { return _.data;}(A2(mappingFunctions.transform,valueUrl(url),cache)));
11701 }));
11702 })
11703 ,subscribe: F2(function (address,url) { return $Task.succeed({ctor: "_Tuple0"});})
11704 ,unsubscribe: F2(function (url,cache) { return A3(doIfSelected,url,cache,A2(mappingFunctions.unsubscribe,valueUrl(url),cache));})
11705 ,handle: F3(function (address,url,state) {
11706 var thisValueChanged = A2($Maybe.withDefault,
11707 false,
11708 A2($Maybe.map,function (remoteEntryEvent) { return A2(valueChangedAt,typeUrl(url),remoteEntryEvent);},state.lastEvent));
11709 var subscribeWithNewMapping = thisValueChanged ? A3(doIfSelected,
11710 url,
11711 state.cache,
11712 A2(mappingFunctions.subscribe,address,valueUrl(url))) : $Task.succeed({ctor: "_Tuple0"});
11713 var unsubscribeWithOldMapping = thisValueChanged ? A3(doIfSelected,
11714 url,
11715 state.previousCache,
11716 A2(mappingFunctions.unsubscribe,valueUrl(url),state.previousCache)) : $Task.succeed({ctor: "_Tuple0"});
11717 var handleCurrentMapping = A3(doIfSelected,url,state.cache,A3(mappingFunctions.handle,address,valueUrl(url),state));
11718 var result = $TaskUtil.parallel(_U.list([handleCurrentMapping,unsubscribeWithOldMapping,subscribeWithNewMapping]));
11719 return result;
11720 })
11721 ,set: F2(function (model,url) {
11722 return $TaskUtil.orDoNothing(A2($Maybe.map,
11723 function (optionModel) {
11724 return $TaskUtil.parallel(_U.list([A2($Task.map,
11725 $Basics.always({ctor: "_Tuple0"}),
11726 A2($ElmFire.set,$Json$Encode.string(option.typeName),$ElmFire.fromUrl(typeUrl(url))))
11727 ,A2(mappingFunctions.set,optionModel,valueUrl(url))]));
11728 },
11729 option.selector(model)));
11730 })};
11731 }));
11732 return result;
11733 };
11734 var withOption = F2(function (mapping,option) {
11735 var optionMappingFunctions = getFunctions(optionToMapping(option));
11736 var mappingFunctions = getFunctions(mapping);
11737 var result = Recursive($Lazy.lazy(function (_p22) {
11738 var _p23 = _p22;
11739 return {transform: F2(function (url,cache) {
11740 var transformedSoFar = A2(mappingFunctions.transform,url,cache);
11741 var transformed = function () {
11742 var _p24 = function (_) { return _.data;}(transformedSoFar);
11743 if (_p24.ctor === "Err") {
11744 return A2(optionMappingFunctions.transform,url,cache);
11745 } else {
11746 return transformedSoFar;
11747 }
11748 }();
11749 return transformed;
11750 })
11751 ,subscribe: F2(function (address,url) { return A2(mappingFunctions.subscribe,address,url);})
11752 ,unsubscribe: F2(function (url,cache) {
11753 return $TaskUtil.parallel(_U.list([A2(mappingFunctions.unsubscribe,url,cache),A2(optionMappingFunctions.unsubscribe,url,cache)]));
11754 })
11755 ,handle: F3(function (address,url,state) {
11756 return $TaskUtil.parallel(_U.list([A3(mappingFunctions.handle,address,url,state),A3(optionMappingFunctions.handle,address,url,state)]));
11757 })
11758 ,set: F2(function (model,url) {
11759 return $TaskUtil.parallel(_U.list([A2(mappingFunctions.set,model,url),A2(optionMappingFunctions.set,model,url)]));
11760 })};
11761 }));
11762 return result;
11763 });
11764 var Output = F2(function (a,b) { return {model: a,tasksToRun: b};});
11765 return _elm.FirebaseModel.Mapping.values = {_op: _op
11766 ,mirror: mirror
11767 ,set: set
11768 ,$delete: $delete
11769 ,fromCodec: fromCodec
11770 ,object: object
11771 ,withField: withField
11772 ,choice: choice
11773 ,withOption: withOption
11774 ,recursive: recursive
11775 ,Output: Output
11776 ,Remote: Remote
11777 ,Field: Field
11778 ,Loading: Loading
11779 ,DecodingError: DecodingError
11780 ,SubscriptionError: SubscriptionError
11781 ,NoSubscription: NoSubscription
11782 ,ElmFireError: ElmFireError
11783 ,ElmFireCancellation: ElmFireCancellation};
11784};
11785Elm.Dux = Elm.Dux || {};
11786Elm.Dux.Language = Elm.Dux.Language || {};
11787Elm.Dux.Language.Types = Elm.Dux.Language.Types || {};
11788Elm.Dux.Language.Types.make = function (_elm) {
11789 "use strict";
11790 _elm.Dux = _elm.Dux || {};
11791 _elm.Dux.Language = _elm.Dux.Language || {};
11792 _elm.Dux.Language.Types = _elm.Dux.Language.Types || {};
11793 if (_elm.Dux.Language.Types.values) return _elm.Dux.Language.Types.values;
11794 var _U = Elm.Native.Utils.make(_elm),
11795 $Basics = Elm.Basics.make(_elm),
11796 $Debug = Elm.Debug.make(_elm),
11797 $FirebaseModel$Mapping = Elm.FirebaseModel.Mapping.make(_elm),
11798 $List = Elm.List.make(_elm),
11799 $Maybe = Elm.Maybe.make(_elm),
11800 $Result = Elm.Result.make(_elm),
11801 $Signal = Elm.Signal.make(_elm);
11802 var _op = {};
11803 var FunctionCallExpression = function (a) { return {ctor: "FunctionCallExpression",_0: a};};
11804 var NumberLiteralExpression = function (a) { return {ctor: "NumberLiteralExpression",_0: a};};
11805 var FunctionCall = F3(function (a,b,c) { return {functionType: a,firstArgument: b,secondArgument: c};});
11806 var NumberLiteral = function (a) { return {value: a};};
11807 var Divide = {ctor: "Divide"};
11808 var Multiply = {ctor: "Multiply"};
11809 var Subtract = {ctor: "Subtract"};
11810 var Add = {ctor: "Add"};
11811 return _elm.Dux.Language.Types.values = {_op: _op
11812 ,Add: Add
11813 ,Subtract: Subtract
11814 ,Multiply: Multiply
11815 ,Divide: Divide
11816 ,NumberLiteral: NumberLiteral
11817 ,FunctionCall: FunctionCall
11818 ,NumberLiteralExpression: NumberLiteralExpression
11819 ,FunctionCallExpression: FunctionCallExpression};
11820};
11821Elm.Dux = Elm.Dux || {};
11822Elm.Dux.Language = Elm.Dux.Language || {};
11823Elm.Dux.Language.Mappings = Elm.Dux.Language.Mappings || {};
11824Elm.Dux.Language.Mappings.make = function (_elm) {
11825 "use strict";
11826 _elm.Dux = _elm.Dux || {};
11827 _elm.Dux.Language = _elm.Dux.Language || {};
11828 _elm.Dux.Language.Mappings = _elm.Dux.Language.Mappings || {};
11829 if (_elm.Dux.Language.Mappings.values) return _elm.Dux.Language.Mappings.values;
11830 var _U = Elm.Native.Utils.make(_elm),
11831 $Basics = Elm.Basics.make(_elm),
11832 $Debug = Elm.Debug.make(_elm),
11833 $Dux$Language$Types = Elm.Dux.Language.Types.make(_elm),
11834 $FirebaseModel$Mapping = Elm.FirebaseModel.Mapping.make(_elm),
11835 $Json$Decode = Elm.Json.Decode.make(_elm),
11836 $Json$Encode = Elm.Json.Encode.make(_elm),
11837 $List = Elm.List.make(_elm),
11838 $Maybe = Elm.Maybe.make(_elm),
11839 $Result = Elm.Result.make(_elm),
11840 $Signal = Elm.Signal.make(_elm),
11841 $String = Elm.String.make(_elm);
11842 var _op = {};
11843 var numberLiteral = A2($FirebaseModel$Mapping.withField,
11844 $FirebaseModel$Mapping.object($Dux$Language$Types.NumberLiteral),
11845 {key: "value",get: function (_) { return _.value;},mapping: A2($FirebaseModel$Mapping.fromCodec,$Json$Encode.$float,$Json$Decode.$float)});
11846 var functionType = A2($FirebaseModel$Mapping.fromCodec,
11847 function (model) {
11848 return $Json$Encode.string($String.toLower($Basics.toString(model)));
11849 },
11850 A2($Json$Decode.customDecoder,
11851 $Json$Decode.string,
11852 function (string) {
11853 var _p0 = string;
11854 switch (_p0)
11855 {case "add": return $Result.Ok($Dux$Language$Types.Add);
11856 case "subtract": return $Result.Ok($Dux$Language$Types.Subtract);
11857 case "multiply": return $Result.Ok($Dux$Language$Types.Multiply);
11858 case "divide": return $Result.Ok($Dux$Language$Types.Divide);
11859 default: return $Result.Err(A2($Basics._op["++"],"Unknown function type: ",_p0));}
11860 }));
11861 var functionCall = $FirebaseModel$Mapping.recursive(function (_p1) {
11862 var _p2 = _p1;
11863 return A2($FirebaseModel$Mapping.withField,
11864 A2($FirebaseModel$Mapping.withField,
11865 A2($FirebaseModel$Mapping.withField,
11866 $FirebaseModel$Mapping.object($Dux$Language$Types.FunctionCall),
11867 {key: "functionType",get: function (_) { return _.functionType;},mapping: functionType}),
11868 {key: "firstArgument"
11869 ,get: function (_) {
11870 return _.firstArgument;
11871 }
11872 ,mapping: $FirebaseModel$Mapping.recursive(function (_p3) { var _p4 = _p3;return expression;})}),
11873 {key: "secondArgument"
11874 ,get: function (_) {
11875 return _.secondArgument;
11876 }
11877 ,mapping: $FirebaseModel$Mapping.recursive(function (_p5) { var _p6 = _p5;return expression;})});
11878 });
11879 var expression = $FirebaseModel$Mapping.recursive(function (_p7) {
11880 var _p8 = _p7;
11881 return A2($FirebaseModel$Mapping.withOption,
11882 A2($FirebaseModel$Mapping.withOption,
11883 $FirebaseModel$Mapping.choice,
11884 {typeName: "numberLiteral"
11885 ,constructor: $Dux$Language$Types.NumberLiteralExpression
11886 ,selector: function (expression) {
11887 var _p9 = expression;
11888 if (_p9.ctor === "NumberLiteralExpression") {
11889 return $Maybe.Just(_p9._0);
11890 } else {
11891 return $Maybe.Nothing;
11892 }
11893 }
11894 ,mapping: numberLiteral}),
11895 {typeName: "functionCall"
11896 ,constructor: $Dux$Language$Types.FunctionCallExpression
11897 ,selector: function (expression) {
11898 var _p10 = expression;
11899 if (_p10.ctor === "FunctionCallExpression") {
11900 return $Maybe.Just(_p10._0);
11901 } else {
11902 return $Maybe.Nothing;
11903 }
11904 }
11905 ,mapping: $FirebaseModel$Mapping.recursive(function (_p11) { var _p12 = _p11;return functionCall;})});
11906 });
11907 return _elm.Dux.Language.Mappings.values = {_op: _op
11908 ,functionType: functionType
11909 ,numberLiteral: numberLiteral
11910 ,functionCall: functionCall
11911 ,expression: expression};
11912};
11913Elm.Test = Elm.Test || {};
11914Elm.Test.Dux = Elm.Test.Dux || {};
11915Elm.Test.Dux.Language = Elm.Test.Dux.Language || {};
11916Elm.Test.Dux.Language.Mappings = Elm.Test.Dux.Language.Mappings || {};
11917Elm.Test.Dux.Language.Mappings.make = function (_elm) {
11918 "use strict";
11919 _elm.Test = _elm.Test || {};
11920 _elm.Test.Dux = _elm.Test.Dux || {};
11921 _elm.Test.Dux.Language = _elm.Test.Dux.Language || {};
11922 _elm.Test.Dux.Language.Mappings = _elm.Test.Dux.Language.Mappings || {};
11923 if (_elm.Test.Dux.Language.Mappings.values) return _elm.Test.Dux.Language.Mappings.values;
11924 var _U = Elm.Native.Utils.make(_elm),
11925 $Basics = Elm.Basics.make(_elm),
11926 $Debug = Elm.Debug.make(_elm),
11927 $Dux$Language$Mappings = Elm.Dux.Language.Mappings.make(_elm),
11928 $Dux$Language$Types = Elm.Dux.Language.Types.make(_elm),
11929 $FirebaseModel$Mapping = Elm.FirebaseModel.Mapping.make(_elm),
11930 $Html = Elm.Html.make(_elm),
11931 $List = Elm.List.make(_elm),
11932 $Maybe = Elm.Maybe.make(_elm),
11933 $Result = Elm.Result.make(_elm),
11934 $Signal = Elm.Signal.make(_elm),
11935 $Task = Elm.Task.make(_elm);
11936 var _op = {};
11937 var toText = F2(function (title,a) {
11938 return A2($Html.div,_U.list([]),_U.list([$Html.text(A2($Basics._op["++"],title,A2($Basics._op["++"],": ",$Basics.toString(a))))]));
11939 });
11940 var baseUrl = "https://thsoft.firebaseio.com/DUX/test/";
11941 var functionType = A2($FirebaseModel$Mapping.mirror,$Dux$Language$Mappings.functionType,A2($Basics._op["++"],baseUrl,"FunctionType"));
11942 var functionTypeTasks = Elm.Native.Task.make(_elm).performSignal("functionTypeTasks",functionType.tasksToRun);
11943 var numberLiteral = A2($FirebaseModel$Mapping.mirror,$Dux$Language$Mappings.numberLiteral,A2($Basics._op["++"],baseUrl,"NumberLiteral"));
11944 var numberLiteralTasks = Elm.Native.Task.make(_elm).performSignal("numberLiteralTasks",numberLiteral.tasksToRun);
11945 var functionCall = A2($FirebaseModel$Mapping.mirror,$Dux$Language$Mappings.functionCall,A2($Basics._op["++"],baseUrl,"FunctionCall"));
11946 var functionCallTasks = Elm.Native.Task.make(_elm).performSignal("functionCallTasks",functionCall.tasksToRun);
11947 var expression = A2($FirebaseModel$Mapping.mirror,$Dux$Language$Mappings.expression,A2($Basics._op["++"],baseUrl,"Expression"));
11948 var main = A5($Signal.map4,
11949 F4(function (a,b,c,d) {
11950 return A2($Html.div,
11951 _U.list([]),
11952 _U.list([A2(toText,"FunctionType",a),A2(toText,"NumberLiteral",b),A2(toText,"FunctionCall",c),A2(toText,"Expression",d)]));
11953 }),
11954 functionType.model,
11955 numberLiteral.model,
11956 functionCall.model,
11957 expression.model);
11958 var expressionTasks = Elm.Native.Task.make(_elm).performSignal("expressionTasks",expression.tasksToRun);
11959 return _elm.Test.Dux.Language.Mappings.values = {_op: _op
11960 ,baseUrl: baseUrl
11961 ,functionType: functionType
11962 ,numberLiteral: numberLiteral
11963 ,functionCall: functionCall
11964 ,expression: expression
11965 ,main: main
11966 ,toText: toText};
11967};
11968</script><script>var runningElmModule =
11969 Elm.fullscreen(Elm.Test.Dux.Language.Mappings);</script></body></html>