1(()=>{"use strict";const e=window.wc.blocksCheckout,t=window.React,s=window.wp.element,i=window.wp.components,n=window.wp.primitives,a=(0,t.createElement)(n.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -2 24 24"},(0,t.createElement)(n.Path,{d:"M10 2c4.42 0 8 3.58 8 8s-3.58 8-8 8-8-3.58-8-8 3.58-8 8-8zm1.13 9.38l.35-6.46H8.52l.35 6.46h2.26zm-.09 3.36c.24-.23.37-.55.37-.96 0-.42-.12-.74-.36-.97s-.59-.35-1.06-.35-.82.12-1.07.35-.37.55-.37.97c0 .41.13.73.38.96.26.23.61.34 1.06.34s.8-.11 1.05-.34z"})),l=window.wp.data,o=window.lodash,r=()=>wcSettings&&wcSettings["omnivalt-blocks_data"]?wcSettings["omnivalt-blocks_data"]:[],c=()=>{const e=r();return e&&e.picapac?e.picapac:{}},m=e=>!!e.startsWith("omnivalt"),h=e=>{u("Got method key:",e);const t=e.split(":")[0];for(let[e,s]of Object.entries(r().methods))if(t==s)return u("Detected Omniva method:",s),!0;return!1},d=e=>{const t=c(),s=e?e.split(":")[0]:"";return Boolean(t.rate_id)&&s===t.rate_id},_=r().debug,p="OMNIVA BLOCKS DEBUG:",u=(...e)=>{_&&console.log(p,...e)},v=(e,t)=>{_&&(0,s.useEffect)(()=>{console.log(p,'Changed state "'+e+'" value to:',t)},[t])},f=window.wp.i18n,g=wcSettings["omnivalt-blocks_data"].txt,y=((0,f.__)("Block options","omnivalt"),(0,f.__)("Parcel terminal","omnivalt"),(0,f.__)("Select parcel terminal","omnivalt"),(0,f.__)("Please select parcel terminal","omnivalt"),(0,f.__)("You can choose the parcel terminal on the Checkout page","omnivalt"),(0,f.__)("Loading select field...","omnivalt"),(0,f.__)("Post office","omnivalt"),(0,f.__)("Select post office","omnivalt"),(0,f.__)("Please select post office","omnivalt"),(0,f.__)("You can choose the post office on the Checkout page","omnivalt"),(0,f.__)("Omniva","omnivalt"),(0,f.__)("Matkahuolto","omnivalt"),(0,f.__)("Invalid format","omnivalt"),(0,f.__)("The phone format specified in the Shipping address is not valid for this shipping method","omnivalt"),(0,f.__)("post offices","omnivalt"),(0,f.__)("parcel terminals","omnivalt"),(0,f.__)("Post offices list","omnivalt"),(0,f.__)("Parcel terminals list","omnivalt"),(0,f.__)("Select post office","omnivalt"),(0,f.__)("Select terminal","omnivalt"),(0,f.__)("Enter postcode","omnivalt"),(0,f.__)("Search","omnivalt"),(0,f.__)("Select","omnivalt"),(0,f.__)("Select in map","omnivalt"),(0,f.__)("Use my location","omnivalt"),(0,f.__)("Distance calculated from this point","omnivalt"),(0,f.__)("Place not found","omnivalt"),(0,f.__)("There were no cities found for your search term","omnivalt"),(0,f.__)("Geolocation is not supported","omnivalt"),(0,f.__)("Place not found","omnivalt"),(0,f.__)("Value is too short","omnivalt"),(0,f.__)("Select terminal","omnivalt"),(0,f.__)("parcel terminals","omnivalt"),(0,f.__)("Parcel terminals addresses","omnivalt"),(0,f.__)("Select post office","omnivalt"),(0,f.__)("post offices","omnivalt"),(0,f.__)("Post offices addresses","omnivalt"),(0,f.__)("Enter postcode/address","omnivalt"),(0,f.__)("Show in map","omnivalt"),(0,f.__)("Show more","omnivalt"),e=>{let t="";let s=0;for(;s<e;)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random())),s+=1;return t}),w=(e,t=0)=>(t||(t=5),{value:e,token:y(t)}),b=e=>{for(const t in e)if(Object.hasOwn(e,t))return!1;return!0},E=async e=>{let t=null;try{let s=await fetch(e);t=await s.json()}catch(e){console.error("OMNIVA UTILS:",e)}return t},S=(e,t)=>{e.value=t;const s=new Event("change",{bubbles:!0});e.dispatchEvent(s)},k=()=>({lib:null,elements:{},translations:{},params:{},variables:{allow_close_modal:!0},load_data:function(e){this.elements={org_field:this.set_param(e,"org_field",null),map_container:this.set_param(e,"map_container",null)},this.params={provider:this.set_param(e,"provider","omniva"),terminals_type:this.set_param(e,"terminals_type","terminal"),selected_terminal:this.set_param(e,"selected_terminal",""),autoselect:this.set_param(e,"autoselect",!0),icons_url:this.set_param(e,"icons_url",`${r().plugin_url}assets/img/terminal-mapping/`),country:this.set_param(e,"country","LT"),map_icon:this.set_param(e,"map_icon","omnivalt_icon.png")};const t="post"==this.params.terminals_type?g.map.modal_title_post:g.map.modal_title_terminal,s=this.params.provider in g.providers?g.providers[this.params.provider]:g.providers.omniva;this.translations={modal_header:s+" "+t,terminal_list_header:"post"==this.params.terminals_type?g.map.modal_search_title_post:g.map.modal_search_title_terminal,select_pickup_point:"post"==this.params.terminals_type?g.map.select_post:g.map.select_terminal,seach_header:g.map.search_placeholder,search_btn:g.map.search_button,select_btn:g.map.select_button,modal_open_btn:g.map.modal_open_button,geolocation_btn:g.map.use_my_location,your_position:g.map.my_position,nothing_found:g.map.not_found,no_cities_found:g.map.no_cities_found,geolocation_not_supported:g.map.geo_not_supported}},set_param:function(e,t,s=null){return t in e?e[t]:s},init:function(e){this.elements.map_container?(this.lib=new TerminalMappingOmnivalt,this.lib.setImagesPath(this.params.icons_url),this.lib.setTranslation(this.translations),this.lib.dom.setContainerParent(this.elements.map_container),this.lib.setParseMapTooltip((e,t)=>{let s=e.address+" ["+e.id+"]";return e.comment&&(s+="<br/><i>"+e.comment+"</i>"),s}),this.build_actions(this),this.lib.init({country_code:this.params.country,identifier:"omnivalt",isModal:!0,modalParent:this.elements.map_container,hideContainer:!0,hideSelectBtn:!0,cssThemeRule:"tmjs-default-theme",customTileServerUrl:"https://maps.omnivasiunta.lt/tile/{z}/{x}/{y}.png",customTileAttribution:'© <a href="https://www.omniva.lt">Omniva</a> | Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',terminalList:e})):this.error("Failed to get a container for the map")},build_actions:function(e){this.lib.sub("tmjs-ready",function(t){e.lib.map.createIcon("omnivalt_icon",e.params.icons_url+e.params.map_icon),e.lib.map.refreshMarkerIcons();let s=t.map.getLocationById(e.params.selected_terminal);void 0!==s&&null!=s&&(e.lib.dom.setActiveTerminal(s),e.lib.publish("terminal-selected",s))}),this.lib.sub("search-result",function(t){e.activate_autoselect()}),this.lib.sub("terminal-selected",function(t){S(e.elements.org_field,t.id),e.lib.dom.setActiveTerminal(t.id),e.variables.allow_close_modal&&e.lib.publish("close-map-modal"),e.variables.allow_close_modal=!0})},set_search_value:function(e){""!=(e=e.trim())&&this.lib.map&&(this.lib.dom.searchNearest(e),this.lib.dom.UI.modal.querySelector(".tmjs-search-input").value=e)},activate_autoselect:function(){this.params.autoselect&&""==this.params.selected_terminal&&this.lib&&"map"in this.lib&&this.lib.map&&"locations"in this.lib.map&&this.lib.map.locations.length&&(this.variables.allow_close_modal=!1,this.lib.dom.setActiveTerminal(this.lib.map.locations[0].id),this.lib.publish("terminal-selected",this.lib.map.locations[0]))},error:function(e){console.error("OMNIVA MAP:",e)}}),L=()=>
1({map:null,selected:{},terminals:[],elements:{},params:{},translations:{},loaded:!1,load_data:function(e){this.elements={org_field:this.set_param(e,"org_field",null),custom_container:this.set_param(e,"custom_container",null),this_dropdown:null,this_list:null,this_container:null,this_inner_container:null,this_loader:null,this_search:null,this_search_msg:null,this_show_more:null},this.params={provider:this.set_param(e,"provider","omniva"),terminals_type:this.set_param(e,"terminals_type","terminal"),country:this.set_param(e,"country","LT"),max_show:this.set_param(e,"max_show",8),active_timeout:null,autoselect:this.set_param(e,"autoselect",!0),selected_terminal:this.set_param(e,"selected_terminal","")},this.params.provider in g.providers?g.providers[this.params.provider]:g.providers.omniva,this.translations={not_found:g.select.not_found,too_short:g.select.search_too_short,select_terminal:"post"==this.params.terminals_type?g.select.post_select:g.select.terminal_select,enter_address:g.select.enter_address,show_more:g.select.show_more}},set_param:function(e,t,s=null){return t in e?e[t]:s},init:function(){if(b(this.elements))return void this.error("Load data is required before initialization");if(!this.elements.custom_container)return void this.error("Failed to get a container for the custom field");this.elements.org_field.value&&this.set_selected();let e,t=null;this.elements.this_container=document.createElement("div"),this.elements.this_container.classList.add("omnivalt-terminals-list"),this.elements.this_dropdown=document.createElement("div"),this.elements.this_dropdown.classList.add("dropdown"),this.elements.this_dropdown.innerHTML=this.translations.select_terminal,this.update_element_dropdown(),this.elements.this_search=document.createElement("input"),this.elements.this_search.type="text",this.elements.this_search.classList.add("search-input"),this.elements.this_search.placeholder=this.translations.enter_address,this.elements.this_search_msg=document.createElement("span"),this.elements.this_search_msg.classList.add("search-msg"),this.show_element_search_msg(!1),this.elements.this_loader=document.createElement("div"),this.elements.this_loader.classList.add("omnivalt-loader"),this.show_element_loader(!1),this.elements.this_list=document.createElement("ul"),this.elements.this_show_more=document.createElement("div"),this.elements.this_show_more.classList.add("show-more"),e=document.createElement("a"),t=document.createTextNode(this.translations.show_more),e.appendChild(t),e.href="#",this.elements.this_show_more.appendChild(e),this.elements.this_inner_container=document.createElement("div"),this.elements.this_inner_container.classList.add("inner-container"),this.show_element_inner_container(!1),this.elements.this_inner_container.append(this.elements.this_search,this.elements.this_search_msg,this.elements.this_loader,this.elements.this_list,this.elements.this_show_more),this.elements.this_container.append(this.elements.this_dropdown,this.elements.this_inner_container),this.elements.custom_container.append(this.elements.this_container),this.reset_terminals(),this.refresh_element_list(),this.elements.this_show_more.addEventListener("click",e=>{e.preventDefault(),this.show_element_all_options()}),this.elements.this_dropdown.addEventListener("click",e=>{this.toggle_dropdown()}),this.elements.org_field.addEventListener("click",e=>{this.set_selected(),this.update_element_dropdown(),this.elements.this_list.querySelector('li[data-id="'+this.elements.org_field.value+'"').classList.add("selected")}),this.elements.this_search.addEventListener("keyup",()=>{this.show_element_search_msg(!1),this.show_element_loader(!0),clearTimeout(this.params.active_timeout),this.params.active_timeout=setTimeout(()=>{this.params.autoselect=!1,this.geo_suggest(this.elements.this_search.value)},400)}),this.elements.this_search.addEventListener("keyup",e=>{"13"==e.which&&e.preventDefault()}),document.addEventListener("mousedown",e=>{this.elements.this_container!=e.target&&!this.elements.this_container.contains(e.target)&&this.elements.this_container.classList.contains("open")&&this.toggle_dropdown(!0)}),this.loaded=!0},set_terminals:function(e){for(let t=0;t<e.length;t++)e[t].distance=!1;this.terminals=e},set_selected:function(){this.selected={id:this.params.selected_terminal,text:this.elements.org_field.options[this.elements.org_field.selectedIndex].text,distance:!1}},set_search_value:function(e){this.elements.this_search.value=e.trim(),this.geo_suggest(this.elements.this_search.value)},activate_autoselect:function(){if(""==this.params.selected_terminal){let e=this.elements.this_list.querySelector("li:not(.city)");this.mark_element_list_selected(e)}},update_element_dropdown:function(){"text"in this.selected&&(this.elements.this_dropdown.innerHTML=this.selected.text)},show_element_loader:function(e=!1){this.elements.this_loader.style.display=e?"block":"none"},show_element_search_msg:function(e=!1){this.elements.this_search_msg.style.display=e?"block":"none"},show_element_inner_container:function(e=!1){this.elements.this_inner_container.style.display=e?"block":"none"},refresh_element_list:function(){let e,t,s,i,n=0,a=!1;this.clear_element_list();for(let l of this.terminals)e=document.createElement("li"),e.setAttribute("data-id",l.id),e.innerHTML=l.name,"distance"in l&&!1!==l.distance?(s=document.createElement("strong"),i=document.createTextNode(l.distance+"km"),s.appendChild(i),e.innerHTML+=" "+s.outerHTML,n++):this.elements.this_show_more.style.display="none","id"in this.selected&&this.selected.id==l.id&&e.classList.add("selected"),n>this.params.max_show&&(e.style.display="none"),a!=l.city&&(t=document.createElement("li"),t.classList.add("city"),t.innerHTML=l.city,n>this.params.max_show&&(t.style.display="none"),this.elements.this_list.append(t),a=l.city),this.elements.this_list.append(e);this.elements.this_list.querySelectorAll("li:not(.city)").forEach(e
1=>e.addEventListener("click",()=>{this.mark_element_list_selected(e)}))},clear_element_list:function(){for(;this.elements.this_list.firstChild;)this.elements.this_list.removeChild(this.elements.this_list.lastChild)},unmark_element_list_selected:function(){let e=this.elements.this_list.querySelector("li.selected");e&&e.classList.remove("selected")},mark_element_list_selected:function(e){this.unmark_element_list_selected();const t=e.getAttribute("data-id");e.classList.add("selected"),S(this.elements.org_field,t),this.params.selected_terminal=t,this.set_selected(),this.update_element_dropdown(),this.toggle_dropdown(!0)},toggle_dropdown:function(e=!1){this.elements.this_container.classList.contains("open")||e?(this.show_element_inner_container(!1),this.elements.this_container.classList.remove("open")):(this.show_element_inner_container(!0),this.elements.this_container.classList.add("open"))},show_element_all_options:function(){this.elements.this_list.querySelectorAll("li").forEach(e=>{e.style.display="",this.elements.this_show_more.style.display="none"})},hide_element_all_options:function(){this.elements.this_list.querySelectorAll("li").forEach(e=>{e.style.display="none",this.elements.this_show_more.style.display=""})},reset_terminals:function(){for(let e=0;e<this.terminals.length;e++)this.terminals[e].distance=!1;this.terminals.sort(function(e,t){return e.city.localeCompare(t.city)||t.name-e.name})},geo_find_position:async function(e){if(""==e||e.length<3)return this.reset_terminals(),this.show_element_all_options(),this.refresh_element_list(),!1;let t="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?singleLine="+e+"&sourceCountry="+this.params.country+"&category=&outFields=Postal&maxLocations=1&forStorage=false&f=pjson",s=await(async()=>await E(t))();if("candidates"in s&&s.candidates.length){let e=s.candidates[0];this.sort_list_by_distance(e.location.y,e.location.x),this.refresh_element_list(),this.elements.this_show_more.style.display="",this.params.autoselect&&this.activate_autoselect()}},geo_suggest:async function(e){if(""==e||e.length<3)return this.reset_terminals(),this.show_element_all_options(),this.refresh_element_list(),this.show_element_loader(!1),e.length&&(this.elements.this_search_msg.innerHTML=this.translations.too_short,this.show_element_search_msg(!0)),!1;let t="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest?text="+e+"&f=pjson&sourceCountry="+this.params.country+"&maxSuggestions=1",s=await(async()=>await E(t))();"suggestions"in s&&s.suggestions.length?this.geo_find_position(s.suggestions[0].text):(this.elements.this_search_msg.innerHTML=this.translations.not_found,this.show_element_search_msg(!0),this.hide_element_all_options()),this.show_element_loader(!1)},sort_list_by_distance:function(e,t){let s;for(let i=0;i<this.terminals.length;i++)s=this.calculate_distance(e,t,this.terminals[i].coords.lat,this.terminals[i].coords.lng),this.terminals[i].distance=s.toFixed(2);this.terminals.sort((e,t)=>{let s=e.distance,i=t.distance;return parseFloat(s)<parseFloat(i)?-1:parseFloat(s)>parseFloat(i)?1:0})},calculate_distance:function(e,t,s,i){let n=this.to_radius(s-e),a=this.to_radius(i-t);e=this.to_radius(e),s=this.to_radius(s);let l=Math.sin(n/2)*Math.sin(n/2)+Math.sin(a/2)*Math.sin(a/2)*Math.cos(e)*Math.cos(s);return 2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l))*6371},to_radius:e=>e*Math.PI/180,error:function(e){console.error("OMNIVA CUSTOM SELECT:",e)}}),T=JSON.parse('{"apiVersion":2,"name":"omnivalt/terminal-selection-checkout","version":"1.0.0","title":"Omniva terminal selection","category":"woocommerce","description":"Allow to add components for Omniva shipping method","parent":["woocommerce/checkout-shipping-methods-block"],"supports":{"html":false,"align":false,"multiple":false,"reusable":false},"attributes":{"lock":{"type":"object","default":{"remove":true,"move":true}},"text":{"type":"string","default":""}},"textdomain":"omnivalt"}');(0,e.registerCheckoutBlock)({metadata:T,component:({checkoutExtensionData:e,extensions:n})=>{const _="omnivalt_terminal",p="shipping_phone",{setExtensionData:f}
1=e,[y,E]=(0,s.useState)({country:"LT",postcode:""}),[S,T]=(0,s.useState)(null),[x,C]=(0,s.useState)([]),[M,O]=(0,s.useState)({}),[A,P]=(0,s.useState)([]),[I,N]=(0,s.useState)([{label:g.select_terminal,value:""}]),[j,D]=(0,s.useState)(w(!1)),[F,q]=(0,s.useState)({title:g.title_terminal,label:g.select_terminal,error:g.error_terminal}),[R,V]=(0,s.useState)(""),[B,H]=(0,s.useState)(""),[U,z]=(0,s.useState)({provider:"unknown",type:"unknown"}),[G,$]=(0,s.useState)(""),W=(0,s.useRef)(null),Y=(0,s.useRef)(null),J=(0,s.useRef)(null),K=k(),Q=L(),X=c(),Z=X.rate_id||"",ee=X.info_url||"https://picapac.com",te=X.info_label||"What is Picapac?";v("Block show",j),v("Terminals list",A),v("Destination",S),v("Map values",y),v("Selected terminal",R),v("Selected rate ID",B),v("Omniva dynamic data",M),(0,s.useCallback)((0,o.debounce)((e,t,s)=>{f(e,t,s)},1e3),[f]);const{setValidationErrors:se,clearValidationError:ie}=(0,l.useDispatch)("wc/store/validation"),ne=(0,l.useSelect)(e=>e("wc/store/validation").getValidationError(_)),ae=(0,l.useSelect)(e=>e("wc/store/validation").getValidationError(p)),le=(0,l.useSelect)(e=>e("wc/store/cart").getCartData().shippingRates),oe=(0,l.useSelect)(e=>{const t=e("wc/store/cart"),s=t.getCartData().billingAddress,i=t.getCartData().shippingAddress;return{phone:(i.phone&&""!==i.phone.trim()?i.phone:s.phone)||"",country:i.country}});return(0,s.useEffect)(()=>{le.length?C((e=>{if(!e.length)return[];let t=[];for(let s=0;s<e.length;s++)if(e[s].shipping_rates)for(let i=0;i<e[s].shipping_rates.length;i++)t.push(e[s].shipping_rates[i]);return t})(le)):u("Empty param: shippingRates")},[le]),(0,s.useEffect)(()=>{D(w(!1)),u("Received "+x.length+" active rates:",x);for(let e=0;e<x.length;e++)x[e].rate_id&&x[e].selected&&(h(x[e].rate_id)&&x[e].selected&&D(w(!0)),H(x[e].rate_id))},[x]),(0,s.useEffect)(()=>{u("Updating destination..."),T(((e,t=!0)=>{if(u("Getting destination..."),!e.length)return u("Failed to get destination because shipping rates is empty"),null;let s=[];for(let t=0;t<e.length;t++)e[t].destination&&s.push(e[t].destination);return s.length?t?(u("First destination",s[0]),s[0]):(u("Destinations",s),s):(u("Failed to get destination"),null)})(le))},[x]),(0,s.useEffect)(()=>{S&&""!=S.country.trim()?E({country:S.country,postcode:S.postcode}):E({country:"LT",postcode:""})},[S]),(0,s.useEffect)(()=>{var e,t;B?S?(e=S.country,t=B,fetch(`${r().ajax_url}?action=omnivalt_get_dynamic_data&country=${e}&method=${t}`,{method:"GET",credentials:"same-origin",headers:{"Content-Type":"application/json"}}).then(e=>e.json()).catch(e=>(console.error("Error fetching terminals:",e),[]))).then(e=>{if(e.data){const t=e.data;u("Updating Omniva data...",t),O(t)}else u("Failed to get dynamic Omniva data")}):u("Skipped retrieving dynamic Omniva data because the destination is still empty"):u("Skipped retrieving dynamic Omniva data because the value of the selected rate ID is not received")},[S,B]),(0,s.useEffect)(()=>{if(b(M))return void u("Skipped getting Terminals because the Omniva dynamic data is empty");if(!1===M.terminals_type)return void u("The selected delivery method does not have a terminals");const e="terminals_type"in M?M.terminals_type:"omniva";var t,s;(t=y.country,s=e,fetch(`${r().ajax_url}?action=omnivalt_get_terminals&country=${t}&type=${s}`,{method:"GET",credentials:"same-origin",headers:{"Content-Type":"application/json"}}).then(e=>e.json()).catch(e=>(console.error("Error fetching terminals:",e),[]))).then(e=>{e.data?(u("Updating terminals list..."),P(e.data)):u("Failed to get terminals list")})},[M]),(0,s.useEffect)(()=>{const e={title:g.title_terminal,label:g.select_terminal,error:g.error_terminal};!b(M)&&"terminals_type"in M&&"post"==M.terminals_type&&(e.title=g.title_post,e.label=g.select_post,e.error=g.error_post),q(e)},[M]),(0,s.useEffect)(()=>{if(!A.length)return void u("Skipped updating terminals block because the terminals list is empty");""!==R&&(u("Checking if the selected terminal is in the terminals list..."),((e,t,s)=>{for(let t=0;t<e.length;t++)if(e[t].id===s)return e[t];return null})(A,0,R)||(u("The specified terminal was not found in the list of terminals"),V(""))),u("Updating terminal selection options...");const e=[{label:F.label,value:""}];for(let t=0;t<A.length;t++)e.push({label:A[t].name,value:A[t].id});N(e)},[A]),(0,s.useEffect)(()=>
1{if(Y.current){""!==Y.current.innerHTML&&(u("Removing previous custom field/map..."),(e=>{for(;e.firstChild;)e.removeChild(e.lastChild)})(Y.current));let e=null,t=!0;"show_map"in r()&&(e=r().show_map,t=r().autoselect,z({provider:"provider"in M?M.provider:"unknown",type:"terminals_type"in M?M.terminals_type:"unknown"})),!0===e?(u("Initializing TMJS map..."),K.load_data({org_field:W.current,map_container:Y.current,terminals_type:M.terminals_type,provider:M.provider,country:y.country,map_icon:M.map_icon,selected_terminal:R,autoselect:t}),K.init(A),K.set_search_value(y.postcode),K.activate_autoselect()):!1===e?(u("Initializing terminal select field..."),Q.load_data({org_field:W.current,custom_container:Y.current,provider:M.provider,terminals_type:M.terminals_type,country:y.country,selected_terminal:R,autoselect_terminal:t}),Q.set_terminals(A),Q.init(),Q.set_search_value(y.postcode)):u("Failed to get map display param")}else u("Failed to get container for custom field/map")},[I]),(0,s.useEffect)(()=>{ie(p),m(B)&&(M.phone_regex&&""!==M.phone_regex.trim()?new RegExp(M.phone_regex).test(oe.phone)?u("Phone number is correct"):(u("Incorrect phone number. Regex: "+M.phone_regex),se({[p]:{message:g.errors.invalid_format,hidden:!1}})):u("Phone regex empty. Skipped validation."))},[oe,M,B]),(0,s.useEffect)(()=>{ne&&(u("Clearing terminal validation error..."),ie(_),$("")),h(B)&&(u("Set selected terminal:",R),f("omnivalt","selected_terminal",R),""!==R&&(document.cookie="omniva_terminal="+R+";path=/;max-age=3600;SameSite=Lax"),""===R&&(u("Terminal not selected. Adding terminal validation error..."),se({[_]:{message:F.error,hidden:!1}}),$("error")))},[f,R,B]),(0,s.useEffect)(()=>{""!==B&&f("omnivalt","selected_rate_id",B)},[f,B]),(0,s.useEffect)(()=>{const e=()=>{J.current&&(J.current.remove(),J.current=null)},t=document.querySelector(".wc-block-components-shipping-rates-control");if(!le.length||""===Z||!t||!window.MutationObserver)return void e();const s=()=>{const s=(e=>{const t=e.querySelectorAll('input[type="radio"]');for(let e=0;e<t.length;e++){if(!d(t[e].value))continue;const s=t[e].closest(".wc-block-components-radio-control__option")||t[e].closest("label");if(s)return s.classList.add("omnivalt-picapac-option"),{container:s}}return null})(t),i=J.current;if(i&&i.isConnected&&s&&i.parentNode===s.container)return;if(e(),!s)return;const n=document.createElement("span");n.className="omnivalt-picapac-info";const a=document.createElement("a");a.href=ee,a.target="_blank",a.rel="noopener noreferrer",a.textContent=te,a.addEventListener("click",e=>e.stopPropagation()),n.appendChild(a),s.container.appendChild(n),J.current=n};s();const i=new MutationObserver(s);return i.observe(t,{childList:!0,subtree:!0}),()=>{i.disconnect(),e()}},[Z,ee,te,le]),m(B)?(0,t.createElement)("div",{className:"omnivalt-container"},(0,t.createElement)("div",{className:"omnivalt-general-errors"},ae&&!ae.hidden&&(0,t.createElement)("div",{className:"wc-block-components-validation-error omnivalt-phone-error"},(0,t.createElement)(i.Icon,{icon:a,size:20,className:"omnivalt-error-icon"}),(0,t.createElement)("span",null,g.errors.invalid_phone_format))),j.value&&(0,t.createElement)("div",{className:`omnivalt-terminal-select-container provider-${U.provider} type-${U.type} ${G}`},(0,t.createElement)("div",{id:"omnivalt-terminal-container-org",className:"omnivalt-org-select"},(0,t.createElement)(i.SelectControl,{id:"omnivalt-terminal-select-field",label:F.title,value:R,options:I,onChange:e=>V(e),ref:W}),ne?.hidden||""!==R?null:(0,t.createElement)("div",{className:"wc-block-components-validation-error omnivalt-terminal-error"},(0,t.createElement)(i.Icon,{icon:a,size:20,className:"omnivalt-error-icon"}),(0,t.createElement)("span",null,ne?.message))),(0,t.createElement)("div",{id:"omnivalt-terminal-container-map",className:"omnivalt-map-select",ref:Y},(0,t.createElement)("div",{class:"omnivalt-loader"})))):null}})})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.