// 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,o,l,m,s,g,u,h,d,c,b,v,f,T=[],N={};if(n=a.getSpan().innerCapture(regExpFormatted(/\b\1 (.*?)\s/,t.bookingReference),1),l=a.getSpan().nextText(t.passengers).collapseToEnd().withEnd(a.getSpan().nextRegExp(t.refundRegExp).getStart()).trim(),l=l.split("\n"),l.length)for(var y=0;y<l.length;y++)o=l[y].innerCapture(/^\d+\. (.*)$/,1),valid(o)&&(N[""+o]={name:o,seats:{},seatingType:{}});if(!Object.keys(N).length)return CONTINUE;g=a.getSpan().nextText(t.itineraryDetails).nextTag("table4").allInnerTags("tr4").map(function(e){return e.allInnerTagsFiltered("td4")}).filter(function(e){return e.length>=7});for(var C=0;C<g.length;C++)s=g[C],m=s[0].innerDate(),h=s[1].innerCapture(/($<code>\D+)($<flightNumber>\d+)/),d=h?h.$code:null,u=h?h.$flightNumber:null,b=s[2],f=s[3],c=combineDateAndTime(m,s[4].innerDate()),v=combineDateAndTime(m,s[5].innerDate()),ASSERT(d,u,c,b,v,f)&&T.push({airlineCode:d,flightNumber:u,departureCode:b,departureTime:c,arrivalCode:f,arrivalTime:v,passengers:N});for(var S=[],C=0;C<T.length;C++)for(var x=T[C],A=Object.keys(x.passengers),k=0;k<A.length;k++){var F=x.passengers[A[k]],D={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:x.airlineName,airlineCode:x.airlineCode,flightNumber:x.flightNumber,departureAirportFuzzy:x.departureAirport,departureAirportCode:x.departureCode,departureTime:x.departureTime,arrivalAirportFuzzy:x.arrivalAirport,arrivalAirportCode:x.arrivalCode,arrivalTime:x.arrivalTime},underName:{"@type":"http://schema.org/Person",name:F.name},checkinUrl:p,reservationId:n,reservationStatus:"http://schema.org/ReservationCancelled",totalPrice:F.totalPrice,priceCurrency:F.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:i,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:F.seats[""+x.airlineCode+(""+x.flightNumber)],seatingType:F.seatingType[x.flightNumber]}}};valid(F.membershipNumber,F.programName)&&(D.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:F.membershipNumber,programName:F.programName}),S.push(D)}return S.length?S:void 0}}).call();