UNPKG

survey-pdf

Version:

survey.pdf.js is a SurveyJS PDF Library. It is a easy way to export SurveyJS surveys to PDF. It uses JSON for survey metadata.

2 lines 180 kB
/*! For license information please see survey.pdf.min.js.LICENSE.txt */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("survey-core"),require("jspdf")):"function"==typeof define&&define.amd?define("SurveyPDF",["survey-core","jspdf"],e):"object"==typeof exports?exports.SurveyPDF=e(require("survey-core"),require("jspdf")):t.SurveyPDF=e(t.Survey,t.jspdf)}(self,((t,e)=>(()=>{var n={156:e=>{"use strict";e.exports=t},400:(t,e,n)=>{"use strict";var i=n(833);function r(t){return void 0===t?-1:t.height}var o=function(){function t(t,e){this.intervalTree=t,this.records=[],this.height=0,this.key=e.low,this.max=e.high,this.records.push(e)}return t.prototype.getNodeHigh=function(){for(var t=this.records[0].high,e=1;e<this.records.length;e++)this.records[e].high>t&&(t=this.records[e].high);return t},t.prototype.updateHeight=function(){this.height=Math.max(r(this.left),r(this.right))+1},t.prototype.updateMaxOfParents=function(){if(void 0!==this){var t=this.getNodeHigh();void 0!==this.left&&void 0!==this.right?this.max=Math.max(Math.max(this.left.max,this.right.max),t):void 0!==this.left&&void 0===this.right?this.max=Math.max(this.left.max,t):void 0===this.left&&void 0!==this.right?this.max=Math.max(this.right.max,t):this.max=t,this.parent&&this.parent.updateMaxOfParents()}},t.prototype._updateMaxAfterRightRotate=function(){var t=this.parent,e=t.left,n=e.getNodeHigh();void 0===e.left&&void 0!==e.right?e.max=Math.max(n,e.right.max):void 0!==e.left&&void 0===e.right?e.max=Math.max(n,e.left.max):void 0===e.left&&void 0===e.right?e.max=n:e.max=Math.max(Math.max(e.left.max,e.right.max),n);var i=this.getNodeHigh();void 0===this.left&&void 0!==this.right?this.max=Math.max(i,this.right.max):void 0!==this.left&&void 0===this.right?this.max=Math.max(i,this.left.max):void 0===this.left&&void 0===this.right?this.max=i:this.max=Math.max(Math.max(this.left.max,this.right.max),i),t.max=Math.max(Math.max(t.left.max,t.right.max),t.getNodeHigh())},t.prototype._updateMaxAfterLeftRotate=function(){var t=this.parent,e=t.right,n=e.getNodeHigh();void 0===e.left&&void 0!==e.right?e.max=Math.max(n,e.right.max):void 0!==e.left&&void 0===e.right?e.max=Math.max(n,e.left.max):void 0===e.left&&void 0===e.right?e.max=n:e.max=Math.max(Math.max(e.left.max,e.right.max),n);var i=this.getNodeHigh();void 0===this.left&&void 0!==this.right?this.max=Math.max(i,this.right.max):void 0!==this.left&&void 0===this.right?this.max=Math.max(i,this.left.max):void 0===this.left&&void 0===this.right?this.max=i:this.max=Math.max(Math.max(this.left.max,this.right.max),i),t.max=Math.max(Math.max(t.left.max,e.max),t.getNodeHigh())},t.prototype._leftRotate=function(){var t=this.right;t.parent=this.parent,void 0===t.parent?this.intervalTree.root=t:t.parent.left===this?t.parent.left=t:t.parent.right===this&&(t.parent.right=t),this.right=t.left,void 0!==this.right&&(this.right.parent=this),t.left=this,this.parent=t,this.updateHeight(),t.updateHeight()},t.prototype._rightRotate=function(){var t=this.left;t.parent=this.parent,void 0===t.parent?this.intervalTree.root=t:t.parent.left===this?t.parent.left=t:t.parent.right===this&&(t.parent.right=t),this.left=t.right,void 0!==this.left&&(this.left.parent=this),t.right=this,this.parent=t,this.updateHeight(),t.updateHeight()},t.prototype._rebalance=function(){if(r(this.left)>=2+r(this.right)){var t=this.left;r(t.left)>=r(t.right)?(this._rightRotate(),this._updateMaxAfterRightRotate()):(t._leftRotate(),this._rightRotate(),this._updateMaxAfterRightRotate())}else if(r(this.right)>=2+r(this.left)){var e=this.right;r(e.right)>=r(e.left)?(this._leftRotate(),this._updateMaxAfterLeftRotate()):(e._rightRotate(),this._leftRotate(),this._updateMaxAfterLeftRotate())}},t.prototype.insert=function(e){e.low<this.key?void 0===this.left?(this.left=new t(this.intervalTree,e),this.left.parent=this):this.left.insert(e):void 0===this.right?(this.right=new t(this.intervalTree,e),this.right.parent=this):this.right.insert(e),this.max<e.high&&(this.max=e.high),this.updateHeight(),this._rebalance()},t.prototype._getOverlappingRecords=function(t,e,n){if(t.key<=n&&e<=t.getNodeHigh()){for(var i=[],r=0;r<t.records.length;r++)t.records[r].high>=e&&i.push(t.records[r]);return i}return[]},t.prototype.search=function(t,e){if(void 0===this)return[];var n,i=[],r=[];return t>this.max?[]:(void 0!==this.left&&this.left.max>=t&&(i=this.left.search(t,e)),n=this._getOverlappingRecords(this,t,e),e<this.key?i.concat(n):(void 0!==this.right&&(r=this.right.search(t,e)),i.concat(n,r)))},t.prototype.searchExisting=function(t){if(void 0!==this){if(this.key===t)return this;if(t<this.key){if(void 0!==this.left)return this.left.searchExisting(t)}else if(void 0!==this.right)return this.right.searchExisting(t)}},t.prototype._minValue=function(){return void 0===this.left?this:this.left._minValue()},t.prototype.remove=function(t){var e=this.parent;if(t.key<this.key)return void 0!==this.left?this.left.remove(t):void 0;if(t.key>this.key)return void 0!==this.right?this.right.remove(t):void 0;if(void 0!==this.left&&void 0!==this.right){var n=this.right._minValue();return this.key=n.key,this.records=n.records,this.right.remove(this)}return e.left===this?(void 0!==this.right?(e.left=this.right,this.right.parent=e):(e.left=this.left,void 0!==this.left&&(this.left.parent=e)),e.updateMaxOfParents(),e.updateHeight(),e._rebalance(),this):e.right===this?(void 0!==this.right?(e.right=this.right,this.right.parent=e):(e.right=this.left,void 0!==this.left&&(this.left.parent=e)),e.updateMaxOfParents(),e.updateHeight(),e._rebalance(),this):void 0},t}(),s=function(){function t(){this.count=0}return t.prototype.insert=function(t){if(t.low>t.high)throw new Error("`low` value must be lower or equal to `high` value");if(void 0===this.root)return this.root=new o(this,t),this.count++,!0;var e=this.root.searchExisting(t.low);if(void 0!==e){for(var n=0;n<e.records.length;n++)if(i(e.records[n],t))return!1;return e.records.push(t),t.high>e.max&&(e.max=t.high,e.parent&&e.parent.updateMaxOfParents()),this.count++,!0}return this.root.insert(t),this.count++,!0},t.prototype.search=function(t,e){return void 0===this.root?[]:this.root.search(t,e)},t.prototype.remove=function(t){if(void 0===this.root)return!1;var e=this.root.searchExisting(t.low);if(void 0===e)return!1;if(e.records.length>1){for(var n=void 0,r=0;r<e.records.length;r++)if(i(e.records[r],t)){n=e.records[r],e.records.splice(r,1);break}if(n){if(n=void 0,t.high===e.max){var s=e.getNodeHigh();void 0!==e.left&&void 0!==e.right?e.max=Math.max(Math.max(e.left.max,e.right.max),s):void 0!==e.left&&void 0===e.right?e.max=Math.max(e.left.max,s):void 0===e.left&&void 0!==e.right?e.max=Math.max(e.right.max,s):e.max=s,e.parent&&e.parent.updateMaxOfParents()}return this.count--,!0}return!1}if(1===e.records.length){if(i(e.records[0],t)){if(this.root.key===e.key){var a=new o(this,{low:t.low,high:t.low});a.left=this.root,this.root.parent=a;var l=this.root.remove(e);return this.root=a.left,void 0!==this.root&&(this.root.parent=void 0),!!l&&(l=void 0,this.count--,!0)}return!!(l=this.root.remove(e))&&(l=void 0,this.count--,!0)}return!1}return!1},t.prototype.inOrder=function(){return new l(this.root)},t.prototype.preOrder=function(){return new c(this.root)},t}(),a=function(){function t(){this.tree=new s}return t.prototype.insert=function(t,e,n){return this.tree.insert({low:t,high:e,data:n})},t.prototype.remove=function(t,e,n){return this.tree.remove({low:t,high:e,data:n})},t.prototype.search=function(t,e){return this.tree.search(t,e).map((function(t){return t.data}))},t.prototype.inOrder=function(){return this.tree.inOrder()},t.prototype.preOrder=function(){return this.tree.preOrder()},Object.defineProperty(t.prototype,"count",{get:function(){return this.tree.count},enumerable:!0,configurable:!0}),t}();e.Ay=a;var l=function(){function t(t){this.stack=[],void 0!==t&&this.push(t)}return t.prototype.next=function(){return void 0===this.currentNode?{done:!0,value:void 0}:this.i<this.currentNode.records.length?{done:!1,value:this.currentNode.records[this.i++]}:(void 0!==this.currentNode.right?this.push(this.currentNode.right):this.pop(),this.next())},t.prototype.push=function(t){for(this.currentNode=t,this.i=0;void 0!==this.currentNode.left;)this.stack.push(this.currentNode),this.currentNode=this.currentNode.left},t.prototype.pop=function(){this.currentNode=this.stack.pop(),this.i=0},t}();"function"==typeof Symbol&&(l.prototype[Symbol.iterator]=function(){return this});var c=function(){function t(t){this.stack=[],this.i=0,this.currentNode=t}return t.prototype.next=function(){return void 0===this.currentNode?{done:!0,value:void 0}:this.i<this.currentNode.records.length?{done:!1,value:this.currentNode.records[this.i++]}:(void 0!==this.currentNode.right&&this.push(this.currentNode.right),void 0!==this.currentNode.left&&this.push(this.currentNode.left),this.pop(),this.next())},t.prototype.push=function(t){this.stack.push(t)},t.prototype.pop=function(){this.currentNode=this.stack.pop(),this.i=0},t}();"function"==typeof Symbol&&(c.prototype[Symbol.iterator]=function(){return this})},814:t=>{"use strict";t.exports=e},833:t=>{t.exports=function(t,e,n,i){var r=n?n.call(i,t,e):void 0;if(void 0!==r)return!!r;if(t===e)return!0;if("object"!=typeof t||!t||"object"!=typeof e||!e)return!1;var o=Object.keys(t),s=Object.keys(e);if(o.length!==s.length)return!1;for(var a=Object.prototype.hasOwnProperty.bind(e),l=0;l<o.length;l++){var c=o[l];if(!a(c))return!1;var h=t[c],u=e[c];if(!1===(r=n?n.call(i,h,u,c):void 0)||void 0===r&&h!==u)return!1}return!0}}},i={};function r(t){var e=i[t];if(void 0!==e)return e.exports;var o=i[t]={exports:{}};return n[t](o,o.exports,r),o.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{"use strict";r.r(o),r.d(o,{BooleanItemBrick:()=>V,CheckItemBrick:()=>G,CheckboxItemBrick:()=>J,CommentBrick:()=>E,CompositeBrick:()=>u,CustomBrick:()=>Ft,DocController:()=>k,DocOptions:()=>M,DrawCanvas:()=>q,DropdownBrick:()=>it,EmptyBrick:()=>B,EventHandler:()=>j,FlatBoolean:()=>K,FlatCheckbox:()=>$,FlatComment:()=>nt,FlatCustomModel:()=>et,FlatDropdown:()=>rt,FlatExpression:()=>ot,FlatFile:()=>st,FlatHTML:()=>at,FlatImage:()=>lt,FlatImagePicker:()=>ct,FlatMatrix:()=>yt,FlatMatrixDynamic:()=>xt,FlatMatrixMultiple:()=>bt,FlatMultipleText:()=>Tt,FlatPanelDynamic:()=>ht,FlatQuestion:()=>x,FlatQuestionDefault:()=>T,FlatRadiogroup:()=>X,FlatRanking:()=>dt,FlatRating:()=>pt,FlatRepository:()=>F,FlatSelectBase:()=>Y,FlatSignaturePad:()=>gt,FlatSurvey:()=>y,FlatTextbox:()=>mt,HTMLBrick:()=>S,HorizontalAlign:()=>I,ImageBrick:()=>L,LinkBrick:()=>O,PagePacker:()=>H,PdfBrick:()=>v,RadioItemBrick:()=>Q,RankingItemBrick:()=>ut,RowlineBrick:()=>f,SurveyHelper:()=>A,SurveyPDF:()=>z,TextBoldBrick:()=>_,TextBoxBrick:()=>P,TextBrick:()=>b,TextFieldBrick:()=>C,TitlePanelBrick:()=>w,VerticalAlign:()=>N});var t={};r.r(t),r.d(t,{BooleanItemBrick:()=>V,CheckItemBrick:()=>G,CheckboxItemBrick:()=>J,CommentBrick:()=>E,CompositeBrick:()=>u,CustomBrick:()=>Ft,DocController:()=>k,DocOptions:()=>M,DrawCanvas:()=>q,DropdownBrick:()=>it,EmptyBrick:()=>B,EventHandler:()=>j,FlatBoolean:()=>K,FlatCheckbox:()=>$,FlatComment:()=>nt,FlatCustomModel:()=>et,FlatDropdown:()=>rt,FlatExpression:()=>ot,FlatFile:()=>st,FlatHTML:()=>at,FlatImage:()=>lt,FlatImagePicker:()=>ct,FlatMatrix:()=>yt,FlatMatrixDynamic:()=>xt,FlatMatrixMultiple:()=>bt,FlatMultipleText:()=>Tt,FlatPanelDynamic:()=>ht,FlatQuestion:()=>x,FlatQuestionDefault:()=>T,FlatRadiogroup:()=>X,FlatRanking:()=>dt,FlatRating:()=>pt,FlatRepository:()=>F,FlatSelectBase:()=>Y,FlatSignaturePad:()=>gt,FlatSurvey:()=>y,FlatTextbox:()=>mt,HTMLBrick:()=>S,HorizontalAlign:()=>I,ImageBrick:()=>L,LinkBrick:()=>O,PagePacker:()=>H,PdfBrick:()=>v,RadioItemBrick:()=>Q,RankingItemBrick:()=>ut,RowlineBrick:()=>f,SurveyHelper:()=>A,SurveyPDF:()=>z,TextBoldBrick:()=>_,TextBoxBrick:()=>P,TextBrick:()=>b,TextFieldBrick:()=>C,TitlePanelBrick:()=>w,VerticalAlign:()=>N});var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},e(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var i=function(){return i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},i.apply(this,arguments)};function s(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))}function a(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function l(t,e,n){if(n||2===arguments.length)for(var i,r=0,o=e.length;r<o;r++)!i&&r in e||(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}var c=r(156),h=r(814),u=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.bricks=[],this.isPageBreak=!1,this._xLeft=0,this._xRight=0,this._yTop=0,this._yBot=0,this.addBrick.apply(this,t)}return Object.defineProperty(t.prototype,"xLeft",{get:function(){return this._xLeft},set:function(t){this.shift(t-this.xLeft,0,0,0),this._xLeft=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xRight",{get:function(){return this._xRight},set:function(t){this.shift(0,t-this.xRight,0,0),this._xRight=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"yTop",{get:function(){return this._yTop},set:function(t){this.shift(0,0,t-this.yTop,0),this._yTop=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"yBot",{get:function(){return this._yBot},set:function(t){this.shift(0,0,0,t-this.yBot),this._yBot=t},enumerable:!1,configurable:!0}),t.prototype.shift=function(t,e,n,i){this.bricks.forEach((function(r){r.xLeft+=t,r.xRight+=e,r.yTop+=n,r.yBot+=i}))},Object.defineProperty(t.prototype,"width",{get:function(){return this.xRight-this.xLeft},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this.yBot-this.yTop},enumerable:!1,configurable:!0}),t.prototype.render=function(){return s(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:t=0,e.label=1;case 1:return t<this.bricks.length?[4,this.bricks[t].render()]:[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},Object.defineProperty(t.prototype,"isEmpty",{get:function(){return 0===this.bricks.length},enumerable:!1,configurable:!0}),t.prototype.addBrick=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(0!=e.length){(t=this.bricks).push.apply(t,e);var i=A.mergeRects.apply(A,this.bricks);this._xLeft=i.xLeft,this._xRight=i.xRight,this._yTop=i.yTop,this._yBot=i.yBot}},t.prototype.unfold=function(){var t=[];return this.bricks.forEach((function(e){t.push.apply(t,e.unfold())})),t},t.prototype.translateX=function(t){this.bricks.forEach((function(e){return e.translateX(t)}));var e=t(this.xLeft,this.xRight);this._xLeft=e.xLeft,this._xRight=e.xRight},t}(),f=function(){function t(t,e,n){this.controller=t,this.color=n,this.isPageBreak=!1,this.xLeft=e.xLeft,this.xRight=e.xRight,this.yTop=e.yTop,this.yBot=e.yBot}return Object.defineProperty(t.prototype,"width",{get:function(){return this.xRight-this.xLeft},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this.yBot-this.yTop},enumerable:!1,configurable:!0}),t.prototype.render=function(){return s(this,void 0,void 0,(function(){var t;return a(this,(function(e){return null!==this.color&&(t=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(t)),[2]}))}))},t.prototype.unfold=function(){return[this]},t.prototype.translateX=function(t){},t}(),d=function(t,e,n,i,r){this.point=t,this.bricks=e,this.controller=n,this.repository=i,this.module=r},p=function(t){function e(e,n,i,r,o,s){var a=t.call(this,e,n,r,o,s)||this;return a.question=i,a}return n(e,t),e}(d),g=function(t){function e(e,n,i,r,o,s){var a=t.call(this,e,n,r,o,s)||this;return a.panel=i,a}return n(e,t),e}(d),m=function(t){function e(e,n,i,r,o,s){var a=t.call(this,e,n,r,o,s)||this;return a.page=i,a}return n(e,t),e}(d),y=function(){function e(){}return e.generateFlatsPanel=function(e,n,i,r){return s(this,void 0,void 0,(function(){var o,s,c,h,u,f;return a(this,(function(a){switch(a.label){case 0:return o=[],s=A.clone(r),n.pushMargins(),n.margins.left+=n.measureText(i.innerIndent).width,s.xLeft+=n.measureText(i.innerIndent).width,h=(c=o.push).apply,u=[o],[4,this.generateFlatsPagePanel(e,n,i,s)];case 1:return h.apply(c,u.concat([a.sent()])),n.popMargins(),f=new g(r,o,i,n,F.getInstance(),t),[4,e.onRenderPanel.fire(e,f)];case 2:return a.sent(),[2,l([],f.bricks,!0)]}}))}))},e.generateFlatsPagePanel=function(t,n,i,r){return s(this,void 0,void 0,(function(){var o,s,l,h,f,d,p,g,m,y,v,b,x,T,F,_,w,R,C,P,E,O,S;return a(this,(function(a){switch(a.label){case 0:return i.isVisible?(i.onFirstRendering(),o=[],s=A.clone(r),"page"!==i.getType()||t.showPageTitles?(l=new u,i.title?i instanceof c.PanelModel&&i.no?[4,A.createTitlePanelFlat(s,n,i.no,"page"===i.getType())]:[3,2]:[3,4]):[3,7]):[2];case 1:h=a.sent(),l.addBrick(h),s.xLeft=h.xRight+n.measureText(" ").width,a.label=2;case 2:return[4,A.createTitlePanelFlat(s,n,i.locTitle,"page"===i.getType())];case 3:f=a.sent(),l.addBrick(f),s=A.createPoint(f),a.label=4;case 4:return i.description?(i.title&&(s.yTop+=n.unitWidth*e.PANEL_DESC_GAP_SCALE),[4,A.createDescFlat(s,null,n,i.locDescription)]):[3,6];case 5:d=a.sent(),l.addBrick(d),s=A.createPoint(d),a.label=6;case 6:l.isEmpty||(p=A.createPoint(l),l.addBrick(A.createRowlineFlat(p,n)),o.push(l),s.yTop+=n.unitHeight*e.PANEL_CONT_GAP_SCALE+A.EPSILON),a.label=7;case 7:g=0,m=i.rows,a.label=8;case 8:if(!(g<m.length))return[3,16];if(!(y=m[g]).visible)return[3,15];n.pushMargins(),v=A.getPageAvailableWidth(n),b=n.margins.left,x=[],T=y.elements.filter((function(t){return t.isVisible})),F=0,a.label=9;case 9:return F<T.length?(_=T[F]).isVisible?(w=A.parseWidth(_.renderWidth,v-(T.length-1)*n.unitWidth,T.length),n.margins.left=b+(0!==F?n.unitWidth:0),n.margins.right=n.paperWidth-n.margins.left-w,s.xLeft=n.margins.left,b=n.margins.left+w,_ instanceof c.PanelModel?(C=(R=x.push).apply,P=[x],[4,this.generateFlatsPanel(t,n,_,s)]):[3,11]):[3,13]:[3,14];case 10:return C.apply(R,P.concat([a.sent()])),[3,13];case 11:return O=(E=x.push).apply,S=[x],[4,A.generateQuestionFlats(t,n,_,s)];case 12:O.apply(E,S.concat([a.sent()])),a.label=13;case 13:return F++,[3,9];case 14:n.popMargins(),s.xLeft=n.margins.left,0!==x.length&&(s.yTop=A.mergeRects.apply(A,x).yBot,s.xLeft=r.xLeft,s.yTop+=n.unitHeight*e.QUES_GAP_VERT_SCALE,o.push.apply(o,x),o.push(A.createRowlineFlat(s,n)),s.yTop+=A.EPSILON),a.label=15;case 15:return g++,[3,8];case 16:return[2,o]}}))}))},e.popRowlines=function(t){for(;t.length>0&&t[t.length-1]instanceof f;)t.pop()},e.generateFlatTitle=function(t,n,i){return s(this,void 0,void 0,(function(){var r,o,s,l;return a(this,(function(a){switch(a.label){case 0:return r=new u,t.showTitle?t.title?[4,A.createTitleSurveyFlat(i,n,t.locTitle)]:[3,2]:[3,4];case 1:o=a.sent(),r.addBrick(o),i=A.createPoint(o),a.label=2;case 2:return t.description?(t.title&&(i.yTop+=n.unitWidth*e.PANEL_DESC_GAP_SCALE),l=(s=r).addBrick,[4,A.createDescFlat(i,null,n,t.locDescription)]):[3,4];case 3:l.apply(s,[a.sent()]),a.label=4;case 4:return[2,r]}}))}))},e.generateFlatLogoImage=function(t,e,n){return s(this,void 0,void 0,(function(){var i,r,o,s;return a(this,(function(a){switch(a.label){case 0:return i=A.getLocString(t.locLogo),[4,A.getCorrectedImageSize(e,{imageLink:i,imageHeight:t.logoHeight,imageWidth:t.logoWidth,defaultImageWidth:"300px",defaultImageHeight:"200px"})];case 1:return r=a.sent(),[4,A.createImageFlat(n,null,e,{link:i,width:r.width,height:r.height})];case 2:return o=a.sent(),s=0,"right"===t.logoPosition?s=A.getPageAvailableWidth(e)-o.width:"left"!==t.logoPosition&&(s=A.getPageAvailableWidth(e)/2-o.width/2),o.xLeft+=s,o.xRight+=s,[2,o]}}))}))},e.generateFlats=function(n,i){return s(this,void 0,void 0,(function(){var r,o,s,c,h,u,f,d,p,g,y,v,b;return a(this,(function(a){switch(a.label){case 0:return r=[],n.hasLogo?[3,2]:[4,this.generateFlatTitle(n,i,i.leftTopPoint)];case 1:return(s=a.sent()).isEmpty||r.push([s]),[3,11];case 2:return n.isLogoBefore?[4,this.generateFlatLogoImage(n,i,i.leftTopPoint)]:[3,5];case 3:return h=a.sent(),r.push([h]),o=A.createPoint(h,"top"===n.logoPosition,"top"!==n.logoPosition),"top"!==n.logoPosition?(i.pushMargins(),o.xLeft+=i.unitWidth,i.margins.left+=h.width+i.unitWidth):(o.xLeft=i.leftTopPoint.xLeft,o.yTop+=i.unitHeight/2),[4,this.generateFlatTitle(n,i,o)];case 4:return s=a.sent(),"top"!==n.logoPosition&&i.popMargins(),s.isEmpty||r[0].push(s),[3,11];case 5:return"right"!==n.logoPosition?[3,8]:[4,this.generateFlatLogoImage(n,i,i.leftTopPoint)];case 6:return h=a.sent(),r.push([h]),i.pushMargins(),i.margins.right+=h.width+i.unitWidth,[4,this.generateFlatTitle(n,i,i.leftTopPoint)];case 7:return(s=a.sent()).isEmpty||r[0].unshift(s),i.popMargins(),[3,11];case 8:return[4,this.generateFlatTitle(n,i,i.leftTopPoint)];case 9:return s=a.sent(),c=i.leftTopPoint,s.isEmpty||(r.push([s]),(c=A.createPoint(s)).yTop+=i.unitHeight/2),[4,this.generateFlatLogoImage(n,i,c)];case 10:h=a.sent(),0!==r.length?r[0].push(h):r.push([h]),a.label=11;case 11:u=i.leftTopPoint,0!==r.length&&(u.yTop=A.createPoint(A.mergeRects.apply(A,r[0])).yTop,r[0].push(A.createRowlineFlat(u,i)),u.yTop+=i.unitHeight*e.PANEL_CONT_GAP_SCALE+A.EPSILON),f=0,a.label=12;case 12:return f<n.visiblePages.length?(n.currentPage=n.visiblePages[f],g=(p=(d=[]).push).apply,y=[d],[4,this.generateFlatsPagePanel(n,i,n.visiblePages[f],u)]):[3,16];case 13:return g.apply(p,y.concat([a.sent()])),v=new m(u,d,n.visiblePages[f],i,F.getInstance(),t),[4,n.onRenderPage.fire(n,v)];case 14:a.sent(),d=l([],v.bricks,!0),0===f&&0!==r.length?(b=r[0]).push.apply(b,d):r.push(d),this.popRowlines(r[r.length-1]),u.yTop=i.leftTopPoint.yTop,a.label=15;case 15:return f++,[3,12];case 16:return[2,r]}}))}))},e.QUES_GAP_VERT_SCALE=1.5,e.PANEL_CONT_GAP_SCALE=1,e.PANEL_DESC_GAP_SCALE=.25,e}(),v=function(){function t(t,e,n){this.question=t,this.controller=e,this.textColor=A.TEXT_COLOR,this.formBorderColor=A.FORM_BORDER_COLOR,this.isPageBreak=!1,this.xLeft=n.xLeft,this.xRight=n.xRight,this.yTop=n.yTop,this.yBot=n.yBot,this.fontSize=e?e.fontSize:k.FONT_SIZE}return Object.defineProperty(t.prototype,"xLeft",{get:function(){return this._xLeft},set:function(t){this.setXLeft(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xRight",{get:function(){return this._xRight},set:function(t){this.setXRight(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"yTop",{get:function(){return this._yTop},set:function(t){this.setYTop(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"yBot",{get:function(){return this._yBot},set:function(t){this.setYBottom(t)},enumerable:!1,configurable:!0}),t.prototype.translateX=function(t){var e=t(this.xLeft,this.xRight);this.xLeft=e.xLeft,this.xRight=e.xRight},Object.defineProperty(t.prototype,"width",{get:function(){return this.xRight-this.xLeft},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this.yBot-this.yTop},enumerable:!1,configurable:!0}),t.prototype.getShouldRenderReadOnly=function(){return A.shouldRenderReadOnly(this.question,this.controller)},t.prototype.render=function(){return s(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return this.getShouldRenderReadOnly()?[4,this.renderReadOnly()]:[3,2];case 1:return t.sent(),[3,4];case 2:return[4,this.renderInteractive()];case 3:t.sent(),t.label=4;case 4:return this.afterRenderCallback&&this.afterRenderCallback(),[2]}}))}))},t.prototype.renderInteractive=function(){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2]}))}))},t.prototype.renderReadOnly=function(){return s(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.renderInteractive()];case 1:return t.sent(),[2]}}))}))},t.prototype.unfold=function(){return[this]},t.prototype.getCorrectedText=function(t){return this.controller.isRTL?(t||"").split("").reverse().join(""):t},t.prototype.setXLeft=function(t){this._xLeft=t},t.prototype.setXRight=function(t){this._xRight=t},t.prototype.setYTop=function(t){this._yTop=t},t.prototype.setYBottom=function(t){this._yBot=t},t}(),b=function(t){function e(e,n,i,r){var o=t.call(this,e,n,i)||this;return o.text=r,o.align={isInputRtl:!1,isOutputRtl:n.isRTL,align:n.isRTL?"right":"left",baseline:"middle"},o}return n(e,t),e.prototype.escapeText=function(){for(;this.text.indexOf("\t")>-1;)this.text=this.text.replace("\t",Array(5).join(String.fromCharCode(160)));return this.text},e.prototype.renderInteractive=function(){return s(this,void 0,void 0,(function(){var t,e,n;return a(this,(function(i){return t=this.alignPoint(this),e=this.controller.fontSize,this.controller.fontSize=this.fontSize,n=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(n),this.controller.fontSize=e,[2]}))}))},e.prototype.alignPoint=function(t){return{xLeft:this.controller.isRTL?t.xRight:t.xLeft,yTop:t.yTop+(t.yBot-t.yTop)/2}},e}(v),x=function(){function t(t,e,n){this.survey=t,this.controller=n,this.question=e}return t.prototype.generateFlatTitle=function(t){return s(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,A.createTitleFlat(t,this.question,this.controller)];case 1:return[2,e.sent()]}}))}))},t.prototype.generateFlatDescription=function(t){return s(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,A.createDescFlat(t,this.question,this.controller,this.question.locDescription)];case 1:return[2,e.sent()]}}))}))},t.prototype.generateFlatHeader=function(e){return s(this,void 0,void 0,(function(){var n,i,r,o,s;return a(this,(function(a){switch(a.label){case 0:return[4,this.generateFlatTitle(e)];case 1:return n=a.sent(),i=new u(n),this.question.hasDescriptionUnderTitle?((r=A.createPoint(n,!0,!1)).yTop+=t.DESC_GAP_SCALE*this.controller.unitHeight,r.xLeft+=this.controller.unitWidth*t.CONTENT_INDENT_SCALE,s=(o=i).addBrick,[4,this.generateFlatDescription(r)]):[3,3];case 2:s.apply(o,[a.sent()]),a.label=3;case 3:return[2,i]}}))}))},t.prototype.generateFlatsComment=function(t){return s(this,void 0,void 0,(function(){var e,n,i,r,o;return a(this,(function(s){switch(s.label){case 0:return e=this.question.locCommentText,[4,A.createTextFlat(t,this.question,this.controller,e,b)];case 1:return n=s.sent(),(i=A.createPoint(n)).yTop+=this.controller.unitHeight*A.GAP_BETWEEN_ROWS,r=u.bind,o=[void 0,n],[4,A.createCommentFlat(i,this.question,this.controller,!1,{rows:A.OTHER_ROWS_COUNT})];case 2:return[2,new(r.apply(u,o.concat([s.sent()])))]}}))}))},t.prototype.generateFlatsComposite=function(t){return s(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return(e=this.question.contentPanel)?[4,y.generateFlatsPanel(this.survey,this.controller,e,t)]:[3,2];case 1:case 3:return[2,n.sent()];case 2:return this.question=A.getContentQuestion(this.question),[4,this.generateFlatsContent(t)]}}))}))},t.prototype.generateFlatsContent=function(t){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,null]}))}))},t.prototype.generateFlatsContentWithOptionalElements=function(t){return s(this,void 0,void 0,(function(){var e,n,i,r,o,s,l,c=this;return a(this,(function(a){switch(a.label){case 0:return e=[],[4,this.generateFlatsComposite(t)];case 1:return n=a.sent(),e.push.apply(e,n),i=function(){var i=A.clone(t);return null!==n&&0!==n.length&&(i.yTop=A.mergeRects.apply(A,e).yBot+c.controller.unitHeight*A.GAP_BETWEEN_ROWS),i},this.question.hasComment?(o=(r=e).push,[4,this.generateFlatsComment(i())]):[3,3];case 2:o.apply(r,[a.sent()]),a.label=3;case 3:return this.question.hasDescriptionUnderInput?(l=(s=e).push,[4,this.generateFlatDescription(i())]):[3,5];case 4:l.apply(s,[a.sent()]),a.label=5;case 5:return[2,e]}}))}))},t.prototype.generateFlats=function(e){return s(this,void 0,void 0,(function(){var n,i,r,o,s,l,c,h,u,f,d,p;return a(this,(function(a){switch(a.label){case 0:switch(this.controller.pushMargins(),this.controller.margins.left+=this.controller.measureText(this.question.indent).width,n={xLeft:e.xLeft+this.controller.measureText(this.question.indent).width,yTop:e.yTop},i=[],r=this.question.getTitleLocation(),r=this.question.hasTitle?r:"hidden"){case"top":case"default":return[3,1];case"bottom":return[3,4];case"left":return[3,7];case"hidden":case A.TITLE_LOCATION_MATRIX:return[3,10]}return[3,10];case 1:return[4,this.generateFlatHeader(n)];case 2:return c=a.sent(),(u=A.createPoint(c)).xLeft+=this.controller.unitWidth*t.CONTENT_INDENT_SCALE,c.addBrick(A.createRowlineFlat(A.createPoint(c),this.controller)),u.yTop+=this.controller.unitHeight*t.CONTENT_GAP_VERT_SCALE+A.EPSILON,this.controller.pushMargins(),this.controller.margins.left+=this.controller.unitWidth*t.CONTENT_INDENT_SCALE,[4,this.generateFlatsContentWithOptionalElements(u)];case 3:return h=a.sent(),this.controller.popMargins(),null!==h&&0!==h.length&&c.addBrick(h.shift()),i.push(c),i.push.apply(i,h),[3,12];case 4:return u=A.clone(n),this.controller.pushMargins(),u.xLeft+=this.controller.unitWidth*t.CONTENT_INDENT_SCALE,this.controller.margins.left+=this.controller.unitWidth*t.CONTENT_INDENT_SCALE,[4,this.generateFlatsContentWithOptionalElements(u)];case 5:return h=a.sent(),this.controller.popMargins(),i.push.apply(i,h),o=n,0!==i.length&&(o.yTop=i[i.length-1].yBot),o.yTop+=this.controller.unitHeight*t.CONTENT_GAP_VERT_SCALE,l=(s=i).push,[4,this.generateFlatHeader(o)];case 6:return l.apply(s,[a.sent()]),[3,12];case 7:return this.controller.pushMargins(this.controller.margins.left,this.controller.paperWidth-this.controller.margins.left-A.getPageAvailableWidth(this.controller)*A.MULTIPLETEXT_TEXT_PERS),[4,this.generateFlatHeader(n)];case 8:return c=a.sent(),u=A.createPoint(c,!1,!0),this.controller.popMargins(),u.xLeft+=this.controller.unitWidth*t.CONTENT_GAP_HOR_SCALE,this.controller.margins.left=u.xLeft,[4,this.generateFlatsContentWithOptionalElements(u)];case 9:return null!==(h=a.sent())&&0!==h.length&&c.addBrick(h.shift()),i.push(c),i.push.apply(i,h),[3,12];case 10:return u=A.clone(n),this.controller.pushMargins(),r!==A.TITLE_LOCATION_MATRIX&&(u.xLeft+=this.controller.unitWidth*t.CONTENT_INDENT_SCALE,this.controller.margins.left+=this.controller.unitWidth*t.CONTENT_INDENT_SCALE),d=(f=i.push).apply,p=[i],[4,this.generateFlatsContentWithOptionalElements(u)];case 11:return d.apply(f,p.concat([a.sent()])),this.controller.popMargins(),[3,12];case 12:return this.controller.popMargins(),[2,i]}}))}))},Object.defineProperty(t.prototype,"shouldRenderAsComment",{get:function(){return A.shouldRenderReadOnly(this.question,this.controller)},enumerable:!1,configurable:!0}),t.CONTENT_GAP_VERT_SCALE=.5,t.CONTENT_GAP_HOR_SCALE=1,t.CONTENT_INDENT_SCALE=1,t.DESC_GAP_SCALE=.0625,t}();c.Serializer.addProperty("question",{name:"readonlyRenderAs",default:"auto",choices:["auto","text","acroform"],visible:!1});var T=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.generateFlatsContent=function(t){return s(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,A.createTextFlat(t,this.question,this.controller,"".concat(this.question.displayValue),b)];case 1:return[2,[e.sent()]]}}))}))},e}(x),F=function(){function t(){this.questions={}}return t.getInstance=function(){return t.instance},t.prototype.register=function(t,e){this.questions[t]=e},t.prototype.isTypeRegistered=function(t){return!!this.questions[t]},t.prototype.getRenderer=function(t){return this.questions[t]},t.prototype.create=function(t,e,n,i){var r,o=void 0===i?e.getType():i,s=this.getRenderer(o);return s||(s=(null===(r=e.customWidget)||void 0===r?void 0:r.pdfRender)?x:T),new s(t,e,n)},t.register=function(t,e){this.getInstance().register(t,e)},t.getRenderer=function(t){return this.getInstance().getRenderer(t)},t.instance=new t,t}(),_=function(t){function e(e,n,i,r){return t.call(this,e,n,i,r)||this}return n(e,t),e.prototype.renderInteractive=function(){return s(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return this.controller.fontStyle="bold",[4,t.prototype.renderInteractive.call(this)];case 1:return e.sent(),this.controller.fontStyle="normal",[2]}}))}))},e}(b),w=function(t){function e(e,n,i,r){return t.call(this,e,n,i,r)||this}return n(e,t),e.prototype.renderInteractive=function(){return s(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return e=this.controller.fontSize,this.controller.fontSize=e*A.TITLE_PANEL_FONT_SIZE_SCALE,[4,t.prototype.renderInteractive.call(this)];case 1:return n.sent(),this.controller.fontSize=e,[2]}}))}))},e}(_),R=function(t){function e(e,n,i,r){return t.call(this,e,n,i,r)||this}return n(e,t),e}(b),C=function(t){function e(e,n,i,r,o,s,a,l,c,h){var u=t.call(this,e,n,i)||this;return u.isQuestion=r,u.fieldName=o,u.value=s,u.placeholder=a,u.isReadOnly=l,u.isMultiline=c,u.inputType=h,u.question=e,u}return n(e,t),e.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)},e.prototype.renderInteractive=function(){return s(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){return"color"===this.inputType?(this.renderColorQuestion(),[2]):((t="password"===this.inputType?new this.controller.doc.AcroFormPasswordField:new this.controller.doc.AcroFormTextField).fieldName=this.fieldName,t.fontName=this.controller.fontName,t.fontSize=this.fontSize,t.isUnicode=A.isCustomFont(this.controller,t.fontName),"password"!==this.inputType?(t.V=" "+this.getCorrectedText(this.value),t.DV=" "+this.getCorrectedText(this.placeholder)):t.value="",t.multiline=this.isMultiline,t.readOnly=this.isReadOnly,t.color=this.textColor,e=A.formScale(this.controller,this),t.maxFontSize=this.controller.fontSize*e,t.Rect=A.createAcroformRect(A.scaleRect(this,e)),this.controller.doc.addField(t),A.renderFlatBorders(this.controller,this),[2])}))}))},e.prototype.shouldRenderFlatBorders=function(){return"input"===c.settings.readOnlyTextRenderMode},e.prototype.getShouldRenderReadOnly=function(){return A.shouldRenderReadOnly(this.question,this.controller,this.isReadOnly)},Object.defineProperty(e.prototype,"textBrick",{get:function(){return this._textBrick},set:function(t){var e=this;this._textBrick=t;var n=t.unfold(),i=n.length,r=0,o={},s=function(t){if(e.shouldRenderFlatBorders()){r++;var n=e.controller.getCurrentPageIndex();if(o[n]||(o[n]=[]),o[n].push(t),r>=i){var s=Object.keys(o),a=1==s.length;s.forEach((function(t){var i=new u;o[t].forEach((function(t){i.addBrick(t)}));var r=e.controller.unitHeight*A.VALUE_READONLY_PADDING_SCALE,s={xLeft:e.xLeft,xRight:e.xRight,width:e.width,yTop:a?e.yTop:i.yTop-r,yBot:a?e.yBot:i.yBot+r,height:a?e.height:i.height+2*r,formBorderColor:e.formBorderColor};e.controller.setPage(Number(t)),A.renderFlatBorders(e.controller,s),e.controller.setPage(n)}))}}};n.forEach((function(t){t.afterRenderCallback=s.bind(e,t)}))},enumerable:!1,configurable:!0}),e.prototype.renderReadOnly=function(){return s(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return this.controller.pushMargins(this.xLeft,this.controller.paperWidth-this.xRight),"color"!==this.inputType?[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]}}))}))},e.prototype.unfold=function(){return this.getShouldRenderReadOnly()&&"color"!==this.inputType?this.textBrick.unfold():t.prototype.unfold.call(this)},e.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)},e.prototype.setXLeft=function(e){var n=e-this._xLeft;t.prototype.setXLeft.call(this,e),this.textBrick&&(this.textBrick.xLeft=this.textBrick.xLeft+n)},e.prototype.setXRight=function(e){var n=e-this._xRight;t.prototype.setXRight.call(this,e),this.textBrick&&(this.textBrick.xRight=this.textBrick.xRight+n)},e.prototype.setYTop=function(e){var n=e-this._yTop;t.prototype.setYTop.call(this,e),this.textBrick&&(this.textBrick.yTop=this.textBrick.yTop+n)},e.prototype.setYBottom=function(e){var n=e-this._yBot;t.prototype.setYBottom.call(this,e),this.textBrick&&(this.textBrick.yBot=this.textBrick.yBot+n)},e}(v),P=function(t){function e(e,n,i,r,o,s){void 0===r&&(r=!0),void 0===o&&(o=!1),void 0===s&&(s=0);var a=t.call(this,e,n,i,r,e.id+(r?"":"_comment"+s),A.getQuestionOrCommentValue(e,r),r&&e.locPlaceHolder?A.getLocString(e.locPlaceHolder):"",e.isReadOnly,o,e.inputType)||this;return a.isQuestion=r,a.isMultiline=o,a}return n(e,t),e}(C),E=function(t){function e(e,n,i,r,o){void 0===o&&(o=0);var s=t.call(this,e,n,i,r,!0,o)||this;return s.controller=n,s}return n(e,t),e.prototype.shouldRenderFlatBorders=function(){return this.isQuestion&&"comment"!==this.question.getType()?t.prototype.shouldRenderFlatBorders.call(this):"textarea"===c.settings.readOnlyCommentRenderMode},e}(P),O=function(t){function e(n,i){var r=t.call(this,n.question,n.controller,n,n.text)||this;return r.link=i,r.textColor=e.COLOR,r}return n(e,t),e.prototype.renderInteractive=function(){return s(this,void 0,void 0,(function(){var n,i,r;return a(this,(function(o){switch(o.label){case 0:return n=this.controller.doc.getTextColor(),this.controller.doc.setTextColor(A.BACKGROUND_COLOR),i=this.controller.unitHeight*(this.controller.doc.getLineHeightFactor()-e.SCALE_FACTOR_MAGIC),r=this.yTop+(this.yBot-this.yTop)-i,this.controller.doc.textWithLink(this.text,this.xLeft,r,{url:this.link}),[4,t.prototype.renderInteractive.call(this)];case 1:return o.sent(),this.controller.doc.setTextColor(n),[2]}}))}))},e.prototype.renderReadOnly=function(){return s(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return"text"!==A.getReadonlyRenderAs(this.question,this.controller)?[2,this.renderInteractive()]:[4,t.prototype.renderInteractive.call(this)];case 1:return e.sent(),[2]}}))}))},e.SCALE_FACTOR_MAGIC=.955,e.COLOR="#0000EE",e}(b),S=function(t){function e(e,n,i,r,o){void 0===o&&(o=!1);var s=t.call(this,e,n,i)||this;return s.html=r,s.margins=o?{top:0,bottom:0}:{top:n.margins.top,bottom:n.margins.bot},s}return n(e,t),e.prototype.renderInteractive=function(){return s(this,void 0,void 0,(function(){var t,e=this;return a(this,(function(n){switch(n.label){case 0:return t=this.controller.fontSize,this.controller.fontSize=this.fontSize,[4,new Promise((function(t){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(t){t.parentNode.removeChild(t)})),t()}),e.margins)}))];case 1:return n.sent(),this.controller.fontSize=t,[2]}}))}))},e}(v),L=function(t){function e(e,n,i,r,o,s){var a=t.call(this,e,n,{xLeft:r.xLeft,xRight:r.xLeft+(o||0),yTop:r.yTop,yBot:r.yTop+(s||0)})||this;return a.image=i,a.originalWidth=o,a.originalHeight=s,a.isPageBreak=void 0===a.originalHeight,a}return n(e,t),e.prototype.renderInteractive=function(){return s(this,void 0,void 0,(function(){var t=this;return a(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){try{t.controller.doc.addImage(t.image,"PNG",t.xLeft,t.yTop,t.originalWidth,t.originalHeight)}finally{e()}}))];case 1:return e.sent(),[2]}}))}))},e}(v),B=function(t){function e(e,n,i){void 0===n&&(n=null),void 0===i&&(i=!1);var r=t.call(this,null,n,e)||this;return r.controller=n,r.isBorderVisible=!1,r.isBorderVisible=i,r}return n(e,t),e.prototype.resizeBorder=function(t){var e=t?1:-1,n=this.controller.doc.getFontSize()*A.VALUE_READONLY_PADDING_SCALE;this.xLeft-=e*n,this.xRight+=e*n,this.yBot+=e*n},e.prototype.renderInteractive=function(){return s(this,void 0,void 0,(function(){return a(this,(function(t){return this.isBorderVisible&&(this.resizeBorder(!0),A.renderFlatBorders(this.controller,this),this.resizeBorder(!1)),[2]}))}))},e}(v),A=function(){function e(){}return e.parseWidth=function(t,e,n,i){if(void 0===n&&(n=1),0===t.indexOf("calc"))return e/n;var r,o=parseFloat(t);switch(t.replace(/[^A-Za-z%]/g,"")||i){case"pt":r=1;break;case"mm":r=72/25.4;break;case"cm":r=72/2.54;break;case"in":r=72;break;case"px":r=.75;break;case"pc":case"em":r=12;break;case"ex":r=6;break;default:r=e/100}return Math.min(o*r,e)},e.pxToPt=function(t){return"string"==typeof t?(isNaN(Number(t))||(t+="px"),e.parseWidth(t,Number.MAX_VALUE)):72*t/96},e.mergeRects=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n={xLeft:t[0].xLeft,xRight:t[0].xRight,yTop:t[0].yTop,yBot:t[0].yBot};return t.forEach((function(t){n.xLeft=Math.min(n.xLeft,t.xLeft),n.xRight=Math.max(n.xRight,t.xRight),n.yTop=Math.min(n.yTop,t.yTop),n.yBot=Math.max(n.yBot,t.yBot)})),n},e.createPoint=function(t,e,n){return void 0===e&&(e=!0),void 0===n&&(n=!1),{xLeft:e?t.xLeft:t.xRight,yTop:n?t.yTop:t.yBot}},e.createRect=function(t,e,n){return{xLeft:t.xLeft,xRight:t.xLeft+e,yTop:t.yTop,yBot:t.yTop+n}},e.createHeaderRect=function(t){return{xLeft:0,xRight:t.paperWidth,yTop:0,yBot:t.margins.top}},e.createFooterRect=function(t){return{xLeft:0,xRight:t.paperWidth,yTop:t.paperHeight-t.margins.bot,yBot:t.paperHeight}},e.chooseHtmlFont=function(t){return t.useCustomFontInHtml?t.fontName:this.STANDARD_FONT},e.generateCssTextRule=function(t,e,n){return'"font-size: '.concat(t,"pt; font-weight: ").concat(e,"; font-family: ").concat(n,"; color: ").concat(this.TEXT_COLOR,';"')},e.createHtmlContainerBlock=function(t,e,n){var i=this.chooseHtmlFont(e);return'<div class="__surveypdf_html" style='.concat(this.generateCssTextRule(e.fontSize,e.fontStyle,i),">")+"<style>.__surveypdf_html p { margin: 0; line-height: ".concat(e.fontSize,"pt } body { margin: 0; }</style>").concat(t,"</div>")},e.splitHtmlRect=function(t,e){var n=[],i=e.height,r=t.doc.getFontSize();e.yBot=e.yTop+r;var o=Math.floor(i/r)-1;n.push(e);for(var s=this.createPoint(e),a=0;a<o;a++)n.push(new B(this.createRect(s,e.width,r))),s.yTop+=r;var c=i-(o+1)*r;return c>0&&n.push(new B(this.createRect(s,e.width,c))),new(u.bind.apply(u,l([void 0],n,!1)))},e.createPlainTextFlat=function(t,e,n,i,r){var o=this,s=n.doc.splitTextToSize(i,n.paperWidth-n.margins.right-t.xLeft),a=this.clone(t),l=new u;return s.forEach((function(t){var i=n.measureText(t);l.addBrick(new r(e,n,o.createRect(a,i.width,i.height),t)),a.yTop+=i.height})),l},e.createTextFlat=function(t,e,n,i,r){return s(this,void 0,void 0,(function(){var o,s;return a(this,(function(a){switch(a.label){case 0:return"string"!=typeof i&&this.hasHtml(i)?[3,1]:[2,this.createPlainTextFlat(t,e,n,"string"==typeof i?i:this.getLocString(i),r)];case 1:return o=this.splitHtmlRect,s=[n],[4,this.createHTMLFlat(t,e,n,this.createHtmlContainerBlock(this.getLocString(i),n,"standard"))];case 2:return[2,o.apply(this,s.concat([a.sent()]))]}}))}))},e.hasHtml=function(t){var e=/<\/?[a-z][\s\S]*>/i;return t.hasHtml&&(e.test(t.renderedText)||e.test(t.renderedHtml))},e.getHtmlMargins=function(t,e){var n=t.paperWidth-e.xLeft-t.margins.right;return{top:t.margins.top,bottom:t.margins.bot,width:n>t.unitWidth?n:t.unitWidth}},e.createHTMLRect=function(t,n,i,r){var o=n.paperHeight-n.margins.bot-n.margins.top,s=(n.helperDoc.getNumberOfPages()-1)*(n.fontSize*Math.floor(o/n.fontSize))+r-i.top+e.HTML_TAIL_TEXT_SCALE*n.fontSize,a=n.helperDoc.getNumberOfPages();n.helperDoc.addPage();for(var l=0;l<a;l++)n.helperDoc.deletePage(1);return e.createRect(t,i.width,s)},e.createHTMLFlat=function(t,n,i,r){return s(this,void 0,void 0,(function(){var o;return a(this,(function(s){switch(s.label){case 0:return o=this.getHtmlMargins(i,t),[4,new Promise((function(s){i.helperDoc.fromHTML(r,t.xLeft,o.top,{pagesplit:!0,width:o.width},(function(a){var l=e.createHTMLRect(t,i,o,a.y);s(new S(n,i,l,r))}),o)}))];case 1:return[2,s.sent()]}}))}))},e.generateFontFace=function(t,e,n){return"@font-face { font-family: ".concat(t,"; ")+"src: url(data:application/font-woff;charset=utf-8;base64,".concat(e,") format('woff'); ")+"font-weight: ".concat(n,"; }")},e.generateFontFaceWithItalicStyle=function(t,e,n){return"@font-face { font-family: ".concat(t,"; ")+"src: url(data:application/font-woff;charset=utf-8;base64,".concat(e,") format('woff'); ")+"font-weight: ".concat(n,"; font-style: italic}")},e.htmlToXml=function(t){var e=document.implementation.createHTMLDocument("");return e.write(t.replace(/\#/g,"%23")),e.documentElement.setAttribute("xmlns",e.documentElement.namespaceURI),e.body.style.margin="unset",(new XMLSerializer).serializeToString(e.body).replace(/%23/g,"#")},e.createSvgContent=function(t,e,n){var i=this,r=document.createElement("style");r.innerHTML=".__surveypdf_html p { margin: unset; line-height: 22px; } body { margin: unset; }",document.body.appendChild(r);var o=document.createElement("div");o.className="__surveypdf_html",o.style.display="block",o.style.position="fixed",o.style.top="-10000px",o.style.left="-10000px",o.style.width=e/72*96+"px",o.style.boxSizing="initial",o.style.color="initial",o.style.fontFamily="initial",o.style.font="initial",o.style.lineHeight="initial",o.insertAdjacentHTML("beforeend",t),document.body.appendChild(o);var s=o.offsetWidth,a=o.offsetHeight;o.remove(),r.remove();var l="";return n.useCustomFontInHtml?l="<defs><style>".concat(this.generateFontFace(n.fontName,n.base64Normal,"normal"))+" ".concat(this.generateFontFace(n.fontName,n.base64Bold,"bold"),"</style></defs>"):Object.keys(k.customFonts).forEach((function(t){var e=k.customFonts[t];Object.keys(e).forEach((function(n){l+="".concat("normal"===n||"bold"===n?i.generateFontFace(t,e[n],n):i.generateFontFaceWithItalicStyle(t,e[n],"italic"===n?"normal":"bold"))})),l="<defs><style>"+l+"</style></defs>"})),{svg:'<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(s,'px" height="').concat(a,'px">')+l+"<style>.__surveypdf_html p { margin: unset; line-height: 22px; }</style>"+'<foreignObject width="'.concat(s,'px" height="').concat(a,'px">')+this.htmlToXml(t)+"</foreignObject></svg>",divWidth:s,divHeight:a}},e.setCanvas=function(t,n,i,r){t.width=n*e.HTML_TO_IMAGE_QUALITY,t.height=i*e.HTML_TO_IMAGE_QUALITY;var o=t.getContext("2d");o.scale(e.HTML_TO_IMAGE_QUALITY,e.HTML_TO_IMAGE_QUALITY),o.fillStyle=e.BACKGROUND_COLOR,o.fillRect(0,0,n,i),o.drawImage(r,0,0)},e.htmlToImage=function(t,n,i){return s(this,void 0,void 0,(function(){var r,o,s,l,c,h;return a(this,(function(a){return r=e.createSvgContent(t,n,i),o=r.svg,s=r.divWidth,l=r.divHeight,c="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(o))),(h=new Image).crossOrigin="anonymous",h.src=c,[2,new Promise((function(t){h.onload=function(){var n=document.createElement("canvas");e.setCanvas(n,s,l,h);var i=n.toDataURL("image/jpeg",e.HTML_TO_IMAGE_QUALITY);n.remove(),t({url:i,aspect:s/l})},h.onerror=function(){t({url:"data:,",aspect:n/this.EPSILON})}}))]}))}))},e.createBoldTextFlat=function(t,e,n,i){return s(this,void 0,void 0,(function(){var r;return a(this,(function(o){switch(o.label){case 0:return n.fontStyle="bold",[4,this.createTextFlat(t,e,n,i,_)];case 1:return r=o.sent(),n.fontStyle="normal",[2,r]}}))}))},e.createTitleFlat=function(t,e,n){return s(this,void 0,void 0,(function(){var i,r,o,s,l,c,h,f,d,p,g;return a(this,(function(a){switch(a.label){case 0:return i=new u,r=this.clone(t),o=n.fontSize,n.fontSize*=this.TITLE_FONT_SCALE,e.no?(s=e.no+" ",l=void 0,this.hasHtml(e.locTitle)?(n.fontStyle="bold",n.pushMargins(),n.margins.right=n.paperWidth-n.margins.left-n.measureText(s,"bold").width,[4,this.createHTMLFlat(r,e,n,this.createHtmlContainerBlock(s,n,"stan