import{A as P,F as T,p as c}from"./chunk-ULQNXXR2.js";import{v as w}from"./chunk-JDRW2YA4.js";import{b as y}from"./chunk-3MA2RUGV.js";import{la as M,r as v,ra as D}from"./chunk-P3ALJJW6.js";var B=(()=>{let s=class s{constructor(){this._translate=D(y)}tipoToNr(t){let r;switch(t){case"Vivienda":r=10;break;case"Suelo":r=8;break;case"Comercial":r=1;break;case"Nave":r=4;break;case"Oficinas":r=6;break;case"Hotel":r=3;break;case"Obra parada":r=5;break;case"Garajes":r=2;break;case"Trasteros":r=9;break;case"Otros":r=7;break}return r}static pvciaFromNr(t){let r=c,n=r.length;for(let e=0;e<n;e++)if(r[e].PkProvincia==t)return{PkProvincia:t,Provincia:r[e].Provincia};return null}static pvciaFromName(t){let r=c.length,n=t.toLowerCase();for(let e=0;e<r;e++)if(c[e].Provincia.toLowerCase()==n)return{PkProvincia:c[e].PkProvincia,Provincia:c[e].Provincia};return null}static existUrl(t){let r=new XMLHttpRequest;return r.open("HEAD",t,!1),r.send(),v({status:r.status!=404})}static convertShortToDatabase(t){let r=t.split("/");return"20"+r[2]+"-"+r[0]+"-"+r[1]}static convertDateToDB(t,r=!1){let n=t.getMonth()+1,e=n<10?"0"+n:n,o=t.getDate(),a=o<10?"0"+o:o,u=t.getFullYear()+"-"+e+"-"+a;if(r){let i=t.getHours()<10?"0"+t.getHours().toString():t.getHours().toString(),f=t.getMinutes()<10?"0"+t.getMinutes().toString():t.getMinutes().toString();return u+" "+i+":"+f+":00"}else return u}static convertDBtoShort(t){let r=t.substring(0,4),n=t.substring(5,2),e=t.substring(8,2);return n+"/"+e+"/"+r}static convertDateToShort(t){let r=t.getFullYear(),n=t.getMonth(),e=t.getDate();return n+"/"+e+"/"+r}static convertDBtoDate(t){if(!t)return null;let r=parseInt(t.substring(0,4)),n=parseInt(t.substring(5,2)),e=parseInt(t.substring(8,2));return new Date(r,n-1,e)}static isPTP(t){let r=s.convertDBtoDate(t),e=Math.abs(Number(new Date)-Number(r));return Math.ceil(e/(1e3*60*60*24))<=s.PTPSpan}static diffBetween(t){let r=new Date,n=Number(t)-Number(r),e=Math.floor(n/864e5),o=Math.floor(n%864e5/36e5),a=Math.round(n%864e5%36e5/6e4);return{days:e,hours:o,minutes:a}}static convertIsoToUSTime(t){return t?(t=t.trim(),t.substring(5,2)+"/"+t.substring(8,2)+"/"+t.substring(2,2)+" "+t.substring(11,5)):""}static convertIsoToTime(t){return t?(t=t.trim(),t.substring(8,2)+"/"+t.substring(5,2)+"/"+t.substring(0,4)+" "+t.substring(11,5)):""}static millons(t){let r=Number(t)<0,n=Math.abs(Number(t))>=1e9?(Math.abs(Number(t))/1e9).toFixed(2)+"B":Math.abs(Number(t))>=1e6?(Math.abs(Number(t))/1e6).toFixed(2)+"M":Math.abs(Number(t))>=1e3?(Math.abs(Number(t))/1e3).toFixed(2)+"K":Math.abs(Number(t)).toFixed(2);return r&&(n="-"+n),n}static round(t,r,n){if(n)return t=t.toFixed(r+1),parseFloat(t.slice(0,-1));let e=Math.pow(10,r);return Math.round(t*e)/e}static validateEmail(t){return!!/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(t)}static normalizeString(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}getTypeObject(t){return P.find(r=>r.value==t)}getSubTypeObject(t,r){return P.find(n=>n.value==t).subtypes.find(n=>n.value==r)}static isMobile(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}getTitle(t,r,n,e,o,a,u){let i=t&&r?this._translate.instant(this.getSubTypeObject(t,r).text):"";i=u?this._translate.instant("PROPERTY_CARD.SUBTYPE_WITH_METERS",{subtype:i,meters:u}):i;let f=new T,S=new w,h=n?S.transform(this._translate.instant("tipovia."+n.trim())):"",p=this._translate.instant(i?"PROPERTY_CARD.ADDRESS":"PROPERTY_CARD.PROMOCION"),l=f.transform(e),m=f.transform(o),b=f.transform(typeof a=="string"?a:c.find(N=>+N.PkProvincia===a)?.Provincia);return!m&&!b?i+" "+p+" "+h+" "+l:m!==b?i+" "+p+" "+h+" "+l+", "+m+(b?", "+b:""):m===b?i+" "+p+" "+h+" "+l+", "+m:""}convertUrlBlogForAnalytics(t){let r=t.split("/");return r[r.length-1]}};s.PTPSpan=300,s.\u0275fac=function(r){return new(r||s)},s.\u0275prov=M({token:s,factory:s.\u0275fac,providedIn:"root"});let g=s;return g})();export{B as a};