Файловый менеджер - Редактировать - /home/harasnat/www/labour/wp-content/plugins/woocommerce/assets/js/frontend/a8c-address-autocomplete-service.min.js
Назад
function createBeacon(e,{name:t,value:r,type:n}){const s=t.replace("-","_");return"counting"===n&&(r=r===undefined?1:r),(r=Array.isArray(r)?r:[r]).map(t=>`a8c.${e}.${s}:${t}|${"timing"===n?"ms":"c"}`)}function createStatsdURL(e,t){Array.isArray(t)||(t=[t]);const r=e.replace(/[.:-]/g,"_"),n=JSON.stringify({beacons:t.map(e=>createBeacon(r,e)).flat()});return`https://pixel.wp.com/boom.gif?json=${encodeURIComponent(n)}`}!function(){const e=[],t="https://public-api.wordpress.com/wpcom/v2/woo/address-autocomplete",r=`${t}/search`,n=`${t}/select`;function s(){return crypto&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).substring(2)}function i(e,t,r){var n,s,i,o,a,c,u=0,d=!1,l=!1,m=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function h(t){var r=n,i=s,a=r._resolve;return n=s=undefined,u=t,o=e.apply(i,r),a&&a(o),o}function f(e){var r=e-c;return c===undefined||r>=t||r<0||l&&e-u>=i}function g(){var e=Date.now();if(f(e))return p(e);a=setTimeout(g,function(e){var r=e-u,n=t-(e-c);return l?Math.min(n,i-r):n}(e))}function p(e){return a=undefined,m&&n?h(e):(n=s=undefined,o)}function _(){var e=Date.now(),r=f(e);if(n=arguments,s=this,c=e,r){if(a===undefined)return function(e){return u=e,a=setTimeout(g,t),d?h(e):new Promise(e=>{n._resolve=e})}(c);if(l)return clearTimeout(a),a=setTimeout(g,t),h(c)}return a===undefined&&(a=setTimeout(g,t)),new Promise(e=>{n._resolve=e})}return"object"==typeof r&&(d=!!r.leading,i=(l="maxWait"in r)?Math.max(r.maxWait||0,t):i,m="trailing"in r?!!r.trailing:m),_.cancel=function(){a!==undefined&&clearTimeout(a),n&&n._resolve&&n._resolve([]),u=0,n=c=s=a=undefined},_.flush=function(){return a===undefined?o:p(Date.now())},_}Object.entries(a8cAddressAutocompleteServiceKeys).forEach(([t,o])=>{let a=s(),c=[],u=0;const d=new class{constructor(e=100){this.maxSize=e,this.cache=new Map}get(e){if(this.cache.has(e)){const t=this.cache.get(e);return this.cache["delete"](e),this.cache.set(e,t),t}return null}set(e,t){if(this.cache.has(e))this.cache["delete"](e);else if(this.cache.size>=this.maxSize){const e=this.cache.keys().next().value;this.cache["delete"](e)}this.cache.set(e,t)}clear(){this.cache.clear()}get size(){return this.cache.size}}(100),l=(r,n)=>{if(!r.code&&!r.error)return;switch(r.code||r.error){case"expired_jwt_token":case"malformed_jwt_token":case"invalid_jwt_token":case"invalid_issuer":case"invalid_service":case"missing_jwt_token":return e.push(t),void console.error(`Automattic Address Suggestion (${t}) has been disabled due to invalid JWT token`);case"rate_limit_exceeded":return e.push(t),setTimeout(()=>{const r=e.indexOf(t);-1!==r&&e.splice(r,1)},1e3*(Number(n.headers.get("RateLimit-Retry-After"))||60)),void console.error(`Automattic Address Suggestion (${t}) has been disabled due to rate limit exceeded`);case"missing_query":case"no_suggestions":return;case"missing_address_id":return void console.error(`Automattic Address Suggestion (${t}) has been disabled due to missing address ID`);case"no_place":return void console.error(`Automattic Address Suggestion (${t}) has been disabled due to no place found`);case"missing_session_id":return void(a=s());case"woo_address_suggestion_internal_error":case"woo_address_suggestion_service_error":case"woo_address_suggestion_server_error":return void(++u>=3&&(e.push(t),console.error(`Automattic Address Suggestion (${t}) has been disabled due to internal service error`)));default:return}},m=i(async(e,n)=>{const s=new URLSearchParams({query:e,country:n,lang:document.documentElement.lang||navigator.lang,session_id:a,token:o.key});try{const o=performance.now(),a=await fetch(`${r}?${s.toString()}`),u=performance.now();c.push(u-o);let m=await a.json();if(l(m,a),Array.isArray(m))return((e,t,r)=>{const n=`${e}:${t}`;d.set(n,r)})(e,n,m=m.map(e=>({id:e.id,label:e.label,matchedSubstrings:e.matched_substrings}))),m}catch(i){return"AbortError"===i.name?[]:(console.error(`Error fetching address suggestions for ${t}:`,i),[])}},300,{leading:!1,trailing:!0});window.wc.addressAutocomplete.registerAddressAutocompleteProvider({id:t,canSearch:()=>{try{if(e.includes(t))return!1;const[,n]=o.key.split(".");if(!n)return e.push(t),!1;const s=JSON.parse(atob(n)),i=Math.floor(Date.now()/1e3);return!(!s.exp||s.exp<i)||(e.push(t),!1)}catch(r){return e.push(t),!1}},search:async(r,n,s)=>{if(e.includes(t))return[];const i=((e,t)=>{const r=`${e}:${t}`;return d.get(r)})(r=r.trim(),n);return null!==i?i:await m(r,n)},async select(e){const r=new URLSearchParams({address_id:e,session_id:a,lang:document.documentElement.lang,token:o.key}),i=await fetch(`${n}?${r.toString()}`);let u=await i.json();a=s();try{dispatchEvent(new CustomEvent("wc-address-autocomplete-service-request-durations",{detail:{requestDurations:c,provider:t}}))}catch(d){console.error(d)}return c=[],l(u,i),u}}),window.addEventListener("wc-address-autocomplete-service-request-durations",e=>{o.canTelemetry&&e.detail.provider===t&&((new Image).src=createStatsdURL("a8c-ac-service",{name:"request-durations",value:e.detail.requestDurations,type:"timing"}))})})}();
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка