diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 027e273077..311da19e49 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -167,6 +167,10 @@ class AccountController extends BaseController $term = Input::get('plan_term'); $numUsers = Input::get('num_users'); + if ($plan != PLAN_ENTERPRISE) { + $numUsers = 1; + } + $planDetails = $account->getPlanDetails(false, false); $newPlan = [ @@ -195,7 +199,9 @@ class AccountController extends BaseController } } + $hasPaid = false; if (!empty($planDetails['paid']) && $plan != PLAN_FREE) { + $hasPaid = true; $time_used = $planDetails['paid']->diff(date_create()); $days_used = $time_used->days; @@ -211,7 +217,11 @@ class AccountController extends BaseController if ($newPlan['price'] > $credit) { $invitation = $this->accountRepo->enablePlan($newPlan, $credit); - return Redirect::to('view/' . $invitation->invitation_key); + if ($hasPaid) { + return Redirect::to('view/' . $invitation->invitation_key); + } else { + return Redirect::to('payment/' . $invitation->invitation_key); + } } else { if ($plan != PLAN_FREE) { diff --git a/public/built.js b/public/built.js index a86e403ba8..731a9ed428 100644 --- a/public/built.js +++ b/public/built.js @@ -22,8 +22,9 @@ this.uploadFiles(t)},n.prototype._getFilesWithXhr=function(t){var e,n;return n=f $(),A){for(a=[],s=i.length;s--;)a[s]=i.charCodeAt(s);c=l.from(i),r=new o(6),r.append(new Uint8Array(a)),i=r.flush(),a=new Uint8Array(i.length+6),a.set(new Uint8Array([120,156])),a.set(i,2),a.set(new Uint8Array([255&c,c>>8&255,c>>16&255,c>>24&255]),i.length+2),i=String.fromCharCode.apply(null,a),U("<>")}else U("<>");V(i),U("endobj")}O[1]=I,U("1 0 obj"),U("<s;s++)d+=3+2*s+" 0 R ";U(d+"]"),U("/Count "+D),U(">>"),U("endobj")},J=function(t){t.objectNumber=$(),U("<>"),U("endobj")},G=function(){for(var t in N)N.hasOwnProperty(t)&&J(N[t])},K=function(){X.publish("putXobjectDict")},Q=function(){U("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]"),U("/Font <<");for(var t in N)N.hasOwnProperty(t)&&U("/"+t+" "+N[t].objectNumber+" 0 R");U(">>"),U("/XObject <<"),K(),U(">>")},Z=function(){G(),X.publish("putResources"),O[2]=I,U("2 0 obj"),U("<<"),Q(),U(">>"),U("endobj"),X.publish("postPutResources")},tt=function(t,e,n){L.hasOwnProperty(e)||(L[e]={}),L[e][n]=t},et=function(t,e,n,i){var o="F"+(Object.keys(N).length+1).toString(10),a=N[o]={id:o,PostScriptName:t,fontName:e,fontStyle:n,encoding:i,metadata:{}};return tt(o,e,n),X.publish("addFont",a),o},nt=function(){for(var t="helvetica",e="times",n="courier",i="normal",o="bold",a="italic",s="bolditalic",r="StandardEncoding",c=[["Helvetica",t,i],["Helvetica-Bold",t,o],["Helvetica-Oblique",t,a],["Helvetica-BoldOblique",t,s],["Courier",n,i],["Courier-Bold",n,o],["Courier-Oblique",n,a],["Courier-BoldOblique",n,s],["Times-Roman",e,i],["Times-Bold",e,o],["Times-Italic",e,a],["Times-BoldItalic",e,s]],l=0,u=c.length;u>l;l++){var h=et(c[l][0],c[l][1],c[l][2],r),d=c[l][0].split("-");tt(h,d[0],d[1]||"")}X.publish("addFonts",{fonts:N,dictionary:L})},it=function(e){return e.foo=function(){try{return e.apply(this,arguments)}catch(n){var i=n.stack||"";~i.indexOf(" at ")&&(i=i.split(" at ")[1]);var o="Error in function "+i.split("\n")[0].split("<")[0]+": "+n.message;if(!t.console)throw new Error(o);t.console.error(o,n),t.alert&&alert(o)}},e.foo.bar=e,e.foo},ot=function(t,e){var n,i,o,a,s,r,c,l,u;if(e=e||{},o=e.sourceEncoding||"Unicode",s=e.outputEncoding,(e.autoencode||s)&&N[d].metadata&&N[d].metadata[o]&&N[d].metadata[o].encoding&&(a=N[d].metadata[o].encoding,!s&&N[d].encoding&&(s=N[d].encoding),!s&&a.codePages&&(s=a.codePages[0]),"string"==typeof s&&(s=a[s]),s)){for(c=!1,r=[],n=0,i=t.length;i>n;n++)l=s[t.charCodeAt(n)],r.push(l?String.fromCharCode(l):t[n]),r[n].charCodeAt(0)>>8&&(c=!0);t=r.join("")}for(n=t.length;void 0===c&&0!==n;)t.charCodeAt(n-1)>>8&&(c=!0),n--;if(!c)return t;for(r=e.noBOM?[]:[254,255],n=0,i=t.length;i>n;n++){if(l=t.charCodeAt(n),u=l>>8,u>>8)throw new Error("Character at position "+n+" of string '"+t+"' exceeds 16bits. Cannot be encoded into UCS-2 BE");r.push(u),r.push(l-(u<<8))}return String.fromCharCode.apply(void 0,r)},at=function(t,e){return ot(t,e).replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},st=function(){U("/Producer (jsPDF "+n.version+")");for(var t in R)R.hasOwnProperty(t)&&R[t]&&U("/"+t.substr(0,1).toUpperCase()+t.substr(1)+" ("+at(R[t])+")");var e=new Date,i=e.getTimezoneOffset(),o=0>i?"+":"-",a=Math.floor(Math.abs(i/60)),s=Math.abs(i%60),r=[o,j(a),"'",j(s),"'"].join("");U(["/CreationDate (D:",e.getFullYear(),j(e.getMonth()+1),j(e.getDate()),j(e.getHours()),j(e.getMinutes()),j(e.getSeconds()),r,")"].join(""))},rt=function(){switch(U("/Type /Catalog"),U("/Pages 1 0 R"),M||(M="fullwidth"),M){case"fullwidth":U("/OpenAction [3 0 R /FitH null]");break;case"fullheight":U("/OpenAction [3 0 R /FitV null]");break;case"fullpage":U("/OpenAction [3 0 R /Fit]");break;case"original":U("/OpenAction [3 0 R /XYZ null null 1]");break;default:var t=""+M;"%"===t.substr(t.length-1)&&(M=parseInt(M)/100),"number"==typeof M&&U("/OpenAction [3 0 R /XYZ null null "+F(M)+"]")}switch(y||(y="continuous"),y){case"continuous":U("/PageLayout /OneColumn");break;case"single":U("/PageLayout /SinglePage");break;case"two":case"twoleft":U("/PageLayout /TwoColumnLeft");break;case"tworight":U("/PageLayout /TwoColumnRight")}v&&U("/PageMode /"+v),X.publish("putCatalog")},ct=function(){U("/Size "+(C+1)),U("/Root "+C+" 0 R"),U("/Info "+(C-1)+" 0 R")},lt=function(t,e){var n="string"==typeof e&&e.toLowerCase();if("string"==typeof t){var i=t.toLowerCase();s.hasOwnProperty(i)&&(t=s[i][0]/p,e=s[i][1]/p)}if(Array.isArray(t)&&(e=t[1],t=t[0]),n){switch(n.substr(0,1)){case"l":e>t&&(n="s");break;case"p":t>e&&(n="s")}"s"===n&&(f=t,t=e,e=f)}S=!0,q[++D]=[],k[D]={width:Number(t)||g,height:Number(e)||b},ht(D)},ut=function(){lt.apply(this,arguments),U(F(x*p)+" w"),U(z),0!==E&&U(E+" J"),0!==B&&U(B+" j"),X.publish("addPage",{pageNumber:D})},ht=function(t){t>0&&D>=t&&(m=t,g=k[t].width,b=k[t].height)},dt=function(t,e){var n;t=void 0!==t?t:N[d].fontName,e=void 0!==e?e:N[d].fontStyle;try{n=L[t][e]}catch(i){}if(!n)throw new Error("Unable to look up font label for font '"+t+"', '"+e+"'. Refer to getFontList() for available fonts.");return n},pt=function(){S=!1,C=2,W=[],O=[],U("%PDF-"+a),Y(),Z(),$(),U("<<"),st(),U(">>"),U("endobj"),$(),U("<<"),rt(),U(">>"),U("endobj");var t,e=I,n="0000000000";for(U("xref"),U("0 "+(C+1)),U(n+" 65535 f "),t=1;C>=t;t++)U((n+O[t]).slice(-10)+" 00000 n ");return U("trailer"),U("<<"),ct(),U(">>"),U("startxref"),U(e),U("%%EOF"),S=!0,W.join("\n")},ft=function(t){var e="S";return"F"===t?e="f":"FD"===t||"DF"===t?e="B":("f"===t||"f*"===t||"B"===t||"B*"===t)&&(e=t),e},mt=function(){for(var t=pt(),e=t.length,n=new ArrayBuffer(e),i=new Uint8Array(n);e--;)i[e]=t.charCodeAt(e);return n},gt=function(){return new Blob([mt()],{type:"application/pdf"})},bt=it(function(e,n){var o="dataur"===(""+e).substr(0,6)?"data:application/pdf;base64,"+btoa(pt()):0;switch(e){case void 0:return pt();case"save":if(navigator.getUserMedia&&(void 0===t.URL||void 0===t.URL.createObjectURL))return P.output("dataurlnewwindow");i(gt(),n),"function"==typeof i.unload&&t.setTimeout&&setTimeout(i.unload,911);break;case"arraybuffer":return mt();case"blob":return gt();case"bloburi":case"bloburl":return t.URL&&t.URL.createObjectURL(gt())||void 0;case"datauristring":case"dataurlstring":return o;case"dataurlnewwindow":var a=t.open(o);if(a||"undefined"==typeof safari)return a;case"datauri":case"dataurl":return t.document.location.href=o;default:throw new Error('Output type "'+e+'" is not supported.')}});switch(c){case"pt":p=1;break;case"mm":p=72/25.4;break;case"cm":p=72/2.54;break;case"in":p=72;break;case"px":p=96/72;break;case"pc":p=12;break;case"em":p=12;break;case"ex":p=6;break;default:throw"Invalid unit: "+c}P.internal={pdfEscape:at,getStyle:ft,getFont:function(){return N[dt.apply(P,arguments)]},getFontSize:function(){return _},getLineHeight:function(){return _*T},write:function(t){U(1===arguments.length?t:Array.prototype.join.call(arguments," "))},getCoordinateString:function(t){return F(t*p)},getVerticalCoordinateString:function(t){return F((b-t)*p)},collections:{},newObject:$,putStream:V,events:X,scaleFactor:p,pageSize:{get width(){return g},get height(){return b}},output:function(t,e){return bt(t,e)},getNumberOfPages:function(){return q.length-1},pages:q},P.addPage=function(){return ut.apply(this,arguments),this},P.setPage=function(){return ht.apply(this,arguments),this},P.setDisplayMode=function(t,e,n){return M=t,y=e,v=n,this},P.text=function(t,e,n,i,o){function a(t){return t=t.split("\t").join(Array(h.TabLen||9).join(" ")),at(t,i)}"number"==typeof t&&(f=n,n=e,e=t,t=f),"string"==typeof t&&t.match(/[\n\r]/)&&(t=t.split(/\r\n|\r|\n/g)),"number"==typeof i&&(o=i,i=null);var s,r="",c="Td";if(o){o*=Math.PI/180;var l=Math.cos(o),u=Math.sin(o);r=[F(l),F(u),F(-1*u),F(l),""].join(" "),c="Tm"}if(i=i||{},"noBOM"in i||(i.noBOM=!0),"autoencode"in i||(i.autoencode=!0),"string"==typeof t)t=a(t);else{if(!(t instanceof Array))throw new Error('Type of text must be string or Array. "'+t+'" is not recognized.');for(var m=t.concat(),g=[],v=m.length;v--;)g.push(a(m.shift()));var M=Math.ceil((b-n)*p/(_*T));M>=0&&Mo;o++,e+=i)this.text(t[o],e,n)},P.line=function(t,e,n,i){return this.lines([[n-t,i-e]],t,e)},P.clip=function(){U("W"),U("S")},P.lines=function(t,e,n,i,o,a){var s,r,c,l,u,h,d,m,g,v,M;for("number"==typeof t&&(f=n,n=e,e=t,t=f),i=i||[1,1],U(H(e*p)+" "+H((b-n)*p)+" m "),s=i[0],r=i[1],l=t.length,v=e,M=n,c=0;l>c;c++)u=t[c],2===u.length?(v=u[0]*s+v,M=u[1]*r+M,U(H(v*p)+" "+H((b-M)*p)+" l")):(h=u[0]*s+v,d=u[1]*r+M,m=u[2]*s+v,g=u[3]*r+M,v=u[4]*s+v,M=u[5]*r+M,U(H(h*p)+" "+H((b-d)*p)+" "+H(m*p)+" "+H((b-g)*p)+" "+H(v*p)+" "+H((b-M)*p)+" c"));return a&&U(" h"),null!==o&&U(ft(o)),this},P.rect=function(t,e,n,i,o){return ft(o),U([F(t*p),F((b-e)*p),F(n*p),F(-i*p),"re"].join(" ")),null!==o&&U(ft(o)),this},P.triangle=function(t,e,n,i,o,a,s){return this.lines([[n-t,i-e],[o-n,a-i],[t-o,e-a]],t,e,[1,1],s,!0),this},P.roundedRect=function(t,e,n,i,o,a,s){var r=4/3*(Math.SQRT2-1);return this.lines([[n-2*o,0],[o*r,0,o,a-a*r,o,a],[0,i-2*a],[0,a*r,-(o*r),a,-o,a],[-n+2*o,0],[-(o*r),0,-o,-(a*r),-o,-a],[0,-i+2*a],[0,-(a*r),o*r,-a,o,-a]],t+o,e,[1,1],s),this},P.ellipse=function(t,e,n,i,o){var a=4/3*(Math.SQRT2-1)*n,s=4/3*(Math.SQRT2-1)*i;return U([F((t+n)*p),F((b-e)*p),"m",F((t+n)*p),F((b-(e-s))*p),F((t+a)*p),F((b-(e-i))*p),F(t*p),F((b-(e-i))*p),"c"].join(" ")),U([F((t-a)*p),F((b-(e-i))*p),F((t-n)*p),F((b-(e-s))*p),F((t-n)*p),F((b-e)*p),"c"].join(" ")),U([F((t-n)*p),F((b-(e+s))*p),F((t-a)*p),F((b-(e+i))*p),F(t*p),F((b-(e+i))*p),"c"].join(" ")),U([F((t+a)*p),F((b-(e+i))*p),F((t+n)*p),F((b-(e+s))*p),F((t+n)*p),F((b-e)*p),"c"].join(" ")),null!==o&&U(ft(o)),this},P.circle=function(t,e,n,i){return this.ellipse(t,e,n,n,i)},P.setProperties=function(t){for(var e in R)R.hasOwnProperty(e)&&t[e]&&(R[e]=t[e]);return this},P.setFontSize=function(t){return _=t,this},P.setFont=function(t,e){return d=dt(t,e),this},P.setFontStyle=P.setFontType=function(t){return d=dt(void 0,t),this},P.getFontList=function(){var t,e,n,i={};for(t in L)if(L.hasOwnProperty(t)){i[t]=n=[];for(e in L[t])L[t].hasOwnProperty(e)&&n.push(e)}return i},P.setLineWidth=function(t){return U((t*p).toFixed(2)+" w"),this},P.setDrawColor=function(t,e,n,i){var o;return o=void 0===e||void 0===i&&t===e===n?"string"==typeof t?t+" G":F(t/255)+" G":void 0===i?"string"==typeof t?[t,e,n,"RG"].join(" "):[F(t/255),F(e/255),F(n/255),"RG"].join(" "):"string"==typeof t?[t,e,n,i,"K"].join(" "):[F(t),F(e),F(n),F(i),"K"].join(" "),U(o),this},P.setFillColor=function(t,e,n,i){var o;return o=void 0===e||void 0===i&&t===e===n?"string"==typeof t?t+" g":F(t/255)+" g":void 0===i?"string"==typeof t?[t,e,n,"rg"].join(" "):[F(t/255),F(e/255),F(n/255),"rg"].join(" "):"string"==typeof t?[t,e,n,i,"k"].join(" "):[F(t),F(e),F(n),F(i),"k"].join(" "),U(o),this},P.setTextColor=function(t,e,n){if("string"==typeof t&&/^#[0-9A-Fa-f]{6}$/.test(t)){var i=parseInt(t.substr(1),16);t=i>>16&255,e=i>>8&255,n=255&i}return w=0===t&&0===e&&0===n||"undefined"==typeof e?H(t/255)+" g":[H(t/255),H(e/255),H(n/255),"rg"].join(" "),this},P.CapJoinStyles={0:0,butt:0,but:0,miter:0,1:1,round:1,rounded:1,circle:1,2:2,projecting:2,project:2,square:2,bevel:2},P.setLineCap=function(t){var e=this.CapJoinStyles[t];if(void 0===e)throw new Error("Line cap style of '"+t+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return E=e,U(e+" J"),this},P.setLineJoin=function(t){var e=this.CapJoinStyles[t];if(void 0===e)throw new Error("Line join style of '"+t+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return B=e,U(e+" j"),this},P.output=bt,P.save=function(t){P.output("save",t)};for(var vt in n.API)n.API.hasOwnProperty(vt)&&("events"===vt&&n.API.events.length?!function(t,e){var n,i,o;for(o=e.length-1;-1!==o;o--)n=e[o][0],i=e[o][1],t.subscribe.apply(t,[n].concat("function"==typeof i?[i]:i))}(X,n.API.events):P[vt]=n.API[vt]);return nt(),d="F1",ut(l,r),X.publish("initialized"),P}var a="1.3",s={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};return n.API={events:[]},n.version="1.0.272-git 2014-09-29T15:09:diegocr","function"==typeof define&&define.amd?define("jsPDF",function(){return n}):t.jsPDF=n,n}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this);!function(t){"use strict";t.addHTML=function(t,e,n,i,o){if("undefined"==typeof html2canvas&&"undefined"==typeof rasterizeHTML)throw new Error("You need either https://github.com/niklasvh/html2canvas or https://github.com/cburgmer/rasterizeHTML.js");"number"!=typeof e&&(i=e,o=n),"function"==typeof i&&(o=i,i=null);var a=this.internal,s=a.scaleFactor,r=a.pageSize.width,c=a.pageSize.height;if(i=i||{},i.onrendered=function(t){e=parseInt(e)||0,n=parseInt(n)||0;var a=i.dim||{},l=a.h||0,u=a.w||Math.min(r,t.width/s)-e,h="JPEG";if(i.format&&(h=i.format),t.height>c&&i.pagesplit){var d=function(){for(var i=0;;){var a=document.createElement("canvas");a.width=Math.min(r*s,t.width),a.height=Math.min(c*s,t.height-i);var l=a.getContext("2d");l.drawImage(t,0,i,t.width,a.height,0,0,a.width,a.height);var d=[a,e,i?0:n,a.width/s,a.height/s,h,null,"SLOW"];if(this.addImage.apply(this,d),i+=a.height,i>=t.height)break;this.addPage()}o(u,i,null,d)}.bind(this);if("CANVAS"===t.nodeName){var p=new Image;p.onload=d,p.src=t.toDataURL("image/png"),t=p}else d()}else{var f=Math.random().toString(35),m=[t,e,n,u,l,h,f,"SLOW"];this.addImage.apply(this,m),o(u,l,f,m)}}.bind(this),"undefined"!=typeof html2canvas&&!i.rstz)return html2canvas(t,i);if("undefined"!=typeof rasterizeHTML){var l="drawDocument";return"string"==typeof t&&(l=/^http/.test(t)?"drawURL":"drawHTML"),i.width=i.width||r*s,rasterizeHTML[l](t,void 0,i).then(function(t){i.onrendered(t.image)},function(t){o(null,t)})}return null}}(n.API),function(t){"use strict";var e="addImage_",n=["jpeg","jpg","png"],i=function(t){var e=this.internal.newObject(),n=this.internal.write,o=this.internal.putStream;if(t.n=e,n("<>"),"trns"in t&&t.trns.constructor==Array){for(var a="",s=0,r=t.trns.length;r>s;s++)a+=t.trns[s]+" "+t.trns[s]+" ";n("/Mask ["+a+"]")}if("smask"in t&&n("/SMask "+(e+1)+" 0 R"),n("/Length "+t.data.length+">>"),o(t.data),n("endobj"),"smask"in t){var c="/Predictor 15 /Colors 1 /BitsPerComponent "+t.bpc+" /Columns "+t.w,l={w:t.w,h:t.h,cs:"DeviceGray",bpc:t.bpc,dp:c,data:t.smask};"f"in t&&(l.f=t.f),i.call(this,l)}t.cs===this.color_spaces.INDEXED&&(this.internal.newObject(),n("<< /Length "+t.pal.length+">>"),o(this.arrayBufferToBinaryString(new Uint8Array(t.pal))),n("endobj"))},o=function(){var t=this.internal.collections[e+"images"];for(var n in t)i.call(this,t[n])},a=function(){var t,n=this.internal.collections[e+"images"],i=this.internal.write;for(var o in n)t=n[o],i("/I"+t.i,t.n,"0","R")},s=function(e){return e&&"string"==typeof e&&(e=e.toUpperCase()),e in t.image_compression?e:t.image_compression.NONE},r=function(){var t=this.internal.collections[e+"images"];return t||(this.internal.collections[e+"images"]=t={},this.internal.events.subscribe("putResources",o),this.internal.events.subscribe("putXobjectDict",a)),t},c=function(t){var e=0;return t&&(e=Object.keys?Object.keys(t).length:function(t){var e=0;for(var n in t)t.hasOwnProperty(n)&&e++;return e}(t)),e},l=function(t){return"undefined"==typeof t||null===t},u=function(e){return"string"==typeof e&&t.sHashCode(e)},h=function(t){return-1===n.indexOf(t)},d=function(e){return"function"!=typeof t["process"+e.toUpperCase()]},p=function(t){return"object"==typeof t&&1===t.nodeType},f=function(t,e,n){if("IMG"===t.nodeName&&t.hasAttribute("src")){var i=""+t.getAttribute("src");if(!n&&0===i.indexOf("data:image/"))return i;!e&&/\.png(?:[?#].*)?$/i.test(i)&&(e="png")}if("CANVAS"===t.nodeName)var o=t;else{var o=document.createElement("canvas");o.width=t.clientWidth||t.width,o.height=t.clientHeight||t.height;var a=o.getContext("2d");if(!a)throw"addImage requires canvas to be supported by browser.";if(n){var s,r,c,l,u,h,d,p,f=Math.PI/180;"object"==typeof n&&(s=n.x,r=n.y,c=n.bg,n=n.angle),p=n*f,l=Math.abs(Math.cos(p)),u=Math.abs(Math.sin(p)),h=o.width,d=o.height,o.width=d*u+h*l,o.height=d*l+h*u,isNaN(s)&&(s=o.width/2),isNaN(r)&&(r=o.height/2),a.clearRect(0,0,o.width,o.height),a.fillStyle=c||"white",a.fillRect(0,0,o.width,o.height),a.save(),a.translate(s,r),a.rotate(p),a.drawImage(t,-(h/2),-(d/2)),a.rotate(-p),a.translate(-s,-r),a.restore()}else a.drawImage(t,0,0,o.width,o.height)}return o.toDataURL("png"==(""+e).toLowerCase()?"image/png":"image/jpeg")},m=function(t,e){var n;if(e)for(var i in e)if(t===e[i].alias){n=e[i];break}return n},g=function(t,e,n){return t||e||(t=-96,e=-96),0>t&&(t=-1*n.w*72/t/this.internal.scaleFactor),0>e&&(e=-1*n.h*72/e/this.internal.scaleFactor),0===t&&(t=e*n.w/n.h),0===e&&(e=t*n.h/n.w),[t,e]},b=function(t,e,n,i,o,a,s){var r=g.call(this,n,i,o),c=this.internal.getCoordinateString,l=this.internal.getVerticalCoordinateString;n=r[0],i=r[1],s[a]=o,this.internal.write("q",c(n),"0 0",c(i),c(t),l(e+i),"cm /I"+o.i,"Do Q")};t.color_spaces={DEVICE_RGB:"DeviceRGB",DEVICE_GRAY:"DeviceGray",DEVICE_CMYK:"DeviceCMYK",CAL_GREY:"CalGray",CAL_RGB:"CalRGB",LAB:"Lab",ICC_BASED:"ICCBased",INDEXED:"Indexed",PATTERN:"Pattern",SEPERATION:"Seperation",DEVICE_N:"DeviceN"},t.decode={DCT_DECODE:"DCTDecode",FLATE_DECODE:"FlateDecode",LZW_DECODE:"LZWDecode",JPX_DECODE:"JPXDecode",JBIG2_DECODE:"JBIG2Decode",ASCII85_DECODE:"ASCII85Decode",ASCII_HEX_DECODE:"ASCIIHexDecode",RUN_LENGTH_DECODE:"RunLengthDecode",CCITT_FAX_DECODE:"CCITTFaxDecode"},t.image_compression={NONE:"NONE",FAST:"FAST",MEDIUM:"MEDIUM",SLOW:"SLOW"},t.sHashCode=function(t){return Array.prototype.reduce&&t.split("").reduce(function(t,e){return t=(t<<5)-t+e.charCodeAt(0),t&t},0)},t.isString=function(t){return"string"==typeof t},t.extractInfoFromBase64DataURI=function(t){return/^data:([\w]+?\/([\w]+?));base64,(.+?)$/g.exec(t)},t.supportsArrayBuffer=function(){return"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array},t.isArrayBuffer=function(t){return!!this.supportsArrayBuffer()&&t instanceof ArrayBuffer},t.isArrayBufferView=function(t){return!!this.supportsArrayBuffer()&&("undefined"!=typeof Uint32Array&&(t instanceof Int8Array||t instanceof Uint8Array||"undefined"!=typeof Uint8ClampedArray&&t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array))},t.binaryStringToUint8Array=function(t){for(var e=t.length,n=new Uint8Array(e),i=0;e>i;i++)n[i]=t.charCodeAt(i);return n},t.arrayBufferToBinaryString=function(t){this.isArrayBuffer(t)&&(t=new Uint8Array(t));for(var e="",n=t.byteLength,i=0;n>i;i++)e+=String.fromCharCode(t[i]);return e},t.arrayBufferToBase64=function(t){for(var e,n,i,o,a,s="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=new Uint8Array(t),l=c.byteLength,u=l%3,h=l-u,d=0;h>d;d+=3)a=c[d]<<16|c[d+1]<<8|c[d+2],e=(16515072&a)>>18,n=(258048&a)>>12,i=(4032&a)>>6,o=63&a,s+=r[e]+r[n]+r[i]+r[o];return 1==u?(a=c[h],e=(252&a)>>2,n=(3&a)<<4,s+=r[e]+r[n]+"=="):2==u&&(a=c[h]<<8|c[h+1],e=(64512&a)>>10,n=(1008&a)>>4,i=(15&a)<<2,s+=r[e]+r[n]+r[i]+"="),s},t.createImageInfo=function(t,e,n,i,o,a,s,r,c,l,u,h){var d={alias:r,w:e,h:n,cs:i,bpc:o,i:s,data:t};return a&&(d.f=a),c&&(d.dp=c),l&&(d.trns=l),u&&(d.pal=u),h&&(d.smask=h),d},t.addImage=function(t,e,i,o,a,g,v,M,y){if("string"!=typeof e){var A=g;g=a,a=o,o=i,i=e,e=A}if("object"==typeof t&&!p(t)&&"imageData"in t){var w=t;t=w.imageData,e=w.format||e,i=w.x||i||0,o=w.y||o||0,a=w.w||a,g=w.h||g,v=w.alias||v,M=w.compression||M,y=w.rotation||w.angle||y}if(isNaN(i)||isNaN(o))throw new Error("Invalid coordinates passed to jsPDF.addImage");var z,_=r.call(this);if(!(z=m(t,_))){var T;if(p(t)&&(t=f(t,e,y)),l(v)&&(v=u(t)),!(z=m(v,_))){if(this.isString(t)){var x=this.extractInfoFromBase64DataURI(t);x?(e=x[2],t=atob(x[3])):137===t.charCodeAt(0)&&80===t.charCodeAt(1)&&78===t.charCodeAt(2)&&71===t.charCodeAt(3)&&(e="png")}if(e=(e||"JPEG").toLowerCase(),h(e))throw new Error("addImage currently only supports formats "+n+", not '"+e+"'");if(d(e))throw new Error("please ensure that the plugin for '"+e+"' support is added");if(this.supportsArrayBuffer()&&(T=t,t=this.binaryStringToUint8Array(t)),z=this["process"+e.toUpperCase()](t,c(_),v,s(M),T),!z)throw new Error("An unkwown error occurred whilst processing the image")}}return b.call(this,i,o,a,g,z,z.i,_),this};var v=function(t){var e,n,i;if(255===!t.charCodeAt(0)||216===!t.charCodeAt(1)||255===!t.charCodeAt(2)||224===!t.charCodeAt(3)||!t.charCodeAt(6)==="J".charCodeAt(0)||!t.charCodeAt(7)==="F".charCodeAt(0)||!t.charCodeAt(8)==="I".charCodeAt(0)||!t.charCodeAt(9)==="F".charCodeAt(0)||0===!t.charCodeAt(10))throw new Error("getJpegSize requires a binary string jpeg file");for(var o=256*t.charCodeAt(4)+t.charCodeAt(5),a=4,s=t.length;s>a;){if(a+=o,255!==t.charCodeAt(a))throw new Error("getJpegSize could not find the size of the image");if(192===t.charCodeAt(a+1)||193===t.charCodeAt(a+1)||194===t.charCodeAt(a+1)||195===t.charCodeAt(a+1)||196===t.charCodeAt(a+1)||197===t.charCodeAt(a+1)||198===t.charCodeAt(a+1)||199===t.charCodeAt(a+1))return n=256*t.charCodeAt(a+5)+t.charCodeAt(a+6),e=256*t.charCodeAt(a+7)+t.charCodeAt(a+8),i=t.charCodeAt(a+9),[e,n,i];a+=2,o=256*t.charCodeAt(a)+t.charCodeAt(a+1)}},M=function(t){var e=t[0]<<8|t[1];if(65496!==e)throw new Error("Supplied data is not a JPEG");for(var n,i,o,a,s=t.length,r=(t[4]<<8)+t[5],c=4;s>c;){if(c+=r,n=y(t,c),r=(n[2]<<8)+n[3],(192===n[1]||194===n[1])&&255===n[0]&&r>7)return n=y(t,c+5),i=(n[2]<<8)+n[3],o=(n[0]<<8)+n[1],a=n[4],{width:i,height:o,numcomponents:a};c+=2}throw new Error("getJpegSizeFromBytes could not find the size of the image")},y=function(t,e){return t.subarray(e,e+5)};t.processJPEG=function(t,e,n,i,o){var a,s=this.color_spaces.DEVICE_RGB,r=this.decode.DCT_DECODE,c=8;return this.isString(t)?(a=v(t),this.createImageInfo(t,a[0],a[1],1==a[3]?this.color_spaces.DEVICE_GRAY:s,c,r,e,n)):(this.isArrayBuffer(t)&&(t=new Uint8Array(t)),this.isArrayBufferView(t)?(a=M(t),t=o||this.arrayBufferToBinaryString(t),this.createImageInfo(t,a.width,a.height,1==a.numcomponents?this.color_spaces.DEVICE_GRAY:s,c,r,e,n)):null)},t.processJPG=function(){return this.processJPEG.apply(this,arguments)}}(n.API),function(t){"use strict";t.autoPrint=function(){var t;return this.internal.events.subscribe("postPutResources",function(){t=this.internal.newObject(),this.internal.write("<< /S/Named /Type/Action /N/Print >>","endobj")}),this.internal.events.subscribe("putCatalog",function(){this.internal.write("/OpenAction "+t+" 0 R")}),this}}(n.API),function(t){"use strict";var e,n,i,o,a=3,s=13,r={x:void 0,y:void 0,w:void 0,h:void 0,ln:void 0},c=1,l=function(t,e,n,i,o){r={x:t,y:e,w:n,h:i,ln:o}},u=function(){return r},h={left:0,top:0,bottom:0};t.setHeaderFunction=function(t){o=t},t.getTextDimensions=function(t){e=this.internal.getFont().fontName,n=this.table_font_size||this.internal.getFontSize(),i=this.internal.getFont().fontStyle;var o,a,s=19.049976/25.4;return a=document.createElement("font"),a.id="jsPDFCell",a.style.fontStyle=i,a.style.fontName=e,a.style.fontSize=n+"pt",a.textContent=t,document.body.appendChild(a),o={w:(a.offsetWidth+1)*s,h:(a.offsetHeight+1)*s},document.body.removeChild(a),o},t.cellAddPage=function(){var t=this.margins||h;this.addPage(),l(t.left,t.top,void 0,void 0),c+=1},t.cellInitialize=function(){r={x:void 0,y:void 0,w:void 0,h:void 0,ln:void 0},c=1},t.cell=function(t,e,n,i,o,r,c){var d=u();if(void 0!==d.ln)if(d.ln===r)t=d.x+d.w,e=d.y;else{var p=this.margins||h;d.y+d.h+i+s>=this.internal.pageSize.height-p.bottom&&(this.cellAddPage(),this.printHeaders&&this.tableHeaderRow&&this.printHeaderRow(r,!0)),e=u().y+u().h}if(void 0!==o[0])if(this.printingHeaderRow?this.rect(t,e,n,i,"FD"):this.rect(t,e,n,i),"right"===c){if(o instanceof Array)for(var f=0;fn;n+=1)o=t[n],e?-1===e(a,o)&&(a=o):o>a&&(a=o);return a},t.table=function(e,n,i,o,a){if(!i)throw"No data for PDF table";var s,l,u,d,p,f,m,g,b,v,M=[],y=[],A={},w={},z=[],_=[],T=!1,x=!0,C=12,S=h;if(S.width=this.internal.pageSize.width,a&&(a.autoSize===!0&&(T=!0),a.printHeaders===!1&&(x=!1),a.fontSize&&(C=a.fontSize),a.margins&&(S=a.margins)),this.lnMod=0,r={x:void 0,y:void 0,w:void 0,h:void 0,ln:void 0},c=1,this.printHeaders=x,this.margins=S,this.setFontSize(C),this.table_font_size=C,void 0===o||null===o)M=Object.keys(i[0]);else if(o[0]&&"string"!=typeof o[0]){var O=19.049976/25.4;for(l=0,u=o.length;u>l;l+=1)s=o[l],M.push(s.name),y.push(s.prompt),w[s.name]=s.width*O}else M=o;if(T)for(v=function(t){return t[s]},l=0,u=M.length;u>l;l+=1){for(s=M[l],A[s]=i.map(v),z.push(this.getTextDimensions(y[l]||s).w),f=A[s],m=0,d=f.length;d>m;m+=1)p=f[m],z.push(this.getTextDimensions(p).w);w[s]=t.arrayMax(z)}if(x){var N=this.calculateLineHeight(M,w,y.length?y:M);for(l=0,u=M.length;u>l;l+=1)s=M[l],_.push([e,n,w[s],N,String(y.length?y[l]:s)]);this.setTableHeaderRow(_),this.printHeaderRow(1,!1)}for(l=0,u=i.length;u>l;l+=1){var N;for(g=i[l],N=this.calculateLineHeight(M,w,g),m=0,b=M.length;b>m;m+=1)s=M[m],this.cell(e,n,w[s],N,g[s],l+2,s.align)}return this.lastCellPos=r,this.table_x=e,this.table_y=n,this},t.calculateLineHeight=function(t,e,n){for(var i,o=0,s=0;so&&(o=r)}return o},t.setTableHeaderRow=function(t){this.tableHeaderRow=t},t.printHeaderRow=function(t,e){if(!this.tableHeaderRow)throw"Property tableHeaderRow does not exist.";var n,i,a,s;if(this.printingHeaderRow=!0,void 0!==o){var r=o(this,c);l(r[0],r[1],r[2],r[3],-1)}this.setFontStyle("bold");var u=[];for(a=0,s=this.tableHeaderRow.length;s>a;a+=1)this.setFillColor(200,200,200),n=this.tableHeaderRow[a],e&&(n[1]=this.margins&&this.margins.top||0,u.push(n)),i=[].concat(n),this.cell.apply(this,i.concat(t));u.length>0&&this.setTableHeaderRow(u),this.setFontStyle("normal"),this.printingHeaderRow=!1}}(n.API),function(t){var e,n,i,o,a,s,r,c,l,u,h,d,p,f,m,g,b,v,M;e=function(){function t(){}return function(e){return t.prototype=e,new t}}(),l=function(t){var e,n,i,o,a,s,r;for(n=0,i=t.length,e=void 0,o=!1,s=!1;!o&&n!==i;)e=t[n]=t[n].trimLeft(),e&&(o=!0),n++;for(n=i-1;i&&!s&&-1!==n;)e=t[n]=t[n].trimRight(),e&&(s=!0),n--;for(a=/\s+$/g,r=!0,n=0;n!==i;)e=t[n].replace(/\s+/g," "),r&&(e=e.trimLeft()),e&&(r=a.test(e)),t[n]=e,n++;return t},u=function(t,e,n,i){return this.pdf=t,this.x=e,this.y=n,this.settings=i,this.watchFunctions=[],this.init(),this},h=function(t){var e,n,o;for(e=void 0,o=t.split(","),n=o.shift();!e&&n;)e=i[n.trim().toLowerCase()],n=o.shift();return e},d=function(t){t="auto"===t?"0px":t,t.indexOf("em")>-1&&!isNaN(Number(t.replace("em","")))&&(t=18.719*Number(t.replace("em",""))+"px"),t.indexOf("pt")>-1&&!isNaN(Number(t.replace("pt","")))&&(t=1.333*Number(t.replace("pt",""))+"px");var e,n,i;return n=void 0,e=16,(i=p[t])?i:(i={"xx-small":9,"x-small":11,small:13,medium:16,large:19,"x-large":23,"xx-large":28,auto:0}[{css_line_height_string:t}],i!==n?p[t]=i/e:(i=parseFloat(t))?p[t]=i/e:(i=t.match(/([\d\.]+)(px)/),p[t]=3===i.length?parseFloat(i[1])/e:1))},c=function(t){var e,n,i;return i=function(t){var e;return e=function(t){return document.defaultView&&document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(t,null):t.currentStyle?t.currentStyle:t.style}(t),function(t){return t=t.replace(/-\D/g,function(t){return t.charAt(1).toUpperCase()}),e[t]}}(t),e={},n=void 0,e["font-family"]=h(i("font-family"))||"times",e["font-style"]=o[i("font-style")]||"normal",e["text-align"]=TextAlignMap[i("text-align")]||"left",n=a[i("font-weight")]||"normal","bold"===n&&(e["font-style"]="normal"===e["font-style"]?n:n+e["font-style"]),e["font-size"]=d(i("font-size"))||1,e["line-height"]=d(i("line-height"))||1,e.display="inline"===i("display")?"inline":"block",n="block"===e.display,e["margin-top"]=n&&d(i("margin-top"))||0,e["margin-bottom"]=n&&d(i("margin-bottom"))||0,e["padding-top"]=n&&d(i("padding-top"))||0,e["padding-bottom"]=n&&d(i("padding-bottom"))||0,e["margin-left"]=n&&d(i("margin-left"))||0,e["margin-right"]=n&&d(i("margin-right"))||0,e["padding-left"]=n&&d(i("padding-left"))||0,e["padding-right"]=n&&d(i("padding-right"))||0,e["float"]=s[i("cssFloat")]||"none",e.clear=r[i("clear")]||"none",e},f=function(t,e,n){var i,o,a,s,r;if(a=!1,o=void 0,s=void 0,r=void 0,i=n["#"+t.id])if("function"==typeof i)a=i(t,e);else for(o=0,s=i.length;!a&&o!==s;)a=i[o](t,e),o++;if(i=n[t.nodeName],!a&&i)if("function"==typeof i)a=i(t,e);else for(o=0,s=i.length;!a&&o!==s;)a=i[o](t,e),o++;return a},M=function(t,e){var n,i,o,a,s,r,c,l,u,h;for(n=[],i=[],o=0,h=t.rows[0].cells.length,l=t.clientWidth;h>o;)u=t.rows[0].cells[o],i[o]={name:u.textContent.toLowerCase().replace(/\s+/g,""),prompt:u.textContent.replace(/\r?\n/g,""),width:u.clientWidth/l*e.pdf.internal.pageSize.width},o++;for(o=1;or;){if(o=a[r],"object"==typeof o){if(e.executeWatchFunctions(o),1===o.nodeType&&"HEADER"===o.nodeName){var g=o,b=e.pdf.margins_doc.top;e.pdf.internal.events.subscribe("addPage",function(){e.y=b,n(g,e,i),e.pdf.margins_doc.top=e.y+10,e.y+=10},!1)}if(8===o.nodeType&&"#comment"===o.nodeName)~o.textContent.indexOf("ADD_PAGE")&&(e.pdf.addPage(),e.y=e.pdf.margins_doc.top);else if(1!==o.nodeType||y[o.nodeName])if(3===o.nodeType){var v=o.nodeValue;if(o.nodeValue&&"LI"===o.parentNode.nodeName)if("OL"===o.parentNode.parentNode.nodeName)v=A++ +". "+v;else{var w=16*s["font-size"],z=2;w>20&&(z=3),p=function(t,e){this.pdf.circle(t,e,z,"FD")}}e.addText(v,s)}else"string"==typeof o&&e.addText(o,s);else{var _;if("IMG"===o.nodeName){var T=o.getAttribute("src");_=m[e.pdf.sHashCode(T)||T]}if(_){e.pdf.internal.pageSize.height-e.pdf.margins_doc.bottome.pdf.margins_doc.top&&(e.pdf.addPage(),e.y=e.pdf.margins_doc.top,e.executeWatchFunctions(o));var x=c(o),C=e.x,S=12/e.pdf.internal.scaleFactor,O=(x["margin-left"]+x["padding-left"])*S,N=(x["margin-right"]+x["padding-right"])*S,L=(x["margin-top"]+x["padding-top"])*S,D=(x["margin-bottom"]+x["padding-bottom"])*S; C+=void 0!==x["float"]&&"right"===x["float"]?e.settings.width-o.width-N:O,e.pdf.addImage(_,C,e.y+L,o.width,o.height),_=void 0,"right"===x["float"]||"left"===x["float"]?(e.watchFunctions.push(function(t,n,i,o){return e.y>=n?(e.x+=t,e.settings.width+=i,!0):!!(o&&1===o.nodeType&&!y[o.nodeName]&&e.x+o.width>e.pdf.margins_doc.left+e.pdf.margins_doc.width)&&(e.x+=t,e.y=n,e.settings.width+=i,!0)}.bind(this,"left"===x["float"]?-o.width-O-N:0,e.y+o.height+L+D,o.width)),e.watchFunctions.push(function(t,n,i){return!(e.y0){o=o[0];var a=e.pdf.internal.write,s=e.y;e.pdf.internal.write=function(){},n(o,e,i);var r=Math.ceil(e.y-s)+5;e.y=s,e.pdf.internal.write=a,e.pdf.margins_doc.bottom+=r;for(var c=function(t){var a=void 0!==t?t.pageNumber:1,s=e.y;e.y=e.pdf.internal.pageSize.height-e.pdf.margins_doc.bottom,e.pdf.margins_doc.bottom-=r;for(var c=o.getElementsByTagName("span"),l=0;l-1&&(c[l].innerHTML=a),(" "+c[l].className+" ").replace(/[\n\t]/g," ").indexOf(" totalPages ")>-1&&(c[l].innerHTML="###jsPDFVarTotalPages###");n(o,e,i),e.pdf.margins_doc.bottom+=r,e.y=s},l=o.getElementsByTagName("span"),u=0;u-1&&e.pdf.internal.events.subscribe("htmlRenderingFinished",e.pdf.putTotalPages.bind(e.pdf,"###jsPDFVarTotalPages###"),!0);e.pdf.internal.events.subscribe("addPage",c,!1),c(),y.FOOTER=1}},v=function(t,e,i,o,a,s){if(!e)return!1;"string"==typeof e||e.parentNode||(e=""+e.innerHTML),"string"==typeof e&&(e=function(t){var e,n,i,o;return i="jsPDFhtmlText"+Date.now().toString()+(1e3*Math.random()).toFixed(0),o="position: absolute !important;clip: rect(1px 1px 1px 1px); /* IE6, IE7 */clip: rect(1px, 1px, 1px, 1px);padding:0 !important;border:0 !important;height: 1px !important;width: 1px !important; top:auto;left:-100px;overflow: hidden;",n=document.createElement("div"),n.style.cssText=o,n.innerHTML='