"use strict";(self.webpackChunkfindagrave_frontend=self.webpackChunkfindagrave_frontend||[]).push([[9923],{69917(e,t,a){a.d(t,{Ri:()=>i,TV:()=>n,kQ:()=>o});a(71757);function n(e,t,a,n){let i="",o=`path= ${n&&n.length>0?n:"/"};`,r=`domain=.${location.hostname.split(".").slice(-2).join(".")};`;if(a){let e=new Date;e.setTime(e.getTime()+24*a*60*60*1e3),i=`expires=${e.toUTCString()};`}document.cookie=`${e}=${t};${i}${o}${r}SameSite=Lax;Secure;`}function i(e){let t=document.cookie.split("; ").find(t=>t.split("=")[0]===e);return t?t.split("=")[1]:""}function o(){var e=i("consentSettings"),t={pref:!1,ga:!1,aa:!1};try{t=JSON.parse(e)}catch(e){}return t}},195(e,t,a){var n=a(71757),i=a.n(n),o=(a(62427),a(29462)),r=a.n(o),s=a(39708),d=function(e,t,a,n){return new(a||(a=Promise))(function(i,o){function r(e){try{d(n.next(e))}catch(e){o(e)}}function s(e){try{d(n.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?i(e.value):(t=e.value,t instanceof a?t:new a(function(e){e(t)})).then(r,s)}d((n=n.apply(e,t||[])).next())})};const l=a(56641),c=a(18510),h=a(53547),g=a(44879),p=new TextEncoder;class y{constructor(e){e.onSelect&&(e.onSelect=e.onSelect.bind(this)),e.onChange&&(e.onChange=e.onChange.bind(this)),this.settings=i().extend({onChange:this.getDefaultOnChange(this)},y.defaults,e),this.initializeCemeteryTypeAhead(this.settings),this.initializeLocationTypeAhead(this.settings),i()("#only-with-cemeteries").on("click",function(){this.checked?this.initializeLocationTypeAhead(this.settings):this.initializeLocationTypeAhead({locationCategories:["loc"]})})}initializeLocationTypeAhead({locationCategories:e,enterSubmitsForm:t}){const a=this.getBloodHound(e,"loc",this.settings.havingCoordinates),n=i()("#cemetery-loc").typeahead("destroy").typeahead({hint:!0,highlight:!0,minLength:1},{name:"cemetery",source:a.ttAdapter(),async:!0,displayKey:"text",limit:5,templates:{suggestion:function(e){return"
"+e.text+"
"},footer:function(){return l.render()},notFound:function({query:e}){return p.encode(e).length<3?h.render():c.render()}}}),o=i()("#locationId"),r=i()("#cemetery-loc"),s=r.parent().parent().find(".clear-search"),d=``;let g;r.addClass("form-control").after(d).parent().addClass("form-floating"),n.typeahead("val")&&s.removeClass("hidden"),n.on("typeahead:autocomplete typeahead:select",function(e,t){o.val(t.id).data("d",t),i()("#cemetery-name, #cemetery-loc").removeClass("show-error"),g=t,n.trigger("typeahead:set",[t.id]),i()("#cemeteryError").hide(),s.removeClass("hidden")}).on("typeahead:change",function(e){n.typeahead("val").trim().length>=3?(g?(o.val(g.id).data("d",g),n.trigger("typeahead:set",[g.id]),n.typeahead("val",g.text),n.typeahead("close")):o.val("").removeData("d"),s.removeClass("hidden")):(o.val("").removeData("d"),n.trigger("typeahead.clear"),s.addClass("hidden"))}).on("typeahead:render",function(e,t){t&&t.length>0&&t[0]&&(g=t[0])}),s.on("click",function(){n.typeahead("val",""),n.trigger("focus"),o.val("").removeData("d"),n.trigger("typeahead.clear"),g=null,i()(this).addClass("hidden")}),r.on("keydown",function(e){if(13==e.which||9==e.which){p.encode(r.typeahead("val").trim()).length>=3?g?(o.val(g.id).data("d",g),n.typeahead("val",g.text),n.trigger("typeahead:set",[g.id]),s.removeClass("hidden")):e.preventDefault():n.typeahead("val","")}else e.key&&(["arrowup","arrowdown","arrowleft","arrowright","end","home","pagedown","pageup","meta","control","alt"].includes(e.key.toLowerCase())||e.metaKey||e.ctrlKey)||(g=null);return i()(this).val().trim().length>0?s.removeClass("hidden"):s.addClass("hidden"),t||13!=e.which}).on("click",function(e){g&&r.typeahead("val").trim().length>=3&&(o.val(g.id).data("d",g),n.typeahead("val",g.text),n.trigger("typeahead:set",[g.id]),n.typeahead("close"),s.removeClass("hidden"))})}initializeCemeteryTypeAhead({cemeteryCategories:e}){const t=this,a=this.getBloodHound(e,"cem"),n=i()("#cemetery-name").typeahead("destroy").typeahead({hint:!1,highlight:!0,minLength:1},{name:"cemetery",source:a.ttAdapter(),displayKey:"text",limit:5,templates:{suggestion:function(e){return""+e.text+"
"},footer:function(e){if(e.suggestions.length>=5)return g.render()}}});this.cemeteryTypeAhead=n;i()("#cemetery-id").val(""),n.on("typeahead:autocomplete typeahead:select",this.settings.onSelect).on("typeahead:change",this.settings.onChange);const o=``;n.addClass("form-control").after(o).parent().addClass("form-floating");const r=i()("#cemetery-name").parent().parent().find(".clear-search");n.typeahead("val")&&r.removeClass("hidden"),i()("#cemetery-name").on("keypress",function(e){9!==e.which&&13!==e.which&&r.removeClass("hidden")}).on("keydown",function(e){8!==e.which&&46!==e.which||1!==n.typeahead("val").trim().length||r.addClass("hidden"),9!==e.which&&13!==e.which&&setTimeout(()=>{t.currentNameInput=i()("#cemetery-name").val().toString().trim()},0)}),r.on("click",function(e){n.typeahead("val",""),n.trigger("focus"),i()(this).addClass("hidden")})}getBloodHound(e,t,a){return new(r())({datumTokenizer:function(e){return r().tokenizers.whitespace(e.text)},queryTokenizer:r().tokenizers.whitespace,identify:e=>e.id,remote:{url:"/graphql?q=%prefix&t="+t,wildcard:"%prefix",transform:function(e){var a;return(null===(a=null==e?void 0:e.locationsByTypeahead)||void 0===a?void 0:a.locations.map(function(a){(a=Object.assign({},a)).text="cem"===t?a.names[0].name.replace(/&/g,"&"):["city","county","state","country"].map(e=>a.locations[0][e]).filter(e=>e).join(", ");const n=e.query.trim().split(/[\p{P}\s]+/u).filter(e=>e).map(e=>e.toLocaleLowerCase()),i=a.text.toLocaleLowerCase();return!n.every(e=>i.includes(e))&&a.highlight&&(a.text+=` (${a.highlight})`),a}))||[]},prepare:(e,t)=>(t.skipLoad=p.encode(e).length<3,t.name=e,t.url=t.url.replace("%prefix",e),t),transport:(n,o,r)=>d(this,void 0,void 0,function*(){if(n.skipLoad)o({locations:{locations:[],total:0}});else{let d;const l=i()("#locationId").val();"cem"===t&&""!==l.trim()&&(d=l);const{errors:c,data:h}=yield this.settings.apolloClient.query({query:s.J1`
query locationTypeahead($search: LocationSearchInput) {
locationsByTypeahead(search: $search) {
total
locations {
... on Location {
id
locations(format: short){ city county state country continent }
names { name }
highlight
}
... on Cemetery {
id
locations(format: short){ cemetery city county state country continent }
names { name }
highlight
}
}
}
}
`,variables:{search:{name:n.name,autocomplete:"cem"===t?"name":"location",categories:e,containingLocationId:d,havingCoordinates:a,returnHighlight:!0}},errorPolicy:"all"});c?r(c):o(Object.assign(Object.assign({},h),{query:n.name.toLocaleLowerCase()}))}})}})}getDefaultOnChange(e){return function(t){e.cemeteryTypeAhead.typeahead("val").trim().length>2&&(i()("#cemetery-name, #cemetery-loc").removeClass("show-error"),i()("#cemeteryError").hide())}}}y.defaults={cemeteryCategories:["cem"],locationCategories:["yes"],enterSubmitsForm:!0,onSelect:function(e,t){i()("#cemetery-name, #cemetery-loc").removeClass("show-error"),i()("#cemeteryError").hide()}};const u=y;a.d(t,["A",0,u])},56533(e,t,a){a.d(t,{Ay:()=>h});var n=a(71757),i=a.n(n),o=(a(62427),a(29462)),r=a.n(o),s=a(39708),d=function(e,t,a,n){return new(a||(a=Promise))(function(i,o){function r(e){try{d(n.next(e))}catch(e){o(e)}}function s(e){try{d(n.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?i(e.value):(t=e.value,t instanceof a?t:new a(function(e){e(t)})).then(r,s)}d((n=n.apply(e,t||[])).next())})};const l=a(18510),c=a(53547);function h(){return{singleTypeahead:function(e){this.settings=i().extend({},this.defaults,e),this.changed=!1;const t=this,a=new TextEncoder;let n=new(r())({datumTokenizer:function(e){return r().tokenizers.whitespace(e.text)},queryTokenizer:r().tokenizers.whitespace,remote:{url:"/graphql/q=%prefix",wildcard:"%prefix",prepare:(e,t)=>(t.skipLoad=!/^\d+$/.test(e.trim())&&a.encode(e).length<3,t.name=e,t.url=t.url.replace("%prefix",e),t),transform:function(e){var a;return(null===(a=e.locationsByTypeahead)||void 0===a?void 0:a.locations.map(function(a){(a=Object.assign({},a)).text=["cemetery","city","county","state","country"].map(e=>a.locations[0][e]).filter(e=>e).join(", ").replace(/&/g,"&"),t.settings.displayId&&(a.text+=` (${a.id})`);const n=e.query.trim().split(/[\p{P}\s]+/u).filter(e=>e).map(e=>e.toLocaleLowerCase()),i=a.text.toLocaleLowerCase();return!n.every(e=>i.includes(e))&&a.highlight&&(a.text+=` (${a.highlight})`),a}))||[]},transport:(e,t,a)=>d(this,void 0,void 0,function*(){if(e.skipLoad)t([]);else{const{errors:n,data:i}=yield this.settings.apolloClient.query({query:s.J1`
query locationTypeahead($search: LocationSearchInput) {
locationsByTypeahead(search: $search) {
total
locations {
... on Location {
id
locations(format: short){ city county state country continent }
names { name }
coordinates { lat lon }
highlight
}
... on Cemetery {
id
locations(format: short){ cemetery city county state country continent }
names { name }
coordinates { lat lon }
highlight
}
}
}
}
`,variables:{search:{name:e.name,autocomplete:this.settings.autocomplete,categories:this.settings.type,havingCoordinates:this.settings.havingCoordinates,returnHighlight:!0}},errorPolicy:"all"});n?a(n):t(Object.assign(Object.assign({},i),{query:e.name.toLocaleLowerCase()}))}})}});this.typeaheadEl=i()(this.settings.inputId),this.typeahead=this.typeaheadEl.typeahead(this.settings.displayOptions,{name:this.settings.inputId.replace(/[#.]/,""),source:n.ttAdapter(),displayKey:"text",limit:5,templates:{notFound:function({query:e}){return!/^\d+$/.test(e.trim())&&a.encode(e).length<3?c.render():l.render()}}});const o=``;return this.typeaheadEl.addClass("form-control").after(o).parent().addClass("form-floating"),this.clearLocation=this.typeaheadEl.parents(".btn-group, .input-group").find(".clear-search"),this.targetId=i()(this.settings.targetId),this.typeahead.on("typeahead:autocomplete typeahead:select",function(e,a){t.targetId.val(null==a?void 0:a.id).data("d",a),t.typeahead.trigger("typeahead:set",[a]),t.targetId.trigger("change"),t.topSuggestion=a,t.clearLocation.removeClass("hidden")}).on("typeahead:change",function(e){var n;t.settings.onChange.call(t,e),!t.targetId.val().trim()&&a.encode(t.typeahead.typeahead("val").trim()).length>=3&&(t.changed=!0,null===(n=t.settings.onEmpty)||void 0===n||n.call(t))}).on("typeahead:render",function(e,a){a&&a.length>0&&a[0]&&(t.topSuggestion=a[0])}),t.typeahead.typeahead("val")&&t.typeahead.typeahead("val").trim().length>0&&t.clearLocation.removeClass("hidden"),t.clearLocation.on("click",function(){t.typeahead.typeahead("val",""),t.typeahead.trigger("typeahead:clear"),t.typeahead.trigger("focus"),t.targetId.val("").removeData("d"),t.targetId.trigger("change"),t.topSuggestion=null,i()(this).addClass("hidden")}),t.typeaheadEl.on("keydown",function(e){var n;if(13==e.which||9==e.which){a.encode(t.typeahead.typeahead("val").trim()).length>=3?t.topSuggestion?(t.targetId.val(t.topSuggestion.id).data("d",t.topSuggestion),t.typeahead.typeahead("val",t.topSuggestion.text),t.typeahead.trigger("typeahead:set",[t.topSuggestion]),t.targetId.trigger("change"),t.clearLocation.removeClass("hidden")):e.preventDefault():t.typeahead.typeahead("val","")}else["arrowup","arrowdown","arrowleft","arrowright","end","home","pagedown","pageup","meta","control","alt"].includes(null===(n=e.key)||void 0===n?void 0:n.toLowerCase())||e.metaKey||e.ctrlKey||(t.topSuggestion=null);return i()(this).val().trim().length>0?t.clearLocation.removeClass("hidden"):t.clearLocation.addClass("hidden"),t.settings.enterSubmitsForm||13!=e.which}).on("click",function(e){t.topSuggestion&&t.typeahead.typeahead("val").trim().length>=3&&(t.targetId.val(t.topSuggestion.id).data("d",t.topSuggestion),t.typeahead.typeahead("val",t.topSuggestion.text),t.typeahead.trigger("typeahead:set",[t.topSuggestion]),t.targetId.trigger("change"),t.typeahead.typeahead("close"),t.clearLocation.removeClass("hidden"))}),t},defaults:{inputId:"#location",targetId:"#locationId",type:g,autocomplete:"location",enterSubmitsForm:!0,noContinents:!1,displayId:!1,displayOptions:{hint:!0,highlight:!0,minLength:1},onEmpty:!1,clearEmpty:!1,onChange:function(e){this.typeahead.typeahead("val").trim().length>=3?(this.topSuggestion?(this.targetId.val(this.topSuggestion.id).data("d",this.topSuggestion),this.typeahead.trigger("typeahead:set",[this.topSuggestion]),this.targetId.trigger("change"),this.typeahead.typeahead("val",this.topSuggestion.text),this.typeahead.typeahead("close")):this.targetId.val("").removeData("d"),this.clearLocation.removeClass("hidden")):(this.targetId.val("").removeData("d"),this.typeahead.trigger("typeahead:clear"),this.targetId.trigger("change"),this.clearLocation.addClass("hidden"))}}}}const g=["loc"]}}]);
//# sourceMappingURL=9923.292ddb12748002145ba6.js.map