import{$ as C,A as X,Aa as f,Ac as $e,Cb as he,D as ee,Fa as oe,H as S,Ha as E,Hc as ke,I as R,Ia as $,K as I,Kc as Ae,Lb as _,M as d,Nb as pe,Ob as de,P as u,Q as w,Qb as me,R as te,Ra as k,Sa as A,V,W as ie,X as re,Y as ne,Zb as L,a as H,aa as N,ab as M,bc as m,c as q,e as G,ec as ge,hc as fe,i as W,ic as be,ja as h,jc as ye,ka as se,kc as Se,l as y,na as D,nc as ve,ob as le,oc as o,qa as T,qc as Ce,r as Q,rc as xe,s as x,sb as ae,ta as g,tb as ce,ub as ue,v as Y,wc as Ie,y as J,za as v,zc as we}from"./chunk-GWUVPOWZ.js";import{a as F,g as z}from"./chunk-KRVUSFHP.js";function _e(i){i||(V(_e),i=w(C));let e=new H(t=>i.onDestroy(t.next.bind(t)));return t=>t.pipe(S(e))}var B=class{constructor(e){this.source=e,this.destroyed=!1,this.destroyRef=w(C),this.destroyRef.onDestroy(()=>{this.destroyed=!0})}subscribe(e){if(this.destroyed)throw new I(953,!1);let t=this.source.pipe(_e(this.destroyRef)).subscribe({next:r=>e(r)});return{unsubscribe:()=>t.unsubscribe()}}};function It(i,e){return new B(i)}function Xe(i,e){let t=!e?.manualCleanup;t&&!e?.injector&&V(Xe);let r=t?e?.injector?.get(C)??w(C):null,n=et(e?.equal),s;e?.requireSync?s=D({kind:0},{equal:n}):s=D({kind:1,value:e?.initialValue},{equal:n});let l=i.subscribe({next:a=>s.set({kind:1,value:a}),error:a=>{if(e?.rejectErrors)throw a;s.set({kind:2,error:a})}});if(e?.requireSync&&s().kind===0)throw new I(601,!1);return r?.onDestroy(l.unsubscribe.bind(l)),le(()=>{let a=s();switch(a.kind){case 1:return a.value;case 2:throw a.error;case 0:throw new I(601,!1)}},{equal:e?.equal})}function et(i=Object.is){return(e,t)=>e.kind===1&&t.kind===1&&i(e.value,t.value)}function P(i){let e=m(i);return e.setHours(0,0,0,0),e}function j(i,e){let t=P(i),r=P(e);return+t==+r}function Oe(i,e){let t=m(i),r=m(e);return t.getTime()>r.getTime()}function Fe(i,e){let t=m(i),r=m(e);return+t<+r}var Nt=(i,e,t)=>Math.max(Math.min(i,t),e),tt=0,Dt=(i="",e="")=>`${i}${++tt}${e}`,Tt=new Date(new Date().getFullYear(),0,1,0,0,0,0);function Re(i){return btoa(encodeURIComponent(i).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16))))}var it=_.mailerPath,p=_.freshdeskApiPath,rt=(t=>(t[t.regular=0]="regular",t[t.leavingSchool=1]="leavingSchool",t))(rt||{}),Ve=class i{constructor(e,t,r){this.http=e;this.auth=t;this.logger=r;this.logger.dump$.subscribe(n=>{let s=n.join(`;
`);this.http.post(`${it}ajax.php`,this.toFormData({topic:"debug",msg:s,formType:"debug"}),{notify:"NONE",spin:!1,handleErrors:!1}).pipe(x(()=>G)).subscribe()})}submitContactForm(e){let t=this.getHeaders(),r=`
        <h1>Anfrage \xFCber Kontaktformular: ${e.topic||"Schule"}</h1>
        <p><strong>Kundeninformationen:</strong></p>
        <p>
            Name: ${e.lastName}, ${e.firstName}<br>`;return e.customerType==="institution"&&(r+=`Position: ${e.jobPosition||"Keine Angabe"}<br>`),r+=`
        Stra\xDFe: ${e.street}<br>
        Ort: ${e.zip} ${e.city} (${e.country})<br>
        Tel.: ${e.phone||"Keine Angabe"}<br>
    <p>
    <p>
        Schule: ${e.school||"Keine Angabe"}<br>
        Fachnr.: ${e.lockerNo||"Keine Angabe"}<br>
    </p>
    <p><strong>Nachricht:</strong><br></p>
    <p>
        <pre>${e.msg||"Keine Angaben"}</pre>
    </p>`,this.http.post(`${p}tickets`,{subject:`Kontaktformular: ${e.topic||"Anfrage von Schule"}`,name:`${e.lastName}, ${e.firstName}`,email:e.mail,description:r,status:2,priority:1,type:e.topic,tags:["Kontaktformular"],group_id:e.customerType==="institution"?80000643283:void 0,custom_fields:{cf_schliefachnummer:e.lockerNo||"keine Angabe",cf_schule_ort:e.school||"keine Angabe"}},{headers:t})}submitContractTerminationForm(e){let t=this.getHeaders(),r=`
        <h1>K\xFCndigung \xFCber K\xFCndigungsformular: ${e.lastName}, ${e.firstName}</h1>
        <p><strong>Art der K\xFCndigung:</strong> ${e.typeOfTermination===0?"Ordentlich":"Au\xDFerordentlich (Schulabgang)"}</p>
        <p><strong>Kundeninformationen:</strong></p>
        <p>
            Name: ${e.lastName}, ${e.firstName}<br>
            Kundennummer: ${e.customerNo||"Keine Angabe"}<br>
            Stra\xDFe: ${e.street}<br>
            Ort: ${e.zip} ${e.city} (${e.country})<br>
        <p>
        <p>
            Schule: ${e.school||"Keine Angabe"}<br>
            Fachnr.: ${e.lockerNo||"Keine Angabe"}<br>
        </p>`;return this.http.post(`${p}tickets`,{subject:`K\xFCndigung: ${e.lastName}, ${e.firstName}`,name:`${e.lastName}, ${e.firstName}`,email:e.mail,description:r,status:2,priority:1,type:"K\xFCndigung",tags:["K\xFCndigungsformular"],group_id:80000480097,custom_fields:{cf_schliefachnummer:e.lockerNo||"keine Angabe",cf_schule_ort:e.school||"keine Angabe"}},{headers:t})}submitInsuranceDamageReport(e,t,r){let n=this.getHeaders(),s=this.toFormData({subject:"Schadensfall Schlie\xDFfachinhalt",name:`${e.lockerUser.lastName}, ${e.lockerUser.firstName}`,phone:e.billingAddress.phone,email:this.auth.user.email,description:this.LockerInsuranceDescription(e,t),status:2,priority:1,type:"Versicherung"}),l=new Date,a=""+l.getFullYear()+(l.getMonth()+1)+l.getDate();return r.forEach((b,Je)=>s.append("attachments[]",b,`${a}_Versicherungsschaden_${Je+1}.${this.getFileExtension(b)}`)),["Schadensmeldung","Schutzbrief"].forEach(b=>s.append("tags[]",b)),this.http.post(`${p}tickets`,s,{headers:n})}submitLockerDamageReport(e,t,r,n,s){let l=this.getHeaders();return this.http.post(`${p}tickets`,{subject:`Schadensmeldung am Schlie\xDFfach ${e.locker.lockerNumber}: ${r}`,name:`${e.lockerUser.lastName}, ${e.lockerUser.firstName}`,phone:e.billingAddress.phone,email:this.auth.user.email,description:`<h1>Schadensmeldung am Schlie\xDFfach ${e.locker.lockerNumber}: ${r}</h1><br>
                    ${this.userInfoToHtmlString(this.contractToUserInfo(e))}<br>
                    <p>
                        <strong>Schadensart:</strong> (Schadenscode: ${t}) ${r}
                    </p><br>
                    <p>
                        <strong>Verhalten des Schlosses:</strong> ${n||"Keine Angabe"}
                    </p><br>
                    <p><strong>Beschreibung des Schadens:</strong><br></p><br>
                    <p>
                        <pre>${s||"Es wurde keine Beschreibung angegeben"}</pre>
                    </p>
                `,status:2,priority:1,type:"Schaden melden",tags:["Schadensmeldung SF"]},{headers:l})}submitReplacementKeyForm(e,t){let r=this.getHeaders();return this.http.post(`${p}tickets`,{subject:"Schl\xFCsselbestellung",name:`${t.lockerUser.lastName}, ${t.lockerUser.firstName}`,phone:t.billingAddress.phone,email:this.auth.user.email,description:`<h1>Schl\xFCsselbestellung</h1><br>
                    ${this.userInfoToHtmlString(this.contractToUserInfo(t))}<br>
                    <p><strong>Bestellung:</strong></p><br>
                    <p>
                        Anzahl: ${e.numberOfKeys}<br>
                        Fachnummer: ${t.locker.lockerNumber}<br>
                        Schl\xFCsselnr.: ${t.locker.keyNumber}<br>
                        Schule: ${e.school}<br>
                        Ident der Schule: ${t.school.ident}
                    </p><br>
                    <p><strong>Bitte senden Sie die Schl\xFCssel an die folgende Adresse:</strong></p><br>
                    <p>
                        ${e.name}<br>
                        ${e.street}<br>
                        ${e.zip} ${e.city} (${e.country})
                    </p>
                `,status:2,priority:1,type:"Schl\xFCssel-/Transponderbestellung",tags:["Schl\xFCsselbestellung"]},{headers:r})}submitTransponderOrderForm(e,t){let r=this.getHeaders();return this.http.post(`${p}tickets`,{subject:"Transponderbestellung",name:`${t.lockerUser.lastName}, ${t.lockerUser.firstName}`,phone:t.billingAddress.phone,email:this.auth.user.email,description:`<h1>Schl\xFCsselbestellung</h1><br>
                    ${this.userInfoToHtmlString(this.contractToUserInfo(t))}<br>
                    <p><strong>Bestellung:</strong></p><br>
                    <p>
                        Anzahl: ${e.numberOfTransponders}<br>
                        Farbe: ${e.color}<br>
                        Fachnummer: ${t.locker.lockerNumber}<br>
                        Schl\xFCsselnr.: ${t.locker.keyNumber}<br>
                        Schule: ${e.school}<br>
                        Ident der Schule: ${t.school.ident}
                    </p><br>
                    <p><strong>Bitte senden Sie die Schl\xFCssel an die folgende Adresse:</strong></p><br>
                    <p>
                        ${e.name}<br>
                        ${e.street}<br>
                        ${e.zip} ${e.city} (${e.country})
                    </p>
                `,status:2,priority:1,type:"Schl\xFCssel-/Transponderbestellung",tags:["Transponderbestellung"]},{headers:r})}submitGetInsuranceForm(e){let t=this.getHeaders();return this.http.post(`${p}tickets`,{subject:"Wechsel von Kaution zu Schutzbrief",name:`${e.lockerUser.lastName}, ${e.lockerUser.firstName}`,email:this.auth.user.email,description:`<h1>Antrag auf Wechsel zum Schutzbrief</h1><br>
                    <p><strong>
                        Der nachfolgende Kunde hat beantragt, von der Kaution zum Schutzbrief zu wechseln:
                    </strong></p><br>
                    ${this.userInfoToHtmlString(this.contractToUserInfo(e))}
                `,status:2,priority:1,type:"Versicherung",tags:["Kaution zu Schutzbrief"]},{headers:t})}submitRegisterQuery(e){let t=this.getHeaders();return this.http.post(`${p}tickets`,{subject:"Gescheiterter Registrierungsversuch",name:`${e.lastName}, ${e.firstName}`,email:e.mail,description:`<h1>Gescheiterter Registrierungsversuch<h2><br>
                    <p>
                        <strong>Automatische Registrierung fehlgeschlagen f\xFCr:</strong>
                    </p><br>
                    <p>
                        ${e.lastName}, ${e.firstName}<br>
                        ${e.street}<br>
                        ${e.zip} ${e.city}
                    </p><br>
                    <p>
                        ${L.schoolToString(e.school)}
                    </p><br>
                    <p>
                        Fachnummer: ${e.lockerNo||"Keine Angabe"}
                    </p>
                `,status:2,priority:1,tags:["Registrierungsfehler"],group_id:80000499262},{headers:t})}submitInterestForm(e){let t=this.getHeaders();return this.http.post(`${p}tickets`,{subject:`Anfrage \xFCber Formular "Schule kein astradirect-Kunde" f\xFCr ${e.school}`,name:`${e.lastName}, ${e.firstName}`,phone:e.phone,email:e.mail,description:`<h1>Anfrage \xFCber Formular "Schule kein astradirect-Kunde"<h1><br>
                <p><strong>Bitte informieren Sie mich, wenn an dieser Schule Schlie\xDFf\xE4cher von astradirect verf\xFCgbar werden:</strong></p><br>
                <p>${e.school}</p><br>
                <p><strong>Kundeninformationen:</strong></p>
                <p>
                    Name: ${e.lastName}, ${e.firstName}<br>
                    Stra\xDFe: ${e.street}<br>
                    Ort: ${e.zip} ${e.city} (${e.country})
                </p><br>
                <p>
                    Tel.: ${e.phone}<br>
                    E-Mail: ${e.mail}
                </p>
            `,status:9,priority:1,tags:["Interesse"],group_id:80000502408},{headers:t})}contractToUserInfo(e){return{customerId:e.customerId,contractId:e.id,lockerNo:e.locker.lockerNumber+"",firstName:e.lockerUser.firstName,lastName:e.lockerUser.lastName,street:e.billingAddress.street,zip:e.billingAddress.zip,city:e.billingAddress.city,country:e.billingAddress.country,phone:e.billingAddress.phone,mail:this.auth.user.email,school:L.schoolToString(e.school)}}userInfoToHtmlString(e){return`
            <br><strong>Kundeninformationen:</strong></br><br>
            <p>
                Name: ${e.lastName}, ${e.firstName}<br>
                Mandatsreferatsnummer: ${e.customerId}<br>
                Vertragsnummer: ${e.contractId}<br>
                Fachnummer: ${e.lockerNo||"nicht zugewiesen"}<br>
                Schule: ${e.school}
            </p><br>
            <p><strong>Anschrift:</strong></p><br>
            <p>
                ${e.street}<br>
                ${e.zip} ${e.city} (${e.country})
            </p><br>
            <p>
                Tel.: ${e.phone}
            </p>`}LockerInsuranceDescription(e,t){return`
            <h1>Schadensfall Schlie\xDFfachinhalt (Schutzbrief)</h1><br>
            <p>
            Im Rahmen der Versicherung f\xFCr den Schlie\xDFfachinhalt wurde folgender Schadensfall gemeldet:
            </p><br>
            ${this.userInfoToHtmlString(this.contractToUserInfo(e))}<br>
            <p><strong>Schadensbeschreibung:</strong></p><br>
            <pre>${t||"Keine Beschreibung vorhanden"}</pre>
        `}getFileExtension(e){switch(e.type.toLowerCase()){case"image/png":return"png";case"image/jpg":case"image/jpeg":return"jpg";case"application/pdf":return"pdf";default:return"unknown"}}getHeaders(){return new he().set("Authorization",`Basic ${Re(_.freshdeskApiKey)}:X`)}toFormData(e,t){typeof t>"u"&&(t=new FormData);for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.append(r,e[r]);return t}static{this.\u0275fac=function(t){return new(t||i)(u(be),u(Se),u(fe))}}static{this.\u0275prov=d({token:i,factory:i.\u0275fac,providedIn:"root"})}};var Wt=[{id:"Deutschland",iso:"DE",name:"Deutschland"},{id:"\xD6sterreich",iso:"AT",name:"\xD6sterreich"},{id:"Schweiz",iso:"CH",name:"Schweiz"},{id:"Luxemburg",iso:"LU",name:"Luxemburg"},{id:"Spanien",iso:"ES",name:"Spanien"},{id:"Belgien",iso:"BE",name:"Belgien"},{id:"Niederlande",iso:"NL",name:"Niederlande"},{id:"D\xE4nemark",iso:"DK",name:"D\xE4nemark"},{id:"Polen",iso:"PL",name:"Polen"},{id:"Tschechien",iso:"CZ",name:"Tschechien"},{id:"Frankreich",iso:"FR",name:"Frankreich"}];var Jt="Backspace;Enter;ArrowLeft;ArrowRight;Delete;Home;End;Tab;.".split(";"),Xt=new RegExp("^[0-9]$");var nt=i=>i.value===null||(typeof i.value=="string"||Array.isArray(i.value))&&i.value.length===0;var st={AL:"\\d{8}[\\dA-Z]{16}",AD:"\\d{8}[\\dA-Z]{12}",AT:"\\d{16}",AZ:"[\\dA-Z]{4}\\d{20}",BE:"\\d{12}",BH:"[A-Z]{4}[\\dA-Z]{14}",BA:"\\d{16}",BR:"\\d{23}[A-Z][\\dA-Z]",BG:"[A-Z]{4}\\d{6}[\\dA-Z]{8}",CR:"\\d{17}",HR:"\\d{17}",CY:"\\d{8}[\\dA-Z]{16}",CZ:"\\d{20}",DK:"\\d{14}",DO:"[A-Z]{4}\\d{20}",EE:"\\d{16}",FO:"\\d{14}",FI:"\\d{14}",FR:"\\d{10}[\\dA-Z]{11}\\d{2}",GE:"[\\dA-Z]{2}\\d{16}",DE:"\\d{18}",GI:"[A-Z]{4}[\\dA-Z]{15}",GR:"\\d{7}[\\dA-Z]{16}",GL:"\\d{14}",GT:"[\\dA-Z]{4}[\\dA-Z]{20}",HU:"\\d{24}",IS:"\\d{22}",IE:"[\\dA-Z]{4}\\d{14}",IL:"\\d{19}",IT:"[A-Z]\\d{10}[\\dA-Z]{12}",KZ:"\\d{3}[\\dA-Z]{13}",KW:"[A-Z]{4}[\\dA-Z]{22}",LV:"[A-Z]{4}[\\dA-Z]{13}",LB:"\\d{4}[\\dA-Z]{20}",LI:"\\d{5}[\\dA-Z]{12}",LT:"\\d{16}",LU:"\\d{3}[\\dA-Z]{13}",MK:"\\d{3}[\\dA-Z]{10}\\d{2}",MT:"[A-Z]{4}\\d{5}[\\dA-Z]{18}",MR:"\\d{23}",MU:"[A-Z]{4}\\d{19}[A-Z]{3}",MC:"\\d{10}[\\dA-Z]{11}\\d{2}",MD:"[\\dA-Z]{2}\\d{18}",ME:"\\d{18}",NL:"[A-Z]{4}\\d{10}",NO:"\\d{11}",PK:"[\\dA-Z]{4}\\d{16}",PS:"[\\dA-Z]{4}\\d{21}",PL:"\\d{24}",PT:"\\d{21}",RO:"[A-Z]{4}[\\dA-Z]{16}",SM:"[A-Z]\\d{10}[\\dA-Z]{12}",SA:"\\d{2}[\\dA-Z]{18}",RS:"\\d{18}",SK:"\\d{20}",SI:"\\d{15}",ES:"\\d{20}",SE:"\\d{20}",CH:"\\d{5}[\\dA-Z]{12}",TN:"\\d{20}",TR:"\\d{5}[\\dA-Z]{17}",AE:"\\d{3}\\d{16}",GB:"[A-Z]{4}\\d{14}",VG:"[\\dA-Z]{4}\\d{16}"};function Ne(i){if(nt(i))return null;let e=i.value.replace(/ /g,"").toUpperCase(),t=e.substring(0,2),r=st[t];if(typeof r<"u"){if(!new RegExp(`^[A-Z]{2}\\d{2}${r}$`,"").test(e))return{invalidCountrySpecificFormat:!0}}else return{noCountryPatternFound:!0};let n=e.substring(4,e.length)+e.substring(0,4),s="";for(let a of n){let b="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(a);s+=b}return U(s)===1?null:{checksumInvalid:!0}}function U(i){return i.length<=15?Number(i)%97:U(`${U(i.substring(0,15))}${i.substring(15,i.length)}`)}function De(i){return i.value===null||typeof i.value>"u"?{isNull:!0}:/^[0-9]{4,16}$/gm.test(i.value)?null:{noValidAccountNo:!0}}function Te(i){return i.value===null||typeof i.value>"u"?{isNull:!0}:/^[0-9]{8}$/gm.test(i.value)?null:{noValidBankcode:!0}}function Ee(i){return i==null||(typeof i=="string"||Array.isArray(i))&&i.length===0}function Me(i,e,t="dd.MM.yyyy"){return r=>{if(Ee(r.value))return null;if(typeof r.value=="string"&&/^[0-9]{2}\.[0-9]{2}\.[0-9]{4}$/.test(r.value)||typeof r.value=="number"||r.value instanceof Date){let n=new Date(typeof r.value=="string"?ge(r.value,t,new Date):new Date(r.value));return Fe(n,i)&&!j(n,i)?{dateToEarly:!0}:e instanceof Date&&Oe(n,e)&&!j(n,e)?{dateToLate:!0}:null}return{noValidDate:!0}}}function Le(i=!1){return e=>i&&Ee(e.value)?null:ot(e.value)||lt(e.value)}function ot(i){return typeof i!="string"||!/^((0[1-9])|([1-2][0-9])|(3[0-1]))\.((0[1-9])|(1[0-2]))\.[1-2][0-9]{3}$/.test(i)?{invalidDateFormat:!0}:null}function lt(i){let[e,t,r]=i.split(".").map(n=>Number(n));if(isNaN(e)||isNaN(t)||isNaN(r))return{dateComponentIsNaN:!0};if(e>0){if(t===2){if(at(r)&&e<30||e<29)return null}else if([1,3,5,7,8,10,12].includes(t)&&e<32||e<31)return null}return{invalidDay:!0}}function at(i){return i%400===0?!0:i%4===0&&i%100!==0}function Be(i){return i.value===null||typeof i.value>"u"?{isNull:!0}:Ae.find(t=>t.id===i.value||t.id+""===i.value)?null:{noValidLockerType:!0}}function K(i,e=null){let t,r;return n=>{if(!n.parent)return null;if(!t){if(t=n,r=n.parent.get(i),!r)throw new Error("matchOtherValidator(): other control is not found in parent group");e!==null?r.valueChanges.pipe(S(e)).subscribe(()=>{t.updateValueAndValidity()}):r.valueChanges.subscribe(()=>{t.updateValueAndValidity()})}return r&&r.value!==t.value?{matchOther:!0}:null}}var Pe=class{static get phone(){return[o.pattern(/^\+?\d{1,4}?[\s]?[-.\s\/]?[\s]?\(?\d{1,3}?\)?[\s]?[-.\s\/]?[\s]?\d{1,4}[\s]?[-.\s\/]?[\s]?\d{1,4}[\s]?[-.\s\/]?[\s]?\d{1,9}[\s]?[-.\s\/]?[\s]?\d{1,9}[\s]?[-.\s\/]?[\s]?\d{1,9}$/)]}static get zip(){return[o.pattern(/^(?!01000|99999)(0[1-9]\d{3}|[1-9]\d{4})$/),o.required]}static get something(){return[o.required,o.minLength(3)]}static get shortSomething(){return[o.required,o.minLength(2)]}static get iban(){return[o.required,Ne]}static get bic(){return[o.required,o.pattern(/^([a-zA-Z]{6})([a-zA-Z0-9]{2}|[a-zA-Z0-9]{5})$/)]}static get accNumber(){return[o.required,De]}static get bankcode(){return[o.required,Te]}static get mail(){return[o.required,o.email]}static get city(){return[o.required,o.pattern(/^[ ]*[a-zA-ZÀ-ž.]{3,}([ \-\(\/,]*[a-zA-ZÀ-ž0-9.]+[. \)]?)*[ ]*$/)]}static get singleNonZeroDigit(){return[o.required,o.pattern(/^[1-9]$/)]}static matchMail(e,t=null){return this.mail.concat([K(e,t)])}static matchOther(e,t=null){return[o.required,K(e,t)]}static get lockerType(){return[o.required,Be]}static matchPassword(e,t,r=null){return this.matchOther(e,r).concat([o.minLength(t)])}static dateBetween(e,t,r){return Me(e,t,r)}static isDate(e="required"){return Le(e==="optional")}};function je(){return{unwrappedCities:[],schools:[],selectedSchool:null,selectedCity:null,schoolSearchTerm:"",citySearchTerm:"",cityResults:[],schoolResults:[]}}var c=class extends de{constructor(){super(je())}reset(){this.update(je())}};c.\u0275fac=function(t){return new(t||c)},c.\u0275prov=d({token:c,factory:c.\u0275fac,providedIn:"root"}),c=z([pe({name:"school-search"})],c);var Ke=class i extends me{constructor(t){super(t);this.store=t;this.cities$=this.select("unwrappedCities");this.schools$=this.select("schools");this.selectedCity$=this.select("selectedCity");this.selectedSchool$=this.select("selectedSchool");this.citySearchTerm$=this.select("citySearchTerm");this.cityResults$=this.select("cityResults");this.schoolResults$=this.select("schoolResults");this.schoolSearchDisabled$=this.select(t=>!t.schools.length);this.citySearchDisabled$=this.select(t=>!t.unwrappedCities.length)}static{this.\u0275fac=function(r){return new(r||i)(u(c))}}static{this.\u0275prov=d({token:i,factory:i.\u0275fac,providedIn:"root"})}};var He=10;function qe(i,e){if(!i.trim().length)return[];let t=i.trim().split(/\s+/),r=[];return e.forEach(n=>{let s=F({},n);s.quality=0,s.zip!==null&&Ze(i)?t.forEach(l=>{s.quality+=Z(l,s.displayName)}):s.zip===null&&!Ze(i)&&t.forEach(l=>{s.quality+=Z(l,s.name)}),s.quality>0&&r.push(s)}),r.sort((n,s)=>s.quality-n.quality),r.splice(0,He)}function Ge(i,e){if(!i.trim().length)return[];let t=i.trim().split(/\s+/),r=[];return e.forEach(n=>{let s=0;t.forEach((l,a)=>{s+=Z(l,n.name)-a*2}),s>0&&r.push({school:n,quality:s,displayName:n.name})}),r.sort((n,s)=>s.quality-n.quality),r.splice(0,He)}function We(i){let e=[];return i.forEach(t=>{e.push({city:t,displayName:t.name,name:t.name,zip:null,quality:0}),t.zips.forEach(r=>{e.push({city:t,displayName:`${r} ${t.name}`,name:t.name,zip:r,quality:0})})}),e}function Ze(i){return!!i.trim().split(/\s+/).find(e=>ct(e))}function ct(i){return/^[0-9]{0,5}$/.test(i)}function ze(i){return i.toUpperCase().replace(/[&/\\#,+()$~%.'":*?<>{}]/g,"")}function Z(i,e){let t=ze(e),r=t.indexOf(ze(i));return r!==-1?Math.max(0,(t.length-r)/t.length+Math.max(0,20-r)):0}var Qe=class i{constructor(e,t){this.schoolSearchStore=e;this.lockersNetInterface=t;this.filterOB=!1;this.filterGS=!1;this.filterPool=!1;this.filterASP=!1}resetStore(){this.schoolSearchStore.reset(),this.fetchCities(),this.filterOB=this.filterGS=this.filterPool=!1}fetchCities(e=!1){(!this.schoolSearchStore.getValue().unwrappedCities.length||e)&&this.lockersNetInterface.getCities().pipe(X(()=>this.schoolSearchStore.setLoading(!1))).subscribe(t=>this.schoolSearchStore.update({unwrappedCities:We(t)}))}fetchSchools(e,t=!1){return this.schoolSearchStore.setLoading(!0),this.schoolSearchStore.update({schools:[]}),this.lockersNetInterface.getSchools(e).pipe(x(()=>(this.schoolSearchStore.setLoading(!1),W(null))),R(()=>this.schoolSearchStore.setLoading(!1)),y(r=>this.filterOB?r.filter(n=>!n.ident.toUpperCase().includes("OB")):r),y(r=>this.filterGS?r.filter(n=>!n.ident.toUpperCase().includes("GS")):r),y(r=>this.filterPool?r.filter(n=>n.id!==0):r),y(r=>this.filterASP?r.filter(n=>!(n.ident.toUpperCase().includes("AS")&&n.ident.toUpperCase().includes("P"))):r),y(r=>r.sort((n,s)=>n.name.localeCompare(s.name))),R(r=>{t?this.schoolSearchStore.update({schools:r}):this.schoolSearchStore.update({schools:r,selectedSchool:null,schoolSearchTerm:"",schoolResults:[]})}))}selectCity(e,t=!1){if(e.displayName!==this.schoolSearchStore.getValue().selectedCity?.displayName){let r=e.zip||e.name;this.fetchSchools(r,t).subscribe()}this.schoolSearchStore.update({selectedCity:e,citySearchTerm:e.displayName,cityResults:[]})}selectSchool(e){this.schoolSearchStore.update({selectedSchool:e,schoolSearchTerm:""})}setCitySearchTerm(e){this.schoolSearchStore.update({citySearchTerm:e,cityResults:qe(e,this.schoolSearchStore.getValue().unwrappedCities)})}setSchoolSearchTerm(e){this.schoolSearchStore.update({schoolSearchTerm:e,schoolResults:Ge(e,this.schoolSearchStore.getValue().schools)})}setOBFilter(e=!1){return this.filterOB=e,this}setGSFilter(e=!1){return this.filterGS=e,this}setAddressPoolFilter(e=!1){return this.filterPool=e,this}setASPFilter(e=!1){return this.filterASP=e,this}static{this.\u0275fac=function(t){return new(t||i)(u(c),u(ye))}}static{this.\u0275prov=d({token:i,factory:i.\u0275fac,providedIn:"root"})}};var ut=i=>({valid:i}),ht=i=>({selected:i});function pt(i,e){if(i&1){let t=oe();v(0,"span",9),E("mousedown",function(){let n=re(t).$implicit,s=$(2);return ne(s.selectResult(n))}),k(1),f()}if(i&2){let t=e.$implicit,r=e.index,n=$(2);g("ngClass",M(2,ht,r==n.preselectedResult)),h(),A(t[n.descriptionKey])}}function dt(i,e){if(i&1&&(v(0,"div",7),T(1,pt,2,4,"span",8),f()),i&2){let t=$();h(),g("ngForOf",t.results)}}var Ye=class i{constructor(e){this.fb=e;this.results=[];this.descriptionKey="";this.placeholder="";this.disabled=!0;this.onTermChange=new N;this.onSelected=new N;this.id="autocomplete-"+Math.floor(Math.random()*new Date().getTime());this.showResults=!1;this.preselectedResult=-1;this.unsubscribe$=new q;this.lastSelectionStart=0;this.searchForm=this.fb.group({term:[""]})}ngOnInit(){this.subscribeToResetEmitter(),this.subscribeToFormValueChanges()}ngAfterViewInit(){this.presetInputValue()}ngOnChanges(){this.results.length?(this.preselectedResult=0,this.showResults=!0):(this.preselectedResult=-1,this.showResults=!1),this.disabled?this.searchForm.get("term").disable():this.searchForm.get("term").enable()}ngOnDestroy(){this.unsubscribe$.next(),this.unsubscribe$.complete()}onKeyUp(e){let t=e.target;e.keyCode===13?(this.selectCurrentlyPreselectedResult(),e.preventDefault()):e.keyCode===39?this.lastSelectionStart===t.value.length&&(this.selectCurrentlyPreselectedResult(),e.preventDefault()):e.keyCode===38?this.cyclePreselectedResults(-1):e.keyCode===40&&this.cyclePreselectedResults(1),this.lastSelectionStart=t.selectionStart}selectResult(e){this.selectedResult=e,this.showResults=!1,this.preselectedResult=-1,this.onSelected.emit(this.selectedResult),this.searchForm.patchValue({term:e[this.descriptionKey]},{emitEvent:!0})}selectCurrentlyPreselectedResult(){this.results.length&&this.preselectedResult!==-1?this.selectResult(this.results[this.preselectedResult]):this.selectedResult&&this.selectResult(this.selectedResult)}cyclePreselectedResults(e=1){this.showResults&&(this.preselectedResult=Math.min(this.results.length-1,Math.max(0,this.preselectedResult+e)))}presetInputValue(){this.initialSelection&&setTimeout(()=>this.selectResult(this.initialSelection))}subscribeToFormValueChanges(){this.searchForm.valueChanges.pipe(S(this.unsubscribe$),ee("term"),J(),Y(200),Q(e=>typeof this.selectedResult>"u"||e!==this.selectedResult[this.descriptionKey])).subscribe(e=>{this.onTermChange.emit(e)})}subscribeToResetEmitter(){this.reset&&this.reset.subscribe(()=>{this.showResults=!1,this.searchForm.patchValue({term:""},{emitEvent:!1}),this.selectedResult=void 0})}static{this.\u0275fac=function(t){return new(t||i)(se(ke))}}static{this.\u0275cmp=te({type:i,selectors:[["app-autocomplete"]],inputs:{results:"results",initialSelection:"initialSelection",descriptionKey:"descriptionKey",placeholder:"placeholder",disabled:"disabled",reset:"reset"},outputs:{onTermChange:"onTermChange",onSelected:"onSelected"},features:[ie],decls:9,vars:10,consts:[[1,"autocomplete-container"],[3,"formGroup"],[1,"form-control"],[3,"for"],["type","text","formControlName","term",1,"ignore-ng-valid","no-margin",3,"keyup","blur","id","placeholder","ngClass"],[1,"tooltip","-top-left"],["class","result-list",4,"ngIf"],[1,"result-list"],["class","search-result",3,"ngClass","mousedown",4,"ngFor","ngForOf"],[1,"search-result",3,"mousedown","ngClass"]],template:function(t,r){t&1&&(v(0,"div",0)(1,"form",1)(2,"div",2)(3,"label",3),k(4),f(),v(5,"input",4),E("keyup",function(s){return r.onKeyUp(s)})("blur",function(){return r.selectCurrentlyPreselectedResult()}),f(),v(6,"div",5),k(7),f()(),T(8,dt,2,1,"div",6),f()()),t&2&&(h(),g("formGroup",r.searchForm),h(2),g("for",r.id),h(),A(r.placeholder),h(),g("id",r.id)("placeholder","* "+r.placeholder)("ngClass",M(8,ut,!!r.selectedResult)),h(2),A(r.placeholder),h(),g("ngIf",r.showResults))},dependencies:[ae,ce,ue,Ie,ve,Ce,xe,we,$e],styles:[".autocomplete-container[_ngcontent-%COMP%]{position:relative}.autocomplete-container[_ngcontent-%COMP%]   .result-list[_ngcontent-%COMP%]{position:absolute;top:100%;left:0;right:0;border:1px solid #9f9f9f;background-color:#e9e9e9;box-shadow:0 2px 6px #00000026,0 4px 12px #0000000d;z-index:9001}.autocomplete-container[_ngcontent-%COMP%]   .result-list[_ngcontent-%COMP%]   span.search-result[_ngcontent-%COMP%]{display:block;line-height:48px;padding:0 8px;cursor:pointer;font-size:1em;font-weight:300}.autocomplete-container[_ngcontent-%COMP%]   .result-list[_ngcontent-%COMP%]   span.search-result.selected[_ngcontent-%COMP%], .autocomplete-container[_ngcontent-%COMP%]   .result-list[_ngcontent-%COMP%]   span.search-result[_ngcontent-%COMP%]:hover{background-color:#fa0;color:#fff;font-weight:700}"]})}};export{Fe as a,Wt as b,_e as c,It as d,Xe as e,Nt as f,Dt as g,Ne as h,Pe as i,rt as j,Ve as k,Ke as l,Qe as m,Ye as n};