// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,r,n){var a=Scanner.fromMessage(e);a.setLocale(t);var i,p,x,g,o,d,m,l=[],u=[],s=[],T=1,h="Confirmed";x=a.getSpan().nextText(r.number).nextText("\n"),x=a.getSpan().withInterval(x.getEnd(),x.nextText("\n").getStart()),g=a.getSpan().nextText(r.price).nextText("\n"),g=a.getSpan().withInterval(g.getEnd(),g.nextText("\n").getStart()),o=g.innerCapture(regExpFormatted(/([\d\., ]+)/),1).trim(),d=g.innerCapture(regExpFormatted(/([^\d\., ]+)/),1),i=a.getSpan().nextText(r.passenger).nextText("\n"),i=a.getSpan().withInterval(i.getEnd(),i.nextText("\n").getStart());do{var v;v=n?i.innerCapture(regExpFormatted(/(.*) .*?/),1):i.innerCapture(regExpFormatted(/.*?\s(.*)/),1),v.exists()||(v=a.getSpan().innerCapture(regExpFormatted(/\1 [\w\.]+ (.*?)\./,r.name),1),v.exists()||(v=a.getSpan().innerCapture(regExpFormatted(/(.*)\1/,r.send),1).trim())),ASSERT(v)&&u.push({name:v}),i=i.nextText("\n"),i=a.getSpan().withInterval(i.getEnd(),i.nextText("\n").getStart())}while(i.getLength());for(p=a.getSpan().nextText(r.flight).nextText("[1]"),a.getSpan().nextText(r.limit).exists()?h="Pending":a.getSpan().nextText(r.cancel).exists()?h="Cancelled":a.getSpan().nextText(r.refund).exists()&&(h="Cancelled");p.exists();){var S,c,E={},F=p.nextDate(),C=p.nextRegExp(regExpFormatted(/([A-Z\d]+)[\n\(]/)).trim();E.airlineCode=C.innerCapture(regExpFormatted(/([A-Z]{2,3})/),1),E.flightNumber=C.innerCapture(regExpFormatted(/(\d+)/),1);var y=a.getSpan().withInterval(p.nextText("\n").getEnd(),p.nextText("\n").nextText("\n").getStart()).split("-");E.arrivalAirportFuzzy=y[1].trim(),E.departureAirportFuzzy=y[0].trim(),E.departureTime=a.getDetachedSpan(F+" "+F.nextText("\n").nextDate()),S=F.nextText("\n").nextDate().collapseToEnd().nextRegExp(regExpFormatted(/[\d\:]+/)),E.arrivalTime=a.getDetachedSpan(F+" "+S),c=a.getSpan().withInterval(S.previousText("\n").getEnd(),S.nextText("\n").getStart()),c.contains(S.nextText(r.addOne))&&(E.arrivalTime=modifyDate(E.arrivalTime,1)),E.seatNumber=a.getSpan().withInterval(c.nextText("\n").getEnd(),c.nextText("\n").nextText("\n").getStart()).innerCapture(regExpFormatted(/\1(.*)/,r.seat),1).trim(),ASSERT(E.arrivalAirportFuzzy,E.departureAirportFuzzy,E.flightNumber,E.departureTime,E.arrivalTime)&&l.push(E),T++,p=p.nextText("["+T+"]")}m=a.getSpan().nextText(r.checkin).nextLink();for(var z=0;z<l.length;z++)for(var A=l[z],f=0;f<u.length;f++){var N=u[f],w={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:"All Nippon Airways",airlineCode:A.airlineCode,flightNumber:A.flightNumber,departureAirportFuzzy:A.departureAirportFuzzy,departureAirportCode:A.departureAirportCode,departureTime:A.departureTime,arrivalAirportFuzzy:A.arrivalAirportFuzzy,arrivalAirportCode:A.arrivalAirportCode,arrivalTime:A.arrivalTime},underName:{"@type":"http://schema.org/Person",name:N.name},checkinUrl:m,reservationId:x,reservationStatus:"http://schema.org/Reservation"+h,totalPrice:o,priceCurrency:d,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:x,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:A.seatNumber,seatingType:""}}};s.push(w)}if(s.length)return s}}).call();