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AACgB,GAAD,OAAWA,EAAMC,YAAY,GAAGjB,OAArB,8EAC6BgB,EAAMC,YAAY,GAAGjB,OADlD,wCAEXkB,GACR1D,WAAY,SAACc,GAAD,4KAEmDA,EAAKO,YAFxD,0EAKZsC,QAAsB,MAAdlC,EAAOL,IAA4B,QAAdK,EAAOL,KAAe,oXAUvDwC,OAAQrC,EAAkBE,EAAOL,IAAIyC,sB,EAnN/C7E,G","sources":["webpack://umms-html/./FrontEndSrc/modules/macro/typeahead/typeahead-kryuus.js"],"sourcesContent":["/* jQuery, Bloodhound */\r\n\r\n'use strict';\r\n\r\nimport Bloodhound from '../../../js/vendor/typeaheadjs/dist/bloodhound.min.js';\r\nimport '../../../js/vendor/typeaheadjs/dist/typeahead.jquery.js';\r\n\r\nclass TypeaheadKryuus {\r\n    wrap;\r\n    ui;\r\n\r\n    constructor(options) {\r\n        if (options.wrap) {\r\n            this.wrap = options.wrap;\r\n        }\r\n        if (this.wrap) {\r\n            this.ui = {\r\n                $typeaheadInput: $(this.wrap).find('.js-typeahead-kryuus-input'),\r\n                $searchType: $(this.wrap).find('.js-typeahead-input-search-type'),\r\n                $searchTermActual: $(this.wrap).find('.js-typeahead-input-search-term-actual')\r\n            };\r\n\r\n            window.addEventListener('load', () => this.implementTypeahead());\r\n\r\n            if (this.ui.$searchType.length) {\r\n                $(this.wrap).on('typeahead:select', (ev, suggestion) => {\r\n                    $('#qtype').val(suggestion.type);\r\n                });\r\n                $(this.wrap).on('typeahead:change', (ev, suggestion) => {\r\n                    if (suggestion.type) {\r\n                        this.ui.$searchType.val(suggestion.type);\r\n                        console.log(`typeahead on change`)\r\n                    }\r\n                    // else {\r\n                    //     this.ui.$searchType.val('');\r\n                    // }\r\n\r\n                    if (suggestion.value) {\r\n                        this.ui.$searchTermActual.val(suggestion.value);\r\n                    } else if (suggestion.name) {\r\n                        this.ui.$searchTermActual.val(suggestion.name);\r\n                    } else {\r\n                        this.ui.$searchTermActual.val('');\r\n                    }\r\n\r\n                    // this.wrap.submit();\r\n                });\r\n            }\r\n\r\n            $(this.wrap)\r\n                .on('input', '.tt-input', () => {\r\n                    $(this.wrap).find('.tt-dataset-full').removeClass('tt-dataset-full');\r\n                })\r\n                .on('click', '.js-typeahead-load-more', (e) => {\r\n                    e.preventDefault();\r\n\r\n                    const linkLabel = $(e.currentTarget).text(),\r\n                        linkPrevLabel = $(e.currentTarget).data('prevLabel');\r\n\r\n                    $(e.currentTarget).closest('.tt-dataset').toggleClass('tt-dataset-full');\r\n                    $(e.currentTarget).text(linkPrevLabel).data('prevLabel', linkLabel);\r\n                })\r\n                .on('typeahead:selected typeahead:autocompleted', function (e, suggestion) {\r\n                    console.log(`Typeahead selected`);\r\n                    $('.js-typeahead-input-search-type.u-visuallyhidden').attr('value', suggestion.type);\r\n                });\r\n\r\n        }\r\n\r\n        $('#search-bar__input__keyword').on(\"keypress keydown\", function (e) {\r\n            if (e.key !== 'Enter') {\r\n                $('.js-typeahead-input-search-type').attr('value', '');\r\n            }\r\n        });\r\n    }\r\n\r\n    implementTypeahead() {\r\n        const remoteEndpoints = [\r\n            {\r\n                id: 'pc',\r\n                name: 'primary_care',\r\n                displayName: 'Primary Care',\r\n                url: $(this.wrap).find('#primaryCareTypeAheadQuery').val() + '&terms=%QUERY'\r\n            }, {\r\n                id: 's',\r\n                name: 'specialties',\r\n                displayName: 'Specialties',\r\n                url: $(this.wrap).find('#specialtyTypeAheadQuery').val() + '&terms=%QUERY'\r\n            }, {\r\n                id: 'sop',\r\n                name: 'clinical_keywords',\r\n                displayName: 'Conditions',\r\n                url: $(this.wrap).find('#scopeOfPracticeTypeAheadQuery').val() + '&terms=%QUERY'\r\n            }, {\r\n                id: 'p',\r\n                name: 'provider_name',\r\n                displayName: 'Providers',\r\n                url: $(this.wrap).find('#providerTypeAheadQuery').val() + '&terms=%QUERY'\r\n            }, {\r\n                id: 'l',\r\n                name: 'location_name',\r\n                displayName: 'Locations',\r\n                url: $(this.wrap).find('#locationTypeAheadQuery').val() + '&terms=%QUERY'\r\n            }, {\r\n                id: 'pg',\r\n                name: 'practice_group',\r\n                displayName: 'Practice Groups',\r\n                url: $(this.wrap).find('#practiceGroupsTypeAheadQuery').val() + '&terms=%QUERY'\r\n            }];\r\n\r\n        var bloodhoundSources = {};\r\n        remoteEndpoints.forEach(function (remote) {\r\n            bloodhoundSources[remote.id] = new Bloodhound({\r\n                datumTokenizer: Bloodhound.tokenizers.whitespace,\r\n                queryTokenizer: Bloodhound.tokenizers.whitespace,\r\n                limit: 5,\r\n                remote: {\r\n                    url: remote.url,\r\n                    wildcard: '%QUERY',\r\n                    rateLimitBy: 'debounce',\r\n                    rateLimitWait: 300,\r\n                    transform: function (list) {\r\n                        if (remote.name == 'provider_name' && list.provider_name) {\r\n                            return list.provider_name.map(function (result) {\r\n                                return {\r\n                                    header: remote.displayName,\r\n                                    displayName: result.name,\r\n                                    type: remote.id,\r\n                                    name: result.name\r\n                                };\r\n                            });\r\n                        }\r\n                        else if (remote.name == 'specialties' && list.specialties && remote.id !== 'alias') {\r\n                            return list.specialties.map(function (result) {\r\n                                return {\r\n                                    header: remote.displayName,\r\n                                    displayName: result.name,\r\n                                    type: remote.id,\r\n                                    name: result.name\r\n                                };\r\n                            });\r\n                        }\r\n                        else if (remote.name == 'primary_care' && list.primary_care) {\r\n                            return list.primary_care.map(function (result) {\r\n                                return {\r\n                                    header: remote.displayName,\r\n                                    displayName: result.name,\r\n                                    type: remote.id,\r\n                                    name: result.name,\r\n                                };\r\n                            });\r\n                        }\r\n                        else if (remote.name == 'clinical_keywords' && list.clinical_keywords) {\r\n                            return list.clinical_keywords.map(function (result) {\r\n                                return {\r\n                                    header: remote.displayName,\r\n                                    displayName: result.name,\r\n                                    type: remote.id,\r\n                                    name: result.name,\r\n                                };\r\n                            });\r\n                        }\r\n                        else if (remote.name == 'location_name' && list.location_name) {\r\n                            return list.location_name.map(function (result) {\r\n                                return {\r\n                                    header: remote.displayName,\r\n                                    displayName: result.name,\r\n                                    type: remote.id,\r\n                                    name: result.name,\r\n                                };\r\n                            });\r\n                        }\r\n                        else if (remote.name == 'practice_group' && list.practice_group) {\r\n                            return list.practice_group.map(function (result) {\r\n                                return {\r\n                                    header: remote.displayName,\r\n                                    displayName: result.name,\r\n                                    type: remote.id,\r\n                                    name: result.name,\r\n                                };\r\n                            });\r\n                        }\r\n                    }\r\n                },\r\n                thumbprint: remote.id,\r\n            });\r\n        });\r\n\r\n        // Init typeahead\r\n        this.ui.$typeaheadInput.typeahead.apply(this.ui.$typeaheadInput, [{\r\n            minLength: 2,\r\n            hint: false,\r\n            highlight: true\r\n        }].concat(remoteEndpoints.map((remote) => {\r\n            return {\r\n                name: remote.id,\r\n                displayKey: 'displayName',\r\n                display: 'displayName',\r\n                limit: remote.id === 'p' || remote.id === 'sop' ? 10000 : 7,\r\n                templates: {\r\n                    header: (query) => query.suggestions[0].header ? `\r\n                            <h3 class=\"twitter-typeahead__header\">${query.suggestions[0].header}</h3>\r\n                        ` : undefined,\r\n                    suggestion: (data) => `\r\n                            <div class=\"twitter-typeahead__suggestion\">\r\n                                <span class=\"twitter-typeahead__suggestion-name\">${data.displayName}</span>\r\n                            </div>\r\n                        `,\r\n                    footer: remote.id === 'p' || remote.id === 'sop' ? () => `\r\n                            <div class=\"twitter-typeahead__footer\">\r\n                              <a class=\"twitter-typeahead__load_more js-typeahead-load-more\" href=\"javascript:;\" data-prev-label=\"See Less\">\r\n                                See All\r\n                              </a>\r\n                            </div>\r\n                        ` : false\r\n                },\r\n                // `ttAdapter` wraps the suggestion engine in an adapter that\r\n                // is compatible with the typeahead jQuery plugin\r\n                source: bloodhoundSources[remote.id].ttAdapter()\r\n            };\r\n        })));\r\n\r\n        // ui.typeaheadInput\r\n\r\n    }\r\n}\r\n\r\nexport default TypeaheadKryuus;\r\n"],"names":["TypeaheadKryuus","options","wrap","this","ui","$typeaheadInput","$","find","$searchType","$searchTermActual","window","addEventListener","implementTypeahead","length","on","ev","suggestion","val","type","console","log","value","name","removeClass","e","preventDefault","linkLabel","currentTarget","text","linkPrevLabel","data","closest","toggleClass","attr","key","remoteEndpoints","id","displayName","url","bloodhoundSources","forEach","remote","Bloodhound","datumTokenizer","tokenizers","whitespace","queryTokenizer","limit","wildcard","rateLimitBy","rateLimitWait","transform","list","provider_name","map","result","header","specialties","primary_care","clinical_keywords","location_name","practice_group","thumbprint","typeahead","apply","minLength","hint","highlight","concat","displayKey","display","templates","query","suggestions","undefined","footer","source","ttAdapter"],"sourceRoot":""}