// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r,t){if(!e||!r||!t)return CONTINUE;var a=Scanner.fromMessage(e);a.setLocale(r);var i,n,p,s,g,o,m,l,u,h,c,d,v=[],T={};if(i=a.getSpan().nextText(t.flightItinerary).nextTag("table4").lastInnerTag("td4").tagContents().innerCapture(regExpFormatted(/\1 (.*)/,t.reservationIdPrefix),1),s=i.nextText(t.passengers).nextTag("td4").tagContents(),o=s.nextTag("table4").withEnd(a.getSpan().nextRegExp(t.pageTitleRegExp).previousTag("table4").getEnd()).allInnerTags("table4"),!o.length)return CONTINUE;n=a.getSpan().nextRegExp(t.checkinRegExp).nextLink();for(var x,b=0;x=o[b++];)if(l=x.allInnerTagsFiltered("td4"),8==l.length){g=l[6].innerCapture(RegExp(regExpEscape(t.seats)+" (.*)"),1),g=g?g.split(",").map(function(e){return e.trim()}):[],p=s?s.split("\n").map(function(e){return e.trim()}):[];for(var T,C=0;C<p.length;C++)T={},T[""+p[C]]={name:p[C],seat:g[C],seatingType:l[5].innerCapture(RegExp(regExpEscape(t.seatingType)+"\\s+(.*)"),1).trim()},m=l[0].innerCapture(RegExp(regExpEscape(t.flightNumber)+" (.*)"),1),u=l[1].innerDate(),h=l[2].tagContents(),c=l[3].innerDate(),d=l[4].tagContents(),ASSERT(m,u,h,c,d)&&v.push({airlineName:"American Airlines",airlineCode:"AA",flightNumber:m,departureTime:u,departureAirport:h,arrivalTime:c,arrivalAirport:d,passengers:T})}for(var N=[],b=0;b<v.length;b++)for(var f=v[b],E=Object.keys(f.passengers),y=0;y<E.length;y++){var A=f.passengers[E[y]],F={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:f.airlineName,airlineCode:f.airlineCode,flightNumber:f.flightNumber,departureAirportFuzzy:f.departureAirport,departureAirportCode:f.departureCode,departureTime:f.departureTime,arrivalAirportFuzzy:f.arrivalAirport,arrivalAirportCode:f.arrivalCode,arrivalTime:f.arrivalTime},underName:{"@type":"http://schema.org/Person",name:A.name},checkinUrl:n,reservationId:i,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:A.totalPrice,priceCurrency:A.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:A.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatingType:A.seatingType,seatNumber:A.seat}}};valid(A.membershipNumber)&&(F.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:A.membershipNumber,programName:A.programName||"Frequent Flyer"}),N.push(F)}return N.length?N:void 0}}).call();