1import{f as w}from"./BkWGOYjw.js";import{h as D,q as C,o as l,c as m,F as R,y as S,a,t as o,x as f,d,B as k,aA as V,i as I,k as L,aa as q,ab as T,v as P,w as B,ac as N,D as A,C as E}from"./CcLuJbFo.js";import{r as M}from"./uMaEQMxp.js";import{E as z,h as H}from"./Duk7kNpl.js";const Q={id:"tickets",class:"space-y-2 w-fit"},j={class:"p-2 w-max border rounded shadow"},G=a("div",{class:"flex flex-row items-center gap-2 flex-nowrap"},[a("img",{alt:"logo",src:V,class:"h-12"}),a("div",{class:"font-bold font-serif text-[#F38222] text-base/tight"},[d(" Lumbini "),a("br"),d(" Development Trust ")])],-1),U={class:"mt-4"},O={class:"font-serif text-sm text-center"},J=["id","innerHTML"],K={class:"*:flex *:justify-between [&>p>span]:font-normal mt-4 text-[10px]"},W={key:0},X={key:1},Y={key:2},Z={key:3},tt={key:4},et=D({__name:"TicketPrint",props:{tickets:{default:()=>[]},createdAt:{default:()=>new Date},download:{type:Boolean,default:!1},filename:{}},emits:["download"],setup(b,{emit:p}){const _=b,g=p,y=s=>s==="Person"?"Service & Conservation Fee":s==="Taxi"?"Taxi/Car/Jeep Fee":`${s} Fee`,h=async s=>{const e=new z({unit:"px",format:[226,280],hotfixes:["px_scaling"]});let t=200;const c=16,x=new Image;x.src="/images/lumbini-development-trust.png";for(let i=0;i<s.length;i++){i!==0&&e.addPage();const n=s[i],r=document.getElementById(`qr-${n.id}`);if(!r){console.error(`QR element with ID qr-${n.id} not found.`);continue}const[u,$]=[r.offsetHeight,r.offsetHeight],F=(await H(r,{backgroundColor:"white",useCORS:!0,scale:3,he
1ight:$,width:u})).toDataURL("image/png");e.addImage(F,"PNG",80,105,u,$),e.addImage(x,10,10,64,48),e.setFontSize(12).setFont("times","bold").setTextColor("#F38222"),e.text("Lumbini",82,28),e.text("Development Trust",82,48),e.setFontSize(10).setFont("times","bold").setTextColor("#000000"),e.text(y(n.type),113,84,{align:"center"}),e.setFontSize(9).setFont("times","normal").setTextColor("#000000"),t=200,e.text(`#${n.ticket_serial_number}`,10,t),e.text(n.nationality,216,t,{align:"right"}),["Vehicle","Taxi","Rickshaw"].includes(n.type)&&(t=t+c,e.text("Vehicle No.",10,t),e.text(n.remarks,216,t,{align:"right"})),n.type==="Person"?(t=t+c,e.text(`Quantity: ${n.is_monk?"Monk":"Laity"}`,10,t),e.text(String(n.quantity),216,t,{align:"right"})):(t=t+c,e.text("Quantity",10,t),e.text(String(n.quantity),216,t,{align:"right"})),t=t+c,e.text("Amount",10,t),e.text(`${n.currency==="NPR"?"Rs.":"$"} ${n.price*n.quantity}`,216,t,{align:"right"}),t=t+c,e.text("Visit date",10,t),e.text(w(n.visit_date),216,t,{align:"right"}),n.expiry_date&&n.visit_date!==n.expiry_date&&(t=t+c,e.text("Valid until",10,t),e.text(w(n.expiry_date),216,t,{align:"right"})),t=t+c,e.text("Issued at",10,t),e.text(n.issued_date,216,t,{align:"right"})}return e},v=async(s,e)=>{g("download"),s.save(`${e}.pdf`)};return C(async()=>{if(_.download){const s=await h(_.tickets);v(s,_.filename??"LumbiniTickets")}}),(s,e)=>(l(),m("div",Q,[(l(!0),m(R,null,S(s.tickets.filter(t=>!t.cancelled),t=>(l(),m("div",{key:t.id},[a("div",j,[G,a("div",U,[a("p",O,o(y(t.type)),1)]),a("div",{id:`qr-${t.id}`,class:"mt-4 [&>svg]:size-16 flex items-center justify-center w-min mx-auto",innerHTML:f(M)(t.qr_code)},null,8,J),a("div",K,[a("p",null,[d(" #"+o(t.ticket_serial_number)+" ",1),a("span",null,o(t.nationality),1)]),["Vehicle","Taxi","Rickshaw"].includes(t.type)?(l(),m("p",W,[d(" Vehicle No. "),a("span",null,o(t.remarks),1)])):k("",!0),t.type==="Person"?(l(),m("p",X,[d(" Quantity: "+o(t.is_monk?"Monk":"Laity")+" ",1),a("span",null,o(t.quantity),1)])):(l(),m("p",Y,[d(" Quantity "),a("span",null,o(t.quantity),1)])),t.quantity>1?(l(),m("p",Z,[d(" Rate "),a("span",null,o(t.currency==="NPR"?"Rs.":"$")+o(" ")+" "+o(t.price),1)])):k("",!0),a("p",null,[d(" Amount "),a("span",null,o(t.currency==="NPR"?"Rs.":"$")+o(" ")+" "+o(t.price*t.quantity),1)]),a("p",null,[d(" Visit date "),a("span",null,o(("formatDate"in s?s.formatDate:f(w))(t.visit_date)),1)]),t.expiry_date&&t.visit_date!==t.expiry_date?(l(),m("p",tt,[d(" Valid until "),a("span",null,o(("formatDate"in s?s.formatDate:f(w))(t.expiry_date)),1)])):k("",!0),a("p",null,[d(" Issued at "),a("span",null,o(t.issued_date),1)])])])]))),128))]))}}),nt={class:"flex items-center justify-center w-full h-full py-8"},at={key:0,class:"text-2xl font-bold text-center text-gray-500"},st={key:1,class:"text-2xl font-bold text-center text-red-500"},ct=D({__name:"[id]",async setup(b){let p,_;const g=I(),{public:{apiBaseUrl:y}}=E(),{id:h}=g.params,v=g.query,s=L(),e=i=>i.mode&&i.mode==="fonepayqr"?["fonepayqr",h.toString()]:i.mode&&i.mode==="khalti"?["khalti",i.token]:i.refId?["esewa",i.refId]:i.token?["getpay",i.token]:null,{data:t,error:c,status:x}=([p,_]=q(async()=>N(async()=>{const[i,n]=e(v)||[];let r=null;try{if(r=await $fetch(`${y}/checkout/${h}/`),r&&r.status==="Paid")return r;if(i&&n&&(r=await $fetch(`${y}/checkout/${h}/verify-payment/`,{method:"POST",body:{gateway:i,token:n}})),r&&r.success){const u=await $fetch(`${y}/checkout/${h}/`);if(u&&u.status==="Paid")return u}throw new Error("Payment verification failed")}catch(u){throw T(u)}},"$af2BF3PSkj")),p=await p,_(),p);if(c.value)throw T({statusCode:500,statusMessage:c.value.message});return(i,n)=>{const r=et,u=A;return l(),P(u,null,{default:B(()=>[a("div",nt,[f(x)==="pending"?(l(),m("div",at," Payment verification in progress... ")):f(x)==="error"?(l(),m("div",st," Payment verification failed ")):(l(),P(r,{key:2,tickets:f(t).tickets,"created-at":f(t).created_at,download:!0,filename:`LumbiniTickets-${f(t).id}`,onDownload:n[0]||(n[0]=$=>f(s).add({id:"download",title:"Ticket downloaded",timeout:3e3}))},null,8,["tickets","created-at","filename"]))])]),_:1})}}});
1export{ct as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.