`);printWindow.document.querySelector('head link').onload=function(){printWindow.document.close();printWindow.focus();printWindow.print();printWindow.close();if(this.trackAs){plausible(this.trackAs,{props:{stage:'print'}});}}},},template:`Letter generator
Fill the missing information to get a printable letter.
Fill the missing information to get a message template.
`,});document.querySelectorAll('.auslaenderbeho*rde-job-change').forEach(el=>new Vue({el:el,mixins:[uniqueIdsMixin],data(){return{fullName:'',address:'',dateOfBirth:'',letterType:'termination',placeOfBirth:'',nationality:'',auslaenderbeho*rde:'friedrich-krause-ufer',customRecipientAddress:'',currentDate:new Date(),lastDayOfWork:'',sortedCountryList:countries.getSortedList(),};},computed:{recipientAddress(){if(this.auslaenderbeho*rde!=='other'){return'Landesamt für Einwanderung\nFriedrich-Krause-Ufer 24\n13353 Berlin';}return this.customRecipientAddress;},},methods:{dateFromString,formatDate,}}));const germanStates={'bw':{isInEastGermany:false,englishName:'Baden-Württemberg',germanName:'Baden-Württemberg',},'by':{isInEastGermany:false,englishName:'Bavaria',germanName:'Bayern',},'be-east':{isInEastGermany:true,englishName:'Berlin (East)',germanName:'Berlin (Ost)',},'be-west':{isInEastGermany:false,englishName:'Berlin (West)',germanName:'Berlin (West)',},'bb':{isInEastGermany:true,englishName:'Brandenburg',germanName:'Brandenburg',},'hb':{isInEastGermany:false,englishName:'Bremen',germanName:'Bremen',},'hh':{isInEastGermany:false,englishName:'Hamburg',germanName:'Hamburg',},'hr':{isInEastGermany:false,englishName:'Hesse',germanName:'Hessen',},'ni':{isInEastGermany:false,englishName:'Lower Saxony',germanName:'Niedersachsen',},'mv':{isInEastGermany:false,englishName:'Mecklenburg-Western Pomerania',germanName:'Mecklenburg-Vorpommern',},'nw':{isInEastGermany:false,englishName:'North Rhine-Westphalia',germanName:'Nordrhein-Westfalen',},'rp':{isInEastGermany:false,englishName:'Rhineland-Palatinate',germanName:'Rheinland-Pfalz',},'sl':{isInEastGermany:false,englishName:'Saarland',germanName:'Saarland',},'sn':{isInEastGermany:false,englishName:'Saxony',germanName:'Sachsen',},'st':{isInEastGermany:false,englishName:'Saxony-Anhalt',germanName:'Sachsen-Anhalt',},'sh':{isInEastGermany:false,englishName:'Schleswig-Holstein',germanName:'Schleswig-Holstein',},'th':{isInEastGermany:false,englishName:'Thuringia',germanName:'Thüringen',},};function stateName(stateObj){if(stateObj.englishName.startsWith('Berlin')||stateObj.englishName===stateObj.germanName){return stateObj.englishName;}return`${stateObj.englishName} (${stateObj.germanName})`;}function formatPercent(num,addSymbol=true){const formattedNum=num.toLocaleString('en-GB',{minimumFractionDigits:0,maximumFractionDigits:3,});return addSymbol?`${formattedNum}%`:formattedNum;}function getDefault(key,fallback){if(typeof sessionStorage==='object'){try{const value=localStorage.getItem(key)return value===null?defaults[key]:value;}catch(e){}return fallback;}}function getDefaultNumber(key,fallback){return+getDefault(key,fallback)}function getDefaultBoolean(key,fallback){const storedValue=getDefault(key);return storedValue?storedValue==='true':!!fallback;}function setDefault(key,value){if(value===null||value===undefined){return;}if(typeof sessionStorage==='object'){try{localStorage.setItem(key,value);defaults[key]=value;return true;}catch(e){}return false;}}function setDefaultString(key,value){setDefault(key,value?'1':'')}function setDefaultNumber(key,value){setDefault(key,+value)}function setDefaultBoolean(key,value){setDefault(key,!!value)}const bafogBedarfssatz=855;const healthInsurance={defaultTarif:14.6/100,selfEmployedTarif:14/100,studentTarif:10.219999999999999/100,minMonthlyIncome:1178.3333333333333,maxMonthlyIncome:62100/12,minFreiwilligMonthlyIncome:69300/12,maxFamilienvericherungIncome:505.0,midijobMaxIncome:2000,avgZusatzbeitrag:1.7/100,azubiFreibetrag:325,nebenjobMaxIncome:2651.25,factorF:0.6846,kskMinimumIncome:3900,companies:{average:{name:'Average health insurance',zusatzbeitrag:1.7/100,},aok:{name:'AOK Nordost',zusatzbeitrag:2.7/100,},barmer:{name:'Barmer',zusatzbeitrag:2.19/100,},dak:{name:'DAK',zusatzbeitrag:1.7/100,},hkk:{name:'hkk',zusatzbeitrag:0.98/100,},tk:{name:'Techniker Krankenkasse',zusatzbeitrag:1.2/100,},},}const pflegeversicherung={defaultTarif:3.4/100,surchargeTarif:4/100,discountPerChild:0.25/100,minimumChildCountForDiscount:2,maximumChildCountForDiscount:5,employerTarif:3.4/100/2,defaultTarifMaxAge:22,};const taxes={church:{default:9/100,bw:8/100,by:8/100,},arbeitslosenversicherungRate:1.3/100,beitragsbemessungsgrenze:{2000:{west:4500*12,east:3750*12},2001:{west:4500*12,east:3750*12},2002:{west:4500*12,east:3750*12},2003:{west:5100*12,east:4250*12},2004:{west:5150*12,east:4350*12},2005:{west:5200*12,east:4400*12},2006:{west:5250*12,east:4400*12},2007:{west:5250*12,east:4550*12},2008:{west:5300*12,east:4500*12},2009:{west:5400*12,east:4550*12},2010:{west:5500*12,east:4650*12},2011:{west:5500*12,east:4800*12},2012:{west:5600*12,east:4800*12},2013:{west:5800*12,east:4900*12},2014:{west:5950*12,east:5000*12},2015:{west:6050*12,east:5200*12},2016:{west:6200*12,east:5400*12},2017:{west:6350*12,east:5700*12},2018:{west:6500*12,east:5800*12},2019:{west:6700*12,east:6150*12},2020:{west:6900*12,east:6450*12},2021:{west:7100*12,east:6700*12},2022:{west:7050*12,east:6750*12},2023:{west:7300*12,east:7100*12},currentYear:{west:90600,east:89400},2024:{west:90600,east:89400},2025:{west:90600,east:89400},2026:{west:90600,east:89400},2027:{west:90600,east:89400},},grundfreibetrag:11604,kinderfreibetrag:9312,entlastungsbetragAlleinerziehende:4260,entlastungsbetragAlleinerziehendePerChild:240,kindergeldPerChild:250,solidarity:{minIncomeTax:18130,milderungszoneRate:0.119,maxRate:0.055,},minVorsorgepauschal:1900,minVorsorgepauschalTaxClass3:3000,incomeTaxTarifZones:{1:{formula:(x,y,z)=>0,minIncome:-Infinity,maxIncome:11604,},2:{formula:(x,y,z)=>(922.98*y+1400)*y,minIncome:11604,maxIncome:17005,},3:{formula:(x,y,z)=>(181.19*z+2397)*z+1025.38,minIncome:17005,maxIncome:66760,},4:{formula:(x,y,z)=>0.42*x-10602.13,minIncome:66760,maxIncome:277825,},5:{formula:(x,y,z)=>45/100*x-18936.88,minIncome:277825,maxIncome:Infinity,},},incomeTaxClass56:{maxIncome1:13279,maxIncome2:33380,maxIncome3:222260,},maxMinijobIncome:538,arbeitnehmerpauschale:1230,sonderausgabenPauschbetrag:36,};const brexitDate=new Date(2021,0,1);const pensions={contractingCountries:new Set(['AL','AU','BR','CA','CL','IN','IL','JP','KR','MA','ME','PH','TN','TR','UY','US']),balkanBlockCountries:new Set(['BA','MK','RS','XK','ME']),disqualifyingCountries:new Set(['BA','MK','RS','XK','ME','TR']),contributionRates:{2000:19.3,2001:19.1,2002:19.1,2003:19.5,2004:19.5,2005:19.5,2006:19.5,2007:19.9,2008:19.9,2009:19.9,2010:19.9,2011:19.9,2012:19.6,2013:18.9,2014:18.9,2015:18.7,2016:18.7,2017:18.7,2018:18.6,2019:18.6,2020:18.6,2021:18.6,2022:18.6,2023:18.6,2024:18.6,currentYear:18.6,2025:18.6,2026:18.6,},}const occupations={isEmployed:(occupation)=>['employee','azubi','studentEmployee'].includes(occupation),isSelfEmployed:(occupation)=>['selfEmployed','studentSelfEmployed'].includes(occupation),isUnemployed:(occupation)=>['unemployed','student'].includes(occupation),isMinijob:(occupation,monthlyIncome)=>['employee','studentEmployee'].includes(occupation)&&monthlyIncome<=taxes.maxMinijobIncome,isLowIncome:(monthlyIncome)=>monthlyIncome<=taxes.maxMinijobIncome,};const defaults={age:25,childrenCount:0,church:'other',isMarried:false,occupation:'employee',state:'be-east',useMonthlyIncome:false,yearlyIncome:Math.round(42192/100)*100,healthInsuranceType:'unknown',privateHealthInsuranceCost:550,publicHealthInsuranceZusatzbeitrag:healthInsurance.companies.average.zusatzbeitrag*100,};function monthsBetween(dateA,dateB){const startDate=new Date(dateA);const endDate=new Date(dateB);const yearDiff=endDate.getFullYear()-startDate.getFullYear();const monthDiff=endDate.getMonth()-startDate.getMonth()+1;return yearDiff*12+monthDiff;}function estimateMonthlyPensionContributions(year,monthlyIncome,isInEastGermany){const maxMonthlyIncome=taxes.beitragsbemessungsgrenze[year][isInEastGermany?'east':'west']/12;const taxedIncome=Math.min(maxMonthlyIncome,monthlyIncome);return taxedIncome*pensions.contributionRates[year]/2/100;}function estimateYearlyPensionContributions(year,yearlyIncome,isInEastGermany,monthsWorked=12){return estimateMonthlyPensionContributions(year,yearlyIncome/12,isInEastGermany)*monthsWorked;}function estimatePensionContributions(startDate,endDate,yearlyIncome,isInEastGermany){const startMonth=startDate.getMonth();const endMonth=endDate.getMonth();if(startDate.getFullYear()===endDate.getFullYear()){return estimateYearlyPensionContributions(endDate.getFullYear(),yearlyIncome,isInEastGermany,endMonth-startMonth+1);}else{const monthsWorkedInFirstYear=12-startMonth;const monthsWorkedInLastYear=endMonth+1;let total=0;total+=estimateYearlyPensionContributions(startDate.getFullYear(),yearlyIncome,isInEastGermany,monthsWorkedInFirstYear);for(let year=startDate.getFullYear()+1;year=60){flags.add('not-eligible');flags.add('over-5-years');}}else if(nationality==='IL'){flags.add('israel-national');if(pensions.disqualifyingCountries.has(countryOfResidence)){flags.add('not-eligible');flags.add('disqualifying-country-resident');}else if(countryOfResidence==='IL'){flags.add('not-eligible');flags.add('israel-resident');}else if(monthsContributed>=60){flags.add('not-eligible');flags.add('over-5-years');}}else if(nationality==='JP'){flags.add('japan-national');if(pensions.disqualifyingCountries.has(countryOfResidence)){flags.add('not-eligible');flags.add('disqualifying-country-resident');}else if(countryOfResidence==='JP'){if(monthsContributed>=60){flags.add('not-eligible');flags.add('over-5-years');}flags.add('japan-resident');}}else if(nationality==='TR'){flags.add('turkey-national');if(monthsContributed>=60){if(countryOfResidence==='TR'){flags.add('turkey-resident');}else{flags.add('not-eligible');flags.add('over-5-years');}}}else if(pensions.contractingCountries.has(nationality)){flags.add('contracting-national');if(pensions.disqualifyingCountries.has(countryOfResidence)){flags.add('not-eligible');flags.add('disqualifying-country-resident');}else if(monthsContributed>=60){flags.add('not-eligible');flags.add('over-5-years');}}else if(nationality==='GB'){flags.add('uk-national');if(entryDate=24){flags.add('eligible');}else{flags.add('eligible-later');}}if(!flags.has('not-eligible')&&entryDate&&exitDate&&yearlyIncome){refundAmount=estimatePensionContributions(entryDate,exitDate,yearlyIncome,isInEastGermany);}return{flags,refundAmount};}Vue.component('collapsible',{props:{static:Boolean,},template:`
`,});function roundCurrency(num,roundDown=false){if(roundDown){return Math.floor(num*100)/100;}return Math.round(num*100)/100;}function formatCurrency(num,includeCents=false,currency='€',html=false){const decimalsToShow=includeCents?2:0;let formattedNum=roundCurrency(num).toLocaleString('en-GB',{minimumFractionDigits:decimalsToShow,maximumFractionDigits:decimalsToShow,});if(formattedNum==='-0.00'){formattedNum='0.00';}else if(formattedNum==='-0'){formattedNum='0';}if(html){return`${formattedNum}${currency ? '' : ''}${currency || ''}`;}return currency?`${formattedNum} ${currency}`:formattedNum;}let exchangeRates=null;const defaultCurrencyCodes=["USD","GBP","INR"];const countryCodeToCurrencyCode={"AF":"AFN","AL":"ALL","DZ":"DZD","AS":"USD","AO":"AOA","AI":"XCD","AQ":"XCD","AG":"XCD","AR":"ARS","AM":"AMD","AW":"AWG","AU":"AUD","AZ":"AZN","BS":"BSD","BH":"BHD","BD":"BDT","BB":"BBD","BZ":"BZD","BJ":"XOF","BM":"BMD","BT":"BTN","BO":"BOB","BA":"BAM","BW":"BWP","BV":"NOK","BR":"BRL","IO":"USD","BN":"BND","BG":"BGN","BF":"XOF","BI":"BIF","KH":"KHR","CM":"XAF","CA":"CAD","CV":"CVE","KY":"KYD","CF":"XAF","TD":"XAF","CL":"CLP","CN":"CNY","CX":"AUD","CC":"AUD","CO":"COP","KM":"KMF","CG":"XAF","CK":"NZD","CR":"CRC","HR":"EUR","CU":"CUP","CZ":"CZK","DK":"DKK","DJ":"DJF","DM":"XCD","DO":"DOP","TP":"USD","EG":"EGP","SV":"SVC","GQ":"XAF","ER":"ERN","ET":"ETB","FK":"FKP","FO":"DKK","FJ":"FJD","PF":"XPF","GA":"XAF","GM":"GMD","GE":"GEL","GH":"GHS","GI":"GIP","GL":"DKK","GD":"XCD","GU":"USD","GN":"GNF","GY":"GYD","HT":"HTG","HM":"AUD","HN":"HNL","HK":"HKD","HU":"HUF","IS":"ISK","IN":"INR","ID":"IDR","IR":"IRR","IQ":"IQD","IL":"ILS","CI":"XOF","JM":"JMD","JP":"JPY","JO":"JOD","KZ":"KZT","KE":"KES","KI":"AUD","KW":"KWD","KG":"KGS","LA":"LAK","LB":"LBP","LS":"LSL","LR":"LRD","LY":"LYD","LI":"CHF","MK":"MKD","MW":"MWK","MY":"MYR","MV":"MVR","ML":"XOF","MH":"USD","MU":"MUR","MX":"MXN","FM":"USD","MD":"MDL","MN":"MNT","MS":"XCD","MA":"MAD","MZ":"MZN","NA":"NAD","NR":"AUD","NP":"NPR","AN":"ANG","NC":"XPF","NZ":"NZD","NI":"NIO","NE":"XOF","NG":"NGN","NU":"NZD","NF":"AUD","KP":"KPW","GB":"GBP","MP":"USD","NO":"NOK","OM":"OMR","PK":"PKR","PW":"USD","PA":"PAB","PG":"PGK","PY":"PYG","PE":"PEN","PH":"PHP","PL":"PLN","PR":"USD","QA":"QAR","RO":"RON","RU":"RUB","RW":"RWF","SH":"SHP","KN":"XCD","LC":"XCD","VC":"XCD","WS":"WST","ST":"STD","SA":"SAR","SN":"XOF","RS":"RSD","SC":"SCR","SL":"SLL","SG":"SGD","SB":"SBD","SO":"SOS","ZA":"ZAR","GS":"GBP","KR":"KRW","SS":"SSP","LK":"LKR","SD":"SDG","SR":"SRD","SJ":"NOK","SZ":"SZL","SE":"SEK","CH":"CHF","SY":"SYP","TJ":"TJS","TZ":"TZS","TH":"THB","CD":"CDF","TG":"XOF","TK":"NZD","TO":"TOP","TT":"TTD","TN":"TND","TR":"TRY","TM":"TMT","TC":"USD","TV":"AUD","UG":"UGX","UA":"UAH","AE":"AED","UK":"GBP","US":"USD","UM":"USD","UY":"UYU","UZ":"UZS","VU":"VUV","VN":"VND","VG":"USD","VI":"USD","WF":"XPF","EH":"MAD","YE":"YER","ZM":"ZMW"};const selectedCurrencyCodes=new Set((navigator.languages||[]).map(l=>countryCodeToCurrencyCode[l.substring(3)]).filter(Boolean).concat(defaultCurrencyCodes));function eurToCurrency(eurValue,currencyCode){const usdValue=eurValue/exchangeRates['EUR'];const value=usdValue*exchangeRates[currencyCode];const showCents=value<100;return Intl.NumberFormat('en-US',{style:'currency',currency:currencyCode,maximumFractionDigits:showCents?undefined:0}).format(value);}function getCurrencyTooltipText(elementText){const eurValue=parseInt(elementText.replaceAll(/[^0-9\.]/g,'')||NaN,10);if(!exchangeRates||isNaN(eurValue)||eurValue===0){return'';}return Array.from(selectedCurrencyCodes).slice(0,3).map(code=>eurToCurrency(eurValue,code)).join('\n')}window.addEventListener("DOMContentLoaded",function(){fetch('/api/exchangerates.json').then(response=>{if(!response.ok){throw new Error('Cannot retrieve exchange rates.');}return response.json()}).then(data=>{const dataAgeInHours=((new Date(data.timestamp*1000)).getTime()-Date.now())/1000/60/60;if(dataAgeInHours<24){exchangeRates=data.rates;document.querySelectorAll('.currency').forEach(element=>{const tooltipText=getCurrencyTooltipText(element.textContent);if(tooltipText){element.dataset.currencies=tooltipText;}});}});});Vue.component('eur',{props:{amount:Number,cents:Boolean,noSymbol:Boolean,},computed:{value(){return formatCurrency(this.amount,this.cents,false,false);},tooltipText(){return(this.value==='0'?null:getCurrencyTooltipText(this.value));},},template:`{{ value }}{{ value }}€{{ value }}€`,});Vue.component('glossary',{data(){return{showTooltip};},props:{term:String,},methods:{getUrl(){return`/glossary/${encodeURIComponent(this.term || this.$slots.default[0].text )}`;}},template:``,});Vue.component('income-input',{props:['value'],methods:{parsedValue(val){let parsed=parseFloat(val);return isNaN(parsed)?val:parsed;}},template:``,});document.querySelectorAll('collapsible.pension-refund-calculator').forEach(el=>new Vue({el:el,mixins:[uniqueIdsMixin,trackedStagesMixin],data(){return{trackAs:'Pension refund calculator',stage:'start',isLoading:false,nationality:getDefault('nationality',''),sortedCountryList:countries.getSortedList(),countryOfResidence:getDefault('countryOfResidence',''),yearlyIncome:getDefaultNumber('yearlyIncome'),firstMonthOfWork:'',firstYearOfWork:'',lastMonthOfWork:'',lastYearOfWork:'',germanState:getDefault('state'),fullName:'',emailAddress:'',dateOfBirth:'',showRefundRequestForm:false,yearOptions:Array.from({length:((new Date()).getFullYear()+2-2000)+1},(_,i)=>2000+i),monthOptions:[{number:'01',name:'January'},{number:'02',name:'February'},{number:'03',name:'March'},{number:'04',name:'April'},{number:'05',name:'May'},{number:'06',name:'June'},{number:'07',name:'July'},{number:'08',name:'August'},{number:'09',name:'September'},{number:'10',name:'October'},{number:'11',name:'November'},{number:'12',name:'December'},],germanStates,partners:[{name:'FundsBack',description:"9.405% fee. Minimum 899€, maximum 2,899€. No refund, no fee.",fee:x=>Math.min(Math.max(x*0.09405,899),2899),apiEndpoint:'/api/forms/pension-refund-fundsback',},{name:'Germany Pension Refund',description:"9.75% fee. No refund, no fee.",fee:x=>x*0.0975,apiEndpoint:'/api/forms/pension-refund-germanypensionrefund',},{name:'Pension Refund Germany',description:"10% fee. Maximum 2,800€. No refund, no fee.",fee:x=>Math.min(x*0.1,2800),apiEndpoint:'/api/forms/pension-refund-pensionrefundgermany',},{name:'Do it yourself',description:'Apply without help. No fee.',fee:x=>0,apiEndpoint:'',},],selectedPartner:null,};},mounted(){this.selectedPartner=this.sortedPartners[0];},methods:{hasFlag(flag){return this.results.flags.has(flag);},stateName,async setReminder(){if(validateForm(this.$refs.reminderForm)){this.isLoading=true;const response=await fetch('/api/reminders/pension',{method:'POST',keepalive:true,headers:{'Content-Type':'application/json; charset=utf-8',},body:JSON.stringify({email:this.emailAddress,refundAmount:this.results.refundAmount,eligibilityDate:this.eligibilityDateString,deliveryDate:this.eligibilityDate.toISOString(),}),});this.isLoading=false;this.stage=response.ok?'reminderConfirmation':'error';}},async sendRefundRequest(){if(validateForm(this.$refs.contactForm)){this.isLoading=true;const response=await fetch(this.selectedPartner.apiEndpoint,{method:'POST',keepalive:true,headers:{'Content-Type':'application/json; charset=utf-8',},body:JSON.stringify({arrivalDate:`${this.firstYearOfWork}-${this.firstMonthOfWork}`,countryOfResidence:countries.all[this.countryOfResidence],dateOfBirth:this.dateOfBirth,departureDate:`${this.lastYearOfWork}-${this.lastMonthOfWork}`,email:this.emailAddress,name:this.fullName,nationality:countries.all[this.nationality],}),},);this.isLoading=false;if(response.ok){plausible('Pension refund request',{props:{partner:this.selectedPartner.name}});this.stage='requestConfirmation';}else{this.stage='error';}}}},computed:{firstDayOfWork(){if(this.firstMonthOfWork&&this.firstYearOfWork){return new Date(`${this.firstYearOfWork}-${this.firstMonthOfWork}-01T00:00:00`);}return null;},lastDayOfWork(){if(this.lastMonthOfWork&&this.lastYearOfWork){const lastDayOfWork=new Date(`${this.lastYearOfWork}-${this.lastMonthOfWork}-01T00:00:00`);lastDayOfWork.setMonth(lastDayOfWork.getMonth()+1);lastDayOfWork.setDate(0);return lastDayOfWork;}return null;},results(){const isInEastGermany=this.germanStates[this.germanState].isInEastGermany;setDefaultNumber('yearlyIncome',this.yearlyIncome);setDefault('state',this.germanState);setDefault('nationality',this.nationality);setDefault('countryOfResidence',this.countryOfResidence);return calculatePensionRefund(this.nationality,this.countryOfResidence,this.firstDayOfWork,this.lastDayOfWork,this.yearlyIncome,isInEastGermany);},isCountriesSelected(){return!!(this.nationality&&this.countryOfResidence);},isCountryOfResidenceEligible(){return(this.results&&!this.hasFlag('eu-resident')&&!this.hasFlag('disqualifying-country-resident')&&!(this.hasFlag('israel-national')&&this.hasFlag('israel-resident')));},isNationalityEligible(){return(this.results&&!this.hasFlag('eu-national')&&!this.hasFlag('eea-national'));},isCountriesEligible(){return this.results&&this.isCountryOfResidenceEligible&&this.isNationalityEligible},isDateRangeSelected(){return this.firstDayOfWork&&this.lastDayOfWork;},isDateRangeEligible(){return this.isDateRangeSelected&&this.lastDayOfWork>=this.firstDayOfWork&&this.results&&!this.hasFlag('not-eligible');},eligibilityDate(){if(this.isDateRangeEligible){const twoYearsAfterDeparture=new Date(this.lastDayOfWork.getTime());twoYearsAfterDeparture.setMonth(this.lastDayOfWork.getMonth()+24+1);return twoYearsAfterDeparture;}},eligibilityDateString(){const monthName=this.monthOptions.find(m=>m.number==(this.eligibilityDate.getMonth()+1).toString().padStart(2,'0')).name;return`${monthName} ${this.eligibilityDate.getFullYear()}`;},monthsUntilEligible(){if(this.isDateRangeEligible){const months=Math.floor((this.eligibilityDate.getTime()-(new Date()).getTime())/(2e3*3600*365.25))if(months===0){return'a few days';}else if(months===1){return'1 month';}else{return`${months} months`;}}},showStatePicker(){if(!(this.results&&this.results.refundAmount)){return false;}const args=[this.nationality,this.countryOfResidence,this.firstDayOfWork,this.lastDayOfWork,this.yearlyIncome];const eastGermanResults=calculatePensionRefund(...args,true).refundAmount;const westGermanResults=calculatePensionRefund(...args,false).refundAmount;return eastGermanResults!=westGermanResults;},sortedPartners(){return this.partners.sort((a,b)=>{if(b.name==='Do it yourself')return-1;return a.fee(this.results.refundAmount)-b.fee(this.results.refundAmount);});},}}));!function(t,e){"function"==typeof define&&define.amd?define("jquery-bridget/jquery-bridget",["jquery"],function(i){return e(t,i)}):"object"==typeof module&&module.exports?module.exports=e(t,require("jquery")):t.jQueryBridget=e(t,t.jQuery)}(window,function(t,e){"use strict";function i(i,r,a){function h(t,e,n){var o,r="$()."+i+'("'+e+'")';return t.each(function(t,h){var u=a.data(h,i);if(!u)return void s(i+" not initialized. Cannot call methods, i.e. "+r);var d=u[e];if(!d||"_"==e.charAt(0))return void s(r+" is not a valid method");var l=d.apply(u,n);o=void 0===o?l:o}),void 0!==o?o:t}function u(t,e){t.each(function(t,n){var o=a.data(n,i);o?(o.option(e),o._init()):(o=new r(n,e),a.data(n,i,o))})}a=a||e||t.jQuery,a&&(r.prototype.option||(r.prototype.option=function(t){a.isPlainObject(t)&&(this.options=a.extend(!0,this.options,t))}),a.fn[i]=function(t){if("string"==typeof t){var e=o.call(arguments,1);return h(this,t,e)}return u(this,t),this},n(a))}function n(t){!t||t&&t.bridget||(t.bridget=i)}var o=Array.prototype.slice,r=t.console,s="undefined"==typeof r?function(){}:function(t){r.error(t)};return n(e||t.jQuery),i}),function(t,e){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",e):"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}("undefined"!=typeof window?window:this,function(){function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var i=this._events=this._events||{},n=i[t]=i[t]||[];return-1==n.indexOf(e)&&n.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var i=this._onceEvents=this._onceEvents||{},n=i[t]=i[t]||{};return n[e]=!0,this}},e.off=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=i.indexOf(e);return-1!=n&&i.splice(n,1),this}},e.emitEvent=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){i=i.slice(0),e=e||[];for(var n=this._onceEvents&&this._onceEvents[t],o=0;oe;e++){var i=h[e];t[i]=0}return t}function n(t){var e=getComputedStyle(t);return e||a("Style returned "+e+". Are you running this code in a hidden iframe on Firefox? See https://bit.ly/getsizebug1"),e}function o(){if(!d){d=!0;var e=document.createElement("div");e.style.width="200px",e.style.padding="1px 2px 3px 4px",e.style.borderStyle="solid",e.style.borderWidth="1px 2px 3px 4px",e.style.boxSizing="border-box";var i=document.body||document.documentElement;i.appendChild(e);var o=n(e);s=200==Math.round(t(o.width)),r.isBoxSizeOuter=s,i.removeChild(e)}}function r(e){if(o(),"string"==typeof e&&(e=document.querySelector(e)),e&&"object"==typeof e&&e.nodeType){var r=n(e);if("none"==r.display)return i();var a={};a.width=e.offsetWidth,a.height=e.offsetHeight;for(var d=a.isBorderBox="border-box"==r.boxSizing,l=0;u>l;l++){var c=h[l],f=r[c],m=parseFloat(f);a[c]=isNaN(m)?0:m}var p=a.paddingLeft+a.paddingRight,g=a.paddingTop+a.paddingBottom,y=a.marginLeft+a.marginRight,v=a.marginTop+a.marginBottom,_=a.borderLeftWidth+a.borderRightWidth,z=a.borderTopWidth+a.borderBottomWidth,E=d&&s,b=t(r.width);b!==!1&&(a.width=b+(E?0:p+_));var x=t(r.height);return x!==!1&&(a.height=x+(E?0:g+z)),a.innerWidth=a.width-(p+_),a.innerHeight=a.height-(g+z),a.outerWidth=a.width+y,a.outerHeight=a.height+v,a}}var s,a="undefined"==typeof console?e:function(t){console.error(t)},h=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],u=h.length,d=!1;return r}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("desandro-matches-selector/matches-selector",e):"object"==typeof module&&module.exports?module.exports=e():t.matchesSelector=e()}(window,function(){"use strict";var t=function(){var t=window.Element.prototype;if(t.matches)return"matches";if(t.matchesSelector)return"matchesSelector";for(var e=["webkit","moz","ms","o"],i=0;is?"round":"floor";r=Math[a](r),this.cols=Math.max(r,1)},n.getContainerWidth=function(){var t=this._getOption("fitWidth"),i=t?this.element.parentNode:this.element,n=e(i);this.containerWidth=n&&n.innerWidth},n._getItemLayoutPosition=function(t){t.getSize();var e=t.size.outerWidth%this.columnWidth,i=e&&1>e?"round":"ceil",n=Math[i](t.size.outerWidth/this.columnWidth);n=Math.min(n,this.cols);for(var o=this.options.horizontalOrder?"_getHorizontalColPosition":"_getTopColPosition",r=this[o](n,t),s={x:this.columnWidth*r.col,y:r.y},a=r.y+t.size.outerHeight,h=n+r.col,u=r.col;h>u;u++)this.colYs[u]=a;return s},n._getTopColPosition=function(t){var e=this._getTopColGroup(t),i=Math.min.apply(Math,e);return{col:e.indexOf(i),y:i}},n._getTopColGroup=function(t){if(2>t)return this.colYs;for(var e=[],i=this.cols+1-t,n=0;i>n;n++)e[n]=this._getColGroupY(n,t);return e},n._getColGroupY=function(t,e){if(2>e)return this.colYs[t];var i=this.colYs.slice(t,t+e);return Math.max.apply(Math,i)},n._getHorizontalColPosition=function(t,e){var i=this.horizontalColIndex%this.cols,n=t>1&&i+t>this.cols;i=n?0:i;var o=e.size.outerWidth&&e.size.outerHeight;return this.horizontalColIndex=o?i+t:this.horizontalColIndex,{col:i,y:this._getColGroupY(i,t)}},n._manageStamp=function(t){var i=e(t),n=this._getElementOffset(t),o=this._getOption("originLeft"),r=o?n.left:n.right,s=r+i.outerWidth,a=Math.floor(r/this.columnWidth);a=Math.max(0,a);var h=Math.floor(s/this.columnWidth);h-=s%this.columnWidth?0:1,h=Math.min(this.cols-1,h);for(var u=this._getOption("originTop"),d=(u?n.top:n.bottom)+i.outerHeight,l=a;h>=l;l++)this.colYs[l]=Math.max(d,this.colYs[l])},n._getContainerSize=function(){this.maxY=Math.max.apply(Math,this.colYs);var t={height:this.maxY};return this._getOption("fitWidth")&&(t.width=this._getContainerFitWidth()),t},n._getContainerFitWidth=function(){for(var t=0,e=this.cols;--e&&0===this.colYs[e];)t++;return(this.cols-t)*this.columnWidth-this.gutter},n.needsResizeLayout=function(){var t=this.containerWidth;return this.getContainerWidth(),t!=this.containerWidth},i});new Masonry(document.querySelector('.collections'),{itemSelector:'.collection',percentPosition:true,gutter:34,transitionDuration:0,});window.addEventListener("DOMContentLoaded",function(){const main=document.querySelector('main');const articleBody=main.querySelector('.article-body');const bodyTableOfContents=articleBody&&articleBody.querySelector('.table-of-contents');const sidebarTableOfContents=document.querySelector('.sidebar .table-of-contents');const sidebarLinks=Array.from(document.querySelectorAll('.sidebar .table-of-contents li a:not(.expand)'));sidebarLinks.forEach((link,index)=>{link.addEventListener('click',(e)=>{sidebarTableOfContents.classList.add('collapsed');});});const sectionHeaders=document.querySelectorAll('.article-body h2, .article-body h3');const headerMap=sidebarLinks.reduce((map,link)=>{if(link.hash){map[link.hash]=document.querySelector(link.hash);}return map;},{});function onScroll(){const mainSectionIsInFocus=main.getBoundingClientRect().top<=0;let highlightedLink=null;if(mainSectionIsInFocus){highlightedLink=(sidebarLinks.find(link=>{const header=headerMap[link.hash];if(!header){return false}const headerBoundingRect=header.getBoundingClientRect();const headerIsInView=headerBoundingRect.bottom>0&&headerBoundingRect.top{const header=headerMap[link.hash];if(!header){return false}const hasScrolledPastHeader=header.getBoundingClientRect().bottom<0;return hasScrolledPastHeader;}).sort((linkA,linkB)=>{return linkB.getBoundingClientRect().top-linkA.getBoundingClientRect().top})[0]);}if(highlightedLink){sidebarLinks.forEach(l=>l.parentElement.classList.toggle('current',l===highlightedLink));const parentSection=highlightedLink.parentElement.parentElement.parentElement;if(parentSection&&!parentSection.classList.contains('expanded')){parentSection.classList.add('current');}}const tableOfContentsIsInView=(bodyTableOfContents&&bodyTableOfContents.getBoundingClientRect().bottom<=0);if(sidebarTableOfContents){sidebarTableOfContents.classList.toggle('visible',tableOfContentsIsInView);}};onScroll();window.addEventListener("scroll",function(e){window.requestAnimationFrame(onScroll);});});const plausibleFallback=function(){(window.plausible.q=window.plausible.q||[]).push(arguments)};window.plausible=window.plausible||plausibleFallback;function getLinkEl(l){while(l&&(typeof l.tagName==='undefined'||l.tagName.toLowerCase()!=='a'||!l.href)){l=l.parentNode}return l;}function openLinkAfterTracking(e,link){if(e.defaultPrevented){return false}const targetsCurrentWindow=!link.target||link.target.match(/^_(self|parent|top)$/i);const isRegularClick=!(e.ctrlKey||e.metaKey||e.shiftKey)&&e.type==='click';return targetsCurrentWindow&&isRegularClick;}function shouldTrackUrl(url){return(url.startsWith('/out/')||url.startsWith('https://allaboutberlin.com/out/')||url.startsWith('https://allaboutberlin.com/donate')||url.startsWith('mailto:')||(url.startsWith('http')&&!url.startsWith('https://allaboutberlin.com'||'/')));}const middleMouse=1;function handleLinkClick(e){if(e.type==='auxclick'&&e.button!==middleMouse){return}const link=getLinkEl(e.target);if(link&&shouldTrackUrl(link.href)){return sendLinkClickEvent(e,link,'Outbound Link: Click',{url:link.href});}}function sendLinkClickEvent(event,link,eventName,eventProps){let followedLink=false;function followLink(){if(!followedLink){followedLink=true;window.location=link.href;}}if(openLinkAfterTracking(event,link)){plausible(eventName,{props:eventProps,callback:followLink});setTimeout(followLink,window.plausible===plausibleFallback?0:1500);event.preventDefault();}else{plausible(eventName,{props:eventProps});}}document.addEventListener('click',handleLinkClick);document.addEventListener('auxclick',handleLinkClick);function validateForm(formElement){let formIsValid=true;const honeypotField=formElement.querySelector('input[name="username"]');formElement.querySelectorAll('input, textarea, select').forEach(function(input){if(input!==honeypotField&&!input.checkValidity()){formIsValid=false;}});if(honeypotField&&honeypotField.value){formIsValid=false;}formElement.classList.toggle('show-errors',!formIsValid);return formIsValid;}window.addEventListener("DOMContentLoaded",function(){document.querySelectorAll('input, textarea').forEach((input)=>{input.placeholder=input.placeholder||' ';});document.querySelectorAll('.post-reviewers a').forEach(link=>{link.addEventListener('click',(e)=>{e.preventDefault();link.classList.toggle('expanded');document.getElementById('reviewers').classList.toggle('hidden');});});document.querySelectorAll('li.checkbox').forEach(checklistItem=>{checklistItem.addEventListener('click',(e)=>{if(e.target.tagName!=='A'&&e.target.tagName!=='INPUT'&&(e.target.parentElement&&e.target.parentElement.tagName)!=='A'){const checkbox=checklistItem.querySelector('[type=checkbox]');checkbox.checked=!checkbox.checked;e.stopPropagation();}});});document.querySelectorAll('.footnote-ref').forEach(link=>{link.addEventListener('click',e=>{document.getElementById('footnotes').setAttribute("open","true");});});document.querySelectorAll(".table-of-contents .expand").forEach(expandButton=>{expandButton.addEventListener('click',e=>{e.preventDefault();expandButton.parentNode.classList.toggle('expanded');})});});const tooltip=document.getElementById('tooltip');let pronounciationAudio=null;function showTooltip(clickEvent){const tooltipBody=tooltip.querySelector('.article-body');tooltip.querySelector('h2 a dfn').innerHTML='Loading...';tooltip.querySelector('h2 a small').innerHTML='...';tooltipBody.innerHTML='...
';const anchor=clickEvent.currentTarget||clickEvent.target;if(!tooltip.open){tooltip.showModal();}fetch(anchor.getAttribute('href')+'.json').then(r=>r.json()).then(data=>{tooltip.querySelector('h2 a').setAttribute('href',anchor.getAttribute('href'));tooltip.querySelector('h2 a dfn').innerHTML=data.title;tooltip.querySelector('h2 a small').innerHTML=data.englishTerm||'';tooltip.querySelector('h2 a small').classList.toggle('hidden',(!data.englishTerm||data.englishTerm==data.germanTerm));tooltipBody.innerHTML=data.definition;tooltipBody.querySelectorAll('a').forEach(a=>a.target='_blank');pronounciationAudio=new Audio(data.audioUrl);tooltip.querySelector('.pronounce-button').href=data.audioUrl;const footnotes=tooltipBody.querySelector('#footnotes');if(footnotes){footnotes.remove();}setTooltipLinks(tooltipBody);plausible('Glossary tooltip',{props:{url:anchor.getAttribute('href')}});});}function hideTooltip(event){event.preventDefault();tooltip.close();if(pronounciationAudio){pronounciationAudio.pause();}}function setTooltipLinks(element){element.querySelectorAll('a[href*="/glossary/"]').forEach((anchor)=>{if(typeof tooltip.show==='function'){anchor.addEventListener('click',(event)=>{event.preventDefault();event.stopPropagation();showTooltip(event);});}else{anchor.setAttribute('target','_blank');}});}function pronounceTerm(event){event.preventDefault();pronounciationAudio.play();}window.addEventListener("DOMContentLoaded",function(){tooltip.querySelector('.close-button').addEventListener('click',hideTooltip);tooltip.addEventListener('click',clickEvent=>{if(clickEvent.target===tooltip){tooltip.close();}});const article=document.querySelector('main .article-body');if(article){setTooltipLinks(article);}tooltip.querySelector('.pronounce-button').addEventListener('click',pronounceTerm);});