-
Notifications
You must be signed in to change notification settings - Fork 0
/
chromeVox2ChromeBackgroundScript.js
1775 lines (1775 loc) · 466 KB
/
chromeVox2ChromeBackgroundScript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var COMPILED=true;var goog=goog||{};goog.global=this;goog.global.CLOSURE_UNCOMPILED_DEFINES;goog.global.CLOSURE_DEFINES;goog.isDef=function(val){return val!==void 0;};goog.exportPath_=function(name,opt_object,opt_objectToExportTo){var parts=name.split('.');var cur=opt_objectToExportTo||goog.global;if(!(parts[0]in cur)&&cur.execScript){cur.execScript('var '+parts[0]);}
for(var part;parts.length&&(part=parts.shift());){if(!parts.length&&goog.isDef(opt_object)){cur[part]=opt_object;}else if(cur[part]){cur=cur[part];}else{cur=cur[part]={};}}};goog.define=function(name,defaultValue){var value=defaultValue;if(!COMPILED){var uncompiledDefines=goog.global.CLOSURE_UNCOMPILED_DEFINES;var defines=goog.global.CLOSURE_DEFINES;if(uncompiledDefines&&(uncompiledDefines).nodeType===undefined&&Object.prototype.hasOwnProperty.call(uncompiledDefines,name)){value=uncompiledDefines[name];}else if(defines&&(defines).nodeType===undefined&&Object.prototype.hasOwnProperty.call(defines,name)){value=defines[name];}}
return value;};goog.DEBUG=true;goog.LOCALE=goog.define('goog.LOCALE','en');goog.TRUSTED_SITE=goog.define('goog.TRUSTED_SITE',true);goog.STRICT_MODE_COMPATIBLE=goog.define('goog.STRICT_MODE_COMPATIBLE',false);goog.provide=function(name){if(!COMPILED){if(goog.isProvided_(name)){throw Error('Namespace "'+name+'" already declared.');}
delete goog.implicitNamespaces_[name];var namespace=name;while((namespace=namespace.substring(0,namespace.lastIndexOf('.')))){if(goog.getObjectByName(namespace)){break;}
goog.implicitNamespaces_[namespace]=true;}}
goog.exportPath_(name);};goog.setTestOnly=function(opt_message){if(COMPILED&&!goog.DEBUG){opt_message=opt_message||'';throw Error('Importing test-only code into non-debug environment'+
opt_message?': '+opt_message:'.');}};goog.forwardDeclare=function(name){};if(!COMPILED){goog.isProvided_=function(name){return!goog.implicitNamespaces_[name]&&goog.isDefAndNotNull(goog.getObjectByName(name));};goog.implicitNamespaces_={};}
goog.getObjectByName=function(name,opt_obj){var parts=name.split('.');var cur=opt_obj||goog.global;for(var part;part=parts.shift();){if(goog.isDefAndNotNull(cur[part])){cur=cur[part];}else{return null;}}
return cur;};goog.globalize=function(obj,opt_global){var global=opt_global||goog.global;for(var x in obj){global[x]=obj[x];}};goog.addDependency=function(relPath,provides,requires){if(goog.DEPENDENCIES_ENABLED){var provide,require;var path=relPath.replace(/\\/g,'/');var deps=goog.dependencies_;for(var i=0;provide=provides[i];i++){deps.nameToPath[provide]=path;if(!(path in deps.pathToNames)){deps.pathToNames[path]={};}
deps.pathToNames[path][provide]=true;}
for(var j=0;require=requires[j];j++){if(!(path in deps.requires)){deps.requires[path]={};}
deps.requires[path][require]=true;}}};goog.ENABLE_DEBUG_LOADER=goog.define('goog.ENABLE_DEBUG_LOADER',true);goog.require=function(name){if(!COMPILED){if(goog.isProvided_(name)){return;}
if(goog.ENABLE_DEBUG_LOADER){var path=goog.getPathFromDeps_(name);if(path){goog.included_[path]=true;goog.writeScripts_();return;}}
var errorMessage='goog.require could not find: '+name;if(goog.global.console){goog.global.console['error'](errorMessage);}
throw Error(errorMessage);}};goog.basePath='';goog.global.CLOSURE_BASE_PATH;goog.global.CLOSURE_NO_DEPS=true;goog.global.CLOSURE_IMPORT_SCRIPT;goog.nullFunction=function(){};goog.identityFunction=function(opt_returnValue,var_args){return opt_returnValue;};goog.abstractMethod=function(){throw Error('unimplemented abstract method');};goog.addSingletonGetter=function(ctor){ctor.getInstance=function(){if(ctor.instance_){return ctor.instance_;}
if(goog.DEBUG){goog.instantiatedSingletons_[goog.instantiatedSingletons_.length]=ctor;}
return ctor.instance_=new ctor;};};goog.instantiatedSingletons_=[];goog.DEPENDENCIES_ENABLED=!COMPILED&&goog.ENABLE_DEBUG_LOADER;if(goog.DEPENDENCIES_ENABLED){goog.included_={};goog.dependencies_={pathToNames:{},nameToPath:{},requires:{},visited:{},written:{}};goog.inHtmlDocument_=function(){var doc=goog.global.document;return typeof doc!='undefined'&&'write'in doc;};goog.findBasePath_=function(){if(goog.global.CLOSURE_BASE_PATH){goog.basePath=goog.global.CLOSURE_BASE_PATH;return;}else if(!goog.inHtmlDocument_()){return;}
var doc=goog.global.document;var scripts=doc.getElementsByTagName('script');for(var i=scripts.length-1;i>=0;--i){var src=scripts[i].src;var qmark=src.lastIndexOf('?');var l=qmark==-1?src.length:qmark;if(src.substr(l-7,7)=='base.js'){goog.basePath=src.substr(0,l-7);return;}}};goog.importScript_=function(src){var importScript=goog.global.CLOSURE_IMPORT_SCRIPT||goog.writeScriptTag_;if(!goog.dependencies_.written[src]&&importScript(src)){goog.dependencies_.written[src]=true;}};goog.writeScriptTag_=function(src){if(goog.inHtmlDocument_()){var doc=goog.global.document;if(doc.readyState=='complete'){var isDeps=/\bdeps.js$/.test(src);if(isDeps){return false;}else{throw Error('Cannot write "'+src+'" after document load');}}
doc.write('<script type="text/javascript" src="'+src+'"></'+'script>');return true;}else{return false;}};goog.writeScripts_=function(){var scripts=[];var seenScript={};var deps=goog.dependencies_;function visitNode(path){if(path in deps.written){return;}
if(path in deps.visited){if(!(path in seenScript)){seenScript[path]=true;scripts.push(path);}
return;}
deps.visited[path]=true;if(path in deps.requires){for(var requireName in deps.requires[path]){if(!goog.isProvided_(requireName)){if(requireName in deps.nameToPath){visitNode(deps.nameToPath[requireName]);}else{throw Error('Undefined nameToPath for '+requireName);}}}}
if(!(path in seenScript)){seenScript[path]=true;scripts.push(path);}}
for(var path in goog.included_){if(!deps.written[path]){visitNode(path);}}
for(var i=0;i<scripts.length;i++){if(scripts[i]){goog.importScript_(goog.basePath+scripts[i]);}else{throw Error('Undefined script input');}}};goog.getPathFromDeps_=function(rule){if(rule in goog.dependencies_.nameToPath){return goog.dependencies_.nameToPath[rule];}else{return null;}};goog.findBasePath_();if(!goog.global.CLOSURE_NO_DEPS){goog.importScript_(goog.basePath+'deps.js');}}
goog.typeOf=function(value){var s=typeof value;if(s=='object'){if(value){if(value instanceof Array){return'array';}else if(value instanceof Object){return s;}
var className=Object.prototype.toString.call((value));if(className=='[object Window]'){return'object';}
if((className=='[object Array]'||typeof value.length=='number'&&typeof value.splice!='undefined'&&typeof value.propertyIsEnumerable!='undefined'&&!value.propertyIsEnumerable('splice'))){return'array';}
if((className=='[object Function]'||typeof value.call!='undefined'&&typeof value.propertyIsEnumerable!='undefined'&&!value.propertyIsEnumerable('call'))){return'function';}}else{return'null';}}else if(s=='function'&&typeof value.call=='undefined'){return'object';}
return s;};goog.isNull=function(val){return val===null;};goog.isDefAndNotNull=function(val){return val!=null;};goog.isArray=function(val){return goog.typeOf(val)=='array';};goog.isArrayLike=function(val){var type=goog.typeOf(val);return type=='array'||type=='object'&&typeof val.length=='number';};goog.isDateLike=function(val){return goog.isObject(val)&&typeof val.getFullYear=='function';};goog.isString=function(val){return typeof val=='string';};goog.isBoolean=function(val){return typeof val=='boolean';};goog.isNumber=function(val){return typeof val=='number';};goog.isFunction=function(val){return goog.typeOf(val)=='function';};goog.isObject=function(val){var type=typeof val;return type=='object'&&val!=null||type=='function';};goog.getUid=function(obj){return obj[goog.UID_PROPERTY_]||(obj[goog.UID_PROPERTY_]=++goog.uidCounter_);};goog.hasUid=function(obj){return!!obj[goog.UID_PROPERTY_];};goog.removeUid=function(obj){if('removeAttribute'in obj){obj.removeAttribute(goog.UID_PROPERTY_);}
try{delete obj[goog.UID_PROPERTY_];}catch(ex){}};goog.UID_PROPERTY_='closure_uid_'+((Math.random()*1e9)>>>0);goog.uidCounter_=0;goog.getHashCode=goog.getUid;goog.removeHashCode=goog.removeUid;goog.cloneObject=function(obj){var type=goog.typeOf(obj);if(type=='object'||type=='array'){if(obj.clone){return obj.clone();}
var clone=type=='array'?[]:{};for(var key in obj){clone[key]=goog.cloneObject(obj[key]);}
return clone;}
return obj;};goog.bindNative_=function(fn,selfObj,var_args){return(fn.call.apply(fn.bind,arguments));};goog.bindJs_=function(fn,selfObj,var_args){if(!fn){throw new Error();}
if(arguments.length>2){var boundArgs=Array.prototype.slice.call(arguments,2);return function(){var newArgs=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(newArgs,boundArgs);return fn.apply(selfObj,newArgs);};}else{return function(){return fn.apply(selfObj,arguments);};}};goog.bind=function(fn,selfObj,var_args){if(Function.prototype.bind&&Function.prototype.bind.toString().indexOf('native code')!=-1){goog.bind=goog.bindNative_;}else{goog.bind=goog.bindJs_;}
return goog.bind.apply(null,arguments);};goog.partial=function(fn,var_args){var args=Array.prototype.slice.call(arguments,1);return function(){var newArgs=args.slice();newArgs.push.apply(newArgs,arguments);return fn.apply(this,newArgs);};};goog.mixin=function(target,source){for(var x in source){target[x]=source[x];}};goog.now=(goog.TRUSTED_SITE&&Date.now)||(function(){return+new Date();});goog.globalEval=function(script){if(goog.global.execScript){goog.global.execScript(script,'JavaScript');}else if(goog.global.eval){if(goog.evalWorksForGlobals_==null){goog.global.eval('var _et_ = 1;');if(typeof goog.global['_et_']!='undefined'){delete goog.global['_et_'];goog.evalWorksForGlobals_=true;}else{goog.evalWorksForGlobals_=false;}}
if(goog.evalWorksForGlobals_){goog.global.eval(script);}else{var doc=goog.global.document;var scriptElt=doc.createElement('script');scriptElt.type='text/javascript';scriptElt.defer=false;scriptElt.appendChild(doc.createTextNode(script));doc.body.appendChild(scriptElt);doc.body.removeChild(scriptElt);}}else{throw Error('goog.globalEval not available');}};goog.evalWorksForGlobals_=null;goog.cssNameMapping_;goog.cssNameMappingStyle_;goog.getCssName=function(className,opt_modifier){var getMapping=function(cssName){return goog.cssNameMapping_[cssName]||cssName;};var renameByParts=function(cssName){var parts=cssName.split('-');var mapped=[];for(var i=0;i<parts.length;i++){mapped.push(getMapping(parts[i]));}
return mapped.join('-');};var rename;if(goog.cssNameMapping_){rename=goog.cssNameMappingStyle_=='BY_WHOLE'?getMapping:renameByParts;}else{rename=function(a){return a;};}
if(opt_modifier){return className+'-'+rename(opt_modifier);}else{return rename(className);}};goog.setCssNameMapping=function(mapping,opt_style){goog.cssNameMapping_=mapping;goog.cssNameMappingStyle_=opt_style;};goog.global.CLOSURE_CSS_NAME_MAPPING;if(!COMPILED&&goog.global.CLOSURE_CSS_NAME_MAPPING){goog.cssNameMapping_=goog.global.CLOSURE_CSS_NAME_MAPPING;}
goog.getMsg=function(str,opt_values){var values=opt_values||{};for(var key in values){var value=(''+values[key]).replace(/\$/g,'$$$$');str=str.replace(new RegExp('\\{\\$'+key+'\\}','gi'),value);}
return str;};goog.getMsgWithFallback=function(a,b){return a;};goog.exportSymbol=function(publicPath,object,opt_objectToExportTo){goog.exportPath_(publicPath,object,opt_objectToExportTo);};goog.exportProperty=function(object,publicName,symbol){object[publicName]=symbol;};goog.inherits=function(childCtor,parentCtor){function tempCtor(){};tempCtor.prototype=parentCtor.prototype;childCtor.superClass_=parentCtor.prototype;childCtor.prototype=new tempCtor();childCtor.prototype.constructor=childCtor;childCtor.base=function(me,methodName,var_args){var args=Array.prototype.slice.call(arguments,2);return parentCtor.prototype[methodName].apply(me,args);};};goog.base=function(me,opt_methodName,var_args){var caller=arguments.callee.caller;if(goog.STRICT_MODE_COMPATIBLE||(goog.DEBUG&&!caller)){throw Error('arguments.caller not defined. goog.base() cannot be used '+'with strict mode code. See '+'http://www.ecma-international.org/ecma-262/5.1/#sec-C');}
if(caller.superClass_){return caller.superClass_.constructor.apply(me,Array.prototype.slice.call(arguments,1));}
var args=Array.prototype.slice.call(arguments,2);var foundCaller=false;for(var ctor=me.constructor;ctor;ctor=ctor.superClass_&&ctor.superClass_.constructor){if(ctor.prototype[opt_methodName]===caller){foundCaller=true;}else if(foundCaller){return ctor.prototype[opt_methodName].apply(me,args);}}
if(me[opt_methodName]===caller){return me.constructor.prototype[opt_methodName].apply(me,args);}else{throw Error('goog.base called from a method of one name '+'to a method of a different name');}};goog.scope=function(fn){fn.call(goog.global);};if(!COMPILED){goog.global['COMPILED']=COMPILED;}
goog.provide('AutomationPredicate');goog.provide('AutomationPredicate.Binary');goog.provide('AutomationPredicate.Unary');goog.scope(function(){var AutomationNode=chrome.automation.AutomationNode;var RoleType=chrome.automation.RoleType;AutomationPredicate=function(){};AutomationPredicate.Unary;AutomationPredicate.Binary;AutomationPredicate.withRole=function(role){return function(node){return node.role==role;};};AutomationPredicate.checkBox=AutomationPredicate.withRole(RoleType.CHECK_BOX);AutomationPredicate.comboBox=AutomationPredicate.withRole(RoleType.COMBO_BOX);AutomationPredicate.heading=AutomationPredicate.withRole(RoleType.HEADING);AutomationPredicate.inlineTextBox=AutomationPredicate.withRole(RoleType.INLINE_TEXT_BOX);AutomationPredicate.link=AutomationPredicate.withRole(RoleType.LINK);AutomationPredicate.table=AutomationPredicate.withRole(RoleType.TABLE);AutomationPredicate.button=function(node){return/button/i.test(node.role);};AutomationPredicate.editText=function(node){return node.state.editable&&node.parent&&!node.parent.state.editable;};AutomationPredicate.formField=function(node){switch(node.role){case'button':case'buttonDropDown':case'checkBox':case'comboBox':case'date':case'dateTime':case'details':case'disclosureTriangle':case'form':case'menuListPopup':case'popUpButton':case'radioButton':case'searchBox':case'slider':case'spinButton':case'switch':case'tab':case'textField':case'time':case'toggleButton':case'tree':return true;}
return false;};AutomationPredicate.landmark=function(node){switch(node.role){case'application':case'banner':case'complementary':case'contentInfo':case'form':case'main':case'navigation':case'search':return true;}
return false;};AutomationPredicate.visitedLink=function(node){return node.state.visited;};AutomationPredicate.focused=function(node){return node.state.focused;};AutomationPredicate.leaf=function(node){return!node.firstChild||node.role==RoleType.BUTTON||node.role==RoleType.BUTTONDROPDOWN||node.role==RoleType.POP_UP_BUTTON||node.role==RoleType.SLIDER||node.role==RoleType.TEXT_FIELD||node.state.invisible||node.children.every(function(n){return n.state.invisible;});};AutomationPredicate.leafWithText=function(node){return AutomationPredicate.leaf(node)&&!!(node.name||node.value);};AutomationPredicate.leafDomNode=function(node){return AutomationPredicate.leaf(node)||node.role==RoleType.STATIC_TEXT;};AutomationPredicate.object=function(node){return node.state.focusable||(AutomationPredicate.leafDomNode(node)&&(/\S+/.test(node.name)||(node.role!=RoleType.LINE_BREAK&&node.role!=RoleType.STATIC_TEXT&&node.role!=RoleType.INLINE_TEXT_BOX)));};AutomationPredicate.linebreak=function(first,second){var fl=first.location;var sl=second.location;return fl.top!=sl.top||(fl.top+fl.height!=sl.top+sl.height);};AutomationPredicate.container=function(node){return AutomationPredicate.structuralContainer(node)||node.role==RoleType.DIV||node.role==RoleType.DOCUMENT||node.role==RoleType.GROUP||node.role==RoleType.LIST_ITEM||node.role==RoleType.TOOLBAR||node.role==RoleType.WINDOW;};AutomationPredicate.structuralContainer=function(node){return node.role==RoleType.ROOT_WEB_AREA||node.role==RoleType.EMBEDDED_OBJECT||node.role==RoleType.IFRAME||node.role==RoleType.IFRAME_PRESENTATIONAL||node.role==RoleType.PLUGIN_OBJECT;};AutomationPredicate.root=function(node){switch(node.role){case RoleType.DIALOG:case RoleType.WINDOW:return true;case RoleType.TOOLBAR:return node.root.role==RoleType.DESKTOP;case RoleType.ROOT_WEB_AREA:return!node.parent||node.parent.root.role==RoleType.DESKTOP;default:return false;}};AutomationPredicate.shouldIgnoreNode=function(node){if(node.state.invisible||(node.location.height==0&&node.location.width==0))
return true;if(AutomationPredicate.structuralContainer(node))
return true;if(node.role==RoleType.LIST_MARKER)
return true;if(node.name||node.value||node.description)
return false;return AutomationPredicate.leaf(node)&&(node.role==RoleType.CLIENT||node.role==RoleType.DIV||node.role==RoleType.GROUP||node.role==RoleType.IMAGE||node.role==RoleType.STATIC_TEXT);};});goog.provide('constants');constants.Dir={FORWARD:'forward',BACKWARD:'backward'};goog.provide('AutomationTreeWalker');goog.provide('AutomationTreeWalkerPhase');goog.provide('AutomationTreeWalkerRestriction');goog.require('constants');AutomationTreeWalkerPhase={INITIAL:'initial',ANCESTOR:'ancestor',DESCENDANT:'descendant',OTHER:'other'};var AutomationTreeWalkerRestriction;AutomationTreeWalker=function(node,dir,opt_restrictions){this.node_=node;this.phase_=AutomationTreeWalkerPhase.INITIAL;this.dir_=dir;this.initialNode_=node;this.backwardAncestor_=node.parent;var restrictions=opt_restrictions||{};this.visitPred_=function(node){if(this.skipInitialAncestry_&&this.phase_==AutomationTreeWalkerPhase.ANCESTOR)
return false;if(this.skipInitialSubtree_&&this.phase!=AutomationTreeWalkerPhase.ANCESTOR&&this.phase!=AutomationTreeWalkerPhase.OTHER)
return false;if(restrictions.visit)
return restrictions.visit(node);return true;};this.leafPred_=restrictions.leaf?restrictions.leaf:AutomationTreeWalker.falsePredicate_;this.rootPred_=restrictions.root?restrictions.root:AutomationTreeWalker.falsePredicate_;this.skipInitialAncestry_=restrictions.skipInitialAncestry||false;this.skipInitialSubtree_=restrictions.skipInitialSubtree||false;};AutomationTreeWalker.falsePredicate_=function(node){return false;};AutomationTreeWalker.prototype={get node(){return this.node_;},get phase(){return this.phase_;},next:function(){if(!this.node_)
return this;do{if(this.rootPred_(this.node_)&&this.dir_==constants.Dir.BACKWARD){this.node_=null;return this;}
if(this.dir_==constants.Dir.FORWARD)
this.forward_(this.node_);else
this.backward_(this.node_);}while(this.node_&&!this.visitPred_(this.node_));return this;},forward_:function(node){if(!this.leafPred_(node)&&node.firstChild){if(this.phase_==AutomationTreeWalkerPhase.INITIAL)
this.phase_=AutomationTreeWalkerPhase.DESCENDANT;if(!this.skipInitialSubtree_||this.phase!=AutomationTreeWalkerPhase.DESCENDANT){this.node_=node.firstChild;return;}}
var searchNode=node;while(searchNode){if(searchNode==this.initialNode_)
this.phase_=AutomationTreeWalkerPhase.OTHER;if(searchNode.nextSibling){this.node_=searchNode.nextSibling;return;}
if(searchNode.parent&&this.rootPred_(searchNode.parent))
break;searchNode=searchNode.parent;}
this.node_=null;},backward_:function(node){if(node.previousSibling){this.phase_=AutomationTreeWalkerPhase.OTHER;node=node.previousSibling;while(!this.leafPred_(node)&&node.lastChild)
node=node.lastChild;this.node_=node;return;}
if(node.parent&&this.backwardAncestor_==node.parent){this.phase_=AutomationTreeWalkerPhase.ANCESTOR;this.backwardAncestor_=node.parent.parent;}
this.node_=node.parent;}};goog.provide('AutomationUtil');goog.require('AutomationPredicate');goog.require('AutomationTreeWalker');goog.require('constants');AutomationUtil=function(){};goog.scope(function(){var AutomationNode=chrome.automation.AutomationNode;var Dir=constants.Dir;var RoleType=chrome.automation.RoleType;AutomationUtil.findNodePre=function(cur,dir,pred){if(!cur)
return null;if(pred(cur)&&!AutomationPredicate.shouldIgnoreNode(cur))
return cur;var child=dir==Dir.BACKWARD?cur.lastChild:cur.firstChild;while(child){var ret=AutomationUtil.findNodePre(child,dir,pred);if(ret)
return ret;child=dir==Dir.BACKWARD?child.previousSibling:child.nextSibling;}
return null;};AutomationUtil.findNodePost=function(cur,dir,pred){if(!cur)
return null;var child=dir==Dir.BACKWARD?cur.lastChild:cur.firstChild;while(child){var ret=AutomationUtil.findNodePost(child,dir,pred);if(ret)
return ret;child=dir==Dir.BACKWARD?child.previousSibling:child.nextSibling;}
if(pred(cur)&&!AutomationPredicate.shouldIgnoreNode(cur))
return cur;return null;};AutomationUtil.findNextNode=function(cur,dir,pred,opt_restrictions){var restrictions={};opt_restrictions=opt_restrictions||{leaf:undefined,root:undefined,visit:undefined,skipInitialSubtree:!AutomationPredicate.container(cur)&&pred(cur)};restrictions.root=opt_restrictions.root||AutomationPredicate.root;restrictions.leaf=opt_restrictions.leaf||function(node){return!AutomationPredicate.container(node)&&pred(node);};restrictions.skipInitialSubtree=opt_restrictions.skipInitialSubtree;restrictions.skipInitialAncestry=opt_restrictions.skipInitialAncestry;restrictions.visit=function(node){return pred(node)&&!AutomationPredicate.shouldIgnoreNode(node);};var walker=new AutomationTreeWalker(cur,dir,restrictions);return walker.next().node;};AutomationUtil.findNodeUntil=function(cur,dir,pred,opt_before){var before=cur;var after=before;do{before=after;after=AutomationUtil.findNextNode(before,dir,AutomationPredicate.leaf);}while(after&&!pred(before,after));return opt_before?before:after;};AutomationUtil.getAncestors=function(node){var ret=[];var candidate=node;while(candidate){ret.push(candidate);candidate=candidate.parent;}
return ret.reverse();};AutomationUtil.getDivergence=function(ancestorsA,ancestorsB){for(var i=0;i<ancestorsA.length;i++){if(ancestorsA[i]!==ancestorsB[i])
return i;}
if(ancestorsA.length==ancestorsB.length)
return-1;return ancestorsA.length;};AutomationUtil.getUniqueAncestors=function(prevNode,node){var prevAncestors=AutomationUtil.getAncestors(prevNode);var ancestors=AutomationUtil.getAncestors(node);var divergence=AutomationUtil.getDivergence(prevAncestors,ancestors);return ancestors.slice(divergence);};AutomationUtil.getDirection=function(nodeA,nodeB){var ancestorsA=AutomationUtil.getAncestors(nodeA);var ancestorsB=AutomationUtil.getAncestors(nodeB);var divergence=AutomationUtil.getDivergence(ancestorsA,ancestorsB);if(divergence==-1)
return Dir.FORWARD;var divA=ancestorsA[divergence];var divB=ancestorsB[divergence];if(!divA||!divB||divA.parent===nodeB||divB.parent===nodeA)
return Dir.FORWARD;return divA.indexInParent<=divB.indexInParent?Dir.FORWARD:Dir.BACKWARD;};AutomationUtil.isInSameTree=function(a,b){if(!a||!b)
return true;return a.root===b.root||(a.root.role==b.root.role&&a.root.role==RoleType.ROOT_WEB_AREA);};AutomationUtil.isInSameWebpage=function(a,b){if(!a||!b)
return false;a=a.root;while(a&&a.parent&&AutomationUtil.isInSameTree(a.parent,a))
a=a.parent.root;b=b.root;while(b&&b.parent&&AutomationUtil.isInSameTree(b.parent,b))
b=b.parent.root;return a==b;};AutomationUtil.isDescendantOf=function(node,ancestor){var testNode=node;while(testNode&&testNode!==ancestor)
testNode=testNode.parent;return testNode===ancestor;};AutomationUtil.hitTest=function(node,point){var loc=node.location;var child=node.firstChild;while(child){var hit=AutomationUtil.hitTest(child,point);if(hit)
return hit;child=child.nextSibling;}
if(point.x<=(loc.left+loc.width)&&point.x>=loc.left&&point.y<=(loc.top+loc.height)&&point.y>=loc.top)
return node;return null;};AutomationUtil.getTopLevelRoot=function(node){var root=node.root;if(!root||root.role==RoleType.DESKTOP)
return null;while(root&&root.parent&&root.parent.root&&root.parent.root.role!=RoleType.DESKTOP){root=root.parent.root;}
return root;};});goog.provide('StringUtil');StringUtil=function(){};StringUtil.longestCommonPrefixLength=function(first,second){var limit=Math.min(first.length,second.length);var i;for(i=0;i<limit;++i){if(first.charAt(i)!=second.charAt(i)){break;}}
return i;};StringUtil.MAX_BMP_CODEPOINT=65535;StringUtil.nextCodePointOffset=function(str,offset){if(offset>=str.length)
return str.length;if(str.codePointAt(offset)>StringUtil.MAX_BMP_CODEPOINT)
return offset+2;return offset+1;};StringUtil.previousCodePointOffset=function(str,offset){if(offset<=0)
return-1;if(offset>1&&str.codePointAt(offset-2)>StringUtil.MAX_BMP_CODEPOINT)
return offset-2;return offset-1;};goog.provide('cursors.Cursor');goog.provide('cursors.Movement');goog.provide('cursors.Range');goog.provide('cursors.Unit');goog.require('AutomationPredicate');goog.require('AutomationUtil');goog.require('StringUtil');goog.require('constants');cursors.NODE_INDEX=-1;cursors.Unit={CHARACTER:'character',WORD:'word',NODE:'node',DOM_NODE:'dom_node',LINE:'line'};cursors.Movement={BOUND:'bound',DIRECTIONAL:'directional'};goog.scope(function(){var AutomationNode=chrome.automation.AutomationNode;var Dir=constants.Dir;var Movement=cursors.Movement;var RoleType=chrome.automation.RoleType;var Unit=cursors.Unit;cursors.Cursor=function(node,index){this.index_=index;this.ancestry_=[];var nodeWalker=node;while(nodeWalker){this.ancestry_.push(nodeWalker);nodeWalker=nodeWalker.parent;if(nodeWalker&&AutomationPredicate.root(nodeWalker))
break;}};cursors.Cursor.fromNode=function(node){return new cursors.Cursor(node,cursors.NODE_INDEX);};cursors.Cursor.prototype={equals:function(rhs){return this.node===rhs.node&&this.index===rhs.index;},get node(){for(var i=0;i<this.ancestry_.length;i++){var firstValidNode=this.ancestry_[i];if(firstValidNode!=null&&firstValidNode.role!==undefined&&firstValidNode.root!==undefined){return firstValidNode;}
this.index_=cursors.NODE_INDEX;}
return null;},get index(){return this.index_;},get selectionIndex_(){if(this.index_==cursors.NODE_INDEX)
return cursors.NODE_INDEX;var adjustedIndex=this.index_;if(this.node.role==RoleType.INLINE_TEXT_BOX){var sibling=this.node.previousSibling;while(sibling){adjustedIndex+=sibling.name.length;sibling=sibling.previousSibling;}}
return adjustedIndex;},getText:function(opt_node){var node=opt_node||this.node;if(node.role===RoleType.TEXT_FIELD)
return node.value;return node.name||'';},move:function(unit,movement,dir){var originalNode=this.node;if(!originalNode)
return this;var newNode=originalNode;var newIndex=this.index_;if((unit!=Unit.NODE||unit!=Unit.DOM_NODE)&&newIndex===cursors.NODE_INDEX)
newIndex=0;switch(unit){case Unit.CHARACTER:var text=this.getText();newIndex=dir==Dir.FORWARD?StringUtil.nextCodePointOffset(text,newIndex):StringUtil.previousCodePointOffset(text,newIndex);if(newIndex<0||newIndex>=text.length){newNode=AutomationUtil.findNextNode(newNode,dir,AutomationPredicate.leafWithText);if(newNode){var newText=this.getText(newNode);newIndex=dir==Dir.FORWARD?0:StringUtil.previousCodePointOffset(newText,newText.length);newIndex=Math.max(newIndex,0);}else{newIndex=this.index_;}}
break;case Unit.WORD:if(newNode.role!=RoleType.INLINE_TEXT_BOX){newNode=AutomationUtil.findNextNode(newNode,Dir.FORWARD,AutomationPredicate.inlineTextBox,{skipInitialSubtree:false})||newNode;}
switch(movement){case Movement.BOUND:if(newNode.role==RoleType.INLINE_TEXT_BOX){var start,end;for(var i=0;i<newNode.wordStarts.length;i++){if(newIndex>=newNode.wordStarts[i]&&newIndex<=newNode.wordEnds[i]){start=newNode.wordStarts[i];end=newNode.wordEnds[i];break;}}
if(goog.isDef(start)&&goog.isDef(end))
newIndex=dir==Dir.FORWARD?end:start;}else{}
break;case Movement.DIRECTIONAL:if(newNode.role==RoleType.INLINE_TEXT_BOX){var start,end;for(var i=0;i<newNode.wordStarts.length;i++){if(newIndex>=newNode.wordStarts[i]&&newIndex<=newNode.wordEnds[i]){var nextIndex=dir==Dir.FORWARD?i+1:i-1;start=newNode.wordStarts[nextIndex];end=newNode.wordEnds[nextIndex];break;}}
if(goog.isDef(start)){newIndex=start;}else{if(dir==Dir.BACKWARD&&newIndex!=0){newIndex=0;}else{newNode=AutomationUtil.findNextNode(newNode,dir,AutomationPredicate.leaf);if(newNode){newIndex=0;if(dir==Dir.BACKWARD&&newNode.role==RoleType.INLINE_TEXT_BOX){var starts=newNode.wordStarts;newIndex=starts[starts.length-1]||0;}else{}}}}}else{}}
break;case Unit.NODE:case Unit.DOM_NODE:switch(movement){case Movement.BOUND:newIndex=dir==Dir.FORWARD?this.getText().length-1:0;break;case Movement.DIRECTIONAL:var pred=unit==Unit.NODE?AutomationPredicate.leaf:AutomationPredicate.object;newNode=AutomationUtil.findNextNode(newNode,dir,pred)||originalNode;newIndex=cursors.NODE_INDEX;break;}
break;case Unit.LINE:newIndex=0;switch(movement){case Movement.BOUND:newNode=AutomationUtil.findNodeUntil(newNode,dir,AutomationPredicate.linebreak,true);newNode=newNode||originalNode;newIndex=dir==Dir.FORWARD?this.getText(newNode).length:0;break;case Movement.DIRECTIONAL:newNode=AutomationUtil.findNodeUntil(newNode,dir,AutomationPredicate.linebreak);break;}
break;default:throw Error('Unrecognized unit: '+unit);}
newNode=newNode||originalNode;newIndex=goog.isDef(newIndex)?newIndex:this.index_;return new cursors.Cursor(newNode,newIndex);},isValid:function(){return this.node!=null;}};cursors.WrappingCursor=function(node,index){cursors.Cursor.call(this,node,index);};cursors.WrappingCursor.fromNode=function(node){return new cursors.WrappingCursor(node,cursors.NODE_INDEX);};cursors.WrappingCursor.prototype={__proto__:cursors.Cursor.prototype,move:function(unit,movement,dir){var result=this;if(!result.node)
return this;if(!AutomationPredicate.root(this.node)||dir==Dir.FORWARD)
result=cursors.Cursor.prototype.move.call(this,unit,movement,dir);if(movement==Movement.DIRECTIONAL&&result.equals(this)){var pred=unit==Unit.DOM_NODE?AutomationPredicate.object:AutomationPredicate.leaf;var endpoint=this.node;if(!endpoint)
return this;while(!AutomationPredicate.root(endpoint)&&endpoint.parent)
endpoint=endpoint.parent;var playEarcon=dir==Dir.FORWARD;if(dir==Dir.BACKWARD&&endpoint==this.node){playEarcon=true;endpoint=AutomationUtil.findNodePre(endpoint,dir,function(n){return pred(n)&&!AutomationPredicate.shouldIgnoreNode(n);})||endpoint;}
if(playEarcon)
cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.WRAP);return new cursors.WrappingCursor(endpoint,cursors.NODE_INDEX);}
return new cursors.WrappingCursor(result.node,result.index);}};cursors.Range=function(start,end){this.start_=start;this.end_=end;};cursors.Range.fromNode=function(node){var cursor=cursors.WrappingCursor.fromNode(node);return new cursors.Range(cursor,cursor);};cursors.Range.getDirection=function(rangeA,rangeB){if(!rangeA||!rangeB)
return Dir.FORWARD;if(!rangeA.start.node||!rangeA.end.node||!rangeB.start.node||!rangeB.end.node)
return Dir.FORWARD;if(rangeA.start.node===rangeB.start.node&&rangeB.end.node===rangeA.end.node)
return Dir.FORWARD;var testDirA=AutomationUtil.getDirection(rangeA.start.node,rangeB.end.node);var testDirB=AutomationUtil.getDirection(rangeB.start.node,rangeA.end.node);if(testDirA==Dir.FORWARD&&testDirB==Dir.BACKWARD)
return Dir.FORWARD;else if(testDirA==Dir.BACKWARD&&testDirB==Dir.FORWARD)
return Dir.BACKWARD;else
return testDirA;};cursors.Range.prototype={equals:function(rhs){return this.start_.equals(rhs.start)&&this.end_.equals(rhs.end);},getBound:function(dir,opt_reverse){if(opt_reverse)
return dir==Dir.BACKWARD?this.end_:this.start_;return dir==Dir.FORWARD?this.end_:this.start_;},get start(){return this.start_;},get end(){return this.end_;},isSubNode:function(){return this.start.node===this.end.node&&this.start.index>-1&&this.end.index>-1;},move:function(unit,dir){var newStart=this.start_;if(!newStart.node)
return this;var newEnd;switch(unit){case Unit.CHARACTER:newStart=newStart.move(unit,Movement.DIRECTIONAL,dir);newEnd=newStart.move(unit,Movement.DIRECTIONAL,Dir.FORWARD);if(newStart.node!==newEnd.node)
newEnd=new cursors.Cursor(newStart.node,newStart.index+1);break;case Unit.WORD:case Unit.LINE:newStart=newStart.move(unit,Movement.DIRECTIONAL,dir);newStart=newStart.move(unit,Movement.BOUND,Dir.BACKWARD);newEnd=newStart.move(unit,Movement.BOUND,Dir.FORWARD);break;case Unit.NODE:case Unit.DOM_NODE:newStart=newStart.move(unit,Movement.DIRECTIONAL,dir);newEnd=newStart;break;default:throw Error('Invalid unit: '+unit);}
return new cursors.Range(newStart,newEnd);},select:function(){var start=this.start.node;var end=this.end.node;if(!start||!end)
return;var uniqueAncestors=AutomationUtil.getUniqueAncestors(start,end);var mcr=start.root;if(uniqueAncestors){var common=uniqueAncestors.pop().parent;if(common)
mcr=common.root;}
if(!mcr||mcr.role==RoleType.DESKTOP)
return;if(mcr===start.root&&mcr===end.root){start=start.role==RoleType.INLINE_TEXT_BOX?start.parent:start;end=end.role==RoleType.INLINE_TEXT_BOX?end.parent:end;if(!start||!end)
return;chrome.automation.setDocumentSelection({anchorObject:start,anchorOffset:this.start.selectionIndex_,focusObject:end,focusOffset:this.end.selectionIndex_});}},isWebRange:function(){return this.isValid()&&(this.start.node.root.role!=RoleType.DESKTOP||this.end.node.root.role!=RoleType.DESKTOP);},isValid:function(){return this.start.isValid()&&this.end.isValid();}};});goog.provide('ChromeVoxMode');goog.provide('ChromeVoxState');goog.require('cursors.Cursor');ChromeVoxMode={CLASSIC:'classic',COMPAT:'compat',NEXT:'next',FORCE_NEXT:'force_next'};ChromeVoxState=function(){if(ChromeVoxState.instance)
throw'Trying to create two instances of singleton ChromeVoxState.';ChromeVoxState.instance=this;};ChromeVoxState.instance;ChromeVoxState.backgroundTts;ChromeVoxState.isReadingContinuously;ChromeVoxState.prototype={get mode(){return this.getMode();},getMode:function(){return ChromeVoxMode.NEXT;},get currentRange(){return this.getCurrentRange();},getCurrentRange:function(){return null;},setCurrentRange:goog.abstractMethod,};goog.provide('LiveRegions');goog.require('ChromeVoxState');goog.scope(function(){var AutomationNode=chrome.automation.AutomationNode;var TreeChange=chrome.automation.TreeChange;LiveRegions=function(chromeVoxState){this.chromeVoxState_=chromeVoxState;this.lastLiveRegionTime_=new Date(0);this.liveRegionNodeSet_=new WeakSet();try{chrome.automation.addTreeChangeObserver('liveRegionTreeChanges',this.onTreeChange.bind(this));}catch(e){}};LiveRegions.LIVE_REGION_QUEUE_TIME_MS=500;LiveRegions.announceLiveRegionsFromBackgroundTabs_=true;LiveRegions.prototype={onTreeChange:function(treeChange){var node=treeChange.target;if(!node.containerLiveStatus)
return;var mode=this.chromeVoxState_.mode;var currentRange=this.chromeVoxState_.currentRange;if(mode===ChromeVoxMode.CLASSIC||!cvox.ChromeVox.isActive)
return;if(!currentRange)
return;if(!LiveRegions.announceLiveRegionsFromBackgroundTabs_&&!AutomationUtil.isInSameWebpage(node,currentRange.start.node)){return;}
var type=treeChange.type;var relevant=node.containerLiveRelevant;if(relevant.indexOf('additions')>=0&&(type=='nodeCreated'||type=='subtreeCreated')){this.outputLiveRegionChange_(node,null);}
if(relevant.indexOf('text')>=0&&type=='textChanged')
this.outputLiveRegionChange_(node,null);if(relevant.indexOf('removals')>=0&&type=='nodeRemoved')
this.outputLiveRegionChange_(node,'@live_regions_removed');},outputLiveRegionChange_:function(node,opt_prependFormatStr){if(node.containerLiveBusy)
return;if(node.containerLiveAtomic&&!node.liveAtomic){if(node.parent)
this.outputLiveRegionChange_(node.parent,opt_prependFormatStr);return;}
var range=cursors.Range.fromNode(node);var output=new Output();if(opt_prependFormatStr)
output.format(opt_prependFormatStr);output.withSpeech(range,range,Output.EventType.NAVIGATE);if(!output.hasSpeech&&node.liveAtomic)
output.format('$joinedDescendants',node);output.withSpeechCategory(cvox.TtsCategory.LIVE);if(!output.hasSpeech)
return;var currentTime=new Date();var queueTime=LiveRegions.LIVE_REGION_QUEUE_TIME_MS;if(currentTime-this.lastLiveRegionTime_>queueTime){this.liveRegionNodeSet_=new WeakSet();output.withQueueMode(cvox.QueueMode.CATEGORY_FLUSH);this.lastLiveRegionTime_=currentTime;}else{output.withQueueMode(cvox.QueueMode.QUEUE);}
var parent=node;while(parent){if(this.liveRegionNodeSet_.has(parent))
return;parent=parent.parent;}
this.liveRegionNodeSet_.add(node);output.go();},};});goog.provide('EarconEngine');EarconEngine=function(){this.masterVolume=1.0;this.masterPitch=-4;this.clickVolume=0.4;this.staticVolume=0.2;this.baseDelay=0.045;this.masterPan=0;this.masterReverb=0.4;this.reverbSound='small_room_2';this.wrapPitch=0;this.alertPitch=0;this.controlSound='control';this.sweepDelay=0.045;this.sweepEchoDelay=0.15;this.sweepEchoCount=3;this.sweepPitch=-7;this.progressFinalGain=0.05;this.progressGain_Decay=0.7;this.context_=new AudioContext();this.reverbConvolver_=null;this.buffers_={};this.progressSources_=[];this.progressGain_=1.0;this.progressTime_=this.context_.currentTime;this.progressIntervalID_=null;var allSoundFilesToLoad=EarconEngine.SOUNDS.concat(EarconEngine.REVERBS);allSoundFilesToLoad.forEach((function(sound){var url=EarconEngine.BASE_URL+sound+'.wav';this.loadSound(sound,url);}).bind(this));};EarconEngine.SOUNDS=['control','selection','selection_reverse','skim','static'];EarconEngine.REVERBS=['small_room_2'];EarconEngine.HALF_STEP=Math.pow(2.0,1.0/12.0);EarconEngine.BASE_URL=chrome.extension.getURL('cvox2/background/earcons/');EarconEngine.prototype.loadSound=function(name,url){var request=new XMLHttpRequest();request.open('GET',url,true);request.responseType='arraybuffer';request.onload=(function(){this.context_.decodeAudioData((request.response),(function(buffer){this.buffers_[name]=buffer;}).bind(this));}).bind(this);request.send();};EarconEngine.prototype.createCommonFilters=function(properties){var gain=this.masterVolume;if(properties.gain){gain*=properties.gain;}
var gainNode=this.context_.createGain();gainNode.gain.value=gain;var first=gainNode;var last=gainNode;var pan=this.masterPan;if(properties.pan!==undefined){pan=properties.pan;}
if(pan!=0){var panNode=this.context_.createPanner();panNode.setPosition(pan,0,-1);panNode.setOrientation(0,0,1);last.connect(panNode);last=panNode;}
var reverb=this.masterReverb;if(properties.reverb!==undefined){reverb=properties.reverb;}
if(reverb){if(!this.reverbConvolver_){this.reverbConvolver_=this.context_.createConvolver();this.reverbConvolver_.buffer=this.buffers_[this.reverbSound];this.reverbConvolver_.connect(this.context_.destination);}
last.connect(this.context_.destination);var reverbGainNode=this.context_.createGain();reverbGainNode.gain.value=reverb;last.connect(reverbGainNode);reverbGainNode.connect(this.reverbConvolver_);}else{last.connect(this.context_.destination);}
return first;};EarconEngine.prototype.play=function(sound,opt_properties){var source=this.context_.createBufferSource();source.buffer=this.buffers_[sound];if(!opt_properties){opt_properties=({});}
var pitch=this.masterPitch;if(opt_properties.pitch){pitch+=opt_properties.pitch;}
if(pitch!=0){source.playbackRate.value=Math.pow(EarconEngine.HALF_STEP,pitch);}
var destination=this.createCommonFilters(opt_properties);source.connect(destination);if(opt_properties.time){source.start(this.context_.currentTime+opt_properties.time);}else{source.start(this.context_.currentTime);}
return source;};EarconEngine.prototype.onStatic=function(){this.play('static',{gain:this.staticVolume});};EarconEngine.prototype.onLink=function(){this.play('static',{gain:this.clickVolume});this.play(this.controlSound,{pitch:12});};EarconEngine.prototype.onButton=function(){this.play('static',{gain:this.clickVolume});this.play(this.controlSound);};EarconEngine.prototype.onTextField=function(){this.play('static',{gain:this.clickVolume});this.play('static',{time:this.baseDelay*1.5,gain:this.clickVolume*0.5});this.play(this.controlSound,{pitch:4});this.play(this.controlSound,{pitch:4,time:this.baseDelay*1.5,gain:0.5});};EarconEngine.prototype.onPopUpButton=function(){this.play('static',{gain:this.clickVolume});this.play(this.controlSound);this.play(this.controlSound,{time:this.baseDelay*3,gain:0.2,pitch:12});this.play(this.controlSound,{time:this.baseDelay*4.5,gain:0.2,pitch:12});};EarconEngine.prototype.onCheckOn=function(){this.play('static',{gain:this.clickVolume});this.play(this.controlSound,{pitch:-5});this.play(this.controlSound,{pitch:7,time:this.baseDelay*2});};EarconEngine.prototype.onCheckOff=function(){this.play('static',{gain:this.clickVolume});this.play(this.controlSound,{pitch:7});this.play(this.controlSound,{pitch:-5,time:this.baseDelay*2});};EarconEngine.prototype.onSelect=function(){this.play('static',{gain:this.clickVolume});this.play(this.controlSound);this.play(this.controlSound,{time:this.baseDelay});this.play(this.controlSound,{time:this.baseDelay*2});};EarconEngine.prototype.onSlider=function(){this.play('static',{gain:this.clickVolume});this.play(this.controlSound);this.play(this.controlSound,{time:this.baseDelay,gain:0.5,pitch:2});this.play(this.controlSound,{time:this.baseDelay*2,gain:0.25,pitch:4});this.play(this.controlSound,{time:this.baseDelay*3,gain:0.125,pitch:6});this.play(this.controlSound,{time:this.baseDelay*4,gain:0.0625,pitch:8});};EarconEngine.prototype.onSkim=function(){this.play('skim');};EarconEngine.prototype.onSelection=function(){this.play('selection');};EarconEngine.prototype.onSelectionReverse=function(){this.play('selection_reverse');};EarconEngine.prototype.generateSinusoidal=function(properties){var envelopeNode=this.context_.createGain();envelopeNode.connect(this.context_.destination);var time=properties.time;if(time===undefined){time=0;}
var gain=properties.gain;for(var i=0;i<properties.overtones;i++){var osc=this.context_.createOscillator();osc.frequency.value=properties.freq*(i+1);if(properties.endFreq){osc.frequency.setValueAtTime(properties.freq*(i+1),this.context_.currentTime+time);osc.frequency.exponentialRampToValueAtTime(properties.endFreq*(i+1),this.context_.currentTime+properties.dur);}
osc.start(this.context_.currentTime+time);osc.stop(this.context_.currentTime+time+properties.dur);var gainNode=this.context_.createGain();gainNode.gain.value=gain;osc.connect(gainNode);gainNode.connect(envelopeNode);gain*=properties.overtoneFactor;}
envelopeNode.gain.setValueAtTime(0,this.context_.currentTime+time);envelopeNode.gain.linearRampToValueAtTime(1,this.context_.currentTime+time+properties.attack);envelopeNode.gain.setValueAtTime(1,this.context_.currentTime+time+properties.dur-properties.decay);envelopeNode.gain.linearRampToValueAtTime(0,this.context_.currentTime+time+properties.dur);var destination=this.createCommonFilters({});envelopeNode.connect(destination);};EarconEngine.prototype.onChromeVoxSweep=function(reverse){var pitches=[-7,-5,0,5,7,12,17,19,24];if(reverse){pitches.reverse();}
var attack=0.015;var dur=pitches.length*this.sweepDelay;var destination=this.createCommonFilters({reverb:2.0});for(var k=0;k<this.sweepEchoCount;k++){var envelopeNode=this.context_.createGain();var startTime=this.context_.currentTime+this.sweepEchoDelay*k;var sweepGain=Math.pow(0.3,k);var overtones=2;var overtoneGain=sweepGain;for(var i=0;i<overtones;i++){var osc=this.context_.createOscillator();osc.start(startTime);osc.stop(startTime+dur);var gainNode=this.context_.createGain();osc.connect(gainNode);gainNode.connect(envelopeNode);for(var j=0;j<pitches.length;j++){var freqDecay;if(reverse){freqDecay=Math.pow(0.75,pitches.length-j);}else{freqDecay=Math.pow(0.75,j);}
var gain=overtoneGain*freqDecay;var freq=(i+1)*220*Math.pow(EarconEngine.HALF_STEP,pitches[j]+this.sweepPitch);if(j==0){osc.frequency.setValueAtTime(freq,startTime);gainNode.gain.setValueAtTime(gain,startTime);}else{osc.frequency.exponentialRampToValueAtTime(freq,startTime+j*this.sweepDelay);gainNode.gain.linearRampToValueAtTime(gain,startTime+j*this.sweepDelay);}
osc.frequency.setValueAtTime(freq,startTime+j*this.sweepDelay+this.sweepDelay-attack);}
overtoneGain*=0.1+0.2*k;}
envelopeNode.gain.setValueAtTime(0,startTime);envelopeNode.gain.linearRampToValueAtTime(1,startTime+this.sweepDelay);envelopeNode.gain.setValueAtTime(1,startTime+dur-attack*2);envelopeNode.gain.linearRampToValueAtTime(0,startTime+dur);envelopeNode.connect(destination);}};EarconEngine.prototype.onChromeVoxOn=function(){this.onChromeVoxSweep(false);};EarconEngine.prototype.onChromeVoxOff=function(){this.onChromeVoxSweep(true);};EarconEngine.prototype.onAlert=function(){var freq1=220*Math.pow(EarconEngine.HALF_STEP,this.alertPitch-2);var freq2=220*Math.pow(EarconEngine.HALF_STEP,this.alertPitch-3);this.generateSinusoidal({attack:0.02,decay:0.07,dur:0.15,gain:0.3,freq:freq1,overtones:3,overtoneFactor:0.1});this.generateSinusoidal({attack:0.02,decay:0.07,dur:0.15,gain:0.3,freq:freq2,overtones:3,overtoneFactor:0.1});};EarconEngine.prototype.onWrap=function(){this.play('static',{gain:this.clickVolume*0.3});var freq1=220*Math.pow(EarconEngine.HALF_STEP,this.wrapPitch-8);var freq2=220*Math.pow(EarconEngine.HALF_STEP,this.wrapPitch+8);this.generateSinusoidal({attack:0.01,decay:0.1,dur:0.15,gain:0.3,freq:freq1,endFreq:freq2,overtones:1,overtoneFactor:0.1});};EarconEngine.prototype.generateProgressTickTocks_=function(){while(this.progressTime_<this.context_.currentTime+3.0){var t=this.progressTime_-this.context_.currentTime;this.progressSources_.push([this.progressTime_,this.play('static',{gain:0.5*this.progressGain_,time:t})]);this.progressSources_.push([this.progressTime_,this.play(this.controlSound,{pitch:20,time:t,gain:this.progressGain_})]);if(this.progressGain_>this.progressFinalGain){this.progressGain_*=this.progressGain_Decay;}
t+=0.5;this.progressSources_.push([this.progressTime_,this.play('static',{gain:0.5*this.progressGain_,time:t})]);this.progressSources_.push([this.progressTime_,this.play(this.controlSound,{pitch:8,time:t,gain:this.progressGain_})]);if(this.progressGain_>this.progressFinalGain){this.progressGain_*=this.progressGain_Decay;}
this.progressTime_+=1.0;}
var removeCount=0;while(removeCount<this.progressSources_.length&&this.progressSources_[removeCount][0]<this.context_.currentTime-0.2){removeCount++;}
this.progressSources_.splice(0,removeCount);};EarconEngine.prototype.startProgress=function(){if(this.progressIntervalID_){this.cancelProgress();}
this.progressSources_=[];this.progressGain_=0.5;this.progressTime_=this.context_.currentTime;this.generateProgressTickTocks_();this.progressIntervalID_=window.setInterval(this.generateProgressTickTocks_.bind(this),1000);};EarconEngine.prototype.cancelProgress=function(){if(!this.progressIntervalID_){return;}
for(var i=0;i<this.progressSources_.length;i++){this.progressSources_[i][1].stop();}
this.progressSources_=[];window.clearInterval(this.progressIntervalID_);this.progressIntervalID_=null;};goog.provide('cvox.AbstractEarcons');goog.provide('cvox.Earcon');cvox.Earcon={ALERT_MODAL:'alert_modal',ALERT_NONMODAL:'alert_nonmodal',BUTTON:'button',CHECK_OFF:'check_off',CHECK_ON:'check_on',EDITABLE_TEXT:'editable_text',INVALID_KEYPRESS:'invalid_keypress',LINK:'link',LISTBOX:'listbox',LIST_ITEM:'list_item',LONG_DESC:'long_desc',MATH:'math',OBJECT_CLOSE:'object_close',OBJECT_ENTER:'object_enter',OBJECT_EXIT:'object_exit',OBJECT_OPEN:'object_open',OBJECT_SELECT:'object_select',PAGE_FINISH_LOADING:'page_finish_loading',PAGE_START_LOADING:'page_start_loading',POP_UP_BUTTON:'pop_up_button',RECOVER_FOCUS:'recover_focus',SELECTION:'selection',SELECTION_REVERSE:'selection_reverse',SKIP:'skip',SLIDER:'slider',WRAP:'wrap',WRAP_EDGE:'wrap_edge',};cvox.AbstractEarcons=function(){};cvox.AbstractEarcons.enabled=true;cvox.AbstractEarcons.prototype.playEarcon=function(earcon){};cvox.AbstractEarcons.prototype.cancelEarcon=function(earcon){};cvox.AbstractEarcons.prototype.earconsAvailable=function(){return true;};cvox.AbstractEarcons.prototype.toggle=function(){cvox.AbstractEarcons.enabled=!cvox.AbstractEarcons.enabled;return cvox.AbstractEarcons.enabled;};goog.provide('NextEarcons');goog.require('EarconEngine');goog.require('cvox.AbstractEarcons');NextEarcons=function(){cvox.AbstractEarcons.call(this);if(localStorage['earcons']==='false'){cvox.AbstractEarcons.enabled=false;}
this.engine_=new EarconEngine();};NextEarcons.prototype={getName:function(){return'ChromeVox Next earcons';},playEarcon:function(earcon){if(!cvox.AbstractEarcons.enabled){return;}
console.log('Earcon '+earcon);switch(earcon){case cvox.Earcon.ALERT_MODAL:case cvox.Earcon.ALERT_NONMODAL:this.engine_.onAlert();break;case cvox.Earcon.BUTTON:this.engine_.onButton();break;case cvox.Earcon.CHECK_OFF:this.engine_.onCheckOff();break;case cvox.Earcon.CHECK_ON:this.engine_.onCheckOn();break;case cvox.Earcon.EDITABLE_TEXT:this.engine_.onTextField();break;case cvox.Earcon.INVALID_KEYPRESS:this.engine_.onWrap();break;case cvox.Earcon.LINK:this.engine_.onLink();break;case cvox.Earcon.LISTBOX:this.engine_.onSelect();break;case cvox.Earcon.LIST_ITEM:case cvox.Earcon.LONG_DESC:case cvox.Earcon.MATH:case cvox.Earcon.OBJECT_CLOSE:case cvox.Earcon.OBJECT_ENTER:case cvox.Earcon.OBJECT_EXIT:case cvox.Earcon.OBJECT_OPEN:case cvox.Earcon.OBJECT_SELECT:break;case cvox.Earcon.PAGE_FINISH_LOADING:this.engine_.cancelProgress();break;case cvox.Earcon.PAGE_START_LOADING:this.engine_.startProgress();break;case cvox.Earcon.POP_UP_BUTTON:this.engine_.onPopUpButton();break;case cvox.Earcon.RECOVER_FOCUS:break;case cvox.Earcon.SELECTION:this.engine_.onSelection();break;case cvox.Earcon.SELECTION_REVERSE:this.engine_.onSelectionReverse();break;case cvox.Earcon.SKIP:this.engine_.onSkim();break;case cvox.Earcon.SLIDER:this.engine_.onSlider();break;case cvox.Earcon.WRAP:case cvox.Earcon.WRAP_EDGE:this.engine_.onWrap();break;}},cancelEarcon:function(earcon){switch(earcon){case cvox.Earcon.PAGE_START_LOADING:this.engine_.cancelProgress();break;}},};goog.provide('Notifications');function UpdateNotification(){this.data={};this.data.type='basic';this.data.iconUrl='/images/chromevox-16.png';this.data.title=Msgs.getMsg('update_title');this.data.message=Msgs.getMsg('update_message_next');}
UpdateNotification.prototype={shouldShow:function(){return!localStorage['notifications_update_notification_shown']&&chrome.runtime.getManifest().version>='53';},show:function(){if(!this.shouldShow())
return;chrome.notifications.create('update',this.data);chrome.notifications.onClicked.addListener(this.onClicked.bind(this));chrome.notifications.onClosed.addListener(this.onClosed.bind(this));},onClicked:function(notificationId){var nextUpdatePage={url:'cvox2/background/next_update.html'};chrome.tabs.create(nextUpdatePage);},onClosed:function(id){localStorage['notifications_update_notification_shown']=true;}};Notifications.onStartup=function(){if(document.location.href.indexOf('background.html')==-1)
return;new UpdateNotification().show();};Notifications.onModeChange=function(){if(document.location.href.indexOf('background.html')==-1)
return;if(ChromeVoxState.instance.mode!==ChromeVoxMode.FORCE_NEXT)
return;new UpdateNotification().show();};goog.provide('Spannable');goog.scope(function(){Spannable=function(opt_string,opt_annotation){this.string_=opt_string instanceof Spannable?'':opt_string||'';this.spans_=[];if(opt_string instanceof Spannable)
this.append(opt_string);if(goog.isDef(opt_annotation)){var len=this.string_.length;this.spans_.push({value:opt_annotation,start:0,end:len});}};Spannable.prototype={toString:function(){return this.string_;},get length(){return this.string_.length;},setSpan:function(value,start,end){this.removeSpan(value);if(0<=start&&start<=end&&end<=this.string_.length){this.spans_.push({value:value,start:start,end:end});this.spans_.sort(function(a,b){var ret=a.start-b.start;if(ret==0)
ret=a.end-b.end;return ret;});}else{throw new RangeError('span out of range (start='+start+', end='+end+', len='+this.string_.length+')');}},removeSpan:function(value){for(var i=this.spans_.length-1;i>=0;i--){if(this.spans_[i].value===value){this.spans_.splice(i,1);}}},append:function(other){if(other instanceof Spannable){var otherSpannable=(other);var originalLength=this.length;this.string_+=otherSpannable.string_;other.spans_.forEach(function(span){this.setSpan(span.value,span.start+originalLength,span.end+originalLength);}.bind(this));}else if(typeof other==='string'){this.string_+=(other);}},getSpan:function(position){return valueOfSpan(this.spans_.find(spanCoversPosition(position)));},getSpanInstanceOf:function(constructor){return valueOfSpan(this.spans_.find(spanInstanceOf(constructor)));},getSpansInstanceOf:function(constructor){return(this.spans_.filter(spanInstanceOf(constructor)).map(valueOfSpan));},getSpans:function(position){return(this.spans_.filter(spanCoversPosition(position)).map(valueOfSpan));},hasSpan:function(value){return this.spans_.some(spanValueIs(value));},getSpanStart:function(value){return this.getSpanByValueOrThrow_(value).start;},getSpanEnd:function(value){return this.getSpanByValueOrThrow_(value).end;},getSpanLength:function(value){var span=this.getSpanByValueOrThrow_(value);return span.end-span.start;},getSpanByValueOrThrow_:function(value){var span=this.spans_.find(spanValueIs(value));if(span)
return span;throw new Error('Span '+value+' doesn\'t exist in spannable');},substring:function(start,opt_end){var end=goog.isDef(opt_end)?opt_end:this.string_.length;if(start<0||end>this.string_.length||start>end){throw new RangeError('substring indices out of range');}
var result=new Spannable(this.string_.substring(start,end));this.spans_.forEach(function(span){if(span.start<=end&&span.end>=start){var newStart=Math.max(0,span.start-start);var newEnd=Math.min(end-start,span.end-start);result.spans_.push({value:span.value,start:newStart,end:newEnd});}});return result;},trimLeft:function(){return this.trim_(true,false);},trimRight:function(){return this.trim_(false,true);},trim:function(){return this.trim_(true,true);},trim_:function(trimStart,trimEnd){if(!trimStart&&!trimEnd){return this;}
if(/^\s*$/.test(this.string_)){return this.substring(0,0);}
var trimmedStart=trimStart?this.string_.match(/^\s*/)[0].length:0;var trimmedEnd=trimEnd?this.string_.match(/\s*$/).index:this.string_.length;return this.substring(trimmedStart,trimmedEnd);},toJson:function(){var result={};result.string=this.string_;result.spans=[];this.spans_.forEach(function(span){var serializeInfo=serializableSpansByConstructor.get(span.value.constructor);if(serializeInfo){var spanObj={type:serializeInfo.name,start:span.start,end:span.end};if(serializeInfo.toJson){spanObj.value=serializeInfo.toJson.apply(span.value);}
result.spans.push(spanObj);}});return result;}};Spannable.fromJson=function(obj){if(typeof obj.string!=='string'){throw new Error('Invalid spannable json object: string field not a string');}
if(!(obj.spans instanceof Array)){throw new Error('Invalid spannable json object: no spans array');}
var result=new Spannable(obj.string);result.spans_=obj.spans.map(function(span){if(typeof span.type!=='string'){throw new Error('Invalid span in spannable json object: type not a string');}
if(typeof span.start!=='number'||typeof span.end!=='number'){throw new Error('Invalid span in spannable json object: start or end not a number');}
var serializeInfo=serializableSpansByName.get(span.type);var value=serializeInfo.fromJson(span.value);return{value:value,start:span.start,end:span.end};});return result;};Spannable.registerSerializableSpan=function(constructor,name,fromJson,toJson){var obj={name:name,fromJson:fromJson,toJson:toJson};serializableSpansByName.set(name,obj);serializableSpansByConstructor.set(constructor,obj);};Spannable.registerStatelessSerializableSpan=function(constructor,name){var obj={name:name,toJson:undefined};obj.fromJson=function(obj){return new constructor();};serializableSpansByName.set(name,obj);serializableSpansByConstructor.set(constructor,obj);};var SpanStruct;var SerializeInfo;var SerializedSpannable;var SerializedSpan;var serializableSpansByName=new Map();var serializableSpansByConstructor=new Map();function spanInstanceOf(constructor){return function(span){return span.value instanceof constructor;}}
function spanCoversPosition(position){return function(span){return span.start<=position&&position<span.end;}}
function spanValueIs(value){return function(span){return span.value===value;}}
function valueOfSpan(span){return span?span.value:undefined;}});goog.provide('cvox.ChromeVox');goog.addDependency('../host/interface/abstract_host.js',['cvox.AbstractHost'],[]);goog.addDependency('../host/interface/tts_interface.js',['cvox.TtsInterface'],[]);goog.addDependency('../host/interface/braille_interface.js',['cvox.BrailleInterface'],[]);goog.addDependency('../host/interface/mathjax_interface.js',['cvox.MathJaxInterface'],[]);goog.addDependency('../chromevox/messages/msgs.js',['Msgs'],[]);goog.addDependency('../host/interface/abstract_earcons.js',['cvox.AbstractEarcons'],[]);goog.addDependency('../chromevox/common/key_sequence.js',['cvox.KeySequence'],[]);goog.addDependency('../chromevox/injected/navigation_manager.js',['cvox.NavigationManager'],[]);goog.addDependency('../chromevox/injected/serializer.js',['cvox.Serializer'],[]);cvox.VERBOSITY_VERBOSE=0;cvox.VERBOSITY_BRIEF=1;cvox.ChromeVox=function(){};cvox.ChromeVox.host=null;cvox.ChromeVox.tts;cvox.ChromeVox.braille;cvox.ChromeVox.mathJax;cvox.ChromeVox.isActive=true;cvox.ChromeVox.version=null;cvox.ChromeVox.earcons=null;cvox.ChromeVox.navigationManager=null;cvox.ChromeVox.serializer=null;cvox.ChromeVox.isStickyPrefOn=false;cvox.ChromeVox.stickyOverride=null;cvox.ChromeVox.keyPrefixOn=false;cvox.ChromeVox.verbosity=cvox.VERBOSITY_VERBOSE;cvox.ChromeVox.typingEcho=0;cvox.ChromeVox.keyEcho={};cvox.Point;cvox.ChromeVox.position={};cvox.ChromeVox.isChromeOS=navigator.userAgent.indexOf('CrOS')!=-1;cvox.ChromeVox.isMac=navigator.platform.indexOf('Mac')!=-1;cvox.ChromeVox.modKeyStr;if(cvox.ChromeVox.isChromeOS){cvox.ChromeVox.modKeyStr='Shift+Search';}else if(cvox.ChromeVox.isMac){cvox.ChromeVox.modKeyStr='Ctrl+Cmd';}else{cvox.ChromeVox.modKeyStr='Shift+Alt';}
cvox.ChromeVox.sequenceSwitchKeyCodes=[];cvox.ChromeVox.visitedUrls={};cvox.ChromeVox.markInUserCommand=function(){};cvox.ChromeVox.syncToNode=function(targetNode,speakNode,opt_queueMode){};cvox.ChromeVox.speakNode=function(targetNode,queueMode,properties){};cvox.ChromeVox.executeUserCommand=function(commandName){};cvox.ChromeVox.entireDocumentIsHidden=false;cvox.ChromeVox.storeOn=function(store){store['isStickyPrefOn']=cvox.ChromeVox.isStickyPrefOn;cvox.ChromeVox.navigationManager.storeOn(store);};cvox.ChromeVox.readFrom=function(store){cvox.ChromeVox.isStickyPrefOn=store['isStickyPrefOn'];cvox.ChromeVox.navigationManager.readFrom(store);};cvox.ChromeVox.isStickyModeOn=function(){if(cvox.ChromeVox.stickyOverride!==null){return cvox.ChromeVox.stickyOverride;}else{return cvox.ChromeVox.isStickyPrefOn;}};function $(id){return document.getElementById(id);}
cvox.ChromeVox.injectChromeVoxIntoTabs=function(tabs){};cvox.ChromeVox.documentHasFocus=function(){if(!document.hasFocus()||document.hidden){return false;}
if(document.activeElement.tagName=='IFRAME'||document.activeElement.tagName=='WEBVIEW'){return false;}
return true;};goog.provide('cvox.NavBraille');goog.require('Spannable');cvox.NavBraille=function(kwargs){this.text=(kwargs.text instanceof Spannable)?kwargs.text:new Spannable(kwargs.text);this.startIndex=goog.isDef(kwargs.startIndex)?kwargs.startIndex:-1;this.endIndex=goog.isDef(kwargs.endIndex)?kwargs.endIndex:this.startIndex;};cvox.NavBraille.fromText=function(text){return new cvox.NavBraille({'text':text});};cvox.NavBraille.fromJson=function(json){if(typeof json.startIndex!=='number'||typeof json.endIndex!=='number'){throw'Invalid start or end index in serialized NavBraille: '+json;}
return new cvox.NavBraille({text:Spannable.fromJson(json.spannable),startIndex:json.startIndex,endIndex:json.endIndex});};cvox.NavBraille.prototype.isEmpty=function(){return this.text.length==0;};cvox.NavBraille.prototype.toString=function(){return'NavBraille(text="'+this.text.toString()+'" '+' startIndex="'+this.startIndex+'" '+' endIndex="'+this.endIndex+'")';};cvox.NavBraille.prototype.toJson=function(){return{spannable:this.text.toJson(),startIndex:this.startIndex,endIndex:this.endIndex};};goog.provide('cvox.QueueMode');goog.provide('cvox.TtsCapturingEventListener');goog.provide('cvox.TtsCategory');goog.provide('cvox.TtsInterface');cvox.TtsCategory={LIVE:'live',NAV:'nav'};cvox.QueueMode={FLUSH:0,QUEUE:1,CATEGORY_FLUSH:2};cvox.TtsCapturingEventListener=function(){};cvox.TtsCapturingEventListener.prototype.onTtsStart=function(){};cvox.TtsCapturingEventListener.prototype.onTtsEnd=function(){};cvox.TtsInterface=function(){};cvox.TtsInterface.prototype.speak=function(textString,queueMode,properties){};cvox.TtsInterface.prototype.isSpeaking=function(){};cvox.TtsInterface.prototype.stop=function(){};cvox.TtsInterface.prototype.addCapturingEventListener=function(listener){};cvox.TtsInterface.prototype.increaseOrDecreaseProperty=function(propertyName,increase){};cvox.TtsInterface.prototype.propertyToPercentage=function(property){};cvox.TtsInterface.prototype.getDefaultProperty=function(property){};goog.provide('cvox.ExtraCellsSpan');goog.provide('cvox.ValueSelectionSpan');goog.provide('cvox.ValueSpan');goog.require('Spannable');cvox.ValueSpan=function(offset){this.offset=offset;};cvox.ValueSpan.fromJson=function(obj){return new cvox.ValueSpan(obj.offset);};cvox.ValueSpan.prototype.toJson=function(){return this;};Spannable.registerSerializableSpan(cvox.ValueSpan,'cvox.ValueSpan',cvox.ValueSpan.fromJson,cvox.ValueSpan.prototype.toJson);cvox.ValueSelectionSpan=function(){};Spannable.registerStatelessSerializableSpan(cvox.ValueSelectionSpan,'cvox.ValueSelectionSpan');cvox.ExtraCellsSpan=function(){this.cells=new Uint8Array(0).buffer;};goog.provide('goog.debug.Error');goog.debug.Error=function(opt_msg){if(Error.captureStackTrace){Error.captureStackTrace(this,goog.debug.Error);}else{var stack=new Error().stack;if(stack){this.stack=stack;}}
if(opt_msg){this.message=String(opt_msg);}};goog.inherits(goog.debug.Error,Error);goog.debug.Error.prototype.name='CustomError';goog.provide('goog.dom.NodeType');goog.dom.NodeType={ELEMENT:1,ATTRIBUTE:2,TEXT:3,CDATA_SECTION:4,ENTITY_REFERENCE:5,ENTITY:6,PROCESSING_INSTRUCTION:7,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,NOTATION:12};goog.provide('goog.string');goog.string.subs=function(str,var_args){var splitParts=str.split('%s');var returnString='';var subsArguments=Array.prototype.slice.call(arguments,1);while(subsArguments.length&&splitParts.length>1){returnString+=splitParts.shift()+subsArguments.shift();}
return returnString+splitParts.join('%s');};goog.provide('goog.asserts');goog.provide('goog.asserts.AssertionError');goog.require('goog.debug.Error');goog.require('goog.dom.NodeType');goog.require('goog.string');goog.asserts.ENABLE_ASSERTS=goog.define('goog.asserts.ENABLE_ASSERTS',goog.DEBUG);goog.asserts.AssertionError=function(messagePattern,messageArgs){messageArgs.unshift(messagePattern);goog.debug.Error.call(this,goog.string.subs.apply(null,messageArgs));messageArgs.shift();this.messagePattern=messagePattern;};goog.inherits(goog.asserts.AssertionError,goog.debug.Error);goog.asserts.AssertionError.prototype.name='AssertionError';goog.asserts.doAssertFailure_=function(defaultMessage,defaultArgs,givenMessage,givenArgs){var message='Assertion failed';if(givenMessage){message+=': '+givenMessage;var args=givenArgs;}else if(defaultMessage){message+=': '+defaultMessage;args=defaultArgs;}
throw new goog.asserts.AssertionError(''+message,args||[]);};goog.asserts.assert=function(condition,opt_message,var_args){if(goog.asserts.ENABLE_ASSERTS&&!condition){goog.asserts.doAssertFailure_('',null,opt_message,Array.prototype.slice.call(arguments,2));}
return condition;};goog.asserts.fail=function(opt_message,var_args){if(goog.asserts.ENABLE_ASSERTS){throw new goog.asserts.AssertionError('Failure'+(opt_message?': '+opt_message:''),Array.prototype.slice.call(arguments,1));}};goog.asserts.assertNumber=function(value,opt_message,var_args){if(goog.asserts.ENABLE_ASSERTS&&!goog.isNumber(value)){goog.asserts.doAssertFailure_('Expected number but got %s: %s.',[goog.typeOf(value),value],opt_message,Array.prototype.slice.call(arguments,2));}
return(value);};goog.asserts.assertString=function(value,opt_message,var_args){if(goog.asserts.ENABLE_ASSERTS&&!goog.isString(value)){goog.asserts.doAssertFailure_('Expected string but got %s: %s.',[goog.typeOf(value),value],opt_message,Array.prototype.slice.call(arguments,2));}
return(value);};goog.asserts.assertFunction=function(value,opt_message,var_args){if(goog.asserts.ENABLE_ASSERTS&&!goog.isFunction(value)){goog.asserts.doAssertFailure_('Expected function but got %s: %s.',[goog.typeOf(value),value],opt_message,Array.prototype.slice.call(arguments,2));}
return(value);};goog.asserts.assertObject=function(value,opt_message,var_args){if(goog.asserts.ENABLE_ASSERTS&&!goog.isObject(value)){goog.asserts.doAssertFailure_('Expected object but got %s: %s.',[goog.typeOf(value),value],opt_message,Array.prototype.slice.call(arguments,2));}
return(value);};goog.asserts.assertArray=function(value,opt_message,var_args){if(goog.asserts.ENABLE_ASSERTS&&!goog.isArray(value)){goog.asserts.doAssertFailure_('Expected array but got %s: %s.',[goog.typeOf(value),value],opt_message,Array.prototype.slice.call(arguments,2));}
return(value);};goog.asserts.assertBoolean=function(value,opt_message,var_args){if(goog.asserts.ENABLE_ASSERTS&&!goog.isBoolean(value)){goog.asserts.doAssertFailure_('Expected boolean but got %s: %s.',[goog.typeOf(value),value],opt_message,Array.prototype.slice.call(arguments,2));}
return(value);};goog.asserts.assertElement=function(value,opt_message,var_args){if(goog.asserts.ENABLE_ASSERTS&&(!goog.isObject(value)||value.nodeType!=goog.dom.NodeType.ELEMENT)){goog.asserts.doAssertFailure_('Expected Element but got %s: %s.',[goog.typeOf(value),value],opt_message,Array.prototype.slice.call(arguments,2));}
return(value);};goog.asserts.assertInstanceof=function(value,type,opt_message,var_args){if(goog.asserts.ENABLE_ASSERTS&&!(value instanceof type)){goog.asserts.doAssertFailure_('instanceof check failed.',null,opt_message,Array.prototype.slice.call(arguments,3));}
return value;};goog.asserts.assertObjectPrototypeIsIntact=function(){for(var key in Object.prototype){goog.asserts.fail(key+' should not be enumerable in Object.prototype.');}};goog.provide('goog.i18n.ordinalRules');goog.i18n.ordinalRules.Keyword={ZERO:'zero',ONE:'one',TWO:'two',FEW:'few',MANY:'many',OTHER:'other'};goog.i18n.ordinalRules.defaultSelect_=function(n,opt_precision){return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.decimals_=function(n){var str=n+'';var result=str.indexOf('.');return(result==-1)?0:str.length-result-1;};goog.i18n.ordinalRules.get_vf_=function(n,opt_precision){var DEFAULT_DIGITS=3;if(undefined===opt_precision){var v=Math.min(goog.i18n.ordinalRules.decimals_(n),DEFAULT_DIGITS);}else{var v=opt_precision;}
var base=Math.pow(10,v);var f=((n*base)|0)%base;return{v:v,f:f};};goog.i18n.ordinalRules.get_wt_=function(v,f){if(f===0){return{w:0,t:0};}
while((f%10)===0){f/=10;v--;}
return{w:v,t:f};};goog.i18n.ordinalRules.enSelect_=function(n,opt_precision){if(n%10==1&&n%100!=11){return goog.i18n.ordinalRules.Keyword.ONE;}
if(n%10==2&&n%100!=12){return goog.i18n.ordinalRules.Keyword.TWO;}
if(n%10==3&&n%100!=13){return goog.i18n.ordinalRules.Keyword.FEW;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.svSelect_=function(n,opt_precision){if((n%10==1||n%10==2)&&n%100!=11&&n%100!=12){return goog.i18n.ordinalRules.Keyword.ONE;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.huSelect_=function(n,opt_precision){if(n==1||n==5){return goog.i18n.ordinalRules.Keyword.ONE;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.kkSelect_=function(n,opt_precision){if(n%10==6||n%10==9||n%10==0&&n!=0){return goog.i18n.ordinalRules.Keyword.MANY;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.mrSelect_=function(n,opt_precision){if(n==1){return goog.i18n.ordinalRules.Keyword.ONE;}
if(n==2||n==3){return goog.i18n.ordinalRules.Keyword.TWO;}
if(n==4){return goog.i18n.ordinalRules.Keyword.FEW;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.sqSelect_=function(n,opt_precision){if(n==1){return goog.i18n.ordinalRules.Keyword.ONE;}
if(n%10==4&&n%100!=14){return goog.i18n.ordinalRules.Keyword.MANY;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.bnSelect_=function(n,opt_precision){if(n==1||n==5||n==7||n==8||n==9||n==10){return goog.i18n.ordinalRules.Keyword.ONE;}
if(n==2||n==3){return goog.i18n.ordinalRules.Keyword.TWO;}
if(n==4){return goog.i18n.ordinalRules.Keyword.FEW;}
if(n==6){return goog.i18n.ordinalRules.Keyword.MANY;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.guSelect_=function(n,opt_precision){if(n==1){return goog.i18n.ordinalRules.Keyword.ONE;}
if(n==2||n==3){return goog.i18n.ordinalRules.Keyword.TWO;}
if(n==4){return goog.i18n.ordinalRules.Keyword.FEW;}
if(n==6){return goog.i18n.ordinalRules.Keyword.MANY;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.kaSelect_=function(n,opt_precision){var i=n|0;if(i==1){return goog.i18n.ordinalRules.Keyword.ONE;}
if(i==0||(i%100>=2&&i%100<=20||i%100==40||i%100==60||i%100==80)){return goog.i18n.ordinalRules.Keyword.MANY;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.frSelect_=function(n,opt_precision){if(n==1){return goog.i18n.ordinalRules.Keyword.ONE;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.neSelect_=function(n,opt_precision){if(n>=1&&n<=4){return goog.i18n.ordinalRules.Keyword.ONE;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.cySelect_=function(n,opt_precision){if(n==0||n==7||n==8||n==9){return goog.i18n.ordinalRules.Keyword.ZERO;}
if(n==1){return goog.i18n.ordinalRules.Keyword.ONE;}
if(n==2){return goog.i18n.ordinalRules.Keyword.TWO;}
if(n==3||n==4){return goog.i18n.ordinalRules.Keyword.FEW;}
if(n==5||n==6){return goog.i18n.ordinalRules.Keyword.MANY;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.azSelect_=function(n,opt_precision){var i=n|0;if((i%10==1||i%10==2||i%10==5||i%10==7||i%10==8)||(i%100==20||i%100==50||i%100==70||i%100==80)){return goog.i18n.ordinalRules.Keyword.ONE;}
if((i%10==3||i%10==4)||(i%1000==100||i%1000==200||i%1000==300||i%1000==400||i%1000==500||i%1000==600||i%1000==700||i%1000==800||i%1000==900)){return goog.i18n.ordinalRules.Keyword.FEW;}
if(i==0||i%10==6||(i%100==40||i%100==60||i%100==90)){return goog.i18n.ordinalRules.Keyword.MANY;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.caSelect_=function(n,opt_precision){if(n==1||n==3){return goog.i18n.ordinalRules.Keyword.ONE;}
if(n==2){return goog.i18n.ordinalRules.Keyword.TWO;}
if(n==4){return goog.i18n.ordinalRules.Keyword.FEW;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.itSelect_=function(n,opt_precision){if(n==11||n==8||n==80||n==800){return goog.i18n.ordinalRules.Keyword.MANY;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.mkSelect_=function(n,opt_precision){var i=n|0;if(i%10==1&&i%100!=11){return goog.i18n.ordinalRules.Keyword.ONE;}
if(i%10==2&&i%100!=12){return goog.i18n.ordinalRules.Keyword.TWO;}
if((i%10==7||i%10==8)&&i%100!=17&&i%100!=18){return goog.i18n.ordinalRules.Keyword.MANY;}
return goog.i18n.ordinalRules.Keyword.OTHER;};goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.enSelect_;if(goog.LOCALE=='af'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='am'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='ar'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='az'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.azSelect_;}
if(goog.LOCALE=='bg'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='bn'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.bnSelect_;}
if(goog.LOCALE=='br'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='ca'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.caSelect_;}
if(goog.LOCALE=='chr'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='cs'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='cy'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.cySelect_;}
if(goog.LOCALE=='da'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='de'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='de_AT'||goog.LOCALE=='de-AT'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='de_CH'||goog.LOCALE=='de-CH'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='el'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='en'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.enSelect_;}
if(goog.LOCALE=='en_AU'||goog.LOCALE=='en-AU'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.enSelect_;}
if(goog.LOCALE=='en_GB'||goog.LOCALE=='en-GB'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.enSelect_;}
if(goog.LOCALE=='en_IE'||goog.LOCALE=='en-IE'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.enSelect_;}
if(goog.LOCALE=='en_IN'||goog.LOCALE=='en-IN'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.enSelect_;}
if(goog.LOCALE=='en_ISO'||goog.LOCALE=='en-ISO'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.enSelect_;}
if(goog.LOCALE=='en_SG'||goog.LOCALE=='en-SG'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.enSelect_;}
if(goog.LOCALE=='en_US'||goog.LOCALE=='en-US'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.enSelect_;}
if(goog.LOCALE=='en_ZA'||goog.LOCALE=='en-ZA'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.enSelect_;}
if(goog.LOCALE=='es'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='es_419'||goog.LOCALE=='es-419'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='es_ES'||goog.LOCALE=='es-ES'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='et'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='eu'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='fa'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='fi'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='fil'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.frSelect_;}
if(goog.LOCALE=='fr'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.frSelect_;}
if(goog.LOCALE=='fr_CA'||goog.LOCALE=='fr-CA'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.frSelect_;}
if(goog.LOCALE=='gl'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='gsw'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='gu'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.guSelect_;}
if(goog.LOCALE=='haw'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='he'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='hi'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.guSelect_;}
if(goog.LOCALE=='hr'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='hu'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.huSelect_;}
if(goog.LOCALE=='hy'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.frSelect_;}
if(goog.LOCALE=='id'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='in'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='is'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='it'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.itSelect_;}
if(goog.LOCALE=='iw'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='ja'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='ka'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.kaSelect_;}
if(goog.LOCALE=='kk'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.kkSelect_;}
if(goog.LOCALE=='km'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='kn'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='ko'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='ky'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='ln'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='lo'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.frSelect_;}
if(goog.LOCALE=='lt'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='lv'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='mk'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.mkSelect_;}
if(goog.LOCALE=='ml'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='mn'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='mo'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.frSelect_;}
if(goog.LOCALE=='mr'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.mrSelect_;}
if(goog.LOCALE=='ms'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.frSelect_;}
if(goog.LOCALE=='mt'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='my'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='nb'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='ne'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.neSelect_;}
if(goog.LOCALE=='nl'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='no'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='no_NO'||goog.LOCALE=='no-NO'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='or'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='pa'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='pl'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='pt'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='pt_BR'||goog.LOCALE=='pt-BR'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='pt_PT'||goog.LOCALE=='pt-PT'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='ro'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.frSelect_;}
if(goog.LOCALE=='ru'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='sh'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='si'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='sk'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='sl'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='sq'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.sqSelect_;}
if(goog.LOCALE=='sr'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='sv'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.svSelect_;}
if(goog.LOCALE=='sw'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='ta'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='te'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='th'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='tl'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.frSelect_;}
if(goog.LOCALE=='tr'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='uk'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='ur'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='uz'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='vi'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.frSelect_;}
if(goog.LOCALE=='zh'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='zh_CN'||goog.LOCALE=='zh-CN'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='zh_HK'||goog.LOCALE=='zh-HK'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='zh_TW'||goog.LOCALE=='zh-TW'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
if(goog.LOCALE=='zu'){goog.i18n.ordinalRules.select=goog.i18n.ordinalRules.defaultSelect_;}
goog.provide('goog.i18n.pluralRules');goog.i18n.pluralRules.Keyword={ZERO:'zero',ONE:'one',TWO:'two',FEW:'few',MANY:'many',OTHER:'other'};goog.i18n.pluralRules.defaultSelect_=function(n,opt_precision){return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.decimals_=function(n){var str=n+'';var result=str.indexOf('.');return(result==-1)?0:str.length-result-1;};goog.i18n.pluralRules.get_vf_=function(n,opt_precision){var DEFAULT_DIGITS=3;if(undefined===opt_precision){var v=Math.min(goog.i18n.pluralRules.decimals_(n),DEFAULT_DIGITS);}else{var v=opt_precision;}
var base=Math.pow(10,v);var f=((n*base)|0)%base;return{v:v,f:f};};goog.i18n.pluralRules.get_wt_=function(v,f){if(f===0){return{w:0,t:0};}
while((f%10)===0){f/=10;v--;}
return{w:v,t:f};};goog.i18n.pluralRules.gaSelect_=function(n,opt_precision){if(n==1){return goog.i18n.pluralRules.Keyword.ONE;}
if(n==2){return goog.i18n.pluralRules.Keyword.TWO;}
if(n>=3&&n<=6){return goog.i18n.pluralRules.Keyword.FEW;}
if(n>=7&&n<=10){return goog.i18n.pluralRules.Keyword.MANY;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.roSelect_=function(n,opt_precision){var i=n|0;var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);if(i==1&&vf.v==0){return goog.i18n.pluralRules.Keyword.ONE;}
if(vf.v!=0||n==0||n!=1&&n%100>=1&&n%100<=19){return goog.i18n.pluralRules.Keyword.FEW;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.filSelect_=function(n,opt_precision){var i=n|0;var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);if(vf.v==0&&(i==1||i==2||i==3)||vf.v==0&&i%10!=4&&i%10!=6&&i%10!=9||vf.v!=0&&vf.f%10!=4&&vf.f%10!=6&&vf.f%10!=9){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.frSelect_=function(n,opt_precision){var i=n|0;if(i==0||i==1){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.enSelect_=function(n,opt_precision){var i=n|0;var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);if(i==1&&vf.v==0){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.mtSelect_=function(n,opt_precision){if(n==1){return goog.i18n.pluralRules.Keyword.ONE;}
if(n==0||n%100>=2&&n%100<=10){return goog.i18n.pluralRules.Keyword.FEW;}
if(n%100>=11&&n%100<=19){return goog.i18n.pluralRules.Keyword.MANY;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.daSelect_=function(n,opt_precision){var i=n|0;var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);var wt=goog.i18n.pluralRules.get_wt_(vf.v,vf.f);if(n==1||wt.t!=0&&(i==0||i==1)){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.gvSelect_=function(n,opt_precision){var i=n|0;var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);if(vf.v==0&&i%10==1){return goog.i18n.pluralRules.Keyword.ONE;}
if(vf.v==0&&i%10==2){return goog.i18n.pluralRules.Keyword.TWO;}
if(vf.v==0&&(i%100==0||i%100==20||i%100==40||i%100==60||i%100==80)){return goog.i18n.pluralRules.Keyword.FEW;}
if(vf.v!=0){return goog.i18n.pluralRules.Keyword.MANY;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.cySelect_=function(n,opt_precision){if(n==0){return goog.i18n.pluralRules.Keyword.ZERO;}
if(n==1){return goog.i18n.pluralRules.Keyword.ONE;}
if(n==2){return goog.i18n.pluralRules.Keyword.TWO;}
if(n==3){return goog.i18n.pluralRules.Keyword.FEW;}
if(n==6){return goog.i18n.pluralRules.Keyword.MANY;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.brSelect_=function(n,opt_precision){if(n%10==1&&n%100!=11&&n%100!=71&&n%100!=91){return goog.i18n.pluralRules.Keyword.ONE;}
if(n%10==2&&n%100!=12&&n%100!=72&&n%100!=92){return goog.i18n.pluralRules.Keyword.TWO;}
if((n%10>=3&&n%10<=4||n%10==9)&&(n%100<10||n%100>19)&&(n%100<70||n%100>79)&&(n%100<90||n%100>99)){return goog.i18n.pluralRules.Keyword.FEW;}
if(n!=0&&n%1000000==0){return goog.i18n.pluralRules.Keyword.MANY;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.esSelect_=function(n,opt_precision){if(n==1){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.siSelect_=function(n,opt_precision){var i=n|0;var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);if((n==0||n==1)||i==0&&vf.f==1){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.slSelect_=function(n,opt_precision){var i=n|0;var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);if(vf.v==0&&i%100==1){return goog.i18n.pluralRules.Keyword.ONE;}
if(vf.v==0&&i%100==2){return goog.i18n.pluralRules.Keyword.TWO;}
if(vf.v==0&&i%100>=3&&i%100<=4||vf.v!=0){return goog.i18n.pluralRules.Keyword.FEW;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.tzmSelect_=function(n,opt_precision){if(n>=0&&n<=1||n>=11&&n<=99){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.srSelect_=function(n,opt_precision){var i=n|0;var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);if(vf.v==0&&i%10==1&&i%100!=11||vf.f%10==1&&vf.f%100!=11){return goog.i18n.pluralRules.Keyword.ONE;}
if(vf.v==0&&i%10>=2&&i%10<=4&&(i%100<12||i%100>14)||vf.f%10>=2&&vf.f%10<=4&&(vf.f%100<12||vf.f%100>14)){return goog.i18n.pluralRules.Keyword.FEW;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.hiSelect_=function(n,opt_precision){var i=n|0;if(i==0||n==1){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.mkSelect_=function(n,opt_precision){var i=n|0;var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);if(vf.v==0&&i%10==1||vf.f%10==1){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.arSelect_=function(n,opt_precision){if(n==0){return goog.i18n.pluralRules.Keyword.ZERO;}
if(n==1){return goog.i18n.pluralRules.Keyword.ONE;}
if(n==2){return goog.i18n.pluralRules.Keyword.TWO;}
if(n%100>=3&&n%100<=10){return goog.i18n.pluralRules.Keyword.FEW;}
if(n%100>=11&&n%100<=99){return goog.i18n.pluralRules.Keyword.MANY;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.iuSelect_=function(n,opt_precision){if(n==1){return goog.i18n.pluralRules.Keyword.ONE;}
if(n==2){return goog.i18n.pluralRules.Keyword.TWO;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.csSelect_=function(n,opt_precision){var i=n|0;var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);if(i==1&&vf.v==0){return goog.i18n.pluralRules.Keyword.ONE;}
if(i>=2&&i<=4&&vf.v==0){return goog.i18n.pluralRules.Keyword.FEW;}
if(vf.v!=0){return goog.i18n.pluralRules.Keyword.MANY;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.pt_PTSelect_=function(n,opt_precision){var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);if(n==1&&vf.v==0){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.beSelect_=function(n,opt_precision){if(n%10==1&&n%100!=11){return goog.i18n.pluralRules.Keyword.ONE;}
if(n%10>=2&&n%10<=4&&(n%100<12||n%100>14)){return goog.i18n.pluralRules.Keyword.FEW;}
if(n%10==0||n%10>=5&&n%10<=9||n%100>=11&&n%100<=14){return goog.i18n.pluralRules.Keyword.MANY;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.akSelect_=function(n,opt_precision){if(n>=0&&n<=1){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.ptSelect_=function(n,opt_precision){var i=n|0;var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);var wt=goog.i18n.pluralRules.get_wt_(vf.v,vf.f);if(i==1&&vf.v==0||i==0&&wt.t==1){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.plSelect_=function(n,opt_precision){var i=n|0;var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);if(i==1&&vf.v==0){return goog.i18n.pluralRules.Keyword.ONE;}
if(vf.v==0&&i%10>=2&&i%10<=4&&(i%100<12||i%100>14)){return goog.i18n.pluralRules.Keyword.FEW;}
if(vf.v==0&&i!=1&&i%10>=0&&i%10<=1||vf.v==0&&i%10>=5&&i%10<=9||vf.v==0&&i%100>=12&&i%100<=14){return goog.i18n.pluralRules.Keyword.MANY;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.ruSelect_=function(n,opt_precision){var i=n|0;var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);if(vf.v==0&&i%10==1&&i%100!=11){return goog.i18n.pluralRules.Keyword.ONE;}
if(vf.v==0&&i%10>=2&&i%10<=4&&(i%100<12||i%100>14)){return goog.i18n.pluralRules.Keyword.FEW;}
if(vf.v==0&&i%10==0||vf.v==0&&i%10>=5&&i%10<=9||vf.v==0&&i%100>=11&&i%100<=14){return goog.i18n.pluralRules.Keyword.MANY;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.lagSelect_=function(n,opt_precision){var i=n|0;if(n==0){return goog.i18n.pluralRules.Keyword.ZERO;}
if((i==0||i==1)&&n!=0){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.shiSelect_=function(n,opt_precision){var i=n|0;if(i==0||n==1){return goog.i18n.pluralRules.Keyword.ONE;}
if(n>=2&&n<=10){return goog.i18n.pluralRules.Keyword.FEW;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.heSelect_=function(n,opt_precision){var i=n|0;var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);if(i==1&&vf.v==0){return goog.i18n.pluralRules.Keyword.ONE;}
if(i==2&&vf.v==0){return goog.i18n.pluralRules.Keyword.TWO;}
if(vf.v==0&&(n<0||n>10)&&n%10==0){return goog.i18n.pluralRules.Keyword.MANY;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.isSelect_=function(n,opt_precision){var i=n|0;var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);var wt=goog.i18n.pluralRules.get_wt_(vf.v,vf.f);if(wt.t==0&&i%10==1&&i%100!=11||wt.t!=0){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.ltSelect_=function(n,opt_precision){var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);if(n%10==1&&(n%100<11||n%100>19)){return goog.i18n.pluralRules.Keyword.ONE;}
if(n%10>=2&&n%10<=9&&(n%100<11||n%100>19)){return goog.i18n.pluralRules.Keyword.FEW;}
if(vf.f!=0){return goog.i18n.pluralRules.Keyword.MANY;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.gdSelect_=function(n,opt_precision){if(n==1||n==11){return goog.i18n.pluralRules.Keyword.ONE;}
if(n==2||n==12){return goog.i18n.pluralRules.Keyword.TWO;}
if(n>=3&&n<=10||n>=13&&n<=19){return goog.i18n.pluralRules.Keyword.FEW;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.lvSelect_=function(n,opt_precision){var vf=goog.i18n.pluralRules.get_vf_(n,opt_precision);if(n%10==0||n%100>=11&&n%100<=19||vf.v==2&&vf.f%100>=11&&vf.f%100<=19){return goog.i18n.pluralRules.Keyword.ZERO;}
if(n%10==1&&n%100!=11||vf.v==2&&vf.f%10==1&&vf.f%100!=11||vf.v!=2&&vf.f%10==1){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.kshSelect_=function(n,opt_precision){if(n==0){return goog.i18n.pluralRules.Keyword.ZERO;}
if(n==1){return goog.i18n.pluralRules.Keyword.ONE;}
return goog.i18n.pluralRules.Keyword.OTHER;};goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;if(goog.LOCALE=='af'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='am'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.hiSelect_;}
if(goog.LOCALE=='ar'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.arSelect_;}
if(goog.LOCALE=='az'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='bg'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='bn'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.hiSelect_;}
if(goog.LOCALE=='br'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.brSelect_;}
if(goog.LOCALE=='ca'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='chr'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='cs'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.csSelect_;}
if(goog.LOCALE=='cy'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.cySelect_;}
if(goog.LOCALE=='da'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.daSelect_;}
if(goog.LOCALE=='de'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='de_AT'||goog.LOCALE=='de-AT'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='de_CH'||goog.LOCALE=='de-CH'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='el'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='en'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='en_AU'||goog.LOCALE=='en-AU'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='en_GB'||goog.LOCALE=='en-GB'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='en_IE'||goog.LOCALE=='en-IE'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='en_IN'||goog.LOCALE=='en-IN'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='en_ISO'||goog.LOCALE=='en-ISO'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='en_SG'||goog.LOCALE=='en-SG'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='en_US'||goog.LOCALE=='en-US'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='en_ZA'||goog.LOCALE=='en-ZA'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='es'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='es_419'||goog.LOCALE=='es-419'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='es_ES'||goog.LOCALE=='es-ES'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='et'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='eu'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='fa'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.hiSelect_;}
if(goog.LOCALE=='fi'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='fil'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.filSelect_;}
if(goog.LOCALE=='fr'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.frSelect_;}
if(goog.LOCALE=='fr_CA'||goog.LOCALE=='fr-CA'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.frSelect_;}
if(goog.LOCALE=='gl'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='gsw'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='gu'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.hiSelect_;}
if(goog.LOCALE=='haw'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='he'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.heSelect_;}
if(goog.LOCALE=='hi'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.hiSelect_;}
if(goog.LOCALE=='hr'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.srSelect_;}
if(goog.LOCALE=='hu'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='hy'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.frSelect_;}
if(goog.LOCALE=='id'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.defaultSelect_;}
if(goog.LOCALE=='in'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.defaultSelect_;}
if(goog.LOCALE=='is'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.isSelect_;}
if(goog.LOCALE=='it'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='iw'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.heSelect_;}
if(goog.LOCALE=='ja'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.defaultSelect_;}
if(goog.LOCALE=='ka'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='kk'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='km'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.defaultSelect_;}
if(goog.LOCALE=='kn'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.hiSelect_;}
if(goog.LOCALE=='ko'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.defaultSelect_;}
if(goog.LOCALE=='ky'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='ln'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.akSelect_;}
if(goog.LOCALE=='lo'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.defaultSelect_;}
if(goog.LOCALE=='lt'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.ltSelect_;}
if(goog.LOCALE=='lv'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.lvSelect_;}
if(goog.LOCALE=='mk'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.mkSelect_;}
if(goog.LOCALE=='ml'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='mn'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='mo'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.roSelect_;}
if(goog.LOCALE=='mr'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.hiSelect_;}
if(goog.LOCALE=='ms'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.defaultSelect_;}
if(goog.LOCALE=='mt'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.mtSelect_;}
if(goog.LOCALE=='my'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.defaultSelect_;}
if(goog.LOCALE=='nb'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='ne'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='nl'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='no'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='no_NO'||goog.LOCALE=='no-NO'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='or'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='pa'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.akSelect_;}
if(goog.LOCALE=='pl'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.plSelect_;}
if(goog.LOCALE=='pt'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.ptSelect_;}
if(goog.LOCALE=='pt_BR'||goog.LOCALE=='pt-BR'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.ptSelect_;}
if(goog.LOCALE=='pt_PT'||goog.LOCALE=='pt-PT'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.pt_PTSelect_;}
if(goog.LOCALE=='ro'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.roSelect_;}
if(goog.LOCALE=='ru'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.ruSelect_;}
if(goog.LOCALE=='sh'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.srSelect_;}
if(goog.LOCALE=='si'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.siSelect_;}
if(goog.LOCALE=='sk'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.csSelect_;}
if(goog.LOCALE=='sl'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.slSelect_;}
if(goog.LOCALE=='sq'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='sr'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.srSelect_;}
if(goog.LOCALE=='sv'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='sw'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='ta'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='te'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='th'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.defaultSelect_;}
if(goog.LOCALE=='tl'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.filSelect_;}
if(goog.LOCALE=='tr'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='uk'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.ruSelect_;}
if(goog.LOCALE=='ur'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.enSelect_;}
if(goog.LOCALE=='uz'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.esSelect_;}
if(goog.LOCALE=='vi'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.defaultSelect_;}
if(goog.LOCALE=='zh'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.defaultSelect_;}
if(goog.LOCALE=='zh_CN'||goog.LOCALE=='zh-CN'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.defaultSelect_;}
if(goog.LOCALE=='zh_HK'||goog.LOCALE=='zh-HK'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.defaultSelect_;}
if(goog.LOCALE=='zh_TW'||goog.LOCALE=='zh-TW'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.defaultSelect_;}
if(goog.LOCALE=='zu'){goog.i18n.pluralRules.select=goog.i18n.pluralRules.hiSelect_;}
goog.provide('goog.i18n.MessageFormat');goog.require('goog.asserts');goog.require('goog.i18n.ordinalRules');goog.require('goog.i18n.pluralRules');goog.i18n.MessageFormat=function(pattern){this.literals_=[];this.parsedPattern_=[];this.parsePattern_(pattern);};goog.i18n.MessageFormat.LITERAL_PLACEHOLDER_='\uFDDF_';goog.i18n.MessageFormat.Element_={STRING:0,BLOCK:1};goog.i18n.MessageFormat.BlockType_={PLURAL:0,ORDINAL:1,SELECT:2,SIMPLE:3,STRING:4,UNKNOWN:5};goog.i18n.MessageFormat.OTHER_='other';goog.i18n.MessageFormat.REGEX_LITERAL_=new RegExp("'([{}#].*?)'",'g');goog.i18n.MessageFormat.REGEX_DOUBLE_APOSTROPHE_=new RegExp("''",'g');goog.i18n.MessageFormat.prototype.format=function(namedParameters){return this.format_(namedParameters,false);};goog.i18n.MessageFormat.prototype.formatIgnoringPound=function(namedParameters){return this.format_(namedParameters,true);};goog.i18n.MessageFormat.prototype.format_=function(namedParameters,ignorePound){if(this.parsedPattern_.length==0){return'';}
var result=[];this.formatBlock_(this.parsedPattern_,namedParameters,ignorePound,result);var message=result.join('');if(!ignorePound){goog.asserts.assert(message.search('#')==-1,'Not all # were replaced.');}
while(this.literals_.length>0){message=message.replace(this.buildPlaceholder_(this.literals_),this.literals_.pop());}
return message;};goog.i18n.MessageFormat.prototype.formatBlock_=function(parsedPattern,namedParameters,ignorePound,result){for(var i=0;i<parsedPattern.length;i++){switch(parsedPattern[i].type){case goog.i18n.MessageFormat.BlockType_.STRING:result.push(parsedPattern[i].value);break;case goog.i18n.MessageFormat.BlockType_.SIMPLE:var pattern=parsedPattern[i].value;this.formatSimplePlaceholder_(pattern,namedParameters,result);break;case goog.i18n.MessageFormat.BlockType_.SELECT:var pattern=parsedPattern[i].value;this.formatSelectBlock_(pattern,namedParameters,ignorePound,result);break;case goog.i18n.MessageFormat.BlockType_.PLURAL:var pattern=parsedPattern[i].value;this.formatPluralOrdinalBlock_(pattern,namedParameters,goog.i18n.pluralRules.select,ignorePound,result);break;case goog.i18n.MessageFormat.BlockType_.ORDINAL:var pattern=parsedPattern[i].value;this.formatPluralOrdinalBlock_(pattern,namedParameters,goog.i18n.ordinalRules.select,ignorePound,result);break;default:goog.asserts.fail('Unrecognized block type.');}}};goog.i18n.MessageFormat.prototype.formatSimplePlaceholder_=function(parsedPattern,namedParameters,result){var value=namedParameters[parsedPattern];if(!goog.isDef(value)){result.push('Undefined parameter - '+parsedPattern);return;}
this.literals_.push(value);result.push(this.buildPlaceholder_(this.literals_));};goog.i18n.MessageFormat.prototype.formatSelectBlock_=function(parsedPattern,namedParameters,ignorePound,result){var argumentIndex=parsedPattern.argumentIndex;if(!goog.isDef(namedParameters[argumentIndex])){result.push('Undefined parameter - '+argumentIndex);return;}
var option=parsedPattern[namedParameters[argumentIndex]];if(!goog.isDef(option)){option=parsedPattern[goog.i18n.MessageFormat.OTHER_];goog.asserts.assertArray(option,'Invalid option or missing other option for select block.');}
this.formatBlock_(option,namedParameters,ignorePound,result);};goog.i18n.MessageFormat.prototype.formatPluralOrdinalBlock_=function(parsedPattern,namedParameters,pluralSelector,ignorePound,result){var argumentIndex=parsedPattern.argumentIndex;var argumentOffset=parsedPattern.argumentOffset;var pluralValue=+namedParameters[argumentIndex];if(isNaN(pluralValue)){result.push('Undefined or invalid parameter - '+argumentIndex);return;}
var diff=pluralValue-argumentOffset;var option=parsedPattern[namedParameters[argumentIndex]];if(!goog.isDef(option)){goog.asserts.assert(diff>=0,'Argument index smaller than offset.');var item;item=pluralSelector(diff);goog.asserts.assertString(item,'Invalid plural key.');option=parsedPattern[item];if(!goog.isDef(option)){option=parsedPattern[goog.i18n.MessageFormat.OTHER_];}
goog.asserts.assertArray(option,'Invalid option or missing other option for plural block.');}
var pluralResult=[];this.formatBlock_(option,namedParameters,ignorePound,pluralResult);var plural=pluralResult.join('');goog.asserts.assertString(plural,'Empty block in plural.');if(ignorePound){result.push(plural);}else{var localeAwareDiff=diff.toLocaleString();result.push(plural.replace(/#/g,localeAwareDiff));}};goog.i18n.MessageFormat.prototype.parsePattern_=function(pattern){if(pattern){pattern=this.insertPlaceholders_(pattern);this.parsedPattern_=this.parseBlock_(pattern);}};goog.i18n.MessageFormat.prototype.insertPlaceholders_=function(pattern){var literals=this.literals_;var buildPlaceholder=goog.bind(this.buildPlaceholder_,this);pattern=pattern.replace(goog.i18n.MessageFormat.REGEX_DOUBLE_APOSTROPHE_,function(){literals.push("'");return buildPlaceholder(literals);});pattern=pattern.replace(goog.i18n.MessageFormat.REGEX_LITERAL_,function(match,text){literals.push(text);return buildPlaceholder(literals);});return pattern;};goog.i18n.MessageFormat.prototype.extractParts_=function(pattern){var prevPos=0;var inBlock=false;var braceStack=[];var results=[];var braces=/[{}]/g;braces.lastIndex=0;var match;while(match=braces.exec(pattern)){var pos=match.index;if(match[0]=='}'){var brace=braceStack.pop();goog.asserts.assert(goog.isDef(brace)&&brace=='{','No matching { for }.');if(braceStack.length==0){var part={};part.type=goog.i18n.MessageFormat.Element_.BLOCK;part.value=pattern.substring(prevPos,pos);results.push(part);prevPos=pos+1;inBlock=false;}}else{if(braceStack.length==0){inBlock=true;var substring=pattern.substring(prevPos,pos);if(substring!=''){results.push({type:goog.i18n.MessageFormat.Element_.STRING,value:substring});}
prevPos=pos+1;}
braceStack.push('{');}}
goog.asserts.assert(braceStack.length==0,'There are mismatched { or } in the pattern.');var substring=pattern.substring(prevPos);if(substring!=''){results.push({type:goog.i18n.MessageFormat.Element_.STRING,value:substring});}
return results;};goog.i18n.MessageFormat.PLURAL_BLOCK_RE_=/^\s*(\w+)\s*,\s*plural\s*,(?:\s*offset:(\d+))?/;goog.i18n.MessageFormat.ORDINAL_BLOCK_RE_=/^\s*(\w+)\s*,\s*selectordinal\s*,/;goog.i18n.MessageFormat.SELECT_BLOCK_RE_=/^\s*(\w+)\s*,\s*select\s*,/;goog.i18n.MessageFormat.prototype.parseBlockType_=function(pattern){if(goog.i18n.MessageFormat.PLURAL_BLOCK_RE_.test(pattern)){return goog.i18n.MessageFormat.BlockType_.PLURAL;}
if(goog.i18n.MessageFormat.ORDINAL_BLOCK_RE_.test(pattern)){return goog.i18n.MessageFormat.BlockType_.ORDINAL;}
if(goog.i18n.MessageFormat.SELECT_BLOCK_RE_.test(pattern)){return goog.i18n.MessageFormat.BlockType_.SELECT;}
if(/^\s*\w+\s*/.test(pattern)){return goog.i18n.MessageFormat.BlockType_.SIMPLE;}
return goog.i18n.MessageFormat.BlockType_.UNKNOWN;};goog.i18n.MessageFormat.prototype.parseBlock_=function(pattern){var result=[];var parts=this.extractParts_(pattern);for(var i=0;i<parts.length;i++){var block={};if(goog.i18n.MessageFormat.Element_.STRING==parts[i].type){block.type=goog.i18n.MessageFormat.BlockType_.STRING;block.value=parts[i].value;}else if(goog.i18n.MessageFormat.Element_.BLOCK==parts[i].type){var blockType=this.parseBlockType_(parts[i].value);switch(blockType){case goog.i18n.MessageFormat.BlockType_.SELECT:block.type=goog.i18n.MessageFormat.BlockType_.SELECT;block.value=this.parseSelectBlock_(parts[i].value);break;case goog.i18n.MessageFormat.BlockType_.PLURAL:block.type=goog.i18n.MessageFormat.BlockType_.PLURAL;block.value=this.parsePluralBlock_(parts[i].value);break;case goog.i18n.MessageFormat.BlockType_.ORDINAL:block.type=goog.i18n.MessageFormat.BlockType_.ORDINAL;block.value=this.parseOrdinalBlock_(parts[i].value);break;case goog.i18n.MessageFormat.BlockType_.SIMPLE:block.type=goog.i18n.MessageFormat.BlockType_.SIMPLE;block.value=parts[i].value;break;default:goog.asserts.fail('Unknown block type.');}}else{goog.asserts.fail('Unknown part of the pattern.');}
result.push(block);}
return result;};goog.i18n.MessageFormat.prototype.parseSelectBlock_=function(pattern){var argumentIndex='';var replaceRegex=goog.i18n.MessageFormat.SELECT_BLOCK_RE_;pattern=pattern.replace(replaceRegex,function(string,name){argumentIndex=name;return'';});var result={};result.argumentIndex=argumentIndex;var parts=this.extractParts_(pattern);var pos=0;while(pos<parts.length){var key=parts[pos].value;goog.asserts.assertString(key,'Missing select key element.');pos++;goog.asserts.assert(pos<parts.length,'Missing or invalid select value element.');if(goog.i18n.MessageFormat.Element_.BLOCK==parts[pos].type){var value=this.parseBlock_(parts[pos].value);}else{goog.asserts.fail('Expected block type.');}
result[key.replace(/\s/g,'')]=value;pos++;}
goog.asserts.assertArray(result[goog.i18n.MessageFormat.OTHER_],'Missing other key in select statement.');return result;};goog.i18n.MessageFormat.prototype.parsePluralBlock_=function(pattern){var argumentIndex='';var argumentOffset=0;var replaceRegex=goog.i18n.MessageFormat.PLURAL_BLOCK_RE_;pattern=pattern.replace(replaceRegex,function(string,name,offset){argumentIndex=name;if(offset){argumentOffset=parseInt(offset,10);}
return'';});var result={};result.argumentIndex=argumentIndex;result.argumentOffset=argumentOffset;var parts=this.extractParts_(pattern);var pos=0;while(pos<parts.length){var key=parts[pos].value;goog.asserts.assertString(key,'Missing plural key element.');pos++;goog.asserts.assert(pos<parts.length,'Missing or invalid plural value element.');if(goog.i18n.MessageFormat.Element_.BLOCK==parts[pos].type){var value=this.parseBlock_(parts[pos].value);}else{goog.asserts.fail('Expected block type.');}
result[key.replace(/\s*(?:=)?(\w+)\s*/,'$1')]=value;pos++;}
goog.asserts.assertArray(result[goog.i18n.MessageFormat.OTHER_],'Missing other key in plural statement.');return result;};goog.i18n.MessageFormat.prototype.parseOrdinalBlock_=function(pattern){var argumentIndex='';var replaceRegex=goog.i18n.MessageFormat.ORDINAL_BLOCK_RE_;pattern=pattern.replace(replaceRegex,function(string,name){argumentIndex=name;return'';});var result={};result.argumentIndex=argumentIndex;result.argumentOffset=0;var parts=this.extractParts_(pattern);var pos=0;while(pos<parts.length){var key=parts[pos].value;goog.asserts.assertString(key,'Missing ordinal key element.');pos++;goog.asserts.assert(pos<parts.length,'Missing or invalid ordinal value element.');if(goog.i18n.MessageFormat.Element_.BLOCK==parts[pos].type){var value=this.parseBlock_(parts[pos].value);}else{goog.asserts.fail('Expected block type.');}
result[key.replace(/\s*(?:=)?(\w+)\s*/,'$1')]=value;pos++;}
goog.asserts.assertArray(result[goog.i18n.MessageFormat.OTHER_],'Missing other key in selectordinal statement.');return result;};goog.i18n.MessageFormat.prototype.buildPlaceholder_=function(literals){goog.asserts.assert(literals.length>0,'Literal array is empty.');var index=(literals.length-1).toString(10);return goog.i18n.MessageFormat.LITERAL_PLACEHOLDER_+index+'_';};goog.provide('Output');goog.provide('Output.EventType');goog.require('EarconEngine');goog.require('Spannable');goog.require('constants');goog.require('cursors.Cursor');goog.require('cursors.Range');goog.require('cursors.Unit');goog.require('cvox.AbstractEarcons');goog.require('cvox.ChromeVox');goog.require('cvox.NavBraille');goog.require('cvox.TtsCategory');goog.require('cvox.ValueSelectionSpan');goog.require('cvox.ValueSpan');goog.require('goog.i18n.MessageFormat');goog.scope(function(){var AutomationNode=chrome.automation.AutomationNode;var Dir=constants.Dir;var EventType=chrome.automation.EventType;var RoleType=chrome.automation.RoleType;Output=function(){this.speechBuffer_=[];this.brailleBuffer_=[];this.locations_=[];this.speechEndCallback_;this.formatOptions_={speech:true,braille:false,auralStyle:false};this.speechCategory_=cvox.TtsCategory.NAV;this.queueMode_=cvox.QueueMode.QUEUE;};Output.SPACE=' ';Output.ROLE_INFO_={alert:{msgId:'role_alert',earconId:'ALERT_NONMODAL'},alertDialog:{msgId:'role_alertdialog'},article:{msgId:'role_article',inherits:'abstractContainer'},application:{msgId:'role_application',inherits:'abstractContainer'},banner:{msgId:'role_banner',inherits:'abstractContainer'},button:{msgId:'role_button',earconId:'BUTTON'},buttonDropDown:{msgId:'role_button',earconId:'BUTTON'},cell:{msgId:'role_gridcell'},checkBox:{msgId:'role_checkbox'},columnHeader:{msgId:'role_columnheader',inherits:'abstractContainer'},comboBox:{msgId:'role_combobox'},complementary:{msgId:'role_complementary',inherits:'abstractContainer'},contentInfo:{msgId:'role_contentinfo',inherits:'abstractContainer'},date:{msgId:'input_type_date',inherits:'abstractContainer'},definition:{msgId:'role_definition',inherits:'abstractContainer'},dialog:{msgId:'role_dialog'},directory:{msgId:'role_directory',inherits:'abstractContainer'},document:{msgId:'role_document',inherits:'abstractContainer'},form:{msgId:'role_form',inherits:'abstractContainer'},grid:{msgId:'role_grid'},group:{msgId:'role_group'},heading:{msgId:'role_heading',},image:{msgId:'role_img',},inputTime:{msgId:'input_type_time',inherits:'abstractContainer'},link:{msgId:'role_link',earconId:'LINK'},listBox:{msgId:'role_listbox',earconId:'LISTBOX'},listBoxOption:{msgId:'role_listitem',earconId:'LIST_ITEM'},listItem:{msgId:'role_listitem',earconId:'LIST_ITEM'},log:{msgId:'role_log',},main:{msgId:'role_main',inherits:'abstractContainer'},marquee:{msgId:'role_marquee',},math:{msgId:'role_math',inherits:'abstractContainer'},menu:{msgId:'role_menu'},menuBar:{msgId:'role_menubar',},menuItem:{msgId:'role_menuitem',ignoreAncestry:true},menuItemCheckBox:{msgId:'role_menuitemcheckbox',ignoreAncestry:true},menuItemRadio:{msgId:'role_menuitemradio',ignoreAncestry:true},menuListOption:{msgId:'role_menuitem',ignoreAncestry:true},menuListPopup:{msgId:'role_menu'},navigation:{msgId:'role_navigation',inherits:'abstractContainer'},note:{msgId:'role_note',inherits:'abstractContainer'},popUpButton:{msgId:'role_button',earconId:'POP_UP_BUTTON'},radioButton:{msgId:'role_radio'},radioGroup:{msgId:'role_radiogroup',},rowHeader:{msgId:'role_rowheader',inherits:'abstractContainer'},scrollBar:{msgId:'role_scrollbar',},search:{msgId:'role_search',inherits:'abstractContainer'},separator:{msgId:'role_separator',inherits:'abstractContainer'},spinButton:{msgId:'role_spinbutton',earconId:'LISTBOX'},status:{msgId:'role_status'},tab:{msgId:'role_tab'},tabList:{msgId:'role_tablist'},tabPanel:{msgId:'role_tabpanel'},textBox:{msgId:'input_type_text',earconId:'EDITABLE_TEXT'},textField:{msgId:'input_type_text',earconId:'EDITABLE_TEXT'},time:{msgId:'tag_time',inherits:'abstractContainer'},timer:{msgId:'role_timer'},toolbar:{msgId:'role_toolbar'},toggleButton:{msgId:'role_button',inherits:'checkBox'},tree:{msgId:'role_tree'},treeItem:{msgId:'role_treeitem'}};Output.STATE_INFO_={checked:{on:{msgId:'checkbox_checked_state'},off:{msgId:'checkbox_unchecked_state'},omitted:{msgId:'checkbox_unchecked_state'}},collapsed:{on:{msgId:'aria_expanded_false'},off:{msgId:'aria_expanded_true'}},expanded:{on:{msgId:'aria_expanded_true'},off:{msgId:'aria_expanded_false'}},pressed:{on:{msgId:'aria_pressed_true'},off:{msgId:'aria_pressed_false'},omitted:{msgId:'aria_pressed_false'}},visited:{on:{msgId:'visited_state'}}};Output.INPUT_TYPE_MESSAGE_IDS_={'email':'input_type_email','number':'input_type_number','password':'input_type_password','search':'input_type_search','tel':'input_type_number','text':'input_type_text','url':'input_type_url',};Output.RULES={navigate:{'default':{speak:'$name $value $state $role $description',braille:''},abstractContainer:{enter:'$nameFromNode $role $description',leave:'@exited_container($role)'},alert:{speak:'!doNotInterrupt $role $descendants'},alertDialog:{enter:'$nameFromNode $role $description',speak:'$name $role $descendants'},cell:{enter:'@column_granularity $tableCellColumnIndex'},checkBox:{speak:'$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) '+'$name $role $checked $description'},dialog:{enter:'$nameFromNode $role $description'},div:{enter:'$nameFromNode',speak:'$name $description $descendants'},grid:{enter:'$nameFromNode $role $description'},heading:{enter:'!relativePitch(hierarchicalLevel) '+'$nameFromNode= @tag_h+$hierarchicalLevel',speak:'!relativePitch(hierarchicalLevel)'+' $nameOrDescendants= @tag_h+$hierarchicalLevel'},inlineTextBox:{speak:'$name='},link:{enter:'$nameFromNode= $if($visited, @visited_link, $role)',speak:'$name= $if($visited, @visited_link, $role) $description'},list:{enter:'$role @@list_with_items($countChildren(listItem))'},listBox:{enter:'$nameFromNode '+'$role @@list_with_items($countChildren(listBoxOption)) '+'$description'},listBoxOption:{speak:'$name $role @describe_index($indexInParent, $parentChildCount) '+'$description'},listItem:{enter:'$role'},menu:{enter:'$name $role',speak:'$name $role @@list_with_items($countChildren(menuItem))'},menuItem:{speak:'$name $role $if($haspopup, @has_submenu) '+'@describe_index($indexInParent, $parentChildCount) '+'$description'},menuItemCheckBox:{speak:'$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) '+'$name $role $checked $description '+'@describe_index($indexInParent, $parentChildCount) '},menuItemRadio:{speak:'$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) '+'$if($checked, @describe_radio_selected($name), '+'@describe_radio_unselected($name)) $description '+'@describe_index($indexInParent, $parentChildCount) '},menuListOption:{speak:'$name @role_menuitem '+'@describe_index($indexInParent, $parentChildCount) $description'},paragraph:{speak:'$descendants'},popUpButton:{speak:'$value $name $role @aria_has_popup '+'$if($collapsed, @aria_expanded_false, @aria_expanded_true) '+'$description'},radioButton:{speak:'$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) '+'$if($checked, @describe_radio_selected($name), '+'@describe_radio_unselected($name)) $description'},radioGroup:{enter:'$name $role $description'},rootWebArea:{enter:'$name',speak:'$if($name, $name, $docUrl)'},region:{speak:'$descendants'},row:{enter:'@row_granularity $tableRowIndex'},slider:{speak:'$earcon(SLIDER) @describe_slider($value, $name) $description'},staticText:{speak:'$name='},tab:{speak:'@describe_tab($name)'},textField:{speak:'$name $value $if($multiline, @tag_textarea, $if('+'$inputType, $inputType, $role)) $description',braille:''},toggleButton:{speak:'$if($pressed, $earcon(CHECK_ON), $earcon(CHECK_OFF)) '+'$name $role $pressed $description'},toolbar:{enter:'$name $role $description'},tree:{enter:'$name $role @@list_with_items($countChildren(treeItem))'},treeItem:{enter:'$role $expanded $collapsed '+'@describe_index($indexInParent, $parentChildCount) '+'@describe_depth($hierarchicalLevel)'},window:{enter:'@describe_window($name)',speak:'@describe_window($name) $earcon(OBJECT_OPEN)'}},menuStart:{'default':{speak:'@chrome_menu_opened($name) $earcon(OBJECT_OPEN)'}},menuEnd:{'default':{speak:'@chrome_menu_closed $earcon(OBJECT_CLOSE)'}},menuListValueChanged:{'default':{speak:'$value $name '+'$find({"state": {"selected": true, "invisible": false}}, '+'@describe_index($indexInParent, $parentChildCount)) '}},alert:{default:{speak:'!doNotInterrupt @role_alert '+'$if($name, $name, $descendants) $earcon(ALERT_NONMODAL) $description'}}};Output.SpeechProperties=function(){};Output.Action=function(){};Output.Action.prototype={run:function(){}};Output.EarconAction=function(earconId){Output.Action.call(this);this.earconId=earconId;};Output.EarconAction.prototype={__proto__:Output.Action.prototype,run:function(){cvox.ChromeVox.earcons.playEarcon(cvox.Earcon[this.earconId]);}};Output.SelectionSpan=function(startIndex,endIndex,opt_offset){this.startIndex=startIndex<endIndex?startIndex:endIndex;this.endIndex=endIndex>startIndex?endIndex:startIndex;this.offset=opt_offset||0;};Output.NodeSpan=function(node){this.node=node;};Output.EventType={NAVIGATE:'navigate'};Output.flushNextSpeechUtterance_=false;Output.flushNextSpeechUtterance=function(){Output.flushNextSpeechUtterance_=true;};Output.prototype={get speechOutputForTest(){return this.speechBuffer_.reduce(function(prev,cur){if(prev===null)
return cur;prev.append('|');prev.append(cur);return prev;},null);},get brailleOutputForTest(){return this.createBrailleOutput_();},get hasSpeech(){for(var i=0;i<this.speechBuffer_.length;i++){if(this.speechBuffer_[i].trim().length)
return true;}
return false;},withSpeech:function(range,prevRange,type){this.formatOptions_={speech:true,braille:false,auralStyle:false};this.render_(range,prevRange,type,this.speechBuffer_);return this;},withRichSpeech:function(range,prevRange,type){this.formatOptions_={speech:true,braille:false,auralStyle:true};this.render_(range,prevRange,type,this.speechBuffer_);return this;},withBraille:function(range,prevRange,type){this.formatOptions_={speech:false,braille:true,auralStyle:false};this.render_(range,prevRange,type,this.brailleBuffer_);return this;},withLocation:function(range,prevRange,type){this.formatOptions_={speech:false,braille:false,auralStyle:false};this.render_(range,prevRange,type,[]);return this;},withSpeechAndBraille:function(range,prevRange,type){this.withSpeech(range,prevRange,type);this.withBraille(range,prevRange,type);return this;},withRichSpeechAndBraille:function(range,prevRange,type){this.withRichSpeech(range,prevRange,type);this.withBraille(range,prevRange,type);return this;},withSpeechCategory:function(category){this.speechCategory_=category;return this;},withQueueMode:function(queueMode){this.queueMode_=queueMode;return this;},withString:function(value){this.append_(this.speechBuffer_,value);this.append_(this.brailleBuffer_,value);return this;},format:function(formatStr,opt_node){return this.formatForSpeech(formatStr,opt_node).formatForBraille(formatStr,opt_node);},formatForSpeech:function(formatStr,opt_node){var node=opt_node||null;this.formatOptions_={speech:true,braille:false,auralStyle:false};this.format_(node,formatStr,this.speechBuffer_);return this;},formatForBraille:function(formatStr,opt_node){var node=opt_node||null;this.formatOptions_={speech:false,braille:true,auralStyle:false};this.format_(node,formatStr,this.brailleBuffer_);return this;},onSpeechEnd:function(callback){this.speechEndCallback_=function(opt_cleanupOnly){if(!opt_cleanupOnly)
callback();}.bind(this);return this;},go:function(){var queueMode=this.queueMode_;this.speechBuffer_.forEach(function(buff,i,a){if(Output.flushNextSpeechUtterance_&&buff.length>0){queueMode=cvox.QueueMode.FLUSH;Output.flushNextSpeechUtterance_=false;}
var speechProps={};(function(){var scopedBuff=buff;speechProps=scopedBuff.getSpanInstanceOf(Output.SpeechProperties)||{};speechProps.category=this.speechCategory_;speechProps['startCallback']=function(){var actions=scopedBuff.getSpansInstanceOf(Output.Action);if(actions){actions.forEach(function(a){a.run();});}};}.bind(this)());if(this.speechEndCallback_&&i==a.length-1)
speechProps['endCallback']=this.speechEndCallback_;else
speechProps['endCallback']=null;cvox.ChromeVox.tts.speak(buff.toString(),queueMode,speechProps);queueMode=cvox.QueueMode.QUEUE;}.bind(this));if(this.brailleBuffer_.length){var buff=this.createBrailleOutput_();var selSpan=buff.getSpanInstanceOf(Output.SelectionSpan);var startIndex=-1,endIndex=-1;if(selSpan){var valueStart=buff.getSpanStart(selSpan);var valueEnd=buff.getSpanEnd(selSpan);startIndex=valueStart+selSpan.startIndex;endIndex=valueStart+selSpan.endIndex;buff.setSpan(new cvox.ValueSpan(selSpan.offset),valueStart,valueEnd);buff.setSpan(new cvox.ValueSelectionSpan(),startIndex,endIndex);}
var output=new cvox.NavBraille({text:buff,startIndex:startIndex,endIndex:endIndex});cvox.ChromeVox.braille.write(output);}
if(cvox.ChromeVox.isChromeOS&&this.speechCategory_!=cvox.TtsCategory.LIVE){chrome.accessibilityPrivate.setFocusRing(this.locations_);}},render_:function(range,prevRange,type,buff){if(prevRange&&!prevRange.isValid())
prevRange=null;if(range.isSubNode())
this.subNode_(range,prevRange,type,buff);else
this.range_(range,prevRange,type,buff);},format_:function(node,format,buff,opt_prevNode){var tokens=[];var args=null;if(typeof(format)=='string'){format=format.replace(/([,:])\W/g,'$1');tokens=format.split(' ');}else{tokens=[format];}
var speechProps=null;tokens.forEach(function(token){if(!token)
return;var tree;if(typeof(token)=='string')
tree=this.createParseTree_(token);else
tree=token;token=tree.value;var options={};options.annotation=[];options.isUnique=token[token.length-1]=='=';if(options.isUnique)
token=token.substring(0,token.length-1);if(node&&this.formatOptions_.braille)
options.annotation.push(new Output.NodeSpan(node));var prefix=token[0];token=token.slice(1);if(prefix=='$'){if(token=='value'){var text=node.value;if(!node.state.editable&&node.name==text)
return;if(text!==undefined){if(node.textSelStart!==undefined){options.annotation.push(new Output.SelectionSpan(node.textSelStart,node.textSelEnd));}}
options.annotation.push(token);this.append_(buff,text,options);}else if(token=='name'){options.annotation.push(token);var earcon=node?this.findEarcon_(node,opt_prevNode):null;if(earcon)
options.annotation.push(earcon);this.append_(buff,node.name,options);}else if(token=='nameFromNode'){if(chrome.automation.NameFromType[node.nameFrom]=='contents')
return;options.annotation.push('name');this.append_(buff,node.name,options);}else if(token=='nameOrDescendants'){options.annotation.push(token);if(node.name)
this.append_(buff,node.name,options);else
this.format_(node,'$descendants',buff);}else if(token=='description'){if(node.name==node.description||node.value==node.description)
return;options.annotation.push(token);this.append_(buff,node.description,options);}else if(token=='indexInParent'){if(node.parent){options.annotation.push(token);var count=0;for(var i=0,child;child=node.parent.children[i];i++){if(node.role==child.role)
count++;if(node===child)
break;}
this.append_(buff,String(count));}}else if(token=='parentChildCount'){if(node.parent){options.annotation.push(token);var count=node.parent.children.filter(function(child){return node.role==child.role;}).length;this.append_(buff,String(count));}}else if(token=='state'){options.annotation.push(token);Object.getOwnPropertyNames(node.state).forEach(function(s){var stateInfo=Output.STATE_INFO_[s];if(stateInfo&&stateInfo.on)
this.append_(buff,Msgs.getMsg(stateInfo.on.msgId),options);}.bind(this));}else if(token=='find'){if(tree.firstChild){var jsonQuery=tree.firstChild.value;node=node.find((JSON.parse(jsonQuery)));var formatString=tree.firstChild.nextSibling;if(node)
this.format_(node,formatString,buff);}}else if(token=='descendants'){if(!node||AutomationPredicate.leaf(node))
return;var leftmost=AutomationUtil.findNodePre(node,Dir.FORWARD,AutomationPredicate.leaf);var rightmost=AutomationUtil.findNodePre(node,Dir.BACKWARD,AutomationPredicate.leaf);if(!leftmost||!rightmost)
return;var subrange=new cursors.Range(new cursors.Cursor(leftmost,0),new cursors.Cursor(rightmost,0));var prev=null;if(node)
prev=cursors.Range.fromNode(node);this.range_(subrange,prev,Output.EventType.NAVIGATE,buff);}else if(token=='joinedDescendants'){var unjoined=[];this.format_(node,'$descendants',unjoined);this.append_(buff,unjoined.join(' '),options);}else if(token=='role'){if(localStorage['useVerboseMode']=='false')
return;if(this.formatOptions_.auralStyle){speechProps=new Output.SpeechProperties();speechProps['relativePitch']=-0.3;}
options.annotation.push(token);var msg=node.role;var info=Output.ROLE_INFO_[node.role];if(info){if(this.formatOptions_.braille)
msg=Msgs.getMsg(info.msgId+'_brl');else
msg=Msgs.getMsg(info.msgId);}else{console.error('Missing role info for '+node.role);}
this.append_(buff,msg,options);}else if(token=='inputType'){if(!node.inputType)
return;options.annotation.push(token);var msgId=Output.INPUT_TYPE_MESSAGE_IDS_[node.inputType]||'input_type_text';if(this.formatOptions_.braille)
msgId=msgId+'_brl';this.append_(buff,Msgs.getMsg(msgId),options);}else if(token=='tableRowIndex'||token=='tableCellColumnIndex'){var value=node[token];if(!value)
return;value=String(value+1);options.annotation.push(token);this.append_(buff,value,options);}else if(node[token]!==undefined){options.annotation.push(token);var value=node[token];if(typeof value=='number')
value=String(value);this.append_(buff,value,options);}else if(Output.STATE_INFO_[token]){options.annotation.push('state');var stateInfo=Output.STATE_INFO_[token];var resolvedInfo={};if(node.state[token]===undefined)
resolvedInfo=stateInfo.omitted;else
resolvedInfo=node.state[token]?stateInfo.on:stateInfo.off;if(!resolvedInfo)
return;if(this.formatOptions_.speech&&resolvedInfo.earconId){options.annotation.push(new Output.EarconAction(resolvedInfo.earconId));}
var msgId=this.formatOptions_.braille?resolvedInfo.msgId+'_brl':resolvedInfo.msgId;var msg=Msgs.getMsg(msgId);this.append_(buff,msg,options);}else if(tree.firstChild){if(token=='if'){var cond=tree.firstChild;var attrib=cond.value.slice(1);if(node[attrib]||node.state[attrib])
this.format_(node,cond.nextSibling,buff);else
this.format_(node,cond.nextSibling.nextSibling,buff);}else if(token=='earcon'){if(!this.formatOptions_.speech)
return;options.annotation.push(new Output.EarconAction(tree.firstChild.value));this.append_(buff,'',options);}else if(token=='countChildren'){var role=tree.firstChild.value;var count=node.children.filter(function(e){return e.role==role;}).length;this.append_(buff,String(count));}}}else if(prefix=='@'){if(this.formatOptions_.auralStyle){speechProps=new Output.SpeechProperties();speechProps['relativePitch']=-0.2;}
var isPluralized=(token[0]=='@');if(isPluralized)
token=token.slice(1);var pieces=token.split('+');token=pieces.reduce(function(prev,cur){var lookup=cur;if(cur[0]=='$')
lookup=node[cur.slice(1)];return prev+lookup;}.bind(this),'');var msgId=token;var msgArgs=[];if(!isPluralized){var curArg=tree.firstChild;while(curArg){if(curArg.value[0]!='$'){console.error('Unexpected value: '+curArg.value);return;}
var msgBuff=[];this.format_(node,curArg,msgBuff);msgArgs=msgArgs.concat(msgBuff);curArg=curArg.nextSibling;}}
var msg=Msgs.getMsg(msgId,msgArgs);try{if(this.formatOptions_.braille)
msg=Msgs.getMsg(msgId+'_brl',msgArgs)||msg;}catch(e){}
if(!msg){console.error('Could not get message '+msgId);return;}
if(isPluralized){var arg=tree.firstChild;if(!arg||arg.nextSibling){console.error('Pluralized messages take exactly one argument');return;}
if(arg.value[0]!='$'){console.error('Unexpected value: '+arg.value);return;}
var argBuff=[];this.format_(node,arg,argBuff);var namedArgs={COUNT:Number(argBuff[0])};msg=new goog.i18n.MessageFormat(msg).format(namedArgs);}
this.append_(buff,msg,options);}else if(prefix=='!'){speechProps=new Output.SpeechProperties();speechProps[token]=true;if(tree.firstChild){if(!this.formatOptions_.auralStyle){speechProps=undefined;return;}
var value=tree.firstChild.value;var float=0;if(float=parseFloat(value))
value=float;else
value=parseFloat(node[value])/-10.0;speechProps[token]=value;return;}}
if(speechProps){if(buff.length>0){buff[buff.length-1].setSpan(speechProps,0,0);speechProps=null;}}}.bind(this));},range_:function(range,prevRange,type,rangeBuff){if(!range.start.node||!range.end.node)
return;if(!prevRange&&range.start.node.root)
prevRange=cursors.Range.fromNode(range.start.node.root);var cursor=cursors.Cursor.fromNode(range.start.node);var prevNode=prevRange.start.node;var formatNodeAndAncestors=function(node,prevNode){var buff=[];var outputContextFirst=localStorage['outputContextFirst']=='true';if(outputContextFirst)
this.ancestry_(node,prevNode,type,buff);this.node_(node,prevNode,type,buff);if(!outputContextFirst)
this.ancestry_(node,prevNode,type,buff);if(node.location)
this.locations_.push(node.location);return buff;}.bind(this);while(cursor.node!=range.end.node){var node=cursor.node;rangeBuff.push.apply(rangeBuff,formatNodeAndAncestors(node,prevNode));prevNode=node;cursor=cursor.move(cursors.Unit.NODE,cursors.Movement.DIRECTIONAL,Dir.FORWARD);if(cursor.node==prevNode)
break;}
var lastNode=range.end.node;rangeBuff.push.apply(rangeBuff,formatNodeAndAncestors(lastNode,prevNode));},ancestry_:function(node,prevNode,type,buff){if(Output.ROLE_INFO_[node.role]&&Output.ROLE_INFO_[node.role].ignoreAncestry)
return;var prevUniqueAncestors=AutomationUtil.getUniqueAncestors(node,prevNode);var uniqueAncestors=AutomationUtil.getUniqueAncestors(prevNode,node);var eventBlock=Output.RULES[type]||Output.RULES['navigate'];var getMergedRoleBlock=function(role){var parentRole=(Output.ROLE_INFO_[role]||{}).inherits;var roleBlock=eventBlock[role]||eventBlock['default'];var parentRoleBlock=parentRole?eventBlock[parentRole]:{};var mergedRoleBlock={};for(var key in parentRoleBlock)
mergedRoleBlock[key]=parentRoleBlock[key];for(var key in roleBlock)
mergedRoleBlock[key]=roleBlock[key];return mergedRoleBlock;};var enteredRoleSet={};for(var j=uniqueAncestors.length-2,hashNode;(hashNode=uniqueAncestors[j]);j--)
enteredRoleSet[hashNode.role]=true;for(var i=0,formatPrevNode;(formatPrevNode=prevUniqueAncestors[i]);i++){if(enteredRoleSet[formatPrevNode.role]||localStorage['useVerboseMode']=='false')
continue;var roleBlock=getMergedRoleBlock(formatPrevNode.role);if(roleBlock.leave&&localStorage['useVerboseMode']=='true')
this.format_(formatPrevNode,roleBlock.leave,buff,prevNode);}
var enterOutputs=[];var enterRole={};for(var j=uniqueAncestors.length-2,formatNode;(formatNode=uniqueAncestors[j]);j--){var roleBlock=getMergedRoleBlock(formatNode.role);if(roleBlock.enter){if(enterRole[formatNode.role])
continue;enterRole[formatNode.role]=true;this.format_(formatNode,roleBlock.enter,buff,prevNode);}
if(formatNode.role=='window')
break;}},node_:function(node,prevNode,type,buff){var eventBlock=Output.RULES[type]||Output.RULES['navigate'];var roleBlock=eventBlock[node.role]||{};var parentRole=(Output.ROLE_INFO_[node.role]||{}).inherits;var parentRoleBlock=eventBlock[parentRole||'']||{};var speakFormat=roleBlock.speak||parentRoleBlock.speak||eventBlock['default'].speak;this.format_(node,speakFormat,buff,prevNode);},subNode_:function(range,prevRange,type,buff){if(!prevRange)
prevRange=range;var dir=cursors.Range.getDirection(prevRange,range);var node=range.start.node;var prevNode=prevRange.getBound(dir).node;if(!node||!prevNode)
return;var options={annotation:['name'],isUnique:true};var startIndex=range.start.index;var endIndex=range.end.index;if(this.formatOptions_.braille){options.annotation.push(new Output.NodeSpan(node));var selStart=node.textSelStart;var selEnd=node.textSelEnd;if(selStart!==undefined&&(selEnd>=startIndex&&selStart<=endIndex)){options.annotation.push(new Output.SelectionSpan(selStart-startIndex,selEnd-startIndex,startIndex));}}
var outputContextFirst=localStorage['outputContextFirst']=='true';if(outputContextFirst)
this.ancestry_(node,prevNode,type,buff);var earcon=this.findEarcon_(node,prevNode);if(earcon)
options.annotation.push(earcon);this.append_(buff,range.start.getText().substring(startIndex,endIndex),options);if(!outputContextFirst)
this.ancestry_(node,prevNode,type,buff);var loc=range.start.node.boundsForRange(startIndex,endIndex);if(loc)
this.locations_.push(loc);},append_:function(buff,value,opt_options){opt_options=opt_options||{isUnique:false,annotation:[]};if((!value||value.length==0)&&opt_options.annotation.every(function(a){return!(a instanceof Output.Action)&&!(a instanceof Output.SelectionSpan);}))
return;var spannableToAdd=new Spannable(value);opt_options.annotation.forEach(function(a){spannableToAdd.setSpan(a,0,spannableToAdd.length);});if(opt_options.isUnique){var annotationSansNodes=opt_options.annotation.filter(function(annotation){return!(annotation instanceof Output.NodeSpan);});var alreadyAnnotated=buff.some(function(s){return annotationSansNodes.some(function(annotation){if(!s.hasSpan(annotation))
return false;var start=s.getSpanStart(annotation);var end=s.getSpanEnd(annotation);var substr=s.substring(start,end);if(substr&&value)
return substr.toString()==value.toString();else
return false;});});if(alreadyAnnotated)
return;}
buff.push(spannableToAdd);},createParseTree_:function(inputStr){var root={value:''};var currentNode=root;var index=0;var braceNesting=0;while(index<inputStr.length){if(inputStr[index]=='('){currentNode.firstChild={value:''};currentNode.firstChild.parent=currentNode;currentNode=currentNode.firstChild;}else if(inputStr[index]==')'){currentNode=currentNode.parent;}else if(inputStr[index]=='{'){braceNesting++;currentNode.value+=inputStr[index];}else if(inputStr[index]=='}'){braceNesting--;currentNode.value+=inputStr[index];}else if(inputStr[index]==','&&braceNesting===0){currentNode.nextSibling={value:''};currentNode.nextSibling.parent=currentNode.parent;currentNode=currentNode.nextSibling;}else{currentNode.value+=inputStr[index];}
index++;}
if(currentNode!=root)
throw'Unbalanced parenthesis: '+inputStr;return root;},createBrailleOutput_:function(){var result=new Spannable();var separator='';this.brailleBuffer_.forEach(function(cur){if(cur.length==0&&!cur.getSpanInstanceOf(Output.SelectionSpan))
return;var spansToExtend=[];var spansToRemove=[];result.getSpansInstanceOf(Output.NodeSpan).forEach(function(leftSpan){if(result.getSpanEnd(leftSpan)<result.length)
return;var newEnd=result.length;cur.getSpansInstanceOf(Output.NodeSpan).forEach(function(rightSpan){if(cur.getSpanStart(rightSpan)==0&&leftSpan.node===rightSpan.node){newEnd=Math.max(newEnd,result.length+separator.length+cur.getSpanEnd(rightSpan));spansToRemove.push(rightSpan);}});if(newEnd>result.length)
spansToExtend.push({span:leftSpan,end:newEnd});});result.append(separator);result.append(cur);spansToExtend.forEach(function(elem){result.setSpan(elem.span,result.getSpanStart(elem.span),elem.end);});spansToRemove.forEach(result.removeSpan.bind(result));separator=Output.SPACE;});return result;},findEarcon_:function(node,opt_prevNode){if(node===opt_prevNode)
return null;if(this.formatOptions_.speech){var earconFinder=node;var ancestors;if(opt_prevNode)
ancestors=AutomationUtil.getUniqueAncestors(opt_prevNode,node);else
ancestors=AutomationUtil.getAncestors(node);while(earconFinder=ancestors.pop()){var info=Output.ROLE_INFO_[earconFinder.role];if(info&&info.earconId){return new Output.EarconAction(info.earconId);break;}
earconFinder=earconFinder.parent;}}
return null;}};});goog.provide('PanelCommand');goog.provide('PanelCommandType');PanelCommand=function(type,opt_data){this.type=type;this.data=opt_data;};PanelCommand.prototype.send=function(){var views=chrome.extension.getViews();for(var i=0;i<views.length;i++){if(views[i].location.href.indexOf('background/panel.html')>0){views[i].postMessage(JSON.stringify(this),window.location.origin);}}};PanelCommandType={CLEAR_SPEECH:'clear_speech',ADD_NORMAL_SPEECH:'add_normal_speech',ADD_ANNOTATION_SPEECH:'add_annotation_speech',UPDATE_BRAILLE:'update_braille',OPEN_MENUS:'open_menus',ENABLE_MENUS:'enable_menus',DISABLE_MENUS:'disable_menus',SEARCH:'search',};goog.provide('cvox.BrailleDisplayState');goog.provide('cvox.BrailleKeyCommand');goog.provide('cvox.BrailleKeyEvent');cvox.BrailleKeyCommand={PAN_LEFT:'pan_left',PAN_RIGHT:'pan_right',LINE_UP:'line_up',LINE_DOWN:'line_down',TOP:'top',BOTTOM:'bottom',ROUTING:'routing',SECONDARY_ROUTING:'secondary_routing',DOTS:'dots',STANDARD_KEY:'standard_key'};cvox.BrailleKeyEvent={};cvox.BrailleKeyEvent.keyCodeToLegacyCode=function(code){return cvox.BrailleKeyEvent.legacyKeyCodeMap_[code];};cvox.BrailleKeyEvent.keyCodeToCharValue=function(keyCode){var SPECIAL_CODES={'Backspace':0x08,'Tab':0x09,'Enter':0x0A};return SPECIAL_CODES[keyCode]||keyCode.charCodeAt(0);};cvox.BrailleKeyEvent.legacyKeyCodeMap_={'Backspace':8,'Tab':9,'Enter':13,'Escape':27,'Home':36,'ArrowLeft':37,'ArrowUp':38,'ArrowRight':39,'ArrowDown':40,'PageUp':33,'PageDown':34,'End':35,'Insert':45,'Delete':46};(function(){for(var i=0;i<12;++i){cvox.BrailleKeyEvent.legacyKeyCodeMap_['F'+(i+1)]=112+i;}})();cvox.BrailleDisplayState;goog.provide('Msgs');Msgs=function(){};Msgs.NAMESPACE_='chromevox_';Msgs.getLocale=function(){return chrome.i18n.getMessage('locale');};Msgs.getMsg=function(messageId,opt_subs){var message=Msgs.Untranslated[messageId.toUpperCase()];if(message!==undefined)
return Msgs.applySubstitutions_(message,opt_subs);message=chrome.i18n.getMessage(Msgs.NAMESPACE_+messageId,opt_subs);if(message==undefined||message==''){throw new Error('Invalid ChromeVox message id: '+messageId);}
return message;};Msgs.addTranslatedMessagesToDom=function(root){var elts=root.querySelectorAll('.i18n');for(var i=0;i<elts.length;i++){var msgid=elts[i].getAttribute('msgid');if(!msgid){throw new Error('Element has no msgid attribute: '+elts[i]);}
var val=this.getMsg(msgid);if(elts[i].tagName=='INPUT'){elts[i].setAttribute('placeholder',val);}else{elts[i].textContent=val;}
elts[i].classList.add('i18n-processed');}};Msgs.getNumber=function(num){return''+num;};Msgs.applySubstitutions_=function(message,opt_subs){if(opt_subs){for(var i=0;i<opt_subs.length;i++){message=message.replace('$'+(i+1),opt_subs[i]);}}
return message;};Msgs.Untranslated={CHECKBOX_UNCHECKED_STATE_BRL:'( )',CHECKBOX_CHECKED_STATE_BRL:'(x)',RADIO_UNSELECTED_STATE_BRL:'( )',RADIO_SELECTED_STATE_BRL:'(x)',ARIA_HAS_SUBMENU_BRL:'->',ROLE_OPTION:' ',ROLE_OPTION_BRL:' ',ARIA_CHECKED_TRUE_BRL:'(x)',ARIA_CHECKED_FALSE_BRL:'( )',ARIA_CHECKED_MIXED_BRL:'(-)',ARIA_DISABLED_TRUE_BRL:'xx',ARIA_EXPANDED_TRUE_BRL:'-',ARIA_EXPANDED_FALSE_BRL:'+',ARIA_INVALID_TRUE_BRL:'!',ARIA_PRESSED_TRUE_BRL:'=',ARIA_PRESSED_FALSE_BRL:' ',ARIA_PRESSED_MIXED_BRL:'-',ARIA_SELECTED_TRUE_BRL:'(x)',ARIA_SELECTED_FALSE_BRL:'( )',HAS_SUBMENU_BRL:'->',TAG_TIME_BRL:' ',ARIA_VALUE_NOW:'$1',ARIA_VALUE_NOW_BRL:'$1',ARIA_VALUE_TEXT:'$1',ARIA_VALUE_TEXT_BRL:'$1',};goog.provide('cvox.ChromeVoxJSON');if(!cvox.ChromeVoxJSON){cvox.ChromeVoxJSON={};}
if(window.JSON&&window.JSON.toString()=='[object JSON]'){cvox.ChromeVoxJSON=window.JSON;}else{(function(){function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z':'null';};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return(this.valueOf());};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof cvox.ChromeVoxJSON.stringify!=='function'){cvox.ChromeVoxJSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof cvox.ChromeVoxJSON.parse!=='function'){cvox.ChromeVoxJSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}}());}
goog.provide('cvox.ExtensionBridge');goog.require('cvox.ChromeVoxJSON');cvox.ExtensionBridge=function(){};cvox.ExtensionBridge.init=function(){var self=cvox.ExtensionBridge;self.messageListeners=[];self.disconnectListeners=[];if(/^chrome-extension:\/\/.*background\.html$/.test(window.location.href)){self.context=self.BACKGROUND;self.initBackground();return;}
if(chrome&&chrome.extension){self.context=self.CONTENT_SCRIPT;self.initContentScript();}};cvox.ExtensionBridge.BACKGROUND=0;cvox.ExtensionBridge.CONTENT_SCRIPT=1;cvox.ExtensionBridge.PORT_NAME='cvox.ExtensionBridge.Port';cvox.ExtensionBridge.PING_MSG='cvox.ExtensionBridge.Ping';cvox.ExtensionBridge.PONG_MSG='cvox.ExtensionBridge.Pong';cvox.ExtensionBridge.send=function(message){var self=cvox.ExtensionBridge;switch(self.context){case self.BACKGROUND:self.sendBackgroundToContentScript(message);break;case self.CONTENT_SCRIPT:self.sendContentScriptToBackground(message);break;}};cvox.ExtensionBridge.addMessageListener=function(listener){cvox.ExtensionBridge.messageListeners.push(listener);};cvox.ExtensionBridge.addDisconnectListener=function(listener){cvox.ExtensionBridge.disconnectListeners.push(listener);};cvox.ExtensionBridge.removeMessageListeners=function(){cvox.ExtensionBridge.messageListeners.length=0;};cvox.ExtensionBridge.uniqueId=function(){return cvox.ExtensionBridge.id_;};cvox.ExtensionBridge.initBackground=function(){var self=cvox.ExtensionBridge;self.portCache_=[];self.nextPongId_=1;self.id_=0;var onConnectHandler=function(port){if(port.name!=self.PORT_NAME){return;}
self.portCache_.push(port);port.onMessage.addListener(function(message){if(message[cvox.ExtensionBridge.PING_MSG]){var pongMessage={};pongMessage[cvox.ExtensionBridge.PONG_MSG]=self.nextPongId_++;port.postMessage(pongMessage);return;}
for(var i=0;i<self.messageListeners.length;i++){self.messageListeners[i](message,port);}});port.onDisconnect.addListener(function(message){for(var i=0;i<self.portCache_.length;i++){if(self.portCache_[i]==port){self.portCache_.splice(i,1);break;}}});};chrome.extension.onConnect.addListener(onConnectHandler);};cvox.ExtensionBridge.initContentScript=function(){var self=cvox.ExtensionBridge;self.connected=false;self.pingAttempts=0;self.queuedMessages=[];self.id_=-1;var onMessageHandler=function(request,sender,sendResponse){if(request&&request['srcFile']){return;}
if(request[cvox.ExtensionBridge.PONG_MSG]){self.gotPongFromBackgroundPage(request[cvox.ExtensionBridge.PONG_MSG]);}else{for(var i=0;i<self.messageListeners.length;i++){self.messageListeners[i](request,cvox.ExtensionBridge.backgroundPort);}}
sendResponse({});};chrome.extension.onMessage.addListener(onMessageHandler);self.setupBackgroundPort();self.tryToPingBackgroundPage();};cvox.ExtensionBridge.setupBackgroundPort=function(){var self=cvox.ExtensionBridge;self.backgroundPort=chrome.extension.connect({name:self.PORT_NAME});if(!self.backgroundPort){return;}
self.backgroundPort.onMessage.addListener(function(message){if(message[cvox.ExtensionBridge.PONG_MSG]){self.gotPongFromBackgroundPage(message[cvox.ExtensionBridge.PONG_MSG]);}else{for(var i=0;i<self.messageListeners.length;i++){self.messageListeners[i](message,self.backgroundPort);}}});self.backgroundPort.onDisconnect.addListener(function(event){if(!self.connected){self.backgroundPort=null;return;}
for(var i=0;i<self.disconnectListeners.length;i++){self.disconnectListeners[i]();}});};cvox.ExtensionBridge.tryToPingBackgroundPage=function(){var self=cvox.ExtensionBridge;if(self.connected){return;}
self.pingAttempts++;if(self.pingAttempts>5){for(var i=0;i<self.disconnectListeners.length;i++){self.disconnectListeners[i]();}
return;}
var msg={};msg[cvox.ExtensionBridge.PING_MSG]=1;if(!self.backgroundPort){self.setupBackgroundPort();}
if(self.backgroundPort){self.backgroundPort.postMessage(msg);}
window.setTimeout(cvox.ExtensionBridge.tryToPingBackgroundPage,500);};cvox.ExtensionBridge.gotPongFromBackgroundPage=function(pongId){var self=cvox.ExtensionBridge;self.connected=true;self.id_=pongId;while(self.queuedMessages.length>0){self.sendContentScriptToBackground(self.queuedMessages.shift());}};cvox.ExtensionBridge.sendContentScriptToBackground=function(message){var self=cvox.ExtensionBridge;if(!self.connected){self.queuedMessages.push(message);return;}
if(cvox.ExtensionBridge.backgroundPort){cvox.ExtensionBridge.backgroundPort.postMessage(message);}else{chrome.extension.sendMessage(message);}};cvox.ExtensionBridge.sendBackgroundToContentScript=function(message){cvox.ExtensionBridge.portCache_.forEach(function(port){port.postMessage(message);});};cvox.ExtensionBridge.init();goog.provide('cvox.BrailleCaptionsBackground');goog.require('PanelCommand');goog.require('cvox.BrailleDisplayState');goog.require('cvox.ExtensionBridge');cvox.BrailleCaptionsBackground.PREF_KEY='brailleCaptions';cvox.BrailleCaptionsBackground.BRAILLE_UNICODE_BLOCK_START=0x2800;cvox.BrailleCaptionsBackground.init=function(stateCallback){var self=cvox.BrailleCaptionsBackground;self.stateCallback_=stateCallback;};cvox.BrailleCaptionsBackground.isEnabled=function(){var self=cvox.BrailleCaptionsBackground;return localStorage[self.PREF_KEY]===String(true);};cvox.BrailleCaptionsBackground.setContent=function(text,cells){var self=cvox.BrailleCaptionsBackground;var byteBuf=new Uint8Array(cells);var brailleChars='';for(var i=0;i<byteBuf.length;++i){brailleChars+=String.fromCharCode(self.BRAILLE_UNICODE_BLOCK_START|byteBuf[i]);}
if(cvox.ChromeVox.isChromeOS){var data={text:text,braille:brailleChars};(new PanelCommand(PanelCommandType.UPDATE_BRAILLE,data)).send();}else{cvox.ExtensionBridge.send({message:'BRAILLE_CAPTION',text:text,brailleChars:brailleChars});}};cvox.BrailleCaptionsBackground.setActive=function(newValue){var self=cvox.BrailleCaptionsBackground;var oldValue=self.isEnabled();window['prefs'].setPref(self.PREF_KEY,String(newValue));if(oldValue!=newValue){if(self.stateCallback_){self.stateCallback_();}
var msg=newValue?Msgs.getMsg('braille_captions_enabled'):Msgs.getMsg('braille_captions_disabled');cvox.ChromeVox.tts.speak(msg,cvox.QueueMode.QUEUE);cvox.ChromeVox.braille.write(cvox.NavBraille.fromText(msg));}};cvox.BrailleCaptionsBackground.getVirtualDisplayState=function(){var self=cvox.BrailleCaptionsBackground;if(self.isEnabled()){return{available:true,textCellCount:40};}else{return{available:false};}};goog.provide('cvox.LibLouis');cvox.LibLouis=function(nmfPath,opt_tablesDir){this.nmfPath_=nmfPath;this.tablesDir_=goog.isDef(opt_tablesDir)?opt_tablesDir:null;this.embedElement_=null;this.pendingRpcCallbacks_={};this.nextMessageId_=1;};cvox.LibLouis.DEBUG=false;cvox.LibLouis.prototype.attachToElement=function(elem){if(this.isAttached()){throw Error('Instance already attached');}
var embed=document.createElement('embed');embed.src=this.nmfPath_;embed.type='application/x-nacl';embed.width=0;embed.height=0;if(!goog.isNull(this.tablesDir_)){embed.setAttribute('tablesdir',this.tablesDir_);}
embed.addEventListener('load',goog.bind(this.onInstanceLoad_,this),false);embed.addEventListener('error',goog.bind(this.onInstanceError_,this),false);embed.addEventListener('message',goog.bind(this.onInstanceMessage_,this),false);elem.appendChild(embed);this.embedElement_=(embed);};cvox.LibLouis.prototype.detach=function(){if(!this.isAttached()){throw Error('cannot detach unattached instance');}
this.embedElement_.parentNode.removeChild(this.embedElement_);this.embedElement_=null;for(var id in this.pendingRpcCallbacks_){this.pendingRpcCallbacks_[id]({});}
this.pendingRpcCallbacks_={};};cvox.LibLouis.prototype.isAttached=function(){return this.embedElement_!==null;};cvox.LibLouis.prototype.getTranslator=function(tableNames,callback){if(!this.isAttached()){callback(null);return;}
this.rpc_('CheckTable',{'table_names':tableNames},function(reply){if(reply['success']){var translator=new cvox.LibLouis.Translator(this,tableNames);callback(translator);}else{callback(null);}}.bind(this));};cvox.LibLouis.prototype.rpc_=function(command,message,callback){if(!this.isAttached()){throw Error('Cannot send RPC: liblouis instance not loaded');}
var messageId=''+this.nextMessageId_++;message['message_id']=messageId;message['command']=command;var json=JSON.stringify(message);if(cvox.LibLouis.DEBUG){window.console.debug('RPC -> '+json);}
this.embedElement_.postMessage(json);this.pendingRpcCallbacks_[messageId]=callback;};cvox.LibLouis.prototype.onInstanceLoad_=function(e){window.console.info('loaded liblouis Native Client instance');};cvox.LibLouis.prototype.onInstanceError_=function(e){window.console.error('failed to load liblouis Native Client instance');this.detach();};cvox.LibLouis.prototype.onInstanceMessage_=function(e){if(cvox.LibLouis.DEBUG){window.console.debug('RPC <- '+e.data);}
var message=(JSON.parse(e.data));var messageId=message['in_reply_to'];if(!goog.isDef(messageId)){window.console.warn('liblouis Native Client module sent message with no ID',message);return;}
if(goog.isDef(message['error'])){window.console.error('liblouis Native Client error',message['error']);}
var callback=this.pendingRpcCallbacks_[messageId];if(goog.isDef(callback)){delete this.pendingRpcCallbacks_[messageId];callback(message);}};cvox.LibLouis.Translator=function(instance,tableNames){this.instance_=instance;this.tableNames_=tableNames;};cvox.LibLouis.Translator.prototype.translate=function(text,callback){if(!this.instance_.isAttached()){callback(null,null,null);return;}
var message={'table_names':this.tableNames_,'text':text};this.instance_.rpc_('Translate',message,function(reply){var cells=null;var textToBraille=null;var brailleToText=null;if(reply['success']&&goog.isString(reply['cells'])){cells=cvox.LibLouis.Translator.decodeHexString_(reply['cells']);if(goog.isDef(reply['text_to_braille'])){textToBraille=reply['text_to_braille'];}
if(goog.isDef(reply['braille_to_text'])){brailleToText=reply['braille_to_text'];}}else if(text.length>0){console.error('Braille translation error for '+JSON.stringify(message));}
callback(cells,textToBraille,brailleToText);});};cvox.LibLouis.Translator.prototype.backTranslate=function(cells,callback){if(!this.instance_.isAttached()){callback(null);return;}
if(cells.byteLength==0){callback('');return;}
var message={'table_names':this.tableNames_,'cells':cvox.LibLouis.Translator.encodeHexString_(cells)};this.instance_.rpc_('BackTranslate',message,function(reply){if(reply['success']&&goog.isString(reply['text'])){callback(reply['text']);}else{callback(null);}});};cvox.LibLouis.Translator.decodeHexString_=function(hex){if(!/^([0-9a-f]{2})*$/i.test(hex)){throw Error('invalid hexadecimal string');}
var array=new Uint8Array(hex.length/2);var idx=0;for(var i=0;i<hex.length;i+=2){array[idx++]=parseInt(hex.substring(i,i+2),16);}
return array.buffer;};cvox.LibLouis.Translator.encodeHexString_=function(arrayBuffer){var array=new Uint8Array(arrayBuffer);var hex='';for(var i=0;i<array.length;i++){var b=array[i];hex+=(b<0x10?'0':'')+b.toString(16);}
return hex;};goog.provide('cvox.ExpandingBrailleTranslator');goog.require('Spannable');goog.require('cvox.ExtraCellsSpan');goog.require('cvox.LibLouis');goog.require('cvox.ValueSelectionSpan');goog.require('cvox.ValueSpan');cvox.ExpandingBrailleTranslator=function(defaultTranslator,opt_uncontractedTranslator){this.defaultTranslator_=defaultTranslator;this.uncontractedTranslator_=opt_uncontractedTranslator||null;};cvox.ExpandingBrailleTranslator.ExpansionType={NONE:0,SELECTION:1,ALL:2};cvox.ExpandingBrailleTranslator.prototype.translate=function(text,expansionType,callback){var expandRanges=this.findExpandRanges_(text,expansionType);var extraCellsSpans=text.getSpansInstanceOf(cvox.ExtraCellsSpan).filter(function(span){return span.cells.byteLength>0;});var extraCellsPositions=extraCellsSpans.map(function(span){return text.getSpanStart(span);});if(expandRanges.length==0&&extraCellsSpans.length==0){this.defaultTranslator_.translate(text.toString(),cvox.ExpandingBrailleTranslator.nullParamsToEmptyAdapter_(text.length,callback));return;}
var chunks=[];function maybeAddChunkToTranslate(translator,start,end){if(start<end)
chunks.push({translator:translator,start:start,end:end});}
function addExtraCellsChunk(pos,cells){var chunk={translator:null,start:pos,end:pos,cells:cells,textToBraille:[],brailleToText:new Array(cells.byteLength)};for(var i=0;i<cells.byteLength;++i)
chunk.brailleToText[i]=0;chunks.push(chunk);}
function addChunk(translator,start,end){while(extraCellsSpans.length>0&&extraCellsPositions[0]<=end){maybeAddChunkToTranslate(translator,start,extraCellsPositions[0]);start=extraCellsPositions.shift();addExtraCellsChunk(start,extraCellsSpans.shift().cells);}
maybeAddChunkToTranslate(translator,start,end);}
var lastEnd=0;for(var i=0;i<expandRanges.length;++i){var range=expandRanges[i];if(lastEnd<range.start){addChunk(this.defaultTranslator_,lastEnd,range.start);}
addChunk(this.uncontractedTranslator_,range.start,range.end);lastEnd=range.end;}
addChunk(this.defaultTranslator_,lastEnd,text.length);var chunksToTranslate=chunks.filter(function(chunk){return chunk.translator;});var numPendingCallbacks=chunksToTranslate.length;function chunkTranslated(chunk,cells,textToBraille,brailleToText){chunk.cells=cells;chunk.textToBraille=textToBraille;chunk.brailleToText=brailleToText;if(--numPendingCallbacks<=0)
finish();}
function finish(){var totalCells=chunks.reduce(function(accum,chunk){return accum+chunk.cells.byteLength},0);var cells=new Uint8Array(totalCells);var cellPos=0;var textToBraille=[];var brailleToText=[];function appendAdjusted(array,toAppend,adjustment){array.push.apply(array,toAppend.map(function(elem){return adjustment+elem;}));}
for(var i=0,chunk;chunk=chunks[i];++i){cells.set(new Uint8Array(chunk.cells),cellPos);appendAdjusted(textToBraille,chunk.textToBraille,cellPos);appendAdjusted(brailleToText,chunk.brailleToText,chunk.start);cellPos+=chunk.cells.byteLength;}
callback(cells.buffer,textToBraille,brailleToText);}
if(chunksToTranslate.length>0){chunksToTranslate.forEach(function(chunk){chunk.translator.translate(text.toString().substring(chunk.start,chunk.end),cvox.ExpandingBrailleTranslator.nullParamsToEmptyAdapter_(chunk.end-chunk.start,goog.partial(chunkTranslated,chunk)));});}else{finish();}};cvox.ExpandingBrailleTranslator.rangeForPosition_=function(str,pos,start,end){if(start<0||end>str.length){throw RangeError('End-points out of range looking for braille expansion range');}
if(pos<start||pos>=end){throw RangeError('Position out of range looking for braille expansion range');}
start=str.substring(start,pos+1).search(/(\s+|\S+)$/)+start;end=pos+/^(\s+|\S+)/.exec(str.substring(pos,end))[0].length;return{start:start,end:end};};cvox.ExpandingBrailleTranslator.prototype.findExpandRanges_=function(text,expansionType){var result=[];if(this.uncontractedTranslator_&&expansionType!=cvox.ExpandingBrailleTranslator.ExpansionType.NONE){var value=text.getSpanInstanceOf(cvox.ValueSpan);if(value){var valueStart=text.getSpanStart(value);var valueEnd=text.getSpanEnd(value);switch(expansionType){case cvox.ExpandingBrailleTranslator.ExpansionType.SELECTION:this.addRangesForSelection_(text,valueStart,valueEnd,result);break;case cvox.ExpandingBrailleTranslator.ExpansionType.ALL:result.push({start:valueStart,end:valueEnd});break;}}}
return result;};cvox.ExpandingBrailleTranslator.prototype.addRangesForSelection_=function(text,valueStart,valueEnd,outRanges){var selection=text.getSpanInstanceOf(cvox.ValueSelectionSpan);if(!selection){return;}
var selectionStart=text.getSpanStart(selection);var selectionEnd=text.getSpanEnd(selection);if(selectionStart<valueStart||selectionEnd>valueEnd){return;}
var expandPositions=[];if(selectionStart==valueEnd){if(selectionStart>valueStart){expandPositions.push(selectionStart-1);}}else{if(selectionStart==selectionEnd&&selectionStart>valueStart){expandPositions.push(selectionStart-1);}
expandPositions.push(selectionStart);if(selectionEnd>selectionStart+1){expandPositions.push(selectionEnd-1);}}
var lastRange=outRanges[outRanges.length-1]||null;for(var i=0;i<expandPositions.length;++i){var range=cvox.ExpandingBrailleTranslator.rangeForPosition_(text.toString(),expandPositions[i],valueStart,valueEnd);if(lastRange&&lastRange.end>=range.start){lastRange.end=range.end;}else{outRanges.push(range);lastRange=range;}}};cvox.ExpandingBrailleTranslator.nullParamsToEmptyAdapter_=function(inputLength,callback){return function(cells,textToBraille,brailleToText){if(!textToBraille){textToBraille=new Array(inputLength);for(var i=0;i<inputLength;++i){textToBraille[i]=0;}}
callback(cells||new ArrayBuffer(0),textToBraille,brailleToText||[]);};};cvox.ExpandingBrailleTranslator.Range_;goog.provide('cvox.PanStrategy');cvox.PanStrategy=function(){this.displaySize_=0;this.contentLength_=0;this.breakPoints_=[];this.viewPort_={start:0,end:0};};cvox.PanStrategy.Range;cvox.PanStrategy.prototype={get viewPort(){return this.viewPort_;},setDisplaySize:function(size){this.displaySize_=size;this.panToPosition_(this.viewPort_.start);},setContent:function(translatedContent,targetPosition){this.breakPoints_=this.calculateBreakPoints_(translatedContent);this.contentLength_=translatedContent.byteLength;this.panToPosition_(targetPosition);},next:function(){var newStart=this.viewPort_.end;var newEnd;if(newStart+this.displaySize_<this.contentLength_){newEnd=this.extendRight_(newStart);}else{newEnd=this.contentLength_;}
if(newEnd>newStart){this.viewPort_={start:newStart,end:newEnd};return true;}
return false;},previous:function(){if(this.viewPort_.start>0){var newStart,newEnd;if(this.viewPort_.start<=this.displaySize_){newStart=0;newEnd=this.extendRight_(newStart);}else{newEnd=this.viewPort_.start;var limit=newEnd-this.displaySize_;newStart=limit;var pos=0;while(pos<this.breakPoints_.length&&this.breakPoints_[pos]<limit){pos++;}
if(pos<this.breakPoints_.length&&this.breakPoints_[pos]<newEnd){newStart=this.breakPoints_[pos];}}
if(newStart<newEnd){this.viewPort_={start:newStart,end:newEnd};return true;}}
return false;},extendRight_:function(from){var limit=Math.min(from+this.displaySize_,this.contentLength_);var pos=0;var result=limit;while(pos<this.breakPoints_.length&&this.breakPoints_[pos]<=from){pos++;}
while(pos<this.breakPoints_.length&&this.breakPoints_[pos]<=limit){result=this.breakPoints_[pos];pos++;}
return result;},calculateBreakPoints_:function(content){return[];},panToPosition_:function(position){if(this.displaySize_>0){this.viewPort_={start:0,end:0};while(this.next()&&this.viewPort_.end<=position){}}else{this.viewPort_={start:position,end:position};}},};cvox.FixedPanStrategy=cvox.PanStrategy;cvox.WrappingPanStrategy=function(){cvox.PanStrategy.call(this);};cvox.WrappingPanStrategy.prototype={__proto__:cvox.PanStrategy.prototype,calculateBreakPoints_:function(content){var view=new Uint8Array(content);var newContentLength=view.length;var result=[];var lastCellWasBlank=false;for(var pos=0;pos<view.length;++pos){if(lastCellWasBlank&&view[pos]!=0){result.push(pos);}
lastCellWasBlank=(view[pos]==0);}
return result;},};goog.provide('cvox.BrailleDisplayManager');goog.require('cvox.BrailleCaptionsBackground');goog.require('cvox.BrailleDisplayState');goog.require('cvox.ExpandingBrailleTranslator');goog.require('cvox.LibLouis');goog.require('cvox.NavBraille');goog.require('cvox.PanStrategy');cvox.BrailleDisplayManager=function(translatorManager){this.translatorManager_=translatorManager;this.content_=new cvox.NavBraille({});this.expansionType_=cvox.ExpandingBrailleTranslator.ExpansionType.SELECTION;this.translatedContent_=new ArrayBuffer(0);this.displayedContent_=this.translatedContent_;this.panStrategy_=new cvox.WrappingPanStrategy();this.commandListener_=function(){};this.displayState_={available:false,textCellCount:undefined};this.realDisplayState_=this.displayState_;this.textToBraille_=[];this.brailleToText_=[];translatorManager.addChangeListener(function(){this.translateContent_(this.content_,this.expansionType_);}.bind(this));chrome.storage.onChanged.addListener(function(changes,area){if(area=='local'&&'brailleWordWrap'in changes){this.updatePanStrategy_(changes.brailleWordWrap.newValue);}}.bind(this));chrome.storage.local.get({brailleWordWrap:true},function(items){this.updatePanStrategy_(items.brailleWordWrap);}.bind(this));cvox.BrailleCaptionsBackground.init(goog.bind(this.onCaptionsStateChanged_,this));if(goog.isDef(chrome.brailleDisplayPrivate)){var onDisplayStateChanged=goog.bind(this.refreshDisplayState_,this);chrome.brailleDisplayPrivate.getDisplayState(onDisplayStateChanged);chrome.brailleDisplayPrivate.onDisplayStateChanged.addListener(onDisplayStateChanged);chrome.brailleDisplayPrivate.onKeyEvent.addListener(goog.bind(this.onKeyEvent_,this));}else{this.onCaptionsStateChanged_();}};cvox.BrailleDisplayManager.CURSOR_DOTS_=1<<6|1<<7;cvox.BrailleDisplayManager.prototype.setContent=function(content,expansionType){this.translateContent_(content,expansionType);};cvox.BrailleDisplayManager.prototype.setCommandListener=function(func){this.commandListener_=func;};cvox.BrailleDisplayManager.prototype.refreshDisplayState_=function(newState){var oldSize=this.displayState_.textCellCount||0;this.realDisplayState_=newState;if(newState.available){this.displayState_=newState;}else{this.displayState_=cvox.BrailleCaptionsBackground.getVirtualDisplayState();}
var newSize=this.displayState_.textCellCount||0;if(oldSize!=newSize){this.panStrategy_.setDisplaySize(newSize);}
this.refresh_();};cvox.BrailleDisplayManager.prototype.onCaptionsStateChanged_=function(){this.refreshDisplayState_(this.realDisplayState_);};cvox.BrailleDisplayManager.prototype.refresh_=function(){if(!this.displayState_.available){return;}
var viewPort=this.panStrategy_.viewPort;var buf=this.displayedContent_.slice(viewPort.start,viewPort.end);if(this.realDisplayState_.available){chrome.brailleDisplayPrivate.writeDots(buf);}
if(cvox.BrailleCaptionsBackground.isEnabled()){var start=this.brailleToTextPosition_(viewPort.start);var end=this.brailleToTextPosition_(viewPort.end);cvox.BrailleCaptionsBackground.setContent(this.content_.text.toString().substring(start,end),buf);}};cvox.BrailleDisplayManager.prototype.translateContent_=function(newContent,newExpansionType){var writeTranslatedContent=function(cells,textToBraille,brailleToText){this.content_=newContent;this.expansionType_=newExpansionType;this.textToBraille_=textToBraille;this.brailleToText_=brailleToText;var startIndex=this.content_.startIndex;var endIndex=this.content_.endIndex;var targetPosition;if(startIndex>=0){var translatedStartIndex;var translatedEndIndex;if(startIndex>=textToBraille.length){var extCells=new ArrayBuffer(cells.byteLength+1);new Uint8Array(extCells).set(new Uint8Array(cells));cells=extCells;translatedStartIndex=cells.byteLength-1;}else{translatedStartIndex=textToBraille[startIndex];}
if(endIndex>=textToBraille.length){translatedEndIndex=cells.byteLength;}else{translatedEndIndex=textToBraille[endIndex];}
this.translatedContent_=cells;this.displayedContent_=new ArrayBuffer(cells.byteLength);new Uint8Array(this.displayedContent_).set(new Uint8Array(cells));this.writeCursor_(this.displayedContent_,translatedStartIndex,translatedEndIndex);targetPosition=translatedStartIndex;}else{this.translatedContent_=this.displayedContent_=cells;targetPosition=0;}
this.panStrategy_.setContent(this.translatedContent_,targetPosition);this.refresh_();}.bind(this);var translator=this.translatorManager_.getExpandingTranslator();if(!translator){writeTranslatedContent(new ArrayBuffer(0),[],[]);}else{translator.translate(newContent.text,newExpansionType,writeTranslatedContent);}};cvox.BrailleDisplayManager.prototype.onKeyEvent_=function(event){switch(event.command){case cvox.BrailleKeyCommand.PAN_LEFT:this.panLeft_();break;case cvox.BrailleKeyCommand.PAN_RIGHT:this.panRight_();break;case cvox.BrailleKeyCommand.ROUTING:event.displayPosition=this.brailleToTextPosition_(event.displayPosition+this.panStrategy_.viewPort.start);default:this.commandListener_(event,this.content_);break;}};cvox.BrailleDisplayManager.prototype.panLeft_=function(){if(this.panStrategy_.previous()){this.refresh_();}else{this.commandListener_({command:cvox.BrailleKeyCommand.PAN_LEFT},this.content_);}};cvox.BrailleDisplayManager.prototype.panRight_=function(){if(this.panStrategy_.next()){this.refresh_();}else{this.commandListener_({command:cvox.BrailleKeyCommand.PAN_RIGHT},this.content_);}};cvox.BrailleDisplayManager.prototype.writeCursor_=function(buffer,startIndex,endIndex){if(startIndex<0||startIndex>=buffer.byteLength||endIndex<startIndex||endIndex>buffer.byteLength){return;}
if(startIndex==endIndex){endIndex=startIndex+1;}
var dataView=new DataView(buffer);while(startIndex<endIndex){var value=dataView.getUint8(startIndex);value|=cvox.BrailleDisplayManager.CURSOR_DOTS_;dataView.setUint8(startIndex,value);startIndex++;}};cvox.BrailleDisplayManager.prototype.brailleToTextPosition_=function(braillePosition){var mapping=this.brailleToText_;if(braillePosition<0){console.error('WARNING: Braille position < 0: '+braillePosition);return 0;}else if(braillePosition>=mapping.length){return this.content_.text.length;}else{return mapping[braillePosition];}};cvox.BrailleDisplayManager.prototype.updatePanStrategy_=function(wordWrap){var newStrategy=wordWrap?new cvox.WrappingPanStrategy():new cvox.FixedPanStrategy();newStrategy.setDisplaySize(this.displayState_.textCellCount||0);newStrategy.setContent(this.translatedContent_,this.panStrategy_.viewPort.start);this.panStrategy_=newStrategy;this.refresh_();};goog.provide('cvox.BrailleInputHandler');goog.require('StringUtil');goog.require('cvox.BrailleKeyCommand');goog.require('cvox.BrailleKeyEvent');goog.require('cvox.ExpandingBrailleTranslator');cvox.BrailleInputHandler=function(translatorManager){this.imePort_=null;this.imeActive_=false;this.inputContext_=null;this.translatorManager_=translatorManager;this.currentTextBefore_='';this.currentTextAfter_='';this.pendingCells_=[];this.entryState_=null;this.uncommittedCellsSpan_=null;this.uncommittedCellsChangedListener_=null;this.translatorManager_.addChangeListener(this.commitAndClearEntryState_.bind(this));};cvox.BrailleInputHandler.IME_EXTENSION_ORIGIN_='chrome-extension://jddehjeebkoimngcbdkaahpobgicbffp';cvox.BrailleInputHandler.IME_PORT_NAME_='cvox.BrailleIme.Port';cvox.BrailleInputHandler.STARTS_WITH_NON_WHITESPACE_RE_=/^\S/;cvox.BrailleInputHandler.ENDS_WITH_NON_WHITESPACE_RE_=/\S$/;cvox.BrailleInputHandler.prototype={init:function(){chrome.runtime.onConnectExternal.addListener(this.onImeConnect_.bind(this));},onDisplayContentChanged:function(text,listener){var valueSpan=text.getSpanInstanceOf(cvox.ValueSpan);var selectionSpan=text.getSpanInstanceOf(cvox.ValueSelectionSpan);if(!(valueSpan&&selectionSpan))
return;this.uncommittedCellsChangedListener_=null;var valueStart=text.getSpanStart(valueSpan);var valueEnd=text.getSpanEnd(valueSpan);var selectionStart=text.getSpanStart(selectionSpan);var selectionEnd=text.getSpanEnd(selectionSpan);if(selectionStart<valueStart||selectionEnd>valueEnd){console.error('Selection outside of value in braille content');this.clearEntryState_();return;}
var newTextBefore=text.toString().substring(valueStart,selectionStart);if(this.currentTextBefore_!==newTextBefore&&this.entryState_)
this.entryState_.onTextBeforeChanged(newTextBefore);this.currentTextBefore_=newTextBefore;this.currentTextAfter_=text.toString().substring(selectionEnd,valueEnd);this.uncommittedCellsSpan_=new cvox.ExtraCellsSpan();text.setSpan(this.uncommittedCellsSpan_,selectionStart,selectionStart);if(this.entryState_&&this.entryState_.usesUncommittedCells){this.updateUncommittedCells_(new Uint8Array(this.entryState_.cells_).buffer);}
this.uncommittedCellsChangedListener_=listener;},onBrailleKeyEvent:function(event){if(event.command===cvox.BrailleKeyCommand.DOTS)
return this.onBrailleDots_((event.brailleDots));this.pendingCells_.length=0;if(event.command===cvox.BrailleKeyCommand.STANDARD_KEY){if(event.standardKeyCode==='Backspace'&&!event.altKey&&!event.ctrlKey&&!event.shiftKey&&this.onBackspace_()){return true;}else{this.commitAndClearEntryState_();this.sendKeyEventPair_(event);return true;}}
return false;},getExpansionType:function(){if(this.inAlwaysUncontractedContext_())
return cvox.ExpandingBrailleTranslator.ExpansionType.ALL;if(this.entryState_&&this.entryState_.translator===this.translatorManager_.getDefaultTranslator()){return cvox.ExpandingBrailleTranslator.ExpansionType.NONE;}
return cvox.ExpandingBrailleTranslator.ExpansionType.SELECTION;},inAlwaysUncontractedContext_:function(){var inputType=this.inputContext_?this.inputContext_.type:'';return inputType==='url'||inputType==='email';},onBrailleDots_:function(dots){if(!this.imeActive_){this.pendingCells_.push(dots);return true;}
if(!this.inputContext_)
return false;if(!this.entryState_){if(!(this.entryState_=this.createEntryState_()))
return false;}
this.entryState_.appendCell(dots);return true;},onBackspace_:function(){if(this.imeActive_&&this.entryState_){this.entryState_.deleteLastCell();return true;}
return false;},createEntryState_:function(){var translator=this.translatorManager_.getDefaultTranslator();if(!translator)
return null;var uncontractedTranslator=this.translatorManager_.getUncontractedTranslator();var constructor=cvox.BrailleInputHandler.EditsEntryState_;if(uncontractedTranslator){var textBefore=this.currentTextBefore_;var textAfter=this.currentTextAfter_;if(this.inAlwaysUncontractedContext_()||(cvox.BrailleInputHandler.ENDS_WITH_NON_WHITESPACE_RE_.test(textBefore))||(cvox.BrailleInputHandler.STARTS_WITH_NON_WHITESPACE_RE_.test(textAfter))){translator=uncontractedTranslator;}else{constructor=cvox.BrailleInputHandler.LateCommitEntryState_;}}
return new constructor(this,translator);},commitAndClearEntryState_:function(){if(this.entryState_){this.entryState_.commit();this.clearEntryState_();}},clearEntryState_:function(){if(this.entryState_){if(this.entryState_.usesUncommittedCells)
this.updateUncommittedCells_(new ArrayBuffer(0));this.entryState_.inputHandler_=null;this.entryState_=null;}},updateUncommittedCells_:function(cells){if(this.uncommittedCellsSpan_)
this.uncommittedCellsSpan_.cells=cells;if(this.uncommittedCellsChangedListener_)
this.uncommittedCellsChangedListener_();},onImeConnect_:function(port){if(port.name!==cvox.BrailleInputHandler.IME_PORT_NAME_||port.sender.origin!==cvox.BrailleInputHandler.IME_EXTENSION_ORIGIN_){return;}
if(this.imePort_)
this.imePort_.disconnect();port.onDisconnect.addListener(this.onImeDisconnect_.bind(this,port));port.onMessage.addListener(this.onImeMessage_.bind(this));this.imePort_=port;},onImeMessage_:function(message){if(!goog.isObject(message)){console.error('Unexpected message from Braille IME: ',JSON.stringify(message));}
switch(message.type){case'activeState':this.imeActive_=message.active;break;case'inputContext':this.inputContext_=message.context;this.clearEntryState_();if(this.imeActive_&&this.inputContext_)
this.pendingCells_.forEach(this.onBrailleDots_,this);this.pendingCells_.length=0;break;case'brailleDots':this.onBrailleDots_(message['dots']);break;case'backspace':this.postImeMessage_({type:'keyEventHandled',requestId:message['requestId'],result:this.onBackspace_()});break;case'reset':this.clearEntryState_();break;default:console.error('Unexpected message from Braille IME: ',JSON.stringify(message));break;}},onImeDisconnect_:function(port){this.imePort_=null;this.clearEntryState_();this.imeActive_=false;this.inputContext_=null;},postImeMessage_:function(message){if(this.imePort_){this.imePort_.postMessage(message);return true;}
return false;},sendKeyEventPair_:function(event){var keyName=(event.standardKeyCode);var numericCode=cvox.BrailleKeyEvent.keyCodeToLegacyCode(keyName);if(!goog.isDef(numericCode))
throw Error('Unknown key code in event: '+JSON.stringify(event));var keyEvent={type:'keydown',keyCode:numericCode,keyName:keyName,charValue:cvox.BrailleKeyEvent.keyCodeToCharValue(keyName),modifiers:(event.shiftKey?2:0)|(event.ctrlKey?4:0)|(event.altKey?8:0)};chrome.virtualKeyboardPrivate.sendKeyEvent(keyEvent);keyEvent.type='keyup';chrome.virtualKeyboardPrivate.sendKeyEvent(keyEvent);}};cvox.BrailleInputHandler.EntryState_=function(inputHandler,translator){this.inputHandler_=inputHandler;this.translator_=translator;this.cells_=[];this.text_='';this.pendingTextsBefore_=[];};cvox.BrailleInputHandler.EntryState_.prototype={get translator(){return this.translator_;},appendCell:function(cell){this.cells_.push(cell);this.updateText_();},deleteLastCell:function(){if(--this.cells_.length<=0){this.sendTextChange_('');this.inputHandler_.clearEntryState_();return;}
this.updateText_();},onTextBeforeChanged:function(newText){for(var i=0;i<this.pendingTextsBefore_.length;++i){if(newText===this.pendingTextsBefore_[i]){this.pendingTextsBefore_.splice(0,i+1);return;}}
this.inputHandler_.clearEntryState_();},commit:function(){},get usesUncommittedCells(){return false;},updateText_:function(){var cellsBuffer=new Uint8Array(this.cells_).buffer;var commit=this.lastCellIsBlank_;if(!commit&&this.usesUncommittedCells)
this.inputHandler_.updateUncommittedCells_(cellsBuffer);this.translator_.backTranslate(cellsBuffer,function(result){if(result===null){console.error('Error when backtranslating braille cells');return;}
if(!this.inputHandler_)
return;this.sendTextChange_(result);this.text_=result;if(commit)
this.inputHandler_.commitAndClearEntryState_();}.bind(this));},get lastCellIsBlank_(){return this.cells_[this.cells_.length-1]===0;},sendTextChange_:function(newText){}};cvox.BrailleInputHandler.EditsEntryState_=function(inputHandler,translator){cvox.BrailleInputHandler.EntryState_.call(this,inputHandler,translator);};cvox.BrailleInputHandler.EditsEntryState_.prototype={__proto__:cvox.BrailleInputHandler.EntryState_.prototype,sendTextChange_:function(newText){var oldText=this.text_;var commonPrefixLength=StringUtil.longestCommonPrefixLength(oldText,newText);var deleteLength=oldText.length-commonPrefixLength;var toInsert=newText.substring(commonPrefixLength);if(deleteLength>0||toInsert.length>0){var textBeforeAfterDelete=this.inputHandler_.currentTextBefore_.substring(0,this.inputHandler_.currentTextBefore_.length-deleteLength);if(deleteLength>0){this.pendingTextsBefore_.push(textBeforeAfterDelete);}
if(toInsert.length>0){this.pendingTextsBefore_.push(textBeforeAfterDelete+toInsert);}
this.inputHandler_.postImeMessage_({type:'replaceText',contextID:this.inputHandler_.inputContext_.contextID,deleteBefore:deleteLength,newText:toInsert});}}};cvox.BrailleInputHandler.LateCommitEntryState_=function(inputHandler,translator){cvox.BrailleInputHandler.EntryState_.call(this,inputHandler,translator);};cvox.BrailleInputHandler.LateCommitEntryState_.prototype={__proto__:cvox.BrailleInputHandler.EntryState_.prototype,commit:function(){this.inputHandler_.postImeMessage_({type:'commitUncommitted',contextID:this.inputHandler_.inputContext_.contextID});},get usesUncommittedCells(){return true;},sendTextChange_:function(newText){this.inputHandler_.postImeMessage_({type:'setUncommitted',contextID:this.inputHandler_.inputContext_.contextID,text:newText});}};goog.provide('cvox.BrailleInterface');goog.require('cvox.BrailleKeyCommand');goog.require('cvox.BrailleKeyEvent');goog.require('cvox.NavBraille');cvox.BrailleInterface=function(){};cvox.BrailleInterface.prototype.write=function(params){};goog.provide('cvox.BrailleTable');cvox.BrailleTable.Table;cvox.BrailleTable.TABLE_PATH='braille/tables.json';cvox.BrailleTable.COMMON_DEFS_FILENAME_='cvox-common.cti';cvox.BrailleTable.getAll=function(callback){function appendCommonFilename(tables){tables.forEach(function(table){table.fileNames+=(','+cvox.BrailleTable.COMMON_DEFS_FILENAME_);});return tables;}
var url=chrome.extension.getURL(cvox.BrailleTable.TABLE_PATH);if(!url){throw'Invalid path: '+cvox.BrailleTable.TABLE_PATH;}
var xhr=new XMLHttpRequest();xhr.open('GET',url,true);xhr.onreadystatechange=function(){if(xhr.readyState==4){if(xhr.status==200){callback(appendCommonFilename((JSON.parse(xhr.responseText))));}}};xhr.send();};cvox.BrailleTable.forId=function(tables,id){return tables.filter(function(table){return table.id===id})[0]||null;};cvox.BrailleTable.getUncontracted=function(tables,table){function mostUncontractedOf(current,candidate){if(current.dots==='6'&&candidate.dots==='8'&¤t.locale.lastIndexOf(candidate.locale,0)==0){return candidate;}
if(current.locale===candidate.locale&¤t.dots===candidate.dots&&goog.isDef(current.grade)&&goog.isDef(candidate.grade)&&candidate.grade<current.grade){return candidate;}
return current;}
return tables.reduce(mostUncontractedOf,table);};cvox.BrailleTable.getDisplayName=function(table){var localeName=chrome.accessibilityPrivate.getDisplayNameForLocale(table.locale,chrome.i18n.getUILanguage().toLowerCase());if(!table.grade&&!table.variant){return localeName;}else if(table.grade&&!table.variant){return Msgs.getMsg('braille_table_name_with_grade',[localeName,table.grade]);}else if(!table.grade&&table.variant){return Msgs.getMsg('braille_table_name_with_variant',[localeName,table.variant]);}else{return Msgs.getMsg('braille_table_name_with_variant_and_grade',[localeName,table.variant,table.grade]);}};goog.provide('cvox.BrailleTranslatorManager');goog.require('cvox.BrailleTable');goog.require('cvox.ExpandingBrailleTranslator');goog.require('cvox.LibLouis');cvox.BrailleTranslatorManager=function(opt_liblouisForTest){this.liblouis_=opt_liblouisForTest||new cvox.LibLouis(chrome.extension.getURL('braille/liblouis_nacl.nmf'),chrome.extension.getURL('braille/tables'));this.changeListeners_=[];this.tables_=[];this.expandingTranslator_=null;this.defaultTranslator_=null;this.defaultTableId_=null;this.uncontractedTranslator_=null;this.uncontractedTableId_=null;if(!opt_liblouisForTest){document.addEventListener('DOMContentLoaded',this.loadLiblouis_.bind(this),false);}};cvox.BrailleTranslatorManager.prototype={addChangeListener:function(listener){this.changeListeners_.push(listener);},refresh:function(){var tables=this.tables_;if(tables.length==0)
return;var table=cvox.BrailleTable.forId(tables,localStorage['brailleTable']);if(!table){var currentLocale=chrome.i18n.getMessage('@@ui_locale').split(/[_-]/);var major=currentLocale[0];var minor=currentLocale[1];var firstPass=tables.filter(function(table){return table.locale.split(/[_-]/)[0]==major;});if(firstPass.length>0){table=firstPass[0];if(minor){var secondPass=firstPass.filter(function(table){return table.locale.split(/[_-]/)[1]==minor;});if(secondPass.length>0)
table=secondPass[0];}}}
if(!table)
table=cvox.BrailleTable.forId(tables,'en-US-comp8');localStorage['brailleTable']=table.id;if(!localStorage['brailleTable6'])
localStorage['brailleTable6']='en-US-g1';if(!localStorage['brailleTable8'])
localStorage['brailleTable8']='en-US-comp8';if(table.dots=='6'){localStorage['brailleTableType']='brailleTable6';localStorage['brailleTable6']=table.id;}else{localStorage['brailleTableType']='brailleTable8';localStorage['brailleTable8']=table.id;}
var table8Dot=cvox.BrailleTable.forId(tables,localStorage['brailleTable8']);var uncontractedTable=cvox.BrailleTable.getUncontracted(tables,table8Dot||table);var newDefaultTableId=table.id;var newUncontractedTableId=table.id===uncontractedTable.id?null:uncontractedTable.id;if(newDefaultTableId===this.defaultTableId_&&newUncontractedTableId===this.uncontractedTableId_){return;}
var finishRefresh=function(defaultTranslator,uncontractedTranslator){this.defaultTableId_=newDefaultTableId;this.uncontractedTableId_=newUncontractedTableId;this.expandingTranslator_=new cvox.ExpandingBrailleTranslator(defaultTranslator,uncontractedTranslator);this.defaultTranslator_=defaultTranslator;this.uncontractedTranslator_=uncontractedTranslator;this.changeListeners_.forEach(function(listener){listener();});}.bind(this);this.liblouis_.getTranslator(table.fileNames,function(translator){if(!newUncontractedTableId){finishRefresh(translator,null);}else{this.liblouis_.getTranslator(uncontractedTable.fileNames,function(uncontractedTranslator){finishRefresh(translator,uncontractedTranslator);});}}.bind(this));},getExpandingTranslator:function(){return this.expandingTranslator_;},getDefaultTranslator:function(){return this.defaultTranslator_;},getUncontractedTranslator:function(){return this.uncontractedTranslator_;},fetchTables_:function(){cvox.BrailleTable.getAll(function(tables){this.tables_=tables;this.refresh();}.bind(this));},loadLiblouis_:function(){this.liblouis_.attachToElement((document.body));this.fetchTables_();},getLibLouisForTest:function(){return this.liblouis_;},getTablesForTest:function(){return this.tables_;}};goog.provide('cvox.BrailleBackground');goog.require('ChromeVoxState');goog.require('cvox.BrailleDisplayManager');goog.require('cvox.BrailleInputHandler');goog.require('cvox.BrailleInterface');goog.require('cvox.BrailleKeyEvent');goog.require('cvox.BrailleTranslatorManager');cvox.BrailleBackground=function(opt_displayManagerForTest,opt_inputHandlerForTest,opt_translatorManagerForTest){this.translatorManager_=opt_translatorManagerForTest||new cvox.BrailleTranslatorManager();this.displayManager_=opt_displayManagerForTest||new cvox.BrailleDisplayManager(this.translatorManager_);this.displayManager_.setCommandListener(this.onBrailleKeyEvent_.bind(this));this.lastContent_=null;this.lastContentId_=null;this.inputHandler_=opt_inputHandlerForTest||new cvox.BrailleInputHandler(this.translatorManager_);this.inputHandler_.init();};cvox.BrailleBackground.prototype.write=function(params){};cvox.BrailleBackground.prototype.getTranslatorManager=function(){return this.translatorManager_;};cvox.BrailleBackground.prototype.onBrailleMessage=function(msg){if(msg['action']=='write'){this.setContent_(cvox.NavBraille.fromJson(msg['params']),msg['contentId']);}};cvox.BrailleBackground.prototype.setContent_=function(newContent,newContentId){var updateContent=function(){this.lastContent_=newContentId?newContent:null;this.lastContentId_=newContentId;this.displayManager_.setContent(newContent,this.inputHandler_.getExpansionType());}.bind(this);this.inputHandler_.onDisplayContentChanged(newContent.text,updateContent);updateContent();};cvox.BrailleBackground.prototype.onBrailleKeyEvent_=function(brailleEvt,content){if(this.inputHandler_.onBrailleKeyEvent(brailleEvt)){return;}
if(ChromeVoxState.instance&&ChromeVoxState.instance.onBrailleKeyEvent(brailleEvt,content)){return;}
this.sendCommand_(brailleEvt,content);};cvox.BrailleBackground.prototype.sendCommand_=function(brailleEvt,content){var msg={'message':'BRAILLE','args':brailleEvt};if(content===this.lastContent_){msg.contentId=this.lastContentId_;}
cvox.ExtensionBridge.send(msg);};goog.provide('cvox.AbstractTts');goog.require('Msgs');goog.require('cvox.TtsInterface');goog.require('goog.i18n.MessageFormat');cvox.AbstractTts=function(){this.ttsProperties=new Object();this.propertyDefault={'rate':0.5,'pitch':0.5,'volume':0.5};this.propertyMin={'rate':0.0,'pitch':0.0,'volume':0.0};this.propertyMax={'rate':1.0,'pitch':1.0,'volume':1.0};this.propertyStep={'rate':0.1,'pitch':0.1,'volume':0.1};if(cvox.AbstractTts.pronunciationDictionaryRegexp_==undefined){var words=[];for(var word in cvox.AbstractTts.PRONUNCIATION_DICTIONARY){words.push(word);}
var expr='\\b('+words.join('|')+')\\b';cvox.AbstractTts.pronunciationDictionaryRegexp_=new RegExp(expr,'ig');}
if(cvox.AbstractTts.substitutionDictionaryRegexp_==undefined){var symbols=[];for(var symbol in cvox.AbstractTts.SUBSTITUTION_DICTIONARY){symbols.push(symbol);}
var expr='('+symbols.join('|')+')';cvox.AbstractTts.substitutionDictionaryRegexp_=new RegExp(expr,'ig');}};cvox.AbstractTts.prototype.ttsProperties;cvox.AbstractTts.prototype.speak=function(textString,queueMode,properties){return this;};cvox.AbstractTts.prototype.isSpeaking=function(){return false;};cvox.AbstractTts.prototype.stop=function(){};cvox.AbstractTts.prototype.addCapturingEventListener=function(listener){};cvox.AbstractTts.prototype.increaseOrDecreaseProperty=function(propertyName,increase){var min=this.propertyMin[propertyName];var max=this.propertyMax[propertyName];var step=this.propertyStep[propertyName];var current=this.ttsProperties[propertyName];current=increase?current+step:current-step;this.ttsProperties[propertyName]=Math.max(Math.min(current,max),min);};cvox.AbstractTts.prototype.propertyToPercentage=function(property){return(this.ttsProperties[property]-this.propertyMin[property])/Math.abs(this.propertyMax[property]-this.propertyMin[property]);};cvox.AbstractTts.prototype.mergeProperties=function(properties){var mergedProperties=new Object();var p;if(this.ttsProperties){for(p in this.ttsProperties){mergedProperties[p]=this.ttsProperties[p];}}
if(properties){var tts=cvox.AbstractTts;if(typeof(properties[tts.VOLUME])=='number'){mergedProperties[tts.VOLUME]=properties[tts.VOLUME];}
if(typeof(properties[tts.PITCH])=='number'){mergedProperties[tts.PITCH]=properties[tts.PITCH];}
if(typeof(properties[tts.RATE])=='number'){mergedProperties[tts.RATE]=properties[tts.RATE];}
if(typeof(properties[tts.LANG])=='string'){mergedProperties[tts.LANG]=properties[tts.LANG];}
var context=this;var mergeRelativeProperty=function(abs,rel){if(typeof(properties[rel])=='number'&&typeof(mergedProperties[abs])=='number'){mergedProperties[abs]+=properties[rel];var min=context.propertyMin[abs];var max=context.propertyMax[abs];if(mergedProperties[abs]>max){mergedProperties[abs]=max;}else if(mergedProperties[abs]<min){mergedProperties[abs]=min;}}};mergeRelativeProperty(tts.VOLUME,tts.RELATIVE_VOLUME);mergeRelativeProperty(tts.PITCH,tts.RELATIVE_PITCH);mergeRelativeProperty(tts.RATE,tts.RELATIVE_RATE);}
for(p in properties){if(!mergedProperties.hasOwnProperty(p)){mergedProperties[p]=properties[p];}}
return mergedProperties;};cvox.AbstractTts.prototype.preprocess=function(text,properties){if(text.length==1&&text>='A'&&text<='Z'){for(var prop in cvox.AbstractTts.PERSONALITY_CAPITAL)
properties[prop]=cvox.AbstractTts.PERSONALITY_CAPITAL[prop];}
text=text.replace(cvox.AbstractTts.substitutionDictionaryRegexp_,function(symbol){return' '+cvox.AbstractTts.SUBSTITUTION_DICTIONARY[symbol]+' ';});if(text.length==1){return cvox.AbstractTts.CHARACTER_DICTIONARY[text]?(new goog.i18n.MessageFormat(Msgs.getMsg(cvox.AbstractTts.CHARACTER_DICTIONARY[text]))).format({'COUNT':1}):text.toUpperCase();}
text=text.replace(cvox.AbstractTts.pronunciationDictionaryRegexp_,function(word){return cvox.AbstractTts.PRONUNCIATION_DICTIONARY[word.toLowerCase()];});text=text.replace(cvox.AbstractTts.repetitionRegexp_,cvox.AbstractTts.repetitionReplace_);return text;};cvox.AbstractTts.RATE='rate';cvox.AbstractTts.PITCH='pitch';cvox.AbstractTts.VOLUME='volume';cvox.AbstractTts.LANG='lang';cvox.AbstractTts.RELATIVE_RATE='relativeRate';cvox.AbstractTts.RELATIVE_PITCH='relativePitch';cvox.AbstractTts.RELATIVE_VOLUME='relativeVolume';cvox.AbstractTts.COLOR='color';cvox.AbstractTts.FONT_WEIGHT='fontWeight';cvox.AbstractTts.PUNCTUATION_ECHO='punctuationEcho';cvox.AbstractTts.PAUSE='pause';cvox.AbstractTts.PERSONALITY_ANNOTATION={'relativePitch':-0.25,'color':'yellow','punctuationEcho':'none'};cvox.AbstractTts.PERSONALITY_ANNOUNCEMENT={'punctuationEcho':'none'};cvox.AbstractTts.PERSONALITY_SYSTEM_ALERT={'punctuationEcho':'none','doNotInterrupt':true};cvox.AbstractTts.PERSONALITY_ASIDE={'relativePitch':-0.1,'color':'#669'};cvox.AbstractTts.PERSONALITY_CAPITAL={'relativePitch':0.6};cvox.AbstractTts.PERSONALITY_DELETED={'punctuationEcho':'none','relativePitch':-0.6};cvox.AbstractTts.PERSONALITY_QUOTE={'relativePitch':0.1,'color':'#b6b','fontWeight':'bold'};cvox.AbstractTts.PERSONALITY_STRONG={'relativePitch':0.1,'color':'#b66','fontWeight':'bold'};cvox.AbstractTts.PERSONALITY_EMPHASIS={'relativeVolume':0.1,'relativeRate':-0.1,'color':'#6bb','fontWeight':'bold'};cvox.AbstractTts.DEBUG=true;cvox.AbstractTts.CHARACTER_DICTIONARY={' ':'space','`':'backtick','~':'tilde','!':'exclamation','@':'at','#':'pound','$':'dollar','%':'percent','^':'caret','&':'ampersand','*':'asterisk','(':'open_paren',')':'close_paren','-':'dash','_':'underscore','=':'equals','+':'plus','[':'left_bracket',']':'right_bracket','{':'left_brace','}':'right_brace','|':'pipe',';':'semicolon',':':'colon',',':'comma','.':'dot','<':'less_than','>':'greater_than','/':'slash','?':'question_mark','"':'quote','\'':'apostrophe','\t':'tab','\r':'return','\n':'new_line','\\':'backslash'};cvox.AbstractTts.PRONUNCIATION_DICTIONARY={'admob':'ad-mob','adsense':'ad-sense','adwords':'ad-words','angularjs':'angular j s','bcc':'B C C','cc':'C C','chromevox':'chrome vox','cr48':'C R 48','ctrl':'control','doubleclick':'double-click','gmail':'gee mail','gtalk':'gee talk','http':'H T T P','https':'H T T P S','igoogle':'eye google','pagerank':'page-rank','username':'user-name','www':'W W W','youtube':'you tube'};cvox.AbstractTts.pronunciationDictionaryRegexp_;cvox.AbstractTts.SUBSTITUTION_DICTIONARY={'://':'colon slash slash','\u00bc':'one fourth','\u00bd':'one half','\u2190':'left arrow','\u2191':'up arrow','\u2192':'right arrow','\u2193':'down arrow','\u21d0':'left double arrow','\u21d1':'up double arrow','\u21d2':'right double arrow','\u21d3':'down double arrow','\u21e6':'left arrow','\u21e7':'up arrow','\u21e8':'right arrow','\u21e9':'down arrow','\u2303':'control','\u2318':'command','\u2325':'option','\u25b2':'up triangle','\u25b3':'up triangle','\u25b4':'up triangle','\u25b5':'up triangle','\u25b6':'right triangle','\u25b7':'right triangle','\u25b8':'right triangle','\u25b9':'right triangle','\u25ba':'right pointer','\u25bb':'right pointer','\u25bc':'down triangle','\u25bd':'down triangle','\u25be':'down triangle','\u25bf':'down triangle','\u25c0':'left triangle','\u25c1':'left triangle','\u25c2':'left triangle','\u25c3':'left triangle','\u25c4':'left pointer','\u25c5':'left pointer','\uf8ff':'apple'};cvox.AbstractTts.substitutionDictionaryRegexp_;cvox.AbstractTts.repetitionRegexp_=/([-\/\\|!@#$%^&*\(\)=_+\[\]\{\}.?;'":<>])\1{2,}/g;cvox.AbstractTts.repetitionReplace_=function(match){var count=match.length;return' '+(new goog.i18n.MessageFormat(Msgs.getMsg(cvox.AbstractTts.CHARACTER_DICTIONARY[match[0]]))).format({'COUNT':count})+' ';};cvox.AbstractTts.prototype.getDefaultProperty=function(property){return this.propertyDefault[property];};goog.provide('cvox.ChromeVoxEditableTextBase');goog.provide('cvox.TextChangeEvent');goog.provide('cvox.TypingEcho');goog.require('cvox.AbstractTts');goog.require('cvox.ChromeVox');goog.require('cvox.TtsInterface');goog.require('goog.i18n.MessageFormat');cvox.TextChangeEvent=function(newValue,newStart,newEnd,triggeredByUser){this.value=newValue;this.start=newStart;this.end=newEnd;this.triggeredByUser=triggeredByUser;if(this.start>this.end){var tempOffset=this.end;this.end=this.start;this.start=tempOffset;}};cvox.TypingEcho={CHARACTER:0,WORD:1,CHARACTER_AND_WORD:2,NONE:3,COUNT:4};cvox.TypingEcho.cycle=function(cur){return(cur+1)%cvox.TypingEcho.COUNT;};cvox.TypingEcho.shouldSpeakChar=function(typingEcho){return typingEcho==cvox.TypingEcho.CHARACTER_AND_WORD||typingEcho==cvox.TypingEcho.CHARACTER;};cvox.ChromeVoxEditableTextBase=function(value,start,end,isPassword,tts){this.value=value;this.start=start;this.end=end;this.isPassword=isPassword;this.tts=tts;this.multiline=false;this.lastChangeDescribed=false;};cvox.ChromeVoxEditableTextBase.prototype.setup=function(){};cvox.ChromeVoxEditableTextBase.prototype.teardown=function(){};cvox.ChromeVoxEditableTextBase.useIBeamCursor=cvox.ChromeVox.isMac;cvox.ChromeVoxEditableTextBase.eventTypingEcho=false;cvox.ChromeVoxEditableTextBase.prototype.maxShortPhraseLen=60;cvox.ChromeVoxEditableTextBase.prototype.getLineIndex=function(index){return 0;};cvox.ChromeVoxEditableTextBase.prototype.getLineStart=function(index){return 0;};cvox.ChromeVoxEditableTextBase.prototype.getLineEnd=function(index){return this.value.length;};cvox.ChromeVoxEditableTextBase.prototype.getLine=function(index){var lineStart=this.getLineStart(index);var lineEnd=this.getLineEnd(index);return this.value.substr(lineStart,lineEnd-lineStart);};cvox.ChromeVoxEditableTextBase.prototype.isWhitespaceChar=function(ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';};cvox.ChromeVoxEditableTextBase.prototype.isWordBreakChar=function(ch){return!!ch.match(/^\W$/);};cvox.ChromeVoxEditableTextBase.prototype.shouldDescribeChange=function(evt){if(evt.value==this.value&&evt.start==this.start&&evt.end==this.end){return false;}
return true;};cvox.ChromeVoxEditableTextBase.prototype.speak=function(str,opt_triggeredByUser,opt_personality){if(!str){return;}
var queueMode=cvox.QueueMode.QUEUE;if(opt_triggeredByUser===true){queueMode=cvox.QueueMode.FLUSH;}
this.tts.speak(str,queueMode,opt_personality||{});};cvox.ChromeVoxEditableTextBase.prototype.changed=function(evt){if(!this.shouldDescribeChange(evt)){this.lastChangeDescribed=false;return;}
if(evt.value==this.value){this.describeSelectionChanged(evt);}else{this.describeTextChanged(evt);}
this.lastChangeDescribed=true;this.value=evt.value;this.start=evt.start;this.end=evt.end;};cvox.ChromeVoxEditableTextBase.prototype.describeSelectionChanged=function(evt){if(this.isPassword){this.speak((new goog.i18n.MessageFormat(Msgs.getMsg('dot')).format({'COUNT':1})),evt.triggeredByUser);return;}
if(evt.start==evt.end){if(this.start!=this.end){this.speak(Msgs.getMsg('Unselected'),evt.triggeredByUser);}else if(this.getLineIndex(this.start)!=this.getLineIndex(evt.start)){var lineValue=this.getLine(this.getLineIndex(evt.start));if(lineValue==''){lineValue=Msgs.getMsg('text_box_blank');}else if(/^\s+$/.test(lineValue)){lineValue=Msgs.getMsg('text_box_whitespace');}
this.speak(lineValue,evt.triggeredByUser);}else if(this.start==evt.start+1||this.start==evt.start-1){if(!cvox.ChromeVoxEditableTextBase.useIBeamCursor){if(evt.start==this.value.length){if(cvox.ChromeVox.verbosity==cvox.VERBOSITY_VERBOSE){this.speak(Msgs.getMsg('end_of_text_verbose'),evt.triggeredByUser);}else{this.speak(Msgs.getMsg('end_of_text_brief'),evt.triggeredByUser);}}else{this.speak(this.value.substr(evt.start,1),evt.triggeredByUser,{'phoneticCharacters':evt.triggeredByUser});}}else{this.speak(this.value.substr(Math.min(this.start,evt.start),1),evt.triggeredByUser,{'phoneticCharacters':evt.triggeredByUser});}}else{this.speak(this.value.substr(Math.min(this.start,evt.start),Math.abs(this.start-evt.start)),evt.triggeredByUser);}}else{if(this.start+1==evt.start&&this.end==this.value.length&&evt.end==this.value.length){this.speak(this.value.substr(this.start,1),evt.triggeredByUser);this.speak(this.value.substr(evt.start));}else if(this.start==this.end){this.speak(this.value.substr(evt.start,evt.end-evt.start),evt.triggeredByUser);this.speak(Msgs.getMsg('selected'));}else if(this.start==evt.start&&this.end<evt.end){this.speak(this.value.substr(this.end,evt.end-this.end),evt.triggeredByUser);this.speak(Msgs.getMsg('added_to_selection'));}else if(this.start==evt.start&&this.end>evt.end){this.speak(this.value.substr(evt.end,this.end-evt.end),evt.triggeredByUser);this.speak(Msgs.getMsg('removed_from_selection'));}else if(this.end==evt.end&&this.start>evt.start){this.speak(this.value.substr(evt.start,this.start-evt.start),evt.triggeredByUser);this.speak(Msgs.getMsg('added_to_selection'));}else if(this.end==evt.end&&this.start<evt.start){this.speak(this.value.substr(this.start,evt.start-this.start),evt.triggeredByUser);this.speak(Msgs.getMsg('removed_from_selection'));}else{this.speak(this.value.substr(evt.start,evt.end-evt.start),evt.triggeredByUser);this.speak(Msgs.getMsg('selected'));}}};cvox.ChromeVoxEditableTextBase.prototype.describeTextChanged=function(evt){var personality={};if(evt.value.length<this.value.length){personality=cvox.AbstractTts.PERSONALITY_DELETED;}
if(this.isPassword){this.speak((new goog.i18n.MessageFormat(Msgs.getMsg('dot')).format({'COUNT':1})),evt.triggeredByUser,personality);return;}
var value=this.value;var len=value.length;var newLen=evt.value.length;var autocompleteSuffix='';var evtValue=evt.value;var evtEnd=evt.end;if(evt.start<evtEnd&&evtEnd==newLen){autocompleteSuffix=evtValue.substr(evt.start);evtValue=evtValue.substr(0,evt.start);evtEnd=evt.start;}
var prefixLen=this.start;var suffixLen=len-this.end;if(newLen>=prefixLen+suffixLen+(evtEnd-evt.start)&&evtValue.substr(0,prefixLen)==value.substr(0,prefixLen)&&evtValue.substr(newLen-suffixLen)==value.substr(this.end)){if(!(cvox.ChromeVoxEditableContentEditable&&this instanceof cvox.ChromeVoxEditableContentEditable)||newLen<len||this.isWordBreakChar(evt.value[newLen-1]||'')){this.describeTextChangedHelper(evt,prefixLen,suffixLen,autocompleteSuffix,personality);}
return;}
prefixLen=evt.start;suffixLen=newLen-evtEnd;if(this.start==this.end&&evt.start==evtEnd&&evtValue.substr(0,prefixLen)==value.substr(0,prefixLen)&&evtValue.substr(newLen-suffixLen)==value.substr(len-suffixLen)){this.describeTextChangedHelper(evt,prefixLen,suffixLen,autocompleteSuffix,personality);return;}
evtValue+=autocompleteSuffix;if((evtValue.length==(value.length+1))||((evtValue.length+1)==value.length)){if(evtValue.length>value.length){if(evtValue.indexOf(value)==0){this.speak(evtValue[evtValue.length-1],evt.triggeredByUser,personality);return;}else if(evtValue.indexOf(value)==1){this.speak(evtValue[0],evt.triggeredByUser,personality);return;}}
if(evtValue.length<value.length){if(value.indexOf(evtValue)==0){this.speak(value[value.length-1],evt.triggeredByUser,personality);return;}else if(value.indexOf(evtValue)==1){this.speak(value[0],evt.triggeredByUser,personality);return;}}}
if(this.multiline){if(evt.value.length<this.value.length){this.speak(Msgs.getMsg('text_deleted'),evt.triggeredByUser,personality);}
return;}
if(newLen<=this.maxShortPhraseLen){this.describeTextChangedHelper(evt,0,0,'',personality);return;}
prefixLen=0;while(prefixLen<len&&prefixLen<newLen&&value[prefixLen]==evtValue[prefixLen]){prefixLen++;}
while(prefixLen>0&&!this.isWordBreakChar(value[prefixLen-1])){prefixLen--;}
suffixLen=0;while(suffixLen<(len-prefixLen)&&suffixLen<(newLen-prefixLen)&&value[len-suffixLen-1]==evtValue[newLen-suffixLen-1]){suffixLen++;}
while(suffixLen>0&&!this.isWordBreakChar(value[len-suffixLen])){suffixLen--;}
this.describeTextChangedHelper(evt,prefixLen,suffixLen,'',personality);};cvox.ChromeVoxEditableTextBase.prototype.describeTextChangedHelper=function(evt,prefixLen,suffixLen,autocompleteSuffix,opt_personality){var len=this.value.length;var newLen=evt.value.length;var deletedLen=len-prefixLen-suffixLen;var deleted=this.value.substr(prefixLen,deletedLen);var insertedLen=newLen-prefixLen-suffixLen;var inserted=evt.value.substr(prefixLen,insertedLen);var utterance='';var triggeredByUser=evt.triggeredByUser;if(insertedLen>1){utterance=inserted;}else if(insertedLen==1){if((cvox.ChromeVox.typingEcho==cvox.TypingEcho.WORD||cvox.ChromeVox.typingEcho==cvox.TypingEcho.CHARACTER_AND_WORD)&&this.isWordBreakChar(inserted)&&prefixLen>0&&!this.isWordBreakChar(evt.value.substr(prefixLen-1,1))){var index=prefixLen;while(index>0&&!this.isWordBreakChar(evt.value[index-1])){index--;}
if(index<prefixLen){utterance=evt.value.substr(index,prefixLen+1-index);}else{utterance=inserted;triggeredByUser=false;}}else if(cvox.ChromeVox.typingEcho==cvox.TypingEcho.CHARACTER||cvox.ChromeVox.typingEcho==cvox.TypingEcho.CHARACTER_AND_WORD){utterance=cvox.ChromeVoxEditableTextBase.eventTypingEcho?'':inserted;}}else if(deletedLen>1&&!autocompleteSuffix){utterance=deleted+', deleted';}else if(deletedLen==1){utterance=deleted;}
if(autocompleteSuffix&&utterance){utterance+=', '+autocompleteSuffix;}else if(autocompleteSuffix){utterance=autocompleteSuffix;}
if(utterance){this.speak(utterance,triggeredByUser,opt_personality);}};cvox.ChromeVoxEditableTextBase.prototype.moveCursorToNextCharacter=function(){return false;};cvox.ChromeVoxEditableTextBase.prototype.moveCursorToPreviousCharacter=function(){return false;};cvox.ChromeVoxEditableTextBase.prototype.moveCursorToNextWord=function(){return false;};cvox.ChromeVoxEditableTextBase.prototype.moveCursorToPreviousWord=function(){return false;};cvox.ChromeVoxEditableTextBase.prototype.moveCursorToNextLine=function(){return false;};cvox.ChromeVoxEditableTextBase.prototype.moveCursorToPreviousLine=function(){return false;};cvox.ChromeVoxEditableTextBase.prototype.moveCursorToNextParagraph=function(){return false;};cvox.ChromeVoxEditableTextBase.prototype.moveCursorToPreviousParagraph=function(){return false;};goog.provide('cvox.PlatformFilter');goog.provide('cvox.PlatformUtil');goog.require('cvox.ChromeVox');cvox.PlatformFilter={NONE:0,WINDOWS:1,MAC:2,LINUX:4,WML:7,CHROMEOS:8,ANDROID:16};cvox.PlatformUtil.matchesPlatform=function(filter){var uA=navigator.userAgent;if(filter==undefined){return true;}else if(uA.indexOf('Android')!=-1){return(filter&cvox.PlatformFilter.ANDROID)!=0;}else if(uA.indexOf('Win')!=-1){return(filter&cvox.PlatformFilter.WINDOWS)!=0;}else if(uA.indexOf('Mac')!=-1){return(filter&cvox.PlatformFilter.MAC)!=0;}else if(uA.indexOf('Linux')!=-1){return(filter&cvox.PlatformFilter.LINUX)!=0;}else if(uA.indexOf('CrOS')!=-1){return(filter&cvox.PlatformFilter.CHROMEOS)!=0;}
return false;};goog.provide('cvox.KeySequence');goog.require('cvox.ChromeVox');goog.require('cvox.PlatformFilter');cvox.KeySequence=function(originalEvent,opt_cvoxModifier,opt_doubleTap,opt_skipStripping){this.doubleTap=!!opt_doubleTap;this.platformFilter;this.skipStripping=!!opt_skipStripping;if(opt_cvoxModifier==undefined){this.cvoxModifier=this.isCVoxModifierActive(originalEvent);}else{this.cvoxModifier=opt_cvoxModifier;}
this.stickyMode=!!originalEvent['stickyMode'];this.prefixKey=!!originalEvent['keyPrefix'];if(this.stickyMode&&this.prefixKey){throw'Prefix key and sticky mode cannot both be enabled: '+originalEvent;}
var event=this.resolveChromeOSSpecialKeys_(originalEvent);this.keys={ctrlKey:[],searchKeyHeld:[],altKey:[],altGraphKey:[],shiftKey:[],metaKey:[],keyCode:[]};this.extractKey_(event);};cvox.KeySequence.KEY_PRESS_CODE={39:222,44:188,45:189,46:190,47:191,59:186,91:219,92:220,93:221};cvox.KeySequence.doubleTapCache=[];cvox.KeySequence.prototype.addKeyEvent=function(additionalKeyEvent){if(this.keys.keyCode.length>1){return false;}
this.extractKey_(additionalKeyEvent);return true;};cvox.KeySequence.prototype.equals=function(rhs){if(!this.checkKeyEquality_(rhs)){return false;}
if(this.doubleTap!=rhs.doubleTap){return false;}
if(this.cvoxModifier===rhs.cvoxModifier){return true;}
var unmodified=this.cvoxModifier?rhs:this;return unmodified.stickyMode||unmodified.prefixKey;};cvox.KeySequence.prototype.extractKey_=function(keyEvent){for(var prop in this.keys){if(prop=='keyCode'){var keyCode;if(keyEvent.type=='keypress'&&keyEvent[prop]>=97&&keyEvent[prop]<=122){keyCode=keyEvent[prop]-32;}else if(keyEvent.type=='keypress'){keyCode=cvox.KeySequence.KEY_PRESS_CODE[keyEvent[prop]];}
this.keys[prop].push(keyCode||keyEvent[prop]);}else{if(this.isKeyModifierActive(keyEvent,prop)){this.keys[prop].push(true);}else{this.keys[prop].push(false);}}}
if(this.cvoxModifier){this.rationalizeKeys_();}};cvox.KeySequence.prototype.rationalizeKeys_=function(){if(this.skipStripping){return;}
var modifierKeyCombo=cvox.ChromeVox.modKeyStr.split(/\+/g);var index=this.keys.keyCode.length-1;if(modifierKeyCombo.indexOf('Ctrl')!=-1){this.keys.ctrlKey[index]=false;}
if(modifierKeyCombo.indexOf('Alt')!=-1){this.keys.altKey[index]=false;}
if(modifierKeyCombo.indexOf('Shift')!=-1){this.keys.shiftKey[index]=false;}
var metaKeyName=this.getMetaKeyName_();if(modifierKeyCombo.indexOf(metaKeyName)!=-1){if(metaKeyName=='Search'){this.keys.searchKeyHeld[index]=false;this.keys.metaKey[index]=false;}else if(metaKeyName=='Cmd'||metaKeyName=='Win'){this.keys.metaKey[index]=false;}}};cvox.KeySequence.prototype.getMetaKeyName_=function(){if(cvox.ChromeVox.isChromeOS){return'Search';}else if(cvox.ChromeVox.isMac){return'Cmd';}else{return'Win';}};cvox.KeySequence.prototype.checkKeyEquality_=function(rhs){for(var i in this.keys){for(var j=this.keys[i].length;j--;){if(this.keys[i][j]!==rhs.keys[i][j])
return false;}}
return true;};cvox.KeySequence.prototype.getFirstKeyCode=function(){return this.keys.keyCode[0];};cvox.KeySequence.prototype.length=function(){return this.keys.keyCode.length;};cvox.KeySequence.prototype.isModifierKey=function(keyCode){return keyCode==16||keyCode==17||keyCode==18||keyCode==91||keyCode==93;};cvox.KeySequence.prototype.isCVoxModifierActive=function(keyEvent){var modifierKeyCombo=cvox.ChromeVox.modKeyStr.split(/\+/g);if(this.isKeyModifierActive(keyEvent,'ctrlKey')){modifierKeyCombo=modifierKeyCombo.filter(function(modifier){return modifier!='Ctrl';});}
if(this.isKeyModifierActive(keyEvent,'altKey')){modifierKeyCombo=modifierKeyCombo.filter(function(modifier){return modifier!='Alt';});}
if(this.isKeyModifierActive(keyEvent,'shiftKey')){modifierKeyCombo=modifierKeyCombo.filter(function(modifier){return modifier!='Shift';});}
if(this.isKeyModifierActive(keyEvent,'metaKey')||this.isKeyModifierActive(keyEvent,'searchKeyHeld')){var metaKeyName=this.getMetaKeyName_();modifierKeyCombo=modifierKeyCombo.filter(function(modifier){return modifier!=metaKeyName;});}
return(modifierKeyCombo.length==0);};cvox.KeySequence.prototype.isKeyModifierActive=function(keyEvent,modifier){switch(modifier){case'ctrlKey':return(keyEvent.ctrlKey||keyEvent.keyCode==17);break;case'altKey':return(keyEvent.altKey||(keyEvent.keyCode==18));break;case'shiftKey':return(keyEvent.shiftKey||(keyEvent.keyCode==16));break;case'metaKey':return(keyEvent.metaKey||(keyEvent.keyCode==91));break;case'searchKeyHeld':return((cvox.ChromeVox.isChromeOS&&keyEvent.keyCode==91)||keyEvent['searchKeyHeld']);break;}
return false;};cvox.KeySequence.prototype.isAnyModifierActive=function(){for(var modifierType in this.keys){for(var i=0;i<this.length();i++){if(this.keys[modifierType][i]&&modifierType!='keyCode'){return true;}}}
return false;};cvox.KeySequence.deserialize=function(sequenceObject){var firstSequenceEvent={};firstSequenceEvent['stickyMode']=(sequenceObject.stickyMode==undefined)?false:sequenceObject.stickyMode;firstSequenceEvent['prefixKey']=(sequenceObject.prefixKey==undefined)?false:sequenceObject.prefixKey;var secondKeyPressed=sequenceObject.keys.keyCode.length>1;var secondSequenceEvent={};for(var keyPressed in sequenceObject.keys){firstSequenceEvent[keyPressed]=sequenceObject.keys[keyPressed][0];if(secondKeyPressed){secondSequenceEvent[keyPressed]=sequenceObject.keys[keyPressed][1];}}
var skipStripping=sequenceObject.skipStripping!==undefined?sequenceObject.skipStripping:true;var keySeq=new cvox.KeySequence(firstSequenceEvent,sequenceObject.cvoxModifier,sequenceObject.doubleTap,skipStripping);if(secondKeyPressed){cvox.ChromeVox.sequenceSwitchKeyCodes.push(new cvox.KeySequence(firstSequenceEvent,sequenceObject.cvoxModifier));keySeq.addKeyEvent(secondSequenceEvent);}
if(sequenceObject.doubleTap){cvox.KeySequence.doubleTapCache.push(keySeq);}
return keySeq;};cvox.KeySequence.fromStr=function(keyStr){var sequenceEvent={};var secondSequenceEvent={};var secondKeyPressed;if(keyStr.indexOf('>')==-1){secondKeyPressed=false;}else{secondKeyPressed=true;}
var cvoxPressed=false;sequenceEvent['stickyMode']=false;sequenceEvent['prefixKey']=false;var tokens=keyStr.split('+');for(var i=0;i<tokens.length;i++){var seqs=tokens[i].split('>');for(var j=0;j<seqs.length;j++){if(seqs[j].charAt(0)=='#'){var keyCode=parseInt(seqs[j].substr(1),10);if(j>0){secondSequenceEvent['keyCode']=keyCode;}else{sequenceEvent['keyCode']=keyCode;}}
var keyName=seqs[j];if(seqs[j].length==1){if(j>0){secondSequenceEvent['keyCode']=seqs[j].charCodeAt(0);}else{sequenceEvent['keyCode']=seqs[j].charCodeAt(0);}}else{if(j>0){cvox.KeySequence.setModifiersOnEvent_(keyName,secondSequenceEvent);if(keyName=='Cvox'){cvoxPressed=true;}}else{cvox.KeySequence.setModifiersOnEvent_(keyName,sequenceEvent);if(keyName=='Cvox'){cvoxPressed=true;}}}}}
var keySeq=new cvox.KeySequence(sequenceEvent,cvoxPressed);if(secondKeyPressed){keySeq.addKeyEvent(secondSequenceEvent);}
return keySeq;};cvox.KeySequence.setModifiersOnEvent_=function(keyName,seqEvent){if(keyName=='Ctrl'){seqEvent['ctrlKey']=true;seqEvent['keyCode']=17;}else if(keyName=='Alt'){seqEvent['altKey']=true;seqEvent['keyCode']=18;}else if(keyName=='Shift'){seqEvent['shiftKey']=true;seqEvent['keyCode']=16;}else if(keyName=='Search'){seqEvent['searchKeyHeld']=true;seqEvent['keyCode']=91;}else if(keyName=='Cmd'){seqEvent['metaKey']=true;seqEvent['keyCode']=91;}else if(keyName=='Win'){seqEvent['metaKey']=true;seqEvent['keyCode']=91;}else if(keyName=='Insert'){seqEvent['keyCode']=45;}};cvox.KeySequence.prototype.resolveChromeOSSpecialKeys_=function(originalEvent){if(!this.cvoxModifier||this.stickyMode||this.prefixKey||!cvox.ChromeVox.isChromeOS){return originalEvent;}
var evt={};for(var key in originalEvent){evt[key]=originalEvent[key];}
switch(evt['keyCode']){case 33:evt['keyCode']=38;break;case 34:evt['keyCode']=40;break;case 35:evt['keyCode']=39;break;case 36:evt['keyCode']=37;break;case 45:evt['keyCode']=190;break;case 46:evt['keyCode']=8;break;case 112:evt['keyCode']=49;break;case 113:evt['keyCode']=50;break;case 114:evt['keyCode']=51;break;case 115:evt['keyCode']=52;break;case 116:evt['keyCode']=53;break;case 117:evt['keyCode']=54;break;case 118:evt['keyCode']=55;break;case 119:evt['keyCode']=56;break;case 120:evt['keyCode']=57;break;case 121:evt['keyCode']=48;break;case 122:evt['keyCode']=189;break;case 123:evt['keyCode']=187;break;}
return evt;};goog.provide('cvox.KeyUtil');goog.provide('cvox.SimpleKeyEvent');goog.require('Msgs');goog.require('cvox.ChromeVox');goog.require('cvox.KeySequence');cvox.SimpleKeyEvent;cvox.KeyUtil=function(){};cvox.KeyUtil.modeKeyPressTime=0;cvox.KeyUtil.sequencing=false;cvox.KeyUtil.prevKeySequence=null;cvox.KeyUtil.stickyKeySequence=null;cvox.KeyUtil.maxSeqLength=2;cvox.KeyUtil.keyEventToKeySequence=function(keyEvent){var util=cvox.KeyUtil;if(util.prevKeySequence&&(util.maxSeqLength==util.prevKeySequence.length())){util.sequencing=false;util.prevKeySequence=null;}
var keyIsPrefixed=util.sequencing||keyEvent['keyPrefix']||keyEvent['stickyMode'];var keySequence=new cvox.KeySequence(keyEvent);var keyWasCvox=keySequence.cvoxModifier;if(keyIsPrefixed||keyWasCvox){if(!util.sequencing&&util.isSequenceSwitchKeyCode(keySequence)){util.sequencing=true;util.prevKeySequence=keySequence;return keySequence;}else if(util.sequencing){if(util.prevKeySequence.addKeyEvent(keyEvent)){keySequence=util.prevKeySequence;util.prevKeySequence=null;util.sequencing=false;return keySequence;}else{throw'Think sequencing is enabled, yet util.prevKeySequence already'+'has two key codes'+util.prevKeySequence;}}}else{util.sequencing=false;}
var currTime=new Date().getTime();if(cvox.KeyUtil.isDoubleTapKey(keySequence)&&util.prevKeySequence&&keySequence.equals(util.prevKeySequence)){var prevTime=util.modeKeyPressTime;if(prevTime>0&&currTime-prevTime<300){keySequence=util.prevKeySequence;keySequence.doubleTap=true;util.prevKeySequence=null;util.sequencing=false;if(cvox.ChromeVox.isChromeOS&&keyEvent.keyCode==cvox.KeyUtil.getStickyKeyCode()){cvox.ChromeVox.searchKeyHeld=false;}
return keySequence;}}
util.prevKeySequence=keySequence;util.modeKeyPressTime=currTime;return keySequence;};cvox.KeyUtil.keyCodeToString=function(keyCode){if(keyCode==17){return'Ctrl';}
if(keyCode==18){return'Alt';}
if(keyCode==16){return'Shift';}
if((keyCode==91)||(keyCode==93)){if(cvox.ChromeVox.isChromeOS){return'Search';}else if(cvox.ChromeVox.isMac){return'Cmd';}else{return'Win';}}
if(keyCode==45){return'Insert';}
if(keyCode>=65&&keyCode<=90){return String.fromCharCode(keyCode);}else if(keyCode>=48&&keyCode<=57){return String.fromCharCode(keyCode);}else{return'#'+keyCode;}};cvox.KeyUtil.modStringToKeyCode=function(keyString){switch(keyString){case'Ctrl':return 17;case'Alt':return 18;case'Shift':return 16;case'Cmd':case'Win':return 91;}
return-1;};cvox.KeyUtil.cvoxModKeyCodes=function(){var modKeyCombo=cvox.ChromeVox.modKeyStr.split(/\+/g);var modKeyCodes=modKeyCombo.map(function(keyString){return cvox.KeyUtil.modStringToKeyCode(keyString);});return modKeyCodes;};cvox.KeyUtil.isSequenceSwitchKeyCode=function(rhKeySeq){for(var i=0;i<cvox.ChromeVox.sequenceSwitchKeyCodes.length;i++){var lhKeySeq=cvox.ChromeVox.sequenceSwitchKeyCodes[i];if(lhKeySeq.equals(rhKeySeq)){return true;}}
return false;};cvox.KeyUtil.getReadableNameForKeyCode=function(keyCode){var msg=Msgs.getMsg.bind(Msgs);var cros=cvox.ChromeVox.isChromeOS;if(keyCode==0){return'Power button';}else if(keyCode==17){return'Control';}else if(keyCode==18){return'Alt';}else if(keyCode==16){return'Shift';}else if(keyCode==9){return'Tab';}else if((keyCode==91)||(keyCode==93)){if(cros){return'Search';}else if(cvox.ChromeVox.isMac){return'Cmd';}else{return'Win';}}else if(keyCode==8){return'Backspace';}else if(keyCode==32){return'Space';}else if(keyCode==35){return'end';}else if(keyCode==36){return'home';}else if(keyCode==37){return'Left arrow';}else if(keyCode==38){return'Up arrow';}else if(keyCode==39){return'Right arrow';}else if(keyCode==40){return'Down arrow';}else if(keyCode==45){return'Insert';}else if(keyCode==13){return'Enter';}else if(keyCode==27){return'Escape';}else if(keyCode==112){return cros?msg('back_key'):'F1';}else if(keyCode==113){return cros?msg('forward_key'):'F2';}else if(keyCode==114){return cros?msg('refresh_key'):'F3';}else if(keyCode==115){return cros?msg('toggle_full_screen_key'):'F4';}else if(keyCode==116){return cros?msg('window_overview_key'):'F5';}else if(keyCode==117){return cros?msg('brightness_down_key'):'F6';}else if(keyCode==118){return cros?msg('brightness_up_key'):'F7';}else if(keyCode==119){return cros?msg('volume_mute_key'):'F8';}else if(keyCode==120){return cros?msg('volume_down_key'):'F9';}else if(keyCode==121){return cros?msg('volume_up_key'):'F10';}else if(keyCode==122){return'F11';}else if(keyCode==123){return'F12';}else if(keyCode==186){return'Semicolon';}else if(keyCode==187){return'Equal sign';}else if(keyCode==188){return'Comma';}else if(keyCode==189){return'Dash';}else if(keyCode==190){return'Period';}else if(keyCode==191){return'Forward slash';}else if(keyCode==192){return'Grave accent';}else if(keyCode==219){return'Open bracket';}else if(keyCode==220){return'Back slash';}else if(keyCode==221){return'Close bracket';}else if(keyCode==222){return'Single quote';}else if(keyCode==115){return'Toggle full screen';}else if(keyCode>=48&&keyCode<=90){return String.fromCharCode(keyCode);}
return'';};cvox.KeyUtil.getStickyKeyCode=function(){var stickyKeyCode=45;if(cvox.ChromeVox.isChromeOS||cvox.ChromeVox.isMac){stickyKeyCode=91;}
return stickyKeyCode;};cvox.KeyUtil.getReadableNameForStr=function(keyStr){return null;};cvox.KeyUtil.keySequenceToString=function(keySequence,opt_readableKeyCode,opt_modifiers){var str='';var numKeys=keySequence.length();for(var index=0;index<numKeys;index++){if(str!=''&&!opt_modifiers){str+='>';}else if(str!=''){str+='+';}
var tempStr='';for(var keyPressed in keySequence.keys){if(!keySequence.keys[keyPressed][index]){continue;}
var modifier='';switch(keyPressed){case'ctrlKey':modifier='Ctrl';break;case'searchKeyHeld':var searchKey=cvox.KeyUtil.getReadableNameForKeyCode(91);modifier=searchKey;break;case'altKey':modifier='Alt';break;case'altGraphKey':modifier='AltGraph';break;case'shiftKey':modifier='Shift';break;case'metaKey':var metaKey=cvox.KeyUtil.getReadableNameForKeyCode(91);modifier=metaKey;break;case'keyCode':var keyCode=keySequence.keys[keyPressed][index];if(!keySequence.isModifierKey(keyCode)&&!opt_modifiers){if(opt_readableKeyCode){tempStr+=cvox.KeyUtil.getReadableNameForKeyCode(keyCode);}else{tempStr+=cvox.KeyUtil.keyCodeToString(keyCode);}}}
if(str.indexOf(modifier)==-1){tempStr+=modifier+'+';}}
str+=tempStr;if(str[str.length-1]=='+'){str=str.slice(0,-1);}}
if(keySequence.cvoxModifier||keySequence.prefixKey){if(str!=''){str='ChromeVox+'+str;}else{str='Cvox';}}else if(keySequence.stickyMode){if(str[str.length-1]=='>'){str=str.slice(0,-1);}
str=str+'+'+str;}
return str;};cvox.KeyUtil.isDoubleTapKey=function(key){var isSet=false;var originalState=key.doubleTap;key.doubleTap=true;for(var i=0,keySeq;keySeq=cvox.KeySequence.doubleTapCache[i];i++){if(keySeq.equals(key)){isSet=true;break;}}
key.doubleTap=originalState;return isSet;};goog.provide('cvox.KeyMap');goog.require('cvox.KeyUtil');goog.require('cvox.PlatformUtil');cvox.KeyMap=function(commandsAndKeySequences){this.bindings_=commandsAndKeySequences;this.commandToKey_={};this.buildCommandToKey_();};cvox.KeyMap.KEYMAP_PATH='chromevox/background/keymaps/';cvox.KeyMap.AVAILABLE_MAP_INFO={'keymap_classic':{'file':'classic_keymap.json'},'keymap_flat':{'file':'flat_keymap.json'},'keymap_next':{'file':'next_keymap.json'},'keymap_experimental':{'file':'experimental.json'}};cvox.KeyMap.DEFAULT_KEYMAP=0;cvox.KeyMap.prototype.length=function(){return this.bindings_.length;};cvox.KeyMap.prototype.keys=function(){return this.bindings_.map(function(binding){return binding.sequence;});};cvox.KeyMap.prototype.bindings=function(){return this.bindings_;};cvox.KeyMap.prototype.toJSON=function(){return JSON.stringify({bindings:this.bindings_});};cvox.KeyMap.prototype.toLocalStorage=function(){localStorage['keyBindings']=this.toJSON();};cvox.KeyMap.prototype.hasBinding=function(command,sequence){if(this.commandToKey_!=null){return this.commandToKey_[command]==sequence;}else{for(var i=0;i<this.bindings_.length;i++){var binding=this.bindings_[i];if(binding.command==command&&binding.sequence==sequence){return true;}}}
return false;};cvox.KeyMap.prototype.hasCommand=function(command){if(this.commandToKey_!=null){return this.commandToKey_[command]!=undefined;}else{for(var i=0;i<this.bindings_.length;i++){var binding=this.bindings_[i];if(binding.command==command){return true;}}}
return false;};cvox.KeyMap.prototype.hasKey=function(key){for(var i=0;i<this.bindings_.length;i++){var binding=this.bindings_[i];if(binding.sequence.equals(key)){return true;}}
return false;};cvox.KeyMap.prototype.commandForKey=function(key){if(key!=null){for(var i=0;i<this.bindings_.length;i++){var binding=this.bindings_[i];if(binding.sequence.equals(key)){return binding.command;}}}
return null;};cvox.KeyMap.prototype.keyForCommand=function(command){if(this.commandToKey_!=null){return[this.commandToKey_[command]];}else{var keySequenceArray=[];for(var i=0;i<this.bindings_.length;i++){var binding=this.bindings_[i];if(binding.command==command){keySequenceArray.push(binding.sequence);}}}
return(keySequenceArray.length>0)?keySequenceArray:[];};cvox.KeyMap.prototype.merge=function(inputMap){var keys=inputMap.keys();var cleanMerge=true;for(var i=0;i<keys.length;++i){var key=keys[i];var command=inputMap.commandForKey(key);if(command=='toggleStickyMode'){continue;}else if(key&&command&&!this.hasKey(key)&&!this.hasCommand(command)){this.bind_(command,key);}else{cleanMerge=false;}}
return cleanMerge;};cvox.KeyMap.prototype.rebind=function(command,newKey){if(this.hasCommand(command)&&!this.hasKey(newKey)){this.bind_(command,newKey);return true;}
return false;};cvox.KeyMap.prototype.bind_=function(command,newKey){var bound=false;for(var i=0;i<this.bindings_.length;i++){var binding=this.bindings_[i];if(binding.command==command){delete binding.sequence;binding.sequence=newKey;if(this.commandToKey_!=null){this.commandToKey_[binding.command]=newKey;}
bound=true;}}
if(!bound){var binding={'command':command,'sequence':newKey};this.bindings_.push(binding);this.commandToKey_[binding.command]=binding.sequence;}};cvox.KeyMap.fromDefaults=function(){return(cvox.KeyMap.fromPath(cvox.KeyMap.KEYMAP_PATH+
cvox.KeyMap.AVAILABLE_MAP_INFO['keymap_classic'].file));};cvox.KeyMap.fromNext=function(){return cvox.KeyMap.fromPath(cvox.KeyMap.KEYMAP_PATH+
cvox.KeyMap.AVAILABLE_MAP_INFO['keymap_next'].file);};cvox.KeyMap.fromJSON=function(json){try{var commandsAndKeySequences=(JSON.parse(json).bindings);commandsAndKeySequences=commandsAndKeySequences.filter(function(value){return value.sequence.platformFilter===undefined||cvox.PlatformUtil.matchesPlatform(value.sequence.platformFilter);});}catch(e){console.error('Failed to load key map from JSON');console.error(e);return null;}
if(typeof(commandsAndKeySequences)!='object'){return null;}
for(var i=0;i<commandsAndKeySequences.length;i++){if(commandsAndKeySequences[i].command==undefined||commandsAndKeySequences[i].sequence==undefined){return null;}else{commandsAndKeySequences[i].sequence=(cvox.KeySequence.deserialize(commandsAndKeySequences[i].sequence));}}
return new cvox.KeyMap(commandsAndKeySequences);};cvox.KeyMap.fromLocalStorage=function(){if(localStorage['keyBindings']){return cvox.KeyMap.fromJSON(localStorage['keyBindings']);}
return null;};cvox.KeyMap.fromPath=function(path){return cvox.KeyMap.fromJSON(cvox.KeyMap.readJSON_(path));};cvox.KeyMap.fromCurrentKeyMap=function(){var map=localStorage['currentKeyMap'];if(map&&cvox.KeyMap.AVAILABLE_MAP_INFO[map]){return(cvox.KeyMap.fromPath(cvox.KeyMap.KEYMAP_PATH+cvox.KeyMap.AVAILABLE_MAP_INFO[map].file));}else{return cvox.KeyMap.fromDefaults();}};cvox.KeyMap.readJSON_=function(path){var url=chrome.extension.getURL(path);if(!url){throw'Invalid path: '+path;}
var xhr=new XMLHttpRequest();xhr.open('GET',url,false);xhr.send();return xhr.responseText;};cvox.KeyMap.prototype.resetModifier=function(){localStorage['cvoxKey']=cvox.ChromeVox.modKeyStr;};cvox.KeyMap.prototype.buildCommandToKey_=function(){for(var i=0;i<this.bindings_.length;i++){var binding=this.bindings_[i];if(this.commandToKey_[binding.command]!=undefined){continue;}
this.commandToKey_[binding.command]=binding.sequence;}};goog.provide('cvox.ChromeVoxPrefs');goog.require('cvox.ChromeVox');goog.require('cvox.ExtensionBridge');goog.require('cvox.KeyMap');cvox.ChromeVoxPrefs=function(){var lastRunVersion=localStorage['lastRunVersion'];if(!lastRunVersion){lastRunVersion='1.16.0';}
var loadExistingSettings=true;if(lastRunVersion=='1.16.0'){loadExistingSettings=false;}
localStorage['lastRunVersion']=chrome.runtime.getManifest().version;this.keyMap_=cvox.KeyMap.fromLocalStorage()||cvox.KeyMap.fromDefaults();this.keyMap_.merge(cvox.KeyMap.fromDefaults());localStorage['position']='{}';localStorage['sticky']=false;this.init(loadExistingSettings);};cvox.ChromeVoxPrefs.DEFAULT_PREFS={'active':true,'brailleCaptions':false,'currentKeyMap':cvox.KeyMap.DEFAULT_KEYMAP,'cvoxKey':'','earcons':true,'focusFollowsMouse':false,'granularity':undefined,'outputContextFirst':false,'position':'{}','siteSpecificScriptBase':'https://ssl.gstatic.com/accessibility/javascript/ext/','siteSpecificScriptLoader':'https://ssl.gstatic.com/accessibility/javascript/ext/loader.js','sticky':false,'typingEcho':0,'useIBeamCursor':cvox.ChromeVox.isMac,'useVerboseMode':true,'siteSpecificEnhancements':true,'useNext':false};cvox.ChromeVoxPrefs.prototype.init=function(pullFromLocalStorage){for(var pref in cvox.ChromeVoxPrefs.DEFAULT_PREFS){if(localStorage[pref]===undefined){localStorage[pref]=cvox.ChromeVoxPrefs.DEFAULT_PREFS[pref];}}};cvox.ChromeVoxPrefs.prototype.switchToKeyMap=function(selectedKeyMap){localStorage['currentKeyMap']=selectedKeyMap;this.keyMap_=cvox.KeyMap.fromCurrentKeyMap();cvox.ChromeVoxKbHandler.handlerKeyMap=this.keyMap_;this.keyMap_.toLocalStorage();this.keyMap_.resetModifier();this.sendPrefsToAllTabs(false,true);};cvox.ChromeVoxPrefs.prototype.getPrefs=function(){var prefs={};for(var pref in cvox.ChromeVoxPrefs.DEFAULT_PREFS){prefs[pref]=localStorage[pref];}
prefs['version']=chrome.runtime.getManifest().version;return prefs;};cvox.ChromeVoxPrefs.prototype.reloadKeyMap=function(){var currentKeyMap=cvox.KeyMap.fromLocalStorage();if(!currentKeyMap){currentKeyMap=cvox.KeyMap.fromCurrentKeyMap();currentKeyMap.toLocalStorage();}
this.keyMap_=currentKeyMap;};cvox.ChromeVoxPrefs.prototype.getKeyMap=function(){return this.keyMap_;};cvox.ChromeVoxPrefs.prototype.resetKeys=function(){this.keyMap_=cvox.KeyMap.fromDefaults();this.keyMap_.toLocalStorage();this.sendPrefsToAllTabs(false,true);};cvox.ChromeVoxPrefs.prototype.sendPrefsToAllTabs=function(sendPrefs,sendKeyBindings){var context=this;var message={};if(sendPrefs){message['prefs']=context.getPrefs();}
if(sendKeyBindings){message['keyBindings']=this.keyMap_.toJSON();}
chrome.windows.getAll({populate:true},function(windows){for(var i=0;i<windows.length;i++){var tabs=windows[i].tabs;for(var j=0;j<tabs.length;j++){chrome.tabs.sendMessage(tabs[j].id,message);}}});};cvox.ChromeVoxPrefs.prototype.sendPrefsToPort=function(port){port.postMessage({'keyBindings':this.keyMap_.toJSON(),'prefs':this.getPrefs()});};cvox.ChromeVoxPrefs.prototype.setPref=function(key,value){if(localStorage[key]!=value){localStorage[key]=value;this.sendPrefsToAllTabs(true,false);}};cvox.ChromeVoxPrefs.prototype.setKey=function(command,newKey){if(this.keyMap_.rebind(command,newKey)){this.keyMap_.toLocalStorage();this.sendPrefsToAllTabs(false,true);return true;}
return false;};goog.provide('cvox.ClassicEarcons');goog.require('cvox.AbstractEarcons');cvox.ClassicEarcons=function(){goog.base(this);if(localStorage['earcons']==='false'){cvox.AbstractEarcons.enabled=false;}
this.audioMap=new Object();};goog.inherits(cvox.ClassicEarcons,cvox.AbstractEarcons);cvox.ClassicEarcons.prototype.getName=function(){return'ChromeVox earcons';};cvox.ClassicEarcons.prototype.getBaseUrl=function(){return cvox.ClassicEarcons.BASE_URL;};cvox.ClassicEarcons.prototype.playEarcon=function(earcon){goog.base(this,'playEarcon',earcon);if(!cvox.AbstractEarcons.enabled){return;}
console.log('Earcon '+earcon);this.currentAudio=this.audioMap[earcon];if(!this.currentAudio){this.currentAudio=new Audio(chrome.extension.getURL(this.getBaseUrl()+
earcon+'.ogg'));this.audioMap[earcon]=this.currentAudio;}
try{this.currentAudio.currentTime=0;}catch(e){}
if(this.currentAudio.paused){this.currentAudio.volume=0.7;this.currentAudio.play();}};cvox.ClassicEarcons.prototype.cancelEarcon=function(earcon){};cvox.ClassicEarcons.BASE_URL='chromevox/background/earcons/';goog.provide('cvox.CompositeTts');goog.require('cvox.TtsInterface');cvox.CompositeTts=function(){this.ttsEngines_=[];};cvox.CompositeTts.prototype.add=function(tts){this.ttsEngines_.push(tts);return this;};cvox.CompositeTts.prototype.speak=function(textString,queueMode,properties){this.ttsEngines_.forEach(function(engine){engine.speak(textString,queueMode,properties);});return this;};cvox.CompositeTts.prototype.isSpeaking=function(){return this.ttsEngines_.some(function(engine){return engine.isSpeaking();});};cvox.CompositeTts.prototype.stop=function(){this.ttsEngines_.forEach(function(engine){engine.stop();});};cvox.CompositeTts.prototype.addCapturingEventListener=function(listener){this.ttsEngines_.forEach(function(engine){engine.addCapturingEventListener(listener);});};cvox.CompositeTts.prototype.increaseOrDecreaseProperty=function(propertyName,increase){this.ttsEngines_.forEach(function(engine){engine.increaseOrDecreaseProperty(propertyName,increase);});};cvox.CompositeTts.prototype.propertyToPercentage=function(property){for(var i=0,engine;engine=this.ttsEngines_[i];i++){var value=engine.propertyToPercentage(property);if(value!==undefined)
return value;}
return null;};cvox.CompositeTts.prototype.getDefaultProperty=function(property){for(var i=0,engine;engine=this.ttsEngines_[i];i++){var value=engine.getDefaultProperty(property);if(value!==undefined)
return value;}
return null;};goog.provide('cvox.ConsoleTts');goog.require('cvox.AbstractTts');goog.require('cvox.TtsInterface');cvox.ConsoleTts=function(){this.enabled_=false;};goog.addSingletonGetter(cvox.ConsoleTts);cvox.ConsoleTts.prototype.speak=function(textString,queueMode,properties){if(this.enabled_&&window['console']){var logStr='Speak';if(queueMode==cvox.QueueMode.FLUSH){logStr+=' (I)';}else if(queueMode==cvox.QueueMode.CATEGORY_FLUSH){logStr+=' (C)';}else{logStr+=' (Q)';}
if(properties&&properties.category){logStr+=' category='+properties.category;}
logStr+=' "'+textString+'"';console.log(logStr);}
return this;};cvox.ConsoleTts.prototype.isSpeaking=function(){return false;};cvox.ConsoleTts.prototype.stop=function(){if(this.enabled_){console.log('Stop');}};cvox.ConsoleTts.prototype.addCapturingEventListener=function(listener){};cvox.ConsoleTts.prototype.increaseOrDecreaseProperty=function(){};cvox.ConsoleTts.prototype.propertyToPercentage=function(){};cvox.ConsoleTts.prototype.setEnabled=function(enabled){this.enabled_=enabled;};cvox.ConsoleTts.prototype.getDefaultProperty=function(property){};goog.provide('cvox.InjectedScriptLoader');cvox.InjectedScriptLoader=function(){};cvox.InjectedScriptLoader.fetchCode=function(files,done){var code={};var waiting=files.length;var startTime=new Date();var loadScriptAsCode=function(src){var xhr=new XMLHttpRequest();var url=chrome.extension.getURL(src)+'?'+new Date().getTime();xhr.onreadystatechange=function(){if(xhr.readyState==4){code[src]=xhr.responseText;waiting--;if(waiting==0){done(code);}}};xhr.open('GET',url);xhr.send(null);};files.forEach(function(f){loadScriptAsCode(f);});};goog.provide('AutomationObjectConstructorInstaller');AutomationObjectConstructorInstaller.init=function(node,callback){chrome.automation.AutomationNode=(node.constructor);node.addEventListener(chrome.automation.EventType.CHILDREN_CHANGED,function installAutomationEvent(e){chrome.automation.AutomationEvent=(e.constructor);node.removeEventListener(chrome.automation.EventType.CHILDREN_CHANGED,installAutomationEvent,true);callback();},true);};goog.provide('BaseAutomationHandler');goog.scope(function(){var AutomationEvent=chrome.automation.AutomationEvent;var AutomationNode=chrome.automation.AutomationNode;var EventType=chrome.automation.EventType;BaseAutomationHandler=function(node){this.node_=node;this.listeners_={};};BaseAutomationHandler.prototype={addListener_:function(eventType,eventCallback){if(this.listeners_[eventType]){var e=new Error();throw'Listener already added: '+eventType+' '+e.stack;}
var listener=this.makeListener_(eventCallback.bind(this));this.node_.addEventListener(eventType,listener,true);this.listeners_[eventType]=listener;},removeAllListeners:function(){for(var eventType in this.listeners_){this.node_.removeEventListener(eventType,this.listeners_[eventType],true);}},makeListener_:function(callback){return function(evt){if(this.willHandleEvent_(evt))
return;callback(evt);this.didHandleEvent_(evt);}.bind(this);},willHandleEvent_:function(evt){return false;},didHandleEvent_:function(evt){}};});goog.provide('editing.TextEditHandler');goog.require('AutomationTreeWalker');goog.require('AutomationUtil');goog.require('Output');goog.require('Output.EventType');goog.require('cursors.Cursor');goog.require('cursors.Range');goog.require('cvox.ChromeVoxEditableTextBase');goog.scope(function(){var AutomationEvent=chrome.automation.AutomationEvent;var AutomationNode=chrome.automation.AutomationNode;var Cursor=cursors.Cursor;var Dir=AutomationUtil.Dir;var EventType=chrome.automation.EventType;var Range=cursors.Range;var RoleType=chrome.automation.RoleType;var Movement=cursors.Movement;var Unit=cursors.Unit;editing.TextEditHandler=function(node){this.node_=node;};editing.TextEditHandler.prototype={get node(){return this.node_;},onEvent:goog.abstractMethod,};function TextFieldTextEditHandler(node){editing.TextEditHandler.call(this,node);this.editableText_=new AutomationEditableText(node);}
TextFieldTextEditHandler.prototype={__proto__:editing.TextEditHandler.prototype,onEvent:function(evt){if(evt.type!==EventType.TEXT_CHANGED&&evt.type!==EventType.TEXT_SELECTION_CHANGED&&evt.type!==EventType.VALUE_CHANGED&&evt.type!==EventType.FOCUS)
return;if(!evt.target.state.focused||!evt.target.state.editable||evt.target!=this.node_)
return;this.editableText_.onUpdate();},};function AutomationEditableText(node){if(!node.state.editable)
throw Error('Node must have editable state set to true.');var start=node.textSelStart;var end=node.textSelEnd;cvox.ChromeVoxEditableTextBase.call(this,node.value,Math.min(start,end),Math.max(start,end),node.state.protected,cvox.ChromeVox.tts);this.multiline=node.state.multiline||false;this.node_=node;}
AutomationEditableText.prototype={__proto__:cvox.ChromeVoxEditableTextBase.prototype,onUpdate:function(){var newValue=this.node_.value;var textChangeEvent=new cvox.TextChangeEvent(newValue,this.node_.textSelStart,this.node_.textSelEnd,true);this.changed(textChangeEvent);this.outputBraille_();},getLineIndex:function(charIndex){if(!this.multiline)
return 0;var breaks=this.node_.lineBreaks||[];var index=0;while(index<breaks.length&&breaks[index]<=charIndex)
++index;return index;},getLineStart:function(lineIndex){if(!this.multiline||lineIndex==0)
return 0;var breaks=this.getLineBreaks_();return breaks[lineIndex-1]||this.node_.value.length;},getLineEnd:function(lineIndex){var breaks=this.getLineBreaks_();var value=this.node_.value;if(lineIndex>=breaks.length)
return value.length;var end=breaks[lineIndex];if(0<end&&value[end-1]=='\n')
return end-1;return end;},getLineBreaks_:function(){return this.node_.lineBreaks||[];},outputBraille_:function(){var isFirstLine=false;var output=new Output();var range;if(this.multiline){var lineIndex=this.getLineIndex(this.start);if(lineIndex==0){isFirstLine=true;output.formatForBraille('$name',this.node_);}
range=new Range(new Cursor(this.node_,this.getLineStart(lineIndex)),new Cursor(this.node_,this.getLineEnd(lineIndex)));}else{range=Range.fromNode(this.node_);}
output.withBraille(range,null,Output.EventType.NAVIGATE);if(isFirstLine)
output.formatForBraille('@tag_textarea');output.go();}};editing.TextEditHandler.createForNode=function(node){var rootFocusedEditable=null;var testNode=node;do{if(testNode.state.focused&&testNode.state.editable)
rootFocusedEditable=testNode;testNode=testNode.parent;}while(testNode);if(rootFocusedEditable)
return new TextFieldTextEditHandler(rootFocusedEditable);return null;};});goog.provide('DesktopAutomationHandler');goog.require('AutomationObjectConstructorInstaller');goog.require('BaseAutomationHandler');goog.require('ChromeVoxState');goog.require('editing.TextEditHandler');goog.scope(function(){var AutomationEvent=chrome.automation.AutomationEvent;var AutomationNode=chrome.automation.AutomationNode;var Dir=constants.Dir;var EventType=chrome.automation.EventType;var RoleType=chrome.automation.RoleType;DesktopAutomationHandler=function(node){BaseAutomationHandler.call(this,node);this.textEditHandler_=null;this.lastValueChanged_=new Date(0);var e=EventType;this.addListener_(e.ACTIVE_DESCENDANT_CHANGED,this.onActiveDescendantChanged);this.addListener_(e.ALERT,this.onAlert);this.addListener_(e.ARIA_ATTRIBUTE_CHANGED,this.onEventIfInRange);this.addListener_(e.CHECKED_STATE_CHANGED,this.onEventIfInRange);this.addListener_(e.FOCUS,this.onFocus);this.addListener_(e.HOVER,this.onHover);this.addListener_(e.LOAD_COMPLETE,this.onLoadComplete);this.addListener_(e.MENU_END,this.onMenuEnd);this.addListener_(e.MENU_LIST_ITEM_SELECTED,this.onEventIfSelected);this.addListener_(e.MENU_START,this.onMenuStart);this.addListener_(e.SCROLL_POSITION_CHANGED,this.onScrollPositionChanged);this.addListener_(e.SELECTION,this.onSelection);this.addListener_(e.TEXT_CHANGED,this.onTextChanged);this.addListener_(e.TEXT_SELECTION_CHANGED,this.onTextSelectionChanged);this.addListener_(e.VALUE_CHANGED,this.onValueChanged);AutomationObjectConstructorInstaller.init(node,function(){chrome.automation.getFocus((function(focus){if(ChromeVoxState.instance.mode!=ChromeVoxMode.FORCE_NEXT)
return;if(focus){this.onFocus(new chrome.automation.AutomationEvent(EventType.FOCUS,focus));}}).bind(this));}.bind(this));};DesktopAutomationHandler.VMIN_VALUE_CHANGE_DELAY_MS=500;DesktopAutomationHandler.prototype={__proto__:BaseAutomationHandler.prototype,willHandleEvent_:function(evt){return!cvox.ChromeVox.isActive;},onEventDefault:function(evt){var node=evt.target;if(!node)
return;var prevRange=ChromeVoxState.instance.currentRange;ChromeVoxState.instance.setCurrentRange(cursors.Range.fromNode(node));if(node.root.role!=RoleType.DESKTOP&&ChromeVoxState.instance.mode===ChromeVoxMode.CLASSIC){if(cvox.ChromeVox.isChromeOS)
chrome.accessibilityPrivate.setFocusRing([]);return;}
if(prevRange&&evt.type=='focus'&&ChromeVoxState.instance.currentRange.equals(prevRange))
return;var output=new Output();output.withRichSpeech(ChromeVoxState.instance.currentRange,prevRange,evt.type);if(!this.textEditHandler_){output.withBraille(ChromeVoxState.instance.currentRange,prevRange,evt.type);}else{this.textEditHandler_.onEvent(evt);}
output.go();},onEventIfInRange:function(evt){if(AutomationUtil.isDescendantOf(ChromeVoxState.instance.currentRange.start.node,evt.target)||evt.target.state.focused)
this.onEventDefault(evt);},onEventIfSelected:function(evt){if(evt.target.state.selected)
this.onEventDefault(evt);},onEventWithFlushedOutput:function(evt){Output.flushNextSpeechUtterance();this.onEventDefault(evt);},onHover:function(evt){if(ChromeVoxState.instance.currentRange&&evt.target==ChromeVoxState.instance.currentRange.start.node)
return;Output.flushNextSpeechUtterance();this.onEventDefault(evt);},onActiveDescendantChanged:function(evt){if(!evt.target.activeDescendant)
return;this.onEventDefault(new chrome.automation.AutomationEvent(EventType.FOCUS,evt.target.activeDescendant));},onAlert:function(evt){var node=evt.target;if(!node)
return;if(node.root.role!=RoleType.DESKTOP&&ChromeVoxState.instance.mode===ChromeVoxMode.CLASSIC){return;}
var range=cursors.Range.fromNode(node);new Output().withSpeechAndBraille(range,null,evt.type).go();},onFocus:function(evt){this.textEditHandler_=null;var node=evt.target;if(node.role==RoleType.EMBEDDED_OBJECT||node.role==RoleType.CLIENT||node.role==RoleType.PLUGIN_OBJECT)
return;this.createTextEditHandlerIfNeeded_(evt.target);if(node.root.role==RoleType.DESKTOP)
Output.flushNextSpeechUtterance();this.onEventDefault(new chrome.automation.AutomationEvent(EventType.FOCUS,node));},onLoadComplete:function(evt){if(evt.target.root.role!=RoleType.DESKTOP&&ChromeVoxState.instance.mode===ChromeVoxMode.CLASSIC)
return;chrome.automation.getFocus(function(focus){if(!focus||!AutomationUtil.isDescendantOf(focus,evt.target))
return;if(ChromeVoxState.instance.currentRange&&ChromeVoxState.instance.currentRange.start.node.root==focus.root)
return;var o=new Output();if(focus.role==RoleType.ROOT_WEB_AREA){var url=focus.docUrl;url=url.substring(0,url.indexOf('#'))||url;var pos=cvox.ChromeVox.position[url];if(pos){focus=AutomationUtil.hitTest(focus.root,pos)||focus;if(focus!=focus.root)
o.format('$name',focus.root);}}
ChromeVoxState.instance.setCurrentRange(cursors.Range.fromNode(focus));o.withRichSpeechAndBraille(ChromeVoxState.instance.currentRange,null,evt.type).go();}.bind(this));},onTextChanged:function(evt){if(evt.target.state.editable)
this.onEditableChanged_(evt);},onTextSelectionChanged:function(evt){if(evt.target.state.editable)
this.onEditableChanged_(evt);},onEditableChanged_:function(evt){if(evt.target.root.role!=RoleType.DESKTOP&&ChromeVoxState.instance.mode===ChromeVoxMode.CLASSIC)
return;if(!evt.target.state.focused)
return;if(!ChromeVoxState.instance.currentRange){this.onEventDefault(evt);ChromeVoxState.instance.setCurrentRange(cursors.Range.fromNode(evt.target));}
this.createTextEditHandlerIfNeeded_(evt.target);if(this.textEditHandler_)
this.textEditHandler_.onEvent(evt);},onValueChanged:function(evt){if(evt.target.state.editable){this.onEditableChanged_(evt);return;}
if(evt.target.root.role!=RoleType.DESKTOP&&ChromeVoxState.instance.mode===ChromeVoxMode.CLASSIC)
return;var t=evt.target;if(t.state.focused||t.root.role==RoleType.DESKTOP||AutomationUtil.isDescendantOf(ChromeVoxState.instance.currentRange.start.node,t)){if(new Date()-this.lastValueChanged_<=DesktopAutomationHandler.VMIN_VALUE_CHANGE_DELAY_MS)
return;this.lastValueChanged_=new Date();new Output().format('$value',evt.target).go();}},onScrollPositionChanged:function(evt){if(ChromeVoxState.instance.mode===ChromeVoxMode.CLASSIC)
return;var currentRange=ChromeVoxState.instance.currentRange;if(currentRange&¤tRange.isValid())
new Output().withLocation(currentRange,null,evt.type).go();},onSelection:function(evt){chrome.automation.getFocus(function(focus){var override=evt.target.role==RoleType.MENU_ITEM||(evt.target.root==focus.root&&focus.root.role==RoleType.DESKTOP);Output.flushNextSpeechUtterance();if(override||AutomationUtil.isDescendantOf(evt.target,focus))