// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r,t){function a(e){if(e){s=i.getSpan().nextRegExp(regExpFormatted(/\1/,e)).parentAnyTag("td");var t=s.getTagNumber()-2;"it_IT"===r&&(t-=1),s=s.parentTag("table"+t).allInnerTags("tr"+t),4===s.length&&(l=s[2].allInnerTagsFiltered("td"+t),5===l.length&&(u=l[0].innerCapture(/^($<departureAirport>.*?) - ($<arrivalAirport>.*?)$/),v=u?u.$departureAirport:null,b=u?u.$arrivalAirport:null,m=l[1].innerDate(),m.exists()||(m=i.getDetachedSpan((""+l[1].tagContents()).replace(/(\d+)([A-Za-z]+)(\d+)/,"$1 $2 $3"))),d=l[2].innerCapture(/($<code>[A-Z]+)($<flightNumber>\d+)/),h=d?d.$code:null,g=d?d.$flightNumber:null,c=combineDateAndTime(m,l[3].innerDate()),T=combineDateAndTime(m,l[4].innerDate()),ASSERT(h,g,c,T)&&N.push({airlineCode:h,flightNumber:g,departureAirport:v,departureTime:c,arrivalAirport:b,arrivalTime:T,passengers:A})))}}if(!regExpFormatted(/\1/,t.reservationId).test(e.plain))return CONTINUE;var i=Scanner.fromMessage(e);i.setLocale(r);var n,p,o,m,l,s,g,u,d,h,c,v,T,b,N=[],A={};p=i.getSpan().nextText(t.reservationId).nextTag("td9").tagContents(),A[e.to]={name:e.to,seats:{},seatingType:{}},a(t.goingOut),a(t.comingBack);for(var f=[],y=0;y<N.length;y++)for(var C=N[y],$=Object.keys(C.passengers),x=0;x<$.length;x++){var F=C.passengers[$[x]],S={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:C.airlineName,airlineCode:C.airlineCode,flightNumber:C.flightNumber,departureAirportFuzzy:C.departureAirport,departureAirportCode:C.departureCode,departureTime:C.departureTime,arrivalAirportFuzzy:C.arrivalAirport,arrivalAirportCode:C.arrivalCode,arrivalTime:C.arrivalTime},underName:{"@type":"http://schema.org/Person",name:F.name},checkinUrl:o,reservationId:p,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:F.totalPrice,priceCurrency:F.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:n,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:F.seats[""+C.airlineCode+(""+C.flightNumber)],seatingType:F.seatingType[C.flightNumber]}}};valid(F.membershipNumber,F.programName)&&(S.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:F.membershipNumber,programName:F.programName}),f.push(S)}return f.length?f:void 0}}).call();