survey-pdf
Version:
Renders JSON-driven SurveyJS forms and their responses as PDF documents in the browser or Node.js: fillable interactive PDF forms (AcroForm) or static printouts.
50 lines • 221 kB
JavaScript
/*!
* For license information please see survey.pdf.node.min.js.LICENSE.txt
*/
(function(T,z){typeof exports=="object"&&typeof module<"u"?z(exports,require("survey-core"),require("jspdf"),require("node-fetch"),require("image-size"),require("@csstools/css-calc"),require("@csstools/css-color-parser"),require("@csstools/css-parser-algorithms"),require("@csstools/css-tokenizer")):typeof define=="function"&&define.amd?define(["exports","survey-core","jspdf","node-fetch","image-size","@csstools/css-calc","@csstools/css-color-parser","@csstools/css-parser-algorithms","@csstools/css-tokenizer"],z):(T=typeof globalThis<"u"?globalThis:T||self,z(T.SurveyPDF={},T.Survey,T.jspdf,T["node-fetch"],T["image-size"],T["@csstools/css-calc"],T["@csstools/css-color-parser"],T["@csstools/css-parser-algorithms"],T["@csstools/css-tokenizer"]))})(this,(function(T,z,_t,ts,es,ss,pe,Jt,Zt){"use strict";function Vt(...m){if(m.length==0)return{xLeft:0,xRight:0,yTop:0,yBot:0};const t={xLeft:m[0].xLeft,xRight:m[0].xRight,yTop:m[0].yTop,yBot:m[0].yBot};return m.forEach(e=>{t.xLeft=Math.min(t.xLeft,e.xLeft),t.xRight=Math.max(t.xRight,e.xRight),t.yTop=Math.min(t.yTop,e.yTop),t.yBot=Math.max(t.yBot,e.yBot)}),t}function St(m){if(Array.isArray(m)&&m.length>1){if(m.length==2)return{top:m[0],bot:m[0],left:m[1],right:m[1]};if(m.length==3)return{top:m[0],left:m[1],right:m[1],bot:m[2]};if(m.length==4)return{top:m[0],right:m[1],bot:m[2],left:m[3]}}else{const t=Array.isArray(m)?m[0]:m;return{top:t,bot:t,right:t,left:t}}}function is(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}var Lt={},se,ge;function ns(){return ge||(ge=1,se=function(t,e,s,i){var n=s?s.call(i,t,e):void 0;if(n!==void 0)return!!n;if(t===e)return!0;if(typeof t!="object"||!t||typeof e!="object"||!e)return!1;var r=Object.keys(t),h=Object.keys(e);if(r.length!==h.length)return!1;for(var a=Object.prototype.hasOwnProperty.bind(e),l=0;l<r.length;l++){var u=r[l];if(!a(u))return!1;var p=t[u],v=e[u];if(n=s?s.call(i,p,v,u):void 0,n===!1||n===void 0&&p!==v)return!1}return!0}),se}var ye;function os(){if(ye)return Lt;ye=1,Object.defineProperty(Lt,"__esModule",{value:!0});var m=ns();function t(h){return h===void 0?-1:h.height}var e=(function(){function h(a,l){this.intervalTree=a,this.records=[],this.height=0,this.key=l.low,this.max=l.high,this.records.push(l)}return h.prototype.getNodeHigh=function(){for(var a=this.records[0].high,l=1;l<this.records.length;l++)this.records[l].high>a&&(a=this.records[l].high);return a},h.prototype.updateHeight=function(){this.height=Math.max(t(this.left),t(this.right))+1},h.prototype.updateMaxOfParents=function(){if(this!==void 0){var a=this.getNodeHigh();this.left!==void 0&&this.right!==void 0?this.max=Math.max(Math.max(this.left.max,this.right.max),a):this.left!==void 0&&this.right===void 0?this.max=Math.max(this.left.max,a):this.left===void 0&&this.right!==void 0?this.max=Math.max(this.right.max,a):this.max=a,this.parent&&this.parent.updateMaxOfParents()}},h.prototype._updateMaxAfterRightRotate=function(){var a=this.parent,l=a.left,u=l.getNodeHigh();l.left===void 0&&l.right!==void 0?l.max=Math.max(u,l.right.max):l.left!==void 0&&l.right===void 0?l.max=Math.max(u,l.left.max):l.left===void 0&&l.right===void 0?l.max=u:l.max=Math.max(Math.max(l.left.max,l.right.max),u);var p=this.getNodeHigh();this.left===void 0&&this.right!==void 0?this.max=Math.max(p,this.right.max):this.left!==void 0&&this.right===void 0?this.max=Math.max(p,this.left.max):this.left===void 0&&this.right===void 0?this.max=p:this.max=Math.max(Math.max(this.left.max,this.right.max),p),a.max=Math.max(Math.max(a.left.max,a.right.max),a.getNodeHigh())},h.prototype._updateMaxAfterLeftRotate=function(){var a=this.parent,l=a.right,u=l.getNodeHigh();l.left===void 0&&l.right!==void 0?l.max=Math.max(u,l.right.max):l.left!==void 0&&l.right===void 0?l.max=Math.max(u,l.left.max):l.left===void 0&&l.right===void 0?l.max=u:l.max=Math.max(Math.max(l.left.max,l.right.max),u);var p=this.getNodeHigh();this.left===void 0&&this.right!==void 0?this.max=Math.max(p,this.right.max):this.left!==void 0&&this.right===void 0?this.max=Math.max(p,this.left.max):this.left===void 0&&this.right===void 0?this.max=p:this.max=Math.max(Math.max(this.left.max,this.right.max),p),a.max=Math.max(Math.max(a.left.max,l.max),a.getNodeHigh())},h.prototype._leftRotate=function(){var a=this.right;a.parent=this.parent,a.parent===void 0?this.intervalTree.root=a:a.parent.left===this?a.parent.left=a:a.parent.right===this&&(a.parent.right=a),this.right=a.left,this.right!==void 0&&(this.right.parent=this),a.left=this,this.parent=a,this.updateHeight(),a.updateHeight()},h.prototype._rightRotate=function(){var a=this.left;a.parent=this.parent,a.parent===void 0?this.intervalTree.root=a:a.parent.left===this?a.parent.left=a:a.parent.right===this&&(a.parent.right=a),this.left=a.right,this.left!==void 0&&(this.left.parent=this),a.right=this,this.parent=a,this.updateHeight(),a.updateHeight()},h.prototype._rebalance=function(){if(t(this.left)>=2+t(this.right)){var a=this.left;t(a.left)>=t(a.right)?(this._rightRotate(),this._updateMaxAfterRightRotate()):(a._leftRotate(),this._rightRotate(),this._updateMaxAfterRightRotate())}else if(t(this.right)>=2+t(this.left)){var l=this.right;t(l.right)>=t(l.left)?(this._leftRotate(),this._updateMaxAfterLeftRotate()):(l._rightRotate(),this._leftRotate(),this._updateMaxAfterLeftRotate())}},h.prototype.insert=function(a){a.low<this.key?this.left===void 0?(this.left=new h(this.intervalTree,a),this.left.parent=this):this.left.insert(a):this.right===void 0?(this.right=new h(this.intervalTree,a),this.right.parent=this):this.right.insert(a),this.max<a.high&&(this.max=a.high),this.updateHeight(),this._rebalance()},h.prototype._getOverlappingRecords=function(a,l,u){if(a.key<=u&&l<=a.getNodeHigh()){for(var p=[],v=0;v<a.records.length;v++)a.records[v].high>=l&&p.push(a.records[v]);return p}return[]},h.prototype.search=function(a,l){if(this===void 0)return[];var u=[],p=[],v=[];return a>this.max?[]:(this.left!==void 0&&this.left.max>=a&&(u=this.left.search(a,l)),p=this._getOverlappingRecords(this,a,l),l<this.key?u.concat(p):(this.right!==void 0&&(v=this.right.search(a,l)),u.concat(p,v)))},h.prototype.searchExisting=function(a){if(this!==void 0){if(this.key===a)return this;if(a<this.key){if(this.left!==void 0)return this.left.searchExisting(a)}else if(this.right!==void 0)return this.right.searchExisting(a)}},h.prototype._minValue=function(){return this.left===void 0?this:this.left._minValue()},h.prototype.remove=function(a){var l=this.parent;if(a.key<this.key)return this.left!==void 0?this.left.remove(a):void 0;if(a.key>this.key)return this.right!==void 0?this.right.remove(a):void 0;if(this.left!==void 0&&this.right!==void 0){var u=this.right._minValue();return this.key=u.key,this.records=u.records,this.right.remove(this)}else{if(l.left===this)return this.right!==void 0?(l.left=this.right,this.right.parent=l):(l.left=this.left,this.left!==void 0&&(this.left.parent=l)),l.updateMaxOfParents(),l.updateHeight(),l._rebalance(),this;if(l.right===this)return this.right!==void 0?(l.right=this.right,this.right.parent=l):(l.right=this.left,this.left!==void 0&&(this.left.parent=l)),l.updateMaxOfParents(),l.updateHeight(),l._rebalance(),this}},h})();Lt.Node=e;var s=(function(){function h(){this.count=0}return h.prototype.insert=function(a){if(a.low>a.high)throw new Error("`low` value must be lower or equal to `high` value");if(this.root===void 0)return this.root=new e(this,a),this.count++,!0;var l=this.root.searchExisting(a.low);if(l!==void 0){for(var u=0;u<l.records.length;u++)if(m(l.records[u],a))return!1;return l.records.push(a),a.high>l.max&&(l.max=a.high,l.parent&&l.parent.updateMaxOfParents()),this.count++,!0}else return this.root.insert(a),this.count++,!0},h.prototype.search=function(a,l){return this.root===void 0?[]:this.root.search(a,l)},h.prototype.remove=function(a){if(this.root===void 0)return!1;var l=this.root.searchExisting(a.low);if(l===void 0)return!1;if(l.records.length>1){for(var u=void 0,p=0;p<l.records.length;p++)if(m(l.records[p],a)){u=l.records[p],l.records.splice(p,1);break}if(u){if(u=void 0,a.high===l.max){var v=l.getNodeHigh();l.left!==void 0&&l.right!==void 0?l.max=Math.max(Math.max(l.left.max,l.right.max),v):l.left!==void 0&&l.right===void 0?l.max=Math.max(l.left.max,v):l.left===void 0&&l.right!==void 0?l.max=Math.max(l.right.max,v):l.max=v,l.parent&&l.parent.updateMaxOfParents()}return this.count--,!0}else return!1}else if(l.records.length===1)if(m(l.records[0],a))if(this.root.key===l.key){var B=new e(this,{low:a.low,high:a.low});B.left=this.root,this.root.parent=B;var M=this.root.remove(l);return this.root=B.left,this.root!==void 0&&(this.root.parent=void 0),M?(M=void 0,this.count--,!0):!1}else{var M=this.root.remove(l);return M?(M=void 0,this.count--,!0):!1}else return!1;else return!1},h.prototype.inOrder=function(){return new n(this.root)},h.prototype.preOrder=function(){return new r(this.root)},h})();Lt.IntervalTree=s;var i=(function(){function h(){this.tree=new s}return h.prototype.insert=function(a,l,u){return this.tree.insert({low:a,high:l,data:u})},h.prototype.remove=function(a,l,u){return this.tree.remove({low:a,high:l,data:u})},h.prototype.search=function(a,l){return this.tree.search(a,l).map(function(u){return u.data})},h.prototype.inOrder=function(){return this.tree.inOrder()},h.prototype.preOrder=function(){return this.tree.preOrder()},Object.defineProperty(h.prototype,"count",{get:function(){return this.tree.count},enumerable:!0,configurable:!0}),h})();Lt.default=i;var n=(function(){function h(a){this.stack=[],a!==void 0&&this.push(a)}return h.prototype.next=function(){return this.currentNode===void 0?{done:!0,value:void 0}:this.i<this.currentNode.records.length?{done:!1,value:this.currentNode.records[this.i++]}:(this.currentNode.right!==void 0?this.push(this.currentNode.right):this.pop(),this.next())},h.prototype.push=function(a){for(this.currentNode=a,this.i=0;this.currentNode.left!==void 0;)this.stack.push(this.currentNode),this.currentNode=this.currentNode.left},h.prototype.pop=function(){this.currentNode=this.stack.pop(),this.i=0},h})();Lt.InOrder=n,typeof Symbol=="function"&&(n.prototype[Symbol.iterator]=function(){return this});var r=(function(){function h(a){this.stack=[],this.i=0,this.currentNode=a}return h.prototype.next=function(){return this.currentNode===void 0?{done:!0,value:void 0}:this.i<this.currentNode.records.length?{done:!1,value:this.currentNode.records[this.i++]}:(this.currentNode.right!==void 0&&this.push(this.currentNode.right),this.currentNode.left!==void 0&&this.push(this.currentNode.left),this.pop(),this.next())},h.prototype.push=function(a){this.stack.push(a)},h.prototype.pop=function(){this.currentNode=this.stack.pop(),this.i=0},h})();return Lt.PreOrder=r,typeof Symbol=="function"&&(r.prototype[Symbol.iterator]=function(){return this}),Lt}var me=os(),rs=is(me);class W{constructor(...t){this.bricks=[],this.isPageBreak=!1,this._xLeft=0,this._xRight=0,this._yTop=0,this._yBot=0,this.addBrick(...t)}addBeforeRenderCallback(t){this.bricks.forEach(e=>e.addBeforeRenderCallback(t))}get xLeft(){return this._xLeft}set xLeft(t){this.shift(t-this.xLeft,0,0,0),this._xLeft=t}get xRight(){return this._xRight}set xRight(t){this.shift(0,t-this.xRight,0,0),this._xRight=t}get yTop(){return this._yTop}set yTop(t){this.shift(0,0,t-this.yTop,0),this._yTop=t}get yBot(){return this._yBot}set yBot(t){this.shift(0,0,0,t-this.yBot),this._yBot=t}shift(t,e,s,i){this.bricks.forEach(n=>{n.xLeft+=t,n.xRight+=e,n.yTop+=s,n.yBot+=i})}get width(){return this.xRight-this.xLeft}get height(){return this.yBot-this.yTop}async render(){for(let t=0;t<this.bricks.length;t++)await this.bricks[t].render()}get isEmpty(){return this.bricks.length===0}_updateRect(){if(this.bricks.length>0){let t=Vt(...this.bricks);this._xLeft=t.xLeft,this._xRight=t.xRight,this._yTop=t.yTop,this._yBot=t.yBot}}addBrick(...t){t.length!=0&&(this.bricks.push(...t),this._updateRect())}unfold(){const t=[];return this.bricks.forEach(e=>{t.push(...e.unfold())}),t}translateX(t){this.bricks.forEach(s=>s.translateX(t));const e=t(this.xLeft,this.xRight);this._xLeft=e.xLeft,this._xRight=e.xRight}translateY(t){this.bricks.forEach(e=>e.translateY(t)),this._updateRect()}setPageNumber(t){this.bricks.forEach(e=>e.setPageNumber(t))}getPageNumber(){return this.bricks[0].getPageNumber()}updateRect(){this.bricks.forEach(t=>{t.updateRect()}),this._updateRect()}increasePadding(t){if(t.top==0&&t.bottom==0)return;const e=new me.IntervalTree;this.bricks.filter(i=>!i.isEmpty).forEach(i=>{e.insert({low:i.xLeft,high:i.xRight,yTop:i.yTop,yBot:i.yBot})}),this.bricks.forEach(i=>{const n={top:0,bottom:0},r=e.search(i.xLeft,i.xRight).reduce((h,a)=>(h.yTop=Math.min(h.yTop,a.yTop),h.yBot=Math.max(h.yBot,a.yBot),h),{yTop:Number.MAX_VALUE,yBot:Number.MIN_VALUE});i.yTop<=r.yTop&&(n.top=t.top),i.yBot>=r.yBot&&(n.bottom=t.bottom),(n.top!==0||n.bottom!==0)&&i.increasePadding(n)}),this.updateRect()}get contentRect(){const t=Vt(...this.bricks.map(e=>e.contentRect));return{...t,width:t.xRight-t.xLeft,height:t.yBot-t.yTop}}}class ie{constructor(t,e,s,i){this.point=t,this.bricks=e,this.controller=s,this.repository=i}}class as extends ie{constructor(t,e,s,i,n){super(t,e,i,n),this.question=s}}class ls extends ie{constructor(t,e,s,i,n){super(t,e,i,n),this.panel=s}}class hs extends ie{constructor(t,e,s,i,n){super(t,e,i,n),this.page=s}}const cs={padding:0,borderWidth:0,backgroundColor:null,borderColor:null,borderMode:1,borderRadius:0};class At extends W{get includedBorderWidth(){if(!this.includedBorderWidthValue){const t=St(this.style.borderWidth);Object.keys(t).forEach(e=>{switch(this.style.borderMode){case It.Inside:break;case It.Middle:t[e]=t[e]/2;break;default:return 0}}),this.includedBorderWidthValue=t}return this.includedBorderWidthValue}get padding(){return this._padding||(this._padding=St(this.style.padding)),this._padding}constructor(t,e,s){super(),this.controller=t,this.layout=e,this.style=o.mergeObjects({},cs,s)}getStartPoint(){return{yTop:this.layout.yTop+this.padding.top+this.includedBorderWidth.top,xLeft:this.layout.xLeft+this.padding.left+this.includedBorderWidth.left}}startSetup(){this.controller.pushMargins(),this.controller.margins.left=this.layout.xLeft+this.padding.left+this.includedBorderWidth.left,this.controller.margins.right=this.controller.paperWidth-(this.layout.xLeft+this.layout.width)+this.padding.right+this.includedBorderWidth.right}finishSetup(){this.controller.popMargins(),this.increasePadding({top:this.padding.top+this.includedBorderWidth.top,bottom:this.padding.bot+this.includedBorderWidth.bot});let t=-1;const e=()=>{const s=this.controller.getCurrentPageIndex();if(s!=t){t=s;const i=this.unfold().filter(u=>!u.isEmpty),n=i.filter(u=>u.getPageNumber()==s),r=o.mergeRects(...n),h=["top","right","bot","left"],a=new Array(4).fill(0,0,4).map((u,p)=>{var v;return(v=Array.isArray(this.style.borderWidth)?this.style.borderWidth[p]:this.style.borderWidth)!==null&&v!==void 0?v:0}),l=new Array(4).fill(0,0,4).map((u,p)=>{var v;const B=(v=Array.isArray(this.style.borderRadius)?this.style.borderRadius[p]:this.style.borderRadius)!==null&&v!==void 0?v:0;return Math.min(Math.max(B-a[p]-this.includedBorderWidth[h[p]]),0),Math.max(B-(a[p-1<0?a.length-1:p-1]-this.includedBorderWidth[h[p-1<0?h.length-1:p-1]]),0)});if(i[0]!=n[0]&&(l[0]=0,l[1]=0,a[0]=0),i[i.length-1]!==n[n.length-1]&&(l[2]=0,l[3]=0,a[2]=0),this.style.backgroundColor!==null){this.controller.setFillColor(this.style.backgroundColor);const u=o.createRect({xLeft:this.layout.xLeft+this.includedBorderWidth.left,yTop:r.yTop+this.includedBorderWidth.top},this.layout.width-this.includedBorderWidth.left-this.includedBorderWidth.right,r.yBot-r.yTop-this.includedBorderWidth.top-this.includedBorderWidth.bot),{lines:p,point:v}=o.getDocLinesFromShape(o.createRoundedShape(u,{...this.style,borderRadius:l}));this.controller.doc.lines(p,...v,[1,1],"F",!0),this.controller.restoreFillColor()}this.style.borderColor!==null&&o.renderFlatBorders(this.controller,{xLeft:this.layout.xLeft,xRight:this.layout.xLeft+this.layout.width,yTop:r.yTop,yBot:r.yBot,width:this.layout.width,height:r.yBot-r.yTop},{...this.style,borderRadius:l,borderWidth:a})}};this.bricks.forEach(s=>{s.addBeforeRenderCallback(e)})}getBricks(){return this.bricks.slice()}async setup(t){this.startSetup();const e=[];await t(this.getStartPoint(),e),this.addBrick(...e),this.finishSetup()}set xLeft(t){}get xLeft(){return this.layout.xLeft}set xRight(t){}get xRight(){return this.layout.xLeft+this.layout.width}get width(){return this.layout.width}fitToHeight(t,e=!1){if(e){const s=(t-this.height)/2;this.translateY((i,n)=>({yTop:i+s,yBot:n+s})),this.increasePadding({top:s,bottom:s})}else this.increasePadding({top:0,bottom:t-this.height})}}class tt{constructor(t,e,s,i){this.survey=t,this.question=e,this.controller=s,this.style=i}async generateFlatTitle(t){const e=new W;let s=o.clone(t);const i={...this.style.title};if(this.question.no){const r=o.mergeObjects({},i,this.style.number),h=this.question.no;let a;o.hasHtml(this.question.locTitle)?(this.controller.pushMargins(),this.controller.margins.right=this.controller.paperWidth-this.controller.margins.left-this.controller.measureText(h,r).width,a=await o.createHTMLFlat(s,this.controller,o.createHtmlContainerBlock(h,this.controller,r),r),this.controller.popMargins()):a=await o.createTextFlat(s,this.controller,h,r),e.addBrick(a),s.xLeft=a.xRight+this.style.spacing.titleNumberGap}this.controller.pushMargins(),this.controller.margins.left=s.xLeft;const n=await o.createTextFlat(s,this.controller,this.question.locTitle,i);if(e.addBrick(n),this.controller.popMargins(),this.question.isRequired){const r=o.mergeObjects({},i,this.style.requiredMark),h=this.question.requiredMark;if(o.hasHtml(this.question.locTitle))s=o.createPoint(n.unfold()[0],!1,!1),s.xLeft+=this.style.spacing.titleRequiredMarkGap,this.controller.pushMargins(),this.controller.margins.right=this.controller.paperWidth-this.controller.margins.left-this.controller.measureText(h,r).width,e.addBrick(await o.createHTMLFlat(s,this.controller,o.createHtmlContainerBlock(h,this.controller,r),r)),this.controller.popMargins();else{const a=n.unfold().pop();if(this.style.spacing.titleRequiredMarkGap+this.controller.measureText(h,r).width<o.getPageAvailableWidth(this.controller)+this.controller.leftTopPoint.xLeft-a.xRight)s=o.createPoint(a,!1,!0),s.xLeft+=this.style.spacing.titleRequiredMarkGap;else{const l=s.xLeft;s=o.createPoint(a,!1,!1),s.xLeft=l}e.addBrick(await o.createTextFlat(s,this.controller,h,r))}}return e}async generateFlatDescription(t){return await o.createTextFlat(t,this.controller,this.question.locDescription,{...this.style.description})}async generateFlatHeader(t){const e=new At(this.controller,{...t,width:o.getPageAvailableWidth(this.controller)},this.style.header);return await e.setup(async(s,i)=>{const n=await this.generateFlatTitle(s);if(i.push(n),this.question.hasDescriptionUnderTitle){const r=o.createPoint(n,!0,!1);r.yTop+=this.style.spacing.titleDescriptionGap,r.xLeft+=this.style.spacing.contentIndentStart,i.push(await this.generateFlatDescription(r))}}),e}async generateFlatsComment(t){const e=this.question.locCommentText,s=await o.createTextFlat(t,this.controller,e,this.style.commentLabel),i=o.createPoint(s);i.yTop+=this.style.spacing.commentLabelGap;const n=o.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),r=o.getPatchedTextStyle(this.controller,o.mergeObjects({},this.style.comment,n?this.style.commentReadOnly:void 0));return new W(s,await o.createCommentFlat(i,this.controller,{fieldName:this.question.id+"_comment",rows:this.controller.otherRowsCount,value:this.question.comment!==void 0&&this.question.comment!==null?this.question.comment:"",shouldRenderBorders:z.settings.readOnlyCommentRenderMode==="textarea",shouldRenderReadOnly:n,isReadOnly:this.question.isReadOnly,isMultiline:!0,placeholder:""},r))}async generateFlatsComposite(t){const e=this.question.contentPanel;return e?await o.generatePanelFlats(this.survey,this.controller,e,t):(this.question=o.getContentQuestion(this.question),await this.generateFlatsContent(t))}async generateFlatsContent(t){return null}async generateFlatsContentWithOptionalElements(t){const e=[],s=await this.generateFlatsComposite(t);Array.isArray(s)&&e.push(...s);const i=o.clone(t);if(s&&s.length>0&&(i.yTop=o.mergeRects(...s).yBot),this.question.hasComment&&(i.yTop+=this.style.spacing.contentCommentGap,e.push(await this.generateFlatsComment(i))),this.question.hasDescriptionUnderInput){const n=new W;e!==null&&e.length!==0&&n.addBrick(e.pop()),i.yTop+=this.style.spacing.contentDescriptionGap,n.addBrick(await this.generateFlatDescription(i)),e.push(n)}return e}async generateFlats(t){this.controller.pushMargins(),this.controller.margins.left+=this.controller.measureText(this.question.indent).width;const e={xLeft:t.xLeft+this.controller.measureText(this.question.indent).width,yTop:t.yTop},s=[];let i=this.question.getTitleLocation();i=this.question.hasTitle?i:"hidden";const n="matrix";switch(i){case"top":case"default":{const a=new W,l=await this.generateFlatHeader(e);a.addBrick(l);let u=o.createPoint(l);const p=this.style.spacing.contentIndentStart;u.xLeft+=p,a.addBrick(o.createRowlineFlat(o.createPoint(l),this.controller)),u.yTop+=this.style.spacing.headerContentGap+o.EPSILON,this.controller.pushMargins(),this.controller.margins.left+=p;const v=await this.generateFlatsContentWithOptionalElements(u);this.controller.popMargins(),v!==null&&v.length!==0&&a.addBrick(v.shift()),s.push(a),s.push(...v);break}case"bottom":{const a=o.clone(e),l=new W;this.controller.pushMargins();const u=this.style.spacing.contentIndentStart;a.xLeft+=u,this.controller.margins.left+=u;const p=await this.generateFlatsContentWithOptionalElements(a);this.controller.popMargins(),p!==null&&p.length!==0&&l.addBrick(p.pop());const v=e;s.length!==0&&(v.yTop=s[s.length-1].yBot),v.yTop+=this.style.spacing.headerContentGap,l.addBrick(await this.generateFlatHeader(v)),s.push(...p),s.push(l);break}case"left":{this.controller.pushMargins(this.controller.margins.left,this.controller.paperWidth-this.controller.margins.left-o.getPageAvailableWidth(this.controller)*this.style.inlineHeaderWidthPercentage);const a=await this.generateFlatHeader(e),l=o.createPoint(a,!1,!0);this.controller.popMargins(),l.xLeft+=this.style.spacing.inlineHeaderContentGap,this.controller.margins.left=l.xLeft;const u=await this.generateFlatsContentWithOptionalElements(l);u!==null&&u.length!==0&&a.addBrick(u.shift()),s.push(a),s.push(...u);break}case"hidden":case n:default:{const a=o.clone(e);if(this.controller.pushMargins(),i!==n){const l=this.style.spacing.contentIndentStart;a.xLeft+=l,this.controller.margins.left+=l}s.push(...await this.generateFlatsContentWithOptionalElements(a)),this.controller.popMargins();break}}this.controller.popMargins();const r=new as(t,s,this.question,this.controller,N.getInstance());this.question.customWidget&&this.question.customWidget.isFit(this.question)&&this.question.customWidget.pdfRender&&this.survey.onRenderQuestion.unshift(this.question.customWidget.pdfRender),await this.survey.onRenderQuestion.fire(this.survey,r);const h=[...r.bricks];return this.survey.afterRenderSurveyElement(this.question,h),h}}z.Serializer.addProperty("question",{name:"readonlyRenderAs",default:"auto",choices:["auto","text","acroform"],visible:!1});class xe extends tt{async generateFlatsContent(t){return[await o.createTextFlat(t,this.controller,`${this.question.displayValue}`)]}}class N{constructor(){this.questions={}}static getInstance(){return N.instance}register(t,e){this.questions[t]=e}registerPanel(t){this.panel=t}registerPage(t){this.page=t}registerSurvey(t){this.survey=t}isTypeRegistered(t){return!!this.questions[t]}getRenderer(t){return this.questions[t]}create(t,e,s,i,n){var r;const h=typeof n>"u"?e.getType():n;let a=this.getRenderer(h);return a||(!((r=e.customWidget)===null||r===void 0)&&r.pdfRender?a=tt:a=xe),new a(t,e,s,i)}createPanel(t,e,s,i){return new this.panel(t,e,s,i)}createPage(t,e,s,i){return new this.page(t,e,s,i)}createSurvey(t,e,s){return new this.survey(t,e,s)}static registerPanel(t){this.getInstance().registerPanel(t)}static registerPage(t){this.getInstance().registerPage(t)}static registerSurvey(t){this.getInstance().registerSurvey(t)}static register(t,e){this.getInstance().register(t,e)}static getRenderer(t){return this.getInstance().getRenderer(t)}}N.instance=new N;class jt extends z.EventBase{constructor(){super(...arguments),this.isProcessing=!1}unshift(t){this.hasFunc(t)||(this.callbacks==null&&(this.callbacks=new Array),this.callbacks.unshift(t))}async fire(t,e){if(!(this.callbacks==null||this.isProcessing)){this.isProcessing=!0;for(var s=0;s<this.callbacks.length;s++)await this.callbacks[s](t,e),this.isProcessing=!1}}}class pt{get xLeft(){return this._xLeft}set xLeft(t){this.setXLeft(t)}get xRight(){return this._xRight}set xRight(t){this.setXRight(t)}get yTop(){return this._yTop}set yTop(t){this.setYTop(t)}get yBot(){return this._yBot}set yBot(t){this.setYBottom(t)}constructor(t,e,s={}){this.controller=t,this.options=s,this.isPageBreak=!1,this.beforeRenderEvent=new jt,this.padding={top:0,bottom:0},this.xLeft=e.xLeft,this.xRight=e.xRight,this.yTop=e.yTop,this.yBot=e.yBot}translateY(t){const e=t(this.yTop,this.yBot);this.yTop=e.yTop,this.yBot=e.yBot}translateX(t){const e=t(this.xLeft,this.xRight);this.xLeft=e.xLeft,this.xRight=e.xRight}get width(){return this.xRight-this.xLeft}get height(){return this.yBot-this.yTop}getShouldRenderReadOnly(){return this.options.shouldRenderReadOnly}async render(){await this.beforeRenderEvent.fire(this,{}),this.getShouldRenderReadOnly()?await this.renderReadOnly():await this.renderInteractive(),this.afterRenderCallback&&this.afterRenderCallback()}async renderInteractive(){}async renderReadOnly(){await this.renderInteractive()}unfold(){return[this]}getCorrectedText(t){return this.controller.isRTL?(t||"").split("").reverse().join(""):t}setXLeft(t){this._xLeft=t,this.resetContentRect()}setXRight(t){this._xRight=t,this.resetContentRect()}setYTop(t){this._yTop=t,this.resetContentRect()}setYBottom(t){this._yBot=t,this.resetContentRect()}getPageNumber(){return this._pageNumber}setPageNumber(t){this._pageNumber=t}addBeforeRenderCallback(t){this.beforeRenderEvent.unshift(t)}increasePadding(t){t.top==0&&t.bottom==0||(Object.keys(this.padding).forEach(e=>{this.padding[e]+=t[e]}),this._yTop-=t.top,this._yBot+=t.bottom,this.resetContentRect())}get contentRect(){return this._contentRect||(this._contentRect=this.getContentRect()),this._contentRect}resetContentRect(){this._contentRect=void 0}getContentRect(){const t=this.yBot-this.padding.bottom,e=this.yTop+this.padding.top;return{yBot:t,yTop:e,xLeft:this.xLeft,xRight:this.xRight,width:this.width,height:Math.max(t-e,0)}}updateRect(){}get isEmpty(){return!1}}class zt extends pt{constructor(t,e,s,i){super(t,e,s),this.options=s,this.style=i,this.align={isInputRtl:!1,isOutputRtl:t.isRTL,align:t.isRTL?"right":"left",baseline:"middle",lineHeightFactor:1.15}}escapeText(){return this.options.text.replace(/\t/g,Array(5).join("\xA0"))}async renderInteractive(){const t=this.alignPoint(this.contentRect);this.controller.setTextStyle(this.style),this.controller.doc.text(this.escapeText(),t.xLeft,t.yTop,this.align),this.controller.restoreTextStyle()}alignPoint(t){return{xLeft:this.controller.isRTL?t.xRight:t.xLeft,yTop:t.yTop+(t.yBot-t.yTop)/2}}}class Wt extends zt{constructor(t,e,s,i){super(t,e,s,i),this.options=s,this.style=i}async renderInteractive(){this.controller.setTextStyle(o.mergeObjects({},this.style,{fontColor:"#FFFFFF00"}));let t=this.controller.unitHeight*(this.controller.doc.getLineHeightFactor()-Wt.SCALE_FACTOR_MAGIC),e=this.contentRect.yTop+(this.contentRect.yBot-this.contentRect.yTop)-t;this.controller.doc.textWithLink(this.options.text,this.contentRect.xLeft,e,{url:this.options.link}),this.controller.restoreTextStyle(),await super.renderInteractive()}async renderReadOnly(){this.options.readOnlyShowLink?super.renderInteractive():this.renderInteractive()}}Wt.SCALE_FACTOR_MAGIC=.955;class ve extends pt{constructor(t,e,s,i){super(t,e),this.options=s,this.style=i}async renderInteractive(){this.controller.setTextStyle(this.style),await new Promise(t=>{this.controller.doc.fromHTML(this.options.html,this.contentRect.xLeft,this.contentRect.yTop,{width:this.contentRect.width,pagesplit:!0},function(){[].slice.call(document.querySelectorAll(".sjs-pdf-hidden-html-div")).forEach(function(e){e.parentNode.removeChild(e)}),t()},{top:this.controller.margins.top,bottom:this.controller.margins.bot})}),this.controller.restoreTextStyle()}}class be extends pt{constructor(t,e,s){super(t,e),this.options=s,this.isPageBreak=this.options.height===void 0}async renderInteractive(){const t=this.options.width||this.contentRect.width,e=this.options.height||this.contentRect.height,s=this.contentRect.width,i=this.contentRect.height,n=s>t?this.contentRect.xLeft+(s-t)/2:this.contentRect.xLeft,r=i>e?this.contentRect.yTop+(i-e)/2:this.contentRect.yTop;await new Promise(h=>{try{this.controller.doc.addImage(this.options.link,"PNG",n,r,Math.min(t,s),Math.min(e,i),this.options.imageId,"MEDIUM")}finally{h()}})}}class Tt extends pt{constructor(t,e,s={}){super(t,e),this.style=s}async renderInteractive(){if(this.style.color){this.controller.setFillColor(this.style.color);const{lines:t,point:e}=o.getDocLinesFromShape(o.createRoundedShape(this.contentRect,this.style));this.controller.doc.lines(t,...e,[1,1],"F",!0),this.controller.restoreFillColor()}o.renderFlatBorders(this.controller,this.contentRect,this.style)}}class ne{constructor(t,e,s){this.controller=t,this.color=s,this.isPageBreak=!1,this.beforeRenderEvent=new jt,this.padding={top:0,bottom:0},this.xLeft=e.xLeft,this.xRight=e.xRight,this.yTop=e.yTop,this.yBot=e.yBot}get width(){return this.xRight-this.xLeft}get height(){return this.yBot-this.yTop}async render(){await this.beforeRenderEvent.fire(this,{}),this.color!==null&&(this.controller.setDrawColor(this.color),this.controller.doc.line(this.contentRect.xLeft,this.yTop,this.contentRect.xRight,this.contentRect.yTop),this.controller.restoreDrawColor())}getPageNumber(){return this._pageNumber}setPageNumber(t){this._pageNumber=t}addBeforeRenderCallback(t){this.beforeRenderEvent.add(t)}unfold(){return[this]}translateX(t){}translateY(t){const e=t(this.yTop,this.yBot);this.yTop=e.yTop,this.yBot=e.yBot}increasePadding(t){t.top==0&&t.bottom==0||(Object.keys(this.padding).forEach(e=>{this.padding[e]+=t[e]}),this.yTop-=t.top,this.yBot+=t.bottom,this._contentRect=void 0)}get contentRect(){if(!this._contentRect){const t=this.yTop+=this.padding.top,e=this.yBot-=this.padding.bottom;this._contentRect={yBot:e,yTop:t,xLeft:this.xLeft,xRight:this.xRight,width:this.width,height:e-t}}return this._contentRect}updateRect(){}get isEmpty(){return this.color===null}}class we extends pt{constructor(t,e,s,i){var n,r,h,a;super(t,e),this.options=s,this.style=i,s.isMultiline=(n=s.isMultiline)!==null&&n!==void 0?n:!1,s.placeholder=(r=s.placeholder)!==null&&r!==void 0?r:"",s.inputType=(h=s.inputType)!==null&&h!==void 0?h:"",s.value=(a=s.value)!==null&&a!==void 0?a:""}renderColorQuestion(){this.controller.setFillColor(this.options.value||"black"),this.controller.doc.rect(this.contentRect.xLeft,this.contentRect.yTop,this.contentRect.width,this.contentRect.height,"F"),this.controller.restoreFillColor()}async renderInteractive(){var t;if(this.options.inputType==="color"){this.renderColorQuestion();return}const e=o.createAcroformRect(o.createRectInsideBorders(this.contentRect,(t=this.style.borderWidth)!==null&&t!==void 0?t:0));this.style.backgroundColor&&(this.controller.setFillColor(this.style.backgroundColor),this.controller.doc.rect(...e,"F"),this.controller.restoreFillColor());const{color:s}=o.parseColor(this.style.fontColor),i=this.options.inputType==="password"?new this.controller.doc.AcroFormPasswordField:new this.controller.AcroFormTextField;i.fieldName=this.options.fieldName,i.fontName=this.style.fontName,i.fontSize=this.style.fontSize,i.maxFontSize=this.style.fontSize,i.isUnicode=o.isCustomFont(this.controller,i.fontName),this.options.inputType!=="password"?(i.value=this.getCorrectedText(this.options.value),i.defaultValue=this.getCorrectedText(this.options.placeholder)):i.value="",i.multiline=this.options.isMultiline,i.readOnly=this.options.isReadOnly,i.color=s,i.Rect=e,this.controller.doc.addField(i),o.renderFlatBorders(this.controller,this.contentRect,this.style)}shouldRenderFlatBorders(){return this.options.shouldRenderBorders}get textBrick(){return this._textBrick}set textBrick(t){this._textBrick=t;const e=t.unfold(),s=e.length;let i=0;const n={},r=h=>{if(this.shouldRenderFlatBorders()){i++;const a=this.controller.getCurrentPageIndex();if(n[a]||(n[a]=[]),n[a].push(h.contentRect),i>=s){const l=Object.keys(n),u=l.length==1;l.forEach(p=>{const v=Vt(...n[p]),B={xLeft:this.contentRect.xLeft,xRight:this.contentRect.xRight,width:this.contentRect.width,yTop:u?this.contentRect.yTop:v.yTop,yBot:u?this.contentRect.yBot:v.yBot,height:u?this.contentRect.height:v.yBot-v.yTop};this.controller.setPage(Number(p)),o.renderFlatBorders(this.controller,B,this.style),this.controller.setPage(a)})}}};e.forEach(h=>{h.afterRenderCallback=r.bind(this.contentRect,h)}),this.updateRect()}updateRect(){if(this.textBrick){const t=this.width;this.textBrick.updateRect(),this._xLeft=this.textBrick.xLeft,this._xRight=this.textBrick.xLeft+t,this._yTop=this.textBrick.yTop,this._yBot=this.textBrick.yBot}}async renderReadOnly(){this.controller.pushMargins(this.contentRect.xLeft,this.controller.paperWidth-this.contentRect.xRight),this.options.inputType==="color"?this.renderColorQuestion():await this.textBrick.render(),this.controller.popMargins()}unfold(){return this.getShouldRenderReadOnly()&&this.options.inputType!=="color"?this.textBrick.unfold():super.unfold()}translateX(t){const e=t(this.contentRect.xLeft,this.contentRect.xRight);this._xLeft=e.xLeft,this._xRight=e.xRight,this.textBrick&&this.textBrick.translateX(t)}setXLeft(t){const e=t-this._xLeft;super.setXLeft(t),this.textBrick&&(this.textBrick.xLeft=this.textBrick.xLeft+e)}setXRight(t){const e=t-this._xRight;super.setXRight(t),this.textBrick&&(this.textBrick.xRight=this.textBrick.xRight+e)}setYTop(t){const e=t-this._yTop;super.setYTop(t),this.textBrick&&(this.textBrick.yTop=this.textBrick.yTop+e)}setYBottom(t){const e=t-this._yBot;super.setYBottom(t),this.textBrick&&(this.textBrick.yBot=this.textBrick.yBot+e)}setPageNumber(t){this.getShouldRenderReadOnly()&&this.options.inputType!=="color"?this.textBrick.setPageNumber(t):super.setPageNumber(t)}getPageNumber(){return this.getShouldRenderReadOnly()&&this.options.inputType!=="color"?this.textBrick.getPageNumber():super.getPageNumber()}increasePadding(t){t.top==0&&t.bottom==0||(this.getShouldRenderReadOnly()&&this.options.inputType!=="color"?(this.textBrick.increasePadding(t),this.updateRect()):super.increasePadding(t))}addBeforeRenderCallback(t){this.getShouldRenderReadOnly()&&this.options.inputType!=="color"?this.textBrick.addBeforeRenderCallback(t):super.addBeforeRenderCallback(t)}getContentRect(){return this.textBrick?{...this.textBrick.contentRect,xLeft:this.xLeft,xRight:this.xRight,width:this.xRight-this.xLeft}:super.getContentRect()}}class Re{constructor(){this.hash={},this.imageId=1}getImageId(){return`image_${this.imageId++}`}async _getImageInfo(t){return{data:t,width:0,height:0,id:this.getImageId()}}async getImageInfo(t){if(!this.hash[t])try{this.hash[t]=await this._getImageInfo(t)}catch{this.hash[t]=this.emptyImage}return this.hash[t]}async applyImageFit(t,e,s,i){if(e=="fill")return{data:t.data,id:t.id,width:s,height:i};if((e=="contain"||e=="cover")&&t.width&&t.height&&s&&s){const n=Math.min(s/t.width,i/t.height);return{data:t.data,id:t.id,width:t.width*n,height:t.height*n}}else return t}get emptyImage(){return{data:"",width:0,height:0,id:"image_0"}}clear(){this.hash={},this.imageId=1}}let Fe=new Re;function oe(){return Fe}function us(m){Fe=m}var It;(function(m){m[m.Inside=0]="Inside",m[m.Middle=1]="Middle",m[m.Outside=2]="Outside"})(It||(It={}));var je;(function(m){m[m.None=0]="None",m[m.Top=1]="Top",m[m.Bottom=2]="Bottom",m[m.Right=4]="Right",m[m.Left=8]="Left",m[m.All=15]="All"})(je||(je={}));class o{static parseWidth(t,e,s=1,i){if(t.indexOf("calc")===0)return e/s;const n=parseFloat(t),r=t.replace(/[^A-Za-z%]/g,"")||i;let h;switch(r){case"pt":h=1;break;case"mm":h=72/25.4;break;case"cm":h=72/2.54;break;case"in":h=72;break;case"px":h=72/96;break;case"pc":h=12;break;case"em":h=12;break;case"ex":h=6;break;default:case"%":h=e/100;break}return Math.min(n*h,e)}static pxToPt(t){return typeof t=="string"?(isNaN(Number(t))||(t+="px"),o.parseWidth(t,Number.MAX_VALUE)):t*72/96}static parseColor(t){let e,s;if((t??"").match(/^rgba/)){const i=t.match(/[\d.]+/g);i.length==4&&(t=`rgb(${i[0]}, ${i[1]}, ${i[2]})`,e=parseFloat(i[3]))}else(s=(t??"").match(/(#[A-Fa-f0-9]{6})([A-Fa-f0-9]{2})/))&&(t=s[1],e=Math.round(parseInt(s[2],16)/255*100)/100);return{color:t,opacity:e}}static mergeRects(...t){return Vt(...t)}static createPoint(t,e=!0,s=!1){return{xLeft:e?t.xLeft:t.xRight,yTop:s?t.yTop:t.yBot}}static createRect(t,e,s){return{xLeft:t.xLeft,xRight:t.xLeft+e,yTop:t.yTop,yBot:t.yTop+s}}static createHeaderRect(t){return{xLeft:0,xRight:t.paperWidth,yTop:0,yBot:t.margins.top}}static createFooterRect(t){return{xLeft:0,xRight:t.paperWidth,yTop:t.paperHeight-t.margins.bot,yBot:t.paperHeight}}static chooseHtmlFont(t,e){return t.useCustomFontInHtml?e??t.fontName:"helvetica"}static generateCssTextRule(t){return`"font-size: ${t.fontSize}pt; font-weight: ${t.fontStyle}; font-family: ${t.fontName}; color: ${o.parseColor(t.fontColor).color}; lineHeight: ${t.lineHeight}; margin: 0"`}static createHtmlContainerBlock(t,e,s){const i=o.getPatchedTextStyle(e,s);return this.chooseHtmlFont(e,i.fontName),`<div class="__surveypdf_html" style=${this.generateCssTextRule(i)}><style>.__surveypdf_html p { margin: 0; line-height: ${i.lineHeight}pt } body { margin: 0; }</style>${t}</div>`}static splitHtmlRect(t,e){const s=[],i=e.height,n=t.doc.getFontSize();e.yBot=e.yTop+n;const r=Math.floor(i/n)-1;s.push(e);const h=this.createPoint(e);for(let l=0;l<r;l++)s.push(new Tt(t,this.createRect(h,e.width,n))),h.yTop+=n;const a=i-(r+1)*n;return a>0&&s.push(new Tt(t,this.createRect(h,e.width,a))),new W(...s)}static createPlainTextFlat(t,e,s,i){e.setTextStyle(i,!0);const n=e.helperDoc.splitTextToSize(s,e.paperWidth-e.margins.right-t.xLeft);e.restoreTextStyle(!0);const r=this.clone(t),h=new W;if(n.forEach(a=>{const l=e.measureText(a,i);h.addBrick(new zt(e,this.createRect(r,l.width,l.height),{text:a},i)),r.yTop+=l.height}),i.textAlign=="right"){const a=t.xLeft+o.getPageAvailableWidth(e);h.translateX((l,u)=>({xLeft:l+(a-u),xRight:a}))}if(i.textAlign=="center"){const a=t.xLeft+o.getPageAvailableWidth(e)/2;h.translateX((l,u)=>{const p=a-(l+u)/2;return{xLeft:l+p,xRight:u+p}})}return h}static async createTextFlat(t,e,s,i){var n;const r={...o.getPatchedTextStyle(e,i),textAlign:(n=i?.textAlign)!==null&&n!==void 0?n:"left"};let h;return typeof s=="string"||!this.hasHtml(s)?h=this.createPlainTextFlat(t,e,typeof s=="string"?s:this.getLocString(s),r):h=this.splitHtmlRect(e,await this.createHTMLFlat(t,e,this.createHtmlContainerBlock(this.getLocString(s),e,r),r)),h}static mergeObjects(t,...e){return e.forEach(s=>{s&&Object.keys(s).forEach(i=>{var n;typeof s[i]=="object"&&s[i]!==null&&!Array.isArray(s[i])?t[i]=o.mergeObjects((n=t[i])!==null&&n!==void 0?n:{},s[i]):t[i]=s[i]})}),t}static getPatchedTextStyle(t,e){const s=o.mergeObjects(o.getDefaultTextStyle(t),e??{});return e&&e.lineHeight==null&&(s.lineHeight=s.fontSize),s}static getDefaultTextStyle(t){return{fontSize:t.fontSize,fontName:t.fontName,fontStyle:t.fontStyle,lineHeight:t.fontSize,fontColor:"#404040"}}static hasHtml(t){const e=/<\/?[a-z][\s\S]*>/i;return t.hasHtml&&(e.test(t.renderedText)||e.test(t.renderedHtml))}static getHtmlMargins(t,e){const s=t.paperWidth-e.xLeft-t.margins.right;return{top:t.margins.top,bottom:t.margins.bot,width:s>t.unitWidth?s:t.unitWidth}}static createHTMLRect(t,e,s,i,n){const r=this.getPatchedTextStyle(e,n),h=e.paperHeight-e.margins.bot-e.margins.top,a=(e.helperDoc.getNumberOfPages()-1)*(r.fontSize*Math.floor(h/r.fontSize))+i-s.top+o.HTML_TAIL_TEXT_SCALE*r.fontSize,l=e.helperDoc.getNumberOfPages();e.helperDoc.addPage();for(let u=0;u<l;u++)e.helperDoc.deletePage(1);return o.createRect(t,s.width,a)}static async createHTMLFlat(t,e,s,i){const n=this.getHtmlMargins(e,t),r=this.getPatchedTextStyle(e,i);return await new Promise(h=>{e.helperDoc.fromHTML(s,t.xLeft,n.top,{pagesplit:!0,width:n.width},function(a){const l=o.createHTMLRect(t,e,n,a.y,r);h(new ve(e,l,{html:s},r))},n)})}static generateFontFace(t,e,s){return`@font-face { font-family: ${t}; src: url(data:application/font-woff;charset=utf-8;base64,${e}) format('woff'); font-weight: ${s}; }`}static generateFontFaceWithItalicStyle(t,e,s){return`@font-face { font-family: ${t}; src: url(data:application/font-woff;charset=utf-8;base64,${e}) format('woff'); font-weight: ${s}; font-style: italic}`}static htmlToXml(t){const 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,"#")}static createSvgContent(t,e,s){const i=document.createElement("style");i.innerHTML=".__surveypdf_html p { margin: unset; line-height: 22px; } body { margin: unset; }",document.body.appendChild(i);const n=document.createElement("div");n.className="__surveypdf_html",n.style.display="block",n.style.position="fixed",n.style.top="-10000px",n.style.left="-10000px",n.style.width=e/72*96+"px",n.style.boxSizing="initial",n.style.color="initial",n.style.fontFamily="initial",n.style.font="initial",n.style.lineHeight="initial",n.insertAdjacentHTML("beforeend",t),document.body.appendChild(n);const r=n.offsetWidth,h=n.offsetHeight;n.remove(),i.remove();let a="";return s.useCustomFontInHtml?a=`<defs><style>${this.generateFontFace(s.fontName,s.base64Normal,"normal")} ${this.generateFontFace(s.fontName,s.base64Bold,"bold")}</style></defs>`:Object.keys(xt.customFonts).forEach(u=>{const p=xt.customFonts[u];Object.keys(p).forEach(v=>{v==="normal"||v==="bold"?a+=`${this.generateFontFace(u,p[v],v)}`:a+=`${this.generateFontFaceWithItalicStyle(u,p[v],v==="italic"?"normal":"bold")}`}),a="<defs><style>"+a+"</style></defs>"}),{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${r}px" height="${h}px">`+a+`<style>.__surveypdf_html p { margin: unset; line-height: 22px; }</style><foreignObject width="${r}px" height="${h}px">`+this.htmlToXml(t)+"</foreignObject></svg>",divWidth:r,divHeight:h}}static setCanvas(t,e,s,i,n){e.width=s*t.htmlToImageQuality,e.height=i*t.htmlToImageQuality;const r=e.getContext("2d");r.scale(t.htmlToImageQuality,t.htmlToImageQuality),r.fillStyle="#FFFFFF",r.fillRect(0,0,s,i),r.drawImage(n,0,0)}static async htmlToImage(t,e,s){const{svg:i,divWidth:n,divHeight:r}=o.createSvgContent(t,e,s),h="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(i))),a=new Image;return a.crossOrigin="anonymous",a.src=h,new Promise(l=>{a.onload=function(){const u=document.createElement("canvas");o.setCanvas(s,u,n,r,a);const p=u.toDataURL("image/jpeg",s.htmlToImageQuality);u.remove(),l({url:p,aspect:n/r})},a.onerror=function(){l({url:"data:,",aspect:e/this.EPSILON})}})}static getReadonlyRenderAs(t,e){return t.readonlyRenderAs==="auto"?e.readonlyRenderAs:t.readonlyRenderAs}static async createCommentFlat(t,e,s,i){var n,r;const h=o.getPatchedTextStyle(e,i);s.rows=(n=s.rows)!==null&&n!==void 0?n:1,s.value=(r=s.value)!==null&&r!==void 0?r:"";const a=this.createTextFieldRect(t,e,s.rows,h.lineHeight);let l;s.shouldRenderReadOnly&&(l=await this.createReadOnlyTextFieldTextFlat(t,e,s.value,h));const u=new we(e,a,s,h);return l&&(u.textBrick=l),u}static get hasDocument(){return typeof document<"u"}static async createImageFlat(t,e,s,i,n){const r=oe();let h=await r.getImageInfo(i.link);(n??s.applyImageFit)&&(h=await r.applyImageFit(h,i.objectFit||"fill",i.width,i.height));const a=o.createRect(t,i.width,i.height);return new be(s,a,{width:h.width,height:h.height,imageId:h.id,link:h.data})}static createRowlineFlat(t,e,s,i){let n=typeof s>"u"?e.paperWidth-e.margins.right:t.xLeft+s;return n=n>t.xLeft?n:t.xLeft+this.EPSILON,new ne(e,{xLeft:t.xLeft,xRight:n,yTop:t.yTop+this.EPSILON,yBot:t.yTop+this.EPSILON},typeof i>"u"?null:i)}static async createLinkFlat(t,e,s,i){const n=o.getPatchedTextStyle(e,i),r=await this.createTextFlat(t,e,s.text,n),h=new W;return r.unfold().forEach(a=>{h.addBrick(new Wt(e,a,{link:s.link,text:a.options.text,readOnlyShowLink:s.readOnlyShowLink,shouldRenderReadOnly:s.shouldRenderReadOnly},n));const l=this.createPoint(h);h.addBrick(this.createRowlineFlat(l,e,h.width,n.fontColor))}),h}static createAcroformRect(t){return[t.xLeft,t.yTop,t.xRight-t.xLeft,t.yBot-t.yTop]}static createTextFieldRect(t,e,s=1,i=e.unitHeight){let n=e.paperWidth-t.xLeft-e.margins.right;n=Math.max(n,e.unitWidth);const r=i*s;return this.createRect(t,n,r)}static async createReadOnlyTextFieldTextFlat(t,e,s,i){e.pushMargins(t.xLeft,e.margins.right);const n=await this.createTextFlat(t,e,s.toString(),i);return e.popMargins(),n}static createRoundedShape(t,e,s=!0){var i;const n=typeof s=="object"?s:{top:s,bot:s,left:s,right:s},r=St((i=e.borderRadius)!==null&&i!==void 0?i:0);Object.keys(r).forEach(l=>{r[l]=Math.max(0,Math.min(r[l],(t.xRight-t.xLeft)/2,(t.yBot-t.yTop)/2))});function h(l,u,p,v,B){const M=1.3333333333333333*Math.tan(v/4)*p;return[[p,0],[p,M],[p*Math.cos(v)+M*Math.sin(v),p*Math.sin(v)-M*Math.cos(v)],[p*Math.cos(v),p*Math.sin(v)]].reduce((st,ut)=>(st.push(Math.cos(B)*ut[0]-Math.sin(B)*ut[1]+l),st.push(Math.sin(B)*ut[0]+Math.cos(B)*ut[1]+u),st),[])}const a=new Map;if(a.set("top",[[t.xLeft+r.top,t.yTop,t.xRight-r.right,t.yTop]]),a.set("right",[[t.xRight,t.yTop+r.right,t.xRight,t.yBot-r.bot]]),a.set("bot",[[t.xRight-r.bot,t.yBot,t.xLeft+r.left,t.yBot]]),a.set("left",[[t.xLeft,t.yBot-r.left,t.xLeft,t.yTop+r.top]]),r.top){const l=n.top?Math.PI/2:Math.PI/4,u=r.top;a.get("left").push(h(t.xLeft+u,t.yTop+u,u,l,Math.PI)),n.top||a.get("top").unshift(h(t.xLeft+u,t.yTop+u,u,l,Math.PI+l))}if(r.right){const l=n.right?Math.PI/2:Math.PI/4,u=r.right;a.get("top").push(h(t.xRight-u,t.yTop+u,u,l,3/2*Math.PI)),n.right||a.get("right").unshift(h(t.xRight-u,t.yTop+u,u,l,3/2*Math.PI+l))}if(r.bot){const l=n.bot?Math.PI/2:Math.PI/4,u=r.bot;a.get("right").push(h(t.xRight-u,t.yBot-u,u,l,0)),n.bot||a.get("bot").unshift(h(t.xRight-u,t.yBot-u,u,l,l))}if(r.left){const l=n.left?Math.PI/2:Math.PI/4,u=r.left;a.get("bot").push(h(t.xLeft+u,t.yBot-u,u,l,Math.PI/2)),n.left||a.get("left").unshift(h(t.xLeft+u,t.yBot-u,u,l,Math.PI/2+l))}return a}static getDocLinesFromShape(t){const e=t.get(t.keys().next().value)[0].slice(0,2);let s=e;const i=[];return t.forEach(n=>n.forEach(h=>{h=h.slice(2),i.push(h.map((a,l)=>a-s[l%2])),s=h.slice(h.length-2)})),{lines:i,point:e}}static renderFlatBorders(t,e,s){var i,n,r;const h=o.mergeObjects({},{borderMode:It.Inside},s),a=St((i=s.borderWidth)!==null&&i!==void 0?i:0),l=St(s.borderColor);if([l,a].some(J=>Object.keys(J).every(C=>!J[C])))return;const u=h.borderMode==It.Middle?0:h.borderMode==It.Inside?.5:-.5,p={xLeft:e.xLeft+u*a.left,yTop:e.yTop+u*a.top,xRight:e.xRight-u*a.right,yBot:e.yBot-u*a.bot},v={top:a.left==a.top&&l.left==l.top,right:a.top==a.right&&l.top==l.right,bot:a.right==a.bot&&l.right==l.bot,left:a.bot==a.left&&l.bot==l.left},B=o.createRoundedShape(p,{...h},v),M=[];let Z=0,st=0,ut=0,D=0,Y,K;const gt=Array.from(B.keys());if(gt.concat(gt).forEach((J,C)=>{const b=a[J],d=l[J];C!==0&&b==Y&&d==K?D++:(Y=b,K=d,D>st&&(Z=ut,st=D),ut=C,D=1)}),st==0&&(st=D,Z=ut),st>=2){const J=new Map;for(let b=Z;b<Z+st;b++){const d=gt[b%gt.length];J.set(d,B.get(d))}M.push(J);const C=gt.filter(b=>!J.has(b));if(C.length!==0)if(C.length==2&&C[0]=="top"&&C[1]=="left"&&C.reverse(),C.every(b=>a[C[0]]==a[b]&&l[C[0]]==l[b])){const b=new Map;C.forEach(d=>{b.set(d,B.get(d))}),M.push(b)}else C.forEach(b=>{const d=new Map;d.set(b,B.get(b)),M.push(d)})}else gt.forEach(J=>{const C=new Map;C.set(J,B.get(J)),M.push(C)});if(h.dashStyle){const J=h.dashStyle,C=(Math.abs(p.yTop-p.yBot)+Math.abs(p.xLeft-p.xRight))*2,b=J.dashArray[0]+((n=J.dashArray[1])!==null&&n!==void 0?n:J.dashArray[0]),d=J.dashArray[0]+C%b/Math.floor(C/b);t.doc.setLineDashPattern([d,(r=J.dashArray[1])!==null&&r!==void 0?r:J.dashArray[0]],J.dashPhase)}M.forEach(J=>{const C=J.keys().next().value;if(!l[C]||!a[C])return;t.setDrawColor(l[C]),t.doc.setLineWidth(a[C]);const{lines:b,point:d}=this.getDocLinesFromShape(J);t.doc.lines(b,...d,[1,1],"S",J.size==4),t.restoreDrawColor()}),h.dashStyle&&t.doc.setLineDashPattern([])}static getLocString(t){return this.hasHtml(t)?t.renderedHtml:t.renderedText||t.renderedHtml}static getContentQuestion(t){return t.contentQuestion?t.contentQuestion:t}static isBooleanDisplayMode(t){return t==="radio"||t==="checkbox"||t==="switch"}static isEmptyRenderAs(t){return!t||t==="default"}static getBooleanRenderAsValue(t){if(!this.isEmptyRenderAs(t.renderAs))return t.renderAs;const e=t,s=e.displayMode;return s==="custom"&&e.customRenderAs?e.customRenderAs:this.isBooleanDisplayMode(s)?s:"default"}static getContentQuestionTypeRenderAs(t,e){let s=t.renderAs;if(t.getType()==="boolean"&&(e.options.useLegacyBooleanRendering?s="checkbox":s=this.getBooleanRenderAsValue(t)),s!=="default"){const i=`${t.getType()}-${s}`;if(N.getInstance().isTypeRegistered(i))return i}return t.getType()}static getContentQuestionType(t,e){return t.customWidget?t.customWidget.pdfQuestionType:t.contentQuestion?"custom_model":this.getContentQuestionTypeRenderAs(t,e)}static getPageAvailableWidth(t){return t.paperWidth-t.margins.left-t.margins.right}static getColumnWidth(t,e,s){return(this.getPageAvailableWidth(t)-(e-1)*s)/e}static setColumnMargins(t,e,s,i){const n=this.getColumnWidth(t,e,i);t.margins.left=t.margins.left+s*(n+i),t.margins.right=t.margins.right+(e-s-1)*(n+i)}static moveRect(t,e=t.xLeft,s=t.yTop){return{xLeft:e,yTop:s,xRight:e+t.xRight-t.xLeft,yBot:s+t.yBot-t.yTop}}static createRectInsideBorders(t,e){const s=St(e);return{xLeft:t.xLeft+s.left,yTop:t.yTop+s.top,xRight:t.xRight-s.right,yBot:t.yBot-s.bot}}static getFlatQuestion(t,e,s){const i=this.getContentQuestionType(s,t),n=t.getElementStyle(s);return N.getInstance().create(t,s,e,n,i)}static async generateQuestionFlats(t,e,s,i){return[...await o.getFlatQuestion(t,e,s).generateFlats(i)]}static async generatePanelFlats(t,e,s,i){return[...await N.getInstance().createPanel(t,s,e,t.getElementStyle(s)).generateFlats(i)]}static async generatePageFlats(t,e,s,i){return[...await N.getInstance().createPage(t,s,e,t.getElementStyle(s)).generateFlats(i)]}static isFontExist(t,e){return t.doc.internal.getFont(e).fontName===e}static isCustomFont(t,e){return t.doc.internal.getFont(e).encoding==="Identity-H"}static fixFont(t){this.isCustomFont(t,t.fontName)&&(t.doc.text("load font",0,0),t.doc.deletePage(1),t.addPage())}static clone(t){const e={};for(const s in t)t.hasOwnProperty(s)&&(e[s]=t[s]);return e}static shouldRenderReadOnly(t,e,s){return(!!t&&t.isReadOnly||s)&&o.getReadonlyRenderAs(t,e)!=="acroform"||e?.compress}static isSizeEmpty(t){return!t||t==="auto"}static isHeightEmpty(t){return this.isSizeEmpty(t)||t=="100%"}static async getCorrectedImageSize(t,e){let{imageWidth:s,imageLink:i,imageHeight:n,defaultImageWidth:r,defaultImageHeight:h}=e;s=typeof s=="number"?s.toString():s,n=typeof n=="number"?n.toString():n;let a=s&&o.parseWidth(s,o.getPageAvailableWidth(t),1,"px"),l=n&&o.parseWidth(n,o.getPageAvailableWidth(t),1,"px");r=typeof r=="number"?r.toString():r,h=typeof h=="number"?h.toString():h;let u=r&&o.parseWidth(r,o.getPageAvailableWidth(t),1,"px"),p=h&&o.parseWidth(h,o.getPageAvailableWidth(t),1,"px");if(o.isSizeEmpty(s)||o.isHeightEmpty(n)){const v=await oe().getImageInfo(i);o.isSizeEmpty(s)?o.isHeightEmpty(n)?v&&v.height&&v.width&&(l=Math.min(v.height,o.getPageAvailableWidth(t)),a=Math.min(v.width,o.getPageAvailableWidth(t))):v&&v.height&&(a=v.width*l/v.height):v&&v.width&&(l=v.height*a/v.width)}return{width:a||u||0,height:l||p||0}}static alignVerticallyBricks(t,...e){const s=o.mergeRects(...e);e.forEach(i=>{switch(t){case"center":{i.translateY((n,r)=>{const h=(s.yTop+s.yBot-(n+r))/2;return{yTop:n+h,yBot:r+h}});break}case"bottom":{i.translateY((n,r)=>({yTop:n+s.yBot-r,yBot:s.yBot}));break}default:i.translateY((n,r)=>({yTop:s.yTop,yBot:r-n+s.yTop}))}})}static clear(){oe().clear()}}o.EPSILON=2220446049250313e-30,o.HTML_TAIL_TEXT_SCALE=.24;function ds(m){return m.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")}function fs(m){return m=m||"",m.toString(),m="("+ds(m)+")",m}function ps(m){class t extends m.AcroFormTextField{getKeyValueListForStream(){const s=super.getKeyValueListForStream();return s.push({key:"DA",value:fs(m.AcroFormAppearance.createDefaultAppearanceStream(this))}),s}}return t}function gs(m){class t extends m.AcroFormRadioButton{constructor(){super()}setAppearance(s){super.setAppearance(s);const i=s.YesNormal;for(const n in this.Kids)if(this.Kids.hasOwnProperty(n)){const r=this.Kids[n];r.appearanceStreamContent.N[r.optionName]=function(h){const a=i(h),l=a.stream.split(`
`),u=m.__private__.encodeColorString(h.color);return l[0]=l[0]+`
`+u+`
`+u.toUpperCase(),a.stream=l.join(`
`),a}}}}return t}function ys(m){class t extends m.AcroFormCheckBox{constructor(){super();const s=this.appearanceStreamContent.N.On;this.appearanceStreamContent.N.On=function(i){const n=s(i);let r=n.stream.split(`
`);return r=r.slice(3),n.stream=r.join(`
`),n}}}return t}function ms(m){class t extends m.AcroFormComboBox{constructor(){super()}set backgroundColor(s){if(s){let i=m.__private__.encodeColorString(s).replace(/\s+RG/i,"");i.includes("g")&&(i=i.replace("g","").repeat(3)),this.MK=`<< /BG [ ${i} ] >>`}}}return t}/**
* @license
* Copyright (c) 2016 Alexander Weidt,
* https://github.com/BiggA94
*
* Licensed under the MIT License. http://opensource.org/licenses/mit-license
*/(function(m,t){var e=m.API,s,i=1;function n(c){for(var g="",f=0;f<c.length;f++){for(var y=c.charCodeAt(f).toString(16).toUpperCase();y.length<4;)y="0"+y;g+=y}return"<FEFF"+g+">"}var r=function(c){return c.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},h=function(c){return c.replace(/\\\\/g,"\\").replace(/\\\(/g,"(").replace(/\\\)/g,")")};function a(c){for(var g="[ ",f=0;f<c.length;f++)g+=n(c[f]);return g+=" ]",g}var l=function(c){return c.toFixed(2)},u=function(c){return c.toFixed(5)};e.__acroform__={};var p=function(c,g){c.prototype=Object.create(g.prototype),c.prototype.constructor=c},v=function(c){return c*i},B=function(c){return c/i},M=function(c){var g=new O,f=P.internal.getHeight(c)||0,y=P.internal.getWidth(c)||0;return g.BBox=[0,0,Number(l(y)),Number(l(f))],g},Z=e.__acroform__.setBit=function(c,g){if(c=c||0,g=g||0,isNaN(c)||isNaN(g))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.setBit");var f=1<<g;return c|=f,c},st=e.__acroform__.clearBit=function(c,g){if(c=c||0,g=g||0,isNaN(c)||isNaN(g))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.clearBit");var f=1<<g;return c&=~f,c},ut=e.__acroform__.getBit=function(c,g){if(isNaN(c)||isNaN(g))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.getBit");return(c&1<<g)===0?0:1},D=e.__acroform__.getBitForPdf=function(c,g){if(isNaN(c)||isNaN(g))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.getBitForPdf");return ut(c,g-1)},Y=e.__acroform__.setBitForPdf=function(c,g){if(isNaN(c)||isNaN(g))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.setBitForPdf");return Z(c,g-1)},K=e.__acroform__.clearBitForPdf=function(c,g){if(isNaN(c)||isNaN(g))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf");return st(c,g-1)},gt=e.__acroform__.calculateCoordinates=function(c){var g=this.internal.getHorizontalCoordinate,f=this.internal.getVerticalCoordinate,y=c[0],w=c[1],I=c[2],Q=c[3],U={};return U.lowerLeft_X=g(y)||0,U.lowerLeft_Y=f(w+Q)||0,U.upperRight_X=g(y+I)||0,U.upperRight_Y=f(w)||0,[Number(l(U.lowerLeft_X)),Number(l(U.lowerLeft_Y)),Number(l(U.upperRight_X)),Number(l(U.upperRight_Y))]},J=function(c){if(c.appearanceStreamContent)return c.appearanceStreamContent;if(!(!c.V&&!c.DV)){var g=[],f=c.V||c.DV,y=C(c,f),w=s.internal.getFont(c.fontName,c.fontStyle).id;g.push("/Tx BMC"),g.push("q"),g.push("BT"),g.push(s.__private__.encodeColorString(c.color)),g.push("/"+w+" "+l(y.fontSize)+" Tf"),g.push("1 0 0 1 0 0 Tm"),g.push(y.text),g.push("ET"),g.push("Q"),g.push("EMC");var I=new M(c);return I.stream=g.join(`
`),I}},C=function(c,g){c.isUnicode&&(g=c.trueValue);var f=c.fontSize===0?c.maxFontSize:c.fontSize,y={text:"",fontSize:""};g=g.substr(0,1)=="("?g.substr(1):g,g=g.substr(g.length-1)==")"?g.substr(0,g.length-1):g;var w=g.split(" ");w=w.map(function(Ct){return Ct.split(`
`)}),c.multiline||(w=w.map(function(Ct){return[Ct.join(" ")]}));var I=f,Q=2,U=2,nt=P.internal.getHeight(c)||0;nt=nt<0?-nt:nt;var rt=P.internal.getWidth(c)||0;rt=rt<0?-rt:rt;var ot=function(Ct,Ls,Is){if(Ct+1<w.length){var Ms=Ls+" "+w[Ct+1][0],Ss=b(Ms,c,Is).width,As=rt-2*U;return Ss<=As}else return!1};I++;t:for(;I>0;){g="",I--;var ct=b("3",c,I).height,at=c.multiline?nt-I:(nt-ct)/2;at+=Q;var Mt,Gt=at,wt=0,R=0,te,Ot=0;if(I<=0){I=12,g=`(...) Tj
`,g+="% Width of Text: "+b(g,c,I).width+", FieldWidth:"+rt+`
`;break}var Rt="",ee=0;e:for(var Ft=0;Ft<w.length;Ft++)if(w.hasOwnProperty(Ft)){var Xe=!1;if(w[Ft].length!==1&&Ot!==w[Ft].length-1){if((ct+Q)*(ee+2)+Q>nt)continue t;Rt+=w[Ft][Ot],Xe=!0,R=Ft,Ft--}else{Rt+=w[Ft][Ot]+" ",Rt=Rt.substr(Rt.length-1)==" "?Rt.substr(0,Rt.length-1):Rt;var de=parseInt(Ft),Je=ot(de,Rt,I),fe=Ft>=w.length-1;if(Je&&!fe){Rt+=" ",Ot=0;continue}else if(!Je&&!fe)if(c.multiline){if((ct+Q)*(ee+2)+Q>nt)continue t;R=de}else continue t;else if(fe)R=de;else if(c.multiline&&(ct+Q)*(ee+2)+Q>nt)continue t}for(var mt="",Kt=wt;Kt<=R;Kt++){var Xt=w[Kt];if(c.multiline){if(Kt===R){mt+=Xt[Ot]+" ",Ot=(Ot+1)%Xt.length;continue}if(Kt===wt){mt+=Xt[Xt.length-1]+" ";continue}}mt+=Xt[0]+" "}switch(mt=mt.substr(mt.length-1)==" "?mt.substr(0,mt.length-1):mt,te=b(mt,c,I).width,c.textAlign){case"right":Mt=rt-te-U;break;case"center":Mt=(rt-te)/2;break;default:Mt=U;break}if(g+=l(Mt)+" "+l(Gt)+` Td
`,c.isUnicode){var Ze={};const Ct=s.internal.getFont(c.fontName,c.fontStyle);Ze[Ct.id]=Ct;var Ve={text:mt,x:null,y:null,options:{lang:null},mutex:{pdfEscape:r,activeFontKey:Ct.id,fonts:Ze,activeFontSize:c.fontSize}};s.internal.events.publish("postProcessText",Ve),g+="<"+Ve.text+`> Tj
`}else g+="("+r(mt)+`) Tj
`;g+=-l(Mt)+` 0 Td
`,Gt=-(I+Q),te=0,wt=Xe?R:R+1,ee++,Rt="";continue e}break}return y.text=g,y.fontSize=I,y},b=function(c,g,f){var y=s.internal.getFont(g.fontName,g.fontStyle),w=s.getStringUnitWidth(c,{font:y,fontSize:parseFloat(f),charSpace:0})*parseFloat(f),I=s.getStringUnitWidth("3",{font:y,fontSize:parseFloat(f),charSpace:0})*parseFloat(f)*1.5;return{height:I,width:w}},d={fields:[],xForms:[],acroFormDictionaryRoot:null,printedOut:!1,internal:null,isInitialized:!1},F=function(){s.internal.acroformPlugin.acroFormDictionaryRoot.objId=void 0;var c=s.internal.acroformPlugin.acroFormDictionaryRoot.Fields;for(var g in c)if(c.hasOwnProperty(g)){var f=c[g];f.objId=void 0,f.hasAnnotation&&j.call(s,f)}},x=function(c){s.internal.acroformPlugin.printedOut&&(s.internal.acroformPlugin.printedOut=!1,s.internal.acroformPlugin.acroFormDictionaryRoot=null),s.internal.acroformPlugin.acroFormDictionaryRoot||q.call(s),s.internal.acroformPlugin.acroFormDictionaryRoot.Fields.push(c)},j=function(c){var g={type:"reference",object:c},f=function(y){return y.type===g.type&&y.object===g.object};s.internal.getPageInfo(c.page).pageContext.annotations.find(f)===void 0&&s.internal.getPageInfo(c.page).pageContext.annotations.push(g)},k=function(){if(typeof s.internal.acroformPlugin.acroFormDictionaryRoot<"u")s.internal.write("/AcroForm "+s.internal.acroformPlugin.acroFormDictionaryRoot.objId+" 0 R");else throw new Error("putCatalogCallback: Root missing.")},L=function(){s.internal.events.unsubscribe(s.internal.acroformPlugin.acroFormDictionaryRoot._eventID),delete s.internal.acroformPlugin.acroFormDictionaryRoot._eventID,s.internal.acroformPlugin.printedOut=!0},A=function(c){var g=!c;c||(s.internal.newObjectDeferredBegin(s.internal.acroformPlugin.acroFormDictionaryRoot.objId,!0),s.internal.acroformPlugin.acroFormDictionaryRoot.putStream()),c=c||s.internal.acroformPlugin.acroFormDictionaryRoot.Kids;for(var f in c)if(c.hasOwnProperty(f)){var y=c[f],w=[],I=y.Rect;if(y.Rect&&(y.Rect=gt.call(this,y.Rect)),s.internal.newObjectDeferredBegin(y.objId,!0),y.DA=P.createDefaultAppearanceStream(y),typeof y=="object"&&typeof y.getKeyValueListForStream=="function"&&(w=y.getKeyValueListForStream()),y.Rect=I,y.hasAppearanceStream&&!y.appearanceStreamContent){var Q=J.call(this,y);w.push({key:"AP",value:"<</N "+Q+">>"}),s.internal.acroformPlugin.xForms.push(Q)}if(y.appearanceStreamContent){var U="";for(var nt in y.appearanceStreamContent)if(y.appearanceStreamContent.hasOwnProperty(nt)){var rt=y.appearanceStreamContent[nt];if(U+="/"+nt+" ",U+="<<",Object.keys(rt).length>=1||Array.isArray(rt)){for(var f in rt)if(rt.hasOwnProperty(f)){var ot=rt[f];typeof ot=="function"&&(ot=ot.call(this,y)),U+="/"+f+" "+ot+" ",s.internal.acroformPlugin.xForms.indexOf(ot)>=0||s.internal.acroformPlugin.xForms.push(ot)}}else ot=rt,typeof ot=="function"&&(ot=ot.call(this,y)),U+="/"+f+" "+ot,s.internal.acroformPlugin.xForms.indexOf(ot)>=0||s.internal.acroformPlugin.xForms.push(ot);U+=">>"}w.push({key:"AP",value:`<<
`+U+">>"})}s.internal.putStream({additionalKeyValues:w}),s.internal.out("endobj")}g&&H.call(this,s.internal.acroformPlugin.xForms)},H=function(c){for(var g in c)if(c.hasOwnProperty(g)){var f=g,y=c[g];s.internal.newObjectDeferredBegin(y&&y.objId,!0),typeof y=="object"&&typeof y.putStream=="function"&&y.putStream(),delete c[f]}},q=function(){if(this.internal!==void 0&&(this.internal.acroformPlugin===void 0||this.internal.acroformPlugin.isInitialized===!1)){if(s=this,et.FieldNum=0,this.internal.acroformPlugin=JSON.parse(JSON.stringify(d)),this.internal.acroformPlugin.acroFormDictionaryRoot)throw new Error("Exception while creating AcroformDictionary");i=s.internal.scaleFactor,s.internal.acroformPlugin.acroFormDictionaryRoot=new X,s.internal.acroformPlugin.acroFormDictionaryRoot._eventID=s.internal.events.subscribe("postPutResources",L),s.internal.events.subscribe("buildDocument",F),s.internal.events.subscribe("putCatalog",k),s.internal.events.subscribe("postPutPages",A),s.internal.acroformPlugin.isInitialized=!0}},_=e.__acroform__.arrayToPdfArray=function(c){if(Array.isArray(c)){for(var g="[",f=0;f<c.length;f++)switch(f!==0&&(g+=" "),typeof c[f]){case"boolean":case"number":case"object":g+=c[f].toString();break;case"string":c[f].substr(0,1)!=="/"?g+="("+r(c[f].toString())+")":g+=c[f].toString();break}return g+="]",g}throw new Error("Invalid argument passed to jsPDF.__acroform__.arrayToPdfArray")};function G(c,g,f){f||(f=1);for(var y=[],w;w=g.exec(c);)y.push(w[f]);return y}var $=function(c){var g=[];return typeof c=="string"&&(g=G(c,/\((.*?)\)/g)),g},S=function(c){return c=c||"",c.toString(),c="("+r(c)+")",c},E=function(){var c;Object.defineProperty(this,"objId",{configurable:!0,get:function(){return c||(c=s.internal.newObjectDeferred()),c},set:function(g){c=g}})};E.prototype.toString=function(){return this.objId+" 0 R"},E.prototype.putStream=function(){var c=this.getKeyValueListForStream();s.internal.putStream({data:this.stream,additionalKeyValues:c}),s.internal.out("endobj")},E.prototype.getKeyValueListForStream=function(){var c=function(g){var f=[],y=Object.getOwnPropertyNames(g).filter(function(nt){return nt!="content"&&nt!="appearanceStreamContent"&&nt.substring(0,1)!="_"});for(var w in y){var I=Object.getOwnPropertyDescriptor(g,y[w]);if(I&&I.configurable===!1){var Q=y[w],U=g[Q];U&&(Array.isArray(U)?f.push({key:Q,value:_(U)}):U instanceof E?f.push({key:Q,value:U.objId+" 0 R"}):typeof U!="function"&&f.push({key:Q,value:U}))}}return f};return c(this)};var O=function(){E.call(this),Object.defineProperty(this,"Type",{value:"/XObject",configurable:!1,writeable:!0}),Object.defineProperty(this,"Subtype",{value:"/Form",configurable:!1,writeable:!0}),Object.defineProperty(this,"FormType",{value:1,configurable:!1,writeable:!0});var c=[];Object.defineProperty(this,"BBox",{configurable:!1,writeable:!0,get:function(){return c},set:function(f){c=f}}),Object.defineProperty(this,"Resources",{value:"2 0 R",configurable:!1,writeable:!0});var g;Object.defineProperty(this,"stream",{enumerable:!1,configurable:!0,set:function(f){g=f.trim()},get:function(){return g||null}})};p(O,E);var X=function(){E.call(this);var c=[];Object.defineProperty(this,"Kids",{enumerable:!1,configurable:!0,get:function(){if(c.length>0)return c}}),Object.defineProperty(this,"Fields",{enumerable:!1,configurable:!1,get:function(){return c}});var g;Object.defineProperty(this,"DA",{enumerable:!1,configurable:!1,get:function(){if(g)return"("+g+")"},set:function(f){g=f}})};p(X,E);var et=function(){E.call(this);var c=4;this.isUnicode=!1,this.trueValue="",Object.defineProperty(this,"F",{enumerable:!1,configurable:!1,get:function(){return c},set:function(R){if(!isNaN(R))c=R;else throw new Error('Invalid value "'+R+'" for attribute F supplied.')}}),Object.defineProperty(this,"showWhenPrinted",{enumerable:!0,configurable:!0,get:function(){return!!D(c,3)},set:function(R){R?this.F=Y(c,3):this.F=K(c,3)}});var g=0;Object.defineProperty(this,"Ff",{enumerable:!1,configurable:!1,get:function(){return g},set:function(R){if(!isNaN(R))g=R;else throw new Error('Invalid value "'+R+'" for attribute Ff supplied.')}});var f=[];Object.defineProperty(this,"Rect",{enumerable:!1,configurable:!1,get:function(){if(f.length!==0)return f},set:function(R){typeof R<"u"?f=R:f=[]}}),Object.defineProperty(this,"x",{enumerable:!0,configurable:!0,get:function(){return!f||isNaN(f[0])?0:B(f[0])},set:function(R){f[0]=v(R)}}),Object.defineProperty(this,"y",{enumerable:!0,configurable:!0,get:function(){return!f||isNaN(f[1])?0:B(f[1])},set:function(R){f[1]=v(R)}}),Object.defineProperty(this,"width",{enumerable:!0,configurable:!0,get:function(){return!f||isNaN(f[2])?0:B(f[2])},set:function(R){f[2]=v(R)}}),Object.defineProperty(this,"height",{enumerable:!0,configurable:!0,get:function(){return!f||isNaN(f[3])?0:B(f[3])},set:function(R){f[3]=v(R)}});var y="";Object.defineProperty(this,"FT",{enumerable:!0,configurable:!1,get:function(){return y},set:function(R){switch(R){case"/Btn":case"/Tx":case"/Ch":case"/Sig":y=R;break;default:throw new Error('Invalid value "'+R+'" for attribute FT supplied.')}}});var w=null;Object.defineProperty(this,"T",{enumerable:!0,configurable:!1,get:function(){if(!w||w.length<1){if(this instanceof Ht)return;w="FieldObject"+et.FieldNum++}return"("+r(w)+")"},set:function(R){w=R.toString()}}),Object.defineProperty(this,"fieldName",{configurable:!0,enumerable:!0,get:function(){return w},set:function(R){w=R}});var I="helvetica";Object.defineProperty(this,"fontName",{enumerable:!0,configurable:!0,get:function(){return I},set:function(R){I=R}});var Q="normal";Object.defineProperty(this,"fontStyle",{enumerable:!0,configurable:!0,get:function(){return Q},set:function(R){Q=R}});var U=0;Object.defineProperty(this,"fontSize",{enumerable:!0,configurable:!0,get:function(){return B(U)},set:function(R){U=v(R)}});var nt=50;Object.defineProperty(this,"maxFontSize",{enumerable:!0,configurable:!0,get:function(){return B(nt)},set:function(R){nt=v(R)}});var rt="black";Object.defineProperty(this,"color",{enumerable:!0,configurable:!0,get:function(){return rt},set:function(R){rt=R}});var ot="/F1 0 Tf 0 g";Object.defineProperty(this,"DA",{enumerable:!0,configurable:!1,get:function(){if(!(!ot||this instanceof Ht||this instanceof bt))return S(ot)},set:function(R){R=R.toString(),ot=R}});var ct=null;Object.defineProperty(this,"DV",{enumerable:!1,configurable:!1,get:function(){if(ct)return this instanceof V?ct:S(ct)},set:function(R){R=R.toString(),this instanceof V?ct=R:R.substr(0,1)==="("?ct=h(R.substr(1,R.length-2)):ct=h(R)}}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,get:function(){return this instanceof V?h(ct.substr(1,ct.length-1)):ct},set:function(R){R=R.toString(),this instanceof V?ct="/"+R:ct=R}});var at=null;Object.defineProperty(this,"V",{enumerable:!1,configurable:!1,get:function(){if(this.isUnicode)return at;if(at)return this instanceof V?at:S(at)},set:function(R){R=R.toString(),this.isUnicode?(at=n(R),this.trueValue=R):this instanceof V?at=R:R.substr(0,1)==="("?at=h(R.substr(1,R.length-2)):at=h(R)}}),Object.defineProperty(this,"value",{enumerable:!0,configurable:!0,get:function(){return this.isUnicode?at:this instanceof V?h(at.substr(1,at.length-1)):at},set:function(R){R=R.toString(),this.isUnicode?(at=n(R),this.trueValue=R):this instanceof V?at="/"+R:at=R}}),Object.defineProperty(this,"hasAnnotation",{enumerable:!0,configurable:!0,get:function(){return this.Rect}}),Object.defineProperty(this,"Type",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?"/Annot":null}}),Object.defineProperty(this,"Subtype",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?"/Widget":null}});var Mt=!1;Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,writeable:!0,get:function(){return Mt},set:function(R){R=!!R,Mt=R}});var Gt;Object.defineProperty(this,"page",{enumerable:!0,configurable:!0,writeable:!0,get:function(){if(Gt)return Gt},set:function(R){Gt=R}}),Object.defineProperty(this,"readOnly",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,1)},set:function(R){R?this.Ff=Y(this.Ff,1):this.Ff=K(this.Ff,1)}}),Object.defineProperty(this,"required",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,2)},set:function(R){R?this.Ff=Y(this.Ff,2):this.Ff=K(this.Ff,2)}}),Object.defineProperty(this,"noExport",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,3)},set:function(R){R?this.Ff=Y(this.Ff,3):this.Ff=K(this.Ff,3)}});var wt=null;Object.defineProperty(this,"Q",{enumerable:!0,configurable:!1,get:function(){if(wt!==null)return wt},set:function(R){if([0,1,2].indexOf(R)!==-1)wt=R;else throw new Error('Invalid value "'+R+'" for attribute Q supplied.')}}),Object.defineProperty(this,"textAlign",{get:function(){var R;switch(wt){case 0:default:R="left";break;case 1:R="center";break;case 2:R="right";break}return R},configurable:!0,enumerable:!0,set:function(R){switch(R){case"right":case 2:wt=2;break;case"center":case 1:wt=1;break;default:wt=0}}})};p(et,E);var it=function(){et.call(this),this.FT="/Ch",this.V="()",this.fontName="zapfdingbats";var c=0;Object.defineProperty(this,"TI",{enumerable:!0,configurable:!1,get:function(){return c},set:function(y){c=y}});var g="<< /BG [ 0.975 0.975 0.975 ] >>";Object.defineProperty(this,"MK",{enumerable:!0,configurable:!1,get:function(){return g},set:function(y){g=y}}),Object.defineProperty(this,"topIndex",{enumerable:!0,configurable:!0,get:function(){return c},set:function(y){c=y}});var f=[];Object.defineProperty(this,"Opt",{enumerable:!0,configurable:!1,get:function(){return this.isUnicode?a(f):_(f)},set:function(y){f=$(y)}}),this.getOptions=function(){return f},this.setOptions=function(y){f=y,this.sort&&f.sort()},this.addOption=function(y){y=y||"",y=y.toString(),f.push(y),this.sort&&f.sort()},this.removeOption=function(y,w){for(w=w||!1,y=y||"",y=y.toString();f.indexOf(y)!==-1&&(f.splice(f.indexOf(y),1),w!==!1););},Object.defineProperty(this,"combo",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,18)},set:function(y){y?this.Ff=Y(this.Ff,18):this.Ff=K(this.Ff,18)}}),Object.defineProperty(this,"edit",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,19)},set:function(y){this.combo===!0&&(y?this.Ff=Y(this.Ff,19):this.Ff=K(this.Ff,19))}}),Object.defineProperty(this,"sort",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,20)},set:function(y){y?(this.Ff=Y(this.Ff,20),f.sort()):this.Ff=K(this.Ff,20)}}),Object.defineProperty(this,"multiSelect",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,22)},set:function(y){y?this.Ff=Y(this.Ff,22):this.Ff=K(this.Ff,22)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,23)},set:function(y){y?this.Ff=Y(this.Ff,23):this.Ff=K(this.Ff,23)}}),Object.defineProperty(this,"commitOnSelChange",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,27)},set:function(y){y?this.Ff=Y(this.Ff,27):this.Ff=K(this.Ff,27)}}),this.hasAppearanceStream=!1};p(it,et);var lt=function(){it.call(this),this.fontName="helvetica",this.combo=!1};p(lt,it);var ht=function(){lt.call(this),this.combo=!0};p(ht,lt);var dt=function(){ht.call(this),this.edit=!0};p(dt,ht);var V=function(){et.call(this),this.FT="/Btn",Object.defineProperty(this,"noToggleToOff",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,15)},set:function(f){f?this.Ff=Y(this.Ff,15):this.Ff=K(this.Ff,15)}}),Object.defineProperty(this,"radio",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,16)},set:function(f){f?this.Ff=Y(this.Ff,16):this.Ff=K(this.Ff,16)}}),Object.defineProperty(this,"pushButton",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,17)},set:function(f){f?this.Ff=Y(this.Ff,17):this.Ff=K(this.Ff,17)}}),Object.defineProperty(this,"radioIsUnison",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,26)},set:function(f){f?this.Ff=Y(this.Ff,26):this.Ff=K(this.Ff,26)}});var c={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){if(Object.keys(c).length!==0){var f=[];f.push("<<");var y;for(y in c)f.push("/"+y+" ("+c[y]+")");return f.push(">>"),f.join(`
`)}},set:function(f){typeof f=="object"&&(c=f)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return c.CA||""},set:function(f){typeof f=="string"&&(c.CA=f)}});var g;Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return g},set:function(f){g=f}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return g.substr(1,g.length-1)},set:function(f){g="/"+f}})};p(V,et);var Bt=function(){V.call(this),this.pushButton=!0};p(Bt,V);var vt=function(){V.call(this),this.radio=!0,this.pushButton=!1;var c=[];Object.defineProperty(this,"Kids",{enumerable:!0,configurable:!1,get:function(){return c},set:function(g){typeof g<"u"?c=g:c=[]}})};p(vt,V);var Ht=function(){et.call(this);var c;Object.defineProperty(this,"Parent",{enumerable:!1,configurable:!1,get:function(){return c},set:function(w){c=w}});var g;Object.defineProperty(this,"optionName",{enumerable:!1,configurable:!0,get:function(){return g},set:function(w){g=w}});var f={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){var w=[];w.push("<<");var I;for(I in f)w.push("/"+I+" ("+f[I]+")");return w.push(">>"),w.join(`
`)},set:function(w){typeof w=="object"&&(f=w)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return f.CA||""},set:function(w){typeof w=="string"&&(f.CA=w)}});var y;Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return y},set:function(w){y=w}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return y.substr(1,y.length-1)},set:function(w){y="/"+w}}),this.caption="l",this.appearanceState="Off",this._AppearanceType=P.RadioButton.Circle,this.appearanceStreamContent=this._AppearanceType.createAppearanceStream(this.optionName)};p(Ht,et),vt.prototype.setAppearance=function(c){if(!("createAppearanceStream"in c&&"getCA"in c))throw new Error("Couldn't assign Appearance to RadioButton. Appearance was Invalid!");for(var g in this.Kids)if(this.Kids.hasOwnProperty(g)){var f=this.Kids[g];f.appearanceStreamContent=c.createAppearanceStream(f.optionName),f.caption=c.getCA()}},vt.prototype.createOption=function(c){var g=new Ht;return g.Parent=this,g.optionName=c,this.Kids.push(g),yt.call(this,g),g};var qt=function(){V.call(this),this.fontName="zapfdingbats",this.caption="3",this.appearanceState="On",this.value="On",this.textAlign="center",this.appearanceStreamContent=P.CheckBox.createAppearanceStream()};p(qt,V);var bt=function(){et.call(this),this.FT="/Tx",Object.defineProperty(this,"multiline",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,13)},set:function(g){g?this.Ff=Y(this.Ff,13):this.Ff=K(this.Ff,13)}}),Object.defineProperty(this,"fileSelect",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,21)},set:function(g){g?this.Ff=Y(this.Ff,21):this.Ff=K(this.Ff,21)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,23)},set:function(g){g?this.Ff=Y(this.Ff,23):this.Ff=K(this.Ff,23)}}),Object.defineProperty(this,"doNotScroll",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,24)},set:function(g){g?this.Ff=Y(this.Ff,24):this.Ff=K(this.Ff,24)}}),Object.defineProperty(this,"comb",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,25)},set:function(g){g?this.Ff=Y(this.Ff,25):this.Ff=K(this.Ff,25)}}),Object.defineProperty(this,"richText",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,26)},set:function(g){g?this.Ff=Y(this.Ff,26):this.Ff=K(this.Ff,26)}});var c=null;Object.defineProperty(this,"MaxLen",{enumerable:!0,configurable:!1,get:function(){return c},set:function(g){c=g}}),Object.defineProperty(this,"maxLength",{enumerable:!0,configurable:!0,get:function(){return c},set:function(g){Number.isInteger(g)&&(c=g)}}),Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,get:function(){return this.V||this.DV}})};p(bt,et);var ft=function(){bt.call(this),Object.defineProperty(this,"password",{enumerable:!0,configurable:!0,get:function(){return!!D(this.Ff,14)},set:function(c){c?this.Ff=Y(this.Ff,14):this.Ff=K(this.Ff,14)}}),this.password=!0};p(ft,bt);var P={CheckBox:{createAppearanceStream:function(){var c={N:{On:P.CheckBox.YesNormal},D:{On:P.CheckBox.YesPushDown,Off:P.CheckBox.OffPushDown}};return c},YesPushDown:function(c){var g=new M(c),f=[],y=s.internal.getFont(c.fontName,c.fontStyle).id,w=s.__private__.encodeColorString(c.color),I=C(c,c.caption);return f.push("0.749023 g"),f.push("0 0 "+l(P.internal.getWidth(c))+" "+l(P.internal.getHeight(c))+" re"),f.push("f"),f.push("BMC"),f.push("q"),f.push("0 0 1 rg"),f.push("/"+y+" "+l(I.fontSize)+" Tf "+w),f.push("BT"),f.push(I.text),f.push("ET"),f.push("Q"),f.push("EMC"),g.stream=f.join(`
`),g},YesNormal:function(c){var g=new M(c),f=s.internal.getFont(c.fontName,c.fontStyle).id,y=s.__private__.encodeColorString(c.color),w=[],I=P.internal.getHeight(c),Q=P.internal.getWidth(c),U=C(c,c.caption);return w.push("1 g"),w.push("0 0 "+l(Q)+" "+l(I)+" re"),w.push("f"),w.push("q"),w.push("0 0 1 rg"),w.push("0 0 "+l(Q-1)+" "+l(I-1)+" re"),w.push("W"),w.push("n"),w.push("0 g"),w.push("BT"),w.push("/"+f+" "+l(U.fontSize)+" Tf "+y),w.push(U.text),w.push("ET"),w.push("Q"),g.stream=w.join(`
`),g},OffPushDown:function(c){var g=new M(c),f=[];return f.push("0.749023 g"),f.push("0 0 "+l(P.internal.getWidth(c))+" "+l(P.internal.getHeight(c))+" re"),f.push("f"),g.stream=f.join(`
`),g}},RadioButton:{Circle:{createAppearanceStream:function(c){var g={D:{Off:P.RadioButton.Circle.OffPushDown},N:{}};return g.N[c]=P.RadioButton.Circle.YesNormal,g.D[c]=P.RadioButton.Circle.YesPushDown,g},getCA:function(){return"l"},YesNormal:function(c){var g=new M(c),f=[],y=P.internal.getWidth(c)<=P.internal.getHeight(c)?P.internal.getWidth(c)/4:P.internal.getHeight(c)/4;y=Number((y*.9).toFixed(5));var w=P.internal.Bezier_C,I=Number((y*w).toFixed(5));return f.push("q"),f.push("1 0 0 1 "+u(P.internal.getWidth(c)/2)+" "+u(P.internal.getHeight(c)/2)+" cm"),f.push(y+" 0 m"),f.push(y+" "+I+" "+I+" "+y+" 0 "+y+" c"),f.push("-"+I+" "+y+" -"+y+" "+I+" -"+y+" 0 c"),f.push("-"+y+" -"+I+" -"+I+" -"+y+" 0 -"+y+" c"),f.push(I+" -"+y+" "+y+" -"+I+" "+y+" 0 c"),f.push("f"),f.push("Q"),g.stream=f.join(`
`),g},YesPushDown:function(c){var g=new M(c),f=[],y=P.internal.getWidth(c)<=P.internal.getHeight(c)?P.internal.getWidth(c)/4:P.internal.getHeight(c)/4,y=Number((y*.9).toFixed(5)),w=Number((y*2).toFixed(5)),I=Number((w*P.internal.Bezier_C).toFixed(5)),Q=Number((y*P.internal.Bezier_C).toFixed(5));return f.push("0.749023 g"),f.push("q"),f.push("1 0 0 1 "+u(P.internal.getWidth(c)/2)+" "+u(P.internal.getHeight(c)/2)+" cm"),f.push(w+" 0 m"),f.push(w+" "+I+" "+I+" "+w+" 0 "+w+" c"),f.push("-"+I+" "+w+" -"+w+" "+I+" -"+w+" 0 c"),f.push("-"+w+" -"+I+" -"+I+" -"+w+" 0 -"+w+" c"),f.push(I+" -"+w+" "+w+" -"+I+" "+w+" 0 c"),f.push("f"),f.push("Q"),f.push("0 g"),f.push("q"),f.push("1 0 0 1 "+u(P.internal.getWidth(c)/2)+" "+u(P.internal.getHeight(c)/2)+" cm"),f.push(y+" 0 m"),f.push(""+y+" "+Q+" "+Q+" "+y+" 0 "+y+" c"),f.push("-"+Q+" "+y+" -"+y+" "+Q+" -"+y+" 0 c"),f.push("-"+y+" -"+Q+" -"+Q+" -"+y+" 0 -"+y+" c"),f.push(Q+" -"+y+" "+y+" -"+Q+" "+y+" 0 c"),f.push("f"),f.push("Q"),g.stream=f.join(`
`),g},OffPushDown:function(c){var g=new M(c),f=[],y=P.internal.getWidth(c)<=P.internal.getHeight(c)?P.internal.getWidth(c)/4:P.internal.getHeight(c)/4;y=Number((y*.9).toFixed(5));var w=Number((y*2).toFixed(5)),I=Number((w*P.internal.Bezier_C).toFixed(5));return f.push("0.749023 g"),f.push("q"),f.push("1 0 0 1 "+u(P.internal.getWidth(c)/2)+" "+u(P.internal.getHeight(c)/2)+" cm"),f.push(w+" 0 m"),f.push(w+" "+I+" "+I+" "+w+" 0 "+w+" c"),f.push("-"+I+" "+w+" -"+w+" "+I+" -"+w+" 0 c"),f.push("-"+w+" -"+I+" -"+I+" -"+w+" 0 -"+w+" c"),f.push(I+" -"+w+" "+w+" -"+I+" "+w+" 0 c"),f.push("f"),f.push("Q"),g.stream=f.join(`
`),g}},Cross:{createAppearanceStream:function(c){var g={D:{Off:P.RadioButton.Cross.OffPushDown},N:{}};return g.N[c]=P.RadioButton.Cross.YesNormal,g.D[c]=P.RadioButton.Cross.YesPushDown,g},getCA:function(){return"8"},YesNormal:function(c){var g=new M(c),f=[],y=P.internal.calculateCross(c);return f.push("q"),f.push("1 1 "+l(P.internal.getWidth(c)-2)+" "+l(P.internal.getHeight(c)-2)+" re"),f.push("W"),f.push("n"),f.push(l(y.x1.x)+" "+l(y.x1.y)+" m"),f.push(l(y.x2.x)+" "+l(y.x2.y)+" l"),f.push(l(y.x4.x)+" "+l(y.x4.y)+" m"),f.push(l(y.x3.x)+" "+l(y.x3.y)+" l"),f.push("s"),f.push("Q"),g.stream=f.join(`
`),g},YesPushDown:function(c){var g=new M(c),f=P.internal.calculateCross(c),y=[];return y.push("0.749023 g"),y.push("0 0 "+l(P.internal.getWidth(c))+" "+l(P.internal.getHeight(c))+" re"),y.push("f"),y.push("q"),y.push("1 1 "+l(P.internal.getWidth(c)-2)+" "+l(P.internal.getHeight(c)-2)+" re"),y.push("W"),y.push("n"),y.push(l(f.x1.x)+" "+l(f.x1.y)+" m"),y.push(l(f.x2.x)+" "+l(f.x2.y)+" l"),y.push(l(f.x4.x)+" "+l(f.x4.y)+" m"),y.push(l(f.x3.x)+" "+l(f.x3.y)+" l"),y.push("s"),y.push("Q"),g.stream=y.join(`
`),g},OffPushDown:function(c){var g=new M(c),f=[];return f.push("0.749023 g"),f.push("0 0 "+l(P.internal.getWidth(c))+" "+l(P.internal.getHeight(c))+" re"),f.push("f"),g.stream=f.join(`
`),g}}},createDefaultAppearanceStream:function(c){var g=s.internal.getFont(c.fontName,c.fontStyle).id,f=s.__private__.encodeColorString(c.color),y=c.fontSize,w="/"+g+" "+y+" Tf "+f;return w}};P.internal={Bezier_C:.551915024494,calculateCross:function(c){var g=P.internal.getWidth(c),f=P.internal.getHeight(c),y=Math.min(g,f),w={x1:{x:(g-y)/2,y:(f-y)/2+y},x2:{x:(g-y)/2+y,y:(f-y)/2},x3:{x:(g-y)/2,y:(f-y)/2},x4:{x:(g-y)/2+y,y:(f-y)/2+y}};return w}},P.internal.getWidth=function(c){var g=0;return typeof c=="object"&&(g=v(c.Rect[2])),g},P.internal.getHeight=function(c){var g=0;return typeof c=="object"&&(g=v(c.Rect[3])),g};var yt=e.addField=function(c){if(q.call(this),c instanceof et)x.call(this,c);else throw new Error("Invalid argument passed to jsPDF.addField.");return c.page=s.internal.getCurrentPageInfo().pageNumber,this};e.addButton=function(c){if(!(c instanceof V))throw new Error("Invalid argument passed to jsPDF.addButton.");return yt.call(this,c)},e.addTextField=function(c){if(!(c instanceof bt))throw new Error("Invalid argument passed to jsPDF.addTextField.");return yt.call(this,c)},e.addChoiceField=function(c){if(!(c instanceof it))throw new Error("Invalid argument passed to jsPDF.addChoiceField.");return yt.call(this,c)},typeof t=="object"&&typeof t.ChoiceField>"u"&&typeof t.ListBox>"u"&&typeof t.ComboBox>"u"&&typeof t.EditBox>"u"&&typeof t.Button>"u"&&typeof t.PushButton>"u"&&typeof t.RadioButton>"u"&&typeof t.CheckBox>"u"&&typeof t.TextField>"u"&&typeof t.PasswordField>"u"&&(t.ChoiceField=it,t.ListBox=lt,t.ComboBox=ht,t.EditBox=dt,t.Button=V,t.PushButton=Bt,t.RadioButton=vt,t.CheckBox=qt,t.TextField=bt,t.PasswordField=ft,t.AcroForm={Appearance:P}),e.AcroFormChoiceField=it,e.AcroFormListBox=lt,e.AcroFormComboBox=ht,e.AcroFormEditBox=dt,e.AcroFormButton=V,e.AcroFormPushButton=Bt,e.AcroFormRadioButton=vt,e.AcroFormCheckBox=qt,e.AcroFormTextField=bt,e.AcroFormPasswordField=ft,e.AcroFormAppearance=P,e.AcroForm={ChoiceField:it,ListBox:lt,ComboBox:ht,EditBox:dt,Button:V,PushButton:Bt,RadioButton:vt,CheckBox:qt,TextField:bt,PasswordField:ft,Appearance:P},m.AcroForm={ChoiceField:it,ListBox:lt,ComboBox:ht,EditBox:dt,Button:V,PushButton:Bt,RadioButton:vt,CheckBox:qt,TextField:bt,PasswordField:ft,Appearance:P}})(_t.jsPDF,typeof window<"u"&&window||typeof global<"u"&&global);/**
* jsPDF fromHTML plugin. BETA stage. API subject to change. Needs browser
* Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
* 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria
* 2014 Diego Casorran, https://github.com/diegocr
* 2014 Daniel Husar, https://github.com/danielhusar
* 2014 Wolfgang Gassler, https://github.com/woolfg
* 2014 Steven Spungin, https://github.com/flamenco
*
* @license
*
* ====================================================================
*/(function(m){var t,e,s,i,n,r,h,a,l,u,p,v,B,M,Z,st,ut,D,Y,K;t=(function(){return function(b){return C.prototype=b,new C};function C(){}})(),u=function(b){var d,F,x,j,k,L,A;for(F=0,x=b.length,d=void 0,j=!1,L=!1;!j&&F!==x;)d=b[F]=b[F].trimLeft(),d&&(j=!0),F++;for(F=x-1;x&&!L&&F!==-1;)d=b[F]=b[F].trimRight(),d&&(L=!0),F--;for(k=/\s+$/g,A=!0,F=0;F!==x;)b[F]!="\u2028"&&(d=b[F].replace(/\s+/g," "),A&&(d=d.trimLeft()),d&&(A=k.test(d)),b[F]=d),F++;return b},p=function(b,d,F,x){return this.pdf=b,this.x=d,this.y=F,this.settings=x,this.watchFunctions=[],this.init(),this},v=function(b){var d,F,x;for(d=void 0,x=b.split(","),F=x.shift();!d&&F;)d=s[F.trim().toLowerCase()],F=x.shift();return d},B=function(b){b=b==="auto"?"0px":b,b.indexOf("em")>-1&&!isNaN(Number(b.replace("em","")))&&(b=Number(b.replace("em",""))*18.719+"px"),b.indexOf("pt")>-1&&!isNaN(Number(b.replace("pt","")))&&(b=Number(b.replace("pt",""))*1.333+"px");var d,F,x;return F=void 0,d=16,x=M[b],x||(x={"xx-small":9,"x-small":11,small:13,medium:16,large:19,"x-large":23,"xx-large":28,auto:0}[b],x!==F||(x=parseFloat(b))?M[b]=x/d:(x=b.match(/([\d\.]+)(px)/),Array.isArray(x)&&x.length===3?M[b]=parseFloat(x[1])/d:M[b]=1))},l=function(b){var d,F,x;return x=(function(j){var k;return k=(function(L){return document.defaultView&&document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(L,null):L.currentStyle?L.currentStyle:L.style})(j),function(L){return L=L.replace(/-\D/g,function(A){return A.charAt(1).toUpperCase()}),k[L]}})(b),d={},F=void 0,d["font-family"]=v(x("font-family"))||"times",d["font-style"]=i[x("font-style")]||"normal",d["text-align"]=n[x("text-align")]||"left",F=r[x("font-weight")]||"normal",F==="bold"&&(d["font-style"]==="normal"?d["font-style"]=F:d["font-style"]=F+d["font-style"]),d["font-size"]=B(x("font-size"))||1,d["line-height"]=B(x("line-height"))||1,d.display=x("display")==="inline"?"inline":"block",F=d.display==="block",d["margin-top"]=F&&B(x("margin-top"))||0,d["margin-bottom"]=F&&B(x("margin-bottom"))||0,d["padding-top"]=F&&B(x("padding-top"))||0,d["padding-bottom"]=F&&B(x("padding-bottom"))||0,d["margin-left"]=F&&B(x("margin-left"))||0,d["margin-right"]=F&&B(x("margin-right"))||0,d["padding-left"]=F&&B(x("padding-left"))||0,d["padding-right"]=F&&B(x("padding-right"))||0,d["page-break-before"]=x("page-break-before")||"auto",d.float=h[x("cssFloat")]||"none",d.clear=a[x("clear")]||"none",d.color=x("color"),d},Z=function(b,d,F){var x,j,k,L,A;if(k=!1,j=void 0,L=void 0,x=F["#"+b.id],x)if(typeof x=="function")k=x(b,d);else for(j=0,L=x.length;!k&&j!==L;)k=x[j](b,d),j++;if(x=F[b.nodeName],!k&&x)if(typeof x=="function")k=x(b,d);else for(j=0,L=x.length;!k&&j!==L;)k=x[j](b,d),j++;for(A=typeof b.className=="string"?b.className.split(" "):[],j=0;j<A.length;j++)if(x=F["."+A[j]],!k&&x)if(typeof x=="function")k=x(b,d);else for(j=0,L=x.length;!k&&j!==L;)k=x[j](b,d),j++;return k},K=function(b,d){var F,x,j,k,L,A,H,q,_;F=[],x=[],j=0,_=0;for(var k=0;k<b.rows[0].cells.length;k++)_+=b.rows[0].cells[k].colSpan;for(H=b.clientWidth;j<_;){q=b.rows[0].cells[j];for(var k=0;k<q.colSpan;k++)x[j+k]={name:q.textContent.toLowerCase().replace(/\s+/g,"")+"_"+k,prompt:q.textContent.replace(/\r?\n/g,""),width:q.clientWidth/H*d.settings.width/q.colSpan};j+=k}for(j=1;j<b.rows.length;){for(A=b.rows[j],L={},k=0;k<A.cells.length;)L[x[k].name]=A.cells[k].textContent.replace(/\r?\n/g,""),k++;F.push(L),j++}return{rows:F,headers:x}};var gt={SCRIPT:1,STYLE:1,NOSCRIPT:1,OBJECT:1,EMBED:1,SELECT:1},J=1;e=function(b,d,F){var x,j,k,L,A,H,q,_;for(j=b.childNodes,x=void 0,k=l(b),A=k.display==="block",A&&(d.setBlockBoundary(),d.setBlockStyle(k)),L=0,H=j.length;L<H;){if(x=j[L],typeof x=="object"){if(d.executeWatchFunctions(x),x.nodeType===1&&x.nodeName==="HEADER"){var G=x,$=d.pdf.margins_doc.top;d.pdf.internal.events.subscribe("addPage",function(ft){d.y=$,e(G,d,F),d.pdf.margins_doc.top=d.y+10,d.y+=10},!1)}if(x.nodeType===8&&x.nodeName==="#comment")~x.textContent.indexOf("ADD_PAGE")&&(d.pdf.addPage(),d.y=d.pdf.margins_doc.top);else if(x.nodeType===1&&!gt[x.nodeName]){var S;if(x.nodeName==="IMG"){var E=x.getAttribute("src");S=st[d.pdf.sHashCode&&d.pdf.sHashCode(E)||E]}if(S){d.pdf.internal.pageSize.getHeight()-d.pdf.margins_doc.bottom<d.y+x.height&&d.y>d.pdf.margins_doc.top&&(d.pdf.addPage(),d.y=d.pdf.margins_doc.top,d.executeWatchFunctions(x));var O=l(x),X=d.x,et=12/d.pdf.internal.scaleFactor,it=(O["margin-left"]+O["padding-left"])*et,lt=(O["margin-right"]+O["padding-right"])*et,ht=(O["margin-top"]+O["padding-top"])*et,dt=(O["margin-bottom"]+O["padding-bottom"])*et;O.float!==void 0&&O.float==="right"?X+=d.settings.width-x.width-lt:X+=it,d.pdf.addImage(S,X,d.y+ht,x.width,x.height),S=void 0,O.float==="right"||O.float==="left"?(d.watchFunctions.push(function(ft,P,yt,c){return d.y>=P?(d.x+=ft,d.settings.width+=yt,!0):c&&c.nodeType===1&&!gt[c.nodeName]&&d.x+c.width>d.pdf.margins_doc.left+d.pdf.margins_doc.width?(d.x+=ft,d.y=P,d.settings.width+=yt,!0):!1}.bind(this,O.float==="left"?-x.width-it-lt:0,d.y+x.height+ht+dt,x.width)),d.watchFunctions.push(function(ft,P,yt){return d.y<ft&&P===d.pdf.internal.getNumberOfPages()?yt.nodeType===1&&l(yt).clear==="both"?(d.y=ft,!0):!1:!0}.bind(this,d.y+x.height,d.pdf.internal.getNumberOfPages())),d.settings.width-=x.width+it+lt,O.float==="left"&&(d.x+=x.width+it+lt)):d.y+=x.height+ht+dt}else if(x.nodeName==="TABLE")d.pdf.autoTable?(d.y+=10,d.pdf.autoTable({theme:"grid",html:x,startY:d.y,styles:{font:d.pdf.getFont().fontName,fontSize:d.pdf.getFontSize(),textColor:d.pdf.getTextColor()},margin:{top:d.pdf.margins_doc.top,left:d.x,right:d.pdf.internal.pageSize.getWidth()-(d.x+d.settings.width),bottom:d.pdf.margins_doc.bottom}}),d.y=d.pdf.lastAutoTable.finalY):(q=K(x,d),d.y+=10,d.pdf.table(d.x,d.y,q.rows,q.headers,{autoSize:!1,printHeaders:F.printHeaders,margins:d.pdf.margins_doc,css:l(x)}),d.y=d.pdf.internal.__cell__.lastCell.y+d.pdf.internal.__cell__.lastCell.height);else if(x.nodeName==="OL"||x.nodeName==="UL")J=1,Z(x,d,F)||e(x,d,F),d.y+=10;else if(x.nodeName==="LI"){var V=d.x;d.x+=20/d.pdf.internal.scaleFactor,d.y+=3,Z(x,d,F)||e(x,d,F),d.x=V}else x.nodeName==="BR"?(d.y+=k["font-size"]*d.pdf.internal.scaleFactor,d.addText("\u2028",t(k))):Z(x,d,F)||e(x,d,F)}else if(x.nodeType===3){var Bt=x.nodeValue;if(x.nodeValue&&x.parentNode.nodeName==="LI")if(x.parentNode.parentNode.nodeName==="OL")Bt=J+++". "+Bt;else{var vt=k["font-size"],Ht=(3-vt*.75)*d.pdf.internal.scaleFactor,qt=vt*.75*d.pdf.internal.scaleFactor,bt=vt*1.74/d.pdf.internal.scaleFactor;_=function(P,yt){this.pdf.circle(P+Ht,yt+qt,bt,"FD")}}x.ownerDocument.body.compareDocumentPosition(x)&16&&d.addText(Bt,k)}else typeof x=="string"&&d.addText(x,k)}L++}if(F.outY=d.y,A)return d.setBlockBoundary(_)},st={},ut=function(b,d,F,x){var j=b.getElementsByTagName("img"),k=j.length,L,A=0;function H(){d.pdf.internal.events.publish("imagesLoaded"),x(L)}function q(_,G,$){if(_){var S=new Image;L=++A,S.crossOrigin="",S.onerror=S.onload=function(){if(S.complete&&(S.src.indexOf("data:image/")===0&&(S.width=G||S.width||0,S.height=$||S.height||0),S.width+S.height)){var E=d.pdf.sHashCode&&d.pdf.sHashCode(_)||_;st[E]=st[E]||S}--A||H()},S.src=_}}for(;k--;)q(j[k].getAttribute("src"),j[k].width,j[k].height);return A||H()},D=function(b,d,F){var x=b.getElementsByTagName("footer");if(x.length>0){x=x[0];var j=d.pdf.internal.write,k=d.y;d.pdf.internal.write=function(){},e(x,d,F);var L=Math.ceil(d.y-k)+5;d.y=k,d.pdf.internal.write=j,d.pdf.margins_doc.bottom+=L;for(var A=function(G){var $=G!==void 0?G.pageNumber:1,S=d.y;d.y=d.pdf.internal.pageSize.getHeight()-d.pdf.margins_doc.bottom,d.pdf.margins_doc.bottom-=L;for(var E=x.getElementsByTagName("span"),O=0;O<E.length;++O)(" "+E[O].className+" ").replace(/[\n\t]/g," ").indexOf(" pageCounter ")>-1&&(E[O].innerHTML=$),(" "+E[O].className+" ").replace(/[\n\t]/g," ").indexOf(" totalPages ")>-1&&(E[O].innerHTML="###jsPDFVarTotalPages###");e(x,d,F),d.pdf.margins_doc.bottom+=L,d.y=S},H=x.getElementsByTagName("span"),q=0;q<H.length;++q)(" "+H[q].className+" ").replace(/[\n\t]/g," ").indexOf(" totalPages ")>-1&&d.pdf.internal.events.subscribe("htmlRenderingFinished",d.pdf.putTotalPages.bind(d.pdf,"###jsPDFVarTotalPages###"),!0);d.pdf.internal.events.subscribe("addPage",A,!1),A(),gt.FOOTER=1}},Y=function(b,d,F,x,j,k){if(!d)return!1;typeof d!="string"&&!d.parentNode&&(d=""+d.innerHTML),typeof d=="string"&&(d=(function($){var S,E,O,X;return O="jsPDFhtmlText"+Date.now().toString()+(Math.random()*1e3).toFixed(0),X="position: absolute !important;clip: rect(1px 1px 1px 1px); /* IE6, IE7 */clip: rect(1px, 1px, 1px, 1px);padding:0 !important;border:0 !important;height: 1px !important;width: 1px !important; top:auto;left:-100px;overflow: hidden;",E=document.createElement("div"),E.className="sjs-pdf-hidden-html-div",E.style.cssText=X,E.innerHTML='<iframe style="height:1px;width:1px" name="'+O+'" />',document.body.appendChild(E),S=window.frames[O],S.document.open(),S.document.writeln($),S.document.close(),S.document.body})(d.replace(/<\/?script[^>]*?>/gi,"")));for(var L=Object.keys(b.getFontList()),A=0;A<L.length;++A){var H=L[A],q=H.toLowerCase();s[q]||(s[q]=H)}var _=new p(b,F,x,j),G;return ut.call(this,d,_,j.elementHandlers,function($){D(d,_,j.elementHandlers),e(d,_,j.elementHandlers),_.pdf.internal.events.publish("htmlRenderingFinished"),G=_.dispose(),typeof k=="function"?k(G):$&&console.error("jsPDF Warning: rendering issues? provide a callback to fromHTML!")}),G||{x:_.x,y:_.y}},p.prototype.init=function(){return this.paragraph={text:[],style:[]},this.pdf.internal.write("q")},p.prototype.dispose=function(){return this.pdf.internal.write("Q"),{x:this.x,y:this.y,ready:!0}},p.prototype.executeWatchFunctions=function(C){var b=!1,d=[];if(this.watchFunctions.length>0){for(var F=0;F<this.watchFunctions.length;++F)this.watchFunctions[F](C)===!0?b=!0:d.push(this.watchFunctions[F]);this.watchFunctions=d}return b},p.prototype.splitFragmentsIntoLines=function(C,b){var d,F,x,j,k,L,A,H,q,_,G,$,S;F=12,q=this.pdf.internal.scaleFactor,x=void 0,H=void 0,j=void 0,S=void 0,A=void 0,L=void 0,k=void 0,_=[],G=[_],d=0,$=this.settings.width;const E=this.pdf.getFont().fontName,O=this.pdf.getFont().fontStyle;for(;C.length;)if(j=C.shift(),S=b.shift(),j)if(x=S["font-family"],H=S["font-style"],this.pdf.setFont(x,H),A={textIndent:d,fontSize:S["font-size"]*F},L=this.pdf.getStringUnitWidth(j,A)*A.fontSize/q,j=="\u2028")_=[],G.push(_);else if(d+L>$){for(k=this.pdf.splitTextToSize(j,$,A),_.push([k.shift(),S]);k.length;)_=[[k.shift(),S]],G.push(_);d=this.pdf.getStringUnitWidth(_[0][0],A)*A.fontSize/q}else _.push([j,S]),d+=L;if(S["text-align"]!==void 0&&(S["text-align"]==="center"||S["text-align"]==="right"||S["text-align"]==="justify"))for(var X=0;X<G.length;++X){var et=this.pdf.getStringUnitWidth(G[X][0][0],A)*A.fontSize/q;X>0&&(G[X][0][1]=t(G[X][0][1]));var it=$-et;if(S["text-align"]==="right")G[X][0][1]["margin-left"]=it;else if(S["text-align"]==="center")G[X][0][1]["margin-left"]=it/2;else if(S["text-align"]==="justify"){var lt=G[X][0][0].split(" ").length-1;G[X][0][1]["word-spacing"]=it/lt,X===G.length-1&&(G[X][0][1]["word-spacing"]=0)}}return this.pdf.setFont(E,O),G},p.prototype.RenderTextFragment=function(C,b){var d,F,x;if(x=0,d=12,this.pdf.internal.pageSize.getHeight()-this.pdf.margins_doc.bottom<this.y+this.pdf.internal.getFontSize()){this.pdf.internal.write("ET","Q","Q");const H=this.pdf.getCurrentPageInfo().pageNumber;this.pdf.getNumberOfPages()===H?this.pdf.addPage():this.pdf.setPage(H+1),this.y=this.pdf.margins_doc.top,this.pdf.internal.write("q","q","BT",this.getPdfColor(b.color),this.pdf.internal.getCoordinateString(this.x),this.pdf.internal.getVerticalCoordinateString(this.y),"Td"),x=Math.max(x,b["line-height"],b["font-size"]),this.pdf.internal.write(0,(-1*d*x).toFixed(2),"Td")}F=this.pdf.internal.getFont(b["font-family"],b["font-style"]);var j=this.getPdfColor(b.color);j!==this.lastTextColor&&(this.pdf.internal.write(j),this.lastTextColor=j),b["word-spacing"]!==void 0&&b["word-spacing"]>0&&this.pdf.internal.write(b["word-spacing"].toFixed(2),"Tw");var k=function(H,q){for(var _=q.metadata.Unicode.widths,G=["","0","00","000","0000"],$=[""],S=0,E=H.length,O;S<E;++S){if(O=q.metadata.characterToGlyph(H.charCodeAt(S)),q.metadata.glyIdsUsed.push(O),q.metadata.toUnicode[O]=H.charCodeAt(S),_.indexOf(O)==-1&&(_.push(O),_.push([parseInt(q.metadata.widthOfGlyph(O),10)])),O=="0")return $.join("");O=O.toString(16),$.push(G[4-O.length],O)}return $.join("")},L=function(_,q){var _=_||"",G="",$=0,S,E="",O=q.encoding;if(q.encoding!=="Identity-H")return _;for(E=_,$=0;$<E.length;$+=1)q.metadata.hasOwnProperty("cmap")&&(S=q.metadata.cmap.unicode.codeMap[E[$].charCodeAt(0)]),S||E[$].charCodeAt(0)<256&&q.metadata.hasOwnProperty("Unicode")?G+=E[$]:G+="";var X="";return parseInt(q.id.slice(1))<14||O==="WinAnsiEncoding"?X=this.pdf.internal.pdfEscape(G,key).split("").map(function(et){return et.charCodeAt(0).toString(16)}).join(""):O==="Identity-H"&&(X=k(G,q)),X},A="";F.encoding!=="Identity-H"?A="("+this.pdf.internal.pdfEscape(C)+")":A="<"+L(C,F)+">",this.pdf.internal.write("/"+F.id,(d*b["font-size"]).toFixed(2),"Tf",A+" Tj"),b["word-spacing"]!==void 0&&this.pdf.internal.write(0,"Tw")},p.prototype.getPdfColor=function(C){var b,d,F,x,j=/rgb\s*\(\s*(\d+),\s*(\d+),\s*(\d+\s*)\)/,k=j.exec(C);if(k!=null)d=parseInt(k[1]),F=parseInt(k[2]),x=parseInt(k[3]);else{if(typeof C=="string"&&C.charAt(0)!="#"){var L=new RGBColor(C);L.ok?C=L.toHex():C="#000000"}d=C.substring(1,3),d=parseInt(d,16),F=C.substring(3,5),F=parseInt(F,16),x=C.substring(5,7),x=parseInt(x,16)}if(typeof d=="string"&&/^#[0-9A-Fa-f]{6}$/.test(d)){var A=parseInt(d.substr(1),16);d=A>>16&255,F=A>>8&255,x=A&255}var H=this.f3;return d===0&&F===0&&x===0||typeof F>"u"?b=H(d/255)+" g":b=[H(d/255),H(F/255),H(x/255),"rg"].join(" "),b},p.prototype.f3=function(C){return C.toFixed(3)},p.prototype.renderParagraph=function(C){var b,d,F,x,j,k,L,A,H,q,_,G,$,S;if(x=u(this.paragraph.text),$=this.paragraph.style,b=this.paragraph.blockstyle,this.paragraph.priorblockstyle,this.paragraph={text:[],style:[],blockstyle:{},priorblockstyle:b},!!x.join("").trim()){A=this.splitFragmentsIntoLines(x,$),L=void 0,H=void 0,d=12,F=d/this.pdf.internal.scaleFactor,this.priorMarginBottom=this.priorMarginBottom||0,G=(Math.max((b["margin-top"]||0)-this.priorMarginBottom,0)+(b["padding-top"]||0))*F,_=((b["margin-bottom"]||0)+(b["padding-bottom"]||0))*F,this.priorMarginBottom=b["margin-bottom"]||0,b["page-break-before"]==="always"&&(this.pdf.addPage(),this.y=0,G=((b["margin-top"]||0)+(b["padding-top"]||0))*F),q=this.pdf.internal.write,j=void 0,k=void 0,this.y+=G,q("q","BT 0 g",this.pdf.internal.getCoordinateString(this.x),this.pdf.internal.getVerticalCoordinateString(this.y),"Td");for(var E=0;A.length;){for(L=A.shift(),H=0,j=0,k=L.length;j!==k;)L[j][0].trim()&&(H=Math.max(H,L[j][1]["line-height"],L[j][1]["font-size"]),S=L[j][1]["font-size"]*7),j++;var O=0,X=0;L[0][1]["margin-left"]!==void 0&&L[0][1]["margin-left"]>0&&(X=this.pdf.internal.getCoordinateString(L[0][1]["margin-left"]),O=X-E,E=X);var et=Math.max(b["margin-left"]||0,0)*F;for(q(O+et,(-1*d*H).toFixed(2),"Td"),j=0,k=L.length;j!==k;)L[j][0]&&this.RenderTextFragment(L[j][0],L[j][1]),j++;if(this.y+=H*F,this.executeWatchFunctions(L[0][1])&&A.length>0){var it=[],lt=[];A.forEach(function(ht){for(var dt=0,V=ht.length;dt!==V;)ht[dt][0]&&(it.push(ht[dt][0]+" "),lt.push(ht[dt][1])),++dt}),A=this.splitFragmentsIntoLines(u(it),lt),q("ET","Q"),q("q","BT 0 g",this.pdf.internal.getCoordinateString(this.x),this.pdf.internal.getVerticalCoordinateString(this.y),"Td")}}return C&&typeof C=="function"&&C.call(this,this.x-9,this.y-S/2),q("ET","Q"),this.y+=_}},p.prototype.setBlockBoundary=function(C){return this.renderParagraph(C)},p.prototype.setBlockStyle=function(C){return this.paragraph.blockstyle=C},p.prototype.addText=function(C,b){return this.paragraph.text.push(C),this.paragraph.style.push(b)},s={helvetica:"helvetica","sans-serif":"helvetica","times new roman":"times",serif:"times",times:"times",monospace:"courier",courier:"courier"},r={100:"normal",200:"normal",300:"normal",400:"normal",500:"bold",600:"bold",700:"bold",800:"bold",900:"bold",normal:"normal",bold:"bold",bolder:"bold",lighter:"normal"},i={normal:"normal",italic:"italic",oblique:"italic"},n={left:"left",right:"right",center:"center",justify:"justify"},h={none:"none",right:"right",left:"left"},a={none:"none",both:"both"},M={normal:1},m.fromHTML=function(C,b,d,F,x,j){return this.margins_doc=j||{top:0,bottom:0},F||(F={}),F.elementHandlers||(F.elementHandlers={}),Y(this,C,isNaN(b)?4:b,isNaN(d)?4:d,F,x)}})(_t.jsPDF.API);class kt{constructor(t){var e,s;this._fontSize=6,this._base64Normal=void 0,this._base64Bold=void 0,typeof t.orientation>"u"?typeof t.format>"u"||t.format[0]<t.format[1]?this._orientation="p":this._orientation="l":this._orientation=t.orientation,this._format=t.format||"a4",Array.isArray(this._format)&&(this._format=this._format.map(i=>i*kt.MM_TO_PT)),t.fontName?this._fontName=t.fontName:!kt.SEGOE_BOLD&&!kt.SEGOE_NORMAL?this._fontName="helvetica":this._fontName="segoe",typeof t.fontName<"u"&&(typeof t.base64Normal<"u"||typeof t.base64Bold<"u")?(this._base64Normal=t.base64Normal||t.base64Bold,this._base64Bold=t.base64Bold||t.base64Normal):this.fontName==="segoe"&&(this._base64Normal=kt.SEGOE_NORMAL,this._base64Bold=kt.SEGOE_BOLD),this._margins=o.clone(t.margins),this._htmlRenderAs=t.htmlRenderAs||"auto",this._matrixRenderAs=t.matrixRenderAs||"auto",this._readonlyRenderAs=t.readonlyRenderAs||"auto",this._compress=t.compress||!1,this._applyImageFit=t.applyImageFit||!1,this._useLegacyBooleanRendering=t.useLegacyBooleanRendering||!1,this._isRTL=t.isRTL||!1,this._tagboxSelectedChoicesOnly=t.tagboxSelectedChoicesOnly||!1,this._htmlToImageQuality=(e=t.htmlToImageQuality)!==null&&e!==void 0?e:1,this._otherRowsCount=(s=t.otherRowsCount)!==null&&s!==void 0?s:2}get leftTopPoint(){return{xLeft:this.margins.left,yTop:this.margins.top}}get fontSize(){return this._fontSize}get fontName(){return this._fontName}get base64Normal(){return this._base64Normal}get base64Bold(){return this._base64Bold}get useCustomFontInHtml(){return this._useCustomFontInHtml}get margins(){return this._margins}get format(){return this._format}get orientation(){return this._orientation}get htmlRenderAs(){return this._htmlRenderAs}get matrixRenderAs(){return this._matrixRenderAs}get readonlyRenderAs(){return this._readonlyRenderAs}get compress(){return this._compress}get applyImageFit(){return this._applyImageFit}get useLegacyBooleanRendering(){return this._useLegacyBooleanRendering}get isRTL(){return this._isRTL}get tagboxSelectedChoicesOnly(){return this._tagboxSelectedChoicesOnly}get htmlToImageQuality(){return this._htmlToImageQuality}get otherRowsCount(){return this._otherRowsCount}}kt.MM_TO_PT=72/25.4;class xt extends kt{constructor(t={}){super(t),this.drawColorRestoreCallbacks=[],this.fillColorRestoreCallbacks=[],this.textColorRestoreCallbacks=[],this.textStyleRestoreCallbacks=[];const e={orientation:this.orientation,unit:"pt",format:this.format,compress:this.compress};this._doc=new _t.jsPDF(e),typeof this.base64Normal<"u"&&!o.isFontExist(this,this.fontName)&&(xt.addFont(this.fontName,this.base64Normal,"normal"),xt.addFont(this.fontName,this.base64Bold,"bold"),this._doc=new _t.jsPDF(e)),this._useCustomFontInHtml=t.useCustomFontInHtml&&o.isFontExist(this,this.fontName),this._helperDoc=new _t.jsPDF(e),this._doc.setFont("helvetica"),this._helperDoc.setFont("helvetica"),this._doc.setFontSize(6),this._helperDoc.setFontSize(6),this._fontStyle="normal",this.marginsStack=[]}static addFont(t,e,s){let i=xt.customFonts[t];i||(i={},xt.customFonts[t]=i),i[s]=e;const n=function(){const r=xt.customFonts[t];if(r&&r[s]){const h=`${t}-${s}.ttf`;this.addFileToVFS(h,r[s]),this.addFont(h,t,s)}};_t.jsPDF.API.events.push(["addFonts",n])}get doc(){return this._doc}get helperDoc(){return this._helperDoc}get fontName(){return this._fontName}set fontName(t){this._fontName=t,this._doc.setFont(t),this._helperDoc.setFont(t)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize=t,this._doc.setFontSize(t),this._helperDoc.setFontSize(t)}get lineHeightFactor(){return this._lineHeightFactor}set lineHeightFactor(t){this._lineHeightFactor=t,this._doc.setLineHeightFactor(t),this._helperDoc.setLineHeightFactor(t)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle=t,this._doc.setFont(this._fontName,t),this._helperDoc.setFont(this._fontName,t)}measureText(t=1,e){this.setTextStyle(e,!0);const s=this._helperDoc.getLineHeight()/this._helperDoc.internal.scaleFactor;let i=0;return typeof t=="number"?i=s*t:(t=typeof t=="string"?t:o.getLocString(t),i=t.split("").reduce((n,r)=>n+this._helperDoc.getTextWidth(r),0)),this.restoreTextStyle(!0),{width:i,height:s}}get unitWidth(){return this.measureText().width}get unitHeight(){return this.measureText().height}pushMargins(t,e){this.marginsStack.push({left:this.margins.left,right:this.margins.right}),typeof t<"u"&&(this.margins.left=t),typeof e<"u"&&(this.margins.right=e)}popMargins(){const t=this.marginsStack.pop();this.margins.left=t.left,this.margins.right=t.right}get paperWidth(){return this.doc.internal.pageSize.width}get paperHeight(){return this.doc.internal.pageSize.height}getNumberOfPages(){return this.doc.getNumberOfPages()}addPage(){this.doc.addPage()}getCurrentPageIndex(){return this.doc.getCurrentPageInfo().pageNumber-1}setPage(t){this.doc.setPage(t+1)}setColor(t,e,s,i="opacity"){const{doc:n}=this,r=e(),{color:h,opacity:a}=o.parseColor(t);s(h);let l=!1;return a!==void 0&&(n.saveGraphicsState(),n.setGState(new n.GState({[i]:a})),l=!0),()=>{s(r),l&&this.doc.restoreGraphicsState()}}setDrawColor(t){this.drawColorRestoreCallbacks.push(this.setColor(t,()=>this.doc.getDrawColor(),e=>this.doc.setDrawColor(e),"stroke-opacity"))}restoreDrawColor(){this.drawColorRestoreCallbacks.length>0&&this.drawColorRestoreCallbacks.pop()()}setFillColor(t){this.fillColorRestoreCallbacks.push(this.setColor(t,()=>this.doc.getFillColor(),e=>this.doc.setFillColor(e)))}restoreFillColor(){this.fillColorRestoreCallbacks.length>0&&this.fillColorRestoreCallbacks.pop()()}setTextColor(t){this.textColorRestoreCallbacks.push(this.setColor(t,()=>this.doc.getTextColor(),e=>this.doc.setTextColor(e)))}restoreTextColor(){this.textColorRestoreCallbacks.length>0&&this.textColorRestoreCallbacks.pop()()}setTextStyle(t,e=!1){var s,i,n,r;const h=e?this.helperDoc:this.doc,a=h.getFontSize(),l=h.getFont(),u=h.getLineHeightFactor(),p=(s=t?.fontSize)!==null&&s!==void 0?s:a,v=t?.fontColor&&!e;h.setFont((i=t?.fontName)!==null&&i!==void 0?i:l.fontName,(n=t?.fontStyle)!==null&&n!==void 0?n:l.fontStyle),h.setFontSize(p),h.setLineHeightFactor(((r=t?.lineHeight)!==null&&r!==void 0?r:p)/p),v&&this.setTextColor(t.fontColor),this.textStyleRestoreCallbacks.push({isHelper:e,callback:()=>{h.setFont(l.fontName,l.fontStyle),h.setFontSize(a),h.setLineHeightFactor(u),v&&this.restoreTextColor()}})}restoreTextStyle(t=!1){const e=this.textStyleRestoreCallbacks.length-1-this.textStyleRestoreCallbacks.slice().reverse().findIndex(s=>s.isHelper===t);e<this.textStyleRestoreCallbacks.length&&this.textStyleRestoreCallbacks.splice(e,1)[0].callback()}get AcroFormCheckBox(){return this._AcroFormCheckBox||(this._AcroFormCheckBox=ys(this.doc)),this._AcroFormCheckBox}get AcroFormComboBox(){return this._AcroFormComboBox||(this._AcroFormComboBox=ms(this.doc)),this._AcroFormComboBox}get AcroFormTextField(){return this._AcroFormTextField||(this._AcroFormTextField=ps(this.doc)),this._AcroFormTextField}get AcroFormRadioButton(){return this._AcroFormRadioButton||(this._AcroFormRadioButton=gs(this.doc)),this._AcroFormRadioButton}}xt.customFonts={};class Dt{static findBotInterval(t,e,s,i){const n=t.search(e,s);return n.push({pageIndex:0,xLeft:i.margins.left,xRight:i.margins.left,yBot:i.margins.top,absBot:i.margins.top}),n.reduce((r,h)=>Math.abs(h.xRight-e)<o.EPSILON||Math.abs(h.xLeft-s)<o.EPSILON||h.pageIndex<r.pageIndex?r:h.pageIndex>r.pageIndex||h.yBot>r.yBot?h:r,n[n.length-1])}static addPack(t,e,s){for(let i=t.length;i<=e;i++)t.push([]);t[e].push(s)}static pack(t,e){const s=e.paperHeight-e.margins.top-e.margins.bot,i=[];t.forEach(a=>{i.push([]),a.forEach(l=>{l.height>s+o.EPSILON?i[i.length-1].push(...l.unfold()):i[i.length-1].push(l)})}),i.forEach(a=>{a.sort((l,u)=>l.yTop<u.yTop?-1:l.yTop>u.yTop||l.xLeft>u.xLeft?1:l.xLeft<u.xLeft?-1:0)});let n=0;const r=[],h=e.paperHeight-e.margins.bot;return i.forEach(a=>{const l=new rs;let u=0;a.forEach(p=>{let{pageIndex:v,yBot:B,absBot:M}=Dt.findBotInterval(l,p.xLeft,p.xRight,e);const Z=p.height;p.yTop=B+p.yTop-M,(Math.abs(p.yTop-e.margins.top)>o.EPSILON&&p.yTop+Z>h+o.EPSILON||p.isPageBreak)&&(p.yTop=e.margins.top,v++,u=Math.max(u,v)),l.insert(p.xLeft,p.xRight,{pageIndex:v,xLeft:p.xLeft,xRight:p.xRight,yBot:p.yTop+Z,absBot:p.yBot}),p.yBot=p.yTop+Z,Dt.addPack(r,n+v,p)}),n+=u+1}),r}}T.HorizontalAlign=void 0,(function(m){m.NotSet="notset",m.Left="left",m.Center="center",m.Right="right"})(T.HorizontalAlign||(T.HorizontalAlign={})),T.VerticalAlign=void 0,(function(m){m.NotSet="notset",m.Top="top",m.Middle="middle",m.Bottom="bottom"})(T.VerticalAlign||(T.VerticalAlign={}));class re{constructor(t,e,s,i,n){this.packs=t,this.controller=e,this._rect=s,this._countPages=i,this._pageNumber=n}get pageCount(){return this._countPages}get countPages(){return this._countPages}get pageNumber(){return this._pageNumber}get rect(){return this._rect}alignRect(t,e){typeof t.margins>"u"?t.margins={left:0,right:0,top:0,bot:0}:(typeof t.margins.left>"u"&&(t.margins.left=0),typeof t.margins.right>"u"&&(t.margins.right=0),typeof t.margins.top>"u"&&(t.margins.top=0),typeof t.margins.bot>"u"&&(t.margins.bot=0)),typeof t.rect>"u"&&((typeof t.horizontalAlign>"u"||t.horizontalAlign===T.HorizontalAlign.NotSet)&&(t.horizontalAlign=T.HorizontalAlign.Center),(typeof t.verticalAlign>"u"||t.verticalAlign===T.VerticalAlign.NotSet)&&(t.verticalAlign=T.VerticalAlign.Middle));const s=o.clone(this.rect);if(typeof t.horizontalAlign<"u")switch(t.horizontalAlign){case T.HorizontalAlign.Left:s.xLeft=this.rect.xLeft+t.margins.left,s.xRight=Math.min(this.rect.xRight-t.margins.right,this.rect.xLeft+t.margins.left+e.width);break;case T.HorizontalAlign.Center:s.xLeft=Math.max(this.rect.xLeft+t.margins.left,(this.rect.xLeft+this.rect.xRight-e.width)/2),s.xRight=Math.min(this.rect.xRight-t.margins.right,(this.rect.xLeft+this.rect.xRight+e.width)/2);break;case T.HorizontalAlign.Right:s.xLeft=Math.max(this.rect.xLeft+t.margins.left,this.rect.xRight-t.margins.right-e.width),s.xRight=this.rect.xRight-t.margins.right;break}else s.xLeft=t.rect.xLeft||this.rect.xLeft,s.xRight=t.rect.xRight||this.rect.xRight;if(typeof t.verticalAlign<"u")switch(t.verticalAlign){case T.VerticalAlign.Top:s.yTop=this.rect.yTop+t.margins.top,s.yBot=Math.min(this.rect.yBot-t.margins.bot,this.rect.yTop+t.margins.top+e.height);break;case T.VerticalAlign.Middle:s.yTop=Math.max(this.rect.yTop+t.margins.top,(this.rect.yTop+this.rect.yBot-e.height)/2),s.yBot=Math.min(this.rect.yBot-t.margins.bot,(this.rect.yTop+this.rect.yBot+e.height)/2);break;case T.VerticalAlign.Bottom:s.yTop=Math.max(this.rect.yTop+t.margins.top,this.rect.yBot-t.margins.bot-e.height),s.yBot=this.rect.yBot-t.margins.bot;break}else s.yTop=t.rect.yTop||this.rect.yTop,s.yBot=t.rect.yBot||this.rect.yBot;return s}drawText(t){t=o.clone(t),typeof t.isBold>"u"&&(t.isBold=!1);const e=o.getPatchedTextStyle(this.controller,{fontStyle:t.isBold?"bold":"normal",fontSize:t.fontSize,fontName:this.controller.fontName,fontColor:"#404040"}),s=this.controller.measureText(t.text,e),i=this.alignRect(t,s);this.packs.push(new zt(this.controller,i,t,e))}async drawImage(t){t=o.clone(t),typeof t.width>"u"&&(t.width=this.rect.xRight-this.rect.xLeft),typeof t.height>"u"&&(t.height=this.rect.yBot-this.rect.yTop);const e={width:t.width,height:t.height},s=this.alignRect(t,e);this.controller.pushMargins(0,0),this.packs.push(await o.createImageFlat(o.createPoint(s,!0,!0),null,this.controller,{link:t.base64,width:s.xRight-s.xLeft,height:s.yBot-s.yTop,objectFit:t.imageFit},!!t.imageFit||this.controller.applyImageFit)),this.controller.popMargins()}}class xs{constructor(t,e,s){this.survey=t,this.controller=e,this.style=s}getTextStyle(){return this.style.text}getLinkStyle(){var t;return o.mergeObjects({},this.getTextStyle(),(t=this.style.link)!==null&&t!==void 0?t:{})}getLicenseParts(t){const e=/\[([^\]]+)\]\(([^)]+)\)|([^\[]+)/g,s=[];let i;for(;(i=e.exec(t))!==null;)i[1]&&i[2]?s.push({text:i[1],isLink:!0,url:i[2]}):i[3]&&s.push({text:i[3]});return s}splitPartsToFit(t,e){const s=[];let i=[],n=0;for(const r of t){const a=r.text.split(/(\s+)/);for(const l of a){if(l==="")continue;const u=this.controller.measureText(l,this.getTextStyle()).width;n+u>e&&i.length>0&&(s.push(i),i=[],n=0),i.push({...r,text:l}),n+=u}}return i.length>0&&s.push(i),s.map(r=>{let h;const a=[];for(const l of r)!h||!(h.isLink===l.isLink&&(!h.isLink||l.isLink&&h.url===l.url))?(h=l,a.push(l)):h.text+=l.text;return a[a.length-1].text=a[a.length-1].text.trimEnd(),a})}generateLicenseFlats(t,e,s){const i=new W,n=o.clone(t);for(const r of e){const h=new W;for(const a of r){const l=this.controller.measureText(a.text,this.getTextStyle());let u;a.isLink?u=new Wt(this.controller,o.createRect(n,l.width,l.height),{text:a.text,link:a.url,readOnlyShowLink:!1},this.getLinkStyle()):u=new zt(this.controller,o.createRect(n,l.width,l.height),{text:a.text},this.getTextStyle()),h.addBrick(u),n.xLeft+=l.width}this.centerLineBrick(h,t.xLeft,s+t.xLeft),i.addBrick(h),n.yTop+=h.height}return[i]}centerLineBrick(t,e,s){const i=(s+e-t.xRight-t.xLeft)/2;t.translateX((n,r)=>({xLeft:n+i,xRight:r+i}))}generateFlats(t){if(this.survey.haveCommercialLicense)return[];const e=this.survey.licenseText,s=o.getPageAvailableWidth(this.controller),i=this.getLicenseParts(e),n=this.splitPartsToFit(i,s);return this.generateLicenseFlats(t,n,s)}}let Te;function vs(m){Te=m}function Ce(){return Te()}function Qt(m,t,e){const s=Ce(),i=Ce();s.setup(m.cssVariables),i.setup(t),s.startCollectingVariables(),i.startCollectingVariables();const n=e({getColorVariable:r=>s.getColorVariable(r),getSizeVariable:r=>i.getSizeVariable(r)});return s.stopCollectingVariables(),i.stopCollectingVariables(),n}function bs(m,t){return Qt(m,t,({getSizeVariable:e,getColorVariable:s})=>{const i=e("--sjs2-base-unit-size"),n=e("--sjs2-base-unit-font-size"),r=e("--sjs2-base-unit-spacing");return{survey:{title:{fontSize:e("--sjs2-typography-font-size-large"),lineHeight:e("--sjs2-typography-line-height-large"),fontStyle:"bold",fontColor:s("--sjs2-color-fg-basic-primary")},description:{fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),fontStyle:"normal",fontColor:s("--sjs2-color-fg-basic-secondary")},spacing:{titleDescriptionGap:e("--sjs2-pdf-layout-title-large-gap"),pageGap:r*3,headerContentGap:e("--sjs2-pdf-layout-page-gap-vertical")+e("--sjs2-pdf-layout-title-large-padding-bottom")},backgroundColor:s("--sjs2-color-utility-body"),padding:[e("--sjs2-pdf-layout-page-padding-top"),e("--sjs2-pdf-layout-page-padding-right"),e("--sjs2-pdf-layout-page-padding-bottom"),e("--sjs2-pdf-layout-page-padding-left")]},question:{minWidth:i*25,inlineHeaderWidthPercentage:Math.E/10,container:{padding:[e("--sjs2-pdf-layout-question-padding-vertical"),e("--sjs2-pdf-layout-question-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-question"),borderWidth:e("--sjs2-pdf-border-width-question"),borderColor:s("--sjs2-color-border-basic-secondary"),backgroundColor:s("--sjs2-color-bg-basic-primary")},title:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small"),fontStyle:"normal"},description:{fontColor:s("--sjs2-color-fg-basic-secondary"),fontSize:e("--sjs2-typography-font-size-small"),fontStyle:"normal",lineHeight:e("--sjs2-typography-line-height-small")},comment:{fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),fontColor:s("--sjs2-color-component-input-default-value"),backgroundColor:s("--sjs2-color-component-formbox-default-bg")},commentReadOnly:{backgroundColor:null,fontColor:s("--sjs2-color-fg-basic-primary")},input:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default")},commentLabel:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),fontStyle:"normal",lineHeight:e("--sjs2-typography-line-height-default")},spacing:{headerContentGap:e("--sjs2-pdf-layout-question-gap"),inlineHeaderContentGap:r,contentIndentStart:0,contentCommentGap:e("--sjs2-pdf-layout-question-gap"),contentDescriptionGap:e("--sjs2-pdf-layout-question-gap"),titleDescriptionGap:e("--sjs2-pdf-layout-question-labels-gap-vertical"),titleRequiredMarkGap:n/2,titleNumberGap:n/2,commentLabelGap:e("--sjs2-spacing-x050")}},panel:{minWidth:i*75,header:{padding:[e("--sjs2-pdf-layout-section-padding-vertical"),e("--sjs2-pdf-layout-section-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-section"),backgroundColor:s("--sjs2-color-bg-basic-secondary"),borderWidth:e("--sjs2-pdf-border-width-section"),borderColor:s("--sjs2-color-border-basic-secondary")},title:{fontSize:e("--sjs2-typography-font-size-default"),fontColor:s("--sjs2-color-fg-basic-primary"),fontStyle:"bold",lineHeight:e("--sjs2-typography-line-height-default")},description:{fontColor:s("--sjs2-color-fg-basic-secondary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small")},spacing:{elementGap:e("--sjs2-pdf-layout-page-questions-gap-vertical"),inlineElementGap:e("--sjs2-pdf-layout-page-questions-gap-horizontal"),headerContentGap:e("--sjs2-pdf-layout-page-questions-gap-vertical"),titleDescriptionGap:e("--sjs2-pdf-layout-title-default-gap")}},page:{header:{borderWidth:0,padding:0,backgroundColor:null},title:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-medium"),fontStyle:"bold",lineHeight:e("--sjs2-typography-line-height-medium")},description:{fontColor:s("--sjs2-color-fg-basic-secondary"),fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default")},spacing:{headerContentGap:e("--sjs2-pdf-layout-page-gap-vertical")+e("--sjs2-pdf-layout-title-medium-padding-bottom"),elementGap:e("--sjs2-pdf-layout-page-gap-vertical")}},selectbase:{columnMinWidth:i*20,choiceText:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),fontStyle:"normal",lineHeight:e("--sjs2-typography-line-height-default")},input:{width:e("--sjs2-size-x200"),height:e("--sjs2-size-x200"),fontSize:e("--sjs2-size-x200")*.625,borderColor:s("--sjs2-color-component-checkbox-false-default-border"),borderWidth:e("--sjs2-pdf-border-width-check"),fontName:"zapfdingbats",backgroundColor:s("--sjs2-color-bg-basic-primary"),fontColor:s("--sjs2-color-fg-brand-primary")},inputReadOnly:{fontColor:s("--sjs2-color-component-checkbox-true-default-icon"),backgroundColor:s("--sjs2-color-component-checkbox-false-default-bg")},inputReadOnlyChecked:{borderColor:s("--sjs2-color-component-checkbox-true-default-border"),backgroundColor:s("--sjs2-color-component-checkbox-true-default-bg")},spacing:{choiceColumnGap:e("--sjs2-pdf-layout-question-items-gap-horizontal"),choiceGap:e("--sjs2-pdf-layout-question-items-gap-vertical"),choiceTextGap:e("--sjs2-pdf-layout-check-gap")}},checkbox:{input:{checkMark:"3"},inputReadOnly:{borderRadius:e("--sjs2-pdf-radius-checkbox")}},radiogroup:{input:{checkMark:"l",borderColor:s("--sjs2-color-component-radio-false-default-border")},inputReadOnly:{borderRadius:e("--sjs2-pdf-radius-radio"),fontColor:s("--sjs2-color-component-radio-true-default-icon"),backgroundColor:s("--sjs2-color-component-radio-false-default-bg")},inputReadOnlyChecked:{borderColor:s("--sjs2-color-component-radio-true-default-border"),backgroundColor:s("--sjs2-color-component-radio-true-default-bg")}},matrixbase:{minWidth:i*40,columnMinWidth:i*15,container:{padding:0,borderWidth:0,backgroundColor:null},header:{padding:[e("--sjs2-pdf-layout-section-padding-vertical"),e("--sjs2-pdf-layout-section-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-section"),backgroundColor:s("--sjs2-color-bg-basic-secondary"),borderWidth:e("--sjs2-pdf-border-width-section"),borderColor:s("--sjs2-color-border-basic-secondary")},title:{fontSize:e("--sjs2-typography-font-size-default"),fontColor:s("--sjs2-color-fg-basic-primary"),fontStyle:"bold",lineHeight:e("--sjs2-typography-line-height-default")},description:{fontColor:s("--sjs2-color-fg-basic-secondary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small")},cell:{padding:[e("--sjs2-pdf-layout-question-padding-vertical"),e("--sjs2-pdf-layout-question-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-matrix"),borderWidth:e("--sjs2-pdf-border-width-question"),borderColor:s("--sjs2-color-border-basic-secondary"),backgroundColor:s("--sjs2-color-bg-basic-primary")},rowTitle:{fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),fontColor:s("--sjs2-color-fg-basic-secondary"),fontStyle:"normal",textAlign:"right"},columnTitle:{fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),fontColor:s("--sjs2-color-fg-basic-secondary"),fontStyle:"normal"},listSectionTitle:{textAlign:"left"},spacing:{titleDescriptionGap:e("--sjs2-pdf-layout-title-default-gap"),headerContentGap:e("--sjs2-pdf-layout-page-questions-gap-vertical"),tableColumnGap:e("--sjs2-pdf-layout-page-matrix-gap-horizontal"),tableRowGap:e("--sjs2-pdf-layout-page-matrix-gap-vertical"),listSectionGap:e("--sjs2-pdf-layout-page-questions-gap-vertical"),listItemTitleContentGap:e("--sjs2-pdf-layout-question-gap")}},matrix:{columnMinWidth:i*12,listChoiceText:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),fontStyle:"normal",lineHeight:e("--sjs2-typography-line-height-default")},listSectionTitle:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small"),fontStyle:"normal"},input:{width:e("--sjs2-size-x200"),height:e("--sjs2-size-x200"),fontSize:e("--sjs2-size-x200")*.625,borderColor:s("--sjs2-color-component-checkbox-false-default-border"),borderWidth:e("--sjs2-pdf-border-width-check"),backgroundColor:s("--sjs2-color-bg-basic-primary"),fontColor:s("--sjs2-color-fg-brand-primary"),fontName:"zapfdingbats"},inputReadOnly:{fontColor:s("--sjs2-color-component-checkbox-true-default-icon"),backgroundColor:s("--sjs2-color-component-checkbox-false-default-bg")},inputReadOnlyChecked:{borderColor:s("--sjs2-color-component-checkbox-true-default-border"),backgroundColor:s("--sjs2-color-component-checkbox-true-default-bg")},radioInput:{checkMark:"l",borderColor:s("--sjs2-color-component-radio-false-default-border")},radioInputReadOnly:{borderRadius:e("--sjs2-pdf-radius-radio"),fontColor:s("--sjs2-color-component-radio-true-default-icon"),backgroundColor:s("--sjs2-color-component-radio-false-default-bg")},radioInputReadOnlyChecked:{borderColor:s("--sjs2-color-component-radio-true-default-border"),backgroundColor:s("--sjs2-color-component-radio-true-default-bg")},checkboxInput:{checkMark:"3"},checkboxInputReadOnly:{borderRadius:e("--sjs2-pdf-radius-checkbox")},spacing:{gapBetweenItemText:e("--sjs2-pdf-layout-check-gap"),listChoiceGap:e("--sjs2-pdf-layout-question-items-gap-vertical"),listChoiceTextGap:e("--sjs2-pdf-layout-check-gap")}},matrixdropdownbase:{listItemTitle:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small"),fontStyle:"normal"}},matrixdropdown:{listSectionTitleContainer:{padding:[e("--sjs2-pdf-layout-section-padding-vertical"),e("--sjs2-pdf-layout-section-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-section"),backgroundColor:s("--sjs2-color-bg-basic-secondary"),borderWidth:e("--sjs2-pdf-border-width-section"),borderColor:s("--sjs2-color-border-basic-secondary")},listSectionTitle:{fontSize:e("--sjs2-typography-font-size-default"),fontColor:s("--sjs2-color-fg-basic-primary"),fontStyle:"bold",lineHeight:e("--sjs2-typography-line-height-default")}},multipletext:{itemTitleWidthPercentage:.4,container:{padding:0,borderWidth:0,backgroundColor:null},header:{padding:[e("--sjs2-pdf-layout-section-padding-vertical"),e("--sjs2-pdf-layout-section-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-section"),backgroundColor:s("--sjs2-color-bg-basic-secondary"),borderWidth:e("--sjs2-pdf-border-width-section"),borderColor:s("--sjs2-color-border-basic-secondary")},title:{fontSize:e("--sjs2-typography-font-size-default"),fontColor:s("--sjs2-color-fg-basic-primary"),fontStyle:"bold",lineHeight:e("--sjs2-typography-line-height-default")},description:{fontColor:s("--sjs2-color-fg-basic-secondary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small")},itemTitle:{fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),fontColor:s("--sjs2-color-fg-basic-secondary"),fontStyle:"normal"},itemCell:{padding:[e("--sjs2-pdf-layout-question-padding-vertical"),e("--sjs2-pdf-layout-question-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-matrix"),borderWidth:e("--sjs2-pdf-border-width-question"),borderColor:s("--sjs2-color-border-basic-secondary"),backgroundColor:s("--sjs2-color-bg-basic-primary")},spacing:{titleDescriptionGap:e("--sjs2-pdf-layout-title-default-gap"),headerContentGap:e("--sjs2-pdf-layout-page-questions-gap-vertical"),itemColumnGap:e("--sjs2-pdf-layout-page-matrix-gap-horizontal"),itemGap:e("--sjs2-pdf-layout-page-matrix-gap-vertical"),itemTitleGap:e("--sjs2-pdf-layout-page-matrix-gap-horizontal")}},rating:{choiceMinWidth:e("--sjs2-size-x300"),choiceText:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),fontStyle:"normal",lineHeight:e("--sjs2-typography-line-height-default")},input:{width:e("--sjs2-size-x200"),height:e("--sjs2-size-x200"),fontSize:e("--sjs2-size-x200")*.625,borderColor:s("--sjs2-color-component-radio-false-default-border"),borderWidth:e("--sjs2-pdf-border-width-check"),backgroundColor:s("--sjs2-color-bg-basic-primary"),fontColor:s("--sjs2-color-fg-brand-primary"),fontName:"zapfdingbats",checkMark:"l"},inputReadOnly:{fontColor:s("--sjs2-color-component-radio-true-default-icon"),backgroundColor:s("--sjs2-color-component-radio-false-default-bg"),borderRadius:e("--sjs2-pdf-radius-checkbox")},inputReadOnlyChecked:{borderColor:s("--sjs2-color-component-radio-true-default-border"),backgroundColor:s("--sjs2-color-component-radio-true-default-bg")},spacing:{choiceColumnGap:e("--sjs2-pdf-layout-question-items-gap-horizontal"),choiceGap:e("--sjs2-pdf-layout-question-items-gap-vertical"),choiceTextGap:e("--sjs2-pdf-layout-check-gap")}},ranking:{input:{width:e("--sjs2-size-x200"),height:e("--sjs2-size-x200"),fontSize:e("--sjs2-size-x200")*.625,lineHeight:e("--sjs2-size-x200")*.625,borderColor:s("--sjs2-color-component-checkbox-false-default-border"),borderWidth:e("--sjs2-pdf-border-width-check"),fontName:"helvetica",fontStyle:"normal",fontColor:s("--sjs2-color-fg-basic-primary"),backgroundColor:s("--sjs2-color-component-checkbox-false-default-bg")},selectToRankAreaSeparator:{width:i/7,color:s("--sjs2-color-fg-basic-primary")},choiceText:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),fontStyle:"normal",lineHeight:e("--sjs2-typography-line-height-default")},spacing:{choiceColumnGap:e("--sjs2-pdf-layout-question-items-gap-horizontal"),choiceGap:e("--sjs2-pdf-layout-question-items-gap-vertical"),choiceTextGap:e("--sjs2-pdf-layout-check-gap")}},slider:{input:{fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),backgroundColor:s("--sjs2-color-component-formbox-default-bg"),fontColor:s("--sjs2-color-component-input-default-value")},inputReadOnly:{backgroundColor:null,fontColor:s("--sjs2-color-fg-basic-primary")},rangeSeparator:{width:i*3,height:i*.125,color:s("--sjs2-color-fg-basic-primary")},spacing:{inputRangeGap:r*8}},dropdown:{input:{borderWidth:0,fontName:void 0,fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),fontColor:s("--sjs2-color-component-input-default-value"),backgroundColor:s("--sjs2-color-component-formbox-default-bg")},inputReadOnly:{backgroundColor:null,fontColor:s("--sjs2-color-fg-basic-primary")}},file:{fileItemMinWidth:e("--sjs2-size-x500"),defaultImageFit:"contain",fileName:{fontColor:s("--sjs2-color-fg-note-primary"),fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default")},spacing:{imageFileNameGap:e("--sjs2-pdf-layout-question-items-gap-vertical"),fileItemColumnGap:e("--sjs2-pdf-layout-question-items-gap-horizontal"),fileItemGap:e("--sjs2-pdf-layout-question-items-gap-vertical")}},paneldynamic:{container:{padding:0,borderWidth:0,backgroundColor:null},header:{padding:[e("--sjs2-pdf-layout-section-padding-vertical"),e("--sjs2-pdf-layout-section-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-section"),backgroundColor:s("--sjs2-color-bg-basic-secondary"),borderWidth:e("--sjs2-pdf-border-width-section"),borderColor:s("--sjs2-color-border-basic-secondary")},title:{fontSize:e("--sjs2-typography-font-size-default"),fontColor:s("--sjs2-color-fg-basic-primary"),fontStyle:"bold",lineHeight:e("--sjs2-typography-line-height-default")},description:{fontColor:s("--sjs2-color-fg-basic-secondary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small")},spacing:{headerContentGap:e("--sjs2-pdf-layout-page-questions-gap-vertical"),titleDescriptionGap:e("--sjs2-pdf-layout-title-default-gap"),panelGap:e("--sjs2-pdf-layout-page-questions-gap-vertical")}},boolean:{choiceText:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),fontStyle:"normal",lineHeight:e("--sjs2-typography-line-height-default")},input:{width:e("--sjs2-size-x200"),height:e("--sjs2-size-x200"),fontSize:e("--sjs2-size-x200")*.625,borderColor:s("--sjs2-color-component-checkbox-false-default-border"),borderWidth:e("--sjs2-pdf-border-width-check"),backgroundColor:s("--sjs2-color-bg-basic-primary"),fontColor:s("--sjs2-color-fg-brand-primary"),fontName:"zapfdingbats"},inputReadOnly:{fontColor:s("--sjs2-color-component-checkbox-true-default-icon"),backgroundColor:s("--sjs2-color-component-checkbox-false-default-bg")},inputReadOnlyChecked:{borderColor:s("--sjs2-color-component-checkbox-true-default-border"),backgroundColor:s("--sjs2-color-component-checkbox-true-default-bg")},radioInput:{checkMark:"l",borderColor:s("--sjs2-color-component-radio-false-default-border")},radioInputReadOnly:{borderRadius:e("--sjs2-pdf-radius-radio"),fontColor:s("--sjs2-color-component-radio-true-default-icon"),backgroundColor:s("--sjs2-color-component-radio-false-default-bg")},radioInputReadOnlyChecked:{borderColor:s("--sjs2-color-component-radio-true-default-border"),backgroundColor:s("--sjs2-color-component-radio-true-default-bg")},checkboxInput:{checkMark:"3"},checkboxInputReadOnly:{borderRadius:e("--sjs2-pdf-radius-checkbox")},spacing:{choiceColumnGap:e("--sjs2-pdf-layout-question-items-gap-horizontal"),choiceTextGap:e("--sjs2-pdf-layout-check-gap")}},imagepicker:{imageRatio:4/3,imageMinWidth:i*12.5,imageMaxWidth:i*37.5,inputReadOnly:{borderRadius:e("--sjs2-pdf-radius-checkbox")},radioInput:{checkMark:"l",borderColor:s("--sjs2-color-component-radio-false-default-border")},radioInputReadOnly:{fontColor:s("--sjs2-color-component-radio-true-default-icon"),backgroundColor:s("--sjs2-color-component-radio-false-default-bg")},radioInputReadOnlyChecked:{borderColor:s("--sjs2-color-component-radio-true-default-border"),backgroundColor:s("--sjs2-color-component-radio-true-default-bg")},checkboxInput:{checkMark:"3"},spacing:{imageInputGap:e("--sjs2-pdf-layout-image-picker-items-gap-image-check")}},textbase:{input:{fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default"),backgroundColor:s("--sjs2-color-component-formbox-default-bg"),fontColor:s("--sjs2-color-component-input-default-value")},inputReadOnly:{backgroundColor:null,fontColor:s("--sjs2-color-fg-basic-primary")}},expression:{input:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default")}},html:{text:{fontColor:s("--sjs2-color-fg-basic-primary"),fontSize:e("--sjs2-typography-font-size-default"),lineHeight:e("--sjs2-typography-line-height-default")}},composite:{container:{padding:0,borderWidth:0,backgroundColor:null},header:{padding:[e("--sjs2-pdf-layout-section-padding-vertical"),e("--sjs2-pdf-layout-section-padding-horizontal")],borderRadius:e("--sjs2-pdf-radius-section"),backgroundColor:s("--sjs2-color-bg-basic-secondary"),borderWidth:e("--sjs2-pdf-border-width-section"),borderColor:s("--sjs2-color-border-basic-secondary")},title:{fontSize:e("--sjs2-typography-font-size-default"),fontColor:s("--sjs2-color-fg-basic-primary"),fontStyle:"bold",lineHeight:e("--sjs2-typography-line-height-default")},description:{fontColor:s("--sjs2-color-fg-basic-secondary"),fontSize:e("--sjs2-typography-font-size-small"),lineHeight:e("--sjs2-typography-line-height-small")},spacing:{headerContentGap:e("--sjs2-pdf-layout-page-questions-gap-vertical"),titleDescriptionGap:e("--sjs2-pdf-layout-title-default-gap")}}}})}class ke{static async process_header_events(t,e,s){var i;const n=Qt(t.theme,t.layout,r=>({text:{fontSize:10,lineHeight:12,fontStyle:"normal",fontName:"helvetica",fontColor:r.getColorVariable("--sjs2-color-fg-basic-primary")},link:{fontColor:r.getColorVariable("--sjs2-color-fg-note-primary")}}));if(!t.haveCommercialLicense){const r=new xs(t,e,n).generateFlats({xLeft:(i=e.margins.left)!==null&&i!==void 0?i:0,yTop:5});t.onRenderHeader.add((h,a)=>{a.packs.push(...r)})}for(let r=0;r<s.length;r++)await t.onRenderHeader.fire(t,new re(s[r],e,o.createHeaderRect(e),s.length,r+1)),await t.onRenderFooter.fire(t,new re(s[r],e,o.createFooterRect(e),s.length,r+1))}}var ws={"--sjs2-base-unit-size":"8px","--sjs2-base-unit-spacing":"8px","--sjs2-base-unit-radius":"8px","--sjs2-base-unit-border-width":"1px","--sjs2-base-unit-font-size":"8px","--sjs2-base-unit-line-height":"8px","--sjs2-base-unit-opacity":"1%","--sjs2-base-unit-scale":"1%","--sjs2-scale-x000":"calc(var(--sjs2-base-unit-scale) * 0)","--sjs2-scale-x025":"calc(var(--sjs2-base-unit-scale) * 25)","--sjs2-scale-x050":"calc(var(--sjs2-base-unit-scale) * 50)","--sjs2-scale-x075":"calc(var(--sjs2-base-unit-scale) * 75)","--sjs2-scale-x095":"calc(var(--sjs2-base-unit-scale) * 95)","--sjs2-scale-x098":"calc(var(--sjs2-base-unit-scale) * 98)","--sjs2-scale-x100":"calc(var(--sjs2-base-unit-scale) * 100)","--sjs2-scale-x200":"calc(var(--sjs2-base-unit-scale) * 200)","--sjs2-size-x000":"calc(var(--sjs2-base-unit-size) * 0)","--sjs2-size-x025":"calc(var(--sjs2-base-unit-size) * 0.25)","--sjs2-size-x050":"calc(var(--sjs2-base-unit-size) * 0.50)","--sjs2-size-x075":"calc(var(--sjs2-base-unit-size) * 0.75)","--sjs2-size-x100":"calc(var(--sjs2-base-unit-size) * 1)","--sjs2-size-x125":"calc(var(--sjs2-base-unit-size) * 1.25)","--sjs2-size-x150":"calc(var(--sjs2-base-unit-size) * 1.50)","--sjs2-size-x200":"calc(var(--sjs2-base-unit-size) * 2)","--sjs2-size-x250":"calc(var(--sjs2-base-unit-size) * 2.50)","--sjs2-size-x300":"calc(var(--sjs2-base-unit-size) * 3)","--sjs2-size-x350":"calc(var(--sjs2-base-unit-size) * 3.50)","--sjs2-size-x400":"calc(var(--sjs2-base-unit-size) * 4)","--sjs2-size-x500":"calc(var(--sjs2-base-unit-size) * 5)","--sjs2-size-x600":"calc(var(--sjs2-base-unit-size) * 6)","--sjs2-size-x700":"calc(var(--sjs2-base-unit-size) * 7)","--sjs2-size-x800":"calc(var(--sjs2-base-unit-size) * 8)","--sjs2-size-x900":"calc(var(--sjs2-base-unit-size) * 9)","--sjs2-size-x1000":"calc(var(--sjs2-base-unit-size) * 10)","--sjs2-size-x1100":"calc(var(--sjs2-base-unit-size) * 11)","--sjs2-size-x1200":"calc(var(--sjs2-base-unit-size) * 12)","--sjs2-size-x1300":"calc(var(--sjs2-base-unit-size) * 13)","--sjs2-size-x1400":"calc(var(--sjs2-base-unit-size) * 14)","--sjs2-size-x1500":"calc(var(--sjs2-base-unit-size) * 15)","--sjs2-radius-x000":"calc(var(--sjs2-base-unit-radius) * 0)","--sjs2-radius-x025":"calc(var(--sjs2-base-unit-radius) * 0.25)","--sjs2-radius-x050":"calc(var(--sjs2-base-unit-radius) * 0.50)","--sjs2-radius-x075":"calc(var(--sjs2-base-unit-radius) * 0.75)","--sjs2-radius-x100":"calc(var(--sjs2-base-unit-radius) * 1)","--sjs2-radius-x125":"calc(var(--sjs2-base-unit-radius) * 1.25)","--sjs2-radius-x150":"calc(var(--sjs2-base-unit-radius) * 1.50)","--sjs2-radius-x200":"calc(var(--sjs2-base-unit-radius) * 2)","--sjs2-radius-x250":"calc(var(--sjs2-base-unit-radius) * 2.50)","--sjs2-radius-x300":"calc(var(--sjs2-base-unit-radius) * 3)","--sjs2-radius-x400":"calc(var(--sjs2-base-unit-radius) * 4)","--sjs2-radius-x500":"calc(var(--sjs2-base-unit-radius) * 5)","--sjs2-radius-x600":"calc(var(--sjs2-base-unit-radius) * 6)","--sjs2-radius-x700":"calc(var(--sjs2-base-unit-radius) * 7)","--sjs2-radius-x800":"calc(var(--sjs2-base-unit-radius) * 8)","--sjs2-radius-round":"9999px","--sjs2-spacing-x000":"calc(var(--sjs2-base-unit-spacing) * 0)","--sjs2-spacing-x025":"calc(var(--sjs2-base-unit-spacing) * 0.25)","--sjs2-spacing-x050":"calc(var(--sjs2-base-unit-spacing) * 0.50)","--sjs2-spacing-x075":"calc(var(--sjs2-base-unit-spacing) * 0.75)","--sjs2-spacing-x100":"calc(var(--sjs2-base-unit-spacing) * 1)","--sjs2-spacing-x125":"calc(var(--sjs2-base-unit-spacing) * 1.25)","--sjs2-spacing-x150":"calc(var(--sjs2-base-unit-spacing) * 1.5)","--sjs2-spacing-x200":"calc(var(--sjs2-base-unit-spacing) * 2)","--sjs2-spacing-x250":"calc(var(--sjs2-base-unit-spacing) * 2.50)","--sjs2-spacing-x300":"calc(var(--sjs2-base-unit-spacing) * 3)","--sjs2-spacing-x400":"calc(var(--sjs2-base-unit-spacing) * 4)","--sjs2-spacing-x500":"calc(var(--sjs2-base-unit-spacing) * 5)","--sjs2-spacing-x550":"calc(var(--sjs2-base-unit-spacing) * 5.5)","--sjs2-spacing-x600":"calc(var(--sjs2-base-unit-spacing) * 6)","--sjs2-spacing-x700":"calc(var(--sjs2-base-unit-spacing) * 7)","--sjs2-spacing-x800":"calc(var(--sjs2-base-unit-spacing) * 8)","--sjs2-spacing-negative-x025":"calc(var(--sjs2-base-unit-spacing) * -0.25)","--sjs2-spacing-negative-x050":"calc(var(--sjs2-base-unit-spacing) * -0.50)","--sjs2-spacing-negative-x075":"calc(var(--sjs2-base-unit-spacing) * -0.75)","--sjs2-spacing-negative-x100":"calc(var(--sjs2-base-unit-spacing) * -1)","--sjs2-spacing-negative-x125":"calc(var(--sjs2-base-unit-spacing) * -1.25)","--sjs2-spacing-negative-x150":"calc(var(--sjs2-base-unit-spacing) * -1.5)","--sjs2-spacing-negative-x200":"calc(var(--sjs2-base-unit-spacing) * -2)","--sjs2-spacing-negative-x250":"calc(var(--sjs2-base-unit-spacing) * -2.50)","--sjs2-spacing-negative-x300":"calc(var(--sjs2-base-unit-spacing) * -3)","--sjs2-spacing-negative-x400":"calc(var(--sjs2-base-unit-spacing) * -4)","--sjs2-spacing-negative-x500":"calc(var(--sjs2-base-unit-spacing) * -5)","--sjs2-spacing-negative-x600":"calc(var(--sjs2-base-unit-spacing) * -6)","--sjs2-spacing-negative-x700":"calc(var(--sjs2-base-unit-spacing) * -7)","--sjs2-spacing-negative-x800":"calc(var(--sjs2-base-unit-spacing) * -8)","--sjs2-opacity-x000":"calc(var(--sjs2-base-unit-opacity) * 0)","--sjs2-opacity-x005":"calc(var(--sjs2-base-unit-opacity) * 5)","--sjs2-opacity-x010":"calc(var(--sjs2-base-unit-opacity) * 10)","--sjs2-opacity-x015":"calc(var(--sjs2-base-unit-opacity) * 15)","--sjs2-opacity-x020":"calc(var(--sjs2-base-unit-opacity) * 20)","--sjs2-opacity-x025":"calc(var(--sjs2-base-unit-opacity) * 25)","--sjs2-opacity-x030":"calc(var(--sjs2-base-unit-opacity) * 30)","--sjs2-opacity-x035":"calc(var(--sjs2-base-unit-opacity) * 35)","--sjs2-opacity-x040":"calc(var(--sjs2-base-unit-opacity) * 40)","--sjs2-opacity-x045":"calc(var(--sjs2-base-unit-opacity) * 45)","--sjs2-opacity-x050":"calc(var(--sjs2-base-unit-opacity) * 50)","--sjs2-opacity-x055":"calc(var(--sjs2-base-unit-opacity) * 55)","--sjs2-opacity-x060":"calc(var(--sjs2-base-unit-opacity) * 60)","--sjs2-opacity-x065":"calc(var(--sjs2-base-unit-opacity) * 65)","--sjs2-opacity-x070":"calc(var(--sjs2-base-unit-opacity) * 70)","--sjs2-opacity-x075":"calc(var(--sjs2-base-unit-opacity) * 75)","--sjs2-opacity-x080":"calc(var(--sjs2-base-unit-opacity) * 80)","--sjs2-opacity-x085":"calc(var(--sjs2-base-unit-opacity) * 85)","--sjs2-opacity-x090":"calc(var(--sjs2-base-unit-opacity) * 90)","--sjs2-opacity-x095":"calc(var(--sjs2-base-unit-opacity) * 95)","--sjs2-opacity-x100":"calc(var(--sjs2-base-unit-opacity) * 100)","--sjs2-border-width-x000":"calc(var(--sjs2-base-unit-border-width) * 0)","--sjs2-border-width-x100":"calc(var(--sjs2-base-unit-border-width) * 1)","--sjs2-border-width-x200":"calc(var(--sjs2-base-unit-border-width) * 2)","--sjs2-border-width-x400":"calc(var(--sjs2-base-unit-border-width) * 4)","--sjs2-font-weight-regular":"400","--sjs2-font-weight-medium":"500","--sjs2-font-weight-semibold":"600","--sjs2-font-weight-bold":"700","--sjs2-font-size-x000":"calc(var(--sjs2-base-unit-font-size) * 0)","--sjs2-font-size-x100":"calc(var(--sjs2-base-unit-font-size) * 1)","--sjs2-font-size-x150":"calc(var(--sjs2-base-unit-font-size) * 1.5)","--sjs2-font-size-x200":"calc(var(--sjs2-base-unit-font-size) * 2)","--sjs2-font-size-x250":"calc(var(--sjs2-base-unit-font-size) * 2.5)","--sjs2-font-size-x300":"calc(var(--sjs2-base-unit-font-size) * 3)","--sjs2-font-size-x350":"calc(var(--sjs2-base-unit-font-size) * 3.5)","--sjs2-font-size-x400":"calc(var(--sjs2-base-unit-font-size) * 4)","--sjs2-font-size-x500":"calc(var(--sjs2-base-unit-font-size) * 5)","--sjs2-font-size-x600":"calc(var(--sjs2-base-unit-font-size) * 6)","--sjs2-line-height-x000":"calc(var(--sjs2-base-unit-line-height) * 0)","--sjs2-line-height-x100":"calc(var(--sjs2-base-unit-line-height) * 1)","--sjs2-line-height-x200":"calc(var(--sjs2-base-unit-line-height) * 2)","--sjs2-line-height-x300":"calc(var(--sjs2-base-unit-line-height) * 3)","--sjs2-line-height-x400":"calc(var(--sjs2-base-unit-line-height) * 4)","--sjs2-line-height-x500":"calc(var(--sjs2-base-unit-line-height) * 5)","--sjs2-line-height-x600":"calc(var(--sjs2-base-unit-line-height) * 6)","--sjs2-text-case-default":"none","--sjs2-text-case-uppercase":"uppercase","--sjs2-typography-font-family-text":"Open Sans","--sjs2-typography-font-family-code":"DM Mono","--sjs2-typography-font-family-component-input-content":"var(--sjs2-typography-font-family-text)","--sjs2-typography-font-family-component-question-title":"var(--sjs2-typography-font-family-text)","--sjs2-typography-font-family-component-question-description":"var(--sjs2-typography-font-family-text)","--sjs2-typography-font-family-component-page-title":"var(--sjs2-typography-font-family-text)","--sjs2-typography-font-family-component-page-description":"var(--sjs2-typography-font-family-text)","--sjs2-typography-font-family-component-header-title":"var(--sjs2-typography-font-family-text)","--sjs2-typography-font-family-component-header-description":"var(--sjs2-typography-font-family-text)","--sjs2-typography-font-size-small":"var(--sjs2-font-size-x150)","--sjs2-typography-font-size-default":"var(--sjs2-font-size-x200)","--sjs2-typography-font-size-medium":"var(--sjs2-font-size-x300)","--sjs2-typography-font-size-large":"var(--sjs2-font-size-x400)","--sjs2-typography-font-size-component-input-content":"var(--sjs2-typography-font-size-default)","--sjs2-typography-font-size-component-question-title":"var(--sjs2-typography-font-size-default)","--sjs2-typography-font-size-component-question-description":"var(--sjs2-typography-font-size-default)","--sjs2-typography-font-size-component-page-title":"var(--sjs2-typography-font-size-medium)","--sjs2-typography-font-size-component-page-description":"var(--sjs2-typography-font-size-default)","--sjs2-typography-font-size-component-header-title":"var(--sjs2-typography-font-size-large)","--sjs2-typography-font-size-component-header-description":"var(--sjs2-typography-font-size-medium)","--sjs2-typography-line-height-small":"var(--sjs2-line-height-x200)","--sjs2-typography-line-height-default":"var(--sjs2-line-height-x300)","--sjs2-typography-line-height-medium":"var(--sjs2-line-height-x400)","--sjs2-typography-line-height-large":"var(--sjs2-line-height-x500)","--sjs2-typography-line-height-component-input-content":"var(--sjs2-typography-line-height-default)","--sjs2-typography-line-height-component-question-title":"var(--sjs2-typography-line-height-default)","--sjs2-typography-line-height-component-question-description":"var(--sjs2-typography-line-height-default)","--sjs2-typography-line-height-component-page-title":"var(--sjs2-typography-line-height-medium)","--sjs2-typography-line-height-component-page-description":"var(--sjs2-typography-line-height-default)","--sjs2-typography-line-height-component-header-title":"var(--sjs2-typography-line-height-large)","--sjs2-typography-line-height-component-header-description":"var(--sjs2-typography-line-height-medium)","--sjs2-typography-font-weight-basic":"var(--sjs2-font-weight-regular)","--sjs2-typography-font-weight-strong":"var(--sjs2-font-weight-semibold)","--sjs2-typography-font-weight-component-input-content":"var(--sjs2-typography-font-weight-basic)","--sjs2-typography-font-weight-component-question-title":"var(--sjs2-typography-font-weight-strong)","--sjs2-typography-font-weight-component-question-description":"var(--sjs2-typography-font-weight-basic)","--sjs2-typography-font-weight-component-page-title":"var(--sjs2-typography-font-weight-strong)","--sjs2-typography-font-weight-component-page-description":"var(--sjs2-typography-font-weight-basic)","--sjs2-typography-font-weight-component-header-title":"var(--sjs2-typography-font-weight-strong)","--sjs2-typography-font-weight-component-header-description":"var(--sjs2-typography-font-weight-basic)","--sjs2-is-panelless":"false","--sjs2-pdf-radius-question":"var(--sjs2-radius-x000)","--sjs2-pdf-radius-matrix":"var(--sjs2-radius-x000)","--sjs2-pdf-radius-checkbox":"var(--sjs2-radius-x000)","--sjs2-pdf-radius-radio":"var(--sjs2-radius-round)","--sjs2-pdf-radius-section":"var(--sjs2-radius-x000)","--sjs2-pdf-border-width-section":"var(--sjs2-border-width-x100)","--sjs2-pdf-border-width-question":"var(--sjs2-border-width-x100)","--sjs2-pdf-border-width-check":"var(--sjs2-border-width-x100)","--sjs2-pdf-layout-page-padding-top":"var(--sjs2-spacing-x550)","--sjs2-pdf-layout-page-padding-bottom":"var(--sjs2-spacing-x550)","--sjs2-pdf-layout-page-padding-left":"var(--sjs2-spacing-x550)","--sjs2-pdf-layout-page-padding-right":"var(--sjs2-spacing-x550)","--sjs2-pdf-layout-page-gap-vertical":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-page-gap-horizontal":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-page-questions-gap-horizontal":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-page-questions-gap-vertical":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-page-matrix-gap-horizontal":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-page-matrix-gap-vertical":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-title-large-gap":"var(--sjs2-spacing-x150)","--sjs2-pdf-layout-title-large-padding-bottom":"var(--sjs2-spacing-x400)","--sjs2-pdf-layout-title-medium-gap":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-title-medium-padding-bottom":"var(--sjs2-spacing-x300)","--sjs2-pdf-layout-title-default-gap":"var(--sjs2-spacing-x050)","--sjs2-pdf-layout-title-default-padding-bottom":"var(--sjs2-spacing-x150)","--sjs2-pdf-layout-section-padding-vertical":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-section-padding-horizontal":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-section-gap":"var(--sjs2-spacing-x050)","--sjs2-pdf-layout-check-padding-vertical":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-check-padding-horizontal":"var(--sjs2-spacing-x050)","--sjs2-pdf-layout-check-gap":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-matrix-padding-vertical":"var(--sjs2-spacing-x000)","--sjs2-pdf-layout-matrix-padding-horizontal":"var(--sjs2-spacing-x050)","--sjs2-pdf-layout-matrix-gap":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-question-padding-vertical":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-question-padding-horizontal":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-question-gap":"var(--sjs2-spacing-x100)","--sjs2-pdf-layout-question-labels-gap-vertical":"var(--sjs2-spacing-x050)","--sjs2-pdf-layout-question-items-gap-vertical":"var(--sjs2-spacing-x050)","--sjs2-pdf-layout-question-items-gap-horizontal":"var(--sjs2-spacing-x150)","--sjs2-pdf-layout-image-picker-items-gap-image-check":"var(--sjs2-spacing-x000)"};class Pt extends z.SurveyModel{constructor(t,e){if(super(t),this.legacyLayout={},this.onRenderHeader=new jt,this.onRenderFooter=new jt,this.onRenderQuestion=new jt,this.onRenderPanel=new jt,this.onRenderPage=new jt,this.onDocControllerCreated=new z.EventBase,this.onRenderCheckItemAcroform=new jt,this.onRenderRadioGroupWrapAcroform=new jt,this.onRenderRadioItemAcroform=new jt,this.onGetQuestionStyle=new z.EventBase,this.onGetPanelStyle=new z.EventBase,this.onGetPageStyle=new z.EventBase,this.onGetItemStyle=new z.EventBase,this.stylesHash={},this.navigationMap={},typeof e>"u"&&(e={}),(this.questionsOnPageMode=="inputPerPage"||this.questionsOnPageMode=="questionPerPage")&&(this.questionsOnPageMode="standard"),this.options=o.clone(e),this.options.fontSize!==void 0){const s=`${this.options.fontSize/14*8}px`;o.mergeObjects(this.legacyLayout,{"--sjs2-base-unit-size":s,"--sjs2-base-unit-spacing":s,"--sjs2-base-unit-radius":s,"--sjs2-base-unit-border-width":`${this.options.fontSize/14}px`,"--sjs2-base-unit-font-size":s,"--sjs2-base-unit-line-height":s})}if(this.options.margins)for(const s in this.options.margins)this.options.margins[s]!==void 0&&(this.legacyLayout[`--sjs2-pdf-layout-page-padding-${s=="bot"?"bottom":s}`]=`${96/25.4*this.options.margins[s]}px`);this.applyTheme(z.BaseTheme)}get haveCommercialLicense(){const t=z.hasLicense;return!!t&&t(2)}set haveCommercialLicense(t){console.error("As of v1.9.101, the haveCommercialLicense property is not supported. To activate your license, use the setLicenseKey(key) method as shown on the following page: https://surveyjs.io/remove-alert-banner")}get licenseText(){const t=z.glc?z.glc(2):!1;return t&&t.toLocaleDateString?"This banner appears because your maintenance subscription for the PDF Generator library expired on {date}. You may continue using [all versions released up to that date](https://surveyjs.io/stay-updated/release-notes). To remove this banner in the latest version, please [renew your subscription](https://surveyjs.io/manage#license-manager) and [set up a new license key](https://surveyjs.io/remove-alert-banner).".replace("{date}",t.toLocaleDateString()):"To use the PDF Generator library to create PDF forms such as this one, a [developer license](https://surveyjs.io/licensing) is required. If you have an active license, please [set up your license key](https://surveyjs.io/remove-alert-banner) and ensure you're using the [latest version](https://surveyjs.io/stay-updated/release-notes)."}updateCheckItemAcroformOptions(t,e,s){this.onRenderCheckItemAcroform.fire(this,{options:t,question:e,...s??{}})}getUpdatedRadioGroupWrapOptions(t,e,s){this.onRenderRadioGroupWrapAcroform.fire(this,{options:t,question:e,...s??{}})}updateRadioItemAcroformOptions(t,e,s){this.onRenderRadioItemAcroform.fire(this,{options:t,question:e,...s??{}})}get style(){return this.styleValue||(this.styleValue=bs(this.theme,this.layout)),this.styleValue}clearStyles(){this.styleValue=void 0,this.stylesHash={}}applyStyle(t){typeof t=="function"?this.styleValue=o.mergeObjects({},this.style,Qt(this.theme,this.layout,t)):this.styleValue=o.mergeObjects({},this.style,t),this.stylesHash={}}get theme(){return this._theme||z.BaseTheme}applyTheme(t,e){this._theme=o.mergeObjects({},z.BaseTheme,e??{},t),this.clearStyles()}get defaultLayout(){return this.defaultLayoutValue||(this.defaultLayoutValue=o.mergeObjects({},ws,this.legacyLayout)),this.defaultLayoutValue}get layout(){return this._layout||this.defaultLayout}applyLayout(t,e){this._layout=o.mergeObjects({},this.defaultLayout,e??{},t),this.clearStyles()}getItemStyle(t,e,s){return Qt(this.theme,this.layout,i=>{const n={getColorVariable:i.getColorVariable,getSizeVariable:i.getSizeVariable,style:s};return this.onGetItemStyle.fire(this,{question:t,item:e,...n}),s})}getElementStyle(t){const e=t.uniqueId;if(!this.stylesHash[e]){const s=this.style,i=[t.getType()];let n=z.Serializer.findClass(t.getType());for(;n.parentName;)i.unshift(n.parentName),n=z.Serializer.findClass(n.parentName);t.getTemplate()=="composite"&&i.push("composite");const r={};i.forEach(h=>{var a;o.mergeObjects(r,(a=s[h])!==null&&a!==void 0?a:{})}),this.stylesHash[e]=Qt(this.theme,this.layout,h=>{const a={getColorVariable:h.getColorVariable,getSizeVariable:h.getSizeVariable,style:r};return t.isPanel&&this.onGetPanelStyle.fire(this,{panel:t,...a}),t.isPage&&this.onGetPageStyle.fire(this,{page:t,...a}),t.isQuestion&&this.onGetQuestionStyle.fire(this,{question:t,...a}),r})}return this.stylesHash[e]}correctBricksPosition(t,e){t.isRTL&&e.forEach(s=>{s.forEach(i=>{i.translateX((n,r)=>{const h=t.paperWidth-n-r;return{xLeft:n+h,xRight:r+h}})})})}afterRenderSurveyElement(t,e){e.forEach(s=>s.addBeforeRenderCallback(()=>{var i;s.getPageNumber()!==void 0&&(this.navigationMap[t.uniqueId]=Math.min((i=this.navigationMap[t.uniqueId])!==null&&i!==void 0?i:Number.MAX_VALUE,s.getPageNumber()+1))}))}renderPanelNavigation(t,e,s){const{doc:i}=t;if(!this.navigationMap[e.uniqueId])return;const n=i.outline.add(s,e.title||e.name,{pageNumber:this.navigationMap[e.uniqueId]});e.elements.forEach(r=>{r.isVisible&&this.navigationMap[r.uniqueId]&&(r.isPanel?this.renderPanelNavigation(t,r,n):i.outline.add(n,r.title||r.name,{pageNumber:this.navigationMap[r.uniqueId]}))})}renderNavigation(t){var e;(!((e=this.options.showNavigation)!==null&&e!==void 0)||e)&&(this.visiblePages.forEach(s=>{this.renderPanelNavigation(t,s,null)}),this.navigationMap={})}async renderSurvey(t){this.visiblePages.forEach(i=>i.onFirstRendering());const e=await N.getInstance().createSurvey(this,t,this.style.survey).generateFlats();this.correctBricksPosition(t,e);const s=Dt.pack(e,t);s.forEach((i,n)=>{i.forEach(r=>{r.setPageNumber(n)})}),await ke.process_header_events(this,t,s);for(let i=0;i<s.length;i++){t.getNumberOfPages()===i&&t.addPage(),t.setPage(i),t.setFillColor(this.style.survey.backgroundColor),t.doc.rect(0,0,t.doc.internal.pageSize.getWidth(),t.doc.internal.pageSize.getHeight(),"F"),t.restoreFillColor();for(let n=0;n<s[i].length;n++)await s[i][n].render()}this.renderNavigation(t),o.clear(),this.stylesHash={}}createDocController(){const t=St(this.style.survey.padding),e=o.mergeObjects({},this.options,{margins:t}),s=new xt(e);return this.onDocControllerCreated.fire(this,{controller:s}),s}get docController(){return this.docControllerValue||(this.docControllerValue=this.createDocController()),this.docControllerValue}async save(t="survey_result.pdf"){if(Pt.currentlySaving)Pt.saveQueue.push(()=>{this.save(t)});else{const e=this.docController;Pt.currentlySaving=!0,o.fixFont(e),await this.renderSurvey(e);const s=e.doc.save(t,{returnPromise:!0});return s.then(()=>{Pt.currentlySaving=!1;const i=Pt.saveQueue.shift();i&&i()}),s}}async raw(t){const e=this.createDocController();return this.onDocControllerCreated.fire(this,{controller:e}),o.fixFont(e),await this.renderSurvey(e),e.doc.output(t)}}Pt.currentlySaving=!1,Pt.saveQueue=[];class ae{constructor(t,e,s,i){this.survey=t,this.panel=e,this.controller=s,this.style=i}async generateFlats(t){const e=[],s=o.clone(t);this.controller.pushMargins(),this.controller.margins.left+=this.controller.measureText(this.panel.innerIndent).width,s.xLeft+=this.controller.measureText(this.panel.innerIndent).width,e.push(...await this.generateContentFlats(s)),this.controller.popMargins();const i=new ls(t,e,this.panel,this.controller,N.getInstance());await this.survey.onRenderPanel.fire(this.survey,i);const n=[...i.bricks];return this.survey.afterRenderSurveyElement(this.panel,n),n}async generateContentFlats(t){if(!this.panel.isVisible)return;this.panel.onFirstRendering();const e=[];let s=o.clone(t);const i=new W;if(this.panel.hasDescriptionUnderTitle||this.panel.hasTitle){const r=await this.createHeaderFlats(s);i.addBrick(...r),s.yTop=r[r.length-1].yBot+this.style.spacing.headerContentGap+o.EPSILON}const n=await this.generateRowsFlats(s);return!i.isEmpty&&n.length>0&&i.addBrick(n.shift()),i.isEmpty||e.push(i),e.push(...n),e}async generateTitleFlat(t){const e=new W,s={...this.style.title};let i=o.clone(t);if(this.panel.no){const r=await o.createTextFlat(i,this.controller,this.panel.no,s);e.addBrick(r),i.xLeft=r.xRight+this.controller.measureText(" ").width}const n=await o.createTextFlat(i,this.controller,this.panel.locTitle,s);return e.addBrick(n),e}async createHeaderFlats(t){const e=new At(this.controller,{...t,width:o.getPageAvailableWidth(this.controller)},this.style.header);return await e.setup(async(s,i)=>{let n=o.clone(s);if(this.panel.hasTitle){const h=await this.generateTitleFlat(n);i.push(h),n=o.createPoint(h)}if(this.panel.description){this.panel.title&&(n.yTop+=this.style.spacing.titleDescriptionGap);const h=await o.createTextFlat(n,this.controller,this.panel.locDescription,{...this.style.description});i.push(h),n=o.createPoint(h)}const r=o.createPoint(o.mergeRects(...i));i.push(o.createRowlineFlat(r,this.controller))}),[e]}getRows(t){const e=o.getPageAvailableWidth(t),s=[],i=this.style.spacing.inlineElementGap;return this.panel.rows.forEach(n=>{let r=e+i,h=[];if(!n.visible)return;n.elements.filter(l=>l.isVisible).forEach((l,u)=>{const p=this.survey.getElementStyle(l),v=l.minWidth&&l.minWidth!=="auto"?o.parseWidth(l.minWidth,e,void 0,"px"):p.minWidth,B=l.width?o.parseWidth(l.width,e,void 0,"px"):0,M=o.parseWidth(l.maxWidth?l.maxWidth:"100%",e,void 0,"px"),Z=Math.min(Math.max(v,B),M);r<Z+i&&(s.push(h),r=e-i,h=[]),r-=Z+i,h.push({element:l,width:Z})}),h.length!=0&&s.push(h)}),s.forEach(n=>{const r=n.reduce((u,p)=>u+p.width,0);let h=(e-r-(n.length-1)*i)/n.length,a=[].concat(n),l=h*n.length;for(;a.length>0&&l>0;)a=a.filter(u=>{const p=o.parseWidth(u.element.maxWidth?u.element.maxWidth:"100%",e,void 0,"px");return u.element.width&&n.length>1?!1:p>u.width+h?(l-=h,u.width=u.width+h,!0):(l-=p-u.width,u.width=p,!1)}),h=l/a.length;if(l>0){const u=n.filter(v=>!v.element.maxWidth),p=l/u.length;u.forEach(v=>{v.width+=p})}}),s}getGapBetweenRows(){return this.style.spacing.elementGap}async generateRowsFlats(t){const e=o.clone(t),s=[],i=this.getRows(this.controller);for(const n of i){let r=this.controller.margins.left;const h=[];for(let a=0;a<n.length;a++){const{element:l,width:u}=n[a],p=this.style.spacing.inlineElementGap;this.controller.pushMargins(),this.controller.margins.left=r,this.controller.margins.right=this.controller.paperWidth-this.controller.margins.left-u,e.xLeft=this.controller.margins.left;const v=this.survey.getElementStyle(l),B=new At(this.controller,{...e,width:o.getPageAvailableWidth(this.controller)},v.container);await B.setup(async(M,Z)=>{l instanceof z.PanelModel?Z.push(...await o.generatePanelFlats(this.survey,this.controller,l,M)):(await l.waitForQuestionIsReady(),Z.push(...await o.generateQuestionFlats(this.survey,this.controller,l,M)))}),h.push(B),this.controller.popMargins(),r+=u+p}if(e.xLeft=this.controller.margins.left,h.length!==0){const a=o.mergeRects(...h),l=a.yBot;e.yTop=l,h.forEach(u=>{u.fitToHeight(a.yBot-a.yTop)}),h.forEach(u=>s.push(...u.getBricks())),s.push(o.createRowlineFlat(e,this.controller)),e.xLeft=t.xLeft,e.yTop+=this.getGapBetweenRows(),r=e.xLeft}}return s}}N.registerPanel(ae);class Pe extends ae{async generateTitleFlat(t){return await o.createTextFlat(t,this.controller,this.panel.locTitle,{...this.style.title})}async generateFlats(t){const e=[];e.push(...await this.generateContentFlats(t));const s=new hs(t,e,this.panel,this.controller,N.getInstance());await this.survey.onRenderPage.fire(this.survey,s);const i=[...s.bricks];return this.survey.afterRenderSurveyElement(this.panel,i),i}getGapBetweenRows(){return this.survey.isSinglePage&&this.panel===this.survey.visiblePages[0]?this.survey.style.survey.spacing.pageGap:super.getGapBetweenRows()}}N.registerPage(Pe);class Ut extends pt{constructor(t,e,s,i){super(t,e),this.options=s,this.style=i}async renderInteractive(){var t;const e=new this.controller.AcroFormCheckBox,s=o.createAcroformRect(o.createRectInsideBorders(this.contentRect,(t=this.style.borderWidth)!==null&&t!==void 0?t:0)),{color:i}=o.parseColor(this.style.fontColor);this.style.backgroundColor&&(this.controller.setFillColor(this.style.backgroundColor),this.controller.doc.rect(...s,"F"),this.controller.restoreFillColor());const n={};n.maxFontSize=this.style.fontSize,n.caption=this.style.checkMark,n.textAlign="center",n.fieldName=this.options.fieldName,n.readOnly=this.options.readOnly,n.color=i,n.value=this.options.checked?"On":!1,n.AS=this.options.checked?"/On":"/Off",n.Rect=s,this.controller.doc.addField(e),this.options.updateOptions(n),e.maxFontSize=n.maxFontSize,e.caption=n.caption,e.textAlign=n.textAlign,e.fieldName=n.fieldName,e.readOnly=n.readOnly,e.color=n.color,e.fillColor=[0,0,0],e.value=n.value,e.AS=n.AS,e.Rect=n.Rect,o.renderFlatBorders(this.controller,this.contentRect,this.style)}async renderReadOnly(){if(this.style.backgroundColor){this.controller.setFillColor(this.style.backgroundColor);const{lines:t,point:e}=o.getDocLinesFromShape(o.createRoundedShape(this.contentRect,this.style));this.controller.doc.lines(t,...e,[1,1],"F",!0),this.controller.restoreFillColor()}if(o.renderFlatBorders(this.controller,this.contentRect,this.style),this.options.checked){const t=o.createPoint(this.contentRect,!0,!0),e={fontName:this.style.fontName,fontSize:this.style.fontSize,fontColor:this.style.fontColor},s=this.controller.measureText(this.style.checkMark,e);t.xLeft+=this.contentRect.width/2-s.width/2,t.yTop+=this.contentRect.height/2-s.height/2,await(await o.createTextFlat(t,this.controller,this.style.checkMark,e)).render()}}}class $t{constructor(t,e){this.controller=t,this.options=e}addToPdf(t){this._radioGroup=new this.controller.AcroFormRadioButton;const e={};e.fieldName=this.options.fieldName,e.readOnly=this.options.readOnly,e.color=t,this.options.updateOptions(e),this._radioGroup.fieldName=e.fieldName,this._radioGroup.readOnly=e.readOnly,this._radioGroup.color=e.color,this._radioGroup.value="",this.controller.doc.addField(this._radioGroup)}get radioGroup(){return this._radioGroup}get readOnly(){return this.options.readOnly}get fieldName(){return this.options.fieldName}}class Nt extends pt{constructor(t,e,s,i,n){super(t,e),this.radioGroupWrap=s,this.options=i,this.style=n}async renderInteractive(){var t;const e=o.createAcroformRect(o.createRectInsideBorders(this.contentRect,(t=this.style.borderWidth)!==null&&t!==void 0?t:0)),{color:s}=o.parseColor(this.style.fontColor);this.options.index==0&&this.radioGroupWrap.addToPdf(s),this.style.backgroundColor&&(this.controller.setFillColor(this.style.backgroundColor),this.controller.doc.rect(...e,"F"),this.controller.restoreFillColor());const i={};i.fieldName=this.radioGroupWrap.fieldName+"index"+this.options.index,i.Rect=e,i.color=s,i.multiSelect=!0,i.style=this.controller.doc.AcroForm.Appearance.RadioButton.Circle,i.radioGroup=this.radioGroupWrap.radioGroup,this.options.updateOptions&&this.options.updateOptions(i);let n=this.radioGroupWrap.radioGroup.createOption(i.fieldName);this.options.checked?(i.AS||(n.AS="/"+i.fieldName),this.radioGroupWrap.radioGroup.value||(this.radioGroupWrap.radioGroup.value=i.fieldName)):i.AS||(i.AS="/Off"),n.Rect=i.Rect,n.color=i.color,o.renderFlatBorders(this.controller,this.contentRect,this.style),this.radioGroupWrap.radioGroup.setAppearance(i.style)}async renderReadOnly(){if(this.style.backgroundColor){this.controller.setFillColor(this.style.backgroundColor);const{lines:t,point:e}=o.getDocLinesFromShape(o.createRoundedShape(this.contentRect,this.style));this.controller.doc.lines(t,...e,[1,1],"F",!0),this.controller.restoreFillColor()}if(o.renderFlatBorders(this.controller,this.contentRect,this.style),this.options.checked){const t={fontName:this.style.fontName,fontSize:this.style.fontSize,fontColor:this.style.fontColor,lineHeight:this.style.lineHeight},e=o.createPoint(this.contentRect,!0,!0),s=this.controller.measureText(this.style.checkMark,t);e.xLeft+=this.contentRect.width/2-s.width/2,e.yTop+=this.contentRect.height/2-s.height/2,await(await o.createTextFlat(e,this.controller,this.style.checkMark,t)).render()}}}class Be extends tt{getInputStyle(t,e){const s=o.mergeObjects({},this.style.input,this.style.checkboxInput);return t&&(o.mergeObjects(s,this.style.inputReadOnly,this.style.checkboxInputReadOnly),e&&o.mergeObjects(s,this.style.inputReadOnlyChecked,this.style.checkboxInputReadOnlyChecked)),s}async generateFlatsContent(t){const e=new W,s=this.question.isReadOnly,i=s&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,n=o.getPatchedTextStyle(this.controller,this.getInputStyle(s,this.question.booleanValue)),r=new Ut(this.controller,o.createRect(t,n.width,n.height),{fieldName:this.question.id,readOnly:s,updateOptions:h=>this.survey.updateCheckItemAcroformOptions(h,this.question),shouldRenderReadOnly:i,checked:this.question.booleanValue},n);if(e.addBrick(r),this.question.isLabelRendered){const h=new W,a=o.clone(t);a.xLeft=r.xRight+this.style.spacing.choiceTextGap;const l=this.question.locTitle;if(l!==null&&l.renderedHtml!==null&&h.addBrick(await o.createTextFlat(a,this.controller,l,this.style.choiceText)),this.question.isRequired){const u=this.question.requiredText,p=o.mergeObjects({},this.style.choiceText,this.style.requiredMark);if(o.hasHtml(this.question.locTitle)){const v=o.createPoint(h.unfold()[0],!1,!1);v.xLeft+=this.style.spacing.titleRequiredMarkGap,this.controller.pushMargins(),this.controller.margins.right=this.controller.paperWidth-this.controller.margins.left-this.controller.measureText(u,p).width,h.addBrick(await o.createHTMLFlat(v,this.controller,o.createHtmlContainerBlock(u,this.controller,p))),this.controller.popMargins()}else{const v=o.createPoint(h.unfold().pop(),!1,!0);v.xLeft+=this.style.spacing.titleRequiredMarkGap,h.addBrick(await o.createTextFlat(v,this.controller,u,p))}}o.alignVerticallyBricks("center",r,h.unfold()[0]),h.updateRect(),e.addBrick(h)}return[e]}}class Rs extends tt{getInputStyle(t,e){const s=o.mergeObjects({},this.style.input,this.style.radioInput);return t&&(o.mergeObjects(s,this.style.inputReadOnly,this.style.radioInputReadOnly),e&&o.mergeObjects(s,this.style.inputReadOnlyChecked,this.style.radioInputReadOnlyChecked)),s}get radioGroupWrap(){return this._radioGroupWrap||(this._radioGroupWrap=new $t(this.controller,{readOnly:this.question.isReadOnly,fieldName:this.question.id,updateOptions:t=>{this.survey.getUpdatedRadioGroupWrapOptions(t,this.question)}})),this._radioGroupWrap}generateFlatItem(t,e,s){const i=this.question.value==e.value,n=this.radioGroupWrap.readOnly&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,r=o.getPatchedTextStyle(this.controller,this.getInputStyle(n,i)),h=o.createRect(t,r.width,r.height);return new Nt(this.controller,h,this.radioGroupWrap,{index:s,checked:i,shouldRenderReadOnly:n},r)}async generateFlatComposite(t,e,s){const i=new W,n=this.style.choiceText,r=this.generateFlatItem(t,e,s);i.addBrick(r);const h=o.clone(t);if(h.xLeft=r.xRight+this.style.spacing.choiceTextGap,e.locText.renderedHtml!==null){const a=await o.createTextFlat(h,this.controller,e.locText,n);o.alignVerticallyBricks("center",r,a.unfold()[0]),a.updateRect(),i.addBrick(a)}return i}async generateFlatsContent(t){const e=o.clone(t),s=new W,i=[{locText:this.question.locLabelFalse,value:this.question.valueFalse!==void 0?this.question.valueFalse:!1},{locText:this.question.locLabelTrue,value:this.question.valueTrue!==void 0?this.question.valueTrue:!0}];let n=0;for(let h of i){this.controller.pushMargins(),o.setColumnMargins(this.controller,2,n,this.style.spacing.choiceColumnGap),e.xLeft=this.controller.margins.left;const a=await this.generateFlatComposite(e,h,n);s.addBrick(a),this.controller.popMargins(),n++}const r=o.createRowlineFlat(o.createPoint(s),this.controller);return[s,r]}}N.getInstance().register("boolean",Rs),N.getInstance().register("boolean-checkbox",Be);class le extends tt{constructor(){super(...arguments),this.generateVerticallyItems=async(t,e,s)=>{const i=o.clone(t),n=[];for(let r=0;r<e.length;r++){const h=await this.generateFlatComposite(i,e[r],r);i.yTop=h.yBot+(s||this.style.spacing.choiceGap),n.push(h)}return n}}async generateItemComment(t,e){const s=o.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),i=o.getPatchedTextStyle(this.controller,o.mergeObjects({},this.style.comment,s?this.style.commentReadOnly:void 0)),n=this.question.getCommentTextAreaModel(e);return await o.createCommentFlat(t,this.controller,{shouldRenderReadOnly:s,fieldName:n.id,rows:this.controller.otherRowsCount,value:n.getTextValue(),shouldRenderBorders:z.settings.readOnlyCommentRenderMode==="textarea",isReadOnly:this.question.isReadOnly,isMultiline:!0},i)}getItemStyle(t){const e=this.question.isItemSelected(t),s=this.question.isReadOnly||!t.isEnabled&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,i={input:o.mergeObjects({},this.style.input,s?this.style.inputReadOnly:{},s&&e?this.style.inputReadOnlyChecked:{}),choiceText:{...this.style.choiceText}};return this.survey.getItemStyle(this.question,t,i)}async generateFlatComposite(t,e,s){const i=new W,n=this.getItemStyle(e),r=this.generateFlatItem(t,e,s,n.input);i.addBrick(r);const h=o.clone(t);if(h.xLeft=r.xRight+this.style.spacing.choiceTextGap,e.locText.renderedHtml!==null){const a=await o.createTextFlat(h,this.controller,e.locText,{...n.choiceText});o.alignVerticallyBricks("center",r,a.unfold()[0]),a.updateRect(),i.addBrick(a)}if(e.isCommentShowing){const a=o.createPoint(i,!0,!1);a.yTop+=this.style.spacing.choiceGap,i.addBrick(await this.generateItemComment(a,e))}return i}getVisibleChoices(){return this.question.visibleChoices}async generateFlatsContent(t){const e=this.question.colCount,s=this.getVisibleChoices();let i=e;if(e==0)i=Math.floor(o.getPageAvailableWidth(this.controller)/this.style.columnMinWidth)||1,s.length<i&&(i=s.length);else if(e>1&&(i=o.getColumnWidth(this.controller,e,this.style.spacing.choiceColumnGap)<this.style.columnMinWidth?1:e,i==e))return await this.generateColumns(t);return i==1?await this.generateVerticallyItems(t,s):await this.generateHorisontallyItems(t,i)}async generateRows(t,e){var s;const i=this.getVisibleChoices(),n=o.clone(t),r=((s=e[0])!==null&&s!==void 0?s:[]).length,h=[];for(let a of e){const l=new W;for(let p=0;p<a.length;p++){const v=a[p];this.controller.pushMargins(),o.setColumnMargins(this.controller,r,p,this.style.spacing.choiceColumnGap),n.xLeft=this.controller.margins.left;const B=await this.generateFlatComposite(n,v,i.indexOf(v));l.addBrick(B),this.controller.popMargins()}const u=o.createRowlineFlat(o.createPoint(l),this.controller);n.yTop=u.yBot+this.style.spacing.choiceGap,h.push(l,u)}return h}async generateColumns(t){const e=this.question.columns,s=e.reduce((n,r)=>Math.max(n,r.length),0),i=[];for(let n=0;n<s;n++){const r=[];for(let h of e)h[n]&&r.push(h[n]);i.push(r)}return await this.generateRows(t,i)}async generateHorisontallyItems(t,e){const s=[];return this.getVisibleChoices().forEach((n,r)=>{const h=Math.floor(r/e),a=r%e;s[h]||(s[h]=[]),s[h][a]=n}),await this.generateRows(t,s)}}class he extends le{generateFlatItem(t,e,s,i){const n=o.createRect(t,i.width,i.height),r=this.question.isReadOnly||!e.isEnabled,h=r&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress;return new Ut(this.controller,n,{shouldRenderReadOnly:h,readOnly:r,checked:this.question.isItemSelected(e),fieldName:this.question.id+"index"+s,updateOptions:a=>{this.survey.updateCheckItemAcroformOptions(a,this.question,{item:e})}},o.getPatchedTextStyle(this.controller,{...i}))}async generateFlats(t){const e=this.question.maxSelectedChoices;this.question.maxSelectedChoices=0;const s=await super.generateFlats(t);return this.question.maxSelectedChoices=e,s}}class Fs extends he{getVisibleChoices(){return this.controller.tagboxSelectedChoicesOnly?this.question.selectedChoices:super.getVisibleChoices()}}N.getInstance().register("tagbox",Fs),N.getInstance().register("checkbox",he);class Le extends tt{async generateFlatsContent(t){return N.getInstance().create(this.survey,this.question,this.controller,this.survey.getElementStyle(this.question),this.question.getType()).generateFlatsContent(t)}}N.getInstance().register("custom_model",Le);class Ie extends tt{async generateFlatsContent(t){const e=o.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),s=o.getPatchedTextStyle(this.controller,o.mergeObjects({},this.style.input,e?this.style.inputReadOnly:void 0));return[await o.createCommentFlat(t,this.controller,{shouldRenderReadOnly:e,rows:this.question.rows,isReadOnly:this.question.isReadOnly,isMultiline:!0,fieldName:this.question.id,placeholder:o.getLocString(this.question.locPlaceHolder),shouldRenderBorders:z.settings.readOnlyCommentRenderMode==="textarea",value:this.question.value},o.getPatchedTextStyle(this.controller,s))]}}N.getInstance().register("comment",Ie);class Me extends pt{constructor(t,e,s,i){super(t,e),this.controller=t,this.options=s,this.style=i}async renderInteractive(){var t;const{color:e}=o.parseColor(this.style.fontColor),{color:s}=o.parseColor(this.style.backgroundColor),i=new this.controller.AcroFormComboBox;i.backgroundColor=s,i.fieldName=this.options.fieldName,i.Rect=o.createAcroformRect(o.createRectInsideBorders(this.contentRect,(t=this.style.borderWidth)!==null&&t!==void 0?t:0)),i.edit=!1,i.color=e;const n=[];this.options.showOptionsCaption&&n.push(this.getCorrectedText(this.options.optionsCaption)),this.options.items.forEach(r=>{n.push(this.getCorrectedText(r))}),i.setOptions(n),i.fontName=this.style.fontName,i.fontSize=this.style.fontSize,i.readOnly=this.options.isReadOnly,i.isUnicode=o.isCustomFont(this.controller,i.fontName),i.V=this.getCorrectedText(this.options.value),this.controller.doc.addField(i),o.renderFlatBorders(this.controller,this.contentRect,this.style)}}class Se extends tt{async generateItemComment(t){const e=this.question.getCommentTextAreaModel(this.question.selectedItem),s=o.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),i=o.getPatchedTextStyle(this.controller,o.mergeObjects({},this.style.comment,s?this.style.commentReadOnly:void 0));return await o.createCommentFlat(t,this.controller,{shouldRenderReadOnly:s,fieldName:e.id,rows:this.controller.otherRowsCount,value:e.getTextValue(),shouldRenderBorders:z.settings.readOnlyCommentRenderMode==="textarea",isReadOnly:this.question.isReadOnly,isMultiline:!0},o.getPatchedTextStyle(this.controller,i))}async generateFlatsContent(t){const e=o.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),s=o.getPatchedTextStyle(this.controller,o.mergeObjects({},this.style.input,e?this.style.inputReadOnly:void 0)),i=e?await o.createCommentFlat(t,this.controller,{fieldName:this.question.id,shouldRenderReadOnly:e,shouldRenderBorders:z.settings.readOnlyTextRenderMode==="input",value:this.question.readOnlyText||"",isReadOnly:this.question.isReadOnly,placeholder:o.getLocString(this.question.locPlaceholder)},s):new Me(this.controller,o.createTextFieldRect(t,this.controller,1,s.lineHeight),{fieldName:this.question.id,value:this.question.readOnlyText,isReadOnly:this.question.isReadOnly,optionsCaption:this.question.optionsCaption,showOptionsCaption:this.question.showOptionsCaption,items:this.question.visibleChoices.map(r=>o.getLocString(r.locText))},s),n=new W(i);if(this.question.isShowingChoiceComment){const r=o.createPoint(n);r.yTop+=this.style.spacing.contentCommentGap,n.addBrick(await this.generateItemComment(r))}return[n]}}N.getInstance().register("dropdown",Se);class Ae extends tt{async generateFlatsContent(t){return[await o.createCommentFlat(t,this.controller,{value:this.question.displayValue,isReadOnly:!0,shouldRenderReadOnly:o.shouldRenderReadOnly(this.question,this.controller,!0),fieldName:this.question.id,shouldRenderBorders:z.settings.readOnlyTextRenderMode==="input"},o.getPatchedTextStyle(this.controller,this.style.input))]}}N.getInstance().register("expression",Ae);class qe extends tt{async generateFlatItem(t,e){const s=new W(await o.createLinkFlat(t,this.controller,{text:e.name===void 0?"image":e.name,link:typeof e.content=="string"?e.content:"",readOnlyShowLink:o.getReadonlyRenderAs(this.question,this.controller)==="text",shouldRenderReadOnly:o.shouldRenderReadOnly(this.question,this.controller)},{...this.style.fileName}));if(this.question.canPreviewImage(e)){const i=o.createPoint(s);i.yTop+=this.style.spacing.imageFileNameGap,s.addBrick(await o.createImageFlat(i,this.question,this.controller,{link:e.content,width:e.imageSize.width,height:e.imageSize.height,objectFit:this.style.defaultImageFit}))}return s}addLine(t,e,s,i){s!==i.length-1&&(t[t.length-1].addBrick(o.createRowlineFlat(e,this.controller)),e.yTop+=o.EPSILON,t.push(new W))}async getImagePreviewContentWidth(t){return Math.max(t.imageSize.width,this.style.fileItemMinWidth)}async generateFlatsContent(t){const e=this.question.showPreview?this.question.previewValue:this.question.value;if(!e||e.length===0)return[await o.createTextFlat(t,this.controller,this.question.noFileChosenCaption)];const s=[new W],i=o.clone(t);let n=i.yTop;for(let r=0;r<e.length;r++){let h={...e[r]};const a=this.question.canPreviewImage(h);a&&(h.imageSize=await o.getCorrectedImageSize(this.controller,{imageWidth:this.question.imageWidth,imageHeight:this.question.imageHeight,imageLink:e[r].content,defaultImageWidth:200,defaultImageHeight:150}));const l=this.controller.paperWidth-this.controller.margins.right-i.xLeft;if(a){const u=await this.getImagePreviewContentWidth(h);l<u&&(i.xLeft=t.xLeft,i.yTop=n+this.style.spacing.fileItemGap,this.addLine(s,i,r,e)),this.controller.pushMargins(i.xLeft,this.controller.paperWidth-i.xLeft-u);const p=await this.generateFlatItem(i,h);s[s.length-1].addBrick(p),i.xLeft+=p.width,n=Math.max(n,p.yBot),this.controller.popMargins()}else{l<this.controller.unitWidth&&(i.xLeft=t.xLeft,i.yTop=n+this.style.spacing.fileItemGap,this.addLine(s,i,r,e));const u=await this.generateFlatItem(i,h);s[s.length-1].addBrick(u),i.xLeft+=u.xRight-u.xLeft,n=Math.max(n,u.yBot)}i.xLeft+=this.style.spacing.fileItemColumnGap}return s}}N.getInstance().register("file",qe);class Oe extends tt{chooseRender(t){return/<[^>]*style[^<]*>/.test(t)||/<[^>]*table[^<]*>/.test(t)||/&\w+;/.test(t)?"image":"standard"}get correctHtmlRules(){const t=[{searchRegExp:/(<\/?br\s*?\/?\s*?>\s*){2,}/g,replaceString:"<br>"}];return this.controller.fontName=="helvetica"&&(t.push({searchRegExp:/’/g,replaceString:"'"}),t.push({searchRegExp:/—/g,replaceString:"-"})),t}correctHtml(t){return this.correctHtmlRules.forEach(e=>{t=t.replace(e.searchRegExp,e.replaceString)}),t}async generateFlatsContent(t){let e=this.question.renderAs;if(!o.hasDocument)return[new Tt(this.controller,o.createRect(t,0,0))];e==="auto"&&(e=this.controller.htmlRenderAs),e==="auto"&&(e=this.chooseRender(o.getLocString(this.question.locHtml)));const s=o.createHtmlContainerBlock(o.getLocString(this.question.locHtml),this.controller,this.style.text);if(e==="image"){const i=o.getPageAvailableWidth(this.controller),{url:n,aspect:r}=await o.htmlToImage(s,i,this.controller),h=i/r;return[await o.createImageFlat(t,this.question,this.controller,{link:n,width:i,height:h})]}return[o.splitHtmlRect(this.controller,await o.createHTMLFlat(t,this.controller,this.correctHtml(s),this.style.text))]}}z.Serializer.removeProperty("html","renderAs"),z.Serializer.addProperty("html",{name:"renderAs",default:"auto",visible:!1,choices:["auto","standard","image"]}),N.getInstance().register("html",Oe);class _e extends tt{async getCorrectImageSize(){return await o.getCorrectedImageSize(this.controller,{imageWidth:this.question.imageWidth,imageHeight:this.question.imageHeight,imageLink:this.question.imageLink})}async generateFlatsContent(t){const e=await this.getCorrectImageSize();return[await o.createImageFlat(t,this.question,this.controller,{link:this.question.imageLink,width:e.width,height:e.height})]}}N.getInstance().register("image",_e);class We extends tt{get radioGroupWrap(){return this._radioGroupWrap||(this._radioGroupWrap=new $t(this.controller,{readOnly:this.question.isReadOnly,fieldName:this.question.id,updateOptions:t=>{this.survey.getUpdatedRadioGroupWrapOptions(t,this.question)}})),this._radioGroupWrap}getInputStyle(t,e,s){const i=s?"checkbox":"radio",n=o.mergeObjects({},this.style.input,this.style[`${i}Input`]);return t&&(o.mergeObjects(n,this.style.inputReadOnly,this.style[`${i}InputReadOnly`]),e&&o.mergeObjects(n,this.style.inputReadOnlyChecked,this.style[`${i}InputReadOnlyChecked`])),n}async generateFlatItem(t,e,s){const i=o.getPageAvailableWidth(this.controller),n=this.question.isReadOnly||!e.isEnabled,r=this.question.isItemSelected(e),h=n&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,a=o.mergeObjects({},this.getInputStyle(n,r,this.question.multiSelect)),l=await o.createImageFlat(t,this.question,this.controller,{link:e.imageLink,width:i,height:i/this.style.imageRatio}),u=new W(l);let p=o.createPoint(u);if(this.question.showLabel){let M=await o.createTextFlat(p,this.controller,e.text||e.value,{...this.style.choiceText});u.addBrick(M),p=o.createPoint(M)}p.yTop+=this.style.spacing.imageInputGap;const v=a.height,B=o.createRect(p,i,v);return this.question.multiSelect?u.addBrick(new Ut(this.controller,B,{fieldName:this.question.id+"index"+s,readOnly:n,checked:r,shouldRenderReadOnly:h,updateOptions:M=>this.survey.updateCheckItemAcroformOptions(M,this.question,{item:e})},a)):u.addBrick(new Nt(this.controller,B,this.radioGroupWrap,{index:s,checked:r,shouldRenderReadOnly:h,updateOptions:M=>this.survey.updateRadioItemAcroformOptions(M,this.question,{item:e})},a)),u}getColumnsInfo(){const{imageMinWidth:t,imageMaxWidth:e}=this.style,{choiceColumnGap:s}=this.style.spacing,i=o.getPageAvailableWidth(this.controller);let n=this.question.colCount==0?this.question.visibleChoices.length:this.question.colCount,r;const h=()=>Math.max(Math.min((i-s*(n-1))/n,e),1);return t*n+s*(n-1)<i||(n=Math.max(Math.ceil((i+s)/(t+s)),1)),r=h(),{columnsCount:n,columnWidth:r}}async generateFlatsContent(t){const e=[new W],{columnsCount:s,columnWidth:i}=this.getColumnsInfo(),n=Math.ceil(this.question.visibleChoices.length/s),r=o.clone(t);for(let h=0;h<n;h++){let a=r.yTop;this.controller.pushMargins();let l=this.controller.margins.left;for(let u=0;u<s;u++){const p=h*s+u;if(p==this.question.visibleChoices.length)break;this.controller.margins.left=l,this.controller.margins.right=this.controller.paperWidth-l-i,r.xLeft=this.controller.margins.left;const v=await this.generateFlatItem(r,this.question.visibleChoices[p],p);e[e.length-1].addBrick(v),l=this.controller.paperWidth-this.controller.margins.right+this.style.spacing.choiceColumnGap,a=Math.max(a,v.yBot)}this.controller.popMargins(),r.xLeft=t.xLeft,r.yTop=a,h!==n-1&&(e[e.length-1].addBrick(o.createRowlineFlat(r,this.controller)),r.yTop+=this.style.spacing.choiceGap,e.push(new W))}return e}}N.getInstance().register("imagepicker",We);class Ne extends tt{async generateFlatsContent(t){const e=[],s=o.clone(t);for(const i of this.question.panels){const n=await o.generatePanelFlats(this.survey,this.controller,i,s);n.length!==0&&(s.yTop=o.mergeRects(...n).yBot,s.yTop+=this.style.spacing.panelGap,e.push(...n))}return e}}N.getInstance().register("paneldynamic",Ne);class ce extends le{get radioGroupWrap(){return this._radioGroupWrap||(this._radioGroupWrap=new $t(this.controller,{readOnly:this.question.isReadOnly,fieldName:this.question.id,updateOptions:t=>{this.survey.getUpdatedRadioGroupWrapOptions(t,this.question)}})),this._radioGroupWrap}generateFlatItem(t,e,s,i){const n=o.createRect(t,i.width,i.height);return new Nt(this.controller,n,this.radioGroupWrap,{index:s,checked:this.question.isItemSelected(e),shouldRenderReadOnly:this.radioGroupWrap.readOnly&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,updateOptions:r=>this.survey.updateRadioItemAcroformOptions(r,this.question,{item:e})},o.getPatchedTextStyle(this.controller,{...i}))}}N.getInstance().register("radiogroup",ce),N.getInstance().register("buttongroup",ce);class Ee extends pt{constructor(t,e,s,i){super(t,e),this.options=s,this.style=i}async renderInteractive(){var t;const e=o.createRectInsideBorders(this.contentRect,(t=this.style.borderWidth)!==null&&t!==void 0?t:0),s=e.xRight-e.xLeft,i=e.yBot-e.yTop,n=o.createAcroformRect(e);if(this.style.backgroundColor&&(this.controller.setFillColor(this.style.backgroundColor),this.controller.doc.rect(...n,"F"),this.controller.restoreFillColor()),o.renderFlatBorders(this.controller,this.contentRect,this.style),this.options.mark){const r=o.createPoint(e,!0,!0),h={...this.style},a=this.controller.measureText(this.options.mark,h);r.xLeft+=s/2-a.width/2,r.yTop+=i/2-a.height/2,await(await o.createTextFlat(r,this.controller,this.options.mark,h)).render()}else{this.controller.setFillColor(this.style.fontColor);let r=o.createRect(e,this.style.fontSize,this.style.fontSize/7);r=o.moveRect(r,r.xLeft+s/2-(r.xRight-r.xLeft)/2,r.yTop+i/2-(r.yBot-r.yTop)/2),this.controller.doc.rect(...o.createAcroformRect(r),"F"),this.controller.restoreFillColor()}}}class He extends pt{constructor(t,e,s){super(t,e),this.options=s}async renderInteractive(){var t,e;this.controller.setFillColor(this.options.color||"black");const{xLeft:s,yTop:i,width:n,height:r}=this.contentRect;this.controller.doc.rect(s,i,(t=this.options.renderWidth)!==null&&t!==void 0?t:n,(e=this.options.renderHeight)!==null&&e!==void 0?e:r,"F"),this.controller.restoreFillColor()}}class Ge extends tt{async generateFlatComposite(t,e,s,i=!1){const n=new Ee(this.controller,o.createRect(t,this.style.input.width,this.style.input.height),{mark:i?"-":this.question.getNumberByIndex(s)||""},o.getPatchedTextStyle(this.controller,this.style.input)),r=o.clone(t);r.xLeft=n.xRight+this.style.spacing.choiceTextGap;const h=await o.createTextFlat(r,this.controller,e.locText,this.style.choiceText);return o.alignVerticallyBricks("center",n,h.unfold()[0]),new W(n,h)}async generateChoicesColumn(t,e,s=!1){const i=o.clone(t),n=[];for(let r=0;r<e.length;r++){const h=await this.generateFlatComposite(i,e[r],r,s);i.yTop=h.yBot+this.style.spacing.choiceGap,n.push(h)}return n}async generateSelectToRankItemsVertically(t){const e=o.clone(t),s=[];this.question.rankingChoices.length!==0&&(s.push(...await this.generateChoicesColumn(e,this.question.rankingChoices)),e.yTop=s[s.length-1].yBot+2*this.style.spacing.choiceGap);const i=o.createRect({xLeft:e.xLeft,yTop:e.yTop-this.style.spacing.choiceGap-.5},this.controller.paperWidth-this.controller.margins.right-e.xLeft,this.style.selectToRankAreaSeparator.width);return s.push(new He(this.controller,i,{color:this.style.selectToRankAreaSeparator.color})),s.push(...await this.generateChoicesColumn(e,this.question.unRankingChoices,!0)),s}async generateSelectToRankItemsHorizontally(t){const s=o.clone(t),i=[],n=Math.max(this.question.unRankingChoices.length,this.question.rankingChoices.length);let r=new W;for(let h=0;h<n;h++){let a=0;for(let v of[this.question.unRankingChoices[h],this.question.rankingChoices[h]]){if(v){this.controller.pushMargins(this.controller.margins.left,this.controller.margins.right),o.setColumnMargins(this.controller,2,a,this.style.spacing.choiceColumnGap),s.xLeft=this.controller.margins.left;const B=await this.generateFlatComposite(s,v,h,a==0);r.addBrick(B),this.controller.popMargins()}a++}const l=o.createRowlineFlat(o.createPoint(r),this.controller);i.push(r,l);const u=o.createRect({xLeft:this.controller.margins.left+o.getPageAvailableWidth(this.controller)/2-.5,yTop:s.yTop},0,0),p=this.style.spacing.choiceGap;r.addBrick(new He(this.controller,u,{color:this.style.selectToRankAreaSeparator.color,renderWidth:this.style.selectToRankAreaSeparator.width,renderHeight:l.yBot-s.yTop+(h!==n-1?p:0)})),s.yTop=l.yBot+p,r=new W}return i}async generateFlatsContent(t){return this.question.selectToRankEnabled?this.question.selectToRankAreasLayout=="vertical"?this.generateSelectToRankItemsVertically(t):this.generateSelectToRankItemsHorizontally(t):this.generateChoicesColumn(t,this.question.rankingChoices)}}N.getInstance().register("ranking",Ge);class ze extends tt{get radioGroupWrap(){return this._radioGroupWrap||(this._radioGroupWrap=new $t(this.controller,{readOnly:this.question.isReadOnly,fieldName:this.question.id,updateOptions:t=>{this.survey.getUpdatedRadioGroupWrapOptions(t,this.question)}})),this._radioGroupWrap}getItemWidth(t){return Math.min(Math.max(this.controller.measureText(t,{...this.style.choiceText}).width,this.style.choiceMinWidth),o.getPageAvailableWidth(this.controller))}getItemText(t,e){const s=new z.LocalizableString(e.owner,e.useMarkdown);return s.text=o.getLocString(e),t===0&&this.question.minRateDescription?s.text=this.question.locMinRateDescription.text+" "+o.getLocString(e):t===this.question.visibleRateValues.length-1&&this.question.maxRateDescription&&(s.text=o.getLocString(e)+" "+this.question.locMaxRateDescription.text),s}getInputStyle(t,e){const s={...this.style.input};return t&&(o.mergeObjects(s,this.style.inputReadOnly),e&&o.mergeObjects(s,this.style.inputReadOnlyChecked)),s}generateFlatItem(t,e,s){const i=this.question.isItemSelected(e),n=this.radioGroupWrap.readOnly&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress;return new Nt(this.controller,t,this.radioGroupWrap,{index:s,checked:i,shouldRenderReadOnly:n,updateOptions:r=>this.survey.updateRadioItemAcroformOptions(r,this.question,{item:e})},o.getPatchedTextStyle(this.controller,this.getInputStyle(n,i)))}async generateItemComposite(t,e){const s=o.clone(t),i=new W,n=await o.createTextFlat(t,this.controller,e.locText,{...this.style.choiceText});return i.addBrick(n),s.yTop=n.yBot+this.style.spacing.choiceTextGap,i.addBrick(this.generateFlatItem(o.createRect(s,e.width,this.style.input.height),e.item,e.index)),i.translateX((r,h)=>{const a=(i.width-(h-r))/2;return{xLeft:r+a,xRight:h+a}}),i}getRows(){const t=[];let e=0,s=0;const i=o.getPageAvailableWidth(this.controller);let n=i;return this.question.visibleRateValues.forEach((r,h)=>{const a=this.getItemText(h,r.locText),l=this.getItemWidth(a),u={index:h,item:r,locText:a,width:l},p=l+(s==0?0:this.style.spacing.choiceColumnGap);s!==0&&p>n?(e++,n=i-l):n-=p,s++,t.length<=e&&t.push([]),t[e].push(u)}),t}async generateFlatsContent(t){const e=o.clone(t),s=[],i=this.getRows();for(const n of i){const r=new W;for(const h of n)this.controller.pushMargins(),this.controller.margins.left=e.xLeft,this.controller.margins.right=o.getPageAvailableWidth(this.controller)-h.width-e.xLeft,r.addBrick(await this.generateItemComposite(e,h)),this.controller.popMargins(),e.xLeft=r.xRight+this.style.spacing.choiceColumnGap;r.addBrick(o.createRowlineFlat(e,this.controller,r.width)),n!==i[i.length-1]&&(e.yTop=r.yBot+this.style.spacing.choiceGap,e.xLeft=r.xLeft),s.push(r)}return s}}N.getInstance().register("rating",ze);class De extends tt{async generateFlatsContent(t){let e=o.clone(t);if(this.question.sliderType==="single"){const s=this.getOptionsByValue(this.question.value);return[await this.generateInputBrick(e,s)]}if(this.question.sliderType==="range"){const s=new W,i=[];for(let r=0;r<this.question.renderedValue.length;r++){const h=this.question.renderedValue[r],a=this.getOptionsByValue(h.toString()),l=o.clone(t);if(this.controller.pushMargins(),o.setColumnMargins(this.controller,2,r,this.style.spacing.inputRangeGap),l.xLeft=this.controller.margins.left,r>0){const p=o.clone(l);p.xLeft-=this.style.spacing.inputRangeGap-(this.style.spacing.inputRangeGap-this.style.rangeSeparator.width)/2,i.push(new Tt(this.controller,{...p,xRight:p.xLeft+this.style.rangeSeparator.width,yBot:p.yTop+this.style.rangeSeparator.height},this.style.rangeSeparator))}const u=await this.generateInputBrick(l,a);this.controller.popMargins(),i.push(u)}const n=o.mergeRects(...i);return i.forEach(r=>r.translateY((h,a)=>{const l=(n.yBot-n.yTop-a+h)/2;return{yTop:h+l,yBot:a+l}})),s.addBrick(...i),[s]}}getOptionsByValue(t){const{id:e,isReadOnly:s}=this.question;return{fieldName:e,inputType:"number",value:t,isReadOnly:s,shouldRenderReadOnly:o.shouldRenderReadOnly(this.question,this.controller,s),shouldRenderBorders:!0}}async generateInputBrick(t,e){const s=o.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),i=o.getPatchedTextStyle(this.controller,o.mergeObjects({},this.style.input,s?this.style.inputReadOnly:void 0));return await o.createCommentFlat(t,this.controller,{...e,shouldRenderReadOnly:s},i)}}N.getInstance().register("slider",De);class Et extends tt{get signatureSize(){if(!this._signatureSize){let t=o.pxToPt(this.question.signatureWidth),e=o.pxToPt(this.question.signatureHeight);const s=o.getPageAvailableWidth(this.controller);if(t>s){const i=s;e*=i/t,t=i}this._signatureSize={width:t,height:e}}return this._signatureSize}async generateBackgroundImage(t){return await o.createImageFlat(t,this.question,this.controller,{link:this.question.backgroundImage,...this.signatureSize,objectFit:"cover"},!0)}getSignImageUrl(){return this.question.storeDataAsText||!this.question.loadedData?this.question.value:this.question.loadedData}async generateSign(t){let e;return this.question.value?e=await o.createImageFlat(t,this.question,this.controller,{link:this.getSignImageUrl(),...this.signatureSize},!1):e=new Tt(this.controller,o.createRect(t,this.signatureSize.width,this.signatureSize.height)),Et.BORDER_STYLE!=="none"&&(e.afterRenderCallback=()=>{const s={height:e.width,width:e.width,yTop:e.yTop,yBot:e.yBot,xLeft:e.xLeft,xRight:e.xRight};o.renderFlatBorders(this.controller,s,{...this.style.input,dashStyle:Et.BORDER_STYLE=="dashed"?{dashArray:[5],dashPhase:0}:void 0})}),e}async generateFlatsContent(t){const e=new W;return this.question.backgroundImage&&e.addBrick(await this.generateBackgroundImage(t)),e.addBrick(await this.generateSign(t)),[e]}}Et.BORDER_STYLE="dashed",N.getInstance().register("signaturepad",Et);class Yt extends tt{async generateFlatsContent(t){const e=o.shouldRenderReadOnly(this.question,this.controller,this.question.isReadOnly),s=o.getPatchedTextStyle(this.controller,o.mergeObjects({},this.style.input,e?this.style.inputReadOnly:void 0)),i={fieldName:this.question.id,inputType:this.question.inputType,value:this.question.value?this.question.inputValue:"",isReadOnly:this.question.isReadOnly,shouldRenderReadOnly:e,shouldRenderBorders:z.settings.readOnlyTextRenderMode==="input",placeholder:o.getLocString(this.question.locPlaceHolder)||this.question.inputValue};return[await o.createCommentFlat(t,this.controller,{shouldRenderReadOnly:e,rows:Yt.MULTILINE_TEXT_ROWS_COUNT,...i},s)]}}Yt.MULTILINE_TEXT_ROWS_COUNT=1,N.getInstance().register("text",Yt);class Qe{popRowlines(t){for(;t.length>0&&t[t.length-1]instanceof ne;)t.pop()}constructor(t,e,s){this.survey=t,this.controller=e,this.style=s}async generateFlatTitle(t){const e=new W;if(this.survey.showTitle){const s=this.style;if(this.survey.title){const i={...s.title},n=await o.createTextFlat(t,this.controller,this.survey.locTitle,i);e.addBrick(n),t=o.createPoint(n)}this.survey.description&&(this.survey.title&&(t.yTop+=s.spacing.titleDescriptionGap),e.addBrick(await o.createTextFlat(t,this.controller,this.survey.locDescription,{...s.description})))}return e}async generateFlatLogoImage(t){const e=o.getLocString(this.survey.locLogo),s=await o.getCorrectedImageSize(this.controller,{imageLink:e,imageHeight:this.survey.logoHeight,imageWidth:this.survey.logoWidth,defaultImageWidth:"300px",defaultImageHeight:"200px"}),i=await o.createImageFlat(t,null,this.controller,{link:e,width:s.width,height:s.height});let n=0;return this.survey.logoPosition==="right"?n=o.getPageAvailableWidth(this.controller)-i.width:this.survey.logoPosition!=="left"&&(n=o.getPageAvailableWidth(this.controller)/2-i.width/2),i.xLeft+=n,i.xRight+=n,i}async generateFlats(){const t=[],e=new At(this.controller,{...this.controller.leftTopPoint,width:o.getPageAvailableWidth(this.controller)},this.style.header);await e.setup(async(i,n)=>{if(this.survey.hasLogo)if(this.survey.isLogoBefore){const r=await this.generateFlatLogoImage(i);n.push(r);const h=o.createPoint(r,this.survey.logoPosition==="top",this.survey.logoPosition!=="top");this.survey.logoPosition!=="top"?(this.controller.pushMargins(),h.xLeft+=this.controller.unitWidth,this.controller.margins.left+=r.width+this.controller.unitWidth):(h.xLeft=i.xLeft,h.yTop+=this.controller.unitHeight/2);const a=await this.generateFlatTitle(h);this.survey.logoPosition!=="top"&&this.controller.popMargins(),a.isEmpty||n.push(a)}else if(this.survey.logoPosition==="right"){const r=await this.generateFlatLogoImage(i);n.push(r),this.controller.pushMargins(),this.controller.margins.right+=r.width+this.controller.unitWidth;const h=await this.generateFlatTitle(i);h.isEmpty||n.unshift(h),this.controller.popMargins()}else{const r=await this.generateFlatTitle(i);let h=i;r.isEmpty||(n.push(r),h=o.createPoint(r),h.yTop+=this.controller.unitHeight/2);const a=await this.generateFlatLogoImage(h);n.length,n.push(a)}else{const r=await this.generateFlatTitle(i);r.isEmpty||n.push(r)}}),e.isEmpty||t.push(e.getBricks());let s=this.controller.leftTopPoint;t.length!==0&&(s.yTop=o.createPoint(o.mergeRects(...t[0])).yTop,t[0].push(o.createRowlineFlat(s,this.controller)),s.yTop+=this.style.spacing.headerContentGap+o.EPSILON);for(let i=0;i<this.survey.visiblePages.length;i++){this.survey.currentPage=this.survey.visiblePages[i];let n=await o.generatePageFlats(this.survey,this.controller,this.survey.currentPage,s);i===0&&t.length!==0?t[0].push(...n):t.push(n),this.popRowlines(t[t.length-1]),s.yTop=this.controller.leftTopPoint.yTop}return t}}N.registerSurvey(Qe);class Ue extends tt{async generateFlatsContent(t){const e=o.getPageAvailableWidth(this.controller),s=this.question.hasRows?this.question.rowTitleWidth?o.parseWidth(this.question.rowTitleWidth,e):this.style.columnMinWidth:0,i=e-s,n=this.question.renderAs==="list"||this.controller.matrixRenderAs==="list"||this.style.columnMinWidth*this.question.visibleColumns.length+this.style.spacing.tableColumnGap*(this.question.visibleColumns.length-1)>i;return new(n?js:Ts)(this.controller,this.survey,this.question,this.style).generateFlats(t)}}class $e{constructor(t,e,s,i){this.controller=t,this.survey=e,this.question=s,this.style=i,this.radioGroupWraps={}}async generateFlatCell(t,e){const s=new At(this.controller,{...t,width:o.getPageAvailableWidth(this.controller)},this.style.cell);return await s.setup(async(i,n)=>{await e(i,n)}),s}async generateTextComposite(t,e){const{item:s,row:i}=e,n=o.clone(t),r=this.generateFlatItem(n,e);n.yTop=r.yBot+this.style.spacing.gapBetweenItemText;const h=await o.createTextFlat(n,this.controller,this.question.getCellDisplayLocText(i.name,s));return new W(r,h)}getRadioGroupWrap(t,e,s){return this.radioGroupWraps[t]||(this.radioGroupWraps[t]=new $t(this.controller,{readOnly:this.question.isReadOnly,fieldName:t,updateOptions:i=>{this.survey.getUpdatedRadioGroupWrapOptions(i,this.question,{row:e,rowIndex:s})}})),this.radioGroupWraps[t]}getInputStyle(t,e,s){const i=s?"checkbox":"radio",n=o.mergeObjects({},this.style.input,this.style[`${i}Input`]);return t&&(o.mergeObjects(n,this.style.inputReadOnly,this.style[`${i}InputReadOnly`]),e&&o.mergeObjects(n,this.style.inputReadOnlyChecked,this.style[`${i}InputReadOnlyChecked`])),n}generateFlatItem(t,e){const{item:s,row:i,itemIndex:n,rowIndex:r}=e,h=this.question.id+"row"+r,a=i.isChecked(s),l=this.question.isReadOnly,u=l&&o.getReadonlyRenderAs(this.question,this.controller)!=="acroform"||this.controller.compress,p=o.getPatchedTextStyle(this.controller,this.getInputStyle(u,a,this.question.isMultiSelect)),v=o.createRect(t,p.width,p.height);if(this.question.isMultiSelect)return new Ut(this.controller,v,{fieldName:h+"index"+n,checked:a,shouldRenderReadOnly:u,readOnly:l,updateOptions:B=>{this.survey.updateCheckItemAcroformOptions(B,this.question,{item:s,row:i,rowIndex:r})}},p);{const B=this.getRadioGroupWrap(h,i,r);return new Nt(this.controller,v,B,{checked:a,index:n,shouldRenderReadOnly:u,updateOptions:M=>this.survey.updateRadioItemAcroformOptions(M,this.question,{item:s,row:i,rowIndex:r})},p)}}getGapBetweenRows(){return this.style.spacing.tableRowGap}async generateFlats(t){const e=[];let s=o.clone(t);for(let i=0;i<this.question.visibleRows.length;i++){const n=await this.generateFlatsRow(s,this.question.visibleRows[i],i);s=o.createPoint(o.mergeRects(...n)),s.yTop+=this.getGapBetweenRows(),e.push(...n)}return e}}class js extends $e{async generateItemComposite(t,e){const s=o.clone(t),i=this.generateFlatItem(t,e);s.xLeft=i.xRight+this.style.spacing.listChoiceTextGap;const n=await o.createTextFlat(s,this.controller,e.item.locText,o.mergeObjects({},this.style.columnTitle,this.style.listChoiceText));return o.alignVerticallyBricks("center",i,n.unfold()[0]),n.updateRect(),new W(i,n)}getGapBetweenRows(){return this.style.spacing.listSectionGap}async generateFlatsRow(t,e,s){const i=o.clone(t),n=await this.generateFlatCell(i,async(r,h)=>{const a=o.clone(r),l=await o.createTextFlat(r,this.controller,e.locText,o.mergeObjects({},this.style.rowTitle,this.style.listSectionTitle));h.push(l),a.yTop=l.yBot+this.style.spacing.listItemTitleContentGap;for(let u=0;u<this.question.visibleColumns.length;u++){const p=await(this.question.hasCellText?this.generateTextComposite:this.generateItemComposite).call(this,a,{item:this.question.visibleColumns[u],itemIndex:u,row:e,rowIndex:s});h.push(p),a.yTop=p.yBot+this.style.spacing.listChoiceGap}});return[n,o.createRowlineFlat(o.createPoint(n),this.controller)]}}class Ts extends $e{setup(){const t=o.getPageAvailableWidth(this.controller);this.question.rowTitleWidth?this.rowTitleWidth=o.parseWidth(this.question.rowTitleWidth,t):this.rowTitleWidth=o.getColumnWidth(this.controller,this.question.visibleColumns.length+(this.question.hasRows?1:0),this.style.spacing.tableColumnGap),this.controller.pushMargins(),this.controller.margins.left+=this.rowTitleWidth+this.style.spacing.tableColumnGap,this.columnWidth=o.getColumnWidth(this.controller,this.question.visibleColumns.length,this.style.spacing.tableColumnGap),this.controller.popMargins()}async generateFlatsRow(t,e,s){const i=[],n=o.clone(t);this.question.hasRows&&(this.controller.pushMargins(),n.xLeft=this.controller.margins.left,this.controller.margins.right+=o.getPageAvailableWidth(this.controller)-this.rowTitleWidth,i.push(await this.generateFlatCell(n,async(a,l)=>{l.push(await o.createTextFlat(a,this.controller,e.locText,this.style.rowTitle))})),n.xLeft+=this.rowTitleWidth+this.style.spacing.tableColumnGap,this.controller.popMargins());for(let a=0;a<this.question.visibleColumns.length;a++){this.controller.pushMargins(),this.controller.margins.left=t.xLeft;const l={item:this.question.visibleColumns[a],itemIndex:a,rowIndex:s,row:e};this.controller.margins.right+=o.getPageAvailableWidth(this.controller)-this.columnWidth,i.push(await this.generateFlatCell(n,async(u,p)=>{this.question.hasCellText?p.push(await this.generateTextComposite(u,l)):p.push(this.generateFlatItem(u,l))})),n.xLeft+=this.columnWidth+this.style.spacing.tableColumnGap,this.controller.popMargins()}const r=o.mergeRects(...i);i.forEach(a=>{a.fitToHeight(r.yBot-r.yTop,!0)});const h=new W(...i);return[h,o.createRowlineFlat(o.createPoint(h),this.controller)]}async generateFlatsHeader(t){const e=[],s=o.clone(t);this.question.hasRows&&(this.controller.margins.left=s.xLeft,this.controller.margins.right+=o.getPageAvailableWidth(this.controller)-this.rowTitleWidth,e.push(await this.generateFlatCell(s,async(r,h)=>{h.push(new Tt(this.controller,o.createRect(r,o.getPageAvailableWidth(this.controller),1)))})),s.xLeft+=this.rowTitleWidth+this.style.spacing.tableColumnGap);for(let r=0;r<this.question.visibleColumns.length;r++)this.controller.pushMargins(),this.controller.margins.left=s.xLeft,this.controller.margins.right+=o.getPageAvailableWidth(this.controller)-this.columnWidth,e.push(await this.generateFlatCell(s,async(h,a)=>{a.push(await o.createTextFlat(h,this.controller,this.question.visibleColumns[r].locText,{...this.style.columnTitle}))})),s.xLeft+=this.columnWidth+this.style.spacing.tableColumnGap,this.controller.popMargins();const i=o.mergeRects(...e);e.forEach(r=>{r.fitToHeight(i.yBot-i.yTop,!0)});const n=new W(...e);return[n,o.createRowlineFlat(o.createPoint(n),this.controller)]}async generateFlats(t){this.setup();const e=o.clone(t),s=await this.generateFlatsHeader(t);e.yTop=o.mergeRects(...s).yBot+this.style.spacing.tableRowGap;const i=await super.generateFlats(e);return[...s,...i]}}z.Serializer.removeProperty("matrix","renderAs"),z.Serializer.addProperty("matrix",{name:"renderAs",default:"auto",visible:!1,choices:["auto","list"]}),N.getInstance().register("matrix",Ue);class ue extends tt{constructor(t,e,s,i,n=!0){super(t,e,s,i),this.survey=t,this.isMultiple=n,this.cellFlatQuestionHash={}}get visibleRows(){return this.visibleRowsValue||(this.visibleRowsValue=this.question.renderedTable.rows.filter(t=>t.visible)),this.visibleRowsValue}getFlatQuestion(t,e,s){const i=s.uniqueId.toString();return this.cellFlatQuestionHash[i]||(this.cellFlatQuestionHash[i]=o.getFlatQuestion(t,e,s)),this.cellFlatQuestionHash[i]}async generateFlatsCell(t,e,s,i=!0){let n=this.style.cell;e.hasTitle&&s!=="header"&&(n=o.mergeObjects({},n),i||(n=o.mergeObjects({},n,this.style.listSectionTitleContainer))),e.hasTitle&&s==="header"&&(n=o.mergeObjects({},n),i||(n=o.mergeObjects({},n)));const r=new At(this.controller,{...t,width:o.getPageAvailableWidth(this.controller)},n);return await r.setup(async(h,a)=>{var l,u;if(e.hasQuestion)if(s=="footer"&&!e.question.isAnswered)a.push(new Tt(this.controller,{...h,yBot:h.yTop,xRight:h.xLeft+o.getPageAvailableWidth(this.controller)}));else{const p=this.getFlatQuestion(this.survey,this.controller,e.question);if(i&&e.isChoice)a.push(p.generateFlatItem(h,e.item,e.choiceIndex,p.getItemStyle(e.item).input));else{e.question.titleLocation="matrix";const v=o.clone(h);!i&&this.question.renderedTable.showHeader&&s!=="header"&&(!((u=(l=e.cell)===null||l===void 0?void 0:l.column)===null||u===void 0)&&u.locTitle)&&(r.addBrick(await o.createTextFlat(v,this.controller,e.cell.column.locTitle,o.mergeObjects({},this.style.columnTitle,this.style.listItemTitle))),v.yTop=r.yBot+this.style.spacing.listItemTitleContentGap),a.push(...await p.generateFlats(v))}}else e.hasTitle?s=="header"?a.push(await o.createTextFlat(h,this.controller,e.locTitle,{...this.style.columnTitle})):a.push(await o.createTextFlat(h,this.controller,e.locTitle,o.mergeObjects({},this.style.rowTitle,i?void 0:this.style.listSectionTitle))):a.push(new Tt(this.controller,{...h,yBot:h.yTop,xRight:h.xLeft+o.getPageAvailableWidth(this.controller)}))}),r}get hasDetailPanel(){return this.visibleRows.some(t=>t.row&&this.question.hasDetailPanel(t.row))}ignoreCell(t,e,s,i=!0){return!i&&s=="footer"&&t.hasQuestion&&!t.question.isAnswered?!0:!(t.hasQuestion||t.hasTitle||this.isMultiple&&(this.hasDetailPanel?e==1:e==0))}getRowLocation(t){return t===this.question.renderedTable.headerRow?"header":this.question.renderedTable.footerRow===t?"footer":void 0}async generateFlatsRowHorisontal(t,e,s){const i=[],n=o.clone(t);let r=this.controller.paperWidth-this.controller.margins.left+this.style.spacing.tableColumnGap;this.controller.pushMargins();let h=0;const a=this.getRowLocation(e);for(let v=0;v<e.cells.length;v++){if(this.ignoreCell(e.cells[v],v,a))continue;this.controller.margins.left=this.controller.paperWidth-r+this.style.spacing.tableColumnGap,this.controller.margins.right=this.controller.paperWidth-this.controller.margins.left-s[h],r=this.controller.margins.right,n.xLeft=this.controller.margins.left;const B=await this.generateFlatsCell(n,e.cells[v],a);B.isEmpty||i.push(B),h++}const{yBot:l,yTop:u}=o.mergeRects(...i),p=l-u;return i.forEach(v=>{v.fitToHeight(p)}),this.controller.popMargins(),new W(...i)}async generateFlatsRowVertical(t,e){const s=new W,i=o.clone(t),n=this.getRowLocation(e);for(let r=0;r<e.cells.length;r++)this.ignoreCell(e.cells[r],r,n,!1)||(s.addBrick(await this.generateFlatsCell(i,e.cells[r],n,!1)),i.yTop=s.yBot+this.style.spacing.tableRowGap);return s}getColumnsAvalableWidth(t){return o.getPageAvailableWidth(this.controller)-(t-1)*this.style.spacing.tableColumnGap}calculateColumnWidth(t,e){const s=this.getColumnsAvalableWidth(e);let i=s,n=e;const r=[],h=[];let a=t[0].cells.filter((u,p)=>!this.ignoreCell(u,p));for(let u=0;u<e;u++){const p=o.parseWidth(a[u].width,s,e)||0;i-=p,p!==0?n--:h.push(a[u]),r.push(p)}if(n===0)return r;const l=this.style.columnMinWidth;return h.sort((u,p)=>{let v=o.parseWidth(u.minWidth,s,e)||0;return(o.parseWidth(p.minWidth,s,e)||0)>v?1:-1}).forEach(u=>{const p=i/n,v=o.parseWidth(u.minWidth,s,e)||0;v>p&&v>l&&(i-=v,n--),r[a.indexOf(u)]=Math.max(l,v,p)}),r}async generateOneRow(t,e,s,i){return s?await this.generateFlatsRowHorisontal(t,e,i):await this.generateFlatsRowVertical(t,e)}async generateFlatsRows(t,e,s,i){const n=o.clone(t),r=[];if(!e||e.length==0)return;const h=this.calculateColumnWidth(e,s);for(let a=0;a<e.length;a++){let l=await this.generateOneRow(n,e[a],i,h);if(!(l.isEmpty&&!(e[a].row&&e[a].row.hasPanel))&&(l.isEmpty||(a!==e.length-1&&(n.yTop=l.yBot,l.addBrick(o.createRowlineFlat(n,this.controller))),r.push(l),n.yTop=l.yBot+this.style.spacing.tableRowGap),e[a].row&&e[a].row.hasPanel)){e[a].row.showDetailPanel();const u=e[a].row.detailPanel;for(let M=0;M<u.questions.length;M++)u.questions[M].id+="_"+a;const p=o.clone(n),v=new W;this.isMultiple&&i&&(this.controller.pushMargins(),p.xLeft+=h[0]+this.style.spacing.tableColumnGap,this.controller.margins.left=p.xLeft);const B=await o.generatePanelFlats(this.survey,this.controller,u,p);if(this.isMultiple&&i){this.controller.popMargins();const M=o.mergeRects(...B),Z=new Tt(this.controller,{...n,xRight:n.xLeft+h[0],yBot:n.yTop+M.yBot-M.yTop},{borderMode:It.Middle,color:this.style.cell.backgroundColor,borderColor:this.style.cell.borderColor,borderRadius:this.style.cell.borderRadius,borderWidth:this.style.cell.borderWidth});v.addBrick(Z)}v.addBrick(...B),n.yTop=v.yBot+this.style.spacing.tableRowGap,r.push(v)}}return r}calculateIsWide(t,e){const s=[];if(t.showHeader&&s.push(t.headerRow),s.push(...this.visibleRows),s.length===0)return!0;const i=this.calculateColumnWidth(s,e).reduce((n,r)=>n+=r,0);return this.question.renderAs!=="list"&&this.controller.matrixRenderAs!=="list"&&Math.floor(i)<=Math.floor(this.getColumnsAvalableWidth(e))}getRowsToRender(t,e,s){const i=[],n=this.visibleRows.filter(r=>!r.isDetailRow);return t.showHeader&&s&&i.push(t.headerRow),i.push(...n),t.hasRemoveRows&&e&&i.pop(),t.showFooter&&i.push(t.footerRow),i}getColCount(t,e){return e[0]?e[0].cells.filter((s,i)=>!this.ignoreCell(s,i)).length:t.showHeader&&t.headerRow?t.headerRow.cells.length:t.showFooter&&t.footerRow?t.footerRow.cells.length:0}async generateFlatsContent(t){let e=this.question.renderedTable,s=this.question.columnLayout==="vertical",i=this.getColCount(e,this.visibleRows);if(i===0&&!this.hasDetailPanel)return[new W(o.createRowlineFlat(t,this.controller))];const n=this.calculateIsWide(e,i),r=this.question.isMobile;n||(this.question.isMobile=!0,s=!1,e=this.question.renderedTable,this.visibleRowsValue=void 0,i=this.getColCount(e,this.visibleRows));const h=this.getRowsToRender(e,s,n),a=await this.generateFlatsRows(t,h,i,n);return this.question.isMobile=r,a}}z.Serializer.removeProperty("matrixdropdown","renderAs"),z.Serializer.addProperty("matrixdropdown",{name:"renderAs",default:"auto",visible:!1,choices:["auto","list"]}),N.getInstance().register("matrixdropdown",ue);class Ye extends ue{constructor(t,e,s,i){super(t,e,s,i,!1),this.survey=t}}z.Serializer.removeProperty("matrixdynamic","renderAs"),z.Serializer.addProperty("matrixdynamic",{name:"renderAs",default:"auto",visible:!1,choices:["auto","list"]}),N.getInstance().register("matrixdynamic",Ye);class Ke extends tt{getVisibleRows(){return this.question.getRows().filter(t=>t.isVisible)}async generateFlatCell(t,e){const s=new At(this.controller,{...t,width:o.getPageAvailableWidth(this.controller)},this.style.itemCell);return await s.setup(e),s}async generateFlatItemCells(t,e){const s=o.getPageAvailableWidth(this.controller),i=[];return this.controller.pushMargins(),this.controller.margins.right=this.controller.paperWidth-this.controller.margins.left-s*this.style.itemTitleWidthPercentage,i.push(await this.generateFlatCell(t,async(n,r)=>{r.push(await o.createTextFlat(n,this.controller,e.locTitle,{...this.style.itemTitle}))})),this.controller.popMargins(),this.controller.pushMargins(),this.controller.margins.left=t.xLeft+s*this.style.itemTitleWidthPercentage+this.style.spacing.itemTitleGap,i.push(await this.generateFlatCell({xLeft:this.controller.margins.left,yTop:t.yTop},async(n,r)=>{const h=N.getInstance().create(this.survey,e.editor,this.controller,this.survey.getElementStyle(e.editor),"text");r.push(...await h.generateFlatsContent(n))})),this.controller.popMargins(),i}async generateFlatsContent(t){const e=[],s=o.clone(t),i=this.getVisibleRows();for(let n=0;n<i.length;n++){this.controller.pushMargins();const r=[];for(let a=0;a<i[n].cells.length;a++)this.controller.pushMargins(),o.setColumnMargins(this.controller,this.question.colCount,a,this.style.spacing.itemColumnGap),s.xLeft=this.controller.margins.left,r.push(...await this.generateFlatItemCells(s,i[n].cells[a].item)),this.controller.popMargins();this.controller.popMargins(),s.xLeft=t.xLeft;const h=o.mergeRects(...r);r.forEach(a=>{a.fitToHeight(h.yBot-h.yTop)}),s.yTop=h.yBot,e.push(...r,o.createRowlineFlat(s,this.controller)),s.yTop+=this.style.spacing.itemGap}return e}}N.getInstance().register("multipletext",Ke);class Cs extends pt{constructor(t,e,s){super(e,s(e.helperDoc,t,0,0)),this.question=t,this.renderFunc=s}async renderInteractive(){await new Promise(t=>{this.renderFunc(this.controller.doc,this.question,this.contentRect.xLeft,this.contentRect.yTop),t()})}}z.checkLibraryVersion("3.0.2","survey-pdf");class ks extends Re{async _getImageInfo(t){let s;if(typeof t=="string"&&t.startsWith("data:"))s=Buffer.from(t.split(",")[1]||"","base64");else{const n=await ts(t);s=new Uint8Array(await n.arrayBuffer())}const i=es.imageSize(s);return{data:s,width:i.width*.75,height:i.height*.75,id:this.getImageId()}}}function Ps(m){const t=m.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+),?\s*([0-9.]+)?\)$/);if(!t)return null;const e=parseInt(t[1]),s=parseInt(t[2]),i=parseInt(t[3]),n=t[4]?parseFloat(t[4]):null,r=a=>{const l=a.toString(16);return l.length===1?"0"+l:l},h=n?r(Math.round(n*255)):"";return`#${r(e)}${r(s)}${r(i)}${h}`}class Bs{setup(t){this.hash={},this.colorHash={},this.variables=t}tokenizeString(t){const e=Zt.tokenizer({css:t}),s=[];for(;!e.endOfFile();)s.push(e.nextToken());return s.push(e.nextToken()),s}splitComponentValuesByTopLevelComma(t){const e=[];let s=[];for(const i of t)i.type=="token"&&i.value[0]=="comma-token"?(e.push(s),s=[]):s.push(i);return e.push(s),e}getVariable(t){if(!t)return t;if(!this.variables||!this.hash||!this.variables[t])return;if(this.hash[t])return this.hash[t];let e=this.variables[t];const s=Jt.parseListOfComponentValues(this.tokenizeString(e)),i=(h,a=0)=>{if(a>50)return h;const l=[];for(const u of h)if(u.type==="function"){const p=u;if(p.getName().toLowerCase()==="var"){const B=p.value||[],M=this.splitComponentValuesByTopLevelComma(B),Z=M[0]||[],st=M.length>1?M[1]:null,ut=Z.map(K=>Zt.stringify(...K.tokens())).join("").trim();let D=[];const Y=this.getVariable(ut);Y?D=Jt.parseListOfComponentValues(this.tokenizeString(Y)):st&&st.length>0?D=i(st,a+1):D=[],l.push(...D);continue}else{const B=p.value||[],M=i(B,a+1);l.push(new Jt.FunctionNode(p.name,p.endToken,M));continue}}else l.push(u);return l},n=i(s),r=ss.calcFromComponentValues([n]).map(h=>h.map(a=>Zt.stringify(...a.tokens())).join("")).join(",");return this.hash[t]=r,r}getSizeVariable(t){const e=this.getVariable(t);return e?e.match(/px$/)?Number.parseFloat(e)*72/96:Number.parseFloat(e):0}getColorVariable(t){const e=this.getVariable(t);if(!this.colorHash[e]){const s=Jt.parseComponentValue(Zt.tokenize({css:e})),i=pe.color(s);if(i){const n=pe.serializeRGB(i);this.colorHash[e]=Ps(n.toString())}else this.colorHash[e]="#000000"}return this.colorHash[e]}startCollectingVariables(){}stopCollectingVariables(){}}us(new ks),vs(()=>new Bs),T.CheckItemBrick=Ut,T.CompositeBrick=W,T.CustomBrick=Cs,T.DocController=xt,T.DocOptions=kt,T.DrawCanvas=re,T.DropdownBrick=Me,T.EmptyBrick=Tt,T.EventHandler=ke,T.FlatBoolean=Be,T.FlatCheckbox=he,T.FlatComment=Ie,T.FlatCustomModel=Le,T.FlatDropdown=Se,T.FlatExpression=Ae,T.FlatFile=qe,T.FlatHTML=Oe,T.FlatImage=_e,T.FlatImagePicker=We,T.FlatMatrix=Ue,T.FlatMatrixDynamic=Ye,T.FlatMatrixMultiple=ue,T.FlatMultipleText=Ke,T.FlatPage=Pe,T.FlatPanel=ae,T.FlatPanelDynamic=Ne,T.FlatQuestion=tt,T.FlatQuestionDefault=xe,T.FlatRadiogroup=ce,T.FlatRanking=Ge,T.FlatRating=ze,T.FlatRepository=N,T.FlatSelectBase=le,T.FlatSignaturePad=Et,T.FlatSlider=De,T.FlatSurvey=Qe,T.FlatTextbox=Yt,T.HTMLBrick=ve,T.ImageBrick=be,T.LinkBrick=Wt,T.PagePacker=Dt,T.PdfBrick=pt,T.RadioItemBrick=Nt,T.RankingItemBrick=Ee,T.RowlineBrick=ne,T.SurveyHelper=o,T.SurveyPDF=Pt,T.TextBrick=zt,T.TextFieldBrick=we}));