// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,r){if(!e||!t||!r)return CONTINUE;var a=Scanner.fromMessage(e);a.setLocale(t);var n,i,p,g,s,o,l,d,m,u,h,T,x,c=[],v=[];for(T=a.getSpan().next(r.passenger).nextAnyTag("table").allInnerTags("td3"),m=0;m<T.length;m++){var C={name:(""+T[m].innerCapture(/\:\s+(.*)/,1)).trim(),seats:{}};v.push(C)}for(n=a.getSpan().nextText(r.passenger).nextTag("td3").tagContents().innerCapture(regExpFormatted(/:(.*)/),1).trim(),o=a.getDetachedSpan(e.subject).innerCapture(regExpFormatted(/(\w+)$/),1),l=a.getSpan().nextText(r.total).nextTag("td3").tagContents(),i=l.innerCapture(regExpFormatted(/([\d\.,\s]+)/),1).trim(),p=l.innerCapture(regExpFormatted(/([^\d\.,\s]+)/),1).trim(),d=a.getSpan().nextText(r.flightData).nextTag("table3").allInnerTagsFiltered("tr3"),m=0;m<d.length;m+=2){h={};var f=d[m],N=f.innerCapture(regExpFormatted(/\1.* (..) (\d{2,})/,r.number));if(3===N.length&&(h.airlineCode=N[1],h.flightNumber=N[2]),d[m+1].inner(r.seat).exists()){if(x=d[m+1].inner(r.seat).parentAnyTag("td").allInnerCapture(/($<seatNumber>\d+\D)\s\(($<seatIndex>\d+)\)/),x.length>0)for(u=0;u<x.length;u++)v[x[u].$seatIndex-1].seats[h.flightNumber]=x[u].$seatNumber;else v[0].seats[h.flightNumber]=d[m+1].innerCapture(regExpFormatted(/\1:\s+(.*)/,r.seat),1);m++}var y=d[m+1];h.departureAirport=y.withEnd(y.nextAnyTag("td").getStart()).tagContents().innerCapture(regExpFormatted(/[\d:]+(.*)/),1).trim(),h.departureTime=getFuzzyDate(a.getDetachedSpan(f.innerDate()+" "+y.firstDate())),h.arrivalAirport=y.nextAnyTag("td").nextAnyTag("td").tagContents().innerCapture(regExpFormatted(/[\d:]+(.*)/),1).trim(),h.arrivalTime=a.getDetachedSpan(f.innerDate()+" "+y.firstDate().nextDate()),ASSERT(h.departureTime,h.arrivalTime,h.departureAirport,h.arrivalAirport,h.flightNumber)&&c.push(h)}var A=[];for(m=0;m<c.length;m++)for(h=c[m],u=0;u<v.length;u++){var F={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:h.airlineName,airlineCode:h.airlineCode,flightNumber:h.flightNumber,departureAirportFuzzy:h.departureAirport,departureAirportCode:h.departureIata,departureTime:h.departureTime,arrivalAirportFuzzy:h.arrivalAirport,arrivalAirportCode:h.arrivalIata,arrivalTime:h.arrivalTime},underName:{"@type":"http://schema.org/Person",name:v[u].name},checkinUrl:s,reservationId:o,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:i,priceCurrency:p,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:g,ticketedSeat:{"@type":"http://schema.org/Seat",seatingType:h.seatingType,seatNumber:v[u].seats[h.flightNumber]}}};A.push(F)}return A.length?A:CONTINUE}}).call();