-
Notifications
You must be signed in to change notification settings - Fork 27
/
bfe.min.js
executable file
·4 lines (4 loc) · 102 KB
/
bfe.min.js
1
2
3
4
/* bfe 2015-10-23 */!function(){function a(a){var b=function(a,b){return e("",a,b)},f=c;a&&(c[a]||(c[a]={}),f=c[a]),f.define&&f.define.packaged||(d.original=f.define,f.define=d,f.define.packaged=!0),f.require&&f.require.packaged||(e.original=f.require,f.require=b,f.require.packaged=!0)}var b="bfe",c=function(){return this}();if(b||"undefined"==typeof requirejs){var d=function(a,b,c){return"string"!=typeof a?void(d.original?d.original.apply(window,arguments):(console.error("dropping module because define wasn't a string."),console.trace())):(2==arguments.length&&(c=b),d.modules||(d.modules={},d.payloads={}),d.payloads[a]=c,void(d.modules[a]=null))},e=function(a,b,c){if("[object Array]"===Object.prototype.toString.call(b)){for(var d=[],f=0,h=b.length;h>f;++f){var i=g(a,b[f]);if(!i&&e.original)return e.original.apply(window,arguments);d.push(i)}c&&c.apply(null,d)}else{if("string"==typeof b){var j=g(a,b);return!j&&e.original?e.original.apply(window,arguments):(c&&c(),j)}if(e.original)return e.original.apply(window,arguments)}},f=function(a,b){if(-1!==b.indexOf("!")){var c=b.split("!");return f(a,c[0])+"!"+f(a,c[1])}if("."==b.charAt(0)){var d=a.split("/").slice(0,-1).join("/");for(b=d+"/"+b;-1!==b.indexOf(".")&&e!=b;){var e=b;b=b.replace(/\/\.\//,"/").replace(/[^\/]+\/\.\.\//,"")}}return b},g=function(a,b){b=f(a,b);var c=d.modules[b];if(!c){if(c=d.payloads[b],"function"==typeof c){var g={},h={id:b,uri:"",exports:g,packaged:!0},i=function(a,c){return e(b,a,c)},j=c(i,g,h);g=j||h.exports,d.modules[b]=g,delete d.payloads[b]}c=d.modules[b]=g||c}return c};a(b)}}(),bfe.define("src/bfe",["require","exports","module","src/lib/jquery-2.1.0.min","src/lib/json","src/lib/lodash.min","src/lib/bootstrap.min","src/lib/typeahead.jquery.min","src/bfestore","src/bfelogging","src/lookups/lcnames","src/lookups/lcsubjects","src/lookups/lcgenreforms","src/lookups/lcworks","src/lookups/lcinstances","src/lookups/lcorganizations","src/lookups/lccountries","src/lookups/lcgacs","src/lookups/lclanguages","src/lookups/lcidentifiers","src/lookups/lctargetaudiences","src/lookups/iso6391","src/lookups/iso6392","src/lookups/iso6395","src/lookups/rdacontenttypes","src/lookups/rdamediatypes","src/lookups/rdacarriers","src/lookups/rdamodeissue","src/lookups/lcrelators","src/lookups/lcperformanceMediums","src/lookups/rdamusnotation","src/lookups/rdaformatnotemus","src/lib/aceconfig"],function(a,b,c){function d(a){if(void 0!==a.scheme){z.addMsg(new Error,"INFO","Setting up scheme "+a.scheme);var b=config.lookups[a.scheme];H[a.scheme]={},H[a.scheme].name=b.name,H[a.scheme].load=a}else z.addMsg(new Error,"WARN","Loading lookup FAILED",a);f()}function e(a){$.get("/api/");var b=null;if(document.cookie&&""!=document.cookie)for(var c=document.cookie.split(";"),d=0;d<c.length;d++){var e=jQuery.trim(c[d]);if(e.substring(0,a.length+1)==a+"="){b=decodeURIComponent(e.substring(a.length+1));break}}return b}function f(){if($("#bfeditor-loader").width($("#bfeditor-loader").width()+5+"%"),F++,F>=E&&($("#bfeditor-formdiv").html(""),D.length>0)){z.addMsg(new Error,"DEBUG","Loading selected template(s)",D);var a=h(D);$(".typeahead",a.form).each(function(){p(this)});var b=$('<div class="btn-group pull-right"> <button id="bfeditor-exitcancel" type="button" class="btn btn-default">Cancel</button> <button id="bfeditor-exitpreview" type="button" class="btn btn-primary">Preview</button> </div>');a.form.append(b),$("#bfeditor-exitcancel",a.form).click(function(){$("#bfeditor > .row").remove(),$("#bfeditor > .footer").remove(),bfeditor=bfe.fulleditor(config,"bfeditor")}),$("#bfeditor-exitcancel",a.form).attr("tabindex",C++),$("#bfeditor-exitpreview",a.form).click(function(){var a=bfeditor.bfestore.store2text(),b=bfeditor.bfestore.store2jsonldExpanded();document.body.scrollTop=document.documentElement.scrollTop=0;var c=$('<div class="btn-group" id="save-btn"> <button id="bfeditor-exitback" type="button" class="btn btn-default">Back</button> <button id="bfeditor-exitsave" type="button" class="btn btn-primary">Save</button> </div>'),d=$("#bfeditor > .row"),f=$('<div id="bfeditor-preview" class="col-md-10 main panel-group"> <div class="panel panel-default"><div class="panel-heading"> <h3 class="panel-title"><a role="button" data-toggle="collapse" href="#humanized">Preview</a></h3></div> <div class="panel-collapse collapse in" id="humanized"><div class="panel-body"><pre>'+a+'</pre></div></div> <div class="panel panel-default"><div class="panel-heading"><h3 class="panel-title"><a role="button" data-toggle="collapse" href="#jsonld">JSONLD-Expanded</a></h3></div> <div class="panel-collapse collapse in" id="jsonld"><div class="panel-body"><pre>'+JSON.stringify(b,void 0," ")+"</pre></div></div></div> </div>");d.append(c),$("#bfeditor-exitback").click(function(){$("#save-btn").remove(),$("#bfeditor-preview").remove(),$("#bfeditor-formdiv").show()}),$("#bfeditor-exitsave").click(function(){if(void 0!==x.save.callback)x.save.callback(y.store2jsonldExpanded(),e("csrftoken"));else{$("#bfeditor > .row").remove(),$("#bfeditor > .footer").remove(),$("#bfeditor-debugdiv").remove(),bfeditor=bfe.fulleditor(config,"bfeditor");var a=$("<div>",{id:"bfeditor-messagediv"});a.append('<span class="str"><h3>Save disabled</h3></span>'),$("#bfeditor-formdiv").append(a)}}),$("#bfeditor-formdiv").hide(),d.append(f)}),$("#bfeditor-exitpreview",a.form).attr("tabindex",C++),$("#bfeditor-formdiv").html(""),$("#bfeditor-formdiv").append(a.form),$("#bfeditor-debug").html(JSON.stringify(y.store,void 0," ")),$("#bfeditor-debug").html(JSON.stringify(z.getLog(),void 0," "))}}function g(a){spnums=a.replace("sp-","").split("_"),spoints=x.startingPoints[spnums[0]].menuItems[spnums[1]],y.store=[],loadtemplatesCounter=0,loadtemplatesCount=spoints.useResourceTemplates.length,D=[],spoints.useResourceTemplates.forEach(function(a){var b=u(),c={},d=[];c.templateGUID=b,c.resourceTemplateID=a,c.embedType="page",c.data=d,D.push(c),f()})}function h(a){var b,c=u(),d={};d.id=c,d.store=[],d.resourceTemplates=[],d.resourceTemplateIDs=[],d.formTemplates=[];for(var e=0;e<a.length;e++){var b=_.where(B,{id:a[e].resourceTemplateID});void 0!==b&&void 0!==b[0]?(d.resourceTemplates[e]=JSON.parse(JSON.stringify(b[0])),d.resourceTemplates[e].data=a[e].data,d.resourceTemplates[e].defaulturi=a[e].resourceURI,d.resourceTemplates[e].useguid=a[e].templateGUID,d.resourceTemplates[e].embedType=a[e].embedType,void 0===d.resourceTemplates[e].defaulturi&&(d.resourceTemplates[e].defaulturi=v(d.resourceTemplates[e],x.baseURI)+a[e].templateGUID),d.resourceTemplateIDs[e]=b[0].id):z.addMsg(new Error,"WARN","Unable to locate resourceTemplate. Verify the resourceTemplate ID is correct.")}var f=$("<form>",{id:"bfeditor-form-"+d.id,"class":"form-horizontal",role:"form"}),g=!0;return d.resourceTemplates.forEach(function(a){z.addMsg(new Error,"DEBUG","Creating form for: "+a.id,a);var b=$("<div>",{id:a.useguid,"data-uri":a.defaulturi}),c=$("<h3>"+a.resourceLabel+"</h3>");b.append(c),a.propertyTemplates.forEach(function(c){var e=u();c.guid=e,c.display="true";var f=$("<div>",{"class":"form-group row"}),h=$('<div class="form-group row"><div class="btn-toolbar col-sm-12" role="toolbar"></div></div></div>');if(/^http/.test(c.remark))var i=$('<label for="'+c.guid+'" class="col-sm-3 control-label" title="'+c.remark+'"><a href="'+c.remark+'" target="_blank">'+c.propertyLabel+"</a></label>");else var i=$('<label for="'+c.guid+'" class="col-sm-3 control-label" title="'+c.remark+'">'+c.propertyLabel+"</label>");if("literal"==c.type){var k=$('<div class="col-sm-8"><input type="text" class="form-control" id="'+c.guid+'" placeholder="'+c.propertyLabel+'" tabindex="'+C++ +'"></div>');k.find("input").keyup(function(a){if(54==a.keyCode&&a.ctrlKey&&a.altKey){var b=this.value;this.value=b+"©"}else 53==a.keyCode&&a.ctrlKey&&a.altKey&&(this.value=this.value+"℗")}),$button=$('<div class="btn-group btn-group-md span1"><button type="button" class="btn btn-default" tabindex="'+C++ +'"><i class="fa fa-plus"></i></button></div>'),$button.click(function(){n(d.id,a.useguid,c.guid)});var l=function(b){13==b.keyCode&&(n(d.id,a.useguid,c.guid),$("#"+c.guid).parent().parent().next().find("input:not('.tt-hint')").length?$("#"+c.guid).parent().parent().next().find("input:not('.tt-hint')").focus():$("[id^=bfeditor-modalSave]").focus())};k.keyup(l),f.append(i),k.append(h),f.append(k),f.append($button)}if("resource"==c.type)if(_.has(c,"valueConstraint"))if(_.has(c.valueConstraint,"valueTemplateRefs")&&!_.isEmpty(c.valueConstraint.valueTemplateRefs)){$buttondiv=$('<div class="col-sm-8" id="'+c.guid+'"></div>'),$buttongrp=$('<div class="btn-group btn-group-md"></div>');for(var m=c.valueConstraint.valueTemplateRefs,p=0;p<m.length;p++){var q=m[p],r=_.where(B,{id:q});if(void 0!==r[0]){var s=r[0],t=$('<button type="button" class="btn btn-default" tabindex="'+C++ +'">'+s.resourceLabel+"</button>"),v=d.id,w=(a.useguid,c.guid),x="_:bnode"+u();t.click({fobjectid:v,newResourceURI:x,propertyguid:w,template:s},function(a){var b="_:bnode"+u();j(a.data.fobjectid,a.data.template,b,a.data.propertyguid,[])}),$buttongrp.append(t)}}$buttondiv.append($buttongrp),f.append(i),$buttondiv.append(h),f.append($buttondiv)}else if(_.has(c.valueConstraint,"useValuesFrom")){if("modal"!=a.embedType&&g&&c.propertyLabel.match(/lookup/i))return void(g=!1);var y=$('<div class="col-sm-8"></div>'),k=$('<input type="text" class="typeahead form-control" data-propertyguid="'+c.guid+'" id="'+c.guid+'" placeholder="'+c.propertyLabel+'" tabindex="'+C++ +'">'),z=$('<input type="hidden" id="'+c.guid+'_page" class="typeaheadpage" value="1">');if(y.append(k),y.append(z),k.on("focus",function(){""===$(this).val()&&$(this).data().ttTypeahead.input.trigger("queryChanged","")}),f.append(i),y.append(h),f.append(y),"modal"==a.embedType&&g&&c.propertyLabel.match(/lookup/i)){var A=$('<div class="modal-header" style="text-align: right;"><button type="button" class="btn btn-primary" id="bfeditor-modalSaveLookup-'+d.id+'" tabindex="'+C++ +'">Save changes</button></div>'),D=$('<div class="modal-header" style="text-align: center;"><h2>OR</h2></div>');f.append(A),f.append(D)}}else{var k=$('<div class="col-sm-8"><input class="form-control" id="'+c.guid+'" placeholder="'+c.propertyLabel+'" tabindex="'+C++ +'"></div>');$button=$('<div class="col-sm-1"><button type="button" class="btn btn-default" tabindex="'+C++ +'">Set</button></div>'),$button.click(function(){o(d.id,a.useguid,c.guid)}),f.append(i),k.append(h),f.append(k),f.append($button)}else{var k=$('<div class="col-sm-8"><input class="form-control" id="'+c.guid+'" placeholder="'+c.propertyLabel+'" tabindex="'+C++ +'"></div>');$button=$('<div class="col-sm-1"><button type="button" class="btn btn-default" tabindex="'+C++ +'">Set</button></div>'),$button.click(function(){o(d.id,a.useguid,c.guid)}),f.append(i),k.append(h),f.append(k),f.append($button)}b.append(f),g=!1}),f.append(b)}),d.resourceTemplates.forEach(function(a){if(0===a.data.length){var b;u();b=void 0!==a.defaulturi&&""!==a.defaulturi?a.defaulturi:x.baseURI+a.useguid;var c={};c.guid=a.useguid,c.rtID=a.id,c.s=b,c.p="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",c.o=a.resourceURI,c.otype="uri",d.store.push(c),y.store.push(c),a.guid=a.useguid,a.propertyTemplates.forEach(function(e){if(_.has(e,"valueConstraint")&&_.has(e.valueConstraint,"valueTemplateRefs")&&!_.isEmpty(e.valueConstraint.valueTemplateRefs))for(var f=e.valueConstraint.valueTemplateRefs,g=0;g<f.length;g++){var h=f[g];if(d.resourceTemplateIDs.indexOf(h)>-1&&h!=a.id){var i=_.where(y.store,{rtID:h});c={},c.guid=u(),c.s=b,c.p=e.propertyURI,c.o=i[0].s,c.otype="uri",d.store.push(c),y.store.push(c),e.display="false"}}})}else a.data.forEach(function(a){var b={};b=a,void 0===b.guid&&(b.guid=u()),d.store.push(b)});z.addMsg(new Error,"DEBUG","Populating form with pre-loaded data, if any"),a.propertyTemplates.forEach(function(b){var c=_.where(y.store,{s:a.defaulturi,p:b.propertyURI});if(void 0!==c[0])z.addMsg(new Error,"DEBUG","Found pre-loaded data for "+b.propertyURI),c.forEach(function(a){var c=$("#"+b.guid,f).closest(".form-group"),e=c.find(".btn-toolbar").eq(0),g="",h=[];if("uri"==a.otype){var h=_.where(y.store,{s:a.o});g=a.o;var i="";h.length>0&&h.forEach(function(a){""==i&&"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"==a.p&&(i=a.o);var c="";if(""!=i&&_.has(b,"valueConstraint")&&_.has(b.valueConstraint,"valueTemplateRefs")&&!_.isEmpty(b.valueConstraint.valueTemplateRefs)){var e=_.where(B,{resourceURI:i});e.forEach(function(d){""==c&&-1!==_.indexOf(b.valueConstraint.valueTemplateRefs,d.id)&&(z.addMsg(new Error,"DEBUG","Assocating one resource with another from loaded templates"),c=d.id,a.rtID=d.id)})}d.store.push(a),a.p.match(/label|authorizedAccessPoint/i)&&(g=a.o)})}else g=a.o;""==g&&(g=a.s),h.push(a);var j={tguid:a.guid,tlabelhover:g,tlabel:g,fobjectid:d.id,inputid:b.guid,triples:h},k=m(j);if(e.append(k),void 0!==b.valueConstraint&&void 0!==b.valueConstraint.repeatable&&"false"==b.valueConstraint.repeatable){var l=$("#"+b.guid,f);if(l.is("input"))l.prop("disabled",!0);else{var n=$("div.btn-group",l).find("button");n.each(function(){$(this).prop("disabled",!0)})}}});else if(_.has(b,"valueConstraint")&&_.has(b.valueConstraint,"defaultURI")&&!_.isEmpty(b.valueConstraint.defaultURI)){z.addMsg(new Error,"DEBUG","Setting default data for "+b.propertyURI);var e=b.valueConstraint.defaultURI,g={};g.guid=u(),void 0!==a.defaulturi&&""!==a.defaulturi?g.s=a.defaulturi:g.s=x.baseURI+a.useguid,g.p=b.propertyURI,g.o=e,g.otype="uri",d.store.push(g),y.store.push(g);var h={};h.s=g.o,h.otype="literal",h.p="http://bibframe.org/vocab/label",h.o=b.valueConstraint.defaultLiteral,d.store.push(h),y.store.push(h);var i=$("#"+b.guid,f).closest(".form-group"),j=i.find(".btn-toolbar").eq(0),k="";_.has(b.valueConstraint,"defaultLiteral")&&(k=b.valueConstraint.defaultLiteral),displaydata=k;var l=!0;void 0!==b.valueConstraint.editable&&"false"===b.valueConstraint.editable&&(l=!1);var n={tguid:g.guid,tlabelhover:displaydata,tlabel:displaydata,fobjectid:d.id,inputid:b.guid,editable:l,triples:[h]},o=m(n);if(j.append(o),void 0!==b.valueConstraint.repeatable&&"false"==b.valueConstraint.repeatable){var p=$("#"+b.guid,f);if(p.is("input"))p.prop("disabled",!0);else{var q=$("div.btn-group",p).find("button");q.each(function(){$(this).prop("disabled",!0)})}}}})}),G.push(d),z.addMsg(new Error,"DEBUG","Newly created formobject.",d),{formobject:d,form:f}}function j(a,b,c,d,e){var f='<div class="modal fade" id="bfeditor-modal-modalID" tabindex="'+C++ +'" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title" id="bfeditor-modaltitle-modalID">Modal title</h4> </div> <div class="modal-body" id="bfeditor-modalbody-modalID"></div> <div class="modal-footer"> <button type="button" class="btn btn-default" id="bfeditor-modalCancel-modalID" data-dismiss="modal">Cancel</button> <button type="button" class="btn btn-primary" id="bfeditor-modalSave-modalID">Save changes</button> </div> </div> </div> </div> ';z.addMsg(new Error,"DEBUG","Opening modal for resourceURI "+c),z.addMsg(new Error,"DEBUG","inputID of DOM element / property when opening modal: "+d),z.addMsg(new Error,"DEBUG","callingformobjectid when opening modal: "+a);var g=u(),i=[];if(0===e.length){var j=_.where(G,{id:a});j=j[0],j.resourceTemplates.forEach(function(a){var e=_.where(a.propertyTemplates,{guid:d});if(void 0!==e[0]){var f={};f.s=a.defaulturi,f.p=e[0].propertyURI,f.o=c,f.otype="uri",i.push(f),f={},f.s=c,f.rtID=b.id,f.p="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",f.o=b.resourceURI,f.otype="uri",i.push(f)}})}else i=e;z.addMsg(new Error,"DEBUG","triplespassed within modal",i);var k=h([{templateGUID:g,resourceTemplateID:b.id,resourceURI:c,embedType:"modal",data:i}]),m=f.replace(/modalID/g,k.formobject.id);m=$(m),$(w).append(m),$("#bfeditor-modalbody-"+k.formobject.id).append(k.form),$("#bfeditor-modaltitle-"+k.formobject.id).html(b.resourceLabel),$("#bfeditor-modal-"+k.formobject.id).modal("show"),$("#bfeditor-modalCancel-"+k.formobject.id).attr("tabindex",C++),$("#bfeditor-modalSave-"+k.formobject.id).click(function(){e.forEach(function(b){s(a,d,null,b)}),k.formobject.store.length<=2?($("#bfeditor-modalSave-"+k.formobject.id).off("click"),$("#bfeditor-modal-"+k.formobject.id).modal("hide")):l(a,k.formobject.id,c,d,k.formobject.store)}),$("#bfeditor-modalSave-"+k.formobject.id).attr("tabindex",C++),$("#bfeditor-modalSaveLookup-"+k.formobject.id).click(function(){e.forEach(function(b){s(a,d,null,b)}),l(a,k.formobject.id,c,d,k.formobject.store)}),$("#bfeditor-modal-"+k.formobject.id).on("hide.bs.modal",function(a){$(this).empty()}),$(".typeahead",k.form).each(function(){p(this)}),$("#bfeditor-debug").html(JSON.stringify(y.store,void 0," ")),$("#bfeditor-modal-"+k.formobject.id+" input:not('.tt-hint'):first").focus()}function l(a,b,c,d,e){z.addMsg(new Error,"DEBUG","Setting resource from modal"),z.addMsg(new Error,"DEBUG","modal form id is: "+b);var f=_.where(G,{id:a});f=f[0],f.resourceTemplates.forEach(function(b){var c=_.where(b.propertyTemplates,{guid:d});if(void 0!==c[0]){z.addMsg(new Error,"DEBUG","Data from modal: ",e),e.forEach(function(a){f.store.push(a),y.store.push(a)}),y.storeDedup();var g=$("#"+d,f.form).closest(".form-group"),h=g.find(".btn-toolbar")[0];if(z.addMsg(new Error,"DEBUG","Selected property from calling form: "+c[0].propertyURI),tlabel=_.find(e,function(a){return a.p.match(/label|authorizedAccessPoint|^title$|titleValue/i)?a.o:void 0}),void 0!==tlabel)j=tlabel.o,displayuri=tlabel.s;else{for(i in e){var j;"literal"===e[i].otype&&(void 0===j&&(j=""),j+=e[i].o+" ")}displayuri=e[0].s,void 0===j&&(j=e[0].s),j.trimRight()}var k=_.where(e,{p:c[0].propertyURI}),l={tguid:k[0].guid,tlabelhover:j,tlabel:j,tlabelURI:displayuri,fobjectid:a,inputid:d,triples:e},n=m(l);$(h).append(n),void 0!==c[0].repeatable&&"false"==c[0].repeatable&&$("#"+d,f.form).attr("disabled",!0)}}),$("#bfeditor-modalSave-"+b).off("click"),$("#bfeditor-modal-"+b).modal("hide"),$("#bfeditor-debug").html(JSON.stringify(y.store,void 0," "))}function m(a){var b=$("<div>",{id:a.tguid,"class":"btn-group btn-group-xs"});_.isUndefined(a.tlabel)?display="example":a.tlabel.length>40?display=a.tlabel.substr(0,40)+"...":display=a.tlabel;var c=$('<button type="button" class="btn btn-default" title="'+a.tlabelhover+'">'+display+"</button>");if(void 0!==a.tlabelURI&&a.tlabelURI.match("^!_:b")&&(c=$('<button type="button" class="btn btn-default" title="'+a.tlabelhover+'"><a href="'+a.tlabelURI+'">'+display+"</a></button>")),b.append(c),void 0===a.editable||a.editable===!0){var d=$('<button class="btn btn-warning" type="button"> <span class="glyphicon glyphicon-pencil"></span></button>');d.click(function(){1===a.triples.length?q(a.fobjectid,a.inputid,a.triples[0]):r(a.fobjectid,a.inputid,a.tguid,a.triples)}),b.append(d)}var e=$('<button class="btn btn-danger" type="button"><span class="glyphicon glyphicon-trash"></span> </button>');return e.click(function(){1===a.triples.length?s(a.fobjectid,a.inputid,a.tguid,a.triples[0]):t(a.fobjectid,a.inputid,a.tguid,a.triples)}),b.append(e),b}function n(a,b,c){var d=_.where(G,{id:a});d=d[0];var e=$("#"+c,d.form).val();if(void 0!==e&&""!==e){var f={};f.guid=u(),d.resourceTemplates.forEach(function(g){var h=_.where(g.propertyTemplates,{guid:c});if(void 0!==h[0]){void 0!==g.defaulturi&&""!==g.defaulturi?f.s=g.defaulturi:f.s=x.baseURI+b,f.p=h[0].propertyURI,f.o=e,f.otype="literal",y.store.push(f),d.store.push(f);var i=$("#"+c,d.form).closest(".form-group"),j=$(i).find(".btn-toolbar")[0],k={tguid:f.guid,tlabel:e,tlabelhover:e,fobjectid:a,inputid:c,triples:[f]},l=m(k);$(j).append(l),$("#"+c,d.form).val(""),void 0!==h[0].repeatable&&"false"==h[0].repeatable&&$("#"+c,d.form).attr("disabled",!0)}})}$("#bfeditor-debug").html(JSON.stringify(y.store,void 0," "))}function o(a,b,c){var d=_.where(G,{id:a});d=d[0];var e=$("#"+c,d.form).val();if(void 0!==e&&""!==e){var f={};f.guid=u(),d.resourceTemplates.forEach(function(g){var h=_.where(g.propertyTemplates,{guid:c});if(void 0!==h[0]){void 0!==g.defaulturi&&""!==g.defaulturi?f.s=g.defaulturi:f.s=x.baseURI+b,f.p=h[0].propertyURI,f.o=e,f.otype="uri",y.store.push(f),d.store.push(f);var i=$("#"+c,d.form).closest(".form-group"),j=i.find(".btn-toolbar")[0],k={tguid:f.guid,tlabel:f.o,tlabelhover:f.o,fobjectid:a,inputid:c,triples:[f]},l=m(k);$(j).append(l),$("#"+c,d.form).val(""),void 0!==h[0].repeatable&&"false"==h[0].repeatable&&$("#"+c,d.form).attr("disabled",!0)}})}$("#bfeditor-debug").html(JSON.stringify(y.store,void 0," "))}function p(a){var b=($(a).closest("form").eq(0),$(a).closest("form").eq(0).attr("id")),c=$(a).siblings(".typeaheadpage").attr("id");b=b.replace("bfeditor-form-","");var d=_.where(G,{id:b});d=d[0],"undefined"!=typeof c&&(d.pageid=c);var e,f=$(a).attr("data-propertyguid");d.resourceTemplates.forEach(function(a){var b=_.where(a.propertyTemplates,{guid:f});void 0!==b[0]&&(e=b[0])});var g=e.valueConstraint.useValuesFrom,h=[];g.forEach(function(a){var b=H[a];z.addMsg(new Error,"DEBUG","Setting typeahead scheme: "+a),z.addMsg(new Error,"DEBUG","Lookup is",b);var c={};c.name=b.name,c.source=function(a,c){b.load.source(a,c,d)},c.templates={header:"<h3>"+b.name+"</h3>",footer:'<div id="dropdown-footer" class=".col-sm-1"></div>'},c.displayKey="value",h.push(c)}),z.addMsg(new Error,"DEBUG","Data source hashes",h);var i={minLength:0,highlight:!0,displayKey:"value"};1===h.length?$(a).typeahead(i,h[0]):2===h.length?$(a).typeahead(i,h[0],h[1]):3===h.length?$(a).typeahead(i,h[0],h[1],h[2]):4===h.length?$(a).typeahead(i,h[0],h[1],h[2],h[3]):5===h.length?$(a).typeahead(i,h[0],h[1],h[2],h[3],h[4]):6===h.length&&$(a).typeahead(i,h[0],h[1],h[2],h[3],h[4],h[5]),$(a).on("typeahead:selected",function(b,c,d){z.addMsg(new Error,"DEBUG","Typeahead selection made");var e=$("#"+b.target.id).closest("form").eq(0),f=$("#"+b.target.id).closest("form").eq(0).attr("id");f=f.replace("bfeditor-form-",""),$(a).parent().siblings(".typeaheadpage").val(1);var g=$(e).children("div").eq(0).attr("id"),h=$(e).find("div[data-uri]").eq(0).attr("data-uri"),i=$("#"+b.target.id).attr("data-propertyguid");z.addMsg(new Error,"DEBUG","propertyguid for typeahead input is "+i);var j=(x.baseURI+g,""),k=_.where(G,{id:f});k=k[0],k.resourceTemplates.forEach(function(a){var b=_.where(a.propertyTemplates,{guid:i});void 0!==b[0]&&(j=b[0])});var l,n=_.where(H,{name:d});void 0!==n[0]&&(z.addMsg(new Error,"DEBUG","Found lookup for datasetname: "+d,n[0]),l=n[0].load),l.getResource(h,j.propertyURI,c,function(a){z.addMsg(new Error,"DEBUG","Triples returned from lookup's getResource func:",a),a.forEach(function(b){if(void 0===b.guid){var c=u();b.guid=c}k.store.push(b),y.store.push(b),b.s==h&&k.resourceTemplates.forEach(function(c){var d=_.where(c.propertyTemplates,{propertyURI:b.p});if(void 0!==d[0]){var e=d[0],f=e.guid,g=$("#"+f,k.form).closest(".form-group"),h=g.find(".btn-toolbar")[0],i=b.o;if("uri"==b.otype){var j=_.where(a,{s:b.o}),l=_.filter(a,function(a){return a.s.match("^_:b")});j=j.concat(l);var n=_.find(j,function(a){return a.p.match(/label|^title$|titleValue/i)});if(void 0!==n&&void 0!==n.o&&n.o.match("^_:b")){var o=_.where(a,{s:b.s}),n=_.find(o,function(a){return a.p.match(/label|authorizedAccessPoint/i)});i=n.o}else void 0!==n&&void 0!==n.o&&(i=n.o)}var p=[b];void 0!==j&&void 0!==j[0]&&(p=j);var q=!0;void 0!==e.valueConstraint.editable&&"false"===e.valueConstraint.editable&&(q=!1);var r={editable:q,tguid:b.guid,tlabel:i,tlabelhover:i,fobjectid:k.id,inputid:f,triples:p},s=m(r);if($(h).append(s),$("#"+f,k.form).val(""),$("#"+f,k.form).typeahead("val",""),$("#"+f,k.form).typeahead("close"),void 0!==e.valueConstraint&&void 0!==e.valueConstraint.repeatable&&"false"==e.valueConstraint.repeatable){var t=$("#"+f,k.form);if(t.is("input"))t.prop("disabled",!0),t.css("background-color","#EEEEEE");else{var u=$("div.btn-group",t).find("button");u.each(function(){$(this).prop("disabled",!0)})}}}})}),y.storeDedup(),$("#bfeditor-debug").html(JSON.stringify(y.store,void 0," "))})})}function q(a,b,c){var d=_.where(G,{id:a});d=d[0],z.addMsg(new Error,"DEBUG","Editing triple: "+c.guid,c),$("#"+c.guid).empty();var e=$("#"+b,d.form);if(e.is("input")&&e.hasClass("typeahead")){var f=$("#"+b,d.form).parent().find("input[data-propertyguid='"+b+"']");f.each(function(){$(this).prop("disabled",!1),$(this).removeAttr("disabled"),$(this).css("background-color","transparent")})}else if(e.is("input"))e.prop("disabled",!1),e.removeAttr("disabled");else{var g=$("div.btn-group",e).find("button");g.each(function(){$(this).prop("disabled",!1)})}e.is("input")&&"literal"==c.otype&&e.val(c.o),d.store=_.without(d.store,_.findWhere(d.store,{guid:c.guid})),y.store=_.without(y.store,_.findWhere(y.store,{guid:c.guid})),$("#bfeditor-debug").html(JSON.stringify(y.store,void 0," "))}function r(a,b,c,d){z.addMsg(new Error,"DEBUG","Editing triples",d);var e=_.where(d,{p:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"});if(void 0==e[0]&&(e=_.where(d,{p:"@type"})),z.addMsg(new Error,"DEBUG","Triples represent these resourceTypes",e),void 0!==e[0]&&void 0!==typeof e[0]&&void 0!==e[0].rtID){var f=_.where(G,{id:a});f=f[0];var g=_.where(B,{id:e[0].rtID});void 0!==g[0]&&(z.addMsg(new Error,"DEBUG","Opening modal for editing",d),j(f.id,g[0],e[0].s,b,d))}else t(a,b,c,d)}function s(a,b,c,d){var e=_.where(G,{id:a});e=e[0],$("#"+d.guid).length&&void 0!==d?(z.addMsg(new Error,"DEBUG","Removing triple: "+d.guid,d),$("#"+d.guid).remove()):(z.addMsg(new Error,"DEBUG","Removing triple: "+c),$("#"+c).remove(),e.store=_.without(e.store,_.findWhere(e.store,{guid:c})),y.store=_.without(y.store,_.findWhere(y.store,{guid:c})));var f=$("#"+b,e.form);if(f.is("input")&&f.hasClass("typeahead")){var g=$("#"+b,e.form).parent().find("input[data-propertyguid='"+b+"']");g.each(function(){$(this).prop("disabled",!1),$(this).removeAttr("disabled"),$(this).css("background-color","transparent")})}else if(f.is("input"))f.prop("disabled",!1),f.removeAttr("disabled");else{var h=$("div.btn-group",f).find("button");h.each(function(){$(this).prop("disabled",!1)})}e.store=_.without(e.store,_.findWhere(e.store,{guid:d.guid})),y.store=_.without(y.store,_.findWhere(y.store,{guid:d.guid})),$("#bfeditor-debug").html(JSON.stringify(y.store,void 0," "))}function t(a,b,c,d){z.addMsg(new Error,"DEBUG","Removing triples for formobjectID: "+a+" and inputID: "+b,d),d.forEach(function(d){s(a,b,c,d)})}function u(){function a(){for(var a="",b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",c=0;1>c;c++)a+=b.charAt(Math.floor(Math.random()*b.length));return a}return a()+a()+a()+parseInt(Date.now()/1e3)}function v(a,b){var c="_:bnode";return $.ajax({dataType:"json",url:a.resourceURI,success:function(d){d.some(function(d){if(d["@id"]===a.resourceURI){if("http://bibframe.org/vocab/Work"===d["http://www.w3.org/2000/01/rdf-schema#subClassOf"][0]["@id"]||"http://bibframe.org/vocab/Work"===d["@id"])return c=b+"resources/works/";if("http://bibframe.org/vocab/Instance"===d["http://www.w3.org/2000/01/rdf-schema#subClassOf"][0]["@id"]||"http://bibframe.org/vocab/Instance"===d["@id"])return c=b+"resources/instances/"}})},error:function(a,b,c){z.addMsg(new Error,"ERROR","Request status: "+b+"; Error msg: "+c)}}),c}a("src/lib/jquery-2.1.0.min"),a("src/lib/json"),a("src/lib/lodash.min"),a("src/lib/bootstrap.min"),a("src/lib/typeahead.jquery.min");var w,x={},y=a("src/bfestore"),z=a("src/bfelogging"),A=[],B=[],C=1,D=[],E=0,F=0,G=[],H={"http://id.loc.gov/authorities/names":{name:"LCNAF",load:a("src/lookups/lcnames")},"http://id.loc.gov/authorities/subjects":{name:"LCSH",load:a("src/lookups/lcsubjects")},"http://id.loc.gov/authorities/genreForms":{name:"LCGFT",load:a("src/lookups/lcgenreforms")},"http://id.loc.gov/resources/works":{name:"LC-Works",load:a("src/lookups/lcworks")},"http://id.loc.gov/resources/instances":{name:"LC-Instances",load:a("src/lookups/lcinstances")},"http://id.loc.gov/vocabulary/organizations":{name:"Organizations",load:a("src/lookups/lcorganizations")},"http://id.loc.gov/vocabulary/countries":{name:"Countries",load:a("src/lookups/lccountries")},"http://id.loc.gov/vocabulary/geographicAreas":{name:"GeographicAreas",load:a("src/lookups/lcgacs")},"http://id.loc.gov/vocabulary/languages":{name:"Languages",load:a("src/lookups/lclanguages")},"http://id.loc.gov/vocabulary/identifiers":{name:"Identifiers",load:a("src/lookups/lcidentifiers")},"http://id.loc.gov/vocabulary/targetAudiences":{name:"Audiences",load:a("src/lookups/lctargetaudiences")},"http://id.loc.gov/vocabulary/iso639-1":{name:"ISO639-1",load:a("src/lookups/iso6391")},"http://id.loc.gov/vocabulary/iso639-2":{name:"ISO639-2",load:a("src/lookups/iso6392")},"http://id.loc.gov/vocabulary/iso639-5":{name:"ISO639-5",load:a("src/lookups/iso6395")},"http://id.loc.gov/vocabulary/contentTypes":{name:"RDA-Content-Types",load:a("src/lookups/rdacontenttypes")},"http://id.loc.gov/vocabulary/mediaTypes":{name:"RDA-Media-Types",load:a("src/lookups/rdamediatypes")},"http://id.loc.gov/vocabulary/carriers":{name:"RDA-Carriers",load:a("src/lookups/rdacarriers")},"http://id.loc.gov/ml38281/vocabulary/rda/ModeIssue":{name:"RDA-Mode-of-Issuance",load:a("src/lookups/rdamodeissue")},"http://id.loc.gov/vocabulary/relators":{name:"RDA-Relators",load:a("src/lookups/lcrelators")},"http://id.loc.gov/authorities/performanceMediums":{name:"Performance-Mediums",load:a("src/lookups/lcperformanceMediums")},"http://id.loc.gov/ml38281/vocabulary/rda/MusNotation":{name:"RDA-Form-Musical-Notation",load:a("src/lookups/rdamusnotation")},"http://rdaregistry.info/termList/FormatNoteMus":{name:"RDA-Format-Musical-Notation",load:a("src/lookups/rdaformatnotemus")}};b.aceconfig=a("src/lib/aceconfig"),b.require=a,b.setConfig=function(b){x=b,z.init(x);for(var c=0;c<b.profiles.length;c++)file=b.profiles[c],z.addMsg(new Error,"INFO","Loading profile: "+b.profiles[c]),$.ajax({type:"GET",dataType:"json",async:!1,url:file,success:function(a){$("#bfeditor-loader").width($("#bfeditor-loader").width()+5+"%"),A.push(a);for(var b=0;b<a.Profile.resourceTemplates.length;b++)B.push(a.Profile.resourceTemplates[b])},error:function(a,b,c){z.addMsg(new Error,"ERROR","FAILED to load profile: "+file),z.addMsg(new Error,"ERROR","Request status: "+b+"; Error msg: "+c)}});if(void 0!==b.lookups){E+=Object.keys(b.lookups).length;for(k in b.lookups){var e=b.lookups[k];z.addMsg(new Error,"INFO","Loading lookup: "+e.load),a([e.load],function(a){d(a)})}}void 0===x.baseURI&&(x.baseURI=window.location.protocol+"//"+window.location.host+"/"),z.addMsg(new Error,"INFO","baseURI is "+x.baseURI),void 0!==b.load&&(E+=b.load.length,b.load.forEach(function(a){var b=u(),c={},d=[];c.templateGUID=b,c.resourceTemplateID=a.templateID,c.resourceURI=a.defaulturi,c.embedType="page",c.data=d,D.push(c),void 0!==a.source&&void 0!==a.source.location&&void 0!==a.source.requestType?$.ajax({url:a.source.location,dataType:a.source.requestType,success:function(b){z.addMsg(new Error,"INFO","Fetched external source baseURI"+a.source.location),z.addMsg(new Error,"DEBUG","Source data",b),d=y.jsonld2store(b),d.forEach(function(b){"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"==b.p&&"uri"==b.otype&&b.s==a.defaulturi.replace("ml38281/","")&&(b.rtID=a.templateID)}),c.data=d,f()},error:function(b,c,d){z.addMsg(new Error,"ERROR","FAILED to load external source: "+a.source.location),z.addMsg(new Error,"ERROR","Request status: "+c+"; Error msg: "+d);
}}):f()}))},b.fulleditor=function(a,b){w=document.getElementById(b);var c=$("<div>",{id:"bfeditor-menudiv","class":"col-md-2 sidebar"}),d=$("<div>",{id:"bfeditor-formdiv","class":"col-md-10 main"}),e=$("<div>",{"class":"row"}),f=$('<div><br /><br /><h2>Loading...</h2><div class="progress progress-striped active"> <div class="progress-bar progress-bar-info" id="bfeditor-loader" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 20%"> <span class="sr-only">80% Complete</span> </div> </div>');d.append(f),c.append("<h3>Create Resource</h3"),e.append(c),d.append("<h2>Dashboard</h2>",{"class":"page-header"}),e.append(d),$(w).append(e),this.setConfig(a);for(var h=0;h<a.startingPoints.length;h++){var i=a.startingPoints[h],j=$("<ul>",{"class":"nav nav-sidebar"});void 0!==typeof i.menuGroup&&""!==i.menuGroup&&($menuheading=$('<li><a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">'+i.menuGroup+'<span class="caret"></span></a></li>'),$menuheadingul=$('<ul class="dropdown-menu"></ul>'),$menuheading.append($menuheadingul),j.append($menuheading));for(var k=0;k<i.menuItems.length;k++){var l=$("<li>"),m=$("<a>",{href:"#",id:"sp-"+h+"_"+k});m.html(i.menuItems[k].label),m.click(function(){g(this.id)}),l.append(m),null!==$menuheadingul?$menuheadingul.append(l):j.append(l)}c.append(j)}if(void 0!==x.logging&&void 0!==x.logging.level&&"DEBUG"==x.logging.level){var n=$('<div id="bfeditor-debugdiv" class="col-md-12 main panel-group"> <div class="panel panel-default"><div class="panel-heading"> <h3 class="panel-title"><a role="button" data-toggle="collapse" href="#debuginfo">Debug output</a></h3></div> <div class="panel-collapse collapse in" id="debuginfo"><div class="panel-body"><pre id="bfeditor-debug"></pre></div></div></div> </div>');$(w).append(n);var o=$("#bfeditor-debug");o.html(JSON.stringify(A,void 0," "))}var p=$("<footer>",{"class":"footer"});return $(w).append(p),0===E&&d.html(""),{profiles:A,div:w,bfestore:y,bfelog:z}},b.editor=function(a,b){this.setConfig(a),w=document.getElementById(b);var c=$("<div>",{id:"bfeditor-formdiv","class":"col-md-12"}),d=$("<div>",{"class":"row"});if(d.append(c),$(w).append(d),void 0!==x.logging&&void 0!==x.logging.level&&"DEBUG"==x.logging.level){var e=$("<div>",{"class":"col-md-12"});e.html("Debug output");var f=$("<pre>",{id:"bfeditor-debug"});e.append(f),$(w).append(e),f.html(JSON.stringify(A,void 0," "))}var g=$("<div>",{"class":"col-md-12"});return $(w).append(g),{profiles:A,div:w,bfestore:y,bfelog:z}}}),function(){function a(a,b,c){c=(c||0)-1;for(var d=a?a.length:0;++c<d;)if(a[c]===b)return c;return-1}function b(b,c){var d=typeof c;if(b=b.l,"boolean"==d||null==c)return b[c]?0:-1;"number"!=d&&"string"!=d&&(d="object");var e="number"==d?c:r+c;return b=(b=b[d])&&b[e],"object"==d?b&&-1<a(b,c)?0:-1:b?0:-1}function c(a){var b=this.l,c=typeof a;if("boolean"==c||null==a)b[a]=!0;else{"number"!=c&&"string"!=c&&(c="object");var d="number"==c?a:r+a,b=b[c]||(b[c]={});"object"==c?(b[d]||(b[d]=[])).push(a):b[d]=!0}}function d(a){return a.charCodeAt(0)}function e(a,b){for(var c=a.m,d=b.m,e=-1,f=c.length;++e<f;){var g=c[e],h=d[e];if(g!==h){if(g>h||"undefined"==typeof g)return 1;if(h>g||"undefined"==typeof h)return-1}}return a.n-b.n}function f(a){var b=-1,d=a.length,e=a[0],f=a[d/2|0],g=a[d-1];if(e&&"object"==typeof e&&f&&"object"==typeof f&&g&&"object"==typeof g)return!1;for(e=i(),e["false"]=e["null"]=e["true"]=e.undefined=!1,f=i(),f.k=a,f.l=e,f.push=c;++b<d;)f.push(a[b]);return f}function g(a){return"\\"+U[a]}function h(){return o.pop()||[]}function i(){return p.pop()||{k:null,l:null,m:null,"false":!1,n:0,"null":!1,number:null,object:null,push:null,string:null,"true":!1,undefined:!1,o:null}}function j(a){a.length=0,o.length<t&&o.push(a)}function k(a){var b=a.l;b&&k(b),a.k=a.l=a.m=a.object=a.number=a.string=a.o=null,p.length<t&&p.push(a)}function l(a,b,c){b||(b=0),"undefined"==typeof c&&(c=a?a.length:0);var d=-1;c=c-b||0;for(var e=Array(0>c?0:c);++d<c;)e[d]=a[b+d];return e}function m(c){function o(a,b,c){if(!a||!T[typeof a])return a;b=b&&"undefined"==typeof c?b:ba(b,c,3);for(var d=-1,e=T[typeof a]&&Kb(a),f=e?e.length:0;++d<f&&(c=e[d],!1!==b(a[c],c,a)););return a}function p(a,b,c){var d;if(!a||!T[typeof a])return a;b=b&&"undefined"==typeof c?b:ba(b,c,3);for(d in a)if(!1===b(a[d],d,a))break;return a}function t(a,b,c){var d,e=a,f=e;if(!e)return f;for(var g=arguments,h=0,i="number"==typeof c?2:g.length;++h<i;)if((e=g[h])&&T[typeof e])for(var j=-1,k=T[typeof e]&&Kb(e),l=k?k.length:0;++j<l;)d=k[j],"undefined"==typeof f[d]&&(f[d]=e[d]);return f}function U(a,b,c){var d,e=a,f=e;if(!e)return f;var g=arguments,h=0,i="number"==typeof c?2:g.length;if(i>3&&"function"==typeof g[i-2])var j=ba(g[--i-1],g[i--],2);else i>2&&"function"==typeof g[i-1]&&(j=g[--i]);for(;++h<i;)if((e=g[h])&&T[typeof e])for(var k=-1,l=T[typeof e]&&Kb(e),m=l?l.length:0;++k<m;)d=l[k],f[d]=j?j(f[d],e[d]):e[d];return f}function W(a){var b,c=[];if(!a||!T[typeof a])return c;for(b in a)rb.call(a,b)&&c.push(b);return c}function X(a){return a&&"object"==typeof a&&!Jb(a)&&rb.call(a,"__wrapped__")?a:new Y(a)}function Y(a,b){this.__chain__=!!b,this.__wrapped__=a}function Z(a){function b(){if(d){var a=l(d);sb.apply(a,arguments)}if(this instanceof b){var f=aa(c.prototype),a=c.apply(f,a||arguments);return va(a)?a:f}return c.apply(e,a||arguments)}var c=a[0],d=a[2],e=a[4];return Ib(b,a),b}function _(a,b,c,d,e){if(c){var f=c(a);if("undefined"!=typeof f)return f}if(!va(a))return a;var g=kb.call(a);if(!Q[g])return a;var i=Gb[g];switch(g){case J:case K:return new i(+a);case M:case P:return new i(a);case O:return f=i(a.source,z.exec(a)),f.lastIndex=a.lastIndex,f}if(g=Jb(a),b){var k=!d;d||(d=h()),e||(e=h());for(var m=d.length;m--;)if(d[m]==a)return e[m];f=g?i(a.length):{}}else f=g?l(a):U({},a);return g&&(rb.call(a,"index")&&(f.index=a.index),rb.call(a,"input")&&(f.input=a.input)),b?(d.push(a),e.push(f),(g?Da:o)(a,function(a,g){f[g]=_(a,b,c,d,e)}),k&&(j(d),j(e)),f):f}function aa(a){return va(a)?xb(a):{}}function ba(a,b,c){if("function"!=typeof a)return Ua;if("undefined"==typeof b||!("prototype"in a))return a;var d=a.__bindData__;if("undefined"==typeof d&&(Hb.funcNames&&(d=!a.name),d=d||!Hb.funcDecomp,!d)){var e=pb.call(a);Hb.funcNames||(d=!A.test(e)),d||(d=E.test(e),Ib(a,d))}if(!1===d||!0!==d&&1&d[1])return a;switch(c){case 1:return function(c){return a.call(b,c)};case 2:return function(c,d){return a.call(b,c,d)};case 3:return function(c,d,e){return a.call(b,c,d,e)};case 4:return function(c,d,e,f){return a.call(b,c,d,e,f)}}return Sa(a,b)}function ca(a){function b(){var a=i?g:this;if(e){var o=l(e);sb.apply(o,arguments)}return(f||k)&&(o||(o=l(arguments)),f&&sb.apply(o,f),k&&o.length<h)?(d|=16,ca([c,m?d:-4&d,o,null,g,h])):(o||(o=arguments),j&&(c=a[n]),this instanceof b?(a=aa(c.prototype),o=c.apply(a,o),va(o)?o:a):c.apply(a,o))}var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],i=1&d,j=2&d,k=4&d,m=8&d,n=c;return Ib(b,a),b}function da(c,d){var e=-1,g=ma(),h=c?c.length:0,i=h>=s&&g===a,j=[];if(i){var l=f(d);l?(g=b,d=l):i=!1}for(;++e<h;)l=c[e],0>g(d,l)&&j.push(l);return i&&k(d),j}function ea(a,b,c,d){d=(d||0)-1;for(var e=a?a.length:0,f=[];++d<e;){var g=a[d];if(g&&"object"==typeof g&&"number"==typeof g.length&&(Jb(g)||qa(g))){b||(g=ea(g,b,c));var h=-1,i=g.length,j=f.length;for(f.length+=i;++h<i;)f[j++]=g[h]}else c||f.push(g)}return f}function fa(a,b,c,d,e,f){if(c){var g=c(a,b);if("undefined"!=typeof g)return!!g}if(a===b)return 0!==a||1/a==1/b;if(a===a&&!(a&&T[typeof a]||b&&T[typeof b]))return!1;if(null==a||null==b)return a===b;var i=kb.call(a),k=kb.call(b);if(i==H&&(i=N),k==H&&(k=N),i!=k)return!1;switch(i){case J:case K:return+a==+b;case M:return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case O:case P:return a==fb(b)}if(k=i==I,!k){var l=rb.call(a,"__wrapped__"),m=rb.call(b,"__wrapped__");if(l||m)return fa(l?a.__wrapped__:a,m?b.__wrapped__:b,c,d,e,f);if(i!=N)return!1;if(i=a.constructor,l=b.constructor,i!=l&&!(ua(i)&&i instanceof i&&ua(l)&&l instanceof l)&&"constructor"in a&&"constructor"in b)return!1}for(i=!e,e||(e=h()),f||(f=h()),l=e.length;l--;)if(e[l]==a)return f[l]==b;var n=0,g=!0;if(e.push(a),f.push(b),k){if(l=a.length,n=b.length,(g=n==l)||d)for(;n--;)if(k=l,m=b[n],d)for(;k--&&!(g=fa(a[k],m,c,d,e,f)););else if(!(g=fa(a[n],m,c,d,e,f)))break}else p(b,function(b,h,i){return rb.call(i,h)?(n++,g=rb.call(a,h)&&fa(a[h],b,c,d,e,f)):void 0}),g&&!d&&p(a,function(a,b,c){return rb.call(c,b)?g=-1<--n:void 0});return e.pop(),f.pop(),i&&(j(e),j(f)),g}function ga(a,b,c,d,e){(Jb(b)?Da:o)(b,function(b,f){var g,h,i=b,j=a[f];if(b&&((h=Jb(b))||Pb(b))){for(i=d.length;i--;)if(g=d[i]==b){j=e[i];break}if(!g){var k;c&&(i=c(j,b),k="undefined"!=typeof i)&&(j=i),k||(j=h?Jb(j)?j:[]:Pb(j)?j:{}),d.push(b),e.push(j),k||ga(j,b,c,d,e)}}else c&&(i=c(j,b),"undefined"==typeof i&&(i=b)),"undefined"!=typeof i&&(j=i);a[f]=j})}function ha(a,b){return a+ob(Fb()*(b-a+1))}function ia(c,d,e){var g=-1,i=ma(),l=c?c.length:0,m=[],n=!d&&l>=s&&i===a,o=e||n?h():m;for(n&&(o=f(o),i=b);++g<l;){var p=c[g],q=e?e(p,g,c):p;(d?!g||o[o.length-1]!==q:0>i(o,q))&&((e||n)&&o.push(q),m.push(p))}return n?(j(o.k),k(o)):e&&j(o),m}function ja(a){return function(b,c,d){var e={};c=X.createCallback(c,d,3),d=-1;var f=b?b.length:0;if("number"==typeof f)for(;++d<f;){var g=b[d];a(e,g,c(g,d,b),b)}else o(b,function(b,d,f){a(e,b,c(b,d,f),f)});return e}}function ka(a,b,c,d,e,f){var g=1&b,h=4&b,i=16&b,j=32&b;if(!(2&b||ua(a)))throw new gb;i&&!c.length&&(b&=-17,i=c=!1),j&&!d.length&&(b&=-33,j=d=!1);var k=a&&a.__bindData__;return k&&!0!==k?(k=l(k),k[2]&&(k[2]=l(k[2])),k[3]&&(k[3]=l(k[3])),!g||1&k[1]||(k[4]=e),!g&&1&k[1]&&(b|=8),!h||4&k[1]||(k[5]=f),i&&sb.apply(k[2]||(k[2]=[]),c),j&&vb.apply(k[3]||(k[3]=[]),d),k[1]|=b,ka.apply(null,k)):(1==b||17===b?Z:ca)([a,b,c,d,e,f])}function la(a){return Lb[a]}function ma(){var b=(b=X.indexOf)===Ma?a:b;return b}function na(a){return"function"==typeof a&&lb.test(a)}function oa(a){var b,c;return a&&kb.call(a)==N&&(b=a.constructor,!ua(b)||b instanceof b)?(p(a,function(a,b){c=b}),"undefined"==typeof c||rb.call(a,c)):!1}function pa(a){return Mb[a]}function qa(a){return a&&"object"==typeof a&&"number"==typeof a.length&&kb.call(a)==H||!1}function ra(a,b,c){var d=Kb(a),e=d.length;for(b=ba(b,c,3);e--&&(c=d[e],!1!==b(a[c],c,a)););return a}function sa(a){var b=[];return p(a,function(a,c){ua(a)&&b.push(c)}),b.sort()}function ta(a){for(var b=-1,c=Kb(a),d=c.length,e={};++b<d;){var f=c[b];e[a[f]]=f}return e}function ua(a){return"function"==typeof a}function va(a){return!(!a||!T[typeof a])}function wa(a){return"number"==typeof a||a&&"object"==typeof a&&kb.call(a)==M||!1}function xa(a){return"string"==typeof a||a&&"object"==typeof a&&kb.call(a)==P||!1}function ya(a){for(var b=-1,c=Kb(a),d=c.length,e=Za(d);++b<d;)e[b]=a[c[b]];return e}function za(a,b,c){var d=-1,e=ma(),f=a?a.length:0,g=!1;return c=(0>c?Cb(0,f+c):c)||0,Jb(a)?g=-1<e(a,b,c):"number"==typeof f?g=-1<(xa(a)?a.indexOf(b,c):e(a,b,c)):o(a,function(a){return++d<c?void 0:!(g=a===b)}),g}function Aa(a,b,c){var d=!0;b=X.createCallback(b,c,3),c=-1;var e=a?a.length:0;if("number"==typeof e)for(;++c<e&&(d=!!b(a[c],c,a)););else o(a,function(a,c,e){return d=!!b(a,c,e)});return d}function Ba(a,b,c){var d=[];b=X.createCallback(b,c,3),c=-1;var e=a?a.length:0;if("number"==typeof e)for(;++c<e;){var f=a[c];b(f,c,a)&&d.push(f)}else o(a,function(a,c,e){b(a,c,e)&&d.push(a)});return d}function Ca(a,b,c){b=X.createCallback(b,c,3),c=-1;var d=a?a.length:0;if("number"!=typeof d){var e;return o(a,function(a,c,d){return b(a,c,d)?(e=a,!1):void 0}),e}for(;++c<d;){var f=a[c];if(b(f,c,a))return f}}function Da(a,b,c){var d=-1,e=a?a.length:0;if(b=b&&"undefined"==typeof c?b:ba(b,c,3),"number"==typeof e)for(;++d<e&&!1!==b(a[d],d,a););else o(a,b);return a}function Ea(a,b,c){var d=a?a.length:0;if(b=b&&"undefined"==typeof c?b:ba(b,c,3),"number"==typeof d)for(;d--&&!1!==b(a[d],d,a););else{var e=Kb(a),d=e.length;o(a,function(a,c,f){return c=e?e[--d]:--d,b(f[c],c,f)})}return a}function Fa(a,b,c){var d=-1,e=a?a.length:0;if(b=X.createCallback(b,c,3),"number"==typeof e)for(var f=Za(e);++d<e;)f[d]=b(a[d],d,a);else f=[],o(a,function(a,c,e){f[++d]=b(a,c,e)});return f}function Ga(a,b,c){var e=-1/0,f=e;if("function"!=typeof b&&c&&c[b]===a&&(b=null),null==b&&Jb(a)){c=-1;for(var g=a.length;++c<g;){var h=a[c];h>f&&(f=h)}}else b=null==b&&xa(a)?d:X.createCallback(b,c,3),Da(a,function(a,c,d){c=b(a,c,d),c>e&&(e=c,f=a)});return f}function Ha(a,b,c,d){if(!a)return c;var e=3>arguments.length;b=X.createCallback(b,d,4);var f=-1,g=a.length;if("number"==typeof g)for(e&&(c=a[++f]);++f<g;)c=b(c,a[f],f,a);else o(a,function(a,d,f){c=e?(e=!1,a):b(c,a,d,f)});return c}function Ia(a,b,c,d){var e=3>arguments.length;return b=X.createCallback(b,d,4),Ea(a,function(a,d,f){c=e?(e=!1,a):b(c,a,d,f)}),c}function Ja(a){var b=-1,c=a?a.length:0,d=Za("number"==typeof c?c:0);return Da(a,function(a){var c=ha(0,++b);d[b]=d[c],d[c]=a}),d}function Ka(a,b,c){var d;b=X.createCallback(b,c,3),c=-1;var e=a?a.length:0;if("number"==typeof e)for(;++c<e&&!(d=b(a[c],c,a)););else o(a,function(a,c,e){return!(d=b(a,c,e))});return!!d}function La(a,b,c){var d=0,e=a?a.length:0;if("number"!=typeof b&&null!=b){var f=-1;for(b=X.createCallback(b,c,3);++f<e&&b(a[f],f,a);)d++}else if(d=b,null==d||c)return a?a[0]:n;return l(a,0,Db(Cb(0,d),e))}function Ma(b,c,d){if("number"==typeof d){var e=b?b.length:0;d=0>d?Cb(0,e+d):d||0}else if(d)return d=Oa(b,c),b[d]===c?d:-1;return a(b,c,d)}function Na(a,b,c){if("number"!=typeof b&&null!=b){var d=0,e=-1,f=a?a.length:0;for(b=X.createCallback(b,c,3);++e<f&&b(a[e],e,a);)d++}else d=null==b||c?1:Cb(0,b);return l(a,d)}function Oa(a,b,c,d){var e=0,f=a?a.length:e;for(c=c?X.createCallback(c,d,1):Ua,b=c(b);f>e;)d=e+f>>>1,c(a[d])<b?e=d+1:f=d;return e}function Pa(a,b,c,d){return"boolean"!=typeof b&&null!=b&&(d=c,c="function"!=typeof b&&d&&d[b]===a?null:b,b=!1),null!=c&&(c=X.createCallback(c,d,3)),ia(a,b,c)}function Qa(){for(var a=1<arguments.length?arguments:arguments[0],b=-1,c=a?Ga(Tb(a,"length")):0,d=Za(0>c?0:c);++b<c;)d[b]=Tb(a,b);return d}function Ra(a,b){var c=-1,d=a?a.length:0,e={};for(b||!d||Jb(a[0])||(b=[]);++c<d;){var f=a[c];b?e[f]=b[c]:f&&(e[f[0]]=f[1])}return e}function Sa(a,b){return 2<arguments.length?ka(a,17,l(arguments,2),null,b):ka(a,1,null,null,b)}function Ta(a,b,c){function d(){k&&nb(k),g=k=l=n,(p||o!==b)&&(m=Ub(),h=a.apply(j,f),k||g||(f=j=null))}function e(){var c=b-(Ub()-i);c>0?k=tb(e,c):(g&&nb(g),c=l,g=k=l=n,c&&(m=Ub(),h=a.apply(j,f),k||g||(f=j=null)))}var f,g,h,i,j,k,l,m=0,o=!1,p=!0;if(!ua(a))throw new gb;if(b=Cb(0,b)||0,!0===c)var q=!0,p=!1;else va(c)&&(q=c.leading,o="maxWait"in c&&(Cb(b,c.maxWait)||0),p="trailing"in c?c.trailing:p);return function(){if(f=arguments,i=Ub(),j=this,l=p&&(k||!q),!1===o)var c=q&&!k;else{g||q||(m=i);var n=o-(i-m),r=0>=n;r?(g&&(g=nb(g)),m=i,h=a.apply(j,f)):g||(g=tb(d,n))}return r&&k?k=nb(k):k||b===o||(k=tb(e,b)),c&&(r=!0,h=a.apply(j,f)),!r||k||g||(f=j=null),h}}function Ua(a){return a}function Va(a,b,c){var d=!0,e=b&&sa(b);b&&(c||e.length)||(null==c&&(c=b),f=Y,b=a,a=X,e=sa(b)),!1===c?d=!1:va(c)&&"chain"in c&&(d=c.chain);var f=a,g=ua(f);Da(e,function(c){var e=a[c]=b[c];g&&(f.prototype[c]=function(){var b=this.__chain__,c=this.__wrapped__,g=[c];if(sb.apply(g,arguments),g=e.apply(a,g),d||b){if(c===g&&va(g))return this;g=new f(g),g.__chain__=b}return g})})}function Wa(){}function Xa(a){return function(b){return b[a]}}function Ya(){return this.__wrapped__}c=c?$.defaults(V.Object(),c,$.pick(V,G)):V;var Za=c.Array,$a=c.Boolean,_a=c.Date,ab=c.Function,bb=c.Math,cb=c.Number,db=c.Object,eb=c.RegExp,fb=c.String,gb=c.TypeError,hb=[],ib=db.prototype,jb=c._,kb=ib.toString,lb=eb("^"+fb(kb).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),mb=bb.ceil,nb=c.clearTimeout,ob=bb.floor,pb=ab.prototype.toString,qb=na(qb=db.getPrototypeOf)&&qb,rb=ib.hasOwnProperty,sb=hb.push,tb=c.setTimeout,ub=hb.splice,vb=hb.unshift,wb=function(){try{var a={},b=na(b=db.defineProperty)&&b,c=b(a,a,a)&&b}catch(d){}return c}(),xb=na(xb=db.create)&&xb,yb=na(yb=Za.isArray)&&yb,zb=c.isFinite,Ab=c.isNaN,Bb=na(Bb=db.keys)&&Bb,Cb=bb.max,Db=bb.min,Eb=c.parseInt,Fb=bb.random,Gb={};Gb[I]=Za,Gb[J]=$a,Gb[K]=_a,Gb[L]=ab,Gb[N]=db,Gb[M]=cb,Gb[O]=eb,Gb[P]=fb,Y.prototype=X.prototype;var Hb=X.support={};Hb.funcDecomp=!na(c.a)&&E.test(m),Hb.funcNames="string"==typeof ab.name,X.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:B,variable:"",imports:{_:X}},xb||(aa=function(){function a(){}return function(b){if(va(b)){a.prototype=b;var d=new a;a.prototype=null}return d||c.Object()}}());var Ib=wb?function(a,b){S.value=b,wb(a,"__bindData__",S)}:Wa,Jb=yb||function(a){return a&&"object"==typeof a&&"number"==typeof a.length&&kb.call(a)==I||!1},Kb=Bb?function(a){return va(a)?Bb(a):[]}:W,Lb={"&":"&","<":"<",">":">",'"':""","'":"'"},Mb=ta(Lb),Nb=eb("("+Kb(Mb).join("|")+")","g"),Ob=eb("["+Kb(Lb).join("")+"]","g"),Pb=qb?function(a){if(!a||kb.call(a)!=N)return!1;var b=a.valueOf,c=na(b)&&(c=qb(b))&&qb(c);return c?a==c||qb(a)==c:oa(a)}:oa,Qb=ja(function(a,b,c){rb.call(a,c)?a[c]++:a[c]=1}),Rb=ja(function(a,b,c){(rb.call(a,c)?a[c]:a[c]=[]).push(b)}),Sb=ja(function(a,b,c){a[c]=b}),Tb=Fa,Ub=na(Ub=_a.now)&&Ub||function(){return(new _a).getTime()},Vb=8==Eb(u+"08")?Eb:function(a,b){return Eb(xa(a)?a.replace(C,""):a,b||0)};return X.after=function(a,b){if(!ua(b))throw new gb;return function(){return 1>--a?b.apply(this,arguments):void 0}},X.assign=U,X.at=function(a){for(var b=arguments,c=-1,d=ea(b,!0,!1,1),b=b[2]&&b[2][b[1]]===a?1:d.length,e=Za(b);++c<b;)e[c]=a[d[c]];return e},X.bind=Sa,X.bindAll=function(a){for(var b=1<arguments.length?ea(arguments,!0,!1,1):sa(a),c=-1,d=b.length;++c<d;){var e=b[c];a[e]=ka(a[e],1,null,null,a)}return a},X.bindKey=function(a,b){return 2<arguments.length?ka(b,19,l(arguments,2),null,a):ka(b,3,null,null,a)},X.chain=function(a){return a=new Y(a),a.__chain__=!0,a},X.compact=function(a){for(var b=-1,c=a?a.length:0,d=[];++b<c;){var e=a[b];e&&d.push(e)}return d},X.compose=function(){for(var a=arguments,b=a.length;b--;)if(!ua(a[b]))throw new gb;return function(){for(var b=arguments,c=a.length;c--;)b=[a[c].apply(this,b)];return b[0]}},X.constant=function(a){return function(){return a}},X.countBy=Qb,X.create=function(a,b){var c=aa(a);return b?U(c,b):c},X.createCallback=function(a,b,c){var d=typeof a;if(null==a||"function"==d)return ba(a,b,c);if("object"!=d)return Xa(a);var e=Kb(a),f=e[0],g=a[f];return 1!=e.length||g!==g||va(g)?function(b){for(var c=e.length,d=!1;c--&&(d=fa(b[e[c]],a[e[c]],null,!0)););return d}:function(a){return a=a[f],g===a&&(0!==g||1/g==1/a)}},X.curry=function(a,b){return b="number"==typeof b?b:+b||a.length,ka(a,4,null,null,null,b)},X.debounce=Ta,X.defaults=t,X.defer=function(a){if(!ua(a))throw new gb;var b=l(arguments,1);return tb(function(){a.apply(n,b)},1)},X.delay=function(a,b){if(!ua(a))throw new gb;var c=l(arguments,2);return tb(function(){a.apply(n,c)},b)},X.difference=function(a){return da(a,ea(arguments,!0,!0,1))},X.filter=Ba,X.flatten=function(a,b,c,d){return"boolean"!=typeof b&&null!=b&&(d=c,c="function"!=typeof b&&d&&d[b]===a?null:b,b=!1),null!=c&&(a=Fa(a,c,d)),ea(a,b)},X.forEach=Da,X.forEachRight=Ea,X.forIn=p,X.forInRight=function(a,b,c){var d=[];p(a,function(a,b){d.push(b,a)});var e=d.length;for(b=ba(b,c,3);e--&&!1!==b(d[e--],d[e],a););return a},X.forOwn=o,X.forOwnRight=ra,X.functions=sa,X.groupBy=Rb,X.indexBy=Sb,X.initial=function(a,b,c){var d=0,e=a?a.length:0;if("number"!=typeof b&&null!=b){var f=e;for(b=X.createCallback(b,c,3);f--&&b(a[f],f,a);)d++}else d=null==b||c?1:b||d;return l(a,0,Db(Cb(0,e-d),e))},X.intersection=function(){for(var c=[],d=-1,e=arguments.length,g=h(),i=ma(),l=i===a,m=h();++d<e;){var n=arguments[d];(Jb(n)||qa(n))&&(c.push(n),g.push(l&&n.length>=s&&f(d?c[d]:m)))}var l=c[0],o=-1,p=l?l.length:0,q=[];a:for(;++o<p;){var r=g[0],n=l[o];if(0>(r?b(r,n):i(m,n))){for(d=e,(r||m).push(n);--d;)if(r=g[d],0>(r?b(r,n):i(c[d],n)))continue a;q.push(n)}}for(;e--;)(r=g[e])&&k(r);return j(g),j(m),q},X.invert=ta,X.invoke=function(a,b){var c=l(arguments,2),d=-1,e="function"==typeof b,f=a?a.length:0,g=Za("number"==typeof f?f:0);return Da(a,function(a){g[++d]=(e?b:a[b]).apply(a,c)}),g},X.keys=Kb,X.map=Fa,X.mapValues=function(a,b,c){var d={};return b=X.createCallback(b,c,3),o(a,function(a,c,e){d[c]=b(a,c,e)}),d},X.max=Ga,X.memoize=function(a,b){function c(){var d=c.cache,e=b?b.apply(this,arguments):r+arguments[0];return rb.call(d,e)?d[e]:d[e]=a.apply(this,arguments)}if(!ua(a))throw new gb;return c.cache={},c},X.merge=function(a){var b=arguments,c=2;if(!va(a))return a;if("number"!=typeof b[2]&&(c=b.length),c>3&&"function"==typeof b[c-2])var d=ba(b[--c-1],b[c--],2);else c>2&&"function"==typeof b[c-1]&&(d=b[--c]);for(var b=l(arguments,1,c),e=-1,f=h(),g=h();++e<c;)ga(a,b[e],d,f,g);return j(f),j(g),a},X.min=function(a,b,c){var e=1/0,f=e;if("function"!=typeof b&&c&&c[b]===a&&(b=null),null==b&&Jb(a)){c=-1;for(var g=a.length;++c<g;){var h=a[c];f>h&&(f=h)}}else b=null==b&&xa(a)?d:X.createCallback(b,c,3),Da(a,function(a,c,d){c=b(a,c,d),e>c&&(e=c,f=a)});return f},X.omit=function(a,b,c){var d={};if("function"!=typeof b){var e=[];p(a,function(a,b){e.push(b)});for(var e=da(e,ea(arguments,!0,!1,1)),f=-1,g=e.length;++f<g;){var h=e[f];d[h]=a[h]}}else b=X.createCallback(b,c,3),p(a,function(a,c,e){b(a,c,e)||(d[c]=a)});return d},X.once=function(a){var b,c;if(!ua(a))throw new gb;return function(){return b?c:(b=!0,c=a.apply(this,arguments),a=null,c)}},X.pairs=function(a){for(var b=-1,c=Kb(a),d=c.length,e=Za(d);++b<d;){var f=c[b];e[b]=[f,a[f]]}return e},X.partial=function(a){return ka(a,16,l(arguments,1))},X.partialRight=function(a){return ka(a,32,null,l(arguments,1))},X.pick=function(a,b,c){var d={};if("function"!=typeof b)for(var e=-1,f=ea(arguments,!0,!1,1),g=va(a)?f.length:0;++e<g;){var h=f[e];h in a&&(d[h]=a[h])}else b=X.createCallback(b,c,3),p(a,function(a,c,e){b(a,c,e)&&(d[c]=a)});return d},X.pluck=Tb,X.property=Xa,X.pull=function(a){for(var b=arguments,c=0,d=b.length,e=a?a.length:0;++c<d;)for(var f=-1,g=b[c];++f<e;)a[f]===g&&(ub.call(a,f--,1),e--);return a},X.range=function(a,b,c){a=+a||0,c="number"==typeof c?c:+c||1,null==b&&(b=a,a=0);var d=-1;b=Cb(0,mb((b-a)/(c||1)));for(var e=Za(b);++d<b;)e[d]=a,a+=c;return e},X.reject=function(a,b,c){return b=X.createCallback(b,c,3),Ba(a,function(a,c,d){return!b(a,c,d)})},X.remove=function(a,b,c){var d=-1,e=a?a.length:0,f=[];for(b=X.createCallback(b,c,3);++d<e;)c=a[d],b(c,d,a)&&(f.push(c),ub.call(a,d--,1),e--);return f},X.rest=Na,X.shuffle=Ja,X.sortBy=function(a,b,c){var d=-1,f=Jb(b),g=a?a.length:0,l=Za("number"==typeof g?g:0);for(f||(b=X.createCallback(b,c,3)),Da(a,function(a,c,e){var g=l[++d]=i();f?g.m=Fa(b,function(b){return a[b]}):(g.m=h())[0]=b(a,c,e),g.n=d,g.o=a}),g=l.length,l.sort(e);g--;)a=l[g],l[g]=a.o,f||j(a.m),k(a);return l},X.tap=function(a,b){return b(a),a},X.throttle=function(a,b,c){var d=!0,e=!0;if(!ua(a))throw new gb;return!1===c?d=!1:va(c)&&(d="leading"in c?c.leading:d,e="trailing"in c?c.trailing:e),R.leading=d,R.maxWait=b,R.trailing=e,Ta(a,b,R)},X.times=function(a,b,c){a=-1<(a=+a)?a:0;var d=-1,e=Za(a);for(b=ba(b,c,1);++d<a;)e[d]=b(d);return e},X.toArray=function(a){return a&&"number"==typeof a.length?l(a):ya(a)},X.transform=function(a,b,c,d){var e=Jb(a);if(null==c)if(e)c=[];else{var f=a&&a.constructor;c=aa(f&&f.prototype)}return b&&(b=X.createCallback(b,d,4),(e?Da:o)(a,function(a,d,e){return b(c,a,d,e)})),c},X.union=function(){return ia(ea(arguments,!0,!0))},X.uniq=Pa,X.values=ya,X.where=Ba,X.without=function(a){return da(a,l(arguments,1))},X.wrap=function(a,b){return ka(b,16,[a])},X.xor=function(){for(var a=-1,b=arguments.length;++a<b;){var c=arguments[a];if(Jb(c)||qa(c))var d=d?ia(da(d,c).concat(da(c,d))):c}return d||[]},X.zip=Qa,X.zipObject=Ra,X.collect=Fa,X.drop=Na,X.each=Da,X.eachRight=Ea,X.extend=U,X.methods=sa,X.object=Ra,X.select=Ba,X.tail=Na,X.unique=Pa,X.unzip=Qa,Va(X),X.clone=function(a,b,c,d){return"boolean"!=typeof b&&null!=b&&(d=c,c=b,b=!1),_(a,b,"function"==typeof c&&ba(c,d,1))},X.cloneDeep=function(a,b,c){return _(a,!0,"function"==typeof b&&ba(b,c,1))},X.contains=za,X.escape=function(a){return null==a?"":fb(a).replace(Ob,la)},X.every=Aa,X.find=Ca,X.findIndex=function(a,b,c){var d=-1,e=a?a.length:0;for(b=X.createCallback(b,c,3);++d<e;)if(b(a[d],d,a))return d;return-1},X.findKey=function(a,b,c){var d;return b=X.createCallback(b,c,3),o(a,function(a,c,e){return b(a,c,e)?(d=c,!1):void 0}),d},X.findLast=function(a,b,c){var d;return b=X.createCallback(b,c,3),Ea(a,function(a,c,e){return b(a,c,e)?(d=a,!1):void 0}),d},X.findLastIndex=function(a,b,c){var d=a?a.length:0;for(b=X.createCallback(b,c,3);d--;)if(b(a[d],d,a))return d;return-1},X.findLastKey=function(a,b,c){var d;return b=X.createCallback(b,c,3),ra(a,function(a,c,e){return b(a,c,e)?(d=c,!1):void 0}),d},X.has=function(a,b){return a?rb.call(a,b):!1},X.identity=Ua,X.indexOf=Ma,X.isArguments=qa,X.isArray=Jb,X.isBoolean=function(a){return!0===a||!1===a||a&&"object"==typeof a&&kb.call(a)==J||!1},X.isDate=function(a){return a&&"object"==typeof a&&kb.call(a)==K||!1},X.isElement=function(a){return a&&1===a.nodeType||!1},X.isEmpty=function(a){var b=!0;if(!a)return b;var c=kb.call(a),d=a.length;return c==I||c==P||c==H||c==N&&"number"==typeof d&&ua(a.splice)?!d:(o(a,function(){return b=!1}),b)},X.isEqual=function(a,b,c,d){return fa(a,b,"function"==typeof c&&ba(c,d,2))},X.isFinite=function(a){return zb(a)&&!Ab(parseFloat(a))},X.isFunction=ua,X.isNaN=function(a){return wa(a)&&a!=+a},X.isNull=function(a){return null===a},X.isNumber=wa,X.isObject=va,X.isPlainObject=Pb,X.isRegExp=function(a){return a&&"object"==typeof a&&kb.call(a)==O||!1},X.isString=xa,X.isUndefined=function(a){return"undefined"==typeof a},X.lastIndexOf=function(a,b,c){var d=a?a.length:0;for("number"==typeof c&&(d=(0>c?Cb(0,d+c):Db(c,d-1))+1);d--;)if(a[d]===b)return d;return-1},X.mixin=Va,X.noConflict=function(){return c._=jb,this},X.noop=Wa,X.now=Ub,X.parseInt=Vb,X.random=function(a,b,c){var d=null==a,e=null==b;return null==c&&("boolean"==typeof a&&e?(c=a,a=1):e||"boolean"!=typeof b||(c=b,e=!0)),d&&e&&(b=1),a=+a||0,e?(b=a,a=0):b=+b||0,c||a%1||b%1?(c=Fb(),Db(a+c*(b-a+parseFloat("1e-"+((c+"").length-1))),b)):ha(a,b)},X.reduce=Ha,X.reduceRight=Ia,X.result=function(a,b){if(a){var c=a[b];return ua(c)?a[b]():c}},X.runInContext=m,X.size=function(a){var b=a?a.length:0;return"number"==typeof b?b:Kb(a).length},X.some=Ka,X.sortedIndex=Oa,X.template=function(a,b,c){var d=X.templateSettings;a=fb(a||""),c=t({},c,d);var e,f=t({},c.imports,d.imports),d=Kb(f),f=ya(f),h=0,i=c.interpolate||D,j="__p+='",i=eb((c.escape||D).source+"|"+i.source+"|"+(i===B?y:D).source+"|"+(c.evaluate||D).source+"|$","g");a.replace(i,function(b,c,d,f,i,k){return d||(d=f),j+=a.slice(h,k).replace(F,g),c&&(j+="'+__e("+c+")+'"),i&&(e=!0,j+="';"+i+";\n__p+='"),d&&(j+="'+((__t=("+d+"))==null?'':__t)+'"),h=k+b.length,b}),j+="';",i=c=c.variable,i||(c="obj",j="with("+c+"){"+j+"}"),j=(e?j.replace(v,""):j).replace(w,"$1").replace(x,"$1;"),j="function("+c+"){"+(i?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(e?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+j+"return __p}";try{var k=ab(d,"return "+j).apply(n,f)}catch(l){throw l.source=j,l}return b?k(b):(k.source=j,k)},X.unescape=function(a){return null==a?"":fb(a).replace(Nb,pa)},X.uniqueId=function(a){var b=++q;return fb(null==a?"":a)+b},X.all=Aa,X.any=Ka,X.detect=Ca,X.findWhere=Ca,X.foldl=Ha,X.foldr=Ia,X.include=za,X.inject=Ha,Va(function(){var a={};return o(X,function(b,c){X.prototype[c]||(a[c]=b)}),a}(),!1),X.first=La,X.last=function(a,b,c){var d=0,e=a?a.length:0;if("number"!=typeof b&&null!=b){var f=e;for(b=X.createCallback(b,c,3);f--&&b(a[f],f,a);)d++}else if(d=b,null==d||c)return a?a[e-1]:n;return l(a,Cb(0,e-d))},X.sample=function(a,b,c){return a&&"number"!=typeof a.length&&(a=ya(a)),null==b||c?a?a[ha(0,a.length-1)]:n:(a=Ja(a),a.length=Db(Cb(0,b),a.length),a)},X.take=La,X.head=La,o(X,function(a,b){var c="sample"!==b;X.prototype[b]||(X.prototype[b]=function(b,d){var e=this.__chain__,f=a(this.__wrapped__,b,d);return e||null!=b&&(!d||c&&"function"==typeof b)?new Y(f,e):f})}),X.VERSION="2.4.1",X.prototype.chain=function(){return this.__chain__=!0,this},X.prototype.toString=function(){return fb(this.__wrapped__)},X.prototype.value=Ya,X.prototype.valueOf=Ya,Da(["join","pop","shift"],function(a){var b=hb[a];X.prototype[a]=function(){var a=this.__chain__,c=b.apply(this.__wrapped__,arguments);return a?new Y(c,a):c}}),Da(["push","reverse","sort","unshift"],function(a){var b=hb[a];X.prototype[a]=function(){return b.apply(this.__wrapped__,arguments),this}}),Da(["concat","slice","splice"],function(a){var b=hb[a];X.prototype[a]=function(){return new Y(b.apply(this.__wrapped__,arguments),this.__chain__)}}),X}var n,o=[],p=[],q=0,r=+new Date+"",s=75,t=40,u=" \f \ufeff\n\r\u2028\u2029 ",v=/\b__p\+='';/g,w=/\b(__p\+=)''\+/g,x=/(__e\(.*?\)|\b__t\))\+'';/g,y=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,z=/\w*$/,A=/^\s*function[ \n\r\t]+\w/,B=/<%=([\s\S]+?)%>/g,C=RegExp("^["+u+"]*0+(?=.$)"),D=/($^)/,E=/\bthis\b/,F=/['\n\r\t\u2028\u2029\\]/g,G="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setTimeout".split(" "),H="[object Arguments]",I="[object Array]",J="[object Boolean]",K="[object Date]",L="[object Function]",M="[object Number]",N="[object Object]",O="[object RegExp]",P="[object String]",Q={};Q[L]=!1,Q[H]=Q[I]=Q[J]=Q[K]=Q[M]=Q[N]=Q[O]=Q[P]=!0;var R={leading:!1,maxWait:0,trailing:!1},S={configurable:!1,enumerable:!1,value:null,writable:!1},T={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},U={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},V=T[typeof window]&&window||this,W=T[typeof exports]&&exports&&!exports.nodeType&&exports,X=T[typeof module]&&module&&!module.nodeType&&module,Y=X&&X.exports===W&&W,Z=T[typeof global]&&global;!Z||Z.global!==Z&&Z.window!==Z||(V=Z);var $=m();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(V._=$,define(function(){return $})):W&&X?Y?(X.exports=$)._=$:W._=$:V._=$}.call(this),!function(a){var b={isMsie:function(){return/(msie|trident)/i.test(navigator.userAgent)?navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2]:!1},isBlankString:function(a){return!a||/^\s*$/.test(a)},escapeRegExChars:function(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},isString:function(a){return"string"==typeof a},isNumber:function(a){return"number"==typeof a},isArray:a.isArray,isFunction:a.isFunction,isObject:a.isPlainObject,isUndefined:function(a){return"undefined"==typeof a},bind:a.proxy,each:function(b,c){function d(a,b){return c(b,a)}a.each(b,d)},map:a.map,filter:a.grep,every:function(b,c){var d=!0;return b?(a.each(b,function(a,e){return(d=c.call(null,e,a,b))?void 0:!1}),!!d):d},some:function(b,c){var d=!1;return b?(a.each(b,function(a,e){return(d=c.call(null,e,a,b))?!1:void 0}),!!d):d},mixin:a.extend,getUniqueId:function(){var a=0;return function(){return a++}}(),templatify:function(b){function c(){return String(b)}return a.isFunction(b)?b:c},defer:function(a){setTimeout(a,0)},debounce:function(a,b,c){var d,e;return function(){var f,g,h=this,i=arguments;return f=function(){d=null,c||(e=a.apply(h,i))},g=c&&!d,clearTimeout(d),d=setTimeout(f,b),g&&(e=a.apply(h,i)),e}},throttle:function(a,b){var c,d,e,f,g,h;return g=0,h=function(){g=new Date,e=null,f=a.apply(c,d)},function(){var i=new Date,j=b-(i-g);return c=this,d=arguments,0>=j?(clearTimeout(e),e=null,g=i,f=a.apply(c,d)):e||(e=setTimeout(h,j)),f}},noop:function(){}},c={wrapper:'<span class="twitter-typeahead"></span>',dropdown:'<span class="tt-dropdown-menu"></span>',dataset:'<div class="tt-dataset-%CLASS%"></div>',suggestions:'<span class="tt-suggestions"></span>',
suggestion:'<div class="tt-suggestion"></div>'},d={wrapper:{position:"relative",display:"inline-block"},hint:{position:"absolute",top:"0",left:"0",borderColor:"transparent",boxShadow:"none"},input:{position:"relative",verticalAlign:"top",backgroundColor:"transparent"},inputWithNoHint:{position:"relative",verticalAlign:"top"},dropdown:{position:"absolute",top:"100%",left:"0",zIndex:"100",display:"none"},suggestions:{display:"block"},suggestion:{whiteSpace:"nowrap",cursor:"pointer"},suggestionChild:{whiteSpace:"normal"},ltr:{left:"0",right:"auto"},rtl:{left:"auto",right:" 0"}};b.isMsie()&&b.mixin(d.input,{backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)"}),b.isMsie()&&b.isMsie()<=7&&b.mixin(d.input,{marginTop:"-1px"});var e=function(){function c(b){b&&b.el||a.error("EventBus initialized without el"),this.$el=a(b.el)}var d="typeahead:";return b.mixin(c.prototype,{trigger:function(a){var b=[].slice.call(arguments,1);this.$el.trigger(d+a,b)}}),c}(),f=function(){function a(a,b,c,d){var e;if(!c)return this;for(b=b.split(i),c=d?h(c,d):c,this._callbacks=this._callbacks||{};e=b.shift();)this._callbacks[e]=this._callbacks[e]||{sync:[],async:[]},this._callbacks[e][a].push(c);return this}function b(b,c,d){return a.call(this,"async",b,c,d)}function c(b,c,d){return a.call(this,"sync",b,c,d)}function d(a){var b;if(!this._callbacks)return this;for(a=a.split(i);b=a.shift();)delete this._callbacks[b];return this}function e(a){var b,c,d,e,g;if(!this._callbacks)return this;for(a=a.split(i),d=[].slice.call(arguments,1);(b=a.shift())&&(c=this._callbacks[b]);)e=f(c.sync,this,[b].concat(d)),g=f(c.async,this,[b].concat(d)),e()&&j(g);return this}function f(a,b,c){function d(){for(var d,e=0;!d&&e<a.length;e+=1)d=a[e].apply(b,c)===!1;return!d}return d}function g(){var a;return a=window.setImmediate?function(a){setImmediate(function(){a()})}:function(a){setTimeout(function(){a()},0)}}function h(a,b){return a.bind?a.bind(b):function(){a.apply(b,[].slice.call(arguments,0))}}var i=/\s+/,j=g();return{onSync:c,onAsync:b,off:d,trigger:e}}(),g=function(a){function c(a,c,d){for(var e,f=[],g=0;g<a.length;g++)f.push(b.escapeRegExChars(a[g]));return e=d?"\\b("+f.join("|")+")\\b":"("+f.join("|")+")",c?new RegExp(e):new RegExp(e,"i")}var d={node:null,pattern:null,tagName:"strong",className:null,wordsOnly:!1,caseSensitive:!1};return function(e){function f(b){var c,d;return(c=h.exec(b.data))&&(wrapperNode=a.createElement(e.tagName),e.className&&(wrapperNode.className=e.className),d=b.splitText(c.index),d.splitText(c[0].length),wrapperNode.appendChild(d.cloneNode(!0)),b.parentNode.replaceChild(wrapperNode,d)),!!c}function g(a,b){for(var c,d=3,e=0;e<a.childNodes.length;e++)c=a.childNodes[e],c.nodeType===d?e+=b(c)?1:0:g(c,b)}var h;e=b.mixin({},d,e),e.node&&e.pattern&&(e.pattern=b.isArray(e.pattern)?e.pattern:[e.pattern],h=c(e.pattern,e.caseSensitive,e.wordsOnly),g(e.node,f))}}(window.document),h=function(){function c(c){var e,f,g,i,j=this;c=c||{},c.input||a.error("input is missing"),e=b.bind(this._onBlur,this),f=b.bind(this._onFocus,this),g=b.bind(this._onKeydown,this),i=b.bind(this._onInput,this),this.$hint=a(c.hint),this.$input=a(c.input).on("blur.tt",e).on("focus.tt",f).on("keydown.tt",g),0===this.$hint.length&&(this.setHint=this.getHint=this.clearHint=this.clearHintIfInvalid=b.noop),b.isMsie()?this.$input.on("keydown.tt keypress.tt cut.tt paste.tt",function(a){h[a.which||a.keyCode]||b.defer(b.bind(j._onInput,j,a))}):this.$input.on("input.tt",i),this.query=this.$input.val(),this.$overflowHelper=d(this.$input)}function d(b){return a('<pre aria-hidden="true"></pre>').css({position:"absolute",visibility:"hidden",whiteSpace:"pre",fontFamily:b.css("font-family"),fontSize:b.css("font-size"),fontStyle:b.css("font-style"),fontVariant:b.css("font-variant"),fontWeight:b.css("font-weight"),wordSpacing:b.css("word-spacing"),letterSpacing:b.css("letter-spacing"),textIndent:b.css("text-indent"),textRendering:b.css("text-rendering"),textTransform:b.css("text-transform")}).insertAfter(b)}function e(a,b){return c.normalizeQuery(a)===c.normalizeQuery(b)}function g(a){return a.altKey||a.ctrlKey||a.metaKey||a.shiftKey}var h;return h={9:"tab",27:"esc",37:"left",39:"right",13:"enter",38:"up",40:"down"},c.normalizeQuery=function(a){return(a||"").replace(/^\s*/g,"").replace(/\s{2,}/g," ")},b.mixin(c.prototype,f,{_onBlur:function(){this.resetInputValue(),this.trigger("blurred")},_onFocus:function(){this.trigger("focused")},_onKeydown:function(a){var b=h[a.which||a.keyCode];this._managePreventDefault(b,a),b&&this._shouldTrigger(b,a)&&this.trigger(b+"Keyed",a)},_onInput:function(){this._checkInputValue()},_managePreventDefault:function(a,b){var c,d,e;switch(a){case"tab":d=this.getHint(),e=this.getInputValue(),c=d&&d!==e&&!g(b);break;case"up":case"down":c=!g(b);break;default:c=!1}c&&b.preventDefault()},_shouldTrigger:function(a,b){var c;switch(a){case"tab":c=!g(b);break;default:c=!0}return c},_checkInputValue:function(){var a,b,c;a=this.getInputValue(),b=e(a,this.query),c=b?this.query.length!==a.length:!1,b?c&&this.trigger("whitespaceChanged",this.query):this.trigger("queryChanged",this.query=a)},focus:function(){this.$input.focus()},blur:function(){this.$input.blur()},getQuery:function(){return this.query},setQuery:function(a){this.query=a},getInputValue:function(){return this.$input.val()},setInputValue:function(a,b){this.$input.val(a),b?this.clearHint():this._checkInputValue()},resetInputValue:function(){this.setInputValue(this.query,!0)},getHint:function(){return this.$hint.val()},setHint:function(a){this.$hint.val(a)},clearHint:function(){this.setHint("")},clearHintIfInvalid:function(){var a,b,c,d;a=this.getInputValue(),b=this.getHint(),c=a!==b&&0===b.indexOf(a),d=""!==a&&c&&!this.hasOverflow(),!d&&this.clearHint()},getLanguageDirection:function(){return(this.$input.css("direction")||"ltr").toLowerCase()},hasOverflow:function(){var a=this.$input.width()-2;return this.$overflowHelper.text(this.getInputValue()),this.$overflowHelper.width()>=a},isCursorAtEnd:function(){var a,c,d;return a=this.$input.val().length,c=this.$input[0].selectionStart,b.isNumber(c)?c===a:document.selection?(d=document.selection.createRange(),d.moveStart("character",-a),a===d.text.length):!0},destroy:function(){this.$hint.off(".tt"),this.$input.off(".tt"),this.$hint=this.$input=this.$overflowHelper=null}}),c}(),i=function(){function e(d){d=d||{},d.templates=d.templates||{},d.source||a.error("missing source"),d.name&&!j(d.name)&&a.error("invalid dataset name: "+d.name),this.query=null,this.highlight=!!d.highlight,this.name=d.name||b.getUniqueId(),this.source=d.source,this.displayFn=h(d.display||d.displayKey),this.templates=i(d.templates,this.displayFn),this.$el=a(c.dataset.replace("%CLASS%",this.name))}function h(a){function c(b){return b[a]}return a=a||"value",b.isFunction(a)?a:c}function i(a,c){function d(a){return"<p>"+c(a)+"</p>"}return{empty:a.empty&&b.templatify(a.empty),header:a.header&&b.templatify(a.header),footer:a.footer&&b.templatify(a.footer),suggestion:a.suggestion||d}}function j(a){return/^[_a-zA-Z0-9-]+$/.test(a)}var k="ttDataset",l="ttValue",m="ttDatum";return e.extractDatasetName=function(b){return a(b).data(k)},e.extractValue=function(b){return a(b).data(l)},e.extractDatum=function(b){return a(b).data(m)},b.mixin(e.prototype,f,{_render:function(e,f){function h(){return p.templates.empty({query:e,isEmpty:!0})}function i(){function h(b){var e;return e=a(c.suggestion).append(p.templates.suggestion(b)).data(k,p.name).data(l,p.displayFn(b)).data(m,b),e.children().each(function(){a(this).css(d.suggestionChild)}),e}var i,j;return i=a(c.suggestions).css(d.suggestions),j=b.map(f,h),i.append.apply(i,j),p.highlight&&g({node:i[0],pattern:e}),i}function j(){return p.templates.header({query:e,isEmpty:!o})}function n(){return p.templates.footer({query:e,isEmpty:!o})}if(this.$el){var o,p=this;this.$el.empty(),o=f&&f.length,!o&&this.templates.empty?this.$el.html(h()).prepend(p.templates.header?j():null).append(p.templates.footer?n():null):o&&this.$el.html(i()).prepend(p.templates.header?j():null).append(p.templates.footer?n():null),this.trigger("rendered")}},getRoot:function(){return this.$el},update:function(a){function b(b){c.canceled||a!==c.query||c._render(a,b)}var c=this;this.query=a,this.canceled=!1,this.source(a,b)},cancel:function(){this.canceled=!0},clear:function(){this.cancel(),this.$el.empty(),this.trigger("rendered")},isEmpty:function(){return this.$el.is(":empty")},destroy:function(){this.$el=null}}),e}(),j=function(){function c(c){var d,f,g,h=this;c=c||{},c.menu||a.error("menu is required"),this.isOpen=!1,this.isEmpty=!0,this.datasets=b.map(c.datasets,e),d=b.bind(this._onSuggestionClick,this),f=b.bind(this._onSuggestionMouseEnter,this),g=b.bind(this._onSuggestionMouseLeave,this),this.$menu=a(c.menu).on("click.tt",".tt-suggestion",d).on("mouseenter.tt",".tt-suggestion",f).on("mouseleave.tt",".tt-suggestion",g),b.each(this.datasets,function(a){h.$menu.append(a.getRoot()),a.onSync("rendered",h._onRendered,h)})}function e(a){return new i(a)}return b.mixin(c.prototype,f,{_onSuggestionClick:function(b){this.trigger("suggestionClicked",a(b.currentTarget))},_onSuggestionMouseEnter:function(b){this._removeCursor(),this._setCursor(a(b.currentTarget),!0)},_onSuggestionMouseLeave:function(){this._removeCursor()},_onRendered:function(){function a(a){return a.isEmpty()}this.isEmpty=b.every(this.datasets,a),this.isEmpty?this._hide():this.isOpen&&this._show(),this.trigger("datasetRendered")},_hide:function(){this.$menu.hide()},_show:function(){this.$menu.css("display","block")},_getSuggestions:function(){return this.$menu.find(".tt-suggestion")},_getCursor:function(){return this.$menu.find(".tt-cursor").first()},_setCursor:function(a,b){a.first().addClass("tt-cursor"),!b&&this.trigger("cursorMoved")},_removeCursor:function(){this._getCursor().removeClass("tt-cursor")},_moveCursor:function(a){var b,c,d,e;if(this.isOpen){if(c=this._getCursor(),b=this._getSuggestions(),this._removeCursor(),d=b.index(c)+a,d=(d+1)%(b.length+1)-1,-1===d)return void this.trigger("cursorRemoved");-1>d&&(d=b.length-1),this._setCursor(e=b.eq(d)),this._ensureVisible(e)}},_ensureVisible:function(a){var b,c,d,e;b=a.position().top,c=b+a.outerHeight(!0),d=this.$menu.scrollTop(),e=this.$menu.height()+parseInt(this.$menu.css("paddingTop"),10)+parseInt(this.$menu.css("paddingBottom"),10),0>b?this.$menu.scrollTop(d+b):c>e&&this.$menu.scrollTop(d+(c-e))},close:function(){this.isOpen&&(this.isOpen=!1,this._removeCursor(),this._hide(),this.trigger("closed"))},open:function(){this.isOpen||(this.isOpen=!0,!this.isEmpty&&this._show(),this.trigger("opened"))},setLanguageDirection:function(a){this.$menu.css("ltr"===a?d.ltr:d.rtl)},moveCursorUp:function(){this._moveCursor(-1)},moveCursorDown:function(){this._moveCursor(1)},getDatumForSuggestion:function(a){var b=null;return a.length&&(b={raw:i.extractDatum(a),value:i.extractValue(a),datasetName:i.extractDatasetName(a)}),b},getDatumForCursor:function(){return this.getDatumForSuggestion(this._getCursor().first())},getDatumForTopSuggestion:function(){return this.getDatumForSuggestion(this._getSuggestions().first())},update:function(a){function c(b){b.update(a)}b.each(this.datasets,c)},empty:function(){function a(a){a.clear()}b.each(this.datasets,a),this.isEmpty=!0},isVisible:function(){return this.isOpen&&!this.isEmpty},destroy:function(){function a(a){a.destroy()}this.$menu.off(".tt"),this.$menu=null,b.each(this.datasets,a)}}),c}(),k=function(){function f(c){var d,f,i;c=c||{},c.input||a.error("missing input"),this.isActivated=!1,this.autoselect=!!c.autoselect,this.minLength=b.isNumber(c.minLength)?c.minLength:1,this.$node=g(c.input,c.withHint),d=this.$node.find(".tt-dropdown-menu"),f=this.$node.find(".tt-input"),i=this.$node.find(".tt-hint"),f.on("blur.tt",function(a){var c,e,g;c=document.activeElement,e=d.is(c),g=d.has(c).length>0,b.isMsie()&&(e||g)&&(a.preventDefault(),a.stopImmediatePropagation(),b.defer(function(){f.focus()}))}),d.on("mousedown.tt",function(a){a.preventDefault()}),this.eventBus=c.eventBus||new e({el:f}),this.dropdown=new j({menu:d,datasets:c.datasets}).onSync("suggestionClicked",this._onSuggestionClicked,this).onSync("cursorMoved",this._onCursorMoved,this).onSync("cursorRemoved",this._onCursorRemoved,this).onSync("opened",this._onOpened,this).onSync("closed",this._onClosed,this).onAsync("datasetRendered",this._onDatasetRendered,this),this.input=new h({input:f,hint:i}).onSync("focused",this._onFocused,this).onSync("blurred",this._onBlurred,this).onSync("enterKeyed",this._onEnterKeyed,this).onSync("tabKeyed",this._onTabKeyed,this).onSync("escKeyed",this._onEscKeyed,this).onSync("upKeyed",this._onUpKeyed,this).onSync("downKeyed",this._onDownKeyed,this).onSync("leftKeyed",this._onLeftKeyed,this).onSync("rightKeyed",this._onRightKeyed,this).onSync("queryChanged",this._onQueryChanged,this).onSync("whitespaceChanged",this._onWhitespaceChanged,this),this._setLanguageDirection()}function g(b,e){var f,g,h,j;f=a(b),g=a(c.wrapper).css(d.wrapper),h=a(c.dropdown).css(d.dropdown),j=f.clone().css(d.hint).css(i(f)),j.val("").removeData().addClass("tt-hint").removeAttr("id name placeholder").prop("disabled",!0).attr({autocomplete:"off",spellcheck:"false"}),f.data(l,{dir:f.attr("dir"),autocomplete:f.attr("autocomplete"),spellcheck:f.attr("spellcheck"),style:f.attr("style")}),f.addClass("tt-input").attr({autocomplete:"off",spellcheck:!1}).css(e?d.input:d.inputWithNoHint);try{!f.attr("dir")&&f.attr("dir","auto")}catch(k){}return f.wrap(g).parent().prepend(e?j:null).append(h)}function i(a){return{backgroundAttachment:a.css("background-attachment"),backgroundClip:a.css("background-clip"),backgroundColor:a.css("background-color"),backgroundImage:a.css("background-image"),backgroundOrigin:a.css("background-origin"),backgroundPosition:a.css("background-position"),backgroundRepeat:a.css("background-repeat"),backgroundSize:a.css("background-size")}}function k(a){var c=a.find(".tt-input");b.each(c.data(l),function(a,d){b.isUndefined(a)?c.removeAttr(d):c.attr(d,a)}),c.detach().removeData(l).removeClass("tt-input").insertAfter(a),a.remove()}var l="ttAttrs";return b.mixin(f.prototype,{_onSuggestionClicked:function(a,b){var c;(c=this.dropdown.getDatumForSuggestion(b))&&this._select(c)},_onCursorMoved:function(){var a=this.dropdown.getDatumForCursor();this.input.setInputValue(a.value,!0),this.eventBus.trigger("cursorchanged",a.raw,a.datasetName)},_onCursorRemoved:function(){this.input.resetInputValue(),this._updateHint()},_onDatasetRendered:function(){this._updateHint()},_onOpened:function(){this._updateHint(),this.eventBus.trigger("opened")},_onClosed:function(){this.input.clearHint(),this.eventBus.trigger("closed")},_onFocused:function(){this.isActivated=!0,this.dropdown.open()},_onBlurred:function(){this.isActivated=!1,this.dropdown.empty(),this.dropdown.close()},_onEnterKeyed:function(a,b){var c,d;c=this.dropdown.getDatumForCursor(),d=this.dropdown.getDatumForTopSuggestion(),c?(this._select(c),b.preventDefault()):this.autoselect&&d&&(this._select(d),b.preventDefault())},_onTabKeyed:function(a,b){var c;(c=this.dropdown.getDatumForCursor())?(this._select(c),b.preventDefault()):this._autocomplete(!0)},_onEscKeyed:function(){this.dropdown.close(),this.input.resetInputValue()},_onUpKeyed:function(){var a=this.input.getQuery();this.dropdown.isEmpty&&a.length>=this.minLength?this.dropdown.update(a):this.dropdown.moveCursorUp(),this.dropdown.open()},_onDownKeyed:function(){var a=this.input.getQuery();this.dropdown.isEmpty&&a.length>=this.minLength?this.dropdown.update(a):this.dropdown.moveCursorDown(),this.dropdown.open()},_onLeftKeyed:function(){"rtl"===this.dir&&this._autocomplete()},_onRightKeyed:function(){"ltr"===this.dir&&this._autocomplete()},_onQueryChanged:function(a,b){this.input.clearHintIfInvalid(),b.length>=this.minLength?this.dropdown.update(b):this.dropdown.empty(),this.dropdown.open(),this._setLanguageDirection()},_onWhitespaceChanged:function(){this._updateHint(),this.dropdown.open()},_setLanguageDirection:function(){var a;this.dir!==(a=this.input.getLanguageDirection())&&(this.dir=a,this.$node.css("direction",a),this.dropdown.setLanguageDirection(a))},_updateHint:function(){var a,c,d,e,f,g;a=this.dropdown.getDatumForTopSuggestion(),a&&this.dropdown.isVisible()&&!this.input.hasOverflow()?(c=this.input.getInputValue(),d=h.normalizeQuery(c),e=b.escapeRegExChars(d),f=new RegExp("^(?:"+e+")(.+$)","i"),g=f.exec(a.value),g?this.input.setHint(c+g[1]):this.input.clearHint()):this.input.clearHint()},_autocomplete:function(a){var b,c,d,e;b=this.input.getHint(),c=this.input.getQuery(),d=a||this.input.isCursorAtEnd(),b&&c!==b&&d&&(e=this.dropdown.getDatumForTopSuggestion(),e&&this.input.setInputValue(e.value),this.eventBus.trigger("autocompleted",e.raw,e.datasetName))},_select:function(a){this.input.setQuery(a.value),this.input.setInputValue(a.value,!0),this._setLanguageDirection(),this.eventBus.trigger("selected",a.raw,a.datasetName),this.dropdown.close(),b.defer(b.bind(this.dropdown.empty,this.dropdown))},open:function(){this.dropdown.open()},close:function(){this.dropdown.close()},setVal:function(a){this.isActivated?this.input.setInputValue(a):(this.input.setQuery(a),this.input.setInputValue(a,!0)),this._setLanguageDirection()},getVal:function(){return this.input.getQuery()},destroy:function(){this.input.destroy(),this.dropdown.destroy(),k(this.$node),this.$node=null}}),f}();!function(){var c,d,f;c=a.fn.typeahead,d="ttTypeahead",f={initialize:function(c,f){function g(){var g,h,i=a(this);b.each(f,function(a){a.highlight=!!c.highlight}),h=new k({input:i,eventBus:g=new e({el:i}),withHint:b.isUndefined(c.hint)?!0:!!c.hint,minLength:c.minLength,autoselect:c.autoselect,datasets:f}),i.data(d,h)}return f=b.isArray(f)?f:[].slice.call(arguments,1),c=c||{},this.each(g)},open:function(){function b(){var b,c=a(this);(b=c.data(d))&&b.open()}return this.each(b)},close:function(){function b(){var b,c=a(this);(b=c.data(d))&&b.close()}return this.each(b)},val:function(b){function c(){var c,e=a(this);(c=e.data(d))&&c.setVal(b)}function e(a){var b,c;return(b=a.data(d))&&(c=b.getVal()),c}return arguments.length?this.each(c):e(this.first())},destroy:function(){function b(){var b,c=a(this);(b=c.data(d))&&(b.destroy(),c.removeData(d))}return this.each(b)}},a.fn.typeahead=function(a){return f[a]?f[a].apply(this,[].slice.call(arguments,1)):f.initialize.apply(this,arguments)},a.fn.typeahead.noConflict=function(){return a.fn.typeahead=c,this}}()}(window.jQuery),bfe.define("src/bfestore",["require","exports","module","src/lib/lodash.min"],function(a,b,c){function d(){function a(){for(var a="",b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",c=0;1>c;c++)a+=b.charAt(Math.floor(Math.random()*b.length));return a}return a()+a()+a()+parseInt(Date.now()/1e3)}a("src/lib/lodash.min"),b.store=[],b.storeDedup=function(){return b.store=_.uniq(b.store,function(a){return void 0!==a.olang?a.s+a.p+a.o+a.otype+a.olang:void 0!==a.odatatype?a.s+a.p+a.o+a.otype+a.odatatype:a.s+a.p+a.o+a.otype}),b.store},b.jsonld2store=function(a){return a.forEach(function(a){var c="undefined"!=typeof a["@id"]?a["@id"]:"_:b"+d();for(var e in a)"@id"!==e&&a[e].forEach(function(a){var f=d(),g={};g.guid=f,g.s=c,g.p=e,void 0!==a["@id"]?(g.o=a["@id"],g.otype="uri"):void 0!==a["@value"]&&(g.o=a["@value"],g.otype="literal",void 0!==a["@language"]&&(g.olang=a["@language"])),b.store.push(g)})}),b.store},b.store2jsonldExpanded=function(){var a=[];b.storeDedup(),groupedResources=_.groupBy(b.store,function(a){return a.s});for(var c in groupedResources){var d={};d["@id"]=c,groupedProperties=_.groupBy(groupedResources[c],function(a){return a.p});for(var e in groupedProperties){var f=e;"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"==e&&(f="@type"),d[f]=[],groupedProperties[e].forEach(function(a){if("@type"==f&&"uri"==a.otype)d[f].push(a.o);else if("uri"==a.otype)d[f].push({"@id":a.o});else{var b={};void 0!==a.olang&&""!==a.olang&&(b["@language"]=a.olang),"@type"==a.p?b=a.o:b["@value"]=a.o,d[f].push(b)}})}a.push(d)}return a},b.store2text=function(){var a="\n",c=a+" ",d=a+" ",e="",f=b.store2jsonldExpanded();return f.forEach(function(b){e+=a+"ID: "+b["@id"],void 0!==b["@type"]&&(e+=c+"Type(s)",b["@type"].forEach(function(a){e+=void 0!==a["@value"]?d+a["@value"]:d+a}));for(var f in b)if("@type"!==f&&"@id"!==f){var g=f.replace("http://bibframe.org/vocab/","bf:");g=g.replace("http://id.loc.gov/vocabulary/relators/","relators:"),g=g.replace("http://bibframe.org/vocab2/","bf2:"),g=g.replace("http://rdaregistry.info/termList/","rda"),e+=c+g,b[f].forEach(function(a){e+=void 0!==a["@id"]?d+a["@id"]:d+a["@value"]})}e+=a+a}),e}}),bfe.define("src/bfelogging",["require","exports","module"],function(a,b,c){function d(a,b,c,d){g&&(console.log(c.fileName+":"+c.lineNumber+" -> "+b),("object"==typeof b||b instanceof Array)&&console.log(b),void 0!==d&&("object"==typeof d||d instanceof Array)&&console.log(d))}function e(a,c,d,e){var f=new Date,g=f.toJSON(),h=f.toLocaleString(),i={};i.dt=f,i.dtLocaleSort=g,i.dtLocaleReadable=h,i.type=a,i.fileName=d.fileName,i.lineNumber=d.lineNumber,"object"==typeof c||c instanceof Array?i.msg=JSON.stringify(c):i.msg=c,void 0!==e&&("object"==typeof e||e instanceof Array)&&(i.obj=JSON.stringify(e)),b.log.push(i)}var f="INFO",g=!0,h=window.location.protocol+"//"+window.location.host+"/";b.log=[],b.getLog=function(){return b.log},b.init=function(a){void 0!==a.logging&&(void 0!==a.logging.level&&"DEBUG"==a.logging.level&&(f=a.logging.level),void 0===a.logging.toConsole||a.logging.toConsole||(g=a.logging.toConsole));var c="Logging instantiated: level is "+f+"; log to console is set to "+g;b.addMsg(new Error,"INFO",c),b.addMsg(new Error,"INFO",h)},b.addMsg=function(a,b,c,g){if(void 0===a.lineNumber&&void 0===a.fileName)try{var i=a.stack.split("\n"),j=i[1].substring(i[1].indexOf("(")+1);j=j.replace(h,"");var k=j.split(":");a.fileName=k[0],a.lineNumber=k[1]}catch(l){a.fileName="unknown",a.lineNumber="?"}a.fileName=a.fileName.replace(h,""),"INFO"==f&&b.match(/INFO|WARN|ERROR/)?(e(b,c,a,g),d(b,c,a,g)):"DEBUG"==f&&(e(b,c,a,g),d(b,c,a,g))}}),bfe.define("src/lookups/lcnames",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/authorities/names",b.source=function(a,c,f){var g=f.store,h="",i=_.where(g,{p:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"});void 0!==i[0]&&(h=i[0].o);var j="http://id.loc.gov/authorities/names";i=_.where(g,{p:"http://bibframe.org/vocab/authoritySource"}),void 0!==i[0]&&(console.log(i[0]),j=i[0].o);var k="";"http://bibframe.org/vocab/Person"==h?k="rdftype:PersonalName":"http://bibframe.org/vocab/Topic"==h?k="(rdftype:Topic OR rdftype:ComplexSubject)":"http://bibframe.org/vocab/Place"==h?k="rdftype:Geographic":"http://bibframe.org/vocab/Organization"==h?k="rdftype:CorporateName":"http://bibframe.org/vocab/Family"==h?k="rdftype:PersonalName":"http://bibframe.org/vocab/Meeting"==h?k="rdftype:ConferenceName":"http://bibframe.org/vocab/Jurisdiction"==h?k="rdftype:CorporateName":"http://bibframe.org/vocab/GenreForm"==h&&(k="rdftype:GenreForm");var l="";return""!==j&&""!==k?l="cs:"+j+" AND "+k:""!==k?l=k:""!==j&&(l="cs:"+j),l=""!==l?l+" AND ("+a+" OR "+a+"* OR *"+a+"*)":"("+a+" OR "+a+"* OR *"+a+"*)",l=encodeURI(l),e[l]?void c(e[l]):("undefined"!=typeof this.searching&&(clearTimeout(this.searching),c([])),void(this.searching=setTimeout(function(){if(a.length>2&&"?"!=a.substr(0,1))suggestquery=a,""!==k&&(suggestquery+="&rdftype="+k.replace("rdftype:","")),u=b.scheme+"/suggest/?q="+suggestquery+"&count=50",$.ajax({url:u,dataType:"jsonp",success:function(b){return parsedlist=d.processSuggestions(b,a),e[l]=parsedlist,c(parsedlist)}});else{if(!(a.length>2))return[];u="http://id.loc.gov/search/?format=jsonp&start=1&count=50&q="+l.replace("?",""),$.ajax({url:u,dataType:"jsonp",success:function(b){return parsedlist=d.processATOM(b,a),e[l]=parsedlist,c(parsedlist)}})}},300)))},b.getResource=d.getResourceWithAAP}),bfe.define("src/lookups/lcshared",["require","exports","module"],function(a,b,c){a("https://twitter.github.io/typeahead.js/releases/latest/typeahead.bundle.js"),b.getResource=function(a,b,c,d){var e=[],f={};return f.s=a,f.p=b,c.uri=c.uri,f.o=c.uri,f.otype="uri",e.push(f),f={},f.s=c.uri,f.p="http://bibframe.org/vocab/label",f.o=c.value,f.otype="literal",f.olang="en",e.push(f),d(e)},b.getResourceWithAAP=function(a,b,c,d){var e=[],f={};f.s=a,f.p=b,f.o=c.uri,f.otype="uri",e.push(f),f={},f.s=a,f.p="http://bibframe.org/vocab/authorizedAccessPoint",f.o=c.value,f.otype="literal",f.olang="en",e.push(f),f={},f.s=a,f.p="http://bibframe.org/vocab/label",f.o=c.value,f.otype="literal",f.olang="en",e.push(f),d(e)},b.getResourceLabelLookup=function(a,b,c,d){var e=[],f={};f.s=a,f.p=b,f.o=c.uri,f.otype="uri",e.push(f),$.ajax({url:c.uri+".jsonp",dataType:"jsonp",success:function(a){a.forEach(function(a){if(a["@id"]===c.uri){var b={};return b.s=c.uri,b.otype="literal",b.p="http://bibframe.org/vocab/label",b.o=a["http://www.loc.gov/mads/rdf/v1#authoritativeLabel"][0]["@value"],e.push(b),d(e)}})}})},b.processJSONLDSuggestions=function(a,b,c){var d=[];if(void 0!==a["@graph"])for(var e=0;e<a["@graph"].length;e++)if(void 0!==a["@graph"][e]["skos:inScheme"]&&"skos:Concept"===a["@graph"][e]["@type"]&&a["@graph"][e]["skos:inScheme"]["@id"]===c){if(void 0!==a["@graph"][e]["skos:prefLabel"].length){for(var f=0;f<a["@graph"][e]["skos:prefLabel"].length;f++)if("en"===a["@graph"][e]["skos:prefLabel"][f]["@language"]){var g=a["@graph"][e]["skos:prefLabel"][f]["@value"];break}}else var g=a["@graph"][e]["skos:prefLabel"]["@value"];var h=a["@graph"][e]["@id"];d.push({uri:h,value:g})}return 0===d.length&&(d[0]={uri:"",value:"[No suggestions found for "+b+".]"}),d},b.processSuggestions=function(a,b){var c=[];if(void 0!==a[1])for(var d=0;d<a[1].length;d++){var e=a[1][d],f=a[3][d];c.push({uri:f,value:e})}return 0===c.length&&(c[0]={uri:"",value:"[No suggestions found for "+b+".]"}),c},b.processATOM=function(a,b){var c=[];for(var d in a)if("atom:entry"==a[d][0]){var e="",f="",g="";for(var h in a[d])if("atom:title"==a[d][h][0]&&(e=a[d][h][2]),"atom:link"==a[d][h][0]&&(f=a[d][h][1].href,g=f.substr(0,f.lastIndexOf("/"))),""!==e&&""!==f){c.push({uri:f,source:g,value:e});break}}return 0===c.length&&(c[0]={uri:"",value:"[No suggestions found for "+b+".]"}),c},b.simpleQuery=function(a,c,d,e){return console.log("q is "+a),q=encodeURI(a),c[q]?void e(c[q]):("undefined"!=typeof this.searching&&(clearTimeout(this.searching),e([])),void(this.searching=setTimeout(function(){if(""===a||" "===a)u=d+"/suggest/?count=100&q=",$.ajax({url:u,dataType:"jsonp",success:function(a){return parsedlist=b.processSuggestions(a,""),e(parsedlist)}});else{if(!(a.length>=1))return[];u=d+"/suggest/?q="+q,$.ajax({url:u,dataType:"jsonp",success:function(d){return parsedlist=b.processSuggestions(d,a),c[q]=parsedlist,e(parsedlist)}})}},300)))}}),bfe.define("src/lookups/lcsubjects",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/authorities/subjects",b.source=function(a,c,f){var g=f.store,h="",i=_.where(g,{p:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"});void 0!==i[0]&&(h=i[0].o);var j="http://id.loc.gov/authorities/subjects";i=_.where(g,{p:"http://bibframe.org/vocab/authoritySource"}),void 0!==i[0]&&(j=i[0].o);var k="";"http://bibframe.org/vocab/Person"==h?k="rdftype:PersonalName":"http://bibframe.org/vocab/Topic"==h?k="(rdftype:Topic OR rdftype:ComplexSubject)":"http://bibframe.org/vocab/Place"==h?k="rdftype:Geographic":"http://bibframe.org/vocab/Organization"==h?k="rdftype:CorporateName":"http://bibframe.org/vocab/Family"==h?k="rdftype:PersonalName":"http://bibframe.org/vocab/Meeting"==h?k="rdftype:ConferenceName":"http://bibframe.org/vocab/Jurisdiction"==h?k="rdftype:CorporateName":"http://bibframe.org/vocab/GenreForm"==h&&(k="rdftype:GenreForm");var l="";return""!==j&&""!==k?l="cs:"+j+" AND "+k:""!==k?l=k:""!==j&&(l="cs:"+j),l=""!==l?l+" AND ("+a+" OR "+a+"* OR *"+a+"*)":"("+a+" OR "+a+"* OR *"+a+"*)",l=encodeURI(l),e[l]?void c(e[l]):("undefined"!=typeof this.searching&&(clearTimeout(this.searching),c([])),void(this.searching=setTimeout(function(){if(a.length>2&&"?"!=a.substr(0,1))suggestquery=a,""!==k&&(suggestquery+="&rdftype="+k.replace("rdftype:","")),u=b.scheme+"/suggest/?q="+suggestquery,$.ajax({url:u,dataType:"jsonp",success:function(b){return parsedlist=d.processSuggestions(b,a),e[l]=parsedlist,c(parsedlist)}});else{if(!(a.length>2))return[];u="http://id.loc.gov/search/?format=jsonp&start=1&count=10&q="+l.replace("?",""),$.ajax({url:u,dataType:"jsonp",success:function(b){return parsedlist=d.processATOM(b,a),e[l]=parsedlist,c(parsedlist)}})}},300)))},b.getResource=d.getResourceWithAAP}),bfe.define("src/lookups/lcgenreforms",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/authorities/genreForms",b.source=function(a,b){var c="http://id.loc.gov/authorities/genreForms",f="rdftype:GenreForm",g="";return""!==c&&""!==f?g="cs:"+c+" AND "+f:""!==f?g=f:""!==c&&(g="cs:"+c),g=""!==g?g+" AND ("+a+" OR "+a+"* OR *"+a+"*)":"("+a+" OR "+a+"* OR *"+a+"*)",console.log("q is "+g),g=encodeURI(g),e[g]?void b(e[g]):("undefined"!=typeof this.searching&&(console.log("searching defined"),clearTimeout(this.searching),b([])),void(this.searching=setTimeout(function(){return a.length>2?(suggestquery=a,""!==f&&(suggestquery+="&rdftype="+f.replace("rdftype:","")),u=c+"/suggest/?q="+suggestquery,$.ajax({url:u,dataType:"jsonp",success:function(c){return parsedlist=d.processSuggestions(c,a),e[g]=parsedlist,b(parsedlist)}}),void 0):[]},300)))},b.getResource=d.getResourceWithAAP}),bfe.define("src/lookups/lcworks",["require","exports","module"],function(a,b,c){function d(a,b){var c=[];for(var d in a)if("atom:entry"==a[d][0]){var e="",f="",g="";for(var h in a[d])if("atom:title"==a[d][h][0]&&(e=a[d][h][2]),"atom:link"==a[d][h][0]&&(f=a[d][h][1].href,g=f.substr(0,f.lastIndexOf("/"))),""!==e&&""!==f){c.push({uri:f,source:g,value:e});break}}return 0===c.length&&(c[0]={uri:"",value:"[No suggestions found for "+b+".]"}),c}var e=[];b.scheme="http://id.loc.gov/resources/works",b.source=function(a,b,c){var f=$("#"+c.pageid),g=void 0!=f.val()?parseInt(f.val()):1,h=c.store,i="",j=_.where(h,{p:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"});void 0!==j[0]&&(i=j[0].o);var k="http://id.loc.gov/resources/works";j=_.where(h,{p:"http://bibframe.org/vocab/authoritySource"}),void 0!==j[0]&&(console.log(j[0]),k=j[0].o);var l="",m="";return""!==k&&""!==l?m="cs:"+k+"&q="+l:""!==l?m=l:""!==k&&(m="cs:"+k),m=m+"&q=scheme:/bibframe&q="+a,m=encodeURI(m),e[m]?void b(e[m]):("undefined"!=typeof this.searching&&(clearTimeout(this.searching),b([])),void(this.searching=setTimeout(function(c){return a.length>2?(u="http://id.loc.gov/ml38281/search/?format=jsonp&start=1&count=50&q="+m,void $.ajax({url:u,dataType:"jsonp",success:function(c){return f.val(g+10),parsedlist=d(c,a),e[m]=parsedlist,b(parsedlist)}})):[]},300)))},b.getResource=function(a,b,c,d){var e=[],f={};f.s=a,f.p=b,f.o=c.uri,f.otype="uri",e.push(f),f={},f.s=a,f.p="http://bibframe.org/vocab/authorizedAccessPoint",f.o=c.value,f.otype="literal",f.olang="en",e.push(f),f={},f.s=c.uri,f.p="http://bibframe.org/vocab/label",f.o=c.value,f.otype="literal",f.olang="en",e.push(f);var g=c.uri.replace(/gov\/resources/,"gov/ml38281/resources")+".bibframe_raw.jsonp";"<"+c.uri+">";$.ajax({url:g,dataType:"jsonp",success:function(a){a.forEach(function(a){var b=a["@id"];for(var c in a)"@id"!==c&&a[c].forEach(function(a){var d={};d.s=b,d.p=c,void 0!==a["@id"]?(d.o=a["@id"],d.otype="uri"):void 0!==a["@value"]?(d.o=a["@value"],d.otype="literal",void 0!==a["@language"]&&(d.olang=a["@language"])):d.o=a,e.push(d)})}),d(e)}})}}),bfe.define("src/lookups/lcinstances",["require","exports","module"],function(a,b,c){function d(a,b){
var c=[];for(var d in a)if("atom:entry"==a[d][0]){var e="",f="",g="";for(var h in a[d])if("atom:title"==a[d][h][0]&&(e=a[d][h][2]),"atom:link"==a[d][h][0]&&(f=a[d][h][1].href,g=f.substr(0,f.lastIndexOf("/"))),""!==e&&""!==f){c.push({uri:f,source:g,value:e});break}}return 0===c.length&&(c[0]={uri:"",value:"[No suggestions found for "+b+".]"}),c}var e=[];b.scheme="http://id.loc.gov/resources/instances",b.source=function(a,b,c){var f=c.store,g="",h=_.where(f,{p:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"});void 0!==h[0]&&(console.log(h[0]),g=h[0].o);var i="http://id.loc.gov/ml38281/resources/instances";h=_.where(f,{p:"http://bibframe.org/vocab/authoritySource"}),void 0!==h[0]&&(console.log(h[0]),i=h[0].o);var j="",k="";return""!==i&&""!==j?k="cs:"+i+"&q="+j:""!==j?k=j:""!==i&&(k="cs:"+i),k=k+"&q=scheme:/bibframe&q="+a,k=encodeURI(k),e[k]?void b(e[k]):("undefined"!=typeof this.searching&&(clearTimeout(this.searching),b([])),void(this.searching=setTimeout(function(){return a.length>2?(u="http://id.loc.gov/ml38281/search/?format=jsonp&start=1&count=10&q="+k,void $.ajax({url:u,dataType:"jsonp",success:function(c){return parsedlist=d(c,a),e[k]=parsedlist,b(parsedlist)}})):[]},300)))},b.getResource=function(a,b,c,d){var e=[],f={};f.s=a,f.p=b,f.o=c.uri,f.otype="uri",e.push(f),f={},f.s=a,f.p="http://bibframe.org/vocab/authorizedAccessPoint",f.o=c.value,f.otype="literal",f.olang="en",e.push(f);var g=c.uri.replace(/gov\/resources/,"gov/ml38281/resources")+".bibframe_raw.jsonp";"<"+c.uri+">";$.ajax({url:g,dataType:"jsonp",success:function(a){a.forEach(function(a){var b=a["@id"];for(var c in a)"@id"!==c&&a[c].forEach(function(a){var d={};d.s=b,d.p=c,void 0!==a["@id"]?(d.o=a["@id"],d.otype="uri"):void 0!==a["@value"]&&(d.o=a["@value"],d.otype="literal",void 0!==a["@language"]&&(d.olang=a["@language"])),e.push(d)})}),console.log(e),d(e)}})}}),bfe.define("src/lookups/lcorganizations",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/vocabulary/organizations",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=d.getResourceWithAAP}),bfe.define("src/lookups/lccountries",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/vocabulary/countries",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=d.getResource}),bfe.define("src/lookups/lcgacs",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/vocabulary/geographicAreas",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=d.getResource}),bfe.define("src/lookups/lclanguages",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/vocabulary/languages",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=d.getResource}),bfe.define("src/lookups/lcidentifiers",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/vocabulary/identifiers",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=d.getResource}),bfe.define("src/lookups/lctargetaudiences",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/vocabulary/targetAudiences",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=d.getResource}),bfe.define("src/lookups/iso6391",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/vocabulary/iso639-1",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=d.getResource}),bfe.define("src/lookups/iso6392",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/vocabulary/iso639-2",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=d.getResource}),bfe.define("src/lookups/iso6395",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/vocabulary/iso639-5",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=d.getResource}),bfe.define("src/lookups/rdacontenttypes",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/vocabulary/contentTypes",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=d.getResource}),bfe.define("src/lookups/rdamediatypes",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/vocabulary/mediaTypes",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=d.getResource}),bfe.define("src/lookups/rdacarriers",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/vocabulary/carriers",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=d.getResource}),bfe.define("src/lookups/rdamodeissue",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/ml38281/vocabulary/rda/ModeIssue",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=function(a,b,c,e){return c.uri=c.uri.replace("gov/","gov/ml38281/"),d.getResource(a,b,c,e)}}),bfe.define("src/lookups/rdamusnotation",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/ml38281/vocabulary/rda/MusNotation",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=function(a,b,c,e){return c.uri=c.uri.replace("gov/","gov/ml38281/"),d.getResource(a,b,c,e)}}),bfe.define("src/lookups/rdaformatnotemus",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://rdaregistry.info/termList/FormatNoteMus",b.source=function(a,c){return console.log("q is "+a),q=encodeURI(a),e[q]?void c(e[q]):("undefined"!=typeof this.searching&&(clearTimeout(this.searching),c([])),void(this.searching=setTimeout(function(){if(""===a||" "===a)u=b.scheme+".json-ld",$.ajax({url:u,dataType:"json",success:function(e){return parsedlist=d.processJSONLDSuggestions(e,a,b.scheme),c(parsedlist)}});else{if(!(a.length>1))return[];u=b.scheme+".json-ld",console.log(u),$.ajax({url:u,dataType:"json",success:function(f){return parsedlist=d.processJSONLDSuggestions(f,a,b.scheme),e[q]=parsedlist,c(parsedlist)}})}},300)))},b.getResource=d.getResource}),bfe.define("src/lookups/lcrelators",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/vocabulary/relators",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=d.getResource}),bfe.define("src/lookups/lcperformanceMediums",["require","exports","module","src/lookups/lcshared"],function(a,b,c){var d=a("src/lookups/lcshared"),e=[];b.scheme="http://id.loc.gov/authorities/performanceMediums",b.source=function(a,c){return d.simpleQuery(a,e,b.scheme,c)},b.getResource=d.getResource}),bfe.define("src/lib/aceconfig",["require","exports","module"],function(a,b,c){function d(d){if(g.packaged=d||a.packaged||c.packaged||f.define&&define.packaged,!f.document)return"";for(var h={},i="",j=document.getElementsByTagName("script"),k=0;k<j.length;k++){var l=j[k],m=l.src||l.getAttribute("src");if(m){for(var n=l.attributes,o=0,p=n.length;p>o;o++){var q=n[o];0===q.name.indexOf("data-ace-")&&(h[e(q.name.replace(/^data-ace-/,""))]=q.value)}var r=m.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);r&&(i=r[1])}}i&&(h.base=h.base||i,h.packaged=!0),h.basePath=h.base,h.workerPath=h.workerPath||h.base,h.modePath=h.modePath||h.base,h.themePath=h.themePath||h.base,delete h.base;for(var s in h)"undefined"!=typeof h[s]&&b.set(s,h[s])}function e(a){return a.replace(/-(.)/g,function(a,b){return b.toUpperCase()})}var f=function(){return this}(),g={packaged:!1,workerPath:null,modePath:null,themePath:null,basePath:"",suffix:".js",$moduleUrls:{}};b.set=function(a,b){if(!g.hasOwnProperty(a))throw new Error("Unknown config key: "+a);g[a]=b},b.init=d}),function(){bfe.require(["src/bfe"],function(a){console.log(a),a&&a.aceconfig.init(),window.bfe||(window.bfe={});for(var b in a)a.hasOwnProperty(b)&&(bfe[b]=a[b])})}();