// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r,t){var a=Scanner.fromMessage(e);a.setLocale(r);var i,n,p,o,m,s,u,l,d,g,h,c,v,C,N,b,f,y,S,$=[],T=[];if(i=a.getSpan().innerCapture(t.name,1).trim(),N=a.getSpan().innerCapture(regExpFormatted(/\1\s+(.*)/,t.reservationId),1),not(i))return CONTINUE;T[""+i]={name:i,seats:{},seatingType:{},ticketNumber:h,totalPrice:c,priceCurrency:v},b=a.getSpan().allInnerCapture(t.arrival,1);for(var A=0;A<b.length;A++)1===b.length&&(S=/(\w{3})\s(\w{3})$/.exec(e.subject),u=S[1],g=S[2]),y=b[A].withStart(b[A].previous(t.contentRegex).getEnd()).withEnd(b[A].previous(/.*/).next(t.flightSectionEnd).getEnd()),f=y.innerCapture(t.flightInfo),m=a.getDetachedSpan(""+f.$departureDate+" "+f.$departureHour+":"+f.$departureMinute).innerDate(),f.$arrivalDate.exists()||(f.$arrivalDate=f.$departureDate),l=a.getDetachedSpan(""+f.$arrivalDate+" "+f.$arrivalHour+":"+f.$arrivalMinute).innerDate(),o=f.$airlineCode,n=f.$flightNumber,s=f.$departureAirport,d=f.$arrivalAirport,p=a.getSpan().innerCapture(regExpFormatted(/\1\s+(.*)/,t.price),1),c=p.innerCapture(/([\d,.]+)/,1),v=p.innerCapture(/([^\d,.]+)/,1).trim(),ASSERT(o,n,s,m,d,l)&&$.push({reservationId:N,airlineCode:o,flightNumber:n,departureAirport:s,departureCode:u,departureTime:m,arrivalAirport:d,arrivalCode:g,arrivalTime:l,passengers:T});var D=[];for(A=0;A<$.length;A++)for(var E=$[A],F=Object.keys(E.passengers),k=0;k<F.length;k++){var x=E.passengers[F[k]],I={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:E.airlineName,airlineCode:E.airlineCode,flightNumber:E.flightNumber,departureAirportFuzzy:E.departureAirport,departureAirportCode:E.departureCode,departureTime:E.departureTime,arrivalAirportFuzzy:E.arrivalAirport,arrivalAirportCode:E.arrivalCode,arrivalTime:E.arrivalTime},underName:{"@type":"http://schema.org/Person",name:x.name},checkinUrl:C,reservationId:E.reservationId,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:c,priceCurrency:v,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:h,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:x.seats[E.flightNumber],seatingType:x.seatingType[E.flightNumber]}}};valid(x.membershipNumber,x.programName)&&(I.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:x.membershipNumber,programName:x.programName}),D.push(I)}return D.length?D:void 0}}).call();