// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,r){var a=Scanner.fromMessage(e);a.setLocale(t);var n,i,g,p,s,l,o,m,u,d,h,c,f,T,b,v,x=[],C={},y=loadHelper("united.com-common.js");n=a.getSpan().nextText(r.confirmationNumber).nextTag("td4").nextTag("td4").tagContents(),m=a.getSpan().nextText(r.seatAssignments).parentTag("td3"),p=m.allInnerCapture(regExpFormatted(/\1/,r.dateOfBirth)).filter(function(e){return e.length>0});for(var F={},N=0;N<p.length;N++)g=a.getSpan().innerCapture(regExpFormatted(/\]\s+(.*)\s+\1/,""+p[N][0].parentTag("table4")),1),m=g.nextTag("table4").withEnd(g.nextTag("table4").nextTag("table4").getEnd()),F[""+g]=m;if(a.getSpan().nextText(r.travelerInfo).exists()){p=a.getSpan().nextText(r.travelerInfo).parentTag("td4").allInnerTags("table5");for(var N=0;N<p.length;N++)g=p[N].nextTag("td5").tagContents(),C[g]={name:g,seats:{},seatingType:{}},C[g].seatMap=y.getSeatMap(p[N].nextText(r.seatAssignments).nextTag("td5").tagContents())}else{p=Object.keys(F);for(var N=0;N<p.length;N++){g=p[N],C[g]={name:g,seats:{},seatingType:{}},m=F[g].allInnerTags("table5");for(var S,E,A=0;A<m.length;A++)S=m[A].innerTag("th5").tagContents(),E=m[A].innerTag("td5").tagContents(),S.innerCapture(regExpFormatted(/^\1/,r.knownTravelerNumber))?C[g].ticketNumber=E:S.innerCapture(regExpFormatted(/^\1/,r.frequentFlyer))?(C[g].programName=r.frequentFlyer,C[g].membershipNumber=E):S.innerCapture(regExpFormatted(/^\1/,r.seatAssignments))&&(C[g].seatMap=y.getSeatMap(E))}}l=a.getSpan().nextText(r.flightDetails).nextTag("table4").allInnerTags("table5").map(function(e){return e.allInnerTagsFiltered("td5")}).filter(function(e){return e.length>0});for(var k=0;k<l.length;k++){s=l[k];for(var z=0;z<s.length;z++)if(m=s[z],m.innerCapture(regExpFormatted(/^\1/,r.depart)))c=getFuzzyDate(a.getDetachedSpan((""+m).replace(/([.,]*)/g,""))),f=m.innerCapture(/\(([A-Z]{3})/,1);else if(m.innerCapture(regExpFormatted(/^\1/,r.arrive)))T=getFuzzyDate(a.getDetachedSpan((""+m).replace(/([.,]*)/g,""))),b=m.innerCapture(/\(([A-Z]{3})/,1);else if(m.innerCapture(regExpFormatted(/^\1/,r.flight))){if(u=m.innerCapture(regExpFormatted(/^\1\s*($<code>\w{2})($<flightNumber>\d+)/,r.flight)),d=u?u.$code:null,o=u?u.$flightNumber:null,v=m.innerCapture(regExpFormatted(/\1\s*(.*)\s+/,r.fareClass),1),valid(o)){p=Object.keys(C);for(var N=0;N<p.length;N++)if(valid(v)&&(C[p[N]].seatingType[""+o]=v.trim()),valid(f,b)){var I=""+f+" - "+b;C[p[N]].seats[""+o]=C[p[N]].seatMap[I]}}ASSERT(c,f,T,b,d,o)&&x.push({airlineCode:d,flightNumber:o,departureTime:c,departureCode:f,arrivalTime:T,arrivalCode:b,passengers:C}),c=f=T=b=u=d=o=v=null}}for(var M=[],k=0;k<x.length;k++)for(var D=x[k],j=Object.keys(D.passengers),O=0;O<j.length;O++){var $=D.passengers[j[O]];h={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineCode:D.airlineCode,flightNumber:D.flightNumber,departureAirportFuzzy:D.departureAirport,departureAirportCode:D.departureCode,departureTime:D.departureTime,arrivalAirportFuzzy:D.arrivalAirport,arrivalAirportCode:D.arrivalCode,arrivalTime:D.arrivalTime},underName:{"@type":"http://schema.org/Person",name:$.name},checkinUrl:i,reservationId:n,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:$.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:$.seats[D.flightNumber],seatingType:$.seatingType[D.flightNumber]}},totalPrice:$.price,priceCurrency:$.currency,reservationStatus:"http://schema.org/ReservationConfirmed"},$.membershipNumber&&(h.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:$.membershipNumber,programName:"Frequent Flyer"}),M.push(h)}if(M.length)return M}}).call();