// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,r){var a=Scanner.fromMessage(e);a.setLocale(t);var n,i,p,o,l,s,m,u,g,d,h,c,v,b,f,T,C,N,$,y,x=[],A={};if(d=a.getSpan().nextText("Confirmation:").nextAnyTag("td").tagContents(),n=d.innerCapture(/([\w]{6})/,1),n.exists()||(n=a.getSpan().innerCapture(regExpFormatted(/\1\s*\n(.+)/,r.reservationId),1).trim()),i=d.innerCapture(regExpFormatted(/\1 > <($<checkinUrl>.*)>/,r.checkin),1),d=a.getSpan().nextTag("table3").nextTag("table3").allInnerTags("tr3"),u=a.getSpan().next(r.eTicketTotal).nextTag("td4").tagContents(),g=u.nextTag("td4").tagContents(),d.length)for(var S,k=1;S=d[k++];)S=S.allInnerTags("td3").map(function(e){return e.tagContents()}),S.length>=4&&(p=S[0],A[""+p]={name:p,price:u,currency:g,ticketNumber:S[1],membershipNumber:""+S[2],seats:{},seatingType:{},seatList:(""+S[3]).split("/").map(function(e){return"---"===e?"":e})});s=a.getSpan().next(r.flightInformation).previousTag("td2").nextTag("table3").allInnerTagsFiltered("td3");var F=/\b(\d{2}[A-Z]{3}\d{2})$/;if(s.length)for(var k=0,D=s.length;k<D;k++)if(F.test(s[k])&&k+4<D){if(l=s[k].innerCapture(F,1),h=s[k+1].innerCapture(/($<code>[A-Z]+)($<flightNumber>\d+)/),c=h?h.$code:null,m=h?""+h.$flightNumber:null,v=s[k+3].innerCapture(/($<airportName>.*)\s+\(($<code>[A-Z]{3}).*\)\s+($<time>\d{1,2}:\d{2} (?:A|P)M)/),T=v?v.$code:null,f=v?v.$airportName.trim():null,b=v?a.getDetachedSpan(""+l+" "+v.$time).innerDate():null,C=s[k+4].innerCapture(/($<airportName>.*)\s+\(($<code>[A-Z]{3}).*\)\s+($<time>\d{1,2}:\d{2} (?:A|P)M)(?: \(($<nextDate>\d{2}[A-Z]{3})\))?/),y=C?C.$code:null,$=C?C.$airportName.trim():null,N=C?a.getDetachedSpan((not(C.$nextDate)?""+l:""+C.$nextDate)+" "+C.$time).innerDate():null,valid(m)){o=Object.keys(A);for(var z=0;z<o.length;z++)A[o[z]].seats[m]=A[o[z]].seatList[x.length]}Date.parse(b)>Date.parse(N)&&(N=modifyDate(N,1)),ASSERT(c,m,T,b,y,N)&&x.push({airlineCode:c,flightNumber:m,departureAirport:f,departureCode:T,departureTime:b,arrivalAirport:$,arrivalCode:y,arrivalTime:N,passengers:A})}for(var I,M=[],k=0;k<x.length;k++)for(var P=x[k],Z=Object.keys(P.passengers),z=0;z<Z.length;z++){var E=P.passengers[Z[z]];I={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineCode:P.airlineCode,flightNumber:P.flightNumber,departureAirportFuzzy:P.departureAirport,departureAirportCode:P.departureCode,departureTime:P.departureTime,arrivalAirportFuzzy:P.arrivalAirport,arrivalAirportCode:P.arrivalCode,arrivalTime:P.arrivalTime},underName:{"@type":"http://schema.org/Person",name:E.name},checkinUrl:i,reservationId:n,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:E.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:E.seats[P.flightNumber],seatingType:E.seatingType[P.flightNumber]}},totalPrice:null,priceCurrency:null,reservationStatus:"http://schema.org/ReservationConfirmed"},valid(E.membershipNumber)&&(I.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:E.membershipNumber,programName:"Frequent Flyer"}),M.push(I)}if(M.length)return M}}).call();