// 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,m,o,s,l,g,u,d,h,c,v=[],N={};l=a.getSpan(),n=l.next(t.confirmation).innerCapture(t.confirmation,1);m=l.next(t.reservationName).innerCapture(t.reservationName,1);var b=a.getSpan().next(t.totalPrice).parentAnyTag("td").nextAnyTag("td").nextAnyTag("td").nextAnyTag("td").tagContents(),y=b.innerCapture(/([\d,.]+)/,1),T=b.innerCapture(/([^\d,.]+)/,1).trim();N[""+m]={name:m,seats:{},seatingType:{},ticketNumber:null,totalPrice:null,priceCurrency:null};for(var f=l.allInnerCapture(t.legs),C=0;C<f.length;C++)o=f[C],u=combineDateAndTime(a.getDetachedSpan(""+o.$date).innerDate(),a.getDetachedSpan(""+o.$departure).innerDate()),h=combineDateAndTime(a.getDetachedSpan(""+o.$date).innerDate(),a.getDetachedSpan(""+o.$arrival).innerDate()),d=o.$from,c=o.$to,s=o.$flight,[,g,s]=s.innerCapture(/([0-9A-Z]{2})(\d{3,4})/),ASSERT(g,s,d,u,c,h)&&v.push({reservationId:n,airlineName:null,airlineCode:g,flightNumber:s,departureAirport:d,departureTime:u,arrivalAirport:c,arrivalTime:h,passengers:N});var A=[];for(C=0;C<v.length;C++)for(var S=v[C],D=Object.keys(S.passengers),k=0;k<D.length;k++){var x=S.passengers[D[k]],$={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:S.airlineName,airlineCode:S.airlineCode,flightNumber:S.flightNumber,departureAirportFuzzy:S.departureAirport,departureAirportCode:S.departureCode,departureTime:S.departureTime,arrivalAirportFuzzy:S.arrivalAirport,arrivalAirportCode:S.arrivalCode,arrivalTime:S.arrivalTime},underName:{"@type":"http://schema.org/Person",name:x.name},checkinUrl:p,reservationId:S.reservationId,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:y,priceCurrency:T,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:i,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:x.seats[S.flightNumber],seatingType:x.seatingType[S.flightNumber]}}};valid(x.membershipNumber,x.programName)&&($.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:x.membershipNumber,programName:x.programName}),A.push($)}if(A.length)return A}}).call();