@spotify/backstage-plugin-pulse-common 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @spotify/backstage-plugin-pulse-common
2
2
 
3
+ ## 0.11.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Support for future experimental features.
8
+
9
+ ## 0.11.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Support for future experimental features.
14
+
15
+ ### Patch Changes
16
+
17
+ - Upgraded Backstage to `v1.20.2`.
18
+
3
19
  ## 0.10.0
4
20
 
5
21
  ### Minor Changes
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Dt=require("@backstage/plugin-permission-common"),Lt=require("@ungap/structured-clone"),Ct=require("ajv"),Qt=require("ajv-formats"),Mt=require("assert"),jt=require("lodash"),Ut=require("crypto");function X(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}function Ft(r){if(r&&r.__esModule)return r;var t=Object.create(null);return r&&Object.keys(r).forEach(function(n){if(n!=="default"){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}}),t.default=r,Object.freeze(t)}var Zt=X(Lt),Bt=X(Ct),Gt=X(Qt),Fe=X(Mt),te=X(jt),Wt=Ft(Ut);const Vt="survey-instance",Ze=Dt.createPermission({name:"survey.instance.administer",attributes:{action:"create"}}),Xt=[Ze],Ht=()=>{"structuredClone"in globalThis||(globalThis.structuredClone=Zt.default)};var Jt="surveyTemplate",Yt="http://json-schema.org/draft-07/schema",Kt="Survey Template",en="object",tn={template:{type:"object",description:"Meta data about the survey template",properties:{id:{type:"string",description:"An id of the survey template. If there are multiple templates with the same id, they must have different versions.",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$",minLength:1},version:{type:"string",format:"regex",pattern:"^[0-9]+(\\.[0-9]+)?$",description:"A version of template"},name:{type:"string",description:"The display name of the survey template",minLength:1},description:{type:"string",description:"A longer description of the survey template"},owner:{type:"string",description:"The owner of the survey template",minLength:1}},required:["id","version","name","owner"],additionalProperties:!1},parameters:{type:"array",description:"Template parameters that can or must be set when creating a survey from this template. Parameters are referred to elsewhere in the survey using the ${p:<id>} construct and will get lazily in-place replaced.",items:{type:"object",properties:{id:{type:"string",description:"The id of the parameter",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},description:{type:"string",description:"The description of the parameter"},format:{type:"string",enum:["string","number","boolean"],description:"The format of the parameter. Should only be set if a default value is not provided."},default:{type:["string","number","boolean"],description:"An optional default value of this parameter. If this is omitted, the parameter must be provided when creating a survey from the template."}},required:["id","description"],oneOf:[{required:["format"]},{required:["default"]}],additionalProperties:!1}},macros:{type:"object",description:"Expression shortcuts. Macros are referred to elsewhere in the survey using the ${m:<name>} construct (similar to parameters) and will get lazily in-place replaced. Macros can be recursive and contain references to parameters or answers in the survey.",additionalProperties:{type:"string"}},sections:{type:"array",description:"The survey sections, in the order they will appear in the survey",items:{$ref:"#/$defs/section"}}},nn=!1,rn=["template","parameters","sections"],sn={section:{type:"object",description:"A survey section.",properties:{id:{type:"string",description:"The id of this section",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$"},name:{type:"string",description:"The name of this section"},display_logic:{type:"string",description:"An optional boolean expression that decides if the surveyee should see the questions in this section."},hide_progress_bar:{type:"boolean",description:"When set, the survey progress bar will not be shown during this section."},pages:{type:"array",description:"The questions in the section, split into pages",items:{$ref:"#/$defs/page"}}},additionalProperties:!1,required:["id","name","pages"]},page:{type:"object",properties:{questions:{type:"array",description:"The questions on the page",items:{$ref:"#/$defs/question"}}},required:["questions"],additionalProperties:!1},question:{type:"object",properties:{id:{type:"string",description:"The unique ID of the question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},text:{type:"string",description:"The question description, in markdown"},type:{type:"string",enum:["mc-single","mc-multi","matrix-single","matrix-multi","text-single","text-multi","description"],description:"The type of question"},layout:{type:"string",enum:["vertical","horizontal"],description:"Determines the visual layout of the options in multiple choice questions"},display_logic:{type:"string",description:"A boolean expression with logic if this question should be displayed or not"},required:{type:"string",enum:["required","optional","request"],description:"If the question is required to answer; request means you will get a warning if you skip it but you can."},validation:{type:"object",description:"Validation constraints on the question. Only applied if the user has answered the question, so typically used in combination with required",properties:{min_choices:{type:"integer",description:"The minimum number of choices to user can pick (multiple choice questions only)"},max_choices:{type:"integer",description:"The maximum number of choices to user can pick (multiple choice questions only)"}},additionalProperties:!1},statements:{type:"array",items:{$ref:"#/$defs/statement"}},dynamic_statements:{type:"string",description:"Carry forward statements from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},statement_groups:{type:"array",items:{type:"object",properties:{statements:{type:"array",items:{$ref:"#/$defs/statement"}},id:{type:"string",description:"The id of the group."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["statements","id","display"],additionalProperties:!1}},choices:{type:"array",items:{$ref:"#/$defs/choice"}},dynamic_choices:{type:"string",description:"Carry forward choices from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},choice_groups:{type:"array",items:{type:"object",properties:{choices:{type:"array",items:{$ref:"#/$defs/choice"}},id:{type:"string",description:"The id of the group."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["choices","id","display"],additionalProperties:!1}},randomization:{$ref:"#/$defs/randomization"},configuration:{type:"object",properties:{choice_column_width_pixels:{type:"integer",description:"Size of the column with the choice descriptions in a matrix question"}},additionalProperties:!1}},additionalProperties:!1,required:["text"],oneOf:[{$ref:"#/$defs/question-mc-horizontal"},{$ref:"#/$defs/question-mc-vertical"},{$ref:"#/$defs/question-matrix"},{$ref:"#/$defs/question-text"},{$ref:"#/$defs/question-description"}]},"question-mc-horizontal":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"horizontal"}},required:["id","type","position","choices"],not:{anyOf:[{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]}},"question-mc-vertical":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"vertical"}},required:["id","type"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]},oneOf:[{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}],not:{required:["choice_groups"]}},{required:["choice_groups"],not:{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}]}}]},"question-matrix":{type:"object",properties:{type:{enum:["matrix-single","matrix-multi"]}},required:["id","type","choices"],not:{anyOf:[{required:["dynamic_choices"]},{required:["choice_groups"]}]},oneOf:[{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}],not:{required:["statement_groups"]}},{required:["statement_groups"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}]}}]},"question-text":{type:"object",properties:{type:{enum:["text-single","text-multi"]}},required:["id","type"],not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},"question-description":{type:"object",properties:{type:{const:"description"}},not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},statement:{type:"object",properties:{id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the statement"},display:{type:"string",description:"The statement name, as shown to the surveyee"},display_logic:{type:"string",description:"A boolean expression determining if the statement should be displayed"}},required:["id","display"],additionalProperties:!1},choice:{type:"object",properties:{display:{type:"string",description:"The choice name, as shown to the surveyee"},id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the choice"},value:{type:"integer",description:"The value the choice"},display_logic:{type:"string",description:"A boolean expression determining if the choice should be displayed"},text_input:{type:"string",enum:["no","optional","forced"],description:"If a textbox should appear next to the choice, and if it should be mandatory to fill it in if the choice is selected"},exclusive_answer:{type:"boolean",description:"If true, this choice can't be combined with other choices in this question"}},required:["display"],oneOf:[{required:["value"]},{required:["id"]}],additionalProperties:!1},randomization:{type:"object",description:"Configuration of the display order randomization of choices, statements or groups.",properties:{type:{type:"string",description:"The type of randomization: randomize all items, a subset of them, or using constrained randomization",enum:["all","subset","constrained"]},total:{type:"integer",description:"Maximum number of items to show"},order:{type:"string",description:"A space separated string containing the order of the items; each 'word' is either an id of some item or the wildcard $ representing the remaining items"}},required:["type"],oneOf:[{properties:{type:{const:"all"}},not:{required:["total","order"]}},{properties:{type:{const:"subset"}},required:["total"],not:{required:["order"]}},{properties:{type:{const:"constrained"}},required:["order"]}],additionalProperties:!1}},Be={$id:Jt,$schema:Yt,title:Kt,type:en,properties:tn,additionalProperties:nn,required:rn,$defs:sn},an=(r=>(r.DuplicateResponse="DUPLICATE_RESPONSE",r.InternalError="INTERNAL_ERROR",r.InvalidDates="INVALID_DATES",r.InvalidId="INVALID_ID",r.InvalidParticipants="INVALID_PARTICIPANTS",r.InvalidResponse="INVALID_RESPONSE",r.MissingTitle="MISSING_TITLE",r.OverlappingSurveys="OVERLAPPING_SURVEYS",r.ParticipantsFrozen="PARTICIPANTS_FROZEN",r.SurveyIsClosed="SURVEY_IS_CLOSED",r.Unauthorized="UNAUTHORIZED",r))(an||{}),on=(r=>(r.Horizontal="HORIZONTAL",r.Vertical="VERTICAL",r))(on||{}),ln=(r=>(r.Optional="OPTIONAL",r.Request="REQUEST",r.Required="REQUIRED",r))(ln||{}),me=(r=>(r.Description="DESCRIPTION",r.MatrixMulti="MATRIX_MULTI",r.MatrixSingle="MATRIX_SINGLE",r.McMulti="MC_MULTI",r.McSingle="MC_SINGLE",r.TextMulti="TEXT_MULTI",r.TextSingle="TEXT_SINGLE",r))(me||{}),_n=(r=>(r.All="ALL",r.Constrained="CONSTRAINED",r.Subset="SUBSET",r))(_n||{}),cn=(r=>(r.Finalized="FINALIZED",r.Partial="PARTIAL",r))(cn||{}),pn=(r=>(r.Active="ACTIVE",r.Published="PUBLISHED",r))(pn||{}),un=(r=>(r.Q1="Q1",r.Q2="Q2",r.Q3="Q3",r.Q4="Q4",r))(un||{}),dn=Object.defineProperty,hn=(r,t,n)=>t in r?dn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,k=(r,t,n)=>(hn(r,typeof t!="symbol"?t+"":t,n),n);function mn(r={}){return r.transformer&&r.transformer.constructor.name==="object"&&(r.transformer=K.fromObj(r.transformer)),gt._load_from_dict({data:xr,memo:wr,...r})}const Ge={};class We{}const ne={},Ve={escape(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},compile(r,t){return new RegExp(r,t)},error:SyntaxError};function fn(r,t,n,i){const s=r.compile(t,i).exec(n);if(s!=null)return s[0]}class Xe{constructor(t,n,i,s,a=!1){this.terminals=t,this.g_regex_flags=n,this.re_=i,this.use_bytes=s,this.match_whole=a,this.allowed_types=new Set(this.terminals.map(o=>o.name)),this._regexps=this._build_mres(t)}_build_mres(t){let n=this.match_whole?"$":"",i=En(t,a=>a.pattern.flags.join("")),s=[];for(let[a,o]of i){const l=o.map(c=>`(?<${c.name}>${c.pattern.to_regexp()+n})`).join("|");s.push(new RegExp(l,this.g_regex_flags+a+"y"))}return s}match(t,n){for(const i of this._regexps){i.lastIndex=n;let s=i.exec(t);if(s){let a=null;for(let[o,l]of Object.entries(s.groups))if(l){a=o;break}return[s[0],a]}}}}const He=typeof require!="undefined"&&require("util");class Je{}const H={};function x(r){return Object.entries(r)}function fe(r){return Object.keys(r)}function yn(r,t){t===void 0&&(t=Object.keys(r)[0]);let n=r[t];return delete r[t],n}function Ye(r,t,n=null){return r[t]||n}function Ke(r,t){if(r.constructor.name==="Map")for(const[n,i]of x(t))r.set(n,i);else for(const[n,i]of x(t))r[n]=i}function gn(r){return function(){return new r(...arguments)}}function h(r){let t=0,n=[...arguments].slice(1);return r.replace(/%([sr])/g,function(){const i=arguments[1],s=n[t++];return i==="r"?He?He.inspect(s,!1,null,!0):JSON.stringify(s,null,0):s})}function xn(r,t){let n=new Set(r);for(const i of t)n.add(i);return n}function et(r,t){return[...r].filter(n=>!t.has(n))}function tt(r){return{...r}}function nt(r){return!!r}function ye(r){return Object.create(r.prototype)}function I(r){if(typeof r=="object"){let t=Object.create(Object.getPrototypeOf(r));return Object.assign(t,r)}return r}function re(r){return new Set(r)}function ge(r){return r&&r.constructor.name==="Object"}function wn(r){return r&&r.constructor.name==="Array"}function Tn(r){return typeof r=="function"}function*J(r,t=0){let n=t;for(const i of r)yield[n++,i]}function vn(r){for(const t of r)if(t)return!0;return!1}function rt(r,t){return t.filter(r||nt)}function ie(r){let t=[...arguments].slice(1);return function(){return r(...t,...arguments)}}class xe extends Error{}function E(r){return r[r.length-1]}function D(r){return function(){let t=new r(...arguments);return t.__call__.bind(t)}}function O(r,t){return Array.from({length:t},()=>r).flat()}function it(r){return/^[A-Z_$]*$/.test(r)}function we(r,t,n){const i=r.split(t);return n?i.splice(-n-1):i}function Te(r,t){let n=new RegExp(t,"g");return(r.match(n)||[]).length}function bn(r,t){for(let n of r)if(!t.has(n))return!1;return!0}function*En(r,t){let n=[],i=null;for(const s of r){const a=t(s);i&&a!=i&&(yield[i,n],n=[]),n.push(s),i=a}yield[i,n]}class S extends Error{}class A extends S{}function ve(r,t,n="Got %r, expected one of %s"){if(!t.includes(r))throw new A(h(n,r,t))}class se extends S{}class Nn extends S{}class Y extends S{}class z extends S{constructor(){super(...arguments),k(this,"pos_in_stream",null),k(this,"_terminals_by_name",null)}get_context(t,n=40){let i,s,a=this.pos_in_stream,o=max(a-n,0),l=a+n;return t instanceof bytes?(s=E(we(t.slice(o,a),`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Lt=require("@backstage/plugin-permission-common"),Ct=require("@ungap/structured-clone"),Qt=require("ajv"),Mt=require("ajv-formats"),jt=require("assert"),Ut=require("lodash"),Ft=require("crypto");function G(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}function Bt(r){if(r&&r.__esModule)return r;var t=Object.create(null);return r&&Object.keys(r).forEach(function(n){if(n!=="default"){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}}),t.default=r,Object.freeze(t)}var Zt=G(Ct),Gt=G(Qt),Wt=G(Mt),Fe=G(jt),ee=G(Ut),Vt=Bt(Ft);const Xt="survey-instance",Be=Lt.createPermission({name:"survey.instance.administer",attributes:{action:"create"}}),Ht=[Be],Ze="pulse.experimentalFlags",Jt=(r,t)=>{const n=r.getOptionalStringArray(Ze);return n==null?void 0:n.includes(t)},Yt=(r,t)=>{var n;const i=r.getOptionalStringArray(Ze),s=`${t}=`;return(n=i==null?void 0:i.find(a=>a.startsWith(s)))==null?void 0:n.replace(s,"")},Kt=()=>{"structuredClone"in globalThis||(globalThis.structuredClone=Zt.default)};var en="surveyTemplate",tn="http://json-schema.org/draft-07/schema",nn="Survey Template",rn="object",sn={template:{type:"object",description:"Meta data about the survey template",properties:{id:{type:"string",description:"An id of the survey template. If there are multiple templates with the same id, they must have different versions.",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$",minLength:1},version:{type:"string",format:"regex",pattern:"^[0-9]+(\\.[0-9]+)?$",description:"A version of template"},name:{type:"string",description:"The display name of the survey template",minLength:1},description:{type:"string",description:"A longer description of the survey template"},owner:{type:"string",description:"The owner of the survey template",minLength:1}},required:["id","version","name","owner"],additionalProperties:!1},parameters:{type:"array",description:"Template parameters that can or must be set when creating a survey from this template. Parameters are referred to elsewhere in the survey using the ${p:<id>} construct and will get lazily in-place replaced.",items:{type:"object",properties:{id:{type:"string",description:"The id of the parameter",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},description:{type:"string",description:"The description of the parameter"},format:{type:"string",enum:["string","number","boolean"],description:"The format of the parameter. Should only be set if a default value is not provided."},default:{type:["string","number","boolean"],description:"An optional default value of this parameter. If this is omitted, the parameter must be provided when creating a survey from the template."}},required:["id","description"],oneOf:[{required:["format"]},{required:["default"]}],additionalProperties:!1}},macros:{type:"object",description:"Expression shortcuts. Macros are referred to elsewhere in the survey using the ${m:<name>} construct (similar to parameters) and will get lazily in-place replaced. Macros can be recursive and contain references to parameters or answers in the survey.",additionalProperties:{type:"string"}},sections:{type:"array",description:"The survey sections, in the order they will appear in the survey",items:{$ref:"#/$defs/section"}}},an=!1,on=["template","parameters","sections"],ln={section:{type:"object",description:"A survey section.",properties:{id:{type:"string",description:"The id of this section",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$"},name:{type:"string",description:"The name of this section"},display_logic:{type:"string",description:"An optional boolean expression that decides if the surveyee should see the questions in this section."},hide_progress_bar:{type:"boolean",description:"When set, the survey progress bar will not be shown during this section."},pages:{type:"array",description:"The questions in the section, split into pages",items:{$ref:"#/$defs/page"}}},additionalProperties:!1,required:["id","name","pages"]},page:{type:"object",properties:{questions:{type:"array",description:"The questions on the page",items:{$ref:"#/$defs/question"}}},required:["questions"],additionalProperties:!1},question:{type:"object",properties:{id:{type:"string",description:"The unique ID of the question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},text:{type:"string",description:"The question description, in markdown"},type:{type:"string",enum:["mc-single","mc-multi","matrix-single","matrix-multi","text-single","text-multi","description"],description:"The type of question"},layout:{type:"string",enum:["vertical","horizontal"],description:"Determines the visual layout of the options in multiple choice questions"},display_logic:{type:"string",description:"A boolean expression with logic if this question should be displayed or not"},required:{type:"string",enum:["required","optional","request"],description:"If the question is required to answer; request means you will get a warning if you skip it but you can."},validation:{type:"object",description:"Validation constraints on the question. Only applied if the user has answered the question, so typically used in combination with required",properties:{min_choices:{type:"integer",description:"The minimum number of choices to user can pick (multiple choice questions only)"},max_choices:{type:"integer",description:"The maximum number of choices to user can pick (multiple choice questions only)"}},additionalProperties:!1},statements:{type:"array",items:{$ref:"#/$defs/statement"}},dynamic_statements:{type:"string",description:"Carry forward statements from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},statement_groups:{type:"array",items:{type:"object",properties:{statements:{type:"array",items:{$ref:"#/$defs/statement"}},id:{type:"string",description:"The id of the group."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["statements","id","display"],additionalProperties:!1}},choices:{type:"array",items:{$ref:"#/$defs/choice"}},dynamic_choices:{type:"string",description:"Carry forward choices from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},choice_groups:{type:"array",items:{type:"object",properties:{choices:{type:"array",items:{$ref:"#/$defs/choice"}},id:{type:"string",description:"The id of the group."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["choices","id","display"],additionalProperties:!1}},randomization:{$ref:"#/$defs/randomization"},configuration:{type:"object",properties:{choice_column_width_pixels:{type:"integer",description:"Size of the column with the choice descriptions in a matrix question"}},additionalProperties:!1}},additionalProperties:!1,required:["text"],oneOf:[{$ref:"#/$defs/question-mc-horizontal"},{$ref:"#/$defs/question-mc-vertical"},{$ref:"#/$defs/question-matrix"},{$ref:"#/$defs/question-text"},{$ref:"#/$defs/question-description"}]},"question-mc-horizontal":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"horizontal"}},required:["id","type","position","choices"],not:{anyOf:[{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]}},"question-mc-vertical":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"vertical"}},required:["id","type"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]},oneOf:[{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}],not:{required:["choice_groups"]}},{required:["choice_groups"],not:{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}]}}]},"question-matrix":{type:"object",properties:{type:{enum:["matrix-single","matrix-multi"]}},required:["id","type","choices"],not:{anyOf:[{required:["dynamic_choices"]},{required:["choice_groups"]}]},oneOf:[{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}],not:{required:["statement_groups"]}},{required:["statement_groups"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}]}}]},"question-text":{type:"object",properties:{type:{enum:["text-single","text-multi"]}},required:["id","type"],not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},"question-description":{type:"object",properties:{type:{const:"description"}},not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},statement:{type:"object",properties:{id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the statement"},display:{type:"string",description:"The statement name, as shown to the surveyee"},display_logic:{type:"string",description:"A boolean expression determining if the statement should be displayed"}},required:["id","display"],additionalProperties:!1},choice:{type:"object",properties:{display:{type:"string",description:"The choice name, as shown to the surveyee"},id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the choice"},value:{type:"integer",description:"The value the choice"},display_logic:{type:"string",description:"A boolean expression determining if the choice should be displayed"},text_input:{type:"string",enum:["no","optional","forced"],description:"If a textbox should appear next to the choice, and if it should be mandatory to fill it in if the choice is selected"},exclusive_answer:{type:"boolean",description:"If true, this choice can't be combined with other choices in this question"}},required:["display"],oneOf:[{required:["value"]},{required:["id"]}],additionalProperties:!1},randomization:{type:"object",description:"Configuration of the display order randomization of choices, statements or groups.",properties:{type:{type:"string",description:"The type of randomization: randomize all items, a subset of them, or using constrained randomization",enum:["all","subset","constrained"]},total:{type:"integer",description:"Maximum number of items to show"},order:{type:"string",description:"A space separated string containing the order of the items; each 'word' is either an id of some item or the wildcard $ representing the remaining items"}},required:["type"],oneOf:[{properties:{type:{const:"all"}},not:{required:["total","order"]}},{properties:{type:{const:"subset"}},required:["total"],not:{required:["order"]}},{properties:{type:{const:"constrained"}},required:["order"]}],additionalProperties:!1}},Ge={$id:en,$schema:tn,title:nn,type:rn,properties:sn,additionalProperties:an,required:on,$defs:ln},_n=(r=>(r.DuplicateResponse="DUPLICATE_RESPONSE",r.InternalError="INTERNAL_ERROR",r.InvalidDates="INVALID_DATES",r.InvalidId="INVALID_ID",r.InvalidParticipants="INVALID_PARTICIPANTS",r.InvalidResponse="INVALID_RESPONSE",r.MissingTitle="MISSING_TITLE",r.OverlappingSurveys="OVERLAPPING_SURVEYS",r.ParticipantsFrozen="PARTICIPANTS_FROZEN",r.SurveyIsClosed="SURVEY_IS_CLOSED",r.Unauthorized="UNAUTHORIZED",r))(_n||{}),cn=(r=>(r.Horizontal="HORIZONTAL",r.Vertical="VERTICAL",r))(cn||{}),pn=(r=>(r.Optional="OPTIONAL",r.Request="REQUEST",r.Required="REQUIRED",r))(pn||{}),me=(r=>(r.Description="DESCRIPTION",r.MatrixMulti="MATRIX_MULTI",r.MatrixSingle="MATRIX_SINGLE",r.McMulti="MC_MULTI",r.McSingle="MC_SINGLE",r.TextMulti="TEXT_MULTI",r.TextSingle="TEXT_SINGLE",r))(me||{}),un=(r=>(r.All="ALL",r.Constrained="CONSTRAINED",r.Subset="SUBSET",r))(un||{}),dn=(r=>(r.Finalized="FINALIZED",r.Partial="PARTIAL",r))(dn||{}),hn=(r=>(r.Active="ACTIVE",r.Published="PUBLISHED",r))(hn||{}),mn=(r=>(r.Q1="Q1",r.Q2="Q2",r.Q3="Q3",r.Q4="Q4",r))(mn||{}),fn=Object.defineProperty,yn=(r,t,n)=>t in r?fn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,k=(r,t,n)=>(yn(r,typeof t!="symbol"?t+"":t,n),n);function gn(r={}){return r.transformer&&r.transformer.constructor.name==="object"&&(r.transformer=H.fromObj(r.transformer)),xt._load_from_dict({data:vr,memo:br,...r})}const We={};class Ve{}const te={},Xe={escape(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},compile(r,t){return new RegExp(r,t)},error:SyntaxError};function xn(r,t,n,i){const s=r.compile(t,i).exec(n);if(s!=null)return s[0]}class He{constructor(t,n,i,s,a=!1){this.terminals=t,this.g_regex_flags=n,this.re_=i,this.use_bytes=s,this.match_whole=a,this.allowed_types=new Set(this.terminals.map(o=>o.name)),this._regexps=this._build_mres(t)}_build_mres(t){let n=this.match_whole?"$":"",i=kn(t,a=>a.pattern.flags.join("")),s=[];for(let[a,o]of i){const l=o.map(c=>`(?<${c.name}>${c.pattern.to_regexp()+n})`).join("|");s.push(new RegExp(l,this.g_regex_flags+a+"y"))}return s}match(t,n){for(const i of this._regexps){i.lastIndex=n;let s=i.exec(t);if(s){let a=null;for(let[o,l]of Object.entries(s.groups))if(l){a=o;break}return[s[0],a]}}}}const Je=typeof require!="undefined"&&require("util");class Ye{}const W={};function x(r){return Object.entries(r)}function fe(r){return Object.keys(r)}function wn(r,t){t===void 0&&(t=Object.keys(r)[0]);let n=r[t];return delete r[t],n}function Ke(r,t,n=null){return r[t]||n}function et(r,t){if(r.constructor.name==="Map")for(const[n,i]of x(t))r.set(n,i);else for(const[n,i]of x(t))r[n]=i}function Tn(r){return function(){return new r(...arguments)}}function h(r){let t=0,n=[...arguments].slice(1);return r.replace(/%([sr])/g,function(){const i=arguments[1],s=n[t++];return i==="r"?Je?Je.inspect(s,!1,null,!0):JSON.stringify(s,null,0):s})}function vn(r,t){let n=new Set(r);for(const i of t)n.add(i);return n}function tt(r,t){return[...r].filter(n=>!t.has(n))}function nt(r){return{...r}}function rt(r){return!!r}function ye(r){return Object.create(r.prototype)}function I(r){if(typeof r=="object"){let t=Object.create(Object.getPrototypeOf(r));return Object.assign(t,r)}return r}function ne(r){return new Set(r)}function ge(r){return r&&r.constructor.name==="Object"}function bn(r){return r&&r.constructor.name==="Array"}function En(r){return typeof r=="function"}function*V(r,t=0){let n=t;for(const i of r)yield[n++,i]}function Nn(r){for(const t of r)if(t)return!0;return!1}function it(r,t){return t.filter(r||rt)}function re(r){let t=[...arguments].slice(1);return function(){return r(...t,...arguments)}}class xe extends Error{}function E(r){return r[r.length-1]}function D(r){return function(){let t=new r(...arguments);return t.__call__.bind(t)}}function O(r,t){return Array.from({length:t},()=>r).flat()}function st(r){return/^[A-Z_$]*$/.test(r)}function we(r,t,n){const i=r.split(t);return n?i.splice(-n-1):i}function Te(r,t){let n=new RegExp(t,"g");return(r.match(n)||[]).length}function Rn(r,t){for(let n of r)if(!t.has(n))return!1;return!0}function*kn(r,t){let n=[],i=null;for(const s of r){const a=t(s);i&&a!=i&&(yield[i,n],n=[]),n.push(s),i=a}yield[i,n]}class A extends Error{}class S extends A{}function ve(r,t,n="Got %r, expected one of %s"){if(!t.includes(r))throw new S(h(n,r,t))}class ie extends A{}class In extends A{}class X extends A{}class z extends A{constructor(){super(...arguments),k(this,"pos_in_stream",null),k(this,"_terminals_by_name",null)}get_context(t,n=40){let i,s,a=this.pos_in_stream,o=max(a-n,0),l=a+n;return t instanceof bytes?(s=E(we(t.slice(o,a),`
2
2
  `,1)),i=t.slice(a,l).split(`
3
3
  `,1)[0],(s+i+`
4
4
  `+" "*s.expandtabs().length+`^
@@ -6,18 +6,18 @@
6
6
  `,1)),i=t.slice(a,l).split(`
7
7
  `,1)[0],s+i+`
8
8
  `+" "*s.expandtabs().length+`^
9
- `)}match_examples(t,n,i=!1){ge(n)&&(n=x(n));let s=[null,!1];for(const[a,[o,l]]of J(n))for(const[c,_]of J(l))try{t(_)}catch(p){if(p instanceof z){if(p.state.eq(this.state)){if(p.token===this.token)return o;i&&p.token.type===this.token.type&&!E(s)&&(s=[o,!0]),s[0]===null&&(s=[o,!1])}}else throw p}return s[0]}_format_expected(t){let n;return this._terminals_by_name&&(n=this._terminals_by_name,t=t.map(i=>i in n?n[i].user_repr():i)),h(`Expected one of:
9
+ `)}match_examples(t,n,i=!1){ge(n)&&(n=x(n));let s=[null,!1];for(const[a,[o,l]]of V(n))for(const[c,_]of V(l))try{t(_)}catch(p){if(p instanceof z){if(p.state.eq(this.state)){if(p.token===this.token)return o;i&&p.token.type===this.token.type&&!E(s)&&(s=[o,!0]),s[0]===null&&(s=[o,!1])}}else throw p}return s[0]}_format_expected(t){let n;return this._terminals_by_name&&(n=this._terminals_by_name,t=t.map(i=>i in n?n[i].user_repr():i)),h(`Expected one of:
10
10
  * %s
11
11
  `,t.join(`
12
- * `))}}class Rn extends z{constructor(t,n=null,i=null){super(),this.expected=t,this.state=n,this.token=new f("<EOF>",""),this.pos_in_stream=-1,this.line=-1,this.column=-1,this._terminals_by_name=i}}class U extends z{constructor({seq:t,lex_pos:n,line:i,column:s,allowed:a=null,considered_tokens:o=null,state:l=null,token_history:c=null,terminals_by_name:_=null,considered_rules:p=null}={}){super(),this.line=i,this.column=s,this.pos_in_stream=n,this.state=l,this._terminals_by_name=_,this.allowed=a,this.considered_tokens=o,this.considered_rules=p,this.token_history=c,this.char=t[n]}}class F extends z{constructor({token:t,expected:n,considered_rules:i=null,state:s=null,interactive_parser:a=null,terminals_by_name:o=null,token_history:l=null}={}){super(),this.line=t&&t.line||"?",this.column=t&&t.column||"?",this.pos_in_stream=t&&t.start_pos||null,this.state=s,this.token=t,this.expected=n,this._accepts=Ge,this.considered_rules=i,this.interactive_parser=a,this._terminals_by_name=o,this.token_history=l}get accepts(){return this._accepts===Ge&&(this._accepts=this.interactive_parser&&this.interactive_parser.accepts()),this._accepts}}class be extends S{constructor(t,n,i){let s=h(`Error trying to process rule "%s":
12
+ * `))}}class qn extends z{constructor(t,n=null,i=null){super(),this.expected=t,this.state=n,this.token=new f("<EOF>",""),this.pos_in_stream=-1,this.line=-1,this.column=-1,this._terminals_by_name=i}}class M extends z{constructor({seq:t,lex_pos:n,line:i,column:s,allowed:a=null,considered_tokens:o=null,state:l=null,token_history:c=null,terminals_by_name:_=null,considered_rules:p=null}={}){super(),this.line=i,this.column=s,this.pos_in_stream=n,this.state=l,this._terminals_by_name=_,this.allowed=a,this.considered_tokens=o,this.considered_rules=p,this.token_history=c,this.char=t[n]}}class j extends z{constructor({token:t,expected:n,considered_rules:i=null,state:s=null,interactive_parser:a=null,terminals_by_name:o=null,token_history:l=null}={}){super(),this.line=t&&t.line||"?",this.column=t&&t.column||"?",this.pos_in_stream=t&&t.start_pos||null,this.state=s,this.token=t,this.expected=n,this._accepts=We,this.considered_rules=i,this.interactive_parser=a,this._terminals_by_name=o,this.token_history=l}get accepts(){return this._accepts===We&&(this._accepts=this.interactive_parser&&this.interactive_parser.accepts()),this._accepts}}class be extends A{constructor(t,n,i){let s=h(`Error trying to process rule "%s":
13
13
 
14
- %s`,t,i);super(s),this.rule=t,this.obj=n,this.orig_exc=i}}function kn(r,t=null,n=null){let i,s,a=new Map;for(const o of r)i=t!==null?t(o):o,s=n!==null?n(o):o,a.has(i)?a.get(i).push(s):a.set(i,[s]);return a}function ae(r,t,n){let i;return ge(r)?"__type__"in r?(i=t[r.__type__],i.deserialize(r,n)):"@"in r?n[r["@"]]:Object.fromEntries(x(r).map(([s,a])=>[s,ae(a,t,n)])):wn(r)?r.map(s=>ae(s,t,n)):r}class N{static deserialize(t,n){const i=this;let s=i&&i.__serialize_fields__;if("@"in t)return n[t["@"]];let a=ye(i);for(const o of s)if(t&&o in t)a[o]=ae(t[o],yr,n);else throw new KeyError("Cannot find key for class",i,e);return"_deserialize"in a&&a._deserialize(),a}}class In extends N{static get __serialize_fields__(){return["memoized"]}constructor(t){super(),this.types_to_memoize=t,this.memoized=new Enumerator}in_types(t){return t instanceof this.types_to_memoize}serialize(){return _serialize(this.memoized.reversed(),null)}static deserialize(t,n,i){return ae(t,n,i)}}class st{constructor(){this.empty=!0}}class g{constructor(t,n,i=null){this.data=t,this.children=n,this._meta=i}get meta(){return this._meta===null&&(this._meta=new st),this._meta}repr(){return h("Tree(%r, %r)",this.data,this.children)}_pretty_label(){return this.data}_pretty(t,n){if(this.children.length===1&&!(this.children[0]instanceof g))return[O(n,t).join(""),this._pretty_label()," ",h("%s",this.children[0].value),`
14
+ %s`,t,i);super(s),this.rule=t,this.obj=n,this.orig_exc=i}}function On(r,t=null,n=null){let i,s,a=new Map;for(const o of r)i=t!==null?t(o):o,s=n!==null?n(o):o,a.has(i)?a.get(i).push(s):a.set(i,[s]);return a}function se(r,t,n){let i;return ge(r)?"__type__"in r?(i=t[r.__type__],i.deserialize(r,n)):"@"in r?n[r["@"]]:Object.fromEntries(x(r).map(([s,a])=>[s,se(a,t,n)])):bn(r)?r.map(s=>se(s,t,n)):r}class N{static deserialize(t,n){const i=this;let s=i&&i.__serialize_fields__;if("@"in t)return n[t["@"]];let a=ye(i);for(const o of s)if(t&&o in t)a[o]=se(t[o],wr,n);else throw new KeyError("Cannot find key for class",i,e);return"_deserialize"in a&&a._deserialize(),a}}class An extends N{static get __serialize_fields__(){return["memoized"]}constructor(t){super(),this.types_to_memoize=t,this.memoized=new Enumerator}in_types(t){return t instanceof this.types_to_memoize}serialize(){return _serialize(this.memoized.reversed(),null)}static deserialize(t,n,i){return se(t,n,i)}}class at{constructor(){this.empty=!0}}class g{constructor(t,n,i=null){this.data=t,this.children=n,this._meta=i}get meta(){return this._meta===null&&(this._meta=new at),this._meta}repr(){return h("Tree(%r, %r)",this.data,this.children)}_pretty_label(){return this.data}_pretty(t,n){if(this.children.length===1&&!(this.children[0]instanceof g))return[O(n,t).join(""),this._pretty_label()," ",h("%s",this.children[0].value),`
15
15
  `];let i=[O(n,t).join(""),this._pretty_label(),`
16
16
  `];for(const s of this.children)s instanceof g?i.push(...s._pretty(t+1,n)):i.push(O(n,t+1).join(""),h("%s",s.value),`
17
- `);return i}pretty(t=" "){return this._pretty(0,t).join("")}eq(t){return t&&this&&t&&this&&t.children&&this.children&&t.data&&this.data?this.data===t.data&&this.children===t.children:!1}iter_subtrees(){let t=[this],n=new Map;for(const i of t)n.set(i,i),t.push(...[...i.children].reverse().filter(s=>s instanceof g&&!n.has(s)).map(s=>s));return t=void 0,[...n.values()].reverse()}find_pred(t){return rt(t,this.iter_subtrees())}find_data(t){return this.find_pred(n=>n.data===t)}*scan_values(t){for(const n of this.children)if(n instanceof g)for(const i of n.scan_values(t))yield i;else t(n)&&(yield n)}*iter_subtrees_topdown(){let t,n=[this];for(;n.length;)if(t=n.pop(),t instanceof g){yield t;for(const i of[...t.children].reverse())n.push(i)}}copy(){return type(this)(this.data,this.children)}set(t,n){this.data=t,this.children=n}}class K extends We{static get __visit_tokens__(){return!0}constructor(t=!0){super(),this.__visit_tokens__=t}static fromObj(t,...n){class i extends this{}for(let[s,a]of Object.entries(t))i.prototype[s]=a;return new i(...n)}_call_userfunc(t,n=null){let i,s,a=n!==null?n:t.children;if(t&&t.data&&this&&this[t.data]){i=this&&this[t.data];try{return s=i&&i.visit_wrapper||null,s!==null?i.visit_wrapper(i,t.data,a,t.meta):i(a)}catch(o){throw o instanceof se?o:o instanceof Error?new be(t.data,t,o):o}}else return this.__default__(t.data,a,t.meta)}_call_userfunc_token(t){let n;if(t&&t.type&&this&&this[t.type]){n=this&&this[t.type];try{return n(t)}catch(i){throw i instanceof se?i:i instanceof Error?new be(t.type,t,i):i}}else return this.__default_token__(t)}*_transform_children(t){let n;for(const i of t)i instanceof g?n=this._transform_tree(i):this.__visit_tokens__&&i instanceof f?n=this._call_userfunc_token(i):n=i,n!==ne&&(yield n)}_transform_tree(t){let n=[...this._transform_children(t.children)];return this._call_userfunc(t,n)}transform(t){return this._transform_tree(t)}__default__(t,n,i){return new g(t,n,i)}__default_token__(t){return t}}class at extends K{_transform_tree(t){return this._call_userfunc(t)}transform(t){for(const n of t.iter_subtrees())n.children=[...this._transform_children(n.children)];return this._transform_tree(t)}}class qn extends K{transform(t){let n,i,s,a=[],o=[t];for(;o.length;){const _=o.pop();a.push(_),_ instanceof g&&o.push(..._.children)}let l=[];for(const _ of[...a].reverse())_ instanceof g?(s=_.children.length,s?(n=l.slice(-s),l.splice(-s)):n=[],i=this._call_userfunc(_,n),i!==ne&&l.push(i)):this.__visit_tokens__&&_ instanceof f?(i=this._call_userfunc_token(_),i!==ne&&l.push(i)):l.push(_);let[c]=l;return c}}class On extends K{_transform_tree(t){return t.children=[...this._transform_children(t.children)],this._call_userfunc(t)}}class Ee{_call_userfunc(t){const n=this[t.data];return n?n(t):this.__default__(t)}__default__(t){return t}__class_getitem__(t){return cls}}class Sn extends Ee{visit(t){for(const n of t.iter_subtrees())this._call_userfunc(n);return t}visit_topdown(t){for(const n of t.iter_subtrees_topdown())this._call_userfunc(n);return t}}class An extends Ee{visit(t){for(const n of t.children)n instanceof g&&this.visit(n);return this._call_userfunc(t),t}visit_topdown(t){this._call_userfunc(t);for(const n of t.children)n instanceof g&&this.visit_topdown(n);return t}}class $n extends We{visit(t){return t.data in this?this[t.data](t):this.__default__(t)}visit_children(t){return t.children.map(n=>n instanceof g?this.visit(n):n)}__default__(t){return this.visit_children(t)}}var zn=0;class Ne extends N{constructor(t){super(),k(this,"is_term",H),this.name=t}eq(t){return this.is_term===t.is_term&&this.name===t.name}repr(){return h("%s(%r)",type(this).name,this.name)}static get fullrepr(){return property(__repr__)}get fullrepr(){return this.constructor.fullrepr}renamed(t){return type(this)(t(this.name))}}class Re extends Ne{static get __serialize_fields__(){return["name","filter_out"]}get is_term(){return!0}constructor(t,n=!1){super(),this.name=t,this.filter_out=n}get fullrepr(){return h("%s(%r, %r)",type(this).name,this.name,this.filter_out)}renamed(t){return type(this)(t(this.name),this.filter_out)}}class ke extends Ne{static get __serialize_fields__(){return["name"]}get is_term(){return!1}}class oe extends N{static get __serialize_fields__(){return["keep_all_tokens","expand1","priority","template_source","empty_indices"]}constructor(t=!1,n=!1,i=null,s=null,a=[]){super(),this.keep_all_tokens=t,this.expand1=n,this.priority=i,this.template_source=s,this.empty_indices=a}repr(){return h("RuleOptions(%r, %r, %r, %r)",this.keep_all_tokens,this.expand1,this.priority,this.template_source)}}class V extends N{static get __serialize_fields__(){return["origin","expansion","order","alias","options"]}static get __serialize_namespace__(){return[Re,ke,oe]}constructor(t,n,i=0,s=null,a=null){super(),this.origin=t,this.expansion=n,this.alias=s,this.order=i,this.options=a||new oe,this._hash=[this.origin,this.expansion]}_deserialize(){this._hash=[this.origin,this.expansion]}repr(){return h("Rule(%r, %r, %r, %r)",this.origin,this.expansion,this.alias,this.options)}eq(t){return t instanceof V?this.origin===t.origin&&this.expansion===t.expansion:!1}}class Ie extends N{constructor(t,n=[],i=null){super(),this.value=t,this.flags=re(n),this.raw=i}repr(){return repr(this.to_regexp())}eq(t){return type(this)===type(t)&&this.value===t.value&&this.flags===t.flags}to_regexp(){throw new NotImplementedError}get min_width(){throw new NotImplementedError}get max_width(){throw new NotImplementedError}_get_flags(t){return t}}class qe extends Ie{static get __serialize_fields__(){return["value","flags"]}static get type(){return"str"}to_regexp(){return this._get_flags(Ve.escape(this.value))}get min_width(){return this.value.length}get max_width(){return this.value.length}}class Oe extends Ie{static get __serialize_fields__(){return["value","flags","_width"]}static get type(){return"re"}to_regexp(){return this._get_flags(this.value)}_get_width(){return this._width===null&&(this._width=get_regexp_width(this.to_regexp())),this._width}get min_width(){return this._get_width()[0]}get max_width(){return this._get_width()[1]}}class le extends N{static get __serialize_fields__(){return["name","pattern","priority"]}static get __serialize_namespace__(){return[qe,Oe]}constructor(t,n,i=zn){super(),this.name=t,this.pattern=n,this.priority=i}repr(){return h("%s(%r, %r)",type(this).name,this.name,this.pattern)}user_repr(){return this.name.startsWith("__")?this.pattern.raw||this.name:this.name}}class f{constructor(t,n,i=null,s=null,a=null,o=null,l=null,c=null){k(this,"value"),k(this,"type"),this.type=t,this.start_pos=i,this.value=n,this.line=s,this.column=a,this.end_line=o,this.end_column=l,this.end_pos=c}update(t=null,n=null){return f.new_borrow_pos(t!==null?t:this.type,n!==null?n:this.value,this)}static new_borrow_pos(t,n,i){const s=this;return new s(t,n,i.start_pos,i.line,i.column,i.end_line,i.end_column,i.end_pos)}repr(){return h("Token(%r, %r)",this.type,this.value)}eq(t){return t instanceof f&&this.type!==t.type?!1:str.__eq__(this,t)}static get __hash__(){return str.__hash__}}class Me{constructor(t){this.newline_char=t,this.char_pos=0,this.line=1,this.column=1,this.line_start_pos=0}eq(t){return t instanceof Me?this.char_pos===t.char_pos&&this.newline_char===t.newline_char:H}feed(t,n=!0){let i;n&&(i=Te(t,this.newline_char),i&&(this.line+=i,this.line_start_pos=this.char_pos+t.lastIndexOf(this.newline_char)+1)),this.char_pos+=t.length,this.column=this.char_pos-this.line_start_pos+1}}class Pn{constructor(t){this.scanner=t}__call__(t){let n,i=this.scanner.match(t.value,0);return i&&([n,t.type]=i),t}}const Dn=D(Pn);class Ln{constructor(t,n,i){this.callback1=t,this.callback2=n,this.cond=i}__call__(t){let n=this.callback1(t);return this.cond(n)?this.callback2(t):n}}const Cn=D(Ln);function Qn(r,t,n,i){let s,a,o=kn(r,_=>_.pattern.constructor.type),l=new Set,c={};for(const _ of o.get("re")||[]){a=[];for(const p of o.get("str")||[])p.priority===_.priority&&(s=p.pattern.value,s===fn(n,_.pattern.to_regexp(),s,t)&&(a.push(p),bn(new Set(p.pattern.flags),new Set(_.pattern.flags))&&l.add(p)));a.length&&(c[_.name]=new Dn(new Xe(a,t,n,i,!0)))}return[r.filter(_=>!l.has(_)).map(_=>_),c]}function Mn(r){return r.includes(`
17
+ `);return i}pretty(t=" "){return this._pretty(0,t).join("")}eq(t){return t&&this&&t&&this&&t.children&&this.children&&t.data&&this.data?this.data===t.data&&this.children===t.children:!1}iter_subtrees(){let t=[this],n=new Map;for(const i of t)n.set(i,i),t.push(...[...i.children].reverse().filter(s=>s instanceof g&&!n.has(s)).map(s=>s));return t=void 0,[...n.values()].reverse()}find_pred(t){return it(t,this.iter_subtrees())}find_data(t){return this.find_pred(n=>n.data===t)}*scan_values(t){for(const n of this.children)if(n instanceof g)for(const i of n.scan_values(t))yield i;else t(n)&&(yield n)}*iter_subtrees_topdown(){let t,n=[this];for(;n.length;)if(t=n.pop(),t instanceof g){yield t;for(const i of[...t.children].reverse())n.push(i)}}copy(){return type(this)(this.data,this.children)}set(t,n){this.data=t,this.children=n}}class H extends Ve{static get __visit_tokens__(){return!0}constructor(t=!0){super(),this.__visit_tokens__=t}static fromObj(t,...n){class i extends this{}for(let[s,a]of Object.entries(t))i.prototype[s]=a;return new i(...n)}_call_userfunc(t,n=null){let i,s,a=n!==null?n:t.children;if(t&&t.data&&this&&this[t.data]){i=this&&this[t.data];try{return s=i&&i.visit_wrapper||null,s!==null?i.visit_wrapper(i,t.data,a,t.meta):i(a)}catch(o){throw o instanceof ie?o:o instanceof Error?new be(t.data,t,o):o}}else return this.__default__(t.data,a,t.meta)}_call_userfunc_token(t){let n;if(t&&t.type&&this&&this[t.type]){n=this&&this[t.type];try{return n(t)}catch(i){throw i instanceof ie?i:i instanceof Error?new be(t.type,t,i):i}}else return this.__default_token__(t)}*_transform_children(t){let n;for(const i of t)i instanceof g?n=this._transform_tree(i):this.__visit_tokens__&&i instanceof f?n=this._call_userfunc_token(i):n=i,n!==te&&(yield n)}_transform_tree(t){let n=[...this._transform_children(t.children)];return this._call_userfunc(t,n)}transform(t){return this._transform_tree(t)}__default__(t,n,i){return new g(t,n,i)}__default_token__(t){return t}}class ot extends H{_transform_tree(t){return this._call_userfunc(t)}transform(t){for(const n of t.iter_subtrees())n.children=[...this._transform_children(n.children)];return this._transform_tree(t)}}class Sn extends H{transform(t){let n,i,s,a=[],o=[t];for(;o.length;){const _=o.pop();a.push(_),_ instanceof g&&o.push(..._.children)}let l=[];for(const _ of[...a].reverse())_ instanceof g?(s=_.children.length,s?(n=l.slice(-s),l.splice(-s)):n=[],i=this._call_userfunc(_,n),i!==te&&l.push(i)):this.__visit_tokens__&&_ instanceof f?(i=this._call_userfunc_token(_),i!==te&&l.push(i)):l.push(_);let[c]=l;return c}}class $n extends H{_transform_tree(t){return t.children=[...this._transform_children(t.children)],this._call_userfunc(t)}}class Ee{_call_userfunc(t){const n=this[t.data];return n?n(t):this.__default__(t)}__default__(t){return t}__class_getitem__(t){return cls}}class zn extends Ee{visit(t){for(const n of t.iter_subtrees())this._call_userfunc(n);return t}visit_topdown(t){for(const n of t.iter_subtrees_topdown())this._call_userfunc(n);return t}}class Pn extends Ee{visit(t){for(const n of t.children)n instanceof g&&this.visit(n);return this._call_userfunc(t),t}visit_topdown(t){this._call_userfunc(t);for(const n of t.children)n instanceof g&&this.visit_topdown(n);return t}}class Dn extends Ve{visit(t){return t.data in this?this[t.data](t):this.__default__(t)}visit_children(t){return t.children.map(n=>n instanceof g?this.visit(n):n)}__default__(t){return this.visit_children(t)}}var Ln=0;class Ne extends N{constructor(t){super(),k(this,"is_term",W),this.name=t}eq(t){return this.is_term===t.is_term&&this.name===t.name}repr(){return h("%s(%r)",type(this).name,this.name)}static get fullrepr(){return property(__repr__)}get fullrepr(){return this.constructor.fullrepr}renamed(t){return type(this)(t(this.name))}}class Re extends Ne{static get __serialize_fields__(){return["name","filter_out"]}get is_term(){return!0}constructor(t,n=!1){super(),this.name=t,this.filter_out=n}get fullrepr(){return h("%s(%r, %r)",type(this).name,this.name,this.filter_out)}renamed(t){return type(this)(t(this.name),this.filter_out)}}class ke extends Ne{static get __serialize_fields__(){return["name"]}get is_term(){return!1}}class ae extends N{static get __serialize_fields__(){return["keep_all_tokens","expand1","priority","template_source","empty_indices"]}constructor(t=!1,n=!1,i=null,s=null,a=[]){super(),this.keep_all_tokens=t,this.expand1=n,this.priority=i,this.template_source=s,this.empty_indices=a}repr(){return h("RuleOptions(%r, %r, %r, %r)",this.keep_all_tokens,this.expand1,this.priority,this.template_source)}}class Z extends N{static get __serialize_fields__(){return["origin","expansion","order","alias","options"]}static get __serialize_namespace__(){return[Re,ke,ae]}constructor(t,n,i=0,s=null,a=null){super(),this.origin=t,this.expansion=n,this.alias=s,this.order=i,this.options=a||new ae,this._hash=[this.origin,this.expansion]}_deserialize(){this._hash=[this.origin,this.expansion]}repr(){return h("Rule(%r, %r, %r, %r)",this.origin,this.expansion,this.alias,this.options)}eq(t){return t instanceof Z?this.origin===t.origin&&this.expansion===t.expansion:!1}}class Ie extends N{constructor(t,n=[],i=null){super(),this.value=t,this.flags=ne(n),this.raw=i}repr(){return repr(this.to_regexp())}eq(t){return type(this)===type(t)&&this.value===t.value&&this.flags===t.flags}to_regexp(){throw new NotImplementedError}get min_width(){throw new NotImplementedError}get max_width(){throw new NotImplementedError}_get_flags(t){return t}}class qe extends Ie{static get __serialize_fields__(){return["value","flags"]}static get type(){return"str"}to_regexp(){return this._get_flags(Xe.escape(this.value))}get min_width(){return this.value.length}get max_width(){return this.value.length}}class Oe extends Ie{static get __serialize_fields__(){return["value","flags","_width"]}static get type(){return"re"}to_regexp(){return this._get_flags(this.value)}_get_width(){return this._width===null&&(this._width=get_regexp_width(this.to_regexp())),this._width}get min_width(){return this._get_width()[0]}get max_width(){return this._get_width()[1]}}class oe extends N{static get __serialize_fields__(){return["name","pattern","priority"]}static get __serialize_namespace__(){return[qe,Oe]}constructor(t,n,i=Ln){super(),this.name=t,this.pattern=n,this.priority=i}repr(){return h("%s(%r, %r)",type(this).name,this.name,this.pattern)}user_repr(){return this.name.startsWith("__")?this.pattern.raw||this.name:this.name}}class f{constructor(t,n,i=null,s=null,a=null,o=null,l=null,c=null){k(this,"value"),k(this,"type"),this.type=t,this.start_pos=i,this.value=n,this.line=s,this.column=a,this.end_line=o,this.end_column=l,this.end_pos=c}update(t=null,n=null){return f.new_borrow_pos(t!==null?t:this.type,n!==null?n:this.value,this)}static new_borrow_pos(t,n,i){const s=this;return new s(t,n,i.start_pos,i.line,i.column,i.end_line,i.end_column,i.end_pos)}repr(){return h("Token(%r, %r)",this.type,this.value)}eq(t){return t instanceof f&&this.type!==t.type?!1:str.__eq__(this,t)}static get __hash__(){return str.__hash__}}class Me{constructor(t){this.newline_char=t,this.char_pos=0,this.line=1,this.column=1,this.line_start_pos=0}eq(t){return t instanceof Me?this.char_pos===t.char_pos&&this.newline_char===t.newline_char:W}feed(t,n=!0){let i;n&&(i=Te(t,this.newline_char),i&&(this.line+=i,this.line_start_pos=this.char_pos+t.lastIndexOf(this.newline_char)+1)),this.char_pos+=t.length,this.column=this.char_pos-this.line_start_pos+1}}class Cn{constructor(t){this.scanner=t}__call__(t){let n,i=this.scanner.match(t.value,0);return i&&([n,t.type]=i),t}}const Qn=D(Cn);class Mn{constructor(t,n,i){this.callback1=t,this.callback2=n,this.cond=i}__call__(t){let n=this.callback1(t);return this.cond(n)?this.callback2(t):n}}const jn=D(Mn);function Un(r,t,n,i){let s,a,o=On(r,_=>_.pattern.constructor.type),l=new Set,c={};for(const _ of o.get("re")||[]){a=[];for(const p of o.get("str")||[])p.priority===_.priority&&(s=p.pattern.value,s===xn(n,_.pattern.to_regexp(),s,t)&&(a.push(p),Rn(new Set(p.pattern.flags),new Set(_.pattern.flags))&&l.add(p)));a.length&&(c[_.name]=new Qn(new He(a,t,n,i,!0)))}return[r.filter(_=>!l.has(_)).map(_=>_),c]}function Fn(r){return r.includes(`
18
18
  `)||r.includes("\\n")||r.includes("\\s")||r.includes("[^")||r.includes("(?s")&&r.includes(".")}class je{constructor(t,n=null,i=null){this.text=t,this.line_ctr=n||new Me(`
19
- `),this.last_token=i}eq(t){return t instanceof je?this.text===t.text&&this.line_ctr===t.line_ctr&&this.last_token===t.last_token:H}}class ot{constructor(t,n){this.lexer=t,this.state=n}static from_text(t,n){return new this(t,new je(n))}lex(t){return this.lexer.lex(this.state,t)}}class _e extends Je{lex(t,n){return H}}function jn(r,t){r.sort((n,i)=>{let s=t(n),a=t(i);for(let o=0;o<s.length;o++){if(s[o]>a[o])return 1;if(s[o]<a[o])return-1}return 0})}class ce extends _e{constructor(t){super();let n=[...t.terminals];if(this.re=t.re_module,!t.skip_validation){for(const i of n){try{this.re.compile(i.pattern.to_regexp(),t.g_regex_flags)}catch(s){throw s instanceof this.re.error?new Y(h("Cannot compile token %s: %s",i.name,i.pattern)):s}if(i.pattern.min_width===0)throw new Y(h("Lexer does not allow zero-width terminals. (%s: %s)",i.name,i.pattern))}if(!(new Set(t.ignore)<=new Set(n.map(i=>i.name))))throw new Y(h("Ignore terminals are not defined: %s",et(new Set(t.ignore),new Set(n.map(i=>i.name)))))}this.newline_types=re(n.filter(i=>Mn(i.pattern.to_regexp())).map(i=>i.name)),this.ignore_types=re(t.ignore),jn(n,i=>[-i.priority,-i.pattern.max_width,-i.pattern.value.length,i.name]),this.terminals=n,this.user_callbacks=t.callbacks,this.g_regex_flags=t.g_regex_flags,this.use_bytes=t.use_bytes,this.terminals_by_name=t.terminals_by_name,this._scanner=null}_build_scanner(){let t;[t,this.callback]=Qn(this.terminals,this.g_regex_flags,this.re,this.use_bytes);for(const[n,i]of x(this.user_callbacks))n in this.callback?this.callback[n]=new Cn(this.callback[n],i,s=>s.type===n):this.callback[n]=i;this._scanner=new Xe(t,this.g_regex_flags,this.re,this.use_bytes)}get scanner(){return this._scanner===null&&this._build_scanner(),this._scanner}match(t,n){return this.scanner.match(t,n)}*lex(t,n){try{for(;;)yield this.next_token(t,n)}catch(i){if(!(i instanceof xe))throw i}}next_token(t,n=null){let i,s,a,o,l=t.line_ctr;for(;l.char_pos<t.text.length;){if(s=this.match(t.text,l.char_pos),!s)throw i=et(this.scanner.allowed_types,this.ignore_types),i||(i=new Set(["<END-OF-FILE>"])),new U({seq:t.text,lex_pos:l.char_pos,line:l.line,column:l.column,allowed:i,token_history:t.last_token&&[t.last_token],state:n,terminals_by_name:this.terminals_by_name});let[c,_]=s;if(this.ignore_types.has(_))_ in this.callback&&(o=new f(_,c,l.char_pos,l.line,l.column),this.callback[_](o)),l.feed(c,this.newline_types.has(_));else{if(a=new f(_,c,l.char_pos,l.line,l.column),l.feed(c,this.newline_types.has(_)),a.end_line=l.line,a.end_column=l.column,a.end_pos=l.char_pos,a.type in this.callback&&(a=this.callback[a.type](a),!(a instanceof f)))throw new Y(h("Callbacks must return a token (returned %r)",a));return t.last_token=a,a}}throw new xe(this)}}class Un extends _e{constructor({conf:t,states:n,always_accept:i=[]}={}){super();let s,a,o,l=[...t.terminals],c=t.terminals_by_name,_=I(t);_.terminals=l;let p=new Map;this.lexers={};for(let[y,v]of x(n))s=re(v),p.has(s)?a=p.get(s):(v=xn(new Set(v),[...new Set(t.ignore),...new Set(i)]),o=I(_),o.terminals=[...v].filter(w=>w in c).map(w=>c[w]),a=new ce(o),p.set(s,a)),this.lexers[y]=a;this.root_lexer=new ce(_)}*lex(t,n){let i,s,a;try{for(;;)s=this.lexers[n.position],yield s.next_token(t,n)}catch(o){if(!(o instanceof xe))if(o instanceof U)try{throw i=t.last_token,a=this.root_lexer.next_token(t,n),new F({token:a,expected:o.allowed,state:n,token_history:[i],terminals_by_name:this.root_lexer.terminals_by_name})}catch(l){throw l}else throw o}}}class lt extends N{static get __serialize_fields__(){return["terminals","ignore","g_regex_flags","use_bytes","lexer_type"]}static get __serialize_namespace__(){return[le]}constructor({terminals:t,re_module:n,ignore:i=[],postlex:s=null,callbacks:a=null,g_regex_flags:o="",skip_validation:l=!1,use_bytes:c=!1}={}){super(),this.terminals=t,this.terminals_by_name=Object.fromEntries(this.terminals.map(_=>[_.name,_])),this.ignore=i,this.postlex=s,this.callbacks=Object.keys(a).length||{},this.g_regex_flags=o,this.re_module=n,this.skip_validation=l,this.use_bytes=c,this.lexer_type=null}_deserialize(){this.terminals_by_name=Object.fromEntries(this.terminals.map(t=>[t.name,t]))}}class _t extends N{static get __serialize_fields__(){return["rules","start","parser_type"]}constructor(t,n,i){super(),this.rules=t,this.callbacks=n,this.start=i,this.parser_type=null}}class Fn{constructor(t){this.node_builder=t}__call__(t){return t.length===1?t[0]:this.node_builder(t)}}const Zn=D(Fn);class Bn{constructor(t,n=null){this.node_builder=t,this.node_filter=n}__call__(t){let n,i,s,a=this.node_builder(t);return a instanceof g&&(s=a.meta,n=this._pp_get_meta(t),n!==null&&("line"in s||(s.line=n&&n.container_line||n.line,s.column=n&&n.container_column||n.column,s.start_pos=n&&n.container_start_pos||n.start_pos,s.empty=!1),s.container_line=n&&n.container_line||n.line,s.container_column=n&&n.container_column||n.column),i=this._pp_get_meta([...t].reverse()),i!==null&&("end_line"in s||(s.end_line=i&&i.container_end_line||i.end_line,s.end_column=i&&i.container_end_column||i.end_column,s.end_pos=i&&i.container_end_pos||i.end_pos,s.empty=!1),s.container_end_line=i&&i.container_end_line||i.end_line,s.container_end_column=i&&i.container_end_column||i.end_column)),a}_pp_get_meta(t){for(const n of t)if(!(this.node_filter!==null&&!this.node_filter(n))){if(n instanceof g){if(!n.meta.empty)return n.meta}else if(n instanceof f)return n}}}const ct=D(Bn);function Gn(r){if(Tn(r))return ie({unknown_param_0:ct,node_filter:r});if(r===!0)return ct;if(r===!1)return null;throw new A(h("Invalid option for propagate_positions: %r",r))}class Se{constructor(t,n,i){this.node_builder=i,this.to_include=t,this.append_none=n}__call__(t){let n=[];for(const[i,s,a]of this.to_include)a&&n.push(...O([null],a)),s?n.push(...t[i].children):n.push(t[i]);return this.append_none&&n.push(...O([null],this.append_none)),this.node_builder(n)}}const Wn=D(Se);class Vn extends Se{__call__(t){let n=[];for(const[i,s,a]of this.to_include)a&&n.push(...O([null],a)),s?n.length?n.push(...t[i].children):n=t[i].children:n.push(t[i]);return this.append_none&&n.push(...O([null],this.append_none)),this.node_builder(n)}}const Xn=D(Vn);class Hn extends Se{constructor(t,n){super(),this.node_builder=n,this.to_include=t}__call__(t){let n=[];for(const[i,s]of this.to_include)s?n.length?n.push(...t[i].children):n=t[i].children:n.push(t[i]);return this.node_builder(n)}}const Jn=D(Hn);function Yn(r){return!r.is_term&&r.name.startsWith("_")}function Kn(r,t,n,i){let s,a;i.length?(a=i.map(c=>(0+c).toString()).join(""),s=a.split("0").map(c=>c.length)):s=O([0],r.length+1);let o=[],l=0;for(const[c,_]of J(r))l+=s[c],(t||!(_.is_term&&_.filter_out))&&(o.push([c,Yn(_),l]),l=0);if(l+=s[r.length],i.length||o.length<r.length||vn(o.map(([c,_,p])=>_)))return(i.length||n).length?ie(n?Wn:Xn,o,l):ie(Jn,o.map(([c,_,p])=>[c,_]))}function er(r){function t(n){let i=new g(r.name,n);return r(i)}return t=wraps(r)(t),t}function tr(r,t,n){if(n===_vargs_meta||n===_vargs_meta_inline)throw new NotImplementedError("Meta args not supported for internal transformer");function i(s){return n(r,t,s,null)}return i=wraps(r)(i),i}class nr{constructor(t,n,i=!1,s=!1,a=!1){this.tree_class=n,this.propagate_positions=i,this.ambiguous=s,this.maybe_placeholders=a,this.rule_builders=[...this._init_builders(t)]}*_init_builders(t){let n,i,s,a,o=Gn(this.propagate_positions);for(const l of t)s=l.options,i=s.keep_all_tokens,n=s.expand1,a=[...rt(null,[n&&!l.alias&&Zn,Kn(l.expansion,i,this.ambiguous,this.maybe_placeholders?s.empty_indices:[]),o])],yield[l,a]}create_callback(t=null){let n,i,s,a=new Map;for(const[o,l]of this.rule_builders){i=o.alias||o.options.template_source||o.origin.name,t&&t[i]?(n=t&&t[i],s=n&&n.visit_wrapper||null,s!==null?n=tr(n,i,s):t instanceof at&&(n=er(n))):n=ie(this.tree_class,i);for(const c of l)n=c(n);if(a.has(o))throw new se(h("Rule '%s' already exists",o));a.set(o,n)}return a}}class pt extends N{constructor({parser_conf:t,debug:n=!1}={}){super();let i=new LALR_Analyzer({unknown_param_0:t,debug:n});i.compute_lalr();let s=t.callbacks;this._parse_table=i.parse_table,this.parser_conf=t,this.parser=new ut(i.parse_table,s,n)}static deserialize(t,n,i,s=!1){let a=ye(this);return a._parse_table=sr.deserialize(t,n),a.parser=new ut(a._parse_table,i,s),a}serialize(t){return this._parse_table.serialize(t)}parse_interactive(t,n){return this.parser.parse({lexer:t,start:n,start_interactive:!0})}parse({lexer:t,start:n,on_error:i=null}={}){let s,a;try{return this.parser.parse({lexer:t,start:n})}catch(o){if(o instanceof z){if(i===null)throw o;for(;;){if(o instanceof U&&(a=o.interactive_parser.lexer_thread.state,s=a.line_ctr.char_pos),!i(o))throw o;o instanceof U&&s===a.line_ctr.char_pos&&a.line_ctr.feed(a.text.slice(s,s+1));try{return o.interactive_parser.resume_parse()}catch(l){if(l instanceof F){if(o instanceof F&&o.token.type===l.token.type&&l.token.type==="$END"&&o.interactive_parser.eq(l.interactive_parser))throw l;o=l}else if(l instanceof U)o=l;else throw l}}}else throw o}}}class rr{constructor(t,n,i){this.parse_table=t,this.start_state=this.parse_table.start_states[i],this.end_state=this.parse_table.end_states[i],this.states=this.parse_table.states,this.callbacks=n,this.start=i}}class Ue{constructor(t,n,i=null,s=null){this.parse_conf=t,this.lexer=n,this.state_stack=i||[this.parse_conf.start_state],this.value_stack=s||[]}get position(){return E(this.state_stack)}eq(t){return t instanceof Ue?this.state_stack.length===t.state_stack.length&&this.position===t.position:H}copy(){return I(this)}feed_token(t,n=!1){let i,s,a,o,l,c,_,p,y,v,w=this.state_stack,u=this.value_stack,d=this.parse_conf.states,m=this.parse_conf.end_state,b=this.parse_conf.callbacks;for(;;){if(y=E(w),t.type in d[y])[s,a]=d[y][t.type];else throw o=new Set(fe(d[y]).filter(q=>it(q)).map(q=>q)),new F({token:t,expected:o,state:this,interactive_parser:null});if(s===Ae){w.push(a),u.push(t.type in b?b[t.type](t):t);return}else if(c=a,p=c.expansion.length,p?(_=u.slice(-p),w.splice(-p),u.splice(-p)):_=[],v=b.get(c)(_),[i,l]=d[E(w)][c.origin.name],w.push(l),u.push(v),n&&E(w)===m)return E(u)}}}class ut{constructor(t,n,i=!1){this.parse_table=t,this.callbacks=n,this.debug=i}parse({lexer:t,start:n,value_stack:i=null,state_stack:s=null,start_interactive:a=!1}={}){let o=new rr(this.parse_table,this.callbacks,n),l=new Ue(o,t,s,i);return a?new P(this,l,l.lexer):this.parse_from_state(l)}parse_from_state(t){let n,i;try{i=null;for(i of t.lexer.lex(t))t.feed_token(i);return n=i?f.new_borrow_pos("$END","",i):new f("$END","",0,1,1),t.feed_token(n,!0)}catch(s){if(s instanceof z){try{s.interactive_parser=new P(this,t,t.lexer)}catch(a){if(!(a instanceof ReferenceError))throw a}throw s}else if(s instanceof Error){if(this.debug){console.log(""),console.log("STATE STACK DUMP"),console.log("----------------");for(const[a,o]of J(t.state_stack))console.log(h("%d)",a),o);console.log("")}throw s}else throw s}}}class P{constructor(t,n,i){this.parser=t,this.parser_state=n,this.lexer_thread=i,this.result=null}feed_token(t){return this.parser_state.feed_token(t,t.type==="$END")}*iter_parse(){for(const t of this.lexer_thread.lex(this.parser_state))yield t,this.result=this.feed_token(t)}exhaust_lexer(){return[...this.iter_parse()]}feed_eof(t=null){let n=t!==null?f.new_borrow_pos("$END","",t):new f("$END","",0,1,1);return this.feed_token(n)}copy(){return I(this)}eq(t){return t instanceof P?this.parser_state===t.parser_state&&this.lexer_thread===t.lexer_thread:!1}as_immutable(){let t=I(this);return new dt(t.parser,t.parser_state,t.lexer_thread)}pretty(){let t=["Parser choices:"];for(const[n,i]of x(this.choices()))t.push(h(" - %s -> %r",n,i));return t.push(h("stack size: %s",this.parser_state.state_stack.length)),t.join(`
20
- `)}choices(){return this.parser_state.parse_conf.parse_table.states[this.parser_state.position]}accepts(){let t,n=new Set;for(const i of this.choices())if(it(i)){t=I(this);let s=null;try{t.feed_token(new f(i,""))}catch(a){if(s=a,!(a instanceof F))throw a}s||n.add(i)}return n}resume_parse(){return this.parser.parse_from_state(this.parser_state)}}class dt extends P{constructor(){super(...arguments),k(this,"result",null)}feed_token(t){let n=I(this);return n.result=P.feed_token(n,t),n}exhaust_lexer(){let t=this.as_mutable();return t.exhaust_lexer(),t.as_immutable()}as_mutable(){let t=I(this);return new P(t.parser,t.parser_state,t.lexer_thread)}}class ht{constructor(t){this.name=t}repr(){return this.toString()}}var Ae=new ht("Shift"),mt=new ht("Reduce");class ir{constructor(t,n,i){this.states=t,this.start_states=n,this.end_states=i}serialize(t){let n=new Enumerator,i=Object.fromEntries(x(this.states).map(([s,a])=>[s,Object.fromEntries(x(a).map(([o,[l,c]])=>[Ye(n,o),l===mt?[1,c.serialize(t)]:[0,c]]))]));return{tokens:n.reversed(),states:i,start_states:this.start_states,end_states:this.end_states}}static deserialize(t,n){const i=this;let s=t.tokens,a=Object.fromEntries(x(t.states).map(([o,l])=>[o,Object.fromEntries(x(l).map(([c,[_,p]])=>[s[c],_===1?[mt,V.deserialize(p,n)]:[Ae,p]]))]));return new i(a,t.start_states,t.end_states)}}class sr extends ir{static from_ParseTable(t){const n=this;let i=[...t.states],s=Object.fromEntries(J(i).map(([c,_])=>[_,c])),a={};for(let[c,_]of x(t.states))_=Object.fromEntries(x(_).map(([p,y])=>[p,y[0]===Ae?[y[0],s[y[1]]]:y])),a[s[c]]=_;let o=Object.fromEntries(x(t.start_states).map(([c,_])=>[c,s[_]])),l=Object.fromEntries(x(t.end_states).map(([c,_])=>[c,s[_]]));return new n(a,o,l)}}function ar(r){if(r&&r.__future_interface__)return r;{class t extends _e{constructor(i){super(),this.lexer=r(i)}lex(i,s){return this.lexer.lex(i.text)}}return t}}function or(r,t,n,i,s){let a=_t.deserialize(r.parser_conf,t),o=pt.deserialize(r.parser,t,i,s.debug);return a.callbacks=i,new lr({lexer_conf:n,parser_conf:a,options:s,parser:o})}var ft={};class lr extends N{static get __serialize_fields__(){return["lexer_conf","parser_conf","parser"]}constructor({lexer_conf:t,parser_conf:n,options:i,parser:s=null}={}){super();let a,o;this.parser_conf=n,this.lexer_conf=t,this.options=i,s?this.parser=s:(o=Ye(ft,n.parser_type),this.parser=o(t,n,i));let l=t.lexer_type;if(this.skip_lexer=!1,["dynamic","dynamic_complete"].includes(l)){this.skip_lexer=!0;return}const c={basic:ur,contextual:dr};l in c?(a=c[l],this.lexer=a(t,this.parser,t.postlex,i)):this.lexer=ar(l)(t),t.postlex&&(this.lexer=new pr(this.lexer,t.postlex))}_verify_start(t=null){let n;if(t===null){if(n=this.parser_conf.start,n.length>1)throw new A("Lark initialized with more than 1 possible start rule. Must specify which start rule to parse",n);[t]=n}else if(!this.parser_conf.start.includes(t))throw new A(h("Unknown start rule %s. Must be one of %r",t,this.parser_conf.start));return t}_make_lexer_thread(t){return this.skip_lexer?t:ot.from_text(this.lexer,t)}parse(t,n=null,i=null){let s=this._verify_start(n),a=i===null?{}:{on_error:i},o=this._make_lexer_thread(t);return this.parser.parse({lexer:o,start:s,...a})}parse_interactive(t=null,n=null){let i=this._verify_start(n);if(this.parser_conf.parser_type!=="lalr")throw new A("parse_interactive() currently only works with parser='lalr' ");let s=this._make_lexer_thread(t);return this.parser.parse_interactive(s,i)}}function _r(r,t){let n;ve(r,["lalr","earley","cyk"]),typeof t!="object"&&(n={lalr:["basic","contextual"],earley:["basic","dynamic","dynamic_complete"],cyk:["basic"]}[r],ve(t,n,h("Parser %r does not support lexer %%r, expected one of %%s",r)))}function cr(r,t){let n,i={};for(const s of t)n=r&&r[s.name]||null,n!==null&&(i[s.name]=n);return i}class pr{constructor(t,n){this.lexer=t,this.postlexer=n}lex(t,n){let i=this.lexer.lex(t,n);return this.postlexer.process(i)}}function ur(r,t,n,i){return new ce(r)}function dr(r,t,n,i){let s=Object.fromEntries(x(t._parse_table.states).map(([o,l])=>[o,[...fe(l)]])),a=n?n.always_accept:[];return new Un({conf:r,states:s,always_accept:a})}function hr(r,t,n=null){let i=n?n.debug:!1;return new pt({parser_conf:t,debug:i})}ft.lalr=hr;class yt extends Je{constructor(){super(...arguments),k(this,"always_accept",[])}process(t){return t}}class mr extends N{constructor(t){super(),k(this,"OPTIONS_DOC",'\n **=== General Options ===**\n\n start\n The start symbol. Either a string, or a list of strings for multiple possible starts (Default: "start")\n debug\n Display debug information and extra warnings. Use only when debugging (Default: ``False``)\n When used with Earley, it generates a forest graph as "sppf.png", if \'dot\' is installed.\n transformer\n Applies the transformer to every parse tree (equivalent to applying it after the parse, but faster)\n propagate_positions\n Propagates (line, column, end_line, end_column) attributes into all tree branches.\n Accepts ``False``, ``True``, or a callable, which will filter which nodes to ignore when propagating.\n maybe_placeholders\n When ``True``, the ``[]`` operator returns ``None`` when not matched.\n When ``False``, ``[]`` behaves like the ``?`` operator, and returns no value at all.\n (default= ``True``)\n cache\n Cache the results of the Lark grammar analysis, for x2 to x3 faster loading. LALR only for now.\n\n - When ``False``, does nothing (default)\n - When ``True``, caches to a temporary file in the local directory\n - When given a string, caches to the path pointed by the string\n regex\n When True, uses the ``regex`` module instead of the stdlib ``re``.\n g_regex_flags\n Flags that are applied to all terminals (both regex and strings)\n keep_all_tokens\n Prevent the tree builder from automagically removing "punctuation" tokens (Default: ``False``)\n tree_class\n Lark will produce trees comprised of instances of this class instead of the default ``lark.Tree``.\n\n **=== Algorithm Options ===**\n\n parser\n Decides which parser engine to use. Accepts "earley" or "lalr". (Default: "earley").\n (there is also a "cyk" option for legacy)\n lexer\n Decides whether or not to use a lexer stage\n\n - "auto" (default): Choose for me based on the parser\n - "basic": Use a basic lexer\n - "contextual": Stronger lexer (only works with parser="lalr")\n - "dynamic": Flexible and powerful (only with parser="earley")\n - "dynamic_complete": Same as dynamic, but tries *every* variation of tokenizing possible.\n ambiguity\n Decides how to handle ambiguity in the parse. Only relevant if parser="earley"\n\n - "resolve": The parser will automatically choose the simplest derivation\n (it chooses consistently: greedy for tokens, non-greedy for rules)\n - "explicit": The parser will return all derivations wrapped in "_ambig" tree nodes (i.e. a forest).\n - "forest": The parser will return the root of the shared packed parse forest.\n\n **=== Misc. / Domain Specific Options ===**\n\n postlex\n Lexer post-processing (Default: ``None``) Only works with the basic and contextual lexers.\n priority\n How priorities should be evaluated - "auto", ``None``, "normal", "invert" (Default: "auto")\n lexer_callbacks\n Dictionary of callbacks for the lexer. May alter tokens during lexing. Use with caution.\n use_bytes\n Accept an input of type ``bytes`` instead of ``str``.\n edit_terminals\n A callback for editing the terminals before parse.\n import_paths\n A List of either paths or loader functions to specify from where grammars are imported\n source_path\n Override the source of from where the grammar was loaded. Useful for relative imports and unconventional grammar loading\n **=== End of Options ===**\n '),k(this,"_defaults",{debug:!1,keep_all_tokens:!1,tree_class:null,cache:!1,postlex:null,parser:"earley",lexer:"auto",transformer:null,start:"start",priority:"auto",ambiguity:"auto",regex:!1,propagate_positions:!1,lexer_callbacks:{},maybe_placeholders:!0,edit_terminals:null,g_regex_flags:"",use_bytes:!1,import_paths:[],source_path:null,_plugins:null});let n,i=tt(t),s=this;for(const[a,o]of x(this._defaults))a in i?(n=yn(i,a),typeof o=="boolean"&&!["cache","use_bytes","propagate_positions"].includes(a)&&(n=nt(n))):n=o,s[a]=n;if(typeof s.start=="string"&&(s.start=[s.start]),this.options=s,ve(this.parser,["earley","lalr","cyk",null]),this.parser==="earley"&&this.transformer)throw new A("Cannot specify an embedded transformer when using the Earley algorithm. Please use your transformer on the resulting parse tree, or use a different algorithm (i.e. LALR)");if(Object.keys(i).length)throw new A(h("Unknown options: %s",fe(i)))}serialize(t){return this.options}static deserialize(t,n){const i=this;return new i(t)}}class gt extends N{static get __serialize_fields__(){return["parser","rules","options"]}_build_lexer(t=!1){let n=this.lexer_conf;return t&&(n=I(n),n.ignore=[]),new ce(n)}_prepare_callbacks(){this._callbacks=new Map,this.options.ambiguity!=="forest"&&(this._parse_tree_builder=new nr(this.rules,this.options.tree_class||gn(g),this.options.propagate_positions,this.options.parser!=="lalr"&&this.options.ambiguity==="explicit",this.options.maybe_placeholders),this._callbacks=this._parse_tree_builder.create_callback(this.options.transformer)),Ke(this._callbacks,cr(this.options.transformer,this.terminals))}_deserialize_lexer_conf(t,n,i){let s=lt.deserialize(t.lexer_conf,n);return s.callbacks=i.lexer_callbacks||{},s.re_module=i.regex?regex:Ve,s.use_bytes=i.use_bytes,s.g_regex_flags=i.g_regex_flags||"",s.skip_validation=!0,s.postlex=i.postlex,s}_load({f:t,...n}={}){let i;ge(t)?i=t:i=pickle.load(t);let s=i.memo,a=i.data,o=In.deserialize(s,{Rule:V,TerminalDef:le},{}),l=tt(a.options);return Ke(l,n),this.options=mr.deserialize(l,o),this.rules=a.rules.map(c=>V.deserialize(c,o)),this.source_path="<deserialized>",_r(this.options.parser,this.options.lexer),this.lexer_conf=this._deserialize_lexer_conf(a.parser,o,this.options),this.terminals=this.lexer_conf.terminals,this._prepare_callbacks(),this._terminals_dict=Object.fromEntries(this.terminals.map(c=>[c.name,c])),this.parser=or(a.parser,o,this.lexer_conf,this._callbacks,this.options),this}static _load_from_dict({data:t,memo:n,...i}={}){return ye(this)._load({f:{data:t,memo:n},...i})}repr(){return h("Lark(open(%r), parser=%r, lexer=%r, ...)",this.source_path,this.options.parser,this.options.lexer)}lex(t,n=!1){let i;!("lexer"in this)||n?i=this._build_lexer(n):i=this.lexer;let s=ot.from_text(i,t).lex(null);return this.options.postlex?this.options.postlex.process(s):s}get_terminal(t){return this._terminals_dict[t]}parse_interactive(t=null,n=null){return this.parser.parse_interactive({unknown_param_0:t,start:n})}parse(t,n=null,i=null){return this.parser.parse(t,n,i)}}class xt extends S{}class wt extends yt{constructor(){super(),this.paren_level=0,this.indent_level=[0]}*handle_NL(t){if(this.paren_level>0)return;yield t;let n=we(t.value,`
21
- `,1)[1],i=Te(n," ")+Te(n," ")*this.tab_len;if(i>E(this.indent_level))this.indent_level.push(i),yield f.new_borrow_pos(this.INDENT_type,n,t);else{for(;i<E(this.indent_level);)this.indent_level.pop(),yield f.new_borrow_pos(this.DEDENT_type,n,t);if(i!==E(this.indent_level))throw new xt(h("Unexpected dedent to column %s. Expected dedent to %s",i,E(this.indent_level)))}}*_process(t){for(const n of t)n.type===this.NL_type?yield*this.handle_NL(n):yield n,this.OPEN_PAREN_types.includes(n.type)?this.paren_level+=1:this.CLOSE_PAREN_types.includes(n.type)&&(this.paren_level-=1);for(;this.indent_level.length>1;)this.indent_level.pop(),yield new f(this.DEDENT_type,"")}process(t){return this.paren_level=0,this.indent_level=[0],this._process(t)}get always_accept(){return[this.NL_type]}get NL_type(){throw new NotImplementedError}get OPEN_PAREN_types(){throw new NotImplementedError}get CLOSE_PAREN_types(){throw new NotImplementedError}get INDENT_type(){throw new NotImplementedError}get DEDENT_type(){throw new NotImplementedError}get tab_len(){throw new NotImplementedError}}class fr extends wt{static get NL_type(){return"_NEWLINE"}get NL_type(){return this.constructor.NL_type}static get OPEN_PAREN_types(){return["LPAR","LSQB","LBRACE"]}get OPEN_PAREN_types(){return this.constructor.OPEN_PAREN_types}static get CLOSE_PAREN_types(){return["RPAR","RSQB","RBRACE"]}get CLOSE_PAREN_types(){return this.constructor.CLOSE_PAREN_types}static get INDENT_type(){return"_INDENT"}get INDENT_type(){return this.constructor.INDENT_type}static get DEDENT_type(){return"_DEDENT"}get DEDENT_type(){return this.constructor.DEDENT_type}static get tab_len(){return 8}get tab_len(){return this.constructor.tab_len}}const yr={Terminal:Re,NonTerminal:ke,RuleOptions:oe,PatternStr:qe,PatternRE:Oe,TerminalDef:le};var gr={LarkError:S,ConfigurationError:A,GrammarError:se,ParseError:Nn,LexError:Y,UnexpectedInput:z,UnexpectedEOF:Rn,UnexpectedCharacters:U,UnexpectedToken:F,VisitError:be,Meta:st,Tree:g,Discard:ne,Transformer:K,Transformer_InPlace:at,Transformer_NonRecursive:qn,Transformer_InPlaceRecursive:On,VisitorBase:Ee,Visitor:Sn,Visitor_Recursive:An,Interpreter:$n,Symbol:Ne,Terminal:Re,NonTerminal:ke,RuleOptions:oe,Rule:V,Pattern:Ie,PatternStr:qe,PatternRE:Oe,TerminalDef:le,Token:f,Lexer:_e,LexerConf:lt,ParserConf:_t,InteractiveParser:P,ImmutableInteractiveParser:dt,PostLex:yt,Lark:gt,DedentError:xt,Indenter:wt,PythonIndenter:fr,get_parser:mn},xr={parser:{lexer_conf:{terminals:[{"@":0},{"@":1},{"@":2},{"@":3},{"@":4},{"@":5},{"@":6},{"@":7},{"@":8},{"@":9},{"@":10},{"@":11},{"@":12},{"@":13},{"@":14},{"@":15},{"@":16},{"@":17},{"@":18},{"@":19},{"@":20}],ignore:["WS"],g_regex_flags:0,use_bytes:!1,lexer_type:"contextual",__type__:"LexerConf"},parser_conf:{rules:[{"@":21},{"@":22},{"@":23},{"@":24},{"@":25},{"@":26},{"@":27},{"@":28},{"@":29},{"@":30},{"@":31},{"@":32},{"@":33},{"@":34},{"@":35},{"@":36},{"@":37},{"@":38},{"@":39},{"@":40},{"@":41},{"@":42},{"@":43},{"@":44},{"@":45},{"@":46},{"@":47},{"@":48},{"@":49},{"@":50},{"@":51},{"@":52},{"@":53},{"@":54}],start:["start"],parser_type:"lalr",__type__:"ParserConf"},parser:{tokens:{0:"$END",1:"RPAR",2:"LSQB",3:"DOT",4:"question_selector",5:"IDENTIFIER",6:"OPERATOR",7:"CONJUNCTION",8:"__ANON_3",9:"__ANON_1",10:"qc_mc_text",11:"FALSE",12:"bool_expr",13:"__ANON_0",14:"__ANON_2",15:"__ANON_5",16:"qc_mc_count",17:"qc_matrix_selected",18:"condition",19:"qc_selected_value",20:"bool_const",21:"qc_matrix_count",22:"NEGATION",23:"__ANON_4",24:"TRUE",25:"qc_mc_selected",26:"qc_mc_text_ignore_case",27:"__ANON_6",28:"INT",29:"RSQB",30:"matrix_statement_selector",31:"matrix_choice_selector",32:"mc_choice_selector",33:"STRING",34:"question_or_matrix_statement_selector",35:"top_level_expr",36:"LPAR",37:"start"},states:{0:{0:[1,{"@":22}]},1:{1:[1,{"@":45}],2:[1,{"@":45}],3:[1,{"@":45}]},2:{2:[1,{"@":48}],1:[1,{"@":48}]},3:{1:[0,10]},4:{1:[0,9]},5:{4:[0,8],5:[0,1]},6:{2:[0,50]},7:{},8:{1:[0,57]},9:{6:[0,65]},10:{1:[1,{"@":42}],0:[1,{"@":42}],7:[1,{"@":42}]},11:{8:[0,66],9:[0,35],10:[0,44],11:[0,63],12:[0,49],13:[0,56],14:[0,54],15:[0,34],16:[0,75],17:[0,68],18:[0,78],19:[0,69],20:[0,36],21:[0,71],22:[0,80],23:[0,5],24:[0,43],25:[0,39],26:[0,51]},12:{0:[1,{"@":24}]},13:{6:[0,70]},14:{2:[0,77],3:[0,28]},15:{3:[0,28],1:[1,{"@":51}]},16:{1:[1,{"@":41}],0:[1,{"@":41}],7:[1,{"@":41}]},17:{27:[0,73]},18:{1:[1,{"@":52}]},19:{8:[0,66],9:[0,35],10:[0,44],11:[0,63],25:[0,39],12:[0,27],13:[0,56],14:[0,54],15:[0,34],16:[0,75],17:[0,68],18:[0,78],19:[0,69],21:[0,71],22:[0,80],23:[0,5],24:[0,43],26:[0,51],20:[0,36]},20:{27:[0,13]},21:{6:[0,47]},22:{6:[0,23]},23:{28:[0,60]},24:{1:[0,16]},25:{2:[0,77]},26:{0:[1,{"@":21}]},27:{1:[0,29]},28:{5:[0,2]},29:{7:[0,81],0:[1,{"@":23}]},30:{1:[0,22]},31:{1:[0,21]},32:{29:[0,64]},33:{1:[0,52]},34:{5:[0,1],4:[0,76]},35:{30:[0,6],5:[0,1],4:[0,14],31:[0,3],32:[0,41]},36:{1:[1,{"@":27}],0:[1,{"@":27}],7:[1,{"@":27}]},37:{29:[0,53]},38:{1:[1,{"@":40}],0:[1,{"@":40}],7:[1,{"@":40}]},39:{1:[1,{"@":29}],0:[1,{"@":29}],7:[1,{"@":29}]},40:{1:[1,{"@":43}],0:[1,{"@":43}],7:[1,{"@":43}]},41:{1:[0,61]},42:{28:[0,40]},43:{1:[1,{"@":53}],0:[1,{"@":53}],7:[1,{"@":53}]},44:{1:[1,{"@":30}],0:[1,{"@":30}],7:[1,{"@":30}]},45:{1:[1,{"@":50}]},46:{1:[1,{"@":39}],0:[1,{"@":39}],7:[1,{"@":39}]},47:{33:[0,48]},48:{1:[1,{"@":38}],0:[1,{"@":38}],7:[1,{"@":38}]},49:{0:[1,{"@":26}],1:[1,{"@":26}]},50:{5:[0,55],28:[0,62]},51:{1:[1,{"@":31}],0:[1,{"@":31}],7:[1,{"@":31}]},52:{1:[1,{"@":36}],0:[1,{"@":36}],7:[1,{"@":36}]},53:{1:[1,{"@":47}]},54:{4:[0,25],32:[0,31],5:[0,1]},55:{29:[0,45]},56:{4:[0,15],5:[0,1],30:[0,18],34:[0,30]},57:{6:[0,58]},58:{28:[0,38]},59:{28:[0,17],5:[0,20]},60:{1:[1,{"@":35}],0:[1,{"@":35}],7:[1,{"@":35}]},61:{1:[1,{"@":37}],0:[1,{"@":37}],7:[1,{"@":37}]},62:{29:[0,79]},63:{1:[1,{"@":54}],0:[1,{"@":54}],7:[1,{"@":54}]},64:{1:[1,{"@":46}]},65:{33:[0,46]},66:{4:[0,25],32:[0,4],5:[0,1]},67:{30:[0,6],5:[0,1],4:[0,14],32:[0,33],31:[0,24]},68:{1:[1,{"@":33}],0:[1,{"@":33}],7:[1,{"@":33}]},69:{1:[1,{"@":28}],0:[1,{"@":28}],7:[1,{"@":28}]},70:{28:[0,74]},71:{1:[1,{"@":34}],0:[1,{"@":34}],7:[1,{"@":34}]},72:{8:[0,66],35:[0,26],9:[0,35],10:[0,44],11:[0,63],36:[0,19],25:[0,39],13:[0,56],14:[0,54],15:[0,34],16:[0,75],17:[0,68],18:[0,78],19:[0,69],37:[0,7],12:[0,0],21:[0,71],22:[0,80],23:[0,5],24:[0,43],26:[0,51],20:[0,36]},73:{6:[0,42]},74:{1:[1,{"@":44}],0:[1,{"@":44}],7:[1,{"@":44}]},75:{1:[1,{"@":32}],0:[1,{"@":32}],7:[1,{"@":32}]},76:{2:[0,59]},77:{28:[0,32],5:[0,37]},78:{7:[0,11],0:[1,{"@":25}],1:[1,{"@":25}]},79:{1:[1,{"@":49}]},80:{9:[0,67]},81:{35:[0,12],36:[0,19]}},start_states:{start:72},end_states:{start:7}},__type__:"ParsingFrontend"},rules:[{"@":21},{"@":22},{"@":23},{"@":24},{"@":25},{"@":26},{"@":27},{"@":28},{"@":29},{"@":30},{"@":31},{"@":32},{"@":33},{"@":34},{"@":35},{"@":36},{"@":37},{"@":38},{"@":39},{"@":40},{"@":41},{"@":42},{"@":43},{"@":44},{"@":45},{"@":46},{"@":47},{"@":48},{"@":49},{"@":50},{"@":51},{"@":52},{"@":53},{"@":54}],options:{debug:!1,keep_all_tokens:!1,tree_class:null,cache:!1,postlex:null,parser:"lalr",lexer:"contextual",transformer:null,start:["start"],priority:"normal",ambiguity:"auto",regex:!1,propagate_positions:!1,lexer_callbacks:{},maybe_placeholders:!1,edit_terminals:null,g_regex_flags:0,use_bytes:!1,import_paths:[],source_path:null,_plugins:{}},__type__:"Lark"},wr={0:{name:"WS",pattern:{value:`(?:[ \f\r
22
- ])+`,flags:[],_width:[1,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},1:{name:"IDENTIFIER",pattern:{value:"[a-zA-Z][a-zA-Z0-9_]*[a-zA-Z0-9]",flags:[],_width:[2,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},2:{name:"INT",pattern:{value:"-?[0-9]+",flags:[],_width:[1,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},3:{name:"STRING",pattern:{value:`(?:'[^\\']*'|"[^"]*")`,flags:[],_width:[2,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},4:{name:"OPERATOR",pattern:{value:"(?:regex_matches|not_contains|contains|==|!=|<=|>=|<|>)",flags:[],_width:[1,13],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},5:{name:"CONJUNCTION",pattern:{value:"(?:and|or)",flags:[],_width:[2,3],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},6:{name:"NEGATION",pattern:{value:"!",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},7:{name:"TRUE",pattern:{value:"true",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},8:{name:"FALSE",pattern:{value:"false",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},9:{name:"LPAR",pattern:{value:"(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},10:{name:"RPAR",pattern:{value:")",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},11:{name:"__ANON_0",pattern:{value:"selected_value(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},12:{name:"__ANON_1",pattern:{value:"selected(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},13:{name:"__ANON_2",pattern:{value:"text(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},14:{name:"__ANON_3",pattern:{value:"text_ignore_case(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},15:{name:"__ANON_4",pattern:{value:"count_selected(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},16:{name:"__ANON_5",pattern:{value:"count_choice_selections(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},17:{name:"LSQB",pattern:{value:"[",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},18:{name:"__ANON_6",pattern:{value:"])",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},19:{name:"RSQB",pattern:{value:"]",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},20:{name:"DOT",pattern:{value:".",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},21:{origin:{name:"start",__type__:"NonTerminal"},expansion:[{name:"top_level_expr",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},22:{origin:{name:"start",__type__:"NonTerminal"},expansion:[{name:"bool_expr",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},23:{origin:{name:"top_level_expr",__type__:"NonTerminal"},expansion:[{name:"LPAR",filter_out:!0,__type__:"Terminal"},{name:"bool_expr",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},24:{origin:{name:"top_level_expr",__type__:"NonTerminal"},expansion:[{name:"LPAR",filter_out:!0,__type__:"Terminal"},{name:"bool_expr",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"CONJUNCTION",filter_out:!1,__type__:"Terminal"},{name:"top_level_expr",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},25:{origin:{name:"bool_expr",__type__:"NonTerminal"},expansion:[{name:"condition",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},26:{origin:{name:"bool_expr",__type__:"NonTerminal"},expansion:[{name:"condition",__type__:"NonTerminal"},{name:"CONJUNCTION",filter_out:!1,__type__:"Terminal"},{name:"bool_expr",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},27:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"bool_const",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},28:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_selected_value",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},29:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_selected",__type__:"NonTerminal"}],order:2,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},30:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_text",__type__:"NonTerminal"}],order:3,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},31:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_text_ignore_case",__type__:"NonTerminal"}],order:4,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},32:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_count",__type__:"NonTerminal"}],order:5,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},33:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_matrix_selected",__type__:"NonTerminal"}],order:6,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},34:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_matrix_count",__type__:"NonTerminal"}],order:7,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},35:{origin:{name:"qc_selected_value",__type__:"NonTerminal"},expansion:[{name:"__ANON_0",filter_out:!0,__type__:"Terminal"},{name:"question_or_matrix_statement_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},36:{origin:{name:"qc_mc_selected",__type__:"NonTerminal"},expansion:[{name:"NEGATION",filter_out:!1,__type__:"Terminal"},{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},37:{origin:{name:"qc_mc_selected",__type__:"NonTerminal"},expansion:[{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},38:{origin:{name:"qc_mc_text",__type__:"NonTerminal"},expansion:[{name:"__ANON_2",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"STRING",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},39:{origin:{name:"qc_mc_text_ignore_case",__type__:"NonTerminal"},expansion:[{name:"__ANON_3",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"STRING",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},40:{origin:{name:"qc_mc_count",__type__:"NonTerminal"},expansion:[{name:"__ANON_4",filter_out:!0,__type__:"Terminal"},{name:"question_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},41:{origin:{name:"qc_matrix_selected",__type__:"NonTerminal"},expansion:[{name:"NEGATION",filter_out:!1,__type__:"Terminal"},{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"matrix_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},42:{origin:{name:"qc_matrix_selected",__type__:"NonTerminal"},expansion:[{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"matrix_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},43:{origin:{name:"qc_matrix_count",__type__:"NonTerminal"},expansion:[{name:"__ANON_5",filter_out:!0,__type__:"Terminal"},{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"},{name:"__ANON_6",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},44:{origin:{name:"qc_matrix_count",__type__:"NonTerminal"},expansion:[{name:"__ANON_5",filter_out:!0,__type__:"Terminal"},{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"},{name:"__ANON_6",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},45:{origin:{name:"question_selector",__type__:"NonTerminal"},expansion:[{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},46:{origin:{name:"mc_choice_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},47:{origin:{name:"mc_choice_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},48:{origin:{name:"matrix_statement_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"},{name:"DOT",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},49:{origin:{name:"matrix_choice_selector",__type__:"NonTerminal"},expansion:[{name:"matrix_statement_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},50:{origin:{name:"matrix_choice_selector",__type__:"NonTerminal"},expansion:[{name:"matrix_statement_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},51:{origin:{name:"question_or_matrix_statement_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},52:{origin:{name:"question_or_matrix_statement_selector",__type__:"NonTerminal"},expansion:[{name:"matrix_statement_selector",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},53:{origin:{name:"bool_const",__type__:"NonTerminal"},expansion:[{name:"TRUE",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},54:{origin:{name:"bool_const",__type__:"NonTerminal"},expansion:[{name:"FALSE",filter_out:!1,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"}};const Tr="(?<questionId>[a-zA-Z][a-zA-Z0-9_]*)",vr="((?<expressionWithoutIdentifier>all|all_entered_text|selected|selected_entered_text|not_selected)|(?<expressionWithIdentifier>for_matrix_choice|unselected_for_matrix_choice)(\\((?<identifier>[\\-a-zA-Z0-9_]+)\\)))",Tt=new RegExp(`^${Tr}/${vr}$`);var T=(r=>(r.ALL="all",r.ALL_ENTERED_TEXT="all_entered_text",r.SELECTED="selected",r.SELECTED_ENTERED_TEXT="selected_entered_text",r.NOT_SELECTED="not_selected",r.FOR_MATRIX_CHOICE="for_matrix_choice",r.UNSELECTED_FOR_MATRIX_CHOICE="unselected_for_matrix_choice",r))(T||{});const vt=r=>Tt.test(r),L=r=>{var t;const n=(t=r.match(Tt))==null?void 0:t.groups;if(!n)throw new Error(`Invalid locator expression: ${r}`);const i=n.expressionWithoutIdentifier||n.expressionWithIdentifier||"all",s={questionId:n.questionId,expression:i};if(n.identifier){const a=isNaN(parseInt(n.identifier,10))?n.identifier:parseInt(n.identifier,10);s.identifier=a}return s},pe=(r,t="camelCase")=>{const n=t==="camelCase"?te.default.camelCase:te.default.snakeCase;return te.default.transform(r,(i,s,a)=>{const o=typeof a=="string"?n(a):a;i[o]=te.default.isObject(s)?pe(s,t):s})};function br(r){const t=structuredClone(r);return{...t,...t.template,templateId:t.template.id,sections:t.sections.map(n=>({...pe(n),pages:n.pages.map((i,s)=>({...i,id:`${n.id}-${s}`,questions:Er(t,n,i.questions)}))}))}}function Er(r,t,n){return n.map(i=>Nr(r.template.id,t,i))}function Nr(r,t,n){var i,s;return{...pe({...n,choiceGroups:(i=n.choice_groups)==null?void 0:i.map(a=>({...a,randomization:$e(a.randomization)})),statementGroups:(s=n.statement_groups)==null?void 0:s.map(a=>({...a,randomization:$e(a.randomization)})),randomization:$e(n.randomization)}),id:Et(r,n),type:Nt(n.type),layout:Rr(n.layout),required:kr(n.required),label:t.name}}function $e(r){var t;return r?{type:bt(r.type),order:(t=r.order)==null?void 0:t.split(" "),total:r.total}:void 0}function bt(r){return r.toUpperCase()}function Et(r,t){return`${r}.${t.id}`}const ze=r=>r.split(".").pop();function Nt(r="description"){return r.replace("-","_").toUpperCase()}function Rr(r){return r==null?void 0:r.toUpperCase()}function kr(r="optional"){return r.replace("-","_").toUpperCase()}function Rt(r){return structuredClone(r).sections.flatMap(t=>t.pages.flatMap(n=>n.questions))}var Ir=Object.defineProperty,qr=(r,t,n)=>t in r?Ir(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,Z=(r,t,n)=>(qr(r,typeof t!="symbol"?t+"":t,n),n),Or=(r,t,n)=>{if(!t.has(r))throw TypeError("Cannot "+n)},kt=(r,t,n)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,n)},C=(r,t,n)=>(Or(r,t,"access private method"),n),Q,B,ue,Pe;const De=/\$\{q\:(?<locator>[\-a-zA-Z0-9_\/\(\)]+)\}/g,It=r=>{var t,n;return(n=(t=r.choiceId)!=null?t:r.choiceValue)!=null?n:r.text};class Sr{constructor(t,n=[],i="",s=!1){kt(this,Q),kt(this,ue),Z(this,"questions",new Map),Z(this,"responsesByQuestion",new Map),Z(this,"responsesByQuestionStatement",new Map),Z(this,"hashSalt"),Z(this,"forExport"),Z(this,"evaluationCache",new Map),this.questions=new Map((t?Rt(t):[]).filter(a=>a.id).map(a=>[ze(a.id),a])),n.filter(a=>a.singleAnswer||a.multipleAnswers).forEach(a=>{const o=ze(a.questionId);this.responsesByQuestion.set(o,[...this.responsesByQuestion.get(o)||[],a]),a.statementId&&this.responsesByQuestionStatement.set(`${o}.${a.statementId}`,a)}),this.hashSalt=i,this.forExport=s}evaluateDisplayLogic(t){if(t&&!this.forExport)try{const n=this.evaluationCache.get(t);if(n!==void 0)return n;const i=Ce(t,this);return this.evaluationCache.set(t,i),i}catch(n){return console.error(n),!1}return!0}evaluateDynamicExpression(t,n){const i=this.questions.get(t.questionId);if(!i)return[];const s=this.getQuestionChoicesFlattened(i),a=s.filter(p=>this.isSelected({questionId:t.questionId,choice:p.id||p.value})),o=this.getQuestionStatementsFlattened(i),l=p=>n==="choices"?p:{...p,id:p.id||p.value||p.display},c=p=>({id:p.id,display:p.display,value:p.value});let _=[];switch(t.expression){case T.ALL:_=s.map(l);break;case T.ALL_ENTERED_TEXT:_=s.map(p=>l(C(this,ue,Pe).call(this,p,t)));break;case T.SELECTED:_=a;break;case T.SELECTED_ENTERED_TEXT:_=a.map(p=>l(C(this,ue,Pe).call(this,p,t)));break;case T.NOT_SELECTED:_=s.filter(p=>!this.isSelected({questionId:t.questionId,choice:p.id||p.value})).map(l);break;case T.FOR_MATRIX_CHOICE:_=o.filter(p=>this.isSelected({questionId:t.questionId,statementId:p.id,choice:t.identifier}));break;case T.UNSELECTED_FOR_MATRIX_CHOICE:_=o.filter(p=>!this.isSelected({questionId:t.questionId,statementId:p.id,choice:t.identifier}));break;default:_=[]}return this.forExport&&(_=t.expression===T.FOR_MATRIX_CHOICE||t.expression===T.UNSELECTED_FOR_MATRIX_CHOICE?o:s.map(l)),_.map(c)}isSelected(t){return!!C(this,Q,B).call(this,t.questionId,t.statementId,t.choice).length}countSelected(t){return C(this,Q,B).call(this,t).length}selectedValue(t){const n=C(this,Q,B).call(this,t.questionId,t.statementId);return n.length?It(n[0]):0}countChoiceSelections(t,n){return C(this,Q,B).call(this,t,null,n).length}textEntry(t){return C(this,Q,B).call(this,t.questionId,t.statementId,t.choice).map(n=>n.text).filter(n=>n).join(", ")}getQuestionText(t){let n=t.text;return n=n.replaceAll(De,(i,s)=>{if(s&&vt(s)){const a=L(s);return this.evaluateDynamicExpression(a,"choices").map(o=>o.display).join(", ")}return i}),n}getQuestionChoices(t){var n;const i=((n=t.choices)!=null?n:[]).filter(s=>this.evaluateDisplayLogic(s.displayLogic));if(t.dynamicChoices){const s=L(t.dynamicChoices),a=this.evaluateDynamicExpression(s,"choices");i.push(...a)}return t.type===me.MatrixSingle||t.type===me.MatrixMulti?i:this.applyRandomization(i,t.id,s=>{var a;return`${(a=s.id)!=null?a:s.value}`},t.randomization)}getQuestionChoiceGroups(t){var n;const i=(((n=t.choiceGroups)==null?void 0:n.filter(s=>this.evaluateDisplayLogic(s.displayLogic)))||[]).map(s=>({...s,choices:this.applyRandomization(s.choices.filter(a=>this.evaluateDisplayLogic(a.displayLogic)),t.id,a=>{var o;return`${(o=a.id)!=null?o:a.value}`},s.randomization)})).filter(s=>!!s.choices.length);return this.applyRandomization(i,t.id,s=>s.id,t.randomization)}getQuestionStatements(t){var n;const i=((n=t.statements)!=null?n:[]).filter(s=>this.evaluateDisplayLogic(s.displayLogic));if(t.dynamicStatements){const s=L(t.dynamicStatements),a=this.evaluateDynamicExpression(s,"statements");i.push(...a)}return this.applyRandomization(i,t.id,s=>s.id,t.randomization)}getQuestionStatementGroups(t){var n;const i=(((n=t.statementGroups)==null?void 0:n.filter(s=>this.evaluateDisplayLogic(s.displayLogic)))||[]).map(s=>({...s,statements:this.applyRandomization(s.statements.filter(a=>this.evaluateDisplayLogic(a.displayLogic)),t.id,a=>a.id,s.randomization)})).filter(s=>!!s.statements.length);return this.applyRandomization(i,t.id,s=>s.id,t.randomization)}getQuestionChoicesFlattened(t){return[...this.getQuestionChoices(t),...this.getQuestionChoiceGroups(t).flatMap(n=>n.choices)]}getQuestionStatementsFlattened(t){return[...this.getQuestionStatements(t),...this.getQuestionStatementGroups(t).flatMap(n=>n.statements)]}applyRandomization(t,n,i,s){var a,o;if(!s)return t;const l=new Map(t.map(d=>[i(d),d])),c=[...l.keys()],_=new Set(c),p=((a=s.order)!=null?a:["$"]).filter(d=>d==="$"||_.has(d)),y=c.filter(d=>!p.includes(d)).map(d=>({weight:this.keyHash(n,d),key:d}));y.sort((d,m)=>d.weight.localeCompare(m.weight));const v=(o=s.total)!=null?o:c.length,w=Math.min(v-(p.length-1),y.length),u=[];return p.forEach(d=>{d==="$"?u.push(...y.slice(0,w).map(m=>m.key)):u.push(d)}),u.map(d=>l.get(d))}keyHash(t,n){const i=`${t}.${this.hashSalt}.${n}`;return Wt.createHash("sha256").update(i).digest("hex")}}Q=new WeakSet,B=function(r,t,n){let i;if(t){const s=this.responsesByQuestionStatement.get(`${r}.${t}`);i=s===void 0?[]:[s]}else i=this.responsesByQuestion.get(r)||[];return i.flatMap(s=>{const{multipleAnswers:a,singleAnswer:o}=s;return(a||[o]).filter(l=>typeof n=="undefined"||n===null||It(l)===n)})},ue=new WeakSet,Pe=function(r,t){if(r.textInput&&["forced","optional"].includes(r.textInput)){const n=this.textEntry({questionId:t.questionId,choice:r.id||r.value});return{...r,display:n}}return r};function qt(r){if(r.length===1)return r[0];const t=r[1].value;return t==="or"?r[0]||r[2]:t==="and"?r[0]&&r[2]:!1}function de(r,t,n){switch(t){case"==":return r===n;case"!=":return r!==n;case"<=":return r<=n;case">=":return r>=n;case"<":return r<n;case">":return r>n;default:return!1}}function Ot(r,t,n,i){const s=i?r.toLowerCase():r,a=i?n.toLowerCase():n;switch(t){case"contains":return s.includes(a);case"not_contains":return!s.includes(a);case"regex_matches":try{return new RegExp(n).test(s)}catch{return!1}default:return de(s,t,a)}}function St(r,t){return r.length===1?t(r[0]):(Fe.default(r[0].type==="NEGATION"),!t(r[1]))}function Le(r){if(!["INT","IDENTIFIER"].includes(r.type))throw new SyntaxError(`Invalid token type: ${r.type}; expected IDENTIFIER or INT`);return R(r)}function R(r){var t,n;switch(r.type){case"IDENTIFIER":return r.value;case"INT":return parseInt(r.value,10);case"STRING":{const i=r.value.match(/(?:'(?<single>[^\']*)')|(?:"(?<double>[^\"]*)")/),s=((t=i==null?void 0:i.groups)==null?void 0:t.double)||((n=i==null?void 0:i.groups)==null?void 0:n.single);return Fe.default(s),s}case"OPERATOR":return r.value;case"TRUE":return!0;case"FALSE":return!1;default:throw new SyntaxError(`Invalid token type: ${r.type}`)}}function Ce(r,t){const n={start:i=>i[0],top_level_expr:qt,bool_expr:qt,condition:i=>i[0],qc_mc_selected:i=>St(i,s=>t.isSelected(s)),qc_mc_text:i=>Ot(t.textEntry(i[0]),R(i[1]),R(i[2]),!1),qc_mc_text_ignore_case:i=>Ot(t.textEntry(i[0]),R(i[1]),R(i[2]),!0),qc_mc_count:i=>de(t.countSelected(i[0]),R(i[1]),R(i[2])),qc_matrix_selected:i=>St(i,s=>t.isSelected(s)),qc_selected_value:i=>de(t.selectedValue(i[0]),R(i[1]),R(i[2])),qc_matrix_count:i=>de(t.countChoiceSelections(i[0],Le(i[1])),R(i[2]),R(i[3])),question_selector:i=>i[0].value,question_or_matrix_statement_selector:i=>typeof i[0]=="string"?{questionId:i[0]}:i[0],mc_choice_selector:i=>({questionId:i[0],choice:Le(i[1])}),matrix_statement_selector:i=>({questionId:i[0],statementId:R(i[1])}),matrix_choice_selector:i=>({...i[0],choice:Le(i[1])}),bool_const:i=>i[0].value==="true"};return gr.get_parser({transformer:n}).parse(r)}const Ar=/\$\{m:([^\}]+)\}/g,$r=100,Qe=(r,t)=>{if(typeof t=="string"){let n=t,i=0;for(;i<$r;){const s=n.replace(Ar,(a,o)=>{if(r[o]===void 0)throw new Error(`Undefined macro: ${o}`);return r[o]});if(s===n)return s;n=s,i+=1}throw new Error(`Failed to finish interpolate macros - cyclic macros!? Stuck at: ${t}"`)}return typeof t=="object"&&Object.keys(t).forEach(n=>{t[n]=Qe(r,t[n])}),t},At=r=>(r.sections=Qe(r.macros||{},r.sections),r);var zr=Object.defineProperty,Pr=(r,t,n)=>t in r?zr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,M=(r,t,n)=>(Pr(r,typeof t!="symbol"?t+"":t,n),n);const $t=new Bt.default({allowUnionTypes:!0});Gt.default($t);const zt=$t.compile(Be);class ee extends Error{}class $ extends Error{}class he extends Error{}class j extends Error{}class Dr extends Error{}class Lr{constructor(){M(this,"seenQuestions",new Set),M(this,"seenMultiQuestions",new Set),M(this,"seenQuestionStatements",new Map),M(this,"seenQuestionChoices",new Map),M(this,"seenTextChoices",new Map),M(this,"evaluator",{}),M(this,"validateReference",t=>{var n,i,s;if(!this.seenQuestions.has(t.questionId))throw new ee(`Invalid question: ${t.questionId}`);if(t.statementId!==void 0&&!((n=this.seenQuestionStatements.get(t.questionId))!=null&&n.has(t.statementId)))throw new ee(`Invalid statement: ${t.questionId}.${t.statementId}`);if(t.choice!==void 0&&!((i=this.seenQuestionChoices.get(t.questionId))!=null&&i.has(t.choice)))throw new ee(`Invalid choice: ${t.questionId}[${t.choice}]`);if(t.choice!==void 0&&t.expectText===!0&&!((s=this.seenTextChoices.get(t.questionId))!=null&&s.has(t.choice)))throw new ee(`Invalid text reference: ${t.questionId}[${t.choice}]`);if(typeof t.expectMulti=="boolean"&&t.expectMulti&&!this.seenMultiQuestions.has(t.questionId))throw new $(`Invalid question reference: ${t.questionId}. Expected a multi-answer question.`);if(typeof t.expectMulti=="boolean"&&!t.expectMulti&&this.seenMultiQuestions.has(t.questionId))throw new $(`Invalid question reference: ${t.questionId}. Expected a non-multi-answer question.`)}),this.evaluator.isSelected=t=>(this.validateReference(t),!1),this.evaluator.countSelected=t=>(this.validateReference({questionId:t}),0),this.evaluator.selectedValue=t=>(this.validateReference({questionId:t.questionId,statementId:t.statementId,expectMulti:!1}),0),this.evaluator.countChoiceSelections=(t,n)=>(this.validateReference({questionId:t,choice:n}),0),this.evaluator.textEntry=t=>(this.validateReference({...t,expectText:!0}),"")}}const G=(r,t,n)=>{if(n)try{Ce(n,r.evaluator)}catch(i){throw i instanceof ee||i instanceof $||i instanceof j?i:new Error(`Syntax error parsing display logic at ${t}: ${n}`)}},Cr=(r,t)=>{[...t.matchAll(De)].forEach(n=>{var i;const s=L(n.groups.locator);if(!r.seenQuestions.has(s.questionId))throw new $(`Invalid question referenced in locator expression: ${s.questionId}/${s.expression}`);if(s.identifier&&!((i=r.seenQuestionChoices.get(s.questionId))!=null&&i.has(s.identifier)))throw new $(`Invalid question choice referenced in locator expression: ${s.questionId}/${s.expression}(${s.identifier})`)})},W=(r,t,n)=>{if(n){const i=new Set(t);if(n.order){const s=n.order.split(" "),a=s.filter(o=>o==="$").length;if(a===0)throw new he(`Wildcard $ is missing in randomization order at ${r.id}`);if(a>1)throw new he(`Wildcard $ occurred multiples times in randomization order at ${r.id}`);if(s.forEach(o=>{if(o!=="$"&&!i.has(o))throw new he(`Unknown id ${o} in randomization ordering at ${r.id}`)}),n.total!==void 0&&n.total<s.length)throw new he(`Total value in randomization is too small at ${r.id}`)}}},Pt=(r,t)=>{const n=[T.FOR_MATRIX_CHOICE,T.UNSELECTED_FOR_MATRIX_CHOICE].includes(r.expression),i=(n?t.seenQuestionStatements:t.seenQuestionChoices).get(r.questionId);if(i===void 0)throw new $(`Invalid question referenced in locator expression: ${r.questionId}/${r.expression}`);if(n){const s=t.seenQuestionChoices.get(r.questionId);if(!r.identifier||!(s!=null&&s.has(r.identifier)))throw new $(`Invalid choice referenced in locator expression: ${r.questionId}/${r.expression}(${r.identifier})`)}return i},Qr=(r,t)=>{var n,i,s,a,o,l,c,_,p,y,v;if(Cr(t,r.text),r.id!==void 0){if(G(t,r.id,r.display_logic),(n=r.statements)==null||n.forEach(u=>{G(t,`${r.id}.${u.id}`,u.display_logic)}),(i=r.choices)==null||i.forEach(u=>{G(t,`${r.id}[${u.id||u.value}]`,u.display_logic)}),r.type==="matrix-multi"||r.type==="matrix-single"?r.statement_groups?W(r,r.statement_groups.map(u=>u.id),r.randomization):W(r,(a=(s=r.statements)==null?void 0:s.map(u=>u.id))!=null?a:[],r.randomization):r.choice_groups?W(r,r.choice_groups.map(u=>u.id),r.randomization):W(r,(l=(o=r.choices)==null?void 0:o.map(u=>`${u.id||u.value}`))!=null?l:[],r.randomization),(c=r.statement_groups)==null||c.forEach(u=>{u.statements.forEach(d=>{G(t,`${r.id}.${d.id}`,d.display_logic)}),W(r,u.statements.map(d=>d.id),u.randomization)}),(_=r.choice_groups)==null||_.forEach(u=>{u.choices.forEach(d=>{G(t,`${r.id}[${d.id||d.value}]`,d.display_logic)}),W(r,u.choices.map(d=>`${d.id||d.value}`),u.randomization)}),t.seenQuestions.has(r.id))throw new j(`Duplicate question id: ${r.id}`);if(t.seenQuestions.add(r.id),r.type&&["matrix-multi","mc-multi"].includes(r.type)&&t.seenMultiQuestions.add(r.id),r.statements||r.dynamic_statements){const u=new Set;if(t.seenQuestionStatements.set(r.id,u),(p=r.statements)==null||p.forEach(d=>{if(u.has(d.id))throw new j(`Duplicate statement id: ${r.id}.${d.id}`);u.add(d.id)}),r.dynamic_statements){const d=L(r.dynamic_statements);Pt(d,t).forEach(m=>{if(typeof m=="number")throw new $(`Dynamic statement in question ${r.id} refers to choices with values`);if(u.has(m))throw new j(`Duplicate statement ${m} via dynamic statements in question ${r.id}`);u.add(m)})}}const w=(y=r.choices)!=null?y:[];if(r.choice_groups){if(new Set(r.choice_groups.map(u=>u.id)).size!==r.choice_groups.length)throw new j(`Choice groups must have a unique id in question ${r.id}`);r.choice_groups.forEach(u=>w.push(...u.choices))}if(w||r.dynamic_choices){const u=new Set;t.seenQuestionChoices.set(r.id,u);const d=new Set;if(t.seenTextChoices.set(r.id,d),w.forEach(m=>{var b;const q=(b=m.id)!=null?b:m.value;if(u.has(q))throw new j(`Duplicate choice: ${r.id}[${q}]`);u.add(q),m.text_input&&m.text_input!=="no"&&d.add(q)}),r.dynamic_choices){const m=L(r.dynamic_choices);Pt(m,t).forEach(b=>{if(u.has(b))throw new j(`Duplicate choice ${b} via dynamic choices in ${r.id}`);u.add(b)}),(v=t.seenTextChoices.get(m.questionId))==null||v.forEach(b=>d.add(b))}if(new Set([...u].map(m=>typeof m)).size>=2)throw new Dr("All choices in a question must either all have id's or all have values")}}},Mr=r=>{if(!zt(r))throw new Error(`Invalid template: ${r.template.id}. Reason: ${JSON.stringify(zt.errors,null,4)}`);At(r);const t=new Lr;r.sections.forEach(n=>{G(t,n.id,n.display_logic),n.pages.forEach(i=>{var s;(s=i.questions)==null||s.forEach(a=>{Qr(a,t)})})})};function jr(r,t){const n=structuredClone(r);return{...n,sections:n.sections.map(i=>({id:i.id,name:i.name,hideProgressBar:i.hideProgressBar,pages:t.evaluateDisplayLogic(i.displayLogic)?i.pages.map(s=>({...s,questions:Ur(s.questions,t)})).filter(s=>s.questions.length):[]})).filter(i=>i.pages.length)}}function Ur(r,t){return r.filter(n=>t.evaluateDisplayLogic(n.displayLogic)).map(n=>({...n,text:t.getQuestionText(n),statements:t.getQuestionStatements(n),choices:t.getQuestionChoices(n),statementGroups:t.getQuestionStatementGroups(n),choiceGroups:t.getQuestionChoiceGroups(n),randomization:void 0}))}const Fr=Be,Zr="pulse_default_alpha",Br={allPermissions:Xt,SURVEY_RESOURCE_TYPE:Vt,surveyAdministerPermission:Ze};exports.DEFAULT_TEMPLATE_ID=Zr,exports.LOCATOR_EXPRESSION=T,exports.QUESTION_TEXT_LOCATOR_PATTERN=De,exports.TemplateContextEvaluator=Sr,exports.evaluateExpression=Ce,exports.evaluateTemplateNode=jr,exports.extractQuestionNodes=Rt,exports.getQualifiedQuestionId=Et,exports.getQuestionTypeEnum=Nt,exports.getRandomizationTypeEnum=bt,exports.getRawQuestionId=ze,exports.getTemplateNode=br,exports.interpolateMacros=Qe,exports.interpolateTemplate=At,exports.parseLocator=L,exports.permissions=Br,exports.polyfillStructuredClone=Ht,exports.templateSchema=Fr,exports.transformCase=pe,exports.validateLocator=vt,exports.validateTemplate=Mr;
19
+ `),this.last_token=i}eq(t){return t instanceof je?this.text===t.text&&this.line_ctr===t.line_ctr&&this.last_token===t.last_token:W}}class lt{constructor(t,n){this.lexer=t,this.state=n}static from_text(t,n){return new this(t,new je(n))}lex(t){return this.lexer.lex(this.state,t)}}class le extends Ye{lex(t,n){return W}}function Bn(r,t){r.sort((n,i)=>{let s=t(n),a=t(i);for(let o=0;o<s.length;o++){if(s[o]>a[o])return 1;if(s[o]<a[o])return-1}return 0})}class _e extends le{constructor(t){super();let n=[...t.terminals];if(this.re=t.re_module,!t.skip_validation){for(const i of n){try{this.re.compile(i.pattern.to_regexp(),t.g_regex_flags)}catch(s){throw s instanceof this.re.error?new X(h("Cannot compile token %s: %s",i.name,i.pattern)):s}if(i.pattern.min_width===0)throw new X(h("Lexer does not allow zero-width terminals. (%s: %s)",i.name,i.pattern))}if(!(new Set(t.ignore)<=new Set(n.map(i=>i.name))))throw new X(h("Ignore terminals are not defined: %s",tt(new Set(t.ignore),new Set(n.map(i=>i.name)))))}this.newline_types=ne(n.filter(i=>Fn(i.pattern.to_regexp())).map(i=>i.name)),this.ignore_types=ne(t.ignore),Bn(n,i=>[-i.priority,-i.pattern.max_width,-i.pattern.value.length,i.name]),this.terminals=n,this.user_callbacks=t.callbacks,this.g_regex_flags=t.g_regex_flags,this.use_bytes=t.use_bytes,this.terminals_by_name=t.terminals_by_name,this._scanner=null}_build_scanner(){let t;[t,this.callback]=Un(this.terminals,this.g_regex_flags,this.re,this.use_bytes);for(const[n,i]of x(this.user_callbacks))n in this.callback?this.callback[n]=new jn(this.callback[n],i,s=>s.type===n):this.callback[n]=i;this._scanner=new He(t,this.g_regex_flags,this.re,this.use_bytes)}get scanner(){return this._scanner===null&&this._build_scanner(),this._scanner}match(t,n){return this.scanner.match(t,n)}*lex(t,n){try{for(;;)yield this.next_token(t,n)}catch(i){if(!(i instanceof xe))throw i}}next_token(t,n=null){let i,s,a,o,l=t.line_ctr;for(;l.char_pos<t.text.length;){if(s=this.match(t.text,l.char_pos),!s)throw i=tt(this.scanner.allowed_types,this.ignore_types),i||(i=new Set(["<END-OF-FILE>"])),new M({seq:t.text,lex_pos:l.char_pos,line:l.line,column:l.column,allowed:i,token_history:t.last_token&&[t.last_token],state:n,terminals_by_name:this.terminals_by_name});let[c,_]=s;if(this.ignore_types.has(_))_ in this.callback&&(o=new f(_,c,l.char_pos,l.line,l.column),this.callback[_](o)),l.feed(c,this.newline_types.has(_));else{if(a=new f(_,c,l.char_pos,l.line,l.column),l.feed(c,this.newline_types.has(_)),a.end_line=l.line,a.end_column=l.column,a.end_pos=l.char_pos,a.type in this.callback&&(a=this.callback[a.type](a),!(a instanceof f)))throw new X(h("Callbacks must return a token (returned %r)",a));return t.last_token=a,a}}throw new xe(this)}}class Zn extends le{constructor({conf:t,states:n,always_accept:i=[]}={}){super();let s,a,o,l=[...t.terminals],c=t.terminals_by_name,_=I(t);_.terminals=l;let p=new Map;this.lexers={};for(let[y,v]of x(n))s=ne(v),p.has(s)?a=p.get(s):(v=vn(new Set(v),[...new Set(t.ignore),...new Set(i)]),o=I(_),o.terminals=[...v].filter(w=>w in c).map(w=>c[w]),a=new _e(o),p.set(s,a)),this.lexers[y]=a;this.root_lexer=new _e(_)}*lex(t,n){let i,s,a;try{for(;;)s=this.lexers[n.position],yield s.next_token(t,n)}catch(o){if(!(o instanceof xe))if(o instanceof M)try{throw i=t.last_token,a=this.root_lexer.next_token(t,n),new j({token:a,expected:o.allowed,state:n,token_history:[i],terminals_by_name:this.root_lexer.terminals_by_name})}catch(l){throw l}else throw o}}}class _t extends N{static get __serialize_fields__(){return["terminals","ignore","g_regex_flags","use_bytes","lexer_type"]}static get __serialize_namespace__(){return[oe]}constructor({terminals:t,re_module:n,ignore:i=[],postlex:s=null,callbacks:a=null,g_regex_flags:o="",skip_validation:l=!1,use_bytes:c=!1}={}){super(),this.terminals=t,this.terminals_by_name=Object.fromEntries(this.terminals.map(_=>[_.name,_])),this.ignore=i,this.postlex=s,this.callbacks=Object.keys(a).length||{},this.g_regex_flags=o,this.re_module=n,this.skip_validation=l,this.use_bytes=c,this.lexer_type=null}_deserialize(){this.terminals_by_name=Object.fromEntries(this.terminals.map(t=>[t.name,t]))}}class ct extends N{static get __serialize_fields__(){return["rules","start","parser_type"]}constructor(t,n,i){super(),this.rules=t,this.callbacks=n,this.start=i,this.parser_type=null}}class Gn{constructor(t){this.node_builder=t}__call__(t){return t.length===1?t[0]:this.node_builder(t)}}const Wn=D(Gn);class Vn{constructor(t,n=null){this.node_builder=t,this.node_filter=n}__call__(t){let n,i,s,a=this.node_builder(t);return a instanceof g&&(s=a.meta,n=this._pp_get_meta(t),n!==null&&("line"in s||(s.line=n&&n.container_line||n.line,s.column=n&&n.container_column||n.column,s.start_pos=n&&n.container_start_pos||n.start_pos,s.empty=!1),s.container_line=n&&n.container_line||n.line,s.container_column=n&&n.container_column||n.column),i=this._pp_get_meta([...t].reverse()),i!==null&&("end_line"in s||(s.end_line=i&&i.container_end_line||i.end_line,s.end_column=i&&i.container_end_column||i.end_column,s.end_pos=i&&i.container_end_pos||i.end_pos,s.empty=!1),s.container_end_line=i&&i.container_end_line||i.end_line,s.container_end_column=i&&i.container_end_column||i.end_column)),a}_pp_get_meta(t){for(const n of t)if(!(this.node_filter!==null&&!this.node_filter(n))){if(n instanceof g){if(!n.meta.empty)return n.meta}else if(n instanceof f)return n}}}const pt=D(Vn);function Xn(r){if(En(r))return re({unknown_param_0:pt,node_filter:r});if(r===!0)return pt;if(r===!1)return null;throw new S(h("Invalid option for propagate_positions: %r",r))}class Ae{constructor(t,n,i){this.node_builder=i,this.to_include=t,this.append_none=n}__call__(t){let n=[];for(const[i,s,a]of this.to_include)a&&n.push(...O([null],a)),s?n.push(...t[i].children):n.push(t[i]);return this.append_none&&n.push(...O([null],this.append_none)),this.node_builder(n)}}const Hn=D(Ae);class Jn extends Ae{__call__(t){let n=[];for(const[i,s,a]of this.to_include)a&&n.push(...O([null],a)),s?n.length?n.push(...t[i].children):n=t[i].children:n.push(t[i]);return this.append_none&&n.push(...O([null],this.append_none)),this.node_builder(n)}}const Yn=D(Jn);class Kn extends Ae{constructor(t,n){super(),this.node_builder=n,this.to_include=t}__call__(t){let n=[];for(const[i,s]of this.to_include)s?n.length?n.push(...t[i].children):n=t[i].children:n.push(t[i]);return this.node_builder(n)}}const er=D(Kn);function tr(r){return!r.is_term&&r.name.startsWith("_")}function nr(r,t,n,i){let s,a;i.length?(a=i.map(c=>(0+c).toString()).join(""),s=a.split("0").map(c=>c.length)):s=O([0],r.length+1);let o=[],l=0;for(const[c,_]of V(r))l+=s[c],(t||!(_.is_term&&_.filter_out))&&(o.push([c,tr(_),l]),l=0);if(l+=s[r.length],i.length||o.length<r.length||Nn(o.map(([c,_,p])=>_)))return(i.length||n).length?re(n?Hn:Yn,o,l):re(er,o.map(([c,_,p])=>[c,_]))}function rr(r){function t(n){let i=new g(r.name,n);return r(i)}return t=wraps(r)(t),t}function ir(r,t,n){if(n===_vargs_meta||n===_vargs_meta_inline)throw new NotImplementedError("Meta args not supported for internal transformer");function i(s){return n(r,t,s,null)}return i=wraps(r)(i),i}class sr{constructor(t,n,i=!1,s=!1,a=!1){this.tree_class=n,this.propagate_positions=i,this.ambiguous=s,this.maybe_placeholders=a,this.rule_builders=[...this._init_builders(t)]}*_init_builders(t){let n,i,s,a,o=Xn(this.propagate_positions);for(const l of t)s=l.options,i=s.keep_all_tokens,n=s.expand1,a=[...it(null,[n&&!l.alias&&Wn,nr(l.expansion,i,this.ambiguous,this.maybe_placeholders?s.empty_indices:[]),o])],yield[l,a]}create_callback(t=null){let n,i,s,a=new Map;for(const[o,l]of this.rule_builders){i=o.alias||o.options.template_source||o.origin.name,t&&t[i]?(n=t&&t[i],s=n&&n.visit_wrapper||null,s!==null?n=ir(n,i,s):t instanceof ot&&(n=rr(n))):n=re(this.tree_class,i);for(const c of l)n=c(n);if(a.has(o))throw new ie(h("Rule '%s' already exists",o));a.set(o,n)}return a}}class ut extends N{constructor({parser_conf:t,debug:n=!1}={}){super();let i=new LALR_Analyzer({unknown_param_0:t,debug:n});i.compute_lalr();let s=t.callbacks;this._parse_table=i.parse_table,this.parser_conf=t,this.parser=new dt(i.parse_table,s,n)}static deserialize(t,n,i,s=!1){let a=ye(this);return a._parse_table=lr.deserialize(t,n),a.parser=new dt(a._parse_table,i,s),a}serialize(t){return this._parse_table.serialize(t)}parse_interactive(t,n){return this.parser.parse({lexer:t,start:n,start_interactive:!0})}parse({lexer:t,start:n,on_error:i=null}={}){let s,a;try{return this.parser.parse({lexer:t,start:n})}catch(o){if(o instanceof z){if(i===null)throw o;for(;;){if(o instanceof M&&(a=o.interactive_parser.lexer_thread.state,s=a.line_ctr.char_pos),!i(o))throw o;o instanceof M&&s===a.line_ctr.char_pos&&a.line_ctr.feed(a.text.slice(s,s+1));try{return o.interactive_parser.resume_parse()}catch(l){if(l instanceof j){if(o instanceof j&&o.token.type===l.token.type&&l.token.type==="$END"&&o.interactive_parser.eq(l.interactive_parser))throw l;o=l}else if(l instanceof M)o=l;else throw l}}}else throw o}}}class ar{constructor(t,n,i){this.parse_table=t,this.start_state=this.parse_table.start_states[i],this.end_state=this.parse_table.end_states[i],this.states=this.parse_table.states,this.callbacks=n,this.start=i}}class Ue{constructor(t,n,i=null,s=null){this.parse_conf=t,this.lexer=n,this.state_stack=i||[this.parse_conf.start_state],this.value_stack=s||[]}get position(){return E(this.state_stack)}eq(t){return t instanceof Ue?this.state_stack.length===t.state_stack.length&&this.position===t.position:W}copy(){return I(this)}feed_token(t,n=!1){let i,s,a,o,l,c,_,p,y,v,w=this.state_stack,u=this.value_stack,d=this.parse_conf.states,m=this.parse_conf.end_state,b=this.parse_conf.callbacks;for(;;){if(y=E(w),t.type in d[y])[s,a]=d[y][t.type];else throw o=new Set(fe(d[y]).filter(q=>st(q)).map(q=>q)),new j({token:t,expected:o,state:this,interactive_parser:null});if(s===Se){w.push(a),u.push(t.type in b?b[t.type](t):t);return}else if(c=a,p=c.expansion.length,p?(_=u.slice(-p),w.splice(-p),u.splice(-p)):_=[],v=b.get(c)(_),[i,l]=d[E(w)][c.origin.name],w.push(l),u.push(v),n&&E(w)===m)return E(u)}}}class dt{constructor(t,n,i=!1){this.parse_table=t,this.callbacks=n,this.debug=i}parse({lexer:t,start:n,value_stack:i=null,state_stack:s=null,start_interactive:a=!1}={}){let o=new ar(this.parse_table,this.callbacks,n),l=new Ue(o,t,s,i);return a?new P(this,l,l.lexer):this.parse_from_state(l)}parse_from_state(t){let n,i;try{i=null;for(i of t.lexer.lex(t))t.feed_token(i);return n=i?f.new_borrow_pos("$END","",i):new f("$END","",0,1,1),t.feed_token(n,!0)}catch(s){if(s instanceof z){try{s.interactive_parser=new P(this,t,t.lexer)}catch(a){if(!(a instanceof ReferenceError))throw a}throw s}else if(s instanceof Error){if(this.debug){console.log(""),console.log("STATE STACK DUMP"),console.log("----------------");for(const[a,o]of V(t.state_stack))console.log(h("%d)",a),o);console.log("")}throw s}else throw s}}}class P{constructor(t,n,i){this.parser=t,this.parser_state=n,this.lexer_thread=i,this.result=null}feed_token(t){return this.parser_state.feed_token(t,t.type==="$END")}*iter_parse(){for(const t of this.lexer_thread.lex(this.parser_state))yield t,this.result=this.feed_token(t)}exhaust_lexer(){return[...this.iter_parse()]}feed_eof(t=null){let n=t!==null?f.new_borrow_pos("$END","",t):new f("$END","",0,1,1);return this.feed_token(n)}copy(){return I(this)}eq(t){return t instanceof P?this.parser_state===t.parser_state&&this.lexer_thread===t.lexer_thread:!1}as_immutable(){let t=I(this);return new ht(t.parser,t.parser_state,t.lexer_thread)}pretty(){let t=["Parser choices:"];for(const[n,i]of x(this.choices()))t.push(h(" - %s -> %r",n,i));return t.push(h("stack size: %s",this.parser_state.state_stack.length)),t.join(`
20
+ `)}choices(){return this.parser_state.parse_conf.parse_table.states[this.parser_state.position]}accepts(){let t,n=new Set;for(const i of this.choices())if(st(i)){t=I(this);let s=null;try{t.feed_token(new f(i,""))}catch(a){if(s=a,!(a instanceof j))throw a}s||n.add(i)}return n}resume_parse(){return this.parser.parse_from_state(this.parser_state)}}class ht extends P{constructor(){super(...arguments),k(this,"result",null)}feed_token(t){let n=I(this);return n.result=P.feed_token(n,t),n}exhaust_lexer(){let t=this.as_mutable();return t.exhaust_lexer(),t.as_immutable()}as_mutable(){let t=I(this);return new P(t.parser,t.parser_state,t.lexer_thread)}}class mt{constructor(t){this.name=t}repr(){return this.toString()}}var Se=new mt("Shift"),ft=new mt("Reduce");class or{constructor(t,n,i){this.states=t,this.start_states=n,this.end_states=i}serialize(t){let n=new Enumerator,i=Object.fromEntries(x(this.states).map(([s,a])=>[s,Object.fromEntries(x(a).map(([o,[l,c]])=>[Ke(n,o),l===ft?[1,c.serialize(t)]:[0,c]]))]));return{tokens:n.reversed(),states:i,start_states:this.start_states,end_states:this.end_states}}static deserialize(t,n){const i=this;let s=t.tokens,a=Object.fromEntries(x(t.states).map(([o,l])=>[o,Object.fromEntries(x(l).map(([c,[_,p]])=>[s[c],_===1?[ft,Z.deserialize(p,n)]:[Se,p]]))]));return new i(a,t.start_states,t.end_states)}}class lr extends or{static from_ParseTable(t){const n=this;let i=[...t.states],s=Object.fromEntries(V(i).map(([c,_])=>[_,c])),a={};for(let[c,_]of x(t.states))_=Object.fromEntries(x(_).map(([p,y])=>[p,y[0]===Se?[y[0],s[y[1]]]:y])),a[s[c]]=_;let o=Object.fromEntries(x(t.start_states).map(([c,_])=>[c,s[_]])),l=Object.fromEntries(x(t.end_states).map(([c,_])=>[c,s[_]]));return new n(a,o,l)}}function _r(r){if(r&&r.__future_interface__)return r;{class t extends le{constructor(i){super(),this.lexer=r(i)}lex(i,s){return this.lexer.lex(i.text)}}return t}}function cr(r,t,n,i,s){let a=ct.deserialize(r.parser_conf,t),o=ut.deserialize(r.parser,t,i,s.debug);return a.callbacks=i,new pr({lexer_conf:n,parser_conf:a,options:s,parser:o})}var yt={};class pr extends N{static get __serialize_fields__(){return["lexer_conf","parser_conf","parser"]}constructor({lexer_conf:t,parser_conf:n,options:i,parser:s=null}={}){super();let a,o;this.parser_conf=n,this.lexer_conf=t,this.options=i,s?this.parser=s:(o=Ke(yt,n.parser_type),this.parser=o(t,n,i));let l=t.lexer_type;if(this.skip_lexer=!1,["dynamic","dynamic_complete"].includes(l)){this.skip_lexer=!0;return}const c={basic:mr,contextual:fr};l in c?(a=c[l],this.lexer=a(t,this.parser,t.postlex,i)):this.lexer=_r(l)(t),t.postlex&&(this.lexer=new hr(this.lexer,t.postlex))}_verify_start(t=null){let n;if(t===null){if(n=this.parser_conf.start,n.length>1)throw new S("Lark initialized with more than 1 possible start rule. Must specify which start rule to parse",n);[t]=n}else if(!this.parser_conf.start.includes(t))throw new S(h("Unknown start rule %s. Must be one of %r",t,this.parser_conf.start));return t}_make_lexer_thread(t){return this.skip_lexer?t:lt.from_text(this.lexer,t)}parse(t,n=null,i=null){let s=this._verify_start(n),a=i===null?{}:{on_error:i},o=this._make_lexer_thread(t);return this.parser.parse({lexer:o,start:s,...a})}parse_interactive(t=null,n=null){let i=this._verify_start(n);if(this.parser_conf.parser_type!=="lalr")throw new S("parse_interactive() currently only works with parser='lalr' ");let s=this._make_lexer_thread(t);return this.parser.parse_interactive(s,i)}}function ur(r,t){let n;ve(r,["lalr","earley","cyk"]),typeof t!="object"&&(n={lalr:["basic","contextual"],earley:["basic","dynamic","dynamic_complete"],cyk:["basic"]}[r],ve(t,n,h("Parser %r does not support lexer %%r, expected one of %%s",r)))}function dr(r,t){let n,i={};for(const s of t)n=r&&r[s.name]||null,n!==null&&(i[s.name]=n);return i}class hr{constructor(t,n){this.lexer=t,this.postlexer=n}lex(t,n){let i=this.lexer.lex(t,n);return this.postlexer.process(i)}}function mr(r,t,n,i){return new _e(r)}function fr(r,t,n,i){let s=Object.fromEntries(x(t._parse_table.states).map(([o,l])=>[o,[...fe(l)]])),a=n?n.always_accept:[];return new Zn({conf:r,states:s,always_accept:a})}function yr(r,t,n=null){let i=n?n.debug:!1;return new ut({parser_conf:t,debug:i})}yt.lalr=yr;class gt extends Ye{constructor(){super(...arguments),k(this,"always_accept",[])}process(t){return t}}class gr extends N{constructor(t){super(),k(this,"OPTIONS_DOC",'\n **=== General Options ===**\n\n start\n The start symbol. Either a string, or a list of strings for multiple possible starts (Default: "start")\n debug\n Display debug information and extra warnings. Use only when debugging (Default: ``False``)\n When used with Earley, it generates a forest graph as "sppf.png", if \'dot\' is installed.\n transformer\n Applies the transformer to every parse tree (equivalent to applying it after the parse, but faster)\n propagate_positions\n Propagates (line, column, end_line, end_column) attributes into all tree branches.\n Accepts ``False``, ``True``, or a callable, which will filter which nodes to ignore when propagating.\n maybe_placeholders\n When ``True``, the ``[]`` operator returns ``None`` when not matched.\n When ``False``, ``[]`` behaves like the ``?`` operator, and returns no value at all.\n (default= ``True``)\n cache\n Cache the results of the Lark grammar analysis, for x2 to x3 faster loading. LALR only for now.\n\n - When ``False``, does nothing (default)\n - When ``True``, caches to a temporary file in the local directory\n - When given a string, caches to the path pointed by the string\n regex\n When True, uses the ``regex`` module instead of the stdlib ``re``.\n g_regex_flags\n Flags that are applied to all terminals (both regex and strings)\n keep_all_tokens\n Prevent the tree builder from automagically removing "punctuation" tokens (Default: ``False``)\n tree_class\n Lark will produce trees comprised of instances of this class instead of the default ``lark.Tree``.\n\n **=== Algorithm Options ===**\n\n parser\n Decides which parser engine to use. Accepts "earley" or "lalr". (Default: "earley").\n (there is also a "cyk" option for legacy)\n lexer\n Decides whether or not to use a lexer stage\n\n - "auto" (default): Choose for me based on the parser\n - "basic": Use a basic lexer\n - "contextual": Stronger lexer (only works with parser="lalr")\n - "dynamic": Flexible and powerful (only with parser="earley")\n - "dynamic_complete": Same as dynamic, but tries *every* variation of tokenizing possible.\n ambiguity\n Decides how to handle ambiguity in the parse. Only relevant if parser="earley"\n\n - "resolve": The parser will automatically choose the simplest derivation\n (it chooses consistently: greedy for tokens, non-greedy for rules)\n - "explicit": The parser will return all derivations wrapped in "_ambig" tree nodes (i.e. a forest).\n - "forest": The parser will return the root of the shared packed parse forest.\n\n **=== Misc. / Domain Specific Options ===**\n\n postlex\n Lexer post-processing (Default: ``None``) Only works with the basic and contextual lexers.\n priority\n How priorities should be evaluated - "auto", ``None``, "normal", "invert" (Default: "auto")\n lexer_callbacks\n Dictionary of callbacks for the lexer. May alter tokens during lexing. Use with caution.\n use_bytes\n Accept an input of type ``bytes`` instead of ``str``.\n edit_terminals\n A callback for editing the terminals before parse.\n import_paths\n A List of either paths or loader functions to specify from where grammars are imported\n source_path\n Override the source of from where the grammar was loaded. Useful for relative imports and unconventional grammar loading\n **=== End of Options ===**\n '),k(this,"_defaults",{debug:!1,keep_all_tokens:!1,tree_class:null,cache:!1,postlex:null,parser:"earley",lexer:"auto",transformer:null,start:"start",priority:"auto",ambiguity:"auto",regex:!1,propagate_positions:!1,lexer_callbacks:{},maybe_placeholders:!0,edit_terminals:null,g_regex_flags:"",use_bytes:!1,import_paths:[],source_path:null,_plugins:null});let n,i=nt(t),s=this;for(const[a,o]of x(this._defaults))a in i?(n=wn(i,a),typeof o=="boolean"&&!["cache","use_bytes","propagate_positions"].includes(a)&&(n=rt(n))):n=o,s[a]=n;if(typeof s.start=="string"&&(s.start=[s.start]),this.options=s,ve(this.parser,["earley","lalr","cyk",null]),this.parser==="earley"&&this.transformer)throw new S("Cannot specify an embedded transformer when using the Earley algorithm. Please use your transformer on the resulting parse tree, or use a different algorithm (i.e. LALR)");if(Object.keys(i).length)throw new S(h("Unknown options: %s",fe(i)))}serialize(t){return this.options}static deserialize(t,n){const i=this;return new i(t)}}class xt extends N{static get __serialize_fields__(){return["parser","rules","options"]}_build_lexer(t=!1){let n=this.lexer_conf;return t&&(n=I(n),n.ignore=[]),new _e(n)}_prepare_callbacks(){this._callbacks=new Map,this.options.ambiguity!=="forest"&&(this._parse_tree_builder=new sr(this.rules,this.options.tree_class||Tn(g),this.options.propagate_positions,this.options.parser!=="lalr"&&this.options.ambiguity==="explicit",this.options.maybe_placeholders),this._callbacks=this._parse_tree_builder.create_callback(this.options.transformer)),et(this._callbacks,dr(this.options.transformer,this.terminals))}_deserialize_lexer_conf(t,n,i){let s=_t.deserialize(t.lexer_conf,n);return s.callbacks=i.lexer_callbacks||{},s.re_module=i.regex?regex:Xe,s.use_bytes=i.use_bytes,s.g_regex_flags=i.g_regex_flags||"",s.skip_validation=!0,s.postlex=i.postlex,s}_load({f:t,...n}={}){let i;ge(t)?i=t:i=pickle.load(t);let s=i.memo,a=i.data,o=An.deserialize(s,{Rule:Z,TerminalDef:oe},{}),l=nt(a.options);return et(l,n),this.options=gr.deserialize(l,o),this.rules=a.rules.map(c=>Z.deserialize(c,o)),this.source_path="<deserialized>",ur(this.options.parser,this.options.lexer),this.lexer_conf=this._deserialize_lexer_conf(a.parser,o,this.options),this.terminals=this.lexer_conf.terminals,this._prepare_callbacks(),this._terminals_dict=Object.fromEntries(this.terminals.map(c=>[c.name,c])),this.parser=cr(a.parser,o,this.lexer_conf,this._callbacks,this.options),this}static _load_from_dict({data:t,memo:n,...i}={}){return ye(this)._load({f:{data:t,memo:n},...i})}repr(){return h("Lark(open(%r), parser=%r, lexer=%r, ...)",this.source_path,this.options.parser,this.options.lexer)}lex(t,n=!1){let i;!("lexer"in this)||n?i=this._build_lexer(n):i=this.lexer;let s=lt.from_text(i,t).lex(null);return this.options.postlex?this.options.postlex.process(s):s}get_terminal(t){return this._terminals_dict[t]}parse_interactive(t=null,n=null){return this.parser.parse_interactive({unknown_param_0:t,start:n})}parse(t,n=null,i=null){return this.parser.parse(t,n,i)}}class wt extends A{}class Tt extends gt{constructor(){super(),this.paren_level=0,this.indent_level=[0]}*handle_NL(t){if(this.paren_level>0)return;yield t;let n=we(t.value,`
21
+ `,1)[1],i=Te(n," ")+Te(n," ")*this.tab_len;if(i>E(this.indent_level))this.indent_level.push(i),yield f.new_borrow_pos(this.INDENT_type,n,t);else{for(;i<E(this.indent_level);)this.indent_level.pop(),yield f.new_borrow_pos(this.DEDENT_type,n,t);if(i!==E(this.indent_level))throw new wt(h("Unexpected dedent to column %s. Expected dedent to %s",i,E(this.indent_level)))}}*_process(t){for(const n of t)n.type===this.NL_type?yield*this.handle_NL(n):yield n,this.OPEN_PAREN_types.includes(n.type)?this.paren_level+=1:this.CLOSE_PAREN_types.includes(n.type)&&(this.paren_level-=1);for(;this.indent_level.length>1;)this.indent_level.pop(),yield new f(this.DEDENT_type,"")}process(t){return this.paren_level=0,this.indent_level=[0],this._process(t)}get always_accept(){return[this.NL_type]}get NL_type(){throw new NotImplementedError}get OPEN_PAREN_types(){throw new NotImplementedError}get CLOSE_PAREN_types(){throw new NotImplementedError}get INDENT_type(){throw new NotImplementedError}get DEDENT_type(){throw new NotImplementedError}get tab_len(){throw new NotImplementedError}}class xr extends Tt{static get NL_type(){return"_NEWLINE"}get NL_type(){return this.constructor.NL_type}static get OPEN_PAREN_types(){return["LPAR","LSQB","LBRACE"]}get OPEN_PAREN_types(){return this.constructor.OPEN_PAREN_types}static get CLOSE_PAREN_types(){return["RPAR","RSQB","RBRACE"]}get CLOSE_PAREN_types(){return this.constructor.CLOSE_PAREN_types}static get INDENT_type(){return"_INDENT"}get INDENT_type(){return this.constructor.INDENT_type}static get DEDENT_type(){return"_DEDENT"}get DEDENT_type(){return this.constructor.DEDENT_type}static get tab_len(){return 8}get tab_len(){return this.constructor.tab_len}}const wr={Terminal:Re,NonTerminal:ke,RuleOptions:ae,PatternStr:qe,PatternRE:Oe,TerminalDef:oe};var Tr={LarkError:A,ConfigurationError:S,GrammarError:ie,ParseError:In,LexError:X,UnexpectedInput:z,UnexpectedEOF:qn,UnexpectedCharacters:M,UnexpectedToken:j,VisitError:be,Meta:at,Tree:g,Discard:te,Transformer:H,Transformer_InPlace:ot,Transformer_NonRecursive:Sn,Transformer_InPlaceRecursive:$n,VisitorBase:Ee,Visitor:zn,Visitor_Recursive:Pn,Interpreter:Dn,Symbol:Ne,Terminal:Re,NonTerminal:ke,RuleOptions:ae,Rule:Z,Pattern:Ie,PatternStr:qe,PatternRE:Oe,TerminalDef:oe,Token:f,Lexer:le,LexerConf:_t,ParserConf:ct,InteractiveParser:P,ImmutableInteractiveParser:ht,PostLex:gt,Lark:xt,DedentError:wt,Indenter:Tt,PythonIndenter:xr,get_parser:gn},vr={parser:{lexer_conf:{terminals:[{"@":0},{"@":1},{"@":2},{"@":3},{"@":4},{"@":5},{"@":6},{"@":7},{"@":8},{"@":9},{"@":10},{"@":11},{"@":12},{"@":13},{"@":14},{"@":15},{"@":16},{"@":17},{"@":18},{"@":19},{"@":20}],ignore:["WS"],g_regex_flags:0,use_bytes:!1,lexer_type:"contextual",__type__:"LexerConf"},parser_conf:{rules:[{"@":21},{"@":22},{"@":23},{"@":24},{"@":25},{"@":26},{"@":27},{"@":28},{"@":29},{"@":30},{"@":31},{"@":32},{"@":33},{"@":34},{"@":35},{"@":36},{"@":37},{"@":38},{"@":39},{"@":40},{"@":41},{"@":42},{"@":43},{"@":44},{"@":45},{"@":46},{"@":47},{"@":48},{"@":49},{"@":50},{"@":51},{"@":52},{"@":53},{"@":54}],start:["start"],parser_type:"lalr",__type__:"ParserConf"},parser:{tokens:{0:"$END",1:"RPAR",2:"LSQB",3:"DOT",4:"question_selector",5:"IDENTIFIER",6:"OPERATOR",7:"CONJUNCTION",8:"__ANON_3",9:"__ANON_1",10:"qc_mc_text",11:"FALSE",12:"bool_expr",13:"__ANON_0",14:"__ANON_2",15:"__ANON_5",16:"qc_mc_count",17:"qc_matrix_selected",18:"condition",19:"qc_selected_value",20:"bool_const",21:"qc_matrix_count",22:"NEGATION",23:"__ANON_4",24:"TRUE",25:"qc_mc_selected",26:"qc_mc_text_ignore_case",27:"__ANON_6",28:"INT",29:"RSQB",30:"matrix_statement_selector",31:"matrix_choice_selector",32:"mc_choice_selector",33:"STRING",34:"question_or_matrix_statement_selector",35:"top_level_expr",36:"LPAR",37:"start"},states:{0:{0:[1,{"@":22}]},1:{1:[1,{"@":45}],2:[1,{"@":45}],3:[1,{"@":45}]},2:{2:[1,{"@":48}],1:[1,{"@":48}]},3:{1:[0,10]},4:{1:[0,9]},5:{4:[0,8],5:[0,1]},6:{2:[0,50]},7:{},8:{1:[0,57]},9:{6:[0,65]},10:{1:[1,{"@":42}],0:[1,{"@":42}],7:[1,{"@":42}]},11:{8:[0,66],9:[0,35],10:[0,44],11:[0,63],12:[0,49],13:[0,56],14:[0,54],15:[0,34],16:[0,75],17:[0,68],18:[0,78],19:[0,69],20:[0,36],21:[0,71],22:[0,80],23:[0,5],24:[0,43],25:[0,39],26:[0,51]},12:{0:[1,{"@":24}]},13:{6:[0,70]},14:{2:[0,77],3:[0,28]},15:{3:[0,28],1:[1,{"@":51}]},16:{1:[1,{"@":41}],0:[1,{"@":41}],7:[1,{"@":41}]},17:{27:[0,73]},18:{1:[1,{"@":52}]},19:{8:[0,66],9:[0,35],10:[0,44],11:[0,63],25:[0,39],12:[0,27],13:[0,56],14:[0,54],15:[0,34],16:[0,75],17:[0,68],18:[0,78],19:[0,69],21:[0,71],22:[0,80],23:[0,5],24:[0,43],26:[0,51],20:[0,36]},20:{27:[0,13]},21:{6:[0,47]},22:{6:[0,23]},23:{28:[0,60]},24:{1:[0,16]},25:{2:[0,77]},26:{0:[1,{"@":21}]},27:{1:[0,29]},28:{5:[0,2]},29:{7:[0,81],0:[1,{"@":23}]},30:{1:[0,22]},31:{1:[0,21]},32:{29:[0,64]},33:{1:[0,52]},34:{5:[0,1],4:[0,76]},35:{30:[0,6],5:[0,1],4:[0,14],31:[0,3],32:[0,41]},36:{1:[1,{"@":27}],0:[1,{"@":27}],7:[1,{"@":27}]},37:{29:[0,53]},38:{1:[1,{"@":40}],0:[1,{"@":40}],7:[1,{"@":40}]},39:{1:[1,{"@":29}],0:[1,{"@":29}],7:[1,{"@":29}]},40:{1:[1,{"@":43}],0:[1,{"@":43}],7:[1,{"@":43}]},41:{1:[0,61]},42:{28:[0,40]},43:{1:[1,{"@":53}],0:[1,{"@":53}],7:[1,{"@":53}]},44:{1:[1,{"@":30}],0:[1,{"@":30}],7:[1,{"@":30}]},45:{1:[1,{"@":50}]},46:{1:[1,{"@":39}],0:[1,{"@":39}],7:[1,{"@":39}]},47:{33:[0,48]},48:{1:[1,{"@":38}],0:[1,{"@":38}],7:[1,{"@":38}]},49:{0:[1,{"@":26}],1:[1,{"@":26}]},50:{5:[0,55],28:[0,62]},51:{1:[1,{"@":31}],0:[1,{"@":31}],7:[1,{"@":31}]},52:{1:[1,{"@":36}],0:[1,{"@":36}],7:[1,{"@":36}]},53:{1:[1,{"@":47}]},54:{4:[0,25],32:[0,31],5:[0,1]},55:{29:[0,45]},56:{4:[0,15],5:[0,1],30:[0,18],34:[0,30]},57:{6:[0,58]},58:{28:[0,38]},59:{28:[0,17],5:[0,20]},60:{1:[1,{"@":35}],0:[1,{"@":35}],7:[1,{"@":35}]},61:{1:[1,{"@":37}],0:[1,{"@":37}],7:[1,{"@":37}]},62:{29:[0,79]},63:{1:[1,{"@":54}],0:[1,{"@":54}],7:[1,{"@":54}]},64:{1:[1,{"@":46}]},65:{33:[0,46]},66:{4:[0,25],32:[0,4],5:[0,1]},67:{30:[0,6],5:[0,1],4:[0,14],32:[0,33],31:[0,24]},68:{1:[1,{"@":33}],0:[1,{"@":33}],7:[1,{"@":33}]},69:{1:[1,{"@":28}],0:[1,{"@":28}],7:[1,{"@":28}]},70:{28:[0,74]},71:{1:[1,{"@":34}],0:[1,{"@":34}],7:[1,{"@":34}]},72:{8:[0,66],35:[0,26],9:[0,35],10:[0,44],11:[0,63],36:[0,19],25:[0,39],13:[0,56],14:[0,54],15:[0,34],16:[0,75],17:[0,68],18:[0,78],19:[0,69],37:[0,7],12:[0,0],21:[0,71],22:[0,80],23:[0,5],24:[0,43],26:[0,51],20:[0,36]},73:{6:[0,42]},74:{1:[1,{"@":44}],0:[1,{"@":44}],7:[1,{"@":44}]},75:{1:[1,{"@":32}],0:[1,{"@":32}],7:[1,{"@":32}]},76:{2:[0,59]},77:{28:[0,32],5:[0,37]},78:{7:[0,11],0:[1,{"@":25}],1:[1,{"@":25}]},79:{1:[1,{"@":49}]},80:{9:[0,67]},81:{35:[0,12],36:[0,19]}},start_states:{start:72},end_states:{start:7}},__type__:"ParsingFrontend"},rules:[{"@":21},{"@":22},{"@":23},{"@":24},{"@":25},{"@":26},{"@":27},{"@":28},{"@":29},{"@":30},{"@":31},{"@":32},{"@":33},{"@":34},{"@":35},{"@":36},{"@":37},{"@":38},{"@":39},{"@":40},{"@":41},{"@":42},{"@":43},{"@":44},{"@":45},{"@":46},{"@":47},{"@":48},{"@":49},{"@":50},{"@":51},{"@":52},{"@":53},{"@":54}],options:{debug:!1,keep_all_tokens:!1,tree_class:null,cache:!1,postlex:null,parser:"lalr",lexer:"contextual",transformer:null,start:["start"],priority:"normal",ambiguity:"auto",regex:!1,propagate_positions:!1,lexer_callbacks:{},maybe_placeholders:!1,edit_terminals:null,g_regex_flags:0,use_bytes:!1,import_paths:[],source_path:null,_plugins:{}},__type__:"Lark"},br={0:{name:"WS",pattern:{value:`(?:[ \f\r
22
+ ])+`,flags:[],_width:[1,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},1:{name:"IDENTIFIER",pattern:{value:"[a-zA-Z][a-zA-Z0-9_]*[a-zA-Z0-9]",flags:[],_width:[2,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},2:{name:"INT",pattern:{value:"-?[0-9]+",flags:[],_width:[1,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},3:{name:"STRING",pattern:{value:`(?:'[^\\']*'|"[^"]*")`,flags:[],_width:[2,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},4:{name:"OPERATOR",pattern:{value:"(?:regex_matches|not_contains|contains|==|!=|<=|>=|<|>)",flags:[],_width:[1,13],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},5:{name:"CONJUNCTION",pattern:{value:"(?:and|or)",flags:[],_width:[2,3],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},6:{name:"NEGATION",pattern:{value:"!",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},7:{name:"TRUE",pattern:{value:"true",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},8:{name:"FALSE",pattern:{value:"false",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},9:{name:"LPAR",pattern:{value:"(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},10:{name:"RPAR",pattern:{value:")",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},11:{name:"__ANON_0",pattern:{value:"selected_value(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},12:{name:"__ANON_1",pattern:{value:"selected(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},13:{name:"__ANON_2",pattern:{value:"text(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},14:{name:"__ANON_3",pattern:{value:"text_ignore_case(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},15:{name:"__ANON_4",pattern:{value:"count_selected(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},16:{name:"__ANON_5",pattern:{value:"count_choice_selections(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},17:{name:"LSQB",pattern:{value:"[",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},18:{name:"__ANON_6",pattern:{value:"])",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},19:{name:"RSQB",pattern:{value:"]",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},20:{name:"DOT",pattern:{value:".",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},21:{origin:{name:"start",__type__:"NonTerminal"},expansion:[{name:"top_level_expr",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},22:{origin:{name:"start",__type__:"NonTerminal"},expansion:[{name:"bool_expr",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},23:{origin:{name:"top_level_expr",__type__:"NonTerminal"},expansion:[{name:"LPAR",filter_out:!0,__type__:"Terminal"},{name:"bool_expr",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},24:{origin:{name:"top_level_expr",__type__:"NonTerminal"},expansion:[{name:"LPAR",filter_out:!0,__type__:"Terminal"},{name:"bool_expr",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"CONJUNCTION",filter_out:!1,__type__:"Terminal"},{name:"top_level_expr",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},25:{origin:{name:"bool_expr",__type__:"NonTerminal"},expansion:[{name:"condition",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},26:{origin:{name:"bool_expr",__type__:"NonTerminal"},expansion:[{name:"condition",__type__:"NonTerminal"},{name:"CONJUNCTION",filter_out:!1,__type__:"Terminal"},{name:"bool_expr",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},27:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"bool_const",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},28:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_selected_value",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},29:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_selected",__type__:"NonTerminal"}],order:2,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},30:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_text",__type__:"NonTerminal"}],order:3,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},31:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_text_ignore_case",__type__:"NonTerminal"}],order:4,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},32:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_count",__type__:"NonTerminal"}],order:5,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},33:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_matrix_selected",__type__:"NonTerminal"}],order:6,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},34:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_matrix_count",__type__:"NonTerminal"}],order:7,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},35:{origin:{name:"qc_selected_value",__type__:"NonTerminal"},expansion:[{name:"__ANON_0",filter_out:!0,__type__:"Terminal"},{name:"question_or_matrix_statement_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},36:{origin:{name:"qc_mc_selected",__type__:"NonTerminal"},expansion:[{name:"NEGATION",filter_out:!1,__type__:"Terminal"},{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},37:{origin:{name:"qc_mc_selected",__type__:"NonTerminal"},expansion:[{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},38:{origin:{name:"qc_mc_text",__type__:"NonTerminal"},expansion:[{name:"__ANON_2",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"STRING",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},39:{origin:{name:"qc_mc_text_ignore_case",__type__:"NonTerminal"},expansion:[{name:"__ANON_3",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"STRING",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},40:{origin:{name:"qc_mc_count",__type__:"NonTerminal"},expansion:[{name:"__ANON_4",filter_out:!0,__type__:"Terminal"},{name:"question_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},41:{origin:{name:"qc_matrix_selected",__type__:"NonTerminal"},expansion:[{name:"NEGATION",filter_out:!1,__type__:"Terminal"},{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"matrix_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},42:{origin:{name:"qc_matrix_selected",__type__:"NonTerminal"},expansion:[{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"matrix_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},43:{origin:{name:"qc_matrix_count",__type__:"NonTerminal"},expansion:[{name:"__ANON_5",filter_out:!0,__type__:"Terminal"},{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"},{name:"__ANON_6",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},44:{origin:{name:"qc_matrix_count",__type__:"NonTerminal"},expansion:[{name:"__ANON_5",filter_out:!0,__type__:"Terminal"},{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"},{name:"__ANON_6",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},45:{origin:{name:"question_selector",__type__:"NonTerminal"},expansion:[{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},46:{origin:{name:"mc_choice_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},47:{origin:{name:"mc_choice_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},48:{origin:{name:"matrix_statement_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"},{name:"DOT",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},49:{origin:{name:"matrix_choice_selector",__type__:"NonTerminal"},expansion:[{name:"matrix_statement_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},50:{origin:{name:"matrix_choice_selector",__type__:"NonTerminal"},expansion:[{name:"matrix_statement_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},51:{origin:{name:"question_or_matrix_statement_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},52:{origin:{name:"question_or_matrix_statement_selector",__type__:"NonTerminal"},expansion:[{name:"matrix_statement_selector",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},53:{origin:{name:"bool_const",__type__:"NonTerminal"},expansion:[{name:"TRUE",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},54:{origin:{name:"bool_const",__type__:"NonTerminal"},expansion:[{name:"FALSE",filter_out:!1,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"}};const Er="(?<questionId>[a-zA-Z][a-zA-Z0-9_]*)",Nr="((?<expressionWithoutIdentifier>all|all_entered_text|selected|selected_entered_text|not_selected)|(?<expressionWithIdentifier>for_matrix_choice|unselected_for_matrix_choice)(\\((?<identifier>[\\-a-zA-Z0-9_]+)\\)))",vt=new RegExp(`^${Er}/${Nr}$`);var T=(r=>(r.ALL="all",r.ALL_ENTERED_TEXT="all_entered_text",r.SELECTED="selected",r.SELECTED_ENTERED_TEXT="selected_entered_text",r.NOT_SELECTED="not_selected",r.FOR_MATRIX_CHOICE="for_matrix_choice",r.UNSELECTED_FOR_MATRIX_CHOICE="unselected_for_matrix_choice",r))(T||{});const bt=r=>vt.test(r),L=r=>{var t;const n=(t=r.match(vt))==null?void 0:t.groups;if(!n)throw new Error(`Invalid locator expression: ${r}`);const i=n.expressionWithoutIdentifier||n.expressionWithIdentifier||"all",s={questionId:n.questionId,expression:i};if(n.identifier){const a=isNaN(parseInt(n.identifier,10))?n.identifier:parseInt(n.identifier,10);s.identifier=a}return s},ce=(r,t="camelCase")=>{const n=t==="camelCase"?ee.default.camelCase:ee.default.snakeCase;return ee.default.transform(r,(i,s,a)=>{const o=typeof a=="string"?n(a):a;i[o]=ee.default.isObject(s)?ce(s,t):s})};function Rr(r){const t=structuredClone(r);return{...t,...t.template,sections:t.sections.map(n=>({...ce(n),pages:n.pages.map((i,s)=>({...i,id:`${n.id}-${s}`,questions:kr(t,n,i.questions)}))}))}}function kr(r,t,n){return n.map(i=>Ir(r.template.id,t,i))}function Ir(r,t,n){var i,s;return{...ce({...n,choiceGroups:(i=n.choice_groups)==null?void 0:i.map(a=>({...a,randomization:$e(a.randomization)})),statementGroups:(s=n.statement_groups)==null?void 0:s.map(a=>({...a,randomization:$e(a.randomization)})),randomization:$e(n.randomization)}),id:Nt(r,n),type:Rt(n.type),layout:qr(n.layout),required:Or(n.required),label:t.name}}function $e(r){var t;return r?{type:Et(r.type),order:(t=r.order)==null?void 0:t.split(" "),total:r.total}:void 0}function Et(r){return r.toUpperCase()}function Nt(r,t){return`${r}.${t.id}`}const ze=r=>r.split(".").pop();function Rt(r="description"){return r.replace("-","_").toUpperCase()}function qr(r){return r==null?void 0:r.toUpperCase()}function Or(r="optional"){return r.replace("-","_").toUpperCase()}function kt(r){return structuredClone(r).sections.flatMap(t=>t.pages.flatMap(n=>n.questions))}var Ar=Object.defineProperty,Sr=(r,t,n)=>t in r?Ar(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,U=(r,t,n)=>(Sr(r,typeof t!="symbol"?t+"":t,n),n),$r=(r,t,n)=>{if(!t.has(r))throw TypeError("Cannot "+n)},It=(r,t,n)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,n)},J=(r,t,n)=>($r(r,t,"access private method"),n),Y,pe,ue,Pe;const De=/\$\{q\:(?<locator>[\-a-zA-Z0-9_\/\(\)]+)\}/g,qt=r=>{var t,n;return(n=(t=r.choiceId)!=null?t:r.choiceValue)!=null?n:r.text};class zr{constructor(t,n=[],i="",s=!1){It(this,Y),It(this,ue),U(this,"questions",new Map),U(this,"responsesByQuestion",new Map),U(this,"responsesByQuestionStatement",new Map),U(this,"hashSalt"),U(this,"forExport"),U(this,"evaluationCache",new Map),this.questions=new Map((t?kt(t):[]).filter(a=>a.id).map(a=>[ze(a.id),a])),n.filter(a=>a.singleAnswer||a.multipleAnswers).forEach(a=>{const o=ze(a.questionId);this.responsesByQuestion.set(o,[...this.responsesByQuestion.get(o)||[],a]),a.statementId&&this.responsesByQuestionStatement.set(`${o}.${a.statementId}`,a)}),this.hashSalt=i,this.forExport=s}getQuestionAnswers(t,n){let i;if(n){const s=this.responsesByQuestionStatement.get(`${t}.${n}`);i=s===void 0?[]:[s]}else i=this.responsesByQuestion.get(t)||[];return i.flatMap(s=>{const{multipleAnswers:a,singleAnswer:o}=s;return a||[o]})}evaluateDisplayLogic(t){if(t&&!this.forExport)try{const n=this.evaluationCache.get(t);if(n!==void 0)return n;const i=Ce(t,this);return this.evaluationCache.set(t,i),i}catch(n){return console.error(n),!1}return!0}evaluateDynamicExpression(t,n){const i=this.questions.get(t.questionId);if(!i)return[];const s=this.getQuestionChoicesFlattened(i),a=s.filter(p=>this.isSelected({questionId:t.questionId,choice:p.id||p.value})),o=this.getQuestionStatementsFlattened(i),l=p=>n==="choices"?p:{...p,id:p.id||p.value||p.display},c=p=>({id:p.id,display:p.display,value:p.value});let _=[];switch(t.expression){case T.ALL:_=s.map(l);break;case T.ALL_ENTERED_TEXT:_=s.map(p=>l(J(this,ue,Pe).call(this,p,t)));break;case T.SELECTED:_=a;break;case T.SELECTED_ENTERED_TEXT:_=a.map(p=>l(J(this,ue,Pe).call(this,p,t)));break;case T.NOT_SELECTED:_=s.filter(p=>!this.isSelected({questionId:t.questionId,choice:p.id||p.value})).map(l);break;case T.FOR_MATRIX_CHOICE:_=o.filter(p=>this.isSelected({questionId:t.questionId,statementId:p.id,choice:t.identifier}));break;case T.UNSELECTED_FOR_MATRIX_CHOICE:_=o.filter(p=>!this.isSelected({questionId:t.questionId,statementId:p.id,choice:t.identifier}));break;default:_=[]}return this.forExport&&(_=t.expression===T.FOR_MATRIX_CHOICE||t.expression===T.UNSELECTED_FOR_MATRIX_CHOICE?o:s.map(l)),_.map(c)}isSelected(t){return!!J(this,Y,pe).call(this,t.questionId,t.statementId,t.choice).length}countSelected(t){return this.getQuestionAnswers(t).length}selectedValue(t){const n=this.getQuestionAnswers(t.questionId,t.statementId);return n.length?qt(n[0]):null}countChoiceSelections(t,n){return J(this,Y,pe).call(this,t,null,n).length}textEntry(t){return J(this,Y,pe).call(this,t.questionId,t.statementId,t.choice).map(n=>n.text).filter(n=>n).join(", ")}getQuestionText(t){if(this.forExport)return t.text;let n=t.text;return n=n.replaceAll(De,(i,s)=>{if(s&&bt(s)){const a=L(s);return this.evaluateDynamicExpression(a,"choices").map(o=>o.display).join(", ")}return i}),n}getQuestionChoices(t){var n;const i=((n=t.choices)!=null?n:[]).filter(s=>this.evaluateDisplayLogic(s.displayLogic));if(t.dynamicChoices){const s=L(t.dynamicChoices),a=this.evaluateDynamicExpression(s,"choices");i.push(...a)}return t.type===me.MatrixSingle||t.type===me.MatrixMulti?i:this.applyRandomization(i,t.id,s=>{var a;return`${(a=s.id)!=null?a:s.value}`},t.randomization)}getQuestionChoiceGroups(t){var n;const i=(((n=t.choiceGroups)==null?void 0:n.filter(s=>this.evaluateDisplayLogic(s.displayLogic)))||[]).map(s=>({...s,choices:this.applyRandomization(s.choices.filter(a=>this.evaluateDisplayLogic(a.displayLogic)),t.id,a=>{var o;return`${(o=a.id)!=null?o:a.value}`},s.randomization)})).filter(s=>!!s.choices.length);return this.applyRandomization(i,t.id,s=>s.id,t.randomization)}getQuestionStatements(t){var n;const i=((n=t.statements)!=null?n:[]).filter(s=>this.evaluateDisplayLogic(s.displayLogic));if(t.dynamicStatements){const s=L(t.dynamicStatements),a=this.evaluateDynamicExpression(s,"statements");i.push(...a)}return this.applyRandomization(i,t.id,s=>s.id,t.randomization)}getQuestionStatementGroups(t){var n;const i=(((n=t.statementGroups)==null?void 0:n.filter(s=>this.evaluateDisplayLogic(s.displayLogic)))||[]).map(s=>({...s,statements:this.applyRandomization(s.statements.filter(a=>this.evaluateDisplayLogic(a.displayLogic)),t.id,a=>a.id,s.randomization)})).filter(s=>!!s.statements.length);return this.applyRandomization(i,t.id,s=>s.id,t.randomization)}getQuestionChoicesFlattened(t){return[...this.getQuestionChoices(t),...this.getQuestionChoiceGroups(t).flatMap(n=>n.choices)]}getQuestionStatementsFlattened(t){return[...this.getQuestionStatements(t),...this.getQuestionStatementGroups(t).flatMap(n=>n.statements)]}applyRandomization(t,n,i,s){var a,o;if(!s||this.forExport)return t;const l=new Map(t.map(d=>[i(d),d])),c=[...l.keys()],_=new Set(c),p=((a=s.order)!=null?a:["$"]).filter(d=>d==="$"||_.has(d)),y=c.filter(d=>!p.includes(d)).map(d=>({weight:this.keyHash(n,d),key:d}));y.sort((d,m)=>d.weight.localeCompare(m.weight));const v=(o=s.total)!=null?o:c.length,w=Math.min(v-(p.length-1),y.length),u=[];return p.forEach(d=>{d==="$"?u.push(...y.slice(0,w).map(m=>m.key)):u.push(d)}),u.map(d=>l.get(d))}keyHash(t,n){const i=`${t}.${this.hashSalt}.${n}`;return Vt.createHash("sha256").update(i).digest("hex")}}Y=new WeakSet,pe=function(r,t,n){return this.getQuestionAnswers(r,t).filter(i=>typeof n=="undefined"||n===null||qt(i)===n)},ue=new WeakSet,Pe=function(r,t){if(r.textInput&&["forced","optional"].includes(r.textInput)){const n=this.textEntry({questionId:t.questionId,choice:r.id||r.value});return{...r,display:n}}return r};function Ot(r){if(r.length===1)return r[0];const t=r[1].value;return t==="or"?r[0]||r[2]:t==="and"?r[0]&&r[2]:!1}function de(r,t,n){switch(t){case"==":return r===n;case"!=":return r!==n;case"<=":return r<=n;case">=":return r>=n;case"<":return r<n;case">":return r>n;default:return!1}}function At(r,t,n,i){const s=i?r.toLowerCase():r,a=i?n.toLowerCase():n;switch(t){case"contains":return s.includes(a);case"not_contains":return!s.includes(a);case"regex_matches":try{return new RegExp(n).test(s)}catch{return!1}default:return de(s,t,a)}}function St(r,t){return r.length===1?t(r[0]):(Fe.default(r[0].type==="NEGATION"),!t(r[1]))}function Le(r){if(!["INT","IDENTIFIER"].includes(r.type))throw new SyntaxError(`Invalid token type: ${r.type}; expected IDENTIFIER or INT`);return R(r)}function R(r){var t,n;switch(r.type){case"IDENTIFIER":return r.value;case"INT":return parseInt(r.value,10);case"STRING":{const i=r.value.match(/(?:'(?<single>[^\']*)')|(?:"(?<double>[^\"]*)")/),s=((t=i==null?void 0:i.groups)==null?void 0:t.double)||((n=i==null?void 0:i.groups)==null?void 0:n.single);return Fe.default(s),s}case"OPERATOR":return r.value;case"TRUE":return!0;case"FALSE":return!1;default:throw new SyntaxError(`Invalid token type: ${r.type}`)}}function Ce(r,t){const n={start:i=>i[0],top_level_expr:Ot,bool_expr:Ot,condition:i=>i[0],qc_mc_selected:i=>St(i,s=>t.isSelected(s)),qc_mc_text:i=>At(t.textEntry(i[0]),R(i[1]),R(i[2]),!1),qc_mc_text_ignore_case:i=>At(t.textEntry(i[0]),R(i[1]),R(i[2]),!0),qc_mc_count:i=>de(t.countSelected(i[0]),R(i[1]),R(i[2])),qc_matrix_selected:i=>St(i,s=>t.isSelected(s)),qc_selected_value:i=>{const s=t.selectedValue(i[0]);return s!==null&&de(s,R(i[1]),R(i[2]))},qc_matrix_count:i=>de(t.countChoiceSelections(i[0],Le(i[1])),R(i[2]),R(i[3])),question_selector:i=>i[0].value,question_or_matrix_statement_selector:i=>typeof i[0]=="string"?{questionId:i[0]}:i[0],mc_choice_selector:i=>({questionId:i[0],choice:Le(i[1])}),matrix_statement_selector:i=>({questionId:i[0],statementId:R(i[1])}),matrix_choice_selector:i=>({...i[0],choice:Le(i[1])}),bool_const:i=>i[0].value==="true"};return Tr.get_parser({transformer:n}).parse(r)}const Pr=/\$\{m:([^\}]+)\}/g,Dr=100,Qe=(r,t)=>{if(typeof t=="string"){let n=t,i=0;for(;i<Dr;){const s=n.replace(Pr,(a,o)=>{if(r[o]===void 0)throw new Error(`Undefined macro: ${o}`);return r[o]});if(s===n)return s;n=s,i+=1}throw new Error(`Failed to finish interpolate macros - cyclic macros!? Stuck at: ${t}"`)}return typeof t=="object"&&Object.keys(t).forEach(n=>{t[n]=Qe(r,t[n])}),t},$t=r=>(r.sections=Qe(r.macros||{},r.sections),r);var Lr=Object.defineProperty,Cr=(r,t,n)=>t in r?Lr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,C=(r,t,n)=>(Cr(r,typeof t!="symbol"?t+"":t,n),n);const zt=new Gt.default({allowUnionTypes:!0});Wt.default(zt);const Pt=zt.compile(Ge);class K extends Error{}class $ extends Error{}class he extends Error{}class Q extends Error{}class Qr extends Error{}class Mr{constructor(){C(this,"seenQuestions",new Set),C(this,"seenMultiQuestions",new Set),C(this,"seenQuestionStatements",new Map),C(this,"seenQuestionChoices",new Map),C(this,"seenTextChoices",new Map),C(this,"evaluator",{}),C(this,"validateReference",t=>{var n,i,s;if(!this.seenQuestions.has(t.questionId))throw new K(`Invalid question: ${t.questionId}`);if(t.statementId!==void 0&&!((n=this.seenQuestionStatements.get(t.questionId))!=null&&n.has(t.statementId)))throw new K(`Invalid statement: ${t.questionId}.${t.statementId}`);if(t.choice!==void 0&&!((i=this.seenQuestionChoices.get(t.questionId))!=null&&i.has(t.choice)))throw new K(`Invalid choice: ${t.questionId}[${t.choice}]`);if(t.choice!==void 0&&t.expectText===!0&&!((s=this.seenTextChoices.get(t.questionId))!=null&&s.has(t.choice)))throw new K(`Invalid text reference: ${t.questionId}[${t.choice}]`);if(typeof t.expectMulti=="boolean"&&t.expectMulti&&!this.seenMultiQuestions.has(t.questionId))throw new $(`Invalid question reference: ${t.questionId}. Expected a multi-answer question.`);if(typeof t.expectMulti=="boolean"&&!t.expectMulti&&this.seenMultiQuestions.has(t.questionId))throw new $(`Invalid question reference: ${t.questionId}. Expected a non-multi-answer question.`)}),this.evaluator.isSelected=t=>(this.validateReference(t),!1),this.evaluator.countSelected=t=>(this.validateReference({questionId:t}),0),this.evaluator.selectedValue=t=>(this.validateReference({questionId:t.questionId,statementId:t.statementId,expectMulti:!1}),0),this.evaluator.countChoiceSelections=(t,n)=>(this.validateReference({questionId:t,choice:n}),0),this.evaluator.textEntry=t=>(this.validateReference({...t,expectText:!0}),"")}}const F=(r,t,n)=>{if(n)try{Ce(n,r.evaluator)}catch(i){throw i instanceof K||i instanceof $||i instanceof Q?i:new Error(`Syntax error parsing display logic at ${t}: ${n}`)}},jr=(r,t)=>{[...t.matchAll(De)].forEach(n=>{var i;const s=L(n.groups.locator);if(!r.seenQuestions.has(s.questionId))throw new $(`Invalid question referenced in locator expression: ${s.questionId}/${s.expression}`);if(s.identifier&&!((i=r.seenQuestionChoices.get(s.questionId))!=null&&i.has(s.identifier)))throw new $(`Invalid question choice referenced in locator expression: ${s.questionId}/${s.expression}(${s.identifier})`)})},B=(r,t,n)=>{if(n){const i=new Set(t);if(n.order){const s=n.order.split(" "),a=s.filter(o=>o==="$").length;if(a===0)throw new he(`Wildcard $ is missing in randomization order at ${r.id}`);if(a>1)throw new he(`Wildcard $ occurred multiples times in randomization order at ${r.id}`);if(s.forEach(o=>{if(o!=="$"&&!i.has(o))throw new he(`Unknown id ${o} in randomization ordering at ${r.id}`)}),n.total!==void 0&&n.total<s.length)throw new he(`Total value in randomization is too small at ${r.id}`)}}},Dt=(r,t)=>{const n=[T.FOR_MATRIX_CHOICE,T.UNSELECTED_FOR_MATRIX_CHOICE].includes(r.expression),i=(n?t.seenQuestionStatements:t.seenQuestionChoices).get(r.questionId);if(i===void 0)throw new $(`Invalid question referenced in locator expression: ${r.questionId}/${r.expression}`);if(n){const s=t.seenQuestionChoices.get(r.questionId);if(!r.identifier||!(s!=null&&s.has(r.identifier)))throw new $(`Invalid choice referenced in locator expression: ${r.questionId}/${r.expression}(${r.identifier})`)}return i},Ur=(r,t)=>{var n,i,s,a,o,l,c,_,p,y,v;if(jr(t,r.text),r.id!==void 0){if(F(t,r.id,r.display_logic),(n=r.statements)==null||n.forEach(u=>{F(t,`${r.id}.${u.id}`,u.display_logic)}),(i=r.choices)==null||i.forEach(u=>{F(t,`${r.id}[${u.id||u.value}]`,u.display_logic)}),r.type==="matrix-multi"||r.type==="matrix-single"?r.statement_groups?B(r,r.statement_groups.map(u=>u.id),r.randomization):B(r,(a=(s=r.statements)==null?void 0:s.map(u=>u.id))!=null?a:[],r.randomization):r.choice_groups?B(r,r.choice_groups.map(u=>u.id),r.randomization):B(r,(l=(o=r.choices)==null?void 0:o.map(u=>`${u.id||u.value}`))!=null?l:[],r.randomization),(c=r.statement_groups)==null||c.forEach(u=>{u.statements.forEach(d=>{F(t,`${r.id}.${d.id}`,d.display_logic)}),B(r,u.statements.map(d=>d.id),u.randomization)}),(_=r.choice_groups)==null||_.forEach(u=>{u.choices.forEach(d=>{F(t,`${r.id}[${d.id||d.value}]`,d.display_logic)}),B(r,u.choices.map(d=>`${d.id||d.value}`),u.randomization)}),t.seenQuestions.has(r.id))throw new Q(`Duplicate question id: ${r.id}`);if(t.seenQuestions.add(r.id),r.type&&["matrix-multi","mc-multi"].includes(r.type)&&t.seenMultiQuestions.add(r.id),r.statements||r.dynamic_statements){const u=new Set;if(t.seenQuestionStatements.set(r.id,u),(p=r.statements)==null||p.forEach(d=>{if(u.has(d.id))throw new Q(`Duplicate statement id: ${r.id}.${d.id}`);u.add(d.id)}),r.dynamic_statements){const d=L(r.dynamic_statements);Dt(d,t).forEach(m=>{if(typeof m=="number")throw new $(`Dynamic statement in question ${r.id} refers to choices with values`);if(u.has(m))throw new Q(`Duplicate statement ${m} via dynamic statements in question ${r.id}`);u.add(m)})}}const w=(y=r.choices)!=null?y:[];if(r.choice_groups){if(new Set(r.choice_groups.map(u=>u.id)).size!==r.choice_groups.length)throw new Q(`Choice groups must have a unique id in question ${r.id}`);r.choice_groups.forEach(u=>w.push(...u.choices))}if(w||r.dynamic_choices){const u=new Set;t.seenQuestionChoices.set(r.id,u);const d=new Set;if(t.seenTextChoices.set(r.id,d),w.forEach(m=>{var b;const q=(b=m.id)!=null?b:m.value;if(u.has(q))throw new Q(`Duplicate choice: ${r.id}[${q}]`);u.add(q),m.text_input&&m.text_input!=="no"&&d.add(q)}),r.dynamic_choices){const m=L(r.dynamic_choices);Dt(m,t).forEach(b=>{if(u.has(b))throw new Q(`Duplicate choice ${b} via dynamic choices in ${r.id}`);u.add(b)}),(v=t.seenTextChoices.get(m.questionId))==null||v.forEach(b=>d.add(b))}if(new Set([...u].map(m=>typeof m)).size>=2)throw new Qr("All choices in a question must either all have id's or all have values")}}},Fr=r=>{if(!Pt(r))throw new Error(`Invalid template: ${r.template.id}. Reason: ${JSON.stringify(Pt.errors,null,4)}`);$t(r);const t=new Mr;r.sections.forEach(n=>{F(t,n.id,n.display_logic),n.pages.forEach(i=>{var s;(s=i.questions)==null||s.forEach(a=>{Ur(a,t)})})})};function Br(r,t){const n=structuredClone(r);return{...n,sections:n.sections.map(i=>({id:i.id,name:i.name,hideProgressBar:i.hideProgressBar,pages:t.evaluateDisplayLogic(i.displayLogic)?i.pages.map(s=>({...s,questions:Zr(s.questions,t)})).filter(s=>s.questions.length):[]})).filter(i=>i.pages.length)}}function Zr(r,t){return r.filter(n=>t.evaluateDisplayLogic(n.displayLogic)).map(n=>({...n,text:t.getQuestionText(n),statements:t.getQuestionStatements(n),choices:t.getQuestionChoices(n),statementGroups:t.getQuestionStatementGroups(n),choiceGroups:t.getQuestionChoiceGroups(n),randomization:void 0}))}const Gr=r=>!!(r!=null&&r.singleAnswer)||!!(r!=null&&r.multipleAnswers)&&(r==null?void 0:r.multipleAnswers.length)>0,Wr=Ge,Vr="pulse_default_alpha",Xr={allPermissions:Ht,SURVEY_RESOURCE_TYPE:Xt,surveyAdministerPermission:Be};exports.DEFAULT_TEMPLATE_ID=Vr,exports.LOCATOR_EXPRESSION=T,exports.QUESTION_TEXT_LOCATOR_PATTERN=De,exports.TemplateContextEvaluator=zr,exports.evaluateExpression=Ce,exports.evaluateTemplateNode=Br,exports.extractQuestionNodes=kt,exports.getExperimentalOptionalBoolean=Jt,exports.getExperimentalOptionalString=Yt,exports.getQualifiedQuestionId=Nt,exports.getQuestionTypeEnum=Rt,exports.getRandomizationTypeEnum=Et,exports.getRawQuestionId=ze,exports.getTemplateNode=Rr,exports.hasAnswer=Gr,exports.interpolateMacros=Qe,exports.interpolateTemplate=$t,exports.parseLocator=L,exports.permissions=Xr,exports.polyfillStructuredClone=Kt,exports.templateSchema=Wr,exports.transformCase=ce,exports.validateLocator=bt,exports.validateTemplate=Fr;
23
23
  //# sourceMappingURL=index.cjs.js.map
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import{createPermission as Dt}from"@backstage/plugin-permission-common";import Pt from"@ungap/structured-clone";import Lt from"ajv";import Ct from"ajv-formats";import Ue from"assert";import ee from"lodash";import*as Qt from"crypto";const Mt="survey-instance",Fe=Dt({name:"survey.instance.administer",attributes:{action:"create"}}),jt=[Fe],Ut=()=>{"structuredClone"in globalThis||(globalThis.structuredClone=Pt)};var Ft="surveyTemplate",Zt="http://json-schema.org/draft-07/schema",Bt="Survey Template",Gt="object",Wt={template:{type:"object",description:"Meta data about the survey template",properties:{id:{type:"string",description:"An id of the survey template. If there are multiple templates with the same id, they must have different versions.",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$",minLength:1},version:{type:"string",format:"regex",pattern:"^[0-9]+(\\.[0-9]+)?$",description:"A version of template"},name:{type:"string",description:"The display name of the survey template",minLength:1},description:{type:"string",description:"A longer description of the survey template"},owner:{type:"string",description:"The owner of the survey template",minLength:1}},required:["id","version","name","owner"],additionalProperties:!1},parameters:{type:"array",description:"Template parameters that can or must be set when creating a survey from this template. Parameters are referred to elsewhere in the survey using the ${p:<id>} construct and will get lazily in-place replaced.",items:{type:"object",properties:{id:{type:"string",description:"The id of the parameter",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},description:{type:"string",description:"The description of the parameter"},format:{type:"string",enum:["string","number","boolean"],description:"The format of the parameter. Should only be set if a default value is not provided."},default:{type:["string","number","boolean"],description:"An optional default value of this parameter. If this is omitted, the parameter must be provided when creating a survey from the template."}},required:["id","description"],oneOf:[{required:["format"]},{required:["default"]}],additionalProperties:!1}},macros:{type:"object",description:"Expression shortcuts. Macros are referred to elsewhere in the survey using the ${m:<name>} construct (similar to parameters) and will get lazily in-place replaced. Macros can be recursive and contain references to parameters or answers in the survey.",additionalProperties:{type:"string"}},sections:{type:"array",description:"The survey sections, in the order they will appear in the survey",items:{$ref:"#/$defs/section"}}},Vt=!1,Xt=["template","parameters","sections"],Ht={section:{type:"object",description:"A survey section.",properties:{id:{type:"string",description:"The id of this section",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$"},name:{type:"string",description:"The name of this section"},display_logic:{type:"string",description:"An optional boolean expression that decides if the surveyee should see the questions in this section."},hide_progress_bar:{type:"boolean",description:"When set, the survey progress bar will not be shown during this section."},pages:{type:"array",description:"The questions in the section, split into pages",items:{$ref:"#/$defs/page"}}},additionalProperties:!1,required:["id","name","pages"]},page:{type:"object",properties:{questions:{type:"array",description:"The questions on the page",items:{$ref:"#/$defs/question"}}},required:["questions"],additionalProperties:!1},question:{type:"object",properties:{id:{type:"string",description:"The unique ID of the question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},text:{type:"string",description:"The question description, in markdown"},type:{type:"string",enum:["mc-single","mc-multi","matrix-single","matrix-multi","text-single","text-multi","description"],description:"The type of question"},layout:{type:"string",enum:["vertical","horizontal"],description:"Determines the visual layout of the options in multiple choice questions"},display_logic:{type:"string",description:"A boolean expression with logic if this question should be displayed or not"},required:{type:"string",enum:["required","optional","request"],description:"If the question is required to answer; request means you will get a warning if you skip it but you can."},validation:{type:"object",description:"Validation constraints on the question. Only applied if the user has answered the question, so typically used in combination with required",properties:{min_choices:{type:"integer",description:"The minimum number of choices to user can pick (multiple choice questions only)"},max_choices:{type:"integer",description:"The maximum number of choices to user can pick (multiple choice questions only)"}},additionalProperties:!1},statements:{type:"array",items:{$ref:"#/$defs/statement"}},dynamic_statements:{type:"string",description:"Carry forward statements from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},statement_groups:{type:"array",items:{type:"object",properties:{statements:{type:"array",items:{$ref:"#/$defs/statement"}},id:{type:"string",description:"The id of the group."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["statements","id","display"],additionalProperties:!1}},choices:{type:"array",items:{$ref:"#/$defs/choice"}},dynamic_choices:{type:"string",description:"Carry forward choices from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},choice_groups:{type:"array",items:{type:"object",properties:{choices:{type:"array",items:{$ref:"#/$defs/choice"}},id:{type:"string",description:"The id of the group."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["choices","id","display"],additionalProperties:!1}},randomization:{$ref:"#/$defs/randomization"},configuration:{type:"object",properties:{choice_column_width_pixels:{type:"integer",description:"Size of the column with the choice descriptions in a matrix question"}},additionalProperties:!1}},additionalProperties:!1,required:["text"],oneOf:[{$ref:"#/$defs/question-mc-horizontal"},{$ref:"#/$defs/question-mc-vertical"},{$ref:"#/$defs/question-matrix"},{$ref:"#/$defs/question-text"},{$ref:"#/$defs/question-description"}]},"question-mc-horizontal":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"horizontal"}},required:["id","type","position","choices"],not:{anyOf:[{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]}},"question-mc-vertical":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"vertical"}},required:["id","type"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]},oneOf:[{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}],not:{required:["choice_groups"]}},{required:["choice_groups"],not:{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}]}}]},"question-matrix":{type:"object",properties:{type:{enum:["matrix-single","matrix-multi"]}},required:["id","type","choices"],not:{anyOf:[{required:["dynamic_choices"]},{required:["choice_groups"]}]},oneOf:[{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}],not:{required:["statement_groups"]}},{required:["statement_groups"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}]}}]},"question-text":{type:"object",properties:{type:{enum:["text-single","text-multi"]}},required:["id","type"],not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},"question-description":{type:"object",properties:{type:{const:"description"}},not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},statement:{type:"object",properties:{id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the statement"},display:{type:"string",description:"The statement name, as shown to the surveyee"},display_logic:{type:"string",description:"A boolean expression determining if the statement should be displayed"}},required:["id","display"],additionalProperties:!1},choice:{type:"object",properties:{display:{type:"string",description:"The choice name, as shown to the surveyee"},id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the choice"},value:{type:"integer",description:"The value the choice"},display_logic:{type:"string",description:"A boolean expression determining if the choice should be displayed"},text_input:{type:"string",enum:["no","optional","forced"],description:"If a textbox should appear next to the choice, and if it should be mandatory to fill it in if the choice is selected"},exclusive_answer:{type:"boolean",description:"If true, this choice can't be combined with other choices in this question"}},required:["display"],oneOf:[{required:["value"]},{required:["id"]}],additionalProperties:!1},randomization:{type:"object",description:"Configuration of the display order randomization of choices, statements or groups.",properties:{type:{type:"string",description:"The type of randomization: randomize all items, a subset of them, or using constrained randomization",enum:["all","subset","constrained"]},total:{type:"integer",description:"Maximum number of items to show"},order:{type:"string",description:"A space separated string containing the order of the items; each 'word' is either an id of some item or the wildcard $ representing the remaining items"}},required:["type"],oneOf:[{properties:{type:{const:"all"}},not:{required:["total","order"]}},{properties:{type:{const:"subset"}},required:["total"],not:{required:["order"]}},{properties:{type:{const:"constrained"}},required:["order"]}],additionalProperties:!1}},Ze={$id:Ft,$schema:Zt,title:Bt,type:Gt,properties:Wt,additionalProperties:Vt,required:Xt,$defs:Ht},Jt=(r=>(r.DuplicateResponse="DUPLICATE_RESPONSE",r.InternalError="INTERNAL_ERROR",r.InvalidDates="INVALID_DATES",r.InvalidId="INVALID_ID",r.InvalidParticipants="INVALID_PARTICIPANTS",r.InvalidResponse="INVALID_RESPONSE",r.MissingTitle="MISSING_TITLE",r.OverlappingSurveys="OVERLAPPING_SURVEYS",r.ParticipantsFrozen="PARTICIPANTS_FROZEN",r.SurveyIsClosed="SURVEY_IS_CLOSED",r.Unauthorized="UNAUTHORIZED",r))(Jt||{}),Yt=(r=>(r.Horizontal="HORIZONTAL",r.Vertical="VERTICAL",r))(Yt||{}),Kt=(r=>(r.Optional="OPTIONAL",r.Request="REQUEST",r.Required="REQUIRED",r))(Kt||{}),de=(r=>(r.Description="DESCRIPTION",r.MatrixMulti="MATRIX_MULTI",r.MatrixSingle="MATRIX_SINGLE",r.McMulti="MC_MULTI",r.McSingle="MC_SINGLE",r.TextMulti="TEXT_MULTI",r.TextSingle="TEXT_SINGLE",r))(de||{}),en=(r=>(r.All="ALL",r.Constrained="CONSTRAINED",r.Subset="SUBSET",r))(en||{}),tn=(r=>(r.Finalized="FINALIZED",r.Partial="PARTIAL",r))(tn||{}),nn=(r=>(r.Active="ACTIVE",r.Published="PUBLISHED",r))(nn||{}),rn=(r=>(r.Q1="Q1",r.Q2="Q2",r.Q3="Q3",r.Q4="Q4",r))(rn||{}),sn=Object.defineProperty,an=(r,t,n)=>t in r?sn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,R=(r,t,n)=>(an(r,typeof t!="symbol"?t+"":t,n),n);function on(r={}){return r.transformer&&r.transformer.constructor.name==="object"&&(r.transformer=Y.fromObj(r.transformer)),yt._load_from_dict({data:pr,memo:ur,...r})}const Be={};class Ge{}const te={},We={escape(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},compile(r,t){return new RegExp(r,t)},error:SyntaxError};function ln(r,t,n,i){const s=r.compile(t,i).exec(n);if(s!=null)return s[0]}class Ve{constructor(t,n,i,s,a=!1){this.terminals=t,this.g_regex_flags=n,this.re_=i,this.use_bytes=s,this.match_whole=a,this.allowed_types=new Set(this.terminals.map(o=>o.name)),this._regexps=this._build_mres(t)}_build_mres(t){let n=this.match_whole?"$":"",i=fn(t,a=>a.pattern.flags.join("")),s=[];for(let[a,o]of i){const l=o.map(c=>`(?<${c.name}>${c.pattern.to_regexp()+n})`).join("|");s.push(new RegExp(l,this.g_regex_flags+a+"y"))}return s}match(t,n){for(const i of this._regexps){i.lastIndex=n;let s=i.exec(t);if(s){let a=null;for(let[o,l]of Object.entries(s.groups))if(l){a=o;break}return[s[0],a]}}}}const Xe=typeof require!="undefined"&&require("util");class He{}const X={};function x(r){return Object.entries(r)}function me(r){return Object.keys(r)}function _n(r,t){t===void 0&&(t=Object.keys(r)[0]);let n=r[t];return delete r[t],n}function Je(r,t,n=null){return r[t]||n}function Ye(r,t){if(r.constructor.name==="Map")for(const[n,i]of x(t))r.set(n,i);else for(const[n,i]of x(t))r[n]=i}function cn(r){return function(){return new r(...arguments)}}function d(r){let t=0,n=[...arguments].slice(1);return r.replace(/%([sr])/g,function(){const i=arguments[1],s=n[t++];return i==="r"?Xe?Xe.inspect(s,!1,null,!0):JSON.stringify(s,null,0):s})}function pn(r,t){let n=new Set(r);for(const i of t)n.add(i);return n}function Ke(r,t){return[...r].filter(n=>!t.has(n))}function et(r){return{...r}}function tt(r){return!!r}function fe(r){return Object.create(r.prototype)}function I(r){if(typeof r=="object"){let t=Object.create(Object.getPrototypeOf(r));return Object.assign(t,r)}return r}function ne(r){return new Set(r)}function ye(r){return r&&r.constructor.name==="Object"}function un(r){return r&&r.constructor.name==="Array"}function hn(r){return typeof r=="function"}function*H(r,t=0){let n=t;for(const i of r)yield[n++,i]}function dn(r){for(const t of r)if(t)return!0;return!1}function nt(r,t){return t.filter(r||tt)}function re(r){let t=[...arguments].slice(1);return function(){return r(...t,...arguments)}}class ge extends Error{}function E(r){return r[r.length-1]}function P(r){return function(){let t=new r(...arguments);return t.__call__.bind(t)}}function O(r,t){return Array.from({length:t},()=>r).flat()}function rt(r){return/^[A-Z_$]*$/.test(r)}function xe(r,t,n){const i=r.split(t);return n?i.splice(-n-1):i}function we(r,t){let n=new RegExp(t,"g");return(r.match(n)||[]).length}function mn(r,t){for(let n of r)if(!t.has(n))return!1;return!0}function*fn(r,t){let n=[],i=null;for(const s of r){const a=t(s);i&&a!=i&&(yield[i,n],n=[]),n.push(s),i=a}yield[i,n]}class S extends Error{}class A extends S{}function Te(r,t,n="Got %r, expected one of %s"){if(!t.includes(r))throw new A(d(n,r,t))}class ie extends S{}class yn extends S{}class J extends S{}class z extends S{constructor(){super(...arguments),R(this,"pos_in_stream",null),R(this,"_terminals_by_name",null)}get_context(t,n=40){let i,s,a=this.pos_in_stream,o=max(a-n,0),l=a+n;return t instanceof bytes?(s=E(xe(t.slice(o,a),`
1
+ import{createPermission as Pt}from"@backstage/plugin-permission-common";import Lt from"@ungap/structured-clone";import Ct from"ajv";import Qt from"ajv-formats";import Ue from"assert";import K from"lodash";import*as Mt from"crypto";const jt="survey-instance",Fe=Pt({name:"survey.instance.administer",attributes:{action:"create"}}),Ut=[Fe],Ze="pulse.experimentalFlags",Ft=(r,t)=>{const n=r.getOptionalStringArray(Ze);return n==null?void 0:n.includes(t)},Zt=(r,t)=>{var n;const i=r.getOptionalStringArray(Ze),s=`${t}=`;return(n=i==null?void 0:i.find(a=>a.startsWith(s)))==null?void 0:n.replace(s,"")},Bt=()=>{"structuredClone"in globalThis||(globalThis.structuredClone=Lt)};var Gt="surveyTemplate",Wt="http://json-schema.org/draft-07/schema",Vt="Survey Template",Xt="object",Ht={template:{type:"object",description:"Meta data about the survey template",properties:{id:{type:"string",description:"An id of the survey template. If there are multiple templates with the same id, they must have different versions.",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$",minLength:1},version:{type:"string",format:"regex",pattern:"^[0-9]+(\\.[0-9]+)?$",description:"A version of template"},name:{type:"string",description:"The display name of the survey template",minLength:1},description:{type:"string",description:"A longer description of the survey template"},owner:{type:"string",description:"The owner of the survey template",minLength:1}},required:["id","version","name","owner"],additionalProperties:!1},parameters:{type:"array",description:"Template parameters that can or must be set when creating a survey from this template. Parameters are referred to elsewhere in the survey using the ${p:<id>} construct and will get lazily in-place replaced.",items:{type:"object",properties:{id:{type:"string",description:"The id of the parameter",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},description:{type:"string",description:"The description of the parameter"},format:{type:"string",enum:["string","number","boolean"],description:"The format of the parameter. Should only be set if a default value is not provided."},default:{type:["string","number","boolean"],description:"An optional default value of this parameter. If this is omitted, the parameter must be provided when creating a survey from the template."}},required:["id","description"],oneOf:[{required:["format"]},{required:["default"]}],additionalProperties:!1}},macros:{type:"object",description:"Expression shortcuts. Macros are referred to elsewhere in the survey using the ${m:<name>} construct (similar to parameters) and will get lazily in-place replaced. Macros can be recursive and contain references to parameters or answers in the survey.",additionalProperties:{type:"string"}},sections:{type:"array",description:"The survey sections, in the order they will appear in the survey",items:{$ref:"#/$defs/section"}}},Jt=!1,Yt=["template","parameters","sections"],Kt={section:{type:"object",description:"A survey section.",properties:{id:{type:"string",description:"The id of this section",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$"},name:{type:"string",description:"The name of this section"},display_logic:{type:"string",description:"An optional boolean expression that decides if the surveyee should see the questions in this section."},hide_progress_bar:{type:"boolean",description:"When set, the survey progress bar will not be shown during this section."},pages:{type:"array",description:"The questions in the section, split into pages",items:{$ref:"#/$defs/page"}}},additionalProperties:!1,required:["id","name","pages"]},page:{type:"object",properties:{questions:{type:"array",description:"The questions on the page",items:{$ref:"#/$defs/question"}}},required:["questions"],additionalProperties:!1},question:{type:"object",properties:{id:{type:"string",description:"The unique ID of the question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},text:{type:"string",description:"The question description, in markdown"},type:{type:"string",enum:["mc-single","mc-multi","matrix-single","matrix-multi","text-single","text-multi","description"],description:"The type of question"},layout:{type:"string",enum:["vertical","horizontal"],description:"Determines the visual layout of the options in multiple choice questions"},display_logic:{type:"string",description:"A boolean expression with logic if this question should be displayed or not"},required:{type:"string",enum:["required","optional","request"],description:"If the question is required to answer; request means you will get a warning if you skip it but you can."},validation:{type:"object",description:"Validation constraints on the question. Only applied if the user has answered the question, so typically used in combination with required",properties:{min_choices:{type:"integer",description:"The minimum number of choices to user can pick (multiple choice questions only)"},max_choices:{type:"integer",description:"The maximum number of choices to user can pick (multiple choice questions only)"}},additionalProperties:!1},statements:{type:"array",items:{$ref:"#/$defs/statement"}},dynamic_statements:{type:"string",description:"Carry forward statements from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},statement_groups:{type:"array",items:{type:"object",properties:{statements:{type:"array",items:{$ref:"#/$defs/statement"}},id:{type:"string",description:"The id of the group."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["statements","id","display"],additionalProperties:!1}},choices:{type:"array",items:{$ref:"#/$defs/choice"}},dynamic_choices:{type:"string",description:"Carry forward choices from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},choice_groups:{type:"array",items:{type:"object",properties:{choices:{type:"array",items:{$ref:"#/$defs/choice"}},id:{type:"string",description:"The id of the group."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["choices","id","display"],additionalProperties:!1}},randomization:{$ref:"#/$defs/randomization"},configuration:{type:"object",properties:{choice_column_width_pixels:{type:"integer",description:"Size of the column with the choice descriptions in a matrix question"}},additionalProperties:!1}},additionalProperties:!1,required:["text"],oneOf:[{$ref:"#/$defs/question-mc-horizontal"},{$ref:"#/$defs/question-mc-vertical"},{$ref:"#/$defs/question-matrix"},{$ref:"#/$defs/question-text"},{$ref:"#/$defs/question-description"}]},"question-mc-horizontal":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"horizontal"}},required:["id","type","position","choices"],not:{anyOf:[{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]}},"question-mc-vertical":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"vertical"}},required:["id","type"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]},oneOf:[{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}],not:{required:["choice_groups"]}},{required:["choice_groups"],not:{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}]}}]},"question-matrix":{type:"object",properties:{type:{enum:["matrix-single","matrix-multi"]}},required:["id","type","choices"],not:{anyOf:[{required:["dynamic_choices"]},{required:["choice_groups"]}]},oneOf:[{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}],not:{required:["statement_groups"]}},{required:["statement_groups"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}]}}]},"question-text":{type:"object",properties:{type:{enum:["text-single","text-multi"]}},required:["id","type"],not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},"question-description":{type:"object",properties:{type:{const:"description"}},not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},statement:{type:"object",properties:{id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the statement"},display:{type:"string",description:"The statement name, as shown to the surveyee"},display_logic:{type:"string",description:"A boolean expression determining if the statement should be displayed"}},required:["id","display"],additionalProperties:!1},choice:{type:"object",properties:{display:{type:"string",description:"The choice name, as shown to the surveyee"},id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the choice"},value:{type:"integer",description:"The value the choice"},display_logic:{type:"string",description:"A boolean expression determining if the choice should be displayed"},text_input:{type:"string",enum:["no","optional","forced"],description:"If a textbox should appear next to the choice, and if it should be mandatory to fill it in if the choice is selected"},exclusive_answer:{type:"boolean",description:"If true, this choice can't be combined with other choices in this question"}},required:["display"],oneOf:[{required:["value"]},{required:["id"]}],additionalProperties:!1},randomization:{type:"object",description:"Configuration of the display order randomization of choices, statements or groups.",properties:{type:{type:"string",description:"The type of randomization: randomize all items, a subset of them, or using constrained randomization",enum:["all","subset","constrained"]},total:{type:"integer",description:"Maximum number of items to show"},order:{type:"string",description:"A space separated string containing the order of the items; each 'word' is either an id of some item or the wildcard $ representing the remaining items"}},required:["type"],oneOf:[{properties:{type:{const:"all"}},not:{required:["total","order"]}},{properties:{type:{const:"subset"}},required:["total"],not:{required:["order"]}},{properties:{type:{const:"constrained"}},required:["order"]}],additionalProperties:!1}},Be={$id:Gt,$schema:Wt,title:Vt,type:Xt,properties:Ht,additionalProperties:Jt,required:Yt,$defs:Kt},en=(r=>(r.DuplicateResponse="DUPLICATE_RESPONSE",r.InternalError="INTERNAL_ERROR",r.InvalidDates="INVALID_DATES",r.InvalidId="INVALID_ID",r.InvalidParticipants="INVALID_PARTICIPANTS",r.InvalidResponse="INVALID_RESPONSE",r.MissingTitle="MISSING_TITLE",r.OverlappingSurveys="OVERLAPPING_SURVEYS",r.ParticipantsFrozen="PARTICIPANTS_FROZEN",r.SurveyIsClosed="SURVEY_IS_CLOSED",r.Unauthorized="UNAUTHORIZED",r))(en||{}),tn=(r=>(r.Horizontal="HORIZONTAL",r.Vertical="VERTICAL",r))(tn||{}),nn=(r=>(r.Optional="OPTIONAL",r.Request="REQUEST",r.Required="REQUIRED",r))(nn||{}),de=(r=>(r.Description="DESCRIPTION",r.MatrixMulti="MATRIX_MULTI",r.MatrixSingle="MATRIX_SINGLE",r.McMulti="MC_MULTI",r.McSingle="MC_SINGLE",r.TextMulti="TEXT_MULTI",r.TextSingle="TEXT_SINGLE",r))(de||{}),rn=(r=>(r.All="ALL",r.Constrained="CONSTRAINED",r.Subset="SUBSET",r))(rn||{}),sn=(r=>(r.Finalized="FINALIZED",r.Partial="PARTIAL",r))(sn||{}),an=(r=>(r.Active="ACTIVE",r.Published="PUBLISHED",r))(an||{}),on=(r=>(r.Q1="Q1",r.Q2="Q2",r.Q3="Q3",r.Q4="Q4",r))(on||{}),ln=Object.defineProperty,_n=(r,t,n)=>t in r?ln(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,R=(r,t,n)=>(_n(r,typeof t!="symbol"?t+"":t,n),n);function cn(r={}){return r.transformer&&r.transformer.constructor.name==="object"&&(r.transformer=X.fromObj(r.transformer)),gt._load_from_dict({data:dr,memo:mr,...r})}const Ge={};class We{}const ee={},Ve={escape(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},compile(r,t){return new RegExp(r,t)},error:SyntaxError};function pn(r,t,n,i){const s=r.compile(t,i).exec(n);if(s!=null)return s[0]}class Xe{constructor(t,n,i,s,a=!1){this.terminals=t,this.g_regex_flags=n,this.re_=i,this.use_bytes=s,this.match_whole=a,this.allowed_types=new Set(this.terminals.map(o=>o.name)),this._regexps=this._build_mres(t)}_build_mres(t){let n=this.match_whole?"$":"",i=xn(t,a=>a.pattern.flags.join("")),s=[];for(let[a,o]of i){const l=o.map(c=>`(?<${c.name}>${c.pattern.to_regexp()+n})`).join("|");s.push(new RegExp(l,this.g_regex_flags+a+"y"))}return s}match(t,n){for(const i of this._regexps){i.lastIndex=n;let s=i.exec(t);if(s){let a=null;for(let[o,l]of Object.entries(s.groups))if(l){a=o;break}return[s[0],a]}}}}const He=typeof require!="undefined"&&require("util");class Je{}const G={};function x(r){return Object.entries(r)}function me(r){return Object.keys(r)}function un(r,t){t===void 0&&(t=Object.keys(r)[0]);let n=r[t];return delete r[t],n}function Ye(r,t,n=null){return r[t]||n}function Ke(r,t){if(r.constructor.name==="Map")for(const[n,i]of x(t))r.set(n,i);else for(const[n,i]of x(t))r[n]=i}function hn(r){return function(){return new r(...arguments)}}function d(r){let t=0,n=[...arguments].slice(1);return r.replace(/%([sr])/g,function(){const i=arguments[1],s=n[t++];return i==="r"?He?He.inspect(s,!1,null,!0):JSON.stringify(s,null,0):s})}function dn(r,t){let n=new Set(r);for(const i of t)n.add(i);return n}function et(r,t){return[...r].filter(n=>!t.has(n))}function tt(r){return{...r}}function nt(r){return!!r}function fe(r){return Object.create(r.prototype)}function I(r){if(typeof r=="object"){let t=Object.create(Object.getPrototypeOf(r));return Object.assign(t,r)}return r}function te(r){return new Set(r)}function ye(r){return r&&r.constructor.name==="Object"}function mn(r){return r&&r.constructor.name==="Array"}function fn(r){return typeof r=="function"}function*W(r,t=0){let n=t;for(const i of r)yield[n++,i]}function yn(r){for(const t of r)if(t)return!0;return!1}function rt(r,t){return t.filter(r||nt)}function ne(r){let t=[...arguments].slice(1);return function(){return r(...t,...arguments)}}class ge extends Error{}function E(r){return r[r.length-1]}function P(r){return function(){let t=new r(...arguments);return t.__call__.bind(t)}}function O(r,t){return Array.from({length:t},()=>r).flat()}function it(r){return/^[A-Z_$]*$/.test(r)}function xe(r,t,n){const i=r.split(t);return n?i.splice(-n-1):i}function we(r,t){let n=new RegExp(t,"g");return(r.match(n)||[]).length}function gn(r,t){for(let n of r)if(!t.has(n))return!1;return!0}function*xn(r,t){let n=[],i=null;for(const s of r){const a=t(s);i&&a!=i&&(yield[i,n],n=[]),n.push(s),i=a}yield[i,n]}class A extends Error{}class S extends A{}function Te(r,t,n="Got %r, expected one of %s"){if(!t.includes(r))throw new S(d(n,r,t))}class re extends A{}class wn extends A{}class V extends A{}class z extends A{constructor(){super(...arguments),R(this,"pos_in_stream",null),R(this,"_terminals_by_name",null)}get_context(t,n=40){let i,s,a=this.pos_in_stream,o=max(a-n,0),l=a+n;return t instanceof bytes?(s=E(xe(t.slice(o,a),`
2
2
  `,1)),i=t.slice(a,l).split(`
3
3
  `,1)[0],(s+i+`
4
4
  `+" "*s.expandtabs().length+`^
@@ -6,18 +6,18 @@ import{createPermission as Dt}from"@backstage/plugin-permission-common";import P
6
6
  `,1)),i=t.slice(a,l).split(`
7
7
  `,1)[0],s+i+`
8
8
  `+" "*s.expandtabs().length+`^
9
- `)}match_examples(t,n,i=!1){ye(n)&&(n=x(n));let s=[null,!1];for(const[a,[o,l]]of H(n))for(const[c,_]of H(l))try{t(_)}catch(p){if(p instanceof z){if(p.state.eq(this.state)){if(p.token===this.token)return o;i&&p.token.type===this.token.type&&!E(s)&&(s=[o,!0]),s[0]===null&&(s=[o,!1])}}else throw p}return s[0]}_format_expected(t){let n;return this._terminals_by_name&&(n=this._terminals_by_name,t=t.map(i=>i in n?n[i].user_repr():i)),d(`Expected one of:
9
+ `)}match_examples(t,n,i=!1){ye(n)&&(n=x(n));let s=[null,!1];for(const[a,[o,l]]of W(n))for(const[c,_]of W(l))try{t(_)}catch(p){if(p instanceof z){if(p.state.eq(this.state)){if(p.token===this.token)return o;i&&p.token.type===this.token.type&&!E(s)&&(s=[o,!0]),s[0]===null&&(s=[o,!1])}}else throw p}return s[0]}_format_expected(t){let n;return this._terminals_by_name&&(n=this._terminals_by_name,t=t.map(i=>i in n?n[i].user_repr():i)),d(`Expected one of:
10
10
  * %s
11
11
  `,t.join(`
12
- * `))}}class gn extends z{constructor(t,n=null,i=null){super(),this.expected=t,this.state=n,this.token=new f("<EOF>",""),this.pos_in_stream=-1,this.line=-1,this.column=-1,this._terminals_by_name=i}}class U extends z{constructor({seq:t,lex_pos:n,line:i,column:s,allowed:a=null,considered_tokens:o=null,state:l=null,token_history:c=null,terminals_by_name:_=null,considered_rules:p=null}={}){super(),this.line=i,this.column=s,this.pos_in_stream=n,this.state=l,this._terminals_by_name=_,this.allowed=a,this.considered_tokens=o,this.considered_rules=p,this.token_history=c,this.char=t[n]}}class F extends z{constructor({token:t,expected:n,considered_rules:i=null,state:s=null,interactive_parser:a=null,terminals_by_name:o=null,token_history:l=null}={}){super(),this.line=t&&t.line||"?",this.column=t&&t.column||"?",this.pos_in_stream=t&&t.start_pos||null,this.state=s,this.token=t,this.expected=n,this._accepts=Be,this.considered_rules=i,this.interactive_parser=a,this._terminals_by_name=o,this.token_history=l}get accepts(){return this._accepts===Be&&(this._accepts=this.interactive_parser&&this.interactive_parser.accepts()),this._accepts}}class ve extends S{constructor(t,n,i){let s=d(`Error trying to process rule "%s":
12
+ * `))}}class Tn extends z{constructor(t,n=null,i=null){super(),this.expected=t,this.state=n,this.token=new f("<EOF>",""),this.pos_in_stream=-1,this.line=-1,this.column=-1,this._terminals_by_name=i}}class M extends z{constructor({seq:t,lex_pos:n,line:i,column:s,allowed:a=null,considered_tokens:o=null,state:l=null,token_history:c=null,terminals_by_name:_=null,considered_rules:p=null}={}){super(),this.line=i,this.column=s,this.pos_in_stream=n,this.state=l,this._terminals_by_name=_,this.allowed=a,this.considered_tokens=o,this.considered_rules=p,this.token_history=c,this.char=t[n]}}class j extends z{constructor({token:t,expected:n,considered_rules:i=null,state:s=null,interactive_parser:a=null,terminals_by_name:o=null,token_history:l=null}={}){super(),this.line=t&&t.line||"?",this.column=t&&t.column||"?",this.pos_in_stream=t&&t.start_pos||null,this.state=s,this.token=t,this.expected=n,this._accepts=Ge,this.considered_rules=i,this.interactive_parser=a,this._terminals_by_name=o,this.token_history=l}get accepts(){return this._accepts===Ge&&(this._accepts=this.interactive_parser&&this.interactive_parser.accepts()),this._accepts}}class ve extends A{constructor(t,n,i){let s=d(`Error trying to process rule "%s":
13
13
 
14
- %s`,t,i);super(s),this.rule=t,this.obj=n,this.orig_exc=i}}function xn(r,t=null,n=null){let i,s,a=new Map;for(const o of r)i=t!==null?t(o):o,s=n!==null?n(o):o,a.has(i)?a.get(i).push(s):a.set(i,[s]);return a}function se(r,t,n){let i;return ye(r)?"__type__"in r?(i=t[r.__type__],i.deserialize(r,n)):"@"in r?n[r["@"]]:Object.fromEntries(x(r).map(([s,a])=>[s,se(a,t,n)])):un(r)?r.map(s=>se(s,t,n)):r}class N{static deserialize(t,n){const i=this;let s=i&&i.__serialize_fields__;if("@"in t)return n[t["@"]];let a=fe(i);for(const o of s)if(t&&o in t)a[o]=se(t[o],_r,n);else throw new KeyError("Cannot find key for class",i,e);return"_deserialize"in a&&a._deserialize(),a}}class wn extends N{static get __serialize_fields__(){return["memoized"]}constructor(t){super(),this.types_to_memoize=t,this.memoized=new Enumerator}in_types(t){return t instanceof this.types_to_memoize}serialize(){return _serialize(this.memoized.reversed(),null)}static deserialize(t,n,i){return se(t,n,i)}}class it{constructor(){this.empty=!0}}class g{constructor(t,n,i=null){this.data=t,this.children=n,this._meta=i}get meta(){return this._meta===null&&(this._meta=new it),this._meta}repr(){return d("Tree(%r, %r)",this.data,this.children)}_pretty_label(){return this.data}_pretty(t,n){if(this.children.length===1&&!(this.children[0]instanceof g))return[O(n,t).join(""),this._pretty_label()," ",d("%s",this.children[0].value),`
14
+ %s`,t,i);super(s),this.rule=t,this.obj=n,this.orig_exc=i}}function vn(r,t=null,n=null){let i,s,a=new Map;for(const o of r)i=t!==null?t(o):o,s=n!==null?n(o):o,a.has(i)?a.get(i).push(s):a.set(i,[s]);return a}function ie(r,t,n){let i;return ye(r)?"__type__"in r?(i=t[r.__type__],i.deserialize(r,n)):"@"in r?n[r["@"]]:Object.fromEntries(x(r).map(([s,a])=>[s,ie(a,t,n)])):mn(r)?r.map(s=>ie(s,t,n)):r}class N{static deserialize(t,n){const i=this;let s=i&&i.__serialize_fields__;if("@"in t)return n[t["@"]];let a=fe(i);for(const o of s)if(t&&o in t)a[o]=ie(t[o],ur,n);else throw new KeyError("Cannot find key for class",i,e);return"_deserialize"in a&&a._deserialize(),a}}class bn extends N{static get __serialize_fields__(){return["memoized"]}constructor(t){super(),this.types_to_memoize=t,this.memoized=new Enumerator}in_types(t){return t instanceof this.types_to_memoize}serialize(){return _serialize(this.memoized.reversed(),null)}static deserialize(t,n,i){return ie(t,n,i)}}class st{constructor(){this.empty=!0}}class g{constructor(t,n,i=null){this.data=t,this.children=n,this._meta=i}get meta(){return this._meta===null&&(this._meta=new st),this._meta}repr(){return d("Tree(%r, %r)",this.data,this.children)}_pretty_label(){return this.data}_pretty(t,n){if(this.children.length===1&&!(this.children[0]instanceof g))return[O(n,t).join(""),this._pretty_label()," ",d("%s",this.children[0].value),`
15
15
  `];let i=[O(n,t).join(""),this._pretty_label(),`
16
16
  `];for(const s of this.children)s instanceof g?i.push(...s._pretty(t+1,n)):i.push(O(n,t+1).join(""),d("%s",s.value),`
17
- `);return i}pretty(t=" "){return this._pretty(0,t).join("")}eq(t){return t&&this&&t&&this&&t.children&&this.children&&t.data&&this.data?this.data===t.data&&this.children===t.children:!1}iter_subtrees(){let t=[this],n=new Map;for(const i of t)n.set(i,i),t.push(...[...i.children].reverse().filter(s=>s instanceof g&&!n.has(s)).map(s=>s));return t=void 0,[...n.values()].reverse()}find_pred(t){return nt(t,this.iter_subtrees())}find_data(t){return this.find_pred(n=>n.data===t)}*scan_values(t){for(const n of this.children)if(n instanceof g)for(const i of n.scan_values(t))yield i;else t(n)&&(yield n)}*iter_subtrees_topdown(){let t,n=[this];for(;n.length;)if(t=n.pop(),t instanceof g){yield t;for(const i of[...t.children].reverse())n.push(i)}}copy(){return type(this)(this.data,this.children)}set(t,n){this.data=t,this.children=n}}class Y extends Ge{static get __visit_tokens__(){return!0}constructor(t=!0){super(),this.__visit_tokens__=t}static fromObj(t,...n){class i extends this{}for(let[s,a]of Object.entries(t))i.prototype[s]=a;return new i(...n)}_call_userfunc(t,n=null){let i,s,a=n!==null?n:t.children;if(t&&t.data&&this&&this[t.data]){i=this&&this[t.data];try{return s=i&&i.visit_wrapper||null,s!==null?i.visit_wrapper(i,t.data,a,t.meta):i(a)}catch(o){throw o instanceof ie?o:o instanceof Error?new ve(t.data,t,o):o}}else return this.__default__(t.data,a,t.meta)}_call_userfunc_token(t){let n;if(t&&t.type&&this&&this[t.type]){n=this&&this[t.type];try{return n(t)}catch(i){throw i instanceof ie?i:i instanceof Error?new ve(t.type,t,i):i}}else return this.__default_token__(t)}*_transform_children(t){let n;for(const i of t)i instanceof g?n=this._transform_tree(i):this.__visit_tokens__&&i instanceof f?n=this._call_userfunc_token(i):n=i,n!==te&&(yield n)}_transform_tree(t){let n=[...this._transform_children(t.children)];return this._call_userfunc(t,n)}transform(t){return this._transform_tree(t)}__default__(t,n,i){return new g(t,n,i)}__default_token__(t){return t}}class st extends Y{_transform_tree(t){return this._call_userfunc(t)}transform(t){for(const n of t.iter_subtrees())n.children=[...this._transform_children(n.children)];return this._transform_tree(t)}}class Tn extends Y{transform(t){let n,i,s,a=[],o=[t];for(;o.length;){const _=o.pop();a.push(_),_ instanceof g&&o.push(..._.children)}let l=[];for(const _ of[...a].reverse())_ instanceof g?(s=_.children.length,s?(n=l.slice(-s),l.splice(-s)):n=[],i=this._call_userfunc(_,n),i!==te&&l.push(i)):this.__visit_tokens__&&_ instanceof f?(i=this._call_userfunc_token(_),i!==te&&l.push(i)):l.push(_);let[c]=l;return c}}class vn extends Y{_transform_tree(t){return t.children=[...this._transform_children(t.children)],this._call_userfunc(t)}}class be{_call_userfunc(t){const n=this[t.data];return n?n(t):this.__default__(t)}__default__(t){return t}__class_getitem__(t){return cls}}class bn extends be{visit(t){for(const n of t.iter_subtrees())this._call_userfunc(n);return t}visit_topdown(t){for(const n of t.iter_subtrees_topdown())this._call_userfunc(n);return t}}class En extends be{visit(t){for(const n of t.children)n instanceof g&&this.visit(n);return this._call_userfunc(t),t}visit_topdown(t){this._call_userfunc(t);for(const n of t.children)n instanceof g&&this.visit_topdown(n);return t}}class Nn extends Ge{visit(t){return t.data in this?this[t.data](t):this.__default__(t)}visit_children(t){return t.children.map(n=>n instanceof g?this.visit(n):n)}__default__(t){return this.visit_children(t)}}var kn=0;class Ee extends N{constructor(t){super(),R(this,"is_term",X),this.name=t}eq(t){return this.is_term===t.is_term&&this.name===t.name}repr(){return d("%s(%r)",type(this).name,this.name)}static get fullrepr(){return property(__repr__)}get fullrepr(){return this.constructor.fullrepr}renamed(t){return type(this)(t(this.name))}}class Ne extends Ee{static get __serialize_fields__(){return["name","filter_out"]}get is_term(){return!0}constructor(t,n=!1){super(),this.name=t,this.filter_out=n}get fullrepr(){return d("%s(%r, %r)",type(this).name,this.name,this.filter_out)}renamed(t){return type(this)(t(this.name),this.filter_out)}}class ke extends Ee{static get __serialize_fields__(){return["name"]}get is_term(){return!1}}class ae extends N{static get __serialize_fields__(){return["keep_all_tokens","expand1","priority","template_source","empty_indices"]}constructor(t=!1,n=!1,i=null,s=null,a=[]){super(),this.keep_all_tokens=t,this.expand1=n,this.priority=i,this.template_source=s,this.empty_indices=a}repr(){return d("RuleOptions(%r, %r, %r, %r)",this.keep_all_tokens,this.expand1,this.priority,this.template_source)}}class V extends N{static get __serialize_fields__(){return["origin","expansion","order","alias","options"]}static get __serialize_namespace__(){return[Ne,ke,ae]}constructor(t,n,i=0,s=null,a=null){super(),this.origin=t,this.expansion=n,this.alias=s,this.order=i,this.options=a||new ae,this._hash=[this.origin,this.expansion]}_deserialize(){this._hash=[this.origin,this.expansion]}repr(){return d("Rule(%r, %r, %r, %r)",this.origin,this.expansion,this.alias,this.options)}eq(t){return t instanceof V?this.origin===t.origin&&this.expansion===t.expansion:!1}}class Re extends N{constructor(t,n=[],i=null){super(),this.value=t,this.flags=ne(n),this.raw=i}repr(){return repr(this.to_regexp())}eq(t){return type(this)===type(t)&&this.value===t.value&&this.flags===t.flags}to_regexp(){throw new NotImplementedError}get min_width(){throw new NotImplementedError}get max_width(){throw new NotImplementedError}_get_flags(t){return t}}class Ie extends Re{static get __serialize_fields__(){return["value","flags"]}static get type(){return"str"}to_regexp(){return this._get_flags(We.escape(this.value))}get min_width(){return this.value.length}get max_width(){return this.value.length}}class qe extends Re{static get __serialize_fields__(){return["value","flags","_width"]}static get type(){return"re"}to_regexp(){return this._get_flags(this.value)}_get_width(){return this._width===null&&(this._width=get_regexp_width(this.to_regexp())),this._width}get min_width(){return this._get_width()[0]}get max_width(){return this._get_width()[1]}}class oe extends N{static get __serialize_fields__(){return["name","pattern","priority"]}static get __serialize_namespace__(){return[Ie,qe]}constructor(t,n,i=kn){super(),this.name=t,this.pattern=n,this.priority=i}repr(){return d("%s(%r, %r)",type(this).name,this.name,this.pattern)}user_repr(){return this.name.startsWith("__")?this.pattern.raw||this.name:this.name}}class f{constructor(t,n,i=null,s=null,a=null,o=null,l=null,c=null){R(this,"value"),R(this,"type"),this.type=t,this.start_pos=i,this.value=n,this.line=s,this.column=a,this.end_line=o,this.end_column=l,this.end_pos=c}update(t=null,n=null){return f.new_borrow_pos(t!==null?t:this.type,n!==null?n:this.value,this)}static new_borrow_pos(t,n,i){const s=this;return new s(t,n,i.start_pos,i.line,i.column,i.end_line,i.end_column,i.end_pos)}repr(){return d("Token(%r, %r)",this.type,this.value)}eq(t){return t instanceof f&&this.type!==t.type?!1:str.__eq__(this,t)}static get __hash__(){return str.__hash__}}class Qe{constructor(t){this.newline_char=t,this.char_pos=0,this.line=1,this.column=1,this.line_start_pos=0}eq(t){return t instanceof Qe?this.char_pos===t.char_pos&&this.newline_char===t.newline_char:X}feed(t,n=!0){let i;n&&(i=we(t,this.newline_char),i&&(this.line+=i,this.line_start_pos=this.char_pos+t.lastIndexOf(this.newline_char)+1)),this.char_pos+=t.length,this.column=this.char_pos-this.line_start_pos+1}}class Rn{constructor(t){this.scanner=t}__call__(t){let n,i=this.scanner.match(t.value,0);return i&&([n,t.type]=i),t}}const In=P(Rn);class qn{constructor(t,n,i){this.callback1=t,this.callback2=n,this.cond=i}__call__(t){let n=this.callback1(t);return this.cond(n)?this.callback2(t):n}}const On=P(qn);function Sn(r,t,n,i){let s,a,o=xn(r,_=>_.pattern.constructor.type),l=new Set,c={};for(const _ of o.get("re")||[]){a=[];for(const p of o.get("str")||[])p.priority===_.priority&&(s=p.pattern.value,s===ln(n,_.pattern.to_regexp(),s,t)&&(a.push(p),mn(new Set(p.pattern.flags),new Set(_.pattern.flags))&&l.add(p)));a.length&&(c[_.name]=new In(new Ve(a,t,n,i,!0)))}return[r.filter(_=>!l.has(_)).map(_=>_),c]}function An(r){return r.includes(`
17
+ `);return i}pretty(t=" "){return this._pretty(0,t).join("")}eq(t){return t&&this&&t&&this&&t.children&&this.children&&t.data&&this.data?this.data===t.data&&this.children===t.children:!1}iter_subtrees(){let t=[this],n=new Map;for(const i of t)n.set(i,i),t.push(...[...i.children].reverse().filter(s=>s instanceof g&&!n.has(s)).map(s=>s));return t=void 0,[...n.values()].reverse()}find_pred(t){return rt(t,this.iter_subtrees())}find_data(t){return this.find_pred(n=>n.data===t)}*scan_values(t){for(const n of this.children)if(n instanceof g)for(const i of n.scan_values(t))yield i;else t(n)&&(yield n)}*iter_subtrees_topdown(){let t,n=[this];for(;n.length;)if(t=n.pop(),t instanceof g){yield t;for(const i of[...t.children].reverse())n.push(i)}}copy(){return type(this)(this.data,this.children)}set(t,n){this.data=t,this.children=n}}class X extends We{static get __visit_tokens__(){return!0}constructor(t=!0){super(),this.__visit_tokens__=t}static fromObj(t,...n){class i extends this{}for(let[s,a]of Object.entries(t))i.prototype[s]=a;return new i(...n)}_call_userfunc(t,n=null){let i,s,a=n!==null?n:t.children;if(t&&t.data&&this&&this[t.data]){i=this&&this[t.data];try{return s=i&&i.visit_wrapper||null,s!==null?i.visit_wrapper(i,t.data,a,t.meta):i(a)}catch(o){throw o instanceof re?o:o instanceof Error?new ve(t.data,t,o):o}}else return this.__default__(t.data,a,t.meta)}_call_userfunc_token(t){let n;if(t&&t.type&&this&&this[t.type]){n=this&&this[t.type];try{return n(t)}catch(i){throw i instanceof re?i:i instanceof Error?new ve(t.type,t,i):i}}else return this.__default_token__(t)}*_transform_children(t){let n;for(const i of t)i instanceof g?n=this._transform_tree(i):this.__visit_tokens__&&i instanceof f?n=this._call_userfunc_token(i):n=i,n!==ee&&(yield n)}_transform_tree(t){let n=[...this._transform_children(t.children)];return this._call_userfunc(t,n)}transform(t){return this._transform_tree(t)}__default__(t,n,i){return new g(t,n,i)}__default_token__(t){return t}}class at extends X{_transform_tree(t){return this._call_userfunc(t)}transform(t){for(const n of t.iter_subtrees())n.children=[...this._transform_children(n.children)];return this._transform_tree(t)}}class En extends X{transform(t){let n,i,s,a=[],o=[t];for(;o.length;){const _=o.pop();a.push(_),_ instanceof g&&o.push(..._.children)}let l=[];for(const _ of[...a].reverse())_ instanceof g?(s=_.children.length,s?(n=l.slice(-s),l.splice(-s)):n=[],i=this._call_userfunc(_,n),i!==ee&&l.push(i)):this.__visit_tokens__&&_ instanceof f?(i=this._call_userfunc_token(_),i!==ee&&l.push(i)):l.push(_);let[c]=l;return c}}class Nn extends X{_transform_tree(t){return t.children=[...this._transform_children(t.children)],this._call_userfunc(t)}}class be{_call_userfunc(t){const n=this[t.data];return n?n(t):this.__default__(t)}__default__(t){return t}__class_getitem__(t){return cls}}class kn extends be{visit(t){for(const n of t.iter_subtrees())this._call_userfunc(n);return t}visit_topdown(t){for(const n of t.iter_subtrees_topdown())this._call_userfunc(n);return t}}class Rn extends be{visit(t){for(const n of t.children)n instanceof g&&this.visit(n);return this._call_userfunc(t),t}visit_topdown(t){this._call_userfunc(t);for(const n of t.children)n instanceof g&&this.visit_topdown(n);return t}}class In extends We{visit(t){return t.data in this?this[t.data](t):this.__default__(t)}visit_children(t){return t.children.map(n=>n instanceof g?this.visit(n):n)}__default__(t){return this.visit_children(t)}}var qn=0;class Ee extends N{constructor(t){super(),R(this,"is_term",G),this.name=t}eq(t){return this.is_term===t.is_term&&this.name===t.name}repr(){return d("%s(%r)",type(this).name,this.name)}static get fullrepr(){return property(__repr__)}get fullrepr(){return this.constructor.fullrepr}renamed(t){return type(this)(t(this.name))}}class Ne extends Ee{static get __serialize_fields__(){return["name","filter_out"]}get is_term(){return!0}constructor(t,n=!1){super(),this.name=t,this.filter_out=n}get fullrepr(){return d("%s(%r, %r)",type(this).name,this.name,this.filter_out)}renamed(t){return type(this)(t(this.name),this.filter_out)}}class ke extends Ee{static get __serialize_fields__(){return["name"]}get is_term(){return!1}}class se extends N{static get __serialize_fields__(){return["keep_all_tokens","expand1","priority","template_source","empty_indices"]}constructor(t=!1,n=!1,i=null,s=null,a=[]){super(),this.keep_all_tokens=t,this.expand1=n,this.priority=i,this.template_source=s,this.empty_indices=a}repr(){return d("RuleOptions(%r, %r, %r, %r)",this.keep_all_tokens,this.expand1,this.priority,this.template_source)}}class B extends N{static get __serialize_fields__(){return["origin","expansion","order","alias","options"]}static get __serialize_namespace__(){return[Ne,ke,se]}constructor(t,n,i=0,s=null,a=null){super(),this.origin=t,this.expansion=n,this.alias=s,this.order=i,this.options=a||new se,this._hash=[this.origin,this.expansion]}_deserialize(){this._hash=[this.origin,this.expansion]}repr(){return d("Rule(%r, %r, %r, %r)",this.origin,this.expansion,this.alias,this.options)}eq(t){return t instanceof B?this.origin===t.origin&&this.expansion===t.expansion:!1}}class Re extends N{constructor(t,n=[],i=null){super(),this.value=t,this.flags=te(n),this.raw=i}repr(){return repr(this.to_regexp())}eq(t){return type(this)===type(t)&&this.value===t.value&&this.flags===t.flags}to_regexp(){throw new NotImplementedError}get min_width(){throw new NotImplementedError}get max_width(){throw new NotImplementedError}_get_flags(t){return t}}class Ie extends Re{static get __serialize_fields__(){return["value","flags"]}static get type(){return"str"}to_regexp(){return this._get_flags(Ve.escape(this.value))}get min_width(){return this.value.length}get max_width(){return this.value.length}}class qe extends Re{static get __serialize_fields__(){return["value","flags","_width"]}static get type(){return"re"}to_regexp(){return this._get_flags(this.value)}_get_width(){return this._width===null&&(this._width=get_regexp_width(this.to_regexp())),this._width}get min_width(){return this._get_width()[0]}get max_width(){return this._get_width()[1]}}class ae extends N{static get __serialize_fields__(){return["name","pattern","priority"]}static get __serialize_namespace__(){return[Ie,qe]}constructor(t,n,i=qn){super(),this.name=t,this.pattern=n,this.priority=i}repr(){return d("%s(%r, %r)",type(this).name,this.name,this.pattern)}user_repr(){return this.name.startsWith("__")?this.pattern.raw||this.name:this.name}}class f{constructor(t,n,i=null,s=null,a=null,o=null,l=null,c=null){R(this,"value"),R(this,"type"),this.type=t,this.start_pos=i,this.value=n,this.line=s,this.column=a,this.end_line=o,this.end_column=l,this.end_pos=c}update(t=null,n=null){return f.new_borrow_pos(t!==null?t:this.type,n!==null?n:this.value,this)}static new_borrow_pos(t,n,i){const s=this;return new s(t,n,i.start_pos,i.line,i.column,i.end_line,i.end_column,i.end_pos)}repr(){return d("Token(%r, %r)",this.type,this.value)}eq(t){return t instanceof f&&this.type!==t.type?!1:str.__eq__(this,t)}static get __hash__(){return str.__hash__}}class Qe{constructor(t){this.newline_char=t,this.char_pos=0,this.line=1,this.column=1,this.line_start_pos=0}eq(t){return t instanceof Qe?this.char_pos===t.char_pos&&this.newline_char===t.newline_char:G}feed(t,n=!0){let i;n&&(i=we(t,this.newline_char),i&&(this.line+=i,this.line_start_pos=this.char_pos+t.lastIndexOf(this.newline_char)+1)),this.char_pos+=t.length,this.column=this.char_pos-this.line_start_pos+1}}class On{constructor(t){this.scanner=t}__call__(t){let n,i=this.scanner.match(t.value,0);return i&&([n,t.type]=i),t}}const An=P(On);class Sn{constructor(t,n,i){this.callback1=t,this.callback2=n,this.cond=i}__call__(t){let n=this.callback1(t);return this.cond(n)?this.callback2(t):n}}const $n=P(Sn);function zn(r,t,n,i){let s,a,o=vn(r,_=>_.pattern.constructor.type),l=new Set,c={};for(const _ of o.get("re")||[]){a=[];for(const p of o.get("str")||[])p.priority===_.priority&&(s=p.pattern.value,s===pn(n,_.pattern.to_regexp(),s,t)&&(a.push(p),gn(new Set(p.pattern.flags),new Set(_.pattern.flags))&&l.add(p)));a.length&&(c[_.name]=new An(new Xe(a,t,n,i,!0)))}return[r.filter(_=>!l.has(_)).map(_=>_),c]}function Dn(r){return r.includes(`
18
18
  `)||r.includes("\\n")||r.includes("\\s")||r.includes("[^")||r.includes("(?s")&&r.includes(".")}class Me{constructor(t,n=null,i=null){this.text=t,this.line_ctr=n||new Qe(`
19
- `),this.last_token=i}eq(t){return t instanceof Me?this.text===t.text&&this.line_ctr===t.line_ctr&&this.last_token===t.last_token:X}}class at{constructor(t,n){this.lexer=t,this.state=n}static from_text(t,n){return new this(t,new Me(n))}lex(t){return this.lexer.lex(this.state,t)}}class le extends He{lex(t,n){return X}}function $n(r,t){r.sort((n,i)=>{let s=t(n),a=t(i);for(let o=0;o<s.length;o++){if(s[o]>a[o])return 1;if(s[o]<a[o])return-1}return 0})}class _e extends le{constructor(t){super();let n=[...t.terminals];if(this.re=t.re_module,!t.skip_validation){for(const i of n){try{this.re.compile(i.pattern.to_regexp(),t.g_regex_flags)}catch(s){throw s instanceof this.re.error?new J(d("Cannot compile token %s: %s",i.name,i.pattern)):s}if(i.pattern.min_width===0)throw new J(d("Lexer does not allow zero-width terminals. (%s: %s)",i.name,i.pattern))}if(!(new Set(t.ignore)<=new Set(n.map(i=>i.name))))throw new J(d("Ignore terminals are not defined: %s",Ke(new Set(t.ignore),new Set(n.map(i=>i.name)))))}this.newline_types=ne(n.filter(i=>An(i.pattern.to_regexp())).map(i=>i.name)),this.ignore_types=ne(t.ignore),$n(n,i=>[-i.priority,-i.pattern.max_width,-i.pattern.value.length,i.name]),this.terminals=n,this.user_callbacks=t.callbacks,this.g_regex_flags=t.g_regex_flags,this.use_bytes=t.use_bytes,this.terminals_by_name=t.terminals_by_name,this._scanner=null}_build_scanner(){let t;[t,this.callback]=Sn(this.terminals,this.g_regex_flags,this.re,this.use_bytes);for(const[n,i]of x(this.user_callbacks))n in this.callback?this.callback[n]=new On(this.callback[n],i,s=>s.type===n):this.callback[n]=i;this._scanner=new Ve(t,this.g_regex_flags,this.re,this.use_bytes)}get scanner(){return this._scanner===null&&this._build_scanner(),this._scanner}match(t,n){return this.scanner.match(t,n)}*lex(t,n){try{for(;;)yield this.next_token(t,n)}catch(i){if(!(i instanceof ge))throw i}}next_token(t,n=null){let i,s,a,o,l=t.line_ctr;for(;l.char_pos<t.text.length;){if(s=this.match(t.text,l.char_pos),!s)throw i=Ke(this.scanner.allowed_types,this.ignore_types),i||(i=new Set(["<END-OF-FILE>"])),new U({seq:t.text,lex_pos:l.char_pos,line:l.line,column:l.column,allowed:i,token_history:t.last_token&&[t.last_token],state:n,terminals_by_name:this.terminals_by_name});let[c,_]=s;if(this.ignore_types.has(_))_ in this.callback&&(o=new f(_,c,l.char_pos,l.line,l.column),this.callback[_](o)),l.feed(c,this.newline_types.has(_));else{if(a=new f(_,c,l.char_pos,l.line,l.column),l.feed(c,this.newline_types.has(_)),a.end_line=l.line,a.end_column=l.column,a.end_pos=l.char_pos,a.type in this.callback&&(a=this.callback[a.type](a),!(a instanceof f)))throw new J(d("Callbacks must return a token (returned %r)",a));return t.last_token=a,a}}throw new ge(this)}}class zn extends le{constructor({conf:t,states:n,always_accept:i=[]}={}){super();let s,a,o,l=[...t.terminals],c=t.terminals_by_name,_=I(t);_.terminals=l;let p=new Map;this.lexers={};for(let[y,v]of x(n))s=ne(v),p.has(s)?a=p.get(s):(v=pn(new Set(v),[...new Set(t.ignore),...new Set(i)]),o=I(_),o.terminals=[...v].filter(w=>w in c).map(w=>c[w]),a=new _e(o),p.set(s,a)),this.lexers[y]=a;this.root_lexer=new _e(_)}*lex(t,n){let i,s,a;try{for(;;)s=this.lexers[n.position],yield s.next_token(t,n)}catch(o){if(!(o instanceof ge))if(o instanceof U)try{throw i=t.last_token,a=this.root_lexer.next_token(t,n),new F({token:a,expected:o.allowed,state:n,token_history:[i],terminals_by_name:this.root_lexer.terminals_by_name})}catch(l){throw l}else throw o}}}class ot extends N{static get __serialize_fields__(){return["terminals","ignore","g_regex_flags","use_bytes","lexer_type"]}static get __serialize_namespace__(){return[oe]}constructor({terminals:t,re_module:n,ignore:i=[],postlex:s=null,callbacks:a=null,g_regex_flags:o="",skip_validation:l=!1,use_bytes:c=!1}={}){super(),this.terminals=t,this.terminals_by_name=Object.fromEntries(this.terminals.map(_=>[_.name,_])),this.ignore=i,this.postlex=s,this.callbacks=Object.keys(a).length||{},this.g_regex_flags=o,this.re_module=n,this.skip_validation=l,this.use_bytes=c,this.lexer_type=null}_deserialize(){this.terminals_by_name=Object.fromEntries(this.terminals.map(t=>[t.name,t]))}}class lt extends N{static get __serialize_fields__(){return["rules","start","parser_type"]}constructor(t,n,i){super(),this.rules=t,this.callbacks=n,this.start=i,this.parser_type=null}}class Dn{constructor(t){this.node_builder=t}__call__(t){return t.length===1?t[0]:this.node_builder(t)}}const Pn=P(Dn);class Ln{constructor(t,n=null){this.node_builder=t,this.node_filter=n}__call__(t){let n,i,s,a=this.node_builder(t);return a instanceof g&&(s=a.meta,n=this._pp_get_meta(t),n!==null&&("line"in s||(s.line=n&&n.container_line||n.line,s.column=n&&n.container_column||n.column,s.start_pos=n&&n.container_start_pos||n.start_pos,s.empty=!1),s.container_line=n&&n.container_line||n.line,s.container_column=n&&n.container_column||n.column),i=this._pp_get_meta([...t].reverse()),i!==null&&("end_line"in s||(s.end_line=i&&i.container_end_line||i.end_line,s.end_column=i&&i.container_end_column||i.end_column,s.end_pos=i&&i.container_end_pos||i.end_pos,s.empty=!1),s.container_end_line=i&&i.container_end_line||i.end_line,s.container_end_column=i&&i.container_end_column||i.end_column)),a}_pp_get_meta(t){for(const n of t)if(!(this.node_filter!==null&&!this.node_filter(n))){if(n instanceof g){if(!n.meta.empty)return n.meta}else if(n instanceof f)return n}}}const _t=P(Ln);function Cn(r){if(hn(r))return re({unknown_param_0:_t,node_filter:r});if(r===!0)return _t;if(r===!1)return null;throw new A(d("Invalid option for propagate_positions: %r",r))}class Oe{constructor(t,n,i){this.node_builder=i,this.to_include=t,this.append_none=n}__call__(t){let n=[];for(const[i,s,a]of this.to_include)a&&n.push(...O([null],a)),s?n.push(...t[i].children):n.push(t[i]);return this.append_none&&n.push(...O([null],this.append_none)),this.node_builder(n)}}const Qn=P(Oe);class Mn extends Oe{__call__(t){let n=[];for(const[i,s,a]of this.to_include)a&&n.push(...O([null],a)),s?n.length?n.push(...t[i].children):n=t[i].children:n.push(t[i]);return this.append_none&&n.push(...O([null],this.append_none)),this.node_builder(n)}}const jn=P(Mn);class Un extends Oe{constructor(t,n){super(),this.node_builder=n,this.to_include=t}__call__(t){let n=[];for(const[i,s]of this.to_include)s?n.length?n.push(...t[i].children):n=t[i].children:n.push(t[i]);return this.node_builder(n)}}const Fn=P(Un);function Zn(r){return!r.is_term&&r.name.startsWith("_")}function Bn(r,t,n,i){let s,a;i.length?(a=i.map(c=>(0+c).toString()).join(""),s=a.split("0").map(c=>c.length)):s=O([0],r.length+1);let o=[],l=0;for(const[c,_]of H(r))l+=s[c],(t||!(_.is_term&&_.filter_out))&&(o.push([c,Zn(_),l]),l=0);if(l+=s[r.length],i.length||o.length<r.length||dn(o.map(([c,_,p])=>_)))return(i.length||n).length?re(n?Qn:jn,o,l):re(Fn,o.map(([c,_,p])=>[c,_]))}function Gn(r){function t(n){let i=new g(r.name,n);return r(i)}return t=wraps(r)(t),t}function Wn(r,t,n){if(n===_vargs_meta||n===_vargs_meta_inline)throw new NotImplementedError("Meta args not supported for internal transformer");function i(s){return n(r,t,s,null)}return i=wraps(r)(i),i}class Vn{constructor(t,n,i=!1,s=!1,a=!1){this.tree_class=n,this.propagate_positions=i,this.ambiguous=s,this.maybe_placeholders=a,this.rule_builders=[...this._init_builders(t)]}*_init_builders(t){let n,i,s,a,o=Cn(this.propagate_positions);for(const l of t)s=l.options,i=s.keep_all_tokens,n=s.expand1,a=[...nt(null,[n&&!l.alias&&Pn,Bn(l.expansion,i,this.ambiguous,this.maybe_placeholders?s.empty_indices:[]),o])],yield[l,a]}create_callback(t=null){let n,i,s,a=new Map;for(const[o,l]of this.rule_builders){i=o.alias||o.options.template_source||o.origin.name,t&&t[i]?(n=t&&t[i],s=n&&n.visit_wrapper||null,s!==null?n=Wn(n,i,s):t instanceof st&&(n=Gn(n))):n=re(this.tree_class,i);for(const c of l)n=c(n);if(a.has(o))throw new ie(d("Rule '%s' already exists",o));a.set(o,n)}return a}}class ct extends N{constructor({parser_conf:t,debug:n=!1}={}){super();let i=new LALR_Analyzer({unknown_param_0:t,debug:n});i.compute_lalr();let s=t.callbacks;this._parse_table=i.parse_table,this.parser_conf=t,this.parser=new pt(i.parse_table,s,n)}static deserialize(t,n,i,s=!1){let a=fe(this);return a._parse_table=Jn.deserialize(t,n),a.parser=new pt(a._parse_table,i,s),a}serialize(t){return this._parse_table.serialize(t)}parse_interactive(t,n){return this.parser.parse({lexer:t,start:n,start_interactive:!0})}parse({lexer:t,start:n,on_error:i=null}={}){let s,a;try{return this.parser.parse({lexer:t,start:n})}catch(o){if(o instanceof z){if(i===null)throw o;for(;;){if(o instanceof U&&(a=o.interactive_parser.lexer_thread.state,s=a.line_ctr.char_pos),!i(o))throw o;o instanceof U&&s===a.line_ctr.char_pos&&a.line_ctr.feed(a.text.slice(s,s+1));try{return o.interactive_parser.resume_parse()}catch(l){if(l instanceof F){if(o instanceof F&&o.token.type===l.token.type&&l.token.type==="$END"&&o.interactive_parser.eq(l.interactive_parser))throw l;o=l}else if(l instanceof U)o=l;else throw l}}}else throw o}}}class Xn{constructor(t,n,i){this.parse_table=t,this.start_state=this.parse_table.start_states[i],this.end_state=this.parse_table.end_states[i],this.states=this.parse_table.states,this.callbacks=n,this.start=i}}class je{constructor(t,n,i=null,s=null){this.parse_conf=t,this.lexer=n,this.state_stack=i||[this.parse_conf.start_state],this.value_stack=s||[]}get position(){return E(this.state_stack)}eq(t){return t instanceof je?this.state_stack.length===t.state_stack.length&&this.position===t.position:X}copy(){return I(this)}feed_token(t,n=!1){let i,s,a,o,l,c,_,p,y,v,w=this.state_stack,u=this.value_stack,h=this.parse_conf.states,m=this.parse_conf.end_state,b=this.parse_conf.callbacks;for(;;){if(y=E(w),t.type in h[y])[s,a]=h[y][t.type];else throw o=new Set(me(h[y]).filter(q=>rt(q)).map(q=>q)),new F({token:t,expected:o,state:this,interactive_parser:null});if(s===Se){w.push(a),u.push(t.type in b?b[t.type](t):t);return}else if(c=a,p=c.expansion.length,p?(_=u.slice(-p),w.splice(-p),u.splice(-p)):_=[],v=b.get(c)(_),[i,l]=h[E(w)][c.origin.name],w.push(l),u.push(v),n&&E(w)===m)return E(u)}}}class pt{constructor(t,n,i=!1){this.parse_table=t,this.callbacks=n,this.debug=i}parse({lexer:t,start:n,value_stack:i=null,state_stack:s=null,start_interactive:a=!1}={}){let o=new Xn(this.parse_table,this.callbacks,n),l=new je(o,t,s,i);return a?new D(this,l,l.lexer):this.parse_from_state(l)}parse_from_state(t){let n,i;try{i=null;for(i of t.lexer.lex(t))t.feed_token(i);return n=i?f.new_borrow_pos("$END","",i):new f("$END","",0,1,1),t.feed_token(n,!0)}catch(s){if(s instanceof z){try{s.interactive_parser=new D(this,t,t.lexer)}catch(a){if(!(a instanceof ReferenceError))throw a}throw s}else if(s instanceof Error){if(this.debug){console.log(""),console.log("STATE STACK DUMP"),console.log("----------------");for(const[a,o]of H(t.state_stack))console.log(d("%d)",a),o);console.log("")}throw s}else throw s}}}class D{constructor(t,n,i){this.parser=t,this.parser_state=n,this.lexer_thread=i,this.result=null}feed_token(t){return this.parser_state.feed_token(t,t.type==="$END")}*iter_parse(){for(const t of this.lexer_thread.lex(this.parser_state))yield t,this.result=this.feed_token(t)}exhaust_lexer(){return[...this.iter_parse()]}feed_eof(t=null){let n=t!==null?f.new_borrow_pos("$END","",t):new f("$END","",0,1,1);return this.feed_token(n)}copy(){return I(this)}eq(t){return t instanceof D?this.parser_state===t.parser_state&&this.lexer_thread===t.lexer_thread:!1}as_immutable(){let t=I(this);return new ut(t.parser,t.parser_state,t.lexer_thread)}pretty(){let t=["Parser choices:"];for(const[n,i]of x(this.choices()))t.push(d(" - %s -> %r",n,i));return t.push(d("stack size: %s",this.parser_state.state_stack.length)),t.join(`
20
- `)}choices(){return this.parser_state.parse_conf.parse_table.states[this.parser_state.position]}accepts(){let t,n=new Set;for(const i of this.choices())if(rt(i)){t=I(this);let s=null;try{t.feed_token(new f(i,""))}catch(a){if(s=a,!(a instanceof F))throw a}s||n.add(i)}return n}resume_parse(){return this.parser.parse_from_state(this.parser_state)}}class ut extends D{constructor(){super(...arguments),R(this,"result",null)}feed_token(t){let n=I(this);return n.result=D.feed_token(n,t),n}exhaust_lexer(){let t=this.as_mutable();return t.exhaust_lexer(),t.as_immutable()}as_mutable(){let t=I(this);return new D(t.parser,t.parser_state,t.lexer_thread)}}class ht{constructor(t){this.name=t}repr(){return this.toString()}}var Se=new ht("Shift"),dt=new ht("Reduce");class Hn{constructor(t,n,i){this.states=t,this.start_states=n,this.end_states=i}serialize(t){let n=new Enumerator,i=Object.fromEntries(x(this.states).map(([s,a])=>[s,Object.fromEntries(x(a).map(([o,[l,c]])=>[Je(n,o),l===dt?[1,c.serialize(t)]:[0,c]]))]));return{tokens:n.reversed(),states:i,start_states:this.start_states,end_states:this.end_states}}static deserialize(t,n){const i=this;let s=t.tokens,a=Object.fromEntries(x(t.states).map(([o,l])=>[o,Object.fromEntries(x(l).map(([c,[_,p]])=>[s[c],_===1?[dt,V.deserialize(p,n)]:[Se,p]]))]));return new i(a,t.start_states,t.end_states)}}class Jn extends Hn{static from_ParseTable(t){const n=this;let i=[...t.states],s=Object.fromEntries(H(i).map(([c,_])=>[_,c])),a={};for(let[c,_]of x(t.states))_=Object.fromEntries(x(_).map(([p,y])=>[p,y[0]===Se?[y[0],s[y[1]]]:y])),a[s[c]]=_;let o=Object.fromEntries(x(t.start_states).map(([c,_])=>[c,s[_]])),l=Object.fromEntries(x(t.end_states).map(([c,_])=>[c,s[_]]));return new n(a,o,l)}}function Yn(r){if(r&&r.__future_interface__)return r;{class t extends le{constructor(i){super(),this.lexer=r(i)}lex(i,s){return this.lexer.lex(i.text)}}return t}}function Kn(r,t,n,i,s){let a=lt.deserialize(r.parser_conf,t),o=ct.deserialize(r.parser,t,i,s.debug);return a.callbacks=i,new er({lexer_conf:n,parser_conf:a,options:s,parser:o})}var mt={};class er extends N{static get __serialize_fields__(){return["lexer_conf","parser_conf","parser"]}constructor({lexer_conf:t,parser_conf:n,options:i,parser:s=null}={}){super();let a,o;this.parser_conf=n,this.lexer_conf=t,this.options=i,s?this.parser=s:(o=Je(mt,n.parser_type),this.parser=o(t,n,i));let l=t.lexer_type;if(this.skip_lexer=!1,["dynamic","dynamic_complete"].includes(l)){this.skip_lexer=!0;return}const c={basic:ir,contextual:sr};l in c?(a=c[l],this.lexer=a(t,this.parser,t.postlex,i)):this.lexer=Yn(l)(t),t.postlex&&(this.lexer=new rr(this.lexer,t.postlex))}_verify_start(t=null){let n;if(t===null){if(n=this.parser_conf.start,n.length>1)throw new A("Lark initialized with more than 1 possible start rule. Must specify which start rule to parse",n);[t]=n}else if(!this.parser_conf.start.includes(t))throw new A(d("Unknown start rule %s. Must be one of %r",t,this.parser_conf.start));return t}_make_lexer_thread(t){return this.skip_lexer?t:at.from_text(this.lexer,t)}parse(t,n=null,i=null){let s=this._verify_start(n),a=i===null?{}:{on_error:i},o=this._make_lexer_thread(t);return this.parser.parse({lexer:o,start:s,...a})}parse_interactive(t=null,n=null){let i=this._verify_start(n);if(this.parser_conf.parser_type!=="lalr")throw new A("parse_interactive() currently only works with parser='lalr' ");let s=this._make_lexer_thread(t);return this.parser.parse_interactive(s,i)}}function tr(r,t){let n;Te(r,["lalr","earley","cyk"]),typeof t!="object"&&(n={lalr:["basic","contextual"],earley:["basic","dynamic","dynamic_complete"],cyk:["basic"]}[r],Te(t,n,d("Parser %r does not support lexer %%r, expected one of %%s",r)))}function nr(r,t){let n,i={};for(const s of t)n=r&&r[s.name]||null,n!==null&&(i[s.name]=n);return i}class rr{constructor(t,n){this.lexer=t,this.postlexer=n}lex(t,n){let i=this.lexer.lex(t,n);return this.postlexer.process(i)}}function ir(r,t,n,i){return new _e(r)}function sr(r,t,n,i){let s=Object.fromEntries(x(t._parse_table.states).map(([o,l])=>[o,[...me(l)]])),a=n?n.always_accept:[];return new zn({conf:r,states:s,always_accept:a})}function ar(r,t,n=null){let i=n?n.debug:!1;return new ct({parser_conf:t,debug:i})}mt.lalr=ar;class ft extends He{constructor(){super(...arguments),R(this,"always_accept",[])}process(t){return t}}class or extends N{constructor(t){super(),R(this,"OPTIONS_DOC",'\n **=== General Options ===**\n\n start\n The start symbol. Either a string, or a list of strings for multiple possible starts (Default: "start")\n debug\n Display debug information and extra warnings. Use only when debugging (Default: ``False``)\n When used with Earley, it generates a forest graph as "sppf.png", if \'dot\' is installed.\n transformer\n Applies the transformer to every parse tree (equivalent to applying it after the parse, but faster)\n propagate_positions\n Propagates (line, column, end_line, end_column) attributes into all tree branches.\n Accepts ``False``, ``True``, or a callable, which will filter which nodes to ignore when propagating.\n maybe_placeholders\n When ``True``, the ``[]`` operator returns ``None`` when not matched.\n When ``False``, ``[]`` behaves like the ``?`` operator, and returns no value at all.\n (default= ``True``)\n cache\n Cache the results of the Lark grammar analysis, for x2 to x3 faster loading. LALR only for now.\n\n - When ``False``, does nothing (default)\n - When ``True``, caches to a temporary file in the local directory\n - When given a string, caches to the path pointed by the string\n regex\n When True, uses the ``regex`` module instead of the stdlib ``re``.\n g_regex_flags\n Flags that are applied to all terminals (both regex and strings)\n keep_all_tokens\n Prevent the tree builder from automagically removing "punctuation" tokens (Default: ``False``)\n tree_class\n Lark will produce trees comprised of instances of this class instead of the default ``lark.Tree``.\n\n **=== Algorithm Options ===**\n\n parser\n Decides which parser engine to use. Accepts "earley" or "lalr". (Default: "earley").\n (there is also a "cyk" option for legacy)\n lexer\n Decides whether or not to use a lexer stage\n\n - "auto" (default): Choose for me based on the parser\n - "basic": Use a basic lexer\n - "contextual": Stronger lexer (only works with parser="lalr")\n - "dynamic": Flexible and powerful (only with parser="earley")\n - "dynamic_complete": Same as dynamic, but tries *every* variation of tokenizing possible.\n ambiguity\n Decides how to handle ambiguity in the parse. Only relevant if parser="earley"\n\n - "resolve": The parser will automatically choose the simplest derivation\n (it chooses consistently: greedy for tokens, non-greedy for rules)\n - "explicit": The parser will return all derivations wrapped in "_ambig" tree nodes (i.e. a forest).\n - "forest": The parser will return the root of the shared packed parse forest.\n\n **=== Misc. / Domain Specific Options ===**\n\n postlex\n Lexer post-processing (Default: ``None``) Only works with the basic and contextual lexers.\n priority\n How priorities should be evaluated - "auto", ``None``, "normal", "invert" (Default: "auto")\n lexer_callbacks\n Dictionary of callbacks for the lexer. May alter tokens during lexing. Use with caution.\n use_bytes\n Accept an input of type ``bytes`` instead of ``str``.\n edit_terminals\n A callback for editing the terminals before parse.\n import_paths\n A List of either paths or loader functions to specify from where grammars are imported\n source_path\n Override the source of from where the grammar was loaded. Useful for relative imports and unconventional grammar loading\n **=== End of Options ===**\n '),R(this,"_defaults",{debug:!1,keep_all_tokens:!1,tree_class:null,cache:!1,postlex:null,parser:"earley",lexer:"auto",transformer:null,start:"start",priority:"auto",ambiguity:"auto",regex:!1,propagate_positions:!1,lexer_callbacks:{},maybe_placeholders:!0,edit_terminals:null,g_regex_flags:"",use_bytes:!1,import_paths:[],source_path:null,_plugins:null});let n,i=et(t),s=this;for(const[a,o]of x(this._defaults))a in i?(n=_n(i,a),typeof o=="boolean"&&!["cache","use_bytes","propagate_positions"].includes(a)&&(n=tt(n))):n=o,s[a]=n;if(typeof s.start=="string"&&(s.start=[s.start]),this.options=s,Te(this.parser,["earley","lalr","cyk",null]),this.parser==="earley"&&this.transformer)throw new A("Cannot specify an embedded transformer when using the Earley algorithm. Please use your transformer on the resulting parse tree, or use a different algorithm (i.e. LALR)");if(Object.keys(i).length)throw new A(d("Unknown options: %s",me(i)))}serialize(t){return this.options}static deserialize(t,n){const i=this;return new i(t)}}class yt extends N{static get __serialize_fields__(){return["parser","rules","options"]}_build_lexer(t=!1){let n=this.lexer_conf;return t&&(n=I(n),n.ignore=[]),new _e(n)}_prepare_callbacks(){this._callbacks=new Map,this.options.ambiguity!=="forest"&&(this._parse_tree_builder=new Vn(this.rules,this.options.tree_class||cn(g),this.options.propagate_positions,this.options.parser!=="lalr"&&this.options.ambiguity==="explicit",this.options.maybe_placeholders),this._callbacks=this._parse_tree_builder.create_callback(this.options.transformer)),Ye(this._callbacks,nr(this.options.transformer,this.terminals))}_deserialize_lexer_conf(t,n,i){let s=ot.deserialize(t.lexer_conf,n);return s.callbacks=i.lexer_callbacks||{},s.re_module=i.regex?regex:We,s.use_bytes=i.use_bytes,s.g_regex_flags=i.g_regex_flags||"",s.skip_validation=!0,s.postlex=i.postlex,s}_load({f:t,...n}={}){let i;ye(t)?i=t:i=pickle.load(t);let s=i.memo,a=i.data,o=wn.deserialize(s,{Rule:V,TerminalDef:oe},{}),l=et(a.options);return Ye(l,n),this.options=or.deserialize(l,o),this.rules=a.rules.map(c=>V.deserialize(c,o)),this.source_path="<deserialized>",tr(this.options.parser,this.options.lexer),this.lexer_conf=this._deserialize_lexer_conf(a.parser,o,this.options),this.terminals=this.lexer_conf.terminals,this._prepare_callbacks(),this._terminals_dict=Object.fromEntries(this.terminals.map(c=>[c.name,c])),this.parser=Kn(a.parser,o,this.lexer_conf,this._callbacks,this.options),this}static _load_from_dict({data:t,memo:n,...i}={}){return fe(this)._load({f:{data:t,memo:n},...i})}repr(){return d("Lark(open(%r), parser=%r, lexer=%r, ...)",this.source_path,this.options.parser,this.options.lexer)}lex(t,n=!1){let i;!("lexer"in this)||n?i=this._build_lexer(n):i=this.lexer;let s=at.from_text(i,t).lex(null);return this.options.postlex?this.options.postlex.process(s):s}get_terminal(t){return this._terminals_dict[t]}parse_interactive(t=null,n=null){return this.parser.parse_interactive({unknown_param_0:t,start:n})}parse(t,n=null,i=null){return this.parser.parse(t,n,i)}}class gt extends S{}class xt extends ft{constructor(){super(),this.paren_level=0,this.indent_level=[0]}*handle_NL(t){if(this.paren_level>0)return;yield t;let n=xe(t.value,`
21
- `,1)[1],i=we(n," ")+we(n," ")*this.tab_len;if(i>E(this.indent_level))this.indent_level.push(i),yield f.new_borrow_pos(this.INDENT_type,n,t);else{for(;i<E(this.indent_level);)this.indent_level.pop(),yield f.new_borrow_pos(this.DEDENT_type,n,t);if(i!==E(this.indent_level))throw new gt(d("Unexpected dedent to column %s. Expected dedent to %s",i,E(this.indent_level)))}}*_process(t){for(const n of t)n.type===this.NL_type?yield*this.handle_NL(n):yield n,this.OPEN_PAREN_types.includes(n.type)?this.paren_level+=1:this.CLOSE_PAREN_types.includes(n.type)&&(this.paren_level-=1);for(;this.indent_level.length>1;)this.indent_level.pop(),yield new f(this.DEDENT_type,"")}process(t){return this.paren_level=0,this.indent_level=[0],this._process(t)}get always_accept(){return[this.NL_type]}get NL_type(){throw new NotImplementedError}get OPEN_PAREN_types(){throw new NotImplementedError}get CLOSE_PAREN_types(){throw new NotImplementedError}get INDENT_type(){throw new NotImplementedError}get DEDENT_type(){throw new NotImplementedError}get tab_len(){throw new NotImplementedError}}class lr extends xt{static get NL_type(){return"_NEWLINE"}get NL_type(){return this.constructor.NL_type}static get OPEN_PAREN_types(){return["LPAR","LSQB","LBRACE"]}get OPEN_PAREN_types(){return this.constructor.OPEN_PAREN_types}static get CLOSE_PAREN_types(){return["RPAR","RSQB","RBRACE"]}get CLOSE_PAREN_types(){return this.constructor.CLOSE_PAREN_types}static get INDENT_type(){return"_INDENT"}get INDENT_type(){return this.constructor.INDENT_type}static get DEDENT_type(){return"_DEDENT"}get DEDENT_type(){return this.constructor.DEDENT_type}static get tab_len(){return 8}get tab_len(){return this.constructor.tab_len}}const _r={Terminal:Ne,NonTerminal:ke,RuleOptions:ae,PatternStr:Ie,PatternRE:qe,TerminalDef:oe};var cr={LarkError:S,ConfigurationError:A,GrammarError:ie,ParseError:yn,LexError:J,UnexpectedInput:z,UnexpectedEOF:gn,UnexpectedCharacters:U,UnexpectedToken:F,VisitError:ve,Meta:it,Tree:g,Discard:te,Transformer:Y,Transformer_InPlace:st,Transformer_NonRecursive:Tn,Transformer_InPlaceRecursive:vn,VisitorBase:be,Visitor:bn,Visitor_Recursive:En,Interpreter:Nn,Symbol:Ee,Terminal:Ne,NonTerminal:ke,RuleOptions:ae,Rule:V,Pattern:Re,PatternStr:Ie,PatternRE:qe,TerminalDef:oe,Token:f,Lexer:le,LexerConf:ot,ParserConf:lt,InteractiveParser:D,ImmutableInteractiveParser:ut,PostLex:ft,Lark:yt,DedentError:gt,Indenter:xt,PythonIndenter:lr,get_parser:on},pr={parser:{lexer_conf:{terminals:[{"@":0},{"@":1},{"@":2},{"@":3},{"@":4},{"@":5},{"@":6},{"@":7},{"@":8},{"@":9},{"@":10},{"@":11},{"@":12},{"@":13},{"@":14},{"@":15},{"@":16},{"@":17},{"@":18},{"@":19},{"@":20}],ignore:["WS"],g_regex_flags:0,use_bytes:!1,lexer_type:"contextual",__type__:"LexerConf"},parser_conf:{rules:[{"@":21},{"@":22},{"@":23},{"@":24},{"@":25},{"@":26},{"@":27},{"@":28},{"@":29},{"@":30},{"@":31},{"@":32},{"@":33},{"@":34},{"@":35},{"@":36},{"@":37},{"@":38},{"@":39},{"@":40},{"@":41},{"@":42},{"@":43},{"@":44},{"@":45},{"@":46},{"@":47},{"@":48},{"@":49},{"@":50},{"@":51},{"@":52},{"@":53},{"@":54}],start:["start"],parser_type:"lalr",__type__:"ParserConf"},parser:{tokens:{0:"$END",1:"RPAR",2:"LSQB",3:"DOT",4:"question_selector",5:"IDENTIFIER",6:"OPERATOR",7:"CONJUNCTION",8:"__ANON_3",9:"__ANON_1",10:"qc_mc_text",11:"FALSE",12:"bool_expr",13:"__ANON_0",14:"__ANON_2",15:"__ANON_5",16:"qc_mc_count",17:"qc_matrix_selected",18:"condition",19:"qc_selected_value",20:"bool_const",21:"qc_matrix_count",22:"NEGATION",23:"__ANON_4",24:"TRUE",25:"qc_mc_selected",26:"qc_mc_text_ignore_case",27:"__ANON_6",28:"INT",29:"RSQB",30:"matrix_statement_selector",31:"matrix_choice_selector",32:"mc_choice_selector",33:"STRING",34:"question_or_matrix_statement_selector",35:"top_level_expr",36:"LPAR",37:"start"},states:{0:{0:[1,{"@":22}]},1:{1:[1,{"@":45}],2:[1,{"@":45}],3:[1,{"@":45}]},2:{2:[1,{"@":48}],1:[1,{"@":48}]},3:{1:[0,10]},4:{1:[0,9]},5:{4:[0,8],5:[0,1]},6:{2:[0,50]},7:{},8:{1:[0,57]},9:{6:[0,65]},10:{1:[1,{"@":42}],0:[1,{"@":42}],7:[1,{"@":42}]},11:{8:[0,66],9:[0,35],10:[0,44],11:[0,63],12:[0,49],13:[0,56],14:[0,54],15:[0,34],16:[0,75],17:[0,68],18:[0,78],19:[0,69],20:[0,36],21:[0,71],22:[0,80],23:[0,5],24:[0,43],25:[0,39],26:[0,51]},12:{0:[1,{"@":24}]},13:{6:[0,70]},14:{2:[0,77],3:[0,28]},15:{3:[0,28],1:[1,{"@":51}]},16:{1:[1,{"@":41}],0:[1,{"@":41}],7:[1,{"@":41}]},17:{27:[0,73]},18:{1:[1,{"@":52}]},19:{8:[0,66],9:[0,35],10:[0,44],11:[0,63],25:[0,39],12:[0,27],13:[0,56],14:[0,54],15:[0,34],16:[0,75],17:[0,68],18:[0,78],19:[0,69],21:[0,71],22:[0,80],23:[0,5],24:[0,43],26:[0,51],20:[0,36]},20:{27:[0,13]},21:{6:[0,47]},22:{6:[0,23]},23:{28:[0,60]},24:{1:[0,16]},25:{2:[0,77]},26:{0:[1,{"@":21}]},27:{1:[0,29]},28:{5:[0,2]},29:{7:[0,81],0:[1,{"@":23}]},30:{1:[0,22]},31:{1:[0,21]},32:{29:[0,64]},33:{1:[0,52]},34:{5:[0,1],4:[0,76]},35:{30:[0,6],5:[0,1],4:[0,14],31:[0,3],32:[0,41]},36:{1:[1,{"@":27}],0:[1,{"@":27}],7:[1,{"@":27}]},37:{29:[0,53]},38:{1:[1,{"@":40}],0:[1,{"@":40}],7:[1,{"@":40}]},39:{1:[1,{"@":29}],0:[1,{"@":29}],7:[1,{"@":29}]},40:{1:[1,{"@":43}],0:[1,{"@":43}],7:[1,{"@":43}]},41:{1:[0,61]},42:{28:[0,40]},43:{1:[1,{"@":53}],0:[1,{"@":53}],7:[1,{"@":53}]},44:{1:[1,{"@":30}],0:[1,{"@":30}],7:[1,{"@":30}]},45:{1:[1,{"@":50}]},46:{1:[1,{"@":39}],0:[1,{"@":39}],7:[1,{"@":39}]},47:{33:[0,48]},48:{1:[1,{"@":38}],0:[1,{"@":38}],7:[1,{"@":38}]},49:{0:[1,{"@":26}],1:[1,{"@":26}]},50:{5:[0,55],28:[0,62]},51:{1:[1,{"@":31}],0:[1,{"@":31}],7:[1,{"@":31}]},52:{1:[1,{"@":36}],0:[1,{"@":36}],7:[1,{"@":36}]},53:{1:[1,{"@":47}]},54:{4:[0,25],32:[0,31],5:[0,1]},55:{29:[0,45]},56:{4:[0,15],5:[0,1],30:[0,18],34:[0,30]},57:{6:[0,58]},58:{28:[0,38]},59:{28:[0,17],5:[0,20]},60:{1:[1,{"@":35}],0:[1,{"@":35}],7:[1,{"@":35}]},61:{1:[1,{"@":37}],0:[1,{"@":37}],7:[1,{"@":37}]},62:{29:[0,79]},63:{1:[1,{"@":54}],0:[1,{"@":54}],7:[1,{"@":54}]},64:{1:[1,{"@":46}]},65:{33:[0,46]},66:{4:[0,25],32:[0,4],5:[0,1]},67:{30:[0,6],5:[0,1],4:[0,14],32:[0,33],31:[0,24]},68:{1:[1,{"@":33}],0:[1,{"@":33}],7:[1,{"@":33}]},69:{1:[1,{"@":28}],0:[1,{"@":28}],7:[1,{"@":28}]},70:{28:[0,74]},71:{1:[1,{"@":34}],0:[1,{"@":34}],7:[1,{"@":34}]},72:{8:[0,66],35:[0,26],9:[0,35],10:[0,44],11:[0,63],36:[0,19],25:[0,39],13:[0,56],14:[0,54],15:[0,34],16:[0,75],17:[0,68],18:[0,78],19:[0,69],37:[0,7],12:[0,0],21:[0,71],22:[0,80],23:[0,5],24:[0,43],26:[0,51],20:[0,36]},73:{6:[0,42]},74:{1:[1,{"@":44}],0:[1,{"@":44}],7:[1,{"@":44}]},75:{1:[1,{"@":32}],0:[1,{"@":32}],7:[1,{"@":32}]},76:{2:[0,59]},77:{28:[0,32],5:[0,37]},78:{7:[0,11],0:[1,{"@":25}],1:[1,{"@":25}]},79:{1:[1,{"@":49}]},80:{9:[0,67]},81:{35:[0,12],36:[0,19]}},start_states:{start:72},end_states:{start:7}},__type__:"ParsingFrontend"},rules:[{"@":21},{"@":22},{"@":23},{"@":24},{"@":25},{"@":26},{"@":27},{"@":28},{"@":29},{"@":30},{"@":31},{"@":32},{"@":33},{"@":34},{"@":35},{"@":36},{"@":37},{"@":38},{"@":39},{"@":40},{"@":41},{"@":42},{"@":43},{"@":44},{"@":45},{"@":46},{"@":47},{"@":48},{"@":49},{"@":50},{"@":51},{"@":52},{"@":53},{"@":54}],options:{debug:!1,keep_all_tokens:!1,tree_class:null,cache:!1,postlex:null,parser:"lalr",lexer:"contextual",transformer:null,start:["start"],priority:"normal",ambiguity:"auto",regex:!1,propagate_positions:!1,lexer_callbacks:{},maybe_placeholders:!1,edit_terminals:null,g_regex_flags:0,use_bytes:!1,import_paths:[],source_path:null,_plugins:{}},__type__:"Lark"},ur={0:{name:"WS",pattern:{value:`(?:[ \f\r
22
- ])+`,flags:[],_width:[1,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},1:{name:"IDENTIFIER",pattern:{value:"[a-zA-Z][a-zA-Z0-9_]*[a-zA-Z0-9]",flags:[],_width:[2,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},2:{name:"INT",pattern:{value:"-?[0-9]+",flags:[],_width:[1,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},3:{name:"STRING",pattern:{value:`(?:'[^\\']*'|"[^"]*")`,flags:[],_width:[2,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},4:{name:"OPERATOR",pattern:{value:"(?:regex_matches|not_contains|contains|==|!=|<=|>=|<|>)",flags:[],_width:[1,13],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},5:{name:"CONJUNCTION",pattern:{value:"(?:and|or)",flags:[],_width:[2,3],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},6:{name:"NEGATION",pattern:{value:"!",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},7:{name:"TRUE",pattern:{value:"true",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},8:{name:"FALSE",pattern:{value:"false",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},9:{name:"LPAR",pattern:{value:"(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},10:{name:"RPAR",pattern:{value:")",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},11:{name:"__ANON_0",pattern:{value:"selected_value(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},12:{name:"__ANON_1",pattern:{value:"selected(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},13:{name:"__ANON_2",pattern:{value:"text(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},14:{name:"__ANON_3",pattern:{value:"text_ignore_case(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},15:{name:"__ANON_4",pattern:{value:"count_selected(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},16:{name:"__ANON_5",pattern:{value:"count_choice_selections(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},17:{name:"LSQB",pattern:{value:"[",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},18:{name:"__ANON_6",pattern:{value:"])",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},19:{name:"RSQB",pattern:{value:"]",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},20:{name:"DOT",pattern:{value:".",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},21:{origin:{name:"start",__type__:"NonTerminal"},expansion:[{name:"top_level_expr",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},22:{origin:{name:"start",__type__:"NonTerminal"},expansion:[{name:"bool_expr",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},23:{origin:{name:"top_level_expr",__type__:"NonTerminal"},expansion:[{name:"LPAR",filter_out:!0,__type__:"Terminal"},{name:"bool_expr",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},24:{origin:{name:"top_level_expr",__type__:"NonTerminal"},expansion:[{name:"LPAR",filter_out:!0,__type__:"Terminal"},{name:"bool_expr",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"CONJUNCTION",filter_out:!1,__type__:"Terminal"},{name:"top_level_expr",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},25:{origin:{name:"bool_expr",__type__:"NonTerminal"},expansion:[{name:"condition",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},26:{origin:{name:"bool_expr",__type__:"NonTerminal"},expansion:[{name:"condition",__type__:"NonTerminal"},{name:"CONJUNCTION",filter_out:!1,__type__:"Terminal"},{name:"bool_expr",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},27:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"bool_const",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},28:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_selected_value",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},29:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_selected",__type__:"NonTerminal"}],order:2,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},30:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_text",__type__:"NonTerminal"}],order:3,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},31:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_text_ignore_case",__type__:"NonTerminal"}],order:4,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},32:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_count",__type__:"NonTerminal"}],order:5,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},33:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_matrix_selected",__type__:"NonTerminal"}],order:6,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},34:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_matrix_count",__type__:"NonTerminal"}],order:7,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},35:{origin:{name:"qc_selected_value",__type__:"NonTerminal"},expansion:[{name:"__ANON_0",filter_out:!0,__type__:"Terminal"},{name:"question_or_matrix_statement_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},36:{origin:{name:"qc_mc_selected",__type__:"NonTerminal"},expansion:[{name:"NEGATION",filter_out:!1,__type__:"Terminal"},{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},37:{origin:{name:"qc_mc_selected",__type__:"NonTerminal"},expansion:[{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},38:{origin:{name:"qc_mc_text",__type__:"NonTerminal"},expansion:[{name:"__ANON_2",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"STRING",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},39:{origin:{name:"qc_mc_text_ignore_case",__type__:"NonTerminal"},expansion:[{name:"__ANON_3",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"STRING",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},40:{origin:{name:"qc_mc_count",__type__:"NonTerminal"},expansion:[{name:"__ANON_4",filter_out:!0,__type__:"Terminal"},{name:"question_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},41:{origin:{name:"qc_matrix_selected",__type__:"NonTerminal"},expansion:[{name:"NEGATION",filter_out:!1,__type__:"Terminal"},{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"matrix_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},42:{origin:{name:"qc_matrix_selected",__type__:"NonTerminal"},expansion:[{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"matrix_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},43:{origin:{name:"qc_matrix_count",__type__:"NonTerminal"},expansion:[{name:"__ANON_5",filter_out:!0,__type__:"Terminal"},{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"},{name:"__ANON_6",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},44:{origin:{name:"qc_matrix_count",__type__:"NonTerminal"},expansion:[{name:"__ANON_5",filter_out:!0,__type__:"Terminal"},{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"},{name:"__ANON_6",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},45:{origin:{name:"question_selector",__type__:"NonTerminal"},expansion:[{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},46:{origin:{name:"mc_choice_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},47:{origin:{name:"mc_choice_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},48:{origin:{name:"matrix_statement_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"},{name:"DOT",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},49:{origin:{name:"matrix_choice_selector",__type__:"NonTerminal"},expansion:[{name:"matrix_statement_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},50:{origin:{name:"matrix_choice_selector",__type__:"NonTerminal"},expansion:[{name:"matrix_statement_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},51:{origin:{name:"question_or_matrix_statement_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},52:{origin:{name:"question_or_matrix_statement_selector",__type__:"NonTerminal"},expansion:[{name:"matrix_statement_selector",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},53:{origin:{name:"bool_const",__type__:"NonTerminal"},expansion:[{name:"TRUE",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},54:{origin:{name:"bool_const",__type__:"NonTerminal"},expansion:[{name:"FALSE",filter_out:!1,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"}};const hr="(?<questionId>[a-zA-Z][a-zA-Z0-9_]*)",dr="((?<expressionWithoutIdentifier>all|all_entered_text|selected|selected_entered_text|not_selected)|(?<expressionWithIdentifier>for_matrix_choice|unselected_for_matrix_choice)(\\((?<identifier>[\\-a-zA-Z0-9_]+)\\)))",wt=new RegExp(`^${hr}/${dr}$`);var T=(r=>(r.ALL="all",r.ALL_ENTERED_TEXT="all_entered_text",r.SELECTED="selected",r.SELECTED_ENTERED_TEXT="selected_entered_text",r.NOT_SELECTED="not_selected",r.FOR_MATRIX_CHOICE="for_matrix_choice",r.UNSELECTED_FOR_MATRIX_CHOICE="unselected_for_matrix_choice",r))(T||{});const Tt=r=>wt.test(r),L=r=>{var t;const n=(t=r.match(wt))==null?void 0:t.groups;if(!n)throw new Error(`Invalid locator expression: ${r}`);const i=n.expressionWithoutIdentifier||n.expressionWithIdentifier||"all",s={questionId:n.questionId,expression:i};if(n.identifier){const a=isNaN(parseInt(n.identifier,10))?n.identifier:parseInt(n.identifier,10);s.identifier=a}return s},ce=(r,t="camelCase")=>{const n=t==="camelCase"?ee.camelCase:ee.snakeCase;return ee.transform(r,(i,s,a)=>{const o=typeof a=="string"?n(a):a;i[o]=ee.isObject(s)?ce(s,t):s})};function mr(r){const t=structuredClone(r);return{...t,...t.template,templateId:t.template.id,sections:t.sections.map(n=>({...ce(n),pages:n.pages.map((i,s)=>({...i,id:`${n.id}-${s}`,questions:fr(t,n,i.questions)}))}))}}function fr(r,t,n){return n.map(i=>yr(r.template.id,t,i))}function yr(r,t,n){var i,s;return{...ce({...n,choiceGroups:(i=n.choice_groups)==null?void 0:i.map(a=>({...a,randomization:Ae(a.randomization)})),statementGroups:(s=n.statement_groups)==null?void 0:s.map(a=>({...a,randomization:Ae(a.randomization)})),randomization:Ae(n.randomization)}),id:bt(r,n),type:Et(n.type),layout:gr(n.layout),required:xr(n.required),label:t.name}}function Ae(r){var t;return r?{type:vt(r.type),order:(t=r.order)==null?void 0:t.split(" "),total:r.total}:void 0}function vt(r){return r.toUpperCase()}function bt(r,t){return`${r}.${t.id}`}const $e=r=>r.split(".").pop();function Et(r="description"){return r.replace("-","_").toUpperCase()}function gr(r){return r==null?void 0:r.toUpperCase()}function xr(r="optional"){return r.replace("-","_").toUpperCase()}function Nt(r){return structuredClone(r).sections.flatMap(t=>t.pages.flatMap(n=>n.questions))}var wr=Object.defineProperty,Tr=(r,t,n)=>t in r?wr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,Z=(r,t,n)=>(Tr(r,typeof t!="symbol"?t+"":t,n),n),vr=(r,t,n)=>{if(!t.has(r))throw TypeError("Cannot "+n)},kt=(r,t,n)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,n)},C=(r,t,n)=>(vr(r,t,"access private method"),n),Q,B,pe,ze;const De=/\$\{q\:(?<locator>[\-a-zA-Z0-9_\/\(\)]+)\}/g,Rt=r=>{var t,n;return(n=(t=r.choiceId)!=null?t:r.choiceValue)!=null?n:r.text};class br{constructor(t,n=[],i="",s=!1){kt(this,Q),kt(this,pe),Z(this,"questions",new Map),Z(this,"responsesByQuestion",new Map),Z(this,"responsesByQuestionStatement",new Map),Z(this,"hashSalt"),Z(this,"forExport"),Z(this,"evaluationCache",new Map),this.questions=new Map((t?Nt(t):[]).filter(a=>a.id).map(a=>[$e(a.id),a])),n.filter(a=>a.singleAnswer||a.multipleAnswers).forEach(a=>{const o=$e(a.questionId);this.responsesByQuestion.set(o,[...this.responsesByQuestion.get(o)||[],a]),a.statementId&&this.responsesByQuestionStatement.set(`${o}.${a.statementId}`,a)}),this.hashSalt=i,this.forExport=s}evaluateDisplayLogic(t){if(t&&!this.forExport)try{const n=this.evaluationCache.get(t);if(n!==void 0)return n;const i=Le(t,this);return this.evaluationCache.set(t,i),i}catch(n){return console.error(n),!1}return!0}evaluateDynamicExpression(t,n){const i=this.questions.get(t.questionId);if(!i)return[];const s=this.getQuestionChoicesFlattened(i),a=s.filter(p=>this.isSelected({questionId:t.questionId,choice:p.id||p.value})),o=this.getQuestionStatementsFlattened(i),l=p=>n==="choices"?p:{...p,id:p.id||p.value||p.display},c=p=>({id:p.id,display:p.display,value:p.value});let _=[];switch(t.expression){case T.ALL:_=s.map(l);break;case T.ALL_ENTERED_TEXT:_=s.map(p=>l(C(this,pe,ze).call(this,p,t)));break;case T.SELECTED:_=a;break;case T.SELECTED_ENTERED_TEXT:_=a.map(p=>l(C(this,pe,ze).call(this,p,t)));break;case T.NOT_SELECTED:_=s.filter(p=>!this.isSelected({questionId:t.questionId,choice:p.id||p.value})).map(l);break;case T.FOR_MATRIX_CHOICE:_=o.filter(p=>this.isSelected({questionId:t.questionId,statementId:p.id,choice:t.identifier}));break;case T.UNSELECTED_FOR_MATRIX_CHOICE:_=o.filter(p=>!this.isSelected({questionId:t.questionId,statementId:p.id,choice:t.identifier}));break;default:_=[]}return this.forExport&&(_=t.expression===T.FOR_MATRIX_CHOICE||t.expression===T.UNSELECTED_FOR_MATRIX_CHOICE?o:s.map(l)),_.map(c)}isSelected(t){return!!C(this,Q,B).call(this,t.questionId,t.statementId,t.choice).length}countSelected(t){return C(this,Q,B).call(this,t).length}selectedValue(t){const n=C(this,Q,B).call(this,t.questionId,t.statementId);return n.length?Rt(n[0]):0}countChoiceSelections(t,n){return C(this,Q,B).call(this,t,null,n).length}textEntry(t){return C(this,Q,B).call(this,t.questionId,t.statementId,t.choice).map(n=>n.text).filter(n=>n).join(", ")}getQuestionText(t){let n=t.text;return n=n.replaceAll(De,(i,s)=>{if(s&&Tt(s)){const a=L(s);return this.evaluateDynamicExpression(a,"choices").map(o=>o.display).join(", ")}return i}),n}getQuestionChoices(t){var n;const i=((n=t.choices)!=null?n:[]).filter(s=>this.evaluateDisplayLogic(s.displayLogic));if(t.dynamicChoices){const s=L(t.dynamicChoices),a=this.evaluateDynamicExpression(s,"choices");i.push(...a)}return t.type===de.MatrixSingle||t.type===de.MatrixMulti?i:this.applyRandomization(i,t.id,s=>{var a;return`${(a=s.id)!=null?a:s.value}`},t.randomization)}getQuestionChoiceGroups(t){var n;const i=(((n=t.choiceGroups)==null?void 0:n.filter(s=>this.evaluateDisplayLogic(s.displayLogic)))||[]).map(s=>({...s,choices:this.applyRandomization(s.choices.filter(a=>this.evaluateDisplayLogic(a.displayLogic)),t.id,a=>{var o;return`${(o=a.id)!=null?o:a.value}`},s.randomization)})).filter(s=>!!s.choices.length);return this.applyRandomization(i,t.id,s=>s.id,t.randomization)}getQuestionStatements(t){var n;const i=((n=t.statements)!=null?n:[]).filter(s=>this.evaluateDisplayLogic(s.displayLogic));if(t.dynamicStatements){const s=L(t.dynamicStatements),a=this.evaluateDynamicExpression(s,"statements");i.push(...a)}return this.applyRandomization(i,t.id,s=>s.id,t.randomization)}getQuestionStatementGroups(t){var n;const i=(((n=t.statementGroups)==null?void 0:n.filter(s=>this.evaluateDisplayLogic(s.displayLogic)))||[]).map(s=>({...s,statements:this.applyRandomization(s.statements.filter(a=>this.evaluateDisplayLogic(a.displayLogic)),t.id,a=>a.id,s.randomization)})).filter(s=>!!s.statements.length);return this.applyRandomization(i,t.id,s=>s.id,t.randomization)}getQuestionChoicesFlattened(t){return[...this.getQuestionChoices(t),...this.getQuestionChoiceGroups(t).flatMap(n=>n.choices)]}getQuestionStatementsFlattened(t){return[...this.getQuestionStatements(t),...this.getQuestionStatementGroups(t).flatMap(n=>n.statements)]}applyRandomization(t,n,i,s){var a,o;if(!s)return t;const l=new Map(t.map(h=>[i(h),h])),c=[...l.keys()],_=new Set(c),p=((a=s.order)!=null?a:["$"]).filter(h=>h==="$"||_.has(h)),y=c.filter(h=>!p.includes(h)).map(h=>({weight:this.keyHash(n,h),key:h}));y.sort((h,m)=>h.weight.localeCompare(m.weight));const v=(o=s.total)!=null?o:c.length,w=Math.min(v-(p.length-1),y.length),u=[];return p.forEach(h=>{h==="$"?u.push(...y.slice(0,w).map(m=>m.key)):u.push(h)}),u.map(h=>l.get(h))}keyHash(t,n){const i=`${t}.${this.hashSalt}.${n}`;return Qt.createHash("sha256").update(i).digest("hex")}}Q=new WeakSet,B=function(r,t,n){let i;if(t){const s=this.responsesByQuestionStatement.get(`${r}.${t}`);i=s===void 0?[]:[s]}else i=this.responsesByQuestion.get(r)||[];return i.flatMap(s=>{const{multipleAnswers:a,singleAnswer:o}=s;return(a||[o]).filter(l=>typeof n=="undefined"||n===null||Rt(l)===n)})},pe=new WeakSet,ze=function(r,t){if(r.textInput&&["forced","optional"].includes(r.textInput)){const n=this.textEntry({questionId:t.questionId,choice:r.id||r.value});return{...r,display:n}}return r};function It(r){if(r.length===1)return r[0];const t=r[1].value;return t==="or"?r[0]||r[2]:t==="and"?r[0]&&r[2]:!1}function ue(r,t,n){switch(t){case"==":return r===n;case"!=":return r!==n;case"<=":return r<=n;case">=":return r>=n;case"<":return r<n;case">":return r>n;default:return!1}}function qt(r,t,n,i){const s=i?r.toLowerCase():r,a=i?n.toLowerCase():n;switch(t){case"contains":return s.includes(a);case"not_contains":return!s.includes(a);case"regex_matches":try{return new RegExp(n).test(s)}catch{return!1}default:return ue(s,t,a)}}function Ot(r,t){return r.length===1?t(r[0]):(Ue(r[0].type==="NEGATION"),!t(r[1]))}function Pe(r){if(!["INT","IDENTIFIER"].includes(r.type))throw new SyntaxError(`Invalid token type: ${r.type}; expected IDENTIFIER or INT`);return k(r)}function k(r){var t,n;switch(r.type){case"IDENTIFIER":return r.value;case"INT":return parseInt(r.value,10);case"STRING":{const i=r.value.match(/(?:'(?<single>[^\']*)')|(?:"(?<double>[^\"]*)")/),s=((t=i==null?void 0:i.groups)==null?void 0:t.double)||((n=i==null?void 0:i.groups)==null?void 0:n.single);return Ue(s),s}case"OPERATOR":return r.value;case"TRUE":return!0;case"FALSE":return!1;default:throw new SyntaxError(`Invalid token type: ${r.type}`)}}function Le(r,t){const n={start:i=>i[0],top_level_expr:It,bool_expr:It,condition:i=>i[0],qc_mc_selected:i=>Ot(i,s=>t.isSelected(s)),qc_mc_text:i=>qt(t.textEntry(i[0]),k(i[1]),k(i[2]),!1),qc_mc_text_ignore_case:i=>qt(t.textEntry(i[0]),k(i[1]),k(i[2]),!0),qc_mc_count:i=>ue(t.countSelected(i[0]),k(i[1]),k(i[2])),qc_matrix_selected:i=>Ot(i,s=>t.isSelected(s)),qc_selected_value:i=>ue(t.selectedValue(i[0]),k(i[1]),k(i[2])),qc_matrix_count:i=>ue(t.countChoiceSelections(i[0],Pe(i[1])),k(i[2]),k(i[3])),question_selector:i=>i[0].value,question_or_matrix_statement_selector:i=>typeof i[0]=="string"?{questionId:i[0]}:i[0],mc_choice_selector:i=>({questionId:i[0],choice:Pe(i[1])}),matrix_statement_selector:i=>({questionId:i[0],statementId:k(i[1])}),matrix_choice_selector:i=>({...i[0],choice:Pe(i[1])}),bool_const:i=>i[0].value==="true"};return cr.get_parser({transformer:n}).parse(r)}const Er=/\$\{m:([^\}]+)\}/g,Nr=100,Ce=(r,t)=>{if(typeof t=="string"){let n=t,i=0;for(;i<Nr;){const s=n.replace(Er,(a,o)=>{if(r[o]===void 0)throw new Error(`Undefined macro: ${o}`);return r[o]});if(s===n)return s;n=s,i+=1}throw new Error(`Failed to finish interpolate macros - cyclic macros!? Stuck at: ${t}"`)}return typeof t=="object"&&Object.keys(t).forEach(n=>{t[n]=Ce(r,t[n])}),t},St=r=>(r.sections=Ce(r.macros||{},r.sections),r);var kr=Object.defineProperty,Rr=(r,t,n)=>t in r?kr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,M=(r,t,n)=>(Rr(r,typeof t!="symbol"?t+"":t,n),n);const At=new Lt({allowUnionTypes:!0});Ct(At);const $t=At.compile(Ze);class K extends Error{}class $ extends Error{}class he extends Error{}class j extends Error{}class Ir extends Error{}class qr{constructor(){M(this,"seenQuestions",new Set),M(this,"seenMultiQuestions",new Set),M(this,"seenQuestionStatements",new Map),M(this,"seenQuestionChoices",new Map),M(this,"seenTextChoices",new Map),M(this,"evaluator",{}),M(this,"validateReference",t=>{var n,i,s;if(!this.seenQuestions.has(t.questionId))throw new K(`Invalid question: ${t.questionId}`);if(t.statementId!==void 0&&!((n=this.seenQuestionStatements.get(t.questionId))!=null&&n.has(t.statementId)))throw new K(`Invalid statement: ${t.questionId}.${t.statementId}`);if(t.choice!==void 0&&!((i=this.seenQuestionChoices.get(t.questionId))!=null&&i.has(t.choice)))throw new K(`Invalid choice: ${t.questionId}[${t.choice}]`);if(t.choice!==void 0&&t.expectText===!0&&!((s=this.seenTextChoices.get(t.questionId))!=null&&s.has(t.choice)))throw new K(`Invalid text reference: ${t.questionId}[${t.choice}]`);if(typeof t.expectMulti=="boolean"&&t.expectMulti&&!this.seenMultiQuestions.has(t.questionId))throw new $(`Invalid question reference: ${t.questionId}. Expected a multi-answer question.`);if(typeof t.expectMulti=="boolean"&&!t.expectMulti&&this.seenMultiQuestions.has(t.questionId))throw new $(`Invalid question reference: ${t.questionId}. Expected a non-multi-answer question.`)}),this.evaluator.isSelected=t=>(this.validateReference(t),!1),this.evaluator.countSelected=t=>(this.validateReference({questionId:t}),0),this.evaluator.selectedValue=t=>(this.validateReference({questionId:t.questionId,statementId:t.statementId,expectMulti:!1}),0),this.evaluator.countChoiceSelections=(t,n)=>(this.validateReference({questionId:t,choice:n}),0),this.evaluator.textEntry=t=>(this.validateReference({...t,expectText:!0}),"")}}const G=(r,t,n)=>{if(n)try{Le(n,r.evaluator)}catch(i){throw i instanceof K||i instanceof $||i instanceof j?i:new Error(`Syntax error parsing display logic at ${t}: ${n}`)}},Or=(r,t)=>{[...t.matchAll(De)].forEach(n=>{var i;const s=L(n.groups.locator);if(!r.seenQuestions.has(s.questionId))throw new $(`Invalid question referenced in locator expression: ${s.questionId}/${s.expression}`);if(s.identifier&&!((i=r.seenQuestionChoices.get(s.questionId))!=null&&i.has(s.identifier)))throw new $(`Invalid question choice referenced in locator expression: ${s.questionId}/${s.expression}(${s.identifier})`)})},W=(r,t,n)=>{if(n){const i=new Set(t);if(n.order){const s=n.order.split(" "),a=s.filter(o=>o==="$").length;if(a===0)throw new he(`Wildcard $ is missing in randomization order at ${r.id}`);if(a>1)throw new he(`Wildcard $ occurred multiples times in randomization order at ${r.id}`);if(s.forEach(o=>{if(o!=="$"&&!i.has(o))throw new he(`Unknown id ${o} in randomization ordering at ${r.id}`)}),n.total!==void 0&&n.total<s.length)throw new he(`Total value in randomization is too small at ${r.id}`)}}},zt=(r,t)=>{const n=[T.FOR_MATRIX_CHOICE,T.UNSELECTED_FOR_MATRIX_CHOICE].includes(r.expression),i=(n?t.seenQuestionStatements:t.seenQuestionChoices).get(r.questionId);if(i===void 0)throw new $(`Invalid question referenced in locator expression: ${r.questionId}/${r.expression}`);if(n){const s=t.seenQuestionChoices.get(r.questionId);if(!r.identifier||!(s!=null&&s.has(r.identifier)))throw new $(`Invalid choice referenced in locator expression: ${r.questionId}/${r.expression}(${r.identifier})`)}return i},Sr=(r,t)=>{var n,i,s,a,o,l,c,_,p,y,v;if(Or(t,r.text),r.id!==void 0){if(G(t,r.id,r.display_logic),(n=r.statements)==null||n.forEach(u=>{G(t,`${r.id}.${u.id}`,u.display_logic)}),(i=r.choices)==null||i.forEach(u=>{G(t,`${r.id}[${u.id||u.value}]`,u.display_logic)}),r.type==="matrix-multi"||r.type==="matrix-single"?r.statement_groups?W(r,r.statement_groups.map(u=>u.id),r.randomization):W(r,(a=(s=r.statements)==null?void 0:s.map(u=>u.id))!=null?a:[],r.randomization):r.choice_groups?W(r,r.choice_groups.map(u=>u.id),r.randomization):W(r,(l=(o=r.choices)==null?void 0:o.map(u=>`${u.id||u.value}`))!=null?l:[],r.randomization),(c=r.statement_groups)==null||c.forEach(u=>{u.statements.forEach(h=>{G(t,`${r.id}.${h.id}`,h.display_logic)}),W(r,u.statements.map(h=>h.id),u.randomization)}),(_=r.choice_groups)==null||_.forEach(u=>{u.choices.forEach(h=>{G(t,`${r.id}[${h.id||h.value}]`,h.display_logic)}),W(r,u.choices.map(h=>`${h.id||h.value}`),u.randomization)}),t.seenQuestions.has(r.id))throw new j(`Duplicate question id: ${r.id}`);if(t.seenQuestions.add(r.id),r.type&&["matrix-multi","mc-multi"].includes(r.type)&&t.seenMultiQuestions.add(r.id),r.statements||r.dynamic_statements){const u=new Set;if(t.seenQuestionStatements.set(r.id,u),(p=r.statements)==null||p.forEach(h=>{if(u.has(h.id))throw new j(`Duplicate statement id: ${r.id}.${h.id}`);u.add(h.id)}),r.dynamic_statements){const h=L(r.dynamic_statements);zt(h,t).forEach(m=>{if(typeof m=="number")throw new $(`Dynamic statement in question ${r.id} refers to choices with values`);if(u.has(m))throw new j(`Duplicate statement ${m} via dynamic statements in question ${r.id}`);u.add(m)})}}const w=(y=r.choices)!=null?y:[];if(r.choice_groups){if(new Set(r.choice_groups.map(u=>u.id)).size!==r.choice_groups.length)throw new j(`Choice groups must have a unique id in question ${r.id}`);r.choice_groups.forEach(u=>w.push(...u.choices))}if(w||r.dynamic_choices){const u=new Set;t.seenQuestionChoices.set(r.id,u);const h=new Set;if(t.seenTextChoices.set(r.id,h),w.forEach(m=>{var b;const q=(b=m.id)!=null?b:m.value;if(u.has(q))throw new j(`Duplicate choice: ${r.id}[${q}]`);u.add(q),m.text_input&&m.text_input!=="no"&&h.add(q)}),r.dynamic_choices){const m=L(r.dynamic_choices);zt(m,t).forEach(b=>{if(u.has(b))throw new j(`Duplicate choice ${b} via dynamic choices in ${r.id}`);u.add(b)}),(v=t.seenTextChoices.get(m.questionId))==null||v.forEach(b=>h.add(b))}if(new Set([...u].map(m=>typeof m)).size>=2)throw new Ir("All choices in a question must either all have id's or all have values")}}},Ar=r=>{if(!$t(r))throw new Error(`Invalid template: ${r.template.id}. Reason: ${JSON.stringify($t.errors,null,4)}`);St(r);const t=new qr;r.sections.forEach(n=>{G(t,n.id,n.display_logic),n.pages.forEach(i=>{var s;(s=i.questions)==null||s.forEach(a=>{Sr(a,t)})})})};function $r(r,t){const n=structuredClone(r);return{...n,sections:n.sections.map(i=>({id:i.id,name:i.name,hideProgressBar:i.hideProgressBar,pages:t.evaluateDisplayLogic(i.displayLogic)?i.pages.map(s=>({...s,questions:zr(s.questions,t)})).filter(s=>s.questions.length):[]})).filter(i=>i.pages.length)}}function zr(r,t){return r.filter(n=>t.evaluateDisplayLogic(n.displayLogic)).map(n=>({...n,text:t.getQuestionText(n),statements:t.getQuestionStatements(n),choices:t.getQuestionChoices(n),statementGroups:t.getQuestionStatementGroups(n),choiceGroups:t.getQuestionChoiceGroups(n),randomization:void 0}))}const Dr=Ze,Pr="pulse_default_alpha",Lr={allPermissions:jt,SURVEY_RESOURCE_TYPE:Mt,surveyAdministerPermission:Fe};export{Pr as DEFAULT_TEMPLATE_ID,T as LOCATOR_EXPRESSION,De as QUESTION_TEXT_LOCATOR_PATTERN,br as TemplateContextEvaluator,Le as evaluateExpression,$r as evaluateTemplateNode,Nt as extractQuestionNodes,bt as getQualifiedQuestionId,Et as getQuestionTypeEnum,vt as getRandomizationTypeEnum,$e as getRawQuestionId,mr as getTemplateNode,Ce as interpolateMacros,St as interpolateTemplate,L as parseLocator,Lr as permissions,Ut as polyfillStructuredClone,Dr as templateSchema,ce as transformCase,Tt as validateLocator,Ar as validateTemplate};
19
+ `),this.last_token=i}eq(t){return t instanceof Me?this.text===t.text&&this.line_ctr===t.line_ctr&&this.last_token===t.last_token:G}}class ot{constructor(t,n){this.lexer=t,this.state=n}static from_text(t,n){return new this(t,new Me(n))}lex(t){return this.lexer.lex(this.state,t)}}class oe extends Je{lex(t,n){return G}}function Pn(r,t){r.sort((n,i)=>{let s=t(n),a=t(i);for(let o=0;o<s.length;o++){if(s[o]>a[o])return 1;if(s[o]<a[o])return-1}return 0})}class le extends oe{constructor(t){super();let n=[...t.terminals];if(this.re=t.re_module,!t.skip_validation){for(const i of n){try{this.re.compile(i.pattern.to_regexp(),t.g_regex_flags)}catch(s){throw s instanceof this.re.error?new V(d("Cannot compile token %s: %s",i.name,i.pattern)):s}if(i.pattern.min_width===0)throw new V(d("Lexer does not allow zero-width terminals. (%s: %s)",i.name,i.pattern))}if(!(new Set(t.ignore)<=new Set(n.map(i=>i.name))))throw new V(d("Ignore terminals are not defined: %s",et(new Set(t.ignore),new Set(n.map(i=>i.name)))))}this.newline_types=te(n.filter(i=>Dn(i.pattern.to_regexp())).map(i=>i.name)),this.ignore_types=te(t.ignore),Pn(n,i=>[-i.priority,-i.pattern.max_width,-i.pattern.value.length,i.name]),this.terminals=n,this.user_callbacks=t.callbacks,this.g_regex_flags=t.g_regex_flags,this.use_bytes=t.use_bytes,this.terminals_by_name=t.terminals_by_name,this._scanner=null}_build_scanner(){let t;[t,this.callback]=zn(this.terminals,this.g_regex_flags,this.re,this.use_bytes);for(const[n,i]of x(this.user_callbacks))n in this.callback?this.callback[n]=new $n(this.callback[n],i,s=>s.type===n):this.callback[n]=i;this._scanner=new Xe(t,this.g_regex_flags,this.re,this.use_bytes)}get scanner(){return this._scanner===null&&this._build_scanner(),this._scanner}match(t,n){return this.scanner.match(t,n)}*lex(t,n){try{for(;;)yield this.next_token(t,n)}catch(i){if(!(i instanceof ge))throw i}}next_token(t,n=null){let i,s,a,o,l=t.line_ctr;for(;l.char_pos<t.text.length;){if(s=this.match(t.text,l.char_pos),!s)throw i=et(this.scanner.allowed_types,this.ignore_types),i||(i=new Set(["<END-OF-FILE>"])),new M({seq:t.text,lex_pos:l.char_pos,line:l.line,column:l.column,allowed:i,token_history:t.last_token&&[t.last_token],state:n,terminals_by_name:this.terminals_by_name});let[c,_]=s;if(this.ignore_types.has(_))_ in this.callback&&(o=new f(_,c,l.char_pos,l.line,l.column),this.callback[_](o)),l.feed(c,this.newline_types.has(_));else{if(a=new f(_,c,l.char_pos,l.line,l.column),l.feed(c,this.newline_types.has(_)),a.end_line=l.line,a.end_column=l.column,a.end_pos=l.char_pos,a.type in this.callback&&(a=this.callback[a.type](a),!(a instanceof f)))throw new V(d("Callbacks must return a token (returned %r)",a));return t.last_token=a,a}}throw new ge(this)}}class Ln extends oe{constructor({conf:t,states:n,always_accept:i=[]}={}){super();let s,a,o,l=[...t.terminals],c=t.terminals_by_name,_=I(t);_.terminals=l;let p=new Map;this.lexers={};for(let[y,v]of x(n))s=te(v),p.has(s)?a=p.get(s):(v=dn(new Set(v),[...new Set(t.ignore),...new Set(i)]),o=I(_),o.terminals=[...v].filter(w=>w in c).map(w=>c[w]),a=new le(o),p.set(s,a)),this.lexers[y]=a;this.root_lexer=new le(_)}*lex(t,n){let i,s,a;try{for(;;)s=this.lexers[n.position],yield s.next_token(t,n)}catch(o){if(!(o instanceof ge))if(o instanceof M)try{throw i=t.last_token,a=this.root_lexer.next_token(t,n),new j({token:a,expected:o.allowed,state:n,token_history:[i],terminals_by_name:this.root_lexer.terminals_by_name})}catch(l){throw l}else throw o}}}class lt extends N{static get __serialize_fields__(){return["terminals","ignore","g_regex_flags","use_bytes","lexer_type"]}static get __serialize_namespace__(){return[ae]}constructor({terminals:t,re_module:n,ignore:i=[],postlex:s=null,callbacks:a=null,g_regex_flags:o="",skip_validation:l=!1,use_bytes:c=!1}={}){super(),this.terminals=t,this.terminals_by_name=Object.fromEntries(this.terminals.map(_=>[_.name,_])),this.ignore=i,this.postlex=s,this.callbacks=Object.keys(a).length||{},this.g_regex_flags=o,this.re_module=n,this.skip_validation=l,this.use_bytes=c,this.lexer_type=null}_deserialize(){this.terminals_by_name=Object.fromEntries(this.terminals.map(t=>[t.name,t]))}}class _t extends N{static get __serialize_fields__(){return["rules","start","parser_type"]}constructor(t,n,i){super(),this.rules=t,this.callbacks=n,this.start=i,this.parser_type=null}}class Cn{constructor(t){this.node_builder=t}__call__(t){return t.length===1?t[0]:this.node_builder(t)}}const Qn=P(Cn);class Mn{constructor(t,n=null){this.node_builder=t,this.node_filter=n}__call__(t){let n,i,s,a=this.node_builder(t);return a instanceof g&&(s=a.meta,n=this._pp_get_meta(t),n!==null&&("line"in s||(s.line=n&&n.container_line||n.line,s.column=n&&n.container_column||n.column,s.start_pos=n&&n.container_start_pos||n.start_pos,s.empty=!1),s.container_line=n&&n.container_line||n.line,s.container_column=n&&n.container_column||n.column),i=this._pp_get_meta([...t].reverse()),i!==null&&("end_line"in s||(s.end_line=i&&i.container_end_line||i.end_line,s.end_column=i&&i.container_end_column||i.end_column,s.end_pos=i&&i.container_end_pos||i.end_pos,s.empty=!1),s.container_end_line=i&&i.container_end_line||i.end_line,s.container_end_column=i&&i.container_end_column||i.end_column)),a}_pp_get_meta(t){for(const n of t)if(!(this.node_filter!==null&&!this.node_filter(n))){if(n instanceof g){if(!n.meta.empty)return n.meta}else if(n instanceof f)return n}}}const ct=P(Mn);function jn(r){if(fn(r))return ne({unknown_param_0:ct,node_filter:r});if(r===!0)return ct;if(r===!1)return null;throw new S(d("Invalid option for propagate_positions: %r",r))}class Oe{constructor(t,n,i){this.node_builder=i,this.to_include=t,this.append_none=n}__call__(t){let n=[];for(const[i,s,a]of this.to_include)a&&n.push(...O([null],a)),s?n.push(...t[i].children):n.push(t[i]);return this.append_none&&n.push(...O([null],this.append_none)),this.node_builder(n)}}const Un=P(Oe);class Fn extends Oe{__call__(t){let n=[];for(const[i,s,a]of this.to_include)a&&n.push(...O([null],a)),s?n.length?n.push(...t[i].children):n=t[i].children:n.push(t[i]);return this.append_none&&n.push(...O([null],this.append_none)),this.node_builder(n)}}const Zn=P(Fn);class Bn extends Oe{constructor(t,n){super(),this.node_builder=n,this.to_include=t}__call__(t){let n=[];for(const[i,s]of this.to_include)s?n.length?n.push(...t[i].children):n=t[i].children:n.push(t[i]);return this.node_builder(n)}}const Gn=P(Bn);function Wn(r){return!r.is_term&&r.name.startsWith("_")}function Vn(r,t,n,i){let s,a;i.length?(a=i.map(c=>(0+c).toString()).join(""),s=a.split("0").map(c=>c.length)):s=O([0],r.length+1);let o=[],l=0;for(const[c,_]of W(r))l+=s[c],(t||!(_.is_term&&_.filter_out))&&(o.push([c,Wn(_),l]),l=0);if(l+=s[r.length],i.length||o.length<r.length||yn(o.map(([c,_,p])=>_)))return(i.length||n).length?ne(n?Un:Zn,o,l):ne(Gn,o.map(([c,_,p])=>[c,_]))}function Xn(r){function t(n){let i=new g(r.name,n);return r(i)}return t=wraps(r)(t),t}function Hn(r,t,n){if(n===_vargs_meta||n===_vargs_meta_inline)throw new NotImplementedError("Meta args not supported for internal transformer");function i(s){return n(r,t,s,null)}return i=wraps(r)(i),i}class Jn{constructor(t,n,i=!1,s=!1,a=!1){this.tree_class=n,this.propagate_positions=i,this.ambiguous=s,this.maybe_placeholders=a,this.rule_builders=[...this._init_builders(t)]}*_init_builders(t){let n,i,s,a,o=jn(this.propagate_positions);for(const l of t)s=l.options,i=s.keep_all_tokens,n=s.expand1,a=[...rt(null,[n&&!l.alias&&Qn,Vn(l.expansion,i,this.ambiguous,this.maybe_placeholders?s.empty_indices:[]),o])],yield[l,a]}create_callback(t=null){let n,i,s,a=new Map;for(const[o,l]of this.rule_builders){i=o.alias||o.options.template_source||o.origin.name,t&&t[i]?(n=t&&t[i],s=n&&n.visit_wrapper||null,s!==null?n=Hn(n,i,s):t instanceof at&&(n=Xn(n))):n=ne(this.tree_class,i);for(const c of l)n=c(n);if(a.has(o))throw new re(d("Rule '%s' already exists",o));a.set(o,n)}return a}}class pt extends N{constructor({parser_conf:t,debug:n=!1}={}){super();let i=new LALR_Analyzer({unknown_param_0:t,debug:n});i.compute_lalr();let s=t.callbacks;this._parse_table=i.parse_table,this.parser_conf=t,this.parser=new ut(i.parse_table,s,n)}static deserialize(t,n,i,s=!1){let a=fe(this);return a._parse_table=er.deserialize(t,n),a.parser=new ut(a._parse_table,i,s),a}serialize(t){return this._parse_table.serialize(t)}parse_interactive(t,n){return this.parser.parse({lexer:t,start:n,start_interactive:!0})}parse({lexer:t,start:n,on_error:i=null}={}){let s,a;try{return this.parser.parse({lexer:t,start:n})}catch(o){if(o instanceof z){if(i===null)throw o;for(;;){if(o instanceof M&&(a=o.interactive_parser.lexer_thread.state,s=a.line_ctr.char_pos),!i(o))throw o;o instanceof M&&s===a.line_ctr.char_pos&&a.line_ctr.feed(a.text.slice(s,s+1));try{return o.interactive_parser.resume_parse()}catch(l){if(l instanceof j){if(o instanceof j&&o.token.type===l.token.type&&l.token.type==="$END"&&o.interactive_parser.eq(l.interactive_parser))throw l;o=l}else if(l instanceof M)o=l;else throw l}}}else throw o}}}class Yn{constructor(t,n,i){this.parse_table=t,this.start_state=this.parse_table.start_states[i],this.end_state=this.parse_table.end_states[i],this.states=this.parse_table.states,this.callbacks=n,this.start=i}}class je{constructor(t,n,i=null,s=null){this.parse_conf=t,this.lexer=n,this.state_stack=i||[this.parse_conf.start_state],this.value_stack=s||[]}get position(){return E(this.state_stack)}eq(t){return t instanceof je?this.state_stack.length===t.state_stack.length&&this.position===t.position:G}copy(){return I(this)}feed_token(t,n=!1){let i,s,a,o,l,c,_,p,y,v,w=this.state_stack,u=this.value_stack,h=this.parse_conf.states,m=this.parse_conf.end_state,b=this.parse_conf.callbacks;for(;;){if(y=E(w),t.type in h[y])[s,a]=h[y][t.type];else throw o=new Set(me(h[y]).filter(q=>it(q)).map(q=>q)),new j({token:t,expected:o,state:this,interactive_parser:null});if(s===Ae){w.push(a),u.push(t.type in b?b[t.type](t):t);return}else if(c=a,p=c.expansion.length,p?(_=u.slice(-p),w.splice(-p),u.splice(-p)):_=[],v=b.get(c)(_),[i,l]=h[E(w)][c.origin.name],w.push(l),u.push(v),n&&E(w)===m)return E(u)}}}class ut{constructor(t,n,i=!1){this.parse_table=t,this.callbacks=n,this.debug=i}parse({lexer:t,start:n,value_stack:i=null,state_stack:s=null,start_interactive:a=!1}={}){let o=new Yn(this.parse_table,this.callbacks,n),l=new je(o,t,s,i);return a?new D(this,l,l.lexer):this.parse_from_state(l)}parse_from_state(t){let n,i;try{i=null;for(i of t.lexer.lex(t))t.feed_token(i);return n=i?f.new_borrow_pos("$END","",i):new f("$END","",0,1,1),t.feed_token(n,!0)}catch(s){if(s instanceof z){try{s.interactive_parser=new D(this,t,t.lexer)}catch(a){if(!(a instanceof ReferenceError))throw a}throw s}else if(s instanceof Error){if(this.debug){console.log(""),console.log("STATE STACK DUMP"),console.log("----------------");for(const[a,o]of W(t.state_stack))console.log(d("%d)",a),o);console.log("")}throw s}else throw s}}}class D{constructor(t,n,i){this.parser=t,this.parser_state=n,this.lexer_thread=i,this.result=null}feed_token(t){return this.parser_state.feed_token(t,t.type==="$END")}*iter_parse(){for(const t of this.lexer_thread.lex(this.parser_state))yield t,this.result=this.feed_token(t)}exhaust_lexer(){return[...this.iter_parse()]}feed_eof(t=null){let n=t!==null?f.new_borrow_pos("$END","",t):new f("$END","",0,1,1);return this.feed_token(n)}copy(){return I(this)}eq(t){return t instanceof D?this.parser_state===t.parser_state&&this.lexer_thread===t.lexer_thread:!1}as_immutable(){let t=I(this);return new ht(t.parser,t.parser_state,t.lexer_thread)}pretty(){let t=["Parser choices:"];for(const[n,i]of x(this.choices()))t.push(d(" - %s -> %r",n,i));return t.push(d("stack size: %s",this.parser_state.state_stack.length)),t.join(`
20
+ `)}choices(){return this.parser_state.parse_conf.parse_table.states[this.parser_state.position]}accepts(){let t,n=new Set;for(const i of this.choices())if(it(i)){t=I(this);let s=null;try{t.feed_token(new f(i,""))}catch(a){if(s=a,!(a instanceof j))throw a}s||n.add(i)}return n}resume_parse(){return this.parser.parse_from_state(this.parser_state)}}class ht extends D{constructor(){super(...arguments),R(this,"result",null)}feed_token(t){let n=I(this);return n.result=D.feed_token(n,t),n}exhaust_lexer(){let t=this.as_mutable();return t.exhaust_lexer(),t.as_immutable()}as_mutable(){let t=I(this);return new D(t.parser,t.parser_state,t.lexer_thread)}}class dt{constructor(t){this.name=t}repr(){return this.toString()}}var Ae=new dt("Shift"),mt=new dt("Reduce");class Kn{constructor(t,n,i){this.states=t,this.start_states=n,this.end_states=i}serialize(t){let n=new Enumerator,i=Object.fromEntries(x(this.states).map(([s,a])=>[s,Object.fromEntries(x(a).map(([o,[l,c]])=>[Ye(n,o),l===mt?[1,c.serialize(t)]:[0,c]]))]));return{tokens:n.reversed(),states:i,start_states:this.start_states,end_states:this.end_states}}static deserialize(t,n){const i=this;let s=t.tokens,a=Object.fromEntries(x(t.states).map(([o,l])=>[o,Object.fromEntries(x(l).map(([c,[_,p]])=>[s[c],_===1?[mt,B.deserialize(p,n)]:[Ae,p]]))]));return new i(a,t.start_states,t.end_states)}}class er extends Kn{static from_ParseTable(t){const n=this;let i=[...t.states],s=Object.fromEntries(W(i).map(([c,_])=>[_,c])),a={};for(let[c,_]of x(t.states))_=Object.fromEntries(x(_).map(([p,y])=>[p,y[0]===Ae?[y[0],s[y[1]]]:y])),a[s[c]]=_;let o=Object.fromEntries(x(t.start_states).map(([c,_])=>[c,s[_]])),l=Object.fromEntries(x(t.end_states).map(([c,_])=>[c,s[_]]));return new n(a,o,l)}}function tr(r){if(r&&r.__future_interface__)return r;{class t extends oe{constructor(i){super(),this.lexer=r(i)}lex(i,s){return this.lexer.lex(i.text)}}return t}}function nr(r,t,n,i,s){let a=_t.deserialize(r.parser_conf,t),o=pt.deserialize(r.parser,t,i,s.debug);return a.callbacks=i,new rr({lexer_conf:n,parser_conf:a,options:s,parser:o})}var ft={};class rr extends N{static get __serialize_fields__(){return["lexer_conf","parser_conf","parser"]}constructor({lexer_conf:t,parser_conf:n,options:i,parser:s=null}={}){super();let a,o;this.parser_conf=n,this.lexer_conf=t,this.options=i,s?this.parser=s:(o=Ye(ft,n.parser_type),this.parser=o(t,n,i));let l=t.lexer_type;if(this.skip_lexer=!1,["dynamic","dynamic_complete"].includes(l)){this.skip_lexer=!0;return}const c={basic:or,contextual:lr};l in c?(a=c[l],this.lexer=a(t,this.parser,t.postlex,i)):this.lexer=tr(l)(t),t.postlex&&(this.lexer=new ar(this.lexer,t.postlex))}_verify_start(t=null){let n;if(t===null){if(n=this.parser_conf.start,n.length>1)throw new S("Lark initialized with more than 1 possible start rule. Must specify which start rule to parse",n);[t]=n}else if(!this.parser_conf.start.includes(t))throw new S(d("Unknown start rule %s. Must be one of %r",t,this.parser_conf.start));return t}_make_lexer_thread(t){return this.skip_lexer?t:ot.from_text(this.lexer,t)}parse(t,n=null,i=null){let s=this._verify_start(n),a=i===null?{}:{on_error:i},o=this._make_lexer_thread(t);return this.parser.parse({lexer:o,start:s,...a})}parse_interactive(t=null,n=null){let i=this._verify_start(n);if(this.parser_conf.parser_type!=="lalr")throw new S("parse_interactive() currently only works with parser='lalr' ");let s=this._make_lexer_thread(t);return this.parser.parse_interactive(s,i)}}function ir(r,t){let n;Te(r,["lalr","earley","cyk"]),typeof t!="object"&&(n={lalr:["basic","contextual"],earley:["basic","dynamic","dynamic_complete"],cyk:["basic"]}[r],Te(t,n,d("Parser %r does not support lexer %%r, expected one of %%s",r)))}function sr(r,t){let n,i={};for(const s of t)n=r&&r[s.name]||null,n!==null&&(i[s.name]=n);return i}class ar{constructor(t,n){this.lexer=t,this.postlexer=n}lex(t,n){let i=this.lexer.lex(t,n);return this.postlexer.process(i)}}function or(r,t,n,i){return new le(r)}function lr(r,t,n,i){let s=Object.fromEntries(x(t._parse_table.states).map(([o,l])=>[o,[...me(l)]])),a=n?n.always_accept:[];return new Ln({conf:r,states:s,always_accept:a})}function _r(r,t,n=null){let i=n?n.debug:!1;return new pt({parser_conf:t,debug:i})}ft.lalr=_r;class yt extends Je{constructor(){super(...arguments),R(this,"always_accept",[])}process(t){return t}}class cr extends N{constructor(t){super(),R(this,"OPTIONS_DOC",'\n **=== General Options ===**\n\n start\n The start symbol. Either a string, or a list of strings for multiple possible starts (Default: "start")\n debug\n Display debug information and extra warnings. Use only when debugging (Default: ``False``)\n When used with Earley, it generates a forest graph as "sppf.png", if \'dot\' is installed.\n transformer\n Applies the transformer to every parse tree (equivalent to applying it after the parse, but faster)\n propagate_positions\n Propagates (line, column, end_line, end_column) attributes into all tree branches.\n Accepts ``False``, ``True``, or a callable, which will filter which nodes to ignore when propagating.\n maybe_placeholders\n When ``True``, the ``[]`` operator returns ``None`` when not matched.\n When ``False``, ``[]`` behaves like the ``?`` operator, and returns no value at all.\n (default= ``True``)\n cache\n Cache the results of the Lark grammar analysis, for x2 to x3 faster loading. LALR only for now.\n\n - When ``False``, does nothing (default)\n - When ``True``, caches to a temporary file in the local directory\n - When given a string, caches to the path pointed by the string\n regex\n When True, uses the ``regex`` module instead of the stdlib ``re``.\n g_regex_flags\n Flags that are applied to all terminals (both regex and strings)\n keep_all_tokens\n Prevent the tree builder from automagically removing "punctuation" tokens (Default: ``False``)\n tree_class\n Lark will produce trees comprised of instances of this class instead of the default ``lark.Tree``.\n\n **=== Algorithm Options ===**\n\n parser\n Decides which parser engine to use. Accepts "earley" or "lalr". (Default: "earley").\n (there is also a "cyk" option for legacy)\n lexer\n Decides whether or not to use a lexer stage\n\n - "auto" (default): Choose for me based on the parser\n - "basic": Use a basic lexer\n - "contextual": Stronger lexer (only works with parser="lalr")\n - "dynamic": Flexible and powerful (only with parser="earley")\n - "dynamic_complete": Same as dynamic, but tries *every* variation of tokenizing possible.\n ambiguity\n Decides how to handle ambiguity in the parse. Only relevant if parser="earley"\n\n - "resolve": The parser will automatically choose the simplest derivation\n (it chooses consistently: greedy for tokens, non-greedy for rules)\n - "explicit": The parser will return all derivations wrapped in "_ambig" tree nodes (i.e. a forest).\n - "forest": The parser will return the root of the shared packed parse forest.\n\n **=== Misc. / Domain Specific Options ===**\n\n postlex\n Lexer post-processing (Default: ``None``) Only works with the basic and contextual lexers.\n priority\n How priorities should be evaluated - "auto", ``None``, "normal", "invert" (Default: "auto")\n lexer_callbacks\n Dictionary of callbacks for the lexer. May alter tokens during lexing. Use with caution.\n use_bytes\n Accept an input of type ``bytes`` instead of ``str``.\n edit_terminals\n A callback for editing the terminals before parse.\n import_paths\n A List of either paths or loader functions to specify from where grammars are imported\n source_path\n Override the source of from where the grammar was loaded. Useful for relative imports and unconventional grammar loading\n **=== End of Options ===**\n '),R(this,"_defaults",{debug:!1,keep_all_tokens:!1,tree_class:null,cache:!1,postlex:null,parser:"earley",lexer:"auto",transformer:null,start:"start",priority:"auto",ambiguity:"auto",regex:!1,propagate_positions:!1,lexer_callbacks:{},maybe_placeholders:!0,edit_terminals:null,g_regex_flags:"",use_bytes:!1,import_paths:[],source_path:null,_plugins:null});let n,i=tt(t),s=this;for(const[a,o]of x(this._defaults))a in i?(n=un(i,a),typeof o=="boolean"&&!["cache","use_bytes","propagate_positions"].includes(a)&&(n=nt(n))):n=o,s[a]=n;if(typeof s.start=="string"&&(s.start=[s.start]),this.options=s,Te(this.parser,["earley","lalr","cyk",null]),this.parser==="earley"&&this.transformer)throw new S("Cannot specify an embedded transformer when using the Earley algorithm. Please use your transformer on the resulting parse tree, or use a different algorithm (i.e. LALR)");if(Object.keys(i).length)throw new S(d("Unknown options: %s",me(i)))}serialize(t){return this.options}static deserialize(t,n){const i=this;return new i(t)}}class gt extends N{static get __serialize_fields__(){return["parser","rules","options"]}_build_lexer(t=!1){let n=this.lexer_conf;return t&&(n=I(n),n.ignore=[]),new le(n)}_prepare_callbacks(){this._callbacks=new Map,this.options.ambiguity!=="forest"&&(this._parse_tree_builder=new Jn(this.rules,this.options.tree_class||hn(g),this.options.propagate_positions,this.options.parser!=="lalr"&&this.options.ambiguity==="explicit",this.options.maybe_placeholders),this._callbacks=this._parse_tree_builder.create_callback(this.options.transformer)),Ke(this._callbacks,sr(this.options.transformer,this.terminals))}_deserialize_lexer_conf(t,n,i){let s=lt.deserialize(t.lexer_conf,n);return s.callbacks=i.lexer_callbacks||{},s.re_module=i.regex?regex:Ve,s.use_bytes=i.use_bytes,s.g_regex_flags=i.g_regex_flags||"",s.skip_validation=!0,s.postlex=i.postlex,s}_load({f:t,...n}={}){let i;ye(t)?i=t:i=pickle.load(t);let s=i.memo,a=i.data,o=bn.deserialize(s,{Rule:B,TerminalDef:ae},{}),l=tt(a.options);return Ke(l,n),this.options=cr.deserialize(l,o),this.rules=a.rules.map(c=>B.deserialize(c,o)),this.source_path="<deserialized>",ir(this.options.parser,this.options.lexer),this.lexer_conf=this._deserialize_lexer_conf(a.parser,o,this.options),this.terminals=this.lexer_conf.terminals,this._prepare_callbacks(),this._terminals_dict=Object.fromEntries(this.terminals.map(c=>[c.name,c])),this.parser=nr(a.parser,o,this.lexer_conf,this._callbacks,this.options),this}static _load_from_dict({data:t,memo:n,...i}={}){return fe(this)._load({f:{data:t,memo:n},...i})}repr(){return d("Lark(open(%r), parser=%r, lexer=%r, ...)",this.source_path,this.options.parser,this.options.lexer)}lex(t,n=!1){let i;!("lexer"in this)||n?i=this._build_lexer(n):i=this.lexer;let s=ot.from_text(i,t).lex(null);return this.options.postlex?this.options.postlex.process(s):s}get_terminal(t){return this._terminals_dict[t]}parse_interactive(t=null,n=null){return this.parser.parse_interactive({unknown_param_0:t,start:n})}parse(t,n=null,i=null){return this.parser.parse(t,n,i)}}class xt extends A{}class wt extends yt{constructor(){super(),this.paren_level=0,this.indent_level=[0]}*handle_NL(t){if(this.paren_level>0)return;yield t;let n=xe(t.value,`
21
+ `,1)[1],i=we(n," ")+we(n," ")*this.tab_len;if(i>E(this.indent_level))this.indent_level.push(i),yield f.new_borrow_pos(this.INDENT_type,n,t);else{for(;i<E(this.indent_level);)this.indent_level.pop(),yield f.new_borrow_pos(this.DEDENT_type,n,t);if(i!==E(this.indent_level))throw new xt(d("Unexpected dedent to column %s. Expected dedent to %s",i,E(this.indent_level)))}}*_process(t){for(const n of t)n.type===this.NL_type?yield*this.handle_NL(n):yield n,this.OPEN_PAREN_types.includes(n.type)?this.paren_level+=1:this.CLOSE_PAREN_types.includes(n.type)&&(this.paren_level-=1);for(;this.indent_level.length>1;)this.indent_level.pop(),yield new f(this.DEDENT_type,"")}process(t){return this.paren_level=0,this.indent_level=[0],this._process(t)}get always_accept(){return[this.NL_type]}get NL_type(){throw new NotImplementedError}get OPEN_PAREN_types(){throw new NotImplementedError}get CLOSE_PAREN_types(){throw new NotImplementedError}get INDENT_type(){throw new NotImplementedError}get DEDENT_type(){throw new NotImplementedError}get tab_len(){throw new NotImplementedError}}class pr extends wt{static get NL_type(){return"_NEWLINE"}get NL_type(){return this.constructor.NL_type}static get OPEN_PAREN_types(){return["LPAR","LSQB","LBRACE"]}get OPEN_PAREN_types(){return this.constructor.OPEN_PAREN_types}static get CLOSE_PAREN_types(){return["RPAR","RSQB","RBRACE"]}get CLOSE_PAREN_types(){return this.constructor.CLOSE_PAREN_types}static get INDENT_type(){return"_INDENT"}get INDENT_type(){return this.constructor.INDENT_type}static get DEDENT_type(){return"_DEDENT"}get DEDENT_type(){return this.constructor.DEDENT_type}static get tab_len(){return 8}get tab_len(){return this.constructor.tab_len}}const ur={Terminal:Ne,NonTerminal:ke,RuleOptions:se,PatternStr:Ie,PatternRE:qe,TerminalDef:ae};var hr={LarkError:A,ConfigurationError:S,GrammarError:re,ParseError:wn,LexError:V,UnexpectedInput:z,UnexpectedEOF:Tn,UnexpectedCharacters:M,UnexpectedToken:j,VisitError:ve,Meta:st,Tree:g,Discard:ee,Transformer:X,Transformer_InPlace:at,Transformer_NonRecursive:En,Transformer_InPlaceRecursive:Nn,VisitorBase:be,Visitor:kn,Visitor_Recursive:Rn,Interpreter:In,Symbol:Ee,Terminal:Ne,NonTerminal:ke,RuleOptions:se,Rule:B,Pattern:Re,PatternStr:Ie,PatternRE:qe,TerminalDef:ae,Token:f,Lexer:oe,LexerConf:lt,ParserConf:_t,InteractiveParser:D,ImmutableInteractiveParser:ht,PostLex:yt,Lark:gt,DedentError:xt,Indenter:wt,PythonIndenter:pr,get_parser:cn},dr={parser:{lexer_conf:{terminals:[{"@":0},{"@":1},{"@":2},{"@":3},{"@":4},{"@":5},{"@":6},{"@":7},{"@":8},{"@":9},{"@":10},{"@":11},{"@":12},{"@":13},{"@":14},{"@":15},{"@":16},{"@":17},{"@":18},{"@":19},{"@":20}],ignore:["WS"],g_regex_flags:0,use_bytes:!1,lexer_type:"contextual",__type__:"LexerConf"},parser_conf:{rules:[{"@":21},{"@":22},{"@":23},{"@":24},{"@":25},{"@":26},{"@":27},{"@":28},{"@":29},{"@":30},{"@":31},{"@":32},{"@":33},{"@":34},{"@":35},{"@":36},{"@":37},{"@":38},{"@":39},{"@":40},{"@":41},{"@":42},{"@":43},{"@":44},{"@":45},{"@":46},{"@":47},{"@":48},{"@":49},{"@":50},{"@":51},{"@":52},{"@":53},{"@":54}],start:["start"],parser_type:"lalr",__type__:"ParserConf"},parser:{tokens:{0:"$END",1:"RPAR",2:"LSQB",3:"DOT",4:"question_selector",5:"IDENTIFIER",6:"OPERATOR",7:"CONJUNCTION",8:"__ANON_3",9:"__ANON_1",10:"qc_mc_text",11:"FALSE",12:"bool_expr",13:"__ANON_0",14:"__ANON_2",15:"__ANON_5",16:"qc_mc_count",17:"qc_matrix_selected",18:"condition",19:"qc_selected_value",20:"bool_const",21:"qc_matrix_count",22:"NEGATION",23:"__ANON_4",24:"TRUE",25:"qc_mc_selected",26:"qc_mc_text_ignore_case",27:"__ANON_6",28:"INT",29:"RSQB",30:"matrix_statement_selector",31:"matrix_choice_selector",32:"mc_choice_selector",33:"STRING",34:"question_or_matrix_statement_selector",35:"top_level_expr",36:"LPAR",37:"start"},states:{0:{0:[1,{"@":22}]},1:{1:[1,{"@":45}],2:[1,{"@":45}],3:[1,{"@":45}]},2:{2:[1,{"@":48}],1:[1,{"@":48}]},3:{1:[0,10]},4:{1:[0,9]},5:{4:[0,8],5:[0,1]},6:{2:[0,50]},7:{},8:{1:[0,57]},9:{6:[0,65]},10:{1:[1,{"@":42}],0:[1,{"@":42}],7:[1,{"@":42}]},11:{8:[0,66],9:[0,35],10:[0,44],11:[0,63],12:[0,49],13:[0,56],14:[0,54],15:[0,34],16:[0,75],17:[0,68],18:[0,78],19:[0,69],20:[0,36],21:[0,71],22:[0,80],23:[0,5],24:[0,43],25:[0,39],26:[0,51]},12:{0:[1,{"@":24}]},13:{6:[0,70]},14:{2:[0,77],3:[0,28]},15:{3:[0,28],1:[1,{"@":51}]},16:{1:[1,{"@":41}],0:[1,{"@":41}],7:[1,{"@":41}]},17:{27:[0,73]},18:{1:[1,{"@":52}]},19:{8:[0,66],9:[0,35],10:[0,44],11:[0,63],25:[0,39],12:[0,27],13:[0,56],14:[0,54],15:[0,34],16:[0,75],17:[0,68],18:[0,78],19:[0,69],21:[0,71],22:[0,80],23:[0,5],24:[0,43],26:[0,51],20:[0,36]},20:{27:[0,13]},21:{6:[0,47]},22:{6:[0,23]},23:{28:[0,60]},24:{1:[0,16]},25:{2:[0,77]},26:{0:[1,{"@":21}]},27:{1:[0,29]},28:{5:[0,2]},29:{7:[0,81],0:[1,{"@":23}]},30:{1:[0,22]},31:{1:[0,21]},32:{29:[0,64]},33:{1:[0,52]},34:{5:[0,1],4:[0,76]},35:{30:[0,6],5:[0,1],4:[0,14],31:[0,3],32:[0,41]},36:{1:[1,{"@":27}],0:[1,{"@":27}],7:[1,{"@":27}]},37:{29:[0,53]},38:{1:[1,{"@":40}],0:[1,{"@":40}],7:[1,{"@":40}]},39:{1:[1,{"@":29}],0:[1,{"@":29}],7:[1,{"@":29}]},40:{1:[1,{"@":43}],0:[1,{"@":43}],7:[1,{"@":43}]},41:{1:[0,61]},42:{28:[0,40]},43:{1:[1,{"@":53}],0:[1,{"@":53}],7:[1,{"@":53}]},44:{1:[1,{"@":30}],0:[1,{"@":30}],7:[1,{"@":30}]},45:{1:[1,{"@":50}]},46:{1:[1,{"@":39}],0:[1,{"@":39}],7:[1,{"@":39}]},47:{33:[0,48]},48:{1:[1,{"@":38}],0:[1,{"@":38}],7:[1,{"@":38}]},49:{0:[1,{"@":26}],1:[1,{"@":26}]},50:{5:[0,55],28:[0,62]},51:{1:[1,{"@":31}],0:[1,{"@":31}],7:[1,{"@":31}]},52:{1:[1,{"@":36}],0:[1,{"@":36}],7:[1,{"@":36}]},53:{1:[1,{"@":47}]},54:{4:[0,25],32:[0,31],5:[0,1]},55:{29:[0,45]},56:{4:[0,15],5:[0,1],30:[0,18],34:[0,30]},57:{6:[0,58]},58:{28:[0,38]},59:{28:[0,17],5:[0,20]},60:{1:[1,{"@":35}],0:[1,{"@":35}],7:[1,{"@":35}]},61:{1:[1,{"@":37}],0:[1,{"@":37}],7:[1,{"@":37}]},62:{29:[0,79]},63:{1:[1,{"@":54}],0:[1,{"@":54}],7:[1,{"@":54}]},64:{1:[1,{"@":46}]},65:{33:[0,46]},66:{4:[0,25],32:[0,4],5:[0,1]},67:{30:[0,6],5:[0,1],4:[0,14],32:[0,33],31:[0,24]},68:{1:[1,{"@":33}],0:[1,{"@":33}],7:[1,{"@":33}]},69:{1:[1,{"@":28}],0:[1,{"@":28}],7:[1,{"@":28}]},70:{28:[0,74]},71:{1:[1,{"@":34}],0:[1,{"@":34}],7:[1,{"@":34}]},72:{8:[0,66],35:[0,26],9:[0,35],10:[0,44],11:[0,63],36:[0,19],25:[0,39],13:[0,56],14:[0,54],15:[0,34],16:[0,75],17:[0,68],18:[0,78],19:[0,69],37:[0,7],12:[0,0],21:[0,71],22:[0,80],23:[0,5],24:[0,43],26:[0,51],20:[0,36]},73:{6:[0,42]},74:{1:[1,{"@":44}],0:[1,{"@":44}],7:[1,{"@":44}]},75:{1:[1,{"@":32}],0:[1,{"@":32}],7:[1,{"@":32}]},76:{2:[0,59]},77:{28:[0,32],5:[0,37]},78:{7:[0,11],0:[1,{"@":25}],1:[1,{"@":25}]},79:{1:[1,{"@":49}]},80:{9:[0,67]},81:{35:[0,12],36:[0,19]}},start_states:{start:72},end_states:{start:7}},__type__:"ParsingFrontend"},rules:[{"@":21},{"@":22},{"@":23},{"@":24},{"@":25},{"@":26},{"@":27},{"@":28},{"@":29},{"@":30},{"@":31},{"@":32},{"@":33},{"@":34},{"@":35},{"@":36},{"@":37},{"@":38},{"@":39},{"@":40},{"@":41},{"@":42},{"@":43},{"@":44},{"@":45},{"@":46},{"@":47},{"@":48},{"@":49},{"@":50},{"@":51},{"@":52},{"@":53},{"@":54}],options:{debug:!1,keep_all_tokens:!1,tree_class:null,cache:!1,postlex:null,parser:"lalr",lexer:"contextual",transformer:null,start:["start"],priority:"normal",ambiguity:"auto",regex:!1,propagate_positions:!1,lexer_callbacks:{},maybe_placeholders:!1,edit_terminals:null,g_regex_flags:0,use_bytes:!1,import_paths:[],source_path:null,_plugins:{}},__type__:"Lark"},mr={0:{name:"WS",pattern:{value:`(?:[ \f\r
22
+ ])+`,flags:[],_width:[1,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},1:{name:"IDENTIFIER",pattern:{value:"[a-zA-Z][a-zA-Z0-9_]*[a-zA-Z0-9]",flags:[],_width:[2,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},2:{name:"INT",pattern:{value:"-?[0-9]+",flags:[],_width:[1,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},3:{name:"STRING",pattern:{value:`(?:'[^\\']*'|"[^"]*")`,flags:[],_width:[2,4294967295],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},4:{name:"OPERATOR",pattern:{value:"(?:regex_matches|not_contains|contains|==|!=|<=|>=|<|>)",flags:[],_width:[1,13],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},5:{name:"CONJUNCTION",pattern:{value:"(?:and|or)",flags:[],_width:[2,3],__type__:"PatternRE"},priority:0,__type__:"TerminalDef"},6:{name:"NEGATION",pattern:{value:"!",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},7:{name:"TRUE",pattern:{value:"true",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},8:{name:"FALSE",pattern:{value:"false",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},9:{name:"LPAR",pattern:{value:"(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},10:{name:"RPAR",pattern:{value:")",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},11:{name:"__ANON_0",pattern:{value:"selected_value(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},12:{name:"__ANON_1",pattern:{value:"selected(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},13:{name:"__ANON_2",pattern:{value:"text(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},14:{name:"__ANON_3",pattern:{value:"text_ignore_case(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},15:{name:"__ANON_4",pattern:{value:"count_selected(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},16:{name:"__ANON_5",pattern:{value:"count_choice_selections(",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},17:{name:"LSQB",pattern:{value:"[",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},18:{name:"__ANON_6",pattern:{value:"])",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},19:{name:"RSQB",pattern:{value:"]",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},20:{name:"DOT",pattern:{value:".",flags:[],__type__:"PatternStr"},priority:0,__type__:"TerminalDef"},21:{origin:{name:"start",__type__:"NonTerminal"},expansion:[{name:"top_level_expr",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},22:{origin:{name:"start",__type__:"NonTerminal"},expansion:[{name:"bool_expr",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},23:{origin:{name:"top_level_expr",__type__:"NonTerminal"},expansion:[{name:"LPAR",filter_out:!0,__type__:"Terminal"},{name:"bool_expr",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},24:{origin:{name:"top_level_expr",__type__:"NonTerminal"},expansion:[{name:"LPAR",filter_out:!0,__type__:"Terminal"},{name:"bool_expr",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"CONJUNCTION",filter_out:!1,__type__:"Terminal"},{name:"top_level_expr",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},25:{origin:{name:"bool_expr",__type__:"NonTerminal"},expansion:[{name:"condition",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},26:{origin:{name:"bool_expr",__type__:"NonTerminal"},expansion:[{name:"condition",__type__:"NonTerminal"},{name:"CONJUNCTION",filter_out:!1,__type__:"Terminal"},{name:"bool_expr",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},27:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"bool_const",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},28:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_selected_value",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},29:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_selected",__type__:"NonTerminal"}],order:2,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},30:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_text",__type__:"NonTerminal"}],order:3,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},31:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_text_ignore_case",__type__:"NonTerminal"}],order:4,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},32:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_mc_count",__type__:"NonTerminal"}],order:5,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},33:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_matrix_selected",__type__:"NonTerminal"}],order:6,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},34:{origin:{name:"condition",__type__:"NonTerminal"},expansion:[{name:"qc_matrix_count",__type__:"NonTerminal"}],order:7,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},35:{origin:{name:"qc_selected_value",__type__:"NonTerminal"},expansion:[{name:"__ANON_0",filter_out:!0,__type__:"Terminal"},{name:"question_or_matrix_statement_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},36:{origin:{name:"qc_mc_selected",__type__:"NonTerminal"},expansion:[{name:"NEGATION",filter_out:!1,__type__:"Terminal"},{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},37:{origin:{name:"qc_mc_selected",__type__:"NonTerminal"},expansion:[{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},38:{origin:{name:"qc_mc_text",__type__:"NonTerminal"},expansion:[{name:"__ANON_2",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"STRING",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},39:{origin:{name:"qc_mc_text_ignore_case",__type__:"NonTerminal"},expansion:[{name:"__ANON_3",filter_out:!0,__type__:"Terminal"},{name:"mc_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"STRING",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},40:{origin:{name:"qc_mc_count",__type__:"NonTerminal"},expansion:[{name:"__ANON_4",filter_out:!0,__type__:"Terminal"},{name:"question_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},41:{origin:{name:"qc_matrix_selected",__type__:"NonTerminal"},expansion:[{name:"NEGATION",filter_out:!1,__type__:"Terminal"},{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"matrix_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},42:{origin:{name:"qc_matrix_selected",__type__:"NonTerminal"},expansion:[{name:"__ANON_1",filter_out:!0,__type__:"Terminal"},{name:"matrix_choice_selector",__type__:"NonTerminal"},{name:"RPAR",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},43:{origin:{name:"qc_matrix_count",__type__:"NonTerminal"},expansion:[{name:"__ANON_5",filter_out:!0,__type__:"Terminal"},{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"},{name:"__ANON_6",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},44:{origin:{name:"qc_matrix_count",__type__:"NonTerminal"},expansion:[{name:"__ANON_5",filter_out:!0,__type__:"Terminal"},{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"},{name:"__ANON_6",filter_out:!0,__type__:"Terminal"},{name:"OPERATOR",filter_out:!1,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},45:{origin:{name:"question_selector",__type__:"NonTerminal"},expansion:[{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},46:{origin:{name:"mc_choice_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},47:{origin:{name:"mc_choice_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},48:{origin:{name:"matrix_statement_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"},{name:"DOT",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},49:{origin:{name:"matrix_choice_selector",__type__:"NonTerminal"},expansion:[{name:"matrix_statement_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"INT",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},50:{origin:{name:"matrix_choice_selector",__type__:"NonTerminal"},expansion:[{name:"matrix_statement_selector",__type__:"NonTerminal"},{name:"LSQB",filter_out:!0,__type__:"Terminal"},{name:"IDENTIFIER",filter_out:!1,__type__:"Terminal"},{name:"RSQB",filter_out:!0,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},51:{origin:{name:"question_or_matrix_statement_selector",__type__:"NonTerminal"},expansion:[{name:"question_selector",__type__:"NonTerminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},52:{origin:{name:"question_or_matrix_statement_selector",__type__:"NonTerminal"},expansion:[{name:"matrix_statement_selector",__type__:"NonTerminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},53:{origin:{name:"bool_const",__type__:"NonTerminal"},expansion:[{name:"TRUE",filter_out:!1,__type__:"Terminal"}],order:0,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"},54:{origin:{name:"bool_const",__type__:"NonTerminal"},expansion:[{name:"FALSE",filter_out:!1,__type__:"Terminal"}],order:1,alias:null,options:{keep_all_tokens:!1,expand1:!1,priority:null,template_source:null,empty_indices:[],__type__:"RuleOptions"},__type__:"Rule"}};const fr="(?<questionId>[a-zA-Z][a-zA-Z0-9_]*)",yr="((?<expressionWithoutIdentifier>all|all_entered_text|selected|selected_entered_text|not_selected)|(?<expressionWithIdentifier>for_matrix_choice|unselected_for_matrix_choice)(\\((?<identifier>[\\-a-zA-Z0-9_]+)\\)))",Tt=new RegExp(`^${fr}/${yr}$`);var T=(r=>(r.ALL="all",r.ALL_ENTERED_TEXT="all_entered_text",r.SELECTED="selected",r.SELECTED_ENTERED_TEXT="selected_entered_text",r.NOT_SELECTED="not_selected",r.FOR_MATRIX_CHOICE="for_matrix_choice",r.UNSELECTED_FOR_MATRIX_CHOICE="unselected_for_matrix_choice",r))(T||{});const vt=r=>Tt.test(r),L=r=>{var t;const n=(t=r.match(Tt))==null?void 0:t.groups;if(!n)throw new Error(`Invalid locator expression: ${r}`);const i=n.expressionWithoutIdentifier||n.expressionWithIdentifier||"all",s={questionId:n.questionId,expression:i};if(n.identifier){const a=isNaN(parseInt(n.identifier,10))?n.identifier:parseInt(n.identifier,10);s.identifier=a}return s},_e=(r,t="camelCase")=>{const n=t==="camelCase"?K.camelCase:K.snakeCase;return K.transform(r,(i,s,a)=>{const o=typeof a=="string"?n(a):a;i[o]=K.isObject(s)?_e(s,t):s})};function gr(r){const t=structuredClone(r);return{...t,...t.template,sections:t.sections.map(n=>({..._e(n),pages:n.pages.map((i,s)=>({...i,id:`${n.id}-${s}`,questions:xr(t,n,i.questions)}))}))}}function xr(r,t,n){return n.map(i=>wr(r.template.id,t,i))}function wr(r,t,n){var i,s;return{..._e({...n,choiceGroups:(i=n.choice_groups)==null?void 0:i.map(a=>({...a,randomization:Se(a.randomization)})),statementGroups:(s=n.statement_groups)==null?void 0:s.map(a=>({...a,randomization:Se(a.randomization)})),randomization:Se(n.randomization)}),id:Et(r,n),type:Nt(n.type),layout:Tr(n.layout),required:vr(n.required),label:t.name}}function Se(r){var t;return r?{type:bt(r.type),order:(t=r.order)==null?void 0:t.split(" "),total:r.total}:void 0}function bt(r){return r.toUpperCase()}function Et(r,t){return`${r}.${t.id}`}const $e=r=>r.split(".").pop();function Nt(r="description"){return r.replace("-","_").toUpperCase()}function Tr(r){return r==null?void 0:r.toUpperCase()}function vr(r="optional"){return r.replace("-","_").toUpperCase()}function kt(r){return structuredClone(r).sections.flatMap(t=>t.pages.flatMap(n=>n.questions))}var br=Object.defineProperty,Er=(r,t,n)=>t in r?br(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,U=(r,t,n)=>(Er(r,typeof t!="symbol"?t+"":t,n),n),Nr=(r,t,n)=>{if(!t.has(r))throw TypeError("Cannot "+n)},Rt=(r,t,n)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,n)},H=(r,t,n)=>(Nr(r,t,"access private method"),n),J,ce,pe,ze;const De=/\$\{q\:(?<locator>[\-a-zA-Z0-9_\/\(\)]+)\}/g,It=r=>{var t,n;return(n=(t=r.choiceId)!=null?t:r.choiceValue)!=null?n:r.text};class kr{constructor(t,n=[],i="",s=!1){Rt(this,J),Rt(this,pe),U(this,"questions",new Map),U(this,"responsesByQuestion",new Map),U(this,"responsesByQuestionStatement",new Map),U(this,"hashSalt"),U(this,"forExport"),U(this,"evaluationCache",new Map),this.questions=new Map((t?kt(t):[]).filter(a=>a.id).map(a=>[$e(a.id),a])),n.filter(a=>a.singleAnswer||a.multipleAnswers).forEach(a=>{const o=$e(a.questionId);this.responsesByQuestion.set(o,[...this.responsesByQuestion.get(o)||[],a]),a.statementId&&this.responsesByQuestionStatement.set(`${o}.${a.statementId}`,a)}),this.hashSalt=i,this.forExport=s}getQuestionAnswers(t,n){let i;if(n){const s=this.responsesByQuestionStatement.get(`${t}.${n}`);i=s===void 0?[]:[s]}else i=this.responsesByQuestion.get(t)||[];return i.flatMap(s=>{const{multipleAnswers:a,singleAnswer:o}=s;return a||[o]})}evaluateDisplayLogic(t){if(t&&!this.forExport)try{const n=this.evaluationCache.get(t);if(n!==void 0)return n;const i=Le(t,this);return this.evaluationCache.set(t,i),i}catch(n){return console.error(n),!1}return!0}evaluateDynamicExpression(t,n){const i=this.questions.get(t.questionId);if(!i)return[];const s=this.getQuestionChoicesFlattened(i),a=s.filter(p=>this.isSelected({questionId:t.questionId,choice:p.id||p.value})),o=this.getQuestionStatementsFlattened(i),l=p=>n==="choices"?p:{...p,id:p.id||p.value||p.display},c=p=>({id:p.id,display:p.display,value:p.value});let _=[];switch(t.expression){case T.ALL:_=s.map(l);break;case T.ALL_ENTERED_TEXT:_=s.map(p=>l(H(this,pe,ze).call(this,p,t)));break;case T.SELECTED:_=a;break;case T.SELECTED_ENTERED_TEXT:_=a.map(p=>l(H(this,pe,ze).call(this,p,t)));break;case T.NOT_SELECTED:_=s.filter(p=>!this.isSelected({questionId:t.questionId,choice:p.id||p.value})).map(l);break;case T.FOR_MATRIX_CHOICE:_=o.filter(p=>this.isSelected({questionId:t.questionId,statementId:p.id,choice:t.identifier}));break;case T.UNSELECTED_FOR_MATRIX_CHOICE:_=o.filter(p=>!this.isSelected({questionId:t.questionId,statementId:p.id,choice:t.identifier}));break;default:_=[]}return this.forExport&&(_=t.expression===T.FOR_MATRIX_CHOICE||t.expression===T.UNSELECTED_FOR_MATRIX_CHOICE?o:s.map(l)),_.map(c)}isSelected(t){return!!H(this,J,ce).call(this,t.questionId,t.statementId,t.choice).length}countSelected(t){return this.getQuestionAnswers(t).length}selectedValue(t){const n=this.getQuestionAnswers(t.questionId,t.statementId);return n.length?It(n[0]):null}countChoiceSelections(t,n){return H(this,J,ce).call(this,t,null,n).length}textEntry(t){return H(this,J,ce).call(this,t.questionId,t.statementId,t.choice).map(n=>n.text).filter(n=>n).join(", ")}getQuestionText(t){if(this.forExport)return t.text;let n=t.text;return n=n.replaceAll(De,(i,s)=>{if(s&&vt(s)){const a=L(s);return this.evaluateDynamicExpression(a,"choices").map(o=>o.display).join(", ")}return i}),n}getQuestionChoices(t){var n;const i=((n=t.choices)!=null?n:[]).filter(s=>this.evaluateDisplayLogic(s.displayLogic));if(t.dynamicChoices){const s=L(t.dynamicChoices),a=this.evaluateDynamicExpression(s,"choices");i.push(...a)}return t.type===de.MatrixSingle||t.type===de.MatrixMulti?i:this.applyRandomization(i,t.id,s=>{var a;return`${(a=s.id)!=null?a:s.value}`},t.randomization)}getQuestionChoiceGroups(t){var n;const i=(((n=t.choiceGroups)==null?void 0:n.filter(s=>this.evaluateDisplayLogic(s.displayLogic)))||[]).map(s=>({...s,choices:this.applyRandomization(s.choices.filter(a=>this.evaluateDisplayLogic(a.displayLogic)),t.id,a=>{var o;return`${(o=a.id)!=null?o:a.value}`},s.randomization)})).filter(s=>!!s.choices.length);return this.applyRandomization(i,t.id,s=>s.id,t.randomization)}getQuestionStatements(t){var n;const i=((n=t.statements)!=null?n:[]).filter(s=>this.evaluateDisplayLogic(s.displayLogic));if(t.dynamicStatements){const s=L(t.dynamicStatements),a=this.evaluateDynamicExpression(s,"statements");i.push(...a)}return this.applyRandomization(i,t.id,s=>s.id,t.randomization)}getQuestionStatementGroups(t){var n;const i=(((n=t.statementGroups)==null?void 0:n.filter(s=>this.evaluateDisplayLogic(s.displayLogic)))||[]).map(s=>({...s,statements:this.applyRandomization(s.statements.filter(a=>this.evaluateDisplayLogic(a.displayLogic)),t.id,a=>a.id,s.randomization)})).filter(s=>!!s.statements.length);return this.applyRandomization(i,t.id,s=>s.id,t.randomization)}getQuestionChoicesFlattened(t){return[...this.getQuestionChoices(t),...this.getQuestionChoiceGroups(t).flatMap(n=>n.choices)]}getQuestionStatementsFlattened(t){return[...this.getQuestionStatements(t),...this.getQuestionStatementGroups(t).flatMap(n=>n.statements)]}applyRandomization(t,n,i,s){var a,o;if(!s||this.forExport)return t;const l=new Map(t.map(h=>[i(h),h])),c=[...l.keys()],_=new Set(c),p=((a=s.order)!=null?a:["$"]).filter(h=>h==="$"||_.has(h)),y=c.filter(h=>!p.includes(h)).map(h=>({weight:this.keyHash(n,h),key:h}));y.sort((h,m)=>h.weight.localeCompare(m.weight));const v=(o=s.total)!=null?o:c.length,w=Math.min(v-(p.length-1),y.length),u=[];return p.forEach(h=>{h==="$"?u.push(...y.slice(0,w).map(m=>m.key)):u.push(h)}),u.map(h=>l.get(h))}keyHash(t,n){const i=`${t}.${this.hashSalt}.${n}`;return Mt.createHash("sha256").update(i).digest("hex")}}J=new WeakSet,ce=function(r,t,n){return this.getQuestionAnswers(r,t).filter(i=>typeof n=="undefined"||n===null||It(i)===n)},pe=new WeakSet,ze=function(r,t){if(r.textInput&&["forced","optional"].includes(r.textInput)){const n=this.textEntry({questionId:t.questionId,choice:r.id||r.value});return{...r,display:n}}return r};function qt(r){if(r.length===1)return r[0];const t=r[1].value;return t==="or"?r[0]||r[2]:t==="and"?r[0]&&r[2]:!1}function ue(r,t,n){switch(t){case"==":return r===n;case"!=":return r!==n;case"<=":return r<=n;case">=":return r>=n;case"<":return r<n;case">":return r>n;default:return!1}}function Ot(r,t,n,i){const s=i?r.toLowerCase():r,a=i?n.toLowerCase():n;switch(t){case"contains":return s.includes(a);case"not_contains":return!s.includes(a);case"regex_matches":try{return new RegExp(n).test(s)}catch{return!1}default:return ue(s,t,a)}}function At(r,t){return r.length===1?t(r[0]):(Ue(r[0].type==="NEGATION"),!t(r[1]))}function Pe(r){if(!["INT","IDENTIFIER"].includes(r.type))throw new SyntaxError(`Invalid token type: ${r.type}; expected IDENTIFIER or INT`);return k(r)}function k(r){var t,n;switch(r.type){case"IDENTIFIER":return r.value;case"INT":return parseInt(r.value,10);case"STRING":{const i=r.value.match(/(?:'(?<single>[^\']*)')|(?:"(?<double>[^\"]*)")/),s=((t=i==null?void 0:i.groups)==null?void 0:t.double)||((n=i==null?void 0:i.groups)==null?void 0:n.single);return Ue(s),s}case"OPERATOR":return r.value;case"TRUE":return!0;case"FALSE":return!1;default:throw new SyntaxError(`Invalid token type: ${r.type}`)}}function Le(r,t){const n={start:i=>i[0],top_level_expr:qt,bool_expr:qt,condition:i=>i[0],qc_mc_selected:i=>At(i,s=>t.isSelected(s)),qc_mc_text:i=>Ot(t.textEntry(i[0]),k(i[1]),k(i[2]),!1),qc_mc_text_ignore_case:i=>Ot(t.textEntry(i[0]),k(i[1]),k(i[2]),!0),qc_mc_count:i=>ue(t.countSelected(i[0]),k(i[1]),k(i[2])),qc_matrix_selected:i=>At(i,s=>t.isSelected(s)),qc_selected_value:i=>{const s=t.selectedValue(i[0]);return s!==null&&ue(s,k(i[1]),k(i[2]))},qc_matrix_count:i=>ue(t.countChoiceSelections(i[0],Pe(i[1])),k(i[2]),k(i[3])),question_selector:i=>i[0].value,question_or_matrix_statement_selector:i=>typeof i[0]=="string"?{questionId:i[0]}:i[0],mc_choice_selector:i=>({questionId:i[0],choice:Pe(i[1])}),matrix_statement_selector:i=>({questionId:i[0],statementId:k(i[1])}),matrix_choice_selector:i=>({...i[0],choice:Pe(i[1])}),bool_const:i=>i[0].value==="true"};return hr.get_parser({transformer:n}).parse(r)}const Rr=/\$\{m:([^\}]+)\}/g,Ir=100,Ce=(r,t)=>{if(typeof t=="string"){let n=t,i=0;for(;i<Ir;){const s=n.replace(Rr,(a,o)=>{if(r[o]===void 0)throw new Error(`Undefined macro: ${o}`);return r[o]});if(s===n)return s;n=s,i+=1}throw new Error(`Failed to finish interpolate macros - cyclic macros!? Stuck at: ${t}"`)}return typeof t=="object"&&Object.keys(t).forEach(n=>{t[n]=Ce(r,t[n])}),t},St=r=>(r.sections=Ce(r.macros||{},r.sections),r);var qr=Object.defineProperty,Or=(r,t,n)=>t in r?qr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,C=(r,t,n)=>(Or(r,typeof t!="symbol"?t+"":t,n),n);const $t=new Ct({allowUnionTypes:!0});Qt($t);const zt=$t.compile(Be);class Y extends Error{}class $ extends Error{}class he extends Error{}class Q extends Error{}class Ar extends Error{}class Sr{constructor(){C(this,"seenQuestions",new Set),C(this,"seenMultiQuestions",new Set),C(this,"seenQuestionStatements",new Map),C(this,"seenQuestionChoices",new Map),C(this,"seenTextChoices",new Map),C(this,"evaluator",{}),C(this,"validateReference",t=>{var n,i,s;if(!this.seenQuestions.has(t.questionId))throw new Y(`Invalid question: ${t.questionId}`);if(t.statementId!==void 0&&!((n=this.seenQuestionStatements.get(t.questionId))!=null&&n.has(t.statementId)))throw new Y(`Invalid statement: ${t.questionId}.${t.statementId}`);if(t.choice!==void 0&&!((i=this.seenQuestionChoices.get(t.questionId))!=null&&i.has(t.choice)))throw new Y(`Invalid choice: ${t.questionId}[${t.choice}]`);if(t.choice!==void 0&&t.expectText===!0&&!((s=this.seenTextChoices.get(t.questionId))!=null&&s.has(t.choice)))throw new Y(`Invalid text reference: ${t.questionId}[${t.choice}]`);if(typeof t.expectMulti=="boolean"&&t.expectMulti&&!this.seenMultiQuestions.has(t.questionId))throw new $(`Invalid question reference: ${t.questionId}. Expected a multi-answer question.`);if(typeof t.expectMulti=="boolean"&&!t.expectMulti&&this.seenMultiQuestions.has(t.questionId))throw new $(`Invalid question reference: ${t.questionId}. Expected a non-multi-answer question.`)}),this.evaluator.isSelected=t=>(this.validateReference(t),!1),this.evaluator.countSelected=t=>(this.validateReference({questionId:t}),0),this.evaluator.selectedValue=t=>(this.validateReference({questionId:t.questionId,statementId:t.statementId,expectMulti:!1}),0),this.evaluator.countChoiceSelections=(t,n)=>(this.validateReference({questionId:t,choice:n}),0),this.evaluator.textEntry=t=>(this.validateReference({...t,expectText:!0}),"")}}const F=(r,t,n)=>{if(n)try{Le(n,r.evaluator)}catch(i){throw i instanceof Y||i instanceof $||i instanceof Q?i:new Error(`Syntax error parsing display logic at ${t}: ${n}`)}},$r=(r,t)=>{[...t.matchAll(De)].forEach(n=>{var i;const s=L(n.groups.locator);if(!r.seenQuestions.has(s.questionId))throw new $(`Invalid question referenced in locator expression: ${s.questionId}/${s.expression}`);if(s.identifier&&!((i=r.seenQuestionChoices.get(s.questionId))!=null&&i.has(s.identifier)))throw new $(`Invalid question choice referenced in locator expression: ${s.questionId}/${s.expression}(${s.identifier})`)})},Z=(r,t,n)=>{if(n){const i=new Set(t);if(n.order){const s=n.order.split(" "),a=s.filter(o=>o==="$").length;if(a===0)throw new he(`Wildcard $ is missing in randomization order at ${r.id}`);if(a>1)throw new he(`Wildcard $ occurred multiples times in randomization order at ${r.id}`);if(s.forEach(o=>{if(o!=="$"&&!i.has(o))throw new he(`Unknown id ${o} in randomization ordering at ${r.id}`)}),n.total!==void 0&&n.total<s.length)throw new he(`Total value in randomization is too small at ${r.id}`)}}},Dt=(r,t)=>{const n=[T.FOR_MATRIX_CHOICE,T.UNSELECTED_FOR_MATRIX_CHOICE].includes(r.expression),i=(n?t.seenQuestionStatements:t.seenQuestionChoices).get(r.questionId);if(i===void 0)throw new $(`Invalid question referenced in locator expression: ${r.questionId}/${r.expression}`);if(n){const s=t.seenQuestionChoices.get(r.questionId);if(!r.identifier||!(s!=null&&s.has(r.identifier)))throw new $(`Invalid choice referenced in locator expression: ${r.questionId}/${r.expression}(${r.identifier})`)}return i},zr=(r,t)=>{var n,i,s,a,o,l,c,_,p,y,v;if($r(t,r.text),r.id!==void 0){if(F(t,r.id,r.display_logic),(n=r.statements)==null||n.forEach(u=>{F(t,`${r.id}.${u.id}`,u.display_logic)}),(i=r.choices)==null||i.forEach(u=>{F(t,`${r.id}[${u.id||u.value}]`,u.display_logic)}),r.type==="matrix-multi"||r.type==="matrix-single"?r.statement_groups?Z(r,r.statement_groups.map(u=>u.id),r.randomization):Z(r,(a=(s=r.statements)==null?void 0:s.map(u=>u.id))!=null?a:[],r.randomization):r.choice_groups?Z(r,r.choice_groups.map(u=>u.id),r.randomization):Z(r,(l=(o=r.choices)==null?void 0:o.map(u=>`${u.id||u.value}`))!=null?l:[],r.randomization),(c=r.statement_groups)==null||c.forEach(u=>{u.statements.forEach(h=>{F(t,`${r.id}.${h.id}`,h.display_logic)}),Z(r,u.statements.map(h=>h.id),u.randomization)}),(_=r.choice_groups)==null||_.forEach(u=>{u.choices.forEach(h=>{F(t,`${r.id}[${h.id||h.value}]`,h.display_logic)}),Z(r,u.choices.map(h=>`${h.id||h.value}`),u.randomization)}),t.seenQuestions.has(r.id))throw new Q(`Duplicate question id: ${r.id}`);if(t.seenQuestions.add(r.id),r.type&&["matrix-multi","mc-multi"].includes(r.type)&&t.seenMultiQuestions.add(r.id),r.statements||r.dynamic_statements){const u=new Set;if(t.seenQuestionStatements.set(r.id,u),(p=r.statements)==null||p.forEach(h=>{if(u.has(h.id))throw new Q(`Duplicate statement id: ${r.id}.${h.id}`);u.add(h.id)}),r.dynamic_statements){const h=L(r.dynamic_statements);Dt(h,t).forEach(m=>{if(typeof m=="number")throw new $(`Dynamic statement in question ${r.id} refers to choices with values`);if(u.has(m))throw new Q(`Duplicate statement ${m} via dynamic statements in question ${r.id}`);u.add(m)})}}const w=(y=r.choices)!=null?y:[];if(r.choice_groups){if(new Set(r.choice_groups.map(u=>u.id)).size!==r.choice_groups.length)throw new Q(`Choice groups must have a unique id in question ${r.id}`);r.choice_groups.forEach(u=>w.push(...u.choices))}if(w||r.dynamic_choices){const u=new Set;t.seenQuestionChoices.set(r.id,u);const h=new Set;if(t.seenTextChoices.set(r.id,h),w.forEach(m=>{var b;const q=(b=m.id)!=null?b:m.value;if(u.has(q))throw new Q(`Duplicate choice: ${r.id}[${q}]`);u.add(q),m.text_input&&m.text_input!=="no"&&h.add(q)}),r.dynamic_choices){const m=L(r.dynamic_choices);Dt(m,t).forEach(b=>{if(u.has(b))throw new Q(`Duplicate choice ${b} via dynamic choices in ${r.id}`);u.add(b)}),(v=t.seenTextChoices.get(m.questionId))==null||v.forEach(b=>h.add(b))}if(new Set([...u].map(m=>typeof m)).size>=2)throw new Ar("All choices in a question must either all have id's or all have values")}}},Dr=r=>{if(!zt(r))throw new Error(`Invalid template: ${r.template.id}. Reason: ${JSON.stringify(zt.errors,null,4)}`);St(r);const t=new Sr;r.sections.forEach(n=>{F(t,n.id,n.display_logic),n.pages.forEach(i=>{var s;(s=i.questions)==null||s.forEach(a=>{zr(a,t)})})})};function Pr(r,t){const n=structuredClone(r);return{...n,sections:n.sections.map(i=>({id:i.id,name:i.name,hideProgressBar:i.hideProgressBar,pages:t.evaluateDisplayLogic(i.displayLogic)?i.pages.map(s=>({...s,questions:Lr(s.questions,t)})).filter(s=>s.questions.length):[]})).filter(i=>i.pages.length)}}function Lr(r,t){return r.filter(n=>t.evaluateDisplayLogic(n.displayLogic)).map(n=>({...n,text:t.getQuestionText(n),statements:t.getQuestionStatements(n),choices:t.getQuestionChoices(n),statementGroups:t.getQuestionStatementGroups(n),choiceGroups:t.getQuestionChoiceGroups(n),randomization:void 0}))}const Cr=r=>!!(r!=null&&r.singleAnswer)||!!(r!=null&&r.multipleAnswers)&&(r==null?void 0:r.multipleAnswers.length)>0,Qr=Be,Mr="pulse_default_alpha",jr={allPermissions:Ut,SURVEY_RESOURCE_TYPE:jt,surveyAdministerPermission:Fe};export{Mr as DEFAULT_TEMPLATE_ID,T as LOCATOR_EXPRESSION,De as QUESTION_TEXT_LOCATOR_PATTERN,kr as TemplateContextEvaluator,Le as evaluateExpression,Pr as evaluateTemplateNode,kt as extractQuestionNodes,Ft as getExperimentalOptionalBoolean,Zt as getExperimentalOptionalString,Et as getQualifiedQuestionId,Nt as getQuestionTypeEnum,bt as getRandomizationTypeEnum,$e as getRawQuestionId,gr as getTemplateNode,Cr as hasAnswer,Ce as interpolateMacros,St as interpolateTemplate,L as parseLocator,jr as permissions,Bt as polyfillStructuredClone,Qr as templateSchema,_e as transformCase,vt as validateLocator,Dr as validateTemplate};
23
23
  //# sourceMappingURL=index.esm.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spotify/backstage-plugin-pulse-common",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "homepage": "https://backstage.spotify.com",
6
6
  "main": "dist/index.cjs.js",
@@ -24,7 +24,8 @@
24
24
  "json2ts": "./src/templates/schema/generateSchemaTypes.sh"
25
25
  },
26
26
  "dependencies": {
27
- "@backstage/plugin-permission-common": "^0.7.9",
27
+ "@backstage/config": "^1.1.1",
28
+ "@backstage/plugin-permission-common": "^0.7.11",
28
29
  "@ungap/structured-clone": "^1.2.0",
29
30
  "ajv": "^8.11.2",
30
31
  "ajv-formats": "^2.1.1",
@@ -32,7 +33,7 @@
32
33
  "lodash": "^4.17.21"
33
34
  },
34
35
  "devDependencies": {
35
- "@backstage/cli": "^0.23.0",
36
+ "@backstage/cli": "^0.25.0",
36
37
  "@types/ungap__structured-clone": "^0.3.0",
37
38
  "js-yaml": "^4.1.0",
38
39
  "json-schema-to-typescript": "^13.1.1",