survey-pdf
Version:
A UI component that uses SurveyJS form JSON schemas to render forms as PDF documents. It populates PDF fields with data collected using SurveyJS Form Library and lets you export your SurveyJS forms as editable or pre-filled PDFs.
5 lines (4 loc) • 186 kB
JavaScript
/*!
* For license information please see survey.pdf.node.min.js.LICENSE.txt
*/
(function(A,tt){typeof exports=="object"&&typeof module<"u"?tt(exports,require("survey-core"),require("jspdf"),require("node-fetch"),require("image-size")):typeof define=="function"&&define.amd?define(["exports","survey-core","jspdf","node-fetch","image-size"],tt):(A=typeof globalThis<"u"?globalThis:A||self,tt(A.SurveyPDF={},A.Survey,A.jspdf,A["node-fetch"],A["image-size"]))})(this,(function(A,tt,Wt,Ze,Je){"use strict";function $e(o){var i=Object.create(null);return o&&Object.keys(o).forEach(function(t){if(t!=="default"){var e=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(i,t,e.get?e:{enumerable:!0,get:function(){return o[t]}})}}),i.default=o,Object.freeze(i)}var ti=$e(tt),re=Object.freeze({__proto__:null,get BooleanItemBrick(){return pe},get CheckItemBrick(){return It},get CheckboxItemBrick(){return ye},get CompositeBrick(){return D},get CustomBrick(){return Ue},get DocController(){return Lt},get DocOptions(){return Xt},get DrawCanvas(){return Zt},get DropdownBrick(){return Fe},get EmptyBrick(){return Ht},get EventHandler(){return ge},get FlatBoolean(){return me},get FlatCheckbox(){return te},get FlatComment(){return be},get FlatCustomModel(){return ve},get FlatDropdown(){return Te},get FlatExpression(){return xe},get FlatFile(){return Re},get FlatHTML(){return we},get FlatImage(){return Pe},get FlatImagePicker(){return Ce},get FlatMatrix(){return Ne},get FlatMatrixDynamic(){return ke},get FlatMatrixMultiple(){return ee},get FlatMultipleText(){return Oe},get FlatPanelDynamic(){return _e},get FlatQuestion(){return ot},get FlatQuestionDefault(){return se},get FlatRadiogroup(){return Nt},get FlatRanking(){return Ee},get FlatRating(){return Ae},get FlatRepository(){return Q},get FlatSelectBase(){return $t},get FlatSignaturePad(){return Le},get FlatSlider(){return Se},get FlatSurvey(){return Dt},get FlatTextbox(){return Ie},get HTMLBrick(){return ue},get HorizontalAlign(){return A.HorizontalAlign},get ImageBrick(){return he},get LinkBrick(){return Qt},get PagePacker(){return de},get PdfBrick(){return mt},get RadioItemBrick(){return Jt},get RankingItemBrick(){return Be},get RowlineBrick(){return Kt},get SurveyHelper(){return h},get SurveyPDF(){return Ge},get TextBoldBrick(){return jt},get TextBrick(){return nt},get TextFieldBrick(){return Vt},get TitlePanelBrick(){return le},get VerticalAlign(){return A.VerticalAlign}}),oe=function(o,i){return oe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},oe(o,i)};function H(o,i){if(typeof i!="function"&&i!==null)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");oe(o,i);function t(){this.constructor=o}o.prototype=i===null?Object.create(i):(t.prototype=i.prototype,new t)}var vt=function(){return vt=Object.assign||function(i){for(var t,e=1,r=arguments.length;e<r;e++){t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},vt.apply(this,arguments)};function F(o,i,t,e){function r(n){return n instanceof t?n:new t(function(a){a(n)})}return new(t||(t=Promise))(function(n,a){function s(f){try{l(e.next(f))}catch(d){a(d)}}function u(f){try{l(e.throw(f))}catch(d){a(d)}}function l(f){f.done?n(f.value):r(f.value).then(s,u)}l((e=e.apply(o,i||[])).next())})}function T(o,i){var t={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},e,r,n,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(l){return function(f){return u([l,f])}}function u(l){if(e)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(t=0)),t;)try{if(e=1,r&&(n=l[0]&2?r.return:l[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,l[1])).done)return n;switch(r=0,n&&(l=[l[0]&2,n.value]),l[0]){case 0:case 1:n=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(n=t.trys,!(n=n.length>0&&n[n.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]<n[3])){t.label=l[1];break}if(l[0]===6&&t.label<n[1]){t.label=n[1],n=l;break}if(n&&t.label<n[2]){t.label=n[2],t.ops.push(l);break}n[2]&&t.ops.pop(),t.trys.pop();continue}l=i.call(o,t)}catch(f){l=[6,f],r=0}finally{e=n=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function _t(o,i,t){if(t||arguments.length===2)for(var e=0,r=i.length,n;e<r;e++)(n||!(e in i))&&(n||(n=Array.prototype.slice.call(i,0,e)),n[e]=i[e]);return o.concat(n||Array.prototype.slice.call(i))}typeof SuppressedError=="function"&&SuppressedError;var D=(function(){function o(){for(var i=[],t=0;t<arguments.length;t++)i[t]=arguments[t];this.bricks=[],this.isPageBreak=!1,this._xLeft=0,this._xRight=0,this._yTop=0,this._yBot=0,this.addBrick.apply(this,i)}return Object.defineProperty(o.prototype,"xLeft",{get:function(){return this._xLeft},set:function(i){this.shift(i-this.xLeft,0,0,0),this._xLeft=i},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"xRight",{get:function(){return this._xRight},set:function(i){this.shift(0,i-this.xRight,0,0),this._xRight=i},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"yTop",{get:function(){return this._yTop},set:function(i){this.shift(0,0,i-this.yTop,0),this._yTop=i},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"yBot",{get:function(){return this._yBot},set:function(i){this.shift(0,0,0,i-this.yBot),this._yBot=i},enumerable:!1,configurable:!0}),o.prototype.shift=function(i,t,e,r){this.bricks.forEach(function(n){n.xLeft+=i,n.xRight+=t,n.yTop+=e,n.yBot+=r})},Object.defineProperty(o.prototype,"width",{get:function(){return this.xRight-this.xLeft},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"height",{get:function(){return this.yBot-this.yTop},enumerable:!1,configurable:!0}),o.prototype.render=function(){return F(this,void 0,void 0,function(){var i;return T(this,function(t){switch(t.label){case 0:i=0,t.label=1;case 1:return i<this.bricks.length?[4,this.bricks[i].render()]:[3,4];case 2:t.sent(),t.label=3;case 3:return i++,[3,1];case 4:return[2]}})})},Object.defineProperty(o.prototype,"isEmpty",{get:function(){return this.bricks.length===0},enumerable:!1,configurable:!0}),o.prototype.addBrick=function(){for(var i,t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(t.length!=0){(i=this.bricks).push.apply(i,t);var r=h.mergeRects.apply(h,this.bricks);this._xLeft=r.xLeft,this._xRight=r.xRight,this._yTop=r.yTop,this._yBot=r.yBot}},o.prototype.unfold=function(){var i=[];return this.bricks.forEach(function(t){i.push.apply(i,t.unfold())}),i},o.prototype.translateX=function(i){this.bricks.forEach(function(e){return e.translateX(i)});var t=i(this.xLeft,this.xRight);this._xLeft=t.xLeft,this._xRight=t.xRight},o})(),Kt=(function(){function o(i,t,e){this.controller=i,this.color=e,this.isPageBreak=!1,this.xLeft=t.xLeft,this.xRight=t.xRight,this.yTop=t.yTop,this.yBot=t.yBot}return Object.defineProperty(o.prototype,"width",{get:function(){return this.xRight-this.xLeft},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"height",{get:function(){return this.yBot-this.yTop},enumerable:!1,configurable:!0}),o.prototype.render=function(){return F(this,void 0,void 0,function(){var i;return T(this,function(t){return this.color!==null&&(i=this.controller.doc.getDrawColor(),this.controller.doc.setDrawColor(this.color),this.controller.doc.line(this.xLeft,this.yTop,this.xRight,this.yTop),this.controller.doc.setDrawColor(i)),[2]})})},o.prototype.unfold=function(){return[this]},o.prototype.translateX=function(i){},o})(),ae=(function(){function o(i,t,e,r,n){this.point=i,this.bricks=t,this.controller=e,this.repository=r,this.module=n}return o})(),ei=(function(o){H(i,o);function i(t,e,r,n,a,s){var u=o.call(this,t,e,n,a,s)||this;return u.question=r,u}return i})(ae),ii=(function(o){H(i,o);function i(t,e,r,n,a,s){var u=o.call(this,t,e,n,a,s)||this;return u.panel=r,u}return i})(ae),ni=(function(o){H(i,o);function i(t,e,r,n,a,s){var u=o.call(this,t,e,n,a,s)||this;return u.page=r,u}return i})(ae),Dt=(function(){function o(){}return o.generateFlatsPanel=function(i,t,e,r){return F(this,void 0,void 0,function(){var n,a,s,u,l,f;return T(this,function(d){switch(d.label){case 0:return n=[],a=h.clone(r),t.pushMargins(),t.margins.left+=t.measureText(e.innerIndent).width,a.xLeft+=t.measureText(e.innerIndent).width,u=(s=n.push).apply,l=[n],[4,this.generateFlatsPagePanel(i,t,e,a)];case 1:return u.apply(s,l.concat([d.sent()])),t.popMargins(),f=new ii(r,n,e,t,Q.getInstance(),re),[4,i.onRenderPanel.fire(i,f)];case 2:return d.sent(),[2,_t([],f.bricks,!0)]}})})},o.generateFlatsPagePanel=function(i,t,e,r){return F(this,void 0,void 0,function(){var n,a,s,u,l,f,d,b,x,P,S,k,et,K,V,X,bt,kt,W,w,p,C,v;return T(this,function(B){switch(B.label){case 0:return e.isVisible?(e.onFirstRendering(),n=[],a=h.clone(r),e.getType()!=="page"||i.showPageTitles?(s=new D,e.title?e instanceof tt.PanelModel&&e.no?[4,h.createTitlePanelFlat(a,t,e.no,e.getType()==="page")]:[3,2]:[3,4]):[3,7]):[2];case 1:u=B.sent(),s.addBrick(u),a.xLeft=u.xRight+t.measureText(" ").width,B.label=2;case 2:return[4,h.createTitlePanelFlat(a,t,e.locTitle,e.getType()==="page")];case 3:l=B.sent(),s.addBrick(l),a=h.createPoint(l),B.label=4;case 4:return e.description?(e.title&&(a.yTop+=t.unitWidth*o.PANEL_DESC_GAP_SCALE),[4,h.createDescFlat(a,null,t,e.locDescription)]):[3,6];case 5:f=B.sent(),s.addBrick(f),a=h.createPoint(f),B.label=6;case 6:s.isEmpty||(d=h.createPoint(s),s.addBrick(h.createRowlineFlat(d,t)),n.push(s),a.yTop+=t.unitHeight*o.PANEL_CONT_GAP_SCALE+h.EPSILON),B.label=7;case 7:b=0,x=e.rows,B.label=8;case 8:if(!(b<x.length))return[3,17];if(P=x[b],!P.visible)return[3,16];t.pushMargins(),S=h.getPageAvailableWidth(t),k=t.margins.left,et=[],K=P.elements.filter(function(E){return E.isVisible}),V=0,B.label=9;case 9:return V<K.length?(X=K[V],X.isVisible?(bt=h.parseWidth(X.renderWidth,S-(K.length-1)*t.unitWidth,K.length),t.margins.left=k+(V!==0?t.unitWidth:0),t.margins.right=t.paperWidth-t.margins.left-bt,a.xLeft=t.margins.left,k=t.margins.left+bt,X instanceof tt.PanelModel?(W=(kt=et.push).apply,w=[et],[4,this.generateFlatsPanel(i,t,X,a)]):[3,11]):[3,14]):[3,15];case 10:return W.apply(kt,w.concat([B.sent()])),[3,14];case 11:return[4,X.waitForQuestionIsReady()];case 12:return B.sent(),C=(p=et.push).apply,v=[et],[4,h.generateQuestionFlats(i,t,X,a)];case 13:C.apply(p,v.concat([B.sent()])),B.label=14;case 14:return V++,[3,9];case 15:t.popMargins(),a.xLeft=t.margins.left,et.length!==0&&(a.yTop=h.mergeRects.apply(h,et).yBot,a.xLeft=r.xLeft,a.yTop+=t.unitHeight*o.QUES_GAP_VERT_SCALE,n.push.apply(n,et),n.push(h.createRowlineFlat(a,t)),a.yTop+=h.EPSILON),B.label=16;case 16:return b++,[3,8];case 17:return[2,n]}})})},o.popRowlines=function(i){for(;i.length>0&&i[i.length-1]instanceof Kt;)i.pop()},o.generateFlatTitle=function(i,t,e){return F(this,void 0,void 0,function(){var r,n,a,s;return T(this,function(u){switch(u.label){case 0:return r=new D,i.showTitle?i.title?[4,h.createTitleSurveyFlat(e,t,i.locTitle)]:[3,2]:[3,4];case 1:n=u.sent(),r.addBrick(n),e=h.createPoint(n),u.label=2;case 2:return i.description?(i.title&&(e.yTop+=t.unitWidth*o.PANEL_DESC_GAP_SCALE),s=(a=r).addBrick,[4,h.createDescFlat(e,null,t,i.locDescription)]):[3,4];case 3:s.apply(a,[u.sent()]),u.label=4;case 4:return[2,r]}})})},o.generateFlatLogoImage=function(i,t,e){return F(this,void 0,void 0,function(){var r,n,a,s;return T(this,function(u){switch(u.label){case 0:return r=h.getLocString(i.locLogo),[4,h.getCorrectedImageSize(t,{imageLink:r,imageHeight:i.logoHeight,imageWidth:i.logoWidth,defaultImageWidth:"300px",defaultImageHeight:"200px"})];case 1:return n=u.sent(),[4,h.createImageFlat(e,null,t,{link:r,width:n.width,height:n.height})];case 2:return a=u.sent(),s=0,i.logoPosition==="right"?s=h.getPageAvailableWidth(t)-a.width:i.logoPosition!=="left"&&(s=h.getPageAvailableWidth(t)/2-a.width/2),a.xLeft+=s,a.xRight+=s,[2,a]}})})},o.generateFlats=function(i,t){return F(this,void 0,void 0,function(){var e,n,s,r,n,s,n,n,a,s,u,l,f,d,b,x,P,S;return T(this,function(k){switch(k.label){case 0:return e=[],i.hasLogo?[3,2]:[4,this.generateFlatTitle(i,t,t.leftTopPoint)];case 1:return n=k.sent(),n.isEmpty||e.push([n]),[3,11];case 2:return i.isLogoBefore?[4,this.generateFlatLogoImage(i,t,t.leftTopPoint)]:[3,5];case 3:return s=k.sent(),e.push([s]),r=h.createPoint(s,i.logoPosition==="top",i.logoPosition!=="top"),i.logoPosition!=="top"?(t.pushMargins(),r.xLeft+=t.unitWidth,t.margins.left+=s.width+t.unitWidth):(r.xLeft=t.leftTopPoint.xLeft,r.yTop+=t.unitHeight/2),[4,this.generateFlatTitle(i,t,r)];case 4:return n=k.sent(),i.logoPosition!=="top"&&t.popMargins(),n.isEmpty||e[0].push(n),[3,11];case 5:return i.logoPosition!=="right"?[3,8]:[4,this.generateFlatLogoImage(i,t,t.leftTopPoint)];case 6:return s=k.sent(),e.push([s]),t.pushMargins(),t.margins.right+=s.width+t.unitWidth,[4,this.generateFlatTitle(i,t,t.leftTopPoint)];case 7:return n=k.sent(),n.isEmpty||e[0].unshift(n),t.popMargins(),[3,11];case 8:return[4,this.generateFlatTitle(i,t,t.leftTopPoint)];case 9:return n=k.sent(),a=t.leftTopPoint,n.isEmpty||(e.push([n]),a=h.createPoint(n),a.yTop+=t.unitHeight/2),[4,this.generateFlatLogoImage(i,t,a)];case 10:s=k.sent(),e.length!==0?e[0].push(s):e.push([s]),k.label=11;case 11:u=t.leftTopPoint,e.length!==0&&(u.yTop=h.createPoint(h.mergeRects.apply(h,e[0])).yTop,e[0].push(h.createRowlineFlat(u,t)),u.yTop+=t.unitHeight*o.PANEL_CONT_GAP_SCALE+h.EPSILON),l=0,k.label=12;case 12:return l<i.visiblePages.length?(i.currentPage=i.visiblePages[l],f=[],b=(d=f.push).apply,x=[f],[4,this.generateFlatsPagePanel(i,t,i.visiblePages[l],u)]):[3,16];case 13:return b.apply(d,x.concat([k.sent()])),P=new ni(u,f,i.visiblePages[l],t,Q.getInstance(),re),[4,i.onRenderPage.fire(i,P)];case 14:k.sent(),f=_t([],P.bricks,!0),l===0&&e.length!==0?(S=e[0]).push.apply(S,f):e.push(f),this.popRowlines(e[e.length-1]),u.yTop=t.leftTopPoint.yTop,k.label=15;case 15:return l++,[3,12];case 16:return[2,e]}})})},o.QUES_GAP_VERT_SCALE=1.5,o.PANEL_CONT_GAP_SCALE=1,o.PANEL_DESC_GAP_SCALE=.25,o})(),mt=(function(){function o(i,t,e){this.question=i,this.controller=t,this.textColor=h.TEXT_COLOR,this.formBorderColor=h.FORM_BORDER_COLOR,this.isPageBreak=!1,this.xLeft=e.xLeft,this.xRight=e.xRight,this.yTop=e.yTop,this.yBot=e.yBot,this.fontSize=t?t.fontSize:Lt.FONT_SIZE}return Object.defineProperty(o.prototype,"xLeft",{get:function(){return this._xLeft},set:function(i){this.setXLeft(i)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"xRight",{get:function(){return this._xRight},set:function(i){this.setXRight(i)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"yTop",{get:function(){return this._yTop},set:function(i){this.setYTop(i)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"yBot",{get:function(){return this._yBot},set:function(i){this.setYBottom(i)},enumerable:!1,configurable:!0}),o.prototype.translateX=function(i){var t=i(this.xLeft,this.xRight);this.xLeft=t.xLeft,this.xRight=t.xRight},Object.defineProperty(o.prototype,"width",{get:function(){return this.xRight-this.xLeft},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"height",{get:function(){return this.yBot-this.yTop},enumerable:!1,configurable:!0}),o.prototype.getShouldRenderReadOnly=function(){return h.shouldRenderReadOnly(this.question,this.controller)},o.prototype.render=function(){return F(this,void 0,void 0,function(){return T(this,function(i){switch(i.label){case 0:return this.getShouldRenderReadOnly()?[4,this.renderReadOnly()]:[3,2];case 1:return i.sent(),[3,4];case 2:return[4,this.renderInteractive()];case 3:i.sent(),i.label=4;case 4:return this.afterRenderCallback&&this.afterRenderCallback(),[2]}})})},o.prototype.renderInteractive=function(){return F(this,void 0,void 0,function(){return T(this,function(i){return[2]})})},o.prototype.renderReadOnly=function(){return F(this,void 0,void 0,function(){return T(this,function(i){switch(i.label){case 0:return[4,this.renderInteractive()];case 1:return i.sent(),[2]}})})},o.prototype.unfold=function(){return[this]},o.prototype.getCorrectedText=function(i){return this.controller.isRTL?(i||"").split("").reverse().join(""):i},o.prototype.setXLeft=function(i){this._xLeft=i},o.prototype.setXRight=function(i){this._xRight=i},o.prototype.setYTop=function(i){this._yTop=i},o.prototype.setYBottom=function(i){this._yBot=i},o})(),nt=(function(o){H(i,o);function i(t,e,r,n){var a=o.call(this,t,e,r)||this;return a.text=n,a.align={isInputRtl:!1,isOutputRtl:e.isRTL,align:e.isRTL?"right":"left",baseline:"middle"},a}return i.prototype.escapeText=function(){for(;this.text.indexOf(" ")>-1;)this.text=this.text.replace(" ",Array(5).join("\xA0"));return this.text},i.prototype.renderInteractive=function(){return F(this,void 0,void 0,function(){var t,e,r;return T(this,function(n){return t=this.alignPoint(this),e=this.controller.fontSize,this.controller.fontSize=this.fontSize,r=this.controller.doc.getTextColor(),this.controller.doc.setTextColor(this.textColor),this.controller.doc.text(this.escapeText(),t.xLeft,t.yTop,this.align),this.controller.doc.setTextColor(r),this.controller.fontSize=e,[2]})})},i.prototype.alignPoint=function(t){return{xLeft:this.controller.isRTL?t.xRight:t.xLeft,yTop:t.yTop+(t.yBot-t.yTop)/2}},i})(mt),ot=(function(){function o(i,t,e){this.survey=i,this.controller=e,this.question=t}return o.prototype.generateFlatTitle=function(i){return F(this,void 0,void 0,function(){return T(this,function(t){switch(t.label){case 0:return[4,h.createTitleFlat(i,this.question,this.controller)];case 1:return[2,t.sent()]}})})},o.prototype.generateFlatDescription=function(i){return F(this,void 0,void 0,function(){return T(this,function(t){switch(t.label){case 0:return[4,h.createDescFlat(i,this.question,this.controller,this.question.locDescription)];case 1:return[2,t.sent()]}})})},o.prototype.generateFlatHeader=function(i){return F(this,void 0,void 0,function(){var t,e,r,n,a;return T(this,function(s){switch(s.label){case 0:return[4,this.generateFlatTitle(i)];case 1:return t=s.sent(),e=new D(t),this.question.hasDescriptionUnderTitle?(r=h.createPoint(t,!0,!1),r.yTop+=o.DESC_GAP_SCALE*this.controller.unitHeight,r.xLeft+=this.controller.unitWidth*o.CONTENT_INDENT_SCALE,a=(n=e).addBrick,[4,this.generateFlatDescription(r)]):[3,3];case 2:a.apply(n,[s.sent()]),s.label=3;case 3:return[2,e]}})})},o.prototype.generateFlatsComment=function(i){return F(this,void 0,void 0,function(){var t,e,r,n,a;return T(this,function(s){switch(s.label){case 0:return t=this.question.locCommentText,[4,h.createTextFlat(i,this.question,this.controller,t,nt)];case 1:return e=s.sent(),r=h.createPoint(e),r.yTop+=this.controller.unitHeight*h.GAP_BETWEEN_ROWS,n=D.bind,a=[void 0,e],[4,h.createCommentFlat(r,this.question,this.controller,{fieldName:this.question.id+"_comment",rows:h.OTHER_ROWS_COUNT,value:this.question.comment!==void 0&&this.question.comment!==null?this.question.comment:"",shouldRenderBorders:tt.settings.readOnlyCommentRenderMode==="textarea",isReadOnly:this.question.isReadOnly,isMultiline:!0,placeholder:""})];case 2:return[2,new(n.apply(D,a.concat([s.sent()])))]}})})},o.prototype.generateFlatsComposite=function(i){return F(this,void 0,void 0,function(){var t;return T(this,function(e){switch(e.label){case 0:return t=this.question.contentPanel,t?[4,Dt.generateFlatsPanel(this.survey,this.controller,t,i)]:[3,2];case 1:return[2,e.sent()];case 2:return this.question=h.getContentQuestion(this.question),[4,this.generateFlatsContent(i)];case 3:return[2,e.sent()]}})})},o.prototype.generateFlatsContent=function(i){return F(this,void 0,void 0,function(){return T(this,function(t){return[2,null]})})},o.prototype.generateFlatsContentWithOptionalElements=function(i){return F(this,void 0,void 0,function(){var t,e,r,n,a,s,u,l=this;return T(this,function(f){switch(f.label){case 0:return t=[],[4,this.generateFlatsComposite(i)];case 1:return e=f.sent(),Array.isArray(e)&&t.push.apply(t,e),r=function(){var d=h.clone(i);return e!==null&&e.length!==0&&(d.yTop=h.mergeRects.apply(h,t).yBot+l.controller.unitHeight*h.GAP_BETWEEN_ROWS),d},this.question.hasComment?(a=(n=t).push,[4,this.generateFlatsComment(r())]):[3,3];case 2:a.apply(n,[f.sent()]),f.label=3;case 3:return this.question.hasDescriptionUnderInput?(u=(s=t).push,[4,this.generateFlatDescription(r())]):[3,5];case 4:u.apply(s,[f.sent()]),f.label=5;case 5:return[2,t]}})})},o.prototype.generateFlats=function(i){return F(this,void 0,void 0,function(){var t,e,r,n,l,d,f,d,f,a,s,u,l,d,f,d,b,x,P;return T(this,function(S){switch(S.label){case 0:switch(this.controller.pushMargins(),this.controller.margins.left+=this.controller.measureText(this.question.indent).width,t={xLeft:i.xLeft+this.controller.measureText(this.question.indent).width,yTop:i.yTop},e=[],r=this.question.getTitleLocation(),r=this.question.hasTitle?r:"hidden",n=r,n){case"top":return[3,1];case"default":return[3,1];case"bottom":return[3,4];case"left":return[3,7];case"hidden":return[3,10];case h.TITLE_LOCATION_MATRIX:return[3,10]}return[3,10];case 1:return[4,this.generateFlatHeader(t)];case 2:return l=S.sent(),d=h.createPoint(l),d.xLeft+=this.controller.unitWidth*o.CONTENT_INDENT_SCALE,l.addBrick(h.createRowlineFlat(h.createPoint(l),this.controller)),d.yTop+=this.controller.unitHeight*o.CONTENT_GAP_VERT_SCALE+h.EPSILON,this.controller.pushMargins(),this.controller.margins.left+=this.controller.unitWidth*o.CONTENT_INDENT_SCALE,[4,this.generateFlatsContentWithOptionalElements(d)];case 3:return f=S.sent(),this.controller.popMargins(),f!==null&&f.length!==0&&l.addBrick(f.shift()),e.push(l),e.push.apply(e,f),[3,12];case 4:return d=h.clone(t),this.controller.pushMargins(),d.xLeft+=this.controller.unitWidth*o.CONTENT_INDENT_SCALE,this.controller.margins.left+=this.controller.unitWidth*o.CONTENT_INDENT_SCALE,[4,this.generateFlatsContentWithOptionalElements(d)];case 5:return f=S.sent(),this.controller.popMargins(),e.push.apply(e,f),a=t,e.length!==0&&(a.yTop=e[e.length-1].yBot),a.yTop+=this.controller.unitHeight*o.CONTENT_GAP_VERT_SCALE,u=(s=e).push,[4,this.generateFlatHeader(a)];case 6:return u.apply(s,[S.sent()]),[3,12];case 7:return this.controller.pushMargins(this.controller.margins.left,this.controller.paperWidth-this.controller.margins.left-h.getPageAvailableWidth(this.controller)*h.MULTIPLETEXT_TEXT_PERS),[4,this.generateFlatHeader(t)];case 8:return l=S.sent(),d=h.createPoint(l,!1,!0),this.controller.popMargins(),d.xLeft+=this.controller.unitWidth*o.CONTENT_GAP_HOR_SCALE,this.controller.margins.left=d.xLeft,[4,this.generateFlatsContentWithOptionalElements(d)];case 9:return f=S.sent(),f!==null&&f.length!==0&&l.addBrick(f.shift()),e.push(l),e.push.apply(e,f),[3,12];case 10:return d=h.clone(t),this.controller.pushMargins(),r!==h.TITLE_LOCATION_MATRIX&&(d.xLeft+=this.controller.unitWidth*o.CONTENT_INDENT_SCALE,this.controller.margins.left+=this.controller.unitWidth*o.CONTENT_INDENT_SCALE),x=(b=e.push).apply,P=[e],[4,this.generateFlatsContentWithOptionalElements(d)];case 11:return x.apply(b,P.concat([S.sent()])),this.controller.popMargins(),[3,12];case 12:return this.controller.popMargins(),[2,e]}})})},Object.defineProperty(o.prototype,"shouldRenderAsComment",{get:function(){return h.shouldRenderReadOnly(this.question,this.controller)},enumerable:!1,configurable:!0}),o.CONTENT_GAP_VERT_SCALE=.5,o.CONTENT_GAP_HOR_SCALE=1,o.CONTENT_INDENT_SCALE=1,o.DESC_GAP_SCALE=.0625,o})();tt.Serializer.addProperty("question",{name:"readonlyRenderAs",default:"auto",choices:["auto","text","acroform"],visible:!1});var se=(function(o){H(i,o);function i(){return o!==null&&o.apply(this,arguments)||this}return i.prototype.generateFlatsContent=function(t){return F(this,void 0,void 0,function(){var e;return T(this,function(r){switch(r.label){case 0:return[4,h.createTextFlat(t,this.question,this.controller,"".concat(this.question.displayValue),nt)];case 1:return e=r.sent(),[2,[e]]}})})},i})(ot),Q=(function(){function o(){this.questions={}}return o.getInstance=function(){return o.instance},o.prototype.register=function(i,t){this.questions[i]=t},o.prototype.isTypeRegistered=function(i){return!!this.questions[i]},o.prototype.getRenderer=function(i){return this.questions[i]},o.prototype.create=function(i,t,e,r){var n,a=typeof r>"u"?t.getType():r,s=this.getRenderer(a);return s||(!((n=t.customWidget)===null||n===void 0)&&n.pdfRender?s=ot:s=se),new s(i,t,e)},o.register=function(i,t){this.getInstance().register(i,t)},o.getRenderer=function(i){return this.getInstance().getRenderer(i)},o.instance=new o,o})(),jt=(function(o){H(i,o);function i(t,e,r,n){return o.call(this,t,e,r,n)||this}return i.prototype.renderInteractive=function(){return F(this,void 0,void 0,function(){return T(this,function(t){switch(t.label){case 0:return this.controller.fontStyle="bold",[4,o.prototype.renderInteractive.call(this)];case 1:return t.sent(),this.controller.fontStyle="normal",[2]}})})},i})(nt),le=(function(o){H(i,o);function i(t,e,r,n){return o.call(this,t,e,r,n)||this}return i.prototype.renderInteractive=function(){return F(this,void 0,void 0,function(){var t;return T(this,function(e){switch(e.label){case 0:return t=this.controller.fontSize,this.controller.fontSize=t*h.TITLE_PANEL_FONT_SIZE_SCALE,[4,o.prototype.renderInteractive.call(this)];case 1:return e.sent(),this.controller.fontSize=t,[2]}})})},i})(jt),ri=(function(o){H(i,o);function i(t,e,r,n){return o.call(this,t,e,r,n)||this}return i})(nt),Qt=(function(o){H(i,o);function i(t,e){var r=o.call(this,t.question,t.controller,t,t.text)||this;return r.link=e,r.textColor=i.COLOR,r}return i.prototype.renderInteractive=function(){return F(this,void 0,void 0,function(){var t,e,r;return T(this,function(n){switch(n.label){case 0:return t=this.controller.doc.getTextColor(),this.controller.doc.setTextColor(h.BACKGROUND_COLOR),e=this.controller.unitHeight*(this.controller.doc.getLineHeightFactor()-i.SCALE_FACTOR_MAGIC),r=this.yTop+(this.yBot-this.yTop)-e,this.controller.doc.textWithLink(this.text,this.xLeft,r,{url:this.link}),[4,o.prototype.renderInteractive.call(this)];case 1:return n.sent(),this.controller.doc.setTextColor(t),[2]}})})},i.prototype.renderReadOnly=function(){return F(this,void 0,void 0,function(){return T(this,function(t){switch(t.label){case 0:return h.getReadonlyRenderAs(this.question,this.controller)!=="text"?[2,this.renderInteractive()]:[4,o.prototype.renderInteractive.call(this)];case 1:return t.sent(),[2]}})})},i.SCALE_FACTOR_MAGIC=.955,i.COLOR="#0000EE",i})(nt),ue=(function(o){H(i,o);function i(t,e,r,n,a){a===void 0&&(a=!1);var s=o.call(this,t,e,r)||this;return s.html=n,a?s.margins={top:0,bottom:0}:s.margins={top:e.margins.top,bottom:e.margins.bot},s}return i.prototype.renderInteractive=function(){return F(this,void 0,void 0,function(){var t,e=this;return T(this,function(r){switch(r.label){case 0:return t=this.controller.fontSize,this.controller.fontSize=this.fontSize,[4,new Promise(function(n){e.controller.doc.fromHTML(e.html,e.xLeft,e.yTop,{width:e.width,pagesplit:!0},function(){[].slice.call(document.querySelectorAll(".sjs-pdf-hidden-html-div")).forEach(function(a){a.parentNode.removeChild(a)}),n()},e.margins)})];case 1:return r.sent(),this.controller.fontSize=t,[2]}})})},i})(mt),he=(function(o){H(i,o);function i(t,e,r,n,a,s,u,l,f){var d=o.call(this,t,e,{xLeft:n.xLeft,xRight:n.xLeft+(a||0),yTop:n.yTop,yBot:n.yTop+(s||0)})||this;return d.image=r,d.targetWidth=a,d.targetHeight=s,d.imageWidth=u,d.imageHeight=l,d.imageId=f,d.imageWidth=d.imageWidth||d.targetWidth,d.imageHeight=d.imageHeight||d.targetHeight,d.isPageBreak=d.targetHeight===void 0,d}return i.prototype.renderInteractive=function(){return F(this,void 0,void 0,function(){var t,e,r=this;return T(this,function(n){switch(n.label){case 0:return t=this.targetWidth>this.imageWidth?this.xLeft+(this.targetWidth-this.imageWidth)/2:this.xLeft,e=this.targetHeight>this.imageHeight?this.yTop+(this.targetHeight-this.imageHeight)/2:this.yTop,[4,new Promise(function(a){try{r.controller.doc.addImage(r.image,"PNG",t,e,Math.min(r.imageWidth,r.targetWidth),Math.min(r.imageHeight,r.targetHeight),r.imageId,"MEDIUM")}finally{a()}})];case 1:return n.sent(),[2]}})})},i})(mt),Ht=(function(o){H(i,o);function i(t,e,r){e===void 0&&(e=null),r===void 0&&(r=!1);var n=o.call(this,null,e,t)||this;return n.controller=e,n.isBorderVisible=!1,n.isBorderVisible=r,n}return i.prototype.resizeBorder=function(t){var e=t?1:-1,r=this.controller.doc.getFontSize()*h.VALUE_READONLY_PADDING_SCALE;this.xLeft-=e*r,this.xRight+=e*r,this.yBot+=e*r},i.prototype.renderInteractive=function(){return F(this,void 0,void 0,function(){return T(this,function(t){return this.isBorderVisible&&(this.resizeBorder(!0),h.renderFlatBorders(this.controller,this),this.resizeBorder(!1)),[2]})})},i})(mt),Vt=(function(o){H(i,o);function i(t,e,r,n){var a,s,u,l,f=o.call(this,t,e,r)||this;return f.question=t,f.options=n,n.isMultiline=(a=n.isMultiline)!==null&&a!==void 0?a:!1,n.placeholder=(s=n.placeholder)!==null&&s!==void 0?s:"",n.inputType=(u=n.inputType)!==null&&u!==void 0?u:"",n.value=(l=n.value)!==null&&l!==void 0?l:"",f.question=t,f}return i.prototype.renderColorQuestion=function(){var t=this.controller.doc.getFillColor();this.controller.doc.setFillColor(this.question.value||"black"),this.controller.doc.rect(this.xLeft,this.yTop,this.width,this.height,"F"),this.controller.doc.setFillColor(t)},i.prototype.renderInteractive=function(){return F(this,void 0,void 0,function(){var t,e;return T(this,function(r){return this.options.inputType==="color"?(this.renderColorQuestion(),[2]):(t=this.options.inputType==="password"?new this.controller.doc.AcroFormPasswordField:new this.controller.doc.AcroFormTextField,t.fieldName=this.options.fieldName,t.fontName=this.controller.fontName,t.fontSize=this.fontSize,t.isUnicode=h.isCustomFont(this.controller,t.fontName),this.options.inputType!=="password"?(t.V=" "+this.getCorrectedText(this.options.value),t.DV=" "+this.getCorrectedText(this.options.placeholder)):t.value="",t.multiline=this.options.isMultiline,t.readOnly=this.options.isReadOnly,t.color=this.textColor,e=h.formScale(this.controller,this),t.maxFontSize=this.controller.fontSize*e,t.Rect=h.createAcroformRect(h.scaleRect(this,e)),this.controller.doc.addField(t),h.renderFlatBorders(this.controller,this),[2])})})},i.prototype.shouldRenderFlatBorders=function(){return this.options.shouldRenderBorders},i.prototype.getShouldRenderReadOnly=function(){return h.shouldRenderReadOnly(this.question,this.controller,this.options.isReadOnly)},Object.defineProperty(i.prototype,"textBrick",{get:function(){return this._textBrick},set:function(t){var e=this;this._textBrick=t;var r=t.unfold(),n=r.length,a=0,s={},u=function(l){if(e.shouldRenderFlatBorders()){a++;var f=e.controller.getCurrentPageIndex();if(s[f]||(s[f]=[]),s[f].push(l),a>=n){var d=Object.keys(s),b=d.length==1;d.forEach(function(x){var P=new D;s[x].forEach(function(et){P.addBrick(et)});var S=e.controller.unitHeight*h.VALUE_READONLY_PADDING_SCALE,k={xLeft:e.xLeft,xRight:e.xRight,width:e.width,yTop:b?e.yTop:P.yTop-S,yBot:b?e.yBot:P.yBot+S,height:b?e.height:P.height+2*S,formBorderColor:e.formBorderColor};e.controller.setPage(Number(x)),h.renderFlatBorders(e.controller,k),e.controller.setPage(f)})}}};r.forEach(function(l){l.afterRenderCallback=u.bind(e,l)})},enumerable:!1,configurable:!0}),i.prototype.renderReadOnly=function(){return F(this,void 0,void 0,function(){return T(this,function(t){switch(t.label){case 0:return this.controller.pushMargins(this.xLeft,this.controller.paperWidth-this.xRight),this.options.inputType!=="color"?[3,1]:(this.renderColorQuestion(),[3,3]);case 1:return[4,this.textBrick.render()];case 2:t.sent(),t.label=3;case 3:return this.controller.popMargins(),[2]}})})},i.prototype.unfold=function(){return this.getShouldRenderReadOnly()&&this.options.inputType!=="color"?this.textBrick.unfold():o.prototype.unfold.call(this)},i.prototype.translateX=function(t){var e=t(this.xLeft,this.xRight);this._xLeft=e.xLeft,this._xRight=e.xRight,this.textBrick&&this.textBrick.translateX(t)},i.prototype.setXLeft=function(t){var e=t-this._xLeft;o.prototype.setXLeft.call(this,t),this.textBrick&&(this.textBrick.xLeft=this.textBrick.xLeft+e)},i.prototype.setXRight=function(t){var e=t-this._xRight;o.prototype.setXRight.call(this,t),this.textBrick&&(this.textBrick.xRight=this.textBrick.xRight+e)},i.prototype.setYTop=function(t){var e=t-this._yTop;o.prototype.setYTop.call(this,t),this.textBrick&&(this.textBrick.yTop=this.textBrick.yTop+e)},i.prototype.setYBottom=function(t){var e=t-this._yBot;o.prototype.setYBottom.call(this,t),this.textBrick&&(this.textBrick.yBot=this.textBrick.yBot+e)},i})(mt),De=(function(){function o(){this.hash={},this.imageId=1}return o.prototype.getImageId=function(){return"image_".concat(this.imageId++)},o.prototype._getImageInfo=function(i){return F(this,void 0,void 0,function(){return T(this,function(t){return[2,{data:i,width:0,height:0,id:this.getImageId()}]})})},o.prototype.getImageInfo=function(i){return F(this,void 0,void 0,function(){var t,e;return T(this,function(r){switch(r.label){case 0:if(this.hash[i])return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),t=this.hash,e=i,[4,this._getImageInfo(i)];case 2:return t[e]=r.sent(),[3,4];case 3:return r.sent(),this.hash[i]=this.emptyImage,[3,4];case 4:return[2,this.hash[i]]}})})},o.prototype.applyImageFit=function(i,t,e,r){return F(this,void 0,void 0,function(){var n;return T(this,function(a){return t=="fill"?[2,{data:i.data,id:i.id,width:e,height:r}]:(t=="contain"||t=="cover")&&i.width&&i.height&&e&&e?(n=Math.min(e/i.width,r/i.height),[2,{data:i.data,id:i.id,width:i.width*n,height:i.height*n}]):[2,i]})})},Object.defineProperty(o.prototype,"emptyImage",{get:function(){return{data:"",width:0,height:0,id:"image_0"}},enumerable:!1,configurable:!0}),o.prototype.clear=function(){this.hash={},this.imageId=1},o})(),He=new De;function ce(){return He}function oi(o){He=o}var h=(function(){function o(){}return o.parseWidth=function(i,t,e,r){if(e===void 0&&(e=1),i.indexOf("calc")===0)return t/e;var n=parseFloat(i),a=i.replace(/[^A-Za-z%]/g,"")||r,s;switch(a){case"pt":s=1;break;case"mm":s=72/25.4;break;case"cm":s=72/2.54;break;case"in":s=72;break;case"px":s=72/96;break;case"pc":s=12;break;case"em":s=12;break;case"ex":s=6;break;default:case"%":s=t/100;break}return Math.min(n*s,t)},o.pxToPt=function(i){return typeof i=="string"?(isNaN(Number(i))||(i+="px"),o.parseWidth(i,Number.MAX_VALUE)):i*72/96},o.mergeRects=function(){for(var i=[],t=0;t<arguments.length;t++)i[t]=arguments[t];var e={xLeft:i[0].xLeft,xRight:i[0].xRight,yTop:i[0].yTop,yBot:i[0].yBot};return i.forEach(function(r){e.xLeft=Math.min(e.xLeft,r.xLeft),e.xRight=Math.max(e.xRight,r.xRight),e.yTop=Math.min(e.yTop,r.yTop),e.yBot=Math.max(e.yBot,r.yBot)}),e},o.createPoint=function(i,t,e){return t===void 0&&(t=!0),e===void 0&&(e=!1),{xLeft:t?i.xLeft:i.xRight,yTop:e?i.yTop:i.yBot}},o.createRect=function(i,t,e){return{xLeft:i.xLeft,xRight:i.xLeft+t,yTop:i.yTop,yBot:i.yTop+e}},o.createHeaderRect=function(i){return{xLeft:0,xRight:i.paperWidth,yTop:0,yBot:i.margins.top}},o.createFooterRect=function(i){return{xLeft:0,xRight:i.paperWidth,yTop:i.paperHeight-i.margins.bot,yBot:i.paperHeight}},o.chooseHtmlFont=function(i){return i.useCustomFontInHtml?i.fontName:this.STANDARD_FONT},o.generateCssTextRule=function(i,t,e){return'"font-size: '.concat(i,"pt; font-weight: ").concat(t,"; font-family: ").concat(e,"; color: ").concat(this.TEXT_COLOR,'; margin: 0"')},o.createHtmlContainerBlock=function(i,t,e){var r=this.chooseHtmlFont(t);return'<div class="__surveypdf_html" style='.concat(this.generateCssTextRule(t.fontSize,t.fontStyle,r),">")+"<style>.__surveypdf_html p { margin: 0; line-height: ".concat(t.fontSize,"pt } body { margin: 0; }</style>").concat(i,"</div>")},o.splitHtmlRect=function(i,t){var e=[],r=t.height,n=i.doc.getFontSize();t.yBot=t.yTop+n;var a=Math.floor(r/n)-1;e.push(t);for(var s=this.createPoint(t),u=0;u<a;u++)e.push(new Ht(this.createRect(s,t.width,n))),s.yTop+=n;var l=r-(a+1)*n;return l>0&&e.push(new Ht(this.createRect(s,t.width,l))),new(D.bind.apply(D,_t([void 0],e,!1)))},o.createPlainTextFlat=function(i,t,e,r,n){var a=this,s=e.doc.splitTextToSize(r,e.paperWidth-e.margins.right-i.xLeft),u=this.clone(i),l=new D;return s.forEach(function(f){var d=e.measureText(f);l.addBrick(new n(t,e,a.createRect(u,d.width,d.height),f)),u.yTop+=d.height}),l},o.createTextFlat=function(i,t,e,r,n){return F(this,void 0,void 0,function(){var a,s;return T(this,function(u){switch(u.label){case 0:return typeof r=="string"||!this.hasHtml(r)?[2,this.createPlainTextFlat(i,t,e,typeof r=="string"?r:this.getLocString(r),n)]:[3,1];case 1:return a=this.splitHtmlRect,s=[e],[4,this.createHTMLFlat(i,t,e,this.createHtmlContainerBlock(this.getLocString(r),e,"standard"))];case 2:return[2,a.apply(this,s.concat([u.sent()]))]}})})},o.hasHtml=function(i){var t=/<\/?[a-z][\s\S]*>/i;return i.hasHtml&&(t.test(i.renderedText)||t.test(i.renderedHtml))},o.getHtmlMargins=function(i,t){var e=i.paperWidth-t.xLeft-i.margins.right;return{top:i.margins.top,bottom:i.margins.bot,width:e>i.unitWidth?e:i.unitWidth}},o.createHTMLRect=function(i,t,e,r){var n=t.paperHeight-t.margins.bot-t.margins.top,a=(t.helperDoc.getNumberOfPages()-1)*(t.fontSize*Math.floor(n/t.fontSize))+r-e.top+o.HTML_TAIL_TEXT_SCALE*t.fontSize,s=t.helperDoc.getNumberOfPages();t.helperDoc.addPage();for(var u=0;u<s;u++)t.helperDoc.deletePage(1);return o.createRect(i,e.width,a)},o.createHTMLFlat=function(i,t,e,r){return F(this,void 0,void 0,function(){var n;return T(this,function(a){switch(a.label){case 0:return n=this.getHtmlMargins(e,i),[4,new Promise(function(s){e.helperDoc.fromHTML(r,i.xLeft,n.top,{pagesplit:!0,width:n.width},function(u){var l=o.createHTMLRect(i,e,n,u.y);s(new ue(t,e,l,r))},n)})];case 1:return[2,a.sent()]}})})},o.generateFontFace=function(i,t,e){return"@font-face { font-family: ".concat(i,"; ")+"src: url(data:application/font-woff;charset=utf-8;base64,".concat(t,") format('woff'); ")+"font-weight: ".concat(e,"; }")},o.generateFontFaceWithItalicStyle=function(i,t,e){return"@font-face { font-family: ".concat(i,"; ")+"src: url(data:application/font-woff;charset=utf-8;base64,".concat(t,") format('woff'); ")+"font-weight: ".concat(e,"; font-style: italic}")},o.htmlToXml=function(i){var t=document.implementation.createHTMLDocument("");return t.write(i.replace(/\#/g,"%23")),t.documentElement.setAttribute("xmlns",t.documentElement.namespaceURI),t.body.style.margin="unset",new XMLSerializer().serializeToString(t.body).replace(/%23/g,"#")},o.createSvgContent=function(i,t,e){var r=this,n=document.createElement("style");n.innerHTML=".__surveypdf_html p { margin: unset; line-height: 22px; } body { margin: unset; }",document.body.appendChild(n);var a=document.createElement("div");a.className="__surveypdf_html",a.style.display="block",a.style.position="fixed",a.style.top="-10000px",a.style.left="-10000px",a.style.width=t/72*96+"px",a.style.boxSizing="initial",a.style.color="initial",a.style.fontFamily="initial",a.style.font="initial",a.style.lineHeight="initial",a.insertAdjacentHTML("beforeend",i),document.body.appendChild(a);var s=a.offsetWidth,u=a.offsetHeight;a.remove(),n.remove();var l="";e.useCustomFontInHtml?l="<defs><style>".concat(this.generateFontFace(e.fontName,e.base64Normal,"normal"))+" ".concat(this.generateFontFace(e.fontName,e.base64Bold,"bold"),"</style></defs>"):Object.keys(Lt.customFonts).forEach(function(d){var b=Lt.customFonts[d];Object.keys(b).forEach(function(x){x==="normal"||x==="bold"?l+="".concat(r.generateFontFace(d,b[x],x)):l+="".concat(r.generateFontFaceWithItalicStyle(d,b[x],x==="italic"?"normal":"bold"))}),l="<defs><style>"+l+"</style></defs>"});var f='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(s,'px" height="').concat(u,'px">')+l+"<style>.__surveypdf_html p { margin: unset; line-height: 22px; }</style>"+'<foreignObject width="'.concat(s,'px" height="').concat(u,'px">')+this.htmlToXml(i)+"</foreignObject></svg>";return{svg:f,divWidth:s,divHeight:u}},o.setCanvas=function(i,t,e,r){i.width=t*o.HTML_TO_IMAGE_QUALITY,i.height=e*o.HTML_TO_IMAGE_QUALITY;var n=i.getContext("2d");n.scale(o.HTML_TO_IMAGE_QUALITY,o.HTML_TO_IMAGE_QUALITY),n.fillStyle=o.BACKGROUND_COLOR,n.fillRect(0,0,t,e),n.drawImage(r,0,0)},o.htmlToImage=function(i,t,e){return F(this,void 0,void 0,function(){var r,n,a,s,u,l;return T(this,function(f){return r=o.createSvgContent(i,t,e),n=r.svg,a=r.divWidth,s=r.divHeight,u="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(n))),l=new Image,l.crossOrigin="anonymous",l.src=u,[2,new Promise(function(d){l.onload=function(){var b=document.createElement("canvas");o.setCanvas(b,a,s,l);var x=b.toDataURL("image/jpeg",o.HTML_TO_IMAGE_QUALITY);b.remove(),d({url:x,aspect:a/s})},l.onerror=function(){d({url:"data:,",aspect:t/this.EPSILON})}})]})})},o.createBoldTextFlat=function(i,t,e,r){return F(this,void 0,void 0,function(){var n;return T(this,function(a){switch(a.label){case 0:return e.fontStyle="bold",[4,this.createTextFlat(i,t,e,r,jt)];case 1:return n=a.sent(),e.fontStyle="normal",[2,n]}})})},o.createTitleFlat=function(i,t,e){return F(this,void 0,void 0,function(){var r,n,a,s,u,l,f,d,b,x,P;return T(this,function(S){switch(S.label){case 0:return r=new D,n=this.clone(i),a=e.fontSize,e.fontSize*=this.TITLE_FONT_SCALE,t.no?(s=t.no+" ",u=void 0,this.hasHtml(t.locTitle)?(e.fontStyle="bold",e.pushMargins(),e.margins.right=e.paperWidth-e.margins.left-e.measureText(s,"bold").width,[4,this.createHTMLFlat(n,t,e,this.createHtmlContainerBlock(s,e,"standard"))]):[3,2]):[3,5];case 1:return u=S.sent(),e.popMargins(),e.fontStyle="normal",[3,4];case 2:return[4,this.createBoldTextFlat(n,t,e,s)];case 3:u=S.sent(),S.label=4;case 4:r.addBrick(u),n.xLeft=u.xRight,S.label=5;case 5:return e.pushMargins(),e.margins.left=n.xLeft,[4,this.createBoldTextFlat(n,t,e,t.locTitle)];case 6:return l=S.sent(),r.addBrick(l),e.popMargins(),t.isRequired?(f=t.requiredText,this.hasHtml(t.locTitle)?(n=this.createPoint(l.unfold()[0],!1,!1),e.fontStyle="bold",e.pushMargins(),e.margins.right=e.paperWidth-e.margins.left-e.measureText(f,"bold").width,b=(d=r).addBrick,[4,this.createHTMLFlat(n,t,e,this.createHtmlContainerBlock(f,e,"standard"))]):[3,8]):[3,10];case 7:return b.apply(d,[S.sent()]),e.popMargins(),e.fontStyle="normal",[3,10];case 8:return n=this.createPoint(l.unfold().pop(),!1,!0),P=(x=r).addBrick,[4,this.createBoldTextFlat(n,t,e,f)];case 9:P.apply(x,[S.sent()]),S.label=10;case 10:return e.fontSize=a,[2,r]}})})},o.createTitleSurveyPanelFlat=function(i,t,e,r){return F(this,void 0,void 0,function(){var n,a;return T(this,function(s){switch(s.label){case 0:return n=t.fontSize,t.fontSize=n*r,t.fontStyle="bold",[4,this.createTextFlat(i,null,t,e,le)];case 1:return a=s.sent(),t.fontStyle="normal",t.fontSize=n,[2,a]}})})},o.createTitleSurveyFlat=function(i,t,e){return F(this,void 0,void 0,function(){return T(this,function(r){switch(r.label){case 0:return[4,this.createTitleSurveyPanelFlat(i,t,e,this.TITLE_SURVEY_FONT_SIZE_SCALE)];case 1:return[2,r.sent()]}})})},o.createTitlePanelFlat=function(i,t,e){return F(this,arguments,void 0,function(r,n,a,s){return s===void 0&&(s=!1),T(this,function(u){switch(u.label){case 0:return[4,this.createTitleSurveyPanelFlat(r,n,a,s?this.TITLE_PAGE_FONT_SIZE_SCALE:this.TITLE_PANEL_FONT_SIZE_SCALE)];case 1:return[2,u.sent()]}})})},o.createDescFlat=function(i,t,e,r){return F(this,void 0,void 0,function(){var n,a;return T(this,function(s){switch(s.label){case 0:return n=e.fontSize,e.fontSize=n*this.DESCRIPTION_FONT_SIZE_SCALE,[4,this.createTextFlat(i,t,e,r,ri)];case 1:return a=s.sent(),e.fontSize=n,[2,a]}})})},o.getReadonlyRenderAs=function(i,t){return i.readonlyRenderAs==="auto"?t.readonlyRenderAs:i.readonlyRenderAs},o.createCommentFlat=function(i,t,e,r){return F(this,void 0,void 0,function(){var n,a,s,u,l,f;return T(this,function(d){switch(d.label){case 0:return r.rows=(l=r.rows)!==null&&l!==void 0?l:1,r.value=(f=r.value)!==null&&f!==void 0?f:"",n=this.createTextFieldRect(i,e,r.rows),o.shouldRenderReadOnly(t,e,r.isReadOnly)?[4,this.createReadOnlyTextFieldTextFlat(i,e,t,r.value)]:[3,2];case 1:a=d.sent(),s=e.unitHeight*this.VALUE_READONLY_PADDING_SCALE,a.yBot+s>n.yBot&&(n.yBot=a.yBot+s),d.label=2;case 2:return u=new Vt(t,e,n,r),a&&(u.textBrick=a),[2,u]}})})},Object.defineProperty(o,"hasDocument",{get:function(){return typeof document<"u"},enumerable:!1,configurable:!0}),o.createImageFlat=function(i,t,e,r,n){return F(this,void 0,void 0,function(){var a,s;return T(this,function(u){switch(u.label){case 0:return a=ce(),[4,a.getImageInfo(r.link)];case 1:return s=u.sent(),n??e.applyImageFit?[4,a.applyImageFit(s,r.objectFit||"fill",r.width,r.height)]:[3,3];case 2:s=u.sent(),u.label=3;case 3:return[2,new he(t,e,s.data,i,r.width,r.height,s.width,s.height,s.id)]}})})},o.canPreviewImage=function(i,t,e){return i.canPreviewImage(t)},o.createRowlineFlat=function(i,t,e,r){var n=typeof e>"u"?t.paperWidth-t.margins.right:i.xLeft+e;return n=n>i.xLeft?n:i.xLeft+this.EPSILON,new Kt(t,{xLeft:i.xLeft,xRight:n,yTop:i.yTop+this.EPSILON,yBot:i.yTop+this.EPSILON},typeof r>"u"?null:r)},o.createLinkFlat=function(i,t,e,r,n){return F(this,void 0,void 0,function(){var a,s,u=this;return T(this,function(l){switch(l.label){case 0:return[4,this.createTextFlat(i,t,e,r,nt)];case 1:return a=l.sent(),s=new D,a.unfold().forEach(function(f){s.addBrick(new Qt(f,n));var d=u.createPoint(s);s.addBrick(u.createRowlineFlat(d,e,s.width,Qt.COLOR))}),[2,s]}})})},o.createAcroformRect=function(i){return[i.xLeft,i.yTop,i.xRight-i.xLeft,i.yBot-i.yTop]},o.createTextFieldRect=function(i,t,e){e===void 0&&(e=1);var r=t.paperWidth-i.xLeft-t.margins.right;r=Math.max(r,t.unitWidth);var n=t.unitHeight*e;return this.createRect(i,r,n)},o.createReadOnlyTextFieldTextFlat=function(i,t,e,r){return F(this,void 0,void 0,function(){var n,a;return T(this,function(s){switch(s.label){case 0:return n=t.unitWidth*this.VALUE_READONLY_PADDING_SCALE,i.yTop+=n,i.xLeft+=n,t.pushMargins(i.xLeft,t.margins.right+n),[4,this.createTextFlat(i,e,t,r.toString(),nt)];case 1:return a=s.sent(),t.popMargins(),[2,a]}})})},o.renderFlatBorders=function(i,t){var e,r,n,a,s,u;if(this.FORM_BORDER_VISIBLE){t.rounded=(n=t.rounded)!==null&&n!==void 0?n:!0,t.outside=(a=t.outside)!==null&&a!==void 0?a:!1;var l=Math.min(t.width,t.height),f=this.getBorderWidth(i),d=i.unitHeight*this.VISIBLE_BORDER_SCALE*this.BORDER_SCALE,b=t.outside?(l+f)/l-d/l:(l-f)/l+d/l,x=i.doc.getDrawColor();i.doc.setDrawColor(t.formBorderColor),i.doc.setLineWidth(d);var P=this.scaleRect(t,b);if(t.dashStyle){var S=t.dashStyle,k=(Math.abs(P.yTop-P.yBot)+Math.abs(P.xLeft-P.xRight))*2,et=S.dashArray[0]+((s=S.dashArray[1])!==null&&s!==void 0?s:S.dashArray[0]),K=S.dashArray[0]+k%et/Math.floor(k/et);i.doc.setLineDashPattern([K,(u=S.dashArray[1])!==null&&u!==void 0?u:S.dashArray[0]],S.dashPhase)}if((e=i.doc).rect.apply(e,this.createAcroformRect(P)),t.rounded){var V=i.unitHeight*this.UNVISIBLE_BORDER_SCALE*this.BORDER_SCALE,X=1-V/l,bt=this.RADIUS_SCALE*V;i.doc.setDrawColor(this.BACKGROUND_COLOR),i.doc.setLineWidth(V),(r=i.doc).roundedRect.apply(r,_t(_t([],this.createAcroformRect(this.scaleRect(t,X)),!1),[bt,bt],!1))}t.dashStyle&&i.doc.setLineDashPattern([]),i.doc.setDrawColor(x)}},o.getLocString=function(i){return this.hasHtml(i)?i.renderedHtml:i.renderedText||i.renderedHtml},o.getContentQuestion=function(i){return i.contentQuestion?i.contentQuestion:i},o.getContentQuestionTypeRenderAs=function(i,t){var e=i.renderAs;if(i.getType()==="boolean"&&t.options.useLegacyBooleanRendering&&(e="checkbox"),e!=="default"){var r="".concat(i.getType(),"-").concat(e);if(Q.getInstance().isTypeRegistered(r))return r}return i.getType()},o.getContentQuestionType=function(i,t){return i.customWidget?i.customWidget.pdfQuestionType:i.contentQuestion?"custom_model":this.getContentQuestionTypeRenderAs(i,t)},o.getRatingMinWidth=function(i){return i.measureText(this.RATING_MIN_WIDTH).width},o.getRatingItemText=function(i,t,e){var r=new tt.LocalizableString(e.owner,e.useMarkdown);return r.text=this.getLocString(e),t===0&&i.minRateDescription?r.text=i.locMinRateDescription.text+" "+this.getLocString(e):t===i.visibleRateValues.length-1&&i.maxRateDescription&&(r.text=this.getLocString(e)+" "+i.locMaxRateDescription.text),r},o.getPageAvailableWidth=function(i){return i.paperWidth-i.margins.left-i.margins.right},o.getImagePickerAvailableWidth=function(i){var t=this.getPageAvailableWidth(i)-(this.IMAGEPICKER_COUNT-1)*i.unitHeight;return t>0?t:i.unitHeight},o.getColumnWidth=function(i,t){return(this.getPageAvailableWidth(i)-(t-1)*i.unitWidth*this.GAP_BETWEEN_COLUMNS)/t},o.setColumnMargins=function(i,t,e){var r=this.getColumnWidth(i,t);i.margins.left=i.margins.left+e*(r+i.unitWidth*this.GAP_BETWEEN_COLUMNS),i.margins.right=i.margins.right+(t-e-1)*(r+i.unitWidth*this.GAP_BETWEEN_COLUMNS)},o.moveRect=function(i,t,e){return t===void 0&&(t=i.xLeft),e===void 0&&(e=i.yTop),{xLeft:t,yTop:e,xRight:t+i.xRight-i.xLeft,yBot:e+i.yBot-i.yTop}},o.scaleRect=function(i,t){var e=Math.min(i.xRight-i.xLeft,i.yBot-i.yTop)*(1-t)/2;return{xLeft:i.xLeft+e,yTop:i.yTop+e,xRight:i.xRight-e,yBot:i.yBot-e}},o.getBorderWidth=function(i){return 2*i.unitWidth*this.BORDER_SCALE},o.formScale=function(i,t){var e=Math.min(t.width,t.height);return(e-this.getBorderWidth(i))/e},o.generateQuestionFlats=function(i,t,e,r){return F(this,void 0,void 0,function(){var n,a,s,u;return T(this,function(l){switch(l.label){case 0:return n=this.getContentQuestionType(e,i),a=Q.getInstance().create(i,e,t,n),[4,a.generateFlats(r)];case 1:return s=l.sent(),u=new ei(r,s,e,t,Q.getInstance(),re),e.customWidget&&e.customWidget.isFit(e)&&e.customWidget.pdfRender&&i.onRenderQuestion.unshift(e.customWi