From 4ce83ee9d27816aed605cbb2c744937030b3cf73 Mon Sep 17 00:00:00 2001 From: "A. Tapekhin" Date: Fri, 30 Oct 2015 15:37:36 +0300 Subject: [PATCH 01/73] new converter --- lingvodoc/__init__.py | 2 + lingvodoc/scripts/lingvodoc_converter_new.py | 452 +++++++++++++++++++ lingvodoc/views.py | 110 ++++- 3 files changed, 563 insertions(+), 1 deletion(-) create mode 100644 lingvodoc/scripts/lingvodoc_converter_new.py diff --git a/lingvodoc/__init__.py b/lingvodoc/__init__.py index 2fe62a031..c3776f70d 100755 --- a/lingvodoc/__init__.py +++ b/lingvodoc/__init__.py @@ -514,6 +514,8 @@ def configure_routes(config): # params: # {"blob_client_id": , "blob_object_id": , "parent_client_id": , "parent_object_id": } config.add_route(name='convert_dictionary', pattern='/convert') + config.add_route(name='convert_dictionary_check', pattern='/convert_check') + config.add_route(name='convert_dictionary_new', pattern='/convert_new') def main(global_config, **settings): diff --git a/lingvodoc/scripts/lingvodoc_converter_new.py b/lingvodoc/scripts/lingvodoc_converter_new.py new file mode 100644 index 000000000..8bd945d6a --- /dev/null +++ b/lingvodoc/scripts/lingvodoc_converter_new.py @@ -0,0 +1,452 @@ +import sqlite3 +import base64 +import requests +import json +import hashlib +import logging + + +def get_dict_attributes(sqconn): + dict_trav = sqconn.cursor() + dict_trav.execute("""SELECT + dict_name, + dict_identificator, + dict_description + FROM + dict_attributes + WHERE + id = 1;""") + req = dict() + for dictionary in dict_trav: + req['dictionary_name'] = dictionary[0] + req['dialeqt_id'] = dictionary[1] + return req + + +def upload_audio(upload_url, audio_sequence, markup_sequence, session): + log = logging.getLogger(__name__) + status = session.post(upload_url, json=audio_sequence) + log.debug(status.text) + audio_ids_list = json.loads(status.text) + if markup_sequence: + for k in range(0, len(audio_ids_list)): + parent_client_id = audio_ids_list[k]['client_id'] + parent_object_id = audio_ids_list[k]['object_id'] + markup_sequence[k]["parent_client_id"] = parent_client_id + markup_sequence[k]["parent_object_id"] = parent_object_id + status = session.post(upload_url, json=markup_sequence) + log.debug(status.text) + + +def upload_markup(upload_url, search_url, markup_sequence, session): + print('I was here. True story') + log = logging.getLogger(__name__) + for entry in markup_sequence: + audio_hash = entry[0] + markup_element = entry[1] + entity_metadata_search = search_url + '?hash=%s' % audio_hash # add filters by perspective. Maybe where search_url is created + status = session.get(entity_metadata_search) + ents = json.loads(status.text) + if 'error' not in ents: + if type(ents) == list and len(ents) >= 1: + existing_entity = ents[0] + parent_client_id = existing_entity['client_id'] + parent_object_id = existing_entity['object_id'] + markup_element["parent_client_id"] = parent_client_id + markup_element["parent_object_id"] = parent_object_id + new_markup_sequence = [o[1] for o in markup_sequence if o[1].get["parent_client_id"]] + result = [o for o in markup_sequence if o[1].get["parent_client_id"] is None] + status = session.post(upload_url, json=new_markup_sequence) + log.debug(status.text) + return result + + +def upload_audio_simple(session, ids_mapping, sound_and_markup_cursor, upload_url, audio_hashes, entity_types, + client_id, is_a_regular_form, locale_id=1): + audio_sequence = [] + for cursor in sound_and_markup_cursor: + blob_id = cursor[0] + audio = cursor[1] + filename = cursor[2] + word_id = cursor[3] + audio_hash = hashlib.sha224(audio).hexdigest() + if audio_hash not in audio_hashes: + audio_hashes.add(audio_hash) + + audio_element = {"locale_id": locale_id, + "level": "leveloneentity", + "data_type": "sound", + "filename": filename, + "entity_type": entity_types[0], + "parent_client_id": ids_mapping[int(word_id)][0], + "parent_object_id": ids_mapping[int(word_id)][1], + "content": base64.urlsafe_b64encode(audio).decode()} + if not is_a_regular_form: + audio_element['additional_metadata'] = '{"hash": %s, "client_id": %s, "row_id": %s}' % \ + (audio_hash, client_id, cursor[4]) + audio_sequence.append(audio_element) + if len(audio_sequence) > 50: + upload_audio(upload_url, audio_sequence, None, session) + audio_sequence = [] + if len(audio_sequence) != 0: + upload_audio(upload_url, audio_sequence, None, session) + audio_sequence = [] + + +def upload_audio_with_markup(session, ids_mapping, sound_and_markup_cursor, upload_url, search_url, audio_hashes, markup_hashes, + entity_types, client_id, is_a_regular_form, locale_id=1): + audio_sequence = [] + markup_sequence = [] + markup__without_audio_sequence = [] + for cursor in sound_and_markup_cursor: + blob_id = cursor[0] + audio = cursor[1] + markup = cursor[2] + common_name = cursor[3] + word_id = cursor[4] + if not audio or not markup: + continue + audio_hash = hashlib.sha224(audio).hexdigest() + markup_hash = hashlib.sha224(markup).hexdigest() + if audio_hash not in audio_hashes: + audio_hashes.add(audio_hash) + audio_element = {"locale_id": locale_id, + "level": "leveloneentity", + "data_type": "sound", + "filename": common_name + ".wav", + "entity_type": entity_types[0], + "parent_client_id": ids_mapping[int(word_id)][0], + "parent_object_id": ids_mapping[int(word_id)][1], + "content": base64.urlsafe_b64encode(audio).decode()} + if not is_a_regular_form: + audio_element['additional_metadata'] = '{"hash": %s, "client_id": %s, "row_id": %s}'\ + % (audio_hash, client_id, cursor[5]) + audio_sequence.append(audio_element) + + markup_hashes.add(markup_hash) + markup_element = { + "locale_id": locale_id, + "level": "leveltwoentity", + "data_type": "markup", + "filename": common_name + ".TextGrid", + "entity_type": entity_types[1], + # need to set after push "parent_client_id": ids_mapping[int(word_id)][0], + # need to set after push "parent_object_id": ids_mapping[int(word_id)][1], + "content": base64.urlsafe_b64encode(markup).decode()} + if not is_a_regular_form: + audio_element['additional_metadata'] = '{"client_id": %s, "row_id": %s}' % (client_id, cursor[5]) + markup_sequence.append(markup_element) + else: + if markup_hash not in markup_hashes: + + markup_hashes.add(markup_hash) + markup_element = { + "locale_id": locale_id, + "level": "leveltwoentity", + "data_type": "markup", + "filename": common_name + ".TextGrid", + "entity_type": entity_types[1], + "content": base64.urlsafe_b64encode(markup).decode(), + "additional_metadata": '{"hash": %s}' % markup_hash} + markup__without_audio_sequence.append((audio_hash, markup_element)) + if len(markup__without_audio_sequence) > 50: + markup__without_audio_sequence = upload_markup(upload_url, search_url, + markup__without_audio_sequence, session) + + if len(audio_sequence) > 50: + upload_audio(upload_url, audio_sequence, markup_sequence, session) + audio_sequence = [] + markup_sequence = [] + if len(markup__without_audio_sequence) > 50: + markup__without_audio_sequence = upload_markup(upload_url, search_url, + markup__without_audio_sequence, session) + + if len(audio_sequence) != 0: + upload_audio(upload_url, audio_sequence, markup_sequence, session) + audio_sequence = [] + markup_sequence = [] + + if len(markup__without_audio_sequence) != 0: + upload_markup(upload_url, markup__without_audio_sequence, session) + markup__without_audio_sequence = [] + + +def change_dict_status(session, converting_status_url, status): + session.put(converting_status_url, json={'status': status}) + + +def convert_db_new(sqconn, session, language_client_id, language_object_id, server_url, + dictionary_client_id, dictionary_object_id, perspective_client_id, perspective_object_id, locale_id=1): + log = logging.getLogger(__name__) + dict_attributes = get_dict_attributes(sqconn) + if not dictionary_client_id or not dictionary_object_id: + create_dictionary_request = {"parent_client_id": language_client_id, + "parent_object_id": language_object_id, + "translation": dict_attributes['dictionary_name'], + "translation_string": dict_attributes['dictionary_name']} + status = session.post(server_url + 'dictionary', json=create_dictionary_request) + dictionary = json.loads(status.text) + else: + dictionary = {'client_id': dictionary_client_id, 'object_id': dictionary_object_id} + client_id = dictionary['client_id'] + + converting_status_url = server_url + 'dictionary/%s/%s/state' % (dictionary['client_id'], dictionary['object_id']) + + change_dict_status(session, converting_status_url, 'Converting 5%') + perspective_create_url = server_url + 'dictionary/%s/%s/perspective' % ( + dictionary['client_id'], dictionary['object_id']) + + if not perspective_client_id or not perspective_object_id: + create_perspective_request = {"translation": "Этимологический словарь из Lingvodoc 0.98", + "translation_string": "Lingvodoc 0.98 etymology dictionary", + "import_source": "Lingvodoc-0.98", + "import_hash": dict_attributes['dialeqt_id']} + + status = session.post(perspective_create_url, json=create_perspective_request) + perspective = json.loads(status.text) + else: + perspective = {'client_id': perspective_client_id, 'object_id': perspective_object_id} + + converting_perspective_status_url = server_url + 'dictionary/%s/%s/perspective/%s/%s/state' % \ + (dictionary['client_id'], dictionary['object_id'], + perspective['client_id'], perspective['object_id']) + change_dict_status(session, converting_perspective_status_url, 'Converting') + + create_perspective_fields_request = session.get(server_url + 'dictionary/1/1/perspective/1/1/fields') + perspective_fields_create_url = perspective_create_url + '/%s/%s/fields' % (perspective['client_id'], + perspective['object_id']) + status = session.post(perspective_fields_create_url, json=create_perspective_fields_request.text) + + get_all_ids = sqconn.cursor() + get_all_ids.execute("select id from dictionary where is_a_regular_form=1") + + create_lexical_entries_url = perspective_create_url + '/%s/%s/lexical_entries' % ( + perspective['client_id'], perspective['object_id']) + count_cursor = sqconn.cursor() + count_cursor.execute("select count(*) from dictionary where is_a_regular_form=1") + words_count = count_cursor.fetchone()[0] + lexical_entries_create_request = {"count": words_count} + status = session.post(create_lexical_entries_url, json=lexical_entries_create_request) + ids_dict = json.loads(status.text) + + ids_mapping = dict() + i = 0 + for id_cursor in get_all_ids: + id = id_cursor[0] + client_id = ids_dict[i]['client_id'] + object_id = ids_dict[i]['object_id'] + ids_mapping[id] = (client_id, object_id) + i += 1 + + create_entities_url = server_url + 'dictionary/%s/%s/perspective/%s/%s/entities' % (dictionary['client_id'], + dictionary['object_id'], + perspective['client_id'], + perspective['object_id']) + + change_dict_status(session, converting_status_url, 'Converting 15%') + + def create_entity_list(mapping, cursor, level, data_type, entity_type, is_a_regular_form, locale_id=1): + push_list = [] + for ld_cursor in cursor: + ld_id = int(ld_cursor[0]) + content = ld_cursor[1] + parent_client_id = mapping[ld_id][0] + parent_object_id = mapping[ld_id][1] + element = {"locale_id": locale_id, + "level": level, + "data_type": data_type, + "entity_type": entity_type, + "parent_client_id": parent_client_id, + "parent_object_id": parent_object_id, + "content": content} + if not is_a_regular_form: + element['additional_metadata'] = '{"client_id": %s, "row_id": %s}' % (client_id, ld_cursor[2]) + push_list.append(element) + return push_list + + def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, entity_type): + sqcursor = sqconn.cursor() + if is_a_regular_form: + sqcursor.execute("select %s,%s from dictionary where is_a_regular_form=1" % (id_column, text_column)) + else: + sqcursor.execute("select %s,%s,id from dictionary where is_a_regular_form=0" % (id_column, text_column)) + push_list = create_entity_list(ids_mapping, sqcursor, "leveloneentity", 'text', entity_type, is_a_regular_form) + return session.post(create_entities_url, json=push_list) + + for column_and_type in [("word", "Word"), + ("transcription", "Transcription"), + ("translation", "Translation")]: + status = prepare_and_upload_text_entities("id", True, column_and_type[0], column_and_type[1]) + log.debug(status.text) + + for column_and_type in [("word", "Paradigm word"), + ("transcription", "Paradigm transcription"), + ("translation", "Paradigm translation")]: + status = prepare_and_upload_text_entities("regular_form", False, column_and_type[0], column_and_type[1]) + log.debug(status.text) + + change_dict_status(session, converting_status_url, 'Converting 35%') + + sound_and_markup_word_cursor = sqconn.cursor() + sound_and_markup_word_cursor.execute("""select blobs.id, + blobs.secblob, + blobs.mainblob, + dict_blobs_description.name, + dictionary.id + from blobs, dict_blobs_description, dictionary + where dict_blobs_description.blobid=blobs.id + and dict_blobs_description.wordid=dictionary.id + and dict_blobs_description.type=2 + and dictionary.is_a_regular_form=1;""") + + audio_hashes = set() + markup_hashes = set() + + + perspective_search = server_url + 'dictionary/%s/%s/perspective/%s/%s/all' % (dictionary['client_id'], + dictionary['object_id'], + perspective['client_id'], + perspective['object_id']) + search_url = server_url + 'meta_search' + status = session.get(perspective_search) + lexes = json.loads(status.text) + sound_types = ['Sound', 'Paradigm sound'] + markup_types = ['Praat markup', "Paradigm Praat markup"] + for lex in lexes: + for entry in lex['contains']: + meta = json.loads(entry['additional_metadata']) + hsh = meta.get('hash') + if hsh: + if entry['entity_type'] in sound_types: + audio_hashes += [hsh] + for ent in entry['contains']: + meta = json.loads(ent['additional_metadata']) + hsh = meta.get('hash') + if hsh: + if ent['entity_type'] in markup_types: + markup_types += [hsh] + + entity_types = ['Sound', 'Praat markup'] + upload_audio_with_markup(session, ids_mapping, sound_and_markup_word_cursor, create_entities_url, search_url, + audio_hashes, markup_hashes, entity_types, client_id, True, locale_id) + log.debug(audio_hashes) + + change_dict_status(session, converting_status_url, 'Converting 45%') + + paradigm_sound_and_markup_cursor = sqconn.cursor() + paradigm_sound_and_markup_cursor.execute("""select blobs.id, + blobs.secblob, + blobs.mainblob, + dict_blobs_description.name, + dictionary.regular_form, + dictionary.id + from blobs, dict_blobs_description, dictionary + where dict_blobs_description.blobid=blobs.id + and dict_blobs_description.wordid=dictionary.id + and dict_blobs_description.type=2 + and dictionary.is_a_regular_form=0;""") + + entity_types = ['Paradigm sound', "Paradigm Praat markup"] + upload_audio_with_markup(session, ids_mapping, paradigm_sound_and_markup_cursor, create_entities_url, search_url, + audio_hashes, markup_hashes, entity_types, client_id, False, locale_id) + log.debug(audio_hashes) + + change_dict_status(session, converting_status_url, 'Converting 60%') + + simple_word_sound_cursor = sqconn.cursor() + simple_word_sound_cursor.execute("""select blobs.id, + blobs.mainblob, + dict_blobs_description.name, + dictionary.id + from blobs, dict_blobs_description, dictionary + where dict_blobs_description.blobid=blobs.id + and dict_blobs_description.wordid=dictionary.id + and dict_blobs_description.type=1 + and dictionary.is_a_regular_form=1;""") + entity_types = ['Sound'] + upload_audio_simple(session, ids_mapping, simple_word_sound_cursor, create_entities_url, audio_hashes, entity_types, + client_id, True, locale_id) + + change_dict_status(session, converting_status_url, 'Converting 70%') + + simple_paradigm_sound_cursor = sqconn.cursor() + simple_paradigm_sound_cursor.execute("""select blobs.id, + blobs.mainblob, + dict_blobs_description.name, + dictionary.regular_form, + dictionary.id + from blobs, dict_blobs_description, dictionary + where dict_blobs_description.blobid=blobs.id + and dict_blobs_description.wordid=dictionary.id + and dict_blobs_description.type=1 + and dictionary.is_a_regular_form=0;""") + entity_types = ['Paradigm sound'] + upload_audio_simple(session, ids_mapping, simple_paradigm_sound_cursor, create_entities_url, audio_hashes, + entity_types, client_id, False, locale_id) + + change_dict_status(session, converting_status_url, 'Converting 80%') + + connect_url = server_url + 'dictionary/%s/%s/perspective/%s/%s/lexical_entry/connect' % (dictionary['client_id'], + dictionary['object_id'], + perspective['client_id'], + perspective['object_id']) + etymology_cursor = sqconn.cursor() + etymology_cursor.execute("""select id, etimology_tag + FROM dictionary + WHERE etimology_tag NOT NULL + and dictionary.is_a_regular_form=1; """) + for cursor in etymology_cursor: + id = int(cursor[0]) + client_id = ids_mapping[id][0] + object_id = ids_mapping[id][1] + item = {"entity_type": "Etymology", "tag": cursor[1], + "connections": [{"client_id": client_id, "object_id": object_id}]} + status = session.post(connect_url, json=item) + log.debug(status.text) + + change_dict_status(session, converting_status_url, 'Converted 100%') + + change_dict_status(session, converting_status_url, 'Published') + change_dict_status(session, converting_perspective_status_url, 'Published') + + return dictionary + +def convert_one(filename, login, password_hash, language_client_id, language_object_id, + dictionary_client_id, dictionary_object_id, perspective_client_id, perspective_object_id, + server_url="http://localhost:6543/"): + log = logging.getLogger(__name__) + log.debug("Starting convert_one") + log.debug("Creating session") + session = requests.Session() + session.headers.update({'Connection': 'Keep-Alive'}) + adapter = requests.adapters.HTTPAdapter(pool_connections=1, pool_maxsize=1, max_retries=3) + session.mount('http://', adapter) + log.debug("Going to login") + login_data = {"login": login, "passwordhash": password_hash} + log.debug("Login data: " + login_data['login'] + login_data['passwordhash']) + cookie_set = session.post(server_url + 'cheatlogin', json=login_data) + log.debug("Login status:" + str(cookie_set.status_code)) + if cookie_set.status_code != 200: + log.error("Cheat login for conversion was unsuccessful") + exit(-1) + sqconn = sqlite3.connect(filename) + log.debug("Connected to sqlite3 database") + try: + status = convert_db_new(sqconn, session, language_client_id, language_object_id, server_url, + dictionary_client_id, dictionary_object_id, perspective_client_id, perspective_object_id) + except Exception as e: + log.error("Converting failed") + log.error(e.__traceback__) + raise + log.debug(status) + return status + + +if __name__ == "__main__": + log = logging.getLogger(__name__) + log.setLevel(logging.DEBUG) + logging.basicConfig(format='%(asctime)s\t%(levelname)s\t[%(name)s]\t%(message)s') + log.debug("!!!!!!!!!! YOU SHOULD NOT SEE IT !!!!!!!!") + convert_one(filename="/Users/al/Movies/dicts-current/nenets_kaninski.sqlite", login="", + password_hash="", + language_client_id=33, language_object_id=24, server_url="http://lingvodoc.ispras.ru/") diff --git a/lingvodoc/views.py b/lingvodoc/views.py index db499d090..da8a4d8a9 100644 --- a/lingvodoc/views.py +++ b/lingvodoc/views.py @@ -4,7 +4,7 @@ from sqlalchemy.exc import DBAPIError -from .scripts.lingvodoc_converter import convert_one +from .scripts.lingvodoc_converter_new import convert_one, get_dict_attributes from .models import ( DBSession, @@ -101,6 +101,37 @@ def __str__(self): return repr(self.value) +@view_config(route_name='entity_metadata_search', renderer='json', request_method='GET') +def entity_metadata_search(request): + # TODO: add same check for permission as in basic_search + # TODO: add filters to search in only one perspective + searchstring = request.params.get('searchstring') + searchtype = request.params.get('searchtype') + client_id = request.params.get('perspective_client_id') + object_id = request.params.get('perspective_object_id') + results_cursor = DBSession.query(LevelOneEntity)\ + .filter(LevelOneEntity.entity_type == searchtype, + LevelOneEntity.additional_metadata.like('%'+searchstring+'%'))\ + .all() + results_cursor += DBSession.query(LevelTwoEntity)\ + .filter(LevelTwoEntity.entity_type == searchtype, + LevelTwoEntity.additional_metadata.like('%'+searchstring+'%'))\ + .all() + results = [] + entries = set() + for item in results_cursor: + entries.add(item) + for entry in entries: + if not entry.marked_for_deletion: + result = dict() + result['level'] = str(type(entry)).lower() + result['client_id'] = entry.client_id + result['object_id'] = entry.object_id + result['additional_metadata'] = entry.additional_metadata + results.append(result) + return results + + @view_config(route_name='basic_search_old', renderer='json', request_method='GET') def basic_search_old(request): searchstring = request.params.get('leveloneentity') @@ -222,6 +253,83 @@ def convert_dictionary(request): " Wait 5-15 minutes and you will see new dictionary in your dashboard."} +@view_config(route_name='convert_dictionary_check', renderer='json', request_method='POST') +def convert_dictionary_check(request): + import sqlite3 + req = request.json_body + + client_id = req['blob_client_id'] + object_id = req['blob_object_id'] + # parent_client_id = req['parent_client_id'] + # parent_object_id = req['parent_object_id'] + client = DBSession.query(Client).filter_by(id=authenticated_userid(request)).first() + user = client.user + + blob = DBSession.query(UserBlobs).filter_by(client_id=client_id, object_id=object_id).first() + filename = blob.real_storage_path + sqconn = sqlite3.connect(filename) + res = get_dict_attributes(sqconn) + dialeqt_id = res['dialeqt_id'] + persps = DBSession.query(DictionaryPerspective).filter(DictionaryPerspective.import_hash == dialeqt_id).all() + perspectives = [] + for perspective in persps: + path = request.route_url('perspective', + dictionary_client_id=perspective.parent_client_id, + dictionary_object_id=perspective.parent_object_id, + perspective_client_id=perspective.client_id, + perspective_id=perspective.object_id) + subreq = Request.blank(path) + subreq.method = 'GET' + subreq.headers = request.headers + resp = request.invoke_subrequest(subreq) + if 'error' not in resp.json: + perspectives += [resp.json] + request.response.status = HTTPOk.code + return perspectives + + +#TODO: make it normal, it's just a test +@view_config(route_name='convert_dictionary_new', renderer='json', request_method='POST') +def convert_dictionary_new(request): + req = request.json_body + + client_id = req['blob_client_id'] + object_id = req['blob_object_id'] + parent_client_id = req['parent_client_id'] + parent_object_id = req['parent_object_id'] + dictionary_client_id = req.get('dictionary_client_id') + dictionary_object_id = req.get('dictionary_object_id') + perspective_client_id = req.get('perspective_client_id') + perspective_object_id = req.get('perspective_object_id') + client = DBSession.query(Client).filter_by(id=authenticated_userid(request)).first() + user = client.user + + blob = DBSession.query(UserBlobs).filter_by(client_id=client_id, object_id=object_id).first() + + # convert_one(blob.real_storage_path, + # user.login, + # user.password.hash, + # parent_client_id, + # parent_object_id) + + # NOTE: doesn't work on Mac OS otherwise + + p = multiprocessing.Process(target=convert_one, args=(blob.real_storage_path, + user.login, + user.password.hash, + parent_client_id, + parent_object_id, + dictionary_client_id, + dictionary_object_id, + perspective_client_id, + perspective_object_id)) + log.debug("Conversion started") + p.start() + request.response.status = HTTPOk.code + return {"status": "Your dictionary is being converted." + " Wait 5-15 minutes and you will see new dictionary in your dashboard."} + + @view_config(route_name='language', renderer='json', request_method='GET') def view_language(request): response = dict() From ecfa9e8d6589dc8e009e62f400a8a12027f61098 Mon Sep 17 00:00:00 2001 From: "A. Tapekhin" Date: Tue, 3 Nov 2015 14:34:53 +0300 Subject: [PATCH 02/73] some changes in converter --- lingvodoc/__init__.py | 4 ++ lingvodoc/models.py | 2 +- lingvodoc/scripts/lingvodoc_converter_new.py | 40 ++++++++++++-------- lingvodoc/views.py | 3 +- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/lingvodoc/__init__.py b/lingvodoc/__init__.py index c3776f70d..9f7238804 100755 --- a/lingvodoc/__init__.py +++ b/lingvodoc/__init__.py @@ -306,6 +306,10 @@ def configure_routes(config): # like config.add_route(name='basic_search', pattern='/basic_search') + # API #GET + # like + config.add_route(name='entity_metadata_search', pattern='/meta_search') + # API #GET # like config.add_route(name='basic_search_old', pattern='/basic_search_old') diff --git a/lingvodoc/models.py b/lingvodoc/models.py index aa5e0c33c..ced59381d 100755 --- a/lingvodoc/models.py +++ b/lingvodoc/models.py @@ -80,7 +80,7 @@ def recursive_content(self, publish): additional_metadata = None if hasattr(xx, "additional_metadata"): if xx.additional_metadata: - additional_metadata = json.loads(xx.additional_metadata) + additional_metadata = xx.additional_metadata locale_id = None if hasattr(xx, "locale_id"): locale_id = xx.locale_id diff --git a/lingvodoc/scripts/lingvodoc_converter_new.py b/lingvodoc/scripts/lingvodoc_converter_new.py index 8bd945d6a..4617c6529 100644 --- a/lingvodoc/scripts/lingvodoc_converter_new.py +++ b/lingvodoc/scripts/lingvodoc_converter_new.py @@ -84,6 +84,8 @@ def upload_audio_simple(session, ids_mapping, sound_and_markup_cursor, upload_ur if not is_a_regular_form: audio_element['additional_metadata'] = '{"hash": %s, "client_id": %s, "row_id": %s}' % \ (audio_hash, client_id, cursor[4]) + else: + audio_element['additional_metadata'] = '{"hash": %s}' % audio_hash audio_sequence.append(audio_element) if len(audio_sequence) > 50: upload_audio(upload_url, audio_sequence, None, session) @@ -121,8 +123,11 @@ def upload_audio_with_markup(session, ids_mapping, sound_and_markup_cursor, uplo if not is_a_regular_form: audio_element['additional_metadata'] = '{"hash": %s, "client_id": %s, "row_id": %s}'\ % (audio_hash, client_id, cursor[5]) + else: + audio_element['additional_metadata'] = '{"hash": %s}' % audio_hash audio_sequence.append(audio_element) + markup_hashes.add(markup_hash) markup_element = { "locale_id": locale_id, @@ -132,9 +137,8 @@ def upload_audio_with_markup(session, ids_mapping, sound_and_markup_cursor, uplo "entity_type": entity_types[1], # need to set after push "parent_client_id": ids_mapping[int(word_id)][0], # need to set after push "parent_object_id": ids_mapping[int(word_id)][1], - "content": base64.urlsafe_b64encode(markup).decode()} - if not is_a_regular_form: - audio_element['additional_metadata'] = '{"client_id": %s, "row_id": %s}' % (client_id, cursor[5]) + "content": base64.urlsafe_b64encode(markup).decode(), + "additional_metadata": '{"hash": %s}' % markup_hash} markup_sequence.append(markup_element) else: if markup_hash not in markup_hashes: @@ -167,7 +171,7 @@ def upload_audio_with_markup(session, ids_mapping, sound_and_markup_cursor, uplo markup_sequence = [] if len(markup__without_audio_sequence) != 0: - upload_markup(upload_url, markup__without_audio_sequence, session) + upload_markup(upload_url, search_url, markup__without_audio_sequence, session) markup__without_audio_sequence = [] @@ -309,23 +313,29 @@ def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, perspective['object_id']) search_url = server_url + 'meta_search' status = session.get(perspective_search) - lexes = json.loads(status.text) + lexes = json.loads(status.text)['lexical_entries'] sound_types = ['Sound', 'Paradigm sound'] markup_types = ['Praat markup', "Paradigm Praat markup"] for lex in lexes: for entry in lex['contains']: - meta = json.loads(entry['additional_metadata']) - hsh = meta.get('hash') - if hsh: - if entry['entity_type'] in sound_types: - audio_hashes += [hsh] - for ent in entry['contains']: - meta = json.loads(ent['additional_metadata']) + meta = entry.get('additional_metadata') + if meta: + meta = json.loads(meta) hsh = meta.get('hash') if hsh: - if ent['entity_type'] in markup_types: - markup_types += [hsh] - + if entry['entity_type'] in sound_types: + audio_hashes += [hsh] + if entry.get('contains'): + for ent in entry['contains']: + meta = entry.get('additional_metadata') + if meta: + meta = json.loads(meta) + hsh = meta.get('hash') + if hsh: + if ent['entity_type'] in markup_types: + markup_types += [hsh] + print(audio_hashes) + print(markup_hashes) entity_types = ['Sound', 'Praat markup'] upload_audio_with_markup(session, ids_mapping, sound_and_markup_word_cursor, create_entities_url, search_url, audio_hashes, markup_hashes, entity_types, client_id, True, locale_id) diff --git a/lingvodoc/views.py b/lingvodoc/views.py index da8a4d8a9..5b982d23a 100644 --- a/lingvodoc/views.py +++ b/lingvodoc/views.py @@ -164,7 +164,6 @@ def basic_search_old(request): @view_config(route_name='basic_search', renderer='json', request_method='GET') def basic_search(request): can_add_tags = request.params.get('can_add_tags') - print(can_add_tags) searchstring = request.params.get('leveloneentity') if searchstring: if len(searchstring) >= 2: @@ -2263,6 +2262,8 @@ def create_entities_bulk(request): inserted_items = [] for item in req: if item['level'] == 'leveloneentity': + if 'sound' in item['entity_type'].lower(): + print(item.get('additional_metadata')) parent = DBSession.query(LexicalEntry).filter_by(client_id=item['parent_client_id'], object_id=item['parent_object_id']).first() entity = LevelOneEntity(client_id=client.id, object_id=DBSession.query(LevelOneEntity).filter_by(client_id=client.id).count() + 1, From 47cb8cddc0981ef791dfbfaccf98a72868403658 Mon Sep 17 00:00:00 2001 From: "A. Tapekhin" Date: Tue, 3 Nov 2015 17:26:18 +0300 Subject: [PATCH 03/73] additional_metadata problem fixed --- lingvodoc/scripts/lingvodoc_converter_new.py | 35 ++++++++++---------- lingvodoc/views.py | 10 +++--- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/lingvodoc/scripts/lingvodoc_converter_new.py b/lingvodoc/scripts/lingvodoc_converter_new.py index 4617c6529..cf58607ea 100644 --- a/lingvodoc/scripts/lingvodoc_converter_new.py +++ b/lingvodoc/scripts/lingvodoc_converter_new.py @@ -39,7 +39,6 @@ def upload_audio(upload_url, audio_sequence, markup_sequence, session): def upload_markup(upload_url, search_url, markup_sequence, session): - print('I was here. True story') log = logging.getLogger(__name__) for entry in markup_sequence: audio_hash = entry[0] @@ -82,10 +81,11 @@ def upload_audio_simple(session, ids_mapping, sound_and_markup_cursor, upload_ur "parent_object_id": ids_mapping[int(word_id)][1], "content": base64.urlsafe_b64encode(audio).decode()} if not is_a_regular_form: - audio_element['additional_metadata'] = '{"hash": %s, "client_id": %s, "row_id": %s}' % \ - (audio_hash, client_id, cursor[4]) + audio_element['additional_metadata'] = json.dumps({"hash": audio_hash, + "client_id": client_id, + "row_id": cursor[4]}) else: - audio_element['additional_metadata'] = '{"hash": %s}' % audio_hash + audio_element['additional_metadata'] = json.dumps({"hash": audio_hash }) audio_sequence.append(audio_element) if len(audio_sequence) > 50: upload_audio(upload_url, audio_sequence, None, session) @@ -121,10 +121,11 @@ def upload_audio_with_markup(session, ids_mapping, sound_and_markup_cursor, uplo "parent_object_id": ids_mapping[int(word_id)][1], "content": base64.urlsafe_b64encode(audio).decode()} if not is_a_regular_form: - audio_element['additional_metadata'] = '{"hash": %s, "client_id": %s, "row_id": %s}'\ - % (audio_hash, client_id, cursor[5]) + audio_element['additional_metadata'] = json.dumps({"hash": audio_hash, + "client_id": client_id, + "row_id": cursor[5]}) else: - audio_element['additional_metadata'] = '{"hash": %s}' % audio_hash + audio_element['additional_metadata'] = json.dumps({"hash": audio_hash }) audio_sequence.append(audio_element) @@ -138,20 +139,20 @@ def upload_audio_with_markup(session, ids_mapping, sound_and_markup_cursor, uplo # need to set after push "parent_client_id": ids_mapping[int(word_id)][0], # need to set after push "parent_object_id": ids_mapping[int(word_id)][1], "content": base64.urlsafe_b64encode(markup).decode(), - "additional_metadata": '{"hash": %s}' % markup_hash} + "additional_metadata": json.dumps({"hash": markup_hash})} markup_sequence.append(markup_element) else: if markup_hash not in markup_hashes: markup_hashes.add(markup_hash) markup_element = { - "locale_id": locale_id, - "level": "leveltwoentity", - "data_type": "markup", - "filename": common_name + ".TextGrid", - "entity_type": entity_types[1], - "content": base64.urlsafe_b64encode(markup).decode(), - "additional_metadata": '{"hash": %s}' % markup_hash} + "locale_id": locale_id, + "level": "leveltwoentity", + "data_type": "markup", + "filename": common_name + ".TextGrid", + "entity_type": entity_types[1], + "content": base64.urlsafe_b64encode(markup).decode(), + "additional_metadata": json.dumps({"hash": markup_hash})} markup__without_audio_sequence.append((audio_hash, markup_element)) if len(markup__without_audio_sequence) > 50: markup__without_audio_sequence = upload_markup(upload_url, search_url, @@ -324,7 +325,7 @@ def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, hsh = meta.get('hash') if hsh: if entry['entity_type'] in sound_types: - audio_hashes += [hsh] + audio_hashes.add(hsh) if entry.get('contains'): for ent in entry['contains']: meta = entry.get('additional_metadata') @@ -333,7 +334,7 @@ def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, hsh = meta.get('hash') if hsh: if ent['entity_type'] in markup_types: - markup_types += [hsh] + markup_hashes.add(hsh) print(audio_hashes) print(markup_hashes) entity_types = ['Sound', 'Praat markup'] diff --git a/lingvodoc/views.py b/lingvodoc/views.py index 5b982d23a..263b8cef5 100644 --- a/lingvodoc/views.py +++ b/lingvodoc/views.py @@ -2209,9 +2209,11 @@ def create_l1_entity(request): if not parent: request.response.status = HTTPNotFound.code return {'error': str("No such lexical entry in the system")} + additional_metadata=req.get('additional_metadata') if additional_metadata: - additional_metadata = json.dumps(additional_metadata) + if type(additional_metadata) != str: + additional_metadata = json.dumps(additional_metadata) entity = LevelOneEntity(client_id=client.id, object_id=DBSession.query(LevelOneEntity).filter_by(client_id=client.id).count() + 1, entity_type=req['entity_type'], locale_id=req['locale_id'], additional_metadata=additional_metadata, parent=parent) @@ -2262,8 +2264,6 @@ def create_entities_bulk(request): inserted_items = [] for item in req: if item['level'] == 'leveloneentity': - if 'sound' in item['entity_type'].lower(): - print(item.get('additional_metadata')) parent = DBSession.query(LexicalEntry).filter_by(client_id=item['parent_client_id'], object_id=item['parent_object_id']).first() entity = LevelOneEntity(client_id=client.id, object_id=DBSession.query(LevelOneEntity).filter_by(client_id=client.id).count() + 1, @@ -4213,8 +4213,8 @@ def remove_deleted(lst): @view_config(route_name='merge_suggestions', renderer='json', request_method='POST') def merge_suggestions(request): req = request.json - entity_type_primary = req['entity_type_primary'] or 'Word' - entity_type_secondary = req['entity_type_secondary'] or 'Transcription' + entity_type_primary = req.get('entity_type_primary') or 'Transcription' + entity_type_secondary = req.get('entity_type_secondary') or 'Translation' threshold = req['threshold'] or 0.2 levenstein = req['levenstein'] or 1 client_id = req['client_id'] From c0838f1346595425f8bba0b9c3759a4183bea8cb Mon Sep 17 00:00:00 2001 From: "A. Tapekhin" Date: Thu, 5 Nov 2015 17:27:18 +0300 Subject: [PATCH 04/73] more work on converter done --- lingvodoc/scripts/lingvodoc_converter_new.py | 28 ++++++-- lingvodoc/views.py | 76 ++++++++++---------- 2 files changed, 60 insertions(+), 44 deletions(-) diff --git a/lingvodoc/scripts/lingvodoc_converter_new.py b/lingvodoc/scripts/lingvodoc_converter_new.py index cf58607ea..e3d3a7f33 100644 --- a/lingvodoc/scripts/lingvodoc_converter_new.py +++ b/lingvodoc/scripts/lingvodoc_converter_new.py @@ -265,7 +265,7 @@ def create_entity_list(mapping, cursor, level, data_type, entity_type, is_a_regu "parent_object_id": parent_object_id, "content": content} if not is_a_regular_form: - element['additional_metadata'] = '{"client_id": %s, "row_id": %s}' % (client_id, ld_cursor[2]) + element['additional_metadata'] = json.dumps({"client_id": client_id, "row_id": ld_cursor[2]}) push_list.append(element) return push_list @@ -321,7 +321,6 @@ def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, for entry in lex['contains']: meta = entry.get('additional_metadata') if meta: - meta = json.loads(meta) hsh = meta.get('hash') if hsh: if entry['entity_type'] in sound_types: @@ -330,13 +329,10 @@ def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, for ent in entry['contains']: meta = entry.get('additional_metadata') if meta: - meta = json.loads(meta) hsh = meta.get('hash') if hsh: if ent['entity_type'] in markup_types: markup_hashes.add(hsh) - print(audio_hashes) - print(markup_hashes) entity_types = ['Sound', 'Praat markup'] upload_audio_with_markup(session, ids_mapping, sound_and_markup_word_cursor, create_entities_url, search_url, audio_hashes, markup_hashes, entity_types, client_id, True, locale_id) @@ -414,14 +410,34 @@ def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, "connections": [{"client_id": client_id, "object_id": object_id}]} status = session.post(connect_url, json=item) log.debug(status.text) + suggestions_url = server_url + 'merge/suggestions' + + suggestions_params = {'threshold': 1.0, + 'levenstein': 0, + 'client_id': perspective['client_id'], + 'object_id': perspective['object_id']} + status = session.post(suggestions_url, json=suggestions_params) + for entry in json.loads(status.text): + if entry['confidence'] >= 1.0: + first_entry = entry['suggestion'][0] + second_entry = entry['suggestion'][1] + lex_move_url = server_url + 'lexical_entry/%d/%d/move' % (second_entry['lexical_entry_client_id'], + second_entry['lexical_entry_object_id']) + move_params = {'client_id': first_entry['lexical_entry_client_id'], + 'object_id': first_entry['lexical_entry_object_id'], + 'real_delete': True} + status = session.patch(lex_move_url, json=move_params) + + else: + break change_dict_status(session, converting_status_url, 'Converted 100%') change_dict_status(session, converting_status_url, 'Published') change_dict_status(session, converting_perspective_status_url, 'Published') - return dictionary + def convert_one(filename, login, password_hash, language_client_id, language_object_id, dictionary_client_id, dictionary_object_id, perspective_client_id, perspective_object_id, server_url="http://localhost:6543/"): diff --git a/lingvodoc/views.py b/lingvodoc/views.py index ecfc30eba..daa4d0428 100644 --- a/lingvodoc/views.py +++ b/lingvodoc/views.py @@ -2212,9 +2212,8 @@ def create_l1_entity(request): return {'error': str("No such lexical entry in the system")} additional_metadata=req.get('additional_metadata') - if additional_metadata: - if type(additional_metadata) != str: - additional_metadata = json.dumps(additional_metadata) + if type(additional_metadata) != str: + additional_metadata = json.dumps(additional_metadata) entity = LevelOneEntity(client_id=client.id, object_id=DBSession.query(LevelOneEntity).filter_by(client_id=client.id).count() + 1, entity_type=req['entity_type'], locale_id=req['locale_id'], additional_metadata=additional_metadata, parent=parent) @@ -3498,6 +3497,8 @@ def move_lexical_entry(request): client_id = request.matchdict.get('client_id') cli_id = req['client_id'] obj_id = req['object_id'] + real_delete = req['real_delete'] # With great power comes great responsibility + # Maybe there needs to be check for permission of some sort (can really delete only when updating dictionary) entry = DBSession.query(LexicalEntry).filter_by(client_id=client_id, object_id=object_id).first() parent = DBSession.query(LexicalEntry).filter_by(client_id=cli_id, object_id=obj_id).first() if entry and parent: @@ -3514,41 +3515,39 @@ def move_lexical_entry(request): if user not in groupoverride.users: if user not in group.users: raise CommonException("You should only move to lexical entires you own") - if parent.moved_to: - path = request.route_url('lexical_entry', - client_id=cli_id, - ) - subreq = Request.blank(path) - subreq.method = 'GET' - subreq.headers = request.headers - resp = request.invoke_subrequest(subreq) - if entry.moved_to is None: - - if not entry.marked_for_deletion and not parent.marked_for_deletion: - l1e = DBSession.query(LevelOneEntity).filter_by(parent = entry).all() - for entity in l1e: - ent = DBSession.query(LevelOneEntity)\ - .filter_by(parent=parent, entity_type=entity.entity_type, content = entity.content)\ - .first() - if ent: - entity.marked_for_deletion = True - entity.parent = parent - - for publent in entity.publishleveloneentity: - publent.marked_for_deletion = True - publent.parent = parent - DBSession.flush() - ge = DBSession.query(GroupingEntity).filter_by(parent = entry).all() - for entity in ge: - entity.parent = parent - for publent in entity.publishgroupingentity: - publent.marked_for_deletion = True - publent.parent = parent - DBSession.flush() - entry.moved_to = str(cli_id) + '/' + str(obj_id) - entry.marked_for_deletion = True - request.response.status = HTTPOk.code - return {} + if parent.moved_to is None: + if entry.moved_to is None: + + if not entry.marked_for_deletion and not parent.marked_for_deletion: + l1e = DBSession.query(LevelOneEntity).filter_by(parent = entry).all() + for entity in l1e: + ent = DBSession.query(LevelOneEntity)\ + .filter_by(parent=parent, entity_type=entity.entity_type, content = entity.content)\ + .first() + if ent: + entity.marked_for_deletion = True + if real_delete: + for publent in entity.publishleveloneentity: + DBSession.delete(publent) + DBSession.delete(entity) + continue + entity.parent = parent + + for publent in entity.publishleveloneentity: + publent.marked_for_deletion = True + publent.parent = parent + DBSession.flush() + ge = DBSession.query(GroupingEntity).filter_by(parent = entry).all() + for entity in ge: + entity.parent = parent + for publent in entity.publishgroupingentity: + publent.marked_for_deletion = True + publent.parent = parent + DBSession.flush() + entry.moved_to = str(cli_id) + '/' + str(obj_id) + entry.marked_for_deletion = True + request.response.status = HTTPOk.code + return {} request.response.status = HTTPNotFound.code return {'error': str("No such lexical entry in the system")} @@ -4211,6 +4210,7 @@ def get_dict(elem): if (not tuples_1) or (not tuples_2): return {} results = [get_dict(i) for i in mergeDicts(tuples_1, tuples_2, float(threshold), int(levenstein))] + results = sorted(results, key=lambda k: k['confidence']) return results @view_config(route_name='profile', renderer='templates/profile.pt', request_method='GET') From cfb040cdfcef3ad5aab8938abd0daa5a879ce130 Mon Sep 17 00:00:00 2001 From: "A. Tapekhin" Date: Fri, 6 Nov 2015 14:24:31 +0300 Subject: [PATCH 05/73] converter with update --- lingvodoc/__init__.py | 2 +- lingvodoc/scripts/lingvodoc_converter.py | 230 +++++++++++++----- ...rter_new.py => lingvodoc_converter_old.py} | 230 +++++------------- lingvodoc/views.py | 20 +- 4 files changed, 242 insertions(+), 240 deletions(-) rename lingvodoc/scripts/{lingvodoc_converter_new.py => lingvodoc_converter_old.py} (60%) diff --git a/lingvodoc/__init__.py b/lingvodoc/__init__.py index 21cbacbff..d32bbf3aa 100755 --- a/lingvodoc/__init__.py +++ b/lingvodoc/__init__.py @@ -517,7 +517,7 @@ def configure_routes(config): # {"blob_client_id": , "blob_object_id": , "parent_client_id": , "parent_object_id": } config.add_route(name='convert_dictionary', pattern='/convert') config.add_route(name='convert_dictionary_check', pattern='/convert_check') - config.add_route(name='convert_dictionary_new', pattern='/convert_new') + config.add_route(name='convert_dictionary_old', pattern='/convert_old') def main(global_config, **settings): diff --git a/lingvodoc/scripts/lingvodoc_converter.py b/lingvodoc/scripts/lingvodoc_converter.py index 27e10156a..e3d3a7f33 100644 --- a/lingvodoc/scripts/lingvodoc_converter.py +++ b/lingvodoc/scripts/lingvodoc_converter.py @@ -38,16 +38,39 @@ def upload_audio(upload_url, audio_sequence, markup_sequence, session): log.debug(status.text) -def upload_audio_simple(session, ids_mapping, sound_and_markup_cursor, upload_url, audio_hashes, entity_types, client_id, is_a_regular_form, - locale_id=1): +def upload_markup(upload_url, search_url, markup_sequence, session): + log = logging.getLogger(__name__) + for entry in markup_sequence: + audio_hash = entry[0] + markup_element = entry[1] + entity_metadata_search = search_url + '?hash=%s' % audio_hash # add filters by perspective. Maybe where search_url is created + status = session.get(entity_metadata_search) + ents = json.loads(status.text) + if 'error' not in ents: + if type(ents) == list and len(ents) >= 1: + existing_entity = ents[0] + parent_client_id = existing_entity['client_id'] + parent_object_id = existing_entity['object_id'] + markup_element["parent_client_id"] = parent_client_id + markup_element["parent_object_id"] = parent_object_id + new_markup_sequence = [o[1] for o in markup_sequence if o[1].get["parent_client_id"]] + result = [o for o in markup_sequence if o[1].get["parent_client_id"] is None] + status = session.post(upload_url, json=new_markup_sequence) + log.debug(status.text) + return result + + +def upload_audio_simple(session, ids_mapping, sound_and_markup_cursor, upload_url, audio_hashes, entity_types, + client_id, is_a_regular_form, locale_id=1): audio_sequence = [] for cursor in sound_and_markup_cursor: blob_id = cursor[0] audio = cursor[1] filename = cursor[2] word_id = cursor[3] - - if hashlib.sha224(audio).hexdigest() not in audio_hashes: + audio_hash = hashlib.sha224(audio).hexdigest() + if audio_hash not in audio_hashes: + audio_hashes.add(audio_hash) audio_element = {"locale_id": locale_id, "level": "leveloneentity", @@ -58,7 +81,11 @@ def upload_audio_simple(session, ids_mapping, sound_and_markup_cursor, upload_ur "parent_object_id": ids_mapping[int(word_id)][1], "content": base64.urlsafe_b64encode(audio).decode()} if not is_a_regular_form: - audio_element['additional_metadata'] = '{"client_id": %s, "row_id": %s}' % (client_id, cursor[4]) + audio_element['additional_metadata'] = json.dumps({"hash": audio_hash, + "client_id": client_id, + "row_id": cursor[4]}) + else: + audio_element['additional_metadata'] = json.dumps({"hash": audio_hash }) audio_sequence.append(audio_element) if len(audio_sequence) > 50: upload_audio(upload_url, audio_sequence, None, session) @@ -68,10 +95,11 @@ def upload_audio_simple(session, ids_mapping, sound_and_markup_cursor, upload_ur audio_sequence = [] -def upload_audio_with_markup(session, ids_mapping, sound_and_markup_cursor, upload_url, audio_hashes, entity_types, client_id, is_a_regular_form, - locale_id=1): +def upload_audio_with_markup(session, ids_mapping, sound_and_markup_cursor, upload_url, search_url, audio_hashes, markup_hashes, + entity_types, client_id, is_a_regular_form, locale_id=1): audio_sequence = [] markup_sequence = [] + markup__without_audio_sequence = [] for cursor in sound_and_markup_cursor: blob_id = cursor[0] audio = cursor[1] @@ -80,72 +108,109 @@ def upload_audio_with_markup(session, ids_mapping, sound_and_markup_cursor, uplo word_id = cursor[4] if not audio or not markup: continue - audio_hashes.add(hashlib.sha224(audio).hexdigest()) - - audio_element = {"locale_id": locale_id, - "level": "leveloneentity", - "data_type": "sound", - "filename": common_name + ".wav", - "entity_type": entity_types[0], - "parent_client_id": ids_mapping[int(word_id)][0], - "parent_object_id": ids_mapping[int(word_id)][1], - "content": base64.urlsafe_b64encode(audio).decode()} - if not is_a_regular_form: - audio_element['additional_metadata'] = '{"client_id": %s, "row_id": %s}' % (client_id, cursor[5]) - audio_sequence.append(audio_element) - - markup_element = { - "locale_id": locale_id, - "level": "leveltwoentity", - "data_type": "markup", - "filename": common_name + ".TextGrid", - "entity_type": entity_types[1], - # need to set after push "parent_client_id": ids_mapping[int(word_id)][0], - # need to set after push "parent_object_id": ids_mapping[int(word_id)][1], - "content": base64.urlsafe_b64encode(markup).decode()} - if not is_a_regular_form: - audio_element['additional_metadata'] = '{"client_id": %s, "row_id": %s}' % (client_id, cursor[5]) - markup_sequence.append(markup_element) + audio_hash = hashlib.sha224(audio).hexdigest() + markup_hash = hashlib.sha224(markup).hexdigest() + if audio_hash not in audio_hashes: + audio_hashes.add(audio_hash) + audio_element = {"locale_id": locale_id, + "level": "leveloneentity", + "data_type": "sound", + "filename": common_name + ".wav", + "entity_type": entity_types[0], + "parent_client_id": ids_mapping[int(word_id)][0], + "parent_object_id": ids_mapping[int(word_id)][1], + "content": base64.urlsafe_b64encode(audio).decode()} + if not is_a_regular_form: + audio_element['additional_metadata'] = json.dumps({"hash": audio_hash, + "client_id": client_id, + "row_id": cursor[5]}) + else: + audio_element['additional_metadata'] = json.dumps({"hash": audio_hash }) + audio_sequence.append(audio_element) + + + markup_hashes.add(markup_hash) + markup_element = { + "locale_id": locale_id, + "level": "leveltwoentity", + "data_type": "markup", + "filename": common_name + ".TextGrid", + "entity_type": entity_types[1], + # need to set after push "parent_client_id": ids_mapping[int(word_id)][0], + # need to set after push "parent_object_id": ids_mapping[int(word_id)][1], + "content": base64.urlsafe_b64encode(markup).decode(), + "additional_metadata": json.dumps({"hash": markup_hash})} + markup_sequence.append(markup_element) + else: + if markup_hash not in markup_hashes: + + markup_hashes.add(markup_hash) + markup_element = { + "locale_id": locale_id, + "level": "leveltwoentity", + "data_type": "markup", + "filename": common_name + ".TextGrid", + "entity_type": entity_types[1], + "content": base64.urlsafe_b64encode(markup).decode(), + "additional_metadata": json.dumps({"hash": markup_hash})} + markup__without_audio_sequence.append((audio_hash, markup_element)) + if len(markup__without_audio_sequence) > 50: + markup__without_audio_sequence = upload_markup(upload_url, search_url, + markup__without_audio_sequence, session) if len(audio_sequence) > 50: upload_audio(upload_url, audio_sequence, markup_sequence, session) audio_sequence = [] markup_sequence = [] + if len(markup__without_audio_sequence) > 50: + markup__without_audio_sequence = upload_markup(upload_url, search_url, + markup__without_audio_sequence, session) if len(audio_sequence) != 0: upload_audio(upload_url, audio_sequence, markup_sequence, session) audio_sequence = [] markup_sequence = [] + if len(markup__without_audio_sequence) != 0: + upload_markup(upload_url, search_url, markup__without_audio_sequence, session) + markup__without_audio_sequence = [] + def change_dict_status(session, converting_status_url, status): session.put(converting_status_url, json={'status': status}) -def convert_db_new(sqconn, session, language_client_id, language_object_id, server_url, locale_id=1): +def convert_db_new(sqconn, session, language_client_id, language_object_id, server_url, + dictionary_client_id, dictionary_object_id, perspective_client_id, perspective_object_id, locale_id=1): log = logging.getLogger(__name__) dict_attributes = get_dict_attributes(sqconn) - create_dictionary_request = {"parent_client_id": language_client_id, - "parent_object_id": language_object_id, - "translation": dict_attributes['dictionary_name'], - "translation_string": dict_attributes['dictionary_name']} - status = session.post(server_url + 'dictionary', json=create_dictionary_request) - dictionary = json.loads(status.text) + if not dictionary_client_id or not dictionary_object_id: + create_dictionary_request = {"parent_client_id": language_client_id, + "parent_object_id": language_object_id, + "translation": dict_attributes['dictionary_name'], + "translation_string": dict_attributes['dictionary_name']} + status = session.post(server_url + 'dictionary', json=create_dictionary_request) + dictionary = json.loads(status.text) + else: + dictionary = {'client_id': dictionary_client_id, 'object_id': dictionary_object_id} client_id = dictionary['client_id'] converting_status_url = server_url + 'dictionary/%s/%s/state' % (dictionary['client_id'], dictionary['object_id']) change_dict_status(session, converting_status_url, 'Converting 5%') - perspective_create_url = server_url + 'dictionary/%s/%s/perspective' % ( dictionary['client_id'], dictionary['object_id']) - create_perspective_request = {"translation": "Этимологический словарь из Lingvodoc 0.98", - "translation_string": "Lingvodoc 0.98 etymology dictionary", - "import_source": "Lingvodoc-0.98", - "import_hash": dict_attributes['dialeqt_id']} - status = session.post(perspective_create_url, json=create_perspective_request) - perspective = json.loads(status.text) + if not perspective_client_id or not perspective_object_id: + create_perspective_request = {"translation": "Этимологический словарь из Lingvodoc 0.98", + "translation_string": "Lingvodoc 0.98 etymology dictionary", + "import_source": "Lingvodoc-0.98", + "import_hash": dict_attributes['dialeqt_id']} + + status = session.post(perspective_create_url, json=create_perspective_request) + perspective = json.loads(status.text) + else: + perspective = {'client_id': perspective_client_id, 'object_id': perspective_object_id} converting_perspective_status_url = server_url + 'dictionary/%s/%s/perspective/%s/%s/state' % \ (dictionary['client_id'], dictionary['object_id'], @@ -153,7 +218,8 @@ def convert_db_new(sqconn, session, language_client_id, language_object_id, serv change_dict_status(session, converting_perspective_status_url, 'Converting') create_perspective_fields_request = session.get(server_url + 'dictionary/1/1/perspective/1/1/fields') - perspective_fields_create_url = perspective_create_url + '/%s/%s/fields' % (perspective['client_id'], perspective['object_id']) + perspective_fields_create_url = perspective_create_url + '/%s/%s/fields' % (perspective['client_id'], + perspective['object_id']) status = session.post(perspective_fields_create_url, json=create_perspective_fields_request.text) get_all_ids = sqconn.cursor() @@ -199,7 +265,7 @@ def create_entity_list(mapping, cursor, level, data_type, entity_type, is_a_regu "parent_object_id": parent_object_id, "content": content} if not is_a_regular_form: - element['additional_metadata'] = '{"client_id": %s, "row_id": %s}' % (client_id, ld_cursor[2]) + element['additional_metadata'] = json.dumps({"client_id": client_id, "row_id": ld_cursor[2]}) push_list.append(element) return push_list @@ -239,9 +305,37 @@ def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, and dictionary.is_a_regular_form=1;""") audio_hashes = set() + markup_hashes = set() + + + perspective_search = server_url + 'dictionary/%s/%s/perspective/%s/%s/all' % (dictionary['client_id'], + dictionary['object_id'], + perspective['client_id'], + perspective['object_id']) + search_url = server_url + 'meta_search' + status = session.get(perspective_search) + lexes = json.loads(status.text)['lexical_entries'] + sound_types = ['Sound', 'Paradigm sound'] + markup_types = ['Praat markup', "Paradigm Praat markup"] + for lex in lexes: + for entry in lex['contains']: + meta = entry.get('additional_metadata') + if meta: + hsh = meta.get('hash') + if hsh: + if entry['entity_type'] in sound_types: + audio_hashes.add(hsh) + if entry.get('contains'): + for ent in entry['contains']: + meta = entry.get('additional_metadata') + if meta: + hsh = meta.get('hash') + if hsh: + if ent['entity_type'] in markup_types: + markup_hashes.add(hsh) entity_types = ['Sound', 'Praat markup'] - upload_audio_with_markup(session, ids_mapping, sound_and_markup_word_cursor, create_entities_url, audio_hashes, - entity_types, client_id, True, locale_id) + upload_audio_with_markup(session, ids_mapping, sound_and_markup_word_cursor, create_entities_url, search_url, + audio_hashes, markup_hashes, entity_types, client_id, True, locale_id) log.debug(audio_hashes) change_dict_status(session, converting_status_url, 'Converting 45%') @@ -260,8 +354,8 @@ def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, and dictionary.is_a_regular_form=0;""") entity_types = ['Paradigm sound', "Paradigm Praat markup"] - upload_audio_with_markup(session, ids_mapping, paradigm_sound_and_markup_cursor, create_entities_url, audio_hashes, - entity_types, client_id, False, locale_id) + upload_audio_with_markup(session, ids_mapping, paradigm_sound_and_markup_cursor, create_entities_url, search_url, + audio_hashes, markup_hashes, entity_types, client_id, False, locale_id) log.debug(audio_hashes) change_dict_status(session, converting_status_url, 'Converting 60%') @@ -294,8 +388,8 @@ def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, and dict_blobs_description.type=1 and dictionary.is_a_regular_form=0;""") entity_types = ['Paradigm sound'] - upload_audio_simple(session, ids_mapping, simple_paradigm_sound_cursor, create_entities_url, audio_hashes, entity_types, - client_id, False, locale_id) + upload_audio_simple(session, ids_mapping, simple_paradigm_sound_cursor, create_entities_url, audio_hashes, + entity_types, client_id, False, locale_id) change_dict_status(session, converting_status_url, 'Converting 80%') @@ -316,15 +410,36 @@ def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, "connections": [{"client_id": client_id, "object_id": object_id}]} status = session.post(connect_url, json=item) log.debug(status.text) + suggestions_url = server_url + 'merge/suggestions' + + suggestions_params = {'threshold': 1.0, + 'levenstein': 0, + 'client_id': perspective['client_id'], + 'object_id': perspective['object_id']} + status = session.post(suggestions_url, json=suggestions_params) + for entry in json.loads(status.text): + if entry['confidence'] >= 1.0: + first_entry = entry['suggestion'][0] + second_entry = entry['suggestion'][1] + lex_move_url = server_url + 'lexical_entry/%d/%d/move' % (second_entry['lexical_entry_client_id'], + second_entry['lexical_entry_object_id']) + move_params = {'client_id': first_entry['lexical_entry_client_id'], + 'object_id': first_entry['lexical_entry_object_id'], + 'real_delete': True} + status = session.patch(lex_move_url, json=move_params) + + else: + break change_dict_status(session, converting_status_url, 'Converted 100%') change_dict_status(session, converting_status_url, 'Published') change_dict_status(session, converting_perspective_status_url, 'Published') - return dictionary + def convert_one(filename, login, password_hash, language_client_id, language_object_id, + dictionary_client_id, dictionary_object_id, perspective_client_id, perspective_object_id, server_url="http://localhost:6543/"): log = logging.getLogger(__name__) log.debug("Starting convert_one") @@ -344,7 +459,8 @@ def convert_one(filename, login, password_hash, language_client_id, language_obj sqconn = sqlite3.connect(filename) log.debug("Connected to sqlite3 database") try: - status = convert_db_new(sqconn, session, language_client_id, language_object_id, server_url) + status = convert_db_new(sqconn, session, language_client_id, language_object_id, server_url, + dictionary_client_id, dictionary_object_id, perspective_client_id, perspective_object_id) except Exception as e: log.error("Converting failed") log.error(e.__traceback__) diff --git a/lingvodoc/scripts/lingvodoc_converter_new.py b/lingvodoc/scripts/lingvodoc_converter_old.py similarity index 60% rename from lingvodoc/scripts/lingvodoc_converter_new.py rename to lingvodoc/scripts/lingvodoc_converter_old.py index e3d3a7f33..27e10156a 100644 --- a/lingvodoc/scripts/lingvodoc_converter_new.py +++ b/lingvodoc/scripts/lingvodoc_converter_old.py @@ -38,39 +38,16 @@ def upload_audio(upload_url, audio_sequence, markup_sequence, session): log.debug(status.text) -def upload_markup(upload_url, search_url, markup_sequence, session): - log = logging.getLogger(__name__) - for entry in markup_sequence: - audio_hash = entry[0] - markup_element = entry[1] - entity_metadata_search = search_url + '?hash=%s' % audio_hash # add filters by perspective. Maybe where search_url is created - status = session.get(entity_metadata_search) - ents = json.loads(status.text) - if 'error' not in ents: - if type(ents) == list and len(ents) >= 1: - existing_entity = ents[0] - parent_client_id = existing_entity['client_id'] - parent_object_id = existing_entity['object_id'] - markup_element["parent_client_id"] = parent_client_id - markup_element["parent_object_id"] = parent_object_id - new_markup_sequence = [o[1] for o in markup_sequence if o[1].get["parent_client_id"]] - result = [o for o in markup_sequence if o[1].get["parent_client_id"] is None] - status = session.post(upload_url, json=new_markup_sequence) - log.debug(status.text) - return result - - -def upload_audio_simple(session, ids_mapping, sound_and_markup_cursor, upload_url, audio_hashes, entity_types, - client_id, is_a_regular_form, locale_id=1): +def upload_audio_simple(session, ids_mapping, sound_and_markup_cursor, upload_url, audio_hashes, entity_types, client_id, is_a_regular_form, + locale_id=1): audio_sequence = [] for cursor in sound_and_markup_cursor: blob_id = cursor[0] audio = cursor[1] filename = cursor[2] word_id = cursor[3] - audio_hash = hashlib.sha224(audio).hexdigest() - if audio_hash not in audio_hashes: - audio_hashes.add(audio_hash) + + if hashlib.sha224(audio).hexdigest() not in audio_hashes: audio_element = {"locale_id": locale_id, "level": "leveloneentity", @@ -81,11 +58,7 @@ def upload_audio_simple(session, ids_mapping, sound_and_markup_cursor, upload_ur "parent_object_id": ids_mapping[int(word_id)][1], "content": base64.urlsafe_b64encode(audio).decode()} if not is_a_regular_form: - audio_element['additional_metadata'] = json.dumps({"hash": audio_hash, - "client_id": client_id, - "row_id": cursor[4]}) - else: - audio_element['additional_metadata'] = json.dumps({"hash": audio_hash }) + audio_element['additional_metadata'] = '{"client_id": %s, "row_id": %s}' % (client_id, cursor[4]) audio_sequence.append(audio_element) if len(audio_sequence) > 50: upload_audio(upload_url, audio_sequence, None, session) @@ -95,11 +68,10 @@ def upload_audio_simple(session, ids_mapping, sound_and_markup_cursor, upload_ur audio_sequence = [] -def upload_audio_with_markup(session, ids_mapping, sound_and_markup_cursor, upload_url, search_url, audio_hashes, markup_hashes, - entity_types, client_id, is_a_regular_form, locale_id=1): +def upload_audio_with_markup(session, ids_mapping, sound_and_markup_cursor, upload_url, audio_hashes, entity_types, client_id, is_a_regular_form, + locale_id=1): audio_sequence = [] markup_sequence = [] - markup__without_audio_sequence = [] for cursor in sound_and_markup_cursor: blob_id = cursor[0] audio = cursor[1] @@ -108,109 +80,72 @@ def upload_audio_with_markup(session, ids_mapping, sound_and_markup_cursor, uplo word_id = cursor[4] if not audio or not markup: continue - audio_hash = hashlib.sha224(audio).hexdigest() - markup_hash = hashlib.sha224(markup).hexdigest() - if audio_hash not in audio_hashes: - audio_hashes.add(audio_hash) - audio_element = {"locale_id": locale_id, - "level": "leveloneentity", - "data_type": "sound", - "filename": common_name + ".wav", - "entity_type": entity_types[0], - "parent_client_id": ids_mapping[int(word_id)][0], - "parent_object_id": ids_mapping[int(word_id)][1], - "content": base64.urlsafe_b64encode(audio).decode()} - if not is_a_regular_form: - audio_element['additional_metadata'] = json.dumps({"hash": audio_hash, - "client_id": client_id, - "row_id": cursor[5]}) - else: - audio_element['additional_metadata'] = json.dumps({"hash": audio_hash }) - audio_sequence.append(audio_element) - - - markup_hashes.add(markup_hash) - markup_element = { - "locale_id": locale_id, - "level": "leveltwoentity", - "data_type": "markup", - "filename": common_name + ".TextGrid", - "entity_type": entity_types[1], - # need to set after push "parent_client_id": ids_mapping[int(word_id)][0], - # need to set after push "parent_object_id": ids_mapping[int(word_id)][1], - "content": base64.urlsafe_b64encode(markup).decode(), - "additional_metadata": json.dumps({"hash": markup_hash})} - markup_sequence.append(markup_element) - else: - if markup_hash not in markup_hashes: - - markup_hashes.add(markup_hash) - markup_element = { - "locale_id": locale_id, - "level": "leveltwoentity", - "data_type": "markup", - "filename": common_name + ".TextGrid", - "entity_type": entity_types[1], - "content": base64.urlsafe_b64encode(markup).decode(), - "additional_metadata": json.dumps({"hash": markup_hash})} - markup__without_audio_sequence.append((audio_hash, markup_element)) - if len(markup__without_audio_sequence) > 50: - markup__without_audio_sequence = upload_markup(upload_url, search_url, - markup__without_audio_sequence, session) + audio_hashes.add(hashlib.sha224(audio).hexdigest()) + + audio_element = {"locale_id": locale_id, + "level": "leveloneentity", + "data_type": "sound", + "filename": common_name + ".wav", + "entity_type": entity_types[0], + "parent_client_id": ids_mapping[int(word_id)][0], + "parent_object_id": ids_mapping[int(word_id)][1], + "content": base64.urlsafe_b64encode(audio).decode()} + if not is_a_regular_form: + audio_element['additional_metadata'] = '{"client_id": %s, "row_id": %s}' % (client_id, cursor[5]) + audio_sequence.append(audio_element) + + markup_element = { + "locale_id": locale_id, + "level": "leveltwoentity", + "data_type": "markup", + "filename": common_name + ".TextGrid", + "entity_type": entity_types[1], + # need to set after push "parent_client_id": ids_mapping[int(word_id)][0], + # need to set after push "parent_object_id": ids_mapping[int(word_id)][1], + "content": base64.urlsafe_b64encode(markup).decode()} + if not is_a_regular_form: + audio_element['additional_metadata'] = '{"client_id": %s, "row_id": %s}' % (client_id, cursor[5]) + markup_sequence.append(markup_element) if len(audio_sequence) > 50: upload_audio(upload_url, audio_sequence, markup_sequence, session) audio_sequence = [] markup_sequence = [] - if len(markup__without_audio_sequence) > 50: - markup__without_audio_sequence = upload_markup(upload_url, search_url, - markup__without_audio_sequence, session) if len(audio_sequence) != 0: upload_audio(upload_url, audio_sequence, markup_sequence, session) audio_sequence = [] markup_sequence = [] - if len(markup__without_audio_sequence) != 0: - upload_markup(upload_url, search_url, markup__without_audio_sequence, session) - markup__without_audio_sequence = [] - def change_dict_status(session, converting_status_url, status): session.put(converting_status_url, json={'status': status}) -def convert_db_new(sqconn, session, language_client_id, language_object_id, server_url, - dictionary_client_id, dictionary_object_id, perspective_client_id, perspective_object_id, locale_id=1): +def convert_db_new(sqconn, session, language_client_id, language_object_id, server_url, locale_id=1): log = logging.getLogger(__name__) dict_attributes = get_dict_attributes(sqconn) - if not dictionary_client_id or not dictionary_object_id: - create_dictionary_request = {"parent_client_id": language_client_id, - "parent_object_id": language_object_id, - "translation": dict_attributes['dictionary_name'], - "translation_string": dict_attributes['dictionary_name']} - status = session.post(server_url + 'dictionary', json=create_dictionary_request) - dictionary = json.loads(status.text) - else: - dictionary = {'client_id': dictionary_client_id, 'object_id': dictionary_object_id} + create_dictionary_request = {"parent_client_id": language_client_id, + "parent_object_id": language_object_id, + "translation": dict_attributes['dictionary_name'], + "translation_string": dict_attributes['dictionary_name']} + status = session.post(server_url + 'dictionary', json=create_dictionary_request) + dictionary = json.loads(status.text) client_id = dictionary['client_id'] converting_status_url = server_url + 'dictionary/%s/%s/state' % (dictionary['client_id'], dictionary['object_id']) change_dict_status(session, converting_status_url, 'Converting 5%') + perspective_create_url = server_url + 'dictionary/%s/%s/perspective' % ( dictionary['client_id'], dictionary['object_id']) + create_perspective_request = {"translation": "Этимологический словарь из Lingvodoc 0.98", + "translation_string": "Lingvodoc 0.98 etymology dictionary", + "import_source": "Lingvodoc-0.98", + "import_hash": dict_attributes['dialeqt_id']} - if not perspective_client_id or not perspective_object_id: - create_perspective_request = {"translation": "Этимологический словарь из Lingvodoc 0.98", - "translation_string": "Lingvodoc 0.98 etymology dictionary", - "import_source": "Lingvodoc-0.98", - "import_hash": dict_attributes['dialeqt_id']} - - status = session.post(perspective_create_url, json=create_perspective_request) - perspective = json.loads(status.text) - else: - perspective = {'client_id': perspective_client_id, 'object_id': perspective_object_id} + status = session.post(perspective_create_url, json=create_perspective_request) + perspective = json.loads(status.text) converting_perspective_status_url = server_url + 'dictionary/%s/%s/perspective/%s/%s/state' % \ (dictionary['client_id'], dictionary['object_id'], @@ -218,8 +153,7 @@ def convert_db_new(sqconn, session, language_client_id, language_object_id, serv change_dict_status(session, converting_perspective_status_url, 'Converting') create_perspective_fields_request = session.get(server_url + 'dictionary/1/1/perspective/1/1/fields') - perspective_fields_create_url = perspective_create_url + '/%s/%s/fields' % (perspective['client_id'], - perspective['object_id']) + perspective_fields_create_url = perspective_create_url + '/%s/%s/fields' % (perspective['client_id'], perspective['object_id']) status = session.post(perspective_fields_create_url, json=create_perspective_fields_request.text) get_all_ids = sqconn.cursor() @@ -265,7 +199,7 @@ def create_entity_list(mapping, cursor, level, data_type, entity_type, is_a_regu "parent_object_id": parent_object_id, "content": content} if not is_a_regular_form: - element['additional_metadata'] = json.dumps({"client_id": client_id, "row_id": ld_cursor[2]}) + element['additional_metadata'] = '{"client_id": %s, "row_id": %s}' % (client_id, ld_cursor[2]) push_list.append(element) return push_list @@ -305,37 +239,9 @@ def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, and dictionary.is_a_regular_form=1;""") audio_hashes = set() - markup_hashes = set() - - - perspective_search = server_url + 'dictionary/%s/%s/perspective/%s/%s/all' % (dictionary['client_id'], - dictionary['object_id'], - perspective['client_id'], - perspective['object_id']) - search_url = server_url + 'meta_search' - status = session.get(perspective_search) - lexes = json.loads(status.text)['lexical_entries'] - sound_types = ['Sound', 'Paradigm sound'] - markup_types = ['Praat markup', "Paradigm Praat markup"] - for lex in lexes: - for entry in lex['contains']: - meta = entry.get('additional_metadata') - if meta: - hsh = meta.get('hash') - if hsh: - if entry['entity_type'] in sound_types: - audio_hashes.add(hsh) - if entry.get('contains'): - for ent in entry['contains']: - meta = entry.get('additional_metadata') - if meta: - hsh = meta.get('hash') - if hsh: - if ent['entity_type'] in markup_types: - markup_hashes.add(hsh) entity_types = ['Sound', 'Praat markup'] - upload_audio_with_markup(session, ids_mapping, sound_and_markup_word_cursor, create_entities_url, search_url, - audio_hashes, markup_hashes, entity_types, client_id, True, locale_id) + upload_audio_with_markup(session, ids_mapping, sound_and_markup_word_cursor, create_entities_url, audio_hashes, + entity_types, client_id, True, locale_id) log.debug(audio_hashes) change_dict_status(session, converting_status_url, 'Converting 45%') @@ -354,8 +260,8 @@ def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, and dictionary.is_a_regular_form=0;""") entity_types = ['Paradigm sound', "Paradigm Praat markup"] - upload_audio_with_markup(session, ids_mapping, paradigm_sound_and_markup_cursor, create_entities_url, search_url, - audio_hashes, markup_hashes, entity_types, client_id, False, locale_id) + upload_audio_with_markup(session, ids_mapping, paradigm_sound_and_markup_cursor, create_entities_url, audio_hashes, + entity_types, client_id, False, locale_id) log.debug(audio_hashes) change_dict_status(session, converting_status_url, 'Converting 60%') @@ -388,8 +294,8 @@ def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, and dict_blobs_description.type=1 and dictionary.is_a_regular_form=0;""") entity_types = ['Paradigm sound'] - upload_audio_simple(session, ids_mapping, simple_paradigm_sound_cursor, create_entities_url, audio_hashes, - entity_types, client_id, False, locale_id) + upload_audio_simple(session, ids_mapping, simple_paradigm_sound_cursor, create_entities_url, audio_hashes, entity_types, + client_id, False, locale_id) change_dict_status(session, converting_status_url, 'Converting 80%') @@ -410,36 +316,15 @@ def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, "connections": [{"client_id": client_id, "object_id": object_id}]} status = session.post(connect_url, json=item) log.debug(status.text) - suggestions_url = server_url + 'merge/suggestions' - - suggestions_params = {'threshold': 1.0, - 'levenstein': 0, - 'client_id': perspective['client_id'], - 'object_id': perspective['object_id']} - status = session.post(suggestions_url, json=suggestions_params) - for entry in json.loads(status.text): - if entry['confidence'] >= 1.0: - first_entry = entry['suggestion'][0] - second_entry = entry['suggestion'][1] - lex_move_url = server_url + 'lexical_entry/%d/%d/move' % (second_entry['lexical_entry_client_id'], - second_entry['lexical_entry_object_id']) - move_params = {'client_id': first_entry['lexical_entry_client_id'], - 'object_id': first_entry['lexical_entry_object_id'], - 'real_delete': True} - status = session.patch(lex_move_url, json=move_params) - - else: - break change_dict_status(session, converting_status_url, 'Converted 100%') change_dict_status(session, converting_status_url, 'Published') change_dict_status(session, converting_perspective_status_url, 'Published') - return dictionary + return dictionary def convert_one(filename, login, password_hash, language_client_id, language_object_id, - dictionary_client_id, dictionary_object_id, perspective_client_id, perspective_object_id, server_url="http://localhost:6543/"): log = logging.getLogger(__name__) log.debug("Starting convert_one") @@ -459,8 +344,7 @@ def convert_one(filename, login, password_hash, language_client_id, language_obj sqconn = sqlite3.connect(filename) log.debug("Connected to sqlite3 database") try: - status = convert_db_new(sqconn, session, language_client_id, language_object_id, server_url, - dictionary_client_id, dictionary_object_id, perspective_client_id, perspective_object_id) + status = convert_db_new(sqconn, session, language_client_id, language_object_id, server_url) except Exception as e: log.error("Converting failed") log.error(e.__traceback__) diff --git a/lingvodoc/views.py b/lingvodoc/views.py index daa4d0428..ff895b900 100644 --- a/lingvodoc/views.py +++ b/lingvodoc/views.py @@ -4,7 +4,7 @@ from sqlalchemy.exc import DBAPIError -from .scripts.lingvodoc_converter_new import convert_one, get_dict_attributes +from .scripts.lingvodoc_converter import convert_one, get_dict_attributes from .models import ( DBSession, @@ -222,8 +222,8 @@ def basic_search(request): #TODO: make it normal, it's just a test -@view_config(route_name='convert_dictionary', renderer='json', request_method='POST') -def convert_dictionary(request): +@view_config(route_name='convert_dictionary_old', renderer='json', request_method='POST') +def convert_dictionary_old(request): req = request.json_body client_id = req['blob_client_id'] @@ -291,8 +291,8 @@ def convert_dictionary_check(request): #TODO: make it normal, it's just a test -@view_config(route_name='convert_dictionary_new', renderer='json', request_method='POST') -def convert_dictionary_new(request): +@view_config(route_name='convert_dictionary', renderer='json', request_method='POST') +def convert_dictionary(request): req = request.json_body client_id = req['blob_client_id'] @@ -4181,15 +4181,16 @@ def merge_suggestions(request): levenstein = req['levenstein'] or 1 client_id = req['client_id'] object_id = req['object_id'] - lexes = list(DBSession.query(LexicalEntry).filter_by(parent_client_id = client_id, parent_object_id = object_id).all()) - lexes_1 = [] - lexes_2 = [] + lexes = list(DBSession.query(LexicalEntry).filter_by(parent_client_id=client_id, + parent_object_id=object_id, + marked_for_deletion=False).all()) if not lexes: - return json.dumps({}) + return json.dumps([]) # first_persp = json.loads(lexes[0].additional_metadata)['came_from'] lexes_1 = [o.track(False) for o in lexes] remove_deleted(lexes_1) lexes_2 = list(lexes_1) + def parse_response(elem): words = filter(lambda x: x['entity_type'] == entity_type_primary and not x['marked_for_deletion'], elem['contains']) words = map(lambda x: x['content'], words) @@ -4197,6 +4198,7 @@ def parse_response(elem): trans = map(lambda x: x['content'], trans) tuples_res = [(i_word, i_trans, (elem['client_id'], elem['object_id'])) for i_word in words for i_trans in trans] return tuples_res + tuples_1 = [parse_response(i) for i in lexes_1] tuples_1 = [item for sublist in tuples_1 for item in sublist] tuples_2 = [parse_response(i) for i in lexes_2] From e7c1c2601358a7209a6620d85a5e26af92116e23 Mon Sep 17 00:00:00 2001 From: "A. Tapekhin" Date: Fri, 13 Nov 2015 13:58:02 +0300 Subject: [PATCH 06/73] added additional metadata to dictionary and perspective --- ...dditional_metadata_on_perspectives_and_.py | 28 +++++++++++++++++++ lingvodoc/models.py | 3 ++ 2 files changed, 31 insertions(+) create mode 100644 alembic/versions/34c4a3c687b_additional_metadata_on_perspectives_and_.py diff --git a/alembic/versions/34c4a3c687b_additional_metadata_on_perspectives_and_.py b/alembic/versions/34c4a3c687b_additional_metadata_on_perspectives_and_.py new file mode 100644 index 000000000..532a53d34 --- /dev/null +++ b/alembic/versions/34c4a3c687b_additional_metadata_on_perspectives_and_.py @@ -0,0 +1,28 @@ +"""additional metadata on perspectives and dictionaries + +Revision ID: 34c4a3c687b +Revises: 28894fa7718 +Create Date: 2015-11-13 13:53:15.258799 + +""" + +# revision identifiers, used by Alembic. +revision = '34c4a3c687b' +down_revision = '28894fa7718' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column('dictionaryperspective', sa.Column('additional_metadata', sa.UnicodeText(), nullable=True)) + op.add_column('dictionary', sa.Column('additional_metadata', sa.UnicodeText(), nullable=True)) + pass + + +def downgrade(): + op.drop_column('dictionary', 'additional_metadata') + op.drop_column('dictionaryperspective', 'additional_metadata') + pass diff --git a/lingvodoc/models.py b/lingvodoc/models.py index ee7188f92..0e38e43aa 100755 --- a/lingvodoc/models.py +++ b/lingvodoc/models.py @@ -384,6 +384,7 @@ class Dictionary(Base, TableNameMixin, CompositeIdMixin, RelationshipMixin, Tran authors = Column(UnicodeText) translation_string = Column(UnicodeText) marked_for_deletion = Column(Boolean, default=False) + additional_metadata = Column(UnicodeText) # about = Column(UnicodeText) @@ -407,6 +408,7 @@ class DictionaryPerspective(Base, TableNameMixin, CompositeIdMixin, Relationship is_template = Column(Boolean, default=False) import_source = Column(UnicodeText) import_hash = Column(UnicodeText) + additional_metadata = Column(UnicodeText) # about = Column(UnicodeText) @@ -799,6 +801,7 @@ def acl_by_groups(object_id, client_id, subject): base_group = group.parent if group.subject_override: group_name = base_group.action + ":" + base_group.subject + ":" + str(group.subject_override) + group_name = base_group.action + ":" + base_group.subject + ":" + str(group.subject_override) else: group_name = base_group.action + ":" + base_group.subject \ + ":" + str(group.subject_client_id) + ":" + str(group.subject_object_id) From d74b609f0af7382505772acf30f4f1e998af0cf7 Mon Sep 17 00:00:00 2001 From: "A. Tapekhin" Date: Fri, 13 Nov 2015 15:54:01 +0300 Subject: [PATCH 07/73] latitude and longitude in perspective additional metadata --- lingvodoc/views.py | 80 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 18 deletions(-) diff --git a/lingvodoc/views.py b/lingvodoc/views.py index 543249551..8faaed909 100755 --- a/lingvodoc/views.py +++ b/lingvodoc/views.py @@ -400,6 +400,7 @@ def view_dictionary(request): response['translation_string'] = translation_string['translation_string'] response['translation'] = translation_string['translation'] response['status'] = dictionary.state + response['additional_metadata'] = dictionary.additional_metadata request.response.status = HTTPOk.code return response request.response.status = HTTPNotFound.code @@ -425,9 +426,16 @@ def edit_dictionary(request): dictionary.parent_object_id = req['parent_object_id'] if 'translation' in req: dictionary.set_translation(request) + additional_metadata = req.get('additional_metadata') + if additional_metadata: + # additional_metadata = json.dumps(additional_metadata) + + old_meta = json.loads(dictionary.additional_metadata) + old_meta.update(additional_metadata) + new_meta = json.dumps(old_meta) + dictionary.additional_metadata = new_meta request.response.status = HTTPOk.code return response - request.response.status = HTTPNotFound.code return {'error': str("No such dictionary in the system")} except KeyError as e: @@ -469,11 +477,15 @@ def create_dictionary(request): if not user: raise CommonException("This client id is orphaned. Try to logout and then login once more.") parent = DBSession.query(Language).filter_by(client_id=parent_client_id, object_id=parent_object_id).first() + additional_metadata = req.get('additional_metadata') + if additional_metadata: + additional_metadata = json.dumps(additional_metadata) dictionary = Dictionary(object_id=DBSession.query(Dictionary).filter_by(client_id=client.id).count() + 1, client_id=variables['auth'], state='WiP', - parent=parent) + parent=parent, + additional_metadata=additional_metadata) dictionary.set_translation(request) DBSession.add(dictionary) DBSession.flush() @@ -622,6 +634,12 @@ def view_perspective(request): response['status'] = perspective.state response['marked_for_deletion'] = perspective.marked_for_deletion response['is_template'] = perspective.is_template + response['additional_metadata'] = perspective.additional_metadata + meta = perspective.additional_metadata + if 'latitude' in meta: + response['latitude'] = meta['latitude'] + if 'longitude' in meta: + response['longitude'] = meta['longitude'] request.response.status = HTTPOk.code return response request.response.status = HTTPNotFound.code @@ -718,12 +736,28 @@ def edit_perspective(request): request.response.status = HTTPNotFound.code return {'error': str("No such pair of dictionary/perspective in the system")} req = request.json_body + + old_meta = json.loads(perspective.additional_metadata) + additional_metadata = req.get('additional_metadata') + if additional_metadata: + # additional_metadata = json.dumps(additional_metadata) + old_meta.update(additional_metadata) + latitude = req.get('latitude') + longitude = req.get('longitude') + if latitude: + old_meta.update({'latitude':latitude}) + if longitude: + old_meta.update({'longitude':longitude}) if 'translation' in req: perspective.set_translation(request) if 'parent_client_id' in req: perspective.parent_client_id = req['parent_client_id'] if 'parent_object_id' in req: perspective.parent_object_id = req['parent_object_id'] + + new_meta = json.dumps(old_meta) + perspective.additional_metadata = new_meta + is_template = req.get('is_template') if is_template is not None: perspective.is_template = is_template @@ -812,12 +846,25 @@ def create_perspective(request): if not parent: request.response.status = HTTPNotFound.code return {'error': str("No such dictionary in the system")} + coord = {} + latitude = req.get('latitude') + longitude = req.get('longitude') + if latitude: + coord['latitude']=latitude + if longitude: + coord['longitude']=longitude + additional_metadata = req.get('additional_metadata') + if additional_metadata: + additional_metadata.update(coord) + additional_metadata = json.dumps(additional_metadata) + perspective = DictionaryPerspective(object_id=DBSession.query(DictionaryPerspective).filter_by(client_id=client.id).count() + 1, client_id=variables['auth'], state='WiP', parent=parent, import_source=req.get('import_source'), - import_hash=req.get('import_hash')) + import_hash=req.get('import_hash'), + additional_metadata=additional_metadata) if is_template is not None: perspective.is_template = is_template perspective.set_translation(request) @@ -2108,7 +2155,7 @@ def create_l1_entity(request): if not parent: request.response.status = HTTPNotFound.code return {'error': str("No such lexical entry in the system")} - additional_metadata=req.get('additional_metadata') + additional_metadata = req.get('additional_metadata') if additional_metadata: additional_metadata = json.dumps(additional_metadata) entity = LevelOneEntity(client_id=client.id, object_id=DBSession.query(LevelOneEntity).filter_by(client_id=client.id).count() + 1, entity_type=req['entity_type'], @@ -2166,7 +2213,7 @@ def create_entities_bulk(request): object_id=DBSession.query(LevelOneEntity).filter_by(client_id=client.id).count() + 1, entity_type=item['entity_type'], locale_id=item['locale_id'], - additional_metadata=item.get('additional_metadata'), + additional_metadata=json.dumps(item.get('additional_metadata')), parent=parent) elif item['level'] == 'groupingentity': parent = DBSession.query(LexicalEntry).filter_by(client_id=item['parent_client_id'], object_id=item['parent_object_id']).first() @@ -2174,7 +2221,7 @@ def create_entities_bulk(request): object_id=DBSession.query(GroupingEntity).filter_by(client_id=client.id).count() + 1, entity_type=item['entity_type'], locale_id=item['locale_id'], - additional_metadata=item.get('additional_metadata'), + additional_metadata=json.dumps(item.get('additional_metadata')), parent=parent) elif item['level'] == 'leveltwoentity': parent = DBSession.query(LevelOneEntity).filter_by(client_id=item['parent_client_id'], object_id=item['parent_object_id']).first() @@ -2182,7 +2229,7 @@ def create_entities_bulk(request): object_id=DBSession.query(LevelTwoEntity).filter_by(client_id=client.id).count() + 1, entity_type=item['entity_type'], locale_id=item['locale_id'], - additional_metadata=item.get('additional_metadata'), + additional_metadata=json.dumps(item.get('additional_metadata')), parent=parent) DBSession.add(entity) DBSession.flush() @@ -2308,7 +2355,7 @@ def create_l2_entity(request): request.response.status = HTTPNotFound.code return {'error': str("No such level one entity in the system")} entity = LevelTwoEntity(client_id=client.id, object_id=DBSession.query(LevelTwoEntity).filter_by(client_id=client.id).count() + 1, entity_type=req['entity_type'], - locale_id=req['locale_id'], additional_metadata=req.get('additional_metadata'), + locale_id=req['locale_id'], additional_metadata=json.dumps(req.get('additional_metadata')), parent=parent) DBSession.add(entity) DBSession.flush() @@ -3860,16 +3907,13 @@ def create_organization(request): @view_config(route_name='testing', renderer='json') def testing(request): - lexes = list(DBSession.query(LexicalEntry).filter_by(parent_client_id = 2, parent_object_id = 1).all()) - lexes_1 = [] - lexes_2 = [] - if not lexes: - return json.dumps({}) - # first_persp = json.loads(lexes[0].additional_metadata)['came_from'] - lexes_1 = [o.track(False) for o in lexes] - remove_deleted(lexes_1) - lexes_2 = list(lexes_1) - return {'list_1':lexes_1, 'list_2':lexes_2} + d1 = {1: 1, 2: 2} + d2 = {2: 'ha!', 3: 3} + d12 = dict(d1) + d12.update(d2) + d21 = dict(d2) + d21.update(d1) + return {'d1':d1,'d2':d2,'d12':d12,'d21':d21} @view_config(route_name='login', renderer='templates/login.pt', request_method='GET') From 2751ada584940f5d356468d944804bc931af95db Mon Sep 17 00:00:00 2001 From: "A. Tapekhin" Date: Fri, 13 Nov 2015 17:28:28 +0300 Subject: [PATCH 08/73] basic search fix --- lingvodoc/__init__.py | 2 ++ lingvodoc/views.py | 23 +++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lingvodoc/__init__.py b/lingvodoc/__init__.py index f2e8797e8..0da5b0978 100755 --- a/lingvodoc/__init__.py +++ b/lingvodoc/__init__.py @@ -302,6 +302,8 @@ def configure_routes(config): # API #GET # like + # perspective_client_id + # perspective_object_id config.add_route(name='basic_search', pattern='/basic_search') # API #GET diff --git a/lingvodoc/views.py b/lingvodoc/views.py index 8faaed909..13f9ab211 100755 --- a/lingvodoc/views.py +++ b/lingvodoc/views.py @@ -138,6 +138,8 @@ def basic_search(request): can_add_tags = request.params.get('can_add_tags') print(can_add_tags) searchstring = request.params.get('leveloneentity') + perspective_client_id = request.params.get('perspective_client_id') + perspective_object_id = request.params.get('perspective_object_id') if searchstring: if len(searchstring) >= 2: searchstring = request.params.get('leveloneentity') @@ -147,11 +149,19 @@ def basic_search(request): .filter(Client.id == request.authenticated_userid).first() if group: results_cursor = DBSession.query(LevelOneEntity).filter(LevelOneEntity.content.like('%'+searchstring+'%')) + if perspective_client_id and perspective_object_id: + results_cursor = results_cursor.join(LexicalEntry)\ + .join(DictionaryPerspective)\ + .filter(DictionaryPerspective.client_id == perspective_client_id, + DictionaryPerspective.object_id == perspective_object_id) else: results_cursor = DBSession.query(LevelOneEntity)\ .join(LexicalEntry)\ - .join(DictionaryPerspective)\ - .join(Group, and_(DictionaryPerspective.client_id == Group.subject_client_id, DictionaryPerspective.object_id == Group.subject_object_id ))\ + .join(DictionaryPerspective) + if perspective_client_id and perspective_object_id: + results_cursor = results_cursor.filter(DictionaryPerspective.client_id == perspective_client_id, + DictionaryPerspective.object_id == perspective_object_id) + results_cursor = results_cursor.join(Group, and_(DictionaryPerspective.client_id == Group.subject_client_id, DictionaryPerspective.object_id == Group.subject_object_id ))\ .join(BaseGroup)\ .join(User, Group.users)\ .join(Client)\ @@ -636,10 +646,11 @@ def view_perspective(request): response['is_template'] = perspective.is_template response['additional_metadata'] = perspective.additional_metadata meta = perspective.additional_metadata - if 'latitude' in meta: - response['latitude'] = meta['latitude'] - if 'longitude' in meta: - response['longitude'] = meta['longitude'] + if meta: + if 'latitude' in meta: + response['latitude'] = meta['latitude'] + if 'longitude' in meta: + response['longitude'] = meta['longitude'] request.response.status = HTTPOk.code return response request.response.status = HTTPNotFound.code From fb422abee67577e7a5447d8fa88bda5c45e96a2f Mon Sep 17 00:00:00 2001 From: "A. Tapekhin" Date: Fri, 13 Nov 2015 17:46:18 +0300 Subject: [PATCH 09/73] geo coordinates fixes --- lingvodoc/__init__.py | 2 +- lingvodoc/views.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lingvodoc/__init__.py b/lingvodoc/__init__.py index 0da5b0978..6127c324b 100755 --- a/lingvodoc/__init__.py +++ b/lingvodoc/__init__.py @@ -302,7 +302,7 @@ def configure_routes(config): # API #GET # like - # perspective_client_id + # perspective_client_id # perspective_object_id config.add_route(name='basic_search', pattern='/basic_search') diff --git a/lingvodoc/views.py b/lingvodoc/views.py index 13f9ab211..65f6bfe1b 100755 --- a/lingvodoc/views.py +++ b/lingvodoc/views.py @@ -138,8 +138,8 @@ def basic_search(request): can_add_tags = request.params.get('can_add_tags') print(can_add_tags) searchstring = request.params.get('leveloneentity') - perspective_client_id = request.params.get('perspective_client_id') - perspective_object_id = request.params.get('perspective_object_id') + perspective_client_id = request.params.get('perspective_client_id') + perspective_object_id = request.params.get('perspective_object_id') if searchstring: if len(searchstring) >= 2: searchstring = request.params.get('leveloneentity') @@ -645,7 +645,7 @@ def view_perspective(request): response['marked_for_deletion'] = perspective.marked_for_deletion response['is_template'] = perspective.is_template response['additional_metadata'] = perspective.additional_metadata - meta = perspective.additional_metadata + meta = json.loads(perspective.additional_metadata) if meta: if 'latitude' in meta: response['latitude'] = meta['latitude'] @@ -867,7 +867,9 @@ def create_perspective(request): additional_metadata = req.get('additional_metadata') if additional_metadata: additional_metadata.update(coord) - additional_metadata = json.dumps(additional_metadata) + else: + additional_metadata = coord + additional_metadata = json.dumps(additional_metadata) perspective = DictionaryPerspective(object_id=DBSession.query(DictionaryPerspective).filter_by(client_id=client.id).count() + 1, client_id=variables['auth'], From b582f247d644ee8d3b7a10704cf005d212e7e4f1 Mon Sep 17 00:00:00 2001 From: Steve Ipatov Date: Fri, 13 Nov 2015 19:59:39 +0300 Subject: [PATCH 10/73] enhanced import --- lingvodoc/__init__.py | 2 +- lingvodoc/static/js/create-dictionary.js | 1273 ++++++++++++++++++++- lingvodoc/static/js/dashboard.js | 60 +- lingvodoc/static/js/edit-dictionary.js | 60 +- lingvodoc/static/js/home.js | 60 +- lingvodoc/static/js/languages.js | 2 +- lingvodoc/static/js/login.js | 2 +- lingvodoc/static/js/merge-master.js | 60 +- lingvodoc/static/js/organizations.js | 60 +- lingvodoc/static/js/profile.js | 60 +- lingvodoc/static/js/publish-dictionary.js | 60 +- lingvodoc/static/js/user-upload.js | 2 +- lingvodoc/static/js/view-dictionary.js | 60 +- lingvodoc/templates/create_dictionary.pt | 67 +- webui/Gruntfile.js | 1 + webui/src/js/api.js | 63 +- webui/src/js/create_dictionary.js | 272 +++-- webui/src/js/edit_dictionary.js | 1 - webui/src/js/response_handler.js | 2 +- webui/src/templates/create_dictionary.pt | 67 +- 20 files changed, 2107 insertions(+), 127 deletions(-) diff --git a/lingvodoc/__init__.py b/lingvodoc/__init__.py index d32bbf3aa..a0a28ee49 100755 --- a/lingvodoc/__init__.py +++ b/lingvodoc/__init__.py @@ -243,7 +243,7 @@ def configure_routes(config): # API #GET # no params, lists only own blobs config.add_route(name="list_user_blobs", - pattern="/blobs/") + pattern="/blobs") # TODO: LOCALES! # API #GET && DELETE diff --git a/lingvodoc/static/js/create-dictionary.js b/lingvodoc/static/js/create-dictionary.js index bbe9a1024..09215eb64 100644 --- a/lingvodoc/static/js/create-dictionary.js +++ b/lingvodoc/static/js/create-dictionary.js @@ -5377,6 +5377,1060 @@ return jQuery; }); +(function() { + var root = this; + var previousUnderscore = root._; + var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; + var push = ArrayProto.push, slice = ArrayProto.slice, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty; + var nativeIsArray = Array.isArray, nativeKeys = Object.keys, nativeBind = FuncProto.bind, nativeCreate = Object.create; + var Ctor = function() {}; + var _ = function(obj) { + if (obj instanceof _) return obj; + if (!(this instanceof _)) return new _(obj); + this._wrapped = obj; + }; + if (typeof exports !== "undefined") { + if (typeof module !== "undefined" && module.exports) { + exports = module.exports = _; + } + exports._ = _; + } else { + root._ = _; + } + _.VERSION = "1.8.3"; + var optimizeCb = function(func, context, argCount) { + if (context === void 0) return func; + switch (argCount == null ? 3 : argCount) { + case 1: + return function(value) { + return func.call(context, value); + }; + + case 2: + return function(value, other) { + return func.call(context, value, other); + }; + + case 3: + return function(value, index, collection) { + return func.call(context, value, index, collection); + }; + + case 4: + return function(accumulator, value, index, collection) { + return func.call(context, accumulator, value, index, collection); + }; + } + return function() { + return func.apply(context, arguments); + }; + }; + var cb = function(value, context, argCount) { + if (value == null) return _.identity; + if (_.isFunction(value)) return optimizeCb(value, context, argCount); + if (_.isObject(value)) return _.matcher(value); + return _.property(value); + }; + _.iteratee = function(value, context) { + return cb(value, context, Infinity); + }; + var createAssigner = function(keysFunc, undefinedOnly) { + return function(obj) { + var length = arguments.length; + if (length < 2 || obj == null) return obj; + for (var index = 1; index < length; index++) { + var source = arguments[index], keys = keysFunc(source), l = keys.length; + for (var i = 0; i < l; i++) { + var key = keys[i]; + if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key]; + } + } + return obj; + }; + }; + var baseCreate = function(prototype) { + if (!_.isObject(prototype)) return {}; + if (nativeCreate) return nativeCreate(prototype); + Ctor.prototype = prototype; + var result = new Ctor(); + Ctor.prototype = null; + return result; + }; + var property = function(key) { + return function(obj) { + return obj == null ? void 0 : obj[key]; + }; + }; + var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; + var getLength = property("length"); + var isArrayLike = function(collection) { + var length = getLength(collection); + return typeof length == "number" && length >= 0 && length <= MAX_ARRAY_INDEX; + }; + _.each = _.forEach = function(obj, iteratee, context) { + iteratee = optimizeCb(iteratee, context); + var i, length; + if (isArrayLike(obj)) { + for (i = 0, length = obj.length; i < length; i++) { + iteratee(obj[i], i, obj); + } + } else { + var keys = _.keys(obj); + for (i = 0, length = keys.length; i < length; i++) { + iteratee(obj[keys[i]], keys[i], obj); + } + } + return obj; + }; + _.map = _.collect = function(obj, iteratee, context) { + iteratee = cb(iteratee, context); + var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length, results = Array(length); + for (var index = 0; index < length; index++) { + var currentKey = keys ? keys[index] : index; + results[index] = iteratee(obj[currentKey], currentKey, obj); + } + return results; + }; + function createReduce(dir) { + function iterator(obj, iteratee, memo, keys, index, length) { + for (;index >= 0 && index < length; index += dir) { + var currentKey = keys ? keys[index] : index; + memo = iteratee(memo, obj[currentKey], currentKey, obj); + } + return memo; + } + return function(obj, iteratee, memo, context) { + iteratee = optimizeCb(iteratee, context, 4); + var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length, index = dir > 0 ? 0 : length - 1; + if (arguments.length < 3) { + memo = obj[keys ? keys[index] : index]; + index += dir; + } + return iterator(obj, iteratee, memo, keys, index, length); + }; + } + _.reduce = _.foldl = _.inject = createReduce(1); + _.reduceRight = _.foldr = createReduce(-1); + _.find = _.detect = function(obj, predicate, context) { + var key; + if (isArrayLike(obj)) { + key = _.findIndex(obj, predicate, context); + } else { + key = _.findKey(obj, predicate, context); + } + if (key !== void 0 && key !== -1) return obj[key]; + }; + _.filter = _.select = function(obj, predicate, context) { + var results = []; + predicate = cb(predicate, context); + _.each(obj, function(value, index, list) { + if (predicate(value, index, list)) results.push(value); + }); + return results; + }; + _.reject = function(obj, predicate, context) { + return _.filter(obj, _.negate(cb(predicate)), context); + }; + _.every = _.all = function(obj, predicate, context) { + predicate = cb(predicate, context); + var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length; + for (var index = 0; index < length; index++) { + var currentKey = keys ? keys[index] : index; + if (!predicate(obj[currentKey], currentKey, obj)) return false; + } + return true; + }; + _.some = _.any = function(obj, predicate, context) { + predicate = cb(predicate, context); + var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length; + for (var index = 0; index < length; index++) { + var currentKey = keys ? keys[index] : index; + if (predicate(obj[currentKey], currentKey, obj)) return true; + } + return false; + }; + _.contains = _.includes = _.include = function(obj, item, fromIndex, guard) { + if (!isArrayLike(obj)) obj = _.values(obj); + if (typeof fromIndex != "number" || guard) fromIndex = 0; + return _.indexOf(obj, item, fromIndex) >= 0; + }; + _.invoke = function(obj, method) { + var args = slice.call(arguments, 2); + var isFunc = _.isFunction(method); + return _.map(obj, function(value) { + var func = isFunc ? method : value[method]; + return func == null ? func : func.apply(value, args); + }); + }; + _.pluck = function(obj, key) { + return _.map(obj, _.property(key)); + }; + _.where = function(obj, attrs) { + return _.filter(obj, _.matcher(attrs)); + }; + _.findWhere = function(obj, attrs) { + return _.find(obj, _.matcher(attrs)); + }; + _.max = function(obj, iteratee, context) { + var result = -Infinity, lastComputed = -Infinity, value, computed; + if (iteratee == null && obj != null) { + obj = isArrayLike(obj) ? obj : _.values(obj); + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value > result) { + result = value; + } + } + } else { + iteratee = cb(iteratee, context); + _.each(obj, function(value, index, list) { + computed = iteratee(value, index, list); + if (computed > lastComputed || computed === -Infinity && result === -Infinity) { + result = value; + lastComputed = computed; + } + }); + } + return result; + }; + _.min = function(obj, iteratee, context) { + var result = Infinity, lastComputed = Infinity, value, computed; + if (iteratee == null && obj != null) { + obj = isArrayLike(obj) ? obj : _.values(obj); + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value < result) { + result = value; + } + } + } else { + iteratee = cb(iteratee, context); + _.each(obj, function(value, index, list) { + computed = iteratee(value, index, list); + if (computed < lastComputed || computed === Infinity && result === Infinity) { + result = value; + lastComputed = computed; + } + }); + } + return result; + }; + _.shuffle = function(obj) { + var set = isArrayLike(obj) ? obj : _.values(obj); + var length = set.length; + var shuffled = Array(length); + for (var index = 0, rand; index < length; index++) { + rand = _.random(0, index); + if (rand !== index) shuffled[index] = shuffled[rand]; + shuffled[rand] = set[index]; + } + return shuffled; + }; + _.sample = function(obj, n, guard) { + if (n == null || guard) { + if (!isArrayLike(obj)) obj = _.values(obj); + return obj[_.random(obj.length - 1)]; + } + return _.shuffle(obj).slice(0, Math.max(0, n)); + }; + _.sortBy = function(obj, iteratee, context) { + iteratee = cb(iteratee, context); + return _.pluck(_.map(obj, function(value, index, list) { + return { + value: value, + index: index, + criteria: iteratee(value, index, list) + }; + }).sort(function(left, right) { + var a = left.criteria; + var b = right.criteria; + if (a !== b) { + if (a > b || a === void 0) return 1; + if (a < b || b === void 0) return -1; + } + return left.index - right.index; + }), "value"); + }; + var group = function(behavior) { + return function(obj, iteratee, context) { + var result = {}; + iteratee = cb(iteratee, context); + _.each(obj, function(value, index) { + var key = iteratee(value, index, obj); + behavior(result, value, key); + }); + return result; + }; + }; + _.groupBy = group(function(result, value, key) { + if (_.has(result, key)) result[key].push(value); else result[key] = [ value ]; + }); + _.indexBy = group(function(result, value, key) { + result[key] = value; + }); + _.countBy = group(function(result, value, key) { + if (_.has(result, key)) result[key]++; else result[key] = 1; + }); + _.toArray = function(obj) { + if (!obj) return []; + if (_.isArray(obj)) return slice.call(obj); + if (isArrayLike(obj)) return _.map(obj, _.identity); + return _.values(obj); + }; + _.size = function(obj) { + if (obj == null) return 0; + return isArrayLike(obj) ? obj.length : _.keys(obj).length; + }; + _.partition = function(obj, predicate, context) { + predicate = cb(predicate, context); + var pass = [], fail = []; + _.each(obj, function(value, key, obj) { + (predicate(value, key, obj) ? pass : fail).push(value); + }); + return [ pass, fail ]; + }; + _.first = _.head = _.take = function(array, n, guard) { + if (array == null) return void 0; + if (n == null || guard) return array[0]; + return _.initial(array, array.length - n); + }; + _.initial = function(array, n, guard) { + return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); + }; + _.last = function(array, n, guard) { + if (array == null) return void 0; + if (n == null || guard) return array[array.length - 1]; + return _.rest(array, Math.max(0, array.length - n)); + }; + _.rest = _.tail = _.drop = function(array, n, guard) { + return slice.call(array, n == null || guard ? 1 : n); + }; + _.compact = function(array) { + return _.filter(array, _.identity); + }; + var flatten = function(input, shallow, strict, startIndex) { + var output = [], idx = 0; + for (var i = startIndex || 0, length = getLength(input); i < length; i++) { + var value = input[i]; + if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) { + if (!shallow) value = flatten(value, shallow, strict); + var j = 0, len = value.length; + output.length += len; + while (j < len) { + output[idx++] = value[j++]; + } + } else if (!strict) { + output[idx++] = value; + } + } + return output; + }; + _.flatten = function(array, shallow) { + return flatten(array, shallow, false); + }; + _.without = function(array) { + return _.difference(array, slice.call(arguments, 1)); + }; + _.uniq = _.unique = function(array, isSorted, iteratee, context) { + if (!_.isBoolean(isSorted)) { + context = iteratee; + iteratee = isSorted; + isSorted = false; + } + if (iteratee != null) iteratee = cb(iteratee, context); + var result = []; + var seen = []; + for (var i = 0, length = getLength(array); i < length; i++) { + var value = array[i], computed = iteratee ? iteratee(value, i, array) : value; + if (isSorted) { + if (!i || seen !== computed) result.push(value); + seen = computed; + } else if (iteratee) { + if (!_.contains(seen, computed)) { + seen.push(computed); + result.push(value); + } + } else if (!_.contains(result, value)) { + result.push(value); + } + } + return result; + }; + _.union = function() { + return _.uniq(flatten(arguments, true, true)); + }; + _.intersection = function(array) { + var result = []; + var argsLength = arguments.length; + for (var i = 0, length = getLength(array); i < length; i++) { + var item = array[i]; + if (_.contains(result, item)) continue; + for (var j = 1; j < argsLength; j++) { + if (!_.contains(arguments[j], item)) break; + } + if (j === argsLength) result.push(item); + } + return result; + }; + _.difference = function(array) { + var rest = flatten(arguments, true, true, 1); + return _.filter(array, function(value) { + return !_.contains(rest, value); + }); + }; + _.zip = function() { + return _.unzip(arguments); + }; + _.unzip = function(array) { + var length = array && _.max(array, getLength).length || 0; + var result = Array(length); + for (var index = 0; index < length; index++) { + result[index] = _.pluck(array, index); + } + return result; + }; + _.object = function(list, values) { + var result = {}; + for (var i = 0, length = getLength(list); i < length; i++) { + if (values) { + result[list[i]] = values[i]; + } else { + result[list[i][0]] = list[i][1]; + } + } + return result; + }; + function createPredicateIndexFinder(dir) { + return function(array, predicate, context) { + predicate = cb(predicate, context); + var length = getLength(array); + var index = dir > 0 ? 0 : length - 1; + for (;index >= 0 && index < length; index += dir) { + if (predicate(array[index], index, array)) return index; + } + return -1; + }; + } + _.findIndex = createPredicateIndexFinder(1); + _.findLastIndex = createPredicateIndexFinder(-1); + _.sortedIndex = function(array, obj, iteratee, context) { + iteratee = cb(iteratee, context, 1); + var value = iteratee(obj); + var low = 0, high = getLength(array); + while (low < high) { + var mid = Math.floor((low + high) / 2); + if (iteratee(array[mid]) < value) low = mid + 1; else high = mid; + } + return low; + }; + function createIndexFinder(dir, predicateFind, sortedIndex) { + return function(array, item, idx) { + var i = 0, length = getLength(array); + if (typeof idx == "number") { + if (dir > 0) { + i = idx >= 0 ? idx : Math.max(idx + length, i); + } else { + length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; + } + } else if (sortedIndex && idx && length) { + idx = sortedIndex(array, item); + return array[idx] === item ? idx : -1; + } + if (item !== item) { + idx = predicateFind(slice.call(array, i, length), _.isNaN); + return idx >= 0 ? idx + i : -1; + } + for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) { + if (array[idx] === item) return idx; + } + return -1; + }; + } + _.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex); + _.lastIndexOf = createIndexFinder(-1, _.findLastIndex); + _.range = function(start, stop, step) { + if (stop == null) { + stop = start || 0; + start = 0; + } + step = step || 1; + var length = Math.max(Math.ceil((stop - start) / step), 0); + var range = Array(length); + for (var idx = 0; idx < length; idx++, start += step) { + range[idx] = start; + } + return range; + }; + var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) { + if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); + var self = baseCreate(sourceFunc.prototype); + var result = sourceFunc.apply(self, args); + if (_.isObject(result)) return result; + return self; + }; + _.bind = function(func, context) { + if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); + if (!_.isFunction(func)) throw new TypeError("Bind must be called on a function"); + var args = slice.call(arguments, 2); + var bound = function() { + return executeBound(func, bound, context, this, args.concat(slice.call(arguments))); + }; + return bound; + }; + _.partial = function(func) { + var boundArgs = slice.call(arguments, 1); + var bound = function() { + var position = 0, length = boundArgs.length; + var args = Array(length); + for (var i = 0; i < length; i++) { + args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i]; + } + while (position < arguments.length) args.push(arguments[position++]); + return executeBound(func, bound, this, this, args); + }; + return bound; + }; + _.bindAll = function(obj) { + var i, length = arguments.length, key; + if (length <= 1) throw new Error("bindAll must be passed function names"); + for (i = 1; i < length; i++) { + key = arguments[i]; + obj[key] = _.bind(obj[key], obj); + } + return obj; + }; + _.memoize = function(func, hasher) { + var memoize = function(key) { + var cache = memoize.cache; + var address = "" + (hasher ? hasher.apply(this, arguments) : key); + if (!_.has(cache, address)) cache[address] = func.apply(this, arguments); + return cache[address]; + }; + memoize.cache = {}; + return memoize; + }; + _.delay = function(func, wait) { + var args = slice.call(arguments, 2); + return setTimeout(function() { + return func.apply(null, args); + }, wait); + }; + _.defer = _.partial(_.delay, _, 1); + _.throttle = function(func, wait, options) { + var context, args, result; + var timeout = null; + var previous = 0; + if (!options) options = {}; + var later = function() { + previous = options.leading === false ? 0 : _.now(); + timeout = null; + result = func.apply(context, args); + if (!timeout) context = args = null; + }; + return function() { + var now = _.now(); + if (!previous && options.leading === false) previous = now; + var remaining = wait - (now - previous); + context = this; + args = arguments; + if (remaining <= 0 || remaining > wait) { + if (timeout) { + clearTimeout(timeout); + timeout = null; + } + previous = now; + result = func.apply(context, args); + if (!timeout) context = args = null; + } else if (!timeout && options.trailing !== false) { + timeout = setTimeout(later, remaining); + } + return result; + }; + }; + _.debounce = function(func, wait, immediate) { + var timeout, args, context, timestamp, result; + var later = function() { + var last = _.now() - timestamp; + if (last < wait && last >= 0) { + timeout = setTimeout(later, wait - last); + } else { + timeout = null; + if (!immediate) { + result = func.apply(context, args); + if (!timeout) context = args = null; + } + } + }; + return function() { + context = this; + args = arguments; + timestamp = _.now(); + var callNow = immediate && !timeout; + if (!timeout) timeout = setTimeout(later, wait); + if (callNow) { + result = func.apply(context, args); + context = args = null; + } + return result; + }; + }; + _.wrap = function(func, wrapper) { + return _.partial(wrapper, func); + }; + _.negate = function(predicate) { + return function() { + return !predicate.apply(this, arguments); + }; + }; + _.compose = function() { + var args = arguments; + var start = args.length - 1; + return function() { + var i = start; + var result = args[start].apply(this, arguments); + while (i--) result = args[i].call(this, result); + return result; + }; + }; + _.after = function(times, func) { + return function() { + if (--times < 1) { + return func.apply(this, arguments); + } + }; + }; + _.before = function(times, func) { + var memo; + return function() { + if (--times > 0) { + memo = func.apply(this, arguments); + } + if (times <= 1) func = null; + return memo; + }; + }; + _.once = _.partial(_.before, 2); + var hasEnumBug = !{ + toString: null + }.propertyIsEnumerable("toString"); + var nonEnumerableProps = [ "valueOf", "isPrototypeOf", "toString", "propertyIsEnumerable", "hasOwnProperty", "toLocaleString" ]; + function collectNonEnumProps(obj, keys) { + var nonEnumIdx = nonEnumerableProps.length; + var constructor = obj.constructor; + var proto = _.isFunction(constructor) && constructor.prototype || ObjProto; + var prop = "constructor"; + if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop); + while (nonEnumIdx--) { + prop = nonEnumerableProps[nonEnumIdx]; + if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) { + keys.push(prop); + } + } + } + _.keys = function(obj) { + if (!_.isObject(obj)) return []; + if (nativeKeys) return nativeKeys(obj); + var keys = []; + for (var key in obj) if (_.has(obj, key)) keys.push(key); + if (hasEnumBug) collectNonEnumProps(obj, keys); + return keys; + }; + _.allKeys = function(obj) { + if (!_.isObject(obj)) return []; + var keys = []; + for (var key in obj) keys.push(key); + if (hasEnumBug) collectNonEnumProps(obj, keys); + return keys; + }; + _.values = function(obj) { + var keys = _.keys(obj); + var length = keys.length; + var values = Array(length); + for (var i = 0; i < length; i++) { + values[i] = obj[keys[i]]; + } + return values; + }; + _.mapObject = function(obj, iteratee, context) { + iteratee = cb(iteratee, context); + var keys = _.keys(obj), length = keys.length, results = {}, currentKey; + for (var index = 0; index < length; index++) { + currentKey = keys[index]; + results[currentKey] = iteratee(obj[currentKey], currentKey, obj); + } + return results; + }; + _.pairs = function(obj) { + var keys = _.keys(obj); + var length = keys.length; + var pairs = Array(length); + for (var i = 0; i < length; i++) { + pairs[i] = [ keys[i], obj[keys[i]] ]; + } + return pairs; + }; + _.invert = function(obj) { + var result = {}; + var keys = _.keys(obj); + for (var i = 0, length = keys.length; i < length; i++) { + result[obj[keys[i]]] = keys[i]; + } + return result; + }; + _.functions = _.methods = function(obj) { + var names = []; + for (var key in obj) { + if (_.isFunction(obj[key])) names.push(key); + } + return names.sort(); + }; + _.extend = createAssigner(_.allKeys); + _.extendOwn = _.assign = createAssigner(_.keys); + _.findKey = function(obj, predicate, context) { + predicate = cb(predicate, context); + var keys = _.keys(obj), key; + for (var i = 0, length = keys.length; i < length; i++) { + key = keys[i]; + if (predicate(obj[key], key, obj)) return key; + } + }; + _.pick = function(object, oiteratee, context) { + var result = {}, obj = object, iteratee, keys; + if (obj == null) return result; + if (_.isFunction(oiteratee)) { + keys = _.allKeys(obj); + iteratee = optimizeCb(oiteratee, context); + } else { + keys = flatten(arguments, false, false, 1); + iteratee = function(value, key, obj) { + return key in obj; + }; + obj = Object(obj); + } + for (var i = 0, length = keys.length; i < length; i++) { + var key = keys[i]; + var value = obj[key]; + if (iteratee(value, key, obj)) result[key] = value; + } + return result; + }; + _.omit = function(obj, iteratee, context) { + if (_.isFunction(iteratee)) { + iteratee = _.negate(iteratee); + } else { + var keys = _.map(flatten(arguments, false, false, 1), String); + iteratee = function(value, key) { + return !_.contains(keys, key); + }; + } + return _.pick(obj, iteratee, context); + }; + _.defaults = createAssigner(_.allKeys, true); + _.create = function(prototype, props) { + var result = baseCreate(prototype); + if (props) _.extendOwn(result, props); + return result; + }; + _.clone = function(obj) { + if (!_.isObject(obj)) return obj; + return _.isArray(obj) ? obj.slice() : _.extend({}, obj); + }; + _.tap = function(obj, interceptor) { + interceptor(obj); + return obj; + }; + _.isMatch = function(object, attrs) { + var keys = _.keys(attrs), length = keys.length; + if (object == null) return !length; + var obj = Object(object); + for (var i = 0; i < length; i++) { + var key = keys[i]; + if (attrs[key] !== obj[key] || !(key in obj)) return false; + } + return true; + }; + var eq = function(a, b, aStack, bStack) { + if (a === b) return a !== 0 || 1 / a === 1 / b; + if (a == null || b == null) return a === b; + if (a instanceof _) a = a._wrapped; + if (b instanceof _) b = b._wrapped; + var className = toString.call(a); + if (className !== toString.call(b)) return false; + switch (className) { + case "[object RegExp]": + case "[object String]": + return "" + a === "" + b; + + case "[object Number]": + if (+a !== +a) return +b !== +b; + return +a === 0 ? 1 / +a === 1 / b : +a === +b; + + case "[object Date]": + case "[object Boolean]": + return +a === +b; + } + var areArrays = className === "[object Array]"; + if (!areArrays) { + if (typeof a != "object" || typeof b != "object") return false; + var aCtor = a.constructor, bCtor = b.constructor; + if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor && _.isFunction(bCtor) && bCtor instanceof bCtor) && ("constructor" in a && "constructor" in b)) { + return false; + } + } + aStack = aStack || []; + bStack = bStack || []; + var length = aStack.length; + while (length--) { + if (aStack[length] === a) return bStack[length] === b; + } + aStack.push(a); + bStack.push(b); + if (areArrays) { + length = a.length; + if (length !== b.length) return false; + while (length--) { + if (!eq(a[length], b[length], aStack, bStack)) return false; + } + } else { + var keys = _.keys(a), key; + length = keys.length; + if (_.keys(b).length !== length) return false; + while (length--) { + key = keys[length]; + if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false; + } + } + aStack.pop(); + bStack.pop(); + return true; + }; + _.isEqual = function(a, b) { + return eq(a, b); + }; + _.isEmpty = function(obj) { + if (obj == null) return true; + if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0; + return _.keys(obj).length === 0; + }; + _.isElement = function(obj) { + return !!(obj && obj.nodeType === 1); + }; + _.isArray = nativeIsArray || function(obj) { + return toString.call(obj) === "[object Array]"; + }; + _.isObject = function(obj) { + var type = typeof obj; + return type === "function" || type === "object" && !!obj; + }; + _.each([ "Arguments", "Function", "String", "Number", "Date", "RegExp", "Error" ], function(name) { + _["is" + name] = function(obj) { + return toString.call(obj) === "[object " + name + "]"; + }; + }); + if (!_.isArguments(arguments)) { + _.isArguments = function(obj) { + return _.has(obj, "callee"); + }; + } + if (typeof /./ != "function" && typeof Int8Array != "object") { + _.isFunction = function(obj) { + return typeof obj == "function" || false; + }; + } + _.isFinite = function(obj) { + return isFinite(obj) && !isNaN(parseFloat(obj)); + }; + _.isNaN = function(obj) { + return _.isNumber(obj) && obj !== +obj; + }; + _.isBoolean = function(obj) { + return obj === true || obj === false || toString.call(obj) === "[object Boolean]"; + }; + _.isNull = function(obj) { + return obj === null; + }; + _.isUndefined = function(obj) { + return obj === void 0; + }; + _.has = function(obj, key) { + return obj != null && hasOwnProperty.call(obj, key); + }; + _.noConflict = function() { + root._ = previousUnderscore; + return this; + }; + _.identity = function(value) { + return value; + }; + _.constant = function(value) { + return function() { + return value; + }; + }; + _.noop = function() {}; + _.property = property; + _.propertyOf = function(obj) { + return obj == null ? function() {} : function(key) { + return obj[key]; + }; + }; + _.matcher = _.matches = function(attrs) { + attrs = _.extendOwn({}, attrs); + return function(obj) { + return _.isMatch(obj, attrs); + }; + }; + _.times = function(n, iteratee, context) { + var accum = Array(Math.max(0, n)); + iteratee = optimizeCb(iteratee, context, 1); + for (var i = 0; i < n; i++) accum[i] = iteratee(i); + return accum; + }; + _.random = function(min, max) { + if (max == null) { + max = min; + min = 0; + } + return min + Math.floor(Math.random() * (max - min + 1)); + }; + _.now = Date.now || function() { + return new Date().getTime(); + }; + var escapeMap = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + "`": "`" + }; + var unescapeMap = _.invert(escapeMap); + var createEscaper = function(map) { + var escaper = function(match) { + return map[match]; + }; + var source = "(?:" + _.keys(map).join("|") + ")"; + var testRegexp = RegExp(source); + var replaceRegexp = RegExp(source, "g"); + return function(string) { + string = string == null ? "" : "" + string; + return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; + }; + }; + _.escape = createEscaper(escapeMap); + _.unescape = createEscaper(unescapeMap); + _.result = function(object, property, fallback) { + var value = object == null ? void 0 : object[property]; + if (value === void 0) { + value = fallback; + } + return _.isFunction(value) ? value.call(object) : value; + }; + var idCounter = 0; + _.uniqueId = function(prefix) { + var id = ++idCounter + ""; + return prefix ? prefix + id : id; + }; + _.templateSettings = { + evaluate: /<%([\s\S]+?)%>/g, + interpolate: /<%=([\s\S]+?)%>/g, + escape: /<%-([\s\S]+?)%>/g + }; + var noMatch = /(.)^/; + var escapes = { + "'": "'", + "\\": "\\", + "\r": "r", + "\n": "n", + "\u2028": "u2028", + "\u2029": "u2029" + }; + var escaper = /\\|'|\r|\n|\u2028|\u2029/g; + var escapeChar = function(match) { + return "\\" + escapes[match]; + }; + _.template = function(text, settings, oldSettings) { + if (!settings && oldSettings) settings = oldSettings; + settings = _.defaults({}, settings, _.templateSettings); + var matcher = RegExp([ (settings.escape || noMatch).source, (settings.interpolate || noMatch).source, (settings.evaluate || noMatch).source ].join("|") + "|$", "g"); + var index = 0; + var source = "__p+='"; + text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { + source += text.slice(index, offset).replace(escaper, escapeChar); + index = offset + match.length; + if (escape) { + source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; + } else if (interpolate) { + source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; + } else if (evaluate) { + source += "';\n" + evaluate + "\n__p+='"; + } + return match; + }); + source += "';\n"; + if (!settings.variable) source = "with(obj||{}){\n" + source + "}\n"; + source = "var __t,__p='',__j=Array.prototype.join," + "print=function(){__p+=__j.call(arguments,'');};\n" + source + "return __p;\n"; + try { + var render = new Function(settings.variable || "obj", "_", source); + } catch (e) { + e.source = source; + throw e; + } + var template = function(data) { + return render.call(this, data, _); + }; + var argument = settings.variable || "obj"; + template.source = "function(" + argument + "){\n" + source + "}"; + return template; + }; + _.chain = function(obj) { + var instance = _(obj); + instance._chain = true; + return instance; + }; + var result = function(instance, obj) { + return instance._chain ? _(obj).chain() : obj; + }; + _.mixin = function(obj) { + _.each(_.functions(obj), function(name) { + var func = _[name] = obj[name]; + _.prototype[name] = function() { + var args = [ this._wrapped ]; + push.apply(args, arguments); + return result(this, func.apply(_, args)); + }; + }); + }; + _.mixin(_); + _.each([ "pop", "push", "reverse", "shift", "sort", "splice", "unshift" ], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + var obj = this._wrapped; + method.apply(obj, arguments); + if ((name === "shift" || name === "splice") && obj.length === 0) delete obj[0]; + return result(this, obj); + }; + }); + _.each([ "concat", "join", "slice" ], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + return result(this, method.apply(this._wrapped, arguments)); + }; + }); + _.prototype.value = function() { + return this._wrapped; + }; + _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; + _.prototype.toString = function() { + return "" + this._wrapped; + }; + if (typeof define === "function" && define.amd) { + define("underscore", [], function() { + return _; + }); + } +}).call(this); + (function(window, document, undefined) { "use strict"; function minErr(module, ErrorConstructor) { @@ -30831,6 +31885,24 @@ lingvodoc.User.fromJS = function(js) { return new lingvodoc.User(js.id, js.login, js.name, js.email, js.intl_name, js.about, js.signup_date, js.organizations); }; +lingvodoc.Blob = function(clientId, objectId, name, data_type) { + lingvodoc.Object.call(this, clientId, objectId); + this.type = "blob"; + this.name = name; + this.data_type = data_type; + this.equals = function(obj) { + return lingvodoc.Object.prototype.equals.call(this, obj) && this.name == obj.name; + }; +}; + +lingvodoc.Blob.fromJS = function(js) { + return new lingvodoc.Blob(js.client_id, js.object_id, js.name, js.data_type); +}; + +lingvodoc.Blob.prototype = new lingvodoc.Object(); + +lingvodoc.Blob.prototype.constructor = lingvodoc.Blob; + function lingvodocAPI($http, $q) { var addUrlParameter = function(url, key, value) { return url + (url.indexOf("?") >= 0 ? "&" : "?") + encodeURIComponent(key) + "=" + encodeURIComponent(value); @@ -31667,6 +32739,41 @@ function lingvodocAPI($http, $q) { }); return deferred.promise; }; + var getUserBlobs = function() { + var deferred = $q.defer(); + $http.get("/blobs").success(function(data, status, headers, config) { + var blobs = _.map(data, lingvodoc.Blob.fromJS); + deferred.resolve(blobs); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var checkDictionaryBlob = function(blob, parent) { + var deferred = $q.defer(); + var query = { + blob_client_id: blob.client_id, + blob_object_id: blob.object_id, + parent_client_id: parent.client_id, + parent_object_id: parent.object_id + }; + $http.post("/convert_check", query).success(function(data, status, headers, config) { + var perspectives = _.map(data, lingvodoc.Perspective.fromJS); + deferred.resolve(perspectives); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var convertDictionary = function(req) { + var deferred = $q.defer(); + $http.post("/convert", req).success(function(data, status, headers, config) { + deferred.resolve(data); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; return { getLexicalEntries: getLexicalEntries, getLexicalEntriesCount: getLexicalEntriesCount, @@ -31714,7 +32821,10 @@ function lingvodocAPI($http, $q) { deleteDictionaryRoles: deleteDictionaryRoles, getPerspectiveRoles: getPerspectiveRoles, addPerspectiveRoles: addPerspectiveRoles, - deletePerspectiveRoles: deletePerspectiveRoles + deletePerspectiveRoles: deletePerspectiveRoles, + getUserBlobs: getUserBlobs, + checkDictionaryBlob: checkDictionaryBlob, + convertDictionary: convertDictionary }; } @@ -31741,7 +32851,7 @@ function responseHandler($timeout, $modal) { }, timeout); } function success(message) { - show("success", message, 500); + show("success", message, 5e3); } function error(message) { show("error", message, 5e3); @@ -31877,6 +32987,13 @@ app.controller("CreateDictionaryController", [ "$scope", "$http", "$modal", "$in delete $scope.perspective.fields[fieldIndex].contains; } }; + var convert = function(req) { + dictionaryService.convertDictionary(req).then(function(response) { + responseHandler.success(response); + }, function(reason) { + responseHandler.error(reason); + }); + }; $scope.createDictionary = function() { var language = getLanguageById($scope.dictionaryData.languageId); if (!$scope.dictionaryData.name && $scope.wizard.mode == "create" || typeof $scope.wizard.importedDictionaryId != "string" && $scope.wizard.mode == "import" || !language) { @@ -31908,20 +33025,40 @@ app.controller("CreateDictionaryController", [ "$scope", "$http", "$modal", "$in if ($scope.wizard.mode == "import") { if (typeof $scope.wizard.importedDictionaryId == "string") { $scope.controls.createDictionary = false; - var ids = $scope.wizard.importedDictionaryId.split("_"); - var url = $("#convertUrl").data("lingvodoc"); - var convertObject = { - blob_client_id: parseInt(ids[0]), - blob_object_id: parseInt(ids[1]), - parent_client_id: language.client_id, - parent_object_id: language.object_id - }; - $http.post(url, convertObject).success(function(data, status, headers, config) { - $scope.controls.createDictionary = true; - responseHandler.success(data.status); - }).error(function(data, status, headers, config) { - $scope.controls.createDictionary = true; - responseHandler.error(data); + var blob = _.find($scope.uploadedDictionaries, function(d) { + return d.getId() == $scope.wizard.importedDictionaryId; + }); + dictionaryService.checkDictionaryBlob(blob, language).then(function(perspectives) { + if (_.size(perspectives) > 0) { + $modal.open({ + animation: true, + templateUrl: "importModal.html", + controller: "ImportController", + size: "lg", + backdrop: "static", + keyboard: false, + resolve: { + params: function() { + return { + perspectives: perspectives, + blob: blob, + language: language + }; + } + } + }).result.then(function(req) { + convert(req); + }, function() {}); + } else { + convert({ + blob_client_id: blob.client_id, + blob_object_id: blob.object_id, + parent_client_id: language.client_id, + parent_object_id: language.object_id + }); + } + }, function(reason) { + responseHandler.error(reason); }); } } @@ -31980,20 +33117,6 @@ app.controller("CreateDictionaryController", [ "$scope", "$http", "$modal", "$in $scope.languages = flatLanguages(data.languages); }).error(function(data, status, headers, config) {}); }; - var loadBlobs = function() { - $http.get(listBlobsUrl).success(function(data, status, headers, config) { - $scope.uploadedDictionaries = []; - for (var i = 0; i < data.length; i++) { - if (data[i].data_type = "dialeqt_dictionary") { - var id = data[i].client_id + "_" + data[i].object_id; - $scope.uploadedDictionaries.push({ - id: id, - data: data[i] - }); - } - } - }).error(function(data, status, headers, config) {}); - }; $scope.$watch("dictionaryData.perspectiveId", function(id) { if (typeof id == "string") { for (var i = 0; i < $scope.perspectives.length; i++) { @@ -32015,7 +33138,13 @@ app.controller("CreateDictionaryController", [ "$scope", "$http", "$modal", "$in responseHandler.error(reason); }); loadLanguages(); - loadBlobs(); + dictionaryService.getUserBlobs().then(function(blobs) { + $scope.uploadedDictionaries = _.filter(blobs, function(e) { + return e.data_type == "dialeqt_dictionary"; + }); + }, function(reason) { + responseHandler.error(reason); + }); } ]); app.controller("CreateLanguageController", [ "$scope", "$http", "$interval", "$modalInstance", "responseHandler", function($scope, $http, $interval, $modalInstance, responseHandler) { @@ -32073,4 +33202,86 @@ app.controller("CreateLanguageController", [ "$scope", "$http", "$interval", "$m $http.get(languagesUrl).success(function(data, status, headers, config) { $scope.languages = flatLanguages(data.languages); }).error(function(data, status, headers, config) {}); +} ]); + +app.controller("ImportController", [ "$scope", "$http", "$q", "$log", "$modalInstance", "dictionaryService", "responseHandler", "params", function($scope, $http, $q, $log, $modalInstance, dictionaryService, responseHandler, params) { + $scope.mode = "create"; + $scope.perspectives = params.perspectives; + $scope.paths = []; + $scope.import = {}; + $scope.import.dictionaryId = ""; + $scope.import.perspectiveId = ""; + $scope.import.createNewPerspective = false; + var getSelectedPerspective = function() { + return _.find($scope.perspectives, function(e) { + return e.getId() === $scope.import.perspectiveId; + }); + }; + var getSelectedDictionary = function() { + return _.find($scope.dictionaries, function(e) { + return e.getId() === $scope.import.dictionaryId; + }); + }; + $scope.ok = function() { + var req = { + blob_client_id: params.blob.client_id, + blob_object_id: params.blob.object_id, + parent_client_id: params.language.client_id, + parent_object_id: params.language.object_id + }; + if ($scope.mode === "import") { + var dictionary = getSelectedDictionary(); + if (dictionary) { + req.dictionary_client_id = dictionary.client_id; + req.dictionary_object_id = dictionary.object_id; + if (!$scope.import.createNewPerspective) { + var perspective = getSelectedPerspective(); + if (perspective) { + req.perspective_client_id = perspective.client_id; + req.perspective_object_id = perspective.object_id; + } else { + responseHandler.error("Please, select perspective."); + return; + } + } + } else { + responseHandler.error("Please, select dictionary."); + return; + } + } + $modalInstance.close(req); + }; + $scope.cancel = function() { + $modalInstance.dismiss("cancel"); + }; + $scope.$watch("import.dictionaryId", function(id) { + var dictionary = _.find($scope.dictionaries, function(d) { + return d.getId() === id; + }); + if (dictionary) { + $scope.perspectives = _.filter(params.perspectives, function(p) { + return p.parent_client_id == dictionary.client_id && p.parent_object_id == dictionary.object_id; + }); + } + }); + var r = params.perspectives.map(function(perspective) { + return dictionaryService.getPerspectiveOriginById(perspective.client_id, perspective.parent_object_id); + }); + $q.all(r).then(function(paths) { + $scope.paths = paths; + var dictionaries = _.reduce(paths, function(acc, path) { + var pathDicts = _.filter(path, function(e) { + return e.type === "dictionary"; + }); + _.each(pathDicts, function(d) { + acc.push(d); + }); + return acc; + }, []); + $scope.dictionaries = _.uniq(dictionaries, function(d, key, a) { + return d.getId(); + }); + }, function(reason) { + responseHandler.error(reason); + }); } ]); \ No newline at end of file diff --git a/lingvodoc/static/js/dashboard.js b/lingvodoc/static/js/dashboard.js index 8c52d9d66..c3a2f6710 100644 --- a/lingvodoc/static/js/dashboard.js +++ b/lingvodoc/static/js/dashboard.js @@ -28384,6 +28384,24 @@ lingvodoc.User.fromJS = function(js) { return new lingvodoc.User(js.id, js.login, js.name, js.email, js.intl_name, js.about, js.signup_date, js.organizations); }; +lingvodoc.Blob = function(clientId, objectId, name, data_type) { + lingvodoc.Object.call(this, clientId, objectId); + this.type = "blob"; + this.name = name; + this.data_type = data_type; + this.equals = function(obj) { + return lingvodoc.Object.prototype.equals.call(this, obj) && this.name == obj.name; + }; +}; + +lingvodoc.Blob.fromJS = function(js) { + return new lingvodoc.Blob(js.client_id, js.object_id, js.name, js.data_type); +}; + +lingvodoc.Blob.prototype = new lingvodoc.Object(); + +lingvodoc.Blob.prototype.constructor = lingvodoc.Blob; + function lingvodocAPI($http, $q) { var addUrlParameter = function(url, key, value) { return url + (url.indexOf("?") >= 0 ? "&" : "?") + encodeURIComponent(key) + "=" + encodeURIComponent(value); @@ -29220,6 +29238,41 @@ function lingvodocAPI($http, $q) { }); return deferred.promise; }; + var getUserBlobs = function() { + var deferred = $q.defer(); + $http.get("/blobs").success(function(data, status, headers, config) { + var blobs = _.map(data, lingvodoc.Blob.fromJS); + deferred.resolve(blobs); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var checkDictionaryBlob = function(blob, parent) { + var deferred = $q.defer(); + var query = { + blob_client_id: blob.client_id, + blob_object_id: blob.object_id, + parent_client_id: parent.client_id, + parent_object_id: parent.object_id + }; + $http.post("/convert_check", query).success(function(data, status, headers, config) { + var perspectives = _.map(data, lingvodoc.Perspective.fromJS); + deferred.resolve(perspectives); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var convertDictionary = function(req) { + var deferred = $q.defer(); + $http.post("/convert", req).success(function(data, status, headers, config) { + deferred.resolve(data); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; return { getLexicalEntries: getLexicalEntries, getLexicalEntriesCount: getLexicalEntriesCount, @@ -29267,7 +29320,10 @@ function lingvodocAPI($http, $q) { deleteDictionaryRoles: deleteDictionaryRoles, getPerspectiveRoles: getPerspectiveRoles, addPerspectiveRoles: addPerspectiveRoles, - deletePerspectiveRoles: deletePerspectiveRoles + deletePerspectiveRoles: deletePerspectiveRoles, + getUserBlobs: getUserBlobs, + checkDictionaryBlob: checkDictionaryBlob, + convertDictionary: convertDictionary }; } @@ -29294,7 +29350,7 @@ function responseHandler($timeout, $modal) { }, timeout); } function success(message) { - show("success", message, 500); + show("success", message, 5e3); } function error(message) { show("error", message, 5e3); diff --git a/lingvodoc/static/js/edit-dictionary.js b/lingvodoc/static/js/edit-dictionary.js index 94a44dd58..19b2362a4 100644 --- a/lingvodoc/static/js/edit-dictionary.js +++ b/lingvodoc/static/js/edit-dictionary.js @@ -27403,6 +27403,24 @@ lingvodoc.User.fromJS = function(js) { return new lingvodoc.User(js.id, js.login, js.name, js.email, js.intl_name, js.about, js.signup_date, js.organizations); }; +lingvodoc.Blob = function(clientId, objectId, name, data_type) { + lingvodoc.Object.call(this, clientId, objectId); + this.type = "blob"; + this.name = name; + this.data_type = data_type; + this.equals = function(obj) { + return lingvodoc.Object.prototype.equals.call(this, obj) && this.name == obj.name; + }; +}; + +lingvodoc.Blob.fromJS = function(js) { + return new lingvodoc.Blob(js.client_id, js.object_id, js.name, js.data_type); +}; + +lingvodoc.Blob.prototype = new lingvodoc.Object(); + +lingvodoc.Blob.prototype.constructor = lingvodoc.Blob; + function lingvodocAPI($http, $q) { var addUrlParameter = function(url, key, value) { return url + (url.indexOf("?") >= 0 ? "&" : "?") + encodeURIComponent(key) + "=" + encodeURIComponent(value); @@ -28239,6 +28257,41 @@ function lingvodocAPI($http, $q) { }); return deferred.promise; }; + var getUserBlobs = function() { + var deferred = $q.defer(); + $http.get("/blobs").success(function(data, status, headers, config) { + var blobs = _.map(data, lingvodoc.Blob.fromJS); + deferred.resolve(blobs); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var checkDictionaryBlob = function(blob, parent) { + var deferred = $q.defer(); + var query = { + blob_client_id: blob.client_id, + blob_object_id: blob.object_id, + parent_client_id: parent.client_id, + parent_object_id: parent.object_id + }; + $http.post("/convert_check", query).success(function(data, status, headers, config) { + var perspectives = _.map(data, lingvodoc.Perspective.fromJS); + deferred.resolve(perspectives); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var convertDictionary = function(req) { + var deferred = $q.defer(); + $http.post("/convert", req).success(function(data, status, headers, config) { + deferred.resolve(data); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; return { getLexicalEntries: getLexicalEntries, getLexicalEntriesCount: getLexicalEntriesCount, @@ -28286,7 +28339,10 @@ function lingvodocAPI($http, $q) { deleteDictionaryRoles: deleteDictionaryRoles, getPerspectiveRoles: getPerspectiveRoles, addPerspectiveRoles: addPerspectiveRoles, - deletePerspectiveRoles: deletePerspectiveRoles + deletePerspectiveRoles: deletePerspectiveRoles, + getUserBlobs: getUserBlobs, + checkDictionaryBlob: checkDictionaryBlob, + convertDictionary: convertDictionary }; } @@ -28313,7 +28369,7 @@ function responseHandler($timeout, $modal) { }, timeout); } function success(message) { - show("success", message, 500); + show("success", message, 5e3); } function error(message) { show("error", message, 5e3); diff --git a/lingvodoc/static/js/home.js b/lingvodoc/static/js/home.js index 8eb8fb39b..d2a1428ff 100644 --- a/lingvodoc/static/js/home.js +++ b/lingvodoc/static/js/home.js @@ -26389,6 +26389,24 @@ lingvodoc.User.fromJS = function(js) { return new lingvodoc.User(js.id, js.login, js.name, js.email, js.intl_name, js.about, js.signup_date, js.organizations); }; +lingvodoc.Blob = function(clientId, objectId, name, data_type) { + lingvodoc.Object.call(this, clientId, objectId); + this.type = "blob"; + this.name = name; + this.data_type = data_type; + this.equals = function(obj) { + return lingvodoc.Object.prototype.equals.call(this, obj) && this.name == obj.name; + }; +}; + +lingvodoc.Blob.fromJS = function(js) { + return new lingvodoc.Blob(js.client_id, js.object_id, js.name, js.data_type); +}; + +lingvodoc.Blob.prototype = new lingvodoc.Object(); + +lingvodoc.Blob.prototype.constructor = lingvodoc.Blob; + function lingvodocAPI($http, $q) { var addUrlParameter = function(url, key, value) { return url + (url.indexOf("?") >= 0 ? "&" : "?") + encodeURIComponent(key) + "=" + encodeURIComponent(value); @@ -27225,6 +27243,41 @@ function lingvodocAPI($http, $q) { }); return deferred.promise; }; + var getUserBlobs = function() { + var deferred = $q.defer(); + $http.get("/blobs").success(function(data, status, headers, config) { + var blobs = _.map(data, lingvodoc.Blob.fromJS); + deferred.resolve(blobs); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var checkDictionaryBlob = function(blob, parent) { + var deferred = $q.defer(); + var query = { + blob_client_id: blob.client_id, + blob_object_id: blob.object_id, + parent_client_id: parent.client_id, + parent_object_id: parent.object_id + }; + $http.post("/convert_check", query).success(function(data, status, headers, config) { + var perspectives = _.map(data, lingvodoc.Perspective.fromJS); + deferred.resolve(perspectives); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var convertDictionary = function(req) { + var deferred = $q.defer(); + $http.post("/convert", req).success(function(data, status, headers, config) { + deferred.resolve(data); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; return { getLexicalEntries: getLexicalEntries, getLexicalEntriesCount: getLexicalEntriesCount, @@ -27272,7 +27325,10 @@ function lingvodocAPI($http, $q) { deleteDictionaryRoles: deleteDictionaryRoles, getPerspectiveRoles: getPerspectiveRoles, addPerspectiveRoles: addPerspectiveRoles, - deletePerspectiveRoles: deletePerspectiveRoles + deletePerspectiveRoles: deletePerspectiveRoles, + getUserBlobs: getUserBlobs, + checkDictionaryBlob: checkDictionaryBlob, + convertDictionary: convertDictionary }; } @@ -27299,7 +27355,7 @@ function responseHandler($timeout, $modal) { }, timeout); } function success(message) { - show("success", message, 500); + show("success", message, 5e3); } function error(message) { show("error", message, 5e3); diff --git a/lingvodoc/static/js/languages.js b/lingvodoc/static/js/languages.js index e7bda726f..cd5b3c344 100644 --- a/lingvodoc/static/js/languages.js +++ b/lingvodoc/static/js/languages.js @@ -27306,7 +27306,7 @@ function responseHandler($timeout, $modal) { }, timeout); } function success(message) { - show("success", message, 500); + show("success", message, 5e3); } function error(message) { show("error", message, 5e3); diff --git a/lingvodoc/static/js/login.js b/lingvodoc/static/js/login.js index e03b60865..c61971896 100644 --- a/lingvodoc/static/js/login.js +++ b/lingvodoc/static/js/login.js @@ -26456,7 +26456,7 @@ function responseHandler($timeout, $modal) { }, timeout); } function success(message) { - show("success", message, 500); + show("success", message, 5e3); } function error(message) { show("error", message, 5e3); diff --git a/lingvodoc/static/js/merge-master.js b/lingvodoc/static/js/merge-master.js index 5f3c47414..b1fbd7cac 100644 --- a/lingvodoc/static/js/merge-master.js +++ b/lingvodoc/static/js/merge-master.js @@ -28230,6 +28230,24 @@ lingvodoc.User.fromJS = function(js) { return new lingvodoc.User(js.id, js.login, js.name, js.email, js.intl_name, js.about, js.signup_date, js.organizations); }; +lingvodoc.Blob = function(clientId, objectId, name, data_type) { + lingvodoc.Object.call(this, clientId, objectId); + this.type = "blob"; + this.name = name; + this.data_type = data_type; + this.equals = function(obj) { + return lingvodoc.Object.prototype.equals.call(this, obj) && this.name == obj.name; + }; +}; + +lingvodoc.Blob.fromJS = function(js) { + return new lingvodoc.Blob(js.client_id, js.object_id, js.name, js.data_type); +}; + +lingvodoc.Blob.prototype = new lingvodoc.Object(); + +lingvodoc.Blob.prototype.constructor = lingvodoc.Blob; + function lingvodocAPI($http, $q) { var addUrlParameter = function(url, key, value) { return url + (url.indexOf("?") >= 0 ? "&" : "?") + encodeURIComponent(key) + "=" + encodeURIComponent(value); @@ -29066,6 +29084,41 @@ function lingvodocAPI($http, $q) { }); return deferred.promise; }; + var getUserBlobs = function() { + var deferred = $q.defer(); + $http.get("/blobs").success(function(data, status, headers, config) { + var blobs = _.map(data, lingvodoc.Blob.fromJS); + deferred.resolve(blobs); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var checkDictionaryBlob = function(blob, parent) { + var deferred = $q.defer(); + var query = { + blob_client_id: blob.client_id, + blob_object_id: blob.object_id, + parent_client_id: parent.client_id, + parent_object_id: parent.object_id + }; + $http.post("/convert_check", query).success(function(data, status, headers, config) { + var perspectives = _.map(data, lingvodoc.Perspective.fromJS); + deferred.resolve(perspectives); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var convertDictionary = function(req) { + var deferred = $q.defer(); + $http.post("/convert", req).success(function(data, status, headers, config) { + deferred.resolve(data); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; return { getLexicalEntries: getLexicalEntries, getLexicalEntriesCount: getLexicalEntriesCount, @@ -29113,7 +29166,10 @@ function lingvodocAPI($http, $q) { deleteDictionaryRoles: deleteDictionaryRoles, getPerspectiveRoles: getPerspectiveRoles, addPerspectiveRoles: addPerspectiveRoles, - deletePerspectiveRoles: deletePerspectiveRoles + deletePerspectiveRoles: deletePerspectiveRoles, + getUserBlobs: getUserBlobs, + checkDictionaryBlob: checkDictionaryBlob, + convertDictionary: convertDictionary }; } @@ -29140,7 +29196,7 @@ function responseHandler($timeout, $modal) { }, timeout); } function success(message) { - show("success", message, 500); + show("success", message, 5e3); } function error(message) { show("error", message, 5e3); diff --git a/lingvodoc/static/js/organizations.js b/lingvodoc/static/js/organizations.js index ed7ffec3d..f0cbdd296 100644 --- a/lingvodoc/static/js/organizations.js +++ b/lingvodoc/static/js/organizations.js @@ -27330,6 +27330,24 @@ lingvodoc.User.fromJS = function(js) { return new lingvodoc.User(js.id, js.login, js.name, js.email, js.intl_name, js.about, js.signup_date, js.organizations); }; +lingvodoc.Blob = function(clientId, objectId, name, data_type) { + lingvodoc.Object.call(this, clientId, objectId); + this.type = "blob"; + this.name = name; + this.data_type = data_type; + this.equals = function(obj) { + return lingvodoc.Object.prototype.equals.call(this, obj) && this.name == obj.name; + }; +}; + +lingvodoc.Blob.fromJS = function(js) { + return new lingvodoc.Blob(js.client_id, js.object_id, js.name, js.data_type); +}; + +lingvodoc.Blob.prototype = new lingvodoc.Object(); + +lingvodoc.Blob.prototype.constructor = lingvodoc.Blob; + function lingvodocAPI($http, $q) { var addUrlParameter = function(url, key, value) { return url + (url.indexOf("?") >= 0 ? "&" : "?") + encodeURIComponent(key) + "=" + encodeURIComponent(value); @@ -28166,6 +28184,41 @@ function lingvodocAPI($http, $q) { }); return deferred.promise; }; + var getUserBlobs = function() { + var deferred = $q.defer(); + $http.get("/blobs").success(function(data, status, headers, config) { + var blobs = _.map(data, lingvodoc.Blob.fromJS); + deferred.resolve(blobs); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var checkDictionaryBlob = function(blob, parent) { + var deferred = $q.defer(); + var query = { + blob_client_id: blob.client_id, + blob_object_id: blob.object_id, + parent_client_id: parent.client_id, + parent_object_id: parent.object_id + }; + $http.post("/convert_check", query).success(function(data, status, headers, config) { + var perspectives = _.map(data, lingvodoc.Perspective.fromJS); + deferred.resolve(perspectives); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var convertDictionary = function(req) { + var deferred = $q.defer(); + $http.post("/convert", req).success(function(data, status, headers, config) { + deferred.resolve(data); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; return { getLexicalEntries: getLexicalEntries, getLexicalEntriesCount: getLexicalEntriesCount, @@ -28213,7 +28266,10 @@ function lingvodocAPI($http, $q) { deleteDictionaryRoles: deleteDictionaryRoles, getPerspectiveRoles: getPerspectiveRoles, addPerspectiveRoles: addPerspectiveRoles, - deletePerspectiveRoles: deletePerspectiveRoles + deletePerspectiveRoles: deletePerspectiveRoles, + getUserBlobs: getUserBlobs, + checkDictionaryBlob: checkDictionaryBlob, + convertDictionary: convertDictionary }; } @@ -28240,7 +28296,7 @@ function responseHandler($timeout, $modal) { }, timeout); } function success(message) { - show("success", message, 500); + show("success", message, 5e3); } function error(message) { show("error", message, 5e3); diff --git a/lingvodoc/static/js/profile.js b/lingvodoc/static/js/profile.js index bd405a759..0619be74a 100644 --- a/lingvodoc/static/js/profile.js +++ b/lingvodoc/static/js/profile.js @@ -27330,6 +27330,24 @@ lingvodoc.User.fromJS = function(js) { return new lingvodoc.User(js.id, js.login, js.name, js.email, js.intl_name, js.about, js.signup_date, js.organizations); }; +lingvodoc.Blob = function(clientId, objectId, name, data_type) { + lingvodoc.Object.call(this, clientId, objectId); + this.type = "blob"; + this.name = name; + this.data_type = data_type; + this.equals = function(obj) { + return lingvodoc.Object.prototype.equals.call(this, obj) && this.name == obj.name; + }; +}; + +lingvodoc.Blob.fromJS = function(js) { + return new lingvodoc.Blob(js.client_id, js.object_id, js.name, js.data_type); +}; + +lingvodoc.Blob.prototype = new lingvodoc.Object(); + +lingvodoc.Blob.prototype.constructor = lingvodoc.Blob; + function lingvodocAPI($http, $q) { var addUrlParameter = function(url, key, value) { return url + (url.indexOf("?") >= 0 ? "&" : "?") + encodeURIComponent(key) + "=" + encodeURIComponent(value); @@ -28166,6 +28184,41 @@ function lingvodocAPI($http, $q) { }); return deferred.promise; }; + var getUserBlobs = function() { + var deferred = $q.defer(); + $http.get("/blobs").success(function(data, status, headers, config) { + var blobs = _.map(data, lingvodoc.Blob.fromJS); + deferred.resolve(blobs); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var checkDictionaryBlob = function(blob, parent) { + var deferred = $q.defer(); + var query = { + blob_client_id: blob.client_id, + blob_object_id: blob.object_id, + parent_client_id: parent.client_id, + parent_object_id: parent.object_id + }; + $http.post("/convert_check", query).success(function(data, status, headers, config) { + var perspectives = _.map(data, lingvodoc.Perspective.fromJS); + deferred.resolve(perspectives); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var convertDictionary = function(req) { + var deferred = $q.defer(); + $http.post("/convert", req).success(function(data, status, headers, config) { + deferred.resolve(data); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; return { getLexicalEntries: getLexicalEntries, getLexicalEntriesCount: getLexicalEntriesCount, @@ -28213,7 +28266,10 @@ function lingvodocAPI($http, $q) { deleteDictionaryRoles: deleteDictionaryRoles, getPerspectiveRoles: getPerspectiveRoles, addPerspectiveRoles: addPerspectiveRoles, - deletePerspectiveRoles: deletePerspectiveRoles + deletePerspectiveRoles: deletePerspectiveRoles, + getUserBlobs: getUserBlobs, + checkDictionaryBlob: checkDictionaryBlob, + convertDictionary: convertDictionary }; } @@ -28240,7 +28296,7 @@ function responseHandler($timeout, $modal) { }, timeout); } function success(message) { - show("success", message, 500); + show("success", message, 5e3); } function error(message) { show("error", message, 5e3); diff --git a/lingvodoc/static/js/publish-dictionary.js b/lingvodoc/static/js/publish-dictionary.js index ab4bf8bea..fc9de2c49 100644 --- a/lingvodoc/static/js/publish-dictionary.js +++ b/lingvodoc/static/js/publish-dictionary.js @@ -27403,6 +27403,24 @@ lingvodoc.User.fromJS = function(js) { return new lingvodoc.User(js.id, js.login, js.name, js.email, js.intl_name, js.about, js.signup_date, js.organizations); }; +lingvodoc.Blob = function(clientId, objectId, name, data_type) { + lingvodoc.Object.call(this, clientId, objectId); + this.type = "blob"; + this.name = name; + this.data_type = data_type; + this.equals = function(obj) { + return lingvodoc.Object.prototype.equals.call(this, obj) && this.name == obj.name; + }; +}; + +lingvodoc.Blob.fromJS = function(js) { + return new lingvodoc.Blob(js.client_id, js.object_id, js.name, js.data_type); +}; + +lingvodoc.Blob.prototype = new lingvodoc.Object(); + +lingvodoc.Blob.prototype.constructor = lingvodoc.Blob; + function lingvodocAPI($http, $q) { var addUrlParameter = function(url, key, value) { return url + (url.indexOf("?") >= 0 ? "&" : "?") + encodeURIComponent(key) + "=" + encodeURIComponent(value); @@ -28239,6 +28257,41 @@ function lingvodocAPI($http, $q) { }); return deferred.promise; }; + var getUserBlobs = function() { + var deferred = $q.defer(); + $http.get("/blobs").success(function(data, status, headers, config) { + var blobs = _.map(data, lingvodoc.Blob.fromJS); + deferred.resolve(blobs); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var checkDictionaryBlob = function(blob, parent) { + var deferred = $q.defer(); + var query = { + blob_client_id: blob.client_id, + blob_object_id: blob.object_id, + parent_client_id: parent.client_id, + parent_object_id: parent.object_id + }; + $http.post("/convert_check", query).success(function(data, status, headers, config) { + var perspectives = _.map(data, lingvodoc.Perspective.fromJS); + deferred.resolve(perspectives); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var convertDictionary = function(req) { + var deferred = $q.defer(); + $http.post("/convert", req).success(function(data, status, headers, config) { + deferred.resolve(data); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; return { getLexicalEntries: getLexicalEntries, getLexicalEntriesCount: getLexicalEntriesCount, @@ -28286,7 +28339,10 @@ function lingvodocAPI($http, $q) { deleteDictionaryRoles: deleteDictionaryRoles, getPerspectiveRoles: getPerspectiveRoles, addPerspectiveRoles: addPerspectiveRoles, - deletePerspectiveRoles: deletePerspectiveRoles + deletePerspectiveRoles: deletePerspectiveRoles, + getUserBlobs: getUserBlobs, + checkDictionaryBlob: checkDictionaryBlob, + convertDictionary: convertDictionary }; } @@ -28313,7 +28369,7 @@ function responseHandler($timeout, $modal) { }, timeout); } function success(message) { - show("success", message, 500); + show("success", message, 5e3); } function error(message) { show("error", message, 5e3); diff --git a/lingvodoc/static/js/user-upload.js b/lingvodoc/static/js/user-upload.js index 6c6daa437..8e77fadd9 100644 --- a/lingvodoc/static/js/user-upload.js +++ b/lingvodoc/static/js/user-upload.js @@ -26970,7 +26970,7 @@ function responseHandler($timeout, $modal) { }, timeout); } function success(message) { - show("success", message, 500); + show("success", message, 5e3); } function error(message) { show("error", message, 5e3); diff --git a/lingvodoc/static/js/view-dictionary.js b/lingvodoc/static/js/view-dictionary.js index 03c51338b..5df9b1843 100644 --- a/lingvodoc/static/js/view-dictionary.js +++ b/lingvodoc/static/js/view-dictionary.js @@ -27403,6 +27403,24 @@ lingvodoc.User.fromJS = function(js) { return new lingvodoc.User(js.id, js.login, js.name, js.email, js.intl_name, js.about, js.signup_date, js.organizations); }; +lingvodoc.Blob = function(clientId, objectId, name, data_type) { + lingvodoc.Object.call(this, clientId, objectId); + this.type = "blob"; + this.name = name; + this.data_type = data_type; + this.equals = function(obj) { + return lingvodoc.Object.prototype.equals.call(this, obj) && this.name == obj.name; + }; +}; + +lingvodoc.Blob.fromJS = function(js) { + return new lingvodoc.Blob(js.client_id, js.object_id, js.name, js.data_type); +}; + +lingvodoc.Blob.prototype = new lingvodoc.Object(); + +lingvodoc.Blob.prototype.constructor = lingvodoc.Blob; + function lingvodocAPI($http, $q) { var addUrlParameter = function(url, key, value) { return url + (url.indexOf("?") >= 0 ? "&" : "?") + encodeURIComponent(key) + "=" + encodeURIComponent(value); @@ -28239,6 +28257,41 @@ function lingvodocAPI($http, $q) { }); return deferred.promise; }; + var getUserBlobs = function() { + var deferred = $q.defer(); + $http.get("/blobs").success(function(data, status, headers, config) { + var blobs = _.map(data, lingvodoc.Blob.fromJS); + deferred.resolve(blobs); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var checkDictionaryBlob = function(blob, parent) { + var deferred = $q.defer(); + var query = { + blob_client_id: blob.client_id, + blob_object_id: blob.object_id, + parent_client_id: parent.client_id, + parent_object_id: parent.object_id + }; + $http.post("/convert_check", query).success(function(data, status, headers, config) { + var perspectives = _.map(data, lingvodoc.Perspective.fromJS); + deferred.resolve(perspectives); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; + var convertDictionary = function(req) { + var deferred = $q.defer(); + $http.post("/convert", req).success(function(data, status, headers, config) { + deferred.resolve(data); + }).error(function(data, status, headers, config) { + deferred.reject("Failed to convert dictionary"); + }); + return deferred.promise; + }; return { getLexicalEntries: getLexicalEntries, getLexicalEntriesCount: getLexicalEntriesCount, @@ -28286,7 +28339,10 @@ function lingvodocAPI($http, $q) { deleteDictionaryRoles: deleteDictionaryRoles, getPerspectiveRoles: getPerspectiveRoles, addPerspectiveRoles: addPerspectiveRoles, - deletePerspectiveRoles: deletePerspectiveRoles + deletePerspectiveRoles: deletePerspectiveRoles, + getUserBlobs: getUserBlobs, + checkDictionaryBlob: checkDictionaryBlob, + convertDictionary: convertDictionary }; } @@ -28313,7 +28369,7 @@ function responseHandler($timeout, $modal) { }, timeout); } function success(message) { - show("success", message, 500); + show("success", message, 5e3); } function error(message) { show("error", message, 5e3); diff --git a/lingvodoc/templates/create_dictionary.pt b/lingvodoc/templates/create_dictionary.pt index 77012e877..fc3f38cf5 100644 --- a/lingvodoc/templates/create_dictionary.pt +++ b/lingvodoc/templates/create_dictionary.pt @@ -82,11 +82,12 @@
(Upload dictionary) - + -
+ @@ -327,6 +328,68 @@ + + + + + + + + + + + + + + + + + +
diff --git a/webui/Gruntfile.js b/webui/Gruntfile.js index db674f290..c2d307324 100755 --- a/webui/Gruntfile.js +++ b/webui/Gruntfile.js @@ -113,6 +113,7 @@ module.exports = function(grunt) { createdictionary: { src: [ 'bower_components/jquery/dist/jquery.js', + 'bower_components/underscore/underscore.js', 'bower_components/angular/angular.js', 'bower_components/bootstrap-sass/assets/javascripts/bootstrap.js', 'bower_components/angular-bootstrap/ui-bootstrap.js', diff --git a/webui/src/js/api.js b/webui/src/js/api.js index f2f4270ec..c6d64b586 100755 --- a/webui/src/js/api.js +++ b/webui/src/js/api.js @@ -118,6 +118,24 @@ lingvodoc.User.fromJS = function (js) { return new lingvodoc.User(js.id, js.login, js.name, js.email, js.intl_name, js.about, js.signup_date, js.organizations); }; +lingvodoc.Blob = function(clientId, objectId, name, data_type) { + + lingvodoc.Object.call(this, clientId, objectId); + this.type = 'blob'; + this.name = name; + this.data_type = data_type; + + this.equals = function(obj) { + return lingvodoc.Object.prototype.equals.call(this, obj) && (this.name == obj.name); + }; +}; +lingvodoc.Blob.fromJS = function (js) { + return new lingvodoc.Blob(js.client_id, js.object_id, js.name, js.data_type); +}; +lingvodoc.Blob.prototype = new lingvodoc.Object(); +lingvodoc.Blob.prototype.constructor = lingvodoc.Blob; + + function lingvodocAPI($http, $q) { @@ -1112,6 +1130,44 @@ function lingvodocAPI($http, $q) { }; + var getUserBlobs = function() { + var deferred = $q.defer(); + $http.get('/blobs').success(function(data, status, headers, config) { + var blobs = _.map(data, lingvodoc.Blob.fromJS); + deferred.resolve(blobs); + }).error(function(data, status, headers, config) { + deferred.reject('Failed to convert dictionary'); + }); + return deferred.promise; + }; + + var checkDictionaryBlob = function(blob, parent) { + var deferred = $q.defer(); + var query = { + 'blob_client_id': blob.client_id, + 'blob_object_id': blob.object_id, + 'parent_client_id': parent.client_id, + 'parent_object_id': parent.object_id + }; + + $http.post('/convert_check', query).success(function(data, status, headers, config) { + var perspectives = _.map(data, lingvodoc.Perspective.fromJS); + deferred.resolve(perspectives); + }).error(function(data, status, headers, config) { + deferred.reject('Failed to convert dictionary'); + }); + return deferred.promise; + }; + + var convertDictionary = function(req) { + var deferred = $q.defer(); + $http.post('/convert', req).success(function(data, status, headers, config) { + deferred.resolve(data); + }).error(function(data, status, headers, config) { + deferred.reject('Failed to convert dictionary'); + }); + return deferred.promise; + }; // Return public API. @@ -1162,6 +1218,9 @@ function lingvodocAPI($http, $q) { 'deleteDictionaryRoles': deleteDictionaryRoles, 'getPerspectiveRoles': getPerspectiveRoles, 'addPerspectiveRoles': addPerspectiveRoles, - 'deletePerspectiveRoles': deletePerspectiveRoles + 'deletePerspectiveRoles': deletePerspectiveRoles, + 'getUserBlobs': getUserBlobs, + 'checkDictionaryBlob': checkDictionaryBlob, + 'convertDictionary': convertDictionary }); -}; +} diff --git a/webui/src/js/create_dictionary.js b/webui/src/js/create_dictionary.js index 44de4dfc9..2e0bd29f5 100755 --- a/webui/src/js/create_dictionary.js +++ b/webui/src/js/create_dictionary.js @@ -2,7 +2,7 @@ var app = angular.module('CreateDictionaryModule', ['ui.router', 'ngAnimate', 'u app.service('dictionaryService', lingvodocAPI); -app.config(function ($stateProvider, $urlRouterProvider) { +app.config(function($stateProvider, $urlRouterProvider) { $stateProvider @@ -32,7 +32,7 @@ app.config(function ($stateProvider, $urlRouterProvider) { app.factory('responseHandler', ['$timeout', '$modal', responseHandler]); -app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$interval', '$state', '$location', '$log', 'dictionaryService', 'responseHandler', function ($scope, $http, $modal, $interval, $state, $location, $log, dictionaryService, responseHandler) { +app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$interval', '$state', '$location', '$log', 'dictionaryService', 'responseHandler', function($scope, $http, $modal, $interval, $state, $location, $log, dictionaryService, responseHandler) { var clientId = $('#clientId').data('lingvodoc'); var userId = $('#userId').data('lingvodoc'); @@ -53,7 +53,7 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int $scope.uploadedDictionaries = []; - var flatLanguages = function (languages) { + var flatLanguages = function(languages) { var flat = []; for (var i = 0; i < languages.length; i++) { var language = languages[i]; @@ -66,7 +66,7 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int return flat; }; - var getLanguageById = function (id) { + var getLanguageById = function(id) { if (typeof id == 'string') { var ids = id.split('_'); for (var i = 0; i < $scope.languages.length; i++) { @@ -102,13 +102,13 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int // Event handlers - $scope.getLanguageId = function (language) { + $scope.getLanguageId = function(language) { if (language) { return language.client_id + '_' + language.object_id; } }; - $scope.newLanguage = function () { + $scope.newLanguage = function() { var modalInstance = $modal.open({ animation: true, templateUrl: 'createLanguageModal.html', @@ -116,21 +116,27 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int size: 'lg' }); - modalInstance.result.then(function (languageObj) { - $http.post(createLanguageUrl, languageObj).success(function (data, status, headers, config) { + modalInstance.result.then(function(languageObj) { + $http.post(createLanguageUrl, languageObj).success(function(data, status, headers, config) { loadLanguages(); - }).error(function (data, status, headers, config) { + }).error(function(data, status, headers, config) { alert('Failed to save language!'); }); - }, function () { + }, function() { }); }; - $scope.addField = function () { - $scope.perspective.fields.push({'entity_type': '', 'entity_type_translation': '', 'data_type': 'text', 'data_type_translation': 'text', 'status': 'enabled'}); + $scope.addField = function() { + $scope.perspective.fields.push({ + 'entity_type': '', + 'entity_type_translation': '', + 'data_type': 'text', + 'data_type_translation': 'text', + 'status': 'enabled' + }); }; - $scope.enableGroup = function (fieldIndex) { + $scope.enableGroup = function(fieldIndex) { if (typeof $scope.perspective.fields[fieldIndex].group === 'undefined') { $scope.perspective.fields[fieldIndex].group = ''; } else { @@ -138,7 +144,7 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int } }; - $scope.enableLinkedField = function (fieldIndex) { + $scope.enableLinkedField = function(fieldIndex) { if (typeof $scope.perspective.fields[fieldIndex].contains === 'undefined') { $scope.perspective.fields[fieldIndex].contains = [{ 'entity_type': '', @@ -152,6 +158,14 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int } }; + var convert = function(req) { + dictionaryService.convertDictionary(req).then(function(response) { + responseHandler.success(response); + }, function(reason) { + responseHandler.error(reason); + }); + }; + // Save dictionary $scope.createDictionary = function() { @@ -171,7 +185,7 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int $scope.controls.createDictionary = false; - $http.post(createDictionaryUrl, dictionaryObj).success(function (data, status, headers, config) { + $http.post(createDictionaryUrl, dictionaryObj).success(function(data, status, headers, config) { if (data.object_id && data.client_id) { $scope.dictionaryData.dictionary_client_id = data.client_id; @@ -183,7 +197,7 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int } $scope.controls.createDictionary = true; - }).error(function (data, status, headers, config) { + }).error(function(data, status, headers, config) { $scope.controls.createDictionary = true; responseHandler.error('Failed to create dictionary!'); }); @@ -196,21 +210,45 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int $scope.controls.createDictionary = false; - var ids = $scope.wizard.importedDictionaryId.split('_'); - var url = $('#convertUrl').data('lingvodoc'); - var convertObject = { - 'blob_client_id': parseInt(ids[0]), - 'blob_object_id': parseInt(ids[1]), - 'parent_client_id': language.client_id, - 'parent_object_id': language.object_id - }; + var blob = _.find($scope.uploadedDictionaries, function(d) { + return d.getId() == $scope.wizard.importedDictionaryId; + }); - $http.post(url, convertObject).success(function (data, status, headers, config) { - $scope.controls.createDictionary = true; - responseHandler.success(data.status); - }).error(function (data, status, headers, config) { - $scope.controls.createDictionary = true; - responseHandler.error(data); + dictionaryService.checkDictionaryBlob(blob, language).then(function(perspectives) { + + if (_.size(perspectives) > 0) { + + $modal.open({ + animation: true, + templateUrl: 'importModal.html', + controller: 'ImportController', + size: 'lg', + backdrop: 'static', + keyboard: false, + resolve: { + 'params': function() { + return { + 'perspectives': perspectives, + 'blob': blob, + 'language': language + }; + } + } + }).result.then(function(req) { + convert(req); + }, function() { + + }); + } else { + convert({ + 'blob_client_id': blob.client_id, + 'blob_object_id': blob.object_id, + 'parent_client_id': language.client_id, + 'parent_object_id': language.object_id + }); + } + }, function(reason) { + responseHandler.error(reason); }); } } @@ -261,10 +299,10 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int $scope.searchUsers = function(query) { - var promise = $http.get('/users?search=' + encodeURIComponent(query)).then(function (response) { + var promise = $http.get('/users?search=' + encodeURIComponent(query)).then(function(response) { return response.data; }); - promise.then(function(data){ + promise.then(function(data) { var userLogins = []; if (data.users) { for (var i = 0; i < data.users.length; i++) { @@ -287,37 +325,14 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int // Load list of languages var loadLanguages = function() { - $http.get(languagesUrl).success(function (data, status, headers, config) { + $http.get(languagesUrl).success(function(data, status, headers, config) { $scope.languages = flatLanguages(data.languages); - }).error(function (data, status, headers, config) { + }).error(function(data, status, headers, config) { // error handling }); }; - - var loadBlobs = function() { - $http.get(listBlobsUrl).success(function (data, status, headers, config) { - $scope.uploadedDictionaries = []; - - - for (var i = 0; i < data.length; i++) { - if (data[i].data_type='dialeqt_dictionary') { - var id = data[i].client_id + '_' + data[i].object_id; - - $scope.uploadedDictionaries.push({ - 'id': id, - 'data': data[i] - }); - } - } - - - }).error(function (data, status, headers, config) { - }); - }; - - - $scope.$watch('dictionaryData.perspectiveId', function (id) { + $scope.$watch('dictionaryData.perspectiveId', function(id) { if (typeof id == 'string') { for (var i = 0; i < $scope.perspectives.length; i++) { if ($scope.perspectives[i].getId() == id) { @@ -342,11 +357,21 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int loadLanguages(); - loadBlobs(); + + dictionaryService.getUserBlobs().then(function(blobs) { + + $scope.uploadedDictionaries = _.filter(blobs, function(e) { + return e.data_type == 'dialeqt_dictionary'; + }); + + }, function(reason) { + responseHandler.error(reason); + }); + }]); -app.controller('CreateLanguageController', ['$scope', '$http', '$interval', '$modalInstance', 'responseHandler', function ($scope, $http, $interval, $modalInstance, responseHandler) { +app.controller('CreateLanguageController', ['$scope', '$http', '$interval', '$modalInstance', 'responseHandler', function($scope, $http, $interval, $modalInstance, responseHandler) { var clientId = $('#clientId').data('lingvodoc'); var userId = $('#userId').data('lingvodoc'); @@ -358,7 +383,7 @@ app.controller('CreateLanguageController', ['$scope', '$http', '$interval', '$mo $scope.translation = ''; $scope.translationString = ''; - var getLanguageById = function (id) { + var getLanguageById = function(id) { var ids = id.split('_'); for (var i = 0; i < $scope.languages.length; i++) { if ($scope.languages[i].client_id == ids[0] && $scope.languages[i].object_id == ids[1]) @@ -366,7 +391,7 @@ app.controller('CreateLanguageController', ['$scope', '$http', '$interval', '$mo } }; - var flatLanguages = function (languages) { + var flatLanguages = function(languages) { var flat = []; for (var i = 0; i < languages.length; i++) { var language = languages[i]; @@ -379,13 +404,13 @@ app.controller('CreateLanguageController', ['$scope', '$http', '$interval', '$mo return flat; }; - $scope.getLanguageId = function (language) { + $scope.getLanguageId = function(language) { if (language) { return language.client_id + '_' + language.object_id; } }; - $scope.ok = function () { + $scope.ok = function() { if (!$scope.translation) { return; @@ -407,13 +432,124 @@ app.controller('CreateLanguageController', ['$scope', '$http', '$interval', '$mo $modalInstance.close(languageObj); }; - $scope.cancel = function () { + $scope.cancel = function() { $modalInstance.dismiss('cancel'); }; - $http.get(languagesUrl).success(function (data, status, headers, config) { + $http.get(languagesUrl).success(function(data, status, headers, config) { $scope.languages = flatLanguages(data.languages); - }).error(function (data, status, headers, config) { + }).error(function(data, status, headers, config) { // error handling }); -}]); \ No newline at end of file +}]); + +app.controller('ImportController', ['$scope', '$http', '$q', '$log', '$modalInstance', 'dictionaryService', 'responseHandler', 'params', function($scope, $http, $q, $log, $modalInstance, dictionaryService, responseHandler, params) { + + $scope.mode = 'create'; + $scope.perspectives = params.perspectives; + $scope.paths = []; + $scope.import = {}; + $scope.import.dictionaryId = ''; + $scope.import.perspectiveId = ''; + $scope.import.createNewPerspective = false; + + + var getSelectedPerspective = function() { + return _.find($scope.perspectives, function(e) { + return e.getId() === $scope.import.perspectiveId; + }); + }; + + var getSelectedDictionary = function() { + return _.find($scope.dictionaries, function(e) { + return e.getId() === $scope.import.dictionaryId; + }); + }; + + $scope.ok = function() { + + var req = { + 'blob_client_id': params.blob.client_id, + 'blob_object_id': params.blob.object_id, + 'parent_client_id': params.language.client_id, + 'parent_object_id': params.language.object_id + }; + + if ($scope.mode === 'import') { + + var dictionary = getSelectedDictionary(); + if (dictionary) { + + req.dictionary_client_id = dictionary.client_id; + req.dictionary_object_id = dictionary.object_id; + + if (!$scope.import.createNewPerspective) { + + var perspective = getSelectedPerspective(); + if (perspective) { + req.perspective_client_id = perspective.client_id; + req.perspective_object_id = perspective.object_id; + } else { + responseHandler.error('Please, select perspective.'); + return; + } + } + } else { + responseHandler.error('Please, select dictionary.'); + return; + } + } + $modalInstance.close(req); + }; + + $scope.cancel = function() { + $modalInstance.dismiss('cancel'); + }; + + + $scope.$watch('import.dictionaryId', function(id) { + + var dictionary = _.find($scope.dictionaries, function(d) { + return d.getId() === id; + }); + + if (dictionary) { + $scope.perspectives = _.filter(params.perspectives, function(p) { + return p.parent_client_id == dictionary.client_id && p.parent_object_id == dictionary.object_id; + }); + } + }); + + // load list of dictionaries + var r = params.perspectives.map(function(perspective) { + return dictionaryService.getPerspectiveOriginById(perspective.client_id, perspective.parent_object_id); + }); + + $q.all(r).then(function(paths) { + $scope.paths = paths; + var dictionaries = _.reduce(paths, function(acc, path) { + var pathDicts = _.filter(path, function(e) { + return e.type === 'dictionary'; + }); + _.each(pathDicts, function(d) { + acc.push(d); + }); + + return acc; + }, []); + + // remove duplicates + $scope.dictionaries = _.uniq(dictionaries, function(d, key, a) { + return d.getId(); + }); + + }, function(reason) { + responseHandler.error(reason); + }); + + +}]); + + + + diff --git a/webui/src/js/edit_dictionary.js b/webui/src/js/edit_dictionary.js index 03c0aacb8..21d576fc3 100755 --- a/webui/src/js/edit_dictionary.js +++ b/webui/src/js/edit_dictionary.js @@ -758,7 +758,6 @@ angular.module('EditDictionaryModule', ['ui.bootstrap']) var entryObject = value.export(); - // TODO: get locale_id from cookies entryObject['entity_type'] = field.entity_type; entryObject['locale_id'] = getCookie('locale_id'); diff --git a/webui/src/js/response_handler.js b/webui/src/js/response_handler.js index bd4a92f33..5e8bf980f 100755 --- a/webui/src/js/response_handler.js +++ b/webui/src/js/response_handler.js @@ -28,7 +28,7 @@ function responseHandler($timeout, $modal) { } function success(message) { - show('success', message, 500); + show('success', message, 5000); } function error(message) { diff --git a/webui/src/templates/create_dictionary.pt b/webui/src/templates/create_dictionary.pt index 77012e877..fc3f38cf5 100755 --- a/webui/src/templates/create_dictionary.pt +++ b/webui/src/templates/create_dictionary.pt @@ -82,11 +82,12 @@
(Upload dictionary) - + -
+ @@ -327,6 +328,68 @@ + + + + + + + + + + + + + + + + + +
From a7bde5461318b6864528156e661df262b59c8eb8 Mon Sep 17 00:00:00 2001 From: "A. Tapekhin" Date: Sat, 14 Nov 2015 12:24:02 +0300 Subject: [PATCH 11/73] additional metadata fix --- lingvodoc/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lingvodoc/views.py b/lingvodoc/views.py index 65f6bfe1b..bae9ef577 100755 --- a/lingvodoc/views.py +++ b/lingvodoc/views.py @@ -645,8 +645,8 @@ def view_perspective(request): response['marked_for_deletion'] = perspective.marked_for_deletion response['is_template'] = perspective.is_template response['additional_metadata'] = perspective.additional_metadata - meta = json.loads(perspective.additional_metadata) - if meta: + if perspective.additional_metadata: + meta = json.loads(perspective.additional_metadata) if 'latitude' in meta: response['latitude'] = meta['latitude'] if 'longitude' in meta: From 020e4ee923e4de2e995dce44fa41ba76190cd8c5 Mon Sep 17 00:00:00 2001 From: "A. Tapekhin" Date: Sat, 14 Nov 2015 13:27:30 +0300 Subject: [PATCH 12/73] more metadata fixes --- lingvodoc/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lingvodoc/views.py b/lingvodoc/views.py index c7a33d8a8..ee4acf69a 100755 --- a/lingvodoc/views.py +++ b/lingvodoc/views.py @@ -2333,7 +2333,7 @@ def create_entities_bulk(request): object_id=DBSession.query(LevelOneEntity).filter_by(client_id=client.id).count() + 1, entity_type=item['entity_type'], locale_id=item['locale_id'], - additional_metadata=json.dumps(item.get('additional_metadata')), + additional_metadata=item.get('additional_metadata'), parent=parent) elif item['level'] == 'groupingentity': parent = DBSession.query(LexicalEntry).filter_by(client_id=item['parent_client_id'], object_id=item['parent_object_id']).first() @@ -2341,7 +2341,7 @@ def create_entities_bulk(request): object_id=DBSession.query(GroupingEntity).filter_by(client_id=client.id).count() + 1, entity_type=item['entity_type'], locale_id=item['locale_id'], - additional_metadata=json.dumps(item.get('additional_metadata')), + additional_metadata=item.get('additional_metadata'), parent=parent) elif item['level'] == 'leveltwoentity': parent = DBSession.query(LevelOneEntity).filter_by(client_id=item['parent_client_id'], object_id=item['parent_object_id']).first() @@ -2349,7 +2349,7 @@ def create_entities_bulk(request): object_id=DBSession.query(LevelTwoEntity).filter_by(client_id=client.id).count() + 1, entity_type=item['entity_type'], locale_id=item['locale_id'], - additional_metadata=json.dumps(item.get('additional_metadata')), + additional_metadata=item.get('additional_metadata'), parent=parent) DBSession.add(entity) DBSession.flush() From 7a02923a89720eee6024e0437b2655c2266e6999 Mon Sep 17 00:00:00 2001 From: "A. Tapekhin" Date: Sat, 14 Nov 2015 16:05:01 +0300 Subject: [PATCH 13/73] search by meta fix --- lingvodoc/scripts/lingvodoc_converter.py | 20 ++++++++++++-------- lingvodoc/views.py | 19 +++++++++---------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/lingvodoc/scripts/lingvodoc_converter.py b/lingvodoc/scripts/lingvodoc_converter.py index e3d3a7f33..8eeaf678f 100644 --- a/lingvodoc/scripts/lingvodoc_converter.py +++ b/lingvodoc/scripts/lingvodoc_converter.py @@ -43,16 +43,17 @@ def upload_markup(upload_url, search_url, markup_sequence, session): for entry in markup_sequence: audio_hash = entry[0] markup_element = entry[1] - entity_metadata_search = search_url + '?hash=%s' % audio_hash # add filters by perspective. Maybe where search_url is created + entity_metadata_search = search_url + '&searchstring=%s' % audio_hash # add filters by perspective. Maybe where search_url is created status = session.get(entity_metadata_search) ents = json.loads(status.text) if 'error' not in ents: if type(ents) == list and len(ents) >= 1: existing_entity = ents[0] - parent_client_id = existing_entity['client_id'] - parent_object_id = existing_entity['object_id'] - markup_element["parent_client_id"] = parent_client_id - markup_element["parent_object_id"] = parent_object_id + if existing_entity: + parent_client_id = existing_entity['client_id'] + parent_object_id = existing_entity['object_id'] + markup_element["parent_client_id"] = parent_client_id + markup_element["parent_object_id"] = parent_object_id new_markup_sequence = [o[1] for o in markup_sequence if o[1].get["parent_client_id"]] result = [o for o in markup_sequence if o[1].get["parent_client_id"] is None] status = session.post(upload_url, json=new_markup_sequence) @@ -143,6 +144,7 @@ def upload_audio_with_markup(session, ids_mapping, sound_and_markup_cursor, uplo markup_sequence.append(markup_element) else: if markup_hash not in markup_hashes: + print('sound exists, but markup doesn\'t') markup_hashes.add(markup_hash) markup_element = { @@ -172,8 +174,8 @@ def upload_audio_with_markup(session, ids_mapping, sound_and_markup_cursor, uplo markup_sequence = [] if len(markup__without_audio_sequence) != 0: - upload_markup(upload_url, search_url, markup__without_audio_sequence, session) - markup__without_audio_sequence = [] + markup__without_audio_sequence = upload_markup(upload_url, search_url, markup__without_audio_sequence, session) + def change_dict_status(session, converting_status_url, status): @@ -312,7 +314,9 @@ def prepare_and_upload_text_entities(id_column, is_a_regular_form, text_column, dictionary['object_id'], perspective['client_id'], perspective['object_id']) - search_url = server_url + 'meta_search' + search_url = server_url + 'meta_search' \ + '?perspective_client_id=%d&perspective_object_id=%d' % (perspective['client_id'], + perspective['object_id']) status = session.get(perspective_search) lexes = json.loads(status.text)['lexical_entries'] sound_types = ['Sound', 'Paradigm sound'] diff --git a/lingvodoc/views.py b/lingvodoc/views.py index ee4acf69a..fb9c9e019 100755 --- a/lingvodoc/views.py +++ b/lingvodoc/views.py @@ -107,19 +107,19 @@ def __str__(self): @view_config(route_name='entity_metadata_search', renderer='json', request_method='GET') def entity_metadata_search(request): # TODO: add same check for permission as in basic_search - # TODO: add filters to search in only one perspective searchstring = request.params.get('searchstring') + if type(searchstring) != str: + searchstring = str(searchstring) + searchtype = request.params.get('searchtype') - client_id = request.params.get('perspective_client_id') - object_id = request.params.get('perspective_object_id') + perspective_client_id = request.params.get('perspective_client_id') + perspective_object_id = request.params.get('perspective_object_id') results_cursor = DBSession.query(LevelOneEntity)\ .filter(LevelOneEntity.entity_type == searchtype, - LevelOneEntity.additional_metadata.like('%'+searchstring+'%'))\ - .all() - results_cursor += DBSession.query(LevelTwoEntity)\ - .filter(LevelTwoEntity.entity_type == searchtype, - LevelTwoEntity.additional_metadata.like('%'+searchstring+'%'))\ - .all() + LevelOneEntity.additional_metadata.like('%'+searchstring+'%')) + if perspective_client_id and perspective_object_id: + results_cursor = results_cursor.filter(DictionaryPerspective.client_id == perspective_client_id, + DictionaryPerspective.object_id == perspective_object_id) results = [] entries = set() for item in results_cursor: @@ -127,7 +127,6 @@ def entity_metadata_search(request): for entry in entries: if not entry.marked_for_deletion: result = dict() - result['level'] = str(type(entry)).lower() result['client_id'] = entry.client_id result['object_id'] = entry.object_id result['additional_metadata'] = entry.additional_metadata From 543093bc26f980c74545ea8af5fce4c7dd3f472f Mon Sep 17 00:00:00 2001 From: Steve Ipatov Date: Mon, 16 Nov 2015 14:46:18 +0300 Subject: [PATCH 14/73] redirect to dashboard --- webui/src/js/create_dictionary.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/webui/src/js/create_dictionary.js b/webui/src/js/create_dictionary.js index 2e0bd29f5..f84ebf818 100755 --- a/webui/src/js/create_dictionary.js +++ b/webui/src/js/create_dictionary.js @@ -32,7 +32,7 @@ app.config(function($stateProvider, $urlRouterProvider) { app.factory('responseHandler', ['$timeout', '$modal', responseHandler]); -app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$interval', '$state', '$location', '$log', 'dictionaryService', 'responseHandler', function($scope, $http, $modal, $interval, $state, $location, $log, dictionaryService, responseHandler) { +app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$interval', '$state', '$window', '$log', 'dictionaryService', 'responseHandler', function($scope, $http, $modal, $interval, $state, $window, $log, dictionaryService, responseHandler) { var clientId = $('#clientId').data('lingvodoc'); var userId = $('#userId').data('lingvodoc'); @@ -161,6 +161,9 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int var convert = function(req) { dictionaryService.convertDictionary(req).then(function(response) { responseHandler.success(response); + $window.location.href = '/dashboard'; + + }, function(reason) { responseHandler.error(reason); }); From 487b621b66fdd848f438e96a481c59423a61d864 Mon Sep 17 00:00:00 2001 From: "A. Tapekhin" Date: Tue, 17 Nov 2015 15:06:10 +0300 Subject: [PATCH 15/73] markup upload in converter fix --- lingvodoc/scripts/lingvodoc_converter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lingvodoc/scripts/lingvodoc_converter.py b/lingvodoc/scripts/lingvodoc_converter.py index 8eeaf678f..6fdb08483 100644 --- a/lingvodoc/scripts/lingvodoc_converter.py +++ b/lingvodoc/scripts/lingvodoc_converter.py @@ -54,8 +54,8 @@ def upload_markup(upload_url, search_url, markup_sequence, session): parent_object_id = existing_entity['object_id'] markup_element["parent_client_id"] = parent_client_id markup_element["parent_object_id"] = parent_object_id - new_markup_sequence = [o[1] for o in markup_sequence if o[1].get["parent_client_id"]] - result = [o for o in markup_sequence if o[1].get["parent_client_id"] is None] + new_markup_sequence = [o[1] for o in markup_sequence if o[1].get("parent_client_id")] + result = [o for o in markup_sequence if o[1].get("parent_client_id") is None] status = session.post(upload_url, json=new_markup_sequence) log.debug(status.text) return result From aede1cff03fe60aca071ae318363e6a453aa6648 Mon Sep 17 00:00:00 2001 From: "A. Tapekhin" Date: Tue, 17 Nov 2015 16:34:37 +0300 Subject: [PATCH 16/73] perspective meta get put delete --- lingvodoc/__init__.py | 10 ++ lingvodoc/scripts/lingvodoc_converter.py | 17 +-- lingvodoc/views.py | 174 ++++++++++++++++++++++- 3 files changed, 188 insertions(+), 13 deletions(-) diff --git a/lingvodoc/__init__.py b/lingvodoc/__init__.py index 1872ee85f..1da7101a7 100755 --- a/lingvodoc/__init__.py +++ b/lingvodoc/__init__.py @@ -159,6 +159,13 @@ def configure_routes(config): config.add_route(name='perspective_outside', pattern='perspective/{perspective_client_id}/{perspective_id}', factory='lingvodoc.models.PerspectiveAcl') + # API #GET && PUT && DELETE + # {:{"type"", "content":},} + # for geo: {"location":{"type":"location", "content":{"lat":, "lng":}}} + config.add_route(name='perspective_meta', + pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}/' + 'perspective/{perspective_client_id}/{perspective_id}/meta', + factory='lingvodoc.models.PerspectiveAcl') config.add_route(name='perspective_tree', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}/' @@ -306,6 +313,9 @@ def configure_routes(config): # perspective_object_id config.add_route(name='basic_search', pattern='/basic_search') + # API #POST + config.add_route(name='advanced_search', pattern='/advanced_search') + # API #GET # like config.add_route(name='entity_metadata_search', pattern='/meta_search') diff --git a/lingvodoc/scripts/lingvodoc_converter.py b/lingvodoc/scripts/lingvodoc_converter.py index 6fdb08483..83e0d223b 100644 --- a/lingvodoc/scripts/lingvodoc_converter.py +++ b/lingvodoc/scripts/lingvodoc_converter.py @@ -41,19 +41,20 @@ def upload_audio(upload_url, audio_sequence, markup_sequence, session): def upload_markup(upload_url, search_url, markup_sequence, session): log = logging.getLogger(__name__) for entry in markup_sequence: + print('in upload markup') audio_hash = entry[0] markup_element = entry[1] entity_metadata_search = search_url + '&searchstring=%s' % audio_hash # add filters by perspective. Maybe where search_url is created status = session.get(entity_metadata_search) ents = json.loads(status.text) - if 'error' not in ents: - if type(ents) == list and len(ents) >= 1: - existing_entity = ents[0] - if existing_entity: - parent_client_id = existing_entity['client_id'] - parent_object_id = existing_entity['object_id'] - markup_element["parent_client_id"] = parent_client_id - markup_element["parent_object_id"] = parent_object_id + if ents: + existing_entity = ents[0] + if existing_entity: + parent_client_id = existing_entity['client_id'] + parent_object_id = existing_entity['object_id'] + print('parent_client_id', parent_client_id, 'parent_object_id', parent_object_id) + markup_element["parent_client_id"] = parent_client_id + markup_element["parent_object_id"] = parent_object_id new_markup_sequence = [o[1] for o in markup_sequence if o[1].get("parent_client_id")] result = [o for o in markup_sequence if o[1].get("parent_client_id") is None] status = session.post(upload_url, json=new_markup_sequence) diff --git a/lingvodoc/views.py b/lingvodoc/views.py index fb9c9e019..771a1c033 100755 --- a/lingvodoc/views.py +++ b/lingvodoc/views.py @@ -110,10 +110,10 @@ def entity_metadata_search(request): searchstring = request.params.get('searchstring') if type(searchstring) != str: searchstring = str(searchstring) - searchtype = request.params.get('searchtype') perspective_client_id = request.params.get('perspective_client_id') perspective_object_id = request.params.get('perspective_object_id') + print('trying to search', searchstring) results_cursor = DBSession.query(LevelOneEntity)\ .filter(LevelOneEntity.entity_type == searchtype, LevelOneEntity.additional_metadata.like('%'+searchstring+'%')) @@ -230,6 +230,73 @@ def basic_search(request): return {'error': 'search is too short'} +@view_config(route_name='advanced_search', renderer='json', request_method='POST') +def advanced_search_search(request): + can_add_tags = request.params.get('can_add_tags') + searchstring = request.params.get('leveloneentity') + perspective_client_id = request.params.get('perspective_client_id') + perspective_object_id = request.params.get('perspective_object_id') + if searchstring: + if len(searchstring) >= 2: + searchstring = request.params.get('leveloneentity') + group = DBSession.query(Group).filter(Group.subject_override == True).join(BaseGroup)\ + .filter(BaseGroup.subject=='lexical_entries_and_entities', BaseGroup.action=='view')\ + .join(User, Group.users).join(Client)\ + .filter(Client.id == request.authenticated_userid).first() + if group: + results_cursor = DBSession.query(LevelOneEntity).filter(LevelOneEntity.content.like('%'+searchstring+'%')) + if perspective_client_id and perspective_object_id: + results_cursor = results_cursor.join(LexicalEntry)\ + .join(DictionaryPerspective)\ + .filter(DictionaryPerspective.client_id == perspective_client_id, + DictionaryPerspective.object_id == perspective_object_id) + else: + results_cursor = DBSession.query(LevelOneEntity)\ + .join(LexicalEntry)\ + .join(DictionaryPerspective) + if perspective_client_id and perspective_object_id: + results_cursor = results_cursor.filter(DictionaryPerspective.client_id == perspective_client_id, + DictionaryPerspective.object_id == perspective_object_id) + results_cursor = results_cursor.join(Group, and_(DictionaryPerspective.client_id == Group.subject_client_id, DictionaryPerspective.object_id == Group.subject_object_id ))\ + .join(BaseGroup)\ + .join(User, Group.users)\ + .join(Client)\ + .filter(Client.id == request.authenticated_userid, LevelOneEntity.content.like('%'+searchstring+'%')) + results = [] + entries = set() + if can_add_tags: + results_cursor = results_cursor\ + .filter(BaseGroup.subject=='lexical_entries_and_entities', + or_(BaseGroup.action=='create', BaseGroup.action=='view'))\ + .group_by(LevelOneEntity).having(func.count('*') == 2) + else: + results_cursor = results_cursor.filter(BaseGroup.subject=='lexical_entries_and_entities', BaseGroup.action=='view') + for item in results_cursor: + entries.add(item.parent) + for entry in entries: + if not entry.marked_for_deletion: + result = dict() + result['lexical_entry'] = entry.track(False) + result['client_id'] = entry.parent_client_id + result['object_id'] = entry.parent_object_id + perspective_tr = entry.parent.get_translation(request) + result['translation_string'] = perspective_tr['translation_string'] + result['translation'] = perspective_tr['translation'] + result['is_template'] = entry.parent.is_template + result['status'] = entry.parent.state + result['marked_for_deletion'] = entry.parent.marked_for_deletion + result['parent_client_id'] = entry.parent.parent_client_id + result['parent_object_id'] = entry.parent.parent_object_id + dict_tr = entry.parent.parent.get_translation(request) + result['parent_translation_string'] = dict_tr['translation_string'] + result['parent_translation'] = dict_tr['translation'] + results.append(result) + request.response.status = HTTPOk.code + return results + request.response.status = HTTPBadRequest.code + return {'error': 'search is too short'} + + #TODO: make it normal, it's just a test @view_config(route_name='convert_dictionary_old', renderer='json', request_method='POST') def convert_dictionary_old(request): @@ -753,10 +820,8 @@ def view_perspective(request): response['additional_metadata'] = perspective.additional_metadata if perspective.additional_metadata: meta = json.loads(perspective.additional_metadata) - if 'latitude' in meta: - response['latitude'] = meta['latitude'] - if 'longitude' in meta: - response['longitude'] = meta['longitude'] + if 'location' in meta: + response['location'] = meta['location'] request.response.status = HTTPOk.code return response request.response.status = HTTPNotFound.code @@ -830,6 +895,105 @@ def view_perspective_tree(request): return {'error': str("No such perspective in the system")} +@view_config(route_name='perspective_meta', renderer='json', request_method='PUT', permission='edit') +def edit_perspective_meta(request): + response = dict() + client_id = request.matchdict.get('perspective_client_id') + object_id = request.matchdict.get('perspective_id') + client = DBSession.query(Client).filter_by(id=request.authenticated_userid).first() + if not client: + raise KeyError("Invalid client id (not registered on server). Try to logout and then login.") + parent_client_id = request.matchdict.get('dictionary_client_id') + parent_object_id = request.matchdict.get('dictionary_object_id') + parent = DBSession.query(Dictionary).filter_by(client_id=parent_client_id, object_id=parent_object_id).first() + if not parent: + request.response.status = HTTPNotFound.code + return {'error': str("No such dictionary in the system")} + + perspective = DBSession.query(DictionaryPerspective).filter_by(client_id=client_id, object_id=object_id).first() + if perspective: + if not perspective.marked_for_deletion: + if perspective.parent != parent: + request.response.status = HTTPNotFound.code + return {'error': str("No such pair of dictionary/perspective in the system")} + req = request.json_body + + old_meta = json.loads(perspective.additional_metadata) + new_meta = req + old_meta.update(new_meta) + perspective.additional_metadata = json.dumps(old_meta) + request.response.status = HTTPOk.code + return response + request.response.status = HTTPNotFound.code + return {'error': str("No such perspective in the system")} + + +@view_config(route_name='perspective_meta', renderer='json', request_method='DELETE', permission='edit') +def delete_perspective_meta(request): + response = dict() + client_id = request.matchdict.get('perspective_client_id') + object_id = request.matchdict.get('perspective_id') + client = DBSession.query(Client).filter_by(id=request.authenticated_userid).first() + if not client: + raise KeyError("Invalid client id (not registered on server). Try to logout and then login.") + parent_client_id = request.matchdict.get('dictionary_client_id') + parent_object_id = request.matchdict.get('dictionary_object_id') + parent = DBSession.query(Dictionary).filter_by(client_id=parent_client_id, object_id=parent_object_id).first() + if not parent: + request.response.status = HTTPNotFound.code + return {'error': str("No such dictionary in the system")} + + perspective = DBSession.query(DictionaryPerspective).filter_by(client_id=client_id, object_id=object_id).first() + if perspective: + if not perspective.marked_for_deletion: + if perspective.parent != parent: + request.response.status = HTTPNotFound.code + return {'error': str("No such pair of dictionary/perspective in the system")} + req = request.json_body + + old_meta = json.loads(perspective.additional_metadata) + new_meta = req + for entry in new_meta: + if entry in old_meta: + del old_meta[entry] + perspective.additional_metadata = json.dumps(old_meta) + request.response.status = HTTPOk.code + return response + request.response.status = HTTPNotFound.code + return {'error': str("No such perspective in the system")} + + +@view_config(route_name='perspective_meta', renderer='json', request_method='GET', permission='edit') +def view_perspective_meta(request): + response = dict() + client_id = request.matchdict.get('perspective_client_id') + object_id = request.matchdict.get('perspective_id') + client = DBSession.query(Client).filter_by(id=request.authenticated_userid).first() + if not client: + raise KeyError("Invalid client id (not registered on server). Try to logout and then login.") + parent_client_id = request.matchdict.get('dictionary_client_id') + parent_object_id = request.matchdict.get('dictionary_object_id') + parent = DBSession.query(Dictionary).filter_by(client_id=parent_client_id, object_id=parent_object_id).first() + if not parent: + request.response.status = HTTPNotFound.code + return {'error': str("No such dictionary in the system")} + + perspective = DBSession.query(DictionaryPerspective).filter_by(client_id=client_id, object_id=object_id).first() + if perspective: + if not perspective.marked_for_deletion: + if perspective.parent != parent: + request.response.status = HTTPNotFound.code + return {'error': str("No such pair of dictionary/perspective in the system")} + + old_meta = json.loads(perspective.additional_metadata) + response = old_meta + request.response.status = HTTPOk.code + return response + request.response.status = HTTPNotFound.code + return {'error': str("No such perspective in the system")} + + + @view_config(route_name='perspective', renderer='json', request_method='PUT', permission='edit') def edit_perspective(request): try: From 79db5d7b3863d639dfe545c182d96f72cde90839 Mon Sep 17 00:00:00 2001 From: Steve Ipatov Date: Tue, 17 Nov 2015 16:52:47 +0300 Subject: [PATCH 17/73] geo labels --- lingvodoc/__init__.py | 3 + lingvodoc/static/js/create-dictionary.js | 5200 ++- lingvodoc/static/js/dashboard.js | 13534 +++++--- lingvodoc/static/js/edit-dictionary.js | 4912 ++- lingvodoc/static/js/home.js | 69 +- lingvodoc/static/js/languages.js | 318 +- lingvodoc/static/js/login.js | 69 +- lingvodoc/static/js/maps.js | 33823 ++++++++++++++++++++ lingvodoc/static/js/merge-master.js | 69 +- lingvodoc/static/js/organizations.js | 318 +- lingvodoc/static/js/profile.js | 318 +- lingvodoc/static/js/publish-dictionary.js | 101 +- lingvodoc/static/js/user-upload.js | 101 +- lingvodoc/static/js/view-dictionary.js | 101 +- lingvodoc/templates/dashboard.pt | 35 + lingvodoc/templates/maps.pt | 48 + lingvodoc/views.py | 10 + webui/Gruntfile.js | 25 +- webui/bower.json | 4 +- webui/src/js/create_dictionary.js | 2 +- webui/src/js/dashboard.js | 56 +- webui/src/js/maps.js | 23 + webui/src/templates/dashboard.pt | 35 + webui/src/templates/maps.pt | 48 + 24 files changed, 51719 insertions(+), 7503 deletions(-) create mode 100644 lingvodoc/static/js/maps.js create mode 100644 lingvodoc/templates/maps.pt create mode 100755 webui/src/js/maps.js create mode 100755 webui/src/templates/maps.pt diff --git a/lingvodoc/__init__.py b/lingvodoc/__init__.py index 1872ee85f..f97f33f92 100755 --- a/lingvodoc/__init__.py +++ b/lingvodoc/__init__.py @@ -56,6 +56,9 @@ def configure_routes(config): # web-view #GET config.add_route(name='languages', pattern='/languages/map') + # web-view #GET + config.add_route(name='maps', pattern='/dashboard/maps') + # API #GET && PUT && DELETE # Gets/puts info about language config.add_route(name='language', pattern='/language/{client_id}/{object_id}', diff --git a/lingvodoc/static/js/create-dictionary.js b/lingvodoc/static/js/create-dictionary.js index 09215eb64..984a3c01b 100644 --- a/lingvodoc/static/js/create-dictionary.js +++ b/lingvodoc/static/js/create-dictionary.js @@ -5378,1056 +5378,3943 @@ }); (function() { - var root = this; - var previousUnderscore = root._; - var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; - var push = ArrayProto.push, slice = ArrayProto.slice, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty; - var nativeIsArray = Array.isArray, nativeKeys = Object.keys, nativeBind = FuncProto.bind, nativeCreate = Object.create; - var Ctor = function() {}; - var _ = function(obj) { - if (obj instanceof _) return obj; - if (!(this instanceof _)) return new _(obj); - this._wrapped = obj; - }; - if (typeof exports !== "undefined") { - if (typeof module !== "undefined" && module.exports) { - exports = module.exports = _; - } - exports._ = _; - } else { - root._ = _; + var undefined; + var VERSION = "3.10.1"; + var BIND_FLAG = 1, BIND_KEY_FLAG = 2, CURRY_BOUND_FLAG = 4, CURRY_FLAG = 8, CURRY_RIGHT_FLAG = 16, PARTIAL_FLAG = 32, PARTIAL_RIGHT_FLAG = 64, ARY_FLAG = 128, REARG_FLAG = 256; + var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = "..."; + var HOT_COUNT = 150, HOT_SPAN = 16; + var LARGE_ARRAY_SIZE = 200; + var LAZY_FILTER_FLAG = 1, LAZY_MAP_FLAG = 2; + var FUNC_ERROR_TEXT = "Expected a function"; + var PLACEHOLDER = "__lodash_placeholder__"; + var argsTag = "[object Arguments]", arrayTag = "[object Array]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", mapTag = "[object Map]", numberTag = "[object Number]", objectTag = "[object Object]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", weakMapTag = "[object WeakMap]"; + var arrayBufferTag = "[object ArrayBuffer]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]"; + var reEmptyStringLeading = /\b__p \+= '';/g, reEmptyStringMiddle = /\b(__p \+=) '' \+/g, reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; + var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g, reUnescapedHtml = /[&<>"'`]/g, reHasEscapedHtml = RegExp(reEscapedHtml.source), reHasUnescapedHtml = RegExp(reUnescapedHtml.source); + var reEscape = /<%-([\s\S]+?)%>/g, reEvaluate = /<%([\s\S]+?)%>/g, reInterpolate = /<%=([\s\S]+?)%>/g; + var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g; + var reRegExpChars = /^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g, reHasRegExpChars = RegExp(reRegExpChars.source); + var reComboMark = /[\u0300-\u036f\ufe20-\ufe23]/g; + var reEscapeChar = /\\(\\)?/g; + var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; + var reFlags = /\w*$/; + var reHasHexPrefix = /^0[xX]/; + var reIsHostCtor = /^\[object .+?Constructor\]$/; + var reIsUint = /^\d+$/; + var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; + var reNoMatch = /($^)/; + var reUnescapedString = /['\n\r\u2028\u2029\\]/g; + var reWords = function() { + var upper = "[A-Z\\xc0-\\xd6\\xd8-\\xde]", lower = "[a-z\\xdf-\\xf6\\xf8-\\xff]+"; + return RegExp(upper + "+(?=" + upper + lower + ")|" + upper + "?" + lower + "|" + upper + "+|[0-9]+", "g"); + }(); + var contextProps = [ "Array", "ArrayBuffer", "Date", "Error", "Float32Array", "Float64Array", "Function", "Int8Array", "Int16Array", "Int32Array", "Math", "Number", "Object", "RegExp", "Set", "String", "_", "clearTimeout", "isFinite", "parseFloat", "parseInt", "setTimeout", "TypeError", "Uint8Array", "Uint8ClampedArray", "Uint16Array", "Uint32Array", "WeakMap" ]; + var templateCounter = -1; + var typedArrayTags = {}; + typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; + typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; + var cloneableTags = {}; + cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[stringTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; + cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[mapTag] = cloneableTags[setTag] = cloneableTags[weakMapTag] = false; + var deburredLetters = { + "À": "A", + "Á": "A", + "Â": "A", + "Ã": "A", + "Ä": "A", + "Å": "A", + "à": "a", + "á": "a", + "â": "a", + "ã": "a", + "ä": "a", + "å": "a", + "Ç": "C", + "ç": "c", + "Ð": "D", + "ð": "d", + "È": "E", + "É": "E", + "Ê": "E", + "Ë": "E", + "è": "e", + "é": "e", + "ê": "e", + "ë": "e", + "Ì": "I", + "Í": "I", + "Î": "I", + "Ï": "I", + "ì": "i", + "í": "i", + "î": "i", + "ï": "i", + "Ñ": "N", + "ñ": "n", + "Ò": "O", + "Ó": "O", + "Ô": "O", + "Õ": "O", + "Ö": "O", + "Ø": "O", + "ò": "o", + "ó": "o", + "ô": "o", + "õ": "o", + "ö": "o", + "ø": "o", + "Ù": "U", + "Ú": "U", + "Û": "U", + "Ü": "U", + "ù": "u", + "ú": "u", + "û": "u", + "ü": "u", + "Ý": "Y", + "ý": "y", + "ÿ": "y", + "Æ": "Ae", + "æ": "ae", + "Þ": "Th", + "þ": "th", + "ß": "ss" + }; + var htmlEscapes = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + "`": "`" + }; + var htmlUnescapes = { + "&": "&", + "<": "<", + ">": ">", + """: '"', + "'": "'", + "`": "`" + }; + var objectTypes = { + "function": true, + object: true + }; + var regexpEscapes = { + "0": "x30", + "1": "x31", + "2": "x32", + "3": "x33", + "4": "x34", + "5": "x35", + "6": "x36", + "7": "x37", + "8": "x38", + "9": "x39", + A: "x41", + B: "x42", + C: "x43", + D: "x44", + E: "x45", + F: "x46", + a: "x61", + b: "x62", + c: "x63", + d: "x64", + e: "x65", + f: "x66", + n: "x6e", + r: "x72", + t: "x74", + u: "x75", + v: "x76", + x: "x78" + }; + var stringEscapes = { + "\\": "\\", + "'": "'", + "\n": "n", + "\r": "r", + "\u2028": "u2028", + "\u2029": "u2029" + }; + var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; + var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; + var freeGlobal = freeExports && freeModule && typeof global == "object" && global && global.Object && global; + var freeSelf = objectTypes[typeof self] && self && self.Object && self; + var freeWindow = objectTypes[typeof window] && window && window.Object && window; + var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; + var root = freeGlobal || freeWindow !== (this && this.window) && freeWindow || freeSelf || this; + function baseCompareAscending(value, other) { + if (value !== other) { + var valIsNull = value === null, valIsUndef = value === undefined, valIsReflexive = value === value; + var othIsNull = other === null, othIsUndef = other === undefined, othIsReflexive = other === other; + if (value > other && !othIsNull || !valIsReflexive || valIsNull && !othIsUndef && othIsReflexive || valIsUndef && othIsReflexive) { + return 1; + } + if (value < other && !valIsNull || !othIsReflexive || othIsNull && !valIsUndef && valIsReflexive || othIsUndef && valIsReflexive) { + return -1; + } + } + return 0; } - _.VERSION = "1.8.3"; - var optimizeCb = function(func, context, argCount) { - if (context === void 0) return func; - switch (argCount == null ? 3 : argCount) { - case 1: - return function(value) { - return func.call(context, value); + function baseFindIndex(array, predicate, fromRight) { + var length = array.length, index = fromRight ? length : -1; + while (fromRight ? index-- : ++index < length) { + if (predicate(array[index], index, array)) { + return index; + } + } + return -1; + } + function baseIndexOf(array, value, fromIndex) { + if (value !== value) { + return indexOfNaN(array, fromIndex); + } + var index = fromIndex - 1, length = array.length; + while (++index < length) { + if (array[index] === value) { + return index; + } + } + return -1; + } + function baseIsFunction(value) { + return typeof value == "function" || false; + } + function baseToString(value) { + return value == null ? "" : value + ""; + } + function charsLeftIndex(string, chars) { + var index = -1, length = string.length; + while (++index < length && chars.indexOf(string.charAt(index)) > -1) {} + return index; + } + function charsRightIndex(string, chars) { + var index = string.length; + while (index-- && chars.indexOf(string.charAt(index)) > -1) {} + return index; + } + function compareAscending(object, other) { + return baseCompareAscending(object.criteria, other.criteria) || object.index - other.index; + } + function compareMultiple(object, other, orders) { + var index = -1, objCriteria = object.criteria, othCriteria = other.criteria, length = objCriteria.length, ordersLength = orders.length; + while (++index < length) { + var result = baseCompareAscending(objCriteria[index], othCriteria[index]); + if (result) { + if (index >= ordersLength) { + return result; + } + var order = orders[index]; + return result * (order === "asc" || order === true ? 1 : -1); + } + } + return object.index - other.index; + } + function deburrLetter(letter) { + return deburredLetters[letter]; + } + function escapeHtmlChar(chr) { + return htmlEscapes[chr]; + } + function escapeRegExpChar(chr, leadingChar, whitespaceChar) { + if (leadingChar) { + chr = regexpEscapes[chr]; + } else if (whitespaceChar) { + chr = stringEscapes[chr]; + } + return "\\" + chr; + } + function escapeStringChar(chr) { + return "\\" + stringEscapes[chr]; + } + function indexOfNaN(array, fromIndex, fromRight) { + var length = array.length, index = fromIndex + (fromRight ? 0 : -1); + while (fromRight ? index-- : ++index < length) { + var other = array[index]; + if (other !== other) { + return index; + } + } + return -1; + } + function isObjectLike(value) { + return !!value && typeof value == "object"; + } + function isSpace(charCode) { + return charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160 || charCode == 5760 || charCode == 6158 || charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279); + } + function replaceHolders(array, placeholder) { + var index = -1, length = array.length, resIndex = -1, result = []; + while (++index < length) { + if (array[index] === placeholder) { + array[index] = PLACEHOLDER; + result[++resIndex] = index; + } + } + return result; + } + function sortedUniq(array, iteratee) { + var seen, index = -1, length = array.length, resIndex = -1, result = []; + while (++index < length) { + var value = array[index], computed = iteratee ? iteratee(value, index, array) : value; + if (!index || seen !== computed) { + seen = computed; + result[++resIndex] = value; + } + } + return result; + } + function trimmedLeftIndex(string) { + var index = -1, length = string.length; + while (++index < length && isSpace(string.charCodeAt(index))) {} + return index; + } + function trimmedRightIndex(string) { + var index = string.length; + while (index-- && isSpace(string.charCodeAt(index))) {} + return index; + } + function unescapeHtmlChar(chr) { + return htmlUnescapes[chr]; + } + function runInContext(context) { + context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root; + var Array = context.Array, Date = context.Date, Error = context.Error, Function = context.Function, Math = context.Math, Number = context.Number, Object = context.Object, RegExp = context.RegExp, String = context.String, TypeError = context.TypeError; + var arrayProto = Array.prototype, objectProto = Object.prototype, stringProto = String.prototype; + var fnToString = Function.prototype.toString; + var hasOwnProperty = objectProto.hasOwnProperty; + var idCounter = 0; + var objToString = objectProto.toString; + var oldDash = root._; + var reIsNative = RegExp("^" + fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"); + var ArrayBuffer = context.ArrayBuffer, clearTimeout = context.clearTimeout, parseFloat = context.parseFloat, pow = Math.pow, propertyIsEnumerable = objectProto.propertyIsEnumerable, Set = getNative(context, "Set"), setTimeout = context.setTimeout, splice = arrayProto.splice, Uint8Array = context.Uint8Array, WeakMap = getNative(context, "WeakMap"); + var nativeCeil = Math.ceil, nativeCreate = getNative(Object, "create"), nativeFloor = Math.floor, nativeIsArray = getNative(Array, "isArray"), nativeIsFinite = context.isFinite, nativeKeys = getNative(Object, "keys"), nativeMax = Math.max, nativeMin = Math.min, nativeNow = getNative(Date, "now"), nativeParseInt = context.parseInt, nativeRandom = Math.random; + var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY, POSITIVE_INFINITY = Number.POSITIVE_INFINITY; + var MAX_ARRAY_LENGTH = 4294967295, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; + var MAX_SAFE_INTEGER = 9007199254740991; + var metaMap = WeakMap && new WeakMap(); + var realNames = {}; + function lodash(value) { + if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { + if (value instanceof LodashWrapper) { + return value; + } + if (hasOwnProperty.call(value, "__chain__") && hasOwnProperty.call(value, "__wrapped__")) { + return wrapperClone(value); + } + } + return new LodashWrapper(value); + } + function baseLodash() {} + function LodashWrapper(value, chainAll, actions) { + this.__wrapped__ = value; + this.__actions__ = actions || []; + this.__chain__ = !!chainAll; + } + var support = lodash.support = {}; + lodash.templateSettings = { + escape: reEscape, + evaluate: reEvaluate, + interpolate: reInterpolate, + variable: "", + imports: { + _: lodash + } + }; + function LazyWrapper(value) { + this.__wrapped__ = value; + this.__actions__ = []; + this.__dir__ = 1; + this.__filtered__ = false; + this.__iteratees__ = []; + this.__takeCount__ = POSITIVE_INFINITY; + this.__views__ = []; + } + function lazyClone() { + var result = new LazyWrapper(this.__wrapped__); + result.__actions__ = arrayCopy(this.__actions__); + result.__dir__ = this.__dir__; + result.__filtered__ = this.__filtered__; + result.__iteratees__ = arrayCopy(this.__iteratees__); + result.__takeCount__ = this.__takeCount__; + result.__views__ = arrayCopy(this.__views__); + return result; + } + function lazyReverse() { + if (this.__filtered__) { + var result = new LazyWrapper(this); + result.__dir__ = -1; + result.__filtered__ = true; + } else { + result = this.clone(); + result.__dir__ *= -1; + } + return result; + } + function lazyValue() { + var array = this.__wrapped__.value(), dir = this.__dir__, isArr = isArray(array), isRight = dir < 0, arrLength = isArr ? array.length : 0, view = getView(0, arrLength, this.__views__), start = view.start, end = view.end, length = end - start, index = isRight ? end : start - 1, iteratees = this.__iteratees__, iterLength = iteratees.length, resIndex = 0, takeCount = nativeMin(length, this.__takeCount__); + if (!isArr || arrLength < LARGE_ARRAY_SIZE || arrLength == length && takeCount == length) { + return baseWrapperValue(array, this.__actions__); + } + var result = []; + outer: while (length-- && resIndex < takeCount) { + index += dir; + var iterIndex = -1, value = array[index]; + while (++iterIndex < iterLength) { + var data = iteratees[iterIndex], iteratee = data.iteratee, type = data.type, computed = iteratee(value); + if (type == LAZY_MAP_FLAG) { + value = computed; + } else if (!computed) { + if (type == LAZY_FILTER_FLAG) { + continue outer; + } else { + break outer; + } + } + } + result[resIndex++] = value; + } + return result; + } + function MapCache() { + this.__data__ = {}; + } + function mapDelete(key) { + return this.has(key) && delete this.__data__[key]; + } + function mapGet(key) { + return key == "__proto__" ? undefined : this.__data__[key]; + } + function mapHas(key) { + return key != "__proto__" && hasOwnProperty.call(this.__data__, key); + } + function mapSet(key, value) { + if (key != "__proto__") { + this.__data__[key] = value; + } + return this; + } + function SetCache(values) { + var length = values ? values.length : 0; + this.data = { + hash: nativeCreate(null), + set: new Set() + }; + while (length--) { + this.push(values[length]); + } + } + function cacheIndexOf(cache, value) { + var data = cache.data, result = typeof value == "string" || isObject(value) ? data.set.has(value) : data.hash[value]; + return result ? 0 : -1; + } + function cachePush(value) { + var data = this.data; + if (typeof value == "string" || isObject(value)) { + data.set.add(value); + } else { + data.hash[value] = true; + } + } + function arrayConcat(array, other) { + var index = -1, length = array.length, othIndex = -1, othLength = other.length, result = Array(length + othLength); + while (++index < length) { + result[index] = array[index]; + } + while (++othIndex < othLength) { + result[index++] = other[othIndex]; + } + return result; + } + function arrayCopy(source, array) { + var index = -1, length = source.length; + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; + } + function arrayEach(array, iteratee) { + var index = -1, length = array.length; + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } + } + return array; + } + function arrayEachRight(array, iteratee) { + var length = array.length; + while (length--) { + if (iteratee(array[length], length, array) === false) { + break; + } + } + return array; + } + function arrayEvery(array, predicate) { + var index = -1, length = array.length; + while (++index < length) { + if (!predicate(array[index], index, array)) { + return false; + } + } + return true; + } + function arrayExtremum(array, iteratee, comparator, exValue) { + var index = -1, length = array.length, computed = exValue, result = computed; + while (++index < length) { + var value = array[index], current = +iteratee(value); + if (comparator(current, computed)) { + computed = current; + result = value; + } + } + return result; + } + function arrayFilter(array, predicate) { + var index = -1, length = array.length, resIndex = -1, result = []; + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[++resIndex] = value; + } + } + return result; + } + function arrayMap(array, iteratee) { + var index = -1, length = array.length, result = Array(length); + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; + } + function arrayPush(array, values) { + var index = -1, length = values.length, offset = array.length; + while (++index < length) { + array[offset + index] = values[index]; + } + return array; + } + function arrayReduce(array, iteratee, accumulator, initFromArray) { + var index = -1, length = array.length; + if (initFromArray && length) { + accumulator = array[++index]; + } + while (++index < length) { + accumulator = iteratee(accumulator, array[index], index, array); + } + return accumulator; + } + function arrayReduceRight(array, iteratee, accumulator, initFromArray) { + var length = array.length; + if (initFromArray && length) { + accumulator = array[--length]; + } + while (length--) { + accumulator = iteratee(accumulator, array[length], length, array); + } + return accumulator; + } + function arraySome(array, predicate) { + var index = -1, length = array.length; + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; + } + function arraySum(array, iteratee) { + var length = array.length, result = 0; + while (length--) { + result += +iteratee(array[length]) || 0; + } + return result; + } + function assignDefaults(objectValue, sourceValue) { + return objectValue === undefined ? sourceValue : objectValue; + } + function assignOwnDefaults(objectValue, sourceValue, key, object) { + return objectValue === undefined || !hasOwnProperty.call(object, key) ? sourceValue : objectValue; + } + function assignWith(object, source, customizer) { + var index = -1, props = keys(source), length = props.length; + while (++index < length) { + var key = props[index], value = object[key], result = customizer(value, source[key], key, object, source); + if ((result === result ? result !== value : value === value) || value === undefined && !(key in object)) { + object[key] = result; + } + } + return object; + } + function baseAssign(object, source) { + return source == null ? object : baseCopy(source, keys(source), object); + } + function baseAt(collection, props) { + var index = -1, isNil = collection == null, isArr = !isNil && isArrayLike(collection), length = isArr ? collection.length : 0, propsLength = props.length, result = Array(propsLength); + while (++index < propsLength) { + var key = props[index]; + if (isArr) { + result[index] = isIndex(key, length) ? collection[key] : undefined; + } else { + result[index] = isNil ? undefined : collection[key]; + } + } + return result; + } + function baseCopy(source, props, object) { + object || (object = {}); + var index = -1, length = props.length; + while (++index < length) { + var key = props[index]; + object[key] = source[key]; + } + return object; + } + function baseCallback(func, thisArg, argCount) { + var type = typeof func; + if (type == "function") { + return thisArg === undefined ? func : bindCallback(func, thisArg, argCount); + } + if (func == null) { + return identity; + } + if (type == "object") { + return baseMatches(func); + } + return thisArg === undefined ? property(func) : baseMatchesProperty(func, thisArg); + } + function baseClone(value, isDeep, customizer, key, object, stackA, stackB) { + var result; + if (customizer) { + result = object ? customizer(value, key, object) : customizer(value); + } + if (result !== undefined) { + return result; + } + if (!isObject(value)) { + return value; + } + var isArr = isArray(value); + if (isArr) { + result = initCloneArray(value); + if (!isDeep) { + return arrayCopy(value, result); + } + } else { + var tag = objToString.call(value), isFunc = tag == funcTag; + if (tag == objectTag || tag == argsTag || isFunc && !object) { + result = initCloneObject(isFunc ? {} : value); + if (!isDeep) { + return baseAssign(result, value); + } + } else { + return cloneableTags[tag] ? initCloneByTag(value, tag, isDeep) : object ? value : {}; + } + } + stackA || (stackA = []); + stackB || (stackB = []); + var length = stackA.length; + while (length--) { + if (stackA[length] == value) { + return stackB[length]; + } + } + stackA.push(value); + stackB.push(result); + (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { + result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB); + }); + return result; + } + var baseCreate = function() { + function object() {} + return function(prototype) { + if (isObject(prototype)) { + object.prototype = prototype; + var result = new object(); + object.prototype = undefined; + } + return result || {}; + }; + }(); + function baseDelay(func, wait, args) { + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + return setTimeout(function() { + func.apply(undefined, args); + }, wait); + } + function baseDifference(array, values) { + var length = array ? array.length : 0, result = []; + if (!length) { + return result; + } + var index = -1, indexOf = getIndexOf(), isCommon = indexOf === baseIndexOf, cache = isCommon && values.length >= LARGE_ARRAY_SIZE ? createCache(values) : null, valuesLength = values.length; + if (cache) { + indexOf = cacheIndexOf; + isCommon = false; + values = cache; + } + outer: while (++index < length) { + var value = array[index]; + if (isCommon && value === value) { + var valuesIndex = valuesLength; + while (valuesIndex--) { + if (values[valuesIndex] === value) { + continue outer; + } + } + result.push(value); + } else if (indexOf(values, value, 0) < 0) { + result.push(value); + } + } + return result; + } + var baseEach = createBaseEach(baseForOwn); + var baseEachRight = createBaseEach(baseForOwnRight, true); + function baseEvery(collection, predicate) { + var result = true; + baseEach(collection, function(value, index, collection) { + result = !!predicate(value, index, collection); + return result; + }); + return result; + } + function baseExtremum(collection, iteratee, comparator, exValue) { + var computed = exValue, result = computed; + baseEach(collection, function(value, index, collection) { + var current = +iteratee(value, index, collection); + if (comparator(current, computed) || current === exValue && current === result) { + computed = current; + result = value; + } + }); + return result; + } + function baseFill(array, value, start, end) { + var length = array.length; + start = start == null ? 0 : +start || 0; + if (start < 0) { + start = -start > length ? 0 : length + start; + } + end = end === undefined || end > length ? length : +end || 0; + if (end < 0) { + end += length; + } + length = start > end ? 0 : end >>> 0; + start >>>= 0; + while (start < length) { + array[start++] = value; + } + return array; + } + function baseFilter(collection, predicate) { + var result = []; + baseEach(collection, function(value, index, collection) { + if (predicate(value, index, collection)) { + result.push(value); + } + }); + return result; + } + function baseFind(collection, predicate, eachFunc, retKey) { + var result; + eachFunc(collection, function(value, key, collection) { + if (predicate(value, key, collection)) { + result = retKey ? key : value; + return false; + } + }); + return result; + } + function baseFlatten(array, isDeep, isStrict, result) { + result || (result = []); + var index = -1, length = array.length; + while (++index < length) { + var value = array[index]; + if (isObjectLike(value) && isArrayLike(value) && (isStrict || isArray(value) || isArguments(value))) { + if (isDeep) { + baseFlatten(value, isDeep, isStrict, result); + } else { + arrayPush(result, value); + } + } else if (!isStrict) { + result[result.length] = value; + } + } + return result; + } + var baseFor = createBaseFor(); + var baseForRight = createBaseFor(true); + function baseForIn(object, iteratee) { + return baseFor(object, iteratee, keysIn); + } + function baseForOwn(object, iteratee) { + return baseFor(object, iteratee, keys); + } + function baseForOwnRight(object, iteratee) { + return baseForRight(object, iteratee, keys); + } + function baseFunctions(object, props) { + var index = -1, length = props.length, resIndex = -1, result = []; + while (++index < length) { + var key = props[index]; + if (isFunction(object[key])) { + result[++resIndex] = key; + } + } + return result; + } + function baseGet(object, path, pathKey) { + if (object == null) { + return; + } + if (pathKey !== undefined && pathKey in toObject(object)) { + path = [ pathKey ]; + } + var index = 0, length = path.length; + while (object != null && index < length) { + object = object[path[index++]]; + } + return index && index == length ? object : undefined; + } + function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) { + if (value === other) { + return true; + } + if (value == null || other == null || !isObject(value) && !isObjectLike(other)) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB); + } + function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) { + var objIsArr = isArray(object), othIsArr = isArray(other), objTag = arrayTag, othTag = arrayTag; + if (!objIsArr) { + objTag = objToString.call(object); + if (objTag == argsTag) { + objTag = objectTag; + } else if (objTag != objectTag) { + objIsArr = isTypedArray(object); + } + } + if (!othIsArr) { + othTag = objToString.call(other); + if (othTag == argsTag) { + othTag = objectTag; + } else if (othTag != objectTag) { + othIsArr = isTypedArray(other); + } + } + var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag; + if (isSameTag && !(objIsArr || objIsObj)) { + return equalByTag(object, other, objTag); + } + if (!isLoose) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__"); + if (objIsWrapped || othIsWrapped) { + return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB); + } + } + if (!isSameTag) { + return false; + } + stackA || (stackA = []); + stackB || (stackB = []); + var length = stackA.length; + while (length--) { + if (stackA[length] == object) { + return stackB[length] == other; + } + } + stackA.push(object); + stackB.push(other); + var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB); + stackA.pop(); + stackB.pop(); + return result; + } + function baseIsMatch(object, matchData, customizer) { + var index = matchData.length, length = index, noCustomizer = !customizer; + if (object == null) { + return !length; + } + object = toObject(object); + while (index--) { + var data = matchData[index]; + if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) { + return false; + } + } + while (++index < length) { + data = matchData[index]; + var key = data[0], objValue = object[key], srcValue = data[1]; + if (noCustomizer && data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } + } else { + var result = customizer ? customizer(objValue, srcValue, key) : undefined; + if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) { + return false; + } + } + } + return true; + } + function baseMap(collection, iteratee) { + var index = -1, result = isArrayLike(collection) ? Array(collection.length) : []; + baseEach(collection, function(value, key, collection) { + result[++index] = iteratee(value, key, collection); + }); + return result; + } + function baseMatches(source) { + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + var key = matchData[0][0], value = matchData[0][1]; + return function(object) { + if (object == null) { + return false; + } + return object[key] === value && (value !== undefined || key in toObject(object)); + }; + } + return function(object) { + return baseIsMatch(object, matchData); + }; + } + function baseMatchesProperty(path, srcValue) { + var isArr = isArray(path), isCommon = isKey(path) && isStrictComparable(srcValue), pathKey = path + ""; + path = toPath(path); + return function(object) { + if (object == null) { + return false; + } + var key = pathKey; + object = toObject(object); + if ((isArr || !isCommon) && !(key in object)) { + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + if (object == null) { + return false; + } + key = last(path); + object = toObject(object); + } + return object[key] === srcValue ? srcValue !== undefined || key in object : baseIsEqual(srcValue, object[key], undefined, true); + }; + } + function baseMerge(object, source, customizer, stackA, stackB) { + if (!isObject(object)) { + return object; + } + var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)), props = isSrcArr ? undefined : keys(source); + arrayEach(props || source, function(srcValue, key) { + if (props) { + key = srcValue; + srcValue = source[key]; + } + if (isObjectLike(srcValue)) { + stackA || (stackA = []); + stackB || (stackB = []); + baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB); + } else { + var value = object[key], result = customizer ? customizer(value, srcValue, key, object, source) : undefined, isCommon = result === undefined; + if (isCommon) { + result = srcValue; + } + if ((result !== undefined || isSrcArr && !(key in object)) && (isCommon || (result === result ? result !== value : value === value))) { + object[key] = result; + } + } + }); + return object; + } + function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) { + var length = stackA.length, srcValue = source[key]; + while (length--) { + if (stackA[length] == srcValue) { + object[key] = stackB[length]; + return; + } + } + var value = object[key], result = customizer ? customizer(value, srcValue, key, object, source) : undefined, isCommon = result === undefined; + if (isCommon) { + result = srcValue; + if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) { + result = isArray(value) ? value : isArrayLike(value) ? arrayCopy(value) : []; + } else if (isPlainObject(srcValue) || isArguments(srcValue)) { + result = isArguments(value) ? toPlainObject(value) : isPlainObject(value) ? value : {}; + } else { + isCommon = false; + } + } + stackA.push(srcValue); + stackB.push(result); + if (isCommon) { + object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB); + } else if (result === result ? result !== value : value === value) { + object[key] = result; + } + } + function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; + } + function basePropertyDeep(path) { + var pathKey = path + ""; + path = toPath(path); + return function(object) { + return baseGet(object, path, pathKey); + }; + } + function basePullAt(array, indexes) { + var length = array ? indexes.length : 0; + while (length--) { + var index = indexes[length]; + if (index != previous && isIndex(index)) { + var previous = index; + splice.call(array, index, 1); + } + } + return array; + } + function baseRandom(min, max) { + return min + nativeFloor(nativeRandom() * (max - min + 1)); + } + function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) { + eachFunc(collection, function(value, index, collection) { + accumulator = initFromCollection ? (initFromCollection = false, value) : iteratee(accumulator, value, index, collection); + }); + return accumulator; + } + var baseSetData = !metaMap ? identity : function(func, data) { + metaMap.set(func, data); + return func; + }; + function baseSlice(array, start, end) { + var index = -1, length = array.length; + start = start == null ? 0 : +start || 0; + if (start < 0) { + start = -start > length ? 0 : length + start; + } + end = end === undefined || end > length ? length : +end || 0; + if (end < 0) { + end += length; + } + length = start > end ? 0 : end - start >>> 0; + start >>>= 0; + var result = Array(length); + while (++index < length) { + result[index] = array[index + start]; + } + return result; + } + function baseSome(collection, predicate) { + var result; + baseEach(collection, function(value, index, collection) { + result = predicate(value, index, collection); + return !result; + }); + return !!result; + } + function baseSortBy(array, comparer) { + var length = array.length; + array.sort(comparer); + while (length--) { + array[length] = array[length].value; + } + return array; + } + function baseSortByOrder(collection, iteratees, orders) { + var callback = getCallback(), index = -1; + iteratees = arrayMap(iteratees, function(iteratee) { + return callback(iteratee); + }); + var result = baseMap(collection, function(value) { + var criteria = arrayMap(iteratees, function(iteratee) { + return iteratee(value); + }); + return { + criteria: criteria, + index: ++index, + value: value + }; + }); + return baseSortBy(result, function(object, other) { + return compareMultiple(object, other, orders); + }); + } + function baseSum(collection, iteratee) { + var result = 0; + baseEach(collection, function(value, index, collection) { + result += +iteratee(value, index, collection) || 0; + }); + return result; + } + function baseUniq(array, iteratee) { + var index = -1, indexOf = getIndexOf(), length = array.length, isCommon = indexOf === baseIndexOf, isLarge = isCommon && length >= LARGE_ARRAY_SIZE, seen = isLarge ? createCache() : null, result = []; + if (seen) { + indexOf = cacheIndexOf; + isCommon = false; + } else { + isLarge = false; + seen = iteratee ? [] : result; + } + outer: while (++index < length) { + var value = array[index], computed = iteratee ? iteratee(value, index, array) : value; + if (isCommon && value === value) { + var seenIndex = seen.length; + while (seenIndex--) { + if (seen[seenIndex] === computed) { + continue outer; + } + } + if (iteratee) { + seen.push(computed); + } + result.push(value); + } else if (indexOf(seen, computed, 0) < 0) { + if (iteratee || isLarge) { + seen.push(computed); + } + result.push(value); + } + } + return result; + } + function baseValues(object, props) { + var index = -1, length = props.length, result = Array(length); + while (++index < length) { + result[index] = object[props[index]]; + } + return result; + } + function baseWhile(array, predicate, isDrop, fromRight) { + var length = array.length, index = fromRight ? length : -1; + while ((fromRight ? index-- : ++index < length) && predicate(array[index], index, array)) {} + return isDrop ? baseSlice(array, fromRight ? 0 : index, fromRight ? index + 1 : length) : baseSlice(array, fromRight ? index + 1 : 0, fromRight ? length : index); + } + function baseWrapperValue(value, actions) { + var result = value; + if (result instanceof LazyWrapper) { + result = result.value(); + } + var index = -1, length = actions.length; + while (++index < length) { + var action = actions[index]; + result = action.func.apply(action.thisArg, arrayPush([ result ], action.args)); + } + return result; + } + function binaryIndex(array, value, retHighest) { + var low = 0, high = array ? array.length : low; + if (typeof value == "number" && value === value && high <= HALF_MAX_ARRAY_LENGTH) { + while (low < high) { + var mid = low + high >>> 1, computed = array[mid]; + if ((retHighest ? computed <= value : computed < value) && computed !== null) { + low = mid + 1; + } else { + high = mid; + } + } + return high; + } + return binaryIndexBy(array, value, identity, retHighest); + } + function binaryIndexBy(array, value, iteratee, retHighest) { + value = iteratee(value); + var low = 0, high = array ? array.length : 0, valIsNaN = value !== value, valIsNull = value === null, valIsUndef = value === undefined; + while (low < high) { + var mid = nativeFloor((low + high) / 2), computed = iteratee(array[mid]), isDef = computed !== undefined, isReflexive = computed === computed; + if (valIsNaN) { + var setLow = isReflexive || retHighest; + } else if (valIsNull) { + setLow = isReflexive && isDef && (retHighest || computed != null); + } else if (valIsUndef) { + setLow = isReflexive && (retHighest || isDef); + } else if (computed == null) { + setLow = false; + } else { + setLow = retHighest ? computed <= value : computed < value; + } + if (setLow) { + low = mid + 1; + } else { + high = mid; + } + } + return nativeMin(high, MAX_ARRAY_INDEX); + } + function bindCallback(func, thisArg, argCount) { + if (typeof func != "function") { + return identity; + } + if (thisArg === undefined) { + return func; + } + switch (argCount) { + case 1: + return function(value) { + return func.call(thisArg, value); + }; + + case 3: + return function(value, index, collection) { + return func.call(thisArg, value, index, collection); + }; + + case 4: + return function(accumulator, value, index, collection) { + return func.call(thisArg, accumulator, value, index, collection); + }; + + case 5: + return function(value, other, key, object, source) { + return func.call(thisArg, value, other, key, object, source); + }; + } + return function() { + return func.apply(thisArg, arguments); + }; + } + function bufferClone(buffer) { + var result = new ArrayBuffer(buffer.byteLength), view = new Uint8Array(result); + view.set(new Uint8Array(buffer)); + return result; + } + function composeArgs(args, partials, holders) { + var holdersLength = holders.length, argsIndex = -1, argsLength = nativeMax(args.length - holdersLength, 0), leftIndex = -1, leftLength = partials.length, result = Array(leftLength + argsLength); + while (++leftIndex < leftLength) { + result[leftIndex] = partials[leftIndex]; + } + while (++argsIndex < holdersLength) { + result[holders[argsIndex]] = args[argsIndex]; + } + while (argsLength--) { + result[leftIndex++] = args[argsIndex++]; + } + return result; + } + function composeArgsRight(args, partials, holders) { + var holdersIndex = -1, holdersLength = holders.length, argsIndex = -1, argsLength = nativeMax(args.length - holdersLength, 0), rightIndex = -1, rightLength = partials.length, result = Array(argsLength + rightLength); + while (++argsIndex < argsLength) { + result[argsIndex] = args[argsIndex]; + } + var offset = argsIndex; + while (++rightIndex < rightLength) { + result[offset + rightIndex] = partials[rightIndex]; + } + while (++holdersIndex < holdersLength) { + result[offset + holders[holdersIndex]] = args[argsIndex++]; + } + return result; + } + function createAggregator(setter, initializer) { + return function(collection, iteratee, thisArg) { + var result = initializer ? initializer() : {}; + iteratee = getCallback(iteratee, thisArg, 3); + if (isArray(collection)) { + var index = -1, length = collection.length; + while (++index < length) { + var value = collection[index]; + setter(result, value, iteratee(value, index, collection), collection); + } + } else { + baseEach(collection, function(value, key, collection) { + setter(result, value, iteratee(value, key, collection), collection); + }); + } + return result; + }; + } + function createAssigner(assigner) { + return restParam(function(object, sources) { + var index = -1, length = object == null ? 0 : sources.length, customizer = length > 2 ? sources[length - 2] : undefined, guard = length > 2 ? sources[2] : undefined, thisArg = length > 1 ? sources[length - 1] : undefined; + if (typeof customizer == "function") { + customizer = bindCallback(customizer, thisArg, 5); + length -= 2; + } else { + customizer = typeof thisArg == "function" ? thisArg : undefined; + length -= customizer ? 1 : 0; + } + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + customizer = length < 3 ? undefined : customizer; + length = 1; + } + while (++index < length) { + var source = sources[index]; + if (source) { + assigner(object, source, customizer); + } + } + return object; + }); + } + function createBaseEach(eachFunc, fromRight) { + return function(collection, iteratee) { + var length = collection ? getLength(collection) : 0; + if (!isLength(length)) { + return eachFunc(collection, iteratee); + } + var index = fromRight ? length : -1, iterable = toObject(collection); + while (fromRight ? index-- : ++index < length) { + if (iteratee(iterable[index], index, iterable) === false) { + break; + } + } + return collection; + }; + } + function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var iterable = toObject(object), props = keysFunc(object), length = props.length, index = fromRight ? length : -1; + while (fromRight ? index-- : ++index < length) { + var key = props[index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } + } + return object; + }; + } + function createBindWrapper(func, thisArg) { + var Ctor = createCtorWrapper(func); + function wrapper() { + var fn = this && this !== root && this instanceof wrapper ? Ctor : func; + return fn.apply(thisArg, arguments); + } + return wrapper; + } + function createCache(values) { + return nativeCreate && Set ? new SetCache(values) : null; + } + function createCompounder(callback) { + return function(string) { + var index = -1, array = words(deburr(string)), length = array.length, result = ""; + while (++index < length) { + result = callback(result, array[index], index); + } + return result; + }; + } + function createCtorWrapper(Ctor) { + return function() { + var args = arguments; + switch (args.length) { + case 0: + return new Ctor(); + + case 1: + return new Ctor(args[0]); + + case 2: + return new Ctor(args[0], args[1]); + + case 3: + return new Ctor(args[0], args[1], args[2]); + + case 4: + return new Ctor(args[0], args[1], args[2], args[3]); + + case 5: + return new Ctor(args[0], args[1], args[2], args[3], args[4]); + + case 6: + return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); + + case 7: + return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + } + var thisBinding = baseCreate(Ctor.prototype), result = Ctor.apply(thisBinding, args); + return isObject(result) ? result : thisBinding; + }; + } + function createCurry(flag) { + function curryFunc(func, arity, guard) { + if (guard && isIterateeCall(func, arity, guard)) { + arity = undefined; + } + var result = createWrapper(func, flag, undefined, undefined, undefined, undefined, undefined, arity); + result.placeholder = curryFunc.placeholder; + return result; + } + return curryFunc; + } + function createDefaults(assigner, customizer) { + return restParam(function(args) { + var object = args[0]; + if (object == null) { + return object; + } + args.push(customizer); + return assigner.apply(undefined, args); + }); + } + function createExtremum(comparator, exValue) { + return function(collection, iteratee, thisArg) { + if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { + iteratee = undefined; + } + iteratee = getCallback(iteratee, thisArg, 3); + if (iteratee.length == 1) { + collection = isArray(collection) ? collection : toIterable(collection); + var result = arrayExtremum(collection, iteratee, comparator, exValue); + if (!(collection.length && result === exValue)) { + return result; + } + } + return baseExtremum(collection, iteratee, comparator, exValue); + }; + } + function createFind(eachFunc, fromRight) { + return function(collection, predicate, thisArg) { + predicate = getCallback(predicate, thisArg, 3); + if (isArray(collection)) { + var index = baseFindIndex(collection, predicate, fromRight); + return index > -1 ? collection[index] : undefined; + } + return baseFind(collection, predicate, eachFunc); + }; + } + function createFindIndex(fromRight) { + return function(array, predicate, thisArg) { + if (!(array && array.length)) { + return -1; + } + predicate = getCallback(predicate, thisArg, 3); + return baseFindIndex(array, predicate, fromRight); + }; + } + function createFindKey(objectFunc) { + return function(object, predicate, thisArg) { + predicate = getCallback(predicate, thisArg, 3); + return baseFind(object, predicate, objectFunc, true); + }; + } + function createFlow(fromRight) { + return function() { + var wrapper, length = arguments.length, index = fromRight ? length : -1, leftIndex = 0, funcs = Array(length); + while (fromRight ? index-- : ++index < length) { + var func = funcs[leftIndex++] = arguments[index]; + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == "wrapper") { + wrapper = new LodashWrapper([], true); + } + } + index = wrapper ? -1 : length; + while (++index < length) { + func = funcs[index]; + var funcName = getFuncName(func), data = funcName == "wrapper" ? getData(func) : undefined; + if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) { + wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); + } else { + wrapper = func.length == 1 && isLaziable(func) ? wrapper[funcName]() : wrapper.thru(func); + } + } + return function() { + var args = arguments, value = args[0]; + if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) { + return wrapper.plant(value).value(); + } + var index = 0, result = length ? funcs[index].apply(this, args) : value; + while (++index < length) { + result = funcs[index].call(this, result); + } + return result; + }; + }; + } + function createForEach(arrayFunc, eachFunc) { + return function(collection, iteratee, thisArg) { + return typeof iteratee == "function" && thisArg === undefined && isArray(collection) ? arrayFunc(collection, iteratee) : eachFunc(collection, bindCallback(iteratee, thisArg, 3)); + }; + } + function createForIn(objectFunc) { + return function(object, iteratee, thisArg) { + if (typeof iteratee != "function" || thisArg !== undefined) { + iteratee = bindCallback(iteratee, thisArg, 3); + } + return objectFunc(object, iteratee, keysIn); + }; + } + function createForOwn(objectFunc) { + return function(object, iteratee, thisArg) { + if (typeof iteratee != "function" || thisArg !== undefined) { + iteratee = bindCallback(iteratee, thisArg, 3); + } + return objectFunc(object, iteratee); + }; + } + function createObjectMapper(isMapKeys) { + return function(object, iteratee, thisArg) { + var result = {}; + iteratee = getCallback(iteratee, thisArg, 3); + baseForOwn(object, function(value, key, object) { + var mapped = iteratee(value, key, object); + key = isMapKeys ? mapped : key; + value = isMapKeys ? value : mapped; + result[key] = value; + }); + return result; + }; + } + function createPadDir(fromRight) { + return function(string, length, chars) { + string = baseToString(string); + return (fromRight ? string : "") + createPadding(string, length, chars) + (fromRight ? "" : string); + }; + } + function createPartial(flag) { + var partialFunc = restParam(function(func, partials) { + var holders = replaceHolders(partials, partialFunc.placeholder); + return createWrapper(func, flag, undefined, partials, holders); + }); + return partialFunc; + } + function createReduce(arrayFunc, eachFunc) { + return function(collection, iteratee, accumulator, thisArg) { + var initFromArray = arguments.length < 3; + return typeof iteratee == "function" && thisArg === undefined && isArray(collection) ? arrayFunc(collection, iteratee, accumulator, initFromArray) : baseReduce(collection, getCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc); + }; + } + function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { + var isAry = bitmask & ARY_FLAG, isBind = bitmask & BIND_FLAG, isBindKey = bitmask & BIND_KEY_FLAG, isCurry = bitmask & CURRY_FLAG, isCurryBound = bitmask & CURRY_BOUND_FLAG, isCurryRight = bitmask & CURRY_RIGHT_FLAG, Ctor = isBindKey ? undefined : createCtorWrapper(func); + function wrapper() { + var length = arguments.length, index = length, args = Array(length); + while (index--) { + args[index] = arguments[index]; + } + if (partials) { + args = composeArgs(args, partials, holders); + } + if (partialsRight) { + args = composeArgsRight(args, partialsRight, holdersRight); + } + if (isCurry || isCurryRight) { + var placeholder = wrapper.placeholder, argsHolders = replaceHolders(args, placeholder); + length -= argsHolders.length; + if (length < arity) { + var newArgPos = argPos ? arrayCopy(argPos) : undefined, newArity = nativeMax(arity - length, 0), newsHolders = isCurry ? argsHolders : undefined, newHoldersRight = isCurry ? undefined : argsHolders, newPartials = isCurry ? args : undefined, newPartialsRight = isCurry ? undefined : args; + bitmask |= isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG; + bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG); + if (!isCurryBound) { + bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); + } + var newData = [ func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity ], result = createHybridWrapper.apply(undefined, newData); + if (isLaziable(func)) { + setData(result, newData); + } + result.placeholder = placeholder; + return result; + } + } + var thisBinding = isBind ? thisArg : this, fn = isBindKey ? thisBinding[func] : func; + if (argPos) { + args = reorder(args, argPos); + } + if (isAry && ary < args.length) { + args.length = ary; + } + if (this && this !== root && this instanceof wrapper) { + fn = Ctor || createCtorWrapper(func); + } + return fn.apply(thisBinding, args); + } + return wrapper; + } + function createPadding(string, length, chars) { + var strLength = string.length; + length = +length; + if (strLength >= length || !nativeIsFinite(length)) { + return ""; + } + var padLength = length - strLength; + chars = chars == null ? " " : chars + ""; + return repeat(chars, nativeCeil(padLength / chars.length)).slice(0, padLength); + } + function createPartialWrapper(func, bitmask, thisArg, partials) { + var isBind = bitmask & BIND_FLAG, Ctor = createCtorWrapper(func); + function wrapper() { + var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array(leftLength + argsLength); + while (++leftIndex < leftLength) { + args[leftIndex] = partials[leftIndex]; + } + while (argsLength--) { + args[leftIndex++] = arguments[++argsIndex]; + } + var fn = this && this !== root && this instanceof wrapper ? Ctor : func; + return fn.apply(isBind ? thisArg : this, args); + } + return wrapper; + } + function createRound(methodName) { + var func = Math[methodName]; + return function(number, precision) { + precision = precision === undefined ? 0 : +precision || 0; + if (precision) { + precision = pow(10, precision); + return func(number * precision) / precision; + } + return func(number); + }; + } + function createSortedIndex(retHighest) { + return function(array, value, iteratee, thisArg) { + var callback = getCallback(iteratee); + return iteratee == null && callback === baseCallback ? binaryIndex(array, value, retHighest) : binaryIndexBy(array, value, callback(iteratee, thisArg, 1), retHighest); + }; + } + function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { + var isBindKey = bitmask & BIND_KEY_FLAG; + if (!isBindKey && typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + var length = partials ? partials.length : 0; + if (!length) { + bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG); + partials = holders = undefined; + } + length -= holders ? holders.length : 0; + if (bitmask & PARTIAL_RIGHT_FLAG) { + var partialsRight = partials, holdersRight = holders; + partials = holders = undefined; + } + var data = isBindKey ? undefined : getData(func), newData = [ func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity ]; + if (data) { + mergeData(newData, data); + bitmask = newData[1]; + arity = newData[9]; + } + newData[9] = arity == null ? isBindKey ? 0 : func.length : nativeMax(arity - length, 0) || 0; + if (bitmask == BIND_FLAG) { + var result = createBindWrapper(newData[0], newData[2]); + } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) { + result = createPartialWrapper.apply(undefined, newData); + } else { + result = createHybridWrapper.apply(undefined, newData); + } + var setter = data ? baseSetData : setData; + return setter(result, newData); + } + function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) { + var index = -1, arrLength = array.length, othLength = other.length; + if (arrLength != othLength && !(isLoose && othLength > arrLength)) { + return false; + } + while (++index < arrLength) { + var arrValue = array[index], othValue = other[index], result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined; + if (result !== undefined) { + if (result) { + continue; + } + return false; + } + if (isLoose) { + if (!arraySome(other, function(othValue) { + return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); + })) { + return false; + } + } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) { + return false; + } + } + return true; + } + function equalByTag(object, other, tag) { + switch (tag) { + case boolTag: + case dateTag: + return +object == +other; + + case errorTag: + return object.name == other.name && object.message == other.message; + + case numberTag: + return object != +object ? other != +other : object == +other; + + case regexpTag: + case stringTag: + return object == other + ""; + } + return false; + } + function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) { + var objProps = keys(object), objLength = objProps.length, othProps = keys(other), othLength = othProps.length; + if (objLength != othLength && !isLoose) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) { + return false; + } + } + var skipCtor = isLoose; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], othValue = other[key], result = customizer ? customizer(isLoose ? othValue : objValue, isLoose ? objValue : othValue, key) : undefined; + if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) { + return false; + } + skipCtor || (skipCtor = key == "constructor"); + } + if (!skipCtor) { + var objCtor = object.constructor, othCtor = other.constructor; + if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) { + return false; + } + } + return true; + } + function getCallback(func, thisArg, argCount) { + var result = lodash.callback || callback; + result = result === callback ? baseCallback : result; + return argCount ? result(func, thisArg, argCount) : result; + } + var getData = !metaMap ? noop : function(func) { + return metaMap.get(func); + }; + function getFuncName(func) { + var result = func.name + "", array = realNames[result], length = array ? array.length : 0; + while (length--) { + var data = array[length], otherFunc = data.func; + if (otherFunc == null || otherFunc == func) { + return data.name; + } + } + return result; + } + function getIndexOf(collection, target, fromIndex) { + var result = lodash.indexOf || indexOf; + result = result === indexOf ? baseIndexOf : result; + return collection ? result(collection, target, fromIndex) : result; + } + var getLength = baseProperty("length"); + function getMatchData(object) { + var result = pairs(object), length = result.length; + while (length--) { + result[length][2] = isStrictComparable(result[length][1]); + } + return result; + } + function getNative(object, key) { + var value = object == null ? undefined : object[key]; + return isNative(value) ? value : undefined; + } + function getView(start, end, transforms) { + var index = -1, length = transforms.length; + while (++index < length) { + var data = transforms[index], size = data.size; + switch (data.type) { + case "drop": + start += size; + break; + + case "dropRight": + end -= size; + break; + + case "take": + end = nativeMin(end, start + size); + break; + + case "takeRight": + start = nativeMax(start, end - size); + break; + } + } + return { + start: start, + end: end + }; + } + function initCloneArray(array) { + var length = array.length, result = new array.constructor(length); + if (length && typeof array[0] == "string" && hasOwnProperty.call(array, "index")) { + result.index = array.index; + result.input = array.input; + } + return result; + } + function initCloneObject(object) { + var Ctor = object.constructor; + if (!(typeof Ctor == "function" && Ctor instanceof Ctor)) { + Ctor = Object; + } + return new Ctor(); + } + function initCloneByTag(object, tag, isDeep) { + var Ctor = object.constructor; + switch (tag) { + case arrayBufferTag: + return bufferClone(object); + + case boolTag: + case dateTag: + return new Ctor(+object); + + case float32Tag: + case float64Tag: + case int8Tag: + case int16Tag: + case int32Tag: + case uint8Tag: + case uint8ClampedTag: + case uint16Tag: + case uint32Tag: + var buffer = object.buffer; + return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length); + + case numberTag: + case stringTag: + return new Ctor(object); + + case regexpTag: + var result = new Ctor(object.source, reFlags.exec(object)); + result.lastIndex = object.lastIndex; + } + return result; + } + function invokePath(object, path, args) { + if (object != null && !isKey(path, object)) { + path = toPath(path); + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + path = last(path); + } + var func = object == null ? object : object[path]; + return func == null ? undefined : func.apply(object, args); + } + function isArrayLike(value) { + return value != null && isLength(getLength(value)); + } + function isIndex(value, length) { + value = typeof value == "number" || reIsUint.test(value) ? +value : -1; + length = length == null ? MAX_SAFE_INTEGER : length; + return value > -1 && value % 1 == 0 && value < length; + } + function isIterateeCall(value, index, object) { + if (!isObject(object)) { + return false; + } + var type = typeof index; + if (type == "number" ? isArrayLike(object) && isIndex(index, object.length) : type == "string" && index in object) { + var other = object[index]; + return value === value ? value === other : other !== other; + } + return false; + } + function isKey(value, object) { + var type = typeof value; + if (type == "string" && reIsPlainProp.test(value) || type == "number") { + return true; + } + if (isArray(value)) { + return false; + } + var result = !reIsDeepProp.test(value); + return result || object != null && value in toObject(object); + } + function isLaziable(func) { + var funcName = getFuncName(func), other = lodash[funcName]; + if (typeof other != "function" || !(funcName in LazyWrapper.prototype)) { + return false; + } + if (func === other) { + return true; + } + var data = getData(other); + return !!data && func === data[0]; + } + function isLength(value) { + return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; + } + function isStrictComparable(value) { + return value === value && !isObject(value); + } + function mergeData(data, source) { + var bitmask = data[1], srcBitmask = source[1], newBitmask = bitmask | srcBitmask, isCommon = newBitmask < ARY_FLAG; + var isCombo = srcBitmask == ARY_FLAG && bitmask == CURRY_FLAG || srcBitmask == ARY_FLAG && bitmask == REARG_FLAG && data[7].length <= source[8] || srcBitmask == (ARY_FLAG | REARG_FLAG) && bitmask == CURRY_FLAG; + if (!(isCommon || isCombo)) { + return data; + } + if (srcBitmask & BIND_FLAG) { + data[2] = source[2]; + newBitmask |= bitmask & BIND_FLAG ? 0 : CURRY_BOUND_FLAG; + } + var value = source[3]; + if (value) { + var partials = data[3]; + data[3] = partials ? composeArgs(partials, value, source[4]) : arrayCopy(value); + data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : arrayCopy(source[4]); + } + value = source[5]; + if (value) { + partials = data[5]; + data[5] = partials ? composeArgsRight(partials, value, source[6]) : arrayCopy(value); + data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : arrayCopy(source[6]); + } + value = source[7]; + if (value) { + data[7] = arrayCopy(value); + } + if (srcBitmask & ARY_FLAG) { + data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); + } + if (data[9] == null) { + data[9] = source[9]; + } + data[0] = source[0]; + data[1] = newBitmask; + return data; + } + function mergeDefaults(objectValue, sourceValue) { + return objectValue === undefined ? sourceValue : merge(objectValue, sourceValue, mergeDefaults); + } + function pickByArray(object, props) { + object = toObject(object); + var index = -1, length = props.length, result = {}; + while (++index < length) { + var key = props[index]; + if (key in object) { + result[key] = object[key]; + } + } + return result; + } + function pickByCallback(object, predicate) { + var result = {}; + baseForIn(object, function(value, key, object) { + if (predicate(value, key, object)) { + result[key] = value; + } + }); + return result; + } + function reorder(array, indexes) { + var arrLength = array.length, length = nativeMin(indexes.length, arrLength), oldArray = arrayCopy(array); + while (length--) { + var index = indexes[length]; + array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; + } + return array; + } + var setData = function() { + var count = 0, lastCalled = 0; + return function(key, value) { + var stamp = now(), remaining = HOT_SPAN - (stamp - lastCalled); + lastCalled = stamp; + if (remaining > 0) { + if (++count >= HOT_COUNT) { + return key; + } + } else { + count = 0; + } + return baseSetData(key, value); + }; + }(); + function shimKeys(object) { + var props = keysIn(object), propsLength = props.length, length = propsLength && object.length; + var allowIndexes = !!length && isLength(length) && (isArray(object) || isArguments(object)); + var index = -1, result = []; + while (++index < propsLength) { + var key = props[index]; + if (allowIndexes && isIndex(key, length) || hasOwnProperty.call(object, key)) { + result.push(key); + } + } + return result; + } + function toIterable(value) { + if (value == null) { + return []; + } + if (!isArrayLike(value)) { + return values(value); + } + return isObject(value) ? value : Object(value); + } + function toObject(value) { + return isObject(value) ? value : Object(value); + } + function toPath(value) { + if (isArray(value)) { + return value; + } + var result = []; + baseToString(value).replace(rePropName, function(match, number, quote, string) { + result.push(quote ? string.replace(reEscapeChar, "$1") : number || match); + }); + return result; + } + function wrapperClone(wrapper) { + return wrapper instanceof LazyWrapper ? wrapper.clone() : new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__)); + } + function chunk(array, size, guard) { + if (guard ? isIterateeCall(array, size, guard) : size == null) { + size = 1; + } else { + size = nativeMax(nativeFloor(size) || 1, 1); + } + var index = 0, length = array ? array.length : 0, resIndex = -1, result = Array(nativeCeil(length / size)); + while (index < length) { + result[++resIndex] = baseSlice(array, index, index += size); + } + return result; + } + function compact(array) { + var index = -1, length = array ? array.length : 0, resIndex = -1, result = []; + while (++index < length) { + var value = array[index]; + if (value) { + result[++resIndex] = value; + } + } + return result; + } + var difference = restParam(function(array, values) { + return isObjectLike(array) && isArrayLike(array) ? baseDifference(array, baseFlatten(values, false, true)) : []; + }); + function drop(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + return baseSlice(array, n < 0 ? 0 : n); + } + function dropRight(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + n = length - (+n || 0); + return baseSlice(array, 0, n < 0 ? 0 : n); + } + function dropRightWhile(array, predicate, thisArg) { + return array && array.length ? baseWhile(array, getCallback(predicate, thisArg, 3), true, true) : []; + } + function dropWhile(array, predicate, thisArg) { + return array && array.length ? baseWhile(array, getCallback(predicate, thisArg, 3), true) : []; + } + function fill(array, value, start, end) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (start && typeof start != "number" && isIterateeCall(array, value, start)) { + start = 0; + end = length; + } + return baseFill(array, value, start, end); + } + var findIndex = createFindIndex(); + var findLastIndex = createFindIndex(true); + function first(array) { + return array ? array[0] : undefined; + } + function flatten(array, isDeep, guard) { + var length = array ? array.length : 0; + if (guard && isIterateeCall(array, isDeep, guard)) { + isDeep = false; + } + return length ? baseFlatten(array, isDeep) : []; + } + function flattenDeep(array) { + var length = array ? array.length : 0; + return length ? baseFlatten(array, true) : []; + } + function indexOf(array, value, fromIndex) { + var length = array ? array.length : 0; + if (!length) { + return -1; + } + if (typeof fromIndex == "number") { + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex; + } else if (fromIndex) { + var index = binaryIndex(array, value); + if (index < length && (value === value ? value === array[index] : array[index] !== array[index])) { + return index; + } + return -1; + } + return baseIndexOf(array, value, fromIndex || 0); + } + function initial(array) { + return dropRight(array, 1); + } + var intersection = restParam(function(arrays) { + var othLength = arrays.length, othIndex = othLength, caches = Array(length), indexOf = getIndexOf(), isCommon = indexOf === baseIndexOf, result = []; + while (othIndex--) { + var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : []; + caches[othIndex] = isCommon && value.length >= 120 ? createCache(othIndex && value) : null; + } + var array = arrays[0], index = -1, length = array ? array.length : 0, seen = caches[0]; + outer: while (++index < length) { + value = array[index]; + if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) { + var othIndex = othLength; + while (--othIndex) { + var cache = caches[othIndex]; + if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) { + continue outer; + } + } + if (seen) { + seen.push(value); + } + result.push(value); + } + } + return result; + }); + function last(array) { + var length = array ? array.length : 0; + return length ? array[length - 1] : undefined; + } + function lastIndexOf(array, value, fromIndex) { + var length = array ? array.length : 0; + if (!length) { + return -1; + } + var index = length; + if (typeof fromIndex == "number") { + index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1; + } else if (fromIndex) { + index = binaryIndex(array, value, true) - 1; + var other = array[index]; + if (value === value ? value === other : other !== other) { + return index; + } + return -1; + } + if (value !== value) { + return indexOfNaN(array, index, true); + } + while (index--) { + if (array[index] === value) { + return index; + } + } + return -1; + } + function pull() { + var args = arguments, array = args[0]; + if (!(array && array.length)) { + return array; + } + var index = 0, indexOf = getIndexOf(), length = args.length; + while (++index < length) { + var fromIndex = 0, value = args[index]; + while ((fromIndex = indexOf(array, value, fromIndex)) > -1) { + splice.call(array, fromIndex, 1); + } + } + return array; + } + var pullAt = restParam(function(array, indexes) { + indexes = baseFlatten(indexes); + var result = baseAt(array, indexes); + basePullAt(array, indexes.sort(baseCompareAscending)); + return result; + }); + function remove(array, predicate, thisArg) { + var result = []; + if (!(array && array.length)) { + return result; + } + var index = -1, indexes = [], length = array.length; + predicate = getCallback(predicate, thisArg, 3); + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result.push(value); + indexes.push(index); + } + } + basePullAt(array, indexes); + return result; + } + function rest(array) { + return drop(array, 1); + } + function slice(array, start, end) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (end && typeof end != "number" && isIterateeCall(array, start, end)) { + start = 0; + end = length; + } + return baseSlice(array, start, end); + } + var sortedIndex = createSortedIndex(); + var sortedLastIndex = createSortedIndex(true); + function take(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + return baseSlice(array, 0, n < 0 ? 0 : n); + } + function takeRight(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + n = length - (+n || 0); + return baseSlice(array, n < 0 ? 0 : n); + } + function takeRightWhile(array, predicate, thisArg) { + return array && array.length ? baseWhile(array, getCallback(predicate, thisArg, 3), false, true) : []; + } + function takeWhile(array, predicate, thisArg) { + return array && array.length ? baseWhile(array, getCallback(predicate, thisArg, 3)) : []; + } + var union = restParam(function(arrays) { + return baseUniq(baseFlatten(arrays, false, true)); + }); + function uniq(array, isSorted, iteratee, thisArg) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (isSorted != null && typeof isSorted != "boolean") { + thisArg = iteratee; + iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted; + isSorted = false; + } + var callback = getCallback(); + if (!(iteratee == null && callback === baseCallback)) { + iteratee = callback(iteratee, thisArg, 3); + } + return isSorted && getIndexOf() === baseIndexOf ? sortedUniq(array, iteratee) : baseUniq(array, iteratee); + } + function unzip(array) { + if (!(array && array.length)) { + return []; + } + var index = -1, length = 0; + array = arrayFilter(array, function(group) { + if (isArrayLike(group)) { + length = nativeMax(group.length, length); + return true; + } + }); + var result = Array(length); + while (++index < length) { + result[index] = arrayMap(array, baseProperty(index)); + } + return result; + } + function unzipWith(array, iteratee, thisArg) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + var result = unzip(array); + if (iteratee == null) { + return result; + } + iteratee = bindCallback(iteratee, thisArg, 4); + return arrayMap(result, function(group) { + return arrayReduce(group, iteratee, undefined, true); + }); + } + var without = restParam(function(array, values) { + return isArrayLike(array) ? baseDifference(array, values) : []; + }); + function xor() { + var index = -1, length = arguments.length; + while (++index < length) { + var array = arguments[index]; + if (isArrayLike(array)) { + var result = result ? arrayPush(baseDifference(result, array), baseDifference(array, result)) : array; + } + } + return result ? baseUniq(result) : []; + } + var zip = restParam(unzip); + function zipObject(props, values) { + var index = -1, length = props ? props.length : 0, result = {}; + if (length && !values && !isArray(props[0])) { + values = []; + } + while (++index < length) { + var key = props[index]; + if (values) { + result[key] = values[index]; + } else if (key) { + result[key[0]] = key[1]; + } + } + return result; + } + var zipWith = restParam(function(arrays) { + var length = arrays.length, iteratee = length > 2 ? arrays[length - 2] : undefined, thisArg = length > 1 ? arrays[length - 1] : undefined; + if (length > 2 && typeof iteratee == "function") { + length -= 2; + } else { + iteratee = length > 1 && typeof thisArg == "function" ? (--length, thisArg) : undefined; + thisArg = undefined; + } + arrays.length = length; + return unzipWith(arrays, iteratee, thisArg); + }); + function chain(value) { + var result = lodash(value); + result.__chain__ = true; + return result; + } + function tap(value, interceptor, thisArg) { + interceptor.call(thisArg, value); + return value; + } + function thru(value, interceptor, thisArg) { + return interceptor.call(thisArg, value); + } + function wrapperChain() { + return chain(this); + } + function wrapperCommit() { + return new LodashWrapper(this.value(), this.__chain__); + } + var wrapperConcat = restParam(function(values) { + values = baseFlatten(values); + return this.thru(function(array) { + return arrayConcat(isArray(array) ? array : [ toObject(array) ], values); + }); + }); + function wrapperPlant(value) { + var result, parent = this; + while (parent instanceof baseLodash) { + var clone = wrapperClone(parent); + if (result) { + previous.__wrapped__ = clone; + } else { + result = clone; + } + var previous = clone; + parent = parent.__wrapped__; + } + previous.__wrapped__ = value; + return result; + } + function wrapperReverse() { + var value = this.__wrapped__; + var interceptor = function(value) { + return value.reverse(); + }; + if (value instanceof LazyWrapper) { + var wrapped = value; + if (this.__actions__.length) { + wrapped = new LazyWrapper(this); + } + wrapped = wrapped.reverse(); + wrapped.__actions__.push({ + func: thru, + args: [ interceptor ], + thisArg: undefined + }); + return new LodashWrapper(wrapped, this.__chain__); + } + return this.thru(interceptor); + } + function wrapperToString() { + return this.value() + ""; + } + function wrapperValue() { + return baseWrapperValue(this.__wrapped__, this.__actions__); + } + var at = restParam(function(collection, props) { + return baseAt(collection, baseFlatten(props)); + }); + var countBy = createAggregator(function(result, value, key) { + hasOwnProperty.call(result, key) ? ++result[key] : result[key] = 1; + }); + function every(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayEvery : baseEvery; + if (thisArg && isIterateeCall(collection, predicate, thisArg)) { + predicate = undefined; + } + if (typeof predicate != "function" || thisArg !== undefined) { + predicate = getCallback(predicate, thisArg, 3); + } + return func(collection, predicate); + } + function filter(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayFilter : baseFilter; + predicate = getCallback(predicate, thisArg, 3); + return func(collection, predicate); + } + var find = createFind(baseEach); + var findLast = createFind(baseEachRight, true); + function findWhere(collection, source) { + return find(collection, baseMatches(source)); + } + var forEach = createForEach(arrayEach, baseEach); + var forEachRight = createForEach(arrayEachRight, baseEachRight); + var groupBy = createAggregator(function(result, value, key) { + if (hasOwnProperty.call(result, key)) { + result[key].push(value); + } else { + result[key] = [ value ]; + } + }); + function includes(collection, target, fromIndex, guard) { + var length = collection ? getLength(collection) : 0; + if (!isLength(length)) { + collection = values(collection); + length = collection.length; + } + if (typeof fromIndex != "number" || guard && isIterateeCall(target, fromIndex, guard)) { + fromIndex = 0; + } else { + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex || 0; + } + return typeof collection == "string" || !isArray(collection) && isString(collection) ? fromIndex <= length && collection.indexOf(target, fromIndex) > -1 : !!length && getIndexOf(collection, target, fromIndex) > -1; + } + var indexBy = createAggregator(function(result, value, key) { + result[key] = value; + }); + var invoke = restParam(function(collection, path, args) { + var index = -1, isFunc = typeof path == "function", isProp = isKey(path), result = isArrayLike(collection) ? Array(collection.length) : []; + baseEach(collection, function(value) { + var func = isFunc ? path : isProp && value != null ? value[path] : undefined; + result[++index] = func ? func.apply(value, args) : invokePath(value, path, args); + }); + return result; + }); + function map(collection, iteratee, thisArg) { + var func = isArray(collection) ? arrayMap : baseMap; + iteratee = getCallback(iteratee, thisArg, 3); + return func(collection, iteratee); + } + var partition = createAggregator(function(result, value, key) { + result[key ? 0 : 1].push(value); + }, function() { + return [ [], [] ]; + }); + function pluck(collection, path) { + return map(collection, property(path)); + } + var reduce = createReduce(arrayReduce, baseEach); + var reduceRight = createReduce(arrayReduceRight, baseEachRight); + function reject(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayFilter : baseFilter; + predicate = getCallback(predicate, thisArg, 3); + return func(collection, function(value, index, collection) { + return !predicate(value, index, collection); + }); + } + function sample(collection, n, guard) { + if (guard ? isIterateeCall(collection, n, guard) : n == null) { + collection = toIterable(collection); + var length = collection.length; + return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; + } + var index = -1, result = toArray(collection), length = result.length, lastIndex = length - 1; + n = nativeMin(n < 0 ? 0 : +n || 0, length); + while (++index < n) { + var rand = baseRandom(index, lastIndex), value = result[rand]; + result[rand] = result[index]; + result[index] = value; + } + result.length = n; + return result; + } + function shuffle(collection) { + return sample(collection, POSITIVE_INFINITY); + } + function size(collection) { + var length = collection ? getLength(collection) : 0; + return isLength(length) ? length : keys(collection).length; + } + function some(collection, predicate, thisArg) { + var func = isArray(collection) ? arraySome : baseSome; + if (thisArg && isIterateeCall(collection, predicate, thisArg)) { + predicate = undefined; + } + if (typeof predicate != "function" || thisArg !== undefined) { + predicate = getCallback(predicate, thisArg, 3); + } + return func(collection, predicate); + } + function sortBy(collection, iteratee, thisArg) { + if (collection == null) { + return []; + } + if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { + iteratee = undefined; + } + var index = -1; + iteratee = getCallback(iteratee, thisArg, 3); + var result = baseMap(collection, function(value, key, collection) { + return { + criteria: iteratee(value, key, collection), + index: ++index, + value: value + }; + }); + return baseSortBy(result, compareAscending); + } + var sortByAll = restParam(function(collection, iteratees) { + if (collection == null) { + return []; + } + var guard = iteratees[2]; + if (guard && isIterateeCall(iteratees[0], iteratees[1], guard)) { + iteratees.length = 1; + } + return baseSortByOrder(collection, baseFlatten(iteratees), []); + }); + function sortByOrder(collection, iteratees, orders, guard) { + if (collection == null) { + return []; + } + if (guard && isIterateeCall(iteratees, orders, guard)) { + orders = undefined; + } + if (!isArray(iteratees)) { + iteratees = iteratees == null ? [] : [ iteratees ]; + } + if (!isArray(orders)) { + orders = orders == null ? [] : [ orders ]; + } + return baseSortByOrder(collection, iteratees, orders); + } + function where(collection, source) { + return filter(collection, baseMatches(source)); + } + var now = nativeNow || function() { + return new Date().getTime(); + }; + function after(n, func) { + if (typeof func != "function") { + if (typeof n == "function") { + var temp = n; + n = func; + func = temp; + } else { + throw new TypeError(FUNC_ERROR_TEXT); + } + } + n = nativeIsFinite(n = +n) ? n : 0; + return function() { + if (--n < 1) { + return func.apply(this, arguments); + } + }; + } + function ary(func, n, guard) { + if (guard && isIterateeCall(func, n, guard)) { + n = undefined; + } + n = func && n == null ? func.length : nativeMax(+n || 0, 0); + return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n); + } + function before(n, func) { + var result; + if (typeof func != "function") { + if (typeof n == "function") { + var temp = n; + n = func; + func = temp; + } else { + throw new TypeError(FUNC_ERROR_TEXT); + } + } + return function() { + if (--n > 0) { + result = func.apply(this, arguments); + } + if (n <= 1) { + func = undefined; + } + return result; + }; + } + var bind = restParam(function(func, thisArg, partials) { + var bitmask = BIND_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, bind.placeholder); + bitmask |= PARTIAL_FLAG; + } + return createWrapper(func, bitmask, thisArg, partials, holders); + }); + var bindAll = restParam(function(object, methodNames) { + methodNames = methodNames.length ? baseFlatten(methodNames) : functions(object); + var index = -1, length = methodNames.length; + while (++index < length) { + var key = methodNames[index]; + object[key] = createWrapper(object[key], BIND_FLAG, object); + } + return object; + }); + var bindKey = restParam(function(object, key, partials) { + var bitmask = BIND_FLAG | BIND_KEY_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, bindKey.placeholder); + bitmask |= PARTIAL_FLAG; + } + return createWrapper(key, bitmask, object, partials, holders); + }); + var curry = createCurry(CURRY_FLAG); + var curryRight = createCurry(CURRY_RIGHT_FLAG); + function debounce(func, wait, options) { + var args, maxTimeoutId, result, stamp, thisArg, timeoutId, trailingCall, lastCalled = 0, maxWait = false, trailing = true; + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + wait = wait < 0 ? 0 : +wait || 0; + if (options === true) { + var leading = true; + trailing = false; + } else if (isObject(options)) { + leading = !!options.leading; + maxWait = "maxWait" in options && nativeMax(+options.maxWait || 0, wait); + trailing = "trailing" in options ? !!options.trailing : trailing; + } + function cancel() { + if (timeoutId) { + clearTimeout(timeoutId); + } + if (maxTimeoutId) { + clearTimeout(maxTimeoutId); + } + lastCalled = 0; + maxTimeoutId = timeoutId = trailingCall = undefined; + } + function complete(isCalled, id) { + if (id) { + clearTimeout(id); + } + maxTimeoutId = timeoutId = trailingCall = undefined; + if (isCalled) { + lastCalled = now(); + result = func.apply(thisArg, args); + if (!timeoutId && !maxTimeoutId) { + args = thisArg = undefined; + } + } + } + function delayed() { + var remaining = wait - (now() - stamp); + if (remaining <= 0 || remaining > wait) { + complete(trailingCall, maxTimeoutId); + } else { + timeoutId = setTimeout(delayed, remaining); + } + } + function maxDelayed() { + complete(trailing, timeoutId); + } + function debounced() { + args = arguments; + stamp = now(); + thisArg = this; + trailingCall = trailing && (timeoutId || !leading); + if (maxWait === false) { + var leadingCall = leading && !timeoutId; + } else { + if (!maxTimeoutId && !leading) { + lastCalled = stamp; + } + var remaining = maxWait - (stamp - lastCalled), isCalled = remaining <= 0 || remaining > maxWait; + if (isCalled) { + if (maxTimeoutId) { + maxTimeoutId = clearTimeout(maxTimeoutId); + } + lastCalled = stamp; + result = func.apply(thisArg, args); + } else if (!maxTimeoutId) { + maxTimeoutId = setTimeout(maxDelayed, remaining); + } + } + if (isCalled && timeoutId) { + timeoutId = clearTimeout(timeoutId); + } else if (!timeoutId && wait !== maxWait) { + timeoutId = setTimeout(delayed, wait); + } + if (leadingCall) { + isCalled = true; + result = func.apply(thisArg, args); + } + if (isCalled && !timeoutId && !maxTimeoutId) { + args = thisArg = undefined; + } + return result; + } + debounced.cancel = cancel; + return debounced; + } + var defer = restParam(function(func, args) { + return baseDelay(func, 1, args); + }); + var delay = restParam(function(func, wait, args) { + return baseDelay(func, wait, args); + }); + var flow = createFlow(); + var flowRight = createFlow(true); + function memoize(func, resolver) { + if (typeof func != "function" || resolver && typeof resolver != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache; + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result); + return result; + }; + memoized.cache = new memoize.Cache(); + return memoized; + } + var modArgs = restParam(function(func, transforms) { + transforms = baseFlatten(transforms); + if (typeof func != "function" || !arrayEvery(transforms, baseIsFunction)) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var length = transforms.length; + return restParam(function(args) { + var index = nativeMin(args.length, length); + while (index--) { + args[index] = transforms[index](args[index]); + } + return func.apply(this, args); + }); + }); + function negate(predicate) { + if (typeof predicate != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + return function() { + return !predicate.apply(this, arguments); }; + } + function once(func) { + return before(2, func); + } + var partial = createPartial(PARTIAL_FLAG); + var partialRight = createPartial(PARTIAL_RIGHT_FLAG); + var rearg = restParam(function(func, indexes) { + return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes)); + }); + function restParam(func, start) { + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + start = nativeMax(start === undefined ? func.length - 1 : +start || 0, 0); + return function() { + var args = arguments, index = -1, length = nativeMax(args.length - start, 0), rest = Array(length); + while (++index < length) { + rest[index] = args[start + index]; + } + switch (start) { + case 0: + return func.call(this, rest); - case 2: - return function(value, other) { - return func.call(context, value, other); - }; + case 1: + return func.call(this, args[0], rest); - case 3: - return function(value, index, collection) { - return func.call(context, value, index, collection); + case 2: + return func.call(this, args[0], args[1], rest); + } + var otherArgs = Array(start + 1); + index = -1; + while (++index < start) { + otherArgs[index] = args[index]; + } + otherArgs[start] = rest; + return func.apply(this, otherArgs); }; - - case 4: - return function(accumulator, value, index, collection) { - return func.call(context, accumulator, value, index, collection); + } + function spread(func) { + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + return function(array) { + return func.apply(this, array); }; } - return function() { - return func.apply(context, arguments); - }; - }; - var cb = function(value, context, argCount) { - if (value == null) return _.identity; - if (_.isFunction(value)) return optimizeCb(value, context, argCount); - if (_.isObject(value)) return _.matcher(value); - return _.property(value); - }; - _.iteratee = function(value, context) { - return cb(value, context, Infinity); - }; - var createAssigner = function(keysFunc, undefinedOnly) { - return function(obj) { - var length = arguments.length; - if (length < 2 || obj == null) return obj; - for (var index = 1; index < length; index++) { - var source = arguments[index], keys = keysFunc(source), l = keys.length; - for (var i = 0; i < l; i++) { - var key = keys[i]; - if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key]; - } + function throttle(func, wait, options) { + var leading = true, trailing = true; + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); } - return obj; - }; - }; - var baseCreate = function(prototype) { - if (!_.isObject(prototype)) return {}; - if (nativeCreate) return nativeCreate(prototype); - Ctor.prototype = prototype; - var result = new Ctor(); - Ctor.prototype = null; - return result; - }; - var property = function(key) { - return function(obj) { - return obj == null ? void 0 : obj[key]; + if (options === false) { + leading = false; + } else if (isObject(options)) { + leading = "leading" in options ? !!options.leading : leading; + trailing = "trailing" in options ? !!options.trailing : trailing; + } + return debounce(func, wait, { + leading: leading, + maxWait: +wait, + trailing: trailing + }); + } + function wrap(value, wrapper) { + wrapper = wrapper == null ? identity : wrapper; + return createWrapper(wrapper, PARTIAL_FLAG, undefined, [ value ], []); + } + function clone(value, isDeep, customizer, thisArg) { + if (isDeep && typeof isDeep != "boolean" && isIterateeCall(value, isDeep, customizer)) { + isDeep = false; + } else if (typeof isDeep == "function") { + thisArg = customizer; + customizer = isDeep; + isDeep = false; + } + return typeof customizer == "function" ? baseClone(value, isDeep, bindCallback(customizer, thisArg, 3)) : baseClone(value, isDeep); + } + function cloneDeep(value, customizer, thisArg) { + return typeof customizer == "function" ? baseClone(value, true, bindCallback(customizer, thisArg, 3)) : baseClone(value, true); + } + function gt(value, other) { + return value > other; + } + function gte(value, other) { + return value >= other; + } + function isArguments(value) { + return isObjectLike(value) && isArrayLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee"); + } + var isArray = nativeIsArray || function(value) { + return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag; }; - }; - var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; - var getLength = property("length"); - var isArrayLike = function(collection) { - var length = getLength(collection); - return typeof length == "number" && length >= 0 && length <= MAX_ARRAY_INDEX; - }; - _.each = _.forEach = function(obj, iteratee, context) { - iteratee = optimizeCb(iteratee, context); - var i, length; - if (isArrayLike(obj)) { - for (i = 0, length = obj.length; i < length; i++) { - iteratee(obj[i], i, obj); + function isBoolean(value) { + return value === true || value === false || isObjectLike(value) && objToString.call(value) == boolTag; + } + function isDate(value) { + return isObjectLike(value) && objToString.call(value) == dateTag; + } + function isElement(value) { + return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value); + } + function isEmpty(value) { + if (value == null) { + return true; } - } else { - var keys = _.keys(obj); - for (i = 0, length = keys.length; i < length; i++) { - iteratee(obj[keys[i]], keys[i], obj); + if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) || isObjectLike(value) && isFunction(value.splice))) { + return !value.length; } + return !keys(value).length; } - return obj; - }; - _.map = _.collect = function(obj, iteratee, context) { - iteratee = cb(iteratee, context); - var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length, results = Array(length); - for (var index = 0; index < length; index++) { - var currentKey = keys ? keys[index] : index; - results[index] = iteratee(obj[currentKey], currentKey, obj); + function isEqual(value, other, customizer, thisArg) { + customizer = typeof customizer == "function" ? bindCallback(customizer, thisArg, 3) : undefined; + var result = customizer ? customizer(value, other) : undefined; + return result === undefined ? baseIsEqual(value, other, customizer) : !!result; } - return results; - }; - function createReduce(dir) { - function iterator(obj, iteratee, memo, keys, index, length) { - for (;index >= 0 && index < length; index += dir) { - var currentKey = keys ? keys[index] : index; - memo = iteratee(memo, obj[currentKey], currentKey, obj); + function isError(value) { + return isObjectLike(value) && typeof value.message == "string" && objToString.call(value) == errorTag; + } + function isFinite(value) { + return typeof value == "number" && nativeIsFinite(value); + } + function isFunction(value) { + return isObject(value) && objToString.call(value) == funcTag; + } + function isObject(value) { + var type = typeof value; + return !!value && (type == "object" || type == "function"); + } + function isMatch(object, source, customizer, thisArg) { + customizer = typeof customizer == "function" ? bindCallback(customizer, thisArg, 3) : undefined; + return baseIsMatch(object, getMatchData(source), customizer); + } + function isNaN(value) { + return isNumber(value) && value != +value; + } + function isNative(value) { + if (value == null) { + return false; } - return memo; + if (isFunction(value)) { + return reIsNative.test(fnToString.call(value)); + } + return isObjectLike(value) && reIsHostCtor.test(value); } - return function(obj, iteratee, memo, context) { - iteratee = optimizeCb(iteratee, context, 4); - var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length, index = dir > 0 ? 0 : length - 1; - if (arguments.length < 3) { - memo = obj[keys ? keys[index] : index]; - index += dir; + function isNull(value) { + return value === null; + } + function isNumber(value) { + return typeof value == "number" || isObjectLike(value) && objToString.call(value) == numberTag; + } + function isPlainObject(value) { + var Ctor; + if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) || !hasOwnProperty.call(value, "constructor") && (Ctor = value.constructor, + typeof Ctor == "function" && !(Ctor instanceof Ctor))) { + return false; } - return iterator(obj, iteratee, memo, keys, index, length); - }; - } - _.reduce = _.foldl = _.inject = createReduce(1); - _.reduceRight = _.foldr = createReduce(-1); - _.find = _.detect = function(obj, predicate, context) { - var key; - if (isArrayLike(obj)) { - key = _.findIndex(obj, predicate, context); - } else { - key = _.findKey(obj, predicate, context); + var result; + baseForIn(value, function(subValue, key) { + result = key; + }); + return result === undefined || hasOwnProperty.call(value, result); } - if (key !== void 0 && key !== -1) return obj[key]; - }; - _.filter = _.select = function(obj, predicate, context) { - var results = []; - predicate = cb(predicate, context); - _.each(obj, function(value, index, list) { - if (predicate(value, index, list)) results.push(value); - }); - return results; - }; - _.reject = function(obj, predicate, context) { - return _.filter(obj, _.negate(cb(predicate)), context); - }; - _.every = _.all = function(obj, predicate, context) { - predicate = cb(predicate, context); - var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length; - for (var index = 0; index < length; index++) { - var currentKey = keys ? keys[index] : index; - if (!predicate(obj[currentKey], currentKey, obj)) return false; + function isRegExp(value) { + return isObject(value) && objToString.call(value) == regexpTag; } - return true; - }; - _.some = _.any = function(obj, predicate, context) { - predicate = cb(predicate, context); - var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length; - for (var index = 0; index < length; index++) { - var currentKey = keys ? keys[index] : index; - if (predicate(obj[currentKey], currentKey, obj)) return true; + function isString(value) { + return typeof value == "string" || isObjectLike(value) && objToString.call(value) == stringTag; } - return false; - }; - _.contains = _.includes = _.include = function(obj, item, fromIndex, guard) { - if (!isArrayLike(obj)) obj = _.values(obj); - if (typeof fromIndex != "number" || guard) fromIndex = 0; - return _.indexOf(obj, item, fromIndex) >= 0; - }; - _.invoke = function(obj, method) { - var args = slice.call(arguments, 2); - var isFunc = _.isFunction(method); - return _.map(obj, function(value) { - var func = isFunc ? method : value[method]; - return func == null ? func : func.apply(value, args); + function isTypedArray(value) { + return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)]; + } + function isUndefined(value) { + return value === undefined; + } + function lt(value, other) { + return value < other; + } + function lte(value, other) { + return value <= other; + } + function toArray(value) { + var length = value ? getLength(value) : 0; + if (!isLength(length)) { + return values(value); + } + if (!length) { + return []; + } + return arrayCopy(value); + } + function toPlainObject(value) { + return baseCopy(value, keysIn(value)); + } + var merge = createAssigner(baseMerge); + var assign = createAssigner(function(object, source, customizer) { + return customizer ? assignWith(object, source, customizer) : baseAssign(object, source); }); - }; - _.pluck = function(obj, key) { - return _.map(obj, _.property(key)); - }; - _.where = function(obj, attrs) { - return _.filter(obj, _.matcher(attrs)); - }; - _.findWhere = function(obj, attrs) { - return _.find(obj, _.matcher(attrs)); - }; - _.max = function(obj, iteratee, context) { - var result = -Infinity, lastComputed = -Infinity, value, computed; - if (iteratee == null && obj != null) { - obj = isArrayLike(obj) ? obj : _.values(obj); - for (var i = 0, length = obj.length; i < length; i++) { - value = obj[i]; - if (value > result) { - result = value; - } + function create(prototype, properties, guard) { + var result = baseCreate(prototype); + if (guard && isIterateeCall(prototype, properties, guard)) { + properties = undefined; + } + return properties ? baseAssign(result, properties) : result; + } + var defaults = createDefaults(assign, assignDefaults); + var defaultsDeep = createDefaults(merge, mergeDefaults); + var findKey = createFindKey(baseForOwn); + var findLastKey = createFindKey(baseForOwnRight); + var forIn = createForIn(baseFor); + var forInRight = createForIn(baseForRight); + var forOwn = createForOwn(baseForOwn); + var forOwnRight = createForOwn(baseForOwnRight); + function functions(object) { + return baseFunctions(object, keysIn(object)); + } + function get(object, path, defaultValue) { + var result = object == null ? undefined : baseGet(object, toPath(path), path + ""); + return result === undefined ? defaultValue : result; + } + function has(object, path) { + if (object == null) { + return false; } - } else { - iteratee = cb(iteratee, context); - _.each(obj, function(value, index, list) { - computed = iteratee(value, index, list); - if (computed > lastComputed || computed === -Infinity && result === -Infinity) { - result = value; - lastComputed = computed; + var result = hasOwnProperty.call(object, path); + if (!result && !isKey(path)) { + path = toPath(path); + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + if (object == null) { + return false; } - }); + path = last(path); + result = hasOwnProperty.call(object, path); + } + return result || isLength(object.length) && isIndex(path, object.length) && (isArray(object) || isArguments(object)); } - return result; - }; - _.min = function(obj, iteratee, context) { - var result = Infinity, lastComputed = Infinity, value, computed; - if (iteratee == null && obj != null) { - obj = isArrayLike(obj) ? obj : _.values(obj); - for (var i = 0, length = obj.length; i < length; i++) { - value = obj[i]; - if (value < result) { - result = value; - } + function invert(object, multiValue, guard) { + if (guard && isIterateeCall(object, multiValue, guard)) { + multiValue = undefined; } - } else { - iteratee = cb(iteratee, context); - _.each(obj, function(value, index, list) { - computed = iteratee(value, index, list); - if (computed < lastComputed || computed === Infinity && result === Infinity) { - result = value; - lastComputed = computed; + var index = -1, props = keys(object), length = props.length, result = {}; + while (++index < length) { + var key = props[index], value = object[key]; + if (multiValue) { + if (hasOwnProperty.call(result, value)) { + result[value].push(key); + } else { + result[value] = [ key ]; + } + } else { + result[value] = key; } - }); - } - return result; - }; - _.shuffle = function(obj) { - var set = isArrayLike(obj) ? obj : _.values(obj); - var length = set.length; - var shuffled = Array(length); - for (var index = 0, rand; index < length; index++) { - rand = _.random(0, index); - if (rand !== index) shuffled[index] = shuffled[rand]; - shuffled[rand] = set[index]; + } + return result; } - return shuffled; - }; - _.sample = function(obj, n, guard) { - if (n == null || guard) { - if (!isArrayLike(obj)) obj = _.values(obj); - return obj[_.random(obj.length - 1)]; + var keys = !nativeKeys ? shimKeys : function(object) { + var Ctor = object == null ? undefined : object.constructor; + if (typeof Ctor == "function" && Ctor.prototype === object || typeof object != "function" && isArrayLike(object)) { + return shimKeys(object); + } + return isObject(object) ? nativeKeys(object) : []; + }; + function keysIn(object) { + if (object == null) { + return []; + } + if (!isObject(object)) { + object = Object(object); + } + var length = object.length; + length = length && isLength(length) && (isArray(object) || isArguments(object)) && length || 0; + var Ctor = object.constructor, index = -1, isProto = typeof Ctor == "function" && Ctor.prototype === object, result = Array(length), skipIndexes = length > 0; + while (++index < length) { + result[index] = index + ""; + } + for (var key in object) { + if (!(skipIndexes && isIndex(key, length)) && !(key == "constructor" && (isProto || !hasOwnProperty.call(object, key)))) { + result.push(key); + } + } + return result; } - return _.shuffle(obj).slice(0, Math.max(0, n)); - }; - _.sortBy = function(obj, iteratee, context) { - iteratee = cb(iteratee, context); - return _.pluck(_.map(obj, function(value, index, list) { - return { - value: value, - index: index, - criteria: iteratee(value, index, list) - }; - }).sort(function(left, right) { - var a = left.criteria; - var b = right.criteria; - if (a !== b) { - if (a > b || a === void 0) return 1; - if (a < b || b === void 0) return -1; + var mapKeys = createObjectMapper(true); + var mapValues = createObjectMapper(); + var omit = restParam(function(object, props) { + if (object == null) { + return {}; } - return left.index - right.index; - }), "value"); - }; - var group = function(behavior) { - return function(obj, iteratee, context) { - var result = {}; - iteratee = cb(iteratee, context); - _.each(obj, function(value, index) { - var key = iteratee(value, index, obj); - behavior(result, value, key); + if (typeof props[0] != "function") { + var props = arrayMap(baseFlatten(props), String); + return pickByArray(object, baseDifference(keysIn(object), props)); + } + var predicate = bindCallback(props[0], props[1], 3); + return pickByCallback(object, function(value, key, object) { + return !predicate(value, key, object); }); + }); + function pairs(object) { + object = toObject(object); + var index = -1, props = keys(object), length = props.length, result = Array(length); + while (++index < length) { + var key = props[index]; + result[index] = [ key, object[key] ]; + } return result; - }; - }; - _.groupBy = group(function(result, value, key) { - if (_.has(result, key)) result[key].push(value); else result[key] = [ value ]; - }); - _.indexBy = group(function(result, value, key) { - result[key] = value; - }); - _.countBy = group(function(result, value, key) { - if (_.has(result, key)) result[key]++; else result[key] = 1; - }); - _.toArray = function(obj) { - if (!obj) return []; - if (_.isArray(obj)) return slice.call(obj); - if (isArrayLike(obj)) return _.map(obj, _.identity); - return _.values(obj); - }; - _.size = function(obj) { - if (obj == null) return 0; - return isArrayLike(obj) ? obj.length : _.keys(obj).length; - }; - _.partition = function(obj, predicate, context) { - predicate = cb(predicate, context); - var pass = [], fail = []; - _.each(obj, function(value, key, obj) { - (predicate(value, key, obj) ? pass : fail).push(value); + } + var pick = restParam(function(object, props) { + if (object == null) { + return {}; + } + return typeof props[0] == "function" ? pickByCallback(object, bindCallback(props[0], props[1], 3)) : pickByArray(object, baseFlatten(props)); }); - return [ pass, fail ]; - }; - _.first = _.head = _.take = function(array, n, guard) { - if (array == null) return void 0; - if (n == null || guard) return array[0]; - return _.initial(array, array.length - n); - }; - _.initial = function(array, n, guard) { - return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); - }; - _.last = function(array, n, guard) { - if (array == null) return void 0; - if (n == null || guard) return array[array.length - 1]; - return _.rest(array, Math.max(0, array.length - n)); - }; - _.rest = _.tail = _.drop = function(array, n, guard) { - return slice.call(array, n == null || guard ? 1 : n); - }; - _.compact = function(array) { - return _.filter(array, _.identity); - }; - var flatten = function(input, shallow, strict, startIndex) { - var output = [], idx = 0; - for (var i = startIndex || 0, length = getLength(input); i < length; i++) { - var value = input[i]; - if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) { - if (!shallow) value = flatten(value, shallow, strict); - var j = 0, len = value.length; - output.length += len; - while (j < len) { - output[idx++] = value[j++]; + function result(object, path, defaultValue) { + var result = object == null ? undefined : object[path]; + if (result === undefined) { + if (object != null && !isKey(path, object)) { + path = toPath(path); + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + result = object == null ? undefined : object[last(path)]; + } + result = result === undefined ? defaultValue : result; + } + return isFunction(result) ? result.call(object) : result; + } + function set(object, path, value) { + if (object == null) { + return object; + } + var pathKey = path + ""; + path = object[pathKey] != null || isKey(path, object) ? [ pathKey ] : toPath(path); + var index = -1, length = path.length, lastIndex = length - 1, nested = object; + while (nested != null && ++index < length) { + var key = path[index]; + if (isObject(nested)) { + if (index == lastIndex) { + nested[key] = value; + } else if (nested[key] == null) { + nested[key] = isIndex(path[index + 1]) ? [] : {}; + } + } + nested = nested[key]; + } + return object; + } + function transform(object, iteratee, accumulator, thisArg) { + var isArr = isArray(object) || isTypedArray(object); + iteratee = getCallback(iteratee, thisArg, 4); + if (accumulator == null) { + if (isArr || isObject(object)) { + var Ctor = object.constructor; + if (isArr) { + accumulator = isArray(object) ? new Ctor() : []; + } else { + accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined); + } + } else { + accumulator = {}; } - } else if (!strict) { - output[idx++] = value; } + (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) { + return iteratee(accumulator, value, index, object); + }); + return accumulator; } - return output; - }; - _.flatten = function(array, shallow) { - return flatten(array, shallow, false); - }; - _.without = function(array) { - return _.difference(array, slice.call(arguments, 1)); - }; - _.uniq = _.unique = function(array, isSorted, iteratee, context) { - if (!_.isBoolean(isSorted)) { - context = iteratee; - iteratee = isSorted; - isSorted = false; + function values(object) { + return baseValues(object, keys(object)); } - if (iteratee != null) iteratee = cb(iteratee, context); - var result = []; - var seen = []; - for (var i = 0, length = getLength(array); i < length; i++) { - var value = array[i], computed = iteratee ? iteratee(value, i, array) : value; - if (isSorted) { - if (!i || seen !== computed) result.push(value); - seen = computed; - } else if (iteratee) { - if (!_.contains(seen, computed)) { - seen.push(computed); - result.push(value); - } - } else if (!_.contains(result, value)) { - result.push(value); - } + function valuesIn(object) { + return baseValues(object, keysIn(object)); } - return result; - }; - _.union = function() { - return _.uniq(flatten(arguments, true, true)); - }; - _.intersection = function(array) { - var result = []; - var argsLength = arguments.length; - for (var i = 0, length = getLength(array); i < length; i++) { - var item = array[i]; - if (_.contains(result, item)) continue; - for (var j = 1; j < argsLength; j++) { - if (!_.contains(arguments[j], item)) break; + function inRange(value, start, end) { + start = +start || 0; + if (end === undefined) { + end = start; + start = 0; + } else { + end = +end || 0; } - if (j === argsLength) result.push(item); - } - return result; - }; - _.difference = function(array) { - var rest = flatten(arguments, true, true, 1); - return _.filter(array, function(value) { - return !_.contains(rest, value); - }); - }; - _.zip = function() { - return _.unzip(arguments); - }; - _.unzip = function(array) { - var length = array && _.max(array, getLength).length || 0; - var result = Array(length); - for (var index = 0; index < length; index++) { - result[index] = _.pluck(array, index); + return value >= nativeMin(start, end) && value < nativeMax(start, end); } - return result; - }; - _.object = function(list, values) { - var result = {}; - for (var i = 0, length = getLength(list); i < length; i++) { - if (values) { - result[list[i]] = values[i]; + function random(min, max, floating) { + if (floating && isIterateeCall(min, max, floating)) { + max = floating = undefined; + } + var noMin = min == null, noMax = max == null; + if (floating == null) { + if (noMax && typeof min == "boolean") { + floating = min; + min = 1; + } else if (typeof max == "boolean") { + floating = max; + noMax = true; + } + } + if (noMin && noMax) { + max = 1; + noMax = false; + } + min = +min || 0; + if (noMax) { + max = min; + min = 0; } else { - result[list[i][0]] = list[i][1]; + max = +max || 0; } + if (floating || min % 1 || max % 1) { + var rand = nativeRandom(); + return nativeMin(min + rand * (max - min + parseFloat("1e-" + ((rand + "").length - 1))), max); + } + return baseRandom(min, max); } - return result; - }; - function createPredicateIndexFinder(dir) { - return function(array, predicate, context) { - predicate = cb(predicate, context); - var length = getLength(array); - var index = dir > 0 ? 0 : length - 1; - for (;index >= 0 && index < length; index += dir) { - if (predicate(array[index], index, array)) return index; + var camelCase = createCompounder(function(result, word, index) { + word = word.toLowerCase(); + return result + (index ? word.charAt(0).toUpperCase() + word.slice(1) : word); + }); + function capitalize(string) { + string = baseToString(string); + return string && string.charAt(0).toUpperCase() + string.slice(1); + } + function deburr(string) { + string = baseToString(string); + return string && string.replace(reLatin1, deburrLetter).replace(reComboMark, ""); + } + function endsWith(string, target, position) { + string = baseToString(string); + target = target + ""; + var length = string.length; + position = position === undefined ? length : nativeMin(position < 0 ? 0 : +position || 0, length); + position -= target.length; + return position >= 0 && string.indexOf(target, position) == position; + } + function escape(string) { + string = baseToString(string); + return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, escapeHtmlChar) : string; + } + function escapeRegExp(string) { + string = baseToString(string); + return string && reHasRegExpChars.test(string) ? string.replace(reRegExpChars, escapeRegExpChar) : string || "(?:)"; + } + var kebabCase = createCompounder(function(result, word, index) { + return result + (index ? "-" : "") + word.toLowerCase(); + }); + function pad(string, length, chars) { + string = baseToString(string); + length = +length; + var strLength = string.length; + if (strLength >= length || !nativeIsFinite(length)) { + return string; + } + var mid = (length - strLength) / 2, leftLength = nativeFloor(mid), rightLength = nativeCeil(mid); + chars = createPadding("", rightLength, chars); + return chars.slice(0, leftLength) + string + chars; + } + var padLeft = createPadDir(); + var padRight = createPadDir(true); + function parseInt(string, radix, guard) { + if (guard ? isIterateeCall(string, radix, guard) : radix == null) { + radix = 0; + } else if (radix) { + radix = +radix; + } + string = trim(string); + return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10)); + } + function repeat(string, n) { + var result = ""; + string = baseToString(string); + n = +n; + if (n < 1 || !string || !nativeIsFinite(n)) { + return result; } - return -1; - }; - } - _.findIndex = createPredicateIndexFinder(1); - _.findLastIndex = createPredicateIndexFinder(-1); - _.sortedIndex = function(array, obj, iteratee, context) { - iteratee = cb(iteratee, context, 1); - var value = iteratee(obj); - var low = 0, high = getLength(array); - while (low < high) { - var mid = Math.floor((low + high) / 2); - if (iteratee(array[mid]) < value) low = mid + 1; else high = mid; - } - return low; - }; - function createIndexFinder(dir, predicateFind, sortedIndex) { - return function(array, item, idx) { - var i = 0, length = getLength(array); - if (typeof idx == "number") { - if (dir > 0) { - i = idx >= 0 ? idx : Math.max(idx + length, i); - } else { - length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; + do { + if (n % 2) { + result += string; } - } else if (sortedIndex && idx && length) { - idx = sortedIndex(array, item); - return array[idx] === item ? idx : -1; + n = nativeFloor(n / 2); + string += string; + } while (n); + return result; + } + var snakeCase = createCompounder(function(result, word, index) { + return result + (index ? "_" : "") + word.toLowerCase(); + }); + var startCase = createCompounder(function(result, word, index) { + return result + (index ? " " : "") + (word.charAt(0).toUpperCase() + word.slice(1)); + }); + function startsWith(string, target, position) { + string = baseToString(string); + position = position == null ? 0 : nativeMin(position < 0 ? 0 : +position || 0, string.length); + return string.lastIndexOf(target, position) == position; + } + function template(string, options, otherOptions) { + var settings = lodash.templateSettings; + if (otherOptions && isIterateeCall(string, options, otherOptions)) { + options = otherOptions = undefined; + } + string = baseToString(string); + options = assignWith(baseAssign({}, otherOptions || options), settings, assignOwnDefaults); + var imports = assignWith(baseAssign({}, options.imports), settings.imports, assignOwnDefaults), importsKeys = keys(imports), importsValues = baseValues(imports, importsKeys); + var isEscaping, isEvaluating, index = 0, interpolate = options.interpolate || reNoMatch, source = "__p += '"; + var reDelimiters = RegExp((options.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options.evaluate || reNoMatch).source + "|$", "g"); + var sourceURL = "//# sourceURL=" + ("sourceURL" in options ? options.sourceURL : "lodash.templateSources[" + ++templateCounter + "]") + "\n"; + string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { + interpolateValue || (interpolateValue = esTemplateValue); + source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); + if (escapeValue) { + isEscaping = true; + source += "' +\n__e(" + escapeValue + ") +\n'"; + } + if (evaluateValue) { + isEvaluating = true; + source += "';\n" + evaluateValue + ";\n__p += '"; + } + if (interpolateValue) { + source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; + } + index = offset + match.length; + return match; + }); + source += "';\n"; + var variable = options.variable; + if (!variable) { + source = "with (obj) {\n" + source + "\n}\n"; } - if (item !== item) { - idx = predicateFind(slice.call(array, i, length), _.isNaN); - return idx >= 0 ? idx + i : -1; + source = (isEvaluating ? source.replace(reEmptyStringLeading, "") : source).replace(reEmptyStringMiddle, "$1").replace(reEmptyStringTrailing, "$1;"); + source = "function(" + (variable || "obj") + ") {\n" + (variable ? "" : "obj || (obj = {});\n") + "var __t, __p = ''" + (isEscaping ? ", __e = _.escape" : "") + (isEvaluating ? ", __j = Array.prototype.join;\n" + "function print() { __p += __j.call(arguments, '') }\n" : ";\n") + source + "return __p\n}"; + var result = attempt(function() { + return Function(importsKeys, sourceURL + "return " + source).apply(undefined, importsValues); + }); + result.source = source; + if (isError(result)) { + throw result; } - for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) { - if (array[idx] === item) return idx; + return result; + } + function trim(string, chars, guard) { + var value = string; + string = baseToString(string); + if (!string) { + return string; } - return -1; - }; - } - _.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex); - _.lastIndexOf = createIndexFinder(-1, _.findLastIndex); - _.range = function(start, stop, step) { - if (stop == null) { - stop = start || 0; - start = 0; + if (guard ? isIterateeCall(value, chars, guard) : chars == null) { + return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1); + } + chars = chars + ""; + return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1); } - step = step || 1; - var length = Math.max(Math.ceil((stop - start) / step), 0); - var range = Array(length); - for (var idx = 0; idx < length; idx++, start += step) { - range[idx] = start; + function trimLeft(string, chars, guard) { + var value = string; + string = baseToString(string); + if (!string) { + return string; + } + if (guard ? isIterateeCall(value, chars, guard) : chars == null) { + return string.slice(trimmedLeftIndex(string)); + } + return string.slice(charsLeftIndex(string, chars + "")); } - return range; - }; - var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) { - if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); - var self = baseCreate(sourceFunc.prototype); - var result = sourceFunc.apply(self, args); - if (_.isObject(result)) return result; - return self; - }; - _.bind = function(func, context) { - if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); - if (!_.isFunction(func)) throw new TypeError("Bind must be called on a function"); - var args = slice.call(arguments, 2); - var bound = function() { - return executeBound(func, bound, context, this, args.concat(slice.call(arguments))); - }; - return bound; - }; - _.partial = function(func) { - var boundArgs = slice.call(arguments, 1); - var bound = function() { - var position = 0, length = boundArgs.length; - var args = Array(length); - for (var i = 0; i < length; i++) { - args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i]; + function trimRight(string, chars, guard) { + var value = string; + string = baseToString(string); + if (!string) { + return string; } - while (position < arguments.length) args.push(arguments[position++]); - return executeBound(func, bound, this, this, args); - }; - return bound; - }; - _.bindAll = function(obj) { - var i, length = arguments.length, key; - if (length <= 1) throw new Error("bindAll must be passed function names"); - for (i = 1; i < length; i++) { - key = arguments[i]; - obj[key] = _.bind(obj[key], obj); + if (guard ? isIterateeCall(value, chars, guard) : chars == null) { + return string.slice(0, trimmedRightIndex(string) + 1); + } + return string.slice(0, charsRightIndex(string, chars + "") + 1); } - return obj; - }; - _.memoize = function(func, hasher) { - var memoize = function(key) { - var cache = memoize.cache; - var address = "" + (hasher ? hasher.apply(this, arguments) : key); - if (!_.has(cache, address)) cache[address] = func.apply(this, arguments); - return cache[address]; - }; - memoize.cache = {}; - return memoize; - }; - _.delay = function(func, wait) { - var args = slice.call(arguments, 2); - return setTimeout(function() { - return func.apply(null, args); - }, wait); - }; - _.defer = _.partial(_.delay, _, 1); - _.throttle = function(func, wait, options) { - var context, args, result; - var timeout = null; - var previous = 0; - if (!options) options = {}; - var later = function() { - previous = options.leading === false ? 0 : _.now(); - timeout = null; - result = func.apply(context, args); - if (!timeout) context = args = null; - }; - return function() { - var now = _.now(); - if (!previous && options.leading === false) previous = now; - var remaining = wait - (now - previous); - context = this; - args = arguments; - if (remaining <= 0 || remaining > wait) { - if (timeout) { - clearTimeout(timeout); - timeout = null; - } - previous = now; - result = func.apply(context, args); - if (!timeout) context = args = null; - } else if (!timeout && options.trailing !== false) { - timeout = setTimeout(later, remaining); + function trunc(string, options, guard) { + if (guard && isIterateeCall(string, options, guard)) { + options = undefined; } - return result; - }; - }; - _.debounce = function(func, wait, immediate) { - var timeout, args, context, timestamp, result; - var later = function() { - var last = _.now() - timestamp; - if (last < wait && last >= 0) { - timeout = setTimeout(later, wait - last); - } else { - timeout = null; - if (!immediate) { - result = func.apply(context, args); - if (!timeout) context = args = null; + var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION; + if (options != null) { + if (isObject(options)) { + var separator = "separator" in options ? options.separator : separator; + length = "length" in options ? +options.length || 0 : length; + omission = "omission" in options ? baseToString(options.omission) : omission; + } else { + length = +options || 0; } } - }; - return function() { - context = this; - args = arguments; - timestamp = _.now(); - var callNow = immediate && !timeout; - if (!timeout) timeout = setTimeout(later, wait); - if (callNow) { - result = func.apply(context, args); - context = args = null; + string = baseToString(string); + if (length >= string.length) { + return string; } - return result; - }; - }; - _.wrap = function(func, wrapper) { - return _.partial(wrapper, func); - }; - _.negate = function(predicate) { - return function() { - return !predicate.apply(this, arguments); - }; - }; - _.compose = function() { - var args = arguments; - var start = args.length - 1; - return function() { - var i = start; - var result = args[start].apply(this, arguments); - while (i--) result = args[i].call(this, result); - return result; - }; - }; - _.after = function(times, func) { - return function() { - if (--times < 1) { - return func.apply(this, arguments); + var end = length - omission.length; + if (end < 1) { + return omission; } - }; - }; - _.before = function(times, func) { - var memo; - return function() { - if (--times > 0) { - memo = func.apply(this, arguments); - } - if (times <= 1) func = null; - return memo; - }; - }; - _.once = _.partial(_.before, 2); - var hasEnumBug = !{ - toString: null - }.propertyIsEnumerable("toString"); - var nonEnumerableProps = [ "valueOf", "isPrototypeOf", "toString", "propertyIsEnumerable", "hasOwnProperty", "toLocaleString" ]; - function collectNonEnumProps(obj, keys) { - var nonEnumIdx = nonEnumerableProps.length; - var constructor = obj.constructor; - var proto = _.isFunction(constructor) && constructor.prototype || ObjProto; - var prop = "constructor"; - if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop); - while (nonEnumIdx--) { - prop = nonEnumerableProps[nonEnumIdx]; - if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) { - keys.push(prop); - } - } - } - _.keys = function(obj) { - if (!_.isObject(obj)) return []; - if (nativeKeys) return nativeKeys(obj); - var keys = []; - for (var key in obj) if (_.has(obj, key)) keys.push(key); - if (hasEnumBug) collectNonEnumProps(obj, keys); - return keys; - }; - _.allKeys = function(obj) { - if (!_.isObject(obj)) return []; - var keys = []; - for (var key in obj) keys.push(key); - if (hasEnumBug) collectNonEnumProps(obj, keys); - return keys; - }; - _.values = function(obj) { - var keys = _.keys(obj); - var length = keys.length; - var values = Array(length); - for (var i = 0; i < length; i++) { - values[i] = obj[keys[i]]; + var result = string.slice(0, end); + if (separator == null) { + return result + omission; + } + if (isRegExp(separator)) { + if (string.slice(end).search(separator)) { + var match, newEnd, substring = string.slice(0, end); + if (!separator.global) { + separator = RegExp(separator.source, (reFlags.exec(separator) || "") + "g"); + } + separator.lastIndex = 0; + while (match = separator.exec(substring)) { + newEnd = match.index; + } + result = result.slice(0, newEnd == null ? end : newEnd); + } + } else if (string.indexOf(separator, end) != end) { + var index = result.lastIndexOf(separator); + if (index > -1) { + result = result.slice(0, index); + } + } + return result + omission; } - return values; - }; - _.mapObject = function(obj, iteratee, context) { - iteratee = cb(iteratee, context); - var keys = _.keys(obj), length = keys.length, results = {}, currentKey; - for (var index = 0; index < length; index++) { - currentKey = keys[index]; - results[currentKey] = iteratee(obj[currentKey], currentKey, obj); + function unescape(string) { + string = baseToString(string); + return string && reHasEscapedHtml.test(string) ? string.replace(reEscapedHtml, unescapeHtmlChar) : string; + } + function words(string, pattern, guard) { + if (guard && isIterateeCall(string, pattern, guard)) { + pattern = undefined; + } + string = baseToString(string); + return string.match(pattern || reWords) || []; + } + var attempt = restParam(function(func, args) { + try { + return func.apply(undefined, args); + } catch (e) { + return isError(e) ? e : new Error(e); + } + }); + function callback(func, thisArg, guard) { + if (guard && isIterateeCall(func, thisArg, guard)) { + thisArg = undefined; + } + return isObjectLike(func) ? matches(func) : baseCallback(func, thisArg); } - return results; - }; - _.pairs = function(obj) { - var keys = _.keys(obj); - var length = keys.length; - var pairs = Array(length); - for (var i = 0; i < length; i++) { - pairs[i] = [ keys[i], obj[keys[i]] ]; + function constant(value) { + return function() { + return value; + }; } - return pairs; - }; - _.invert = function(obj) { - var result = {}; - var keys = _.keys(obj); - for (var i = 0, length = keys.length; i < length; i++) { - result[obj[keys[i]]] = keys[i]; + function identity(value) { + return value; } - return result; - }; - _.functions = _.methods = function(obj) { - var names = []; - for (var key in obj) { - if (_.isFunction(obj[key])) names.push(key); + function matches(source) { + return baseMatches(baseClone(source, true)); } - return names.sort(); - }; - _.extend = createAssigner(_.allKeys); - _.extendOwn = _.assign = createAssigner(_.keys); - _.findKey = function(obj, predicate, context) { - predicate = cb(predicate, context); - var keys = _.keys(obj), key; - for (var i = 0, length = keys.length; i < length; i++) { - key = keys[i]; - if (predicate(obj[key], key, obj)) return key; + function matchesProperty(path, srcValue) { + return baseMatchesProperty(path, baseClone(srcValue, true)); } - }; - _.pick = function(object, oiteratee, context) { - var result = {}, obj = object, iteratee, keys; - if (obj == null) return result; - if (_.isFunction(oiteratee)) { - keys = _.allKeys(obj); - iteratee = optimizeCb(oiteratee, context); - } else { - keys = flatten(arguments, false, false, 1); - iteratee = function(value, key, obj) { - return key in obj; + var method = restParam(function(path, args) { + return function(object) { + return invokePath(object, path, args); + }; + }); + var methodOf = restParam(function(object, args) { + return function(path) { + return invokePath(object, path, args); }; - obj = Object(obj); + }); + function mixin(object, source, options) { + if (options == null) { + var isObj = isObject(source), props = isObj ? keys(source) : undefined, methodNames = props && props.length ? baseFunctions(source, props) : undefined; + if (!(methodNames ? methodNames.length : isObj)) { + methodNames = false; + options = source; + source = object; + object = this; + } + } + if (!methodNames) { + methodNames = baseFunctions(source, keys(source)); + } + var chain = true, index = -1, isFunc = isFunction(object), length = methodNames.length; + if (options === false) { + chain = false; + } else if (isObject(options) && "chain" in options) { + chain = options.chain; + } + while (++index < length) { + var methodName = methodNames[index], func = source[methodName]; + object[methodName] = func; + if (isFunc) { + object.prototype[methodName] = function(func) { + return function() { + var chainAll = this.__chain__; + if (chain || chainAll) { + var result = object(this.__wrapped__), actions = result.__actions__ = arrayCopy(this.__actions__); + actions.push({ + func: func, + args: arguments, + thisArg: object + }); + result.__chain__ = chainAll; + return result; + } + return func.apply(object, arrayPush([ this.value() ], arguments)); + }; + }(func); + } + } + return object; } - for (var i = 0, length = keys.length; i < length; i++) { - var key = keys[i]; - var value = obj[key]; - if (iteratee(value, key, obj)) result[key] = value; + function noConflict() { + root._ = oldDash; + return this; } - return result; - }; - _.omit = function(obj, iteratee, context) { - if (_.isFunction(iteratee)) { - iteratee = _.negate(iteratee); - } else { - var keys = _.map(flatten(arguments, false, false, 1), String); - iteratee = function(value, key) { - return !_.contains(keys, key); - }; + function noop() {} + function property(path) { + return isKey(path) ? baseProperty(path) : basePropertyDeep(path); } - return _.pick(obj, iteratee, context); - }; - _.defaults = createAssigner(_.allKeys, true); - _.create = function(prototype, props) { - var result = baseCreate(prototype); - if (props) _.extendOwn(result, props); - return result; - }; - _.clone = function(obj) { - if (!_.isObject(obj)) return obj; - return _.isArray(obj) ? obj.slice() : _.extend({}, obj); - }; - _.tap = function(obj, interceptor) { - interceptor(obj); - return obj; - }; - _.isMatch = function(object, attrs) { - var keys = _.keys(attrs), length = keys.length; - if (object == null) return !length; - var obj = Object(object); - for (var i = 0; i < length; i++) { - var key = keys[i]; - if (attrs[key] !== obj[key] || !(key in obj)) return false; + function propertyOf(object) { + return function(path) { + return baseGet(object, toPath(path), path + ""); + }; } - return true; - }; - var eq = function(a, b, aStack, bStack) { - if (a === b) return a !== 0 || 1 / a === 1 / b; - if (a == null || b == null) return a === b; - if (a instanceof _) a = a._wrapped; - if (b instanceof _) b = b._wrapped; - var className = toString.call(a); - if (className !== toString.call(b)) return false; - switch (className) { - case "[object RegExp]": - case "[object String]": - return "" + a === "" + b; - - case "[object Number]": - if (+a !== +a) return +b !== +b; - return +a === 0 ? 1 / +a === 1 / b : +a === +b; - - case "[object Date]": - case "[object Boolean]": - return +a === +b; - } - var areArrays = className === "[object Array]"; - if (!areArrays) { - if (typeof a != "object" || typeof b != "object") return false; - var aCtor = a.constructor, bCtor = b.constructor; - if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor && _.isFunction(bCtor) && bCtor instanceof bCtor) && ("constructor" in a && "constructor" in b)) { - return false; + function range(start, end, step) { + if (step && isIterateeCall(start, end, step)) { + end = step = undefined; } + start = +start || 0; + step = step == null ? 1 : +step || 0; + if (end == null) { + end = start; + start = 0; + } else { + end = +end || 0; + } + var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result = Array(length); + while (++index < length) { + result[index] = start; + start += step; + } + return result; } - aStack = aStack || []; - bStack = bStack || []; - var length = aStack.length; - while (length--) { - if (aStack[length] === a) return bStack[length] === b; - } - aStack.push(a); - bStack.push(b); - if (areArrays) { - length = a.length; - if (length !== b.length) return false; - while (length--) { - if (!eq(a[length], b[length], aStack, bStack)) return false; + function times(n, iteratee, thisArg) { + n = nativeFloor(n); + if (n < 1 || !nativeIsFinite(n)) { + return []; } - } else { - var keys = _.keys(a), key; - length = keys.length; - if (_.keys(b).length !== length) return false; - while (length--) { - key = keys[length]; - if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false; + var index = -1, result = Array(nativeMin(n, MAX_ARRAY_LENGTH)); + iteratee = bindCallback(iteratee, thisArg, 1); + while (++index < n) { + if (index < MAX_ARRAY_LENGTH) { + result[index] = iteratee(index); + } else { + iteratee(index); + } } + return result; } - aStack.pop(); - bStack.pop(); - return true; - }; - _.isEqual = function(a, b) { - return eq(a, b); - }; - _.isEmpty = function(obj) { - if (obj == null) return true; - if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0; - return _.keys(obj).length === 0; - }; - _.isElement = function(obj) { - return !!(obj && obj.nodeType === 1); - }; - _.isArray = nativeIsArray || function(obj) { - return toString.call(obj) === "[object Array]"; - }; - _.isObject = function(obj) { - var type = typeof obj; - return type === "function" || type === "object" && !!obj; - }; - _.each([ "Arguments", "Function", "String", "Number", "Date", "RegExp", "Error" ], function(name) { - _["is" + name] = function(obj) { - return toString.call(obj) === "[object " + name + "]"; - }; - }); - if (!_.isArguments(arguments)) { - _.isArguments = function(obj) { - return _.has(obj, "callee"); - }; - } - if (typeof /./ != "function" && typeof Int8Array != "object") { - _.isFunction = function(obj) { - return typeof obj == "function" || false; + function uniqueId(prefix) { + var id = ++idCounter; + return baseToString(prefix) + id; + } + function add(augend, addend) { + return (+augend || 0) + (+addend || 0); + } + var ceil = createRound("ceil"); + var floor = createRound("floor"); + var max = createExtremum(gt, NEGATIVE_INFINITY); + var min = createExtremum(lt, POSITIVE_INFINITY); + var round = createRound("round"); + function sum(collection, iteratee, thisArg) { + if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { + iteratee = undefined; + } + iteratee = getCallback(iteratee, thisArg, 3); + return iteratee.length == 1 ? arraySum(isArray(collection) ? collection : toIterable(collection), iteratee) : baseSum(collection, iteratee); + } + lodash.prototype = baseLodash.prototype; + LodashWrapper.prototype = baseCreate(baseLodash.prototype); + LodashWrapper.prototype.constructor = LodashWrapper; + LazyWrapper.prototype = baseCreate(baseLodash.prototype); + LazyWrapper.prototype.constructor = LazyWrapper; + MapCache.prototype["delete"] = mapDelete; + MapCache.prototype.get = mapGet; + MapCache.prototype.has = mapHas; + MapCache.prototype.set = mapSet; + SetCache.prototype.push = cachePush; + memoize.Cache = MapCache; + lodash.after = after; + lodash.ary = ary; + lodash.assign = assign; + lodash.at = at; + lodash.before = before; + lodash.bind = bind; + lodash.bindAll = bindAll; + lodash.bindKey = bindKey; + lodash.callback = callback; + lodash.chain = chain; + lodash.chunk = chunk; + lodash.compact = compact; + lodash.constant = constant; + lodash.countBy = countBy; + lodash.create = create; + lodash.curry = curry; + lodash.curryRight = curryRight; + lodash.debounce = debounce; + lodash.defaults = defaults; + lodash.defaultsDeep = defaultsDeep; + lodash.defer = defer; + lodash.delay = delay; + lodash.difference = difference; + lodash.drop = drop; + lodash.dropRight = dropRight; + lodash.dropRightWhile = dropRightWhile; + lodash.dropWhile = dropWhile; + lodash.fill = fill; + lodash.filter = filter; + lodash.flatten = flatten; + lodash.flattenDeep = flattenDeep; + lodash.flow = flow; + lodash.flowRight = flowRight; + lodash.forEach = forEach; + lodash.forEachRight = forEachRight; + lodash.forIn = forIn; + lodash.forInRight = forInRight; + lodash.forOwn = forOwn; + lodash.forOwnRight = forOwnRight; + lodash.functions = functions; + lodash.groupBy = groupBy; + lodash.indexBy = indexBy; + lodash.initial = initial; + lodash.intersection = intersection; + lodash.invert = invert; + lodash.invoke = invoke; + lodash.keys = keys; + lodash.keysIn = keysIn; + lodash.map = map; + lodash.mapKeys = mapKeys; + lodash.mapValues = mapValues; + lodash.matches = matches; + lodash.matchesProperty = matchesProperty; + lodash.memoize = memoize; + lodash.merge = merge; + lodash.method = method; + lodash.methodOf = methodOf; + lodash.mixin = mixin; + lodash.modArgs = modArgs; + lodash.negate = negate; + lodash.omit = omit; + lodash.once = once; + lodash.pairs = pairs; + lodash.partial = partial; + lodash.partialRight = partialRight; + lodash.partition = partition; + lodash.pick = pick; + lodash.pluck = pluck; + lodash.property = property; + lodash.propertyOf = propertyOf; + lodash.pull = pull; + lodash.pullAt = pullAt; + lodash.range = range; + lodash.rearg = rearg; + lodash.reject = reject; + lodash.remove = remove; + lodash.rest = rest; + lodash.restParam = restParam; + lodash.set = set; + lodash.shuffle = shuffle; + lodash.slice = slice; + lodash.sortBy = sortBy; + lodash.sortByAll = sortByAll; + lodash.sortByOrder = sortByOrder; + lodash.spread = spread; + lodash.take = take; + lodash.takeRight = takeRight; + lodash.takeRightWhile = takeRightWhile; + lodash.takeWhile = takeWhile; + lodash.tap = tap; + lodash.throttle = throttle; + lodash.thru = thru; + lodash.times = times; + lodash.toArray = toArray; + lodash.toPlainObject = toPlainObject; + lodash.transform = transform; + lodash.union = union; + lodash.uniq = uniq; + lodash.unzip = unzip; + lodash.unzipWith = unzipWith; + lodash.values = values; + lodash.valuesIn = valuesIn; + lodash.where = where; + lodash.without = without; + lodash.wrap = wrap; + lodash.xor = xor; + lodash.zip = zip; + lodash.zipObject = zipObject; + lodash.zipWith = zipWith; + lodash.backflow = flowRight; + lodash.collect = map; + lodash.compose = flowRight; + lodash.each = forEach; + lodash.eachRight = forEachRight; + lodash.extend = assign; + lodash.iteratee = callback; + lodash.methods = functions; + lodash.object = zipObject; + lodash.select = filter; + lodash.tail = rest; + lodash.unique = uniq; + mixin(lodash, lodash); + lodash.add = add; + lodash.attempt = attempt; + lodash.camelCase = camelCase; + lodash.capitalize = capitalize; + lodash.ceil = ceil; + lodash.clone = clone; + lodash.cloneDeep = cloneDeep; + lodash.deburr = deburr; + lodash.endsWith = endsWith; + lodash.escape = escape; + lodash.escapeRegExp = escapeRegExp; + lodash.every = every; + lodash.find = find; + lodash.findIndex = findIndex; + lodash.findKey = findKey; + lodash.findLast = findLast; + lodash.findLastIndex = findLastIndex; + lodash.findLastKey = findLastKey; + lodash.findWhere = findWhere; + lodash.first = first; + lodash.floor = floor; + lodash.get = get; + lodash.gt = gt; + lodash.gte = gte; + lodash.has = has; + lodash.identity = identity; + lodash.includes = includes; + lodash.indexOf = indexOf; + lodash.inRange = inRange; + lodash.isArguments = isArguments; + lodash.isArray = isArray; + lodash.isBoolean = isBoolean; + lodash.isDate = isDate; + lodash.isElement = isElement; + lodash.isEmpty = isEmpty; + lodash.isEqual = isEqual; + lodash.isError = isError; + lodash.isFinite = isFinite; + lodash.isFunction = isFunction; + lodash.isMatch = isMatch; + lodash.isNaN = isNaN; + lodash.isNative = isNative; + lodash.isNull = isNull; + lodash.isNumber = isNumber; + lodash.isObject = isObject; + lodash.isPlainObject = isPlainObject; + lodash.isRegExp = isRegExp; + lodash.isString = isString; + lodash.isTypedArray = isTypedArray; + lodash.isUndefined = isUndefined; + lodash.kebabCase = kebabCase; + lodash.last = last; + lodash.lastIndexOf = lastIndexOf; + lodash.lt = lt; + lodash.lte = lte; + lodash.max = max; + lodash.min = min; + lodash.noConflict = noConflict; + lodash.noop = noop; + lodash.now = now; + lodash.pad = pad; + lodash.padLeft = padLeft; + lodash.padRight = padRight; + lodash.parseInt = parseInt; + lodash.random = random; + lodash.reduce = reduce; + lodash.reduceRight = reduceRight; + lodash.repeat = repeat; + lodash.result = result; + lodash.round = round; + lodash.runInContext = runInContext; + lodash.size = size; + lodash.snakeCase = snakeCase; + lodash.some = some; + lodash.sortedIndex = sortedIndex; + lodash.sortedLastIndex = sortedLastIndex; + lodash.startCase = startCase; + lodash.startsWith = startsWith; + lodash.sum = sum; + lodash.template = template; + lodash.trim = trim; + lodash.trimLeft = trimLeft; + lodash.trimRight = trimRight; + lodash.trunc = trunc; + lodash.unescape = unescape; + lodash.uniqueId = uniqueId; + lodash.words = words; + lodash.all = every; + lodash.any = some; + lodash.contains = includes; + lodash.eq = isEqual; + lodash.detect = find; + lodash.foldl = reduce; + lodash.foldr = reduceRight; + lodash.head = first; + lodash.include = includes; + lodash.inject = reduce; + mixin(lodash, function() { + var source = {}; + baseForOwn(lodash, function(func, methodName) { + if (!lodash.prototype[methodName]) { + source[methodName] = func; + } + }); + return source; + }(), false); + lodash.sample = sample; + lodash.prototype.sample = function(n) { + if (!this.__chain__ && n == null) { + return sample(this.value()); + } + return this.thru(function(value) { + return sample(value, n); + }); + }; + lodash.VERSION = VERSION; + arrayEach([ "bind", "bindKey", "curry", "curryRight", "partial", "partialRight" ], function(methodName) { + lodash[methodName].placeholder = lodash; + }); + arrayEach([ "drop", "take" ], function(methodName, index) { + LazyWrapper.prototype[methodName] = function(n) { + var filtered = this.__filtered__; + if (filtered && !index) { + return new LazyWrapper(this); + } + n = n == null ? 1 : nativeMax(nativeFloor(n) || 0, 0); + var result = this.clone(); + if (filtered) { + result.__takeCount__ = nativeMin(result.__takeCount__, n); + } else { + result.__views__.push({ + size: n, + type: methodName + (result.__dir__ < 0 ? "Right" : "") + }); + } + return result; + }; + LazyWrapper.prototype[methodName + "Right"] = function(n) { + return this.reverse()[methodName](n).reverse(); + }; + }); + arrayEach([ "filter", "map", "takeWhile" ], function(methodName, index) { + var type = index + 1, isFilter = type != LAZY_MAP_FLAG; + LazyWrapper.prototype[methodName] = function(iteratee, thisArg) { + var result = this.clone(); + result.__iteratees__.push({ + iteratee: getCallback(iteratee, thisArg, 1), + type: type + }); + result.__filtered__ = result.__filtered__ || isFilter; + return result; + }; + }); + arrayEach([ "first", "last" ], function(methodName, index) { + var takeName = "take" + (index ? "Right" : ""); + LazyWrapper.prototype[methodName] = function() { + return this[takeName](1).value()[0]; + }; + }); + arrayEach([ "initial", "rest" ], function(methodName, index) { + var dropName = "drop" + (index ? "" : "Right"); + LazyWrapper.prototype[methodName] = function() { + return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); + }; + }); + arrayEach([ "pluck", "where" ], function(methodName, index) { + var operationName = index ? "filter" : "map", createCallback = index ? baseMatches : property; + LazyWrapper.prototype[methodName] = function(value) { + return this[operationName](createCallback(value)); + }; + }); + LazyWrapper.prototype.compact = function() { + return this.filter(identity); }; - } - _.isFinite = function(obj) { - return isFinite(obj) && !isNaN(parseFloat(obj)); - }; - _.isNaN = function(obj) { - return _.isNumber(obj) && obj !== +obj; - }; - _.isBoolean = function(obj) { - return obj === true || obj === false || toString.call(obj) === "[object Boolean]"; - }; - _.isNull = function(obj) { - return obj === null; - }; - _.isUndefined = function(obj) { - return obj === void 0; - }; - _.has = function(obj, key) { - return obj != null && hasOwnProperty.call(obj, key); - }; - _.noConflict = function() { - root._ = previousUnderscore; - return this; - }; - _.identity = function(value) { - return value; - }; - _.constant = function(value) { - return function() { - return value; + LazyWrapper.prototype.reject = function(predicate, thisArg) { + predicate = getCallback(predicate, thisArg, 1); + return this.filter(function(value) { + return !predicate(value); + }); }; - }; - _.noop = function() {}; - _.property = property; - _.propertyOf = function(obj) { - return obj == null ? function() {} : function(key) { - return obj[key]; + LazyWrapper.prototype.slice = function(start, end) { + start = start == null ? 0 : +start || 0; + var result = this; + if (result.__filtered__ && (start > 0 || end < 0)) { + return new LazyWrapper(result); + } + if (start < 0) { + result = result.takeRight(-start); + } else if (start) { + result = result.drop(start); + } + if (end !== undefined) { + end = +end || 0; + result = end < 0 ? result.dropRight(-end) : result.take(end - start); + } + return result; }; - }; - _.matcher = _.matches = function(attrs) { - attrs = _.extendOwn({}, attrs); - return function(obj) { - return _.isMatch(obj, attrs); + LazyWrapper.prototype.takeRightWhile = function(predicate, thisArg) { + return this.reverse().takeWhile(predicate, thisArg).reverse(); }; - }; - _.times = function(n, iteratee, context) { - var accum = Array(Math.max(0, n)); - iteratee = optimizeCb(iteratee, context, 1); - for (var i = 0; i < n; i++) accum[i] = iteratee(i); - return accum; - }; - _.random = function(min, max) { - if (max == null) { - max = min; - min = 0; - } - return min + Math.floor(Math.random() * (max - min + 1)); - }; - _.now = Date.now || function() { - return new Date().getTime(); - }; - var escapeMap = { - "&": "&", - "<": "<", - ">": ">", - '"': """, - "'": "'", - "`": "`" - }; - var unescapeMap = _.invert(escapeMap); - var createEscaper = function(map) { - var escaper = function(match) { - return map[match]; - }; - var source = "(?:" + _.keys(map).join("|") + ")"; - var testRegexp = RegExp(source); - var replaceRegexp = RegExp(source, "g"); - return function(string) { - string = string == null ? "" : "" + string; - return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; - }; - }; - _.escape = createEscaper(escapeMap); - _.unescape = createEscaper(unescapeMap); - _.result = function(object, property, fallback) { - var value = object == null ? void 0 : object[property]; - if (value === void 0) { - value = fallback; - } - return _.isFunction(value) ? value.call(object) : value; - }; - var idCounter = 0; - _.uniqueId = function(prefix) { - var id = ++idCounter + ""; - return prefix ? prefix + id : id; - }; - _.templateSettings = { - evaluate: /<%([\s\S]+?)%>/g, - interpolate: /<%=([\s\S]+?)%>/g, - escape: /<%-([\s\S]+?)%>/g - }; - var noMatch = /(.)^/; - var escapes = { - "'": "'", - "\\": "\\", - "\r": "r", - "\n": "n", - "\u2028": "u2028", - "\u2029": "u2029" - }; - var escaper = /\\|'|\r|\n|\u2028|\u2029/g; - var escapeChar = function(match) { - return "\\" + escapes[match]; - }; - _.template = function(text, settings, oldSettings) { - if (!settings && oldSettings) settings = oldSettings; - settings = _.defaults({}, settings, _.templateSettings); - var matcher = RegExp([ (settings.escape || noMatch).source, (settings.interpolate || noMatch).source, (settings.evaluate || noMatch).source ].join("|") + "|$", "g"); - var index = 0; - var source = "__p+='"; - text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { - source += text.slice(index, offset).replace(escaper, escapeChar); - index = offset + match.length; - if (escape) { - source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; - } else if (interpolate) { - source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; - } else if (evaluate) { - source += "';\n" + evaluate + "\n__p+='"; - } - return match; - }); - source += "';\n"; - if (!settings.variable) source = "with(obj||{}){\n" + source + "}\n"; - source = "var __t,__p='',__j=Array.prototype.join," + "print=function(){__p+=__j.call(arguments,'');};\n" + source + "return __p;\n"; - try { - var render = new Function(settings.variable || "obj", "_", source); - } catch (e) { - e.source = source; - throw e; - } - var template = function(data) { - return render.call(this, data, _); + LazyWrapper.prototype.toArray = function() { + return this.take(POSITIVE_INFINITY); }; - var argument = settings.variable || "obj"; - template.source = "function(" + argument + "){\n" + source + "}"; - return template; - }; - _.chain = function(obj) { - var instance = _(obj); - instance._chain = true; - return instance; - }; - var result = function(instance, obj) { - return instance._chain ? _(obj).chain() : obj; - }; - _.mixin = function(obj) { - _.each(_.functions(obj), function(name) { - var func = _[name] = obj[name]; - _.prototype[name] = function() { - var args = [ this._wrapped ]; - push.apply(args, arguments); - return result(this, func.apply(_, args)); + baseForOwn(LazyWrapper.prototype, function(func, methodName) { + var checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName), retUnwrapped = /^(?:first|last)$/.test(methodName), lodashFunc = lodash[retUnwrapped ? "take" + (methodName == "last" ? "Right" : "") : methodName]; + if (!lodashFunc) { + return; + } + lodash.prototype[methodName] = function() { + var args = retUnwrapped ? [ 1 ] : arguments, chainAll = this.__chain__, value = this.__wrapped__, isHybrid = !!this.__actions__.length, isLazy = value instanceof LazyWrapper, iteratee = args[0], useLazy = isLazy || isArray(value); + if (useLazy && checkIteratee && typeof iteratee == "function" && iteratee.length != 1) { + isLazy = useLazy = false; + } + var interceptor = function(value) { + return retUnwrapped && chainAll ? lodashFunc(value, 1)[0] : lodashFunc.apply(undefined, arrayPush([ value ], args)); + }; + var action = { + func: thru, + args: [ interceptor ], + thisArg: undefined + }, onlyLazy = isLazy && !isHybrid; + if (retUnwrapped && !chainAll) { + if (onlyLazy) { + value = value.clone(); + value.__actions__.push(action); + return func.call(value); + } + return lodashFunc.call(undefined, this.value())[0]; + } + if (!retUnwrapped && useLazy) { + value = onlyLazy ? value : new LazyWrapper(this); + var result = func.apply(value, args); + result.__actions__.push(action); + return new LodashWrapper(result, chainAll); + } + return this.thru(interceptor); }; }); - }; - _.mixin(_); - _.each([ "pop", "push", "reverse", "shift", "sort", "splice", "unshift" ], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - var obj = this._wrapped; - method.apply(obj, arguments); - if ((name === "shift" || name === "splice") && obj.length === 0) delete obj[0]; - return result(this, obj); - }; - }); - _.each([ "concat", "join", "slice" ], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - return result(this, method.apply(this._wrapped, arguments)); - }; - }); - _.prototype.value = function() { - return this._wrapped; - }; - _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; - _.prototype.toString = function() { - return "" + this._wrapped; - }; - if (typeof define === "function" && define.amd) { - define("underscore", [], function() { + arrayEach([ "join", "pop", "push", "replace", "shift", "sort", "splice", "split", "unshift" ], function(methodName) { + var func = (/^(?:replace|split)$/.test(methodName) ? stringProto : arrayProto)[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? "tap" : "thru", retUnwrapped = /^(?:join|pop|replace|shift)$/.test(methodName); + lodash.prototype[methodName] = function() { + var args = arguments; + if (retUnwrapped && !this.__chain__) { + return func.apply(this.value(), args); + } + return this[chainName](function(value) { + return func.apply(value, args); + }); + }; + }); + baseForOwn(LazyWrapper.prototype, function(func, methodName) { + var lodashFunc = lodash[methodName]; + if (lodashFunc) { + var key = lodashFunc.name + "", names = realNames[key] || (realNames[key] = []); + names.push({ + name: methodName, + func: lodashFunc + }); + } + }); + realNames[createHybridWrapper(undefined, BIND_KEY_FLAG).name] = [ { + name: "wrapper", + func: undefined + } ]; + LazyWrapper.prototype.clone = lazyClone; + LazyWrapper.prototype.reverse = lazyReverse; + LazyWrapper.prototype.value = lazyValue; + lodash.prototype.chain = wrapperChain; + lodash.prototype.commit = wrapperCommit; + lodash.prototype.concat = wrapperConcat; + lodash.prototype.plant = wrapperPlant; + lodash.prototype.reverse = wrapperReverse; + lodash.prototype.toString = wrapperToString; + lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; + lodash.prototype.collect = lodash.prototype.map; + lodash.prototype.head = lodash.prototype.first; + lodash.prototype.select = lodash.prototype.filter; + lodash.prototype.tail = lodash.prototype.rest; + return lodash; + } + var _ = runInContext(); + if (typeof define == "function" && typeof define.amd == "object" && define.amd) { + root._ = _; + define(function() { return _; }); + } else if (freeExports && freeModule) { + if (moduleExports) { + (freeModule.exports = _)._ = _; + } else { + freeExports._ = _; + } + } else { + root._ = _; } }).call(this); @@ -6445,7 +9332,7 @@ } return match; }); - message += "\nhttp://errors.angularjs.org/1.4.6/" + (module ? module + "/" : "") + code; + message += "\nhttp://errors.angularjs.org/1.4.7/" + (module ? module + "/" : "") + code; for (i = SKIP_INDEXES, paramPrefix = "?"; i < templateArgs.length; i++, paramPrefix = "&") { message += paramPrefix + "p" + (i - SKIP_INDEXES) + "=" + encodeURIComponent(toDebugString(templateArgs[i])); } @@ -7264,11 +10151,11 @@ return obj; } var version = { - full: "1.4.6", + full: "1.4.7", major: 1, minor: 4, - dot: 6, - codeName: "multiplicative-elevation" + dot: 7, + codeName: "dark-luminescence" }; function publishExternalAPI(angular) { extend(angular, { @@ -7377,6 +10264,7 @@ $httpParamSerializer: $HttpParamSerializerProvider, $httpParamSerializerJQLike: $HttpParamSerializerJQLikeProvider, $httpBackend: $HttpBackendProvider, + $xhrFactory: $xhrFactoryProvider, $location: $LocationProvider, $log: $LogProvider, $parse: $ParseProvider, @@ -7422,10 +10310,10 @@ return offset ? letter.toUpperCase() : letter; }).replace(MOZ_HACK_REGEXP, "Moz$1"); } - var SINGLE_TAG_REGEXP = /^<(\w+)\s*\/?>(?:<\/\1>|)$/; + var SINGLE_TAG_REGEXP = /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/; var HTML_REGEXP = /<|&#?\w+;/; - var TAG_NAME_REGEXP = /<([\w:]+)/; - var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi; + var TAG_NAME_REGEXP = /<([\w:-]+)/; + var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi; var wrapMap = { option: [ 1, '" ], thead: [ 1, "", "
" ], @@ -8668,6 +11556,9 @@ } }; return function(element, options) { + if (options.cleanupStyles) { + options.from = options.to = null; + } if (options.from) { element.css(options.from); options.from = null; @@ -9933,7 +12824,7 @@ compile: function() { return { pre: function attrInterpolatePreLinkFn(scope, element, attr) { - var $$observers = attr.$$observers || (attr.$$observers = {}); + var $$observers = attr.$$observers || (attr.$$observers = createMap()); if (EVENT_HANDLER_ATTR_REGEXP.test(name)) { throw $compileMinErr("nodomevents", "Interpolations for HTML DOM event attributes are disallowed. Please use the " + "ng- versions (such as ng-click instead of onclick) instead."); } @@ -10596,12 +13487,16 @@ } } ]; } - function createXhr() { - return new window.XMLHttpRequest(); + function $xhrFactoryProvider() { + this.$get = function() { + return function createXhr() { + return new window.XMLHttpRequest(); + }; + }; } function $HttpBackendProvider() { - this.$get = [ "$browser", "$window", "$document", function($browser, $window, $document) { - return createHttpBackend($browser, createXhr, $browser.defer, $window.angular.callbacks, $document[0]); + this.$get = [ "$browser", "$window", "$document", "$xhrFactory", function($browser, $window, $document, $xhrFactory) { + return createHttpBackend($browser, $xhrFactory, $browser.defer, $window.angular.callbacks, $document[0]); } ]; } function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDocument) { @@ -10619,7 +13514,7 @@ callbacks[callbackId] = noop; }); } else { - var xhr = createXhr(); + var xhr = createXhr(method, url); xhr.open(method, url, true); forEach(headers, function(value, key) { if (isDefined(value)) { @@ -11327,12 +14222,18 @@ } var $parseMinErr = minErr("$parse"); function ensureSafeMemberName(name, fullExpression) { - name = isObject(name) && name.toString ? name.toString() : name; if (name === "__defineGetter__" || name === "__defineSetter__" || name === "__lookupGetter__" || name === "__lookupSetter__" || name === "__proto__") { throw $parseMinErr("isecfld", "Attempting to access a disallowed field in Angular expressions! " + "Expression: {0}", fullExpression); } return name; } + function getStringValue(name, fullExpression) { + name = name + ""; + if (!isString(name)) { + throw $parseMinErr("iseccst", "Cannot convert object to primitive value! " + "Expression: {0}", fullExpression); + } + return name; + } function ensureSafeObject(obj, fullExpression) { if (obj) { if (obj.constructor === obj) { @@ -11359,6 +14260,13 @@ } } } + function ensureSafeAssignContext(obj, fullExpression) { + if (obj) { + if (obj === 0..constructor || obj === false.constructor || obj === "".constructor || obj === {}.constructor || obj === [].constructor || obj === Function.constructor) { + throw $parseMinErr("isecaf", "Assigning to a constructor is disallowed! Expression: {0}", fullExpression); + } + } + } var OPERATORS = createMap(); forEach("+ - * / % === !== == != < > <= >= && || ! = |".split(" "), function(operator) { OPERATORS[operator] = true; @@ -12107,7 +15015,7 @@ this.stage = "main"; this.recurse(ast); var fnString = '"' + this.USE + " " + this.STRICT + '";\n' + this.filterPrefix() + "var fn=" + this.generateFunction("fn", "s,l,a,i") + extra + this.watchFns() + "return fn;"; - var fn = new Function("$filter", "ensureSafeMemberName", "ensureSafeObject", "ensureSafeFunction", "ifDefined", "plus", "text", fnString)(this.$filter, ensureSafeMemberName, ensureSafeObject, ensureSafeFunction, ifDefined, plusFn, expression); + var fn = new Function("$filter", "ensureSafeMemberName", "ensureSafeObject", "ensureSafeFunction", "getStringValue", "ensureSafeAssignContext", "ifDefined", "plus", "text", fnString)(this.$filter, ensureSafeMemberName, ensureSafeObject, ensureSafeFunction, getStringValue, ensureSafeAssignContext, ifDefined, plusFn, expression); this.state = this.stage = undefined; fn.literal = isLiteral(ast); fn.constant = isConstant(ast); @@ -12244,6 +15152,7 @@ if (ast.computed) { right = self.nextId(); self.recurse(ast.property, right); + self.getStringValue(right); self.addEnsureSafeMemberName(right); if (create && create !== 1) { self.if_(self.not(self.computedMember(left, right)), self.lazyAssign(self.computedMember(left, right), "{}")); @@ -12329,6 +15238,7 @@ self.if_(self.notNull(left.context), function() { self.recurse(ast.right, right); self.addEnsureSafeObject(self.member(left.context, left.name, left.computed)); + self.addEnsureSafeAssignContext(left.context); expression = self.member(left.context, left.name, left.computed) + ast.operator + right; self.assign(intoId, expression); recursionFn(intoId || expression); @@ -12439,6 +15349,9 @@ addEnsureSafeFunction: function(item) { this.current().body.push(this.ensureSafeFunction(item), ";"); }, + addEnsureSafeAssignContext: function(item) { + this.current().body.push(this.ensureSafeAssignContext(item), ";"); + }, ensureSafeObject: function(item) { return "ensureSafeObject(" + item + ",text)"; }, @@ -12448,6 +15361,12 @@ ensureSafeFunction: function(item) { return "ensureSafeFunction(" + item + ",text)"; }, + getStringValue: function(item) { + this.assign(item, "getStringValue(" + item + ",text)"); + }, + ensureSafeAssignContext: function(item) { + return "ensureSafeAssignContext(" + item + ",text)"; + }, lazyRecurse: function(ast, intoId, nameId, recursionFn, create, skipWatchIdCheck) { var self = this; return function() { @@ -12615,6 +15534,7 @@ var lhs = left(scope, locals, assign, inputs); var rhs = right(scope, locals, assign, inputs); ensureSafeObject(lhs.value, self.expression); + ensureSafeAssignContext(lhs.context); lhs.context[lhs.name] = rhs; return context ? { value: rhs @@ -12872,6 +15792,7 @@ var value; if (lhs != null) { rhs = right(scope, locals, assign, inputs); + rhs = getStringValue(rhs); ensureSafeMemberName(rhs, expression); if (create && create !== 1 && lhs && !lhs[rhs]) { lhs[rhs] = {}; @@ -14554,6 +17475,7 @@ if (fractionSize > 0 && number < 1) { formatedText = number.toFixed(fractionSize); number = parseFloat(formatedText); + formatedText = formatedText.replace(DECIMAL_SEP, decimalSep); } } if (number === 0) { @@ -16571,11 +19493,11 @@ function updateOptionElement(option, element) { option.element = element; element.disabled = option.disabled; - if (option.value !== element.value) element.value = option.selectValue; if (option.label !== element.label) { element.label = option.label; element.textContent = option.label; } + if (option.value !== element.value) element.value = option.selectValue; } function addOrReuseElement(parent, current, type, templateElement) { var element; @@ -16603,7 +19525,7 @@ var emptyOption_ = emptyOption && emptyOption[0]; var unknownOption_ = unknownOption && unknownOption[0]; if (emptyOption_ || unknownOption_) { - while (current && (current === emptyOption_ || current === unknownOption_)) { + while (current && (current === emptyOption_ || current === unknownOption_ || emptyOption_ && emptyOption_.nodeType === NODE_TYPE_COMMENT)) { current = current.nextSibling; } } @@ -29692,11 +32614,6 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex if (!b) return a; return a + " " + b; } - function $$BodyProvider() { - this.$get = [ "$document", function($document) { - return jqLite($document[0].body); - } ]; - } var $$rAFSchedulerFactory = [ "$$rAF", function($$rAF) { var queue, cancelFn; function scheduler(tasks) { @@ -29834,6 +32751,11 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex } }; } + function registerRestorableStyles(backup, node, properties) { + forEach(properties, function(prop) { + backup[prop] = isDefined(backup[prop]) ? backup[prop] : node.style.getPropertyValue(prop); + }); + } var $AnimateCssProvider = [ "$animateProvider", function($animateProvider) { var gcsLookup = createLocalCacheLookup(); var gcsStaggerLookup = createLocalCacheLookup(); @@ -29896,6 +32818,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex return timings; } return function init(element, options) { + var restoreStyles = {}; var node = getDomNode(element); if (!node || !node.parentNode || !$animate.enabled()) { return closeAndReturnNoopAnimator(); @@ -30031,7 +32954,12 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex flags.blockTransition = timings.transitionDuration > 0; flags.blockKeyframeAnimation = timings.animationDuration > 0 && stagger.animationDelay > 0 && stagger.animationDuration === 0; } - applyAnimationFromStyles(element, options); + if (options.from) { + if (options.cleanupStyles) { + registerRestorableStyles(restoreStyles, node, Object.keys(options.from)); + } + applyAnimationFromStyles(element, options); + } if (flags.blockTransition || flags.blockKeyframeAnimation) { applyBlocking(maxDuration); } else if (!options.skipBlocking) { @@ -30074,6 +33002,11 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex }); applyAnimationClasses(element, options); applyAnimationStyles(element, options); + if (Object.keys(restoreStyles).length) { + forEach(restoreStyles, function(value, prop) { + value ? node.style.setProperty(prop, value) : node.style.removeProperty(prop); + }); + } if (options.onDone) { options.onDone(); } @@ -30212,7 +33145,12 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex element.data(ANIMATE_TIMER_KEY, animationsData); } element.on(events.join(" "), onAnimationProgress); - applyAnimationToStyles(element, options); + if (options.to) { + if (options.cleanupStyles) { + registerRestorableStyles(restoreStyles, node, Object.keys(options.to)); + } + applyAnimationToStyles(element, options); + } } function onAnimationExpired() { var animationsData = element.data(ANIMATE_TIMER_KEY); @@ -30243,11 +33181,14 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex var NG_ANIMATE_ANCHOR_CLASS_NAME = "ng-anchor"; var NG_OUT_ANCHOR_CLASS_NAME = "ng-anchor-out"; var NG_IN_ANCHOR_CLASS_NAME = "ng-anchor-in"; - this.$get = [ "$animateCss", "$rootScope", "$$AnimateRunner", "$rootElement", "$$body", "$sniffer", "$$jqLite", function($animateCss, $rootScope, $$AnimateRunner, $rootElement, $$body, $sniffer, $$jqLite) { + function isDocumentFragment(node) { + return node.parentNode && node.parentNode.nodeType === 11; + } + this.$get = [ "$animateCss", "$rootScope", "$$AnimateRunner", "$rootElement", "$sniffer", "$$jqLite", "$document", function($animateCss, $rootScope, $$AnimateRunner, $rootElement, $sniffer, $$jqLite, $document) { if (!$sniffer.animations && !$sniffer.transitions) return noop; - var bodyNode = getDomNode($$body); + var bodyNode = $document[0].body; var rootNode = getDomNode($rootElement); - var rootBodyElement = jqLite(bodyNode.parentNode === rootNode ? bodyNode : rootNode); + var rootBodyElement = jqLite(isDocumentFragment(rootNode) || bodyNode.contains(rootNode) ? rootNode : bodyNode); var applyAnimationClasses = applyAnimationClassesFactory($$jqLite); return function initDriverFn(animationDetails) { return animationDetails.from && animationDetails.to ? prepareFromToAnchorAnimation(animationDetails.from, animationDetails.to, animationDetails.classes, animationDetails.anchors) : prepareRegularAnimation(animationDetails); @@ -30716,10 +33657,23 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex var cO = currentAnimation.options; return nO.addClass && nO.addClass === cO.removeClass || nO.removeClass && nO.removeClass === cO.addClass; }); - this.$get = [ "$$rAF", "$rootScope", "$rootElement", "$document", "$$body", "$$HashMap", "$$animation", "$$AnimateRunner", "$templateRequest", "$$jqLite", "$$forceReflow", function($$rAF, $rootScope, $rootElement, $document, $$body, $$HashMap, $$animation, $$AnimateRunner, $templateRequest, $$jqLite, $$forceReflow) { + this.$get = [ "$$rAF", "$rootScope", "$rootElement", "$document", "$$HashMap", "$$animation", "$$AnimateRunner", "$templateRequest", "$$jqLite", "$$forceReflow", function($$rAF, $rootScope, $rootElement, $document, $$HashMap, $$animation, $$AnimateRunner, $templateRequest, $$jqLite, $$forceReflow) { var activeAnimationsLookup = new $$HashMap(); var disabledElementsLookup = new $$HashMap(); var animationsEnabled = null; + function postDigestTaskFactory() { + var postDigestCalled = false; + return function(fn) { + if (postDigestCalled) { + fn(); + } else { + $rootScope.$$postDigest(function() { + postDigestCalled = true; + fn(); + }); + } + }; + } var deregisterWatch = $rootScope.$watch(function() { return $templateRequest.totalPendingRequests === 0; }, function(isEmpty) { @@ -30757,13 +33711,6 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex } return matches; } - function triggerCallback(event, element, phase, data) { - $$rAF(function() { - forEach(findCallbacks(element, event), function(callback) { - callback(element, phase, data); - }); - }); - } return { on: function(event, container, callback) { var node = extractElementNode(container); @@ -30830,6 +33777,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex } options = prepareAnimationOptions(options); var runner = new $$AnimateRunner(); + var runInNextPostDigestOrNow = postDigestTaskFactory(); if (isArray(options.addClass)) { options.addClass = options.addClass.join(" "); } @@ -30964,7 +33912,16 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex }); return runner; function notifyProgress(runner, event, phase, data) { - triggerCallback(event, element, phase, data); + runInNextPostDigestOrNow(function() { + var callbacks = findCallbacks(element, event); + if (callbacks.length) { + $$rAF(function() { + forEach(callbacks, function(callback) { + callback(element, phase, data); + }); + }); + } + }); runner.progress(event, phase, data); } function close(reject) { @@ -31002,7 +33959,8 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex return getDomNode(nodeOrElmA) === getDomNode(nodeOrElmB); } function areAnimationsAllowed(element, parentElement, event) { - var bodyElementDetected = isMatchingElement(element, $$body) || element[0].nodeName === "HTML"; + var bodyElement = jqLite($document[0].body); + var bodyElementDetected = isMatchingElement(element, bodyElement) || element[0].nodeName === "HTML"; var rootElementDetected = isMatchingElement(element, $rootElement); var parentAnimationDetected = false; var animateChildren; @@ -31039,7 +33997,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex } } if (!bodyElementDetected) { - bodyElementDetected = isMatchingElement(parentElement, $$body); + bodyElementDetected = isMatchingElement(parentElement, bodyElement); } parentElement = parentElement.parent(); } @@ -31499,228 +34457,9 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex }; } ]; } ]; - angular.module("ngAnimate", []).provider("$$body", $$BodyProvider).directive("ngAnimateChildren", $$AnimateChildrenDirective).factory("$$rAFScheduler", $$rAFSchedulerFactory).factory("$$AnimateRunner", $$AnimateRunnerFactory).factory("$$animateAsyncRun", $$AnimateAsyncRunFactory).provider("$$animateQueue", $$AnimateQueueProvider).provider("$$animation", $$AnimationProvider).provider("$animateCss", $AnimateCssProvider).provider("$$animateCssDriver", $$AnimateCssDriverProvider).provider("$$animateJs", $$AnimateJsProvider).provider("$$animateJsDriver", $$AnimateJsDriverProvider); + angular.module("ngAnimate", []).directive("ngAnimateChildren", $$AnimateChildrenDirective).factory("$$rAFScheduler", $$rAFSchedulerFactory).factory("$$AnimateRunner", $$AnimateRunnerFactory).factory("$$animateAsyncRun", $$AnimateAsyncRunFactory).provider("$$animateQueue", $$AnimateQueueProvider).provider("$$animation", $$AnimationProvider).provider("$animateCss", $AnimateCssProvider).provider("$$animateCssDriver", $$AnimateCssDriverProvider).provider("$$animateJs", $$AnimateJsProvider).provider("$$animateJsDriver", $$AnimateJsDriverProvider); })(window, window.angular); -var app = angular.module("autocomplete", []); - -app.directive("autocomplete", function() { - var index = -1; - return { - restrict: "E", - scope: { - searchParam: "=ngModel", - suggestions: "=data", - onType: "=onType", - onSelect: "=onSelect", - autocompleteRequired: "=" - }, - controller: [ "$scope", function($scope) { - $scope.selectedIndex = -1; - $scope.initLock = true; - $scope.setIndex = function(i) { - $scope.selectedIndex = parseInt(i); - }; - this.setIndex = function(i) { - $scope.setIndex(i); - $scope.$apply(); - }; - $scope.getIndex = function(i) { - return $scope.selectedIndex; - }; - var watching = true; - $scope.completing = false; - $scope.$watch("searchParam", function(newValue, oldValue) { - if (oldValue === newValue || !oldValue && $scope.initLock) { - return; - } - if (watching && typeof $scope.searchParam !== "undefined" && $scope.searchParam !== null) { - $scope.completing = true; - $scope.searchFilter = $scope.searchParam; - $scope.selectedIndex = -1; - } - if ($scope.onType) $scope.onType($scope.searchParam); - }); - this.preSelect = function(suggestion) { - watching = false; - $scope.$apply(); - watching = true; - }; - $scope.preSelect = this.preSelect; - this.preSelectOff = function() { - watching = true; - }; - $scope.preSelectOff = this.preSelectOff; - $scope.select = function(suggestion) { - if (suggestion) { - $scope.searchParam = suggestion; - $scope.searchFilter = suggestion; - if ($scope.onSelect) $scope.onSelect(suggestion); - } - watching = false; - $scope.completing = false; - setTimeout(function() { - watching = true; - }, 1e3); - $scope.setIndex(-1); - }; - } ], - link: function(scope, element, attrs) { - setTimeout(function() { - scope.initLock = false; - scope.$apply(); - }, 250); - var attr = ""; - scope.attrs = { - placeholder: "start typing...", - "class": "", - id: "", - inputclass: "", - inputid: "" - }; - for (var a in attrs) { - attr = a.replace("attr", "").toLowerCase(); - if (a.indexOf("attr") === 0) { - scope.attrs[attr] = attrs[a]; - } - } - if (attrs.clickActivation) { - element[0].onclick = function(e) { - if (!scope.searchParam) { - setTimeout(function() { - scope.completing = true; - scope.$apply(); - }, 200); - } - }; - } - var key = { - left: 37, - up: 38, - right: 39, - down: 40, - enter: 13, - esc: 27, - tab: 9 - }; - document.addEventListener("keydown", function(e) { - var keycode = e.keyCode || e.which; - switch (keycode) { - case key.esc: - scope.select(); - scope.setIndex(-1); - scope.$apply(); - e.preventDefault(); - } - }, true); - document.addEventListener("blur", function(e) { - setTimeout(function() { - scope.select(); - scope.setIndex(-1); - scope.$apply(); - }, 150); - }, true); - element[0].addEventListener("keydown", function(e) { - var keycode = e.keyCode || e.which; - var l = angular.element(this).find("li").length; - if (!scope.completing || l == 0) return; - switch (keycode) { - case key.up: - index = scope.getIndex() - 1; - if (index < -1) { - index = l - 1; - } else if (index >= l) { - index = -1; - scope.setIndex(index); - scope.preSelectOff(); - break; - } - scope.setIndex(index); - if (index !== -1) scope.preSelect(angular.element(angular.element(this).find("li")[index]).text()); - scope.$apply(); - break; - - case key.down: - index = scope.getIndex() + 1; - if (index < -1) { - index = l - 1; - } else if (index >= l) { - index = -1; - scope.setIndex(index); - scope.preSelectOff(); - scope.$apply(); - break; - } - scope.setIndex(index); - if (index !== -1) scope.preSelect(angular.element(angular.element(this).find("li")[index]).text()); - break; - - case key.left: - break; - - case key.right: - case key.enter: - case key.tab: - index = scope.getIndex(); - if (index !== -1) { - scope.select(angular.element(angular.element(this).find("li")[index]).text()); - if (keycode == key.enter) { - e.preventDefault(); - } - } else { - if (keycode == key.enter) { - scope.select(); - } - } - scope.setIndex(-1); - scope.$apply(); - break; - - case key.esc: - scope.select(); - scope.setIndex(-1); - scope.$apply(); - e.preventDefault(); - break; - - default: - return; - } - }); - }, - template: '
' - }; -}); - -app.filter("highlight", [ "$sce", function($sce) { - return function(input, searchParam) { - if (typeof input === "function") return ""; - if (searchParam) { - var words = "(" + searchParam.split(/\ /).join(" |") + "|" + searchParam.split(/\ /).join("|") + ")", exp = new RegExp(words, "gi"); - if (words.length) { - input = input.replace(exp, '$1'); - } - } - return $sce.trustAsHtml(input); - }; -} ]); - -app.directive("suggestion", function() { - return { - restrict: "A", - require: "^autocomplete", - link: function(scope, element, attrs, autoCtrl) { - element.bind("mouseenter", function() { - autoCtrl.preSelect(attrs.val); - autoCtrl.setIndex(attrs.index); - }); - element.bind("mouseleave", function() { - autoCtrl.preSelectOff(); - }); - } - }; -}); - function getCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(";"); @@ -32862,7 +35601,7 @@ function responseHandler($timeout, $modal) { }; } -var app = angular.module("CreateDictionaryModule", [ "ui.router", "ngAnimate", "ui.bootstrap", "autocomplete" ]); +var app = angular.module("CreateDictionaryModule", [ "ui.router", "ui.bootstrap" ]); app.service("dictionaryService", lingvodocAPI); @@ -32886,7 +35625,7 @@ app.config(function($stateProvider, $urlRouterProvider) { app.factory("responseHandler", [ "$timeout", "$modal", responseHandler ]); -app.controller("CreateDictionaryController", [ "$scope", "$http", "$modal", "$interval", "$state", "$location", "$log", "dictionaryService", "responseHandler", function($scope, $http, $modal, $interval, $state, $location, $log, dictionaryService, responseHandler) { +app.controller("CreateDictionaryController", [ "$scope", "$http", "$modal", "$interval", "$state", "$window", "$log", "dictionaryService", "responseHandler", function($scope, $http, $modal, $interval, $state, $window, $log, dictionaryService, responseHandler) { var clientId = $("#clientId").data("lingvodoc"); var userId = $("#userId").data("lingvodoc"); var languagesUrl = $("#languagesUrl").data("lingvodoc"); @@ -32990,6 +35729,7 @@ app.controller("CreateDictionaryController", [ "$scope", "$http", "$modal", "$in var convert = function(req) { dictionaryService.convertDictionary(req).then(function(response) { responseHandler.success(response); + $window.location.href = "/dashboard"; }, function(reason) { responseHandler.error(reason); }); diff --git a/lingvodoc/static/js/dashboard.js b/lingvodoc/static/js/dashboard.js index 050ccff6a..bc1e20e29 100644 --- a/lingvodoc/static/js/dashboard.js +++ b/lingvodoc/static/js/dashboard.js @@ -5378,4028 +5378,6919 @@ }); (function() { - var root = this; - var previousUnderscore = root._; - var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; - var push = ArrayProto.push, slice = ArrayProto.slice, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty; - var nativeIsArray = Array.isArray, nativeKeys = Object.keys, nativeBind = FuncProto.bind, nativeCreate = Object.create; - var Ctor = function() {}; - var _ = function(obj) { - if (obj instanceof _) return obj; - if (!(this instanceof _)) return new _(obj); - this._wrapped = obj; - }; - if (typeof exports !== "undefined") { - if (typeof module !== "undefined" && module.exports) { - exports = module.exports = _; - } - exports._ = _; - } else { - root._ = _; - } - _.VERSION = "1.8.3"; - var optimizeCb = function(func, context, argCount) { - if (context === void 0) return func; - switch (argCount == null ? 3 : argCount) { - case 1: - return function(value) { - return func.call(context, value); - }; - - case 2: - return function(value, other) { - return func.call(context, value, other); - }; - - case 3: - return function(value, index, collection) { - return func.call(context, value, index, collection); - }; - - case 4: - return function(accumulator, value, index, collection) { - return func.call(context, accumulator, value, index, collection); - }; - } - return function() { - return func.apply(context, arguments); - }; - }; - var cb = function(value, context, argCount) { - if (value == null) return _.identity; - if (_.isFunction(value)) return optimizeCb(value, context, argCount); - if (_.isObject(value)) return _.matcher(value); - return _.property(value); - }; - _.iteratee = function(value, context) { - return cb(value, context, Infinity); + var undefined; + var VERSION = "3.10.1"; + var BIND_FLAG = 1, BIND_KEY_FLAG = 2, CURRY_BOUND_FLAG = 4, CURRY_FLAG = 8, CURRY_RIGHT_FLAG = 16, PARTIAL_FLAG = 32, PARTIAL_RIGHT_FLAG = 64, ARY_FLAG = 128, REARG_FLAG = 256; + var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = "..."; + var HOT_COUNT = 150, HOT_SPAN = 16; + var LARGE_ARRAY_SIZE = 200; + var LAZY_FILTER_FLAG = 1, LAZY_MAP_FLAG = 2; + var FUNC_ERROR_TEXT = "Expected a function"; + var PLACEHOLDER = "__lodash_placeholder__"; + var argsTag = "[object Arguments]", arrayTag = "[object Array]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", mapTag = "[object Map]", numberTag = "[object Number]", objectTag = "[object Object]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", weakMapTag = "[object WeakMap]"; + var arrayBufferTag = "[object ArrayBuffer]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]"; + var reEmptyStringLeading = /\b__p \+= '';/g, reEmptyStringMiddle = /\b(__p \+=) '' \+/g, reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; + var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g, reUnescapedHtml = /[&<>"'`]/g, reHasEscapedHtml = RegExp(reEscapedHtml.source), reHasUnescapedHtml = RegExp(reUnescapedHtml.source); + var reEscape = /<%-([\s\S]+?)%>/g, reEvaluate = /<%([\s\S]+?)%>/g, reInterpolate = /<%=([\s\S]+?)%>/g; + var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g; + var reRegExpChars = /^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g, reHasRegExpChars = RegExp(reRegExpChars.source); + var reComboMark = /[\u0300-\u036f\ufe20-\ufe23]/g; + var reEscapeChar = /\\(\\)?/g; + var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; + var reFlags = /\w*$/; + var reHasHexPrefix = /^0[xX]/; + var reIsHostCtor = /^\[object .+?Constructor\]$/; + var reIsUint = /^\d+$/; + var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; + var reNoMatch = /($^)/; + var reUnescapedString = /['\n\r\u2028\u2029\\]/g; + var reWords = function() { + var upper = "[A-Z\\xc0-\\xd6\\xd8-\\xde]", lower = "[a-z\\xdf-\\xf6\\xf8-\\xff]+"; + return RegExp(upper + "+(?=" + upper + lower + ")|" + upper + "?" + lower + "|" + upper + "+|[0-9]+", "g"); + }(); + var contextProps = [ "Array", "ArrayBuffer", "Date", "Error", "Float32Array", "Float64Array", "Function", "Int8Array", "Int16Array", "Int32Array", "Math", "Number", "Object", "RegExp", "Set", "String", "_", "clearTimeout", "isFinite", "parseFloat", "parseInt", "setTimeout", "TypeError", "Uint8Array", "Uint8ClampedArray", "Uint16Array", "Uint32Array", "WeakMap" ]; + var templateCounter = -1; + var typedArrayTags = {}; + typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; + typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; + var cloneableTags = {}; + cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[stringTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; + cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[mapTag] = cloneableTags[setTag] = cloneableTags[weakMapTag] = false; + var deburredLetters = { + "À": "A", + "Á": "A", + "Â": "A", + "Ã": "A", + "Ä": "A", + "Å": "A", + "à": "a", + "á": "a", + "â": "a", + "ã": "a", + "ä": "a", + "å": "a", + "Ç": "C", + "ç": "c", + "Ð": "D", + "ð": "d", + "È": "E", + "É": "E", + "Ê": "E", + "Ë": "E", + "è": "e", + "é": "e", + "ê": "e", + "ë": "e", + "Ì": "I", + "Í": "I", + "Î": "I", + "Ï": "I", + "ì": "i", + "í": "i", + "î": "i", + "ï": "i", + "Ñ": "N", + "ñ": "n", + "Ò": "O", + "Ó": "O", + "Ô": "O", + "Õ": "O", + "Ö": "O", + "Ø": "O", + "ò": "o", + "ó": "o", + "ô": "o", + "õ": "o", + "ö": "o", + "ø": "o", + "Ù": "U", + "Ú": "U", + "Û": "U", + "Ü": "U", + "ù": "u", + "ú": "u", + "û": "u", + "ü": "u", + "Ý": "Y", + "ý": "y", + "ÿ": "y", + "Æ": "Ae", + "æ": "ae", + "Þ": "Th", + "þ": "th", + "ß": "ss" + }; + var htmlEscapes = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + "`": "`" + }; + var htmlUnescapes = { + "&": "&", + "<": "<", + ">": ">", + """: '"', + "'": "'", + "`": "`" + }; + var objectTypes = { + "function": true, + object: true + }; + var regexpEscapes = { + "0": "x30", + "1": "x31", + "2": "x32", + "3": "x33", + "4": "x34", + "5": "x35", + "6": "x36", + "7": "x37", + "8": "x38", + "9": "x39", + A: "x41", + B: "x42", + C: "x43", + D: "x44", + E: "x45", + F: "x46", + a: "x61", + b: "x62", + c: "x63", + d: "x64", + e: "x65", + f: "x66", + n: "x6e", + r: "x72", + t: "x74", + u: "x75", + v: "x76", + x: "x78" + }; + var stringEscapes = { + "\\": "\\", + "'": "'", + "\n": "n", + "\r": "r", + "\u2028": "u2028", + "\u2029": "u2029" }; - var createAssigner = function(keysFunc, undefinedOnly) { - return function(obj) { - var length = arguments.length; - if (length < 2 || obj == null) return obj; - for (var index = 1; index < length; index++) { - var source = arguments[index], keys = keysFunc(source), l = keys.length; - for (var i = 0; i < l; i++) { - var key = keys[i]; - if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key]; - } + var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; + var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; + var freeGlobal = freeExports && freeModule && typeof global == "object" && global && global.Object && global; + var freeSelf = objectTypes[typeof self] && self && self.Object && self; + var freeWindow = objectTypes[typeof window] && window && window.Object && window; + var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; + var root = freeGlobal || freeWindow !== (this && this.window) && freeWindow || freeSelf || this; + function baseCompareAscending(value, other) { + if (value !== other) { + var valIsNull = value === null, valIsUndef = value === undefined, valIsReflexive = value === value; + var othIsNull = other === null, othIsUndef = other === undefined, othIsReflexive = other === other; + if (value > other && !othIsNull || !valIsReflexive || valIsNull && !othIsUndef && othIsReflexive || valIsUndef && othIsReflexive) { + return 1; } - return obj; - }; - }; - var baseCreate = function(prototype) { - if (!_.isObject(prototype)) return {}; - if (nativeCreate) return nativeCreate(prototype); - Ctor.prototype = prototype; - var result = new Ctor(); - Ctor.prototype = null; - return result; - }; - var property = function(key) { - return function(obj) { - return obj == null ? void 0 : obj[key]; - }; - }; - var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; - var getLength = property("length"); - var isArrayLike = function(collection) { - var length = getLength(collection); - return typeof length == "number" && length >= 0 && length <= MAX_ARRAY_INDEX; - }; - _.each = _.forEach = function(obj, iteratee, context) { - iteratee = optimizeCb(iteratee, context); - var i, length; - if (isArrayLike(obj)) { - for (i = 0, length = obj.length; i < length; i++) { - iteratee(obj[i], i, obj); + if (value < other && !valIsNull || !othIsReflexive || othIsNull && !valIsUndef && valIsReflexive || othIsUndef && valIsReflexive) { + return -1; } - } else { - var keys = _.keys(obj); - for (i = 0, length = keys.length; i < length; i++) { - iteratee(obj[keys[i]], keys[i], obj); + } + return 0; + } + function baseFindIndex(array, predicate, fromRight) { + var length = array.length, index = fromRight ? length : -1; + while (fromRight ? index-- : ++index < length) { + if (predicate(array[index], index, array)) { + return index; } } - return obj; - }; - _.map = _.collect = function(obj, iteratee, context) { - iteratee = cb(iteratee, context); - var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length, results = Array(length); - for (var index = 0; index < length; index++) { - var currentKey = keys ? keys[index] : index; - results[index] = iteratee(obj[currentKey], currentKey, obj); + return -1; + } + function baseIndexOf(array, value, fromIndex) { + if (value !== value) { + return indexOfNaN(array, fromIndex); } - return results; - }; - function createReduce(dir) { - function iterator(obj, iteratee, memo, keys, index, length) { - for (;index >= 0 && index < length; index += dir) { - var currentKey = keys ? keys[index] : index; - memo = iteratee(memo, obj[currentKey], currentKey, obj); + var index = fromIndex - 1, length = array.length; + while (++index < length) { + if (array[index] === value) { + return index; } - return memo; } - return function(obj, iteratee, memo, context) { - iteratee = optimizeCb(iteratee, context, 4); - var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length, index = dir > 0 ? 0 : length - 1; - if (arguments.length < 3) { - memo = obj[keys ? keys[index] : index]; - index += dir; - } - return iterator(obj, iteratee, memo, keys, index, length); - }; + return -1; } - _.reduce = _.foldl = _.inject = createReduce(1); - _.reduceRight = _.foldr = createReduce(-1); - _.find = _.detect = function(obj, predicate, context) { - var key; - if (isArrayLike(obj)) { - key = _.findIndex(obj, predicate, context); - } else { - key = _.findKey(obj, predicate, context); + function baseIsFunction(value) { + return typeof value == "function" || false; + } + function baseToString(value) { + return value == null ? "" : value + ""; + } + function charsLeftIndex(string, chars) { + var index = -1, length = string.length; + while (++index < length && chars.indexOf(string.charAt(index)) > -1) {} + return index; + } + function charsRightIndex(string, chars) { + var index = string.length; + while (index-- && chars.indexOf(string.charAt(index)) > -1) {} + return index; + } + function compareAscending(object, other) { + return baseCompareAscending(object.criteria, other.criteria) || object.index - other.index; + } + function compareMultiple(object, other, orders) { + var index = -1, objCriteria = object.criteria, othCriteria = other.criteria, length = objCriteria.length, ordersLength = orders.length; + while (++index < length) { + var result = baseCompareAscending(objCriteria[index], othCriteria[index]); + if (result) { + if (index >= ordersLength) { + return result; + } + var order = orders[index]; + return result * (order === "asc" || order === true ? 1 : -1); + } } - if (key !== void 0 && key !== -1) return obj[key]; - }; - _.filter = _.select = function(obj, predicate, context) { - var results = []; - predicate = cb(predicate, context); - _.each(obj, function(value, index, list) { - if (predicate(value, index, list)) results.push(value); - }); - return results; - }; - _.reject = function(obj, predicate, context) { - return _.filter(obj, _.negate(cb(predicate)), context); - }; - _.every = _.all = function(obj, predicate, context) { - predicate = cb(predicate, context); - var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length; - for (var index = 0; index < length; index++) { - var currentKey = keys ? keys[index] : index; - if (!predicate(obj[currentKey], currentKey, obj)) return false; + return object.index - other.index; + } + function deburrLetter(letter) { + return deburredLetters[letter]; + } + function escapeHtmlChar(chr) { + return htmlEscapes[chr]; + } + function escapeRegExpChar(chr, leadingChar, whitespaceChar) { + if (leadingChar) { + chr = regexpEscapes[chr]; + } else if (whitespaceChar) { + chr = stringEscapes[chr]; } - return true; - }; - _.some = _.any = function(obj, predicate, context) { - predicate = cb(predicate, context); - var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length; - for (var index = 0; index < length; index++) { - var currentKey = keys ? keys[index] : index; - if (predicate(obj[currentKey], currentKey, obj)) return true; + return "\\" + chr; + } + function escapeStringChar(chr) { + return "\\" + stringEscapes[chr]; + } + function indexOfNaN(array, fromIndex, fromRight) { + var length = array.length, index = fromIndex + (fromRight ? 0 : -1); + while (fromRight ? index-- : ++index < length) { + var other = array[index]; + if (other !== other) { + return index; + } } - return false; - }; - _.contains = _.includes = _.include = function(obj, item, fromIndex, guard) { - if (!isArrayLike(obj)) obj = _.values(obj); - if (typeof fromIndex != "number" || guard) fromIndex = 0; - return _.indexOf(obj, item, fromIndex) >= 0; - }; - _.invoke = function(obj, method) { - var args = slice.call(arguments, 2); - var isFunc = _.isFunction(method); - return _.map(obj, function(value) { - var func = isFunc ? method : value[method]; - return func == null ? func : func.apply(value, args); - }); - }; - _.pluck = function(obj, key) { - return _.map(obj, _.property(key)); - }; - _.where = function(obj, attrs) { - return _.filter(obj, _.matcher(attrs)); - }; - _.findWhere = function(obj, attrs) { - return _.find(obj, _.matcher(attrs)); - }; - _.max = function(obj, iteratee, context) { - var result = -Infinity, lastComputed = -Infinity, value, computed; - if (iteratee == null && obj != null) { - obj = isArrayLike(obj) ? obj : _.values(obj); - for (var i = 0, length = obj.length; i < length; i++) { - value = obj[i]; - if (value > result) { - result = value; - } + return -1; + } + function isObjectLike(value) { + return !!value && typeof value == "object"; + } + function isSpace(charCode) { + return charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160 || charCode == 5760 || charCode == 6158 || charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279); + } + function replaceHolders(array, placeholder) { + var index = -1, length = array.length, resIndex = -1, result = []; + while (++index < length) { + if (array[index] === placeholder) { + array[index] = PLACEHOLDER; + result[++resIndex] = index; } - } else { - iteratee = cb(iteratee, context); - _.each(obj, function(value, index, list) { - computed = iteratee(value, index, list); - if (computed > lastComputed || computed === -Infinity && result === -Infinity) { - result = value; - lastComputed = computed; - } - }); } return result; - }; - _.min = function(obj, iteratee, context) { - var result = Infinity, lastComputed = Infinity, value, computed; - if (iteratee == null && obj != null) { - obj = isArrayLike(obj) ? obj : _.values(obj); - for (var i = 0, length = obj.length; i < length; i++) { - value = obj[i]; - if (value < result) { - result = value; - } + } + function sortedUniq(array, iteratee) { + var seen, index = -1, length = array.length, resIndex = -1, result = []; + while (++index < length) { + var value = array[index], computed = iteratee ? iteratee(value, index, array) : value; + if (!index || seen !== computed) { + seen = computed; + result[++resIndex] = value; } - } else { - iteratee = cb(iteratee, context); - _.each(obj, function(value, index, list) { - computed = iteratee(value, index, list); - if (computed < lastComputed || computed === Infinity && result === Infinity) { - result = value; - lastComputed = computed; - } - }); } return result; - }; - _.shuffle = function(obj) { - var set = isArrayLike(obj) ? obj : _.values(obj); - var length = set.length; - var shuffled = Array(length); - for (var index = 0, rand; index < length; index++) { - rand = _.random(0, index); - if (rand !== index) shuffled[index] = shuffled[rand]; - shuffled[rand] = set[index]; - } - return shuffled; - }; - _.sample = function(obj, n, guard) { - if (n == null || guard) { - if (!isArrayLike(obj)) obj = _.values(obj); - return obj[_.random(obj.length - 1)]; + } + function trimmedLeftIndex(string) { + var index = -1, length = string.length; + while (++index < length && isSpace(string.charCodeAt(index))) {} + return index; + } + function trimmedRightIndex(string) { + var index = string.length; + while (index-- && isSpace(string.charCodeAt(index))) {} + return index; + } + function unescapeHtmlChar(chr) { + return htmlUnescapes[chr]; + } + function runInContext(context) { + context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root; + var Array = context.Array, Date = context.Date, Error = context.Error, Function = context.Function, Math = context.Math, Number = context.Number, Object = context.Object, RegExp = context.RegExp, String = context.String, TypeError = context.TypeError; + var arrayProto = Array.prototype, objectProto = Object.prototype, stringProto = String.prototype; + var fnToString = Function.prototype.toString; + var hasOwnProperty = objectProto.hasOwnProperty; + var idCounter = 0; + var objToString = objectProto.toString; + var oldDash = root._; + var reIsNative = RegExp("^" + fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"); + var ArrayBuffer = context.ArrayBuffer, clearTimeout = context.clearTimeout, parseFloat = context.parseFloat, pow = Math.pow, propertyIsEnumerable = objectProto.propertyIsEnumerable, Set = getNative(context, "Set"), setTimeout = context.setTimeout, splice = arrayProto.splice, Uint8Array = context.Uint8Array, WeakMap = getNative(context, "WeakMap"); + var nativeCeil = Math.ceil, nativeCreate = getNative(Object, "create"), nativeFloor = Math.floor, nativeIsArray = getNative(Array, "isArray"), nativeIsFinite = context.isFinite, nativeKeys = getNative(Object, "keys"), nativeMax = Math.max, nativeMin = Math.min, nativeNow = getNative(Date, "now"), nativeParseInt = context.parseInt, nativeRandom = Math.random; + var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY, POSITIVE_INFINITY = Number.POSITIVE_INFINITY; + var MAX_ARRAY_LENGTH = 4294967295, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; + var MAX_SAFE_INTEGER = 9007199254740991; + var metaMap = WeakMap && new WeakMap(); + var realNames = {}; + function lodash(value) { + if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { + if (value instanceof LodashWrapper) { + return value; + } + if (hasOwnProperty.call(value, "__chain__") && hasOwnProperty.call(value, "__wrapped__")) { + return wrapperClone(value); + } + } + return new LodashWrapper(value); + } + function baseLodash() {} + function LodashWrapper(value, chainAll, actions) { + this.__wrapped__ = value; + this.__actions__ = actions || []; + this.__chain__ = !!chainAll; + } + var support = lodash.support = {}; + lodash.templateSettings = { + escape: reEscape, + evaluate: reEvaluate, + interpolate: reInterpolate, + variable: "", + imports: { + _: lodash + } + }; + function LazyWrapper(value) { + this.__wrapped__ = value; + this.__actions__ = []; + this.__dir__ = 1; + this.__filtered__ = false; + this.__iteratees__ = []; + this.__takeCount__ = POSITIVE_INFINITY; + this.__views__ = []; + } + function lazyClone() { + var result = new LazyWrapper(this.__wrapped__); + result.__actions__ = arrayCopy(this.__actions__); + result.__dir__ = this.__dir__; + result.__filtered__ = this.__filtered__; + result.__iteratees__ = arrayCopy(this.__iteratees__); + result.__takeCount__ = this.__takeCount__; + result.__views__ = arrayCopy(this.__views__); + return result; } - return _.shuffle(obj).slice(0, Math.max(0, n)); - }; - _.sortBy = function(obj, iteratee, context) { - iteratee = cb(iteratee, context); - return _.pluck(_.map(obj, function(value, index, list) { - return { - value: value, - index: index, - criteria: iteratee(value, index, list) - }; - }).sort(function(left, right) { - var a = left.criteria; - var b = right.criteria; - if (a !== b) { - if (a > b || a === void 0) return 1; - if (a < b || b === void 0) return -1; + function lazyReverse() { + if (this.__filtered__) { + var result = new LazyWrapper(this); + result.__dir__ = -1; + result.__filtered__ = true; + } else { + result = this.clone(); + result.__dir__ *= -1; } - return left.index - right.index; - }), "value"); - }; - var group = function(behavior) { - return function(obj, iteratee, context) { - var result = {}; - iteratee = cb(iteratee, context); - _.each(obj, function(value, index) { - var key = iteratee(value, index, obj); - behavior(result, value, key); - }); return result; - }; - }; - _.groupBy = group(function(result, value, key) { - if (_.has(result, key)) result[key].push(value); else result[key] = [ value ]; - }); - _.indexBy = group(function(result, value, key) { - result[key] = value; - }); - _.countBy = group(function(result, value, key) { - if (_.has(result, key)) result[key]++; else result[key] = 1; - }); - _.toArray = function(obj) { - if (!obj) return []; - if (_.isArray(obj)) return slice.call(obj); - if (isArrayLike(obj)) return _.map(obj, _.identity); - return _.values(obj); - }; - _.size = function(obj) { - if (obj == null) return 0; - return isArrayLike(obj) ? obj.length : _.keys(obj).length; - }; - _.partition = function(obj, predicate, context) { - predicate = cb(predicate, context); - var pass = [], fail = []; - _.each(obj, function(value, key, obj) { - (predicate(value, key, obj) ? pass : fail).push(value); - }); - return [ pass, fail ]; - }; - _.first = _.head = _.take = function(array, n, guard) { - if (array == null) return void 0; - if (n == null || guard) return array[0]; - return _.initial(array, array.length - n); - }; - _.initial = function(array, n, guard) { - return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); - }; - _.last = function(array, n, guard) { - if (array == null) return void 0; - if (n == null || guard) return array[array.length - 1]; - return _.rest(array, Math.max(0, array.length - n)); - }; - _.rest = _.tail = _.drop = function(array, n, guard) { - return slice.call(array, n == null || guard ? 1 : n); - }; - _.compact = function(array) { - return _.filter(array, _.identity); - }; - var flatten = function(input, shallow, strict, startIndex) { - var output = [], idx = 0; - for (var i = startIndex || 0, length = getLength(input); i < length; i++) { - var value = input[i]; - if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) { - if (!shallow) value = flatten(value, shallow, strict); - var j = 0, len = value.length; - output.length += len; - while (j < len) { - output[idx++] = value[j++]; - } - } else if (!strict) { - output[idx++] = value; - } - } - return output; - }; - _.flatten = function(array, shallow) { - return flatten(array, shallow, false); - }; - _.without = function(array) { - return _.difference(array, slice.call(arguments, 1)); - }; - _.uniq = _.unique = function(array, isSorted, iteratee, context) { - if (!_.isBoolean(isSorted)) { - context = iteratee; - iteratee = isSorted; - isSorted = false; - } - if (iteratee != null) iteratee = cb(iteratee, context); - var result = []; - var seen = []; - for (var i = 0, length = getLength(array); i < length; i++) { - var value = array[i], computed = iteratee ? iteratee(value, i, array) : value; - if (isSorted) { - if (!i || seen !== computed) result.push(value); - seen = computed; - } else if (iteratee) { - if (!_.contains(seen, computed)) { - seen.push(computed); - result.push(value); + } + function lazyValue() { + var array = this.__wrapped__.value(), dir = this.__dir__, isArr = isArray(array), isRight = dir < 0, arrLength = isArr ? array.length : 0, view = getView(0, arrLength, this.__views__), start = view.start, end = view.end, length = end - start, index = isRight ? end : start - 1, iteratees = this.__iteratees__, iterLength = iteratees.length, resIndex = 0, takeCount = nativeMin(length, this.__takeCount__); + if (!isArr || arrLength < LARGE_ARRAY_SIZE || arrLength == length && takeCount == length) { + return baseWrapperValue(array, this.__actions__); + } + var result = []; + outer: while (length-- && resIndex < takeCount) { + index += dir; + var iterIndex = -1, value = array[index]; + while (++iterIndex < iterLength) { + var data = iteratees[iterIndex], iteratee = data.iteratee, type = data.type, computed = iteratee(value); + if (type == LAZY_MAP_FLAG) { + value = computed; + } else if (!computed) { + if (type == LAZY_FILTER_FLAG) { + continue outer; + } else { + break outer; + } + } } - } else if (!_.contains(result, value)) { - result.push(value); + result[resIndex++] = value; } + return result; } - return result; - }; - _.union = function() { - return _.uniq(flatten(arguments, true, true)); - }; - _.intersection = function(array) { - var result = []; - var argsLength = arguments.length; - for (var i = 0, length = getLength(array); i < length; i++) { - var item = array[i]; - if (_.contains(result, item)) continue; - for (var j = 1; j < argsLength; j++) { - if (!_.contains(arguments[j], item)) break; + function MapCache() { + this.__data__ = {}; + } + function mapDelete(key) { + return this.has(key) && delete this.__data__[key]; + } + function mapGet(key) { + return key == "__proto__" ? undefined : this.__data__[key]; + } + function mapHas(key) { + return key != "__proto__" && hasOwnProperty.call(this.__data__, key); + } + function mapSet(key, value) { + if (key != "__proto__") { + this.__data__[key] = value; } - if (j === argsLength) result.push(item); + return this; } - return result; - }; - _.difference = function(array) { - var rest = flatten(arguments, true, true, 1); - return _.filter(array, function(value) { - return !_.contains(rest, value); - }); - }; - _.zip = function() { - return _.unzip(arguments); - }; - _.unzip = function(array) { - var length = array && _.max(array, getLength).length || 0; - var result = Array(length); - for (var index = 0; index < length; index++) { - result[index] = _.pluck(array, index); + function SetCache(values) { + var length = values ? values.length : 0; + this.data = { + hash: nativeCreate(null), + set: new Set() + }; + while (length--) { + this.push(values[length]); + } } - return result; - }; - _.object = function(list, values) { - var result = {}; - for (var i = 0, length = getLength(list); i < length; i++) { - if (values) { - result[list[i]] = values[i]; + function cacheIndexOf(cache, value) { + var data = cache.data, result = typeof value == "string" || isObject(value) ? data.set.has(value) : data.hash[value]; + return result ? 0 : -1; + } + function cachePush(value) { + var data = this.data; + if (typeof value == "string" || isObject(value)) { + data.set.add(value); } else { - result[list[i][0]] = list[i][1]; + data.hash[value] = true; } } - return result; - }; - function createPredicateIndexFinder(dir) { - return function(array, predicate, context) { - predicate = cb(predicate, context); - var length = getLength(array); - var index = dir > 0 ? 0 : length - 1; - for (;index >= 0 && index < length; index += dir) { - if (predicate(array[index], index, array)) return index; + function arrayConcat(array, other) { + var index = -1, length = array.length, othIndex = -1, othLength = other.length, result = Array(length + othLength); + while (++index < length) { + result[index] = array[index]; } - return -1; - }; - } - _.findIndex = createPredicateIndexFinder(1); - _.findLastIndex = createPredicateIndexFinder(-1); - _.sortedIndex = function(array, obj, iteratee, context) { - iteratee = cb(iteratee, context, 1); - var value = iteratee(obj); - var low = 0, high = getLength(array); - while (low < high) { - var mid = Math.floor((low + high) / 2); - if (iteratee(array[mid]) < value) low = mid + 1; else high = mid; - } - return low; - }; - function createIndexFinder(dir, predicateFind, sortedIndex) { - return function(array, item, idx) { - var i = 0, length = getLength(array); - if (typeof idx == "number") { - if (dir > 0) { - i = idx >= 0 ? idx : Math.max(idx + length, i); - } else { - length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; - } - } else if (sortedIndex && idx && length) { - idx = sortedIndex(array, item); - return array[idx] === item ? idx : -1; + while (++othIndex < othLength) { + result[index++] = other[othIndex]; } - if (item !== item) { - idx = predicateFind(slice.call(array, i, length), _.isNaN); - return idx >= 0 ? idx + i : -1; + return result; + } + function arrayCopy(source, array) { + var index = -1, length = source.length; + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; } - for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) { - if (array[idx] === item) return idx; + return array; + } + function arrayEach(array, iteratee) { + var index = -1, length = array.length; + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } } - return -1; - }; - } - _.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex); - _.lastIndexOf = createIndexFinder(-1, _.findLastIndex); - _.range = function(start, stop, step) { - if (stop == null) { - stop = start || 0; - start = 0; + return array; } - step = step || 1; - var length = Math.max(Math.ceil((stop - start) / step), 0); - var range = Array(length); - for (var idx = 0; idx < length; idx++, start += step) { - range[idx] = start; + function arrayEachRight(array, iteratee) { + var length = array.length; + while (length--) { + if (iteratee(array[length], length, array) === false) { + break; + } + } + return array; } - return range; - }; - var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) { - if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); - var self = baseCreate(sourceFunc.prototype); - var result = sourceFunc.apply(self, args); - if (_.isObject(result)) return result; - return self; - }; - _.bind = function(func, context) { - if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); - if (!_.isFunction(func)) throw new TypeError("Bind must be called on a function"); - var args = slice.call(arguments, 2); - var bound = function() { - return executeBound(func, bound, context, this, args.concat(slice.call(arguments))); - }; - return bound; - }; - _.partial = function(func) { - var boundArgs = slice.call(arguments, 1); - var bound = function() { - var position = 0, length = boundArgs.length; - var args = Array(length); - for (var i = 0; i < length; i++) { - args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i]; + function arrayEvery(array, predicate) { + var index = -1, length = array.length; + while (++index < length) { + if (!predicate(array[index], index, array)) { + return false; + } } - while (position < arguments.length) args.push(arguments[position++]); - return executeBound(func, bound, this, this, args); - }; - return bound; - }; - _.bindAll = function(obj) { - var i, length = arguments.length, key; - if (length <= 1) throw new Error("bindAll must be passed function names"); - for (i = 1; i < length; i++) { - key = arguments[i]; - obj[key] = _.bind(obj[key], obj); + return true; } - return obj; - }; - _.memoize = function(func, hasher) { - var memoize = function(key) { - var cache = memoize.cache; - var address = "" + (hasher ? hasher.apply(this, arguments) : key); - if (!_.has(cache, address)) cache[address] = func.apply(this, arguments); - return cache[address]; - }; - memoize.cache = {}; - return memoize; - }; - _.delay = function(func, wait) { - var args = slice.call(arguments, 2); - return setTimeout(function() { - return func.apply(null, args); - }, wait); - }; - _.defer = _.partial(_.delay, _, 1); - _.throttle = function(func, wait, options) { - var context, args, result; - var timeout = null; - var previous = 0; - if (!options) options = {}; - var later = function() { - previous = options.leading === false ? 0 : _.now(); - timeout = null; - result = func.apply(context, args); - if (!timeout) context = args = null; - }; - return function() { - var now = _.now(); - if (!previous && options.leading === false) previous = now; - var remaining = wait - (now - previous); - context = this; - args = arguments; - if (remaining <= 0 || remaining > wait) { - if (timeout) { - clearTimeout(timeout); - timeout = null; - } - previous = now; - result = func.apply(context, args); - if (!timeout) context = args = null; - } else if (!timeout && options.trailing !== false) { - timeout = setTimeout(later, remaining); + function arrayExtremum(array, iteratee, comparator, exValue) { + var index = -1, length = array.length, computed = exValue, result = computed; + while (++index < length) { + var value = array[index], current = +iteratee(value); + if (comparator(current, computed)) { + computed = current; + result = value; + } } return result; - }; - }; - _.debounce = function(func, wait, immediate) { - var timeout, args, context, timestamp, result; - var later = function() { - var last = _.now() - timestamp; - if (last < wait && last >= 0) { - timeout = setTimeout(later, wait - last); - } else { - timeout = null; - if (!immediate) { - result = func.apply(context, args); - if (!timeout) context = args = null; + } + function arrayFilter(array, predicate) { + var index = -1, length = array.length, resIndex = -1, result = []; + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[++resIndex] = value; } } - }; - return function() { - context = this; - args = arguments; - timestamp = _.now(); - var callNow = immediate && !timeout; - if (!timeout) timeout = setTimeout(later, wait); - if (callNow) { - result = func.apply(context, args); - context = args = null; - } - return result; - }; - }; - _.wrap = function(func, wrapper) { - return _.partial(wrapper, func); - }; - _.negate = function(predicate) { - return function() { - return !predicate.apply(this, arguments); - }; - }; - _.compose = function() { - var args = arguments; - var start = args.length - 1; - return function() { - var i = start; - var result = args[start].apply(this, arguments); - while (i--) result = args[i].call(this, result); return result; - }; - }; - _.after = function(times, func) { - return function() { - if (--times < 1) { - return func.apply(this, arguments); - } - }; - }; - _.before = function(times, func) { - var memo; - return function() { - if (--times > 0) { - memo = func.apply(this, arguments); - } - if (times <= 1) func = null; - return memo; - }; - }; - _.once = _.partial(_.before, 2); - var hasEnumBug = !{ - toString: null - }.propertyIsEnumerable("toString"); - var nonEnumerableProps = [ "valueOf", "isPrototypeOf", "toString", "propertyIsEnumerable", "hasOwnProperty", "toLocaleString" ]; - function collectNonEnumProps(obj, keys) { - var nonEnumIdx = nonEnumerableProps.length; - var constructor = obj.constructor; - var proto = _.isFunction(constructor) && constructor.prototype || ObjProto; - var prop = "constructor"; - if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop); - while (nonEnumIdx--) { - prop = nonEnumerableProps[nonEnumIdx]; - if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) { - keys.push(prop); - } - } - } - _.keys = function(obj) { - if (!_.isObject(obj)) return []; - if (nativeKeys) return nativeKeys(obj); - var keys = []; - for (var key in obj) if (_.has(obj, key)) keys.push(key); - if (hasEnumBug) collectNonEnumProps(obj, keys); - return keys; - }; - _.allKeys = function(obj) { - if (!_.isObject(obj)) return []; - var keys = []; - for (var key in obj) keys.push(key); - if (hasEnumBug) collectNonEnumProps(obj, keys); - return keys; - }; - _.values = function(obj) { - var keys = _.keys(obj); - var length = keys.length; - var values = Array(length); - for (var i = 0; i < length; i++) { - values[i] = obj[keys[i]]; - } - return values; - }; - _.mapObject = function(obj, iteratee, context) { - iteratee = cb(iteratee, context); - var keys = _.keys(obj), length = keys.length, results = {}, currentKey; - for (var index = 0; index < length; index++) { - currentKey = keys[index]; - results[currentKey] = iteratee(obj[currentKey], currentKey, obj); } - return results; - }; - _.pairs = function(obj) { - var keys = _.keys(obj); - var length = keys.length; - var pairs = Array(length); - for (var i = 0; i < length; i++) { - pairs[i] = [ keys[i], obj[keys[i]] ]; + function arrayMap(array, iteratee) { + var index = -1, length = array.length, result = Array(length); + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; } - return pairs; - }; - _.invert = function(obj) { - var result = {}; - var keys = _.keys(obj); - for (var i = 0, length = keys.length; i < length; i++) { - result[obj[keys[i]]] = keys[i]; + function arrayPush(array, values) { + var index = -1, length = values.length, offset = array.length; + while (++index < length) { + array[offset + index] = values[index]; + } + return array; } - return result; - }; - _.functions = _.methods = function(obj) { - var names = []; - for (var key in obj) { - if (_.isFunction(obj[key])) names.push(key); + function arrayReduce(array, iteratee, accumulator, initFromArray) { + var index = -1, length = array.length; + if (initFromArray && length) { + accumulator = array[++index]; + } + while (++index < length) { + accumulator = iteratee(accumulator, array[index], index, array); + } + return accumulator; } - return names.sort(); - }; - _.extend = createAssigner(_.allKeys); - _.extendOwn = _.assign = createAssigner(_.keys); - _.findKey = function(obj, predicate, context) { - predicate = cb(predicate, context); - var keys = _.keys(obj), key; - for (var i = 0, length = keys.length; i < length; i++) { - key = keys[i]; - if (predicate(obj[key], key, obj)) return key; + function arrayReduceRight(array, iteratee, accumulator, initFromArray) { + var length = array.length; + if (initFromArray && length) { + accumulator = array[--length]; + } + while (length--) { + accumulator = iteratee(accumulator, array[length], length, array); + } + return accumulator; } - }; - _.pick = function(object, oiteratee, context) { - var result = {}, obj = object, iteratee, keys; - if (obj == null) return result; - if (_.isFunction(oiteratee)) { - keys = _.allKeys(obj); - iteratee = optimizeCb(oiteratee, context); - } else { - keys = flatten(arguments, false, false, 1); - iteratee = function(value, key, obj) { - return key in obj; - }; - obj = Object(obj); + function arraySome(array, predicate) { + var index = -1, length = array.length; + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; } - for (var i = 0, length = keys.length; i < length; i++) { - var key = keys[i]; - var value = obj[key]; - if (iteratee(value, key, obj)) result[key] = value; + function arraySum(array, iteratee) { + var length = array.length, result = 0; + while (length--) { + result += +iteratee(array[length]) || 0; + } + return result; } - return result; - }; - _.omit = function(obj, iteratee, context) { - if (_.isFunction(iteratee)) { - iteratee = _.negate(iteratee); - } else { - var keys = _.map(flatten(arguments, false, false, 1), String); - iteratee = function(value, key) { - return !_.contains(keys, key); - }; + function assignDefaults(objectValue, sourceValue) { + return objectValue === undefined ? sourceValue : objectValue; } - return _.pick(obj, iteratee, context); - }; - _.defaults = createAssigner(_.allKeys, true); - _.create = function(prototype, props) { - var result = baseCreate(prototype); - if (props) _.extendOwn(result, props); - return result; - }; - _.clone = function(obj) { - if (!_.isObject(obj)) return obj; - return _.isArray(obj) ? obj.slice() : _.extend({}, obj); - }; - _.tap = function(obj, interceptor) { - interceptor(obj); - return obj; - }; - _.isMatch = function(object, attrs) { - var keys = _.keys(attrs), length = keys.length; - if (object == null) return !length; - var obj = Object(object); - for (var i = 0; i < length; i++) { - var key = keys[i]; - if (attrs[key] !== obj[key] || !(key in obj)) return false; + function assignOwnDefaults(objectValue, sourceValue, key, object) { + return objectValue === undefined || !hasOwnProperty.call(object, key) ? sourceValue : objectValue; } - return true; - }; - var eq = function(a, b, aStack, bStack) { - if (a === b) return a !== 0 || 1 / a === 1 / b; - if (a == null || b == null) return a === b; - if (a instanceof _) a = a._wrapped; - if (b instanceof _) b = b._wrapped; - var className = toString.call(a); - if (className !== toString.call(b)) return false; - switch (className) { - case "[object RegExp]": - case "[object String]": - return "" + a === "" + b; - - case "[object Number]": - if (+a !== +a) return +b !== +b; - return +a === 0 ? 1 / +a === 1 / b : +a === +b; - - case "[object Date]": - case "[object Boolean]": - return +a === +b; - } - var areArrays = className === "[object Array]"; - if (!areArrays) { - if (typeof a != "object" || typeof b != "object") return false; - var aCtor = a.constructor, bCtor = b.constructor; - if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor && _.isFunction(bCtor) && bCtor instanceof bCtor) && ("constructor" in a && "constructor" in b)) { - return false; + function assignWith(object, source, customizer) { + var index = -1, props = keys(source), length = props.length; + while (++index < length) { + var key = props[index], value = object[key], result = customizer(value, source[key], key, object, source); + if ((result === result ? result !== value : value === value) || value === undefined && !(key in object)) { + object[key] = result; + } } + return object; } - aStack = aStack || []; - bStack = bStack || []; - var length = aStack.length; - while (length--) { - if (aStack[length] === a) return bStack[length] === b; + function baseAssign(object, source) { + return source == null ? object : baseCopy(source, keys(source), object); } - aStack.push(a); - bStack.push(b); - if (areArrays) { - length = a.length; - if (length !== b.length) return false; - while (length--) { - if (!eq(a[length], b[length], aStack, bStack)) return false; - } - } else { - var keys = _.keys(a), key; - length = keys.length; - if (_.keys(b).length !== length) return false; - while (length--) { - key = keys[length]; - if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false; + function baseAt(collection, props) { + var index = -1, isNil = collection == null, isArr = !isNil && isArrayLike(collection), length = isArr ? collection.length : 0, propsLength = props.length, result = Array(propsLength); + while (++index < propsLength) { + var key = props[index]; + if (isArr) { + result[index] = isIndex(key, length) ? collection[key] : undefined; + } else { + result[index] = isNil ? undefined : collection[key]; + } } + return result; } - aStack.pop(); - bStack.pop(); - return true; - }; - _.isEqual = function(a, b) { - return eq(a, b); - }; - _.isEmpty = function(obj) { - if (obj == null) return true; - if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0; - return _.keys(obj).length === 0; - }; - _.isElement = function(obj) { - return !!(obj && obj.nodeType === 1); - }; - _.isArray = nativeIsArray || function(obj) { - return toString.call(obj) === "[object Array]"; - }; - _.isObject = function(obj) { - var type = typeof obj; - return type === "function" || type === "object" && !!obj; - }; - _.each([ "Arguments", "Function", "String", "Number", "Date", "RegExp", "Error" ], function(name) { - _["is" + name] = function(obj) { - return toString.call(obj) === "[object " + name + "]"; - }; - }); - if (!_.isArguments(arguments)) { - _.isArguments = function(obj) { - return _.has(obj, "callee"); - }; - } - if (typeof /./ != "function" && typeof Int8Array != "object") { - _.isFunction = function(obj) { - return typeof obj == "function" || false; - }; - } - _.isFinite = function(obj) { - return isFinite(obj) && !isNaN(parseFloat(obj)); - }; - _.isNaN = function(obj) { - return _.isNumber(obj) && obj !== +obj; - }; - _.isBoolean = function(obj) { - return obj === true || obj === false || toString.call(obj) === "[object Boolean]"; - }; - _.isNull = function(obj) { - return obj === null; - }; - _.isUndefined = function(obj) { - return obj === void 0; - }; - _.has = function(obj, key) { - return obj != null && hasOwnProperty.call(obj, key); - }; - _.noConflict = function() { - root._ = previousUnderscore; - return this; - }; - _.identity = function(value) { - return value; - }; - _.constant = function(value) { - return function() { - return value; - }; - }; - _.noop = function() {}; - _.property = property; - _.propertyOf = function(obj) { - return obj == null ? function() {} : function(key) { - return obj[key]; - }; - }; - _.matcher = _.matches = function(attrs) { - attrs = _.extendOwn({}, attrs); - return function(obj) { - return _.isMatch(obj, attrs); - }; - }; - _.times = function(n, iteratee, context) { - var accum = Array(Math.max(0, n)); - iteratee = optimizeCb(iteratee, context, 1); - for (var i = 0; i < n; i++) accum[i] = iteratee(i); - return accum; - }; - _.random = function(min, max) { - if (max == null) { - max = min; - min = 0; + function baseCopy(source, props, object) { + object || (object = {}); + var index = -1, length = props.length; + while (++index < length) { + var key = props[index]; + object[key] = source[key]; + } + return object; } - return min + Math.floor(Math.random() * (max - min + 1)); - }; - _.now = Date.now || function() { - return new Date().getTime(); - }; - var escapeMap = { - "&": "&", - "<": "<", - ">": ">", - '"': """, - "'": "'", - "`": "`" - }; - var unescapeMap = _.invert(escapeMap); - var createEscaper = function(map) { - var escaper = function(match) { - return map[match]; - }; - var source = "(?:" + _.keys(map).join("|") + ")"; - var testRegexp = RegExp(source); - var replaceRegexp = RegExp(source, "g"); - return function(string) { - string = string == null ? "" : "" + string; - return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; - }; - }; - _.escape = createEscaper(escapeMap); - _.unescape = createEscaper(unescapeMap); - _.result = function(object, property, fallback) { - var value = object == null ? void 0 : object[property]; - if (value === void 0) { - value = fallback; - } - return _.isFunction(value) ? value.call(object) : value; - }; - var idCounter = 0; - _.uniqueId = function(prefix) { - var id = ++idCounter + ""; - return prefix ? prefix + id : id; - }; - _.templateSettings = { - evaluate: /<%([\s\S]+?)%>/g, - interpolate: /<%=([\s\S]+?)%>/g, - escape: /<%-([\s\S]+?)%>/g - }; - var noMatch = /(.)^/; - var escapes = { - "'": "'", - "\\": "\\", - "\r": "r", - "\n": "n", - "\u2028": "u2028", - "\u2029": "u2029" - }; - var escaper = /\\|'|\r|\n|\u2028|\u2029/g; - var escapeChar = function(match) { - return "\\" + escapes[match]; - }; - _.template = function(text, settings, oldSettings) { - if (!settings && oldSettings) settings = oldSettings; - settings = _.defaults({}, settings, _.templateSettings); - var matcher = RegExp([ (settings.escape || noMatch).source, (settings.interpolate || noMatch).source, (settings.evaluate || noMatch).source ].join("|") + "|$", "g"); - var index = 0; - var source = "__p+='"; - text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { - source += text.slice(index, offset).replace(escaper, escapeChar); - index = offset + match.length; - if (escape) { - source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; - } else if (interpolate) { - source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; - } else if (evaluate) { - source += "';\n" + evaluate + "\n__p+='"; - } - return match; - }); - source += "';\n"; - if (!settings.variable) source = "with(obj||{}){\n" + source + "}\n"; - source = "var __t,__p='',__j=Array.prototype.join," + "print=function(){__p+=__j.call(arguments,'');};\n" + source + "return __p;\n"; - try { - var render = new Function(settings.variable || "obj", "_", source); - } catch (e) { - e.source = source; - throw e; + function baseCallback(func, thisArg, argCount) { + var type = typeof func; + if (type == "function") { + return thisArg === undefined ? func : bindCallback(func, thisArg, argCount); + } + if (func == null) { + return identity; + } + if (type == "object") { + return baseMatches(func); + } + return thisArg === undefined ? property(func) : baseMatchesProperty(func, thisArg); } - var template = function(data) { - return render.call(this, data, _); - }; - var argument = settings.variable || "obj"; - template.source = "function(" + argument + "){\n" + source + "}"; - return template; - }; - _.chain = function(obj) { - var instance = _(obj); - instance._chain = true; - return instance; - }; - var result = function(instance, obj) { - return instance._chain ? _(obj).chain() : obj; - }; - _.mixin = function(obj) { - _.each(_.functions(obj), function(name) { - var func = _[name] = obj[name]; - _.prototype[name] = function() { - var args = [ this._wrapped ]; - push.apply(args, arguments); - return result(this, func.apply(_, args)); - }; - }); - }; - _.mixin(_); - _.each([ "pop", "push", "reverse", "shift", "sort", "splice", "unshift" ], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - var obj = this._wrapped; - method.apply(obj, arguments); - if ((name === "shift" || name === "splice") && obj.length === 0) delete obj[0]; - return result(this, obj); - }; - }); - _.each([ "concat", "join", "slice" ], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - return result(this, method.apply(this._wrapped, arguments)); - }; - }); - _.prototype.value = function() { - return this._wrapped; - }; - _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; - _.prototype.toString = function() { - return "" + this._wrapped; - }; - if (typeof define === "function" && define.amd) { - define("underscore", [], function() { - return _; - }); - } -}).call(this); - -(function(window, document, undefined) { - "use strict"; - function minErr(module, ErrorConstructor) { - ErrorConstructor = ErrorConstructor || Error; - return function() { - var SKIP_INDEXES = 2; - var templateArgs = arguments, code = templateArgs[0], message = "[" + (module ? module + ":" : "") + code + "] ", template = templateArgs[1], paramPrefix, i; - message += template.replace(/\{\d+\}/g, function(match) { - var index = +match.slice(1, -1), shiftedIndex = index + SKIP_INDEXES; - if (shiftedIndex < templateArgs.length) { - return toDebugString(templateArgs[shiftedIndex]); + function baseClone(value, isDeep, customizer, key, object, stackA, stackB) { + var result; + if (customizer) { + result = object ? customizer(value, key, object) : customizer(value); + } + if (result !== undefined) { + return result; + } + if (!isObject(value)) { + return value; + } + var isArr = isArray(value); + if (isArr) { + result = initCloneArray(value); + if (!isDeep) { + return arrayCopy(value, result); + } + } else { + var tag = objToString.call(value), isFunc = tag == funcTag; + if (tag == objectTag || tag == argsTag || isFunc && !object) { + result = initCloneObject(isFunc ? {} : value); + if (!isDeep) { + return baseAssign(result, value); + } + } else { + return cloneableTags[tag] ? initCloneByTag(value, tag, isDeep) : object ? value : {}; } - return match; - }); - message += "\nhttp://errors.angularjs.org/1.4.6/" + (module ? module + "/" : "") + code; - for (i = SKIP_INDEXES, paramPrefix = "?"; i < templateArgs.length; i++, paramPrefix = "&") { - message += paramPrefix + "p" + (i - SKIP_INDEXES) + "=" + encodeURIComponent(toDebugString(templateArgs[i])); } - return new ErrorConstructor(message); - }; - } - var REGEX_STRING_REGEXP = /^\/(.+)\/([a-z]*)$/; - var VALIDITY_STATE_PROPERTY = "validity"; - var lowercase = function(string) { - return isString(string) ? string.toLowerCase() : string; - }; - var hasOwnProperty = Object.prototype.hasOwnProperty; - var uppercase = function(string) { - return isString(string) ? string.toUpperCase() : string; - }; - var manualLowercase = function(s) { - return isString(s) ? s.replace(/[A-Z]/g, function(ch) { - return String.fromCharCode(ch.charCodeAt(0) | 32); - }) : s; - }; - var manualUppercase = function(s) { - return isString(s) ? s.replace(/[a-z]/g, function(ch) { - return String.fromCharCode(ch.charCodeAt(0) & ~32); - }) : s; - }; - if ("i" !== "I".toLowerCase()) { - lowercase = manualLowercase; - uppercase = manualUppercase; - } - var msie, jqLite, jQuery, slice = [].slice, splice = [].splice, push = [].push, toString = Object.prototype.toString, getPrototypeOf = Object.getPrototypeOf, ngMinErr = minErr("ng"), angular = window.angular || (window.angular = {}), angularModule, uid = 0; - msie = document.documentMode; - function isArrayLike(obj) { - if (obj == null || isWindow(obj)) { - return false; + stackA || (stackA = []); + stackB || (stackB = []); + var length = stackA.length; + while (length--) { + if (stackA[length] == value) { + return stackB[length]; + } + } + stackA.push(value); + stackB.push(result); + (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { + result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB); + }); + return result; } - var length = "length" in Object(obj) && obj.length; - if (obj.nodeType === NODE_TYPE_ELEMENT && length) { - return true; + var baseCreate = function() { + function object() {} + return function(prototype) { + if (isObject(prototype)) { + object.prototype = prototype; + var result = new object(); + object.prototype = undefined; + } + return result || {}; + }; + }(); + function baseDelay(func, wait, args) { + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + return setTimeout(function() { + func.apply(undefined, args); + }, wait); } - return isString(obj) || isArray(obj) || length === 0 || typeof length === "number" && length > 0 && length - 1 in obj; - } - function forEach(obj, iterator, context) { - var key, length; - if (obj) { - if (isFunction(obj)) { - for (key in obj) { - if (key != "prototype" && key != "length" && key != "name" && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) { - iterator.call(context, obj[key], key, obj); + function baseDifference(array, values) { + var length = array ? array.length : 0, result = []; + if (!length) { + return result; + } + var index = -1, indexOf = getIndexOf(), isCommon = indexOf === baseIndexOf, cache = isCommon && values.length >= LARGE_ARRAY_SIZE ? createCache(values) : null, valuesLength = values.length; + if (cache) { + indexOf = cacheIndexOf; + isCommon = false; + values = cache; + } + outer: while (++index < length) { + var value = array[index]; + if (isCommon && value === value) { + var valuesIndex = valuesLength; + while (valuesIndex--) { + if (values[valuesIndex] === value) { + continue outer; + } } + result.push(value); + } else if (indexOf(values, value, 0) < 0) { + result.push(value); } - } else if (isArray(obj) || isArrayLike(obj)) { - var isPrimitive = typeof obj !== "object"; - for (key = 0, length = obj.length; key < length; key++) { - if (isPrimitive || key in obj) { - iterator.call(context, obj[key], key, obj); - } + } + return result; + } + var baseEach = createBaseEach(baseForOwn); + var baseEachRight = createBaseEach(baseForOwnRight, true); + function baseEvery(collection, predicate) { + var result = true; + baseEach(collection, function(value, index, collection) { + result = !!predicate(value, index, collection); + return result; + }); + return result; + } + function baseExtremum(collection, iteratee, comparator, exValue) { + var computed = exValue, result = computed; + baseEach(collection, function(value, index, collection) { + var current = +iteratee(value, index, collection); + if (comparator(current, computed) || current === exValue && current === result) { + computed = current; + result = value; } - } else if (obj.forEach && obj.forEach !== forEach) { - obj.forEach(iterator, context, obj); - } else if (isBlankObject(obj)) { - for (key in obj) { - iterator.call(context, obj[key], key, obj); + }); + return result; + } + function baseFill(array, value, start, end) { + var length = array.length; + start = start == null ? 0 : +start || 0; + if (start < 0) { + start = -start > length ? 0 : length + start; + } + end = end === undefined || end > length ? length : +end || 0; + if (end < 0) { + end += length; + } + length = start > end ? 0 : end >>> 0; + start >>>= 0; + while (start < length) { + array[start++] = value; + } + return array; + } + function baseFilter(collection, predicate) { + var result = []; + baseEach(collection, function(value, index, collection) { + if (predicate(value, index, collection)) { + result.push(value); } - } else if (typeof obj.hasOwnProperty === "function") { - for (key in obj) { - if (obj.hasOwnProperty(key)) { - iterator.call(context, obj[key], key, obj); - } + }); + return result; + } + function baseFind(collection, predicate, eachFunc, retKey) { + var result; + eachFunc(collection, function(value, key, collection) { + if (predicate(value, key, collection)) { + result = retKey ? key : value; + return false; } - } else { - for (key in obj) { - if (hasOwnProperty.call(obj, key)) { - iterator.call(context, obj[key], key, obj); + }); + return result; + } + function baseFlatten(array, isDeep, isStrict, result) { + result || (result = []); + var index = -1, length = array.length; + while (++index < length) { + var value = array[index]; + if (isObjectLike(value) && isArrayLike(value) && (isStrict || isArray(value) || isArguments(value))) { + if (isDeep) { + baseFlatten(value, isDeep, isStrict, result); + } else { + arrayPush(result, value); } + } else if (!isStrict) { + result[result.length] = value; } } + return result; } - return obj; - } - function forEachSorted(obj, iterator, context) { - var keys = Object.keys(obj).sort(); - for (var i = 0; i < keys.length; i++) { - iterator.call(context, obj[keys[i]], keys[i]); + var baseFor = createBaseFor(); + var baseForRight = createBaseFor(true); + function baseForIn(object, iteratee) { + return baseFor(object, iteratee, keysIn); } - return keys; - } - function reverseParams(iteratorFn) { - return function(value, key) { - iteratorFn(key, value); - }; - } - function nextUid() { - return ++uid; - } - function setHashKey(obj, h) { - if (h) { - obj.$$hashKey = h; - } else { - delete obj.$$hashKey; + function baseForOwn(object, iteratee) { + return baseFor(object, iteratee, keys); } - } - function baseExtend(dst, objs, deep) { - var h = dst.$$hashKey; - for (var i = 0, ii = objs.length; i < ii; ++i) { - var obj = objs[i]; - if (!isObject(obj) && !isFunction(obj)) continue; - var keys = Object.keys(obj); - for (var j = 0, jj = keys.length; j < jj; j++) { - var key = keys[j]; - var src = obj[key]; - if (deep && isObject(src)) { - if (isDate(src)) { - dst[key] = new Date(src.valueOf()); - } else if (isRegExp(src)) { - dst[key] = new RegExp(src); - } else { - if (!isObject(dst[key])) dst[key] = isArray(src) ? [] : {}; - baseExtend(dst[key], [ src ], true); - } - } else { - dst[key] = src; + function baseForOwnRight(object, iteratee) { + return baseForRight(object, iteratee, keys); + } + function baseFunctions(object, props) { + var index = -1, length = props.length, resIndex = -1, result = []; + while (++index < length) { + var key = props[index]; + if (isFunction(object[key])) { + result[++resIndex] = key; } } + return result; } - setHashKey(dst, h); - return dst; - } - function extend(dst) { - return baseExtend(dst, slice.call(arguments, 1), false); - } - function merge(dst) { - return baseExtend(dst, slice.call(arguments, 1), true); - } - function toInt(str) { - return parseInt(str, 10); - } - function inherit(parent, extra) { - return extend(Object.create(parent), extra); - } - function noop() {} - noop.$inject = []; - function identity($) { - return $; - } - identity.$inject = []; - function valueFn(value) { - return function() { - return value; - }; - } - function hasCustomToString(obj) { - return isFunction(obj.toString) && obj.toString !== Object.prototype.toString; - } - function isUndefined(value) { - return typeof value === "undefined"; - } - function isDefined(value) { - return typeof value !== "undefined"; - } - function isObject(value) { - return value !== null && typeof value === "object"; - } - function isBlankObject(value) { - return value !== null && typeof value === "object" && !getPrototypeOf(value); - } - function isString(value) { - return typeof value === "string"; - } - function isNumber(value) { - return typeof value === "number"; - } - function isDate(value) { - return toString.call(value) === "[object Date]"; - } - var isArray = Array.isArray; - function isFunction(value) { - return typeof value === "function"; - } - function isRegExp(value) { - return toString.call(value) === "[object RegExp]"; - } - function isWindow(obj) { - return obj && obj.window === obj; - } - function isScope(obj) { - return obj && obj.$evalAsync && obj.$watch; - } - function isFile(obj) { - return toString.call(obj) === "[object File]"; - } - function isFormData(obj) { - return toString.call(obj) === "[object FormData]"; - } - function isBlob(obj) { - return toString.call(obj) === "[object Blob]"; - } - function isBoolean(value) { - return typeof value === "boolean"; - } - function isPromiseLike(obj) { - return obj && isFunction(obj.then); - } - var TYPED_ARRAY_REGEXP = /^\[object (Uint8(Clamped)?)|(Uint16)|(Uint32)|(Int8)|(Int16)|(Int32)|(Float(32)|(64))Array\]$/; - function isTypedArray(value) { - return TYPED_ARRAY_REGEXP.test(toString.call(value)); - } - var trim = function(value) { - return isString(value) ? value.trim() : value; - }; - var escapeForRegexp = function(s) { - return s.replace(/([-()\[\]{}+?*.$\^|,:#= 0) { - array.splice(index, 1); - } - return index; - } - function copy(source, destination, stackSource, stackDest) { - if (isWindow(source) || isScope(source)) { - throw ngMinErr("cpws", "Can't copy! Making copies of Window or Scope instances is not supported."); + function baseGet(object, path, pathKey) { + if (object == null) { + return; + } + if (pathKey !== undefined && pathKey in toObject(object)) { + path = [ pathKey ]; + } + var index = 0, length = path.length; + while (object != null && index < length) { + object = object[path[index++]]; + } + return index && index == length ? object : undefined; } - if (isTypedArray(destination)) { - throw ngMinErr("cpta", "Can't copy! TypedArray destination cannot be mutated."); + function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) { + if (value === other) { + return true; + } + if (value == null || other == null || !isObject(value) && !isObjectLike(other)) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB); } - if (!destination) { - destination = source; - if (isObject(source)) { - var index; - if (stackSource && (index = stackSource.indexOf(source)) !== -1) { - return stackDest[index]; + function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) { + var objIsArr = isArray(object), othIsArr = isArray(other), objTag = arrayTag, othTag = arrayTag; + if (!objIsArr) { + objTag = objToString.call(object); + if (objTag == argsTag) { + objTag = objectTag; + } else if (objTag != objectTag) { + objIsArr = isTypedArray(object); } - if (isArray(source)) { - return copy(source, [], stackSource, stackDest); - } else if (isTypedArray(source)) { - destination = new source.constructor(source); - } else if (isDate(source)) { - destination = new Date(source.getTime()); - } else if (isRegExp(source)) { - destination = new RegExp(source.source, source.toString().match(/[^\/]*$/)[0]); - destination.lastIndex = source.lastIndex; - } else if (isFunction(source.cloneNode)) { - destination = source.cloneNode(true); - } else { - var emptyObject = Object.create(getPrototypeOf(source)); - return copy(source, emptyObject, stackSource, stackDest); + } + if (!othIsArr) { + othTag = objToString.call(other); + if (othTag == argsTag) { + othTag = objectTag; + } else if (othTag != objectTag) { + othIsArr = isTypedArray(other); } - if (stackDest) { - stackSource.push(source); - stackDest.push(destination); + } + var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag; + if (isSameTag && !(objIsArr || objIsObj)) { + return equalByTag(object, other, objTag); + } + if (!isLoose) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__"); + if (objIsWrapped || othIsWrapped) { + return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB); } } - } else { - if (source === destination) throw ngMinErr("cpi", "Can't copy! Source and destination are identical."); - stackSource = stackSource || []; - stackDest = stackDest || []; - if (isObject(source)) { - stackSource.push(source); - stackDest.push(destination); + if (!isSameTag) { + return false; } - var result, key; - if (isArray(source)) { - destination.length = 0; - for (var i = 0; i < source.length; i++) { - destination.push(copy(source[i], null, stackSource, stackDest)); + stackA || (stackA = []); + stackB || (stackB = []); + var length = stackA.length; + while (length--) { + if (stackA[length] == object) { + return stackB[length] == other; } - } else { - var h = destination.$$hashKey; - if (isArray(destination)) { - destination.length = 0; - } else { - forEach(destination, function(value, key) { - delete destination[key]; - }); + } + stackA.push(object); + stackB.push(other); + var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB); + stackA.pop(); + stackB.pop(); + return result; + } + function baseIsMatch(object, matchData, customizer) { + var index = matchData.length, length = index, noCustomizer = !customizer; + if (object == null) { + return !length; + } + object = toObject(object); + while (index--) { + var data = matchData[index]; + if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) { + return false; } - if (isBlankObject(source)) { - for (key in source) { - destination[key] = copy(source[key], null, stackSource, stackDest); - } - } else if (source && typeof source.hasOwnProperty === "function") { - for (key in source) { - if (source.hasOwnProperty(key)) { - destination[key] = copy(source[key], null, stackSource, stackDest); - } + } + while (++index < length) { + data = matchData[index]; + var key = data[0], objValue = object[key], srcValue = data[1]; + if (noCustomizer && data[2]) { + if (objValue === undefined && !(key in object)) { + return false; } } else { - for (key in source) { - if (hasOwnProperty.call(source, key)) { - destination[key] = copy(source[key], null, stackSource, stackDest); - } + var result = customizer ? customizer(objValue, srcValue, key) : undefined; + if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) { + return false; } } - setHashKey(destination, h); } + return true; } - return destination; - } - function shallowCopy(src, dst) { - if (isArray(src)) { - dst = dst || []; - for (var i = 0, ii = src.length; i < ii; i++) { - dst[i] = src[i]; - } - } else if (isObject(src)) { - dst = dst || {}; - for (var key in src) { - if (!(key.charAt(0) === "$" && key.charAt(1) === "$")) { - dst[key] = src[key]; - } + function baseMap(collection, iteratee) { + var index = -1, result = isArrayLike(collection) ? Array(collection.length) : []; + baseEach(collection, function(value, key, collection) { + result[++index] = iteratee(value, key, collection); + }); + return result; + } + function baseMatches(source) { + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + var key = matchData[0][0], value = matchData[0][1]; + return function(object) { + if (object == null) { + return false; + } + return object[key] === value && (value !== undefined || key in toObject(object)); + }; } + return function(object) { + return baseIsMatch(object, matchData); + }; } - return dst || src; - } - function equals(o1, o2) { - if (o1 === o2) return true; - if (o1 === null || o2 === null) return false; - if (o1 !== o1 && o2 !== o2) return true; - var t1 = typeof o1, t2 = typeof o2, length, key, keySet; - if (t1 == t2) { - if (t1 == "object") { - if (isArray(o1)) { - if (!isArray(o2)) return false; - if ((length = o1.length) == o2.length) { - for (key = 0; key < length; key++) { - if (!equals(o1[key], o2[key])) return false; - } - return true; + function baseMatchesProperty(path, srcValue) { + var isArr = isArray(path), isCommon = isKey(path) && isStrictComparable(srcValue), pathKey = path + ""; + path = toPath(path); + return function(object) { + if (object == null) { + return false; + } + var key = pathKey; + object = toObject(object); + if ((isArr || !isCommon) && !(key in object)) { + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + if (object == null) { + return false; } - } else if (isDate(o1)) { - if (!isDate(o2)) return false; - return equals(o1.getTime(), o2.getTime()); - } else if (isRegExp(o1)) { - return isRegExp(o2) ? o1.toString() == o2.toString() : false; + key = last(path); + object = toObject(object); + } + return object[key] === srcValue ? srcValue !== undefined || key in object : baseIsEqual(srcValue, object[key], undefined, true); + }; + } + function baseMerge(object, source, customizer, stackA, stackB) { + if (!isObject(object)) { + return object; + } + var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)), props = isSrcArr ? undefined : keys(source); + arrayEach(props || source, function(srcValue, key) { + if (props) { + key = srcValue; + srcValue = source[key]; + } + if (isObjectLike(srcValue)) { + stackA || (stackA = []); + stackB || (stackB = []); + baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB); } else { - if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2) || isArray(o2) || isDate(o2) || isRegExp(o2)) return false; - keySet = createMap(); - for (key in o1) { - if (key.charAt(0) === "$" || isFunction(o1[key])) continue; - if (!equals(o1[key], o2[key])) return false; - keySet[key] = true; + var value = object[key], result = customizer ? customizer(value, srcValue, key, object, source) : undefined, isCommon = result === undefined; + if (isCommon) { + result = srcValue; } - for (key in o2) { - if (!(key in keySet) && key.charAt(0) !== "$" && isDefined(o2[key]) && !isFunction(o2[key])) return false; + if ((result !== undefined || isSrcArr && !(key in object)) && (isCommon || (result === result ? result !== value : value === value))) { + object[key] = result; } - return true; } + }); + return object; + } + function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) { + var length = stackA.length, srcValue = source[key]; + while (length--) { + if (stackA[length] == srcValue) { + object[key] = stackB[length]; + return; + } + } + var value = object[key], result = customizer ? customizer(value, srcValue, key, object, source) : undefined, isCommon = result === undefined; + if (isCommon) { + result = srcValue; + if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) { + result = isArray(value) ? value : isArrayLike(value) ? arrayCopy(value) : []; + } else if (isPlainObject(srcValue) || isArguments(srcValue)) { + result = isArguments(value) ? toPlainObject(value) : isPlainObject(value) ? value : {}; + } else { + isCommon = false; + } + } + stackA.push(srcValue); + stackB.push(result); + if (isCommon) { + object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB); + } else if (result === result ? result !== value : value === value) { + object[key] = result; } } - return false; - } - var csp = function() { - if (!isDefined(csp.rules)) { - var ngCspElement = document.querySelector("[ng-csp]") || document.querySelector("[data-ng-csp]"); - if (ngCspElement) { - var ngCspAttribute = ngCspElement.getAttribute("ng-csp") || ngCspElement.getAttribute("data-ng-csp"); - csp.rules = { - noUnsafeEval: !ngCspAttribute || ngCspAttribute.indexOf("no-unsafe-eval") !== -1, - noInlineStyle: !ngCspAttribute || ngCspAttribute.indexOf("no-inline-style") !== -1 - }; - } else { - csp.rules = { - noUnsafeEval: noUnsafeEval(), - noInlineStyle: false - }; - } + function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; } - return csp.rules; - function noUnsafeEval() { - try { - new Function(""); - return false; - } catch (e) { - return true; + function basePropertyDeep(path) { + var pathKey = path + ""; + path = toPath(path); + return function(object) { + return baseGet(object, path, pathKey); + }; + } + function basePullAt(array, indexes) { + var length = array ? indexes.length : 0; + while (length--) { + var index = indexes[length]; + if (index != previous && isIndex(index)) { + var previous = index; + splice.call(array, index, 1); + } } + return array; } - }; - var jq = function() { - if (isDefined(jq.name_)) return jq.name_; - var el; - var i, ii = ngAttrPrefixes.length, prefix, name; - for (i = 0; i < ii; ++i) { - prefix = ngAttrPrefixes[i]; - if (el = document.querySelector("[" + prefix.replace(":", "\\:") + "jq]")) { - name = el.getAttribute(prefix + "jq"); - break; + function baseRandom(min, max) { + return min + nativeFloor(nativeRandom() * (max - min + 1)); + } + function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) { + eachFunc(collection, function(value, index, collection) { + accumulator = initFromCollection ? (initFromCollection = false, value) : iteratee(accumulator, value, index, collection); + }); + return accumulator; + } + var baseSetData = !metaMap ? identity : function(func, data) { + metaMap.set(func, data); + return func; + }; + function baseSlice(array, start, end) { + var index = -1, length = array.length; + start = start == null ? 0 : +start || 0; + if (start < 0) { + start = -start > length ? 0 : length + start; + } + end = end === undefined || end > length ? length : +end || 0; + if (end < 0) { + end += length; + } + length = start > end ? 0 : end - start >>> 0; + start >>>= 0; + var result = Array(length); + while (++index < length) { + result[index] = array[index + start]; } + return result; } - return jq.name_ = name; - }; - function concat(array1, array2, index) { - return array1.concat(slice.call(array2, index)); - } - function sliceArgs(args, startIndex) { - return slice.call(args, startIndex || 0); - } - function bind(self, fn) { - var curryArgs = arguments.length > 2 ? sliceArgs(arguments, 2) : []; - if (isFunction(fn) && !(fn instanceof RegExp)) { - return curryArgs.length ? function() { - return arguments.length ? fn.apply(self, concat(curryArgs, arguments, 0)) : fn.apply(self, curryArgs); - } : function() { - return arguments.length ? fn.apply(self, arguments) : fn.call(self); - }; - } else { - return fn; + function baseSome(collection, predicate) { + var result; + baseEach(collection, function(value, index, collection) { + result = predicate(value, index, collection); + return !result; + }); + return !!result; } - } - function toJsonReplacer(key, value) { - var val = value; - if (typeof key === "string" && key.charAt(0) === "$" && key.charAt(1) === "$") { - val = undefined; - } else if (isWindow(value)) { - val = "$WINDOW"; - } else if (value && document === value) { - val = "$DOCUMENT"; - } else if (isScope(value)) { - val = "$SCOPE"; + function baseSortBy(array, comparer) { + var length = array.length; + array.sort(comparer); + while (length--) { + array[length] = array[length].value; + } + return array; } - return val; - } - function toJson(obj, pretty) { - if (typeof obj === "undefined") return undefined; - if (!isNumber(pretty)) { - pretty = pretty ? 2 : null; + function baseSortByOrder(collection, iteratees, orders) { + var callback = getCallback(), index = -1; + iteratees = arrayMap(iteratees, function(iteratee) { + return callback(iteratee); + }); + var result = baseMap(collection, function(value) { + var criteria = arrayMap(iteratees, function(iteratee) { + return iteratee(value); + }); + return { + criteria: criteria, + index: ++index, + value: value + }; + }); + return baseSortBy(result, function(object, other) { + return compareMultiple(object, other, orders); + }); } - return JSON.stringify(obj, toJsonReplacer, pretty); - } - function fromJson(json) { - return isString(json) ? JSON.parse(json) : json; - } - function timezoneToOffset(timezone, fallback) { - var requestedTimezoneOffset = Date.parse("Jan 01, 1970 00:00:00 " + timezone) / 6e4; - return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset; - } - function addDateMinutes(date, minutes) { - date = new Date(date.getTime()); - date.setMinutes(date.getMinutes() + minutes); - return date; - } - function convertTimezoneToLocal(date, timezone, reverse) { - reverse = reverse ? -1 : 1; - var timezoneOffset = timezoneToOffset(timezone, date.getTimezoneOffset()); - return addDateMinutes(date, reverse * (timezoneOffset - date.getTimezoneOffset())); - } - function startingTag(element) { - element = jqLite(element).clone(); - try { - element.empty(); - } catch (e) {} - var elemHtml = jqLite("
").append(element).html(); - try { - return element[0].nodeType === NODE_TYPE_TEXT ? lowercase(elemHtml) : elemHtml.match(/^(<[^>]+>)/)[1].replace(/^<([\w\-]+)/, function(match, nodeName) { - return "<" + lowercase(nodeName); + function baseSum(collection, iteratee) { + var result = 0; + baseEach(collection, function(value, index, collection) { + result += +iteratee(value, index, collection) || 0; }); - } catch (e) { - return lowercase(elemHtml); + return result; } - } - function tryDecodeURIComponent(value) { - try { - return decodeURIComponent(value); - } catch (e) {} - } - function parseKeyValue(keyValue) { - var obj = {}; - forEach((keyValue || "").split("&"), function(keyValue) { - var splitPoint, key, val; - if (keyValue) { - key = keyValue = keyValue.replace(/\+/g, "%20"); - splitPoint = keyValue.indexOf("="); - if (splitPoint !== -1) { - key = keyValue.substring(0, splitPoint); - val = keyValue.substring(splitPoint + 1); + function baseUniq(array, iteratee) { + var index = -1, indexOf = getIndexOf(), length = array.length, isCommon = indexOf === baseIndexOf, isLarge = isCommon && length >= LARGE_ARRAY_SIZE, seen = isLarge ? createCache() : null, result = []; + if (seen) { + indexOf = cacheIndexOf; + isCommon = false; + } else { + isLarge = false; + seen = iteratee ? [] : result; + } + outer: while (++index < length) { + var value = array[index], computed = iteratee ? iteratee(value, index, array) : value; + if (isCommon && value === value) { + var seenIndex = seen.length; + while (seenIndex--) { + if (seen[seenIndex] === computed) { + continue outer; + } + } + if (iteratee) { + seen.push(computed); + } + result.push(value); + } else if (indexOf(seen, computed, 0) < 0) { + if (iteratee || isLarge) { + seen.push(computed); + } + result.push(value); } - key = tryDecodeURIComponent(key); - if (isDefined(key)) { - val = isDefined(val) ? tryDecodeURIComponent(val) : true; - if (!hasOwnProperty.call(obj, key)) { - obj[key] = val; - } else if (isArray(obj[key])) { - obj[key].push(val); + } + return result; + } + function baseValues(object, props) { + var index = -1, length = props.length, result = Array(length); + while (++index < length) { + result[index] = object[props[index]]; + } + return result; + } + function baseWhile(array, predicate, isDrop, fromRight) { + var length = array.length, index = fromRight ? length : -1; + while ((fromRight ? index-- : ++index < length) && predicate(array[index], index, array)) {} + return isDrop ? baseSlice(array, fromRight ? 0 : index, fromRight ? index + 1 : length) : baseSlice(array, fromRight ? index + 1 : 0, fromRight ? length : index); + } + function baseWrapperValue(value, actions) { + var result = value; + if (result instanceof LazyWrapper) { + result = result.value(); + } + var index = -1, length = actions.length; + while (++index < length) { + var action = actions[index]; + result = action.func.apply(action.thisArg, arrayPush([ result ], action.args)); + } + return result; + } + function binaryIndex(array, value, retHighest) { + var low = 0, high = array ? array.length : low; + if (typeof value == "number" && value === value && high <= HALF_MAX_ARRAY_LENGTH) { + while (low < high) { + var mid = low + high >>> 1, computed = array[mid]; + if ((retHighest ? computed <= value : computed < value) && computed !== null) { + low = mid + 1; } else { - obj[key] = [ obj[key], val ]; - } + high = mid; + } + } + return high; + } + return binaryIndexBy(array, value, identity, retHighest); + } + function binaryIndexBy(array, value, iteratee, retHighest) { + value = iteratee(value); + var low = 0, high = array ? array.length : 0, valIsNaN = value !== value, valIsNull = value === null, valIsUndef = value === undefined; + while (low < high) { + var mid = nativeFloor((low + high) / 2), computed = iteratee(array[mid]), isDef = computed !== undefined, isReflexive = computed === computed; + if (valIsNaN) { + var setLow = isReflexive || retHighest; + } else if (valIsNull) { + setLow = isReflexive && isDef && (retHighest || computed != null); + } else if (valIsUndef) { + setLow = isReflexive && (retHighest || isDef); + } else if (computed == null) { + setLow = false; + } else { + setLow = retHighest ? computed <= value : computed < value; + } + if (setLow) { + low = mid + 1; + } else { + high = mid; } } - }); - return obj; - } - function toKeyValue(obj) { - var parts = []; - forEach(obj, function(value, key) { - if (isArray(value)) { - forEach(value, function(arrayValue) { - parts.push(encodeUriQuery(key, true) + (arrayValue === true ? "" : "=" + encodeUriQuery(arrayValue, true))); - }); - } else { - parts.push(encodeUriQuery(key, true) + (value === true ? "" : "=" + encodeUriQuery(value, true))); + return nativeMin(high, MAX_ARRAY_INDEX); + } + function bindCallback(func, thisArg, argCount) { + if (typeof func != "function") { + return identity; } - }); - return parts.length ? parts.join("&") : ""; - } - function encodeUriSegment(val) { - return encodeUriQuery(val, true).replace(/%26/gi, "&").replace(/%3D/gi, "=").replace(/%2B/gi, "+"); - } - function encodeUriQuery(val, pctEncodeSpaces) { - return encodeURIComponent(val).replace(/%40/gi, "@").replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%3B/gi, ";").replace(/%20/g, pctEncodeSpaces ? "%20" : "+"); - } - var ngAttrPrefixes = [ "ng-", "data-ng-", "ng:", "x-ng-" ]; - function getNgAttribute(element, ngAttr) { - var attr, i, ii = ngAttrPrefixes.length; - for (i = 0; i < ii; ++i) { - attr = ngAttrPrefixes[i] + ngAttr; - if (isString(attr = element.getAttribute(attr))) { - return attr; + if (thisArg === undefined) { + return func; + } + switch (argCount) { + case 1: + return function(value) { + return func.call(thisArg, value); + }; + + case 3: + return function(value, index, collection) { + return func.call(thisArg, value, index, collection); + }; + + case 4: + return function(accumulator, value, index, collection) { + return func.call(thisArg, accumulator, value, index, collection); + }; + + case 5: + return function(value, other, key, object, source) { + return func.call(thisArg, value, other, key, object, source); + }; } + return function() { + return func.apply(thisArg, arguments); + }; } - return null; - } - function angularInit(element, bootstrap) { - var appElement, module, config = {}; - forEach(ngAttrPrefixes, function(prefix) { - var name = prefix + "app"; - if (!appElement && element.hasAttribute && element.hasAttribute(name)) { - appElement = element; - module = element.getAttribute(name); + function bufferClone(buffer) { + var result = new ArrayBuffer(buffer.byteLength), view = new Uint8Array(result); + view.set(new Uint8Array(buffer)); + return result; + } + function composeArgs(args, partials, holders) { + var holdersLength = holders.length, argsIndex = -1, argsLength = nativeMax(args.length - holdersLength, 0), leftIndex = -1, leftLength = partials.length, result = Array(leftLength + argsLength); + while (++leftIndex < leftLength) { + result[leftIndex] = partials[leftIndex]; } - }); - forEach(ngAttrPrefixes, function(prefix) { - var name = prefix + "app"; - var candidate; - if (!appElement && (candidate = element.querySelector("[" + name.replace(":", "\\:") + "]"))) { - appElement = candidate; - module = candidate.getAttribute(name); + while (++argsIndex < holdersLength) { + result[holders[argsIndex]] = args[argsIndex]; } - }); - if (appElement) { - config.strictDi = getNgAttribute(appElement, "strict-di") !== null; - bootstrap(appElement, module ? [ module ] : [], config); + while (argsLength--) { + result[leftIndex++] = args[argsIndex++]; + } + return result; } - } - function bootstrap(element, modules, config) { - if (!isObject(config)) config = {}; - var defaultConfig = { - strictDi: false - }; - config = extend(defaultConfig, config); - var doBootstrap = function() { - element = jqLite(element); - if (element.injector()) { - var tag = element[0] === document ? "document" : startingTag(element); - throw ngMinErr("btstrpd", "App Already Bootstrapped with this Element '{0}'", tag.replace(//, ">")); + function composeArgsRight(args, partials, holders) { + var holdersIndex = -1, holdersLength = holders.length, argsIndex = -1, argsLength = nativeMax(args.length - holdersLength, 0), rightIndex = -1, rightLength = partials.length, result = Array(argsLength + rightLength); + while (++argsIndex < argsLength) { + result[argsIndex] = args[argsIndex]; } - modules = modules || []; - modules.unshift([ "$provide", function($provide) { - $provide.value("$rootElement", element); - } ]); - if (config.debugInfoEnabled) { - modules.push([ "$compileProvider", function($compileProvider) { - $compileProvider.debugInfoEnabled(true); - } ]); + var offset = argsIndex; + while (++rightIndex < rightLength) { + result[offset + rightIndex] = partials[rightIndex]; } - modules.unshift("ng"); - var injector = createInjector(modules, config.strictDi); - injector.invoke([ "$rootScope", "$rootElement", "$compile", "$injector", function bootstrapApply(scope, element, compile, injector) { - scope.$apply(function() { - element.data("$injector", injector); - compile(element)(scope); - }); - } ]); - return injector; - }; - var NG_ENABLE_DEBUG_INFO = /^NG_ENABLE_DEBUG_INFO!/; - var NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/; - if (window && NG_ENABLE_DEBUG_INFO.test(window.name)) { - config.debugInfoEnabled = true; - window.name = window.name.replace(NG_ENABLE_DEBUG_INFO, ""); + while (++holdersIndex < holdersLength) { + result[offset + holders[holdersIndex]] = args[argsIndex++]; + } + return result; } - if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) { - return doBootstrap(); + function createAggregator(setter, initializer) { + return function(collection, iteratee, thisArg) { + var result = initializer ? initializer() : {}; + iteratee = getCallback(iteratee, thisArg, 3); + if (isArray(collection)) { + var index = -1, length = collection.length; + while (++index < length) { + var value = collection[index]; + setter(result, value, iteratee(value, index, collection), collection); + } + } else { + baseEach(collection, function(value, key, collection) { + setter(result, value, iteratee(value, key, collection), collection); + }); + } + return result; + }; } - window.name = window.name.replace(NG_DEFER_BOOTSTRAP, ""); - angular.resumeBootstrap = function(extraModules) { - forEach(extraModules, function(module) { - modules.push(module); + function createAssigner(assigner) { + return restParam(function(object, sources) { + var index = -1, length = object == null ? 0 : sources.length, customizer = length > 2 ? sources[length - 2] : undefined, guard = length > 2 ? sources[2] : undefined, thisArg = length > 1 ? sources[length - 1] : undefined; + if (typeof customizer == "function") { + customizer = bindCallback(customizer, thisArg, 5); + length -= 2; + } else { + customizer = typeof thisArg == "function" ? thisArg : undefined; + length -= customizer ? 1 : 0; + } + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + customizer = length < 3 ? undefined : customizer; + length = 1; + } + while (++index < length) { + var source = sources[index]; + if (source) { + assigner(object, source, customizer); + } + } + return object; }); - return doBootstrap(); - }; - if (isFunction(angular.resumeDeferredBootstrap)) { - angular.resumeDeferredBootstrap(); - } - } - function reloadWithDebugInfo() { - window.name = "NG_ENABLE_DEBUG_INFO!" + window.name; - window.location.reload(); - } - function getTestability(rootElement) { - var injector = angular.element(rootElement).injector(); - if (!injector) { - throw ngMinErr("test", "no injector found for element argument to getTestability"); - } - return injector.get("$$testability"); - } - var SNAKE_CASE_REGEXP = /[A-Z]/g; - function snake_case(name, separator) { - separator = separator || "_"; - return name.replace(SNAKE_CASE_REGEXP, function(letter, pos) { - return (pos ? separator : "") + letter.toLowerCase(); - }); - } - var bindJQueryFired = false; - var skipDestroyOnNextJQueryCleanData; - function bindJQuery() { - var originalCleanData; - if (bindJQueryFired) { - return; } - var jqName = jq(); - jQuery = isUndefined(jqName) ? window.jQuery : !jqName ? undefined : window[jqName]; - if (jQuery && jQuery.fn.on) { - jqLite = jQuery; - extend(jQuery.fn, { - scope: JQLitePrototype.scope, - isolateScope: JQLitePrototype.isolateScope, - controller: JQLitePrototype.controller, - injector: JQLitePrototype.injector, - inheritedData: JQLitePrototype.inheritedData - }); - originalCleanData = jQuery.cleanData; - jQuery.cleanData = function(elems) { - var events; - if (!skipDestroyOnNextJQueryCleanData) { - for (var i = 0, elem; (elem = elems[i]) != null; i++) { - events = jQuery._data(elem, "events"); - if (events && events.$destroy) { - jQuery(elem).triggerHandler("$destroy"); - } + function createBaseEach(eachFunc, fromRight) { + return function(collection, iteratee) { + var length = collection ? getLength(collection) : 0; + if (!isLength(length)) { + return eachFunc(collection, iteratee); + } + var index = fromRight ? length : -1, iterable = toObject(collection); + while (fromRight ? index-- : ++index < length) { + if (iteratee(iterable[index], index, iterable) === false) { + break; } - } else { - skipDestroyOnNextJQueryCleanData = false; } - originalCleanData(elems); + return collection; }; - } else { - jqLite = JQLite; } - angular.element = jqLite; - bindJQueryFired = true; - } - function assertArg(arg, name, reason) { - if (!arg) { - throw ngMinErr("areq", "Argument '{0}' is {1}", name || "?", reason || "required"); + function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var iterable = toObject(object), props = keysFunc(object), length = props.length, index = fromRight ? length : -1; + while (fromRight ? index-- : ++index < length) { + var key = props[index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } + } + return object; + }; } - return arg; - } - function assertArgFn(arg, name, acceptArrayAnnotation) { - if (acceptArrayAnnotation && isArray(arg)) { - arg = arg[arg.length - 1]; + function createBindWrapper(func, thisArg) { + var Ctor = createCtorWrapper(func); + function wrapper() { + var fn = this && this !== root && this instanceof wrapper ? Ctor : func; + return fn.apply(thisArg, arguments); + } + return wrapper; } - assertArg(isFunction(arg), name, "not a function, got " + (arg && typeof arg === "object" ? arg.constructor.name || "Object" : typeof arg)); - return arg; - } - function assertNotHasOwnProperty(name, context) { - if (name === "hasOwnProperty") { - throw ngMinErr("badname", "hasOwnProperty is not a valid {0} name", context); + function createCache(values) { + return nativeCreate && Set ? new SetCache(values) : null; } - } - function getter(obj, path, bindFnToScope) { - if (!path) return obj; - var keys = path.split("."); - var key; - var lastInstance = obj; - var len = keys.length; - for (var i = 0; i < len; i++) { - key = keys[i]; - if (obj) { - obj = (lastInstance = obj)[key]; - } + function createCompounder(callback) { + return function(string) { + var index = -1, array = words(deburr(string)), length = array.length, result = ""; + while (++index < length) { + result = callback(result, array[index], index); + } + return result; + }; } - if (!bindFnToScope && isFunction(obj)) { - return bind(lastInstance, obj); + function createCtorWrapper(Ctor) { + return function() { + var args = arguments; + switch (args.length) { + case 0: + return new Ctor(); + + case 1: + return new Ctor(args[0]); + + case 2: + return new Ctor(args[0], args[1]); + + case 3: + return new Ctor(args[0], args[1], args[2]); + + case 4: + return new Ctor(args[0], args[1], args[2], args[3]); + + case 5: + return new Ctor(args[0], args[1], args[2], args[3], args[4]); + + case 6: + return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); + + case 7: + return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + } + var thisBinding = baseCreate(Ctor.prototype), result = Ctor.apply(thisBinding, args); + return isObject(result) ? result : thisBinding; + }; } - return obj; - } - function getBlockNodes(nodes) { - var node = nodes[0]; - var endNode = nodes[nodes.length - 1]; - var blockNodes; - for (var i = 1; node !== endNode && (node = node.nextSibling); i++) { - if (blockNodes || nodes[i] !== node) { - if (!blockNodes) { - blockNodes = jqLite(slice.call(nodes, 0, i)); + function createCurry(flag) { + function curryFunc(func, arity, guard) { + if (guard && isIterateeCall(func, arity, guard)) { + arity = undefined; } - blockNodes.push(node); + var result = createWrapper(func, flag, undefined, undefined, undefined, undefined, undefined, arity); + result.placeholder = curryFunc.placeholder; + return result; } + return curryFunc; } - return blockNodes || nodes; - } - function createMap() { - return Object.create(null); - } - var NODE_TYPE_ELEMENT = 1; - var NODE_TYPE_ATTRIBUTE = 2; - var NODE_TYPE_TEXT = 3; - var NODE_TYPE_COMMENT = 8; - var NODE_TYPE_DOCUMENT = 9; - var NODE_TYPE_DOCUMENT_FRAGMENT = 11; - function setupModuleLoader(window) { - var $injectorMinErr = minErr("$injector"); - var ngMinErr = minErr("ng"); - function ensure(obj, name, factory) { - return obj[name] || (obj[name] = factory()); + function createDefaults(assigner, customizer) { + return restParam(function(args) { + var object = args[0]; + if (object == null) { + return object; + } + args.push(customizer); + return assigner.apply(undefined, args); + }); } - var angular = ensure(window, "angular", Object); - angular.$$minErr = angular.$$minErr || minErr; - return ensure(angular, "module", function() { - var modules = {}; - return function module(name, requires, configFn) { - var assertNotHasOwnProperty = function(name, context) { - if (name === "hasOwnProperty") { - throw ngMinErr("badname", "hasOwnProperty is not a valid {0} name", context); - } - }; - assertNotHasOwnProperty(name, "module"); - if (requires && modules.hasOwnProperty(name)) { - modules[name] = null; + function createExtremum(comparator, exValue) { + return function(collection, iteratee, thisArg) { + if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { + iteratee = undefined; } - return ensure(modules, name, function() { - if (!requires) { - throw $injectorMinErr("nomod", "Module '{0}' is not available! You either misspelled " + "the module name or forgot to load it. If registering a module ensure that you " + "specify the dependencies as the second argument.", name); + iteratee = getCallback(iteratee, thisArg, 3); + if (iteratee.length == 1) { + collection = isArray(collection) ? collection : toIterable(collection); + var result = arrayExtremum(collection, iteratee, comparator, exValue); + if (!(collection.length && result === exValue)) { + return result; } - var invokeQueue = []; - var configBlocks = []; - var runBlocks = []; - var config = invokeLater("$injector", "invoke", "push", configBlocks); - var moduleInstance = { - _invokeQueue: invokeQueue, - _configBlocks: configBlocks, - _runBlocks: runBlocks, - requires: requires, - name: name, - provider: invokeLaterAndSetModuleName("$provide", "provider"), - factory: invokeLaterAndSetModuleName("$provide", "factory"), - service: invokeLaterAndSetModuleName("$provide", "service"), - value: invokeLater("$provide", "value"), - constant: invokeLater("$provide", "constant", "unshift"), - decorator: invokeLaterAndSetModuleName("$provide", "decorator"), - animation: invokeLaterAndSetModuleName("$animateProvider", "register"), - filter: invokeLaterAndSetModuleName("$filterProvider", "register"), - controller: invokeLaterAndSetModuleName("$controllerProvider", "register"), - directive: invokeLaterAndSetModuleName("$compileProvider", "directive"), - config: config, - run: function(block) { - runBlocks.push(block); - return this; - } - }; - if (configFn) { - config(configFn); + } + return baseExtremum(collection, iteratee, comparator, exValue); + }; + } + function createFind(eachFunc, fromRight) { + return function(collection, predicate, thisArg) { + predicate = getCallback(predicate, thisArg, 3); + if (isArray(collection)) { + var index = baseFindIndex(collection, predicate, fromRight); + return index > -1 ? collection[index] : undefined; + } + return baseFind(collection, predicate, eachFunc); + }; + } + function createFindIndex(fromRight) { + return function(array, predicate, thisArg) { + if (!(array && array.length)) { + return -1; + } + predicate = getCallback(predicate, thisArg, 3); + return baseFindIndex(array, predicate, fromRight); + }; + } + function createFindKey(objectFunc) { + return function(object, predicate, thisArg) { + predicate = getCallback(predicate, thisArg, 3); + return baseFind(object, predicate, objectFunc, true); + }; + } + function createFlow(fromRight) { + return function() { + var wrapper, length = arguments.length, index = fromRight ? length : -1, leftIndex = 0, funcs = Array(length); + while (fromRight ? index-- : ++index < length) { + var func = funcs[leftIndex++] = arguments[index]; + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == "wrapper") { + wrapper = new LodashWrapper([], true); + } + } + index = wrapper ? -1 : length; + while (++index < length) { + func = funcs[index]; + var funcName = getFuncName(func), data = funcName == "wrapper" ? getData(func) : undefined; + if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) { + wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); + } else { + wrapper = func.length == 1 && isLaziable(func) ? wrapper[funcName]() : wrapper.thru(func); } - return moduleInstance; - function invokeLater(provider, method, insertMethod, queue) { - if (!queue) queue = invokeQueue; - return function() { - queue[insertMethod || "push"]([ provider, method, arguments ]); - return moduleInstance; - }; + } + return function() { + var args = arguments, value = args[0]; + if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) { + return wrapper.plant(value).value(); } - function invokeLaterAndSetModuleName(provider, method) { - return function(recipeName, factoryFunction) { - if (factoryFunction && isFunction(factoryFunction)) factoryFunction.$$moduleName = name; - invokeQueue.push([ provider, method, arguments ]); - return moduleInstance; - }; + var index = 0, result = length ? funcs[index].apply(this, args) : value; + while (++index < length) { + result = funcs[index].call(this, result); } + return result; + }; + }; + } + function createForEach(arrayFunc, eachFunc) { + return function(collection, iteratee, thisArg) { + return typeof iteratee == "function" && thisArg === undefined && isArray(collection) ? arrayFunc(collection, iteratee) : eachFunc(collection, bindCallback(iteratee, thisArg, 3)); + }; + } + function createForIn(objectFunc) { + return function(object, iteratee, thisArg) { + if (typeof iteratee != "function" || thisArg !== undefined) { + iteratee = bindCallback(iteratee, thisArg, 3); + } + return objectFunc(object, iteratee, keysIn); + }; + } + function createForOwn(objectFunc) { + return function(object, iteratee, thisArg) { + if (typeof iteratee != "function" || thisArg !== undefined) { + iteratee = bindCallback(iteratee, thisArg, 3); + } + return objectFunc(object, iteratee); + }; + } + function createObjectMapper(isMapKeys) { + return function(object, iteratee, thisArg) { + var result = {}; + iteratee = getCallback(iteratee, thisArg, 3); + baseForOwn(object, function(value, key, object) { + var mapped = iteratee(value, key, object); + key = isMapKeys ? mapped : key; + value = isMapKeys ? value : mapped; + result[key] = value; }); + return result; }; - }); - } - function serializeObject(obj) { - var seen = []; - return JSON.stringify(obj, function(key, val) { - val = toJsonReplacer(key, val); - if (isObject(val)) { - if (seen.indexOf(val) >= 0) return "..."; - seen.push(val); - } - return val; - }); - } - function toDebugString(obj) { - if (typeof obj === "function") { - return obj.toString().replace(/ \{[\s\S]*$/, ""); - } else if (isUndefined(obj)) { - return "undefined"; - } else if (typeof obj !== "string") { - return serializeObject(obj); } - return obj; - } - var version = { - full: "1.4.6", - major: 1, - minor: 4, - dot: 6, - codeName: "multiplicative-elevation" - }; - function publishExternalAPI(angular) { - extend(angular, { - bootstrap: bootstrap, - copy: copy, - extend: extend, - merge: merge, - equals: equals, - element: jqLite, - forEach: forEach, - injector: createInjector, - noop: noop, - bind: bind, - toJson: toJson, - fromJson: fromJson, - identity: identity, - isUndefined: isUndefined, - isDefined: isDefined, - isString: isString, - isFunction: isFunction, - isObject: isObject, - isNumber: isNumber, - isElement: isElement, - isArray: isArray, - version: version, - isDate: isDate, - lowercase: lowercase, - uppercase: uppercase, - callbacks: { - counter: 0 - }, - getTestability: getTestability, - $$minErr: minErr, - $$csp: csp, - reloadWithDebugInfo: reloadWithDebugInfo - }); - angularModule = setupModuleLoader(window); - angularModule("ng", [ "ngLocale" ], [ "$provide", function ngModule($provide) { - $provide.provider({ - $$sanitizeUri: $$SanitizeUriProvider - }); - $provide.provider("$compile", $CompileProvider).directive({ - a: htmlAnchorDirective, - input: inputDirective, - textarea: inputDirective, - form: formDirective, - script: scriptDirective, - select: selectDirective, - style: styleDirective, - option: optionDirective, - ngBind: ngBindDirective, - ngBindHtml: ngBindHtmlDirective, - ngBindTemplate: ngBindTemplateDirective, - ngClass: ngClassDirective, - ngClassEven: ngClassEvenDirective, - ngClassOdd: ngClassOddDirective, - ngCloak: ngCloakDirective, - ngController: ngControllerDirective, - ngForm: ngFormDirective, - ngHide: ngHideDirective, - ngIf: ngIfDirective, - ngInclude: ngIncludeDirective, - ngInit: ngInitDirective, - ngNonBindable: ngNonBindableDirective, - ngPluralize: ngPluralizeDirective, - ngRepeat: ngRepeatDirective, - ngShow: ngShowDirective, - ngStyle: ngStyleDirective, - ngSwitch: ngSwitchDirective, - ngSwitchWhen: ngSwitchWhenDirective, - ngSwitchDefault: ngSwitchDefaultDirective, - ngOptions: ngOptionsDirective, - ngTransclude: ngTranscludeDirective, - ngModel: ngModelDirective, - ngList: ngListDirective, - ngChange: ngChangeDirective, - pattern: patternDirective, - ngPattern: patternDirective, - required: requiredDirective, - ngRequired: requiredDirective, - minlength: minlengthDirective, - ngMinlength: minlengthDirective, - maxlength: maxlengthDirective, - ngMaxlength: maxlengthDirective, - ngValue: ngValueDirective, - ngModelOptions: ngModelOptionsDirective - }).directive({ - ngInclude: ngIncludeFillContentDirective - }).directive(ngAttributeAliasDirectives).directive(ngEventDirectives); - $provide.provider({ - $anchorScroll: $AnchorScrollProvider, - $animate: $AnimateProvider, - $animateCss: $CoreAnimateCssProvider, - $$animateQueue: $$CoreAnimateQueueProvider, - $$AnimateRunner: $$CoreAnimateRunnerProvider, - $browser: $BrowserProvider, - $cacheFactory: $CacheFactoryProvider, - $controller: $ControllerProvider, - $document: $DocumentProvider, - $exceptionHandler: $ExceptionHandlerProvider, - $filter: $FilterProvider, - $$forceReflow: $$ForceReflowProvider, - $interpolate: $InterpolateProvider, - $interval: $IntervalProvider, - $http: $HttpProvider, - $httpParamSerializer: $HttpParamSerializerProvider, - $httpParamSerializerJQLike: $HttpParamSerializerJQLikeProvider, - $httpBackend: $HttpBackendProvider, - $location: $LocationProvider, - $log: $LogProvider, - $parse: $ParseProvider, - $rootScope: $RootScopeProvider, - $q: $QProvider, - $$q: $$QProvider, - $sce: $SceProvider, - $sceDelegate: $SceDelegateProvider, - $sniffer: $SnifferProvider, - $templateCache: $TemplateCacheProvider, - $templateRequest: $TemplateRequestProvider, - $$testability: $$TestabilityProvider, - $timeout: $TimeoutProvider, - $window: $WindowProvider, - $$rAF: $$RAFProvider, - $$jqLite: $$jqLiteProvider, - $$HashMap: $$HashMapProvider, - $$cookieReader: $$CookieReaderProvider + function createPadDir(fromRight) { + return function(string, length, chars) { + string = baseToString(string); + return (fromRight ? string : "") + createPadding(string, length, chars) + (fromRight ? "" : string); + }; + } + function createPartial(flag) { + var partialFunc = restParam(function(func, partials) { + var holders = replaceHolders(partials, partialFunc.placeholder); + return createWrapper(func, flag, undefined, partials, holders); }); - } ]); - } - JQLite.expando = "ng339"; - var jqCache = JQLite.cache = {}, jqId = 1, addEventListenerFn = function(element, type, fn) { - element.addEventListener(type, fn, false); - }, removeEventListenerFn = function(element, type, fn) { - element.removeEventListener(type, fn, false); - }; - JQLite._data = function(node) { - return this.cache[node[this.expando]] || {}; - }; - function jqNextId() { - return ++jqId; - } - var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g; - var MOZ_HACK_REGEXP = /^moz([A-Z])/; - var MOUSE_EVENT_MAP = { - mouseleave: "mouseout", - mouseenter: "mouseover" - }; - var jqLiteMinErr = minErr("jqLite"); - function camelCase(name) { - return name.replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) { - return offset ? letter.toUpperCase() : letter; - }).replace(MOZ_HACK_REGEXP, "Moz$1"); - } - var SINGLE_TAG_REGEXP = /^<(\w+)\s*\/?>(?:<\/\1>|)$/; - var HTML_REGEXP = /<|&#?\w+;/; - var TAG_NAME_REGEXP = /<([\w:]+)/; - var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi; - var wrapMap = { - option: [ 1, '" ], - thead: [ 1, "", "
" ], - col: [ 2, "", "
" ], - tr: [ 2, "", "
" ], - td: [ 3, "", "
" ], - _default: [ 0, "", "" ] - }; - wrapMap.optgroup = wrapMap.option; - wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; - wrapMap.th = wrapMap.td; - function jqLiteIsTextNode(html) { - return !HTML_REGEXP.test(html); - } - function jqLiteAcceptsData(node) { - var nodeType = node.nodeType; - return nodeType === NODE_TYPE_ELEMENT || !nodeType || nodeType === NODE_TYPE_DOCUMENT; - } - function jqLiteHasData(node) { - for (var key in jqCache[node.ng339]) { - return true; + return partialFunc; } - return false; - } - function jqLiteBuildFragment(html, context) { - var tmp, tag, wrap, fragment = context.createDocumentFragment(), nodes = [], i; - if (jqLiteIsTextNode(html)) { - nodes.push(context.createTextNode(html)); - } else { - tmp = tmp || fragment.appendChild(context.createElement("div")); - tag = (TAG_NAME_REGEXP.exec(html) || [ "", "" ])[1].toLowerCase(); - wrap = wrapMap[tag] || wrapMap._default; - tmp.innerHTML = wrap[1] + html.replace(XHTML_TAG_REGEXP, "<$1>") + wrap[2]; - i = wrap[0]; - while (i--) { - tmp = tmp.lastChild; + function createReduce(arrayFunc, eachFunc) { + return function(collection, iteratee, accumulator, thisArg) { + var initFromArray = arguments.length < 3; + return typeof iteratee == "function" && thisArg === undefined && isArray(collection) ? arrayFunc(collection, iteratee, accumulator, initFromArray) : baseReduce(collection, getCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc); + }; + } + function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { + var isAry = bitmask & ARY_FLAG, isBind = bitmask & BIND_FLAG, isBindKey = bitmask & BIND_KEY_FLAG, isCurry = bitmask & CURRY_FLAG, isCurryBound = bitmask & CURRY_BOUND_FLAG, isCurryRight = bitmask & CURRY_RIGHT_FLAG, Ctor = isBindKey ? undefined : createCtorWrapper(func); + function wrapper() { + var length = arguments.length, index = length, args = Array(length); + while (index--) { + args[index] = arguments[index]; + } + if (partials) { + args = composeArgs(args, partials, holders); + } + if (partialsRight) { + args = composeArgsRight(args, partialsRight, holdersRight); + } + if (isCurry || isCurryRight) { + var placeholder = wrapper.placeholder, argsHolders = replaceHolders(args, placeholder); + length -= argsHolders.length; + if (length < arity) { + var newArgPos = argPos ? arrayCopy(argPos) : undefined, newArity = nativeMax(arity - length, 0), newsHolders = isCurry ? argsHolders : undefined, newHoldersRight = isCurry ? undefined : argsHolders, newPartials = isCurry ? args : undefined, newPartialsRight = isCurry ? undefined : args; + bitmask |= isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG; + bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG); + if (!isCurryBound) { + bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); + } + var newData = [ func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity ], result = createHybridWrapper.apply(undefined, newData); + if (isLaziable(func)) { + setData(result, newData); + } + result.placeholder = placeholder; + return result; + } + } + var thisBinding = isBind ? thisArg : this, fn = isBindKey ? thisBinding[func] : func; + if (argPos) { + args = reorder(args, argPos); + } + if (isAry && ary < args.length) { + args.length = ary; + } + if (this && this !== root && this instanceof wrapper) { + fn = Ctor || createCtorWrapper(func); + } + return fn.apply(thisBinding, args); } - nodes = concat(nodes, tmp.childNodes); - tmp = fragment.firstChild; - tmp.textContent = ""; + return wrapper; } - fragment.textContent = ""; - fragment.innerHTML = ""; - forEach(nodes, function(node) { - fragment.appendChild(node); - }); - return fragment; - } - function jqLiteParseHTML(html, context) { - context = context || document; - var parsed; - if (parsed = SINGLE_TAG_REGEXP.exec(html)) { - return [ context.createElement(parsed[1]) ]; + function createPadding(string, length, chars) { + var strLength = string.length; + length = +length; + if (strLength >= length || !nativeIsFinite(length)) { + return ""; + } + var padLength = length - strLength; + chars = chars == null ? " " : chars + ""; + return repeat(chars, nativeCeil(padLength / chars.length)).slice(0, padLength); } - if (parsed = jqLiteBuildFragment(html, context)) { - return parsed.childNodes; + function createPartialWrapper(func, bitmask, thisArg, partials) { + var isBind = bitmask & BIND_FLAG, Ctor = createCtorWrapper(func); + function wrapper() { + var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array(leftLength + argsLength); + while (++leftIndex < leftLength) { + args[leftIndex] = partials[leftIndex]; + } + while (argsLength--) { + args[leftIndex++] = arguments[++argsIndex]; + } + var fn = this && this !== root && this instanceof wrapper ? Ctor : func; + return fn.apply(isBind ? thisArg : this, args); + } + return wrapper; } - return []; - } - function JQLite(element) { - if (element instanceof JQLite) { - return element; + function createRound(methodName) { + var func = Math[methodName]; + return function(number, precision) { + precision = precision === undefined ? 0 : +precision || 0; + if (precision) { + precision = pow(10, precision); + return func(number * precision) / precision; + } + return func(number); + }; } - var argIsString; - if (isString(element)) { - element = trim(element); - argIsString = true; + function createSortedIndex(retHighest) { + return function(array, value, iteratee, thisArg) { + var callback = getCallback(iteratee); + return iteratee == null && callback === baseCallback ? binaryIndex(array, value, retHighest) : binaryIndexBy(array, value, callback(iteratee, thisArg, 1), retHighest); + }; } - if (!(this instanceof JQLite)) { - if (argIsString && element.charAt(0) != "<") { - throw jqLiteMinErr("nosel", "Looking up elements via selectors is not supported by jqLite! See: http://docs.angularjs.org/api/angular.element"); + function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { + var isBindKey = bitmask & BIND_KEY_FLAG; + if (!isBindKey && typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); } - return new JQLite(element); + var length = partials ? partials.length : 0; + if (!length) { + bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG); + partials = holders = undefined; + } + length -= holders ? holders.length : 0; + if (bitmask & PARTIAL_RIGHT_FLAG) { + var partialsRight = partials, holdersRight = holders; + partials = holders = undefined; + } + var data = isBindKey ? undefined : getData(func), newData = [ func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity ]; + if (data) { + mergeData(newData, data); + bitmask = newData[1]; + arity = newData[9]; + } + newData[9] = arity == null ? isBindKey ? 0 : func.length : nativeMax(arity - length, 0) || 0; + if (bitmask == BIND_FLAG) { + var result = createBindWrapper(newData[0], newData[2]); + } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) { + result = createPartialWrapper.apply(undefined, newData); + } else { + result = createHybridWrapper.apply(undefined, newData); + } + var setter = data ? baseSetData : setData; + return setter(result, newData); } - if (argIsString) { - jqLiteAddNodes(this, jqLiteParseHTML(element)); - } else { - jqLiteAddNodes(this, element); + function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) { + var index = -1, arrLength = array.length, othLength = other.length; + if (arrLength != othLength && !(isLoose && othLength > arrLength)) { + return false; + } + while (++index < arrLength) { + var arrValue = array[index], othValue = other[index], result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined; + if (result !== undefined) { + if (result) { + continue; + } + return false; + } + if (isLoose) { + if (!arraySome(other, function(othValue) { + return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); + })) { + return false; + } + } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) { + return false; + } + } + return true; } - } - function jqLiteClone(element) { - return element.cloneNode(true); - } - function jqLiteDealoc(element, onlyDescendants) { - if (!onlyDescendants) jqLiteRemoveData(element); - if (element.querySelectorAll) { - var descendants = element.querySelectorAll("*"); - for (var i = 0, l = descendants.length; i < l; i++) { - jqLiteRemoveData(descendants[i]); + function equalByTag(object, other, tag) { + switch (tag) { + case boolTag: + case dateTag: + return +object == +other; + + case errorTag: + return object.name == other.name && object.message == other.message; + + case numberTag: + return object != +object ? other != +other : object == +other; + + case regexpTag: + case stringTag: + return object == other + ""; } + return false; } - } - function jqLiteOff(element, type, fn, unsupported) { - if (isDefined(unsupported)) throw jqLiteMinErr("offargs", "jqLite#off() does not support the `selector` argument"); - var expandoStore = jqLiteExpandoStore(element); - var events = expandoStore && expandoStore.events; - var handle = expandoStore && expandoStore.handle; - if (!handle) return; - if (!type) { - for (type in events) { - if (type !== "$destroy") { - removeEventListenerFn(element, type, handle); + function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) { + var objProps = keys(object), objLength = objProps.length, othProps = keys(other), othLength = othProps.length; + if (objLength != othLength && !isLoose) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) { + return false; } - delete events[type]; } - } else { - forEach(type.split(" "), function(type) { - if (isDefined(fn)) { - var listenerFns = events[type]; - arrayRemove(listenerFns || [], fn); - if (listenerFns && listenerFns.length > 0) { - return; - } + var skipCtor = isLoose; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], othValue = other[key], result = customizer ? customizer(isLoose ? othValue : objValue, isLoose ? objValue : othValue, key) : undefined; + if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) { + return false; } - removeEventListenerFn(element, type, handle); - delete events[type]; - }); - } - } - function jqLiteRemoveData(element, name) { - var expandoId = element.ng339; - var expandoStore = expandoId && jqCache[expandoId]; - if (expandoStore) { - if (name) { - delete expandoStore.data[name]; - return; + skipCtor || (skipCtor = key == "constructor"); } - if (expandoStore.handle) { - if (expandoStore.events.$destroy) { - expandoStore.handle({}, "$destroy"); + if (!skipCtor) { + var objCtor = object.constructor, othCtor = other.constructor; + if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) { + return false; } - jqLiteOff(element); } - delete jqCache[expandoId]; - element.ng339 = undefined; + return true; } - } - function jqLiteExpandoStore(element, createIfNecessary) { - var expandoId = element.ng339, expandoStore = expandoId && jqCache[expandoId]; - if (createIfNecessary && !expandoStore) { - element.ng339 = expandoId = jqNextId(); - expandoStore = jqCache[expandoId] = { - events: {}, - data: {}, - handle: undefined - }; + function getCallback(func, thisArg, argCount) { + var result = lodash.callback || callback; + result = result === callback ? baseCallback : result; + return argCount ? result(func, thisArg, argCount) : result; } - return expandoStore; - } - function jqLiteData(element, key, value) { - if (jqLiteAcceptsData(element)) { - var isSimpleSetter = isDefined(value); - var isSimpleGetter = !isSimpleSetter && key && !isObject(key); - var massGetter = !key; - var expandoStore = jqLiteExpandoStore(element, !isSimpleGetter); - var data = expandoStore && expandoStore.data; - if (isSimpleSetter) { - data[key] = value; - } else { - if (massGetter) { - return data; - } else { - if (isSimpleGetter) { - return data && data[key]; - } else { - extend(data, key); - } + var getData = !metaMap ? noop : function(func) { + return metaMap.get(func); + }; + function getFuncName(func) { + var result = func.name + "", array = realNames[result], length = array ? array.length : 0; + while (length--) { + var data = array[length], otherFunc = data.func; + if (otherFunc == null || otherFunc == func) { + return data.name; } } + return result; } - } - function jqLiteHasClass(element, selector) { - if (!element.getAttribute) return false; - return (" " + (element.getAttribute("class") || "") + " ").replace(/[\n\t]/g, " ").indexOf(" " + selector + " ") > -1; - } - function jqLiteRemoveClass(element, cssClasses) { - if (cssClasses && element.setAttribute) { - forEach(cssClasses.split(" "), function(cssClass) { - element.setAttribute("class", trim((" " + (element.getAttribute("class") || "") + " ").replace(/[\n\t]/g, " ").replace(" " + trim(cssClass) + " ", " "))); - }); + function getIndexOf(collection, target, fromIndex) { + var result = lodash.indexOf || indexOf; + result = result === indexOf ? baseIndexOf : result; + return collection ? result(collection, target, fromIndex) : result; } - } - function jqLiteAddClass(element, cssClasses) { - if (cssClasses && element.setAttribute) { - var existingClasses = (" " + (element.getAttribute("class") || "") + " ").replace(/[\n\t]/g, " "); - forEach(cssClasses.split(" "), function(cssClass) { - cssClass = trim(cssClass); - if (existingClasses.indexOf(" " + cssClass + " ") === -1) { - existingClasses += cssClass + " "; + var getLength = baseProperty("length"); + function getMatchData(object) { + var result = pairs(object), length = result.length; + while (length--) { + result[length][2] = isStrictComparable(result[length][1]); + } + return result; + } + function getNative(object, key) { + var value = object == null ? undefined : object[key]; + return isNative(value) ? value : undefined; + } + function getView(start, end, transforms) { + var index = -1, length = transforms.length; + while (++index < length) { + var data = transforms[index], size = data.size; + switch (data.type) { + case "drop": + start += size; + break; + + case "dropRight": + end -= size; + break; + + case "take": + end = nativeMin(end, start + size); + break; + + case "takeRight": + start = nativeMax(start, end - size); + break; + } + } + return { + start: start, + end: end + }; + } + function initCloneArray(array) { + var length = array.length, result = new array.constructor(length); + if (length && typeof array[0] == "string" && hasOwnProperty.call(array, "index")) { + result.index = array.index; + result.input = array.input; + } + return result; + } + function initCloneObject(object) { + var Ctor = object.constructor; + if (!(typeof Ctor == "function" && Ctor instanceof Ctor)) { + Ctor = Object; + } + return new Ctor(); + } + function initCloneByTag(object, tag, isDeep) { + var Ctor = object.constructor; + switch (tag) { + case arrayBufferTag: + return bufferClone(object); + + case boolTag: + case dateTag: + return new Ctor(+object); + + case float32Tag: + case float64Tag: + case int8Tag: + case int16Tag: + case int32Tag: + case uint8Tag: + case uint8ClampedTag: + case uint16Tag: + case uint32Tag: + var buffer = object.buffer; + return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length); + + case numberTag: + case stringTag: + return new Ctor(object); + + case regexpTag: + var result = new Ctor(object.source, reFlags.exec(object)); + result.lastIndex = object.lastIndex; + } + return result; + } + function invokePath(object, path, args) { + if (object != null && !isKey(path, object)) { + path = toPath(path); + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + path = last(path); + } + var func = object == null ? object : object[path]; + return func == null ? undefined : func.apply(object, args); + } + function isArrayLike(value) { + return value != null && isLength(getLength(value)); + } + function isIndex(value, length) { + value = typeof value == "number" || reIsUint.test(value) ? +value : -1; + length = length == null ? MAX_SAFE_INTEGER : length; + return value > -1 && value % 1 == 0 && value < length; + } + function isIterateeCall(value, index, object) { + if (!isObject(object)) { + return false; + } + var type = typeof index; + if (type == "number" ? isArrayLike(object) && isIndex(index, object.length) : type == "string" && index in object) { + var other = object[index]; + return value === value ? value === other : other !== other; + } + return false; + } + function isKey(value, object) { + var type = typeof value; + if (type == "string" && reIsPlainProp.test(value) || type == "number") { + return true; + } + if (isArray(value)) { + return false; + } + var result = !reIsDeepProp.test(value); + return result || object != null && value in toObject(object); + } + function isLaziable(func) { + var funcName = getFuncName(func), other = lodash[funcName]; + if (typeof other != "function" || !(funcName in LazyWrapper.prototype)) { + return false; + } + if (func === other) { + return true; + } + var data = getData(other); + return !!data && func === data[0]; + } + function isLength(value) { + return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; + } + function isStrictComparable(value) { + return value === value && !isObject(value); + } + function mergeData(data, source) { + var bitmask = data[1], srcBitmask = source[1], newBitmask = bitmask | srcBitmask, isCommon = newBitmask < ARY_FLAG; + var isCombo = srcBitmask == ARY_FLAG && bitmask == CURRY_FLAG || srcBitmask == ARY_FLAG && bitmask == REARG_FLAG && data[7].length <= source[8] || srcBitmask == (ARY_FLAG | REARG_FLAG) && bitmask == CURRY_FLAG; + if (!(isCommon || isCombo)) { + return data; + } + if (srcBitmask & BIND_FLAG) { + data[2] = source[2]; + newBitmask |= bitmask & BIND_FLAG ? 0 : CURRY_BOUND_FLAG; + } + var value = source[3]; + if (value) { + var partials = data[3]; + data[3] = partials ? composeArgs(partials, value, source[4]) : arrayCopy(value); + data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : arrayCopy(source[4]); + } + value = source[5]; + if (value) { + partials = data[5]; + data[5] = partials ? composeArgsRight(partials, value, source[6]) : arrayCopy(value); + data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : arrayCopy(source[6]); + } + value = source[7]; + if (value) { + data[7] = arrayCopy(value); + } + if (srcBitmask & ARY_FLAG) { + data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); + } + if (data[9] == null) { + data[9] = source[9]; + } + data[0] = source[0]; + data[1] = newBitmask; + return data; + } + function mergeDefaults(objectValue, sourceValue) { + return objectValue === undefined ? sourceValue : merge(objectValue, sourceValue, mergeDefaults); + } + function pickByArray(object, props) { + object = toObject(object); + var index = -1, length = props.length, result = {}; + while (++index < length) { + var key = props[index]; + if (key in object) { + result[key] = object[key]; + } + } + return result; + } + function pickByCallback(object, predicate) { + var result = {}; + baseForIn(object, function(value, key, object) { + if (predicate(value, key, object)) { + result[key] = value; } }); - element.setAttribute("class", trim(existingClasses)); + return result; } - } - function jqLiteAddNodes(root, elements) { - if (elements) { - if (elements.nodeType) { - root[root.length++] = elements; - } else { - var length = elements.length; - if (typeof length === "number" && elements.window !== elements) { - if (length) { - for (var i = 0; i < length; i++) { - root[root.length++] = elements[i]; - } + function reorder(array, indexes) { + var arrLength = array.length, length = nativeMin(indexes.length, arrLength), oldArray = arrayCopy(array); + while (length--) { + var index = indexes[length]; + array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; + } + return array; + } + var setData = function() { + var count = 0, lastCalled = 0; + return function(key, value) { + var stamp = now(), remaining = HOT_SPAN - (stamp - lastCalled); + lastCalled = stamp; + if (remaining > 0) { + if (++count >= HOT_COUNT) { + return key; } } else { - root[root.length++] = elements; + count = 0; + } + return baseSetData(key, value); + }; + }(); + function shimKeys(object) { + var props = keysIn(object), propsLength = props.length, length = propsLength && object.length; + var allowIndexes = !!length && isLength(length) && (isArray(object) || isArguments(object)); + var index = -1, result = []; + while (++index < propsLength) { + var key = props[index]; + if (allowIndexes && isIndex(key, length) || hasOwnProperty.call(object, key)) { + result.push(key); } } + return result; } - } - function jqLiteController(element, name) { - return jqLiteInheritedData(element, "$" + (name || "ngController") + "Controller"); - } - function jqLiteInheritedData(element, name, value) { - if (element.nodeType == NODE_TYPE_DOCUMENT) { - element = element.documentElement; + function toIterable(value) { + if (value == null) { + return []; + } + if (!isArrayLike(value)) { + return values(value); + } + return isObject(value) ? value : Object(value); } - var names = isArray(name) ? name : [ name ]; - while (element) { - for (var i = 0, ii = names.length; i < ii; i++) { - if (isDefined(value = jqLite.data(element, names[i]))) return value; + function toObject(value) { + return isObject(value) ? value : Object(value); + } + function toPath(value) { + if (isArray(value)) { + return value; } - element = element.parentNode || element.nodeType === NODE_TYPE_DOCUMENT_FRAGMENT && element.host; + var result = []; + baseToString(value).replace(rePropName, function(match, number, quote, string) { + result.push(quote ? string.replace(reEscapeChar, "$1") : number || match); + }); + return result; } - } - function jqLiteEmpty(element) { - jqLiteDealoc(element, true); - while (element.firstChild) { - element.removeChild(element.firstChild); + function wrapperClone(wrapper) { + return wrapper instanceof LazyWrapper ? wrapper.clone() : new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__)); } - } - function jqLiteRemove(element, keepData) { - if (!keepData) jqLiteDealoc(element); - var parent = element.parentNode; - if (parent) parent.removeChild(element); - } - function jqLiteDocumentLoaded(action, win) { - win = win || window; - if (win.document.readyState === "complete") { - win.setTimeout(action); - } else { - jqLite(win).on("load", action); + function chunk(array, size, guard) { + if (guard ? isIterateeCall(array, size, guard) : size == null) { + size = 1; + } else { + size = nativeMax(nativeFloor(size) || 1, 1); + } + var index = 0, length = array ? array.length : 0, resIndex = -1, result = Array(nativeCeil(length / size)); + while (index < length) { + result[++resIndex] = baseSlice(array, index, index += size); + } + return result; } - } - var JQLitePrototype = JQLite.prototype = { - ready: function(fn) { - var fired = false; - function trigger() { - if (fired) return; - fired = true; - fn(); + function compact(array) { + var index = -1, length = array ? array.length : 0, resIndex = -1, result = []; + while (++index < length) { + var value = array[index]; + if (value) { + result[++resIndex] = value; + } } - if (document.readyState === "complete") { - setTimeout(trigger); - } else { - this.on("DOMContentLoaded", trigger); - JQLite(window).on("load", trigger); + return result; + } + var difference = restParam(function(array, values) { + return isObjectLike(array) && isArrayLike(array) ? baseDifference(array, baseFlatten(values, false, true)) : []; + }); + function drop(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; } - }, - toString: function() { - var value = []; - forEach(this, function(e) { - value.push("" + e); - }); - return "[" + value.join(", ") + "]"; - }, - eq: function(index) { - return index >= 0 ? jqLite(this[index]) : jqLite(this[this.length + index]); - }, - length: 0, - push: push, - sort: [].sort, - splice: [].splice - }; - var BOOLEAN_ATTR = {}; - forEach("multiple,selected,checked,disabled,readOnly,required,open".split(","), function(value) { - BOOLEAN_ATTR[lowercase(value)] = value; - }); - var BOOLEAN_ELEMENTS = {}; - forEach("input,select,option,textarea,button,form,details".split(","), function(value) { - BOOLEAN_ELEMENTS[value] = true; - }); - var ALIASED_ATTR = { - ngMinlength: "minlength", - ngMaxlength: "maxlength", - ngMin: "min", - ngMax: "max", - ngPattern: "pattern" - }; - function getBooleanAttrName(element, name) { - var booleanAttr = BOOLEAN_ATTR[name.toLowerCase()]; - return booleanAttr && BOOLEAN_ELEMENTS[nodeName_(element)] && booleanAttr; - } - function getAliasedAttrName(name) { - return ALIASED_ATTR[name]; - } - forEach({ - data: jqLiteData, - removeData: jqLiteRemoveData, - hasData: jqLiteHasData - }, function(fn, name) { - JQLite[name] = fn; - }); - forEach({ - data: jqLiteData, - inheritedData: jqLiteInheritedData, - scope: function(element) { - return jqLite.data(element, "$scope") || jqLiteInheritedData(element.parentNode || element, [ "$isolateScope", "$scope" ]); - }, - isolateScope: function(element) { - return jqLite.data(element, "$isolateScope") || jqLite.data(element, "$isolateScopeNoTemplate"); - }, - controller: jqLiteController, - injector: function(element) { - return jqLiteInheritedData(element, "$injector"); - }, - removeAttr: function(element, name) { - element.removeAttribute(name); - }, - hasClass: jqLiteHasClass, - css: function(element, name, value) { - name = camelCase(name); - if (isDefined(value)) { - element.style[name] = value; - } else { - return element.style[name]; + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; } - }, - attr: function(element, name, value) { - var nodeType = element.nodeType; - if (nodeType === NODE_TYPE_TEXT || nodeType === NODE_TYPE_ATTRIBUTE || nodeType === NODE_TYPE_COMMENT) { - return; + return baseSlice(array, n < 0 ? 0 : n); + } + function dropRight(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; } - var lowercasedName = lowercase(name); - if (BOOLEAN_ATTR[lowercasedName]) { - if (isDefined(value)) { - if (!!value) { - element[name] = true; - element.setAttribute(name, lowercasedName); - } else { - element[name] = false; - element.removeAttribute(lowercasedName); - } - } else { - return element[name] || (element.attributes.getNamedItem(name) || noop).specified ? lowercasedName : undefined; - } - } else if (isDefined(value)) { - element.setAttribute(name, value); - } else if (element.getAttribute) { - var ret = element.getAttribute(name, 2); - return ret === null ? undefined : ret; + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; } - }, - prop: function(element, name, value) { - if (isDefined(value)) { - element[name] = value; - } else { - return element[name]; + n = length - (+n || 0); + return baseSlice(array, 0, n < 0 ? 0 : n); + } + function dropRightWhile(array, predicate, thisArg) { + return array && array.length ? baseWhile(array, getCallback(predicate, thisArg, 3), true, true) : []; + } + function dropWhile(array, predicate, thisArg) { + return array && array.length ? baseWhile(array, getCallback(predicate, thisArg, 3), true) : []; + } + function fill(array, value, start, end) { + var length = array ? array.length : 0; + if (!length) { + return []; } - }, - text: function() { - getText.$dv = ""; - return getText; - function getText(element, value) { - if (isUndefined(value)) { - var nodeType = element.nodeType; - return nodeType === NODE_TYPE_ELEMENT || nodeType === NODE_TYPE_TEXT ? element.textContent : ""; - } - element.textContent = value; + if (start && typeof start != "number" && isIterateeCall(array, value, start)) { + start = 0; + end = length; } - }(), - val: function(element, value) { - if (isUndefined(value)) { - if (element.multiple && nodeName_(element) === "select") { - var result = []; - forEach(element.options, function(option) { - if (option.selected) { - result.push(option.value || option.text); - } - }); - return result.length === 0 ? null : result; + return baseFill(array, value, start, end); + } + var findIndex = createFindIndex(); + var findLastIndex = createFindIndex(true); + function first(array) { + return array ? array[0] : undefined; + } + function flatten(array, isDeep, guard) { + var length = array ? array.length : 0; + if (guard && isIterateeCall(array, isDeep, guard)) { + isDeep = false; + } + return length ? baseFlatten(array, isDeep) : []; + } + function flattenDeep(array) { + var length = array ? array.length : 0; + return length ? baseFlatten(array, true) : []; + } + function indexOf(array, value, fromIndex) { + var length = array ? array.length : 0; + if (!length) { + return -1; + } + if (typeof fromIndex == "number") { + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex; + } else if (fromIndex) { + var index = binaryIndex(array, value); + if (index < length && (value === value ? value === array[index] : array[index] !== array[index])) { + return index; } - return element.value; + return -1; } - element.value = value; - }, - html: function(element, value) { - if (isUndefined(value)) { - return element.innerHTML; + return baseIndexOf(array, value, fromIndex || 0); + } + function initial(array) { + return dropRight(array, 1); + } + var intersection = restParam(function(arrays) { + var othLength = arrays.length, othIndex = othLength, caches = Array(length), indexOf = getIndexOf(), isCommon = indexOf === baseIndexOf, result = []; + while (othIndex--) { + var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : []; + caches[othIndex] = isCommon && value.length >= 120 ? createCache(othIndex && value) : null; } - jqLiteDealoc(element, true); - element.innerHTML = value; - }, - empty: jqLiteEmpty - }, function(fn, name) { - JQLite.prototype[name] = function(arg1, arg2) { - var i, key; - var nodeCount = this.length; - if (fn !== jqLiteEmpty && isUndefined(fn.length == 2 && (fn !== jqLiteHasClass && fn !== jqLiteController) ? arg1 : arg2)) { - if (isObject(arg1)) { - for (i = 0; i < nodeCount; i++) { - if (fn === jqLiteData) { - fn(this[i], arg1); - } else { - for (key in arg1) { - fn(this[i], key, arg1[key]); - } + var array = arrays[0], index = -1, length = array ? array.length : 0, seen = caches[0]; + outer: while (++index < length) { + value = array[index]; + if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) { + var othIndex = othLength; + while (--othIndex) { + var cache = caches[othIndex]; + if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) { + continue outer; } } - return this; - } else { - var value = fn.$dv; - var jj = isUndefined(value) ? Math.min(nodeCount, 1) : nodeCount; - for (var j = 0; j < jj; j++) { - var nodeValue = fn(this[j], arg1, arg2); - value = value ? value + nodeValue : nodeValue; + if (seen) { + seen.push(value); } - return value; - } - } else { - for (i = 0; i < nodeCount; i++) { - fn(this[i], arg1, arg2); + result.push(value); } - return this; } - }; - }); - function createEventHandler(element, events) { - var eventHandler = function(event, type) { - event.isDefaultPrevented = function() { - return event.defaultPrevented; - }; - var eventFns = events[type || event.type]; - var eventFnsLength = eventFns ? eventFns.length : 0; - if (!eventFnsLength) return; - if (isUndefined(event.immediatePropagationStopped)) { - var originalStopImmediatePropagation = event.stopImmediatePropagation; - event.stopImmediatePropagation = function() { - event.immediatePropagationStopped = true; - if (event.stopPropagation) { - event.stopPropagation(); - } - if (originalStopImmediatePropagation) { - originalStopImmediatePropagation.call(event); - } - }; + return result; + }); + function last(array) { + var length = array ? array.length : 0; + return length ? array[length - 1] : undefined; + } + function lastIndexOf(array, value, fromIndex) { + var length = array ? array.length : 0; + if (!length) { + return -1; } - event.isImmediatePropagationStopped = function() { - return event.immediatePropagationStopped === true; - }; - if (eventFnsLength > 1) { - eventFns = shallowCopy(eventFns); + var index = length; + if (typeof fromIndex == "number") { + index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1; + } else if (fromIndex) { + index = binaryIndex(array, value, true) - 1; + var other = array[index]; + if (value === value ? value === other : other !== other) { + return index; + } + return -1; } - for (var i = 0; i < eventFnsLength; i++) { - if (!event.isImmediatePropagationStopped()) { - eventFns[i].call(element, event); + if (value !== value) { + return indexOfNaN(array, index, true); + } + while (index--) { + if (array[index] === value) { + return index; } } - }; - eventHandler.elem = element; - return eventHandler; - } - forEach({ - removeData: jqLiteRemoveData, - on: function jqLiteOn(element, type, fn, unsupported) { - if (isDefined(unsupported)) throw jqLiteMinErr("onargs", "jqLite#on() does not support the `selector` or `eventData` parameters"); - if (!jqLiteAcceptsData(element)) { - return; + return -1; + } + function pull() { + var args = arguments, array = args[0]; + if (!(array && array.length)) { + return array; } - var expandoStore = jqLiteExpandoStore(element, true); - var events = expandoStore.events; - var handle = expandoStore.handle; - if (!handle) { - handle = expandoStore.handle = createEventHandler(element, events); + var index = 0, indexOf = getIndexOf(), length = args.length; + while (++index < length) { + var fromIndex = 0, value = args[index]; + while ((fromIndex = indexOf(array, value, fromIndex)) > -1) { + splice.call(array, fromIndex, 1); + } } - var types = type.indexOf(" ") >= 0 ? type.split(" ") : [ type ]; - var i = types.length; - while (i--) { - type = types[i]; - var eventFns = events[type]; - if (!eventFns) { - events[type] = []; - if (type === "mouseenter" || type === "mouseleave") { - jqLiteOn(element, MOUSE_EVENT_MAP[type], function(event) { - var target = this, related = event.relatedTarget; - if (!related || related !== target && !target.contains(related)) { - handle(event, type); - } - }); - } else { - if (type !== "$destroy") { - addEventListenerFn(element, type, handle); - } - } - eventFns = events[type]; - } - eventFns.push(fn); + return array; + } + var pullAt = restParam(function(array, indexes) { + indexes = baseFlatten(indexes); + var result = baseAt(array, indexes); + basePullAt(array, indexes.sort(baseCompareAscending)); + return result; + }); + function remove(array, predicate, thisArg) { + var result = []; + if (!(array && array.length)) { + return result; } - }, - off: jqLiteOff, - one: function(element, type, fn) { - element = jqLite(element); - element.on(type, function onFn() { - element.off(type, fn); - element.off(type, onFn); - }); - element.on(type, fn); - }, - replaceWith: function(element, replaceNode) { - var index, parent = element.parentNode; - jqLiteDealoc(element); - forEach(new JQLite(replaceNode), function(node) { - if (index) { - parent.insertBefore(node, index.nextSibling); - } else { - parent.replaceChild(node, element); - } - index = node; - }); - }, - children: function(element) { - var children = []; - forEach(element.childNodes, function(element) { - if (element.nodeType === NODE_TYPE_ELEMENT) { - children.push(element); + var index = -1, indexes = [], length = array.length; + predicate = getCallback(predicate, thisArg, 3); + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result.push(value); + indexes.push(index); } - }); - return children; - }, - contents: function(element) { - return element.contentDocument || element.childNodes || []; - }, - append: function(element, node) { - var nodeType = element.nodeType; - if (nodeType !== NODE_TYPE_ELEMENT && nodeType !== NODE_TYPE_DOCUMENT_FRAGMENT) return; - node = new JQLite(node); - for (var i = 0, ii = node.length; i < ii; i++) { - var child = node[i]; - element.appendChild(child); } - }, - prepend: function(element, node) { - if (element.nodeType === NODE_TYPE_ELEMENT) { - var index = element.firstChild; - forEach(new JQLite(node), function(child) { - element.insertBefore(child, index); - }); + basePullAt(array, indexes); + return result; + } + function rest(array) { + return drop(array, 1); + } + function slice(array, start, end) { + var length = array ? array.length : 0; + if (!length) { + return []; } - }, - wrap: function(element, wrapNode) { - wrapNode = jqLite(wrapNode).eq(0).clone()[0]; - var parent = element.parentNode; - if (parent) { - parent.replaceChild(wrapNode, element); + if (end && typeof end != "number" && isIterateeCall(array, start, end)) { + start = 0; + end = length; } - wrapNode.appendChild(element); - }, - remove: jqLiteRemove, - detach: function(element) { - jqLiteRemove(element, true); - }, - after: function(element, newElement) { - var index = element, parent = element.parentNode; - newElement = new JQLite(newElement); - for (var i = 0, ii = newElement.length; i < ii; i++) { - var node = newElement[i]; - parent.insertBefore(node, index.nextSibling); - index = node; + return baseSlice(array, start, end); + } + var sortedIndex = createSortedIndex(); + var sortedLastIndex = createSortedIndex(true); + function take(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; } - }, - addClass: jqLiteAddClass, - removeClass: jqLiteRemoveClass, - toggleClass: function(element, selector, condition) { - if (selector) { - forEach(selector.split(" "), function(className) { - var classCondition = condition; - if (isUndefined(classCondition)) { - classCondition = !jqLiteHasClass(element, className); - } - (classCondition ? jqLiteAddClass : jqLiteRemoveClass)(element, className); - }); + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; } - }, - parent: function(element) { - var parent = element.parentNode; - return parent && parent.nodeType !== NODE_TYPE_DOCUMENT_FRAGMENT ? parent : null; - }, - next: function(element) { - return element.nextElementSibling; - }, - find: function(element, selector) { - if (element.getElementsByTagName) { - return element.getElementsByTagName(selector); - } else { + return baseSlice(array, 0, n < 0 ? 0 : n); + } + function takeRight(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { return []; } - }, - clone: jqLiteClone, - triggerHandler: function(element, event, extraParameters) { - var dummyEvent, eventFnsCopy, handlerArgs; - var eventName = event.type || event; - var expandoStore = jqLiteExpandoStore(element); - var events = expandoStore && expandoStore.events; - var eventFns = events && events[eventName]; - if (eventFns) { - dummyEvent = { - preventDefault: function() { - this.defaultPrevented = true; - }, - isDefaultPrevented: function() { - return this.defaultPrevented === true; - }, - stopImmediatePropagation: function() { - this.immediatePropagationStopped = true; - }, - isImmediatePropagationStopped: function() { - return this.immediatePropagationStopped === true; - }, - stopPropagation: noop, - type: eventName, - target: element - }; - if (event.type) { - dummyEvent = extend(dummyEvent, event); - } - eventFnsCopy = shallowCopy(eventFns); - handlerArgs = extraParameters ? [ dummyEvent ].concat(extraParameters) : [ dummyEvent ]; - forEach(eventFnsCopy, function(fn) { - if (!dummyEvent.isImmediatePropagationStopped()) { - fn.apply(element, handlerArgs); - } - }); + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; } + n = length - (+n || 0); + return baseSlice(array, n < 0 ? 0 : n); } - }, function(fn, name) { - JQLite.prototype[name] = function(arg1, arg2, arg3) { - var value; - for (var i = 0, ii = this.length; i < ii; i++) { - if (isUndefined(value)) { - value = fn(this[i], arg1, arg2, arg3); - if (isDefined(value)) { - value = jqLite(value); - } - } else { - jqLiteAddNodes(value, fn(this[i], arg1, arg2, arg3)); - } + function takeRightWhile(array, predicate, thisArg) { + return array && array.length ? baseWhile(array, getCallback(predicate, thisArg, 3), false, true) : []; + } + function takeWhile(array, predicate, thisArg) { + return array && array.length ? baseWhile(array, getCallback(predicate, thisArg, 3)) : []; + } + var union = restParam(function(arrays) { + return baseUniq(baseFlatten(arrays, false, true)); + }); + function uniq(array, isSorted, iteratee, thisArg) { + var length = array ? array.length : 0; + if (!length) { + return []; } - return isDefined(value) ? value : this; - }; - JQLite.prototype.bind = JQLite.prototype.on; - JQLite.prototype.unbind = JQLite.prototype.off; - }); - function $$jqLiteProvider() { - this.$get = function $$jqLite() { - return extend(JQLite, { - hasClass: function(node, classes) { - if (node.attr) node = node[0]; - return jqLiteHasClass(node, classes); - }, - addClass: function(node, classes) { - if (node.attr) node = node[0]; - return jqLiteAddClass(node, classes); - }, - removeClass: function(node, classes) { - if (node.attr) node = node[0]; - return jqLiteRemoveClass(node, classes); + if (isSorted != null && typeof isSorted != "boolean") { + thisArg = iteratee; + iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted; + isSorted = false; + } + var callback = getCallback(); + if (!(iteratee == null && callback === baseCallback)) { + iteratee = callback(iteratee, thisArg, 3); + } + return isSorted && getIndexOf() === baseIndexOf ? sortedUniq(array, iteratee) : baseUniq(array, iteratee); + } + function unzip(array) { + if (!(array && array.length)) { + return []; + } + var index = -1, length = 0; + array = arrayFilter(array, function(group) { + if (isArrayLike(group)) { + length = nativeMax(group.length, length); + return true; } }); - }; - } - function hashKey(obj, nextUidFn) { - var key = obj && obj.$$hashKey; - if (key) { - if (typeof key === "function") { - key = obj.$$hashKey(); + var result = Array(length); + while (++index < length) { + result[index] = arrayMap(array, baseProperty(index)); } - return key; + return result; } - var objType = typeof obj; - if (objType == "function" || objType == "object" && obj !== null) { - key = obj.$$hashKey = objType + ":" + (nextUidFn || nextUid)(); - } else { - key = objType + ":" + obj; + function unzipWith(array, iteratee, thisArg) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + var result = unzip(array); + if (iteratee == null) { + return result; + } + iteratee = bindCallback(iteratee, thisArg, 4); + return arrayMap(result, function(group) { + return arrayReduce(group, iteratee, undefined, true); + }); } - return key; - } - function HashMap(array, isolatedUid) { - if (isolatedUid) { - var uid = 0; - this.nextUid = function() { - return ++uid; - }; + var without = restParam(function(array, values) { + return isArrayLike(array) ? baseDifference(array, values) : []; + }); + function xor() { + var index = -1, length = arguments.length; + while (++index < length) { + var array = arguments[index]; + if (isArrayLike(array)) { + var result = result ? arrayPush(baseDifference(result, array), baseDifference(array, result)) : array; + } + } + return result ? baseUniq(result) : []; } - forEach(array, this.put, this); - } - HashMap.prototype = { - put: function(key, value) { - this[hashKey(key, this.nextUid)] = value; - }, - get: function(key) { - return this[hashKey(key, this.nextUid)]; - }, - remove: function(key) { - var value = this[key = hashKey(key, this.nextUid)]; - delete this[key]; + var zip = restParam(unzip); + function zipObject(props, values) { + var index = -1, length = props ? props.length : 0, result = {}; + if (length && !values && !isArray(props[0])) { + values = []; + } + while (++index < length) { + var key = props[index]; + if (values) { + result[key] = values[index]; + } else if (key) { + result[key[0]] = key[1]; + } + } + return result; + } + var zipWith = restParam(function(arrays) { + var length = arrays.length, iteratee = length > 2 ? arrays[length - 2] : undefined, thisArg = length > 1 ? arrays[length - 1] : undefined; + if (length > 2 && typeof iteratee == "function") { + length -= 2; + } else { + iteratee = length > 1 && typeof thisArg == "function" ? (--length, thisArg) : undefined; + thisArg = undefined; + } + arrays.length = length; + return unzipWith(arrays, iteratee, thisArg); + }); + function chain(value) { + var result = lodash(value); + result.__chain__ = true; + return result; + } + function tap(value, interceptor, thisArg) { + interceptor.call(thisArg, value); return value; } - }; - var $$HashMapProvider = [ function() { - this.$get = [ function() { - return HashMap; - } ]; - } ]; - var FN_ARGS = /^[^\(]*\(\s*([^\)]*)\)/m; - var FN_ARG_SPLIT = /,/; - var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/; - var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm; - var $injectorMinErr = minErr("$injector"); - function anonFn(fn) { - var fnText = fn.toString().replace(STRIP_COMMENTS, ""), args = fnText.match(FN_ARGS); - if (args) { - return "function(" + (args[1] || "").replace(/[\s\r\n]+/, " ") + ")"; + function thru(value, interceptor, thisArg) { + return interceptor.call(thisArg, value); } - return "fn"; - } - function annotate(fn, strictDi, name) { - var $inject, fnText, argDecl, last; - if (typeof fn === "function") { - if (!($inject = fn.$inject)) { - $inject = []; - if (fn.length) { - if (strictDi) { - if (!isString(name) || !name) { - name = fn.name || anonFn(fn); - } - throw $injectorMinErr("strictdi", "{0} is not using explicit annotation and cannot be invoked in strict mode", name); - } - fnText = fn.toString().replace(STRIP_COMMENTS, ""); - argDecl = fnText.match(FN_ARGS); - forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg) { - arg.replace(FN_ARG, function(all, underscore, name) { - $inject.push(name); - }); - }); + function wrapperChain() { + return chain(this); + } + function wrapperCommit() { + return new LodashWrapper(this.value(), this.__chain__); + } + var wrapperConcat = restParam(function(values) { + values = baseFlatten(values); + return this.thru(function(array) { + return arrayConcat(isArray(array) ? array : [ toObject(array) ], values); + }); + }); + function wrapperPlant(value) { + var result, parent = this; + while (parent instanceof baseLodash) { + var clone = wrapperClone(parent); + if (result) { + previous.__wrapped__ = clone; + } else { + result = clone; } - fn.$inject = $inject; + var previous = clone; + parent = parent.__wrapped__; } - } else if (isArray(fn)) { - last = fn.length - 1; - assertArgFn(fn[last], "fn"); - $inject = fn.slice(0, last); - } else { - assertArgFn(fn, "fn", true); + previous.__wrapped__ = value; + return result; } - return $inject; - } - function createInjector(modulesToLoad, strictDi) { - strictDi = strictDi === true; - var INSTANTIATING = {}, providerSuffix = "Provider", path = [], loadedModules = new HashMap([], true), providerCache = { - $provide: { - provider: supportObject(provider), - factory: supportObject(factory), - service: supportObject(service), - value: supportObject(value), - constant: supportObject(constant), - decorator: decorator + function wrapperReverse() { + var value = this.__wrapped__; + var interceptor = function(value) { + return value.reverse(); + }; + if (value instanceof LazyWrapper) { + var wrapped = value; + if (this.__actions__.length) { + wrapped = new LazyWrapper(this); + } + wrapped = wrapped.reverse(); + wrapped.__actions__.push({ + func: thru, + args: [ interceptor ], + thisArg: undefined + }); + return new LodashWrapper(wrapped, this.__chain__); } - }, providerInjector = providerCache.$injector = createInternalInjector(providerCache, function(serviceName, caller) { - if (angular.isString(caller)) { - path.push(caller); + return this.thru(interceptor); + } + function wrapperToString() { + return this.value() + ""; + } + function wrapperValue() { + return baseWrapperValue(this.__wrapped__, this.__actions__); + } + var at = restParam(function(collection, props) { + return baseAt(collection, baseFlatten(props)); + }); + var countBy = createAggregator(function(result, value, key) { + hasOwnProperty.call(result, key) ? ++result[key] : result[key] = 1; + }); + function every(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayEvery : baseEvery; + if (thisArg && isIterateeCall(collection, predicate, thisArg)) { + predicate = undefined; + } + if (typeof predicate != "function" || thisArg !== undefined) { + predicate = getCallback(predicate, thisArg, 3); + } + return func(collection, predicate); + } + function filter(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayFilter : baseFilter; + predicate = getCallback(predicate, thisArg, 3); + return func(collection, predicate); + } + var find = createFind(baseEach); + var findLast = createFind(baseEachRight, true); + function findWhere(collection, source) { + return find(collection, baseMatches(source)); + } + var forEach = createForEach(arrayEach, baseEach); + var forEachRight = createForEach(arrayEachRight, baseEachRight); + var groupBy = createAggregator(function(result, value, key) { + if (hasOwnProperty.call(result, key)) { + result[key].push(value); + } else { + result[key] = [ value ]; } - throw $injectorMinErr("unpr", "Unknown provider: {0}", path.join(" <- ")); - }), instanceCache = {}, instanceInjector = instanceCache.$injector = createInternalInjector(instanceCache, function(serviceName, caller) { - var provider = providerInjector.get(serviceName + providerSuffix, caller); - return instanceInjector.invoke(provider.$get, provider, undefined, serviceName); }); - forEach(loadModules(modulesToLoad), function(fn) { - if (fn) instanceInjector.invoke(fn); + function includes(collection, target, fromIndex, guard) { + var length = collection ? getLength(collection) : 0; + if (!isLength(length)) { + collection = values(collection); + length = collection.length; + } + if (typeof fromIndex != "number" || guard && isIterateeCall(target, fromIndex, guard)) { + fromIndex = 0; + } else { + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex || 0; + } + return typeof collection == "string" || !isArray(collection) && isString(collection) ? fromIndex <= length && collection.indexOf(target, fromIndex) > -1 : !!length && getIndexOf(collection, target, fromIndex) > -1; + } + var indexBy = createAggregator(function(result, value, key) { + result[key] = value; }); - return instanceInjector; - function supportObject(delegate) { - return function(key, value) { - if (isObject(key)) { - forEach(key, reverseParams(delegate)); - } else { - return delegate(key, value); - } - }; + var invoke = restParam(function(collection, path, args) { + var index = -1, isFunc = typeof path == "function", isProp = isKey(path), result = isArrayLike(collection) ? Array(collection.length) : []; + baseEach(collection, function(value) { + var func = isFunc ? path : isProp && value != null ? value[path] : undefined; + result[++index] = func ? func.apply(value, args) : invokePath(value, path, args); + }); + return result; + }); + function map(collection, iteratee, thisArg) { + var func = isArray(collection) ? arrayMap : baseMap; + iteratee = getCallback(iteratee, thisArg, 3); + return func(collection, iteratee); + } + var partition = createAggregator(function(result, value, key) { + result[key ? 0 : 1].push(value); + }, function() { + return [ [], [] ]; + }); + function pluck(collection, path) { + return map(collection, property(path)); + } + var reduce = createReduce(arrayReduce, baseEach); + var reduceRight = createReduce(arrayReduceRight, baseEachRight); + function reject(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayFilter : baseFilter; + predicate = getCallback(predicate, thisArg, 3); + return func(collection, function(value, index, collection) { + return !predicate(value, index, collection); + }); } - function provider(name, provider_) { - assertNotHasOwnProperty(name, "service"); - if (isFunction(provider_) || isArray(provider_)) { - provider_ = providerInjector.instantiate(provider_); + function sample(collection, n, guard) { + if (guard ? isIterateeCall(collection, n, guard) : n == null) { + collection = toIterable(collection); + var length = collection.length; + return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; } - if (!provider_.$get) { - throw $injectorMinErr("pget", "Provider '{0}' must define $get factory method.", name); + var index = -1, result = toArray(collection), length = result.length, lastIndex = length - 1; + n = nativeMin(n < 0 ? 0 : +n || 0, length); + while (++index < n) { + var rand = baseRandom(index, lastIndex), value = result[rand]; + result[rand] = result[index]; + result[index] = value; } - return providerCache[name + providerSuffix] = provider_; + result.length = n; + return result; } - function enforceReturnValue(name, factory) { - return function enforcedReturnValue() { - var result = instanceInjector.invoke(factory, this); - if (isUndefined(result)) { - throw $injectorMinErr("undef", "Provider '{0}' must return a value from $get factory method.", name); - } - return result; - }; + function shuffle(collection) { + return sample(collection, POSITIVE_INFINITY); } - function factory(name, factoryFn, enforce) { - return provider(name, { - $get: enforce !== false ? enforceReturnValue(name, factoryFn) : factoryFn - }); + function size(collection) { + var length = collection ? getLength(collection) : 0; + return isLength(length) ? length : keys(collection).length; } - function service(name, constructor) { - return factory(name, [ "$injector", function($injector) { - return $injector.instantiate(constructor); - } ]); + function some(collection, predicate, thisArg) { + var func = isArray(collection) ? arraySome : baseSome; + if (thisArg && isIterateeCall(collection, predicate, thisArg)) { + predicate = undefined; + } + if (typeof predicate != "function" || thisArg !== undefined) { + predicate = getCallback(predicate, thisArg, 3); + } + return func(collection, predicate); } - function value(name, val) { - return factory(name, valueFn(val), false); + function sortBy(collection, iteratee, thisArg) { + if (collection == null) { + return []; + } + if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { + iteratee = undefined; + } + var index = -1; + iteratee = getCallback(iteratee, thisArg, 3); + var result = baseMap(collection, function(value, key, collection) { + return { + criteria: iteratee(value, key, collection), + index: ++index, + value: value + }; + }); + return baseSortBy(result, compareAscending); } - function constant(name, value) { - assertNotHasOwnProperty(name, "constant"); - providerCache[name] = value; - instanceCache[name] = value; + var sortByAll = restParam(function(collection, iteratees) { + if (collection == null) { + return []; + } + var guard = iteratees[2]; + if (guard && isIterateeCall(iteratees[0], iteratees[1], guard)) { + iteratees.length = 1; + } + return baseSortByOrder(collection, baseFlatten(iteratees), []); + }); + function sortByOrder(collection, iteratees, orders, guard) { + if (collection == null) { + return []; + } + if (guard && isIterateeCall(iteratees, orders, guard)) { + orders = undefined; + } + if (!isArray(iteratees)) { + iteratees = iteratees == null ? [] : [ iteratees ]; + } + if (!isArray(orders)) { + orders = orders == null ? [] : [ orders ]; + } + return baseSortByOrder(collection, iteratees, orders); } - function decorator(serviceName, decorFn) { - var origProvider = providerInjector.get(serviceName + providerSuffix), orig$get = origProvider.$get; - origProvider.$get = function() { - var origInstance = instanceInjector.invoke(orig$get, origProvider); - return instanceInjector.invoke(decorFn, null, { - $delegate: origInstance - }); - }; + function where(collection, source) { + return filter(collection, baseMatches(source)); } - function loadModules(modulesToLoad) { - assertArg(isUndefined(modulesToLoad) || isArray(modulesToLoad), "modulesToLoad", "not an array"); - var runBlocks = [], moduleFn; - forEach(modulesToLoad, function(module) { - if (loadedModules.get(module)) return; - loadedModules.put(module, true); - function runInvokeQueue(queue) { - var i, ii; - for (i = 0, ii = queue.length; i < ii; i++) { - var invokeArgs = queue[i], provider = providerInjector.get(invokeArgs[0]); - provider[invokeArgs[1]].apply(provider, invokeArgs[2]); - } + var now = nativeNow || function() { + return new Date().getTime(); + }; + function after(n, func) { + if (typeof func != "function") { + if (typeof n == "function") { + var temp = n; + n = func; + func = temp; + } else { + throw new TypeError(FUNC_ERROR_TEXT); } - try { - if (isString(module)) { - moduleFn = angularModule(module); - runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks); - runInvokeQueue(moduleFn._invokeQueue); - runInvokeQueue(moduleFn._configBlocks); - } else if (isFunction(module)) { - runBlocks.push(providerInjector.invoke(module)); - } else if (isArray(module)) { - runBlocks.push(providerInjector.invoke(module)); - } else { - assertArgFn(module, "module"); - } - } catch (e) { - if (isArray(module)) { - module = module[module.length - 1]; - } - if (e.message && e.stack && e.stack.indexOf(e.message) == -1) { - e = e.message + "\n" + e.stack; - } - throw $injectorMinErr("modulerr", "Failed to instantiate module {0} due to:\n{1}", module, e.stack || e.message || e); + } + n = nativeIsFinite(n = +n) ? n : 0; + return function() { + if (--n < 1) { + return func.apply(this, arguments); } - }); - return runBlocks; + }; } - function createInternalInjector(cache, factory) { - function getService(serviceName, caller) { - if (cache.hasOwnProperty(serviceName)) { - if (cache[serviceName] === INSTANTIATING) { - throw $injectorMinErr("cdep", "Circular dependency found: {0}", serviceName + " <- " + path.join(" <- ")); - } - return cache[serviceName]; + function ary(func, n, guard) { + if (guard && isIterateeCall(func, n, guard)) { + n = undefined; + } + n = func && n == null ? func.length : nativeMax(+n || 0, 0); + return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n); + } + function before(n, func) { + var result; + if (typeof func != "function") { + if (typeof n == "function") { + var temp = n; + n = func; + func = temp; } else { - try { - path.unshift(serviceName); - cache[serviceName] = INSTANTIATING; - return cache[serviceName] = factory(serviceName, caller); - } catch (err) { - if (cache[serviceName] === INSTANTIATING) { - delete cache[serviceName]; - } - throw err; - } finally { - path.shift(); - } + throw new TypeError(FUNC_ERROR_TEXT); } } - function invoke(fn, self, locals, serviceName) { - if (typeof locals === "string") { - serviceName = locals; - locals = null; + return function() { + if (--n > 0) { + result = func.apply(this, arguments); } - var args = [], $inject = createInjector.$$annotate(fn, strictDi, serviceName), length, i, key; - for (i = 0, length = $inject.length; i < length; i++) { - key = $inject[i]; - if (typeof key !== "string") { - throw $injectorMinErr("itkn", "Incorrect injection token! Expected service name as string, got {0}", key); - } - args.push(locals && locals.hasOwnProperty(key) ? locals[key] : getService(key, serviceName)); + if (n <= 1) { + func = undefined; } - if (isArray(fn)) { - fn = fn[length]; + return result; + }; + } + var bind = restParam(function(func, thisArg, partials) { + var bitmask = BIND_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, bind.placeholder); + bitmask |= PARTIAL_FLAG; + } + return createWrapper(func, bitmask, thisArg, partials, holders); + }); + var bindAll = restParam(function(object, methodNames) { + methodNames = methodNames.length ? baseFlatten(methodNames) : functions(object); + var index = -1, length = methodNames.length; + while (++index < length) { + var key = methodNames[index]; + object[key] = createWrapper(object[key], BIND_FLAG, object); + } + return object; + }); + var bindKey = restParam(function(object, key, partials) { + var bitmask = BIND_FLAG | BIND_KEY_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, bindKey.placeholder); + bitmask |= PARTIAL_FLAG; + } + return createWrapper(key, bitmask, object, partials, holders); + }); + var curry = createCurry(CURRY_FLAG); + var curryRight = createCurry(CURRY_RIGHT_FLAG); + function debounce(func, wait, options) { + var args, maxTimeoutId, result, stamp, thisArg, timeoutId, trailingCall, lastCalled = 0, maxWait = false, trailing = true; + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + wait = wait < 0 ? 0 : +wait || 0; + if (options === true) { + var leading = true; + trailing = false; + } else if (isObject(options)) { + leading = !!options.leading; + maxWait = "maxWait" in options && nativeMax(+options.maxWait || 0, wait); + trailing = "trailing" in options ? !!options.trailing : trailing; + } + function cancel() { + if (timeoutId) { + clearTimeout(timeoutId); + } + if (maxTimeoutId) { + clearTimeout(maxTimeoutId); + } + lastCalled = 0; + maxTimeoutId = timeoutId = trailingCall = undefined; + } + function complete(isCalled, id) { + if (id) { + clearTimeout(id); + } + maxTimeoutId = timeoutId = trailingCall = undefined; + if (isCalled) { + lastCalled = now(); + result = func.apply(thisArg, args); + if (!timeoutId && !maxTimeoutId) { + args = thisArg = undefined; + } + } + } + function delayed() { + var remaining = wait - (now() - stamp); + if (remaining <= 0 || remaining > wait) { + complete(trailingCall, maxTimeoutId); + } else { + timeoutId = setTimeout(delayed, remaining); } - return fn.apply(self, args); } - function instantiate(Type, locals, serviceName) { - var instance = Object.create((isArray(Type) ? Type[Type.length - 1] : Type).prototype || null); - var returnedValue = invoke(Type, instance, locals, serviceName); - return isObject(returnedValue) || isFunction(returnedValue) ? returnedValue : instance; + function maxDelayed() { + complete(trailing, timeoutId); } - return { - invoke: invoke, - instantiate: instantiate, - get: getService, - annotate: createInjector.$$annotate, - has: function(name) { - return providerCache.hasOwnProperty(name + providerSuffix) || cache.hasOwnProperty(name); + function debounced() { + args = arguments; + stamp = now(); + thisArg = this; + trailingCall = trailing && (timeoutId || !leading); + if (maxWait === false) { + var leadingCall = leading && !timeoutId; + } else { + if (!maxTimeoutId && !leading) { + lastCalled = stamp; + } + var remaining = maxWait - (stamp - lastCalled), isCalled = remaining <= 0 || remaining > maxWait; + if (isCalled) { + if (maxTimeoutId) { + maxTimeoutId = clearTimeout(maxTimeoutId); + } + lastCalled = stamp; + result = func.apply(thisArg, args); + } else if (!maxTimeoutId) { + maxTimeoutId = setTimeout(maxDelayed, remaining); + } + } + if (isCalled && timeoutId) { + timeoutId = clearTimeout(timeoutId); + } else if (!timeoutId && wait !== maxWait) { + timeoutId = setTimeout(delayed, wait); } + if (leadingCall) { + isCalled = true; + result = func.apply(thisArg, args); + } + if (isCalled && !timeoutId && !maxTimeoutId) { + args = thisArg = undefined; + } + return result; + } + debounced.cancel = cancel; + return debounced; + } + var defer = restParam(function(func, args) { + return baseDelay(func, 1, args); + }); + var delay = restParam(function(func, wait, args) { + return baseDelay(func, wait, args); + }); + var flow = createFlow(); + var flowRight = createFlow(true); + function memoize(func, resolver) { + if (typeof func != "function" || resolver && typeof resolver != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache; + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result); + return result; }; + memoized.cache = new memoize.Cache(); + return memoized; } - } - createInjector.$$annotate = annotate; - function $AnchorScrollProvider() { - var autoScrollingEnabled = true; - this.disableAutoScrolling = function() { - autoScrollingEnabled = false; - }; - this.$get = [ "$window", "$location", "$rootScope", function($window, $location, $rootScope) { - var document = $window.document; - function getFirstAnchor(list) { - var result = null; - Array.prototype.some.call(list, function(element) { - if (nodeName_(element) === "a") { - result = element; - return true; - } - }); - return result; + var modArgs = restParam(function(func, transforms) { + transforms = baseFlatten(transforms); + if (typeof func != "function" || !arrayEvery(transforms, baseIsFunction)) { + throw new TypeError(FUNC_ERROR_TEXT); } - function getYOffset() { - var offset = scroll.yOffset; - if (isFunction(offset)) { - offset = offset(); - } else if (isElement(offset)) { - var elem = offset[0]; - var style = $window.getComputedStyle(elem); - if (style.position !== "fixed") { - offset = 0; - } else { - offset = elem.getBoundingClientRect().bottom; - } - } else if (!isNumber(offset)) { - offset = 0; + var length = transforms.length; + return restParam(function(args) { + var index = nativeMin(args.length, length); + while (index--) { + args[index] = transforms[index](args[index]); } - return offset; + return func.apply(this, args); + }); + }); + function negate(predicate) { + if (typeof predicate != "function") { + throw new TypeError(FUNC_ERROR_TEXT); } - function scrollTo(elem) { - if (elem) { - elem.scrollIntoView(); - var offset = getYOffset(); - if (offset) { - var elemTop = elem.getBoundingClientRect().top; - $window.scrollBy(0, elemTop - offset); - } - } else { - $window.scrollTo(0, 0); + return function() { + return !predicate.apply(this, arguments); + }; + } + function once(func) { + return before(2, func); + } + var partial = createPartial(PARTIAL_FLAG); + var partialRight = createPartial(PARTIAL_RIGHT_FLAG); + var rearg = restParam(function(func, indexes) { + return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes)); + }); + function restParam(func, start) { + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + start = nativeMax(start === undefined ? func.length - 1 : +start || 0, 0); + return function() { + var args = arguments, index = -1, length = nativeMax(args.length - start, 0), rest = Array(length); + while (++index < length) { + rest[index] = args[start + index]; + } + switch (start) { + case 0: + return func.call(this, rest); + + case 1: + return func.call(this, args[0], rest); + + case 2: + return func.call(this, args[0], args[1], rest); + } + var otherArgs = Array(start + 1); + index = -1; + while (++index < start) { + otherArgs[index] = args[index]; } + otherArgs[start] = rest; + return func.apply(this, otherArgs); + }; + } + function spread(func) { + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); } - function scroll(hash) { - hash = isString(hash) ? hash : $location.hash(); - var elm; - if (!hash) scrollTo(null); else if (elm = document.getElementById(hash)) scrollTo(elm); else if (elm = getFirstAnchor(document.getElementsByName(hash))) scrollTo(elm); else if (hash === "top") scrollTo(null); + return function(array) { + return func.apply(this, array); + }; + } + function throttle(func, wait, options) { + var leading = true, trailing = true; + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); } - if (autoScrollingEnabled) { - $rootScope.$watch(function autoScrollWatch() { - return $location.hash(); - }, function autoScrollWatchAction(newVal, oldVal) { - if (newVal === oldVal && newVal === "") return; - jqLiteDocumentLoaded(function() { - $rootScope.$evalAsync(scroll); - }); - }); + if (options === false) { + leading = false; + } else if (isObject(options)) { + leading = "leading" in options ? !!options.leading : leading; + trailing = "trailing" in options ? !!options.trailing : trailing; } - return scroll; - } ]; - } - var $animateMinErr = minErr("$animate"); - var ELEMENT_NODE = 1; - var NG_ANIMATE_CLASSNAME = "ng-animate"; - function mergeClasses(a, b) { - if (!a && !b) return ""; - if (!a) return b; - if (!b) return a; - if (isArray(a)) a = a.join(" "); - if (isArray(b)) b = b.join(" "); - return a + " " + b; - } - function extractElementNode(element) { - for (var i = 0; i < element.length; i++) { - var elm = element[i]; - if (elm.nodeType === ELEMENT_NODE) { - return elm; + return debounce(func, wait, { + leading: leading, + maxWait: +wait, + trailing: trailing + }); + } + function wrap(value, wrapper) { + wrapper = wrapper == null ? identity : wrapper; + return createWrapper(wrapper, PARTIAL_FLAG, undefined, [ value ], []); + } + function clone(value, isDeep, customizer, thisArg) { + if (isDeep && typeof isDeep != "boolean" && isIterateeCall(value, isDeep, customizer)) { + isDeep = false; + } else if (typeof isDeep == "function") { + thisArg = customizer; + customizer = isDeep; + isDeep = false; } + return typeof customizer == "function" ? baseClone(value, isDeep, bindCallback(customizer, thisArg, 3)) : baseClone(value, isDeep); } - } - function splitClasses(classes) { - if (isString(classes)) { - classes = classes.split(" "); + function cloneDeep(value, customizer, thisArg) { + return typeof customizer == "function" ? baseClone(value, true, bindCallback(customizer, thisArg, 3)) : baseClone(value, true); } - var obj = createMap(); - forEach(classes, function(klass) { - if (klass.length) { - obj[klass] = true; + function gt(value, other) { + return value > other; + } + function gte(value, other) { + return value >= other; + } + function isArguments(value) { + return isObjectLike(value) && isArrayLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee"); + } + var isArray = nativeIsArray || function(value) { + return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag; + }; + function isBoolean(value) { + return value === true || value === false || isObjectLike(value) && objToString.call(value) == boolTag; + } + function isDate(value) { + return isObjectLike(value) && objToString.call(value) == dateTag; + } + function isElement(value) { + return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value); + } + function isEmpty(value) { + if (value == null) { + return true; + } + if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) || isObjectLike(value) && isFunction(value.splice))) { + return !value.length; + } + return !keys(value).length; + } + function isEqual(value, other, customizer, thisArg) { + customizer = typeof customizer == "function" ? bindCallback(customizer, thisArg, 3) : undefined; + var result = customizer ? customizer(value, other) : undefined; + return result === undefined ? baseIsEqual(value, other, customizer) : !!result; + } + function isError(value) { + return isObjectLike(value) && typeof value.message == "string" && objToString.call(value) == errorTag; + } + function isFinite(value) { + return typeof value == "number" && nativeIsFinite(value); + } + function isFunction(value) { + return isObject(value) && objToString.call(value) == funcTag; + } + function isObject(value) { + var type = typeof value; + return !!value && (type == "object" || type == "function"); + } + function isMatch(object, source, customizer, thisArg) { + customizer = typeof customizer == "function" ? bindCallback(customizer, thisArg, 3) : undefined; + return baseIsMatch(object, getMatchData(source), customizer); + } + function isNaN(value) { + return isNumber(value) && value != +value; + } + function isNative(value) { + if (value == null) { + return false; + } + if (isFunction(value)) { + return reIsNative.test(fnToString.call(value)); + } + return isObjectLike(value) && reIsHostCtor.test(value); + } + function isNull(value) { + return value === null; + } + function isNumber(value) { + return typeof value == "number" || isObjectLike(value) && objToString.call(value) == numberTag; + } + function isPlainObject(value) { + var Ctor; + if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) || !hasOwnProperty.call(value, "constructor") && (Ctor = value.constructor, + typeof Ctor == "function" && !(Ctor instanceof Ctor))) { + return false; + } + var result; + baseForIn(value, function(subValue, key) { + result = key; + }); + return result === undefined || hasOwnProperty.call(value, result); + } + function isRegExp(value) { + return isObject(value) && objToString.call(value) == regexpTag; + } + function isString(value) { + return typeof value == "string" || isObjectLike(value) && objToString.call(value) == stringTag; + } + function isTypedArray(value) { + return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)]; + } + function isUndefined(value) { + return value === undefined; + } + function lt(value, other) { + return value < other; + } + function lte(value, other) { + return value <= other; + } + function toArray(value) { + var length = value ? getLength(value) : 0; + if (!isLength(length)) { + return values(value); + } + if (!length) { + return []; } + return arrayCopy(value); + } + function toPlainObject(value) { + return baseCopy(value, keysIn(value)); + } + var merge = createAssigner(baseMerge); + var assign = createAssigner(function(object, source, customizer) { + return customizer ? assignWith(object, source, customizer) : baseAssign(object, source); }); - return obj; - } - function prepareAnimateOptions(options) { - return isObject(options) ? options : {}; - } - var $$CoreAnimateRunnerProvider = function() { - this.$get = [ "$q", "$$rAF", function($q, $$rAF) { - function AnimateRunner() {} - AnimateRunner.all = noop; - AnimateRunner.chain = noop; - AnimateRunner.prototype = { - end: noop, - cancel: noop, - resume: noop, - pause: noop, - complete: noop, - then: function(pass, fail) { - return $q(function(resolve) { - $$rAF(function() { - resolve(); - }); - }).then(pass, fail); - } - }; - return AnimateRunner; - } ]; - }; - var $$CoreAnimateQueueProvider = function() { - var postDigestQueue = new HashMap(); - var postDigestElements = []; - this.$get = [ "$$AnimateRunner", "$rootScope", function($$AnimateRunner, $rootScope) { - return { - enabled: noop, - on: noop, - off: noop, - pin: noop, - push: function(element, event, options, domOperation) { - domOperation && domOperation(); - options = options || {}; - options.from && element.css(options.from); - options.to && element.css(options.to); - if (options.addClass || options.removeClass) { - addRemoveClassesPostDigest(element, options.addClass, options.removeClass); - } - return new $$AnimateRunner(); - } - }; - function updateData(data, classes, value) { - var changed = false; - if (classes) { - classes = isString(classes) ? classes.split(" ") : isArray(classes) ? classes : []; - forEach(classes, function(className) { - if (className) { - changed = true; - data[className] = value; - } - }); + function create(prototype, properties, guard) { + var result = baseCreate(prototype); + if (guard && isIterateeCall(prototype, properties, guard)) { + properties = undefined; + } + return properties ? baseAssign(result, properties) : result; + } + var defaults = createDefaults(assign, assignDefaults); + var defaultsDeep = createDefaults(merge, mergeDefaults); + var findKey = createFindKey(baseForOwn); + var findLastKey = createFindKey(baseForOwnRight); + var forIn = createForIn(baseFor); + var forInRight = createForIn(baseForRight); + var forOwn = createForOwn(baseForOwn); + var forOwnRight = createForOwn(baseForOwnRight); + function functions(object) { + return baseFunctions(object, keysIn(object)); + } + function get(object, path, defaultValue) { + var result = object == null ? undefined : baseGet(object, toPath(path), path + ""); + return result === undefined ? defaultValue : result; + } + function has(object, path) { + if (object == null) { + return false; + } + var result = hasOwnProperty.call(object, path); + if (!result && !isKey(path)) { + path = toPath(path); + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + if (object == null) { + return false; } - return changed; + path = last(path); + result = hasOwnProperty.call(object, path); } - function handleCSSClassChanges() { - forEach(postDigestElements, function(element) { - var data = postDigestQueue.get(element); - if (data) { - var existing = splitClasses(element.attr("class")); - var toAdd = ""; - var toRemove = ""; - forEach(data, function(status, className) { - var hasClass = !!existing[className]; - if (status !== hasClass) { - if (status) { - toAdd += (toAdd.length ? " " : "") + className; - } else { - toRemove += (toRemove.length ? " " : "") + className; - } - } - }); - forEach(element, function(elm) { - toAdd && jqLiteAddClass(elm, toAdd); - toRemove && jqLiteRemoveClass(elm, toRemove); - }); - postDigestQueue.remove(element); - } - }); - postDigestElements.length = 0; + return result || isLength(object.length) && isIndex(path, object.length) && (isArray(object) || isArguments(object)); + } + function invert(object, multiValue, guard) { + if (guard && isIterateeCall(object, multiValue, guard)) { + multiValue = undefined; } - function addRemoveClassesPostDigest(element, add, remove) { - var data = postDigestQueue.get(element) || {}; - var classesAdded = updateData(data, add, true); - var classesRemoved = updateData(data, remove, false); - if (classesAdded || classesRemoved) { - postDigestQueue.put(element, data); - postDigestElements.push(element); - if (postDigestElements.length === 1) { - $rootScope.$$postDigest(handleCSSClassChanges); + var index = -1, props = keys(object), length = props.length, result = {}; + while (++index < length) { + var key = props[index], value = object[key]; + if (multiValue) { + if (hasOwnProperty.call(result, value)) { + result[value].push(key); + } else { + result[value] = [ key ]; } + } else { + result[value] = key; } } - } ]; - }; - var $AnimateProvider = [ "$provide", function($provide) { - var provider = this; - this.$$registeredAnimations = Object.create(null); - this.register = function(name, factory) { - if (name && name.charAt(0) !== ".") { - throw $animateMinErr("notcsel", "Expecting class selector starting with '.' got '{0}'.", name); + return result; + } + var keys = !nativeKeys ? shimKeys : function(object) { + var Ctor = object == null ? undefined : object.constructor; + if (typeof Ctor == "function" && Ctor.prototype === object || typeof object != "function" && isArrayLike(object)) { + return shimKeys(object); } - var key = name + "-animation"; - provider.$$registeredAnimations[name.substr(1)] = key; - $provide.factory(key, factory); + return isObject(object) ? nativeKeys(object) : []; }; - this.classNameFilter = function(expression) { - if (arguments.length === 1) { - this.$$classNameFilter = expression instanceof RegExp ? expression : null; - if (this.$$classNameFilter) { - var reservedRegex = new RegExp("(\\s+|\\/)" + NG_ANIMATE_CLASSNAME + "(\\s+|\\/)"); - if (reservedRegex.test(this.$$classNameFilter.toString())) { - throw $animateMinErr("nongcls", '$animateProvider.classNameFilter(regex) prohibits accepting a regex value which matches/contains the "{0}" CSS class.', NG_ANIMATE_CLASSNAME); - } + function keysIn(object) { + if (object == null) { + return []; + } + if (!isObject(object)) { + object = Object(object); + } + var length = object.length; + length = length && isLength(length) && (isArray(object) || isArguments(object)) && length || 0; + var Ctor = object.constructor, index = -1, isProto = typeof Ctor == "function" && Ctor.prototype === object, result = Array(length), skipIndexes = length > 0; + while (++index < length) { + result[index] = index + ""; + } + for (var key in object) { + if (!(skipIndexes && isIndex(key, length)) && !(key == "constructor" && (isProto || !hasOwnProperty.call(object, key)))) { + result.push(key); } } - return this.$$classNameFilter; - }; - this.$get = [ "$$animateQueue", function($$animateQueue) { - function domInsert(element, parentElement, afterElement) { - if (afterElement) { - var afterNode = extractElementNode(afterElement); - if (afterNode && !afterNode.parentNode && !afterNode.previousElementSibling) { - afterElement = null; + return result; + } + var mapKeys = createObjectMapper(true); + var mapValues = createObjectMapper(); + var omit = restParam(function(object, props) { + if (object == null) { + return {}; + } + if (typeof props[0] != "function") { + var props = arrayMap(baseFlatten(props), String); + return pickByArray(object, baseDifference(keysIn(object), props)); + } + var predicate = bindCallback(props[0], props[1], 3); + return pickByCallback(object, function(value, key, object) { + return !predicate(value, key, object); + }); + }); + function pairs(object) { + object = toObject(object); + var index = -1, props = keys(object), length = props.length, result = Array(length); + while (++index < length) { + var key = props[index]; + result[index] = [ key, object[key] ]; + } + return result; + } + var pick = restParam(function(object, props) { + if (object == null) { + return {}; + } + return typeof props[0] == "function" ? pickByCallback(object, bindCallback(props[0], props[1], 3)) : pickByArray(object, baseFlatten(props)); + }); + function result(object, path, defaultValue) { + var result = object == null ? undefined : object[path]; + if (result === undefined) { + if (object != null && !isKey(path, object)) { + path = toPath(path); + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + result = object == null ? undefined : object[last(path)]; + } + result = result === undefined ? defaultValue : result; + } + return isFunction(result) ? result.call(object) : result; + } + function set(object, path, value) { + if (object == null) { + return object; + } + var pathKey = path + ""; + path = object[pathKey] != null || isKey(path, object) ? [ pathKey ] : toPath(path); + var index = -1, length = path.length, lastIndex = length - 1, nested = object; + while (nested != null && ++index < length) { + var key = path[index]; + if (isObject(nested)) { + if (index == lastIndex) { + nested[key] = value; + } else if (nested[key] == null) { + nested[key] = isIndex(path[index + 1]) ? [] : {}; + } + } + nested = nested[key]; + } + return object; + } + function transform(object, iteratee, accumulator, thisArg) { + var isArr = isArray(object) || isTypedArray(object); + iteratee = getCallback(iteratee, thisArg, 4); + if (accumulator == null) { + if (isArr || isObject(object)) { + var Ctor = object.constructor; + if (isArr) { + accumulator = isArray(object) ? new Ctor() : []; + } else { + accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined); } + } else { + accumulator = {}; } - afterElement ? afterElement.after(element) : parentElement.prepend(element); } - return { - on: $$animateQueue.on, - off: $$animateQueue.off, - pin: $$animateQueue.pin, - enabled: $$animateQueue.enabled, - cancel: function(runner) { - runner.end && runner.end(); - }, - enter: function(element, parent, after, options) { - parent = parent && jqLite(parent); - after = after && jqLite(after); - parent = parent || after.parent(); - domInsert(element, parent, after); - return $$animateQueue.push(element, "enter", prepareAnimateOptions(options)); - }, - move: function(element, parent, after, options) { - parent = parent && jqLite(parent); - after = after && jqLite(after); - parent = parent || after.parent(); - domInsert(element, parent, after); - return $$animateQueue.push(element, "move", prepareAnimateOptions(options)); - }, - leave: function(element, options) { - return $$animateQueue.push(element, "leave", prepareAnimateOptions(options), function() { - element.remove(); - }); - }, - addClass: function(element, className, options) { - options = prepareAnimateOptions(options); - options.addClass = mergeClasses(options.addclass, className); - return $$animateQueue.push(element, "addClass", options); - }, - removeClass: function(element, className, options) { - options = prepareAnimateOptions(options); - options.removeClass = mergeClasses(options.removeClass, className); - return $$animateQueue.push(element, "removeClass", options); - }, - setClass: function(element, add, remove, options) { - options = prepareAnimateOptions(options); - options.addClass = mergeClasses(options.addClass, add); - options.removeClass = mergeClasses(options.removeClass, remove); - return $$animateQueue.push(element, "setClass", options); - }, - animate: function(element, from, to, className, options) { - options = prepareAnimateOptions(options); - options.from = options.from ? extend(options.from, from) : from; - options.to = options.to ? extend(options.to, to) : to; - className = className || "ng-inline-animate"; - options.tempClasses = mergeClasses(options.tempClasses, className); - return $$animateQueue.push(element, "animate", options); - } - }; - } ]; - } ]; - var $CoreAnimateCssProvider = function() { - this.$get = [ "$$rAF", "$q", function($$rAF, $q) { - var RAFPromise = function() {}; - RAFPromise.prototype = { - done: function(cancel) { - this.defer && this.defer[cancel === true ? "reject" : "resolve"](); - }, - end: function() { - this.done(); - }, - cancel: function() { - this.done(true); - }, - getPromise: function() { - if (!this.defer) { - this.defer = $q.defer(); - } - return this.defer.promise; - }, - then: function(f1, f2) { - return this.getPromise().then(f1, f2); - }, - "catch": function(f1) { - return this.getPromise()["catch"](f1); - }, - "finally": function(f1) { - return this.getPromise()["finally"](f1); + (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) { + return iteratee(accumulator, value, index, object); + }); + return accumulator; + } + function values(object) { + return baseValues(object, keys(object)); + } + function valuesIn(object) { + return baseValues(object, keysIn(object)); + } + function inRange(value, start, end) { + start = +start || 0; + if (end === undefined) { + end = start; + start = 0; + } else { + end = +end || 0; + } + return value >= nativeMin(start, end) && value < nativeMax(start, end); + } + function random(min, max, floating) { + if (floating && isIterateeCall(min, max, floating)) { + max = floating = undefined; + } + var noMin = min == null, noMax = max == null; + if (floating == null) { + if (noMax && typeof min == "boolean") { + floating = min; + min = 1; + } else if (typeof max == "boolean") { + floating = max; + noMax = true; } - }; - return function(element, options) { - if (options.from) { - element.css(options.from); - options.from = null; + } + if (noMin && noMax) { + max = 1; + noMax = false; + } + min = +min || 0; + if (noMax) { + max = min; + min = 0; + } else { + max = +max || 0; + } + if (floating || min % 1 || max % 1) { + var rand = nativeRandom(); + return nativeMin(min + rand * (max - min + parseFloat("1e-" + ((rand + "").length - 1))), max); + } + return baseRandom(min, max); + } + var camelCase = createCompounder(function(result, word, index) { + word = word.toLowerCase(); + return result + (index ? word.charAt(0).toUpperCase() + word.slice(1) : word); + }); + function capitalize(string) { + string = baseToString(string); + return string && string.charAt(0).toUpperCase() + string.slice(1); + } + function deburr(string) { + string = baseToString(string); + return string && string.replace(reLatin1, deburrLetter).replace(reComboMark, ""); + } + function endsWith(string, target, position) { + string = baseToString(string); + target = target + ""; + var length = string.length; + position = position === undefined ? length : nativeMin(position < 0 ? 0 : +position || 0, length); + position -= target.length; + return position >= 0 && string.indexOf(target, position) == position; + } + function escape(string) { + string = baseToString(string); + return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, escapeHtmlChar) : string; + } + function escapeRegExp(string) { + string = baseToString(string); + return string && reHasRegExpChars.test(string) ? string.replace(reRegExpChars, escapeRegExpChar) : string || "(?:)"; + } + var kebabCase = createCompounder(function(result, word, index) { + return result + (index ? "-" : "") + word.toLowerCase(); + }); + function pad(string, length, chars) { + string = baseToString(string); + length = +length; + var strLength = string.length; + if (strLength >= length || !nativeIsFinite(length)) { + return string; + } + var mid = (length - strLength) / 2, leftLength = nativeFloor(mid), rightLength = nativeCeil(mid); + chars = createPadding("", rightLength, chars); + return chars.slice(0, leftLength) + string + chars; + } + var padLeft = createPadDir(); + var padRight = createPadDir(true); + function parseInt(string, radix, guard) { + if (guard ? isIterateeCall(string, radix, guard) : radix == null) { + radix = 0; + } else if (radix) { + radix = +radix; + } + string = trim(string); + return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10)); + } + function repeat(string, n) { + var result = ""; + string = baseToString(string); + n = +n; + if (n < 1 || !string || !nativeIsFinite(n)) { + return result; + } + do { + if (n % 2) { + result += string; } - var closed, runner = new RAFPromise(); - return { - start: run, - end: run - }; - function run() { - $$rAF(function() { - close(); - if (!closed) { - runner.done(); - } - closed = true; - }); - return runner; + n = nativeFloor(n / 2); + string += string; + } while (n); + return result; + } + var snakeCase = createCompounder(function(result, word, index) { + return result + (index ? "_" : "") + word.toLowerCase(); + }); + var startCase = createCompounder(function(result, word, index) { + return result + (index ? " " : "") + (word.charAt(0).toUpperCase() + word.slice(1)); + }); + function startsWith(string, target, position) { + string = baseToString(string); + position = position == null ? 0 : nativeMin(position < 0 ? 0 : +position || 0, string.length); + return string.lastIndexOf(target, position) == position; + } + function template(string, options, otherOptions) { + var settings = lodash.templateSettings; + if (otherOptions && isIterateeCall(string, options, otherOptions)) { + options = otherOptions = undefined; + } + string = baseToString(string); + options = assignWith(baseAssign({}, otherOptions || options), settings, assignOwnDefaults); + var imports = assignWith(baseAssign({}, options.imports), settings.imports, assignOwnDefaults), importsKeys = keys(imports), importsValues = baseValues(imports, importsKeys); + var isEscaping, isEvaluating, index = 0, interpolate = options.interpolate || reNoMatch, source = "__p += '"; + var reDelimiters = RegExp((options.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options.evaluate || reNoMatch).source + "|$", "g"); + var sourceURL = "//# sourceURL=" + ("sourceURL" in options ? options.sourceURL : "lodash.templateSources[" + ++templateCounter + "]") + "\n"; + string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { + interpolateValue || (interpolateValue = esTemplateValue); + source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); + if (escapeValue) { + isEscaping = true; + source += "' +\n__e(" + escapeValue + ") +\n'"; + } + if (evaluateValue) { + isEvaluating = true; + source += "';\n" + evaluateValue + ";\n__p += '"; + } + if (interpolateValue) { + source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; + } + index = offset + match.length; + return match; + }); + source += "';\n"; + var variable = options.variable; + if (!variable) { + source = "with (obj) {\n" + source + "\n}\n"; + } + source = (isEvaluating ? source.replace(reEmptyStringLeading, "") : source).replace(reEmptyStringMiddle, "$1").replace(reEmptyStringTrailing, "$1;"); + source = "function(" + (variable || "obj") + ") {\n" + (variable ? "" : "obj || (obj = {});\n") + "var __t, __p = ''" + (isEscaping ? ", __e = _.escape" : "") + (isEvaluating ? ", __j = Array.prototype.join;\n" + "function print() { __p += __j.call(arguments, '') }\n" : ";\n") + source + "return __p\n}"; + var result = attempt(function() { + return Function(importsKeys, sourceURL + "return " + source).apply(undefined, importsValues); + }); + result.source = source; + if (isError(result)) { + throw result; + } + return result; + } + function trim(string, chars, guard) { + var value = string; + string = baseToString(string); + if (!string) { + return string; + } + if (guard ? isIterateeCall(value, chars, guard) : chars == null) { + return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1); + } + chars = chars + ""; + return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1); + } + function trimLeft(string, chars, guard) { + var value = string; + string = baseToString(string); + if (!string) { + return string; + } + if (guard ? isIterateeCall(value, chars, guard) : chars == null) { + return string.slice(trimmedLeftIndex(string)); + } + return string.slice(charsLeftIndex(string, chars + "")); + } + function trimRight(string, chars, guard) { + var value = string; + string = baseToString(string); + if (!string) { + return string; + } + if (guard ? isIterateeCall(value, chars, guard) : chars == null) { + return string.slice(0, trimmedRightIndex(string) + 1); + } + return string.slice(0, charsRightIndex(string, chars + "") + 1); + } + function trunc(string, options, guard) { + if (guard && isIterateeCall(string, options, guard)) { + options = undefined; + } + var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION; + if (options != null) { + if (isObject(options)) { + var separator = "separator" in options ? options.separator : separator; + length = "length" in options ? +options.length || 0 : length; + omission = "omission" in options ? baseToString(options.omission) : omission; + } else { + length = +options || 0; } - function close() { - if (options.addClass) { - element.addClass(options.addClass); - options.addClass = null; - } - if (options.removeClass) { - element.removeClass(options.removeClass); - options.removeClass = null; + } + string = baseToString(string); + if (length >= string.length) { + return string; + } + var end = length - omission.length; + if (end < 1) { + return omission; + } + var result = string.slice(0, end); + if (separator == null) { + return result + omission; + } + if (isRegExp(separator)) { + if (string.slice(end).search(separator)) { + var match, newEnd, substring = string.slice(0, end); + if (!separator.global) { + separator = RegExp(separator.source, (reFlags.exec(separator) || "") + "g"); } - if (options.to) { - element.css(options.to); - options.to = null; + separator.lastIndex = 0; + while (match = separator.exec(substring)) { + newEnd = match.index; } + result = result.slice(0, newEnd == null ? end : newEnd); } - }; - } ]; - }; - function Browser(window, document, $log, $sniffer) { - var self = this, rawDocument = document[0], location = window.location, history = window.history, setTimeout = window.setTimeout, clearTimeout = window.clearTimeout, pendingDeferIds = {}; - self.isMock = false; - var outstandingRequestCount = 0; - var outstandingRequestCallbacks = []; - self.$$completeOutstandingRequest = completeOutstandingRequest; - self.$$incOutstandingRequestCount = function() { - outstandingRequestCount++; - }; - function completeOutstandingRequest(fn) { - try { - fn.apply(null, sliceArgs(arguments, 1)); - } finally { - outstandingRequestCount--; - if (outstandingRequestCount === 0) { - while (outstandingRequestCallbacks.length) { - try { - outstandingRequestCallbacks.pop()(); - } catch (e) { - $log.error(e); - } - } + } else if (string.indexOf(separator, end) != end) { + var index = result.lastIndexOf(separator); + if (index > -1) { + result = result.slice(0, index); } } + return result + omission; } - function getHash(url) { - var index = url.indexOf("#"); - return index === -1 ? "" : url.substr(index); + function unescape(string) { + string = baseToString(string); + return string && reHasEscapedHtml.test(string) ? string.replace(reEscapedHtml, unescapeHtmlChar) : string; } - self.notifyWhenNoOutstandingRequests = function(callback) { - if (outstandingRequestCount === 0) { - callback(); - } else { - outstandingRequestCallbacks.push(callback); + function words(string, pattern, guard) { + if (guard && isIterateeCall(string, pattern, guard)) { + pattern = undefined; } - }; - var cachedState, lastHistoryState, lastBrowserUrl = location.href, baseElement = document.find("base"), pendingLocation = null; - cacheState(); - lastHistoryState = cachedState; - self.url = function(url, replace, state) { - if (isUndefined(state)) { - state = null; + string = baseToString(string); + return string.match(pattern || reWords) || []; + } + var attempt = restParam(function(func, args) { + try { + return func.apply(undefined, args); + } catch (e) { + return isError(e) ? e : new Error(e); } - if (location !== window.location) location = window.location; - if (history !== window.history) history = window.history; - if (url) { - var sameState = lastHistoryState === state; - if (lastBrowserUrl === url && (!$sniffer.history || sameState)) { - return self; + }); + function callback(func, thisArg, guard) { + if (guard && isIterateeCall(func, thisArg, guard)) { + thisArg = undefined; + } + return isObjectLike(func) ? matches(func) : baseCallback(func, thisArg); + } + function constant(value) { + return function() { + return value; + }; + } + function identity(value) { + return value; + } + function matches(source) { + return baseMatches(baseClone(source, true)); + } + function matchesProperty(path, srcValue) { + return baseMatchesProperty(path, baseClone(srcValue, true)); + } + var method = restParam(function(path, args) { + return function(object) { + return invokePath(object, path, args); + }; + }); + var methodOf = restParam(function(object, args) { + return function(path) { + return invokePath(object, path, args); + }; + }); + function mixin(object, source, options) { + if (options == null) { + var isObj = isObject(source), props = isObj ? keys(source) : undefined, methodNames = props && props.length ? baseFunctions(source, props) : undefined; + if (!(methodNames ? methodNames.length : isObj)) { + methodNames = false; + options = source; + source = object; + object = this; + } + } + if (!methodNames) { + methodNames = baseFunctions(source, keys(source)); + } + var chain = true, index = -1, isFunc = isFunction(object), length = methodNames.length; + if (options === false) { + chain = false; + } else if (isObject(options) && "chain" in options) { + chain = options.chain; + } + while (++index < length) { + var methodName = methodNames[index], func = source[methodName]; + object[methodName] = func; + if (isFunc) { + object.prototype[methodName] = function(func) { + return function() { + var chainAll = this.__chain__; + if (chain || chainAll) { + var result = object(this.__wrapped__), actions = result.__actions__ = arrayCopy(this.__actions__); + actions.push({ + func: func, + args: arguments, + thisArg: object + }); + result.__chain__ = chainAll; + return result; + } + return func.apply(object, arrayPush([ this.value() ], arguments)); + }; + }(func); } - var sameBase = lastBrowserUrl && stripHash(lastBrowserUrl) === stripHash(url); - lastBrowserUrl = url; - lastHistoryState = state; - if ($sniffer.history && (!sameBase || !sameState)) { - history[replace ? "replaceState" : "pushState"](state, "", url); - cacheState(); - lastHistoryState = cachedState; - } else { - if (!sameBase || pendingLocation) { - pendingLocation = url; - } - if (replace) { - location.replace(url); - } else if (!sameBase) { - location.href = url; - } else { - location.hash = getHash(url); - } - if (location.href !== url) { - pendingLocation = url; - } - } - return self; - } else { - return pendingLocation || location.href.replace(/%27/g, "'"); } - }; - self.state = function() { - return cachedState; - }; - var urlChangeListeners = [], urlChangeInit = false; - function cacheStateAndFireUrlChange() { - pendingLocation = null; - cacheState(); - fireUrlChange(); + return object; } - function getCurrentState() { - try { - return history.state; - } catch (e) {} + function noConflict() { + root._ = oldDash; + return this; } - var lastCachedState = null; - function cacheState() { - cachedState = getCurrentState(); - cachedState = isUndefined(cachedState) ? null : cachedState; - if (equals(cachedState, lastCachedState)) { - cachedState = lastCachedState; - } - lastCachedState = cachedState; + function noop() {} + function property(path) { + return isKey(path) ? baseProperty(path) : basePropertyDeep(path); } - function fireUrlChange() { - if (lastBrowserUrl === self.url() && lastHistoryState === cachedState) { - return; + function propertyOf(object) { + return function(path) { + return baseGet(object, toPath(path), path + ""); + }; + } + function range(start, end, step) { + if (step && isIterateeCall(start, end, step)) { + end = step = undefined; } - lastBrowserUrl = self.url(); - lastHistoryState = cachedState; - forEach(urlChangeListeners, function(listener) { - listener(self.url(), cachedState); - }); + start = +start || 0; + step = step == null ? 1 : +step || 0; + if (end == null) { + end = start; + start = 0; + } else { + end = +end || 0; + } + var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result = Array(length); + while (++index < length) { + result[index] = start; + start += step; + } + return result; } - self.onUrlChange = function(callback) { - if (!urlChangeInit) { - if ($sniffer.history) jqLite(window).on("popstate", cacheStateAndFireUrlChange); - jqLite(window).on("hashchange", cacheStateAndFireUrlChange); - urlChangeInit = true; + function times(n, iteratee, thisArg) { + n = nativeFloor(n); + if (n < 1 || !nativeIsFinite(n)) { + return []; } - urlChangeListeners.push(callback); - return callback; - }; - self.$$applicationDestroyed = function() { - jqLite(window).off("hashchange popstate", cacheStateAndFireUrlChange); + var index = -1, result = Array(nativeMin(n, MAX_ARRAY_LENGTH)); + iteratee = bindCallback(iteratee, thisArg, 1); + while (++index < n) { + if (index < MAX_ARRAY_LENGTH) { + result[index] = iteratee(index); + } else { + iteratee(index); + } + } + return result; + } + function uniqueId(prefix) { + var id = ++idCounter; + return baseToString(prefix) + id; + } + function add(augend, addend) { + return (+augend || 0) + (+addend || 0); + } + var ceil = createRound("ceil"); + var floor = createRound("floor"); + var max = createExtremum(gt, NEGATIVE_INFINITY); + var min = createExtremum(lt, POSITIVE_INFINITY); + var round = createRound("round"); + function sum(collection, iteratee, thisArg) { + if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { + iteratee = undefined; + } + iteratee = getCallback(iteratee, thisArg, 3); + return iteratee.length == 1 ? arraySum(isArray(collection) ? collection : toIterable(collection), iteratee) : baseSum(collection, iteratee); + } + lodash.prototype = baseLodash.prototype; + LodashWrapper.prototype = baseCreate(baseLodash.prototype); + LodashWrapper.prototype.constructor = LodashWrapper; + LazyWrapper.prototype = baseCreate(baseLodash.prototype); + LazyWrapper.prototype.constructor = LazyWrapper; + MapCache.prototype["delete"] = mapDelete; + MapCache.prototype.get = mapGet; + MapCache.prototype.has = mapHas; + MapCache.prototype.set = mapSet; + SetCache.prototype.push = cachePush; + memoize.Cache = MapCache; + lodash.after = after; + lodash.ary = ary; + lodash.assign = assign; + lodash.at = at; + lodash.before = before; + lodash.bind = bind; + lodash.bindAll = bindAll; + lodash.bindKey = bindKey; + lodash.callback = callback; + lodash.chain = chain; + lodash.chunk = chunk; + lodash.compact = compact; + lodash.constant = constant; + lodash.countBy = countBy; + lodash.create = create; + lodash.curry = curry; + lodash.curryRight = curryRight; + lodash.debounce = debounce; + lodash.defaults = defaults; + lodash.defaultsDeep = defaultsDeep; + lodash.defer = defer; + lodash.delay = delay; + lodash.difference = difference; + lodash.drop = drop; + lodash.dropRight = dropRight; + lodash.dropRightWhile = dropRightWhile; + lodash.dropWhile = dropWhile; + lodash.fill = fill; + lodash.filter = filter; + lodash.flatten = flatten; + lodash.flattenDeep = flattenDeep; + lodash.flow = flow; + lodash.flowRight = flowRight; + lodash.forEach = forEach; + lodash.forEachRight = forEachRight; + lodash.forIn = forIn; + lodash.forInRight = forInRight; + lodash.forOwn = forOwn; + lodash.forOwnRight = forOwnRight; + lodash.functions = functions; + lodash.groupBy = groupBy; + lodash.indexBy = indexBy; + lodash.initial = initial; + lodash.intersection = intersection; + lodash.invert = invert; + lodash.invoke = invoke; + lodash.keys = keys; + lodash.keysIn = keysIn; + lodash.map = map; + lodash.mapKeys = mapKeys; + lodash.mapValues = mapValues; + lodash.matches = matches; + lodash.matchesProperty = matchesProperty; + lodash.memoize = memoize; + lodash.merge = merge; + lodash.method = method; + lodash.methodOf = methodOf; + lodash.mixin = mixin; + lodash.modArgs = modArgs; + lodash.negate = negate; + lodash.omit = omit; + lodash.once = once; + lodash.pairs = pairs; + lodash.partial = partial; + lodash.partialRight = partialRight; + lodash.partition = partition; + lodash.pick = pick; + lodash.pluck = pluck; + lodash.property = property; + lodash.propertyOf = propertyOf; + lodash.pull = pull; + lodash.pullAt = pullAt; + lodash.range = range; + lodash.rearg = rearg; + lodash.reject = reject; + lodash.remove = remove; + lodash.rest = rest; + lodash.restParam = restParam; + lodash.set = set; + lodash.shuffle = shuffle; + lodash.slice = slice; + lodash.sortBy = sortBy; + lodash.sortByAll = sortByAll; + lodash.sortByOrder = sortByOrder; + lodash.spread = spread; + lodash.take = take; + lodash.takeRight = takeRight; + lodash.takeRightWhile = takeRightWhile; + lodash.takeWhile = takeWhile; + lodash.tap = tap; + lodash.throttle = throttle; + lodash.thru = thru; + lodash.times = times; + lodash.toArray = toArray; + lodash.toPlainObject = toPlainObject; + lodash.transform = transform; + lodash.union = union; + lodash.uniq = uniq; + lodash.unzip = unzip; + lodash.unzipWith = unzipWith; + lodash.values = values; + lodash.valuesIn = valuesIn; + lodash.where = where; + lodash.without = without; + lodash.wrap = wrap; + lodash.xor = xor; + lodash.zip = zip; + lodash.zipObject = zipObject; + lodash.zipWith = zipWith; + lodash.backflow = flowRight; + lodash.collect = map; + lodash.compose = flowRight; + lodash.each = forEach; + lodash.eachRight = forEachRight; + lodash.extend = assign; + lodash.iteratee = callback; + lodash.methods = functions; + lodash.object = zipObject; + lodash.select = filter; + lodash.tail = rest; + lodash.unique = uniq; + mixin(lodash, lodash); + lodash.add = add; + lodash.attempt = attempt; + lodash.camelCase = camelCase; + lodash.capitalize = capitalize; + lodash.ceil = ceil; + lodash.clone = clone; + lodash.cloneDeep = cloneDeep; + lodash.deburr = deburr; + lodash.endsWith = endsWith; + lodash.escape = escape; + lodash.escapeRegExp = escapeRegExp; + lodash.every = every; + lodash.find = find; + lodash.findIndex = findIndex; + lodash.findKey = findKey; + lodash.findLast = findLast; + lodash.findLastIndex = findLastIndex; + lodash.findLastKey = findLastKey; + lodash.findWhere = findWhere; + lodash.first = first; + lodash.floor = floor; + lodash.get = get; + lodash.gt = gt; + lodash.gte = gte; + lodash.has = has; + lodash.identity = identity; + lodash.includes = includes; + lodash.indexOf = indexOf; + lodash.inRange = inRange; + lodash.isArguments = isArguments; + lodash.isArray = isArray; + lodash.isBoolean = isBoolean; + lodash.isDate = isDate; + lodash.isElement = isElement; + lodash.isEmpty = isEmpty; + lodash.isEqual = isEqual; + lodash.isError = isError; + lodash.isFinite = isFinite; + lodash.isFunction = isFunction; + lodash.isMatch = isMatch; + lodash.isNaN = isNaN; + lodash.isNative = isNative; + lodash.isNull = isNull; + lodash.isNumber = isNumber; + lodash.isObject = isObject; + lodash.isPlainObject = isPlainObject; + lodash.isRegExp = isRegExp; + lodash.isString = isString; + lodash.isTypedArray = isTypedArray; + lodash.isUndefined = isUndefined; + lodash.kebabCase = kebabCase; + lodash.last = last; + lodash.lastIndexOf = lastIndexOf; + lodash.lt = lt; + lodash.lte = lte; + lodash.max = max; + lodash.min = min; + lodash.noConflict = noConflict; + lodash.noop = noop; + lodash.now = now; + lodash.pad = pad; + lodash.padLeft = padLeft; + lodash.padRight = padRight; + lodash.parseInt = parseInt; + lodash.random = random; + lodash.reduce = reduce; + lodash.reduceRight = reduceRight; + lodash.repeat = repeat; + lodash.result = result; + lodash.round = round; + lodash.runInContext = runInContext; + lodash.size = size; + lodash.snakeCase = snakeCase; + lodash.some = some; + lodash.sortedIndex = sortedIndex; + lodash.sortedLastIndex = sortedLastIndex; + lodash.startCase = startCase; + lodash.startsWith = startsWith; + lodash.sum = sum; + lodash.template = template; + lodash.trim = trim; + lodash.trimLeft = trimLeft; + lodash.trimRight = trimRight; + lodash.trunc = trunc; + lodash.unescape = unescape; + lodash.uniqueId = uniqueId; + lodash.words = words; + lodash.all = every; + lodash.any = some; + lodash.contains = includes; + lodash.eq = isEqual; + lodash.detect = find; + lodash.foldl = reduce; + lodash.foldr = reduceRight; + lodash.head = first; + lodash.include = includes; + lodash.inject = reduce; + mixin(lodash, function() { + var source = {}; + baseForOwn(lodash, function(func, methodName) { + if (!lodash.prototype[methodName]) { + source[methodName] = func; + } + }); + return source; + }(), false); + lodash.sample = sample; + lodash.prototype.sample = function(n) { + if (!this.__chain__ && n == null) { + return sample(this.value()); + } + return this.thru(function(value) { + return sample(value, n); + }); }; - self.$$checkUrlChange = fireUrlChange; - self.baseHref = function() { - var href = baseElement.attr("href"); - return href ? href.replace(/^(https?\:)?\/\/[^\/]*/, "") : ""; + lodash.VERSION = VERSION; + arrayEach([ "bind", "bindKey", "curry", "curryRight", "partial", "partialRight" ], function(methodName) { + lodash[methodName].placeholder = lodash; + }); + arrayEach([ "drop", "take" ], function(methodName, index) { + LazyWrapper.prototype[methodName] = function(n) { + var filtered = this.__filtered__; + if (filtered && !index) { + return new LazyWrapper(this); + } + n = n == null ? 1 : nativeMax(nativeFloor(n) || 0, 0); + var result = this.clone(); + if (filtered) { + result.__takeCount__ = nativeMin(result.__takeCount__, n); + } else { + result.__views__.push({ + size: n, + type: methodName + (result.__dir__ < 0 ? "Right" : "") + }); + } + return result; + }; + LazyWrapper.prototype[methodName + "Right"] = function(n) { + return this.reverse()[methodName](n).reverse(); + }; + }); + arrayEach([ "filter", "map", "takeWhile" ], function(methodName, index) { + var type = index + 1, isFilter = type != LAZY_MAP_FLAG; + LazyWrapper.prototype[methodName] = function(iteratee, thisArg) { + var result = this.clone(); + result.__iteratees__.push({ + iteratee: getCallback(iteratee, thisArg, 1), + type: type + }); + result.__filtered__ = result.__filtered__ || isFilter; + return result; + }; + }); + arrayEach([ "first", "last" ], function(methodName, index) { + var takeName = "take" + (index ? "Right" : ""); + LazyWrapper.prototype[methodName] = function() { + return this[takeName](1).value()[0]; + }; + }); + arrayEach([ "initial", "rest" ], function(methodName, index) { + var dropName = "drop" + (index ? "" : "Right"); + LazyWrapper.prototype[methodName] = function() { + return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); + }; + }); + arrayEach([ "pluck", "where" ], function(methodName, index) { + var operationName = index ? "filter" : "map", createCallback = index ? baseMatches : property; + LazyWrapper.prototype[methodName] = function(value) { + return this[operationName](createCallback(value)); + }; + }); + LazyWrapper.prototype.compact = function() { + return this.filter(identity); }; - self.defer = function(fn, delay) { - var timeoutId; - outstandingRequestCount++; - timeoutId = setTimeout(function() { - delete pendingDeferIds[timeoutId]; - completeOutstandingRequest(fn); - }, delay || 0); - pendingDeferIds[timeoutId] = true; - return timeoutId; + LazyWrapper.prototype.reject = function(predicate, thisArg) { + predicate = getCallback(predicate, thisArg, 1); + return this.filter(function(value) { + return !predicate(value); + }); }; - self.defer.cancel = function(deferId) { - if (pendingDeferIds[deferId]) { - delete pendingDeferIds[deferId]; - clearTimeout(deferId); - completeOutstandingRequest(noop); - return true; + LazyWrapper.prototype.slice = function(start, end) { + start = start == null ? 0 : +start || 0; + var result = this; + if (result.__filtered__ && (start > 0 || end < 0)) { + return new LazyWrapper(result); } - return false; + if (start < 0) { + result = result.takeRight(-start); + } else if (start) { + result = result.drop(start); + } + if (end !== undefined) { + end = +end || 0; + result = end < 0 ? result.dropRight(-end) : result.take(end - start); + } + return result; }; - } - function $BrowserProvider() { - this.$get = [ "$window", "$log", "$sniffer", "$document", function($window, $log, $sniffer, $document) { - return new Browser($window, $document, $log, $sniffer); - } ]; - } - function $CacheFactoryProvider() { - this.$get = function() { - var caches = {}; - function cacheFactory(cacheId, options) { - if (cacheId in caches) { - throw minErr("$cacheFactory")("iid", "CacheId '{0}' is already taken!", cacheId); + LazyWrapper.prototype.takeRightWhile = function(predicate, thisArg) { + return this.reverse().takeWhile(predicate, thisArg).reverse(); + }; + LazyWrapper.prototype.toArray = function() { + return this.take(POSITIVE_INFINITY); + }; + baseForOwn(LazyWrapper.prototype, function(func, methodName) { + var checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName), retUnwrapped = /^(?:first|last)$/.test(methodName), lodashFunc = lodash[retUnwrapped ? "take" + (methodName == "last" ? "Right" : "") : methodName]; + if (!lodashFunc) { + return; + } + lodash.prototype[methodName] = function() { + var args = retUnwrapped ? [ 1 ] : arguments, chainAll = this.__chain__, value = this.__wrapped__, isHybrid = !!this.__actions__.length, isLazy = value instanceof LazyWrapper, iteratee = args[0], useLazy = isLazy || isArray(value); + if (useLazy && checkIteratee && typeof iteratee == "function" && iteratee.length != 1) { + isLazy = useLazy = false; } - var size = 0, stats = extend({}, options, { - id: cacheId - }), data = {}, capacity = options && options.capacity || Number.MAX_VALUE, lruHash = {}, freshEnd = null, staleEnd = null; - return caches[cacheId] = { - put: function(key, value) { - if (isUndefined(value)) return; - if (capacity < Number.MAX_VALUE) { - var lruEntry = lruHash[key] || (lruHash[key] = { - key: key - }); - refresh(lruEntry); - } - if (!(key in data)) size++; - data[key] = value; - if (size > capacity) { - this.remove(staleEnd.key); - } - return value; - }, - get: function(key) { - if (capacity < Number.MAX_VALUE) { - var lruEntry = lruHash[key]; - if (!lruEntry) return; - refresh(lruEntry); - } - return data[key]; - }, - remove: function(key) { - if (capacity < Number.MAX_VALUE) { - var lruEntry = lruHash[key]; - if (!lruEntry) return; - if (lruEntry == freshEnd) freshEnd = lruEntry.p; - if (lruEntry == staleEnd) staleEnd = lruEntry.n; - link(lruEntry.n, lruEntry.p); - delete lruHash[key]; - } - delete data[key]; - size--; - }, - removeAll: function() { - data = {}; - size = 0; - lruHash = {}; - freshEnd = staleEnd = null; - }, - destroy: function() { - data = null; - stats = null; - lruHash = null; - delete caches[cacheId]; - }, - info: function() { - return extend({}, stats, { - size: size - }); - } + var interceptor = function(value) { + return retUnwrapped && chainAll ? lodashFunc(value, 1)[0] : lodashFunc.apply(undefined, arrayPush([ value ], args)); }; - function refresh(entry) { - if (entry != freshEnd) { - if (!staleEnd) { - staleEnd = entry; - } else if (staleEnd == entry) { - staleEnd = entry.n; - } - link(entry.n, entry.p); - link(entry, freshEnd); - freshEnd = entry; - freshEnd.n = null; - } - } - function link(nextEntry, prevEntry) { - if (nextEntry != prevEntry) { - if (nextEntry) nextEntry.p = prevEntry; - if (prevEntry) prevEntry.n = nextEntry; - } - } - } - cacheFactory.info = function() { - var info = {}; - forEach(caches, function(cache, cacheId) { - info[cacheId] = cache.info(); - }); - return info; + var action = { + func: thru, + args: [ interceptor ], + thisArg: undefined + }, onlyLazy = isLazy && !isHybrid; + if (retUnwrapped && !chainAll) { + if (onlyLazy) { + value = value.clone(); + value.__actions__.push(action); + return func.call(value); + } + return lodashFunc.call(undefined, this.value())[0]; + } + if (!retUnwrapped && useLazy) { + value = onlyLazy ? value : new LazyWrapper(this); + var result = func.apply(value, args); + result.__actions__.push(action); + return new LodashWrapper(result, chainAll); + } + return this.thru(interceptor); }; - cacheFactory.get = function(cacheId) { - return caches[cacheId]; + }); + arrayEach([ "join", "pop", "push", "replace", "shift", "sort", "splice", "split", "unshift" ], function(methodName) { + var func = (/^(?:replace|split)$/.test(methodName) ? stringProto : arrayProto)[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? "tap" : "thru", retUnwrapped = /^(?:join|pop|replace|shift)$/.test(methodName); + lodash.prototype[methodName] = function() { + var args = arguments; + if (retUnwrapped && !this.__chain__) { + return func.apply(this.value(), args); + } + return this[chainName](function(value) { + return func.apply(value, args); + }); }; - return cacheFactory; - }; - } - function $TemplateCacheProvider() { - this.$get = [ "$cacheFactory", function($cacheFactory) { - return $cacheFactory("templates"); + }); + baseForOwn(LazyWrapper.prototype, function(func, methodName) { + var lodashFunc = lodash[methodName]; + if (lodashFunc) { + var key = lodashFunc.name + "", names = realNames[key] || (realNames[key] = []); + names.push({ + name: methodName, + func: lodashFunc + }); + } + }); + realNames[createHybridWrapper(undefined, BIND_KEY_FLAG).name] = [ { + name: "wrapper", + func: undefined } ]; + LazyWrapper.prototype.clone = lazyClone; + LazyWrapper.prototype.reverse = lazyReverse; + LazyWrapper.prototype.value = lazyValue; + lodash.prototype.chain = wrapperChain; + lodash.prototype.commit = wrapperCommit; + lodash.prototype.concat = wrapperConcat; + lodash.prototype.plant = wrapperPlant; + lodash.prototype.reverse = wrapperReverse; + lodash.prototype.toString = wrapperToString; + lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; + lodash.prototype.collect = lodash.prototype.map; + lodash.prototype.head = lodash.prototype.first; + lodash.prototype.select = lodash.prototype.filter; + lodash.prototype.tail = lodash.prototype.rest; + return lodash; + } + var _ = runInContext(); + if (typeof define == "function" && typeof define.amd == "object" && define.amd) { + root._ = _; + define(function() { + return _; + }); + } else if (freeExports && freeModule) { + if (moduleExports) { + (freeModule.exports = _)._ = _; + } else { + freeExports._ = _; + } + } else { + root._ = _; } - var $compileMinErr = minErr("$compile"); - $CompileProvider.$inject = [ "$provide", "$$sanitizeUriProvider" ]; - function $CompileProvider($provide, $$sanitizeUriProvider) { - var hasDirectives = {}, Suffix = "Directive", COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\w\-]+)\s+(.*)$/, CLASS_DIRECTIVE_REGEXP = /(([\w\-]+)(?:\:([^;]+))?;?)/, ALL_OR_NOTHING_ATTRS = makeMap("ngSrc,ngSrcset,src,srcset"), REQUIRE_PREFIX_REGEXP = /^(?:(\^\^?)?(\?)?(\^\^?)?)?/; - var EVENT_HANDLER_ATTR_REGEXP = /^(on[a-z]+|formaction)$/; - function parseIsolateBindings(scope, directiveName, isController) { - var LOCAL_REGEXP = /^\s*([@&]|=(\*?))(\??)\s*(\w*)\s*$/; - var bindings = {}; - forEach(scope, function(definition, scopeName) { - var match = definition.match(LOCAL_REGEXP); - if (!match) { - throw $compileMinErr("iscp", "Invalid {3} for directive '{0}'." + " Definition: {... {1}: '{2}' ...}", directiveName, scopeName, definition, isController ? "controller bindings definition" : "isolate scope definition"); - } - bindings[scopeName] = { - mode: match[1][0], - collection: match[2] === "*", - optional: match[3] === "?", - attrName: match[4] || scopeName - }; - }); - return bindings; - } - function parseDirectiveBindings(directive, directiveName) { - var bindings = { - isolateScope: null, - bindToController: null - }; - if (isObject(directive.scope)) { - if (directive.bindToController === true) { - bindings.bindToController = parseIsolateBindings(directive.scope, directiveName, true); - bindings.isolateScope = {}; - } else { - bindings.isolateScope = parseIsolateBindings(directive.scope, directiveName, false); - } - } - if (isObject(directive.bindToController)) { - bindings.bindToController = parseIsolateBindings(directive.bindToController, directiveName, true); - } - if (isObject(bindings.bindToController)) { - var controller = directive.controller; - var controllerAs = directive.controllerAs; - if (!controller) { - throw $compileMinErr("noctrl", "Cannot bind to controller without directive '{0}'s controller.", directiveName); - } else if (!identifierForController(controller, controllerAs)) { - throw $compileMinErr("noident", "Cannot bind to controller without identifier for directive '{0}'.", directiveName); +}).call(this); + +(function(window, document, undefined) { + "use strict"; + function minErr(module, ErrorConstructor) { + ErrorConstructor = ErrorConstructor || Error; + return function() { + var SKIP_INDEXES = 2; + var templateArgs = arguments, code = templateArgs[0], message = "[" + (module ? module + ":" : "") + code + "] ", template = templateArgs[1], paramPrefix, i; + message += template.replace(/\{\d+\}/g, function(match) { + var index = +match.slice(1, -1), shiftedIndex = index + SKIP_INDEXES; + if (shiftedIndex < templateArgs.length) { + return toDebugString(templateArgs[shiftedIndex]); } + return match; + }); + message += "\nhttp://errors.angularjs.org/1.4.7/" + (module ? module + "/" : "") + code; + for (i = SKIP_INDEXES, paramPrefix = "?"; i < templateArgs.length; i++, paramPrefix = "&") { + message += paramPrefix + "p" + (i - SKIP_INDEXES) + "=" + encodeURIComponent(toDebugString(templateArgs[i])); } - return bindings; + return new ErrorConstructor(message); + }; + } + var REGEX_STRING_REGEXP = /^\/(.+)\/([a-z]*)$/; + var VALIDITY_STATE_PROPERTY = "validity"; + var lowercase = function(string) { + return isString(string) ? string.toLowerCase() : string; + }; + var hasOwnProperty = Object.prototype.hasOwnProperty; + var uppercase = function(string) { + return isString(string) ? string.toUpperCase() : string; + }; + var manualLowercase = function(s) { + return isString(s) ? s.replace(/[A-Z]/g, function(ch) { + return String.fromCharCode(ch.charCodeAt(0) | 32); + }) : s; + }; + var manualUppercase = function(s) { + return isString(s) ? s.replace(/[a-z]/g, function(ch) { + return String.fromCharCode(ch.charCodeAt(0) & ~32); + }) : s; + }; + if ("i" !== "I".toLowerCase()) { + lowercase = manualLowercase; + uppercase = manualUppercase; + } + var msie, jqLite, jQuery, slice = [].slice, splice = [].splice, push = [].push, toString = Object.prototype.toString, getPrototypeOf = Object.getPrototypeOf, ngMinErr = minErr("ng"), angular = window.angular || (window.angular = {}), angularModule, uid = 0; + msie = document.documentMode; + function isArrayLike(obj) { + if (obj == null || isWindow(obj)) { + return false; } - function assertValidDirectiveName(name) { - var letter = name.charAt(0); - if (!letter || letter !== lowercase(letter)) { - throw $compileMinErr("baddir", "Directive name '{0}' is invalid. The first character must be a lowercase letter", name); - } - if (name !== name.trim()) { - throw $compileMinErr("baddir", "Directive name '{0}' is invalid. The name should not contain leading or trailing whitespaces", name); - } + var length = "length" in Object(obj) && obj.length; + if (obj.nodeType === NODE_TYPE_ELEMENT && length) { + return true; } - this.directive = function registerDirective(name, directiveFactory) { - assertNotHasOwnProperty(name, "directive"); - if (isString(name)) { - assertValidDirectiveName(name); - assertArg(directiveFactory, "directiveFactory"); - if (!hasDirectives.hasOwnProperty(name)) { - hasDirectives[name] = []; - $provide.factory(name + Suffix, [ "$injector", "$exceptionHandler", function($injector, $exceptionHandler) { - var directives = []; - forEach(hasDirectives[name], function(directiveFactory, index) { - try { - var directive = $injector.invoke(directiveFactory); - if (isFunction(directive)) { - directive = { - compile: valueFn(directive) - }; - } else if (!directive.compile && directive.link) { - directive.compile = valueFn(directive.link); - } - directive.priority = directive.priority || 0; - directive.index = index; - directive.name = directive.name || name; - directive.require = directive.require || directive.controller && directive.name; - directive.restrict = directive.restrict || "EA"; - var bindings = directive.$$bindings = parseDirectiveBindings(directive, directive.name); - if (isObject(bindings.isolateScope)) { - directive.$$isolateBindings = bindings.isolateScope; - } - directive.$$moduleName = directiveFactory.$$moduleName; - directives.push(directive); - } catch (e) { - $exceptionHandler(e); - } - }); - return directives; - } ]); + return isString(obj) || isArray(obj) || length === 0 || typeof length === "number" && length > 0 && length - 1 in obj; + } + function forEach(obj, iterator, context) { + var key, length; + if (obj) { + if (isFunction(obj)) { + for (key in obj) { + if (key != "prototype" && key != "length" && key != "name" && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) { + iterator.call(context, obj[key], key, obj); + } + } + } else if (isArray(obj) || isArrayLike(obj)) { + var isPrimitive = typeof obj !== "object"; + for (key = 0, length = obj.length; key < length; key++) { + if (isPrimitive || key in obj) { + iterator.call(context, obj[key], key, obj); + } + } + } else if (obj.forEach && obj.forEach !== forEach) { + obj.forEach(iterator, context, obj); + } else if (isBlankObject(obj)) { + for (key in obj) { + iterator.call(context, obj[key], key, obj); + } + } else if (typeof obj.hasOwnProperty === "function") { + for (key in obj) { + if (obj.hasOwnProperty(key)) { + iterator.call(context, obj[key], key, obj); + } } - hasDirectives[name].push(directiveFactory); - } else { - forEach(name, reverseParams(registerDirective)); - } - return this; - }; - this.aHrefSanitizationWhitelist = function(regexp) { - if (isDefined(regexp)) { - $$sanitizeUriProvider.aHrefSanitizationWhitelist(regexp); - return this; - } else { - return $$sanitizeUriProvider.aHrefSanitizationWhitelist(); - } - }; - this.imgSrcSanitizationWhitelist = function(regexp) { - if (isDefined(regexp)) { - $$sanitizeUriProvider.imgSrcSanitizationWhitelist(regexp); - return this; } else { - return $$sanitizeUriProvider.imgSrcSanitizationWhitelist(); - } - }; - var debugInfoEnabled = true; - this.debugInfoEnabled = function(enabled) { - if (isDefined(enabled)) { - debugInfoEnabled = enabled; - return this; + for (key in obj) { + if (hasOwnProperty.call(obj, key)) { + iterator.call(context, obj[key], key, obj); + } + } } - return debugInfoEnabled; + } + return obj; + } + function forEachSorted(obj, iterator, context) { + var keys = Object.keys(obj).sort(); + for (var i = 0; i < keys.length; i++) { + iterator.call(context, obj[keys[i]], keys[i]); + } + return keys; + } + function reverseParams(iteratorFn) { + return function(value, key) { + iteratorFn(key, value); }; - this.$get = [ "$injector", "$interpolate", "$exceptionHandler", "$templateRequest", "$parse", "$controller", "$rootScope", "$document", "$sce", "$animate", "$$sanitizeUri", function($injector, $interpolate, $exceptionHandler, $templateRequest, $parse, $controller, $rootScope, $document, $sce, $animate, $$sanitizeUri) { - var Attributes = function(element, attributesToCopy) { - if (attributesToCopy) { - var keys = Object.keys(attributesToCopy); - var i, l, key; - for (i = 0, l = keys.length; i < l; i++) { - key = keys[i]; - this[key] = attributesToCopy[key]; + } + function nextUid() { + return ++uid; + } + function setHashKey(obj, h) { + if (h) { + obj.$$hashKey = h; + } else { + delete obj.$$hashKey; + } + } + function baseExtend(dst, objs, deep) { + var h = dst.$$hashKey; + for (var i = 0, ii = objs.length; i < ii; ++i) { + var obj = objs[i]; + if (!isObject(obj) && !isFunction(obj)) continue; + var keys = Object.keys(obj); + for (var j = 0, jj = keys.length; j < jj; j++) { + var key = keys[j]; + var src = obj[key]; + if (deep && isObject(src)) { + if (isDate(src)) { + dst[key] = new Date(src.valueOf()); + } else if (isRegExp(src)) { + dst[key] = new RegExp(src); + } else { + if (!isObject(dst[key])) dst[key] = isArray(src) ? [] : {}; + baseExtend(dst[key], [ src ], true); } } else { - this.$attr = {}; + dst[key] = src; } - this.$$element = element; - }; - Attributes.prototype = { - $normalize: directiveNormalize, - $addClass: function(classVal) { - if (classVal && classVal.length > 0) { - $animate.addClass(this.$$element, classVal); - } - }, - $removeClass: function(classVal) { - if (classVal && classVal.length > 0) { - $animate.removeClass(this.$$element, classVal); - } - }, - $updateClass: function(newClasses, oldClasses) { - var toAdd = tokenDifference(newClasses, oldClasses); - if (toAdd && toAdd.length) { - $animate.addClass(this.$$element, toAdd); - } - var toRemove = tokenDifference(oldClasses, newClasses); - if (toRemove && toRemove.length) { - $animate.removeClass(this.$$element, toRemove); - } - }, - $set: function(key, value, writeAttr, attrName) { - var node = this.$$element[0], booleanKey = getBooleanAttrName(node, key), aliasedKey = getAliasedAttrName(key), observer = key, nodeName; - if (booleanKey) { - this.$$element.prop(key, value); - attrName = booleanKey; - } else if (aliasedKey) { - this[aliasedKey] = value; - observer = aliasedKey; - } - this[key] = value; - if (attrName) { - this.$attr[key] = attrName; - } else { - attrName = this.$attr[key]; - if (!attrName) { - this.$attr[key] = attrName = snake_case(key, "-"); - } + } + } + setHashKey(dst, h); + return dst; + } + function extend(dst) { + return baseExtend(dst, slice.call(arguments, 1), false); + } + function merge(dst) { + return baseExtend(dst, slice.call(arguments, 1), true); + } + function toInt(str) { + return parseInt(str, 10); + } + function inherit(parent, extra) { + return extend(Object.create(parent), extra); + } + function noop() {} + noop.$inject = []; + function identity($) { + return $; + } + identity.$inject = []; + function valueFn(value) { + return function() { + return value; + }; + } + function hasCustomToString(obj) { + return isFunction(obj.toString) && obj.toString !== Object.prototype.toString; + } + function isUndefined(value) { + return typeof value === "undefined"; + } + function isDefined(value) { + return typeof value !== "undefined"; + } + function isObject(value) { + return value !== null && typeof value === "object"; + } + function isBlankObject(value) { + return value !== null && typeof value === "object" && !getPrototypeOf(value); + } + function isString(value) { + return typeof value === "string"; + } + function isNumber(value) { + return typeof value === "number"; + } + function isDate(value) { + return toString.call(value) === "[object Date]"; + } + var isArray = Array.isArray; + function isFunction(value) { + return typeof value === "function"; + } + function isRegExp(value) { + return toString.call(value) === "[object RegExp]"; + } + function isWindow(obj) { + return obj && obj.window === obj; + } + function isScope(obj) { + return obj && obj.$evalAsync && obj.$watch; + } + function isFile(obj) { + return toString.call(obj) === "[object File]"; + } + function isFormData(obj) { + return toString.call(obj) === "[object FormData]"; + } + function isBlob(obj) { + return toString.call(obj) === "[object Blob]"; + } + function isBoolean(value) { + return typeof value === "boolean"; + } + function isPromiseLike(obj) { + return obj && isFunction(obj.then); + } + var TYPED_ARRAY_REGEXP = /^\[object (Uint8(Clamped)?)|(Uint16)|(Uint32)|(Int8)|(Int16)|(Int32)|(Float(32)|(64))Array\]$/; + function isTypedArray(value) { + return TYPED_ARRAY_REGEXP.test(toString.call(value)); + } + var trim = function(value) { + return isString(value) ? value.trim() : value; + }; + var escapeForRegexp = function(s) { + return s.replace(/([-()\[\]{}+?*.$\^|,:#= 0) { + array.splice(index, 1); + } + return index; + } + function copy(source, destination, stackSource, stackDest) { + if (isWindow(source) || isScope(source)) { + throw ngMinErr("cpws", "Can't copy! Making copies of Window or Scope instances is not supported."); + } + if (isTypedArray(destination)) { + throw ngMinErr("cpta", "Can't copy! TypedArray destination cannot be mutated."); + } + if (!destination) { + destination = source; + if (isObject(source)) { + var index; + if (stackSource && (index = stackSource.indexOf(source)) !== -1) { + return stackDest[index]; + } + if (isArray(source)) { + return copy(source, [], stackSource, stackDest); + } else if (isTypedArray(source)) { + destination = new source.constructor(source); + } else if (isDate(source)) { + destination = new Date(source.getTime()); + } else if (isRegExp(source)) { + destination = new RegExp(source.source, source.toString().match(/[^\/]*$/)[0]); + destination.lastIndex = source.lastIndex; + } else if (isFunction(source.cloneNode)) { + destination = source.cloneNode(true); + } else { + var emptyObject = Object.create(getPrototypeOf(source)); + return copy(source, emptyObject, stackSource, stackDest); + } + if (stackDest) { + stackSource.push(source); + stackDest.push(destination); + } + } + } else { + if (source === destination) throw ngMinErr("cpi", "Can't copy! Source and destination are identical."); + stackSource = stackSource || []; + stackDest = stackDest || []; + if (isObject(source)) { + stackSource.push(source); + stackDest.push(destination); + } + var result, key; + if (isArray(source)) { + destination.length = 0; + for (var i = 0; i < source.length; i++) { + destination.push(copy(source[i], null, stackSource, stackDest)); + } + } else { + var h = destination.$$hashKey; + if (isArray(destination)) { + destination.length = 0; + } else { + forEach(destination, function(value, key) { + delete destination[key]; + }); + } + if (isBlankObject(source)) { + for (key in source) { + destination[key] = copy(source[key], null, stackSource, stackDest); } - nodeName = nodeName_(this.$$element); - if (nodeName === "a" && key === "href" || nodeName === "img" && key === "src") { - this[key] = value = $$sanitizeUri(value, key === "src"); - } else if (nodeName === "img" && key === "srcset") { - var result = ""; - var trimmedSrcset = trim(value); - var srcPattern = /(\s+\d+x\s*,|\s+\d+w\s*,|\s+,|,\s+)/; - var pattern = /\s/.test(trimmedSrcset) ? srcPattern : /(,)/; - var rawUris = trimmedSrcset.split(pattern); - var nbrUrisWith2parts = Math.floor(rawUris.length / 2); - for (var i = 0; i < nbrUrisWith2parts; i++) { - var innerIdx = i * 2; - result += $$sanitizeUri(trim(rawUris[innerIdx]), true); - result += " " + trim(rawUris[innerIdx + 1]); - } - var lastTuple = trim(rawUris[i * 2]).split(/\s/); - result += $$sanitizeUri(trim(lastTuple[0]), true); - if (lastTuple.length === 2) { - result += " " + trim(lastTuple[1]); + } else if (source && typeof source.hasOwnProperty === "function") { + for (key in source) { + if (source.hasOwnProperty(key)) { + destination[key] = copy(source[key], null, stackSource, stackDest); } - this[key] = value = result; } - if (writeAttr !== false) { - if (value === null || isUndefined(value)) { - this.$$element.removeAttr(attrName); - } else { - this.$$element.attr(attrName, value); + } else { + for (key in source) { + if (hasOwnProperty.call(source, key)) { + destination[key] = copy(source[key], null, stackSource, stackDest); } } - var $$observers = this.$$observers; - $$observers && forEach($$observers[observer], function(fn) { - try { - fn(value); - } catch (e) { - $exceptionHandler(e); - } - }); - }, - $observe: function(key, fn) { - var attrs = this, $$observers = attrs.$$observers || (attrs.$$observers = createMap()), listeners = $$observers[key] || ($$observers[key] = []); - listeners.push(fn); - $rootScope.$evalAsync(function() { - if (!listeners.$$inter && attrs.hasOwnProperty(key) && !isUndefined(attrs[key])) { - fn(attrs[key]); - } - }); - return function() { - arrayRemove(listeners, fn); - }; } - }; - function safeAddClass($element, className) { - try { - $element.addClass(className); - } catch (e) {} + setHashKey(destination, h); } - var startSymbol = $interpolate.startSymbol(), endSymbol = $interpolate.endSymbol(), denormalizeTemplate = startSymbol == "{{" || endSymbol == "}}" ? identity : function denormalizeTemplate(template) { - return template.replace(/\{\{/g, startSymbol).replace(/}}/g, endSymbol); - }, NG_ATTR_BINDING = /^ngAttr[A-Z]/; - compile.$$addBindingInfo = debugInfoEnabled ? function $$addBindingInfo($element, binding) { - var bindings = $element.data("$binding") || []; - if (isArray(binding)) { - bindings = bindings.concat(binding); - } else { - bindings.push(binding); - } - $element.data("$binding", bindings); - } : noop; - compile.$$addBindingClass = debugInfoEnabled ? function $$addBindingClass($element) { - safeAddClass($element, "ng-binding"); - } : noop; - compile.$$addScopeInfo = debugInfoEnabled ? function $$addScopeInfo($element, scope, isolated, noTemplate) { - var dataName = isolated ? noTemplate ? "$isolateScopeNoTemplate" : "$isolateScope" : "$scope"; - $element.data(dataName, scope); - } : noop; - compile.$$addScopeClass = debugInfoEnabled ? function $$addScopeClass($element, isolated) { - safeAddClass($element, isolated ? "ng-isolate-scope" : "ng-scope"); - } : noop; - return compile; - function compile($compileNodes, transcludeFn, maxPriority, ignoreDirective, previousCompileContext) { - if (!($compileNodes instanceof jqLite)) { - $compileNodes = jqLite($compileNodes); - } - forEach($compileNodes, function(node, index) { - if (node.nodeType == NODE_TYPE_TEXT && node.nodeValue.match(/\S+/)) { - $compileNodes[index] = jqLite(node).wrap("").parent()[0]; - } - }); - var compositeLinkFn = compileNodes($compileNodes, transcludeFn, $compileNodes, maxPriority, ignoreDirective, previousCompileContext); - compile.$$addScopeClass($compileNodes); - var namespace = null; - return function publicLinkFn(scope, cloneConnectFn, options) { - assertArg(scope, "scope"); - options = options || {}; - var parentBoundTranscludeFn = options.parentBoundTranscludeFn, transcludeControllers = options.transcludeControllers, futureParentElement = options.futureParentElement; - if (parentBoundTranscludeFn && parentBoundTranscludeFn.$$boundTransclude) { - parentBoundTranscludeFn = parentBoundTranscludeFn.$$boundTransclude; - } - if (!namespace) { - namespace = detectNamespaceForChildElements(futureParentElement); - } - var $linkNode; - if (namespace !== "html") { - $linkNode = jqLite(wrapTemplate(namespace, jqLite("
").append($compileNodes).html())); - } else if (cloneConnectFn) { - $linkNode = JQLitePrototype.clone.call($compileNodes); - } else { - $linkNode = $compileNodes; - } - if (transcludeControllers) { - for (var controllerName in transcludeControllers) { - $linkNode.data("$" + controllerName + "Controller", transcludeControllers[controllerName].instance); - } - } - compile.$$addScopeInfo($linkNode, scope); - if (cloneConnectFn) cloneConnectFn($linkNode, scope); - if (compositeLinkFn) compositeLinkFn(scope, $linkNode, $linkNode, parentBoundTranscludeFn); - return $linkNode; - }; + } + return destination; + } + function shallowCopy(src, dst) { + if (isArray(src)) { + dst = dst || []; + for (var i = 0, ii = src.length; i < ii; i++) { + dst[i] = src[i]; } - function detectNamespaceForChildElements(parentElement) { - var node = parentElement && parentElement[0]; - if (!node) { - return "html"; - } else { - return nodeName_(node) !== "foreignobject" && node.toString().match(/SVG/) ? "svg" : "html"; + } else if (isObject(src)) { + dst = dst || {}; + for (var key in src) { + if (!(key.charAt(0) === "$" && key.charAt(1) === "$")) { + dst[key] = src[key]; } } - function compileNodes(nodeList, transcludeFn, $rootElement, maxPriority, ignoreDirective, previousCompileContext) { - var linkFns = [], attrs, directives, nodeLinkFn, childNodes, childLinkFn, linkFnFound, nodeLinkFnFound; - for (var i = 0; i < nodeList.length; i++) { - attrs = new Attributes(); - directives = collectDirectives(nodeList[i], [], attrs, i === 0 ? maxPriority : undefined, ignoreDirective); - nodeLinkFn = directives.length ? applyDirectivesToNode(directives, nodeList[i], attrs, transcludeFn, $rootElement, null, [], [], previousCompileContext) : null; - if (nodeLinkFn && nodeLinkFn.scope) { - compile.$$addScopeClass(attrs.$$element); - } - childLinkFn = nodeLinkFn && nodeLinkFn.terminal || !(childNodes = nodeList[i].childNodes) || !childNodes.length ? null : compileNodes(childNodes, nodeLinkFn ? (nodeLinkFn.transcludeOnThisElement || !nodeLinkFn.templateOnThisElement) && nodeLinkFn.transclude : transcludeFn); - if (nodeLinkFn || childLinkFn) { - linkFns.push(i, nodeLinkFn, childLinkFn); - linkFnFound = true; - nodeLinkFnFound = nodeLinkFnFound || nodeLinkFn; - } - previousCompileContext = null; - } - return linkFnFound ? compositeLinkFn : null; - function compositeLinkFn(scope, nodeList, $rootElement, parentBoundTranscludeFn) { - var nodeLinkFn, childLinkFn, node, childScope, i, ii, idx, childBoundTranscludeFn; - var stableNodeList; - if (nodeLinkFnFound) { - var nodeListLength = nodeList.length; - stableNodeList = new Array(nodeListLength); - for (i = 0; i < linkFns.length; i += 3) { - idx = linkFns[i]; - stableNodeList[idx] = nodeList[idx]; + } + return dst || src; + } + function equals(o1, o2) { + if (o1 === o2) return true; + if (o1 === null || o2 === null) return false; + if (o1 !== o1 && o2 !== o2) return true; + var t1 = typeof o1, t2 = typeof o2, length, key, keySet; + if (t1 == t2) { + if (t1 == "object") { + if (isArray(o1)) { + if (!isArray(o2)) return false; + if ((length = o1.length) == o2.length) { + for (key = 0; key < length; key++) { + if (!equals(o1[key], o2[key])) return false; } - } else { - stableNodeList = nodeList; + return true; } - for (i = 0, ii = linkFns.length; i < ii; ) { - node = stableNodeList[linkFns[i++]]; - nodeLinkFn = linkFns[i++]; - childLinkFn = linkFns[i++]; - if (nodeLinkFn) { - if (nodeLinkFn.scope) { - childScope = scope.$new(); - compile.$$addScopeInfo(jqLite(node), childScope); - var destroyBindings = nodeLinkFn.$$destroyBindings; - if (destroyBindings) { - nodeLinkFn.$$destroyBindings = null; - childScope.$on("$destroyed", destroyBindings); - } - } else { - childScope = scope; - } - if (nodeLinkFn.transcludeOnThisElement) { - childBoundTranscludeFn = createBoundTranscludeFn(scope, nodeLinkFn.transclude, parentBoundTranscludeFn); - } else if (!nodeLinkFn.templateOnThisElement && parentBoundTranscludeFn) { - childBoundTranscludeFn = parentBoundTranscludeFn; - } else if (!parentBoundTranscludeFn && transcludeFn) { - childBoundTranscludeFn = createBoundTranscludeFn(scope, transcludeFn); - } else { - childBoundTranscludeFn = null; - } - nodeLinkFn(childLinkFn, childScope, node, $rootElement, childBoundTranscludeFn, nodeLinkFn); - } else if (childLinkFn) { - childLinkFn(scope, node.childNodes, undefined, parentBoundTranscludeFn); - } + } else if (isDate(o1)) { + if (!isDate(o2)) return false; + return equals(o1.getTime(), o2.getTime()); + } else if (isRegExp(o1)) { + return isRegExp(o2) ? o1.toString() == o2.toString() : false; + } else { + if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2) || isArray(o2) || isDate(o2) || isRegExp(o2)) return false; + keySet = createMap(); + for (key in o1) { + if (key.charAt(0) === "$" || isFunction(o1[key])) continue; + if (!equals(o1[key], o2[key])) return false; + keySet[key] = true; + } + for (key in o2) { + if (!(key in keySet) && key.charAt(0) !== "$" && isDefined(o2[key]) && !isFunction(o2[key])) return false; } + return true; } } - function createBoundTranscludeFn(scope, transcludeFn, previousBoundTranscludeFn) { - var boundTranscludeFn = function(transcludedScope, cloneFn, controllers, futureParentElement, containingScope) { - if (!transcludedScope) { - transcludedScope = scope.$new(false, containingScope); - transcludedScope.$$transcluded = true; - } - return transcludeFn(transcludedScope, cloneFn, { - parentBoundTranscludeFn: previousBoundTranscludeFn, - transcludeControllers: controllers, - futureParentElement: futureParentElement - }); + } + return false; + } + var csp = function() { + if (!isDefined(csp.rules)) { + var ngCspElement = document.querySelector("[ng-csp]") || document.querySelector("[data-ng-csp]"); + if (ngCspElement) { + var ngCspAttribute = ngCspElement.getAttribute("ng-csp") || ngCspElement.getAttribute("data-ng-csp"); + csp.rules = { + noUnsafeEval: !ngCspAttribute || ngCspAttribute.indexOf("no-unsafe-eval") !== -1, + noInlineStyle: !ngCspAttribute || ngCspAttribute.indexOf("no-inline-style") !== -1 + }; + } else { + csp.rules = { + noUnsafeEval: noUnsafeEval(), + noInlineStyle: false }; - return boundTranscludeFn; } - function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) { - var nodeType = node.nodeType, attrsMap = attrs.$attr, match, className; - switch (nodeType) { - case NODE_TYPE_ELEMENT: - addDirective(directives, directiveNormalize(nodeName_(node)), "E", maxPriority, ignoreDirective); - for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes, j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) { - var attrStartName = false; - var attrEndName = false; - attr = nAttrs[j]; - name = attr.name; - value = trim(attr.value); - ngAttrName = directiveNormalize(name); - if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) { - name = name.replace(PREFIX_REGEXP, "").substr(8).replace(/_(.)/g, function(match, letter) { - return letter.toUpperCase(); - }); - } - var directiveNName = ngAttrName.replace(/(Start|End)$/, ""); - if (directiveIsMultiElement(directiveNName)) { - if (ngAttrName === directiveNName + "Start") { - attrStartName = name; - attrEndName = name.substr(0, name.length - 5) + "end"; - name = name.substr(0, name.length - 6); - } - } - nName = directiveNormalize(name.toLowerCase()); - attrsMap[nName] = name; - if (isNgAttr || !attrs.hasOwnProperty(nName)) { - attrs[nName] = value; - if (getBooleanAttrName(node, nName)) { - attrs[nName] = true; - } - } - addAttrInterpolateDirective(node, directives, value, nName, isNgAttr); - addDirective(directives, nName, "A", maxPriority, ignoreDirective, attrStartName, attrEndName); - } - className = node.className; - if (isObject(className)) { - className = className.animVal; - } - if (isString(className) && className !== "") { - while (match = CLASS_DIRECTIVE_REGEXP.exec(className)) { - nName = directiveNormalize(match[2]); - if (addDirective(directives, nName, "C", maxPriority, ignoreDirective)) { - attrs[nName] = trim(match[3]); - } - className = className.substr(match.index + match[0].length); - } - } - break; - - case NODE_TYPE_TEXT: - if (msie === 11) { - while (node.parentNode && node.nextSibling && node.nextSibling.nodeType === NODE_TYPE_TEXT) { - node.nodeValue = node.nodeValue + node.nextSibling.nodeValue; - node.parentNode.removeChild(node.nextSibling); - } - } + } + return csp.rules; + function noUnsafeEval() { + try { + new Function(""); + return false; + } catch (e) { + return true; + } + } + }; + var jq = function() { + if (isDefined(jq.name_)) return jq.name_; + var el; + var i, ii = ngAttrPrefixes.length, prefix, name; + for (i = 0; i < ii; ++i) { + prefix = ngAttrPrefixes[i]; + if (el = document.querySelector("[" + prefix.replace(":", "\\:") + "jq]")) { + name = el.getAttribute(prefix + "jq"); + break; + } + } + return jq.name_ = name; + }; + function concat(array1, array2, index) { + return array1.concat(slice.call(array2, index)); + } + function sliceArgs(args, startIndex) { + return slice.call(args, startIndex || 0); + } + function bind(self, fn) { + var curryArgs = arguments.length > 2 ? sliceArgs(arguments, 2) : []; + if (isFunction(fn) && !(fn instanceof RegExp)) { + return curryArgs.length ? function() { + return arguments.length ? fn.apply(self, concat(curryArgs, arguments, 0)) : fn.apply(self, curryArgs); + } : function() { + return arguments.length ? fn.apply(self, arguments) : fn.call(self); + }; + } else { + return fn; + } + } + function toJsonReplacer(key, value) { + var val = value; + if (typeof key === "string" && key.charAt(0) === "$" && key.charAt(1) === "$") { + val = undefined; + } else if (isWindow(value)) { + val = "$WINDOW"; + } else if (value && document === value) { + val = "$DOCUMENT"; + } else if (isScope(value)) { + val = "$SCOPE"; + } + return val; + } + function toJson(obj, pretty) { + if (typeof obj === "undefined") return undefined; + if (!isNumber(pretty)) { + pretty = pretty ? 2 : null; + } + return JSON.stringify(obj, toJsonReplacer, pretty); + } + function fromJson(json) { + return isString(json) ? JSON.parse(json) : json; + } + function timezoneToOffset(timezone, fallback) { + var requestedTimezoneOffset = Date.parse("Jan 01, 1970 00:00:00 " + timezone) / 6e4; + return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset; + } + function addDateMinutes(date, minutes) { + date = new Date(date.getTime()); + date.setMinutes(date.getMinutes() + minutes); + return date; + } + function convertTimezoneToLocal(date, timezone, reverse) { + reverse = reverse ? -1 : 1; + var timezoneOffset = timezoneToOffset(timezone, date.getTimezoneOffset()); + return addDateMinutes(date, reverse * (timezoneOffset - date.getTimezoneOffset())); + } + function startingTag(element) { + element = jqLite(element).clone(); + try { + element.empty(); + } catch (e) {} + var elemHtml = jqLite("
").append(element).html(); + try { + return element[0].nodeType === NODE_TYPE_TEXT ? lowercase(elemHtml) : elemHtml.match(/^(<[^>]+>)/)[1].replace(/^<([\w\-]+)/, function(match, nodeName) { + return "<" + lowercase(nodeName); + }); + } catch (e) { + return lowercase(elemHtml); + } + } + function tryDecodeURIComponent(value) { + try { + return decodeURIComponent(value); + } catch (e) {} + } + function parseKeyValue(keyValue) { + var obj = {}; + forEach((keyValue || "").split("&"), function(keyValue) { + var splitPoint, key, val; + if (keyValue) { + key = keyValue = keyValue.replace(/\+/g, "%20"); + splitPoint = keyValue.indexOf("="); + if (splitPoint !== -1) { + key = keyValue.substring(0, splitPoint); + val = keyValue.substring(splitPoint + 1); + } + key = tryDecodeURIComponent(key); + if (isDefined(key)) { + val = isDefined(val) ? tryDecodeURIComponent(val) : true; + if (!hasOwnProperty.call(obj, key)) { + obj[key] = val; + } else if (isArray(obj[key])) { + obj[key].push(val); + } else { + obj[key] = [ obj[key], val ]; + } + } + } + }); + return obj; + } + function toKeyValue(obj) { + var parts = []; + forEach(obj, function(value, key) { + if (isArray(value)) { + forEach(value, function(arrayValue) { + parts.push(encodeUriQuery(key, true) + (arrayValue === true ? "" : "=" + encodeUriQuery(arrayValue, true))); + }); + } else { + parts.push(encodeUriQuery(key, true) + (value === true ? "" : "=" + encodeUriQuery(value, true))); + } + }); + return parts.length ? parts.join("&") : ""; + } + function encodeUriSegment(val) { + return encodeUriQuery(val, true).replace(/%26/gi, "&").replace(/%3D/gi, "=").replace(/%2B/gi, "+"); + } + function encodeUriQuery(val, pctEncodeSpaces) { + return encodeURIComponent(val).replace(/%40/gi, "@").replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%3B/gi, ";").replace(/%20/g, pctEncodeSpaces ? "%20" : "+"); + } + var ngAttrPrefixes = [ "ng-", "data-ng-", "ng:", "x-ng-" ]; + function getNgAttribute(element, ngAttr) { + var attr, i, ii = ngAttrPrefixes.length; + for (i = 0; i < ii; ++i) { + attr = ngAttrPrefixes[i] + ngAttr; + if (isString(attr = element.getAttribute(attr))) { + return attr; + } + } + return null; + } + function angularInit(element, bootstrap) { + var appElement, module, config = {}; + forEach(ngAttrPrefixes, function(prefix) { + var name = prefix + "app"; + if (!appElement && element.hasAttribute && element.hasAttribute(name)) { + appElement = element; + module = element.getAttribute(name); + } + }); + forEach(ngAttrPrefixes, function(prefix) { + var name = prefix + "app"; + var candidate; + if (!appElement && (candidate = element.querySelector("[" + name.replace(":", "\\:") + "]"))) { + appElement = candidate; + module = candidate.getAttribute(name); + } + }); + if (appElement) { + config.strictDi = getNgAttribute(appElement, "strict-di") !== null; + bootstrap(appElement, module ? [ module ] : [], config); + } + } + function bootstrap(element, modules, config) { + if (!isObject(config)) config = {}; + var defaultConfig = { + strictDi: false + }; + config = extend(defaultConfig, config); + var doBootstrap = function() { + element = jqLite(element); + if (element.injector()) { + var tag = element[0] === document ? "document" : startingTag(element); + throw ngMinErr("btstrpd", "App Already Bootstrapped with this Element '{0}'", tag.replace(//, ">")); + } + modules = modules || []; + modules.unshift([ "$provide", function($provide) { + $provide.value("$rootElement", element); + } ]); + if (config.debugInfoEnabled) { + modules.push([ "$compileProvider", function($compileProvider) { + $compileProvider.debugInfoEnabled(true); + } ]); + } + modules.unshift("ng"); + var injector = createInjector(modules, config.strictDi); + injector.invoke([ "$rootScope", "$rootElement", "$compile", "$injector", function bootstrapApply(scope, element, compile, injector) { + scope.$apply(function() { + element.data("$injector", injector); + compile(element)(scope); + }); + } ]); + return injector; + }; + var NG_ENABLE_DEBUG_INFO = /^NG_ENABLE_DEBUG_INFO!/; + var NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/; + if (window && NG_ENABLE_DEBUG_INFO.test(window.name)) { + config.debugInfoEnabled = true; + window.name = window.name.replace(NG_ENABLE_DEBUG_INFO, ""); + } + if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) { + return doBootstrap(); + } + window.name = window.name.replace(NG_DEFER_BOOTSTRAP, ""); + angular.resumeBootstrap = function(extraModules) { + forEach(extraModules, function(module) { + modules.push(module); + }); + return doBootstrap(); + }; + if (isFunction(angular.resumeDeferredBootstrap)) { + angular.resumeDeferredBootstrap(); + } + } + function reloadWithDebugInfo() { + window.name = "NG_ENABLE_DEBUG_INFO!" + window.name; + window.location.reload(); + } + function getTestability(rootElement) { + var injector = angular.element(rootElement).injector(); + if (!injector) { + throw ngMinErr("test", "no injector found for element argument to getTestability"); + } + return injector.get("$$testability"); + } + var SNAKE_CASE_REGEXP = /[A-Z]/g; + function snake_case(name, separator) { + separator = separator || "_"; + return name.replace(SNAKE_CASE_REGEXP, function(letter, pos) { + return (pos ? separator : "") + letter.toLowerCase(); + }); + } + var bindJQueryFired = false; + var skipDestroyOnNextJQueryCleanData; + function bindJQuery() { + var originalCleanData; + if (bindJQueryFired) { + return; + } + var jqName = jq(); + jQuery = isUndefined(jqName) ? window.jQuery : !jqName ? undefined : window[jqName]; + if (jQuery && jQuery.fn.on) { + jqLite = jQuery; + extend(jQuery.fn, { + scope: JQLitePrototype.scope, + isolateScope: JQLitePrototype.isolateScope, + controller: JQLitePrototype.controller, + injector: JQLitePrototype.injector, + inheritedData: JQLitePrototype.inheritedData + }); + originalCleanData = jQuery.cleanData; + jQuery.cleanData = function(elems) { + var events; + if (!skipDestroyOnNextJQueryCleanData) { + for (var i = 0, elem; (elem = elems[i]) != null; i++) { + events = jQuery._data(elem, "events"); + if (events && events.$destroy) { + jQuery(elem).triggerHandler("$destroy"); + } + } + } else { + skipDestroyOnNextJQueryCleanData = false; + } + originalCleanData(elems); + }; + } else { + jqLite = JQLite; + } + angular.element = jqLite; + bindJQueryFired = true; + } + function assertArg(arg, name, reason) { + if (!arg) { + throw ngMinErr("areq", "Argument '{0}' is {1}", name || "?", reason || "required"); + } + return arg; + } + function assertArgFn(arg, name, acceptArrayAnnotation) { + if (acceptArrayAnnotation && isArray(arg)) { + arg = arg[arg.length - 1]; + } + assertArg(isFunction(arg), name, "not a function, got " + (arg && typeof arg === "object" ? arg.constructor.name || "Object" : typeof arg)); + return arg; + } + function assertNotHasOwnProperty(name, context) { + if (name === "hasOwnProperty") { + throw ngMinErr("badname", "hasOwnProperty is not a valid {0} name", context); + } + } + function getter(obj, path, bindFnToScope) { + if (!path) return obj; + var keys = path.split("."); + var key; + var lastInstance = obj; + var len = keys.length; + for (var i = 0; i < len; i++) { + key = keys[i]; + if (obj) { + obj = (lastInstance = obj)[key]; + } + } + if (!bindFnToScope && isFunction(obj)) { + return bind(lastInstance, obj); + } + return obj; + } + function getBlockNodes(nodes) { + var node = nodes[0]; + var endNode = nodes[nodes.length - 1]; + var blockNodes; + for (var i = 1; node !== endNode && (node = node.nextSibling); i++) { + if (blockNodes || nodes[i] !== node) { + if (!blockNodes) { + blockNodes = jqLite(slice.call(nodes, 0, i)); + } + blockNodes.push(node); + } + } + return blockNodes || nodes; + } + function createMap() { + return Object.create(null); + } + var NODE_TYPE_ELEMENT = 1; + var NODE_TYPE_ATTRIBUTE = 2; + var NODE_TYPE_TEXT = 3; + var NODE_TYPE_COMMENT = 8; + var NODE_TYPE_DOCUMENT = 9; + var NODE_TYPE_DOCUMENT_FRAGMENT = 11; + function setupModuleLoader(window) { + var $injectorMinErr = minErr("$injector"); + var ngMinErr = minErr("ng"); + function ensure(obj, name, factory) { + return obj[name] || (obj[name] = factory()); + } + var angular = ensure(window, "angular", Object); + angular.$$minErr = angular.$$minErr || minErr; + return ensure(angular, "module", function() { + var modules = {}; + return function module(name, requires, configFn) { + var assertNotHasOwnProperty = function(name, context) { + if (name === "hasOwnProperty") { + throw ngMinErr("badname", "hasOwnProperty is not a valid {0} name", context); + } + }; + assertNotHasOwnProperty(name, "module"); + if (requires && modules.hasOwnProperty(name)) { + modules[name] = null; + } + return ensure(modules, name, function() { + if (!requires) { + throw $injectorMinErr("nomod", "Module '{0}' is not available! You either misspelled " + "the module name or forgot to load it. If registering a module ensure that you " + "specify the dependencies as the second argument.", name); + } + var invokeQueue = []; + var configBlocks = []; + var runBlocks = []; + var config = invokeLater("$injector", "invoke", "push", configBlocks); + var moduleInstance = { + _invokeQueue: invokeQueue, + _configBlocks: configBlocks, + _runBlocks: runBlocks, + requires: requires, + name: name, + provider: invokeLaterAndSetModuleName("$provide", "provider"), + factory: invokeLaterAndSetModuleName("$provide", "factory"), + service: invokeLaterAndSetModuleName("$provide", "service"), + value: invokeLater("$provide", "value"), + constant: invokeLater("$provide", "constant", "unshift"), + decorator: invokeLaterAndSetModuleName("$provide", "decorator"), + animation: invokeLaterAndSetModuleName("$animateProvider", "register"), + filter: invokeLaterAndSetModuleName("$filterProvider", "register"), + controller: invokeLaterAndSetModuleName("$controllerProvider", "register"), + directive: invokeLaterAndSetModuleName("$compileProvider", "directive"), + config: config, + run: function(block) { + runBlocks.push(block); + return this; + } + }; + if (configFn) { + config(configFn); + } + return moduleInstance; + function invokeLater(provider, method, insertMethod, queue) { + if (!queue) queue = invokeQueue; + return function() { + queue[insertMethod || "push"]([ provider, method, arguments ]); + return moduleInstance; + }; + } + function invokeLaterAndSetModuleName(provider, method) { + return function(recipeName, factoryFunction) { + if (factoryFunction && isFunction(factoryFunction)) factoryFunction.$$moduleName = name; + invokeQueue.push([ provider, method, arguments ]); + return moduleInstance; + }; + } + }); + }; + }); + } + function serializeObject(obj) { + var seen = []; + return JSON.stringify(obj, function(key, val) { + val = toJsonReplacer(key, val); + if (isObject(val)) { + if (seen.indexOf(val) >= 0) return "..."; + seen.push(val); + } + return val; + }); + } + function toDebugString(obj) { + if (typeof obj === "function") { + return obj.toString().replace(/ \{[\s\S]*$/, ""); + } else if (isUndefined(obj)) { + return "undefined"; + } else if (typeof obj !== "string") { + return serializeObject(obj); + } + return obj; + } + var version = { + full: "1.4.7", + major: 1, + minor: 4, + dot: 7, + codeName: "dark-luminescence" + }; + function publishExternalAPI(angular) { + extend(angular, { + bootstrap: bootstrap, + copy: copy, + extend: extend, + merge: merge, + equals: equals, + element: jqLite, + forEach: forEach, + injector: createInjector, + noop: noop, + bind: bind, + toJson: toJson, + fromJson: fromJson, + identity: identity, + isUndefined: isUndefined, + isDefined: isDefined, + isString: isString, + isFunction: isFunction, + isObject: isObject, + isNumber: isNumber, + isElement: isElement, + isArray: isArray, + version: version, + isDate: isDate, + lowercase: lowercase, + uppercase: uppercase, + callbacks: { + counter: 0 + }, + getTestability: getTestability, + $$minErr: minErr, + $$csp: csp, + reloadWithDebugInfo: reloadWithDebugInfo + }); + angularModule = setupModuleLoader(window); + angularModule("ng", [ "ngLocale" ], [ "$provide", function ngModule($provide) { + $provide.provider({ + $$sanitizeUri: $$SanitizeUriProvider + }); + $provide.provider("$compile", $CompileProvider).directive({ + a: htmlAnchorDirective, + input: inputDirective, + textarea: inputDirective, + form: formDirective, + script: scriptDirective, + select: selectDirective, + style: styleDirective, + option: optionDirective, + ngBind: ngBindDirective, + ngBindHtml: ngBindHtmlDirective, + ngBindTemplate: ngBindTemplateDirective, + ngClass: ngClassDirective, + ngClassEven: ngClassEvenDirective, + ngClassOdd: ngClassOddDirective, + ngCloak: ngCloakDirective, + ngController: ngControllerDirective, + ngForm: ngFormDirective, + ngHide: ngHideDirective, + ngIf: ngIfDirective, + ngInclude: ngIncludeDirective, + ngInit: ngInitDirective, + ngNonBindable: ngNonBindableDirective, + ngPluralize: ngPluralizeDirective, + ngRepeat: ngRepeatDirective, + ngShow: ngShowDirective, + ngStyle: ngStyleDirective, + ngSwitch: ngSwitchDirective, + ngSwitchWhen: ngSwitchWhenDirective, + ngSwitchDefault: ngSwitchDefaultDirective, + ngOptions: ngOptionsDirective, + ngTransclude: ngTranscludeDirective, + ngModel: ngModelDirective, + ngList: ngListDirective, + ngChange: ngChangeDirective, + pattern: patternDirective, + ngPattern: patternDirective, + required: requiredDirective, + ngRequired: requiredDirective, + minlength: minlengthDirective, + ngMinlength: minlengthDirective, + maxlength: maxlengthDirective, + ngMaxlength: maxlengthDirective, + ngValue: ngValueDirective, + ngModelOptions: ngModelOptionsDirective + }).directive({ + ngInclude: ngIncludeFillContentDirective + }).directive(ngAttributeAliasDirectives).directive(ngEventDirectives); + $provide.provider({ + $anchorScroll: $AnchorScrollProvider, + $animate: $AnimateProvider, + $animateCss: $CoreAnimateCssProvider, + $$animateQueue: $$CoreAnimateQueueProvider, + $$AnimateRunner: $$CoreAnimateRunnerProvider, + $browser: $BrowserProvider, + $cacheFactory: $CacheFactoryProvider, + $controller: $ControllerProvider, + $document: $DocumentProvider, + $exceptionHandler: $ExceptionHandlerProvider, + $filter: $FilterProvider, + $$forceReflow: $$ForceReflowProvider, + $interpolate: $InterpolateProvider, + $interval: $IntervalProvider, + $http: $HttpProvider, + $httpParamSerializer: $HttpParamSerializerProvider, + $httpParamSerializerJQLike: $HttpParamSerializerJQLikeProvider, + $httpBackend: $HttpBackendProvider, + $xhrFactory: $xhrFactoryProvider, + $location: $LocationProvider, + $log: $LogProvider, + $parse: $ParseProvider, + $rootScope: $RootScopeProvider, + $q: $QProvider, + $$q: $$QProvider, + $sce: $SceProvider, + $sceDelegate: $SceDelegateProvider, + $sniffer: $SnifferProvider, + $templateCache: $TemplateCacheProvider, + $templateRequest: $TemplateRequestProvider, + $$testability: $$TestabilityProvider, + $timeout: $TimeoutProvider, + $window: $WindowProvider, + $$rAF: $$RAFProvider, + $$jqLite: $$jqLiteProvider, + $$HashMap: $$HashMapProvider, + $$cookieReader: $$CookieReaderProvider + }); + } ]); + } + JQLite.expando = "ng339"; + var jqCache = JQLite.cache = {}, jqId = 1, addEventListenerFn = function(element, type, fn) { + element.addEventListener(type, fn, false); + }, removeEventListenerFn = function(element, type, fn) { + element.removeEventListener(type, fn, false); + }; + JQLite._data = function(node) { + return this.cache[node[this.expando]] || {}; + }; + function jqNextId() { + return ++jqId; + } + var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g; + var MOZ_HACK_REGEXP = /^moz([A-Z])/; + var MOUSE_EVENT_MAP = { + mouseleave: "mouseout", + mouseenter: "mouseover" + }; + var jqLiteMinErr = minErr("jqLite"); + function camelCase(name) { + return name.replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) { + return offset ? letter.toUpperCase() : letter; + }).replace(MOZ_HACK_REGEXP, "Moz$1"); + } + var SINGLE_TAG_REGEXP = /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/; + var HTML_REGEXP = /<|&#?\w+;/; + var TAG_NAME_REGEXP = /<([\w:-]+)/; + var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi; + var wrapMap = { + option: [ 1, '" ], + thead: [ 1, "", "
" ], + col: [ 2, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + _default: [ 0, "", "" ] + }; + wrapMap.optgroup = wrapMap.option; + wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; + wrapMap.th = wrapMap.td; + function jqLiteIsTextNode(html) { + return !HTML_REGEXP.test(html); + } + function jqLiteAcceptsData(node) { + var nodeType = node.nodeType; + return nodeType === NODE_TYPE_ELEMENT || !nodeType || nodeType === NODE_TYPE_DOCUMENT; + } + function jqLiteHasData(node) { + for (var key in jqCache[node.ng339]) { + return true; + } + return false; + } + function jqLiteBuildFragment(html, context) { + var tmp, tag, wrap, fragment = context.createDocumentFragment(), nodes = [], i; + if (jqLiteIsTextNode(html)) { + nodes.push(context.createTextNode(html)); + } else { + tmp = tmp || fragment.appendChild(context.createElement("div")); + tag = (TAG_NAME_REGEXP.exec(html) || [ "", "" ])[1].toLowerCase(); + wrap = wrapMap[tag] || wrapMap._default; + tmp.innerHTML = wrap[1] + html.replace(XHTML_TAG_REGEXP, "<$1>") + wrap[2]; + i = wrap[0]; + while (i--) { + tmp = tmp.lastChild; + } + nodes = concat(nodes, tmp.childNodes); + tmp = fragment.firstChild; + tmp.textContent = ""; + } + fragment.textContent = ""; + fragment.innerHTML = ""; + forEach(nodes, function(node) { + fragment.appendChild(node); + }); + return fragment; + } + function jqLiteParseHTML(html, context) { + context = context || document; + var parsed; + if (parsed = SINGLE_TAG_REGEXP.exec(html)) { + return [ context.createElement(parsed[1]) ]; + } + if (parsed = jqLiteBuildFragment(html, context)) { + return parsed.childNodes; + } + return []; + } + function JQLite(element) { + if (element instanceof JQLite) { + return element; + } + var argIsString; + if (isString(element)) { + element = trim(element); + argIsString = true; + } + if (!(this instanceof JQLite)) { + if (argIsString && element.charAt(0) != "<") { + throw jqLiteMinErr("nosel", "Looking up elements via selectors is not supported by jqLite! See: http://docs.angularjs.org/api/angular.element"); + } + return new JQLite(element); + } + if (argIsString) { + jqLiteAddNodes(this, jqLiteParseHTML(element)); + } else { + jqLiteAddNodes(this, element); + } + } + function jqLiteClone(element) { + return element.cloneNode(true); + } + function jqLiteDealoc(element, onlyDescendants) { + if (!onlyDescendants) jqLiteRemoveData(element); + if (element.querySelectorAll) { + var descendants = element.querySelectorAll("*"); + for (var i = 0, l = descendants.length; i < l; i++) { + jqLiteRemoveData(descendants[i]); + } + } + } + function jqLiteOff(element, type, fn, unsupported) { + if (isDefined(unsupported)) throw jqLiteMinErr("offargs", "jqLite#off() does not support the `selector` argument"); + var expandoStore = jqLiteExpandoStore(element); + var events = expandoStore && expandoStore.events; + var handle = expandoStore && expandoStore.handle; + if (!handle) return; + if (!type) { + for (type in events) { + if (type !== "$destroy") { + removeEventListenerFn(element, type, handle); + } + delete events[type]; + } + } else { + forEach(type.split(" "), function(type) { + if (isDefined(fn)) { + var listenerFns = events[type]; + arrayRemove(listenerFns || [], fn); + if (listenerFns && listenerFns.length > 0) { + return; + } + } + removeEventListenerFn(element, type, handle); + delete events[type]; + }); + } + } + function jqLiteRemoveData(element, name) { + var expandoId = element.ng339; + var expandoStore = expandoId && jqCache[expandoId]; + if (expandoStore) { + if (name) { + delete expandoStore.data[name]; + return; + } + if (expandoStore.handle) { + if (expandoStore.events.$destroy) { + expandoStore.handle({}, "$destroy"); + } + jqLiteOff(element); + } + delete jqCache[expandoId]; + element.ng339 = undefined; + } + } + function jqLiteExpandoStore(element, createIfNecessary) { + var expandoId = element.ng339, expandoStore = expandoId && jqCache[expandoId]; + if (createIfNecessary && !expandoStore) { + element.ng339 = expandoId = jqNextId(); + expandoStore = jqCache[expandoId] = { + events: {}, + data: {}, + handle: undefined + }; + } + return expandoStore; + } + function jqLiteData(element, key, value) { + if (jqLiteAcceptsData(element)) { + var isSimpleSetter = isDefined(value); + var isSimpleGetter = !isSimpleSetter && key && !isObject(key); + var massGetter = !key; + var expandoStore = jqLiteExpandoStore(element, !isSimpleGetter); + var data = expandoStore && expandoStore.data; + if (isSimpleSetter) { + data[key] = value; + } else { + if (massGetter) { + return data; + } else { + if (isSimpleGetter) { + return data && data[key]; + } else { + extend(data, key); + } + } + } + } + } + function jqLiteHasClass(element, selector) { + if (!element.getAttribute) return false; + return (" " + (element.getAttribute("class") || "") + " ").replace(/[\n\t]/g, " ").indexOf(" " + selector + " ") > -1; + } + function jqLiteRemoveClass(element, cssClasses) { + if (cssClasses && element.setAttribute) { + forEach(cssClasses.split(" "), function(cssClass) { + element.setAttribute("class", trim((" " + (element.getAttribute("class") || "") + " ").replace(/[\n\t]/g, " ").replace(" " + trim(cssClass) + " ", " "))); + }); + } + } + function jqLiteAddClass(element, cssClasses) { + if (cssClasses && element.setAttribute) { + var existingClasses = (" " + (element.getAttribute("class") || "") + " ").replace(/[\n\t]/g, " "); + forEach(cssClasses.split(" "), function(cssClass) { + cssClass = trim(cssClass); + if (existingClasses.indexOf(" " + cssClass + " ") === -1) { + existingClasses += cssClass + " "; + } + }); + element.setAttribute("class", trim(existingClasses)); + } + } + function jqLiteAddNodes(root, elements) { + if (elements) { + if (elements.nodeType) { + root[root.length++] = elements; + } else { + var length = elements.length; + if (typeof length === "number" && elements.window !== elements) { + if (length) { + for (var i = 0; i < length; i++) { + root[root.length++] = elements[i]; + } + } + } else { + root[root.length++] = elements; + } + } + } + } + function jqLiteController(element, name) { + return jqLiteInheritedData(element, "$" + (name || "ngController") + "Controller"); + } + function jqLiteInheritedData(element, name, value) { + if (element.nodeType == NODE_TYPE_DOCUMENT) { + element = element.documentElement; + } + var names = isArray(name) ? name : [ name ]; + while (element) { + for (var i = 0, ii = names.length; i < ii; i++) { + if (isDefined(value = jqLite.data(element, names[i]))) return value; + } + element = element.parentNode || element.nodeType === NODE_TYPE_DOCUMENT_FRAGMENT && element.host; + } + } + function jqLiteEmpty(element) { + jqLiteDealoc(element, true); + while (element.firstChild) { + element.removeChild(element.firstChild); + } + } + function jqLiteRemove(element, keepData) { + if (!keepData) jqLiteDealoc(element); + var parent = element.parentNode; + if (parent) parent.removeChild(element); + } + function jqLiteDocumentLoaded(action, win) { + win = win || window; + if (win.document.readyState === "complete") { + win.setTimeout(action); + } else { + jqLite(win).on("load", action); + } + } + var JQLitePrototype = JQLite.prototype = { + ready: function(fn) { + var fired = false; + function trigger() { + if (fired) return; + fired = true; + fn(); + } + if (document.readyState === "complete") { + setTimeout(trigger); + } else { + this.on("DOMContentLoaded", trigger); + JQLite(window).on("load", trigger); + } + }, + toString: function() { + var value = []; + forEach(this, function(e) { + value.push("" + e); + }); + return "[" + value.join(", ") + "]"; + }, + eq: function(index) { + return index >= 0 ? jqLite(this[index]) : jqLite(this[this.length + index]); + }, + length: 0, + push: push, + sort: [].sort, + splice: [].splice + }; + var BOOLEAN_ATTR = {}; + forEach("multiple,selected,checked,disabled,readOnly,required,open".split(","), function(value) { + BOOLEAN_ATTR[lowercase(value)] = value; + }); + var BOOLEAN_ELEMENTS = {}; + forEach("input,select,option,textarea,button,form,details".split(","), function(value) { + BOOLEAN_ELEMENTS[value] = true; + }); + var ALIASED_ATTR = { + ngMinlength: "minlength", + ngMaxlength: "maxlength", + ngMin: "min", + ngMax: "max", + ngPattern: "pattern" + }; + function getBooleanAttrName(element, name) { + var booleanAttr = BOOLEAN_ATTR[name.toLowerCase()]; + return booleanAttr && BOOLEAN_ELEMENTS[nodeName_(element)] && booleanAttr; + } + function getAliasedAttrName(name) { + return ALIASED_ATTR[name]; + } + forEach({ + data: jqLiteData, + removeData: jqLiteRemoveData, + hasData: jqLiteHasData + }, function(fn, name) { + JQLite[name] = fn; + }); + forEach({ + data: jqLiteData, + inheritedData: jqLiteInheritedData, + scope: function(element) { + return jqLite.data(element, "$scope") || jqLiteInheritedData(element.parentNode || element, [ "$isolateScope", "$scope" ]); + }, + isolateScope: function(element) { + return jqLite.data(element, "$isolateScope") || jqLite.data(element, "$isolateScopeNoTemplate"); + }, + controller: jqLiteController, + injector: function(element) { + return jqLiteInheritedData(element, "$injector"); + }, + removeAttr: function(element, name) { + element.removeAttribute(name); + }, + hasClass: jqLiteHasClass, + css: function(element, name, value) { + name = camelCase(name); + if (isDefined(value)) { + element.style[name] = value; + } else { + return element.style[name]; + } + }, + attr: function(element, name, value) { + var nodeType = element.nodeType; + if (nodeType === NODE_TYPE_TEXT || nodeType === NODE_TYPE_ATTRIBUTE || nodeType === NODE_TYPE_COMMENT) { + return; + } + var lowercasedName = lowercase(name); + if (BOOLEAN_ATTR[lowercasedName]) { + if (isDefined(value)) { + if (!!value) { + element[name] = true; + element.setAttribute(name, lowercasedName); + } else { + element[name] = false; + element.removeAttribute(lowercasedName); + } + } else { + return element[name] || (element.attributes.getNamedItem(name) || noop).specified ? lowercasedName : undefined; + } + } else if (isDefined(value)) { + element.setAttribute(name, value); + } else if (element.getAttribute) { + var ret = element.getAttribute(name, 2); + return ret === null ? undefined : ret; + } + }, + prop: function(element, name, value) { + if (isDefined(value)) { + element[name] = value; + } else { + return element[name]; + } + }, + text: function() { + getText.$dv = ""; + return getText; + function getText(element, value) { + if (isUndefined(value)) { + var nodeType = element.nodeType; + return nodeType === NODE_TYPE_ELEMENT || nodeType === NODE_TYPE_TEXT ? element.textContent : ""; + } + element.textContent = value; + } + }(), + val: function(element, value) { + if (isUndefined(value)) { + if (element.multiple && nodeName_(element) === "select") { + var result = []; + forEach(element.options, function(option) { + if (option.selected) { + result.push(option.value || option.text); + } + }); + return result.length === 0 ? null : result; + } + return element.value; + } + element.value = value; + }, + html: function(element, value) { + if (isUndefined(value)) { + return element.innerHTML; + } + jqLiteDealoc(element, true); + element.innerHTML = value; + }, + empty: jqLiteEmpty + }, function(fn, name) { + JQLite.prototype[name] = function(arg1, arg2) { + var i, key; + var nodeCount = this.length; + if (fn !== jqLiteEmpty && isUndefined(fn.length == 2 && (fn !== jqLiteHasClass && fn !== jqLiteController) ? arg1 : arg2)) { + if (isObject(arg1)) { + for (i = 0; i < nodeCount; i++) { + if (fn === jqLiteData) { + fn(this[i], arg1); + } else { + for (key in arg1) { + fn(this[i], key, arg1[key]); + } + } + } + return this; + } else { + var value = fn.$dv; + var jj = isUndefined(value) ? Math.min(nodeCount, 1) : nodeCount; + for (var j = 0; j < jj; j++) { + var nodeValue = fn(this[j], arg1, arg2); + value = value ? value + nodeValue : nodeValue; + } + return value; + } + } else { + for (i = 0; i < nodeCount; i++) { + fn(this[i], arg1, arg2); + } + return this; + } + }; + }); + function createEventHandler(element, events) { + var eventHandler = function(event, type) { + event.isDefaultPrevented = function() { + return event.defaultPrevented; + }; + var eventFns = events[type || event.type]; + var eventFnsLength = eventFns ? eventFns.length : 0; + if (!eventFnsLength) return; + if (isUndefined(event.immediatePropagationStopped)) { + var originalStopImmediatePropagation = event.stopImmediatePropagation; + event.stopImmediatePropagation = function() { + event.immediatePropagationStopped = true; + if (event.stopPropagation) { + event.stopPropagation(); + } + if (originalStopImmediatePropagation) { + originalStopImmediatePropagation.call(event); + } + }; + } + event.isImmediatePropagationStopped = function() { + return event.immediatePropagationStopped === true; + }; + if (eventFnsLength > 1) { + eventFns = shallowCopy(eventFns); + } + for (var i = 0; i < eventFnsLength; i++) { + if (!event.isImmediatePropagationStopped()) { + eventFns[i].call(element, event); + } + } + }; + eventHandler.elem = element; + return eventHandler; + } + forEach({ + removeData: jqLiteRemoveData, + on: function jqLiteOn(element, type, fn, unsupported) { + if (isDefined(unsupported)) throw jqLiteMinErr("onargs", "jqLite#on() does not support the `selector` or `eventData` parameters"); + if (!jqLiteAcceptsData(element)) { + return; + } + var expandoStore = jqLiteExpandoStore(element, true); + var events = expandoStore.events; + var handle = expandoStore.handle; + if (!handle) { + handle = expandoStore.handle = createEventHandler(element, events); + } + var types = type.indexOf(" ") >= 0 ? type.split(" ") : [ type ]; + var i = types.length; + while (i--) { + type = types[i]; + var eventFns = events[type]; + if (!eventFns) { + events[type] = []; + if (type === "mouseenter" || type === "mouseleave") { + jqLiteOn(element, MOUSE_EVENT_MAP[type], function(event) { + var target = this, related = event.relatedTarget; + if (!related || related !== target && !target.contains(related)) { + handle(event, type); + } + }); + } else { + if (type !== "$destroy") { + addEventListenerFn(element, type, handle); + } + } + eventFns = events[type]; + } + eventFns.push(fn); + } + }, + off: jqLiteOff, + one: function(element, type, fn) { + element = jqLite(element); + element.on(type, function onFn() { + element.off(type, fn); + element.off(type, onFn); + }); + element.on(type, fn); + }, + replaceWith: function(element, replaceNode) { + var index, parent = element.parentNode; + jqLiteDealoc(element); + forEach(new JQLite(replaceNode), function(node) { + if (index) { + parent.insertBefore(node, index.nextSibling); + } else { + parent.replaceChild(node, element); + } + index = node; + }); + }, + children: function(element) { + var children = []; + forEach(element.childNodes, function(element) { + if (element.nodeType === NODE_TYPE_ELEMENT) { + children.push(element); + } + }); + return children; + }, + contents: function(element) { + return element.contentDocument || element.childNodes || []; + }, + append: function(element, node) { + var nodeType = element.nodeType; + if (nodeType !== NODE_TYPE_ELEMENT && nodeType !== NODE_TYPE_DOCUMENT_FRAGMENT) return; + node = new JQLite(node); + for (var i = 0, ii = node.length; i < ii; i++) { + var child = node[i]; + element.appendChild(child); + } + }, + prepend: function(element, node) { + if (element.nodeType === NODE_TYPE_ELEMENT) { + var index = element.firstChild; + forEach(new JQLite(node), function(child) { + element.insertBefore(child, index); + }); + } + }, + wrap: function(element, wrapNode) { + wrapNode = jqLite(wrapNode).eq(0).clone()[0]; + var parent = element.parentNode; + if (parent) { + parent.replaceChild(wrapNode, element); + } + wrapNode.appendChild(element); + }, + remove: jqLiteRemove, + detach: function(element) { + jqLiteRemove(element, true); + }, + after: function(element, newElement) { + var index = element, parent = element.parentNode; + newElement = new JQLite(newElement); + for (var i = 0, ii = newElement.length; i < ii; i++) { + var node = newElement[i]; + parent.insertBefore(node, index.nextSibling); + index = node; + } + }, + addClass: jqLiteAddClass, + removeClass: jqLiteRemoveClass, + toggleClass: function(element, selector, condition) { + if (selector) { + forEach(selector.split(" "), function(className) { + var classCondition = condition; + if (isUndefined(classCondition)) { + classCondition = !jqLiteHasClass(element, className); + } + (classCondition ? jqLiteAddClass : jqLiteRemoveClass)(element, className); + }); + } + }, + parent: function(element) { + var parent = element.parentNode; + return parent && parent.nodeType !== NODE_TYPE_DOCUMENT_FRAGMENT ? parent : null; + }, + next: function(element) { + return element.nextElementSibling; + }, + find: function(element, selector) { + if (element.getElementsByTagName) { + return element.getElementsByTagName(selector); + } else { + return []; + } + }, + clone: jqLiteClone, + triggerHandler: function(element, event, extraParameters) { + var dummyEvent, eventFnsCopy, handlerArgs; + var eventName = event.type || event; + var expandoStore = jqLiteExpandoStore(element); + var events = expandoStore && expandoStore.events; + var eventFns = events && events[eventName]; + if (eventFns) { + dummyEvent = { + preventDefault: function() { + this.defaultPrevented = true; + }, + isDefaultPrevented: function() { + return this.defaultPrevented === true; + }, + stopImmediatePropagation: function() { + this.immediatePropagationStopped = true; + }, + isImmediatePropagationStopped: function() { + return this.immediatePropagationStopped === true; + }, + stopPropagation: noop, + type: eventName, + target: element + }; + if (event.type) { + dummyEvent = extend(dummyEvent, event); + } + eventFnsCopy = shallowCopy(eventFns); + handlerArgs = extraParameters ? [ dummyEvent ].concat(extraParameters) : [ dummyEvent ]; + forEach(eventFnsCopy, function(fn) { + if (!dummyEvent.isImmediatePropagationStopped()) { + fn.apply(element, handlerArgs); + } + }); + } + } + }, function(fn, name) { + JQLite.prototype[name] = function(arg1, arg2, arg3) { + var value; + for (var i = 0, ii = this.length; i < ii; i++) { + if (isUndefined(value)) { + value = fn(this[i], arg1, arg2, arg3); + if (isDefined(value)) { + value = jqLite(value); + } + } else { + jqLiteAddNodes(value, fn(this[i], arg1, arg2, arg3)); + } + } + return isDefined(value) ? value : this; + }; + JQLite.prototype.bind = JQLite.prototype.on; + JQLite.prototype.unbind = JQLite.prototype.off; + }); + function $$jqLiteProvider() { + this.$get = function $$jqLite() { + return extend(JQLite, { + hasClass: function(node, classes) { + if (node.attr) node = node[0]; + return jqLiteHasClass(node, classes); + }, + addClass: function(node, classes) { + if (node.attr) node = node[0]; + return jqLiteAddClass(node, classes); + }, + removeClass: function(node, classes) { + if (node.attr) node = node[0]; + return jqLiteRemoveClass(node, classes); + } + }); + }; + } + function hashKey(obj, nextUidFn) { + var key = obj && obj.$$hashKey; + if (key) { + if (typeof key === "function") { + key = obj.$$hashKey(); + } + return key; + } + var objType = typeof obj; + if (objType == "function" || objType == "object" && obj !== null) { + key = obj.$$hashKey = objType + ":" + (nextUidFn || nextUid)(); + } else { + key = objType + ":" + obj; + } + return key; + } + function HashMap(array, isolatedUid) { + if (isolatedUid) { + var uid = 0; + this.nextUid = function() { + return ++uid; + }; + } + forEach(array, this.put, this); + } + HashMap.prototype = { + put: function(key, value) { + this[hashKey(key, this.nextUid)] = value; + }, + get: function(key) { + return this[hashKey(key, this.nextUid)]; + }, + remove: function(key) { + var value = this[key = hashKey(key, this.nextUid)]; + delete this[key]; + return value; + } + }; + var $$HashMapProvider = [ function() { + this.$get = [ function() { + return HashMap; + } ]; + } ]; + var FN_ARGS = /^[^\(]*\(\s*([^\)]*)\)/m; + var FN_ARG_SPLIT = /,/; + var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/; + var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm; + var $injectorMinErr = minErr("$injector"); + function anonFn(fn) { + var fnText = fn.toString().replace(STRIP_COMMENTS, ""), args = fnText.match(FN_ARGS); + if (args) { + return "function(" + (args[1] || "").replace(/[\s\r\n]+/, " ") + ")"; + } + return "fn"; + } + function annotate(fn, strictDi, name) { + var $inject, fnText, argDecl, last; + if (typeof fn === "function") { + if (!($inject = fn.$inject)) { + $inject = []; + if (fn.length) { + if (strictDi) { + if (!isString(name) || !name) { + name = fn.name || anonFn(fn); + } + throw $injectorMinErr("strictdi", "{0} is not using explicit annotation and cannot be invoked in strict mode", name); + } + fnText = fn.toString().replace(STRIP_COMMENTS, ""); + argDecl = fnText.match(FN_ARGS); + forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg) { + arg.replace(FN_ARG, function(all, underscore, name) { + $inject.push(name); + }); + }); + } + fn.$inject = $inject; + } + } else if (isArray(fn)) { + last = fn.length - 1; + assertArgFn(fn[last], "fn"); + $inject = fn.slice(0, last); + } else { + assertArgFn(fn, "fn", true); + } + return $inject; + } + function createInjector(modulesToLoad, strictDi) { + strictDi = strictDi === true; + var INSTANTIATING = {}, providerSuffix = "Provider", path = [], loadedModules = new HashMap([], true), providerCache = { + $provide: { + provider: supportObject(provider), + factory: supportObject(factory), + service: supportObject(service), + value: supportObject(value), + constant: supportObject(constant), + decorator: decorator + } + }, providerInjector = providerCache.$injector = createInternalInjector(providerCache, function(serviceName, caller) { + if (angular.isString(caller)) { + path.push(caller); + } + throw $injectorMinErr("unpr", "Unknown provider: {0}", path.join(" <- ")); + }), instanceCache = {}, instanceInjector = instanceCache.$injector = createInternalInjector(instanceCache, function(serviceName, caller) { + var provider = providerInjector.get(serviceName + providerSuffix, caller); + return instanceInjector.invoke(provider.$get, provider, undefined, serviceName); + }); + forEach(loadModules(modulesToLoad), function(fn) { + if (fn) instanceInjector.invoke(fn); + }); + return instanceInjector; + function supportObject(delegate) { + return function(key, value) { + if (isObject(key)) { + forEach(key, reverseParams(delegate)); + } else { + return delegate(key, value); + } + }; + } + function provider(name, provider_) { + assertNotHasOwnProperty(name, "service"); + if (isFunction(provider_) || isArray(provider_)) { + provider_ = providerInjector.instantiate(provider_); + } + if (!provider_.$get) { + throw $injectorMinErr("pget", "Provider '{0}' must define $get factory method.", name); + } + return providerCache[name + providerSuffix] = provider_; + } + function enforceReturnValue(name, factory) { + return function enforcedReturnValue() { + var result = instanceInjector.invoke(factory, this); + if (isUndefined(result)) { + throw $injectorMinErr("undef", "Provider '{0}' must return a value from $get factory method.", name); + } + return result; + }; + } + function factory(name, factoryFn, enforce) { + return provider(name, { + $get: enforce !== false ? enforceReturnValue(name, factoryFn) : factoryFn + }); + } + function service(name, constructor) { + return factory(name, [ "$injector", function($injector) { + return $injector.instantiate(constructor); + } ]); + } + function value(name, val) { + return factory(name, valueFn(val), false); + } + function constant(name, value) { + assertNotHasOwnProperty(name, "constant"); + providerCache[name] = value; + instanceCache[name] = value; + } + function decorator(serviceName, decorFn) { + var origProvider = providerInjector.get(serviceName + providerSuffix), orig$get = origProvider.$get; + origProvider.$get = function() { + var origInstance = instanceInjector.invoke(orig$get, origProvider); + return instanceInjector.invoke(decorFn, null, { + $delegate: origInstance + }); + }; + } + function loadModules(modulesToLoad) { + assertArg(isUndefined(modulesToLoad) || isArray(modulesToLoad), "modulesToLoad", "not an array"); + var runBlocks = [], moduleFn; + forEach(modulesToLoad, function(module) { + if (loadedModules.get(module)) return; + loadedModules.put(module, true); + function runInvokeQueue(queue) { + var i, ii; + for (i = 0, ii = queue.length; i < ii; i++) { + var invokeArgs = queue[i], provider = providerInjector.get(invokeArgs[0]); + provider[invokeArgs[1]].apply(provider, invokeArgs[2]); + } + } + try { + if (isString(module)) { + moduleFn = angularModule(module); + runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks); + runInvokeQueue(moduleFn._invokeQueue); + runInvokeQueue(moduleFn._configBlocks); + } else if (isFunction(module)) { + runBlocks.push(providerInjector.invoke(module)); + } else if (isArray(module)) { + runBlocks.push(providerInjector.invoke(module)); + } else { + assertArgFn(module, "module"); + } + } catch (e) { + if (isArray(module)) { + module = module[module.length - 1]; + } + if (e.message && e.stack && e.stack.indexOf(e.message) == -1) { + e = e.message + "\n" + e.stack; + } + throw $injectorMinErr("modulerr", "Failed to instantiate module {0} due to:\n{1}", module, e.stack || e.message || e); + } + }); + return runBlocks; + } + function createInternalInjector(cache, factory) { + function getService(serviceName, caller) { + if (cache.hasOwnProperty(serviceName)) { + if (cache[serviceName] === INSTANTIATING) { + throw $injectorMinErr("cdep", "Circular dependency found: {0}", serviceName + " <- " + path.join(" <- ")); + } + return cache[serviceName]; + } else { + try { + path.unshift(serviceName); + cache[serviceName] = INSTANTIATING; + return cache[serviceName] = factory(serviceName, caller); + } catch (err) { + if (cache[serviceName] === INSTANTIATING) { + delete cache[serviceName]; + } + throw err; + } finally { + path.shift(); + } + } + } + function invoke(fn, self, locals, serviceName) { + if (typeof locals === "string") { + serviceName = locals; + locals = null; + } + var args = [], $inject = createInjector.$$annotate(fn, strictDi, serviceName), length, i, key; + for (i = 0, length = $inject.length; i < length; i++) { + key = $inject[i]; + if (typeof key !== "string") { + throw $injectorMinErr("itkn", "Incorrect injection token! Expected service name as string, got {0}", key); + } + args.push(locals && locals.hasOwnProperty(key) ? locals[key] : getService(key, serviceName)); + } + if (isArray(fn)) { + fn = fn[length]; + } + return fn.apply(self, args); + } + function instantiate(Type, locals, serviceName) { + var instance = Object.create((isArray(Type) ? Type[Type.length - 1] : Type).prototype || null); + var returnedValue = invoke(Type, instance, locals, serviceName); + return isObject(returnedValue) || isFunction(returnedValue) ? returnedValue : instance; + } + return { + invoke: invoke, + instantiate: instantiate, + get: getService, + annotate: createInjector.$$annotate, + has: function(name) { + return providerCache.hasOwnProperty(name + providerSuffix) || cache.hasOwnProperty(name); + } + }; + } + } + createInjector.$$annotate = annotate; + function $AnchorScrollProvider() { + var autoScrollingEnabled = true; + this.disableAutoScrolling = function() { + autoScrollingEnabled = false; + }; + this.$get = [ "$window", "$location", "$rootScope", function($window, $location, $rootScope) { + var document = $window.document; + function getFirstAnchor(list) { + var result = null; + Array.prototype.some.call(list, function(element) { + if (nodeName_(element) === "a") { + result = element; + return true; + } + }); + return result; + } + function getYOffset() { + var offset = scroll.yOffset; + if (isFunction(offset)) { + offset = offset(); + } else if (isElement(offset)) { + var elem = offset[0]; + var style = $window.getComputedStyle(elem); + if (style.position !== "fixed") { + offset = 0; + } else { + offset = elem.getBoundingClientRect().bottom; + } + } else if (!isNumber(offset)) { + offset = 0; + } + return offset; + } + function scrollTo(elem) { + if (elem) { + elem.scrollIntoView(); + var offset = getYOffset(); + if (offset) { + var elemTop = elem.getBoundingClientRect().top; + $window.scrollBy(0, elemTop - offset); + } + } else { + $window.scrollTo(0, 0); + } + } + function scroll(hash) { + hash = isString(hash) ? hash : $location.hash(); + var elm; + if (!hash) scrollTo(null); else if (elm = document.getElementById(hash)) scrollTo(elm); else if (elm = getFirstAnchor(document.getElementsByName(hash))) scrollTo(elm); else if (hash === "top") scrollTo(null); + } + if (autoScrollingEnabled) { + $rootScope.$watch(function autoScrollWatch() { + return $location.hash(); + }, function autoScrollWatchAction(newVal, oldVal) { + if (newVal === oldVal && newVal === "") return; + jqLiteDocumentLoaded(function() { + $rootScope.$evalAsync(scroll); + }); + }); + } + return scroll; + } ]; + } + var $animateMinErr = minErr("$animate"); + var ELEMENT_NODE = 1; + var NG_ANIMATE_CLASSNAME = "ng-animate"; + function mergeClasses(a, b) { + if (!a && !b) return ""; + if (!a) return b; + if (!b) return a; + if (isArray(a)) a = a.join(" "); + if (isArray(b)) b = b.join(" "); + return a + " " + b; + } + function extractElementNode(element) { + for (var i = 0; i < element.length; i++) { + var elm = element[i]; + if (elm.nodeType === ELEMENT_NODE) { + return elm; + } + } + } + function splitClasses(classes) { + if (isString(classes)) { + classes = classes.split(" "); + } + var obj = createMap(); + forEach(classes, function(klass) { + if (klass.length) { + obj[klass] = true; + } + }); + return obj; + } + function prepareAnimateOptions(options) { + return isObject(options) ? options : {}; + } + var $$CoreAnimateRunnerProvider = function() { + this.$get = [ "$q", "$$rAF", function($q, $$rAF) { + function AnimateRunner() {} + AnimateRunner.all = noop; + AnimateRunner.chain = noop; + AnimateRunner.prototype = { + end: noop, + cancel: noop, + resume: noop, + pause: noop, + complete: noop, + then: function(pass, fail) { + return $q(function(resolve) { + $$rAF(function() { + resolve(); + }); + }).then(pass, fail); + } + }; + return AnimateRunner; + } ]; + }; + var $$CoreAnimateQueueProvider = function() { + var postDigestQueue = new HashMap(); + var postDigestElements = []; + this.$get = [ "$$AnimateRunner", "$rootScope", function($$AnimateRunner, $rootScope) { + return { + enabled: noop, + on: noop, + off: noop, + pin: noop, + push: function(element, event, options, domOperation) { + domOperation && domOperation(); + options = options || {}; + options.from && element.css(options.from); + options.to && element.css(options.to); + if (options.addClass || options.removeClass) { + addRemoveClassesPostDigest(element, options.addClass, options.removeClass); + } + return new $$AnimateRunner(); + } + }; + function updateData(data, classes, value) { + var changed = false; + if (classes) { + classes = isString(classes) ? classes.split(" ") : isArray(classes) ? classes : []; + forEach(classes, function(className) { + if (className) { + changed = true; + data[className] = value; + } + }); + } + return changed; + } + function handleCSSClassChanges() { + forEach(postDigestElements, function(element) { + var data = postDigestQueue.get(element); + if (data) { + var existing = splitClasses(element.attr("class")); + var toAdd = ""; + var toRemove = ""; + forEach(data, function(status, className) { + var hasClass = !!existing[className]; + if (status !== hasClass) { + if (status) { + toAdd += (toAdd.length ? " " : "") + className; + } else { + toRemove += (toRemove.length ? " " : "") + className; + } + } + }); + forEach(element, function(elm) { + toAdd && jqLiteAddClass(elm, toAdd); + toRemove && jqLiteRemoveClass(elm, toRemove); + }); + postDigestQueue.remove(element); + } + }); + postDigestElements.length = 0; + } + function addRemoveClassesPostDigest(element, add, remove) { + var data = postDigestQueue.get(element) || {}; + var classesAdded = updateData(data, add, true); + var classesRemoved = updateData(data, remove, false); + if (classesAdded || classesRemoved) { + postDigestQueue.put(element, data); + postDigestElements.push(element); + if (postDigestElements.length === 1) { + $rootScope.$$postDigest(handleCSSClassChanges); + } + } + } + } ]; + }; + var $AnimateProvider = [ "$provide", function($provide) { + var provider = this; + this.$$registeredAnimations = Object.create(null); + this.register = function(name, factory) { + if (name && name.charAt(0) !== ".") { + throw $animateMinErr("notcsel", "Expecting class selector starting with '.' got '{0}'.", name); + } + var key = name + "-animation"; + provider.$$registeredAnimations[name.substr(1)] = key; + $provide.factory(key, factory); + }; + this.classNameFilter = function(expression) { + if (arguments.length === 1) { + this.$$classNameFilter = expression instanceof RegExp ? expression : null; + if (this.$$classNameFilter) { + var reservedRegex = new RegExp("(\\s+|\\/)" + NG_ANIMATE_CLASSNAME + "(\\s+|\\/)"); + if (reservedRegex.test(this.$$classNameFilter.toString())) { + throw $animateMinErr("nongcls", '$animateProvider.classNameFilter(regex) prohibits accepting a regex value which matches/contains the "{0}" CSS class.', NG_ANIMATE_CLASSNAME); + } + } + } + return this.$$classNameFilter; + }; + this.$get = [ "$$animateQueue", function($$animateQueue) { + function domInsert(element, parentElement, afterElement) { + if (afterElement) { + var afterNode = extractElementNode(afterElement); + if (afterNode && !afterNode.parentNode && !afterNode.previousElementSibling) { + afterElement = null; + } + } + afterElement ? afterElement.after(element) : parentElement.prepend(element); + } + return { + on: $$animateQueue.on, + off: $$animateQueue.off, + pin: $$animateQueue.pin, + enabled: $$animateQueue.enabled, + cancel: function(runner) { + runner.end && runner.end(); + }, + enter: function(element, parent, after, options) { + parent = parent && jqLite(parent); + after = after && jqLite(after); + parent = parent || after.parent(); + domInsert(element, parent, after); + return $$animateQueue.push(element, "enter", prepareAnimateOptions(options)); + }, + move: function(element, parent, after, options) { + parent = parent && jqLite(parent); + after = after && jqLite(after); + parent = parent || after.parent(); + domInsert(element, parent, after); + return $$animateQueue.push(element, "move", prepareAnimateOptions(options)); + }, + leave: function(element, options) { + return $$animateQueue.push(element, "leave", prepareAnimateOptions(options), function() { + element.remove(); + }); + }, + addClass: function(element, className, options) { + options = prepareAnimateOptions(options); + options.addClass = mergeClasses(options.addclass, className); + return $$animateQueue.push(element, "addClass", options); + }, + removeClass: function(element, className, options) { + options = prepareAnimateOptions(options); + options.removeClass = mergeClasses(options.removeClass, className); + return $$animateQueue.push(element, "removeClass", options); + }, + setClass: function(element, add, remove, options) { + options = prepareAnimateOptions(options); + options.addClass = mergeClasses(options.addClass, add); + options.removeClass = mergeClasses(options.removeClass, remove); + return $$animateQueue.push(element, "setClass", options); + }, + animate: function(element, from, to, className, options) { + options = prepareAnimateOptions(options); + options.from = options.from ? extend(options.from, from) : from; + options.to = options.to ? extend(options.to, to) : to; + className = className || "ng-inline-animate"; + options.tempClasses = mergeClasses(options.tempClasses, className); + return $$animateQueue.push(element, "animate", options); + } + }; + } ]; + } ]; + var $CoreAnimateCssProvider = function() { + this.$get = [ "$$rAF", "$q", function($$rAF, $q) { + var RAFPromise = function() {}; + RAFPromise.prototype = { + done: function(cancel) { + this.defer && this.defer[cancel === true ? "reject" : "resolve"](); + }, + end: function() { + this.done(); + }, + cancel: function() { + this.done(true); + }, + getPromise: function() { + if (!this.defer) { + this.defer = $q.defer(); + } + return this.defer.promise; + }, + then: function(f1, f2) { + return this.getPromise().then(f1, f2); + }, + "catch": function(f1) { + return this.getPromise()["catch"](f1); + }, + "finally": function(f1) { + return this.getPromise()["finally"](f1); + } + }; + return function(element, options) { + if (options.cleanupStyles) { + options.from = options.to = null; + } + if (options.from) { + element.css(options.from); + options.from = null; + } + var closed, runner = new RAFPromise(); + return { + start: run, + end: run + }; + function run() { + $$rAF(function() { + close(); + if (!closed) { + runner.done(); + } + closed = true; + }); + return runner; + } + function close() { + if (options.addClass) { + element.addClass(options.addClass); + options.addClass = null; + } + if (options.removeClass) { + element.removeClass(options.removeClass); + options.removeClass = null; + } + if (options.to) { + element.css(options.to); + options.to = null; + } + } + }; + } ]; + }; + function Browser(window, document, $log, $sniffer) { + var self = this, rawDocument = document[0], location = window.location, history = window.history, setTimeout = window.setTimeout, clearTimeout = window.clearTimeout, pendingDeferIds = {}; + self.isMock = false; + var outstandingRequestCount = 0; + var outstandingRequestCallbacks = []; + self.$$completeOutstandingRequest = completeOutstandingRequest; + self.$$incOutstandingRequestCount = function() { + outstandingRequestCount++; + }; + function completeOutstandingRequest(fn) { + try { + fn.apply(null, sliceArgs(arguments, 1)); + } finally { + outstandingRequestCount--; + if (outstandingRequestCount === 0) { + while (outstandingRequestCallbacks.length) { + try { + outstandingRequestCallbacks.pop()(); + } catch (e) { + $log.error(e); + } + } + } + } + } + function getHash(url) { + var index = url.indexOf("#"); + return index === -1 ? "" : url.substr(index); + } + self.notifyWhenNoOutstandingRequests = function(callback) { + if (outstandingRequestCount === 0) { + callback(); + } else { + outstandingRequestCallbacks.push(callback); + } + }; + var cachedState, lastHistoryState, lastBrowserUrl = location.href, baseElement = document.find("base"), pendingLocation = null; + cacheState(); + lastHistoryState = cachedState; + self.url = function(url, replace, state) { + if (isUndefined(state)) { + state = null; + } + if (location !== window.location) location = window.location; + if (history !== window.history) history = window.history; + if (url) { + var sameState = lastHistoryState === state; + if (lastBrowserUrl === url && (!$sniffer.history || sameState)) { + return self; + } + var sameBase = lastBrowserUrl && stripHash(lastBrowserUrl) === stripHash(url); + lastBrowserUrl = url; + lastHistoryState = state; + if ($sniffer.history && (!sameBase || !sameState)) { + history[replace ? "replaceState" : "pushState"](state, "", url); + cacheState(); + lastHistoryState = cachedState; + } else { + if (!sameBase || pendingLocation) { + pendingLocation = url; + } + if (replace) { + location.replace(url); + } else if (!sameBase) { + location.href = url; + } else { + location.hash = getHash(url); + } + if (location.href !== url) { + pendingLocation = url; + } + } + return self; + } else { + return pendingLocation || location.href.replace(/%27/g, "'"); + } + }; + self.state = function() { + return cachedState; + }; + var urlChangeListeners = [], urlChangeInit = false; + function cacheStateAndFireUrlChange() { + pendingLocation = null; + cacheState(); + fireUrlChange(); + } + function getCurrentState() { + try { + return history.state; + } catch (e) {} + } + var lastCachedState = null; + function cacheState() { + cachedState = getCurrentState(); + cachedState = isUndefined(cachedState) ? null : cachedState; + if (equals(cachedState, lastCachedState)) { + cachedState = lastCachedState; + } + lastCachedState = cachedState; + } + function fireUrlChange() { + if (lastBrowserUrl === self.url() && lastHistoryState === cachedState) { + return; + } + lastBrowserUrl = self.url(); + lastHistoryState = cachedState; + forEach(urlChangeListeners, function(listener) { + listener(self.url(), cachedState); + }); + } + self.onUrlChange = function(callback) { + if (!urlChangeInit) { + if ($sniffer.history) jqLite(window).on("popstate", cacheStateAndFireUrlChange); + jqLite(window).on("hashchange", cacheStateAndFireUrlChange); + urlChangeInit = true; + } + urlChangeListeners.push(callback); + return callback; + }; + self.$$applicationDestroyed = function() { + jqLite(window).off("hashchange popstate", cacheStateAndFireUrlChange); + }; + self.$$checkUrlChange = fireUrlChange; + self.baseHref = function() { + var href = baseElement.attr("href"); + return href ? href.replace(/^(https?\:)?\/\/[^\/]*/, "") : ""; + }; + self.defer = function(fn, delay) { + var timeoutId; + outstandingRequestCount++; + timeoutId = setTimeout(function() { + delete pendingDeferIds[timeoutId]; + completeOutstandingRequest(fn); + }, delay || 0); + pendingDeferIds[timeoutId] = true; + return timeoutId; + }; + self.defer.cancel = function(deferId) { + if (pendingDeferIds[deferId]) { + delete pendingDeferIds[deferId]; + clearTimeout(deferId); + completeOutstandingRequest(noop); + return true; + } + return false; + }; + } + function $BrowserProvider() { + this.$get = [ "$window", "$log", "$sniffer", "$document", function($window, $log, $sniffer, $document) { + return new Browser($window, $document, $log, $sniffer); + } ]; + } + function $CacheFactoryProvider() { + this.$get = function() { + var caches = {}; + function cacheFactory(cacheId, options) { + if (cacheId in caches) { + throw minErr("$cacheFactory")("iid", "CacheId '{0}' is already taken!", cacheId); + } + var size = 0, stats = extend({}, options, { + id: cacheId + }), data = {}, capacity = options && options.capacity || Number.MAX_VALUE, lruHash = {}, freshEnd = null, staleEnd = null; + return caches[cacheId] = { + put: function(key, value) { + if (isUndefined(value)) return; + if (capacity < Number.MAX_VALUE) { + var lruEntry = lruHash[key] || (lruHash[key] = { + key: key + }); + refresh(lruEntry); + } + if (!(key in data)) size++; + data[key] = value; + if (size > capacity) { + this.remove(staleEnd.key); + } + return value; + }, + get: function(key) { + if (capacity < Number.MAX_VALUE) { + var lruEntry = lruHash[key]; + if (!lruEntry) return; + refresh(lruEntry); + } + return data[key]; + }, + remove: function(key) { + if (capacity < Number.MAX_VALUE) { + var lruEntry = lruHash[key]; + if (!lruEntry) return; + if (lruEntry == freshEnd) freshEnd = lruEntry.p; + if (lruEntry == staleEnd) staleEnd = lruEntry.n; + link(lruEntry.n, lruEntry.p); + delete lruHash[key]; + } + delete data[key]; + size--; + }, + removeAll: function() { + data = {}; + size = 0; + lruHash = {}; + freshEnd = staleEnd = null; + }, + destroy: function() { + data = null; + stats = null; + lruHash = null; + delete caches[cacheId]; + }, + info: function() { + return extend({}, stats, { + size: size + }); + } + }; + function refresh(entry) { + if (entry != freshEnd) { + if (!staleEnd) { + staleEnd = entry; + } else if (staleEnd == entry) { + staleEnd = entry.n; + } + link(entry.n, entry.p); + link(entry, freshEnd); + freshEnd = entry; + freshEnd.n = null; + } + } + function link(nextEntry, prevEntry) { + if (nextEntry != prevEntry) { + if (nextEntry) nextEntry.p = prevEntry; + if (prevEntry) prevEntry.n = nextEntry; + } + } + } + cacheFactory.info = function() { + var info = {}; + forEach(caches, function(cache, cacheId) { + info[cacheId] = cache.info(); + }); + return info; + }; + cacheFactory.get = function(cacheId) { + return caches[cacheId]; + }; + return cacheFactory; + }; + } + function $TemplateCacheProvider() { + this.$get = [ "$cacheFactory", function($cacheFactory) { + return $cacheFactory("templates"); + } ]; + } + var $compileMinErr = minErr("$compile"); + $CompileProvider.$inject = [ "$provide", "$$sanitizeUriProvider" ]; + function $CompileProvider($provide, $$sanitizeUriProvider) { + var hasDirectives = {}, Suffix = "Directive", COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\w\-]+)\s+(.*)$/, CLASS_DIRECTIVE_REGEXP = /(([\w\-]+)(?:\:([^;]+))?;?)/, ALL_OR_NOTHING_ATTRS = makeMap("ngSrc,ngSrcset,src,srcset"), REQUIRE_PREFIX_REGEXP = /^(?:(\^\^?)?(\?)?(\^\^?)?)?/; + var EVENT_HANDLER_ATTR_REGEXP = /^(on[a-z]+|formaction)$/; + function parseIsolateBindings(scope, directiveName, isController) { + var LOCAL_REGEXP = /^\s*([@&]|=(\*?))(\??)\s*(\w*)\s*$/; + var bindings = {}; + forEach(scope, function(definition, scopeName) { + var match = definition.match(LOCAL_REGEXP); + if (!match) { + throw $compileMinErr("iscp", "Invalid {3} for directive '{0}'." + " Definition: {... {1}: '{2}' ...}", directiveName, scopeName, definition, isController ? "controller bindings definition" : "isolate scope definition"); + } + bindings[scopeName] = { + mode: match[1][0], + collection: match[2] === "*", + optional: match[3] === "?", + attrName: match[4] || scopeName + }; + }); + return bindings; + } + function parseDirectiveBindings(directive, directiveName) { + var bindings = { + isolateScope: null, + bindToController: null + }; + if (isObject(directive.scope)) { + if (directive.bindToController === true) { + bindings.bindToController = parseIsolateBindings(directive.scope, directiveName, true); + bindings.isolateScope = {}; + } else { + bindings.isolateScope = parseIsolateBindings(directive.scope, directiveName, false); + } + } + if (isObject(directive.bindToController)) { + bindings.bindToController = parseIsolateBindings(directive.bindToController, directiveName, true); + } + if (isObject(bindings.bindToController)) { + var controller = directive.controller; + var controllerAs = directive.controllerAs; + if (!controller) { + throw $compileMinErr("noctrl", "Cannot bind to controller without directive '{0}'s controller.", directiveName); + } else if (!identifierForController(controller, controllerAs)) { + throw $compileMinErr("noident", "Cannot bind to controller without identifier for directive '{0}'.", directiveName); + } + } + return bindings; + } + function assertValidDirectiveName(name) { + var letter = name.charAt(0); + if (!letter || letter !== lowercase(letter)) { + throw $compileMinErr("baddir", "Directive name '{0}' is invalid. The first character must be a lowercase letter", name); + } + if (name !== name.trim()) { + throw $compileMinErr("baddir", "Directive name '{0}' is invalid. The name should not contain leading or trailing whitespaces", name); + } + } + this.directive = function registerDirective(name, directiveFactory) { + assertNotHasOwnProperty(name, "directive"); + if (isString(name)) { + assertValidDirectiveName(name); + assertArg(directiveFactory, "directiveFactory"); + if (!hasDirectives.hasOwnProperty(name)) { + hasDirectives[name] = []; + $provide.factory(name + Suffix, [ "$injector", "$exceptionHandler", function($injector, $exceptionHandler) { + var directives = []; + forEach(hasDirectives[name], function(directiveFactory, index) { + try { + var directive = $injector.invoke(directiveFactory); + if (isFunction(directive)) { + directive = { + compile: valueFn(directive) + }; + } else if (!directive.compile && directive.link) { + directive.compile = valueFn(directive.link); + } + directive.priority = directive.priority || 0; + directive.index = index; + directive.name = directive.name || name; + directive.require = directive.require || directive.controller && directive.name; + directive.restrict = directive.restrict || "EA"; + var bindings = directive.$$bindings = parseDirectiveBindings(directive, directive.name); + if (isObject(bindings.isolateScope)) { + directive.$$isolateBindings = bindings.isolateScope; + } + directive.$$moduleName = directiveFactory.$$moduleName; + directives.push(directive); + } catch (e) { + $exceptionHandler(e); + } + }); + return directives; + } ]); + } + hasDirectives[name].push(directiveFactory); + } else { + forEach(name, reverseParams(registerDirective)); + } + return this; + }; + this.aHrefSanitizationWhitelist = function(regexp) { + if (isDefined(regexp)) { + $$sanitizeUriProvider.aHrefSanitizationWhitelist(regexp); + return this; + } else { + return $$sanitizeUriProvider.aHrefSanitizationWhitelist(); + } + }; + this.imgSrcSanitizationWhitelist = function(regexp) { + if (isDefined(regexp)) { + $$sanitizeUriProvider.imgSrcSanitizationWhitelist(regexp); + return this; + } else { + return $$sanitizeUriProvider.imgSrcSanitizationWhitelist(); + } + }; + var debugInfoEnabled = true; + this.debugInfoEnabled = function(enabled) { + if (isDefined(enabled)) { + debugInfoEnabled = enabled; + return this; + } + return debugInfoEnabled; + }; + this.$get = [ "$injector", "$interpolate", "$exceptionHandler", "$templateRequest", "$parse", "$controller", "$rootScope", "$document", "$sce", "$animate", "$$sanitizeUri", function($injector, $interpolate, $exceptionHandler, $templateRequest, $parse, $controller, $rootScope, $document, $sce, $animate, $$sanitizeUri) { + var Attributes = function(element, attributesToCopy) { + if (attributesToCopy) { + var keys = Object.keys(attributesToCopy); + var i, l, key; + for (i = 0, l = keys.length; i < l; i++) { + key = keys[i]; + this[key] = attributesToCopy[key]; + } + } else { + this.$attr = {}; + } + this.$$element = element; + }; + Attributes.prototype = { + $normalize: directiveNormalize, + $addClass: function(classVal) { + if (classVal && classVal.length > 0) { + $animate.addClass(this.$$element, classVal); + } + }, + $removeClass: function(classVal) { + if (classVal && classVal.length > 0) { + $animate.removeClass(this.$$element, classVal); + } + }, + $updateClass: function(newClasses, oldClasses) { + var toAdd = tokenDifference(newClasses, oldClasses); + if (toAdd && toAdd.length) { + $animate.addClass(this.$$element, toAdd); + } + var toRemove = tokenDifference(oldClasses, newClasses); + if (toRemove && toRemove.length) { + $animate.removeClass(this.$$element, toRemove); + } + }, + $set: function(key, value, writeAttr, attrName) { + var node = this.$$element[0], booleanKey = getBooleanAttrName(node, key), aliasedKey = getAliasedAttrName(key), observer = key, nodeName; + if (booleanKey) { + this.$$element.prop(key, value); + attrName = booleanKey; + } else if (aliasedKey) { + this[aliasedKey] = value; + observer = aliasedKey; + } + this[key] = value; + if (attrName) { + this.$attr[key] = attrName; + } else { + attrName = this.$attr[key]; + if (!attrName) { + this.$attr[key] = attrName = snake_case(key, "-"); + } + } + nodeName = nodeName_(this.$$element); + if (nodeName === "a" && key === "href" || nodeName === "img" && key === "src") { + this[key] = value = $$sanitizeUri(value, key === "src"); + } else if (nodeName === "img" && key === "srcset") { + var result = ""; + var trimmedSrcset = trim(value); + var srcPattern = /(\s+\d+x\s*,|\s+\d+w\s*,|\s+,|,\s+)/; + var pattern = /\s/.test(trimmedSrcset) ? srcPattern : /(,)/; + var rawUris = trimmedSrcset.split(pattern); + var nbrUrisWith2parts = Math.floor(rawUris.length / 2); + for (var i = 0; i < nbrUrisWith2parts; i++) { + var innerIdx = i * 2; + result += $$sanitizeUri(trim(rawUris[innerIdx]), true); + result += " " + trim(rawUris[innerIdx + 1]); + } + var lastTuple = trim(rawUris[i * 2]).split(/\s/); + result += $$sanitizeUri(trim(lastTuple[0]), true); + if (lastTuple.length === 2) { + result += " " + trim(lastTuple[1]); + } + this[key] = value = result; + } + if (writeAttr !== false) { + if (value === null || isUndefined(value)) { + this.$$element.removeAttr(attrName); + } else { + this.$$element.attr(attrName, value); + } + } + var $$observers = this.$$observers; + $$observers && forEach($$observers[observer], function(fn) { + try { + fn(value); + } catch (e) { + $exceptionHandler(e); + } + }); + }, + $observe: function(key, fn) { + var attrs = this, $$observers = attrs.$$observers || (attrs.$$observers = createMap()), listeners = $$observers[key] || ($$observers[key] = []); + listeners.push(fn); + $rootScope.$evalAsync(function() { + if (!listeners.$$inter && attrs.hasOwnProperty(key) && !isUndefined(attrs[key])) { + fn(attrs[key]); + } + }); + return function() { + arrayRemove(listeners, fn); + }; + } + }; + function safeAddClass($element, className) { + try { + $element.addClass(className); + } catch (e) {} + } + var startSymbol = $interpolate.startSymbol(), endSymbol = $interpolate.endSymbol(), denormalizeTemplate = startSymbol == "{{" || endSymbol == "}}" ? identity : function denormalizeTemplate(template) { + return template.replace(/\{\{/g, startSymbol).replace(/}}/g, endSymbol); + }, NG_ATTR_BINDING = /^ngAttr[A-Z]/; + compile.$$addBindingInfo = debugInfoEnabled ? function $$addBindingInfo($element, binding) { + var bindings = $element.data("$binding") || []; + if (isArray(binding)) { + bindings = bindings.concat(binding); + } else { + bindings.push(binding); + } + $element.data("$binding", bindings); + } : noop; + compile.$$addBindingClass = debugInfoEnabled ? function $$addBindingClass($element) { + safeAddClass($element, "ng-binding"); + } : noop; + compile.$$addScopeInfo = debugInfoEnabled ? function $$addScopeInfo($element, scope, isolated, noTemplate) { + var dataName = isolated ? noTemplate ? "$isolateScopeNoTemplate" : "$isolateScope" : "$scope"; + $element.data(dataName, scope); + } : noop; + compile.$$addScopeClass = debugInfoEnabled ? function $$addScopeClass($element, isolated) { + safeAddClass($element, isolated ? "ng-isolate-scope" : "ng-scope"); + } : noop; + return compile; + function compile($compileNodes, transcludeFn, maxPriority, ignoreDirective, previousCompileContext) { + if (!($compileNodes instanceof jqLite)) { + $compileNodes = jqLite($compileNodes); + } + forEach($compileNodes, function(node, index) { + if (node.nodeType == NODE_TYPE_TEXT && node.nodeValue.match(/\S+/)) { + $compileNodes[index] = jqLite(node).wrap("").parent()[0]; + } + }); + var compositeLinkFn = compileNodes($compileNodes, transcludeFn, $compileNodes, maxPriority, ignoreDirective, previousCompileContext); + compile.$$addScopeClass($compileNodes); + var namespace = null; + return function publicLinkFn(scope, cloneConnectFn, options) { + assertArg(scope, "scope"); + options = options || {}; + var parentBoundTranscludeFn = options.parentBoundTranscludeFn, transcludeControllers = options.transcludeControllers, futureParentElement = options.futureParentElement; + if (parentBoundTranscludeFn && parentBoundTranscludeFn.$$boundTransclude) { + parentBoundTranscludeFn = parentBoundTranscludeFn.$$boundTransclude; + } + if (!namespace) { + namespace = detectNamespaceForChildElements(futureParentElement); + } + var $linkNode; + if (namespace !== "html") { + $linkNode = jqLite(wrapTemplate(namespace, jqLite("
").append($compileNodes).html())); + } else if (cloneConnectFn) { + $linkNode = JQLitePrototype.clone.call($compileNodes); + } else { + $linkNode = $compileNodes; + } + if (transcludeControllers) { + for (var controllerName in transcludeControllers) { + $linkNode.data("$" + controllerName + "Controller", transcludeControllers[controllerName].instance); + } + } + compile.$$addScopeInfo($linkNode, scope); + if (cloneConnectFn) cloneConnectFn($linkNode, scope); + if (compositeLinkFn) compositeLinkFn(scope, $linkNode, $linkNode, parentBoundTranscludeFn); + return $linkNode; + }; + } + function detectNamespaceForChildElements(parentElement) { + var node = parentElement && parentElement[0]; + if (!node) { + return "html"; + } else { + return nodeName_(node) !== "foreignobject" && node.toString().match(/SVG/) ? "svg" : "html"; + } + } + function compileNodes(nodeList, transcludeFn, $rootElement, maxPriority, ignoreDirective, previousCompileContext) { + var linkFns = [], attrs, directives, nodeLinkFn, childNodes, childLinkFn, linkFnFound, nodeLinkFnFound; + for (var i = 0; i < nodeList.length; i++) { + attrs = new Attributes(); + directives = collectDirectives(nodeList[i], [], attrs, i === 0 ? maxPriority : undefined, ignoreDirective); + nodeLinkFn = directives.length ? applyDirectivesToNode(directives, nodeList[i], attrs, transcludeFn, $rootElement, null, [], [], previousCompileContext) : null; + if (nodeLinkFn && nodeLinkFn.scope) { + compile.$$addScopeClass(attrs.$$element); + } + childLinkFn = nodeLinkFn && nodeLinkFn.terminal || !(childNodes = nodeList[i].childNodes) || !childNodes.length ? null : compileNodes(childNodes, nodeLinkFn ? (nodeLinkFn.transcludeOnThisElement || !nodeLinkFn.templateOnThisElement) && nodeLinkFn.transclude : transcludeFn); + if (nodeLinkFn || childLinkFn) { + linkFns.push(i, nodeLinkFn, childLinkFn); + linkFnFound = true; + nodeLinkFnFound = nodeLinkFnFound || nodeLinkFn; + } + previousCompileContext = null; + } + return linkFnFound ? compositeLinkFn : null; + function compositeLinkFn(scope, nodeList, $rootElement, parentBoundTranscludeFn) { + var nodeLinkFn, childLinkFn, node, childScope, i, ii, idx, childBoundTranscludeFn; + var stableNodeList; + if (nodeLinkFnFound) { + var nodeListLength = nodeList.length; + stableNodeList = new Array(nodeListLength); + for (i = 0; i < linkFns.length; i += 3) { + idx = linkFns[i]; + stableNodeList[idx] = nodeList[idx]; + } + } else { + stableNodeList = nodeList; + } + for (i = 0, ii = linkFns.length; i < ii; ) { + node = stableNodeList[linkFns[i++]]; + nodeLinkFn = linkFns[i++]; + childLinkFn = linkFns[i++]; + if (nodeLinkFn) { + if (nodeLinkFn.scope) { + childScope = scope.$new(); + compile.$$addScopeInfo(jqLite(node), childScope); + var destroyBindings = nodeLinkFn.$$destroyBindings; + if (destroyBindings) { + nodeLinkFn.$$destroyBindings = null; + childScope.$on("$destroyed", destroyBindings); + } + } else { + childScope = scope; + } + if (nodeLinkFn.transcludeOnThisElement) { + childBoundTranscludeFn = createBoundTranscludeFn(scope, nodeLinkFn.transclude, parentBoundTranscludeFn); + } else if (!nodeLinkFn.templateOnThisElement && parentBoundTranscludeFn) { + childBoundTranscludeFn = parentBoundTranscludeFn; + } else if (!parentBoundTranscludeFn && transcludeFn) { + childBoundTranscludeFn = createBoundTranscludeFn(scope, transcludeFn); + } else { + childBoundTranscludeFn = null; + } + nodeLinkFn(childLinkFn, childScope, node, $rootElement, childBoundTranscludeFn, nodeLinkFn); + } else if (childLinkFn) { + childLinkFn(scope, node.childNodes, undefined, parentBoundTranscludeFn); + } + } + } + } + function createBoundTranscludeFn(scope, transcludeFn, previousBoundTranscludeFn) { + var boundTranscludeFn = function(transcludedScope, cloneFn, controllers, futureParentElement, containingScope) { + if (!transcludedScope) { + transcludedScope = scope.$new(false, containingScope); + transcludedScope.$$transcluded = true; + } + return transcludeFn(transcludedScope, cloneFn, { + parentBoundTranscludeFn: previousBoundTranscludeFn, + transcludeControllers: controllers, + futureParentElement: futureParentElement + }); + }; + return boundTranscludeFn; + } + function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) { + var nodeType = node.nodeType, attrsMap = attrs.$attr, match, className; + switch (nodeType) { + case NODE_TYPE_ELEMENT: + addDirective(directives, directiveNormalize(nodeName_(node)), "E", maxPriority, ignoreDirective); + for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes, j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) { + var attrStartName = false; + var attrEndName = false; + attr = nAttrs[j]; + name = attr.name; + value = trim(attr.value); + ngAttrName = directiveNormalize(name); + if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) { + name = name.replace(PREFIX_REGEXP, "").substr(8).replace(/_(.)/g, function(match, letter) { + return letter.toUpperCase(); + }); + } + var directiveNName = ngAttrName.replace(/(Start|End)$/, ""); + if (directiveIsMultiElement(directiveNName)) { + if (ngAttrName === directiveNName + "Start") { + attrStartName = name; + attrEndName = name.substr(0, name.length - 5) + "end"; + name = name.substr(0, name.length - 6); + } + } + nName = directiveNormalize(name.toLowerCase()); + attrsMap[nName] = name; + if (isNgAttr || !attrs.hasOwnProperty(nName)) { + attrs[nName] = value; + if (getBooleanAttrName(node, nName)) { + attrs[nName] = true; + } + } + addAttrInterpolateDirective(node, directives, value, nName, isNgAttr); + addDirective(directives, nName, "A", maxPriority, ignoreDirective, attrStartName, attrEndName); + } + className = node.className; + if (isObject(className)) { + className = className.animVal; + } + if (isString(className) && className !== "") { + while (match = CLASS_DIRECTIVE_REGEXP.exec(className)) { + nName = directiveNormalize(match[2]); + if (addDirective(directives, nName, "C", maxPriority, ignoreDirective)) { + attrs[nName] = trim(match[3]); + } + className = className.substr(match.index + match[0].length); + } + } + break; + + case NODE_TYPE_TEXT: + if (msie === 11) { + while (node.parentNode && node.nextSibling && node.nextSibling.nodeType === NODE_TYPE_TEXT) { + node.nodeValue = node.nodeValue + node.nextSibling.nodeValue; + node.parentNode.removeChild(node.nextSibling); + } + } addTextInterpolateDirective(directives, node.nodeValue); break; @@ -9933,7 +12824,7 @@ compile: function() { return { pre: function attrInterpolatePreLinkFn(scope, element, attr) { - var $$observers = attr.$$observers || (attr.$$observers = {}); + var $$observers = attr.$$observers || (attr.$$observers = createMap()); if (EVENT_HANDLER_ATTR_REGEXP.test(name)) { throw $compileMinErr("nodomevents", "Interpolations for HTML DOM event attributes are disallowed. Please use the " + "ng- versions (such as ng-click instead of onclick) instead."); } @@ -10596,12 +13487,16 @@ } } ]; } - function createXhr() { - return new window.XMLHttpRequest(); + function $xhrFactoryProvider() { + this.$get = function() { + return function createXhr() { + return new window.XMLHttpRequest(); + }; + }; } function $HttpBackendProvider() { - this.$get = [ "$browser", "$window", "$document", function($browser, $window, $document) { - return createHttpBackend($browser, createXhr, $browser.defer, $window.angular.callbacks, $document[0]); + this.$get = [ "$browser", "$window", "$document", "$xhrFactory", function($browser, $window, $document, $xhrFactory) { + return createHttpBackend($browser, $xhrFactory, $browser.defer, $window.angular.callbacks, $document[0]); } ]; } function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDocument) { @@ -10619,7 +13514,7 @@ callbacks[callbackId] = noop; }); } else { - var xhr = createXhr(); + var xhr = createXhr(method, url); xhr.open(method, url, true); forEach(headers, function(value, key) { if (isDefined(value)) { @@ -11327,12 +14222,18 @@ } var $parseMinErr = minErr("$parse"); function ensureSafeMemberName(name, fullExpression) { - name = isObject(name) && name.toString ? name.toString() : name; if (name === "__defineGetter__" || name === "__defineSetter__" || name === "__lookupGetter__" || name === "__lookupSetter__" || name === "__proto__") { throw $parseMinErr("isecfld", "Attempting to access a disallowed field in Angular expressions! " + "Expression: {0}", fullExpression); } return name; } + function getStringValue(name, fullExpression) { + name = name + ""; + if (!isString(name)) { + throw $parseMinErr("iseccst", "Cannot convert object to primitive value! " + "Expression: {0}", fullExpression); + } + return name; + } function ensureSafeObject(obj, fullExpression) { if (obj) { if (obj.constructor === obj) { @@ -11359,6 +14260,13 @@ } } } + function ensureSafeAssignContext(obj, fullExpression) { + if (obj) { + if (obj === 0..constructor || obj === false.constructor || obj === "".constructor || obj === {}.constructor || obj === [].constructor || obj === Function.constructor) { + throw $parseMinErr("isecaf", "Assigning to a constructor is disallowed! Expression: {0}", fullExpression); + } + } + } var OPERATORS = createMap(); forEach("+ - * / % === !== == != < > <= >= && || ! = |".split(" "), function(operator) { OPERATORS[operator] = true; @@ -12107,7 +15015,7 @@ this.stage = "main"; this.recurse(ast); var fnString = '"' + this.USE + " " + this.STRICT + '";\n' + this.filterPrefix() + "var fn=" + this.generateFunction("fn", "s,l,a,i") + extra + this.watchFns() + "return fn;"; - var fn = new Function("$filter", "ensureSafeMemberName", "ensureSafeObject", "ensureSafeFunction", "ifDefined", "plus", "text", fnString)(this.$filter, ensureSafeMemberName, ensureSafeObject, ensureSafeFunction, ifDefined, plusFn, expression); + var fn = new Function("$filter", "ensureSafeMemberName", "ensureSafeObject", "ensureSafeFunction", "getStringValue", "ensureSafeAssignContext", "ifDefined", "plus", "text", fnString)(this.$filter, ensureSafeMemberName, ensureSafeObject, ensureSafeFunction, getStringValue, ensureSafeAssignContext, ifDefined, plusFn, expression); this.state = this.stage = undefined; fn.literal = isLiteral(ast); fn.constant = isConstant(ast); @@ -12244,6 +15152,7 @@ if (ast.computed) { right = self.nextId(); self.recurse(ast.property, right); + self.getStringValue(right); self.addEnsureSafeMemberName(right); if (create && create !== 1) { self.if_(self.not(self.computedMember(left, right)), self.lazyAssign(self.computedMember(left, right), "{}")); @@ -12329,6 +15238,7 @@ self.if_(self.notNull(left.context), function() { self.recurse(ast.right, right); self.addEnsureSafeObject(self.member(left.context, left.name, left.computed)); + self.addEnsureSafeAssignContext(left.context); expression = self.member(left.context, left.name, left.computed) + ast.operator + right; self.assign(intoId, expression); recursionFn(intoId || expression); @@ -12439,6 +15349,9 @@ addEnsureSafeFunction: function(item) { this.current().body.push(this.ensureSafeFunction(item), ";"); }, + addEnsureSafeAssignContext: function(item) { + this.current().body.push(this.ensureSafeAssignContext(item), ";"); + }, ensureSafeObject: function(item) { return "ensureSafeObject(" + item + ",text)"; }, @@ -12448,6 +15361,12 @@ ensureSafeFunction: function(item) { return "ensureSafeFunction(" + item + ",text)"; }, + getStringValue: function(item) { + this.assign(item, "getStringValue(" + item + ",text)"); + }, + ensureSafeAssignContext: function(item) { + return "ensureSafeAssignContext(" + item + ",text)"; + }, lazyRecurse: function(ast, intoId, nameId, recursionFn, create, skipWatchIdCheck) { var self = this; return function() { @@ -12615,6 +15534,7 @@ var lhs = left(scope, locals, assign, inputs); var rhs = right(scope, locals, assign, inputs); ensureSafeObject(lhs.value, self.expression); + ensureSafeAssignContext(lhs.context); lhs.context[lhs.name] = rhs; return context ? { value: rhs @@ -12872,6 +15792,7 @@ var value; if (lhs != null) { rhs = right(scope, locals, assign, inputs); + rhs = getStringValue(rhs); ensureSafeMemberName(rhs, expression); if (create && create !== 1 && lhs && !lhs[rhs]) { lhs[rhs] = {}; @@ -14554,6 +17475,7 @@ if (fractionSize > 0 && number < 1) { formatedText = number.toFixed(fractionSize); number = parseFloat(formatedText); + formatedText = formatedText.replace(DECIMAL_SEP, decimalSep); } } if (number === 0) { @@ -16571,11 +19493,11 @@ function updateOptionElement(option, element) { option.element = element; element.disabled = option.disabled; - if (option.value !== element.value) element.value = option.selectValue; if (option.label !== element.label) { element.label = option.label; element.textContent = option.label; } + if (option.value !== element.value) element.value = option.selectValue; } function addOrReuseElement(parent, current, type, templateElement) { var element; @@ -16603,7 +19525,7 @@ var emptyOption_ = emptyOption && emptyOption[0]; var unknownOption_ = unknownOption && unknownOption[0]; if (emptyOption_ || unknownOption_) { - while (current && (current === emptyOption_ || current === unknownOption_)) { + while (current && (current === emptyOption_ || current === unknownOption_ || emptyOption_ && emptyOption_.nodeType === NODE_TYPE_COMMENT)) { current = current.nextSibling; } } @@ -26436,848 +29358,2537 @@ angular.module("ui.bootstrap.timepicker", []).constant("timepickerConfig", { if (mousewheel) { this.setupMousewheelEvents(hoursInputEl, minutesInputEl); } - var arrowkeys = angular.isDefined($attrs.arrowkeys) ? $scope.$parent.$eval($attrs.arrowkeys) : timepickerConfig.arrowkeys; - if (arrowkeys) { - this.setupArrowkeyEvents(hoursInputEl, minutesInputEl); + var arrowkeys = angular.isDefined($attrs.arrowkeys) ? $scope.$parent.$eval($attrs.arrowkeys) : timepickerConfig.arrowkeys; + if (arrowkeys) { + this.setupArrowkeyEvents(hoursInputEl, minutesInputEl); + } + $scope.readonlyInput = angular.isDefined($attrs.readonlyInput) ? $scope.$parent.$eval($attrs.readonlyInput) : timepickerConfig.readonlyInput; + this.setupInputEvents(hoursInputEl, minutesInputEl); + }; + var hourStep = timepickerConfig.hourStep; + if ($attrs.hourStep) { + $scope.$parent.$watch($parse($attrs.hourStep), function(value) { + hourStep = parseInt(value, 10); + }); + } + var minuteStep = timepickerConfig.minuteStep; + if ($attrs.minuteStep) { + $scope.$parent.$watch($parse($attrs.minuteStep), function(value) { + minuteStep = parseInt(value, 10); + }); + } + var min; + $scope.$parent.$watch($parse($attrs.min), function(value) { + var dt = new Date(value); + min = isNaN(dt) ? undefined : dt; + }); + var max; + $scope.$parent.$watch($parse($attrs.max), function(value) { + var dt = new Date(value); + max = isNaN(dt) ? undefined : dt; + }); + $scope.noIncrementHours = function() { + var incrementedSelected = addMinutes(selected, hourStep * 60); + return incrementedSelected > max || incrementedSelected < selected && incrementedSelected < min; + }; + $scope.noDecrementHours = function() { + var decrementedSelected = addMinutes(selected, -hourStep * 60); + return decrementedSelected < min || decrementedSelected > selected && decrementedSelected > max; + }; + $scope.noIncrementMinutes = function() { + var incrementedSelected = addMinutes(selected, minuteStep); + return incrementedSelected > max || incrementedSelected < selected && incrementedSelected < min; + }; + $scope.noDecrementMinutes = function() { + var decrementedSelected = addMinutes(selected, -minuteStep); + return decrementedSelected < min || decrementedSelected > selected && decrementedSelected > max; + }; + $scope.noToggleMeridian = function() { + if (selected.getHours() < 13) { + return addMinutes(selected, 12 * 60) > max; + } else { + return addMinutes(selected, -12 * 60) < min; + } + }; + $scope.showMeridian = timepickerConfig.showMeridian; + if ($attrs.showMeridian) { + $scope.$parent.$watch($parse($attrs.showMeridian), function(value) { + $scope.showMeridian = !!value; + if (ngModelCtrl.$error.time) { + var hours = getHoursFromTemplate(), minutes = getMinutesFromTemplate(); + if (angular.isDefined(hours) && angular.isDefined(minutes)) { + selected.setHours(hours); + refresh(); + } + } else { + updateTemplate(); + } + }); + } + function getHoursFromTemplate() { + var hours = parseInt($scope.hours, 10); + var valid = $scope.showMeridian ? hours > 0 && hours < 13 : hours >= 0 && hours < 24; + if (!valid) { + return undefined; + } + if ($scope.showMeridian) { + if (hours === 12) { + hours = 0; + } + if ($scope.meridian === meridians[1]) { + hours = hours + 12; + } + } + return hours; + } + function getMinutesFromTemplate() { + var minutes = parseInt($scope.minutes, 10); + return minutes >= 0 && minutes < 60 ? minutes : undefined; + } + function pad(value) { + return angular.isDefined(value) && value.toString().length < 2 ? "0" + value : value.toString(); + } + this.setupMousewheelEvents = function(hoursInputEl, minutesInputEl) { + var isScrollingUp = function(e) { + if (e.originalEvent) { + e = e.originalEvent; + } + var delta = e.wheelDelta ? e.wheelDelta : -e.deltaY; + return e.detail || delta > 0; + }; + hoursInputEl.bind("mousewheel wheel", function(e) { + $scope.$apply(isScrollingUp(e) ? $scope.incrementHours() : $scope.decrementHours()); + e.preventDefault(); + }); + minutesInputEl.bind("mousewheel wheel", function(e) { + $scope.$apply(isScrollingUp(e) ? $scope.incrementMinutes() : $scope.decrementMinutes()); + e.preventDefault(); + }); + }; + this.setupArrowkeyEvents = function(hoursInputEl, minutesInputEl) { + hoursInputEl.bind("keydown", function(e) { + if (e.which === 38) { + e.preventDefault(); + $scope.incrementHours(); + $scope.$apply(); + } else if (e.which === 40) { + e.preventDefault(); + $scope.decrementHours(); + $scope.$apply(); + } + }); + minutesInputEl.bind("keydown", function(e) { + if (e.which === 38) { + e.preventDefault(); + $scope.incrementMinutes(); + $scope.$apply(); + } else if (e.which === 40) { + e.preventDefault(); + $scope.decrementMinutes(); + $scope.$apply(); + } + }); + }; + this.setupInputEvents = function(hoursInputEl, minutesInputEl) { + if ($scope.readonlyInput) { + $scope.updateHours = angular.noop; + $scope.updateMinutes = angular.noop; + return; + } + var invalidate = function(invalidHours, invalidMinutes) { + ngModelCtrl.$setViewValue(null); + ngModelCtrl.$setValidity("time", false); + if (angular.isDefined(invalidHours)) { + $scope.invalidHours = invalidHours; + } + if (angular.isDefined(invalidMinutes)) { + $scope.invalidMinutes = invalidMinutes; + } + }; + $scope.updateHours = function() { + var hours = getHoursFromTemplate(), minutes = getMinutesFromTemplate(); + if (angular.isDefined(hours) && angular.isDefined(minutes)) { + selected.setHours(hours); + if (selected < min || selected > max) { + invalidate(true); + } else { + refresh("h"); + } + } else { + invalidate(true); + } + }; + hoursInputEl.bind("blur", function(e) { + if (!$scope.invalidHours && $scope.hours < 10) { + $scope.$apply(function() { + $scope.hours = pad($scope.hours); + }); + } + }); + $scope.updateMinutes = function() { + var minutes = getMinutesFromTemplate(), hours = getHoursFromTemplate(); + if (angular.isDefined(minutes) && angular.isDefined(hours)) { + selected.setMinutes(minutes); + if (selected < min || selected > max) { + invalidate(undefined, true); + } else { + refresh("m"); + } + } else { + invalidate(undefined, true); + } + }; + minutesInputEl.bind("blur", function(e) { + if (!$scope.invalidMinutes && $scope.minutes < 10) { + $scope.$apply(function() { + $scope.minutes = pad($scope.minutes); + }); + } + }); + }; + this.render = function() { + var date = ngModelCtrl.$viewValue; + if (isNaN(date)) { + ngModelCtrl.$setValidity("time", false); + $log.error('Timepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date.'); + } else { + if (date) { + selected = date; + } + if (selected < min || selected > max) { + ngModelCtrl.$setValidity("time", false); + $scope.invalidHours = true; + $scope.invalidMinutes = true; + } else { + makeValid(); + } + updateTemplate(); + } + }; + function refresh(keyboardChange) { + makeValid(); + ngModelCtrl.$setViewValue(new Date(selected)); + updateTemplate(keyboardChange); + } + function makeValid() { + ngModelCtrl.$setValidity("time", true); + $scope.invalidHours = false; + $scope.invalidMinutes = false; + } + function updateTemplate(keyboardChange) { + var hours = selected.getHours(), minutes = selected.getMinutes(); + if ($scope.showMeridian) { + hours = hours === 0 || hours === 12 ? 12 : hours % 12; + } + $scope.hours = keyboardChange === "h" ? hours : pad(hours); + if (keyboardChange !== "m") { + $scope.minutes = pad(minutes); } - $scope.readonlyInput = angular.isDefined($attrs.readonlyInput) ? $scope.$parent.$eval($attrs.readonlyInput) : timepickerConfig.readonlyInput; - this.setupInputEvents(hoursInputEl, minutesInputEl); - }; - var hourStep = timepickerConfig.hourStep; - if ($attrs.hourStep) { - $scope.$parent.$watch($parse($attrs.hourStep), function(value) { - hourStep = parseInt(value, 10); - }); + $scope.meridian = selected.getHours() < 12 ? meridians[0] : meridians[1]; } - var minuteStep = timepickerConfig.minuteStep; - if ($attrs.minuteStep) { - $scope.$parent.$watch($parse($attrs.minuteStep), function(value) { - minuteStep = parseInt(value, 10); - }); + function addMinutes(date, minutes) { + var dt = new Date(date.getTime() + minutes * 6e4); + var newDate = new Date(date); + newDate.setHours(dt.getHours(), dt.getMinutes()); + return newDate; } - var min; - $scope.$parent.$watch($parse($attrs.min), function(value) { - var dt = new Date(value); - min = isNaN(dt) ? undefined : dt; - }); - var max; - $scope.$parent.$watch($parse($attrs.max), function(value) { - var dt = new Date(value); - max = isNaN(dt) ? undefined : dt; - }); - $scope.noIncrementHours = function() { - var incrementedSelected = addMinutes(selected, hourStep * 60); - return incrementedSelected > max || incrementedSelected < selected && incrementedSelected < min; + function addMinutesToSelected(minutes) { + selected = addMinutes(selected, minutes); + refresh(); + } + $scope.showSpinners = angular.isDefined($attrs.showSpinners) ? $scope.$parent.$eval($attrs.showSpinners) : timepickerConfig.showSpinners; + $scope.incrementHours = function() { + if (!$scope.noIncrementHours()) { + addMinutesToSelected(hourStep * 60); + } }; - $scope.noDecrementHours = function() { - var decrementedSelected = addMinutes(selected, -hourStep * 60); - return decrementedSelected < min || decrementedSelected > selected && decrementedSelected > max; + $scope.decrementHours = function() { + if (!$scope.noDecrementHours()) { + addMinutesToSelected(-hourStep * 60); + } }; - $scope.noIncrementMinutes = function() { - var incrementedSelected = addMinutes(selected, minuteStep); - return incrementedSelected > max || incrementedSelected < selected && incrementedSelected < min; + $scope.incrementMinutes = function() { + if (!$scope.noIncrementMinutes()) { + addMinutesToSelected(minuteStep); + } }; - $scope.noDecrementMinutes = function() { - var decrementedSelected = addMinutes(selected, -minuteStep); - return decrementedSelected < min || decrementedSelected > selected && decrementedSelected > max; + $scope.decrementMinutes = function() { + if (!$scope.noDecrementMinutes()) { + addMinutesToSelected(-minuteStep); + } }; - $scope.noToggleMeridian = function() { - if (selected.getHours() < 13) { - return addMinutes(selected, 12 * 60) > max; - } else { - return addMinutes(selected, -12 * 60) < min; + $scope.toggleMeridian = function() { + if (!$scope.noToggleMeridian()) { + addMinutesToSelected(12 * 60 * (selected.getHours() < 12 ? 1 : -1)); } }; - $scope.showMeridian = timepickerConfig.showMeridian; - if ($attrs.showMeridian) { - $scope.$parent.$watch($parse($attrs.showMeridian), function(value) { - $scope.showMeridian = !!value; - if (ngModelCtrl.$error.time) { - var hours = getHoursFromTemplate(), minutes = getMinutesFromTemplate(); - if (angular.isDefined(hours) && angular.isDefined(minutes)) { - selected.setHours(hours); - refresh(); - } - } else { - updateTemplate(); +} ]).directive("timepicker", function() { + return { + restrict: "EA", + require: [ "timepicker", "?^ngModel" ], + controller: "TimepickerController", + controllerAs: "timepicker", + replace: true, + scope: {}, + templateUrl: function(element, attrs) { + return attrs.templateUrl || "template/timepicker/timepicker.html"; + }, + link: function(scope, element, attrs, ctrls) { + var timepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1]; + if (ngModelCtrl) { + timepickerCtrl.init(ngModelCtrl, element.find("input")); } - }); + } + }; +}); + +angular.module("ui.bootstrap.transition", []).value("$transitionSuppressDeprecated", false).factory("$transition", [ "$q", "$timeout", "$rootScope", "$log", "$transitionSuppressDeprecated", function($q, $timeout, $rootScope, $log, $transitionSuppressDeprecated) { + if (!$transitionSuppressDeprecated) { + $log.warn("$transition is now deprecated. Use $animate from ngAnimate instead."); } - function getHoursFromTemplate() { - var hours = parseInt($scope.hours, 10); - var valid = $scope.showMeridian ? hours > 0 && hours < 13 : hours >= 0 && hours < 24; - if (!valid) { - return undefined; + var $transition = function(element, trigger, options) { + options = options || {}; + var deferred = $q.defer(); + var endEventName = $transition[options.animation ? "animationEndEventName" : "transitionEndEventName"]; + var transitionEndHandler = function(event) { + $rootScope.$apply(function() { + element.unbind(endEventName, transitionEndHandler); + deferred.resolve(element); + }); + }; + if (endEventName) { + element.bind(endEventName, transitionEndHandler); } - if ($scope.showMeridian) { - if (hours === 12) { - hours = 0; + $timeout(function() { + if (angular.isString(trigger)) { + element.addClass(trigger); + } else if (angular.isFunction(trigger)) { + trigger(element); + } else if (angular.isObject(trigger)) { + element.css(trigger); } - if ($scope.meridian === meridians[1]) { - hours = hours + 12; + if (!endEventName) { + deferred.resolve(element); + } + }); + deferred.promise.cancel = function() { + if (endEventName) { + element.unbind(endEventName, transitionEndHandler); + } + deferred.reject("Transition cancelled"); + }; + return deferred.promise; + }; + var transElement = document.createElement("trans"); + var transitionEndEventNames = { + WebkitTransition: "webkitTransitionEnd", + MozTransition: "transitionend", + OTransition: "oTransitionEnd", + transition: "transitionend" + }; + var animationEndEventNames = { + WebkitTransition: "webkitAnimationEnd", + MozTransition: "animationend", + OTransition: "oAnimationEnd", + transition: "animationend" + }; + function findEndEventName(endEventNames) { + for (var name in endEventNames) { + if (transElement.style[name] !== undefined) { + return endEventNames[name]; } } - return hours; - } - function getMinutesFromTemplate() { - var minutes = parseInt($scope.minutes, 10); - return minutes >= 0 && minutes < 60 ? minutes : undefined; - } - function pad(value) { - return angular.isDefined(value) && value.toString().length < 2 ? "0" + value : value.toString(); } - this.setupMousewheelEvents = function(hoursInputEl, minutesInputEl) { - var isScrollingUp = function(e) { - if (e.originalEvent) { - e = e.originalEvent; + $transition.transitionEndEventName = findEndEventName(transitionEndEventNames); + $transition.animationEndEventName = findEndEventName(animationEndEventNames); + return $transition; +} ]); + +angular.module("ui.bootstrap.typeahead", [ "ui.bootstrap.position" ]).factory("typeaheadParser", [ "$parse", function($parse) { + var TYPEAHEAD_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w\d]*))\s+in\s+([\s\S]+?)$/; + return { + parse: function(input) { + var match = input.match(TYPEAHEAD_REGEXP); + if (!match) { + throw new Error('Expected typeahead specification in form of "_modelValue_ (as _label_)? for _item_ in _collection_"' + ' but got "' + input + '".'); + } + return { + itemName: match[3], + source: $parse(match[4]), + viewMapper: $parse(match[2] || match[1]), + modelMapper: $parse(match[1]) + }; + } + }; +} ]).directive("typeahead", [ "$compile", "$parse", "$q", "$timeout", "$document", "$window", "$rootScope", "$position", "typeaheadParser", function($compile, $parse, $q, $timeout, $document, $window, $rootScope, $position, typeaheadParser) { + var HOT_KEYS = [ 9, 13, 27, 38, 40 ]; + var eventDebounceTime = 200; + return { + require: [ "ngModel", "^?ngModelOptions" ], + link: function(originalScope, element, attrs, ctrls) { + var modelCtrl = ctrls[0]; + var ngModelOptions = ctrls[1]; + var minLength = originalScope.$eval(attrs.typeaheadMinLength); + if (!minLength && minLength !== 0) { + minLength = 1; + } + var waitTime = originalScope.$eval(attrs.typeaheadWaitMs) || 0; + var isEditable = originalScope.$eval(attrs.typeaheadEditable) !== false; + var isLoadingSetter = $parse(attrs.typeaheadLoading).assign || angular.noop; + var onSelectCallback = $parse(attrs.typeaheadOnSelect); + var isSelectOnBlur = angular.isDefined(attrs.typeaheadSelectOnBlur) ? originalScope.$eval(attrs.typeaheadSelectOnBlur) : false; + var isNoResultsSetter = $parse(attrs.typeaheadNoResults).assign || angular.noop; + var inputFormatter = attrs.typeaheadInputFormatter ? $parse(attrs.typeaheadInputFormatter) : undefined; + var appendToBody = attrs.typeaheadAppendToBody ? originalScope.$eval(attrs.typeaheadAppendToBody) : false; + var focusFirst = originalScope.$eval(attrs.typeaheadFocusFirst) !== false; + var selectOnExact = attrs.typeaheadSelectOnExact ? originalScope.$eval(attrs.typeaheadSelectOnExact) : false; + var parsedModel = $parse(attrs.ngModel); + var invokeModelSetter = $parse(attrs.ngModel + "($$$p)"); + var $setModelValue = function(scope, newValue) { + if (angular.isFunction(parsedModel(originalScope)) && ngModelOptions && ngModelOptions.$options && ngModelOptions.$options.getterSetter) { + return invokeModelSetter(scope, { + $$$p: newValue + }); + } else { + return parsedModel.assign(scope, newValue); + } + }; + var parserResult = typeaheadParser.parse(attrs.typeahead); + var hasFocus; + var selected; + var scope = originalScope.$new(); + var offDestroy = originalScope.$on("$destroy", function() { + scope.$destroy(); + }); + scope.$on("$destroy", offDestroy); + var popupId = "typeahead-" + scope.$id + "-" + Math.floor(Math.random() * 1e4); + element.attr({ + "aria-autocomplete": "list", + "aria-expanded": false, + "aria-owns": popupId + }); + var popUpEl = angular.element("
"); + popUpEl.attr({ + id: popupId, + matches: "matches", + active: "activeIdx", + select: "select(activeIdx)", + "move-in-progress": "moveInProgress", + query: "query", + position: "position" + }); + if (angular.isDefined(attrs.typeaheadTemplateUrl)) { + popUpEl.attr("template-url", attrs.typeaheadTemplateUrl); } - var delta = e.wheelDelta ? e.wheelDelta : -e.deltaY; - return e.detail || delta > 0; - }; - hoursInputEl.bind("mousewheel wheel", function(e) { - $scope.$apply(isScrollingUp(e) ? $scope.incrementHours() : $scope.decrementHours()); - e.preventDefault(); - }); - minutesInputEl.bind("mousewheel wheel", function(e) { - $scope.$apply(isScrollingUp(e) ? $scope.incrementMinutes() : $scope.decrementMinutes()); - e.preventDefault(); - }); - }; - this.setupArrowkeyEvents = function(hoursInputEl, minutesInputEl) { - hoursInputEl.bind("keydown", function(e) { - if (e.which === 38) { - e.preventDefault(); - $scope.incrementHours(); - $scope.$apply(); - } else if (e.which === 40) { - e.preventDefault(); - $scope.decrementHours(); - $scope.$apply(); + if (angular.isDefined(attrs.typeaheadPopupTemplateUrl)) { + popUpEl.attr("popup-template-url", attrs.typeaheadPopupTemplateUrl); } - }); - minutesInputEl.bind("keydown", function(e) { - if (e.which === 38) { - e.preventDefault(); - $scope.incrementMinutes(); - $scope.$apply(); - } else if (e.which === 40) { - e.preventDefault(); - $scope.decrementMinutes(); - $scope.$apply(); + var resetMatches = function() { + scope.matches = []; + scope.activeIdx = -1; + element.attr("aria-expanded", false); + }; + var getMatchId = function(index) { + return popupId + "-option-" + index; + }; + scope.$watch("activeIdx", function(index) { + if (index < 0) { + element.removeAttr("aria-activedescendant"); + } else { + element.attr("aria-activedescendant", getMatchId(index)); + } + }); + var inputIsExactMatch = function(inputValue, index) { + if (scope.matches.length > index && inputValue) { + return inputValue.toUpperCase() === scope.matches[index].label.toUpperCase(); + } + return false; + }; + var getMatchesAsync = function(inputValue) { + var locals = { + $viewValue: inputValue + }; + isLoadingSetter(originalScope, true); + isNoResultsSetter(originalScope, false); + $q.when(parserResult.source(originalScope, locals)).then(function(matches) { + var onCurrentRequest = inputValue === modelCtrl.$viewValue; + if (onCurrentRequest && hasFocus) { + if (matches && matches.length > 0) { + scope.activeIdx = focusFirst ? 0 : -1; + isNoResultsSetter(originalScope, false); + scope.matches.length = 0; + for (var i = 0; i < matches.length; i++) { + locals[parserResult.itemName] = matches[i]; + scope.matches.push({ + id: getMatchId(i), + label: parserResult.viewMapper(scope, locals), + model: matches[i] + }); + } + scope.query = inputValue; + recalculatePosition(); + element.attr("aria-expanded", true); + if (selectOnExact && scope.matches.length === 1 && inputIsExactMatch(inputValue, 0)) { + scope.select(0); + } + } else { + resetMatches(); + isNoResultsSetter(originalScope, true); + } + } + if (onCurrentRequest) { + isLoadingSetter(originalScope, false); + } + }, function() { + resetMatches(); + isLoadingSetter(originalScope, false); + isNoResultsSetter(originalScope, true); + }); + }; + if (appendToBody) { + angular.element($window).bind("resize", fireRecalculating); + $document.find("body").bind("scroll", fireRecalculating); } - }); - }; - this.setupInputEvents = function(hoursInputEl, minutesInputEl) { - if ($scope.readonlyInput) { - $scope.updateHours = angular.noop; - $scope.updateMinutes = angular.noop; - return; - } - var invalidate = function(invalidHours, invalidMinutes) { - ngModelCtrl.$setViewValue(null); - ngModelCtrl.$setValidity("time", false); - if (angular.isDefined(invalidHours)) { - $scope.invalidHours = invalidHours; + var timeoutEventPromise; + scope.moveInProgress = false; + function fireRecalculating() { + if (!scope.moveInProgress) { + scope.moveInProgress = true; + scope.$digest(); + } + if (timeoutEventPromise) { + $timeout.cancel(timeoutEventPromise); + } + timeoutEventPromise = $timeout(function() { + if (scope.matches.length) { + recalculatePosition(); + } + scope.moveInProgress = false; + scope.$digest(); + }, eventDebounceTime); } - if (angular.isDefined(invalidMinutes)) { - $scope.invalidMinutes = invalidMinutes; + function recalculatePosition() { + scope.position = appendToBody ? $position.offset(element) : $position.position(element); + scope.position.top += element.prop("offsetHeight"); } - }; - $scope.updateHours = function() { - var hours = getHoursFromTemplate(), minutes = getMinutesFromTemplate(); - if (angular.isDefined(hours) && angular.isDefined(minutes)) { - selected.setHours(hours); - if (selected < min || selected > max) { - invalidate(true); + resetMatches(); + scope.query = undefined; + var timeoutPromise; + var scheduleSearchWithTimeout = function(inputValue) { + timeoutPromise = $timeout(function() { + getMatchesAsync(inputValue); + }, waitTime); + }; + var cancelPreviousTimeout = function() { + if (timeoutPromise) { + $timeout.cancel(timeoutPromise); + } + }; + modelCtrl.$parsers.unshift(function(inputValue) { + hasFocus = true; + if (minLength === 0 || inputValue && inputValue.length >= minLength) { + if (waitTime > 0) { + cancelPreviousTimeout(); + scheduleSearchWithTimeout(inputValue); + } else { + getMatchesAsync(inputValue); + } } else { - refresh("h"); + isLoadingSetter(originalScope, false); + cancelPreviousTimeout(); + resetMatches(); + } + if (isEditable) { + return inputValue; + } else { + if (!inputValue) { + modelCtrl.$setValidity("editable", true); + return null; + } else { + modelCtrl.$setValidity("editable", false); + return undefined; + } + } + }); + modelCtrl.$formatters.push(function(modelValue) { + var candidateViewValue, emptyViewValue; + var locals = {}; + if (!isEditable) { + modelCtrl.$setValidity("editable", true); + } + if (inputFormatter) { + locals.$model = modelValue; + return inputFormatter(originalScope, locals); + } else { + locals[parserResult.itemName] = modelValue; + candidateViewValue = parserResult.viewMapper(originalScope, locals); + locals[parserResult.itemName] = undefined; + emptyViewValue = parserResult.viewMapper(originalScope, locals); + return candidateViewValue !== emptyViewValue ? candidateViewValue : modelValue; + } + }); + scope.select = function(activeIdx) { + var locals = {}; + var model, item; + selected = true; + locals[parserResult.itemName] = item = scope.matches[activeIdx].model; + model = parserResult.modelMapper(originalScope, locals); + $setModelValue(originalScope, model); + modelCtrl.$setValidity("editable", true); + modelCtrl.$setValidity("parse", true); + onSelectCallback(originalScope, { + $item: item, + $model: model, + $label: parserResult.viewMapper(originalScope, locals) + }); + resetMatches(); + if (scope.$eval(attrs.typeaheadFocusOnSelect) !== false) { + $timeout(function() { + element[0].focus(); + }, 0, false); + } + }; + element.bind("keydown", function(evt) { + if (scope.matches.length === 0 || HOT_KEYS.indexOf(evt.which) === -1) { + return; + } + if (scope.activeIdx === -1 && (evt.which === 9 || evt.which === 13)) { + resetMatches(); + scope.$digest(); + return; + } + evt.preventDefault(); + if (evt.which === 40) { + scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length; + scope.$digest(); + } else if (evt.which === 38) { + scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1; + scope.$digest(); + } else if (evt.which === 13 || evt.which === 9) { + scope.$apply(function() { + scope.select(scope.activeIdx); + }); + } else if (evt.which === 27) { + evt.stopPropagation(); + resetMatches(); + scope.$digest(); } - } else { - invalidate(true); - } - }; - hoursInputEl.bind("blur", function(e) { - if (!$scope.invalidHours && $scope.hours < 10) { - $scope.$apply(function() { - $scope.hours = pad($scope.hours); - }); - } - }); - $scope.updateMinutes = function() { - var minutes = getMinutesFromTemplate(), hours = getHoursFromTemplate(); - if (angular.isDefined(minutes) && angular.isDefined(hours)) { - selected.setMinutes(minutes); - if (selected < min || selected > max) { - invalidate(undefined, true); - } else { - refresh("m"); + }); + element.bind("blur", function() { + if (isSelectOnBlur && scope.matches.length && scope.activeIdx !== -1 && !selected) { + selected = true; + scope.$apply(function() { + scope.select(scope.activeIdx); + }); + } + hasFocus = false; + selected = false; + }); + var dismissClickHandler = function(evt) { + if (element[0] !== evt.target && evt.which !== 3 && scope.matches.length !== 0) { + resetMatches(); + if (!$rootScope.$$phase) { + scope.$digest(); + } + } + }; + $document.bind("click", dismissClickHandler); + originalScope.$on("$destroy", function() { + $document.unbind("click", dismissClickHandler); + if (appendToBody) { + $popup.remove(); } + popUpEl.remove(); + }); + var $popup = $compile(popUpEl)(scope); + if (appendToBody) { + $document.find("body").append($popup); } else { - invalidate(undefined, true); + element.after($popup); } - }; - minutesInputEl.bind("blur", function(e) { - if (!$scope.invalidMinutes && $scope.minutes < 10) { - $scope.$apply(function() { - $scope.minutes = pad($scope.minutes); + } + }; +} ]).directive("typeaheadPopup", function() { + return { + restrict: "EA", + scope: { + matches: "=", + query: "=", + active: "=", + position: "&", + moveInProgress: "=", + select: "&" + }, + replace: true, + templateUrl: function(element, attrs) { + return attrs.popupTemplateUrl || "template/typeahead/typeahead-popup.html"; + }, + link: function(scope, element, attrs) { + scope.templateUrl = attrs.templateUrl; + scope.isOpen = function() { + return scope.matches.length > 0; + }; + scope.isActive = function(matchIdx) { + return scope.active == matchIdx; + }; + scope.selectActive = function(matchIdx) { + scope.active = matchIdx; + }; + scope.selectMatch = function(activeIdx) { + scope.select({ + activeIdx: activeIdx + }); + }; + } + }; +}).directive("typeaheadMatch", [ "$templateRequest", "$compile", "$parse", function($templateRequest, $compile, $parse) { + return { + restrict: "EA", + scope: { + index: "=", + match: "=", + query: "=" + }, + link: function(scope, element, attrs) { + var tplUrl = $parse(attrs.templateUrl)(scope.$parent) || "template/typeahead/typeahead-match.html"; + $templateRequest(tplUrl).then(function(tplContent) { + $compile(tplContent.trim())(scope, function(clonedElement) { + element.replaceWith(clonedElement); + }); + }); + } + }; +} ]).filter("typeaheadHighlight", [ "$sce", "$injector", "$log", function($sce, $injector, $log) { + var isSanitizePresent; + isSanitizePresent = $injector.has("$sanitize"); + function escapeRegexp(queryToEscape) { + return queryToEscape.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1"); + } + function containsHtml(matchItem) { + return /<.*>/g.test(matchItem); + } + return function(matchItem, query) { + if (!isSanitizePresent && containsHtml(matchItem)) { + $log.warn("Unsafe use of typeahead please use ngSanitize"); + } + matchItem = query ? ("" + matchItem).replace(new RegExp(escapeRegexp(query), "gi"), "$&") : matchItem; + if (!isSanitizePresent) { + matchItem = $sce.trustAsHtml(matchItem); + } + return matchItem; + }; +} ]); + +angular.module("template/accordion/accordion-group.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/accordion/accordion-group.html", "
\n" + '
\n' + '

\n' + ' {{heading}}\n' + "

\n" + "
\n" + '
\n' + '
\n' + "
\n" + "
\n" + ""); +} ]); + +angular.module("template/accordion/accordion.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/accordion/accordion.html", '
'); +} ]); + +angular.module("template/alert/alert.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/alert/alert.html", "
\n" + ' \n" + "
\n" + "
\n" + ""); +} ]); + +angular.module("template/carousel/carousel.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/carousel/carousel.html", '\n" + ""); +} ]); + +angular.module("template/carousel/slide.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/carousel/slide.html", '
\n' + ""); +} ]); + +angular.module("template/datepicker/datepicker.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/datepicker/datepicker.html", '
\n' + ' \n' + ' \n' + ' \n' + "
"); +} ]); + +angular.module("template/datepicker/day.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/datepicker/day.html", '\n' + " \n" + " \n" + ' \n' + ' \n' + ' \n' + " \n" + " \n" + ' \n' + ' \n' + " \n" + " \n" + " \n" + ' \n' + ' \n' + ' \n" + " \n" + " \n" + "
{{::label.abbr}}
{{ weekNumbers[$index] }}\n' + ' \n' + "
\n" + ""); +} ]); + +angular.module("template/datepicker/month.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/datepicker/month.html", '\n' + " \n" + " \n" + ' \n' + ' \n' + ' \n' + " \n" + " \n" + " \n" + ' \n' + ' \n" + " \n" + " \n" + "
\n' + ' \n' + "
\n" + ""); +} ]); + +angular.module("template/datepicker/popup.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/datepicker/popup.html", '\n" + ""); +} ]); + +angular.module("template/datepicker/year.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/datepicker/year.html", '\n' + " \n" + " \n" + ' \n' + ' \n' + ' \n' + " \n" + " \n" + " \n" + ' \n' + ' \n" + " \n" + " \n" + "
\n' + ' \n' + "
\n" + ""); +} ]); + +angular.module("template/modal/backdrop.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/modal/backdrop.html", '\n" + ""); +} ]); + +angular.module("template/modal/window.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/modal/window.html", '\n" + ""); +} ]); + +angular.module("template/pagination/pager.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/pagination/pager.html", '\n" + ""); +} ]); + +angular.module("template/pagination/pagination.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/pagination/pagination.html", '\n" + ""); +} ]); + +angular.module("template/tooltip/tooltip-html-popup.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/tooltip/tooltip-html-popup.html", '
\n' + '
\n' + '
\n' + "
\n" + ""); +} ]); + +angular.module("template/tooltip/tooltip-html-unsafe-popup.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/tooltip/tooltip-html-unsafe-popup.html", '
\n' + '
\n' + '
\n' + "
\n" + ""); +} ]); + +angular.module("template/tooltip/tooltip-popup.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/tooltip/tooltip-popup.html", '
\n' + '
\n' + '
\n' + "
\n" + ""); +} ]); + +angular.module("template/tooltip/tooltip-template-popup.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/tooltip/tooltip-template-popup.html", '
\n' + '
\n' + '
\n' + "
\n" + ""); +} ]); + +angular.module("template/popover/popover-html.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/popover/popover-html.html", '
\n' + '
\n' + "\n" + '
\n' + '

\n' + '
\n' + "
\n" + "
\n" + ""); +} ]); + +angular.module("template/popover/popover-template.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/popover/popover-template.html", '
\n' + '
\n' + "\n" + '
\n' + '

\n' + '
\n' + "
\n" + "
\n" + ""); +} ]); + +angular.module("template/popover/popover.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/popover/popover.html", '
\n' + '
\n' + "\n" + '
\n' + '

\n' + '
\n' + "
\n" + "
\n" + ""); +} ]); + +angular.module("template/progressbar/bar.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/progressbar/bar.html", '
\n' + ""); +} ]); + +angular.module("template/progressbar/progress.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/progressbar/progress.html", '
'); +} ]); + +angular.module("template/progressbar/progressbar.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/progressbar/progressbar.html", '
\n' + '
\n' + "
\n" + ""); +} ]); + +angular.module("template/rating/rating.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/rating/rating.html", '\n' + " ({{ $index < value ? '*' : ' ' }})\n" + ' \n' + "\n" + ""); +} ]); + +angular.module("template/tabs/tab.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/tabs/tab.html", '
  • \n' + ' {{heading}}\n' + "
  • \n" + ""); +} ]); + +angular.module("template/tabs/tabset.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/tabs/tabset.html", "
    \n" + "
      \n" + '
      \n' + '
      \n' + "
      \n" + "
      \n" + "
      \n" + ""); +} ]); + +angular.module("template/timepicker/timepicker.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/timepicker/timepicker.html", "\n" + " \n" + ' \n' + ' \n' + " \n" + ' \n' + ' \n' + " \n" + " \n" + ' \n" + " \n" + ' \n" + ' \n' + " \n" + ' \n' + ' \n' + " \n" + ' \n' + ' \n' + " \n" + " \n" + "
       
      \n' + ' \n' + " :\n' + ' \n' + "
       
      \n" + ""); +} ]); + +angular.module("template/typeahead/typeahead-match.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/typeahead/typeahead-match.html", '\n' + ""); +} ]); + +angular.module("template/typeahead/typeahead-popup.html", []).run([ "$templateCache", function($templateCache) { + $templateCache.put("template/typeahead/typeahead-popup.html", '\n" + ""); +} ]); + +!angular.$$csp() && angular.element(document).find("head").prepend(''); + +angular.module("ngMap", []); + +(function() { + "use strict"; + var Attr2MapOptions; + var __MapController = function($scope, $element, $attrs, $parse, _Attr2MapOptions_, NgMap) { + Attr2MapOptions = _Attr2MapOptions_; + var vm = this; + vm.mapOptions; + vm.mapEvents; + vm.ngMapDiv; + vm.addObject = function(groupName, obj) { + if (vm.map) { + vm.map[groupName] = vm.map[groupName] || {}; + var len = Object.keys(vm.map[groupName]).length; + vm.map[groupName][obj.id || len] = obj; + if (groupName != "infoWindows" && obj.setMap) { + obj.setMap && obj.setMap(vm.map); + } + if (obj.centered && obj.position) { + vm.map.setCenter(obj.position); + } + groupName == "markers" && vm.objectChanged("markers"); + groupName == "customMarkers" && vm.objectChanged("customMarkers"); + } + }; + vm.deleteObject = function(groupName, obj) { + if (obj.map) { + var objs = obj.map[groupName]; + for (var name in objs) { + objs[name] === obj && delete objs[name]; + } + obj.map && obj.setMap && obj.setMap(null); + groupName == "markers" && vm.objectChanged("markers"); + groupName == "customMarkers" && vm.objectChanged("customMarkers"); + } + }; + vm.observeAttrSetObj = function(orgAttrs, attrs, obj) { + if (attrs.noWatcher) { + return false; + } + var attrsToObserve = Attr2MapOptions.getAttrsToObserve(orgAttrs); + for (var i = 0; i < attrsToObserve.length; i++) { + var attrName = attrsToObserve[i]; + attrs.$observe(attrName, NgMap.observeAndSet(attrName, obj)); + } + }; + vm.zoomToIncludeMarkers = function() { + var bounds = new google.maps.LatLngBounds(); + for (var k1 in vm.map.markers) { + bounds.extend(vm.map.markers[k1].getPosition()); + } + for (var k2 in vm.map.customMarkers) { + bounds.extend(vm.map.customMarkers[k2].getPosition()); + } + vm.map.fitBounds(bounds); + }; + vm.objectChanged = function(group) { + if ((group == "markers" || group == "customMarkers") && vm.map.zoomToIncludeMarkers == "auto") { + vm.zoomToIncludeMarkers(); + } + }; + vm.initializeMap = function() { + var mapOptions = vm.mapOptions, mapEvents = vm.mapEvents, ngMapDiv = vm.ngMapDiv; + vm.map = new google.maps.Map(ngMapDiv, {}); + mapOptions.zoom = mapOptions.zoom || 15; + var center = mapOptions.center; + if (!mapOptions.center || typeof center === "string" && center.match(/\{\{.*\}\}/)) { + mapOptions.center = new google.maps.LatLng(0, 0); + } else if (!(center instanceof google.maps.LatLng)) { + var geoCenter = mapOptions.center; + delete mapOptions.center; + NgMap.getGeoLocation(geoCenter, mapOptions.geoLocationOptions).then(function(latlng) { + vm.map.setCenter(latlng); + var geoCallback = mapOptions.geoCallback; + geoCallback && $parse(geoCallback)($scope); + }, function() { + if (mapOptions.geoFallbackCenter) { + vm.map.setCenter(mapOptions.geoFallbackCenter); + } }); } - }); - }; - this.render = function() { - var date = ngModelCtrl.$viewValue; - if (isNaN(date)) { - ngModelCtrl.$setValidity("time", false); - $log.error('Timepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date.'); + vm.map.setOptions(mapOptions); + for (var eventName in mapEvents) { + google.maps.event.addListener(vm.map, eventName, mapEvents[eventName]); + } + vm.observeAttrSetObj(orgAttrs, $attrs, vm.map); + vm.singleInfoWindow = mapOptions.singleInfoWindow; + google.maps.event.addListenerOnce(vm.map, "idle", function() { + NgMap.addMap(vm); + if (mapOptions.zoomToIncludeMarkers) { + vm.zoomToIncludeMarkers(); + } + $scope.map = vm.map; + $scope.$emit("mapInitialized", vm.map); + if ($attrs.mapInitialized) { + $parse($attrs.mapInitialized)($scope, { + map: vm.map + }); + } + }); + }; + $scope.google = google; + var orgAttrs = Attr2MapOptions.orgAttributes($element); + var filtered = Attr2MapOptions.filter($attrs); + var options = Attr2MapOptions.getOptions(filtered); + var controlOptions = Attr2MapOptions.getControlOptions(filtered); + var mapOptions = angular.extend(options, controlOptions); + var mapEvents = Attr2MapOptions.getEvents($scope, filtered); + void 0; + vm.mapOptions = mapOptions; + vm.mapEvents = mapEvents; + vm.ngMapDiv = NgMap.getNgMapDiv($element[0]); + $element.append(vm.ngMapDiv); + if (options.lazyInit) { + vm.map = { + id: $attrs.id + }; + NgMap.addMap(vm); } else { - if (date) { - selected = date; - } - if (selected < min || selected > max) { - ngModelCtrl.$setValidity("time", false); - $scope.invalidHours = true; - $scope.invalidMinutes = true; - } else { - makeValid(); - } - updateTemplate(); + vm.initializeMap(); } + $element.bind("$destroy", function() { + NgMap.deleteMap(vm); + }); }; - function refresh(keyboardChange) { - makeValid(); - ngModelCtrl.$setViewValue(new Date(selected)); - updateTemplate(keyboardChange); - } - function makeValid() { - ngModelCtrl.$setValidity("time", true); - $scope.invalidHours = false; - $scope.invalidMinutes = false; - } - function updateTemplate(keyboardChange) { - var hours = selected.getHours(), minutes = selected.getMinutes(); - if ($scope.showMeridian) { - hours = hours === 0 || hours === 12 ? 12 : hours % 12; - } - $scope.hours = keyboardChange === "h" ? hours : pad(hours); - if (keyboardChange !== "m") { - $scope.minutes = pad(minutes); - } - $scope.meridian = selected.getHours() < 12 ? meridians[0] : meridians[1]; - } - function addMinutes(date, minutes) { - var dt = new Date(date.getTime() + minutes * 6e4); - var newDate = new Date(date); - newDate.setHours(dt.getHours(), dt.getMinutes()); - return newDate; - } - function addMinutesToSelected(minutes) { - selected = addMinutes(selected, minutes); - refresh(); - } - $scope.showSpinners = angular.isDefined($attrs.showSpinners) ? $scope.$parent.$eval($attrs.showSpinners) : timepickerConfig.showSpinners; - $scope.incrementHours = function() { - if (!$scope.noIncrementHours()) { - addMinutesToSelected(hourStep * 60); - } + __MapController.$inject = [ "$scope", "$element", "$attrs", "$parse", "Attr2MapOptions", "NgMap" ]; + angular.module("ngMap").controller("__MapController", __MapController); +})(); + +(function() { + "use strict"; + var parser; + var linkFunc = function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var orgAttrs = parser.orgAttributes(element); + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered); + var events = parser.getEvents(scope, filtered); + void 0; + var layer = getLayer(options, events); + mapController.addObject("bicyclingLayers", layer); + mapController.observeAttrSetObj(orgAttrs, attrs, layer); + element.bind("$destroy", function() { + mapController.deleteObject("bicyclingLayers", layer); + }); }; - $scope.decrementHours = function() { - if (!$scope.noDecrementHours()) { - addMinutesToSelected(-hourStep * 60); + var getLayer = function(options, events) { + var layer = new google.maps.BicyclingLayer(options); + for (var eventName in events) { + google.maps.event.addListener(layer, eventName, events[eventName]); } + return layer; }; - $scope.incrementMinutes = function() { - if (!$scope.noIncrementMinutes()) { - addMinutesToSelected(minuteStep); - } + var bicyclingLayer = function(Attr2MapOptions) { + parser = Attr2MapOptions; + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: linkFunc + }; }; - $scope.decrementMinutes = function() { - if (!$scope.noDecrementMinutes()) { - addMinutesToSelected(-minuteStep); - } + bicyclingLayer.$inject = [ "Attr2MapOptions" ]; + angular.module("ngMap").directive("bicyclingLayer", bicyclingLayer); +})(); + +(function() { + "use strict"; + var parser, $compile, NgMap; + var linkFunc = function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered); + var events = parser.getEvents(scope, filtered); + void 0; + var customControlEl = element[0].parentElement.removeChild(element[0]); + $compile(customControlEl.innerHTML.trim())(scope); + for (var eventName in events) { + google.maps.event.addDomListener(customControlEl, eventName, events[eventName]); + } + mapController.addObject("customControls", customControlEl); + NgMap.getMap().then(function(map) { + var position = options.position; + map.controls[google.maps.ControlPosition[position]].push(customControlEl); + }); }; - $scope.toggleMeridian = function() { - if (!$scope.noToggleMeridian()) { - addMinutesToSelected(12 * 60 * (selected.getHours() < 12 ? 1 : -1)); + var customControl = function(Attr2MapOptions, _$compile_, _NgMap_) { + parser = Attr2MapOptions, $compile = _$compile_, NgMap = _NgMap_; + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: linkFunc + }; + }; + customControl.$inject = [ "Attr2MapOptions", "$compile", "NgMap" ]; + angular.module("ngMap").directive("customControl", customControl); +})(); + +(function() { + "use strict"; + var parser, $timeout, $compile, NgMap; + var CustomMarker = function(options) { + options = options || {}; + this.el = document.createElement("div"); + this.el.style.display = "inline-block"; + this.visible = true; + for (var key in options) { + this[key] = options[key]; + } + }; + var setCustomMarker = function() { + CustomMarker.prototype = new google.maps.OverlayView(); + CustomMarker.prototype.setContent = function(html, scope) { + this.el.innerHTML = html; + this.el.style.position = "absolute"; + if (scope) { + $compile(angular.element(this.el).contents())(scope); + } + }; + CustomMarker.prototype.getDraggable = function() { + return this.draggable; + }; + CustomMarker.prototype.setDraggable = function(draggable) { + this.draggable = draggable; + }; + CustomMarker.prototype.getPosition = function() { + return this.position; + }; + CustomMarker.prototype.setPosition = function(position) { + position && (this.position = position); + if (this.getProjection() && typeof this.position.lng == "function") { + var posPixel = this.getProjection().fromLatLngToDivPixel(this.position); + var x = Math.round(posPixel.x - this.el.offsetWidth / 2); + var y = Math.round(posPixel.y - this.el.offsetHeight - 10); + this.el.style.left = x + "px"; + this.el.style.top = y + "px"; + } + }; + CustomMarker.prototype.setZIndex = function(zIndex) { + zIndex && (this.zIndex = zIndex); + this.el.style.zIndex = this.zIndex; + }; + CustomMarker.prototype.setVisible = function(visible) { + this.el.style.display = visible ? "inline-block" : "none"; + this.visible = visible; + }; + CustomMarker.prototype.addClass = function(className) { + var classNames = this.el.className.trim().split(" "); + classNames.indexOf(className) == -1 && classNames.push(className); + this.el.className = classNames.join(" "); + }; + CustomMarker.prototype.removeClass = function(className) { + var classNames = this.el.className.split(" "); + var index = classNames.indexOf(className); + index > -1 && classNames.splice(index, 1); + this.el.className = classNames.join(" "); + }; + CustomMarker.prototype.onAdd = function() { + this.getPanes().overlayMouseTarget.appendChild(this.el); + }; + CustomMarker.prototype.draw = function() { + this.setPosition(); + this.setZIndex(this.zIndex); + this.setVisible(this.visible); + }; + CustomMarker.prototype.onRemove = function() { + this.el.parentNode.removeChild(this.el); + }; + }; + var linkFunc = function(orgHtml, varsToWatch) { + return function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var orgAttrs = parser.orgAttributes(element); + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered, scope); + var events = parser.getEvents(scope, filtered); + var removedEl = element[0].parentElement.removeChild(element[0]); + void 0; + var customMarker = new CustomMarker(options); + $timeout(function() { + scope.$watch("[" + varsToWatch.join(",") + "]", function() { + customMarker.setContent(orgHtml, scope); + }); + customMarker.setContent(removedEl.innerHTML, scope); + var classNames = removedEl.firstElementChild.className; + customMarker.addClass("custom-marker"); + customMarker.addClass(classNames); + void 0; + if (!(options.position instanceof google.maps.LatLng)) { + NgMap.getGeoLocation(options.position).then(function(latlng) { + customMarker.setPosition(latlng); + }); + } + }); + void 0; + for (var eventName in events) { + google.maps.event.addDomListener(customMarker.el, eventName, events[eventName]); + } + mapController.addObject("customMarkers", customMarker); + mapController.observeAttrSetObj(orgAttrs, attrs, customMarker); + element.bind("$destroy", function() { + mapController.deleteObject("customMarkers", customMarker); + }); + }; + }; + var customMarkerDirective = function(_$timeout_, _$compile_, Attr2MapOptions, _NgMap_) { + parser = Attr2MapOptions; + $timeout = _$timeout_; + $compile = _$compile_; + NgMap = _NgMap_; + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + compile: function(element) { + setCustomMarker(); + element[0].style.display = "none"; + var orgHtml = element.html(); + var matches = orgHtml.match(/{{([^}]+)}}/g); + var varsToWatch = []; + (matches || []).forEach(function(match) { + var toWatch = match.replace("{{", "").replace("}}", ""); + if (match.indexOf("::") == -1 && match.indexOf("this.") == -1 && varsToWatch.indexOf(toWatch) == -1) { + varsToWatch.push(match.replace("{{", "").replace("}}", "")); + } + }); + return linkFunc(orgHtml, varsToWatch); + } + }; + }; + customMarkerDirective.$inject = [ "$timeout", "$compile", "Attr2MapOptions", "NgMap" ]; + angular.module("ngMap").directive("customMarker", customMarkerDirective); +})(); + +(function() { + "use strict"; + var NgMap, $timeout, NavigatorGeolocation; + var getDirectionsRenderer = function(options, events) { + if (options.panel) { + options.panel = document.getElementById(options.panel) || document.querySelector(options.panel); + } + var renderer = new google.maps.DirectionsRenderer(options); + for (var eventName in events) { + google.maps.event.addListener(renderer, eventName, events[eventName]); } + return renderer; }; -} ]).directive("timepicker", function() { - return { - restrict: "EA", - require: [ "timepicker", "?^ngModel" ], - controller: "TimepickerController", - controllerAs: "timepicker", - replace: true, - scope: {}, - templateUrl: function(element, attrs) { - return attrs.templateUrl || "template/timepicker/timepicker.html"; - }, - link: function(scope, element, attrs, ctrls) { - var timepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1]; - if (ngModelCtrl) { - timepickerCtrl.init(ngModelCtrl, element.find("input")); + var updateRoute = function(renderer, options) { + var directionsService = new google.maps.DirectionsService(); + var request = options; + request.travelMode = request.travelMode || "DRIVING"; + var validKeys = [ "origin", "destination", "travelMode", "transitOptions", "unitSystem", "durationInTraffic", "waypoints", "optimizeWaypoints", "provideRouteAlternatives", "avoidHighways", "avoidTolls", "region" ]; + for (var key in request) { + validKeys.indexOf(key) === -1 && delete request[key]; + } + if (request.waypoints) { + if (request.waypoints == "[]" || request.waypoints === "") { + delete request.waypoints; } } + var showDirections = function(request) { + directionsService.route(request, function(response, status) { + if (status == google.maps.DirectionsStatus.OK) { + $timeout(function() { + renderer.setDirections(response); + }); + } + }); + }; + if (request.origin && request.destination) { + if (request.origin == "current-location") { + NavigatorGeolocation.getCurrentPosition().then(function(ll) { + request.origin = new google.maps.LatLng(ll.coords.latitude, ll.coords.longitude); + showDirections(request); + }); + } else if (request.destination == "current-location") { + NavigatorGeolocation.getCurrentPosition().then(function(ll) { + request.destination = new google.maps.LatLng(ll.coords.latitude, ll.coords.longitude); + showDirections(request); + }); + } else { + showDirections(request); + } + } + }; + var directions = function(Attr2MapOptions, _$timeout_, _NavigatorGeolocation_, _NgMap_) { + var parser = Attr2MapOptions; + NgMap = _NgMap_; + $timeout = _$timeout_; + NavigatorGeolocation = _NavigatorGeolocation_; + var linkFunc = function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var orgAttrs = parser.orgAttributes(element); + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered); + var events = parser.getEvents(scope, filtered); + var attrsToObserve = parser.getAttrsToObserve(orgAttrs); + var renderer = getDirectionsRenderer(options, events); + mapController.addObject("directionsRenderers", renderer); + attrsToObserve.forEach(function(attrName) { + (function(attrName) { + attrs.$observe(attrName, function(val) { + if (attrName == "panel") { + $timeout(function() { + var panel = document.getElementById(val) || document.querySelector(val); + void 0; + panel && renderer.setPanel(panel); + }); + } else if (options[attrName] !== val) { + var optionValue = parser.toOptionValue(val, { + key: attrName + }); + void 0; + options[attrName] = optionValue; + updateRoute(renderer, options); + } + }); + })(attrName); + }); + NgMap.getMap().then(function() { + updateRoute(renderer, options); + }); + element.bind("$destroy", function() { + mapController.deleteObject("directionsRenderers", renderer); + }); + }; + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: linkFunc + }; }; -}); + directions.$inject = [ "Attr2MapOptions", "$timeout", "NavigatorGeolocation", "NgMap" ]; + angular.module("ngMap").directive("directions", directions); +})(); -angular.module("ui.bootstrap.transition", []).value("$transitionSuppressDeprecated", false).factory("$transition", [ "$q", "$timeout", "$rootScope", "$log", "$transitionSuppressDeprecated", function($q, $timeout, $rootScope, $log, $transitionSuppressDeprecated) { - if (!$transitionSuppressDeprecated) { - $log.warn("$transition is now deprecated. Use $animate from ngAnimate instead."); - } - var $transition = function(element, trigger, options) { - options = options || {}; - var deferred = $q.defer(); - var endEventName = $transition[options.animation ? "animationEndEventName" : "transitionEndEventName"]; - var transitionEndHandler = function(event) { - $rootScope.$apply(function() { - element.unbind(endEventName, transitionEndHandler); - deferred.resolve(element); +(function() { + "use strict"; + angular.module("ngMap").directive("drawingManager", [ "Attr2MapOptions", function(Attr2MapOptions) { + var parser = Attr2MapOptions; + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered); + var controlOptions = parser.getControlOptions(filtered); + var events = parser.getEvents(scope, filtered); + void 0; + var drawingManager = new google.maps.drawing.DrawingManager({ + drawingMode: options.drawingmode, + drawingControl: options.drawingcontrol, + drawingControlOptions: controlOptions.drawingControlOptions, + circleOptions: options.circleoptions, + markerOptions: options.markeroptions, + polygonOptions: options.polygonoptions, + polylineOptions: options.polylineoptions, + rectangleOptions: options.rectangleoptions + }); + for (var eventName in events) { + google.maps.event.addListener(drawingManager, eventName, events[eventName]); + } + mapController.addObject("mapDrawingManager", drawingManager); + } + }; + } ]); +})(); + +(function() { + "use strict"; + angular.module("ngMap").directive("dynamicMapsEngineLayer", [ "Attr2MapOptions", function(Attr2MapOptions) { + var parser = Attr2MapOptions; + var getDynamicMapsEngineLayer = function(options, events) { + var layer = new google.maps.visualization.DynamicMapsEngineLayer(options); + for (var eventName in events) { + google.maps.event.addListener(layer, eventName, events[eventName]); + } + return layer; + }; + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered); + var events = parser.getEvents(scope, filtered, events); + void 0; + var layer = getDynamicMapsEngineLayer(options, events); + mapController.addObject("mapsEngineLayers", layer); + } + }; + } ]); +})(); + +(function() { + "use strict"; + angular.module("ngMap").directive("fusionTablesLayer", [ "Attr2MapOptions", function(Attr2MapOptions) { + var parser = Attr2MapOptions; + var getLayer = function(options, events) { + var layer = new google.maps.FusionTablesLayer(options); + for (var eventName in events) { + google.maps.event.addListener(layer, eventName, events[eventName]); + } + return layer; + }; + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered); + var events = parser.getEvents(scope, filtered, events); + void 0; + var layer = getLayer(options, events); + mapController.addObject("fusionTablesLayers", layer); + } + }; + } ]); +})(); + +(function() { + "use strict"; + angular.module("ngMap").directive("heatmapLayer", [ "Attr2MapOptions", "$window", function(Attr2MapOptions, $window) { + var parser = Attr2MapOptions; + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered); + options.data = $window[attrs.data] || scope[attrs.data]; + if (options.data instanceof Array) { + options.data = new google.maps.MVCArray(options.data); + } else { + throw "invalid heatmap data"; + } + var layer = new google.maps.visualization.HeatmapLayer(options); + var events = parser.getEvents(scope, filtered); + void 0; + mapController.addObject("heatmapLayers", layer); + } + }; + } ]); +})(); + +(function() { + "use strict"; + var infoWindow = function(Attr2MapOptions, $compile, $timeout, $parse, NgMap) { + var parser = Attr2MapOptions; + var getInfoWindow = function(options, events, element) { + var infoWindow; + if (options.position && !(options.position instanceof google.maps.LatLng)) { + delete options.position; + } + infoWindow = new google.maps.InfoWindow(options); + if (Object.keys(events).length > 0) { + void 0; + } + for (var eventName in events) { + if (eventName) { + google.maps.event.addListener(infoWindow, eventName, events[eventName]); + } + } + var template = element.html().trim(); + if (angular.element(template).length != 1) { + throw "info-window working as a template must have a container"; + } + infoWindow.__template = template.replace(/\s?ng-non-bindable[='"]+/, ""); + infoWindow.__open = function(map, scope, anchor) { + $timeout(function() { + anchor && (scope.anchor = anchor); + var el = $compile(infoWindow.__template)(scope); + infoWindow.setContent(el[0]); + scope.$apply(); + if (anchor && anchor.getPosition) { + infoWindow.open(map, anchor); + } else if (anchor && anchor instanceof google.maps.LatLng) { + infoWindow.open(map); + infoWindow.setPosition(anchor); + } else { + infoWindow.open(map); + } + }); + }; + return infoWindow; + }; + var linkFunc = function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + element.css("display", "none"); + var orgAttrs = parser.orgAttributes(element); + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered); + var events = parser.getEvents(scope, filtered); + void 0; + var address; + if (options.position && !(options.position instanceof google.maps.LatLng)) { + address = options.position; + } + var infoWindow = getInfoWindow(options, events, element); + if (address) { + NgMap.getGeoLocation(address).then(function(latlng) { + infoWindow.setPosition(latlng); + infoWindow.__open(mapController.map, scope, latlng); + var geoCallback = attrs.geoCallback; + geoCallback && $parse(geoCallback)(scope); + }); + } + mapController.addObject("infoWindows", infoWindow); + mapController.observeAttrSetObj(orgAttrs, attrs, infoWindow); + NgMap.getMap().then(function(map) { + infoWindow.visible && infoWindow.__open(map, scope); + if (infoWindow.visibleOnMarker) { + var markerId = infoWindow.visibleOnMarker; + infoWindow.__open(map, scope, map.markers[markerId]); + } + map.showInfoWindow = map.showInfoWindow || function(p1, p2, p3) { + var id = typeof p1 == "string" ? p1 : p2; + var marker = typeof p1 == "string" ? p2 : p3; + var infoWindow = mapController.map.infoWindows[id]; + var anchor = marker ? marker : this.getPosition ? this : null; + infoWindow.__open(mapController.map, scope, anchor); + if (mapController.singleInfoWindow) { + if (mapController.lastInfoWindow) { + scope.hideInfoWindow(mapController.lastInfoWindow); + } + mapController.lastInfoWindow = id; + } + }; + map.hideInfoWindow = scope.hideInfoWindow || function(p1, p2) { + var id = typeof p1 == "string" ? p1 : p2; + var infoWindow = mapController.map.infoWindows[id]; + infoWindow.close(); + }; + scope.showInfoWindow = map.showInfoWindow; + scope.hideInfoWindow = map.hideInfoWindow; }); }; - if (endEventName) { - element.bind(endEventName, transitionEndHandler); - } - $timeout(function() { - if (angular.isString(trigger)) { - element.addClass(trigger); - } else if (angular.isFunction(trigger)) { - trigger(element); - } else if (angular.isObject(trigger)) { - element.css(trigger); + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: linkFunc + }; + }; + infoWindow.$inject = [ "Attr2MapOptions", "$compile", "$timeout", "$parse", "NgMap" ]; + angular.module("ngMap").directive("infoWindow", infoWindow); +})(); + +(function() { + "use strict"; + angular.module("ngMap").directive("kmlLayer", [ "Attr2MapOptions", function(Attr2MapOptions) { + var parser = Attr2MapOptions; + var getKmlLayer = function(options, events) { + var kmlLayer = new google.maps.KmlLayer(options); + for (var eventName in events) { + google.maps.event.addListener(kmlLayer, eventName, events[eventName]); } - if (!endEventName) { - deferred.resolve(element); + return kmlLayer; + }; + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var orgAttrs = parser.orgAttributes(element); + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered); + var events = parser.getEvents(scope, filtered); + void 0; + var kmlLayer = getKmlLayer(options, events); + mapController.addObject("kmlLayers", kmlLayer); + mapController.observeAttrSetObj(orgAttrs, attrs, kmlLayer); + element.bind("$destroy", function() { + mapController.deleteObject("kmlLayers", kmlLayer); + }); } - }); - deferred.promise.cancel = function() { - if (endEventName) { - element.unbind(endEventName, transitionEndHandler); + }; + } ]); +})(); + +(function() { + "use strict"; + angular.module("ngMap").directive("mapData", [ "Attr2MapOptions", "NgMap", function(Attr2MapOptions, NgMap) { + var parser = Attr2MapOptions; + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: function(scope, element, attrs) { + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered); + var events = parser.getEvents(scope, filtered, events); + void 0; + NgMap.getMap().then(function(map) { + for (var key in options) { + var val = options[key]; + if (typeof scope[val] === "function") { + map.data[key](scope[val]); + } else { + map.data[key](val); + } + } + for (var eventName in events) { + map.data.addListener(eventName, events[eventName]); + } + }); } - deferred.reject("Transition cancelled"); }; - return deferred.promise; + } ]); +})(); + +(function() { + "use strict"; + var $timeout, $compile, src, savedHtml; + var preLinkFunc = function(scope, element, attrs) { + var mapsUrl = attrs.mapLazyLoadParams || attrs.mapLazyLoad; + window.lazyLoadCallback = function() { + void 0; + $timeout(function() { + element.html(savedHtml); + $compile(element.contents())(scope); + }, 100); + }; + if (window.google === undefined || window.google.maps === undefined) { + var scriptEl = document.createElement("script"); + void 0; + scriptEl.src = mapsUrl + (mapsUrl.indexOf("?") > -1 ? "&" : "?") + "callback=lazyLoadCallback"; + document.body.appendChild(scriptEl); + } else { + element.html(savedHtml); + $compile(element.contents())(scope); + } }; - var transElement = document.createElement("trans"); - var transitionEndEventNames = { - WebkitTransition: "webkitTransitionEnd", - MozTransition: "transitionend", - OTransition: "oTransitionEnd", - transition: "transitionend" + var compileFunc = function(tElement, tAttrs) { + !tAttrs.mapLazyLoad && void 0; + savedHtml = tElement.html(); + src = tAttrs.mapLazyLoad; + if (document.querySelector('script[src="' + src + (src.indexOf("?") > -1 ? "&" : "?") + 'callback=lazyLoadCallback"]')) { + return false; + } + tElement.html(""); + return { + pre: preLinkFunc + }; }; - var animationEndEventNames = { - WebkitTransition: "webkitAnimationEnd", - MozTransition: "animationend", - OTransition: "oAnimationEnd", - transition: "animationend" + var mapLazyLoad = function(_$compile_, _$timeout_) { + $compile = _$compile_, $timeout = _$timeout_; + return { + compile: compileFunc + }; }; - function findEndEventName(endEventNames) { - for (var name in endEventNames) { - if (transElement.style[name] !== undefined) { - return endEventNames[name]; + mapLazyLoad.$inject = [ "$compile", "$timeout" ]; + angular.module("ngMap").directive("mapLazyLoad", mapLazyLoad); +})(); + +(function() { + "use strict"; + angular.module("ngMap").directive("mapType", [ "$parse", "NgMap", function($parse, NgMap) { + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var mapTypeName = attrs.name, mapTypeObject; + if (!mapTypeName) { + throw "invalid map-type name"; + } + mapTypeObject = $parse(attrs.object)(scope); + if (!mapTypeObject) { + throw "invalid map-type object"; + } + NgMap.getMap().then(function(map) { + map.mapTypes.set(mapTypeName, mapTypeObject); + }); + mapController.addObject("mapTypes", mapTypeObject); } - } - } - $transition.transitionEndEventName = findEndEventName(transitionEndEventNames); - $transition.animationEndEventName = findEndEventName(animationEndEventNames); - return $transition; -} ]); + }; + } ]); +})(); -angular.module("ui.bootstrap.typeahead", [ "ui.bootstrap.position" ]).factory("typeaheadParser", [ "$parse", function($parse) { - var TYPEAHEAD_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w\d]*))\s+in\s+([\s\S]+?)$/; - return { - parse: function(input) { - var match = input.match(TYPEAHEAD_REGEXP); - if (!match) { - throw new Error('Expected typeahead specification in form of "_modelValue_ (as _label_)? for _item_ in _collection_"' + ' but got "' + input + '".'); +(function() { + "use strict"; + var mapDirective = function() { + return { + restrict: "AE", + controller: "__MapController", + conrollerAs: "ngmap" + }; + }; + angular.module("ngMap").directive("map", [ mapDirective ]); + angular.module("ngMap").directive("ngMap", [ mapDirective ]); +})(); + +(function() { + "use strict"; + angular.module("ngMap").directive("mapsEngineLayer", [ "Attr2MapOptions", function(Attr2MapOptions) { + var parser = Attr2MapOptions; + var getMapsEngineLayer = function(options, events) { + var layer = new google.maps.visualization.MapsEngineLayer(options); + for (var eventName in events) { + google.maps.event.addListener(layer, eventName, events[eventName]); } - return { - itemName: match[3], - source: $parse(match[4]), - viewMapper: $parse(match[2] || match[1]), - modelMapper: $parse(match[1]) - }; + return layer; + }; + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered); + var events = parser.getEvents(scope, filtered, events); + void 0; + var layer = getMapsEngineLayer(options, events); + mapController.addObject("mapsEngineLayers", layer); + } + }; + } ]); +})(); + +(function() { + "use strict"; + var parser, $parse, NgMap; + var getMarker = function(options, events) { + var marker; + if (NgMap.defaultOptions.marker) { + for (var key in NgMap.defaultOptions.marker) { + if (typeof options[key] == "undefined") { + void 0; + options[key] = NgMap.defaultOptions.marker[key]; + } + } + } + if (!(options.position instanceof google.maps.LatLng)) { + options.position = new google.maps.LatLng(0, 0); + } + marker = new google.maps.Marker(options); + if (Object.keys(events).length > 0) { + void 0; + } + for (var eventName in events) { + if (eventName) { + google.maps.event.addListener(marker, eventName, events[eventName]); + } + } + return marker; + }; + var linkFunc = function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var orgAttrs = parser.orgAttributes(element); + var filtered = parser.filter(attrs); + var markerOptions = parser.getOptions(filtered, scope); + var markerEvents = parser.getEvents(scope, filtered); + void 0; + var address; + if (!(markerOptions.position instanceof google.maps.LatLng)) { + address = markerOptions.position; + } + var marker = getMarker(markerOptions, markerEvents); + mapController.addObject("markers", marker); + if (address) { + NgMap.getGeoLocation(address).then(function(latlng) { + marker.setPosition(latlng); + markerOptions.centered && marker.map.setCenter(latlng); + var geoCallback = attrs.geoCallback; + geoCallback && $parse(geoCallback)(scope); + }); } + mapController.observeAttrSetObj(orgAttrs, attrs, marker); + element.bind("$destroy", function() { + mapController.deleteObject("markers", marker); + }); }; -} ]).directive("typeahead", [ "$compile", "$parse", "$q", "$timeout", "$document", "$window", "$rootScope", "$position", "typeaheadParser", function($compile, $parse, $q, $timeout, $document, $window, $rootScope, $position, typeaheadParser) { - var HOT_KEYS = [ 9, 13, 27, 38, 40 ]; - var eventDebounceTime = 200; - return { - require: [ "ngModel", "^?ngModelOptions" ], - link: function(originalScope, element, attrs, ctrls) { - var modelCtrl = ctrls[0]; - var ngModelOptions = ctrls[1]; - var minLength = originalScope.$eval(attrs.typeaheadMinLength); - if (!minLength && minLength !== 0) { - minLength = 1; + var marker = function(Attr2MapOptions, _$parse_, _NgMap_) { + parser = Attr2MapOptions; + $parse = _$parse_; + NgMap = _NgMap_; + return { + restrict: "E", + require: [ "^?map", "?^ngMap" ], + link: linkFunc + }; + }; + marker.$inject = [ "Attr2MapOptions", "$parse", "NgMap" ]; + angular.module("ngMap").directive("marker", marker); +})(); + +(function() { + "use strict"; + angular.module("ngMap").directive("overlayMapType", [ "NgMap", function(NgMap) { + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var initMethod = attrs.initMethod || "insertAt"; + var overlayMapTypeObject = scope[attrs.object]; + NgMap.getMap().then(function(map) { + if (initMethod == "insertAt") { + var index = parseInt(attrs.index, 10); + map.overlayMapTypes.insertAt(index, overlayMapTypeObject); + } else if (initMethod == "push") { + map.overlayMapTypes.push(overlayMapTypeObject); + } + }); + mapController.addObject("overlayMapTypes", overlayMapTypeObject); } - var waitTime = originalScope.$eval(attrs.typeaheadWaitMs) || 0; - var isEditable = originalScope.$eval(attrs.typeaheadEditable) !== false; - var isLoadingSetter = $parse(attrs.typeaheadLoading).assign || angular.noop; - var onSelectCallback = $parse(attrs.typeaheadOnSelect); - var isSelectOnBlur = angular.isDefined(attrs.typeaheadSelectOnBlur) ? originalScope.$eval(attrs.typeaheadSelectOnBlur) : false; - var isNoResultsSetter = $parse(attrs.typeaheadNoResults).assign || angular.noop; - var inputFormatter = attrs.typeaheadInputFormatter ? $parse(attrs.typeaheadInputFormatter) : undefined; - var appendToBody = attrs.typeaheadAppendToBody ? originalScope.$eval(attrs.typeaheadAppendToBody) : false; - var focusFirst = originalScope.$eval(attrs.typeaheadFocusFirst) !== false; - var selectOnExact = attrs.typeaheadSelectOnExact ? originalScope.$eval(attrs.typeaheadSelectOnExact) : false; - var parsedModel = $parse(attrs.ngModel); - var invokeModelSetter = $parse(attrs.ngModel + "($$$p)"); - var $setModelValue = function(scope, newValue) { - if (angular.isFunction(parsedModel(originalScope)) && ngModelOptions && ngModelOptions.$options && ngModelOptions.$options.getterSetter) { - return invokeModelSetter(scope, { - $$$p: newValue + }; + } ]); +})(); + +(function() { + "use strict"; + var placesAutoComplete = function(Attr2MapOptions, $timeout) { + var parser = Attr2MapOptions; + var linkFunc = function(scope, element, attrs, ngModelCtrl) { + if (attrs.placesAutoComplete === "false") { + return false; + } + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered); + var events = parser.getEvents(scope, filtered); + void 0; + var autocomplete = new google.maps.places.Autocomplete(element[0], options); + for (var eventName in events) { + google.maps.event.addListener(autocomplete, eventName, events[eventName]); + } + var updateModel = function() { + $timeout(function() { + ngModelCtrl && ngModelCtrl.$setViewValue(element.val()); + }, 100); + }; + google.maps.event.addListener(autocomplete, "place_changed", updateModel); + element[0].addEventListener("change", updateModel); + attrs.$observe("types", function(val) { + if (val) { + void 0; + var optionValue = parser.toOptionValue(val, { + key: "types" }); - } else { - return parsedModel.assign(scope, newValue); + void 0; + autocomplete.setTypes(optionValue); } - }; - var parserResult = typeaheadParser.parse(attrs.typeahead); - var hasFocus; - var selected; - var scope = originalScope.$new(); - var offDestroy = originalScope.$on("$destroy", function() { - scope.$destroy(); }); - scope.$on("$destroy", offDestroy); - var popupId = "typeahead-" + scope.$id + "-" + Math.floor(Math.random() * 1e4); - element.attr({ - "aria-autocomplete": "list", - "aria-expanded": false, - "aria-owns": popupId + }; + return { + restrict: "A", + require: "?ngModel", + link: linkFunc + }; + }; + placesAutoComplete.$inject = [ "Attr2MapOptions", "$timeout" ]; + angular.module("ngMap").directive("placesAutoComplete", placesAutoComplete); +})(); + +(function() { + "use strict"; + var getShape = function(options, events) { + var shape; + var shapeName = options.name; + delete options.name; + void 0; + switch (shapeName) { + case "circle": + if (!(options.center instanceof google.maps.LatLng)) { + options.center = new google.maps.LatLng(0, 0); + } + shape = new google.maps.Circle(options); + break; + + case "polygon": + shape = new google.maps.Polygon(options); + break; + + case "polyline": + shape = new google.maps.Polyline(options); + break; + + case "rectangle": + shape = new google.maps.Rectangle(options); + break; + + case "groundOverlay": + case "image": + var url = options.url; + var opts = { + opacity: options.opacity, + clickable: options.clickable, + id: options.id + }; + shape = new google.maps.GroundOverlay(url, options.bounds, opts); + break; + } + for (var eventName in events) { + if (events[eventName]) { + google.maps.event.addListener(shape, eventName, events[eventName]); + } + } + return shape; + }; + var shape = function(Attr2MapOptions, $parse, NgMap) { + var parser = Attr2MapOptions; + var linkFunc = function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var orgAttrs = parser.orgAttributes(element); + var filtered = parser.filter(attrs); + var shapeOptions = parser.getOptions(filtered); + var shapeEvents = parser.getEvents(scope, filtered); + var address, shapeType; + shapeType = shapeOptions.name; + if (!(shapeOptions.center instanceof google.maps.LatLng)) { + address = shapeOptions.center; + } + var shape = getShape(shapeOptions, shapeEvents); + mapController.addObject("shapes", shape); + if (address && shapeType == "circle") { + NgMap.getGeoLocation(address).then(function(latlng) { + shape.setCenter(latlng); + shape.centered && shape.map.setCenter(latlng); + var geoCallback = attrs.geoCallback; + geoCallback && $parse(geoCallback)(scope); + }); + } + mapController.observeAttrSetObj(orgAttrs, attrs, shape); + element.bind("$destroy", function() { + mapController.deleteObject("shapes", shape); }); - var popUpEl = angular.element("
      "); - popUpEl.attr({ - id: popupId, - matches: "matches", - active: "activeIdx", - select: "select(activeIdx)", - "move-in-progress": "moveInProgress", - query: "query", - position: "position" + }; + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: linkFunc + }; + }; + shape.$inject = [ "Attr2MapOptions", "$parse", "NgMap" ]; + angular.module("ngMap").directive("shape", shape); +})(); + +(function() { + "use strict"; + var streetViewPanorama = function(Attr2MapOptions, NgMap) { + var parser = Attr2MapOptions; + var getStreetViewPanorama = function(map, options, events) { + var svp, container; + if (options.container) { + container = document.getElementById(options.container); + container = container || document.querySelector(options.container); + } + if (container) { + svp = new google.maps.StreetViewPanorama(container, options); + } else { + svp = map.getStreetView(); + svp.setOptions(options); + } + for (var eventName in events) { + eventName && google.maps.event.addListener(svp, eventName, events[eventName]); + } + return svp; + }; + var linkFunc = function(scope, element, attrs) { + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered); + var controlOptions = parser.getControlOptions(filtered); + var svpOptions = angular.extend(options, controlOptions); + var svpEvents = parser.getEvents(scope, filtered); + void 0; + NgMap.getMap().then(function(map) { + var svp = getStreetViewPanorama(map, svpOptions, svpEvents); + map.setStreetView(svp); + !svp.getPosition() && svp.setPosition(map.getCenter()); + google.maps.event.addListener(svp, "position_changed", function() { + if (svp.getPosition() !== map.getCenter()) { + map.setCenter(svp.getPosition()); + } + }); + var listener = google.maps.event.addListener(map, "center_changed", function() { + svp.setPosition(map.getCenter()); + google.maps.event.removeListener(listener); + }); }); - if (angular.isDefined(attrs.typeaheadTemplateUrl)) { - popUpEl.attr("template-url", attrs.typeaheadTemplateUrl); + }; + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: linkFunc + }; + }; + streetViewPanorama.$inject = [ "Attr2MapOptions", "NgMap" ]; + angular.module("ngMap").directive("streetViewPanorama", streetViewPanorama); +})(); + +(function() { + "use strict"; + angular.module("ngMap").directive("trafficLayer", [ "Attr2MapOptions", function(Attr2MapOptions) { + var parser = Attr2MapOptions; + var getLayer = function(options, events) { + var layer = new google.maps.TrafficLayer(options); + for (var eventName in events) { + google.maps.event.addListener(layer, eventName, events[eventName]); } - if (angular.isDefined(attrs.typeaheadPopupTemplateUrl)) { - popUpEl.attr("popup-template-url", attrs.typeaheadPopupTemplateUrl); + return layer; + }; + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var orgAttrs = parser.orgAttributes(element); + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered); + var events = parser.getEvents(scope, filtered); + void 0; + var layer = getLayer(options, events); + mapController.addObject("trafficLayers", layer); + mapController.observeAttrSetObj(orgAttrs, attrs, layer); + element.bind("$destroy", function() { + mapController.deleteObject("trafficLayers", layer); + }); } - var resetMatches = function() { - scope.matches = []; - scope.activeIdx = -1; - element.attr("aria-expanded", false); - }; - var getMatchId = function(index) { - return popupId + "-option-" + index; - }; - scope.$watch("activeIdx", function(index) { - if (index < 0) { - element.removeAttr("aria-activedescendant"); - } else { - element.attr("aria-activedescendant", getMatchId(index)); - } - }); - var inputIsExactMatch = function(inputValue, index) { - if (scope.matches.length > index && inputValue) { - return inputValue.toUpperCase() === scope.matches[index].label.toUpperCase(); - } - return false; - }; - var getMatchesAsync = function(inputValue) { - var locals = { - $viewValue: inputValue - }; - isLoadingSetter(originalScope, true); - isNoResultsSetter(originalScope, false); - $q.when(parserResult.source(originalScope, locals)).then(function(matches) { - var onCurrentRequest = inputValue === modelCtrl.$viewValue; - if (onCurrentRequest && hasFocus) { - if (matches && matches.length > 0) { - scope.activeIdx = focusFirst ? 0 : -1; - isNoResultsSetter(originalScope, false); - scope.matches.length = 0; - for (var i = 0; i < matches.length; i++) { - locals[parserResult.itemName] = matches[i]; - scope.matches.push({ - id: getMatchId(i), - label: parserResult.viewMapper(scope, locals), - model: matches[i] - }); - } - scope.query = inputValue; - recalculatePosition(); - element.attr("aria-expanded", true); - if (selectOnExact && scope.matches.length === 1 && inputIsExactMatch(inputValue, 0)) { - scope.select(0); - } + }; + } ]); +})(); + +(function() { + "use strict"; + angular.module("ngMap").directive("transitLayer", [ "Attr2MapOptions", function(Attr2MapOptions) { + var parser = Attr2MapOptions; + var getLayer = function(options, events) { + var layer = new google.maps.TransitLayer(options); + for (var eventName in events) { + google.maps.event.addListener(layer, eventName, events[eventName]); + } + return layer; + }; + return { + restrict: "E", + require: [ "?^map", "?^ngMap" ], + link: function(scope, element, attrs, mapController) { + mapController = mapController[0] || mapController[1]; + var orgAttrs = parser.orgAttributes(element); + var filtered = parser.filter(attrs); + var options = parser.getOptions(filtered); + var events = parser.getEvents(scope, filtered); + void 0; + var layer = getLayer(options, events); + mapController.addObject("transitLayers", layer); + mapController.observeAttrSetObj(orgAttrs, attrs, layer); + element.bind("$destroy", function() { + mapController.deleteObject("transitLayers", layer); + }); + } + }; + } ]); +})(); + +(function() { + "use strict"; + var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g; + var MOZ_HACK_REGEXP = /^moz([A-Z])/; + var camelCaseFilter = function() { + return function(name) { + return name.replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) { + return offset ? letter.toUpperCase() : letter; + }).replace(MOZ_HACK_REGEXP, "Moz$1"); + }; + }; + angular.module("ngMap").filter("camelCase", camelCaseFilter); +})(); + +(function() { + "use strict"; + var jsonizeFilter = function() { + return function(str) { + try { + JSON.parse(str); + return str; + } catch (e) { + return str.replace(/([\$\w]+)\s*:/g, function(_, $1) { + return '"' + $1 + '":'; + }).replace(/'([^']+)'/g, function(_, $1) { + return '"' + $1 + '"'; + }); + } + }; + }; + angular.module("ngMap").filter("jsonize", jsonizeFilter); +})(); + +(function() { + "use strict"; + var isoDateRE = /^(\d{4}\-\d\d\-\d\d([tT][\d:\.]*)?)([zZ]|([+\-])(\d\d):?(\d\d))?$/; + var Attr2MapOptions = function($parse, $timeout, $log, NavigatorGeolocation, GeoCoder, camelCaseFilter, jsonizeFilter) { + var orgAttributes = function(el) { + el.length > 0 && (el = el[0]); + var orgAttributes = {}; + for (var i = 0; i < el.attributes.length; i++) { + var attr = el.attributes[i]; + orgAttributes[attr.name] = attr.value; + } + return orgAttributes; + }; + var getJSON = function(input) { + var re = /^[\+\-]?[0-9\.]+,[ ]*\ ?[\+\-]?[0-9\.]+$/; + if (input.match(re)) { + input = "[" + input + "]"; + } + return JSON.parse(jsonizeFilter(input)); + }; + var getLatLng = function(input) { + var output = input; + if (input[0].constructor == Array) { + output = input.map(function(el) { + return new google.maps.LatLng(el[0], el[1]); + }); + } else if (!isNaN(parseFloat(input[0])) && isFinite(input[0])) { + output = new google.maps.LatLng(output[0], output[1]); + } + return output; + }; + var toOptionValue = function(input, options) { + var output; + try { + output = getNumber(input); + } catch (err) { + try { + var output = getJSON(input); + if (output instanceof Array) { + if (output[0].constructor == Object) { + output = output; } else { - resetMatches(); - isNoResultsSetter(originalScope, true); + output = getLatLng(output); } + } else if (output === Object(output)) { + var newOptions = options; + newOptions.doNotConverStringToNumber = true; + output = getOptions(output, newOptions); } - if (onCurrentRequest) { - isLoadingSetter(originalScope, false); + } catch (err2) { + if (input.match(/^[A-Z][a-zA-Z0-9]+\(.*\)$/)) { + try { + var exp = "new google.maps." + input; + output = eval(exp); + } catch (e) { + output = input; + } + } else if (input.match(/^([A-Z][a-zA-Z0-9]+)\.([A-Z]+)$/)) { + try { + var matches = input.match(/^([A-Z][a-zA-Z0-9]+)\.([A-Z]+)$/); + output = google.maps[matches[1]][matches[2]]; + } catch (e) { + output = input; + } + } else if (input.match(/^[A-Z]+$/)) { + try { + var capitalizedKey = options.key.charAt(0).toUpperCase() + options.key.slice(1); + if (options.key.match(/temperatureUnit|windSpeedUnit|labelColor/)) { + capitalizedKey = capitalizedKey.replace(/s$/, ""); + output = google.maps.weather[capitalizedKey][input]; + } else { + output = google.maps[capitalizedKey][input]; + } + } catch (e) { + output = input; + } + } else if (input.match(isoDateRE)) { + try { + output = new Date(input); + } catch (e) { + output = input; + } + } else { + output = input; } - }, function() { - resetMatches(); - isLoadingSetter(originalScope, false); - isNoResultsSetter(originalScope, true); - }); - }; - if (appendToBody) { - angular.element($window).bind("resize", fireRecalculating); - $document.find("body").bind("scroll", fireRecalculating); - } - var timeoutEventPromise; - scope.moveInProgress = false; - function fireRecalculating() { - if (!scope.moveInProgress) { - scope.moveInProgress = true; - scope.$digest(); } - if (timeoutEventPromise) { - $timeout.cancel(timeoutEventPromise); - } - timeoutEventPromise = $timeout(function() { - if (scope.matches.length) { - recalculatePosition(); - } - scope.moveInProgress = false; - scope.$digest(); - }, eventDebounceTime); } - function recalculatePosition() { - scope.position = appendToBody ? $position.offset(element) : $position.position(element); - scope.position.top += element.prop("offsetHeight"); + if (options.key == "bounds" && output instanceof Array) { + output = new google.maps.LatLngBounds(output[0], output[1]); } - resetMatches(); - scope.query = undefined; - var timeoutPromise; - var scheduleSearchWithTimeout = function(inputValue) { - timeoutPromise = $timeout(function() { - getMatchesAsync(inputValue); - }, waitTime); - }; - var cancelPreviousTimeout = function() { - if (timeoutPromise) { - $timeout.cancel(timeoutPromise); - } - }; - modelCtrl.$parsers.unshift(function(inputValue) { - hasFocus = true; - if (minLength === 0 || inputValue && inputValue.length >= minLength) { - if (waitTime > 0) { - cancelPreviousTimeout(); - scheduleSearchWithTimeout(inputValue); - } else { - getMatchesAsync(inputValue); + if (options.key == "icons" && output instanceof Array) { + for (var i = 0; i < output.length; i++) { + var el = output[i]; + if (el.icon.path.match(/^[A-Z_]+$/)) { + el.icon.path = google.maps.SymbolPath[el.icon.path]; } - } else { - isLoadingSetter(originalScope, false); - cancelPreviousTimeout(); - resetMatches(); } - if (isEditable) { - return inputValue; - } else { - if (!inputValue) { - modelCtrl.$setValidity("editable", true); - return null; - } else { - modelCtrl.$setValidity("editable", false); - return undefined; + } + if (options.key == "icon" && output instanceof Object) { + if (("" + output.path).match(/^[A-Z_]+$/)) { + output.path = google.maps.SymbolPath[output.path]; + } + for (var key in output) { + var arr = output[key]; + if (key == "anchor" || key == "origin") { + output[key] = new google.maps.Point(arr[0], arr[1]); + } else if (key == "size" || key == "scaledSize") { + output[key] = new google.maps.Size(arr[0], arr[1]); } } - }); - modelCtrl.$formatters.push(function(modelValue) { - var candidateViewValue, emptyViewValue; - var locals = {}; - if (!isEditable) { - modelCtrl.$setValidity("editable", true); + } + return output; + }; + var getAttrsToObserve = function(attrs) { + var attrsToObserve = []; + if (!attrs.noWatcher) { + for (var attrName in attrs) { + var attrValue = attrs[attrName]; + void 0; + if (attrValue && attrValue.match(/\{\{.*\}\}/)) { + void 0; + attrsToObserve.push(camelCaseFilter(attrName)); + } } - if (inputFormatter) { - locals.$model = modelValue; - return inputFormatter(originalScope, locals); + } + return attrsToObserve; + }; + var filter = function(attrs) { + var options = {}; + for (var key in attrs) { + if (key.match(/^\$/) || key.match(/^ng[A-Z]/)) { + void 0; } else { - locals[parserResult.itemName] = modelValue; - candidateViewValue = parserResult.viewMapper(originalScope, locals); - locals[parserResult.itemName] = undefined; - emptyViewValue = parserResult.viewMapper(originalScope, locals); - return candidateViewValue !== emptyViewValue ? candidateViewValue : modelValue; + options[key] = attrs[key]; } - }); - scope.select = function(activeIdx) { - var locals = {}; - var model, item; - selected = true; - locals[parserResult.itemName] = item = scope.matches[activeIdx].model; - model = parserResult.modelMapper(originalScope, locals); - $setModelValue(originalScope, model); - modelCtrl.$setValidity("editable", true); - modelCtrl.$setValidity("parse", true); - onSelectCallback(originalScope, { - $item: item, - $model: model, - $label: parserResult.viewMapper(originalScope, locals) - }); - resetMatches(); - if (scope.$eval(attrs.typeaheadFocusOnSelect) !== false) { - $timeout(function() { - element[0].focus(); - }, 0, false); + } + return options; + }; + var getOptions = function(attrs, params) { + var options = {}; + for (var key in attrs) { + if (attrs[key] || attrs[key] === 0) { + if (key.match(/^on[A-Z]/)) { + continue; + } else if (key.match(/ControlOptions$/)) { + continue; + } else { + if (typeof attrs[key] !== "string") { + options[key] = attrs[key]; + } else { + if (params && params.doNotConverStringToNumber && attrs[key].match(/^[0-9]+$/)) { + options[key] = attrs[key]; + } else { + options[key] = toOptionValue(attrs[key], { + key: key + }); + } + } + } } + } + return options; + }; + var getEvents = function(scope, attrs) { + var events = {}; + var toLowercaseFunc = function($1) { + return "_" + $1.toLowerCase(); }; - element.bind("keydown", function(evt) { - if (scope.matches.length === 0 || HOT_KEYS.indexOf(evt.which) === -1) { - return; - } - if (scope.activeIdx === -1 && (evt.which === 9 || evt.which === 13)) { - resetMatches(); - scope.$digest(); - return; - } - evt.preventDefault(); - if (evt.which === 40) { - scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length; - scope.$digest(); - } else if (evt.which === 38) { - scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1; - scope.$digest(); - } else if (evt.which === 13 || evt.which === 9) { - scope.$apply(function() { - scope.select(scope.activeIdx); + var EventFunc = function(attrValue) { + var matches = attrValue.match(/([^\(]+)\(([^\)]*)\)/); + var funcName = matches[1]; + var argsStr = matches[2].replace(/event[ ,]*/, ""); + var argsExpr = $parse("[" + argsStr + "]"); + return function(event) { + var args = argsExpr(scope); + function index(obj, i) { + return obj[i]; + } + var f = funcName.split(".").reduce(index, scope); + f && f.apply(this, [ event ].concat(args)); + $timeout(function() { + scope.$apply(); }); - } else if (evt.which === 27) { - evt.stopPropagation(); - resetMatches(); - scope.$digest(); + }; + }; + for (var key in attrs) { + if (attrs[key]) { + if (!key.match(/^on[A-Z]/)) { + continue; + } + var eventName = key.replace(/^on/, ""); + eventName = eventName.charAt(0).toLowerCase() + eventName.slice(1); + eventName = eventName.replace(/([A-Z])/g, toLowercaseFunc); + var attrValue = attrs[key]; + events[eventName] = new EventFunc(attrValue); } - }); - element.bind("blur", function() { - if (isSelectOnBlur && scope.matches.length && scope.activeIdx !== -1 && !selected) { - selected = true; - scope.$apply(function() { - scope.select(scope.activeIdx); + } + return events; + }; + var getControlOptions = function(filtered) { + var controlOptions = {}; + if (typeof filtered != "object") { + return false; + } + for (var attr in filtered) { + if (filtered[attr]) { + if (!attr.match(/(.*)ControlOptions$/)) { + continue; + } + var orgValue = filtered[attr]; + var newValue = orgValue.replace(/'/g, '"'); + newValue = newValue.replace(/([^"]+)|("[^"]+")/g, function($0, $1, $2) { + if ($1) { + return $1.replace(/([a-zA-Z0-9]+?):/g, '"$1":'); + } else { + return $2; + } }); - } - hasFocus = false; - selected = false; - }); - var dismissClickHandler = function(evt) { - if (element[0] !== evt.target && evt.which !== 3 && scope.matches.length !== 0) { - resetMatches(); - if (!$rootScope.$$phase) { - scope.$digest(); + try { + var options = JSON.parse(newValue); + for (var key in options) { + if (options[key]) { + var value = options[key]; + if (typeof value === "string") { + value = value.toUpperCase(); + } else if (key === "mapTypeIds") { + value = value.map(function(str) { + if (str.match(/^[A-Z]+$/)) { + return google.maps.MapTypeId[str.toUpperCase()]; + } else { + return str; + } + }); + } + if (key === "style") { + var str = attr.charAt(0).toUpperCase() + attr.slice(1); + var objName = str.replace(/Options$/, "") + "Style"; + options[key] = google.maps[objName][value]; + } else if (key === "position") { + options[key] = google.maps.ControlPosition[value]; + } else { + options[key] = value; + } + } + } + controlOptions[attr] = options; + } catch (e) { + void 0; } } - }; - $document.bind("click", dismissClickHandler); - originalScope.$on("$destroy", function() { - $document.unbind("click", dismissClickHandler); - if (appendToBody) { - $popup.remove(); - } - popUpEl.remove(); - }); - var $popup = $compile(popUpEl)(scope); - if (appendToBody) { - $document.find("body").append($popup); + } + return controlOptions; + }; + return { + filter: filter, + getOptions: getOptions, + getEvents: getEvents, + getControlOptions: getControlOptions, + toOptionValue: toOptionValue, + getAttrsToObserve: getAttrsToObserve, + orgAttributes: orgAttributes + }; + }; + Attr2MapOptions.$inject = [ "$parse", "$timeout", "$log", "NavigatorGeolocation", "GeoCoder", "camelCaseFilter", "jsonizeFilter" ]; + angular.module("ngMap").service("Attr2MapOptions", Attr2MapOptions); +})(); + +(function() { + "use strict"; + var $q; + var geocodeFunc = function(options) { + var deferred = $q.defer(); + var geocoder = new google.maps.Geocoder(); + geocoder.geocode(options, function(results, status) { + if (status == google.maps.GeocoderStatus.OK) { + deferred.resolve(results); + } else { + deferred.reject(status); + } + }); + return deferred.promise; + }; + var GeoCoder = function(_$q_) { + $q = _$q_; + return { + geocode: geocodeFunc + }; + }; + GeoCoder.$inject = [ "$q" ]; + angular.module("ngMap").service("GeoCoder", GeoCoder); +})(); + +(function() { + "use strict"; + var $q; + var getCurrentPosition = function(geoLocationOptions) { + var deferred = $q.defer(); + if (navigator.geolocation) { + if (geoLocationOptions === undefined) { + geoLocationOptions = { + timeout: 5e3 + }; + } else if (geoLocationOptions.timeout === undefined) { + geoLocationOptions.timeout = 5e3; + } + navigator.geolocation.getCurrentPosition(function(position) { + deferred.resolve(position); + }, function(evt) { + void 0; + deferred.reject(evt); + }, geoLocationOptions); + } else { + deferred.reject("Browser Geolocation service failed."); + } + return deferred.promise; + }; + var NavigatorGeolocation = function(_$q_) { + $q = _$q_; + return { + getCurrentPosition: getCurrentPosition + }; + }; + NavigatorGeolocation.$inject = [ "$q" ]; + angular.module("ngMap").service("NavigatorGeolocation", NavigatorGeolocation); +})(); + +(function() { + "use strict"; + var $window, $document, $q; + var NavigatorGeolocation, Attr2MapOptions, GeoCoder, camelCaseFilter; + var mapControllers = {}; + var initMap = function(id) { + var ctrl = mapControllers[id || 0]; + ctrl.initializeMap(); + }; + var getMap = function(options) { + options = options || {}; + var deferred = $q.defer(); + var id = options.id || 0; + var timeout = options.timeout || 2e3; + function waitForMap(timeElapsed) { + if (mapControllers[id]) { + deferred.resolve(mapControllers[id].map); + } else if (timeElapsed > timeout) { + deferred.reject("could not find map"); } else { - element.after($popup); + $window.setTimeout(function() { + waitForMap(timeElapsed + 100); + }, 100); } } + waitForMap(0); + return deferred.promise; }; -} ]).directive("typeaheadPopup", function() { - return { - restrict: "EA", - scope: { - matches: "=", - query: "=", - active: "=", - position: "&", - moveInProgress: "=", - select: "&" - }, - replace: true, - templateUrl: function(element, attrs) { - return attrs.popupTemplateUrl || "template/typeahead/typeahead-popup.html"; - }, - link: function(scope, element, attrs) { - scope.templateUrl = attrs.templateUrl; - scope.isOpen = function() { - return scope.matches.length > 0; - }; - scope.isActive = function(matchIdx) { - return scope.active == matchIdx; - }; - scope.selectActive = function(matchIdx) { - scope.active = matchIdx; - }; - scope.selectMatch = function(activeIdx) { - scope.select({ - activeIdx: activeIdx - }); - }; + var addMap = function(mapCtrl) { + var len = Object.keys(mapControllers).length; + mapControllers[mapCtrl.map.id || len] = mapCtrl; + }; + var deleteMap = function(mapCtrl) { + var len = Object.keys(mapControllers).length - 1; + delete mapControllers[mapCtrl.map.id || len]; + }; + var getStyle = function(el, styleProp) { + var y; + if (el.currentStyle) { + y = el.currentStyle[styleProp]; + } else if ($window.getComputedStyle) { + y = $document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp); + } + return y; + }; + var getNgMapDiv = function(ngMapEl) { + var el = $document.createElement("div"); + var defaultStyle = ngMapEl.getAttribute("default-style"); + el.style.width = "100%"; + el.style.height = "100%"; + if (defaultStyle == "true") { + ngMapEl.style.display = "block"; + ngMapEl.style.height = "300px"; + } else { + if (getStyle(ngMapEl, "display") != "block") { + ngMapEl.style.display = "block"; + } + if (getStyle(ngMapEl, "height").match(/^(0|auto)/)) { + ngMapEl.style.height = "300px"; + } } + el.addEventListener("dragstart", function(event) { + event.preventDefault(); + return false; + }); + return el; }; -}).directive("typeaheadMatch", [ "$templateRequest", "$compile", "$parse", function($templateRequest, $compile, $parse) { - return { - restrict: "EA", - scope: { - index: "=", - match: "=", - query: "=" - }, - link: function(scope, element, attrs) { - var tplUrl = $parse(attrs.templateUrl)(scope.$parent) || "template/typeahead/typeahead-match.html"; - $templateRequest(tplUrl).then(function(tplContent) { - $compile(tplContent.trim())(scope, function(clonedElement) { - element.replaceWith(clonedElement); - }); + var getGeoLocation = function(string, options) { + var deferred = $q.defer(); + if (!string || string.match(/^current/i)) { + NavigatorGeolocation.getCurrentPosition(options).then(function(position) { + var lat = position.coords.latitude; + var lng = position.coords.longitude; + var latLng = new google.maps.LatLng(lat, lng); + deferred.resolve(latLng); + }, function(error) { + deferred.reject(error); + }); + } else { + GeoCoder.geocode({ + address: string + }).then(function(results) { + deferred.resolve(results[0].geometry.location); + }, function(error) { + deferred.reject(error); }); } + return deferred.promise; }; -} ]).filter("typeaheadHighlight", [ "$sce", "$injector", "$log", function($sce, $injector, $log) { - var isSanitizePresent; - isSanitizePresent = $injector.has("$sanitize"); - function escapeRegexp(queryToEscape) { - return queryToEscape.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1"); - } - function containsHtml(matchItem) { - return /<.*>/g.test(matchItem); - } - return function(matchItem, query) { - if (!isSanitizePresent && containsHtml(matchItem)) { - $log.warn("Unsafe use of typeahead please use ngSanitize"); - } - matchItem = query ? ("" + matchItem).replace(new RegExp(escapeRegexp(query), "gi"), "$&") : matchItem; - if (!isSanitizePresent) { - matchItem = $sce.trustAsHtml(matchItem); - } - return matchItem; + var observeAndSet = function(attrName, object) { + return function(val) { + if (val) { + void 0; + var setMethod = camelCaseFilter("set-" + attrName); + var optionValue = Attr2MapOptions.toOptionValue(val, { + key: attrName + }); + void 0; + if (object[setMethod]) { + if (attrName.match(/center|position/) && typeof optionValue == "string") { + getGeoLocation(optionValue).then(function(latlng) { + object[setMethod](latlng); + }); + } else { + object[setMethod](optionValue); + } + } + } + }; }; -} ]); - -angular.module("template/accordion/accordion-group.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/accordion/accordion-group.html", "
      \n" + '
      \n' + '

      \n' + ' {{heading}}\n' + "

      \n" + "
      \n" + '
      \n' + '
      \n' + "
      \n" + "
      \n" + ""); -} ]); - -angular.module("template/accordion/accordion.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/accordion/accordion.html", '
      '); -} ]); - -angular.module("template/alert/alert.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/alert/alert.html", "
      \n" + ' \n" + "
      \n" + "
      \n" + ""); -} ]); - -angular.module("template/carousel/carousel.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/carousel/carousel.html", '\n" + ""); -} ]); - -angular.module("template/carousel/slide.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/carousel/slide.html", '
      \n' + ""); -} ]); - -angular.module("template/datepicker/datepicker.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/datepicker/datepicker.html", '
      \n' + ' \n' + ' \n' + ' \n' + "
      "); -} ]); - -angular.module("template/datepicker/day.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/datepicker/day.html", '\n' + " \n" + " \n" + ' \n' + ' \n' + ' \n' + " \n" + " \n" + ' \n' + ' \n' + " \n" + " \n" + " \n" + ' \n' + ' \n' + ' \n" + " \n" + " \n" + "
      {{::label.abbr}}
      {{ weekNumbers[$index] }}\n' + ' \n' + "
      \n" + ""); -} ]); - -angular.module("template/datepicker/month.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/datepicker/month.html", '\n' + " \n" + " \n" + ' \n' + ' \n' + ' \n' + " \n" + " \n" + " \n" + ' \n' + ' \n" + " \n" + " \n" + "
      \n' + ' \n' + "
      \n" + ""); -} ]); - -angular.module("template/datepicker/popup.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/datepicker/popup.html", '\n" + ""); -} ]); - -angular.module("template/datepicker/year.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/datepicker/year.html", '\n' + " \n" + " \n" + ' \n' + ' \n' + ' \n' + " \n" + " \n" + " \n" + ' \n' + ' \n" + " \n" + " \n" + "
      \n' + ' \n' + "
      \n" + ""); -} ]); - -angular.module("template/modal/backdrop.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/modal/backdrop.html", '\n" + ""); -} ]); - -angular.module("template/modal/window.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/modal/window.html", '\n" + ""); -} ]); - -angular.module("template/pagination/pager.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/pagination/pager.html", '\n" + ""); -} ]); - -angular.module("template/pagination/pagination.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/pagination/pagination.html", '\n" + ""); -} ]); - -angular.module("template/tooltip/tooltip-html-popup.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/tooltip/tooltip-html-popup.html", '
      \n' + '
      \n' + '
      \n' + "
      \n" + ""); -} ]); - -angular.module("template/tooltip/tooltip-html-unsafe-popup.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/tooltip/tooltip-html-unsafe-popup.html", '
      \n' + '
      \n' + '
      \n' + "
      \n" + ""); -} ]); - -angular.module("template/tooltip/tooltip-popup.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/tooltip/tooltip-popup.html", '
      \n' + '
      \n' + '
      \n' + "
      \n" + ""); -} ]); - -angular.module("template/tooltip/tooltip-template-popup.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/tooltip/tooltip-template-popup.html", '
      \n' + '
      \n' + '
      \n' + "
      \n" + ""); -} ]); - -angular.module("template/popover/popover-html.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/popover/popover-html.html", '
      \n' + '
      \n' + "\n" + '
      \n' + '

      \n' + '
      \n' + "
      \n" + "
      \n" + ""); -} ]); - -angular.module("template/popover/popover-template.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/popover/popover-template.html", '
      \n' + '
      \n' + "\n" + '
      \n' + '

      \n' + '
      \n' + "
      \n" + "
      \n" + ""); -} ]); - -angular.module("template/popover/popover.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/popover/popover.html", '
      \n' + '
      \n' + "\n" + '
      \n' + '

      \n' + '
      \n' + "
      \n" + "
      \n" + ""); -} ]); - -angular.module("template/progressbar/bar.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/progressbar/bar.html", '
      \n' + ""); -} ]); - -angular.module("template/progressbar/progress.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/progressbar/progress.html", '
      '); -} ]); - -angular.module("template/progressbar/progressbar.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/progressbar/progressbar.html", '
      \n' + '
      \n' + "
      \n" + ""); -} ]); - -angular.module("template/rating/rating.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/rating/rating.html", '\n' + " ({{ $index < value ? '*' : ' ' }})\n" + ' \n' + "\n" + ""); -} ]); - -angular.module("template/tabs/tab.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/tabs/tab.html", '
    • \n' + ' {{heading}}\n' + "
    • \n" + ""); -} ]); - -angular.module("template/tabs/tabset.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/tabs/tabset.html", "
      \n" + "
        \n" + '
        \n' + '
        \n' + "
        \n" + "
        \n" + "
        \n" + ""); -} ]); - -angular.module("template/timepicker/timepicker.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/timepicker/timepicker.html", "\n" + " \n" + ' \n' + ' \n' + " \n" + ' \n' + ' \n' + " \n" + " \n" + ' \n" + " \n" + ' \n" + ' \n' + " \n" + ' \n' + ' \n' + " \n" + ' \n' + ' \n' + " \n" + " \n" + "
         
        \n' + ' \n' + " :\n' + ' \n' + "
         
        \n" + ""); -} ]); - -angular.module("template/typeahead/typeahead-match.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/typeahead/typeahead-match.html", '\n' + ""); -} ]); - -angular.module("template/typeahead/typeahead-popup.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/typeahead/typeahead-popup.html", '\n" + ""); -} ]); + angular.module("ngMap").provider("NgMap", function() { + var defaultOptions = {}; + var useTinfoilShielding = false; + this.setDefaultOptions = function(options) { + defaultOptions = options; + }; + var NgMap = function(_$window_, _$document_, _$q_, _NavigatorGeolocation_, _Attr2MapOptions_, _GeoCoder_, _camelCaseFilter_) { + $window = _$window_; + $document = _$document_[0]; + $q = _$q_; + NavigatorGeolocation = _NavigatorGeolocation_; + Attr2MapOptions = _Attr2MapOptions_; + GeoCoder = _GeoCoder_; + camelCaseFilter = _camelCaseFilter_; + return { + defaultOptions: defaultOptions, + addMap: addMap, + deleteMap: deleteMap, + getMap: getMap, + initMap: initMap, + getStyle: getStyle, + getNgMapDiv: getNgMapDiv, + getGeoLocation: getGeoLocation, + observeAndSet: observeAndSet + }; + }; + NgMap.$inject = [ "$window", "$document", "$q", "NavigatorGeolocation", "Attr2MapOptions", "GeoCoder", "camelCaseFilter" ]; + this.$get = NgMap; + }); +})(); -!angular.$$csp() && angular.element(document).find("head").prepend(''); +(function() { + "use strict"; + var $q; + var getPanorama = function(map, latlng) { + latlng = latlng || map.getCenter(); + var deferred = $q.defer(); + var svs = new google.maps.StreetViewService(); + svs.getPanoramaByLocation(latlng || map.getCenter, 100, function(data, status) { + if (status === google.maps.StreetViewStatus.OK) { + deferred.resolve(data.location.pano); + } else { + deferred.resolve(false); + } + }); + return deferred.promise; + }; + var setPanorama = function(map, panoId) { + var svp = new google.maps.StreetViewPanorama(map.getDiv(), { + enableCloseButton: true + }); + svp.setPano(panoId); + }; + var StreetView = function(_$q_) { + $q = _$q_; + return { + getPanorama: getPanorama, + setPanorama: setPanorama + }; + }; + StreetView.$inject = [ "$q" ]; + angular.module("ngMap").service("StreetView", StreetView); +})(); function getCookie(name) { var nameEQ = name + "="; @@ -28422,7 +33033,7 @@ function responseHandler($timeout, $modal) { "use strict"; -var app = angular.module("DashboardModule", [ "ui.bootstrap" ]); +var app = angular.module("DashboardModule", [ "ui.bootstrap", "ngMap" ]); app.service("dictionaryService", lingvodocAPI); @@ -28732,7 +33343,7 @@ app.controller("editDictionaryPropertiesController", [ "$scope", "$http", "$q", }; } ]); -app.controller("editPerspectivePropertiesController", [ "$scope", "$http", "$q", "$modalInstance", "$log", "dictionaryService", "responseHandler", "params", function($scope, $http, $q, $modalInstance, $log, dictionaryService, responseHandler, params) { +app.controller("editPerspectivePropertiesController", [ "$scope", "$http", "$q", "$modal", "$modalInstance", "$log", "dictionaryService", "responseHandler", "params", function($scope, $http, $q, $modal, $modalInstance, $log, dictionaryService, responseHandler, params) { $scope.dictionary = params.dictionary; $scope.perspective = {}; $scope.controls = { @@ -28752,6 +33363,24 @@ app.controller("editPerspectivePropertiesController", [ "$scope", "$http", "$q", } } }; + $scope.editGeoLabels = function() { + $modal.open({ + animation: true, + templateUrl: "perspectiveGeoLabelsModal.html", + controller: "perspectiveGeoLabelsController", + size: "lg", + backdrop: "static", + keyboard: false, + resolve: { + params: function() { + return { + dictionary: params.dictionary, + perspective: params.perspective + }; + } + } + }); + }; $scope.ok = function() { $scope.controls.ok = false; dictionaryService.setPerspectiveProperties($scope.dictionary, $scope.perspective).then(function(data) { @@ -29043,4 +33672,35 @@ app.controller("editPerspectiveRolesController", [ "$scope", "$http", "$q", "$mo }, function(reason) { responseHandler.error(reason); }); +} ]); + +app.controller("perspectiveGeoLabelsController", [ "$scope", "$http", "$q", "$modalInstance", "$log", "NgMap", "dictionaryService", "responseHandler", "params", function($scope, $http, $q, $modalInstance, $log, NgMap, dictionaryService, responseHandler, params) { + var key = "AIzaSyB6l1ciVMcP1pIUkqvSx8vmuRJL14lbPXk"; + $scope.googleMapsUrl = "http://maps.google.com/maps/api/js?v=3.20&key=" + encodeURIComponent(key); + $scope.positions = []; + $modalInstance.opened.then(function() { + NgMap.getMap().then(function(map) { + google.maps.event.trigger(map, "resize"); + }); + }); + $scope.addMarker = function(event) { + if ($scope.positions.length > 0) { + return; + } + var latLng = event.latLng; + $scope.positions.push({ + lat: latLng.lat(), + lng: latLng.lng() + }); + }; + $scope.removeMarker = function(marker) { + _.remove($scope.positions, function(e) { + var p = new google.maps.LatLng(e.lat, e.lng); + return p.equals(marker.latLng); + }); + }; + $scope.ok = function() {}; + $scope.cancel = function() { + $modalInstance.dismiss(); + }; } ]); \ No newline at end of file diff --git a/lingvodoc/static/js/edit-dictionary.js b/lingvodoc/static/js/edit-dictionary.js index 9ff77c7aa..2a77d0334 100644 --- a/lingvodoc/static/js/edit-dictionary.js +++ b/lingvodoc/static/js/edit-dictionary.js @@ -5378,1056 +5378,3943 @@ }); (function() { - var root = this; - var previousUnderscore = root._; - var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; - var push = ArrayProto.push, slice = ArrayProto.slice, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty; - var nativeIsArray = Array.isArray, nativeKeys = Object.keys, nativeBind = FuncProto.bind, nativeCreate = Object.create; - var Ctor = function() {}; - var _ = function(obj) { - if (obj instanceof _) return obj; - if (!(this instanceof _)) return new _(obj); - this._wrapped = obj; - }; - if (typeof exports !== "undefined") { - if (typeof module !== "undefined" && module.exports) { - exports = module.exports = _; - } - exports._ = _; - } else { - root._ = _; + var undefined; + var VERSION = "3.10.1"; + var BIND_FLAG = 1, BIND_KEY_FLAG = 2, CURRY_BOUND_FLAG = 4, CURRY_FLAG = 8, CURRY_RIGHT_FLAG = 16, PARTIAL_FLAG = 32, PARTIAL_RIGHT_FLAG = 64, ARY_FLAG = 128, REARG_FLAG = 256; + var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = "..."; + var HOT_COUNT = 150, HOT_SPAN = 16; + var LARGE_ARRAY_SIZE = 200; + var LAZY_FILTER_FLAG = 1, LAZY_MAP_FLAG = 2; + var FUNC_ERROR_TEXT = "Expected a function"; + var PLACEHOLDER = "__lodash_placeholder__"; + var argsTag = "[object Arguments]", arrayTag = "[object Array]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", mapTag = "[object Map]", numberTag = "[object Number]", objectTag = "[object Object]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", weakMapTag = "[object WeakMap]"; + var arrayBufferTag = "[object ArrayBuffer]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]"; + var reEmptyStringLeading = /\b__p \+= '';/g, reEmptyStringMiddle = /\b(__p \+=) '' \+/g, reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; + var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g, reUnescapedHtml = /[&<>"'`]/g, reHasEscapedHtml = RegExp(reEscapedHtml.source), reHasUnescapedHtml = RegExp(reUnescapedHtml.source); + var reEscape = /<%-([\s\S]+?)%>/g, reEvaluate = /<%([\s\S]+?)%>/g, reInterpolate = /<%=([\s\S]+?)%>/g; + var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g; + var reRegExpChars = /^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g, reHasRegExpChars = RegExp(reRegExpChars.source); + var reComboMark = /[\u0300-\u036f\ufe20-\ufe23]/g; + var reEscapeChar = /\\(\\)?/g; + var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; + var reFlags = /\w*$/; + var reHasHexPrefix = /^0[xX]/; + var reIsHostCtor = /^\[object .+?Constructor\]$/; + var reIsUint = /^\d+$/; + var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; + var reNoMatch = /($^)/; + var reUnescapedString = /['\n\r\u2028\u2029\\]/g; + var reWords = function() { + var upper = "[A-Z\\xc0-\\xd6\\xd8-\\xde]", lower = "[a-z\\xdf-\\xf6\\xf8-\\xff]+"; + return RegExp(upper + "+(?=" + upper + lower + ")|" + upper + "?" + lower + "|" + upper + "+|[0-9]+", "g"); + }(); + var contextProps = [ "Array", "ArrayBuffer", "Date", "Error", "Float32Array", "Float64Array", "Function", "Int8Array", "Int16Array", "Int32Array", "Math", "Number", "Object", "RegExp", "Set", "String", "_", "clearTimeout", "isFinite", "parseFloat", "parseInt", "setTimeout", "TypeError", "Uint8Array", "Uint8ClampedArray", "Uint16Array", "Uint32Array", "WeakMap" ]; + var templateCounter = -1; + var typedArrayTags = {}; + typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; + typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; + var cloneableTags = {}; + cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[stringTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; + cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[mapTag] = cloneableTags[setTag] = cloneableTags[weakMapTag] = false; + var deburredLetters = { + "À": "A", + "Á": "A", + "Â": "A", + "Ã": "A", + "Ä": "A", + "Å": "A", + "à": "a", + "á": "a", + "â": "a", + "ã": "a", + "ä": "a", + "å": "a", + "Ç": "C", + "ç": "c", + "Ð": "D", + "ð": "d", + "È": "E", + "É": "E", + "Ê": "E", + "Ë": "E", + "è": "e", + "é": "e", + "ê": "e", + "ë": "e", + "Ì": "I", + "Í": "I", + "Î": "I", + "Ï": "I", + "ì": "i", + "í": "i", + "î": "i", + "ï": "i", + "Ñ": "N", + "ñ": "n", + "Ò": "O", + "Ó": "O", + "Ô": "O", + "Õ": "O", + "Ö": "O", + "Ø": "O", + "ò": "o", + "ó": "o", + "ô": "o", + "õ": "o", + "ö": "o", + "ø": "o", + "Ù": "U", + "Ú": "U", + "Û": "U", + "Ü": "U", + "ù": "u", + "ú": "u", + "û": "u", + "ü": "u", + "Ý": "Y", + "ý": "y", + "ÿ": "y", + "Æ": "Ae", + "æ": "ae", + "Þ": "Th", + "þ": "th", + "ß": "ss" + }; + var htmlEscapes = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + "`": "`" + }; + var htmlUnescapes = { + "&": "&", + "<": "<", + ">": ">", + """: '"', + "'": "'", + "`": "`" + }; + var objectTypes = { + "function": true, + object: true + }; + var regexpEscapes = { + "0": "x30", + "1": "x31", + "2": "x32", + "3": "x33", + "4": "x34", + "5": "x35", + "6": "x36", + "7": "x37", + "8": "x38", + "9": "x39", + A: "x41", + B: "x42", + C: "x43", + D: "x44", + E: "x45", + F: "x46", + a: "x61", + b: "x62", + c: "x63", + d: "x64", + e: "x65", + f: "x66", + n: "x6e", + r: "x72", + t: "x74", + u: "x75", + v: "x76", + x: "x78" + }; + var stringEscapes = { + "\\": "\\", + "'": "'", + "\n": "n", + "\r": "r", + "\u2028": "u2028", + "\u2029": "u2029" + }; + var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; + var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; + var freeGlobal = freeExports && freeModule && typeof global == "object" && global && global.Object && global; + var freeSelf = objectTypes[typeof self] && self && self.Object && self; + var freeWindow = objectTypes[typeof window] && window && window.Object && window; + var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; + var root = freeGlobal || freeWindow !== (this && this.window) && freeWindow || freeSelf || this; + function baseCompareAscending(value, other) { + if (value !== other) { + var valIsNull = value === null, valIsUndef = value === undefined, valIsReflexive = value === value; + var othIsNull = other === null, othIsUndef = other === undefined, othIsReflexive = other === other; + if (value > other && !othIsNull || !valIsReflexive || valIsNull && !othIsUndef && othIsReflexive || valIsUndef && othIsReflexive) { + return 1; + } + if (value < other && !valIsNull || !othIsReflexive || othIsNull && !valIsUndef && valIsReflexive || othIsUndef && valIsReflexive) { + return -1; + } + } + return 0; } - _.VERSION = "1.8.3"; - var optimizeCb = function(func, context, argCount) { - if (context === void 0) return func; - switch (argCount == null ? 3 : argCount) { - case 1: - return function(value) { - return func.call(context, value); + function baseFindIndex(array, predicate, fromRight) { + var length = array.length, index = fromRight ? length : -1; + while (fromRight ? index-- : ++index < length) { + if (predicate(array[index], index, array)) { + return index; + } + } + return -1; + } + function baseIndexOf(array, value, fromIndex) { + if (value !== value) { + return indexOfNaN(array, fromIndex); + } + var index = fromIndex - 1, length = array.length; + while (++index < length) { + if (array[index] === value) { + return index; + } + } + return -1; + } + function baseIsFunction(value) { + return typeof value == "function" || false; + } + function baseToString(value) { + return value == null ? "" : value + ""; + } + function charsLeftIndex(string, chars) { + var index = -1, length = string.length; + while (++index < length && chars.indexOf(string.charAt(index)) > -1) {} + return index; + } + function charsRightIndex(string, chars) { + var index = string.length; + while (index-- && chars.indexOf(string.charAt(index)) > -1) {} + return index; + } + function compareAscending(object, other) { + return baseCompareAscending(object.criteria, other.criteria) || object.index - other.index; + } + function compareMultiple(object, other, orders) { + var index = -1, objCriteria = object.criteria, othCriteria = other.criteria, length = objCriteria.length, ordersLength = orders.length; + while (++index < length) { + var result = baseCompareAscending(objCriteria[index], othCriteria[index]); + if (result) { + if (index >= ordersLength) { + return result; + } + var order = orders[index]; + return result * (order === "asc" || order === true ? 1 : -1); + } + } + return object.index - other.index; + } + function deburrLetter(letter) { + return deburredLetters[letter]; + } + function escapeHtmlChar(chr) { + return htmlEscapes[chr]; + } + function escapeRegExpChar(chr, leadingChar, whitespaceChar) { + if (leadingChar) { + chr = regexpEscapes[chr]; + } else if (whitespaceChar) { + chr = stringEscapes[chr]; + } + return "\\" + chr; + } + function escapeStringChar(chr) { + return "\\" + stringEscapes[chr]; + } + function indexOfNaN(array, fromIndex, fromRight) { + var length = array.length, index = fromIndex + (fromRight ? 0 : -1); + while (fromRight ? index-- : ++index < length) { + var other = array[index]; + if (other !== other) { + return index; + } + } + return -1; + } + function isObjectLike(value) { + return !!value && typeof value == "object"; + } + function isSpace(charCode) { + return charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160 || charCode == 5760 || charCode == 6158 || charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279); + } + function replaceHolders(array, placeholder) { + var index = -1, length = array.length, resIndex = -1, result = []; + while (++index < length) { + if (array[index] === placeholder) { + array[index] = PLACEHOLDER; + result[++resIndex] = index; + } + } + return result; + } + function sortedUniq(array, iteratee) { + var seen, index = -1, length = array.length, resIndex = -1, result = []; + while (++index < length) { + var value = array[index], computed = iteratee ? iteratee(value, index, array) : value; + if (!index || seen !== computed) { + seen = computed; + result[++resIndex] = value; + } + } + return result; + } + function trimmedLeftIndex(string) { + var index = -1, length = string.length; + while (++index < length && isSpace(string.charCodeAt(index))) {} + return index; + } + function trimmedRightIndex(string) { + var index = string.length; + while (index-- && isSpace(string.charCodeAt(index))) {} + return index; + } + function unescapeHtmlChar(chr) { + return htmlUnescapes[chr]; + } + function runInContext(context) { + context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root; + var Array = context.Array, Date = context.Date, Error = context.Error, Function = context.Function, Math = context.Math, Number = context.Number, Object = context.Object, RegExp = context.RegExp, String = context.String, TypeError = context.TypeError; + var arrayProto = Array.prototype, objectProto = Object.prototype, stringProto = String.prototype; + var fnToString = Function.prototype.toString; + var hasOwnProperty = objectProto.hasOwnProperty; + var idCounter = 0; + var objToString = objectProto.toString; + var oldDash = root._; + var reIsNative = RegExp("^" + fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"); + var ArrayBuffer = context.ArrayBuffer, clearTimeout = context.clearTimeout, parseFloat = context.parseFloat, pow = Math.pow, propertyIsEnumerable = objectProto.propertyIsEnumerable, Set = getNative(context, "Set"), setTimeout = context.setTimeout, splice = arrayProto.splice, Uint8Array = context.Uint8Array, WeakMap = getNative(context, "WeakMap"); + var nativeCeil = Math.ceil, nativeCreate = getNative(Object, "create"), nativeFloor = Math.floor, nativeIsArray = getNative(Array, "isArray"), nativeIsFinite = context.isFinite, nativeKeys = getNative(Object, "keys"), nativeMax = Math.max, nativeMin = Math.min, nativeNow = getNative(Date, "now"), nativeParseInt = context.parseInt, nativeRandom = Math.random; + var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY, POSITIVE_INFINITY = Number.POSITIVE_INFINITY; + var MAX_ARRAY_LENGTH = 4294967295, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; + var MAX_SAFE_INTEGER = 9007199254740991; + var metaMap = WeakMap && new WeakMap(); + var realNames = {}; + function lodash(value) { + if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { + if (value instanceof LodashWrapper) { + return value; + } + if (hasOwnProperty.call(value, "__chain__") && hasOwnProperty.call(value, "__wrapped__")) { + return wrapperClone(value); + } + } + return new LodashWrapper(value); + } + function baseLodash() {} + function LodashWrapper(value, chainAll, actions) { + this.__wrapped__ = value; + this.__actions__ = actions || []; + this.__chain__ = !!chainAll; + } + var support = lodash.support = {}; + lodash.templateSettings = { + escape: reEscape, + evaluate: reEvaluate, + interpolate: reInterpolate, + variable: "", + imports: { + _: lodash + } + }; + function LazyWrapper(value) { + this.__wrapped__ = value; + this.__actions__ = []; + this.__dir__ = 1; + this.__filtered__ = false; + this.__iteratees__ = []; + this.__takeCount__ = POSITIVE_INFINITY; + this.__views__ = []; + } + function lazyClone() { + var result = new LazyWrapper(this.__wrapped__); + result.__actions__ = arrayCopy(this.__actions__); + result.__dir__ = this.__dir__; + result.__filtered__ = this.__filtered__; + result.__iteratees__ = arrayCopy(this.__iteratees__); + result.__takeCount__ = this.__takeCount__; + result.__views__ = arrayCopy(this.__views__); + return result; + } + function lazyReverse() { + if (this.__filtered__) { + var result = new LazyWrapper(this); + result.__dir__ = -1; + result.__filtered__ = true; + } else { + result = this.clone(); + result.__dir__ *= -1; + } + return result; + } + function lazyValue() { + var array = this.__wrapped__.value(), dir = this.__dir__, isArr = isArray(array), isRight = dir < 0, arrLength = isArr ? array.length : 0, view = getView(0, arrLength, this.__views__), start = view.start, end = view.end, length = end - start, index = isRight ? end : start - 1, iteratees = this.__iteratees__, iterLength = iteratees.length, resIndex = 0, takeCount = nativeMin(length, this.__takeCount__); + if (!isArr || arrLength < LARGE_ARRAY_SIZE || arrLength == length && takeCount == length) { + return baseWrapperValue(array, this.__actions__); + } + var result = []; + outer: while (length-- && resIndex < takeCount) { + index += dir; + var iterIndex = -1, value = array[index]; + while (++iterIndex < iterLength) { + var data = iteratees[iterIndex], iteratee = data.iteratee, type = data.type, computed = iteratee(value); + if (type == LAZY_MAP_FLAG) { + value = computed; + } else if (!computed) { + if (type == LAZY_FILTER_FLAG) { + continue outer; + } else { + break outer; + } + } + } + result[resIndex++] = value; + } + return result; + } + function MapCache() { + this.__data__ = {}; + } + function mapDelete(key) { + return this.has(key) && delete this.__data__[key]; + } + function mapGet(key) { + return key == "__proto__" ? undefined : this.__data__[key]; + } + function mapHas(key) { + return key != "__proto__" && hasOwnProperty.call(this.__data__, key); + } + function mapSet(key, value) { + if (key != "__proto__") { + this.__data__[key] = value; + } + return this; + } + function SetCache(values) { + var length = values ? values.length : 0; + this.data = { + hash: nativeCreate(null), + set: new Set() + }; + while (length--) { + this.push(values[length]); + } + } + function cacheIndexOf(cache, value) { + var data = cache.data, result = typeof value == "string" || isObject(value) ? data.set.has(value) : data.hash[value]; + return result ? 0 : -1; + } + function cachePush(value) { + var data = this.data; + if (typeof value == "string" || isObject(value)) { + data.set.add(value); + } else { + data.hash[value] = true; + } + } + function arrayConcat(array, other) { + var index = -1, length = array.length, othIndex = -1, othLength = other.length, result = Array(length + othLength); + while (++index < length) { + result[index] = array[index]; + } + while (++othIndex < othLength) { + result[index++] = other[othIndex]; + } + return result; + } + function arrayCopy(source, array) { + var index = -1, length = source.length; + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; + } + function arrayEach(array, iteratee) { + var index = -1, length = array.length; + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } + } + return array; + } + function arrayEachRight(array, iteratee) { + var length = array.length; + while (length--) { + if (iteratee(array[length], length, array) === false) { + break; + } + } + return array; + } + function arrayEvery(array, predicate) { + var index = -1, length = array.length; + while (++index < length) { + if (!predicate(array[index], index, array)) { + return false; + } + } + return true; + } + function arrayExtremum(array, iteratee, comparator, exValue) { + var index = -1, length = array.length, computed = exValue, result = computed; + while (++index < length) { + var value = array[index], current = +iteratee(value); + if (comparator(current, computed)) { + computed = current; + result = value; + } + } + return result; + } + function arrayFilter(array, predicate) { + var index = -1, length = array.length, resIndex = -1, result = []; + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[++resIndex] = value; + } + } + return result; + } + function arrayMap(array, iteratee) { + var index = -1, length = array.length, result = Array(length); + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; + } + function arrayPush(array, values) { + var index = -1, length = values.length, offset = array.length; + while (++index < length) { + array[offset + index] = values[index]; + } + return array; + } + function arrayReduce(array, iteratee, accumulator, initFromArray) { + var index = -1, length = array.length; + if (initFromArray && length) { + accumulator = array[++index]; + } + while (++index < length) { + accumulator = iteratee(accumulator, array[index], index, array); + } + return accumulator; + } + function arrayReduceRight(array, iteratee, accumulator, initFromArray) { + var length = array.length; + if (initFromArray && length) { + accumulator = array[--length]; + } + while (length--) { + accumulator = iteratee(accumulator, array[length], length, array); + } + return accumulator; + } + function arraySome(array, predicate) { + var index = -1, length = array.length; + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; + } + function arraySum(array, iteratee) { + var length = array.length, result = 0; + while (length--) { + result += +iteratee(array[length]) || 0; + } + return result; + } + function assignDefaults(objectValue, sourceValue) { + return objectValue === undefined ? sourceValue : objectValue; + } + function assignOwnDefaults(objectValue, sourceValue, key, object) { + return objectValue === undefined || !hasOwnProperty.call(object, key) ? sourceValue : objectValue; + } + function assignWith(object, source, customizer) { + var index = -1, props = keys(source), length = props.length; + while (++index < length) { + var key = props[index], value = object[key], result = customizer(value, source[key], key, object, source); + if ((result === result ? result !== value : value === value) || value === undefined && !(key in object)) { + object[key] = result; + } + } + return object; + } + function baseAssign(object, source) { + return source == null ? object : baseCopy(source, keys(source), object); + } + function baseAt(collection, props) { + var index = -1, isNil = collection == null, isArr = !isNil && isArrayLike(collection), length = isArr ? collection.length : 0, propsLength = props.length, result = Array(propsLength); + while (++index < propsLength) { + var key = props[index]; + if (isArr) { + result[index] = isIndex(key, length) ? collection[key] : undefined; + } else { + result[index] = isNil ? undefined : collection[key]; + } + } + return result; + } + function baseCopy(source, props, object) { + object || (object = {}); + var index = -1, length = props.length; + while (++index < length) { + var key = props[index]; + object[key] = source[key]; + } + return object; + } + function baseCallback(func, thisArg, argCount) { + var type = typeof func; + if (type == "function") { + return thisArg === undefined ? func : bindCallback(func, thisArg, argCount); + } + if (func == null) { + return identity; + } + if (type == "object") { + return baseMatches(func); + } + return thisArg === undefined ? property(func) : baseMatchesProperty(func, thisArg); + } + function baseClone(value, isDeep, customizer, key, object, stackA, stackB) { + var result; + if (customizer) { + result = object ? customizer(value, key, object) : customizer(value); + } + if (result !== undefined) { + return result; + } + if (!isObject(value)) { + return value; + } + var isArr = isArray(value); + if (isArr) { + result = initCloneArray(value); + if (!isDeep) { + return arrayCopy(value, result); + } + } else { + var tag = objToString.call(value), isFunc = tag == funcTag; + if (tag == objectTag || tag == argsTag || isFunc && !object) { + result = initCloneObject(isFunc ? {} : value); + if (!isDeep) { + return baseAssign(result, value); + } + } else { + return cloneableTags[tag] ? initCloneByTag(value, tag, isDeep) : object ? value : {}; + } + } + stackA || (stackA = []); + stackB || (stackB = []); + var length = stackA.length; + while (length--) { + if (stackA[length] == value) { + return stackB[length]; + } + } + stackA.push(value); + stackB.push(result); + (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { + result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB); + }); + return result; + } + var baseCreate = function() { + function object() {} + return function(prototype) { + if (isObject(prototype)) { + object.prototype = prototype; + var result = new object(); + object.prototype = undefined; + } + return result || {}; }; + }(); + function baseDelay(func, wait, args) { + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + return setTimeout(function() { + func.apply(undefined, args); + }, wait); + } + function baseDifference(array, values) { + var length = array ? array.length : 0, result = []; + if (!length) { + return result; + } + var index = -1, indexOf = getIndexOf(), isCommon = indexOf === baseIndexOf, cache = isCommon && values.length >= LARGE_ARRAY_SIZE ? createCache(values) : null, valuesLength = values.length; + if (cache) { + indexOf = cacheIndexOf; + isCommon = false; + values = cache; + } + outer: while (++index < length) { + var value = array[index]; + if (isCommon && value === value) { + var valuesIndex = valuesLength; + while (valuesIndex--) { + if (values[valuesIndex] === value) { + continue outer; + } + } + result.push(value); + } else if (indexOf(values, value, 0) < 0) { + result.push(value); + } + } + return result; + } + var baseEach = createBaseEach(baseForOwn); + var baseEachRight = createBaseEach(baseForOwnRight, true); + function baseEvery(collection, predicate) { + var result = true; + baseEach(collection, function(value, index, collection) { + result = !!predicate(value, index, collection); + return result; + }); + return result; + } + function baseExtremum(collection, iteratee, comparator, exValue) { + var computed = exValue, result = computed; + baseEach(collection, function(value, index, collection) { + var current = +iteratee(value, index, collection); + if (comparator(current, computed) || current === exValue && current === result) { + computed = current; + result = value; + } + }); + return result; + } + function baseFill(array, value, start, end) { + var length = array.length; + start = start == null ? 0 : +start || 0; + if (start < 0) { + start = -start > length ? 0 : length + start; + } + end = end === undefined || end > length ? length : +end || 0; + if (end < 0) { + end += length; + } + length = start > end ? 0 : end >>> 0; + start >>>= 0; + while (start < length) { + array[start++] = value; + } + return array; + } + function baseFilter(collection, predicate) { + var result = []; + baseEach(collection, function(value, index, collection) { + if (predicate(value, index, collection)) { + result.push(value); + } + }); + return result; + } + function baseFind(collection, predicate, eachFunc, retKey) { + var result; + eachFunc(collection, function(value, key, collection) { + if (predicate(value, key, collection)) { + result = retKey ? key : value; + return false; + } + }); + return result; + } + function baseFlatten(array, isDeep, isStrict, result) { + result || (result = []); + var index = -1, length = array.length; + while (++index < length) { + var value = array[index]; + if (isObjectLike(value) && isArrayLike(value) && (isStrict || isArray(value) || isArguments(value))) { + if (isDeep) { + baseFlatten(value, isDeep, isStrict, result); + } else { + arrayPush(result, value); + } + } else if (!isStrict) { + result[result.length] = value; + } + } + return result; + } + var baseFor = createBaseFor(); + var baseForRight = createBaseFor(true); + function baseForIn(object, iteratee) { + return baseFor(object, iteratee, keysIn); + } + function baseForOwn(object, iteratee) { + return baseFor(object, iteratee, keys); + } + function baseForOwnRight(object, iteratee) { + return baseForRight(object, iteratee, keys); + } + function baseFunctions(object, props) { + var index = -1, length = props.length, resIndex = -1, result = []; + while (++index < length) { + var key = props[index]; + if (isFunction(object[key])) { + result[++resIndex] = key; + } + } + return result; + } + function baseGet(object, path, pathKey) { + if (object == null) { + return; + } + if (pathKey !== undefined && pathKey in toObject(object)) { + path = [ pathKey ]; + } + var index = 0, length = path.length; + while (object != null && index < length) { + object = object[path[index++]]; + } + return index && index == length ? object : undefined; + } + function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) { + if (value === other) { + return true; + } + if (value == null || other == null || !isObject(value) && !isObjectLike(other)) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB); + } + function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) { + var objIsArr = isArray(object), othIsArr = isArray(other), objTag = arrayTag, othTag = arrayTag; + if (!objIsArr) { + objTag = objToString.call(object); + if (objTag == argsTag) { + objTag = objectTag; + } else if (objTag != objectTag) { + objIsArr = isTypedArray(object); + } + } + if (!othIsArr) { + othTag = objToString.call(other); + if (othTag == argsTag) { + othTag = objectTag; + } else if (othTag != objectTag) { + othIsArr = isTypedArray(other); + } + } + var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag; + if (isSameTag && !(objIsArr || objIsObj)) { + return equalByTag(object, other, objTag); + } + if (!isLoose) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__"); + if (objIsWrapped || othIsWrapped) { + return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB); + } + } + if (!isSameTag) { + return false; + } + stackA || (stackA = []); + stackB || (stackB = []); + var length = stackA.length; + while (length--) { + if (stackA[length] == object) { + return stackB[length] == other; + } + } + stackA.push(object); + stackB.push(other); + var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB); + stackA.pop(); + stackB.pop(); + return result; + } + function baseIsMatch(object, matchData, customizer) { + var index = matchData.length, length = index, noCustomizer = !customizer; + if (object == null) { + return !length; + } + object = toObject(object); + while (index--) { + var data = matchData[index]; + if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) { + return false; + } + } + while (++index < length) { + data = matchData[index]; + var key = data[0], objValue = object[key], srcValue = data[1]; + if (noCustomizer && data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } + } else { + var result = customizer ? customizer(objValue, srcValue, key) : undefined; + if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) { + return false; + } + } + } + return true; + } + function baseMap(collection, iteratee) { + var index = -1, result = isArrayLike(collection) ? Array(collection.length) : []; + baseEach(collection, function(value, key, collection) { + result[++index] = iteratee(value, key, collection); + }); + return result; + } + function baseMatches(source) { + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + var key = matchData[0][0], value = matchData[0][1]; + return function(object) { + if (object == null) { + return false; + } + return object[key] === value && (value !== undefined || key in toObject(object)); + }; + } + return function(object) { + return baseIsMatch(object, matchData); + }; + } + function baseMatchesProperty(path, srcValue) { + var isArr = isArray(path), isCommon = isKey(path) && isStrictComparable(srcValue), pathKey = path + ""; + path = toPath(path); + return function(object) { + if (object == null) { + return false; + } + var key = pathKey; + object = toObject(object); + if ((isArr || !isCommon) && !(key in object)) { + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + if (object == null) { + return false; + } + key = last(path); + object = toObject(object); + } + return object[key] === srcValue ? srcValue !== undefined || key in object : baseIsEqual(srcValue, object[key], undefined, true); + }; + } + function baseMerge(object, source, customizer, stackA, stackB) { + if (!isObject(object)) { + return object; + } + var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)), props = isSrcArr ? undefined : keys(source); + arrayEach(props || source, function(srcValue, key) { + if (props) { + key = srcValue; + srcValue = source[key]; + } + if (isObjectLike(srcValue)) { + stackA || (stackA = []); + stackB || (stackB = []); + baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB); + } else { + var value = object[key], result = customizer ? customizer(value, srcValue, key, object, source) : undefined, isCommon = result === undefined; + if (isCommon) { + result = srcValue; + } + if ((result !== undefined || isSrcArr && !(key in object)) && (isCommon || (result === result ? result !== value : value === value))) { + object[key] = result; + } + } + }); + return object; + } + function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) { + var length = stackA.length, srcValue = source[key]; + while (length--) { + if (stackA[length] == srcValue) { + object[key] = stackB[length]; + return; + } + } + var value = object[key], result = customizer ? customizer(value, srcValue, key, object, source) : undefined, isCommon = result === undefined; + if (isCommon) { + result = srcValue; + if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) { + result = isArray(value) ? value : isArrayLike(value) ? arrayCopy(value) : []; + } else if (isPlainObject(srcValue) || isArguments(srcValue)) { + result = isArguments(value) ? toPlainObject(value) : isPlainObject(value) ? value : {}; + } else { + isCommon = false; + } + } + stackA.push(srcValue); + stackB.push(result); + if (isCommon) { + object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB); + } else if (result === result ? result !== value : value === value) { + object[key] = result; + } + } + function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; + } + function basePropertyDeep(path) { + var pathKey = path + ""; + path = toPath(path); + return function(object) { + return baseGet(object, path, pathKey); + }; + } + function basePullAt(array, indexes) { + var length = array ? indexes.length : 0; + while (length--) { + var index = indexes[length]; + if (index != previous && isIndex(index)) { + var previous = index; + splice.call(array, index, 1); + } + } + return array; + } + function baseRandom(min, max) { + return min + nativeFloor(nativeRandom() * (max - min + 1)); + } + function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) { + eachFunc(collection, function(value, index, collection) { + accumulator = initFromCollection ? (initFromCollection = false, value) : iteratee(accumulator, value, index, collection); + }); + return accumulator; + } + var baseSetData = !metaMap ? identity : function(func, data) { + metaMap.set(func, data); + return func; + }; + function baseSlice(array, start, end) { + var index = -1, length = array.length; + start = start == null ? 0 : +start || 0; + if (start < 0) { + start = -start > length ? 0 : length + start; + } + end = end === undefined || end > length ? length : +end || 0; + if (end < 0) { + end += length; + } + length = start > end ? 0 : end - start >>> 0; + start >>>= 0; + var result = Array(length); + while (++index < length) { + result[index] = array[index + start]; + } + return result; + } + function baseSome(collection, predicate) { + var result; + baseEach(collection, function(value, index, collection) { + result = predicate(value, index, collection); + return !result; + }); + return !!result; + } + function baseSortBy(array, comparer) { + var length = array.length; + array.sort(comparer); + while (length--) { + array[length] = array[length].value; + } + return array; + } + function baseSortByOrder(collection, iteratees, orders) { + var callback = getCallback(), index = -1; + iteratees = arrayMap(iteratees, function(iteratee) { + return callback(iteratee); + }); + var result = baseMap(collection, function(value) { + var criteria = arrayMap(iteratees, function(iteratee) { + return iteratee(value); + }); + return { + criteria: criteria, + index: ++index, + value: value + }; + }); + return baseSortBy(result, function(object, other) { + return compareMultiple(object, other, orders); + }); + } + function baseSum(collection, iteratee) { + var result = 0; + baseEach(collection, function(value, index, collection) { + result += +iteratee(value, index, collection) || 0; + }); + return result; + } + function baseUniq(array, iteratee) { + var index = -1, indexOf = getIndexOf(), length = array.length, isCommon = indexOf === baseIndexOf, isLarge = isCommon && length >= LARGE_ARRAY_SIZE, seen = isLarge ? createCache() : null, result = []; + if (seen) { + indexOf = cacheIndexOf; + isCommon = false; + } else { + isLarge = false; + seen = iteratee ? [] : result; + } + outer: while (++index < length) { + var value = array[index], computed = iteratee ? iteratee(value, index, array) : value; + if (isCommon && value === value) { + var seenIndex = seen.length; + while (seenIndex--) { + if (seen[seenIndex] === computed) { + continue outer; + } + } + if (iteratee) { + seen.push(computed); + } + result.push(value); + } else if (indexOf(seen, computed, 0) < 0) { + if (iteratee || isLarge) { + seen.push(computed); + } + result.push(value); + } + } + return result; + } + function baseValues(object, props) { + var index = -1, length = props.length, result = Array(length); + while (++index < length) { + result[index] = object[props[index]]; + } + return result; + } + function baseWhile(array, predicate, isDrop, fromRight) { + var length = array.length, index = fromRight ? length : -1; + while ((fromRight ? index-- : ++index < length) && predicate(array[index], index, array)) {} + return isDrop ? baseSlice(array, fromRight ? 0 : index, fromRight ? index + 1 : length) : baseSlice(array, fromRight ? index + 1 : 0, fromRight ? length : index); + } + function baseWrapperValue(value, actions) { + var result = value; + if (result instanceof LazyWrapper) { + result = result.value(); + } + var index = -1, length = actions.length; + while (++index < length) { + var action = actions[index]; + result = action.func.apply(action.thisArg, arrayPush([ result ], action.args)); + } + return result; + } + function binaryIndex(array, value, retHighest) { + var low = 0, high = array ? array.length : low; + if (typeof value == "number" && value === value && high <= HALF_MAX_ARRAY_LENGTH) { + while (low < high) { + var mid = low + high >>> 1, computed = array[mid]; + if ((retHighest ? computed <= value : computed < value) && computed !== null) { + low = mid + 1; + } else { + high = mid; + } + } + return high; + } + return binaryIndexBy(array, value, identity, retHighest); + } + function binaryIndexBy(array, value, iteratee, retHighest) { + value = iteratee(value); + var low = 0, high = array ? array.length : 0, valIsNaN = value !== value, valIsNull = value === null, valIsUndef = value === undefined; + while (low < high) { + var mid = nativeFloor((low + high) / 2), computed = iteratee(array[mid]), isDef = computed !== undefined, isReflexive = computed === computed; + if (valIsNaN) { + var setLow = isReflexive || retHighest; + } else if (valIsNull) { + setLow = isReflexive && isDef && (retHighest || computed != null); + } else if (valIsUndef) { + setLow = isReflexive && (retHighest || isDef); + } else if (computed == null) { + setLow = false; + } else { + setLow = retHighest ? computed <= value : computed < value; + } + if (setLow) { + low = mid + 1; + } else { + high = mid; + } + } + return nativeMin(high, MAX_ARRAY_INDEX); + } + function bindCallback(func, thisArg, argCount) { + if (typeof func != "function") { + return identity; + } + if (thisArg === undefined) { + return func; + } + switch (argCount) { + case 1: + return function(value) { + return func.call(thisArg, value); + }; + + case 3: + return function(value, index, collection) { + return func.call(thisArg, value, index, collection); + }; + + case 4: + return function(accumulator, value, index, collection) { + return func.call(thisArg, accumulator, value, index, collection); + }; + + case 5: + return function(value, other, key, object, source) { + return func.call(thisArg, value, other, key, object, source); + }; + } + return function() { + return func.apply(thisArg, arguments); + }; + } + function bufferClone(buffer) { + var result = new ArrayBuffer(buffer.byteLength), view = new Uint8Array(result); + view.set(new Uint8Array(buffer)); + return result; + } + function composeArgs(args, partials, holders) { + var holdersLength = holders.length, argsIndex = -1, argsLength = nativeMax(args.length - holdersLength, 0), leftIndex = -1, leftLength = partials.length, result = Array(leftLength + argsLength); + while (++leftIndex < leftLength) { + result[leftIndex] = partials[leftIndex]; + } + while (++argsIndex < holdersLength) { + result[holders[argsIndex]] = args[argsIndex]; + } + while (argsLength--) { + result[leftIndex++] = args[argsIndex++]; + } + return result; + } + function composeArgsRight(args, partials, holders) { + var holdersIndex = -1, holdersLength = holders.length, argsIndex = -1, argsLength = nativeMax(args.length - holdersLength, 0), rightIndex = -1, rightLength = partials.length, result = Array(argsLength + rightLength); + while (++argsIndex < argsLength) { + result[argsIndex] = args[argsIndex]; + } + var offset = argsIndex; + while (++rightIndex < rightLength) { + result[offset + rightIndex] = partials[rightIndex]; + } + while (++holdersIndex < holdersLength) { + result[offset + holders[holdersIndex]] = args[argsIndex++]; + } + return result; + } + function createAggregator(setter, initializer) { + return function(collection, iteratee, thisArg) { + var result = initializer ? initializer() : {}; + iteratee = getCallback(iteratee, thisArg, 3); + if (isArray(collection)) { + var index = -1, length = collection.length; + while (++index < length) { + var value = collection[index]; + setter(result, value, iteratee(value, index, collection), collection); + } + } else { + baseEach(collection, function(value, key, collection) { + setter(result, value, iteratee(value, key, collection), collection); + }); + } + return result; + }; + } + function createAssigner(assigner) { + return restParam(function(object, sources) { + var index = -1, length = object == null ? 0 : sources.length, customizer = length > 2 ? sources[length - 2] : undefined, guard = length > 2 ? sources[2] : undefined, thisArg = length > 1 ? sources[length - 1] : undefined; + if (typeof customizer == "function") { + customizer = bindCallback(customizer, thisArg, 5); + length -= 2; + } else { + customizer = typeof thisArg == "function" ? thisArg : undefined; + length -= customizer ? 1 : 0; + } + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + customizer = length < 3 ? undefined : customizer; + length = 1; + } + while (++index < length) { + var source = sources[index]; + if (source) { + assigner(object, source, customizer); + } + } + return object; + }); + } + function createBaseEach(eachFunc, fromRight) { + return function(collection, iteratee) { + var length = collection ? getLength(collection) : 0; + if (!isLength(length)) { + return eachFunc(collection, iteratee); + } + var index = fromRight ? length : -1, iterable = toObject(collection); + while (fromRight ? index-- : ++index < length) { + if (iteratee(iterable[index], index, iterable) === false) { + break; + } + } + return collection; + }; + } + function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var iterable = toObject(object), props = keysFunc(object), length = props.length, index = fromRight ? length : -1; + while (fromRight ? index-- : ++index < length) { + var key = props[index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } + } + return object; + }; + } + function createBindWrapper(func, thisArg) { + var Ctor = createCtorWrapper(func); + function wrapper() { + var fn = this && this !== root && this instanceof wrapper ? Ctor : func; + return fn.apply(thisArg, arguments); + } + return wrapper; + } + function createCache(values) { + return nativeCreate && Set ? new SetCache(values) : null; + } + function createCompounder(callback) { + return function(string) { + var index = -1, array = words(deburr(string)), length = array.length, result = ""; + while (++index < length) { + result = callback(result, array[index], index); + } + return result; + }; + } + function createCtorWrapper(Ctor) { + return function() { + var args = arguments; + switch (args.length) { + case 0: + return new Ctor(); + + case 1: + return new Ctor(args[0]); + + case 2: + return new Ctor(args[0], args[1]); + + case 3: + return new Ctor(args[0], args[1], args[2]); + + case 4: + return new Ctor(args[0], args[1], args[2], args[3]); + + case 5: + return new Ctor(args[0], args[1], args[2], args[3], args[4]); + + case 6: + return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); + + case 7: + return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + } + var thisBinding = baseCreate(Ctor.prototype), result = Ctor.apply(thisBinding, args); + return isObject(result) ? result : thisBinding; + }; + } + function createCurry(flag) { + function curryFunc(func, arity, guard) { + if (guard && isIterateeCall(func, arity, guard)) { + arity = undefined; + } + var result = createWrapper(func, flag, undefined, undefined, undefined, undefined, undefined, arity); + result.placeholder = curryFunc.placeholder; + return result; + } + return curryFunc; + } + function createDefaults(assigner, customizer) { + return restParam(function(args) { + var object = args[0]; + if (object == null) { + return object; + } + args.push(customizer); + return assigner.apply(undefined, args); + }); + } + function createExtremum(comparator, exValue) { + return function(collection, iteratee, thisArg) { + if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { + iteratee = undefined; + } + iteratee = getCallback(iteratee, thisArg, 3); + if (iteratee.length == 1) { + collection = isArray(collection) ? collection : toIterable(collection); + var result = arrayExtremum(collection, iteratee, comparator, exValue); + if (!(collection.length && result === exValue)) { + return result; + } + } + return baseExtremum(collection, iteratee, comparator, exValue); + }; + } + function createFind(eachFunc, fromRight) { + return function(collection, predicate, thisArg) { + predicate = getCallback(predicate, thisArg, 3); + if (isArray(collection)) { + var index = baseFindIndex(collection, predicate, fromRight); + return index > -1 ? collection[index] : undefined; + } + return baseFind(collection, predicate, eachFunc); + }; + } + function createFindIndex(fromRight) { + return function(array, predicate, thisArg) { + if (!(array && array.length)) { + return -1; + } + predicate = getCallback(predicate, thisArg, 3); + return baseFindIndex(array, predicate, fromRight); + }; + } + function createFindKey(objectFunc) { + return function(object, predicate, thisArg) { + predicate = getCallback(predicate, thisArg, 3); + return baseFind(object, predicate, objectFunc, true); + }; + } + function createFlow(fromRight) { + return function() { + var wrapper, length = arguments.length, index = fromRight ? length : -1, leftIndex = 0, funcs = Array(length); + while (fromRight ? index-- : ++index < length) { + var func = funcs[leftIndex++] = arguments[index]; + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == "wrapper") { + wrapper = new LodashWrapper([], true); + } + } + index = wrapper ? -1 : length; + while (++index < length) { + func = funcs[index]; + var funcName = getFuncName(func), data = funcName == "wrapper" ? getData(func) : undefined; + if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) { + wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); + } else { + wrapper = func.length == 1 && isLaziable(func) ? wrapper[funcName]() : wrapper.thru(func); + } + } + return function() { + var args = arguments, value = args[0]; + if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) { + return wrapper.plant(value).value(); + } + var index = 0, result = length ? funcs[index].apply(this, args) : value; + while (++index < length) { + result = funcs[index].call(this, result); + } + return result; + }; + }; + } + function createForEach(arrayFunc, eachFunc) { + return function(collection, iteratee, thisArg) { + return typeof iteratee == "function" && thisArg === undefined && isArray(collection) ? arrayFunc(collection, iteratee) : eachFunc(collection, bindCallback(iteratee, thisArg, 3)); + }; + } + function createForIn(objectFunc) { + return function(object, iteratee, thisArg) { + if (typeof iteratee != "function" || thisArg !== undefined) { + iteratee = bindCallback(iteratee, thisArg, 3); + } + return objectFunc(object, iteratee, keysIn); + }; + } + function createForOwn(objectFunc) { + return function(object, iteratee, thisArg) { + if (typeof iteratee != "function" || thisArg !== undefined) { + iteratee = bindCallback(iteratee, thisArg, 3); + } + return objectFunc(object, iteratee); + }; + } + function createObjectMapper(isMapKeys) { + return function(object, iteratee, thisArg) { + var result = {}; + iteratee = getCallback(iteratee, thisArg, 3); + baseForOwn(object, function(value, key, object) { + var mapped = iteratee(value, key, object); + key = isMapKeys ? mapped : key; + value = isMapKeys ? value : mapped; + result[key] = value; + }); + return result; + }; + } + function createPadDir(fromRight) { + return function(string, length, chars) { + string = baseToString(string); + return (fromRight ? string : "") + createPadding(string, length, chars) + (fromRight ? "" : string); + }; + } + function createPartial(flag) { + var partialFunc = restParam(function(func, partials) { + var holders = replaceHolders(partials, partialFunc.placeholder); + return createWrapper(func, flag, undefined, partials, holders); + }); + return partialFunc; + } + function createReduce(arrayFunc, eachFunc) { + return function(collection, iteratee, accumulator, thisArg) { + var initFromArray = arguments.length < 3; + return typeof iteratee == "function" && thisArg === undefined && isArray(collection) ? arrayFunc(collection, iteratee, accumulator, initFromArray) : baseReduce(collection, getCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc); + }; + } + function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { + var isAry = bitmask & ARY_FLAG, isBind = bitmask & BIND_FLAG, isBindKey = bitmask & BIND_KEY_FLAG, isCurry = bitmask & CURRY_FLAG, isCurryBound = bitmask & CURRY_BOUND_FLAG, isCurryRight = bitmask & CURRY_RIGHT_FLAG, Ctor = isBindKey ? undefined : createCtorWrapper(func); + function wrapper() { + var length = arguments.length, index = length, args = Array(length); + while (index--) { + args[index] = arguments[index]; + } + if (partials) { + args = composeArgs(args, partials, holders); + } + if (partialsRight) { + args = composeArgsRight(args, partialsRight, holdersRight); + } + if (isCurry || isCurryRight) { + var placeholder = wrapper.placeholder, argsHolders = replaceHolders(args, placeholder); + length -= argsHolders.length; + if (length < arity) { + var newArgPos = argPos ? arrayCopy(argPos) : undefined, newArity = nativeMax(arity - length, 0), newsHolders = isCurry ? argsHolders : undefined, newHoldersRight = isCurry ? undefined : argsHolders, newPartials = isCurry ? args : undefined, newPartialsRight = isCurry ? undefined : args; + bitmask |= isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG; + bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG); + if (!isCurryBound) { + bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); + } + var newData = [ func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity ], result = createHybridWrapper.apply(undefined, newData); + if (isLaziable(func)) { + setData(result, newData); + } + result.placeholder = placeholder; + return result; + } + } + var thisBinding = isBind ? thisArg : this, fn = isBindKey ? thisBinding[func] : func; + if (argPos) { + args = reorder(args, argPos); + } + if (isAry && ary < args.length) { + args.length = ary; + } + if (this && this !== root && this instanceof wrapper) { + fn = Ctor || createCtorWrapper(func); + } + return fn.apply(thisBinding, args); + } + return wrapper; + } + function createPadding(string, length, chars) { + var strLength = string.length; + length = +length; + if (strLength >= length || !nativeIsFinite(length)) { + return ""; + } + var padLength = length - strLength; + chars = chars == null ? " " : chars + ""; + return repeat(chars, nativeCeil(padLength / chars.length)).slice(0, padLength); + } + function createPartialWrapper(func, bitmask, thisArg, partials) { + var isBind = bitmask & BIND_FLAG, Ctor = createCtorWrapper(func); + function wrapper() { + var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array(leftLength + argsLength); + while (++leftIndex < leftLength) { + args[leftIndex] = partials[leftIndex]; + } + while (argsLength--) { + args[leftIndex++] = arguments[++argsIndex]; + } + var fn = this && this !== root && this instanceof wrapper ? Ctor : func; + return fn.apply(isBind ? thisArg : this, args); + } + return wrapper; + } + function createRound(methodName) { + var func = Math[methodName]; + return function(number, precision) { + precision = precision === undefined ? 0 : +precision || 0; + if (precision) { + precision = pow(10, precision); + return func(number * precision) / precision; + } + return func(number); + }; + } + function createSortedIndex(retHighest) { + return function(array, value, iteratee, thisArg) { + var callback = getCallback(iteratee); + return iteratee == null && callback === baseCallback ? binaryIndex(array, value, retHighest) : binaryIndexBy(array, value, callback(iteratee, thisArg, 1), retHighest); + }; + } + function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { + var isBindKey = bitmask & BIND_KEY_FLAG; + if (!isBindKey && typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + var length = partials ? partials.length : 0; + if (!length) { + bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG); + partials = holders = undefined; + } + length -= holders ? holders.length : 0; + if (bitmask & PARTIAL_RIGHT_FLAG) { + var partialsRight = partials, holdersRight = holders; + partials = holders = undefined; + } + var data = isBindKey ? undefined : getData(func), newData = [ func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity ]; + if (data) { + mergeData(newData, data); + bitmask = newData[1]; + arity = newData[9]; + } + newData[9] = arity == null ? isBindKey ? 0 : func.length : nativeMax(arity - length, 0) || 0; + if (bitmask == BIND_FLAG) { + var result = createBindWrapper(newData[0], newData[2]); + } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) { + result = createPartialWrapper.apply(undefined, newData); + } else { + result = createHybridWrapper.apply(undefined, newData); + } + var setter = data ? baseSetData : setData; + return setter(result, newData); + } + function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) { + var index = -1, arrLength = array.length, othLength = other.length; + if (arrLength != othLength && !(isLoose && othLength > arrLength)) { + return false; + } + while (++index < arrLength) { + var arrValue = array[index], othValue = other[index], result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined; + if (result !== undefined) { + if (result) { + continue; + } + return false; + } + if (isLoose) { + if (!arraySome(other, function(othValue) { + return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); + })) { + return false; + } + } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) { + return false; + } + } + return true; + } + function equalByTag(object, other, tag) { + switch (tag) { + case boolTag: + case dateTag: + return +object == +other; - case 2: - return function(value, other) { - return func.call(context, value, other); - }; + case errorTag: + return object.name == other.name && object.message == other.message; + + case numberTag: + return object != +object ? other != +other : object == +other; + + case regexpTag: + case stringTag: + return object == other + ""; + } + return false; + } + function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) { + var objProps = keys(object), objLength = objProps.length, othProps = keys(other), othLength = othProps.length; + if (objLength != othLength && !isLoose) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) { + return false; + } + } + var skipCtor = isLoose; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], othValue = other[key], result = customizer ? customizer(isLoose ? othValue : objValue, isLoose ? objValue : othValue, key) : undefined; + if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) { + return false; + } + skipCtor || (skipCtor = key == "constructor"); + } + if (!skipCtor) { + var objCtor = object.constructor, othCtor = other.constructor; + if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) { + return false; + } + } + return true; + } + function getCallback(func, thisArg, argCount) { + var result = lodash.callback || callback; + result = result === callback ? baseCallback : result; + return argCount ? result(func, thisArg, argCount) : result; + } + var getData = !metaMap ? noop : function(func) { + return metaMap.get(func); + }; + function getFuncName(func) { + var result = func.name + "", array = realNames[result], length = array ? array.length : 0; + while (length--) { + var data = array[length], otherFunc = data.func; + if (otherFunc == null || otherFunc == func) { + return data.name; + } + } + return result; + } + function getIndexOf(collection, target, fromIndex) { + var result = lodash.indexOf || indexOf; + result = result === indexOf ? baseIndexOf : result; + return collection ? result(collection, target, fromIndex) : result; + } + var getLength = baseProperty("length"); + function getMatchData(object) { + var result = pairs(object), length = result.length; + while (length--) { + result[length][2] = isStrictComparable(result[length][1]); + } + return result; + } + function getNative(object, key) { + var value = object == null ? undefined : object[key]; + return isNative(value) ? value : undefined; + } + function getView(start, end, transforms) { + var index = -1, length = transforms.length; + while (++index < length) { + var data = transforms[index], size = data.size; + switch (data.type) { + case "drop": + start += size; + break; + + case "dropRight": + end -= size; + break; + + case "take": + end = nativeMin(end, start + size); + break; - case 3: - return function(value, index, collection) { - return func.call(context, value, index, collection); + case "takeRight": + start = nativeMax(start, end - size); + break; + } + } + return { + start: start, + end: end }; + } + function initCloneArray(array) { + var length = array.length, result = new array.constructor(length); + if (length && typeof array[0] == "string" && hasOwnProperty.call(array, "index")) { + result.index = array.index; + result.input = array.input; + } + return result; + } + function initCloneObject(object) { + var Ctor = object.constructor; + if (!(typeof Ctor == "function" && Ctor instanceof Ctor)) { + Ctor = Object; + } + return new Ctor(); + } + function initCloneByTag(object, tag, isDeep) { + var Ctor = object.constructor; + switch (tag) { + case arrayBufferTag: + return bufferClone(object); + + case boolTag: + case dateTag: + return new Ctor(+object); + + case float32Tag: + case float64Tag: + case int8Tag: + case int16Tag: + case int32Tag: + case uint8Tag: + case uint8ClampedTag: + case uint16Tag: + case uint32Tag: + var buffer = object.buffer; + return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length); + + case numberTag: + case stringTag: + return new Ctor(object); - case 4: - return function(accumulator, value, index, collection) { - return func.call(context, accumulator, value, index, collection); + case regexpTag: + var result = new Ctor(object.source, reFlags.exec(object)); + result.lastIndex = object.lastIndex; + } + return result; + } + function invokePath(object, path, args) { + if (object != null && !isKey(path, object)) { + path = toPath(path); + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + path = last(path); + } + var func = object == null ? object : object[path]; + return func == null ? undefined : func.apply(object, args); + } + function isArrayLike(value) { + return value != null && isLength(getLength(value)); + } + function isIndex(value, length) { + value = typeof value == "number" || reIsUint.test(value) ? +value : -1; + length = length == null ? MAX_SAFE_INTEGER : length; + return value > -1 && value % 1 == 0 && value < length; + } + function isIterateeCall(value, index, object) { + if (!isObject(object)) { + return false; + } + var type = typeof index; + if (type == "number" ? isArrayLike(object) && isIndex(index, object.length) : type == "string" && index in object) { + var other = object[index]; + return value === value ? value === other : other !== other; + } + return false; + } + function isKey(value, object) { + var type = typeof value; + if (type == "string" && reIsPlainProp.test(value) || type == "number") { + return true; + } + if (isArray(value)) { + return false; + } + var result = !reIsDeepProp.test(value); + return result || object != null && value in toObject(object); + } + function isLaziable(func) { + var funcName = getFuncName(func), other = lodash[funcName]; + if (typeof other != "function" || !(funcName in LazyWrapper.prototype)) { + return false; + } + if (func === other) { + return true; + } + var data = getData(other); + return !!data && func === data[0]; + } + function isLength(value) { + return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; + } + function isStrictComparable(value) { + return value === value && !isObject(value); + } + function mergeData(data, source) { + var bitmask = data[1], srcBitmask = source[1], newBitmask = bitmask | srcBitmask, isCommon = newBitmask < ARY_FLAG; + var isCombo = srcBitmask == ARY_FLAG && bitmask == CURRY_FLAG || srcBitmask == ARY_FLAG && bitmask == REARG_FLAG && data[7].length <= source[8] || srcBitmask == (ARY_FLAG | REARG_FLAG) && bitmask == CURRY_FLAG; + if (!(isCommon || isCombo)) { + return data; + } + if (srcBitmask & BIND_FLAG) { + data[2] = source[2]; + newBitmask |= bitmask & BIND_FLAG ? 0 : CURRY_BOUND_FLAG; + } + var value = source[3]; + if (value) { + var partials = data[3]; + data[3] = partials ? composeArgs(partials, value, source[4]) : arrayCopy(value); + data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : arrayCopy(source[4]); + } + value = source[5]; + if (value) { + partials = data[5]; + data[5] = partials ? composeArgsRight(partials, value, source[6]) : arrayCopy(value); + data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : arrayCopy(source[6]); + } + value = source[7]; + if (value) { + data[7] = arrayCopy(value); + } + if (srcBitmask & ARY_FLAG) { + data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); + } + if (data[9] == null) { + data[9] = source[9]; + } + data[0] = source[0]; + data[1] = newBitmask; + return data; + } + function mergeDefaults(objectValue, sourceValue) { + return objectValue === undefined ? sourceValue : merge(objectValue, sourceValue, mergeDefaults); + } + function pickByArray(object, props) { + object = toObject(object); + var index = -1, length = props.length, result = {}; + while (++index < length) { + var key = props[index]; + if (key in object) { + result[key] = object[key]; + } + } + return result; + } + function pickByCallback(object, predicate) { + var result = {}; + baseForIn(object, function(value, key, object) { + if (predicate(value, key, object)) { + result[key] = value; + } + }); + return result; + } + function reorder(array, indexes) { + var arrLength = array.length, length = nativeMin(indexes.length, arrLength), oldArray = arrayCopy(array); + while (length--) { + var index = indexes[length]; + array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; + } + return array; + } + var setData = function() { + var count = 0, lastCalled = 0; + return function(key, value) { + var stamp = now(), remaining = HOT_SPAN - (stamp - lastCalled); + lastCalled = stamp; + if (remaining > 0) { + if (++count >= HOT_COUNT) { + return key; + } + } else { + count = 0; + } + return baseSetData(key, value); }; + }(); + function shimKeys(object) { + var props = keysIn(object), propsLength = props.length, length = propsLength && object.length; + var allowIndexes = !!length && isLength(length) && (isArray(object) || isArguments(object)); + var index = -1, result = []; + while (++index < propsLength) { + var key = props[index]; + if (allowIndexes && isIndex(key, length) || hasOwnProperty.call(object, key)) { + result.push(key); + } + } + return result; } - return function() { - return func.apply(context, arguments); - }; - }; - var cb = function(value, context, argCount) { - if (value == null) return _.identity; - if (_.isFunction(value)) return optimizeCb(value, context, argCount); - if (_.isObject(value)) return _.matcher(value); - return _.property(value); - }; - _.iteratee = function(value, context) { - return cb(value, context, Infinity); - }; - var createAssigner = function(keysFunc, undefinedOnly) { - return function(obj) { - var length = arguments.length; - if (length < 2 || obj == null) return obj; - for (var index = 1; index < length; index++) { - var source = arguments[index], keys = keysFunc(source), l = keys.length; - for (var i = 0; i < l; i++) { - var key = keys[i]; - if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key]; + function toIterable(value) { + if (value == null) { + return []; + } + if (!isArrayLike(value)) { + return values(value); + } + return isObject(value) ? value : Object(value); + } + function toObject(value) { + return isObject(value) ? value : Object(value); + } + function toPath(value) { + if (isArray(value)) { + return value; + } + var result = []; + baseToString(value).replace(rePropName, function(match, number, quote, string) { + result.push(quote ? string.replace(reEscapeChar, "$1") : number || match); + }); + return result; + } + function wrapperClone(wrapper) { + return wrapper instanceof LazyWrapper ? wrapper.clone() : new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__)); + } + function chunk(array, size, guard) { + if (guard ? isIterateeCall(array, size, guard) : size == null) { + size = 1; + } else { + size = nativeMax(nativeFloor(size) || 1, 1); + } + var index = 0, length = array ? array.length : 0, resIndex = -1, result = Array(nativeCeil(length / size)); + while (index < length) { + result[++resIndex] = baseSlice(array, index, index += size); + } + return result; + } + function compact(array) { + var index = -1, length = array ? array.length : 0, resIndex = -1, result = []; + while (++index < length) { + var value = array[index]; + if (value) { + result[++resIndex] = value; + } + } + return result; + } + var difference = restParam(function(array, values) { + return isObjectLike(array) && isArrayLike(array) ? baseDifference(array, baseFlatten(values, false, true)) : []; + }); + function drop(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + return baseSlice(array, n < 0 ? 0 : n); + } + function dropRight(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + n = length - (+n || 0); + return baseSlice(array, 0, n < 0 ? 0 : n); + } + function dropRightWhile(array, predicate, thisArg) { + return array && array.length ? baseWhile(array, getCallback(predicate, thisArg, 3), true, true) : []; + } + function dropWhile(array, predicate, thisArg) { + return array && array.length ? baseWhile(array, getCallback(predicate, thisArg, 3), true) : []; + } + function fill(array, value, start, end) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (start && typeof start != "number" && isIterateeCall(array, value, start)) { + start = 0; + end = length; + } + return baseFill(array, value, start, end); + } + var findIndex = createFindIndex(); + var findLastIndex = createFindIndex(true); + function first(array) { + return array ? array[0] : undefined; + } + function flatten(array, isDeep, guard) { + var length = array ? array.length : 0; + if (guard && isIterateeCall(array, isDeep, guard)) { + isDeep = false; + } + return length ? baseFlatten(array, isDeep) : []; + } + function flattenDeep(array) { + var length = array ? array.length : 0; + return length ? baseFlatten(array, true) : []; + } + function indexOf(array, value, fromIndex) { + var length = array ? array.length : 0; + if (!length) { + return -1; + } + if (typeof fromIndex == "number") { + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex; + } else if (fromIndex) { + var index = binaryIndex(array, value); + if (index < length && (value === value ? value === array[index] : array[index] !== array[index])) { + return index; + } + return -1; + } + return baseIndexOf(array, value, fromIndex || 0); + } + function initial(array) { + return dropRight(array, 1); + } + var intersection = restParam(function(arrays) { + var othLength = arrays.length, othIndex = othLength, caches = Array(length), indexOf = getIndexOf(), isCommon = indexOf === baseIndexOf, result = []; + while (othIndex--) { + var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : []; + caches[othIndex] = isCommon && value.length >= 120 ? createCache(othIndex && value) : null; + } + var array = arrays[0], index = -1, length = array ? array.length : 0, seen = caches[0]; + outer: while (++index < length) { + value = array[index]; + if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) { + var othIndex = othLength; + while (--othIndex) { + var cache = caches[othIndex]; + if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) { + continue outer; + } + } + if (seen) { + seen.push(value); + } + result.push(value); + } + } + return result; + }); + function last(array) { + var length = array ? array.length : 0; + return length ? array[length - 1] : undefined; + } + function lastIndexOf(array, value, fromIndex) { + var length = array ? array.length : 0; + if (!length) { + return -1; + } + var index = length; + if (typeof fromIndex == "number") { + index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1; + } else if (fromIndex) { + index = binaryIndex(array, value, true) - 1; + var other = array[index]; + if (value === value ? value === other : other !== other) { + return index; + } + return -1; + } + if (value !== value) { + return indexOfNaN(array, index, true); + } + while (index--) { + if (array[index] === value) { + return index; + } + } + return -1; + } + function pull() { + var args = arguments, array = args[0]; + if (!(array && array.length)) { + return array; + } + var index = 0, indexOf = getIndexOf(), length = args.length; + while (++index < length) { + var fromIndex = 0, value = args[index]; + while ((fromIndex = indexOf(array, value, fromIndex)) > -1) { + splice.call(array, fromIndex, 1); + } + } + return array; + } + var pullAt = restParam(function(array, indexes) { + indexes = baseFlatten(indexes); + var result = baseAt(array, indexes); + basePullAt(array, indexes.sort(baseCompareAscending)); + return result; + }); + function remove(array, predicate, thisArg) { + var result = []; + if (!(array && array.length)) { + return result; + } + var index = -1, indexes = [], length = array.length; + predicate = getCallback(predicate, thisArg, 3); + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result.push(value); + indexes.push(index); + } + } + basePullAt(array, indexes); + return result; + } + function rest(array) { + return drop(array, 1); + } + function slice(array, start, end) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (end && typeof end != "number" && isIterateeCall(array, start, end)) { + start = 0; + end = length; + } + return baseSlice(array, start, end); + } + var sortedIndex = createSortedIndex(); + var sortedLastIndex = createSortedIndex(true); + function take(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + return baseSlice(array, 0, n < 0 ? 0 : n); + } + function takeRight(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + n = length - (+n || 0); + return baseSlice(array, n < 0 ? 0 : n); + } + function takeRightWhile(array, predicate, thisArg) { + return array && array.length ? baseWhile(array, getCallback(predicate, thisArg, 3), false, true) : []; + } + function takeWhile(array, predicate, thisArg) { + return array && array.length ? baseWhile(array, getCallback(predicate, thisArg, 3)) : []; + } + var union = restParam(function(arrays) { + return baseUniq(baseFlatten(arrays, false, true)); + }); + function uniq(array, isSorted, iteratee, thisArg) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (isSorted != null && typeof isSorted != "boolean") { + thisArg = iteratee; + iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted; + isSorted = false; + } + var callback = getCallback(); + if (!(iteratee == null && callback === baseCallback)) { + iteratee = callback(iteratee, thisArg, 3); + } + return isSorted && getIndexOf() === baseIndexOf ? sortedUniq(array, iteratee) : baseUniq(array, iteratee); + } + function unzip(array) { + if (!(array && array.length)) { + return []; + } + var index = -1, length = 0; + array = arrayFilter(array, function(group) { + if (isArrayLike(group)) { + length = nativeMax(group.length, length); + return true; + } + }); + var result = Array(length); + while (++index < length) { + result[index] = arrayMap(array, baseProperty(index)); + } + return result; + } + function unzipWith(array, iteratee, thisArg) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + var result = unzip(array); + if (iteratee == null) { + return result; + } + iteratee = bindCallback(iteratee, thisArg, 4); + return arrayMap(result, function(group) { + return arrayReduce(group, iteratee, undefined, true); + }); + } + var without = restParam(function(array, values) { + return isArrayLike(array) ? baseDifference(array, values) : []; + }); + function xor() { + var index = -1, length = arguments.length; + while (++index < length) { + var array = arguments[index]; + if (isArrayLike(array)) { + var result = result ? arrayPush(baseDifference(result, array), baseDifference(array, result)) : array; + } + } + return result ? baseUniq(result) : []; + } + var zip = restParam(unzip); + function zipObject(props, values) { + var index = -1, length = props ? props.length : 0, result = {}; + if (length && !values && !isArray(props[0])) { + values = []; + } + while (++index < length) { + var key = props[index]; + if (values) { + result[key] = values[index]; + } else if (key) { + result[key[0]] = key[1]; + } + } + return result; + } + var zipWith = restParam(function(arrays) { + var length = arrays.length, iteratee = length > 2 ? arrays[length - 2] : undefined, thisArg = length > 1 ? arrays[length - 1] : undefined; + if (length > 2 && typeof iteratee == "function") { + length -= 2; + } else { + iteratee = length > 1 && typeof thisArg == "function" ? (--length, thisArg) : undefined; + thisArg = undefined; + } + arrays.length = length; + return unzipWith(arrays, iteratee, thisArg); + }); + function chain(value) { + var result = lodash(value); + result.__chain__ = true; + return result; + } + function tap(value, interceptor, thisArg) { + interceptor.call(thisArg, value); + return value; + } + function thru(value, interceptor, thisArg) { + return interceptor.call(thisArg, value); + } + function wrapperChain() { + return chain(this); + } + function wrapperCommit() { + return new LodashWrapper(this.value(), this.__chain__); + } + var wrapperConcat = restParam(function(values) { + values = baseFlatten(values); + return this.thru(function(array) { + return arrayConcat(isArray(array) ? array : [ toObject(array) ], values); + }); + }); + function wrapperPlant(value) { + var result, parent = this; + while (parent instanceof baseLodash) { + var clone = wrapperClone(parent); + if (result) { + previous.__wrapped__ = clone; + } else { + result = clone; } + var previous = clone; + parent = parent.__wrapped__; } - return obj; - }; - }; - var baseCreate = function(prototype) { - if (!_.isObject(prototype)) return {}; - if (nativeCreate) return nativeCreate(prototype); - Ctor.prototype = prototype; - var result = new Ctor(); - Ctor.prototype = null; - return result; - }; - var property = function(key) { - return function(obj) { - return obj == null ? void 0 : obj[key]; - }; - }; - var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; - var getLength = property("length"); - var isArrayLike = function(collection) { - var length = getLength(collection); - return typeof length == "number" && length >= 0 && length <= MAX_ARRAY_INDEX; - }; - _.each = _.forEach = function(obj, iteratee, context) { - iteratee = optimizeCb(iteratee, context); - var i, length; - if (isArrayLike(obj)) { - for (i = 0, length = obj.length; i < length; i++) { - iteratee(obj[i], i, obj); + previous.__wrapped__ = value; + return result; + } + function wrapperReverse() { + var value = this.__wrapped__; + var interceptor = function(value) { + return value.reverse(); + }; + if (value instanceof LazyWrapper) { + var wrapped = value; + if (this.__actions__.length) { + wrapped = new LazyWrapper(this); + } + wrapped = wrapped.reverse(); + wrapped.__actions__.push({ + func: thru, + args: [ interceptor ], + thisArg: undefined + }); + return new LodashWrapper(wrapped, this.__chain__); } - } else { - var keys = _.keys(obj); - for (i = 0, length = keys.length; i < length; i++) { - iteratee(obj[keys[i]], keys[i], obj); + return this.thru(interceptor); + } + function wrapperToString() { + return this.value() + ""; + } + function wrapperValue() { + return baseWrapperValue(this.__wrapped__, this.__actions__); + } + var at = restParam(function(collection, props) { + return baseAt(collection, baseFlatten(props)); + }); + var countBy = createAggregator(function(result, value, key) { + hasOwnProperty.call(result, key) ? ++result[key] : result[key] = 1; + }); + function every(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayEvery : baseEvery; + if (thisArg && isIterateeCall(collection, predicate, thisArg)) { + predicate = undefined; + } + if (typeof predicate != "function" || thisArg !== undefined) { + predicate = getCallback(predicate, thisArg, 3); + } + return func(collection, predicate); + } + function filter(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayFilter : baseFilter; + predicate = getCallback(predicate, thisArg, 3); + return func(collection, predicate); + } + var find = createFind(baseEach); + var findLast = createFind(baseEachRight, true); + function findWhere(collection, source) { + return find(collection, baseMatches(source)); + } + var forEach = createForEach(arrayEach, baseEach); + var forEachRight = createForEach(arrayEachRight, baseEachRight); + var groupBy = createAggregator(function(result, value, key) { + if (hasOwnProperty.call(result, key)) { + result[key].push(value); + } else { + result[key] = [ value ]; + } + }); + function includes(collection, target, fromIndex, guard) { + var length = collection ? getLength(collection) : 0; + if (!isLength(length)) { + collection = values(collection); + length = collection.length; + } + if (typeof fromIndex != "number" || guard && isIterateeCall(target, fromIndex, guard)) { + fromIndex = 0; + } else { + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex || 0; } + return typeof collection == "string" || !isArray(collection) && isString(collection) ? fromIndex <= length && collection.indexOf(target, fromIndex) > -1 : !!length && getIndexOf(collection, target, fromIndex) > -1; } - return obj; - }; - _.map = _.collect = function(obj, iteratee, context) { - iteratee = cb(iteratee, context); - var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length, results = Array(length); - for (var index = 0; index < length; index++) { - var currentKey = keys ? keys[index] : index; - results[index] = iteratee(obj[currentKey], currentKey, obj); + var indexBy = createAggregator(function(result, value, key) { + result[key] = value; + }); + var invoke = restParam(function(collection, path, args) { + var index = -1, isFunc = typeof path == "function", isProp = isKey(path), result = isArrayLike(collection) ? Array(collection.length) : []; + baseEach(collection, function(value) { + var func = isFunc ? path : isProp && value != null ? value[path] : undefined; + result[++index] = func ? func.apply(value, args) : invokePath(value, path, args); + }); + return result; + }); + function map(collection, iteratee, thisArg) { + var func = isArray(collection) ? arrayMap : baseMap; + iteratee = getCallback(iteratee, thisArg, 3); + return func(collection, iteratee); + } + var partition = createAggregator(function(result, value, key) { + result[key ? 0 : 1].push(value); + }, function() { + return [ [], [] ]; + }); + function pluck(collection, path) { + return map(collection, property(path)); + } + var reduce = createReduce(arrayReduce, baseEach); + var reduceRight = createReduce(arrayReduceRight, baseEachRight); + function reject(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayFilter : baseFilter; + predicate = getCallback(predicate, thisArg, 3); + return func(collection, function(value, index, collection) { + return !predicate(value, index, collection); + }); } - return results; - }; - function createReduce(dir) { - function iterator(obj, iteratee, memo, keys, index, length) { - for (;index >= 0 && index < length; index += dir) { - var currentKey = keys ? keys[index] : index; - memo = iteratee(memo, obj[currentKey], currentKey, obj); + function sample(collection, n, guard) { + if (guard ? isIterateeCall(collection, n, guard) : n == null) { + collection = toIterable(collection); + var length = collection.length; + return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; + } + var index = -1, result = toArray(collection), length = result.length, lastIndex = length - 1; + n = nativeMin(n < 0 ? 0 : +n || 0, length); + while (++index < n) { + var rand = baseRandom(index, lastIndex), value = result[rand]; + result[rand] = result[index]; + result[index] = value; } - return memo; + result.length = n; + return result; } - return function(obj, iteratee, memo, context) { - iteratee = optimizeCb(iteratee, context, 4); - var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length, index = dir > 0 ? 0 : length - 1; - if (arguments.length < 3) { - memo = obj[keys ? keys[index] : index]; - index += dir; + function shuffle(collection) { + return sample(collection, POSITIVE_INFINITY); + } + function size(collection) { + var length = collection ? getLength(collection) : 0; + return isLength(length) ? length : keys(collection).length; + } + function some(collection, predicate, thisArg) { + var func = isArray(collection) ? arraySome : baseSome; + if (thisArg && isIterateeCall(collection, predicate, thisArg)) { + predicate = undefined; } - return iterator(obj, iteratee, memo, keys, index, length); - }; - } - _.reduce = _.foldl = _.inject = createReduce(1); - _.reduceRight = _.foldr = createReduce(-1); - _.find = _.detect = function(obj, predicate, context) { - var key; - if (isArrayLike(obj)) { - key = _.findIndex(obj, predicate, context); - } else { - key = _.findKey(obj, predicate, context); + if (typeof predicate != "function" || thisArg !== undefined) { + predicate = getCallback(predicate, thisArg, 3); + } + return func(collection, predicate); } - if (key !== void 0 && key !== -1) return obj[key]; - }; - _.filter = _.select = function(obj, predicate, context) { - var results = []; - predicate = cb(predicate, context); - _.each(obj, function(value, index, list) { - if (predicate(value, index, list)) results.push(value); + function sortBy(collection, iteratee, thisArg) { + if (collection == null) { + return []; + } + if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { + iteratee = undefined; + } + var index = -1; + iteratee = getCallback(iteratee, thisArg, 3); + var result = baseMap(collection, function(value, key, collection) { + return { + criteria: iteratee(value, key, collection), + index: ++index, + value: value + }; + }); + return baseSortBy(result, compareAscending); + } + var sortByAll = restParam(function(collection, iteratees) { + if (collection == null) { + return []; + } + var guard = iteratees[2]; + if (guard && isIterateeCall(iteratees[0], iteratees[1], guard)) { + iteratees.length = 1; + } + return baseSortByOrder(collection, baseFlatten(iteratees), []); }); - return results; - }; - _.reject = function(obj, predicate, context) { - return _.filter(obj, _.negate(cb(predicate)), context); - }; - _.every = _.all = function(obj, predicate, context) { - predicate = cb(predicate, context); - var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length; - for (var index = 0; index < length; index++) { - var currentKey = keys ? keys[index] : index; - if (!predicate(obj[currentKey], currentKey, obj)) return false; + function sortByOrder(collection, iteratees, orders, guard) { + if (collection == null) { + return []; + } + if (guard && isIterateeCall(iteratees, orders, guard)) { + orders = undefined; + } + if (!isArray(iteratees)) { + iteratees = iteratees == null ? [] : [ iteratees ]; + } + if (!isArray(orders)) { + orders = orders == null ? [] : [ orders ]; + } + return baseSortByOrder(collection, iteratees, orders); } - return true; - }; - _.some = _.any = function(obj, predicate, context) { - predicate = cb(predicate, context); - var keys = !isArrayLike(obj) && _.keys(obj), length = (keys || obj).length; - for (var index = 0; index < length; index++) { - var currentKey = keys ? keys[index] : index; - if (predicate(obj[currentKey], currentKey, obj)) return true; + function where(collection, source) { + return filter(collection, baseMatches(source)); } - return false; - }; - _.contains = _.includes = _.include = function(obj, item, fromIndex, guard) { - if (!isArrayLike(obj)) obj = _.values(obj); - if (typeof fromIndex != "number" || guard) fromIndex = 0; - return _.indexOf(obj, item, fromIndex) >= 0; - }; - _.invoke = function(obj, method) { - var args = slice.call(arguments, 2); - var isFunc = _.isFunction(method); - return _.map(obj, function(value) { - var func = isFunc ? method : value[method]; - return func == null ? func : func.apply(value, args); - }); - }; - _.pluck = function(obj, key) { - return _.map(obj, _.property(key)); - }; - _.where = function(obj, attrs) { - return _.filter(obj, _.matcher(attrs)); - }; - _.findWhere = function(obj, attrs) { - return _.find(obj, _.matcher(attrs)); - }; - _.max = function(obj, iteratee, context) { - var result = -Infinity, lastComputed = -Infinity, value, computed; - if (iteratee == null && obj != null) { - obj = isArrayLike(obj) ? obj : _.values(obj); - for (var i = 0, length = obj.length; i < length; i++) { - value = obj[i]; - if (value > result) { - result = value; + var now = nativeNow || function() { + return new Date().getTime(); + }; + function after(n, func) { + if (typeof func != "function") { + if (typeof n == "function") { + var temp = n; + n = func; + func = temp; + } else { + throw new TypeError(FUNC_ERROR_TEXT); } } - } else { - iteratee = cb(iteratee, context); - _.each(obj, function(value, index, list) { - computed = iteratee(value, index, list); - if (computed > lastComputed || computed === -Infinity && result === -Infinity) { - result = value; - lastComputed = computed; + n = nativeIsFinite(n = +n) ? n : 0; + return function() { + if (--n < 1) { + return func.apply(this, arguments); } - }); + }; } - return result; - }; - _.min = function(obj, iteratee, context) { - var result = Infinity, lastComputed = Infinity, value, computed; - if (iteratee == null && obj != null) { - obj = isArrayLike(obj) ? obj : _.values(obj); - for (var i = 0, length = obj.length; i < length; i++) { - value = obj[i]; - if (value < result) { - result = value; + function ary(func, n, guard) { + if (guard && isIterateeCall(func, n, guard)) { + n = undefined; + } + n = func && n == null ? func.length : nativeMax(+n || 0, 0); + return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n); + } + function before(n, func) { + var result; + if (typeof func != "function") { + if (typeof n == "function") { + var temp = n; + n = func; + func = temp; + } else { + throw new TypeError(FUNC_ERROR_TEXT); } } - } else { - iteratee = cb(iteratee, context); - _.each(obj, function(value, index, list) { - computed = iteratee(value, index, list); - if (computed < lastComputed || computed === Infinity && result === Infinity) { - result = value; - lastComputed = computed; + return function() { + if (--n > 0) { + result = func.apply(this, arguments); + } + if (n <= 1) { + func = undefined; + } + return result; + }; + } + var bind = restParam(function(func, thisArg, partials) { + var bitmask = BIND_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, bind.placeholder); + bitmask |= PARTIAL_FLAG; + } + return createWrapper(func, bitmask, thisArg, partials, holders); + }); + var bindAll = restParam(function(object, methodNames) { + methodNames = methodNames.length ? baseFlatten(methodNames) : functions(object); + var index = -1, length = methodNames.length; + while (++index < length) { + var key = methodNames[index]; + object[key] = createWrapper(object[key], BIND_FLAG, object); + } + return object; + }); + var bindKey = restParam(function(object, key, partials) { + var bitmask = BIND_FLAG | BIND_KEY_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, bindKey.placeholder); + bitmask |= PARTIAL_FLAG; + } + return createWrapper(key, bitmask, object, partials, holders); + }); + var curry = createCurry(CURRY_FLAG); + var curryRight = createCurry(CURRY_RIGHT_FLAG); + function debounce(func, wait, options) { + var args, maxTimeoutId, result, stamp, thisArg, timeoutId, trailingCall, lastCalled = 0, maxWait = false, trailing = true; + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + wait = wait < 0 ? 0 : +wait || 0; + if (options === true) { + var leading = true; + trailing = false; + } else if (isObject(options)) { + leading = !!options.leading; + maxWait = "maxWait" in options && nativeMax(+options.maxWait || 0, wait); + trailing = "trailing" in options ? !!options.trailing : trailing; + } + function cancel() { + if (timeoutId) { + clearTimeout(timeoutId); + } + if (maxTimeoutId) { + clearTimeout(maxTimeoutId); + } + lastCalled = 0; + maxTimeoutId = timeoutId = trailingCall = undefined; + } + function complete(isCalled, id) { + if (id) { + clearTimeout(id); + } + maxTimeoutId = timeoutId = trailingCall = undefined; + if (isCalled) { + lastCalled = now(); + result = func.apply(thisArg, args); + if (!timeoutId && !maxTimeoutId) { + args = thisArg = undefined; + } + } + } + function delayed() { + var remaining = wait - (now() - stamp); + if (remaining <= 0 || remaining > wait) { + complete(trailingCall, maxTimeoutId); + } else { + timeoutId = setTimeout(delayed, remaining); + } + } + function maxDelayed() { + complete(trailing, timeoutId); + } + function debounced() { + args = arguments; + stamp = now(); + thisArg = this; + trailingCall = trailing && (timeoutId || !leading); + if (maxWait === false) { + var leadingCall = leading && !timeoutId; + } else { + if (!maxTimeoutId && !leading) { + lastCalled = stamp; + } + var remaining = maxWait - (stamp - lastCalled), isCalled = remaining <= 0 || remaining > maxWait; + if (isCalled) { + if (maxTimeoutId) { + maxTimeoutId = clearTimeout(maxTimeoutId); + } + lastCalled = stamp; + result = func.apply(thisArg, args); + } else if (!maxTimeoutId) { + maxTimeoutId = setTimeout(maxDelayed, remaining); + } + } + if (isCalled && timeoutId) { + timeoutId = clearTimeout(timeoutId); + } else if (!timeoutId && wait !== maxWait) { + timeoutId = setTimeout(delayed, wait); } + if (leadingCall) { + isCalled = true; + result = func.apply(thisArg, args); + } + if (isCalled && !timeoutId && !maxTimeoutId) { + args = thisArg = undefined; + } + return result; + } + debounced.cancel = cancel; + return debounced; + } + var defer = restParam(function(func, args) { + return baseDelay(func, 1, args); + }); + var delay = restParam(function(func, wait, args) { + return baseDelay(func, wait, args); + }); + var flow = createFlow(); + var flowRight = createFlow(true); + function memoize(func, resolver) { + if (typeof func != "function" || resolver && typeof resolver != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache; + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result); + return result; + }; + memoized.cache = new memoize.Cache(); + return memoized; + } + var modArgs = restParam(function(func, transforms) { + transforms = baseFlatten(transforms); + if (typeof func != "function" || !arrayEvery(transforms, baseIsFunction)) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var length = transforms.length; + return restParam(function(args) { + var index = nativeMin(args.length, length); + while (index--) { + args[index] = transforms[index](args[index]); + } + return func.apply(this, args); }); + }); + function negate(predicate) { + if (typeof predicate != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + return function() { + return !predicate.apply(this, arguments); + }; } - return result; - }; - _.shuffle = function(obj) { - var set = isArrayLike(obj) ? obj : _.values(obj); - var length = set.length; - var shuffled = Array(length); - for (var index = 0, rand; index < length; index++) { - rand = _.random(0, index); - if (rand !== index) shuffled[index] = shuffled[rand]; - shuffled[rand] = set[index]; + function once(func) { + return before(2, func); } - return shuffled; - }; - _.sample = function(obj, n, guard) { - if (n == null || guard) { - if (!isArrayLike(obj)) obj = _.values(obj); - return obj[_.random(obj.length - 1)]; + var partial = createPartial(PARTIAL_FLAG); + var partialRight = createPartial(PARTIAL_RIGHT_FLAG); + var rearg = restParam(function(func, indexes) { + return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes)); + }); + function restParam(func, start) { + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + start = nativeMax(start === undefined ? func.length - 1 : +start || 0, 0); + return function() { + var args = arguments, index = -1, length = nativeMax(args.length - start, 0), rest = Array(length); + while (++index < length) { + rest[index] = args[start + index]; + } + switch (start) { + case 0: + return func.call(this, rest); + + case 1: + return func.call(this, args[0], rest); + + case 2: + return func.call(this, args[0], args[1], rest); + } + var otherArgs = Array(start + 1); + index = -1; + while (++index < start) { + otherArgs[index] = args[index]; + } + otherArgs[start] = rest; + return func.apply(this, otherArgs); + }; } - return _.shuffle(obj).slice(0, Math.max(0, n)); - }; - _.sortBy = function(obj, iteratee, context) { - iteratee = cb(iteratee, context); - return _.pluck(_.map(obj, function(value, index, list) { - return { - value: value, - index: index, - criteria: iteratee(value, index, list) + function spread(func) { + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); + } + return function(array) { + return func.apply(this, array); }; - }).sort(function(left, right) { - var a = left.criteria; - var b = right.criteria; - if (a !== b) { - if (a > b || a === void 0) return 1; - if (a < b || b === void 0) return -1; + } + function throttle(func, wait, options) { + var leading = true, trailing = true; + if (typeof func != "function") { + throw new TypeError(FUNC_ERROR_TEXT); } - return left.index - right.index; - }), "value"); - }; - var group = function(behavior) { - return function(obj, iteratee, context) { - var result = {}; - iteratee = cb(iteratee, context); - _.each(obj, function(value, index) { - var key = iteratee(value, index, obj); - behavior(result, value, key); + if (options === false) { + leading = false; + } else if (isObject(options)) { + leading = "leading" in options ? !!options.leading : leading; + trailing = "trailing" in options ? !!options.trailing : trailing; + } + return debounce(func, wait, { + leading: leading, + maxWait: +wait, + trailing: trailing + }); + } + function wrap(value, wrapper) { + wrapper = wrapper == null ? identity : wrapper; + return createWrapper(wrapper, PARTIAL_FLAG, undefined, [ value ], []); + } + function clone(value, isDeep, customizer, thisArg) { + if (isDeep && typeof isDeep != "boolean" && isIterateeCall(value, isDeep, customizer)) { + isDeep = false; + } else if (typeof isDeep == "function") { + thisArg = customizer; + customizer = isDeep; + isDeep = false; + } + return typeof customizer == "function" ? baseClone(value, isDeep, bindCallback(customizer, thisArg, 3)) : baseClone(value, isDeep); + } + function cloneDeep(value, customizer, thisArg) { + return typeof customizer == "function" ? baseClone(value, true, bindCallback(customizer, thisArg, 3)) : baseClone(value, true); + } + function gt(value, other) { + return value > other; + } + function gte(value, other) { + return value >= other; + } + function isArguments(value) { + return isObjectLike(value) && isArrayLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee"); + } + var isArray = nativeIsArray || function(value) { + return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag; + }; + function isBoolean(value) { + return value === true || value === false || isObjectLike(value) && objToString.call(value) == boolTag; + } + function isDate(value) { + return isObjectLike(value) && objToString.call(value) == dateTag; + } + function isElement(value) { + return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value); + } + function isEmpty(value) { + if (value == null) { + return true; + } + if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) || isObjectLike(value) && isFunction(value.splice))) { + return !value.length; + } + return !keys(value).length; + } + function isEqual(value, other, customizer, thisArg) { + customizer = typeof customizer == "function" ? bindCallback(customizer, thisArg, 3) : undefined; + var result = customizer ? customizer(value, other) : undefined; + return result === undefined ? baseIsEqual(value, other, customizer) : !!result; + } + function isError(value) { + return isObjectLike(value) && typeof value.message == "string" && objToString.call(value) == errorTag; + } + function isFinite(value) { + return typeof value == "number" && nativeIsFinite(value); + } + function isFunction(value) { + return isObject(value) && objToString.call(value) == funcTag; + } + function isObject(value) { + var type = typeof value; + return !!value && (type == "object" || type == "function"); + } + function isMatch(object, source, customizer, thisArg) { + customizer = typeof customizer == "function" ? bindCallback(customizer, thisArg, 3) : undefined; + return baseIsMatch(object, getMatchData(source), customizer); + } + function isNaN(value) { + return isNumber(value) && value != +value; + } + function isNative(value) { + if (value == null) { + return false; + } + if (isFunction(value)) { + return reIsNative.test(fnToString.call(value)); + } + return isObjectLike(value) && reIsHostCtor.test(value); + } + function isNull(value) { + return value === null; + } + function isNumber(value) { + return typeof value == "number" || isObjectLike(value) && objToString.call(value) == numberTag; + } + function isPlainObject(value) { + var Ctor; + if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) || !hasOwnProperty.call(value, "constructor") && (Ctor = value.constructor, + typeof Ctor == "function" && !(Ctor instanceof Ctor))) { + return false; + } + var result; + baseForIn(value, function(subValue, key) { + result = key; }); + return result === undefined || hasOwnProperty.call(value, result); + } + function isRegExp(value) { + return isObject(value) && objToString.call(value) == regexpTag; + } + function isString(value) { + return typeof value == "string" || isObjectLike(value) && objToString.call(value) == stringTag; + } + function isTypedArray(value) { + return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)]; + } + function isUndefined(value) { + return value === undefined; + } + function lt(value, other) { + return value < other; + } + function lte(value, other) { + return value <= other; + } + function toArray(value) { + var length = value ? getLength(value) : 0; + if (!isLength(length)) { + return values(value); + } + if (!length) { + return []; + } + return arrayCopy(value); + } + function toPlainObject(value) { + return baseCopy(value, keysIn(value)); + } + var merge = createAssigner(baseMerge); + var assign = createAssigner(function(object, source, customizer) { + return customizer ? assignWith(object, source, customizer) : baseAssign(object, source); + }); + function create(prototype, properties, guard) { + var result = baseCreate(prototype); + if (guard && isIterateeCall(prototype, properties, guard)) { + properties = undefined; + } + return properties ? baseAssign(result, properties) : result; + } + var defaults = createDefaults(assign, assignDefaults); + var defaultsDeep = createDefaults(merge, mergeDefaults); + var findKey = createFindKey(baseForOwn); + var findLastKey = createFindKey(baseForOwnRight); + var forIn = createForIn(baseFor); + var forInRight = createForIn(baseForRight); + var forOwn = createForOwn(baseForOwn); + var forOwnRight = createForOwn(baseForOwnRight); + function functions(object) { + return baseFunctions(object, keysIn(object)); + } + function get(object, path, defaultValue) { + var result = object == null ? undefined : baseGet(object, toPath(path), path + ""); + return result === undefined ? defaultValue : result; + } + function has(object, path) { + if (object == null) { + return false; + } + var result = hasOwnProperty.call(object, path); + if (!result && !isKey(path)) { + path = toPath(path); + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + if (object == null) { + return false; + } + path = last(path); + result = hasOwnProperty.call(object, path); + } + return result || isLength(object.length) && isIndex(path, object.length) && (isArray(object) || isArguments(object)); + } + function invert(object, multiValue, guard) { + if (guard && isIterateeCall(object, multiValue, guard)) { + multiValue = undefined; + } + var index = -1, props = keys(object), length = props.length, result = {}; + while (++index < length) { + var key = props[index], value = object[key]; + if (multiValue) { + if (hasOwnProperty.call(result, value)) { + result[value].push(key); + } else { + result[value] = [ key ]; + } + } else { + result[value] = key; + } + } return result; + } + var keys = !nativeKeys ? shimKeys : function(object) { + var Ctor = object == null ? undefined : object.constructor; + if (typeof Ctor == "function" && Ctor.prototype === object || typeof object != "function" && isArrayLike(object)) { + return shimKeys(object); + } + return isObject(object) ? nativeKeys(object) : []; }; - }; - _.groupBy = group(function(result, value, key) { - if (_.has(result, key)) result[key].push(value); else result[key] = [ value ]; - }); - _.indexBy = group(function(result, value, key) { - result[key] = value; - }); - _.countBy = group(function(result, value, key) { - if (_.has(result, key)) result[key]++; else result[key] = 1; - }); - _.toArray = function(obj) { - if (!obj) return []; - if (_.isArray(obj)) return slice.call(obj); - if (isArrayLike(obj)) return _.map(obj, _.identity); - return _.values(obj); - }; - _.size = function(obj) { - if (obj == null) return 0; - return isArrayLike(obj) ? obj.length : _.keys(obj).length; - }; - _.partition = function(obj, predicate, context) { - predicate = cb(predicate, context); - var pass = [], fail = []; - _.each(obj, function(value, key, obj) { - (predicate(value, key, obj) ? pass : fail).push(value); + function keysIn(object) { + if (object == null) { + return []; + } + if (!isObject(object)) { + object = Object(object); + } + var length = object.length; + length = length && isLength(length) && (isArray(object) || isArguments(object)) && length || 0; + var Ctor = object.constructor, index = -1, isProto = typeof Ctor == "function" && Ctor.prototype === object, result = Array(length), skipIndexes = length > 0; + while (++index < length) { + result[index] = index + ""; + } + for (var key in object) { + if (!(skipIndexes && isIndex(key, length)) && !(key == "constructor" && (isProto || !hasOwnProperty.call(object, key)))) { + result.push(key); + } + } + return result; + } + var mapKeys = createObjectMapper(true); + var mapValues = createObjectMapper(); + var omit = restParam(function(object, props) { + if (object == null) { + return {}; + } + if (typeof props[0] != "function") { + var props = arrayMap(baseFlatten(props), String); + return pickByArray(object, baseDifference(keysIn(object), props)); + } + var predicate = bindCallback(props[0], props[1], 3); + return pickByCallback(object, function(value, key, object) { + return !predicate(value, key, object); + }); }); - return [ pass, fail ]; - }; - _.first = _.head = _.take = function(array, n, guard) { - if (array == null) return void 0; - if (n == null || guard) return array[0]; - return _.initial(array, array.length - n); - }; - _.initial = function(array, n, guard) { - return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); - }; - _.last = function(array, n, guard) { - if (array == null) return void 0; - if (n == null || guard) return array[array.length - 1]; - return _.rest(array, Math.max(0, array.length - n)); - }; - _.rest = _.tail = _.drop = function(array, n, guard) { - return slice.call(array, n == null || guard ? 1 : n); - }; - _.compact = function(array) { - return _.filter(array, _.identity); - }; - var flatten = function(input, shallow, strict, startIndex) { - var output = [], idx = 0; - for (var i = startIndex || 0, length = getLength(input); i < length; i++) { - var value = input[i]; - if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) { - if (!shallow) value = flatten(value, shallow, strict); - var j = 0, len = value.length; - output.length += len; - while (j < len) { - output[idx++] = value[j++]; + function pairs(object) { + object = toObject(object); + var index = -1, props = keys(object), length = props.length, result = Array(length); + while (++index < length) { + var key = props[index]; + result[index] = [ key, object[key] ]; + } + return result; + } + var pick = restParam(function(object, props) { + if (object == null) { + return {}; + } + return typeof props[0] == "function" ? pickByCallback(object, bindCallback(props[0], props[1], 3)) : pickByArray(object, baseFlatten(props)); + }); + function result(object, path, defaultValue) { + var result = object == null ? undefined : object[path]; + if (result === undefined) { + if (object != null && !isKey(path, object)) { + path = toPath(path); + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + result = object == null ? undefined : object[last(path)]; + } + result = result === undefined ? defaultValue : result; + } + return isFunction(result) ? result.call(object) : result; + } + function set(object, path, value) { + if (object == null) { + return object; + } + var pathKey = path + ""; + path = object[pathKey] != null || isKey(path, object) ? [ pathKey ] : toPath(path); + var index = -1, length = path.length, lastIndex = length - 1, nested = object; + while (nested != null && ++index < length) { + var key = path[index]; + if (isObject(nested)) { + if (index == lastIndex) { + nested[key] = value; + } else if (nested[key] == null) { + nested[key] = isIndex(path[index + 1]) ? [] : {}; + } + } + nested = nested[key]; + } + return object; + } + function transform(object, iteratee, accumulator, thisArg) { + var isArr = isArray(object) || isTypedArray(object); + iteratee = getCallback(iteratee, thisArg, 4); + if (accumulator == null) { + if (isArr || isObject(object)) { + var Ctor = object.constructor; + if (isArr) { + accumulator = isArray(object) ? new Ctor() : []; + } else { + accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined); + } + } else { + accumulator = {}; } - } else if (!strict) { - output[idx++] = value; } + (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) { + return iteratee(accumulator, value, index, object); + }); + return accumulator; } - return output; - }; - _.flatten = function(array, shallow) { - return flatten(array, shallow, false); - }; - _.without = function(array) { - return _.difference(array, slice.call(arguments, 1)); - }; - _.uniq = _.unique = function(array, isSorted, iteratee, context) { - if (!_.isBoolean(isSorted)) { - context = iteratee; - iteratee = isSorted; - isSorted = false; + function values(object) { + return baseValues(object, keys(object)); } - if (iteratee != null) iteratee = cb(iteratee, context); - var result = []; - var seen = []; - for (var i = 0, length = getLength(array); i < length; i++) { - var value = array[i], computed = iteratee ? iteratee(value, i, array) : value; - if (isSorted) { - if (!i || seen !== computed) result.push(value); - seen = computed; - } else if (iteratee) { - if (!_.contains(seen, computed)) { - seen.push(computed); - result.push(value); + function valuesIn(object) { + return baseValues(object, keysIn(object)); + } + function inRange(value, start, end) { + start = +start || 0; + if (end === undefined) { + end = start; + start = 0; + } else { + end = +end || 0; + } + return value >= nativeMin(start, end) && value < nativeMax(start, end); + } + function random(min, max, floating) { + if (floating && isIterateeCall(min, max, floating)) { + max = floating = undefined; + } + var noMin = min == null, noMax = max == null; + if (floating == null) { + if (noMax && typeof min == "boolean") { + floating = min; + min = 1; + } else if (typeof max == "boolean") { + floating = max; + noMax = true; } - } else if (!_.contains(result, value)) { - result.push(value); } - } - return result; - }; - _.union = function() { - return _.uniq(flatten(arguments, true, true)); - }; - _.intersection = function(array) { - var result = []; - var argsLength = arguments.length; - for (var i = 0, length = getLength(array); i < length; i++) { - var item = array[i]; - if (_.contains(result, item)) continue; - for (var j = 1; j < argsLength; j++) { - if (!_.contains(arguments[j], item)) break; + if (noMin && noMax) { + max = 1; + noMax = false; + } + min = +min || 0; + if (noMax) { + max = min; + min = 0; + } else { + max = +max || 0; + } + if (floating || min % 1 || max % 1) { + var rand = nativeRandom(); + return nativeMin(min + rand * (max - min + parseFloat("1e-" + ((rand + "").length - 1))), max); } - if (j === argsLength) result.push(item); + return baseRandom(min, max); } - return result; - }; - _.difference = function(array) { - var rest = flatten(arguments, true, true, 1); - return _.filter(array, function(value) { - return !_.contains(rest, value); + var camelCase = createCompounder(function(result, word, index) { + word = word.toLowerCase(); + return result + (index ? word.charAt(0).toUpperCase() + word.slice(1) : word); }); - }; - _.zip = function() { - return _.unzip(arguments); - }; - _.unzip = function(array) { - var length = array && _.max(array, getLength).length || 0; - var result = Array(length); - for (var index = 0; index < length; index++) { - result[index] = _.pluck(array, index); + function capitalize(string) { + string = baseToString(string); + return string && string.charAt(0).toUpperCase() + string.slice(1); + } + function deburr(string) { + string = baseToString(string); + return string && string.replace(reLatin1, deburrLetter).replace(reComboMark, ""); + } + function endsWith(string, target, position) { + string = baseToString(string); + target = target + ""; + var length = string.length; + position = position === undefined ? length : nativeMin(position < 0 ? 0 : +position || 0, length); + position -= target.length; + return position >= 0 && string.indexOf(target, position) == position; + } + function escape(string) { + string = baseToString(string); + return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, escapeHtmlChar) : string; + } + function escapeRegExp(string) { + string = baseToString(string); + return string && reHasRegExpChars.test(string) ? string.replace(reRegExpChars, escapeRegExpChar) : string || "(?:)"; + } + var kebabCase = createCompounder(function(result, word, index) { + return result + (index ? "-" : "") + word.toLowerCase(); + }); + function pad(string, length, chars) { + string = baseToString(string); + length = +length; + var strLength = string.length; + if (strLength >= length || !nativeIsFinite(length)) { + return string; + } + var mid = (length - strLength) / 2, leftLength = nativeFloor(mid), rightLength = nativeCeil(mid); + chars = createPadding("", rightLength, chars); + return chars.slice(0, leftLength) + string + chars; + } + var padLeft = createPadDir(); + var padRight = createPadDir(true); + function parseInt(string, radix, guard) { + if (guard ? isIterateeCall(string, radix, guard) : radix == null) { + radix = 0; + } else if (radix) { + radix = +radix; + } + string = trim(string); + return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10)); + } + function repeat(string, n) { + var result = ""; + string = baseToString(string); + n = +n; + if (n < 1 || !string || !nativeIsFinite(n)) { + return result; + } + do { + if (n % 2) { + result += string; + } + n = nativeFloor(n / 2); + string += string; + } while (n); + return result; } - return result; - }; - _.object = function(list, values) { - var result = {}; - for (var i = 0, length = getLength(list); i < length; i++) { - if (values) { - result[list[i]] = values[i]; - } else { - result[list[i][0]] = list[i][1]; + var snakeCase = createCompounder(function(result, word, index) { + return result + (index ? "_" : "") + word.toLowerCase(); + }); + var startCase = createCompounder(function(result, word, index) { + return result + (index ? " " : "") + (word.charAt(0).toUpperCase() + word.slice(1)); + }); + function startsWith(string, target, position) { + string = baseToString(string); + position = position == null ? 0 : nativeMin(position < 0 ? 0 : +position || 0, string.length); + return string.lastIndexOf(target, position) == position; + } + function template(string, options, otherOptions) { + var settings = lodash.templateSettings; + if (otherOptions && isIterateeCall(string, options, otherOptions)) { + options = otherOptions = undefined; + } + string = baseToString(string); + options = assignWith(baseAssign({}, otherOptions || options), settings, assignOwnDefaults); + var imports = assignWith(baseAssign({}, options.imports), settings.imports, assignOwnDefaults), importsKeys = keys(imports), importsValues = baseValues(imports, importsKeys); + var isEscaping, isEvaluating, index = 0, interpolate = options.interpolate || reNoMatch, source = "__p += '"; + var reDelimiters = RegExp((options.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options.evaluate || reNoMatch).source + "|$", "g"); + var sourceURL = "//# sourceURL=" + ("sourceURL" in options ? options.sourceURL : "lodash.templateSources[" + ++templateCounter + "]") + "\n"; + string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { + interpolateValue || (interpolateValue = esTemplateValue); + source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); + if (escapeValue) { + isEscaping = true; + source += "' +\n__e(" + escapeValue + ") +\n'"; + } + if (evaluateValue) { + isEvaluating = true; + source += "';\n" + evaluateValue + ";\n__p += '"; + } + if (interpolateValue) { + source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; + } + index = offset + match.length; + return match; + }); + source += "';\n"; + var variable = options.variable; + if (!variable) { + source = "with (obj) {\n" + source + "\n}\n"; + } + source = (isEvaluating ? source.replace(reEmptyStringLeading, "") : source).replace(reEmptyStringMiddle, "$1").replace(reEmptyStringTrailing, "$1;"); + source = "function(" + (variable || "obj") + ") {\n" + (variable ? "" : "obj || (obj = {});\n") + "var __t, __p = ''" + (isEscaping ? ", __e = _.escape" : "") + (isEvaluating ? ", __j = Array.prototype.join;\n" + "function print() { __p += __j.call(arguments, '') }\n" : ";\n") + source + "return __p\n}"; + var result = attempt(function() { + return Function(importsKeys, sourceURL + "return " + source).apply(undefined, importsValues); + }); + result.source = source; + if (isError(result)) { + throw result; } + return result; } - return result; - }; - function createPredicateIndexFinder(dir) { - return function(array, predicate, context) { - predicate = cb(predicate, context); - var length = getLength(array); - var index = dir > 0 ? 0 : length - 1; - for (;index >= 0 && index < length; index += dir) { - if (predicate(array[index], index, array)) return index; + function trim(string, chars, guard) { + var value = string; + string = baseToString(string); + if (!string) { + return string; } - return -1; - }; - } - _.findIndex = createPredicateIndexFinder(1); - _.findLastIndex = createPredicateIndexFinder(-1); - _.sortedIndex = function(array, obj, iteratee, context) { - iteratee = cb(iteratee, context, 1); - var value = iteratee(obj); - var low = 0, high = getLength(array); - while (low < high) { - var mid = Math.floor((low + high) / 2); - if (iteratee(array[mid]) < value) low = mid + 1; else high = mid; - } - return low; - }; - function createIndexFinder(dir, predicateFind, sortedIndex) { - return function(array, item, idx) { - var i = 0, length = getLength(array); - if (typeof idx == "number") { - if (dir > 0) { - i = idx >= 0 ? idx : Math.max(idx + length, i); - } else { - length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; - } - } else if (sortedIndex && idx && length) { - idx = sortedIndex(array, item); - return array[idx] === item ? idx : -1; + if (guard ? isIterateeCall(value, chars, guard) : chars == null) { + return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1); } - if (item !== item) { - idx = predicateFind(slice.call(array, i, length), _.isNaN); - return idx >= 0 ? idx + i : -1; + chars = chars + ""; + return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1); + } + function trimLeft(string, chars, guard) { + var value = string; + string = baseToString(string); + if (!string) { + return string; } - for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) { - if (array[idx] === item) return idx; + if (guard ? isIterateeCall(value, chars, guard) : chars == null) { + return string.slice(trimmedLeftIndex(string)); } - return -1; - }; - } - _.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex); - _.lastIndexOf = createIndexFinder(-1, _.findLastIndex); - _.range = function(start, stop, step) { - if (stop == null) { - stop = start || 0; - start = 0; + return string.slice(charsLeftIndex(string, chars + "")); } - step = step || 1; - var length = Math.max(Math.ceil((stop - start) / step), 0); - var range = Array(length); - for (var idx = 0; idx < length; idx++, start += step) { - range[idx] = start; - } - return range; - }; - var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) { - if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); - var self = baseCreate(sourceFunc.prototype); - var result = sourceFunc.apply(self, args); - if (_.isObject(result)) return result; - return self; - }; - _.bind = function(func, context) { - if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); - if (!_.isFunction(func)) throw new TypeError("Bind must be called on a function"); - var args = slice.call(arguments, 2); - var bound = function() { - return executeBound(func, bound, context, this, args.concat(slice.call(arguments))); - }; - return bound; - }; - _.partial = function(func) { - var boundArgs = slice.call(arguments, 1); - var bound = function() { - var position = 0, length = boundArgs.length; - var args = Array(length); - for (var i = 0; i < length; i++) { - args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i]; + function trimRight(string, chars, guard) { + var value = string; + string = baseToString(string); + if (!string) { + return string; } - while (position < arguments.length) args.push(arguments[position++]); - return executeBound(func, bound, this, this, args); - }; - return bound; - }; - _.bindAll = function(obj) { - var i, length = arguments.length, key; - if (length <= 1) throw new Error("bindAll must be passed function names"); - for (i = 1; i < length; i++) { - key = arguments[i]; - obj[key] = _.bind(obj[key], obj); + if (guard ? isIterateeCall(value, chars, guard) : chars == null) { + return string.slice(0, trimmedRightIndex(string) + 1); + } + return string.slice(0, charsRightIndex(string, chars + "") + 1); } - return obj; - }; - _.memoize = function(func, hasher) { - var memoize = function(key) { - var cache = memoize.cache; - var address = "" + (hasher ? hasher.apply(this, arguments) : key); - if (!_.has(cache, address)) cache[address] = func.apply(this, arguments); - return cache[address]; - }; - memoize.cache = {}; - return memoize; - }; - _.delay = function(func, wait) { - var args = slice.call(arguments, 2); - return setTimeout(function() { - return func.apply(null, args); - }, wait); - }; - _.defer = _.partial(_.delay, _, 1); - _.throttle = function(func, wait, options) { - var context, args, result; - var timeout = null; - var previous = 0; - if (!options) options = {}; - var later = function() { - previous = options.leading === false ? 0 : _.now(); - timeout = null; - result = func.apply(context, args); - if (!timeout) context = args = null; - }; - return function() { - var now = _.now(); - if (!previous && options.leading === false) previous = now; - var remaining = wait - (now - previous); - context = this; - args = arguments; - if (remaining <= 0 || remaining > wait) { - if (timeout) { - clearTimeout(timeout); - timeout = null; - } - previous = now; - result = func.apply(context, args); - if (!timeout) context = args = null; - } else if (!timeout && options.trailing !== false) { - timeout = setTimeout(later, remaining); + function trunc(string, options, guard) { + if (guard && isIterateeCall(string, options, guard)) { + options = undefined; } - return result; - }; - }; - _.debounce = function(func, wait, immediate) { - var timeout, args, context, timestamp, result; - var later = function() { - var last = _.now() - timestamp; - if (last < wait && last >= 0) { - timeout = setTimeout(later, wait - last); - } else { - timeout = null; - if (!immediate) { - result = func.apply(context, args); - if (!timeout) context = args = null; + var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION; + if (options != null) { + if (isObject(options)) { + var separator = "separator" in options ? options.separator : separator; + length = "length" in options ? +options.length || 0 : length; + omission = "omission" in options ? baseToString(options.omission) : omission; + } else { + length = +options || 0; } } - }; - return function() { - context = this; - args = arguments; - timestamp = _.now(); - var callNow = immediate && !timeout; - if (!timeout) timeout = setTimeout(later, wait); - if (callNow) { - result = func.apply(context, args); - context = args = null; + string = baseToString(string); + if (length >= string.length) { + return string; } - return result; - }; - }; - _.wrap = function(func, wrapper) { - return _.partial(wrapper, func); - }; - _.negate = function(predicate) { - return function() { - return !predicate.apply(this, arguments); - }; - }; - _.compose = function() { - var args = arguments; - var start = args.length - 1; - return function() { - var i = start; - var result = args[start].apply(this, arguments); - while (i--) result = args[i].call(this, result); - return result; - }; - }; - _.after = function(times, func) { - return function() { - if (--times < 1) { - return func.apply(this, arguments); + var end = length - omission.length; + if (end < 1) { + return omission; } - }; - }; - _.before = function(times, func) { - var memo; - return function() { - if (--times > 0) { - memo = func.apply(this, arguments); - } - if (times <= 1) func = null; - return memo; - }; - }; - _.once = _.partial(_.before, 2); - var hasEnumBug = !{ - toString: null - }.propertyIsEnumerable("toString"); - var nonEnumerableProps = [ "valueOf", "isPrototypeOf", "toString", "propertyIsEnumerable", "hasOwnProperty", "toLocaleString" ]; - function collectNonEnumProps(obj, keys) { - var nonEnumIdx = nonEnumerableProps.length; - var constructor = obj.constructor; - var proto = _.isFunction(constructor) && constructor.prototype || ObjProto; - var prop = "constructor"; - if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop); - while (nonEnumIdx--) { - prop = nonEnumerableProps[nonEnumIdx]; - if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) { - keys.push(prop); - } - } - } - _.keys = function(obj) { - if (!_.isObject(obj)) return []; - if (nativeKeys) return nativeKeys(obj); - var keys = []; - for (var key in obj) if (_.has(obj, key)) keys.push(key); - if (hasEnumBug) collectNonEnumProps(obj, keys); - return keys; - }; - _.allKeys = function(obj) { - if (!_.isObject(obj)) return []; - var keys = []; - for (var key in obj) keys.push(key); - if (hasEnumBug) collectNonEnumProps(obj, keys); - return keys; - }; - _.values = function(obj) { - var keys = _.keys(obj); - var length = keys.length; - var values = Array(length); - for (var i = 0; i < length; i++) { - values[i] = obj[keys[i]]; + var result = string.slice(0, end); + if (separator == null) { + return result + omission; + } + if (isRegExp(separator)) { + if (string.slice(end).search(separator)) { + var match, newEnd, substring = string.slice(0, end); + if (!separator.global) { + separator = RegExp(separator.source, (reFlags.exec(separator) || "") + "g"); + } + separator.lastIndex = 0; + while (match = separator.exec(substring)) { + newEnd = match.index; + } + result = result.slice(0, newEnd == null ? end : newEnd); + } + } else if (string.indexOf(separator, end) != end) { + var index = result.lastIndexOf(separator); + if (index > -1) { + result = result.slice(0, index); + } + } + return result + omission; } - return values; - }; - _.mapObject = function(obj, iteratee, context) { - iteratee = cb(iteratee, context); - var keys = _.keys(obj), length = keys.length, results = {}, currentKey; - for (var index = 0; index < length; index++) { - currentKey = keys[index]; - results[currentKey] = iteratee(obj[currentKey], currentKey, obj); + function unescape(string) { + string = baseToString(string); + return string && reHasEscapedHtml.test(string) ? string.replace(reEscapedHtml, unescapeHtmlChar) : string; } - return results; - }; - _.pairs = function(obj) { - var keys = _.keys(obj); - var length = keys.length; - var pairs = Array(length); - for (var i = 0; i < length; i++) { - pairs[i] = [ keys[i], obj[keys[i]] ]; + function words(string, pattern, guard) { + if (guard && isIterateeCall(string, pattern, guard)) { + pattern = undefined; + } + string = baseToString(string); + return string.match(pattern || reWords) || []; } - return pairs; - }; - _.invert = function(obj) { - var result = {}; - var keys = _.keys(obj); - for (var i = 0, length = keys.length; i < length; i++) { - result[obj[keys[i]]] = keys[i]; + var attempt = restParam(function(func, args) { + try { + return func.apply(undefined, args); + } catch (e) { + return isError(e) ? e : new Error(e); + } + }); + function callback(func, thisArg, guard) { + if (guard && isIterateeCall(func, thisArg, guard)) { + thisArg = undefined; + } + return isObjectLike(func) ? matches(func) : baseCallback(func, thisArg); } - return result; - }; - _.functions = _.methods = function(obj) { - var names = []; - for (var key in obj) { - if (_.isFunction(obj[key])) names.push(key); + function constant(value) { + return function() { + return value; + }; } - return names.sort(); - }; - _.extend = createAssigner(_.allKeys); - _.extendOwn = _.assign = createAssigner(_.keys); - _.findKey = function(obj, predicate, context) { - predicate = cb(predicate, context); - var keys = _.keys(obj), key; - for (var i = 0, length = keys.length; i < length; i++) { - key = keys[i]; - if (predicate(obj[key], key, obj)) return key; + function identity(value) { + return value; } - }; - _.pick = function(object, oiteratee, context) { - var result = {}, obj = object, iteratee, keys; - if (obj == null) return result; - if (_.isFunction(oiteratee)) { - keys = _.allKeys(obj); - iteratee = optimizeCb(oiteratee, context); - } else { - keys = flatten(arguments, false, false, 1); - iteratee = function(value, key, obj) { - return key in obj; - }; - obj = Object(obj); + function matches(source) { + return baseMatches(baseClone(source, true)); } - for (var i = 0, length = keys.length; i < length; i++) { - var key = keys[i]; - var value = obj[key]; - if (iteratee(value, key, obj)) result[key] = value; + function matchesProperty(path, srcValue) { + return baseMatchesProperty(path, baseClone(srcValue, true)); } - return result; - }; - _.omit = function(obj, iteratee, context) { - if (_.isFunction(iteratee)) { - iteratee = _.negate(iteratee); - } else { - var keys = _.map(flatten(arguments, false, false, 1), String); - iteratee = function(value, key) { - return !_.contains(keys, key); + var method = restParam(function(path, args) { + return function(object) { + return invokePath(object, path, args); }; + }); + var methodOf = restParam(function(object, args) { + return function(path) { + return invokePath(object, path, args); + }; + }); + function mixin(object, source, options) { + if (options == null) { + var isObj = isObject(source), props = isObj ? keys(source) : undefined, methodNames = props && props.length ? baseFunctions(source, props) : undefined; + if (!(methodNames ? methodNames.length : isObj)) { + methodNames = false; + options = source; + source = object; + object = this; + } + } + if (!methodNames) { + methodNames = baseFunctions(source, keys(source)); + } + var chain = true, index = -1, isFunc = isFunction(object), length = methodNames.length; + if (options === false) { + chain = false; + } else if (isObject(options) && "chain" in options) { + chain = options.chain; + } + while (++index < length) { + var methodName = methodNames[index], func = source[methodName]; + object[methodName] = func; + if (isFunc) { + object.prototype[methodName] = function(func) { + return function() { + var chainAll = this.__chain__; + if (chain || chainAll) { + var result = object(this.__wrapped__), actions = result.__actions__ = arrayCopy(this.__actions__); + actions.push({ + func: func, + args: arguments, + thisArg: object + }); + result.__chain__ = chainAll; + return result; + } + return func.apply(object, arrayPush([ this.value() ], arguments)); + }; + }(func); + } + } + return object; } - return _.pick(obj, iteratee, context); - }; - _.defaults = createAssigner(_.allKeys, true); - _.create = function(prototype, props) { - var result = baseCreate(prototype); - if (props) _.extendOwn(result, props); - return result; - }; - _.clone = function(obj) { - if (!_.isObject(obj)) return obj; - return _.isArray(obj) ? obj.slice() : _.extend({}, obj); - }; - _.tap = function(obj, interceptor) { - interceptor(obj); - return obj; - }; - _.isMatch = function(object, attrs) { - var keys = _.keys(attrs), length = keys.length; - if (object == null) return !length; - var obj = Object(object); - for (var i = 0; i < length; i++) { - var key = keys[i]; - if (attrs[key] !== obj[key] || !(key in obj)) return false; + function noConflict() { + root._ = oldDash; + return this; } - return true; - }; - var eq = function(a, b, aStack, bStack) { - if (a === b) return a !== 0 || 1 / a === 1 / b; - if (a == null || b == null) return a === b; - if (a instanceof _) a = a._wrapped; - if (b instanceof _) b = b._wrapped; - var className = toString.call(a); - if (className !== toString.call(b)) return false; - switch (className) { - case "[object RegExp]": - case "[object String]": - return "" + a === "" + b; - - case "[object Number]": - if (+a !== +a) return +b !== +b; - return +a === 0 ? 1 / +a === 1 / b : +a === +b; - - case "[object Date]": - case "[object Boolean]": - return +a === +b; - } - var areArrays = className === "[object Array]"; - if (!areArrays) { - if (typeof a != "object" || typeof b != "object") return false; - var aCtor = a.constructor, bCtor = b.constructor; - if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor && _.isFunction(bCtor) && bCtor instanceof bCtor) && ("constructor" in a && "constructor" in b)) { - return false; - } + function noop() {} + function property(path) { + return isKey(path) ? baseProperty(path) : basePropertyDeep(path); } - aStack = aStack || []; - bStack = bStack || []; - var length = aStack.length; - while (length--) { - if (aStack[length] === a) return bStack[length] === b; + function propertyOf(object) { + return function(path) { + return baseGet(object, toPath(path), path + ""); + }; } - aStack.push(a); - bStack.push(b); - if (areArrays) { - length = a.length; - if (length !== b.length) return false; - while (length--) { - if (!eq(a[length], b[length], aStack, bStack)) return false; + function range(start, end, step) { + if (step && isIterateeCall(start, end, step)) { + end = step = undefined; } - } else { - var keys = _.keys(a), key; - length = keys.length; - if (_.keys(b).length !== length) return false; - while (length--) { - key = keys[length]; - if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false; + start = +start || 0; + step = step == null ? 1 : +step || 0; + if (end == null) { + end = start; + start = 0; + } else { + end = +end || 0; + } + var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result = Array(length); + while (++index < length) { + result[index] = start; + start += step; } + return result; } - aStack.pop(); - bStack.pop(); - return true; - }; - _.isEqual = function(a, b) { - return eq(a, b); - }; - _.isEmpty = function(obj) { - if (obj == null) return true; - if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0; - return _.keys(obj).length === 0; - }; - _.isElement = function(obj) { - return !!(obj && obj.nodeType === 1); - }; - _.isArray = nativeIsArray || function(obj) { - return toString.call(obj) === "[object Array]"; - }; - _.isObject = function(obj) { - var type = typeof obj; - return type === "function" || type === "object" && !!obj; - }; - _.each([ "Arguments", "Function", "String", "Number", "Date", "RegExp", "Error" ], function(name) { - _["is" + name] = function(obj) { - return toString.call(obj) === "[object " + name + "]"; - }; - }); - if (!_.isArguments(arguments)) { - _.isArguments = function(obj) { - return _.has(obj, "callee"); + function times(n, iteratee, thisArg) { + n = nativeFloor(n); + if (n < 1 || !nativeIsFinite(n)) { + return []; + } + var index = -1, result = Array(nativeMin(n, MAX_ARRAY_LENGTH)); + iteratee = bindCallback(iteratee, thisArg, 1); + while (++index < n) { + if (index < MAX_ARRAY_LENGTH) { + result[index] = iteratee(index); + } else { + iteratee(index); + } + } + return result; + } + function uniqueId(prefix) { + var id = ++idCounter; + return baseToString(prefix) + id; + } + function add(augend, addend) { + return (+augend || 0) + (+addend || 0); + } + var ceil = createRound("ceil"); + var floor = createRound("floor"); + var max = createExtremum(gt, NEGATIVE_INFINITY); + var min = createExtremum(lt, POSITIVE_INFINITY); + var round = createRound("round"); + function sum(collection, iteratee, thisArg) { + if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { + iteratee = undefined; + } + iteratee = getCallback(iteratee, thisArg, 3); + return iteratee.length == 1 ? arraySum(isArray(collection) ? collection : toIterable(collection), iteratee) : baseSum(collection, iteratee); + } + lodash.prototype = baseLodash.prototype; + LodashWrapper.prototype = baseCreate(baseLodash.prototype); + LodashWrapper.prototype.constructor = LodashWrapper; + LazyWrapper.prototype = baseCreate(baseLodash.prototype); + LazyWrapper.prototype.constructor = LazyWrapper; + MapCache.prototype["delete"] = mapDelete; + MapCache.prototype.get = mapGet; + MapCache.prototype.has = mapHas; + MapCache.prototype.set = mapSet; + SetCache.prototype.push = cachePush; + memoize.Cache = MapCache; + lodash.after = after; + lodash.ary = ary; + lodash.assign = assign; + lodash.at = at; + lodash.before = before; + lodash.bind = bind; + lodash.bindAll = bindAll; + lodash.bindKey = bindKey; + lodash.callback = callback; + lodash.chain = chain; + lodash.chunk = chunk; + lodash.compact = compact; + lodash.constant = constant; + lodash.countBy = countBy; + lodash.create = create; + lodash.curry = curry; + lodash.curryRight = curryRight; + lodash.debounce = debounce; + lodash.defaults = defaults; + lodash.defaultsDeep = defaultsDeep; + lodash.defer = defer; + lodash.delay = delay; + lodash.difference = difference; + lodash.drop = drop; + lodash.dropRight = dropRight; + lodash.dropRightWhile = dropRightWhile; + lodash.dropWhile = dropWhile; + lodash.fill = fill; + lodash.filter = filter; + lodash.flatten = flatten; + lodash.flattenDeep = flattenDeep; + lodash.flow = flow; + lodash.flowRight = flowRight; + lodash.forEach = forEach; + lodash.forEachRight = forEachRight; + lodash.forIn = forIn; + lodash.forInRight = forInRight; + lodash.forOwn = forOwn; + lodash.forOwnRight = forOwnRight; + lodash.functions = functions; + lodash.groupBy = groupBy; + lodash.indexBy = indexBy; + lodash.initial = initial; + lodash.intersection = intersection; + lodash.invert = invert; + lodash.invoke = invoke; + lodash.keys = keys; + lodash.keysIn = keysIn; + lodash.map = map; + lodash.mapKeys = mapKeys; + lodash.mapValues = mapValues; + lodash.matches = matches; + lodash.matchesProperty = matchesProperty; + lodash.memoize = memoize; + lodash.merge = merge; + lodash.method = method; + lodash.methodOf = methodOf; + lodash.mixin = mixin; + lodash.modArgs = modArgs; + lodash.negate = negate; + lodash.omit = omit; + lodash.once = once; + lodash.pairs = pairs; + lodash.partial = partial; + lodash.partialRight = partialRight; + lodash.partition = partition; + lodash.pick = pick; + lodash.pluck = pluck; + lodash.property = property; + lodash.propertyOf = propertyOf; + lodash.pull = pull; + lodash.pullAt = pullAt; + lodash.range = range; + lodash.rearg = rearg; + lodash.reject = reject; + lodash.remove = remove; + lodash.rest = rest; + lodash.restParam = restParam; + lodash.set = set; + lodash.shuffle = shuffle; + lodash.slice = slice; + lodash.sortBy = sortBy; + lodash.sortByAll = sortByAll; + lodash.sortByOrder = sortByOrder; + lodash.spread = spread; + lodash.take = take; + lodash.takeRight = takeRight; + lodash.takeRightWhile = takeRightWhile; + lodash.takeWhile = takeWhile; + lodash.tap = tap; + lodash.throttle = throttle; + lodash.thru = thru; + lodash.times = times; + lodash.toArray = toArray; + lodash.toPlainObject = toPlainObject; + lodash.transform = transform; + lodash.union = union; + lodash.uniq = uniq; + lodash.unzip = unzip; + lodash.unzipWith = unzipWith; + lodash.values = values; + lodash.valuesIn = valuesIn; + lodash.where = where; + lodash.without = without; + lodash.wrap = wrap; + lodash.xor = xor; + lodash.zip = zip; + lodash.zipObject = zipObject; + lodash.zipWith = zipWith; + lodash.backflow = flowRight; + lodash.collect = map; + lodash.compose = flowRight; + lodash.each = forEach; + lodash.eachRight = forEachRight; + lodash.extend = assign; + lodash.iteratee = callback; + lodash.methods = functions; + lodash.object = zipObject; + lodash.select = filter; + lodash.tail = rest; + lodash.unique = uniq; + mixin(lodash, lodash); + lodash.add = add; + lodash.attempt = attempt; + lodash.camelCase = camelCase; + lodash.capitalize = capitalize; + lodash.ceil = ceil; + lodash.clone = clone; + lodash.cloneDeep = cloneDeep; + lodash.deburr = deburr; + lodash.endsWith = endsWith; + lodash.escape = escape; + lodash.escapeRegExp = escapeRegExp; + lodash.every = every; + lodash.find = find; + lodash.findIndex = findIndex; + lodash.findKey = findKey; + lodash.findLast = findLast; + lodash.findLastIndex = findLastIndex; + lodash.findLastKey = findLastKey; + lodash.findWhere = findWhere; + lodash.first = first; + lodash.floor = floor; + lodash.get = get; + lodash.gt = gt; + lodash.gte = gte; + lodash.has = has; + lodash.identity = identity; + lodash.includes = includes; + lodash.indexOf = indexOf; + lodash.inRange = inRange; + lodash.isArguments = isArguments; + lodash.isArray = isArray; + lodash.isBoolean = isBoolean; + lodash.isDate = isDate; + lodash.isElement = isElement; + lodash.isEmpty = isEmpty; + lodash.isEqual = isEqual; + lodash.isError = isError; + lodash.isFinite = isFinite; + lodash.isFunction = isFunction; + lodash.isMatch = isMatch; + lodash.isNaN = isNaN; + lodash.isNative = isNative; + lodash.isNull = isNull; + lodash.isNumber = isNumber; + lodash.isObject = isObject; + lodash.isPlainObject = isPlainObject; + lodash.isRegExp = isRegExp; + lodash.isString = isString; + lodash.isTypedArray = isTypedArray; + lodash.isUndefined = isUndefined; + lodash.kebabCase = kebabCase; + lodash.last = last; + lodash.lastIndexOf = lastIndexOf; + lodash.lt = lt; + lodash.lte = lte; + lodash.max = max; + lodash.min = min; + lodash.noConflict = noConflict; + lodash.noop = noop; + lodash.now = now; + lodash.pad = pad; + lodash.padLeft = padLeft; + lodash.padRight = padRight; + lodash.parseInt = parseInt; + lodash.random = random; + lodash.reduce = reduce; + lodash.reduceRight = reduceRight; + lodash.repeat = repeat; + lodash.result = result; + lodash.round = round; + lodash.runInContext = runInContext; + lodash.size = size; + lodash.snakeCase = snakeCase; + lodash.some = some; + lodash.sortedIndex = sortedIndex; + lodash.sortedLastIndex = sortedLastIndex; + lodash.startCase = startCase; + lodash.startsWith = startsWith; + lodash.sum = sum; + lodash.template = template; + lodash.trim = trim; + lodash.trimLeft = trimLeft; + lodash.trimRight = trimRight; + lodash.trunc = trunc; + lodash.unescape = unescape; + lodash.uniqueId = uniqueId; + lodash.words = words; + lodash.all = every; + lodash.any = some; + lodash.contains = includes; + lodash.eq = isEqual; + lodash.detect = find; + lodash.foldl = reduce; + lodash.foldr = reduceRight; + lodash.head = first; + lodash.include = includes; + lodash.inject = reduce; + mixin(lodash, function() { + var source = {}; + baseForOwn(lodash, function(func, methodName) { + if (!lodash.prototype[methodName]) { + source[methodName] = func; + } + }); + return source; + }(), false); + lodash.sample = sample; + lodash.prototype.sample = function(n) { + if (!this.__chain__ && n == null) { + return sample(this.value()); + } + return this.thru(function(value) { + return sample(value, n); + }); }; - } - if (typeof /./ != "function" && typeof Int8Array != "object") { - _.isFunction = function(obj) { - return typeof obj == "function" || false; + lodash.VERSION = VERSION; + arrayEach([ "bind", "bindKey", "curry", "curryRight", "partial", "partialRight" ], function(methodName) { + lodash[methodName].placeholder = lodash; + }); + arrayEach([ "drop", "take" ], function(methodName, index) { + LazyWrapper.prototype[methodName] = function(n) { + var filtered = this.__filtered__; + if (filtered && !index) { + return new LazyWrapper(this); + } + n = n == null ? 1 : nativeMax(nativeFloor(n) || 0, 0); + var result = this.clone(); + if (filtered) { + result.__takeCount__ = nativeMin(result.__takeCount__, n); + } else { + result.__views__.push({ + size: n, + type: methodName + (result.__dir__ < 0 ? "Right" : "") + }); + } + return result; + }; + LazyWrapper.prototype[methodName + "Right"] = function(n) { + return this.reverse()[methodName](n).reverse(); + }; + }); + arrayEach([ "filter", "map", "takeWhile" ], function(methodName, index) { + var type = index + 1, isFilter = type != LAZY_MAP_FLAG; + LazyWrapper.prototype[methodName] = function(iteratee, thisArg) { + var result = this.clone(); + result.__iteratees__.push({ + iteratee: getCallback(iteratee, thisArg, 1), + type: type + }); + result.__filtered__ = result.__filtered__ || isFilter; + return result; + }; + }); + arrayEach([ "first", "last" ], function(methodName, index) { + var takeName = "take" + (index ? "Right" : ""); + LazyWrapper.prototype[methodName] = function() { + return this[takeName](1).value()[0]; + }; + }); + arrayEach([ "initial", "rest" ], function(methodName, index) { + var dropName = "drop" + (index ? "" : "Right"); + LazyWrapper.prototype[methodName] = function() { + return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); + }; + }); + arrayEach([ "pluck", "where" ], function(methodName, index) { + var operationName = index ? "filter" : "map", createCallback = index ? baseMatches : property; + LazyWrapper.prototype[methodName] = function(value) { + return this[operationName](createCallback(value)); + }; + }); + LazyWrapper.prototype.compact = function() { + return this.filter(identity); }; - } - _.isFinite = function(obj) { - return isFinite(obj) && !isNaN(parseFloat(obj)); - }; - _.isNaN = function(obj) { - return _.isNumber(obj) && obj !== +obj; - }; - _.isBoolean = function(obj) { - return obj === true || obj === false || toString.call(obj) === "[object Boolean]"; - }; - _.isNull = function(obj) { - return obj === null; - }; - _.isUndefined = function(obj) { - return obj === void 0; - }; - _.has = function(obj, key) { - return obj != null && hasOwnProperty.call(obj, key); - }; - _.noConflict = function() { - root._ = previousUnderscore; - return this; - }; - _.identity = function(value) { - return value; - }; - _.constant = function(value) { - return function() { - return value; + LazyWrapper.prototype.reject = function(predicate, thisArg) { + predicate = getCallback(predicate, thisArg, 1); + return this.filter(function(value) { + return !predicate(value); + }); }; - }; - _.noop = function() {}; - _.property = property; - _.propertyOf = function(obj) { - return obj == null ? function() {} : function(key) { - return obj[key]; + LazyWrapper.prototype.slice = function(start, end) { + start = start == null ? 0 : +start || 0; + var result = this; + if (result.__filtered__ && (start > 0 || end < 0)) { + return new LazyWrapper(result); + } + if (start < 0) { + result = result.takeRight(-start); + } else if (start) { + result = result.drop(start); + } + if (end !== undefined) { + end = +end || 0; + result = end < 0 ? result.dropRight(-end) : result.take(end - start); + } + return result; }; - }; - _.matcher = _.matches = function(attrs) { - attrs = _.extendOwn({}, attrs); - return function(obj) { - return _.isMatch(obj, attrs); + LazyWrapper.prototype.takeRightWhile = function(predicate, thisArg) { + return this.reverse().takeWhile(predicate, thisArg).reverse(); }; - }; - _.times = function(n, iteratee, context) { - var accum = Array(Math.max(0, n)); - iteratee = optimizeCb(iteratee, context, 1); - for (var i = 0; i < n; i++) accum[i] = iteratee(i); - return accum; - }; - _.random = function(min, max) { - if (max == null) { - max = min; - min = 0; - } - return min + Math.floor(Math.random() * (max - min + 1)); - }; - _.now = Date.now || function() { - return new Date().getTime(); - }; - var escapeMap = { - "&": "&", - "<": "<", - ">": ">", - '"': """, - "'": "'", - "`": "`" - }; - var unescapeMap = _.invert(escapeMap); - var createEscaper = function(map) { - var escaper = function(match) { - return map[match]; - }; - var source = "(?:" + _.keys(map).join("|") + ")"; - var testRegexp = RegExp(source); - var replaceRegexp = RegExp(source, "g"); - return function(string) { - string = string == null ? "" : "" + string; - return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; - }; - }; - _.escape = createEscaper(escapeMap); - _.unescape = createEscaper(unescapeMap); - _.result = function(object, property, fallback) { - var value = object == null ? void 0 : object[property]; - if (value === void 0) { - value = fallback; - } - return _.isFunction(value) ? value.call(object) : value; - }; - var idCounter = 0; - _.uniqueId = function(prefix) { - var id = ++idCounter + ""; - return prefix ? prefix + id : id; - }; - _.templateSettings = { - evaluate: /<%([\s\S]+?)%>/g, - interpolate: /<%=([\s\S]+?)%>/g, - escape: /<%-([\s\S]+?)%>/g - }; - var noMatch = /(.)^/; - var escapes = { - "'": "'", - "\\": "\\", - "\r": "r", - "\n": "n", - "\u2028": "u2028", - "\u2029": "u2029" - }; - var escaper = /\\|'|\r|\n|\u2028|\u2029/g; - var escapeChar = function(match) { - return "\\" + escapes[match]; - }; - _.template = function(text, settings, oldSettings) { - if (!settings && oldSettings) settings = oldSettings; - settings = _.defaults({}, settings, _.templateSettings); - var matcher = RegExp([ (settings.escape || noMatch).source, (settings.interpolate || noMatch).source, (settings.evaluate || noMatch).source ].join("|") + "|$", "g"); - var index = 0; - var source = "__p+='"; - text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { - source += text.slice(index, offset).replace(escaper, escapeChar); - index = offset + match.length; - if (escape) { - source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; - } else if (interpolate) { - source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; - } else if (evaluate) { - source += "';\n" + evaluate + "\n__p+='"; - } - return match; - }); - source += "';\n"; - if (!settings.variable) source = "with(obj||{}){\n" + source + "}\n"; - source = "var __t,__p='',__j=Array.prototype.join," + "print=function(){__p+=__j.call(arguments,'');};\n" + source + "return __p;\n"; - try { - var render = new Function(settings.variable || "obj", "_", source); - } catch (e) { - e.source = source; - throw e; - } - var template = function(data) { - return render.call(this, data, _); + LazyWrapper.prototype.toArray = function() { + return this.take(POSITIVE_INFINITY); }; - var argument = settings.variable || "obj"; - template.source = "function(" + argument + "){\n" + source + "}"; - return template; - }; - _.chain = function(obj) { - var instance = _(obj); - instance._chain = true; - return instance; - }; - var result = function(instance, obj) { - return instance._chain ? _(obj).chain() : obj; - }; - _.mixin = function(obj) { - _.each(_.functions(obj), function(name) { - var func = _[name] = obj[name]; - _.prototype[name] = function() { - var args = [ this._wrapped ]; - push.apply(args, arguments); - return result(this, func.apply(_, args)); + baseForOwn(LazyWrapper.prototype, function(func, methodName) { + var checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName), retUnwrapped = /^(?:first|last)$/.test(methodName), lodashFunc = lodash[retUnwrapped ? "take" + (methodName == "last" ? "Right" : "") : methodName]; + if (!lodashFunc) { + return; + } + lodash.prototype[methodName] = function() { + var args = retUnwrapped ? [ 1 ] : arguments, chainAll = this.__chain__, value = this.__wrapped__, isHybrid = !!this.__actions__.length, isLazy = value instanceof LazyWrapper, iteratee = args[0], useLazy = isLazy || isArray(value); + if (useLazy && checkIteratee && typeof iteratee == "function" && iteratee.length != 1) { + isLazy = useLazy = false; + } + var interceptor = function(value) { + return retUnwrapped && chainAll ? lodashFunc(value, 1)[0] : lodashFunc.apply(undefined, arrayPush([ value ], args)); + }; + var action = { + func: thru, + args: [ interceptor ], + thisArg: undefined + }, onlyLazy = isLazy && !isHybrid; + if (retUnwrapped && !chainAll) { + if (onlyLazy) { + value = value.clone(); + value.__actions__.push(action); + return func.call(value); + } + return lodashFunc.call(undefined, this.value())[0]; + } + if (!retUnwrapped && useLazy) { + value = onlyLazy ? value : new LazyWrapper(this); + var result = func.apply(value, args); + result.__actions__.push(action); + return new LodashWrapper(result, chainAll); + } + return this.thru(interceptor); }; }); - }; - _.mixin(_); - _.each([ "pop", "push", "reverse", "shift", "sort", "splice", "unshift" ], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - var obj = this._wrapped; - method.apply(obj, arguments); - if ((name === "shift" || name === "splice") && obj.length === 0) delete obj[0]; - return result(this, obj); - }; - }); - _.each([ "concat", "join", "slice" ], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - return result(this, method.apply(this._wrapped, arguments)); - }; - }); - _.prototype.value = function() { - return this._wrapped; - }; - _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; - _.prototype.toString = function() { - return "" + this._wrapped; - }; - if (typeof define === "function" && define.amd) { - define("underscore", [], function() { + arrayEach([ "join", "pop", "push", "replace", "shift", "sort", "splice", "split", "unshift" ], function(methodName) { + var func = (/^(?:replace|split)$/.test(methodName) ? stringProto : arrayProto)[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? "tap" : "thru", retUnwrapped = /^(?:join|pop|replace|shift)$/.test(methodName); + lodash.prototype[methodName] = function() { + var args = arguments; + if (retUnwrapped && !this.__chain__) { + return func.apply(this.value(), args); + } + return this[chainName](function(value) { + return func.apply(value, args); + }); + }; + }); + baseForOwn(LazyWrapper.prototype, function(func, methodName) { + var lodashFunc = lodash[methodName]; + if (lodashFunc) { + var key = lodashFunc.name + "", names = realNames[key] || (realNames[key] = []); + names.push({ + name: methodName, + func: lodashFunc + }); + } + }); + realNames[createHybridWrapper(undefined, BIND_KEY_FLAG).name] = [ { + name: "wrapper", + func: undefined + } ]; + LazyWrapper.prototype.clone = lazyClone; + LazyWrapper.prototype.reverse = lazyReverse; + LazyWrapper.prototype.value = lazyValue; + lodash.prototype.chain = wrapperChain; + lodash.prototype.commit = wrapperCommit; + lodash.prototype.concat = wrapperConcat; + lodash.prototype.plant = wrapperPlant; + lodash.prototype.reverse = wrapperReverse; + lodash.prototype.toString = wrapperToString; + lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; + lodash.prototype.collect = lodash.prototype.map; + lodash.prototype.head = lodash.prototype.first; + lodash.prototype.select = lodash.prototype.filter; + lodash.prototype.tail = lodash.prototype.rest; + return lodash; + } + var _ = runInContext(); + if (typeof define == "function" && typeof define.amd == "object" && define.amd) { + root._ = _; + define(function() { return _; }); + } else if (freeExports && freeModule) { + if (moduleExports) { + (freeModule.exports = _)._ = _; + } else { + freeExports._ = _; + } + } else { + root._ = _; } }).call(this); @@ -6445,7 +9332,7 @@ } return match; }); - message += "\nhttp://errors.angularjs.org/1.4.6/" + (module ? module + "/" : "") + code; + message += "\nhttp://errors.angularjs.org/1.4.7/" + (module ? module + "/" : "") + code; for (i = SKIP_INDEXES, paramPrefix = "?"; i < templateArgs.length; i++, paramPrefix = "&") { message += paramPrefix + "p" + (i - SKIP_INDEXES) + "=" + encodeURIComponent(toDebugString(templateArgs[i])); } @@ -7264,11 +10151,11 @@ return obj; } var version = { - full: "1.4.6", + full: "1.4.7", major: 1, minor: 4, - dot: 6, - codeName: "multiplicative-elevation" + dot: 7, + codeName: "dark-luminescence" }; function publishExternalAPI(angular) { extend(angular, { @@ -7377,6 +10264,7 @@ $httpParamSerializer: $HttpParamSerializerProvider, $httpParamSerializerJQLike: $HttpParamSerializerJQLikeProvider, $httpBackend: $HttpBackendProvider, + $xhrFactory: $xhrFactoryProvider, $location: $LocationProvider, $log: $LogProvider, $parse: $ParseProvider, @@ -7422,10 +10310,10 @@ return offset ? letter.toUpperCase() : letter; }).replace(MOZ_HACK_REGEXP, "Moz$1"); } - var SINGLE_TAG_REGEXP = /^<(\w+)\s*\/?>(?:<\/\1>|)$/; + var SINGLE_TAG_REGEXP = /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/; var HTML_REGEXP = /<|&#?\w+;/; - var TAG_NAME_REGEXP = /<([\w:]+)/; - var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi; + var TAG_NAME_REGEXP = /<([\w:-]+)/; + var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi; var wrapMap = { option: [ 1, '" ], thead: [ 1, "", "
        " ], @@ -8668,6 +11556,9 @@ } }; return function(element, options) { + if (options.cleanupStyles) { + options.from = options.to = null; + } if (options.from) { element.css(options.from); options.from = null; @@ -9933,7 +12824,7 @@ compile: function() { return { pre: function attrInterpolatePreLinkFn(scope, element, attr) { - var $$observers = attr.$$observers || (attr.$$observers = {}); + var $$observers = attr.$$observers || (attr.$$observers = createMap()); if (EVENT_HANDLER_ATTR_REGEXP.test(name)) { throw $compileMinErr("nodomevents", "Interpolations for HTML DOM event attributes are disallowed. Please use the " + "ng- versions (such as ng-click instead of onclick) instead."); } @@ -10596,12 +13487,16 @@ } } ]; } - function createXhr() { - return new window.XMLHttpRequest(); + function $xhrFactoryProvider() { + this.$get = function() { + return function createXhr() { + return new window.XMLHttpRequest(); + }; + }; } function $HttpBackendProvider() { - this.$get = [ "$browser", "$window", "$document", function($browser, $window, $document) { - return createHttpBackend($browser, createXhr, $browser.defer, $window.angular.callbacks, $document[0]); + this.$get = [ "$browser", "$window", "$document", "$xhrFactory", function($browser, $window, $document, $xhrFactory) { + return createHttpBackend($browser, $xhrFactory, $browser.defer, $window.angular.callbacks, $document[0]); } ]; } function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDocument) { @@ -10619,7 +13514,7 @@ callbacks[callbackId] = noop; }); } else { - var xhr = createXhr(); + var xhr = createXhr(method, url); xhr.open(method, url, true); forEach(headers, function(value, key) { if (isDefined(value)) { @@ -11327,12 +14222,18 @@ } var $parseMinErr = minErr("$parse"); function ensureSafeMemberName(name, fullExpression) { - name = isObject(name) && name.toString ? name.toString() : name; if (name === "__defineGetter__" || name === "__defineSetter__" || name === "__lookupGetter__" || name === "__lookupSetter__" || name === "__proto__") { throw $parseMinErr("isecfld", "Attempting to access a disallowed field in Angular expressions! " + "Expression: {0}", fullExpression); } return name; } + function getStringValue(name, fullExpression) { + name = name + ""; + if (!isString(name)) { + throw $parseMinErr("iseccst", "Cannot convert object to primitive value! " + "Expression: {0}", fullExpression); + } + return name; + } function ensureSafeObject(obj, fullExpression) { if (obj) { if (obj.constructor === obj) { @@ -11359,6 +14260,13 @@ } } } + function ensureSafeAssignContext(obj, fullExpression) { + if (obj) { + if (obj === 0..constructor || obj === false.constructor || obj === "".constructor || obj === {}.constructor || obj === [].constructor || obj === Function.constructor) { + throw $parseMinErr("isecaf", "Assigning to a constructor is disallowed! Expression: {0}", fullExpression); + } + } + } var OPERATORS = createMap(); forEach("+ - * / % === !== == != < > <= >= && || ! = |".split(" "), function(operator) { OPERATORS[operator] = true; @@ -12107,7 +15015,7 @@ this.stage = "main"; this.recurse(ast); var fnString = '"' + this.USE + " " + this.STRICT + '";\n' + this.filterPrefix() + "var fn=" + this.generateFunction("fn", "s,l,a,i") + extra + this.watchFns() + "return fn;"; - var fn = new Function("$filter", "ensureSafeMemberName", "ensureSafeObject", "ensureSafeFunction", "ifDefined", "plus", "text", fnString)(this.$filter, ensureSafeMemberName, ensureSafeObject, ensureSafeFunction, ifDefined, plusFn, expression); + var fn = new Function("$filter", "ensureSafeMemberName", "ensureSafeObject", "ensureSafeFunction", "getStringValue", "ensureSafeAssignContext", "ifDefined", "plus", "text", fnString)(this.$filter, ensureSafeMemberName, ensureSafeObject, ensureSafeFunction, getStringValue, ensureSafeAssignContext, ifDefined, plusFn, expression); this.state = this.stage = undefined; fn.literal = isLiteral(ast); fn.constant = isConstant(ast); @@ -12244,6 +15152,7 @@ if (ast.computed) { right = self.nextId(); self.recurse(ast.property, right); + self.getStringValue(right); self.addEnsureSafeMemberName(right); if (create && create !== 1) { self.if_(self.not(self.computedMember(left, right)), self.lazyAssign(self.computedMember(left, right), "{}")); @@ -12329,6 +15238,7 @@ self.if_(self.notNull(left.context), function() { self.recurse(ast.right, right); self.addEnsureSafeObject(self.member(left.context, left.name, left.computed)); + self.addEnsureSafeAssignContext(left.context); expression = self.member(left.context, left.name, left.computed) + ast.operator + right; self.assign(intoId, expression); recursionFn(intoId || expression); @@ -12439,6 +15349,9 @@ addEnsureSafeFunction: function(item) { this.current().body.push(this.ensureSafeFunction(item), ";"); }, + addEnsureSafeAssignContext: function(item) { + this.current().body.push(this.ensureSafeAssignContext(item), ";"); + }, ensureSafeObject: function(item) { return "ensureSafeObject(" + item + ",text)"; }, @@ -12448,6 +15361,12 @@ ensureSafeFunction: function(item) { return "ensureSafeFunction(" + item + ",text)"; }, + getStringValue: function(item) { + this.assign(item, "getStringValue(" + item + ",text)"); + }, + ensureSafeAssignContext: function(item) { + return "ensureSafeAssignContext(" + item + ",text)"; + }, lazyRecurse: function(ast, intoId, nameId, recursionFn, create, skipWatchIdCheck) { var self = this; return function() { @@ -12615,6 +15534,7 @@ var lhs = left(scope, locals, assign, inputs); var rhs = right(scope, locals, assign, inputs); ensureSafeObject(lhs.value, self.expression); + ensureSafeAssignContext(lhs.context); lhs.context[lhs.name] = rhs; return context ? { value: rhs @@ -12872,6 +15792,7 @@ var value; if (lhs != null) { rhs = right(scope, locals, assign, inputs); + rhs = getStringValue(rhs); ensureSafeMemberName(rhs, expression); if (create && create !== 1 && lhs && !lhs[rhs]) { lhs[rhs] = {}; @@ -14554,6 +17475,7 @@ if (fractionSize > 0 && number < 1) { formatedText = number.toFixed(fractionSize); number = parseFloat(formatedText); + formatedText = formatedText.replace(DECIMAL_SEP, decimalSep); } } if (number === 0) { @@ -16571,11 +19493,11 @@ function updateOptionElement(option, element) { option.element = element; element.disabled = option.disabled; - if (option.value !== element.value) element.value = option.selectValue; if (option.label !== element.label) { element.label = option.label; element.textContent = option.label; } + if (option.value !== element.value) element.value = option.selectValue; } function addOrReuseElement(parent, current, type, templateElement) { var element; @@ -16603,7 +19525,7 @@ var emptyOption_ = emptyOption && emptyOption[0]; var unknownOption_ = unknownOption && unknownOption[0]; if (emptyOption_ || unknownOption_) { - while (current && (current === emptyOption_ || current === unknownOption_)) { + while (current && (current === emptyOption_ || current === unknownOption_ || emptyOption_ && emptyOption_.nodeType === NODE_TYPE_COMMENT)) { current = current.nextSibling; } } @@ -27302,6 +30224,8 @@ var WaveSurfer = { audioRate: 1, interact: !0, splitChannels: !1, + mediaContainer: null, + mediaControls: !1, renderer: "Canvas", backend: "WebAudio", mediaType: "audio" @@ -27309,7 +30233,7 @@ var WaveSurfer = { init: function(a) { if (this.params = WaveSurfer.util.extend({}, this.defaultParams, a), this.container = "string" == typeof a.container ? document.querySelector(this.params.container) : this.params.container, !this.container) throw new Error("Container element not found"); - if ("undefined" == typeof this.params.mediaContainer ? this.mediaContainer = this.container : "string" == typeof this.params.mediaContainer ? this.mediaContainer = document.querySelector(this.params.mediaContainer) : this.mediaContainer = this.params.mediaContainer, + if (null == this.params.mediaContainer ? this.mediaContainer = this.container : "string" == typeof this.params.mediaContainer ? this.mediaContainer = document.querySelector(this.params.mediaContainer) : this.mediaContainer = this.params.mediaContainer, !this.mediaContainer) throw new Error("Media Container element not found"); this.savedVolume = 0, this.isMuted = !1, this.tmpEvents = [], this.createDrawer(), this.createBackend(); @@ -27405,7 +30329,8 @@ var WaveSurfer = { this.drawer.drawPeaks(d, c), this.fireEvent("redraw", d, c); }, zoom: function(a) { - this.params.minPxPerSec = a, this.params.scrollParent = !0, this.drawBuffer(), this.seekAndCenter(this.getCurrentTime() / this.getDuration()); + this.params.minPxPerSec = a, this.params.scrollParent = !0, this.drawBuffer(), this.seekAndCenter(this.getCurrentTime() / this.getDuration()), + this.fireEvent("zoom", a); }, loadArrayBuffer: function(a) { this.decodeArrayBuffer(a, function(a) { @@ -27736,7 +30661,8 @@ WaveSurfer.util.extend(WaveSurfer.MediaElement, { }, load: function(a, b, c) { var d = this, e = document.createElement(this.mediaType); - e.controls = !1, e.autoplay = !1, e.preload = "auto", e.src = a, e.addEventListener("error", function() { + e.controls = this.params.mediaControls, e.autoplay = !1, e.preload = "auto", e.src = a, + e.style.width = "100%", e.addEventListener("error", function() { d.fireEvent("error", "Error loading media element"); }), e.addEventListener("canplay", function() { d.fireEvent("canplay"); @@ -27949,11 +30875,11 @@ WaveSurfer.util.extend(WaveSurfer.Drawer.Canvas, { this.waveCc.fillStyle = this.params.waveColor, this.progressCc && (this.progressCc.fillStyle = this.params.progressColor), [ this.waveCc, this.progressCc ].forEach(function(b) { if (b) if (this.params.reflection) for (var c = 0; e > c; c += l) { - var f = Math.round(a[2 * c * p] / m * h); + var f = Math.round(a[Math.floor(2 * c * p)] / m * h); b.fillRect(c + d, h - f + g, j + d, 2 * f); } else { for (var c = 0; e > c; c += l) { - var f = Math.round(a[2 * c * p] / m * h); + var f = Math.round(a[Math.floor(2 * c * p)] / m * h); b.fillRect(c + d, h - f + g, j + d, f); } for (var c = 0; e > c; c += l) { @@ -27999,7 +30925,23 @@ WaveSurfer.util.extend(WaveSurfer.Drawer.Canvas, { width: b + "px" }); } -}); +}), function() { + var a = function() { + var a = document.querySelectorAll("wavesurfer"); + Array.prototype.forEach.call(a, function(a) { + var b = WaveSurfer.util.extend({ + container: a, + backend: "MediaElement", + mediaControls: !0 + }, a.dataset); + a.style.display = "block"; + var c = WaveSurfer.create(b); + if (a.dataset.peaks) var d = JSON.parse(a.dataset.peaks); + c.load(a.dataset.url, d); + }); + }; + "complete" === document.readyState ? a() : window.addEventListener("load", a); +}(); "use strict"; diff --git a/lingvodoc/static/js/home.js b/lingvodoc/static/js/home.js index d2a1428ff..112dfeef2 100644 --- a/lingvodoc/static/js/home.js +++ b/lingvodoc/static/js/home.js @@ -5391,7 +5391,7 @@ } return match; }); - message += "\nhttp://errors.angularjs.org/1.4.6/" + (module ? module + "/" : "") + code; + message += "\nhttp://errors.angularjs.org/1.4.7/" + (module ? module + "/" : "") + code; for (i = SKIP_INDEXES, paramPrefix = "?"; i < templateArgs.length; i++, paramPrefix = "&") { message += paramPrefix + "p" + (i - SKIP_INDEXES) + "=" + encodeURIComponent(toDebugString(templateArgs[i])); } @@ -6210,11 +6210,11 @@ return obj; } var version = { - full: "1.4.6", + full: "1.4.7", major: 1, minor: 4, - dot: 6, - codeName: "multiplicative-elevation" + dot: 7, + codeName: "dark-luminescence" }; function publishExternalAPI(angular) { extend(angular, { @@ -6323,6 +6323,7 @@ $httpParamSerializer: $HttpParamSerializerProvider, $httpParamSerializerJQLike: $HttpParamSerializerJQLikeProvider, $httpBackend: $HttpBackendProvider, + $xhrFactory: $xhrFactoryProvider, $location: $LocationProvider, $log: $LogProvider, $parse: $ParseProvider, @@ -6368,10 +6369,10 @@ return offset ? letter.toUpperCase() : letter; }).replace(MOZ_HACK_REGEXP, "Moz$1"); } - var SINGLE_TAG_REGEXP = /^<(\w+)\s*\/?>(?:<\/\1>|)$/; + var SINGLE_TAG_REGEXP = /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/; var HTML_REGEXP = /<|&#?\w+;/; - var TAG_NAME_REGEXP = /<([\w:]+)/; - var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi; + var TAG_NAME_REGEXP = /<([\w:-]+)/; + var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi; var wrapMap = { option: [ 1, '" ], thead: [ 1, "", "
        " ], @@ -7614,6 +7615,9 @@ } }; return function(element, options) { + if (options.cleanupStyles) { + options.from = options.to = null; + } if (options.from) { element.css(options.from); options.from = null; @@ -8879,7 +8883,7 @@ compile: function() { return { pre: function attrInterpolatePreLinkFn(scope, element, attr) { - var $$observers = attr.$$observers || (attr.$$observers = {}); + var $$observers = attr.$$observers || (attr.$$observers = createMap()); if (EVENT_HANDLER_ATTR_REGEXP.test(name)) { throw $compileMinErr("nodomevents", "Interpolations for HTML DOM event attributes are disallowed. Please use the " + "ng- versions (such as ng-click instead of onclick) instead."); } @@ -9542,12 +9546,16 @@ } } ]; } - function createXhr() { - return new window.XMLHttpRequest(); + function $xhrFactoryProvider() { + this.$get = function() { + return function createXhr() { + return new window.XMLHttpRequest(); + }; + }; } function $HttpBackendProvider() { - this.$get = [ "$browser", "$window", "$document", function($browser, $window, $document) { - return createHttpBackend($browser, createXhr, $browser.defer, $window.angular.callbacks, $document[0]); + this.$get = [ "$browser", "$window", "$document", "$xhrFactory", function($browser, $window, $document, $xhrFactory) { + return createHttpBackend($browser, $xhrFactory, $browser.defer, $window.angular.callbacks, $document[0]); } ]; } function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDocument) { @@ -9565,7 +9573,7 @@ callbacks[callbackId] = noop; }); } else { - var xhr = createXhr(); + var xhr = createXhr(method, url); xhr.open(method, url, true); forEach(headers, function(value, key) { if (isDefined(value)) { @@ -10273,12 +10281,18 @@ } var $parseMinErr = minErr("$parse"); function ensureSafeMemberName(name, fullExpression) { - name = isObject(name) && name.toString ? name.toString() : name; if (name === "__defineGetter__" || name === "__defineSetter__" || name === "__lookupGetter__" || name === "__lookupSetter__" || name === "__proto__") { throw $parseMinErr("isecfld", "Attempting to access a disallowed field in Angular expressions! " + "Expression: {0}", fullExpression); } return name; } + function getStringValue(name, fullExpression) { + name = name + ""; + if (!isString(name)) { + throw $parseMinErr("iseccst", "Cannot convert object to primitive value! " + "Expression: {0}", fullExpression); + } + return name; + } function ensureSafeObject(obj, fullExpression) { if (obj) { if (obj.constructor === obj) { @@ -10305,6 +10319,13 @@ } } } + function ensureSafeAssignContext(obj, fullExpression) { + if (obj) { + if (obj === 0..constructor || obj === false.constructor || obj === "".constructor || obj === {}.constructor || obj === [].constructor || obj === Function.constructor) { + throw $parseMinErr("isecaf", "Assigning to a constructor is disallowed! Expression: {0}", fullExpression); + } + } + } var OPERATORS = createMap(); forEach("+ - * / % === !== == != < > <= >= && || ! = |".split(" "), function(operator) { OPERATORS[operator] = true; @@ -11053,7 +11074,7 @@ this.stage = "main"; this.recurse(ast); var fnString = '"' + this.USE + " " + this.STRICT + '";\n' + this.filterPrefix() + "var fn=" + this.generateFunction("fn", "s,l,a,i") + extra + this.watchFns() + "return fn;"; - var fn = new Function("$filter", "ensureSafeMemberName", "ensureSafeObject", "ensureSafeFunction", "ifDefined", "plus", "text", fnString)(this.$filter, ensureSafeMemberName, ensureSafeObject, ensureSafeFunction, ifDefined, plusFn, expression); + var fn = new Function("$filter", "ensureSafeMemberName", "ensureSafeObject", "ensureSafeFunction", "getStringValue", "ensureSafeAssignContext", "ifDefined", "plus", "text", fnString)(this.$filter, ensureSafeMemberName, ensureSafeObject, ensureSafeFunction, getStringValue, ensureSafeAssignContext, ifDefined, plusFn, expression); this.state = this.stage = undefined; fn.literal = isLiteral(ast); fn.constant = isConstant(ast); @@ -11190,6 +11211,7 @@ if (ast.computed) { right = self.nextId(); self.recurse(ast.property, right); + self.getStringValue(right); self.addEnsureSafeMemberName(right); if (create && create !== 1) { self.if_(self.not(self.computedMember(left, right)), self.lazyAssign(self.computedMember(left, right), "{}")); @@ -11275,6 +11297,7 @@ self.if_(self.notNull(left.context), function() { self.recurse(ast.right, right); self.addEnsureSafeObject(self.member(left.context, left.name, left.computed)); + self.addEnsureSafeAssignContext(left.context); expression = self.member(left.context, left.name, left.computed) + ast.operator + right; self.assign(intoId, expression); recursionFn(intoId || expression); @@ -11385,6 +11408,9 @@ addEnsureSafeFunction: function(item) { this.current().body.push(this.ensureSafeFunction(item), ";"); }, + addEnsureSafeAssignContext: function(item) { + this.current().body.push(this.ensureSafeAssignContext(item), ";"); + }, ensureSafeObject: function(item) { return "ensureSafeObject(" + item + ",text)"; }, @@ -11394,6 +11420,12 @@ ensureSafeFunction: function(item) { return "ensureSafeFunction(" + item + ",text)"; }, + getStringValue: function(item) { + this.assign(item, "getStringValue(" + item + ",text)"); + }, + ensureSafeAssignContext: function(item) { + return "ensureSafeAssignContext(" + item + ",text)"; + }, lazyRecurse: function(ast, intoId, nameId, recursionFn, create, skipWatchIdCheck) { var self = this; return function() { @@ -11561,6 +11593,7 @@ var lhs = left(scope, locals, assign, inputs); var rhs = right(scope, locals, assign, inputs); ensureSafeObject(lhs.value, self.expression); + ensureSafeAssignContext(lhs.context); lhs.context[lhs.name] = rhs; return context ? { value: rhs @@ -11818,6 +11851,7 @@ var value; if (lhs != null) { rhs = right(scope, locals, assign, inputs); + rhs = getStringValue(rhs); ensureSafeMemberName(rhs, expression); if (create && create !== 1 && lhs && !lhs[rhs]) { lhs[rhs] = {}; @@ -13500,6 +13534,7 @@ if (fractionSize > 0 && number < 1) { formatedText = number.toFixed(fractionSize); number = parseFloat(formatedText); + formatedText = formatedText.replace(DECIMAL_SEP, decimalSep); } } if (number === 0) { @@ -15517,11 +15552,11 @@ function updateOptionElement(option, element) { option.element = element; element.disabled = option.disabled; - if (option.value !== element.value) element.value = option.selectValue; if (option.label !== element.label) { element.label = option.label; element.textContent = option.label; } + if (option.value !== element.value) element.value = option.selectValue; } function addOrReuseElement(parent, current, type, templateElement) { var element; @@ -15549,7 +15584,7 @@ var emptyOption_ = emptyOption && emptyOption[0]; var unknownOption_ = unknownOption && unknownOption[0]; if (emptyOption_ || unknownOption_) { - while (current && (current === emptyOption_ || current === unknownOption_)) { + while (current && (current === emptyOption_ || current === unknownOption_ || emptyOption_ && emptyOption_.nodeType === NODE_TYPE_COMMENT)) { current = current.nextSibling; } } diff --git a/lingvodoc/static/js/languages.js b/lingvodoc/static/js/languages.js index cd5b3c344..98168191e 100644 --- a/lingvodoc/static/js/languages.js +++ b/lingvodoc/static/js/languages.js @@ -5391,7 +5391,7 @@ } return match; }); - message += "\nhttp://errors.angularjs.org/1.4.6/" + (module ? module + "/" : "") + code; + message += "\nhttp://errors.angularjs.org/1.4.7/" + (module ? module + "/" : "") + code; for (i = SKIP_INDEXES, paramPrefix = "?"; i < templateArgs.length; i++, paramPrefix = "&") { message += paramPrefix + "p" + (i - SKIP_INDEXES) + "=" + encodeURIComponent(toDebugString(templateArgs[i])); } @@ -6210,11 +6210,11 @@ return obj; } var version = { - full: "1.4.6", + full: "1.4.7", major: 1, minor: 4, - dot: 6, - codeName: "multiplicative-elevation" + dot: 7, + codeName: "dark-luminescence" }; function publishExternalAPI(angular) { extend(angular, { @@ -6323,6 +6323,7 @@ $httpParamSerializer: $HttpParamSerializerProvider, $httpParamSerializerJQLike: $HttpParamSerializerJQLikeProvider, $httpBackend: $HttpBackendProvider, + $xhrFactory: $xhrFactoryProvider, $location: $LocationProvider, $log: $LogProvider, $parse: $ParseProvider, @@ -6368,10 +6369,10 @@ return offset ? letter.toUpperCase() : letter; }).replace(MOZ_HACK_REGEXP, "Moz$1"); } - var SINGLE_TAG_REGEXP = /^<(\w+)\s*\/?>(?:<\/\1>|)$/; + var SINGLE_TAG_REGEXP = /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/; var HTML_REGEXP = /<|&#?\w+;/; - var TAG_NAME_REGEXP = /<([\w:]+)/; - var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi; + var TAG_NAME_REGEXP = /<([\w:-]+)/; + var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi; var wrapMap = { option: [ 1, '" ], thead: [ 1, "", "
        " ], @@ -7614,6 +7615,9 @@ } }; return function(element, options) { + if (options.cleanupStyles) { + options.from = options.to = null; + } if (options.from) { element.css(options.from); options.from = null; @@ -8879,7 +8883,7 @@ compile: function() { return { pre: function attrInterpolatePreLinkFn(scope, element, attr) { - var $$observers = attr.$$observers || (attr.$$observers = {}); + var $$observers = attr.$$observers || (attr.$$observers = createMap()); if (EVENT_HANDLER_ATTR_REGEXP.test(name)) { throw $compileMinErr("nodomevents", "Interpolations for HTML DOM event attributes are disallowed. Please use the " + "ng- versions (such as ng-click instead of onclick) instead."); } @@ -9542,12 +9546,16 @@ } } ]; } - function createXhr() { - return new window.XMLHttpRequest(); + function $xhrFactoryProvider() { + this.$get = function() { + return function createXhr() { + return new window.XMLHttpRequest(); + }; + }; } function $HttpBackendProvider() { - this.$get = [ "$browser", "$window", "$document", function($browser, $window, $document) { - return createHttpBackend($browser, createXhr, $browser.defer, $window.angular.callbacks, $document[0]); + this.$get = [ "$browser", "$window", "$document", "$xhrFactory", function($browser, $window, $document, $xhrFactory) { + return createHttpBackend($browser, $xhrFactory, $browser.defer, $window.angular.callbacks, $document[0]); } ]; } function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDocument) { @@ -9565,7 +9573,7 @@ callbacks[callbackId] = noop; }); } else { - var xhr = createXhr(); + var xhr = createXhr(method, url); xhr.open(method, url, true); forEach(headers, function(value, key) { if (isDefined(value)) { @@ -10273,12 +10281,18 @@ } var $parseMinErr = minErr("$parse"); function ensureSafeMemberName(name, fullExpression) { - name = isObject(name) && name.toString ? name.toString() : name; if (name === "__defineGetter__" || name === "__defineSetter__" || name === "__lookupGetter__" || name === "__lookupSetter__" || name === "__proto__") { throw $parseMinErr("isecfld", "Attempting to access a disallowed field in Angular expressions! " + "Expression: {0}", fullExpression); } return name; } + function getStringValue(name, fullExpression) { + name = name + ""; + if (!isString(name)) { + throw $parseMinErr("iseccst", "Cannot convert object to primitive value! " + "Expression: {0}", fullExpression); + } + return name; + } function ensureSafeObject(obj, fullExpression) { if (obj) { if (obj.constructor === obj) { @@ -10305,6 +10319,13 @@ } } } + function ensureSafeAssignContext(obj, fullExpression) { + if (obj) { + if (obj === 0..constructor || obj === false.constructor || obj === "".constructor || obj === {}.constructor || obj === [].constructor || obj === Function.constructor) { + throw $parseMinErr("isecaf", "Assigning to a constructor is disallowed! Expression: {0}", fullExpression); + } + } + } var OPERATORS = createMap(); forEach("+ - * / % === !== == != < > <= >= && || ! = |".split(" "), function(operator) { OPERATORS[operator] = true; @@ -11053,7 +11074,7 @@ this.stage = "main"; this.recurse(ast); var fnString = '"' + this.USE + " " + this.STRICT + '";\n' + this.filterPrefix() + "var fn=" + this.generateFunction("fn", "s,l,a,i") + extra + this.watchFns() + "return fn;"; - var fn = new Function("$filter", "ensureSafeMemberName", "ensureSafeObject", "ensureSafeFunction", "ifDefined", "plus", "text", fnString)(this.$filter, ensureSafeMemberName, ensureSafeObject, ensureSafeFunction, ifDefined, plusFn, expression); + var fn = new Function("$filter", "ensureSafeMemberName", "ensureSafeObject", "ensureSafeFunction", "getStringValue", "ensureSafeAssignContext", "ifDefined", "plus", "text", fnString)(this.$filter, ensureSafeMemberName, ensureSafeObject, ensureSafeFunction, getStringValue, ensureSafeAssignContext, ifDefined, plusFn, expression); this.state = this.stage = undefined; fn.literal = isLiteral(ast); fn.constant = isConstant(ast); @@ -11190,6 +11211,7 @@ if (ast.computed) { right = self.nextId(); self.recurse(ast.property, right); + self.getStringValue(right); self.addEnsureSafeMemberName(right); if (create && create !== 1) { self.if_(self.not(self.computedMember(left, right)), self.lazyAssign(self.computedMember(left, right), "{}")); @@ -11275,6 +11297,7 @@ self.if_(self.notNull(left.context), function() { self.recurse(ast.right, right); self.addEnsureSafeObject(self.member(left.context, left.name, left.computed)); + self.addEnsureSafeAssignContext(left.context); expression = self.member(left.context, left.name, left.computed) + ast.operator + right; self.assign(intoId, expression); recursionFn(intoId || expression); @@ -11385,6 +11408,9 @@ addEnsureSafeFunction: function(item) { this.current().body.push(this.ensureSafeFunction(item), ";"); }, + addEnsureSafeAssignContext: function(item) { + this.current().body.push(this.ensureSafeAssignContext(item), ";"); + }, ensureSafeObject: function(item) { return "ensureSafeObject(" + item + ",text)"; }, @@ -11394,6 +11420,12 @@ ensureSafeFunction: function(item) { return "ensureSafeFunction(" + item + ",text)"; }, + getStringValue: function(item) { + this.assign(item, "getStringValue(" + item + ",text)"); + }, + ensureSafeAssignContext: function(item) { + return "ensureSafeAssignContext(" + item + ",text)"; + }, lazyRecurse: function(ast, intoId, nameId, recursionFn, create, skipWatchIdCheck) { var self = this; return function() { @@ -11561,6 +11593,7 @@ var lhs = left(scope, locals, assign, inputs); var rhs = right(scope, locals, assign, inputs); ensureSafeObject(lhs.value, self.expression); + ensureSafeAssignContext(lhs.context); lhs.context[lhs.name] = rhs; return context ? { value: rhs @@ -11818,6 +11851,7 @@ var value; if (lhs != null) { rhs = right(scope, locals, assign, inputs); + rhs = getStringValue(rhs); ensureSafeMemberName(rhs, expression); if (create && create !== 1 && lhs && !lhs[rhs]) { lhs[rhs] = {}; @@ -13500,6 +13534,7 @@ if (fractionSize > 0 && number < 1) { formatedText = number.toFixed(fractionSize); number = parseFloat(formatedText); + formatedText = formatedText.replace(DECIMAL_SEP, decimalSep); } } if (number === 0) { @@ -15517,11 +15552,11 @@ function updateOptionElement(option, element) { option.element = element; element.disabled = option.disabled; - if (option.value !== element.value) element.value = option.selectValue; if (option.label !== element.label) { element.label = option.label; element.textContent = option.label; } + if (option.value !== element.value) element.value = option.selectValue; } function addOrReuseElement(parent, current, type, templateElement) { var element; @@ -15549,7 +15584,7 @@ var emptyOption_ = emptyOption && emptyOption[0]; var unknownOption_ = unknownOption && unknownOption[0]; if (emptyOption_ || unknownOption_) { - while (current && (current === emptyOption_ || current === unknownOption_)) { + while (current && (current === emptyOption_ || current === unknownOption_ || emptyOption_ && emptyOption_.nodeType === NODE_TYPE_COMMENT)) { current = current.nextSibling; } } @@ -26248,6 +26283,8 @@ var WaveSurfer = { audioRate: 1, interact: !0, splitChannels: !1, + mediaContainer: null, + mediaControls: !1, renderer: "Canvas", backend: "WebAudio", mediaType: "audio" @@ -26255,7 +26292,7 @@ var WaveSurfer = { init: function(a) { if (this.params = WaveSurfer.util.extend({}, this.defaultParams, a), this.container = "string" == typeof a.container ? document.querySelector(this.params.container) : this.params.container, !this.container) throw new Error("Container element not found"); - if ("undefined" == typeof this.params.mediaContainer ? this.mediaContainer = this.container : "string" == typeof this.params.mediaContainer ? this.mediaContainer = document.querySelector(this.params.mediaContainer) : this.mediaContainer = this.params.mediaContainer, + if (null == this.params.mediaContainer ? this.mediaContainer = this.container : "string" == typeof this.params.mediaContainer ? this.mediaContainer = document.querySelector(this.params.mediaContainer) : this.mediaContainer = this.params.mediaContainer, !this.mediaContainer) throw new Error("Media Container element not found"); this.savedVolume = 0, this.isMuted = !1, this.tmpEvents = [], this.createDrawer(), this.createBackend(); @@ -26351,7 +26388,8 @@ var WaveSurfer = { this.drawer.drawPeaks(d, c), this.fireEvent("redraw", d, c); }, zoom: function(a) { - this.params.minPxPerSec = a, this.params.scrollParent = !0, this.drawBuffer(), this.seekAndCenter(this.getCurrentTime() / this.getDuration()); + this.params.minPxPerSec = a, this.params.scrollParent = !0, this.drawBuffer(), this.seekAndCenter(this.getCurrentTime() / this.getDuration()), + this.fireEvent("zoom", a); }, loadArrayBuffer: function(a) { this.decodeArrayBuffer(a, function(a) { @@ -26682,7 +26720,8 @@ WaveSurfer.util.extend(WaveSurfer.MediaElement, { }, load: function(a, b, c) { var d = this, e = document.createElement(this.mediaType); - e.controls = !1, e.autoplay = !1, e.preload = "auto", e.src = a, e.addEventListener("error", function() { + e.controls = this.params.mediaControls, e.autoplay = !1, e.preload = "auto", e.src = a, + e.style.width = "100%", e.addEventListener("error", function() { d.fireEvent("error", "Error loading media element"); }), e.addEventListener("canplay", function() { d.fireEvent("canplay"); @@ -26895,11 +26934,11 @@ WaveSurfer.util.extend(WaveSurfer.Drawer.Canvas, { this.waveCc.fillStyle = this.params.waveColor, this.progressCc && (this.progressCc.fillStyle = this.params.progressColor), [ this.waveCc, this.progressCc ].forEach(function(b) { if (b) if (this.params.reflection) for (var c = 0; e > c; c += l) { - var f = Math.round(a[2 * c * p] / m * h); + var f = Math.round(a[Math.floor(2 * c * p)] / m * h); b.fillRect(c + d, h - f + g, j + d, 2 * f); } else { for (var c = 0; e > c; c += l) { - var f = Math.round(a[2 * c * p] / m * h); + var f = Math.round(a[Math.floor(2 * c * p)] / m * h); b.fillRect(c + d, h - f + g, j + d, f); } for (var c = 0; e > c; c += l) { @@ -26945,226 +26984,23 @@ WaveSurfer.util.extend(WaveSurfer.Drawer.Canvas, { width: b + "px" }); } -}); - -var app = angular.module("autocomplete", []); - -app.directive("autocomplete", function() { - var index = -1; - return { - restrict: "E", - scope: { - searchParam: "=ngModel", - suggestions: "=data", - onType: "=onType", - onSelect: "=onSelect", - autocompleteRequired: "=" - }, - controller: [ "$scope", function($scope) { - $scope.selectedIndex = -1; - $scope.initLock = true; - $scope.setIndex = function(i) { - $scope.selectedIndex = parseInt(i); - }; - this.setIndex = function(i) { - $scope.setIndex(i); - $scope.$apply(); - }; - $scope.getIndex = function(i) { - return $scope.selectedIndex; - }; - var watching = true; - $scope.completing = false; - $scope.$watch("searchParam", function(newValue, oldValue) { - if (oldValue === newValue || !oldValue && $scope.initLock) { - return; - } - if (watching && typeof $scope.searchParam !== "undefined" && $scope.searchParam !== null) { - $scope.completing = true; - $scope.searchFilter = $scope.searchParam; - $scope.selectedIndex = -1; - } - if ($scope.onType) $scope.onType($scope.searchParam); - }); - this.preSelect = function(suggestion) { - watching = false; - $scope.$apply(); - watching = true; - }; - $scope.preSelect = this.preSelect; - this.preSelectOff = function() { - watching = true; - }; - $scope.preSelectOff = this.preSelectOff; - $scope.select = function(suggestion) { - if (suggestion) { - $scope.searchParam = suggestion; - $scope.searchFilter = suggestion; - if ($scope.onSelect) $scope.onSelect(suggestion); - } - watching = false; - $scope.completing = false; - setTimeout(function() { - watching = true; - }, 1e3); - $scope.setIndex(-1); - }; - } ], - link: function(scope, element, attrs) { - setTimeout(function() { - scope.initLock = false; - scope.$apply(); - }, 250); - var attr = ""; - scope.attrs = { - placeholder: "start typing...", - "class": "", - id: "", - inputclass: "", - inputid: "" - }; - for (var a in attrs) { - attr = a.replace("attr", "").toLowerCase(); - if (a.indexOf("attr") === 0) { - scope.attrs[attr] = attrs[a]; - } - } - if (attrs.clickActivation) { - element[0].onclick = function(e) { - if (!scope.searchParam) { - setTimeout(function() { - scope.completing = true; - scope.$apply(); - }, 200); - } - }; - } - var key = { - left: 37, - up: 38, - right: 39, - down: 40, - enter: 13, - esc: 27, - tab: 9 - }; - document.addEventListener("keydown", function(e) { - var keycode = e.keyCode || e.which; - switch (keycode) { - case key.esc: - scope.select(); - scope.setIndex(-1); - scope.$apply(); - e.preventDefault(); - } - }, true); - document.addEventListener("blur", function(e) { - setTimeout(function() { - scope.select(); - scope.setIndex(-1); - scope.$apply(); - }, 150); - }, true); - element[0].addEventListener("keydown", function(e) { - var keycode = e.keyCode || e.which; - var l = angular.element(this).find("li").length; - if (!scope.completing || l == 0) return; - switch (keycode) { - case key.up: - index = scope.getIndex() - 1; - if (index < -1) { - index = l - 1; - } else if (index >= l) { - index = -1; - scope.setIndex(index); - scope.preSelectOff(); - break; - } - scope.setIndex(index); - if (index !== -1) scope.preSelect(angular.element(angular.element(this).find("li")[index]).text()); - scope.$apply(); - break; - - case key.down: - index = scope.getIndex() + 1; - if (index < -1) { - index = l - 1; - } else if (index >= l) { - index = -1; - scope.setIndex(index); - scope.preSelectOff(); - scope.$apply(); - break; - } - scope.setIndex(index); - if (index !== -1) scope.preSelect(angular.element(angular.element(this).find("li")[index]).text()); - break; - - case key.left: - break; - - case key.right: - case key.enter: - case key.tab: - index = scope.getIndex(); - if (index !== -1) { - scope.select(angular.element(angular.element(this).find("li")[index]).text()); - if (keycode == key.enter) { - e.preventDefault(); - } - } else { - if (keycode == key.enter) { - scope.select(); - } - } - scope.setIndex(-1); - scope.$apply(); - break; - - case key.esc: - scope.select(); - scope.setIndex(-1); - scope.$apply(); - e.preventDefault(); - break; - - default: - return; - } - }); - }, - template: '
        ' - }; -}); - -app.filter("highlight", [ "$sce", function($sce) { - return function(input, searchParam) { - if (typeof input === "function") return ""; - if (searchParam) { - var words = "(" + searchParam.split(/\ /).join(" |") + "|" + searchParam.split(/\ /).join("|") + ")", exp = new RegExp(words, "gi"); - if (words.length) { - input = input.replace(exp, '$1'); - } - } - return $sce.trustAsHtml(input); - }; -} ]); - -app.directive("suggestion", function() { - return { - restrict: "A", - require: "^autocomplete", - link: function(scope, element, attrs, autoCtrl) { - element.bind("mouseenter", function() { - autoCtrl.preSelect(attrs.val); - autoCtrl.setIndex(attrs.index); - }); - element.bind("mouseleave", function() { - autoCtrl.preSelectOff(); - }); - } +}), function() { + var a = function() { + var a = document.querySelectorAll("wavesurfer"); + Array.prototype.forEach.call(a, function(a) { + var b = WaveSurfer.util.extend({ + container: a, + backend: "MediaElement", + mediaControls: !0 + }, a.dataset); + a.style.display = "block"; + var c = WaveSurfer.create(b); + if (a.dataset.peaks) var d = JSON.parse(a.dataset.peaks); + c.load(a.dataset.url, d); + }); }; -}); + "complete" === document.readyState ? a() : window.addEventListener("load", a); +}(); "use strict"; diff --git a/lingvodoc/static/js/login.js b/lingvodoc/static/js/login.js index c61971896..c181f7642 100644 --- a/lingvodoc/static/js/login.js +++ b/lingvodoc/static/js/login.js @@ -5391,7 +5391,7 @@ } return match; }); - message += "\nhttp://errors.angularjs.org/1.4.6/" + (module ? module + "/" : "") + code; + message += "\nhttp://errors.angularjs.org/1.4.7/" + (module ? module + "/" : "") + code; for (i = SKIP_INDEXES, paramPrefix = "?"; i < templateArgs.length; i++, paramPrefix = "&") { message += paramPrefix + "p" + (i - SKIP_INDEXES) + "=" + encodeURIComponent(toDebugString(templateArgs[i])); } @@ -6210,11 +6210,11 @@ return obj; } var version = { - full: "1.4.6", + full: "1.4.7", major: 1, minor: 4, - dot: 6, - codeName: "multiplicative-elevation" + dot: 7, + codeName: "dark-luminescence" }; function publishExternalAPI(angular) { extend(angular, { @@ -6323,6 +6323,7 @@ $httpParamSerializer: $HttpParamSerializerProvider, $httpParamSerializerJQLike: $HttpParamSerializerJQLikeProvider, $httpBackend: $HttpBackendProvider, + $xhrFactory: $xhrFactoryProvider, $location: $LocationProvider, $log: $LogProvider, $parse: $ParseProvider, @@ -6368,10 +6369,10 @@ return offset ? letter.toUpperCase() : letter; }).replace(MOZ_HACK_REGEXP, "Moz$1"); } - var SINGLE_TAG_REGEXP = /^<(\w+)\s*\/?>(?:<\/\1>|)$/; + var SINGLE_TAG_REGEXP = /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/; var HTML_REGEXP = /<|&#?\w+;/; - var TAG_NAME_REGEXP = /<([\w:]+)/; - var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi; + var TAG_NAME_REGEXP = /<([\w:-]+)/; + var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi; var wrapMap = { option: [ 1, '" ], thead: [ 1, "", "
        " ], @@ -7614,6 +7615,9 @@ } }; return function(element, options) { + if (options.cleanupStyles) { + options.from = options.to = null; + } if (options.from) { element.css(options.from); options.from = null; @@ -8879,7 +8883,7 @@ compile: function() { return { pre: function attrInterpolatePreLinkFn(scope, element, attr) { - var $$observers = attr.$$observers || (attr.$$observers = {}); + var $$observers = attr.$$observers || (attr.$$observers = createMap()); if (EVENT_HANDLER_ATTR_REGEXP.test(name)) { throw $compileMinErr("nodomevents", "Interpolations for HTML DOM event attributes are disallowed. Please use the " + "ng- versions (such as ng-click instead of onclick) instead."); } @@ -9542,12 +9546,16 @@ } } ]; } - function createXhr() { - return new window.XMLHttpRequest(); + function $xhrFactoryProvider() { + this.$get = function() { + return function createXhr() { + return new window.XMLHttpRequest(); + }; + }; } function $HttpBackendProvider() { - this.$get = [ "$browser", "$window", "$document", function($browser, $window, $document) { - return createHttpBackend($browser, createXhr, $browser.defer, $window.angular.callbacks, $document[0]); + this.$get = [ "$browser", "$window", "$document", "$xhrFactory", function($browser, $window, $document, $xhrFactory) { + return createHttpBackend($browser, $xhrFactory, $browser.defer, $window.angular.callbacks, $document[0]); } ]; } function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDocument) { @@ -9565,7 +9573,7 @@ callbacks[callbackId] = noop; }); } else { - var xhr = createXhr(); + var xhr = createXhr(method, url); xhr.open(method, url, true); forEach(headers, function(value, key) { if (isDefined(value)) { @@ -10273,12 +10281,18 @@ } var $parseMinErr = minErr("$parse"); function ensureSafeMemberName(name, fullExpression) { - name = isObject(name) && name.toString ? name.toString() : name; if (name === "__defineGetter__" || name === "__defineSetter__" || name === "__lookupGetter__" || name === "__lookupSetter__" || name === "__proto__") { throw $parseMinErr("isecfld", "Attempting to access a disallowed field in Angular expressions! " + "Expression: {0}", fullExpression); } return name; } + function getStringValue(name, fullExpression) { + name = name + ""; + if (!isString(name)) { + throw $parseMinErr("iseccst", "Cannot convert object to primitive value! " + "Expression: {0}", fullExpression); + } + return name; + } function ensureSafeObject(obj, fullExpression) { if (obj) { if (obj.constructor === obj) { @@ -10305,6 +10319,13 @@ } } } + function ensureSafeAssignContext(obj, fullExpression) { + if (obj) { + if (obj === 0..constructor || obj === false.constructor || obj === "".constructor || obj === {}.constructor || obj === [].constructor || obj === Function.constructor) { + throw $parseMinErr("isecaf", "Assigning to a constructor is disallowed! Expression: {0}", fullExpression); + } + } + } var OPERATORS = createMap(); forEach("+ - * / % === !== == != < > <= >= && || ! = |".split(" "), function(operator) { OPERATORS[operator] = true; @@ -11053,7 +11074,7 @@ this.stage = "main"; this.recurse(ast); var fnString = '"' + this.USE + " " + this.STRICT + '";\n' + this.filterPrefix() + "var fn=" + this.generateFunction("fn", "s,l,a,i") + extra + this.watchFns() + "return fn;"; - var fn = new Function("$filter", "ensureSafeMemberName", "ensureSafeObject", "ensureSafeFunction", "ifDefined", "plus", "text", fnString)(this.$filter, ensureSafeMemberName, ensureSafeObject, ensureSafeFunction, ifDefined, plusFn, expression); + var fn = new Function("$filter", "ensureSafeMemberName", "ensureSafeObject", "ensureSafeFunction", "getStringValue", "ensureSafeAssignContext", "ifDefined", "plus", "text", fnString)(this.$filter, ensureSafeMemberName, ensureSafeObject, ensureSafeFunction, getStringValue, ensureSafeAssignContext, ifDefined, plusFn, expression); this.state = this.stage = undefined; fn.literal = isLiteral(ast); fn.constant = isConstant(ast); @@ -11190,6 +11211,7 @@ if (ast.computed) { right = self.nextId(); self.recurse(ast.property, right); + self.getStringValue(right); self.addEnsureSafeMemberName(right); if (create && create !== 1) { self.if_(self.not(self.computedMember(left, right)), self.lazyAssign(self.computedMember(left, right), "{}")); @@ -11275,6 +11297,7 @@ self.if_(self.notNull(left.context), function() { self.recurse(ast.right, right); self.addEnsureSafeObject(self.member(left.context, left.name, left.computed)); + self.addEnsureSafeAssignContext(left.context); expression = self.member(left.context, left.name, left.computed) + ast.operator + right; self.assign(intoId, expression); recursionFn(intoId || expression); @@ -11385,6 +11408,9 @@ addEnsureSafeFunction: function(item) { this.current().body.push(this.ensureSafeFunction(item), ";"); }, + addEnsureSafeAssignContext: function(item) { + this.current().body.push(this.ensureSafeAssignContext(item), ";"); + }, ensureSafeObject: function(item) { return "ensureSafeObject(" + item + ",text)"; }, @@ -11394,6 +11420,12 @@ ensureSafeFunction: function(item) { return "ensureSafeFunction(" + item + ",text)"; }, + getStringValue: function(item) { + this.assign(item, "getStringValue(" + item + ",text)"); + }, + ensureSafeAssignContext: function(item) { + return "ensureSafeAssignContext(" + item + ",text)"; + }, lazyRecurse: function(ast, intoId, nameId, recursionFn, create, skipWatchIdCheck) { var self = this; return function() { @@ -11561,6 +11593,7 @@ var lhs = left(scope, locals, assign, inputs); var rhs = right(scope, locals, assign, inputs); ensureSafeObject(lhs.value, self.expression); + ensureSafeAssignContext(lhs.context); lhs.context[lhs.name] = rhs; return context ? { value: rhs @@ -11818,6 +11851,7 @@ var value; if (lhs != null) { rhs = right(scope, locals, assign, inputs); + rhs = getStringValue(rhs); ensureSafeMemberName(rhs, expression); if (create && create !== 1 && lhs && !lhs[rhs]) { lhs[rhs] = {}; @@ -13500,6 +13534,7 @@ if (fractionSize > 0 && number < 1) { formatedText = number.toFixed(fractionSize); number = parseFloat(formatedText); + formatedText = formatedText.replace(DECIMAL_SEP, decimalSep); } } if (number === 0) { @@ -15517,11 +15552,11 @@ function updateOptionElement(option, element) { option.element = element; element.disabled = option.disabled; - if (option.value !== element.value) element.value = option.selectValue; if (option.label !== element.label) { element.label = option.label; element.textContent = option.label; } + if (option.value !== element.value) element.value = option.selectValue; } function addOrReuseElement(parent, current, type, templateElement) { var element; @@ -15549,7 +15584,7 @@ var emptyOption_ = emptyOption && emptyOption[0]; var unknownOption_ = unknownOption && unknownOption[0]; if (emptyOption_ || unknownOption_) { - while (current && (current === emptyOption_ || current === unknownOption_)) { + while (current && (current === emptyOption_ || current === unknownOption_ || emptyOption_ && emptyOption_.nodeType === NODE_TYPE_COMMENT)) { current = current.nextSibling; } } diff --git a/lingvodoc/static/js/maps.js b/lingvodoc/static/js/maps.js new file mode 100644 index 000000000..b9d8d3945 --- /dev/null +++ b/lingvodoc/static/js/maps.js @@ -0,0 +1,33823 @@ +(function(global, factory) { + if (typeof module === "object" && typeof module.exports === "object") { + module.exports = global.document ? factory(global, true) : function(w) { + if (!w.document) { + throw new Error("jQuery requires a window with a document"); + } + return factory(w); + }; + } else { + factory(global); + } +})(typeof window !== "undefined" ? window : this, function(window, noGlobal) { + var arr = []; + var slice = arr.slice; + var concat = arr.concat; + var push = arr.push; + var indexOf = arr.indexOf; + var class2type = {}; + var toString = class2type.toString; + var hasOwn = class2type.hasOwnProperty; + var support = {}; + var document = window.document, version = "2.1.4", jQuery = function(selector, context) { + return new jQuery.fn.init(selector, context); + }, rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, rmsPrefix = /^-ms-/, rdashAlpha = /-([\da-z])/gi, fcamelCase = function(all, letter) { + return letter.toUpperCase(); + }; + jQuery.fn = jQuery.prototype = { + jquery: version, + constructor: jQuery, + selector: "", + length: 0, + toArray: function() { + return slice.call(this); + }, + get: function(num) { + return num != null ? num < 0 ? this[num + this.length] : this[num] : slice.call(this); + }, + pushStack: function(elems) { + var ret = jQuery.merge(this.constructor(), elems); + ret.prevObject = this; + ret.context = this.context; + return ret; + }, + each: function(callback, args) { + return jQuery.each(this, callback, args); + }, + map: function(callback) { + return this.pushStack(jQuery.map(this, function(elem, i) { + return callback.call(elem, i, elem); + })); + }, + slice: function() { + return this.pushStack(slice.apply(this, arguments)); + }, + first: function() { + return this.eq(0); + }, + last: function() { + return this.eq(-1); + }, + eq: function(i) { + var len = this.length, j = +i + (i < 0 ? len : 0); + return this.pushStack(j >= 0 && j < len ? [ this[j] ] : []); + }, + end: function() { + return this.prevObject || this.constructor(null); + }, + push: push, + sort: arr.sort, + splice: arr.splice + }; + jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; + if (typeof target === "boolean") { + deep = target; + target = arguments[i] || {}; + i++; + } + if (typeof target !== "object" && !jQuery.isFunction(target)) { + target = {}; + } + if (i === length) { + target = this; + i--; + } + for (;i < length; i++) { + if ((options = arguments[i]) != null) { + for (name in options) { + src = target[name]; + copy = options[name]; + if (target === copy) { + continue; + } + if (deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + target[name] = jQuery.extend(deep, clone, copy); + } else if (copy !== undefined) { + target[name] = copy; + } + } + } + } + return target; + }; + jQuery.extend({ + expando: "jQuery" + (version + Math.random()).replace(/\D/g, ""), + isReady: true, + error: function(msg) { + throw new Error(msg); + }, + noop: function() {}, + isFunction: function(obj) { + return jQuery.type(obj) === "function"; + }, + isArray: Array.isArray, + isWindow: function(obj) { + return obj != null && obj === obj.window; + }, + isNumeric: function(obj) { + return !jQuery.isArray(obj) && obj - parseFloat(obj) + 1 >= 0; + }, + isPlainObject: function(obj) { + if (jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow(obj)) { + return false; + } + if (obj.constructor && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) { + return false; + } + return true; + }, + isEmptyObject: function(obj) { + var name; + for (name in obj) { + return false; + } + return true; + }, + type: function(obj) { + if (obj == null) { + return obj + ""; + } + return typeof obj === "object" || typeof obj === "function" ? class2type[toString.call(obj)] || "object" : typeof obj; + }, + globalEval: function(code) { + var script, indirect = eval; + code = jQuery.trim(code); + if (code) { + if (code.indexOf("use strict") === 1) { + script = document.createElement("script"); + script.text = code; + document.head.appendChild(script).parentNode.removeChild(script); + } else { + indirect(code); + } + } + }, + camelCase: function(string) { + return string.replace(rmsPrefix, "ms-").replace(rdashAlpha, fcamelCase); + }, + nodeName: function(elem, name) { + return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); + }, + each: function(obj, callback, args) { + var value, i = 0, length = obj.length, isArray = isArraylike(obj); + if (args) { + if (isArray) { + for (;i < length; i++) { + value = callback.apply(obj[i], args); + if (value === false) { + break; + } + } + } else { + for (i in obj) { + value = callback.apply(obj[i], args); + if (value === false) { + break; + } + } + } + } else { + if (isArray) { + for (;i < length; i++) { + value = callback.call(obj[i], i, obj[i]); + if (value === false) { + break; + } + } + } else { + for (i in obj) { + value = callback.call(obj[i], i, obj[i]); + if (value === false) { + break; + } + } + } + } + return obj; + }, + trim: function(text) { + return text == null ? "" : (text + "").replace(rtrim, ""); + }, + makeArray: function(arr, results) { + var ret = results || []; + if (arr != null) { + if (isArraylike(Object(arr))) { + jQuery.merge(ret, typeof arr === "string" ? [ arr ] : arr); + } else { + push.call(ret, arr); + } + } + return ret; + }, + inArray: function(elem, arr, i) { + return arr == null ? -1 : indexOf.call(arr, elem, i); + }, + merge: function(first, second) { + var len = +second.length, j = 0, i = first.length; + for (;j < len; j++) { + first[i++] = second[j]; + } + first.length = i; + return first; + }, + grep: function(elems, callback, invert) { + var callbackInverse, matches = [], i = 0, length = elems.length, callbackExpect = !invert; + for (;i < length; i++) { + callbackInverse = !callback(elems[i], i); + if (callbackInverse !== callbackExpect) { + matches.push(elems[i]); + } + } + return matches; + }, + map: function(elems, callback, arg) { + var value, i = 0, length = elems.length, isArray = isArraylike(elems), ret = []; + if (isArray) { + for (;i < length; i++) { + value = callback(elems[i], i, arg); + if (value != null) { + ret.push(value); + } + } + } else { + for (i in elems) { + value = callback(elems[i], i, arg); + if (value != null) { + ret.push(value); + } + } + } + return concat.apply([], ret); + }, + guid: 1, + proxy: function(fn, context) { + var tmp, args, proxy; + if (typeof context === "string") { + tmp = fn[context]; + context = fn; + fn = tmp; + } + if (!jQuery.isFunction(fn)) { + return undefined; + } + args = slice.call(arguments, 2); + proxy = function() { + return fn.apply(context || this, args.concat(slice.call(arguments))); + }; + proxy.guid = fn.guid = fn.guid || jQuery.guid++; + return proxy; + }, + now: Date.now, + support: support + }); + jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { + class2type["[object " + name + "]"] = name.toLowerCase(); + }); + function isArraylike(obj) { + var length = "length" in obj && obj.length, type = jQuery.type(obj); + if (type === "function" || jQuery.isWindow(obj)) { + return false; + } + if (obj.nodeType === 1 && length) { + return true; + } + return type === "array" || length === 0 || typeof length === "number" && length > 0 && length - 1 in obj; + } + var Sizzle = function(window) { + var i, support, Expr, getText, isXML, tokenize, compile, select, outermostContext, sortInput, hasDuplicate, setDocument, document, docElem, documentIsHTML, rbuggyQSA, rbuggyMatches, matches, contains, expando = "sizzle" + 1 * new Date(), preferredDoc = window.document, dirruns = 0, done = 0, classCache = createCache(), tokenCache = createCache(), compilerCache = createCache(), sortOrder = function(a, b) { + if (a === b) { + hasDuplicate = true; + } + return 0; + }, MAX_NEGATIVE = 1 << 31, hasOwn = {}.hasOwnProperty, arr = [], pop = arr.pop, push_native = arr.push, push = arr.push, slice = arr.slice, indexOf = function(list, elem) { + var i = 0, len = list.length; + for (;i < len; i++) { + if (list[i] === elem) { + return i; + } + } + return -1; + }, booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", whitespace = "[\\x20\\t\\r\\n\\f]", characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", identifier = characterEncoding.replace("w", "w#"), attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace + "*([*^$|!~]?=)" + whitespace + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + "*\\]", pseudos = ":(" + characterEncoding + ")(?:\\((" + "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + ".*" + ")\\)|)", rwhitespace = new RegExp(whitespace + "+", "g"), rtrim = new RegExp("^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g"), rcomma = new RegExp("^" + whitespace + "*," + whitespace + "*"), rcombinators = new RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*"), rattributeQuotes = new RegExp("=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g"), rpseudo = new RegExp(pseudos), ridentifier = new RegExp("^" + identifier + "$"), matchExpr = { + ID: new RegExp("^#(" + characterEncoding + ")"), + CLASS: new RegExp("^\\.(" + characterEncoding + ")"), + TAG: new RegExp("^(" + characterEncoding.replace("w", "w*") + ")"), + ATTR: new RegExp("^" + attributes), + PSEUDO: new RegExp("^" + pseudos), + CHILD: new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i"), + bool: new RegExp("^(?:" + booleans + ")$", "i"), + needsContext: new RegExp("^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i") + }, rinputs = /^(?:input|select|textarea|button)$/i, rheader = /^h\d$/i, rnative = /^[^{]+\{\s*\[native \w/, rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, rsibling = /[+~]/, rescape = /'|\\/g, runescape = new RegExp("\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig"), funescape = function(_, escaped, escapedWhitespace) { + var high = "0x" + escaped - 65536; + return high !== high || escapedWhitespace ? escaped : high < 0 ? String.fromCharCode(high + 65536) : String.fromCharCode(high >> 10 | 55296, high & 1023 | 56320); + }, unloadHandler = function() { + setDocument(); + }; + try { + push.apply(arr = slice.call(preferredDoc.childNodes), preferredDoc.childNodes); + arr[preferredDoc.childNodes.length].nodeType; + } catch (e) { + push = { + apply: arr.length ? function(target, els) { + push_native.apply(target, slice.call(els)); + } : function(target, els) { + var j = target.length, i = 0; + while (target[j++] = els[i++]) {} + target.length = j - 1; + } + }; + } + function Sizzle(selector, context, results, seed) { + var match, elem, m, nodeType, i, groups, old, nid, newContext, newSelector; + if ((context ? context.ownerDocument || context : preferredDoc) !== document) { + setDocument(context); + } + context = context || document; + results = results || []; + nodeType = context.nodeType; + if (typeof selector !== "string" || !selector || nodeType !== 1 && nodeType !== 9 && nodeType !== 11) { + return results; + } + if (!seed && documentIsHTML) { + if (nodeType !== 11 && (match = rquickExpr.exec(selector))) { + if (m = match[1]) { + if (nodeType === 9) { + elem = context.getElementById(m); + if (elem && elem.parentNode) { + if (elem.id === m) { + results.push(elem); + return results; + } + } else { + return results; + } + } else { + if (context.ownerDocument && (elem = context.ownerDocument.getElementById(m)) && contains(context, elem) && elem.id === m) { + results.push(elem); + return results; + } + } + } else if (match[2]) { + push.apply(results, context.getElementsByTagName(selector)); + return results; + } else if ((m = match[3]) && support.getElementsByClassName) { + push.apply(results, context.getElementsByClassName(m)); + return results; + } + } + if (support.qsa && (!rbuggyQSA || !rbuggyQSA.test(selector))) { + nid = old = expando; + newContext = context; + newSelector = nodeType !== 1 && selector; + if (nodeType === 1 && context.nodeName.toLowerCase() !== "object") { + groups = tokenize(selector); + if (old = context.getAttribute("id")) { + nid = old.replace(rescape, "\\$&"); + } else { + context.setAttribute("id", nid); + } + nid = "[id='" + nid + "'] "; + i = groups.length; + while (i--) { + groups[i] = nid + toSelector(groups[i]); + } + newContext = rsibling.test(selector) && testContext(context.parentNode) || context; + newSelector = groups.join(","); + } + if (newSelector) { + try { + push.apply(results, newContext.querySelectorAll(newSelector)); + return results; + } catch (qsaError) {} finally { + if (!old) { + context.removeAttribute("id"); + } + } + } + } + } + return select(selector.replace(rtrim, "$1"), context, results, seed); + } + function createCache() { + var keys = []; + function cache(key, value) { + if (keys.push(key + " ") > Expr.cacheLength) { + delete cache[keys.shift()]; + } + return cache[key + " "] = value; + } + return cache; + } + function markFunction(fn) { + fn[expando] = true; + return fn; + } + function assert(fn) { + var div = document.createElement("div"); + try { + return !!fn(div); + } catch (e) { + return false; + } finally { + if (div.parentNode) { + div.parentNode.removeChild(div); + } + div = null; + } + } + function addHandle(attrs, handler) { + var arr = attrs.split("|"), i = attrs.length; + while (i--) { + Expr.attrHandle[arr[i]] = handler; + } + } + function siblingCheck(a, b) { + var cur = b && a, diff = cur && a.nodeType === 1 && b.nodeType === 1 && (~b.sourceIndex || MAX_NEGATIVE) - (~a.sourceIndex || MAX_NEGATIVE); + if (diff) { + return diff; + } + if (cur) { + while (cur = cur.nextSibling) { + if (cur === b) { + return -1; + } + } + } + return a ? 1 : -1; + } + function createInputPseudo(type) { + return function(elem) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === type; + }; + } + function createButtonPseudo(type) { + return function(elem) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && elem.type === type; + }; + } + function createPositionalPseudo(fn) { + return markFunction(function(argument) { + argument = +argument; + return markFunction(function(seed, matches) { + var j, matchIndexes = fn([], seed.length, argument), i = matchIndexes.length; + while (i--) { + if (seed[j = matchIndexes[i]]) { + seed[j] = !(matches[j] = seed[j]); + } + } + }); + }); + } + function testContext(context) { + return context && typeof context.getElementsByTagName !== "undefined" && context; + } + support = Sizzle.support = {}; + isXML = Sizzle.isXML = function(elem) { + var documentElement = elem && (elem.ownerDocument || elem).documentElement; + return documentElement ? documentElement.nodeName !== "HTML" : false; + }; + setDocument = Sizzle.setDocument = function(node) { + var hasCompare, parent, doc = node ? node.ownerDocument || node : preferredDoc; + if (doc === document || doc.nodeType !== 9 || !doc.documentElement) { + return document; + } + document = doc; + docElem = doc.documentElement; + parent = doc.defaultView; + if (parent && parent !== parent.top) { + if (parent.addEventListener) { + parent.addEventListener("unload", unloadHandler, false); + } else if (parent.attachEvent) { + parent.attachEvent("onunload", unloadHandler); + } + } + documentIsHTML = !isXML(doc); + support.attributes = assert(function(div) { + div.className = "i"; + return !div.getAttribute("className"); + }); + support.getElementsByTagName = assert(function(div) { + div.appendChild(doc.createComment("")); + return !div.getElementsByTagName("*").length; + }); + support.getElementsByClassName = rnative.test(doc.getElementsByClassName); + support.getById = assert(function(div) { + docElem.appendChild(div).id = expando; + return !doc.getElementsByName || !doc.getElementsByName(expando).length; + }); + if (support.getById) { + Expr.find["ID"] = function(id, context) { + if (typeof context.getElementById !== "undefined" && documentIsHTML) { + var m = context.getElementById(id); + return m && m.parentNode ? [ m ] : []; + } + }; + Expr.filter["ID"] = function(id) { + var attrId = id.replace(runescape, funescape); + return function(elem) { + return elem.getAttribute("id") === attrId; + }; + }; + } else { + delete Expr.find["ID"]; + Expr.filter["ID"] = function(id) { + var attrId = id.replace(runescape, funescape); + return function(elem) { + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); + return node && node.value === attrId; + }; + }; + } + Expr.find["TAG"] = support.getElementsByTagName ? function(tag, context) { + if (typeof context.getElementsByTagName !== "undefined") { + return context.getElementsByTagName(tag); + } else if (support.qsa) { + return context.querySelectorAll(tag); + } + } : function(tag, context) { + var elem, tmp = [], i = 0, results = context.getElementsByTagName(tag); + if (tag === "*") { + while (elem = results[i++]) { + if (elem.nodeType === 1) { + tmp.push(elem); + } + } + return tmp; + } + return results; + }; + Expr.find["CLASS"] = support.getElementsByClassName && function(className, context) { + if (documentIsHTML) { + return context.getElementsByClassName(className); + } + }; + rbuggyMatches = []; + rbuggyQSA = []; + if (support.qsa = rnative.test(doc.querySelectorAll)) { + assert(function(div) { + docElem.appendChild(div).innerHTML = "" + ""; + if (div.querySelectorAll("[msallowcapture^='']").length) { + rbuggyQSA.push("[*^$]=" + whitespace + "*(?:''|\"\")"); + } + if (!div.querySelectorAll("[selected]").length) { + rbuggyQSA.push("\\[" + whitespace + "*(?:value|" + booleans + ")"); + } + if (!div.querySelectorAll("[id~=" + expando + "-]").length) { + rbuggyQSA.push("~="); + } + if (!div.querySelectorAll(":checked").length) { + rbuggyQSA.push(":checked"); + } + if (!div.querySelectorAll("a#" + expando + "+*").length) { + rbuggyQSA.push(".#.+[+~]"); + } + }); + assert(function(div) { + var input = doc.createElement("input"); + input.setAttribute("type", "hidden"); + div.appendChild(input).setAttribute("name", "D"); + if (div.querySelectorAll("[name=d]").length) { + rbuggyQSA.push("name" + whitespace + "*[*^$|!~]?="); + } + if (!div.querySelectorAll(":enabled").length) { + rbuggyQSA.push(":enabled", ":disabled"); + } + div.querySelectorAll("*,:x"); + rbuggyQSA.push(",.*:"); + }); + } + if (support.matchesSelector = rnative.test(matches = docElem.matches || docElem.webkitMatchesSelector || docElem.mozMatchesSelector || docElem.oMatchesSelector || docElem.msMatchesSelector)) { + assert(function(div) { + support.disconnectedMatch = matches.call(div, "div"); + matches.call(div, "[s!='']:x"); + rbuggyMatches.push("!=", pseudos); + }); + } + rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join("|")); + rbuggyMatches = rbuggyMatches.length && new RegExp(rbuggyMatches.join("|")); + hasCompare = rnative.test(docElem.compareDocumentPosition); + contains = hasCompare || rnative.test(docElem.contains) ? function(a, b) { + var adown = a.nodeType === 9 ? a.documentElement : a, bup = b && b.parentNode; + return a === bup || !!(bup && bup.nodeType === 1 && (adown.contains ? adown.contains(bup) : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16)); + } : function(a, b) { + if (b) { + while (b = b.parentNode) { + if (b === a) { + return true; + } + } + } + return false; + }; + sortOrder = hasCompare ? function(a, b) { + if (a === b) { + hasDuplicate = true; + return 0; + } + var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; + if (compare) { + return compare; + } + compare = (a.ownerDocument || a) === (b.ownerDocument || b) ? a.compareDocumentPosition(b) : 1; + if (compare & 1 || !support.sortDetached && b.compareDocumentPosition(a) === compare) { + if (a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a)) { + return -1; + } + if (b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b)) { + return 1; + } + return sortInput ? indexOf(sortInput, a) - indexOf(sortInput, b) : 0; + } + return compare & 4 ? -1 : 1; + } : function(a, b) { + if (a === b) { + hasDuplicate = true; + return 0; + } + var cur, i = 0, aup = a.parentNode, bup = b.parentNode, ap = [ a ], bp = [ b ]; + if (!aup || !bup) { + return a === doc ? -1 : b === doc ? 1 : aup ? -1 : bup ? 1 : sortInput ? indexOf(sortInput, a) - indexOf(sortInput, b) : 0; + } else if (aup === bup) { + return siblingCheck(a, b); + } + cur = a; + while (cur = cur.parentNode) { + ap.unshift(cur); + } + cur = b; + while (cur = cur.parentNode) { + bp.unshift(cur); + } + while (ap[i] === bp[i]) { + i++; + } + return i ? siblingCheck(ap[i], bp[i]) : ap[i] === preferredDoc ? -1 : bp[i] === preferredDoc ? 1 : 0; + }; + return doc; + }; + Sizzle.matches = function(expr, elements) { + return Sizzle(expr, null, null, elements); + }; + Sizzle.matchesSelector = function(elem, expr) { + if ((elem.ownerDocument || elem) !== document) { + setDocument(elem); + } + expr = expr.replace(rattributeQuotes, "='$1']"); + if (support.matchesSelector && documentIsHTML && (!rbuggyMatches || !rbuggyMatches.test(expr)) && (!rbuggyQSA || !rbuggyQSA.test(expr))) { + try { + var ret = matches.call(elem, expr); + if (ret || support.disconnectedMatch || elem.document && elem.document.nodeType !== 11) { + return ret; + } + } catch (e) {} + } + return Sizzle(expr, document, null, [ elem ]).length > 0; + }; + Sizzle.contains = function(context, elem) { + if ((context.ownerDocument || context) !== document) { + setDocument(context); + } + return contains(context, elem); + }; + Sizzle.attr = function(elem, name) { + if ((elem.ownerDocument || elem) !== document) { + setDocument(elem); + } + var fn = Expr.attrHandle[name.toLowerCase()], val = fn && hasOwn.call(Expr.attrHandle, name.toLowerCase()) ? fn(elem, name, !documentIsHTML) : undefined; + return val !== undefined ? val : support.attributes || !documentIsHTML ? elem.getAttribute(name) : (val = elem.getAttributeNode(name)) && val.specified ? val.value : null; + }; + Sizzle.error = function(msg) { + throw new Error("Syntax error, unrecognized expression: " + msg); + }; + Sizzle.uniqueSort = function(results) { + var elem, duplicates = [], j = 0, i = 0; + hasDuplicate = !support.detectDuplicates; + sortInput = !support.sortStable && results.slice(0); + results.sort(sortOrder); + if (hasDuplicate) { + while (elem = results[i++]) { + if (elem === results[i]) { + j = duplicates.push(i); + } + } + while (j--) { + results.splice(duplicates[j], 1); + } + } + sortInput = null; + return results; + }; + getText = Sizzle.getText = function(elem) { + var node, ret = "", i = 0, nodeType = elem.nodeType; + if (!nodeType) { + while (node = elem[i++]) { + ret += getText(node); + } + } else if (nodeType === 1 || nodeType === 9 || nodeType === 11) { + if (typeof elem.textContent === "string") { + return elem.textContent; + } else { + for (elem = elem.firstChild; elem; elem = elem.nextSibling) { + ret += getText(elem); + } + } + } else if (nodeType === 3 || nodeType === 4) { + return elem.nodeValue; + } + return ret; + }; + Expr = Sizzle.selectors = { + cacheLength: 50, + createPseudo: markFunction, + match: matchExpr, + attrHandle: {}, + find: {}, + relative: { + ">": { + dir: "parentNode", + first: true + }, + " ": { + dir: "parentNode" + }, + "+": { + dir: "previousSibling", + first: true + }, + "~": { + dir: "previousSibling" + } + }, + preFilter: { + ATTR: function(match) { + match[1] = match[1].replace(runescape, funescape); + match[3] = (match[3] || match[4] || match[5] || "").replace(runescape, funescape); + if (match[2] === "~=") { + match[3] = " " + match[3] + " "; + } + return match.slice(0, 4); + }, + CHILD: function(match) { + match[1] = match[1].toLowerCase(); + if (match[1].slice(0, 3) === "nth") { + if (!match[3]) { + Sizzle.error(match[0]); + } + match[4] = +(match[4] ? match[5] + (match[6] || 1) : 2 * (match[3] === "even" || match[3] === "odd")); + match[5] = +(match[7] + match[8] || match[3] === "odd"); + } else if (match[3]) { + Sizzle.error(match[0]); + } + return match; + }, + PSEUDO: function(match) { + var excess, unquoted = !match[6] && match[2]; + if (matchExpr["CHILD"].test(match[0])) { + return null; + } + if (match[3]) { + match[2] = match[4] || match[5] || ""; + } else if (unquoted && rpseudo.test(unquoted) && (excess = tokenize(unquoted, true)) && (excess = unquoted.indexOf(")", unquoted.length - excess) - unquoted.length)) { + match[0] = match[0].slice(0, excess); + match[2] = unquoted.slice(0, excess); + } + return match.slice(0, 3); + } + }, + filter: { + TAG: function(nodeNameSelector) { + var nodeName = nodeNameSelector.replace(runescape, funescape).toLowerCase(); + return nodeNameSelector === "*" ? function() { + return true; + } : function(elem) { + return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; + }; + }, + CLASS: function(className) { + var pattern = classCache[className + " "]; + return pattern || (pattern = new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)")) && classCache(className, function(elem) { + return pattern.test(typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || ""); + }); + }, + ATTR: function(name, operator, check) { + return function(elem) { + var result = Sizzle.attr(elem, name); + if (result == null) { + return operator === "!="; + } + if (!operator) { + return true; + } + result += ""; + return operator === "=" ? result === check : operator === "!=" ? result !== check : operator === "^=" ? check && result.indexOf(check) === 0 : operator === "*=" ? check && result.indexOf(check) > -1 : operator === "$=" ? check && result.slice(-check.length) === check : operator === "~=" ? (" " + result.replace(rwhitespace, " ") + " ").indexOf(check) > -1 : operator === "|=" ? result === check || result.slice(0, check.length + 1) === check + "-" : false; + }; + }, + CHILD: function(type, what, argument, first, last) { + var simple = type.slice(0, 3) !== "nth", forward = type.slice(-4) !== "last", ofType = what === "of-type"; + return first === 1 && last === 0 ? function(elem) { + return !!elem.parentNode; + } : function(elem, context, xml) { + var cache, outerCache, node, diff, nodeIndex, start, dir = simple !== forward ? "nextSibling" : "previousSibling", parent = elem.parentNode, name = ofType && elem.nodeName.toLowerCase(), useCache = !xml && !ofType; + if (parent) { + if (simple) { + while (dir) { + node = elem; + while (node = node[dir]) { + if (ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) { + return false; + } + } + start = dir = type === "only" && !start && "nextSibling"; + } + return true; + } + start = [ forward ? parent.firstChild : parent.lastChild ]; + if (forward && useCache) { + outerCache = parent[expando] || (parent[expando] = {}); + cache = outerCache[type] || []; + nodeIndex = cache[0] === dirruns && cache[1]; + diff = cache[0] === dirruns && cache[2]; + node = nodeIndex && parent.childNodes[nodeIndex]; + while (node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop()) { + if (node.nodeType === 1 && ++diff && node === elem) { + outerCache[type] = [ dirruns, nodeIndex, diff ]; + break; + } + } + } else if (useCache && (cache = (elem[expando] || (elem[expando] = {}))[type]) && cache[0] === dirruns) { + diff = cache[1]; + } else { + while (node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop()) { + if ((ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) && ++diff) { + if (useCache) { + (node[expando] || (node[expando] = {}))[type] = [ dirruns, diff ]; + } + if (node === elem) { + break; + } + } + } + } + diff -= last; + return diff === first || diff % first === 0 && diff / first >= 0; + } + }; + }, + PSEUDO: function(pseudo, argument) { + var args, fn = Expr.pseudos[pseudo] || Expr.setFilters[pseudo.toLowerCase()] || Sizzle.error("unsupported pseudo: " + pseudo); + if (fn[expando]) { + return fn(argument); + } + if (fn.length > 1) { + args = [ pseudo, pseudo, "", argument ]; + return Expr.setFilters.hasOwnProperty(pseudo.toLowerCase()) ? markFunction(function(seed, matches) { + var idx, matched = fn(seed, argument), i = matched.length; + while (i--) { + idx = indexOf(seed, matched[i]); + seed[idx] = !(matches[idx] = matched[i]); + } + }) : function(elem) { + return fn(elem, 0, args); + }; + } + return fn; + } + }, + pseudos: { + not: markFunction(function(selector) { + var input = [], results = [], matcher = compile(selector.replace(rtrim, "$1")); + return matcher[expando] ? markFunction(function(seed, matches, context, xml) { + var elem, unmatched = matcher(seed, null, xml, []), i = seed.length; + while (i--) { + if (elem = unmatched[i]) { + seed[i] = !(matches[i] = elem); + } + } + }) : function(elem, context, xml) { + input[0] = elem; + matcher(input, null, xml, results); + input[0] = null; + return !results.pop(); + }; + }), + has: markFunction(function(selector) { + return function(elem) { + return Sizzle(selector, elem).length > 0; + }; + }), + contains: markFunction(function(text) { + text = text.replace(runescape, funescape); + return function(elem) { + return (elem.textContent || elem.innerText || getText(elem)).indexOf(text) > -1; + }; + }), + lang: markFunction(function(lang) { + if (!ridentifier.test(lang || "")) { + Sizzle.error("unsupported lang: " + lang); + } + lang = lang.replace(runescape, funescape).toLowerCase(); + return function(elem) { + var elemLang; + do { + if (elemLang = documentIsHTML ? elem.lang : elem.getAttribute("xml:lang") || elem.getAttribute("lang")) { + elemLang = elemLang.toLowerCase(); + return elemLang === lang || elemLang.indexOf(lang + "-") === 0; + } + } while ((elem = elem.parentNode) && elem.nodeType === 1); + return false; + }; + }), + target: function(elem) { + var hash = window.location && window.location.hash; + return hash && hash.slice(1) === elem.id; + }, + root: function(elem) { + return elem === docElem; + }, + focus: function(elem) { + return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); + }, + enabled: function(elem) { + return elem.disabled === false; + }, + disabled: function(elem) { + return elem.disabled === true; + }, + checked: function(elem) { + var nodeName = elem.nodeName.toLowerCase(); + return nodeName === "input" && !!elem.checked || nodeName === "option" && !!elem.selected; + }, + selected: function(elem) { + if (elem.parentNode) { + elem.parentNode.selectedIndex; + } + return elem.selected === true; + }, + empty: function(elem) { + for (elem = elem.firstChild; elem; elem = elem.nextSibling) { + if (elem.nodeType < 6) { + return false; + } + } + return true; + }, + parent: function(elem) { + return !Expr.pseudos["empty"](elem); + }, + header: function(elem) { + return rheader.test(elem.nodeName); + }, + input: function(elem) { + return rinputs.test(elem.nodeName); + }, + button: function(elem) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === "button" || name === "button"; + }, + text: function(elem) { + var attr; + return elem.nodeName.toLowerCase() === "input" && elem.type === "text" && ((attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text"); + }, + first: createPositionalPseudo(function() { + return [ 0 ]; + }), + last: createPositionalPseudo(function(matchIndexes, length) { + return [ length - 1 ]; + }), + eq: createPositionalPseudo(function(matchIndexes, length, argument) { + return [ argument < 0 ? argument + length : argument ]; + }), + even: createPositionalPseudo(function(matchIndexes, length) { + var i = 0; + for (;i < length; i += 2) { + matchIndexes.push(i); + } + return matchIndexes; + }), + odd: createPositionalPseudo(function(matchIndexes, length) { + var i = 1; + for (;i < length; i += 2) { + matchIndexes.push(i); + } + return matchIndexes; + }), + lt: createPositionalPseudo(function(matchIndexes, length, argument) { + var i = argument < 0 ? argument + length : argument; + for (;--i >= 0; ) { + matchIndexes.push(i); + } + return matchIndexes; + }), + gt: createPositionalPseudo(function(matchIndexes, length, argument) { + var i = argument < 0 ? argument + length : argument; + for (;++i < length; ) { + matchIndexes.push(i); + } + return matchIndexes; + }) + } + }; + Expr.pseudos["nth"] = Expr.pseudos["eq"]; + for (i in { + radio: true, + checkbox: true, + file: true, + password: true, + image: true + }) { + Expr.pseudos[i] = createInputPseudo(i); + } + for (i in { + submit: true, + reset: true + }) { + Expr.pseudos[i] = createButtonPseudo(i); + } + function setFilters() {} + setFilters.prototype = Expr.filters = Expr.pseudos; + Expr.setFilters = new setFilters(); + tokenize = Sizzle.tokenize = function(selector, parseOnly) { + var matched, match, tokens, type, soFar, groups, preFilters, cached = tokenCache[selector + " "]; + if (cached) { + return parseOnly ? 0 : cached.slice(0); + } + soFar = selector; + groups = []; + preFilters = Expr.preFilter; + while (soFar) { + if (!matched || (match = rcomma.exec(soFar))) { + if (match) { + soFar = soFar.slice(match[0].length) || soFar; + } + groups.push(tokens = []); + } + matched = false; + if (match = rcombinators.exec(soFar)) { + matched = match.shift(); + tokens.push({ + value: matched, + type: match[0].replace(rtrim, " ") + }); + soFar = soFar.slice(matched.length); + } + for (type in Expr.filter) { + if ((match = matchExpr[type].exec(soFar)) && (!preFilters[type] || (match = preFilters[type](match)))) { + matched = match.shift(); + tokens.push({ + value: matched, + type: type, + matches: match + }); + soFar = soFar.slice(matched.length); + } + } + if (!matched) { + break; + } + } + return parseOnly ? soFar.length : soFar ? Sizzle.error(selector) : tokenCache(selector, groups).slice(0); + }; + function toSelector(tokens) { + var i = 0, len = tokens.length, selector = ""; + for (;i < len; i++) { + selector += tokens[i].value; + } + return selector; + } + function addCombinator(matcher, combinator, base) { + var dir = combinator.dir, checkNonElements = base && dir === "parentNode", doneName = done++; + return combinator.first ? function(elem, context, xml) { + while (elem = elem[dir]) { + if (elem.nodeType === 1 || checkNonElements) { + return matcher(elem, context, xml); + } + } + } : function(elem, context, xml) { + var oldCache, outerCache, newCache = [ dirruns, doneName ]; + if (xml) { + while (elem = elem[dir]) { + if (elem.nodeType === 1 || checkNonElements) { + if (matcher(elem, context, xml)) { + return true; + } + } + } + } else { + while (elem = elem[dir]) { + if (elem.nodeType === 1 || checkNonElements) { + outerCache = elem[expando] || (elem[expando] = {}); + if ((oldCache = outerCache[dir]) && oldCache[0] === dirruns && oldCache[1] === doneName) { + return newCache[2] = oldCache[2]; + } else { + outerCache[dir] = newCache; + if (newCache[2] = matcher(elem, context, xml)) { + return true; + } + } + } + } + } + }; + } + function elementMatcher(matchers) { + return matchers.length > 1 ? function(elem, context, xml) { + var i = matchers.length; + while (i--) { + if (!matchers[i](elem, context, xml)) { + return false; + } + } + return true; + } : matchers[0]; + } + function multipleContexts(selector, contexts, results) { + var i = 0, len = contexts.length; + for (;i < len; i++) { + Sizzle(selector, contexts[i], results); + } + return results; + } + function condense(unmatched, map, filter, context, xml) { + var elem, newUnmatched = [], i = 0, len = unmatched.length, mapped = map != null; + for (;i < len; i++) { + if (elem = unmatched[i]) { + if (!filter || filter(elem, context, xml)) { + newUnmatched.push(elem); + if (mapped) { + map.push(i); + } + } + } + } + return newUnmatched; + } + function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector) { + if (postFilter && !postFilter[expando]) { + postFilter = setMatcher(postFilter); + } + if (postFinder && !postFinder[expando]) { + postFinder = setMatcher(postFinder, postSelector); + } + return markFunction(function(seed, results, context, xml) { + var temp, i, elem, preMap = [], postMap = [], preexisting = results.length, elems = seed || multipleContexts(selector || "*", context.nodeType ? [ context ] : context, []), matcherIn = preFilter && (seed || !selector) ? condense(elems, preMap, preFilter, context, xml) : elems, matcherOut = matcher ? postFinder || (seed ? preFilter : preexisting || postFilter) ? [] : results : matcherIn; + if (matcher) { + matcher(matcherIn, matcherOut, context, xml); + } + if (postFilter) { + temp = condense(matcherOut, postMap); + postFilter(temp, [], context, xml); + i = temp.length; + while (i--) { + if (elem = temp[i]) { + matcherOut[postMap[i]] = !(matcherIn[postMap[i]] = elem); + } + } + } + if (seed) { + if (postFinder || preFilter) { + if (postFinder) { + temp = []; + i = matcherOut.length; + while (i--) { + if (elem = matcherOut[i]) { + temp.push(matcherIn[i] = elem); + } + } + postFinder(null, matcherOut = [], temp, xml); + } + i = matcherOut.length; + while (i--) { + if ((elem = matcherOut[i]) && (temp = postFinder ? indexOf(seed, elem) : preMap[i]) > -1) { + seed[temp] = !(results[temp] = elem); + } + } + } + } else { + matcherOut = condense(matcherOut === results ? matcherOut.splice(preexisting, matcherOut.length) : matcherOut); + if (postFinder) { + postFinder(null, results, matcherOut, xml); + } else { + push.apply(results, matcherOut); + } + } + }); + } + function matcherFromTokens(tokens) { + var checkContext, matcher, j, len = tokens.length, leadingRelative = Expr.relative[tokens[0].type], implicitRelative = leadingRelative || Expr.relative[" "], i = leadingRelative ? 1 : 0, matchContext = addCombinator(function(elem) { + return elem === checkContext; + }, implicitRelative, true), matchAnyContext = addCombinator(function(elem) { + return indexOf(checkContext, elem) > -1; + }, implicitRelative, true), matchers = [ function(elem, context, xml) { + var ret = !leadingRelative && (xml || context !== outermostContext) || ((checkContext = context).nodeType ? matchContext(elem, context, xml) : matchAnyContext(elem, context, xml)); + checkContext = null; + return ret; + } ]; + for (;i < len; i++) { + if (matcher = Expr.relative[tokens[i].type]) { + matchers = [ addCombinator(elementMatcher(matchers), matcher) ]; + } else { + matcher = Expr.filter[tokens[i].type].apply(null, tokens[i].matches); + if (matcher[expando]) { + j = ++i; + for (;j < len; j++) { + if (Expr.relative[tokens[j].type]) { + break; + } + } + return setMatcher(i > 1 && elementMatcher(matchers), i > 1 && toSelector(tokens.slice(0, i - 1).concat({ + value: tokens[i - 2].type === " " ? "*" : "" + })).replace(rtrim, "$1"), matcher, i < j && matcherFromTokens(tokens.slice(i, j)), j < len && matcherFromTokens(tokens = tokens.slice(j)), j < len && toSelector(tokens)); + } + matchers.push(matcher); + } + } + return elementMatcher(matchers); + } + function matcherFromGroupMatchers(elementMatchers, setMatchers) { + var bySet = setMatchers.length > 0, byElement = elementMatchers.length > 0, superMatcher = function(seed, context, xml, results, outermost) { + var elem, j, matcher, matchedCount = 0, i = "0", unmatched = seed && [], setMatched = [], contextBackup = outermostContext, elems = seed || byElement && Expr.find["TAG"]("*", outermost), dirrunsUnique = dirruns += contextBackup == null ? 1 : Math.random() || .1, len = elems.length; + if (outermost) { + outermostContext = context !== document && context; + } + for (;i !== len && (elem = elems[i]) != null; i++) { + if (byElement && elem) { + j = 0; + while (matcher = elementMatchers[j++]) { + if (matcher(elem, context, xml)) { + results.push(elem); + break; + } + } + if (outermost) { + dirruns = dirrunsUnique; + } + } + if (bySet) { + if (elem = !matcher && elem) { + matchedCount--; + } + if (seed) { + unmatched.push(elem); + } + } + } + matchedCount += i; + if (bySet && i !== matchedCount) { + j = 0; + while (matcher = setMatchers[j++]) { + matcher(unmatched, setMatched, context, xml); + } + if (seed) { + if (matchedCount > 0) { + while (i--) { + if (!(unmatched[i] || setMatched[i])) { + setMatched[i] = pop.call(results); + } + } + } + setMatched = condense(setMatched); + } + push.apply(results, setMatched); + if (outermost && !seed && setMatched.length > 0 && matchedCount + setMatchers.length > 1) { + Sizzle.uniqueSort(results); + } + } + if (outermost) { + dirruns = dirrunsUnique; + outermostContext = contextBackup; + } + return unmatched; + }; + return bySet ? markFunction(superMatcher) : superMatcher; + } + compile = Sizzle.compile = function(selector, match) { + var i, setMatchers = [], elementMatchers = [], cached = compilerCache[selector + " "]; + if (!cached) { + if (!match) { + match = tokenize(selector); + } + i = match.length; + while (i--) { + cached = matcherFromTokens(match[i]); + if (cached[expando]) { + setMatchers.push(cached); + } else { + elementMatchers.push(cached); + } + } + cached = compilerCache(selector, matcherFromGroupMatchers(elementMatchers, setMatchers)); + cached.selector = selector; + } + return cached; + }; + select = Sizzle.select = function(selector, context, results, seed) { + var i, tokens, token, type, find, compiled = typeof selector === "function" && selector, match = !seed && tokenize(selector = compiled.selector || selector); + results = results || []; + if (match.length === 1) { + tokens = match[0] = match[0].slice(0); + if (tokens.length > 2 && (token = tokens[0]).type === "ID" && support.getById && context.nodeType === 9 && documentIsHTML && Expr.relative[tokens[1].type]) { + context = (Expr.find["ID"](token.matches[0].replace(runescape, funescape), context) || [])[0]; + if (!context) { + return results; + } else if (compiled) { + context = context.parentNode; + } + selector = selector.slice(tokens.shift().value.length); + } + i = matchExpr["needsContext"].test(selector) ? 0 : tokens.length; + while (i--) { + token = tokens[i]; + if (Expr.relative[type = token.type]) { + break; + } + if (find = Expr.find[type]) { + if (seed = find(token.matches[0].replace(runescape, funescape), rsibling.test(tokens[0].type) && testContext(context.parentNode) || context)) { + tokens.splice(i, 1); + selector = seed.length && toSelector(tokens); + if (!selector) { + push.apply(results, seed); + return results; + } + break; + } + } + } + } + (compiled || compile(selector, match))(seed, context, !documentIsHTML, results, rsibling.test(selector) && testContext(context.parentNode) || context); + return results; + }; + support.sortStable = expando.split("").sort(sortOrder).join("") === expando; + support.detectDuplicates = !!hasDuplicate; + setDocument(); + support.sortDetached = assert(function(div1) { + return div1.compareDocumentPosition(document.createElement("div")) & 1; + }); + if (!assert(function(div) { + div.innerHTML = ""; + return div.firstChild.getAttribute("href") === "#"; + })) { + addHandle("type|href|height|width", function(elem, name, isXML) { + if (!isXML) { + return elem.getAttribute(name, name.toLowerCase() === "type" ? 1 : 2); + } + }); + } + if (!support.attributes || !assert(function(div) { + div.innerHTML = ""; + div.firstChild.setAttribute("value", ""); + return div.firstChild.getAttribute("value") === ""; + })) { + addHandle("value", function(elem, name, isXML) { + if (!isXML && elem.nodeName.toLowerCase() === "input") { + return elem.defaultValue; + } + }); + } + if (!assert(function(div) { + return div.getAttribute("disabled") == null; + })) { + addHandle(booleans, function(elem, name, isXML) { + var val; + if (!isXML) { + return elem[name] === true ? name.toLowerCase() : (val = elem.getAttributeNode(name)) && val.specified ? val.value : null; + } + }); + } + return Sizzle; + }(window); + jQuery.find = Sizzle; + jQuery.expr = Sizzle.selectors; + jQuery.expr[":"] = jQuery.expr.pseudos; + jQuery.unique = Sizzle.uniqueSort; + jQuery.text = Sizzle.getText; + jQuery.isXMLDoc = Sizzle.isXML; + jQuery.contains = Sizzle.contains; + var rneedsContext = jQuery.expr.match.needsContext; + var rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/; + var risSimple = /^.[^:#\[\.,]*$/; + function winnow(elements, qualifier, not) { + if (jQuery.isFunction(qualifier)) { + return jQuery.grep(elements, function(elem, i) { + return !!qualifier.call(elem, i, elem) !== not; + }); + } + if (qualifier.nodeType) { + return jQuery.grep(elements, function(elem) { + return elem === qualifier !== not; + }); + } + if (typeof qualifier === "string") { + if (risSimple.test(qualifier)) { + return jQuery.filter(qualifier, elements, not); + } + qualifier = jQuery.filter(qualifier, elements); + } + return jQuery.grep(elements, function(elem) { + return indexOf.call(qualifier, elem) >= 0 !== not; + }); + } + jQuery.filter = function(expr, elems, not) { + var elem = elems[0]; + if (not) { + expr = ":not(" + expr + ")"; + } + return elems.length === 1 && elem.nodeType === 1 ? jQuery.find.matchesSelector(elem, expr) ? [ elem ] : [] : jQuery.find.matches(expr, jQuery.grep(elems, function(elem) { + return elem.nodeType === 1; + })); + }; + jQuery.fn.extend({ + find: function(selector) { + var i, len = this.length, ret = [], self = this; + if (typeof selector !== "string") { + return this.pushStack(jQuery(selector).filter(function() { + for (i = 0; i < len; i++) { + if (jQuery.contains(self[i], this)) { + return true; + } + } + })); + } + for (i = 0; i < len; i++) { + jQuery.find(selector, self[i], ret); + } + ret = this.pushStack(len > 1 ? jQuery.unique(ret) : ret); + ret.selector = this.selector ? this.selector + " " + selector : selector; + return ret; + }, + filter: function(selector) { + return this.pushStack(winnow(this, selector || [], false)); + }, + not: function(selector) { + return this.pushStack(winnow(this, selector || [], true)); + }, + is: function(selector) { + return !!winnow(this, typeof selector === "string" && rneedsContext.test(selector) ? jQuery(selector) : selector || [], false).length; + } + }); + var rootjQuery, rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, init = jQuery.fn.init = function(selector, context) { + var match, elem; + if (!selector) { + return this; + } + if (typeof selector === "string") { + if (selector[0] === "<" && selector[selector.length - 1] === ">" && selector.length >= 3) { + match = [ null, selector, null ]; + } else { + match = rquickExpr.exec(selector); + } + if (match && (match[1] || !context)) { + if (match[1]) { + context = context instanceof jQuery ? context[0] : context; + jQuery.merge(this, jQuery.parseHTML(match[1], context && context.nodeType ? context.ownerDocument || context : document, true)); + if (rsingleTag.test(match[1]) && jQuery.isPlainObject(context)) { + for (match in context) { + if (jQuery.isFunction(this[match])) { + this[match](context[match]); + } else { + this.attr(match, context[match]); + } + } + } + return this; + } else { + elem = document.getElementById(match[2]); + if (elem && elem.parentNode) { + this.length = 1; + this[0] = elem; + } + this.context = document; + this.selector = selector; + return this; + } + } else if (!context || context.jquery) { + return (context || rootjQuery).find(selector); + } else { + return this.constructor(context).find(selector); + } + } else if (selector.nodeType) { + this.context = this[0] = selector; + this.length = 1; + return this; + } else if (jQuery.isFunction(selector)) { + return typeof rootjQuery.ready !== "undefined" ? rootjQuery.ready(selector) : selector(jQuery); + } + if (selector.selector !== undefined) { + this.selector = selector.selector; + this.context = selector.context; + } + return jQuery.makeArray(selector, this); + }; + init.prototype = jQuery.fn; + rootjQuery = jQuery(document); + var rparentsprev = /^(?:parents|prev(?:Until|All))/, guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + jQuery.extend({ + dir: function(elem, dir, until) { + var matched = [], truncate = until !== undefined; + while ((elem = elem[dir]) && elem.nodeType !== 9) { + if (elem.nodeType === 1) { + if (truncate && jQuery(elem).is(until)) { + break; + } + matched.push(elem); + } + } + return matched; + }, + sibling: function(n, elem) { + var matched = []; + for (;n; n = n.nextSibling) { + if (n.nodeType === 1 && n !== elem) { + matched.push(n); + } + } + return matched; + } + }); + jQuery.fn.extend({ + has: function(target) { + var targets = jQuery(target, this), l = targets.length; + return this.filter(function() { + var i = 0; + for (;i < l; i++) { + if (jQuery.contains(this, targets[i])) { + return true; + } + } + }); + }, + closest: function(selectors, context) { + var cur, i = 0, l = this.length, matched = [], pos = rneedsContext.test(selectors) || typeof selectors !== "string" ? jQuery(selectors, context || this.context) : 0; + for (;i < l; i++) { + for (cur = this[i]; cur && cur !== context; cur = cur.parentNode) { + if (cur.nodeType < 11 && (pos ? pos.index(cur) > -1 : cur.nodeType === 1 && jQuery.find.matchesSelector(cur, selectors))) { + matched.push(cur); + break; + } + } + } + return this.pushStack(matched.length > 1 ? jQuery.unique(matched) : matched); + }, + index: function(elem) { + if (!elem) { + return this[0] && this[0].parentNode ? this.first().prevAll().length : -1; + } + if (typeof elem === "string") { + return indexOf.call(jQuery(elem), this[0]); + } + return indexOf.call(this, elem.jquery ? elem[0] : elem); + }, + add: function(selector, context) { + return this.pushStack(jQuery.unique(jQuery.merge(this.get(), jQuery(selector, context)))); + }, + addBack: function(selector) { + return this.add(selector == null ? this.prevObject : this.prevObject.filter(selector)); + } + }); + function sibling(cur, dir) { + while ((cur = cur[dir]) && cur.nodeType !== 1) {} + return cur; + } + jQuery.each({ + parent: function(elem) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function(elem) { + return jQuery.dir(elem, "parentNode"); + }, + parentsUntil: function(elem, i, until) { + return jQuery.dir(elem, "parentNode", until); + }, + next: function(elem) { + return sibling(elem, "nextSibling"); + }, + prev: function(elem) { + return sibling(elem, "previousSibling"); + }, + nextAll: function(elem) { + return jQuery.dir(elem, "nextSibling"); + }, + prevAll: function(elem) { + return jQuery.dir(elem, "previousSibling"); + }, + nextUntil: function(elem, i, until) { + return jQuery.dir(elem, "nextSibling", until); + }, + prevUntil: function(elem, i, until) { + return jQuery.dir(elem, "previousSibling", until); + }, + siblings: function(elem) { + return jQuery.sibling((elem.parentNode || {}).firstChild, elem); + }, + children: function(elem) { + return jQuery.sibling(elem.firstChild); + }, + contents: function(elem) { + return elem.contentDocument || jQuery.merge([], elem.childNodes); + } + }, function(name, fn) { + jQuery.fn[name] = function(until, selector) { + var matched = jQuery.map(this, fn, until); + if (name.slice(-5) !== "Until") { + selector = until; + } + if (selector && typeof selector === "string") { + matched = jQuery.filter(selector, matched); + } + if (this.length > 1) { + if (!guaranteedUnique[name]) { + jQuery.unique(matched); + } + if (rparentsprev.test(name)) { + matched.reverse(); + } + } + return this.pushStack(matched); + }; + }); + var rnotwhite = /\S+/g; + var optionsCache = {}; + function createOptions(options) { + var object = optionsCache[options] = {}; + jQuery.each(options.match(rnotwhite) || [], function(_, flag) { + object[flag] = true; + }); + return object; + } + jQuery.Callbacks = function(options) { + options = typeof options === "string" ? optionsCache[options] || createOptions(options) : jQuery.extend({}, options); + var memory, fired, firing, firingStart, firingLength, firingIndex, list = [], stack = !options.once && [], fire = function(data) { + memory = options.memory && data; + fired = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + firing = true; + for (;list && firingIndex < firingLength; firingIndex++) { + if (list[firingIndex].apply(data[0], data[1]) === false && options.stopOnFalse) { + memory = false; + break; + } + } + firing = false; + if (list) { + if (stack) { + if (stack.length) { + fire(stack.shift()); + } + } else if (memory) { + list = []; + } else { + self.disable(); + } + } + }, self = { + add: function() { + if (list) { + var start = list.length; + (function add(args) { + jQuery.each(args, function(_, arg) { + var type = jQuery.type(arg); + if (type === "function") { + if (!options.unique || !self.has(arg)) { + list.push(arg); + } + } else if (arg && arg.length && type !== "string") { + add(arg); + } + }); + })(arguments); + if (firing) { + firingLength = list.length; + } else if (memory) { + firingStart = start; + fire(memory); + } + } + return this; + }, + remove: function() { + if (list) { + jQuery.each(arguments, function(_, arg) { + var index; + while ((index = jQuery.inArray(arg, list, index)) > -1) { + list.splice(index, 1); + if (firing) { + if (index <= firingLength) { + firingLength--; + } + if (index <= firingIndex) { + firingIndex--; + } + } + } + }); + } + return this; + }, + has: function(fn) { + return fn ? jQuery.inArray(fn, list) > -1 : !!(list && list.length); + }, + empty: function() { + list = []; + firingLength = 0; + return this; + }, + disable: function() { + list = stack = memory = undefined; + return this; + }, + disabled: function() { + return !list; + }, + lock: function() { + stack = undefined; + if (!memory) { + self.disable(); + } + return this; + }, + locked: function() { + return !stack; + }, + fireWith: function(context, args) { + if (list && (!fired || stack)) { + args = args || []; + args = [ context, args.slice ? args.slice() : args ]; + if (firing) { + stack.push(args); + } else { + fire(args); + } + } + return this; + }, + fire: function() { + self.fireWith(this, arguments); + return this; + }, + fired: function() { + return !!fired; + } + }; + return self; + }; + jQuery.extend({ + Deferred: function(func) { + var tuples = [ [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], [ "notify", "progress", jQuery.Callbacks("memory") ] ], state = "pending", promise = { + state: function() { + return state; + }, + always: function() { + deferred.done(arguments).fail(arguments); + return this; + }, + then: function() { + var fns = arguments; + return jQuery.Deferred(function(newDefer) { + jQuery.each(tuples, function(i, tuple) { + var fn = jQuery.isFunction(fns[i]) && fns[i]; + deferred[tuple[1]](function() { + var returned = fn && fn.apply(this, arguments); + if (returned && jQuery.isFunction(returned.promise)) { + returned.promise().done(newDefer.resolve).fail(newDefer.reject).progress(newDefer.notify); + } else { + newDefer[tuple[0] + "With"](this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments); + } + }); + }); + fns = null; + }).promise(); + }, + promise: function(obj) { + return obj != null ? jQuery.extend(obj, promise) : promise; + } + }, deferred = {}; + promise.pipe = promise.then; + jQuery.each(tuples, function(i, tuple) { + var list = tuple[2], stateString = tuple[3]; + promise[tuple[1]] = list.add; + if (stateString) { + list.add(function() { + state = stateString; + }, tuples[i ^ 1][2].disable, tuples[2][2].lock); + } + deferred[tuple[0]] = function() { + deferred[tuple[0] + "With"](this === deferred ? promise : this, arguments); + return this; + }; + deferred[tuple[0] + "With"] = list.fireWith; + }); + promise.promise(deferred); + if (func) { + func.call(deferred, deferred); + } + return deferred; + }, + when: function(subordinate) { + var i = 0, resolveValues = slice.call(arguments), length = resolveValues.length, remaining = length !== 1 || subordinate && jQuery.isFunction(subordinate.promise) ? length : 0, deferred = remaining === 1 ? subordinate : jQuery.Deferred(), updateFunc = function(i, contexts, values) { + return function(value) { + contexts[i] = this; + values[i] = arguments.length > 1 ? slice.call(arguments) : value; + if (values === progressValues) { + deferred.notifyWith(contexts, values); + } else if (!--remaining) { + deferred.resolveWith(contexts, values); + } + }; + }, progressValues, progressContexts, resolveContexts; + if (length > 1) { + progressValues = new Array(length); + progressContexts = new Array(length); + resolveContexts = new Array(length); + for (;i < length; i++) { + if (resolveValues[i] && jQuery.isFunction(resolveValues[i].promise)) { + resolveValues[i].promise().done(updateFunc(i, resolveContexts, resolveValues)).fail(deferred.reject).progress(updateFunc(i, progressContexts, progressValues)); + } else { + --remaining; + } + } + } + if (!remaining) { + deferred.resolveWith(resolveContexts, resolveValues); + } + return deferred.promise(); + } + }); + var readyList; + jQuery.fn.ready = function(fn) { + jQuery.ready.promise().done(fn); + return this; + }; + jQuery.extend({ + isReady: false, + readyWait: 1, + holdReady: function(hold) { + if (hold) { + jQuery.readyWait++; + } else { + jQuery.ready(true); + } + }, + ready: function(wait) { + if (wait === true ? --jQuery.readyWait : jQuery.isReady) { + return; + } + jQuery.isReady = true; + if (wait !== true && --jQuery.readyWait > 0) { + return; + } + readyList.resolveWith(document, [ jQuery ]); + if (jQuery.fn.triggerHandler) { + jQuery(document).triggerHandler("ready"); + jQuery(document).off("ready"); + } + } + }); + function completed() { + document.removeEventListener("DOMContentLoaded", completed, false); + window.removeEventListener("load", completed, false); + jQuery.ready(); + } + jQuery.ready.promise = function(obj) { + if (!readyList) { + readyList = jQuery.Deferred(); + if (document.readyState === "complete") { + setTimeout(jQuery.ready); + } else { + document.addEventListener("DOMContentLoaded", completed, false); + window.addEventListener("load", completed, false); + } + } + return readyList.promise(obj); + }; + jQuery.ready.promise(); + var access = jQuery.access = function(elems, fn, key, value, chainable, emptyGet, raw) { + var i = 0, len = elems.length, bulk = key == null; + if (jQuery.type(key) === "object") { + chainable = true; + for (i in key) { + jQuery.access(elems, fn, i, key[i], true, emptyGet, raw); + } + } else if (value !== undefined) { + chainable = true; + if (!jQuery.isFunction(value)) { + raw = true; + } + if (bulk) { + if (raw) { + fn.call(elems, value); + fn = null; + } else { + bulk = fn; + fn = function(elem, key, value) { + return bulk.call(jQuery(elem), value); + }; + } + } + if (fn) { + for (;i < len; i++) { + fn(elems[i], key, raw ? value : value.call(elems[i], i, fn(elems[i], key))); + } + } + } + return chainable ? elems : bulk ? fn.call(elems) : len ? fn(elems[0], key) : emptyGet; + }; + jQuery.acceptData = function(owner) { + return owner.nodeType === 1 || owner.nodeType === 9 || !+owner.nodeType; + }; + function Data() { + Object.defineProperty(this.cache = {}, 0, { + get: function() { + return {}; + } + }); + this.expando = jQuery.expando + Data.uid++; + } + Data.uid = 1; + Data.accepts = jQuery.acceptData; + Data.prototype = { + key: function(owner) { + if (!Data.accepts(owner)) { + return 0; + } + var descriptor = {}, unlock = owner[this.expando]; + if (!unlock) { + unlock = Data.uid++; + try { + descriptor[this.expando] = { + value: unlock + }; + Object.defineProperties(owner, descriptor); + } catch (e) { + descriptor[this.expando] = unlock; + jQuery.extend(owner, descriptor); + } + } + if (!this.cache[unlock]) { + this.cache[unlock] = {}; + } + return unlock; + }, + set: function(owner, data, value) { + var prop, unlock = this.key(owner), cache = this.cache[unlock]; + if (typeof data === "string") { + cache[data] = value; + } else { + if (jQuery.isEmptyObject(cache)) { + jQuery.extend(this.cache[unlock], data); + } else { + for (prop in data) { + cache[prop] = data[prop]; + } + } + } + return cache; + }, + get: function(owner, key) { + var cache = this.cache[this.key(owner)]; + return key === undefined ? cache : cache[key]; + }, + access: function(owner, key, value) { + var stored; + if (key === undefined || key && typeof key === "string" && value === undefined) { + stored = this.get(owner, key); + return stored !== undefined ? stored : this.get(owner, jQuery.camelCase(key)); + } + this.set(owner, key, value); + return value !== undefined ? value : key; + }, + remove: function(owner, key) { + var i, name, camel, unlock = this.key(owner), cache = this.cache[unlock]; + if (key === undefined) { + this.cache[unlock] = {}; + } else { + if (jQuery.isArray(key)) { + name = key.concat(key.map(jQuery.camelCase)); + } else { + camel = jQuery.camelCase(key); + if (key in cache) { + name = [ key, camel ]; + } else { + name = camel; + name = name in cache ? [ name ] : name.match(rnotwhite) || []; + } + } + i = name.length; + while (i--) { + delete cache[name[i]]; + } + } + }, + hasData: function(owner) { + return !jQuery.isEmptyObject(this.cache[owner[this.expando]] || {}); + }, + discard: function(owner) { + if (owner[this.expando]) { + delete this.cache[owner[this.expando]]; + } + } + }; + var data_priv = new Data(); + var data_user = new Data(); + var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, rmultiDash = /([A-Z])/g; + function dataAttr(elem, key, data) { + var name; + if (data === undefined && elem.nodeType === 1) { + name = "data-" + key.replace(rmultiDash, "-$1").toLowerCase(); + data = elem.getAttribute(name); + if (typeof data === "string") { + try { + data = data === "true" ? true : data === "false" ? false : data === "null" ? null : +data + "" === data ? +data : rbrace.test(data) ? jQuery.parseJSON(data) : data; + } catch (e) {} + data_user.set(elem, key, data); + } else { + data = undefined; + } + } + return data; + } + jQuery.extend({ + hasData: function(elem) { + return data_user.hasData(elem) || data_priv.hasData(elem); + }, + data: function(elem, name, data) { + return data_user.access(elem, name, data); + }, + removeData: function(elem, name) { + data_user.remove(elem, name); + }, + _data: function(elem, name, data) { + return data_priv.access(elem, name, data); + }, + _removeData: function(elem, name) { + data_priv.remove(elem, name); + } + }); + jQuery.fn.extend({ + data: function(key, value) { + var i, name, data, elem = this[0], attrs = elem && elem.attributes; + if (key === undefined) { + if (this.length) { + data = data_user.get(elem); + if (elem.nodeType === 1 && !data_priv.get(elem, "hasDataAttrs")) { + i = attrs.length; + while (i--) { + if (attrs[i]) { + name = attrs[i].name; + if (name.indexOf("data-") === 0) { + name = jQuery.camelCase(name.slice(5)); + dataAttr(elem, name, data[name]); + } + } + } + data_priv.set(elem, "hasDataAttrs", true); + } + } + return data; + } + if (typeof key === "object") { + return this.each(function() { + data_user.set(this, key); + }); + } + return access(this, function(value) { + var data, camelKey = jQuery.camelCase(key); + if (elem && value === undefined) { + data = data_user.get(elem, key); + if (data !== undefined) { + return data; + } + data = data_user.get(elem, camelKey); + if (data !== undefined) { + return data; + } + data = dataAttr(elem, camelKey, undefined); + if (data !== undefined) { + return data; + } + return; + } + this.each(function() { + var data = data_user.get(this, camelKey); + data_user.set(this, camelKey, value); + if (key.indexOf("-") !== -1 && data !== undefined) { + data_user.set(this, key, value); + } + }); + }, null, value, arguments.length > 1, null, true); + }, + removeData: function(key) { + return this.each(function() { + data_user.remove(this, key); + }); + } + }); + jQuery.extend({ + queue: function(elem, type, data) { + var queue; + if (elem) { + type = (type || "fx") + "queue"; + queue = data_priv.get(elem, type); + if (data) { + if (!queue || jQuery.isArray(data)) { + queue = data_priv.access(elem, type, jQuery.makeArray(data)); + } else { + queue.push(data); + } + } + return queue || []; + } + }, + dequeue: function(elem, type) { + type = type || "fx"; + var queue = jQuery.queue(elem, type), startLength = queue.length, fn = queue.shift(), hooks = jQuery._queueHooks(elem, type), next = function() { + jQuery.dequeue(elem, type); + }; + if (fn === "inprogress") { + fn = queue.shift(); + startLength--; + } + if (fn) { + if (type === "fx") { + queue.unshift("inprogress"); + } + delete hooks.stop; + fn.call(elem, next, hooks); + } + if (!startLength && hooks) { + hooks.empty.fire(); + } + }, + _queueHooks: function(elem, type) { + var key = type + "queueHooks"; + return data_priv.get(elem, key) || data_priv.access(elem, key, { + empty: jQuery.Callbacks("once memory").add(function() { + data_priv.remove(elem, [ type + "queue", key ]); + }) + }); + } + }); + jQuery.fn.extend({ + queue: function(type, data) { + var setter = 2; + if (typeof type !== "string") { + data = type; + type = "fx"; + setter--; + } + if (arguments.length < setter) { + return jQuery.queue(this[0], type); + } + return data === undefined ? this : this.each(function() { + var queue = jQuery.queue(this, type, data); + jQuery._queueHooks(this, type); + if (type === "fx" && queue[0] !== "inprogress") { + jQuery.dequeue(this, type); + } + }); + }, + dequeue: function(type) { + return this.each(function() { + jQuery.dequeue(this, type); + }); + }, + clearQueue: function(type) { + return this.queue(type || "fx", []); + }, + promise: function(type, obj) { + var tmp, count = 1, defer = jQuery.Deferred(), elements = this, i = this.length, resolve = function() { + if (!--count) { + defer.resolveWith(elements, [ elements ]); + } + }; + if (typeof type !== "string") { + obj = type; + type = undefined; + } + type = type || "fx"; + while (i--) { + tmp = data_priv.get(elements[i], type + "queueHooks"); + if (tmp && tmp.empty) { + count++; + tmp.empty.add(resolve); + } + } + resolve(); + return defer.promise(obj); + } + }); + var pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source; + var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; + var isHidden = function(elem, el) { + elem = el || elem; + return jQuery.css(elem, "display") === "none" || !jQuery.contains(elem.ownerDocument, elem); + }; + var rcheckableType = /^(?:checkbox|radio)$/i; + (function() { + var fragment = document.createDocumentFragment(), div = fragment.appendChild(document.createElement("div")), input = document.createElement("input"); + input.setAttribute("type", "radio"); + input.setAttribute("checked", "checked"); + input.setAttribute("name", "t"); + div.appendChild(input); + support.checkClone = div.cloneNode(true).cloneNode(true).lastChild.checked; + div.innerHTML = ""; + support.noCloneChecked = !!div.cloneNode(true).lastChild.defaultValue; + })(); + var strundefined = typeof undefined; + support.focusinBubbles = "onfocusin" in window; + var rkeyEvent = /^key/, rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/, rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; + function returnTrue() { + return true; + } + function returnFalse() { + return false; + } + function safeActiveElement() { + try { + return document.activeElement; + } catch (err) {} + } + jQuery.event = { + global: {}, + add: function(elem, types, handler, data, selector) { + var handleObjIn, eventHandle, tmp, events, t, handleObj, special, handlers, type, namespaces, origType, elemData = data_priv.get(elem); + if (!elemData) { + return; + } + if (handler.handler) { + handleObjIn = handler; + handler = handleObjIn.handler; + selector = handleObjIn.selector; + } + if (!handler.guid) { + handler.guid = jQuery.guid++; + } + if (!(events = elemData.events)) { + events = elemData.events = {}; + } + if (!(eventHandle = elemData.handle)) { + eventHandle = elemData.handle = function(e) { + return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ? jQuery.event.dispatch.apply(elem, arguments) : undefined; + }; + } + types = (types || "").match(rnotwhite) || [ "" ]; + t = types.length; + while (t--) { + tmp = rtypenamespace.exec(types[t]) || []; + type = origType = tmp[1]; + namespaces = (tmp[2] || "").split(".").sort(); + if (!type) { + continue; + } + special = jQuery.event.special[type] || {}; + type = (selector ? special.delegateType : special.bindType) || type; + special = jQuery.event.special[type] || {}; + handleObj = jQuery.extend({ + type: type, + origType: origType, + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + needsContext: selector && jQuery.expr.match.needsContext.test(selector), + namespace: namespaces.join(".") + }, handleObjIn); + if (!(handlers = events[type])) { + handlers = events[type] = []; + handlers.delegateCount = 0; + if (!special.setup || special.setup.call(elem, data, namespaces, eventHandle) === false) { + if (elem.addEventListener) { + elem.addEventListener(type, eventHandle, false); + } + } + } + if (special.add) { + special.add.call(elem, handleObj); + if (!handleObj.handler.guid) { + handleObj.handler.guid = handler.guid; + } + } + if (selector) { + handlers.splice(handlers.delegateCount++, 0, handleObj); + } else { + handlers.push(handleObj); + } + jQuery.event.global[type] = true; + } + }, + remove: function(elem, types, handler, selector, mappedTypes) { + var j, origCount, tmp, events, t, handleObj, special, handlers, type, namespaces, origType, elemData = data_priv.hasData(elem) && data_priv.get(elem); + if (!elemData || !(events = elemData.events)) { + return; + } + types = (types || "").match(rnotwhite) || [ "" ]; + t = types.length; + while (t--) { + tmp = rtypenamespace.exec(types[t]) || []; + type = origType = tmp[1]; + namespaces = (tmp[2] || "").split(".").sort(); + if (!type) { + for (type in events) { + jQuery.event.remove(elem, type + types[t], handler, selector, true); + } + continue; + } + special = jQuery.event.special[type] || {}; + type = (selector ? special.delegateType : special.bindType) || type; + handlers = events[type] || []; + tmp = tmp[2] && new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)"); + origCount = j = handlers.length; + while (j--) { + handleObj = handlers[j]; + if ((mappedTypes || origType === handleObj.origType) && (!handler || handler.guid === handleObj.guid) && (!tmp || tmp.test(handleObj.namespace)) && (!selector || selector === handleObj.selector || selector === "**" && handleObj.selector)) { + handlers.splice(j, 1); + if (handleObj.selector) { + handlers.delegateCount--; + } + if (special.remove) { + special.remove.call(elem, handleObj); + } + } + } + if (origCount && !handlers.length) { + if (!special.teardown || special.teardown.call(elem, namespaces, elemData.handle) === false) { + jQuery.removeEvent(elem, type, elemData.handle); + } + delete events[type]; + } + } + if (jQuery.isEmptyObject(events)) { + delete elemData.handle; + data_priv.remove(elem, "events"); + } + }, + trigger: function(event, data, elem, onlyHandlers) { + var i, cur, tmp, bubbleType, ontype, handle, special, eventPath = [ elem || document ], type = hasOwn.call(event, "type") ? event.type : event, namespaces = hasOwn.call(event, "namespace") ? event.namespace.split(".") : []; + cur = tmp = elem = elem || document; + if (elem.nodeType === 3 || elem.nodeType === 8) { + return; + } + if (rfocusMorph.test(type + jQuery.event.triggered)) { + return; + } + if (type.indexOf(".") >= 0) { + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + ontype = type.indexOf(":") < 0 && "on" + type; + event = event[jQuery.expando] ? event : new jQuery.Event(type, typeof event === "object" && event); + event.isTrigger = onlyHandlers ? 2 : 3; + event.namespace = namespaces.join("."); + event.namespace_re = event.namespace ? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null; + event.result = undefined; + if (!event.target) { + event.target = elem; + } + data = data == null ? [ event ] : jQuery.makeArray(data, [ event ]); + special = jQuery.event.special[type] || {}; + if (!onlyHandlers && special.trigger && special.trigger.apply(elem, data) === false) { + return; + } + if (!onlyHandlers && !special.noBubble && !jQuery.isWindow(elem)) { + bubbleType = special.delegateType || type; + if (!rfocusMorph.test(bubbleType + type)) { + cur = cur.parentNode; + } + for (;cur; cur = cur.parentNode) { + eventPath.push(cur); + tmp = cur; + } + if (tmp === (elem.ownerDocument || document)) { + eventPath.push(tmp.defaultView || tmp.parentWindow || window); + } + } + i = 0; + while ((cur = eventPath[i++]) && !event.isPropagationStopped()) { + event.type = i > 1 ? bubbleType : special.bindType || type; + handle = (data_priv.get(cur, "events") || {})[event.type] && data_priv.get(cur, "handle"); + if (handle) { + handle.apply(cur, data); + } + handle = ontype && cur[ontype]; + if (handle && handle.apply && jQuery.acceptData(cur)) { + event.result = handle.apply(cur, data); + if (event.result === false) { + event.preventDefault(); + } + } + } + event.type = type; + if (!onlyHandlers && !event.isDefaultPrevented()) { + if ((!special._default || special._default.apply(eventPath.pop(), data) === false) && jQuery.acceptData(elem)) { + if (ontype && jQuery.isFunction(elem[type]) && !jQuery.isWindow(elem)) { + tmp = elem[ontype]; + if (tmp) { + elem[ontype] = null; + } + jQuery.event.triggered = type; + elem[type](); + jQuery.event.triggered = undefined; + if (tmp) { + elem[ontype] = tmp; + } + } + } + } + return event.result; + }, + dispatch: function(event) { + event = jQuery.event.fix(event); + var i, j, ret, matched, handleObj, handlerQueue = [], args = slice.call(arguments), handlers = (data_priv.get(this, "events") || {})[event.type] || [], special = jQuery.event.special[event.type] || {}; + args[0] = event; + event.delegateTarget = this; + if (special.preDispatch && special.preDispatch.call(this, event) === false) { + return; + } + handlerQueue = jQuery.event.handlers.call(this, event, handlers); + i = 0; + while ((matched = handlerQueue[i++]) && !event.isPropagationStopped()) { + event.currentTarget = matched.elem; + j = 0; + while ((handleObj = matched.handlers[j++]) && !event.isImmediatePropagationStopped()) { + if (!event.namespace_re || event.namespace_re.test(handleObj.namespace)) { + event.handleObj = handleObj; + event.data = handleObj.data; + ret = ((jQuery.event.special[handleObj.origType] || {}).handle || handleObj.handler).apply(matched.elem, args); + if (ret !== undefined) { + if ((event.result = ret) === false) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + if (special.postDispatch) { + special.postDispatch.call(this, event); + } + return event.result; + }, + handlers: function(event, handlers) { + var i, matches, sel, handleObj, handlerQueue = [], delegateCount = handlers.delegateCount, cur = event.target; + if (delegateCount && cur.nodeType && (!event.button || event.type !== "click")) { + for (;cur !== this; cur = cur.parentNode || this) { + if (cur.disabled !== true || event.type !== "click") { + matches = []; + for (i = 0; i < delegateCount; i++) { + handleObj = handlers[i]; + sel = handleObj.selector + " "; + if (matches[sel] === undefined) { + matches[sel] = handleObj.needsContext ? jQuery(sel, this).index(cur) >= 0 : jQuery.find(sel, this, null, [ cur ]).length; + } + if (matches[sel]) { + matches.push(handleObj); + } + } + if (matches.length) { + handlerQueue.push({ + elem: cur, + handlers: matches + }); + } + } + } + } + if (delegateCount < handlers.length) { + handlerQueue.push({ + elem: this, + handlers: handlers.slice(delegateCount) + }); + } + return handlerQueue; + }, + props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + fixHooks: {}, + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function(event, original) { + if (event.which == null) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + return event; + } + }, + mouseHooks: { + props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function(event, original) { + var eventDoc, doc, body, button = original.button; + if (event.pageX == null && original.clientX != null) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + event.pageX = original.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); + event.pageY = original.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); + } + if (!event.which && button !== undefined) { + event.which = button & 1 ? 1 : button & 2 ? 3 : button & 4 ? 2 : 0; + } + return event; + } + }, + fix: function(event) { + if (event[jQuery.expando]) { + return event; + } + var i, prop, copy, type = event.type, originalEvent = event, fixHook = this.fixHooks[type]; + if (!fixHook) { + this.fixHooks[type] = fixHook = rmouseEvent.test(type) ? this.mouseHooks : rkeyEvent.test(type) ? this.keyHooks : {}; + } + copy = fixHook.props ? this.props.concat(fixHook.props) : this.props; + event = new jQuery.Event(originalEvent); + i = copy.length; + while (i--) { + prop = copy[i]; + event[prop] = originalEvent[prop]; + } + if (!event.target) { + event.target = document; + } + if (event.target.nodeType === 3) { + event.target = event.target.parentNode; + } + return fixHook.filter ? fixHook.filter(event, originalEvent) : event; + }, + special: { + load: { + noBubble: true + }, + focus: { + trigger: function() { + if (this !== safeActiveElement() && this.focus) { + this.focus(); + return false; + } + }, + delegateType: "focusin" + }, + blur: { + trigger: function() { + if (this === safeActiveElement() && this.blur) { + this.blur(); + return false; + } + }, + delegateType: "focusout" + }, + click: { + trigger: function() { + if (this.type === "checkbox" && this.click && jQuery.nodeName(this, "input")) { + this.click(); + return false; + } + }, + _default: function(event) { + return jQuery.nodeName(event.target, "a"); + } + }, + beforeunload: { + postDispatch: function(event) { + if (event.result !== undefined && event.originalEvent) { + event.originalEvent.returnValue = event.result; + } + } + } + }, + simulate: function(type, elem, event, bubble) { + var e = jQuery.extend(new jQuery.Event(), event, { + type: type, + isSimulated: true, + originalEvent: {} + }); + if (bubble) { + jQuery.event.trigger(e, null, elem); + } else { + jQuery.event.dispatch.call(elem, e); + } + if (e.isDefaultPrevented()) { + event.preventDefault(); + } + } + }; + jQuery.removeEvent = function(elem, type, handle) { + if (elem.removeEventListener) { + elem.removeEventListener(type, handle, false); + } + }; + jQuery.Event = function(src, props) { + if (!(this instanceof jQuery.Event)) { + return new jQuery.Event(src, props); + } + if (src && src.type) { + this.originalEvent = src; + this.type = src.type; + this.isDefaultPrevented = src.defaultPrevented || src.defaultPrevented === undefined && src.returnValue === false ? returnTrue : returnFalse; + } else { + this.type = src; + } + if (props) { + jQuery.extend(this, props); + } + this.timeStamp = src && src.timeStamp || jQuery.now(); + this[jQuery.expando] = true; + }; + jQuery.Event.prototype = { + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse, + preventDefault: function() { + var e = this.originalEvent; + this.isDefaultPrevented = returnTrue; + if (e && e.preventDefault) { + e.preventDefault(); + } + }, + stopPropagation: function() { + var e = this.originalEvent; + this.isPropagationStopped = returnTrue; + if (e && e.stopPropagation) { + e.stopPropagation(); + } + }, + stopImmediatePropagation: function() { + var e = this.originalEvent; + this.isImmediatePropagationStopped = returnTrue; + if (e && e.stopImmediatePropagation) { + e.stopImmediatePropagation(); + } + this.stopPropagation(); + } + }; + jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout", + pointerenter: "pointerover", + pointerleave: "pointerout" + }, function(orig, fix) { + jQuery.event.special[orig] = { + delegateType: fix, + bindType: fix, + handle: function(event) { + var ret, target = this, related = event.relatedTarget, handleObj = event.handleObj; + if (!related || related !== target && !jQuery.contains(target, related)) { + event.type = handleObj.origType; + ret = handleObj.handler.apply(this, arguments); + event.type = fix; + } + return ret; + } + }; + }); + if (!support.focusinBubbles) { + jQuery.each({ + focus: "focusin", + blur: "focusout" + }, function(orig, fix) { + var handler = function(event) { + jQuery.event.simulate(fix, event.target, jQuery.event.fix(event), true); + }; + jQuery.event.special[fix] = { + setup: function() { + var doc = this.ownerDocument || this, attaches = data_priv.access(doc, fix); + if (!attaches) { + doc.addEventListener(orig, handler, true); + } + data_priv.access(doc, fix, (attaches || 0) + 1); + }, + teardown: function() { + var doc = this.ownerDocument || this, attaches = data_priv.access(doc, fix) - 1; + if (!attaches) { + doc.removeEventListener(orig, handler, true); + data_priv.remove(doc, fix); + } else { + data_priv.access(doc, fix, attaches); + } + } + }; + }); + } + jQuery.fn.extend({ + on: function(types, selector, data, fn, one) { + var origFn, type; + if (typeof types === "object") { + if (typeof selector !== "string") { + data = data || selector; + selector = undefined; + } + for (type in types) { + this.on(type, selector, data, types[type], one); + } + return this; + } + if (data == null && fn == null) { + fn = selector; + data = selector = undefined; + } else if (fn == null) { + if (typeof selector === "string") { + fn = data; + data = undefined; + } else { + fn = data; + data = selector; + selector = undefined; + } + } + if (fn === false) { + fn = returnFalse; + } else if (!fn) { + return this; + } + if (one === 1) { + origFn = fn; + fn = function(event) { + jQuery().off(event); + return origFn.apply(this, arguments); + }; + fn.guid = origFn.guid || (origFn.guid = jQuery.guid++); + } + return this.each(function() { + jQuery.event.add(this, types, fn, data, selector); + }); + }, + one: function(types, selector, data, fn) { + return this.on(types, selector, data, fn, 1); + }, + off: function(types, selector, fn) { + var handleObj, type; + if (types && types.preventDefault && types.handleObj) { + handleObj = types.handleObj; + jQuery(types.delegateTarget).off(handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, handleObj.selector, handleObj.handler); + return this; + } + if (typeof types === "object") { + for (type in types) { + this.off(type, selector, types[type]); + } + return this; + } + if (selector === false || typeof selector === "function") { + fn = selector; + selector = undefined; + } + if (fn === false) { + fn = returnFalse; + } + return this.each(function() { + jQuery.event.remove(this, types, fn, selector); + }); + }, + trigger: function(type, data) { + return this.each(function() { + jQuery.event.trigger(type, data, this); + }); + }, + triggerHandler: function(type, data) { + var elem = this[0]; + if (elem) { + return jQuery.event.trigger(type, data, elem, true); + } + } + }); + var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, rtagName = /<([\w:]+)/, rhtml = /<|&#?\w+;/, rnoInnerhtml = /<(?:script|style|link)/i, rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, rscriptType = /^$|\/(?:java|ecma)script/i, rscriptTypeMasked = /^true\/(.*)/, rcleanScript = /^\s*\s*$/g, wrapMap = { + option: [ 1, "" ], + thead: [ 1, "", "
        " ], + col: [ 2, "", "
        " ], + tr: [ 2, "", "
        " ], + td: [ 3, "", "
        " ], + _default: [ 0, "", "" ] + }; + wrapMap.optgroup = wrapMap.option; + wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; + wrapMap.th = wrapMap.td; + function manipulationTarget(elem, content) { + return jQuery.nodeName(elem, "table") && jQuery.nodeName(content.nodeType !== 11 ? content : content.firstChild, "tr") ? elem.getElementsByTagName("tbody")[0] || elem.appendChild(elem.ownerDocument.createElement("tbody")) : elem; + } + function disableScript(elem) { + elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type; + return elem; + } + function restoreScript(elem) { + var match = rscriptTypeMasked.exec(elem.type); + if (match) { + elem.type = match[1]; + } else { + elem.removeAttribute("type"); + } + return elem; + } + function setGlobalEval(elems, refElements) { + var i = 0, l = elems.length; + for (;i < l; i++) { + data_priv.set(elems[i], "globalEval", !refElements || data_priv.get(refElements[i], "globalEval")); + } + } + function cloneCopyEvent(src, dest) { + var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; + if (dest.nodeType !== 1) { + return; + } + if (data_priv.hasData(src)) { + pdataOld = data_priv.access(src); + pdataCur = data_priv.set(dest, pdataOld); + events = pdataOld.events; + if (events) { + delete pdataCur.handle; + pdataCur.events = {}; + for (type in events) { + for (i = 0, l = events[type].length; i < l; i++) { + jQuery.event.add(dest, type, events[type][i]); + } + } + } + } + if (data_user.hasData(src)) { + udataOld = data_user.access(src); + udataCur = jQuery.extend({}, udataOld); + data_user.set(dest, udataCur); + } + } + function getAll(context, tag) { + var ret = context.getElementsByTagName ? context.getElementsByTagName(tag || "*") : context.querySelectorAll ? context.querySelectorAll(tag || "*") : []; + return tag === undefined || tag && jQuery.nodeName(context, tag) ? jQuery.merge([ context ], ret) : ret; + } + function fixInput(src, dest) { + var nodeName = dest.nodeName.toLowerCase(); + if (nodeName === "input" && rcheckableType.test(src.type)) { + dest.checked = src.checked; + } else if (nodeName === "input" || nodeName === "textarea") { + dest.defaultValue = src.defaultValue; + } + } + jQuery.extend({ + clone: function(elem, dataAndEvents, deepDataAndEvents) { + var i, l, srcElements, destElements, clone = elem.cloneNode(true), inPage = jQuery.contains(elem.ownerDocument, elem); + if (!support.noCloneChecked && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem)) { + destElements = getAll(clone); + srcElements = getAll(elem); + for (i = 0, l = srcElements.length; i < l; i++) { + fixInput(srcElements[i], destElements[i]); + } + } + if (dataAndEvents) { + if (deepDataAndEvents) { + srcElements = srcElements || getAll(elem); + destElements = destElements || getAll(clone); + for (i = 0, l = srcElements.length; i < l; i++) { + cloneCopyEvent(srcElements[i], destElements[i]); + } + } else { + cloneCopyEvent(elem, clone); + } + } + destElements = getAll(clone, "script"); + if (destElements.length > 0) { + setGlobalEval(destElements, !inPage && getAll(elem, "script")); + } + return clone; + }, + buildFragment: function(elems, context, scripts, selection) { + var elem, tmp, tag, wrap, contains, j, fragment = context.createDocumentFragment(), nodes = [], i = 0, l = elems.length; + for (;i < l; i++) { + elem = elems[i]; + if (elem || elem === 0) { + if (jQuery.type(elem) === "object") { + jQuery.merge(nodes, elem.nodeType ? [ elem ] : elem); + } else if (!rhtml.test(elem)) { + nodes.push(context.createTextNode(elem)); + } else { + tmp = tmp || fragment.appendChild(context.createElement("div")); + tag = (rtagName.exec(elem) || [ "", "" ])[1].toLowerCase(); + wrap = wrapMap[tag] || wrapMap._default; + tmp.innerHTML = wrap[1] + elem.replace(rxhtmlTag, "<$1>") + wrap[2]; + j = wrap[0]; + while (j--) { + tmp = tmp.lastChild; + } + jQuery.merge(nodes, tmp.childNodes); + tmp = fragment.firstChild; + tmp.textContent = ""; + } + } + } + fragment.textContent = ""; + i = 0; + while (elem = nodes[i++]) { + if (selection && jQuery.inArray(elem, selection) !== -1) { + continue; + } + contains = jQuery.contains(elem.ownerDocument, elem); + tmp = getAll(fragment.appendChild(elem), "script"); + if (contains) { + setGlobalEval(tmp); + } + if (scripts) { + j = 0; + while (elem = tmp[j++]) { + if (rscriptType.test(elem.type || "")) { + scripts.push(elem); + } + } + } + } + return fragment; + }, + cleanData: function(elems) { + var data, elem, type, key, special = jQuery.event.special, i = 0; + for (;(elem = elems[i]) !== undefined; i++) { + if (jQuery.acceptData(elem)) { + key = elem[data_priv.expando]; + if (key && (data = data_priv.cache[key])) { + if (data.events) { + for (type in data.events) { + if (special[type]) { + jQuery.event.remove(elem, type); + } else { + jQuery.removeEvent(elem, type, data.handle); + } + } + } + if (data_priv.cache[key]) { + delete data_priv.cache[key]; + } + } + } + delete data_user.cache[elem[data_user.expando]]; + } + } + }); + jQuery.fn.extend({ + text: function(value) { + return access(this, function(value) { + return value === undefined ? jQuery.text(this) : this.empty().each(function() { + if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) { + this.textContent = value; + } + }); + }, null, value, arguments.length); + }, + append: function() { + return this.domManip(arguments, function(elem) { + if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) { + var target = manipulationTarget(this, elem); + target.appendChild(elem); + } + }); + }, + prepend: function() { + return this.domManip(arguments, function(elem) { + if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) { + var target = manipulationTarget(this, elem); + target.insertBefore(elem, target.firstChild); + } + }); + }, + before: function() { + return this.domManip(arguments, function(elem) { + if (this.parentNode) { + this.parentNode.insertBefore(elem, this); + } + }); + }, + after: function() { + return this.domManip(arguments, function(elem) { + if (this.parentNode) { + this.parentNode.insertBefore(elem, this.nextSibling); + } + }); + }, + remove: function(selector, keepData) { + var elem, elems = selector ? jQuery.filter(selector, this) : this, i = 0; + for (;(elem = elems[i]) != null; i++) { + if (!keepData && elem.nodeType === 1) { + jQuery.cleanData(getAll(elem)); + } + if (elem.parentNode) { + if (keepData && jQuery.contains(elem.ownerDocument, elem)) { + setGlobalEval(getAll(elem, "script")); + } + elem.parentNode.removeChild(elem); + } + } + return this; + }, + empty: function() { + var elem, i = 0; + for (;(elem = this[i]) != null; i++) { + if (elem.nodeType === 1) { + jQuery.cleanData(getAll(elem, false)); + elem.textContent = ""; + } + } + return this; + }, + clone: function(dataAndEvents, deepDataAndEvents) { + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; + return this.map(function() { + return jQuery.clone(this, dataAndEvents, deepDataAndEvents); + }); + }, + html: function(value) { + return access(this, function(value) { + var elem = this[0] || {}, i = 0, l = this.length; + if (value === undefined && elem.nodeType === 1) { + return elem.innerHTML; + } + if (typeof value === "string" && !rnoInnerhtml.test(value) && !wrapMap[(rtagName.exec(value) || [ "", "" ])[1].toLowerCase()]) { + value = value.replace(rxhtmlTag, "<$1>"); + try { + for (;i < l; i++) { + elem = this[i] || {}; + if (elem.nodeType === 1) { + jQuery.cleanData(getAll(elem, false)); + elem.innerHTML = value; + } + } + elem = 0; + } catch (e) {} + } + if (elem) { + this.empty().append(value); + } + }, null, value, arguments.length); + }, + replaceWith: function() { + var arg = arguments[0]; + this.domManip(arguments, function(elem) { + arg = this.parentNode; + jQuery.cleanData(getAll(this)); + if (arg) { + arg.replaceChild(elem, this); + } + }); + return arg && (arg.length || arg.nodeType) ? this : this.remove(); + }, + detach: function(selector) { + return this.remove(selector, true); + }, + domManip: function(args, callback) { + args = concat.apply([], args); + var fragment, first, scripts, hasScripts, node, doc, i = 0, l = this.length, set = this, iNoClone = l - 1, value = args[0], isFunction = jQuery.isFunction(value); + if (isFunction || l > 1 && typeof value === "string" && !support.checkClone && rchecked.test(value)) { + return this.each(function(index) { + var self = set.eq(index); + if (isFunction) { + args[0] = value.call(this, index, self.html()); + } + self.domManip(args, callback); + }); + } + if (l) { + fragment = jQuery.buildFragment(args, this[0].ownerDocument, false, this); + first = fragment.firstChild; + if (fragment.childNodes.length === 1) { + fragment = first; + } + if (first) { + scripts = jQuery.map(getAll(fragment, "script"), disableScript); + hasScripts = scripts.length; + for (;i < l; i++) { + node = fragment; + if (i !== iNoClone) { + node = jQuery.clone(node, true, true); + if (hasScripts) { + jQuery.merge(scripts, getAll(node, "script")); + } + } + callback.call(this[i], node, i); + } + if (hasScripts) { + doc = scripts[scripts.length - 1].ownerDocument; + jQuery.map(scripts, restoreScript); + for (i = 0; i < hasScripts; i++) { + node = scripts[i]; + if (rscriptType.test(node.type || "") && !data_priv.access(node, "globalEval") && jQuery.contains(doc, node)) { + if (node.src) { + if (jQuery._evalUrl) { + jQuery._evalUrl(node.src); + } + } else { + jQuery.globalEval(node.textContent.replace(rcleanScript, "")); + } + } + } + } + } + } + return this; + } + }); + jQuery.each({ + appendTo: "append", + prependTo: "prepend", + insertBefore: "before", + insertAfter: "after", + replaceAll: "replaceWith" + }, function(name, original) { + jQuery.fn[name] = function(selector) { + var elems, ret = [], insert = jQuery(selector), last = insert.length - 1, i = 0; + for (;i <= last; i++) { + elems = i === last ? this : this.clone(true); + jQuery(insert[i])[original](elems); + push.apply(ret, elems.get()); + } + return this.pushStack(ret); + }; + }); + var iframe, elemdisplay = {}; + function actualDisplay(name, doc) { + var style, elem = jQuery(doc.createElement(name)).appendTo(doc.body), display = window.getDefaultComputedStyle && (style = window.getDefaultComputedStyle(elem[0])) ? style.display : jQuery.css(elem[0], "display"); + elem.detach(); + return display; + } + function defaultDisplay(nodeName) { + var doc = document, display = elemdisplay[nodeName]; + if (!display) { + display = actualDisplay(nodeName, doc); + if (display === "none" || !display) { + iframe = (iframe || jQuery("