// 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 i,n,o,p,s,l,m,c,d,u,g,h,T,v,x,C,y,f,A,I,N=a.getSpan(),P=[],F={};for(n=N.nextText(r.reservationId).parentTag("td1").tagContents().innerCapture(regExpFormatted(/\1(.+)/,r.reservationId),1).trim(),a.getSpan().nextText("KAIKKI YHT.").exists()&&(r.totalPrice=r.totalPrice_et),a.getSpan().nextText("Nimi").exists()&&(r.namePrefix=r.namePrefix_et),m=N.nextText(r.totalPrice).nextTag("td1").tagContents().innerCapture(/($<priceCurrency>[\w]+)\s($<totalPrice>[\d,.]+)/),c=m?m.$totalPrice:null,d=m?m.$priceCurrency:null,[,p]=N.nextText(r.namePrefix).nextTag("td1").tagContents().innerCapture(/:\s(.+)\s\(/),F[""+p]={name:p,totalPrice:c,priceCurrency:d},s=N.withInterval(N.nextText("Itinerary").getEnd(),N.nextText("Ok = confirmed").getStart()).allInnerTagsFiltered("tr1"),s.shift(),s.pop(),A=0;A<s.length;A++)if(!(/_/.test(s[A])||/Terminal/.test(s[A])||/Operated by/.test(s[A])||/Frequent flyer number/.test(s[A])||/Arrival Day/.test(s[A]))){var b=s[A].allInnerTagsFiltered("td1");T=(""+s[A]).match(/(.+)\n/)[0].trim(),C=b[0],[,u,l]=b[1].innerCapture(/([A-Z0-9]{2})(\d+)/),g=b[3],h=b[4],x=b[5],h=combineDateAndTime(g,h),int(""+x)<int(""+h)&&(g=modifyDate(g,1)),x=combineDateAndTime(g,x),ASSERT(l,h,x)&&P.push({airlineCode:u,flightNumber:l,departureTime:h,departureCode:v,departureAirport:T.trim(),arrivalTime:x,arrivalCode:y,arrivalAirport:C.trim(),passengers:F})}var S=[];for(A=0;A<P.length;A++){var k=P[A],z=Object.keys(k.passengers);for(I=0;I<z.length;I++){f=k.passengers[z[I]];var D={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:"FINNAIR",airlineCode:k.airlineCode,flightNumber:k.flightNumber,departureAirportFuzzy:k.departureAirport,departureAirportCode:k.departureCode,departureTime:k.departureTime,arrivalAirportFuzzy:k.arrivalAirport,arrivalAirportCode:k.arrivalCode,arrivalTime:k.arrivalTime},underName:{"@type":"http://schema.org/Person",name:f.name},checkinUrl:o,reservationId:n,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:f.totalPrice,priceCurrency:f.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:i,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:"",seatingType:""}}};S.push(D)}}return S.length?S:void 0}}).call();