@tripetto/runner-autoscroll
Version:
Autoscroll UI for running Tripetto forms and surveys.
2 lines • 575 kB
JavaScript
/*! Tripetto Autoscroll Runner 8.2.3 - Copyright (C) 2023 Tripetto B.V. - All Rights Reserved */
import{Collection as e,Components as t,pgettext as o,isString as i,lookupVariable as l,Slots as a,isNumberFinite as n,L10n as s,setAny as c,icon as r,name as u,title as d,width as b,menu as M,definition as h,affects as g,editor as m,created as p,deleted as v,tripetto as N,assigned as w,slots as A,renamed as I,conditions as D,Forms as L,DateTime as j,makeMarkdownSafe as S,Markdown as x,npgettext as k,isFilledString as f,Str as y,insertVariable as T,NodeBlock as C,getMetadata as z,each as E,castToString as U,castToNumber as O,Num as Y,set as P,getHelpTopic as Z,isNumber as V,scheduleTimeout as R,populateSlots as W,findFirst as G,getSlotIcon as F,ConditionBlock as Q,populateVariables as B,metadata as H,markdownifyToString as q,isBoolean as $,alias as X,score as J,collection as _,reordered as K,refreshed as ee,supplies as te,isVariable as oe,map as ie,filter as le,REGEX_IS_URL as ae,detached as ne,arraySize as se,mountNamespace as ce,unmountNamespace as re,AES as ue,isDefined as de}from"@tripetto/builder";function be(e,t,o,i){var l,a=arguments.length,n=a<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,o,i);else for(var s=e.length-1;s>=0;s--)(l=e[s])&&(n=(a<3?l(n):a>3?l(t,o,n):l(t,o))||n);return a>3&&n&&Object.defineProperty(t,o,n),n}const Me=["π","e","γ","c","random","timestamp","year","month","day","day-of-week","hour","minute","second","millisecond","timezone","branch"];function he(e){if("string"==typeof e){const t=Me.length;for(let o=0;o<t;o++)if(Me[o]===e)return!0}return!1}function ge(e){switch(e){case"π":return`π ≈ ${s.locale.number(3.14159,"auto")}`;case"e":return`e ≈ ${s.locale.number(2.71828,"auto")}`;case"γ":return`γ ≈ ${s.locale.number(.57722,"auto")}`;case"c":return`c = ${s.locale.number(299792458)} m/s`;case"random":return o("block:calculator","Random value (0 to less than 1)");case"timestamp":return o("block:calculator","UNIX time (seconds since Unix Epoch)");case"year":return o("block:calculator","Year");case"month":return o("block:calculator","Month (January = 1)");case"day":return o("block:calculator","Day of month (1-31)");case"day-of-week":return o("block:calculator","Day of week (Sunday = 0)");case"hour":return o("block:calculator","Hour (0-23)");case"minute":return o("block:calculator","Minute (0-59)");case"second":return o("block:calculator","Second (0-59)");case"millisecond":return o("block:calculator","Millisecond (0-999)");case"timezone":return o("block:calculator","Timezone (in milliseconds)");case"branch":return o("block:calculator","Branch number")}}var me="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIgLjVDMS4xNzMuNS41IDEuMTczLjUgMnYxNmMwIC44MjcuNjczIDEuNSAxLjUgMS41aDE2Yy44MjcgMCAxLjUtLjY3MyAxLjUtMS41VjJjMC0uODI3LS42NzMtMS41LTEuNS0xLjVIMnpNNSA4aDEwYS41LjUgMCAwIDEgMCAxSDVhLjUuNSAwIDAgMSAwLTF6bTAgM2gxMGEuNS41IDAgMCAxIDAgMUg1YS41LjUgMCAwIDEgMC0xeiIgZmlsbD0iI0E4QzZERiIgY2xhc3M9InRyaXBldHRvLWZpbGwiLz48L3N2Zz4=",pe="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0E4QzZERiI+PHBhdGggZD0iTTE4IDE5LjVIMmMtLjgyNyAwLTEuNS0uNjczLTEuNS0xLjVWMkMuNSAxLjE3MyAxLjE3My41IDIgLjVoMTZjLjgyNyAwIDEuNS42NzMgMS41IDEuNXYxNmMwIC44MjctLjY3MyAxLjUtMS41IDEuNXpNMiAxLjVhLjUuNSAwIDAgMC0uNS41djE2YS41LjUgMCAwIDAgLjUuNWgxNmEuNS41IDAgMCAwIC41LS41VjJhLjUuNSAwIDAgMC0uNS0uNXoiIGNsYXNzPSJ0cmlwZXR0by1maWxsIi8+PHBhdGggZD0iTTE1IDkuNWgtNC41VjVhLjUuNSAwIDAgMC0xIDB2NC41SDVhLjUuNSAwIDAgMCAwIDFoNC41VjE1YS41LjUgMCAwIDAgMSAwdi00LjVIMTVhLjUuNSAwIDAgMCAwLTF6IiBjbGFzcz0idHJpcGV0dG8tZmlsbCIvPjwvZz48L3N2Zz4=",ve="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0E4QzZERiI+PHBhdGggZD0iTTE4IDE5LjVIMmMtLjgyNyAwLTEuNS0uNjczLTEuNS0xLjVWMkMuNSAxLjE3MyAxLjE3My41IDIgLjVoMTZjLjgyNyAwIDEuNS42NzMgMS41IDEuNXYxNmMwIC44MjctLjY3MyAxLjUtMS41IDEuNXpNMiAxLjVhLjUuNSAwIDAgMC0uNS41djE2YS41LjUgMCAwIDAgLjUuNWgxNmEuNS41IDAgMCAwIC41LS41VjJhLjUuNSAwIDAgMC0uNS0uNXoiIGNsYXNzPSJ0cmlwZXR0by1maWxsIi8+PHBhdGggZD0iTTE1IDEwLjVINWEuNS41IDAgMCAxIDAtMWgxMGEuNS41IDAgMCAxIDAgMXoiIGNsYXNzPSJ0cmlwZXR0by1maWxsIi8+PC9nPjwvc3ZnPg==",Ne="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0E4QzZERiI+PHBhdGggZD0iTTE4IDE5LjVIMmMtLjgyNyAwLTEuNS0uNjczLTEuNS0xLjVWMkMuNSAxLjE3MyAxLjE3My41IDIgLjVoMTZjLjgyNyAwIDEuNS42NzMgMS41IDEuNXYxNmMwIC44MjctLjY3MyAxLjUtMS41IDEuNXpNMiAxLjVhLjUuNSAwIDAgMC0uNS41djE2YS41LjUgMCAwIDAgLjUuNWgxNmEuNS41IDAgMCAwIC41LS41VjJhLjUuNSAwIDAgMC0uNS0uNXoiIGNsYXNzPSJ0cmlwZXR0by1maWxsIi8+PHBhdGggZD0iTTE0LjgzMiAxMy42MjYgMTAuNzUyIDEwbDQuMDgtMy42MjZhLjUuNSAwIDAgMC0uNjY0LS43NDhMMTAgOS4zMzEgNS44MzIgNS42MjZhLjUuNSAwIDEgMC0uNjY0Ljc0OEw5LjI0OCAxMGwtNC4wOCAzLjYyNmEuNS41IDAgMCAwIC42NjQuNzQ4TDEwIDEwLjY2OWw0LjE2OCAzLjcwNWEuNS41IDAgMSAwIC42NjQtLjc0OHoiIGNsYXNzPSJ0cmlwZXR0by1maWxsIi8+PC9nPjwvc3ZnPg==",we="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0E4QzZERiI+PHBhdGggZD0iTTE4IDE5LjVIMmMtLjgyNyAwLTEuNS0uNjczLTEuNS0xLjVWMkMuNSAxLjE3MyAxLjE3My41IDIgLjVoMTZjLjgyNyAwIDEuNS42NzMgMS41IDEuNXYxNmMwIC44MjctLjY3MyAxLjUtMS41IDEuNXpNMiAxLjVhLjUuNSAwIDAgMC0uNS41djE2YS41LjUgMCAwIDAgLjUuNWgxNmEuNS41IDAgMCAwIC41LS41VjJhLjUuNSAwIDAgMC0uNS0uNXoiIGNsYXNzPSJ0cmlwZXR0by1maWxsIi8+PHBhdGggZD0iTTE1IDEwLjVINWEuNS41IDAgMCAxIDAtMWgxMGEuNS41IDAgMCAxIDAgMXpNMTAgOGMtLjU1MSAwLTEtLjQ0OS0xLTFzLjQ0OS0xIDEtMWMuNTUxIDAgMSAuNDQ5IDEgMXMtLjQ0OSAxLTEgMXptMCA2Yy0uNTUxIDAtMS0uNDQ5LTEtMXMuNDQ5LTEgMS0xYy41NTEgMCAxIC40NDkgMSAxcy0uNDQ5IDEtMSAxeiIgY2xhc3M9InRyaXBldHRvLWZpbGwiLz48L2c+PC9zdmc+";const Ae=(e,i)=>l=>{const a=i||e.startBlank&&0===e.operations.count||"="!==l,n=[];n.push(new t.MenuItemWithIcon(59254,o("block:calculator","Number"),(()=>e.operations.append().set({operator:l,opcode:"number",value:"/"===l?1:0,open:!0}))));const s=je(e,l);return n.push(new t.MenuSubmenuWithIcon(59105,o("block:calculator","Score"),Ie(e,l),!1,!1),new t.MenuSubmenuWithIcon(59449,o("block:calculator","Comparison"),(()=>{const i=De(e,l);return[new t.MenuItemWithIcon(e.startBlank||e.operations.count>0?59239:59644,e.startBlank||e.operations.count>0?o("block:calculator","Last outcome (%1)","ANS"):o("block:calculator","Initial value"),(()=>e.operations.append().set({operator:l,opcode:"equation",value:void 0,cona:0,conb:0,outa:1,outb:0,open:!0})),0===e.operations.count&&e.startBlank),new t.MenuSubmenuWithIcon(59273,o("block:calculator","Date/time"),[new t.MenuItem(o("block:calculator","Current date"),(()=>e.operations.append().set({operator:l,opcode:"date",value:void 0,cona:j.UTCToday,conb:void 0,outa:1,outb:0,open:!0}))),new t.MenuItem(o("block:calculator","Current date + time"),(()=>e.operations.append().set({operator:l,opcode:"datetime",value:void 0,cona:j.UTC,conb:void 0,outa:1,outb:0,open:!0})))]),...i]})),new t.MenuSubmenuWithIcon(58927,o("block:calculator","Function"),(()=>Le(l,e.operations,a))),new t.MenuItemWithIcon(59238,o("block:calculator","Subcalculation"),(()=>e.operations.append().set({operator:l,opcode:"calc",open:!0})))),s.length>0&&(s[0]instanceof t.MenuSeparator||n.push(new t.MenuSeparator,new t.MenuLabel(o("block:calculator","Blocks"))),n.push(...s)),n},Ie=(i,l)=>{const n=[];let s;const c=e=>{if((null==e?void 0:e.id)!==s){const o=null==e?void 0:e.name;n.length>0&&n.push(new t.MenuSeparator),o&&n.push(new t.MenuLabel(o)),s=null==e?void 0:e.id}},r=(a,s)=>{var r,u,d,b;const M=e.find(s),h=z(s.block,"calculator");if(M||h&&(null===(u=h[(null===(r=s.slot)||void 0===r?void 0:r.reference)||"*"]||h["*"])||void 0===u?void 0:u.scores)){c(a.block.node.section);const e=null===(b=null===(d=s.slot)||void 0===d?void 0:d.slots)||void 0===b?void 0:b.select("score","feature");if(e){const c=[];Se(c,l,i.operations,{type:"slot",block:a.block,label:e.alias||o("block:calculator","Existing score"),icon:a.icon||a.block.type.icon,id:e.id,reference:e.reference,slot:e},!1,!0),c.push(new t.MenuItemWithIcon(59147,o("block:calculator","New score"),(()=>i.operations.append().set({operator:l,opcode:"score",value:s.id,open:!0})))),n.push(new t.MenuSubmenuWithImage(a.icon||a.block.type.icon,a.label,c))}else n.push(new t.MenuItemWithImage(a.icon||a.block.type.icon,a.label,(()=>i.operations.append().set({operator:l,opcode:"score",value:s.id,open:!0}))))}};return E(W(i.block,{mode:"validated",pipes:"include-consumed-slots"}),(s=>{s.slots?G(s.slots,(u=>{var d,b;if("pipe"===u.type){if(e.find(u)){const e=null===(b=null===(d=u.slot)||void 0===d?void 0:d.slots)||void 0===b?void 0:b.select("score","feature");if(c(s.block.node.section),e){const a=[];Se(a,l,i.operations,{type:"slot",block:s.block,label:e.alias||o("block:calculator","Existing score"),icon:s.icon||s.block.type.icon,id:e.id,reference:e.reference,slot:e},!1,!0),a.push(new t.MenuItemWithIcon(59147,o("block:calculator","New score"),(()=>i.operations.append().set({operator:l,opcode:"score",value:u.id,open:!0})))),n.push(new t.MenuSubmenuWithImage(s.icon||s.block.type.icon,s.label,a))}else n.push(new t.MenuItemWithImage(s.icon||s.block.type.icon,s.label,(()=>i.operations.append().set({operator:l,opcode:"score",value:u.id,open:!0}))));return!0}}else if(u.id&&(u.slot instanceof a.String||u.slot instanceof a.Text))return r(s,u),!0;return!1})):s.id&&(s.slot instanceof a.String||s.slot instanceof a.Text)&&r(s,s)})),n},De=(i,l)=>{const n=[];let s;const c=e=>{if((null==e?void 0:e.id)!==s){const i=null==e?void 0:e.name;n.push(new t.MenuSeparator),(i||1===n.length)&&n.push(new t.MenuLabel(i||o("block:calculator","Blocks"))),s=null==e?void 0:e.id}};return E(W(i.block,{mode:"validated",pipes:"exclude"}),(o=>{if(o.slots){const s=[];let r;E(o.slots,(o=>{if(o.id&&(o.slot instanceof a.String||o.slot instanceof a.Text||o.slot instanceof a.Boolean||o.slot instanceof a.Number||o.slot instanceof a.Numeric||o.slot instanceof a.Date)){const n=(o.slot instanceof a.String||o.slot instanceof a.Text)&&e.find(o);n&&n.sole||s.push(new t.MenuItemWithIcon(F(o.slot),o.label,r=()=>i.operations.append().set(o.slot instanceof a.String||o.slot instanceof a.Text?{operator:l,opcode:"evaluate",value:o.id,cona:0,conb:0,outa:1,outb:0,open:!0}:o.slot instanceof a.Boolean?{operator:l,opcode:"boolean",value:o.id,outa:1,outb:0,open:!0}:o.slot instanceof a.Date?{operator:l,opcode:"date",value:o.id,cona:void 0,conb:void 0,outa:1,outb:0,open:!0}:{operator:l,opcode:"equation",value:o.id,cona:0,conb:0,outa:1,outb:0,open:!0})))}})),s.length>0&&(c(o.block.node.section),n.push(1===s.length&&r?new t.MenuItemWithImage(o.icon||o.block.type.icon,o.label,r):new t.MenuSubmenuWithImage(o.icon||o.block.type.icon,o.label,s)))}else if(o.id&&(o.slot instanceof a.String||o.slot instanceof a.Text||o.slot instanceof a.Boolean||o.slot instanceof a.Number||o.slot instanceof a.Numeric||o.slot instanceof a.Date)){const s=(o.slot instanceof a.String||o.slot instanceof a.Text)&&e.find(o);s&&s.sole||(c(o.block.node.section),n.push(new t.MenuItemWithImage(o.icon||o.block.type.icon,o.label,(()=>i.operations.append().set(o.slot instanceof a.String||o.slot instanceof a.Text?{operator:l,opcode:"evaluate",value:o.id,cona:0,conb:0,outa:1,outb:0,open:!0}:o.slot instanceof a.Boolean?{operator:l,opcode:"boolean",value:o.id,outa:1,outb:0,open:!0}:o.slot instanceof a.Date?{operator:l,opcode:"date",value:o.id,cona:void 0,conb:void 0,outa:1,outb:0,open:!0}:{operator:l,opcode:"equation",value:o.id,cona:0,conb:0,outa:1,outb:0,open:!0})))))}})),n},Le=(e,i,l,a,n=!0)=>[new t.MenuSubmenuWithIcon(59122,o("block:calculator","Limiting"),[new t.MenuItem("min",(()=>i.append().set({operator:e,opcode:"min",value:l?0:a,min:0,open:!0}))),new t.MenuItem("max",(()=>i.append().set({operator:e,opcode:"max",value:l?0:a,max:0,open:!0}))),new t.MenuItem("clamp",(()=>i.append().set({operator:e,opcode:"clamp",value:l?0:a,min:0,max:0,open:!0})))]),new t.MenuSubmenuWithImage("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbDpzcGFjZT0icHJlc2VydmUiIHdpZHRoPSI1ODAiIGhlaWdodD0iNTgwIiBzaGFwZS1yZW5kZXJpbmc9Imdlb21ldHJpY1ByZWNpc2lvbiIgdGV4dC1yZW5kZXJpbmc9Imdlb21ldHJpY1ByZWNpc2lvbiIgaW1hZ2UtcmVuZGVyaW5nPSJvcHRpbWl6ZVF1YWxpdHkiIHZpZXdCb3g9IjAgMCA1ODAwIDU4MDAiPjxwYXRoIGNsYXNzPSJ0cmlwZXR0by1maWxsIiBkPSJNNzAwIDE1MDBoNDQwMGMyMjAgMCA0MDAgMTgwIDQwMCA0MDB2MjAwMGMwIDIyMC0xODAgNDAwLTQwMCA0MDBINzAwYy0yMjAgMC00MDAtMTgwLTQwMC00MDBWMTkwMGMwLTIyMCAxODAtNDAwIDQwMC00MDB6bTMxMDAgMjAwdjI0MDBoMTMwMGMxMTAgMCAyMDAtOTAgMjAwLTIwMFYxOTAwYzAtMTEwLTkwLTIwMC0yMDAtMjAwSDM4MDB6bS0yMDAgMjQwMFYxNzAwSDcwMGMtMTEwIDAtMjAwIDkwLTIwMCAyMDB2MjAwMGMwIDExMCA5MCAyMDAgMjAwIDIwMGgyOTAwem0xMzAwLTE0MDBjMC0xMjEtNzktMjAwLTIwMC0yMDBoLTIwMGMtMTIxIDAtMjAwIDc5LTIwMCAyMDB2NDAwYzAgMTIxIDc5IDIwMCAyMDAgMjAwaDIwMGMxMjEgMCAyMDAtNzkgMjAwLTIwMHYtNDAwem0yMDAgMHY0MDBjMCAyMzEtMTY5IDQwMC00MDAgNDAwaC0yMDBjLTIzMSAwLTQwMC0xNjktNDAwLTQwMHYtNDAwYzAtMjMxIDE2OS00MDAgNDAwLTQwMGgyMDBjMjMxIDAgNDAwIDE2OSA0MDAgNDAwem0tMjAwMCAwYzAtMTIxLTc5LTIwMC0yMDAtMjAwaC0yMDBjLTEyMSAwLTIwMCA3OS0yMDAgMjAwdjQwMGMwIDEyMSA3OSAyMDAgMjAwIDIwMGgyMDBjMTIxIDAgMjAwLTc5IDIwMC0yMDB2LTQwMHptMjAwIDB2NDAwYzAgMjMxLTE2OSA0MDAtNDAwIDQwMGgtMjAwYy0yMzEgMC00MDAtMTY5LTQwMC00MDB2LTQwMGMwLTIzMSAxNjktNDAwIDQwMC00MDBoMjAwYzIzMSAwIDQwMCAxNjkgNDAwIDQwMHptLTE2MDAgMGMwLTEyMS03OS0yMDAtMjAwLTIwMGgtMjAwYy0xMjEgMC0yMDAgNzktMjAwIDIwMHY0MDBjMCAxMjEgNzkgMjAwIDIwMCAyMDBoMjAwYzEyMSAwIDIwMC03OSAyMDAtMjAwdi00MDB6bTIwMCAwdjQwMGMwIDIzMS0xNjkgNDAwLTQwMCA0MDBoLTIwMGMtMjMxIDAtNDAwLTE2OS00MDAtNDAwdi00MDBjMC0yMzEgMTY5LTQwMCA0MDAtNDAwaDIwMGMyMzEgMCA0MDAgMTY5IDQwMCA0MDB6Ii8+PC9zdmc+",o("block:calculator","Floating point"),[new t.MenuItem("round",(()=>i.append().set({operator:e,opcode:"round",value:l?0:a,open:l}))),new t.MenuItem("floor",(()=>i.append().set({operator:e,opcode:"floor",value:l?0:a,open:l}))),new t.MenuItem("ceil",(()=>i.append().set({operator:e,opcode:"ceil",value:l?0:a,open:l}))),new t.MenuItem("trunc",(()=>i.append().set({operator:e,opcode:"trunc",value:l?0:a,open:l})))]),new t.MenuSubmenuWithImage("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbDpzcGFjZT0icHJlc2VydmUiIHdpZHRoPSI1ODAiIGhlaWdodD0iNTgwIiBzaGFwZS1yZW5kZXJpbmc9Imdlb21ldHJpY1ByZWNpc2lvbiIgdGV4dC1yZW5kZXJpbmc9Imdlb21ldHJpY1ByZWNpc2lvbiIgaW1hZ2UtcmVuZGVyaW5nPSJvcHRpbWl6ZVF1YWxpdHkiIHZpZXdCb3g9IjAgMCA1ODAwIDU4MDAiPjxwYXRoIGNsYXNzPSJ0cmlwZXR0by1maWxsIiBkPSJNNTEwMCAyMzAwaC0zNTZsLTgyNCA5MTYgNDQxIDg4NGgzMzl2MjAwaC00MDBjLTM2IDAtNzItMjEtODktNTVsLTQzNS04NzAtODAyIDg5MmMtNSA1LTc0IDMzLTc0IDMzaC00MDB2LTIwMGgzNTZsODI0LTkxNi00NDEtODg0aC0zMzl2LTIwMGg0MDBjNDMgMCA3OSAyNyA5MyA2NGw0MzEgODYxIDc5OC04ODhjMTgtMjIgNDctMzcgNzgtMzdoNDAwdjIwMHoiLz48cGF0aCBjbGFzcz0idHJpcGV0dG8tZmlsbCIgZD0iTTMwMCAyOTAwaDQwMGM0OCAwIDg3IDMzIDk3IDc4bDUwMCAxNDk5TDI0MDUgOTcwYzEzLTQzIDUzLTcwIDk1LTcwaDMwMDB2MjAwSDI1NzNMMTM5NSA0ODMwYy05IDI5LTMyIDU0LTY0IDY1LTUyIDE3LTEwOC0xMi0xMjYtNjRMNjI4IDMxMDBIMzAwdi0yMDB6Ii8+PC9zdmc+",o("block:calculator","Exponentiation"),[new t.MenuItem("x²",(()=>i.append().set({operator:e,opcode:"square",value:l?0:a,open:l}))),new t.MenuItem("√",(()=>i.append().set({operator:e,opcode:"sqrt",value:l?0:a,open:l}))),new t.MenuItem("pow",(()=>i.append().set({operator:e,opcode:"pow",exponent:1,open:!0}))),new t.MenuItem("exp",(()=>i.append().set({operator:e,opcode:"exp",exponent:l?0:void 0,open:l}))),new t.MenuItem("ln",(()=>i.append().set({operator:e,opcode:"ln",value:l?0:a,open:l}))),new t.MenuItem("log",(()=>i.append().set({operator:e,opcode:"log",value:l?0:a,open:l})))]),new t.MenuSubmenuWithIcon(59778,o("block:calculator","Trigonometry"),[new t.MenuItem("sin",(()=>i.append().set({operator:e,opcode:"sin",value:l?0:a,open:l}))),new t.MenuItem("cos",(()=>i.append().set({operator:e,opcode:"cos",value:l?0:a,open:l}))),new t.MenuItem("tan",(()=>i.append().set({operator:e,opcode:"tan",value:l?0:a,open:l}))),new t.MenuSeparator,new t.MenuLabel(o("block:calculator","Inverse")),new t.MenuItem("sin⁻¹",(()=>i.append().set({operator:e,opcode:"asin",value:l?0:a,open:l}))),new t.MenuItem("cos⁻¹",(()=>i.append().set({operator:e,opcode:"acos",value:l?0:a,open:l}))),new t.MenuItem("tan⁻¹",(()=>i.append().set({operator:e,opcode:"atan",value:l?0:a,open:l}))),new t.MenuSeparator,new t.MenuLabel(o("block:calculator","Hyperbolic")),new t.MenuItem("sinh",(()=>i.append().set({operator:e,opcode:"sinh",value:l?0:a,open:l}))),new t.MenuItem("cosh",(()=>i.append().set({operator:e,opcode:"cosh",value:l?0:a,open:l}))),new t.MenuItem("tanh",(()=>i.append().set({operator:e,opcode:"tanh",value:l?0:a,open:l}))),new t.MenuSeparator,new t.MenuLabel(o("block:calculator","Inverse hyperbolic")),new t.MenuItem("sinh⁻¹",(()=>i.append().set({operator:e,opcode:"asinh",value:l?0:a,open:l}))),new t.MenuItem("cosh⁻¹",(()=>i.append().set({operator:e,opcode:"acosh",value:l?0:a,open:l}))),new t.MenuItem("tanh⁻¹",(()=>i.append().set({operator:e,opcode:"atanh",value:l?0:a,open:l})))]),new t.MenuSubmenuWithIcon(59732,o("block:calculator","Factorial"),[new t.MenuItem("n!",(()=>i.append().set({operator:e,opcode:"fact",value:l?0:a,open:l}))),new t.MenuItem("gamma",(()=>i.append().set({operator:e,opcode:"gamma",value:l?0:a,open:l})))]),new t.MenuSubmenuWithIcon(59704,o("block:calculator","Miscellaneous"),[new t.MenuItem("abs",(()=>i.append().set({operator:e,opcode:"abs",value:l?0:a,open:l}))),new t.MenuItem("sgn",(()=>i.append().set({operator:e,opcode:"sgn",value:l?0:a,open:l}))),new t.MenuItem("mod",(()=>i.append().set({operator:e,opcode:"mod",value:l?0:a,divisor:1,open:!0}))),new t.MenuItem("%",(()=>i.append().set({operator:e,opcode:"percentage",value:l?0:a,percentage:0,open:!0})))]),...n?[new t.MenuSubmenuWithIcon(59222,o("block:calculator","Constants"),(()=>Me.map((o=>new t.MenuItemWithIcon(function(e){switch(e){case"π":case"e":case"γ":case"c":return 59098;case"random":return 59015;case"timestamp":return 59274;case"year":case"month":case"day-of-week":return 59273;case"day":return 59272;case"hour":case"minute":case"second":case"millisecond":return 59624;case"timezone":return 59526;case"branch":return 59719}}(o),ge(o),(()=>i.append().set({operator:e,opcode:"number",value:o})))))))]:[]],je=(i,l)=>{const n=[];let s;const c=e=>{if((null==e?void 0:e.id)!==s){const o=null==e?void 0:e.name;(n.length>0||o)&&n.push(new t.MenuSeparator),o&&n.push(new t.MenuLabel(o)),s=null==e?void 0:e.id}};return E(W(i.block,{mode:"validated",pipes:"include-consumed-slots"}),(s=>{if(s.slots){const r=[];let u=!0,d=!1,b=!1;G(s.slots,(n=>{var c,u,M;if("pipe"===n.type){const h=e.find(n);if(h){const e=null===(u=null===(c=n.slot)||void 0===c?void 0:c.slots)||void 0===u?void 0:u.select("score","feature");if(d=!0,e){const a=[];Se(a,l,i.operations,{type:"slot",block:s.block,label:e.alias||o("block:calculator","Existing score"),icon:s.icon||s.block.type.icon,id:e.id,reference:e.reference,slot:e},!1,!0),a.push(new t.MenuItemWithIcon(59147,o("block:calculator","New score"),(()=>i.operations.append().set({operator:l,opcode:"score",value:n.id,open:!0})))),r.push(new t.MenuSubmenuWithIcon(59105,o("block:calculator","Score"),a))}else r.push(new t.MenuItemWithIcon(59105,o("block:calculator","Score"),(()=>i.operations.append().set({operator:l,opcode:"score",value:n.id,open:!0}))));if(h.origin&&h.sole)if(n.slot instanceof a.Number||n.slot instanceof a.Numeric)r.push(new t.MenuItemWithIcon(59837,o("block:calculator","Sum"),(()=>i.operations.append().set({operator:l,opcode:"sum",value:n.id}))));else if(n.slot instanceof a.Boolean){const e=null===(M=n.slot.slots)||void 0===M?void 0:M.select("counter");e?(b=!0,Se(r,l,i.operations,{type:"slot",block:s.block,label:e.label||o("block:calculator","Counter"),icon:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCI+PHBhdGggZD0iTTIgNmEuNTAyLjUwMiAwIDAgMS0uMzU0LS4xNDZsLTEuNS0xLjVhLjUuNSAwIDAgMSAuNzA3LS43MDdsMS4xNDYgMS4xNDZMNi4xNDUuNjQ3YS41LjUgMCAwIDEgLjcwNy43MDdsLTQuNSA0LjVBLjQ5OC40OTggMCAwIDEgMS45OTggNnptMTcuNS0xaC0xMmEuNS41IDAgMCAxIDAtMWgxMmEuNS41IDAgMCAxIDAgMXpNMiAxM2EuNTAyLjUwMiAwIDAgMS0uMzU0LS4xNDZsLTEuNS0xLjVhLjUuNSAwIDAgMSAuNzA3LS43MDdsMS4xNDYgMS4xNDYgNC4xNDYtNC4xNDZhLjUuNSAwIDAgMSAuNzA3LjcwN2wtNC41IDQuNWEuNDk4LjQ5OCAwIDAgMS0uMzU0LjE0NnptMTcuNS0xaC0xMmEuNS41IDAgMCAxIDAtMWgxMmEuNS41IDAgMCAxIDAgMXpNMiAyMGEuNTAyLjUwMiAwIDAgMS0uMzU0LS4xNDZsLTEuNS0xLjVhLjUuNSAwIDAgMSAuNzA3LS43MDdsMS4xNDYgMS4xNDYgNC4xNDYtNC4xNDZhLjUuNSAwIDAgMSAuNzA3LjcwN2wtNC41IDQuNWEuNDk4LjQ5OCAwIDAgMS0uMzU0LjE0NnptMTcuNS0xaC0xMmEuNS41IDAgMCAxIDAtMWgxMmEuNS41IDAgMCAxIDAgMXoiIGNsYXNzPSJ0cmlwZXR0by1maWxsIi8+PC9zdmc+",id:e.id,reference:e.reference,slot:e},!1,!0)):r.push(new t.MenuItemWithIcon(59694,o("block:calculator","Count"),(()=>i.operations.append().set({operator:l,opcode:"count",value:n.id}))))}return!0}}return!1})),E(s.slots,(e=>{"slot"===e.type&&e.id&&e.slot&&("score"!==e.reference&&"counter"!==e.reference||"score"===e.reference&&!d||"counter"===e.reference&&!b)&&(u&&(u=!1,r.length>0&&r.push(new t.MenuSeparator)),Se(r,l,i.operations,e,!0))})),r.length>0&&(c(s.block.node.section),n.push(new t.MenuSubmenuWithImage(s.icon||s.block.type.icon,s.label,r)))}else if(s.id&&s.slot){const e=[];Se(e,l,i.operations,s,!1),e.length>0&&(c(s.block.node.section),n.push(...e))}})),n},Se=(i,l,n,s,c,r=!1)=>{var u,d,b,M,h,g,m;if(s.slot instanceof a.String||s.slot instanceof a.Text){const a=e.find(s),r=z(s.block,"calculator"),p=()=>n.append().set({operator:l,opcode:"score",value:s.id,open:!0}),v=(null==a?void 0:a.sole)&&r&&!0===(null===(u=r[s.slot.reference]||r["*"])||void 0===u?void 0:u.allowDefault)||!(null==a?void 0:a.sole)&&(!r||!1!==(null===(d=r[s.slot.reference]||r["*"])||void 0===d?void 0:d.allowDefault)),N=(null==a?void 0:a.sole)&&r&&!0===(null===(b=r[s.slot.reference]||r["*"])||void 0===b?void 0:b.allowCastToNumber)||!(null==a?void 0:a.sole)&&(!r||!1!==(null===(M=r[s.slot.reference]||r["*"])||void 0===M?void 0:M.allowCastToNumber)),w=null===(h=s.slot.slots)||void 0===h?void 0:h.select("score","feature"),A=!!(a||r&&(null===(g=r[s.slot.reference]||r["*"])||void 0===g?void 0:g.scores));if((null==a?void 0:a.sole)&&!N||r&&(null===(m=r[s.slot.reference]||r["*"])||void 0===m?void 0:m.scores)&&!v&&!N)if(w){const e=[];Se(e,l,n,{type:"slot",block:s.block,label:w.alias||o("block:calculator","Existing score"),icon:s.icon||s.block.type.icon,id:w.id,reference:w.reference,slot:w},!1,!0),e.push(new t.MenuItemWithIcon(59147,o("block:calculator","New score"),(()=>n.append().set({operator:l,opcode:"score",value:s.id,open:!0})))),i.push(c?new t.MenuSubmenuWithIcon(59105,o("block:calculator","Score"),e):new t.MenuSubmenuWithImage(s.icon||s.block.type.icon,s.label,e))}else i.push(c?new t.MenuItemWithIcon(59105,s.label,p):new t.MenuItemWithImage(s.icon||s.block.type.icon,s.label,p));else{const e=[];if(A||w)if(w){const i=[];Se(i,l,n,{type:"slot",block:s.block,label:w.alias||o("block:calculator","Existing score"),icon:s.icon||s.block.type.icon,id:w.id,reference:w.reference,slot:w},!1,!0),i.push(new t.MenuItemWithIcon(59147,o("block:calculator","New score"),p)),e.push(new t.MenuSubmenuWithIcon(59105,o("block:calculator","Score"),i))}else e.push(new t.MenuItemWithIcon(59105,o("block:calculator","Score"),p));v&&e.push(new t.MenuItemWithIcon(59449,o("block:calculator","Compare"),(()=>n.append().set({operator:l,opcode:"evaluate",value:s.id,cona:0,conb:0,outa:1,outb:0,open:!0}))),new t.MenuItemWithIcon(59771,o("block:calculator","Character count"),(()=>n.append().set({operator:l,opcode:"chars",value:s.id}))),new t.MenuItemWithIcon(59771,o("block:calculator","Word count"),(()=>n.append().set({operator:l,opcode:"words",value:s.id}))),new t.MenuItemWithIcon(59771,o("block:calculator","Line count"),(()=>n.append().set({operator:l,opcode:"lines",value:s.id}))),new t.MenuItemWithIcon(59683,o("block:calculator","Count occurrences"),(()=>n.append().set({operator:l,opcode:"occurrences",value:s.id,open:!0})))),N&&e.push(new t.MenuItemWithIcon(59117,o("block:calculator","Convert to number"),(()=>n.append().set({operator:l,opcode:"cast",value:s.id})))),e.length>0&&i.push(1===e.length?e[0]:new t.MenuSubmenuWithImage(s.icon||s.block.type.icon,s.label,e))}}else if(!(s.slot instanceof a.Number||s.slot instanceof a.Numeric)||!r&&"score"===s.reference&&xe(s))if(s.slot instanceof a.Boolean){const e=()=>n.append().set({operator:l,opcode:"boolean",value:s.id,outa:1,outb:0,open:!0});i.push(c?new t.MenuItemWithIcon(59801,s.label,e):new t.MenuItemWithImage(s.icon||s.block.type.icon,s.label,e))}else s.slot instanceof a.Date&&i.push(new t.MenuSubmenuWithImage(s.icon||s.block.type.icon,s.label,[new t.MenuItemWithIcon(59449,o("block:calculator","Compare"),(()=>n.append().set({operator:l,opcode:"date",value:s.id,cona:void 0,conb:void 0,outa:1,outb:0,open:!0}))),new t.MenuItemWithIcon(59390,o("block:calculator","Age"),(()=>n.append().set({operator:l,opcode:"age",value:s.id,ageAbs:!0}))),new t.MenuSeparator,new t.MenuLabel(o("block:calculator","Date related")),new t.MenuItemWithIcon(59269,o("block:calculator","Year"),(()=>n.append().set({operator:l,opcode:"year",value:s.id}))),new t.MenuItemWithIcon(59273,o("block:calculator","Month (January = 1)"),(()=>n.append().set({operator:l,opcode:"month",value:s.id}))),new t.MenuItemWithIcon(59272,o("block:calculator","Day of month (1-31)"),(()=>n.append().set({operator:l,opcode:"day-of-month",value:s.id}))),new t.MenuItemWithIcon(59274,o("block:calculator","Day of week (Sunday = 0)"),(()=>n.append().set({operator:l,opcode:"day-of-week",value:s.id}))),...s.slot.supportsTime?[new t.MenuSeparator,new t.MenuLabel(o("block:calculator","Time related")),new t.MenuItemWithIcon(59624,o("block:calculator","Hour (0-23)"),(()=>n.append().set({operator:l,opcode:"hour",value:s.id}))),new t.MenuItemWithIcon(59624,o("block:calculator","Minute (0-59)"),(()=>n.append().set({operator:l,opcode:"minute",value:s.id}))),new t.MenuItemWithIcon(59624,o("block:calculator","Second (0-59)"),(()=>n.append().set({operator:l,opcode:"second",value:s.id}))),new t.MenuItemWithIcon(59624,o("block:calculator","Millisecond (0-999)"),(()=>n.append().set({operator:l,opcode:"millisecond",value:s.id})))]:[]]));else{const e=s.block instanceof Vt?"calculator":s.slot.reference,a=()=>[new t.MenuItemWithIcon("calculator"===e?59238:"score"===e?59105:"counter"===e?59694:59700,o("block:calculator","calculator"===e?"Calculation outcome":"score"===e?"Score value":"counter"===e?"Counter value":"Current value"),(()=>n.append().set({operator:l,opcode:"number",value:s.id}))),new t.MenuItemWithIcon(59449,o("block:calculator","Compare"),(()=>n.append().set({operator:l,opcode:"equation",value:s.id,cona:0,conb:0,outa:1,outb:0,open:!0}))),new t.MenuSeparator,new t.MenuLabel(o("block:calculator","Functions")),...Le(l,n,!1,s.id,!1)];i.push(s.block instanceof Vt||"calculator"!==s.reference&&"score"!==s.reference?new t.MenuSubmenuWithImage(s.icon||s.block.type.icon,s.label,a):new t.MenuSubmenuWithIcon("calculator"===s.reference?59238:59105,s.label,a))}},xe=t=>{var o,i;return null===(i=null===(o=t.slot)||void 0===o?void 0:o.slots)||void 0===i?void 0:i.each((o=>{var i;if(o instanceof a.String||o instanceof a.Text){const l=z(t.block,"calculator");return!!(e.find(Object.assign(Object.assign({},t),{slot:o}))||l&&(null===(i=l[o.reference]||l["*"])||void 0===i?void 0:i.scores))}return!1}))},ke=(e,t,l="value",n="form",s=!0,r=(e=>e instanceof a.Number||e instanceof a.Numeric),u)=>{const d=e[l],b=B(e.calculator.block,r,i(d)?d:void 0),M=new L.Dropdown(b,i(d)?d:"").placeholder(0===b.length?o("block:calculator","No usable values found..."):"").autoFocus(s).on((t=>{t.isFormVisible&&t.isObservable&&c(e,l,t.value||""),u&&u(t.value||"")}));return["form"===n?t.form({title:o("block:calculator","Use value of"),controls:[M]}):M.label(o("block:calculator","Use value of")),b.length,M]},fe=(e,t,i,l="angleUnits")=>{const a=e[l];return t.form({title:o("block:calculator","Units"),controls:[new L.Radiobutton([{label:o("block:calculator","Degrees")+" (°)",value:"degrees"},{label:o("block:calculator","Radians")+" (rad)",value:"radians"},{label:o("block:calculator","Gradians")+" (ᵍ)",value:"gradians"}],"radians"===a||"gradians"===a?a:"degrees").on((t=>{c(e,l,t.value||"degrees"),i&&i(t.value||"degrees")}))]})},ye=(e,t)=>e.form({title:o("block:calculator","Explanation"),controls:[new L.Static(t).markdown()]}),Te=(e,t,a=!0,s=!1,r=!0,u="value",d=!0,b=!0,M,h)=>{const g=e[u],m=M?"inline":"form";let p;const v=new L.Radiobutton([...a?[{label:e.isSubCalculation&&e.isFirst?o("block:calculator","Last outcome *(%1 parent calculation)*","ANS"):e.isFirst&&!e.calculator.startBlank?o("block:calculator","Initial value"):o("block:calculator","Last outcome *(%1)*","ANS"),value:"ans",disabled:!e.allowANS,markdown:!0}]:[],...r?[{label:o("block:calculator","Number"),value:"number"}]:[],{label:o("block:calculator","Value"),value:"variable"},...s?[{label:o("block:calculator","Constant"),value:"constant"}]:[]],i(g)?he(g)?"constant":"variable":n(g)||!a?"number":"ans").on((t=>{N[0].visible("number"===t.value),w[0].visible("variable"===t.value),A.visible("constant"===t.value),"ans"===t.value&&c(e,u,void 0),h&&h(t.value||"number","variable"===t.value&&w[2].value&&l(e.calculator.block,w[2].value)||void 0)}));"form"===m&&(p=t.form({title:o("block:calculator","Input"),controls:[v]}));const N=((e,t,i="value",l=!0,a=!0,s="form")=>{const r=e[i],u=new L.Numeric(n(r)?r:0).precision("auto").thousands(!1).autoFocus(a).on((t=>{t.isFormVisible&&t.isObservable&&c(e,i,t.value)}));return l&&(u.enter(t.close),u.escape(t.close)),"percentage"===i&&(u.suffix("%"),u.min(0)),["form"===s?t.form({title:o("block:calculator","Use fixed number"),controls:[u]}):u.label(o("block:calculator","Use fixed number")),u]})(e,t,u,d,b,m),w=ke(e,t,u,m,b,void 0,h&&(t=>{h(v.value||"number","variable"===v.value&&t&&l(e.calculator.block,t)||void 0)})),A=((e,t,i="value",l="form",a=!0)=>{const n=new L.Dropdown(Me.map((e=>({label:ge(e),value:e}))),U(e[i])).autoFocus(a).on((t=>{var o;t.isFormVisible&&t.isObservable&&c(e,i,"string"==typeof(o=t.value)&&he(o)?o:"π")}));return"inline"===l?n.label(o("block:calculator","Use constant")):t.form({title:o("block:calculator","Use constant"),controls:[n]})})(e,t,u,m,b).visible(he(U(g)));return N[0].visible(n(g)||!a&&!i(g)),w[0].visible(i(g)),v.buttonDisabled("variable",0===w[1]),N[0]instanceof L.Control&&w[0]instanceof L.Control&&A instanceof L.Control&&(p=t.form({title:M,markdown:!0,controls:[v,N[0],w[0],A]})),[p,N[1]]},Ce=ke,ze={name:e=>e.format("value","|","|"),title:()=>o("block:calculator","Absolute value"),editor:(e,t)=>{ye(t,o("block:calculator","Retrieves the absolute value (or modulus) of a number ([learn more](https://en.wikipedia.org/wiki/Absolute_value)). This makes negative numbers positive.")),Te(e,t,!0,!1,!1)}},Ee={name:e=>e.format("value","*cosh⁻¹* (",")"),title:()=>o("block:calculator","Inverse hyperbolic cosine"),editor:(e,t)=>{ye(t,o("block:calculator","Calculates the inverse hyperbolic cosine (arccosine) of the given number ([learn more](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions)).")),Te(e,t)}},Ue={name:e=>e.format("value","*cos⁻¹* (",") "+("radians"===e.angleUnits?"rad":"gradians"===e.angleUnits?"ᵍ":"°")),title:()=>o("block:calculator","Inverse cosine (arccosine)"),editor:(e,t)=>{ye(t,o("block:calculator","Calculates the inverse cosine (arccosine) of the given number ([learn more](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions)). This number should be a value between `-1` and `1`.")),Te(e,t)[1].min(-1).max(1),fe(e,t)}};function Oe(e="years"){switch(e){case"months":return o("block:calculator","Months");case"days":return o("block:calculator","Days");case"hours":return o("block:calculator","Hours");case"minutes":return o("block:calculator","Minutes");case"seconds":return o("block:calculator","Seconds");case"milliseconds":return o("block:calculator","Milliseconds");default:return o("block:calculator","Years")}}const Ye={name:e=>e.format("value",`*${o("block:calculator","age")}* (`,") "+Oe(e.ageIn).toLowerCase()),title:e=>{var t;return i(e.value)&&(null===(t=l(e.calculator.block,e.value))||void 0===t?void 0:t.label)||o("block:calculator","Age")},editor:(e,t)=>{const s=i(e.value)&&l(e.calculator.block,e.value),c=s&&s.slot instanceof a.Date&&s.slot.supportsTime||!1,r=new L.Radiobutton([{label:o("block:calculator","Current date"),value:"current"},{label:o("block:calculator","Fixed date"),value:"date"},{label:o("block:calculator","Value"),value:"variable"}],i(e.reference)?"variable":n(e.reference)?"date":"current").on((t=>{u.visible("date"===t.value),d[0].visible("variable"===t.value),"current"===t.value&&(e.reference=void 0)}));ye(t,o("block:calculator","Calculates the age (time) between two points in time.")),t.form({title:o("block:calculator","Calculate age using"),controls:[r]});const u=t.form({title:o("block:calculator","Use fixed date"),controls:[new L.DateTime(n(e.reference)?e.reference:j.UTC).zone("UTC").years((new Date).getFullYear()-150,(new Date).getFullYear()+50).features(1|(c?8:32)).required().on((t=>{t.isFormVisible&&t.isObservable&&(e.reference=t.value)}))]}),d=Ce(e,t,"reference","form",!0,(t=>t instanceof a.Date&&t.id!==e.value));r.buttonDisabled("variable",0===d[1]),t.form({title:o("block:calculator","Units"),controls:[new L.Radiobutton(["years","months","days","hours","minutes","seconds","milliseconds"].map((e=>({label:Oe(e),value:e}))),L.Radiobutton.bind(e,"ageIn",void 0,"years"))]}),t.form({title:o("block:calculator","Options"),controls:[new L.Checkbox(o("block:calculator","Always return a positive (absolute) value"),L.Checkbox.bind(e,"ageAbs",void 0)).description(o("block:calculator","If unchecked, a negative value is possible, which indicates that the source date is after the date that serves as compare date for the calculation."))]})}},Pe={name:e=>e.format("value","*sinh⁻¹* (",")"),title:()=>o("block:calculator","Inverse hyperbolic sine"),editor:(e,t)=>{ye(t,o("block:calculator","Calculates the inverse hyperbolic sine (arcsine) of the given number ([learn more](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions)).")),Te(e,t)}},Ze={name:e=>e.format("value","*sin⁻¹* (",") "+("radians"===e.angleUnits?"rad":"gradians"===e.angleUnits?"ᵍ":"°")),title:()=>o("block:calculator","Inverse sine (arcsine)"),editor:(e,t)=>{ye(t,o("block:calculator","Calculates the inverse sine (arcsine) of the given number ([learn more](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions)). This number should be a value between `-1` and `1`.")),Te(e,t)[1].min(-1).max(1),fe(e,t)}},Ve={name:e=>e.format("value","*tanh⁻¹* (",")"),title:()=>o("block:calculator","Inverse hyperbolic tangent"),editor:(e,t)=>{ye(t,o("block:calculator","Calculates the inverse hyperbolic tangent (arctangent) of the given number ([learn more](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions)).")),Te(e,t)}},Re={name:e=>e.format("value","*tan⁻¹* (",") "+("radians"===e.angleUnits?"rad":"gradians"===e.angleUnits?"ᵍ":"°")),title:()=>o("block:calculator","Inverse tangent (arctangent)"),editor:(e,t)=>{ye(t,o("block:calculator","Calculates the inverse tangent (arctangent) of the given number ([learn more](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions)).")),Te(e,t),fe(e,t)}},We={name:e=>{const t=e.format("value",void 0,void 0,void 0,!0),n=e.format("outa",void 0,void 0,void 0,!0),s=e.format("outb",void 0,void 0,void 0,!0);if(!t||!n||!s)return"";const c=i(e.value)&&l(e.calculator.block,e.value)||void 0;return t+" = "+o("block:calculator","%1 then %2 else %3",`**${(null==c?void 0:c.slot)instanceof a.Boolean&&S(c.slot.labelForTrue||"")||o("block:calculator","True")}**`,n,s)},title:e=>{var t;return i(e.value)&&(null===(t=l(e.calculator.block,e.value))||void 0===t?void 0:t.label)||o("block:calculator","Boolean")},editor:(e,t)=>{const n=i(e.value)&&l(e.calculator.block,e.value)||void 0;ye(t,o("block:calculator","Outputs a value based on the boolean state.")),Te(e,t,!0,!0,!0,"outa",!1,!1,o("block:calculator","If %1 then output",`**${(null==n?void 0:n.slot)instanceof a.Boolean&&S(n.slot.labelForTrue||"")||o("block:calculator","True")}**`)),Te(e,t,!0,!0,!0,"outb",!1,!1,o("block:calculator","If %1 then output",`**${(null==n?void 0:n.slot)instanceof a.Boolean&&S(n.slot.labelForFalse||"")||o("block:calculator","False")}**`))}},Ge=(e,i=o("block:calculator","Initial value is the last outcome (ANS)."),l)=>({collection:e.operations,banner:l,title:o("block:calculator","Operations"),icon:!0,allowAutoSorting:!1,allowCleanup:o("block:calculator","Remove invalid operations"),placeholder:o("block:calculator","Invalid operation"),allowVariables:!0,allowFormatting:!0,markdown:x.MarkdownFeatures.Formatting|x.MarkdownFeatures.InlineCode,showAliases:t=>{var o;return null===(o=e.block.slots.select(t.id,"dynamic"))||void 0===o?void 0:o.alias},onReposition:e=>e.refresh("name"),onResize:e instanceof Yt&&(()=>e.refresh("name"))||void 0,menu:()=>((e,i=!1)=>e.startBlank&&0===e.operations.count&&!i?Ae(e,!1)("+"):[new t.MenuSubmenuWithImage(pe,o("block:calculator","Add"),(()=>Ae(e,i)("+"))),new t.MenuSubmenuWithImage(ve,o("block:calculator","Subtract"),(()=>Ae(e,i)("-"))),new t.MenuSubmenuWithImage(Ne,o("block:calculator","Multiply"),(()=>Ae(e,i)("*"))),new t.MenuSubmenuWithImage(we,o("block:calculator","Divide"),(()=>Ae(e,i)("/"))),new t.MenuSeparator,new t.MenuSubmenuWithImage(me,o("block:calculator","Equal"),(()=>Ae(e,i)("=")))])(e,e instanceof Yt),emptyMessage:{message:e instanceof Yt||!e.startBlank?"**"+i+"**\n\n"+o("block:calculator","Click the + button to add an operation.")+"\n\n"+o("block:calculator","Use **=** operation to set another initial value."):"**"+o("block:calculator","Every calculation begins with an initial value.")+"**\n\n"+o("block:calculator","Click the + button to specify that value.")+"\n\n"+o("block:calculator","After that you can add more operations."),height:96}}),Fe={name:e=>`${S(e.description||"")||o("block:calculator","Calculation")} *(${k("block:calculator","%1 operation","%1 operations",e.operations.count)})*`,title:e=>e.description||o("block:calculator","Subcalculation"),editor:(e,t)=>{var i,l,n,s;ye(t,o("block:calculator","Performs a subcalculation. The initial value for this subcalculation is automatically set to the current outcome (**ANS**) of the parent calculation. If you want to begin this subcalculation with another value, then add an equal (**=**) operation to begin with.")),t.collection(Ge(e)),t.form({title:o("block:calculator","Description"),controls:[new L.Text("singleline",L.Text.bind(e,"description",void 0)).autoFocus(0===e.operations.count).on((t=>{e.outcome&&(e.outcome.label=t.value),d.visible(!!(t.value&&e.block instanceof Vt))}))]});const c=new L.Checkbox(o("block:calculator","Set an alias for this subcalculation"),!!(null===(i=e.outcome)||void 0===i?void 0:i.alias)).on((e=>r.visible(e.isChecked))),r=new L.Group([new L.Text("singleline",(null===(l=e.outcome)||void 0===l?void 0:l.alias)||"").placeholder(o("block:calculator","Type alias identifier here...")).indent(32).on((t=>{if(e.outcome){const o=e.outcome.alias;e.outcome.alias=t.isObservable&&t.value||void 0,e.outcome.alias!==o&&e.refresh("name")}})),new L.Static(o("block:calculator","This alias will be used as identifier of the subcalculation in the dataset.")).indent(32)]).visible(!!(null===(n=e.outcome)||void 0===n?void 0:n.alias)),u=new L.Group([new L.Checkbox(o("block:calculator","Make outcome exportable and include it in the dataset"),(null===(s=e.outcome)||void 0===s?void 0:s.exportable)||!1).on((t=>{e.outcome&&(e.outcome.exportable=t.isChecked)})),c]).visible(!!e.outcome),d=t.form({title:o("block:calculator","Exportability"),controls:[new L.Checkbox(o("block:calculator","Make outcome available for other blocks"),!!e.outcome).on((t=>{if(t.isFormVisible&&t.isObservable&&t.isChecked&&e.description&&e.block instanceof Vt){const t=e.calculator.block.slots.dynamic({type:a.Numeric,reference:e.id,label:e.description,exportable:!1});e.calculator.outcome&&(t.decimal=e.calculator.outcome.decimal,t.precision=e.calculator.outcome.precision,t.digits=e.calculator.outcome.digits,t.separator=e.calculator.outcome.separator,t.minimum=e.calculator.outcome.minimum,t.maximum=e.calculator.outcome.maximum,t.prefix=e.calculator.outcome.prefix,t.prefixPlural=e.calculator.outcome.prefixPlural,t.suffix=e.calculator.outcome.suffix,t.suffixPlural=e.calculator.outcome.suffixPlural)}else e.calculator.block.slots.delete(e.id,"dynamic");u.visible(t.isChecked),r.visible(t.isChecked&&c.isChecked),e.refresh("name")})),u,r]}).visible(!!(e.description&&e.block instanceof Vt))}},Qe={name:e=>e.format("value",`*${o("block:calculator","convert")}* (`,`) *${o("block:calculator","to number")}*`),title:()=>o("block:calculator","Convert to number"),editor:(e,t)=>{ye(t,o("block:calculator","Converts a text value to a number."))}},Be={name:e=>e.format("value","⌈","⌉"),title:()=>o("block:calculator","Ceil"),editor:(e,t)=>{ye(t,o("block:calculator","Rounds a floating point number up ([learn more](https://en.wikipedia.org/wiki/Floor_and_ceiling_functions)).")),Te(e,t,!0,!0)}},He={name:e=>e.format("value",`*${o("block:calculator","characters")}* (`,")"),title:()=>o("block:calculator","Character count"),editor:(e,t)=>{ye(t,o("block:calculator","Counts the number of characters in a text."))}},qe={name:e=>{const t=e.format("value","*clamp* (",",",!0),o=e.format("min"," ",",",!0),i=e.format("max"," ",")");return t&&o&&i?t+o+i:""},title:()=>o("block:calculator","Clamp number"),editor:(e,t)=>{ye(t,o("block:calculator","Clamps (restricts) the input between the specified minimum and maximum value ([learn more](https://en.wikipedia.org/wiki/Clamping_%28graphics%29)).")),Te(e,t,!0,!0,!1,"value",!1,!0,o("block:calculator","Input")),Te(e,t,!0,!0,!0,"min",!1,!1,o("block:calculator","Minimum value")),Te(e,t,!0,!0,!0,"max",!1,!1,o("block:calculator","Maximum value"))}},$e={name:e=>e.format("value","*cosh* (",")"),title:()=>o("block:calculator","Hyperbolic cosine"),editor:(e,t)=>{ye(t,o("block:calculator","Calculates the hyperbolic cosine of the given hyperbolic angle ([learn more](https://en.wikipedia.org/wiki/Hyperbolic_functions)).")),Te(e,t)}},Xe={name:e=>e.format("value","*cos* (",("radians"===e.angleUnits?"rad":"gradians"===e.angleUnits?"ᵍ":"°")+" )","radians"!==e.angleUnits),title:()=>o("block:calculator","Cosine"),editor:(e,t)=>{ye(t,o("block:calculator","Calculates the cosine of the given angle ([learn more](https://en.wikipedia.org/wiki/Trigonometric_functions)). The result is a number between `-1` and `1`."));const[,i]=Te(e,t);fe(e,t,(e=>i.suffix("radians"===e?" rad":"gradians"===e?"ᵍ":"°")))}},Je={name:e=>e.format("value",`*${o("block:calculator","count")}* (`,")"),title:e=>{var t;return(i(e.value)?null===(t=l(e.calculator.block,e.value))||void 0===t?void 0:t.label:"")||o("block:calculator","Count")},editor:(e,t)=>{ye(t,o("block:calculator","Counts the number of selected options or given answers. Useful if you want to calculate the average of given answers."))}};function _e(e,t){var c;const r=e[t],u=i(e.value)&&l(e.calculator.block,e.value),d=u&&u.slot instanceof a.Date&&u.slot||void 0;return i(r)?r&&(null===(c=l(e.calculator.block,r))||void 0===c?void 0:c.label)?`@${r}`:"":n(r)?`**${(d?d.supportsTime:"datetime"===e.opcode)?s.locale.dateTimeShort(r,!0):s.locale.dateShort(r,!0)}**`:"`"+o("block:calculator","Now").toUpperCase()+"`"}const Ke={name:e=>{const t=e.format("value",void 0,void 0,void 0,!0,"NOW"),i=_e(e,"cona"),l=_e(e,"conb"),a=e.format("outa",void 0,void 0,void 0,!0),n=e.format("outb",void 0,void 0,void 0,!0);if(!t||!a||!n)return"";const s=`then ${a} else ${n}`;switch(e.compareMode||"equal"){case"defined":return`${t} ${o("block:calculator","not empty")} ${s}`;case"between":return i&&l&&`${i} ≤ ${t} ≤ ${l} ${s}`||"";case"before":case"after":case"equal":return i&&`${t} ${"after"===e.compareMode?">":"before"===e.compareMode?"<":"="} ${i} ${s}`||""}},title:e=>{var t;return(i(e.value)?null===(t=l(e.calculator.block,e.value))||void 0===t?void 0:t.label:"")||("datetime"===e.opcode?o("block:calculator","Current date + time"):o("block:calculator","Current date"))},editor:(e,t)=>{const s=i(e.value)&&l(e.calculator.block,e.value),c=s&&s.slot instanceof a.Date&&s.slot||void 0,r=c?c.supportsTime:"datetime"===e.opcode,u=new L.Radiobutton([{label:o("block:calculator","Date is equal to"),value:"equal"},{label:o("block:calculator","Date is before"),value:"before"},{label:o("block:calculator","Date is after"),value:"after"},{label:o("block:calculator","Date is between"),value:"between"},{label:o("block:calculator","Date is not empty"),value:"defined",visible:!!c}],e.compareMode||"equal").on((t=>{switch(e.compareMode=t.value||"equal",b.visible("defined"!==e.compareMode),M.visible("between"===t.value),e.compareMode){case"equal":b.title=o("block:calculator","If date equals");break;case"before":b.title=o("block:calculator","If date is before");break;case"after":b.title=o("block:calculator","If date is after");break;case"between":b.title=o("block:calculator","If date is between")}}));ye(t,o("block:calculator","Compares a date and outputs a value based on the result of the comparison.")),t.form({title:o("block:calculator","Compare mode"),controls:[u]});const d=(l,c,u)=>{const d=e[l],b=new L.DateTime(n(d)?d:void 0).zone("UTC").years((new Date).getFullYear()-150,(new Date).getFullYear()+50).label(o("block:calculator",r?"Use fixed date/time":"Use fixed date")).features(1|(r?8:32)).required().on((t=>{t.isFormVisible&&t.isObservable&&(e[l]=t.value)})),M=Ce(e,t,l,"inline",!1,(t=>t instanceof a.Date&&t.id!==e.value));return t.form({title:c,controls:[new L.Radiobutton([{label:o("block:calculator","Current date"),value:"current",visible:!!s},{label:o("block:calculator",r?"Fixed date/time":"Fixed date"),value:"date"},{label:o("block:calculator","Value"),value:"variable",disabled:0===M[1]}],i(d)?"variable":n(d)?"date":"current").on((t=>{b.visible("date"===t.value),M[0].visible("variable"===t.value),"current"===t.value&&(e[l]=void 0)})),b,M[0]]}).visible(u)},b=d("cona",o("block:calculator","If date equals"),"defined"!==e.compareMode),M=d("conb",o("block:calculator","And"),"between"===e.compareMode);Te(e,t,!0,!0,!0,"outa",!1,!1,o("block:calculator","Then output")),Te(e,t,!0,!0,!0,"outb",!1,!1,o("block:calculator","Else output"))}},et={name:e=>e.format("value",`*${o("block:calculator","day of month")}* (`,")"),title:e=>{var t;return(i(e.value)?null===(t=l(e.calculator.block,e.value))||void 0===t?void 0:t.label:"")||o("block:calculator","Day of month")},editor:(e,t)=>{ye(t,o("block:calculator","Retrieves the day of month of the date."))}},tt={name:e=>e.format("value",`*${o("block:calculator","day of week")}* (`,")"),title:e=>{var t;return(i(e.value)?null===(t=l(e.calculator.block,e.value))||void 0===t?void 0:t.label:"")||o("block:calculator","Day of week")},editor:(e,t)=>{ye(t,o("block:calculator","Retrieves the day of the week (where 0 represents Sunday) of the date."))}},ot={name:e=>{const t=e.format("value",void 0,void 0,void 0,!0),i=e.format("cona",void 0,void 0,void 0,!0),l=e.format("conb",void 0,void 0,void 0,!0),a=e.format("outa",void 0,void 0,void 0,!0),n=e.format("outb",void 0,void 0,void 0,!0);if(!t||!a||!n)return"";const s=`then ${a} else ${n}`;switch(e.compareMode||"equal"){case"defined":return`${t} ${o("block:calculator","not empty")} ${s}`;case"between":return i&&l&&`${i} ≤ ${t} ≤ ${l} ${s}`||"";case"above":case"below":case"equal":return i&&`${t} ${"above"===e.compareMode?">":"below"===e.compareMode?"<":"="} ${i} ${s}`||""}},title:()=>o("block:calculator","Compare"),editor:(e,t)=>{const l=new L.Radiobutton([{label:o("block:calculator","Input is equal to"),value:"equal"},{label:o("block:calculator","Input is lower than"),value:"below"},{label:o("block:calculator","Input is higher than"),value:"above"},{label:o("block:calculator","Input is between"),value:"between"},{label:o("block:calculator","Input is not empty"),value:"defined",visible:(n=e.value,i(n)&&!he(n))}],e.compareMode||"equal").on((t=>{switch(e.compareMode=t.value||"equal",s.visible("defined"!==e.compareMode),r.visible("between"===t.value),e.compareMode){case"equal":s.title=o("block:calculator","If input equals");break;case"below":s.title=o("block:calculator","If input is lower than");break;case"above":s.title=o("block:calculator","If input is higher than");break;case"between":s.title=o("block:calculator","If input is between")}}));var n;ye(t,o("block:calculator","Compares the supplied input and outputs a value based on the result of the comparison.")),Te(e,t,!0,!1,!1,"value",!1,!0,o("block:calculator","Input"),((e,t)=>{if(l.buttonVisible("defined","variable"===e),c&&u){const e=e=>{e.precision((null==t?void 0:t.slot)instanceof a.Numeric?t.slot.precision||0:"auto"),e.digits((null==t?void 0:t.slot)instanceof a.Numeric&&t.slot.digits||0),e.decimalSign((null==t?void 0:t.slot)instanceof a.Numeric&&t.slot.decimal||""),e.thousands(!!((null==t?void 0:t.slot)instanceof a.Numeric&&t.slot.separator),(null==t?void 0:t.slot)instanceof a.Numeric&&t.slot.separator||""),e.min((null==t?void 0:t.slot)instanceof a.Numeric&&t.slot.minimum||void 0),e.max((null==t?void 0:t.slot)instanceof a.Numeric&&t.slot.maximum||void 0),e.prefix((null==t?void 0:t.slot)instanceof a.Numeric&&t.slot.prefix||""),e.prefixPlural((null==t?void 0:t.slot)instanceof a.Numeric&&t.slot.prefixPlural||void 0),e.suffix((null==t?void 0:t.slot)instanceof a.Numeric&&t.slot.suffix||""),e.suffixPlural((null==t?void 0:t.slot)instanceof a.Numeric&&t.slot.suffixPlural||void 0)};e(c),e(u)}})),t.form({title:o("block:calculator","Compare mode"),controls:[l]});const[s,c]=Te(e,t,!0,!0,!0,"cona",!1,!1,o("block:calculator","If input equals")),[r,u]=Te(e,t,!0,!0,!0,"conb",!1,!1,o("block:calculator","And"));s.visible("defined"!==e.compareMode),r.visible("between"===e.compareMode),Te(e,t,!0,!0,!0,"outa",!1,!1,o("block:calculator","Then output")),Te(e,t,!0,!0,!0,"outb",!1,!1,o("block:calculator","Else output"))}},it={name:e=>{const t=e.format("value",void 0,void 0,void 0,!0),i=e.format(