!function(){var e={281:function(e){e.exports=function(e){var t=function(r,n,i){var s=r.splice(0,50);i=(i=i||[]).concat(e.add(s)),r.length>0?setTimeout((function(){t(r,n,i)}),1):(e.update(),n(i))};return t}},332:function(e){e.exports=function(e){return e.handlers.filterStart=e.handlers.filterStart||[],e.handlers.filterComplete=e.handlers.filterComplete||[],function(t){if(e.trigger("filterStart"),e.i=1,e.reset.filter(),void 0===t)e.filtered=!1;else{e.filtered=!0;for(var r=e.items,n=0,i=r.length;np.page,a=new v(e[i],void 0,n),p.items.push(a),r.push(a)}return p.update(),r}g(e.slice(0),t)}},this.show=function(e,t){return this.i=e,this.page=t,p.update(),p},this.remove=function(e,t,r){for(var n=0,i=0,s=p.items.length;i-1&&r.splice(n,1),p},this.trigger=function(e){for(var t=p.handlers[e].length;t--;)p.handlers[e][t](p);return p},this.reset={filter:function(){for(var e=p.items,t=e.length;t--;)e[t].filtered=!1;return p},search:function(){for(var e=p.items,t=e.length;t--;)e[t].found=!1;return p}},this.update=function(){var e=p.items,t=e.length;p.visibleItems=[],p.matchingItems=[],p.templater.clear();for(var r=0;r=p.i&&p.visibleItems.lengtht},innerWindow:function(e,t,r){return e>=t-r&&e<=t+r},dotted:function(e,t,r,n,i,s,a){return this.dottedLeft(e,t,r,n,i,s)||this.dottedRight(e,t,r,n,i,s,a)},dottedLeft:function(e,t,r,n,i,s){return t==r+1&&!this.innerWindow(t,i,s)&&!this.right(t,n)},dottedRight:function(e,t,r,n,i,s,a){return!e.items[a-1].values().dotted&&t==n&&!this.innerWindow(t,i,s)&&!this.right(t,n)}};return function(t){var n=new s(e.listContainer.id,{listClass:t.paginationClass||"pagination",item:t.item||"
  • ",valueNames:["page","dotted"],searchClass:"pagination-search-that-is-not-supposed-to-exist",sortClass:"pagination-sort-that-is-not-supposed-to-exist"});i.bind(n.listContainer,"click",(function(t){var r=t.target||t.srcElement,n=e.utils.getAttribute(r,"data-page"),i=e.utils.getAttribute(r,"data-i");i&&e.show((i-1)*n+1,n)})),e.on("updated",(function(){r(n,t)})),r(n,t)}}},607:function(e,t,r){e.exports=function(e){var t=r(266)(e),n=function(r,n){for(var i=0,s=r.length;i0?setTimeout((function(){i(t,r)}),1):(e.update(),e.trigger("parseComplete"))};return e.handlers.parseComplete=e.handlers.parseComplete||[],function(){var t=function(e){for(var t=e.childNodes,r=[],n=0,i=t.length;n]/g.exec(e)){var t=document.createElement("tbody");return t.innerHTML=e,t.firstElementChild}if(-1!==e.indexOf("<")){var r=document.createElement("div");return r.innerHTML=e,r.firstElementChild}}},i=function(t,r,n){var i=void 0,s=function(t){for(var r=0,n=e.valueNames.length;r=1;)e.list.removeChild(e.list.firstChild)},function(){var r;if("function"!=typeof e.item){if(!(r="string"==typeof e.item?-1===e.item.indexOf("<")?document.getElementById(e.item):n(e.item):function(){for(var t=e.list.childNodes,r=0,n=t.length;r32)return!1;var a=n,o=function(){var e,r={};for(e=0;e=m;w--){var C=o[e.charAt(w-1)];if(b[w]=0===g?(b[w+1]<<1|1)&C:(b[w+1]<<1|1)&C|(p[w+1]|p[w])<<1|1|p[w+1],b[w]&f){var _=l(g,w-1);if(_<=c){if(c=_,!((u=w-1)>a))break;m=Math.max(1,2*a-u)}}}if(l(g+1,a)>c)break;p=b}return!(u<0)}},961:function(e){e.exports=function(e,t){var r=e.getAttribute&&e.getAttribute(t)||null;if(!r)for(var n=e.attributes,i=n.length,s=0;s=48&&e<=57}function s(e,t){for(var s=(e+="").length,a=(t+="").length,o=0,l=0;o=s&&l=a?-1:l>=a&&o=s?1:s-a}s.caseInsensitive=s.i=function(e,t){return s((""+e).toLowerCase(),(""+t).toLowerCase())},Object.defineProperties(s,{alphabet:{get:function(){return t},set:function(e){r=[];var i=0;if(t=e)for(;i=this.retries+1}createUrl(){let e=this.url;return e+=`?callback=${this.CALLBACK}`,this.apiKey&&(e+=`&key=${this.apiKey}`),this.channel&&(e+=`&channel=${this.channel}`),this.client&&(e+=`&client=${this.client}`),this.libraries.length>0&&(e+=`&libraries=${this.libraries.join(",")}`),this.language&&(e+=`&language=${this.language}`),this.region&&(e+=`®ion=${this.region}`),this.version&&(e+=`&v=${this.version}`),this.mapIds&&(e+=`&map_ids=${this.mapIds.join(",")}`),e}load(){return this.loadPromise()}loadPromise(){return new Promise(((e,t)=>{this.loadCallback((r=>{r?t(r.error):e(window.google)}))}))}loadCallback(e){this.callbacks.push(e),this.execute()}setScript(){if(document.getElementById(this.id))return void this.callback();const e=this.createUrl(),t=document.createElement("script");t.id=this.id,t.type="text/javascript",t.src=e,t.onerror=this.loadErrorCallback.bind(this),t.defer=!0,t.async=!0,this.nonce&&(t.nonce=this.nonce),document.head.appendChild(t)}deleteScript(){const e=document.getElementById(this.id);e&&e.remove()}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(e){if(this.errors.push(e),this.errors.length<=this.retries){const e=this.errors.length*Math.pow(2,this.errors.length);console.log(`Failed to load Google Maps script, retrying in ${e} ms.`),setTimeout((()=>{this.deleteScript(),this.setScript()}),e)}else this.onerrorEvent=e,this.callback()}setCallback(){window.__googleMapsCallback=this.callback.bind(this)}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach((e=>{e(this.onerrorEvent)})),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version)return console.warn("Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."),void this.callback();this.loading||(this.loading=!0,this.setCallback(),this.setScript())}}}var i=window.wp.i18n,s=r(709),a=r.n(s);const o=RS.googleAPIKey,l=document.getElementById("rs-content-window"),c=document.getElementById("rs-search-form"),u=document.getElementById("address"),d=document.getElementById("wp-block-representative-search--map"),h=document.getElementById("rs-toggle-overlay"),f=document.getElementById("rs-error-messages"),p=document.getElementById("rs-level-select"),v=document.getElementById("rs-map"),g=document.getElementById("rs-level-select-manual"),m=document.querySelectorAll("#rs-search-form-manual .districts"),y=document.getElementById("rs-filters"),b=document.getElementById("address");let w,C,_;function S(){console.log(...arguments)}function I(){w=new google.maps.Map(v,{zoom:5,center:{lat:36.778259,lng:-119.417931},disableDefaultUI:!0,draggable:!0,zoomControl:!0,zoomControlOptions:{position:google.maps.ControlPosition.LEFT_BOTTOM},scrollwheel:!0,panControl:!0}),C=new google.maps.places.Autocomplete(u,{bounds:{north:42.009517,south:32.528832,west:-124.482003,east:-114.131211},strictBounds:!1,componentRestrictions:{country:"us"},fields:["geometry"]}),C.addListener("place_changed",(e=>{$()})),c.addEventListener("submit",(e=>{e.preventDefault(),$()})),g.addEventListener("change",(e=>{e.preventDefault(),m.forEach((e=>{e.style.display="none"})),document.getElementById(e.target.value+"-districts").style.display="inline-block"})),m.forEach((e=>{e.addEventListener("change",(e=>{e.preventDefault(),b.value="",y.style.display="none";var t=e.target.value,r="https://www.googleapis.com/civicinfo/v2/representatives/"+encodeURIComponent(t);fetch(r+"?key="+o).then((e=>e.json())).then((r=>{D("rs-"+e.target.name,r.officials[0],P(t))}))}))}))}function E(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;var r=null!==t?t:j(e),n=P(r),i=document.querySelectorAll(".rs-reps .rep");S("loadDistrict",{district:r,districtNumber:n,reps:i}),0{"DOCUMENT_NOT_FOUND"===_.status&&(w.setCenter({lat:36.7783,lng:-119.4179}),w.setZoom(5),S("loadDistrict",{kmlLayerStatus:_.status}))}),500)}new n({apiKey:o,version:"weekly",libraries:["places"]}).load().then((e=>{I()})).catch((e=>{}));const O=e=>{var t=sessionStorage.getItem("rs-"+e);t?T(JSON.parse(t),e).then((e=>A(e))):console.warn("No rep saved for level "+e)},A=e=>{var t={valueNames:["name","website","party","photo","district","score","takes_oil_money","link","rep_photo","new_legislator"],item:e=>{var t="",r=e.rep_photo?`
    `:`
    `,n=e.link;if(void 0!==e.score&&"YES"!==e.new_legislator){var s=e.score,a="letter-f",o="F";89s?(a="letter-b",o="B"):69s?(a="letter-c",o="C"):64s&&(a="letter-d",o="D"),t=`
    ${(0,i.__)("Current Score","representative-search")}: ${o}
    `}var l=`\n\t\t\t
    \n\t\t\t${r}\n\t\t\t\t
    ${t}
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t

    ${e.name}

    \n\t\t\t\t

    ${(0,i.__)(e.party,"representative-search")}

    \n\t\t\t\t

    ${(0,i.__)("District","representative-search")} ${e.district}

    \n\t\t\t
    `,c="YES"!==e.new_legislator?`

    View Environmental Score

    `:"";return n&&(l=`\n\t\t\t\t
    \n\t\t\t\t\t${r}\n\t\t\t\t\t
    ${t}
    \n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t

    ${e.name}

    \n\t\t\t\t\t

    ${(0,i.__)(e.party,"representative-search")}

    \n\t\t\t\t\t

    ${(0,i.__)("District","representative-search")} ${e.district}

    \n\t\t\t\t\t${c}\n\t\t\t\t
    `),`
  • ${l}
  • `}},r=new(a())("reps",t);r.clear(),r.add([e],(e=>k(e))),(()=>{const e=d.getBoundingClientRect().top+window.pageYOffset+-60;window.scrollTo({top:e,behavior:"smooth"})})()},k=e=>{0===e.length&&(document.querySelector(".rs-reps").innerHTML=`

    ${(0,i.__)("No matching representatives for this district","representative-search")}

    `)};h.onclick=function(){l.classList.toggle("active")};const x=e=>{f.innerHTML='

    '+e+"

    "},$=()=>{(e=>{fetch("https://www.googleapis.com/civicinfo/v2/representatives?includeOffices=false&levels=country&levels=administrativeArea1&roles=legislatorLowerBody&roles=legislatorUpperBody&address="+encodeURI(e)+"&key="+o).then((e=>e.json())).then((t=>{t.error?x(t.error.message):""===t.normalizedInput.line1?x((0,i.__)("Please enter your full address","representative-search")):"CA"!==t.normalizedInput.state?x((0,i.__)("Please enter a valid CA address","representative-search")):(S(t),f.innerHTML="",B(Object.keys(t.divisions)),j("sldl")&&j("sldu")||N(e),y.style.display="block",p.value="sldl",R("sldl"))}))})(new FormData(c).get("rs-address"))},N=e=>{var t="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates",r=new URLSearchParams;r.append("SingleLine",e),r.append("forStorage","false"),r.append("f","pjson"),r.append("w","300"),t+=`?${r.toString()}`,fetch(t).then((e=>e.json())).then((e=>{S("fallbackAddressSearch",e),e.candidates&&e.candidates[0].location&&e.candidates[0].location.x&&e.spatialReference?L(JSON.stringify(e.spatialReference),e.candidates[0].location.x,e.candidates[0].location.y):x((0,i.__)("We could not find the representative for the provided address. Please go to the https://findyourrep.legislature.ca.gov/ to locate ypur representatives","representative-search"))}))},L=(e,t,r)=>{var n="https://services5.arcgis.com/0CGHmi5SBMvfD65u/arcgis/rest/services/AD_SD_2011_2021_Union/FeatureServer/4/query",s=new URLSearchParams;s.append("f","json"),s.append("returnGeometry","false"),s.append("spatialRel","esriSpatialRelIntersects"),s.append("geometry",`{"x":${t},"y":${r},"spatialReference":${e}}`),s.append("geometryType","esriGeometryPoint"),s.append("outFields","AD_2011,SD_2011,AD_2021,SD_2021"),n+=`?${s.toString()}`,fetch(n).then((e=>e.json())).then((e=>{if(S("fallbackGetDistrict",e),e.features&&e.features[0].attributes){let t=P(j("sldu"));if(!t){const r=parseInt(e.features[0].attributes.SD_2011,10),n=parseInt(e.features[0].attributes.SD_2021,10);t=r%2!=0?r:n,console.log("senateDistrict",t)}let r=P(j("sldl"));r||(r=parseInt(e.features[0].attributes.AD_2021,10)),B([`ocd-division/country:us/state:ca/sldl:${r}`,`ocd-division/country:us/state:ca/sldu:${t}`])}else x((0,i.__)("We could not find the representative for the provided address. Please go to the https://findyourrep.legislature.ca.gov/ to locate ypur representatives","representative-search"))}))},B=e=>{M(),sessionStorage.setItem("rs-user-districts",JSON.stringify(e))},P=e=>{if(void 0!==e)return e.replace(/\D/g,"")},j=e=>{var t=sessionStorage.getItem("rs-user-districts");if(t)return(t=JSON.parse(t)).find((function(t){return t.replace("ocd-division/country:us/state:ca/","").includes(e)}))},D=(e,t,r)=>{var n={name:t.name,website:Array.isArray(t.urls)&&t.urls.length>0?t.urls[0]:"",party:t.party,photo:t.hasOwnProperty("photoUrl")?t.photoUrl.replace(/^http:\/\//i,"https://"):null,district:r};sessionStorage.setItem(e,JSON.stringify(n)),window.dispatchEvent(new Event("new-rep"))},R=e=>{if(sessionStorage.getItem("rs-"+e))window.dispatchEvent(new Event("new-rep"));else{var t=j(e);if(t){var r="https://www.googleapis.com/civicinfo/v2/representatives/"+encodeURIComponent(t);fetch(r+"?key="+o).then((e=>e.json())).then((r=>{S("getRepsByLevel",r),D("rs-"+e,r.officials[0],P(t))}))}else console.error("Failed to find district for level",e)}};p.addEventListener("change",(function(e){R(e.target.value)}),!1),window.addEventListener("new-rep",(function(e){var t=p.value;""!==b.value?(E(t),O(t)):(E(t=g.value,document.getElementById(t+"-districts").value),O(t))}));const M=()=>{sessionStorage.removeItem("rs-sldl"),sessionStorage.removeItem("rs-sldu"),sessionStorage.removeItem("rs-cd")},T=(e,t)=>new Promise(((r,n)=>{S("getRepContent",e.name,e.district,t);let i=RS.root+"wp/v2/rs-representatives?api-title="+encodeURIComponent(e.name)+"&api-district="+encodeURIComponent(e.district)+"&api-level="+encodeURIComponent(t);e.hasOwnProperty("location")&&e.location&&(i+="&api-location="+encodeURIComponent(e.location)),S("fetchURL",i),fetch(i,{headers:{"Content-Type":"application/json","X-WP-Nonce":RS.nonce}}).then((e=>{S("getRepContent resp",e);let t=e.json();return 200===e.status?t:t.then(Promise.reject.bind(Promise))})).then((t=>{S("getRepContent data",t,e);var n={...e};if(0