// Copyright 2014 Apple Inc.  All Rights Reserved.
new ReverseTemplateList([new ReverseTemplate("ticketweb.com-confirmation-en",function(e){return/^Order Confirmation/.test(e.subject)},function(e){if(/^Order Confirmation/.test(e.subject)){var t="en_US",a=loadHelper("ticketweb-schemaorg-parser.js"),r=a(e);if(r)return r;var n=Scanner.fromMessage(e);n.setLocale(t);var s,c,i,p,o,m,d,u,g=[];for(s=n.getSpan().innerCapture(/\bName: (.*)\s/,1),c=n.getSpan().innerCapture(/\bOrder Number: (.*?)\s/,1),u=n.getSpan().nextText("Order Summary");u.nextText("Delivery Type:").exists();){i={},u=u.nextText("Delivery Type:"),d=u.previousTag("td3").tagContents();var h=(""+d).split("\n");i.eventName=h[0].trim(),i.startDate=getFuzzyDate(n.getDetachedSpan(h[1]).firstDate()),h.length>=3&&(i.endDate=getFuzzyDate(n.getDetachedSpan(h[2]).firstDate())),valid(i.eventName,i.startDate)&&(i.name=s,i.ticketNumber=c,i.address=d.innerAddress(),i.address.exists()&&(p=n.getAddressDD(i.address).text,o=d.innerCapture(RegExp("\\b($<place>.*?), ($<address>.*(?:"+regExpEscape(p)+").*)")),o&&(i.place=o.$place,m=o.$address.trim(),p.length<(""+m).length&&(i.address=m))),i.numSeats=d.nextText("Delivery Type:").nextTag("td2").tagContents(),i.price=i.numSeats.nextTag("td2").nextTag("td2").tagContents().innerCapture(/([\d,.]+)/,1),ASSERT(i.name,i.eventName,i.startDate,i.ticketNumber,i.address)&&g.push(i))}if(1===g.length&&(g[0].price=n.getSpan().nextText("Total Charges:").nextTag("td2").tagContents().trim().innerCapture(/([\d.,]+)$/,1)),g.length){for(var l,v=[],S=0;l=g[S++];)v.push({"@context":"http://schema.org","@type":"http://schema.org/EventReservation",name:l.name,totalPrice:l.price,priceCurrency:l.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:l.ticketNumber,ticketToken:l.ticketDownloadUrl,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:l.seat,seatRow:l.seatRow,seatSection:l.seatSection}},reservationFor:{"@type":"http://schema.org/Event",eventStatus:"http://schema.org/EventConfirmed",name:l.eventName,url:l.eventUrl,startDate:l.startDate,endDate:l.endDate,location:{"@type":"http://schema.org/Place",name:l.place,telephone:l.phoneNumber,address:l.address}}});return v}}},"0/1/2/3/4/5/1248/1339/1340","SG5a41738b"),new ReverseTemplate("ticketweb.com-ticket-update-en",function(e){return/^An important update regarding/.test(e.subject)},function(e){if(/^An important update regarding/.test(e.subject)){var a=Scanner.fromMessage(e);a.setLocale("en_US");var r,n,s,c=[];if(r={},s=/\b($<eventName>.*)\s+at ($<place>.*)\s+on/,n=a.getSpan().innerCapture(s),n&&(r.eventName=n.$eventName,r.place=n.$place),r.startDate=a.getSpan().firstDate(),r.ticketNumber=a.getSpan().innerCapture(/Confirmation #:\s+(.*)\s+/,1),ASSERT(r.eventName,r.startDate)&&c.push(r),c.length){for(var i=[],p=0;t=c[p++];)i.push({"@context":"http://schema.org","@type":"http://schema.org/EventReservation",name:t.name,totalPrice:t.price,priceCurrency:t.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:t.ticketNumber,ticketToken:t.ticketDownloadUrl,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:t.seat,seatRow:t.seatRow,seatSection:t.seatSection}},reservationFor:{"@type":"http://schema.org/Event",eventStatus:"http://schema.org/EventConfirmed",name:t.eventName,url:t.eventUrl,startDate:t.startDate,endDate:t.endDate,location:{"@type":"http://schema.org/Place",name:t.place,telephone:t.phoneNumber,address:t.address}}});return i}}},"0/1/2/3/4/5/1248/1339/1342","SG421c91a0")]);