// Copyright 2014 Apple Inc.  All Rights Reserved.
new ReverseTemplateList([new ReverseTemplate("expedia.com-flight-changes-en",function(e){return/^Changes have been made to your .*? flight/.test(e.subject)||/^Your flight itinerary .*? changed$/.test(e.subject)},function(e){if(/^Changes have been made to your .*? flight/.test(e.subject)||/^Your flight itinerary .*? changed$/.test(e.subject)){if(!/notifications@expedia.com/.test(e.from)){var r="en_US",t={};t.itineraryLabel="Revised Itinerary",t.confirmationLabel="Airline confirmation code",t.passenger="Traveler(s)",t.traveler="Traveler",t.ticketNo="Airline Ticket No.",t.cancelled=/Per your request, your flight is canceled/,t.cancelledLabel="CANCELED",t.reservationId="Expedia Itinerary No.";var a=loadHelper("expediamail.com-flight-alternative-skeleton.js");return a(e,r,t)}var i=Scanner.fromMessage(e);i.setLocale("en_US");var n,s,l,o,p,u,m,g,c,h,d,f,v,C,b,y,N,T=[],S={};if(n=i.getSpan().nextText("Passenger(s):").parentAnyTag("td").tagContents().innerCapture(/\bPassenger\(s\): (.*)/,1),not(n))return CONTINUE;n=n.split(",").map(function(e){return e.trim()});for(var A=0;A<n.length;A++)S[""+n[A]]={name:n[A],seats:{},seatingType:{}};p=i.getSpan().next(/Your updated flight (?:schedule|itinerary) is below/).next(/(?:Flight (?:Change )?Details|Cancelled Flight)/).parentAnyTag("table");var F=p.getTagNumber();p=p.withStart(i.getSpan().next(/Your updated flight (?:itinerary|schedule) is below/).getEnd()).allInnerTags("tr"+F).map(function(e){return e.allInnerTagsFiltered("td"+F)}).filter(function(e){return e.length>0});for(var x=0;x<p.length;x++)if(s=p[x],s[0].innerCapture(/^(?:Flight(?: Change)? Details|Cancelled Flight)/)&&s[1])d=s[1],/Cancelled Flight/.test(s[0])&&(N="Cancelled");else if(s[1]&&s[1].innerCapture(/^Flight Number:/))m=s[0],u=s[1].innerCapture(/^Flight Number: ($<code>\w{2})\s*(?:\d+\s+)?($<flightNumber>\d+)/),g=u?u.$code:null,c=u?u.$flightNumber:null,i.getSpan().nextText(""+m+" confirmation code:").exists()&&(l=i.getSpan().innerCapture(RegExp(regExpEscape(""+m)+" confirmation code: (.*)\\s"),1));else if(s[0].innerCapture(/^From:/)&&s[1])f=s[0].innerCapture(/^From:.*\(([A-Z]{3})[-\)]/,1);else if(s[0].innerCapture(/^To:/)&&s[1])C=s[0].innerCapture(/^To:.*\(([A-Z]{3})[-\)]/,1),b=s[1].innerCapture(/^Arrive: .* \+1 day$/),v=combineDateAndTime(d,s[1].lastInnerDate()),not(b)||(v=modifyDate(v,1));else if(s[1]&&s[1].innerCapture(/^Class:/))y=s[1].innerCapture(/^Class: (.*)/,1);else if(s[0].innerCapture(/^Equipment:/)){if(s[1]&&s[1].innerCapture(/^Seats:/)&&(o=s[1].innerCapture(/^Seats: (.*)/,1).split(",").map(function(e){return e.trim()})),valid(c)){n=Object.keys(S);for(var A=0;A<n.length;A++)valid(o)&&(S[n[A]].seats[""+c]=o[A]),valid(y)&&(S[n[A]].seatingType[""+c]=y)}ASSERT(g,c,d,f,v,C)&&T.push({airlineName:m,airlineCode:g,flightNumber:c,departureTime:d,departureCode:f,arrivalTime:v,arrivalCode:C,reservationId:l,passengers:S,reservationStatus:N}),u=m=g=c=h=d=f=v=C=y=o=l=N=null}for(var k,E=[],x=0;x<T.length;x++){k=T[x];for(var I=Object.keys(k.passengers),j=0;j<I.length;j++){var R=k.passengers[I[j]],$={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:k.airlineName,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:R.name},checkinUrl:k.checkinUrl,reservationId:k.reservationId,reservationStatus:"http://schema.org/Reservation"+(k.reservationStatus||"Confirmed"),totalPrice:R.price,priceCurrency:R.currency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:R.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:R.seats[k.flightNumber],seatingType:R.seatingType[k.flightNumber]}}};valid(R.membershipNumber,R.programName)&&($.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:R.membershipNumber,programName:R.programName}),E.push($)}}if(E.length)return E}},"0/1/2/3/4/5/939/987/988","SG6be94b68")]);