UNPKG

bible-ref-parse

Version:

Identifies and parses Bible references (like John 3:16) in over 40 languages.

1 lines 124 kB
(function(){var e,s,a,t,n={}.hasOwnProperty;e=function(){class e{constructor(){var s,a,t;for(s in this.options={},a=e.prototype.options)n.call(a,s)&&(t=a[s],this.options[s]=t);this.versification_system(this.options.versification_system)}parse(e){return this.reset(),this.s=e,e=this.replace_control_characters(e),[e,this.passage.books]=this.match_books(e),[this.entities]=this.match_passages(e),this}parse_with_context(e,s){var a;return this.reset(),[s,this.passage.books]=this.match_books(this.replace_control_characters(s)),[a,s]=this.match_passages(s),this.reset(),this.s=e,e=this.replace_control_characters(e),[e,this.passage.books]=this.match_books(e),this.passage.books.push({value:"",parsed:[],start_index:0,type:"context",context:s}),e=""+(this.passage.books.length-1)+"/9"+e,[this.entities]=this.match_passages(e),this}reset(){return this.s="",this.entities=[],this.passage?(this.passage.books=[],this.passage.indices={}):(this.passage=new s,this.passage.options=this.options,this.passage.translations=this.translations)}set_options(e){var s,a;for(s in e)n.call(e,s)&&(a=e[s],"include_apocrypha"===s||"versification_system"===s||"case_sensitive"===s?this[s](a):this.options[s]=a);return this}include_apocrypha(e){var s,t,i,o,r;if(null==e||!0!==e&&!1!==e)return this;for(o in this.options.include_apocrypha=e,this.regexps.books=this.regexps.get_books(e,this.options.case_sensitive),i=this.translations)n.call(i,o)&&"aliases"!==o&&"alternates"!==o&&(null==(s=this.translations[o]).chapters&&(s.chapters={}),null==(t=this.translations[o].chapters).Ps&&(t.Ps=a.shallow_clone_array(this.translations.default.chapters.Ps)),!0===e?(r=null!=this.translations[o].chapters.Ps151?this.translations[o].chapters.Ps151[0]:this.translations.default.chapters.Ps151[0],this.translations[o].chapters.Ps[150]=r):151===this.translations[o].chapters.Ps.length&&this.translations[o].chapters.Ps.pop());return this}versification_system(e){var s,t,i,o,r,l,h;if(null==e||null==this.translations[e])return this;if(null!=this.translations.alternates.default)if("default"===e)for(o in null!=this.translations.alternates.default.order&&(this.translations.default.order=a.shallow_clone(this.translations.alternates.default.order)),l=this.translations.alternates.default.chapters)n.call(l,o)&&(r=l[o],this.translations.default.chapters[o]=a.shallow_clone_array(r));else this.versification_system("default");if(null==(s=this.translations.alternates).default&&(s.default={order:null,chapters:{}}),"default"!==e&&null!=this.translations[e].order&&(null==(t=this.translations.alternates.default).order&&(t.order=a.shallow_clone(this.translations.default.order)),this.translations.default.order=a.shallow_clone(this.translations[e].order)),"default"!==e&&null!=this.translations[e].chapters)for(o in h=this.translations[e].chapters)n.call(h,o)&&(r=h[o],null==(i=this.translations.alternates.default.chapters)[o]&&(i[o]=a.shallow_clone_array(this.translations.default.chapters[o])),this.translations.default.chapters[o]=a.shallow_clone_array(r));return this.options.versification_system=e,this.include_apocrypha(this.options.include_apocrypha),this}case_sensitive(e){return null==e||"none"!==e&&"books"!==e||e===this.options.case_sensitive||(this.options.case_sensitive=e,this.regexps.books=this.regexps.get_books(this.options.include_apocrypha,e)),this}translation_info(e="default"){var s,t,i,o,r,l,h,u;for(s in null!=e&&null!=(null!=(l=this.translations.aliases[e])?l.alias:void 0)&&(e=this.translations.aliases[e].alias),null!=e&&null!=this.translations[e]||(e="default"),e!==(o=this.options.versification_system)&&this.versification_system(e),r={alias:e,books:[],chapters:{},order:a.shallow_clone(this.translations.default.order)},h=this.translations.default.chapters)n.call(h,s)&&(t=h[s],r.chapters[s]=a.shallow_clone_array(t));for(s in u=r.order)n.call(u,s)&&(i=u[s],r.books[i-1]=s);return e!==o&&this.versification_system(o),r}replace_control_characters(e){return e=e.replace(this.regexps.control," "),"replace"===this.options.non_latin_digits_strategy&&(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/[٠۰߀०০੦૦୦0౦೦൦๐໐༠၀႐០᠐᥆᧐᪀᪐᭐᮰᱀᱐꘠꣐꤀꧐꩐꯰0]/g,"0")).replace(/[١۱߁१১੧૧୧௧౧೧൧๑໑༡၁႑១᠑᥇᧑᪁᪑᭑᮱᱁᱑꘡꣑꤁꧑꩑꯱1]/g,"1")).replace(/[٢۲߂२২੨૨୨௨౨೨൨๒໒༢၂႒២᠒᥈᧒᪂᪒᭒᮲᱂᱒꘢꣒꤂꧒꩒꯲2]/g,"2")).replace(/[٣۳߃३৩੩૩୩௩౩೩൩๓໓༣၃႓៣᠓᥉᧓᪃᪓᭓᮳᱃᱓꘣꣓꤃꧓꩓꯳3]/g,"3")).replace(/[٤۴߄४৪੪૪୪௪౪೪൪๔໔༤၄႔៤᠔᥊᧔᪄᪔᭔᮴᱄᱔꘤꣔꤄꧔꩔꯴4]/g,"4")).replace(/[٥۵߅५৫੫૫୫௫౫೫൫๕໕༥၅႕៥᠕᥋᧕᪅᪕᭕᮵᱅᱕꘥꣕꤅꧕꩕꯵5]/g,"5")).replace(/[٦۶߆६৬੬૬୬௬౬೬൬๖໖༦၆႖៦᠖᥌᧖᪆᪖᭖᮶᱆᱖꘦꣖꤆꧖꩖꯶6]/g,"6")).replace(/[٧۷߇७৭੭૭୭௭౭೭൭๗໗༧၇႗៧᠗᥍᧗᪇᪗᭗᮷᱇᱗꘧꣗꤇꧗꩗꯷7]/g,"7")).replace(/[٨۸߈८৮੮૮୮௮౮೮൮๘໘༨၈႘៨᠘᥎᧘᪈᪘᭘᮸᱈᱘꘨꣘꤈꧘꩘꯸8]/g,"8")).replace(/[٩۹߉९৯੯૯୯௯౯೯൯๙໙༩၉႙៩᠙᥏᧙᪉᪙᭙᮹᱉᱙꘩꣙꤉꧙꩙꯹9]/g,"9")),e}match_books(e){var s,a,t,n,i,o;for(a=[],n=0,i=(o=this.regexps.books).length;n<i&&(s=o[n],t=!1,e=e.replace(s.regexp,(function(e,n,i){var o;return t=!0,a.push({value:i,parsed:s.osis,type:"book"}),o=null!=s.extra?`/${s.extra}`:"",`${n}${a.length-1}${o}`})),!0!==t||!/^[\s\x1f\d:.,;\-\u2013\u2014]+$/.test(e));n++);return[e=e.replace(this.regexps.translations,(function(e){return a.push({value:e,parsed:e.toLowerCase(),type:"translation"}),`${a.length-1}`})),this.get_book_indices(a,e)]}get_book_indices(e,s){var a,t,n;for(a=0,n=/([\x1f\x1e])(\d+)(?:\/\d+)?\1/g;t=n.exec(s);)e[t[2]].start_index=t.index+a,a+=e[t[2]].value.length-t[0].length;return e}match_passages(e){var s,a,n,i,o,r,l,h,u,c,p,x;for(n=[],c={};o=this.regexps.escaped_passage.exec(e);)[i,h,a]=o,l=h.length,o.index+=i.length-l,/\s[2-9]\d\d\s*$|\s\d{4,}\s*$/.test(h)&&(h=h.replace(/\s+\d+\s*$/,"")),/[\d\x1f\x1e)]$/.test(h)||(h=this.replace_match_end(h)),"delete"===this.options.captive_end_digits_strategy&&(r=o.index+h.length,e.length>r&&/^\w/.test(e.substr(r,1))&&(h=h.replace(/[\s*]+\d+$/,"")),h=h.replace(/(\x1e[)\]]?)[\s*]*\d+$/,"$1")),x=""===(h=h.replace(/[A-Z]+/g,(function(e){return e.toLowerCase()}))).substr(0,1)?0:h.split("")[0].length,u={value:t.parse(h,{punctuation_strategy:this.options.punctuation_strategy}),type:"base",start_index:this.passage.books[a].start_index-x,match:h},"full"===this.options.book_alone_strategy&&"include"===this.options.book_range_strategy&&"b"===u.value[0].type&&(1===u.value.length||u.value.length>1&&"translation_sequence"===u.value[1].type)&&0===x&&(1===this.passage.books[a].parsed.length||this.passage.books[a].parsed.length>1&&"translation"===this.passage.books[a].parsed[1].type)&&/^[234]/.test(this.passage.books[a].parsed[0])&&this.create_book_range(e,u,a),[s,c]=this.passage.handle_obj(u),n=n.concat(s),(p=this.adjust_regexp_end(s,l,h.length))>0&&(this.regexps.escaped_passage.lastIndex-=p);return[n,c]}adjust_regexp_end(e,s,a){var t;return t=0,e.length>0?t=s-e[e.length-1].indices[1]-1:s!==a&&(t=s-a),t}replace_match_end(e){var s,a;for(a=e.length;s=this.regexps.match_end_split.exec(e);)a=s.index+s[0].length;return a<e.length&&(e=e.substr(0,a)),e}create_book_range(s,a,t){var n,i,o,r,l,h,u;for(n=[e.prototype.regexps.first,e.prototype.regexps.second,e.prototype.regexps.third],i=o=1,u=r=parseInt(this.passage.books[t].parsed[0].substr(0,1),10);1<=u?o<u:o>u;i=1<=u?++o:--o)if(h=i===r-1?e.prototype.regexps.range_and:e.prototype.regexps.range_only,null!=(l=s.match(RegExp(`(?:^|\\W)(${n[i-1]}\\s*${h}\\s*)\\x1f${t}\\x1f`,"i"))))return this.add_book_range_object(a,l,i);return!1}add_book_range_object(e,s,a){var t,n,i,o,r,l;if(i=s[1].length,e.value[0]={type:"b_range_pre",value:[{type:"b_pre",value:a.toString(),indices:[s.index,s.index+i]},e.value[0]],indices:[0,e.value[0].indices[1]+i]},e.value[0].value[1].indices[0]+=i,e.value[0].value[1].indices[1]+=i,e.start_index-=i,e.match=s[1]+e.match,1!==e.value.length){for(l=[],t=n=1,o=e.value.length;1<=o?n<o:n>o;t=1<=o?++n:--n)null!=e.value[t].value&&(null!=(null!=(r=e.value[t].value[0])?r.indices:void 0)&&(e.value[t].value[0].indices[0]+=i,e.value[t].value[0].indices[1]+=i),e.value[t].indices[0]+=i,l.push(e.value[t].indices[1]+=i));return l}}osis(){var e,s,a,t,n;for(t=[],e=0,s=(n=this.parsed_entities()).length;e<s;e++)(a=n[e]).osis.length>0&&t.push(a.osis);return t.join(",")}osis_and_translations(){var e,s,a,t,n;for(t=[],e=0,s=(n=this.parsed_entities()).length;e<s;e++)(a=n[e]).osis.length>0&&t.push([a.osis,a.translations.join(",")]);return t}osis_and_indices(){var e,s,a,t,n;for(t=[],e=0,s=(n=this.parsed_entities()).length;e<s;e++)(a=n[e]).osis.length>0&&t.push({osis:a.osis,translations:a.translations,indices:a.indices});return t}parsed_entities(){var e,s,a,t,n,i,o,r,l,h,u,c,p,x,g,_,d,f,b,v,y,m,k,$;for(x=[],s=t=0,_=this.entities.length;0<=_?t<_:t>_;s=0<=_?++t:--t)if((e=this.entities[s]).type&&"translation_sequence"===e.type&&x.length>0&&s===x[x.length-1].entity_id+1&&(x[x.length-1].indices[1]=e.absolute_indices[1]),null!=e.passages&&!("b"===e.type&&"ignore"===this.options.book_alone_strategy||"b_range"===e.type&&"ignore"===this.options.book_range_strategy||"context"===e.type)){if($=[],m=null,null!=e.passages[0].translations)for(n=0,o=(d=e.passages[0].translations).length;n<o;n++)k=(null!=(f=(y=d[n]).osis)?f.length:void 0)>0?y.osis:"",null==m&&(m=y.alias),$.push(k);else $=[""],m="default";for(p=[],a=h=0,b=l=e.passages.length;0<=b?h<b:h>b;a=0<=b?++h:--h)null==(g=e.passages[a]).type&&(g.type=e.type),!1===g.valid.valid&&("ignore"===this.options.invalid_sequence_strategy&&"sequence"===e.type&&this.snap_sequence("ignore",e,p,a,l),"ignore"===this.options.invalid_passage_strategy)||("b"!==g.type&&"b_range"!==g.type||"ignore"!==this.options.book_sequence_strategy||"sequence"!==e.type?("b_range_start"!==g.type&&"range_end_b"!==g.type||"ignore"!==this.options.book_range_strategy||this.snap_range(e,a),null==g.absolute_indices&&(g.absolute_indices=e.absolute_indices),p.push({osis:g.valid.valid?this.to_osis(g.start,g.end,m):"",type:g.type,indices:g.absolute_indices,translations:$,start:g.start,end:g.end,enclosed_indices:g.enclosed_absolute_indices,entity_id:s,entities:[g]})):this.snap_sequence("book",e,p,a,l));if(0!==p.length)if(p.length>1&&"combine"===this.options.consecutive_combination_strategy&&(p=this.combine_consecutive_passages(p,m)),"separate"===this.options.sequence_combination_strategy)x=x.concat(p);else{for(v=[],null!=p[i=p.length-1].enclosed_indices&&p[i].enclosed_indices[1]>=0&&(e.absolute_indices[1]=p[i].enclosed_indices[1]),u=0,r=p.length;u<r;u++)(c=p[u]).osis.length>0&&v.push(c.osis);x.push({osis:v.join(","),indices:e.absolute_indices,translations:$,entity_id:s,entities:p})}}return x}to_osis(e,s,a){var t,n;return null==s.c&&null==s.v&&e.b===s.b&&null==e.c&&null==e.v&&"first_chapter"===this.options.book_alone_strategy&&(s.c=1),t={start:"",end:""},null==e.c&&(e.c=1),null==e.v&&(e.v=1),null==s.c&&(this.options.passage_existence_strategy.indexOf("c")>=0||null!=this.passage.translations[a].chapters[s.b]&&1===this.passage.translations[a].chapters[s.b].length?s.c=this.passage.translations[a].chapters[s.b].length:s.c=999),null==s.v&&(null!=this.passage.translations[a].chapters[s.b][s.c-1]&&this.options.passage_existence_strategy.indexOf("v")>=0?s.v=this.passage.translations[a].chapters[s.b][s.c-1]:s.v=999),this.options.include_apocrypha&&"b"===this.options.ps151_strategy&&(151===e.c&&"Ps"===e.b||151===s.c&&"Ps"===s.b)&&this.fix_ps151(e,s,a),"b"===this.options.osis_compaction_strategy&&1===e.c&&1===e.v&&(999===s.c&&999===s.v||s.c===this.passage.translations[a].chapters[s.b].length&&this.options.passage_existence_strategy.indexOf("c")>=0&&(999===s.v||s.v===this.passage.translations[a].chapters[s.b][s.c-1]&&this.options.passage_existence_strategy.indexOf("v")>=0))?(t.start=e.b,t.end=s.b):this.options.osis_compaction_strategy.length<=2&&1===e.v&&(999===s.v||s.v===this.passage.translations[a].chapters[s.b][s.c-1]&&this.options.passage_existence_strategy.indexOf("v")>=0)?(t.start=e.b+"."+e.c.toString(),t.end=s.b+"."+s.c.toString()):(t.start=e.b+"."+e.c.toString()+"."+e.v.toString(),t.end=s.b+"."+s.c.toString()+"."+s.v.toString()),n=t.start===t.end?t.start:t.start+"-"+t.end,null!=e.extra&&(n=e.extra+","+n),null!=s.extra&&(n+=","+s.extra),n}fix_ps151(e,s,a){var t;return"default"!==a&&null==(null!=(t=this.translations[a])?t.chapters.Ps151:void 0)&&this.passage.promote_book_to_translation("Ps151",a),151===e.c&&"Ps"===e.b?151===s.c&&"Ps"===s.b?(e.b="Ps151",e.c=1,s.b="Ps151",s.c=1):(e.extra=this.to_osis({b:"Ps151",c:1,v:e.v},{b:"Ps151",c:1,v:this.passage.translations[a].chapters.Ps151[0]},a),e.b="Prov",e.c=1,e.v=1):(s.extra=this.to_osis({b:"Ps151",c:1,v:1},{b:"Ps151",c:1,v:s.v},a),s.c=150,s.v=this.passage.translations[a].chapters.Ps[149])}combine_consecutive_passages(e,s){var a,t,n,i,o,r,l,h,u,c,p;for(h=[],u={},a=-1,t=!1,n=o=0,p=r=e.length-1;0<=p?o<=p:o>=p;n=0<=p?++o:--o)(l=e[n]).osis.length>0?(c=h.length-1,i=!1,l.enclosed_indices[0]!==a&&(a=l.enclosed_indices[0]),a>=0&&(n===r||e[n+1].enclosed_indices[0]!==l.enclosed_indices[0])&&(i=!0,t=!0),this.is_verse_consecutive(u,l.start,s)?(h[c].end=l.end,h[c].is_enclosed_last=i,h[c].indices[1]=l.indices[1],h[c].enclosed_indices[1]=l.enclosed_indices[1],h[c].osis=this.to_osis(h[c].start,l.end,s)):h.push(l),u={b:l.end.b,c:l.end.c,v:l.end.v}):(h.push(l),u={});return t&&this.snap_enclosed_indices(h),h}snap_enclosed_indices(e){var s,a,t;for(s=0,a=e.length;s<a;s++)null!=(t=e[s]).is_enclosed_last&&(t.enclosed_indices[0]<0&&t.is_enclosed_last&&(t.indices[1]=t.enclosed_indices[1]),delete t.is_enclosed_last);return e}is_verse_consecutive(e,s,a){var t;if(null==e.b)return!1;if(t=null!=this.passage.translations[a].order?this.passage.translations[a].order:this.passage.translations.default.order,e.b===s.b){if(e.c===s.c){if(e.v===s.v-1)return!0}else if(1===s.v&&e.c===s.c-1&&e.v===this.passage.translations[a].chapters[e.b][e.c-1])return!0}else if(1===s.c&&1===s.v&&t[e.b]===t[s.b]-1&&e.c===this.passage.translations[a].chapters[e.b].length&&e.v===this.passage.translations[a].chapters[e.b][e.c-1])return!0;return!1}snap_range(e,s){var a,t,i,o,r,l,h,u;for(t in"b_range_start"===e.type||"sequence"===e.type&&"b_range_start"===e.passages[s].type?(a=1,r="end",u="b_range_start"):(a=0,r="start",u="range_end_b"),l="end"===r?"start":"end",o=e.passages[s][l])n.call(o,t)&&(e.passages[s][l][t]=e.passages[s][r][t]);return"sequence"===e.type?(s>=e.value.length&&(s=e.value.length-1),null!=(i=this.passage.pluck(u,e.value[s]))&&(h=this.snap_range(i,0),0===s?e.absolute_indices[0]=h.absolute_indices[0]:e.absolute_indices[1]=h.absolute_indices[1])):(e.original_type=e.type,e.type=e.value[a].type,e.absolute_indices=[e.value[a].absolute_indices[0],e.value[a].absolute_indices[1]]),e}snap_sequence(e,s,a,t,n){var i;return(i=s.passages[t]).absolute_indices[0]===s.absolute_indices[0]&&t<n-1&&this.get_snap_sequence_i(s.passages,t,n)!==t?(s.absolute_indices[0]=s.passages[t+1].absolute_indices[0],this.remove_absolute_indices(s.passages,t+1)):i.absolute_indices[1]===s.absolute_indices[1]&&t>0?s.absolute_indices[1]=a.length>0?a[a.length-1].indices[1]:s.passages[t-1].absolute_indices[1]:"book"===e&&t<n-1&&!this.starts_with_book(s.passages[t+1])&&(s.passages[t+1].absolute_indices[0]=i.absolute_indices[0]),s}get_snap_sequence_i(e,s,a){var t,n,i,o;for(t=n=i=s+1,o=a;i<=o?n<o:n>o;t=i<=o?++n:--n){if(this.starts_with_book(e[t]))return t;if(e[t].valid.valid)return s}return s}starts_with_book(e){return"b"===e.type.substr(0,1)||("range"===e.type||"ff"===e.type)&&"b"===e.start.type.substr(0,1)}remove_absolute_indices(e,s){var a,t,n,i,o,r;if(e[s].enclosed_absolute_indices[0]<0)return!1;for([r,a]=e[s].enclosed_absolute_indices,t=0,n=(o=e.slice(s)).length;t<n&&((i=o[t]).enclosed_absolute_indices[0]===r&&i.enclosed_absolute_indices[1]===a);t++)i.enclosed_absolute_indices=[-1,-1];return!0}}return e.prototype.s="",e.prototype.entities=[],e.prototype.passage=null,e.prototype.regexps={},e.prototype.options={consecutive_combination_strategy:"combine",osis_compaction_strategy:"b",book_sequence_strategy:"ignore",invalid_sequence_strategy:"ignore",sequence_combination_strategy:"combine",punctuation_strategy:"us",invalid_passage_strategy:"ignore",non_latin_digits_strategy:"ignore",passage_existence_strategy:"bcv",zero_chapter_strategy:"error",zero_verse_strategy:"error",single_chapter_1_strategy:"chapter",book_alone_strategy:"ignore",book_range_strategy:"ignore",captive_end_digits_strategy:"delete",end_range_digits_strategy:"verse",include_apocrypha:!1,ps151_strategy:"c",versification_system:"default",case_sensitive:"none"},e}.call(this),this.bcv_parser=e,s=function(){class e{handle_array(e,s=[],a={}){var t,n,i;for(t=0,n=e.length;t<n;t++)if(null!=(i=e[t])){if("stop"===i.type)break;[s,a]=this.handle_obj(i,s,a)}return[s,a]}handle_obj(e,s,a){return null!=e.type&&null!=this[e.type]?this[e.type](e,s,a):[s,a]}b(e,s,t){var n,i,o,r,l,h,u;for(e.start_context=a.shallow_clone(t),e.passages=[],n=[],o=0,r=(h=this.books[e.value].parsed).length;o<r;o++)l={start:{b:i=h[o]},end:{b:i},valid:u=this.validate_ref(e.start_context.translations,{b:i})},0===e.passages.length&&u.valid?e.passages.push(l):n.push(l);return 0===e.passages.length&&e.passages.push(n.shift()),n.length>0&&(e.passages[0].alternates=n),null!=e.start_context.translations&&(e.passages[0].translations=e.start_context.translations),null==e.absolute_indices&&(e.absolute_indices=this.get_absolute_indices(e.indices)),s.push(e),t={b:e.passages[0].start.b},null!=e.start_context.translations&&(t.translations=e.start_context.translations),[s,t]}b_range(e,s,a){return this.range(e,s,a)}b_range_pre(e,s,t){var n,i,o;return e.start_context=a.shallow_clone(t),e.passages=[],n=this.pluck("b",e.value),[[i],t]=this.b(n,[],t),null==e.absolute_indices&&(e.absolute_indices=this.get_absolute_indices(e.indices)),o={b:e.value[0].value+i.passages[0].start.b.substr(1),type:"b"},e.passages=[{start:o,end:i.passages[0].end,valid:i.passages[0].valid}],null!=e.start_context.translations&&(e.passages[0].translations=e.start_context.translations),s.push(e),[s,t]}b_range_start(e,s,a){return this.range(e,s,a)}base(e,s,a){return this.indices=this.calculate_indices(e.match,e.start_index),this.handle_array(e.value,s,a)}bc(e,s,t){var n,i,o,r,l,h,u,c,p;for(e.start_context=a.shallow_clone(t),e.passages=[],this.reset_context(t,["b","c","v"]),o=this.pluck("c",e.value).value,n=[],l=0,h=(c=this.books[this.pluck("b",e.value).value].parsed).length;l<h;l++)r="c",u={start:{b:i=c[l]},end:{b:i},valid:p=this.validate_ref(e.start_context.translations,{b:i,c:o})},(p.messages.start_chapter_not_exist_in_single_chapter_book||p.messages.start_chapter_1)&&(u.valid=this.validate_ref(e.start_context.translations,{b:i,v:o}),p.messages.start_chapter_not_exist_in_single_chapter_book&&(u.valid.messages.start_chapter_not_exist_in_single_chapter_book=1),u.start.c=1,u.end.c=1,r="v"),u.start[r]=o,[u.start.c,u.start.v]=this.fix_start_zeroes(u.valid,u.start.c,u.start.v),null==u.start.v&&delete u.start.v,u.end[r]=u.start[r],0===e.passages.length&&u.valid.valid?e.passages.push(u):n.push(u);return 0===e.passages.length&&e.passages.push(n.shift()),n.length>0&&(e.passages[0].alternates=n),null!=e.start_context.translations&&(e.passages[0].translations=e.start_context.translations),null==e.absolute_indices&&(e.absolute_indices=this.get_absolute_indices(e.indices)),this.set_context_from_object(t,["b","c","v"],e.passages[0].start),s.push(e),[s,t]}bc_title(e,s,t){var n,i,o,r,l;if(e.start_context=a.shallow_clone(t),[[n],t]=this.bc(this.pluck("bc",e.value),[],t),"Ps"!==n.passages[0].start.b.substr(0,2)&&null!=n.passages[0].alternates)for(i=o=0,r=n.passages[0].alternates.length;0<=r?o<r:o>r;i=0<=r?++o:--o)if("Ps"===n.passages[0].alternates[i].start.b.substr(0,2)){n.passages[0]=n.passages[0].alternates[i];break}return"Ps"!==n.passages[0].start.b.substr(0,2)?(s.push(n),[s,t]):(this.books[this.pluck("b",n.value).value].parsed=["Ps"],null==(l=this.pluck("title",e.value))&&(l=this.pluck("v",e.value)),e.value[1]={type:"v",value:[{type:"integer",value:1,indices:l.indices}],indices:l.indices},e.type="bcv",this.bcv(e,s,e.start_context))}bcv(e,s,t){var n,i,o,r,l,h,u,c,p,x;for(e.start_context=a.shallow_clone(t),e.passages=[],this.reset_context(t,["b","c","v"]),o=this.pluck("bc",e.value),r=this.pluck("c",o.value).value,p=this.pluck("v",e.value).value,n=[],l=0,h=(c=this.books[this.pluck("b",o.value).value].parsed).length;l<h;l++)i=c[l],x=this.validate_ref(e.start_context.translations,{b:i,c:r,v:p}),[r,p]=this.fix_start_zeroes(x,r,p),u={start:{b:i,c:r,v:p},end:{b:i,c:r,v:p},valid:x},0===e.passages.length&&x.valid?e.passages.push(u):n.push(u);return 0===e.passages.length&&e.passages.push(n.shift()),n.length>0&&(e.passages[0].alternates=n),null!=e.start_context.translations&&(e.passages[0].translations=e.start_context.translations),null==e.absolute_indices&&(e.absolute_indices=this.get_absolute_indices(e.indices)),this.set_context_from_object(t,["b","c","v"],e.passages[0].start),s.push(e),[s,t]}bv(e,s,t){var n,i,o;return e.start_context=a.shallow_clone(t),[n,o]=e.value,i={indices:e.indices,value:[{type:"bc",value:[n,{type:"c",value:[{type:"integer",value:1}]}]},o]},[[i],t]=this.bcv(i,[],t),e.passages=i.passages,null==e.absolute_indices&&(e.absolute_indices=this.get_absolute_indices(e.indices)),s.push(e),[s,t]}c(e,s,t){var n,i;return e.start_context=a.shallow_clone(t),n="integer"===e.type?e.value:this.pluck("integer",e.value).value,!(i=this.validate_ref(e.start_context.translations,{b:t.b,c:n})).valid&&i.messages.start_chapter_not_exist_in_single_chapter_book?this.v(e,s,t):([n]=this.fix_start_zeroes(i,n),e.passages=[{start:{b:t.b,c:n},end:{b:t.b,c:n},valid:i}],null!=e.start_context.translations&&(e.passages[0].translations=e.start_context.translations),s.push(e),t.c=n,this.reset_context(t,["v"]),null==e.absolute_indices&&(e.absolute_indices=this.get_absolute_indices(e.indices)),[s,t])}c_psalm(e,s,a){var t;return e.type="bc",t=parseInt(this.books[e.value].value.match(/^\d+/)[0],10),e.value=[{type:"b",value:e.value,indices:e.indices},{type:"c",value:[{type:"integer",value:t,indices:e.indices}],indices:e.indices}],this.bc(e,s,a)}c_title(e,s,t){var n;return e.start_context=a.shallow_clone(t),"Ps"!==t.b?this.c(e.value[0],s,t):(n=this.pluck("title",e.value),e.value[1]={type:"v",value:[{type:"integer",value:1,indices:n.indices}],indices:n.indices},e.type="cv",this.cv(e,s,e.start_context))}cv(e,s,t){var n,i,o;return e.start_context=a.shallow_clone(t),n=this.pluck("c",e.value).value,i=this.pluck("v",e.value).value,o=this.validate_ref(e.start_context.translations,{b:t.b,c:n,v:i}),[n,i]=this.fix_start_zeroes(o,n,i),e.passages=[{start:{b:t.b,c:n,v:i},end:{b:t.b,c:n,v:i},valid:o}],null!=e.start_context.translations&&(e.passages[0].translations=e.start_context.translations),s.push(e),t.c=n,t.v=i,null==e.absolute_indices&&(e.absolute_indices=this.get_absolute_indices(e.indices)),[s,t]}cb_range(e,s,a){var t,n,i;return e.type="range",[t,i,n]=e.value,e.value=[{type:"bc",value:[t,i],indices:e.indices},n],n.indices[1]=e.indices[1],this.range(e,s,a)}context(e,s,t){var i,o;for(i in e.start_context=a.shallow_clone(t),e.passages=[],o=this.books[e.value].context)n.call(o,i)&&(t[i]=this.books[e.value].context[i]);return s.push(e),[s,t]}cv_psalm(e,s,t){var n,i,o;return e.start_context=a.shallow_clone(t),e.type="bcv",[i,o]=e.value,[[n]]=this.c_psalm(i,[],e.start_context),e.value=[n,o],this.bcv(e,s,t)}ff(e,s,t){return e.start_context=a.shallow_clone(t),e.value.push({type:"integer",indices:e.indices,value:999}),[[e],t]=this.range(e,[],e.start_context),e.value[0].indices=e.value[1].indices,e.value[0].absolute_indices=e.value[1].absolute_indices,e.value.pop(),null!=e.passages[0].valid.messages.end_verse_not_exist&&delete e.passages[0].valid.messages.end_verse_not_exist,null!=e.passages[0].valid.messages.end_chapter_not_exist&&delete e.passages[0].valid.messages.end_chapter_not_exist,null!=e.passages[0].end.original_c&&delete e.passages[0].end.original_c,s.push(e),[s,t]}integer_title(e,s,t){return e.start_context=a.shallow_clone(t),"Ps"!==t.b?this.integer(e.value[0],s,t):(e.value[0]={type:"c",value:[e.value[0]],indices:[e.value[0].indices[0],e.value[0].indices[1]]},e.value[1].type="v",e.value[1].original_type="title",e.value[1].value=[{type:"integer",value:1,indices:e.value[1].value.indices}],e.type="cv",this.cv(e,s,e.start_context))}integer(e,s,a){return null!=a.v?this.v(e,s,a):this.c(e,s,a)}next_v(e,s,t){var n,i;return e.start_context=a.shallow_clone(t),null==(n=this.pluck_last_recursively("integer",e.value))&&(n={value:1}),e.value.push({type:"integer",indices:e.indices,value:n.value+1}),[[i],t]=this.range(e,[],e.start_context),null!=i.passages[0].valid.messages.end_verse_not_exist&&null==i.passages[0].valid.messages.start_verse_not_exist&&null==i.passages[0].valid.messages.start_chapter_not_exist&&null!=t.c&&(e.value.pop(),e.value.push({type:"cv",indices:e.indices,value:[{type:"c",value:[{type:"integer",value:t.c+1,indices:e.indices}],indices:e.indices},{type:"v",value:[{type:"integer",value:1,indices:e.indices}],indices:e.indices}]}),[[i],t]=this.range(e,[],e.start_context)),i.value[0].indices=i.value[1].indices,i.value[0].absolute_indices=i.value[1].absolute_indices,i.value.pop(),null!=i.passages[0].valid.messages.end_verse_not_exist&&delete i.passages[0].valid.messages.end_verse_not_exist,null!=i.passages[0].valid.messages.end_chapter_not_exist&&delete i.passages[0].valid.messages.end_chapter_not_exist,null!=i.passages[0].end.original_c&&delete i.passages[0].end.original_c,s.push(i),[s,t]}sequence(e,s,t){var n,i,o,r,l,h,u,c,p;for(e.start_context=a.shallow_clone(t),e.passages=[],n=0,o=(u=e.value).length;n<o;n++)for(l=u[n],[[h],t]=this.handle_array(l,[],t),i=0,r=(c=h.passages).length;i<r;i++)null==(p=c[i]).type&&(p.type=h.type),null==p.absolute_indices&&(p.absolute_indices=h.absolute_indices),null!=h.start_context.translations&&(p.translations=h.start_context.translations),p.enclosed_absolute_indices="sequence_post_enclosed"===h.type?h.absolute_indices:[-1,-1],e.passages.push(p);return null==e.absolute_indices&&(e.passages.length>0&&"sequence"===e.type?e.absolute_indices=[e.passages[0].absolute_indices[0],e.passages[e.passages.length-1].absolute_indices[1]]:e.absolute_indices=this.get_absolute_indices(e.indices)),s.push(e),[s,t]}sequence_post_enclosed(e,s,a){return this.sequence(e,s,a)}v(e,s,t){var n,i,o,r;return o="integer"===e.type?e.value:this.pluck("integer",e.value).value,e.start_context=a.shallow_clone(t),n=null!=t.c?t.c:1,r=this.validate_ref(e.start_context.translations,{b:t.b,c:n,v:o}),[i,o]=this.fix_start_zeroes(r,0,o),e.passages=[{start:{b:t.b,c:n,v:o},end:{b:t.b,c:n,v:o},valid:r}],null!=e.start_context.translations&&(e.passages[0].translations=e.start_context.translations),null==e.absolute_indices&&(e.absolute_indices=this.get_absolute_indices(e.indices)),s.push(e),t.v=o,[s,t]}range(e,s,t){var n,i,o,r,l,h,u,c,p,x,g;return e.start_context=a.shallow_clone(t),[p,n]=e.value,[[p],t]=this.handle_obj(p,[],t),"v"!==n.type||("bc"!==p.type||(null!=(o=p.passages)&&null!=(r=o[0])&&null!=(l=r.valid)&&null!=(h=l.messages)?h.start_chapter_not_exist_in_single_chapter_book:void 0))&&"c"!==p.type||"verse"!==this.options.end_range_digits_strategy?([[n],t]=this.handle_obj(n,[],t),e.value=[p,n],e.indices=[p.indices[0],n.indices[1]],delete e.absolute_indices,x={b:p.passages[0].start.b,c:p.passages[0].start.c,v:p.passages[0].start.v,type:p.type},i={b:n.passages[0].end.b,c:n.passages[0].end.c,v:n.passages[0].end.v,type:n.type},n.passages[0].valid.messages.start_chapter_is_zero&&(i.c=0),n.passages[0].valid.messages.start_verse_is_zero&&(i.v=0),(g=this.validate_ref(e.start_context.translations,x,i)).valid?([u,c]=this.range_handle_valid(g,e,p,x,n,i,s),u?c:(null==e.absolute_indices&&(e.absolute_indices=this.get_absolute_indices(e.indices)),e.passages=[{start:x,end:i,valid:g}],null!=e.start_context.translations&&(e.passages[0].translations=e.start_context.translations),"b"===x.type?"b"===i.type?e.type="b_range":e.type="b_range_start":"b"===i.type&&(e.type="range_end_b"),s.push(e),[s,t])):this.range_handle_invalid(g,e,p,x,n,i,s)):(e.value[0]=p,this.range_change_integer_end(e,s))}range_change_end(e,s,a){var t,n,i;return[i,t]=e.value,"integer"===t.type?(t.original_value=t.value,t.value=a):"v"===t.type?((n=this.pluck("integer",t.value)).original_value=n.value,n.value=a):"cv"===t.type&&((n=this.pluck("c",t.value)).original_value=n.value,n.value=a),this.handle_obj(e,s,e.start_context)}range_change_integer_end(e,s){var a,t;return[t,a]=e.value,null==e.original_type&&(e.original_type=e.type),null==e.original_value&&(e.original_value=[t,a]),e.type="integer"===t.type?"cv":t.type+"v","integer"===t.type&&(e.value[0]={type:"c",value:[t],indices:t.indices}),"integer"===a.type&&(e.value[1]={type:"v",value:[a],indices:a.indices}),this.handle_obj(e,s,e.start_context)}range_check_new_end(e,s,a,t){var n,i,o;return n=0,o=null,t.messages.end_chapter_before_start?o="c":t.messages.end_verse_before_start&&(o="v"),null!=o&&(n=this.range_get_new_end_value(s,a,t,o)),n>0&&((i={b:a.b,c:a.c,v:a.v})[o]=n,this.validate_ref(e,i).valid||(n=0)),n}range_end_b(e,s,a){return this.range(e,s,a)}range_get_new_end_value(e,s,a,t){var n;return n=0,"c"===t&&a.messages.end_chapter_is_zero||"v"===t&&a.messages.end_verse_is_zero||(e[t]>=10&&s[t]<10&&e[t]-10*Math.floor(e[t]/10)<s[t]?n=s[t]+10*Math.floor(e[t]/10):e[t]>=100&&s[t]<100&&e[t]-100<s[t]&&(n=s[t]+100)),n}range_handle_invalid(e,s,a,t,n,i,o){var r,l;return(!1===e.valid&&(e.messages.end_chapter_before_start||e.messages.end_verse_before_start)&&("integer"===n.type||"v"===n.type)||!1===e.valid&&e.messages.end_chapter_before_start&&"cv"===n.type)&&(r=this.range_check_new_end(s.start_context.translations,t,i,e))>0?this.range_change_end(s,o,r):"verse"!==this.options.end_range_digits_strategy||null!=t.v||"integer"!==n.type&&"v"!==n.type||(l="v"===n.type?this.pluck("integer",n.value):n.value,!this.validate_ref(s.start_context.translations,{b:t.b,c:t.c,v:l}).valid)?(null==s.original_type&&(s.original_type=s.type),s.type="sequence",[s.original_value,s.value]=[[a,n],[[a],[n]]],this.sequence(s,o,s.start_context)):this.range_change_integer_end(s,o)}range_handle_valid(e,s,a,t,n,i,o){var r;return e.messages.end_chapter_not_exist&&"verse"===this.options.end_range_digits_strategy&&null==t.v&&("integer"===n.type||"v"===n.type)&&this.options.passage_existence_strategy.indexOf("v")>=0&&(r="v"===n.type?this.pluck("integer",n.value):n.value,this.validate_ref(s.start_context.translations,{b:t.b,c:t.c,v:r}).valid)?[!0,this.range_change_integer_end(s,o)]:(this.range_validate(e,t,i,s),[!1,null])}range_validate(e,s,a,t){return e.messages.end_chapter_not_exist||e.messages.end_chapter_not_exist_in_single_chapter_book?(a.original_c=a.c,a.c=e.messages.end_chapter_not_exist?e.messages.end_chapter_not_exist:e.messages.end_chapter_not_exist_in_single_chapter_book,null!=a.v&&(a.v=this.validate_ref(t.start_context.translations,{b:a.b,c:a.c,v:999}).messages.end_verse_not_exist,delete e.messages.end_verse_is_zero)):e.messages.end_verse_not_exist&&(a.original_v=a.v,a.v=e.messages.end_verse_not_exist),e.messages.end_verse_is_zero&&"allow"!==this.options.zero_verse_strategy&&(a.v=e.messages.end_verse_is_zero),e.messages.end_chapter_is_zero&&(a.c=e.messages.end_chapter_is_zero),[s.c,s.v]=this.fix_start_zeroes(e,s.c,s.v),!0}translation_sequence(e,s,t){var n,i,o,r,l,h,u,c;for(e.start_context=a.shallow_clone(t),(u=[]).push({translation:this.books[e.value[0].value].parsed}),n=0,o=(l=e.value[1]).length;n<o;n++)c=l[n],null!=(c=this.books[this.pluck("translation",c).value].parsed)&&u.push({translation:c});for(i=0,r=u.length;i<r;i++)h=u[i],null!=this.translations.aliases[h.translation]?(h.alias=this.translations.aliases[h.translation].alias,h.osis=this.translations.aliases[h.translation].osis||h.translation.toUpperCase()):(h.alias="default",h.osis=h.translation.toUpperCase());return s.length>0&&(t=this.translation_sequence_apply(s,u)),null==e.absolute_indices&&(e.absolute_indices=this.get_absolute_indices(e.indices)),s.push(e),this.reset_context(t,["translations"]),[s,t]}translation_sequence_apply(e,s){var t,n,i,o,r,l;for(l=0,n=i=r=e.length-1;r<=0?i<=0:i>=0;n=r<=0?++i:--i)if(null!=e[n].original_type&&(e[n].type=e[n].original_type),null!=e[n].original_value&&(e[n].value=e[n].original_value),"translation_sequence"===e[n].type){l=n+1;break}return l<e.length?(e[l].start_context.translations=s,[o,t]=this.handle_array(e.slice(l),[],e[l].start_context)):t=a.shallow_clone(e[e.length-1].start_context),t}pluck(e,s){var a,t,n;for(a=0,t=s.length;a<t;a++)if(null!=(n=s[a])&&null!=n.type&&n.type===e)return"c"===e||"v"===e?this.pluck("integer",n.value):n;return null}pluck_last_recursively(e,s){var a,t,n;for(a=s.length-1;a>=0;a+=-1)if(null!=(t=s[a])&&null!=t.type){if(t.type===e)return this.pluck(e,[t]);if(null!=(n=this.pluck_last_recursively(e,t.value)))return n}return null}set_context_from_object(e,s,a){var t,n,i,o;for(i=[],t=0,n=s.length;t<n;t++)null!=a[o=s[t]]&&i.push(e[o]=a[o]);return i}reset_context(e,s){var a,t,n,i;for(n=[],a=0,t=s.length;a<t;a++)i=s[a],n.push(delete e[i]);return n}fix_start_zeroes(e,s,a){return e.messages.start_chapter_is_zero&&"upgrade"===this.options.zero_chapter_strategy&&(s=e.messages.start_chapter_is_zero),e.messages.start_verse_is_zero&&"upgrade"===this.options.zero_verse_strategy&&(a=e.messages.start_verse_is_zero),[s,a]}calculate_indices(e,s){var a,t,n,i,o,r,l,h,u,c,p,x,g,_,d,f;for(d="book",n=[],c=0,s=parseInt(s,10),g=[e],i=0,r=(_=["",""]).length;i<r;i++){for(a=_[i],f=[],o=0,l=g.length;o<l;o++)p=g[o],f=f.concat(p.split(a));g=f}for(u=0,h=g.length;u<h;u++)d="book"===d?"rest":"book",0!==(x=(p=g[u]).length)&&("book"===d?(p=p.replace(/\/\d+$/,""),t=c+x,n.length>0&&n[n.length-1].index===s?n[n.length-1].end=t:n.push({start:c,end:t,index:s}),c+=x+2,s=this.books[p].start_index+this.books[p].value.length-c,n.push({start:t+1,end:t+1,index:s})):(t=c+x-1,n.length>0&&n[n.length-1].index===s?n[n.length-1].end=t:n.push({start:c,end:t,index:s}),c+=x));return n}get_absolute_indices([e,s]){var a,t,n,i,o,r;for(r=null,a=null,n=0,i=(o=this.indices).length;n<i;n++)if(t=o[n],null===r&&t.start<=e&&e<=t.end&&(r=e+t.index),t.start<=s&&s<=t.end){a=s+t.index+1;break}return[r,a]}validate_ref(e,s,a){var t,n,i,o,r,l;for(null!=e&&e.length>0||(e=[{translation:"default",osis:"",alias:"default"}]),l=!1,i={},t=0,n=e.length;t<n;t++)null==(r=e[t]).alias&&(r.alias="default"),null!=r.alias?(null==this.translations.aliases[r.alias]&&(r.alias="default",null==i.translation_unknown&&(i.translation_unknown=[]),i.translation_unknown.push(r)),[o]=this.validate_start_ref(r.alias,s,i),a&&([o]=this.validate_end_ref(r.alias,s,a,o,i)),!0===o&&(l=!0)):(null==i.translation_invalid&&(i.translation_invalid=[]),i.translation_invalid.push(r));return{valid:l,messages:i}}validate_start_ref(e,s,a){var t,n,i,o;if(o=!0,"default"!==e&&null==(null!=(t=this.translations[e])?t.chapters[s.b]:void 0)&&this.promote_book_to_translation(s.b,e),i=null!=(null!=(n=this.translations[e])?n.order:void 0)?e:"default",null!=s.v&&(s.v=parseInt(s.v,10)),null!=this.translations[i].order[s.b]){if(null==s.c&&(s.c=1),s.c=parseInt(s.c,10),isNaN(s.c))return o=!1,a.start_chapter_not_numeric=!0,[o,a];0===s.c&&(a.start_chapter_is_zero=1,"error"===this.options.zero_chapter_strategy?o=!1:s.c=1),null!=s.v&&0===s.v&&(a.start_verse_is_zero=1,"error"===this.options.zero_verse_strategy?o=!1:"upgrade"===this.options.zero_verse_strategy&&(s.v=1)),s.c>0&&null!=this.translations[e].chapters[s.b][s.c-1]?null!=s.v?isNaN(s.v)?(o=!1,a.start_verse_not_numeric=!0):s.v>this.translations[e].chapters[s.b][s.c-1]&&this.options.passage_existence_strategy.indexOf("v")>=0&&(o=!1,a.start_verse_not_exist=this.translations[e].chapters[s.b][s.c-1]):1===s.c&&"verse"===this.options.single_chapter_1_strategy&&1===this.translations[e].chapters[s.b].length&&(a.start_chapter_1=1):1!==s.c&&1===this.translations[e].chapters[s.b].length?(o=!1,a.start_chapter_not_exist_in_single_chapter_book=1):s.c>0&&this.options.passage_existence_strategy.indexOf("c")>=0&&(o=!1,a.start_chapter_not_exist=this.translations[e].chapters[s.b].length)}else null==s.b?(o=!1,a.start_book_not_defined=!0):(this.options.passage_existence_strategy.indexOf("b")>=0&&(o=!1),a.start_book_not_exist=!0);return[o,a]}validate_end_ref(e,s,a,t,n){var i,o;return o=null!=(null!=(i=this.translations[e])?i.order:void 0)?e:"default",null!=a.c&&(a.c=parseInt(a.c,10),isNaN(a.c)?(t=!1,n.end_chapter_not_numeric=!0):0===a.c&&(n.end_chapter_is_zero=1,"error"===this.options.zero_chapter_strategy?t=!1:a.c=1)),null!=a.v&&(a.v=parseInt(a.v,10),isNaN(a.v)?(t=!1,n.end_verse_not_numeric=!0):0===a.v&&(n.end_verse_is_zero=1,"error"===this.options.zero_verse_strategy?t=!1:"upgrade"===this.options.zero_verse_strategy&&(a.v=1))),null!=this.translations[o].order[a.b]?(null==a.c&&1===this.translations[e].chapters[a.b].length&&(a.c=1),null!=this.translations[o].order[s.b]&&this.translations[o].order[s.b]>this.translations[o].order[a.b]&&(this.options.passage_existence_strategy.indexOf("b")>=0&&(t=!1),n.end_book_before_start=!0),s.b!==a.b||null==a.c||isNaN(a.c)||(null==s.c&&(s.c=1),!isNaN(parseInt(s.c,10))&&s.c>a.c?(t=!1,n.end_chapter_before_start=!0):s.c!==a.c||null==a.v||isNaN(a.v)||(null==s.v&&(s.v=1),!isNaN(parseInt(s.v,10))&&s.v>a.v&&(t=!1,n.end_verse_before_start=!0))),null==a.c||isNaN(a.c)||null==this.translations[e].chapters[a.b][a.c-1]&&(1===this.translations[e].chapters[a.b].length?n.end_chapter_not_exist_in_single_chapter_book=1:a.c>0&&this.options.passage_existence_strategy.indexOf("c")>=0&&(n.end_chapter_not_exist=this.translations[e].chapters[a.b].length)),null==a.v||isNaN(a.v)||(null==a.c&&(a.c=this.translations[e].chapters[a.b].length),a.v>this.translations[e].chapters[a.b][a.c-1]&&this.options.passage_existence_strategy.indexOf("v")>=0&&(n.end_verse_not_exist=this.translations[e].chapters[a.b][a.c-1]))):(t=!1,n.end_book_not_exist=!0),[t,n]}promote_book_to_translation(e,s){var t,n;if(null==(t=this.translations)[s]&&(t[s]={}),null==(n=this.translations[s]).chapters&&(n.chapters={}),null==this.translations[s].chapters[e])return this.translations[s].chapters[e]=a.shallow_clone_array(this.translations.default.chapters[e])}}return e.prototype.books=[],e.prototype.indices={},e.prototype.options={},e.prototype.translations={},e}.call(this),a={shallow_clone:function(e){var s,a,t;if(null==e)return e;for(s in a={},e)n.call(e,s)&&(t=e[s],a[s]=t);return a},shallow_clone_array:function(e){var s,a,t,n;if(null==e)return e;for(t=[],s=a=0,n=e.length;0<=n?a<=n:a>=n;s=0<=n?++a:--a)void 0!==e[s]&&(t[s]=e[s]);return t}},e.prototype.regexps.translations=/(?:(?:N(?:A(?:B(?:RE)?|SB?)|(?:RS|KJ)V|IR?V|LT)|HCSB|(?:TNI|E[RS]|AS|RS|KJ)V|MSG|LXX|CE[BV]|AMP))\b/gi,e.prototype.translations={aliases:{ceb:{alias:"ceb"},kjv:{alias:"kjv"},lxx:{alias:"nab"},nab:{alias:"nab"},nabre:{alias:"nab"},nas:{osis:"NASB",alias:"default"},nirv:{alias:"kjv"},niv:{alias:"kjv"},nkjv:{alias:"nkjv"},nlt:{alias:"nlt"},nrsv:{alias:"nrsv"},tniv:{alias:"kjv"},default:{osis:"",alias:"default"}},alternates:{},default:{order:{Gen:1,Exod:2,Lev:3,Num:4,Deut:5,Josh:6,Judg:7,Ruth:8,"1Sam":9,"2Sam":10,"1Kgs":11,"2Kgs":12,"1Chr":13,"2Chr":14,Ezra:15,Neh:16,Esth:17,Job:18,Ps:19,Prov:20,Eccl:21,Song:22,Isa:23,Jer:24,Lam:25,Ezek:26,Dan:27,Hos:28,Joel:29,Amos:30,Obad:31,Jonah:32,Mic:33,Nah:34,Hab:35,Zeph:36,Hag:37,Zech:38,Mal:39,Matt:40,Mark:41,Luke:42,John:43,Acts:44,Rom:45,"1Cor":46,"2Cor":47,Gal:48,Eph:49,Phil:50,Col:51,"1Thess":52,"2Thess":53,"1Tim":54,"2Tim":55,Titus:56,Phlm:57,Heb:58,Jas:59,"1Pet":60,"2Pet":61,"1John":62,"2John":63,"3John":64,Jude:65,Rev:66,Tob:67,Jdt:68,GkEsth:69,Wis:70,Sir:71,Bar:72,PrAzar:73,Sus:74,Bel:75,SgThree:76,EpJer:77,"1Macc":78,"2Macc":79,"3Macc":80,"4Macc":81,"1Esd":82,"2Esd":83,PrMan:84},chapters:{Gen:[31,25,24,26,32,22,24,22,29,32,32,20,18,24,21,16,27,33,38,18,34,24,20,67,34,35,46,22,35,43,55,32,20,31,29,43,36,30,23,23,57,38,34,34,28,34,31,22,33,26],Exod:[22,25,22,31,23,30,25,32,35,29,10,51,22,31,27,36,16,27,25,26,36,31,33,18,40,37,21,43,46,38,18,35,23,35,35,38,29,31,43,38],Lev:[17,16,17,35,19,30,38,36,24,20,47,8,59,57,33,34,16,30,37,27,24,33,44,23,55,46,34],Num:[54,34,51,49,31,27,89,26,23,36,35,16,33,45,41,50,13,32,22,29,35,41,30,25,18,65,23,31,40,16,54,42,56,29,34,13],Deut:[46,37,29,49,33,25,26,20,29,22,32,32,18,29,23,22,20,22,21,20,23,30,25,22,19,19,26,68,29,20,30,52,29,12],Josh:[18,24,17,24,15,27,26,35,27,43,23,24,33,15,63,10,18,28,51,9,45,34,16,33],Judg:[36,23,31,24,31,40,25,35,57,18,40,15,25,20,20,31,13,31,30,48,25],Ruth:[22,23,18,22],"1Sam":[28,36,21,22,12,21,17,22,27,27,15,25,23,52,35,23,58,30,24,42,15,23,29,22,44,25,12,25,11,31,13],"2Sam":[27,32,39,12,25,23,29,18,13,19,27,31,39,33,37,23,29,33,43,26,22,51,39,25],"1Kgs":[53,46,28,34,18,38,51,66,28,29,43,33,34,31,34,34,24,46,21,43,29,53],"2Kgs":[18,25,27,44,27,33,20,29,37,36,21,21,25,29,38,20,41,37,37,21,26,20,37,20,30],"1Chr":[54,55,24,43,26,81,40,40,44,14,47,40,14,17,29,43,27,17,19,8,30,19,32,31,31,32,34,21,30],"2Chr":[17,18,17,22,14,42,22,18,31,19,23,16,22,15,19,14,19,34,11,37,20,12,21,27,28,23,9,27,36,27,21,33,25,33,27,23],Ezra:[11,70,13,24,17,22,28,36,15,44],Neh:[11,20,32,23,19,19,73,18,38,39,36,47,31],Esth:[22,23,15,17,14,14,10,17,32,3],Job:[22,13,26,21,27,30,21,22,35,22,20,25,28,22,35,22,16,21,29,29,34,30,17,25,6,14,23,28,25,31,40,22,33,37,16,33,24,41,30,24,34,17],Ps:[6,12,8,8,12,10,17,9,20,18,7,8,6,7,5,11,15,50,14,9,13,31,6,10,22,12,14,9,11,12,24,11,22,22,28,12,40,22,13,17,13,11,5,26,17,11,9,14,20,23,19,9,6,7,23,13,11,11,17,12,8,12,11,10,13,20,7,35,36,5,24,20,28,23,10,12,20,72,13,19,16,8,18,12,13,17,7,18,52,17,16,15,5,23,11,13,12,9,9,5,8,28,22,35,45,48,43,13,31,7,10,10,9,8,18,19,2,29,176,7,8,9,4,8,5,6,5,6,8,8,3,18,3,3,21,26,9,8,24,13,10,7,12,15,21,10,20,14,9,6],Prov:[33,22,35,27,23,35,27,36,18,32,31,28,25,35,33,33,28,24,29,30,31,29,35,34,28,28,27,28,27,33,31],Eccl:[18,26,22,16,20,12,29,17,18,20,10,14],Song:[17,17,11,16,16,13,13,14],Isa:[31,22,26,6,30,13,25,22,21,34,16,6,22,32,9,14,14,7,25,6,17,25,18,23,12,21,13,29,24,33,9,20,24,17,10,22,38,22,8,31,29,25,28,28,25,13,15,22,26,11,23,15,12,17,13,12,21,14,21,22,11,12,19,12,25,24],Jer:[19,37,25,31,31,30,34,22,26,25,23,17,27,22,21,21,27,23,15,18,14,30,40,10,38,24,22,17,32,24,40,44,26,22,19,32,21,28,18,16,18,22,13,30,5,28,7,47,39,46,64,34],Lam:[22,22,66,22,22],Ezek:[28,10,27,17,17,14,27,18,11,22,25,28,23,23,8,63,24,32,14,49,32,31,49,27,17,21,36,26,21,26,18,32,33,31,15,38,28,23,29,49,26,20,27,31,25,24,23,35],Dan:[21,49,30,37,31,28,28,27,27,21,45,13],Hos:[11,23,5,19,15,11,16,14,17,15,12,14,16,9],Joel:[20,32,21],Amos:[15,16,15,13,27,14,17,14,15],Obad:[21],Jonah:[17,10,10,11],Mic:[16,13,12,13,15,16,20],Nah:[15,13,19],Hab:[17,20,19],Zeph:[18,15,20],Hag:[15,23],Zech:[21,13,10,14,11,15,14,23,17,12,17,14,9,21],Mal:[14,17,18,6],Matt:[25,23,17,25,48,34,29,34,38,42,30,50,58,36,39,28,27,35,30,34,46,46,39,51,46,75,66,20],Mark:[45,28,35,41,43,56,37,38,50,52,33,44,37,72,47,20],Luke:[80,52,38,44,39,49,50,56,62,42,54,59,35,35,32,31,37,43,48,47,38,71,56,53],John:[51,25,36,54,47,71,53,59,41,42,57,50,38,31,27,33,26,40,42,31,25],Acts:[26,47,26,37,42,15,60,40,43,48,30,25,52,28,41,40,34,28,41,38,40,30,35,27,27,32,44,31],Rom:[32,29,31,25,21,23,25,39,33,21,36,21,14,23,33,27],"1Cor":[31,16,23,21,13,20,40,13,27,33,34,31,13,40,58,24],"2Cor":[24,17,18,18,21,18,16,24,15,18,33,21,14],Gal:[24,21,29,31,26,18],Eph:[23,22,21,32,33,24],Phil:[30,30,21,23],Col:[29,23,25,18],"1Thess":[10,20,13,18,28],"2Thess":[12,17,18],"1Tim":[20,15,16,16,25,21],"2Tim":[18,26,17,22],Titus:[16,15,15],Phlm:[25],Heb:[14,18,19,16,14,20,28,13,28,39,40,29,25],Jas:[27,26,18,17,20],"1Pet":[25,25,22,19,14],"2Pet":[21,22,18],"1John":[10,29,24,21,21],"2John":[13],"3John":[15],Jude:[25],Rev:[20,29,22,11,14,17,17,13,21,11,19,17,18,20,8,21,18,24,21,15,27,21],Tob:[22,14,17,21,22,18,16,21,6,13,18,22,17,15],Jdt:[16,28,10,15,24,21,32,36,14,23,23,20,20,19,14,25],GkEsth:[22,23,15,17,14,14,10,17,32,13,12,6,18,19,16,24],Wis:[16,24,19,20,23,25,30,21,18,21,26,27,19,31,19,29,21,25,22],Sir:[30,18,31,31,15,37,36,19,18,31,34,18,26,27,20,30,32,33,30,31,28,27,27,34,26,29,30,26,28,25,31,24,33,31,26,31,31,34,35,30,22,25,33,23,26,20,25,25,16,29,30],Bar:[22,35,37,37,9],PrAzar:[68],Sus:[64],Bel:[42],SgThree:[39],EpJer:[73],"1Macc":[64,70,60,61,68,63,50,32,73,89,74,53,53,49,41,24],"2Macc":[36,32,40,50,27,31,42,36,29,38,38,45,26,46,39],"3Macc":[29,33,30,21,51,41,23],"4Macc":[35,24,21,26,38,35,23,29,32,21,27,19,27,20,32,25,24,24],"1Esd":[58,30,24,63,73,34,15,96,55],"2Esd":[40,48,36,52,56,59,70,63,47,59,46,51,58,48,63,78],PrMan:[15],Ps151:[7]}},vulgate:{chapters:{Gen:[31,25,24,26,32,22,24,22,29,32,32,20,18,24,21,16,27,33,38,18,34,24,20,67,34,35,46,22,35,43,55,32,20,31,29,43,36,30,23,23,57,38,34,34,28,34,31,22,32,25],Exod:[22,25,22,31,23,30,25,32,35,29,10,51,22,31,27,36,16,27,25,26,36,31,33,18,40,37,21,43,46,38,18,35,23,35,35,38,29,31,43,36],Lev:[17,16,17,35,19,30,38,36,24,20,47,8,59,57,33,34,16,30,37,27,24,33,44,23,55,45,34],Num:[54,34,51,49,31,27,89,26,23,36,34,15,34,45,41,50,13,32,22,30,35,41,30,25,18,65,23,31,39,17,54,42,56,29,34,13],Josh:[18,24,17,25,16,27,26,35,27,44,23,24,33,15,63,10,18,28,51,9,43,34,16,33],Judg:[36,23,31,24,32,40,25,35,57,18,40,15,25,20,20,31,13,31,30,48,24],"1Sam":[28,36,21,22,12,21,17,22,27,27,15,25,23,52,35,23,58,30,24,43,15,23,28,23,44,25,12,25,11,31,13],"1Kgs":[53,46,28,34,18,38,51,66,28,29,43,33,34,31,34,34,24,46,21,43,29,54],"1Chr":[54,55,24,43,26,81,40,40,44,14,46,40,14,17,29,43,27,17,19,7,30,19,32,31,31,32,34,21,30],Neh:[11,20,31,23,19,19,73,18,38,39,36,46,31],Job:[22,13,26,21,27,30,21,22,35,22,20,25,28,22,35,23,16,21,29,29,34,30,17,25,6,14,23,28,25,31,40,22,33,37,16,33,24,41,35,28,25,16],Ps:[6,13,9,10,13,11,18,10,39,8,9,6,7,5,10,15,51,15,10,14,32,6,10,22,12,14,9,11,13,25,11,22,23,28,13,40,23,14,18,14,12,5,26,18,12,10,15,21,23,21,11,7,9,24,13,12,12,18,14,9,13,12,11,14,20,8,36,37,6,24,20,28,23,11,13,21,72,13,20,17,8,19,13,14,17,7,19,53,17,16,16,5,23,11,13,12,9,9,5,8,29,22,35,45,48,43,14,31,7,10,10,9,26,9,10,2,29,176,7,8,9,4,8,5,6,5,6,8,8,3,18,3,3,21,26,9,8,24,14,10,8,12,15,21,10,11,9,14,9,6],Eccl:[18,26,22,17,19,11,30,17,18,20,10,14],Song:[16,17,11,16,17,12,13,14],Jer:[19,37,25,31,31,30,34,22,26,25,23,17,27,22,21,21,27,23,15,18,14,30,40,10,38,24,22,17,32,24,40,44,26,22,19,32,20,28,18,16,18,22,13,30,5,28,7,47,39,46,64,34],Ezek:[28,9,27,17,17,14,27,18,11,22,25,28,23,23,8,63,24,32,14,49,32,31,49,27,17,21,36,26,21,26,18,32,33,31,15,38,28,23,29,49,26,20,27,31,25,24,23,35],Dan:[21,49,100,34,31,28,28,27,27,21,45,13,65,42],Hos:[11,24,5,19,15,11,16,14,17,15,12,14,15,10],Amos:[15,16,15,13,27,15,17,14,14],Jonah:[16,11,10,11],Mic:[16,13,12,13,14,16,20],Hag:[14,24],Matt:[25,23,17,25,48,34,29,34,38,42,30,50,58,36,39,28,26,35,30,34,46,46,39,51,46,75,66,20],Mark:[45,28,35,40,43,56,37,39,49,52,33,44,37,72,47,20],John:[51,25,36,54,47,72,53,59,41,42,57,50,38,31,27,33,26,40,42,31,25],Acts:[26,47,26,37,42,15,59,40,43,48,30,25,52,27,41,40,34,28,40,38,40,30,35,27,27,32,44,31],"2Cor":[24,17,18,18,21,18,16,24,15,18,33,21,13],Rev:[20,29,22,11,14,17,17,13,21,11,19,18,18,20,8,21,18,24,21,15,27,21],Tob:[25,23,25,23,28,22,20,24,12,13,21,22,23,17],Jdt:[12,18,15,17,29,21,25,34,19,20,21,20,31,18,15,31],Wis:[16,25,19,20,24,27,30,21,19,21,27,27,19,31,19,29,20,25,20],Sir:[40,23,34,36,18,37,40,22,25,34,36,19,32,27,22,31,31,33,28,33,31,33,38,47,36,28,33,30,35,27,42,28,33,31,26,28,34,39,41,32,28,26,37,27,31,23,31,28,19,31,38,13],Bar:[22,35,38,37,9,72],"1Macc":[67,70,60,61,68,63,50,32,73,89,74,54,54,49,41,24],"2Macc":[36,33,40,50,27,31,42,36,29,38,38,46,26,46,40]}},ceb:{chapters:{"2Cor":[24,17,18,18,21,18,16,24,15,18,33,21,13],Rev:[20,29,22,11,14,17,17,13,21,11,19,18,18,20,8,21,18,24,21,15,27,21],Tob:[22,14,17,21,22,18,16,21,6,13,18,22,18,15],PrAzar:[67],EpJer:[72],"1Esd":[55,26,24,63,71,33,15,92,55]}},kjv:{chapters:{"3John":[14]}},nab:{order:{Gen:1,Exod:2,Lev:3,Num:4,Deut:5,Josh:6,Judg:7,Ruth:8,"1Sam":9,"2Sam":10,"1Kgs":11,"2Kgs":12,"1Chr":13,"2Chr":14,PrMan:15,Ezra:16,Neh:17,"1Esd":18,"2Esd":19,Tob:20,Jdt:21,Esth:22,GkEsth:23,"1Macc":24,"2Macc":25,"3Macc":26,"4Macc":27,Job:28,Ps:29,Prov:30,Eccl:31,Song:32,Wis:33,Sir:34,Isa:35,Jer:36,Lam:37,Bar:38,EpJer:39,Ezek:40,Dan:41,PrAzar:42,Sus:43,Bel:44,SgThree:45,Hos:46,Joel:47,Amos:48,Obad:49,Jonah:50,Mic:51,Nah:52,Hab:53,Zeph:54,Hag:55,Zech:56,Mal:57,Matt:58,Mark:59,Luke:60,John:61,Acts:62,Rom:63,"1Cor":64,"2Cor":65,Gal:66,Eph:67,Phil:68,Col:69,"1Thess":70,"2Thess":71,"1Tim":72,"2Tim":73,Titus:74,Phlm:75,Heb:76,Jas:77,"1Pet":78,"2Pet":79,"1John":80,"2John":81,"3John":82,Jude:83,Rev:84},chapters:{Gen:[31,25,24,26,32,22,24,22,29,32,32,20,18,24,21,16,27,33,38,18,34,24,20,67,34,35,46,22,35,43,54,33,20,31,29,43,36,30,23,23,57,38,34,34,28,34,31,22,33,26],Exod:[22,25,22,31,23,30,29,28,35,29,10,51,22,31,27,36,16,27,25,26,37,30,33,18,40,37,21,43,46,38,18,35,23,35,35,38,29,31,43,38],Lev:[17,16,17,35,26,23,38,36,24,20,47,8,59,57,33,34,16,30,37,27,24,33,44,23,55,46,34],Num:[54,34,51,49,31,27,89,26,23,36,35,16,33,45,41,35,28,32,22,29,35,41,30,25,19,65,23,31,39,17,54,42,56,29,34,13],Deut:[46,37,29,49,33,25,26,20,29,22,32,31,19,29,23,22,20,22,21,20,23,29,26,22,19,19,26,69,28,20,30,52,29,12],"1Sam":[28,36,21,22,12,21,17,22,27,27,15,25,23,52,35,23,58,30,24,42,16,23,28,23,44,25,12,25,11,31,13],"2Sam":[27,32,39,12,25,23,29,18,13,19,27,31,39,33,37,23,29,32,44,26,22,51,39,25],"1Kgs":[53,46,28,20,32,38,51,66,28,29,43,33,34,31,34,34,24,46,21,43,29,54],"2Kgs":[18,25,27,44,27,33,20,29,37,36,20,22,25,29,38,20,41,37,37,21,26,20,37,20,30],"1Chr":[54,55,24,43,41,66,40,40,44,14,47,41,14,17,29,43,27,17,19,8,30,19,32,31,31,32,34,21,30],"2Chr":[18,17,17,22,14,42,22,18,31,19,23,16,23,14,19,14,19,34,11,37,20,12,21,27,28,23,9,27,36,27,21,33,25,33,27,23],Neh:[11,20,38,17,19,19,72,18,37,40,36,47,31],Job:[22,13,26,21,27,30,21,22,35,22,20,25,28,22,35,22,16,21,29,29,34,30,17,25,6,14,23,28,25,31,40,22,33,37,16,33,24,41,30,32,26,17],Ps:[6,11,9,9,13,11,18,10,21,18,7,9,6,7,5,11,15,51,15,10,14,32,6,10,22,12,14,9,11,13,25,11,22,23,28,13,40,23,14,18,14,12,5,27,18,12,10,15,21,23,21,11,7,9,24,14,12,12,18,14,9,13,12,11,14,20,8,36,37,6,24,20,28,23,11,13,21,72,13,20,17,8,19,13,14,17,7,19,53,17,16,16,5,23,11,13,12,9,9,5,8,29,22,35,45,48,43,14,31,7,10,10,9,8,18,19,2,29,176,7,8,9,4,8,5,6,5,6,8,8,3,18,3,3,21,26,9,8,24,14,10,8,12,15,21,10,20,14,9,6],Eccl:[18,26,22,17,19,12,29,17,18,20,10,14],Song:[17,17,11,16,16,12,14,14],Isa:[31,22,26,6,30,13,25,23,20,34,16,6,22,32,9,14,14,7,25,6,17,25,