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