PageSourceSearch

https://www.locopast.com/assets/api-DEwQs-pj.js

js locopast.com collected 2026-10-02 00:00:57 UTC 8,494 bytes, 1 lines download raw bytes

1import{i as e}from"./index-De55cMFo.js";var t=2,n=2,r={title:3,description:2,extract:1},i={market:[`stock market`,`market town`,`market square`],fire:[`fireplace`],station:[`radio station`,`police station`],revolution:[`industrial revolution`],marché:[`marché boursier`]};function a(e,t){let n=e.toLowerCase(),r=t.toLowerCase().trim();if(!r)return!1;if(r.includes(` `))return n.includes(r);let i=r.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`\\b${i}\\b`,`iu`).test(n)}function o(e,t){if(!a(e,t))return!1;let n=e.toLowerCase();return!i[t.toLowerCase()]?.some(e=>n.includes(e))}function s(e,t,n,r){if(!e)return 0;let i=0;for(let n of t)o(e,n)&&(i+=r);for(let t of n??[])o(e,t)&&(i+=r);return i}function c(e,t){if(!e)return 0;let n=0;for(let i of t)o(e,i)&&(n+=r.extract);return n}function l(i){let a=new Map;for(let n of e){if(n.id===`all`)continue;let e=n.weak??[],o=s(i.title,n.keywords,e,r.title)+s(i.description??``,n.keywords,e,r.description)+c(i.extract,n.keywords);o>=t&&a.set(n.id,o)}let o=[...a.entries()].sort((e,t)=>t[1]-e[1]).slice(0,n).map(([e])=>e);return{topics:o,primaryTopic:o[0]}}var u=`https://www.wikipedia.org/`,d=`https://creativecommons.org/licenses/by-sa/4.0/`,f={FR:[`fr`],BE:[`fr`,`nl`],CH:[`de`,`fr`],LU:[`fr`,`de`],MC:[`fr`],DE:[`de`],AT:[`de`],IT:[`it`],SM:[`it`],VA:[`it`],ES:[`es`],AD:[`ca`],PT:[`pt`],NL:[`nl`],DK:[`da`],SE:[`sv`],NO:[`no`],FI:[`fi`],IS:[`is`],PL:[`pl`],CZ:[`cs`],SK:[`sk`],HU:[`hu`],SI:[`sl`],HR:[`hr`],RS:[`sr`],BA:[`sh`],GR:[`el`],RO:[`ro`],BG:[`bg`],TR:[`tr`],RU:[`ru`],UA:[`uk`],BY:[`be`],EE:[`et`],LV:[`lv`],LT:[`lt`],JP:[`ja`],KR:[`ko`],CN:[`zh`],TW:[`zh`],HK:[`zh`],VN:[`vi`],TH:[`th`],ID:[`id`],MY:[`ms`],IL:[`he`],EG:[`ar`],SA:[`ar`],MA:[`fr`,`ar`],DZ:[`fr`,`ar`],TN:[`fr`,`ar`],MX:[`es`],AR:[`es`],CL:[`es`],CO:[`es`],PE:[`es`],BR:[`pt`],QC:[`fr`]},p={headers:{"Api-User-Agent":`LocoPast/1.0 (location history explorer)`}},m=e=>new Promise(t=>setTimeout(t,e));async function h(e){let t=[700,1500];for(let n=0;;n++)try{let r=await fetch(e,p);if((r.status===429||r.status===503)&&n<t.length){let e=Number(r.headers.get(`retry-after`));await m(Number.isFinite(e)&&e>0?Math.min(e*1e3,5e3):t[n]);continue}return r}catch(e){if(n>=t.length)throw e;await m(t[n])}}var g=new Map;async function _(e,t){let n=`${e.toFixed(1)},${t.toFixed(1)}`,r=g.get(n);if(r)return r;let i=[];try{i=(f[(await(await fetch(`https://photon.komoot.io/reverse?lat=${e}&lon=${t}`)).json()).features?.[0]?.properties?.countrycode?.toUpperCase()]??[]).filter(e=>e!==`en`).slice(0,2)}catch{}return g.set(n,i),i}function v(e){let t={I:1,V:5,X:10,L:50,C:100},n=0;for(let r=0;r<e.length;r++){let i=t[e[r]];if(!i)return 0;n+=i<(t[e[r+1]]??0)?-i:i}return n}function y(e){let t=new Date().getFullYear(),n=[],r=e=>{if(e<1||e>21)return;let r=(e-1)*100+50;r<=t&&n.push(r)};for(let t of e.matchAll(/(\d{1,2})(?:st|nd|rd|th)[-\s]century/gi))r(parseInt(t[1],10));for(let t of e.matchAll(/\b([IVXLC]{1,6})(?:ᵉ|e|er|ème)?[\s-]*si[èe]cle/gi))r(v(t[1].toUpperCase()));for(let t of e.matchAll(/\b(\d{1,2})\s*(?:er?|ème)\s*si[èe]cle/gi))r(parseInt(t[1],10));for(let t of e.matchAll(/\b([IVXLC]{1,6})\s+secolo/gi))r(v(t[1].toUpperCase()));for(let t of e.matchAll(/siglo\s+([IVXLC]{1,6})/gi))r(v(t[1].toUpperCase()));for(let t of e.matchAll(/\b(\d{1,2})\.\s*Jahrhundert/gi))r(parseInt(t[1],10));for(let t of e.matchAll(/\b(\d{2,4})\s*(?:av(?:\.|ant)\s*J|a\.\s*C\.|v\.\s*Chr)/gi))n.push(-parseInt(t[1],10));for(let r of e.matchAll(/\b(1[0-9]{3}|20[0-2][0-9]|[1-9][0-9]{2})\s*(BC|BCE|AD|CE)?\b/g)){let e=parseInt(r[1],10),i=r[2];(i===`BC`||i===`BCE`)&&(e=-e),!(r[1].length===3&&!i)&&e<=t&&n.push(e)}if(n.length!==0)return Math.min(...n)}function b(e){return Math.max(0,20-e/100)}function x(e){let t=0;if(e.year!==void 0){let n=new Date().getFullYear()-e.year;t+=Math.min(n/10,60)}return e.thumbnail&&(t+=25),t+=Math.min(e.extract.length/40,25),t+=e.topics.length*6,t+=b(e.distance),t}function S(e){return e.replace(/<[^>]*>/g,``).replace(/&nbsp;/g,` `).replace(/&amp;/g,`&`).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&#039;/g,`'`).trim()}function C(e){return e.replace(/\.[^.]+$/,``).replace(/_/g,` `)}function w(e,t){let n=t.extmetadata,r=S(n?.ObjectName?.value??``)||C(e),i=S(n?.Credit?.value??``),a=S(n?.Artist?.value??``),o=i||a||`Wikimedia Commons`,s=S(n?.LicenseShortName?.value??``)||`CC BY-SA 4.0`,c=n?.LicenseUrl?.value?.trim();return{title:r,source:o,sourceUrl:t.descriptionurl,license:s,licenseUrl:c||void 0}}async function T(e,t){let n=new Map;if(t.length===0)return n;let r=`https://${e}.wikipedia.org/w/api.php`,i=[];for(let e=0;e<t.length;e+=50)i.push(t.slice(e,e+50));return await Promise.all(i.map(async e=>{let t=new URLSearchParams({action:`query`,format:`json`,origin:`*`,titles:e.map(e=>`File:${e}`).join(`|`),prop:`imageinfo`,iiprop:`url|extmetadata`,iiextmetadatafilter:`ObjectName|Artist|Credit|LicenseShortName|LicenseUrl|Attribution`});try{let e=await fetch(`${r}?${t}`,p);if(!e.ok)return;let i=await e.json();for(let e of Object.values(i?.query?.pages??{})){if(e.missing!==void 0)continue;let t=e.title?.replace(/^File:/,``)??``,r=e.imageinfo?.[0];!t||!r||n.set(t,w(t,r))}}catch{}})),n}function E(e,t){let n=t.pageimage,r=n?`https://${e}.wikipedia.org/wiki/File:${encodeURIComponent(n.replace(/ /g,`_`))}`:void 0;return{title:n?C(n):t.title,source:`Wikipedia`,sourceUrl:r??t.fullurl??`https://${e}.wikipedia.org/?curid=${t.pageid}`,license:`CC BY-SA 4.0`,licenseUrl:d}}async function D(e,t,n,r){let i=`https://${e}.wikipedia.org/w/api.php`,a=await h(`${i}?${new URLSearchParams({action:`query`,format:`json`,origin:`*`,list:`geosearch`,gscoord:`${t}|${n}`,gsradius:String(Math.min(r,1e4)),gslimit:`75`})}`);if(!a.ok)throw Error(`Wikipedia (${e}) request failed (${a.status})`);let o=(await a.json())?.query?.geosearch??[];if(o.length===0)return[];let s=new Map(o.map(e=>[e.pageid,{lat:e.lat,lon:e.lon}])),c=o.map(e=>e.pageid),u=[];for(let e=0;e<c.length;e+=20)u.push(c.slice(e,e+20));let d=(await Promise.all(u.map(async e=>{let t=await h(`${i}?${new URLSearchParams({action:`query`,format:`json`,origin:`*`,pageids:e.join(`|`),prop:`extracts|pageimages|description|info|pageprops`,ppprop:`wikibase_item`,exintro:`1`,explaintext:`1`,exlimit:`max`,pithumbsize:`480`,pilimit:`max`,inprop:`url`})}`);if(!t.ok)return[];let n=await t.json();return Object.values(n?.query?.pages??{})}))).flat(),f=await T(e,[...new Set(d.map(e=>
1e.pageimage).filter(Boolean))]),p=[];for(let r of d){let i=s.get(r.pageid);if(!i||!r.extract)continue;let a=y(r.extract),{topics:o,primaryTopic:c}=l({title:r.title,description:r.description,extract:r.extract}),u=j(t,n,i.lat,i.lon),d={id:`${e}:${r.pageid}`,lang:e,qid:r.pageprops?.wikibase_item,title:r.title,description:r.description,extract:r.extract,lat:i.lat,lon:i.lon,thumbnail:r.thumbnail?.source,imageAttribution:r.thumbnail?.source?(r.pageimage?f.get(r.pageimage):void 0)??E(e,r):void 0,year:a,topics:o,primaryTopic:c,distance:u,url:r.fullurl??`https://${e}.wikipedia.org/?curid=${r.pageid}`};p.push({...d,score:x(d)})}return p}async function O(e,t,n,r){let i=0,a=await Promise.all(e.map(e=>D(e,t,n,r).catch(()=>(i++,[]))));if(i===e.length)throw Error(`All Wikipedia requests failed`);let o=new Set,s=[];for(let e of a)for(let t of e){let e=t.qid??t.id;o.has(e)||(o.add(e),s.push(t))}return s}async function k(e,t,n=3e3){let r=[`en`,...await _(e,t)],i=await O(r,e,t,n);return i.length<30&&n<1e4&&(i=await O(r,e,t,1e4)),i.sort((e,t)=>t.score-e.score)}async function A(e){let t=new URLSearchParams({q:e,limit:`6`,lang:`en`}),n=await fetch(`https://photon.komoot.io/api/?${t}`);if(!n.ok)throw Error(`Geocoding failed (${n.status})`);return((await n.json()).features??[]).filter(e=>e.geometry?.coordinates).map(t=>{let n=t.properties??{},r=[n.street,n.district,n.city,n.state,n.country].filter(e=>e&&e!==n.name).slice(0,3).join(`, `);return{name:n.name??e,detail:r,lat:t.geometry.coordinates[1],lon:t.geometry.coordinates[0]}})}function j(e,t,n,r){let i=e=>e*Math.PI/180,a=i(n-e),o=i(r-t),s=Math.sin(a/2)**2+Math.cos(i(e))*Math.cos(i(n))*Math.sin(o/2)**2;return 2*6371e3*Math.asin(Math.sqrt(s))}function M(e){return e<100?`right here`:e<1e3?`${Math.round(e/10)*10}m away`:`${(e/1e3).toFixed(1)} km away`}function N(e){return e===void 0?``:e<0?`${-e} BCE`:String(e)}function P(e){if(e===void 0||e>new Date().getFullYear())return``;let t=new Date().getFullYear()-e;return t<1?`this year`:t===1?`1 year ago`:`${t} years ago`}export{A as a,u as c,N as i,d as l,k as n,j as o,M as r,P as s,b as t};

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.