@kbss-cvut/s-forms 0.8.1-alpha-3d60f13.0 → 0.8.1-alpha-e35e7ed.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 r,forwardRef as a,useImperativeHandle as i}from"react";import l from"prop-types";import"core-js/modules/es.object.assign.js";import*as c from"jsonld";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.string.includes.js";import*as u from"jsonld-utils";import"core-js/modules/es.array.sort.js";import p from"@kbss-cvut/tsort";import m from"react-dom";import{Form as d,FormGroup as h,FormControl as E,OverlayTrigger as S,Tooltip as A,Col as g,Row as _,Button as f,Badge as v,Overlay as T,FormText as N,Popover as I,ListGroup as O,ListGroupItem as C,Card as w,Accordion as L,ButtonToolbar as R,Nav as b,NavItem as y,NavLink as D,Modal as V,Alert as H}from"react-bootstrap";import{jsx as M,jsxs as U}from"react/jsx-runtime";import{IntlProvider as x,useIntl as P}from"react-intl";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 q from"react-datepicker";import{parse as k,format as j}from"date-fns";import z from"classnames";import F from"yasgui-yasqe";import"@triply/yasgui/build/yasgui.min.css";import Q from"inputmask-core";import{IntelligentTreeSelect as B}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"core-js/modules/es.parse-int.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.replace.js";import W from"javascript-time-ago";import X from"javascript-time-ago/locale/en";import G from"javascript-time-ago/locale/cs";import{motion as Y}from"framer-motion";import{Rings as K}from"react-loader-spinner";import"core-js/modules/es.string.trim.js";import"core-js/modules/es.regexp.constructor.js";function J(){return J=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},J.apply(this,arguments)}function $(e,t){if(null==e)return{};var s,n,o={},r=Object.keys(e);for(n=0;n<r.length;n++)t.indexOf(s=r[n])>=0||(o[s]=e[s]);return o}class Z{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 ee=["children"],te=/*#__PURE__*/e.createContext({}),se=s=>{let{children:n}=s,o=$(s,ee),r=[];const a=async(e,t)=>{const s=r[e];if(s&&s.length)return s;const n=await o.fetchTypeAheadValues(t);return n.length?c.frame(n,{},{}).then(t=>{const s=t["@graph"];return r.push(Object.assign({},s,{[e]:s})),s}):(Z.warn(`No data received when loading options using id ${e}`),[])},i=e=>r[e]||[],l=t(()=>({loadFormOptions:a,getOptions:i}),[a,i]);/*#__PURE__*/return e.createElement(te.Provider,J({value:l},o),n)};var ne;se.propTypes={children:l.element.isRequired,fetchTypeAheadValues:l.func};class oe{}ne=oe,oe.COLUMN_COUNT=12,oe.INPUT_LENGTH_THRESHOLD=50,oe.DATETIME_NUMBER_FORMAT="x",oe.EPOCH_MILLISECONDS="epoch-milliseconds",oe.FORM="http://onto.fel.cvut.cz/ontologies/documentation/form",oe.HAS_SUBQUESTION="http://onto.fel.cvut.cz/ontologies/documentation/has_related_question",oe.HAS_ANSWER="http://onto.fel.cvut.cz/ontologies/documentation/has_answer",oe.HAS_OPTION="http://onto.fel.cvut.cz/ontologies/form/has-possible-value",oe.HAS_OPTIONS_QUERY="http://onto.fel.cvut.cz/ontologies/form/has-possible-values-query",oe.HAS_VALUE_TYPE="http://onto.fel.cvut.cz/ontologies/form/has-value-type",oe.IS_DISABLED="http://onto.fel.cvut.cz/ontologies/aviation/form-376/is-disabled",oe.INPUT_MASK="http://onto.fel.cvut.cz/ontologies/form/has-input-mask",oe.LAYOUT_CLASS="http://onto.fel.cvut.cz/ontologies/form-layout/has-layout-class",oe.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"]},oe.HAS_INITIAL_INPUT_LENGTH="http://onto.fel.cvut.cz/ontologies/form-layout/has-initial-input-length",oe.VALUE_TYPE_CODE="code",oe.VALUE_TYPE_TEXT="text",oe.GENERATED_ROW_SIZE=1,oe.HAS_QUESTION_ORIGIN="http://onto.fel.cvut.cz/ontologies/form/has-question-origin",oe.HAS_ANSWER_ORIGIN="http://onto.fel.cvut.cz/ontologies/form/has-answer-origin",oe.HAS_DATA_VALUE="http://onto.fel.cvut.cz/ontologies/documentation/has_data_value",oe.HAS_OBJECT_VALUE="http://onto.fel.cvut.cz/ontologies/documentation/has_object_value",oe.HELP_DESCRIPTION="http://purl.org/dc/elements/1.1/description",oe.SOURCE="http://purl.org/dc/elements/1.1/source",oe.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"},oe.STEP="http://onto.fel.cvut.cz/ontologies/form/step",oe.PATTERN="http://onto.fel.cvut.cz/ontologies/form/pattern",oe.ACCEPTS_ANSWER_VALUE="http://onto.fel.cvut.cz/ontologies/form/accepts-answer-value",oe.ACCEPTS="http://onto.fel.cvut.cz/ontologies/form/accepts",oe.HAS_DATATYPE="http://onto.fel.cvut.cz/ontologies/form/has-datatype",oe.HAS_LAYOUT_CLASS="http://onto.fel.cvut.cz/ontologies/form/has-layout-class",oe.HAS_POSSIBLE_VALUES_QUERY="http://onto.fel.cvut.cz/ontologies/form/has-possible-values-query",oe.HAS_REQUIRED_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-required-value",oe.HAS_TESTED_QUESTION="http://onto.fel.cvut.cz/ontologies/form/has-tested-question",oe.HAS_TESTED_FORM="http://onto.fel.cvut.cz/ontologies/form/has-tested-form",oe.HAS_UNIT="http://onto.fel.cvut.cz/ontologies/form/has-unit",oe.HAS_VALID_ANSWER="http://onto.fel.cvut.cz/ontologies/form/has-valid-answer",oe.IS_RELEVANT_IF="http://onto.fel.cvut.cz/ontologies/form/is-relevant-if",oe.ACCEPTS_VALIDATION_VALUE="http://onto.fel.cvut.cz/ontologies/form/accepts-validation-value",oe.HAS_VALIDATION_MESSAGE="http://onto.fel.cvut.cz/ontologies/form/has-validation-message",oe.NEGATIVE_CONDITION="http://onto.fel.cvut.cz/ontologies/form/negative-condition",oe.REQUIRES_ANSWER="http://onto.fel.cvut.cz/ontologies/form/requires-answer",oe.USED_ONLY_FOR_COMPLETENESS="http://onto.fel.cvut.cz/ontologies/form/used-only-for-completeness",oe.REQUIRES_ANSWER_DESCRIPTION_IF="http://onto.fel.cvut.cz/ontologies/form/requires-answer-description-if",oe.REQUIRES_ANSWER_IF="http://onto.fel.cvut.cz/ontologies/form/requires-answer-if",oe.HAS_PRECEDING_QUESTION="http://onto.fel.cvut.cz/ontologies/form/has-preceding-question",oe.HAS_PRECEDING_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-preceding-value",oe.HAS_MEDIA_CONTENT="http://onto.fel.cvut.cz/ontologies/form/has-media-content",oe.CONDITION="http://onto.fel.cvut.cz/ontologies/form/condition",oe.OR_CONDITION="http://onto.fel.cvut.cz/ontologies/form/or-condition",oe.HAS_SUB_CONDITION="http://onto.fel.cvut.cz/ontologies/form/has-sub-condition",oe.HAS_PATTERN="http://onto.fel.cvut.cz/ontologies/form-lt/has-pattern",oe.HAS_DECLARED_PREFIX="http://onto.fel.cvut.cz/ontologies/form-spin/has-declared-prefix",oe.PREFIX="http://www.w3.org/ns/shacl#prefix",oe.NAMESPACE="http://www.w3.org/ns/shacl#namespace",oe.HAS_COMMENT="http://onto.fel.cvut.cz/ontologies/form/has-comment",oe.HAS_COMMENT_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-comment-value",oe.HAS_AUTHOR="http://onto.fel.cvut.cz/ontologies/form/has-author",oe.HAS_TIMESTAMP="http://onto.fel.cvut.cz/ontologies/form/has-timestamp",oe.TIME_FORMAT="http://onto.fel.cvut.cz/ontologies/form/time-format",oe.DATE_FORMAT="http://onto.fel.cvut.cz/ontologies/form/date-format",oe.DATETIME_FORMAT="http://onto.fel.cvut.cz/ontologies/form/datetime-format",oe.TIMESTAMP_FORMAT="http://onto.fel.cvut.cz/ontologies/form/timestamp-format",oe.NOT_ANSWERED_QUESTION="http://onto.fel.cvut.cz/ontologies/form/not-answered-question",oe.ANSWERED_QUESTION="http://onto.fel.cvut.cz/ontologies/form/answered-question",oe.HAS_VALIDATION_SEVERITY="http://onto.fel.cvut.cz/ontologies/form/has-validation-severity",oe.RDFS_LABEL=u.RDFS_LABEL,oe.RDFS_COMMENT=u.RDFS_COMMENT,oe.DEFAULT_HAS_CHILD=u.DEFAULT_HAS_CHILD,oe.BROADER="http://www.w3.org/2004/02/skos/core#broader",oe.HAS_NON_SELECTABLE_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-non-selectable-value",oe.PROVIDES_DEREFERENCEABLE_ANSWER_VALUES="http://onto.fel.cvut.cz/ontologies/form/provides-dereferenceable-answer-values",oe.ICONS={QUESTION_COMMENTS:"questionComments",QUESTION_HELP:"questionHelp",QUESTION_LINK:"questionLink"},oe.ICON_BEHAVIOR={ENABLE:"enable",DISABLE:"disable",ON_HOVER:"onHover"},oe.DEFAULT_OPTIONS={icons:[{id:ne.ICONS.QUESTION_HELP,behavior:ne.ICON_BEHAVIOR.ENABLE},{id:ne.ICONS.QUESTION_COMMENTS,behavior:ne.ICON_BEHAVIOR.ON_HOVER},{id:ne.ICONS.QUESTION_LINK,behavior:ne.ICON_BEHAVIOR.ON_HOVER}]},oe.LANG={cs:{locale:"cs",label:"Čestina"},en:{locale:"en",label:"English"}},oe.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 re{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 r=re.asArray(t[oe.HAS_SUBQUESTION]);if(n)for(let t of r){let s=re.findQuestionById(e,t,!0,!1,!1);if(s)return s}if(o)for(let t of r){let s=re.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 ae{static putObject(e,t){ae.objectMap[e]=t}static getObject(e){return ae.objectMap[e]}}ae.objectMap={};class ie{static getFirstObject(e,t){const s=c.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"])))||c.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=p(),n={};for(let o=0;o<e.length;o++){let r=e[o]["@id"];s.add(r),n[r]=e[o],re.asArray(e[o][t]).map(e=>"object"==typeof e?e["@id"]:e).map(e=>[e,r]).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=u.getLocalized(t[u.RDFS_LABEL],e),o=u.getLocalized(s[u.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 le{static isForm(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.FORM)}static isWizardStep(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.WIZARD_STEP)}static isSection(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.QUESTION_SECTION)}static isAnswerable(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.ANSWERABLE)}static isTypeahead(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.QUESTION_TYPEAHEAD)}static getPossibleValuesQuery(e){return u.getJsonAttValue(e,oe.HAS_OPTIONS_QUERY)}static isDisabled(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.DISABLED)}static isHidden(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.HIDDEN)}static isTextarea(e,t){return t&&t.length>oe.INPUT_LENGTH_THRESHOLD&&!le.isTypeahead(e)||u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.TEXTAREA)}static isText(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.TEXT)}static isCalendar(e){return le.isDate(e)||le.isTime(e)||le.isDateTime(e)}static isDate(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.DATE)}static isTime(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.TIME)}static isDateTime(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.DATETIME)}static isTimestamp(e){return u.hasValue(e,oe.TIMESTAMP_FORMAT,oe.EPOCH_MILLISECONDS)}static isCheckbox(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.CHECKBOX)}static isMaskedInput(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.MASKED_INPUT)}static isSparqlInput(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.SPARQL)}static isTurtleInput(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.TURTLE)}static isCollapsed(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.COLLAPSED)}static isEmphasised(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.EMPHASISED)}static getCategory(e){return oe.LAYOUT.CATEGORY.find(t=>u.hasValue(e,oe.LAYOUT_CLASS,t))}static resolveValue(e){return e?e[oe.HAS_OBJECT_VALUE]?e[oe.HAS_OBJECT_VALUE]["@id"]:u.getJsonAttValue(e,oe.HAS_DATA_VALUE):null}static resolveValueObject(e){return e?e[oe.HAS_OBJECT_VALUE]?re.asArray(e[oe.HAS_OBJECT_VALUE])[0]:e[oe.HAS_DATA_VALUE]?re.asArray(e[oe.HAS_DATA_VALUE])[0]:null:null}static isRelevant(e){if(!e[oe.IS_RELEVANT_IF])return!0;for(let t of re.asArray(e[oe.IS_RELEVANT_IF]))if(!le.testCondition(t))return!1;return!0}static hasValidationLogic(e){return!!(e[oe.REQUIRES_ANSWER]||e[oe.REQUIRES_ANSWER_IF]||e[oe.PATTERN]||this.containsXSDProperty(e))}static isValid(e){if(!1===e[oe.HAS_VALID_ANSWER])return!1;for(const t of re.asArray(e[oe.HAS_SUBQUESTION]))if(!1===this.isValid(t))return!1;return!0}static testOrCondition(e){const t=e[oe.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[oe.ACCEPTS_VALIDATION_VALUE],s=e[oe.ACCEPTS_ANSWER_VALUE],n=e[oe.ACCEPTS],o=e[oe.HAS_TESTED_QUESTION];let r;if(e[oe.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=re.asArray(n);if(1!==e.length&&console.warn("Support for multiple accepts values is not implemented !"),e[0]["@id"]===oe.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=re.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 re.asArray(o)){if(r=ae.getObject(e["@id"]),void 0===r)return console.warn("Questions is not loaded in an object map."),!0;if(!1===this.isValid(r))return!1}return!0}if(s&&o){r=ae.getObject(o["@id"]);for(const e of re.asArray(s)){if(!r)return console.warn("Question is not defined."),!0;if(!r.hasOwnProperty(oe.HAS_ANSWER))return!1;const t=c.getValues(r,oe.HAS_ANSWER);if(0===t.length)return!1;const s=le.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 re.asArray(e).map(e=>{const s=ae.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(oe.HAS_ANSWER)){const t=c.getValues(e,oe.HAS_ANSWER);if(t.length){const e=le.resolveValueObject(t[0]);if(e&&(e["@value"]||e["@id"]))return!0}}for(const t of re.asArray(e[oe.HAS_SUBQUESTION]))if(le.hasAnswer(t))return!0;return!1}static getAnswerValue(e){if(!e)return null;if(e.hasOwnProperty(oe.HAS_ANSWER)){const t=c.getValues(e,oe.HAS_ANSWER);if(t.length){const e=le.resolveValueObject(t[0]);if(e&&(e["@value"]||e["@id"]))return e["@value"]||e["@id"]}}for(const t of re.asArray(e[oe.HAS_SUBQUESTION])){const e=le.getAnswerValue(t);if(e)return e}return null}static resolveDateTimeFormat(e,t,s){const n=le.isDate(e),o=le.isTime(e),r=le.isDateTime(e);switch(!0){case n:return e[oe.DATE_FORMAT]||s.dateFormat;case o:return e[oe.TIME_FORMAT]||s.timeFormat;case r:return e[oe.DATETIME_FORMAT]||s.dateTimeFormat;default:return null}}static dfsTraverseQuestionTree(e,t,s=(()=>{})){function n(e){t(e),re.asArray(e[oe.HAS_SUBQUESTION]).forEach(e=>{n(e)}),s(e)}e.forEach(e=>{n(e)})}static getFormSpecification(e){let t=-1;const s="..";let n="";return le.dfsTraverseQuestionTree(e,function(e){t+=1;const o=" ".repeat(t);let r="";e[oe.REQUIRES_ANSWER]&&!e[oe.USED_ONLY_FOR_COMPLETENESS]?r=o+s+"required: "+e[oe.REQUIRES_ANSWER]+"\n":e[oe.USED_ONLY_FOR_COMPLETENESS]&&(r=o+s+"required only for completeness: "+e[oe.USED_ONLY_FOR_COMPLETENESS]+"\n"),n+=o+e["http://www.w3.org/2000/01/rdf-schema#label"]+"\n",n+=e[oe.HELP_DESCRIPTION]?o+s+"description: "+e[oe.HELP_DESCRIPTION]+"\n":"",n+=r,n+=e[oe.PATTERN]?o+s+"pattern: "+e[oe.PATTERN]+"\n":"",n+=e[oe.INPUT_MASK]?o+s+"mask: "+e[oe.INPUT_MASK]+"\n":"",n+=e[oe.XSD.MAX_INCLUSIVE]?o+s+"This field should be a number equal or lower to "+e[oe.XSD.MAX_INCLUSIVE]+"\n":"",n+=e[oe.XSD.MIN_INCLUSIVE]?o+s+"This field must be greater or equal to "+e[oe.XSD.MIN_INCLUSIVE]+"\n":"",n+=e[oe.HAS_VALIDATION_MESSAGE]?o+s+"validation-message: "+e[oe.HAS_VALIDATION_MESSAGE]+"\n":"",n+="\n"},function(){t-=1}),n}static containsXSDProperty(e){const t=Object.keys(e),s=Object.values(oe.XSD);for(const e of s)if(t.includes(e))return!0;return!1}static getInputMask(e){if(e[oe.INPUT_MASK])return e[oe.INPUT_MASK]}}const ce={},ue=[],pe=/*#__PURE__*/e.createContext({}),me=o=>{const[r,a]=s(o.data||ce),[i,l]=s(o.formQuestions||ue);n(()=>{if(o.isFormValid){const e=le.isValid(r);o.isFormValid(e)}},[]),n(()=>{a(o.data||ce)},[i]);const c=e=>{e&&a(Object.assign({},r,e))},u=(e,t)=>{if(!(!t||e<0||e>=i.length)){if("object"==typeof t){const s=[...i];s[e]=Object.assign({},s[e],t),l(s)}if(Array.isArray(t)&&l(t),o.isFormValid){const e=le.isValid(r);o.isFormValid(e)}}},p=()=>r,m=e=>null==e?i:i[e],d=t(()=>({updateData:c,updateFormQuestionsData:u,getData:p,getFormQuestionsData:m}),[m,p]);/*#__PURE__*/return e.createElement(pe.Provider,J({value:d},o),o.children)};me.propTypes={children:l.element.isRequired,data:l.object.isRequired,formQuestions:l.array.isRequired,isFormValid:l.func};class de extends e.Component{constructor(e){super(e),this.state={cursorPosition:0}}focus(){m.findDOMNode(this.input).focus()}getInputDOMNode(){return m.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(d.Group,{size:"small",controlId:Math.floor(Math.random()*Number.MAX_SAFE_INTEGER),className:"mb-3"},/*#__PURE__*/e.createElement(d.Check,J({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(h,{size:"small",className:"mb-3"},/*#__PURE__*/e.createElement(d.Check,J({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(h,{size:"small",className:"mb-3"},this._renderLabel(),/*#__PURE__*/e.createElement(E,J({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(d.Label,null,this.props.label):null}_renderTextArea(){/*#__PURE__*/return e.createElement(h,{size:"small",className:"mb-3"},this._renderLabel(),/*#__PURE__*/e.createElement(E,J({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(h,{size:"small",className:"mb-3"},this._renderLabel(),/*#__PURE__*/e.createElement(E,J({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)}}de.propTypes={type:l.string,label:l.object,value:l.any,onChange:l.func,help:l.string,validation:l.object,placeholder:l.string},de.defaultProps={type:"text"};const he=["children"],Ee=/*#__PURE__*/e.createContext({}),Se={components:{inputComponent:de},componentsOptions:{dateTimeAnswer:{dateFormat:"yyyy-MM-dd",timeFormat:"HH:mm",dateTimeFormat:"yyyy-MM-dd HH:mm:ss"},readOnly:!1},options:{intl:{locale:"en"},modalView:!1,modalProps:{},horizontalWizardNav:!0,wizardStepButtons:!0,enableWizardStepSkip:!0,startingStep:0}},Ae=s=>{let{children:n}=s,o=$(s,he);const r=t(()=>({inputComponent:o.components&&o.components.inputComponent||Se.components.inputComponent,componentsOptions:Object.assign({},Se.componentsOptions,o.componentsOptions),options:Object.assign({},Se.options,o.options),mapComponent:o.mapComponent}),[o]);/*#__PURE__*/return e.createElement(Ee.Provider,{value:r},n)};Ae.propTypes={children:l.element.isRequired,components:l.object,mapComponent:l.func,options:l.object};var ge={"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.","wizard.next":"Další","wizard.previous":"Předchozí","section.expand":"Rozbalit","section.collapse":"Sbalit","validation.required":"Toto pole je povinné.","validation.required_only_for_completeness":"Toto pole je povinné pro vyplnění formuláře.","validation.invalid":"Toto pole je neplatné.","validation.check":"Toto pole musí být zkontrolováno.","validation.lower_or_equal":"Toto pole by mělo být číslo rovné nebo nižší než ","validation.greater_or_equal":"Toto pole musí být větší nebo rovno ","error.default_message":"Něco se pokazilo.","error.view_details":"Zobrazit podrobnosti o chybě","comment.unknownAuthor":"Neznámý autor"},_e={"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.","wizard.next":"Next","wizard.previous":"Previous","section.expand":"Expand","section.collapse":"Collapse","validation.required":"This field is required.","validation.required_only_for_completeness":"This field is required to complete the form.","validation.invalid":"This field is invalid.","validation.check":"This field must be checked.","validation.lower_or_equal":"This field should be a number equal or lower to ","validation.greater_or_equal":"This field must be greater or equal to ","error.default_message":"Something went wrong.","error.view_details":"View Error Details","comment.unknownAuthor":"Unknown Author"};const fe=/*#__PURE__*/e.createContext({}),ve=({children:e,locale:t=navigator.language})=>{let s=_e;return t===oe.LANG.cs.locale&&(s=ge),M(fe.Provider,{value:{locale:t,lang:s},children:M(x,{locale:t,messages:s,children:e})})};var Te,Ne={"@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 Ie{static generateForm(){return JSON.parse(JSON.stringify(Ne))}}const Oe={root:{[oe.HAS_LAYOUT_CLASS]:oe.FORM},expandProperties:[oe.HAS_SUBQUESTION,oe.IS_RELEVANT_IF,oe.HAS_ANSWER,oe.HAS_DECLARED_PREFIX,oe.HAS_OPTION,oe.HAS_COMMENT]};class Ce{static customFrame(e,t,s){if(arguments.length<2)return c.nextTick(function(){s(new TypeError("Could not frame, too few arguments."))});null===t&&(t=Oe),c.flatten(e,null,null,(e,t)=>{})}static expandStructure(e){let t;const s={};e["@graph"].forEach(e=>{s[e["@id"]]=e,le.isForm(e)&&(t=e)});try{this._expandGraph(t,Oe,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,r;t.expandProperties.forEach(a=>{if(e.hasOwnProperty(a)){e[a]=re.asArray(e[a]),n=e[a];for(let e=0;e<n.length;e++)r=this._getId(n[e]),o=s[r],void 0!==o?(n[e]=o,this._expandGraph(o,t,s)):console.warn("object with @id "+r+" was not defined in input data.")}})}static _getId(e){return"string"==typeof e?e:e["@id"]}}Te=Ce,Ce.compressStructure=e=>{let t=[],s=new Set;return t=Te._compressGraph(e,t,s),t=t.sort((e,t)=>e["@id"]&&t["@id"]?e["@id"].localeCompare(t["@id"]):0),t},Ce._compressGraph=(e,t,s)=>(s.has(e["@id"])||(t.push(e),s.add(e["@id"])),Oe.expandProperties.forEach(n=>{if(e.hasOwnProperty(n)){const o=e[n];for(let r=0;r<o.length;r++){const a=o[r];void 0!==a&&(o[r]=a,t=Te._compressGraph(a,t,s),e[n][r]={"@id":a["@id"]})}}}),t);class we{static constructDefaultForm(e){const t=Ie.generateForm();return we._constructFormQuestions(t,e)}static async constructForm(e,t){let s,n;return c.flatten(e,{}).then(e=>{try{const[o,r]=we._constructFormQuestions(e,t);n=r,s={formQuestions:o}}catch(e){console.error("Error while constructing form questions from the provided structure:",e)}if(!n){const[e,o]=we.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,r=[];if(void 0!==e["@graph"][0]["@id"]?(o=Ce.expandStructure(e),Object.keys(o).map(e=>{ae.putObject(e,o[e])})):console.warn("default form is constructed."),s=e["@graph"].find(e=>le.isForm(e)),n=s[oe.HAS_SUBQUESTION],!n)throw Z.error("Could not find any questions in the received data."),"No questions in the form";return r=n.filter(e=>!(!le.isWizardStep(e)||le.isHidden(e))||(Z.warn("Item is not a wizard step: "+e),!1)),r.length||(Z.log("Could not find any wizard steps in the received data. Building form without steps"),s[oe.HAS_SUBQUESTION].forEach(e=>r.push(e))),r.sort(ie.getCompareLocalizedLabelFunction(t)),ie.orderPreservingToplogicalSort(r,oe.HAS_PRECEDING_QUESTION),[r,{root:s}]}}class Le{static buildQuestionAnswerModel(e,t){const s={subQuestions:[]};let n;if(e&&(s.uri=e.root["@id"],s.origin=u.getJsonAttValue(e.root,oe.HAS_QUESTION_ORIGIN,"@id")),t)for(let e=0;e<t.length;e++)n=Le.processQuestionAnswerHierarchy(t[e]),n&&s.subQuestions.push(n);return s}static processQuestionAnswerHierarchy(e){return e?Le._processQuestion(e):null}static _processQuestion(e){const t={};if(t.uri=e["@id"],t.origin=u.getJsonAttValue(e,oe.HAS_QUESTION_ORIGIN,"@id"),e[oe.HAS_SUBQUESTION]){t.subQuestions=[];for(let s=0;s<e[oe.HAS_SUBQUESTION].length;s++)t.subQuestions.push(Le._processQuestion(e[oe.HAS_SUBQUESTION][s]))}if(e[oe.HAS_ANSWER]){t.answers=[],Array.isArray(e[oe.HAS_ANSWER])||(e[oe.HAS_ANSWER]=[e[oe.HAS_ANSWER]]);for(let s=0;s<e[oe.HAS_ANSWER].length;s++)t.answers.push(Le.processAnswer(e[oe.HAS_ANSWER][s]))}if(e[oe.HAS_COMMENT]){t.comments=[],Array.isArray(e[oe.HAS_COMMENT])||(e[oe.HAS_COMMENT]=[e[oe.HAS_COMMENT]]);for(let s=0;s<e[oe.HAS_COMMENT].length;s++)t.comments.push(Le.processComment(e[oe.HAS_COMMENT][s]))}return t}static processComment(e){const t={};return t.author=u.getJsonAttValue(e,oe.HAS_AUTHOR,"@id"),t.value=u.getJsonAttValue(e,oe.HAS_COMMENT_VALUE),t.timestamp=u.getJsonAttValue(e,oe.HAS_TIMESTAMP,"@id"),t}static processAnswer(e){const t={};return t.uri=e["@id"],t.origin=u.getJsonAttValue(e,oe.HAS_ANSWER_ORIGIN,"@id"),e[oe.HAS_OBJECT_VALUE]?t.codeValue=u.getJsonAttValue(e,oe.HAS_OBJECT_VALUE,"@id"):t.textValue=u.getJsonAttValue(e,oe.HAS_DATA_VALUE),t}static generateAnswer(e){const t={};return t[oe.HAS_DATA_VALUE]="",t}}const Re=t=>{const{inputComponent:s,componentsOptions:n}=o(Ee);/*#__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||le.isDisabled(t.question)})};Re.propTypes={question:l.object.isRequired,label:l.object.isRequired,title:l.string,value:l.oneOfType([l.string,l.bool]),onChange:l.func.isRequired,mouseHover:l.bool,validation:l.object};const be=t=>{const{componentsOptions:r}=o(Ee),[a,i]=s(null),[l,c]=s(""),u=le.resolveDateTimeFormat(t.question,t.value,r.dateTimeAnswer),p=le.isDate(t.question),m=le.isTime(t.question),E=le.isTimestamp(t.question);n(()=>{const e=S(t.value);e?i(e):(i(null),c(`Invalid date value ${t.value} of question ${t.question["@id"]}.`),console.error(l))},[t.value,u]);const S=e=>{if(!e)return null;const t=E?new Date(e):k(e,u,new Date);return isNaN(t.getTime())?null:t};/*#__PURE__*/return e.createElement(h,{size:"small",className:"mb-3"},/*#__PURE__*/e.createElement(d.Label,{className:"w-100"},t.label),/*#__PURE__*/e.createElement(q,{selected:a,placeholderText:u,onChange:e=>{i(e);const s=e?E?e.getTime():j(e,u):"";t.onChange(s)},showTimeSelect:!p,showTimeSelectOnly:m,timeFormat:"HH:mm",timeIntervals:1,timeCaption:"Time",dateFormat:u,className:z("form-control",t.validation.classname),disabled:r.readOnly||le.isDisabled(t.question)}),t.validation.message)};be.propTypes={question:l.object.isRequired,label:l.object.isRequired,title:l.string,value:l.oneOfType([l.string,l.number]),onChange:l.func.isRequired,validation:l.object};const ye=[oe.XSD.INT,oe.XSD.INTEGER,oe.XSD.NON_NEGATIVE_INTEGER,oe.XSD.NON_POSITIVE_INTEGER,oe.XSD.NEGATIVE_INTEGER,oe.XSD.POSITIVE_INTEGER,oe.XSD.FLOAT,oe.XSD.POSITIVE_FLOAT,oe.XSD.NEGATIVE_FLOAT],De={};De[oe.XSD.NON_NEGATIVE_INTEGER]={min:0},De[oe.XSD.NON_POSITIVE_INTEGER]={max:0},De[oe.XSD.NEGATIVE_INTEGER]={max:-1},De[oe.XSD.POSITIVE_INTEGER]={min:1};const Ve={"string-2":"prefixed",atom:"var"};class He{static _resolveInputType(e,t){return le.isSparqlInput(e)||le.isTurtleInput(e)||le.isTextarea(e,t)?"textarea":He._isNumeric(e)?"number":"text"}static _isNumeric(e){for(let t=0,s=ye.length;t<s;t++)if(u.hasValue(e,oe.HAS_DATATYPE,ye[t]))return!0;return!1}static resolveInputProperties(e,t,s){let n={};switch(n.type=He._resolveInputType(e,t),n.type){case"textarea":n.rows=5;break;case"number":n=Object.assign({},n,He._resolveNumberRestrictions(e),this._resolveStepRestriction(e))}return n.disabled=s.readOnly||le.isDisabled(e),n}static _resolveStepRestriction(e){let t={};return void 0!==e[oe.STEP]&&(t.step=u.getJsonAttValue(e,oe.STEP)),t}static _resolveNumberRestrictions(e){let t={};return Object.getOwnPropertyNames(De).forEach(s=>{u.hasValue(e,oe.HAS_DATATYPE,s)&&(t=Object.assign({},t,De[s]))}),void 0!==e[oe.XSD.MIN_INCLUSIVE]&&(t.min=e[oe.XSD.MIN_INCLUSIVE]),void 0!==e[oe.XSD.MIN_EXCLUSIVE]&&(t.min=e[oe.XSD.MIN_EXCLUSIVE]+1),void 0!==e[oe.XSD.MAX_EXCLUSIVE]&&(t.max=e[oe.XSD.MAX_EXCLUSIVE]-1),void 0!==e[oe.XSD.MAX_INCLUSIVE]&&(t.max=e[oe.XSD.MAX_INCLUSIVE]),t}static _preventCharacterInput(e,t){"number"!==He._resolveInputType(t)||e.key>="0"&&e.key<="9"||["Backspace","Delete","ArrowLeft","ArrowRight","-","Minus","NumpadSubtract",".","Period"].includes(e.key)||e.preventDefault()}}const Me=t=>{const{inputComponent:s,componentsOptions:n}=o(Ee),r=t.question,a=t.answer;let i=t.value;return a[oe.HAS_OBJECT_VALUE]&&a[oe.HAS_OBJECT_VALUE][u.RDFS_LABEL]&&(i=u.getJsonAttValue(a[oe.HAS_OBJECT_VALUE],u.RDFS_LABEL)),/*#__PURE__*/e.createElement(s,Object.assign({},He.resolveInputProperties(r,i,n),{validation:t.validation,label:t.label,title:t.title,value:null==i?"":i,placeholder:le.getInputMask(r),onKeyPress:e=>He._preventCharacterInput(e,r),onChange:e=>{t.onChange(e.target.value),(t.sparql||t.turtle)&&(void 0).hide()},onFocus:e=>{if(t.sparql){const s=F.fromTextArea(e.target);s.setValue(i),s.on("change",()=>{t.onChange(s.getValue())}),F.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"===Ve[o.type]){const r=o.string.indexOf(":");if(-1!==r){const a=e.getPreviousNonWsToken(n.line,o).string.toUpperCase(),i=e.getTokenAt({line:n.line,ch:o.start});if("PREFIX"!==a&&("ws"===i.type||null==i.type)){const n=o.string.substring(0,r+1);if(null==e.getPrefixesFromQuery()[n.slice(0,-1)])if(t.question[oe.HAS_DECLARED_PREFIX]&&t.question[oe.HAS_DECLARED_PREFIX].filter(e=>e[oe.PREFIX]===n.slice(0,-1)).length){const s=t.question[oe.HAS_DECLARED_PREFIX].filter(e=>e[oe.PREFIX]===n.slice(0,-1)),o={};o[s[0][oe.PREFIX]]=s[0][oe.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=F.fromTextArea(e.target);s.setValue(i),s.on("change",()=>{t.onChange(s.getValue())})}}}))};Me.propTypes={question:l.object.isRequired,answer:l.object.isRequired,label:l.object.isRequired,title:l.string,value:l.oneOfType([l.string,l.number]),onChange:l.func.isRequired,validation:l.object};const Ue={D:"1",M:"1",Y:"1",h:"1",m:"1",s:"1"};class xe{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+=Ue[t]?Ue[t]:t;return s}}const Pe=["size","placeholder"];function qe(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 ke extends e.Component{constructor(e){super(e),this._updatePattern=e=>{this.mask.setPattern(xe.mapMask(e.mask),{value:this.mask.getRawValue(),selection:qe(this.input)})},this._updateMaskSelection=()=>{this.mask.selection=qe(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 Q({pattern:xe.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(xe.mapMask(this.props.mask),{value:this.props.value}):this.mask.setPattern(xe.mapMask(this.props.mask),{value:this.mask.getRawValue()}):e.mask!==this.props.mask?this.mask.setPattern(xe.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=$(t,Pe),r=this.mask.pattern.length;/*#__PURE__*/return e.createElement(this.context.inputComponent,Object.assign({},o,{ref:e=>{e&&(this.input=e.input?m.findDOMNode(e.input):e)},maxLength:r,onChange:this._onChange,onKeyDown:this._onKeyDown,onKeyPress:this._onKeyPress,onPaste:this._onPaste,placeholder:n||this.mask.emptyValue,size:s||r,value:this._getDisplayValue(),type:"text"}))}}ke.contextType=Ee,ke.propTypes={mask:l.string.isRequired},ke.defaultProps={value:""};const je=t=>{const{componentsOptions:s}=o(Ee),n=t.question,r=t.value,a=u.getJsonAttValue(n,oe.INPUT_MASK);return a?/*#__PURE__*/e.createElement(ke,{mask:a,value:r,label:t.label,title:t.title,placeholder:a,onChange:e=>t.onChange(e.target.value),disabled:s.readOnly||le.isDisabled(n),validation:t.validation}):(Z.warn("Input mask not provided. Falling back to regular input."),/*#__PURE__*/e.createElement(Me,t))};je.propTypes={question:l.object.isRequired,answer:l.object.isRequired,label:l.object.isRequired,title:l.string,value:l.oneOfType([l.string,l.number]),onChange:l.func.isRequired,validation:l.object};class ze extends e.Component{_generateSelectOptions(t){const s=[];t.sort(function(e,t){const s=u.getJsonAttValue(e,oe.RDFS_LABEL),n=u.getJsonAttValue(t,oe.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:u.getJsonAttValue(t[n],oe.RDFS_LABEL),key:"opt-"+n},u.getJsonAttValue(t[n],oe.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||le.isDisabled(t)},this._generateSelectOptions(t[oe.HAS_OPTION]))}}ze.contextType=Ee,ze.propTypes={question:l.object.isRequired,label:l.object.isRequired,title:l.string,value:l.string,onChange:l.func.isRequired,validation:l.object};const Fe=(e,t)=>void 0!==e&&e.length?(e.sort(ie.getCompareLocalizedLabelFunction(t)),ie.orderPreservingToplogicalSort(e,oe.HAS_PRECEDING_VALUE),e):[],Qe=t=>{const r=re.getStringHash(le.getPossibleValuesQuery(t.question)),a=o(te),i=o(Ee),l=P(),[c,p]=s(!0),[m,E]=s(Fe(t.options,l));n(()=>{let e=!1;const s=t.question;return!s[oe.HAS_OPTION]&&le.getPossibleValuesQuery(s)?async function(){try{const t=await a.loadFormOptions(r,le.getPossibleValuesQuery(s));e||(p(!1),S(t))}catch(e){Z.error(`An error has occurred during loadFormOptions for query hash: ${r}`)}}():(p(!1),S(s[oe.HAS_OPTION])),()=>{e=!0}},[r,a,t.question,l]);const S=e=>{if(!e)return[];e=Fe(e,l);const t={},s=[];for(let n of e){let e=u.getLocalized(n[oe.RDFS_LABEL],l),o=u.getLocalized(n[oe.RDFS_COMMENT],l);t[n["@id"]]={id:n["@id"],value:n["@id"],label:e,description:o,children:[]};for(let e of re.asArray(n[oe.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=re.findKeyInObjects(m,["name","value"]),g=re.findKeyInObjects(m,["name","label"]);/*#__PURE__*/return e.createElement(h,{size:"small",className:"mb-3"},/*#__PURE__*/e.createElement(d.Label,null,t.label),/*#__PURE__*/e.createElement(B,{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[oe.PROVIDES_DEREFERENCEABLE_ANSWER_VALUES]?t=>/*#__PURE__*/e.createElement(e.Fragment,null,t):null,value:m.find(e=>e.id===t.value)||null,multi:!1,options:m,isSearchable:!0,isLoading:c,isClearable:!0,renderAsTree:!0,optionLeftOffset:5,isDisabled:c||i.componentsOptions.readOnly||le.isDisabled(t.question),onChange:e=>{t.onChange(e?e.id:null)},titleKey:"description"}),t.validation.message)};Qe.propTypes={question:l.object.isRequired,answer:l.object.isRequired,label:l.oneOfType([l.string,l.object]).isRequired,title:l.string,value:l.string,onChange:l.func.isRequired,validation:l.object};const Be=({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"})),We=({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"})),Xe=()=>/*#__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"})),Ge=()=>/*#__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"})),Ye=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(S,{overlay:t.show?/*#__PURE__*/e.createElement(A,{className:"tooltip-content",id:t.id},t.tooltipContent):/*#__PURE__*/e.createElement("span",null),placement:t.overlayPlacement||n},/*#__PURE__*/e.createElement("span",null,t.children)))};Ye.propTypes={tooltipContent:l.oneOfType([l.object.isRequired,l.string.isRequired]),id:l.string.isRequired,overlayPlacement:l.string,absolutePosition:l.bool,show:l.bool},Ye.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(Ye,{id:"help-icon-tooltip-",overlayPlacement:t.overlayPlacement||n,absolutePosition:t.absolutePosition,tooltipContent:t.text},/*#__PURE__*/e.createElement(Ge,{className:t.iconClass})))};Ke.propTypes={text:l.string.isRequired,iconClassContainer:l.string,iconClass:l.string,overlayPlacement:l.string,absolutePosition:l.bool},Ke.defaultProps={iconClassContainer:"",iconClass:"",absolutePosition:!0};const Je=()=>/*#__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"})),$e=t=>/*#__PURE__*/e.createElement(Ye,{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(Je,{className:t.iconClass})));$e.propTypes={url:l.oneOfType([l.string.isRequired,l.object.isRequired]),iconClassContainer:l.string,iconClass:l.string,overlayPlacement:l.string,absolutePosition:l.bool},$e.defaultProps={iconClassContainer:"",iconClass:"",absolutePosition:!0};const Ze=()=>/*#__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"})),et=()=>/*#__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"})))),tt=t=>{const{options:n}=o(Ee),[r,a]=s(!1),[i,l]=s(!1),c=P();W.addLocale(G),W.addLocale(X),W.setDefaultLocale(oe.LANG.en.locale);const u=new W(c.locale),p=()=>{if(n&&n.users){const e=n.users.find(e=>e.id===n.currentUser);if(t.author)return e.label?e.label:m()}return c.formatMessage({id:"comment.unknownAuthor"})},m=()=>t.author["@id"].replace(/.*[#\/]/,"... "),d=()=>{a(!r)};/*#__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:d,onMouseLeave:d},/*#__PURE__*/e.createElement(e.Fragment,null,r?/*#__PURE__*/e.createElement(e.Fragment,null,p(),/*#__PURE__*/e.createElement($e,{iconClassContainer:"emphasise-on-relevant-icon",url:t.author?Object.values(t.author).toString():c.formatMessage({id:"comment.unknownAuthor"})})):p())),/*#__PURE__*/e.createElement("div",{className:"col-auto text-muted comment-timestamp"},/*#__PURE__*/e.createElement(Ye,{id:"exact-time-overlay",tooltipContent:(()=>{const e=new Date(parseInt(t.timestamp));return new Intl.DateTimeFormat(c.locale,{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}).format(e)})()},u.format(parseInt(t.timestamp)))),i?/*#__PURE__*/e.createElement(Y.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(et,null)):null),/*#__PURE__*/e.createElement("div",{className:"row"},/*#__PURE__*/e.createElement("div",{className:"col comment-value"},t.commentValue)))};tt.propTypes={author:l.object,timestamp:l.string.isRequired,commentValue:l.string.isRequired,onDeleteQuestionComment:l.func.isRequired,onDeleteViewComment:l.func,index:l.number.isRequired};const st=({comments:e,onDeleteCommentClick:t})=>{const o=r(null),[a,i]=s(!1),l=()=>{i(!0),setTimeout(()=>{i(!1)},2e3)};return n(()=>{null!==o.current&&(o.current.scrollTop=o.current.scrollHeight)},[JSON.stringify(e)]),M("span",{children:a?U("div",{className:"comment-delete",children:[M(K,{color:"#00BFFF",height:80,width:80}),M("p",{children:"Deleting comment..."})]}):M("div",{className:"comment-list-items",ref:o,children:e.map((e,s)=>M("div",{className:"comment-list-item",children:M(tt,{commentValue:e[oe.HAS_COMMENT_VALUE],author:e[oe.HAS_AUTHOR]?e[oe.HAS_AUTHOR]:null,timestamp:e[oe.HAS_TIMESTAMP],onDeleteQuestionComment:t,onDeleteViewComment:l,index:s})},s))})})},nt=()=>/*#__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"})),ot="300px",rt=t=>{const[o,a]=s(""),i=r(null),l=P();n(()=>{i.current.focus()},[]);const c=e=>{e.preventDefault(),t.onChange(o),a("")},u=()=>{const e=i.current;e.style.height="auto",p(e)},p=e=>{e.style.height=`${e.scrollHeight}px`,parseInt(e.style.height)>parseInt(ot)&&(e.style.height=ot)};/*#__PURE__*/return e.createElement(d,{onSubmit:c,onKeyUp:e=>{"Enter"===e.key&&e.ctrlKey&&o.trim()&&c(e)},onClick:e=>{e.stopPropagation()}},/*#__PURE__*/e.createElement(d.Group,{className:"m-2 position-relative",controlId:"formBasicComment"},/*#__PURE__*/e.createElement(g,{className:"col-lg-12 p-0"},/*#__PURE__*/e.createElement(_,{className:"container-fluid p-0 m-0"},/*#__PURE__*/e.createElement("div",{id:"comment-form"},/*#__PURE__*/e.createElement(d.Control,{className:"comment-form-control",name:"comment",as:"textarea",placeholder:l.formatMessage({id:"comment.form.placeholder"}),required:!0,value:o,onChange:e=>{a(e.target.value)},ref:i,onKeyPress:u,onKeyDown:u}),/*#__PURE__*/e.createElement(f,{className:"comment-form-button",variant:"primary",type:"submit"},/*#__PURE__*/e.createElement(nt,null)))))))};rt.propTypes={onChange:l.func.isRequired};const at=()=>/*#__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"})),it=t=>{const a=o(Ee),i=r(null),l=r(null),c=r(null),[u,p]=s(!1),[m,d]=s("right");n(()=>{I(c.current)});const h=()=>{p(!1)},E=()=>{const e=t.question;return e[oe.HAS_COMMENT]||(e[oe.HAS_COMMENT]=[]),Array.isArray(e[oe.HAS_COMMENT])||(e[oe.HAS_COMMENT]=[e[oe.HAS_COMMENT]]),e[oe.HAS_COMMENT]},S=e=>{const s={};g(s,e),t.onChange(N(),s)},g=(e,t)=>{a.options.currentUser&&(e[oe.HAS_AUTHOR]={"@id":a.options.currentUser}),e[oe.HAS_COMMENT_VALUE]=t,e[oe.HAS_TIMESTAMP]=Date.now().toString()},_=e=>{E().splice(e,1)},f=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:f},/*#__PURE__*/e.createElement("span",{className:"comment-bubble",ref:i,onClick:e=>{f(e),p(!u)}},/*#__PURE__*/e.createElement(Ze,null),N()>0?/*#__PURE__*/e.createElement(v,{className:"comment-badge",pill:!0,variant:"primary"},N()):null),/*#__PURE__*/e.createElement(Y.div,{className:"overlay-comment",ref:l,drag:!0,dragConstraints:{top:-50,left:-50,right:50,bottom:50}},/*#__PURE__*/e.createElement(T,{target:i.current,show:u,placement:m,rootClose:!1,onHide:h,container:l},t=>/*#__PURE__*/e.createElement(A,J({className:"comment-tooltip"},t),/*#__PURE__*/e.createElement("span",{onKeyDown:e=>{(e=>{"Escape"===e.key&&h()})(e)}},/*#__PURE__*/e.createElement(Y.div,{className:"close-comment-icon",onClick:h,whileHover:{scale:1.1,transition:{duration:.1}}},/*#__PURE__*/e.createElement(at,null)),/*#__PURE__*/e.createElement(st,{comments:E(),onDeleteCommentClick:_}),/*#__PURE__*/e.createElement(rt,{onChange:S}))))))};var lt;it.propTypes={question:l.object.isRequired,onChange:l.func.isRequired};class ct{static renderIcons(t,s,n,o,r){let a;a=s.icons?s.icons:oe.DEFAULT_OPTIONS.icons;let i=[];const l=this.renderQuestionHelp(t,s,n,o,r),c=this.renderQuestionComments(t,s,n,o,r),u=this.renderQuestionLink(t,s,n,o,r);for(let t=0;t<a.length;t++)a[t].id===oe.ICONS.QUESTION_COMMENTS&&i.push(/*#__PURE__*/e.createElement("li",{key:t,className:"icon-list-item"},c)),a[t].id===oe.ICONS.QUESTION_HELP&&i.push(/*#__PURE__*/e.createElement("li",{key:t,className:"icon-list-item"},l)),a[t].id===oe.ICONS.QUESTION_LINK&&i.push(/*#__PURE__*/e.createElement("li",{key:t,className:"icon-list-item"},u));/*#__PURE__*/return e.createElement("ol",{className:"icon-list-items"},i)}static renderQuestionHelp(e,t,s,n,o){return this.getIconComponentFromName(oe.ICONS.QUESTION_HELP,e,t,s,n,o)}static renderQuestionLink(e,t,s,n,o){return this.getIconComponentFromName(oe.ICONS.QUESTION_LINK,e,t,s,n,o)}static getIconComponentFromName(e,t,s,n,o,r){const a=this.getIconFromIconList(s.icons?s.icons:oe.DEFAULT_OPTIONS.icons,e);return this.getIconComponent(a,t,s,n,o,r)}static getIconComponent(t,s,n,o,r,a){let i;if(t&&(t.behavior===oe.ICON_BEHAVIOR.ON_HOVER||t.behavior===oe.ICON_BEHAVIOR.ENABLE))return t.behavior===oe.ICON_BEHAVIOR.ENABLE?(r=!0,i=""):i="emphasise-on-relevant-icon",t.id===oe.ICONS.QUESTION_HELP&&s[oe.HELP_DESCRIPTION]?r?/*#__PURE__*/e.createElement("div",{className:i},/*#__PURE__*/e.createElement(Ke,{text:u.getLocalized(s[oe.HELP_DESCRIPTION],a),absolutePosition:!1})):null:t.id===oe.ICONS.QUESTION_LINK&&s[oe.SOURCE]?r?/*#__PURE__*/e.createElement("div",{className:i},/*#__PURE__*/e.createElement($e,{url:s[oe.SOURCE]})):null:t.id===oe.ICONS.QUESTION_COMMENTS&&r?/*#__PURE__*/e.createElement("div",{className:i},/*#__PURE__*/e.createElement(it,{question:s,onChange:o})):null}}lt=ct,ct.renderQuestionComments=(e,t,s,n,o)=>lt.getIconComponentFromName(oe.ICONS.QUESTION_COMMENTS,e,t,s,n,o),ct.getIconFromIconList=(e,t)=>e?e.find(e=>e.id===t):null;const ut=t=>{const o=e.useContext(te),{options:r}=e.useContext(Ee),[a,i]=s({severity:"",classname:"",message:null}),l=P();n(()=>{m()},[t.question]);const c=e=>{const s=Object.assign({},t.answer);p(s,e),t.onChange(t.index,s)},p=(e,s)=>{null===s?(e[oe.HAS_OBJECT_VALUE]=null,e[oe.HAS_DATA_VALUE]=null):t.answer[oe.HAS_OBJECT_VALUE]||le.isTypeahead(t.question)?e[oe.HAS_OBJECT_VALUE]={"@id":s}:e[oe.HAS_DATA_VALUE]={"@value":s}},m=()=>{i({severity:"",classname:"",message:null}),!1===d[oe.HAS_VALID_ANSWER]&&i(d[oe.HAS_VALIDATION_SEVERITY]===oe.VALIDATION.SEVERITY.WARNING?{severity:oe.VALIDATION.SEVERITY.WARNING,classname:oe.VALIDATION.CLASSNAME.WARNING,message:/*#__PURE__*/e.createElement(N,{className:oe.VALIDATION.CLASSNAME.WARNING},d[oe.HAS_VALIDATION_MESSAGE])}:{severity:oe.VALIDATION.SEVERITY.ERROR,classname:oe.VALIDATION.CLASSNAME.ERROR,message:/*#__PURE__*/e.createElement(N,{className:oe.VALIDATION.CLASSNAME.ERROR},d[oe.HAS_VALIDATION_MESSAGE])})},d=t.question,h=le.resolveValue(t.answer),E=(s=>{const n=u.getLocalized(s[oe.RDFS_LABEL],l);/*#__PURE__*/return e.createElement("div",{className:"question-header"},n,ct.renderIcons(t.question,r,t.onCommentChange,t.showIcon,l))})(d),S=u.getLocalized(d[oe.RDFS_COMMENT],l);let A;var g;return A=le.isTypeahead(d)?((s,n,r)=>{const i=re.getStringHash(le.getPossibleValuesQuery(t.question)),l=o.getOptions(i)||[];/*#__PURE__*/return e.createElement(Qe,{question:t.question,answer:t.answer,label:n,title:r,value:s,onChange:c,options:l,validation:a})})(h,E,S):(g=d)[oe.HAS_OPTION]&&0!==g[oe.HAS_OPTION].length?((s,n,o)=>/*#__PURE__*/e.createElement(ze,{question:t.question,label:n,title:o,value:s,onChange:c,validation:a}))(h,E,S):le.isCalendar(d)?((s,n,o)=>/*#__PURE__*/e.createElement(be,{question:t.question,value:s,title:o,label:n,onChange:c,validation:a}))(h,E,S):le.isCheckbox(d)?((s,n,o)=>/*#__PURE__*/e.createElement(Re,{label:n,title:o,value:s,onChange:c,question:t.question,validation:a}))(h,E,S):le.isMaskedInput(d)?((s,n,o)=>/*#__PURE__*/e.createElement(je,{label:n,title:o,value:s,onChange:c,question:t.question,answer:t.answer,validation:a}))(h,E,S):le.isSparqlInput(d)?((s,n,o)=>/*#__PURE__*/e.createElement(Me,{question:t.question,answer:t.answer,label:n,title:o,value:s,onChange:c,sparql:!0,validation:a}))(h,E,S):le.isTurtleInput(d)?((s,n,o)=>/*#__PURE__*/e.createElement(Me,{question:t.question,answer:t.answer,label:n,title:o,value:s,onChange:c,turtle:!0,validation:a}))(h,E,S):((s,n,o)=>/*#__PURE__*/e.createElement(Me,{question:t.question,answer:t.answer,label:n,title:o,value:s,onChange:c,validation:a}))(h,E,S),A};ut.propTypes={answer:l.object.isRequired,question:l.object.isRequired,onChange:l.func.isRequired,onCommentChange:l.func.isRequired,index:l.number,icons:l.object};const pt=(e,t)=>{const s=[gt,At,dt,Et,ht,St];return()=>{if(le.hasValidationLogic(e,t)){const n=le.getAnswerValue(e);return mt(e,t,n,s)}}},mt=(e,t,s,n)=>{const o={};for(const s of n){const n=s(e,t);if(!n.isValid)return o[oe.HAS_VALID_ANSWER]=!1,o[oe.HAS_VALIDATION_MESSAGE]=n.message,o[oe.HAS_VALIDATION_SEVERITY]=n.validationSeverity,o;if(!1===o[oe.HAS_VALID_ANSWER])break}return o[oe.HAS_VALID_ANSWER]=!0,o[oe.HAS_VALIDATION_MESSAGE]="",o[oe.HAS_VALIDATION_SEVERITY]="",o},dt=(e,t)=>{const s=le.getAnswerValue(e);return s&&s.length>0&&e[oe.PATTERN]&&!new RegExp(e[oe.PATTERN]).test(s)&&le.hasAnswer(e)?{isValid:!1,validationSeverity:oe.VALIDATION.SEVERITY.ERROR,message:e[oe.HAS_VALIDATION_MESSAGE]?e[oe.HAS_VALIDATION_MESSAGE]:t.formatMessage({id:"validation.invalid"})}:{isValid:!0}},ht=(e,t)=>!e[oe.REQUIRES_ANSWER]||e[oe.USED_ONLY_FOR_COMPLETENESS]||le.hasAnswer(e)?{isValid:!0}:{isValid:!1,validationSeverity:oe.VALIDATION.SEVERITY.ERROR,message:e[oe.HAS_VALIDATION_MESSAGE]?e[oe.HAS_VALIDATION_MESSAGE]:t.formatMessage({id:"validation.required"})},Et=(e,t)=>le.isCheckbox(e)&&e[oe.REQUIRES_ANSWER]&&!le.hasAnswer(e)?{isValid:!1,validationSeverity:oe.VALIDATION.SEVERITY.ERROR,message:e[oe.HAS_VALIDATION_MESSAGE]?e[oe.HAS_VALIDATION_MESSAGE]:t.formatMessage({id:"validation.check"})}:{isValid:!0},St=(e,t)=>e[oe.REQUIRES_ANSWER]&&e[oe.USED_ONLY_FOR_COMPLETENESS]&&!le.hasAnswer(e)?{isValid:!1,validationSeverity:oe.VALIDATION.SEVERITY.WARNING,message:e[oe.HAS_VALIDATION_MESSAGE]?e[oe.HAS_VALIDATION_MESSAGE]:t.formatMessage({id:"validation.required_only_for_completeness"})}:{isValid:!0},At=(e,t)=>{if(e[oe.XSD.MIN_INCLUSIVE]){const s=le.getAnswerValue(e);if(s&&s.length>0){const n=e[oe.XSD.MIN_INCLUSIVE];if(!(Number.isInteger(parseInt(s))&&s>=n))return{isValid:!1,validationSeverity:oe.VALIDATION.SEVERITY.ERROR,message:e[oe.HAS_VALIDATION_MESSAGE]?e[oe.HAS_VALIDATION_MESSAGE]:t.formatMessage({id:"validation.greater_or_equal"})+n+"."}}}return{isValid:!0}},gt=(e,t)=>{const s=le.getAnswerValue(e);if(e[oe.XSD.MAX_INCLUSIVE]&&s&&s.length>0){const n=e[oe.XSD.MAX_INCLUSIVE];if(!(Number.isInteger(parseInt(s))&&s<=n))return{isValid:!1,validationSeverity:oe.VALIDATION.SEVERITY.ERROR,message:e[oe.HAS_VALIDATION_MESSAGE]?e[oe.HAS_VALIDATION_MESSAGE]:t.formatMessage({id:"validation.lower_or_equal"})+n+"."}}return{isValid:!0}};class _t 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(O,null,this.state.prefixes.sort((e,t)=>e[oe.PREFIX]<t[oe.PREFIX]?-1:1).map(t=>/*#__PURE__*/e.createElement(C,{key:t[oe.PREFIX]},/*#__PURE__*/e.createElement("strong",null,t[oe.PREFIX]),": ",t[oe.NAMESPACE]))));/*#__PURE__*/return e.createElement(S,{trigger:"click",placement:"right",overlay:t},/*#__PURE__*/e.createElement("span",{className:this.props.iconClass},this.props.children))}}_t.propTypes={prefixes:l.array.isRequired,children:l.element.isRequired,iconClass:l.string},_t.defaultProps={iconClass:""};const ft=({question:e})=>(()=>{const t=e[oe.HAS_MEDIA_CONTENT];return t?Array.isArray(t)?M("div",{className:"col-6",children:t.map((e,s)=>M("div",{className:"row embed-responsive-21by9 media-content-video-container mb-3",children:M("iframe",{src:t[s],className:"embed-responsive-item",allowFullScreen:!0})},s))}):M("div",{className:"col-6",children:M("iframe",{src:t,className:"embed-responsive-item",allowFullScreen:!0})}):null})();class vt extends e.Component{constructor(e){super(e),this.handleAnswerChange=(e,t)=>{if(le.isSection(this.props.question)){let e=!!le.resolveValue(t);this.setState({expanded:e})}this._handleChange(oe.HAS_ANSWER,e,t)},this.handleSubQuestionChange=(e,t)=>{this._handleChange(oe.HAS_SUBQUESTION,e,t)},this.handleCommentChange=(e,t)=>{this._handleChange(oe.HAS_COMMENT,e,t)},this._toggleCollapse=()=>{this.props.collapsible&&this.setState({expanded:!this.state.expanded})},this._onEnterHandler=()=>{this.setState({showIcon:!0})},this._onLeaveHandler=()=>{this.setState({showIcon:!1})},this._getHeaderClassName=()=>{const e=this.props.question,t=this.props.collapsible;let s=[];return s.push(vt.getEmphasizedOnRelevantClass(e),"question-header"),le.isWizardStep(e)&&s.push("wizard-step bg-primary text-white"),le.isEmphasised(e)&&s.push(vt.getEmphasizedClass(e)),le.isSection(e)&&s.push("section-background"),t&&s.push("cursor-pointer"),this.isDebugged(e)&&s.push("show-irrelevant"),s},ae.putObject(e.question["@id"],e.question),this.state={validator:{},expanded:!le.isCollapsed(e.question),showIcon:!1}}componentDidMount(){this.setState({validator:pt(this.props.question,this.props.intl)})}componentDidUpdate(){const e=this.props.question,t=this.context.options.startingQuestionId,s=e[oe.HAS_SUBQUESTION].find(e=>e["@id"]===t);if(le.isSection(e)&&le.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===oe.HAS_ANSWER){const e=this.state.validator(s);n=Object.assign({},n,e)}ae.putObject(n["@id"],n),this.props.onChange(this.props.index,n)}isDebugged(e){const t=this.context.options.startingQuestionId;return!le.isRelevant(e)&&(!!this.context.options.debugMode||null!=t&&!!re.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):le.isHidden(t)?null:le.isRelevant(t)?s:null}renderQuestion(t){if(le.isAnswerable(t)&&!le.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(le.isAnswerable(t))return this.renderAnswerableSection();if(le.isSection(t)){const{collapsible:s,withoutCard:n}=this.props,o=vt._getQuestionCategoryClass(t);if(n)/*#__PURE__*/return e.createElement("div",null,this._renderQuestionContent());const r=u.getLocalized(t[u.RDFS_LABEL],this.props.intl),a=/*#__PURE__*/e.createElement(w.Body,{className:z("p-3",o)},this._renderQuestionContent());/*#__PURE__*/return e.createElement(e.Fragment,null,/*#__PURE__*/e.createElement(L,{activeKey:this.state.expanded?r:void 0,className:"mb-3"},/*#__PURE__*/e.createElement(L.Item,{eventKey:r},/*#__PURE__*/e.createElement(w,{className:""},/*#__PURE__*/e.createElement(L.Button,{as:w.Header,onClick:this._toggleCollapse,className:this._getHeaderClassName(),onMouseEnter:this._onEnterHandler,onMouseLeave:this._onLeaveHandler,onFocus:this._onEnterHandler,onBlur:this._onLeaveHandler},/*#__PURE__*/e.createElement("div",{className:"d-inline",id:t["@id"]},s&&!le.isWizardStep(t)&&this._renderCollapseToggle(),r),this.renderQuestionIcons(),this.props.children),/*#__PURE__*/e.createElement(L.Body,{className:"p-0"},s?a:/*#__PURE__*/e.createElement(e.Fragment,null,a))))))}/*#__PURE__*/return e.createElement("div",null,this._renderQuestionContent())}_renderQuestionContent(){let t=[];return this.state.expanded&&t.push(/*#__PURE__*/e.createElement(ft,{key:this.props.question["@id"]+"-media",question:this.props.question})),t.push(this.renderAnswers()),t.push(this.renderSubQuestions()),t}renderQuestionIcons(){return ct.renderIcons(this.props.question,this.context.options,this.handleCommentChange,this.state.showIcon,this.props.intl)}renderAnswerableSection(){const t=this.props.question,s=this.props.collapsible,n=vt._getQuestionCategoryClass(t);let o=this.getShowIrrelevantClassname(t);const r=/*#__PURE__*/e.createElement(w.Body,{className:z("p-3",n)},this.renderSubQuestions(o)),a=this._getHeaderClassName();return this.state.expanded&&a.push("text-primary"),/*#__PURE__*/e.createElement(L,{activeKey:this.state.expanded?t["@id"]:void 0,className:"answerable-section"},/*#__PURE__*/e.createElement(w,{className:"mb-3"},/*#__PURE__*/e.createElement(w.Header,{onClick:this._toggleCollapse,className:a},this.renderAnswers()),s?/*#__PURE__*/e.createElement(L.Collapse,{className:o,eventKey:t["@id"]},r):{cardBody:r}))}getShowIrrelevantClassname(e){return!this.context.options.debugMode&&!ie.checkId(e[oe.HAS_SUBQUESTION],this.context.options.startingQuestionId)||le.hasAnswer(e)?"":"show-irrelevant"}renderAnswers(){const t=this.props.question,s=[],n=this._getAnswers();let o;for(let r=0,a=n.length;r<a;r++)le.isTextarea(t,le.resolveValue(n[r]))||le.isSparqlInput(t)||le.isTurtleInput(t),o=z("answer",vt._getQuestionCategoryClass(t),vt.getEmphasizedOnRelevantClass(t)),s.push(/*#__PURE__*/e.createElement("div",{key:"row-item-"+r,className:o,id:t["@id"],onMouseEnter:this._onEnterHandler,onMouseLeave:this._onLeaveHandler,onFocus:this._onEnterHandler,onBlur:this._onLeaveHandler},/*#__PURE__*/e.createElement("div",{className:"answer-content",style:this._getAnswerWidthStyle()},/*#__PURE__*/e.createElement(ut,{index:r,answer:n[r],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[oe.HAS_ANSWER]||(e[oe.HAS_ANSWER]=[]),Array.isArray(e[oe.HAS_ANSWER])||(e[oe.HAS_ANSWER]=[e[oe.HAS_ANSWER]]),0===e[oe.HAS_ANSWER].length&&(e[oe.HAS_ANSWER]=le.isSection(e)&&!le.isAnswerable(e)?[]:[Le.generateAnswer(e)]),e[oe.HAS_ANSWER]}_getAnswerWidthStyle(){const e=Number(this.props.question[oe.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===oe.GENERATED_ROW_SIZE?"col-6":"col-"+oe.COLUMN_COUNT/oe.GENERATED_ROW_SIZE}static _getQuestionCategoryClass(e){const t=le.getCategory(e);return t?"question-"+t:""}static getEmphasizedClass(e){return le.isEmphasised(e)?"bg-warning":""}static getEmphasizedOnRelevantClass(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.EMPHASISE_ON_RELEVANT)?"emphasise-on-relevant":""}_renderCollapseToggle(){const t=this.props.intl.formatMessage(this.state.expanded?{id:"section.collapse"}:{id:"section.expand"});/*#__PURE__*/return e.createElement("span",{onClick:this._toggleCollapse,title:t},/*#__PURE__*/e.createElement(this.state.expanded?Be:We,{title:t}))}_renderPrefixes(){const t=this.props.question;return t[oe.HAS_DECLARED_PREFIX]&&t[oe.HAS_DECLARED_PREFIX].length?/*#__PURE__*/e.createElement(_t,{prefixes:t[oe.HAS_DECLARED_PREFIX],iconClass:"help-icon-checkbox"},/*#__PURE__*/e.createElement(Xe,null)):null}_renderUnits(){const t=this.props.question;return t[oe.HAS_UNIT]?/*#__PURE__*/e.createElement("div",{className:"has-unit-label"},t[oe.HAS_UNIT]):null}renderSubQuestions(t){const s=[],n=this._getSubQuestions(),o=this.context.options.debugMode,r=this.context.options.startingQuestionId;for(let a=0;a<n.length;a++){let i=n[a],l=this.context.mapComponent(i,vt),c=null;(o||"show-irrelevant"!==t||re.findQuestionById(r,i,!0,!1,!1))&&(c=/*#__PURE__*/e.createElement(l,{key:"sub-question-"+a,question:i,onChange:this.handleSubQuestionChange,index:a,intl:this.props.intl})),s.push(c)}return s}_getSubQuestions(){const e=this.props.question;return e[oe.HAS_SUBQUESTION]||(e[oe.HAS_SUBQUESTION]=[]),Array.isArray(e[oe.HAS_SUBQUESTION])||(e[oe.HAS_SUBQUESTION]=[e[oe.HAS_SUBQUESTION]]),ie.orderByLocalizedLabels(e[oe.HAS_SUBQUESTION],this.props.intl),ie.orderPreservingToplogicalSort(e[oe.HAS_SUBQUESTION],oe.HAS_PRECEDING_QUESTION),e[oe.HAS_SUBQUESTION]}_getFirstAnswerValue(){return le.resolveValue(this._getAnswers()[0])}}vt.contextType=Ee,vt.propTypes={question:l.object.isRequired,onChange:l.func.isRequired,index:l.number,withoutCard:l.bool,collapsible:l.bool},vt.defaultProps={withoutCard:!1,collapsible:!0};const Tt=t=>{const{updateFormQuestionsData:s,getFormQuestionsData:n}=o(pe),r=P(),a=n([t.index]);/*#__PURE__*/return e.createElement(e.Fragment,null,/*#__PURE__*/e.createElement(vt,{question:a,onChange:(e,n)=>{s(t.index||e,Object.assign({},t.question,n))},collapsible:le.isAnswerable(a),intl:r}),t.options.wizardStepButtons&&/*#__PURE__*/e.createElement(R,{className:"m-3 float-end"},!t.isFirstStep&&/*#__PURE__*/e.createElement(f,{className:"me-2",onClick:()=>{t.onPreviousStep()},variant:"primary",size:"sm"},r.formatMessage({id:"wizard.previous"})),!t.isLastStep&&/*#__PURE__*/e.createElement(f,{onClick:()=>{s(t.index,n()),t.onNextStep()},variant:"primary",size:"sm"},r.formatMessage({id:"wizard.next"}))))};Tt.propTypes={options:l.object.isRequired,question:l.object.isRequired,index:l.number.isRequired,onNextStep:l.func,onPreviousStep:l.func,mapComponent:l.func,isFirstStep:l.bool,isLastStep:l.bool};const Nt=({steps:t,onNavigate:s,currentStep:n})=>{const{options:r}=o(Ee),a=P();/*#__PURE__*/return e.createElement(w.Header,null,/*#__PURE__*/e.createElement(b,{variant:"tabs",activeKey:n,onSelect:e=>s(parseInt(e))},t.map((t,s)=>/*#__PURE__*/e.createElement(Ye,{id:"step-disabled",tooltipContent:a.formatMessage({id:"wizard.nav.tooltip"}),show:!r.enableWizardStepSkip},/*#__PURE__*/e.createElement(y,{key:"nav"+s,id:"wizard-nav-"+s},/*#__PURE__*/e.createElement(D,{eventKey:s,active:s===n?"active":"",hidden:!r.debugMode&&!le.isRelevant(t),disabled:!r.enableWizardStepSkip,className:z([r.debugMode&&!le.isRelevant(t)?"show-irrelevant":vt.getEmphasizedClass(t),"wizard-nav"])},u.getLocalized(t[u.RDFS_LABEL],a)))))))};Nt.propTypes={currentStep:l.number.isRequired,steps:l.array.isRequired,onNavigate:l.func.isRequired};const It=({steps:t,onNavigate:s,currentStep:n})=>{const{options:r}=o(Ee),a=P();/*#__PURE__*/return e.createElement("div",{className:"wizard-nav col-2 p-0"},/*#__PURE__*/e.createElement(O,null,t.map((t,o)=>/*#__PURE__*/e.createElement(Ye,{id:"step-disabled",tooltipContent:a.formatMessage({id:"wizard.nav.tooltip"}),show:!r.enableWizardStepSkip},/*#__PURE__*/e.createElement(C,{hidden:!r.debugMode&&!le.isRelevant(t),key:"nav"+o,onClick:()=>s(o),id:"wizard-nav-"+o,action:!0,active:o===n?"active":"",disabled:!r.enableWizardStepSkip,variant:"default",className:z([r.debugMode&&!le.isRelevant(t)?"show-irrelevant":vt.getEmphasizedClass(t),"wizard-nav"])},u.getLocalized(t[u.RDFS_LABEL],P()))))))};It.propTypes={currentStep:l.number.isRequired,steps:l.array.isRequired,onNavigate:l.func.isRequired};const Ot=()=>{const t=e.useContext(pe),{options:s,mapComponent:o}=e.useContext(Ee);let r=0;s.startingQuestionId?(r=((e,t)=>{const s=(e,n)=>e?e["@id"]===t?n:re.asArray(e[oe.HAS_SUBQUESTION]).findIndex((e,t)=>-1!==s(e,t)):-1;return e.findIndex((e,t)=>-1!==s(e,t))})(t.getFormQuestionsData(),s.startingQuestionId),-1===r&&(console.warn(`Question with id ${s.startingQuestionId} not found!`),r=0)):s.startingStep&&(r=s.startingStep<t.getFormQuestionsData().length?s.startingStep:0);const[a,i]=e.useState(r),[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();a!==e.length-1&&(e[a+1].visited=!0,i(e=>e+1))},p=()=>{0!==a&&i(e=>e-1)},m=e=>{const n=t.getFormQuestionsData();e===a||e>=n.length||e>a&&!n[e].visited&&!s.enableWizardStepSkip||i(e)};let d=null;t.getFormQuestionsData().length>1&&(d=(()=>{const n=t.getFormQuestionsData();/*#__PURE__*/return e.createElement(s.horizontalWizardNav?Nt:It,{currentStep:a,steps:n,onNavigate:m})})());const h=s.horizontalWizardNav;/*#__PURE__*/return e.createElement(w,{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()[a];let r=o(n,Tt);/*#__PURE__*/return e.createElement(r,{options:s,key:"step"+a,question:n,onNextStep:u,onPreviousStep:p,mapComponent:o,index:a,isFirstStep:0===a,isLastStep:a===t.getFormQuestionsData().length-1})})()))},Ct=/*#__PURE__*/e.forwardRef((t,s)=>{const{options:n}=e.useContext(Ee);/*#__PURE__*/return e.createElement(V,J({size:"xl",animation:!0},n.modalProps),/*#__PURE__*/e.createElement(V.Header,{closeButton:!0},/*#__PURE__*/e.createElement(V.Title,null,n.modalProps.title)),/*#__PURE__*/e.createElement(V.Body,{className:"overflow-hidden p-0"},t.children))});var wt;Ct.propTypes={children:l.element.isRequired};class Lt{}wt=Lt,Lt.updateQuestionValidation=(e,t,s,n)=>{const o=pt(t,n)();o&&(e[s]=Object.assign({},t,o));for(const t of e)wt.updateSubQuestionsValidation(t,n)},Lt.updateSubQuestionsValidation=(e,t)=>{const s=re.asArray(e[oe.HAS_SUBQUESTION]);for(let e=0;e<s.length;e++)wt.updateQuestionValidation(s,s[e],e,t)};const Rt=/*#__PURE__*/a((t,s)=>{const{getFormQuestionsData:n,updateFormQuestionsData:r,getData:a}=o(pe),l=P();i(s,()=>({validateForm:u,getFormSpecification:p,getFormQuestionsData:n,getFormData:c}),[]);const c=()=>{const e=a(),t=n();return Le.buildQuestionAnswerModel(e,t)},u=()=>{const e=n();for(let t=0;t<e.length;t++)Lt.updateQuestionValidation(e,e[t],t,l);r(null,e)},p=()=>{const e=n();return le.getFormSpecification(e)},m=()=>{const t=n();/*#__PURE__*/return e.createElement(w,{className:"p-3"},t.map((e,t)=>d(e,t)))},d=(s,n)=>{let o=t.mapComponent(s,vt);/*#__PURE__*/return e.createElement(o,{key:s["@id"],question:s,onChange:(e,t)=>((e,t,s)=>{r(t,Object.assign({},e,s))})(s,e,t),index:n,intl:l})},{modalView:h}=t,E=n();if(!E.length)/*#__PURE__*/return e.createElement(w,{className:"p-3 font-italic"},"There are no questions available...");const S=E.every(e=>!le.isWizardStep(e));return h?/*#__PURE__*/e.createElement(Ct,null,S?m():/*#__PURE__*/e.createElement(Ot,null)):S?m():/*#__PURE__*/e.createElement(Ot,null)});class bt extends e.Component{constructor(e){super(e),this.state={hasError:!1,errorLabel:null,errorDetails:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({errorLabel:e,errorDetails:t})}render(){if(this.state.hasError){const{lang:t}=this.context;/*#__PURE__*/return e.createElement("div",{style:{padding:"20px"}},/*#__PURE__*/e.createElement(H,{variant:"danger"},/*#__PURE__*/e.createElement(H.Heading,null,t["error.default_message"]||"Something went wrong."),/*#__PURE__*/e.createElement("p",null,this.state.errorLabel&&this.state.errorLabel.toString())),/*#__PURE__*/e.createElement(L,null,/*#__PURE__*/e.createElement(w,null,/*#__PURE__*/e.createElement(w.Header,null,/*#__PURE__*/e.createElement(L,{as:f,variant:"link",eventKey:"0"},t["error.view_details"]||"View Error Details")),/*#__PURE__*/e.createElement(L.Collapse,{eventKey:"0"},/*#__PURE__*/e.createElement(w.Body,null,/*#__PURE__*/e.createElement("pre",{style:{whiteSpace:"pre-wrap"}},this.state.errorDetails&&this.state.errorDetails.componentStack))))))}return this.props.children}}bt.contextType=fe;const yt=/*#__PURE__*/a((t,o)=>{const[r,a]=s(!0),[i,l]=s(null),[c,u]=s(null),p=P();if(n(()=>{(async()=>{const[e,s]=await we.constructForm(t.form,p);e.formQuestions.some(e=>le.isWizardStep(e))&&(e.formQuestions[0].visited=!0),l(e),u(s),a(!1)})()},[t.form]),r)return t.loader||/*#__PURE__*/e.createElement(w,{className:"p-3 font-italic"},"Loading SForms...");const m=((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(Ae,{components:t.components,componentsOptions:t.componentsOptions,mapComponent:m,options:t.options},/*#__PURE__*/e.createElement(ve,{locale:p.locale},/*#__PURE__*/e.createElement(bt,null,/*#__PURE__*/e.createElement(se,{fetchTypeAheadValues:t.fetchTypeAheadValues},/*#__PURE__*/e.createElement(me,{data:c,formQuestions:i.formQuestions,isFormValid:t.isFormValid},/*#__PURE__*/e.createElement(Rt,{ref:o,modalView:t.options&&t.options.modalView,mapComponent:m}))))))});yt.propTypes={form:l.object.isRequired,options:l.object.isRequired,componentMapRules:l.array,components:l.object,componentsOptions:l.object,fetchTypeAheadValues:l.func,isFormValid:l.func,loader:l.element};export{ut as Answer,Ee as ConfigurationContext,oe as Constants,pe as FormQuestionsContext,le as FormUtils,Ke as HelpIcon,ve as IntlContextProvider,Ce as JsonLdFramingUtils,ae as JsonLdObjectMap,ie as JsonLdObjectUtils,vt as Question,ct as QuestionStatic,Tt as WizardStep,yt 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 r,forwardRef as a,useImperativeHandle as i}from"react";import l from"prop-types";import"core-js/modules/es.object.assign.js";import*as c from"jsonld";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.string.includes.js";import*as u from"jsonld-utils";import"core-js/modules/es.array.sort.js";import p from"@kbss-cvut/tsort";import m from"react-dom";import{Form as d,FormGroup as h,FormControl as E,OverlayTrigger as S,Tooltip as A,Col as g,Row as _,Button as f,Badge as v,Overlay as T,FormText as N,Popover as I,ListGroup as O,ListGroupItem as C,Card as w,Accordion as L,ButtonToolbar as R,Nav as b,NavItem as y,NavLink as D,Modal as V,Alert as H}from"react-bootstrap";import{jsx as M,jsxs as U}from"react/jsx-runtime";import{IntlProvider as x,useIntl as P}from"react-intl";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 q from"react-datepicker";import{parse as k,format as z}from"date-fns";import F from"classnames";import j from"yasgui-yasqe";import"@triply/yasgui/build/yasgui.min.css";import Q from"inputmask-core";import{IntelligentTreeSelect as B}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"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.replace.js";import W from"javascript-time-ago";import X from"javascript-time-ago/locale/en";import G from"javascript-time-ago/locale/cs";import{motion as Y}from"framer-motion";import{Rings as K}from"react-loader-spinner";import"core-js/modules/es.parse-int.js";import"core-js/modules/es.string.trim.js";import"core-js/modules/es.regexp.constructor.js";function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)({}).hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},J.apply(null,arguments)}function $(e,t){if(null==e)return{};var s={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;s[n]=e[n]}return s}class Z{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 ee=["children"],te=/*#__PURE__*/e.createContext({}),se=s=>{let{children:n}=s,o=$(s,ee),r=[];const a=async(e,t)=>{const s=r[e];if(s&&s.length)return s;const n=await o.fetchTypeAheadValues(t);return n.length?c.frame(n,{},{}).then(t=>{const s=t["@graph"];return r.push(Object.assign({},s,{[e]:s})),s}):(Z.warn(`No data received when loading options using id ${e}`),[])},i=e=>r[e]||[],l=t(()=>({loadFormOptions:a,getOptions:i}),[a,i]);/*#__PURE__*/return e.createElement(te.Provider,J({value:l},o),n)};var ne;se.propTypes={children:l.element.isRequired,fetchTypeAheadValues:l.func};class oe{}ne=oe,oe.COLUMN_COUNT=12,oe.INPUT_LENGTH_THRESHOLD=50,oe.DATETIME_NUMBER_FORMAT="x",oe.EPOCH_MILLISECONDS="epoch-milliseconds",oe.FORM="http://onto.fel.cvut.cz/ontologies/documentation/form",oe.HAS_SUBQUESTION="http://onto.fel.cvut.cz/ontologies/documentation/has_related_question",oe.HAS_ANSWER="http://onto.fel.cvut.cz/ontologies/documentation/has_answer",oe.HAS_OPTION="http://onto.fel.cvut.cz/ontologies/form/has-possible-value",oe.HAS_OPTIONS_QUERY="http://onto.fel.cvut.cz/ontologies/form/has-possible-values-query",oe.HAS_VALUE_TYPE="http://onto.fel.cvut.cz/ontologies/form/has-value-type",oe.IS_DISABLED="http://onto.fel.cvut.cz/ontologies/aviation/form-376/is-disabled",oe.INPUT_MASK="http://onto.fel.cvut.cz/ontologies/form/has-input-mask",oe.LAYOUT_CLASS="http://onto.fel.cvut.cz/ontologies/form-layout/has-layout-class",oe.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"]},oe.HAS_INITIAL_INPUT_LENGTH="http://onto.fel.cvut.cz/ontologies/form-layout/has-initial-input-length",oe.VALUE_TYPE_CODE="code",oe.VALUE_TYPE_TEXT="text",oe.GENERATED_ROW_SIZE=1,oe.HAS_QUESTION_ORIGIN="http://onto.fel.cvut.cz/ontologies/form/has-question-origin",oe.HAS_ANSWER_ORIGIN="http://onto.fel.cvut.cz/ontologies/form/has-answer-origin",oe.HAS_DATA_VALUE="http://onto.fel.cvut.cz/ontologies/documentation/has_data_value",oe.HAS_OBJECT_VALUE="http://onto.fel.cvut.cz/ontologies/documentation/has_object_value",oe.HELP_DESCRIPTION="http://purl.org/dc/elements/1.1/description",oe.SOURCE="http://purl.org/dc/elements/1.1/source",oe.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"},oe.STEP="http://onto.fel.cvut.cz/ontologies/form/step",oe.PATTERN="http://onto.fel.cvut.cz/ontologies/form/pattern",oe.ACCEPTS_ANSWER_VALUE="http://onto.fel.cvut.cz/ontologies/form/accepts-answer-value",oe.ACCEPTS="http://onto.fel.cvut.cz/ontologies/form/accepts",oe.HAS_DATATYPE="http://onto.fel.cvut.cz/ontologies/form/has-datatype",oe.HAS_LAYOUT_CLASS="http://onto.fel.cvut.cz/ontologies/form/has-layout-class",oe.HAS_POSSIBLE_VALUES_QUERY="http://onto.fel.cvut.cz/ontologies/form/has-possible-values-query",oe.HAS_REQUIRED_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-required-value",oe.HAS_TESTED_QUESTION="http://onto.fel.cvut.cz/ontologies/form/has-tested-question",oe.HAS_TESTED_FORM="http://onto.fel.cvut.cz/ontologies/form/has-tested-form",oe.HAS_UNIT="http://onto.fel.cvut.cz/ontologies/form/has-unit",oe.HAS_VALID_ANSWER="http://onto.fel.cvut.cz/ontologies/form/has-valid-answer",oe.IS_RELEVANT_IF="http://onto.fel.cvut.cz/ontologies/form/is-relevant-if",oe.ACCEPTS_VALIDATION_VALUE="http://onto.fel.cvut.cz/ontologies/form/accepts-validation-value",oe.HAS_VALIDATION_MESSAGE="http://onto.fel.cvut.cz/ontologies/form/has-validation-message",oe.NEGATIVE_CONDITION="http://onto.fel.cvut.cz/ontologies/form/negative-condition",oe.REQUIRES_ANSWER="http://onto.fel.cvut.cz/ontologies/form/requires-answer",oe.USED_ONLY_FOR_COMPLETENESS="http://onto.fel.cvut.cz/ontologies/form/used-only-for-completeness",oe.REQUIRES_ANSWER_DESCRIPTION_IF="http://onto.fel.cvut.cz/ontologies/form/requires-answer-description-if",oe.REQUIRES_ANSWER_IF="http://onto.fel.cvut.cz/ontologies/form/requires-answer-if",oe.HAS_PRECEDING_QUESTION="http://onto.fel.cvut.cz/ontologies/form/has-preceding-question",oe.HAS_PRECEDING_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-preceding-value",oe.HAS_MEDIA_CONTENT="http://onto.fel.cvut.cz/ontologies/form/has-media-content",oe.CONDITION="http://onto.fel.cvut.cz/ontologies/form/condition",oe.OR_CONDITION="http://onto.fel.cvut.cz/ontologies/form/or-condition",oe.HAS_SUB_CONDITION="http://onto.fel.cvut.cz/ontologies/form/has-sub-condition",oe.HAS_PATTERN="http://onto.fel.cvut.cz/ontologies/form-lt/has-pattern",oe.HAS_DECLARED_PREFIX="http://onto.fel.cvut.cz/ontologies/form-spin/has-declared-prefix",oe.PREFIX="http://www.w3.org/ns/shacl#prefix",oe.NAMESPACE="http://www.w3.org/ns/shacl#namespace",oe.HAS_COMMENT="http://onto.fel.cvut.cz/ontologies/form/has-comment",oe.HAS_COMMENT_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-comment-value",oe.HAS_AUTHOR="http://onto.fel.cvut.cz/ontologies/form/has-author",oe.HAS_TIMESTAMP="http://onto.fel.cvut.cz/ontologies/form/has-timestamp",oe.TIME_FORMAT="http://onto.fel.cvut.cz/ontologies/form/time-format",oe.DATE_FORMAT="http://onto.fel.cvut.cz/ontologies/form/date-format",oe.DATETIME_FORMAT="http://onto.fel.cvut.cz/ontologies/form/datetime-format",oe.TIMESTAMP_FORMAT="http://onto.fel.cvut.cz/ontologies/form/timestamp-format",oe.NOT_ANSWERED_QUESTION="http://onto.fel.cvut.cz/ontologies/form/not-answered-question",oe.ANSWERED_QUESTION="http://onto.fel.cvut.cz/ontologies/form/answered-question",oe.HAS_VALIDATION_SEVERITY="http://onto.fel.cvut.cz/ontologies/form/has-validation-severity",oe.RDFS_LABEL=u.RDFS_LABEL,oe.RDFS_COMMENT=u.RDFS_COMMENT,oe.DEFAULT_HAS_CHILD=u.DEFAULT_HAS_CHILD,oe.BROADER="http://www.w3.org/2004/02/skos/core#broader",oe.HAS_NON_SELECTABLE_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-non-selectable-value",oe.PROVIDES_DEREFERENCEABLE_ANSWER_VALUES="http://onto.fel.cvut.cz/ontologies/form/provides-dereferenceable-answer-values",oe.ICONS={QUESTION_COMMENTS:"questionComments",QUESTION_HELP:"questionHelp",QUESTION_LINK:"questionLink"},oe.ICON_BEHAVIOR={ENABLE:"enable",DISABLE:"disable",ON_HOVER:"onHover"},oe.DEFAULT_OPTIONS={icons:[{id:ne.ICONS.QUESTION_HELP,behavior:ne.ICON_BEHAVIOR.ENABLE},{id:ne.ICONS.QUESTION_COMMENTS,behavior:ne.ICON_BEHAVIOR.ON_HOVER},{id:ne.ICONS.QUESTION_LINK,behavior:ne.ICON_BEHAVIOR.ON_HOVER}]},oe.LANG={cs:{locale:"cs",label:"Čestina"},en:{locale:"en",label:"English"}},oe.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 re{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 r=re.asArray(t[oe.HAS_SUBQUESTION]);if(n)for(let t of r){let s=re.findQuestionById(e,t,!0,!1,!1);if(s)return s}if(o)for(let t of r){let s=re.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 ae{static putObject(e,t){ae.objectMap[e]=t}static getObject(e){return ae.objectMap[e]}}ae.objectMap={};class ie{static getFirstObject(e,t){const s=c.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"])))||c.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=p(),n={};for(let o=0;o<e.length;o++){let r=e[o]["@id"];s.add(r),n[r]=e[o],re.asArray(e[o][t]).map(e=>"object"==typeof e?e["@id"]:e).map(e=>[e,r]).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=u.getLocalized(t[u.RDFS_LABEL],e),o=u.getLocalized(s[u.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 le{static isForm(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.FORM)}static isWizardStep(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.WIZARD_STEP)}static isSection(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.QUESTION_SECTION)}static isAnswerable(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.ANSWERABLE)}static isTypeahead(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.QUESTION_TYPEAHEAD)}static getPossibleValuesQuery(e){return u.getJsonAttValue(e,oe.HAS_OPTIONS_QUERY)}static isDisabled(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.DISABLED)}static isHidden(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.HIDDEN)}static isTextarea(e,t){return t&&t.length>oe.INPUT_LENGTH_THRESHOLD&&!le.isTypeahead(e)||u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.TEXTAREA)}static isText(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.TEXT)}static isCalendar(e){return le.isDate(e)||le.isTime(e)||le.isDateTime(e)}static isDate(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.DATE)}static isTime(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.TIME)}static isDateTime(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.DATETIME)}static isTimestamp(e){return u.hasValue(e,oe.TIMESTAMP_FORMAT,oe.EPOCH_MILLISECONDS)}static isCheckbox(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.CHECKBOX)}static isMaskedInput(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.MASKED_INPUT)}static isSparqlInput(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.SPARQL)}static isTurtleInput(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.TURTLE)}static isCollapsed(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.COLLAPSED)}static isEmphasised(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.EMPHASISED)}static getCategory(e){return oe.LAYOUT.CATEGORY.find(t=>u.hasValue(e,oe.LAYOUT_CLASS,t))}static resolveValue(e){return e?e[oe.HAS_OBJECT_VALUE]?e[oe.HAS_OBJECT_VALUE]["@id"]:u.getJsonAttValue(e,oe.HAS_DATA_VALUE):null}static resolveValueObject(e){return e?e[oe.HAS_OBJECT_VALUE]?re.asArray(e[oe.HAS_OBJECT_VALUE])[0]:e[oe.HAS_DATA_VALUE]?re.asArray(e[oe.HAS_DATA_VALUE])[0]:null:null}static isRelevant(e){if(!e[oe.IS_RELEVANT_IF])return!0;for(let t of re.asArray(e[oe.IS_RELEVANT_IF]))if(!le.testCondition(t))return!1;return!0}static hasValidationLogic(e){return!!(e[oe.REQUIRES_ANSWER]||e[oe.REQUIRES_ANSWER_IF]||e[oe.PATTERN]||this.containsXSDProperty(e))}static isValid(e){if(!1===e[oe.HAS_VALID_ANSWER])return!1;for(const t of re.asArray(e[oe.HAS_SUBQUESTION]))if(!1===this.isValid(t))return!1;return!0}static testOrCondition(e){const t=e[oe.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[oe.ACCEPTS_VALIDATION_VALUE],s=e[oe.ACCEPTS_ANSWER_VALUE],n=e[oe.ACCEPTS],o=e[oe.HAS_TESTED_QUESTION];let r;if(e[oe.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=re.asArray(n);if(1!==e.length&&console.warn("Support for multiple accepts values is not implemented !"),e[0]["@id"]===oe.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=re.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 re.asArray(o)){if(r=ae.getObject(e["@id"]),void 0===r)return console.warn("Questions is not loaded in an object map."),!0;if(!1===this.isValid(r))return!1}return!0}if(s&&o){r=ae.getObject(o["@id"]);for(const e of re.asArray(s)){if(!r)return console.warn("Question is not defined."),!0;if(!r.hasOwnProperty(oe.HAS_ANSWER))return!1;const t=c.getValues(r,oe.HAS_ANSWER);if(0===t.length)return!1;const s=le.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 re.asArray(e).map(e=>{const s=ae.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(oe.HAS_ANSWER)){const t=c.getValues(e,oe.HAS_ANSWER);if(t.length){const e=le.resolveValueObject(t[0]);if(e&&(e["@value"]||e["@id"]))return!0}}for(const t of re.asArray(e[oe.HAS_SUBQUESTION]))if(le.hasAnswer(t))return!0;return!1}static getAnswerValue(e){if(!e)return null;if(e.hasOwnProperty(oe.HAS_ANSWER)){const t=c.getValues(e,oe.HAS_ANSWER);if(t.length){const e=le.resolveValueObject(t[0]);if(e&&(e["@value"]||e["@id"]))return e["@value"]||e["@id"]}}for(const t of re.asArray(e[oe.HAS_SUBQUESTION])){const e=le.getAnswerValue(t);if(e)return e}return null}static resolveDateTimeFormat(e,t,s){const n=le.isDate(e),o=le.isTime(e),r=le.isDateTime(e);switch(!0){case n:return e[oe.DATE_FORMAT]||s.dateFormat;case o:return e[oe.TIME_FORMAT]||s.timeFormat;case r:return e[oe.DATETIME_FORMAT]||s.dateTimeFormat;default:return null}}static dfsTraverseQuestionTree(e,t,s=(()=>{})){function n(e){t(e),re.asArray(e[oe.HAS_SUBQUESTION]).forEach(e=>{n(e)}),s(e)}e.forEach(e=>{n(e)})}static getFormSpecification(e){let t=-1;const s="..";let n="";return le.dfsTraverseQuestionTree(e,function(e){t+=1;const o=" ".repeat(t);let r="";e[oe.REQUIRES_ANSWER]&&!e[oe.USED_ONLY_FOR_COMPLETENESS]?r=o+s+"required: "+e[oe.REQUIRES_ANSWER]+"\n":e[oe.USED_ONLY_FOR_COMPLETENESS]&&(r=o+s+"required only for completeness: "+e[oe.USED_ONLY_FOR_COMPLETENESS]+"\n"),n+=o+e["http://www.w3.org/2000/01/rdf-schema#label"]+"\n",n+=e[oe.HELP_DESCRIPTION]?o+s+"description: "+e[oe.HELP_DESCRIPTION]+"\n":"",n+=r,n+=e[oe.PATTERN]?o+s+"pattern: "+e[oe.PATTERN]+"\n":"",n+=e[oe.INPUT_MASK]?o+s+"mask: "+e[oe.INPUT_MASK]+"\n":"",n+=e[oe.XSD.MAX_INCLUSIVE]?o+s+"This field should be a number equal or lower to "+e[oe.XSD.MAX_INCLUSIVE]+"\n":"",n+=e[oe.XSD.MIN_INCLUSIVE]?o+s+"This field must be greater or equal to "+e[oe.XSD.MIN_INCLUSIVE]+"\n":"",n+=e[oe.HAS_VALIDATION_MESSAGE]?o+s+"validation-message: "+e[oe.HAS_VALIDATION_MESSAGE]+"\n":"",n+="\n"},function(){t-=1}),n}static containsXSDProperty(e){const t=Object.keys(e),s=Object.values(oe.XSD);for(const e of s)if(t.includes(e))return!0;return!1}static getInputMask(e){if(e[oe.INPUT_MASK])return e[oe.INPUT_MASK]}}const ce={},ue=[],pe=/*#__PURE__*/e.createContext({}),me=o=>{const[r,a]=s(o.data||ce),[i,l]=s(o.formQuestions||ue);n(()=>{if(o.isFormValid){const e=le.isValid(r);o.isFormValid(e)}},[]),n(()=>{a(o.data||ce)},[i]);const c=e=>{e&&a(Object.assign({},r,e))},u=(e,t)=>{if(!(!t||e<0||e>=i.length)){if("object"==typeof t){const s=[...i];s[e]=Object.assign({},s[e],t),l(s)}if(Array.isArray(t)&&l(t),o.isFormValid){const e=le.isValid(r);o.isFormValid(e)}}},p=()=>r,m=e=>null==e?i:i[e],d=t(()=>({updateData:c,updateFormQuestionsData:u,getData:p,getFormQuestionsData:m}),[m,p]);/*#__PURE__*/return e.createElement(pe.Provider,J({value:d},o),o.children)};me.propTypes={children:l.element.isRequired,data:l.object.isRequired,formQuestions:l.array.isRequired,isFormValid:l.func};class de extends e.Component{constructor(e){super(e),this.state={cursorPosition:0}}focus(){m.findDOMNode(this.input).focus()}getInputDOMNode(){return m.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(d.Group,{size:"small",controlId:Math.floor(Math.random()*Number.MAX_SAFE_INTEGER),className:"mb-3"},/*#__PURE__*/e.createElement(d.Check,J({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(h,{size:"small",className:"mb-3"},/*#__PURE__*/e.createElement(d.Check,J({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(h,{size:"small",className:"mb-3"},this._renderLabel(),/*#__PURE__*/e.createElement(E,J({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(d.Label,null,this.props.label):null}_renderTextArea(){/*#__PURE__*/return e.createElement(h,{size:"small",className:"mb-3"},this._renderLabel(),/*#__PURE__*/e.createElement(E,J({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(h,{size:"small",className:"mb-3"},this._renderLabel(),/*#__PURE__*/e.createElement(E,J({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)}}de.propTypes={type:l.string,label:l.object,value:l.any,onChange:l.func,help:l.string,validation:l.object,placeholder:l.string},de.defaultProps={type:"text"};const he=["children"],Ee=/*#__PURE__*/e.createContext({}),Se={components:{inputComponent:de},componentsOptions:{dateTimeAnswer:{dateFormat:"yyyy-MM-dd",timeFormat:"HH:mm",dateTimeFormat:"yyyy-MM-dd HH:mm:ss"},readOnly:!1},options:{intl:{locale:"en"},modalView:!1,modalProps:{},horizontalWizardNav:!0,wizardStepButtons:!0,enableWizardStepSkip:!0,startingStep:0}},Ae=s=>{let{children:n}=s,o=$(s,he);const r=t(()=>({inputComponent:o.components&&o.components.inputComponent||Se.components.inputComponent,componentsOptions:Object.assign({},Se.componentsOptions,o.componentsOptions),options:Object.assign({},Se.options,o.options),mapComponent:o.mapComponent}),[o]);/*#__PURE__*/return e.createElement(Ee.Provider,{value:r},n)};Ae.propTypes={children:l.element.isRequired,components:l.object,mapComponent:l.func,options:l.object};var ge={"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.","wizard.next":"Další","wizard.previous":"Předchozí","section.expand":"Rozbalit","section.collapse":"Sbalit","validation.required":"Toto pole je povinné.","validation.required_only_for_completeness":"Toto pole je povinné pro vyplnění formuláře.","validation.invalid":"Toto pole je neplatné.","validation.check":"Toto pole musí být zkontrolováno.","validation.lower_or_equal":"Toto pole by mělo být číslo rovné nebo nižší než ","validation.greater_or_equal":"Toto pole musí být větší nebo rovno ","error.default_message":"Něco se pokazilo.","error.view_details":"Zobrazit podrobnosti o chybě","comment.unknownAuthor":"Neznámý autor"},_e={"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.","wizard.next":"Next","wizard.previous":"Previous","section.expand":"Expand","section.collapse":"Collapse","validation.required":"This field is required.","validation.required_only_for_completeness":"This field is required to complete the form.","validation.invalid":"This field is invalid.","validation.check":"This field must be checked.","validation.lower_or_equal":"This field should be a number equal or lower to ","validation.greater_or_equal":"This field must be greater or equal to ","error.default_message":"Something went wrong.","error.view_details":"View Error Details","comment.unknownAuthor":"Unknown Author"};const fe=/*#__PURE__*/e.createContext({}),ve=({children:e,locale:t=navigator.language})=>{let s=_e;return t===oe.LANG.cs.locale&&(s=ge),M(fe.Provider,{value:{locale:t,lang:s},children:M(x,{locale:t,messages:s,children:e})})};var Te,Ne={"@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 Ie{static generateForm(){return JSON.parse(JSON.stringify(Ne))}}const Oe={root:{[oe.HAS_LAYOUT_CLASS]:oe.FORM},expandProperties:[oe.HAS_SUBQUESTION,oe.IS_RELEVANT_IF,oe.HAS_ANSWER,oe.HAS_DECLARED_PREFIX,oe.HAS_OPTION,oe.HAS_COMMENT]};class Ce{static customFrame(e,t,s){if(arguments.length<2)return c.nextTick(function(){s(new TypeError("Could not frame, too few arguments."))});null===t&&(t=Oe),c.flatten(e,null,null,(e,t)=>{})}static expandStructure(e){let t;const s={};e["@graph"].forEach(e=>{s[e["@id"]]=e,le.isForm(e)&&(t=e)});try{this._expandGraph(t,Oe,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,r;t.expandProperties.forEach(a=>{if(e.hasOwnProperty(a)){e[a]=re.asArray(e[a]),n=e[a];for(let e=0;e<n.length;e++)r=this._getId(n[e]),o=s[r],void 0!==o?(n[e]=o,this._expandGraph(o,t,s)):console.warn("object with @id "+r+" was not defined in input data.")}})}static _getId(e){return"string"==typeof e?e:e["@id"]}}Te=Ce,Ce.compressStructure=e=>{let t=[],s=new Set;return t=Te._compressGraph(e,t,s),t=t.sort((e,t)=>e["@id"]&&t["@id"]?e["@id"].localeCompare(t["@id"]):0),t},Ce._compressGraph=(e,t,s)=>(s.has(e["@id"])||(t.push(e),s.add(e["@id"])),Oe.expandProperties.forEach(n=>{if(e.hasOwnProperty(n)){const o=e[n];for(let r=0;r<o.length;r++){const a=o[r];void 0!==a&&(o[r]=a,t=Te._compressGraph(a,t,s),e[n][r]={"@id":a["@id"]})}}}),t);class we{static constructDefaultForm(e){const t=Ie.generateForm();return we._constructFormQuestions(t,e)}static async constructForm(e,t){let s,n;return c.flatten(e,{}).then(e=>{try{const[o,r]=we._constructFormQuestions(e,t);n=r,s={formQuestions:o}}catch(e){console.error("Error while constructing form questions from the provided structure:",e)}if(!n){const[e,o]=we.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,r=[];if(void 0!==e["@graph"][0]["@id"]?(o=Ce.expandStructure(e),Object.keys(o).map(e=>{ae.putObject(e,o[e])})):console.warn("default form is constructed."),s=e["@graph"].find(e=>le.isForm(e)),n=s[oe.HAS_SUBQUESTION],!n)throw Z.error("Could not find any questions in the received data."),"No questions in the form";return r=n.filter(e=>!(!le.isWizardStep(e)||le.isHidden(e))||(Z.warn("Item is not a wizard step: "+e),!1)),r.length||(Z.log("Could not find any wizard steps in the received data. Building form without steps"),s[oe.HAS_SUBQUESTION].forEach(e=>r.push(e))),r.sort(ie.getCompareLocalizedLabelFunction(t)),ie.orderPreservingToplogicalSort(r,oe.HAS_PRECEDING_QUESTION),[r,{root:s}]}}class Le{static buildQuestionAnswerModel(e,t){const s={subQuestions:[]};let n;if(e&&(s.uri=e.root["@id"],s.origin=u.getJsonAttValue(e.root,oe.HAS_QUESTION_ORIGIN,"@id")),t)for(let e=0;e<t.length;e++)n=Le.processQuestionAnswerHierarchy(t[e]),n&&s.subQuestions.push(n);return s}static processQuestionAnswerHierarchy(e){return e?Le._processQuestion(e):null}static _processQuestion(e){const t={};if(t.uri=e["@id"],t.origin=u.getJsonAttValue(e,oe.HAS_QUESTION_ORIGIN,"@id"),e[oe.HAS_SUBQUESTION]){t.subQuestions=[];for(let s=0;s<e[oe.HAS_SUBQUESTION].length;s++)t.subQuestions.push(Le._processQuestion(e[oe.HAS_SUBQUESTION][s]))}if(e[oe.HAS_ANSWER]){t.answers=[],Array.isArray(e[oe.HAS_ANSWER])||(e[oe.HAS_ANSWER]=[e[oe.HAS_ANSWER]]);for(let s=0;s<e[oe.HAS_ANSWER].length;s++)t.answers.push(Le.processAnswer(e[oe.HAS_ANSWER][s]))}if(e[oe.HAS_COMMENT]){t.comments=[],Array.isArray(e[oe.HAS_COMMENT])||(e[oe.HAS_COMMENT]=[e[oe.HAS_COMMENT]]);for(let s=0;s<e[oe.HAS_COMMENT].length;s++)t.comments.push(Le.processComment(e[oe.HAS_COMMENT][s]))}return t}static processComment(e){const t={};return t.author=u.getJsonAttValue(e,oe.HAS_AUTHOR,"@id"),t.value=u.getJsonAttValue(e,oe.HAS_COMMENT_VALUE),t.timestamp=u.getJsonAttValue(e,oe.HAS_TIMESTAMP,"@id"),t}static processAnswer(e){const t={};return t.uri=e["@id"],t.origin=u.getJsonAttValue(e,oe.HAS_ANSWER_ORIGIN,"@id"),e[oe.HAS_OBJECT_VALUE]?t.codeValue=u.getJsonAttValue(e,oe.HAS_OBJECT_VALUE,"@id"):t.textValue=u.getJsonAttValue(e,oe.HAS_DATA_VALUE),t}static generateAnswer(e){const t={};return t[oe.HAS_DATA_VALUE]="",t}}const Re=t=>{const{inputComponent:s,componentsOptions:n}=o(Ee);/*#__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||le.isDisabled(t.question)})};Re.propTypes={question:l.object.isRequired,label:l.object.isRequired,title:l.string,value:l.oneOfType([l.string,l.bool]),onChange:l.func.isRequired,mouseHover:l.bool,validation:l.object};const be=t=>{const{componentsOptions:r}=o(Ee),[a,i]=s(null),[l,c]=s(""),u=le.resolveDateTimeFormat(t.question,t.value,r.dateTimeAnswer),p=le.isDate(t.question),m=le.isTime(t.question),E=le.isTimestamp(t.question);n(()=>{const e=S(t.value);e?i(e):(i(null),c(`Invalid date value ${t.value} of question ${t.question["@id"]}.`),console.error(l))},[t.value,u]);const S=e=>{if(!e)return null;const t=E?new Date(e):k(e,u,new Date);return isNaN(t.getTime())?null:t};/*#__PURE__*/return e.createElement(h,{size:"small",className:"mb-3"},/*#__PURE__*/e.createElement(d.Label,{className:"w-100"},t.label),/*#__PURE__*/e.createElement(q,{selected:a,placeholderText:u,onChange:e=>{i(e);const s=e?E?e.getTime():z(e,u):"";t.onChange(s)},showTimeSelect:!p,showTimeSelectOnly:m,timeFormat:"HH:mm",timeIntervals:1,timeCaption:"Time",dateFormat:u,className:F("form-control",t.validation.classname),disabled:r.readOnly||le.isDisabled(t.question)}),t.validation.message)};be.propTypes={question:l.object.isRequired,label:l.object.isRequired,title:l.string,value:l.oneOfType([l.string,l.number]),onChange:l.func.isRequired,validation:l.object};const ye=[oe.XSD.INT,oe.XSD.INTEGER,oe.XSD.NON_NEGATIVE_INTEGER,oe.XSD.NON_POSITIVE_INTEGER,oe.XSD.NEGATIVE_INTEGER,oe.XSD.POSITIVE_INTEGER,oe.XSD.FLOAT,oe.XSD.POSITIVE_FLOAT,oe.XSD.NEGATIVE_FLOAT],De={};De[oe.XSD.NON_NEGATIVE_INTEGER]={min:0},De[oe.XSD.NON_POSITIVE_INTEGER]={max:0},De[oe.XSD.NEGATIVE_INTEGER]={max:-1},De[oe.XSD.POSITIVE_INTEGER]={min:1};const Ve={"string-2":"prefixed",atom:"var"};class He{static _resolveInputType(e,t){return le.isSparqlInput(e)||le.isTurtleInput(e)||le.isTextarea(e,t)?"textarea":He._isNumeric(e)?"number":"text"}static _isNumeric(e){for(let t=0,s=ye.length;t<s;t++)if(u.hasValue(e,oe.HAS_DATATYPE,ye[t]))return!0;return!1}static resolveInputProperties(e,t,s){let n={};switch(n.type=He._resolveInputType(e,t),n.type){case"textarea":n.rows=5;break;case"number":n=Object.assign({},n,He._resolveNumberRestrictions(e),this._resolveStepRestriction(e))}return n.disabled=s.readOnly||le.isDisabled(e),n}static _resolveStepRestriction(e){let t={};return void 0!==e[oe.STEP]&&(t.step=u.getJsonAttValue(e,oe.STEP)),t}static _resolveNumberRestrictions(e){let t={};return Object.getOwnPropertyNames(De).forEach(s=>{u.hasValue(e,oe.HAS_DATATYPE,s)&&(t=Object.assign({},t,De[s]))}),void 0!==e[oe.XSD.MIN_INCLUSIVE]&&(t.min=e[oe.XSD.MIN_INCLUSIVE]),void 0!==e[oe.XSD.MIN_EXCLUSIVE]&&(t.min=e[oe.XSD.MIN_EXCLUSIVE]+1),void 0!==e[oe.XSD.MAX_EXCLUSIVE]&&(t.max=e[oe.XSD.MAX_EXCLUSIVE]-1),void 0!==e[oe.XSD.MAX_INCLUSIVE]&&(t.max=e[oe.XSD.MAX_INCLUSIVE]),t}static _preventCharacterInput(e,t){"number"!==He._resolveInputType(t)||e.key>="0"&&e.key<="9"||["Backspace","Delete","ArrowLeft","ArrowRight","-","Minus","NumpadSubtract",".","Period"].includes(e.key)||e.preventDefault()}}const Me=t=>{const{inputComponent:s,componentsOptions:n}=o(Ee),r=t.question,a=t.answer;let i=t.value;return a[oe.HAS_OBJECT_VALUE]&&a[oe.HAS_OBJECT_VALUE][u.RDFS_LABEL]&&(i=u.getJsonAttValue(a[oe.HAS_OBJECT_VALUE],u.RDFS_LABEL)),/*#__PURE__*/e.createElement(s,Object.assign({},He.resolveInputProperties(r,i,n),{validation:t.validation,label:t.label,title:t.title,value:null==i?"":i,placeholder:le.getInputMask(r),onKeyPress:e=>He._preventCharacterInput(e,r),onChange:e=>{t.onChange(e.target.value),(t.sparql||t.turtle)&&(void 0).hide()},onFocus:e=>{if(t.sparql){const s=j.fromTextArea(e.target);s.setValue(i),s.on("change",()=>{t.onChange(s.getValue())}),j.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"===Ve[o.type]){const r=o.string.indexOf(":");if(-1!==r){const a=e.getPreviousNonWsToken(n.line,o).string.toUpperCase(),i=e.getTokenAt({line:n.line,ch:o.start});if("PREFIX"!==a&&("ws"===i.type||null==i.type)){const n=o.string.substring(0,r+1);if(null==e.getPrefixesFromQuery()[n.slice(0,-1)])if(t.question[oe.HAS_DECLARED_PREFIX]&&t.question[oe.HAS_DECLARED_PREFIX].filter(e=>e[oe.PREFIX]===n.slice(0,-1)).length){const s=t.question[oe.HAS_DECLARED_PREFIX].filter(e=>e[oe.PREFIX]===n.slice(0,-1)),o={};o[s[0][oe.PREFIX]]=s[0][oe.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=j.fromTextArea(e.target);s.setValue(i),s.on("change",()=>{t.onChange(s.getValue())})}}}))};Me.propTypes={question:l.object.isRequired,answer:l.object.isRequired,label:l.object.isRequired,title:l.string,value:l.oneOfType([l.string,l.number]),onChange:l.func.isRequired,validation:l.object};const Ue={D:"1",M:"1",Y:"1",h:"1",m:"1",s:"1"};class xe{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+=Ue[t]?Ue[t]:t;return s}}const Pe=["size","placeholder"];function qe(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 ke extends e.Component{constructor(e){super(e),this._updatePattern=e=>{this.mask.setPattern(xe.mapMask(e.mask),{value:this.mask.getRawValue(),selection:qe(this.input)})},this._updateMaskSelection=()=>{this.mask.selection=qe(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 Q({pattern:xe.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(xe.mapMask(this.props.mask),{value:this.props.value}):this.mask.setPattern(xe.mapMask(this.props.mask),{value:this.mask.getRawValue()}):e.mask!==this.props.mask?this.mask.setPattern(xe.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=$(t,Pe),r=this.mask.pattern.length;/*#__PURE__*/return e.createElement(this.context.inputComponent,Object.assign({},o,{ref:e=>{e&&(this.input=e.input?m.findDOMNode(e.input):e)},maxLength:r,onChange:this._onChange,onKeyDown:this._onKeyDown,onKeyPress:this._onKeyPress,onPaste:this._onPaste,placeholder:n||this.mask.emptyValue,size:s||r,value:this._getDisplayValue(),type:"text"}))}}ke.contextType=Ee,ke.propTypes={mask:l.string.isRequired},ke.defaultProps={value:""};const ze=t=>{const{componentsOptions:s}=o(Ee),n=t.question,r=t.value,a=u.getJsonAttValue(n,oe.INPUT_MASK);return a?/*#__PURE__*/e.createElement(ke,{mask:a,value:r,label:t.label,title:t.title,placeholder:a,onChange:e=>t.onChange(e.target.value),disabled:s.readOnly||le.isDisabled(n),validation:t.validation}):(Z.warn("Input mask not provided. Falling back to regular input."),/*#__PURE__*/e.createElement(Me,t))};ze.propTypes={question:l.object.isRequired,answer:l.object.isRequired,label:l.object.isRequired,title:l.string,value:l.oneOfType([l.string,l.number]),onChange:l.func.isRequired,validation:l.object};class Fe extends e.Component{_generateSelectOptions(t){const s=[];t.sort(function(e,t){const s=u.getJsonAttValue(e,oe.RDFS_LABEL),n=u.getJsonAttValue(t,oe.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:u.getJsonAttValue(t[n],oe.RDFS_LABEL),key:"opt-"+n},u.getJsonAttValue(t[n],oe.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||le.isDisabled(t)},this._generateSelectOptions(t[oe.HAS_OPTION]))}}Fe.contextType=Ee,Fe.propTypes={question:l.object.isRequired,label:l.object.isRequired,title:l.string,value:l.string,onChange:l.func.isRequired,validation:l.object};const je=(e,t)=>void 0!==e&&e.length?(e.sort(ie.getCompareLocalizedLabelFunction(t)),ie.orderPreservingToplogicalSort(e,oe.HAS_PRECEDING_VALUE),e):[],Qe=t=>{const r=re.getStringHash(le.getPossibleValuesQuery(t.question)),a=o(te),i=o(Ee),l=P(),[c,p]=s(!0),[m,E]=s(je(t.options,l));n(()=>{let e=!1;const s=t.question;return!s[oe.HAS_OPTION]&&le.getPossibleValuesQuery(s)?async function(){try{const t=await a.loadFormOptions(r,le.getPossibleValuesQuery(s));e||(p(!1),S(t))}catch(e){Z.error(`An error has occurred during loadFormOptions for query hash: ${r}`)}}():(p(!1),S(s[oe.HAS_OPTION])),()=>{e=!0}},[r,a,t.question,l]);const S=e=>{if(!e)return[];e=je(e,l);const t={},s=[];for(let n of e){let e=u.getLocalized(n[oe.RDFS_LABEL],l),o=u.getLocalized(n[oe.RDFS_COMMENT],l);t[n["@id"]]={id:n["@id"],value:n["@id"],label:e,description:o,children:[]};for(let e of re.asArray(n[oe.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=re.findKeyInObjects(m,["name","value"]),g=re.findKeyInObjects(m,["name","label"]);/*#__PURE__*/return e.createElement(h,{size:"small",className:"mb-3"},/*#__PURE__*/e.createElement(d.Label,null,t.label),/*#__PURE__*/e.createElement(B,{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[oe.PROVIDES_DEREFERENCEABLE_ANSWER_VALUES]?t=>/*#__PURE__*/e.createElement(e.Fragment,null,t):null,value:m.find(e=>e.id===t.value)||null,multi:!1,options:m,isSearchable:!0,isLoading:c,isClearable:!0,renderAsTree:!0,optionLeftOffset:5,isDisabled:c||i.componentsOptions.readOnly||le.isDisabled(t.question),onChange:e=>{t.onChange(e?e.id:null)},titleKey:"description"}),t.validation.message)};Qe.propTypes={question:l.object.isRequired,answer:l.object.isRequired,label:l.oneOfType([l.string,l.object]).isRequired,title:l.string,value:l.string,onChange:l.func.isRequired,validation:l.object};const Be=({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"})),We=({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"})),Xe=()=>/*#__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"})),Ge=()=>/*#__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"})),Ye=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(S,{overlay:t.show?/*#__PURE__*/e.createElement(A,{className:"tooltip-content",id:t.id},t.tooltipContent):/*#__PURE__*/e.createElement("span",null),placement:t.overlayPlacement||n},/*#__PURE__*/e.createElement("span",null,t.children)))};Ye.propTypes={tooltipContent:l.oneOfType([l.object.isRequired,l.string.isRequired]),id:l.string.isRequired,overlayPlacement:l.string,absolutePosition:l.bool,show:l.bool},Ye.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(Ye,{id:"help-icon-tooltip-",overlayPlacement:t.overlayPlacement||n,absolutePosition:t.absolutePosition,tooltipContent:t.text},/*#__PURE__*/e.createElement(Ge,{className:t.iconClass})))};Ke.propTypes={text:l.string.isRequired,iconClassContainer:l.string,iconClass:l.string,overlayPlacement:l.string,absolutePosition:l.bool},Ke.defaultProps={iconClassContainer:"",iconClass:"",absolutePosition:!0};const Je=()=>/*#__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"})),$e=t=>/*#__PURE__*/e.createElement(Ye,{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(Je,{className:t.iconClass})));$e.propTypes={url:l.oneOfType([l.string.isRequired,l.object.isRequired]),iconClassContainer:l.string,iconClass:l.string,overlayPlacement:l.string,absolutePosition:l.bool},$e.defaultProps={iconClassContainer:"",iconClass:"",absolutePosition:!0};const Ze=()=>/*#__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"})),et=()=>/*#__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"})))),tt=t=>{const{options:n}=o(Ee),[r,a]=s(!1),[i,l]=s(!1),c=P();W.addLocale(G),W.addLocale(X),W.setDefaultLocale(oe.LANG.en.locale);const u=new W(c.locale),p=()=>{if(n&&n.users){const e=n.users.find(e=>e.id===n.currentUser);if(t.author)return e.label?e.label:m()}return c.formatMessage({id:"comment.unknownAuthor"})},m=()=>t.author["@id"].replace(/.*[#\/]/,"... "),d=()=>{a(!r)};/*#__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:d,onMouseLeave:d},/*#__PURE__*/e.createElement(e.Fragment,null,r?/*#__PURE__*/e.createElement(e.Fragment,null,p(),/*#__PURE__*/e.createElement($e,{iconClassContainer:"emphasise-on-relevant-icon",url:t.author?Object.values(t.author).toString():c.formatMessage({id:"comment.unknownAuthor"})})):p())),/*#__PURE__*/e.createElement("div",{className:"col-auto text-muted comment-timestamp"},(()=>{const s=Number(t.timestamp),n=isNaN(s)?new Date(t.timestamp):new Date(s);/*#__PURE__*/return e.createElement(Ye,{id:"exact-time-overlay",tooltipContent:new Intl.DateTimeFormat(c.locale,{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}).format(new Date(n))},u.format(n))})()),i?/*#__PURE__*/e.createElement(Y.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(et,null)):null),/*#__PURE__*/e.createElement("div",{className:"row"},/*#__PURE__*/e.createElement("div",{className:"col comment-value"},t.commentValue)))};tt.propTypes={author:l.object,timestamp:l.string.isRequired,commentValue:l.string.isRequired,onDeleteQuestionComment:l.func.isRequired,onDeleteViewComment:l.func,index:l.number.isRequired};const st=({comments:e,onDeleteCommentClick:t})=>{const o=r(null),[a,i]=s(!1),l=()=>{i(!0),setTimeout(()=>{i(!1)},2e3)};return n(()=>{null!==o.current&&(o.current.scrollTop=o.current.scrollHeight)},[JSON.stringify(e)]),M("span",{children:a?U("div",{className:"comment-delete",children:[M(K,{color:"#00BFFF",height:80,width:80}),M("p",{children:"Deleting comment..."})]}):M("div",{className:"comment-list-items",ref:o,children:e.map((e,s)=>M("div",{className:"comment-list-item",children:M(tt,{commentValue:u.getJsonAttValue(e,oe.HAS_COMMENT_VALUE),author:e[oe.HAS_AUTHOR]?e[oe.HAS_AUTHOR]:null,timestamp:u.getJsonAttValue(e,oe.HAS_TIMESTAMP),onDeleteQuestionComment:t,onDeleteViewComment:l,index:s})},s))})})},nt=()=>/*#__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"})),ot="300px",rt=t=>{const[o,a]=s(""),i=r(null),l=P();n(()=>{i.current.focus()},[]);const c=e=>{e.preventDefault(),t.onChange(o),a("")},u=()=>{const e=i.current;e.style.height="auto",p(e)},p=e=>{e.style.height=`${e.scrollHeight}px`,parseInt(e.style.height)>parseInt(ot)&&(e.style.height=ot)};/*#__PURE__*/return e.createElement(d,{onSubmit:c,onKeyUp:e=>{"Enter"===e.key&&e.ctrlKey&&o.trim()&&c(e)},onClick:e=>{e.stopPropagation()}},/*#__PURE__*/e.createElement(d.Group,{className:"m-2 position-relative",controlId:"formBasicComment"},/*#__PURE__*/e.createElement(g,{className:"col-lg-12 p-0"},/*#__PURE__*/e.createElement(_,{className:"container-fluid p-0 m-0"},/*#__PURE__*/e.createElement("div",{id:"comment-form"},/*#__PURE__*/e.createElement(d.Control,{className:"comment-form-control",name:"comment",as:"textarea",placeholder:l.formatMessage({id:"comment.form.placeholder"}),required:!0,value:o,onChange:e=>{a(e.target.value)},ref:i,onKeyPress:u,onKeyDown:u}),/*#__PURE__*/e.createElement(f,{className:"comment-form-button",variant:"primary",type:"submit"},/*#__PURE__*/e.createElement(nt,null)))))))};rt.propTypes={onChange:l.func.isRequired};const at=()=>/*#__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"})),it=t=>{const a=o(Ee),i=r(null),l=r(null),c=r(null),[u,p]=s(!1),[m,d]=s("right");n(()=>{I(c.current)});const h=()=>{p(!1)},E=()=>{const e=t.question;return e[oe.HAS_COMMENT]||(e[oe.HAS_COMMENT]=[]),Array.isArray(e[oe.HAS_COMMENT])||(e[oe.HAS_COMMENT]=[e[oe.HAS_COMMENT]]),e[oe.HAS_COMMENT]},S=e=>{const s={};g(s,e),t.onChange(N(),s)},g=(e,t)=>{a.options.currentUser&&(e[oe.HAS_AUTHOR]={"@id":a.options.currentUser}),e[oe.HAS_COMMENT_VALUE]=t,e[oe.HAS_TIMESTAMP]=Date.now().toString()},_=e=>{E().splice(e,1)},f=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:f},/*#__PURE__*/e.createElement("span",{className:"comment-bubble",ref:i,onClick:e=>{f(e),p(!u)}},/*#__PURE__*/e.createElement(Ze,null),N()>0?/*#__PURE__*/e.createElement(v,{className:"comment-badge",pill:!0,variant:"primary"},N()):null),/*#__PURE__*/e.createElement(Y.div,{className:"overlay-comment",ref:l,drag:!0,dragConstraints:{top:-50,left:-50,right:50,bottom:50}},/*#__PURE__*/e.createElement(T,{target:i.current,show:u,placement:m,rootClose:!1,onHide:h,container:l},t=>/*#__PURE__*/e.createElement(A,J({className:"comment-tooltip"},t),/*#__PURE__*/e.createElement("span",{onKeyDown:e=>{(e=>{"Escape"===e.key&&h()})(e)}},/*#__PURE__*/e.createElement(Y.div,{className:"close-comment-icon",onClick:h,whileHover:{scale:1.1,transition:{duration:.1}}},/*#__PURE__*/e.createElement(at,null)),/*#__PURE__*/e.createElement(st,{comments:E(),onDeleteCommentClick:_}),/*#__PURE__*/e.createElement(rt,{onChange:S}))))))};var lt;it.propTypes={question:l.object.isRequired,onChange:l.func.isRequired};class ct{static renderIcons(t,s,n,o,r){let a;a=s.icons?s.icons:oe.DEFAULT_OPTIONS.icons;let i=[];const l=this.renderQuestionHelp(t,s,n,o,r),c=this.renderQuestionComments(t,s,n,o,r),u=this.renderQuestionLink(t,s,n,o,r);for(let t=0;t<a.length;t++)a[t].id===oe.ICONS.QUESTION_COMMENTS&&i.push(/*#__PURE__*/e.createElement("li",{key:t,className:"icon-list-item"},c)),a[t].id===oe.ICONS.QUESTION_HELP&&i.push(/*#__PURE__*/e.createElement("li",{key:t,className:"icon-list-item"},l)),a[t].id===oe.ICONS.QUESTION_LINK&&i.push(/*#__PURE__*/e.createElement("li",{key:t,className:"icon-list-item"},u));/*#__PURE__*/return e.createElement("ol",{className:"icon-list-items"},i)}static renderQuestionHelp(e,t,s,n,o){return this.getIconComponentFromName(oe.ICONS.QUESTION_HELP,e,t,s,n,o)}static renderQuestionLink(e,t,s,n,o){return this.getIconComponentFromName(oe.ICONS.QUESTION_LINK,e,t,s,n,o)}static getIconComponentFromName(e,t,s,n,o,r){const a=this.getIconFromIconList(s.icons?s.icons:oe.DEFAULT_OPTIONS.icons,e);return this.getIconComponent(a,t,s,n,o,r)}static getIconComponent(t,s,n,o,r,a){let i;if(t&&(t.behavior===oe.ICON_BEHAVIOR.ON_HOVER||t.behavior===oe.ICON_BEHAVIOR.ENABLE))return t.behavior===oe.ICON_BEHAVIOR.ENABLE?(r=!0,i=""):i="emphasise-on-relevant-icon",t.id===oe.ICONS.QUESTION_HELP&&s[oe.HELP_DESCRIPTION]?r?/*#__PURE__*/e.createElement("div",{className:i},/*#__PURE__*/e.createElement(Ke,{text:u.getLocalized(s[oe.HELP_DESCRIPTION],a),absolutePosition:!1})):null:t.id===oe.ICONS.QUESTION_LINK&&s[oe.SOURCE]?r?/*#__PURE__*/e.createElement("div",{className:i},/*#__PURE__*/e.createElement($e,{url:s[oe.SOURCE]})):null:t.id===oe.ICONS.QUESTION_COMMENTS&&r?/*#__PURE__*/e.createElement("div",{className:i},/*#__PURE__*/e.createElement(it,{question:s,onChange:o})):null}}lt=ct,ct.renderQuestionComments=(e,t,s,n,o)=>lt.getIconComponentFromName(oe.ICONS.QUESTION_COMMENTS,e,t,s,n,o),ct.getIconFromIconList=(e,t)=>e?e.find(e=>e.id===t):null;const ut=t=>{const o=e.useContext(te),{options:r}=e.useContext(Ee),[a,i]=s({severity:"",classname:"",message:null}),l=P();n(()=>{m()},[t.question]);const c=e=>{const s=Object.assign({},t.answer);p(s,e),t.onChange(t.index,s)},p=(e,s)=>{null===s?(e[oe.HAS_OBJECT_VALUE]=null,e[oe.HAS_DATA_VALUE]=null):t.answer[oe.HAS_OBJECT_VALUE]||le.isTypeahead(t.question)?e[oe.HAS_OBJECT_VALUE]={"@id":s}:e[oe.HAS_DATA_VALUE]={"@value":s}},m=()=>{i({severity:"",classname:"",message:null}),!1===d[oe.HAS_VALID_ANSWER]&&i(d[oe.HAS_VALIDATION_SEVERITY]===oe.VALIDATION.SEVERITY.WARNING?{severity:oe.VALIDATION.SEVERITY.WARNING,classname:oe.VALIDATION.CLASSNAME.WARNING,message:/*#__PURE__*/e.createElement(N,{className:oe.VALIDATION.CLASSNAME.WARNING},d[oe.HAS_VALIDATION_MESSAGE])}:{severity:oe.VALIDATION.SEVERITY.ERROR,classname:oe.VALIDATION.CLASSNAME.ERROR,message:/*#__PURE__*/e.createElement(N,{className:oe.VALIDATION.CLASSNAME.ERROR},d[oe.HAS_VALIDATION_MESSAGE])})},d=t.question,h=le.resolveValue(t.answer),E=(s=>{const n=u.getLocalized(s[oe.RDFS_LABEL],l);/*#__PURE__*/return e.createElement("div",{className:"question-header"},n,ct.renderIcons(t.question,r,t.onCommentChange,t.showIcon,l))})(d),S=u.getLocalized(d[oe.RDFS_COMMENT],l);let A;var g;return A=le.isTypeahead(d)?((s,n,r)=>{const i=re.getStringHash(le.getPossibleValuesQuery(t.question)),l=o.getOptions(i)||[];/*#__PURE__*/return e.createElement(Qe,{question:t.question,answer:t.answer,label:n,title:r,value:s,onChange:c,options:l,validation:a})})(h,E,S):(g=d)[oe.HAS_OPTION]&&0!==g[oe.HAS_OPTION].length?((s,n,o)=>/*#__PURE__*/e.createElement(Fe,{question:t.question,label:n,title:o,value:s,onChange:c,validation:a}))(h,E,S):le.isCalendar(d)?((s,n,o)=>/*#__PURE__*/e.createElement(be,{question:t.question,value:s,title:o,label:n,onChange:c,validation:a}))(h,E,S):le.isCheckbox(d)?((s,n,o)=>/*#__PURE__*/e.createElement(Re,{label:n,title:o,value:s,onChange:c,question:t.question,validation:a}))(h,E,S):le.isMaskedInput(d)?((s,n,o)=>/*#__PURE__*/e.createElement(ze,{label:n,title:o,value:s,onChange:c,question:t.question,answer:t.answer,validation:a}))(h,E,S):le.isSparqlInput(d)?((s,n,o)=>/*#__PURE__*/e.createElement(Me,{question:t.question,answer:t.answer,label:n,title:o,value:s,onChange:c,sparql:!0,validation:a}))(h,E,S):le.isTurtleInput(d)?((s,n,o)=>/*#__PURE__*/e.createElement(Me,{question:t.question,answer:t.answer,label:n,title:o,value:s,onChange:c,turtle:!0,validation:a}))(h,E,S):((s,n,o)=>/*#__PURE__*/e.createElement(Me,{question:t.question,answer:t.answer,label:n,title:o,value:s,onChange:c,validation:a}))(h,E,S),A};ut.propTypes={answer:l.object.isRequired,question:l.object.isRequired,onChange:l.func.isRequired,onCommentChange:l.func.isRequired,index:l.number,icons:l.object};const pt=(e,t)=>{const s=[gt,At,dt,Et,ht,St];return()=>{if(le.hasValidationLogic(e,t)){const n=le.getAnswerValue(e);return mt(e,t,n,s)}}},mt=(e,t,s,n)=>{const o={};for(const s of n){const n=s(e,t);if(!n.isValid)return o[oe.HAS_VALID_ANSWER]=!1,o[oe.HAS_VALIDATION_MESSAGE]=n.message,o[oe.HAS_VALIDATION_SEVERITY]=n.validationSeverity,o;if(!1===o[oe.HAS_VALID_ANSWER])break}return o[oe.HAS_VALID_ANSWER]=!0,o[oe.HAS_VALIDATION_MESSAGE]="",o[oe.HAS_VALIDATION_SEVERITY]="",o},dt=(e,t)=>{const s=le.getAnswerValue(e);return s&&s.length>0&&e[oe.PATTERN]&&!new RegExp(e[oe.PATTERN]).test(s)&&le.hasAnswer(e)?{isValid:!1,validationSeverity:oe.VALIDATION.SEVERITY.ERROR,message:e[oe.HAS_VALIDATION_MESSAGE]?e[oe.HAS_VALIDATION_MESSAGE]:t.formatMessage({id:"validation.invalid"})}:{isValid:!0}},ht=(e,t)=>!e[oe.REQUIRES_ANSWER]||e[oe.USED_ONLY_FOR_COMPLETENESS]||le.hasAnswer(e)?{isValid:!0}:{isValid:!1,validationSeverity:oe.VALIDATION.SEVERITY.ERROR,message:e[oe.HAS_VALIDATION_MESSAGE]?e[oe.HAS_VALIDATION_MESSAGE]:t.formatMessage({id:"validation.required"})},Et=(e,t)=>le.isCheckbox(e)&&e[oe.REQUIRES_ANSWER]&&!le.hasAnswer(e)?{isValid:!1,validationSeverity:oe.VALIDATION.SEVERITY.ERROR,message:e[oe.HAS_VALIDATION_MESSAGE]?e[oe.HAS_VALIDATION_MESSAGE]:t.formatMessage({id:"validation.check"})}:{isValid:!0},St=(e,t)=>e[oe.REQUIRES_ANSWER]&&e[oe.USED_ONLY_FOR_COMPLETENESS]&&!le.hasAnswer(e)?{isValid:!1,validationSeverity:oe.VALIDATION.SEVERITY.WARNING,message:e[oe.HAS_VALIDATION_MESSAGE]?e[oe.HAS_VALIDATION_MESSAGE]:t.formatMessage({id:"validation.required_only_for_completeness"})}:{isValid:!0},At=(e,t)=>{if(e[oe.XSD.MIN_INCLUSIVE]){const s=le.getAnswerValue(e);if(s&&s.length>0){const n=e[oe.XSD.MIN_INCLUSIVE];if(!(Number.isInteger(parseInt(s))&&s>=n))return{isValid:!1,validationSeverity:oe.VALIDATION.SEVERITY.ERROR,message:e[oe.HAS_VALIDATION_MESSAGE]?e[oe.HAS_VALIDATION_MESSAGE]:t.formatMessage({id:"validation.greater_or_equal"})+n+"."}}}return{isValid:!0}},gt=(e,t)=>{const s=le.getAnswerValue(e);if(e[oe.XSD.MAX_INCLUSIVE]&&s&&s.length>0){const n=e[oe.XSD.MAX_INCLUSIVE];if(!(Number.isInteger(parseInt(s))&&s<=n))return{isValid:!1,validationSeverity:oe.VALIDATION.SEVERITY.ERROR,message:e[oe.HAS_VALIDATION_MESSAGE]?e[oe.HAS_VALIDATION_MESSAGE]:t.formatMessage({id:"validation.lower_or_equal"})+n+"."}}return{isValid:!0}};class _t 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(O,null,this.state.prefixes.sort((e,t)=>e[oe.PREFIX]<t[oe.PREFIX]?-1:1).map(t=>/*#__PURE__*/e.createElement(C,{key:t[oe.PREFIX]},/*#__PURE__*/e.createElement("strong",null,t[oe.PREFIX]),": ",t[oe.NAMESPACE]))));/*#__PURE__*/return e.createElement(S,{trigger:"click",placement:"right",overlay:t},/*#__PURE__*/e.createElement("span",{className:this.props.iconClass},this.props.children))}}_t.propTypes={prefixes:l.array.isRequired,children:l.element.isRequired,iconClass:l.string},_t.defaultProps={iconClass:""};const ft=({question:e})=>(()=>{const t=e[oe.HAS_MEDIA_CONTENT];return t?Array.isArray(t)?M("div",{className:"col-6",children:t.map((e,s)=>M("div",{className:"row embed-responsive-21by9 media-content-video-container mb-3",children:M("iframe",{src:t[s],className:"embed-responsive-item",allowFullScreen:!0})},s))}):M("div",{className:"col-6",children:M("iframe",{src:t,className:"embed-responsive-item",allowFullScreen:!0})}):null})();class vt extends e.Component{constructor(e){super(e),this.handleAnswerChange=(e,t)=>{if(le.isSection(this.props.question)){let e=!!le.resolveValue(t);this.setState({expanded:e})}this._handleChange(oe.HAS_ANSWER,e,t)},this.handleSubQuestionChange=(e,t)=>{this._handleChange(oe.HAS_SUBQUESTION,e,t)},this.handleCommentChange=(e,t)=>{this._handleChange(oe.HAS_COMMENT,e,t)},this._toggleCollapse=()=>{this.props.collapsible&&this.setState({expanded:!this.state.expanded})},this._onEnterHandler=()=>{this.setState({showIcon:!0})},this._onLeaveHandler=()=>{this.setState({showIcon:!1})},this._getHeaderClassName=()=>{const e=this.props.question,t=this.props.collapsible;let s=[];return s.push(vt.getEmphasizedOnRelevantClass(e),"question-header"),le.isWizardStep(e)&&s.push("wizard-step bg-primary text-white"),le.isEmphasised(e)&&s.push(vt.getEmphasizedClass(e)),le.isSection(e)&&s.push("section-background"),t&&s.push("cursor-pointer"),this.isDebugged(e)&&s.push("show-irrelevant"),s},ae.putObject(e.question["@id"],e.question),this.state={validator:{},expanded:!le.isCollapsed(e.question),showIcon:!1}}componentDidMount(){this.setState({validator:pt(this.props.question,this.props.intl)})}componentDidUpdate(){const e=this.props.question,t=this.context.options.startingQuestionId,s=e[oe.HAS_SUBQUESTION].find(e=>e["@id"]===t);if(le.isSection(e)&&le.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===oe.HAS_ANSWER){const e=this.state.validator(s);n=Object.assign({},n,e)}ae.putObject(n["@id"],n),this.props.onChange(this.props.index,n)}isDebugged(e){const t=this.context.options.startingQuestionId;return!le.isRelevant(e)&&(!!this.context.options.debugMode||null!=t&&!!re.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):le.isHidden(t)?null:le.isRelevant(t)?s:null}renderQuestion(t){if(le.isAnswerable(t)&&!le.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(le.isAnswerable(t))return this.renderAnswerableSection();if(le.isSection(t)){const{collapsible:s,withoutCard:n}=this.props,o=vt._getQuestionCategoryClass(t);if(n)/*#__PURE__*/return e.createElement("div",null,this._renderQuestionContent());const r=u.getLocalized(t[u.RDFS_LABEL],this.props.intl),a=/*#__PURE__*/e.createElement(w.Body,{className:F("p-3",o)},this._renderQuestionContent());/*#__PURE__*/return e.createElement(e.Fragment,null,/*#__PURE__*/e.createElement(L,{activeKey:this.state.expanded?r:void 0,className:"mb-3"},/*#__PURE__*/e.createElement(L.Item,{eventKey:r},/*#__PURE__*/e.createElement(w,{className:""},/*#__PURE__*/e.createElement(L.Button,{as:w.Header,onClick:this._toggleCollapse,className:this._getHeaderClassName(),onMouseEnter:this._onEnterHandler,onMouseLeave:this._onLeaveHandler,onFocus:this._onEnterHandler,onBlur:this._onLeaveHandler},/*#__PURE__*/e.createElement("div",{className:"d-inline",id:t["@id"]},s&&!le.isWizardStep(t)&&this._renderCollapseToggle(),r),this.renderQuestionIcons(),this.props.children),/*#__PURE__*/e.createElement(L.Body,{className:"p-0"},s?a:/*#__PURE__*/e.createElement(e.Fragment,null,a))))))}/*#__PURE__*/return e.createElement("div",null,this._renderQuestionContent())}_renderQuestionContent(){let t=[];return this.state.expanded&&t.push(/*#__PURE__*/e.createElement(ft,{key:this.props.question["@id"]+"-media",question:this.props.question})),t.push(this.renderAnswers()),t.push(this.renderSubQuestions()),t}renderQuestionIcons(){return ct.renderIcons(this.props.question,this.context.options,this.handleCommentChange,this.state.showIcon,this.props.intl)}renderAnswerableSection(){const t=this.props.question,s=this.props.collapsible,n=vt._getQuestionCategoryClass(t);let o=this.getShowIrrelevantClassname(t);const r=/*#__PURE__*/e.createElement(w.Body,{className:F("p-3",n)},this.renderSubQuestions(o)),a=this._getHeaderClassName();return this.state.expanded&&a.push("text-primary"),/*#__PURE__*/e.createElement(L,{activeKey:this.state.expanded?t["@id"]:void 0,className:"answerable-section"},/*#__PURE__*/e.createElement(w,{className:"mb-3"},/*#__PURE__*/e.createElement(w.Header,{onClick:this._toggleCollapse,className:a},this.renderAnswers()),s?/*#__PURE__*/e.createElement(L.Collapse,{className:o,eventKey:t["@id"]},r):{cardBody:r}))}getShowIrrelevantClassname(e){return!this.context.options.debugMode&&!ie.checkId(e[oe.HAS_SUBQUESTION],this.context.options.startingQuestionId)||le.hasAnswer(e)?"":"show-irrelevant"}renderAnswers(){const t=this.props.question,s=[],n=this._getAnswers();let o;for(let r=0,a=n.length;r<a;r++)le.isTextarea(t,le.resolveValue(n[r]))||le.isSparqlInput(t)||le.isTurtleInput(t),o=F("answer",vt._getQuestionCategoryClass(t),vt.getEmphasizedOnRelevantClass(t)),s.push(/*#__PURE__*/e.createElement("div",{key:"row-item-"+r,className:o,id:t["@id"],onMouseEnter:this._onEnterHandler,onMouseLeave:this._onLeaveHandler,onFocus:this._onEnterHandler,onBlur:this._onLeaveHandler},/*#__PURE__*/e.createElement("div",{className:"answer-content",style:this._getAnswerWidthStyle()},/*#__PURE__*/e.createElement(ut,{index:r,answer:n[r],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[oe.HAS_ANSWER]||(e[oe.HAS_ANSWER]=[]),Array.isArray(e[oe.HAS_ANSWER])||(e[oe.HAS_ANSWER]=[e[oe.HAS_ANSWER]]),0===e[oe.HAS_ANSWER].length&&(e[oe.HAS_ANSWER]=le.isSection(e)&&!le.isAnswerable(e)?[]:[Le.generateAnswer(e)]),e[oe.HAS_ANSWER]}_getAnswerWidthStyle(){const e=Number(this.props.question[oe.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===oe.GENERATED_ROW_SIZE?"col-6":"col-"+oe.COLUMN_COUNT/oe.GENERATED_ROW_SIZE}static _getQuestionCategoryClass(e){const t=le.getCategory(e);return t?"question-"+t:""}static getEmphasizedClass(e){return le.isEmphasised(e)?"bg-warning":""}static getEmphasizedOnRelevantClass(e){return u.hasValue(e,oe.LAYOUT_CLASS,oe.LAYOUT.EMPHASISE_ON_RELEVANT)?"emphasise-on-relevant":""}_renderCollapseToggle(){const t=this.props.intl.formatMessage(this.state.expanded?{id:"section.collapse"}:{id:"section.expand"});/*#__PURE__*/return e.createElement("span",{onClick:this._toggleCollapse,title:t},/*#__PURE__*/e.createElement(this.state.expanded?Be:We,{title:t}))}_renderPrefixes(){const t=this.props.question;return t[oe.HAS_DECLARED_PREFIX]&&t[oe.HAS_DECLARED_PREFIX].length?/*#__PURE__*/e.createElement(_t,{prefixes:t[oe.HAS_DECLARED_PREFIX],iconClass:"help-icon-checkbox"},/*#__PURE__*/e.createElement(Xe,null)):null}_renderUnits(){const t=this.props.question;return t[oe.HAS_UNIT]?/*#__PURE__*/e.createElement("div",{className:"has-unit-label"},t[oe.HAS_UNIT]):null}renderSubQuestions(t){const s=[],n=this._getSubQuestions(),o=this.context.options.debugMode,r=this.context.options.startingQuestionId;for(let a=0;a<n.length;a++){let i=n[a],l=this.context.mapComponent(i,vt),c=null;(o||"show-irrelevant"!==t||re.findQuestionById(r,i,!0,!1,!1))&&(c=/*#__PURE__*/e.createElement(l,{key:"sub-question-"+a,question:i,onChange:this.handleSubQuestionChange,index:a,intl:this.props.intl})),s.push(c)}return s}_getSubQuestions(){const e=this.props.question;return e[oe.HAS_SUBQUESTION]||(e[oe.HAS_SUBQUESTION]=[]),Array.isArray(e[oe.HAS_SUBQUESTION])||(e[oe.HAS_SUBQUESTION]=[e[oe.HAS_SUBQUESTION]]),ie.orderByLocalizedLabels(e[oe.HAS_SUBQUESTION],this.props.intl),ie.orderPreservingToplogicalSort(e[oe.HAS_SUBQUESTION],oe.HAS_PRECEDING_QUESTION),e[oe.HAS_SUBQUESTION]}_getFirstAnswerValue(){return le.resolveValue(this._getAnswers()[0])}}vt.contextType=Ee,vt.propTypes={question:l.object.isRequired,onChange:l.func.isRequired,index:l.number,withoutCard:l.bool,collapsible:l.bool},vt.defaultProps={withoutCard:!1,collapsible:!0};const Tt=t=>{const{updateFormQuestionsData:s,getFormQuestionsData:n}=o(pe),r=P(),a=n([t.index]);/*#__PURE__*/return e.createElement(e.Fragment,null,/*#__PURE__*/e.createElement(vt,{question:a,onChange:(e,n)=>{s(t.index||e,Object.assign({},t.question,n))},collapsible:le.isAnswerable(a),intl:r}),t.options.wizardStepButtons&&/*#__PURE__*/e.createElement(R,{className:"m-3 float-end"},!t.isFirstStep&&/*#__PURE__*/e.createElement(f,{className:"me-2",onClick:()=>{t.onPreviousStep()},variant:"primary",size:"sm"},r.formatMessage({id:"wizard.previous"})),!t.isLastStep&&/*#__PURE__*/e.createElement(f,{onClick:()=>{s(t.index,n()),t.onNextStep()},variant:"primary",size:"sm"},r.formatMessage({id:"wizard.next"}))))};Tt.propTypes={options:l.object.isRequired,question:l.object.isRequired,index:l.number.isRequired,onNextStep:l.func,onPreviousStep:l.func,mapComponent:l.func,isFirstStep:l.bool,isLastStep:l.bool};const Nt=({steps:t,onNavigate:s,currentStep:n})=>{const{options:r}=o(Ee),a=P();/*#__PURE__*/return e.createElement(w.Header,null,/*#__PURE__*/e.createElement(b,{variant:"tabs",activeKey:n,onSelect:e=>s(parseInt(e))},t.map((t,s)=>/*#__PURE__*/e.createElement(Ye,{id:"step-disabled",tooltipContent:a.formatMessage({id:"wizard.nav.tooltip"}),show:!r.enableWizardStepSkip},/*#__PURE__*/e.createElement(y,{key:"nav"+s,id:"wizard-nav-"+s},/*#__PURE__*/e.createElement(D,{eventKey:s,active:s===n?"active":"",hidden:!r.debugMode&&!le.isRelevant(t),disabled:!r.enableWizardStepSkip,className:F([r.debugMode&&!le.isRelevant(t)?"show-irrelevant":vt.getEmphasizedClass(t),"wizard-nav"])},u.getLocalized(t[u.RDFS_LABEL],a)))))))};Nt.propTypes={currentStep:l.number.isRequired,steps:l.array.isRequired,onNavigate:l.func.isRequired};const It=({steps:t,onNavigate:s,currentStep:n})=>{const{options:r}=o(Ee),a=P();/*#__PURE__*/return e.createElement("div",{className:"wizard-nav col-2 p-0"},/*#__PURE__*/e.createElement(O,null,t.map((t,o)=>/*#__PURE__*/e.createElement(Ye,{id:"step-disabled",tooltipContent:a.formatMessage({id:"wizard.nav.tooltip"}),show:!r.enableWizardStepSkip},/*#__PURE__*/e.createElement(C,{hidden:!r.debugMode&&!le.isRelevant(t),key:"nav"+o,onClick:()=>s(o),id:"wizard-nav-"+o,action:!0,active:o===n?"active":"",disabled:!r.enableWizardStepSkip,variant:"default",className:F([r.debugMode&&!le.isRelevant(t)?"show-irrelevant":vt.getEmphasizedClass(t),"wizard-nav"])},u.getLocalized(t[u.RDFS_LABEL],P()))))))};It.propTypes={currentStep:l.number.isRequired,steps:l.array.isRequired,onNavigate:l.func.isRequired};const Ot=()=>{const t=e.useContext(pe),{options:s,mapComponent:o}=e.useContext(Ee);let r=0;s.startingQuestionId?(r=((e,t)=>{const s=(e,n)=>e?e["@id"]===t?n:re.asArray(e[oe.HAS_SUBQUESTION]).findIndex((e,t)=>-1!==s(e,t)):-1;return e.findIndex((e,t)=>-1!==s(e,t))})(t.getFormQuestionsData(),s.startingQuestionId),-1===r&&(console.warn(`Question with id ${s.startingQuestionId} not found!`),r=0)):s.startingStep&&(r=s.startingStep<t.getFormQuestionsData().length?s.startingStep:0);const[a,i]=e.useState(r),[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();a!==e.length-1&&(e[a+1].visited=!0,i(e=>e+1))},p=()=>{0!==a&&i(e=>e-1)},m=e=>{const n=t.getFormQuestionsData();e===a||e>=n.length||e>a&&!n[e].visited&&!s.enableWizardStepSkip||i(e)};let d=null;t.getFormQuestionsData().length>1&&(d=(()=>{const n=t.getFormQuestionsData();/*#__PURE__*/return e.createElement(s.horizontalWizardNav?Nt:It,{currentStep:a,steps:n,onNavigate:m})})());const h=s.horizontalWizardNav;/*#__PURE__*/return e.createElement(w,{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()[a];let r=o(n,Tt);/*#__PURE__*/return e.createElement(r,{options:s,key:"step"+a,question:n,onNextStep:u,onPreviousStep:p,mapComponent:o,index:a,isFirstStep:0===a,isLastStep:a===t.getFormQuestionsData().length-1})})()))},Ct=/*#__PURE__*/e.forwardRef((t,s)=>{const{options:n}=e.useContext(Ee);/*#__PURE__*/return e.createElement(V,J({size:"xl",animation:!0},n.modalProps),/*#__PURE__*/e.createElement(V.Header,{closeButton:!0},/*#__PURE__*/e.createElement(V.Title,null,n.modalProps.title)),/*#__PURE__*/e.createElement(V.Body,{className:"overflow-hidden p-0"},t.children))});var wt;Ct.propTypes={children:l.element.isRequired};class Lt{}wt=Lt,Lt.updateQuestionValidation=(e,t,s,n)=>{const o=pt(t,n)();o&&(e[s]=Object.assign({},t,o));for(const t of e)wt.updateSubQuestionsValidation(t,n)},Lt.updateSubQuestionsValidation=(e,t)=>{const s=re.asArray(e[oe.HAS_SUBQUESTION]);for(let e=0;e<s.length;e++)wt.updateQuestionValidation(s,s[e],e,t)};const Rt=/*#__PURE__*/a((t,s)=>{const{getFormQuestionsData:n,updateFormQuestionsData:r,getData:a}=o(pe),l=P();i(s,()=>({validateForm:u,getFormSpecification:p,getFormQuestionsData:n,getFormData:c}),[]);const c=()=>{const e=a(),t=n();return Le.buildQuestionAnswerModel(e,t)},u=()=>{const e=n();for(let t=0;t<e.length;t++)Lt.updateQuestionValidation(e,e[t],t,l);r(null,e)},p=()=>{const e=n();return le.getFormSpecification(e)},m=()=>{const t=n();/*#__PURE__*/return e.createElement(w,{className:"p-3"},t.map((e,t)=>d(e,t)))},d=(s,n)=>{let o=t.mapComponent(s,vt);/*#__PURE__*/return e.createElement(o,{key:s["@id"],question:s,onChange:(e,t)=>((e,t,s)=>{r(t,Object.assign({},e,s))})(s,e,t),index:n,intl:l})},{modalView:h}=t,E=n();if(!E.length)/*#__PURE__*/return e.createElement(w,{className:"p-3 font-italic"},"There are no questions available...");const S=E.every(e=>!le.isWizardStep(e));return h?/*#__PURE__*/e.createElement(Ct,null,S?m():/*#__PURE__*/e.createElement(Ot,null)):S?m():/*#__PURE__*/e.createElement(Ot,null)});class bt extends e.Component{constructor(e){super(e),this.state={hasError:!1,errorLabel:null,errorDetails:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({errorLabel:e,errorDetails:t})}render(){if(this.state.hasError){const{lang:t}=this.context;/*#__PURE__*/return e.createElement("div",{style:{padding:"20px"}},/*#__PURE__*/e.createElement(H,{variant:"danger"},/*#__PURE__*/e.createElement(H.Heading,null,t["error.default_message"]||"Something went wrong."),/*#__PURE__*/e.createElement("p",null,this.state.errorLabel&&this.state.errorLabel.toString())),/*#__PURE__*/e.createElement(L,null,/*#__PURE__*/e.createElement(w,null,/*#__PURE__*/e.createElement(w.Header,null,/*#__PURE__*/e.createElement(L,{as:f,variant:"link",eventKey:"0"},t["error.view_details"]||"View Error Details")),/*#__PURE__*/e.createElement(L.Collapse,{eventKey:"0"},/*#__PURE__*/e.createElement(w.Body,null,/*#__PURE__*/e.createElement("pre",{style:{whiteSpace:"pre-wrap"}},this.state.errorDetails&&this.state.errorDetails.componentStack))))))}return this.props.children}}bt.contextType=fe;const yt=/*#__PURE__*/a((t,o)=>{const[r,a]=s(!0),[i,l]=s(null),[c,u]=s(null),p=P();if(n(()=>{(async()=>{const[e,s]=await we.constructForm(t.form,p);e.formQuestions.some(e=>le.isWizardStep(e))&&(e.formQuestions[0].visited=!0),l(e),u(s),a(!1)})()},[t.form]),r)return t.loader||/*#__PURE__*/e.createElement(w,{className:"p-3 font-italic"},"Loading SForms...");const m=((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(Ae,{components:t.components,componentsOptions:t.componentsOptions,mapComponent:m,options:t.options},/*#__PURE__*/e.createElement(ve,{locale:p.locale},/*#__PURE__*/e.createElement(bt,null,/*#__PURE__*/e.createElement(se,{fetchTypeAheadValues:t.fetchTypeAheadValues},/*#__PURE__*/e.createElement(me,{data:c,formQuestions:i.formQuestions,isFormValid:t.isFormValid},/*#__PURE__*/e.createElement(Rt,{ref:o,modalView:t.options&&t.options.modalView,mapComponent:m}))))))});yt.propTypes={form:l.object.isRequired,options:l.object.isRequired,componentMapRules:l.array,components:l.object,componentsOptions:l.object,fetchTypeAheadValues:l.func,isFormValid:l.func,loader:l.element};export{ut as Answer,Ee as ConfigurationContext,oe as Constants,pe as FormQuestionsContext,le as FormUtils,Ke as HelpIcon,ve as IntlContextProvider,Ce as JsonLdFramingUtils,ae as JsonLdObjectMap,ie as JsonLdObjectUtils,vt as Question,ct as QuestionStatic,Tt as WizardStep,yt as default};
2
2
  //# sourceMappingURL=s-forms.modern.js.map