@kbss-cvut/s-forms 0.7.1-beta-b76add4.0 → 0.7.1-beta-e71a5b6.0

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.
@@ -1,2 +1,2 @@
1
- import"core-js/modules/es.array.iterator.js";import"core-js/modules/es.promise.js";import"core-js/modules/web.dom-collections.iterator.js";import e,{useMemo as t,useState as s,useEffect as n,useContext as o,useRef as i,forwardRef as r}from"react";import a from"prop-types";import"core-js/modules/es.object.assign.js";import*as l from"jsonld";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.string.includes.js";import*as c from"jsonld-utils";import"core-js/modules/es.array.sort.js";import u from"@kbss-cvut/tsort";import p from"react-dom";import{Form as m,FormGroup as d,FormControl as h,OverlayTrigger as E,Tooltip as S,Col as A,Row as g,Button as _,Badge as f,Overlay as v,FormText as T,Popover as N,ListGroup as I,ListGroupItem as O,Card as C,Accordion as R,ButtonToolbar as L,Nav as w,NavItem as b,NavLink as y,Modal as D}from"react-bootstrap";import"core-js/modules/esnext.set.add-all.js";import"core-js/modules/esnext.set.delete-all.js";import"core-js/modules/esnext.set.difference.js";import"core-js/modules/esnext.set.every.js";import"core-js/modules/esnext.set.filter.js";import"core-js/modules/esnext.set.find.js";import"core-js/modules/esnext.set.intersection.js";import"core-js/modules/esnext.set.is-disjoint-from.js";import"core-js/modules/esnext.set.is-subset-of.js";import"core-js/modules/esnext.set.is-superset-of.js";import"core-js/modules/esnext.set.join.js";import"core-js/modules/esnext.set.map.js";import"core-js/modules/esnext.set.reduce.js";import"core-js/modules/esnext.set.some.js";import"core-js/modules/esnext.set.symmetric-difference.js";import"core-js/modules/esnext.set.union.js";import V from"react-datepicker";import{format as H}from"date-fns";import M from"classnames";import U from"yasgui-yasqe";import"@triply/yasgui/build/yasgui.min.css";import x from"inputmask-core";import{IntelligentTreeSelect as P}from"intelligent-tree-select/lib/components/IntelligentTreeSelect.js";import"intelligent-tree-select/lib/styles.css";import"core-js/modules/es.regexp.to-string.js";import{jsx as q,jsxs as Q}from"react/jsx-runtime";import"core-js/modules/es.parse-int.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.replace.js";import F from"javascript-time-ago";import j from"javascript-time-ago/locale/en";import z from"javascript-time-ago/locale/cs";import{motion as k}from"framer-motion";import{Rings as B}from"react-loader-spinner";import"core-js/modules/es.string.trim.js";import{useIntl as W,IntlProvider as G}from"react-intl";import"core-js/modules/es.regexp.constructor.js";function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},Y.apply(this,arguments)}function X(e,t){if(null==e)return{};var s,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(s=i[n])>=0||(o[s]=e[s]);return o}class K{static log(e){console.log(e)}static warn(e){console.warn?console.warn(e):console.log("WARNING: "+e)}static error(e){console.error?console.error(e):console.log("ERROR: "+e)}}const J=["children"],Z=/*#__PURE__*/e.createContext({}),$=s=>{let{children:n}=s,o=X(s,J),i=[];const r=async(e,t)=>{const s=i[e];if(s&&s.length)return s;const n=await o.fetchTypeAheadValues(t);return n.length?l.frame(n,{},{}).then(t=>{const s=t["@graph"];return i.push(Object.assign({},s,{[e]:s})),s}):(K.warn(`No data received when loading options using id ${e}`),[])},a=e=>i[e]||[],c=t(()=>({loadFormOptions:r,getOptions:a}),[r,a]);/*#__PURE__*/return e.createElement(Z.Provider,Y({value:c},o),n)};var ee;$.propTypes={children:a.element.isRequired,fetchTypeAheadValues:a.func};class te{}ee=te,te.COLUMN_COUNT=12,te.INPUT_LENGTH_THRESHOLD=50,te.DATETIME_NUMBER_FORMAT="x",te.FORM="http://onto.fel.cvut.cz/ontologies/documentation/form",te.HAS_SUBQUESTION="http://onto.fel.cvut.cz/ontologies/documentation/has_related_question",te.HAS_ANSWER="http://onto.fel.cvut.cz/ontologies/documentation/has_answer",te.HAS_OPTION="http://onto.fel.cvut.cz/ontologies/form/has-possible-value",te.HAS_OPTIONS_QUERY="http://onto.fel.cvut.cz/ontologies/form/has-possible-values-query",te.HAS_VALUE_TYPE="http://onto.fel.cvut.cz/ontologies/form/has-value-type",te.IS_DISABLED="http://onto.fel.cvut.cz/ontologies/aviation/form-376/is-disabled",te.INPUT_MASK="http://onto.fel.cvut.cz/ontologies/form/has-input-mask",te.LAYOUT_CLASS="http://onto.fel.cvut.cz/ontologies/form-layout/has-layout-class",te.LAYOUT={FORM:"form",QUESTION_SECTION:"section",WIZARD_STEP:"wizard-step",DATE:"date",TIME:"time",DATETIME:"datetime",TEXT:"text",TEXTAREA:"textarea",CHECKBOX:"checkbox",QUESTION_TYPEAHEAD:"type-ahead",MASKED_INPUT:"masked-input",ANSWERABLE:"answerable",SPARQL:"sparql",TURTLE:"ttl",DISABLED:"disabled",HIDDEN:"hidden",COLLAPSED:"collapsed",EMPHASISED:"emphasised",EMPHASISE_ON_RELEVANT:"emphasise-on-relevant",CATEGORY:["category-1","category-2","category-3","category-4","category-5"]},te.HAS_INITIAL_INPUT_LENGTH="http://onto.fel.cvut.cz/ontologies/form-layout/has-initial-input-length",te.VALUE_TYPE_CODE="code",te.VALUE_TYPE_TEXT="text",te.GENERATED_ROW_SIZE=1,te.HAS_QUESTION_ORIGIN="http://onto.fel.cvut.cz/ontologies/form/has-question-origin",te.HAS_ANSWER_ORIGIN="http://onto.fel.cvut.cz/ontologies/form/has-answer-origin",te.HAS_DATA_VALUE="http://onto.fel.cvut.cz/ontologies/documentation/has_data_value",te.HAS_OBJECT_VALUE="http://onto.fel.cvut.cz/ontologies/documentation/has_object_value",te.HELP_DESCRIPTION="http://purl.org/dc/elements/1.1/description",te.SOURCE="http://purl.org/dc/elements/1.1/source",te.XSD={MAX_EXCLUSIVE:"http://www.w3.org/2001/XMLSchema#maxExclusive",MAX_INCLUSIVE:"http://www.w3.org/2001/XMLSchema#maxInclusive",MIN_EXCLUSIVE:"http://www.w3.org/2001/XMLSchema#minExclusive",MIN_INCLUSIVE:"http://www.w3.org/2001/XMLSchema#minInclusive",INT:"http://www.w3.org/2001/XMLSchema#int",INTEGER:"http://www.w3.org/2001/XMLSchema#integer",NEGATIVE_INTEGER:"http://www.w3.org/2001/XMLSchema#negativeInteger",NON_NEGATIVE_INTEGER:"http://www.w3.org/2001/XMLSchema#nonNegativeInteger",NON_POSITIVE_INTEGER:"http://www.w3.org/2001/XMLSchema#nonPositiveInteger",POSITIVE_INTEGER:"http://www.w3.org/2001/XMLSchema#positiveInteger",BOOLEAN:"http://www.w3.org/2001/XMLSchema#boolean"},te.STEP="http://onto.fel.cvut.cz/ontologies/form/step",te.PATTERN="http://onto.fel.cvut.cz/ontologies/form/pattern",te.ACCEPTS_ANSWER_VALUE="http://onto.fel.cvut.cz/ontologies/form/accepts-answer-value",te.ACCEPTS="http://onto.fel.cvut.cz/ontologies/form/accepts",te.HAS_DATATYPE="http://onto.fel.cvut.cz/ontologies/form/has-datatype",te.HAS_LAYOUT_CLASS="http://onto.fel.cvut.cz/ontologies/form/has-layout-class",te.HAS_POSSIBLE_VALUES_QUERY="http://onto.fel.cvut.cz/ontologies/form/has-possible-values-query",te.HAS_REQUIRED_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-required-value",te.HAS_TESTED_QUESTION="http://onto.fel.cvut.cz/ontologies/form/has-tested-question",te.HAS_TESTED_FORM="http://onto.fel.cvut.cz/ontologies/form/has-tested-form",te.HAS_UNIT="http://onto.fel.cvut.cz/ontologies/form/has-unit",te.HAS_VALID_ANSWER="http://onto.fel.cvut.cz/ontologies/form/has-valid-answer",te.IS_RELEVANT_IF="http://onto.fel.cvut.cz/ontologies/form/is-relevant-if",te.ACCEPTS_VALIDATION_VALUE="http://onto.fel.cvut.cz/ontologies/form/accepts-validation-value",te.HAS_VALIDATION_MESSAGE="http://onto.fel.cvut.cz/ontologies/form/has-validation-message",te.NEGATIVE_CONDITION="http://onto.fel.cvut.cz/ontologies/form/negative-condition",te.REQUIRES_ANSWER="http://onto.fel.cvut.cz/ontologies/form/requires-answer",te.USED_ONLY_FOR_COMPLETENESS="http://onto.fel.cvut.cz/ontologies/form/used-only-for-completeness",te.REQUIRES_ANSWER_DESCRIPTION_IF="http://onto.fel.cvut.cz/ontologies/form/requires-answer-description-if",te.REQUIRES_ANSWER_IF="http://onto.fel.cvut.cz/ontologies/form/requires-answer-if",te.HAS_PRECEDING_QUESTION="http://onto.fel.cvut.cz/ontologies/form/has-preceding-question",te.HAS_PRECEDING_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-preceding-value",te.HAS_MEDIA_CONTENT="http://onto.fel.cvut.cz/ontologies/form/has-media-content",te.CONDITION="http://onto.fel.cvut.cz/ontologies/form/condition",te.OR_CONDITION="http://onto.fel.cvut.cz/ontologies/form/or-condition",te.HAS_SUB_CONDITION="http://onto.fel.cvut.cz/ontologies/form/has-sub-condition",te.HAS_PATTERN="http://onto.fel.cvut.cz/ontologies/form-lt/has-pattern",te.HAS_DECLARED_PREFIX="http://onto.fel.cvut.cz/ontologies/form-spin/has-declared-prefix",te.PREFIX="http://www.w3.org/ns/shacl#prefix",te.NAMESPACE="http://www.w3.org/ns/shacl#namespace",te.HAS_COMMENT="http://onto.fel.cvut.cz/ontologies/form/has-comment",te.HAS_COMMENT_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-comment-value",te.HAS_AUTHOR="http://onto.fel.cvut.cz/ontologies/form/has-author",te.HAS_TIMESTAMP="http://onto.fel.cvut.cz/ontologies/form/has-timestamp",te.TIME_FORMAT="http://onto.fel.cvut.cz/ontologies/form/time-format",te.DATE_FORMAT="http://onto.fel.cvut.cz/ontologies/form/date-format",te.DATETIME_FORMAT="http://onto.fel.cvut.cz/ontologies/form/datetime-format",te.NOT_ANSWERED_QUESTION="http://onto.fel.cvut.cz/ontologies/form/not-answered-question",te.ANSWERED_QUESTION="http://onto.fel.cvut.cz/ontologies/form/answered-question",te.HAS_VALIDATION_SEVERITY="http://onto.fel.cvut.cz/ontologies/form/has-validation-severity",te.RDFS_LABEL=c.RDFS_LABEL,te.RDFS_COMMENT=c.RDFS_COMMENT,te.DEFAULT_HAS_CHILD=c.DEFAULT_HAS_CHILD,te.BROADER="http://www.w3.org/2004/02/skos/core#broader",te.HAS_NON_SELECTABLE_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-non-selectable-value",te.PROVIDES_DEREFERENCEABLE_ANSWER_VALUES="http://onto.fel.cvut.cz/ontologies/form/provides-dereferenceable-answer-values",te.ICONS={QUESTION_COMMENTS:"questionComments",QUESTION_HELP:"questionHelp",QUESTION_LINK:"questionLink"},te.ICON_BEHAVIOR={ENABLE:"enable",DISABLE:"disable",ON_HOVER:"onHover"},te.DEFAULT_OPTIONS={icons:[{id:ee.ICONS.QUESTION_HELP,behavior:ee.ICON_BEHAVIOR.ENABLE},{id:ee.ICONS.QUESTION_COMMENTS,behavior:ee.ICON_BEHAVIOR.ON_HOVER},{id:ee.ICONS.QUESTION_LINK,behavior:ee.ICON_BEHAVIOR.ON_HOVER}]},te.LANG={cs:{locale:"cs",label:"Čestina"},en:{locale:"en",label:"English"}},te.VALIDATION={SEVERITY:{ERROR:"error",WARNING:"warning"},DEFAULT_MESSAGE:{REQUIRED:"This field is required.",REQUIRED_ONLY_FOR_COMPLETENESS:"This field is required to complete the form.",INVALID:"This field is invalid.",CHECK:"This field must be checked.",LOWER_OR_EQUAL:"This field should be a number equal or lower to ",GREATER_OR_EQUAL:"This field must be greater or equal to "},CLASSNAME:{ERROR:"is-invalid",WARNING:"is-warning"}};class se{static getStringHash(e){let t=0;const s=e?e.length:0;if(0===s)return t;for(let n=0;n<s;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return t}static asArray(e){return e?e.constructor===Array?e:[e]:[]}static findQuestionById(e,t,s,n,o){if(s&&t["@id"]===e)return t;const i=se.asArray(t[te.HAS_SUBQUESTION]);if(n)for(let t of i){let s=se.findQuestionById(e,t,!0,!1,!1);if(s)return s}if(o)for(let t of i){let s=se.findQuestionById(e,t,!1,!0,!0);if(s)return s}return null}static findKeyInObjects(e,t){for(let s=0;s<e.length;s++)for(let n=0;n<t.length;n++)if(e[s].hasOwnProperty(t[n]))return t[n];return null}}class ne{static putObject(e,t){ne.objectMap[e]=t}static getObject(e){return ne.objectMap[e]}}ne.objectMap={};class oe{static getFirstObject(e,t){const s=l.getValues(e,t);return 0===s.length?null:s[0]}static compareValues(e,t){return t="object"==typeof t?t:{"@value":t},!!((e="object"==typeof e?e:{"@value":e})&&e["@value"]&&t&&t["@value"]&&("string"==typeof e["@value"]?e["@value"]:JSON.stringify(e["@value"]))===("string"==typeof t["@value"]?t["@value"]:JSON.stringify(t["@value"])))||l.compareValues(e,t)}static toplogicalSort(e,t){let s;do{s=!1;for(let n=0;n<e.length;n++)for(let o=n;o<e.length;o++)if(e[n][t]&&("object"==typeof e[n][t]?e[n][t]["@id"]:e[n][t])===e[o]["@id"]){const t=e[n];e[n]=e[o],e[o]=t,s=!0;break}}while(s);return e}static orderPreservingToplogicalSort(e,t){const s=u(),n={};for(let o=0;o<e.length;o++){let i=e[o]["@id"];s.add(i),n[i]=e[o],se.asArray(e[o][t]).map(e=>"object"==typeof e?e["@id"]:e).map(e=>[e,i]).forEach(e=>s.add(e))}let o=s.sort();for(let t=0;t<o.length;t++)e[t]=n[o[t]];return e}static getCompareLocalizedLabelFunction(e){return(t,s)=>{const n=c.getLocalized(t[c.RDFS_LABEL],e),o=c.getLocalized(s[c.RDFS_LABEL],e);return n<o?-1:n>o?1:0}}static orderByLocalizedLabels(e,t){return e.sort(oe.getCompareLocalizedLabelFunction(t))}static checkId(e,t){if(void 0!==e)return e.constructor===Array?!!e.find(e=>e["@id"]===t):e.constructor===Object?e["@id"]===t:void 0}}class ie{static isForm(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.FORM)}static isWizardStep(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.WIZARD_STEP)}static isSection(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.QUESTION_SECTION)}static isAnswerable(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.ANSWERABLE)}static isTypeahead(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.QUESTION_TYPEAHEAD)}static getPossibleValuesQuery(e){return c.getJsonAttValue(e,te.HAS_OPTIONS_QUERY)}static isDisabled(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.DISABLED)}static isHidden(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.HIDDEN)}static isTextarea(e,t){return t&&t.length>te.INPUT_LENGTH_THRESHOLD&&!ie.isTypeahead(e)||c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.TEXTAREA)}static isText(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.TEXT)}static isCalendar(e){return ie.isDate(e)||ie.isTime(e)||ie.isDateTime(e)}static isDate(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.DATE)}static isTime(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.TIME)}static isDateTime(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.DATETIME)}static isCheckbox(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.CHECKBOX)}static isMaskedInput(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.MASKED_INPUT)}static isSparqlInput(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.SPARQL)}static isTurtleInput(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.TURTLE)}static isCollapsed(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.COLLAPSED)}static isEmphasised(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.EMPHASISED)}static getCategory(e){return te.LAYOUT.CATEGORY.find(t=>c.hasValue(e,te.LAYOUT_CLASS,t))}static resolveValue(e){return e?e[te.HAS_OBJECT_VALUE]?e[te.HAS_OBJECT_VALUE]["@id"]:c.getJsonAttValue(e,te.HAS_DATA_VALUE):null}static resolveValueObject(e){return e?e[te.HAS_OBJECT_VALUE]?se.asArray(e[te.HAS_OBJECT_VALUE])[0]:e[te.HAS_DATA_VALUE]?se.asArray(e[te.HAS_DATA_VALUE])[0]:null:null}static isRelevant(e){if(!e[te.IS_RELEVANT_IF])return!0;for(let t of se.asArray(e[te.IS_RELEVANT_IF]))if(!ie.testCondition(t))return!1;return!0}static hasValidationLogic(e){return!!(e[te.REQUIRES_ANSWER]||e[te.REQUIRES_ANSWER_IF]||e[te.PATTERN]||this.containsXSDProperty(e))}static isValid(e){if(!1===e[te.HAS_VALID_ANSWER])return!1;for(const t of se.asArray(e[te.HAS_SUBQUESTION]))if(!1===this.isValid(t))return!1;return!0}static testOrCondition(e){const t=e[te.HAS_SUB_CONDITION];t||console.warn("Or condition does not have any sub-condition !");for(const e of this._getMappedObjectsArray(t))if(this.testCondition(e))return!0;return!1}static testCondition(e){const t=e[te.ACCEPTS_VALIDATION_VALUE],s=e[te.ACCEPTS_ANSWER_VALUE],n=e[te.ACCEPTS],o=e[te.HAS_TESTED_QUESTION];let i;if(e[te.HAS_SUB_CONDITION])return this.testOrCondition(e);if(t&&s&&console.warn("Support for validation and requirement constraints at same time is not implemented !"),n&&o){const e=se.asArray(n);if(1!==e.length&&console.warn("Support for multiple accepts values is not implemented !"),e[0]["@id"]===te.ANSWERED_QUESTION){(s||t)&&console.warn("Support for accepted answer/validations values is not implemented !");for(const e of this._getMappedObjectsArray(o))if(!this.hasAnswer(e))return!1;return!0}console.warn("No support to accept question of type "+e[0]["@id"]+" !")}if(t&&o){const e=se.asArray(t);(1!==e.length||!0!==e[0]&&"true"!==e[0])&&console.warn('Validation values other than "true" are not implemented !');for(const e of se.asArray(o)){if(i=ne.getObject(e["@id"]),void 0===i)return console.warn("Questions is not loaded in an object map."),!0;if(!1===this.isValid(i))return!1}return!0}if(s&&o){i=ne.getObject(o["@id"]);for(const e of se.asArray(s)){if(!i)return console.warn("Question is not defined."),!0;if(!i.hasOwnProperty(te.HAS_ANSWER))return!1;const t=l.getValues(i,te.HAS_ANSWER);if(0===t.length)return!1;const s=ie.resolveValueObject(t[0]);if(s&&e&&s.hasOwnProperty("@value")&&e.hasOwnProperty("@id")&&s["@value"]==e["@id"])return!0;if(oe.compareValues(s,e))return!0}}return!1}static _getMappedObjectsArray(e,t){return se.asArray(e).map(e=>{const s=ne.getObject(e["@id"]);return void 0===s?(console.warn((t||"Object")+' "'+e["@id"]+'" is not loaded in an object map.'),null):s}).filter(function(e){return null!==e})}static hasAnswer(e){if(!e)return!1;if(e.hasOwnProperty(te.HAS_ANSWER)){const t=l.getValues(e,te.HAS_ANSWER);if(t.length){const e=ie.resolveValueObject(t[0]);if(e&&(e["@value"]||e["@id"]))return!0}}for(const t of se.asArray(e[te.HAS_SUBQUESTION]))if(ie.hasAnswer(t))return!0;return!1}static getAnswerValue(e){if(!e)return null;if(e.hasOwnProperty(te.HAS_ANSWER)){const t=l.getValues(e,te.HAS_ANSWER);if(t.length){const e=ie.resolveValueObject(t[0]);if(e&&(e["@value"]||e["@id"]))return e["@value"]||e["@id"]}}for(const t of se.asArray(e[te.HAS_SUBQUESTION])){const e=ie.getAnswerValue(t);if(e)return e}return null}static resolveDateTimeFormat(e,t,s){const n="number"==typeof t,o=ie.isDate(e),i=ie.isTime(e),r=ie.isDateTime(e);return n?te.DATETIME_NUMBER_FORMAT:o?e[te.DATE_FORMAT]||s.dateFormat:i?e[te.TIME_FORMAT]||s.timeFormat:r?e[te.DATETIME_FORMAT]||s.dateTimeFormat:null}static dfsTraverseQuestionTree(e,t,s=(()=>{})){function n(e){t(e),se.asArray(e[te.HAS_SUBQUESTION]).forEach(e=>{n(e)}),s(e)}e.forEach(e=>{n(e)})}static getFormSpecification(e){let t=-1;const s="..";let n="";return ie.dfsTraverseQuestionTree(e,function(e){t+=1;const o=" ".repeat(t);let i="";e[te.REQUIRES_ANSWER]&&!e[te.USED_ONLY_FOR_COMPLETENESS]?i=o+s+"required: "+e[te.REQUIRES_ANSWER]+"\n":e[te.USED_ONLY_FOR_COMPLETENESS]&&(i=o+s+"required only for completeness: "+e[te.USED_ONLY_FOR_COMPLETENESS]+"\n"),n+=o+e["http://www.w3.org/2000/01/rdf-schema#label"]+"\n",n+=e[te.HELP_DESCRIPTION]?o+s+"description: "+e[te.HELP_DESCRIPTION]+"\n":"",n+=i,n+=e[te.PATTERN]?o+s+"pattern: "+e[te.PATTERN]+"\n":"",n+=e[te.INPUT_MASK]?o+s+"mask: "+e[te.INPUT_MASK]+"\n":"",n+=e[te.HAS_VALIDATION_MESSAGE]?o+s+"validation-message: "+e[te.HAS_VALIDATION_MESSAGE]+"\n":"",n+="\n"},function(){t-=1}),n}static containsXSDProperty(e){const t=Object.keys(e),s=Object.values(te.XSD);for(const e of s)if(t.includes(e))return!0;return!1}static getInputMask(e){if(e[te.INPUT_MASK])return e[te.INPUT_MASK]}}const re={},ae=[],le=/*#__PURE__*/e.createContext({}),ce=o=>{const[i,r]=s(o.data||re),[a,l]=s(o.formQuestions||ae);n(()=>{if(o.isFormValid){const e=ie.isValid(i);o.isFormValid(e)}},[]),n(()=>{r(o.data||re)},[a]);const c=e=>{e&&r(Object.assign({},i,e))},u=(e,t)=>{if(!(!t||e<0||e>=a.length)){if("object"==typeof t){const s=[...a];s[e]=Object.assign({},s[e],t),l(s)}if(Array.isArray(t)&&l(t),o.isFormValid){const e=ie.isValid(i);o.isFormValid(e)}}},p=()=>i,m=e=>null==e?a:a[e],d=t(()=>({updateData:c,updateFormQuestionsData:u,getData:p,getFormQuestionsData:m}),[m,p]);/*#__PURE__*/return e.createElement(le.Provider,Y({value:d},o),o.children)};ce.propTypes={children:a.element.isRequired,data:a.object.isRequired,formQuestions:a.array.isRequired,isFormValid:a.func};class ue extends e.Component{constructor(e){super(e),this.state={cursorPosition:0}}focus(){p.findDOMNode(this.input).focus()}getInputDOMNode(){return p.findDOMNode(this.input)}componentDidUpdate(e,t,s){(this.fieldDidShrink(e)||this.fieldDidExpand(e))&&this.updateFieldCursorPosition()}fieldDidExpand(e){return"textarea"===this.props.type&&"textarea"!==e.type}fieldDidShrink(e){return"text"===this.props.type&&"text"!==e.type}updateFieldCursorPosition(){this.focus(),this.getInputDOMNode().setSelectionRange(this.state.cursorPosition,this.state.cursorPosition)}saveCursorPosition(e){this.props.onChange(e),this.setState({cursorPosition:e.target.selectionStart})}render(){switch(this.props.type){case"radio":return this._renderRadio();case"checkbox":return this._renderCheckbox();case"select":return this._renderSelect();case"textarea":return this._renderTextArea();default:return this._renderInput()}}_renderCheckbox(){/*#__PURE__*/return e.createElement(m.Group,{size:"small",controlId:Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)},/*#__PURE__*/e.createElement(m.Check,Y({type:"checkbox",ref:e=>this.input=e},this.props,{label:this.props.label,className:this.props.validation.classname})),this.props.validation.message)}_renderRadio(){/*#__PURE__*/return e.createElement(d,{size:"small"},/*#__PURE__*/e.createElement(m.Check,Y({type:"radio",ref:e=>this.input=e},this.props,{label:this.props.label,className:this.props.validation.classname})),this.props.validation.message)}_renderSelect(){/*#__PURE__*/return e.createElement(d,{size:"small"},this._renderLabel(),/*#__PURE__*/e.createElement(h,Y({as:"select",className:this.props.validation.classname,ref:e=>this.input=e},this.props),this.props.children),this.props.validation.message)}_renderLabel(){return this.props.label?/*#__PURE__*/e.createElement(m.Label,null,this.props.label):null}_renderTextArea(){/*#__PURE__*/return e.createElement(d,{size:"small"},this._renderLabel(),/*#__PURE__*/e.createElement(h,Y({ref:e=>this.input=e,as:"textarea"},this.props,{className:this.props.validation.classname,onChange:e=>this.saveCursorPosition(e)})),this.props.validation.message)}_renderInput(){/*#__PURE__*/return e.createElement(d,{size:"small"},this._renderLabel(),/*#__PURE__*/e.createElement(h,Y({className:this.props.validation.classname,ref:e=>this.input=e,as:"input",placeholder:this.props.placeholder},this.props,{onChange:e=>this.saveCursorPosition(e)})),this.props.validation.message)}}ue.propTypes={type:a.string,label:a.object,value:a.any,onChange:a.func,help:a.string,validation:a.object,placeholder:a.string},ue.defaultProps={type:"text"};const pe=["children"],me=/*#__PURE__*/e.createContext({}),de={components:{inputComponent:ue},componentsOptions:{dateTimeAnswer:{dateFormat:"yyyy-MM-dd",timeFormat:"HH:mm",dateTimeFormat:"yyyy-MM-dd HH:mm:ss"},readOnly:!1},options:{intl:{locale:"en"},i18n:{"wizard.next":"Next","wizard.previous":"Previous","section.collapse":"Collapse","section.expand":"Expand"},modalView:!1,modalProps:{},horizontalWizardNav:!0,wizardStepButtons:!0,enableWizardStepSkip:!0,startingStep:0}},he=s=>{let{children:n}=s,o=X(s,pe);const i=t(()=>({inputComponent:o.components&&o.components.inputComponent||de.components.inputComponent,componentsOptions:Object.assign({},de.componentsOptions,o.componentsOptions),options:Object.assign({},de.options,o.options),mapComponent:o.mapComponent}),[o]);/*#__PURE__*/return e.createElement(me.Provider,{value:i},n)};he.propTypes={children:a.element.isRequired,components:a.object,mapComponent:a.func,options:a.object};var Ee,Se={"@graph":[{"@type":"http://onto.fel.cvut.cz/ontologies/documentation/question","http://onto.fel.cvut.cz/ontologies/form-layout/has-layout-class":"form","http://onto.fel.cvut.cz/ontologies/documentation/has_related_question":[{"http://onto.fel.cvut.cz/ontologies/form-layout/has-layout-class":["wizard-step","section"],"http://www.w3.org/2000/01/rdf-schema#label":[{"@language":"en","@value":"Description"},{"@language":"cs","@value":"Popis"}],"http://onto.fel.cvut.cz/ontologies/documentation/has_related_question":[{"@type":"http://onto.fel.cvut.cz/ontologies/documentation/question","http://onto.fel.cvut.cz/ontologies/form-layout/has-layout-class":["textarea"],"http://www.w3.org/2000/01/rdf-schema#label":[{"@language":"en","@value":"Description"},{"@language":"cs","@value":"Popis"}],"http://onto.fel.cvut.cz/ontologies/documentation/has_answer":{"@type":"http://onto.fel.cvut.cz/ontologies/documentation/answer","http://onto.fel.cvut.cz/ontologies/documentation/has_data_value":""}}]}]}]};class Ae{static generateForm(){return JSON.parse(JSON.stringify(Se))}}const ge={root:{[te.HAS_LAYOUT_CLASS]:te.FORM},expandProperties:[te.HAS_SUBQUESTION,te.IS_RELEVANT_IF,te.HAS_ANSWER,te.HAS_DECLARED_PREFIX,te.HAS_OPTION,te.HAS_COMMENT]};class _e{static customFrame(e,t,s){if(arguments.length<2)return l.nextTick(function(){s(new TypeError("Could not frame, too few arguments."))});null===t&&(t=ge),l.flatten(e,null,null,(e,t)=>{})}static expandStructure(e){let t;const s={};e["@graph"].forEach(e=>{s[e["@id"]]=e,ie.isForm(e)&&(t=e)});try{this._expandGraph(t,ge,s)}catch(e){console.error("Error '"+e+"' occured, while trying to apply frame-ing with custom shape.")}return s}static _expandGraph(e,t,s){let n,o,i;t.expandProperties.forEach(r=>{if(e.hasOwnProperty(r)){e[r]=se.asArray(e[r]),n=e[r];for(let e=0;e<n.length;e++)i=this._getId(n[e]),o=s[i],void 0!==o?(n[e]=o,this._expandGraph(o,t,s)):console.warn("object with @id "+i+" was not defined in input data.")}})}static _getId(e){return"string"==typeof e?e:e["@id"]}}Ee=_e,_e.compressStructure=e=>{let t=[],s=new Set;return t=Ee._compressGraph(e,t,s),t=t.sort((e,t)=>e["@id"]&&t["@id"]?e["@id"].localeCompare(t["@id"]):0),t},_e._compressGraph=(e,t,s)=>(s.has(e["@id"])||(t.push(e),s.add(e["@id"])),ge.expandProperties.forEach(n=>{if(e.hasOwnProperty(n)){const o=e[n];for(let i=0;i<o.length;i++){const r=o[i];void 0!==r&&(o[i]=r,t=Ee._compressGraph(r,t,s),e[n][i]={"@id":r["@id"]})}}}),t);class fe{static constructDefaultForm(e){const t=Ae.generateForm();return fe._constructFormQuestions(t,e)}static async constructForm(e,t){let s,n;return l.flatten(e,{}).then(e=>{try{const[o,i]=fe._constructFormQuestions(e,t);n=i,s={formQuestions:o}}catch(e){console.error("Error while constructing form questions from the provided structure:",e)}if(!n){const[e,o]=fe.constructDefaultForm(t);n=o,s={formQuestions:e}}return[s,n]}).catch(e=>(console.error("Failed to flatten the JSON-LD structure. Expected to transform a nested JSON-LD document into a flattened array of node objects:",e),[s,n]))}static _constructFormQuestions(e,t){let s,n,o,i=[];if(void 0!==e["@graph"][0]["@id"]?(o=_e.expandStructure(e),Object.keys(o).map(e=>{ne.putObject(e,o[e])})):console.warn("default form is constructed."),s=e["@graph"].find(e=>ie.isForm(e)),n=s[te.HAS_SUBQUESTION],!n)throw K.error("Could not find any questions in the received data."),"No questions in the form";return i=n.filter(e=>!(!ie.isWizardStep(e)||ie.isHidden(e))||(K.warn("Item is not a wizard step: "+e),!1)),i.length||(K.log("Could not find any wizard steps in the received data. Building form without steps"),s[te.HAS_SUBQUESTION].forEach(e=>i.push(e))),i.sort(oe.getCompareLocalizedLabelFunction(t)),oe.orderPreservingToplogicalSort(i,te.HAS_PRECEDING_QUESTION),[i,{root:s}]}}class ve{static buildQuestionAnswerModel(e,t){const s={subQuestions:[]};let n;if(e&&(s.uri=e.root["@id"],s.origin=c.getJsonAttValue(e.root,te.HAS_QUESTION_ORIGIN,"@id")),t)for(let e=0;e<t.length;e++)n=ve.processQuestionAnswerHierarchy(t[e]),n&&s.subQuestions.push(n);return s}static processQuestionAnswerHierarchy(e){return e?ve._processQuestion(e):null}static _processQuestion(e){const t={};if(t.uri=e["@id"],t.origin=c.getJsonAttValue(e,te.HAS_QUESTION_ORIGIN,"@id"),e[te.HAS_SUBQUESTION]){t.subQuestions=[];for(let s=0;s<e[te.HAS_SUBQUESTION].length;s++)t.subQuestions.push(ve._processQuestion(e[te.HAS_SUBQUESTION][s]))}if(e[te.HAS_ANSWER]){t.answers=[],Array.isArray(e[te.HAS_ANSWER])||(e[te.HAS_ANSWER]=[e[te.HAS_ANSWER]]);for(let s=0;s<e[te.HAS_ANSWER].length;s++)t.answers.push(ve.processAnswer(e[te.HAS_ANSWER][s]))}if(e[te.HAS_COMMENT]){t.comments=[],Array.isArray(e[te.HAS_COMMENT])||(e[te.HAS_COMMENT]=[e[te.HAS_COMMENT]]);for(let s=0;s<e[te.HAS_COMMENT].length;s++)t.comments.push(ve.processComment(e[te.HAS_COMMENT][s]))}return t}static processComment(e){const t={};return t.author=c.getJsonAttValue(e,te.HAS_AUTHOR,"@id"),t.value=c.getJsonAttValue(e,te.HAS_COMMENT_VALUE),t.timestamp=c.getJsonAttValue(e,te.HAS_TIMESTAMP,"@id"),t}static processAnswer(e){const t={};return t.uri=e["@id"],t.origin=c.getJsonAttValue(e,te.HAS_ANSWER_ORIGIN,"@id"),e[te.HAS_OBJECT_VALUE]?t.codeValue=c.getJsonAttValue(e,te.HAS_OBJECT_VALUE,"@id"):t.textValue=c.getJsonAttValue(e,te.HAS_DATA_VALUE),t}static generateAnswer(e){const t={};return t[te.HAS_DATA_VALUE]="",t}}const Te=t=>{const{inputComponent:s,componentsOptions:n}=o(me);/*#__PURE__*/return e.createElement(s,{type:"checkbox",label:t.label,title:t.title,checked:!0===t.value||"true"===t.value,validation:t.validation,onChange:e=>{t.onChange(e.target.checked)},disabled:n.readOnly||ie.isDisabled(t.question)})};Te.propTypes={question:a.object.isRequired,label:a.object.isRequired,title:a.string,value:a.oneOfType([a.string,a.bool]),onChange:a.func.isRequired,mouseHover:a.bool,validation:a.object};const Ne=t=>{const{componentsOptions:n}=o(me),[i,r]=s(t.value?new Date(t.value):null),a=ie.resolveDateTimeFormat(t.question,t.value,n.dateTimeAnswer),l=ie.isDate(t.question),c=ie.isTime(t.question),u="x"===a?n.dateTimeAnswer.dateTimeFormat:a;/*#__PURE__*/return e.createElement(d,{size:"small"},/*#__PURE__*/e.createElement(m.Label,{className:"w-100"},t.label),/*#__PURE__*/e.createElement(V,{selected:i,placeholderText:u,onChange:e=>{r(e),e||t.onChange(""),t.onChange(a===te.DATETIME_NUMBER_FORMAT?Number(e):H(e,a))},showTimeSelect:!l,showTimeSelectOnly:c,timeFormat:"HH:mm",timeIntervals:1,timeCaption:"Time",dateFormat:u,className:M("form-control",t.validation.classname),disabled:n.readOnly||ie.isDisabled(t.question)}),t.validation.message)};Ne.propTypes={question:a.object.isRequired,label:a.object.isRequired,title:a.string,value:a.oneOfType([a.string,a.number]),onChange:a.func.isRequired,validation:a.object};const Ie=[te.XSD.INT,te.XSD.INTEGER,te.XSD.NON_NEGATIVE_INTEGER,te.XSD.NON_POSITIVE_INTEGER,te.XSD.NEGATIVE_INTEGER,te.XSD.POSITIVE_INTEGER],Oe={};Oe[te.XSD.NON_NEGATIVE_INTEGER]={min:0},Oe[te.XSD.NON_POSITIVE_INTEGER]={max:0},Oe[te.XSD.NEGATIVE_INTEGER]={max:-1},Oe[te.XSD.POSITIVE_INTEGER]={min:1};const Ce={"string-2":"prefixed",atom:"var"};class Re{static _resolveInputType(e,t){return ie.isSparqlInput(e)||ie.isTurtleInput(e)||ie.isTextarea(e,t)?"textarea":Re._isNumeric(e)?"number":"text"}static _isNumeric(e){for(let t=0,s=Ie.length;t<s;t++)if(c.hasValue(e,te.HAS_DATATYPE,Ie[t]))return!0;return!1}static resolveInputProperties(e,t,s){let n={};switch(n.type=Re._resolveInputType(e,t),n.type){case"textarea":n.rows=5;break;case"number":n=Object.assign({},n,Re._resolveNumberRestrictions(e),this._resolveStepRestriction(e))}return n.disabled=s.readOnly||ie.isDisabled(e),n}static _resolveStepRestriction(e){let t={};return void 0!==e[te.STEP]&&(t.step=c.getJsonAttValue(e,te.STEP)),t}static _resolveNumberRestrictions(e){let t={};return Object.getOwnPropertyNames(Oe).forEach(s=>{c.hasValue(e,te.HAS_DATATYPE,s)&&(t=Object.assign({},t,Oe[s]))}),void 0!==e[te.XSD.MIN_INCLUSIVE]&&(t.min=e[te.XSD.MIN_INCLUSIVE]),void 0!==e[te.XSD.MIN_EXCLUSIVE]&&(t.min=e[te.XSD.MIN_EXCLUSIVE]+1),void 0!==e[te.XSD.MAX_EXCLUSIVE]&&(t.max=e[te.XSD.MAX_EXCLUSIVE]-1),void 0!==e[te.XSD.MAX_INCLUSIVE]&&(t.max=e[te.XSD.MAX_INCLUSIVE]),t}static _preventCharacterInput(e,t){"number"!==Re._resolveInputType(t)||e.key>="0"&&e.key<="9"||["Backspace","Delete","ArrowLeft","ArrowRight","-","Minus","NumpadSubtract"].includes(e.key)||e.preventDefault()}}const Le=t=>{const{inputComponent:s,componentsOptions:n}=o(me),i=t.question,r=t.answer;let a=t.value;return r[te.HAS_OBJECT_VALUE]&&r[te.HAS_OBJECT_VALUE][c.RDFS_LABEL]&&(a=c.getJsonAttValue(r[te.HAS_OBJECT_VALUE],c.RDFS_LABEL)),/*#__PURE__*/e.createElement(s,Object.assign({},Re.resolveInputProperties(i,a,n),{validation:t.validation,label:t.label,title:t.title,value:null==a?"":a,placeholder:ie.getInputMask(i),onKeyPress:e=>Re._preventCharacterInput(e,i),onChange:e=>{t.onChange(e.target.value),(t.sparql||t.turtle)&&(void 0).hide()},onFocus:e=>{if(t.sparql){const s=U.fromTextArea(e.target);s.setValue(a),s.on("change",()=>{t.onChange(s.getValue())}),U.Autocompleters.prefixes.appendPrefixIfNeeded=function(e,s){if(!e.autocompleters.getTrie(s))return;if(!e.options.autocompleters||-1===e.options.autocompleters.indexOf(s))return;const n=e.getCursor(),o=e.getTokenAt(n);if("prefixed"===Ce[o.type]){const i=o.string.indexOf(":");if(-1!==i){const r=e.getPreviousNonWsToken(n.line,o).string.toUpperCase(),a=e.getTokenAt({line:n.line,ch:o.start});if("PREFIX"!==r&&("ws"===a.type||null==a.type)){const n=o.string.substring(0,i+1);if(null==e.getPrefixesFromQuery()[n.slice(0,-1)])if(t.question[te.HAS_DECLARED_PREFIX]&&t.question[te.HAS_DECLARED_PREFIX].filter(e=>e[te.PREFIX]===n.slice(0,-1)).length){const s=t.question[te.HAS_DECLARED_PREFIX].filter(e=>e[te.PREFIX]===n.slice(0,-1)),o={};o[s[0][te.PREFIX]]=s[0][te.NAMESPACE],e.addPrefixes(o)}else{const t=e.autocompleters.getTrie(s).autoComplete(n);t.length>0&&e.addPrefixes(t[0])}}}}}}else if(t.turtle){console.log("TTL");const s=U.fromTextArea(e.target);s.setValue(a),s.on("change",()=>{t.onChange(s.getValue())})}}}))};Le.propTypes={question:a.object.isRequired,answer:a.object.isRequired,label:a.object.isRequired,title:a.string,value:a.oneOfType([a.string,a.number]),onChange:a.func.isRequired,validation:a.object};const we={D:"1",M:"1",Y:"1",h:"1",m:"1",s:"1"};class be{static mapMask(e){if(!e)return e;let t,s="";for(let n=0,o=e.length;n<o;n++)t=e.charAt(n),s+=we[t]?we[t]:t;return s}}const ye=["size","placeholder"];function De(e){let t,s,n,o;if(void 0!==e.selectionStart)t=e.selectionStart,s=e.selectionEnd;else try{e.focus(),n=e.createTextRange(),o=n.duplicate(),n.moveToBookmark(document.selection.createRange().getBookmark()),o.setEndPoint("EndToStart",n),t=o.text.length,s=t+n.text.length}catch(e){}return{start:t,end:s}}class Ve extends e.Component{constructor(e){super(e),this._updatePattern=e=>{this.mask.setPattern(be.mapMask(e.mask),{value:this.mask.getRawValue(),selection:De(this.input)})},this._updateMaskSelection=()=>{this.mask.selection=De(this.input)},this._updateInputSelection=()=>{!function(e,t){let s;try{void 0!==e.selectionStart?(e.focus(),e.setSelectionRange(t.start,t.end)):(e.focus(),s=e.createTextRange(),s.collapse(!0),s.moveStart("character",t.start),s.moveEnd("character",t.end-t.start),s.select())}catch(e){}}(this.input,this.mask.selection)},this._onChange=e=>{const t=this.mask.getValue();if(e.target.value!==t){if(e.target.value.length<t.length){const s=t.length-e.target.value.length;this._updateMaskSelection(),this.mask.selection.end=this.mask.selection.start+s,this.mask.backspace()}const s=this._getDisplayValue();e.target.value=s,s&&this._updateInputSelection()}this.props.onChange&&this.props.onChange(e)},this._onKeyDown=e=>{if(function(e){return e.ctrlKey&&90===e.keyCode}(e))e.preventDefault(),this.mask.undo()&&(e.target.value=this._getDisplayValue(),this._updateInputSelection(),this.props.onChange&&this.props.onChange(e));else if(function(e){return e.ctrlKey&&89===e.keyCode}(e))e.preventDefault(),this.mask.redo()&&(e.target.value=this._getDisplayValue(),this._updateInputSelection(),this.props.onChange&&this.props.onChange(e));else if("Backspace"===e.key&&(e.preventDefault(),this._updateMaskSelection(),this.mask.backspace())){const t=this._getDisplayValue();e.target.value=t,t&&this._updateInputSelection(),this.props.onChange&&this.props.onChange(e)}},this._onKeyPress=e=>{e.metaKey||e.altKey||e.ctrlKey||"Enter"===e.key||(e.preventDefault(),this._updateMaskSelection(),this.mask.input(e.key)&&(e.target.value=this.mask.getValue(),this._updateInputSelection(),this.props.onChange&&this.props.onChange(e)))},this._onPaste=e=>{e.preventDefault(),this._updateMaskSelection(),this.mask.paste(e.clipboardData.getData("Text"))&&(e.target.value=this.mask.getValue(),setTimeout(this._updateInputSelection,0),this.props.onChange&&this.props.onChange(e))},this.mask=new x({pattern:be.mapMask(e.mask),value:e.value,formatCharacters:e.formatCharacters,placeholderChar:e.placeholderChar||"_"})}componentDidUpdate(e){e.mask!==this.props.mask&&this._updatePattern(this.props),e.mask!==this.props.mask&&e.value!==this.props.mask?this.mask.getValue()===this.mask.emptyValue?this.mask.setPattern(be.mapMask(this.props.mask),{value:this.props.value}):this.mask.setPattern(be.mapMask(this.props.mask),{value:this.mask.getRawValue()}):e.mask!==this.props.mask?this.mask.setPattern(be.mapMask(this.props.mask),{value:this.mask.getRawValue()}):e.value!==this.props.value&&this.mask.setValue(this.props.value),e.mask!==this.props.mask&&this.mask.selection.start&&this._updateInputSelection()}_getDisplayValue(){const e=this.mask.getValue();return e===this.mask.emptyValue?"":e}focus(){this.input.focus()}blur(){this.input.blur()}render(){const t=this.props,{size:s,placeholder:n}=t,o=X(t,ye),i=this.mask.pattern.length;/*#__PURE__*/return e.createElement(this.context.inputComponent,Object.assign({},o,{ref:e=>{e&&(this.input=e.input?p.findDOMNode(e.input):e)},maxLength:i,onChange:this._onChange,onKeyDown:this._onKeyDown,onKeyPress:this._onKeyPress,onPaste:this._onPaste,placeholder:n||this.mask.emptyValue,size:s||i,value:this._getDisplayValue(),type:"text"}))}}Ve.contextType=me,Ve.propTypes={mask:a.string.isRequired},Ve.defaultProps={value:""};const He=t=>{const{componentsOptions:s}=o(me),n=t.question,i=t.value,r=c.getJsonAttValue(n,te.INPUT_MASK);return r?/*#__PURE__*/e.createElement(Ve,{mask:r,value:i,label:t.label,title:t.title,placeholder:r,onChange:e=>t.onChange(e.target.value),disabled:s.readOnly||ie.isDisabled(n),validation:t.validation}):(K.warn("Input mask not provided. Falling back to regular input."),/*#__PURE__*/e.createElement(Le,t))};He.propTypes={question:a.object.isRequired,answer:a.object.isRequired,label:a.object.isRequired,title:a.string,value:a.oneOfType([a.string,a.number]),onChange:a.func.isRequired,validation:a.object};class Me extends e.Component{_generateSelectOptions(t){const s=[];t.sort(function(e,t){const s=c.getJsonAttValue(e,te.RDFS_LABEL),n=c.getJsonAttValue(t,te.RDFS_LABEL);return s<n?-1:s>n?1:0});for(let n=0;n<t.length;n++)s.push(/*#__PURE__*/e.createElement("option",{value:c.getJsonAttValue(t[n],te.RDFS_LABEL),key:"opt-"+n},c.getJsonAttValue(t[n],te.RDFS_LABEL)));return s}render(){const t=this.props.question;/*#__PURE__*/return e.createElement(this.context.inputComponent,{type:"select",label:this.props.label,value:this.props.value,title:this.props.title,validation:this.props.validation,onChange:e=>{this.props.onChange(e.target.value)},disabled:this.context.componentsOptions.readOnly||ie.isDisabled(t)},this._generateSelectOptions(t[te.HAS_OPTION]))}}Me.contextType=me,Me.propTypes={question:a.object.isRequired,label:a.object.isRequired,title:a.string,value:a.string,onChange:a.func.isRequired,validation:a.object};const Ue=(e,t)=>e&&e.length?(e.sort(oe.getCompareLocalizedLabelFunction(t)),oe.orderPreservingToplogicalSort(e,te.HAS_PRECEDING_VALUE),e):[],xe=t=>{const i=se.getStringHash(ie.getPossibleValuesQuery(t.question)),r=o(Z),a=o(me),l=a.options.intl,[u,p]=s(!0),[h,E]=s([Ue(t.options,l)]);n(()=>{let e=!1;const s=t.question;return!s[te.HAS_OPTION]&&ie.getPossibleValuesQuery(s)?async function(){try{const t=await r.loadFormOptions(i,ie.getPossibleValuesQuery(s));e||(p(!1),S(t))}catch(e){K.error(`An error has occurred during loadFormOptions for query hash: ${i}`)}}():(p(!1),S(s[te.HAS_OPTION])),()=>{e=!0}},[]);const S=e=>{if(!e)return[];e=Ue(e,l);const t={},s=[];for(let n of e){let e=c.getLocalized(n[te.RDFS_LABEL],l);t[n["@id"]]={id:n["@id"],value:n["@id"],label:e,children:[]};for(let e of se.asArray(n[te.BROADER]))s.push({type:"parent-child",parent:e["@id"],child:n["@id"]})}for(let e of s){var n;"parent-child"===e.type&&(null==(n=t[e.parent])||n.children.push(e.child))}const o=Object.values(t);E(o)},A=se.findKeyInObjects(h,["name","value"]),g=se.findKeyInObjects(h,["name","label"]);/*#__PURE__*/return e.createElement(d,{size:"small"},/*#__PURE__*/e.createElement(m.Label,null,t.label),/*#__PURE__*/e.createElement(P,{styles:(()=>{let e,s;return"is-warning"===t.validation.classname?(e="#dc9135",s="0 0 0 0.2rem rgba(203, 127, 16, 0.25)"):"is-invalid"===t.validation.classname&&(e="#dc3545",s="0 0 0 .2rem rgba(220,53,69,.25)"),{control:t=>Object.assign({},t,{border:e?`1px solid ${e}`:t.border,boxShadow:t.boxShadow,"&:hover":{border:`1px solid ${e}`,boxShadow:s||t.boxShadow}})}})(),valueKey:A,labelKey:g,valueRenderer:!1===t.question[te.PROVIDES_DEREFERENCEABLE_ANSWER_VALUES]?t=>/*#__PURE__*/e.createElement(e.Fragment,null,t):null,valueIsControlled:!0,value:h.filter(e=>e.id===t.value),multi:!1,options:h,isSearchable:!0,isLoading:u,isClearable:!0,renderAsTree:!0,optionLeftOffset:5,isDisabled:u||a.componentsOptions.readOnly||ie.isDisabled(t.question),onChange:e=>{t.onChange(e?e.id:null)}}),t.validation.message)};xe.propTypes={question:a.object.isRequired,answer:a.object.isRequired,label:a.oneOfType([a.string,a.object]).isRequired,title:a.string,value:a.string,onChange:a.func.isRequired,validation:a.object};const Pe=({title:t})=>/*#__PURE__*/e.createElement("svg",{className:"caret-square-up",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"28",viewBox:"0 0 24 28"},/*#__PURE__*/e.createElement("title",null,t||""),/*#__PURE__*/e.createElement("path",{d:"M17.891 17.453c-0.172 0.344-0.516 0.547-0.891 0.547h-10c-0.375 0-0.719-0.203-0.891-0.547-0.172-0.328-0.141-0.734 0.078-1.031l5-7c0.187-0.266 0.484-0.422 0.812-0.422s0.625 0.156 0.812 0.422l5 7c0.219 0.297 0.25 0.703 0.078 1.031zM20 21.5v-15c0-0.266-0.234-0.5-0.5-0.5h-15c-0.266 0-0.5 0.234-0.5 0.5v15c0 0.266 0.234 0.5 0.5 0.5h15c0.266 0 0.5-0.234 0.5-0.5zM24 6.5v15c0 2.484-2.016 4.5-4.5 4.5h-15c-2.484 0-4.5-2.016-4.5-4.5v-15c0-2.484 2.016-4.5 4.5-4.5h15c2.484 0 4.5 2.016 4.5 4.5z"})),qe=({title:t})=>/*#__PURE__*/e.createElement("svg",{className:"caret-square-down",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"28",viewBox:"0 0 24 28"},/*#__PURE__*/e.createElement("title",null,t||""),/*#__PURE__*/e.createElement("path",{d:"M17.891 10.547c0.172 0.328 0.141 0.734-0.078 1.031l-5 7c-0.187 0.266-0.484 0.422-0.812 0.422s-0.625-0.156-0.812-0.422l-5-7c-0.219-0.297-0.25-0.703-0.078-1.031 0.172-0.344 0.516-0.547 0.891-0.547h10c0.375 0 0.719 0.203 0.891 0.547zM20 21.5v-15c0-0.266-0.234-0.5-0.5-0.5h-15c-0.266 0-0.5 0.234-0.5 0.5v15c0 0.266 0.234 0.5 0.5 0.5h15c0.266 0 0.5-0.234 0.5-0.5zM24 6.5v15c0 2.484-2.016 4.5-4.5 4.5h-15c-2.484 0-4.5-2.016-4.5-4.5v-15c0-2.484 2.016-4.5 4.5-4.5h15c2.484 0 4.5 2.016 4.5 4.5z"})),Qe=()=>/*#__PURE__*/e.createElement("svg",{className:"info-circle",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"28",viewBox:"0 0 24 28"},/*#__PURE__*/e.createElement("title",null,"info-circle"),/*#__PURE__*/e.createElement("path",{d:"M16 21.5v-2.5c0-0.281-0.219-0.5-0.5-0.5h-1.5v-8c0-0.281-0.219-0.5-0.5-0.5h-5c-0.281 0-0.5 0.219-0.5 0.5v2.5c0 0.281 0.219 0.5 0.5 0.5h1.5v5h-1.5c-0.281 0-0.5 0.219-0.5 0.5v2.5c0 0.281 0.219 0.5 0.5 0.5h7c0.281 0 0.5-0.219 0.5-0.5zM14 7.5v-2.5c0-0.281-0.219-0.5-0.5-0.5h-3c-0.281 0-0.5 0.219-0.5 0.5v2.5c0 0.281 0.219 0.5 0.5 0.5h3c0.281 0 0.5-0.219 0.5-0.5zM24 14c0 6.625-5.375 12-12 12s-12-5.375-12-12 5.375-12 12-12 12 5.375 12 12z"})),Fe=()=>/*#__PURE__*/e.createElement("svg",{className:"question-circle",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"28",viewBox:"0 0 24 28"},/*#__PURE__*/e.createElement("path",{d:"M14 21.5v-3c0-0.281-0.219-0.5-0.5-0.5h-3c-0.281 0-0.5 0.219-0.5 0.5v3c0 0.281 0.219 0.5 0.5 0.5h3c0.281 0 0.5-0.219 0.5-0.5zM18 11c0-2.859-3-5-5.688-5-2.547 0-4.453 1.094-5.797 3.328-0.141 0.219-0.078 0.5 0.125 0.656l2.063 1.563c0.078 0.063 0.187 0.094 0.297 0.094 0.141 0 0.297-0.063 0.391-0.187 0.734-0.938 1.047-1.219 1.344-1.437 0.266-0.187 0.781-0.375 1.344-0.375 1 0 1.922 0.641 1.922 1.328 0 0.812-0.422 1.219-1.375 1.656-1.109 0.5-2.625 1.797-2.625 3.313v0.562c0 0.281 0.219 0.5 0.5 0.5h3c0.281 0 0.5-0.219 0.5-0.5v0c0-0.359 0.453-1.125 1.188-1.547 1.188-0.672 2.812-1.578 2.812-3.953zM24 14c0 6.625-5.375 12-12 12s-12-5.375-12-12 5.375-12 12-12 12 5.375 12 12z"})),je=t=>{const[n,o]=s("right");/*#__PURE__*/return e.createElement("span",{ref:e=>(e=>{e&&(e.getBoundingClientRect().x>window.innerWidth/2?o("left"):o("right"))})(e)},/*#__PURE__*/e.createElement(E,{overlay:t.show?/*#__PURE__*/e.createElement(S,{className:"tooltip-content",id:t.id},t.tooltipContent):/*#__PURE__*/e.createElement("span",null),placement:t.overlayPlacement||n},/*#__PURE__*/e.createElement("span",null,t.children)))};je.propTypes={tooltipContent:a.oneOfType([a.object.isRequired,a.string.isRequired]),id:a.string.isRequired,overlayPlacement:a.string,absolutePosition:a.bool,show:a.bool},je.defaultProps={iconClassContainer:"",iconClass:"",absolutePosition:!0,show:!0};const ze=t=>{const[n,o]=s("right");/*#__PURE__*/return e.createElement("div",{ref:e=>(e=>{e&&(e.getBoundingClientRect().x>window.innerWidth/2?o("left"):o("right"))})(e)},/*#__PURE__*/e.createElement(je,{id:"help-icon-tooltip-",overlayPlacement:t.overlayPlacement||n,absolutePosition:t.absolutePosition,tooltipContent:t.text},/*#__PURE__*/e.createElement(Fe,{className:t.iconClass})))};ze.propTypes={text:a.string.isRequired,iconClassContainer:a.string,iconClass:a.string,overlayPlacement:a.string,absolutePosition:a.bool},ze.defaultProps={iconClassContainer:"",iconClass:"",absolutePosition:!0};const ke=()=>/*#__PURE__*/e.createElement("svg",{className:"external-link-icon",width:"24",height:"16",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},/*#__PURE__*/e.createElement("path",{d:"M5,2 C5.55228,2 6,2.44772 6,3 C6,3.55228 5.55228,4 5,4 L4,4 L4,12 L12,12 L12,11 C12,10.4477 12.4477,10 13,10 C13.5523,10 14,10.4477 14,11 L14,12 C14,13.1046 13.1046,14 12,14 L4,14 C2.89543,14 2,13.1046 2,12 L2,4 C2,2.89543 2.89543,2 4,2 L5,2 Z M15,1 L15,5.99814453 C15,6.55043453 14.5523,6.99814453 14,6.99814453 C13.4477,6.99814453 13,6.55043453 13,5.99814453 L13,4.41419 L8.71571,8.69846 C8.32519,9.08899 7.69202,9.08899 7.3015,8.69846 C6.91097,8.30794 6.91097,7.67477 7.3015,7.28425 L11.5858,3 L9.99619141,3 C9.44391141,3 8.99619141,2.55228 8.99619141,2 C8.99619141,1.44772 9.44391141,1 9.99619141,1 L15,1 Z"})),Be=t=>/*#__PURE__*/e.createElement(je,{tooltipContent:t.url["@id"]||t.url,id:"url-tooltip",overlayPlacement:t.overlayPlacement},/*#__PURE__*/e.createElement("a",{href:t.url["@id"]||t.url,target:"_blank",className:t.iconClassContainer},/*#__PURE__*/e.createElement(ke,{className:t.iconClass})));Be.propTypes={url:a.oneOfType([a.string.isRequired,a.object.isRequired]),iconClassContainer:a.string,iconClass:a.string,overlayPlacement:a.string,absolutePosition:a.bool},Be.defaultProps={iconClassContainer:"",iconClass:"",absolutePosition:!0};const We=()=>/*#__PURE__*/e.createElement("svg",{className:"question-comment",version:"1.1",id:"Capa_1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 60 60",width:"24",height:"28"},/*#__PURE__*/e.createElement("path",{d:"M30,1.5c-16.542,0-30,12.112-30,27c0,5.204,1.646,10.245,4.768,14.604c-0.591,6.537-2.175,11.39-4.475,13.689 c-0.304,0.304-0.38,0.769-0.188,1.153C0.275,58.289,0.625,58.5,1,58.5c0.046,0,0.092-0.003,0.139-0.01 c0.405-0.057,9.813-1.411,16.618-5.339C21.621,54.71,25.737,55.5,30,55.5c16.542,0,30-12.112,30-27S46.542,1.5,30,1.5z M16,32.5 c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S18.206,32.5,16,32.5z M30,32.5c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4 S32.206,32.5,30,32.5z M44,32.5c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S46.206,32.5,44,32.5z"})),Ge=()=>/*#__PURE__*/e.createElement("svg",{className:"recycle-bin-icon",version:"1.1",xmlns:"http://www.w3.org/2000/svg",height:"15px",width:"15px",viewBox:"0 0 512 512"},/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("path",{d:"M331.636,69.818V0H180.364v69.818h-128v128h34.909V512h337.455V197.818h34.909v-128H331.636z M215.273,34.909h81.455\nv34.909h-81.455V34.909z M389.818,477.091H122.182V197.818h267.636V477.091z M424.727,162.909H87.273v-58.182h337.455V162.909z"}))),/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("rect",{x:"168.727",y:"256",width:"34.909",height:"162.909"}))),/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("rect",{x:"308.364",y:"256",width:"34.909",height:"162.909"}))),/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("rect",{x:"238.545",y:"256",width:"34.909",height:"162.909"})))),Ye="Unknown author",Xe=t=>{const{options:n}=o(me),[i,r]=s(!1),[a,l]=s(!1);F.addLocale(z),F.addLocale(j),F.setDefaultLocale(te.LANG.en.locale);const c=new F(n.intl.locale),u=()=>{if(n&&n.users){const e=n.users.find(e=>e.id===n.currentUser);if(t.author)return e.label?e.label:p()}return Ye},p=()=>t.author["@id"].replace(/.*[#\/]/,"... "),m=()=>{r(!i)};/*#__PURE__*/return e.createElement("div",{className:"comment-content",onMouseEnter:()=>{l(!0)},onMouseLeave:()=>{l(!1)}},/*#__PURE__*/e.createElement("div",{className:"row"},/*#__PURE__*/e.createElement("div",{className:"col-auto comment-author",onMouseEnter:m,onMouseLeave:m},/*#__PURE__*/e.createElement(e.Fragment,null,i?/*#__PURE__*/e.createElement(e.Fragment,null,u(),/*#__PURE__*/e.createElement(Be,{iconClassContainer:"emphasise-on-relevant-icon",url:t.author?Object.values(t.author).toString():Ye})):u())),/*#__PURE__*/e.createElement("div",{className:"col-auto text-muted comment-timestamp"},/*#__PURE__*/e.createElement(je,{id:"exact-time-overlay",tooltipContent:(()=>{const e=new Date(parseInt(t.timestamp));return new Intl.DateTimeFormat(n.intl.locale,{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}).format(e)})()},c.format(parseInt(t.timestamp)))),a?/*#__PURE__*/e.createElement(k.div,{className:"comment-delete emphasise-on-relevant-icon",whileHover:{scale:1.2},whileTap:{scale:.9},onClick:()=>{t.onDeleteQuestionComment(t.index),t.onDeleteViewComment()}},/*#__PURE__*/e.createElement(Ge,null)):null),/*#__PURE__*/e.createElement("div",{className:"row"},/*#__PURE__*/e.createElement("div",{className:"col comment-value"},t.commentValue)))};Xe.propTypes={author:a.object,timestamp:a.string.isRequired,commentValue:a.string.isRequired,onDeleteQuestionComment:a.func.isRequired,onDeleteViewComment:a.func,index:a.number.isRequired};const Ke=({comments:e,onDeleteCommentClick:t})=>{const o=i(null),[r,a]=s(!1),l=()=>{a(!0),setTimeout(()=>{a(!1)},2e3)};return n(()=>{null!==o.current&&(o.current.scrollTop=o.current.scrollHeight)},[JSON.stringify(e)]),q("span",{children:r?Q("div",{className:"comment-delete",children:[q(B,{color:"#00BFFF",height:80,width:80}),q("p",{children:"Deleting comment..."})]}):q("div",{className:"comment-list-items",ref:o,children:e.map((e,s)=>q("div",{className:"comment-list-item",children:q(Xe,{commentValue:e[te.HAS_COMMENT_VALUE],author:e[te.HAS_AUTHOR]?e[te.HAS_AUTHOR]:null,timestamp:e[te.HAS_TIMESTAMP],onDeleteQuestionComment:t,onDeleteViewComment:l,index:s})},s))})})},Je=()=>/*#__PURE__*/e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"15",viewBox:"0 0 24 24"},/*#__PURE__*/e.createElement("path",{d:"M6.185 4.843l11.927 7.157-11.927 7.157 2.982-7.157-2.982-7.157zm-4.185-4.843l5 12-5 12 20-12-20-12z"})),Ze="300px",$e=t=>{const[o,r]=s(""),a=i(null),l=W();n(()=>{a.current.focus()},[]);const c=e=>{e.preventDefault(),t.onChange(o),r("")},u=()=>{const e=a.current;e.style.height="auto",p(e)},p=e=>{e.style.height=`${e.scrollHeight}px`,parseInt(e.style.height)>parseInt(Ze)&&(e.style.height=Ze)};/*#__PURE__*/return e.createElement(m,{onSubmit:c,onKeyUp:e=>{"Enter"===e.key&&e.ctrlKey&&o.trim()&&c(e)},onClick:e=>{e.stopPropagation()}},/*#__PURE__*/e.createElement(m.Group,{className:"m-2",controlId:"formBasicComment"},/*#__PURE__*/e.createElement(A,{className:"col-lg-12 p-0"},/*#__PURE__*/e.createElement(g,{className:"container-fluid p-0 m-0"},/*#__PURE__*/e.createElement("div",{id:"comment-form"},/*#__PURE__*/e.createElement(m.Control,{className:"comment-form-control",name:"comment",as:"textarea",placeholder:l.formatMessage({id:"comment.form.placeholder"}),required:!0,value:o,onChange:e=>{r(e.target.value)},ref:a,onKeyPress:u,onKeyDown:u}),/*#__PURE__*/e.createElement(_,{className:"comment-form-button",variant:"primary",type:"submit"},/*#__PURE__*/e.createElement(Je,null)))))))};$e.propTypes={onChange:a.func.isRequired};const et=()=>/*#__PURE__*/e.createElement("svg",{className:"close-icon",width:"24px",height:"24px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},/*#__PURE__*/e.createElement("path",{d:"M13.41 12l4.3-4.29a1 1 0 1 0-1.42-1.42L12 10.59l-4.29-4.3a1 1 0 0 0-1.42 1.42l4.3 4.29-4.3 4.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l4.29-4.3 4.29 4.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42z"})),tt=t=>{const r=o(me),a=i(null),l=i(null),c=i(null),[u,p]=s(!1),[m,d]=s("right");n(()=>{I(c.current)});const h=()=>{p(!1)},E=()=>{const e=t.question;return e[te.HAS_COMMENT]||(e[te.HAS_COMMENT]=[]),Array.isArray(e[te.HAS_COMMENT])||(e[te.HAS_COMMENT]=[e[te.HAS_COMMENT]]),e[te.HAS_COMMENT]},A=e=>{const s={};g(s,e),t.onChange(N(),s)},g=(e,t)=>{r.options.currentUser&&(e[te.HAS_AUTHOR]={"@id":r.options.currentUser}),e[te.HAS_COMMENT_VALUE]=t,e[te.HAS_TIMESTAMP]=Date.now().toString()},_=e=>{E().splice(e,1)},T=e=>{e.preventDefault(),e.stopPropagation()},N=()=>E().length,I=e=>{e&&(e.getBoundingClientRect().x>window.innerWidth/2?d("left"):d("right"))};/*#__PURE__*/return e.createElement("div",{ref:c,onClick:T},/*#__PURE__*/e.createElement("span",{className:"comment-bubble",ref:a,onClick:e=>{T(e),p(!u)}},/*#__PURE__*/e.createElement(We,null),N()>0?/*#__PURE__*/e.createElement(f,{className:"comment-badge",pill:!0,variant:"primary"},N()):null),/*#__PURE__*/e.createElement(k.div,{className:"overlay-comment",ref:l,drag:!0,dragConstraints:{top:-50,left:-50,right:50,bottom:50}},/*#__PURE__*/e.createElement(v,{target:a.current,show:u,placement:m,rootClose:!1,onHide:h,container:l},t=>/*#__PURE__*/e.createElement(S,Y({className:"comment-tooltip"},t),/*#__PURE__*/e.createElement("span",{onKeyDown:e=>{(e=>{"Escape"===e.key&&h()})(e)}},/*#__PURE__*/e.createElement(k.div,{className:"close-comment-icon",onClick:h,whileHover:{scale:1.1,transition:{duration:.1}}},/*#__PURE__*/e.createElement(et,null)),/*#__PURE__*/e.createElement(Ke,{comments:E(),onDeleteCommentClick:_}),/*#__PURE__*/e.createElement($e,{onChange:A}))))))};var st;tt.propTypes={question:a.object.isRequired,onChange:a.func.isRequired};class nt{static renderIcons(t,s,n,o){let i;i=s.icons?s.icons:te.DEFAULT_OPTIONS.icons;let r=[];const a=this.renderQuestionHelp(t,s,n,o),l=this.renderQuestionComments(t,s,n,o),c=this.renderQuestionLink(t,s,n,o);for(let t=0;t<i.length;t++)i[t].id===te.ICONS.QUESTION_COMMENTS&&r.push(/*#__PURE__*/e.createElement("li",{key:t,className:"icon-list-item"},l)),i[t].id===te.ICONS.QUESTION_HELP&&r.push(/*#__PURE__*/e.createElement("li",{key:t,className:"icon-list-item"},a)),i[t].id===te.ICONS.QUESTION_LINK&&r.push(/*#__PURE__*/e.createElement("li",{key:t,className:"icon-list-item"},c));/*#__PURE__*/return e.createElement("ol",{className:"icon-list-items"},r)}static renderQuestionHelp(e,t,s,n){return this.getIconComponentFromName(te.ICONS.QUESTION_HELP,e,t,s,n)}static renderQuestionLink(e,t,s,n){return this.getIconComponentFromName(te.ICONS.QUESTION_LINK,e,t,s,n)}static getIconComponentFromName(e,t,s,n,o){const i=this.getIconFromIconList(s.icons?s.icons:te.DEFAULT_OPTIONS.icons,e);return this.getIconComponent(i,t,s,n,o)}static getIconComponent(t,s,n,o,i){let r;if(t&&(t.behavior===te.ICON_BEHAVIOR.ON_HOVER||t.behavior===te.ICON_BEHAVIOR.ENABLE))return t.behavior===te.ICON_BEHAVIOR.ENABLE?(i=!0,r=""):r="emphasise-on-relevant-icon",t.id===te.ICONS.QUESTION_HELP&&s[te.HELP_DESCRIPTION]?i?/*#__PURE__*/e.createElement("div",{className:r},/*#__PURE__*/e.createElement(ze,{text:c.getLocalized(s[te.HELP_DESCRIPTION],n.intl),absolutePosition:!1})):null:t.id===te.ICONS.QUESTION_LINK&&s[te.SOURCE]?i?/*#__PURE__*/e.createElement("div",{className:r},/*#__PURE__*/e.createElement(Be,{url:s[te.SOURCE]})):null:t.id===te.ICONS.QUESTION_COMMENTS&&i?/*#__PURE__*/e.createElement("div",{className:r},/*#__PURE__*/e.createElement(tt,{question:s,onChange:o})):null}}st=nt,nt.renderQuestionComments=(e,t,s,n)=>st.getIconComponentFromName(te.ICONS.QUESTION_COMMENTS,e,t,s,n),nt.getIconFromIconList=(e,t)=>e?e.find(e=>e.id===t):null;const ot=t=>{const o=e.useContext(Z),{options:i}=e.useContext(me),[r,a]=s({severity:"",classname:"",message:null});n(()=>{p()},[t.question]);const l=e=>{const s=Object.assign({},t.answer);u(s,e),t.onChange(t.index,s)},u=(e,s)=>{null===s?(e[te.HAS_OBJECT_VALUE]=null,e[te.HAS_DATA_VALUE]=null):t.answer[te.HAS_OBJECT_VALUE]||ie.isTypeahead(t.question)?e[te.HAS_OBJECT_VALUE]={"@id":s}:e[te.HAS_DATA_VALUE]={"@value":s}},p=()=>{a({severity:"",classname:"",message:null}),!1===m[te.HAS_VALID_ANSWER]&&a(m[te.HAS_VALIDATION_SEVERITY]===te.VALIDATION.SEVERITY.WARNING?{severity:te.VALIDATION.SEVERITY.WARNING,classname:te.VALIDATION.CLASSNAME.WARNING,message:/*#__PURE__*/e.createElement(T,{className:te.VALIDATION.CLASSNAME.WARNING},m[te.HAS_VALIDATION_MESSAGE])}:{severity:te.VALIDATION.SEVERITY.ERROR,classname:te.VALIDATION.CLASSNAME.ERROR,message:/*#__PURE__*/e.createElement(T,{className:te.VALIDATION.CLASSNAME.ERROR},m[te.HAS_VALIDATION_MESSAGE])})},m=t.question,d=ie.resolveValue(t.answer),h=(s=>{const n=c.getLocalized(s[te.RDFS_LABEL],i.intl);/*#__PURE__*/return e.createElement("div",{className:"question-header"},n,nt.renderIcons(t.question,i,t.onCommentChange,t.showIcon))})(m),E=c.getLocalized(m[te.RDFS_COMMENT],i.intl);let S;var A;return S=ie.isTypeahead(m)?((s,n,i)=>{const a=se.getStringHash(ie.getPossibleValuesQuery(t.question)),c=o.getOptions(a)||[];/*#__PURE__*/return e.createElement(xe,{question:t.question,answer:t.answer,label:n,title:i,value:s,onChange:l,options:c,validation:r})})(d,h,E):(A=m)[te.HAS_OPTION]&&0!==A[te.HAS_OPTION].length?((s,n,o)=>/*#__PURE__*/e.createElement(Me,{question:t.question,label:n,title:o,value:s,onChange:l,validation:r}))(d,h,E):ie.isCalendar(m)?((s,n,o)=>/*#__PURE__*/e.createElement(Ne,{question:t.question,value:s,title:o,label:n,onChange:l,validation:r}))(d,h,E):ie.isCheckbox(m)?((s,n,o)=>/*#__PURE__*/e.createElement(Te,{label:n,title:o,value:s,onChange:l,question:t.question,validation:r}))(d,h,E):ie.isMaskedInput(m)?((s,n,o)=>/*#__PURE__*/e.createElement(He,{label:n,title:o,value:s,onChange:l,question:t.question,answer:t.answer,validation:r}))(d,h,E):ie.isSparqlInput(m)?((s,n,o)=>/*#__PURE__*/e.createElement(Le,{question:t.question,answer:t.answer,label:n,title:o,value:s,onChange:l,sparql:!0,validation:r}))(d,h,E):ie.isTurtleInput(m)?((s,n,o)=>/*#__PURE__*/e.createElement(Le,{question:t.question,answer:t.answer,label:n,title:o,value:s,onChange:l,turtle:!0,validation:r}))(d,h,E):((s,n,o)=>/*#__PURE__*/e.createElement(Le,{question:t.question,answer:t.answer,label:n,title:o,value:s,onChange:l,validation:r}))(d,h,E),S};ot.propTypes={answer:a.object.isRequired,question:a.object.isRequired,onChange:a.func.isRequired,onCommentChange:a.func.isRequired,index:a.number,icons:a.object};class it{static createValidator(e,t){const s=[this._intMaxInclusiveValidator,this._intMinInclusiveValidator,this._patternValidator,this._checkboxValidator,this._requiredValidator,this._completenessValidator];return()=>{if(ie.hasValidationLogic(e)){const n=ie.getAnswerValue(e);return this._validateAnswer(e,t,n,s)}}}static _validateAnswer(e,t,s,n){const o={};for(const i of n){const n=i(e,t,s);if(!n.isValid)return o[te.HAS_VALID_ANSWER]=!1,o[te.HAS_VALIDATION_MESSAGE]=n.message,o[te.HAS_VALIDATION_SEVERITY]=n.validationSeverity,o;if(!1===o[te.HAS_VALID_ANSWER])break}return o[te.HAS_VALID_ANSWER]=!0,o[te.HAS_VALIDATION_MESSAGE]="",o[te.HAS_VALIDATION_SEVERITY]="",o}static _patternValidator(e,t){const s=ie.getAnswerValue(e);return s&&s.length>0&&e[te.PATTERN]&&!new RegExp(e[te.PATTERN]).test(s)&&ie.hasAnswer(e)?{isValid:!1,validationSeverity:te.VALIDATION.SEVERITY.ERROR,message:e[te.HAS_VALIDATION_MESSAGE]?e[te.HAS_VALIDATION_MESSAGE]:te.VALIDATION.DEFAULT_MESSAGE.INVALID}:{isValid:!0}}static _requiredValidator(e,t){return!e[te.REQUIRES_ANSWER]||e[te.USED_ONLY_FOR_COMPLETENESS]||ie.hasAnswer(e)?{isValid:!0}:{isValid:!1,validationSeverity:te.VALIDATION.SEVERITY.ERROR,message:e[te.HAS_VALIDATION_MESSAGE]?e[te.HAS_VALIDATION_MESSAGE]:te.VALIDATION.DEFAULT_MESSAGE.REQUIRED}}static _checkboxValidator(e,t){return ie.isCheckbox(e)&&e[te.REQUIRES_ANSWER]&&!ie.hasAnswer(e)?{isValid:!1,validationSeverity:te.VALIDATION.SEVERITY.ERROR,message:e[te.HAS_VALIDATION_MESSAGE]?e[te.HAS_VALIDATION_MESSAGE]:te.VALIDATION.DEFAULT_MESSAGE.CHECK}:{isValid:!0}}static _completenessValidator(e,t){return e[te.REQUIRES_ANSWER]&&e[te.USED_ONLY_FOR_COMPLETENESS]&&!ie.hasAnswer(e)?{isValid:!1,validationSeverity:te.VALIDATION.SEVERITY.WARNING,message:e[te.HAS_VALIDATION_MESSAGE]?e[te.HAS_VALIDATION_MESSAGE]:te.VALIDATION.DEFAULT_MESSAGE.REQUIRED_ONLY_FOR_COMPLETENESS}:{isValid:!0}}static _intMinInclusiveValidator(e,t){if(e[te.XSD.MIN_INCLUSIVE]){const t=ie.getAnswerValue(e);if(t&&t.length>0){const s=e[te.XSD.MIN_INCLUSIVE];if(!(Number.isInteger(parseInt(t))&&t>=s))return{isValid:!1,validationSeverity:te.VALIDATION.SEVERITY.ERROR,message:e[te.HAS_VALIDATION_MESSAGE]?e[te.HAS_VALIDATION_MESSAGE]:te.VALIDATION.DEFAULT_MESSAGE.GREATER_OR_EQUAL+s+"."}}}return{isValid:!0}}static _intMaxInclusiveValidator(e,t){const s=ie.getAnswerValue(e);if(e[te.XSD.MAX_INCLUSIVE]&&s&&s.length>0){const t=e[te.XSD.MAX_INCLUSIVE];if(!(Number.isInteger(parseInt(s))&&s<=t))return{isValid:!1,validationSeverity:te.VALIDATION.SEVERITY.ERROR,message:e[te.HAS_VALIDATION_MESSAGE]?e[te.HAS_VALIDATION_MESSAGE]:te.VALIDATION.DEFAULT_MESSAGE.LOWER_OR_EQUAL+t+"."}}return{isValid:!0}}}class rt extends e.Component{constructor(e){super(e),this.state={prefixes:e.prefixes}}render(){const t=/*#__PURE__*/e.createElement(N,{id:"prefixes",title:"Prefixes"},/*#__PURE__*/e.createElement(I,null,this.state.prefixes.sort((e,t)=>e[te.PREFIX]<t[te.PREFIX]?-1:1).map(t=>/*#__PURE__*/e.createElement(O,{key:t[te.PREFIX]},/*#__PURE__*/e.createElement("strong",null,t[te.PREFIX]),": ",t[te.NAMESPACE]))));/*#__PURE__*/return e.createElement(E,{trigger:"click",placement:"right",overlay:t},/*#__PURE__*/e.createElement("span",{className:this.props.iconClass},this.props.children))}}rt.propTypes={prefixes:a.array.isRequired,children:a.element.isRequired,iconClass:a.string},rt.defaultProps={iconClass:""};const at=({question:e})=>(()=>{const t=e[te.HAS_MEDIA_CONTENT];return t?Array.isArray(t)?q("div",{className:"col-6",children:t.map((e,s)=>q("div",{className:"row embed-responsive-21by9 media-content-video-container mb-3",children:q("iframe",{src:t[s],className:"embed-responsive-item",allowFullScreen:!0})},s))}):q("div",{className:"col-6",children:q("iframe",{src:t,className:"embed-responsive-item",allowFullScreen:!0})}):null})();class lt extends e.Component{constructor(e){super(e),this.handleAnswerChange=(e,t)=>{if(ie.isSection(this.props.question)){let e=!!ie.resolveValue(t);this.setState({expanded:e})}this._handleChange(te.HAS_ANSWER,e,t)},this.handleSubQuestionChange=(e,t)=>{this._handleChange(te.HAS_SUBQUESTION,e,t)},this.handleCommentChange=(e,t)=>{this._handleChange(te.HAS_COMMENT,e,t)},this._toggleCollapse=()=>{this.props.collapsible&&this.setState({expanded:!this.state.expanded})},this._onMouseEnterHandler=()=>{this.setState({showIcon:!0})},this._onMouseLeaveHandler=()=>{this.setState({showIcon:!1})},this._getHeaderClassName=()=>{const e=this.props.question,t=this.props.collapsible;let s=[];return s.push(lt.getEmphasizedOnRelevantClass(e),"question-header"),ie.isWizardStep(e)&&s.push("wizard-step bg-primary text-white"),ie.isEmphasised(e)&&s.push(lt.getEmphasizedClass(e)),ie.isSection(e)&&s.push("section-background"),t&&s.push("cursor-pointer"),this.isDebugged(e)&&s.push("show-irrelevant"),s},ne.putObject(e.question["@id"],e.question),this.state={validator:{},expanded:!ie.isCollapsed(e.question),showIcon:!1}}componentDidMount(){this.setState({validator:it.createValidator(this.props.question,this.context.options.intl)})}componentDidUpdate(){const e=this.props.question,t=this.context.options.startingQuestionId,s=e[te.HAS_SUBQUESTION].find(e=>e["@id"]===t);if(ie.isSection(e)&&ie.isAnswerable(e)){const e=this._getFirstAnswerValue();if(this.context.options.debugMode)return null;if(s)return null;this.state.expanded&&!e&&this.setState({expanded:!1})}}_handleChange(e,t,s){let n=Object.assign({},this.props.question);if(n[e][t]=s,e===te.HAS_ANSWER){const e=this.state.validator(s);n=Object.assign({},n,e)}ne.putObject(n["@id"],n),this.props.onChange(this.props.index,n)}isDebugged(e){const t=this.context.options.startingQuestionId;return!ie.isRelevant(e)&&(!!this.context.options.debugMode||null!=t&&!!se.findQuestionById(t,e,!0,!1,!1))}render(){const t=this.props.question,s=this.renderQuestion(t);return this.isDebugged(t)?/*#__PURE__*/e.createElement("div",{className:"show-irrelevant"},s):ie.isHidden(t)?null:ie.isRelevant(t)?s:null}renderQuestion(t){if(ie.isAnswerable(t)&&!ie.isSection(t))/*#__PURE__*/return e.createElement("div",{id:t["@id"]},/*#__PURE__*/e.createElement("div",{className:"panel-title answerable-question"},this.renderAnswers()),/*#__PURE__*/e.createElement("div",{className:"answerable-subquestions"},this.renderSubQuestions()));if(ie.isAnswerable(t))return this.renderAnswerableSection();if(ie.isSection(t)){const{collapsible:s,withoutCard:n}=this.props,o=lt._getQuestionCategoryClass(t);if(n)/*#__PURE__*/return e.createElement("div",null,this._renderQuestionContent());const i=c.getLocalized(t[c.RDFS_LABEL],this.context.options.intl),r=/*#__PURE__*/e.createElement(C.Body,{className:M("p-3",o)},this._renderQuestionContent());/*#__PURE__*/return e.createElement(e.Fragment,null,/*#__PURE__*/e.createElement(R,{defaultActiveKey:this.state.expanded?void 0:i},/*#__PURE__*/e.createElement(C,{className:"mb-3"},/*#__PURE__*/e.createElement(R.Toggle,{as:C.Header,onClick:this._toggleCollapse,className:this._getHeaderClassName(),onMouseEnter:this._onMouseEnterHandler,onMouseLeave:this._onMouseLeaveHandler},/*#__PURE__*/e.createElement("h6",{className:"d-inline",id:t["@id"]},s&&!ie.isWizardStep(t)&&this._renderCollapseToggle(),i),this.renderQuestionIcons(),this.props.children),/*#__PURE__*/e.createElement(s?R.Collapse:e.Fragment,null,r))))}/*#__PURE__*/return e.createElement("div",null,this._renderQuestionContent())}_renderQuestionContent(){let t=[];return this.state.expanded&&t.push(/*#__PURE__*/e.createElement(at,{key:this.props.question["@id"]+"-media",question:this.props.question})),t.push(this.renderAnswers()),t.push(this.renderSubQuestions()),t}renderQuestionIcons(){return nt.renderIcons(this.props.question,this.context.options,this.handleCommentChange,this.state.showIcon)}renderAnswerableSection(){const t=this.props.question,s=this.props.collapsible,n=lt._getQuestionCategoryClass(t);let o=this.getShowIrrelevantClassname(t);const i=/*#__PURE__*/e.createElement(C.Body,{className:M("p-3",n)},this.renderSubQuestions(o));/*#__PURE__*/return e.createElement(R,{activeKey:this.state.expanded?t["@id"]:void 0,className:"answerable-section"},/*#__PURE__*/e.createElement(C,{className:"mb-3"},/*#__PURE__*/e.createElement(C.Header,{onClick:this._toggleCollapse,className:this._getHeaderClassName()},this.renderAnswers()),s?/*#__PURE__*/e.createElement(R.Collapse,{className:o,eventKey:t["@id"]},i):{cardBody:i}))}getShowIrrelevantClassname(e){return!this.context.options.debugMode&&!oe.checkId(e[te.HAS_SUBQUESTION],this.context.options.startingQuestionId)||ie.hasAnswer(e)?"":"show-irrelevant"}renderAnswers(){const t=this.props.question,s=[],n=this._getAnswers();let o;for(let i=0,r=n.length;i<r;i++)ie.isTextarea(t,ie.resolveValue(n[i]))||ie.isSparqlInput(t)||ie.isTurtleInput(t),o=M("answer",lt._getQuestionCategoryClass(t),lt.getEmphasizedOnRelevantClass(t)),s.push(/*#__PURE__*/e.createElement("div",{key:"row-item-"+i,className:o,id:t["@id"],onMouseEnter:this._onMouseEnterHandler,onMouseLeave:this._onMouseLeaveHandler},/*#__PURE__*/e.createElement("div",{className:"answer-content",style:this._getAnswerWidthStyle()},/*#__PURE__*/e.createElement(ot,{index:i,answer:n[i],question:t,onChange:this.handleAnswerChange,onCommentChange:this.handleCommentChange,showIcon:this.state.showIcon})),this._renderUnits(),this._renderPrefixes()));return s}_getAnswers(){const e=this.props.question;return e[te.HAS_ANSWER]||(e[te.HAS_ANSWER]=[]),Array.isArray(e[te.HAS_ANSWER])||(e[te.HAS_ANSWER]=[e[te.HAS_ANSWER]]),0===e[te.HAS_ANSWER].length&&(e[te.HAS_ANSWER]=ie.isSection(e)&&!ie.isAnswerable(e)?[]:[ve.generateAnswer(e)]),e[te.HAS_ANSWER]}_getAnswerWidthStyle(){const e=Number(this.props.question[te.HAS_INITIAL_INPUT_LENGTH]);return e?{flexGrow:0,maxWidth:"none",width:`calc(${e}ch + 1.5rem + 2px)`}:{}}static _getAnswerClass(e,t){return t?"col-12":1===te.GENERATED_ROW_SIZE?"col-6":"col-"+te.COLUMN_COUNT/te.GENERATED_ROW_SIZE}static _getQuestionCategoryClass(e){const t=ie.getCategory(e);return t?"question-"+t:""}static getEmphasizedClass(e){return ie.isEmphasised(e)?"bg-warning":""}static getEmphasizedOnRelevantClass(e){return c.hasValue(e,te.LAYOUT_CLASS,te.LAYOUT.EMPHASISE_ON_RELEVANT)?"emphasise-on-relevant":""}_renderCollapseToggle(){const{options:t}=this.context,s=this.state.expanded?t.i18n["section.collapse"]:t.i18n["section.expand"];/*#__PURE__*/return e.createElement("span",{onClick:this._toggleCollapse,title:s},/*#__PURE__*/e.createElement(this.state.expanded?Pe:qe,{title:s}))}_renderPrefixes(){const t=this.props.question;return t[te.HAS_DECLARED_PREFIX]&&t[te.HAS_DECLARED_PREFIX].length?/*#__PURE__*/e.createElement(rt,{prefixes:t[te.HAS_DECLARED_PREFIX],iconClass:"help-icon-checkbox"},/*#__PURE__*/e.createElement(Qe,null)):null}_renderUnits(){const t=this.props.question;return t[te.HAS_UNIT]?/*#__PURE__*/e.createElement("div",{className:"has-unit-label"},t[te.HAS_UNIT]):null}renderSubQuestions(t){const s=[],n=this._getSubQuestions(),o=this.context.options.debugMode,i=this.context.options.startingQuestionId;for(let r=0;r<n.length;r++){let a=n[r],l=this.context.mapComponent(a,lt),c=null;(o||"show-irrelevant"!==t||se.findQuestionById(i,a,!0,!1,!1))&&(c=/*#__PURE__*/e.createElement(l,{key:"sub-question-"+r,question:a,onChange:this.handleSubQuestionChange,index:r})),s.push(c)}return s}_getSubQuestions(){const e=this.props.question;return e[te.HAS_SUBQUESTION]||(e[te.HAS_SUBQUESTION]=[]),Array.isArray(e[te.HAS_SUBQUESTION])||(e[te.HAS_SUBQUESTION]=[e[te.HAS_SUBQUESTION]]),oe.orderByLocalizedLabels(e[te.HAS_SUBQUESTION],this.context.options.intl),oe.orderPreservingToplogicalSort(e[te.HAS_SUBQUESTION],te.HAS_PRECEDING_QUESTION),e[te.HAS_SUBQUESTION]}_getFirstAnswerValue(){return ie.resolveValue(this._getAnswers()[0])}}lt.contextType=me,lt.propTypes={question:a.object.isRequired,onChange:a.func.isRequired,index:a.number,withoutCard:a.bool,collapsible:a.bool},lt.defaultProps={withoutCard:!1,collapsible:!0};class ct extends e.Component{constructor(t){super(t),this.onNextStep=()=>{this.context.updateFormQuestionsData(this.props.index,this.context.getFormQuestionsData()),this.props.onNextStep()},this.onPreviousStep=()=>{this.props.onPreviousStep()},this._renderWizardStepButtons=()=>/*#__PURE__*/e.createElement(L,{className:"m-3 float-right"},!this.props.isFirstStep&&/*#__PURE__*/e.createElement(_,{className:"mr-2",onClick:this.onPreviousStep,variant:"primary",size:"sm"},this.props.options.i18n["wizard.previous"]),!this.props.isLastStep&&/*#__PURE__*/e.createElement(_,{onClick:this.onNextStep,variant:"primary",size:"sm"},this.props.options.i18n["wizard.next"])),this.onChange=(e,t)=>{this.context.updateFormQuestionsData(this.props.index||e,Object.assign({},this.props.question,t))}}render(){const t=this.context.getFormQuestionsData([this.props.index]);/*#__PURE__*/return e.createElement(e.Fragment,null,/*#__PURE__*/e.createElement(lt,{question:t,onChange:this.onChange,collapsible:ie.isAnswerable(t)}),this.props.options.wizardStepButtons&&this._renderWizardStepButtons())}}ct.propTypes={options:a.object.isRequired,question:a.object.isRequired,index:a.number.isRequired,onNextStep:a.func,onPreviousStep:a.func,mapComponent:a.func,isFirstStep:a.bool,isLastStep:a.bool},ct.contextType=le;const ut=({steps:t,onNavigate:s,currentStep:n})=>{const{options:i}=o(me),r=W();/*#__PURE__*/return e.createElement(C.Header,null,/*#__PURE__*/e.createElement(w,{variant:"tabs",activeKey:n,onSelect:e=>s(parseInt(e))},t.map((t,s)=>/*#__PURE__*/e.createElement(je,{id:"step-disabled",tooltipContent:r.formatMessage({id:"wizard.nav.tooltip"}),show:!i.enableWizardStepSkip},/*#__PURE__*/e.createElement(b,{key:"nav"+s,id:"wizard-nav-"+s},/*#__PURE__*/e.createElement(y,{eventKey:s,active:s===n?"active":"",hidden:!i.debugMode&&!ie.isRelevant(t),disabled:!i.enableWizardStepSkip,className:M([i.debugMode&&!ie.isRelevant(t)?"show-irrelevant":lt.getEmphasizedClass(t),"wizard-nav"])},c.getLocalized(t[c.RDFS_LABEL],i.intl)))))))};ut.propTypes={currentStep:a.number.isRequired,steps:a.array.isRequired,onNavigate:a.func.isRequired};const pt=({steps:t,onNavigate:s,currentStep:n})=>{const{options:i}=o(me),r=W();/*#__PURE__*/return e.createElement("div",{className:"wizard-nav col-2 p-0"},/*#__PURE__*/e.createElement(I,null,t.map((t,o)=>/*#__PURE__*/e.createElement(je,{id:"step-disabled",tooltipContent:r.formatMessage({id:"wizard.nav.tooltip"}),show:!i.enableWizardStepSkip},/*#__PURE__*/e.createElement(O,{hidden:!i.debugMode&&!ie.isRelevant(t),key:"nav"+o,onClick:()=>s(o),id:"wizard-nav-"+o,action:!0,active:o===n?"active":"",disabled:!i.enableWizardStepSkip,variant:"default",className:M([i.debugMode&&!ie.isRelevant(t)?"show-irrelevant":lt.getEmphasizedClass(t),"wizard-nav"])},c.getLocalized(t[c.RDFS_LABEL],i.intl))))))};pt.propTypes={currentStep:a.number.isRequired,steps:a.array.isRequired,onNavigate:a.func.isRequired};const mt=()=>{const t=e.useContext(le),{options:s,mapComponent:o}=e.useContext(me);let i=0;s.startingQuestionId?(i=((e,t)=>{const s=(e,n)=>e?e["@id"]===t?n:se.asArray(e[te.HAS_SUBQUESTION]).findIndex((e,t)=>-1!==s(e,t)):-1;return e.findIndex((e,t)=>-1!==s(e,t))})(t.getFormQuestionsData(),s.startingQuestionId),-1===i&&(console.warn(`Question with id ${s.startingQuestionId} not found!`),i=0)):s.startingStep&&(i=s.startingStep<t.getFormQuestionsData().length?s.startingStep:0);const[r,a]=e.useState(i),[l,c]=e.useState(!1);n(()=>{if(s.startingQuestionId&&!l){const e=document.getElementById(s.startingQuestionId);e&&(e.scrollIntoView(),e.classList.add("text-danger"),c(!0))}});const u=()=>{const e=t.getFormQuestionsData();r!==e.length-1&&(e[r+1].visited=!0,a(e=>e+1))},p=()=>{0!==r&&a(e=>e-1)},m=e=>{const n=t.getFormQuestionsData();e===r||e>=n.length||e>r&&!n[e].visited&&!s.enableWizardStepSkip||a(e)};let d=null;t.getFormQuestionsData().length>1&&(d=(()=>{const n=t.getFormQuestionsData();/*#__PURE__*/return e.createElement(s.horizontalWizardNav?ut:pt,{currentStep:r,steps:n,onNavigate:m})})());const h=s.horizontalWizardNav;/*#__PURE__*/return e.createElement(C,{className:h?"":"flex-row p-3"},d,/*#__PURE__*/e.createElement("div",{className:h?"card-body p-3":d?"col-10 p-0 pl-3":"col-12 p-0"},(()=>{const n=t.getFormQuestionsData()[r];let i=o(n,ct);/*#__PURE__*/return e.createElement(i,{options:s,key:"step"+r,question:n,onNextStep:u,onPreviousStep:p,mapComponent:o,index:r,isFirstStep:0===r,isLastStep:r===t.getFormQuestionsData().length-1})})()))},dt=/*#__PURE__*/e.forwardRef((t,s)=>{const{options:n}=e.useContext(me);/*#__PURE__*/return e.createElement(D,Y({size:"xl",animation:!0},n.modalProps),/*#__PURE__*/e.createElement(D.Header,{closeButton:!0},/*#__PURE__*/e.createElement(D.Title,null,n.modalProps.title)),/*#__PURE__*/e.createElement(D.Body,{className:"overflow-hidden p-0"},t.children))});var ht;dt.propTypes={children:a.element.isRequired};class Et{}ht=Et,Et.updateQuestionValidation=(e,t,s,n)=>{if(t[te.HAS_ANSWER]){const o=it.createValidator(t,n)();o&&(e[s]=Object.assign({},t,o))}for(const t of e)ht.updateSubQuestionsValidation(t,n)},Et.updateSubQuestionsValidation=(e,t)=>{const s=se.asArray(e[te.HAS_SUBQUESTION]);for(let e=0;e<s.length;e++)ht.updateQuestionValidation(s,s[e],e,t)};class St extends e.Component{constructor(...t){super(...t),this.getFormData=()=>{const e=this.context.getData(),t=this.context.getFormQuestionsData();return ve.buildQuestionAnswerModel(e,t)},this.validateForm=()=>{const e=this.context.getFormQuestionsData();for(let t=0;t<e.length;t++)Et.updateQuestionValidation(e,e[t],t,"en");this.context.updateFormQuestionsData(null,e)},this.getFormQuestionsData=()=>this.context.getFormQuestionsData(),this.getFormSpecification=()=>{const e=this.context.getFormQuestionsData();return ie.getFormSpecification(e)},this.handleStepChange=(e,t,s)=>{this.context.updateFormQuestionsData(t,Object.assign({},e,s))},this.renderWizardlessForm=()=>{const t=this.context.getFormQuestionsData();/*#__PURE__*/return e.createElement(C,{className:"p-3"},t.map((e,t)=>this._mapQuestion(e,t)))}}_mapQuestion(t,s){let n=this.props.mapComponent(t,lt);/*#__PURE__*/return e.createElement(n,{key:t["@id"],question:t,onChange:(e,s)=>this.handleStepChange(t,e,s),index:s})}render(){const{modalView:t}=this.props,s=this.context.getFormQuestionsData();if(!s.length)/*#__PURE__*/return e.createElement(C,{className:"p-3 font-italic"},"There are no questions available...");const n=s.every(e=>!ie.isWizardStep(e));return t?/*#__PURE__*/e.createElement(dt,null,n?this.renderWizardlessForm():/*#__PURE__*/e.createElement(mt,null)):n?this.renderWizardlessForm():/*#__PURE__*/e.createElement(mt,null)}}St.contextType=le;const At=/*#__PURE__*/r((t,o)=>{const[i,r]=s(!0),[a,l]=s(null),[c,u]=s(null);if(n(()=>{(async()=>{const e=t.options.intl,[s,n]=await fe.constructForm(t.form,e);s.formQuestions.some(e=>ie.isWizardStep(e))&&(s.formQuestions[0].visited=!0),l(s),u(n),r(!1)})()},[t.form]),i)return t.loader||/*#__PURE__*/e.createElement(C,{className:"p-3 font-italic"},"Loading SForms...");const p=((e,t)=>(s,n)=>{if(!e)return n;for(let{component:n,mapRule:o}of e)if(o(s,t))return n;return n})(t.componentMapRules,c);/*#__PURE__*/return e.createElement(he,{components:t.components,componentsOptions:t.componentsOptions,mapComponent:p,options:t.options},/*#__PURE__*/e.createElement($,{fetchTypeAheadValues:t.fetchTypeAheadValues},/*#__PURE__*/e.createElement(ce,{data:c,formQuestions:a.formQuestions,isFormValid:t.isFormValid},/*#__PURE__*/e.createElement(St,{ref:o,modalView:t.options&&t.options.modalView,mapComponent:p}))))});At.propTypes={form:a.object.isRequired,options:a.object.isRequired,componentMapRules:a.array,components:a.object,componentsOptions:a.object,fetchTypeAheadValues:a.func,isFormValid:a.func,loader:a.element};var gt={"comment.form.placeholder":"Sem napište své komentáře (Ctrl+Enter pro potvrzení)","wizard.nav.tooltip":"Navigace na této kartě je zakázána, aby nedošlo k přehlédnutí důležitých otázek. K navigaci na tuto kartu použijte tlačítka související s formulářem."},_t={"comment.form.placeholder":"Write your comments here (Ctrl+Enter to confirm, Esc to cancel)","wizard.nav.tooltip":"Navigation to this tab is disabled to prevent overlooking important questions. Use form-related buttons to navigate to this tab instead."};const ft=/*#__PURE__*/e.createContext({}),vt=({children:e,locale:t=navigator.language})=>{let s=_t;return t===te.LANG.cs.locale&&(s=gt),q(ft.Provider,{value:{locale:t,lang:s},children:q(G,{locale:t,messages:s,children:e})})};export{ot as Answer,me as ConfigurationContext,te as Constants,le as FormQuestionsContext,ie as FormUtils,ze as HelpIcon,vt as IntlContextProvider,_e as JsonLdFramingUtils,ne as JsonLdObjectMap,oe as JsonLdObjectUtils,lt as Question,nt as QuestionStatic,ct as WizardStep,At as default};
1
+ import"core-js/modules/es.array.iterator.js";import"core-js/modules/es.promise.js";import"core-js/modules/web.dom-collections.iterator.js";import e,{useMemo as t,useState as s,useEffect as n,useContext as o,useRef as i,forwardRef as r}from"react";import a from"prop-types";import"core-js/modules/es.object.assign.js";import*as l from"jsonld";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.string.includes.js";import*as c from"jsonld-utils";import"core-js/modules/es.array.sort.js";import u from"@kbss-cvut/tsort";import p from"react-dom";import{Form as m,FormGroup as d,FormControl as h,OverlayTrigger as E,Tooltip as S,Col as A,Row as g,Button as _,Badge as f,Overlay as T,FormText as v,Popover as I,ListGroup as N,ListGroupItem as O,Card as C,Accordion as L,ButtonToolbar as R,Nav as w,NavItem as b,NavLink as y,Modal as D}from"react-bootstrap";import"core-js/modules/esnext.set.add-all.js";import"core-js/modules/esnext.set.delete-all.js";import"core-js/modules/esnext.set.difference.js";import"core-js/modules/esnext.set.every.js";import"core-js/modules/esnext.set.filter.js";import"core-js/modules/esnext.set.find.js";import"core-js/modules/esnext.set.intersection.js";import"core-js/modules/esnext.set.is-disjoint-from.js";import"core-js/modules/esnext.set.is-subset-of.js";import"core-js/modules/esnext.set.is-superset-of.js";import"core-js/modules/esnext.set.join.js";import"core-js/modules/esnext.set.map.js";import"core-js/modules/esnext.set.reduce.js";import"core-js/modules/esnext.set.some.js";import"core-js/modules/esnext.set.symmetric-difference.js";import"core-js/modules/esnext.set.union.js";import V from"react-datepicker";import{parse as M,format as H}from"date-fns";import U from"classnames";import x from"yasgui-yasqe";import"@triply/yasgui/build/yasgui.min.css";import P from"inputmask-core";import{IntelligentTreeSelect as q}from"intelligent-tree-select/lib/components/IntelligentTreeSelect.js";import"intelligent-tree-select/lib/styles.css";import"core-js/modules/es.regexp.to-string.js";import{jsx as F,jsxs as Q}from"react/jsx-runtime";import"core-js/modules/es.parse-int.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.replace.js";import j from"javascript-time-ago";import z from"javascript-time-ago/locale/en";import k from"javascript-time-ago/locale/cs";import{motion as B}from"framer-motion";import{Rings as W}from"react-loader-spinner";import"core-js/modules/es.string.trim.js";import{useIntl as G,IntlProvider as X}from"react-intl";import"core-js/modules/es.regexp.constructor.js";function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},Y.apply(this,arguments)}function K(e,t){if(null==e)return{};var s,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(s=i[n])>=0||(o[s]=e[s]);return o}class J{static log(e){console.log(e)}static warn(e){console.warn?console.warn(e):console.log("WARNING: "+e)}static error(e){console.error?console.error(e):console.log("ERROR: "+e)}}const Z=["children"],$=/*#__PURE__*/e.createContext({}),ee=s=>{let{children:n}=s,o=K(s,Z),i=[];const r=async(e,t)=>{const s=i[e];if(s&&s.length)return s;const n=await o.fetchTypeAheadValues(t);return n.length?l.frame(n,{},{}).then(t=>{const s=t["@graph"];return i.push(Object.assign({},s,{[e]:s})),s}):(J.warn(`No data received when loading options using id ${e}`),[])},a=e=>i[e]||[],c=t(()=>({loadFormOptions:r,getOptions:a}),[r,a]);/*#__PURE__*/return e.createElement($.Provider,Y({value:c},o),n)};var te;ee.propTypes={children:a.element.isRequired,fetchTypeAheadValues:a.func};class se{}te=se,se.COLUMN_COUNT=12,se.INPUT_LENGTH_THRESHOLD=50,se.DATETIME_NUMBER_FORMAT="x",se.FORM="http://onto.fel.cvut.cz/ontologies/documentation/form",se.HAS_SUBQUESTION="http://onto.fel.cvut.cz/ontologies/documentation/has_related_question",se.HAS_ANSWER="http://onto.fel.cvut.cz/ontologies/documentation/has_answer",se.HAS_OPTION="http://onto.fel.cvut.cz/ontologies/form/has-possible-value",se.HAS_OPTIONS_QUERY="http://onto.fel.cvut.cz/ontologies/form/has-possible-values-query",se.HAS_VALUE_TYPE="http://onto.fel.cvut.cz/ontologies/form/has-value-type",se.IS_DISABLED="http://onto.fel.cvut.cz/ontologies/aviation/form-376/is-disabled",se.INPUT_MASK="http://onto.fel.cvut.cz/ontologies/form/has-input-mask",se.LAYOUT_CLASS="http://onto.fel.cvut.cz/ontologies/form-layout/has-layout-class",se.LAYOUT={FORM:"form",QUESTION_SECTION:"section",WIZARD_STEP:"wizard-step",DATE:"date",TIME:"time",DATETIME:"datetime",TEXT:"text",TEXTAREA:"textarea",CHECKBOX:"checkbox",QUESTION_TYPEAHEAD:"type-ahead",MASKED_INPUT:"masked-input",ANSWERABLE:"answerable",SPARQL:"sparql",TURTLE:"ttl",DISABLED:"disabled",HIDDEN:"hidden",COLLAPSED:"collapsed",EMPHASISED:"emphasised",EMPHASISE_ON_RELEVANT:"emphasise-on-relevant",CATEGORY:["category-1","category-2","category-3","category-4","category-5"]},se.HAS_INITIAL_INPUT_LENGTH="http://onto.fel.cvut.cz/ontologies/form-layout/has-initial-input-length",se.VALUE_TYPE_CODE="code",se.VALUE_TYPE_TEXT="text",se.GENERATED_ROW_SIZE=1,se.HAS_QUESTION_ORIGIN="http://onto.fel.cvut.cz/ontologies/form/has-question-origin",se.HAS_ANSWER_ORIGIN="http://onto.fel.cvut.cz/ontologies/form/has-answer-origin",se.HAS_DATA_VALUE="http://onto.fel.cvut.cz/ontologies/documentation/has_data_value",se.HAS_OBJECT_VALUE="http://onto.fel.cvut.cz/ontologies/documentation/has_object_value",se.HELP_DESCRIPTION="http://purl.org/dc/elements/1.1/description",se.SOURCE="http://purl.org/dc/elements/1.1/source",se.XSD={MAX_EXCLUSIVE:"http://www.w3.org/2001/XMLSchema#maxExclusive",MAX_INCLUSIVE:"http://www.w3.org/2001/XMLSchema#maxInclusive",MIN_EXCLUSIVE:"http://www.w3.org/2001/XMLSchema#minExclusive",MIN_INCLUSIVE:"http://www.w3.org/2001/XMLSchema#minInclusive",INT:"http://www.w3.org/2001/XMLSchema#int",INTEGER:"http://www.w3.org/2001/XMLSchema#integer",NEGATIVE_INTEGER:"http://www.w3.org/2001/XMLSchema#negativeInteger",NON_NEGATIVE_INTEGER:"http://www.w3.org/2001/XMLSchema#nonNegativeInteger",NON_POSITIVE_INTEGER:"http://www.w3.org/2001/XMLSchema#nonPositiveInteger",POSITIVE_INTEGER:"http://www.w3.org/2001/XMLSchema#positiveInteger",FLOAT:"http://www.w3.org/2001/XMLSchema#float",POSITIVE_FLOAT:"http://www.w3.org/2001/XMLSchema#positiveFloat",NEGATIVE_FLOAT:"http://www.w3.org/2001/XMLSchema#negativeFloat",BOOLEAN:"http://www.w3.org/2001/XMLSchema#boolean"},se.STEP="http://onto.fel.cvut.cz/ontologies/form/step",se.PATTERN="http://onto.fel.cvut.cz/ontologies/form/pattern",se.ACCEPTS_ANSWER_VALUE="http://onto.fel.cvut.cz/ontologies/form/accepts-answer-value",se.ACCEPTS="http://onto.fel.cvut.cz/ontologies/form/accepts",se.HAS_DATATYPE="http://onto.fel.cvut.cz/ontologies/form/has-datatype",se.HAS_LAYOUT_CLASS="http://onto.fel.cvut.cz/ontologies/form/has-layout-class",se.HAS_POSSIBLE_VALUES_QUERY="http://onto.fel.cvut.cz/ontologies/form/has-possible-values-query",se.HAS_REQUIRED_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-required-value",se.HAS_TESTED_QUESTION="http://onto.fel.cvut.cz/ontologies/form/has-tested-question",se.HAS_TESTED_FORM="http://onto.fel.cvut.cz/ontologies/form/has-tested-form",se.HAS_UNIT="http://onto.fel.cvut.cz/ontologies/form/has-unit",se.HAS_VALID_ANSWER="http://onto.fel.cvut.cz/ontologies/form/has-valid-answer",se.IS_RELEVANT_IF="http://onto.fel.cvut.cz/ontologies/form/is-relevant-if",se.ACCEPTS_VALIDATION_VALUE="http://onto.fel.cvut.cz/ontologies/form/accepts-validation-value",se.HAS_VALIDATION_MESSAGE="http://onto.fel.cvut.cz/ontologies/form/has-validation-message",se.NEGATIVE_CONDITION="http://onto.fel.cvut.cz/ontologies/form/negative-condition",se.REQUIRES_ANSWER="http://onto.fel.cvut.cz/ontologies/form/requires-answer",se.USED_ONLY_FOR_COMPLETENESS="http://onto.fel.cvut.cz/ontologies/form/used-only-for-completeness",se.REQUIRES_ANSWER_DESCRIPTION_IF="http://onto.fel.cvut.cz/ontologies/form/requires-answer-description-if",se.REQUIRES_ANSWER_IF="http://onto.fel.cvut.cz/ontologies/form/requires-answer-if",se.HAS_PRECEDING_QUESTION="http://onto.fel.cvut.cz/ontologies/form/has-preceding-question",se.HAS_PRECEDING_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-preceding-value",se.HAS_MEDIA_CONTENT="http://onto.fel.cvut.cz/ontologies/form/has-media-content",se.CONDITION="http://onto.fel.cvut.cz/ontologies/form/condition",se.OR_CONDITION="http://onto.fel.cvut.cz/ontologies/form/or-condition",se.HAS_SUB_CONDITION="http://onto.fel.cvut.cz/ontologies/form/has-sub-condition",se.HAS_PATTERN="http://onto.fel.cvut.cz/ontologies/form-lt/has-pattern",se.HAS_DECLARED_PREFIX="http://onto.fel.cvut.cz/ontologies/form-spin/has-declared-prefix",se.PREFIX="http://www.w3.org/ns/shacl#prefix",se.NAMESPACE="http://www.w3.org/ns/shacl#namespace",se.HAS_COMMENT="http://onto.fel.cvut.cz/ontologies/form/has-comment",se.HAS_COMMENT_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-comment-value",se.HAS_AUTHOR="http://onto.fel.cvut.cz/ontologies/form/has-author",se.HAS_TIMESTAMP="http://onto.fel.cvut.cz/ontologies/form/has-timestamp",se.TIME_FORMAT="http://onto.fel.cvut.cz/ontologies/form/time-format",se.DATE_FORMAT="http://onto.fel.cvut.cz/ontologies/form/date-format",se.DATETIME_FORMAT="http://onto.fel.cvut.cz/ontologies/form/datetime-format",se.NOT_ANSWERED_QUESTION="http://onto.fel.cvut.cz/ontologies/form/not-answered-question",se.ANSWERED_QUESTION="http://onto.fel.cvut.cz/ontologies/form/answered-question",se.HAS_VALIDATION_SEVERITY="http://onto.fel.cvut.cz/ontologies/form/has-validation-severity",se.RDFS_LABEL=c.RDFS_LABEL,se.RDFS_COMMENT=c.RDFS_COMMENT,se.DEFAULT_HAS_CHILD=c.DEFAULT_HAS_CHILD,se.BROADER="http://www.w3.org/2004/02/skos/core#broader",se.HAS_NON_SELECTABLE_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-non-selectable-value",se.PROVIDES_DEREFERENCEABLE_ANSWER_VALUES="http://onto.fel.cvut.cz/ontologies/form/provides-dereferenceable-answer-values",se.ICONS={QUESTION_COMMENTS:"questionComments",QUESTION_HELP:"questionHelp",QUESTION_LINK:"questionLink"},se.ICON_BEHAVIOR={ENABLE:"enable",DISABLE:"disable",ON_HOVER:"onHover"},se.DEFAULT_OPTIONS={icons:[{id:te.ICONS.QUESTION_HELP,behavior:te.ICON_BEHAVIOR.ENABLE},{id:te.ICONS.QUESTION_COMMENTS,behavior:te.ICON_BEHAVIOR.ON_HOVER},{id:te.ICONS.QUESTION_LINK,behavior:te.ICON_BEHAVIOR.ON_HOVER}]},se.LANG={cs:{locale:"cs",label:"Čestina"},en:{locale:"en",label:"English"}},se.VALIDATION={SEVERITY:{ERROR:"error",WARNING:"warning"},DEFAULT_MESSAGE:{REQUIRED:"This field is required.",REQUIRED_ONLY_FOR_COMPLETENESS:"This field is required to complete the form.",INVALID:"This field is invalid.",CHECK:"This field must be checked.",LOWER_OR_EQUAL:"This field should be a number equal or lower to ",GREATER_OR_EQUAL:"This field must be greater or equal to "},CLASSNAME:{ERROR:"is-invalid",WARNING:"is-warning"}};class ne{static getStringHash(e){let t=0;const s=e?e.length:0;if(0===s)return t;for(let n=0;n<s;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return t}static asArray(e){return e?e.constructor===Array?e:[e]:[]}static findQuestionById(e,t,s,n,o){if(s&&t["@id"]===e)return t;const i=ne.asArray(t[se.HAS_SUBQUESTION]);if(n)for(let t of i){let s=ne.findQuestionById(e,t,!0,!1,!1);if(s)return s}if(o)for(let t of i){let s=ne.findQuestionById(e,t,!1,!0,!0);if(s)return s}return null}static findKeyInObjects(e,t){for(let s=0;s<e.length;s++)for(let n=0;n<t.length;n++)if(e[s].hasOwnProperty(t[n]))return t[n];return null}}class oe{static putObject(e,t){oe.objectMap[e]=t}static getObject(e){return oe.objectMap[e]}}oe.objectMap={};class ie{static getFirstObject(e,t){const s=l.getValues(e,t);return 0===s.length?null:s[0]}static compareValues(e,t){return t="object"==typeof t?t:{"@value":t},!!((e="object"==typeof e?e:{"@value":e})&&e["@value"]&&t&&t["@value"]&&("string"==typeof e["@value"]?e["@value"]:JSON.stringify(e["@value"]))===("string"==typeof t["@value"]?t["@value"]:JSON.stringify(t["@value"])))||l.compareValues(e,t)}static toplogicalSort(e,t){let s;do{s=!1;for(let n=0;n<e.length;n++)for(let o=n;o<e.length;o++)if(e[n][t]&&("object"==typeof e[n][t]?e[n][t]["@id"]:e[n][t])===e[o]["@id"]){const t=e[n];e[n]=e[o],e[o]=t,s=!0;break}}while(s);return e}static orderPreservingToplogicalSort(e,t){const s=u(),n={};for(let o=0;o<e.length;o++){let i=e[o]["@id"];s.add(i),n[i]=e[o],ne.asArray(e[o][t]).map(e=>"object"==typeof e?e["@id"]:e).map(e=>[e,i]).forEach(e=>s.add(e))}let o=s.sort();for(let t=0;t<o.length;t++)e[t]=n[o[t]];return e}static getCompareLocalizedLabelFunction(e){return(t,s)=>{const n=c.getLocalized(t[c.RDFS_LABEL],e),o=c.getLocalized(s[c.RDFS_LABEL],e);return n<o?-1:n>o?1:0}}static orderByLocalizedLabels(e,t){return e.sort(ie.getCompareLocalizedLabelFunction(t))}static checkId(e,t){if(void 0!==e)return e.constructor===Array?!!e.find(e=>e["@id"]===t):e.constructor===Object?e["@id"]===t:void 0}}class re{static isForm(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.FORM)}static isWizardStep(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.WIZARD_STEP)}static isSection(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.QUESTION_SECTION)}static isAnswerable(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.ANSWERABLE)}static isTypeahead(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.QUESTION_TYPEAHEAD)}static getPossibleValuesQuery(e){return c.getJsonAttValue(e,se.HAS_OPTIONS_QUERY)}static isDisabled(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.DISABLED)}static isHidden(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.HIDDEN)}static isTextarea(e,t){return t&&t.length>se.INPUT_LENGTH_THRESHOLD&&!re.isTypeahead(e)||c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.TEXTAREA)}static isText(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.TEXT)}static isCalendar(e){return re.isDate(e)||re.isTime(e)||re.isDateTime(e)}static isDate(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.DATE)}static isTime(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.TIME)}static isDateTime(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.DATETIME)}static isCheckbox(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.CHECKBOX)}static isMaskedInput(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.MASKED_INPUT)}static isSparqlInput(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.SPARQL)}static isTurtleInput(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.TURTLE)}static isCollapsed(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.COLLAPSED)}static isEmphasised(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.EMPHASISED)}static getCategory(e){return se.LAYOUT.CATEGORY.find(t=>c.hasValue(e,se.LAYOUT_CLASS,t))}static resolveValue(e){return e?e[se.HAS_OBJECT_VALUE]?e[se.HAS_OBJECT_VALUE]["@id"]:c.getJsonAttValue(e,se.HAS_DATA_VALUE):null}static resolveValueObject(e){return e?e[se.HAS_OBJECT_VALUE]?ne.asArray(e[se.HAS_OBJECT_VALUE])[0]:e[se.HAS_DATA_VALUE]?ne.asArray(e[se.HAS_DATA_VALUE])[0]:null:null}static isRelevant(e){if(!e[se.IS_RELEVANT_IF])return!0;for(let t of ne.asArray(e[se.IS_RELEVANT_IF]))if(!re.testCondition(t))return!1;return!0}static hasValidationLogic(e){return!!(e[se.REQUIRES_ANSWER]||e[se.REQUIRES_ANSWER_IF]||e[se.PATTERN]||this.containsXSDProperty(e))}static isValid(e){if(!1===e[se.HAS_VALID_ANSWER])return!1;for(const t of ne.asArray(e[se.HAS_SUBQUESTION]))if(!1===this.isValid(t))return!1;return!0}static testOrCondition(e){const t=e[se.HAS_SUB_CONDITION];t||console.warn("Or condition does not have any sub-condition !");for(const e of this._getMappedObjectsArray(t))if(this.testCondition(e))return!0;return!1}static testCondition(e){const t=e[se.ACCEPTS_VALIDATION_VALUE],s=e[se.ACCEPTS_ANSWER_VALUE],n=e[se.ACCEPTS],o=e[se.HAS_TESTED_QUESTION];let i;if(e[se.HAS_SUB_CONDITION])return this.testOrCondition(e);if(t&&s&&console.warn("Support for validation and requirement constraints at same time is not implemented !"),n&&o){const e=ne.asArray(n);if(1!==e.length&&console.warn("Support for multiple accepts values is not implemented !"),e[0]["@id"]===se.ANSWERED_QUESTION){(s||t)&&console.warn("Support for accepted answer/validations values is not implemented !");for(const e of this._getMappedObjectsArray(o))if(!this.hasAnswer(e))return!1;return!0}console.warn("No support to accept question of type "+e[0]["@id"]+" !")}if(t&&o){const e=ne.asArray(t);(1!==e.length||!0!==e[0]&&"true"!==e[0])&&console.warn('Validation values other than "true" are not implemented !');for(const e of ne.asArray(o)){if(i=oe.getObject(e["@id"]),void 0===i)return console.warn("Questions is not loaded in an object map."),!0;if(!1===this.isValid(i))return!1}return!0}if(s&&o){i=oe.getObject(o["@id"]);for(const e of ne.asArray(s)){if(!i)return console.warn("Question is not defined."),!0;if(!i.hasOwnProperty(se.HAS_ANSWER))return!1;const t=l.getValues(i,se.HAS_ANSWER);if(0===t.length)return!1;const s=re.resolveValueObject(t[0]);if(s&&e&&s.hasOwnProperty("@value")&&e.hasOwnProperty("@id")&&s["@value"]==e["@id"])return!0;if(ie.compareValues(s,e))return!0}}return!1}static _getMappedObjectsArray(e,t){return ne.asArray(e).map(e=>{const s=oe.getObject(e["@id"]);return void 0===s?(console.warn((t||"Object")+' "'+e["@id"]+'" is not loaded in an object map.'),null):s}).filter(function(e){return null!==e})}static hasAnswer(e){if(!e)return!1;if(e.hasOwnProperty(se.HAS_ANSWER)){const t=l.getValues(e,se.HAS_ANSWER);if(t.length){const e=re.resolveValueObject(t[0]);if(e&&(e["@value"]||e["@id"]))return!0}}for(const t of ne.asArray(e[se.HAS_SUBQUESTION]))if(re.hasAnswer(t))return!0;return!1}static getAnswerValue(e){if(!e)return null;if(e.hasOwnProperty(se.HAS_ANSWER)){const t=l.getValues(e,se.HAS_ANSWER);if(t.length){const e=re.resolveValueObject(t[0]);if(e&&(e["@value"]||e["@id"]))return e["@value"]||e["@id"]}}for(const t of ne.asArray(e[se.HAS_SUBQUESTION])){const e=re.getAnswerValue(t);if(e)return e}return null}static resolveDateTimeFormat(e,t,s){const n="number"==typeof t,o=re.isDate(e),i=re.isTime(e),r=re.isDateTime(e);return n?se.DATETIME_NUMBER_FORMAT:o?e[se.DATE_FORMAT]||s.dateFormat:i?e[se.TIME_FORMAT]||s.timeFormat:r?e[se.DATETIME_FORMAT]||s.dateTimeFormat:null}static dfsTraverseQuestionTree(e,t,s=(()=>{})){function n(e){t(e),ne.asArray(e[se.HAS_SUBQUESTION]).forEach(e=>{n(e)}),s(e)}e.forEach(e=>{n(e)})}static getFormSpecification(e){let t=-1;const s="..";let n="";return re.dfsTraverseQuestionTree(e,function(e){t+=1;const o=" ".repeat(t);let i="";e[se.REQUIRES_ANSWER]&&!e[se.USED_ONLY_FOR_COMPLETENESS]?i=o+s+"required: "+e[se.REQUIRES_ANSWER]+"\n":e[se.USED_ONLY_FOR_COMPLETENESS]&&(i=o+s+"required only for completeness: "+e[se.USED_ONLY_FOR_COMPLETENESS]+"\n"),n+=o+e["http://www.w3.org/2000/01/rdf-schema#label"]+"\n",n+=e[se.HELP_DESCRIPTION]?o+s+"description: "+e[se.HELP_DESCRIPTION]+"\n":"",n+=i,n+=e[se.PATTERN]?o+s+"pattern: "+e[se.PATTERN]+"\n":"",n+=e[se.INPUT_MASK]?o+s+"mask: "+e[se.INPUT_MASK]+"\n":"",n+=e[se.HAS_VALIDATION_MESSAGE]?o+s+"validation-message: "+e[se.HAS_VALIDATION_MESSAGE]+"\n":"",n+="\n"},function(){t-=1}),n}static containsXSDProperty(e){const t=Object.keys(e),s=Object.values(se.XSD);for(const e of s)if(t.includes(e))return!0;return!1}static getInputMask(e){if(e[se.INPUT_MASK])return e[se.INPUT_MASK]}}const ae={},le=[],ce=/*#__PURE__*/e.createContext({}),ue=o=>{const[i,r]=s(o.data||ae),[a,l]=s(o.formQuestions||le);n(()=>{if(o.isFormValid){const e=re.isValid(i);o.isFormValid(e)}},[]),n(()=>{r(o.data||ae)},[a]);const c=e=>{e&&r(Object.assign({},i,e))},u=(e,t)=>{if(!(!t||e<0||e>=a.length)){if("object"==typeof t){const s=[...a];s[e]=Object.assign({},s[e],t),l(s)}if(Array.isArray(t)&&l(t),o.isFormValid){const e=re.isValid(i);o.isFormValid(e)}}},p=()=>i,m=e=>null==e?a:a[e],d=t(()=>({updateData:c,updateFormQuestionsData:u,getData:p,getFormQuestionsData:m}),[m,p]);/*#__PURE__*/return e.createElement(ce.Provider,Y({value:d},o),o.children)};ue.propTypes={children:a.element.isRequired,data:a.object.isRequired,formQuestions:a.array.isRequired,isFormValid:a.func};class pe extends e.Component{constructor(e){super(e),this.state={cursorPosition:0}}focus(){p.findDOMNode(this.input).focus()}getInputDOMNode(){return p.findDOMNode(this.input)}componentDidUpdate(e,t,s){(this.fieldDidShrink(e)||this.fieldDidExpand(e))&&this.updateFieldCursorPosition()}fieldDidExpand(e){return"textarea"===this.props.type&&"textarea"!==e.type}fieldDidShrink(e){return"text"===this.props.type&&"text"!==e.type}updateFieldCursorPosition(){this.focus(),this.getInputDOMNode().setSelectionRange(this.state.cursorPosition,this.state.cursorPosition)}saveCursorPosition(e){this.props.onChange(e),this.setState({cursorPosition:e.target.selectionStart})}render(){switch(this.props.type){case"radio":return this._renderRadio();case"checkbox":return this._renderCheckbox();case"select":return this._renderSelect();case"textarea":return this._renderTextArea();default:return this._renderInput()}}_renderCheckbox(){/*#__PURE__*/return e.createElement(m.Group,{size:"small",controlId:Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)},/*#__PURE__*/e.createElement(m.Check,Y({type:"checkbox",ref:e=>this.input=e},this.props,{label:this.props.label,className:this.props.validation.classname})),this.props.validation.message)}_renderRadio(){/*#__PURE__*/return e.createElement(d,{size:"small"},/*#__PURE__*/e.createElement(m.Check,Y({type:"radio",ref:e=>this.input=e},this.props,{label:this.props.label,className:this.props.validation.classname})),this.props.validation.message)}_renderSelect(){/*#__PURE__*/return e.createElement(d,{size:"small"},this._renderLabel(),/*#__PURE__*/e.createElement(h,Y({as:"select",className:this.props.validation.classname,ref:e=>this.input=e},this.props),this.props.children),this.props.validation.message)}_renderLabel(){return this.props.label?/*#__PURE__*/e.createElement(m.Label,null,this.props.label):null}_renderTextArea(){/*#__PURE__*/return e.createElement(d,{size:"small"},this._renderLabel(),/*#__PURE__*/e.createElement(h,Y({ref:e=>this.input=e,as:"textarea"},this.props,{className:this.props.validation.classname,onChange:e=>this.saveCursorPosition(e)})),this.props.validation.message)}_renderInput(){/*#__PURE__*/return e.createElement(d,{size:"small"},this._renderLabel(),/*#__PURE__*/e.createElement(h,Y({className:this.props.validation.classname,ref:e=>this.input=e,as:"input",placeholder:this.props.placeholder},this.props,{onChange:e=>this.saveCursorPosition(e)})),this.props.validation.message)}}pe.propTypes={type:a.string,label:a.object,value:a.any,onChange:a.func,help:a.string,validation:a.object,placeholder:a.string},pe.defaultProps={type:"text"};const me=["children"],de=/*#__PURE__*/e.createContext({}),he={components:{inputComponent:pe},componentsOptions:{dateTimeAnswer:{dateFormat:"yyyy-MM-dd",timeFormat:"HH:mm",dateTimeFormat:"yyyy-MM-dd HH:mm:ss"},readOnly:!1},options:{intl:{locale:"en"},i18n:{"wizard.next":"Next","wizard.previous":"Previous","section.collapse":"Collapse","section.expand":"Expand"},modalView:!1,modalProps:{},horizontalWizardNav:!0,wizardStepButtons:!0,enableWizardStepSkip:!0,startingStep:0}},Ee=s=>{let{children:n}=s,o=K(s,me);const i=t(()=>({inputComponent:o.components&&o.components.inputComponent||he.components.inputComponent,componentsOptions:Object.assign({},he.componentsOptions,o.componentsOptions),options:Object.assign({},he.options,o.options),mapComponent:o.mapComponent}),[o]);/*#__PURE__*/return e.createElement(de.Provider,{value:i},n)};Ee.propTypes={children:a.element.isRequired,components:a.object,mapComponent:a.func,options:a.object};var Se,Ae={"@graph":[{"@type":"http://onto.fel.cvut.cz/ontologies/documentation/question","http://onto.fel.cvut.cz/ontologies/form-layout/has-layout-class":"form","http://onto.fel.cvut.cz/ontologies/documentation/has_related_question":[{"http://onto.fel.cvut.cz/ontologies/form-layout/has-layout-class":["wizard-step","section"],"http://www.w3.org/2000/01/rdf-schema#label":[{"@language":"en","@value":"Description"},{"@language":"cs","@value":"Popis"}],"http://onto.fel.cvut.cz/ontologies/documentation/has_related_question":[{"@type":"http://onto.fel.cvut.cz/ontologies/documentation/question","http://onto.fel.cvut.cz/ontologies/form-layout/has-layout-class":["textarea"],"http://www.w3.org/2000/01/rdf-schema#label":[{"@language":"en","@value":"Description"},{"@language":"cs","@value":"Popis"}],"http://onto.fel.cvut.cz/ontologies/documentation/has_answer":{"@type":"http://onto.fel.cvut.cz/ontologies/documentation/answer","http://onto.fel.cvut.cz/ontologies/documentation/has_data_value":""}}]}]}]};class ge{static generateForm(){return JSON.parse(JSON.stringify(Ae))}}const _e={root:{[se.HAS_LAYOUT_CLASS]:se.FORM},expandProperties:[se.HAS_SUBQUESTION,se.IS_RELEVANT_IF,se.HAS_ANSWER,se.HAS_DECLARED_PREFIX,se.HAS_OPTION,se.HAS_COMMENT]};class fe{static customFrame(e,t,s){if(arguments.length<2)return l.nextTick(function(){s(new TypeError("Could not frame, too few arguments."))});null===t&&(t=_e),l.flatten(e,null,null,(e,t)=>{})}static expandStructure(e){let t;const s={};e["@graph"].forEach(e=>{s[e["@id"]]=e,re.isForm(e)&&(t=e)});try{this._expandGraph(t,_e,s)}catch(e){console.error("Error '"+e+"' occured, while trying to apply frame-ing with custom shape.")}return s}static _expandGraph(e,t,s){let n,o,i;t.expandProperties.forEach(r=>{if(e.hasOwnProperty(r)){e[r]=ne.asArray(e[r]),n=e[r];for(let e=0;e<n.length;e++)i=this._getId(n[e]),o=s[i],void 0!==o?(n[e]=o,this._expandGraph(o,t,s)):console.warn("object with @id "+i+" was not defined in input data.")}})}static _getId(e){return"string"==typeof e?e:e["@id"]}}Se=fe,fe.compressStructure=e=>{let t=[],s=new Set;return t=Se._compressGraph(e,t,s),t=t.sort((e,t)=>e["@id"]&&t["@id"]?e["@id"].localeCompare(t["@id"]):0),t},fe._compressGraph=(e,t,s)=>(s.has(e["@id"])||(t.push(e),s.add(e["@id"])),_e.expandProperties.forEach(n=>{if(e.hasOwnProperty(n)){const o=e[n];for(let i=0;i<o.length;i++){const r=o[i];void 0!==r&&(o[i]=r,t=Se._compressGraph(r,t,s),e[n][i]={"@id":r["@id"]})}}}),t);class Te{static constructDefaultForm(e){const t=ge.generateForm();return Te._constructFormQuestions(t,e)}static async constructForm(e,t){let s,n;return l.flatten(e,{}).then(e=>{try{const[o,i]=Te._constructFormQuestions(e,t);n=i,s={formQuestions:o}}catch(e){console.error("Error while constructing form questions from the provided structure:",e)}if(!n){const[e,o]=Te.constructDefaultForm(t);n=o,s={formQuestions:e}}return[s,n]}).catch(e=>(console.error("Failed to flatten the JSON-LD structure. Expected to transform a nested JSON-LD document into a flattened array of node objects:",e),[s,n]))}static _constructFormQuestions(e,t){let s,n,o,i=[];if(void 0!==e["@graph"][0]["@id"]?(o=fe.expandStructure(e),Object.keys(o).map(e=>{oe.putObject(e,o[e])})):console.warn("default form is constructed."),s=e["@graph"].find(e=>re.isForm(e)),n=s[se.HAS_SUBQUESTION],!n)throw J.error("Could not find any questions in the received data."),"No questions in the form";return i=n.filter(e=>!(!re.isWizardStep(e)||re.isHidden(e))||(J.warn("Item is not a wizard step: "+e),!1)),i.length||(J.log("Could not find any wizard steps in the received data. Building form without steps"),s[se.HAS_SUBQUESTION].forEach(e=>i.push(e))),i.sort(ie.getCompareLocalizedLabelFunction(t)),ie.orderPreservingToplogicalSort(i,se.HAS_PRECEDING_QUESTION),[i,{root:s}]}}class ve{static buildQuestionAnswerModel(e,t){const s={subQuestions:[]};let n;if(e&&(s.uri=e.root["@id"],s.origin=c.getJsonAttValue(e.root,se.HAS_QUESTION_ORIGIN,"@id")),t)for(let e=0;e<t.length;e++)n=ve.processQuestionAnswerHierarchy(t[e]),n&&s.subQuestions.push(n);return s}static processQuestionAnswerHierarchy(e){return e?ve._processQuestion(e):null}static _processQuestion(e){const t={};if(t.uri=e["@id"],t.origin=c.getJsonAttValue(e,se.HAS_QUESTION_ORIGIN,"@id"),e[se.HAS_SUBQUESTION]){t.subQuestions=[];for(let s=0;s<e[se.HAS_SUBQUESTION].length;s++)t.subQuestions.push(ve._processQuestion(e[se.HAS_SUBQUESTION][s]))}if(e[se.HAS_ANSWER]){t.answers=[],Array.isArray(e[se.HAS_ANSWER])||(e[se.HAS_ANSWER]=[e[se.HAS_ANSWER]]);for(let s=0;s<e[se.HAS_ANSWER].length;s++)t.answers.push(ve.processAnswer(e[se.HAS_ANSWER][s]))}if(e[se.HAS_COMMENT]){t.comments=[],Array.isArray(e[se.HAS_COMMENT])||(e[se.HAS_COMMENT]=[e[se.HAS_COMMENT]]);for(let s=0;s<e[se.HAS_COMMENT].length;s++)t.comments.push(ve.processComment(e[se.HAS_COMMENT][s]))}return t}static processComment(e){const t={};return t.author=c.getJsonAttValue(e,se.HAS_AUTHOR,"@id"),t.value=c.getJsonAttValue(e,se.HAS_COMMENT_VALUE),t.timestamp=c.getJsonAttValue(e,se.HAS_TIMESTAMP,"@id"),t}static processAnswer(e){const t={};return t.uri=e["@id"],t.origin=c.getJsonAttValue(e,se.HAS_ANSWER_ORIGIN,"@id"),e[se.HAS_OBJECT_VALUE]?t.codeValue=c.getJsonAttValue(e,se.HAS_OBJECT_VALUE,"@id"):t.textValue=c.getJsonAttValue(e,se.HAS_DATA_VALUE),t}static generateAnswer(e){const t={};return t[se.HAS_DATA_VALUE]="",t}}const Ie=t=>{const{inputComponent:s,componentsOptions:n}=o(de);/*#__PURE__*/return e.createElement(s,{type:"checkbox",label:t.label,title:t.title,checked:!0===t.value||"true"===t.value,validation:t.validation,onChange:e=>{t.onChange(e.target.checked)},disabled:n.readOnly||re.isDisabled(t.question)})};Ie.propTypes={question:a.object.isRequired,label:a.object.isRequired,title:a.string,value:a.oneOfType([a.string,a.bool]),onChange:a.func.isRequired,mouseHover:a.bool,validation:a.object};const Ne=t=>{const{componentsOptions:i}=o(de),[r,a]=s(null);n(()=>{t.value&&a(new Date(M(t.value,p,new Date)))},[]);const l=re.resolveDateTimeFormat(t.question,t.value,i.dateTimeAnswer),c=re.isDate(t.question),u=re.isTime(t.question),p="x"===l?i.dateTimeAnswer.dateTimeFormat:l;/*#__PURE__*/return e.createElement(d,{size:"small"},/*#__PURE__*/e.createElement(m.Label,{className:"w-100"},t.label),/*#__PURE__*/e.createElement(V,{selected:r,placeholderText:p,onChange:e=>{a(e),e||t.onChange(""),t.onChange(l===se.DATETIME_NUMBER_FORMAT?Number(e):H(e,l))},showTimeSelect:!c,showTimeSelectOnly:u,timeFormat:"HH:mm",timeIntervals:1,timeCaption:"Time",dateFormat:p,className:U("form-control",t.validation.classname),disabled:i.readOnly||re.isDisabled(t.question)}),t.validation.message)};Ne.propTypes={question:a.object.isRequired,label:a.object.isRequired,title:a.string,value:a.oneOfType([a.string,a.number]),onChange:a.func.isRequired,validation:a.object};const Oe=[se.XSD.INT,se.XSD.INTEGER,se.XSD.NON_NEGATIVE_INTEGER,se.XSD.NON_POSITIVE_INTEGER,se.XSD.NEGATIVE_INTEGER,se.XSD.POSITIVE_INTEGER,se.XSD.FLOAT,se.XSD.POSITIVE_FLOAT,se.XSD.NEGATIVE_FLOAT],Ce={};Ce[se.XSD.NON_NEGATIVE_INTEGER]={min:0},Ce[se.XSD.NON_POSITIVE_INTEGER]={max:0},Ce[se.XSD.NEGATIVE_INTEGER]={max:-1},Ce[se.XSD.POSITIVE_INTEGER]={min:1};const Le={"string-2":"prefixed",atom:"var"};class Re{static _resolveInputType(e,t){return re.isSparqlInput(e)||re.isTurtleInput(e)||re.isTextarea(e,t)?"textarea":Re._isNumeric(e)?"number":"text"}static _isNumeric(e){for(let t=0,s=Oe.length;t<s;t++)if(c.hasValue(e,se.HAS_DATATYPE,Oe[t]))return!0;return!1}static resolveInputProperties(e,t,s){let n={};switch(n.type=Re._resolveInputType(e,t),n.type){case"textarea":n.rows=5;break;case"number":n=Object.assign({},n,Re._resolveNumberRestrictions(e),this._resolveStepRestriction(e))}return n.disabled=s.readOnly||re.isDisabled(e),n}static _resolveStepRestriction(e){let t={};return void 0!==e[se.STEP]&&(t.step=c.getJsonAttValue(e,se.STEP)),t}static _resolveNumberRestrictions(e){let t={};return Object.getOwnPropertyNames(Ce).forEach(s=>{c.hasValue(e,se.HAS_DATATYPE,s)&&(t=Object.assign({},t,Ce[s]))}),void 0!==e[se.XSD.MIN_INCLUSIVE]&&(t.min=e[se.XSD.MIN_INCLUSIVE]),void 0!==e[se.XSD.MIN_EXCLUSIVE]&&(t.min=e[se.XSD.MIN_EXCLUSIVE]+1),void 0!==e[se.XSD.MAX_EXCLUSIVE]&&(t.max=e[se.XSD.MAX_EXCLUSIVE]-1),void 0!==e[se.XSD.MAX_INCLUSIVE]&&(t.max=e[se.XSD.MAX_INCLUSIVE]),t}static _preventCharacterInput(e,t){"number"!==Re._resolveInputType(t)||e.key>="0"&&e.key<="9"||["Backspace","Delete","ArrowLeft","ArrowRight","-","Minus","NumpadSubtract",".","Period"].includes(e.key)||e.preventDefault()}}const we=t=>{const{inputComponent:s,componentsOptions:n}=o(de),i=t.question,r=t.answer;let a=t.value;return r[se.HAS_OBJECT_VALUE]&&r[se.HAS_OBJECT_VALUE][c.RDFS_LABEL]&&(a=c.getJsonAttValue(r[se.HAS_OBJECT_VALUE],c.RDFS_LABEL)),/*#__PURE__*/e.createElement(s,Object.assign({},Re.resolveInputProperties(i,a,n),{validation:t.validation,label:t.label,title:t.title,value:null==a?"":a,placeholder:re.getInputMask(i),onKeyPress:e=>Re._preventCharacterInput(e,i),onChange:e=>{t.onChange(e.target.value),(t.sparql||t.turtle)&&(void 0).hide()},onFocus:e=>{if(t.sparql){const s=x.fromTextArea(e.target);s.setValue(a),s.on("change",()=>{t.onChange(s.getValue())}),x.Autocompleters.prefixes.appendPrefixIfNeeded=function(e,s){if(!e.autocompleters.getTrie(s))return;if(!e.options.autocompleters||-1===e.options.autocompleters.indexOf(s))return;const n=e.getCursor(),o=e.getTokenAt(n);if("prefixed"===Le[o.type]){const i=o.string.indexOf(":");if(-1!==i){const r=e.getPreviousNonWsToken(n.line,o).string.toUpperCase(),a=e.getTokenAt({line:n.line,ch:o.start});if("PREFIX"!==r&&("ws"===a.type||null==a.type)){const n=o.string.substring(0,i+1);if(null==e.getPrefixesFromQuery()[n.slice(0,-1)])if(t.question[se.HAS_DECLARED_PREFIX]&&t.question[se.HAS_DECLARED_PREFIX].filter(e=>e[se.PREFIX]===n.slice(0,-1)).length){const s=t.question[se.HAS_DECLARED_PREFIX].filter(e=>e[se.PREFIX]===n.slice(0,-1)),o={};o[s[0][se.PREFIX]]=s[0][se.NAMESPACE],e.addPrefixes(o)}else{const t=e.autocompleters.getTrie(s).autoComplete(n);t.length>0&&e.addPrefixes(t[0])}}}}}}else if(t.turtle){console.log("TTL");const s=x.fromTextArea(e.target);s.setValue(a),s.on("change",()=>{t.onChange(s.getValue())})}}}))};we.propTypes={question:a.object.isRequired,answer:a.object.isRequired,label:a.object.isRequired,title:a.string,value:a.oneOfType([a.string,a.number]),onChange:a.func.isRequired,validation:a.object};const be={D:"1",M:"1",Y:"1",h:"1",m:"1",s:"1"};class ye{static mapMask(e){if(!e)return e;let t,s="";for(let n=0,o=e.length;n<o;n++)t=e.charAt(n),s+=be[t]?be[t]:t;return s}}const De=["size","placeholder"];function Ve(e){let t,s,n,o;if(void 0!==e.selectionStart)t=e.selectionStart,s=e.selectionEnd;else try{e.focus(),n=e.createTextRange(),o=n.duplicate(),n.moveToBookmark(document.selection.createRange().getBookmark()),o.setEndPoint("EndToStart",n),t=o.text.length,s=t+n.text.length}catch(e){}return{start:t,end:s}}class Me extends e.Component{constructor(e){super(e),this._updatePattern=e=>{this.mask.setPattern(ye.mapMask(e.mask),{value:this.mask.getRawValue(),selection:Ve(this.input)})},this._updateMaskSelection=()=>{this.mask.selection=Ve(this.input)},this._updateInputSelection=()=>{!function(e,t){let s;try{void 0!==e.selectionStart?(e.focus(),e.setSelectionRange(t.start,t.end)):(e.focus(),s=e.createTextRange(),s.collapse(!0),s.moveStart("character",t.start),s.moveEnd("character",t.end-t.start),s.select())}catch(e){}}(this.input,this.mask.selection)},this._onChange=e=>{const t=this.mask.getValue();if(e.target.value!==t){if(e.target.value.length<t.length){const s=t.length-e.target.value.length;this._updateMaskSelection(),this.mask.selection.end=this.mask.selection.start+s,this.mask.backspace()}const s=this._getDisplayValue();e.target.value=s,s&&this._updateInputSelection()}this.props.onChange&&this.props.onChange(e)},this._onKeyDown=e=>{if(function(e){return e.ctrlKey&&90===e.keyCode}(e))e.preventDefault(),this.mask.undo()&&(e.target.value=this._getDisplayValue(),this._updateInputSelection(),this.props.onChange&&this.props.onChange(e));else if(function(e){return e.ctrlKey&&89===e.keyCode}(e))e.preventDefault(),this.mask.redo()&&(e.target.value=this._getDisplayValue(),this._updateInputSelection(),this.props.onChange&&this.props.onChange(e));else if("Backspace"===e.key&&(e.preventDefault(),this._updateMaskSelection(),this.mask.backspace())){const t=this._getDisplayValue();e.target.value=t,t&&this._updateInputSelection(),this.props.onChange&&this.props.onChange(e)}},this._onKeyPress=e=>{e.metaKey||e.altKey||e.ctrlKey||"Enter"===e.key||(e.preventDefault(),this._updateMaskSelection(),this.mask.input(e.key)&&(e.target.value=this.mask.getValue(),this._updateInputSelection(),this.props.onChange&&this.props.onChange(e)))},this._onPaste=e=>{e.preventDefault(),this._updateMaskSelection(),this.mask.paste(e.clipboardData.getData("Text"))&&(e.target.value=this.mask.getValue(),setTimeout(this._updateInputSelection,0),this.props.onChange&&this.props.onChange(e))},this.mask=new P({pattern:ye.mapMask(e.mask),value:e.value,formatCharacters:e.formatCharacters,placeholderChar:e.placeholderChar||"_"})}componentDidUpdate(e){e.mask!==this.props.mask&&this._updatePattern(this.props),e.mask!==this.props.mask&&e.value!==this.props.mask?this.mask.getValue()===this.mask.emptyValue?this.mask.setPattern(ye.mapMask(this.props.mask),{value:this.props.value}):this.mask.setPattern(ye.mapMask(this.props.mask),{value:this.mask.getRawValue()}):e.mask!==this.props.mask?this.mask.setPattern(ye.mapMask(this.props.mask),{value:this.mask.getRawValue()}):e.value!==this.props.value&&this.mask.setValue(this.props.value),e.mask!==this.props.mask&&this.mask.selection.start&&this._updateInputSelection()}_getDisplayValue(){const e=this.mask.getValue();return e===this.mask.emptyValue?"":e}focus(){this.input.focus()}blur(){this.input.blur()}render(){const t=this.props,{size:s,placeholder:n}=t,o=K(t,De),i=this.mask.pattern.length;/*#__PURE__*/return e.createElement(this.context.inputComponent,Object.assign({},o,{ref:e=>{e&&(this.input=e.input?p.findDOMNode(e.input):e)},maxLength:i,onChange:this._onChange,onKeyDown:this._onKeyDown,onKeyPress:this._onKeyPress,onPaste:this._onPaste,placeholder:n||this.mask.emptyValue,size:s||i,value:this._getDisplayValue(),type:"text"}))}}Me.contextType=de,Me.propTypes={mask:a.string.isRequired},Me.defaultProps={value:""};const He=t=>{const{componentsOptions:s}=o(de),n=t.question,i=t.value,r=c.getJsonAttValue(n,se.INPUT_MASK);return r?/*#__PURE__*/e.createElement(Me,{mask:r,value:i,label:t.label,title:t.title,placeholder:r,onChange:e=>t.onChange(e.target.value),disabled:s.readOnly||re.isDisabled(n),validation:t.validation}):(J.warn("Input mask not provided. Falling back to regular input."),/*#__PURE__*/e.createElement(we,t))};He.propTypes={question:a.object.isRequired,answer:a.object.isRequired,label:a.object.isRequired,title:a.string,value:a.oneOfType([a.string,a.number]),onChange:a.func.isRequired,validation:a.object};class Ue extends e.Component{_generateSelectOptions(t){const s=[];t.sort(function(e,t){const s=c.getJsonAttValue(e,se.RDFS_LABEL),n=c.getJsonAttValue(t,se.RDFS_LABEL);return s<n?-1:s>n?1:0});for(let n=0;n<t.length;n++)s.push(/*#__PURE__*/e.createElement("option",{value:c.getJsonAttValue(t[n],se.RDFS_LABEL),key:"opt-"+n},c.getJsonAttValue(t[n],se.RDFS_LABEL)));return s}render(){const t=this.props.question;/*#__PURE__*/return e.createElement(this.context.inputComponent,{type:"select",label:this.props.label,value:this.props.value,title:this.props.title,validation:this.props.validation,onChange:e=>{this.props.onChange(e.target.value)},disabled:this.context.componentsOptions.readOnly||re.isDisabled(t)},this._generateSelectOptions(t[se.HAS_OPTION]))}}Ue.contextType=de,Ue.propTypes={question:a.object.isRequired,label:a.object.isRequired,title:a.string,value:a.string,onChange:a.func.isRequired,validation:a.object};const xe=(e,t)=>e&&e.length?(e.sort(ie.getCompareLocalizedLabelFunction(t)),ie.orderPreservingToplogicalSort(e,se.HAS_PRECEDING_VALUE),e):[],Pe=t=>{const i=ne.getStringHash(re.getPossibleValuesQuery(t.question)),r=o($),a=o(de),l=a.options.intl,[u,p]=s(!0),[h,E]=s([xe(t.options,l)]);n(()=>{let e=!1;const s=t.question;return!s[se.HAS_OPTION]&&re.getPossibleValuesQuery(s)?async function(){try{const t=await r.loadFormOptions(i,re.getPossibleValuesQuery(s));e||(p(!1),S(t))}catch(e){J.error(`An error has occurred during loadFormOptions for query hash: ${i}`)}}():(p(!1),S(s[se.HAS_OPTION])),()=>{e=!0}},[]);const S=e=>{if(!e)return[];e=xe(e,l);const t={},s=[];for(let n of e){let e=c.getLocalized(n[se.RDFS_LABEL],l);t[n["@id"]]={id:n["@id"],value:n["@id"],label:e,children:[]};for(let e of ne.asArray(n[se.BROADER]))s.push({type:"parent-child",parent:e["@id"],child:n["@id"]})}for(let e of s){var n;"parent-child"===e.type&&(null==(n=t[e.parent])||n.children.push(e.child))}const o=Object.values(t);E(o)},A=ne.findKeyInObjects(h,["name","value"]),g=ne.findKeyInObjects(h,["name","label"]);/*#__PURE__*/return e.createElement(d,{size:"small"},/*#__PURE__*/e.createElement(m.Label,null,t.label),/*#__PURE__*/e.createElement(q,{styles:(()=>{let e,s;return"is-warning"===t.validation.classname?(e="#dc9135",s="0 0 0 0.2rem rgba(203, 127, 16, 0.25)"):"is-invalid"===t.validation.classname&&(e="#dc3545",s="0 0 0 .2rem rgba(220,53,69,.25)"),{control:t=>Object.assign({},t,{border:e?`1px solid ${e}`:t.border,boxShadow:t.boxShadow,"&:hover":{border:`1px solid ${e}`,boxShadow:s||t.boxShadow}})}})(),valueKey:A,labelKey:g,valueRenderer:!1===t.question[se.PROVIDES_DEREFERENCEABLE_ANSWER_VALUES]?t=>/*#__PURE__*/e.createElement(e.Fragment,null,t):null,valueIsControlled:!0,value:h.filter(e=>e.id===t.value),multi:!1,options:h,isSearchable:!0,isLoading:u,isClearable:!0,renderAsTree:!0,optionLeftOffset:5,isDisabled:u||a.componentsOptions.readOnly||re.isDisabled(t.question),onChange:e=>{t.onChange(e?e.id:null)}}),t.validation.message)};Pe.propTypes={question:a.object.isRequired,answer:a.object.isRequired,label:a.oneOfType([a.string,a.object]).isRequired,title:a.string,value:a.string,onChange:a.func.isRequired,validation:a.object};const qe=({title:t})=>/*#__PURE__*/e.createElement("svg",{className:"caret-square-up",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"28",viewBox:"0 0 24 28"},/*#__PURE__*/e.createElement("title",null,t||""),/*#__PURE__*/e.createElement("path",{d:"M17.891 17.453c-0.172 0.344-0.516 0.547-0.891 0.547h-10c-0.375 0-0.719-0.203-0.891-0.547-0.172-0.328-0.141-0.734 0.078-1.031l5-7c0.187-0.266 0.484-0.422 0.812-0.422s0.625 0.156 0.812 0.422l5 7c0.219 0.297 0.25 0.703 0.078 1.031zM20 21.5v-15c0-0.266-0.234-0.5-0.5-0.5h-15c-0.266 0-0.5 0.234-0.5 0.5v15c0 0.266 0.234 0.5 0.5 0.5h15c0.266 0 0.5-0.234 0.5-0.5zM24 6.5v15c0 2.484-2.016 4.5-4.5 4.5h-15c-2.484 0-4.5-2.016-4.5-4.5v-15c0-2.484 2.016-4.5 4.5-4.5h15c2.484 0 4.5 2.016 4.5 4.5z"})),Fe=({title:t})=>/*#__PURE__*/e.createElement("svg",{className:"caret-square-down",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"28",viewBox:"0 0 24 28"},/*#__PURE__*/e.createElement("title",null,t||""),/*#__PURE__*/e.createElement("path",{d:"M17.891 10.547c0.172 0.328 0.141 0.734-0.078 1.031l-5 7c-0.187 0.266-0.484 0.422-0.812 0.422s-0.625-0.156-0.812-0.422l-5-7c-0.219-0.297-0.25-0.703-0.078-1.031 0.172-0.344 0.516-0.547 0.891-0.547h10c0.375 0 0.719 0.203 0.891 0.547zM20 21.5v-15c0-0.266-0.234-0.5-0.5-0.5h-15c-0.266 0-0.5 0.234-0.5 0.5v15c0 0.266 0.234 0.5 0.5 0.5h15c0.266 0 0.5-0.234 0.5-0.5zM24 6.5v15c0 2.484-2.016 4.5-4.5 4.5h-15c-2.484 0-4.5-2.016-4.5-4.5v-15c0-2.484 2.016-4.5 4.5-4.5h15c2.484 0 4.5 2.016 4.5 4.5z"})),Qe=()=>/*#__PURE__*/e.createElement("svg",{className:"info-circle",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"28",viewBox:"0 0 24 28"},/*#__PURE__*/e.createElement("title",null,"info-circle"),/*#__PURE__*/e.createElement("path",{d:"M16 21.5v-2.5c0-0.281-0.219-0.5-0.5-0.5h-1.5v-8c0-0.281-0.219-0.5-0.5-0.5h-5c-0.281 0-0.5 0.219-0.5 0.5v2.5c0 0.281 0.219 0.5 0.5 0.5h1.5v5h-1.5c-0.281 0-0.5 0.219-0.5 0.5v2.5c0 0.281 0.219 0.5 0.5 0.5h7c0.281 0 0.5-0.219 0.5-0.5zM14 7.5v-2.5c0-0.281-0.219-0.5-0.5-0.5h-3c-0.281 0-0.5 0.219-0.5 0.5v2.5c0 0.281 0.219 0.5 0.5 0.5h3c0.281 0 0.5-0.219 0.5-0.5zM24 14c0 6.625-5.375 12-12 12s-12-5.375-12-12 5.375-12 12-12 12 5.375 12 12z"})),je=()=>/*#__PURE__*/e.createElement("svg",{className:"question-circle",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"28",viewBox:"0 0 24 28"},/*#__PURE__*/e.createElement("path",{d:"M14 21.5v-3c0-0.281-0.219-0.5-0.5-0.5h-3c-0.281 0-0.5 0.219-0.5 0.5v3c0 0.281 0.219 0.5 0.5 0.5h3c0.281 0 0.5-0.219 0.5-0.5zM18 11c0-2.859-3-5-5.688-5-2.547 0-4.453 1.094-5.797 3.328-0.141 0.219-0.078 0.5 0.125 0.656l2.063 1.563c0.078 0.063 0.187 0.094 0.297 0.094 0.141 0 0.297-0.063 0.391-0.187 0.734-0.938 1.047-1.219 1.344-1.437 0.266-0.187 0.781-0.375 1.344-0.375 1 0 1.922 0.641 1.922 1.328 0 0.812-0.422 1.219-1.375 1.656-1.109 0.5-2.625 1.797-2.625 3.313v0.562c0 0.281 0.219 0.5 0.5 0.5h3c0.281 0 0.5-0.219 0.5-0.5v0c0-0.359 0.453-1.125 1.188-1.547 1.188-0.672 2.812-1.578 2.812-3.953zM24 14c0 6.625-5.375 12-12 12s-12-5.375-12-12 5.375-12 12-12 12 5.375 12 12z"})),ze=t=>{const[n,o]=s("right");/*#__PURE__*/return e.createElement("span",{ref:e=>(e=>{e&&(e.getBoundingClientRect().x>window.innerWidth/2?o("left"):o("right"))})(e)},/*#__PURE__*/e.createElement(E,{overlay:t.show?/*#__PURE__*/e.createElement(S,{className:"tooltip-content",id:t.id},t.tooltipContent):/*#__PURE__*/e.createElement("span",null),placement:t.overlayPlacement||n},/*#__PURE__*/e.createElement("span",null,t.children)))};ze.propTypes={tooltipContent:a.oneOfType([a.object.isRequired,a.string.isRequired]),id:a.string.isRequired,overlayPlacement:a.string,absolutePosition:a.bool,show:a.bool},ze.defaultProps={iconClassContainer:"",iconClass:"",absolutePosition:!0,show:!0};const ke=t=>{const[n,o]=s("right");/*#__PURE__*/return e.createElement("div",{ref:e=>(e=>{e&&(e.getBoundingClientRect().x>window.innerWidth/2?o("left"):o("right"))})(e)},/*#__PURE__*/e.createElement(ze,{id:"help-icon-tooltip-",overlayPlacement:t.overlayPlacement||n,absolutePosition:t.absolutePosition,tooltipContent:t.text},/*#__PURE__*/e.createElement(je,{className:t.iconClass})))};ke.propTypes={text:a.string.isRequired,iconClassContainer:a.string,iconClass:a.string,overlayPlacement:a.string,absolutePosition:a.bool},ke.defaultProps={iconClassContainer:"",iconClass:"",absolutePosition:!0};const Be=()=>/*#__PURE__*/e.createElement("svg",{className:"external-link-icon",width:"24",height:"16",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},/*#__PURE__*/e.createElement("path",{d:"M5,2 C5.55228,2 6,2.44772 6,3 C6,3.55228 5.55228,4 5,4 L4,4 L4,12 L12,12 L12,11 C12,10.4477 12.4477,10 13,10 C13.5523,10 14,10.4477 14,11 L14,12 C14,13.1046 13.1046,14 12,14 L4,14 C2.89543,14 2,13.1046 2,12 L2,4 C2,2.89543 2.89543,2 4,2 L5,2 Z M15,1 L15,5.99814453 C15,6.55043453 14.5523,6.99814453 14,6.99814453 C13.4477,6.99814453 13,6.55043453 13,5.99814453 L13,4.41419 L8.71571,8.69846 C8.32519,9.08899 7.69202,9.08899 7.3015,8.69846 C6.91097,8.30794 6.91097,7.67477 7.3015,7.28425 L11.5858,3 L9.99619141,3 C9.44391141,3 8.99619141,2.55228 8.99619141,2 C8.99619141,1.44772 9.44391141,1 9.99619141,1 L15,1 Z"})),We=t=>/*#__PURE__*/e.createElement(ze,{tooltipContent:t.url["@id"]||t.url,id:"url-tooltip",overlayPlacement:t.overlayPlacement},/*#__PURE__*/e.createElement("a",{href:t.url["@id"]||t.url,target:"_blank",className:t.iconClassContainer},/*#__PURE__*/e.createElement(Be,{className:t.iconClass})));We.propTypes={url:a.oneOfType([a.string.isRequired,a.object.isRequired]),iconClassContainer:a.string,iconClass:a.string,overlayPlacement:a.string,absolutePosition:a.bool},We.defaultProps={iconClassContainer:"",iconClass:"",absolutePosition:!0};const Ge=()=>/*#__PURE__*/e.createElement("svg",{className:"question-comment",version:"1.1",id:"Capa_1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 60 60",width:"24",height:"28"},/*#__PURE__*/e.createElement("path",{d:"M30,1.5c-16.542,0-30,12.112-30,27c0,5.204,1.646,10.245,4.768,14.604c-0.591,6.537-2.175,11.39-4.475,13.689 c-0.304,0.304-0.38,0.769-0.188,1.153C0.275,58.289,0.625,58.5,1,58.5c0.046,0,0.092-0.003,0.139-0.01 c0.405-0.057,9.813-1.411,16.618-5.339C21.621,54.71,25.737,55.5,30,55.5c16.542,0,30-12.112,30-27S46.542,1.5,30,1.5z M16,32.5 c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S18.206,32.5,16,32.5z M30,32.5c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4 S32.206,32.5,30,32.5z M44,32.5c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S46.206,32.5,44,32.5z"})),Xe=()=>/*#__PURE__*/e.createElement("svg",{className:"recycle-bin-icon",version:"1.1",xmlns:"http://www.w3.org/2000/svg",height:"15px",width:"15px",viewBox:"0 0 512 512"},/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("path",{d:"M331.636,69.818V0H180.364v69.818h-128v128h34.909V512h337.455V197.818h34.909v-128H331.636z M215.273,34.909h81.455\nv34.909h-81.455V34.909z M389.818,477.091H122.182V197.818h267.636V477.091z M424.727,162.909H87.273v-58.182h337.455V162.909z"}))),/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("rect",{x:"168.727",y:"256",width:"34.909",height:"162.909"}))),/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("rect",{x:"308.364",y:"256",width:"34.909",height:"162.909"}))),/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("g",null,/*#__PURE__*/e.createElement("rect",{x:"238.545",y:"256",width:"34.909",height:"162.909"})))),Ye="Unknown author",Ke=t=>{const{options:n}=o(de),[i,r]=s(!1),[a,l]=s(!1);j.addLocale(k),j.addLocale(z),j.setDefaultLocale(se.LANG.en.locale);const c=new j(n.intl.locale),u=()=>{if(n&&n.users){const e=n.users.find(e=>e.id===n.currentUser);if(t.author)return e.label?e.label:p()}return Ye},p=()=>t.author["@id"].replace(/.*[#\/]/,"... "),m=()=>{r(!i)};/*#__PURE__*/return e.createElement("div",{className:"comment-content",onMouseEnter:()=>{l(!0)},onMouseLeave:()=>{l(!1)}},/*#__PURE__*/e.createElement("div",{className:"row"},/*#__PURE__*/e.createElement("div",{className:"col-auto comment-author",onMouseEnter:m,onMouseLeave:m},/*#__PURE__*/e.createElement(e.Fragment,null,i?/*#__PURE__*/e.createElement(e.Fragment,null,u(),/*#__PURE__*/e.createElement(We,{iconClassContainer:"emphasise-on-relevant-icon",url:t.author?Object.values(t.author).toString():Ye})):u())),/*#__PURE__*/e.createElement("div",{className:"col-auto text-muted comment-timestamp"},/*#__PURE__*/e.createElement(ze,{id:"exact-time-overlay",tooltipContent:(()=>{const e=new Date(parseInt(t.timestamp));return new Intl.DateTimeFormat(n.intl.locale,{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}).format(e)})()},c.format(parseInt(t.timestamp)))),a?/*#__PURE__*/e.createElement(B.div,{className:"comment-delete emphasise-on-relevant-icon",whileHover:{scale:1.2},whileTap:{scale:.9},onClick:()=>{t.onDeleteQuestionComment(t.index),t.onDeleteViewComment()}},/*#__PURE__*/e.createElement(Xe,null)):null),/*#__PURE__*/e.createElement("div",{className:"row"},/*#__PURE__*/e.createElement("div",{className:"col comment-value"},t.commentValue)))};Ke.propTypes={author:a.object,timestamp:a.string.isRequired,commentValue:a.string.isRequired,onDeleteQuestionComment:a.func.isRequired,onDeleteViewComment:a.func,index:a.number.isRequired};const Je=({comments:e,onDeleteCommentClick:t})=>{const o=i(null),[r,a]=s(!1),l=()=>{a(!0),setTimeout(()=>{a(!1)},2e3)};return n(()=>{null!==o.current&&(o.current.scrollTop=o.current.scrollHeight)},[JSON.stringify(e)]),F("span",{children:r?Q("div",{className:"comment-delete",children:[F(W,{color:"#00BFFF",height:80,width:80}),F("p",{children:"Deleting comment..."})]}):F("div",{className:"comment-list-items",ref:o,children:e.map((e,s)=>F("div",{className:"comment-list-item",children:F(Ke,{commentValue:e[se.HAS_COMMENT_VALUE],author:e[se.HAS_AUTHOR]?e[se.HAS_AUTHOR]:null,timestamp:e[se.HAS_TIMESTAMP],onDeleteQuestionComment:t,onDeleteViewComment:l,index:s})},s))})})},Ze=()=>/*#__PURE__*/e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"15",viewBox:"0 0 24 24"},/*#__PURE__*/e.createElement("path",{d:"M6.185 4.843l11.927 7.157-11.927 7.157 2.982-7.157-2.982-7.157zm-4.185-4.843l5 12-5 12 20-12-20-12z"})),$e="300px",et=t=>{const[o,r]=s(""),a=i(null),l=G();n(()=>{a.current.focus()},[]);const c=e=>{e.preventDefault(),t.onChange(o),r("")},u=()=>{const e=a.current;e.style.height="auto",p(e)},p=e=>{e.style.height=`${e.scrollHeight}px`,parseInt(e.style.height)>parseInt($e)&&(e.style.height=$e)};/*#__PURE__*/return e.createElement(m,{onSubmit:c,onKeyUp:e=>{"Enter"===e.key&&e.ctrlKey&&o.trim()&&c(e)},onClick:e=>{e.stopPropagation()}},/*#__PURE__*/e.createElement(m.Group,{className:"m-2",controlId:"formBasicComment"},/*#__PURE__*/e.createElement(A,{className:"col-lg-12 p-0"},/*#__PURE__*/e.createElement(g,{className:"container-fluid p-0 m-0"},/*#__PURE__*/e.createElement("div",{id:"comment-form"},/*#__PURE__*/e.createElement(m.Control,{className:"comment-form-control",name:"comment",as:"textarea",placeholder:l.formatMessage({id:"comment.form.placeholder"}),required:!0,value:o,onChange:e=>{r(e.target.value)},ref:a,onKeyPress:u,onKeyDown:u}),/*#__PURE__*/e.createElement(_,{className:"comment-form-button",variant:"primary",type:"submit"},/*#__PURE__*/e.createElement(Ze,null)))))))};et.propTypes={onChange:a.func.isRequired};const tt=()=>/*#__PURE__*/e.createElement("svg",{className:"close-icon",width:"24px",height:"24px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},/*#__PURE__*/e.createElement("path",{d:"M13.41 12l4.3-4.29a1 1 0 1 0-1.42-1.42L12 10.59l-4.29-4.3a1 1 0 0 0-1.42 1.42l4.3 4.29-4.3 4.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l4.29-4.3 4.29 4.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42z"})),st=t=>{const r=o(de),a=i(null),l=i(null),c=i(null),[u,p]=s(!1),[m,d]=s("right");n(()=>{N(c.current)});const h=()=>{p(!1)},E=()=>{const e=t.question;return e[se.HAS_COMMENT]||(e[se.HAS_COMMENT]=[]),Array.isArray(e[se.HAS_COMMENT])||(e[se.HAS_COMMENT]=[e[se.HAS_COMMENT]]),e[se.HAS_COMMENT]},A=e=>{const s={};g(s,e),t.onChange(I(),s)},g=(e,t)=>{r.options.currentUser&&(e[se.HAS_AUTHOR]={"@id":r.options.currentUser}),e[se.HAS_COMMENT_VALUE]=t,e[se.HAS_TIMESTAMP]=Date.now().toString()},_=e=>{E().splice(e,1)},v=e=>{e.preventDefault(),e.stopPropagation()},I=()=>E().length,N=e=>{e&&(e.getBoundingClientRect().x>window.innerWidth/2?d("left"):d("right"))};/*#__PURE__*/return e.createElement("div",{ref:c,onClick:v},/*#__PURE__*/e.createElement("span",{className:"comment-bubble",ref:a,onClick:e=>{v(e),p(!u)}},/*#__PURE__*/e.createElement(Ge,null),I()>0?/*#__PURE__*/e.createElement(f,{className:"comment-badge",pill:!0,variant:"primary"},I()):null),/*#__PURE__*/e.createElement(B.div,{className:"overlay-comment",ref:l,drag:!0,dragConstraints:{top:-50,left:-50,right:50,bottom:50}},/*#__PURE__*/e.createElement(T,{target:a.current,show:u,placement:m,rootClose:!1,onHide:h,container:l},t=>/*#__PURE__*/e.createElement(S,Y({className:"comment-tooltip"},t),/*#__PURE__*/e.createElement("span",{onKeyDown:e=>{(e=>{"Escape"===e.key&&h()})(e)}},/*#__PURE__*/e.createElement(B.div,{className:"close-comment-icon",onClick:h,whileHover:{scale:1.1,transition:{duration:.1}}},/*#__PURE__*/e.createElement(tt,null)),/*#__PURE__*/e.createElement(Je,{comments:E(),onDeleteCommentClick:_}),/*#__PURE__*/e.createElement(et,{onChange:A}))))))};var nt;st.propTypes={question:a.object.isRequired,onChange:a.func.isRequired};class ot{static renderIcons(t,s,n,o){let i;i=s.icons?s.icons:se.DEFAULT_OPTIONS.icons;let r=[];const a=this.renderQuestionHelp(t,s,n,o),l=this.renderQuestionComments(t,s,n,o),c=this.renderQuestionLink(t,s,n,o);for(let t=0;t<i.length;t++)i[t].id===se.ICONS.QUESTION_COMMENTS&&r.push(/*#__PURE__*/e.createElement("li",{key:t,className:"icon-list-item"},l)),i[t].id===se.ICONS.QUESTION_HELP&&r.push(/*#__PURE__*/e.createElement("li",{key:t,className:"icon-list-item"},a)),i[t].id===se.ICONS.QUESTION_LINK&&r.push(/*#__PURE__*/e.createElement("li",{key:t,className:"icon-list-item"},c));/*#__PURE__*/return e.createElement("ol",{className:"icon-list-items"},r)}static renderQuestionHelp(e,t,s,n){return this.getIconComponentFromName(se.ICONS.QUESTION_HELP,e,t,s,n)}static renderQuestionLink(e,t,s,n){return this.getIconComponentFromName(se.ICONS.QUESTION_LINK,e,t,s,n)}static getIconComponentFromName(e,t,s,n,o){const i=this.getIconFromIconList(s.icons?s.icons:se.DEFAULT_OPTIONS.icons,e);return this.getIconComponent(i,t,s,n,o)}static getIconComponent(t,s,n,o,i){let r;if(t&&(t.behavior===se.ICON_BEHAVIOR.ON_HOVER||t.behavior===se.ICON_BEHAVIOR.ENABLE))return t.behavior===se.ICON_BEHAVIOR.ENABLE?(i=!0,r=""):r="emphasise-on-relevant-icon",t.id===se.ICONS.QUESTION_HELP&&s[se.HELP_DESCRIPTION]?i?/*#__PURE__*/e.createElement("div",{className:r},/*#__PURE__*/e.createElement(ke,{text:c.getLocalized(s[se.HELP_DESCRIPTION],n.intl),absolutePosition:!1})):null:t.id===se.ICONS.QUESTION_LINK&&s[se.SOURCE]?i?/*#__PURE__*/e.createElement("div",{className:r},/*#__PURE__*/e.createElement(We,{url:s[se.SOURCE]})):null:t.id===se.ICONS.QUESTION_COMMENTS&&i?/*#__PURE__*/e.createElement("div",{className:r},/*#__PURE__*/e.createElement(st,{question:s,onChange:o})):null}}nt=ot,ot.renderQuestionComments=(e,t,s,n)=>nt.getIconComponentFromName(se.ICONS.QUESTION_COMMENTS,e,t,s,n),ot.getIconFromIconList=(e,t)=>e?e.find(e=>e.id===t):null;const it=t=>{const o=e.useContext($),{options:i}=e.useContext(de),[r,a]=s({severity:"",classname:"",message:null});n(()=>{p()},[t.question]);const l=e=>{const s=Object.assign({},t.answer);u(s,e),t.onChange(t.index,s)},u=(e,s)=>{null===s?(e[se.HAS_OBJECT_VALUE]=null,e[se.HAS_DATA_VALUE]=null):t.answer[se.HAS_OBJECT_VALUE]||re.isTypeahead(t.question)?e[se.HAS_OBJECT_VALUE]={"@id":s}:e[se.HAS_DATA_VALUE]={"@value":s}},p=()=>{a({severity:"",classname:"",message:null}),!1===m[se.HAS_VALID_ANSWER]&&a(m[se.HAS_VALIDATION_SEVERITY]===se.VALIDATION.SEVERITY.WARNING?{severity:se.VALIDATION.SEVERITY.WARNING,classname:se.VALIDATION.CLASSNAME.WARNING,message:/*#__PURE__*/e.createElement(v,{className:se.VALIDATION.CLASSNAME.WARNING},m[se.HAS_VALIDATION_MESSAGE])}:{severity:se.VALIDATION.SEVERITY.ERROR,classname:se.VALIDATION.CLASSNAME.ERROR,message:/*#__PURE__*/e.createElement(v,{className:se.VALIDATION.CLASSNAME.ERROR},m[se.HAS_VALIDATION_MESSAGE])})},m=t.question,d=re.resolveValue(t.answer),h=(s=>{const n=c.getLocalized(s[se.RDFS_LABEL],i.intl);/*#__PURE__*/return e.createElement("div",{className:"question-header"},n,ot.renderIcons(t.question,i,t.onCommentChange,t.showIcon))})(m),E=c.getLocalized(m[se.RDFS_COMMENT],i.intl);let S;var A;return S=re.isTypeahead(m)?((s,n,i)=>{const a=ne.getStringHash(re.getPossibleValuesQuery(t.question)),c=o.getOptions(a)||[];/*#__PURE__*/return e.createElement(Pe,{question:t.question,answer:t.answer,label:n,title:i,value:s,onChange:l,options:c,validation:r})})(d,h,E):(A=m)[se.HAS_OPTION]&&0!==A[se.HAS_OPTION].length?((s,n,o)=>/*#__PURE__*/e.createElement(Ue,{question:t.question,label:n,title:o,value:s,onChange:l,validation:r}))(d,h,E):re.isCalendar(m)?((s,n,o)=>/*#__PURE__*/e.createElement(Ne,{question:t.question,value:s,title:o,label:n,onChange:l,validation:r}))(d,h,E):re.isCheckbox(m)?((s,n,o)=>/*#__PURE__*/e.createElement(Ie,{label:n,title:o,value:s,onChange:l,question:t.question,validation:r}))(d,h,E):re.isMaskedInput(m)?((s,n,o)=>/*#__PURE__*/e.createElement(He,{label:n,title:o,value:s,onChange:l,question:t.question,answer:t.answer,validation:r}))(d,h,E):re.isSparqlInput(m)?((s,n,o)=>/*#__PURE__*/e.createElement(we,{question:t.question,answer:t.answer,label:n,title:o,value:s,onChange:l,sparql:!0,validation:r}))(d,h,E):re.isTurtleInput(m)?((s,n,o)=>/*#__PURE__*/e.createElement(we,{question:t.question,answer:t.answer,label:n,title:o,value:s,onChange:l,turtle:!0,validation:r}))(d,h,E):((s,n,o)=>/*#__PURE__*/e.createElement(we,{question:t.question,answer:t.answer,label:n,title:o,value:s,onChange:l,validation:r}))(d,h,E),S};it.propTypes={answer:a.object.isRequired,question:a.object.isRequired,onChange:a.func.isRequired,onCommentChange:a.func.isRequired,index:a.number,icons:a.object};class rt{static createValidator(e,t){const s=[this._intMaxInclusiveValidator,this._intMinInclusiveValidator,this._patternValidator,this._checkboxValidator,this._requiredValidator,this._completenessValidator];return()=>{if(re.hasValidationLogic(e)){const n=re.getAnswerValue(e);return this._validateAnswer(e,t,n,s)}}}static _validateAnswer(e,t,s,n){const o={};for(const i of n){const n=i(e,t,s);if(!n.isValid)return o[se.HAS_VALID_ANSWER]=!1,o[se.HAS_VALIDATION_MESSAGE]=n.message,o[se.HAS_VALIDATION_SEVERITY]=n.validationSeverity,o;if(!1===o[se.HAS_VALID_ANSWER])break}return o[se.HAS_VALID_ANSWER]=!0,o[se.HAS_VALIDATION_MESSAGE]="",o[se.HAS_VALIDATION_SEVERITY]="",o}static _patternValidator(e,t){const s=re.getAnswerValue(e);return s&&s.length>0&&e[se.PATTERN]&&!new RegExp(e[se.PATTERN]).test(s)&&re.hasAnswer(e)?{isValid:!1,validationSeverity:se.VALIDATION.SEVERITY.ERROR,message:e[se.HAS_VALIDATION_MESSAGE]?e[se.HAS_VALIDATION_MESSAGE]:se.VALIDATION.DEFAULT_MESSAGE.INVALID}:{isValid:!0}}static _requiredValidator(e,t){return!e[se.REQUIRES_ANSWER]||e[se.USED_ONLY_FOR_COMPLETENESS]||re.hasAnswer(e)?{isValid:!0}:{isValid:!1,validationSeverity:se.VALIDATION.SEVERITY.ERROR,message:e[se.HAS_VALIDATION_MESSAGE]?e[se.HAS_VALIDATION_MESSAGE]:se.VALIDATION.DEFAULT_MESSAGE.REQUIRED}}static _checkboxValidator(e,t){return re.isCheckbox(e)&&e[se.REQUIRES_ANSWER]&&!re.hasAnswer(e)?{isValid:!1,validationSeverity:se.VALIDATION.SEVERITY.ERROR,message:e[se.HAS_VALIDATION_MESSAGE]?e[se.HAS_VALIDATION_MESSAGE]:se.VALIDATION.DEFAULT_MESSAGE.CHECK}:{isValid:!0}}static _completenessValidator(e,t){return e[se.REQUIRES_ANSWER]&&e[se.USED_ONLY_FOR_COMPLETENESS]&&!re.hasAnswer(e)?{isValid:!1,validationSeverity:se.VALIDATION.SEVERITY.WARNING,message:e[se.HAS_VALIDATION_MESSAGE]?e[se.HAS_VALIDATION_MESSAGE]:se.VALIDATION.DEFAULT_MESSAGE.REQUIRED_ONLY_FOR_COMPLETENESS}:{isValid:!0}}static _intMinInclusiveValidator(e,t){if(e[se.XSD.MIN_INCLUSIVE]){const t=re.getAnswerValue(e);if(t&&t.length>0){const s=e[se.XSD.MIN_INCLUSIVE];if(!(Number.isInteger(parseInt(t))&&t>=s))return{isValid:!1,validationSeverity:se.VALIDATION.SEVERITY.ERROR,message:e[se.HAS_VALIDATION_MESSAGE]?e[se.HAS_VALIDATION_MESSAGE]:se.VALIDATION.DEFAULT_MESSAGE.GREATER_OR_EQUAL+s+"."}}}return{isValid:!0}}static _intMaxInclusiveValidator(e,t){const s=re.getAnswerValue(e);if(e[se.XSD.MAX_INCLUSIVE]&&s&&s.length>0){const t=e[se.XSD.MAX_INCLUSIVE];if(!(Number.isInteger(parseInt(s))&&s<=t))return{isValid:!1,validationSeverity:se.VALIDATION.SEVERITY.ERROR,message:e[se.HAS_VALIDATION_MESSAGE]?e[se.HAS_VALIDATION_MESSAGE]:se.VALIDATION.DEFAULT_MESSAGE.LOWER_OR_EQUAL+t+"."}}return{isValid:!0}}}class at extends e.Component{constructor(e){super(e),this.state={prefixes:e.prefixes}}render(){const t=/*#__PURE__*/e.createElement(I,{id:"prefixes",title:"Prefixes"},/*#__PURE__*/e.createElement(N,null,this.state.prefixes.sort((e,t)=>e[se.PREFIX]<t[se.PREFIX]?-1:1).map(t=>/*#__PURE__*/e.createElement(O,{key:t[se.PREFIX]},/*#__PURE__*/e.createElement("strong",null,t[se.PREFIX]),": ",t[se.NAMESPACE]))));/*#__PURE__*/return e.createElement(E,{trigger:"click",placement:"right",overlay:t},/*#__PURE__*/e.createElement("span",{className:this.props.iconClass},this.props.children))}}at.propTypes={prefixes:a.array.isRequired,children:a.element.isRequired,iconClass:a.string},at.defaultProps={iconClass:""};const lt=({question:e})=>(()=>{const t=e[se.HAS_MEDIA_CONTENT];return t?Array.isArray(t)?F("div",{className:"col-6",children:t.map((e,s)=>F("div",{className:"row embed-responsive-21by9 media-content-video-container mb-3",children:F("iframe",{src:t[s],className:"embed-responsive-item",allowFullScreen:!0})},s))}):F("div",{className:"col-6",children:F("iframe",{src:t,className:"embed-responsive-item",allowFullScreen:!0})}):null})();class ct extends e.Component{constructor(e){super(e),this.handleAnswerChange=(e,t)=>{if(re.isSection(this.props.question)){let e=!!re.resolveValue(t);this.setState({expanded:e})}this._handleChange(se.HAS_ANSWER,e,t)},this.handleSubQuestionChange=(e,t)=>{this._handleChange(se.HAS_SUBQUESTION,e,t)},this.handleCommentChange=(e,t)=>{this._handleChange(se.HAS_COMMENT,e,t)},this._toggleCollapse=()=>{this.props.collapsible&&this.setState({expanded:!this.state.expanded})},this._onMouseEnterHandler=()=>{this.setState({showIcon:!0})},this._onMouseLeaveHandler=()=>{this.setState({showIcon:!1})},this._getHeaderClassName=()=>{const e=this.props.question,t=this.props.collapsible;let s=[];return s.push(ct.getEmphasizedOnRelevantClass(e),"question-header"),re.isWizardStep(e)&&s.push("wizard-step bg-primary text-white"),re.isEmphasised(e)&&s.push(ct.getEmphasizedClass(e)),re.isSection(e)&&s.push("section-background"),t&&s.push("cursor-pointer"),this.isDebugged(e)&&s.push("show-irrelevant"),s},oe.putObject(e.question["@id"],e.question),this.state={validator:{},expanded:!re.isCollapsed(e.question),showIcon:!1}}componentDidMount(){this.setState({validator:rt.createValidator(this.props.question,this.context.options.intl)})}componentDidUpdate(){const e=this.props.question,t=this.context.options.startingQuestionId,s=e[se.HAS_SUBQUESTION].find(e=>e["@id"]===t);if(re.isSection(e)&&re.isAnswerable(e)){const e=this._getFirstAnswerValue();if(this.context.options.debugMode)return null;if(s)return null;this.state.expanded&&!e&&this.setState({expanded:!1})}}_handleChange(e,t,s){let n=Object.assign({},this.props.question);if(n[e][t]=s,e===se.HAS_ANSWER){const e=this.state.validator(s);n=Object.assign({},n,e)}oe.putObject(n["@id"],n),this.props.onChange(this.props.index,n)}isDebugged(e){const t=this.context.options.startingQuestionId;return!re.isRelevant(e)&&(!!this.context.options.debugMode||null!=t&&!!ne.findQuestionById(t,e,!0,!1,!1))}render(){const t=this.props.question,s=this.renderQuestion(t);return this.isDebugged(t)?/*#__PURE__*/e.createElement("div",{className:"show-irrelevant"},s):re.isHidden(t)?null:re.isRelevant(t)?s:null}renderQuestion(t){if(re.isAnswerable(t)&&!re.isSection(t))/*#__PURE__*/return e.createElement("div",{id:t["@id"]},/*#__PURE__*/e.createElement("div",{className:"panel-title answerable-question"},this.renderAnswers()),/*#__PURE__*/e.createElement("div",{className:"answerable-subquestions"},this.renderSubQuestions()));if(re.isAnswerable(t))return this.renderAnswerableSection();if(re.isSection(t)){const{collapsible:s,withoutCard:n}=this.props,o=ct._getQuestionCategoryClass(t);if(n)/*#__PURE__*/return e.createElement("div",null,this._renderQuestionContent());const i=c.getLocalized(t[c.RDFS_LABEL],this.context.options.intl),r=/*#__PURE__*/e.createElement(C.Body,{className:U("p-3",o)},this._renderQuestionContent());/*#__PURE__*/return e.createElement(e.Fragment,null,/*#__PURE__*/e.createElement(L,{defaultActiveKey:this.state.expanded?void 0:i},/*#__PURE__*/e.createElement(C,{className:"mb-3"},/*#__PURE__*/e.createElement(L.Toggle,{as:C.Header,onClick:this._toggleCollapse,className:this._getHeaderClassName(),onMouseEnter:this._onMouseEnterHandler,onMouseLeave:this._onMouseLeaveHandler},/*#__PURE__*/e.createElement("h6",{className:"d-inline",id:t["@id"]},s&&!re.isWizardStep(t)&&this._renderCollapseToggle(),i),this.renderQuestionIcons(),this.props.children),/*#__PURE__*/e.createElement(s?L.Collapse:e.Fragment,null,r))))}/*#__PURE__*/return e.createElement("div",null,this._renderQuestionContent())}_renderQuestionContent(){let t=[];return this.state.expanded&&t.push(/*#__PURE__*/e.createElement(lt,{key:this.props.question["@id"]+"-media",question:this.props.question})),t.push(this.renderAnswers()),t.push(this.renderSubQuestions()),t}renderQuestionIcons(){return ot.renderIcons(this.props.question,this.context.options,this.handleCommentChange,this.state.showIcon)}renderAnswerableSection(){const t=this.props.question,s=this.props.collapsible,n=ct._getQuestionCategoryClass(t);let o=this.getShowIrrelevantClassname(t);const i=/*#__PURE__*/e.createElement(C.Body,{className:U("p-3",n)},this.renderSubQuestions(o));/*#__PURE__*/return e.createElement(L,{activeKey:this.state.expanded?t["@id"]:void 0,className:"answerable-section"},/*#__PURE__*/e.createElement(C,{className:"mb-3"},/*#__PURE__*/e.createElement(C.Header,{onClick:this._toggleCollapse,className:this._getHeaderClassName()},this.renderAnswers()),s?/*#__PURE__*/e.createElement(L.Collapse,{className:o,eventKey:t["@id"]},i):{cardBody:i}))}getShowIrrelevantClassname(e){return!this.context.options.debugMode&&!ie.checkId(e[se.HAS_SUBQUESTION],this.context.options.startingQuestionId)||re.hasAnswer(e)?"":"show-irrelevant"}renderAnswers(){const t=this.props.question,s=[],n=this._getAnswers();let o;for(let i=0,r=n.length;i<r;i++)re.isTextarea(t,re.resolveValue(n[i]))||re.isSparqlInput(t)||re.isTurtleInput(t),o=U("answer",ct._getQuestionCategoryClass(t),ct.getEmphasizedOnRelevantClass(t)),s.push(/*#__PURE__*/e.createElement("div",{key:"row-item-"+i,className:o,id:t["@id"],onMouseEnter:this._onMouseEnterHandler,onMouseLeave:this._onMouseLeaveHandler},/*#__PURE__*/e.createElement("div",{className:"answer-content",style:this._getAnswerWidthStyle()},/*#__PURE__*/e.createElement(it,{index:i,answer:n[i],question:t,onChange:this.handleAnswerChange,onCommentChange:this.handleCommentChange,showIcon:this.state.showIcon})),this._renderUnits(),this._renderPrefixes()));return s}_getAnswers(){const e=this.props.question;return e[se.HAS_ANSWER]||(e[se.HAS_ANSWER]=[]),Array.isArray(e[se.HAS_ANSWER])||(e[se.HAS_ANSWER]=[e[se.HAS_ANSWER]]),0===e[se.HAS_ANSWER].length&&(e[se.HAS_ANSWER]=re.isSection(e)&&!re.isAnswerable(e)?[]:[ve.generateAnswer(e)]),e[se.HAS_ANSWER]}_getAnswerWidthStyle(){const e=Number(this.props.question[se.HAS_INITIAL_INPUT_LENGTH]);return e?{flexGrow:0,maxWidth:"none",width:`calc(${e}ch + 1.5rem + 2px)`}:{}}static _getAnswerClass(e,t){return t?"col-12":1===se.GENERATED_ROW_SIZE?"col-6":"col-"+se.COLUMN_COUNT/se.GENERATED_ROW_SIZE}static _getQuestionCategoryClass(e){const t=re.getCategory(e);return t?"question-"+t:""}static getEmphasizedClass(e){return re.isEmphasised(e)?"bg-warning":""}static getEmphasizedOnRelevantClass(e){return c.hasValue(e,se.LAYOUT_CLASS,se.LAYOUT.EMPHASISE_ON_RELEVANT)?"emphasise-on-relevant":""}_renderCollapseToggle(){const{options:t}=this.context,s=this.state.expanded?t.i18n["section.collapse"]:t.i18n["section.expand"];/*#__PURE__*/return e.createElement("span",{onClick:this._toggleCollapse,title:s},/*#__PURE__*/e.createElement(this.state.expanded?qe:Fe,{title:s}))}_renderPrefixes(){const t=this.props.question;return t[se.HAS_DECLARED_PREFIX]&&t[se.HAS_DECLARED_PREFIX].length?/*#__PURE__*/e.createElement(at,{prefixes:t[se.HAS_DECLARED_PREFIX],iconClass:"help-icon-checkbox"},/*#__PURE__*/e.createElement(Qe,null)):null}_renderUnits(){const t=this.props.question;return t[se.HAS_UNIT]?/*#__PURE__*/e.createElement("div",{className:"has-unit-label"},t[se.HAS_UNIT]):null}renderSubQuestions(t){const s=[],n=this._getSubQuestions(),o=this.context.options.debugMode,i=this.context.options.startingQuestionId;for(let r=0;r<n.length;r++){let a=n[r],l=this.context.mapComponent(a,ct),c=null;(o||"show-irrelevant"!==t||ne.findQuestionById(i,a,!0,!1,!1))&&(c=/*#__PURE__*/e.createElement(l,{key:"sub-question-"+r,question:a,onChange:this.handleSubQuestionChange,index:r})),s.push(c)}return s}_getSubQuestions(){const e=this.props.question;return e[se.HAS_SUBQUESTION]||(e[se.HAS_SUBQUESTION]=[]),Array.isArray(e[se.HAS_SUBQUESTION])||(e[se.HAS_SUBQUESTION]=[e[se.HAS_SUBQUESTION]]),ie.orderByLocalizedLabels(e[se.HAS_SUBQUESTION],this.context.options.intl),ie.orderPreservingToplogicalSort(e[se.HAS_SUBQUESTION],se.HAS_PRECEDING_QUESTION),e[se.HAS_SUBQUESTION]}_getFirstAnswerValue(){return re.resolveValue(this._getAnswers()[0])}}ct.contextType=de,ct.propTypes={question:a.object.isRequired,onChange:a.func.isRequired,index:a.number,withoutCard:a.bool,collapsible:a.bool},ct.defaultProps={withoutCard:!1,collapsible:!0};class ut extends e.Component{constructor(t){super(t),this.onNextStep=()=>{this.context.updateFormQuestionsData(this.props.index,this.context.getFormQuestionsData()),this.props.onNextStep()},this.onPreviousStep=()=>{this.props.onPreviousStep()},this._renderWizardStepButtons=()=>/*#__PURE__*/e.createElement(R,{className:"m-3 float-right"},!this.props.isFirstStep&&/*#__PURE__*/e.createElement(_,{className:"mr-2",onClick:this.onPreviousStep,variant:"primary",size:"sm"},this.props.options.i18n["wizard.previous"]),!this.props.isLastStep&&/*#__PURE__*/e.createElement(_,{onClick:this.onNextStep,variant:"primary",size:"sm"},this.props.options.i18n["wizard.next"])),this.onChange=(e,t)=>{this.context.updateFormQuestionsData(this.props.index||e,Object.assign({},this.props.question,t))}}render(){const t=this.context.getFormQuestionsData([this.props.index]);/*#__PURE__*/return e.createElement(e.Fragment,null,/*#__PURE__*/e.createElement(ct,{question:t,onChange:this.onChange,collapsible:re.isAnswerable(t)}),this.props.options.wizardStepButtons&&this._renderWizardStepButtons())}}ut.propTypes={options:a.object.isRequired,question:a.object.isRequired,index:a.number.isRequired,onNextStep:a.func,onPreviousStep:a.func,mapComponent:a.func,isFirstStep:a.bool,isLastStep:a.bool},ut.contextType=ce;const pt=({steps:t,onNavigate:s,currentStep:n})=>{const{options:i}=o(de),r=G();/*#__PURE__*/return e.createElement(C.Header,null,/*#__PURE__*/e.createElement(w,{variant:"tabs",activeKey:n,onSelect:e=>s(parseInt(e))},t.map((t,s)=>/*#__PURE__*/e.createElement(ze,{id:"step-disabled",tooltipContent:r.formatMessage({id:"wizard.nav.tooltip"}),show:!i.enableWizardStepSkip},/*#__PURE__*/e.createElement(b,{key:"nav"+s,id:"wizard-nav-"+s},/*#__PURE__*/e.createElement(y,{eventKey:s,active:s===n?"active":"",hidden:!i.debugMode&&!re.isRelevant(t),disabled:!i.enableWizardStepSkip,className:U([i.debugMode&&!re.isRelevant(t)?"show-irrelevant":ct.getEmphasizedClass(t),"wizard-nav"])},c.getLocalized(t[c.RDFS_LABEL],i.intl)))))))};pt.propTypes={currentStep:a.number.isRequired,steps:a.array.isRequired,onNavigate:a.func.isRequired};const mt=({steps:t,onNavigate:s,currentStep:n})=>{const{options:i}=o(de),r=G();/*#__PURE__*/return e.createElement("div",{className:"wizard-nav col-2 p-0"},/*#__PURE__*/e.createElement(N,null,t.map((t,o)=>/*#__PURE__*/e.createElement(ze,{id:"step-disabled",tooltipContent:r.formatMessage({id:"wizard.nav.tooltip"}),show:!i.enableWizardStepSkip},/*#__PURE__*/e.createElement(O,{hidden:!i.debugMode&&!re.isRelevant(t),key:"nav"+o,onClick:()=>s(o),id:"wizard-nav-"+o,action:!0,active:o===n?"active":"",disabled:!i.enableWizardStepSkip,variant:"default",className:U([i.debugMode&&!re.isRelevant(t)?"show-irrelevant":ct.getEmphasizedClass(t),"wizard-nav"])},c.getLocalized(t[c.RDFS_LABEL],i.intl))))))};mt.propTypes={currentStep:a.number.isRequired,steps:a.array.isRequired,onNavigate:a.func.isRequired};const dt=()=>{const t=e.useContext(ce),{options:s,mapComponent:o}=e.useContext(de);let i=0;s.startingQuestionId?(i=((e,t)=>{const s=(e,n)=>e?e["@id"]===t?n:ne.asArray(e[se.HAS_SUBQUESTION]).findIndex((e,t)=>-1!==s(e,t)):-1;return e.findIndex((e,t)=>-1!==s(e,t))})(t.getFormQuestionsData(),s.startingQuestionId),-1===i&&(console.warn(`Question with id ${s.startingQuestionId} not found!`),i=0)):s.startingStep&&(i=s.startingStep<t.getFormQuestionsData().length?s.startingStep:0);const[r,a]=e.useState(i),[l,c]=e.useState(!1);n(()=>{if(s.startingQuestionId&&!l){const e=document.getElementById(s.startingQuestionId);e&&(e.scrollIntoView(),e.classList.add("text-danger"),c(!0))}});const u=()=>{const e=t.getFormQuestionsData();r!==e.length-1&&(e[r+1].visited=!0,a(e=>e+1))},p=()=>{0!==r&&a(e=>e-1)},m=e=>{const n=t.getFormQuestionsData();e===r||e>=n.length||e>r&&!n[e].visited&&!s.enableWizardStepSkip||a(e)};let d=null;t.getFormQuestionsData().length>1&&(d=(()=>{const n=t.getFormQuestionsData();/*#__PURE__*/return e.createElement(s.horizontalWizardNav?pt:mt,{currentStep:r,steps:n,onNavigate:m})})());const h=s.horizontalWizardNav;/*#__PURE__*/return e.createElement(C,{className:h?"":"flex-row p-3"},d,/*#__PURE__*/e.createElement("div",{className:h?"card-body p-3":d?"col-10 p-0 pl-3":"col-12 p-0"},(()=>{const n=t.getFormQuestionsData()[r];let i=o(n,ut);/*#__PURE__*/return e.createElement(i,{options:s,key:"step"+r,question:n,onNextStep:u,onPreviousStep:p,mapComponent:o,index:r,isFirstStep:0===r,isLastStep:r===t.getFormQuestionsData().length-1})})()))},ht=/*#__PURE__*/e.forwardRef((t,s)=>{const{options:n}=e.useContext(de);/*#__PURE__*/return e.createElement(D,Y({size:"xl",animation:!0},n.modalProps),/*#__PURE__*/e.createElement(D.Header,{closeButton:!0},/*#__PURE__*/e.createElement(D.Title,null,n.modalProps.title)),/*#__PURE__*/e.createElement(D.Body,{className:"overflow-hidden p-0"},t.children))});var Et;ht.propTypes={children:a.element.isRequired};class St{}Et=St,St.updateQuestionValidation=(e,t,s,n)=>{if(t[se.HAS_ANSWER]){const o=rt.createValidator(t,n)();o&&(e[s]=Object.assign({},t,o))}for(const t of e)Et.updateSubQuestionsValidation(t,n)},St.updateSubQuestionsValidation=(e,t)=>{const s=ne.asArray(e[se.HAS_SUBQUESTION]);for(let e=0;e<s.length;e++)Et.updateQuestionValidation(s,s[e],e,t)};class At extends e.Component{constructor(...t){super(...t),this.getFormData=()=>{const e=this.context.getData(),t=this.context.getFormQuestionsData();return ve.buildQuestionAnswerModel(e,t)},this.validateForm=()=>{const e=this.context.getFormQuestionsData();for(let t=0;t<e.length;t++)St.updateQuestionValidation(e,e[t],t,"en");this.context.updateFormQuestionsData(null,e)},this.getFormQuestionsData=()=>this.context.getFormQuestionsData(),this.getFormSpecification=()=>{const e=this.context.getFormQuestionsData();return re.getFormSpecification(e)},this.handleStepChange=(e,t,s)=>{this.context.updateFormQuestionsData(t,Object.assign({},e,s))},this.renderWizardlessForm=()=>{const t=this.context.getFormQuestionsData();/*#__PURE__*/return e.createElement(C,{className:"p-3"},t.map((e,t)=>this._mapQuestion(e,t)))}}_mapQuestion(t,s){let n=this.props.mapComponent(t,ct);/*#__PURE__*/return e.createElement(n,{key:t["@id"],question:t,onChange:(e,s)=>this.handleStepChange(t,e,s),index:s})}render(){const{modalView:t}=this.props,s=this.context.getFormQuestionsData();if(!s.length)/*#__PURE__*/return e.createElement(C,{className:"p-3 font-italic"},"There are no questions available...");const n=s.every(e=>!re.isWizardStep(e));return t?/*#__PURE__*/e.createElement(ht,null,n?this.renderWizardlessForm():/*#__PURE__*/e.createElement(dt,null)):n?this.renderWizardlessForm():/*#__PURE__*/e.createElement(dt,null)}}At.contextType=ce;const gt=/*#__PURE__*/r((t,o)=>{const[i,r]=s(!0),[a,l]=s(null),[c,u]=s(null);if(n(()=>{(async()=>{const e=t.options.intl,[s,n]=await Te.constructForm(t.form,e);s.formQuestions.some(e=>re.isWizardStep(e))&&(s.formQuestions[0].visited=!0),l(s),u(n),r(!1)})()},[t.form]),i)return t.loader||/*#__PURE__*/e.createElement(C,{className:"p-3 font-italic"},"Loading SForms...");const p=((e,t)=>(s,n)=>{if(!e)return n;for(let{component:n,mapRule:o}of e)if(o(s,t))return n;return n})(t.componentMapRules,c);/*#__PURE__*/return e.createElement(Ee,{components:t.components,componentsOptions:t.componentsOptions,mapComponent:p,options:t.options},/*#__PURE__*/e.createElement(ee,{fetchTypeAheadValues:t.fetchTypeAheadValues},/*#__PURE__*/e.createElement(ue,{data:c,formQuestions:a.formQuestions,isFormValid:t.isFormValid},/*#__PURE__*/e.createElement(At,{ref:o,modalView:t.options&&t.options.modalView,mapComponent:p}))))});gt.propTypes={form:a.object.isRequired,options:a.object.isRequired,componentMapRules:a.array,components:a.object,componentsOptions:a.object,fetchTypeAheadValues:a.func,isFormValid:a.func,loader:a.element};var _t={"comment.form.placeholder":"Sem napište své komentáře (Ctrl+Enter pro potvrzení)","wizard.nav.tooltip":"Navigace na této kartě je zakázána, aby nedošlo k přehlédnutí důležitých otázek. K navigaci na tuto kartu použijte tlačítka související s formulářem."},ft={"comment.form.placeholder":"Write your comments here (Ctrl+Enter to confirm, Esc to cancel)","wizard.nav.tooltip":"Navigation to this tab is disabled to prevent overlooking important questions. Use form-related buttons to navigate to this tab instead."};const Tt=/*#__PURE__*/e.createContext({}),vt=({children:e,locale:t=navigator.language})=>{let s=ft;return t===se.LANG.cs.locale&&(s=_t),F(Tt.Provider,{value:{locale:t,lang:s},children:F(X,{locale:t,messages:s,children:e})})};export{it as Answer,de as ConfigurationContext,se as Constants,ce as FormQuestionsContext,re as FormUtils,ke as HelpIcon,vt as IntlContextProvider,fe as JsonLdFramingUtils,oe as JsonLdObjectMap,ie as JsonLdObjectUtils,ct as Question,ot as QuestionStatic,ut as WizardStep,gt as default};
2
2
  //# sourceMappingURL=s-forms.modern.js.map