// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,r){var a=Scanner.fromMessage(e);a.setLocale(t);var n,i,g,o,p,s,l,d,c,m,x,u,T,C,h,b,f,v,y,A,S=[],N={};if(a.getSpan().nextRegExp(/Swiss International Air Lines/).exists()){for(n=a.getSpan().nextRegExp(regExpFormatted(/\1/,r.bookingReference)).parentAnyTag("td").tagContents().innerCapture(regExpFormatted(/\1.*? (\w{6})/,r.bookingReference),1),g=a.getSpan().nextText(r.selectedServices).nextTag("td3").tagContents();g.exists()&&g.nextRegExp(r.eticket).exists();)c=g.nextRegExp(r.eticket).parentAnyTag("td").tagContents().innerCapture(regExpFormatted(/\1 (\d+)/,r.eticket),1),x=g.nextTag("td3").nextTag("td3").tagContents().innerCapture(regExpFormatted(/\1/,r.priceCurrency),1),m=r.totalPrice?g.nextText(r.totalPrice).nextAnyTag("td").tagContents():x.nextTag("table4").lastInnerTag("td4").tagContents(),N[""+g]={name:g,ticketNumber:c,priceCurrency:x,totalPrice:m,seats:{},seatingType:{}},g=g.nextTag("table4").nextTag("td3").tagContents();for(l=a.getSpan().firstText(r.flightInformation).nextTag("table4").nextTag("td4").tagContents();l.exists()&&l.nextText(r.selectedServices).exists();){if(u=l.innerCapture(/^($<departureAirport>.+) \(($<departureCode>[A-Z]{3})\) - ($<arrivalAirport>.+) \(($<arrivalCode>[A-Z]{3})\)$/),u&&(b=u.$departureAirport,f=u.$departureCode,y=u.$arrivalAirport,A=u.$arrivalCode),s=l.nextTag("td4").innerDate(),h=combineDateAndTime(s,s.nextTag("td4").innerDate()),v=combineDateAndTime(s,s.nextTag("td4").lastInnerDate()),s.nextTag("td4").innerText("+1").exists()&&(v=modifyDate(v,1)),T=l.nextTag("td5").nextTag("td5").tagContents().innerCapture(/($<code>.*) ($<flightNumber>\d+)/),C=T?T.$code:null,d=T?T.$flightNumber:null,p=d.nextTag("td4").nextTag("td4").tagContents(),valid(d,p)){o=Object.keys(N);for(var k=0;k<o.length;k++)N[o[k]].seatingType[""+d]=p}ASSERT(C,d,h,f,v,A)&&S.push({airlineCode:C,flightNumber:d,departureAirport:b,departureTime:h,departureCode:f,arrivalAirport:y,arrivalTime:v,arrivalCode:A,passengers:N}),l=d.nextTag("table4").nextTag("td4").tagContents()}}else{n=a.getSpan().nextRegExp(regExpFormatted(/\1/,r.bookingReference)).parentAnyTag("td").tagContents().innerCapture(regExpFormatted(/\1.*? (\w{6})/,r.bookingReference),1),o=a.getSpan().nextText(r.selectedServices).nextTag("td3").nextTag("td3").allInnerTags("table6").map(function(e){return e.allInnerTagsFiltered("td6")}).filter(function(e){return e.length>=2&&""+e[0]=="name"});for(var k=0,F=o.length;k<F;k++)c=o[k][1].nextRegExp(r.eticket).nextAnyTag("td").tagContents(),x=o[k][1].nextRegExp(r.priceCurrency).parentAnyTag("td").tagContents().innerCapture(regExpFormatted(/\1/,r.priceCurrency),1),m=x.nextAnyTag("td").tagContents(),N[o[k][1]]={name:o[k][1],ticketNumber:c,totalPrice:m,priceCurrency:x,seats:{},seatingType:{}};u=a.getSpan().nextText(r.flightInformation).nextTag("table3").allInnerTags("td3").map(function(e){return e.allInnerTags("table4")}).filter(function(e){return e.length>=2});for(var $,E=0,F=u.length;E<F;E++)if($=u[E][0],$.innerRegExp(r.dateFormat).exists()){s=$.innerDate(),l=$.nextTag("table6").allInnerTagsFiltered("td6");var R=a.getDetachedSpan((""+l[0]).replace(".",":")),D=a.getDetachedSpan((""+l[1]).replace(".",":"));if(h=combineDateAndTime(s,R.innerDate()),f=l[0].innerCapture(/([A-Z]{3})$/,1),v=combineDateAndTime(s,D.innerDate()),A=l[2],T=$.nextTag("table6").nextTag("table6").nextTag("td6").nextTag("td6").tagContents().innerCapture(/($<code>\w+) ($<flightNumber>\d+)/),C=T?T.$code:null,d=T?T.$flightNumber:null,p=$.nextTag("table6").nextTag("table6").nextTag("table6").nextTag("td6").tagContents(),valid(d,p)){o=Object.keys(N);for(var k=0;k<o.length;k++)N[o[k]].seatingType[""+d]=p}ASSERT(C,d,f,h,A,v)&&S.push({airlineCode:C,flightNumber:d,departureCode:f,departureTime:h,arrivalCode:A,arrivalTime:v,passengers:N})}}for(var I,P=[],z=0;z<S.length;z++)for(var w=S[z],j=Object.keys(w.passengers),M=0;M<j.length;M++){var O=w.passengers[j[M]];I={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineCode:w.airlineCode,flightNumber:w.flightNumber,departureAirportFuzzy:w.departureAirport,departureAirportCode:w.departureCode,departureTime:w.departureTime,arrivalAirportFuzzy:w.arrivalAirport,arrivalAirportCode:w.arrivalCode,arrivalTime:w.arrivalTime},underName:{"@type":"http://schema.org/Person",name:O.name},checkinUrl:i,reservationId:n,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:O.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:O.seats[w.flightNumber],seatingType:O.seatingType[w.flightNumber]}},totalPrice:O.totalPrice,priceCurrency:O.priceCurrency,reservationStatus:"http://schema.org/ReservationConfirmed"},valid(O.membershipNumber)&&(I.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:O.membershipNumber,programName:"Frequent Flyer"}),P.push(I)}if(P.length)return P}}).call();