// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,r){var a=Scanner.fromMessage(e);if(a.setLocale(t),a.getSpan().nextText(r.flightSummary).exists()){for(var n,i,o,p,m,s,g,l,d,u,C,c,h=[],T=[],v={},b=a.getSpan().next(r.names).parentAnyTag("table").allInnerTags("td6"),N=0;N<b.length;N++)n=b[N].tagContents().innerCapture(r.name,1),n&&0!==(""+n).length&&h.push(n);i=a.getSpan().nextText(r.price).nextText(r.totalPrice).parentAnyTag("td").tagContents().innerCapture(/([\d,.]+)/,1),o=a.getSpan().nextText(r.priceCurrency).parentAnyTag("td").tagContents().innerCapture(regExpFormatted(/\1\s(.*)$/,r.priceCurrency),1),p=a.getSpan().next(r.reservationId).parentAnyTag("td").tagContents().innerCapture(regExpFormatted(/\1\s*(.*)/,r.reservationId),1);var y=(""+a.getSpan().next(r.ticketNumber).parentAnyTag("td").tagContents()).match(/\d+/g);for(c=0;c<h.length;c++)y&&y[c]&&(l=y[c]),v[h[c].trim()]={name:h[c].trim(),programName:r.programName,membershipNumber:d,ticketNumber:l,totalPrice:i,priceCurrency:o,seats:{},seatingType:{}};g=a.getSpan().next(r.travelerInfo).parentAnyTag("table"),s=g.nextTag("td6").nextTag("td6").innerDate(),g=g.allInnerTags("td8");var A=6;for(u=0;u<g.length;u+=A)if(g[u+2]&&0!==(""+g[u+2].tagContents()).length){var f,x={},S=!1;g[u+2]&&(""+g[u+2].tagContents()).match(/Terminal/i)?(x.departureAirport=g[u+0].tagContents().trim()+" "+g[u+2].tagContents().trim(),x.departureTime=combineDateAndTime(s,g[u+1].tagContents().innerDate()),x.departureCode=g[u+0].tagContents().innerCapture(/([A-Z]{3})/,1),S=!1,g[u+6]&&(""+g[u+6].tagContents()).match(r.dateSpecified)&&(s=g[u+6].tagContents().innerDate(),S=!0),x.arrivalAirport=g[u+3].tagContents().trim()+" "+g[u+5].tagContents().trim(),x.arrivalTime=combineDateAndTime(s,g[u+4].tagContents().innerDate()),x.arrivalCode=g[u+3].tagContents().innerCapture(/([A-Z]{3})/,1),f=g[u].previousTag("td6").tagContents().innerCapture(/($<airline>.*?)\s($<code>\d+)/),x.airlineName=f.$airline,x.airlineCode=f.$airline,x.flightNumber=f.$code,x.passengers=v,S&&u++):(A=4,x.departureAirport=g[u+0].tagContents().trim(),x.departureTime=combineDateAndTime(s,g[u+1].tagContents().innerDate()),x.departureCode=g[u+0].tagContents().innerCapture(/([A-Z]{3})/,1),S=!1,g[u+5]&&(""+g[u+5].tagContents()).match(r.dateSpecified)&&(s=g[u+5].tagContents().innerDate(),S=!0),x.arrivalAirport=g[u+2].tagContents().trim(),x.arrivalTime=combineDateAndTime(s,g[u+3].tagContents().innerDate()),x.arrivalCode=g[u+2].tagContents().innerCapture(/([A-Z]{3})/,1),f=g[u].previousTag("td6").tagContents().innerCapture(/($<airline>.*?)\s($<code>\d+)/),x.airlineName=f.$airline,x.airlineCode=f.$airline,x.flightNumber=f.$code,x.passengers=v,S&&u++),ASSERT(x.departureTime,x.arrivalTime,x.departureCode,x.arrivalCode,x.flightNumber,x.airlineName)&&T.push(x)}else u++;m=r.cancelled.test(e.plain)?"Cancelled":"Confirmed";var D,$=[];for(u=0;u<T.length;u++){var k=T[u],F=Object.keys(k.passengers);for(C=0;C<F.length;C++){var z=k.passengers[F[C]];D={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:k.airlineName,airlineCode:k.airlineCode,flightNumber:k.flightNumber,departureAirportFuzzy:k.departureAirport,departureAirportCode:k.departureCode,departureTime:k.departureTime,arrivalAirportFuzzy:k.arrivalAirport,arrivalAirportCode:k.arrivalCode,arrivalTime:k.arrivalTime},underName:{"@type":"http://schema.org/Person",name:z.name},checkinUrl:k.checkinUrl,reservationId:p,reservationStatus:"http://schema.org/Reservation"+(m||"Confirmed"),reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:z.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:z.seats[k.flightNumber],seatingType:z.seatingType[k.flightNumber]}},totalPrice:z.totalPrice,priceCurrency:z.priceCurrency},not(z.membershipNumber)||(D.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:z.membershipNumber,programName:z.programName}),$.push(D)}}if($.length)return $}}}).call();