// 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,g,o,s,l,m,d,u,h,c,C,T,x,v,N,A,f=[],b={};for(o=a.getSpan().next(r.reservationId).parentAnyTag("td").tagContents().innerCapture(regExpFormatted(/\1\s+(.*)\s+</,r.reservationId),1),l=a.getSpan().next(r.ticketNr).parentAnyTag("td").tagContents().innerCapture(regExpFormatted(/\1\s+(.*)\s+</,r.ticketNr),1),p=a.getSpan().next(r.price).nextTag("th7").tagContents(),m=p.innerCapture(/([\d,.]+)/,1),d=p.innerCapture(/([^\d,.]+)/,1),u=a.getSpan().next(r.departure).parentTag("table5").allInnerTags("tr5"),h=1;h<u.length;h++)if(u[h].tagContents().innerRegExp(r.departure).exists())C=u[h].tagContents().innerRegExp(r.departure),c=C.previousAnyTag("th").tagContents();else{if(C=u[h],T={},x=C.nextTag("td6").tagContents().innerCapture(/($<airline>[^\d]+)\s+($<flightNumber>\d+)/),T.airlineName=x.$airline,T.flightNumber=x.$flightNumber,T.airlineCode=/delta/gi.test(T.airlineName)?"DL":null,T.seatingType=T.flightNumber.nextTag("td6").tagContents(),T.departureAirport=T.seatingType.nextTag("td6").tagContents(),T.departureTime=a.getDetachedSpan(""+c+" "+(""+T.departureAirport.nextTag("td6").tagContents()).replace("N"," pm")).innerDate(),T.arrivalAirport=T.departureAirport.nextTag("td6").nextTag("td6").tagContents(),g=(""+T.arrivalAirport.nextTag("td6").tagContents()).replace(/(\d+:\d+)(N)/,"$1 pm"),/\*\*/.test(g)){var y=g.split("\n");y&&2===y.length?(g=y[0].replace("**",""),c=y[1].replace("**","")):(g=g.replace("**",""),c=modifyDate(c,1))}T.arrivalTime=a.getDetachedSpan(c+" "+g).innerDate(),ASSERT(T.airlineName,T.flightNumber,T.departureAirport,T.departureTime,T.arrivalAirport,T.arrivalTime)&&f.push(T)}for(v=a.getSpan().next(r.passengerInfo).nextTag("table6").allInnerTags("tr6"),h=0;h<v.length-1;h++)N=v[h],N.tagContents().innerRegExp(r.name).exists()?(n=N.tagContents().innerRegExp(r.name).nextTag("td7").tagContents(),A={name:n,seats:{}}):(i=N.nextTag("td6").tagContents().innerCapture(/(\d+)/,1),i.nextTag("td7").tagContents().inner(r.seat,1).exists()||(A.seats[i]=i.nextTag("td7").tagContents()),b[A.name]=A);for(var S=/DELTA: ([A-Z]{3}) ([A-Z]{3})/,k=a.getSpan().next(S),E=0;k!==a.getNullSpan();){var F=S.exec(k);if(3!==F.length||!f[E])break;f[E].departureAirportCode=F[1],f[E].arrivalAirportCode=F[2],k=k.next(S),E+=1}var D=[];for(h=0;h<f.length;h++){T=f[h];for(var R=Object.keys(b),z=0;z<R.length;z++){N=b[R[z]];var I={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:T.airlineName,airlineCode:T.airlineCode,flightNumber:T.flightNumber,departureAirportFuzzy:T.departureAirport,departureAirportCode:T.departureAirportCode,departureTime:T.departureTime,arrivalAirportFuzzy:T.arrivalAirport,arrivalAirportCode:T.arrivalAirportCode,arrivalTime:T.arrivalTime},underName:{"@type":"http://schema.org/Person",name:N.name},checkinUrl:s,reservationId:o,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:m,priceCurrency:d,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:l,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:N.seats[T.flightNumber],seatingType:T.seatingType}}};valid(N.membershipNumber,N.programName)&&(I.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:N.membershipNumber,programName:N.programName}),D.push(I)}}if(D.length)return D}}).call();