UNPKG

@kbss-cvut/s-forms

Version:

Semantic forms generator and processor

1 lines 113 kB
import e,{useMemo as t,useState as n,useEffect as o,useContext as r,useRef as i,useCallback as a,forwardRef as s,useImperativeHandle as l}from"react";import*as u from"jsonld-utils";import{IntlProvider as c,useIntl as d}from"react-intl";import"core-js/modules/es.array.some.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.promise.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.array.find.js";import"core-js/modules/es.array.for-each.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.array.sort.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/web.dom-collections.for-each.js";import*as m from"jsonld";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.array.is-array.js";import"core-js/modules/es.object.values.js";import"core-js/modules/es.string.includes.js";import"core-js/modules/es.string.repeat.js";import p from"@kbss-cvut/tsort";import"core-js/modules/es.array.iterator.js";import"core-js/modules/es.set.js";import"core-js/modules/es.string.iterator.js";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"core-js/modules/web.dom-collections.iterator.js";import{Form as f,FormGroup as h,FormControl as v,Alert as E,Accordion as A,Card as g,Button as S,OverlayTrigger as _,Tooltip as T,Col as N,Row as O,Badge as I,Overlay as C,FormText as b,Popover as y,ListGroup as R,ListGroupItem as L,ButtonToolbar as w,Nav as H,NavItem as D,NavLink as V,Modal as M}from"react-bootstrap";import"core-js/modules/es.object.assign.js";import j from"prop-types";import"core-js/modules/es.number.constructor.js";import"core-js/modules/es.number.max-safe-integer.js";import U from"react-dom";import"core-js/modules/es.date.to-string.js";import"core-js/modules/es.regexp.to-string.js";import"core-js/modules/es.array.concat.js";import"core-js/modules/es.array.every.js";import"core-js/modules/es.array.find-index.js";import P from"react-datepicker";import{parse as x,format as q}from"date-fns";import k from"classnames";import"core-js/modules/es.array.index-of.js";import"core-js/modules/es.array.slice.js";import"core-js/modules/es.object.get-own-property-names.js";import F from"yasgui-yasqe";import"@triply/yasgui/build/yasgui.min.css";import"core-js/modules/web.timers.js";import z from"inputmask-core";import"core-js/modules/es.string.trim.js";import{IntelligentTreeSelect as Q}from"intelligent-tree-select/lib/components/IntelligentTreeSelect";import B from"intelligent-tree-select/lib/components/Option";import"intelligent-tree-select/lib/styles.css";import"core-js/modules/es.array.splice.js";import"core-js/modules/es.date.now.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.replace.js";import W from"javascript-time-ago";import Y from"javascript-time-ago/locale/en";import X from"javascript-time-ago/locale/cs";import{motion as G}from"framer-motion";import{Rings as K}from"react-loader-spinner";import"core-js/modules/es.parse-int.js";import"core-js/modules/es.number.is-integer.js";import"core-js/modules/es.regexp.constructor.js";import"core-js/modules/es.array.join.js";import"core-js/modules/es.parse-float.js";import"core-js/modules/es.string.split.js";import"video.js/dist/video-js.css";import"core-js/modules/es.array.reduce.js";import J from"video.js";import"core-js/modules/es.array.fill.js";import"core-js/modules/es.object.entries.js";function Z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function $(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Z(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Z(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ee(){return ee=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},ee.apply(null,arguments)}function te(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,oe(e,t)}function ne(e,t){if(null==e)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(-1!==t.indexOf(o))continue;n[o]=e[o]}return n}function oe(e,t){return oe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},oe(e,t)}var re,ie=function(){};re=ie,ie.COLUMN_COUNT=12,ie.INPUT_LENGTH_THRESHOLD=50,ie.DATETIME_NUMBER_FORMAT="x",ie.EPOCH_MILLISECONDS="epoch-milliseconds",ie.FORM="http://onto.fel.cvut.cz/ontologies/documentation/form",ie.HAS_SUBQUESTION="http://onto.fel.cvut.cz/ontologies/documentation/has_related_question",ie.HAS_ANSWER="http://onto.fel.cvut.cz/ontologies/documentation/has_answer",ie.HAS_OPTION="http://onto.fel.cvut.cz/ontologies/form/has-possible-value",ie.HAS_OPTIONS_QUERY="http://onto.fel.cvut.cz/ontologies/form/has-possible-values-query",ie.HAS_VALUE_TYPE="http://onto.fel.cvut.cz/ontologies/form/has-value-type",ie.IS_DISABLED="http://onto.fel.cvut.cz/ontologies/aviation/form-376/is-disabled",ie.INPUT_MASK="http://onto.fel.cvut.cz/ontologies/form/has-input-mask",ie.LAYOUT_CLASS="http://onto.fel.cvut.cz/ontologies/form-layout/has-layout-class",ie.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"]},ie.HAS_INITIAL_INPUT_LENGTH="http://onto.fel.cvut.cz/ontologies/form-layout/has-initial-input-length",ie.VALUE_TYPE_CODE="code",ie.VALUE_TYPE_TEXT="text",ie.GENERATED_ROW_SIZE=1,ie.HAS_QUESTION_ORIGIN="http://onto.fel.cvut.cz/ontologies/form/has-question-origin",ie.HAS_ANSWER_ORIGIN="http://onto.fel.cvut.cz/ontologies/form/has-answer-origin",ie.HAS_DATA_VALUE="http://onto.fel.cvut.cz/ontologies/documentation/has_data_value",ie.HAS_OBJECT_VALUE="http://onto.fel.cvut.cz/ontologies/documentation/has_object_value",ie.HELP_DESCRIPTION="http://purl.org/dc/terms/description",ie.SOURCE="http://purl.org/dc/terms/source",ie.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"},ie.STEP="http://onto.fel.cvut.cz/ontologies/form/step",ie.PATTERN="http://onto.fel.cvut.cz/ontologies/form/pattern",ie.ACCEPTS_ANSWER_VALUE="http://onto.fel.cvut.cz/ontologies/form/accepts-answer-value",ie.ACCEPTS="http://onto.fel.cvut.cz/ontologies/form/accepts",ie.HAS_DATATYPE="http://onto.fel.cvut.cz/ontologies/form/has-datatype",ie.HAS_LAYOUT_CLASS="http://onto.fel.cvut.cz/ontologies/form/has-layout-class",ie.HAS_POSSIBLE_VALUES_QUERY="http://onto.fel.cvut.cz/ontologies/form/has-possible-values-query",ie.HAS_REQUIRED_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-required-value",ie.HAS_TESTED_QUESTION="http://onto.fel.cvut.cz/ontologies/form/has-tested-question",ie.HAS_TESTED_FORM="http://onto.fel.cvut.cz/ontologies/form/has-tested-form",ie.HAS_UNIT="http://onto.fel.cvut.cz/ontologies/form/has-unit",ie.HAS_VALID_ANSWER="http://onto.fel.cvut.cz/ontologies/form/has-valid-answer",ie.HAS_CORRECT_ANSWER="http://onto.fel.cvut.cz/ontologies/form/has-correct-answer-value",ie.IS_RELEVANT_IF="http://onto.fel.cvut.cz/ontologies/form/is-relevant-if",ie.ACCEPTS_VALIDATION_VALUE="http://onto.fel.cvut.cz/ontologies/form/accepts-validation-value",ie.HAS_VALIDATION_MESSAGE="http://onto.fel.cvut.cz/ontologies/form/has-validation-message",ie.NEGATIVE_CONDITION="http://onto.fel.cvut.cz/ontologies/form/negative-condition",ie.REQUIRES_ANSWER="http://onto.fel.cvut.cz/ontologies/form/requires-answer",ie.USED_ONLY_FOR_COMPLETENESS="http://onto.fel.cvut.cz/ontologies/form/used-only-for-completeness",ie.REQUIRES_ANSWER_DESCRIPTION_IF="http://onto.fel.cvut.cz/ontologies/form/requires-answer-description-if",ie.REQUIRES_ANSWER_IF="http://onto.fel.cvut.cz/ontologies/form/requires-answer-if",ie.HAS_PRECEDING_QUESTION="http://onto.fel.cvut.cz/ontologies/form/has-preceding-question",ie.HAS_PRECEDING_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-preceding-value",ie.HAS_MEDIA_CONTENT="http://onto.fel.cvut.cz/ontologies/form/has-media-content",ie.ASSET="http://onto.fel.cvut.cz/ontologies/form/media/asset",ie.HAS_SOURCE="http://onto.fel.cvut.cz/ontologies/form/media/has-source",ie.HAS_ANNOTATION="http://onto.fel.cvut.cz/ontologies/form/media/has-annotation",ie.CONDITION="http://onto.fel.cvut.cz/ontologies/form/condition",ie.OR_CONDITION="http://onto.fel.cvut.cz/ontologies/form/or-condition",ie.HAS_SUB_CONDITION="http://onto.fel.cvut.cz/ontologies/form/has-sub-condition",ie.HAS_PATTERN="http://onto.fel.cvut.cz/ontologies/form-lt/has-pattern",ie.HAS_DECLARED_PREFIX="http://onto.fel.cvut.cz/ontologies/form-spin/has-declared-prefix",ie.PREFIX="http://www.w3.org/ns/shacl#prefix",ie.NAMESPACE="http://www.w3.org/ns/shacl#namespace",ie.HAS_COMMENT="http://onto.fel.cvut.cz/ontologies/form/has-comment",ie.HAS_COMMENT_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-comment-value",ie.HAS_AUTHOR="http://onto.fel.cvut.cz/ontologies/form/has-author",ie.HAS_TIMESTAMP="http://onto.fel.cvut.cz/ontologies/form/has-timestamp",ie.TIME_FORMAT="http://onto.fel.cvut.cz/ontologies/form/time-format",ie.DATE_FORMAT="http://onto.fel.cvut.cz/ontologies/form/date-format",ie.DATETIME_FORMAT="http://onto.fel.cvut.cz/ontologies/form/datetime-format",ie.TIMESTAMP_FORMAT="http://onto.fel.cvut.cz/ontologies/form/timestamp-format",ie.NOT_ANSWERED_QUESTION="http://onto.fel.cvut.cz/ontologies/form/not-answered-question",ie.ANSWERED_QUESTION="http://onto.fel.cvut.cz/ontologies/form/answered-question",ie.HAS_VALIDATION_SEVERITY="http://onto.fel.cvut.cz/ontologies/form/has-validation-severity",ie.RDFS_LABEL=u.RDFS_LABEL,ie.RDFS_COMMENT=u.RDFS_COMMENT,ie.DEFAULT_HAS_CHILD=u.DEFAULT_HAS_CHILD,ie.BROADER="http://www.w3.org/2004/02/skos/core#broader",ie.HAS_NON_SELECTABLE_VALUE="http://onto.fel.cvut.cz/ontologies/form/has-non-selectable-value",ie.PROVIDES_DEREFERENCEABLE_ANSWER_VALUES="http://onto.fel.cvut.cz/ontologies/form/provides-dereferenceable-answer-values",ie.ICONS={QUESTION_COMMENTS:"questionComments",QUESTION_HELP:"questionHelp",QUESTION_LINK:"questionLink",QUESTION_HINT:"questionHint"},ie.ICON_BEHAVIOR={ENABLE:"enable",DISABLE:"disable",ON_HOVER:"onHover"},ie.DEFAULT_OPTIONS={icons:[{id:re.ICONS.QUESTION_HELP,behavior:re.ICON_BEHAVIOR.ENABLE},{id:re.ICONS.QUESTION_COMMENTS,behavior:re.ICON_BEHAVIOR.ON_HOVER},{id:re.ICONS.QUESTION_LINK,behavior:re.ICON_BEHAVIOR.ON_HOVER},{id:re.ICONS.QUESTION_HINT,behavior:re.ICON_BEHAVIOR.DISABLE}],enableOptionQuestionFeedback:!1},ie.ANNOTATION={HAS_ANNOTATION_TYPE:"http://onto.fel.cvut.cz/ontologies/form/media/annotation/has-annotation-type",HAS_START_TIME:"http://onto.fel.cvut.cz/ontologies/form/media/annotation/has-start-time",HAS_END_TIME:"http://onto.fel.cvut.cz/ontologies/form/media/annotation/has-end-time",HAS_GEOMETRY_POINTS:"http://onto.fel.cvut.cz/ontologies/form/media/annotation/has-geometry-points",HAS_OPACITY:"http://onto.fel.cvut.cz/ontologies/form/media/annotation/has-opacity",HAS_COLOR:"http://onto.fel.cvut.cz/ontologies/form/media/annotation/has-color"},ie.POLYLINE_ANNOTATION={IMPLICIT_TYPE_LABEL:"polyline",HAS_STROKE_WIDTH:"http://onto.fel.cvut.cz/ontologies/form/media/annotation/has-stroke-width",HAS_FILL_COLOR:"http://onto.fel.cvut.cz/ontologies/form/media/annotation/has-fill-color",DEFAULT_POLYLINE_ANNOTATION_STYLE:{color:"red",strokeWidth:2e-6,fillColor:"transparent",opacity:1}},ie.TEXT_ANNOTATION={IMPLICIT_TYPE_LABEL:"text",HAS_FONT_SIZE:"http://onto.fel.cvut.cz/ontologies/form/media/annotation/has-font-size",HAS_FONT_WEIGHT:"http://onto.fel.cvut.cz/ontologies/form/media/annotation/has-font-weight",HAS_TEXT:"http://onto.fel.cvut.cz/ontologies/form/media/annotation/has-text",DEFAULT_TEXT_ANNOTATION_STYLE:{text:"Hello world",color:"red",fontSizeInNormalizedPx:.05,fontWeight:"300",fontFamily:"sans-serif",fontColor:"red",opacity:1}},ie.LANG={cs:{locale:"cs",label:"Čestina"},en:{locale:"en",label:"English"}},ie.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"}};var ae={"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"},se={"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"},le=/*#__PURE__*/e.createContext({}),ue=function(t){var n=t.locale,o=void 0===n?navigator.language:n,r=se;return o===ie.LANG.cs.locale&&(r=ae),/*#__PURE__*/e.createElement(le.Provider,{value:{locale:o,lang:r}},/*#__PURE__*/e.createElement(c,{locale:o,messages:r},t.children))},ce={"@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":""}}]}]}]},de=/*#__PURE__*/function(){function e(){}return e.generateForm=function(){return JSON.parse(JSON.stringify(ce))},e}(),me=/*#__PURE__*/function(){function e(){}return e.getStringHash=function(e){var t=0,n=e?e.length:0;if(0===n)return t;for(var o=0;o<n;o++)t=(t<<5)-t+e.charCodeAt(o),t&=t;return t},e.asArray=function(e){return e?e.constructor===Array?e:[e]:[]},e.findQuestionById=function(t,n,o,r,i){if(o&&n["@id"]===t)return n;var a=e.asArray(n[ie.HAS_SUBQUESTION]);if(r)for(var s,l=$(a);!(s=l()).done;){var u=e.findQuestionById(t,s.value,!0,!1,!1);if(u)return u}if(i)for(var c,d=$(a);!(c=d()).done;){var m=e.findQuestionById(t,c.value,!1,!0,!0);if(m)return m}return null},e.findKeyInObjects=function(e,t){for(var n=0;n<e.length;n++)for(var o=0;o<t.length;o++)if(e[n].hasOwnProperty(t[o]))return t[o];return null},e.isOptionQuestionFeedbackEnabled=function(e){var t;return null!=(t=null==e?void 0:e.enableOptionQuestionFeedback)&&t},e}(),pe=/*#__PURE__*/function(){function e(){}return e.putObject=function(t,n){e.objectMap[t]=n},e.getObject=function(t){return e.objectMap[t]},e}();pe.objectMap={};var fe,he,ve=/*#__PURE__*/function(){function e(){}return e.getFirstObject=function(e,t){var n=m.getValues(e,t);return 0===n.length?null:n[0]},e.compareValues=function(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"])))||m.compareValues(e,t)},e.toplogicalSort=function(e,t){var n;do{n=!1;for(var o=0;o<e.length;o++)for(var r=o;r<e.length;r++)if(e[o][t]&&("object"==typeof e[o][t]?e[o][t]["@id"]:e[o][t])===e[r]["@id"]){var i=e[o];e[o]=e[r],e[r]=i,n=!0;break}}while(n);return e},e.orderPreservingToplogicalSort=function(e,t){for(var n=p(),o={},r=function(){var r=e[i]["@id"];n.add(r),o[r]=e[i],me.asArray(e[i][t]).map(function(e){return"object"==typeof e?e["@id"]:e}).map(function(e){return[e,r]}).forEach(function(e){return n.add(e)})},i=0;i<e.length;i++)r();for(var a=n.sort(),s=0;s<a.length;s++)e[s]=o[a[s]];return e},e.getCompareLocalizedLabelFunction=function(e){return function(t,n){var o=u.getLocalized(t[u.RDFS_LABEL],e),r=u.getLocalized(n[u.RDFS_LABEL],e);return o<r?-1:o>r?1:0}},e.orderByLocalizedLabels=function(t,n){return t.sort(e.getCompareLocalizedLabelFunction(n))},e.checkId=function(e,t){if(void 0!==e)return e.constructor===Array?!!e.find(function(e){return e["@id"]===t}):e.constructor===Object?e["@id"]===t:void 0},e}(),Ee=/*#__PURE__*/function(){function e(){}return e.isForm=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.FORM)},e.isWizardStep=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.WIZARD_STEP)},e.isSection=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.QUESTION_SECTION)},e.isAnswerable=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.ANSWERABLE)},e.isTypeahead=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.QUESTION_TYPEAHEAD)},e.getPossibleValuesQuery=function(e){return u.getJsonAttValue(e,ie.HAS_OPTIONS_QUERY)},e.isDisabled=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.DISABLED)},e.isHidden=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.HIDDEN)},e.isTextarea=function(t,n){return n&&n.length>ie.INPUT_LENGTH_THRESHOLD&&!e.isTypeahead(t)||u.hasValue(t,ie.LAYOUT_CLASS,ie.LAYOUT.TEXTAREA)},e.isText=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.TEXT)},e.isCalendar=function(t){return e.isDate(t)||e.isTime(t)||e.isDateTime(t)},e.isDate=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.DATE)},e.isTime=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.TIME)},e.isDateTime=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.DATETIME)},e.isTimestamp=function(e){return u.hasValue(e,ie.TIMESTAMP_FORMAT,ie.EPOCH_MILLISECONDS)},e.isCheckbox=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.CHECKBOX)},e.isMaskedInput=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.MASKED_INPUT)},e.isSparqlInput=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.SPARQL)},e.isTurtleInput=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.TURTLE)},e.isCollapsed=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.COLLAPSED)},e.isEmphasised=function(e){return u.hasValue(e,ie.LAYOUT_CLASS,ie.LAYOUT.EMPHASISED)},e.getCategory=function(e){return ie.LAYOUT.CATEGORY.find(function(t){return u.hasValue(e,ie.LAYOUT_CLASS,t)})},e.resolveValue=function(e){return e?e[ie.HAS_OBJECT_VALUE]?e[ie.HAS_OBJECT_VALUE]["@id"]:u.getJsonAttValue(e,ie.HAS_DATA_VALUE):null},e.resolveValueObject=function(e){return e?e[ie.HAS_OBJECT_VALUE]?me.asArray(e[ie.HAS_OBJECT_VALUE])[0]:e[ie.HAS_DATA_VALUE]?me.asArray(e[ie.HAS_DATA_VALUE])[0]:null:null},e.isRelevant=function(t){if(!t[ie.IS_RELEVANT_IF])return!0;for(var n,o=$(me.asArray(t[ie.IS_RELEVANT_IF]));!(n=o()).done;)if(!e.testCondition(n.value))return!1;return!0},e.hasValidationLogic=function(e){return!!(e[ie.REQUIRES_ANSWER]||e[ie.REQUIRES_ANSWER_IF]||e[ie.PATTERN]||this.containsXSDProperty(e))},e.isValid=function(e){if(!1===e[ie.HAS_VALID_ANSWER])return!1;for(var t,n=$(me.asArray(e[ie.HAS_SUBQUESTION]));!(t=n()).done;)if(!1===this.isValid(t.value))return!1;return!0},e.testOrCondition=function(e){var t=e[ie.HAS_SUB_CONDITION];t||console.warn("Or condition does not have any sub-condition !");for(var n,o=$(this._getMappedObjectsArray(t));!(n=o()).done;)if(this.testCondition(n.value))return!0;return!1},e.testCondition=function(t){var n,o=t[ie.ACCEPTS_VALIDATION_VALUE],r=t[ie.ACCEPTS_ANSWER_VALUE],i=t[ie.ACCEPTS],a=t[ie.HAS_TESTED_QUESTION];if(t[ie.HAS_SUB_CONDITION])return this.testOrCondition(t);if(o&&r&&console.warn("Support for validation and requirement constraints at same time is not implemented !"),i&&a){var s=me.asArray(i);if(1!==s.length&&console.warn("Support for multiple accepts values is not implemented !"),s[0]["@id"]===ie.ANSWERED_QUESTION){(r||o)&&console.warn("Support for accepted answer/validations values is not implemented !");for(var l,u=$(this._getMappedObjectsArray(a));!(l=u()).done;)if(!this.hasAnswer(l.value))return!1;return!0}console.warn("No support to accept question of type "+s[0]["@id"]+" !")}if(o&&a){var c=me.asArray(o);(1!==c.length||!0!==c[0]&&"true"!==c[0])&&console.warn('Validation values other than "true" are not implemented !');for(var d,p=$(me.asArray(a));!(d=p()).done;){if(void 0===(n=pe.getObject(d.value["@id"])))return console.warn("Questions is not loaded in an object map."),!0;if(!1===this.isValid(n))return!1}return!0}if(r&&a){n=pe.getObject(a["@id"]);for(var f,h=$(me.asArray(r));!(f=h()).done;){var v=f.value;if(!n)return console.warn("Question is not defined."),!0;if(!n.hasOwnProperty(ie.HAS_ANSWER))return!1;var E=m.getValues(n,ie.HAS_ANSWER);if(0===E.length)return!1;var A=e.resolveValueObject(E[0]);if(A&&v&&A.hasOwnProperty("@value")&&v.hasOwnProperty("@id")&&A["@value"]==v["@id"])return!0;if(ve.compareValues(A,v))return!0}}return!1},e._getMappedObjectsArray=function(e,t){return me.asArray(e).map(function(e){var n=pe.getObject(e["@id"]);return void 0===n?(console.warn((t||"Object")+' "'+e["@id"]+'" is not loaded in an object map.'),null):n}).filter(function(e){return null!==e})},e.hasAnswer=function(t){if(!t)return!1;if(t.hasOwnProperty(ie.HAS_ANSWER)){var n=m.getValues(t,ie.HAS_ANSWER);if(n.length){var o=e.resolveValueObject(n[0]);if(o&&(o["@value"]||o["@id"]))return!0}}for(var r,i=$(me.asArray(t[ie.HAS_SUBQUESTION]));!(r=i()).done;)if(e.hasAnswer(r.value))return!0;return!1},e.hasCorrectAnswer=function(t){if(!t)return!1;if(t.hasOwnProperty(ie.HAS_CORRECT_ANSWER)){var n=m.getValues(t,ie.HAS_CORRECT_ANSWER);if(Array.isArray(n)&&0!==n.length){var o=e.resolveValueObject(n=n[0]);if(o&&(o["@value"]||o["@id"]))return!0}return!(!n["@value"]&&!n["@id"])}for(var r,i=$(me.asArray(t[ie.HAS_SUBQUESTION]));!(r=i()).done;)if(e.hasCorrectAnswer(r.value))return!0;return!1},e.getAnswerValue=function(t){if(!t)return null;if(t.hasOwnProperty(ie.HAS_ANSWER)){var n=m.getValues(t,ie.HAS_ANSWER);if(n.length){var o=e.resolveValueObject(n[0]);if(o&&(o["@value"]||o["@id"]))return o["@value"]||o["@id"]}}for(var r,i=$(me.asArray(t[ie.HAS_SUBQUESTION]));!(r=i()).done;){var a=e.getAnswerValue(r.value);if(a)return a}return null},e.getCorrectAnswerValue=function(t){if(!t)return null;if(t.hasOwnProperty(ie.HAS_CORRECT_ANSWER)){var n,o,r=m.getValues(t,ie.HAS_CORRECT_ANSWER);if(!r)return null;Array.isArray(r)&&(r=r[0]);var i=m.getValues(r,ie.HAS_DATA_VALUE)||m.getValues(r,ie.HAS_OBJECT_VALUE);if(i&&(!Array.isArray(i)||i.length>0)){var a;Array.isArray(i)&&(i=i[0]);var s,l=i[ie.RDFS_LABEL];return l?null!=(s=l["@value"])?s:l:null!=(a=i["@value"])?a:null}return null!=(n=null!=(o=r["@value"])?o:r[ie.RDFS_LABEL])?n:null}for(var u,c=$(me.asArray(t[ie.HAS_SUBQUESTION]));!(u=c()).done;){var d=e.getCorrectAnswerValue(u.value);if(d)return d}return null},e.resolveDateTimeFormat=function(t,n,o){var r=e.isDate(t),i=e.isTime(t),a=e.isDateTime(t);switch(!0){case r:return t[ie.DATE_FORMAT]||o.dateFormat;case i:return t[ie.TIME_FORMAT]||o.timeFormat;case a:return t[ie.DATETIME_FORMAT]||o.dateTimeFormat;default:return null}},e.dfsTraverseQuestionTree=function(e,t,n){function o(e){t(e),me.asArray(e[ie.HAS_SUBQUESTION]).forEach(function(e){o(e)}),n(e)}void 0===n&&(n=function(){}),e.forEach(function(e){o(e)})},e.getFormSpecification=function(t){var n=-1,o="..",r="";return e.dfsTraverseQuestionTree(t,function(e){var t=" ".repeat(n+=1),i="";e[ie.REQUIRES_ANSWER]&&!e[ie.USED_ONLY_FOR_COMPLETENESS]?i=t+o+"required: "+e[ie.REQUIRES_ANSWER]+"\n":e[ie.USED_ONLY_FOR_COMPLETENESS]&&(i=t+o+"required only for completeness: "+e[ie.USED_ONLY_FOR_COMPLETENESS]+"\n"),r+=t+e["http://www.w3.org/2000/01/rdf-schema#label"]+"\n",r+=e[ie.HELP_DESCRIPTION]?t+o+"description: "+e[ie.HELP_DESCRIPTION]+"\n":"",r+=i,r+=e[ie.PATTERN]?t+o+"pattern: "+e[ie.PATTERN]+"\n":"",r+=e[ie.INPUT_MASK]?t+o+"mask: "+e[ie.INPUT_MASK]+"\n":"",r+=e[ie.XSD.MAX_INCLUSIVE]?t+o+"This field should be a number equal or lower to "+e[ie.XSD.MAX_INCLUSIVE]+"\n":"",r+=e[ie.XSD.MIN_INCLUSIVE]?t+o+"This field must be greater or equal to "+e[ie.XSD.MIN_INCLUSIVE]+"\n":"",r+=e[ie.HAS_VALIDATION_MESSAGE]?t+o+"validation-message: "+e[ie.HAS_VALIDATION_MESSAGE]+"\n":"",r+="\n"},function(){n-=1}),r},e.containsXSDProperty=function(e){for(var t=Object.keys(e),n=0,o=Object.values(ie.XSD);n<o.length;n++)if(t.includes(o[n]))return!0;return!1},e.getInputMask=function(e){if(e[ie.INPUT_MASK])return e[ie.INPUT_MASK]},e.hasMediaContentWithAnnotations=function(e){if(e[ie.HAS_MEDIA_CONTENT])for(var t,n=$(me.asArray(e[ie.HAS_MEDIA_CONTENT]));!(t=n()).done;){var o=t.value;if(o[ie.HAS_ANNOTATION]&&me.asArray(o[ie.HAS_ANNOTATION]).length>0)return!0}return!1},e.containsHints=function(t){if(t[ie.HAS_SUBQUESTION])for(var n,o=$(me.asArray(t[ie.HAS_SUBQUESTION]));!(n=o()).done;)if(e.containsHints(n.value))return!0;return this.hasCorrectAnswer(t)||this.hasMediaContentWithAnnotations(t)},e}(),Ae=/*#__PURE__*/function(){function e(){}return e.log=function(e){console.log(e)},e.warn=function(e){console.warn?console.warn(e):console.log("WARNING: "+e)},e.error=function(e){console.error?console.error(e):console.log("ERROR: "+e)},e}(),ge={root:(fe={},fe[ie.HAS_LAYOUT_CLASS]=ie.FORM,fe),expandProperties:[ie.HAS_SUBQUESTION,ie.IS_RELEVANT_IF,ie.HAS_ANSWER,ie.HAS_DECLARED_PREFIX,ie.HAS_OPTION,ie.HAS_CORRECT_ANSWER,ie.HAS_COMMENT,ie.HAS_MEDIA_CONTENT,ie.HAS_ANNOTATION]},Se=/*#__PURE__*/function(){function e(){}return e.customFrame=function(e,t,n){if(arguments.length<2)return m.nextTick(function(){n(new TypeError("Could not frame, too few arguments."))});null===t&&(t=ge),m.flatten(e,null,null,function(e,t){})},e.expandStructure=function(e){var t,n={};e["@graph"].forEach(function(e){n[e["@id"]]=e,Ee.isForm(e)&&(t=e)});try{this._expandGraph(t,ge,n)}catch(e){console.error("Error '"+e+"' occured, while trying to apply frame-ing with custom shape.")}return n},e._expandGraph=function(e,t,n){var o,r,i,a=this;t.expandProperties.forEach(function(s){if(e.hasOwnProperty(s)){e[s]=me.asArray(e[s]),o=e[s];for(var l=0;l<o.length;l++)i=a._getId(o[l]),void 0!==(r=n[i])?(o[l]=r,a._expandGraph(r,t,n)):console.warn("object with @id "+i+" was not defined in input data.")}})},e._getId=function(e){return"string"==typeof e?e:e&&"object"==typeof e?e["@id"]:void 0},e}();he=Se,Se.compressStructure=function(e){var t=[],n=new Set;return(t=he._compressGraph(e,t,n)).sort(function(e,t){return e["@id"]&&t["@id"]?e["@id"].localeCompare(t["@id"]):0})},Se._compressGraph=function(e,t,n){return n.has(e["@id"])||(t.push(e),n.add(e["@id"])),ge.expandProperties.forEach(function(o){if(e.hasOwnProperty(o))for(var r=e[o],i=0;i<r.length;i++){var a=r[i];void 0!==a&&(r[i]=a,t=he._compressGraph(a,t,n),e[o][i]={"@id":a["@id"]})}}),t};var _e=/*#__PURE__*/function(){function e(){}return e.constructDefaultForm=function(t){var n=de.generateForm();return e._constructFormQuestions(n,t)},e.constructForm=function(t,n){try{var o,r;return Promise.resolve(m.flatten(t,{}).then(function(t){try{var i=e._constructFormQuestions(t,n);r=i[1],o={formQuestions:i[0]}}catch(e){console.error("Error while constructing form questions from the provided structure:",e)}if(!r){var a=e.constructDefaultForm(n);r=a[1],o={formQuestions:a[0]}}return[o,r]}).catch(function(e){return 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),[o,r]}))}catch(e){return Promise.reject(e)}},e._constructFormQuestions=function(e,t){var n,o,r,i=[];if(void 0!==e["@graph"][0]["@id"]?(r=Se.expandStructure(e),Object.keys(r).map(function(e){pe.putObject(e,r[e])})):console.warn("default form is constructed."),!(o=(n=e["@graph"].find(function(e){return Ee.isForm(e)}))[ie.HAS_SUBQUESTION]))throw Ae.error("Could not find any questions in the received data."),"No questions in the form";return(i=o.filter(function(e){return!(!Ee.isWizardStep(e)||Ee.isHidden(e))||(Ae.warn("Item is not a wizard step: "+e),!1)})).length||(Ae.log("Could not find any wizard steps in the received data. Building form without steps"),n[ie.HAS_SUBQUESTION].forEach(function(e){return i.push(e)})),i.sort(ve.getCompareLocalizedLabelFunction(t)),ve.orderPreservingToplogicalSort(i,ie.HAS_PRECEDING_QUESTION),[i,{root:n}]},e}(),Te=["validation","children","value"],Ne=/*#__PURE__*/function(t){function n(e){var n;return(n=t.call(this,e)||this).state={cursorPosition:0},n}te(n,t);var o=n.prototype;return o.focus=function(){U.findDOMNode(this.input).focus()},o.getInputDOMNode=function(){return U.findDOMNode(this.input)},o.componentDidUpdate=function(e,t,n){(this.fieldDidShrink(e)||this.fieldDidExpand(e))&&this.updateFieldCursorPosition()},o.fieldDidExpand=function(e){return"textarea"===this.props.type&&"textarea"!==e.type},o.fieldDidShrink=function(e){return"text"===this.props.type&&"text"!==e.type},o.updateFieldCursorPosition=function(){this.focus(),this.getInputDOMNode().setSelectionRange(this.state.cursorPosition,this.state.cursorPosition)},o.saveCursorPosition=function(e){this.props.onChange(e),this.setState({cursorPosition:e.target.selectionStart})},o.render=function(){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()}},o._renderCheckbox=function(){var t=this;/*#__PURE__*/return e.createElement(f.Group,{size:"small",controlId:Math.floor(Math.random()*Number.MAX_SAFE_INTEGER),className:"mb-3"},/*#__PURE__*/e.createElement(f.Check,ee({type:"checkbox",ref:function(e){return t.input=e}},this.props,{label:this.props.label,className:this.props.validation.classname})),this.props.validation.message)},o._renderRadio=function(){var t=this;/*#__PURE__*/return e.createElement(h,{size:"small",className:"mb-3"},/*#__PURE__*/e.createElement(f.Check,ee({type:"radio",ref:function(e){return t.input=e}},this.props,{label:this.props.label,className:this.props.validation.classname})),this.props.validation.message)},o._renderSelect=function(){var t=this,n=this.props,o=n.validation,r=n.children,i=n.value,a=ne(n,Te);/*#__PURE__*/return e.createElement(h,{size:"small",className:"mb-3"},this._renderLabel(),/*#__PURE__*/e.createElement(v,ee({as:"select",value:i,className:o.classname,ref:function(e){return t.input=e}},a),r),o.message)},o._renderLabel=function(){return this.props.label?/*#__PURE__*/e.createElement(f.Label,null,this.props.label):null},o._renderTextArea=function(){var t=this;/*#__PURE__*/return e.createElement(h,{size:"small",className:"mb-3"},this._renderLabel(),/*#__PURE__*/e.createElement(v,ee({ref:function(e){return t.input=e},as:"textarea"},this.props,{className:this.props.validation.classname,onChange:function(e){return t.saveCursorPosition(e)}})),this.props.validation.message)},o._renderInput=function(){var t=this;/*#__PURE__*/return e.createElement(h,{size:"small",className:"mb-3"},this._renderLabel(),/*#__PURE__*/e.createElement(v,ee({className:this.props.validation.classname,ref:function(e){return t.input=e},as:"input",placeholder:this.props.placeholder},this.props,{onChange:function(e){return t.saveCursorPosition(e)}})),this.props.validation.message)},n}(e.Component);Ne.propTypes={type:j.string,label:j.object,value:j.any,onChange:j.func,help:j.string,validation:j.object,placeholder:j.string},Ne.defaultProps={type:"text"};var Oe=["children"],Ie=/*#__PURE__*/e.createContext({}),Ce={components:{inputComponent:Ne},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,enableOptionQuestionFeedback:!1}},be=function(n){var o=n.children,r=ne(n,Oe),i=t(function(){return{inputComponent:r.components&&r.components.inputComponent||Ce.components.inputComponent,componentsOptions:Object.assign({},Ce.componentsOptions,r.componentsOptions),options:Object.assign({},Ce.options,r.options),mapComponent:r.mapComponent}},[r]);/*#__PURE__*/return e.createElement(Ie.Provider,{value:i},o)};be.propTypes={children:j.element.isRequired,components:j.object,mapComponent:j.func,options:j.object};var ye=/*#__PURE__*/function(t){function n(e){var n;return(n=t.call(this,e)||this).state={hasError:!1,errorLabel:null,errorDetails:null},n}te(n,t),n.getDerivedStateFromError=function(e){return{hasError:!0,error:e}};var o=n.prototype;return o.componentDidCatch=function(e,t){this.setState({errorLabel:e,errorDetails:t})},o.render=function(){if(this.state.hasError){var t=this.context.lang;/*#__PURE__*/return e.createElement("div",{style:{padding:"20px"}},/*#__PURE__*/e.createElement(E,{variant:"danger"},/*#__PURE__*/e.createElement(E.Heading,null,t["error.default_message"]||"Something went wrong."),/*#__PURE__*/e.createElement("p",null,this.state.errorLabel&&this.state.errorLabel.toString())),/*#__PURE__*/e.createElement(A,null,/*#__PURE__*/e.createElement(g,null,/*#__PURE__*/e.createElement(g.Header,null,/*#__PURE__*/e.createElement(A,{as:S,variant:"link",eventKey:"0"},t["error.view_details"]||"View Error Details")),/*#__PURE__*/e.createElement(A.Collapse,{eventKey:"0"},/*#__PURE__*/e.createElement(g.Body,null,/*#__PURE__*/e.createElement("pre",{style:{whiteSpace:"pre-wrap"}},this.state.errorDetails&&this.state.errorDetails.componentStack))))))}return this.props.children},n}(e.Component);ye.contextType=le;var Re=["children"],Le=/*#__PURE__*/e.createContext({}),we=function(n){var o=n.children,r=ne(n,Re),i=[],a=function(e,t){try{var n=i[e];return n&&n.length?Promise.resolve(n):Promise.resolve(r.fetchTypeAheadValues(t)).then(function(t){return t.length?m.frame(t,{},{}).then(function(t){var n,o=t["@graph"];return i.push(Object.assign({},o,((n={})[e]=o,n))),o}):(Ae.warn("No data received when loading options using id "+e),[])})}catch(e){return Promise.reject(e)}},s=function(e){return i[e]||[]},l=t(function(){return{loadFormOptions:a,getOptions:s}},[a,s]);/*#__PURE__*/return e.createElement(Le.Provider,ee({value:l},r),o)};we.propTypes={children:j.element.isRequired,fetchTypeAheadValues:j.func};var He={},De=[],Ve=/*#__PURE__*/e.createContext({}),Me=function(r){var i=n(r.data||He),a=i[0],s=i[1],l=n(r.formQuestions||De),u=l[0],c=l[1];o(function(){if(r.isFormValid){var e=Ee.isValid(a);r.isFormValid(e)}},[]),o(function(){s(r.data||He)},[u]);var d=function(e){e&&s(Object.assign({},a,e))},m=function(e,t){if(!(!t||e<0||e>=u.length)){if("object"==typeof t){var n=[].concat(u);n[e]=Object.assign({},n[e],t),c(n)}if(Array.isArray(t)&&c(t),r.isFormValid){var o=Ee.isValid(a);r.isFormValid(o)}}},p=function(){return a},f=function(e){return null==e?u:u[e]},h=t(function(){return{updateData:d,updateFormQuestionsData:m,getData:p,getFormQuestionsData:f}},[f,p]);/*#__PURE__*/return e.createElement(Ve.Provider,ee({value:h},r),r.children)};Me.propTypes={children:j.element.isRequired,data:j.object.isRequired,formQuestions:j.array.isRequired,isFormValid:j.func};var je=/*#__PURE__*/function(){function e(){}return e.buildQuestionAnswerModel=function(t,n){var o,r={subQuestions:[]};if(t&&(r.uri=t.root["@id"],r.origin=u.getJsonAttValue(t.root,ie.HAS_QUESTION_ORIGIN,"@id")),n)for(var i=0;i<n.length;i++)(o=e.processQuestionAnswerHierarchy(n[i]))&&r.subQuestions.push(o);return r},e.processQuestionAnswerHierarchy=function(t){return t?e._processQuestion(t):null},e._processQuestion=function(t){var n={};if(n.uri=t["@id"],n.origin=u.getJsonAttValue(t,ie.HAS_QUESTION_ORIGIN,"@id"),t[ie.HAS_SUBQUESTION]){n.subQuestions=[];for(var o=0;o<t[ie.HAS_SUBQUESTION].length;o++)n.subQuestions.push(e._processQuestion(t[ie.HAS_SUBQUESTION][o]))}if(t[ie.HAS_ANSWER]){n.answers=[],Array.isArray(t[ie.HAS_ANSWER])||(t[ie.HAS_ANSWER]=[t[ie.HAS_ANSWER]]);for(var r=0;r<t[ie.HAS_ANSWER].length;r++)n.answers.push(e.processAnswer(t[ie.HAS_ANSWER][r]))}if(t[ie.HAS_COMMENT]){n.comments=[],Array.isArray(t[ie.HAS_COMMENT])||(t[ie.HAS_COMMENT]=[t[ie.HAS_COMMENT]]);for(var i=0;i<t[ie.HAS_COMMENT].length;i++)n.comments.push(e.processComment(t[ie.HAS_COMMENT][i]))}return n},e.processComment=function(e){var t={};return t.author=u.getJsonAttValue(e,ie.HAS_AUTHOR,"@id"),t.value=u.getJsonAttValue(e,ie.HAS_COMMENT_VALUE),t.timestamp=u.getJsonAttValue(e,ie.HAS_TIMESTAMP,"@id"),t},e.processAnswer=function(e){var t={};return t.uri=e["@id"],t.origin=u.getJsonAttValue(e,ie.HAS_ANSWER_ORIGIN,"@id"),e[ie.HAS_OBJECT_VALUE]?t.codeValue=u.getJsonAttValue(e,ie.HAS_OBJECT_VALUE,"@id"):t.textValue=u.getJsonAttValue(e,ie.HAS_DATA_VALUE),t},e.generateAnswer=function(e){var t={};return t[ie.HAS_DATA_VALUE]="",t},e}(),Ue=function(t){var n=r(Ie);/*#__PURE__*/return e.createElement(n.inputComponent,{type:"checkbox",label:t.label,title:t.title,checked:!0===t.value||"true"===t.value,validation:t.validation,onChange:function(e){t.onChange(e.target.checked)},disabled:n.componentsOptions.readOnly||Ee.isDisabled(t.question)})};Ue.propTypes={question:j.object.isRequired,label:j.object.isRequired,title:j.string,value:j.oneOfType([j.string,j.bool]),onChange:j.func.isRequired,mouseHover:j.bool,validation:j.object};var Pe=function(t){var i=r(Ie).componentsOptions,a=n(null),s=a[0],l=a[1],u=n(""),c=u[0],d=u[1],m=Ee.resolveDateTimeFormat(t.question,t.value,i.dateTimeAnswer),p=Ee.isDate(t.question),v=Ee.isTime(t.question),E=Ee.isTimestamp(t.question);o(function(){var e=A(t.value);e?l(e):(l(null),d("Invalid date value "+t.value+" of question "+t.question["@id"]+"."),console.error(c))},[t.value,m]);var A=function(e){if(!e)return null;var t=E?new Date(e):x(e,m,new Date);return isNaN(t.getTime())?null:t};/*#__PURE__*/return e.createElement(h,{size:"small",className:"mb-3"},/*#__PURE__*/e.createElement(f.Label,{className:"w-100"},t.label),/*#__PURE__*/e.createElement(P,{selected:s,placeholderText:m,onChange:function(e){l(e);var n=e?E?e.getTime():q(e,m):"";t.onChange(n)},showTimeSelect:!p,showTimeSelectOnly:v,timeFormat:"HH:mm",timeIntervals:1,timeCaption:"Time",dateFormat:m,className:k("form-control",t.validation.classname),disabled:i.readOnly||Ee.isDisabled(t.question)}),t.validation.message)};Pe.propTypes={question:j.object.isRequired,label:j.object.isRequired,title:j.string,value:j.oneOfType([j.string,j.number]),onChange:j.func.isRequired,validation:j.object};var xe=[ie.XSD.INT,ie.XSD.INTEGER,ie.XSD.NON_NEGATIVE_INTEGER,ie.XSD.NON_POSITIVE_INTEGER,ie.XSD.NEGATIVE_INTEGER,ie.XSD.POSITIVE_INTEGER,ie.XSD.FLOAT,ie.XSD.POSITIVE_FLOAT,ie.XSD.NEGATIVE_FLOAT],qe={};qe[ie.XSD.NON_NEGATIVE_INTEGER]={min:0},qe[ie.XSD.NON_POSITIVE_INTEGER]={max:0},qe[ie.XSD.NEGATIVE_INTEGER]={max:-1},qe[ie.XSD.POSITIVE_INTEGER]={min:1};var ke={"string-2":"prefixed",atom:"var"},Fe=/*#__PURE__*/function(){function e(){}return e._resolveInputType=function(t,n){return Ee.isSparqlInput(t)||Ee.isTurtleInput(t)||Ee.isTextarea(t,n)?"textarea":e._isNumeric(t)?"number":"text"},e._isNumeric=function(e){for(var t=0,n=xe.length;t<n;t++)if(u.hasValue(e,ie.HAS_DATATYPE,xe[t]))return!0;return!1},e.resolveInputProperties=function(t,n,o){var r={};switch(r.type=e._resolveInputType(t,n),r.type){case"textarea":r.rows=5;break;case"number":r=Object.assign({},r,e._resolveNumberRestrictions(t),this._resolveStepRestriction(t))}return r.disabled=o.readOnly||Ee.isDisabled(t),r},e._resolveStepRestriction=function(e){var t={};return void 0!==e[ie.STEP]&&(t.step=u.getJsonAttValue(e,ie.STEP)),t},e._resolveNumberRestrictions=function(e){var t={};return Object.getOwnPropertyNames(qe).forEach(function(n){u.hasValue(e,ie.HAS_DATATYPE,n)&&(t=Object.assign({},t,qe[n]))}),void 0!==e[ie.XSD.MIN_INCLUSIVE]&&(t.min=e[ie.XSD.MIN_INCLUSIVE]),void 0!==e[ie.XSD.MIN_EXCLUSIVE]&&(t.min=e[ie.XSD.MIN_EXCLUSIVE]+1),void 0!==e[ie.XSD.MAX_EXCLUSIVE]&&(t.max=e[ie.XSD.MAX_EXCLUSIVE]-1),void 0!==e[ie.XSD.MAX_INCLUSIVE]&&(t.max=e[ie.XSD.MAX_INCLUSIVE]),t},e._preventCharacterInput=function(t,n){"number"!==e._resolveInputType(n)||t.key>="0"&&t.key<="9"||["Backspace","Delete","ArrowLeft","ArrowRight","-","Minus","NumpadSubtract",".","Period"].includes(t.key)||t.preventDefault()},e}(),ze=function(t){var n=r(Ie),o=n.inputComponent,i=n.componentsOptions,a=t.question,s=t.answer,l=t.value;return s[ie.HAS_OBJECT_VALUE]&&s[ie.HAS_OBJECT_VALUE][u.RDFS_LABEL]&&(l=u.getJsonAttValue(s[ie.HAS_OBJECT_VALUE],u.RDFS_LABEL)),/*#__PURE__*/e.createElement(o,Object.assign({},Fe.resolveInputProperties(a,l,i),{validation:t.validation,label:t.label,title:t.title,value:null==l?"":l,placeholder:Ee.getInputMask(a),onKeyPress:function(e){return Fe._preventCharacterInput(e,a)},onChange:function(e){t.onChange(e.target.value),(t.sparql||t.turtle)&&(void 0).hide()},onFocus:function(e){if(t.sparql){var n=F.fromTextArea(e.target);n.setValue(l),n.on("change",function(){t.onChange(n.getValue())}),F.Autocompleters.prefixes.appendPrefixIfNeeded=function(e,n){if(e.autocompleters.getTrie(n)&&e.options.autocompleters&&-1!==e.options.autocompleters.indexOf(n)){var o=e.getCursor(),r=e.getTokenAt(o);if("prefixed"===ke[r.type]){var i=r.string.indexOf(":");if(-1!==i){var a=e.getPreviousNonWsToken(o.line,r).string.toUpperCase(),s=e.getTokenAt({line:o.line,ch:r.start});if("PREFIX"!==a&&("ws"===s.type||null==s.type)){var l=r.string.substring(0,i+1);if(null==e.getPrefixesFromQuery()[l.slice(0,-1)])if(t.question[ie.HAS_DECLARED_PREFIX]&&t.question[ie.HAS_DECLARED_PREFIX].filter(function(e){return e[ie.PREFIX]===l.slice(0,-1)}).length){var u=t.question[ie.HAS_DECLARED_PREFIX].filter(function(e){return e[ie.PREFIX]===l.slice(0,-1)}),c={};c[u[0][ie.PREFIX]]=u[0][ie.NAMESPACE],e.addPrefixes(c)}else{var d=e.autocompleters.getTrie(n).autoComplete(l);d.length>0&&e.addPrefixes(d[0])}}}}}}}else if(t.turtle){console.log("TTL");var o=F.fromTextArea(e.target);o.setValue(l),o.on("change",function(){t.onChange(o.getValue())})}}}))};ze.propTypes={question:j.object.isRequired,answer:j.object.isRequired,label:j.object.isRequired,title:j.string,value:j.oneOfType([j.string,j.number]),onChange:j.func.isRequired,validation:j.object};var Qe={D:"1",M:"1",Y:"1",h:"1",m:"1",s:"1"},Be=/*#__PURE__*/function(){function e(){}return e.mapMask=function(e){if(!e)return e;for(var t,n="",o=0,r=e.length;o<r;o++)t=e.charAt(o),n+=Qe[t]?Qe[t]:t;return n},e}(),We=["size","placeholder"];function Ye(e){var t,n,o,r;if(void 0!==e.selectionStart)t=e.selectionStart,n=e.selectionEnd;else try{e.focus(),r=(o=e.createTextRange()).duplicate(),o.moveToBookmark(document.selection.createRange().getBookmark()),r.setEndPoint("EndToStart",o),n=(t=r.text.length)+o.text.length}catch(e){}return{start:t,end:n}}var Xe=/*#__PURE__*/function(t){function n(e){var n;return(n=t.call(this,e)||this)._updatePattern=function(e){n.mask.setPattern(Be.mapMask(e.mask),{value:n.mask.getRawValue(),selection:Ye(n.input)})},n._updateMaskSelection=function(){n.mask.selection=Ye(n.input)},n._updateInputSelection=function(){!function(e,t){var n;try{void 0!==e.selectionStart?(e.focus(),e.setSelectionRange(t.start,t.end)):(e.focus(),(n=e.createTextRange()).collapse(!0),n.moveStart("character",t.start),n.moveEnd("character",t.end-t.start),n.select())}catch(e){}}(n.input,n.mask.selection)},n._onChange=function(e){var t=n.mask.getValue();if(e.target.value!==t){if(e.target.value.length<t.length){var o=t.length-e.target.value.length;n._updateMaskSelection(),n.mask.selection.end=n.mask.selection.start+o,n.mask.backspace()}var r=n._getDisplayValue();e.target.value=r,r&&n._updateInputSelection()}n.props.onChange&&n.props.onChange(e)},n._onKeyDown=function(e){if(function(e){return e.ctrlKey&&90===e.keyCode}(e))e.preventDefault(),n.mask.undo()&&(e.target.value=n._getDisplayValue(),n._updateInputSelection(),n.props.onChange&&n.props.onChange(e));else if(function(e){return e.ctrlKey&&89===e.keyCode}(e))e.preventDefault(),n.mask.redo()&&(e.target.value=n._getDisplayValue(),n._updateInputSelection(),n.props.onChange&&n.props.onChange(e));else if("Backspace"===e.key&&(e.preventDefault(),n._updateMaskSelection(),n.mask.backspace())){var t=n._getDisplayValue();e.target.value=t,t&&n._updateInputSelection(),n.props.onChange&&n.props.onChange(e)}},n._onKeyPress=function(e){e.metaKey||e.altKey||e.ctrlKey||"Enter"===e.key||(e.preventDefault(),n._updateMaskSelection(),n.mask.input(e.key)&&(e.target.value=n.mask.getValue(),n._updateInputSelection(),n.props.onChange&&n.props.onChange(e)))},n._onPaste=function(e){e.preventDefault(),n._updateMaskSelection(),n.mask.paste(e.clipboardData.getData("Text"))&&(e.target.value=n.mask.getValue(),setTimeout(n._updateInputSelection,0),n.props.onChange&&n.props.onChange(e))},n.mask=new z({pattern:Be.mapMask(e.mask),value:e.value,formatCharacters:e.formatCharacters,placeholderChar:e.placeholderChar||"_"}),n}te(n,t);var o=n.prototype;return o.componentDidUpdate=function(e){e.mask!==this.props.mask&&this._updatePattern(this.props),e.mask!==this.props.mask&&e.value!==this.props.mask?this.mask.getValue()===this.mask.emptyValue?this.mask.setPattern(Be.mapMask(this.props.mask),{value:this.props.value}):this.mask.setPattern(Be.mapMask(this.props.mask),{value:this.mask.getRawValue()}):e.mask!==this.props.mask?this.mask.setPattern(Be.mapMask(this.props.mask),{value:this.mask.getRawValue()}):e.value!==this.props.value&&this.mask.setValue(this.props.value),e.mask!==this.props.mask&&this.mask.selection.start&&this._updateInputSelection()},o._getDisplayValue=function(){var e=this.mask.getValue();return e===this.mask.emptyValue?"":e},o.focus=function(){this.input.focus()},o.blur=function(){this.input.blur()},o.render=function(){var t=this,n=this.props,o=n.size,r=n.placeholder,i=ne(n,We),a=this.mask.pattern.length;/*#__PURE__*/return e.createElement(this.context.inputComponent,Object.assign({},i,{ref:function(e){e&&(t.input=e.input?U.findDOMNode(e.input):e)},maxLength:a,onChange:this._onChange,onKeyDown:this._onKeyDown,onKeyPress:this._onKeyPress,onPaste:this._onPaste,placeholder:r||this.mask.emptyValue,size:o||a,value:this._getDisplayValue(),type:"text"}))},n}(e.Component);Xe.contextType=Ie,Xe.propTypes={mask:j.string.isRequired},Xe.defaultProps={value:""};var Ge=function(t){var n=r(Ie).componentsOptions,o=t.question,i=t.value,a=u.getJsonAttValue(o,ie.INPUT_MASK);return a?/*#__PURE__*/e.createElement(Xe,{mask:a,value:i,label:t.label,title:t.title,placeholder:a,onChange:function(e){return t.onCha