@magicfeedback/native 1.2.8-beta.7 → 1.2.8-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/magicfeedback-sdk.browser.js +1 -1
- package/dist/magicfeedback-sdk.node.js +1 -1
- package/dist/types/src/models/History.d.ts +10 -0
- package/dist/types/src/models/form.d.ts +19 -19
- package/dist/types/src/models/formData.d.ts +3 -1
- package/dist/types/src/models/page.d.ts +13 -0
- package/dist/types/src/models/pageGrafs.d.ts +34 -0
- package/dist/types/src/models/pageNode.d.ts +22 -0
- package/dist/types/src/models/pageRoute.d.ts +38 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.magicfeedback=t():e.magicfeedback=t()}(self,(()=>{return e={98:function(e,t){var i="undefined"!=typeof self?self:this,n=function(){function e(){this.fetch=!1,this.DOMException=i.DOMException}return e.prototype=i,new e}();!function(e){!function(t){var i="URLSearchParams"in e,n="Symbol"in e&&"iterator"in Symbol,s="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),a="FormData"in e,r="ArrayBuffer"in e;if(r)var o=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(e){return e&&o.indexOf(Object.prototype.toString.call(e))>-1};function d(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function u(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function p(e){this.map={},e instanceof p?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function h(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function m(e){return new Promise((function(t,i){e.onload=function(){t(e.result)},e.onerror=function(){i(e.error)}}))}function f(e){var t=new FileReader,i=m(t);return t.readAsArrayBuffer(e),i}function g(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:s&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:a&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:i&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r&&s&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=g(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=g(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):i&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s&&(this.blob=function(){var e=h(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(f)}),this.text=function(){var e,t,i,n=h(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,i=m(t=new FileReader),t.readAsText(e),i;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),i=new Array(t.length),n=0;n<t.length;n++)i[n]=String.fromCharCode(t[n]);return i.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a&&(this.formData=function(){return this.text().then(E)}),this.json=function(){return this.text().then(JSON.parse)},this}p.prototype.append=function(e,t){e=d(e),t=l(t);var i=this.map[e];this.map[e]=i?i+", "+t:t},p.prototype.delete=function(e){delete this.map[d(e)]},p.prototype.get=function(e){return e=d(e),this.has(e)?this.map[e]:null},p.prototype.has=function(e){return this.map.hasOwnProperty(d(e))},p.prototype.set=function(e,t){this.map[d(e)]=l(t)},p.prototype.forEach=function(e,t){for(var i in this.map)this.map.hasOwnProperty(i)&&e.call(t,this.map[i],i,this)},p.prototype.keys=function(){var e=[];return this.forEach((function(t,i){e.push(i)})),u(e)},p.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),u(e)},p.prototype.entries=function(){var e=[];return this.forEach((function(t,i){e.push([i,t])})),u(e)},n&&(p.prototype[Symbol.iterator]=p.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function v(e,t){var i,n,s=(t=t||{}).body;if(e instanceof v){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new p(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,s||null==e._bodyInit||(s=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new p(t.headers)),this.method=(n=(i=t.method||this.method||"GET").toUpperCase(),y.indexOf(n)>-1?n:i),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(s)}function E(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var i=e.split("="),n=i.shift().replace(/\+/g," "),s=i.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(s))}})),t}function k(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new p(t.headers),this.url=t.url||"",this._initBody(e)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},b.call(v.prototype),b.call(k.prototype),k.prototype.clone=function(){return new k(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},k.error=function(){var e=new k(null,{status:0,statusText:""});return e.type="error",e};var x=[301,302,303,307,308];k.redirect=function(e,t){if(-1===x.indexOf(t))throw new RangeError("Invalid status code");return new k(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var i=Error(e);this.stack=i.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function C(e,i){return new Promise((function(n,a){var r=new v(e,i);if(r.signal&&r.signal.aborted)return a(new t.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function c(){o.abort()}o.onload=function(){var e,t,i={status:o.status,statusText:o.statusText,headers:(e=o.getAllResponseHeaders()||"",t=new p,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var i=e.split(":"),n=i.shift().trim();if(n){var s=i.join(":").trim();t.append(n,s)}})),t)};i.url="responseURL"in o?o.responseURL:i.headers.get("X-Request-URL");var s="response"in o?o.response:o.responseText;n(new k(s,i))},o.onerror=function(){a(new TypeError("Network request failed"))},o.ontimeout=function(){a(new TypeError("Network request failed"))},o.onabort=function(){a(new t.DOMException("Aborted","AbortError"))},o.open(r.method,r.url,!0),"include"===r.credentials?o.withCredentials=!0:"omit"===r.credentials&&(o.withCredentials=!1),"responseType"in o&&s&&(o.responseType="blob"),r.headers.forEach((function(e,t){o.setRequestHeader(t,e)})),r.signal&&(r.signal.addEventListener("abort",c),o.onreadystatechange=function(){4===o.readyState&&r.signal.removeEventListener("abort",c)}),o.send(void 0===r._bodyInit?null:r._bodyInit)}))}C.polyfill=!0,e.fetch||(e.fetch=C,e.Headers=p,e.Request=v,e.Response=k),t.Headers=p,t.Request=v,t.Response=k,t.fetch=C,Object.defineProperty(t,"__esModule",{value:!0})}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var s=n;(t=s.fetch).default=s.fetch,t.fetch=s.fetch,t.Headers=s.Headers,t.Request=s.Request,t.Response=s.Response,e.exports=t},290:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HOST_API_URL_DEV=t.HOST_API_URL=void 0,t.HOST_API_URL="https://api.magicfeedback.io/",t.HOST_API_URL_DEV="https://api-dev.magicfeedback.io/"},607:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(519));let a=null;a||(a=(0,s.default)()),t.default=a},519:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,a){function r(e){try{c(n.next(e))}catch(e){a(e)}}function o(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,o)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const s=i(954),a=i(712),r=i(5),o=i(341),c=i(290);t.default=function(){const e=new a.Config;let t;return{init:function(i){(null==i?void 0:i.debug)&&e.set("debug",null==i?void 0:i.debug),e.set("url",(null==i?void 0:i.env)&&"dev"===(null==i?void 0:i.env)?c.HOST_API_URL_DEV:c.HOST_API_URL),t=new r.Log(e),t.log("Initialized Magicfeedback",e)},send:function(i,s,a,r=!0,c,d){return n(this,void 0,void 0,(function*(){i||t.err("No appID provided"),s||t.err("No publicKey provided"),a||t.err("No feedback provided"),a.answers||a.profile||a.metrics||a.metadata||t.err("No feedback data provided");const n=e.get("url"),l={integration:i,publicKey:s,privateKey:d,completed:r,id:c,feedback:a};try{const e=yield(0,o.sendFeedback)(n,l,t);return t.log("sent native feedback"),e}catch(e){return t.err("error native feedback",e),!1}}))},form:function(i,n){return i||t.err("No appID provided"),n||t.err("No publicKey provided"),new s.Form(e,i,n)}}}},712:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Config=void 0,t.Config=class{constructor(){this.variables={},this.variables.env="prod",this.variables.debug=!1}get(e){return this.variables[e]}set(e,t){this.variables[e]=t}}},954:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,a){function r(e){try{c(n.next(e))}catch(e){a(e)}}function o(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,o)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.Form=void 0;const s=i(5),a=i(341),r=i(183);t.Form=class{constructor(e,t,i){this.config=e,this.log=new s.Log(e),this.formOptionsConfig={addButton:!0,sendButtonText:"Send",backButtonText:"Back",nextButtonText:"Next",addSuccessScreen:!0,getMetaData:!0,questionFormat:"standard"},this.selector="",this.appId=t,this.publicKey=i,this.url=e.get("url"),this.id="",this.formData=null,this.feedback={text:"",answers:[],profile:[],metrics:[],metadata:[]},this.questions=[],this.censorQuestions=[],this.elementQuestions=[],this.questionInProcess=null,this.history={},this.progress=0,this.total=0}generate(e,t){var i;return n(this,void 0,void 0,(function*(){try{this.formOptionsConfig=Object.assign(Object.assign({},this.formOptionsConfig),t),this.selector=e;const n=localStorage.getItem(`magicfeedback-${this.appId}`);if(n&&new Date(JSON.parse(n).savedAt)<new Date((new Date).getTime()+864e5)?(this.formData=JSON.parse(n),(0,a.getForm)(this.url,this.appId,this.publicKey,this.log).then((e=>{var t,i,n;(null==e?void 0:e.updatedAt)&&(null===(t=this.formData)||void 0===t?void 0:t.savedAt)&&(null==e?void 0:e.updatedAt)>(null===(i=this.formData)||void 0===i?void 0:i.savedAt)&&(console.log("Form updated"),this.formData=e,this.formData.savedAt=new Date,this.formData.questions&&(this.questions=this.formData.questions,this.total=this.questions.length),localStorage.setItem(`magicfeedback-${this.appId}`,JSON.stringify(this.formData)),(null===(n=this.formData.style)||void 0===n?void 0:n.startMessage)?this.generateWelcomeMessage(this.formData.style.startMessage):this.generateForm())}))):this.formData=yield(0,a.getForm)(this.url,this.appId,this.publicKey,this.log),void 0===this.formData||!this.formData)throw new Error(`No form for app ${this.appId}`);if(this.formData.savedAt||(this.formData.savedAt=new Date,localStorage.setItem(`magicfeedback-${this.appId}`,JSON.stringify(this.formData))),this.questions=this.formData.questions,void 0===this.questions||!this.questions)throw new Error(`No questions for app ${this.appId}`);this.total=this.questions.length,this.formOptionsConfig.onLoadedEvent&&(yield this.formOptionsConfig.onLoadedEvent({loading:!1,progress:this.progress,total:this.total,formData:this.formData})),this.formOptionsConfig.getMetaData&&this.getMetaData(),(null===(i=this.formData.style)||void 0===i?void 0:i.startMessage)?this.generateWelcomeMessage(this.formData.style.startMessage):this.generateForm()}catch(e){return this.log.err(e),void(this.formOptionsConfig.onLoadedEvent&&(yield this.formOptionsConfig.onLoadedEvent({loading:!1,error:e})))}}))}generateContainer(){let e=document.getElementById(this.selector);if(!e&&(e=document.getElementById("magicfeedback-container-"+this.appId),!e))throw new Error(`Element with ID '${this.selector}' not found.`);return e.classList.add("magicfeedback-container"),e.id="magicfeedback-container-"+this.appId,e.innerHTML="",e}generateForm(){var e,t,i;try{this.questions.sort(((e,t)=>e.position-t.position));let n=this.generateContainer();const s=document.createElement("form");s.classList.add("magicfeedback-form"),s.id="magicfeedback-"+this.appId;const a=document.createElement("div");if(a.classList.add("magicfeedback-questions"),a.id="magicfeedback-questions-"+this.appId,this.elementQuestions=(0,r.renderQuestions)(this.questions,this.formOptionsConfig.questionFormat,null===(e=this.formData)||void 0===e?void 0:e.lang[0],(()=>this.send())),"MAGICSURVEY"===(null===(t=this.formData)||void 0===t?void 0:t.identity)?(this.elementQuestions.forEach(((e,t)=>this.history[t]=[{object:this.questions[t],element:e}])),this.questionInProcess=this.history[0][0].object,a.appendChild(this.history[0][0].element)):this.elementQuestions.forEach((e=>a.appendChild(e))),s.appendChild(a),n.appendChild(s),this.formOptionsConfig.addButton){const e=(0,r.renderActions)(null===(i=this.formData)||void 0===i?void 0:i.identity,(()=>this.back()),this.formOptionsConfig.sendButtonText,this.formOptionsConfig.backButtonText,this.formOptionsConfig.nextButtonText);s.appendChild(e)}s.addEventListener("submit",(e=>{e.preventDefault(),this.send()}))}catch(e){return this.log.err(e),void(this.formOptionsConfig.onLoadedEvent&&this.formOptionsConfig.onLoadedEvent({loading:!1,error:e}))}}startForm(){this.generateForm()}generateWelcomeMessage(e){try{const t=this.generateContainer(),i=(0,r.renderStartMessage)(e,(()=>this.startForm()),this.formOptionsConfig.addButton,this.formOptionsConfig.startButtonText);t.appendChild(i)}catch(e){return this.log.err(e),void(this.formOptionsConfig.onLoadedEvent&&this.formOptionsConfig.onLoadedEvent({loading:!1,error:e}))}}getMetaData(){this.feedback.metadata.push({key:"navigator-url",value:[window.location.href]}),this.feedback.metadata.push({key:"navigator-origin",value:[window.location.origin]}),this.feedback.metadata.push({key:"navigator-pathname",value:[window.location.pathname]}),this.feedback.metadata.push({key:"navigator-search",value:[window.location.search]}),this.feedback.metadata.push({key:"navigator-user",value:[navigator.userAgent]}),this.feedback.metadata.push({key:"navigator-language",value:[navigator.language]}),this.feedback.metadata.push({key:"navigator-platform",value:[navigator.platform]}),this.feedback.metadata.push({key:"navigator-appVersion",value:[navigator.appVersion]}),this.feedback.metadata.push({key:"navigator-appName",value:[navigator.appName]}),this.feedback.metadata.push({key:"navigator-product",value:[navigator.product]}),this.feedback.metadata.push({key:"screen-width",value:[window.screen.width.toString()]}),this.feedback.metadata.push({key:"screen-height",value:[window.screen.height.toString()]})}send(e,t,i){var s;return n(this,void 0,void 0,(function*(){const n=document.getElementById("magicfeedback-container-"+this.appId),a=document.getElementById("magicfeedback-questions-"+this.appId);try{i&&(this.feedback.profile=[...this.feedback.profile,...i]),t&&(this.feedback.metrics=[...this.feedback.metrics,...t]),e&&(this.feedback.metadata=[...this.feedback.metadata,...e]),this.answer(),this.formOptionsConfig.beforeSubmitEvent&&(yield this.formOptionsConfig.beforeSubmitEvent({loading:!0,answer:this.feedback.answers,progress:this.progress,total:this.total}));const r=yield this.pushAnswers("MAGICSURVEY"!==(null===(s=this.formData)||void 0===s?void 0:s.identity));r&&(this.id=r,yield this.processNextQuestion(n,a)),this.formOptionsConfig.afterSubmitEvent&&(yield this.formOptionsConfig.afterSubmitEvent({response:r,loading:!1,progress:this.progress,total:this.total,answer:this.feedback.answers,error:r?null:new Error("No response")}))}catch(e){this.log.err(`An error occurred while submitting the form ${this.appId}:`,e),this.formOptionsConfig.afterSubmitEvent&&(yield this.formOptionsConfig.afterSubmitEvent({loading:!1,progress:this.progress+this.censorQuestions.length,total:this.total-this.censorQuestions.length,error:e}))}}))}answer(){const e=document.getElementById("magicfeedback-"+this.appId);if(!e)return this.log.err(`Form "${e}" not found.`),void(this.feedback.answers=[]);const t=[];let i=!1;const n=e.querySelectorAll(".magicfeedback-input");n.forEach((e=>{const s=e.type,r=e.classList[0],o={key:e.name,value:[]},c="magicfeedback-consent"===r?e.checked.toString():e.value;if(o.key&&""!==o.key)switch(s){case"radio":case"checkbox":if("magicfeedback-consent"===r||e.checked){if(e.id.includes("matrix")){const t=e.id.split("-")[e.id.split("-").length-1];let i="";n.forEach((e=>{e.checked&&e.id.includes(`matrix-${t}`)&&(i+=e.value+", ")})),i=i.slice(0,-2),o.value.push(`${t}: ${i}`)}else o.value.push(c);const i=t.findIndex((e=>e.key===o.key));-1!==i?t[i].value=[...t[i].value,...o.value]:t.push(o)}break;default:if(""!==c){if("email"===s){if(!(0,a.validateEmail)(c)){this.log.err("Invalid email"),i=!0;break}this.feedback.profile.push({key:"email",value:[c]})}if(e.id.includes("point-system")){const t=e.id.split("-")[e.id.split("-").length-1];o.value.push(`${t}: ${c}%`)}else o.value.push(c);const n=t.findIndex((e=>e.key===o.key));-1!==n?t[n].value=[...t[n].value,...o.value]:t.push(o)}}})),this.feedback.answers=i?[]:t}finish(){if(this.formOptionsConfig.addSuccessScreen){const e=document.getElementById("magicfeedback-container-"+this.appId);e.childNodes.length>0&&e.removeChild(e.childNodes[0]);const t=(0,r.renderSuccess)(this.formOptionsConfig.successMessage||"Thank you for your feedback!");e.appendChild(t)}this.answer(),this.pushAnswers(!0)}censureQuestions(e){this.censorQuestions=this.questions.filter((t=>e.includes(t.id))).map((e=>e.id))}pushAnswers(e=!1){var t,i;return n(this,void 0,void 0,(function*(){try{if("MAGICFORM"===(null===(t=this.formData)||void 0===t?void 0:t.identity)){if(0===this.feedback.answers.length)throw new Error("No answers provided");this.questions.forEach((e=>{if(e.require&&!this.feedback.answers.find((t=>t.key===e.ref)))throw new Error(`No answer provided for question ${e.title}`)}))}else if(!e&&(null===(i=this.questionInProcess)||void 0===i?void 0:i.require)&&0===this.feedback.answers.length)throw new Error("No answers provided");const n=this.config.get("url"),s={integration:this.appId,publicKey:this.publicKey,feedback:this.feedback,completed:e};return yield(0,a.sendFeedback)(n,this.id?Object.assign(Object.assign({},s),{sessionId:this.id}):s,this.log)}catch(e){return this.log.err(`An error occurred while submitting the form ${this.appId}:`,e),""}}))}callFollowUpQuestion(e){return n(this,void 0,void 0,(function*(){if(!(null==e?void 0:e.followup))return null;try{if(0===this.feedback.answers.length)throw new Error("No answers provided");const t=this.config.get("url"),i={answer:this.feedback.answers[0].value[0],publicKey:this.publicKey,sessionId:this.id,question:e};return yield(0,a.getFollowUpQuestion)(t,i,this.log)}catch(e){throw this.log.err(`An error occurred while submitting the form ${this.appId}:`,e),e}}))}processNextQuestion(e,t){var i,s,a,o;return n(this,void 0,void 0,(function*(){if("MAGICSURVEY"===(null===(i=this.formData)||void 0===i?void 0:i.identity))if(null===(s=this.questionInProcess)||void 0===s?void 0:s.followup){const e=yield this.callFollowUpQuestion(this.questionInProcess);if(e){this.questionInProcess=e;const i=(0,r.renderQuestions)([e],null===(a=this.formOptionsConfig)||void 0===a?void 0:a.questionFormat,null===(o=this.formData)||void 0===o?void 0:o.lang[0])[0];this.history[this.progress].push({object:e,element:i}),t.removeChild(t.childNodes[0]),t.appendChild(i)}else this.renderNextQuestion(t)}else this.renderNextQuestion(t);else if(this.total=this.questions.length,this.progress=this.questions.length,this.formOptionsConfig.addSuccessScreen){e.childNodes.length>0&&e.removeChild(e.childNodes[0]);const t=(0,r.renderSuccess)(this.formOptionsConfig.successMessage||"Thank you for your feedback!");e.appendChild(t)}}))}renderNextQuestion(e){this.progress++,this.progress<this.total?(this.questionInProcess=this.history[this.progress][0].object,this.censorQuestions.includes(this.questionInProcess.id)?this.renderNextQuestion(e):(e.removeChild(e.childNodes[0]),e.appendChild(this.history[this.progress][0].element))):this.finish()}back(){if(0===this.progress)return;const e=document.getElementById("magicfeedback-questions-"+this.appId);e&&e.childNodes.length>0&&e.removeChild(e.childNodes[0]),this.history[this.progress].length>1?this.history[this.progress].pop():this.progress--;let t=this.history[this.progress][this.history[this.progress].length-1];this.censorQuestions.includes(t.object.id)?this.back():(this.questionInProcess=t.object,e.appendChild(t.element))}}},244:(e,t)=>{"use strict";var i,n;Object.defineProperty(t,"__esModule",{value:!0}),t.QuestionType=t.FEEDBACKAPPANSWERTYPE=void 0,(n=t.FEEDBACKAPPANSWERTYPE||(t.FEEDBACKAPPANSWERTYPE={})).CONTACT="CONTACT",n.MULTIPLECHOISE_IMAGE="MULTIPLECHOISE_IMAGE",n.EMAIL="EMAIL",n.RATING_STAR="RATING_STAR",n.RADIO="RADIO",n.MULTIPLECHOICE="MULTIPLECHOICE",n.SELECT="SELECT",n.TEXT="TEXT",n.LONGTEXT="LONGTEXT",n.NUMBER="NUMBER",n.RATING_EMOJI="RATING_EMOJI",n.RATING_NUMBER="RATING_NUMBER",n.DATE="DATE",n.BOOLEAN="BOOLEAN",n.PASSWORD="PASSWORD",n.CONSENT="CONSENT",n.MULTI_QUESTION_MATRIX="MULTI_QUESTION_MATRIX",n.POINT_SYSTEM="POINT_SYSTEM",n.PRIORITY_LIST="PRIORITY_LIST",t.QuestionType=class{},function(e){e.FORM="form",e.DIV="div"}(i||(i={}))},374:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.endpoints=void 0,t.endpoints={sdk:{app:(e,t)=>`sdk/app/${e}/${t}`,app_info:(e,t)=>`sdk/app/${e}/${t}/info`,feedback:"sdk/feedback",followUpQuestion:"sdk/followUpQuestion"}}},528:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.placeholder=void 0,t.placeholder={answer:e=>{switch(e){case"en":default:return"Write your answer here...";case"es":return"Escribe tu respuesta aquí...";case"da":return"Skriv dit svar her...";case"fi":return"Kirjoita vastauksesi tähän...";case"sv":return"Skriv ditt svar här...";case"no":return"Skriv svaret ditt her...";case"ar":return"اكتب إجابتك هنا...";case"bn":return"এখানে আপনার"}},number:e=>{switch(e){case"en":default:return"Write your number here...";case"es":return"Escribe tu número aquí...";case"da":return"Skriv dit nummer her...";case"fi":return"Kirjoita numerosi tähän...";case"sv":return"Skriv ditt nummer här...";case"no":return"Skriv nummeret ditt her...";case"ar":return"اكتب رقمك هنا...";case"bn":return"এখানে আপনার"}},email:e=>{switch(e){case"en":default:return"Write your email here...";case"es":return"Escribe tu correo electrónico aquí...";case"da":return"Skriv din e-mail her...";case"fi":return"Kirjoita sähköpostiosoitteesi tähän...";case"sv":return"Skriv din e-post här...";case"no":return"Skriv e-posten din her...";case"ar":return"اكتب بريدك الإلكتروني هنا...";case"bn":return"এখানে আপনার"}},date:e=>{switch(e){case"en":default:return"Write your date here...";case"es":return"Escribe tu fecha aquí...";case"da":return"Skriv din dato her...";case"fi":return"Kirjoita päivämääräsi tähän...";case"sv":return"Skriv ditt datum här...";case"no":return"Skriv datoen din her...";case"ar":return"اكتب تاريخك هنا...";case"bn":return"এখানে আপনার"}},password:e=>{switch(e){case"en":default:return"Write your password here...";case"es":return"Escribe tu contraseña aquí...";case"da":return"Skriv dit kodeord her...";case"fi":return"Kirjoita salasanasi tähän...";case"sv":return"Skriv ditt lösenord här...";case"no":return"Skriv passordet ditt her...";case"ar":return"اكتب كلمة المرور الخاصة بك هنا...";case"bn":return"এখানে আপনার"}}}},183:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.renderStartMessage=t.renderSuccess=t.renderError=t.renderActions=t.renderQuestions=void 0;const n=i(244),s=i(528);function a(e,t){return"object"==typeof e?e[t]||e.en:e}function r(e,t,i,n,s,a=!0){const r=document.createElement("div");r.classList.add("magicfeedback-rating-placeholder"),r.style.display="flex",r.style.justifyContent="space-between",r.style.width=s?`calc(100% - (100% / ${t+1}))`:"100%",r.style.marginRight="auto",a&&window.innerWidth<600&&(r.style.flexDirection="column");const o=document.createElement("span");o.textContent=i,o.classList.add("magicfeedback-rating-placeholder-value"),o.style.fontStyle="italic",o.style.fontSize="14px",o.style.textAlign="left",o.style.width="50%",a&&window.innerWidth<600&&(o.textContent=`${e} ➜ ${i}`,o.style.width="100%",o.style.textAlign="left",o.style.marginBottom="5px"),r.appendChild(o);const c=document.createElement("span");return c.textContent=n,c.classList.add("magicfeedback-rating-placeholder-value"),c.style.fontStyle="italic",c.style.fontSize="14px",c.style.textAlign="right",c.style.width="50%",a&&window.innerWidth<600&&(c.textContent=`${t} ➜ ${n}`,c.style.width="100%",c.style.textAlign="left",c.style.marginBottom="5px"),r.appendChild(c),r}t.renderQuestions=function e(t,i="standard",o="en",c){if(!t)throw new Error("[MagicFeedback] No questions provided");const d=[];return t.forEach((t=>{var l,u;if((null===(u=null===(l=null==t?void 0:t.questionType)||void 0===l?void 0:l.conf)||void 0===u?void 0:u.length)>0){let n=document.createElement("div");n.classList.add("magicfeedback-div"),t.questionType.conf.forEach((e=>{e.ref=t.ref,t.assets[e.id]&&(e.assets={placeholder:t.assets[e.id]})})),e(t.questionType.conf,i,o,c).forEach((e=>{n.appendChild(e)})),d.push(n)}else{const e=function(e,t,i,o){var c;let d,l,{id:u,title:p,type:h,ref:m,require:f,value:g,defaultValue:b,assets:y}=e,v=document.createElement("div");v.classList.add("magicfeedback-div");const E="slim"===t?a(p,i):null==y?void 0:y.placeholder,k=(C=u,new URLSearchParams(window.location.search).get(C)),x=y.maxCharacters||300;var C;switch(h){case n.FEEDBACKAPPANSWERTYPE.TEXT:d=document.createElement("input"),d.type="text",d.placeholder=E||s.placeholder.answer(i||"en"),l="magicfeedback-text";break;case n.FEEDBACKAPPANSWERTYPE.LONGTEXT:d=document.createElement("textarea"),d.rows=3,x>0&&(d.maxLength=x),d.placeholder=E||s.placeholder.answer(i||"en"),l="magicfeedback-longtext";break;case n.FEEDBACKAPPANSWERTYPE.NUMBER:d=document.createElement("input"),d.type="number",d.placeholder="slim"===t?a(p,i):s.placeholder.number(i||"en"),l="magicfeedback-number",g.length&&(g.sort(((e,t)=>Number(e)-Number(t))),d.max=g[g.length-1],d.min=g[0],d.value=g[0]);break;case n.FEEDBACKAPPANSWERTYPE.RADIO:case n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE:d=document.createElement("div"),l="magicfeedback-"+("MULTIPLECHOICE"===h?"checkbox":"radio"),y.extraOption&&g.push(y.extraOptionText),g.forEach(((e,t)=>{const a=document.createElement("div");a.classList.add(`magicfeedback-${"MULTIPLECHOICE"===h?"checkbox":"radio"}-container`);const r=document.createElement("label"),o=document.createElement("input");if(o.id=`rating-${m}-${t}`,o.type="MULTIPLECHOICE"===h?"checkbox":"radio",o.name=m,o.value=e,o.classList.add(l),o.classList.add("magicfeedback-input"),h===n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE&&y.maxOptions&&y.maxOptions>0&&o.addEventListener("change",(()=>{document.querySelectorAll(`input[name="${m}"]:checked`).length>y.maxOptions&&(o.checked=!1)})),e!==b&&e!==k||(o.checked=!0),r.textContent=e,r.htmlFor=`rating-${m}-${t}`,o.addEventListener("change",(t=>{const i=document.getElementById(`extra-option-${m}`);i&&y.extraOption&&(t.target.checked&&e===y.extraOptionText?i.style.display="block":i.style.display="none")})),a.appendChild(o),a.appendChild(r),d.appendChild(a),y.extraOption&&e===y.extraOptionText){const e=document.createElement("input");e.type="text",e.placeholder=y.extraOptionPlaceholder||s.placeholder.answer(i||"en"),e.classList.add("magicfeedback-extra-option"),e.classList.add("magicfeedback-input"),e.id=`extra-option-${m}`,e.name=`extra-option-${m}`,e.style.display="none",d.appendChild(e)}}));break;case n.FEEDBACKAPPANSWERTYPE.BOOLEAN:d=document.createElement("div"),l="magicfeedback-radio";const A=document.createElement("div");A.classList.add("magicfeedback-boolean-container"),A.style.display="flex",A.style.flexDirection="row",A.style.justifyContent="space-between",A.style.width="70%",A.style.margin="auto",(y.addIcon?["👍","👎"]:function(e){switch(e){case"es":return["Sí","No"];case"fr":return["Oui","Non"];case"de":return["Ja","Nein"];case"it":return["Sì","No"];case"pt":return["Sim","Não"];case"nl":return["Ja","Nee"];case"pl":return["Tak","Nie"];case"ru":return["Да","Нет"];case"ja":return["はい","いいえ"];case"zh":return["是","不"];case"ko":return["예","아니"];case"da":case"sv":return["Ja","Nej"];case"fi":return["Kyllä","Ei"];case"no":return["Ja","Nei"];case"ar":return["نعم","لا"];case"bn":return["হ্যাঁ","না"];default:return["Yes","No"]}}(i)).forEach(((e,t)=>{const i=document.createElement("label");i.classList.add("magicfeedback-boolean-option"),i.htmlFor=`rating-${m}-${t}`,i.style.cursor="pointer",i.style.border="1px solid #000",i.style.display="flex",i.style.justifyContent="center",i.style.alignItems="center",i.style.margin="auto",i.style.padding="0",i.style.width="45%",i.style.height="38px";const n=document.createElement("label");n.htmlFor=`rating-${m}-${t}`,n.textContent=e,n.style.margin="0",n.style.padding="0";const s=document.createElement("input");s.id=`rating-${m}-${t}`,s.type="radio",s.name=m,s.value=e,s.classList.add(l),s.classList.add("magicfeedback-input"),s.style.position="absolute",s.style.opacity="0",s.style.width="0",s.style.height="0",s.style.margin="0",s.addEventListener("change",(()=>{o&&o()})),i.appendChild(s),i.appendChild(n),A.appendChild(i)})),d.appendChild(A);break;case n.FEEDBACKAPPANSWERTYPE.RATING_EMOJI:d=document.createElement("div"),l="magicfeedback-rating";const L=document.createElement("div");L.classList.add("magicfeedback-rating-container");const T=y.max?Number(y.max):5,S=y.min?Number(y.min):1,O=r(S,T,y.minPlaceholder,y.maxPlaceholder,y.extraOption);for(let ne=S;ne<=T;ne++){const se=document.createElement("div");se.classList.add("magicfeedback-rating-option");const ae=document.createElement("label");ae.htmlFor=`rating-${m}-${ne}`,ae.classList.add("magicfeedback-rating-option-label-container");const re=document.createElement("label");re.htmlFor=`rating-${m}-${ne}`,re.textContent=ne.toString();const oe=document.createElement("img");if(oe.alt=`face-${m}-${ne}`,oe.className=`rating-image${ne}`,0===S&&10===T)oe.src=`https://magicfeedback-c6458-dev.web.app/assets/${ne}.svg`;else if(1===S&&5===T)switch(ne){case 1:oe.src="https://magicfeedback-c6458-dev.web.app/assets/1.svg";break;case 2:oe.src="https://magicfeedback-c6458-dev.web.app/assets/2.svg";break;case 3:oe.src="https://magicfeedback-c6458-dev.web.app/assets/6.svg";break;case 4:oe.src="https://magicfeedback-c6458-dev.web.app/assets/9.svg";break;case 5:oe.src="https://magicfeedback-c6458-dev.web.app/assets/10.svg"}else{const de=Math.round(10/(T-S)*(ne-S));oe.src=`https://magicfeedback-c6458-dev.web.app/assets/${de}.svg`}const ce=document.createElement("input");ce.id=`rating-${m}-${ne}`,ce.type="radio",ce.name=m,ce.value=ne.toString(),ce.classList.add(l),ce.classList.add("magicfeedback-input"),ae.appendChild(ce),ae.appendChild(oe),ae.appendChild(re),se.appendChild(ae),L.appendChild(se)}if(y.extraOption&&y.extraOptionText){const le=document.createElement("div");le.classList.add("magicfeedback-rating-option");const ue=document.createElement("label");ue.htmlFor=`rating-${m}-extra`,ue.classList.add("magicfeedback-rating-option-label-container");const pe=document.createElement("label");pe.htmlFor=`rating-${m}-extra`,pe.textContent=y.extraOptionText;const he=document.createElement("img");he.src="https://magicfeedback-c6458-dev.web.app/assets/question.svg",he.alt=`face-${m}-extra`,he.className="magicfeedback-rating-image-extra";const me=document.createElement("input");me.id=`rating-${m}-extra`,me.type="radio",me.name=m,me.value="-",me.classList.add(l),me.classList.add("magicfeedback-input"),ue.appendChild(me),ue.appendChild(he),ue.appendChild(pe),le.appendChild(ue),L.appendChild(le)}d.appendChild(O),d.appendChild(L);break;case n.FEEDBACKAPPANSWERTYPE.RATING_NUMBER:d=document.createElement("div"),l="magicfeedback-rating-number";const P=document.createElement("div");P.classList.add("magicfeedback-rating-number-container");const I=y.max?Number(y.max):5,N=y.min?Number(y.min):1,_=r(N,I,y.minPlaceholder,y.maxPlaceholder,y.extraOption);for(let fe=N;fe<=I;fe++){const ge=document.createElement("div");ge.classList.add("magicfeedback-rating-number-option");const be=document.createElement("label");be.htmlFor=`rating-${m}-${fe}`,be.classList.add("magicfeedback-rating-number-option-label-container");const ye=document.createElement("label");ye.htmlFor=`rating-${m}-${fe}`,ye.textContent=fe.toString();const ve=document.createElement("input");ve.id=`rating-${m}-${fe}`,ve.type="radio",ve.name=m,ve.value=fe.toString(),ve.classList.add(l),ve.classList.add("magicfeedback-input"),be.appendChild(ve),be.appendChild(ye),ge.appendChild(be),P.appendChild(ge)}if(y.extraOption&&y.extraOptionText){const Ee=document.createElement("div");Ee.classList.add("magicfeedback-rating-number-option");const ke=document.createElement("label");ke.htmlFor=`rating-${m}-extra`,ke.classList.add("magicfeedback-rating-number-option-label-container");const xe=document.createElement("label");xe.htmlFor=`rating-${m}-extra`,xe.textContent=y.extraOptionText;const Ce=document.createElement("input");Ce.id=`rating-${m}-extra`,Ce.type="radio",Ce.name=m,Ce.value="-",Ce.classList.add(l),Ce.classList.add("magicfeedback-input"),ke.appendChild(Ce),ke.appendChild(xe),Ee.appendChild(ke),P.appendChild(Ee)}d.appendChild(_),d.appendChild(P);break;case n.FEEDBACKAPPANSWERTYPE.RATING_STAR:d=document.createElement("div"),l="magicfeedback-rating-star";const $=function(e,t,i){const n="magicfeedback-rating-star-selected",s=document.createElement("div");s.classList.add("magicfeedback-rating-star-container"),s.style.maxWidth="300px",s.style.margin="auto";for(let t=1;t<=5;t++){const i=document.createElement("label");i.classList.add("magicfeedback-rating-star-option");const a=document.createElement("input");a.id=`rating-${e}-${t}`,a.type="radio",a.name=e,a.value=t.toString(),a.style.position="absolute",a.style.opacity="0",a.style.width="0",a.style.height="0",a.classList.add("magicfeedback-input"),a.addEventListener("change",(()=>{const e=s.querySelectorAll(".rating__star");for(let t=0;t<e.length;t++)t+1<=Number(a.value)?e[t].classList.contains(n)||e[t].classList.add(n):e[t].classList.contains(n)&&e[t].classList.remove(n)})),i.appendChild(a);const r=document.createElement("label");r.htmlFor=`rating-${e}-${t}`,r.classList.add("rating__star"),r.textContent="★",r.style.fontSize="40px",r.style.color="#CCCCCC",r.style.cursor="pointer",i.appendChild(r),s.appendChild(i)}return s.appendChild(r(1,5,t,i,!1,!1)),s}(m,y.minPlaceholder,y.maxPlaceholder);d.appendChild($);break;case n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE:d=document.createElement("div"),l="magicfeedback-multiple-choice-image";const D=document.createElement("div");D.classList.add("magicfeedback-multiple-choice-image-container"),D.style.display="flex",D.style.flexDirection="row",D.style.flexWrap="wrap",D.style.justifyContent="center";const M=g.length;let R=1,F=1;switch(M){case 1:case 2:case 3:R=M,F=1;break;case 4:case 5:case 6:F=2,R=Math.ceil(M/F);break;case 7:case 8:case 9:F=3,R=Math.ceil(M/F);break;default:F=4,R=Math.ceil(M/F)}const B=void 0!==(null==y?void 0:y.addTitle)&&y.addTitle,q=void 0!==(null==y?void 0:y.multiOption)&&y.multiOption,j=void 0!==(null==y?void 0:y.randomPosition)&&y.randomPosition,U=void 0!==(null==y?void 0:y.extraOption)&&y.extraOption;function K(e){try{const{position:t,url:i,value:n}=e,s=document.createElement("label");s.classList.add("magicfeedback-multiple-choice-image-option"),s.style.width=`calc( ${100/R}% - 10px)`,s.style.height=`calc( ${100/F}% - 10px)`,s.style.margin="5px";const a=document.createElement("label");a.htmlFor=`rating-${m}-${t}`,a.classList.add("magicfeedback-image-option-label-container"),a.style.display="flex",a.style.flexDirection="column",a.addEventListener("mouseover",(()=>{a.style.border="2px solid #000"})),a.addEventListener("mouseout",(()=>{a.style.border="none"})),a.addEventListener("click",(()=>{a.style.border="2px solid #000"}));const r=document.createElement("label");r.textContent=n,r.classList.add("magicfeedback-multiple-choice-image-label");const o=document.createElement("input");o.id=`rating-${m}-${t}`,o.type=q?"checkbox":"radio",o.name=m,o.value=n,o.style.position="absolute",o.style.opacity="0",o.style.width="0",o.style.height="0",o.classList.add("magicfeedback-input");const c=document.createElement("img");c.classList.add("magicfeedback-multiple-choice-image-image"),c.src=i,c.style.cursor="pointer",c.style.backgroundSize="cover",c.style.backgroundPosition="center",c.style.width="100%",c.style.height="100%",c.style.objectFit="cover",c.style.margin="auto",a.appendChild(o),a.appendChild(c),B&&a.appendChild(r),s.appendChild(a),D.appendChild(s)}catch(e){console.error(e)}}j&&(g=g.sort((()=>Math.random()-.5))),g.forEach((e=>K(JSON.parse(e)))),U&&y.extraOptionValue&&y.extraOptionValue.length>0&&K(y.extraOptionValue[0]),d.appendChild(D);break;case n.FEEDBACKAPPANSWERTYPE.SELECT:d=document.createElement("select"),l="magicfeedback-select";const W=document.createElement("option");W.value="",W.text="slim"===t?a(p,i):b||"Select an option",W.disabled=!0,W.selected=!0,d.appendChild(W),g.forEach((e=>{const t=document.createElement("option");t.value=e,t.text=e,d.appendChild(t)}));break;case n.FEEDBACKAPPANSWERTYPE.DATE:d=document.createElement("input"),d.type="date",d.required=f,d.placeholder=E||s.placeholder.date(i||"en"),l="magicfeedback-date";break;case n.FEEDBACKAPPANSWERTYPE.CONSENT:d=document.createElement("input"),l="magicfeedback-consent",d.type="checkbox",d.id=`magicfeedback-${u}`,d.name=m,d.value="true",d.required=f,d.classList.add("magicfeedback-consent"),d.classList.add("magicfeedback-input");break;case n.FEEDBACKAPPANSWERTYPE.EMAIL:d=document.createElement("input"),d.type="email",d.required=f,d.placeholder=E||"you@example.com",l="magicfeedback-email";break;case n.FEEDBACKAPPANSWERTYPE.PASSWORD:d=document.createElement("input"),d.type="password",d.required=f,d.placeholder=E||s.placeholder.password(i||"en"),l="magicfeedback-password";break;case n.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX:d=document.createElement("div"),l="magicfeedback-multi-question-matrix";const Q=document.createElement("div");Q.classList.add("magicfeedback-multi-question-matrix-container");const Y=document.createElement("table");Y.classList.add("magicfeedback-multi-question-matrix-table");const G=document.createElement("thead");G.classList.add("magicfeedback-multi-question-matrix-header"),G.style.paddingBottom="15px";const H=document.createElement("tr");["",...g].forEach((e=>{const t=document.createElement("th");t.textContent=e,t.style.padding="0 10px 10px 10px ",H.appendChild(t)})),G.appendChild(H);const V=document.createElement("tbody");(null===(c=null==y?void 0:y.options)||void 0===c?void 0:c.length)>0&&y.options.split("|").forEach((e=>{const t=document.createElement("tr");t.style.paddingBottom="15px";const i=document.createElement("td");i.classList.add("magicfeedback-multi-question-matrix-row-label");const n=document.createElement("label");n.classList.add("magicfeedback-multi-question-matrix-label"),n.style.paddingRight="15px",n.textContent=e,i.appendChild(n),t.appendChild(i),g.forEach((i=>{const n=document.createElement("td"),s=document.createElement("input");s.type="checkbox",s.name=m,s.value=i,s.id=`matrix-${e}`,s.classList.add("magicfeedback-input"),s.style.padding="0 10px",n.appendChild(s),t.appendChild(n)})),V.appendChild(t)})),Y.appendChild(G),Y.appendChild(V),Q.appendChild(Y),d.appendChild(Q);break;case n.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST:d=document.createElement("div"),l="magicfeedback-priority-list";const J=document.createElement("div");J.classList.add("magicfeedback-priority-list-container");const X=document.createElement("ul");X.classList.add("magicfeedback-priority-list-list"),g.forEach(((e,t)=>{const i=document.createElement("li");i.classList.add("magicfeedback-priority-list-item"),i.style.display="flex",i.style.justifyContent="space-between",i.style.alignItems="center",i.style.margin="5px";const n=document.createElement("input");n.classList.add("magicfeedback-input-magicfeedback-priority-list"),n.classList.add("magicfeedback-input"),n.type="hidden",n.id=`priority-list-${m}`,n.name=m,n.value=`${t+1}. ${e}`,i.appendChild(n);const s=document.createElement("label");s.classList.add("magicfeedback-priority-list-item-label"),s.textContent=`${t+1}. ${e}`,i.appendChild(s);const a=document.createElement("div");a.style.display="flex",a.style.alignItems="center",a.style.justifyContent="space-between";const r=document.createElement("img");r.classList.add("magicfeedback-priority-list-arrow-up"),r.src="https://magicfeedback-c6458-dev.web.app/assets/arrow.svg",r.style.width="20px",r.style.height="20px",r.style.cursor="pointer",r.style.margin="0 5px",r.style.color="#000",r.style.visibility=0===t?"hidden":"visible",r.addEventListener("click",(()=>{var t,a;const c=i.previousElementSibling;if(c){const d=Number(n.value.split(".")[0])-1;n.value=`${d}. ${e}`,s.textContent=`${d}. ${e}`,r.style.visibility=1===d?"hidden":"visible",o.style.visibility=d===g.length?"hidden":"visible";const l=c.querySelector(".magicfeedback-input-magicfeedback-priority-list"),u=c.querySelector(".magicfeedback-priority-list-item-label"),p=c.querySelector(".magicfeedback-priority-list-arrow-up"),h=c.querySelector(".magicfeedback-priority-list-arrow-down");if(l&&u&&p&&h){const e=Number(l.value.split(".")[0])+1;l.value=`${e}.${null===(t=u.textContent)||void 0===t?void 0:t.split(".")[1]}`,u.textContent=`${e}.${null===(a=u.textContent)||void 0===a?void 0:a.split(".")[1]}`,p.style.visibility=1===e?"hidden":"visible",h.style.visibility=e===g.length?"hidden":"visible"}X.insertBefore(i,c)}})),a.appendChild(r);const o=document.createElement("img");o.classList.add("magicfeedback-priority-list-arrow-down"),o.src="https://magicfeedback-c6458-dev.web.app/assets/arrow.svg",o.style.width="20px",o.style.height="20px",o.style.cursor="pointer",o.style.margin="0 5px",o.style.color="#000",o.style.transform="rotate(180deg)",o.style.visibility=t===g.length-1?"hidden":"visible",o.addEventListener("click",(()=>{var t,a;const c=i.nextElementSibling;if(c){const d=Number(n.value.split(".")[0])+1;n.value=d.toString(),s.textContent=`${d.toString()}. ${e}`,r.style.visibility=1===d?"hidden":"visible",o.style.visibility=d===g.length?"hidden":"visible";const l=c.querySelector(".magicfeedback-input-magicfeedback-priority-list"),u=c.querySelector(".magicfeedback-priority-list-item-label"),p=c.querySelector(".magicfeedback-priority-list-arrow-up"),h=c.querySelector(".magicfeedback-priority-list-arrow-down");if(l&&u&&p&&h){const e=Number(l.value.split(".")[0])-1;l.value=`${e}.${null===(t=u.textContent)||void 0===t?void 0:t.split(".")[1]}`,u.textContent=`${e}.${null===(a=u.textContent)||void 0===a?void 0:a.split(".")[1]}`,p.style.visibility=1===e?"hidden":"visible",h.style.visibility=e===g.length?"hidden":"visible"}X.insertBefore(c,i)}})),a.appendChild(o),i.appendChild(a),X.appendChild(i)})),J.appendChild(X),d.appendChild(J);break;case n.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM:d=document.createElement("div"),l="magicfeedback-point-system";const z=document.createElement("div");z.classList.add("magicfeedback-point-system-container");const Z=document.createElement("ul");Z.classList.add("magicfeedback-point-system-list"),Z.style.padding="0";const ee=100,te=ee/g.length,ie=document.createElement("div");ie.classList.add("magicfeedback-point-system-total"),ie.textContent="0 / 100 %",ie.style.textAlign="right",ie.style.fontSize="0.8em",ie.style.color="#999",ie.style.marginTop="5px",g.forEach((e=>{const t=document.createElement("li");t.classList.add("magicfeedback-point-system-item"),t.style.display="flex",t.style.justifyContent="space-between",t.style.alignItems="center",t.style.margin="5px";const i=document.createElement("label");i.textContent=e,t.appendChild(i);const n=document.createElement("span");n.classList.add("magicfeedback-point-system-input-container");const s=document.createElement("input");s.name=m,s.id=`point-system-${e}`,s.type="number",s.min="0",s.max=`${ee}`,s.value="0",s.classList.add("magicfeedback-input"),s.style.width="40px",s.style.border="0",s.style.textAlign="center",s.style.margin="0 5px";const a=document.createElement("span");a.textContent="%",a.style.color="#000",s.addEventListener("input",(()=>{const e=Z.querySelectorAll("input");let t=0;e.forEach((e=>{t+=Number(e.value)})),t>ee&&(s.value=`${te}%`,t-=Number(s.value)),ie.textContent=`${t} / 100 %`})),n.appendChild(s),n.appendChild(a),t.appendChild(n),Z.appendChild(t)})),z.appendChild(Z),z.appendChild(ie),d.appendChild(z);break;default:return v}d.id=`magicfeedback-${u}`,d.setAttribute("name",m),d.classList.add(l),(void 0!==b||null!==k)&&(d.value=k||b),["RADIO","MULTIPLECHOICE"].includes(h)||(d.classList.add("magicfeedback-input"),d.required=f);const w=document.createElement("label");if(w.setAttribute("for",`magicfeedback-${u}`),w.textContent=a(p,i),w.classList.add("magicfeedback-label"),["CONSENT"].includes(h))v.classList.add("magicfeedback-consent-container"),v.appendChild(d),v.appendChild(w);else{if("slim"!==t&&(v.appendChild(w),void 0!==(null==y?void 0:y.general)&&""!==(null==y?void 0:y.general))){const we=document.createElement("img");we.src=y.general,we.classList.add("magicfeedback-image"),we.style.maxWidth="auto",we.style.height="400px",we.style.margin="10px 0",v.appendChild(we)}if("LONGTEXT"===h&&x>0){const Ae=document.createElement("div");if(Ae.classList.add("magicfeedback-counter"),Ae.textContent=`${d.value.length}/${x}`,Ae.style.textAlign="right",Ae.style.fontSize="0.8em",Ae.style.color="#999",Ae.style.marginTop="5px",d.addEventListener("input",(()=>{Ae.textContent=`${d.value.length}/${x}`})),v.appendChild(d),v.appendChild(Ae),y.extraOption&&y.extraOptionText){const Le=document.createElement("div");Le.classList.add("magicfeedback-skip-container"),Le.classList.add("magicfeedback-checkbox-container"),Le.style.display="flex",Le.style.justifyContent="flex-start";const Te=document.createElement("input");Te.classList.add("magicfeedback-skip"),Te.type="checkbox",Te.id=`skip-${m}`,Te.name=m,Te.value="-",Te.style.cursor="pointer";const Se=document.createElement("label");Se.htmlFor=`skip-${m}`,Se.textContent=y.extraOptionText,Se.style.fontSize="0.8em",Se.style.color="#999",Se.style.cursor="pointer",Se.style.margin="0 5px",Te.addEventListener("click",(()=>{d.value="-",o&&o()})),Le.appendChild(Te),Le.appendChild(Se),v.appendChild(Le)}}else v.appendChild(d)}return v}(t,i,o,c);d.push(e)}})),d},t.renderActions=function(e="",t,i="Submit",n="Back",s="Next"){const a=document.createElement("div");a.classList.add("magicfeedback-action-container");const r=document.createElement("button");r.id="magicfeedback-submit",r.type="submit",r.classList.add("magicfeedback-submit"),r.textContent="MAGICSURVEY"===e?s||"Next":i||"Submit";const o=document.createElement("button");return o.id="magicfeedback-back",o.type="button",o.classList.add("magicfeedback-back"),o.textContent=n||"Back",o.addEventListener("click",t),"MAGICSURVEY"===e&&a.appendChild(o),a.appendChild(r),a},t.renderError=function(e){const t=document.createElement("div");return t.classList.add("magicfeedback-error"),t.textContent=e,t},t.renderSuccess=function(e){const t=document.createElement("div");return t.classList.add("magicfeedback-success"),t.textContent=e,t},t.renderStartMessage=function(e,t,i=!1,n="Go!"){const s=document.createElement("div");s.classList.add("magicfeedback-start-message-container");const a=document.createElement("div");a.classList.add("magicfeedback-start-message"),a.innerHTML=e;const r=document.createElement("button");return r.id="magicfeedback-start-message-button",r.classList.add("magicfeedback-start-message-button"),r.textContent=n,r.addEventListener("click",(()=>t())),s.appendChild(a),i&&s.appendChild(r),s}},341:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,a){function r(e){try{c(n.next(e))}catch(e){a(e)}}function o(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,o)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getFollowUpQuestion=t.sendFeedback=t.getQuestions=t.getForm=t.validateEmail=void 0;const a=s(i(98)),r=s(i(147)),o=i(374),c={Accept:"application/json","Magicfeedback-Sdk-Version":r.default.version};t.validateEmail=function(e){return/\S+@\S+\.\S+/.test(e)},t.getForm=function(e,t,i,s){return n(this,void 0,void 0,(function*(){try{const n=yield(0,a.default)(e+o.endpoints.sdk.app_info(t,i),{method:"GET",headers:c});if(n.ok){const e=yield n.json();return s.log(`Received form for app ${t}`,e),e}throw s.err(`Failed to get questions for app ${t}:`,n.status,n.statusText),new Error("[MagicFeedback] Bad response from server")}catch(e){return s.err(e),null}}))},t.getQuestions=function(e,t,i,s){return n(this,void 0,void 0,(function*(){try{const n=yield(0,a.default)(e+o.endpoints.sdk.app(t,i),{method:"GET",headers:c});if(n.ok){const e=yield n.json();return s.log(`Received questions for app ${t}`,e),e}throw s.err(`Failed to get questions for app ${t}:`,n.status,n.statusText),new Error("[MagicFeedback] Bad response from server")}catch(e){return s.err(e),[]}}))},t.sendFeedback=function(e,t,i){return n(this,void 0,void 0,(function*(){try{const n=yield(0,a.default)(e+o.endpoints.sdk.feedback,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},c),body:JSON.stringify(t)});if(n.ok)return i.log(`Form ${t.integration} submitted successfully!`),(yield n.json()).sessionId;throw i.err(`Failed to submit form ${t.integration}:`,n.status,n.statusText),new Error(n.statusText)}catch(e){return i.err(e),""}}))},t.getFollowUpQuestion=function(e,t,i){return n(this,void 0,void 0,(function*(){try{const n=yield(0,a.default)(e+o.endpoints.sdk.followUpQuestion,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},c),body:JSON.stringify(t)});if(n.ok)return i.log(`Received follow up question for form ${t.integration}`),(yield n.json())||"";throw i.err(`Failed to get follow up question for form ${t.integration}:`,n.status,n.statusText),new Error(n.statusText)}catch(e){return i.err(e),""}}))}},5:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Log=void 0,t.Log=class{constructor(e){this.config=e}log(...e){this.config.get("debug")&&console.log("[MagicFeedback]:",...e)}err(...e){console.error("[MagicFeedback]:",...e)}}},147:e=>{"use strict";e.exports=JSON.parse('{"name":"@magicfeedback/native","version":"1.2.8-beta.7","main":"./dist/magicfeedback-sdk.node.js","browser":"./dist/magicfeedback-sdk.browser.js","types":"./dist/types/src/index.d.ts","repository":{"type":"git","url":"git+ssh://git@github.com/MagicFeedback/magicfeedback-sdk.git"},"author":"farias@magicfeedback.io","license":"MIT","private":false,"scripts":{"dev":"vite","build":"webpack","build:watch":"webpack --watch --mode development","publish":"npm publish --access public","publish:beta":"npm publish --access public --tag beta","test":"jest","test:watch":"jest --watchAll","coverage":"vitest run --coverage"},"files":["dist"],"devDependencies":{"@babel/preset-typescript":"^7.22.5","@types/node":"^17.0.21","@types/webpack":"^5.28.0","@types/webpack-node-externals":"^2.5.3","c8":"^7.11.0","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","jest-fetch-mock":"^3.0.3","nock":"^13.2.4","ts-jest":"^29.1.0","ts-loader":"^9.2.7","ts-node":"^10.7.0","typescript":"^4.6.2","vite":"^2.8.0","vite-plugin-dts":"^0.9.9","vitest":"^0.5.9","webpack":"^5.70.0","webpack-cli":"^4.9.2","webpack-node-externals":"^3.0.0"},"dependencies":{"cross-fetch":"^3.1.5","is-bundling-for-browser-or-node":"^1.1.1"},"description":"MagicFeedbackAI JavaScript Library for [MagicFeedback.io](https://magicfeedback.io/)","bugs":{"url":"https://github.com/MagicFeedback/magicfeedback-sdk/issues"},"homepage":"https://github.com/MagicFeedback/magicfeedback-sdk#readme","directories":{"example":"examples","test":"test"}}')}},t={},function i(n){var s=t[n];if(void 0!==s)return s.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,i),a.exports}(607).default;var e,t}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.magicfeedback=t():e.magicfeedback=t()}(self,(()=>{return e={98:function(e,t){var i="undefined"!=typeof self?self:this,a=function(){function e(){this.fetch=!1,this.DOMException=i.DOMException}return e.prototype=i,new e}();!function(e){!function(t){var i="URLSearchParams"in e,a="Symbol"in e&&"iterator"in Symbol,n="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),s="FormData"in e,r="ArrayBuffer"in e;if(r)var o=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],d=ArrayBuffer.isView||function(e){return e&&o.indexOf(Object.prototype.toString.call(e))>-1};function c(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function u(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return a&&(t[Symbol.iterator]=function(){return t}),t}function p(e){this.map={},e instanceof p?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function h(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function m(e){return new Promise((function(t,i){e.onload=function(){t(e.result)},e.onerror=function(){i(e.error)}}))}function f(e){var t=new FileReader,i=m(t);return t.readAsArrayBuffer(e),i}function g(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:n&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:s&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:i&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r&&n&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=g(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r&&(ArrayBuffer.prototype.isPrototypeOf(e)||d(e))?this._bodyArrayBuffer=g(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):i&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},n&&(this.blob=function(){var e=h(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(f)}),this.text=function(){var e,t,i,a=h(this);if(a)return a;if(this._bodyBlob)return e=this._bodyBlob,i=m(t=new FileReader),t.readAsText(e),i;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),i=new Array(t.length),a=0;a<t.length;a++)i[a]=String.fromCharCode(t[a]);return i.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s&&(this.formData=function(){return this.text().then(E)}),this.json=function(){return this.text().then(JSON.parse)},this}p.prototype.append=function(e,t){e=c(e),t=l(t);var i=this.map[e];this.map[e]=i?i+", "+t:t},p.prototype.delete=function(e){delete this.map[c(e)]},p.prototype.get=function(e){return e=c(e),this.has(e)?this.map[e]:null},p.prototype.has=function(e){return this.map.hasOwnProperty(c(e))},p.prototype.set=function(e,t){this.map[c(e)]=l(t)},p.prototype.forEach=function(e,t){for(var i in this.map)this.map.hasOwnProperty(i)&&e.call(t,this.map[i],i,this)},p.prototype.keys=function(){var e=[];return this.forEach((function(t,i){e.push(i)})),u(e)},p.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),u(e)},p.prototype.entries=function(){var e=[];return this.forEach((function(t,i){e.push([i,t])})),u(e)},a&&(p.prototype[Symbol.iterator]=p.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function v(e,t){var i,a,n=(t=t||{}).body;if(e instanceof v){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new p(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,n||null==e._bodyInit||(n=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new p(t.headers)),this.method=(a=(i=t.method||this.method||"GET").toUpperCase(),y.indexOf(a)>-1?a:i),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function E(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var i=e.split("="),a=i.shift().replace(/\+/g," "),n=i.join("=").replace(/\+/g," ");t.append(decodeURIComponent(a),decodeURIComponent(n))}})),t}function k(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new p(t.headers),this.url=t.url||"",this._initBody(e)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},b.call(v.prototype),b.call(k.prototype),k.prototype.clone=function(){return new k(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},k.error=function(){var e=new k(null,{status:0,statusText:""});return e.type="error",e};var x=[301,302,303,307,308];k.redirect=function(e,t){if(-1===x.indexOf(t))throw new RangeError("Invalid status code");return new k(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var i=Error(e);this.stack=i.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function C(e,i){return new Promise((function(a,s){var r=new v(e,i);if(r.signal&&r.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function d(){o.abort()}o.onload=function(){var e,t,i={status:o.status,statusText:o.statusText,headers:(e=o.getAllResponseHeaders()||"",t=new p,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var i=e.split(":"),a=i.shift().trim();if(a){var n=i.join(":").trim();t.append(a,n)}})),t)};i.url="responseURL"in o?o.responseURL:i.headers.get("X-Request-URL");var n="response"in o?o.response:o.responseText;a(new k(n,i))},o.onerror=function(){s(new TypeError("Network request failed"))},o.ontimeout=function(){s(new TypeError("Network request failed"))},o.onabort=function(){s(new t.DOMException("Aborted","AbortError"))},o.open(r.method,r.url,!0),"include"===r.credentials?o.withCredentials=!0:"omit"===r.credentials&&(o.withCredentials=!1),"responseType"in o&&n&&(o.responseType="blob"),r.headers.forEach((function(e,t){o.setRequestHeader(t,e)})),r.signal&&(r.signal.addEventListener("abort",d),o.onreadystatechange=function(){4===o.readyState&&r.signal.removeEventListener("abort",d)}),o.send(void 0===r._bodyInit?null:r._bodyInit)}))}C.polyfill=!0,e.fetch||(e.fetch=C,e.Headers=p,e.Request=v,e.Response=k),t.Headers=p,t.Request=v,t.Response=k,t.fetch=C,Object.defineProperty(t,"__esModule",{value:!0})}({})}(a),a.fetch.ponyfill=!0,delete a.fetch.polyfill;var n=a;(t=n.fetch).default=n.fetch,t.fetch=n.fetch,t.Headers=n.Headers,t.Request=n.Request,t.Response=n.Response,e.exports=t},290:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HOST_API_URL_DEV=t.HOST_API_URL=void 0,t.HOST_API_URL="https://api.magicfeedback.io/",t.HOST_API_URL_DEV="https://api-dev.magicfeedback.io/"},607:function(e,t,i){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=a(i(519));let s=null;s||(s=(0,n.default)()),t.default=s},519:function(e,t,i){"use strict";var a=this&&this.__awaiter||function(e,t,i,a){return new(i||(i=Promise))((function(n,s){function r(e){try{d(a.next(e))}catch(e){s(e)}}function o(e){try{d(a.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,o)}d((a=a.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const n=i(954),s=i(712),r=i(5),o=i(341),d=i(290);t.default=function(){const e=new s.Config;let t;return{init:function(i){(null==i?void 0:i.debug)&&e.set("debug",null==i?void 0:i.debug),e.set("url",(null==i?void 0:i.env)&&"dev"===(null==i?void 0:i.env)?d.HOST_API_URL_DEV:d.HOST_API_URL),t=new r.Log(e),t.log("Initialized Magicfeedback",e)},send:function(i,n,s,r=!0,d,c){return a(this,void 0,void 0,(function*(){i||t.err("No appID provided"),n||t.err("No publicKey provided"),s||t.err("No feedback provided"),s.answers||s.profile||s.metrics||s.metadata||t.err("No feedback data provided");const a=e.get("url"),l={integration:i,publicKey:n,privateKey:c,completed:r,id:d,feedback:s};try{const e=yield(0,o.sendFeedback)(a,l,t);return t.log("sent native feedback"),e}catch(e){return t.err("error native feedback",e),!1}}))},form:function(i,a){return i||t.err("No appID provided"),a||t.err("No publicKey provided"),new n.Form(e,i,a)}}}},314:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.History=void 0,t.History=class{constructor(){this.items=[]}enqueue(e){this.items.push(e)}dequeue(){return this.items.shift()}rollback(){return this.items.pop()}front(){return this.items[0]}back(){return this.items[this.items.length-1]}isEmpty(){return 0===this.items.length}size(){return this.items.length}}},712:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Config=void 0,t.Config=class{constructor(){this.variables={},this.variables.env="prod",this.variables.debug=!1}get(e){return this.variables[e]}set(e,t){this.variables[e]=t}}},954:function(e,t,i){"use strict";var a=this&&this.__awaiter||function(e,t,i,a){return new(i||(i=Promise))((function(n,s){function r(e){try{d(a.next(e))}catch(e){s(e)}}function o(e){try{d(a.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,o)}d((a=a.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.Form=void 0;const n=i(5),s=i(341),r=i(183),o=i(24),d=i(804),c=i(116),l=i(314),u=i(457);t.Form=class{constructor(e,t,i){this.config=e,this.log=new n.Log(e),this.formOptionsConfig={addButton:!0,sendButtonText:"Send",backButtonText:"Back",nextButtonText:"Next",addSuccessScreen:!0,getMetaData:!0,questionFormat:"standard"},this.selector="",this.appId=t,this.publicKey=i,this.url=e.get("url"),this.id="",this.formData=null,this.getDataFromStorage(),this.feedback={text:"",answers:[],profile:[],metrics:[],metadata:[]},this.history=new l.History,this.graph=new o.PageGraph([]),this.progress=0,this.total=0}getDataFromStorage(){const e=localStorage.getItem(`magicfeedback-${this.appId}`);e&&new Date(JSON.parse(e).savedAt)<new Date((new Date).getTime()+864e5)&&(this.formData=JSON.parse(e),(0,s.getForm)(this.url,this.appId,this.publicKey,this.log).then((e=>{var t,i,a;(null==e?void 0:e.updatedAt)&&(null===(t=this.formData)||void 0===t?void 0:t.savedAt)&&(null==e?void 0:e.updatedAt)>(null===(i=this.formData)||void 0===i?void 0:i.savedAt)&&(console.log("Form updated"),this.formData=e,this.formData.savedAt=new Date,localStorage.setItem(`magicfeedback-${this.appId}`,JSON.stringify(this.formData)),(null===(a=this.formData.style)||void 0===a?void 0:a.startMessage)?this.generateWelcomeMessage(this.formData.style.startMessage):this.startForm())})))}generate(e,t){var i,n,r;return a(this,void 0,void 0,(function*(){try{if(this.formOptionsConfig=Object.assign(Object.assign({},this.formOptionsConfig),t),this.selector=e,void 0!==this.formData&&this.formData||(this.formData=yield(0,s.getForm)(this.url,this.appId,this.publicKey,this.log)),void 0===this.formData||!this.formData)throw new Error(`No form for app ${this.appId}`);if(this.formData.savedAt||(this.formData.savedAt=new Date,localStorage.setItem(`magicfeedback-${this.appId}`,JSON.stringify(this.formData))),void 0===this.formData.questions||!this.formData.questions)throw new Error(`No questions for app ${this.appId}`);0===(null===(i=this.formData.pages)||void 0===i?void 0:i.length)&&this.formatPages(),null===(n=this.formData.questions)||void 0===n||n.sort(((e,t)=>e.position-t.position)),this.formOptionsConfig.getMetaData&&this.getMetaData(),(null===(r=this.formData.style)||void 0===r?void 0:r.startMessage)?yield this.generateWelcomeMessage(this.formData.style.startMessage):this.startForm()}catch(e){return this.log.err(e),void(this.formOptionsConfig.onLoadedEvent&&(yield this.formOptionsConfig.onLoadedEvent({loading:!1,error:e})))}}))}formatPages(){var e;if(this.formData)switch(this.formData.identity){case"MAGICSURVEY":this.formData.pages=[],null===(e=this.formData.questions)||void 0===e||e.forEach((e=>{var t,i;const a=new c.PageRoute(e.id,e.ref,c.OperatorType.NOEQUAL,null,c.TransitionType.PAGE,(e.position+1).toString(),e.position.toString()),n=new d.Page(e.position.toString(),e.position,this.appId,[e],[a]);null===(i=null===(t=this.formData)||void 0===t?void 0:t.pages)||void 0===i||i.push(n)}));break;case"MAGICFORM":const t=new d.Page("1",1,this.appId,this.formData.questions,[]);this.formData.pages=[t]}}generateContainer(){let e=document.getElementById(this.selector);if(!e&&(e=document.getElementById("magicfeedback-container-"+this.appId),!e))throw new Error(`Element with ID '${this.selector}' not found.`);return e.classList.add("magicfeedback-container"),e.id="magicfeedback-container-"+this.appId,e.innerHTML="",e}generateForm(){var e,t,i,n;return a(this,void 0,void 0,(function*(){try{if(this.formData&&(null===(e=this.formData.pages)||void 0===e?void 0:e.length)>0){this.graph=new o.PageGraph(this.formData.pages.sort(((e,t)=>e.position-t.position)));let e=this.generateContainer();const a=document.createElement("form");a.classList.add("magicfeedback-form"),a.id="magicfeedback-"+this.appId;const s=document.createElement("div");s.classList.add("magicfeedback-questions"),s.id="magicfeedback-questions-"+this.appId;const d=this.graph.getFirstPage();if(!d)throw new Error("No page found");if(this.total=this.graph.findMaxDepth(),d.elements=(0,r.renderQuestions)(d.questions,this.formOptionsConfig.questionFormat,null===(t=this.formData)||void 0===t?void 0:t.lang[0],(()=>this.send())),null===(i=d.elements)||void 0===i||i.forEach((e=>s.appendChild(e))),a.appendChild(s),this.history.enqueue(d),e.appendChild(a),this.formOptionsConfig.addButton){const e=(0,r.renderActions)(null===(n=this.formData)||void 0===n?void 0:n.identity,(()=>this.back()),this.formOptionsConfig.sendButtonText,this.formOptionsConfig.backButtonText,this.formOptionsConfig.nextButtonText);a.appendChild(e)}a.addEventListener("submit",(e=>{e.preventDefault(),this.send()})),this.formOptionsConfig.onLoadedEvent&&(yield this.formOptionsConfig.onLoadedEvent({loading:!1,progress:this.progress,total:this.total,formData:this.formData}))}}catch(e){return this.log.err(e),void(this.formOptionsConfig.onLoadedEvent&&this.formOptionsConfig.onLoadedEvent({loading:!1,error:e}))}}))}startForm(){this.generateForm()}generateWelcomeMessage(e){return a(this,void 0,void 0,(function*(){try{const t=this.generateContainer(),i=(0,r.renderStartMessage)(e,(()=>this.startForm()),this.formOptionsConfig.addButton,this.formOptionsConfig.startButtonText);t.appendChild(i),this.formOptionsConfig.onLoadedEvent&&(yield this.formOptionsConfig.onLoadedEvent({loading:!1,formData:this.formData}))}catch(e){return this.log.err(e),void(this.formOptionsConfig.onLoadedEvent&&this.formOptionsConfig.onLoadedEvent({loading:!1,error:e}))}}))}getMetaData(){this.feedback.metadata.push({key:"navigator-url",value:[window.location.href]}),this.feedback.metadata.push({key:"navigator-origin",value:[window.location.origin]}),this.feedback.metadata.push({key:"navigator-pathname",value:[window.location.pathname]}),this.feedback.metadata.push({key:"navigator-search",value:[window.location.search]}),this.feedback.metadata.push({key:"navigator-user",value:[navigator.userAgent]}),this.feedback.metadata.push({key:"navigator-language",value:[navigator.language]}),this.feedback.metadata.push({key:"navigator-platform",value:[navigator.platform]}),this.feedback.metadata.push({key:"navigator-appVersion",value:[navigator.appVersion]}),this.feedback.metadata.push({key:"navigator-appName",value:[navigator.appName]}),this.feedback.metadata.push({key:"navigator-product",value:[navigator.product]}),this.feedback.metadata.push({key:"screen-width",value:[window.screen.width.toString()]}),this.feedback.metadata.push({key:"screen-height",value:[window.screen.height.toString()]})}send(e,t,i){var n;return a(this,void 0,void 0,(function*(){const a=document.getElementById("magicfeedback-questions-"+this.appId);try{i&&(this.feedback.profile=[...this.feedback.profile,...i]),t&&(this.feedback.metrics=[...this.feedback.metrics,...t]),e&&(this.feedback.metadata=[...this.feedback.metadata,...e]),this.answer(),this.formOptionsConfig.beforeSubmitEvent&&(yield this.formOptionsConfig.beforeSubmitEvent({loading:!0,progress:this.progress,total:this.total}));const s=this.history.back();if(!s)throw new Error("No page found");const r=s.getRequiredQuestions();for(const e of r)if(!this.feedback.answers.find((t=>t.key===e&&t.value.length>0)))return void this.log.err(`The question ${e} is required`);const o=yield this.pushAnswers("MAGICSURVEY"!==(null===(n=this.formData)||void 0===n?void 0:n.identity));o&&(this.id=o,yield this.processNextQuestion(a)),this.formOptionsConfig.afterSubmitEvent&&(yield this.formOptionsConfig.afterSubmitEvent({response:o,loading:!1,progress:this.progress,total:this.total,error:o?null:new Error("No response")}))}catch(e){this.log.err(`An error occurred while submitting the form ${this.appId}:`,e),this.formOptionsConfig.afterSubmitEvent&&(yield this.formOptionsConfig.afterSubmitEvent({loading:!1,progress:this.progress,total:this.total,error:e}))}}))}answer(){const e=document.getElementById("magicfeedback-"+this.appId);if(!e)return this.log.err(`Form "${e}" not found.`),void(this.feedback.answers=[]);const t=[];let i=!1;const a=e.querySelectorAll(".magicfeedback-input");a.forEach((e=>{const n=e.type,r=e.classList[0],o={key:e.name,value:[]},d="magicfeedback-consent"===r?e.checked.toString():e.value;if(o.key&&""!==o.key)switch(n){case"radio":case"checkbox":if("magicfeedback-consent"===r||e.checked){if(e.id.includes("matrix")){const t=e.id.split("-")[e.id.split("-").length-1];let i="";a.forEach((e=>{e.checked&&e.id.includes(`matrix-${t}`)&&(i+=e.value+", ")})),i=i.slice(0,-2),o.value.push(`${t}: ${i}`)}else o.value.push(d);const i=t.findIndex((e=>e.key===o.key));-1!==i?t[i].value=[...t[i].value,...o.value]:t.push(o)}break;default:if(""!==d){if("email"===n){if(!(0,s.validateEmail)(d)){this.log.err("Invalid email"),i=!0;break}this.feedback.profile.push({key:"email",value:[d]})}if(e.id.includes("point-system")){const t=e.id.split("-")[e.id.split("-").length-1];o.value.push(`${t}: ${d}%`)}else o.value.push(d);const a=t.findIndex((e=>e.key===o.key));-1!==a?t[a].value=[...t[a].value,...o.value]:t.push(o)}}})),this.feedback.answers=i?[]:t}finish(){if(this.formOptionsConfig.addSuccessScreen){const e=document.getElementById("magicfeedback-container-"+this.appId);e.childNodes.length>0&&e.removeChild(e.childNodes[0]);const t=(0,r.renderSuccess)(this.formOptionsConfig.successMessage||"Thank you for your feedback!");e.appendChild(t)}this.answer(),this.pushAnswers(!0)}pushAnswers(e=!1){return a(this,void 0,void 0,(function*(){try{const t=this.config.get("url"),i={integration:this.appId,publicKey:this.publicKey,feedback:this.feedback,completed:e};return yield(0,s.sendFeedback)(t,this.id?Object.assign(Object.assign({},i),{sessionId:this.id}):i,this.log)}catch(e){return this.log.err(`An error occurred while submitting the form ${this.appId}:`,e),""}}))}callFollowUpQuestion(e){var t;return a(this,void 0,void 0,(function*(){if(!(null==e?void 0:e.followup))return null;try{if(0===this.feedback.answers.length)throw new Error("No answers provided");const i=this.config.get("url"),a={answer:null===(t=this.feedback.answers.find((t=>t.key===e.ref)))||void 0===t?void 0:t.value[0],publicKey:this.publicKey,sessionId:this.id,question:e};return yield(0,s.getFollowUpQuestion)(i,a,this.log)}catch(e){throw this.log.err(`An error occurred while submitting the form ${this.appId}:`,e),e}}))}processNextQuestion(e){var t,i;return a(this,void 0,void 0,(function*(){const a=this.history.back();if(!a)throw new Error("No page found");const n=a.getFollowupQuestions();if((null==n?void 0:n.length)>0){const s=[];for(const e of n){const t=a.questions.find((t=>t.ref===e));if(t){const e=yield this.callFollowUpQuestion(t);e&&s.push(e)}}if(s.length>0){const n=new d.Page(a.id,a.position,this.appId,s,a.edges),o=new u.PageNode(a.id,a.position,a.edges,n,s);o.elements=(0,r.renderQuestions)(s,this.formOptionsConfig.questionFormat,null===(t=this.formData)||void 0===t?void 0:t.lang[0],(()=>this.send())),this.history.enqueue(o),e.removeChild(e.childNodes[0]),null===(i=o.elements)||void 0===i||i.forEach((t=>e.appendChild(t)))}else this.renderNextQuestion(e,a)}else this.renderNextQuestion(e,a)}))}renderNextQuestion(e,t){var i,a;const n=this.graph.getNextPage(t,this.feedback.answers);n?(this.progress=this.total-this.graph.findDepth(n.id),n.elements=(0,r.renderQuestions)(n.questions,this.formOptionsConfig.questionFormat,null===(i=this.formData)||void 0===i?void 0:i.lang[0],(()=>this.send())),e.removeChild(e.childNodes[0]),null===(a=n.elements)||void 0===a||a.forEach((t=>e.appendChild(t))),this.history.enqueue(n)):this.finish()}back(){var e;if(0===this.history.size())return;console.log("Back",this.history);const t=document.getElementById("magicfeedback-questions-"+this.appId);t&&t.childNodes.length>0&&t.removeChild(t.childNodes[0]),this.history.rollback();const i=this.history.back();i&&(null===(e=i.elements)||void 0===e||e.forEach((e=>t.appendChild(e))))}}},804:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Page=void 0,t.Page=class{constructor(e,t,i,a,n){this.id=e,this.position=t,this.generatedAt=(new Date).toISOString(),this.updatedAt=(new Date).getTime(),this.status="ACTIVE",this.integrationId=i,this.integrationQuestions=a,this.integrationPageRoutes=n}}},24:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PageGraph=void 0;const a=i(457),n=i(116);t.PageGraph=class{constructor(e){this.nodes=new Map,this.buildGraph(e)}buildGraph(e){e.forEach((e=>{const t=new a.PageNode(e.id,e.position,e.integrationPageRoutes||[],e,e.integrationQuestions);this.nodes.set(t.id,t)}))}getNodeById(e){return this.nodes.get(e)}getNextEdgeByDefault(e){if(e)for(const t of this.nodes.values())if(t.position===e.position+1)return t.id}getFirstPage(){let e,t=Number.MAX_VALUE;for(const i of this.nodes.values())i.position<t&&(t=i.position,e=i);return e}getNextPage(e,t){if(!e)return;const i=e.edges.find((e=>{const i=null==t?void 0:t.filter((t=>t.key===e.questionRef));if(!i)return!1;switch(e.typeOperator){case n.OperatorType.EQUAL:return i.find((t=>{var i;return null===(i=t.value)||void 0===i?void 0:i.includes(e.value)}));case n.OperatorType.NOEQUAL:return!i.find((t=>{var i;return null===(i=t.value)||void 0===i?void 0:i.includes(e.value)}));case n.OperatorType.GREATER:return i.find((t=>t.value.find((t=>Number(t)>Number(e.value)))));case n.OperatorType.LESS:return i.find((t=>t.value.find((t=>Number(t)<Number(e.value)))));case n.OperatorType.GREATEREQUAL:return console.log(i),i.find((t=>t.value.find((t=>Number(t)>=Number(e.value)))));case n.OperatorType.LESSEQUAL:return i.find((t=>t.value.find((t=>Number(t)<=Number(e.value)))));case n.OperatorType.INQ:return i.find((t=>e.value.includes(t.value)));case n.OperatorType.NINQ:return!i.find((t=>e.value.includes(t.value)));default:return!1}}));if(!i){const t=this.getNextEdgeByDefault(e);if(!t)return;return this.getNodeById(t)}return this.getNodeById(i.transitionDestiny)}findDepth(e){const t=this.getNodeById(e);if(!t)return 0;const i=new Set;return this.DFSUtil(t,i,0)}findMaxDepth(){const e=new Set;let t=0;return this.nodes.forEach((i=>{e.has(i)||(t=Math.max(t,this.DFSUtil(i,e,0)))})),t}DFSUtil(e,t,i){t.add(e);let a=i;const n=this.getNextEdgeByDefault(e);for(const s of n?[...e.edges,{transitionDestiny:n}]:e.edges){const e=this.getNodeById(s.transitionDestiny);e&&!t.has(e)&&(a=Math.max(a,this.DFSUtil(e,t,i+1)))}return a}}},457:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PageNode=void 0,t.PageNode=class{constructor(e,t,i,a,n){this.id=e,this.position=t,this.edges=i,this.data=a,this.questions=n,this.elements=[]}getFollowupQuestions(){return this.questions.filter((e=>e.followup)).map((e=>e.ref))}getRequiredQuestions(){return this.questions.filter((e=>e.require)).map((e=>e.ref))}}},116:(e,t)=>{"use strict";var i,a,n,s;Object.defineProperty(t,"__esModule",{value:!0}),t.PageRoute=t.OperatorType=t.ConditionType=t.TransitionType=void 0,(s=t.TransitionType||(t.TransitionType={})).PAGE="PAGE",s.FINISH="FINISH",function(e){e.LOGICAL="LOGICAL"}(i=t.ConditionType||(t.ConditionType={})),(n=t.OperatorType||(t.OperatorType={})).EQUAL="EQUAL",n.NOEQUAL="NOEQUAL",n.GREATER="GREATER",n.LESS="LESS",n.GREATEREQUAL="GREATEREQUAL",n.LESSEQUAL="LESSEQUAL",n.INQ="INQ",n.NINQ="NINQ",n.DEFAULT="DEFAULT",function(e){e.ACTIVE="ACTIVE",e.DEPRECATED="DEPRECATED",e.DELETE="DELETE"}(a||(a={})),t.PageRoute=class{constructor(e,t,n,s,r,o,d){this.id=e,this.questionRef=t,this.typeCondition=i.LOGICAL,this.typeOperator=n,this.value=s,this.transition=r,this.transitionDestiny=o,this.status=a.ACTIVE,this.generatedAt=new Date,this.updatedAt=new Date,this.integrationPageId=d}}},244:(e,t)=>{"use strict";var i,a;Object.defineProperty(t,"__esModule",{value:!0}),t.QuestionType=t.FEEDBACKAPPANSWERTYPE=void 0,(a=t.FEEDBACKAPPANSWERTYPE||(t.FEEDBACKAPPANSWERTYPE={})).CONTACT="CONTACT",a.MULTIPLECHOISE_IMAGE="MULTIPLECHOISE_IMAGE",a.EMAIL="EMAIL",a.RATING_STAR="RATING_STAR",a.RADIO="RADIO",a.MULTIPLECHOICE="MULTIPLECHOICE",a.SELECT="SELECT",a.TEXT="TEXT",a.LONGTEXT="LONGTEXT",a.NUMBER="NUMBER",a.RATING_EMOJI="RATING_EMOJI",a.RATING_NUMBER="RATING_NUMBER",a.DATE="DATE",a.BOOLEAN="BOOLEAN",a.PASSWORD="PASSWORD",a.CONSENT="CONSENT",a.MULTI_QUESTION_MATRIX="MULTI_QUESTION_MATRIX",a.POINT_SYSTEM="POINT_SYSTEM",a.PRIORITY_LIST="PRIORITY_LIST",t.QuestionType=class{},function(e){e.FORM="form",e.DIV="div"}(i||(i={}))},374:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.endpoints=void 0,t.endpoints={sdk:{app:(e,t)=>`sdk/app/${e}/${t}`,app_info:(e,t)=>`sdk/app/${e}/${t}/info`,feedback:"sdk/feedback",followUpQuestion:"sdk/followUpQuestion"}}},528:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.placeholder=void 0,t.placeholder={answer:e=>{switch(e){case"en":default:return"Write your answer here...";case"es":return"Escribe tu respuesta aquí...";case"da":return"Skriv dit svar her...";case"fi":return"Kirjoita vastauksesi tähän...";case"sv":return"Skriv ditt svar här...";case"no":return"Skriv svaret ditt her...";case"ar":return"اكتب إجابتك هنا...";case"bn":return"এখানে আপনার"}},number:e=>{switch(e){case"en":default:return"Write your number here...";case"es":return"Escribe tu número aquí...";case"da":return"Skriv dit nummer her...";case"fi":return"Kirjoita numerosi tähän...";case"sv":return"Skriv ditt nummer här...";case"no":return"Skriv nummeret ditt her...";case"ar":return"اكتب رقمك هنا...";case"bn":return"এখানে আপনার"}},email:e=>{switch(e){case"en":default:return"Write your email here...";case"es":return"Escribe tu correo electrónico aquí...";case"da":return"Skriv din e-mail her...";case"fi":return"Kirjoita sähköpostiosoitteesi tähän...";case"sv":return"Skriv din e-post här...";case"no":return"Skriv e-posten din her...";case"ar":return"اكتب بريدك الإلكتروني هنا...";case"bn":return"এখানে আপনার"}},date:e=>{switch(e){case"en":default:return"Write your date here...";case"es":return"Escribe tu fecha aquí...";case"da":return"Skriv din dato her...";case"fi":return"Kirjoita päivämääräsi tähän...";case"sv":return"Skriv ditt datum här...";case"no":return"Skriv datoen din her...";case"ar":return"اكتب تاريخك هنا...";case"bn":return"এখানে আপনার"}},password:e=>{switch(e){case"en":default:return"Write your password here...";case"es":return"Escribe tu contraseña aquí...";case"da":return"Skriv dit kodeord her...";case"fi":return"Kirjoita salasanasi tähän...";case"sv":return"Skriv ditt lösenord här...";case"no":return"Skriv passordet ditt her...";case"ar":return"اكتب كلمة المرور الخاصة بك هنا...";case"bn":return"এখানে আপনার"}}}},183:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.renderStartMessage=t.renderSuccess=t.renderError=t.renderActions=t.renderQuestions=void 0;const a=i(244),n=i(528);function s(e,t){return"object"==typeof e?e[t]||e.en:e}function r(e,t,i,a,n,s=!0){const r=document.createElement("div");r.classList.add("magicfeedback-rating-placeholder"),r.style.display="flex",r.style.justifyContent="space-between",r.style.width=n?`calc(100% - (100% / ${t+1}))`:"100%",r.style.marginRight="auto",s&&window.innerWidth<600&&(r.style.flexDirection="column");const o=document.createElement("span");o.textContent=i,o.classList.add("magicfeedback-rating-placeholder-value"),o.style.fontStyle="italic",o.style.fontSize="14px",o.style.textAlign="left",o.style.width="50%",s&&window.innerWidth<600&&(o.textContent=`${e} ➜ ${i}`,o.style.width="100%",o.style.textAlign="left",o.style.marginBottom="5px"),r.appendChild(o);const d=document.createElement("span");return d.textContent=a,d.classList.add("magicfeedback-rating-placeholder-value"),d.style.fontStyle="italic",d.style.fontSize="14px",d.style.textAlign="right",d.style.width="50%",s&&window.innerWidth<600&&(d.textContent=`${t} ➜ ${a}`,d.style.width="100%",d.style.textAlign="left",d.style.marginBottom="5px"),r.appendChild(d),r}t.renderQuestions=function e(t,i="standard",o="en",d){if(!t)throw new Error("[MagicFeedback] No questions provided");const c=[];return t.forEach((t=>{var l,u;if((null===(u=null===(l=null==t?void 0:t.questionType)||void 0===l?void 0:l.conf)||void 0===u?void 0:u.length)>0){let a=document.createElement("div");a.classList.add("magicfeedback-div"),t.questionType.conf.forEach((e=>{e.ref=t.ref,t.assets[e.id]&&(e.assets={placeholder:t.assets[e.id]})})),e(t.questionType.conf,i,o,d).forEach((e=>{a.appendChild(e)})),c.push(a)}else{const e=function(e,t,i,o){var d;let c,l,{id:u,title:p,type:h,ref:m,require:f,value:g,defaultValue:b,assets:y}=e,v=document.createElement("div");v.classList.add("magicfeedback-div");const E="slim"===t?s(p,i):null==y?void 0:y.placeholder,k=(C=u,new URLSearchParams(window.location.search).get(C)),x=y.maxCharacters||300;var C;switch(h){case a.FEEDBACKAPPANSWERTYPE.TEXT:c=document.createElement("input"),c.type="text",c.placeholder=E||n.placeholder.answer(i||"en"),l="magicfeedback-text";break;case a.FEEDBACKAPPANSWERTYPE.LONGTEXT:c=document.createElement("textarea"),c.rows=3,x>0&&(c.maxLength=x),c.placeholder=E||n.placeholder.answer(i||"en"),l="magicfeedback-longtext";break;case a.FEEDBACKAPPANSWERTYPE.NUMBER:c=document.createElement("input"),c.type="number",c.placeholder="slim"===t?s(p,i):n.placeholder.number(i||"en"),l="magicfeedback-number",g.length&&(g.sort(((e,t)=>Number(e)-Number(t))),c.max=g[g.length-1],c.min=g[0],c.value=g[0]);break;case a.FEEDBACKAPPANSWERTYPE.RADIO:case a.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE:c=document.createElement("div"),l="magicfeedback-"+("MULTIPLECHOICE"===h?"checkbox":"radio"),y.extraOption&&g.push(y.extraOptionText),g.forEach(((e,t)=>{const s=document.createElement("div");s.classList.add(`magicfeedback-${"MULTIPLECHOICE"===h?"checkbox":"radio"}-container`);const r=document.createElement("label"),o=document.createElement("input");if(o.id=`rating-${m}-${t}`,o.type="MULTIPLECHOICE"===h?"checkbox":"radio",o.name=m,o.value=e,o.classList.add(l),o.classList.add("magicfeedback-input"),h===a.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE&&y.maxOptions&&y.maxOptions>0&&o.addEventListener("change",(()=>{document.querySelectorAll(`input[name="${m}"]:checked`).length>y.maxOptions&&(o.checked=!1)})),e!==b&&e!==k||(o.checked=!0),r.textContent=e,r.htmlFor=`rating-${m}-${t}`,o.addEventListener("change",(t=>{const i=document.getElementById(`extra-option-${m}`);i&&y.extraOption&&(t.target.checked&&e===y.extraOptionText?i.style.display="block":i.style.display="none")})),s.appendChild(o),s.appendChild(r),c.appendChild(s),y.extraOption&&e===y.extraOptionText){const e=document.createElement("input");e.type="text",e.placeholder=y.extraOptionPlaceholder||n.placeholder.answer(i||"en"),e.classList.add("magicfeedback-extra-option"),e.classList.add("magicfeedback-input"),e.id=`extra-option-${m}`,e.name=`extra-option-${m}`,e.style.display="none",c.appendChild(e)}}));break;case a.FEEDBACKAPPANSWERTYPE.BOOLEAN:c=document.createElement("div"),l="magicfeedback-radio";const A=document.createElement("div");A.classList.add("magicfeedback-boolean-container"),A.style.display="flex",A.style.flexDirection="row",A.style.justifyContent="space-between",A.style.width="70%",A.style.margin="auto",(y.addIcon?["👍","👎"]:function(e){switch(e){case"es":return["Sí","No"];case"fr":return["Oui","Non"];case"de":return["Ja","Nein"];case"it":return["Sì","No"];case"pt":return["Sim","Não"];case"nl":return["Ja","Nee"];case"pl":return["Tak","Nie"];case"ru":return["Да","Нет"];case"ja":return["はい","いいえ"];case"zh":return["是","不"];case"ko":return["예","아니"];case"da":case"sv":return["Ja","Nej"];case"fi":return["Kyllä","Ei"];case"no":return["Ja","Nei"];case"ar":return["نعم","لا"];case"bn":return["হ্যাঁ","না"];default:return["Yes","No"]}}(i)).forEach(((e,t)=>{const i=document.createElement("label");i.classList.add("magicfeedback-boolean-option"),i.htmlFor=`rating-${m}-${t}`,i.style.cursor="pointer",i.style.border="1px solid #000",i.style.display="flex",i.style.justifyContent="center",i.style.alignItems="center",i.style.margin="auto",i.style.padding="0",i.style.width="45%",i.style.height="38px";const a=document.createElement("label");a.htmlFor=`rating-${m}-${t}`,a.textContent=e,a.style.margin="0",a.style.padding="0";const n=document.createElement("input");n.id=`rating-${m}-${t}`,n.type="radio",n.name=m,n.value=e,n.classList.add(l),n.classList.add("magicfeedback-input"),n.style.position="absolute",n.style.opacity="0",n.style.width="0",n.style.height="0",n.style.margin="0",n.addEventListener("change",(()=>{o&&o()})),i.appendChild(n),i.appendChild(a),A.appendChild(i)})),c.appendChild(A);break;case a.FEEDBACKAPPANSWERTYPE.RATING_EMOJI:c=document.createElement("div"),l="magicfeedback-rating";const T=document.createElement("div");T.classList.add("magicfeedback-rating-container");const L=y.max?Number(y.max):5,O=y.min?Number(y.min):1,S=r(O,L,y.minPlaceholder,y.maxPlaceholder,y.extraOption);for(let ae=O;ae<=L;ae++){const ne=document.createElement("div");ne.classList.add("magicfeedback-rating-option");const se=document.createElement("label");se.htmlFor=`rating-${m}-${ae}`,se.classList.add("magicfeedback-rating-option-label-container");const re=document.createElement("label");re.htmlFor=`rating-${m}-${ae}`,re.textContent=ae.toString();const oe=document.createElement("img");if(oe.alt=`face-${m}-${ae}`,oe.className=`rating-image${ae}`,0===O&&10===L)oe.src=`https://magicfeedback-c6458-dev.web.app/assets/${ae}.svg`;else if(1===O&&5===L)switch(ae){case 1:oe.src="https://magicfeedback-c6458-dev.web.app/assets/1.svg";break;case 2:oe.src="https://magicfeedback-c6458-dev.web.app/assets/2.svg";break;case 3:oe.src="https://magicfeedback-c6458-dev.web.app/assets/6.svg";break;case 4:oe.src="https://magicfeedback-c6458-dev.web.app/assets/9.svg";break;case 5:oe.src="https://magicfeedback-c6458-dev.web.app/assets/10.svg"}else{const ce=Math.round(10/(L-O)*(ae-O));oe.src=`https://magicfeedback-c6458-dev.web.app/assets/${ce}.svg`}const de=document.createElement("input");de.id=`rating-${m}-${ae}`,de.type="radio",de.name=m,de.value=ae.toString(),de.classList.add(l),de.classList.add("magicfeedback-input"),se.appendChild(de),se.appendChild(oe),se.appendChild(re),ne.appendChild(se),T.appendChild(ne)}if(y.extraOption&&y.extraOptionText){const le=document.createElement("div");le.classList.add("magicfeedback-rating-option");const ue=document.createElement("label");ue.htmlFor=`rating-${m}-extra`,ue.classList.add("magicfeedback-rating-option-label-container");const pe=document.createElement("label");pe.htmlFor=`rating-${m}-extra`,pe.textContent=y.extraOptionText;const he=document.createElement("img");he.src="https://magicfeedback-c6458-dev.web.app/assets/question.svg",he.alt=`face-${m}-extra`,he.className="magicfeedback-rating-image-extra";const me=document.createElement("input");me.id=`rating-${m}-extra`,me.type="radio",me.name=m,me.value="-",me.classList.add(l),me.classList.add("magicfeedback-input"),ue.appendChild(me),ue.appendChild(he),ue.appendChild(pe),le.appendChild(ue),T.appendChild(le)}c.appendChild(S),c.appendChild(T);break;case a.FEEDBACKAPPANSWERTYPE.RATING_NUMBER:c=document.createElement("div"),l="magicfeedback-rating-number";const P=document.createElement("div");P.classList.add("magicfeedback-rating-number-container");const I=y.max?Number(y.max):5,N=y.min?Number(y.min):1,D=r(N,I,y.minPlaceholder,y.maxPlaceholder,y.extraOption);for(let fe=N;fe<=I;fe++){const ge=document.createElement("div");ge.classList.add("magicfeedback-rating-number-option");const be=document.createElement("label");be.htmlFor=`rating-${m}-${fe}`,be.classList.add("magicfeedback-rating-number-option-label-container");const ye=document.createElement("label");ye.htmlFor=`rating-${m}-${fe}`,ye.textContent=fe.toString();const ve=document.createElement("input");ve.id=`rating-${m}-${fe}`,ve.type="radio",ve.name=m,ve.value=fe.toString(),ve.classList.add(l),ve.classList.add("magicfeedback-input"),be.appendChild(ve),be.appendChild(ye),ge.appendChild(be),P.appendChild(ge)}if(y.extraOption&&y.extraOptionText){const Ee=document.createElement("div");Ee.classList.add("magicfeedback-rating-number-option");const ke=document.createElement("label");ke.htmlFor=`rating-${m}-extra`,ke.classList.add("magicfeedback-rating-number-option-label-container");const xe=document.createElement("label");xe.htmlFor=`rating-${m}-extra`,xe.textContent=y.extraOptionText;const Ce=document.createElement("input");Ce.id=`rating-${m}-extra`,Ce.type="radio",Ce.name=m,Ce.value="-",Ce.classList.add(l),Ce.classList.add("magicfeedback-input"),ke.appendChild(Ce),ke.appendChild(xe),Ee.appendChild(ke),P.appendChild(Ee)}c.appendChild(D),c.appendChild(P);break;case a.FEEDBACKAPPANSWERTYPE.RATING_STAR:c=document.createElement("div"),l="magicfeedback-rating-star";const _=function(e,t,i){const a="magicfeedback-rating-star-selected",n=document.createElement("div");n.classList.add("magicfeedback-rating-star-container"),n.style.maxWidth="300px",n.style.margin="auto";for(let t=1;t<=5;t++){const i=document.createElement("label");i.classList.add("magicfeedback-rating-star-option");const s=document.createElement("input");s.id=`rating-${e}-${t}`,s.type="radio",s.name=e,s.value=t.toString(),s.style.position="absolute",s.style.opacity="0",s.style.width="0",s.style.height="0",s.classList.add("magicfeedback-input"),s.addEventListener("change",(()=>{const e=n.querySelectorAll(".rating__star");for(let t=0;t<e.length;t++)t+1<=Number(s.value)?e[t].classList.contains(a)||e[t].classList.add(a):e[t].classList.contains(a)&&e[t].classList.remove(a)})),i.appendChild(s);const r=document.createElement("label");r.htmlFor=`rating-${e}-${t}`,r.classList.add("rating__star"),r.textContent="★",r.style.fontSize="40px",r.style.color="#CCCCCC",r.style.cursor="pointer",i.appendChild(r),n.appendChild(i)}return n.appendChild(r(1,5,t,i,!1,!1)),n}(m,y.minPlaceholder,y.maxPlaceholder);c.appendChild(_);break;case a.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE:c=document.createElement("div"),l="magicfeedback-multiple-choice-image";const R=document.createElement("div");R.classList.add("magicfeedback-multiple-choice-image-container"),R.style.display="flex",R.style.flexDirection="row",R.style.flexWrap="wrap",R.style.justifyContent="center";const $=g.length;let M=1,F=1;switch($){case 1:case 2:case 3:M=$,F=1;break;case 4:case 5:case 6:F=2,M=Math.ceil($/F);break;case 7:case 8:case 9:F=3,M=Math.ceil($/F);break;default:F=4,M=Math.ceil($/F)}const B=void 0!==(null==y?void 0:y.addTitle)&&y.addTitle,U=void 0!==(null==y?void 0:y.multiOption)&&y.multiOption,q=void 0!==(null==y?void 0:y.randomPosition)&&y.randomPosition,j=void 0!==(null==y?void 0:y.extraOption)&&y.extraOption;function Q(e){try{const{position:t,url:i,value:a}=e,n=document.createElement("label");n.classList.add("magicfeedback-multiple-choice-image-option"),n.style.width=`calc( ${100/M}% - 10px)`,n.style.height=`calc( ${100/F}% - 10px)`,n.style.margin="5px";const s=document.createElement("label");s.htmlFor=`rating-${m}-${t}`,s.classList.add("magicfeedback-image-option-label-container"),s.style.display="flex",s.style.flexDirection="column",s.addEventListener("mouseover",(()=>{s.style.border="2px solid #000"})),s.addEventListener("mouseout",(()=>{s.style.border="none"})),s.addEventListener("click",(()=>{s.style.border="2px solid #000"}));const r=document.createElement("label");r.textContent=a,r.classList.add("magicfeedback-multiple-choice-image-label");const o=document.createElement("input");o.id=`rating-${m}-${t}`,o.type=U?"checkbox":"radio",o.name=m,o.value=a,o.style.position="absolute",o.style.opacity="0",o.style.width="0",o.style.height="0",o.classList.add("magicfeedback-input");const d=document.createElement("img");d.classList.add("magicfeedback-multiple-choice-image-image"),d.src=i,d.style.cursor="pointer",d.style.backgroundSize="cover",d.style.backgroundPosition="center",d.style.width="100%",d.style.height="100%",d.style.objectFit="cover",d.style.margin="auto",s.appendChild(o),s.appendChild(d),B&&s.appendChild(r),n.appendChild(s),R.appendChild(n)}catch(e){console.error(e)}}q&&(g=g.sort((()=>Math.random()-.5))),g.forEach((e=>Q(JSON.parse(e)))),j&&y.extraOptionValue&&y.extraOptionValue.length>0&&Q(y.extraOptionValue[0]),c.appendChild(R);break;case a.FEEDBACKAPPANSWERTYPE.SELECT:c=document.createElement("select"),l="magicfeedback-select";const G=document.createElement("option");G.value="",G.text="slim"===t?s(p,i):b||"Select an option",G.disabled=!0,G.selected=!0,c.appendChild(G),g.forEach((e=>{const t=document.createElement("option");t.value=e,t.text=e,c.appendChild(t)}));break;case a.FEEDBACKAPPANSWERTYPE.DATE:c=document.createElement("input"),c.type="date",c.required=f,c.placeholder=E||n.placeholder.date(i||"en"),l="magicfeedback-date";break;case a.FEEDBACKAPPANSWERTYPE.CONSENT:c=document.createElement("input"),l="magicfeedback-consent",c.type="checkbox",c.id=`magicfeedback-${u}`,c.name=m,c.value="true",c.required=f,c.classList.add("magicfeedback-consent"),c.classList.add("magicfeedback-input");break;case a.FEEDBACKAPPANSWERTYPE.EMAIL:c=document.createElement("input"),c.type="email",c.required=f,c.placeholder=E||"you@example.com",l="magicfeedback-email";break;case a.FEEDBACKAPPANSWERTYPE.PASSWORD:c=document.createElement("input"),c.type="password",c.required=f,c.placeholder=E||n.placeholder.password(i||"en"),l="magicfeedback-password";break;case a.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX:c=document.createElement("div"),l="magicfeedback-multi-question-matrix";const K=document.createElement("div");K.classList.add("magicfeedback-multi-question-matrix-container");const W=document.createElement("table");W.classList.add("magicfeedback-multi-question-matrix-table");const H=document.createElement("thead");H.classList.add("magicfeedback-multi-question-matrix-header"),H.style.paddingBottom="15px";const Y=document.createElement("tr");["",...g].forEach((e=>{const t=document.createElement("th");t.textContent=e,t.style.padding="0 10px 10px 10px ",Y.appendChild(t)})),H.appendChild(Y);const V=document.createElement("tbody");(null===(d=null==y?void 0:y.options)||void 0===d?void 0:d.length)>0&&y.options.split("|").forEach((e=>{const t=document.createElement("tr");t.style.paddingBottom="15px";const i=document.createElement("td");i.classList.add("magicfeedback-multi-question-matrix-row-label");const a=document.createElement("label");a.classList.add("magicfeedback-multi-question-matrix-label"),a.style.paddingRight="15px",a.textContent=e,i.appendChild(a),t.appendChild(i),g.forEach((i=>{const a=document.createElement("td"),n=document.createElement("input");n.type="checkbox",n.name=m,n.value=i,n.id=`matrix-${e}`,n.classList.add("magicfeedback-input"),n.style.padding="0 10px",a.appendChild(n),t.appendChild(a)})),V.appendChild(t)})),W.appendChild(H),W.appendChild(V),K.appendChild(W),c.appendChild(K);break;case a.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST:c=document.createElement("div"),l="magicfeedback-priority-list";const J=document.createElement("div");J.classList.add("magicfeedback-priority-list-container");const X=document.createElement("ul");X.classList.add("magicfeedback-priority-list-list"),g.forEach(((e,t)=>{const i=document.createElement("li");i.classList.add("magicfeedback-priority-list-item"),i.style.display="flex",i.style.justifyContent="space-between",i.style.alignItems="center",i.style.margin="5px";const a=document.createElement("input");a.classList.add("magicfeedback-input-magicfeedback-priority-list"),a.classList.add("magicfeedback-input"),a.type="hidden",a.id=`priority-list-${m}`,a.name=m,a.value=`${t+1}. ${e}`,i.appendChild(a);const n=document.createElement("label");n.classList.add("magicfeedback-priority-list-item-label"),n.textContent=`${t+1}. ${e}`,i.appendChild(n);const s=document.createElement("div");s.style.display="flex",s.style.alignItems="center",s.style.justifyContent="space-between";const r=document.createElement("img");r.classList.add("magicfeedback-priority-list-arrow-up"),r.src="https://magicfeedback-c6458-dev.web.app/assets/arrow.svg",r.style.width="20px",r.style.height="20px",r.style.cursor="pointer",r.style.margin="0 5px",r.style.color="#000",r.style.visibility=0===t?"hidden":"visible",r.addEventListener("click",(()=>{var t,s;const d=i.previousElementSibling;if(d){const c=Number(a.value.split(".")[0])-1;a.value=`${c}. ${e}`,n.textContent=`${c}. ${e}`,r.style.visibility=1===c?"hidden":"visible",o.style.visibility=c===g.length?"hidden":"visible";const l=d.querySelector(".magicfeedback-input-magicfeedback-priority-list"),u=d.querySelector(".magicfeedback-priority-list-item-label"),p=d.querySelector(".magicfeedback-priority-list-arrow-up"),h=d.querySelector(".magicfeedback-priority-list-arrow-down");if(l&&u&&p&&h){const e=Number(l.value.split(".")[0])+1;l.value=`${e}.${null===(t=u.textContent)||void 0===t?void 0:t.split(".")[1]}`,u.textContent=`${e}.${null===(s=u.textContent)||void 0===s?void 0:s.split(".")[1]}`,p.style.visibility=1===e?"hidden":"visible",h.style.visibility=e===g.length?"hidden":"visible"}X.insertBefore(i,d)}})),s.appendChild(r);const o=document.createElement("img");o.classList.add("magicfeedback-priority-list-arrow-down"),o.src="https://magicfeedback-c6458-dev.web.app/assets/arrow.svg",o.style.width="20px",o.style.height="20px",o.style.cursor="pointer",o.style.margin="0 5px",o.style.color="#000",o.style.transform="rotate(180deg)",o.style.visibility=t===g.length-1?"hidden":"visible",o.addEventListener("click",(()=>{var t,s;const d=i.nextElementSibling;if(d){const c=Number(a.value.split(".")[0])+1;a.value=c.toString(),n.textContent=`${c.toString()}. ${e}`,r.style.visibility=1===c?"hidden":"visible",o.style.visibility=c===g.length?"hidden":"visible";const l=d.querySelector(".magicfeedback-input-magicfeedback-priority-list"),u=d.querySelector(".magicfeedback-priority-list-item-label"),p=d.querySelector(".magicfeedback-priority-list-arrow-up"),h=d.querySelector(".magicfeedback-priority-list-arrow-down");if(l&&u&&p&&h){const e=Number(l.value.split(".")[0])-1;l.value=`${e}.${null===(t=u.textContent)||void 0===t?void 0:t.split(".")[1]}`,u.textContent=`${e}.${null===(s=u.textContent)||void 0===s?void 0:s.split(".")[1]}`,p.style.visibility=1===e?"hidden":"visible",h.style.visibility=e===g.length?"hidden":"visible"}X.insertBefore(d,i)}})),s.appendChild(o),i.appendChild(s),X.appendChild(i)})),J.appendChild(X),c.appendChild(J);break;case a.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM:c=document.createElement("div"),l="magicfeedback-point-system";const z=document.createElement("div");z.classList.add("magicfeedback-point-system-container");const Z=document.createElement("ul");Z.classList.add("magicfeedback-point-system-list"),Z.style.padding="0";const ee=100,te=ee/g.length,ie=document.createElement("div");ie.classList.add("magicfeedback-point-system-total"),ie.textContent="0 / 100 %",ie.style.textAlign="right",ie.style.fontSize="0.8em",ie.style.color="#999",ie.style.marginTop="5px",g.forEach((e=>{const t=document.createElement("li");t.classList.add("magicfeedback-point-system-item"),t.style.display="flex",t.style.justifyContent="space-between",t.style.alignItems="center",t.style.margin="5px";const i=document.createElement("label");i.textContent=e,t.appendChild(i);const a=document.createElement("span");a.classList.add("magicfeedback-point-system-input-container");const n=document.createElement("input");n.name=m,n.id=`point-system-${e}`,n.type="number",n.min="0",n.max=`${ee}`,n.value="0",n.classList.add("magicfeedback-input"),n.style.width="40px",n.style.border="0",n.style.textAlign="center",n.style.margin="0 5px";const s=document.createElement("span");s.textContent="%",s.style.color="#000",n.addEventListener("input",(()=>{const e=Z.querySelectorAll("input");let t=0;e.forEach((e=>{t+=Number(e.value)})),t>ee&&(n.value=`${te}%`,t-=Number(n.value)),ie.textContent=`${t} / 100 %`})),a.appendChild(n),a.appendChild(s),t.appendChild(a),Z.appendChild(t)})),z.appendChild(Z),z.appendChild(ie),c.appendChild(z);break;default:return v}c.id=`magicfeedback-${u}`,c.setAttribute("name",m),c.classList.add(l),(void 0!==b||null!==k)&&(c.value=k||b),["RADIO","MULTIPLECHOICE"].includes(h)||(c.classList.add("magicfeedback-input"),c.required=f);const w=document.createElement("label");if(w.setAttribute("for",`magicfeedback-${u}`),w.textContent=s(p,i),w.classList.add("magicfeedback-label"),["CONSENT"].includes(h))v.classList.add("magicfeedback-consent-container"),v.appendChild(c),v.appendChild(w);else{if("slim"!==t&&(v.appendChild(w),void 0!==(null==y?void 0:y.general)&&""!==(null==y?void 0:y.general))){const we=document.createElement("img");we.src=y.general,we.classList.add("magicfeedback-image"),we.style.maxWidth="auto",we.style.height="400px",we.style.margin="10px 0",v.appendChild(we)}if("LONGTEXT"===h&&x>0){const Ae=document.createElement("div");if(Ae.classList.add("magicfeedback-counter"),Ae.textContent=`${c.value.length}/${x}`,Ae.style.textAlign="right",Ae.style.fontSize="0.8em",Ae.style.color="#999",Ae.style.marginTop="5px",c.addEventListener("input",(()=>{Ae.textContent=`${c.value.length}/${x}`})),v.appendChild(c),v.appendChild(Ae),y.extraOption&&y.extraOptionText){const Te=document.createElement("div");Te.classList.add("magicfeedback-skip-container"),Te.classList.add("magicfeedback-checkbox-container"),Te.style.display="flex",Te.style.justifyContent="flex-start";const Le=document.createElement("input");Le.classList.add("magicfeedback-skip"),Le.type="checkbox",Le.id=`skip-${m}`,Le.name=m,Le.value="-",Le.style.cursor="pointer";const Oe=document.createElement("label");Oe.htmlFor=`skip-${m}`,Oe.textContent=y.extraOptionText,Oe.style.fontSize="0.8em",Oe.style.color="#999",Oe.style.cursor="pointer",Oe.style.margin="0 5px",Le.addEventListener("click",(()=>{c.value="-",o&&o()})),Te.appendChild(Le),Te.appendChild(Oe),v.appendChild(Te)}}else v.appendChild(c)}return v}(t,i,o,d);c.push(e)}})),c},t.renderActions=function(e="",t,i="Submit",a="Back",n="Next"){const s=document.createElement("div");s.classList.add("magicfeedback-action-container");const r=document.createElement("button");r.id="magicfeedback-submit",r.type="submit",r.classList.add("magicfeedback-submit"),r.textContent="MAGICSURVEY"===e?n||"Next":i||"Submit";const o=document.createElement("button");return o.id="magicfeedback-back",o.type="button",o.classList.add("magicfeedback-back"),o.textContent=a||"Back",o.addEventListener("click",t),"MAGICSURVEY"===e&&s.appendChild(o),s.appendChild(r),s},t.renderError=function(e){const t=document.createElement("div");return t.classList.add("magicfeedback-error"),t.textContent=e,t},t.renderSuccess=function(e){const t=document.createElement("div");return t.classList.add("magicfeedback-success"),t.textContent=e,t},t.renderStartMessage=function(e,t,i=!1,a="Go!"){const n=document.createElement("div");n.classList.add("magicfeedback-start-message-container");const s=document.createElement("div");s.classList.add("magicfeedback-start-message"),s.innerHTML=e;const r=document.createElement("button");return r.id="magicfeedback-start-message-button",r.classList.add("magicfeedback-start-message-button"),r.textContent=a,r.addEventListener("click",(()=>t())),n.appendChild(s),i&&n.appendChild(r),n}},341:function(e,t,i){"use strict";var a=this&&this.__awaiter||function(e,t,i,a){return new(i||(i=Promise))((function(n,s){function r(e){try{d(a.next(e))}catch(e){s(e)}}function o(e){try{d(a.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,o)}d((a=a.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getFollowUpQuestion=t.sendFeedback=t.getQuestions=t.getForm=t.validateEmail=void 0;const s=n(i(98)),r=n(i(147)),o=i(374),d={Accept:"application/json","Magicfeedback-Sdk-Version":r.default.version};t.validateEmail=function(e){return/\S+@\S+\.\S+/.test(e)},t.getForm=function(e,t,i,n){return a(this,void 0,void 0,(function*(){try{const a=yield(0,s.default)(e+o.endpoints.sdk.app_info(t,i),{method:"GET",headers:d});if(a.ok){const e=yield a.json();return n.log(`Received form for app ${t}`,e),e}throw n.err(`Failed to get questions for app ${t}:`,a.status,a.statusText),new Error("[MagicFeedback] Bad response from server")}catch(e){return n.err(e),null}}))},t.getQuestions=function(e,t,i,n){return a(this,void 0,void 0,(function*(){try{const a=yield(0,s.default)(e+o.endpoints.sdk.app(t,i),{method:"GET",headers:d});if(a.ok){const e=yield a.json();return n.log(`Received questions for app ${t}`,e),e}throw n.err(`Failed to get questions for app ${t}:`,a.status,a.statusText),new Error("[MagicFeedback] Bad response from server")}catch(e){return n.err(e),[]}}))},t.sendFeedback=function(e,t,i){return a(this,void 0,void 0,(function*(){try{const a=yield(0,s.default)(e+o.endpoints.sdk.feedback,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},d),body:JSON.stringify(t)});if(a.ok)return i.log(`Form ${t.integration} submitted successfully!`),(yield a.json()).sessionId;throw i.err(`Failed to submit form ${t.integration}:`,a.status,a.statusText),new Error(a.statusText)}catch(e){return i.err(e),""}}))},t.getFollowUpQuestion=function(e,t,i){return a(this,void 0,void 0,(function*(){try{const a=yield(0,s.default)(e+o.endpoints.sdk.followUpQuestion,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},d),body:JSON.stringify(t)});if(a.ok)return i.log(`Received follow up question for form ${t.integration}`),(yield a.json())||"";throw i.err(`Failed to get follow up question for form ${t.integration}:`,a.status,a.statusText),new Error(a.statusText)}catch(e){return i.err(e),""}}))}},5:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Log=void 0,t.Log=class{constructor(e){this.config=e}log(...e){this.config.get("debug")&&console.log("[MagicFeedback]:",...e)}err(...e){console.error("[MagicFeedback]:",...e)}}},147:e=>{"use strict";e.exports=JSON.parse('{"name":"@magicfeedback/native","version":"1.2.8-beta.8","main":"./dist/magicfeedback-sdk.node.js","browser":"./dist/magicfeedback-sdk.browser.js","types":"./dist/types/src/index.d.ts","repository":{"type":"git","url":"git+ssh://git@github.com/MagicFeedback/magicfeedback-sdk.git"},"author":"farias@magicfeedback.io","license":"MIT","private":false,"scripts":{"dev":"vite","build":"webpack","build:watch":"webpack --watch --mode development","publish":"npm publish --access public","publish:beta":"npm publish --access public --tag beta","test":"jest","test:watch":"jest --watchAll","coverage":"vitest run --coverage"},"files":["dist"],"devDependencies":{"@babel/preset-typescript":"^7.22.5","@types/node":"^17.0.21","@types/webpack":"^5.28.0","@types/webpack-node-externals":"^2.5.3","c8":"^7.11.0","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","jest-fetch-mock":"^3.0.3","nock":"^13.2.4","ts-jest":"^29.1.0","ts-loader":"^9.2.7","ts-node":"^10.7.0","typescript":"^4.6.2","vite":"^2.8.0","vite-plugin-dts":"^0.9.9","vitest":"^0.5.9","webpack":"^5.70.0","webpack-cli":"^4.9.2","webpack-node-externals":"^3.0.0"},"dependencies":{"cross-fetch":"^3.1.5","is-bundling-for-browser-or-node":"^1.1.1"},"description":"MagicFeedbackAI JavaScript Library for [MagicFeedback.io](https://magicfeedback.io/)","bugs":{"url":"https://github.com/MagicFeedback/magicfeedback-sdk/issues"},"homepage":"https://github.com/MagicFeedback/magicfeedback-sdk#readme","directories":{"example":"examples","test":"test"}}')}},t={},function i(a){var n=t[a];if(void 0!==n)return n.exports;var s=t[a]={exports:{}};return e[a].call(s.exports,s,s.exports,i),s.exports}(607).default;var e,t}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.magicfeedback=t():e.magicfeedback=t()}(global,(()=>(()=>{"use strict";var e={290:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HOST_API_URL_DEV=t.HOST_API_URL=void 0,t.HOST_API_URL="https://api.magicfeedback.io/",t.HOST_API_URL_DEV="https://api-dev.magicfeedback.io/"},607:function(e,t,i){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=a(i(519));let n=null;n||(n=(0,s.default)()),t.default=n},519:function(e,t,i){var a=this&&this.__awaiter||function(e,t,i,a){return new(i||(i=Promise))((function(s,n){function o(e){try{c(a.next(e))}catch(e){n(e)}}function r(e){try{c(a.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}c((a=a.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const s=i(954),n=i(712),o=i(5),r=i(341),c=i(290);t.default=function(){const e=new n.Config;let t;return{init:function(i){(null==i?void 0:i.debug)&&e.set("debug",null==i?void 0:i.debug),e.set("url",(null==i?void 0:i.env)&&"dev"===(null==i?void 0:i.env)?c.HOST_API_URL_DEV:c.HOST_API_URL),t=new o.Log(e),t.log("Initialized Magicfeedback",e)},send:function(i,s,n,o=!0,c,d){return a(this,void 0,void 0,(function*(){i||t.err("No appID provided"),s||t.err("No publicKey provided"),n||t.err("No feedback provided"),n.answers||n.profile||n.metrics||n.metadata||t.err("No feedback data provided");const a=e.get("url"),l={integration:i,publicKey:s,privateKey:d,completed:o,id:c,feedback:n};try{const e=yield(0,r.sendFeedback)(a,l,t);return t.log("sent native feedback"),e}catch(e){return t.err("error native feedback",e),!1}}))},form:function(i,a){return i||t.err("No appID provided"),a||t.err("No publicKey provided"),new s.Form(e,i,a)}}}},712:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Config=void 0,t.Config=class{constructor(){this.variables={},this.variables.env="prod",this.variables.debug=!1}get(e){return this.variables[e]}set(e,t){this.variables[e]=t}}},954:function(e,t,i){var a=this&&this.__awaiter||function(e,t,i,a){return new(i||(i=Promise))((function(s,n){function o(e){try{c(a.next(e))}catch(e){n(e)}}function r(e){try{c(a.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}c((a=a.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.Form=void 0;const s=i(5),n=i(341),o=i(183);t.Form=class{constructor(e,t,i){this.config=e,this.log=new s.Log(e),this.formOptionsConfig={addButton:!0,sendButtonText:"Send",backButtonText:"Back",nextButtonText:"Next",addSuccessScreen:!0,getMetaData:!0,questionFormat:"standard"},this.selector="",this.appId=t,this.publicKey=i,this.url=e.get("url"),this.id="",this.formData=null,this.feedback={text:"",answers:[],profile:[],metrics:[],metadata:[]},this.questions=[],this.censorQuestions=[],this.elementQuestions=[],this.questionInProcess=null,this.history={},this.progress=0,this.total=0}generate(e,t){var i;return a(this,void 0,void 0,(function*(){try{this.formOptionsConfig=Object.assign(Object.assign({},this.formOptionsConfig),t),this.selector=e;const a=localStorage.getItem(`magicfeedback-${this.appId}`);if(a&&new Date(JSON.parse(a).savedAt)<new Date((new Date).getTime()+864e5)?(this.formData=JSON.parse(a),(0,n.getForm)(this.url,this.appId,this.publicKey,this.log).then((e=>{var t,i,a;(null==e?void 0:e.updatedAt)&&(null===(t=this.formData)||void 0===t?void 0:t.savedAt)&&(null==e?void 0:e.updatedAt)>(null===(i=this.formData)||void 0===i?void 0:i.savedAt)&&(console.log("Form updated"),this.formData=e,this.formData.savedAt=new Date,this.formData.questions&&(this.questions=this.formData.questions,this.total=this.questions.length),localStorage.setItem(`magicfeedback-${this.appId}`,JSON.stringify(this.formData)),(null===(a=this.formData.style)||void 0===a?void 0:a.startMessage)?this.generateWelcomeMessage(this.formData.style.startMessage):this.generateForm())}))):this.formData=yield(0,n.getForm)(this.url,this.appId,this.publicKey,this.log),void 0===this.formData||!this.formData)throw new Error(`No form for app ${this.appId}`);if(this.formData.savedAt||(this.formData.savedAt=new Date,localStorage.setItem(`magicfeedback-${this.appId}`,JSON.stringify(this.formData))),this.questions=this.formData.questions,void 0===this.questions||!this.questions)throw new Error(`No questions for app ${this.appId}`);this.total=this.questions.length,this.formOptionsConfig.onLoadedEvent&&(yield this.formOptionsConfig.onLoadedEvent({loading:!1,progress:this.progress,total:this.total,formData:this.formData})),this.formOptionsConfig.getMetaData&&this.getMetaData(),(null===(i=this.formData.style)||void 0===i?void 0:i.startMessage)?this.generateWelcomeMessage(this.formData.style.startMessage):this.generateForm()}catch(e){return this.log.err(e),void(this.formOptionsConfig.onLoadedEvent&&(yield this.formOptionsConfig.onLoadedEvent({loading:!1,error:e})))}}))}generateContainer(){let e=document.getElementById(this.selector);if(!e&&(e=document.getElementById("magicfeedback-container-"+this.appId),!e))throw new Error(`Element with ID '${this.selector}' not found.`);return e.classList.add("magicfeedback-container"),e.id="magicfeedback-container-"+this.appId,e.innerHTML="",e}generateForm(){var e,t,i;try{this.questions.sort(((e,t)=>e.position-t.position));let a=this.generateContainer();const s=document.createElement("form");s.classList.add("magicfeedback-form"),s.id="magicfeedback-"+this.appId;const n=document.createElement("div");if(n.classList.add("magicfeedback-questions"),n.id="magicfeedback-questions-"+this.appId,this.elementQuestions=(0,o.renderQuestions)(this.questions,this.formOptionsConfig.questionFormat,null===(e=this.formData)||void 0===e?void 0:e.lang[0],(()=>this.send())),"MAGICSURVEY"===(null===(t=this.formData)||void 0===t?void 0:t.identity)?(this.elementQuestions.forEach(((e,t)=>this.history[t]=[{object:this.questions[t],element:e}])),this.questionInProcess=this.history[0][0].object,n.appendChild(this.history[0][0].element)):this.elementQuestions.forEach((e=>n.appendChild(e))),s.appendChild(n),a.appendChild(s),this.formOptionsConfig.addButton){const e=(0,o.renderActions)(null===(i=this.formData)||void 0===i?void 0:i.identity,(()=>this.back()),this.formOptionsConfig.sendButtonText,this.formOptionsConfig.backButtonText,this.formOptionsConfig.nextButtonText);s.appendChild(e)}s.addEventListener("submit",(e=>{e.preventDefault(),this.send()}))}catch(e){return this.log.err(e),void(this.formOptionsConfig.onLoadedEvent&&this.formOptionsConfig.onLoadedEvent({loading:!1,error:e}))}}startForm(){this.generateForm()}generateWelcomeMessage(e){try{const t=this.generateContainer(),i=(0,o.renderStartMessage)(e,(()=>this.startForm()),this.formOptionsConfig.addButton,this.formOptionsConfig.startButtonText);t.appendChild(i)}catch(e){return this.log.err(e),void(this.formOptionsConfig.onLoadedEvent&&this.formOptionsConfig.onLoadedEvent({loading:!1,error:e}))}}getMetaData(){this.feedback.metadata.push({key:"navigator-url",value:[window.location.href]}),this.feedback.metadata.push({key:"navigator-origin",value:[window.location.origin]}),this.feedback.metadata.push({key:"navigator-pathname",value:[window.location.pathname]}),this.feedback.metadata.push({key:"navigator-search",value:[window.location.search]}),this.feedback.metadata.push({key:"navigator-user",value:[navigator.userAgent]}),this.feedback.metadata.push({key:"navigator-language",value:[navigator.language]}),this.feedback.metadata.push({key:"navigator-platform",value:[navigator.platform]}),this.feedback.metadata.push({key:"navigator-appVersion",value:[navigator.appVersion]}),this.feedback.metadata.push({key:"navigator-appName",value:[navigator.appName]}),this.feedback.metadata.push({key:"navigator-product",value:[navigator.product]}),this.feedback.metadata.push({key:"screen-width",value:[window.screen.width.toString()]}),this.feedback.metadata.push({key:"screen-height",value:[window.screen.height.toString()]})}send(e,t,i){var s;return a(this,void 0,void 0,(function*(){const a=document.getElementById("magicfeedback-container-"+this.appId),n=document.getElementById("magicfeedback-questions-"+this.appId);try{i&&(this.feedback.profile=[...this.feedback.profile,...i]),t&&(this.feedback.metrics=[...this.feedback.metrics,...t]),e&&(this.feedback.metadata=[...this.feedback.metadata,...e]),this.answer(),this.formOptionsConfig.beforeSubmitEvent&&(yield this.formOptionsConfig.beforeSubmitEvent({loading:!0,answer:this.feedback.answers,progress:this.progress,total:this.total}));const o=yield this.pushAnswers("MAGICSURVEY"!==(null===(s=this.formData)||void 0===s?void 0:s.identity));o&&(this.id=o,yield this.processNextQuestion(a,n)),this.formOptionsConfig.afterSubmitEvent&&(yield this.formOptionsConfig.afterSubmitEvent({response:o,loading:!1,progress:this.progress,total:this.total,answer:this.feedback.answers,error:o?null:new Error("No response")}))}catch(e){this.log.err(`An error occurred while submitting the form ${this.appId}:`,e),this.formOptionsConfig.afterSubmitEvent&&(yield this.formOptionsConfig.afterSubmitEvent({loading:!1,progress:this.progress+this.censorQuestions.length,total:this.total-this.censorQuestions.length,error:e}))}}))}answer(){const e=document.getElementById("magicfeedback-"+this.appId);if(!e)return this.log.err(`Form "${e}" not found.`),void(this.feedback.answers=[]);const t=[];let i=!1;const a=e.querySelectorAll(".magicfeedback-input");a.forEach((e=>{const s=e.type,o=e.classList[0],r={key:e.name,value:[]},c="magicfeedback-consent"===o?e.checked.toString():e.value;if(r.key&&""!==r.key)switch(s){case"radio":case"checkbox":if("magicfeedback-consent"===o||e.checked){if(e.id.includes("matrix")){const t=e.id.split("-")[e.id.split("-").length-1];let i="";a.forEach((e=>{e.checked&&e.id.includes(`matrix-${t}`)&&(i+=e.value+", ")})),i=i.slice(0,-2),r.value.push(`${t}: ${i}`)}else r.value.push(c);const i=t.findIndex((e=>e.key===r.key));-1!==i?t[i].value=[...t[i].value,...r.value]:t.push(r)}break;default:if(""!==c){if("email"===s){if(!(0,n.validateEmail)(c)){this.log.err("Invalid email"),i=!0;break}this.feedback.profile.push({key:"email",value:[c]})}if(e.id.includes("point-system")){const t=e.id.split("-")[e.id.split("-").length-1];r.value.push(`${t}: ${c}%`)}else r.value.push(c);const a=t.findIndex((e=>e.key===r.key));-1!==a?t[a].value=[...t[a].value,...r.value]:t.push(r)}}})),this.feedback.answers=i?[]:t}finish(){if(this.formOptionsConfig.addSuccessScreen){const e=document.getElementById("magicfeedback-container-"+this.appId);e.childNodes.length>0&&e.removeChild(e.childNodes[0]);const t=(0,o.renderSuccess)(this.formOptionsConfig.successMessage||"Thank you for your feedback!");e.appendChild(t)}this.answer(),this.pushAnswers(!0)}censureQuestions(e){this.censorQuestions=this.questions.filter((t=>e.includes(t.id))).map((e=>e.id))}pushAnswers(e=!1){var t,i;return a(this,void 0,void 0,(function*(){try{if("MAGICFORM"===(null===(t=this.formData)||void 0===t?void 0:t.identity)){if(0===this.feedback.answers.length)throw new Error("No answers provided");this.questions.forEach((e=>{if(e.require&&!this.feedback.answers.find((t=>t.key===e.ref)))throw new Error(`No answer provided for question ${e.title}`)}))}else if(!e&&(null===(i=this.questionInProcess)||void 0===i?void 0:i.require)&&0===this.feedback.answers.length)throw new Error("No answers provided");const a=this.config.get("url"),s={integration:this.appId,publicKey:this.publicKey,feedback:this.feedback,completed:e};return yield(0,n.sendFeedback)(a,this.id?Object.assign(Object.assign({},s),{sessionId:this.id}):s,this.log)}catch(e){return this.log.err(`An error occurred while submitting the form ${this.appId}:`,e),""}}))}callFollowUpQuestion(e){return a(this,void 0,void 0,(function*(){if(!(null==e?void 0:e.followup))return null;try{if(0===this.feedback.answers.length)throw new Error("No answers provided");const t=this.config.get("url"),i={answer:this.feedback.answers[0].value[0],publicKey:this.publicKey,sessionId:this.id,question:e};return yield(0,n.getFollowUpQuestion)(t,i,this.log)}catch(e){throw this.log.err(`An error occurred while submitting the form ${this.appId}:`,e),e}}))}processNextQuestion(e,t){var i,s,n,r;return a(this,void 0,void 0,(function*(){if("MAGICSURVEY"===(null===(i=this.formData)||void 0===i?void 0:i.identity))if(null===(s=this.questionInProcess)||void 0===s?void 0:s.followup){const e=yield this.callFollowUpQuestion(this.questionInProcess);if(e){this.questionInProcess=e;const i=(0,o.renderQuestions)([e],null===(n=this.formOptionsConfig)||void 0===n?void 0:n.questionFormat,null===(r=this.formData)||void 0===r?void 0:r.lang[0])[0];this.history[this.progress].push({object:e,element:i}),t.removeChild(t.childNodes[0]),t.appendChild(i)}else this.renderNextQuestion(t)}else this.renderNextQuestion(t);else if(this.total=this.questions.length,this.progress=this.questions.length,this.formOptionsConfig.addSuccessScreen){e.childNodes.length>0&&e.removeChild(e.childNodes[0]);const t=(0,o.renderSuccess)(this.formOptionsConfig.successMessage||"Thank you for your feedback!");e.appendChild(t)}}))}renderNextQuestion(e){this.progress++,this.progress<this.total?(this.questionInProcess=this.history[this.progress][0].object,this.censorQuestions.includes(this.questionInProcess.id)?this.renderNextQuestion(e):(e.removeChild(e.childNodes[0]),e.appendChild(this.history[this.progress][0].element))):this.finish()}back(){if(0===this.progress)return;const e=document.getElementById("magicfeedback-questions-"+this.appId);e&&e.childNodes.length>0&&e.removeChild(e.childNodes[0]),this.history[this.progress].length>1?this.history[this.progress].pop():this.progress--;let t=this.history[this.progress][this.history[this.progress].length-1];this.censorQuestions.includes(t.object.id)?this.back():(this.questionInProcess=t.object,e.appendChild(t.element))}}},244:(e,t)=>{var i,a;Object.defineProperty(t,"__esModule",{value:!0}),t.QuestionType=t.FEEDBACKAPPANSWERTYPE=void 0,(a=t.FEEDBACKAPPANSWERTYPE||(t.FEEDBACKAPPANSWERTYPE={})).CONTACT="CONTACT",a.MULTIPLECHOISE_IMAGE="MULTIPLECHOISE_IMAGE",a.EMAIL="EMAIL",a.RATING_STAR="RATING_STAR",a.RADIO="RADIO",a.MULTIPLECHOICE="MULTIPLECHOICE",a.SELECT="SELECT",a.TEXT="TEXT",a.LONGTEXT="LONGTEXT",a.NUMBER="NUMBER",a.RATING_EMOJI="RATING_EMOJI",a.RATING_NUMBER="RATING_NUMBER",a.DATE="DATE",a.BOOLEAN="BOOLEAN",a.PASSWORD="PASSWORD",a.CONSENT="CONSENT",a.MULTI_QUESTION_MATRIX="MULTI_QUESTION_MATRIX",a.POINT_SYSTEM="POINT_SYSTEM",a.PRIORITY_LIST="PRIORITY_LIST",t.QuestionType=class{},function(e){e.FORM="form",e.DIV="div"}(i||(i={}))},374:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.endpoints=void 0,t.endpoints={sdk:{app:(e,t)=>`sdk/app/${e}/${t}`,app_info:(e,t)=>`sdk/app/${e}/${t}/info`,feedback:"sdk/feedback",followUpQuestion:"sdk/followUpQuestion"}}},528:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.placeholder=void 0,t.placeholder={answer:e=>{switch(e){case"en":default:return"Write your answer here...";case"es":return"Escribe tu respuesta aquí...";case"da":return"Skriv dit svar her...";case"fi":return"Kirjoita vastauksesi tähän...";case"sv":return"Skriv ditt svar här...";case"no":return"Skriv svaret ditt her...";case"ar":return"اكتب إجابتك هنا...";case"bn":return"এখানে আপনার"}},number:e=>{switch(e){case"en":default:return"Write your number here...";case"es":return"Escribe tu número aquí...";case"da":return"Skriv dit nummer her...";case"fi":return"Kirjoita numerosi tähän...";case"sv":return"Skriv ditt nummer här...";case"no":return"Skriv nummeret ditt her...";case"ar":return"اكتب رقمك هنا...";case"bn":return"এখানে আপনার"}},email:e=>{switch(e){case"en":default:return"Write your email here...";case"es":return"Escribe tu correo electrónico aquí...";case"da":return"Skriv din e-mail her...";case"fi":return"Kirjoita sähköpostiosoitteesi tähän...";case"sv":return"Skriv din e-post här...";case"no":return"Skriv e-posten din her...";case"ar":return"اكتب بريدك الإلكتروني هنا...";case"bn":return"এখানে আপনার"}},date:e=>{switch(e){case"en":default:return"Write your date here...";case"es":return"Escribe tu fecha aquí...";case"da":return"Skriv din dato her...";case"fi":return"Kirjoita päivämääräsi tähän...";case"sv":return"Skriv ditt datum här...";case"no":return"Skriv datoen din her...";case"ar":return"اكتب تاريخك هنا...";case"bn":return"এখানে আপনার"}},password:e=>{switch(e){case"en":default:return"Write your password here...";case"es":return"Escribe tu contraseña aquí...";case"da":return"Skriv dit kodeord her...";case"fi":return"Kirjoita salasanasi tähän...";case"sv":return"Skriv ditt lösenord här...";case"no":return"Skriv passordet ditt her...";case"ar":return"اكتب كلمة المرور الخاصة بك هنا...";case"bn":return"এখানে আপনার"}}}},183:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.renderStartMessage=t.renderSuccess=t.renderError=t.renderActions=t.renderQuestions=void 0;const a=i(244),s=i(528);function n(e,t){return"object"==typeof e?e[t]||e.en:e}function o(e,t,i,a,s,n=!0){const o=document.createElement("div");o.classList.add("magicfeedback-rating-placeholder"),o.style.display="flex",o.style.justifyContent="space-between",o.style.width=s?`calc(100% - (100% / ${t+1}))`:"100%",o.style.marginRight="auto",n&&window.innerWidth<600&&(o.style.flexDirection="column");const r=document.createElement("span");r.textContent=i,r.classList.add("magicfeedback-rating-placeholder-value"),r.style.fontStyle="italic",r.style.fontSize="14px",r.style.textAlign="left",r.style.width="50%",n&&window.innerWidth<600&&(r.textContent=`${e} ➜ ${i}`,r.style.width="100%",r.style.textAlign="left",r.style.marginBottom="5px"),o.appendChild(r);const c=document.createElement("span");return c.textContent=a,c.classList.add("magicfeedback-rating-placeholder-value"),c.style.fontStyle="italic",c.style.fontSize="14px",c.style.textAlign="right",c.style.width="50%",n&&window.innerWidth<600&&(c.textContent=`${t} ➜ ${a}`,c.style.width="100%",c.style.textAlign="left",c.style.marginBottom="5px"),o.appendChild(c),o}t.renderQuestions=function e(t,i="standard",r="en",c){if(!t)throw new Error("[MagicFeedback] No questions provided");const d=[];return t.forEach((t=>{var l,u;if((null===(u=null===(l=null==t?void 0:t.questionType)||void 0===l?void 0:l.conf)||void 0===u?void 0:u.length)>0){let a=document.createElement("div");a.classList.add("magicfeedback-div"),t.questionType.conf.forEach((e=>{e.ref=t.ref,t.assets[e.id]&&(e.assets={placeholder:t.assets[e.id]})})),e(t.questionType.conf,i,r,c).forEach((e=>{a.appendChild(e)})),d.push(a)}else{const e=function(e,t,i,r){var c;let d,l,{id:u,title:p,type:m,ref:h,require:f,value:g,defaultValue:b,assets:v}=e,y=document.createElement("div");y.classList.add("magicfeedback-div");const E="slim"===t?n(p,i):null==v?void 0:v.placeholder,k=(x=u,new URLSearchParams(window.location.search).get(x)),C=v.maxCharacters||300;var x;switch(m){case a.FEEDBACKAPPANSWERTYPE.TEXT:d=document.createElement("input"),d.type="text",d.placeholder=E||s.placeholder.answer(i||"en"),l="magicfeedback-text";break;case a.FEEDBACKAPPANSWERTYPE.LONGTEXT:d=document.createElement("textarea"),d.rows=3,C>0&&(d.maxLength=C),d.placeholder=E||s.placeholder.answer(i||"en"),l="magicfeedback-longtext";break;case a.FEEDBACKAPPANSWERTYPE.NUMBER:d=document.createElement("input"),d.type="number",d.placeholder="slim"===t?n(p,i):s.placeholder.number(i||"en"),l="magicfeedback-number",g.length&&(g.sort(((e,t)=>Number(e)-Number(t))),d.max=g[g.length-1],d.min=g[0],d.value=g[0]);break;case a.FEEDBACKAPPANSWERTYPE.RADIO:case a.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE:d=document.createElement("div"),l="magicfeedback-"+("MULTIPLECHOICE"===m?"checkbox":"radio"),v.extraOption&&g.push(v.extraOptionText),g.forEach(((e,t)=>{const n=document.createElement("div");n.classList.add(`magicfeedback-${"MULTIPLECHOICE"===m?"checkbox":"radio"}-container`);const o=document.createElement("label"),r=document.createElement("input");if(r.id=`rating-${h}-${t}`,r.type="MULTIPLECHOICE"===m?"checkbox":"radio",r.name=h,r.value=e,r.classList.add(l),r.classList.add("magicfeedback-input"),m===a.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE&&v.maxOptions&&v.maxOptions>0&&r.addEventListener("change",(()=>{document.querySelectorAll(`input[name="${h}"]:checked`).length>v.maxOptions&&(r.checked=!1)})),e!==b&&e!==k||(r.checked=!0),o.textContent=e,o.htmlFor=`rating-${h}-${t}`,r.addEventListener("change",(t=>{const i=document.getElementById(`extra-option-${h}`);i&&v.extraOption&&(t.target.checked&&e===v.extraOptionText?i.style.display="block":i.style.display="none")})),n.appendChild(r),n.appendChild(o),d.appendChild(n),v.extraOption&&e===v.extraOptionText){const e=document.createElement("input");e.type="text",e.placeholder=v.extraOptionPlaceholder||s.placeholder.answer(i||"en"),e.classList.add("magicfeedback-extra-option"),e.classList.add("magicfeedback-input"),e.id=`extra-option-${h}`,e.name=`extra-option-${h}`,e.style.display="none",d.appendChild(e)}}));break;case a.FEEDBACKAPPANSWERTYPE.BOOLEAN:d=document.createElement("div"),l="magicfeedback-radio";const L=document.createElement("div");L.classList.add("magicfeedback-boolean-container"),L.style.display="flex",L.style.flexDirection="row",L.style.justifyContent="space-between",L.style.width="70%",L.style.margin="auto",(v.addIcon?["👍","👎"]:function(e){switch(e){case"es":return["Sí","No"];case"fr":return["Oui","Non"];case"de":return["Ja","Nein"];case"it":return["Sì","No"];case"pt":return["Sim","Não"];case"nl":return["Ja","Nee"];case"pl":return["Tak","Nie"];case"ru":return["Да","Нет"];case"ja":return["はい","いいえ"];case"zh":return["是","不"];case"ko":return["예","아니"];case"da":case"sv":return["Ja","Nej"];case"fi":return["Kyllä","Ei"];case"no":return["Ja","Nei"];case"ar":return["نعم","لا"];case"bn":return["হ্যাঁ","না"];default:return["Yes","No"]}}(i)).forEach(((e,t)=>{const i=document.createElement("label");i.classList.add("magicfeedback-boolean-option"),i.htmlFor=`rating-${h}-${t}`,i.style.cursor="pointer",i.style.border="1px solid #000",i.style.display="flex",i.style.justifyContent="center",i.style.alignItems="center",i.style.margin="auto",i.style.padding="0",i.style.width="45%",i.style.height="38px";const a=document.createElement("label");a.htmlFor=`rating-${h}-${t}`,a.textContent=e,a.style.margin="0",a.style.padding="0";const s=document.createElement("input");s.id=`rating-${h}-${t}`,s.type="radio",s.name=h,s.value=e,s.classList.add(l),s.classList.add("magicfeedback-input"),s.style.position="absolute",s.style.opacity="0",s.style.width="0",s.style.height="0",s.style.margin="0",s.addEventListener("change",(()=>{r&&r()})),i.appendChild(s),i.appendChild(a),L.appendChild(i)})),d.appendChild(L);break;case a.FEEDBACKAPPANSWERTYPE.RATING_EMOJI:d=document.createElement("div"),l="magicfeedback-rating";const S=document.createElement("div");S.classList.add("magicfeedback-rating-container");const A=v.max?Number(v.max):5,T=v.min?Number(v.min):1,O=o(T,A,v.minPlaceholder,v.maxPlaceholder,v.extraOption);for(let ae=T;ae<=A;ae++){const se=document.createElement("div");se.classList.add("magicfeedback-rating-option");const ne=document.createElement("label");ne.htmlFor=`rating-${h}-${ae}`,ne.classList.add("magicfeedback-rating-option-label-container");const oe=document.createElement("label");oe.htmlFor=`rating-${h}-${ae}`,oe.textContent=ae.toString();const re=document.createElement("img");if(re.alt=`face-${h}-${ae}`,re.className=`rating-image${ae}`,0===T&&10===A)re.src=`https://magicfeedback-c6458-dev.web.app/assets/${ae}.svg`;else if(1===T&&5===A)switch(ae){case 1:re.src="https://magicfeedback-c6458-dev.web.app/assets/1.svg";break;case 2:re.src="https://magicfeedback-c6458-dev.web.app/assets/2.svg";break;case 3:re.src="https://magicfeedback-c6458-dev.web.app/assets/6.svg";break;case 4:re.src="https://magicfeedback-c6458-dev.web.app/assets/9.svg";break;case 5:re.src="https://magicfeedback-c6458-dev.web.app/assets/10.svg"}else{const de=Math.round(10/(A-T)*(ae-T));re.src=`https://magicfeedback-c6458-dev.web.app/assets/${de}.svg`}const ce=document.createElement("input");ce.id=`rating-${h}-${ae}`,ce.type="radio",ce.name=h,ce.value=ae.toString(),ce.classList.add(l),ce.classList.add("magicfeedback-input"),ne.appendChild(ce),ne.appendChild(re),ne.appendChild(oe),se.appendChild(ne),S.appendChild(se)}if(v.extraOption&&v.extraOptionText){const le=document.createElement("div");le.classList.add("magicfeedback-rating-option");const ue=document.createElement("label");ue.htmlFor=`rating-${h}-extra`,ue.classList.add("magicfeedback-rating-option-label-container");const pe=document.createElement("label");pe.htmlFor=`rating-${h}-extra`,pe.textContent=v.extraOptionText;const me=document.createElement("img");me.src="https://magicfeedback-c6458-dev.web.app/assets/question.svg",me.alt=`face-${h}-extra`,me.className="magicfeedback-rating-image-extra";const he=document.createElement("input");he.id=`rating-${h}-extra`,he.type="radio",he.name=h,he.value="-",he.classList.add(l),he.classList.add("magicfeedback-input"),ue.appendChild(he),ue.appendChild(me),ue.appendChild(pe),le.appendChild(ue),S.appendChild(le)}d.appendChild(O),d.appendChild(S);break;case a.FEEDBACKAPPANSWERTYPE.RATING_NUMBER:d=document.createElement("div"),l="magicfeedback-rating-number";const I=document.createElement("div");I.classList.add("magicfeedback-rating-number-container");const P=v.max?Number(v.max):5,N=v.min?Number(v.min):1,$=o(N,P,v.minPlaceholder,v.maxPlaceholder,v.extraOption);for(let fe=N;fe<=P;fe++){const ge=document.createElement("div");ge.classList.add("magicfeedback-rating-number-option");const be=document.createElement("label");be.htmlFor=`rating-${h}-${fe}`,be.classList.add("magicfeedback-rating-number-option-label-container");const ve=document.createElement("label");ve.htmlFor=`rating-${h}-${fe}`,ve.textContent=fe.toString();const ye=document.createElement("input");ye.id=`rating-${h}-${fe}`,ye.type="radio",ye.name=h,ye.value=fe.toString(),ye.classList.add(l),ye.classList.add("magicfeedback-input"),be.appendChild(ye),be.appendChild(ve),ge.appendChild(be),I.appendChild(ge)}if(v.extraOption&&v.extraOptionText){const Ee=document.createElement("div");Ee.classList.add("magicfeedback-rating-number-option");const ke=document.createElement("label");ke.htmlFor=`rating-${h}-extra`,ke.classList.add("magicfeedback-rating-number-option-label-container");const Ce=document.createElement("label");Ce.htmlFor=`rating-${h}-extra`,Ce.textContent=v.extraOptionText;const xe=document.createElement("input");xe.id=`rating-${h}-extra`,xe.type="radio",xe.name=h,xe.value="-",xe.classList.add(l),xe.classList.add("magicfeedback-input"),ke.appendChild(xe),ke.appendChild(Ce),Ee.appendChild(ke),I.appendChild(Ee)}d.appendChild($),d.appendChild(I);break;case a.FEEDBACKAPPANSWERTYPE.RATING_STAR:d=document.createElement("div"),l="magicfeedback-rating-star";const M=function(e,t,i){const a="magicfeedback-rating-star-selected",s=document.createElement("div");s.classList.add("magicfeedback-rating-star-container"),s.style.maxWidth="300px",s.style.margin="auto";for(let t=1;t<=5;t++){const i=document.createElement("label");i.classList.add("magicfeedback-rating-star-option");const n=document.createElement("input");n.id=`rating-${e}-${t}`,n.type="radio",n.name=e,n.value=t.toString(),n.style.position="absolute",n.style.opacity="0",n.style.width="0",n.style.height="0",n.classList.add("magicfeedback-input"),n.addEventListener("change",(()=>{const e=s.querySelectorAll(".rating__star");for(let t=0;t<e.length;t++)t+1<=Number(n.value)?e[t].classList.contains(a)||e[t].classList.add(a):e[t].classList.contains(a)&&e[t].classList.remove(a)})),i.appendChild(n);const o=document.createElement("label");o.htmlFor=`rating-${e}-${t}`,o.classList.add("rating__star"),o.textContent="★",o.style.fontSize="40px",o.style.color="#CCCCCC",o.style.cursor="pointer",i.appendChild(o),s.appendChild(i)}return s.appendChild(o(1,5,t,i,!1,!1)),s}(h,v.minPlaceholder,v.maxPlaceholder);d.appendChild(M);break;case a.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE:d=document.createElement("div"),l="magicfeedback-multiple-choice-image";const D=document.createElement("div");D.classList.add("magicfeedback-multiple-choice-image-container"),D.style.display="flex",D.style.flexDirection="row",D.style.flexWrap="wrap",D.style.justifyContent="center";const F=g.length;let _=1,q=1;switch(F){case 1:case 2:case 3:_=F,q=1;break;case 4:case 5:case 6:q=2,_=Math.ceil(F/q);break;case 7:case 8:case 9:q=3,_=Math.ceil(F/q);break;default:q=4,_=Math.ceil(F/q)}const R=void 0!==(null==v?void 0:v.addTitle)&&v.addTitle,B=void 0!==(null==v?void 0:v.multiOption)&&v.multiOption,j=void 0!==(null==v?void 0:v.randomPosition)&&v.randomPosition,U=void 0!==(null==v?void 0:v.extraOption)&&v.extraOption;function K(e){try{const{position:t,url:i,value:a}=e,s=document.createElement("label");s.classList.add("magicfeedback-multiple-choice-image-option"),s.style.width=`calc( ${100/_}% - 10px)`,s.style.height=`calc( ${100/q}% - 10px)`,s.style.margin="5px";const n=document.createElement("label");n.htmlFor=`rating-${h}-${t}`,n.classList.add("magicfeedback-image-option-label-container"),n.style.display="flex",n.style.flexDirection="column",n.addEventListener("mouseover",(()=>{n.style.border="2px solid #000"})),n.addEventListener("mouseout",(()=>{n.style.border="none"})),n.addEventListener("click",(()=>{n.style.border="2px solid #000"}));const o=document.createElement("label");o.textContent=a,o.classList.add("magicfeedback-multiple-choice-image-label");const r=document.createElement("input");r.id=`rating-${h}-${t}`,r.type=B?"checkbox":"radio",r.name=h,r.value=a,r.style.position="absolute",r.style.opacity="0",r.style.width="0",r.style.height="0",r.classList.add("magicfeedback-input");const c=document.createElement("img");c.classList.add("magicfeedback-multiple-choice-image-image"),c.src=i,c.style.cursor="pointer",c.style.backgroundSize="cover",c.style.backgroundPosition="center",c.style.width="100%",c.style.height="100%",c.style.objectFit="cover",c.style.margin="auto",n.appendChild(r),n.appendChild(c),R&&n.appendChild(o),s.appendChild(n),D.appendChild(s)}catch(e){console.error(e)}}j&&(g=g.sort((()=>Math.random()-.5))),g.forEach((e=>K(JSON.parse(e)))),U&&v.extraOptionValue&&v.extraOptionValue.length>0&&K(v.extraOptionValue[0]),d.appendChild(D);break;case a.FEEDBACKAPPANSWERTYPE.SELECT:d=document.createElement("select"),l="magicfeedback-select";const W=document.createElement("option");W.value="",W.text="slim"===t?n(p,i):b||"Select an option",W.disabled=!0,W.selected=!0,d.appendChild(W),g.forEach((e=>{const t=document.createElement("option");t.value=e,t.text=e,d.appendChild(t)}));break;case a.FEEDBACKAPPANSWERTYPE.DATE:d=document.createElement("input"),d.type="date",d.required=f,d.placeholder=E||s.placeholder.date(i||"en"),l="magicfeedback-date";break;case a.FEEDBACKAPPANSWERTYPE.CONSENT:d=document.createElement("input"),l="magicfeedback-consent",d.type="checkbox",d.id=`magicfeedback-${u}`,d.name=h,d.value="true",d.required=f,d.classList.add("magicfeedback-consent"),d.classList.add("magicfeedback-input");break;case a.FEEDBACKAPPANSWERTYPE.EMAIL:d=document.createElement("input"),d.type="email",d.required=f,d.placeholder=E||"you@example.com",l="magicfeedback-email";break;case a.FEEDBACKAPPANSWERTYPE.PASSWORD:d=document.createElement("input"),d.type="password",d.required=f,d.placeholder=E||s.placeholder.password(i||"en"),l="magicfeedback-password";break;case a.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX:d=document.createElement("div"),l="magicfeedback-multi-question-matrix";const Q=document.createElement("div");Q.classList.add("magicfeedback-multi-question-matrix-container");const Y=document.createElement("table");Y.classList.add("magicfeedback-multi-question-matrix-table");const G=document.createElement("thead");G.classList.add("magicfeedback-multi-question-matrix-header"),G.style.paddingBottom="15px";const H=document.createElement("tr");["",...g].forEach((e=>{const t=document.createElement("th");t.textContent=e,t.style.padding="0 10px 10px 10px ",H.appendChild(t)})),G.appendChild(H);const J=document.createElement("tbody");(null===(c=null==v?void 0:v.options)||void 0===c?void 0:c.length)>0&&v.options.split("|").forEach((e=>{const t=document.createElement("tr");t.style.paddingBottom="15px";const i=document.createElement("td");i.classList.add("magicfeedback-multi-question-matrix-row-label");const a=document.createElement("label");a.classList.add("magicfeedback-multi-question-matrix-label"),a.style.paddingRight="15px",a.textContent=e,i.appendChild(a),t.appendChild(i),g.forEach((i=>{const a=document.createElement("td"),s=document.createElement("input");s.type="checkbox",s.name=h,s.value=i,s.id=`matrix-${e}`,s.classList.add("magicfeedback-input"),s.style.padding="0 10px",a.appendChild(s),t.appendChild(a)})),J.appendChild(t)})),Y.appendChild(G),Y.appendChild(J),Q.appendChild(Y),d.appendChild(Q);break;case a.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST:d=document.createElement("div"),l="magicfeedback-priority-list";const V=document.createElement("div");V.classList.add("magicfeedback-priority-list-container");const X=document.createElement("ul");X.classList.add("magicfeedback-priority-list-list"),g.forEach(((e,t)=>{const i=document.createElement("li");i.classList.add("magicfeedback-priority-list-item"),i.style.display="flex",i.style.justifyContent="space-between",i.style.alignItems="center",i.style.margin="5px";const a=document.createElement("input");a.classList.add("magicfeedback-input-magicfeedback-priority-list"),a.classList.add("magicfeedback-input"),a.type="hidden",a.id=`priority-list-${h}`,a.name=h,a.value=`${t+1}. ${e}`,i.appendChild(a);const s=document.createElement("label");s.classList.add("magicfeedback-priority-list-item-label"),s.textContent=`${t+1}. ${e}`,i.appendChild(s);const n=document.createElement("div");n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="space-between";const o=document.createElement("img");o.classList.add("magicfeedback-priority-list-arrow-up"),o.src="https://magicfeedback-c6458-dev.web.app/assets/arrow.svg",o.style.width="20px",o.style.height="20px",o.style.cursor="pointer",o.style.margin="0 5px",o.style.color="#000",o.style.visibility=0===t?"hidden":"visible",o.addEventListener("click",(()=>{var t,n;const c=i.previousElementSibling;if(c){const d=Number(a.value.split(".")[0])-1;a.value=`${d}. ${e}`,s.textContent=`${d}. ${e}`,o.style.visibility=1===d?"hidden":"visible",r.style.visibility=d===g.length?"hidden":"visible";const l=c.querySelector(".magicfeedback-input-magicfeedback-priority-list"),u=c.querySelector(".magicfeedback-priority-list-item-label"),p=c.querySelector(".magicfeedback-priority-list-arrow-up"),m=c.querySelector(".magicfeedback-priority-list-arrow-down");if(l&&u&&p&&m){const e=Number(l.value.split(".")[0])+1;l.value=`${e}.${null===(t=u.textContent)||void 0===t?void 0:t.split(".")[1]}`,u.textContent=`${e}.${null===(n=u.textContent)||void 0===n?void 0:n.split(".")[1]}`,p.style.visibility=1===e?"hidden":"visible",m.style.visibility=e===g.length?"hidden":"visible"}X.insertBefore(i,c)}})),n.appendChild(o);const r=document.createElement("img");r.classList.add("magicfeedback-priority-list-arrow-down"),r.src="https://magicfeedback-c6458-dev.web.app/assets/arrow.svg",r.style.width="20px",r.style.height="20px",r.style.cursor="pointer",r.style.margin="0 5px",r.style.color="#000",r.style.transform="rotate(180deg)",r.style.visibility=t===g.length-1?"hidden":"visible",r.addEventListener("click",(()=>{var t,n;const c=i.nextElementSibling;if(c){const d=Number(a.value.split(".")[0])+1;a.value=d.toString(),s.textContent=`${d.toString()}. ${e}`,o.style.visibility=1===d?"hidden":"visible",r.style.visibility=d===g.length?"hidden":"visible";const l=c.querySelector(".magicfeedback-input-magicfeedback-priority-list"),u=c.querySelector(".magicfeedback-priority-list-item-label"),p=c.querySelector(".magicfeedback-priority-list-arrow-up"),m=c.querySelector(".magicfeedback-priority-list-arrow-down");if(l&&u&&p&&m){const e=Number(l.value.split(".")[0])-1;l.value=`${e}.${null===(t=u.textContent)||void 0===t?void 0:t.split(".")[1]}`,u.textContent=`${e}.${null===(n=u.textContent)||void 0===n?void 0:n.split(".")[1]}`,p.style.visibility=1===e?"hidden":"visible",m.style.visibility=e===g.length?"hidden":"visible"}X.insertBefore(c,i)}})),n.appendChild(r),i.appendChild(n),X.appendChild(i)})),V.appendChild(X),d.appendChild(V);break;case a.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM:d=document.createElement("div"),l="magicfeedback-point-system";const z=document.createElement("div");z.classList.add("magicfeedback-point-system-container");const Z=document.createElement("ul");Z.classList.add("magicfeedback-point-system-list"),Z.style.padding="0";const ee=100,te=ee/g.length,ie=document.createElement("div");ie.classList.add("magicfeedback-point-system-total"),ie.textContent="0 / 100 %",ie.style.textAlign="right",ie.style.fontSize="0.8em",ie.style.color="#999",ie.style.marginTop="5px",g.forEach((e=>{const t=document.createElement("li");t.classList.add("magicfeedback-point-system-item"),t.style.display="flex",t.style.justifyContent="space-between",t.style.alignItems="center",t.style.margin="5px";const i=document.createElement("label");i.textContent=e,t.appendChild(i);const a=document.createElement("span");a.classList.add("magicfeedback-point-system-input-container");const s=document.createElement("input");s.name=h,s.id=`point-system-${e}`,s.type="number",s.min="0",s.max=`${ee}`,s.value="0",s.classList.add("magicfeedback-input"),s.style.width="40px",s.style.border="0",s.style.textAlign="center",s.style.margin="0 5px";const n=document.createElement("span");n.textContent="%",n.style.color="#000",s.addEventListener("input",(()=>{const e=Z.querySelectorAll("input");let t=0;e.forEach((e=>{t+=Number(e.value)})),t>ee&&(s.value=`${te}%`,t-=Number(s.value)),ie.textContent=`${t} / 100 %`})),a.appendChild(s),a.appendChild(n),t.appendChild(a),Z.appendChild(t)})),z.appendChild(Z),z.appendChild(ie),d.appendChild(z);break;default:return y}d.id=`magicfeedback-${u}`,d.setAttribute("name",h),d.classList.add(l),(void 0!==b||null!==k)&&(d.value=k||b),["RADIO","MULTIPLECHOICE"].includes(m)||(d.classList.add("magicfeedback-input"),d.required=f);const w=document.createElement("label");if(w.setAttribute("for",`magicfeedback-${u}`),w.textContent=n(p,i),w.classList.add("magicfeedback-label"),["CONSENT"].includes(m))y.classList.add("magicfeedback-consent-container"),y.appendChild(d),y.appendChild(w);else{if("slim"!==t&&(y.appendChild(w),void 0!==(null==v?void 0:v.general)&&""!==(null==v?void 0:v.general))){const we=document.createElement("img");we.src=v.general,we.classList.add("magicfeedback-image"),we.style.maxWidth="auto",we.style.height="400px",we.style.margin="10px 0",y.appendChild(we)}if("LONGTEXT"===m&&C>0){const Le=document.createElement("div");if(Le.classList.add("magicfeedback-counter"),Le.textContent=`${d.value.length}/${C}`,Le.style.textAlign="right",Le.style.fontSize="0.8em",Le.style.color="#999",Le.style.marginTop="5px",d.addEventListener("input",(()=>{Le.textContent=`${d.value.length}/${C}`})),y.appendChild(d),y.appendChild(Le),v.extraOption&&v.extraOptionText){const Se=document.createElement("div");Se.classList.add("magicfeedback-skip-container"),Se.classList.add("magicfeedback-checkbox-container"),Se.style.display="flex",Se.style.justifyContent="flex-start";const Ae=document.createElement("input");Ae.classList.add("magicfeedback-skip"),Ae.type="checkbox",Ae.id=`skip-${h}`,Ae.name=h,Ae.value="-",Ae.style.cursor="pointer";const Te=document.createElement("label");Te.htmlFor=`skip-${h}`,Te.textContent=v.extraOptionText,Te.style.fontSize="0.8em",Te.style.color="#999",Te.style.cursor="pointer",Te.style.margin="0 5px",Ae.addEventListener("click",(()=>{d.value="-",r&&r()})),Se.appendChild(Ae),Se.appendChild(Te),y.appendChild(Se)}}else y.appendChild(d)}return y}(t,i,r,c);d.push(e)}})),d},t.renderActions=function(e="",t,i="Submit",a="Back",s="Next"){const n=document.createElement("div");n.classList.add("magicfeedback-action-container");const o=document.createElement("button");o.id="magicfeedback-submit",o.type="submit",o.classList.add("magicfeedback-submit"),o.textContent="MAGICSURVEY"===e?s||"Next":i||"Submit";const r=document.createElement("button");return r.id="magicfeedback-back",r.type="button",r.classList.add("magicfeedback-back"),r.textContent=a||"Back",r.addEventListener("click",t),"MAGICSURVEY"===e&&n.appendChild(r),n.appendChild(o),n},t.renderError=function(e){const t=document.createElement("div");return t.classList.add("magicfeedback-error"),t.textContent=e,t},t.renderSuccess=function(e){const t=document.createElement("div");return t.classList.add("magicfeedback-success"),t.textContent=e,t},t.renderStartMessage=function(e,t,i=!1,a="Go!"){const s=document.createElement("div");s.classList.add("magicfeedback-start-message-container");const n=document.createElement("div");n.classList.add("magicfeedback-start-message"),n.innerHTML=e;const o=document.createElement("button");return o.id="magicfeedback-start-message-button",o.classList.add("magicfeedback-start-message-button"),o.textContent=a,o.addEventListener("click",(()=>t())),s.appendChild(n),i&&s.appendChild(o),s}},341:function(e,t,i){var a=this&&this.__awaiter||function(e,t,i,a){return new(i||(i=Promise))((function(s,n){function o(e){try{c(a.next(e))}catch(e){n(e)}}function r(e){try{c(a.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}c((a=a.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getFollowUpQuestion=t.sendFeedback=t.getQuestions=t.getForm=t.validateEmail=void 0;const n=s(i(31)),o=s(i(147)),r=i(374),c={Accept:"application/json","Magicfeedback-Sdk-Version":o.default.version};t.validateEmail=function(e){return/\S+@\S+\.\S+/.test(e)},t.getForm=function(e,t,i,s){return a(this,void 0,void 0,(function*(){try{const a=yield(0,n.default)(e+r.endpoints.sdk.app_info(t,i),{method:"GET",headers:c});if(a.ok){const e=yield a.json();return s.log(`Received form for app ${t}`,e),e}throw s.err(`Failed to get questions for app ${t}:`,a.status,a.statusText),new Error("[MagicFeedback] Bad response from server")}catch(e){return s.err(e),null}}))},t.getQuestions=function(e,t,i,s){return a(this,void 0,void 0,(function*(){try{const a=yield(0,n.default)(e+r.endpoints.sdk.app(t,i),{method:"GET",headers:c});if(a.ok){const e=yield a.json();return s.log(`Received questions for app ${t}`,e),e}throw s.err(`Failed to get questions for app ${t}:`,a.status,a.statusText),new Error("[MagicFeedback] Bad response from server")}catch(e){return s.err(e),[]}}))},t.sendFeedback=function(e,t,i){return a(this,void 0,void 0,(function*(){try{const a=yield(0,n.default)(e+r.endpoints.sdk.feedback,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},c),body:JSON.stringify(t)});if(a.ok)return i.log(`Form ${t.integration} submitted successfully!`),(yield a.json()).sessionId;throw i.err(`Failed to submit form ${t.integration}:`,a.status,a.statusText),new Error(a.statusText)}catch(e){return i.err(e),""}}))},t.getFollowUpQuestion=function(e,t,i){return a(this,void 0,void 0,(function*(){try{const a=yield(0,n.default)(e+r.endpoints.sdk.followUpQuestion,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},c),body:JSON.stringify(t)});if(a.ok)return i.log(`Received follow up question for form ${t.integration}`),(yield a.json())||"";throw i.err(`Failed to get follow up question for form ${t.integration}:`,a.status,a.statusText),new Error(a.statusText)}catch(e){return i.err(e),""}}))}},5:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Log=void 0,t.Log=class{constructor(e){this.config=e}log(...e){this.config.get("debug")&&console.log("[MagicFeedback]:",...e)}err(...e){console.error("[MagicFeedback]:",...e)}}},31:e=>{e.exports=require("cross-fetch")},147:e=>{e.exports=JSON.parse('{"name":"@magicfeedback/native","version":"1.2.8-beta.7","main":"./dist/magicfeedback-sdk.node.js","browser":"./dist/magicfeedback-sdk.browser.js","types":"./dist/types/src/index.d.ts","repository":{"type":"git","url":"git+ssh://git@github.com/MagicFeedback/magicfeedback-sdk.git"},"author":"farias@magicfeedback.io","license":"MIT","private":false,"scripts":{"dev":"vite","build":"webpack","build:watch":"webpack --watch --mode development","publish":"npm publish --access public","publish:beta":"npm publish --access public --tag beta","test":"jest","test:watch":"jest --watchAll","coverage":"vitest run --coverage"},"files":["dist"],"devDependencies":{"@babel/preset-typescript":"^7.22.5","@types/node":"^17.0.21","@types/webpack":"^5.28.0","@types/webpack-node-externals":"^2.5.3","c8":"^7.11.0","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","jest-fetch-mock":"^3.0.3","nock":"^13.2.4","ts-jest":"^29.1.0","ts-loader":"^9.2.7","ts-node":"^10.7.0","typescript":"^4.6.2","vite":"^2.8.0","vite-plugin-dts":"^0.9.9","vitest":"^0.5.9","webpack":"^5.70.0","webpack-cli":"^4.9.2","webpack-node-externals":"^3.0.0"},"dependencies":{"cross-fetch":"^3.1.5","is-bundling-for-browser-or-node":"^1.1.1"},"description":"MagicFeedbackAI JavaScript Library for [MagicFeedback.io](https://magicfeedback.io/)","bugs":{"url":"https://github.com/MagicFeedback/magicfeedback-sdk/issues"},"homepage":"https://github.com/MagicFeedback/magicfeedback-sdk#readme","directories":{"example":"examples","test":"test"}}')}},t={},i=function i(a){var s=t[a];if(void 0!==s)return s.exports;var n=t[a]={exports:{}};return e[a].call(n.exports,n,n.exports,i),n.exports}(607);return i.default})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.magicfeedback=t():e.magicfeedback=t()}(global,(()=>(()=>{"use strict";var e={290:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HOST_API_URL_DEV=t.HOST_API_URL=void 0,t.HOST_API_URL="https://api.magicfeedback.io/",t.HOST_API_URL_DEV="https://api-dev.magicfeedback.io/"},607:function(e,t,i){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=a(i(519));let s=null;s||(s=(0,n.default)()),t.default=s},519:function(e,t,i){var a=this&&this.__awaiter||function(e,t,i,a){return new(i||(i=Promise))((function(n,s){function o(e){try{d(a.next(e))}catch(e){s(e)}}function r(e){try{d(a.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((a=a.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const n=i(954),s=i(712),o=i(5),r=i(341),d=i(290);t.default=function(){const e=new s.Config;let t;return{init:function(i){(null==i?void 0:i.debug)&&e.set("debug",null==i?void 0:i.debug),e.set("url",(null==i?void 0:i.env)&&"dev"===(null==i?void 0:i.env)?d.HOST_API_URL_DEV:d.HOST_API_URL),t=new o.Log(e),t.log("Initialized Magicfeedback",e)},send:function(i,n,s,o=!0,d,c){return a(this,void 0,void 0,(function*(){i||t.err("No appID provided"),n||t.err("No publicKey provided"),s||t.err("No feedback provided"),s.answers||s.profile||s.metrics||s.metadata||t.err("No feedback data provided");const a=e.get("url"),l={integration:i,publicKey:n,privateKey:c,completed:o,id:d,feedback:s};try{const e=yield(0,r.sendFeedback)(a,l,t);return t.log("sent native feedback"),e}catch(e){return t.err("error native feedback",e),!1}}))},form:function(i,a){return i||t.err("No appID provided"),a||t.err("No publicKey provided"),new n.Form(e,i,a)}}}},314:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.History=void 0,t.History=class{constructor(){this.items=[]}enqueue(e){this.items.push(e)}dequeue(){return this.items.shift()}rollback(){return this.items.pop()}front(){return this.items[0]}back(){return this.items[this.items.length-1]}isEmpty(){return 0===this.items.length}size(){return this.items.length}}},712:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Config=void 0,t.Config=class{constructor(){this.variables={},this.variables.env="prod",this.variables.debug=!1}get(e){return this.variables[e]}set(e,t){this.variables[e]=t}}},954:function(e,t,i){var a=this&&this.__awaiter||function(e,t,i,a){return new(i||(i=Promise))((function(n,s){function o(e){try{d(a.next(e))}catch(e){s(e)}}function r(e){try{d(a.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((a=a.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.Form=void 0;const n=i(5),s=i(341),o=i(183),r=i(24),d=i(804),c=i(116),l=i(314),u=i(457);t.Form=class{constructor(e,t,i){this.config=e,this.log=new n.Log(e),this.formOptionsConfig={addButton:!0,sendButtonText:"Send",backButtonText:"Back",nextButtonText:"Next",addSuccessScreen:!0,getMetaData:!0,questionFormat:"standard"},this.selector="",this.appId=t,this.publicKey=i,this.url=e.get("url"),this.id="",this.formData=null,this.getDataFromStorage(),this.feedback={text:"",answers:[],profile:[],metrics:[],metadata:[]},this.history=new l.History,this.graph=new r.PageGraph([]),this.progress=0,this.total=0}getDataFromStorage(){const e=localStorage.getItem(`magicfeedback-${this.appId}`);e&&new Date(JSON.parse(e).savedAt)<new Date((new Date).getTime()+864e5)&&(this.formData=JSON.parse(e),(0,s.getForm)(this.url,this.appId,this.publicKey,this.log).then((e=>{var t,i,a;(null==e?void 0:e.updatedAt)&&(null===(t=this.formData)||void 0===t?void 0:t.savedAt)&&(null==e?void 0:e.updatedAt)>(null===(i=this.formData)||void 0===i?void 0:i.savedAt)&&(console.log("Form updated"),this.formData=e,this.formData.savedAt=new Date,localStorage.setItem(`magicfeedback-${this.appId}`,JSON.stringify(this.formData)),(null===(a=this.formData.style)||void 0===a?void 0:a.startMessage)?this.generateWelcomeMessage(this.formData.style.startMessage):this.startForm())})))}generate(e,t){var i,n,o;return a(this,void 0,void 0,(function*(){try{if(this.formOptionsConfig=Object.assign(Object.assign({},this.formOptionsConfig),t),this.selector=e,void 0!==this.formData&&this.formData||(this.formData=yield(0,s.getForm)(this.url,this.appId,this.publicKey,this.log)),void 0===this.formData||!this.formData)throw new Error(`No form for app ${this.appId}`);if(this.formData.savedAt||(this.formData.savedAt=new Date,localStorage.setItem(`magicfeedback-${this.appId}`,JSON.stringify(this.formData))),void 0===this.formData.questions||!this.formData.questions)throw new Error(`No questions for app ${this.appId}`);0===(null===(i=this.formData.pages)||void 0===i?void 0:i.length)&&this.formatPages(),null===(n=this.formData.questions)||void 0===n||n.sort(((e,t)=>e.position-t.position)),this.formOptionsConfig.getMetaData&&this.getMetaData(),(null===(o=this.formData.style)||void 0===o?void 0:o.startMessage)?yield this.generateWelcomeMessage(this.formData.style.startMessage):this.startForm()}catch(e){return this.log.err(e),void(this.formOptionsConfig.onLoadedEvent&&(yield this.formOptionsConfig.onLoadedEvent({loading:!1,error:e})))}}))}formatPages(){var e;if(this.formData)switch(this.formData.identity){case"MAGICSURVEY":this.formData.pages=[],null===(e=this.formData.questions)||void 0===e||e.forEach((e=>{var t,i;const a=new c.PageRoute(e.id,e.ref,c.OperatorType.NOEQUAL,null,c.TransitionType.PAGE,(e.position+1).toString(),e.position.toString()),n=new d.Page(e.position.toString(),e.position,this.appId,[e],[a]);null===(i=null===(t=this.formData)||void 0===t?void 0:t.pages)||void 0===i||i.push(n)}));break;case"MAGICFORM":const t=new d.Page("1",1,this.appId,this.formData.questions,[]);this.formData.pages=[t]}}generateContainer(){let e=document.getElementById(this.selector);if(!e&&(e=document.getElementById("magicfeedback-container-"+this.appId),!e))throw new Error(`Element with ID '${this.selector}' not found.`);return e.classList.add("magicfeedback-container"),e.id="magicfeedback-container-"+this.appId,e.innerHTML="",e}generateForm(){var e,t,i,n;return a(this,void 0,void 0,(function*(){try{if(this.formData&&(null===(e=this.formData.pages)||void 0===e?void 0:e.length)>0){this.graph=new r.PageGraph(this.formData.pages.sort(((e,t)=>e.position-t.position)));let e=this.generateContainer();const a=document.createElement("form");a.classList.add("magicfeedback-form"),a.id="magicfeedback-"+this.appId;const s=document.createElement("div");s.classList.add("magicfeedback-questions"),s.id="magicfeedback-questions-"+this.appId;const d=this.graph.getFirstPage();if(!d)throw new Error("No page found");if(this.total=this.graph.findMaxDepth(),d.elements=(0,o.renderQuestions)(d.questions,this.formOptionsConfig.questionFormat,null===(t=this.formData)||void 0===t?void 0:t.lang[0],(()=>this.send())),null===(i=d.elements)||void 0===i||i.forEach((e=>s.appendChild(e))),a.appendChild(s),this.history.enqueue(d),e.appendChild(a),this.formOptionsConfig.addButton){const e=(0,o.renderActions)(null===(n=this.formData)||void 0===n?void 0:n.identity,(()=>this.back()),this.formOptionsConfig.sendButtonText,this.formOptionsConfig.backButtonText,this.formOptionsConfig.nextButtonText);a.appendChild(e)}a.addEventListener("submit",(e=>{e.preventDefault(),this.send()})),this.formOptionsConfig.onLoadedEvent&&(yield this.formOptionsConfig.onLoadedEvent({loading:!1,progress:this.progress,total:this.total,formData:this.formData}))}}catch(e){return this.log.err(e),void(this.formOptionsConfig.onLoadedEvent&&this.formOptionsConfig.onLoadedEvent({loading:!1,error:e}))}}))}startForm(){this.generateForm()}generateWelcomeMessage(e){return a(this,void 0,void 0,(function*(){try{const t=this.generateContainer(),i=(0,o.renderStartMessage)(e,(()=>this.startForm()),this.formOptionsConfig.addButton,this.formOptionsConfig.startButtonText);t.appendChild(i),this.formOptionsConfig.onLoadedEvent&&(yield this.formOptionsConfig.onLoadedEvent({loading:!1,formData:this.formData}))}catch(e){return this.log.err(e),void(this.formOptionsConfig.onLoadedEvent&&this.formOptionsConfig.onLoadedEvent({loading:!1,error:e}))}}))}getMetaData(){this.feedback.metadata.push({key:"navigator-url",value:[window.location.href]}),this.feedback.metadata.push({key:"navigator-origin",value:[window.location.origin]}),this.feedback.metadata.push({key:"navigator-pathname",value:[window.location.pathname]}),this.feedback.metadata.push({key:"navigator-search",value:[window.location.search]}),this.feedback.metadata.push({key:"navigator-user",value:[navigator.userAgent]}),this.feedback.metadata.push({key:"navigator-language",value:[navigator.language]}),this.feedback.metadata.push({key:"navigator-platform",value:[navigator.platform]}),this.feedback.metadata.push({key:"navigator-appVersion",value:[navigator.appVersion]}),this.feedback.metadata.push({key:"navigator-appName",value:[navigator.appName]}),this.feedback.metadata.push({key:"navigator-product",value:[navigator.product]}),this.feedback.metadata.push({key:"screen-width",value:[window.screen.width.toString()]}),this.feedback.metadata.push({key:"screen-height",value:[window.screen.height.toString()]})}send(e,t,i){var n;return a(this,void 0,void 0,(function*(){const a=document.getElementById("magicfeedback-questions-"+this.appId);try{i&&(this.feedback.profile=[...this.feedback.profile,...i]),t&&(this.feedback.metrics=[...this.feedback.metrics,...t]),e&&(this.feedback.metadata=[...this.feedback.metadata,...e]),this.answer(),this.formOptionsConfig.beforeSubmitEvent&&(yield this.formOptionsConfig.beforeSubmitEvent({loading:!0,progress:this.progress,total:this.total}));const s=this.history.back();if(!s)throw new Error("No page found");const o=s.getRequiredQuestions();for(const e of o)if(!this.feedback.answers.find((t=>t.key===e&&t.value.length>0)))return void this.log.err(`The question ${e} is required`);const r=yield this.pushAnswers("MAGICSURVEY"!==(null===(n=this.formData)||void 0===n?void 0:n.identity));r&&(this.id=r,yield this.processNextQuestion(a)),this.formOptionsConfig.afterSubmitEvent&&(yield this.formOptionsConfig.afterSubmitEvent({response:r,loading:!1,progress:this.progress,total:this.total,error:r?null:new Error("No response")}))}catch(e){this.log.err(`An error occurred while submitting the form ${this.appId}:`,e),this.formOptionsConfig.afterSubmitEvent&&(yield this.formOptionsConfig.afterSubmitEvent({loading:!1,progress:this.progress,total:this.total,error:e}))}}))}answer(){const e=document.getElementById("magicfeedback-"+this.appId);if(!e)return this.log.err(`Form "${e}" not found.`),void(this.feedback.answers=[]);const t=[];let i=!1;const a=e.querySelectorAll(".magicfeedback-input");a.forEach((e=>{const n=e.type,o=e.classList[0],r={key:e.name,value:[]},d="magicfeedback-consent"===o?e.checked.toString():e.value;if(r.key&&""!==r.key)switch(n){case"radio":case"checkbox":if("magicfeedback-consent"===o||e.checked){if(e.id.includes("matrix")){const t=e.id.split("-")[e.id.split("-").length-1];let i="";a.forEach((e=>{e.checked&&e.id.includes(`matrix-${t}`)&&(i+=e.value+", ")})),i=i.slice(0,-2),r.value.push(`${t}: ${i}`)}else r.value.push(d);const i=t.findIndex((e=>e.key===r.key));-1!==i?t[i].value=[...t[i].value,...r.value]:t.push(r)}break;default:if(""!==d){if("email"===n){if(!(0,s.validateEmail)(d)){this.log.err("Invalid email"),i=!0;break}this.feedback.profile.push({key:"email",value:[d]})}if(e.id.includes("point-system")){const t=e.id.split("-")[e.id.split("-").length-1];r.value.push(`${t}: ${d}%`)}else r.value.push(d);const a=t.findIndex((e=>e.key===r.key));-1!==a?t[a].value=[...t[a].value,...r.value]:t.push(r)}}})),this.feedback.answers=i?[]:t}finish(){if(this.formOptionsConfig.addSuccessScreen){const e=document.getElementById("magicfeedback-container-"+this.appId);e.childNodes.length>0&&e.removeChild(e.childNodes[0]);const t=(0,o.renderSuccess)(this.formOptionsConfig.successMessage||"Thank you for your feedback!");e.appendChild(t)}this.answer(),this.pushAnswers(!0)}pushAnswers(e=!1){return a(this,void 0,void 0,(function*(){try{const t=this.config.get("url"),i={integration:this.appId,publicKey:this.publicKey,feedback:this.feedback,completed:e};return yield(0,s.sendFeedback)(t,this.id?Object.assign(Object.assign({},i),{sessionId:this.id}):i,this.log)}catch(e){return this.log.err(`An error occurred while submitting the form ${this.appId}:`,e),""}}))}callFollowUpQuestion(e){var t;return a(this,void 0,void 0,(function*(){if(!(null==e?void 0:e.followup))return null;try{if(0===this.feedback.answers.length)throw new Error("No answers provided");const i=this.config.get("url"),a={answer:null===(t=this.feedback.answers.find((t=>t.key===e.ref)))||void 0===t?void 0:t.value[0],publicKey:this.publicKey,sessionId:this.id,question:e};return yield(0,s.getFollowUpQuestion)(i,a,this.log)}catch(e){throw this.log.err(`An error occurred while submitting the form ${this.appId}:`,e),e}}))}processNextQuestion(e){var t,i;return a(this,void 0,void 0,(function*(){const a=this.history.back();if(!a)throw new Error("No page found");const n=a.getFollowupQuestions();if((null==n?void 0:n.length)>0){const s=[];for(const e of n){const t=a.questions.find((t=>t.ref===e));if(t){const e=yield this.callFollowUpQuestion(t);e&&s.push(e)}}if(s.length>0){const n=new d.Page(a.id,a.position,this.appId,s,a.edges),r=new u.PageNode(a.id,a.position,a.edges,n,s);r.elements=(0,o.renderQuestions)(s,this.formOptionsConfig.questionFormat,null===(t=this.formData)||void 0===t?void 0:t.lang[0],(()=>this.send())),this.history.enqueue(r),e.removeChild(e.childNodes[0]),null===(i=r.elements)||void 0===i||i.forEach((t=>e.appendChild(t)))}else this.renderNextQuestion(e,a)}else this.renderNextQuestion(e,a)}))}renderNextQuestion(e,t){var i,a;const n=this.graph.getNextPage(t,this.feedback.answers);n?(this.progress=this.total-this.graph.findDepth(n.id),n.elements=(0,o.renderQuestions)(n.questions,this.formOptionsConfig.questionFormat,null===(i=this.formData)||void 0===i?void 0:i.lang[0],(()=>this.send())),e.removeChild(e.childNodes[0]),null===(a=n.elements)||void 0===a||a.forEach((t=>e.appendChild(t))),this.history.enqueue(n)):this.finish()}back(){var e;if(0===this.history.size())return;console.log("Back",this.history);const t=document.getElementById("magicfeedback-questions-"+this.appId);t&&t.childNodes.length>0&&t.removeChild(t.childNodes[0]),this.history.rollback();const i=this.history.back();i&&(null===(e=i.elements)||void 0===e||e.forEach((e=>t.appendChild(e))))}}},804:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Page=void 0,t.Page=class{constructor(e,t,i,a,n){this.id=e,this.position=t,this.generatedAt=(new Date).toISOString(),this.updatedAt=(new Date).getTime(),this.status="ACTIVE",this.integrationId=i,this.integrationQuestions=a,this.integrationPageRoutes=n}}},24:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PageGraph=void 0;const a=i(457),n=i(116);t.PageGraph=class{constructor(e){this.nodes=new Map,this.buildGraph(e)}buildGraph(e){e.forEach((e=>{const t=new a.PageNode(e.id,e.position,e.integrationPageRoutes||[],e,e.integrationQuestions);this.nodes.set(t.id,t)}))}getNodeById(e){return this.nodes.get(e)}getNextEdgeByDefault(e){if(e)for(const t of this.nodes.values())if(t.position===e.position+1)return t.id}getFirstPage(){let e,t=Number.MAX_VALUE;for(const i of this.nodes.values())i.position<t&&(t=i.position,e=i);return e}getNextPage(e,t){if(!e)return;const i=e.edges.find((e=>{const i=null==t?void 0:t.filter((t=>t.key===e.questionRef));if(!i)return!1;switch(e.typeOperator){case n.OperatorType.EQUAL:return i.find((t=>{var i;return null===(i=t.value)||void 0===i?void 0:i.includes(e.value)}));case n.OperatorType.NOEQUAL:return!i.find((t=>{var i;return null===(i=t.value)||void 0===i?void 0:i.includes(e.value)}));case n.OperatorType.GREATER:return i.find((t=>t.value.find((t=>Number(t)>Number(e.value)))));case n.OperatorType.LESS:return i.find((t=>t.value.find((t=>Number(t)<Number(e.value)))));case n.OperatorType.GREATEREQUAL:return console.log(i),i.find((t=>t.value.find((t=>Number(t)>=Number(e.value)))));case n.OperatorType.LESSEQUAL:return i.find((t=>t.value.find((t=>Number(t)<=Number(e.value)))));case n.OperatorType.INQ:return i.find((t=>e.value.includes(t.value)));case n.OperatorType.NINQ:return!i.find((t=>e.value.includes(t.value)));default:return!1}}));if(!i){const t=this.getNextEdgeByDefault(e);if(!t)return;return this.getNodeById(t)}return this.getNodeById(i.transitionDestiny)}findDepth(e){const t=this.getNodeById(e);if(!t)return 0;const i=new Set;return this.DFSUtil(t,i,0)}findMaxDepth(){const e=new Set;let t=0;return this.nodes.forEach((i=>{e.has(i)||(t=Math.max(t,this.DFSUtil(i,e,0)))})),t}DFSUtil(e,t,i){t.add(e);let a=i;const n=this.getNextEdgeByDefault(e);for(const s of n?[...e.edges,{transitionDestiny:n}]:e.edges){const e=this.getNodeById(s.transitionDestiny);e&&!t.has(e)&&(a=Math.max(a,this.DFSUtil(e,t,i+1)))}return a}}},457:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PageNode=void 0,t.PageNode=class{constructor(e,t,i,a,n){this.id=e,this.position=t,this.edges=i,this.data=a,this.questions=n,this.elements=[]}getFollowupQuestions(){return this.questions.filter((e=>e.followup)).map((e=>e.ref))}getRequiredQuestions(){return this.questions.filter((e=>e.require)).map((e=>e.ref))}}},116:(e,t)=>{var i,a,n,s;Object.defineProperty(t,"__esModule",{value:!0}),t.PageRoute=t.OperatorType=t.ConditionType=t.TransitionType=void 0,(s=t.TransitionType||(t.TransitionType={})).PAGE="PAGE",s.FINISH="FINISH",function(e){e.LOGICAL="LOGICAL"}(i=t.ConditionType||(t.ConditionType={})),(n=t.OperatorType||(t.OperatorType={})).EQUAL="EQUAL",n.NOEQUAL="NOEQUAL",n.GREATER="GREATER",n.LESS="LESS",n.GREATEREQUAL="GREATEREQUAL",n.LESSEQUAL="LESSEQUAL",n.INQ="INQ",n.NINQ="NINQ",n.DEFAULT="DEFAULT",function(e){e.ACTIVE="ACTIVE",e.DEPRECATED="DEPRECATED",e.DELETE="DELETE"}(a||(a={})),t.PageRoute=class{constructor(e,t,n,s,o,r,d){this.id=e,this.questionRef=t,this.typeCondition=i.LOGICAL,this.typeOperator=n,this.value=s,this.transition=o,this.transitionDestiny=r,this.status=a.ACTIVE,this.generatedAt=new Date,this.updatedAt=new Date,this.integrationPageId=d}}},244:(e,t)=>{var i,a;Object.defineProperty(t,"__esModule",{value:!0}),t.QuestionType=t.FEEDBACKAPPANSWERTYPE=void 0,(a=t.FEEDBACKAPPANSWERTYPE||(t.FEEDBACKAPPANSWERTYPE={})).CONTACT="CONTACT",a.MULTIPLECHOISE_IMAGE="MULTIPLECHOISE_IMAGE",a.EMAIL="EMAIL",a.RATING_STAR="RATING_STAR",a.RADIO="RADIO",a.MULTIPLECHOICE="MULTIPLECHOICE",a.SELECT="SELECT",a.TEXT="TEXT",a.LONGTEXT="LONGTEXT",a.NUMBER="NUMBER",a.RATING_EMOJI="RATING_EMOJI",a.RATING_NUMBER="RATING_NUMBER",a.DATE="DATE",a.BOOLEAN="BOOLEAN",a.PASSWORD="PASSWORD",a.CONSENT="CONSENT",a.MULTI_QUESTION_MATRIX="MULTI_QUESTION_MATRIX",a.POINT_SYSTEM="POINT_SYSTEM",a.PRIORITY_LIST="PRIORITY_LIST",t.QuestionType=class{},function(e){e.FORM="form",e.DIV="div"}(i||(i={}))},374:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.endpoints=void 0,t.endpoints={sdk:{app:(e,t)=>`sdk/app/${e}/${t}`,app_info:(e,t)=>`sdk/app/${e}/${t}/info`,feedback:"sdk/feedback",followUpQuestion:"sdk/followUpQuestion"}}},528:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.placeholder=void 0,t.placeholder={answer:e=>{switch(e){case"en":default:return"Write your answer here...";case"es":return"Escribe tu respuesta aquí...";case"da":return"Skriv dit svar her...";case"fi":return"Kirjoita vastauksesi tähän...";case"sv":return"Skriv ditt svar här...";case"no":return"Skriv svaret ditt her...";case"ar":return"اكتب إجابتك هنا...";case"bn":return"এখানে আপনার"}},number:e=>{switch(e){case"en":default:return"Write your number here...";case"es":return"Escribe tu número aquí...";case"da":return"Skriv dit nummer her...";case"fi":return"Kirjoita numerosi tähän...";case"sv":return"Skriv ditt nummer här...";case"no":return"Skriv nummeret ditt her...";case"ar":return"اكتب رقمك هنا...";case"bn":return"এখানে আপনার"}},email:e=>{switch(e){case"en":default:return"Write your email here...";case"es":return"Escribe tu correo electrónico aquí...";case"da":return"Skriv din e-mail her...";case"fi":return"Kirjoita sähköpostiosoitteesi tähän...";case"sv":return"Skriv din e-post här...";case"no":return"Skriv e-posten din her...";case"ar":return"اكتب بريدك الإلكتروني هنا...";case"bn":return"এখানে আপনার"}},date:e=>{switch(e){case"en":default:return"Write your date here...";case"es":return"Escribe tu fecha aquí...";case"da":return"Skriv din dato her...";case"fi":return"Kirjoita päivämääräsi tähän...";case"sv":return"Skriv ditt datum här...";case"no":return"Skriv datoen din her...";case"ar":return"اكتب تاريخك هنا...";case"bn":return"এখানে আপনার"}},password:e=>{switch(e){case"en":default:return"Write your password here...";case"es":return"Escribe tu contraseña aquí...";case"da":return"Skriv dit kodeord her...";case"fi":return"Kirjoita salasanasi tähän...";case"sv":return"Skriv ditt lösenord här...";case"no":return"Skriv passordet ditt her...";case"ar":return"اكتب كلمة المرور الخاصة بك هنا...";case"bn":return"এখানে আপনার"}}}},183:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.renderStartMessage=t.renderSuccess=t.renderError=t.renderActions=t.renderQuestions=void 0;const a=i(244),n=i(528);function s(e,t){return"object"==typeof e?e[t]||e.en:e}function o(e,t,i,a,n,s=!0){const o=document.createElement("div");o.classList.add("magicfeedback-rating-placeholder"),o.style.display="flex",o.style.justifyContent="space-between",o.style.width=n?`calc(100% - (100% / ${t+1}))`:"100%",o.style.marginRight="auto",s&&window.innerWidth<600&&(o.style.flexDirection="column");const r=document.createElement("span");r.textContent=i,r.classList.add("magicfeedback-rating-placeholder-value"),r.style.fontStyle="italic",r.style.fontSize="14px",r.style.textAlign="left",r.style.width="50%",s&&window.innerWidth<600&&(r.textContent=`${e} ➜ ${i}`,r.style.width="100%",r.style.textAlign="left",r.style.marginBottom="5px"),o.appendChild(r);const d=document.createElement("span");return d.textContent=a,d.classList.add("magicfeedback-rating-placeholder-value"),d.style.fontStyle="italic",d.style.fontSize="14px",d.style.textAlign="right",d.style.width="50%",s&&window.innerWidth<600&&(d.textContent=`${t} ➜ ${a}`,d.style.width="100%",d.style.textAlign="left",d.style.marginBottom="5px"),o.appendChild(d),o}t.renderQuestions=function e(t,i="standard",r="en",d){if(!t)throw new Error("[MagicFeedback] No questions provided");const c=[];return t.forEach((t=>{var l,u;if((null===(u=null===(l=null==t?void 0:t.questionType)||void 0===l?void 0:l.conf)||void 0===u?void 0:u.length)>0){let a=document.createElement("div");a.classList.add("magicfeedback-div"),t.questionType.conf.forEach((e=>{e.ref=t.ref,t.assets[e.id]&&(e.assets={placeholder:t.assets[e.id]})})),e(t.questionType.conf,i,r,d).forEach((e=>{a.appendChild(e)})),c.push(a)}else{const e=function(e,t,i,r){var d;let c,l,{id:u,title:p,type:m,ref:h,require:f,value:g,defaultValue:b,assets:v}=e,y=document.createElement("div");y.classList.add("magicfeedback-div");const E="slim"===t?s(p,i):null==v?void 0:v.placeholder,k=(x=u,new URLSearchParams(window.location.search).get(x)),C=v.maxCharacters||300;var x;switch(m){case a.FEEDBACKAPPANSWERTYPE.TEXT:c=document.createElement("input"),c.type="text",c.placeholder=E||n.placeholder.answer(i||"en"),l="magicfeedback-text";break;case a.FEEDBACKAPPANSWERTYPE.LONGTEXT:c=document.createElement("textarea"),c.rows=3,C>0&&(c.maxLength=C),c.placeholder=E||n.placeholder.answer(i||"en"),l="magicfeedback-longtext";break;case a.FEEDBACKAPPANSWERTYPE.NUMBER:c=document.createElement("input"),c.type="number",c.placeholder="slim"===t?s(p,i):n.placeholder.number(i||"en"),l="magicfeedback-number",g.length&&(g.sort(((e,t)=>Number(e)-Number(t))),c.max=g[g.length-1],c.min=g[0],c.value=g[0]);break;case a.FEEDBACKAPPANSWERTYPE.RADIO:case a.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE:c=document.createElement("div"),l="magicfeedback-"+("MULTIPLECHOICE"===m?"checkbox":"radio"),v.extraOption&&g.push(v.extraOptionText),g.forEach(((e,t)=>{const s=document.createElement("div");s.classList.add(`magicfeedback-${"MULTIPLECHOICE"===m?"checkbox":"radio"}-container`);const o=document.createElement("label"),r=document.createElement("input");if(r.id=`rating-${h}-${t}`,r.type="MULTIPLECHOICE"===m?"checkbox":"radio",r.name=h,r.value=e,r.classList.add(l),r.classList.add("magicfeedback-input"),m===a.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE&&v.maxOptions&&v.maxOptions>0&&r.addEventListener("change",(()=>{document.querySelectorAll(`input[name="${h}"]:checked`).length>v.maxOptions&&(r.checked=!1)})),e!==b&&e!==k||(r.checked=!0),o.textContent=e,o.htmlFor=`rating-${h}-${t}`,r.addEventListener("change",(t=>{const i=document.getElementById(`extra-option-${h}`);i&&v.extraOption&&(t.target.checked&&e===v.extraOptionText?i.style.display="block":i.style.display="none")})),s.appendChild(r),s.appendChild(o),c.appendChild(s),v.extraOption&&e===v.extraOptionText){const e=document.createElement("input");e.type="text",e.placeholder=v.extraOptionPlaceholder||n.placeholder.answer(i||"en"),e.classList.add("magicfeedback-extra-option"),e.classList.add("magicfeedback-input"),e.id=`extra-option-${h}`,e.name=`extra-option-${h}`,e.style.display="none",c.appendChild(e)}}));break;case a.FEEDBACKAPPANSWERTYPE.BOOLEAN:c=document.createElement("div"),l="magicfeedback-radio";const L=document.createElement("div");L.classList.add("magicfeedback-boolean-container"),L.style.display="flex",L.style.flexDirection="row",L.style.justifyContent="space-between",L.style.width="70%",L.style.margin="auto",(v.addIcon?["👍","👎"]:function(e){switch(e){case"es":return["Sí","No"];case"fr":return["Oui","Non"];case"de":return["Ja","Nein"];case"it":return["Sì","No"];case"pt":return["Sim","Não"];case"nl":return["Ja","Nee"];case"pl":return["Tak","Nie"];case"ru":return["Да","Нет"];case"ja":return["はい","いいえ"];case"zh":return["是","不"];case"ko":return["예","아니"];case"da":case"sv":return["Ja","Nej"];case"fi":return["Kyllä","Ei"];case"no":return["Ja","Nei"];case"ar":return["نعم","لا"];case"bn":return["হ্যাঁ","না"];default:return["Yes","No"]}}(i)).forEach(((e,t)=>{const i=document.createElement("label");i.classList.add("magicfeedback-boolean-option"),i.htmlFor=`rating-${h}-${t}`,i.style.cursor="pointer",i.style.border="1px solid #000",i.style.display="flex",i.style.justifyContent="center",i.style.alignItems="center",i.style.margin="auto",i.style.padding="0",i.style.width="45%",i.style.height="38px";const a=document.createElement("label");a.htmlFor=`rating-${h}-${t}`,a.textContent=e,a.style.margin="0",a.style.padding="0";const n=document.createElement("input");n.id=`rating-${h}-${t}`,n.type="radio",n.name=h,n.value=e,n.classList.add(l),n.classList.add("magicfeedback-input"),n.style.position="absolute",n.style.opacity="0",n.style.width="0",n.style.height="0",n.style.margin="0",n.addEventListener("change",(()=>{r&&r()})),i.appendChild(n),i.appendChild(a),L.appendChild(i)})),c.appendChild(L);break;case a.FEEDBACKAPPANSWERTYPE.RATING_EMOJI:c=document.createElement("div"),l="magicfeedback-rating";const A=document.createElement("div");A.classList.add("magicfeedback-rating-container");const T=v.max?Number(v.max):5,S=v.min?Number(v.min):1,O=o(S,T,v.minPlaceholder,v.maxPlaceholder,v.extraOption);for(let ae=S;ae<=T;ae++){const ne=document.createElement("div");ne.classList.add("magicfeedback-rating-option");const se=document.createElement("label");se.htmlFor=`rating-${h}-${ae}`,se.classList.add("magicfeedback-rating-option-label-container");const oe=document.createElement("label");oe.htmlFor=`rating-${h}-${ae}`,oe.textContent=ae.toString();const re=document.createElement("img");if(re.alt=`face-${h}-${ae}`,re.className=`rating-image${ae}`,0===S&&10===T)re.src=`https://magicfeedback-c6458-dev.web.app/assets/${ae}.svg`;else if(1===S&&5===T)switch(ae){case 1:re.src="https://magicfeedback-c6458-dev.web.app/assets/1.svg";break;case 2:re.src="https://magicfeedback-c6458-dev.web.app/assets/2.svg";break;case 3:re.src="https://magicfeedback-c6458-dev.web.app/assets/6.svg";break;case 4:re.src="https://magicfeedback-c6458-dev.web.app/assets/9.svg";break;case 5:re.src="https://magicfeedback-c6458-dev.web.app/assets/10.svg"}else{const ce=Math.round(10/(T-S)*(ae-S));re.src=`https://magicfeedback-c6458-dev.web.app/assets/${ce}.svg`}const de=document.createElement("input");de.id=`rating-${h}-${ae}`,de.type="radio",de.name=h,de.value=ae.toString(),de.classList.add(l),de.classList.add("magicfeedback-input"),se.appendChild(de),se.appendChild(re),se.appendChild(oe),ne.appendChild(se),A.appendChild(ne)}if(v.extraOption&&v.extraOptionText){const le=document.createElement("div");le.classList.add("magicfeedback-rating-option");const ue=document.createElement("label");ue.htmlFor=`rating-${h}-extra`,ue.classList.add("magicfeedback-rating-option-label-container");const pe=document.createElement("label");pe.htmlFor=`rating-${h}-extra`,pe.textContent=v.extraOptionText;const me=document.createElement("img");me.src="https://magicfeedback-c6458-dev.web.app/assets/question.svg",me.alt=`face-${h}-extra`,me.className="magicfeedback-rating-image-extra";const he=document.createElement("input");he.id=`rating-${h}-extra`,he.type="radio",he.name=h,he.value="-",he.classList.add(l),he.classList.add("magicfeedback-input"),ue.appendChild(he),ue.appendChild(me),ue.appendChild(pe),le.appendChild(ue),A.appendChild(le)}c.appendChild(O),c.appendChild(A);break;case a.FEEDBACKAPPANSWERTYPE.RATING_NUMBER:c=document.createElement("div"),l="magicfeedback-rating-number";const N=document.createElement("div");N.classList.add("magicfeedback-rating-number-container");const P=v.max?Number(v.max):5,I=v.min?Number(v.min):1,D=o(I,P,v.minPlaceholder,v.maxPlaceholder,v.extraOption);for(let fe=I;fe<=P;fe++){const ge=document.createElement("div");ge.classList.add("magicfeedback-rating-number-option");const be=document.createElement("label");be.htmlFor=`rating-${h}-${fe}`,be.classList.add("magicfeedback-rating-number-option-label-container");const ve=document.createElement("label");ve.htmlFor=`rating-${h}-${fe}`,ve.textContent=fe.toString();const ye=document.createElement("input");ye.id=`rating-${h}-${fe}`,ye.type="radio",ye.name=h,ye.value=fe.toString(),ye.classList.add(l),ye.classList.add("magicfeedback-input"),be.appendChild(ye),be.appendChild(ve),ge.appendChild(be),N.appendChild(ge)}if(v.extraOption&&v.extraOptionText){const Ee=document.createElement("div");Ee.classList.add("magicfeedback-rating-number-option");const ke=document.createElement("label");ke.htmlFor=`rating-${h}-extra`,ke.classList.add("magicfeedback-rating-number-option-label-container");const Ce=document.createElement("label");Ce.htmlFor=`rating-${h}-extra`,Ce.textContent=v.extraOptionText;const xe=document.createElement("input");xe.id=`rating-${h}-extra`,xe.type="radio",xe.name=h,xe.value="-",xe.classList.add(l),xe.classList.add("magicfeedback-input"),ke.appendChild(xe),ke.appendChild(Ce),Ee.appendChild(ke),N.appendChild(Ee)}c.appendChild(D),c.appendChild(N);break;case a.FEEDBACKAPPANSWERTYPE.RATING_STAR:c=document.createElement("div"),l="magicfeedback-rating-star";const $=function(e,t,i){const a="magicfeedback-rating-star-selected",n=document.createElement("div");n.classList.add("magicfeedback-rating-star-container"),n.style.maxWidth="300px",n.style.margin="auto";for(let t=1;t<=5;t++){const i=document.createElement("label");i.classList.add("magicfeedback-rating-star-option");const s=document.createElement("input");s.id=`rating-${e}-${t}`,s.type="radio",s.name=e,s.value=t.toString(),s.style.position="absolute",s.style.opacity="0",s.style.width="0",s.style.height="0",s.classList.add("magicfeedback-input"),s.addEventListener("change",(()=>{const e=n.querySelectorAll(".rating__star");for(let t=0;t<e.length;t++)t+1<=Number(s.value)?e[t].classList.contains(a)||e[t].classList.add(a):e[t].classList.contains(a)&&e[t].classList.remove(a)})),i.appendChild(s);const o=document.createElement("label");o.htmlFor=`rating-${e}-${t}`,o.classList.add("rating__star"),o.textContent="★",o.style.fontSize="40px",o.style.color="#CCCCCC",o.style.cursor="pointer",i.appendChild(o),n.appendChild(i)}return n.appendChild(o(1,5,t,i,!1,!1)),n}(h,v.minPlaceholder,v.maxPlaceholder);c.appendChild($);break;case a.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE:c=document.createElement("div"),l="magicfeedback-multiple-choice-image";const M=document.createElement("div");M.classList.add("magicfeedback-multiple-choice-image-container"),M.style.display="flex",M.style.flexDirection="row",M.style.flexWrap="wrap",M.style.justifyContent="center";const R=g.length;let F=1,_=1;switch(R){case 1:case 2:case 3:F=R,_=1;break;case 4:case 5:case 6:_=2,F=Math.ceil(R/_);break;case 7:case 8:case 9:_=3,F=Math.ceil(R/_);break;default:_=4,F=Math.ceil(R/_)}const q=void 0!==(null==v?void 0:v.addTitle)&&v.addTitle,B=void 0!==(null==v?void 0:v.multiOption)&&v.multiOption,U=void 0!==(null==v?void 0:v.randomPosition)&&v.randomPosition,j=void 0!==(null==v?void 0:v.extraOption)&&v.extraOption;function Q(e){try{const{position:t,url:i,value:a}=e,n=document.createElement("label");n.classList.add("magicfeedback-multiple-choice-image-option"),n.style.width=`calc( ${100/F}% - 10px)`,n.style.height=`calc( ${100/_}% - 10px)`,n.style.margin="5px";const s=document.createElement("label");s.htmlFor=`rating-${h}-${t}`,s.classList.add("magicfeedback-image-option-label-container"),s.style.display="flex",s.style.flexDirection="column",s.addEventListener("mouseover",(()=>{s.style.border="2px solid #000"})),s.addEventListener("mouseout",(()=>{s.style.border="none"})),s.addEventListener("click",(()=>{s.style.border="2px solid #000"}));const o=document.createElement("label");o.textContent=a,o.classList.add("magicfeedback-multiple-choice-image-label");const r=document.createElement("input");r.id=`rating-${h}-${t}`,r.type=B?"checkbox":"radio",r.name=h,r.value=a,r.style.position="absolute",r.style.opacity="0",r.style.width="0",r.style.height="0",r.classList.add("magicfeedback-input");const d=document.createElement("img");d.classList.add("magicfeedback-multiple-choice-image-image"),d.src=i,d.style.cursor="pointer",d.style.backgroundSize="cover",d.style.backgroundPosition="center",d.style.width="100%",d.style.height="100%",d.style.objectFit="cover",d.style.margin="auto",s.appendChild(r),s.appendChild(d),q&&s.appendChild(o),n.appendChild(s),M.appendChild(n)}catch(e){console.error(e)}}U&&(g=g.sort((()=>Math.random()-.5))),g.forEach((e=>Q(JSON.parse(e)))),j&&v.extraOptionValue&&v.extraOptionValue.length>0&&Q(v.extraOptionValue[0]),c.appendChild(M);break;case a.FEEDBACKAPPANSWERTYPE.SELECT:c=document.createElement("select"),l="magicfeedback-select";const G=document.createElement("option");G.value="",G.text="slim"===t?s(p,i):b||"Select an option",G.disabled=!0,G.selected=!0,c.appendChild(G),g.forEach((e=>{const t=document.createElement("option");t.value=e,t.text=e,c.appendChild(t)}));break;case a.FEEDBACKAPPANSWERTYPE.DATE:c=document.createElement("input"),c.type="date",c.required=f,c.placeholder=E||n.placeholder.date(i||"en"),l="magicfeedback-date";break;case a.FEEDBACKAPPANSWERTYPE.CONSENT:c=document.createElement("input"),l="magicfeedback-consent",c.type="checkbox",c.id=`magicfeedback-${u}`,c.name=h,c.value="true",c.required=f,c.classList.add("magicfeedback-consent"),c.classList.add("magicfeedback-input");break;case a.FEEDBACKAPPANSWERTYPE.EMAIL:c=document.createElement("input"),c.type="email",c.required=f,c.placeholder=E||"you@example.com",l="magicfeedback-email";break;case a.FEEDBACKAPPANSWERTYPE.PASSWORD:c=document.createElement("input"),c.type="password",c.required=f,c.placeholder=E||n.placeholder.password(i||"en"),l="magicfeedback-password";break;case a.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX:c=document.createElement("div"),l="magicfeedback-multi-question-matrix";const K=document.createElement("div");K.classList.add("magicfeedback-multi-question-matrix-container");const W=document.createElement("table");W.classList.add("magicfeedback-multi-question-matrix-table");const Y=document.createElement("thead");Y.classList.add("magicfeedback-multi-question-matrix-header"),Y.style.paddingBottom="15px";const H=document.createElement("tr");["",...g].forEach((e=>{const t=document.createElement("th");t.textContent=e,t.style.padding="0 10px 10px 10px ",H.appendChild(t)})),Y.appendChild(H);const V=document.createElement("tbody");(null===(d=null==v?void 0:v.options)||void 0===d?void 0:d.length)>0&&v.options.split("|").forEach((e=>{const t=document.createElement("tr");t.style.paddingBottom="15px";const i=document.createElement("td");i.classList.add("magicfeedback-multi-question-matrix-row-label");const a=document.createElement("label");a.classList.add("magicfeedback-multi-question-matrix-label"),a.style.paddingRight="15px",a.textContent=e,i.appendChild(a),t.appendChild(i),g.forEach((i=>{const a=document.createElement("td"),n=document.createElement("input");n.type="checkbox",n.name=h,n.value=i,n.id=`matrix-${e}`,n.classList.add("magicfeedback-input"),n.style.padding="0 10px",a.appendChild(n),t.appendChild(a)})),V.appendChild(t)})),W.appendChild(Y),W.appendChild(V),K.appendChild(W),c.appendChild(K);break;case a.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST:c=document.createElement("div"),l="magicfeedback-priority-list";const J=document.createElement("div");J.classList.add("magicfeedback-priority-list-container");const z=document.createElement("ul");z.classList.add("magicfeedback-priority-list-list"),g.forEach(((e,t)=>{const i=document.createElement("li");i.classList.add("magicfeedback-priority-list-item"),i.style.display="flex",i.style.justifyContent="space-between",i.style.alignItems="center",i.style.margin="5px";const a=document.createElement("input");a.classList.add("magicfeedback-input-magicfeedback-priority-list"),a.classList.add("magicfeedback-input"),a.type="hidden",a.id=`priority-list-${h}`,a.name=h,a.value=`${t+1}. ${e}`,i.appendChild(a);const n=document.createElement("label");n.classList.add("magicfeedback-priority-list-item-label"),n.textContent=`${t+1}. ${e}`,i.appendChild(n);const s=document.createElement("div");s.style.display="flex",s.style.alignItems="center",s.style.justifyContent="space-between";const o=document.createElement("img");o.classList.add("magicfeedback-priority-list-arrow-up"),o.src="https://magicfeedback-c6458-dev.web.app/assets/arrow.svg",o.style.width="20px",o.style.height="20px",o.style.cursor="pointer",o.style.margin="0 5px",o.style.color="#000",o.style.visibility=0===t?"hidden":"visible",o.addEventListener("click",(()=>{var t,s;const d=i.previousElementSibling;if(d){const c=Number(a.value.split(".")[0])-1;a.value=`${c}. ${e}`,n.textContent=`${c}. ${e}`,o.style.visibility=1===c?"hidden":"visible",r.style.visibility=c===g.length?"hidden":"visible";const l=d.querySelector(".magicfeedback-input-magicfeedback-priority-list"),u=d.querySelector(".magicfeedback-priority-list-item-label"),p=d.querySelector(".magicfeedback-priority-list-arrow-up"),m=d.querySelector(".magicfeedback-priority-list-arrow-down");if(l&&u&&p&&m){const e=Number(l.value.split(".")[0])+1;l.value=`${e}.${null===(t=u.textContent)||void 0===t?void 0:t.split(".")[1]}`,u.textContent=`${e}.${null===(s=u.textContent)||void 0===s?void 0:s.split(".")[1]}`,p.style.visibility=1===e?"hidden":"visible",m.style.visibility=e===g.length?"hidden":"visible"}z.insertBefore(i,d)}})),s.appendChild(o);const r=document.createElement("img");r.classList.add("magicfeedback-priority-list-arrow-down"),r.src="https://magicfeedback-c6458-dev.web.app/assets/arrow.svg",r.style.width="20px",r.style.height="20px",r.style.cursor="pointer",r.style.margin="0 5px",r.style.color="#000",r.style.transform="rotate(180deg)",r.style.visibility=t===g.length-1?"hidden":"visible",r.addEventListener("click",(()=>{var t,s;const d=i.nextElementSibling;if(d){const c=Number(a.value.split(".")[0])+1;a.value=c.toString(),n.textContent=`${c.toString()}. ${e}`,o.style.visibility=1===c?"hidden":"visible",r.style.visibility=c===g.length?"hidden":"visible";const l=d.querySelector(".magicfeedback-input-magicfeedback-priority-list"),u=d.querySelector(".magicfeedback-priority-list-item-label"),p=d.querySelector(".magicfeedback-priority-list-arrow-up"),m=d.querySelector(".magicfeedback-priority-list-arrow-down");if(l&&u&&p&&m){const e=Number(l.value.split(".")[0])-1;l.value=`${e}.${null===(t=u.textContent)||void 0===t?void 0:t.split(".")[1]}`,u.textContent=`${e}.${null===(s=u.textContent)||void 0===s?void 0:s.split(".")[1]}`,p.style.visibility=1===e?"hidden":"visible",m.style.visibility=e===g.length?"hidden":"visible"}z.insertBefore(d,i)}})),s.appendChild(r),i.appendChild(s),z.appendChild(i)})),J.appendChild(z),c.appendChild(J);break;case a.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM:c=document.createElement("div"),l="magicfeedback-point-system";const X=document.createElement("div");X.classList.add("magicfeedback-point-system-container");const Z=document.createElement("ul");Z.classList.add("magicfeedback-point-system-list"),Z.style.padding="0";const ee=100,te=ee/g.length,ie=document.createElement("div");ie.classList.add("magicfeedback-point-system-total"),ie.textContent="0 / 100 %",ie.style.textAlign="right",ie.style.fontSize="0.8em",ie.style.color="#999",ie.style.marginTop="5px",g.forEach((e=>{const t=document.createElement("li");t.classList.add("magicfeedback-point-system-item"),t.style.display="flex",t.style.justifyContent="space-between",t.style.alignItems="center",t.style.margin="5px";const i=document.createElement("label");i.textContent=e,t.appendChild(i);const a=document.createElement("span");a.classList.add("magicfeedback-point-system-input-container");const n=document.createElement("input");n.name=h,n.id=`point-system-${e}`,n.type="number",n.min="0",n.max=`${ee}`,n.value="0",n.classList.add("magicfeedback-input"),n.style.width="40px",n.style.border="0",n.style.textAlign="center",n.style.margin="0 5px";const s=document.createElement("span");s.textContent="%",s.style.color="#000",n.addEventListener("input",(()=>{const e=Z.querySelectorAll("input");let t=0;e.forEach((e=>{t+=Number(e.value)})),t>ee&&(n.value=`${te}%`,t-=Number(n.value)),ie.textContent=`${t} / 100 %`})),a.appendChild(n),a.appendChild(s),t.appendChild(a),Z.appendChild(t)})),X.appendChild(Z),X.appendChild(ie),c.appendChild(X);break;default:return y}c.id=`magicfeedback-${u}`,c.setAttribute("name",h),c.classList.add(l),(void 0!==b||null!==k)&&(c.value=k||b),["RADIO","MULTIPLECHOICE"].includes(m)||(c.classList.add("magicfeedback-input"),c.required=f);const w=document.createElement("label");if(w.setAttribute("for",`magicfeedback-${u}`),w.textContent=s(p,i),w.classList.add("magicfeedback-label"),["CONSENT"].includes(m))y.classList.add("magicfeedback-consent-container"),y.appendChild(c),y.appendChild(w);else{if("slim"!==t&&(y.appendChild(w),void 0!==(null==v?void 0:v.general)&&""!==(null==v?void 0:v.general))){const we=document.createElement("img");we.src=v.general,we.classList.add("magicfeedback-image"),we.style.maxWidth="auto",we.style.height="400px",we.style.margin="10px 0",y.appendChild(we)}if("LONGTEXT"===m&&C>0){const Le=document.createElement("div");if(Le.classList.add("magicfeedback-counter"),Le.textContent=`${c.value.length}/${C}`,Le.style.textAlign="right",Le.style.fontSize="0.8em",Le.style.color="#999",Le.style.marginTop="5px",c.addEventListener("input",(()=>{Le.textContent=`${c.value.length}/${C}`})),y.appendChild(c),y.appendChild(Le),v.extraOption&&v.extraOptionText){const Ae=document.createElement("div");Ae.classList.add("magicfeedback-skip-container"),Ae.classList.add("magicfeedback-checkbox-container"),Ae.style.display="flex",Ae.style.justifyContent="flex-start";const Te=document.createElement("input");Te.classList.add("magicfeedback-skip"),Te.type="checkbox",Te.id=`skip-${h}`,Te.name=h,Te.value="-",Te.style.cursor="pointer";const Se=document.createElement("label");Se.htmlFor=`skip-${h}`,Se.textContent=v.extraOptionText,Se.style.fontSize="0.8em",Se.style.color="#999",Se.style.cursor="pointer",Se.style.margin="0 5px",Te.addEventListener("click",(()=>{c.value="-",r&&r()})),Ae.appendChild(Te),Ae.appendChild(Se),y.appendChild(Ae)}}else y.appendChild(c)}return y}(t,i,r,d);c.push(e)}})),c},t.renderActions=function(e="",t,i="Submit",a="Back",n="Next"){const s=document.createElement("div");s.classList.add("magicfeedback-action-container");const o=document.createElement("button");o.id="magicfeedback-submit",o.type="submit",o.classList.add("magicfeedback-submit"),o.textContent="MAGICSURVEY"===e?n||"Next":i||"Submit";const r=document.createElement("button");return r.id="magicfeedback-back",r.type="button",r.classList.add("magicfeedback-back"),r.textContent=a||"Back",r.addEventListener("click",t),"MAGICSURVEY"===e&&s.appendChild(r),s.appendChild(o),s},t.renderError=function(e){const t=document.createElement("div");return t.classList.add("magicfeedback-error"),t.textContent=e,t},t.renderSuccess=function(e){const t=document.createElement("div");return t.classList.add("magicfeedback-success"),t.textContent=e,t},t.renderStartMessage=function(e,t,i=!1,a="Go!"){const n=document.createElement("div");n.classList.add("magicfeedback-start-message-container");const s=document.createElement("div");s.classList.add("magicfeedback-start-message"),s.innerHTML=e;const o=document.createElement("button");return o.id="magicfeedback-start-message-button",o.classList.add("magicfeedback-start-message-button"),o.textContent=a,o.addEventListener("click",(()=>t())),n.appendChild(s),i&&n.appendChild(o),n}},341:function(e,t,i){var a=this&&this.__awaiter||function(e,t,i,a){return new(i||(i=Promise))((function(n,s){function o(e){try{d(a.next(e))}catch(e){s(e)}}function r(e){try{d(a.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((a=a.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getFollowUpQuestion=t.sendFeedback=t.getQuestions=t.getForm=t.validateEmail=void 0;const s=n(i(31)),o=n(i(147)),r=i(374),d={Accept:"application/json","Magicfeedback-Sdk-Version":o.default.version};t.validateEmail=function(e){return/\S+@\S+\.\S+/.test(e)},t.getForm=function(e,t,i,n){return a(this,void 0,void 0,(function*(){try{const a=yield(0,s.default)(e+r.endpoints.sdk.app_info(t,i),{method:"GET",headers:d});if(a.ok){const e=yield a.json();return n.log(`Received form for app ${t}`,e),e}throw n.err(`Failed to get questions for app ${t}:`,a.status,a.statusText),new Error("[MagicFeedback] Bad response from server")}catch(e){return n.err(e),null}}))},t.getQuestions=function(e,t,i,n){return a(this,void 0,void 0,(function*(){try{const a=yield(0,s.default)(e+r.endpoints.sdk.app(t,i),{method:"GET",headers:d});if(a.ok){const e=yield a.json();return n.log(`Received questions for app ${t}`,e),e}throw n.err(`Failed to get questions for app ${t}:`,a.status,a.statusText),new Error("[MagicFeedback] Bad response from server")}catch(e){return n.err(e),[]}}))},t.sendFeedback=function(e,t,i){return a(this,void 0,void 0,(function*(){try{const a=yield(0,s.default)(e+r.endpoints.sdk.feedback,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},d),body:JSON.stringify(t)});if(a.ok)return i.log(`Form ${t.integration} submitted successfully!`),(yield a.json()).sessionId;throw i.err(`Failed to submit form ${t.integration}:`,a.status,a.statusText),new Error(a.statusText)}catch(e){return i.err(e),""}}))},t.getFollowUpQuestion=function(e,t,i){return a(this,void 0,void 0,(function*(){try{const a=yield(0,s.default)(e+r.endpoints.sdk.followUpQuestion,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},d),body:JSON.stringify(t)});if(a.ok)return i.log(`Received follow up question for form ${t.integration}`),(yield a.json())||"";throw i.err(`Failed to get follow up question for form ${t.integration}:`,a.status,a.statusText),new Error(a.statusText)}catch(e){return i.err(e),""}}))}},5:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Log=void 0,t.Log=class{constructor(e){this.config=e}log(...e){this.config.get("debug")&&console.log("[MagicFeedback]:",...e)}err(...e){console.error("[MagicFeedback]:",...e)}}},31:e=>{e.exports=require("cross-fetch")},147:e=>{e.exports=JSON.parse('{"name":"@magicfeedback/native","version":"1.2.8-beta.8","main":"./dist/magicfeedback-sdk.node.js","browser":"./dist/magicfeedback-sdk.browser.js","types":"./dist/types/src/index.d.ts","repository":{"type":"git","url":"git+ssh://git@github.com/MagicFeedback/magicfeedback-sdk.git"},"author":"farias@magicfeedback.io","license":"MIT","private":false,"scripts":{"dev":"vite","build":"webpack","build:watch":"webpack --watch --mode development","publish":"npm publish --access public","publish:beta":"npm publish --access public --tag beta","test":"jest","test:watch":"jest --watchAll","coverage":"vitest run --coverage"},"files":["dist"],"devDependencies":{"@babel/preset-typescript":"^7.22.5","@types/node":"^17.0.21","@types/webpack":"^5.28.0","@types/webpack-node-externals":"^2.5.3","c8":"^7.11.0","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","jest-fetch-mock":"^3.0.3","nock":"^13.2.4","ts-jest":"^29.1.0","ts-loader":"^9.2.7","ts-node":"^10.7.0","typescript":"^4.6.2","vite":"^2.8.0","vite-plugin-dts":"^0.9.9","vitest":"^0.5.9","webpack":"^5.70.0","webpack-cli":"^4.9.2","webpack-node-externals":"^3.0.0"},"dependencies":{"cross-fetch":"^3.1.5","is-bundling-for-browser-or-node":"^1.1.1"},"description":"MagicFeedbackAI JavaScript Library for [MagicFeedback.io](https://magicfeedback.io/)","bugs":{"url":"https://github.com/MagicFeedback/magicfeedback-sdk/issues"},"homepage":"https://github.com/MagicFeedback/magicfeedback-sdk#readme","directories":{"example":"examples","test":"test"}}')}},t={},i=function i(a){var n=t[a];if(void 0!==n)return n.exports;var s=t[a]={exports:{}};return e[a].call(s.exports,s,s.exports,i),s.exports}(607);return i.default})()));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generateFormOptions, NativeAnswer
|
|
1
|
+
import { generateFormOptions, NativeAnswer } from "./types";
|
|
2
2
|
import { Config } from "./config";
|
|
3
3
|
export declare class Form {
|
|
4
4
|
/**
|
|
@@ -14,11 +14,8 @@ export declare class Form {
|
|
|
14
14
|
private formData;
|
|
15
15
|
private id;
|
|
16
16
|
private readonly feedback;
|
|
17
|
-
|
|
18
|
-
private
|
|
19
|
-
private censorQuestions;
|
|
20
|
-
private readonly history;
|
|
21
|
-
private elementQuestions;
|
|
17
|
+
private graph;
|
|
18
|
+
private history;
|
|
22
19
|
progress: number;
|
|
23
20
|
total: number;
|
|
24
21
|
/**
|
|
@@ -28,22 +25,31 @@ export declare class Form {
|
|
|
28
25
|
* @param publicKey
|
|
29
26
|
*/
|
|
30
27
|
constructor(config: Config, appId: string, publicKey: string);
|
|
28
|
+
/**
|
|
29
|
+
* Get data from the local storage, if the data is older than 24 hours, get the data from the server
|
|
30
|
+
* @private
|
|
31
|
+
**/
|
|
32
|
+
private getDataFromStorage;
|
|
31
33
|
/**
|
|
32
34
|
* Generate
|
|
33
|
-
* TODO: Check if is inside of a <form>
|
|
34
35
|
* @param selector
|
|
35
36
|
* @param options
|
|
36
37
|
*/
|
|
37
38
|
generate(selector: string, options: generateFormOptions): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Format pages in case of the survey don't have pages
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
private formatPages;
|
|
38
44
|
/**
|
|
39
45
|
* Generate container
|
|
40
46
|
* @returns
|
|
41
47
|
*/
|
|
42
48
|
private generateContainer;
|
|
43
49
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
50
|
+
* Generate form
|
|
51
|
+
* @private
|
|
52
|
+
* @returns void
|
|
47
53
|
*/
|
|
48
54
|
private generateForm;
|
|
49
55
|
/**
|
|
@@ -70,9 +76,9 @@ export declare class Form {
|
|
|
70
76
|
*/
|
|
71
77
|
send(metadata?: NativeAnswer[], metrics?: NativeAnswer[], profile?: NativeAnswer[]): Promise<void>;
|
|
72
78
|
/**
|
|
73
|
-
* Update feedback
|
|
79
|
+
* Update feedback -> answers with the answers of the form in a JSON format
|
|
74
80
|
* @returns
|
|
75
|
-
*
|
|
81
|
+
* @public
|
|
76
82
|
*/
|
|
77
83
|
answer(): void;
|
|
78
84
|
/**
|
|
@@ -80,12 +86,6 @@ export declare class Form {
|
|
|
80
86
|
* @public
|
|
81
87
|
*/
|
|
82
88
|
finish(): void;
|
|
83
|
-
/**
|
|
84
|
-
* Censure questions form the form
|
|
85
|
-
* @param questions
|
|
86
|
-
* @public
|
|
87
|
-
*/
|
|
88
|
-
censureQuestions(questions: string[]): void;
|
|
89
89
|
/**
|
|
90
90
|
* Send
|
|
91
91
|
* @param completed
|
|
@@ -100,7 +100,6 @@ export declare class Form {
|
|
|
100
100
|
private callFollowUpQuestion;
|
|
101
101
|
/**
|
|
102
102
|
* Process next question
|
|
103
|
-
* @param container
|
|
104
103
|
* @param form
|
|
105
104
|
* @private
|
|
106
105
|
*/
|
|
@@ -108,6 +107,7 @@ export declare class Form {
|
|
|
108
107
|
/**
|
|
109
108
|
* Render next question
|
|
110
109
|
* @param form
|
|
110
|
+
* @param page
|
|
111
111
|
* @private
|
|
112
112
|
*/
|
|
113
113
|
private renderNextQuestion;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NativeQuestion } from "./types";
|
|
2
|
+
import { Page } from "./page";
|
|
2
3
|
export declare class FormData {
|
|
3
4
|
id: string;
|
|
4
5
|
name: string;
|
|
@@ -18,5 +19,6 @@ export declare class FormData {
|
|
|
18
19
|
questions: NativeQuestion[];
|
|
19
20
|
lang: string[];
|
|
20
21
|
style: Record<string, any>;
|
|
21
|
-
|
|
22
|
+
pages: Page[];
|
|
23
|
+
constructor(id: string, name: string, description: string, type: string, identity: string, status: string, createdAt: Date, updatedAt: Date, externalId: string | null, companyId: string, productId: string, userId: string, setting: Record<string, any>, conf: Record<string, any>, questions: NativeQuestion[], lang: string[], style: Record<string, any>, pages: Page[]);
|
|
22
24
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NativeQuestion } from "./types";
|
|
2
|
+
import { PageRoute } from "./pageRoute";
|
|
3
|
+
export declare class Page {
|
|
4
|
+
id: string;
|
|
5
|
+
position: number;
|
|
6
|
+
generatedAt: string;
|
|
7
|
+
updatedAt: number;
|
|
8
|
+
status: string;
|
|
9
|
+
integrationId: string;
|
|
10
|
+
integrationQuestions: NativeQuestion[];
|
|
11
|
+
integrationPageRoutes: PageRoute[];
|
|
12
|
+
constructor(id: string, position: number, integrationId: string, integrationQuestions: NativeQuestion[], integrationPageRoutes: PageRoute[]);
|
|
13
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Page } from "./page";
|
|
2
|
+
import { PageNode } from "./pageNode";
|
|
3
|
+
import { NativeAnswer } from "./types";
|
|
4
|
+
export declare class PageGraph {
|
|
5
|
+
private nodes;
|
|
6
|
+
constructor(pages: Page[]);
|
|
7
|
+
private buildGraph;
|
|
8
|
+
getNodeById(id: string): PageNode | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Get the next page position of the graph given the current page and the answer
|
|
11
|
+
* @param node
|
|
12
|
+
*/
|
|
13
|
+
getNextEdgeByDefault(node: PageNode): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Get the first page of the graph
|
|
16
|
+
* @returns first page
|
|
17
|
+
**/
|
|
18
|
+
getFirstPage(): PageNode | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Get the next page of the graph given the current page and the answer
|
|
21
|
+
* @param currentNode
|
|
22
|
+
* @param answer - answer to the question in the current page
|
|
23
|
+
* @returns page
|
|
24
|
+
**/
|
|
25
|
+
getNextPage(currentNode: PageNode, answer: NativeAnswer[]): PageNode | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Get the number deep (DFS) of this node
|
|
28
|
+
* @param id - node id
|
|
29
|
+
* @returns DFS number
|
|
30
|
+
*/
|
|
31
|
+
findDepth(id: string): number;
|
|
32
|
+
findMaxDepth(): number;
|
|
33
|
+
DFSUtil(v: PageNode, visited: Set<PageNode>, depth: number): number;
|
|
34
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NativeQuestion } from "./types";
|
|
2
|
+
import { Page } from "./page";
|
|
3
|
+
import { PageRoute } from "./pageRoute";
|
|
4
|
+
export declare class PageNode {
|
|
5
|
+
id: string;
|
|
6
|
+
position: number;
|
|
7
|
+
edges: PageRoute[];
|
|
8
|
+
data: Page;
|
|
9
|
+
questions: NativeQuestion[];
|
|
10
|
+
elements: HTMLElement[];
|
|
11
|
+
constructor(id: string, position: number, edges: PageRoute[], data: Page, questions: NativeQuestion[]);
|
|
12
|
+
/**
|
|
13
|
+
* Get a list of followup questions ref
|
|
14
|
+
* @returns list of followup questions ref
|
|
15
|
+
**/
|
|
16
|
+
getFollowupQuestions(): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Get a list of ref of the questions that are required in the page
|
|
19
|
+
* @returns ref of the required questions ref
|
|
20
|
+
**/
|
|
21
|
+
getRequiredQuestions(): string[];
|
|
22
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare enum TransitionType {
|
|
2
|
+
PAGE = "PAGE",
|
|
3
|
+
FINISH = "FINISH"
|
|
4
|
+
}
|
|
5
|
+
export declare enum ConditionType {
|
|
6
|
+
LOGICAL = "LOGICAL"
|
|
7
|
+
}
|
|
8
|
+
export declare enum OperatorType {
|
|
9
|
+
EQUAL = "EQUAL",
|
|
10
|
+
NOEQUAL = "NOEQUAL",
|
|
11
|
+
GREATER = "GREATER",
|
|
12
|
+
LESS = "LESS",
|
|
13
|
+
GREATEREQUAL = "GREATEREQUAL",
|
|
14
|
+
LESSEQUAL = "LESSEQUAL",
|
|
15
|
+
INQ = "INQ",
|
|
16
|
+
NINQ = "NINQ",
|
|
17
|
+
DEFAULT = "DEFAULT"
|
|
18
|
+
}
|
|
19
|
+
declare enum StatusType {
|
|
20
|
+
ACTIVE = "ACTIVE",
|
|
21
|
+
DEPRECATED = "DEPRECATED",
|
|
22
|
+
DELETE = "DELETE"
|
|
23
|
+
}
|
|
24
|
+
export declare class PageRoute {
|
|
25
|
+
id: string;
|
|
26
|
+
questionRef: string;
|
|
27
|
+
typeCondition: ConditionType;
|
|
28
|
+
typeOperator: OperatorType;
|
|
29
|
+
value: string | any;
|
|
30
|
+
transition: TransitionType;
|
|
31
|
+
transitionDestiny: string;
|
|
32
|
+
status: StatusType;
|
|
33
|
+
generatedAt: Date;
|
|
34
|
+
updatedAt: Date;
|
|
35
|
+
integrationPageId: string;
|
|
36
|
+
constructor(id: string, questionRef: string, typeOperator: OperatorType, value: string | any, transition: TransitionType, transitionDestiny: string, integrationPageId: string);
|
|
37
|
+
}
|
|
38
|
+
export {};
|