maze-blockly-wrapper 0.2.1 → 0.2.2

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/dist/index.cjs.js CHANGED
@@ -1,15 +1,15 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const de=require("react"),Mr=require("react-dom");function iT(a){const h=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const r in a)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(a,r);Object.defineProperty(h,r,l.get?l:{enumerable:!0,get:()=>a[r]})}}return h.default=a,Object.freeze(h)}const fe=iT(de);var jf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Di(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Ll={exports:{}},rT=Ll.exports,Kf;function sd(){return Kf||(Kf=1,(function(a,h){(function(r,l){a.exports=l()})(rT,function(){var r={},l,g,m,y,k,A,D,H,W,X,ue,ie,K,ee,me,z,ae,te,Y,Ie,Ye,It,Re,rt,bt,Bt,Ct,nt,Tt,lt,$t,St,Ue,_,F,Q,ne,le,he,J,$e,ce,_e,U,Xe,v,G,Lt,Te,qo,ke,Qt,Mo,eo,to,ot,ms,ho,E,oo,Do,He,ct,kt,st,Ut,c,p,I,C,V,Ae,so,$o,io,u,$,b,S,x,q,pe,Rt,fs,zs,Mt,Zo,Yl,Xl,jl,Kl,xi,Br,Jl,ql,Zl,Ys,pd,Xs,gd,Pr,md,Bi,Fr,fd,Ur,_d,Hr,Ql,ec,Gr,Vr,Wr,Pi,bd,js,Fi,zr,Td,Ed,yd,po,it,Ui,tc,go,Qo,vd,oc,Yr,sc,Id,ic,Hi,Cd,Xr,Sd,jr,kd,Rd,wd,Ks,Od,rc,pt,Kr,nc,Jr,qr,Nd,lc,cc,Ad,Zr,_s,Qr,Ld,uc,ac,Md,Dd,bs,xd,Gi,Js,qs,jt,Bd,Pd,Fd,Ud,Hd,Gd,Vd,hc,es,Zs,dc,Wd,zd,Yd,Xd,jd,Kd,Jd,qd,Zd,$c,Qd,Ts,en,e$,Qs,tn,pc,gc,on,sn,mc,t$,fc,_c,bc,Tc,Ec,yc,vc,o$,Vi,Ic,rn,nn,mo,Cc,Sc,Wi,kc,Rc,s$,ln,wc,i$,r$,n$,l$,c$,ei,Oc,Nc,zi,Ac,u$,a$,Lc,Mc,xo,Dc,xc,h$,d$,$$,p$,Bc,g$,Pc,m$,Es,Yi,cn,un,ys,Fc,an,Uc,Je,f$,ti,oi,_$,Hc,hn,si,Gc,vs,Xi,Vc,Wc,b$,T$,E$,zc,y$,Yc,ii,v$,I$,C$,S$,ji,Xc,jc,dn,$n,k$,Ki,Kc,Ji,R$,w$,ts,Jc,fo,O$,N$,qc,A$,Is,Zc,L$,M$,D$,x$,B$,Qc,P$,F$,pn,U$,H$,eu,_o,G$,V$,ri,W$,tu,gn,z$,Y$,X$,ou,mn,su,fn,j$,K$,J$,q$,se,Pt,gt,je,bo,ni,re,qe,Z$,Q$,ep,iu,tp,_n,ru,nu,lu,cu,li,op,sp,ip,ci,uu,rp,bn,Kt,au,ui,ro,ai,hu,du,np,os,Tn,qi,$u,lp,pu,cp,En,gu,mu,fu,up,_u,ap,yn,hp,dp,Zi,$p,bu,vn,In,Cn,Sn,Tu,pp,Eu,kn,Rn,gp,wn,mp,yu,fp,ss,vu,Qi,Iu,Cu,On,Su,ku,Ru,wu,Ou,Nu,Au,Lu,Mu,_p,bp,Tp,Ep,yp,vp,Ip,Cp,Du,xu,Bu,Pu,Fu,Uu,Hu,Nn,er,Gu,Sp,Vu,Wu,zu,Yu,Xu,ju,Ku,Ju,qu,Zu,kp,Rp,wp,Qu,Op,Np,Ap,Lp,N;l=function(e,t,o,s){if(!(e instanceof M)&&typeof e!="string"||`${e}`.trim()==="")throw Error('Invalid type "'+e+'". The type must be a non-empty string or a Blockly.registry.Type.');if(e=`${e}`.toLowerCase(),typeof t!="string"||t.trim()==="")throw Error('Invalid name "'+t+'". The name must be a non-empty string.');const i=t.toLowerCase();if(!o)throw Error("Can not register a null value");let n=is[e],d=An[e];if(n||(n=is[e]=Object.create(null),d=An[e]=Object.create(null)),g(e,o),!s&&n[i]&&n[i]!==o)throw Error('Name "'+i+'" with type "'+e+'" already registered.');n[i]=o,d[i]=t},g=function(e,t){switch(e){case String(M.FIELD):if(typeof t.fromJson!="function")throw Error('Type "'+e+'" must have a fromJson function')}},m=function(e,t){e=`${e}`.toLowerCase(),t=t.toLowerCase();const o=is[e];o&&o[t]?(delete is[e][t],delete An[e][t]):console.warn("Unable to unregister ["+t+"]["+e+"] from the registry.")},y=function(e,t,o){e=`${e}`.toLowerCase(),t=t.toLowerCase();const s=is[e];if(!s||!s[t]){if(t="Unable to find ["+t+"]["+e+"] in the registry.",o)throw Error(t+" You must require or register a "+e+" plugin.");return console.warn(t),null}return s[t]},k=function(e,t){return e=`${e}`.toLowerCase(),t=t.toLowerCase(),(e=is[e])?!!e[t]:!1},A=function(e,t,o){return y(e,t,o)},D=function(e,t,o){return y(e,t,o)},H=function(e,t,o){e=`${e}`.toLowerCase();var s=is[e];if(!s){if(s=`Unable to find [${e}] in the registry.`,o)throw Error(`${s} You must require or register a ${e} plugin.`);return console.warn(s),null}if(!t)return s;e=An[e],o=Object.create(null);for(const i of Object.keys(s))o[e[i]]=s[i];return o},W=function(e,t,o){return t=t.plugins[String(e)]||Ft,typeof t=="function"?t:A(e,t,o)},X=function(e,t){ue(),Mn=setTimeout(function(){t&&t.handleRightClick(e)},ab)},ue=function(){Mn&&(clearTimeout(Mn),Mn=0)},ie=function(){Ln=null},K=function(e){return!e.type.startsWith("pointer")||e instanceof PointerEvent&&me(e)},ee=function(e){return`${e.pointerId}`},me=function(e){const t=ee(e);return Ln?Ln===t:e.type==="pointerdown"?(Ln=t,!0):!1},z=function(e,t,o,s,i){function n(f){(i||K(f))&&(o?s.call(o,f):s(f))}const d=[];if(t in Cs)for(let f=0;f<Cs[t].length;f++){const L=Cs[t][f];e.addEventListener(L,n,!1),d.push([e,L,n])}else e.addEventListener(t,n,!1),d.push([e,t,n]);return d},ae=function(e,t,o,s){function i(d){o?s.call(o,d):s(d)}const n=[];if(t in Cs)for(let d=0;d<Cs[t].length;d++){const f=Cs[t][d];e.addEventListener(f,i,!1),n.push([e,f,i])}else e.addEventListener(t,i,!1),n.push([e,t,i]);return n},te=function(e){const t=e[e.length-1][2];for(;e.length;){const[o,s,i]=e.pop();o.removeEventListener(s,i,!1)}return t},Y=function(e){if(e.target instanceof HTMLElement){if(e.target.isContentEditable||e.target.getAttribute("data-is-text-input")==="true")return!0;if(e.target instanceof HTMLInputElement)return e=e.target,e.type==="text"||e.type==="number"||e.type==="email"||e.type==="password"||e.type==="search"||e.type==="tel"||e.type==="url";if(e.target instanceof HTMLTextAreaElement)return!0}return!1},Ie=function(e){return e.ctrlKey&&sa?!0:e.button===2},Ye=function(e,t,o){const s=t.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,o||(o=t.getScreenCTM().inverse()),s.matrixTransform(o)},It=function(e){switch(e.deltaMode){default:return{x:e.deltaX,y:e.deltaY};case 1:return{x:e.deltaX*zp,y:e.deltaY*zp};case 2:return{x:e.deltaX*Yp,y:e.deltaY*Yp}}},Re=function(){return"blockly-"+($b++).toString(36)},rt=function(){return Kp.genUid()},bt=function(e){return e.type===w.BLOCK_CREATE},Bt=function(e){return e.type===w.BLOCK_DELETE},Ct=function(e){return e.type===w.BLOCK_CHANGE},nt=function(e){return e.type===w.BLOCK_FIELD_INTERMEDIATE_CHANGE},Tt=function(e){return e.type===w.BLOCK_MOVE},lt=function(e){return e.type===w.CLICK},$t=function(e){return e.type===w.BUBBLE_OPEN},St=function(e){return e.type===w.VIEWPORT_CHANGE},r.setRecordUndo$$module$build$src$core$events$utils=function(e){tr=e},Ue=function(){return tr},_=function(e){qp.fireInternal(e)},F=function(e){if(J()){if(!Fo.length)try{requestAnimationFrame(()=>{setTimeout(Q,0)})}catch{setTimeout(Q,0)}ne(e)}},Q=function(){const e=le(Fo);Fo.length=0;for(const t of e){if(!t.workspaceId)continue;let o;(o=ct(t.workspaceId))==null||o.fireChangeListener(t)}},ne=function(e){if(Ct(e)&&e.element==="mutation"){let t;for(t=Fo.length;t>0;t--){const o=Fo[t-1];if(o.group!==e.group||o.workspaceId!==e.workspaceId||!Tt(o)||o.newParentId!==e.blockId)break}Fo.splice(t,0,e)}else Fo.push(e)},le=function(e){const t=[];for(const o of e)if(e=t[t.length-1],!o.isNull())if(e&&e.workspaceId===o.workspaceId&&e.group===o.group)if(Tt(o)&&Tt(e)&&o.blockId===e.blockId){if(e.newParentId=o.newParentId,e.newInputName=o.newInputName,e.newCoordinate=o.newCoordinate,e.reason||o.reason){let s,i;e.reason=Array.from(new Set(((s=e.reason)!=null?s:[]).concat((i=o.reason)!=null?i:[])))}}else Ct(o)&&Ct(e)&&o.blockId===e.blockId&&o.element===e.element&&o.name===e.name?e.newValue=o.newValue:St(o)&&St(e)?(e.viewTop=o.viewTop,e.viewLeft=o.viewLeft,e.scale=o.scale,e.oldScale=o.oldScale):lt(o)&&$t(e)||t.push(o);else t.push(o);return e=t.filter(o=>!o.isNull())},he=function(){for(let e=0,t;t=Fo[e];e++)t.recordUndo=!1},r.disable$$module$build$src$core$events$utils=function(){ra++},r.enable$$module$build$src$core$events$utils=function(){ra--},J=function(){return ra===0},r.getGroup$$module$build$src$core$events$utils=function(){return Jp},r.setGroup$$module$build$src$core$events$utils=function(e){qp.setGroupInternal(e)},$e=function(e){Jp=typeof e=="boolean"?e?rt():"":e},ce=function(e){const t=[];e=e.getDescendants(!1);for(let o=0,s;s=e[o];o++)t[o]=s.id;return t},_e=function(e,t){const o=U(e.type);if(!o)throw Error("Unknown event type.");return o.fromJson(e,t)},U=function(e){const t=A(M.EVENT,e);if(!t)throw Error(`Event type ${e} not found in registry.`);return t},Xe=function(e){if((Tt(e)||bt(e))&&e.workspaceId){var t=ct(e.workspaceId);if(!e.blockId)throw Error("Encountered a blockEvent without a proper blockId");if(e=t.getBlockById(e.blockId)){const o=tr;try{tr=!1;const s=e.getParent();if(s&&!s.hasDisabledReason(na)){const i=e.getDescendants(!1);for(let n=0,d;d=i[n];n++)d.setDisabledReason(!1,na)}else if((e.outputConnection||e.previousConnection)&&!t.isDragging())do e.setDisabledReason(!0,na),e=e.getNextBlock();while(e)}finally{tr=o}}}},v=function(e,t,o){e=document.createElementNS(or,`${e}`);for(const s in t)e.setAttribute(s,`${t[s]}`);return o&&o.appendChild(e),e},G=function(e,t){return t=t.split(" "),t.every(o=>e.classList.contains(o))?!1:(e.classList.add(...t),!0)},Lt=function(e,t){e.classList.remove(...t.split(" "))},Te=function(e,t){return t=t.split(" "),t.every(o=>!e.classList.contains(o))?!1:(e.classList.remove(...t),!0)},qo=function(e,t){return e.classList.contains(t)},ke=function(e){return e&&e.parentNode?e.parentNode.removeChild(e):null},Qt=function(e,t){const o=t.nextSibling;if(t=t.parentNode,!t)throw Error("Reference node has no parent.");o?t.insertBefore(e,o):t.appendChild(e)},Mo=function(e,t){e.style.transform=t,e.style["-webkit-transform"]=t},eo=function(){la++,no||(no=Object.create(null))},to=function(){la--,la||(no=null)},ot=function(e){const t=e.textContent+`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const de=require("react"),Dr=require("react-dom");function lT(h){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const r in h)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(h,r);Object.defineProperty(a,r,l.get?l:{enumerable:!0,get:()=>h[r]})}}return a.default=h,Object.freeze(a)}const fe=lT(de);var qf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xi(h){return h&&h.__esModule&&Object.prototype.hasOwnProperty.call(h,"default")?h.default:h}var Ml={exports:{}},cT=Ml.exports,Zf;function nd(){return Zf||(Zf=1,(function(h,a){(function(r,l){h.exports=l()})(cT,function(){var r={},l,g,m,y,k,A,D,H,W,X,ue,ie,K,ee,me,z,ae,te,Y,Ie,Ye,It,Re,rt,bt,Bt,Ct,nt,Tt,lt,$t,St,Ue,_,F,Q,ne,le,he,J,$e,ce,_e,U,Xe,v,G,Lt,Te,qo,ke,Qt,Mo,eo,to,ot,ms,ho,E,oo,Do,He,ct,kt,st,Ut,c,p,I,C,V,Ae,so,$o,io,u,$,b,S,x,q,pe,Rt,fs,zs,Mt,Zo,jl,Kl,Jl,ql,Bi,Pr,Zl,Ql,ec,Ys,fd,Xs,_d,Fr,bd,Pi,Ur,Td,Hr,Ed,Gr,tc,oc,Vr,Wr,zr,Fi,yd,js,Ui,Yr,vd,Id,Cd,po,it,Hi,sc,go,Qo,Sd,ic,Xr,rc,kd,nc,Gi,Rd,jr,wd,Kr,Od,Nd,Ad,Ks,Ld,lc,pt,Jr,cc,qr,Zr,Md,uc,ac,Dd,Qr,_s,en,xd,hc,dc,Bd,Pd,bs,Fd,Vi,Js,qs,jt,Ud,Hd,Gd,Vd,Wd,zd,Yd,$c,es,Zs,pc,Xd,jd,Kd,Jd,qd,Zd,Qd,e$,t$,gc,o$,Ts,tn,s$,Qs,on,mc,fc,sn,rn,_c,i$,bc,Tc,Ec,yc,vc,Ic,Cc,r$,Wi,Sc,nn,ln,mo,kc,Rc,zi,wc,Oc,n$,cn,Nc,l$,c$,u$,a$,h$,ei,Ac,Lc,Yi,Mc,d$,$$,Dc,xc,xo,Bc,Pc,p$,g$,m$,f$,Fc,_$,Uc,b$,Es,Xi,un,an,ys,Hc,hn,Gc,Je,T$,ti,oi,E$,Vc,dn,si,Wc,vs,ji,zc,Yc,y$,v$,I$,Xc,C$,jc,ii,S$,k$,R$,w$,Ki,Kc,Jc,$n,pn,O$,Ji,qc,qi,N$,A$,ts,Zc,fo,L$,M$,Qc,D$,Is,eu,x$,B$,P$,F$,U$,tu,H$,G$,gn,V$,W$,ou,_o,z$,Y$,ri,X$,su,mn,j$,K$,J$,iu,fn,ru,_n,q$,Z$,Q$,ep,se,Pt,gt,je,bo,ni,re,qe,tp,op,sp,nu,ip,bn,lu,cu,uu,au,li,rp,np,lp,ci,hu,cp,Tn,Kt,du,ui,ro,ai,$u,pu,up,os,En,Zi,gu,ap,mu,hp,yn,fu,_u,bu,dp,Tu,$p,vn,pp,gp,Qi,mp,Eu,In,Cn,Sn,kn,yu,fp,vu,Rn,wn,_p,On,bp,Iu,Tp,ss,Cu,er,Su,ku,Nn,Ru,wu,Ou,Nu,Au,Lu,Mu,Du,xu,Ep,yp,vp,Ip,Cp,Sp,kp,Rp,Bu,Pu,Fu,Uu,Hu,Gu,Vu,An,tr,Wu,wp,zu,Yu,Xu,ju,Ku,Ju,qu,Zu,Qu,ea,Op,Np,Ap,ta,Lp,Mp,Dp,xp,N;l=function(e,t,o,s){if(!(e instanceof M)&&typeof e!="string"||`${e}`.trim()==="")throw Error('Invalid type "'+e+'". The type must be a non-empty string or a Blockly.registry.Type.');if(e=`${e}`.toLowerCase(),typeof t!="string"||t.trim()==="")throw Error('Invalid name "'+t+'". The name must be a non-empty string.');const i=t.toLowerCase();if(!o)throw Error("Can not register a null value");let n=is[e],d=Ln[e];if(n||(n=is[e]=Object.create(null),d=Ln[e]=Object.create(null)),g(e,o),!s&&n[i]&&n[i]!==o)throw Error('Name "'+i+'" with type "'+e+'" already registered.');n[i]=o,d[i]=t},g=function(e,t){switch(e){case String(M.FIELD):if(typeof t.fromJson!="function")throw Error('Type "'+e+'" must have a fromJson function')}},m=function(e,t){e=`${e}`.toLowerCase(),t=t.toLowerCase();const o=is[e];o&&o[t]?(delete is[e][t],delete Ln[e][t]):console.warn("Unable to unregister ["+t+"]["+e+"] from the registry.")},y=function(e,t,o){e=`${e}`.toLowerCase(),t=t.toLowerCase();const s=is[e];if(!s||!s[t]){if(t="Unable to find ["+t+"]["+e+"] in the registry.",o)throw Error(t+" You must require or register a "+e+" plugin.");return console.warn(t),null}return s[t]},k=function(e,t){return e=`${e}`.toLowerCase(),t=t.toLowerCase(),(e=is[e])?!!e[t]:!1},A=function(e,t,o){return y(e,t,o)},D=function(e,t,o){return y(e,t,o)},H=function(e,t,o){e=`${e}`.toLowerCase();var s=is[e];if(!s){if(s=`Unable to find [${e}] in the registry.`,o)throw Error(`${s} You must require or register a ${e} plugin.`);return console.warn(s),null}if(!t)return s;e=Ln[e],o=Object.create(null);for(const i of Object.keys(s))o[e[i]]=s[i];return o},W=function(e,t,o){return t=t.plugins[String(e)]||Ft,typeof t=="function"?t:A(e,t,o)},X=function(e,t){ue(),Dn=setTimeout(function(){t&&t.handleRightClick(e)},$b)},ue=function(){Dn&&(clearTimeout(Dn),Dn=0)},ie=function(){Mn=null},K=function(e){return!e.type.startsWith("pointer")||e instanceof PointerEvent&&me(e)},ee=function(e){return`${e.pointerId}`},me=function(e){const t=ee(e);return Mn?Mn===t:e.type==="pointerdown"?(Mn=t,!0):!1},z=function(e,t,o,s,i){function n(f){(i||K(f))&&(o?s.call(o,f):s(f))}const d=[];if(t in Cs)for(let f=0;f<Cs[t].length;f++){const L=Cs[t][f];e.addEventListener(L,n,!1),d.push([e,L,n])}else e.addEventListener(t,n,!1),d.push([e,t,n]);return d},ae=function(e,t,o,s){function i(d){o?s.call(o,d):s(d)}const n=[];if(t in Cs)for(let d=0;d<Cs[t].length;d++){const f=Cs[t][d];e.addEventListener(f,i,!1),n.push([e,f,i])}else e.addEventListener(t,i,!1),n.push([e,t,i]);return n},te=function(e){const t=e[e.length-1][2];for(;e.length;){const[o,s,i]=e.pop();o.removeEventListener(s,i,!1)}return t},Y=function(e){if(e.target instanceof HTMLElement){if(e.target.isContentEditable||e.target.getAttribute("data-is-text-input")==="true")return!0;if(e.target instanceof HTMLInputElement)return e=e.target,e.type==="text"||e.type==="number"||e.type==="email"||e.type==="password"||e.type==="search"||e.type==="tel"||e.type==="url";if(e.target instanceof HTMLTextAreaElement)return!0}return!1},Ie=function(e){return e.ctrlKey&&ra?!0:e.button===2},Ye=function(e,t,o){const s=t.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,o||(o=t.getScreenCTM().inverse()),s.matrixTransform(o)},It=function(e){switch(e.deltaMode){default:return{x:e.deltaX,y:e.deltaY};case 1:return{x:e.deltaX*jp,y:e.deltaY*jp};case 2:return{x:e.deltaX*Kp,y:e.deltaY*Kp}}},Re=function(){return"blockly-"+(mb++).toString(36)},rt=function(){return Zp.genUid()},bt=function(e){return e.type===w.BLOCK_CREATE},Bt=function(e){return e.type===w.BLOCK_DELETE},Ct=function(e){return e.type===w.BLOCK_CHANGE},nt=function(e){return e.type===w.BLOCK_FIELD_INTERMEDIATE_CHANGE},Tt=function(e){return e.type===w.BLOCK_MOVE},lt=function(e){return e.type===w.CLICK},$t=function(e){return e.type===w.BUBBLE_OPEN},St=function(e){return e.type===w.VIEWPORT_CHANGE},r.setRecordUndo$$module$build$src$core$events$utils=function(e){or=e},Ue=function(){return or},_=function(e){eg.fireInternal(e)},F=function(e){if(J()){if(!Fo.length)try{requestAnimationFrame(()=>{setTimeout(Q,0)})}catch{setTimeout(Q,0)}ne(e)}},Q=function(){const e=le(Fo);Fo.length=0;for(const t of e){if(!t.workspaceId)continue;let o;(o=ct(t.workspaceId))==null||o.fireChangeListener(t)}},ne=function(e){if(Ct(e)&&e.element==="mutation"){let t;for(t=Fo.length;t>0;t--){const o=Fo[t-1];if(o.group!==e.group||o.workspaceId!==e.workspaceId||!Tt(o)||o.newParentId!==e.blockId)break}Fo.splice(t,0,e)}else Fo.push(e)},le=function(e){const t=[];for(const o of e)if(e=t[t.length-1],!o.isNull())if(e&&e.workspaceId===o.workspaceId&&e.group===o.group)if(Tt(o)&&Tt(e)&&o.blockId===e.blockId){if(e.newParentId=o.newParentId,e.newInputName=o.newInputName,e.newCoordinate=o.newCoordinate,e.reason||o.reason){let s,i;e.reason=Array.from(new Set(((s=e.reason)!=null?s:[]).concat((i=o.reason)!=null?i:[])))}}else Ct(o)&&Ct(e)&&o.blockId===e.blockId&&o.element===e.element&&o.name===e.name?e.newValue=o.newValue:St(o)&&St(e)?(e.viewTop=o.viewTop,e.viewLeft=o.viewLeft,e.scale=o.scale,e.oldScale=o.oldScale):lt(o)&&$t(e)||t.push(o);else t.push(o);return e=t.filter(o=>!o.isNull())},he=function(){for(let e=0,t;t=Fo[e];e++)t.recordUndo=!1},r.disable$$module$build$src$core$events$utils=function(){la++},r.enable$$module$build$src$core$events$utils=function(){la--},J=function(){return la===0},r.getGroup$$module$build$src$core$events$utils=function(){return Qp},r.setGroup$$module$build$src$core$events$utils=function(e){eg.setGroupInternal(e)},$e=function(e){Qp=typeof e=="boolean"?e?rt():"":e},ce=function(e){const t=[];e=e.getDescendants(!1);for(let o=0,s;s=e[o];o++)t[o]=s.id;return t},_e=function(e,t){const o=U(e.type);if(!o)throw Error("Unknown event type.");return o.fromJson(e,t)},U=function(e){const t=A(M.EVENT,e);if(!t)throw Error(`Event type ${e} not found in registry.`);return t},Xe=function(e){if((Tt(e)||bt(e))&&e.workspaceId){var t=ct(e.workspaceId);if(!e.blockId)throw Error("Encountered a blockEvent without a proper blockId");if(e=t.getBlockById(e.blockId)){const o=or;try{or=!1;const s=e.getParent();if(s&&!s.hasDisabledReason(ca)){const i=e.getDescendants(!1);for(let n=0,d;d=i[n];n++)d.setDisabledReason(!1,ca)}else if((e.outputConnection||e.previousConnection)&&!t.isDragging())do e.setDisabledReason(!0,ca),e=e.getNextBlock();while(e)}finally{or=o}}}},v=function(e,t,o){e=document.createElementNS(sr,`${e}`);for(const s in t)e.setAttribute(s,`${t[s]}`);return o&&o.appendChild(e),e},G=function(e,t){return t=t.split(" "),t.every(o=>e.classList.contains(o))?!1:(e.classList.add(...t),!0)},Lt=function(e,t){e.classList.remove(...t.split(" "))},Te=function(e,t){return t=t.split(" "),t.every(o=>!e.classList.contains(o))?!1:(e.classList.remove(...t),!0)},qo=function(e,t){return e.classList.contains(t)},ke=function(e){return e&&e.parentNode?e.parentNode.removeChild(e):null},Qt=function(e,t){const o=t.nextSibling;if(t=t.parentNode,!t)throw Error("Reference node has no parent.");o?t.insertBefore(e,o):t.appendChild(e)},Mo=function(e,t){e.style.transform=t,e.style["-webkit-transform"]=t},eo=function(){ua++,no||(no=Object.create(null))},to=function(){ua--,ua||(no=null)},ot=function(e){const t=e.textContent+`
2
2
  `+e.className.baseVal;var o;return no&&(o=no[t])||(o=window.getComputedStyle(e),o=ho(e,o.fontSize,o.fontWeight,o.fontFamily),no&&(no[t]=o)),o},ms=function(e,t,o,s){return ho(e,t+"pt",o,s)},ho=function(e,t,o,s){const i=e.textContent;e=i+`
3
- `+e.className.baseVal;var n;return no&&(n=no[e])||(sr||(n=document.createElement("canvas"),n.className="blocklyComputeCanvas",document.body.appendChild(n),sr=n.getContext("2d")),i&&sr?(sr.font=o+" "+t+" "+s,n=sr.measureText(i).width):n=0,no&&(no[e]=n)),n},E=function(e,t,o,s){const i=document.createElement("span");i.style.font=o+" "+t+" "+s,i.textContent=e,e=document.createElement("div"),e.style.width="1px",e.style.height="0",t=document.createElement("div"),t.style.display="flex",t.style.position="fixed",t.style.top="0",t.style.left="0",t.appendChild(i),t.appendChild(e),document.body.appendChild(t),o={height:0,baseline:0};try{t.style.alignItems="baseline",o.baseline=e.offsetTop-i.offsetTop,t.style.alignItems="flex-end",o.height=e.offsetTop-i.offsetTop}finally{document.body.removeChild(t)}return o},r.getFocusManager$$module$build$src$core$focus_manager=function(){return Et.getFocusManager()},oo=function(e){return e&&typeof e.getFocusableElement=="function"&&typeof e.getFocusableTree=="function"&&typeof e.onNodeFocus=="function"&&typeof e.onNodeBlur=="function"&&typeof e.canBeFocused=="function"},Do=function(e){return oo(e)&&typeof e.id=="string"&&typeof e.workspace=="object"&&typeof e.select=="function"&&typeof e.unselect=="function"},He=function(e,t){for(const o in t)t[o]!==null&&Array.isArray(t[o])?e[o]=He(e[o]||[],t[o]):e[o]=t[o]!==null&&typeof t[o]=="object"?He(e[o]||Object.create(null),t[o]):t[o];return e},ct=function(e){return ir[e]||null},kt=function(){const e=[];for(const t in ir)e.push(ir[t]);return e},st=function(e){ir[e.id]=e},Ut=function(e){delete ir[e.id]},c=function(){return Qp},p=function(e){Qp=e},I=function(){const e=r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode();return e&&Do(e)?e:null},C=function(e){r.getFocusManager$$module$build$src$core$focus_manager().focusNode(e)},V=function(e){const t=I();let o,s,i,n;const d=new(U(w.SELECTED))((o=t?.id)!=null?o:null,(s=e?.id)!=null?s:null,(n=(i=e?.workspace.id)!=null?i:t?.workspace.id)!=null?n:"");_(d)},Ae=function(){return eg},so=function(e){eg=e},$o=function(e){for(;e.options.parentWorkspace;)e=e.options.parentWorkspace;const t=e.getParentSvg(),o=e.getCachedParentSvgSize();var s=t.parentElement;if(s instanceof HTMLElement){var i=s.offsetWidth;s=s.offsetHeight,o.width!==i&&(t.setAttribute("width",i+"px"),e.setCachedParentSvgSize(i,null)),o.height!==s&&(t.setAttribute("height",s+"px"),e.setCachedParentSvgSize(null,s)),e.resize()}},io=function(e,t){const o=Object.create(null),s=e.getDescendants(!0);t&&(e=e.getNextBlock())&&(e=s.indexOf(e),s.splice(e,s.length-e));for(let i=0,n;n=s[i];i++)o[n.type]?o[n.type]++:o[n.type]=1;return o},u=function(e){return function(){this.jsonInit(e)}},$=function(e){tg.defineBlocksWithJsonArrayInternal(e)},b=function(e){r.defineBlocks$$module$build$src$core$common(r.createBlockDefinitionsFromJsonArray$$module$build$src$core$common(e))},r.createBlockDefinitionsFromJsonArray$$module$build$src$core$common=function(e){const t={};for(let o=0;o<e.length;o++){const s=e[o];if(!s){console.warn(`Block definition #${o} in JSON array is ${s}. Skipping`);continue}const i=s.type;i?t[i]={init:u(s)}:console.warn(`Block definition #${o} in JSON array is missing a type attribute. Skipping.`)}return t},r.defineBlocks$$module$build$src$core$common=function(e){for(const t of Object.keys(e)){const o=e[t];t in Ge&&console.warn(`Block definition "${t}" overwrites previous definition.`),Ge[t]=o}},S=function(e){let t=c();const o=r.getFocusManager$$module$build$src$core$focus_manager().getFocusedTree();for(const s of kt())if(o===s){t=s;break}!Y(e)&&t&&(!t.rendered||t.isFlyout||t.isVisible())&&Pe.registry.onKeyDown(t,e)},x=function(e,t){return t=e.indexOf(t),t===-1?!1:(e.splice(t,1),!0)},q=function(e){if(aa)throw Error("CSS already injected");ha+=`
4
- `+e},pe=function(e,t){aa||(aa=!0,e&&(e=t.replace(/[\\/]$/,""),t=ha.replace(/<<<PATH>>>/g,e),ha="",e=document.createElement("style"),e.id="blockly-common-style",t=document.createTextNode(t),e.appendChild(t),document.head.insertBefore(e,document.head.firstChild)))},Rt=function(e){return sg.getSizeInternal(e)},fs=function(e){if(Mt(e,"display")!=="none")return zs(e);const t=e.style,o=t.display,s=t.visibility,i=t.position;t.visibility="hidden",t.position="absolute",t.display="inline";const n=e.offsetWidth;return e=e.offsetHeight,t.display=o,t.position=i,t.visibility=s,new ve(n,e)},zs=function(e){return new ve(e.offsetWidth,e.offsetHeight)},Mt=function(e,t){return e=window.getComputedStyle(e),e[t]||e.getPropertyValue(t)},Zo=function(e){const t=new P(0,0);e=e.getBoundingClientRect();var o=document.documentElement;return o=new P(window.pageXOffset||o.scrollLeft,window.pageYOffset||o.scrollTop),t.x=e.left+o.x,t.y=e.top+o.y,t},Yl=function(){const e=document.body,t=document.documentElement;return new P(e.scrollLeft||t.scrollLeft,e.scrollTop||t.scrollTop)},Xl=function(e){const t=parseFloat(Mt(e,"borderLeftWidth")),o=parseFloat(Mt(e,"borderRightWidth")),s=parseFloat(Mt(e,"borderTopWidth"));return e=parseFloat(Mt(e,"borderBottomWidth")),new ye(s,e,t,o)},jl=function(e,t,o){e=Kl(e,t,o),t.scrollLeft=e.x,t.scrollTop=e.y},Kl=function(e,t,o){var s=Zo(e),i=Zo(t),n=Xl(t);const d=s.x-i.x-n.left;return s=s.y-i.y-n.top,i=zs(e),e=t.clientWidth-i.width,i=t.clientHeight-i.height,n=t.scrollLeft,t=t.scrollTop,o?(n+=d-e/2,t+=s-i/2):(n+=Math.min(d,Math.max(d-e,0)),t+=Math.min(s,Math.max(s-i,0))),new P(n,t)},xi=function(e){const t=new P(0,0);var o=e.x&&e.getAttribute("x");const s=e.y&&e.getAttribute("y");return o&&(t.x=parseInt(o)),s&&(t.y=parseInt(s)),(o=(o=e.getAttribute("transform"))&&o.match(ig))&&(t.x+=Number(o[1]),o[3]&&(t.y+=Number(o[3]))),(e=e.getAttribute("style"))&&e.includes("translate")&&(e=e.match(rg))&&(t.x+=Number(e[1]),e[3]&&(t.y+=Number(e[3]))),t},Br=function(e){let t=0,o=0;for(;e;){const s=xi(e);if(t+=s.x,o+=s.y,(" "+(e.getAttribute("class")||"")+" ").includes(" injectionDiv "))break;e=e.parentNode}return new P(t,o)},Jl=function(){const e=Yl();return new ye(e.y,document.documentElement.clientHeight+e.y,e.x,document.documentElement.clientWidth+e.x)},ql=function(){const e=document.documentElement,t=window;return new P(t.pageXOffset||e.scrollLeft,t.pageYOffset||e.scrollTop)},Zl=function(e,t){var o=t.x;t=t.y;const s=e.getInjectionDiv().getBoundingClientRect();return o=new P(o-s.left,t-s.top),t=e.getOriginOffsetInPixels(),P.difference(o,t).scale(1/e.scale)},Ys=function(e,t){var o=t.scale(e.scale);t=o.x,o=o.y;const s=e.getInjectionDiv().getBoundingClientRect();return e=e.getOriginOffsetInPixels(),new P(t+s.left+e.x,o+s.top+e.y)},pd=function(e){({document:Fn=Fn,DOMParser:nr=nr,XMLSerializer:lr=lr}=e),Pn=new nr,$a=new lr},r.createElement$$module$build$src$core$utils$xml=function(e){return Fn.createElementNS(ng,e)},r.createTextNode$$module$build$src$core$utils$xml=function(e){return Fn.createTextNode(e)},r.textToDom$$module$build$src$core$utils$xml=function(e){let t=Pn.parseFromString(e,"text/xml");if(t&&t.documentElement&&!t.getElementsByTagName("parsererror").length)return t.documentElement;if((t=Pn.parseFromString(e,"text/html"))&&t.body.firstChild&&t.body.firstChild.nodeName.toLowerCase()==="xml")return t.body.firstChild;throw Error(`DOMParser was unable to parse: ${e}`)},Xs=function(e){return gd($a.serializeToString(e))},gd=function(e){return e.replace(mb,t=>`&#${t.charCodeAt(0)};`)},Pr=function(e){return e?((e instanceof Element||typeof e=="string")&&(e=ec(e),e=_d(e)),md(e),e):null},md=function(e){const t=e.kind;if(e=e.contents,t&&t!==lg&&t!==pa)throw Error("Invalid toolbox kind "+t+". Please supply either "+lg+" or "+pa);if(!e)throw Error("Toolbox must have a contents attribute.")},Bi=function(e){return e?e.contents?e.contents:Array.isArray(e)&&e.length>0&&!e[0].nodeType?e:Hr(e):[]},Fr=function(e){return cg.hasCategoriesInternal(e)},fd=function(e){if(!e)return!1;const t=e.kind;return t?t===pa:!!e.contents.filter(o=>o.kind.toUpperCase()==="CATEGORY").length},Ur=function(e){return e&&e.contents?!!e.contents.filter(function(t){return t.kind.toUpperCase()==="CATEGORY"}).length:!1},_d=function(e){const t={contents:Hr(e)};return e instanceof Node&&Ql(e,t),t},Hr=function(e){const t=[];let o=e.childNodes;o||(o=e);for(let s=0,i;i=o[s];s++){if(!i.tagName)continue;e={};const n=i.tagName.toUpperCase();e.kind=n,n==="BLOCK"?e.blockxml=i:i.childNodes&&i.childNodes.length>0&&(e.contents=Hr(i)),Ql(i,e),t.push(e)}return t},Ql=function(e,t){for(let o=0;o<e.attributes.length;o++){const s=e.attributes[o];s.nodeName.includes("css-")?(t.cssconfig=t.cssconfig||{},t.cssconfig[s.nodeName.replace("css-","")]=s.value):t[s.nodeName]=s.value}},ec=function(e){let t=null;if(e)if(typeof e=="string"){if(t=r.textToDom$$module$build$src$core$utils$xml(e),t.nodeName.toLowerCase()!=="xml")throw TypeError("Toolbox should be an <xml> document.")}else e instanceof Element&&(t=e);return t},Gr=function(e,t,o,s,i,n){const d=n.scrollbar&&n.scrollbar.canScrollVertically();return e.horizontal===$i.LEFT?(o=i.absoluteMetrics.left+o,d&&n.RTL&&(o+=Ze.scrollbarThickness)):(o=i.absoluteMetrics.left+i.viewMetrics.width-t.width-o,d&&!n.RTL&&(o-=Ze.scrollbarThickness)),e.vertical===Go.TOP?e=i.absoluteMetrics.top+s:(e=i.absoluteMetrics.top+i.viewMetrics.height-t.height-s,n.scrollbar&&n.scrollbar.canScrollHorizontally()&&(e-=Ze.scrollbarThickness)),new ye(e,e+t.height,o,o+t.width)},Vr=function(e,t){return{horizontal:t.toolboxMetrics.position===be.LEFT||e.horizontalLayout&&!e.RTL?$i.RIGHT:$i.LEFT,vertical:t.toolboxMetrics.position===be.BOTTOM?Go.TOP:Go.BOTTOM}},Wr=function(e,t,o,s){const i=e.left,n=e.right-e.left,d=e.bottom-e.top;for(let f=0;f<s.length;f++){const L=s[f];e.intersects(L)&&(e=o===ls.UP?L.top-d-t:L.bottom+t,e=new ye(e,e+d,i,i+n),f=-1)}return e},Pi=function(e,t){l(M.SERIALIZER,e,t)},bd=function(e){m(M.SERIALIZER,e)},js=function(e,{addCoordinates:t=!1,saveIds:o=!0}={}){const s=e.workspace,i=Object.create(null);return i.height=e.getSize().height,i.width=e.getSize().width,o&&(i.id=e.id),t&&(t=e.getRelativeToSurfaceXY(),i.x=s.RTL?s.getWidth()-t.x:t.x,i.y=t.y),e.getText()&&(i.text=e.getText()),e.isCollapsed()&&(i.collapsed=!0),e.isOwnEditable()||(i.editable=!1),e.isOwnMovable()||(i.movable=!1),e.isOwnDeletable()||(i.deletable=!1),i},Fi=function(e,t,{recordUndo:o=!1}={}){const s=Ue();if(r.setRecordUndo$$module$build$src$core$events$utils(o),o=t.newComment(e.id),e.text!==void 0&&o.setText(e.text),e.x!==void 0||e.y!==void 0){const n=o.getRelativeToSurfaceXY();let d,f=(d=e.x)!=null?d:n.x;f=t.RTL?t.getWidth()-f:f;var i;t=(i=e.y)!=null?i:n.y,o.moveTo(new P(f,t))}if(e.width!==void 0||e.height){i=o.getSize();let n,d;o.setSize(new ve((n=e.width)!=null?n:i.width,(d=e.height)!=null?d:i.height))}return e.collapsed!==void 0&&o.setCollapsed(e.collapsed),e.editable!==void 0&&o.setEditable(e.editable),e.movable!==void 0&&o.setMovable(e.movable),e.deletable!==void 0&&o.setDeletable(e.deletable),r.setRecordUndo$$module$build$src$core$events$utils(s),o},zr=function(e,t){l(M.PASTER,e,t)},Td=function(e){m(M.PASTER,e)},Ed=function(e){const t=e.workspace,o=e.getRelativeToSurfaceXY(),s=new P(0,0),i=t.getTopComments(!1).filter(n=>n.id!==e.id).map(n=>n.getRelativeToSurfaceXY());for(;yd(P.sum(o,s),i);)s.translate(t.RTL?-30:30,30);e.moveTo(P.sum(o,s))},yd=function(e,t){return t.some(o=>Math.abs(o.x-e.x)<=1&&Math.abs(o.y-e.y)<=1)},po=function(e,t){e.setAttribute(bb,t)},it=function(e,t,o){Array.isArray(o)&&(o=o.join(" ")),e.setAttribute(_b+t,`${o}`)},Ui=function(e){return e&&typeof e.saveState=="function"&&typeof e.loadState=="function"},tc=function(e){return oc(e),vd()?(Yr(),Promise.resolve()):(pi||(pi=new Promise(t=>{Ea=t,mg=window.requestAnimationFrame(()=>{Yr(),t()})})),pi)},go=function(){return pi||Promise.resolve()},Qo=function(e){e||window.cancelAnimationFrame(mg),Yr(e),!e&&Ea&&Ea()},vd=function(){return Hp},oc=function(e){ba.add(e),Ta.set(e,r.getGroup$$module$build$src$core$events$utils());const t=e.getParent();t?oc(t):Wn.add(e)},Yr=function(e){const t=e?new Set([e]):new Set([...Wn].map(n=>n.workspace)),o=[...Wn].filter(Id).filter(n=>t.has(n.workspace));for(var s of o)ic(s);for(const n of t)n.resizeContents();for(var i of o)s=i.getRelativeToSurfaceXY(),i.updateComponentLocations(s);for(const n of o)i=r.getGroup$$module$build$src$core$events$utils(),(s=Ta.get(n))&&r.setGroup$$module$build$src$core$events$utils(s),n.bumpNeighbours(),r.setGroup$$module$build$src$core$events$utils(i);for(const n of o)sc(n);e||(pi=null)},sc=function(e){Wn.delete(e),ba.delete(e),Ta.delete(e);for(const t of e.getChildren(!1))sc(t)},Id=function(e){return!e.isDisposed()&&!e.getParent()},ic=function(e){if(ba.has(e)&&e.initialized){for(const t of e.getChildren(!1))ic(t);e.renderEfficiently()}},Hi=function(e,t){Eg(e,t)},Cd=function(e=Tg){Eg=e},Xr=function(e,t){vg(e,t)},Sd=function(e=yg){vg=e},jr=function(e,t,o){Cg(e,t,o)},kd=function(e=Ig){Cg=e},Rd=function(e,t){kg(e,t)},wd=function(e=Sg){kg=e},Ks=function(e){return e&&typeof e.getProcedureDef=="function"},Od=function(e){return e&&typeof e.getProcedureCall=="function"&&typeof e.renameProcedure=="function"},rc=function(e){return e.getVariableModel!==void 0},pt=function(e,t,o,s){e=e+" was deprecated in "+t+" and will be deleted in "+o+".",s&&(e+=`
5
- Use `+s+" instead."),Rg.has(e)||(Rg.add(e),console.warn(e))},r.allUsedVarModels$$module$build$src$core$variables=function(e){e=e.getAllBlocks(!1);const t=new Set;for(let o=0;o<e.length;o++){const s=e[o].getVarModels();if(s)for(let i=0;i<s.length;i++){const n=s[i];n.getId()&&t.add(n)}}return Array.from(t.values())},r.allDeveloperVariables$$module$build$src$core$variables=function(e){e=e.getAllBlocks(!1);const t=new Set;for(let s=0,i;i=e[s];s++){var o=i.getDeveloperVariables;if(o){o=o();for(let n=0;n<o.length;n++)t.add(o[n])}}return Array.from(t.values())},Kr=function(e){return nc(e,!1)},nc=function(e,t=!0){return Ge.variables_set||Ge.variables_get||console.warn("There are no variable blocks, but there is a variable category."),t?(pt("The XML return value of Blockly.Variables.flyoutCategory()","v12","v13","the same method, but handle a return type of FlyoutItemInfo[] (JSON) instead."),Nd(e)):(e.registerButtonCallback("CREATE_VARIABLE",function(o){_s(o.getTargetWorkspace())}),[{kind:"button",text:"%{BKY_NEW_VARIABLE}",callbackkey:"CREATE_VARIABLE"},...qr(e,e.getVariableMap().getVariablesOfType(""),!0)])},Jr=function(e){return{VAR:{name:e.getName(),type:e.getType()}}},qr=function(e,t,o,s="variables_get",i="variables_set"){o&&(o=Ge.math_change),e=[];const n=t.slice(-1)[0];return n&&(Ge[i]&&e.push({kind:"block",type:i,gap:o?8:24,fields:Jr(n)}),o&&e.push({kind:"block",type:"math_change",gap:Ge[s]?20:8,fields:Jr(n),inputs:{DELTA:{shadow:{type:"math_number",fields:{NUM:1}}}}})),Ge[s]&&e.push(...t.sort(Js).map(d=>({kind:"block",type:s,gap:8,fields:Jr(d)}))),e},Nd=function(e){let t=[];const o=document.createElement("button");return o.setAttribute("text","%{BKY_NEW_VARIABLE}"),o.setAttribute("callbackKey","CREATE_VARIABLE"),e.registerButtonCallback("CREATE_VARIABLE",function(s){_s(s.getTargetWorkspace())}),t.push(o),e=lc(e),t=t.concat(e)},lc=function(e){e=e.getVariableMap().getVariablesOfType("");const t=[];if(e.length>0){var o=e[e.length-1];if(Ge.variables_set){var s=r.createElement$$module$build$src$core$utils$xml("block");s.setAttribute("type","variables_set"),s.setAttribute("gap",Ge.math_change?"8":"24"),s.appendChild(bs(o)),t.push(s)}if(Ge.math_change&&(s=r.createElement$$module$build$src$core$utils$xml("block"),s.setAttribute("type","math_change"),s.setAttribute("gap",Ge.variables_get?"20":"8"),s.appendChild(bs(o)),o=r.textToDom$$module$build$src$core$utils$xml('<value name="DELTA"><shadow type="math_number"><field name="NUM">1</field></shadow></value>'),s.appendChild(o),t.push(s)),Ge.variables_get){e.sort(Js);for(let i=0,n;n=e[i];i++)o=r.createElement$$module$build$src$core$utils$xml("block"),o.setAttribute("type","variables_get"),o.setAttribute("gap","8"),o.appendChild(bs(n)),t.push(o)}}return t},cc=function(e){return Og.generateUniqueNameInternal(e)},Ad=function(e){return Zr(Ia.charAt(0),e.getVariableMap().getAllVariables().map(t=>t.getName()))},Zr=function(e,t){if(!t.length)return e;const o=Ia;let s="",i=o.indexOf(e);for(;;){let n=!1;for(let d=0;d<t.length;d++)if(t[d].toLowerCase()===e){n=!0;break}if(!n)break;i++,i===o.length&&(i=0,s=`${Number(s)+1}`),e=o.charAt(i)+s}return e},_s=function(e,t,o){function s(n){Qr(r.Msg$$module$build$src$core$msg.NEW_VARIABLE_TITLE,n,function(d){if(d){var f=uc(d,e);if(f){if(f.getType()===i)var L=r.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS.replace("%1",f.getName());else L=r.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE,L=L.replace("%1",f.getName()).replace("%2",f.getType());Hi(L,function(){s(d)})}else e.getVariableMap().createVariable(d,i),t&&t(d)}else t&&t(null)})}const i=o||"";s("")},r.renameVariable$$module$build$src$core$variables=function(e,t,o){function s(i){const n=r.Msg$$module$build$src$core$msg.RENAME_VARIABLE_TITLE.replace("%1",t.getName());Qr(n,i,function(d){if(d){var f=Ld(d,t.getType(),e),L=ac(t.getName(),d,e);if(f||L){var oe="";f?oe=r.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE.replace("%1",f.getName()).replace("%2",f.getType()):L&&(oe=r.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS_FOR_A_PARAMETER.replace("%1",d).replace("%2",L)),Hi(oe,function(){s(d)})}else e.getVariableMap().renameVariable(t,d),o&&o(d)}else o&&o(null)})}s("")},Qr=function(e,t,o){jr(e,t,function(s){s&&(s=s.replace(/[\s\xa0]+/g," ").trim(),s===r.Msg$$module$build$src$core$msg.RENAME_VARIABLE||s===r.Msg$$module$build$src$core$msg.NEW_VARIABLE)&&(s=null),o(s)})},Ld=function(e,t,o){o=o.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let s=0,i;i=o[s];s++)if(i.getName().toLowerCase()===e&&i.getType()!==t)return i;return null},uc=function(e,t){t=t.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let o=0,s;s=t[o];o++)if(s.getName().toLowerCase()===e)return s;return null},ac=function(e,t,o){return o.getProcedureMap().getProcedures().length?Md(e,t,o):Dd(e,t,o)},Md=function(e,t,o){e=e.toLowerCase(),t=t.toLowerCase(),o=o.getProcedureMap().getProcedures();for(const i of o){var s=i.getParameters().filter(rc).map(n=>n.getVariableModel().getName());if(s&&(o=s.some(n=>n.toLowerCase()===e),s=s.some(n=>n.toLowerCase()===t),o&&s))return i.getName()}return null},Dd=function(e,t,o){e=e.toLowerCase(),t=t.toLowerCase(),o=o.getAllBlocks(!1);for(const i of o){if(!Ks(i))continue;o=i.getProcedureDef();var s=o[1];const n=s.some(d=>d.toLowerCase()===e);if(s=s.some(d=>d.toLowerCase()===t),n&&s)return o[0]}return null},bs=function(e){const t=r.createElement$$module$build$src$core$utils$xml("field");return t.setAttribute("name","VAR"),t.setAttribute("id",e.getId()),t.setAttribute("variabletype",e.getType()),e=r.createTextNode$$module$build$src$core$utils$xml(e.getName()),t.appendChild(e),t},r.getOrCreateVariablePackage$$module$build$src$core$variables=function(e,t,o,s){let i=r.getVariable$$module$build$src$core$variables(e,t,o,s);return i||(i=xd(e,t,o,s)),i},r.getVariable$$module$build$src$core$variables=function(e,t,o,s){const i=e.getPotentialVariableMap();let n=null;if(t&&(n=e.getVariableById(t),!n&&i&&(n=i.getVariableById(t)),n))return n;if(o){if(s===void 0)throw Error("Tried to look up a variable by name without a type");n=e.getVariable(o,s),!n&&i&&(n=i.getVariable(o,s))}return n},xd=function(e,t,o,s){const i=e.getVariableMap(),n=e.getPotentialVariableMap();return o||(o=cc(e.isFlyout?e.targetWorkspace:e)),n?n.createVariable(o,s,t??void 0):i.createVariable(o,s,t)},Gi=function(e,t){e=e.getAllVariables();const o=[];if(t.length!==e.length)for(let s=0;s<e.length;s++){const i=e[s];t.includes(i)||o.push(i)}return o},Js=function(e,t){return e.getName().localeCompare(t.getName(),void 0,{sensitivity:"base"})},qs=function(e,t){const o=[];e=e.getAllBlocks(!1);for(let s=0;s<e.length;s++){const i=e[s].getVarModels();if(i)for(let n=0;n<i.length;n++)i[n].getId()===t&&o.push(e[s])}return o},r.deleteVariable$$module$build$src$core$variables=function(e,t,o){var s=t.getName();const i=qs(e,t.getId());for(let n=i.length-1;n>=0;n--){const d=i[n];if(d.type==="procedures_defnoreturn"||d.type==="procedures_defreturn"){o=String(d.getFieldValue("NAME")),s=r.Msg$$module$build$src$core$msg.CANNOT_DELETE_VARIABLE_PROCEDURE.replace("%1",s).replace("%2",o),Hi(s);return}d===o&&i.splice(n,1)}o&&i.length||i.length>1?(s=r.Msg$$module$build$src$core$msg.DELETE_VARIABLE_CONFIRMATION.replace("%1",String(i.length+(o&&!o.workspace.isFlyout?1:0))).replace("%2",s),Xr(s,n=>{n&&t&&e.getVariableMap().deleteVariable(t)})):e.getVariableMap().deleteVariable(t)},jt=function(e,{addCoordinates:t=!1,addInputBlocks:o=!0,addNextBlocks:s=!0,doFullSerialization:i=!0,saveIds:n=!0}={}){if(e.isInsertionMarker())return null;const d={type:e.type,id:n?e.id:void 0};return t&&Pd(e,d),Bd(e,d),Fd(e,d,i),Ud(e,d,i),Hd(e,d,i),o&&Gd(e,d,i,n),s&&Vd(e,d,i,n),d},Bd=function(e,t){e.isCollapsed()&&(t.collapsed=!0),e.isEnabled()||(t.disabledReasons=Array.from(e.getDisabledReasons())),e.isOwnDeletable()||(t.deletable=!1),e.isOwnMovable()||(t.movable=!1),e.isOwnEditable()||(t.editable=!1),e.inputsInline!==void 0&&e.inputsInline!==e.inputsInlineDefault&&(t.inline=e.inputsInline),e.data&&(t.data=e.data)},Pd=function(e,t){const o=e.workspace;e=e.getRelativeToSurfaceXY(),t.x=Math.round(o.RTL?o.getWidth()-e.x:e.x),t.y=Math.round(e.y)},Fd=function(e,t,o){e.saveExtraState?(e=e.saveExtraState(o),e!==null&&(t.extraState=e)):e.mutationToDom&&(e=e.mutationToDom(),e!==null&&(t.extraState=fo(e).replace(' xmlns="https://developers.google.com/blockly/xml"',"")))},Ud=function(e,t,o){const s=Object.create(null);for(const i of e.getIcons())Ui(i)&&(e=i.saveState(o))&&(s[i.getType().toString()]=e);Object.keys(s).length&&(t.icons=s)},Hd=function(e,t,o){const s=Object.create(null);for(const i of e.getFields())i.isSerializable()&&(s[i.name]=i.saveState(o));Object.keys(s).length&&(t.fields=s)},Gd=function(e,t,o,s){const i=Object.create(null);for(let n=0;n<e.inputList.length;n++){const d=e.inputList[n];if(!d.connection)continue;const f=hc(d.connection,o,s);f&&(i[d.name]=f)}Object.keys(i).length&&(t.inputs=i)},Vd=function(e,t,o,s){e.nextConnection&&(e=hc(e.nextConnection,o,s))&&(t.next=e)},hc=function(e,t,o){const s=e.getShadowState(!0);if(e=e.targetBlock(),!s&&!e)return null;const i=Object.create(null);return s&&(i.shadow=s),e&&!e.isShadow()&&(i.block=jt(e,{doFullSerialization:t,saveIds:o})),i},es=function(e,t,{recordUndo:o=!1}={}){return e=Zs(e,t,{recordUndo:o}),t.rendered&&Qo(),e},Zs=function(e,t,{parentConnection:o,isShadow:s=!1,recordUndo:i=!1}={}){const n=Ue();r.setRecordUndo$$module$build$src$core$events$utils(i),(i=r.getGroup$$module$build$src$core$events$utils())||r.setGroup$$module$build$src$core$events$utils(!0),r.disable$$module$build$src$core$events$utils();const d=t.getAllVariables();let f;try{f=dc(e,t,{parentConnection:o,isShadow:s})}finally{r.enable$$module$build$src$core$events$utils()}if(Wd(t,d),J()&&_(new(U(w.BLOCK_CREATE))(f)),r.setGroup$$module$build$src$core$events$utils(i),r.setRecordUndo$$module$build$src$core$events$utils(n),t.rendered){const L=f;setTimeout(()=>{L.disposed||L.setConnectionTracking(!0)},1)}return f},dc=function(e,t,{parentConnection:o,isShadow:s=!1}={}){if(!e.type)throw new Ng(e);const i=t.newBlock(e.type,e.id);return i.setShadow(s),zd(i,e),Yd(i,e),Xd(i,e),jd(o,i,e),Kd(i,e),Jd(i,e),qd(i,e),Zd(i,e),Qd(i,t.rendered),i},Wd=function(e,t){if(J())for(e=Gi(e,t),t=0;t<e.length;t++){const o=e[t];_(new(U(w.VAR_CREATE))(o))}},zd=function(e,t){let o=t.x===void 0?0:t.x;t=t.y===void 0?0:t.y;const s=e.workspace;o=s.RTL?s.getWidth()-o:o,e.moveBy(o,t)},Yd=function(e,t){if(t.collapsed&&e.setCollapsed(!0),t.deletable===!1&&e.setDeletable(!1),t.movable===!1&&e.setMovable(!1),t.editable===!1&&e.setEditable(!1),t.enabled===!1&&e.setDisabledReason(!0,Jt),Array.isArray(t.disabledReasons))for(const o of t.disabledReasons)e.setDisabledReason(!0,o);t.inline!==void 0&&e.setInputsInline(t.inline),t.data!==void 0&&(e.data=t.data)},Xd=function(e,t){t.extraState&&(e.loadExtraState?e.loadExtraState(t.extraState):e.domToMutation&&e.domToMutation(r.textToDom$$module$build$src$core$utils$xml(t.extraState)))},jd=function(e,t,o){if(e){if(e.getSourceBlock().isShadow()&&!t.isShadow())throw new Lg(o);if(e.type===r.inputTypes$$module$build$src$core$inputs$input_types.VALUE){var s=t.outputConnection;if(!s)throw new hr("output",t,o)}else if(s=t.previousConnection,!s)throw new hr("previous",t,o);if(!e.connect(s)){const i=t.workspace.connectionChecker;throw new Ag(i.getErrorMessage(i.canConnectWithReason(s,e,!1),s,e),e.type===r.inputTypes$$module$build$src$core$inputs$input_types.VALUE?"output connection":"previous connection",t,o)}}},Kd=function(e,t){if(t.icons){var o=Object.keys(t.icons);for(const i of o){o=t.icons[i];var s=e.getIcon(i);if(!s){if(s=A(M.ICON,i,!1),!s)throw new Mg(i,e,t);s=new s(e),e.addIcon(s)}Ui(s)&&s.loadState(o)}}},Jd=function(e,t){if(t.fields){var o=Object.keys(t.fields);for(let s=0;s<o.length;s++){const i=o[s],n=t.fields[i],d=e.getField(i);d?d.loadState(n):console.warn(`Ignoring non-existant field ${i} in block ${e.type}`)}}},qd=function(e,t){if(t.inputs){var o=Object.keys(t.inputs);for(let s=0;s<o.length;s++){const i=o[s],n=e.getInput(i);if(!n||!n.connection)throw new hr(i,e,t);$c(n.connection,t.inputs[i])}}},Zd=function(e,t){if(t.next){if(!e.nextConnection)throw new hr("next",e,t);$c(e.nextConnection,t.next)}},$c=function(e,t){t.shadow&&e.setShadowState(t.shadow),t.block&&dc(t.block,e.getSourceBlock().workspace,{parentConnection:e})},Qd=function(e,t){if(t){e.setConnectionTracking(!1),e.initSvg(),e.queueRender();for(const o of e.getIcons())o.onLocationChange(e.getRelativeToSurfaceXY())}else e.initModel()},Ts=function(e){return typeof e.bubbleIsVisible=="function"&&typeof e.setBubbleVisible=="function"&&typeof e.getBubble=="function"},en=function(e){return e*Math.PI/180},e$=function(e){return e*180/Math.PI},Qs=function(e,t,o){if(o<e){const s=o;o=e,e=s}return Math.max(e,Math.min(t,o))},tn=function(){document.querySelector(".blocklyDropDownDiv")||(Ke=document.createElement("div"),Ke.className="blocklyDropDownDiv",Ke.tabIndex=-1,(Ae()||document.body).appendChild(Ke),$r=document.createElement("div"),$r.className="blocklyDropDownContent",Ke.appendChild($r),Jn=z($r,"keydown",null,S),Ms=document.createElement("div"),Ms.className="blocklyDropDownArrow",Ke.appendChild(Ms),Ke.style.opacity="0",Ke.style.transition="transform "+jn+"s, opacity "+jn+"s")},pc=function(e){ka=e},gc=function(){return cs},on=function(){return $r},sn=function(){Jn&&(te(Jn),Jn=null),Ke.remove(),tn()},mc=function(e,t){Ke.style.backgroundColor=e,Ke.style.borderColor=t},t$=function(e,t,o,s,i=!0){return Tc(_c(t),e,i,o,s)},fc=function(e,t,o,s=!0){return Ug=!0,Tc(bc(e),e,s,t,o)},_c=function(e){var t=e.getSvgRoot();const o=e.workspace.scale,s=e.height*o;return e=e.width*o,t=Zo(t),new ye(t.y,t.y+s,t.x,t.x+e)},bc=function(e){return e=e.getScaledBBox(),new ye(e.top,e.bottom,e.left,e.right)},Tc=function(e,t,o,s,i){const n=e.left+(e.right-e.left)/2,d=e.bottom;e=e.top,i&&(e+=i),i=t.getSourceBlock();let f=i.workspace;for(;f.options.parentWorkspace;)f=f.options.parentWorkspace;return pc(f.getParentSvg().parentNode),Ec(t,i.RTL,n,d,n,e,o,s)},Ec=function(e,t,o,s,i,n,d,f){return cs=e,Ls=f||null,Ke.style.direction=t?"rtl":"ltr",e=c(),Pg=e.getRenderer().getClassName(),Fg=e.getTheme().getClassName(),G(Ke,Pg),G(Ke,Fg),o=Cc(o,s,i,n),d&&(Kn=r.getFocusManager$$module$build$src$core$focus_manager().takeEphemeralFocus(Ke)),o},yc=function(e,t,o,s){return e=Vi(e,o.left,o.right,s.width),{initialX:e.divX,initialY:t,finalX:e.divX,finalY:t+Ca,arrowX:e.arrowX,arrowY:-9,arrowAtTop:!0,arrowVisible:!0}},vc=function(e,t,o,s){return e=Vi(e,o.left,o.right,s.width),{initialX:e.divX,initialY:t-s.height,finalX:e.divX,finalY:t-s.height-Ca,arrowX:e.arrowX,arrowY:s.height-xg*2-Xn/2,arrowAtTop:!1,arrowVisible:!0}},o$=function(e,t,o){return e=Vi(e,t.left,t.right,o.width),{initialX:e.divX,initialY:0,finalX:e.divX,finalY:0,arrowAtTop:null,arrowX:null,arrowY:null,arrowVisible:!1}},Vi=function(e,t,o,s){return t=Qs(t,e-s/2,o-s),e=e-Xn/2-t,o=Bg,e=Qs(o,e,s-o-Xn),{arrowX:e,divX:t}},Ic=function(){return!!cs},rn=function(e,t){return cs===e?(t?mo():nn(),!0):!1},nn=function(){Ke.style.transform="translate(0, 0)",Ke.style.opacity="0",Sa=setTimeout(function(){mo()},jn*1e3),Ls&&(Ls(),Ls=null)},mo=function(){Ic()&&(Sa&&clearTimeout(Sa),Ls&&(Ls(),Ls=null),sn(),cs=null,c().markFocused(),Kn&&(Kn(),Kn=null))},Cc=function(e,t,o,s){e=Ra.getPositionMetrics(e,t,o,s),e.arrowVisible?(t=e.arrowX,o=e.arrowY,s=e.arrowAtTop?45:225,Ms.style.display="",Ms.style.transform=`translate(${t}px, ${o}px) rotate(${s}deg)`,Ms.setAttribute("class","blocklyDropDownArrow")):Ms.style.display="none",t=Math.floor(e.initialX),o=Math.floor(e.initialY),s=Math.floor(e.finalX);const i=Math.floor(e.finalY);return Ke.style.left=t+"px",Ke.style.top=o+"px",Ke.style.display="block",Ke.style.opacity="1",Ke.style.transform="translate("+(s-t)+"px,"+(i-o)+"px)",!!e.arrowAtTop},Sc=function(){if(cs){var e=cs.getSourceBlock();e=Ug?bc(cs):_c(e);const t=e.left+(e.right-e.left)/2;Cc(t,e.bottom,t,e.top)}else nn()},Wi=function(e){return e.length?e.reduce(function(t,o){return t.length<o.length?t:o}).length:0},kc=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;let o=0;t=t||Wi(e);let s;for(s=0;s<t;s++){for(var i=e[0][s],n=1;n<e.length;n++)if(i!==e[n][s])return o;i===" "&&(o=s+1)}for(i=1;i<e.length;i++)if((n=e[i][s])&&n!==" ")return o;return t},Rc=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;let o=0;t=t||Wi(e);let s;for(s=0;s<t;s++){for(var i=e[0].substr(-s-1,1),n=1;n<e.length;n++)if(i!==e[n].substr(-s-1,1))return o;i===" "&&(o=s+1)}for(i=1;i<e.length;i++)if((n=e[i].charAt(e[i].length-s-1))&&n!==" ")return o;return t},r.wrap$$module$build$src$core$utils$string=function(e,t){e=e.split(`
6
- `);for(let o=0;o<e.length;o++)e[o]=s$(e[o],t);return e.join(`
7
- `)},s$=function(e,t){if(e.length<=t)return e;const o=e.trim().split(/\s+/);for(var s=0;s<o.length;s++)o[s].length>t&&(t=o[s].length);var i=-1/0;let n,d=1;do{s=i,n=e,e=[],i=o.length/d;let f=1;for(let L=0;L<o.length-1;L++)f<(L+1.5)/i?(f++,e[L]=!0):e[L]=!1;e=wc(o,e,t),i=ln(o,e,t),e=i$(o,e),d++}while(i>s);return n},ln=function(e,t,o){const s=[0],i=[];for(var n=0;n<e.length;n++)s[s.length-1]+=e[n].length,t[n]===!0?(s.push(0),i.push(e[n].charAt(e[n].length-1))):t[n]===!1&&s[s.length-1]++;for(e=Math.max(...s),t=0,n=0;n<s.length;n++)t-=Math.pow(Math.abs(o-s[n]),1.5)*2,t-=Math.pow(e-s[n],1.5),".?!".includes(i[n])?t+=o/3:",;)]}".includes(i[n])&&(t+=o/4);return s.length>1&&s[s.length-1]<=s[s.length-2]&&(t+=.5),t},wc=function(e,t,o){let s=ln(e,t,o),i;for(let n=0;n<t.length-1;n++){if(t[n]===t[n+1])continue;const d=[].concat(t);d[n]=!d[n],d[n+1]=!d[n+1];const f=ln(e,d,o);f>s&&(s=f,i=d)}return i?wc(e,i,o):t},i$=function(e,t){const o=[];for(let s=0;s<e.length;s++)o.push(e[s]),t[s]!==void 0&&o.push(t[s]?`
8
- `:" ");return o.join("")},r.isNumber$$module$build$src$core$utils$string=function(e){return/^\s*-?\d+(\.\d+)?\s*$/.test(e)},r$=function(e){qn=e},n$=function(){return qn},l$=function(){return pr},c$=function(){return at},ei=function(e){if(e=Oc(e)){for(e=e.tooltip;typeof e=="function";)e=e();if(typeof e!="string")throw Error("Tooltip function must return a string.");return e}return""},Oc=function(e){for(;e&&e.tooltip;){if(typeof e.tooltip=="string"||typeof e.tooltip=="function")return e;e=e.tooltip}return null},Nc=function(){document.querySelector(".blocklyTooltipDiv")||(at=document.createElement("div"),at.className="blocklyTooltipDiv",(Ae()||document.body).appendChild(at))},zi=function(e){e.mouseOverWrapper_=ae(e,"pointerover",null,u$),e.mouseOutWrapper_=ae(e,"pointerout",null,a$),e.addEventListener("pointermove",Lc,!1)},Ac=function(e){e&&(te(e.mouseOverWrapper_),te(e.mouseOutWrapper_),e.removeEventListener("pointermove",Lc))},u$=function(e){fi||(e=Oc(e.currentTarget),qt!==e&&(xo(),gr=null,qt=e),clearTimeout(Gg))},a$=function(e){fi||(Gg=setTimeout(function(){gr=qt=null,xo()},1),clearTimeout(Ds),Ds=0)},Lc=function(e){if(qt&&qt.tooltip&&!fi)if(pr){const t=wa-e.pageX;e=Oa-e.pageY,Math.sqrt(t*t+e*e)>Vg&&xo()}else gr!==qt&&(clearTimeout(Ds),wa=e.pageX,Oa=e.pageY,Ds=setTimeout(p$,Wg))},Mc=function(){gr=qt=null,xo()},xo=function(){pr&&(pr=!1,at&&(at.style.display="none")),Ds&&(clearTimeout(Ds),Ds=0)},Dc=function(){xo(),fi=!0},xc=function(){fi=!1},h$=function(){at&&qt&&(typeof qn=="function"?qn(at,qt):d$())},d$=function(){var e=ei(qt);e=r.wrap$$module$build$src$core$utils$string(e,Hg),e=e.split(`
9
- `);for(let t=0;t<e.length;t++){const o=document.createElement("div");o.appendChild(document.createTextNode(e[t])),at.appendChild(o)}},$$=function(e){const t=document.documentElement.clientWidth,o=document.documentElement.clientHeight;let s=wa;s=e?s-(Na+at.offsetWidth):s+Na;let i=Oa+Aa;return i+at.offsetHeight>o+window.scrollY&&(i-=at.offsetHeight+2*Aa),e?s=Math.max(Zn-window.scrollX,s):s+at.offsetWidth>t+window.scrollX-2*Zn&&(s=t-at.offsetWidth-2*Zn),{x:s,y:i}},p$=function(){if(!fi&&(gr=qt,at)){at.textContent="",h$();var e=qt.RTL;at.style.direction=e?"rtl":"ltr",at.style.display="block",pr=!0;var{x:t,y:o}=$$(e);at.style.left=t+"px",at.style.top=o+"px"}},Bc=function(){return La},g$=function(e){La=e},Pc=function(){return Ma},m$=function(e){Ma=e},Es=function(e){e=`${e}`.toLowerCase().trim();var t=zg[e];if(t||(t=e.substring(0,2)==="0x"?"#"+e.substring(2):e,t=t[0]==="#"?t:"#"+t,/^#[0-9a-f]{6}$/.test(t)))return t;if(/^#[0-9a-f]{3}$/.test(t))return["#",t[1],t[1],t[2],t[2],t[3],t[3]].join("");var o=e.match(/^(?:rgb)?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);return o&&(e=Number(o[1]),t=Number(o[2]),o=Number(o[3]),e>=0&&e<256&&t>=0&&t<256&&o>=0&&o<256)?Yi(e,t,o):null},Yi=function(e,t,o){return t=e<<16|t<<8|o,e<16?"#"+(16777216|t).toString(16).substr(1):"#"+t.toString(16)},cn=function(e){return e=Es(e),e?(e=parseInt(e.substr(1),16),[e>>16,e>>8&255,e&255]):[0,0,0]},un=function(e,t,o){let s=0,i=0,n=0;if(t===0)n=i=s=o;else{const d=Math.floor(e/60),f=e/60-d;e=o*(1-t);const L=o*(1-t*f);switch(t=o*(1-t*(1-f)),d){case 1:s=L,i=o,n=e;break;case 2:s=e,i=o,n=t;break;case 3:s=e,i=L,n=o;break;case 4:s=t,i=e,n=o;break;case 5:s=o,i=e,n=L;break;case 6:case 0:s=o,i=t,n=e}}return Yi(Math.floor(s),Math.floor(i),Math.floor(n))},ys=function(e,t,o){return e=Es(e),!e||(t=Es(t),!t)?null:(e=cn(e),t=cn(t),Yi(Math.round(t[0]+o*(e[0]-t[0])),Math.round(t[1]+o*(e[1]-t[1])),Math.round(t[2]+o*(e[2]-t[2]))))},Fc=function(e){return un(e,La,Ma*255)},an=function(e,t,o){const s=[];var i=e.split("");i.push("");var n=0;e=[];let d=null;for(let oe=0;oe<i.length;oe++){var f=i[oe];if(n===0)if(f==="%")(n=e.join(""))&&s.push(n),e.length=0,n=1;else if(o&&f===`
10
- `){const ze=e.join("");ze&&s.push(ze),e.length=0,s.push(f)}else e.push(f);else if(n===1)f==="%"?(e.push(f),n=0):t&&"0"<=f&&f<="9"?(n=2,d=f,(f=e.join(""))&&s.push(f),e.length=0):f==="{"?n=3:(e.push("%",f),n=0);else if(n===2)if("0"<=f&&f<="9")d+=f;else{var L=void 0;s.push(parseInt((L=d)!=null?L:"",10)),oe--,n=0}else n===3&&(f===""?(e.splice(0,0,"%{"),oe--,n=0):f!=="}"?e.push(f):(n=e.join(""),/[A-Z]\w*/i.test(n)?(f=n.toUpperCase(),(f=f.startsWith("BKY_")?f.substring(4):null)&&f in r.Msg$$module$build$src$core$msg?(n=r.Msg$$module$build$src$core$msg[f],typeof n=="string"?Array.prototype.push.apply(s,an(n,t,o)):t?s.push(`${n}`):s.push(n)):s.push("%{"+n+"}")):s.push("%{"+n+"}"),n=e.length=0))}for((t=e.join(""))&&s.push(t),L=[],e.length=0,i=0;i<s.length;i++)typeof s[i]!="string"||o&&s[i]===`
11
- `?((t=e.join(""))&&L.push(t),e.length=0,L.push(s[i])):e.push(s[i]);return(t=e.join(""))&&L.push(t),e.length=0,L},Uc=function(e){return an(e,!0,!0)},Je=function(e){return typeof e!="string"?e:(e=an(e,!1,!1),e.length?String(e[0]):"")},f$=function(e){let t=!0;const o=r.Msg$$module$build$src$core$msg,s=e.match(/%{BKY_[A-Z]\w*}/gi);if(s)for(let i=0;i<s.length;i++){const n=s[i].toUpperCase();o[n.slice(6,-1)]===void 0&&(console.warn("No message string for "+s[i]+" in "+e),t=!1)}return t},ti=function(e){const t=typeof e=="string"?Je(e):e;var o=Number(t);if(!isNaN(o)&&0<=o&&o<=360)return{hue:o,hex:un(o,Bc(),Pc()*255)};if(o=Es(t))return{hue:null,hex:o};throw o='Invalid colour: "'+t+'"',e!==t&&(o+=' (from "'+e+'")'),Error(o)},oi=function(){return Wt},_$=function(e){if(Wt=e,e===null){let t;(t=document.querySelector("."+Da))==null||t.remove()}},Hc=function(){const e=Ae()||document.body,t=document.querySelector("div."+Da);t?Wt=t:(Wt=document.createElement("div"),Wt.className=Da,Wt.tabIndex=-1),z(Wt,"keydown",null,S),e.appendChild(Wt)},hn=function(e,t,o,s,i=!0){if(si(),_i=e,Qn=o,o=Wt){if(o.style.direction=t?"rtl":"ltr",o.style.display="block",!s&&e instanceof we){let f;s=(f=e.getSourceBlock())==null?void 0:f.workspace}var n;Yg=(n=s)!=null?n:null;var d;e=(d=s)!=null?d:c(),bi=e.getRenderer().getClassName(),Ti=e.getTheme().getClassName(),bi&&G(o,bi),Ti&&G(o,Ti),i&&(el=r.getFocusManager$$module$build$src$core$focus_manager().takeEphemeralFocus(o))}},si=function(){if(Gc()){_i=null;var e=Wt;e&&(e.style.display="none",e.style.left="",e.style.top="",Qn&&(Qn(),Qn=null),e.textContent="",bi&&(Te(e,bi),bi=""),Ti&&(Te(e,Ti),Ti=""),c().markFocused(),el&&(el(),el=null))}},Gc=function(){return!!_i},vs=function(e){_i===e&&si()},Xi=function(e){let t=Yg===null,o=e;for(;!t&&o;){if(o===e){t=!0;break}o=e.options.parentWorkspace}t&&si()},Vc=function(e,t,o){Wt.style.left=e+"px",Wt.style.top=t+"px",Wt.style.height=o+"px"},Wc=function(e,t,o,s){const i=T$(e,t,o);e=b$(e,t,o,s),i<0?Vc(e,0,o.height+i):Vc(e,i,o.height)},b$=function(e,t,o,s){return s?Math.min(Math.max(t.right-o.width,e.left),e.right-o.width):Math.max(Math.min(t.left,e.right-o.width),e.left)},T$=function(e,t,o){return t.bottom+o.height>=e.bottom?t.top-o.height:t.bottom},E$=function(e){return!(e==null||!e.repositionForWindowResize)},zc=function(){E$(_i)&&_i.repositionForWindowResize()||si()},y$=function(){return tl},Yc=function(e){tl=e},ii=function(e,t,o,s,i){if(hn(Xg,o,Xc,s),t.length){i||(e instanceof PointerEvent?i=new P(e.clientX,e.clientY):(console.warn("Context menu opened with keyboard but no location given"),i=new P(0,0)));var n=v$(t,o,e,i);ol=n,I$(n,o,i),setTimeout(function(){n.focus()},1),tl=null}else ji()},v$=function(e,t,o,s){const i=new _a;i.setRole(Gt.MENU);for(let n=0;n<e.length;n++){const d=e[n];if(d.separator){i.addChild(new gg);continue}const f=new Gn(d.text);f.setRightToLeft(t),f.setRole(Gt.MENUITEM),i.addChild(f),f.setEnabled(d.enabled),d.enabled&&f.onAction(function(L,oe){ji(),requestAnimationFrame(()=>{setTimeout(()=>{d.callback(d.scope,o,oe,s)},0)})},{})}return i},I$=function(e,t,o){const s=Jl();o=new ye(o.y+s.top,o.y+s.top,o.x+s.left,o.x+s.left),C$(e);const i=e.getSize();t&&(o.left+=i.width,o.right+=i.width,s.left+=i.width,s.right+=i.width),Wc(s,o,i,t),e.focus()},C$=function(e){var t=oi();if(!t)throw Error("Attempting to create a context menu when widget div is null");t=e.render(t),G(t,"blocklyContextMenu"),z(t,"contextmenu",null,S$),e.focus()},S$=function(e){e.preventDefault(),e.stopPropagation()},ji=function(){vs(Xg),tl=null},Xc=function(){ol&&(ol.dispose(),ol=null)},r.callbackFactory$$module$build$src$core$contextmenu=function(e,t){return()=>{r.disable$$module$build$src$core$events$utils();let o;try{o=t instanceof Element?Is(t,e.workspace):Zs(t,e.workspace);const s=e.getRelativeToSurfaceXY();s.x=e.RTL?s.x-r.config$$module$build$src$core$config.snapRadius:s.x+r.config$$module$build$src$core$config.snapRadius,s.y+=r.config$$module$build$src$core$config.snapRadius*2,o.moveBy(s.x,s.y)}finally{r.enable$$module$build$src$core$events$utils()}return J()&&!o.isShadow()&&_(new(U(w.BLOCK_CREATE))(o)),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(o),o}},jc=function(e,t){return t=Ye(t,e.getParentSvg(),e.getInverseScreenCTM()),t.x/=e.scale,t.y/=e.scale,t},dn=function(e,t,o){t=jc(e,t),Kg.set(e,P.difference(o,t))},$n=function(e,t){if(t=jc(e,t),e=Kg.get(e),!e)throw Error("Drag not initialized");return P.sum(e,t)},k$=function(e,t=!1){const o=r.createElement$$module$build$src$core$utils$xml("xml");var s=Kc(r.allUsedVarModels$$module$build$src$core$variables(e));s.hasChildNodes()&&o.appendChild(s);for(const i of e.getTopComments())o.appendChild(Ki(i,t));for(e=e.getTopBlocks(!0),s=0;s<e.length;s++)o.appendChild(Ji(e[s],t));return o},Ki=function(e,t=!1){const o=r.createElement$$module$build$src$core$utils$xml("comment");t||o.setAttribute("id",e.id),t=e.workspace;const s=e.getRelativeToSurfaceXY();return s.x=t.RTL?t.getWidth()-s.x:s.x,o.setAttribute("x",`${s.x}`),o.setAttribute("y",`${s.y}`),o.setAttribute("w",`${e.getSize().width}`),o.setAttribute("h",`${e.getSize().height}`),e.getText()&&(o.textContent=e.getText()),e.isCollapsed()&&o.setAttribute("collapsed","true"),e.isOwnEditable()||o.setAttribute("editable","false"),e.isOwnMovable()||o.setAttribute("movable","false"),e.isOwnDeletable()||o.setAttribute("deletable","false"),o},Kc=function(e){const t=r.createElement$$module$build$src$core$utils$xml("variables");for(let o=0;o<e.length;o++){const s=e[o],i=r.createElement$$module$build$src$core$utils$xml("variable");i.appendChild(r.createTextNode$$module$build$src$core$utils$xml(s.getName())),s.getType()&&i.setAttribute("type",s.getType()),i.id=s.getId(),t.appendChild(i)}return t},Ji=function(e,t){if(e.isInsertionMarker()&&(e=e.getChildren(!1)[0],!e))return new DocumentFragment;let o=0;if(e.workspace.RTL&&(o=e.workspace.getWidth()),t=ts(e,t),eu(t)){const s=e.getRelativeToSurfaceXY();t.setAttribute("x",String(Math.round(e.workspace.RTL?o-s.x:s.x))),t.setAttribute("y",String(Math.round(s.y)))}return t},R$=function(e){if(e.isSerializable()){const t=r.createElement$$module$build$src$core$utils$xml("field");return t.setAttribute("name",e.name||""),e.toXml(t)}return null},w$=function(e,t){for(const o of e.getFields())(e=R$(o))&&t.appendChild(e)},ts=function(e,t){if(e.isInsertionMarker())return(t=e.getChildren(!1)[0])?ts(t):new DocumentFragment;const o=r.createElement$$module$build$src$core$utils$xml(e.isShadow()?"shadow":"block");if(o.setAttribute("type",e.type),t||(o.id=e.id),e.mutationToDom){var s=e.mutationToDom();s&&(s.hasChildNodes()||s.hasAttributes())&&o.appendChild(s)}if(w$(e,o),s=e.getCommentText()){var i=e.getIcon(ut.COMMENT),n=i.getBubbleSize(),d=i.bubbleIsVisible();i=i.getBubbleLocation();var f=r.createElement$$module$build$src$core$utils$xml("comment");f.appendChild(r.createTextNode$$module$build$src$core$utils$xml(s)),f.setAttribute("pinned",`${d}`),f.setAttribute("h",`${n.height}`),f.setAttribute("w",`${n.width}`),i&&(f.setAttribute("x",`${e.workspace.RTL?e.workspace.getWidth()-(i.x+n.width):i.x}`),f.setAttribute("y",`${i.y}`)),o.appendChild(f)}for(e.data&&(s=r.createElement$$module$build$src$core$utils$xml("data"),s.appendChild(r.createTextNode$$module$build$src$core$utils$xml(e.data)),o.appendChild(s)),s=0;s<e.inputList.length;s++){n=e.inputList[s];var L=void 0;d=!0,n.type!==r.inputTypes$$module$build$src$core$inputs$input_types.DUMMY&&n.type!==r.inputTypes$$module$build$src$core$inputs$input_types.END_ROW&&(i=n.connection.targetBlock(),n.type===r.inputTypes$$module$build$src$core$inputs$input_types.VALUE?L=r.createElement$$module$build$src$core$utils$xml("value"):n.type===r.inputTypes$$module$build$src$core$inputs$input_types.STATEMENT&&(L=r.createElement$$module$build$src$core$utils$xml("statement")),f=n.connection.getShadowDom(),!f||i&&i.isShadow()||L.appendChild(Jc(f,t)),i&&(i=ts(i,t),i.nodeType===Uo.ELEMENT_NODE&&(L.appendChild(i),d=!1)),L.setAttribute("name",n.name),d||o.appendChild(L))}e.inputsInline!==void 0&&e.inputsInline!==e.inputsInlineDefault&&o.setAttribute("inline",String(e.inputsInline)),e.isCollapsed()&&o.setAttribute("collapsed","true"),e.isEnabled()||o.setAttribute("disabled-reasons",Array.from(e.getDisabledReasons()).map(encodeURIComponent).join(",")),e.isOwnDeletable()||o.setAttribute("deletable","false"),e.isOwnMovable()||o.setAttribute("movable","false"),e.isOwnEditable()||o.setAttribute("editable","false"),L=e.getNextBlock();let oe;return L&&(s=ts(L,t),s.nodeType===Uo.ELEMENT_NODE&&(oe=r.createElement$$module$build$src$core$utils$xml("next"),oe.appendChild(s),o.appendChild(oe))),e=e.nextConnection&&e.nextConnection.getShadowDom(),!e||L&&L.isShadow()||oe.appendChild(Jc(e,t)),o},Jc=function(e,t){let o=e=e.cloneNode(!0),s;for(;o;)if(t&&o.nodeName==="shadow"&&o.removeAttribute("id"),o.firstChild)o=o.firstChild;else{for(;o&&!o.nextSibling;){s=o,o=o.parentNode;let i;s.nodeType===Uo.TEXT_NODE&&s.data.trim()===""&&((i=o)==null?void 0:i.firstChild)!==s&&ke(s)}o&&(s=o,o=o.nextSibling,s.nodeType===Uo.TEXT_NODE&&s.data.trim()===""&&ke(s))}return e},fo=function(e){return Xs(e).replace(/<(\w+)([^<]*)\/>/g,"<$1$2></$1>")},O$=function(e){e=fo(e).split("<");let t="";for(let o=1;o<e.length;o++){const s=e[o];s[0]==="/"&&(t=t.substring(2)),e[o]=t+"<"+s,s[0]!=="/"&&s.slice(-2)!=="/>"&&(t+=" ")}return e=e.join(`
12
- `),e=e.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1</$2>"),e.replace(/^\n/,"")},N$=function(e,t){return t.setResizesEnabled(!1),t.clear(),e=r.domToWorkspace$$module$build$src$core$xml(e,t),t.setResizesEnabled(!0),e},r.domToWorkspace$$module$build$src$core$xml=function(e,t){let o=0;t.RTL&&(o=t.getWidth());const s=[];eo();const i=r.getGroup$$module$build$src$core$events$utils();i||r.setGroup$$module$build$src$core$events$utils(!0),t.setResizesEnabled&&t.setResizesEnabled(!1);let n=!0;try{for(let d=0,f;f=e.childNodes[d];d++){const L=f.nodeName.toLowerCase(),oe=f;if(L==="block"||L==="shadow"&&!Ue()){const ze=Is(oe,t);s.push(ze.id);let Fe;const vt=parseInt((Fe=oe.getAttribute("x"))!=null?Fe:"10",10);let jo;const Ao=parseInt((jo=oe.getAttribute("y"))!=null?jo:"10",10);isNaN(vt)||isNaN(Ao)||ze.moveBy(t.RTL?o-vt:vt,Ao,["create"]),n=!1}else{if(L==="shadow")throw TypeError("Shadow block cannot be a top-level block.");if(L==="comment")qc(oe,t);else if(L==="variables"){if(n)Zc(oe,t);else throw Error("'variables' tag must exist once before block and shadow tag elements in the workspace XML, but it was found in another location.");n=!1}}}}finally{r.setGroup$$module$build$src$core$events$utils(i),t.setResizesEnabled&&t.setResizesEnabled(!0),t.rendered&&Qo(),to()}return _(new(U(w.FINISHED_LOADING))(t)),s},qc=function(e,t){var o;const s=(o=e.getAttribute("id"))!=null?o:void 0;o=t.rendered?new yo(t,s):new rl(t,s);var i;o.setText((i=e.textContent)!=null?i:"");var n;i=parseInt((n=e.getAttribute("x"))!=null?n:"",10);let d;n=parseInt((d=e.getAttribute("y"))!=null?d:"",10),isNaN(i)||isNaN(n)||(i=t.RTL?t.getWidth()-i:i,o.moveTo(new P(i,n)));var f;t=parseInt((f=e.getAttribute("w"))!=null?f:"",10);let L;return f=parseInt((L=e.getAttribute("h"))!=null?L:"",10),isNaN(t)||isNaN(f)||o.setSize(new ve(t,f)),e.getAttribute("collapsed")==="true"&&o.setCollapsed(!0),e.getAttribute("editable")==="false"&&o.setEditable(!1),e.getAttribute("movable")==="false"&&o.setMovable(!1),e.getAttribute("deletable")==="false"&&o.setDeletable(!1),o},A$=function(e,t){if(!t.getBlocksBoundingBox)return r.domToWorkspace$$module$build$src$core$xml(e,t);var o=t.getBlocksBoundingBox();if(e=r.domToWorkspace$$module$build$src$core$xml(e,t),o&&o.top!==o.bottom){var s=o.bottom;o=t.RTL?o.right:o.left;var i=1/0;let n=-1/0,d=1/0;for(let f=0;f<e.length;f++){const L=t.getBlockById(e[f]).getRelativeToSurfaceXY();L.y<d&&(d=L.y),L.x<i&&(i=L.x),L.x>n&&(n=L.x)}for(s=s-d+10,o=t.RTL?o-n:o-i,i=0;i<e.length;i++)t.getBlockById(e[i]).moveBy(o,s,["create"])}return e},r.domToBlock$$module$build$src$core$xml=function(e,t){return e=Is(e,t),t.rendered&&Qo(),e},Is=function(e,t){r.disable$$module$build$src$core$events$utils();var o=t.getAllVariables();let s;try{if(s=pn(e,t),t.rendered){const i=s,n=s.getDescendants(!1);i.setConnectionTracking(!1);for(let d=n.length-1;d>=0;d--)n[d].initSvg();for(let d=n.length-1;d>=0;d--)n[d].queueRender();setTimeout(function(){i.disposed||i.setConnectionTracking(!0)},1),t.resizeContents()}else{const i=s.getDescendants(!1);for(let n=i.length-1;n>=0;n--)i[n].initModel()}}finally{r.enable$$module$build$src$core$events$utils()}if(J()){for(e=Gi(t,o),t=0;t<e.length;t++)o=e[t],_(new(U(w.VAR_CREATE))(o));_(new(U(w.BLOCK_CREATE))(s))}return s},Zc=function(e,t){for(let s=0;s<e.children.length;s++){var o=e.children[s];const i=o.getAttribute("type"),n=o.getAttribute("id");if(o=o.textContent,!o)break;let d;t.getVariableMap().createVariable(o,(d=i)!=null?d:void 0,n)}},L$=function(e){const t={mutation:[],comment:[],data:[],field:[],input:[],next:[]};for(let o=0;o<e.children.length;o++){const s=e.children[o];if(s.nodeType!==Uo.TEXT_NODE)switch(s.nodeName.toLowerCase()){case"mutation":t.mutation.push(s);break;case"comment":t.comment.push(s);break;case"data":t.data.push(s);break;case"title":case"field":t.field.push(s);break;case"value":case"statement":t.input.push(s);break;case"next":t.next.push(s);break;default:console.warn("Ignoring unknown tag: "+s.nodeName)}}return t},M$=function(e,t){let o=!1;for(let s=0;s<e.length;s++){const i=e[s];t.domToMutation&&(t.domToMutation(i),t.initSvg&&(o=!0))}return o},D$=function(e,t){for(let o=0;o<e.length;o++){const s=e[o],i=s.textContent,n=s.getAttribute("pinned")==="true";let d;const f=parseInt((d=s.getAttribute("w"))!=null?d:"50",10);let L;const oe=parseInt((L=s.getAttribute("h"))!=null?L:"50",10);let ze,Fe=parseInt((ze=s.getAttribute("x"))!=null?ze:"",10),vt;const jo=parseInt((vt=s.getAttribute("y"))!=null?vt:"",10);t.setCommentText(i);const Ao=t.getIcon(ut.COMMENT);isNaN(f)||isNaN(oe)||Ao.setBubbleSize(new ve(f,oe)),Ao.setBubbleVisible(n),setTimeout(()=>{isNaN(Fe)||isNaN(jo)||(Fe=t.workspace.RTL?t.workspace.getWidth()-(Fe+f):Fe,Ao.setBubbleLocation(new P(Fe,jo))),Ao.setBubbleVisible(n)},1)}},x$=function(e,t){for(let o=0;o<e.length;o++)t.data=e[o].textContent},B$=function(e,t){for(let o=0;o<e.length;o++){const s=e[o],i=s.getAttribute("name");i?U$(t,i,s):console.warn(`Ignoring unnamed field in block ${t.type}`)}},Qc=function(e){let t=null,o=null;for(let s=0;s<e.childNodes.length;s++){const i=e.childNodes[s];eu(i)&&(i.nodeName.toLowerCase()==="block"?t=i:i.nodeName.toLowerCase()==="shadow"&&(o=i))}return{childBlockElement:t,childShadowElement:o}},P$=function(e,t,o,s){for(let n=0;n<e.length;n++){var i=e[n];const d=i.getAttribute("name"),f=d?o.getInput(d):null;if(!f){console.warn("Ignoring non-existent input "+d+" in block "+s);break}if(i=Qc(i),i.childBlockElement){if(!f.connection)throw TypeError("Input connection does not exist.");pn(i.childBlockElement,t,f.connection,!1)}if(i.childShadowElement){let L;(L=f.connection)==null||L.setShadowDom(i.childShadowElement)}}},F$=function(e,t,o){for(let s=0;s<e.length;s++){const i=Qc(e[s]);if(i.childBlockElement){if(!o.nextConnection)throw TypeError("Next statement does not exist.");if(o.nextConnection.isConnected())throw TypeError("Next statement is already connected.");pn(i.childBlockElement,t,o.nextConnection,!0)}i.childShadowElement&&o.nextConnection&&o.nextConnection.setShadowDom(i.childShadowElement)}},pn=function(e,t,o,s){var i;const n=e.getAttribute("type");if(!n)throw TypeError("Block type unspecified: "+e.outerHTML);var d=(i=e.getAttribute("id"))!=null?i:void 0;i=t.newBlock(n,d),d=L$(e);const f=M$(d.mutation,i);if(D$(d.comment,i),x$(d.data,i),o)if(s)if(i.previousConnection)o.connect(i.previousConnection);else throw TypeError("Next block does not have previous statement.");else if(i.outputConnection)o.connect(i.outputConnection);else if(i.previousConnection)o.connect(i.previousConnection);else throw TypeError("Child block does not have output or previous statement.");if(B$(d.field,i),P$(d.input,t,i,n),F$(d.next,t,i),f&&i.initSvg(),(t=e.getAttribute("inline"))&&i.setInputsInline(t==="true"),(t=e.getAttribute("disabled"))&&i.setDisabledReason(t==="true"||t==="disabled",Jt),t=e.getAttribute("disabled-reasons"),t!==null)for(var L of t.split(","))i.setDisabledReason(!0,decodeURIComponent(L));if((L=e.getAttribute("deletable"))&&i.setDeletable(L==="true"),(L=e.getAttribute("movable"))&&i.setMovable(L==="true"),(L=e.getAttribute("editable"))&&i.setEditable(L==="true"),(L=e.getAttribute("collapsed"))&&i.setCollapsed(L==="true"),e.nodeName.toLowerCase()==="shadow"){for(e=i.getChildren(!1),L=0;L<e.length;L++)if(!e[L].isShadow())throw TypeError("Shadow block not allowed non-shadow child.");i.setShadow(!0)}return i},U$=function(e,t,o){const s=e.getField(t);s?s.fromXml(o):console.warn("Ignoring non-existent field "+t+" in block "+e.type)},H$=function(e){for(let t=0;t<e.childNodes.length;t++){const o=e.childNodes[t];if(o.nodeName.toLowerCase()==="next"){e.removeChild(o);break}}},eu=function(e){return e.nodeType===Uo.ELEMENT_NODE},_o=function(e,t){l(M.FIELD,e,t)},G$=function(e){m(M.FIELD,e)},r.fromJson$$module$build$src$core$field_registry=function(e){return tm.fromJsonInternal(e)},V$=function(e){const t=D(M.FIELD,e.type);return t?t.fromJson(e):(console.warn("Blockly could not create a field of type "+e.type+". The field is probably not being registered. This could be because the file is not loaded, the field does not register itself (Issue #1584), or the registration is not being reached."),null)},ri=function(e){return e&&typeof e=="object"&&"src"in e&&typeof e.src=="string"&&"alt"in e&&typeof e.alt=="string"&&"width"in e&&typeof e.width=="number"&&"height"in e&&typeof e.height=="number"},r.register$$module$build$src$core$extensions=function(e,t){if(typeof e!="string"||e.trim()==="")throw Error('Error: Invalid extension name "'+e+'"');if(yi[e])throw Error('Error: Extension "'+e+'" is already registered.');if(typeof t!="function")throw Error('Error: Extension "'+e+'" must be a function');yi[e]=t},r.registerMixin$$module$build$src$core$extensions=function(e,t){if(!t||typeof t!="object")throw Error('Error: Mixin "'+e+'" must be a object');r.register$$module$build$src$core$extensions(e,function(){this.mixin(t)})},r.registerMutator$$module$build$src$core$extensions=function(e,t,o,s){const i='Error when registering mutator "'+e+'": ';su(i,t);const n=ou(t,i);if(o&&typeof o!="function")throw Error(i+'Extension "'+e+'" is not a function');r.register$$module$build$src$core$extensions(e,function(){n&&this.setMutator(new r.MutatorIcon$$module$build$src$core$icons$mutator_icon(s||[],this)),this.mixin(t),o&&o.apply(this)})},W$=function(e){tu(e)?delete yi[e]:console.warn('No extension mapping for name "'+e+'" found to unregister')},tu=function(e){return!!yi[e]},gn=function(e,t,o){const s=yi[e];if(typeof s!="function")throw Error('Error: Extension "'+e+'" not found.');let i;if(o?z$(e,t):i=fn(t),s.apply(t),o)su('Error after applying mutator "'+e+'": ',t);else if(!j$(i,t))throw Error('Error when applying extension "'+e+'": mutation properties changed when applying a non-mutator extension.')},z$=function(e,t){if(fn(t).length)throw Error('Error: tried to apply mutation "'+e+'" to a block that already has mutator functions. Block id: '+t.id)},Y$=function(e,t){return mn(e.mutationToDom,e.domToMutation,t+" mutationToDom/domToMutation")},X$=function(e,t){return mn(e.saveExtraState,e.loadExtraState,t+" saveExtraState/loadExtraState")},ou=function(e,t){return mn(e.compose,e.decompose,t+" compose/decompose")},mn=function(e,t,o){if(e&&t){if(typeof e!="function"||typeof t!="function")throw Error(o+" must be a function");return!0}if(!e&&!t)return!1;throw Error(o+"Must have both or neither functions")},su=function(e,t){const o=Y$(t,e),s=X$(t,e);if(!o&&!s)throw Error(e+"Mutations must contain either XML hooks, or JSON hooks, or both");ou(t,e)},fn=function(e){const t=[];return e.domToMutation!==void 0&&t.push(e.domToMutation),e.mutationToDom!==void 0&&t.push(e.mutationToDom),e.saveExtraState!==void 0&&t.push(e.saveExtraState),e.loadExtraState!==void 0&&t.push(e.loadExtraState),e.compose!==void 0&&t.push(e.compose),e.decompose!==void 0&&t.push(e.decompose),t},j$=function(e,t){if(t=fn(t),t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(e[o]!==t[o])return!1;return!0},K$=function(e){if(typeof document!="object")throw Error("runAfterPageLoad() requires browser document.");if(document.readyState==="complete")e();else{const t=setInterval(function(){document.readyState==="complete"&&(clearInterval(t),e())},10)}},r.buildTooltipForDropdown$$module$build$src$core$extensions=function(e,t){const o=[];return function(){o.includes(this.type)||(J$(this,e,t),o.push(this.type)),this.setTooltip((function(){const s=String(this.getFieldValue(e));return Je(t[s])}).bind(this))}},J$=function(e,t,o){var s=e.getField(t);if(s instanceof yt&&!s.isOptionListDynamic()){s=s.getOptions();for(const i of s)i!==yt.SEPARATOR&&([,s]=i,o[s]===void 0&&console.warn(`No tooltip mapping for value ${s} of field ${t} of block type ${e.type}.`))}},r.buildTooltipWithFieldText$$module$build$src$core$extensions=function(e,t){return function(){this.setTooltip((function(){const o=this.getField(t);return Je(e).replace("%1",o?o.getText():"")}).bind(this))}},q$=function(){const e=this.tooltip;this.setTooltip((function(){const t=this.getParent();return t&&t.getInputsInline()&&t.tooltip||e}).bind(this))},se=function(e,t){return" "+e+","+t+" "},Pt=function(e,t){return" "+e+t.join("")},gt=function(e,t){return" M "+e+","+t+" "},je=function(e,t){return" m "+e+","+t+" "},bo=function(e,t){return" l "+e+","+t+" "},ni=function(e){return" l"+e.join("")},re=function(e,t){return" "+e+" "+t+" "},qe=function(e,t,o,s){return e+" "+o+" "+o+" "+t+s},Z$=function(e,t){if(!e||!t)throw Error("Cannot connect null connections.");e.targetConnection=t,t.targetConnection=e},Q$=function(e,t){let o=null;t=t.outputConnection;const s=t?.getConnectionChecker();for(let i=0,n;n=e.inputList[i];i++){const d=n.connection;let f;if(d&&((f=s)!=null&&f.canConnect(t,d,!1))){if(o)return null;o=d}}return o},ep=function(e,t){let o;for(;o=Q$(e,t);)if(e=o.targetBlock(),!e||e.isShadow())return o;return null},iu=function(e){return oo(e)&&typeof e.getType=="function"&&typeof e.initView=="function"&&typeof e.dispose=="function"&&typeof e.getWeight=="function"&&typeof e.getSize=="function"&&typeof e.applyColour=="function"&&typeof e.hideForInsertionMarker=="function"&&typeof e.updateEditable=="function"&&typeof e.updateCollapsed=="function"&&typeof e.isShownWhenCollapsed=="function"&&typeof e.setOffsetInBlock=="function"&&typeof e.onLocationChange=="function"&&typeof e.onClick=="function"},tp=function(e){return iu(e)&&Ts(e)&&Ui(e)&&typeof e.setText=="function"&&typeof e.getText=="function"&&typeof e.setBubbleSize=="function"&&typeof e.getBubbleSize=="function"&&typeof e.setBubbleLocation=="function"&&typeof e.getBubbleLocation=="function"&&e.getType()===ut.COMMENT},_n=function(e){if(!(e.getDescendants(!1).length>100)){var t=e.workspace,o=e.getSvgRoot();t.getAudioManager().play("delete");var s=e.getRelativeToSurfaceXY(),i=o.cloneNode(!0);i.setAttribute("transform","translate("+s.x+","+s.y+")");var n;(n=t.getLayerManager())==null||n.appendToAnimationLayer({getSvgRoot:()=>i}),ru(i,{x:s.x,y:s.y,width:e.width,height:e.height},t.RTL,new Date)}},ru=function(e,t,o,s){const i=(new Date().getTime()-s.getTime())/150;i>1?ke(e):(e.setAttribute("transform","translate("+(t.x+(o?-1:1)*t.width/2*i)+","+(t.y+t.height/2*i)+") scale("+(1-i)+")"),setTimeout(ru,10,e,t,o,s))},nu=function(e){var t=e.workspace;const o=t.scale;if(t.getAudioManager().play("click"),!(o<1)){var s=t.getSvgXY(e.getSvgRoot());e.outputConnection?(s.x+=(e.RTL?3:-3)*o,s.y+=13*o):e.previousConnection&&(s.x+=(e.RTL?-23:23)*o,s.y+=3*o);var i=v(R.CIRCLE,{cx:s.x,cy:s.y,r:0,fill:"none",stroke:"#888","stroke-width":10},t.getParentSvg());e=v(R.ANIMATE,{id:"animationCircle",begin:"indefinite",attributeName:"r",dur:"150ms",from:0,to:25*o},i),t=v(R.ANIMATE,{id:"animationOpacity",begin:"indefinite",attributeName:"opacity",dur:"150ms",from:1,to:0},i),e.beginElement(),t.beginElement(),setTimeout(()=>void ke(i),150)}},lu=function(e){if(li(),e.workspace.getAudioManager().play("disconnect"),!(e.workspace.scale<1)){var t=e.getHeightWidth().height;t=Math.atan(10/t)/Math.PI*180,e.RTL||(t*=-1),br=e,cu(e,t,new Date,0)}},cu=function(e,t,o,s){const i=[.66,1,.66,0,-.66,-1,-.66,0];let n="";o.getTime()+200>new Date().getTime()&&(n=`skewX(${Math.round(i[s%i.length]*t)})`,al=setTimeout(cu,15,e,t,o,s+1)),e.getSvgRoot().setAttribute("transform",`${e.getTranslation()} ${n}`)},li=function(){br&&(al&&(clearTimeout(al),al=null),br.getSvgRoot().setAttribute("transform",br.getTranslation()),br=null)},op=function(e,t){const o=e.workspace,s=r.config$$module$build$src$core$config.snapRadius,i=P.difference(t,e.getRelativeToSurfaceXY()),n=new P(0,0),d=o.getAllBlocks(!1).filter(f=>f.id!=e.id).map(f=>f.getRelativeToSurfaceXY());for(;sp(P.sum(t,n),d)||ip(e,P.sum(i,n),s);)o.RTL?n.translate(-s,s*2):n.translate(s,s*2);e.moveTo(P.sum(t,n))},sp=function(e,t){return t.some(o=>Math.abs(o.x-e.x)<=1&&Math.abs(o.y-e.y)<=1)},ip=function(e,t,o){return e.getConnections_(!1).some(s=>!!s.closest(o,t).connection)},ci=function(e,t,o){const s=o.getBoundingRectangle(),i=s.right-s.left,n=Qs(t.top,s.top,t.top+t.height-(s.bottom-s.top))-s.top;let d=t.left;return t=t.left+t.width-i,e.RTL?d=Math.min(t,d):t=Math.max(d,t),(e=Qs(d,s.left,t)-s.left)||n?(o.moveBy(e,n,["inbounds"]),!0):!1},uu=function(e){return t=>{var o=e.getMetricsManager();if(o.hasFixedEdges()&&!e.isDragging()){var s;if(Xp.includes((s=t.type)!=null?s:"")){s=o.getScrollMetrics(!0);const i=rp(e,t);i&&(o=r.getGroup$$module$build$src$core$events$utils()||!1,r.setGroup$$module$build$src$core$events$utils(t.group),ci(e,s,i)&&!t.group&&console.warn("Moved object in bounds but there was no event group. This may break undo."),r.setGroup$$module$build$src$core$events$utils(o))}else St(t)&&t.scale&&t.oldScale&&t.scale>t.oldScale&&bn(e)}}},rp=function(e,t){let o=null;switch(t.type){case w.BLOCK_CREATE:case w.BLOCK_MOVE:(o=e.getBlockById(t.blockId))&&(o=o.getRootBlock());break;case w.COMMENT_CREATE:case w.COMMENT_MOVE:case w.COMMENT_RESIZE:o=e.getCommentById(t.commentId)}return o},bn=function(e){var t=e.getMetricsManager();if(t.hasFixedEdges()&&!e.isDragging()){t=t.getScrollMetrics(!0);var o=e.getTopBoundedElements();for(let s=0,i;i=o[s];s++)ci(e,t,i)}},Kt=function(e){return e&&typeof e.isDeletable=="function"&&typeof e.dispose=="function"&&typeof e.setDeleteStyle=="function"},au=function(e,t){const o=e.getIcons();for(const s of e.inputList){if(!s.isVisible())continue;o.push(...s.fieldRow);let i;if((i=s.connection)!=null&&i.targetBlock())if(e=s.connection.targetBlock(),s.connection.type!==Z.NEXT_STATEMENT||t)o.push(e);else{let n;(e=(n=e.lastConnectionInStack(!1))==null?void 0:n.getSourceBlock())&&o.push(e)}else{let n;((n=s.connection)==null?void 0:n.type)===Z.INPUT_VALUE&&o.push(s.connection)}}return o},ui=function(e,t){const o=e.workspace.getTopBoundedElements(!0).filter(i=>oo(i));e=o.indexOf(e instanceof Be?e.getRootBlock():e)+t;let s=null;if(e>=0&&e<o.length?s=o[e]:e<0?s=o[o.length-1]:e>=o.length&&(s=o[0]),t<0&&s instanceof Be){let i,n;return(n=(i=s.lastConnectionInStack(!1))==null?void 0:i.getSourceBlock())!=null?n:s}return s},ro=function(e,t){var o;let s;const i=e instanceof Be?(s=(o=e.outputConnection)==null?void 0:o.targetBlock())!=null?s:e.getSurroundParent():e.getSourceBlock();return!(i instanceof Be)||(o=au(i,t>0),e=o.indexOf(e),e===-1)?null:(t=e+t,t>=0&&t<o.length?o[t]:null)},ai=function(e){return e&&typeof e.getRelativeToSurfaceXY=="function"&&typeof e.isMovable=="function"&&typeof e.startDrag=="function"&&typeof e.drag=="function"&&typeof e.endDrag=="function"&&typeof e.revertDrag=="function"},hu=function(e){return e&&typeof e.autoHide=="function"},du=function(e,t){l(M.ICON,e.toString(),t)},np=function(e){m(M.ICON,e)},os=function(e){return typeof e.getProcedureModel=="function"&&typeof e.doProcedureUpdate=="function"&&typeof e.isProcedureDef=="function"},Tn=function(e){return e&&typeof e.startPublishing=="function"&&typeof e.stopPublishing=="function"},qi=function(e){const t=e.getProcedureMap().getProcedures().filter(s=>!s.getReturnTypes()).map(s=>[s.getName(),s.getParameters().map(i=>i.getName()),!1]);e.getBlocksByType("procedures_defnoreturn",!1).forEach(s=>{!os(s)&&Ks(s)&&t.push(s.getProcedureDef())});const o=e.getProcedureMap().getProcedures().filter(s=>!!s.getReturnTypes()).map(s=>[s.getName(),s.getParameters().map(i=>i.getName()),!0]);return e.getBlocksByType("procedures_defreturn",!1).forEach(s=>{!os(s)&&Ks(s)&&o.push(s.getProcedureDef())}),t.sort($u),o.sort($u),[t,o]},$u=function(e,t){return e[0].localeCompare(t[0],void 0,{sensitivity:"base"})},r.findLegalName$$module$build$src$core$procedures=function(e,t){if(t.isInFlyout)return e;for(e=e||r.Msg$$module$build$src$core$msg.UNNAMED_KEY||"unnamed";!lp(e,t.workspace,t);){const o=e.match(/^(.*?)(\d+)$/);e=o?o[1]+(parseInt(o[2])+1):e+"2"}return e},lp=function(e,t,o){return!pu(e,t,o)},pu=function(e,t,o){for(const s of t.getAllBlocks(!1))if(s!==o&&Ks(s)&&r.Names$$module$build$src$core$names.equals(s.getProcedureDef()[0],e))return!0;o=o&&os(o)?o?.getProcedureModel():void 0;for(const s of t.getProcedureMap().getProcedures())if(s!==o&&r.Names$$module$build$src$core$names.equals(s.getName(),e))return!0;return!1},r.rename$$module$build$src$core$procedures=function(e){var t=this.getSourceBlock();if(!t)throw new tt;e=e.trim();const o=r.findLegalName$$module$build$src$core$procedures(e,t);os(t)&&!t.isInsertionMarker()&&t.getProcedureModel().setName(o);const s=this.getValue();if(s!==e&&s!==o)for(e=t.workspace.getAllBlocks(!1),t=0;t<e.length;t++){const i=e[t];i.renameProcedure&&i.renameProcedure(s,o)}return o},cp=function(e){function t(n,d){for(let L=0;L<n.length;L++){var f=n[L][0];const oe=n[L][1],ze=r.createElement$$module$build$src$core$utils$xml("block");ze.setAttribute("type",d),ze.setAttribute("gap","16");const Fe=r.createElement$$module$build$src$core$utils$xml("mutation");for(Fe.setAttribute("name",f),ze.appendChild(Fe),f=0;f<oe.length;f++){const vt=r.createElement$$module$build$src$core$utils$xml("arg");vt.setAttribute("name",oe[f]),Fe.appendChild(vt)}o.push(ze)}}const o=[];if(Ge.procedures_defnoreturn){var s=r.createElement$$module$build$src$core$utils$xml("block");s.setAttribute("type","procedures_defnoreturn"),s.setAttribute("gap","16");var i=r.createElement$$module$build$src$core$utils$xml("field");i.setAttribute("name","NAME"),i.appendChild(r.createTextNode$$module$build$src$core$utils$xml(r.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_PROCEDURE)),s.appendChild(i),o.push(s)}return Ge.procedures_defreturn&&(s=r.createElement$$module$build$src$core$utils$xml("block"),s.setAttribute("type","procedures_defreturn"),s.setAttribute("gap","16"),i=r.createElement$$module$build$src$core$utils$xml("field"),i.setAttribute("name","NAME"),i.appendChild(r.createTextNode$$module$build$src$core$utils$xml(r.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_PROCEDURE)),s.appendChild(i),o.push(s)),Ge.procedures_ifreturn&&(s=r.createElement$$module$build$src$core$utils$xml("block"),s.setAttribute("type","procedures_ifreturn"),s.setAttribute("gap","16"),o.push(s)),o.length&&o[o.length-1].setAttribute("gap","24"),e=qi(e),t(e[0],"procedures_callnoreturn"),t(e[1],"procedures_callreturn"),o},En=function(e){return gu(e,!1)},gu=function(e,t=!0){function o(i,n){for(const[d,f]of i)s.push({kind:"block",type:n,gap:16,extraState:{name:d,params:f}})}if(t)return pt("The XML return value of Blockly.Procedures.flyoutCategory()","v12","v13","the same method, but handle a return type of FlyoutItemInfo[] (JSON) instead."),cp(e);const s=[];return Ge.procedures_defnoreturn&&s.push({kind:"block",type:"procedures_defnoreturn",gap:16,fields:{NAME:r.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_PROCEDURE}}),Ge.procedures_defreturn&&s.push({kind:"block",type:"procedures_defreturn",gap:16,fields:{NAME:r.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_PROCEDURE}}),Ge.procedures_ifreturn&&s.push({kind:"block",type:"procedures_ifreturn",gap:16}),s.length&&(s[s.length-1].gap=24),e=qi(e),o(e[0],"procedures_callnoreturn"),o(e[1],"procedures_callreturn"),s},mu=function(e){var t=[],o=e.getBlocksByType("procedures_mutatorarg",!1);for(let n=0,d;d=o[n];n++)t.push(d.getFieldValue("NAME"));o=r.createElement$$module$build$src$core$utils$xml("xml");const s=r.createElement$$module$build$src$core$utils$xml("block");s.setAttribute("type","procedures_mutatorarg");const i=r.createElement$$module$build$src$core$utils$xml("field");i.setAttribute("name","NAME"),t=Zr(r.DEFAULT_ARG$$module$build$src$core$procedures,t),t=r.createTextNode$$module$build$src$core$utils$xml(t),i.appendChild(t),s.appendChild(i),o.appendChild(s),e.updateToolbox(o)},fu=function(e){if($t(e)&&e.bubbleType==="mutator"&&e.isOpen&&e.blockId){e=ct(e.workspaceId).getBlockById(e.blockId);var t=e.type;(t==="procedures_defnoreturn"||t==="procedures_defreturn")&&(e=e.getIcon(r.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE).getWorkspace(),mu(e),e.addChangeListener(up))}},up=function(e){(bt(e)||Bt(e)||Ct(e)||nt(e))&&(e=ct(e.workspaceId),mu(e))},_u=function(e,t){return t.getAllBlocks(!1).filter(o=>ap(o,e)||Od(o)&&r.Names$$module$build$src$core$names.equals(o.getProcedureCall(),e))},ap=function(e,t){return os(e)&&!e.isProcedureDef()&&e.getProcedureModel()&&r.Names$$module$build$src$core$names.equals(e.getProcedureModel().getName(),t)},r.mutateCallers$$module$build$src$core$procedures=function(e){const t=Ue();var o=e.getProcedureDef()[0];const s=e.mutationToDom(!0);e=_u(o,e.workspace);for(let n=0,d;d=e[n];n++){o=(o=d.mutationToDom())&&Xs(o),d.domToMutation&&d.domToMutation(s);var i=d.mutationToDom();i=i&&Xs(i),o!==i&&(r.setRecordUndo$$module$build$src$core$events$utils(!1),_(new(U(w.BLOCK_CHANGE))(d,"mutation",null,o,i)),r.setRecordUndo$$module$build$src$core$events$utils(t))}},r.getDefinition$$module$build$src$core$procedures=function(e,t){for(const o of t.getAllBlocks(!1))if(os(o)&&o.isProcedureDef()&&r.Names$$module$build$src$core$names.equals(o.getProcedureModel().getName(),e)||Ks(o)&&r.Names$$module$build$src$core$names.equals(o.getProcedureDef()[0],e))return o;return null},yn=function(e){return e.isDynamic},hp=function(e){return e.pathDown!==void 0&&e.pathUp!==void 0},dp=function(e){return e.pathLeft!==void 0&&e.pathRight!==void 0},Zi=function(e,t){l(M.RENDERER,e,t)},$p=function(e){m(M.RENDERER,e)},bu=function(e,t,o){return e=new(A(M.RENDERER,e))(e),e.init(t,o),e},vn=function(e){_s(e.getTargetWorkspace(),void 0,"String")},In=function(e){_s(e.getTargetWorkspace(),void 0,"Number")},Cn=function(e){_s(e.getTargetWorkspace(),void 0,"Colour")},Sn=function(e){return Tu(e,!1)},Tu=function(e,t=!0){return Ge.variables_set_dynamic||Ge.variables_get_dynamic||console.warn("There are no dynamic variable blocks, but there is a dynamic variable category."),t?(pt("The XML return value of Blockly.VariablesDynamic.flyoutCategory()","v12","v13","the same method, but handle a return type of FlyoutItemInfo[] (JSON) instead."),pp(e)):(e.registerButtonCallback("CREATE_VARIABLE_STRING",vn),e.registerButtonCallback("CREATE_VARIABLE_NUMBER",In),e.registerButtonCallback("CREATE_VARIABLE_COLOUR",Cn),[{kind:"button",text:r.Msg$$module$build$src$core$msg.NEW_STRING_VARIABLE,callbackkey:"CREATE_VARIABLE_STRING"},{kind:"button",text:r.Msg$$module$build$src$core$msg.NEW_NUMBER_VARIABLE,callbackkey:"CREATE_VARIABLE_NUMBER"},{kind:"button",text:r.Msg$$module$build$src$core$msg.NEW_COLOUR_VARIABLE,callbackkey:"CREATE_VARIABLE_COLOUR"},...qr(e,e.getVariableMap().getAllVariables(),!1,"variables_get_dynamic","variables_set_dynamic")])},pp=function(e){let t=[],o=document.createElement("button");return o.setAttribute("text",r.Msg$$module$build$src$core$msg.NEW_STRING_VARIABLE),o.setAttribute("callbackKey","CREATE_VARIABLE_STRING"),t.push(o),o=document.createElement("button"),o.setAttribute("text",r.Msg$$module$build$src$core$msg.NEW_NUMBER_VARIABLE),o.setAttribute("callbackKey","CREATE_VARIABLE_NUMBER"),t.push(o),o=document.createElement("button"),o.setAttribute("text",r.Msg$$module$build$src$core$msg.NEW_COLOUR_VARIABLE),o.setAttribute("callbackKey","CREATE_VARIABLE_COLOUR"),t.push(o),e.registerButtonCallback("CREATE_VARIABLE_STRING",vn),e.registerButtonCallback("CREATE_VARIABLE_NUMBER",In),e.registerButtonCallback("CREATE_VARIABLE_COLOUR",Cn),e=Eu(e),t=t.concat(e)},Eu=function(e){e=e.getVariableMap().getAllVariables();const t=[];if(e.length>0){if(Ge.variables_set_dynamic){var o=e[e.length-1];const s=r.createElement$$module$build$src$core$utils$xml("block");s.setAttribute("type","variables_set_dynamic"),s.setAttribute("gap","24"),s.appendChild(bs(o)),t.push(s)}if(Ge.variables_get_dynamic){e.sort(Js);for(let s=0,i;i=e[s];s++)o=r.createElement$$module$build$src$core$utils$xml("block"),o.setAttribute("type","variables_get_dynamic"),o.setAttribute("gap","8"),o.appendChild(bs(i)),t.push(o)}}return t},kn=function(e,t){const o=e.toCopyData();return Sr=o,kr=Do(e)&&e.workspace instanceof At?e.workspace:null,Sl=t,o},Rn=function(){return Sr},gp=function(e){Sr=e},wn=function(){return kr},mp=function(e){kr=e},yu=function(){return Sl},fp=function(e){Sl=e},ss=function(e,t,o){return e&&t?vu(e,t,o):Sr&&kr?vu(Sr,kr,Sl):null},vu=function(e,t,o){let s;t=t.isMutator?t:(s=t.options.parentWorkspace)!=null?s:t;let i,n;return(n=(i=D(M.PASTER,e.paster,!1))==null?void 0:i.paste(e,t,o))!=null?n:null},Qi=function(e){return e&&typeof e.toCopyData=="function"},Iu=function(){Pe.registry.register({name:ko.ESCAPE,preconditionFn(e){return!e.isReadOnly()},callback(e){return e.hideChaff(),!0},keyCodes:[Le.ESC]})},Cu=function(){Pe.registry.register({name:ko.DELETE,preconditionFn(e,t){return t=t.focusedNode,!e.isReadOnly()&&t!=null&&Kt(t)&&t.isDeletable()&&!e.isDragging()&&!r.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()},callback(e,t,o,s){return t.preventDefault(),e=s.focusedNode,e instanceof Be?e.checkAndDelete():Kt(e)&&e.isDeletable()&&(r.setGroup$$module$build$src$core$events$utils(!0),e.dispose(),r.setGroup$$module$build$src$core$events$utils(!1)),!0},keyCodes:[Le.DELETE,Le.BACKSPACE]})},On=function(e){return Qi(e)&&Kt(e)&&ai(e)?e.isCopyable?e.isCopyable():e instanceof Be||e instanceof yo?e.isOwnDeletable()&&e.isOwnMovable():e.isDeletable()&&e.isMovable():!1},Su=function(e){return On(e)&&Kt(e)&&e.isDeletable()},ku=function(){const e=Pe.registry.createSerializedKey(Le.C,[Le.CTRL]),t=Pe.registry.createSerializedKey(Le.C,[Le.META]);Pe.registry.register({name:ko.COPY,preconditionFn(o,s){return s=s.focusedNode,o=o.isFlyout?o.targetWorkspace:o,!!s&&!!o&&!o.isDragging()&&!r.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()&&On(s)},callback(o,s,i,n){return s.preventDefault(),s=n.focusedNode,!s||!Qi(s)||!On(s)||(o=o.isFlyout?o.targetWorkspace:o,!o)?!1:(s.workspace.isFlyout||o.hideChaff(),o=ai(s)&&s.workspace==o?s.getRelativeToSurfaceXY():void 0,!!kn(s,o))},keyCodes:[e,t]})},Ru=function(){const e=Pe.registry.createSerializedKey(Le.X,[Le.CTRL]),t=Pe.registry.createSerializedKey(Le.X,[Le.META]);Pe.registry.register({name:ko.CUT,preconditionFn(o,s){return s=s.focusedNode,!!s&&!o.isReadOnly()&&!o.isDragging()&&!r.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()&&Su(s)},callback(o,s,i,n){return o=n.focusedNode,!o||!Su(o)||!Qi(o)?!1:(s=ai(o)?o.getRelativeToSurfaceXY():void 0,s=kn(o,s),o instanceof Be?o.checkAndDelete():Kt(o)&&o.dispose(),!!s)},keyCodes:[e,t]})},wu=function(){const e=Pe.registry.createSerializedKey(Le.V,[Le.CTRL]),t=Pe.registry.createSerializedKey(Le.V,[Le.META]);Pe.registry.register({name:ko.PASTE,preconditionFn(){var o=wn();return!o||!o.rendered?!1:(o=o.isFlyout?o.targetWorkspace:o,!!Rn()&&!!o&&!o.isReadOnly()&&!o.isDragging()&&!r.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken())},callback(o,s){if(o=Rn(),!o)return!1;var i=wn();if(!i||(i=i.isFlyout?i.targetWorkspace:i,!i||i.isReadOnly()))return!1;if(s instanceof PointerEvent)return s=Zl(i,new P(s.clientX,s.clientY)),!!ss(o,i,s);if(s=yu(),!s)return!!ss(o,i);const{left:n,top:d,width:f,height:L}=i.getMetricsManager().getViewMetrics(!0);return new ye(d,d+L,n,n+f).contains(s.x,s.y)?!!ss(o,i):(s=new P(n+f/2,d+L/2),!!ss(o,i,s))},keyCodes:[e,t]})},Ou=function(){const e=Pe.registry.createSerializedKey(Le.Z,[Le.CTRL]),t=Pe.registry.createSerializedKey(Le.Z,[Le.META]);Pe.registry.register({name:ko.UNDO,preconditionFn(o){return!o.isReadOnly()&&!o.isDragging()&&!r.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()},callback(o,s){return o.hideChaff(),o.undo(!1),s.preventDefault(),!0},keyCodes:[e,t]})},Nu=function(){const e=Pe.registry.createSerializedKey(Le.Z,[Le.CTRL,Le.SHIFT]),t=Pe.registry.createSerializedKey(Le.Z,[Le.META,Le.SHIFT]),o=Pe.registry.createSerializedKey(Le.Y,[Le.CTRL]);Pe.registry.register({name:ko.REDO,preconditionFn(s){return!s.isDragging()&&!s.isReadOnly()&&!r.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()},callback(s,i){return s.hideChaff(),s.undo(!0),i.preventDefault(),!0},keyCodes:[e,t,o]})},Au=function(){Iu(),Cu(),ku(),Ru(),wu(),Ou(),Nu()},Lu=function(e){const t=e.saveState();return e.getParameters().length&&(t.parameters=e.getParameters().map(o=>o.saveState())),t},Mu=function(e,t,o,s){if(e=e.loadState(o,s),!o.parameters)return e;for(const[i,n]of o.parameters.entries())e.insertParameter(t.loadState(n,s),i);return e},_p=function(e){const t=Object.create(null),o=H(M.SERIALIZER,!0);for(const s in o){let i;const n=(i=o[s])==null?void 0:i.save(e);n&&(t[s]=n)}return t},bp=function(e,t,{recordUndo:o=!1}={}){var s=H(M.SERIALIZER,!0);if(s){s=Object.entries(s).sort((n,d)=>d[1].priority-n[1].priority);var i=Ue();r.setRecordUndo$$module$build$src$core$events$utils(o),(o=r.getGroup$$module$build$src$core$events$utils())||r.setGroup$$module$build$src$core$events$utils(!0),eo(),t instanceof At&&t.setResizesEnabled(!1);for(const[,n]of s.reverse()){let d;(d=n)==null||d.clear(t)}for(const[n,d]of s.reverse())if(e[n]){let f;(f=d)==null||f.load(e[n],t)}t instanceof At&&t.setResizesEnabled(!0),to(),_(new(U(w.FINISHED_LOADING))(t)),r.setGroup$$module$build$src$core$events$utils(o),r.setRecordUndo$$module$build$src$core$events$utils(i)}},Tp=function(e,t){let o=null;o=typeof e=="string"?document.getElementById(e)||document.querySelector(e):e;var s;if(!document.contains(o)&&document!==((s=o)==null?void 0:s.ownerDocument))throw Error("Error: container is not in current document");e=new vo(t||{}),s=document.createElement("div"),G(s,"injectionDiv"),t!=null&&t.rtl&&G(s,"blocklyRTL"),o.appendChild(s),t=Ep(s,e);const i=yp(s,t,e);return vp(i),p(i),$o(i),s.addEventListener("focusin",function(){p(i)}),z(s,"keydown",null,S),i},Ep=function(e,t){e.setAttribute("dir","LTR"),pe(t.hasCss,t.pathToMedia);const o=v(R.SVG,{xmlns:or,"xmlns:html":To,"xmlns:xlink":Ht,version:"1.1",class:"blocklySvg"},e),s=v(R.DEFS,{},o),i=String(Math.random()).substring(2);return t.gridPattern=Ka.createDom(i,t.gridOptions,s,e),o},yp=function(e,t,o){o.parentWorkspace=null,o=new At(o);const s=o.options;o.scale=s.zoomOptions.startScale,t.appendChild(o.createDom("blocklyMainBackground",e));var i=o.getRenderer().getClassName();return i&&G(e,i),(i=o.getTheme().getClassName())&&G(e,i),!s.hasCategories&&s.languageTree&&(e=o.addFlyout(R.SVG),Qt(e,t)),s.hasTrashcan&&o.addTrashcan(),s.zoomOptions&&s.zoomOptions.controls&&o.addZoomControls(),o.getThemeManager().subscribe(t,"workspaceBackgroundColour","background-color"),o.translate(0,0),o.addChangeListener(uu(o)),$o(o),Hc(),tn(),Nc(),o},vp=function(e){const t=e.options;var o=e.getParentSvg();if(z(o.parentNode,"contextmenu",null,function(s){Y(s)||s.preventDefault()}),o=z(window,"resize",null,function(){xo(),e.hideComponents(!0),Sc(),zc(),$o(e),bn(e)}),e.setResizeHandlerWrapper(o),Ip(),t.languageTree){o=e.getToolbox();const s=e.getFlyout(!0);o?o.init():s&&(s.init(e),s.show(t.languageTree),typeof s.scrollToStart=="function"&&s.scrollToStart())}t.hasTrashcan&&e.trashcan.init(),t.zoomOptions&&t.zoomOptions.controls&&e.zoomControls_.init(),t.moveOptions&&t.moveOptions.scrollbars?(e.scrollbar=new ja(e,t.moveOptions.scrollbars===!0||!!t.moveOptions.scrollbars.horizontal,t.moveOptions.scrollbars===!0||!!t.moveOptions.scrollbars.vertical,"blocklyMainWorkspaceScrollbar"),e.scrollbar.resize()):e.setMetrics({x:.5,y:.5}),t.hasSounds&&Cp(t.pathToMedia,e)},Ip=function(){Qm||(z(document,"scroll",null,function(){const e=kt();for(let t=0,o;o=e[t];t++)o instanceof At&&o.updateInverseScreenCTM()}),ae(document,"touchend",null,ue),ae(document,"touchcancel",null,ue)),Qm=!0},Cp=function(e,t){function o(){for(;i.length;){const n=i.pop();n&&te(n)}s.preload()}const s=t.getAudioManager();s.load([e+"click.mp3",e+"click.wav",e+"click.ogg"],"click"),s.load([e+"disconnect.wav",e+"disconnect.mp3",e+"disconnect.ogg"],"disconnect"),s.load([e+"delete.mp3",e+"delete.ogg",e+"delete.wav"],"delete");const i=[];i.push(z(document,"pointermove",null,o,!0)),i.push(z(document,"touchstart",null,o,!0))},Du=function(){Ee.registry.register({displayText(){return r.Msg$$module$build$src$core$msg.UNDO},preconditionFn(e){return e.workspace.getUndoStack().length>0?"enabled":"disabled"},callback(e){e.workspace.undo(!1)},scopeType:Ee.ScopeType.WORKSPACE,id:"undoWorkspace",weight:1})},xu=function(){Ee.registry.register({displayText(){return r.Msg$$module$build$src$core$msg.REDO},preconditionFn(e){return e.workspace.getRedoStack().length>0?"enabled":"disabled"},callback(e){e.workspace.undo(!0)},scopeType:Ee.ScopeType.WORKSPACE,id:"redoWorkspace",weight:2})},Bu=function(){Ee.registry.register({displayText(){return r.Msg$$module$build$src$core$msg.CLEAN_UP},preconditionFn(e){return e.workspace.isMovable()?e.workspace.getTopBlocks(!1).length>1?"enabled":"disabled":"hidden"},callback(e){e.workspace.cleanUp()},scopeType:Ee.ScopeType.WORKSPACE,id:"cleanWorkspace",weight:3})},Pu=function(e,t){function o(n){i--,n.setCollapsed(e),i===0&&r.setGroup$$module$build$src$core$events$utils(!1)}let s=0,i=0;r.setGroup$$module$build$src$core$events$utils(!0);for(let n=0;n<t.length;n++){let d=t[n];for(;d;)i++,setTimeout(o.bind(null,d),s),d=d.getNextBlock(),s+=10}},Fu=function(){Ee.registry.register({displayText(){return r.Msg$$module$build$src$core$msg.COLLAPSE_ALL},preconditionFn(e){if(e.workspace.options.collapse){e=e.workspace.getTopBlocks(!1);for(let t=0;t<e.length;t++){let o=e[t];for(;o;){if(!o.isCollapsed())return"enabled";o=o.getNextBlock()}}return"disabled"}return"hidden"},callback(e){Pu(!0,e.workspace.getTopBlocks(!0))},scopeType:Ee.ScopeType.WORKSPACE,id:"collapseWorkspace",weight:4})},Uu=function(){Ee.registry.register({displayText(){return r.Msg$$module$build$src$core$msg.EXPAND_ALL},preconditionFn(e){if(e.workspace.options.collapse){e=e.workspace.getTopBlocks(!1);for(let t=0;t<e.length;t++){let o=e[t];for(;o;){if(o.isCollapsed())return"enabled";o=o.getNextBlock()}}return"disabled"}return"hidden"},callback(e){Pu(!1,e.workspace.getTopBlocks(!0))},scopeType:Ee.ScopeType.WORKSPACE,id:"expandWorkspace",weight:5})},Hu=function(e,t){if(e.isDeletable())Array.prototype.push.apply(t,e.getDescendants(!1));else{e=e.getChildren(!1);for(let o=0;o<e.length;o++)Hu(e[o],t)}},Nn=function(e){const t=[];e=e.getTopBlocks(!0);for(let o=0;o<e.length;o++)Hu(e[o],t);return t},er=function(e,t){t?r.setGroup$$module$build$src$core$events$utils(t):(r.setGroup$$module$build$src$core$events$utils(!0),t=r.getGroup$$module$build$src$core$events$utils());const o=e.shift();o&&(o.isDeadOrDying()?er(e,t):(o.dispose(!1,!0),setTimeout(er,10,e,t))),r.setGroup$$module$build$src$core$events$utils(!1)},Gu=function(){Ee.registry.register({displayText(e){return e.workspace?(e=Nn(e.workspace).length,e===1?r.Msg$$module$build$src$core$msg.DELETE_BLOCK:r.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace("%1",`${e}`)):""},preconditionFn(e){return e.workspace&&Nn(e.workspace).length>0?"enabled":"disabled"},callback(e){if(e.workspace){e.workspace.cancelCurrentGesture();var t=Nn(e.workspace);t.length<2?er(t):Xr(r.Msg$$module$build$src$core$msg.DELETE_ALL_BLOCKS.replace("%1",String(t.length)),function(o){o&&er(t)})}},scopeType:Ee.ScopeType.WORKSPACE,id:"workspaceDelete",weight:6})},Sp=function(){Du(),xu(),Bu(),Fu(),Uu(),Gu()},Vu=function(){Ee.registry.register({displayText(){return r.Msg$$module$build$src$core$msg.DUPLICATE_BLOCK},preconditionFn(e){return e=e.block,!e.isInFlyout&&e.isDeletable()&&e.isMovable()?e.isDuplicatable()?"enabled":"disabled":"hidden"},callback(e){if(e.block){var t=e.block.toCopyData();t&&ss(t,e.block.workspace)}},scopeType:Ee.ScopeType.BLOCK,id:"blockDuplicate",weight:1})},Wu=function(){Ee.registry.register({displayText(e){return e.block.hasIcon(Xo.TYPE)?r.Msg$$module$build$src$core$msg.REMOVE_COMMENT:r.Msg$$module$build$src$core$msg.ADD_COMMENT},preconditionFn(e){return e=e.block,!e.isInFlyout&&e.workspace.options.comments&&!e.isCollapsed()&&e.isEditable()?"enabled":"hidden"},callback(e){e=e.block,e.hasIcon(Xo.TYPE)?e.setCommentText(null):e.setCommentText("")},scopeType:Ee.ScopeType.BLOCK,id:"blockComment",weight:2})},zu=function(){Ee.registry.register({displayText(e){return e.block.getInputsInline()?r.Msg$$module$build$src$core$msg.EXTERNAL_INPUTS:r.Msg$$module$build$src$core$msg.INLINE_INPUTS},preconditionFn(e){if(e=e.block,!e.isInFlyout&&e.isMovable()&&!e.isCollapsed()){for(let t=1;t<e.inputList.length;t++)if(!(e.inputList[t-1]instanceof Rl||e.inputList[t]instanceof Rl))return"enabled"}return"hidden"},callback(e){e.block.setInputsInline(!e.block.getInputsInline())},scopeType:Ee.ScopeType.BLOCK,id:"blockInline",weight:3})},Yu=function(){Ee.registry.register({displayText(e){return e.block.isCollapsed()?r.Msg$$module$build$src$core$msg.EXPAND_BLOCK:r.Msg$$module$build$src$core$msg.COLLAPSE_BLOCK},preconditionFn(e){return e=e.block,!e.isInFlyout&&e.isMovable()&&e.workspace.options.collapse?"enabled":"hidden"},callback(e){e.block.setCollapsed(!e.block.isCollapsed())},scopeType:Ee.ScopeType.BLOCK,id:"blockCollapseExpand",weight:4})},Xu=function(){Ee.registry.register({displayText(e){return e.block.hasDisabledReason(Jt)?r.Msg$$module$build$src$core$msg.ENABLE_BLOCK:r.Msg$$module$build$src$core$msg.DISABLE_BLOCK},preconditionFn(e){if(e=e.block,!e.isInFlyout&&e.workspace.options.disable&&e.isEditable()){var t=e.getDisabledReasons();return t=t.size>(t.has(Jt)?1:0),e.getInheritedDisabled()||t?"disabled":"enabled"}return"hidden"},callback(e){e=e.block;const t=r.getGroup$$module$build$src$core$events$utils();t||r.setGroup$$module$build$src$core$events$utils(!0),e.setDisabledReason(!e.hasDisabledReason(Jt),Jt),r.setGroup$$module$build$src$core$events$utils(t)},scopeType:Ee.ScopeType.BLOCK,id:"blockDisable",weight:5})},ju=function(){Ee.registry.register({displayText(e){var t=e.block;return e=t.getDescendants(!1).length,(t=t.getNextBlock())&&(e-=t.getDescendants(!1).length),e===1?r.Msg$$module$build$src$core$msg.DELETE_BLOCK:r.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace("%1",`${e}`)},preconditionFn(e){return!e.block.isInFlyout&&e.block.isDeletable()?"enabled":"hidden"},callback(e){e.block&&e.block.checkAndDelete()},scopeType:Ee.ScopeType.BLOCK,id:"blockDelete",weight:6})},Ku=function(){Ee.registry.register({displayText(){return r.Msg$$module$build$src$core$msg.HELP},preconditionFn(e){return e=e.block,(typeof e.helpUrl=="function"?e.helpUrl():e.helpUrl)?"enabled":"hidden"},callback(e){e.block.showHelp()},scopeType:Ee.ScopeType.BLOCK,id:"blockHelp",weight:7})},Ju=function(){Ee.registry.register({displayText:()=>r.Msg$$module$build$src$core$msg.REMOVE_COMMENT,preconditionFn(e){let t;return(t=e.comment)!=null&&t.isDeletable()?"enabled":"hidden"},callback(e){r.setGroup$$module$build$src$core$events$utils(!0);let t;(t=e.comment)==null||t.dispose(),r.setGroup$$module$build$src$core$events$utils(!1)},scopeType:Ee.ScopeType.COMMENT,id:"commentDelete",weight:6})},qu=function(){Ee.registry.register({displayText:()=>r.Msg$$module$build$src$core$msg.DUPLICATE_COMMENT,preconditionFn(e){let t;return(t=e.comment)!=null&&t.isMovable()?"enabled":"hidden"},callback(e){if(e.comment){var t=e.comment.toCopyData();t&&ss(t,e.comment.workspace)}},scopeType:Ee.ScopeType.COMMENT,id:"commentDuplicate",weight:1})},Zu=function(){Ee.registry.register({displayText:()=>r.Msg$$module$build$src$core$msg.ADD_COMMENT,preconditionFn:e=>{let t;return(t=e.workspace)!=null&&t.isMutator?"hidden":"enabled"},callback:(e,t,o,s)=>{(e=e.workspace)&&(r.setGroup$$module$build$src$core$events$utils(!0),t=new yo(e),t.setPlaceholderText(r.Msg$$module$build$src$core$msg.WORKSPACE_COMMENT_DEFAULT_TEXT),t.moveTo(kp(new P(s.x,s.y),e)),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(t),r.setGroup$$module$build$src$core$events$utils(!1))},scopeType:Ee.ScopeType.WORKSPACE,id:"commentCreate",weight:8})},kp=function(e,t){var o=t.getInjectionDiv().getBoundingClientRect();return e=new P(e.x-o.left,e.y-o.top),o=t.getOriginOffsetInPixels(),e=P.difference(e,o),e.scale(1/t.scale),e},Rp=function(){Vu(),Wu(),zu(),Yu(),Xu(),ju(),Ku()},wp=function(){qu(),Ju(),Zu()},Qu=function(){Sp(),Rp()},Op=function(e){return e&&typeof e.paste=="function"},Np=function(e){return e&&typeof e.getSvgRoot=="function"},Ap=function(e){return e.isSelectable()},Lp=function(e){c().hideChaff(e)},N=N||{},N.scope={},N.ASSUME_ES5=!1,N.ASSUME_ES6=!1,N.ASSUME_ES2020=!1,N.ASSUME_NO_NATIVE_MAP=!1,N.ASSUME_NO_NATIVE_SET=!1,N.ISOLATE_POLYFILLS=!1,N.FORCE_POLYFILL_PROMISE=!1,N.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1,N.INSTRUMENT_ASYNC_CONTEXT=!0,N.objectCreate=N.ASSUME_ES5||typeof Object.create=="function"?Object.create:function(e){var t=function(){};return t.prototype=e,new t},N.defineProperty=N.ASSUME_ES5||typeof Object.defineProperties=="function"?Object.defineProperty:function(e,t,o){return e==Array.prototype||e==Object.prototype||(e[t]=o.value),e},N.getGlobal=function(e){e=[typeof globalThis=="object"&&globalThis,e,typeof window=="object"&&window,typeof self=="object"&&self,typeof jf=="object"&&jf];for(var t=0;t<e.length;++t){var o=e[t];if(o&&o.Math==Math)return o}throw Error("Cannot find global object")},N.global=N.ASSUME_ES2020?globalThis:N.getGlobal(this),N.IS_SYMBOL_NATIVE=typeof Symbol=="function"&&typeof Symbol("x")=="symbol",N.TRUST_ES6_POLYFILLS=!N.ISOLATE_POLYFILLS||N.IS_SYMBOL_NATIVE,N.polyfills={},N.propertyToPolyfillSymbol={},N.POLYFILL_PREFIX="$jscp$",N.polyfill=function(e,t,o,s){t&&(N.ISOLATE_POLYFILLS?N.polyfillIsolated(e,t,o,s):N.polyfillUnisolated(e,t,o,s))},N.polyfillUnisolated=function(e,t,o,s){for(o=N.global,e=e.split("."),s=0;s<e.length-1;s++){var i=e[s];if(!(i in o))return;o=o[i]}e=e[e.length-1],s=o[e],t=t(s),t!=s&&t!=null&&N.defineProperty(o,e,{configurable:!0,writable:!0,value:t})},N.polyfillIsolated=function(e,t,o,s){var i=e.split(".");e=i.length===1,s=i[0],s=!e&&s in N.polyfills?N.polyfills:N.global;for(var n=0;n<i.length-1;n++){var d=i[n];if(!(d in s))return;s=s[d]}i=i[i.length-1],o=N.IS_SYMBOL_NATIVE&&o==="es6"?s[i]:null,t=t(o),t!=null&&(e?N.defineProperty(N.polyfills,i,{configurable:!0,writable:!0,value:t}):t!==o&&(N.propertyToPolyfillSymbol[i]===void 0&&(o=Math.random()*1e9>>>0,N.propertyToPolyfillSymbol[i]=N.IS_SYMBOL_NATIVE?N.global.Symbol(i):N.POLYFILL_PREFIX+o+"$"+i),N.defineProperty(s,N.propertyToPolyfillSymbol[i],{configurable:!0,writable:!0,value:t})))},N.getConstructImplementation=function(){function e(){function o(){}return Reflect.construct(o,[],function(){}),new o instanceof o}if(N.TRUST_ES6_POLYFILLS&&typeof Reflect<"u"&&Reflect.construct){if(e())return Reflect.construct;var t=Reflect.construct;return function(o,s,i){return o=t(o,s),i&&Reflect.setPrototypeOf(o,i.prototype),o}}return function(o,s,i){return i===void 0&&(i=o),i=N.objectCreate(i.prototype||Object.prototype),Function.prototype.apply.call(o,i,s)||i}},N.construct={valueOf:N.getConstructImplementation}.valueOf(),N.underscoreProtoCanBeSet=function(){var e={a:!0},t={};try{return t.__proto__=e,t.a}catch{}return!1},N.setPrototypeOf=N.ASSUME_ES6||N.TRUST_ES6_POLYFILLS&&typeof Object.setPrototypeOf=="function"?Object.setPrototypeOf:N.underscoreProtoCanBeSet()?function(e,t){if(e.__proto__=t,e.__proto__!==t)throw new TypeError(e+" is not extensible");return e}:null,N.inherits=function(e,t){if(e.prototype=N.objectCreate(t.prototype),e.prototype.constructor=e,N.ASSUME_ES6||N.setPrototypeOf){var o=N.setPrototypeOf;o(e,t)}else for(o in t)if(o!="prototype")if(Object.defineProperties){var s=Object.getOwnPropertyDescriptor(t,o);s&&Object.defineProperty(e,o,s)}else e[o]=t[o];e.superClass_=t.prototype},N.arrayIteratorImpl=function(e){var t=0;return function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}},N.arrayIterator=function(e){return{next:N.arrayIteratorImpl(e)}},N.makeIterator=function(e){var t=typeof Symbol<"u"&&Symbol.iterator&&e[Symbol.iterator];if(t)return t.call(e);if(typeof e.length=="number")return N.arrayIterator(e);throw Error(String(e)+" is not an iterable or ArrayLike")},N.arrayFromIterator=function(e){for(var t,o=[];!(t=e.next()).done;)o.push(t.value);return o},N.arrayFromIterable=function(e){return e instanceof Array?e:N.arrayFromIterator(N.makeIterator(e))},N.generator={},N.generator.ensureIteratorResultIsObject_=function(e){if(!(e instanceof Object))throw new TypeError("Iterator result "+e+" is not an object")},N.generator.Context=function(){this.isRunning_=!1,this.yieldAllIterator_=null,this.yieldResult=void 0,this.nextAddress=1,this.finallyAddress_=this.catchAddress_=0,this.finallyContexts_=this.abruptCompletion_=null},N.generator.Context.prototype.start_=function(){if(this.isRunning_)throw new TypeError("Generator is already running");this.isRunning_=!0},N.generator.Context.prototype.stop_=function(){this.isRunning_=!1},N.generator.Context.prototype.jumpToErrorHandler_=function(){this.nextAddress=this.catchAddress_||this.finallyAddress_},N.generator.Context.prototype.next_=function(e){this.yieldResult=e},N.generator.Context.prototype.throw_=function(e){this.abruptCompletion_={exception:e,isException:!0},this.jumpToErrorHandler_()},N.generator.Context.prototype.return=function(e){this.abruptCompletion_={return:e},this.nextAddress=this.finallyAddress_},N.generator.Context.prototype.jumpThroughFinallyBlocks=function(e){this.abruptCompletion_={jumpTo:e},this.nextAddress=this.finallyAddress_},N.generator.Context.prototype.yield=function(e,t){return this.nextAddress=t,{value:e}},N.generator.Context.prototype.yieldAll=function(e,t){e=N.makeIterator(e);var o=e.next();if(N.generator.ensureIteratorResultIsObject_(o),o.done)this.yieldResult=o.value,this.nextAddress=t;else return this.yieldAllIterator_=e,this.yield(o.value,t)},N.generator.Context.prototype.jumpTo=function(e){this.nextAddress=e},N.generator.Context.prototype.jumpToEnd=function(){this.nextAddress=0},N.generator.Context.prototype.setCatchFinallyBlocks=function(e,t){this.catchAddress_=e,t!=null&&(this.finallyAddress_=t)},N.generator.Context.prototype.setFinallyBlock=function(e){this.catchAddress_=0,this.finallyAddress_=e||0},N.generator.Context.prototype.leaveTryBlock=function(e,t){this.nextAddress=e,this.catchAddress_=t||0},N.generator.Context.prototype.enterCatchBlock=function(e){return this.catchAddress_=e||0,e=this.abruptCompletion_.exception,this.abruptCompletion_=null,e},N.generator.Context.prototype.enterFinallyBlock=function(e,t,o){o?this.finallyContexts_[o]=this.abruptCompletion_:this.finallyContexts_=[this.abruptCompletion_],this.catchAddress_=e||0,this.finallyAddress_=t||0},N.generator.Context.prototype.leaveFinallyBlock=function(e,t){if(t=this.finallyContexts_.splice(t||0)[0],t=this.abruptCompletion_=this.abruptCompletion_||t){if(t.isException)return this.jumpToErrorHandler_();t.jumpTo!=null&&this.finallyAddress_<t.jumpTo?(this.nextAddress=t.jumpTo,this.abruptCompletion_=null):this.nextAddress=this.finallyAddress_}else this.nextAddress=e},N.generator.Context.prototype.forIn=function(e){return new N.generator.Context.PropertyIterator(e)},N.generator.Context.PropertyIterator=function(e){this.object_=e,this.properties_=[];for(var t in e)this.properties_.push(t);this.properties_.reverse()},N.generator.Context.PropertyIterator.prototype.getNext=function(){for(;this.properties_.length>0;){var e=this.properties_.pop();if(e in this.object_)return e}return null},N.generator.Engine_=function(e){this.context_=new N.generator.Context,this.program_=e},N.generator.Engine_.prototype.next_=function(e){return this.context_.start_(),this.context_.yieldAllIterator_?this.yieldAllStep_(this.context_.yieldAllIterator_.next,e,this.context_.next_):(this.context_.next_(e),this.nextStep_())},N.generator.Engine_.prototype.return_=function(e){this.context_.start_();var t=this.context_.yieldAllIterator_;return t?this.yieldAllStep_("return"in t?t.return:function(o){return{value:o,done:!0}},e,this.context_.return):(this.context_.return(e),this.nextStep_())},N.generator.Engine_.prototype.throw_=function(e){return this.context_.start_(),this.context_.yieldAllIterator_?this.yieldAllStep_(this.context_.yieldAllIterator_.throw,e,this.context_.next_):(this.context_.throw_(e),this.nextStep_())},N.generator.Engine_.prototype.yieldAllStep_=function(e,t,o){try{var s=e.call(this.context_.yieldAllIterator_,t);if(N.generator.ensureIteratorResultIsObject_(s),!s.done)return this.context_.stop_(),s;var i=s.value}catch(n){return this.context_.yieldAllIterator_=null,this.context_.throw_(n),this.nextStep_()}return this.context_.yieldAllIterator_=null,o.call(this.context_,i),this.nextStep_()},N.generator.Engine_.prototype.nextStep_=function(){for(;this.context_.nextAddress;)try{var e=this.program_(this.context_);if(e)return this.context_.stop_(),{value:e.value,done:!1}}catch(t){this.context_.yieldResult=void 0,this.context_.throw_(t)}if(this.context_.stop_(),this.context_.abruptCompletion_){if(e=this.context_.abruptCompletion_,this.context_.abruptCompletion_=null,e.isException)throw e.exception;return{value:e.return,done:!0}}return{value:void 0,done:!0}},N.generator.Generator_=function(e){this.next=function(t){return e.next_(t)},this.throw=function(t){return e.throw_(t)},this.return=function(t){return e.return_(t)},this[Symbol.iterator]=function(){return this}},N.generator.createGenerator=function(e,t){return t=new N.generator.Generator_(new N.generator.Engine_(t)),N.setPrototypeOf&&e.prototype&&N.setPrototypeOf(t,e.prototype),t},N.asyncExecutePromiseGenerator=function(e){function t(s){return e.next(s)}function o(s){return e.throw(s)}return new Promise(function(s,i){function n(d){d.done?s(d.value):Promise.resolve(d.value).then(t,o).then(n,i)}n(e.next())})},N.asyncExecutePromiseGeneratorFunction=function(e){return N.asyncExecutePromiseGenerator(e())},N.asyncExecutePromiseGeneratorProgram=function(e){return N.asyncExecutePromiseGenerator(new N.generator.Generator_(new N.generator.Engine_(e)))},N.polyfill("globalThis",function(e){return e||N.global},"es_2020","es3"),N.polyfill("Array.prototype.includes",function(e){return e||function(t,o){var s=this;s instanceof String&&(s=String(s));var i=s.length;for(o=o||0,o<0&&(o=Math.max(o+i,0));o<i;o++){var n=s[o];if(n===t||Object.is(n,t))return!0}return!1}},"es7","es3"),N.checkEs6ConformanceViaProxy=function(){try{var e={},t=Object.create(new N.global.Proxy(e,{get:function(o,s,i){return o==e&&s=="q"&&i==t}}));return t.q===!0}catch{return!1}},N.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1,N.ES6_CONFORMANCE=N.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&N.checkEs6ConformanceViaProxy(),N.initSymbol=function(){},N.iteratorPrototype=function(e){return e={next:e},e[Symbol.iterator]=function(){return this},e},N.owns=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},N.MapEntry=function(){},N.polyfill("Set.prototype.difference",function(e){return e||function(t){N.checkIsSetInstance(this),N.checkIsSetLike(t);var o=N.getSmallerAndLargerSets(this,t);t=new Set(this);var s=o.smallerSetIterator;o=o.largerSet;for(var i=s.next();!i.done;)o.has(i.value)&&t.delete(i.value),i=s.next();return t}},"es_next","es6"),N.checkIsSetLike=function(e){if(typeof e!="object"||e===null||typeof e.size!="number"||e.size<0||typeof e.keys!="function"||typeof e.has!="function")throw new TypeError("Argument must be set-like")},N.checkIsValidIterator=function(e){if(typeof e!="object"||e===null||typeof e.next!="function")throw new TypeError("Invalid iterator.");return e},N.getSmallerAndLargerSets=function(e,t){return e.size<=t.size?{smallerSetIterator:e.keys(),largerSet:t}:{smallerSetIterator:N.checkIsValidIterator(t.keys()),largerSet:e}},N.checkIsSetInstance=function(e){if(!(e instanceof Set))throw new TypeError("Method must be called on an instance of Set.")},N.iteratorFromArray=function(e,t){if(N.ASSUME_ES6)return e[Symbol.iterator]();e instanceof String&&(e+="");var o=0,s=!1,i={next:function(){if(!s&&o<e.length){var n=o++;return{value:t(n,e[n]),done:!1}}return s=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i},N.polyfill("Array.prototype.values",function(e){return e||function(){return N.iteratorFromArray(this,function(t,o){return o})}},"es8","es3"),N.polyfill("Array.prototype.flatMap",function(e){return e||function(t,o){var s=[];return Array.prototype.forEach.call(this,function(i,n){i=t.call(o,i,n,this),Array.isArray(i)?s.push.apply(s,i):s.push(i)}),s}},"es9","es5"),N.polyfill("Array.prototype.flat",function(e){return e||function(t){t=t===void 0?1:t;var o=[];return Array.prototype.forEach.call(this,function(s){Array.isArray(s)&&t>0?(s=Array.prototype.flat.call(s,t-1),o.push.apply(o,s)):o.push(s)}),o}},"es9","es5"),N.polyfill("Object.entries",function(e){return e||function(t){var o=[],s;for(s in t)N.owns(t,s)&&o.push([s,t[s]]);return o}},"es8","es3"),N.polyfill("Object.values",function(e){return e||function(t){var o=[],s;for(s in t)N.owns(t,s)&&o.push(t[s]);return o}},"es8","es3");var is=Object.create(null),ub={typeMap:is},An=Object.create(null),Ft="default",M=class{constructor(e){this.name=e}toString(){return this.name}};M.CONNECTION_CHECKER=new M("connectionChecker"),M.CONNECTION_PREVIEWER=new M("connectionPreviewer"),M.CURSOR=new M("cursor"),M.EVENT=new M("event"),M.FIELD=new M("field"),M.INPUT=new M("input"),M.RENDERER=new M("renderer"),M.TOOLBOX=new M("toolbox"),M.THEME=new M("theme"),M.TOOLBOX_ITEM=new M("toolboxItem"),M.FLYOUTS_VERTICAL_TOOLBOX=new M("flyoutsVerticalToolbox"),M.FLYOUTS_HORIZONTAL_TOOLBOX=new M("flyoutsHorizontalToolbox"),M.FLYOUT_INFLATER=new M("flyoutInflater"),M.METRICS_MANAGER=new M("metricsManager"),M.BLOCK_DRAGGER=new M("blockDragger"),M.SERIALIZER=new M("serializer"),M.ICON=new M("icon"),M.PASTER=new M("paster"),M.VARIABLE_MODEL=new M("variableModel"),M.VARIABLE_MAP=new M("variableMap");var Bo={DEFAULT:Ft,TEST_ONLY:ub};Bo.Type=M,Bo.getAllItems=H,Bo.getClass=A,Bo.getClassFromOptions=W,Bo.getObject=D,Bo.hasItem=k,Bo.register=l,Bo.unregister=m;var Ge=Object.create(null),ab=750,Mp="ontouchstart"in globalThis||!!(globalThis.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),Ln=null,Cs={mousedown:["pointerdown"],mouseenter:["pointerenter"],mouseleave:["pointerleave"],mousemove:["pointermove"],mouseout:["pointerout"],mouseover:["pointerover"],mouseup:["pointerup","pointercancel"],touchend:["pointerup"],touchcancel:["pointercancel"]},Mn=0,Ss={TOUCH_ENABLED:Mp,TOUCH_MAP:Cs};Ss.checkTouchIdentifier=me,Ss.clearTouchIdentifier=ie,Ss.getTouchIdentifierFromEvent=ee,Ss.longStart=X,Ss.longStop=ue,Ss.shouldHandleEvent=K;var ea,Dp,xp,Bp,Dn,xn,ta,Pp,Fp,Up;(function(e){function t(s){return o.includes(s.toUpperCase())}ea=e;const o=ea.toUpperCase();Dp=t("JavaFX"),xp=t("WebKit"),Bp=t("Gecko")&&!xp,Dn=t("Android"),e=globalThis.navigator&&globalThis.navigator.maxTouchPoints,xn=t("iPad")||t("Macintosh")&&e>0,ta=t("iPhone")&&!xn,Pp=t("Macintosh"),Fp=xn||Dn&&!t("Mobile")||t("Silk"),Up=!Fp&&(ta||Dn)})(globalThis.navigator&&globalThis.navigator.userAgent||"");var hb=ea,Hp=Dp,Gp=Bp,oa=Dn,Bn=xn,Vp=ta,sa=Pp,Wp=Up,db={ANDROID:oa,GECKO:Gp,IPAD:Bn,IPHONE:Vp,JavaFx:Hp,MAC:sa,MOBILE:Wp,raw:hb},zp=40,Yp=125,Po={};Po.bind=ae,Po.conditionalBind=z,Po.getScrollDeltaPixels=It,Po.isRightButton=Ie,Po.isTargetInput=Y,Po.mouseToSvg=Ye,Po.unbind=te;var w;(function(e){e.BLOCK_CREATE="create",e.BLOCK_DELETE="delete",e.BLOCK_CHANGE="change",e.BLOCK_FIELD_INTERMEDIATE_CHANGE="block_field_intermediate_change",e.BLOCK_MOVE="move",e.VAR_CREATE="var_create",e.VAR_DELETE="var_delete",e.VAR_RENAME="var_rename",e.VAR_TYPE_CHANGE="var_type_change",e.UI="ui",e.BLOCK_DRAG="drag",e.SELECTED="selected",e.CLICK="click",e.MARKER_MOVE="marker_move",e.BUBBLE_OPEN="bubble_open",e.TRASHCAN_OPEN="trashcan_open",e.TOOLBOX_ITEM_SELECT="toolbox_item_select",e.THEME_CHANGE="theme_change",e.VIEWPORT_CHANGE="viewport_change",e.COMMENT_CREATE="comment_create",e.COMMENT_DELETE="comment_delete",e.COMMENT_CHANGE="comment_change",e.COMMENT_MOVE="comment_move",e.COMMENT_RESIZE="comment_resize",e.COMMENT_DRAG="comment_drag",e.COMMENT_COLLAPSE="comment_collapse",e.FINISHED_LOADING="finished_loading"})(w||(w={}));var Xp=[w.BLOCK_CREATE,w.BLOCK_MOVE,w.COMMENT_CREATE,w.COMMENT_MOVE],jp="!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Kp={genUid:()=>{const e=jp.length,t=[];for(let o=0;o<20;o++)t[o]=jp.charAt(Math.random()*e);return t.join("")}},$b=0,ia={TEST_ONLY:Kp};ia.genUid=rt,ia.getNextUniqueId=Re;var Jp="",tr=!0,ra=0,na="ORPHANED_BLOCK",Fo=[],qp={FIRE_QUEUE:Fo,enqueueEvent:ne,fireNow:Q,fireInternal:F,setGroupInternal:$e};r.disable$$module$build$src$core$events$utils,r.enable$$module$build$src$core$events$utils,r.getGroup$$module$build$src$core$events$utils,r.setGroup$$module$build$src$core$events$utils,r.setRecordUndo$$module$build$src$core$events$utils;var or="http://www.w3.org/2000/svg",To="http://www.w3.org/1999/xhtml",Ht="http://www.w3.org/1999/xlink",Uo;(function(e){e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE"})(Uo||(Uo={}));var no=null,la=0,sr=null,mt={HTML_NS:To};mt.NodeType=Uo,mt.SVG_NS=or,mt.XLINK_NS=Ht,mt.addClass=G,mt.createSvgElement=v,mt.getFastTextWidth=ms,mt.getFastTextWidthWithSizeString=ho,mt.getTextWidth=ot,mt.hasClass=qo,mt.insertAfter=Qt,mt.measureFontMetrics=E,mt.removeClass=Te,mt.removeClasses=Lt,mt.removeNode=ke,mt.setCssTransform=Mo,mt.startTextWidthCache=eo,mt.stopTextWidthCache=to;var ft=class{static findFocusedNode(e){var t=e.getRootFocusableNode();if(!t.canBeFocused())return null;var o=t.getFocusableElement();return qo(o,ft.ACTIVE_CLASS_NAME)||qo(o,ft.PASSIVE_CSS_CLASS_NAME)||(t=o.querySelector(this.ACTIVE_FOCUS_NODE_CSS_SELECTOR),(t instanceof HTMLElement||t instanceof SVGElement)&&(t=ft.findFocusableNodeFor(t,e)))?t:(o=o.querySelector(this.PASSIVE_FOCUS_NODE_CSS_SELECTOR),(o instanceof HTMLElement||o instanceof SVGElement)&&(e=ft.findFocusableNodeFor(o,e))?e:null)}static findFocusableNodeFor(e,t){if(!e.id||e.id==="null"||t.getNestedTrees().map(i=>ft.findFocusableNodeFor(e,i)).findIndex(i=>!!i)!==-1)return null;var o=t.getRootFocusableNode();if(o.canBeFocused()&&e===o.getFocusableElement())return o;var s;return(o=(s=t.lookUpFocusableNode(e.id))!=null?s:null)?o:(s=e.parentElement,!o&&s?ft.findFocusableNodeFor(s,t):null)}};ft.ACTIVE_CLASS_NAME="blocklyActiveFocus",ft.PASSIVE_CSS_CLASS_NAME="blocklyPassiveFocus",ft.ACTIVE_FOCUS_NODE_CSS_SELECTOR=`.${ft.ACTIVE_CLASS_NAME}`,ft.PASSIVE_FOCUS_NODE_CSS_SELECTOR=`.${ft.PASSIVE_CSS_CLASS_NAME}`;var pb=class{constructor(e,t){this.tree=e,this.rootShouldBeAutoTabbable=t}},Et=class{constructor(e){this.previouslyFocusedNode=this.focusedNode=null,this.registeredTrees=[],this.isUpdatingFocusedNode=this.recentlyLostAllFocus=this.lockFocusStateChanges=this.currentlyHoldsEphemeralFocus=!1;const t=o=>{if(!this.isUpdatingFocusedNode){this.recentlyLostAllFocus=!o;var s=null;if(o instanceof HTMLElement||o instanceof SVGElement){for(var i of this.registeredTrees)if(s=ft.findFocusableNodeFor(o,i.tree))break}if(s&&s.canBeFocused()){o=s.getFocusableTree();let n;i=(n=this.focusedNode)==null?void 0:n.getFocusableTree(),s===o.getRootFocusableNode()&&o!==i?this.focusTree(o):this.focusNode(s)}else this.defocusCurrentFocusedNode()}};e("focusin",o=>{o instanceof FocusEvent&&t(document.activeElement)}),e("focusout",o=>{o instanceof FocusEvent&&t(o.relatedTarget)})}registerTree(e,t=!1){if(this.ensureManagerIsUnlocked(),this.isRegistered(e))throw Error(`Attempted to re-register already registered tree: ${e}.`);this.registeredTrees.push(new pb(e,t));const o=e.getRootFocusableNode().getFocusableElement();if(!o.id||o.id==="null")throw Error(`Attempting to register a tree with a root element that has an invalid ID: ${e}.`);t&&(o.tabIndex=0)}isRegistered(e){return!!this.lookUpRegistration(e)}lookUpRegistration(e){let t;return(t=this.registeredTrees.find(o=>o.tree===e))!=null?t:null}unregisterTree(e){if(this.ensureManagerIsUnlocked(),!this.isRegistered(e))throw Error(`Attempted to unregister not registered tree: ${e}.`);var t=this.registeredTrees.findIndex(i=>i.tree===e);const o=this.registeredTrees[t];this.registeredTrees.splice(t,1),t=ft.findFocusedNode(e);const s=e.getRootFocusableNode();t&&this.removeHighlight(t),this.focusedNode!==t&&this.focusedNode!==s||this.updateFocusedNode(null),this.removeHighlight(s),o.rootShouldBeAutoTabbable&&e.getRootFocusableNode().getFocusableElement().removeAttribute("tabindex")}getFocusedTree(){let e,t;return(t=(e=this.focusedNode)==null?void 0:e.getFocusableTree())!=null?t:null}getFocusedNode(){return this.focusedNode}focusTree(e){if(this.ensureManagerIsUnlocked(),!this.isRegistered(e))throw Error(`Attempted to focus unregistered tree: ${e}.`);const t=ft.findFocusedNode(e),o=e.getRestoredFocusableNode(t);e=e.getRootFocusableNode();let s;this.focusNode((s=o??t)!=null?s:e)}focusNode(e){this.ensureManagerIsUnlocked();const t=!this.currentlyHoldsEphemeralFocus;t&&(this.isUpdatingFocusedNode=!0);var o,s=((o=this.focusedNode)==null?void 0:o.getFocusableElement())!==document.activeElement;if(this.focusedNode!==e||s)if(e.canBeFocused()){if(o=e.getFocusableTree(),!this.isRegistered(o))throw Error(`Attempted to focus unregistered node: ${e}.`);s=e.getFocusableElement(),s.id&&s.id!=="null"||console.warn("Trying to focus a node that has an invalid ID.");var i=ft.findFocusableNodeFor(s,o);s=ft.findFocusedNode(o);var n=e;if(i!==e){n=o.getRestoredFocusableNode(s),e=o.getRootFocusableNode();var d;n=(d=n??s)!=null?d:e}e=this.focusedNode,d=e?.getFocusableTree(),e&&this.passivelyFocusNode(e,o),o=o.getRootFocusableNode(),s&&this.removeHighlight(s),o!==n&&this.removeHighlight(o),this.currentlyHoldsEphemeralFocus||this.activelyFocusNode(n,d??null),this.updateFocusedNode(n)}else console.warn("Trying to focus a node that can't be focused.");t&&(this.isUpdatingFocusedNode=!1)}takeEphemeralFocus(e){if(this.ensureManagerIsUnlocked(),this.currentlyHoldsEphemeralFocus)throw Error(`Attempted to take ephemeral focus when it's already held, with new element: ${e}.`);this.currentlyHoldsEphemeralFocus=!0,this.focusedNode&&this.passivelyFocusNode(this.focusedNode,null),e.focus();let t=!1;return()=>{if(t)throw Error(`Attempted to finish ephemeral focus twice for element: ${e}.`);if(t=!0,this.currentlyHoldsEphemeralFocus=!1,this.focusedNode){this.activelyFocusNode(this.focusedNode,null);const o=this.focusedNode;setTimeout(()=>{!this.focusedNode&&this.previouslyFocusedNode===o&&this.recentlyLostAllFocus&&this.focusNode(o)},0)}}}ephemeralFocusTaken(){return this.currentlyHoldsEphemeralFocus}ensureManagerIsUnlocked(){if(this.lockFocusStateChanges)throw Error("FocusManager state changes cannot happen in a tree/node focus/blur callback.")}updateFocusedNode(e){this.previouslyFocusedNode=this.focusedNode,this.focusedNode=e}defocusCurrentFocusedNode(){this.focusedNode&&!this.currentlyHoldsEphemeralFocus&&(this.passivelyFocusNode(this.focusedNode,null),this.updateFocusedNode(null))}activelyFocusNode(e,t){this.lockFocusStateChanges=!0;const o=e.getFocusableTree(),s=e.getFocusableElement();let i;const n=(i=this.lookUpRegistration(o))==null?void 0:i.rootShouldBeAutoTabbable;o!==t&&(o.onTreeFocus(e,t),n&&(o.getRootFocusableNode().getFocusableElement().tabIndex=-1)),e.onNodeFocus(),this.lockFocusStateChanges=!1,n&&e===o.getRootFocusableNode()||s.hasAttribute("tabindex")||(s.tabIndex=-1),this.setNodeToVisualActiveFocus(e),s.focus()}passivelyFocusNode(e,t){this.lockFocusStateChanges=!0;const o=e.getFocusableTree();if(o!==t){o.onTreeBlur(t);let s;(s=this.lookUpRegistration(o))!=null&&s.rootShouldBeAutoTabbable&&(o.getRootFocusableNode().getFocusableElement().tabIndex=0)}e.onNodeBlur(),this.lockFocusStateChanges=!1,o!==t&&this.setNodeToVisualPassiveFocus(e)}setNodeToVisualActiveFocus(e){e=e.getFocusableElement(),G(e,Et.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),Te(e,Et.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}setNodeToVisualPassiveFocus(e){e=e.getFocusableElement(),Te(e,Et.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),G(e,Et.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}removeHighlight(e){e=e.getFocusableElement(),Te(e,Et.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),Te(e,Et.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}static getFocusManager(){return Et.focusManager||(Et.focusManager=new Et(document.addEventListener)),Et.focusManager}};Et.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME="blocklyActiveFocus",Et.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME="blocklyPassiveFocus",Et.focusManager=null,r.getFocusManager$$module$build$src$core$focus_manager;var Zp={};Zp.deepMerge=He;var Pe=class{constructor(){this.shortcuts=new Map,this.keyMap=new Map,this.reset()}reset(){this.shortcuts.clear(),this.keyMap.clear()}register(e,t){if(this.shortcuts.get(e.name)&&!t)throw Error(`Shortcut named "${e.name}" already exists.`);if(this.shortcuts.set(e.name,e),t=e.keyCodes,t!=null&&t.length)for(const o of t)this.addKeyMapping(o,e.name,!!e.allowCollision)}unregister(e){return this.shortcuts.get(e)?(this.removeAllKeyMappings(e),this.shortcuts.delete(e),!0):(console.warn(`Keyboard shortcut named "${e}" not found.`),!1)}addKeyMapping(e,t,o){e=`${e}`;const s=this.keyMap.get(e);if(s&&!o)throw Error(`Shortcut named "${t}" collides with shortcuts "${s}"`);s&&o?s.unshift(t):this.keyMap.set(e,[t])}removeKeyMapping(e,t,o){const s=this.keyMap.get(e);if(!s)return o||console.warn(`No keyboard shortcut named "${t}" registered with key code "${e}"`),!1;const i=s.indexOf(t);return i>-1?(s.splice(i,1),s.length===0&&this.keyMap.delete(e),!0):(o||console.warn(`No keyboard shortcut named "${t}" registered with key code "${e}"`),!1)}removeAllKeyMappings(e){for(const t of this.keyMap.keys())this.removeKeyMapping(t,e,!0)}setKeyMap(e){this.keyMap.clear();for(const t in e)this.keyMap.set(t,e[t])}getKeyMap(){const e=Object.create(null);for(const[t,o]of this.keyMap)e[t]=o;return e}getRegistry(){const e=Object.create(null);for(const[t,o]of this.shortcuts)e[t]=o;return He(Object.create(null),e)}onKeyDown(e,t){var o=this.serializeKeyEvent(t);if(o=this.getShortcutNamesByKeyCode(o),!o)return!1;for(const s of o){o=this.shortcuts.get(s);let i;if(!o||o.preconditionFn&&!o.preconditionFn(e,{focusedNode:(i=r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode())!=null?i:void 0}))continue;let n,d,f;if((d=(n=o).callback)!=null&&d.call(n,e,t,o,{focusedNode:(f=r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode())!=null?f:void 0}))return!0}return!1}getShortcutNamesByKeyCode(e){let t;return((t=this.keyMap.get(e))==null?void 0:t.slice())||[]}getKeyCodesByShortcutName(e){const t=[];for(const[o,s]of this.keyMap)s.indexOf(e)>-1&&t.push(o);return t}serializeKeyEvent(e){let t="";for(const o in Pe.modifierKeys)e.getModifierState(o)&&(t!==""&&(t+="+"),t+=o);return t!==""&&e.keyCode?t+="+"+e.keyCode:e.keyCode&&(t=String(e.keyCode)),t}checkModifiers(e){for(const t of e)if(!(t in Pe.modifierKeys))throw Error(t+" is not a valid modifier key.")}createSerializedKey(e,t){let o="";if(t){this.checkModifiers(t);for(const s in Pe.modifierKeys)t.includes(Pe.modifierKeys[s])&&(o!==""&&(o+="+"),o+=s)}return o!==""&&e?o+="+"+e:e&&(o=`${e}`),o}};Pe.registry=new Pe,(function(e){e=e.modifierKeys||(e.modifierKeys={}),e[e.Shift=16]="Shift",e[e.Control=17]="Control",e[e.Alt=18]="Alt",e[e.Meta=91]="Meta"})(Pe||(Pe={}));var ir=Object.create(null),Qp,eg,rr=[],tg={defineBlocksWithJsonArrayInternal:b},ht={TEST_ONLY:tg};ht.createBlockDefinitionsFromJsonArray=r.createBlockDefinitionsFromJsonArray$$module$build$src$core$common,ht.defineBlocks=r.defineBlocks$$module$build$src$core$common,ht.defineBlocksWithJsonArray=$,ht.draggingConnections=rr,ht.fireSelectedEvent=V,ht.getAllWorkspaces=kt,ht.getBlockTypeCounts=io,ht.getMainWorkspace=c,ht.getParentContainer=Ae,ht.getSelected=I,ht.getWorkspaceById=ct,ht.globalShortcutHandler=S,ht.registerWorkspace=st,ht.setMainWorkspace=p,ht.setParentContainer=so,ht.setSelected=C,ht.svgResize=$o,ht.unregisterWorkpace=Ut;var hi=class{constructor(){this.workspaceId=void 0,this.isUiEvent=!1,this.type="",this.group=r.getGroup$$module$build$src$core$events$utils(),this.recordUndo=Ue()}toJson(){return{type:this.type,group:this.group}}static fromJson(e,t,o){return o.isBlank=!1,o.group=e.group||"",o.workspaceId=t.id,o}isNull(){return!1}run(e){}getEventWorkspace_(){let e;if(this.workspaceId&&(e=ct(this.workspaceId)),!e)throw Error("Workspace is null. Event must have been generated from real Blockly events.");return e}},Eo=class extends hi{constructor(e){super(),this.recordUndo=!1,this.isUiEvent=!0,this.isBlank=typeof e>"u",this.workspaceId=e||""}},ca=class extends Eo{constructor(e,t,o){t=e?e.workspace.id:t,t===null&&(t=void 0),super(t),this.type=w.CLICK,this.blockId=e?e.id:void 0,this.targetType=o}toJson(){const e=super.toJson();if(!this.targetType)throw Error("The click target type is undefined. Either pass a block to the constructor, or call fromJson");return e.targetType=this.targetType,e.blockId=this.blockId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new ca),t.targetType=e.targetType,t.blockId=e.blockId,t}},ua;(function(e){e.BLOCK="block",e.WORKSPACE="workspace",e.ZOOM_CONTROLS="zoom_controls"})(ua||(ua={})),l(M.EVENT,w.CLICK,ca);var og={};og.removeElem=x;var Ho=class{constructor(e){this.name=e}toString(){return this.name}};Ho.POSITIONABLE=new Ho("positionable"),Ho.DRAG_TARGET=new Ho("drag_target"),Ho.DELETE_AREA=new Ho("delete_area"),Ho.AUTOHIDEABLE=new Ho("autohideable");var Ve=class{constructor(){this.componentData=new Map,this.capabilityToComponentIds=new Map}addComponent(e,t){const o=e.component.id;if(!t&&this.componentData.has(o)){var s;throw Error('Plugin "'+o+'" with capabilities "'+((s=this.componentData.get(o))==null?void 0:s.capabilities)+'" already added.')}for(this.componentData.set(o,e),t=[],s=0;s<e.capabilities.length;s++){const i=String(e.capabilities[s]).toLowerCase();if(t.push(i),this.capabilityToComponentIds.has(i)){let n;(n=this.capabilityToComponentIds.get(i))==null||n.push(o)}else this.capabilityToComponentIds.set(i,[o])}this.componentData.get(o).capabilities=t}removeComponent(e){const t=this.componentData.get(e);if(t){for(let o=0;o<t.capabilities.length;o++){const s=String(t.capabilities[o]).toLowerCase();x(this.capabilityToComponentIds.get(s),e)}this.componentData.delete(e)}}addCapability(e,t){if(!this.getComponent(e))throw Error('Cannot add capability, "'+t+'". Plugin "'+e+'" has not been added to the ComponentManager');if(this.hasCapability(e,t))console.warn('Plugin "'+e+'already has capability "'+t+'"');else{t=`${t}`.toLowerCase();var o;(o=this.componentData.get(e))==null||o.capabilities.push(t);var s;(s=this.capabilityToComponentIds.get(t))==null||s.push(e)}}removeCapability(e,t){if(!this.getComponent(e))throw Error('Cannot remove capability, "'+t+'". Plugin "'+e+'" has not been added to the ComponentManager');this.hasCapability(e,t)?(t=`${t}`.toLowerCase(),x(this.componentData.get(e).capabilities,t),x(this.capabilityToComponentIds.get(t),e)):console.warn('Plugin "'+e+`doesn't have capability "`+t+'" to remove')}hasCapability(e,t){return t=`${t}`.toLowerCase(),this.componentData.has(e)&&this.componentData.get(e).capabilities.includes(t)}getComponent(e){let t;return(t=this.componentData.get(e))==null?void 0:t.component}getComponents(e,t){if(e=`${e}`.toLowerCase(),e=this.capabilityToComponentIds.get(e),!e)return[];const o=[];if(t){const s=[];e.forEach(i=>{s.push(this.componentData.get(i))}),s.sort(function(i,n){return i.weight-n.weight}),s.forEach(function(i){o.push(i.component)})}else e.forEach(s=>{o.push(this.componentData.get(s).component)});return o}};Ve.Capability=Ho,(function(e){e=e.ComponentWeight||(e.ComponentWeight={}),e[e.TOOLBOX_WEIGHT=0]="TOOLBOX_WEIGHT",e[e.FLYOUT_WEIGHT=1]="FLYOUT_WEIGHT",e[e.TRASHCAN_WEIGHT=2]="TRASHCAN_WEIGHT",e[e.ZOOM_CONTROLS_WEIGHT=3]="ZOOM_CONTROLS_WEIGHT"})(Ve||(Ve={})),Ve.ComponentWeight;var aa=!1,ha=`
3
+ `+e.className.baseVal;var n;return no&&(n=no[e])||(ir||(n=document.createElement("canvas"),n.className="blocklyComputeCanvas",document.body.appendChild(n),ir=n.getContext("2d")),i&&ir?(ir.font=o+" "+t+" "+s,n=ir.measureText(i).width):n=0,no&&(no[e]=n)),n},E=function(e,t,o,s){const i=document.createElement("span");i.style.font=o+" "+t+" "+s,i.textContent=e,e=document.createElement("div"),e.style.width="1px",e.style.height="0",t=document.createElement("div"),t.style.display="flex",t.style.position="fixed",t.style.top="0",t.style.left="0",t.appendChild(i),t.appendChild(e),document.body.appendChild(t),o={height:0,baseline:0};try{t.style.alignItems="baseline",o.baseline=e.offsetTop-i.offsetTop,t.style.alignItems="flex-end",o.height=e.offsetTop-i.offsetTop}finally{document.body.removeChild(t)}return o},r.getFocusManager$$module$build$src$core$focus_manager=function(){return Et.getFocusManager()},oo=function(e){return e&&typeof e.getFocusableElement=="function"&&typeof e.getFocusableTree=="function"&&typeof e.onNodeFocus=="function"&&typeof e.onNodeBlur=="function"&&typeof e.canBeFocused=="function"},Do=function(e){return oo(e)&&typeof e.id=="string"&&typeof e.workspace=="object"&&typeof e.select=="function"&&typeof e.unselect=="function"},He=function(e,t){for(const o in t)t[o]!==null&&Array.isArray(t[o])?e[o]=He(e[o]||[],t[o]):e[o]=t[o]!==null&&typeof t[o]=="object"?He(e[o]||Object.create(null),t[o]):t[o];return e},ct=function(e){return rr[e]||null},kt=function(){const e=[];for(const t in rr)e.push(rr[t]);return e},st=function(e){rr[e.id]=e},Ut=function(e){delete rr[e.id]},c=function(){return og},p=function(e){og=e},I=function(){const e=r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode();return e&&Do(e)?e:null},C=function(e){r.getFocusManager$$module$build$src$core$focus_manager().focusNode(e)},V=function(e){const t=I();let o,s,i,n;const d=new(U(w.SELECTED))((o=t?.id)!=null?o:null,(s=e?.id)!=null?s:null,(n=(i=e?.workspace.id)!=null?i:t?.workspace.id)!=null?n:"");_(d)},Ae=function(){return sg},so=function(e){sg=e},$o=function(e){for(;e.options.parentWorkspace;)e=e.options.parentWorkspace;const t=e.getParentSvg(),o=e.getCachedParentSvgSize();var s=t.parentElement;if(s instanceof HTMLElement){var i=s.offsetWidth;s=s.offsetHeight,o.width!==i&&(t.setAttribute("width",i+"px"),e.setCachedParentSvgSize(i,null)),o.height!==s&&(t.setAttribute("height",s+"px"),e.setCachedParentSvgSize(null,s)),e.resize()}},io=function(e,t){const o=Object.create(null),s=e.getDescendants(!0);t&&(e=e.getNextBlock())&&(e=s.indexOf(e),s.splice(e,s.length-e));for(let i=0,n;n=s[i];i++)o[n.type]?o[n.type]++:o[n.type]=1;return o},u=function(e){return function(){this.jsonInit(e)}},$=function(e){ig.defineBlocksWithJsonArrayInternal(e)},b=function(e){r.defineBlocks$$module$build$src$core$common(r.createBlockDefinitionsFromJsonArray$$module$build$src$core$common(e))},r.createBlockDefinitionsFromJsonArray$$module$build$src$core$common=function(e){const t={};for(let o=0;o<e.length;o++){const s=e[o];if(!s){console.warn(`Block definition #${o} in JSON array is ${s}. Skipping`);continue}const i=s.type;i?t[i]={init:u(s)}:console.warn(`Block definition #${o} in JSON array is missing a type attribute. Skipping.`)}return t},r.defineBlocks$$module$build$src$core$common=function(e){for(const t of Object.keys(e)){const o=e[t];t in Ge&&console.warn(`Block definition "${t}" overwrites previous definition.`),Ge[t]=o}},S=function(e){let t=c();const o=r.getFocusManager$$module$build$src$core$focus_manager().getFocusedTree();for(const s of kt())if(o===s){t=s;break}!Y(e)&&t&&(!t.rendered||t.isFlyout||t.isVisible())&&Pe.registry.onKeyDown(t,e)},x=function(e,t){return t=e.indexOf(t),t===-1?!1:(e.splice(t,1),!0)},q=function(e){if(da)throw Error("CSS already injected");$a+=`
4
+ `+e},pe=function(e,t){da||(da=!0,e&&(e=t.replace(/[\\/]$/,""),t=$a.replace(/<<<PATH>>>/g,e),$a="",e=document.createElement("style"),e.id="blockly-common-style",t=document.createTextNode(t),e.appendChild(t),document.head.insertBefore(e,document.head.firstChild)))},Rt=function(e){return ng.getSizeInternal(e)},fs=function(e){if(Mt(e,"display")!=="none")return zs(e);const t=e.style,o=t.display,s=t.visibility,i=t.position;t.visibility="hidden",t.position="absolute",t.display="inline";const n=e.offsetWidth;return e=e.offsetHeight,t.display=o,t.position=i,t.visibility=s,new ve(n,e)},zs=function(e){return new ve(e.offsetWidth,e.offsetHeight)},Mt=function(e,t){return e=window.getComputedStyle(e),e[t]||e.getPropertyValue(t)},Zo=function(e){const t=new P(0,0);e=e.getBoundingClientRect();var o=document.documentElement;return o=new P(window.pageXOffset||o.scrollLeft,window.pageYOffset||o.scrollTop),t.x=e.left+o.x,t.y=e.top+o.y,t},jl=function(){const e=document.body,t=document.documentElement;return new P(e.scrollLeft||t.scrollLeft,e.scrollTop||t.scrollTop)},Kl=function(e){const t=parseFloat(Mt(e,"borderLeftWidth")),o=parseFloat(Mt(e,"borderRightWidth")),s=parseFloat(Mt(e,"borderTopWidth"));return e=parseFloat(Mt(e,"borderBottomWidth")),new ye(s,e,t,o)},Jl=function(e,t,o){e=ql(e,t,o),t.scrollLeft=e.x,t.scrollTop=e.y},ql=function(e,t,o){var s=Zo(e),i=Zo(t),n=Kl(t);const d=s.x-i.x-n.left;return s=s.y-i.y-n.top,i=zs(e),e=t.clientWidth-i.width,i=t.clientHeight-i.height,n=t.scrollLeft,t=t.scrollTop,o?(n+=d-e/2,t+=s-i/2):(n+=Math.min(d,Math.max(d-e,0)),t+=Math.min(s,Math.max(s-i,0))),new P(n,t)},Bi=function(e){const t=new P(0,0);var o=e.x&&e.getAttribute("x");const s=e.y&&e.getAttribute("y");return o&&(t.x=parseInt(o)),s&&(t.y=parseInt(s)),(o=(o=e.getAttribute("transform"))&&o.match(lg))&&(t.x+=Number(o[1]),o[3]&&(t.y+=Number(o[3]))),(e=e.getAttribute("style"))&&e.includes("translate")&&(e=e.match(cg))&&(t.x+=Number(e[1]),e[3]&&(t.y+=Number(e[3]))),t},Pr=function(e){let t=0,o=0;for(;e;){const s=Bi(e);if(t+=s.x,o+=s.y,(" "+(e.getAttribute("class")||"")+" ").includes(" injectionDiv "))break;e=e.parentNode}return new P(t,o)},Zl=function(){const e=jl();return new ye(e.y,document.documentElement.clientHeight+e.y,e.x,document.documentElement.clientWidth+e.x)},Ql=function(){const e=document.documentElement,t=window;return new P(t.pageXOffset||e.scrollLeft,t.pageYOffset||e.scrollTop)},ec=function(e,t){var o=t.x;t=t.y;const s=e.getInjectionDiv().getBoundingClientRect();return o=new P(o-s.left,t-s.top),t=e.getOriginOffsetInPixels(),P.difference(o,t).scale(1/e.scale)},Ys=function(e,t){var o=t.scale(e.scale);t=o.x,o=o.y;const s=e.getInjectionDiv().getBoundingClientRect();return e=e.getOriginOffsetInPixels(),new P(t+s.left+e.x,o+s.top+e.y)},fd=function(e){({document:Un=Un,DOMParser:lr=lr,XMLSerializer:cr=cr}=e),Fn=new lr,ga=new cr},r.createElement$$module$build$src$core$utils$xml=function(e){return Un.createElementNS(ug,e)},r.createTextNode$$module$build$src$core$utils$xml=function(e){return Un.createTextNode(e)},r.textToDom$$module$build$src$core$utils$xml=function(e){let t=Fn.parseFromString(e,"text/xml");if(t&&t.documentElement&&!t.getElementsByTagName("parsererror").length)return t.documentElement;if((t=Fn.parseFromString(e,"text/html"))&&t.body.firstChild&&t.body.firstChild.nodeName.toLowerCase()==="xml")return t.body.firstChild;throw Error(`DOMParser was unable to parse: ${e}`)},Xs=function(e){return _d(ga.serializeToString(e))},_d=function(e){return e.replace(bb,t=>`&#${t.charCodeAt(0)};`)},Fr=function(e){return e?((e instanceof Element||typeof e=="string")&&(e=oc(e),e=Ed(e)),bd(e),e):null},bd=function(e){const t=e.kind;if(e=e.contents,t&&t!==ag&&t!==ma)throw Error("Invalid toolbox kind "+t+". Please supply either "+ag+" or "+ma);if(!e)throw Error("Toolbox must have a contents attribute.")},Pi=function(e){return e?e.contents?e.contents:Array.isArray(e)&&e.length>0&&!e[0].nodeType?e:Gr(e):[]},Ur=function(e){return hg.hasCategoriesInternal(e)},Td=function(e){if(!e)return!1;const t=e.kind;return t?t===ma:!!e.contents.filter(o=>o.kind.toUpperCase()==="CATEGORY").length},Hr=function(e){return e&&e.contents?!!e.contents.filter(function(t){return t.kind.toUpperCase()==="CATEGORY"}).length:!1},Ed=function(e){const t={contents:Gr(e)};return e instanceof Node&&tc(e,t),t},Gr=function(e){const t=[];let o=e.childNodes;o||(o=e);for(let s=0,i;i=o[s];s++){if(!i.tagName)continue;e={};const n=i.tagName.toUpperCase();e.kind=n,n==="BLOCK"?e.blockxml=i:i.childNodes&&i.childNodes.length>0&&(e.contents=Gr(i)),tc(i,e),t.push(e)}return t},tc=function(e,t){for(let o=0;o<e.attributes.length;o++){const s=e.attributes[o];s.nodeName.includes("css-")?(t.cssconfig=t.cssconfig||{},t.cssconfig[s.nodeName.replace("css-","")]=s.value):t[s.nodeName]=s.value}},oc=function(e){let t=null;if(e)if(typeof e=="string"){if(t=r.textToDom$$module$build$src$core$utils$xml(e),t.nodeName.toLowerCase()!=="xml")throw TypeError("Toolbox should be an <xml> document.")}else e instanceof Element&&(t=e);return t},Vr=function(e,t,o,s,i,n){const d=n.scrollbar&&n.scrollbar.canScrollVertically();return e.horizontal===$i.LEFT?(o=i.absoluteMetrics.left+o,d&&n.RTL&&(o+=Ze.scrollbarThickness)):(o=i.absoluteMetrics.left+i.viewMetrics.width-t.width-o,d&&!n.RTL&&(o-=Ze.scrollbarThickness)),e.vertical===Go.TOP?e=i.absoluteMetrics.top+s:(e=i.absoluteMetrics.top+i.viewMetrics.height-t.height-s,n.scrollbar&&n.scrollbar.canScrollHorizontally()&&(e-=Ze.scrollbarThickness)),new ye(e,e+t.height,o,o+t.width)},Wr=function(e,t){return{horizontal:t.toolboxMetrics.position===be.LEFT||e.horizontalLayout&&!e.RTL?$i.RIGHT:$i.LEFT,vertical:t.toolboxMetrics.position===be.BOTTOM?Go.TOP:Go.BOTTOM}},zr=function(e,t,o,s){const i=e.left,n=e.right-e.left,d=e.bottom-e.top;for(let f=0;f<s.length;f++){const L=s[f];e.intersects(L)&&(e=o===ls.UP?L.top-d-t:L.bottom+t,e=new ye(e,e+d,i,i+n),f=-1)}return e},Fi=function(e,t){l(M.SERIALIZER,e,t)},yd=function(e){m(M.SERIALIZER,e)},js=function(e,{addCoordinates:t=!1,saveIds:o=!0}={}){const s=e.workspace,i=Object.create(null);return i.height=e.getSize().height,i.width=e.getSize().width,o&&(i.id=e.id),t&&(t=e.getRelativeToSurfaceXY(),i.x=s.RTL?s.getWidth()-t.x:t.x,i.y=t.y),e.getText()&&(i.text=e.getText()),e.isCollapsed()&&(i.collapsed=!0),e.isOwnEditable()||(i.editable=!1),e.isOwnMovable()||(i.movable=!1),e.isOwnDeletable()||(i.deletable=!1),i},Ui=function(e,t,{recordUndo:o=!1}={}){const s=Ue();if(r.setRecordUndo$$module$build$src$core$events$utils(o),o=t.newComment(e.id),e.text!==void 0&&o.setText(e.text),e.x!==void 0||e.y!==void 0){const n=o.getRelativeToSurfaceXY();let d,f=(d=e.x)!=null?d:n.x;f=t.RTL?t.getWidth()-f:f;var i;t=(i=e.y)!=null?i:n.y,o.moveTo(new P(f,t))}if(e.width!==void 0||e.height){i=o.getSize();let n,d;o.setSize(new ve((n=e.width)!=null?n:i.width,(d=e.height)!=null?d:i.height))}return e.collapsed!==void 0&&o.setCollapsed(e.collapsed),e.editable!==void 0&&o.setEditable(e.editable),e.movable!==void 0&&o.setMovable(e.movable),e.deletable!==void 0&&o.setDeletable(e.deletable),r.setRecordUndo$$module$build$src$core$events$utils(s),o},Yr=function(e,t){l(M.PASTER,e,t)},vd=function(e){m(M.PASTER,e)},Id=function(e){const t=e.workspace,o=e.getRelativeToSurfaceXY(),s=new P(0,0),i=t.getTopComments(!1).filter(n=>n.id!==e.id).map(n=>n.getRelativeToSurfaceXY());for(;Cd(P.sum(o,s),i);)s.translate(t.RTL?-30:30,30);e.moveTo(P.sum(o,s))},Cd=function(e,t){return t.some(o=>Math.abs(o.x-e.x)<=1&&Math.abs(o.y-e.y)<=1)},po=function(e,t){e.setAttribute(yb,t)},it=function(e,t,o){Array.isArray(o)&&(o=o.join(" ")),e.setAttribute(Eb+t,`${o}`)},Hi=function(e){return e&&typeof e.saveState=="function"&&typeof e.loadState=="function"},sc=function(e){return ic(e),Sd()?(Xr(),Promise.resolve()):(pi||(pi=new Promise(t=>{va=t,bg=window.requestAnimationFrame(()=>{Xr(),t()})})),pi)},go=function(){return pi||Promise.resolve()},Qo=function(e){e||window.cancelAnimationFrame(bg),Xr(e),!e&&va&&va()},Sd=function(){return Wp},ic=function(e){Ea.add(e),ya.set(e,r.getGroup$$module$build$src$core$events$utils());const t=e.getParent();t?ic(t):zn.add(e)},Xr=function(e){const t=e?new Set([e]):new Set([...zn].map(n=>n.workspace)),o=[...zn].filter(kd).filter(n=>t.has(n.workspace));for(var s of o)nc(s);for(const n of t)n.resizeContents();for(var i of o)s=i.getRelativeToSurfaceXY(),i.updateComponentLocations(s);for(const n of o)i=r.getGroup$$module$build$src$core$events$utils(),(s=ya.get(n))&&r.setGroup$$module$build$src$core$events$utils(s),n.bumpNeighbours(),r.setGroup$$module$build$src$core$events$utils(i);for(const n of o)rc(n);e||(pi=null)},rc=function(e){zn.delete(e),Ea.delete(e),ya.delete(e);for(const t of e.getChildren(!1))rc(t)},kd=function(e){return!e.isDisposed()&&!e.getParent()},nc=function(e){if(Ea.has(e)&&e.initialized){for(const t of e.getChildren(!1))nc(t);e.renderEfficiently()}},Gi=function(e,t){Ig(e,t)},Rd=function(e=vg){Ig=e},jr=function(e,t){Sg(e,t)},wd=function(e=Cg){Sg=e},Kr=function(e,t,o){Rg(e,t,o)},Od=function(e=kg){Rg=e},Nd=function(e,t){Og(e,t)},Ad=function(e=wg){Og=e},Ks=function(e){return e&&typeof e.getProcedureDef=="function"},Ld=function(e){return e&&typeof e.getProcedureCall=="function"&&typeof e.renameProcedure=="function"},lc=function(e){return e.getVariableModel!==void 0},pt=function(e,t,o,s){e=e+" was deprecated in "+t+" and will be deleted in "+o+".",s&&(e+=`
5
+ Use `+s+" instead."),Ng.has(e)||(Ng.add(e),console.warn(e))},r.allUsedVarModels$$module$build$src$core$variables=function(e){e=e.getAllBlocks(!1);const t=new Set;for(let o=0;o<e.length;o++){const s=e[o].getVarModels();if(s)for(let i=0;i<s.length;i++){const n=s[i];n.getId()&&t.add(n)}}return Array.from(t.values())},r.allDeveloperVariables$$module$build$src$core$variables=function(e){e=e.getAllBlocks(!1);const t=new Set;for(let s=0,i;i=e[s];s++){var o=i.getDeveloperVariables;if(o){o=o();for(let n=0;n<o.length;n++)t.add(o[n])}}return Array.from(t.values())},Jr=function(e){return cc(e,!1)},cc=function(e,t=!0){return Ge.variables_set||Ge.variables_get||console.warn("There are no variable blocks, but there is a variable category."),t?(pt("The XML return value of Blockly.Variables.flyoutCategory()","v12","v13","the same method, but handle a return type of FlyoutItemInfo[] (JSON) instead."),Md(e)):(e.registerButtonCallback("CREATE_VARIABLE",function(o){_s(o.getTargetWorkspace())}),[{kind:"button",text:"%{BKY_NEW_VARIABLE}",callbackkey:"CREATE_VARIABLE"},...Zr(e,e.getVariableMap().getVariablesOfType(""),!0)])},qr=function(e){return{VAR:{name:e.getName(),type:e.getType()}}},Zr=function(e,t,o,s="variables_get",i="variables_set"){o&&(o=Ge.math_change),e=[];const n=t.slice(-1)[0];return n&&(Ge[i]&&e.push({kind:"block",type:i,gap:o?8:24,fields:qr(n)}),o&&e.push({kind:"block",type:"math_change",gap:Ge[s]?20:8,fields:qr(n),inputs:{DELTA:{shadow:{type:"math_number",fields:{NUM:1}}}}})),Ge[s]&&e.push(...t.sort(Js).map(d=>({kind:"block",type:s,gap:8,fields:qr(d)}))),e},Md=function(e){let t=[];const o=document.createElement("button");return o.setAttribute("text","%{BKY_NEW_VARIABLE}"),o.setAttribute("callbackKey","CREATE_VARIABLE"),e.registerButtonCallback("CREATE_VARIABLE",function(s){_s(s.getTargetWorkspace())}),t.push(o),e=uc(e),t=t.concat(e)},uc=function(e){e=e.getVariableMap().getVariablesOfType("");const t=[];if(e.length>0){var o=e[e.length-1];if(Ge.variables_set){var s=r.createElement$$module$build$src$core$utils$xml("block");s.setAttribute("type","variables_set"),s.setAttribute("gap",Ge.math_change?"8":"24"),s.appendChild(bs(o)),t.push(s)}if(Ge.math_change&&(s=r.createElement$$module$build$src$core$utils$xml("block"),s.setAttribute("type","math_change"),s.setAttribute("gap",Ge.variables_get?"20":"8"),s.appendChild(bs(o)),o=r.textToDom$$module$build$src$core$utils$xml('<value name="DELTA"><shadow type="math_number"><field name="NUM">1</field></shadow></value>'),s.appendChild(o),t.push(s)),Ge.variables_get){e.sort(Js);for(let i=0,n;n=e[i];i++)o=r.createElement$$module$build$src$core$utils$xml("block"),o.setAttribute("type","variables_get"),o.setAttribute("gap","8"),o.appendChild(bs(n)),t.push(o)}}return t},ac=function(e){return Lg.generateUniqueNameInternal(e)},Dd=function(e){return Qr(Sa.charAt(0),e.getVariableMap().getAllVariables().map(t=>t.getName()))},Qr=function(e,t){if(!t.length)return e;const o=Sa;let s="",i=o.indexOf(e);for(;;){let n=!1;for(let d=0;d<t.length;d++)if(t[d].toLowerCase()===e){n=!0;break}if(!n)break;i++,i===o.length&&(i=0,s=`${Number(s)+1}`),e=o.charAt(i)+s}return e},_s=function(e,t,o){function s(n){en(r.Msg$$module$build$src$core$msg.NEW_VARIABLE_TITLE,n,function(d){if(d){var f=hc(d,e);if(f){if(f.getType()===i)var L=r.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS.replace("%1",f.getName());else L=r.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE,L=L.replace("%1",f.getName()).replace("%2",f.getType());Gi(L,function(){s(d)})}else e.getVariableMap().createVariable(d,i),t&&t(d)}else t&&t(null)})}const i=o||"";s("")},r.renameVariable$$module$build$src$core$variables=function(e,t,o){function s(i){const n=r.Msg$$module$build$src$core$msg.RENAME_VARIABLE_TITLE.replace("%1",t.getName());en(n,i,function(d){if(d){var f=xd(d,t.getType(),e),L=dc(t.getName(),d,e);if(f||L){var oe="";f?oe=r.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE.replace("%1",f.getName()).replace("%2",f.getType()):L&&(oe=r.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS_FOR_A_PARAMETER.replace("%1",d).replace("%2",L)),Gi(oe,function(){s(d)})}else e.getVariableMap().renameVariable(t,d),o&&o(d)}else o&&o(null)})}s("")},en=function(e,t,o){Kr(e,t,function(s){s&&(s=s.replace(/[\s\xa0]+/g," ").trim(),s===r.Msg$$module$build$src$core$msg.RENAME_VARIABLE||s===r.Msg$$module$build$src$core$msg.NEW_VARIABLE)&&(s=null),o(s)})},xd=function(e,t,o){o=o.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let s=0,i;i=o[s];s++)if(i.getName().toLowerCase()===e&&i.getType()!==t)return i;return null},hc=function(e,t){t=t.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let o=0,s;s=t[o];o++)if(s.getName().toLowerCase()===e)return s;return null},dc=function(e,t,o){return o.getProcedureMap().getProcedures().length?Bd(e,t,o):Pd(e,t,o)},Bd=function(e,t,o){e=e.toLowerCase(),t=t.toLowerCase(),o=o.getProcedureMap().getProcedures();for(const i of o){var s=i.getParameters().filter(lc).map(n=>n.getVariableModel().getName());if(s&&(o=s.some(n=>n.toLowerCase()===e),s=s.some(n=>n.toLowerCase()===t),o&&s))return i.getName()}return null},Pd=function(e,t,o){e=e.toLowerCase(),t=t.toLowerCase(),o=o.getAllBlocks(!1);for(const i of o){if(!Ks(i))continue;o=i.getProcedureDef();var s=o[1];const n=s.some(d=>d.toLowerCase()===e);if(s=s.some(d=>d.toLowerCase()===t),n&&s)return o[0]}return null},bs=function(e){const t=r.createElement$$module$build$src$core$utils$xml("field");return t.setAttribute("name","VAR"),t.setAttribute("id",e.getId()),t.setAttribute("variabletype",e.getType()),e=r.createTextNode$$module$build$src$core$utils$xml(e.getName()),t.appendChild(e),t},r.getOrCreateVariablePackage$$module$build$src$core$variables=function(e,t,o,s){let i=r.getVariable$$module$build$src$core$variables(e,t,o,s);return i||(i=Fd(e,t,o,s)),i},r.getVariable$$module$build$src$core$variables=function(e,t,o,s){const i=e.getPotentialVariableMap();let n=null;if(t&&(n=e.getVariableById(t),!n&&i&&(n=i.getVariableById(t)),n))return n;if(o){if(s===void 0)throw Error("Tried to look up a variable by name without a type");n=e.getVariable(o,s),!n&&i&&(n=i.getVariable(o,s))}return n},Fd=function(e,t,o,s){const i=e.getVariableMap(),n=e.getPotentialVariableMap();return o||(o=ac(e.isFlyout?e.targetWorkspace:e)),n?n.createVariable(o,s,t??void 0):i.createVariable(o,s,t)},Vi=function(e,t){e=e.getAllVariables();const o=[];if(t.length!==e.length)for(let s=0;s<e.length;s++){const i=e[s];t.includes(i)||o.push(i)}return o},Js=function(e,t){return e.getName().localeCompare(t.getName(),void 0,{sensitivity:"base"})},qs=function(e,t){const o=[];e=e.getAllBlocks(!1);for(let s=0;s<e.length;s++){const i=e[s].getVarModels();if(i)for(let n=0;n<i.length;n++)i[n].getId()===t&&o.push(e[s])}return o},r.deleteVariable$$module$build$src$core$variables=function(e,t,o){var s=t.getName();const i=qs(e,t.getId());for(let n=i.length-1;n>=0;n--){const d=i[n];if(d.type==="procedures_defnoreturn"||d.type==="procedures_defreturn"){o=String(d.getFieldValue("NAME")),s=r.Msg$$module$build$src$core$msg.CANNOT_DELETE_VARIABLE_PROCEDURE.replace("%1",s).replace("%2",o),Gi(s);return}d===o&&i.splice(n,1)}o&&i.length||i.length>1?(s=r.Msg$$module$build$src$core$msg.DELETE_VARIABLE_CONFIRMATION.replace("%1",String(i.length+(o&&!o.workspace.isFlyout?1:0))).replace("%2",s),jr(s,n=>{n&&t&&e.getVariableMap().deleteVariable(t)})):e.getVariableMap().deleteVariable(t)},jt=function(e,{addCoordinates:t=!1,addInputBlocks:o=!0,addNextBlocks:s=!0,doFullSerialization:i=!0,saveIds:n=!0}={}){if(e.isInsertionMarker())return null;const d={type:e.type,id:n?e.id:void 0};return t&&Hd(e,d),Ud(e,d),Gd(e,d,i),Vd(e,d,i),Wd(e,d,i),o&&zd(e,d,i,n),s&&Yd(e,d,i,n),d},Ud=function(e,t){e.isCollapsed()&&(t.collapsed=!0),e.isEnabled()||(t.disabledReasons=Array.from(e.getDisabledReasons())),e.isOwnDeletable()||(t.deletable=!1),e.isOwnMovable()||(t.movable=!1),e.isOwnEditable()||(t.editable=!1),e.inputsInline!==void 0&&e.inputsInline!==e.inputsInlineDefault&&(t.inline=e.inputsInline),e.data&&(t.data=e.data)},Hd=function(e,t){const o=e.workspace;e=e.getRelativeToSurfaceXY(),t.x=Math.round(o.RTL?o.getWidth()-e.x:e.x),t.y=Math.round(e.y)},Gd=function(e,t,o){e.saveExtraState?(e=e.saveExtraState(o),e!==null&&(t.extraState=e)):e.mutationToDom&&(e=e.mutationToDom(),e!==null&&(t.extraState=fo(e).replace(' xmlns="https://developers.google.com/blockly/xml"',"")))},Vd=function(e,t,o){const s=Object.create(null);for(const i of e.getIcons())Hi(i)&&(e=i.saveState(o))&&(s[i.getType().toString()]=e);Object.keys(s).length&&(t.icons=s)},Wd=function(e,t,o){const s=Object.create(null);for(const i of e.getFields())i.isSerializable()&&(s[i.name]=i.saveState(o));Object.keys(s).length&&(t.fields=s)},zd=function(e,t,o,s){const i=Object.create(null);for(let n=0;n<e.inputList.length;n++){const d=e.inputList[n];if(!d.connection)continue;const f=$c(d.connection,o,s);f&&(i[d.name]=f)}Object.keys(i).length&&(t.inputs=i)},Yd=function(e,t,o,s){e.nextConnection&&(e=$c(e.nextConnection,o,s))&&(t.next=e)},$c=function(e,t,o){const s=e.getShadowState(!0);if(e=e.targetBlock(),!s&&!e)return null;const i=Object.create(null);return s&&(i.shadow=s),e&&!e.isShadow()&&(i.block=jt(e,{doFullSerialization:t,saveIds:o})),i},es=function(e,t,{recordUndo:o=!1}={}){return e=Zs(e,t,{recordUndo:o}),t.rendered&&Qo(),e},Zs=function(e,t,{parentConnection:o,isShadow:s=!1,recordUndo:i=!1}={}){const n=Ue();r.setRecordUndo$$module$build$src$core$events$utils(i),(i=r.getGroup$$module$build$src$core$events$utils())||r.setGroup$$module$build$src$core$events$utils(!0),r.disable$$module$build$src$core$events$utils();const d=t.getAllVariables();let f;try{f=pc(e,t,{parentConnection:o,isShadow:s})}finally{r.enable$$module$build$src$core$events$utils()}if(Xd(t,d),J()&&_(new(U(w.BLOCK_CREATE))(f)),r.setGroup$$module$build$src$core$events$utils(i),r.setRecordUndo$$module$build$src$core$events$utils(n),t.rendered){const L=f;setTimeout(()=>{L.disposed||L.setConnectionTracking(!0)},1)}return f},pc=function(e,t,{parentConnection:o,isShadow:s=!1}={}){if(!e.type)throw new Mg(e);const i=t.newBlock(e.type,e.id);return i.setShadow(s),jd(i,e),Kd(i,e),Jd(i,e),qd(o,i,e),Zd(i,e),Qd(i,e),e$(i,e),t$(i,e),o$(i,t.rendered),i},Xd=function(e,t){if(J())for(e=Vi(e,t),t=0;t<e.length;t++){const o=e[t];_(new(U(w.VAR_CREATE))(o))}},jd=function(e,t){let o=t.x===void 0?0:t.x;t=t.y===void 0?0:t.y;const s=e.workspace;o=s.RTL?s.getWidth()-o:o,e.moveBy(o,t)},Kd=function(e,t){if(t.collapsed&&e.setCollapsed(!0),t.deletable===!1&&e.setDeletable(!1),t.movable===!1&&e.setMovable(!1),t.editable===!1&&e.setEditable(!1),t.enabled===!1&&e.setDisabledReason(!0,Jt),Array.isArray(t.disabledReasons))for(const o of t.disabledReasons)e.setDisabledReason(!0,o);t.inline!==void 0&&e.setInputsInline(t.inline),t.data!==void 0&&(e.data=t.data)},Jd=function(e,t){t.extraState&&(e.loadExtraState?e.loadExtraState(t.extraState):e.domToMutation&&e.domToMutation(r.textToDom$$module$build$src$core$utils$xml(t.extraState)))},qd=function(e,t,o){if(e){if(e.getSourceBlock().isShadow()&&!t.isShadow())throw new xg(o);if(e.type===r.inputTypes$$module$build$src$core$inputs$input_types.VALUE){var s=t.outputConnection;if(!s)throw new dr("output",t,o)}else if(s=t.previousConnection,!s)throw new dr("previous",t,o);if(!e.connect(s)){const i=t.workspace.connectionChecker;throw new Dg(i.getErrorMessage(i.canConnectWithReason(s,e,!1),s,e),e.type===r.inputTypes$$module$build$src$core$inputs$input_types.VALUE?"output connection":"previous connection",t,o)}}},Zd=function(e,t){if(t.icons){var o=Object.keys(t.icons);for(const i of o){o=t.icons[i];var s=e.getIcon(i);if(!s){if(s=A(M.ICON,i,!1),!s)throw new Bg(i,e,t);s=new s(e),e.addIcon(s)}Hi(s)&&s.loadState(o)}}},Qd=function(e,t){if(t.fields){var o=Object.keys(t.fields);for(let s=0;s<o.length;s++){const i=o[s],n=t.fields[i],d=e.getField(i);d?d.loadState(n):console.warn(`Ignoring non-existant field ${i} in block ${e.type}`)}}},e$=function(e,t){if(t.inputs){var o=Object.keys(t.inputs);for(let s=0;s<o.length;s++){const i=o[s],n=e.getInput(i);if(!n||!n.connection)throw new dr(i,e,t);gc(n.connection,t.inputs[i])}}},t$=function(e,t){if(t.next){if(!e.nextConnection)throw new dr("next",e,t);gc(e.nextConnection,t.next)}},gc=function(e,t){t.shadow&&e.setShadowState(t.shadow),t.block&&pc(t.block,e.getSourceBlock().workspace,{parentConnection:e})},o$=function(e,t){if(t){e.setConnectionTracking(!1),e.initSvg(),e.queueRender();for(const o of e.getIcons())o.onLocationChange(e.getRelativeToSurfaceXY())}else e.initModel()},Ts=function(e){return typeof e.bubbleIsVisible=="function"&&typeof e.setBubbleVisible=="function"&&typeof e.getBubble=="function"},tn=function(e){return e*Math.PI/180},s$=function(e){return e*180/Math.PI},Qs=function(e,t,o){if(o<e){const s=o;o=e,e=s}return Math.max(e,Math.min(t,o))},on=function(){document.querySelector(".blocklyDropDownDiv")||(Ke=document.createElement("div"),Ke.className="blocklyDropDownDiv",Ke.tabIndex=-1,(Ae()||document.body).appendChild(Ke),pr=document.createElement("div"),pr.className="blocklyDropDownContent",Ke.appendChild(pr),qn=z(pr,"keydown",null,S),Ms=document.createElement("div"),Ms.className="blocklyDropDownArrow",Ke.appendChild(Ms),Ke.style.opacity="0",Ke.style.transition="transform "+Kn+"s, opacity "+Kn+"s")},mc=function(e){wa=e},fc=function(){return cs},sn=function(){return pr},rn=function(){qn&&(te(qn),qn=null),Ke.remove(),on()},_c=function(e,t){Ke.style.backgroundColor=e,Ke.style.borderColor=t},i$=function(e,t,o,s,i=!0){return yc(Tc(t),e,i,o,s)},bc=function(e,t,o,s=!0){return Vg=!0,yc(Ec(e),e,s,t,o)},Tc=function(e){var t=e.getSvgRoot();const o=e.workspace.scale,s=e.height*o;return e=e.width*o,t=Zo(t),new ye(t.y,t.y+s,t.x,t.x+e)},Ec=function(e){return e=e.getScaledBBox(),new ye(e.top,e.bottom,e.left,e.right)},yc=function(e,t,o,s,i){const n=e.left+(e.right-e.left)/2,d=e.bottom;e=e.top,i&&(e+=i),i=t.getSourceBlock();let f=i.workspace;for(;f.options.parentWorkspace;)f=f.options.parentWorkspace;return mc(f.getParentSvg().parentNode),vc(t,i.RTL,n,d,n,e,o,s)},vc=function(e,t,o,s,i,n,d,f){return cs=e,Ls=f||null,Ke.style.direction=t?"rtl":"ltr",e=c(),Hg=e.getRenderer().getClassName(),Gg=e.getTheme().getClassName(),G(Ke,Hg),G(Ke,Gg),o=kc(o,s,i,n),d&&(Jn=r.getFocusManager$$module$build$src$core$focus_manager().takeEphemeralFocus(Ke)),o},Ic=function(e,t,o,s){return e=Wi(e,o.left,o.right,s.width),{initialX:e.divX,initialY:t,finalX:e.divX,finalY:t+ka,arrowX:e.arrowX,arrowY:-9,arrowAtTop:!0,arrowVisible:!0}},Cc=function(e,t,o,s){return e=Wi(e,o.left,o.right,s.width),{initialX:e.divX,initialY:t-s.height,finalX:e.divX,finalY:t-s.height-ka,arrowX:e.arrowX,arrowY:s.height-Fg*2-jn/2,arrowAtTop:!1,arrowVisible:!0}},r$=function(e,t,o){return e=Wi(e,t.left,t.right,o.width),{initialX:e.divX,initialY:0,finalX:e.divX,finalY:0,arrowAtTop:null,arrowX:null,arrowY:null,arrowVisible:!1}},Wi=function(e,t,o,s){return t=Qs(t,e-s/2,o-s),e=e-jn/2-t,o=Ug,e=Qs(o,e,s-o-jn),{arrowX:e,divX:t}},Sc=function(){return!!cs},nn=function(e,t){return cs===e?(t?mo():ln(),!0):!1},ln=function(){Ke.style.transform="translate(0, 0)",Ke.style.opacity="0",Ra=setTimeout(function(){mo()},Kn*1e3),Ls&&(Ls(),Ls=null)},mo=function(){Sc()&&(Ra&&clearTimeout(Ra),Ls&&(Ls(),Ls=null),rn(),cs=null,c().markFocused(),Jn&&(Jn(),Jn=null))},kc=function(e,t,o,s){e=Oa.getPositionMetrics(e,t,o,s),e.arrowVisible?(t=e.arrowX,o=e.arrowY,s=e.arrowAtTop?45:225,Ms.style.display="",Ms.style.transform=`translate(${t}px, ${o}px) rotate(${s}deg)`,Ms.setAttribute("class","blocklyDropDownArrow")):Ms.style.display="none",t=Math.floor(e.initialX),o=Math.floor(e.initialY),s=Math.floor(e.finalX);const i=Math.floor(e.finalY);return Ke.style.left=t+"px",Ke.style.top=o+"px",Ke.style.display="block",Ke.style.opacity="1",Ke.style.transform="translate("+(s-t)+"px,"+(i-o)+"px)",!!e.arrowAtTop},Rc=function(){if(cs){var e=cs.getSourceBlock();e=Vg?Ec(cs):Tc(e);const t=e.left+(e.right-e.left)/2;kc(t,e.bottom,t,e.top)}else ln()},zi=function(e){return e.length?e.reduce(function(t,o){return t.length<o.length?t:o}).length:0},wc=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;let o=0;t=t||zi(e);let s;for(s=0;s<t;s++){for(var i=e[0][s],n=1;n<e.length;n++)if(i!==e[n][s])return o;i===" "&&(o=s+1)}for(i=1;i<e.length;i++)if((n=e[i][s])&&n!==" ")return o;return t},Oc=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;let o=0;t=t||zi(e);let s;for(s=0;s<t;s++){for(var i=e[0].substr(-s-1,1),n=1;n<e.length;n++)if(i!==e[n].substr(-s-1,1))return o;i===" "&&(o=s+1)}for(i=1;i<e.length;i++)if((n=e[i].charAt(e[i].length-s-1))&&n!==" ")return o;return t},r.wrap$$module$build$src$core$utils$string=function(e,t){e=e.split(`
6
+ `);for(let o=0;o<e.length;o++)e[o]=n$(e[o],t);return e.join(`
7
+ `)},n$=function(e,t){if(e.length<=t)return e;const o=e.trim().split(/\s+/);for(var s=0;s<o.length;s++)o[s].length>t&&(t=o[s].length);var i=-1/0;let n,d=1;do{s=i,n=e,e=[],i=o.length/d;let f=1;for(let L=0;L<o.length-1;L++)f<(L+1.5)/i?(f++,e[L]=!0):e[L]=!1;e=Nc(o,e,t),i=cn(o,e,t),e=l$(o,e),d++}while(i>s);return n},cn=function(e,t,o){const s=[0],i=[];for(var n=0;n<e.length;n++)s[s.length-1]+=e[n].length,t[n]===!0?(s.push(0),i.push(e[n].charAt(e[n].length-1))):t[n]===!1&&s[s.length-1]++;for(e=Math.max(...s),t=0,n=0;n<s.length;n++)t-=Math.pow(Math.abs(o-s[n]),1.5)*2,t-=Math.pow(e-s[n],1.5),".?!".includes(i[n])?t+=o/3:",;)]}".includes(i[n])&&(t+=o/4);return s.length>1&&s[s.length-1]<=s[s.length-2]&&(t+=.5),t},Nc=function(e,t,o){let s=cn(e,t,o),i;for(let n=0;n<t.length-1;n++){if(t[n]===t[n+1])continue;const d=[].concat(t);d[n]=!d[n],d[n+1]=!d[n+1];const f=cn(e,d,o);f>s&&(s=f,i=d)}return i?Nc(e,i,o):t},l$=function(e,t){const o=[];for(let s=0;s<e.length;s++)o.push(e[s]),t[s]!==void 0&&o.push(t[s]?`
8
+ `:" ");return o.join("")},r.isNumber$$module$build$src$core$utils$string=function(e){return/^\s*-?\d+(\.\d+)?\s*$/.test(e)},c$=function(e){Zn=e},u$=function(){return Zn},a$=function(){return gr},h$=function(){return at},ei=function(e){if(e=Ac(e)){for(e=e.tooltip;typeof e=="function";)e=e();if(typeof e!="string")throw Error("Tooltip function must return a string.");return e}return""},Ac=function(e){for(;e&&e.tooltip;){if(typeof e.tooltip=="string"||typeof e.tooltip=="function")return e;e=e.tooltip}return null},Lc=function(){document.querySelector(".blocklyTooltipDiv")||(at=document.createElement("div"),at.className="blocklyTooltipDiv",(Ae()||document.body).appendChild(at))},Yi=function(e){e.mouseOverWrapper_=ae(e,"pointerover",null,d$),e.mouseOutWrapper_=ae(e,"pointerout",null,$$),e.addEventListener("pointermove",Dc,!1)},Mc=function(e){e&&(te(e.mouseOverWrapper_),te(e.mouseOutWrapper_),e.removeEventListener("pointermove",Dc))},d$=function(e){fi||(e=Ac(e.currentTarget),qt!==e&&(xo(),mr=null,qt=e),clearTimeout(zg))},$$=function(e){fi||(zg=setTimeout(function(){mr=qt=null,xo()},1),clearTimeout(Ds),Ds=0)},Dc=function(e){if(qt&&qt.tooltip&&!fi)if(gr){const t=Na-e.pageX;e=Aa-e.pageY,Math.sqrt(t*t+e*e)>Yg&&xo()}else mr!==qt&&(clearTimeout(Ds),Na=e.pageX,Aa=e.pageY,Ds=setTimeout(f$,Xg))},xc=function(){mr=qt=null,xo()},xo=function(){gr&&(gr=!1,at&&(at.style.display="none")),Ds&&(clearTimeout(Ds),Ds=0)},Bc=function(){xo(),fi=!0},Pc=function(){fi=!1},p$=function(){at&&qt&&(typeof Zn=="function"?Zn(at,qt):g$())},g$=function(){var e=ei(qt);e=r.wrap$$module$build$src$core$utils$string(e,Wg),e=e.split(`
9
+ `);for(let t=0;t<e.length;t++){const o=document.createElement("div");o.appendChild(document.createTextNode(e[t])),at.appendChild(o)}},m$=function(e){const t=document.documentElement.clientWidth,o=document.documentElement.clientHeight;let s=Na;s=e?s-(La+at.offsetWidth):s+La;let i=Aa+Ma;return i+at.offsetHeight>o+window.scrollY&&(i-=at.offsetHeight+2*Ma),e?s=Math.max(Qn-window.scrollX,s):s+at.offsetWidth>t+window.scrollX-2*Qn&&(s=t-at.offsetWidth-2*Qn),{x:s,y:i}},f$=function(){if(!fi&&(mr=qt,at)){at.textContent="",p$();var e=qt.RTL;at.style.direction=e?"rtl":"ltr",at.style.display="block",gr=!0;var{x:t,y:o}=m$(e);at.style.left=t+"px",at.style.top=o+"px"}},Fc=function(){return Da},_$=function(e){Da=e},Uc=function(){return xa},b$=function(e){xa=e},Es=function(e){e=`${e}`.toLowerCase().trim();var t=jg[e];if(t||(t=e.substring(0,2)==="0x"?"#"+e.substring(2):e,t=t[0]==="#"?t:"#"+t,/^#[0-9a-f]{6}$/.test(t)))return t;if(/^#[0-9a-f]{3}$/.test(t))return["#",t[1],t[1],t[2],t[2],t[3],t[3]].join("");var o=e.match(/^(?:rgb)?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);return o&&(e=Number(o[1]),t=Number(o[2]),o=Number(o[3]),e>=0&&e<256&&t>=0&&t<256&&o>=0&&o<256)?Xi(e,t,o):null},Xi=function(e,t,o){return t=e<<16|t<<8|o,e<16?"#"+(16777216|t).toString(16).substr(1):"#"+t.toString(16)},un=function(e){return e=Es(e),e?(e=parseInt(e.substr(1),16),[e>>16,e>>8&255,e&255]):[0,0,0]},an=function(e,t,o){let s=0,i=0,n=0;if(t===0)n=i=s=o;else{const d=Math.floor(e/60),f=e/60-d;e=o*(1-t);const L=o*(1-t*f);switch(t=o*(1-t*(1-f)),d){case 1:s=L,i=o,n=e;break;case 2:s=e,i=o,n=t;break;case 3:s=e,i=L,n=o;break;case 4:s=t,i=e,n=o;break;case 5:s=o,i=e,n=L;break;case 6:case 0:s=o,i=t,n=e}}return Xi(Math.floor(s),Math.floor(i),Math.floor(n))},ys=function(e,t,o){return e=Es(e),!e||(t=Es(t),!t)?null:(e=un(e),t=un(t),Xi(Math.round(t[0]+o*(e[0]-t[0])),Math.round(t[1]+o*(e[1]-t[1])),Math.round(t[2]+o*(e[2]-t[2]))))},Hc=function(e){return an(e,Da,xa*255)},hn=function(e,t,o){const s=[];var i=e.split("");i.push("");var n=0;e=[];let d=null;for(let oe=0;oe<i.length;oe++){var f=i[oe];if(n===0)if(f==="%")(n=e.join(""))&&s.push(n),e.length=0,n=1;else if(o&&f===`
10
+ `){const ze=e.join("");ze&&s.push(ze),e.length=0,s.push(f)}else e.push(f);else if(n===1)f==="%"?(e.push(f),n=0):t&&"0"<=f&&f<="9"?(n=2,d=f,(f=e.join(""))&&s.push(f),e.length=0):f==="{"?n=3:(e.push("%",f),n=0);else if(n===2)if("0"<=f&&f<="9")d+=f;else{var L=void 0;s.push(parseInt((L=d)!=null?L:"",10)),oe--,n=0}else n===3&&(f===""?(e.splice(0,0,"%{"),oe--,n=0):f!=="}"?e.push(f):(n=e.join(""),/[A-Z]\w*/i.test(n)?(f=n.toUpperCase(),(f=f.startsWith("BKY_")?f.substring(4):null)&&f in r.Msg$$module$build$src$core$msg?(n=r.Msg$$module$build$src$core$msg[f],typeof n=="string"?Array.prototype.push.apply(s,hn(n,t,o)):t?s.push(`${n}`):s.push(n)):s.push("%{"+n+"}")):s.push("%{"+n+"}"),n=e.length=0))}for((t=e.join(""))&&s.push(t),L=[],e.length=0,i=0;i<s.length;i++)typeof s[i]!="string"||o&&s[i]===`
11
+ `?((t=e.join(""))&&L.push(t),e.length=0,L.push(s[i])):e.push(s[i]);return(t=e.join(""))&&L.push(t),e.length=0,L},Gc=function(e){return hn(e,!0,!0)},Je=function(e){return typeof e!="string"?e:(e=hn(e,!1,!1),e.length?String(e[0]):"")},T$=function(e){let t=!0;const o=r.Msg$$module$build$src$core$msg,s=e.match(/%{BKY_[A-Z]\w*}/gi);if(s)for(let i=0;i<s.length;i++){const n=s[i].toUpperCase();o[n.slice(6,-1)]===void 0&&(console.warn("No message string for "+s[i]+" in "+e),t=!1)}return t},ti=function(e){const t=typeof e=="string"?Je(e):e;var o=Number(t);if(!isNaN(o)&&0<=o&&o<=360)return{hue:o,hex:an(o,Fc(),Uc()*255)};if(o=Es(t))return{hue:null,hex:o};throw o='Invalid colour: "'+t+'"',e!==t&&(o+=' (from "'+e+'")'),Error(o)},oi=function(){return Wt},E$=function(e){if(Wt=e,e===null){let t;(t=document.querySelector("."+Ba))==null||t.remove()}},Vc=function(){const e=Ae()||document.body,t=document.querySelector("div."+Ba);t?Wt=t:(Wt=document.createElement("div"),Wt.className=Ba,Wt.tabIndex=-1),z(Wt,"keydown",null,S),e.appendChild(Wt)},dn=function(e,t,o,s,i=!0){if(si(),_i=e,el=o,o=Wt){if(o.style.direction=t?"rtl":"ltr",o.style.display="block",!s&&e instanceof we){let f;s=(f=e.getSourceBlock())==null?void 0:f.workspace}var n;Kg=(n=s)!=null?n:null;var d;e=(d=s)!=null?d:c(),bi=e.getRenderer().getClassName(),Ti=e.getTheme().getClassName(),bi&&G(o,bi),Ti&&G(o,Ti),i&&(tl=r.getFocusManager$$module$build$src$core$focus_manager().takeEphemeralFocus(o))}},si=function(){if(Wc()){_i=null;var e=Wt;e&&(e.style.display="none",e.style.left="",e.style.top="",el&&(el(),el=null),e.textContent="",bi&&(Te(e,bi),bi=""),Ti&&(Te(e,Ti),Ti=""),c().markFocused(),tl&&(tl(),tl=null))}},Wc=function(){return!!_i},vs=function(e){_i===e&&si()},ji=function(e){let t=Kg===null,o=e;for(;!t&&o;){if(o===e){t=!0;break}o=e.options.parentWorkspace}t&&si()},zc=function(e,t,o){Wt.style.left=e+"px",Wt.style.top=t+"px",Wt.style.height=o+"px"},Yc=function(e,t,o,s){const i=v$(e,t,o);e=y$(e,t,o,s),i<0?zc(e,0,o.height+i):zc(e,i,o.height)},y$=function(e,t,o,s){return s?Math.min(Math.max(t.right-o.width,e.left),e.right-o.width):Math.max(Math.min(t.left,e.right-o.width),e.left)},v$=function(e,t,o){return t.bottom+o.height>=e.bottom?t.top-o.height:t.bottom},I$=function(e){return!(e==null||!e.repositionForWindowResize)},Xc=function(){I$(_i)&&_i.repositionForWindowResize()||si()},C$=function(){return ol},jc=function(e){ol=e},ii=function(e,t,o,s,i){if(dn(Jg,o,Kc,s),t.length){i||(e instanceof PointerEvent?i=new P(e.clientX,e.clientY):(console.warn("Context menu opened with keyboard but no location given"),i=new P(0,0)));var n=S$(t,o,e,i);sl=n,k$(n,o,i),setTimeout(function(){n.focus()},1),ol=null}else Ki()},S$=function(e,t,o,s){const i=new Ta;i.setRole(Gt.MENU);for(let n=0;n<e.length;n++){const d=e[n];if(d.separator){i.addChild(new _g);continue}const f=new Vn(d.text);f.setRightToLeft(t),f.setRole(Gt.MENUITEM),i.addChild(f),f.setEnabled(d.enabled),d.enabled&&f.onAction(function(L,oe){Ki(),requestAnimationFrame(()=>{setTimeout(()=>{d.callback(d.scope,o,oe,s)},0)})},{})}return i},k$=function(e,t,o){const s=Zl();o=new ye(o.y+s.top,o.y+s.top,o.x+s.left,o.x+s.left),R$(e);const i=e.getSize();t&&(o.left+=i.width,o.right+=i.width,s.left+=i.width,s.right+=i.width),Yc(s,o,i,t),e.focus()},R$=function(e){var t=oi();if(!t)throw Error("Attempting to create a context menu when widget div is null");t=e.render(t),G(t,"blocklyContextMenu"),z(t,"contextmenu",null,w$),e.focus()},w$=function(e){e.preventDefault(),e.stopPropagation()},Ki=function(){vs(Jg),ol=null},Kc=function(){sl&&(sl.dispose(),sl=null)},r.callbackFactory$$module$build$src$core$contextmenu=function(e,t){return()=>{r.disable$$module$build$src$core$events$utils();let o;try{o=t instanceof Element?Is(t,e.workspace):Zs(t,e.workspace);const s=e.getRelativeToSurfaceXY();s.x=e.RTL?s.x-r.config$$module$build$src$core$config.snapRadius:s.x+r.config$$module$build$src$core$config.snapRadius,s.y+=r.config$$module$build$src$core$config.snapRadius*2,o.moveBy(s.x,s.y)}finally{r.enable$$module$build$src$core$events$utils()}return J()&&!o.isShadow()&&_(new(U(w.BLOCK_CREATE))(o)),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(o),o}},Jc=function(e,t){return t=Ye(t,e.getParentSvg(),e.getInverseScreenCTM()),t.x/=e.scale,t.y/=e.scale,t},$n=function(e,t,o){t=Jc(e,t),Zg.set(e,P.difference(o,t))},pn=function(e,t){if(t=Jc(e,t),e=Zg.get(e),!e)throw Error("Drag not initialized");return P.sum(e,t)},O$=function(e,t=!1){const o=r.createElement$$module$build$src$core$utils$xml("xml");var s=qc(r.allUsedVarModels$$module$build$src$core$variables(e));s.hasChildNodes()&&o.appendChild(s);for(const i of e.getTopComments())o.appendChild(Ji(i,t));for(e=e.getTopBlocks(!0),s=0;s<e.length;s++)o.appendChild(qi(e[s],t));return o},Ji=function(e,t=!1){const o=r.createElement$$module$build$src$core$utils$xml("comment");t||o.setAttribute("id",e.id),t=e.workspace;const s=e.getRelativeToSurfaceXY();return s.x=t.RTL?t.getWidth()-s.x:s.x,o.setAttribute("x",`${s.x}`),o.setAttribute("y",`${s.y}`),o.setAttribute("w",`${e.getSize().width}`),o.setAttribute("h",`${e.getSize().height}`),e.getText()&&(o.textContent=e.getText()),e.isCollapsed()&&o.setAttribute("collapsed","true"),e.isOwnEditable()||o.setAttribute("editable","false"),e.isOwnMovable()||o.setAttribute("movable","false"),e.isOwnDeletable()||o.setAttribute("deletable","false"),o},qc=function(e){const t=r.createElement$$module$build$src$core$utils$xml("variables");for(let o=0;o<e.length;o++){const s=e[o],i=r.createElement$$module$build$src$core$utils$xml("variable");i.appendChild(r.createTextNode$$module$build$src$core$utils$xml(s.getName())),s.getType()&&i.setAttribute("type",s.getType()),i.id=s.getId(),t.appendChild(i)}return t},qi=function(e,t){if(e.isInsertionMarker()&&(e=e.getChildren(!1)[0],!e))return new DocumentFragment;let o=0;if(e.workspace.RTL&&(o=e.workspace.getWidth()),t=ts(e,t),ou(t)){const s=e.getRelativeToSurfaceXY();t.setAttribute("x",String(Math.round(e.workspace.RTL?o-s.x:s.x))),t.setAttribute("y",String(Math.round(s.y)))}return t},N$=function(e){if(e.isSerializable()){const t=r.createElement$$module$build$src$core$utils$xml("field");return t.setAttribute("name",e.name||""),e.toXml(t)}return null},A$=function(e,t){for(const o of e.getFields())(e=N$(o))&&t.appendChild(e)},ts=function(e,t){if(e.isInsertionMarker())return(t=e.getChildren(!1)[0])?ts(t):new DocumentFragment;const o=r.createElement$$module$build$src$core$utils$xml(e.isShadow()?"shadow":"block");if(o.setAttribute("type",e.type),t||(o.id=e.id),e.mutationToDom){var s=e.mutationToDom();s&&(s.hasChildNodes()||s.hasAttributes())&&o.appendChild(s)}if(A$(e,o),s=e.getCommentText()){var i=e.getIcon(ut.COMMENT),n=i.getBubbleSize(),d=i.bubbleIsVisible();i=i.getBubbleLocation();var f=r.createElement$$module$build$src$core$utils$xml("comment");f.appendChild(r.createTextNode$$module$build$src$core$utils$xml(s)),f.setAttribute("pinned",`${d}`),f.setAttribute("h",`${n.height}`),f.setAttribute("w",`${n.width}`),i&&(f.setAttribute("x",`${e.workspace.RTL?e.workspace.getWidth()-(i.x+n.width):i.x}`),f.setAttribute("y",`${i.y}`)),o.appendChild(f)}for(e.data&&(s=r.createElement$$module$build$src$core$utils$xml("data"),s.appendChild(r.createTextNode$$module$build$src$core$utils$xml(e.data)),o.appendChild(s)),s=0;s<e.inputList.length;s++){n=e.inputList[s];var L=void 0;d=!0,n.type!==r.inputTypes$$module$build$src$core$inputs$input_types.DUMMY&&n.type!==r.inputTypes$$module$build$src$core$inputs$input_types.END_ROW&&(i=n.connection.targetBlock(),n.type===r.inputTypes$$module$build$src$core$inputs$input_types.VALUE?L=r.createElement$$module$build$src$core$utils$xml("value"):n.type===r.inputTypes$$module$build$src$core$inputs$input_types.STATEMENT&&(L=r.createElement$$module$build$src$core$utils$xml("statement")),f=n.connection.getShadowDom(),!f||i&&i.isShadow()||L.appendChild(Zc(f,t)),i&&(i=ts(i,t),i.nodeType===Uo.ELEMENT_NODE&&(L.appendChild(i),d=!1)),L.setAttribute("name",n.name),d||o.appendChild(L))}e.inputsInline!==void 0&&e.inputsInline!==e.inputsInlineDefault&&o.setAttribute("inline",String(e.inputsInline)),e.isCollapsed()&&o.setAttribute("collapsed","true"),e.isEnabled()||o.setAttribute("disabled-reasons",Array.from(e.getDisabledReasons()).map(encodeURIComponent).join(",")),e.isOwnDeletable()||o.setAttribute("deletable","false"),e.isOwnMovable()||o.setAttribute("movable","false"),e.isOwnEditable()||o.setAttribute("editable","false"),L=e.getNextBlock();let oe;return L&&(s=ts(L,t),s.nodeType===Uo.ELEMENT_NODE&&(oe=r.createElement$$module$build$src$core$utils$xml("next"),oe.appendChild(s),o.appendChild(oe))),e=e.nextConnection&&e.nextConnection.getShadowDom(),!e||L&&L.isShadow()||oe.appendChild(Zc(e,t)),o},Zc=function(e,t){let o=e=e.cloneNode(!0),s;for(;o;)if(t&&o.nodeName==="shadow"&&o.removeAttribute("id"),o.firstChild)o=o.firstChild;else{for(;o&&!o.nextSibling;){s=o,o=o.parentNode;let i;s.nodeType===Uo.TEXT_NODE&&s.data.trim()===""&&((i=o)==null?void 0:i.firstChild)!==s&&ke(s)}o&&(s=o,o=o.nextSibling,s.nodeType===Uo.TEXT_NODE&&s.data.trim()===""&&ke(s))}return e},fo=function(e){return Xs(e).replace(/<(\w+)([^<]*)\/>/g,"<$1$2></$1>")},L$=function(e){e=fo(e).split("<");let t="";for(let o=1;o<e.length;o++){const s=e[o];s[0]==="/"&&(t=t.substring(2)),e[o]=t+"<"+s,s[0]!=="/"&&s.slice(-2)!=="/>"&&(t+=" ")}return e=e.join(`
12
+ `),e=e.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1</$2>"),e.replace(/^\n/,"")},M$=function(e,t){return t.setResizesEnabled(!1),t.clear(),e=r.domToWorkspace$$module$build$src$core$xml(e,t),t.setResizesEnabled(!0),e},r.domToWorkspace$$module$build$src$core$xml=function(e,t){let o=0;t.RTL&&(o=t.getWidth());const s=[];eo();const i=r.getGroup$$module$build$src$core$events$utils();i||r.setGroup$$module$build$src$core$events$utils(!0),t.setResizesEnabled&&t.setResizesEnabled(!1);let n=!0;try{for(let d=0,f;f=e.childNodes[d];d++){const L=f.nodeName.toLowerCase(),oe=f;if(L==="block"||L==="shadow"&&!Ue()){const ze=Is(oe,t);s.push(ze.id);let Fe;const vt=parseInt((Fe=oe.getAttribute("x"))!=null?Fe:"10",10);let jo;const Ao=parseInt((jo=oe.getAttribute("y"))!=null?jo:"10",10);isNaN(vt)||isNaN(Ao)||ze.moveBy(t.RTL?o-vt:vt,Ao,["create"]),n=!1}else{if(L==="shadow")throw TypeError("Shadow block cannot be a top-level block.");if(L==="comment")Qc(oe,t);else if(L==="variables"){if(n)eu(oe,t);else throw Error("'variables' tag must exist once before block and shadow tag elements in the workspace XML, but it was found in another location.");n=!1}}}}finally{r.setGroup$$module$build$src$core$events$utils(i),t.setResizesEnabled&&t.setResizesEnabled(!0),t.rendered&&Qo(),to()}return _(new(U(w.FINISHED_LOADING))(t)),s},Qc=function(e,t){var o;const s=(o=e.getAttribute("id"))!=null?o:void 0;o=t.rendered?new yo(t,s):new nl(t,s);var i;o.setText((i=e.textContent)!=null?i:"");var n;i=parseInt((n=e.getAttribute("x"))!=null?n:"",10);let d;n=parseInt((d=e.getAttribute("y"))!=null?d:"",10),isNaN(i)||isNaN(n)||(i=t.RTL?t.getWidth()-i:i,o.moveTo(new P(i,n)));var f;t=parseInt((f=e.getAttribute("w"))!=null?f:"",10);let L;return f=parseInt((L=e.getAttribute("h"))!=null?L:"",10),isNaN(t)||isNaN(f)||o.setSize(new ve(t,f)),e.getAttribute("collapsed")==="true"&&o.setCollapsed(!0),e.getAttribute("editable")==="false"&&o.setEditable(!1),e.getAttribute("movable")==="false"&&o.setMovable(!1),e.getAttribute("deletable")==="false"&&o.setDeletable(!1),o},D$=function(e,t){if(!t.getBlocksBoundingBox)return r.domToWorkspace$$module$build$src$core$xml(e,t);var o=t.getBlocksBoundingBox();if(e=r.domToWorkspace$$module$build$src$core$xml(e,t),o&&o.top!==o.bottom){var s=o.bottom;o=t.RTL?o.right:o.left;var i=1/0;let n=-1/0,d=1/0;for(let f=0;f<e.length;f++){const L=t.getBlockById(e[f]).getRelativeToSurfaceXY();L.y<d&&(d=L.y),L.x<i&&(i=L.x),L.x>n&&(n=L.x)}for(s=s-d+10,o=t.RTL?o-n:o-i,i=0;i<e.length;i++)t.getBlockById(e[i]).moveBy(o,s,["create"])}return e},r.domToBlock$$module$build$src$core$xml=function(e,t){return e=Is(e,t),t.rendered&&Qo(),e},Is=function(e,t){r.disable$$module$build$src$core$events$utils();var o=t.getAllVariables();let s;try{if(s=gn(e,t),t.rendered){const i=s,n=s.getDescendants(!1);i.setConnectionTracking(!1);for(let d=n.length-1;d>=0;d--)n[d].initSvg();for(let d=n.length-1;d>=0;d--)n[d].queueRender();setTimeout(function(){i.disposed||i.setConnectionTracking(!0)},1),t.resizeContents()}else{const i=s.getDescendants(!1);for(let n=i.length-1;n>=0;n--)i[n].initModel()}}finally{r.enable$$module$build$src$core$events$utils()}if(J()){for(e=Vi(t,o),t=0;t<e.length;t++)o=e[t],_(new(U(w.VAR_CREATE))(o));_(new(U(w.BLOCK_CREATE))(s))}return s},eu=function(e,t){for(let s=0;s<e.children.length;s++){var o=e.children[s];const i=o.getAttribute("type"),n=o.getAttribute("id");if(o=o.textContent,!o)break;let d;t.getVariableMap().createVariable(o,(d=i)!=null?d:void 0,n)}},x$=function(e){const t={mutation:[],comment:[],data:[],field:[],input:[],next:[]};for(let o=0;o<e.children.length;o++){const s=e.children[o];if(s.nodeType!==Uo.TEXT_NODE)switch(s.nodeName.toLowerCase()){case"mutation":t.mutation.push(s);break;case"comment":t.comment.push(s);break;case"data":t.data.push(s);break;case"title":case"field":t.field.push(s);break;case"value":case"statement":t.input.push(s);break;case"next":t.next.push(s);break;default:console.warn("Ignoring unknown tag: "+s.nodeName)}}return t},B$=function(e,t){let o=!1;for(let s=0;s<e.length;s++){const i=e[s];t.domToMutation&&(t.domToMutation(i),t.initSvg&&(o=!0))}return o},P$=function(e,t){for(let o=0;o<e.length;o++){const s=e[o],i=s.textContent,n=s.getAttribute("pinned")==="true";let d;const f=parseInt((d=s.getAttribute("w"))!=null?d:"50",10);let L;const oe=parseInt((L=s.getAttribute("h"))!=null?L:"50",10);let ze,Fe=parseInt((ze=s.getAttribute("x"))!=null?ze:"",10),vt;const jo=parseInt((vt=s.getAttribute("y"))!=null?vt:"",10);t.setCommentText(i);const Ao=t.getIcon(ut.COMMENT);isNaN(f)||isNaN(oe)||Ao.setBubbleSize(new ve(f,oe)),Ao.setBubbleVisible(n),setTimeout(()=>{isNaN(Fe)||isNaN(jo)||(Fe=t.workspace.RTL?t.workspace.getWidth()-(Fe+f):Fe,Ao.setBubbleLocation(new P(Fe,jo))),Ao.setBubbleVisible(n)},1)}},F$=function(e,t){for(let o=0;o<e.length;o++)t.data=e[o].textContent},U$=function(e,t){for(let o=0;o<e.length;o++){const s=e[o],i=s.getAttribute("name");i?V$(t,i,s):console.warn(`Ignoring unnamed field in block ${t.type}`)}},tu=function(e){let t=null,o=null;for(let s=0;s<e.childNodes.length;s++){const i=e.childNodes[s];ou(i)&&(i.nodeName.toLowerCase()==="block"?t=i:i.nodeName.toLowerCase()==="shadow"&&(o=i))}return{childBlockElement:t,childShadowElement:o}},H$=function(e,t,o,s){for(let n=0;n<e.length;n++){var i=e[n];const d=i.getAttribute("name"),f=d?o.getInput(d):null;if(!f){console.warn("Ignoring non-existent input "+d+" in block "+s);break}if(i=tu(i),i.childBlockElement){if(!f.connection)throw TypeError("Input connection does not exist.");gn(i.childBlockElement,t,f.connection,!1)}if(i.childShadowElement){let L;(L=f.connection)==null||L.setShadowDom(i.childShadowElement)}}},G$=function(e,t,o){for(let s=0;s<e.length;s++){const i=tu(e[s]);if(i.childBlockElement){if(!o.nextConnection)throw TypeError("Next statement does not exist.");if(o.nextConnection.isConnected())throw TypeError("Next statement is already connected.");gn(i.childBlockElement,t,o.nextConnection,!0)}i.childShadowElement&&o.nextConnection&&o.nextConnection.setShadowDom(i.childShadowElement)}},gn=function(e,t,o,s){var i;const n=e.getAttribute("type");if(!n)throw TypeError("Block type unspecified: "+e.outerHTML);var d=(i=e.getAttribute("id"))!=null?i:void 0;i=t.newBlock(n,d),d=x$(e);const f=B$(d.mutation,i);if(P$(d.comment,i),F$(d.data,i),o)if(s)if(i.previousConnection)o.connect(i.previousConnection);else throw TypeError("Next block does not have previous statement.");else if(i.outputConnection)o.connect(i.outputConnection);else if(i.previousConnection)o.connect(i.previousConnection);else throw TypeError("Child block does not have output or previous statement.");if(U$(d.field,i),H$(d.input,t,i,n),G$(d.next,t,i),f&&i.initSvg(),(t=e.getAttribute("inline"))&&i.setInputsInline(t==="true"),(t=e.getAttribute("disabled"))&&i.setDisabledReason(t==="true"||t==="disabled",Jt),t=e.getAttribute("disabled-reasons"),t!==null)for(var L of t.split(","))i.setDisabledReason(!0,decodeURIComponent(L));if((L=e.getAttribute("deletable"))&&i.setDeletable(L==="true"),(L=e.getAttribute("movable"))&&i.setMovable(L==="true"),(L=e.getAttribute("editable"))&&i.setEditable(L==="true"),(L=e.getAttribute("collapsed"))&&i.setCollapsed(L==="true"),e.nodeName.toLowerCase()==="shadow"){for(e=i.getChildren(!1),L=0;L<e.length;L++)if(!e[L].isShadow())throw TypeError("Shadow block not allowed non-shadow child.");i.setShadow(!0)}return i},V$=function(e,t,o){const s=e.getField(t);s?s.fromXml(o):console.warn("Ignoring non-existent field "+t+" in block "+e.type)},W$=function(e){for(let t=0;t<e.childNodes.length;t++){const o=e.childNodes[t];if(o.nodeName.toLowerCase()==="next"){e.removeChild(o);break}}},ou=function(e){return e.nodeType===Uo.ELEMENT_NODE},_o=function(e,t){l(M.FIELD,e,t)},z$=function(e){m(M.FIELD,e)},r.fromJson$$module$build$src$core$field_registry=function(e){return im.fromJsonInternal(e)},Y$=function(e){const t=D(M.FIELD,e.type);return t?t.fromJson(e):(console.warn("Blockly could not create a field of type "+e.type+". The field is probably not being registered. This could be because the file is not loaded, the field does not register itself (Issue #1584), or the registration is not being reached."),null)},ri=function(e){return e&&typeof e=="object"&&"src"in e&&typeof e.src=="string"&&"alt"in e&&typeof e.alt=="string"&&"width"in e&&typeof e.width=="number"&&"height"in e&&typeof e.height=="number"},r.register$$module$build$src$core$extensions=function(e,t){if(typeof e!="string"||e.trim()==="")throw Error('Error: Invalid extension name "'+e+'"');if(yi[e])throw Error('Error: Extension "'+e+'" is already registered.');if(typeof t!="function")throw Error('Error: Extension "'+e+'" must be a function');yi[e]=t},r.registerMixin$$module$build$src$core$extensions=function(e,t){if(!t||typeof t!="object")throw Error('Error: Mixin "'+e+'" must be a object');r.register$$module$build$src$core$extensions(e,function(){this.mixin(t)})},r.registerMutator$$module$build$src$core$extensions=function(e,t,o,s){const i='Error when registering mutator "'+e+'": ';ru(i,t);const n=iu(t,i);if(o&&typeof o!="function")throw Error(i+'Extension "'+e+'" is not a function');r.register$$module$build$src$core$extensions(e,function(){n&&this.setMutator(new r.MutatorIcon$$module$build$src$core$icons$mutator_icon(s||[],this)),this.mixin(t),o&&o.apply(this)})},X$=function(e){su(e)?delete yi[e]:console.warn('No extension mapping for name "'+e+'" found to unregister')},su=function(e){return!!yi[e]},mn=function(e,t,o){const s=yi[e];if(typeof s!="function")throw Error('Error: Extension "'+e+'" not found.');let i;if(o?j$(e,t):i=_n(t),s.apply(t),o)ru('Error after applying mutator "'+e+'": ',t);else if(!q$(i,t))throw Error('Error when applying extension "'+e+'": mutation properties changed when applying a non-mutator extension.')},j$=function(e,t){if(_n(t).length)throw Error('Error: tried to apply mutation "'+e+'" to a block that already has mutator functions. Block id: '+t.id)},K$=function(e,t){return fn(e.mutationToDom,e.domToMutation,t+" mutationToDom/domToMutation")},J$=function(e,t){return fn(e.saveExtraState,e.loadExtraState,t+" saveExtraState/loadExtraState")},iu=function(e,t){return fn(e.compose,e.decompose,t+" compose/decompose")},fn=function(e,t,o){if(e&&t){if(typeof e!="function"||typeof t!="function")throw Error(o+" must be a function");return!0}if(!e&&!t)return!1;throw Error(o+"Must have both or neither functions")},ru=function(e,t){const o=K$(t,e),s=J$(t,e);if(!o&&!s)throw Error(e+"Mutations must contain either XML hooks, or JSON hooks, or both");iu(t,e)},_n=function(e){const t=[];return e.domToMutation!==void 0&&t.push(e.domToMutation),e.mutationToDom!==void 0&&t.push(e.mutationToDom),e.saveExtraState!==void 0&&t.push(e.saveExtraState),e.loadExtraState!==void 0&&t.push(e.loadExtraState),e.compose!==void 0&&t.push(e.compose),e.decompose!==void 0&&t.push(e.decompose),t},q$=function(e,t){if(t=_n(t),t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(e[o]!==t[o])return!1;return!0},Z$=function(e){if(typeof document!="object")throw Error("runAfterPageLoad() requires browser document.");if(document.readyState==="complete")e();else{const t=setInterval(function(){document.readyState==="complete"&&(clearInterval(t),e())},10)}},r.buildTooltipForDropdown$$module$build$src$core$extensions=function(e,t){const o=[];return function(){o.includes(this.type)||(Q$(this,e,t),o.push(this.type)),this.setTooltip((function(){const s=String(this.getFieldValue(e));return Je(t[s])}).bind(this))}},Q$=function(e,t,o){var s=e.getField(t);if(s instanceof yt&&!s.isOptionListDynamic()){s=s.getOptions();for(const i of s)i!==yt.SEPARATOR&&([,s]=i,o[s]===void 0&&console.warn(`No tooltip mapping for value ${s} of field ${t} of block type ${e.type}.`))}},r.buildTooltipWithFieldText$$module$build$src$core$extensions=function(e,t){return function(){this.setTooltip((function(){const o=this.getField(t);return Je(e).replace("%1",o?o.getText():"")}).bind(this))}},ep=function(){const e=this.tooltip;this.setTooltip((function(){const t=this.getParent();return t&&t.getInputsInline()&&t.tooltip||e}).bind(this))},se=function(e,t){return" "+e+","+t+" "},Pt=function(e,t){return" "+e+t.join("")},gt=function(e,t){return" M "+e+","+t+" "},je=function(e,t){return" m "+e+","+t+" "},bo=function(e,t){return" l "+e+","+t+" "},ni=function(e){return" l"+e.join("")},re=function(e,t){return" "+e+" "+t+" "},qe=function(e,t,o,s){return e+" "+o+" "+o+" "+t+s},tp=function(e,t){if(!e||!t)throw Error("Cannot connect null connections.");e.targetConnection=t,t.targetConnection=e},op=function(e,t){let o=null;t=t.outputConnection;const s=t?.getConnectionChecker();for(let i=0,n;n=e.inputList[i];i++){const d=n.connection;let f;if(d&&((f=s)!=null&&f.canConnect(t,d,!1))){if(o)return null;o=d}}return o},sp=function(e,t){let o;for(;o=op(e,t);)if(e=o.targetBlock(),!e||e.isShadow())return o;return null},nu=function(e){return oo(e)&&typeof e.getType=="function"&&typeof e.initView=="function"&&typeof e.dispose=="function"&&typeof e.getWeight=="function"&&typeof e.getSize=="function"&&typeof e.applyColour=="function"&&typeof e.hideForInsertionMarker=="function"&&typeof e.updateEditable=="function"&&typeof e.updateCollapsed=="function"&&typeof e.isShownWhenCollapsed=="function"&&typeof e.setOffsetInBlock=="function"&&typeof e.onLocationChange=="function"&&typeof e.onClick=="function"},ip=function(e){return nu(e)&&Ts(e)&&Hi(e)&&typeof e.setText=="function"&&typeof e.getText=="function"&&typeof e.setBubbleSize=="function"&&typeof e.getBubbleSize=="function"&&typeof e.setBubbleLocation=="function"&&typeof e.getBubbleLocation=="function"&&e.getType()===ut.COMMENT},bn=function(e){if(!(e.getDescendants(!1).length>100)){var t=e.workspace,o=e.getSvgRoot();t.getAudioManager().play("delete");var s=e.getRelativeToSurfaceXY(),i=o.cloneNode(!0);i.setAttribute("transform","translate("+s.x+","+s.y+")");var n;(n=t.getLayerManager())==null||n.appendToAnimationLayer({getSvgRoot:()=>i}),lu(i,{x:s.x,y:s.y,width:e.width,height:e.height},t.RTL,new Date)}},lu=function(e,t,o,s){const i=(new Date().getTime()-s.getTime())/150;i>1?ke(e):(e.setAttribute("transform","translate("+(t.x+(o?-1:1)*t.width/2*i)+","+(t.y+t.height/2*i)+") scale("+(1-i)+")"),setTimeout(lu,10,e,t,o,s))},cu=function(e){var t=e.workspace;const o=t.scale;if(t.getAudioManager().play("click"),!(o<1)){var s=t.getSvgXY(e.getSvgRoot());e.outputConnection?(s.x+=(e.RTL?3:-3)*o,s.y+=13*o):e.previousConnection&&(s.x+=(e.RTL?-23:23)*o,s.y+=3*o);var i=v(R.CIRCLE,{cx:s.x,cy:s.y,r:0,fill:"none",stroke:"#888","stroke-width":10},t.getParentSvg());e=v(R.ANIMATE,{id:"animationCircle",begin:"indefinite",attributeName:"r",dur:"150ms",from:0,to:25*o},i),t=v(R.ANIMATE,{id:"animationOpacity",begin:"indefinite",attributeName:"opacity",dur:"150ms",from:1,to:0},i),e.beginElement(),t.beginElement(),setTimeout(()=>void ke(i),150)}},uu=function(e){if(li(),e.workspace.getAudioManager().play("disconnect"),!(e.workspace.scale<1)){var t=e.getHeightWidth().height;t=Math.atan(10/t)/Math.PI*180,e.RTL||(t*=-1),Tr=e,au(e,t,new Date,0)}},au=function(e,t,o,s){const i=[.66,1,.66,0,-.66,-1,-.66,0];let n="";o.getTime()+200>new Date().getTime()&&(n=`skewX(${Math.round(i[s%i.length]*t)})`,hl=setTimeout(au,15,e,t,o,s+1)),e.getSvgRoot().setAttribute("transform",`${e.getTranslation()} ${n}`)},li=function(){Tr&&(hl&&(clearTimeout(hl),hl=null),Tr.getSvgRoot().setAttribute("transform",Tr.getTranslation()),Tr=null)},rp=function(e,t){const o=e.workspace,s=r.config$$module$build$src$core$config.snapRadius,i=P.difference(t,e.getRelativeToSurfaceXY()),n=new P(0,0),d=o.getAllBlocks(!1).filter(f=>f.id!=e.id).map(f=>f.getRelativeToSurfaceXY());for(;np(P.sum(t,n),d)||lp(e,P.sum(i,n),s);)o.RTL?n.translate(-s,s*2):n.translate(s,s*2);e.moveTo(P.sum(t,n))},np=function(e,t){return t.some(o=>Math.abs(o.x-e.x)<=1&&Math.abs(o.y-e.y)<=1)},lp=function(e,t,o){return e.getConnections_(!1).some(s=>!!s.closest(o,t).connection)},ci=function(e,t,o){const s=o.getBoundingRectangle(),i=s.right-s.left,n=Qs(t.top,s.top,t.top+t.height-(s.bottom-s.top))-s.top;let d=t.left;return t=t.left+t.width-i,e.RTL?d=Math.min(t,d):t=Math.max(d,t),(e=Qs(d,s.left,t)-s.left)||n?(o.moveBy(e,n,["inbounds"]),!0):!1},hu=function(e){return t=>{var o=e.getMetricsManager();if(o.hasFixedEdges()&&!e.isDragging()){var s;if(Jp.includes((s=t.type)!=null?s:"")){s=o.getScrollMetrics(!0);const i=cp(e,t);i&&(o=r.getGroup$$module$build$src$core$events$utils()||!1,r.setGroup$$module$build$src$core$events$utils(t.group),ci(e,s,i)&&!t.group&&console.warn("Moved object in bounds but there was no event group. This may break undo."),r.setGroup$$module$build$src$core$events$utils(o))}else St(t)&&t.scale&&t.oldScale&&t.scale>t.oldScale&&Tn(e)}}},cp=function(e,t){let o=null;switch(t.type){case w.BLOCK_CREATE:case w.BLOCK_MOVE:(o=e.getBlockById(t.blockId))&&(o=o.getRootBlock());break;case w.COMMENT_CREATE:case w.COMMENT_MOVE:case w.COMMENT_RESIZE:o=e.getCommentById(t.commentId)}return o},Tn=function(e){var t=e.getMetricsManager();if(t.hasFixedEdges()&&!e.isDragging()){t=t.getScrollMetrics(!0);var o=e.getTopBoundedElements();for(let s=0,i;i=o[s];s++)ci(e,t,i)}},Kt=function(e){return e&&typeof e.isDeletable=="function"&&typeof e.dispose=="function"&&typeof e.setDeleteStyle=="function"},du=function(e,t){const o=e.getIcons();for(const s of e.inputList){if(!s.isVisible())continue;o.push(...s.fieldRow);let i;if((i=s.connection)!=null&&i.targetBlock())if(e=s.connection.targetBlock(),s.connection.type!==Z.NEXT_STATEMENT||t)o.push(e);else{let n;(e=(n=e.lastConnectionInStack(!1))==null?void 0:n.getSourceBlock())&&o.push(e)}else{let n;((n=s.connection)==null?void 0:n.type)===Z.INPUT_VALUE&&o.push(s.connection)}}return o},ui=function(e,t){const o=e.workspace.getTopBoundedElements(!0).filter(i=>oo(i));e=o.indexOf(e instanceof Be?e.getRootBlock():e)+t;let s=null;if(e>=0&&e<o.length?s=o[e]:e<0?s=o[o.length-1]:e>=o.length&&(s=o[0]),t<0&&s instanceof Be){let i,n;return(n=(i=s.lastConnectionInStack(!1))==null?void 0:i.getSourceBlock())!=null?n:s}return s},ro=function(e,t){var o;let s;const i=e instanceof Be?(s=(o=e.outputConnection)==null?void 0:o.targetBlock())!=null?s:e.getSurroundParent():e.getSourceBlock();return!(i instanceof Be)||(o=du(i,t>0),e=o.indexOf(e),e===-1)?null:(t=e+t,t>=0&&t<o.length?o[t]:null)},ai=function(e){return e&&typeof e.getRelativeToSurfaceXY=="function"&&typeof e.isMovable=="function"&&typeof e.startDrag=="function"&&typeof e.drag=="function"&&typeof e.endDrag=="function"&&typeof e.revertDrag=="function"},$u=function(e){return e&&typeof e.autoHide=="function"},pu=function(e,t){l(M.ICON,e.toString(),t)},up=function(e){m(M.ICON,e)},os=function(e){return typeof e.getProcedureModel=="function"&&typeof e.doProcedureUpdate=="function"&&typeof e.isProcedureDef=="function"},En=function(e){return e&&typeof e.startPublishing=="function"&&typeof e.stopPublishing=="function"},Zi=function(e){const t=e.getProcedureMap().getProcedures().filter(s=>!s.getReturnTypes()).map(s=>[s.getName(),s.getParameters().map(i=>i.getName()),!1]);e.getBlocksByType("procedures_defnoreturn",!1).forEach(s=>{!os(s)&&Ks(s)&&t.push(s.getProcedureDef())});const o=e.getProcedureMap().getProcedures().filter(s=>!!s.getReturnTypes()).map(s=>[s.getName(),s.getParameters().map(i=>i.getName()),!0]);return e.getBlocksByType("procedures_defreturn",!1).forEach(s=>{!os(s)&&Ks(s)&&o.push(s.getProcedureDef())}),t.sort(gu),o.sort(gu),[t,o]},gu=function(e,t){return e[0].localeCompare(t[0],void 0,{sensitivity:"base"})},r.findLegalName$$module$build$src$core$procedures=function(e,t){if(t.isInFlyout)return e;for(e=e||r.Msg$$module$build$src$core$msg.UNNAMED_KEY||"unnamed";!ap(e,t.workspace,t);){const o=e.match(/^(.*?)(\d+)$/);e=o?o[1]+(parseInt(o[2])+1):e+"2"}return e},ap=function(e,t,o){return!mu(e,t,o)},mu=function(e,t,o){for(const s of t.getAllBlocks(!1))if(s!==o&&Ks(s)&&r.Names$$module$build$src$core$names.equals(s.getProcedureDef()[0],e))return!0;o=o&&os(o)?o?.getProcedureModel():void 0;for(const s of t.getProcedureMap().getProcedures())if(s!==o&&r.Names$$module$build$src$core$names.equals(s.getName(),e))return!0;return!1},r.rename$$module$build$src$core$procedures=function(e){var t=this.getSourceBlock();if(!t)throw new tt;e=e.trim();const o=r.findLegalName$$module$build$src$core$procedures(e,t);os(t)&&!t.isInsertionMarker()&&t.getProcedureModel().setName(o);const s=this.getValue();if(s!==e&&s!==o)for(e=t.workspace.getAllBlocks(!1),t=0;t<e.length;t++){const i=e[t];i.renameProcedure&&i.renameProcedure(s,o)}return o},hp=function(e){function t(n,d){for(let L=0;L<n.length;L++){var f=n[L][0];const oe=n[L][1],ze=r.createElement$$module$build$src$core$utils$xml("block");ze.setAttribute("type",d),ze.setAttribute("gap","16");const Fe=r.createElement$$module$build$src$core$utils$xml("mutation");for(Fe.setAttribute("name",f),ze.appendChild(Fe),f=0;f<oe.length;f++){const vt=r.createElement$$module$build$src$core$utils$xml("arg");vt.setAttribute("name",oe[f]),Fe.appendChild(vt)}o.push(ze)}}const o=[];if(Ge.procedures_defnoreturn){var s=r.createElement$$module$build$src$core$utils$xml("block");s.setAttribute("type","procedures_defnoreturn"),s.setAttribute("gap","16");var i=r.createElement$$module$build$src$core$utils$xml("field");i.setAttribute("name","NAME"),i.appendChild(r.createTextNode$$module$build$src$core$utils$xml(r.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_PROCEDURE)),s.appendChild(i),o.push(s)}return Ge.procedures_defreturn&&(s=r.createElement$$module$build$src$core$utils$xml("block"),s.setAttribute("type","procedures_defreturn"),s.setAttribute("gap","16"),i=r.createElement$$module$build$src$core$utils$xml("field"),i.setAttribute("name","NAME"),i.appendChild(r.createTextNode$$module$build$src$core$utils$xml(r.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_PROCEDURE)),s.appendChild(i),o.push(s)),Ge.procedures_ifreturn&&(s=r.createElement$$module$build$src$core$utils$xml("block"),s.setAttribute("type","procedures_ifreturn"),s.setAttribute("gap","16"),o.push(s)),o.length&&o[o.length-1].setAttribute("gap","24"),e=Zi(e),t(e[0],"procedures_callnoreturn"),t(e[1],"procedures_callreturn"),o},yn=function(e){return fu(e,!1)},fu=function(e,t=!0){function o(i,n){for(const[d,f]of i)s.push({kind:"block",type:n,gap:16,extraState:{name:d,params:f}})}if(t)return pt("The XML return value of Blockly.Procedures.flyoutCategory()","v12","v13","the same method, but handle a return type of FlyoutItemInfo[] (JSON) instead."),hp(e);const s=[];return Ge.procedures_defnoreturn&&s.push({kind:"block",type:"procedures_defnoreturn",gap:16,fields:{NAME:r.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_PROCEDURE}}),Ge.procedures_defreturn&&s.push({kind:"block",type:"procedures_defreturn",gap:16,fields:{NAME:r.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_PROCEDURE}}),Ge.procedures_ifreturn&&s.push({kind:"block",type:"procedures_ifreturn",gap:16}),s.length&&(s[s.length-1].gap=24),e=Zi(e),o(e[0],"procedures_callnoreturn"),o(e[1],"procedures_callreturn"),s},_u=function(e){var t=[],o=e.getBlocksByType("procedures_mutatorarg",!1);for(let n=0,d;d=o[n];n++)t.push(d.getFieldValue("NAME"));o=r.createElement$$module$build$src$core$utils$xml("xml");const s=r.createElement$$module$build$src$core$utils$xml("block");s.setAttribute("type","procedures_mutatorarg");const i=r.createElement$$module$build$src$core$utils$xml("field");i.setAttribute("name","NAME"),t=Qr(r.DEFAULT_ARG$$module$build$src$core$procedures,t),t=r.createTextNode$$module$build$src$core$utils$xml(t),i.appendChild(t),s.appendChild(i),o.appendChild(s),e.updateToolbox(o)},bu=function(e){if($t(e)&&e.bubbleType==="mutator"&&e.isOpen&&e.blockId){e=ct(e.workspaceId).getBlockById(e.blockId);var t=e.type;(t==="procedures_defnoreturn"||t==="procedures_defreturn")&&(e=e.getIcon(r.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE).getWorkspace(),_u(e),e.addChangeListener(dp))}},dp=function(e){(bt(e)||Bt(e)||Ct(e)||nt(e))&&(e=ct(e.workspaceId),_u(e))},Tu=function(e,t){return t.getAllBlocks(!1).filter(o=>$p(o,e)||Ld(o)&&r.Names$$module$build$src$core$names.equals(o.getProcedureCall(),e))},$p=function(e,t){return os(e)&&!e.isProcedureDef()&&e.getProcedureModel()&&r.Names$$module$build$src$core$names.equals(e.getProcedureModel().getName(),t)},r.mutateCallers$$module$build$src$core$procedures=function(e){const t=Ue();var o=e.getProcedureDef()[0];const s=e.mutationToDom(!0);e=Tu(o,e.workspace);for(let n=0,d;d=e[n];n++){o=(o=d.mutationToDom())&&Xs(o),d.domToMutation&&d.domToMutation(s);var i=d.mutationToDom();i=i&&Xs(i),o!==i&&(r.setRecordUndo$$module$build$src$core$events$utils(!1),_(new(U(w.BLOCK_CHANGE))(d,"mutation",null,o,i)),r.setRecordUndo$$module$build$src$core$events$utils(t))}},r.getDefinition$$module$build$src$core$procedures=function(e,t){for(const o of t.getAllBlocks(!1))if(os(o)&&o.isProcedureDef()&&r.Names$$module$build$src$core$names.equals(o.getProcedureModel().getName(),e)||Ks(o)&&r.Names$$module$build$src$core$names.equals(o.getProcedureDef()[0],e))return o;return null},vn=function(e){return e.isDynamic},pp=function(e){return e.pathDown!==void 0&&e.pathUp!==void 0},gp=function(e){return e.pathLeft!==void 0&&e.pathRight!==void 0},Qi=function(e,t){l(M.RENDERER,e,t)},mp=function(e){m(M.RENDERER,e)},Eu=function(e,t,o){return e=new(A(M.RENDERER,e))(e),e.init(t,o),e},In=function(e){_s(e.getTargetWorkspace(),void 0,"String")},Cn=function(e){_s(e.getTargetWorkspace(),void 0,"Number")},Sn=function(e){_s(e.getTargetWorkspace(),void 0,"Colour")},kn=function(e){return yu(e,!1)},yu=function(e,t=!0){return Ge.variables_set_dynamic||Ge.variables_get_dynamic||console.warn("There are no dynamic variable blocks, but there is a dynamic variable category."),t?(pt("The XML return value of Blockly.VariablesDynamic.flyoutCategory()","v12","v13","the same method, but handle a return type of FlyoutItemInfo[] (JSON) instead."),fp(e)):(e.registerButtonCallback("CREATE_VARIABLE_STRING",In),e.registerButtonCallback("CREATE_VARIABLE_NUMBER",Cn),e.registerButtonCallback("CREATE_VARIABLE_COLOUR",Sn),[{kind:"button",text:r.Msg$$module$build$src$core$msg.NEW_STRING_VARIABLE,callbackkey:"CREATE_VARIABLE_STRING"},{kind:"button",text:r.Msg$$module$build$src$core$msg.NEW_NUMBER_VARIABLE,callbackkey:"CREATE_VARIABLE_NUMBER"},{kind:"button",text:r.Msg$$module$build$src$core$msg.NEW_COLOUR_VARIABLE,callbackkey:"CREATE_VARIABLE_COLOUR"},...Zr(e,e.getVariableMap().getAllVariables(),!1,"variables_get_dynamic","variables_set_dynamic")])},fp=function(e){let t=[],o=document.createElement("button");return o.setAttribute("text",r.Msg$$module$build$src$core$msg.NEW_STRING_VARIABLE),o.setAttribute("callbackKey","CREATE_VARIABLE_STRING"),t.push(o),o=document.createElement("button"),o.setAttribute("text",r.Msg$$module$build$src$core$msg.NEW_NUMBER_VARIABLE),o.setAttribute("callbackKey","CREATE_VARIABLE_NUMBER"),t.push(o),o=document.createElement("button"),o.setAttribute("text",r.Msg$$module$build$src$core$msg.NEW_COLOUR_VARIABLE),o.setAttribute("callbackKey","CREATE_VARIABLE_COLOUR"),t.push(o),e.registerButtonCallback("CREATE_VARIABLE_STRING",In),e.registerButtonCallback("CREATE_VARIABLE_NUMBER",Cn),e.registerButtonCallback("CREATE_VARIABLE_COLOUR",Sn),e=vu(e),t=t.concat(e)},vu=function(e){e=e.getVariableMap().getAllVariables();const t=[];if(e.length>0){if(Ge.variables_set_dynamic){var o=e[e.length-1];const s=r.createElement$$module$build$src$core$utils$xml("block");s.setAttribute("type","variables_set_dynamic"),s.setAttribute("gap","24"),s.appendChild(bs(o)),t.push(s)}if(Ge.variables_get_dynamic){e.sort(Js);for(let s=0,i;i=e[s];s++)o=r.createElement$$module$build$src$core$utils$xml("block"),o.setAttribute("type","variables_get_dynamic"),o.setAttribute("gap","8"),o.appendChild(bs(i)),t.push(o)}}return t},Rn=function(e,t){const o=e.toCopyData();return kr=o,Rr=Do(e)&&e.workspace instanceof At?e.workspace:null,kl=t,o},wn=function(){return kr},_p=function(e){kr=e},On=function(){return Rr},bp=function(e){Rr=e},Iu=function(){return kl},Tp=function(e){kl=e},ss=function(e,t,o){return e&&t?Cu(e,t,o):kr&&Rr?Cu(kr,Rr,kl):null},Cu=function(e,t,o){let s;t=t.isMutator?t:(s=t.options.parentWorkspace)!=null?s:t;let i,n;return(n=(i=D(M.PASTER,e.paster,!1))==null?void 0:i.paste(e,t,o))!=null?n:null},er=function(e){return e&&typeof e.toCopyData=="function"},Su=function(){Pe.registry.register({name:ko.ESCAPE,preconditionFn(e){return!e.isReadOnly()},callback(e){return e.hideChaff(),!0},keyCodes:[Le.ESC]})},ku=function(){Pe.registry.register({name:ko.DELETE,preconditionFn(e,t){return t=t.focusedNode,!e.isReadOnly()&&t!=null&&Kt(t)&&t.isDeletable()&&!e.isDragging()&&!r.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()},callback(e,t,o,s){return t.preventDefault(),e=s.focusedNode,e instanceof Be?e.checkAndDelete():Kt(e)&&e.isDeletable()&&(r.setGroup$$module$build$src$core$events$utils(!0),e.dispose(),r.setGroup$$module$build$src$core$events$utils(!1)),!0},keyCodes:[Le.DELETE,Le.BACKSPACE]})},Nn=function(e){return er(e)&&Kt(e)&&ai(e)?e.isCopyable?e.isCopyable():e instanceof Be||e instanceof yo?e.isOwnDeletable()&&e.isOwnMovable():e.isDeletable()&&e.isMovable():!1},Ru=function(e){return Nn(e)&&Kt(e)&&e.isDeletable()},wu=function(){const e=Pe.registry.createSerializedKey(Le.C,[Le.CTRL]),t=Pe.registry.createSerializedKey(Le.C,[Le.META]);Pe.registry.register({name:ko.COPY,preconditionFn(o,s){return s=s.focusedNode,o=o.isFlyout?o.targetWorkspace:o,!!s&&!!o&&!o.isDragging()&&!r.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()&&Nn(s)},callback(o,s,i,n){return s.preventDefault(),s=n.focusedNode,!s||!er(s)||!Nn(s)||(o=o.isFlyout?o.targetWorkspace:o,!o)?!1:(s.workspace.isFlyout||o.hideChaff(),o=ai(s)&&s.workspace==o?s.getRelativeToSurfaceXY():void 0,!!Rn(s,o))},keyCodes:[e,t]})},Ou=function(){const e=Pe.registry.createSerializedKey(Le.X,[Le.CTRL]),t=Pe.registry.createSerializedKey(Le.X,[Le.META]);Pe.registry.register({name:ko.CUT,preconditionFn(o,s){return s=s.focusedNode,!!s&&!o.isReadOnly()&&!o.isDragging()&&!r.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()&&Ru(s)},callback(o,s,i,n){return o=n.focusedNode,!o||!Ru(o)||!er(o)?!1:(s=ai(o)?o.getRelativeToSurfaceXY():void 0,s=Rn(o,s),o instanceof Be?o.checkAndDelete():Kt(o)&&o.dispose(),!!s)},keyCodes:[e,t]})},Nu=function(){const e=Pe.registry.createSerializedKey(Le.V,[Le.CTRL]),t=Pe.registry.createSerializedKey(Le.V,[Le.META]);Pe.registry.register({name:ko.PASTE,preconditionFn(){var o=On();return!o||!o.rendered?!1:(o=o.isFlyout?o.targetWorkspace:o,!!wn()&&!!o&&!o.isReadOnly()&&!o.isDragging()&&!r.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken())},callback(o,s){if(o=wn(),!o)return!1;var i=On();if(!i||(i=i.isFlyout?i.targetWorkspace:i,!i||i.isReadOnly()))return!1;if(s instanceof PointerEvent)return s=ec(i,new P(s.clientX,s.clientY)),!!ss(o,i,s);if(s=Iu(),!s)return!!ss(o,i);const{left:n,top:d,width:f,height:L}=i.getMetricsManager().getViewMetrics(!0);return new ye(d,d+L,n,n+f).contains(s.x,s.y)?!!ss(o,i):(s=new P(n+f/2,d+L/2),!!ss(o,i,s))},keyCodes:[e,t]})},Au=function(){const e=Pe.registry.createSerializedKey(Le.Z,[Le.CTRL]),t=Pe.registry.createSerializedKey(Le.Z,[Le.META]);Pe.registry.register({name:ko.UNDO,preconditionFn(o){return!o.isReadOnly()&&!o.isDragging()&&!r.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()},callback(o,s){return o.hideChaff(),o.undo(!1),s.preventDefault(),!0},keyCodes:[e,t]})},Lu=function(){const e=Pe.registry.createSerializedKey(Le.Z,[Le.CTRL,Le.SHIFT]),t=Pe.registry.createSerializedKey(Le.Z,[Le.META,Le.SHIFT]),o=Pe.registry.createSerializedKey(Le.Y,[Le.CTRL]);Pe.registry.register({name:ko.REDO,preconditionFn(s){return!s.isDragging()&&!s.isReadOnly()&&!r.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()},callback(s,i){return s.hideChaff(),s.undo(!0),i.preventDefault(),!0},keyCodes:[e,t,o]})},Mu=function(){Su(),ku(),wu(),Ou(),Nu(),Au(),Lu()},Du=function(e){const t=e.saveState();return e.getParameters().length&&(t.parameters=e.getParameters().map(o=>o.saveState())),t},xu=function(e,t,o,s){if(e=e.loadState(o,s),!o.parameters)return e;for(const[i,n]of o.parameters.entries())e.insertParameter(t.loadState(n,s),i);return e},Ep=function(e){const t=Object.create(null),o=H(M.SERIALIZER,!0);for(const s in o){let i;const n=(i=o[s])==null?void 0:i.save(e);n&&(t[s]=n)}return t},yp=function(e,t,{recordUndo:o=!1}={}){var s=H(M.SERIALIZER,!0);if(s){s=Object.entries(s).sort((n,d)=>d[1].priority-n[1].priority);var i=Ue();r.setRecordUndo$$module$build$src$core$events$utils(o),(o=r.getGroup$$module$build$src$core$events$utils())||r.setGroup$$module$build$src$core$events$utils(!0),eo(),t instanceof At&&t.setResizesEnabled(!1);for(const[,n]of s.reverse()){let d;(d=n)==null||d.clear(t)}for(const[n,d]of s.reverse())if(e[n]){let f;(f=d)==null||f.load(e[n],t)}t instanceof At&&t.setResizesEnabled(!0),to(),_(new(U(w.FINISHED_LOADING))(t)),r.setGroup$$module$build$src$core$events$utils(o),r.setRecordUndo$$module$build$src$core$events$utils(i)}},vp=function(e,t){let o=null;o=typeof e=="string"?document.getElementById(e)||document.querySelector(e):e;var s;if(!document.contains(o)&&document!==((s=o)==null?void 0:s.ownerDocument))throw Error("Error: container is not in current document");e=new vo(t||{}),s=document.createElement("div"),G(s,"injectionDiv"),t!=null&&t.rtl&&G(s,"blocklyRTL"),o.appendChild(s),t=Ip(s,e);const i=Cp(s,t,e);return Sp(i),p(i),$o(i),s.addEventListener("focusin",function(){p(i)}),z(s,"keydown",null,S),i},Ip=function(e,t){e.setAttribute("dir","LTR"),pe(t.hasCss,t.pathToMedia);const o=v(R.SVG,{xmlns:sr,"xmlns:html":To,"xmlns:xlink":Ht,version:"1.1",class:"blocklySvg"},e),s=v(R.DEFS,{},o),i=String(Math.random()).substring(2);return t.gridPattern=qa.createDom(i,t.gridOptions,s,e),o},Cp=function(e,t,o){o.parentWorkspace=null,o=new At(o);const s=o.options;o.scale=s.zoomOptions.startScale,t.appendChild(o.createDom("blocklyMainBackground",e));var i=o.getRenderer().getClassName();return i&&G(e,i),(i=o.getTheme().getClassName())&&G(e,i),!s.hasCategories&&s.languageTree&&(e=o.addFlyout(R.SVG),Qt(e,t)),s.hasTrashcan&&o.addTrashcan(),s.zoomOptions&&s.zoomOptions.controls&&o.addZoomControls(),o.getThemeManager().subscribe(t,"workspaceBackgroundColour","background-color"),o.translate(0,0),o.addChangeListener(hu(o)),$o(o),Vc(),on(),Lc(),o},Sp=function(e){const t=e.options;var o=e.getParentSvg();if(z(o.parentNode,"contextmenu",null,function(s){Y(s)||s.preventDefault()}),o=z(window,"resize",null,function(){xo(),e.hideComponents(!0),Rc(),Xc(),$o(e),Tn(e)}),e.setResizeHandlerWrapper(o),kp(),t.languageTree){o=e.getToolbox();const s=e.getFlyout(!0);o?o.init():s&&(s.init(e),s.show(t.languageTree),typeof s.scrollToStart=="function"&&s.scrollToStart())}t.hasTrashcan&&e.trashcan.init(),t.zoomOptions&&t.zoomOptions.controls&&e.zoomControls_.init(),t.moveOptions&&t.moveOptions.scrollbars?(e.scrollbar=new Ja(e,t.moveOptions.scrollbars===!0||!!t.moveOptions.scrollbars.horizontal,t.moveOptions.scrollbars===!0||!!t.moveOptions.scrollbars.vertical,"blocklyMainWorkspaceScrollbar"),e.scrollbar.resize()):e.setMetrics({x:.5,y:.5}),t.hasSounds&&Rp(t.pathToMedia,e)},kp=function(){of||(z(document,"scroll",null,function(){const e=kt();for(let t=0,o;o=e[t];t++)o instanceof At&&o.updateInverseScreenCTM()}),ae(document,"touchend",null,ue),ae(document,"touchcancel",null,ue)),of=!0},Rp=function(e,t){function o(){for(;i.length;){const n=i.pop();n&&te(n)}s.preload()}const s=t.getAudioManager();s.load([e+"click.mp3",e+"click.wav",e+"click.ogg"],"click"),s.load([e+"disconnect.wav",e+"disconnect.mp3",e+"disconnect.ogg"],"disconnect"),s.load([e+"delete.mp3",e+"delete.ogg",e+"delete.wav"],"delete");const i=[];i.push(z(document,"pointermove",null,o,!0)),i.push(z(document,"touchstart",null,o,!0))},Bu=function(){Ee.registry.register({displayText(){return r.Msg$$module$build$src$core$msg.UNDO},preconditionFn(e){return e.workspace.getUndoStack().length>0?"enabled":"disabled"},callback(e){e.workspace.undo(!1)},scopeType:Ee.ScopeType.WORKSPACE,id:"undoWorkspace",weight:1})},Pu=function(){Ee.registry.register({displayText(){return r.Msg$$module$build$src$core$msg.REDO},preconditionFn(e){return e.workspace.getRedoStack().length>0?"enabled":"disabled"},callback(e){e.workspace.undo(!0)},scopeType:Ee.ScopeType.WORKSPACE,id:"redoWorkspace",weight:2})},Fu=function(){Ee.registry.register({displayText(){return r.Msg$$module$build$src$core$msg.CLEAN_UP},preconditionFn(e){return e.workspace.isMovable()?e.workspace.getTopBlocks(!1).length>1?"enabled":"disabled":"hidden"},callback(e){e.workspace.cleanUp()},scopeType:Ee.ScopeType.WORKSPACE,id:"cleanWorkspace",weight:3})},Uu=function(e,t){function o(n){i--,n.setCollapsed(e),i===0&&r.setGroup$$module$build$src$core$events$utils(!1)}let s=0,i=0;r.setGroup$$module$build$src$core$events$utils(!0);for(let n=0;n<t.length;n++){let d=t[n];for(;d;)i++,setTimeout(o.bind(null,d),s),d=d.getNextBlock(),s+=10}},Hu=function(){Ee.registry.register({displayText(){return r.Msg$$module$build$src$core$msg.COLLAPSE_ALL},preconditionFn(e){if(e.workspace.options.collapse){e=e.workspace.getTopBlocks(!1);for(let t=0;t<e.length;t++){let o=e[t];for(;o;){if(!o.isCollapsed())return"enabled";o=o.getNextBlock()}}return"disabled"}return"hidden"},callback(e){Uu(!0,e.workspace.getTopBlocks(!0))},scopeType:Ee.ScopeType.WORKSPACE,id:"collapseWorkspace",weight:4})},Gu=function(){Ee.registry.register({displayText(){return r.Msg$$module$build$src$core$msg.EXPAND_ALL},preconditionFn(e){if(e.workspace.options.collapse){e=e.workspace.getTopBlocks(!1);for(let t=0;t<e.length;t++){let o=e[t];for(;o;){if(o.isCollapsed())return"enabled";o=o.getNextBlock()}}return"disabled"}return"hidden"},callback(e){Uu(!1,e.workspace.getTopBlocks(!0))},scopeType:Ee.ScopeType.WORKSPACE,id:"expandWorkspace",weight:5})},Vu=function(e,t){if(e.isDeletable())Array.prototype.push.apply(t,e.getDescendants(!1));else{e=e.getChildren(!1);for(let o=0;o<e.length;o++)Vu(e[o],t)}},An=function(e){const t=[];e=e.getTopBlocks(!0);for(let o=0;o<e.length;o++)Vu(e[o],t);return t},tr=function(e,t){t?r.setGroup$$module$build$src$core$events$utils(t):(r.setGroup$$module$build$src$core$events$utils(!0),t=r.getGroup$$module$build$src$core$events$utils());const o=e.shift();o&&(o.isDeadOrDying()?tr(e,t):(o.dispose(!1,!0),setTimeout(tr,10,e,t))),r.setGroup$$module$build$src$core$events$utils(!1)},Wu=function(){Ee.registry.register({displayText(e){return e.workspace?(e=An(e.workspace).length,e===1?r.Msg$$module$build$src$core$msg.DELETE_BLOCK:r.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace("%1",`${e}`)):""},preconditionFn(e){return e.workspace&&An(e.workspace).length>0?"enabled":"disabled"},callback(e){if(e.workspace){e.workspace.cancelCurrentGesture();var t=An(e.workspace);t.length<2?tr(t):jr(r.Msg$$module$build$src$core$msg.DELETE_ALL_BLOCKS.replace("%1",String(t.length)),function(o){o&&tr(t)})}},scopeType:Ee.ScopeType.WORKSPACE,id:"workspaceDelete",weight:6})},wp=function(){Bu(),Pu(),Fu(),Hu(),Gu(),Wu()},zu=function(){Ee.registry.register({displayText(){return r.Msg$$module$build$src$core$msg.DUPLICATE_BLOCK},preconditionFn(e){return e=e.block,!e.isInFlyout&&e.isDeletable()&&e.isMovable()?e.isDuplicatable()?"enabled":"disabled":"hidden"},callback(e){if(e.block){var t=e.block.toCopyData();t&&ss(t,e.block.workspace)}},scopeType:Ee.ScopeType.BLOCK,id:"blockDuplicate",weight:1})},Yu=function(){Ee.registry.register({displayText(e){return e.block.hasIcon(Xo.TYPE)?r.Msg$$module$build$src$core$msg.REMOVE_COMMENT:r.Msg$$module$build$src$core$msg.ADD_COMMENT},preconditionFn(e){return e=e.block,!e.isInFlyout&&e.workspace.options.comments&&!e.isCollapsed()&&e.isEditable()?"enabled":"hidden"},callback(e){e=e.block,e.hasIcon(Xo.TYPE)?e.setCommentText(null):e.setCommentText("")},scopeType:Ee.ScopeType.BLOCK,id:"blockComment",weight:2})},Xu=function(){Ee.registry.register({displayText(e){return e.block.getInputsInline()?r.Msg$$module$build$src$core$msg.EXTERNAL_INPUTS:r.Msg$$module$build$src$core$msg.INLINE_INPUTS},preconditionFn(e){if(e=e.block,!e.isInFlyout&&e.isMovable()&&!e.isCollapsed()){for(let t=1;t<e.inputList.length;t++)if(!(e.inputList[t-1]instanceof wl||e.inputList[t]instanceof wl))return"enabled"}return"hidden"},callback(e){e.block.setInputsInline(!e.block.getInputsInline())},scopeType:Ee.ScopeType.BLOCK,id:"blockInline",weight:3})},ju=function(){Ee.registry.register({displayText(e){return e.block.isCollapsed()?r.Msg$$module$build$src$core$msg.EXPAND_BLOCK:r.Msg$$module$build$src$core$msg.COLLAPSE_BLOCK},preconditionFn(e){return e=e.block,!e.isInFlyout&&e.isMovable()&&e.workspace.options.collapse?"enabled":"hidden"},callback(e){e.block.setCollapsed(!e.block.isCollapsed())},scopeType:Ee.ScopeType.BLOCK,id:"blockCollapseExpand",weight:4})},Ku=function(){Ee.registry.register({displayText(e){return e.block.hasDisabledReason(Jt)?r.Msg$$module$build$src$core$msg.ENABLE_BLOCK:r.Msg$$module$build$src$core$msg.DISABLE_BLOCK},preconditionFn(e){if(e=e.block,!e.isInFlyout&&e.workspace.options.disable&&e.isEditable()){var t=e.getDisabledReasons();return t=t.size>(t.has(Jt)?1:0),e.getInheritedDisabled()||t?"disabled":"enabled"}return"hidden"},callback(e){e=e.block;const t=r.getGroup$$module$build$src$core$events$utils();t||r.setGroup$$module$build$src$core$events$utils(!0),e.setDisabledReason(!e.hasDisabledReason(Jt),Jt),r.setGroup$$module$build$src$core$events$utils(t)},scopeType:Ee.ScopeType.BLOCK,id:"blockDisable",weight:5})},Ju=function(){Ee.registry.register({displayText(e){var t=e.block;return e=t.getDescendants(!1).length,(t=t.getNextBlock())&&(e-=t.getDescendants(!1).length),e===1?r.Msg$$module$build$src$core$msg.DELETE_BLOCK:r.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace("%1",`${e}`)},preconditionFn(e){return!e.block.isInFlyout&&e.block.isDeletable()?"enabled":"hidden"},callback(e){e.block&&e.block.checkAndDelete()},scopeType:Ee.ScopeType.BLOCK,id:"blockDelete",weight:6})},qu=function(){Ee.registry.register({displayText(){return r.Msg$$module$build$src$core$msg.HELP},preconditionFn(e){return e=e.block,(typeof e.helpUrl=="function"?e.helpUrl():e.helpUrl)?"enabled":"hidden"},callback(e){e.block.showHelp()},scopeType:Ee.ScopeType.BLOCK,id:"blockHelp",weight:7})},Zu=function(){Ee.registry.register({displayText:()=>r.Msg$$module$build$src$core$msg.REMOVE_COMMENT,preconditionFn(e){let t;return(t=e.comment)!=null&&t.isDeletable()?"enabled":"hidden"},callback(e){r.setGroup$$module$build$src$core$events$utils(!0);let t;(t=e.comment)==null||t.dispose(),r.setGroup$$module$build$src$core$events$utils(!1)},scopeType:Ee.ScopeType.COMMENT,id:"commentDelete",weight:6})},Qu=function(){Ee.registry.register({displayText:()=>r.Msg$$module$build$src$core$msg.DUPLICATE_COMMENT,preconditionFn(e){let t;return(t=e.comment)!=null&&t.isMovable()?"enabled":"hidden"},callback(e){if(e.comment){var t=e.comment.toCopyData();t&&ss(t,e.comment.workspace)}},scopeType:Ee.ScopeType.COMMENT,id:"commentDuplicate",weight:1})},ea=function(){Ee.registry.register({displayText:()=>r.Msg$$module$build$src$core$msg.ADD_COMMENT,preconditionFn:e=>{let t;return(t=e.workspace)!=null&&t.isMutator?"hidden":"enabled"},callback:(e,t,o,s)=>{(e=e.workspace)&&(r.setGroup$$module$build$src$core$events$utils(!0),t=new yo(e),t.setPlaceholderText(r.Msg$$module$build$src$core$msg.WORKSPACE_COMMENT_DEFAULT_TEXT),t.moveTo(Op(new P(s.x,s.y),e)),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(t),r.setGroup$$module$build$src$core$events$utils(!1))},scopeType:Ee.ScopeType.WORKSPACE,id:"commentCreate",weight:8})},Op=function(e,t){var o=t.getInjectionDiv().getBoundingClientRect();return e=new P(e.x-o.left,e.y-o.top),o=t.getOriginOffsetInPixels(),e=P.difference(e,o),e.scale(1/t.scale),e},Np=function(){zu(),Yu(),Xu(),ju(),Ku(),Ju(),qu()},Ap=function(){Qu(),Zu(),ea()},ta=function(){wp(),Np()},Lp=function(e){return e&&typeof e.paste=="function"},Mp=function(e){return e&&typeof e.getSvgRoot=="function"},Dp=function(e){return e.isSelectable()},xp=function(e){c().hideChaff(e)},N=N||{},N.scope={},N.ASSUME_ES5=!1,N.ASSUME_ES6=!1,N.ASSUME_ES2020=!1,N.ASSUME_NO_NATIVE_MAP=!1,N.ASSUME_NO_NATIVE_SET=!1,N.ISOLATE_POLYFILLS=!1,N.FORCE_POLYFILL_PROMISE=!1,N.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1,N.INSTRUMENT_ASYNC_CONTEXT=!0,N.objectCreate=N.ASSUME_ES5||typeof Object.create=="function"?Object.create:function(e){var t=function(){};return t.prototype=e,new t},N.defineProperty=N.ASSUME_ES5||typeof Object.defineProperties=="function"?Object.defineProperty:function(e,t,o){return e==Array.prototype||e==Object.prototype||(e[t]=o.value),e},N.getGlobal=function(e){e=[typeof globalThis=="object"&&globalThis,e,typeof window=="object"&&window,typeof self=="object"&&self,typeof qf=="object"&&qf];for(var t=0;t<e.length;++t){var o=e[t];if(o&&o.Math==Math)return o}throw Error("Cannot find global object")},N.global=N.ASSUME_ES2020?globalThis:N.getGlobal(this),N.IS_SYMBOL_NATIVE=typeof Symbol=="function"&&typeof Symbol("x")=="symbol",N.TRUST_ES6_POLYFILLS=!N.ISOLATE_POLYFILLS||N.IS_SYMBOL_NATIVE,N.polyfills={},N.propertyToPolyfillSymbol={},N.POLYFILL_PREFIX="$jscp$",N.polyfill=function(e,t,o,s){t&&(N.ISOLATE_POLYFILLS?N.polyfillIsolated(e,t,o,s):N.polyfillUnisolated(e,t,o,s))},N.polyfillUnisolated=function(e,t,o,s){for(o=N.global,e=e.split("."),s=0;s<e.length-1;s++){var i=e[s];if(!(i in o))return;o=o[i]}e=e[e.length-1],s=o[e],t=t(s),t!=s&&t!=null&&N.defineProperty(o,e,{configurable:!0,writable:!0,value:t})},N.polyfillIsolated=function(e,t,o,s){var i=e.split(".");e=i.length===1,s=i[0],s=!e&&s in N.polyfills?N.polyfills:N.global;for(var n=0;n<i.length-1;n++){var d=i[n];if(!(d in s))return;s=s[d]}i=i[i.length-1],o=N.IS_SYMBOL_NATIVE&&o==="es6"?s[i]:null,t=t(o),t!=null&&(e?N.defineProperty(N.polyfills,i,{configurable:!0,writable:!0,value:t}):t!==o&&(N.propertyToPolyfillSymbol[i]===void 0&&(o=Math.random()*1e9>>>0,N.propertyToPolyfillSymbol[i]=N.IS_SYMBOL_NATIVE?N.global.Symbol(i):N.POLYFILL_PREFIX+o+"$"+i),N.defineProperty(s,N.propertyToPolyfillSymbol[i],{configurable:!0,writable:!0,value:t})))},N.getConstructImplementation=function(){function e(){function o(){}return Reflect.construct(o,[],function(){}),new o instanceof o}if(N.TRUST_ES6_POLYFILLS&&typeof Reflect<"u"&&Reflect.construct){if(e())return Reflect.construct;var t=Reflect.construct;return function(o,s,i){return o=t(o,s),i&&Reflect.setPrototypeOf(o,i.prototype),o}}return function(o,s,i){return i===void 0&&(i=o),i=N.objectCreate(i.prototype||Object.prototype),Function.prototype.apply.call(o,i,s)||i}},N.construct={valueOf:N.getConstructImplementation}.valueOf(),N.underscoreProtoCanBeSet=function(){var e={a:!0},t={};try{return t.__proto__=e,t.a}catch{}return!1},N.setPrototypeOf=N.ASSUME_ES6||N.TRUST_ES6_POLYFILLS&&typeof Object.setPrototypeOf=="function"?Object.setPrototypeOf:N.underscoreProtoCanBeSet()?function(e,t){if(e.__proto__=t,e.__proto__!==t)throw new TypeError(e+" is not extensible");return e}:null,N.inherits=function(e,t){if(e.prototype=N.objectCreate(t.prototype),e.prototype.constructor=e,N.ASSUME_ES6||N.setPrototypeOf){var o=N.setPrototypeOf;o(e,t)}else for(o in t)if(o!="prototype")if(Object.defineProperties){var s=Object.getOwnPropertyDescriptor(t,o);s&&Object.defineProperty(e,o,s)}else e[o]=t[o];e.superClass_=t.prototype},N.arrayIteratorImpl=function(e){var t=0;return function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}},N.arrayIterator=function(e){return{next:N.arrayIteratorImpl(e)}},N.makeIterator=function(e){var t=typeof Symbol<"u"&&Symbol.iterator&&e[Symbol.iterator];if(t)return t.call(e);if(typeof e.length=="number")return N.arrayIterator(e);throw Error(String(e)+" is not an iterable or ArrayLike")},N.arrayFromIterator=function(e){for(var t,o=[];!(t=e.next()).done;)o.push(t.value);return o},N.arrayFromIterable=function(e){return e instanceof Array?e:N.arrayFromIterator(N.makeIterator(e))},N.generator={},N.generator.ensureIteratorResultIsObject_=function(e){if(!(e instanceof Object))throw new TypeError("Iterator result "+e+" is not an object")},N.generator.Context=function(){this.isRunning_=!1,this.yieldAllIterator_=null,this.yieldResult=void 0,this.nextAddress=1,this.finallyAddress_=this.catchAddress_=0,this.finallyContexts_=this.abruptCompletion_=null},N.generator.Context.prototype.start_=function(){if(this.isRunning_)throw new TypeError("Generator is already running");this.isRunning_=!0},N.generator.Context.prototype.stop_=function(){this.isRunning_=!1},N.generator.Context.prototype.jumpToErrorHandler_=function(){this.nextAddress=this.catchAddress_||this.finallyAddress_},N.generator.Context.prototype.next_=function(e){this.yieldResult=e},N.generator.Context.prototype.throw_=function(e){this.abruptCompletion_={exception:e,isException:!0},this.jumpToErrorHandler_()},N.generator.Context.prototype.return=function(e){this.abruptCompletion_={return:e},this.nextAddress=this.finallyAddress_},N.generator.Context.prototype.jumpThroughFinallyBlocks=function(e){this.abruptCompletion_={jumpTo:e},this.nextAddress=this.finallyAddress_},N.generator.Context.prototype.yield=function(e,t){return this.nextAddress=t,{value:e}},N.generator.Context.prototype.yieldAll=function(e,t){e=N.makeIterator(e);var o=e.next();if(N.generator.ensureIteratorResultIsObject_(o),o.done)this.yieldResult=o.value,this.nextAddress=t;else return this.yieldAllIterator_=e,this.yield(o.value,t)},N.generator.Context.prototype.jumpTo=function(e){this.nextAddress=e},N.generator.Context.prototype.jumpToEnd=function(){this.nextAddress=0},N.generator.Context.prototype.setCatchFinallyBlocks=function(e,t){this.catchAddress_=e,t!=null&&(this.finallyAddress_=t)},N.generator.Context.prototype.setFinallyBlock=function(e){this.catchAddress_=0,this.finallyAddress_=e||0},N.generator.Context.prototype.leaveTryBlock=function(e,t){this.nextAddress=e,this.catchAddress_=t||0},N.generator.Context.prototype.enterCatchBlock=function(e){return this.catchAddress_=e||0,e=this.abruptCompletion_.exception,this.abruptCompletion_=null,e},N.generator.Context.prototype.enterFinallyBlock=function(e,t,o){o?this.finallyContexts_[o]=this.abruptCompletion_:this.finallyContexts_=[this.abruptCompletion_],this.catchAddress_=e||0,this.finallyAddress_=t||0},N.generator.Context.prototype.leaveFinallyBlock=function(e,t){if(t=this.finallyContexts_.splice(t||0)[0],t=this.abruptCompletion_=this.abruptCompletion_||t){if(t.isException)return this.jumpToErrorHandler_();t.jumpTo!=null&&this.finallyAddress_<t.jumpTo?(this.nextAddress=t.jumpTo,this.abruptCompletion_=null):this.nextAddress=this.finallyAddress_}else this.nextAddress=e},N.generator.Context.prototype.forIn=function(e){return new N.generator.Context.PropertyIterator(e)},N.generator.Context.PropertyIterator=function(e){this.object_=e,this.properties_=[];for(var t in e)this.properties_.push(t);this.properties_.reverse()},N.generator.Context.PropertyIterator.prototype.getNext=function(){for(;this.properties_.length>0;){var e=this.properties_.pop();if(e in this.object_)return e}return null},N.generator.Engine_=function(e){this.context_=new N.generator.Context,this.program_=e},N.generator.Engine_.prototype.next_=function(e){return this.context_.start_(),this.context_.yieldAllIterator_?this.yieldAllStep_(this.context_.yieldAllIterator_.next,e,this.context_.next_):(this.context_.next_(e),this.nextStep_())},N.generator.Engine_.prototype.return_=function(e){this.context_.start_();var t=this.context_.yieldAllIterator_;return t?this.yieldAllStep_("return"in t?t.return:function(o){return{value:o,done:!0}},e,this.context_.return):(this.context_.return(e),this.nextStep_())},N.generator.Engine_.prototype.throw_=function(e){return this.context_.start_(),this.context_.yieldAllIterator_?this.yieldAllStep_(this.context_.yieldAllIterator_.throw,e,this.context_.next_):(this.context_.throw_(e),this.nextStep_())},N.generator.Engine_.prototype.yieldAllStep_=function(e,t,o){try{var s=e.call(this.context_.yieldAllIterator_,t);if(N.generator.ensureIteratorResultIsObject_(s),!s.done)return this.context_.stop_(),s;var i=s.value}catch(n){return this.context_.yieldAllIterator_=null,this.context_.throw_(n),this.nextStep_()}return this.context_.yieldAllIterator_=null,o.call(this.context_,i),this.nextStep_()},N.generator.Engine_.prototype.nextStep_=function(){for(;this.context_.nextAddress;)try{var e=this.program_(this.context_);if(e)return this.context_.stop_(),{value:e.value,done:!1}}catch(t){this.context_.yieldResult=void 0,this.context_.throw_(t)}if(this.context_.stop_(),this.context_.abruptCompletion_){if(e=this.context_.abruptCompletion_,this.context_.abruptCompletion_=null,e.isException)throw e.exception;return{value:e.return,done:!0}}return{value:void 0,done:!0}},N.generator.Generator_=function(e){this.next=function(t){return e.next_(t)},this.throw=function(t){return e.throw_(t)},this.return=function(t){return e.return_(t)},this[Symbol.iterator]=function(){return this}},N.generator.createGenerator=function(e,t){return t=new N.generator.Generator_(new N.generator.Engine_(t)),N.setPrototypeOf&&e.prototype&&N.setPrototypeOf(t,e.prototype),t},N.asyncExecutePromiseGenerator=function(e){function t(s){return e.next(s)}function o(s){return e.throw(s)}return new Promise(function(s,i){function n(d){d.done?s(d.value):Promise.resolve(d.value).then(t,o).then(n,i)}n(e.next())})},N.asyncExecutePromiseGeneratorFunction=function(e){return N.asyncExecutePromiseGenerator(e())},N.asyncExecutePromiseGeneratorProgram=function(e){return N.asyncExecutePromiseGenerator(new N.generator.Generator_(new N.generator.Engine_(e)))},N.polyfill("globalThis",function(e){return e||N.global},"es_2020","es3"),N.polyfill("Array.prototype.includes",function(e){return e||function(t,o){var s=this;s instanceof String&&(s=String(s));var i=s.length;for(o=o||0,o<0&&(o=Math.max(o+i,0));o<i;o++){var n=s[o];if(n===t||Object.is(n,t))return!0}return!1}},"es7","es3"),N.checkEs6ConformanceViaProxy=function(){try{var e={},t=Object.create(new N.global.Proxy(e,{get:function(o,s,i){return o==e&&s=="q"&&i==t}}));return t.q===!0}catch{return!1}},N.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1,N.ES6_CONFORMANCE=N.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&N.checkEs6ConformanceViaProxy(),N.initSymbol=function(){},N.iteratorPrototype=function(e){return e={next:e},e[Symbol.iterator]=function(){return this},e},N.owns=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},N.MapEntry=function(){},N.polyfill("Set.prototype.difference",function(e){return e||function(t){N.checkIsSetInstance(this),N.checkIsSetLike(t);var o=N.getSmallerAndLargerSets(this,t);t=new Set(this);var s=o.smallerSetIterator;o=o.largerSet;for(var i=s.next();!i.done;)o.has(i.value)&&t.delete(i.value),i=s.next();return t}},"es_next","es6"),N.checkIsSetLike=function(e){if(typeof e!="object"||e===null||typeof e.size!="number"||e.size<0||typeof e.keys!="function"||typeof e.has!="function")throw new TypeError("Argument must be set-like")},N.checkIsValidIterator=function(e){if(typeof e!="object"||e===null||typeof e.next!="function")throw new TypeError("Invalid iterator.");return e},N.getSmallerAndLargerSets=function(e,t){return e.size<=t.size?{smallerSetIterator:e.keys(),largerSet:t}:{smallerSetIterator:N.checkIsValidIterator(t.keys()),largerSet:e}},N.checkIsSetInstance=function(e){if(!(e instanceof Set))throw new TypeError("Method must be called on an instance of Set.")},N.iteratorFromArray=function(e,t){if(N.ASSUME_ES6)return e[Symbol.iterator]();e instanceof String&&(e+="");var o=0,s=!1,i={next:function(){if(!s&&o<e.length){var n=o++;return{value:t(n,e[n]),done:!1}}return s=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i},N.polyfill("Array.prototype.values",function(e){return e||function(){return N.iteratorFromArray(this,function(t,o){return o})}},"es8","es3"),N.polyfill("Array.prototype.flatMap",function(e){return e||function(t,o){var s=[];return Array.prototype.forEach.call(this,function(i,n){i=t.call(o,i,n,this),Array.isArray(i)?s.push.apply(s,i):s.push(i)}),s}},"es9","es5"),N.polyfill("Array.prototype.flat",function(e){return e||function(t){t=t===void 0?1:t;var o=[];return Array.prototype.forEach.call(this,function(s){Array.isArray(s)&&t>0?(s=Array.prototype.flat.call(s,t-1),o.push.apply(o,s)):o.push(s)}),o}},"es9","es5"),N.polyfill("Object.entries",function(e){return e||function(t){var o=[],s;for(s in t)N.owns(t,s)&&o.push([s,t[s]]);return o}},"es8","es3"),N.polyfill("Object.values",function(e){return e||function(t){var o=[],s;for(s in t)N.owns(t,s)&&o.push(t[s]);return o}},"es8","es3");var is=Object.create(null),db={typeMap:is},Ln=Object.create(null),Ft="default",M=class{constructor(e){this.name=e}toString(){return this.name}};M.CONNECTION_CHECKER=new M("connectionChecker"),M.CONNECTION_PREVIEWER=new M("connectionPreviewer"),M.CURSOR=new M("cursor"),M.EVENT=new M("event"),M.FIELD=new M("field"),M.INPUT=new M("input"),M.RENDERER=new M("renderer"),M.TOOLBOX=new M("toolbox"),M.THEME=new M("theme"),M.TOOLBOX_ITEM=new M("toolboxItem"),M.FLYOUTS_VERTICAL_TOOLBOX=new M("flyoutsVerticalToolbox"),M.FLYOUTS_HORIZONTAL_TOOLBOX=new M("flyoutsHorizontalToolbox"),M.FLYOUT_INFLATER=new M("flyoutInflater"),M.METRICS_MANAGER=new M("metricsManager"),M.BLOCK_DRAGGER=new M("blockDragger"),M.SERIALIZER=new M("serializer"),M.ICON=new M("icon"),M.PASTER=new M("paster"),M.VARIABLE_MODEL=new M("variableModel"),M.VARIABLE_MAP=new M("variableMap");var Bo={DEFAULT:Ft,TEST_ONLY:db};Bo.Type=M,Bo.getAllItems=H,Bo.getClass=A,Bo.getClassFromOptions=W,Bo.getObject=D,Bo.hasItem=k,Bo.register=l,Bo.unregister=m;var Ge=Object.create(null),$b=750,Bp="ontouchstart"in globalThis||!!(globalThis.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),Mn=null,Cs={mousedown:["pointerdown"],mouseenter:["pointerenter"],mouseleave:["pointerleave"],mousemove:["pointermove"],mouseout:["pointerout"],mouseover:["pointerover"],mouseup:["pointerup","pointercancel"],touchend:["pointerup"],touchcancel:["pointercancel"]},Dn=0,Ss={TOUCH_ENABLED:Bp,TOUCH_MAP:Cs};Ss.checkTouchIdentifier=me,Ss.clearTouchIdentifier=ie,Ss.getTouchIdentifierFromEvent=ee,Ss.longStart=X,Ss.longStop=ue,Ss.shouldHandleEvent=K;var oa,Pp,Fp,Up,xn,Bn,sa,Hp,Gp,Vp;(function(e){function t(s){return o.includes(s.toUpperCase())}oa=e;const o=oa.toUpperCase();Pp=t("JavaFX"),Fp=t("WebKit"),Up=t("Gecko")&&!Fp,xn=t("Android"),e=globalThis.navigator&&globalThis.navigator.maxTouchPoints,Bn=t("iPad")||t("Macintosh")&&e>0,sa=t("iPhone")&&!Bn,Hp=t("Macintosh"),Gp=Bn||xn&&!t("Mobile")||t("Silk"),Vp=!Gp&&(sa||xn)})(globalThis.navigator&&globalThis.navigator.userAgent||"");var pb=oa,Wp=Pp,zp=Up,ia=xn,Pn=Bn,Yp=sa,ra=Hp,Xp=Vp,gb={ANDROID:ia,GECKO:zp,IPAD:Pn,IPHONE:Yp,JavaFx:Wp,MAC:ra,MOBILE:Xp,raw:pb},jp=40,Kp=125,Po={};Po.bind=ae,Po.conditionalBind=z,Po.getScrollDeltaPixels=It,Po.isRightButton=Ie,Po.isTargetInput=Y,Po.mouseToSvg=Ye,Po.unbind=te;var w;(function(e){e.BLOCK_CREATE="create",e.BLOCK_DELETE="delete",e.BLOCK_CHANGE="change",e.BLOCK_FIELD_INTERMEDIATE_CHANGE="block_field_intermediate_change",e.BLOCK_MOVE="move",e.VAR_CREATE="var_create",e.VAR_DELETE="var_delete",e.VAR_RENAME="var_rename",e.VAR_TYPE_CHANGE="var_type_change",e.UI="ui",e.BLOCK_DRAG="drag",e.SELECTED="selected",e.CLICK="click",e.MARKER_MOVE="marker_move",e.BUBBLE_OPEN="bubble_open",e.TRASHCAN_OPEN="trashcan_open",e.TOOLBOX_ITEM_SELECT="toolbox_item_select",e.THEME_CHANGE="theme_change",e.VIEWPORT_CHANGE="viewport_change",e.COMMENT_CREATE="comment_create",e.COMMENT_DELETE="comment_delete",e.COMMENT_CHANGE="comment_change",e.COMMENT_MOVE="comment_move",e.COMMENT_RESIZE="comment_resize",e.COMMENT_DRAG="comment_drag",e.COMMENT_COLLAPSE="comment_collapse",e.FINISHED_LOADING="finished_loading"})(w||(w={}));var Jp=[w.BLOCK_CREATE,w.BLOCK_MOVE,w.COMMENT_CREATE,w.COMMENT_MOVE],qp="!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Zp={genUid:()=>{const e=qp.length,t=[];for(let o=0;o<20;o++)t[o]=qp.charAt(Math.random()*e);return t.join("")}},mb=0,na={TEST_ONLY:Zp};na.genUid=rt,na.getNextUniqueId=Re;var Qp="",or=!0,la=0,ca="ORPHANED_BLOCK",Fo=[],eg={FIRE_QUEUE:Fo,enqueueEvent:ne,fireNow:Q,fireInternal:F,setGroupInternal:$e};r.disable$$module$build$src$core$events$utils,r.enable$$module$build$src$core$events$utils,r.getGroup$$module$build$src$core$events$utils,r.setGroup$$module$build$src$core$events$utils,r.setRecordUndo$$module$build$src$core$events$utils;var sr="http://www.w3.org/2000/svg",To="http://www.w3.org/1999/xhtml",Ht="http://www.w3.org/1999/xlink",Uo;(function(e){e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE"})(Uo||(Uo={}));var no=null,ua=0,ir=null,mt={HTML_NS:To};mt.NodeType=Uo,mt.SVG_NS=sr,mt.XLINK_NS=Ht,mt.addClass=G,mt.createSvgElement=v,mt.getFastTextWidth=ms,mt.getFastTextWidthWithSizeString=ho,mt.getTextWidth=ot,mt.hasClass=qo,mt.insertAfter=Qt,mt.measureFontMetrics=E,mt.removeClass=Te,mt.removeClasses=Lt,mt.removeNode=ke,mt.setCssTransform=Mo,mt.startTextWidthCache=eo,mt.stopTextWidthCache=to;var ft=class{static findFocusedNode(e){var t=e.getRootFocusableNode();if(!t.canBeFocused())return null;var o=t.getFocusableElement();return qo(o,ft.ACTIVE_CLASS_NAME)||qo(o,ft.PASSIVE_CSS_CLASS_NAME)||(t=o.querySelector(this.ACTIVE_FOCUS_NODE_CSS_SELECTOR),(t instanceof HTMLElement||t instanceof SVGElement)&&(t=ft.findFocusableNodeFor(t,e)))?t:(o=o.querySelector(this.PASSIVE_FOCUS_NODE_CSS_SELECTOR),(o instanceof HTMLElement||o instanceof SVGElement)&&(e=ft.findFocusableNodeFor(o,e))?e:null)}static findFocusableNodeFor(e,t){if(!e.id||e.id==="null"||t.getNestedTrees().map(i=>ft.findFocusableNodeFor(e,i)).findIndex(i=>!!i)!==-1)return null;var o=t.getRootFocusableNode();if(o.canBeFocused()&&e===o.getFocusableElement())return o;var s;return(o=(s=t.lookUpFocusableNode(e.id))!=null?s:null)?o:(s=e.parentElement,!o&&s?ft.findFocusableNodeFor(s,t):null)}};ft.ACTIVE_CLASS_NAME="blocklyActiveFocus",ft.PASSIVE_CSS_CLASS_NAME="blocklyPassiveFocus",ft.ACTIVE_FOCUS_NODE_CSS_SELECTOR=`.${ft.ACTIVE_CLASS_NAME}`,ft.PASSIVE_FOCUS_NODE_CSS_SELECTOR=`.${ft.PASSIVE_CSS_CLASS_NAME}`;var fb=class{constructor(e,t){this.tree=e,this.rootShouldBeAutoTabbable=t}},Et=class{constructor(e){this.previouslyFocusedNode=this.focusedNode=null,this.registeredTrees=[],this.isUpdatingFocusedNode=this.recentlyLostAllFocus=this.lockFocusStateChanges=this.currentlyHoldsEphemeralFocus=!1;const t=o=>{if(!this.isUpdatingFocusedNode){this.recentlyLostAllFocus=!o;var s=null;if(o instanceof HTMLElement||o instanceof SVGElement){for(var i of this.registeredTrees)if(s=ft.findFocusableNodeFor(o,i.tree))break}if(s&&s.canBeFocused()){o=s.getFocusableTree();let n;i=(n=this.focusedNode)==null?void 0:n.getFocusableTree(),s===o.getRootFocusableNode()&&o!==i?this.focusTree(o):this.focusNode(s)}else this.defocusCurrentFocusedNode()}};e("focusin",o=>{o instanceof FocusEvent&&t(document.activeElement)}),e("focusout",o=>{o instanceof FocusEvent&&t(o.relatedTarget)})}registerTree(e,t=!1){if(this.ensureManagerIsUnlocked(),this.isRegistered(e))throw Error(`Attempted to re-register already registered tree: ${e}.`);this.registeredTrees.push(new fb(e,t));const o=e.getRootFocusableNode().getFocusableElement();if(!o.id||o.id==="null")throw Error(`Attempting to register a tree with a root element that has an invalid ID: ${e}.`);t&&(o.tabIndex=0)}isRegistered(e){return!!this.lookUpRegistration(e)}lookUpRegistration(e){let t;return(t=this.registeredTrees.find(o=>o.tree===e))!=null?t:null}unregisterTree(e){if(this.ensureManagerIsUnlocked(),!this.isRegistered(e))throw Error(`Attempted to unregister not registered tree: ${e}.`);var t=this.registeredTrees.findIndex(i=>i.tree===e);const o=this.registeredTrees[t];this.registeredTrees.splice(t,1),t=ft.findFocusedNode(e);const s=e.getRootFocusableNode();t&&this.removeHighlight(t),this.focusedNode!==t&&this.focusedNode!==s||this.updateFocusedNode(null),this.removeHighlight(s),o.rootShouldBeAutoTabbable&&e.getRootFocusableNode().getFocusableElement().removeAttribute("tabindex")}getFocusedTree(){let e,t;return(t=(e=this.focusedNode)==null?void 0:e.getFocusableTree())!=null?t:null}getFocusedNode(){return this.focusedNode}focusTree(e){if(this.ensureManagerIsUnlocked(),!this.isRegistered(e))throw Error(`Attempted to focus unregistered tree: ${e}.`);const t=ft.findFocusedNode(e),o=e.getRestoredFocusableNode(t);e=e.getRootFocusableNode();let s;this.focusNode((s=o??t)!=null?s:e)}focusNode(e){this.ensureManagerIsUnlocked();const t=!this.currentlyHoldsEphemeralFocus;t&&(this.isUpdatingFocusedNode=!0);var o,s=((o=this.focusedNode)==null?void 0:o.getFocusableElement())!==document.activeElement;if(this.focusedNode!==e||s)if(e.canBeFocused()){if(o=e.getFocusableTree(),!this.isRegistered(o))throw Error(`Attempted to focus unregistered node: ${e}.`);s=e.getFocusableElement(),s.id&&s.id!=="null"||console.warn("Trying to focus a node that has an invalid ID.");var i=ft.findFocusableNodeFor(s,o);s=ft.findFocusedNode(o);var n=e;if(i!==e){n=o.getRestoredFocusableNode(s),e=o.getRootFocusableNode();var d;n=(d=n??s)!=null?d:e}e=this.focusedNode,d=e?.getFocusableTree(),e&&this.passivelyFocusNode(e,o),o=o.getRootFocusableNode(),s&&this.removeHighlight(s),o!==n&&this.removeHighlight(o),this.currentlyHoldsEphemeralFocus||this.activelyFocusNode(n,d??null),this.updateFocusedNode(n)}else console.warn("Trying to focus a node that can't be focused.");t&&(this.isUpdatingFocusedNode=!1)}takeEphemeralFocus(e){if(this.ensureManagerIsUnlocked(),this.currentlyHoldsEphemeralFocus)throw Error(`Attempted to take ephemeral focus when it's already held, with new element: ${e}.`);this.currentlyHoldsEphemeralFocus=!0,this.focusedNode&&this.passivelyFocusNode(this.focusedNode,null),e.focus();let t=!1;return()=>{if(t)throw Error(`Attempted to finish ephemeral focus twice for element: ${e}.`);if(t=!0,this.currentlyHoldsEphemeralFocus=!1,this.focusedNode){this.activelyFocusNode(this.focusedNode,null);const o=this.focusedNode;setTimeout(()=>{!this.focusedNode&&this.previouslyFocusedNode===o&&this.recentlyLostAllFocus&&this.focusNode(o)},0)}}}ephemeralFocusTaken(){return this.currentlyHoldsEphemeralFocus}ensureManagerIsUnlocked(){if(this.lockFocusStateChanges)throw Error("FocusManager state changes cannot happen in a tree/node focus/blur callback.")}updateFocusedNode(e){this.previouslyFocusedNode=this.focusedNode,this.focusedNode=e}defocusCurrentFocusedNode(){this.focusedNode&&!this.currentlyHoldsEphemeralFocus&&(this.passivelyFocusNode(this.focusedNode,null),this.updateFocusedNode(null))}activelyFocusNode(e,t){this.lockFocusStateChanges=!0;const o=e.getFocusableTree(),s=e.getFocusableElement();let i;const n=(i=this.lookUpRegistration(o))==null?void 0:i.rootShouldBeAutoTabbable;o!==t&&(o.onTreeFocus(e,t),n&&(o.getRootFocusableNode().getFocusableElement().tabIndex=-1)),e.onNodeFocus(),this.lockFocusStateChanges=!1,n&&e===o.getRootFocusableNode()||s.hasAttribute("tabindex")||(s.tabIndex=-1),this.setNodeToVisualActiveFocus(e),s.focus()}passivelyFocusNode(e,t){this.lockFocusStateChanges=!0;const o=e.getFocusableTree();if(o!==t){o.onTreeBlur(t);let s;(s=this.lookUpRegistration(o))!=null&&s.rootShouldBeAutoTabbable&&(o.getRootFocusableNode().getFocusableElement().tabIndex=0)}e.onNodeBlur(),this.lockFocusStateChanges=!1,o!==t&&this.setNodeToVisualPassiveFocus(e)}setNodeToVisualActiveFocus(e){e=e.getFocusableElement(),G(e,Et.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),Te(e,Et.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}setNodeToVisualPassiveFocus(e){e=e.getFocusableElement(),Te(e,Et.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),G(e,Et.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}removeHighlight(e){e=e.getFocusableElement(),Te(e,Et.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),Te(e,Et.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}static getFocusManager(){return Et.focusManager||(Et.focusManager=new Et(document.addEventListener)),Et.focusManager}};Et.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME="blocklyActiveFocus",Et.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME="blocklyPassiveFocus",Et.focusManager=null,r.getFocusManager$$module$build$src$core$focus_manager;var tg={};tg.deepMerge=He;var Pe=class{constructor(){this.shortcuts=new Map,this.keyMap=new Map,this.reset()}reset(){this.shortcuts.clear(),this.keyMap.clear()}register(e,t){if(this.shortcuts.get(e.name)&&!t)throw Error(`Shortcut named "${e.name}" already exists.`);if(this.shortcuts.set(e.name,e),t=e.keyCodes,t!=null&&t.length)for(const o of t)this.addKeyMapping(o,e.name,!!e.allowCollision)}unregister(e){return this.shortcuts.get(e)?(this.removeAllKeyMappings(e),this.shortcuts.delete(e),!0):(console.warn(`Keyboard shortcut named "${e}" not found.`),!1)}addKeyMapping(e,t,o){e=`${e}`;const s=this.keyMap.get(e);if(s&&!o)throw Error(`Shortcut named "${t}" collides with shortcuts "${s}"`);s&&o?s.unshift(t):this.keyMap.set(e,[t])}removeKeyMapping(e,t,o){const s=this.keyMap.get(e);if(!s)return o||console.warn(`No keyboard shortcut named "${t}" registered with key code "${e}"`),!1;const i=s.indexOf(t);return i>-1?(s.splice(i,1),s.length===0&&this.keyMap.delete(e),!0):(o||console.warn(`No keyboard shortcut named "${t}" registered with key code "${e}"`),!1)}removeAllKeyMappings(e){for(const t of this.keyMap.keys())this.removeKeyMapping(t,e,!0)}setKeyMap(e){this.keyMap.clear();for(const t in e)this.keyMap.set(t,e[t])}getKeyMap(){const e=Object.create(null);for(const[t,o]of this.keyMap)e[t]=o;return e}getRegistry(){const e=Object.create(null);for(const[t,o]of this.shortcuts)e[t]=o;return He(Object.create(null),e)}onKeyDown(e,t){var o=this.serializeKeyEvent(t);if(o=this.getShortcutNamesByKeyCode(o),!o)return!1;for(const s of o){o=this.shortcuts.get(s);let i;if(!o||o.preconditionFn&&!o.preconditionFn(e,{focusedNode:(i=r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode())!=null?i:void 0}))continue;let n,d,f;if((d=(n=o).callback)!=null&&d.call(n,e,t,o,{focusedNode:(f=r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode())!=null?f:void 0}))return!0}return!1}getShortcutNamesByKeyCode(e){let t;return((t=this.keyMap.get(e))==null?void 0:t.slice())||[]}getKeyCodesByShortcutName(e){const t=[];for(const[o,s]of this.keyMap)s.indexOf(e)>-1&&t.push(o);return t}serializeKeyEvent(e){let t="";for(const o in Pe.modifierKeys)e.getModifierState(o)&&(t!==""&&(t+="+"),t+=o);return t!==""&&e.keyCode?t+="+"+e.keyCode:e.keyCode&&(t=String(e.keyCode)),t}checkModifiers(e){for(const t of e)if(!(t in Pe.modifierKeys))throw Error(t+" is not a valid modifier key.")}createSerializedKey(e,t){let o="";if(t){this.checkModifiers(t);for(const s in Pe.modifierKeys)t.includes(Pe.modifierKeys[s])&&(o!==""&&(o+="+"),o+=s)}return o!==""&&e?o+="+"+e:e&&(o=`${e}`),o}};Pe.registry=new Pe,(function(e){e=e.modifierKeys||(e.modifierKeys={}),e[e.Shift=16]="Shift",e[e.Control=17]="Control",e[e.Alt=18]="Alt",e[e.Meta=91]="Meta"})(Pe||(Pe={}));var rr=Object.create(null),og,sg,nr=[],ig={defineBlocksWithJsonArrayInternal:b},ht={TEST_ONLY:ig};ht.createBlockDefinitionsFromJsonArray=r.createBlockDefinitionsFromJsonArray$$module$build$src$core$common,ht.defineBlocks=r.defineBlocks$$module$build$src$core$common,ht.defineBlocksWithJsonArray=$,ht.draggingConnections=nr,ht.fireSelectedEvent=V,ht.getAllWorkspaces=kt,ht.getBlockTypeCounts=io,ht.getMainWorkspace=c,ht.getParentContainer=Ae,ht.getSelected=I,ht.getWorkspaceById=ct,ht.globalShortcutHandler=S,ht.registerWorkspace=st,ht.setMainWorkspace=p,ht.setParentContainer=so,ht.setSelected=C,ht.svgResize=$o,ht.unregisterWorkpace=Ut;var hi=class{constructor(){this.workspaceId=void 0,this.isUiEvent=!1,this.type="",this.group=r.getGroup$$module$build$src$core$events$utils(),this.recordUndo=Ue()}toJson(){return{type:this.type,group:this.group}}static fromJson(e,t,o){return o.isBlank=!1,o.group=e.group||"",o.workspaceId=t.id,o}isNull(){return!1}run(e){}getEventWorkspace_(){let e;if(this.workspaceId&&(e=ct(this.workspaceId)),!e)throw Error("Workspace is null. Event must have been generated from real Blockly events.");return e}},Eo=class extends hi{constructor(e){super(),this.recordUndo=!1,this.isUiEvent=!0,this.isBlank=typeof e>"u",this.workspaceId=e||""}},aa=class extends Eo{constructor(e,t,o){t=e?e.workspace.id:t,t===null&&(t=void 0),super(t),this.type=w.CLICK,this.blockId=e?e.id:void 0,this.targetType=o}toJson(){const e=super.toJson();if(!this.targetType)throw Error("The click target type is undefined. Either pass a block to the constructor, or call fromJson");return e.targetType=this.targetType,e.blockId=this.blockId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new aa),t.targetType=e.targetType,t.blockId=e.blockId,t}},ha;(function(e){e.BLOCK="block",e.WORKSPACE="workspace",e.ZOOM_CONTROLS="zoom_controls"})(ha||(ha={})),l(M.EVENT,w.CLICK,aa);var rg={};rg.removeElem=x;var Ho=class{constructor(e){this.name=e}toString(){return this.name}};Ho.POSITIONABLE=new Ho("positionable"),Ho.DRAG_TARGET=new Ho("drag_target"),Ho.DELETE_AREA=new Ho("delete_area"),Ho.AUTOHIDEABLE=new Ho("autohideable");var Ve=class{constructor(){this.componentData=new Map,this.capabilityToComponentIds=new Map}addComponent(e,t){const o=e.component.id;if(!t&&this.componentData.has(o)){var s;throw Error('Plugin "'+o+'" with capabilities "'+((s=this.componentData.get(o))==null?void 0:s.capabilities)+'" already added.')}for(this.componentData.set(o,e),t=[],s=0;s<e.capabilities.length;s++){const i=String(e.capabilities[s]).toLowerCase();if(t.push(i),this.capabilityToComponentIds.has(i)){let n;(n=this.capabilityToComponentIds.get(i))==null||n.push(o)}else this.capabilityToComponentIds.set(i,[o])}this.componentData.get(o).capabilities=t}removeComponent(e){const t=this.componentData.get(e);if(t){for(let o=0;o<t.capabilities.length;o++){const s=String(t.capabilities[o]).toLowerCase();x(this.capabilityToComponentIds.get(s),e)}this.componentData.delete(e)}}addCapability(e,t){if(!this.getComponent(e))throw Error('Cannot add capability, "'+t+'". Plugin "'+e+'" has not been added to the ComponentManager');if(this.hasCapability(e,t))console.warn('Plugin "'+e+'already has capability "'+t+'"');else{t=`${t}`.toLowerCase();var o;(o=this.componentData.get(e))==null||o.capabilities.push(t);var s;(s=this.capabilityToComponentIds.get(t))==null||s.push(e)}}removeCapability(e,t){if(!this.getComponent(e))throw Error('Cannot remove capability, "'+t+'". Plugin "'+e+'" has not been added to the ComponentManager');this.hasCapability(e,t)?(t=`${t}`.toLowerCase(),x(this.componentData.get(e).capabilities,t),x(this.capabilityToComponentIds.get(t),e)):console.warn('Plugin "'+e+`doesn't have capability "`+t+'" to remove')}hasCapability(e,t){return t=`${t}`.toLowerCase(),this.componentData.has(e)&&this.componentData.get(e).capabilities.includes(t)}getComponent(e){let t;return(t=this.componentData.get(e))==null?void 0:t.component}getComponents(e,t){if(e=`${e}`.toLowerCase(),e=this.capabilityToComponentIds.get(e),!e)return[];const o=[];if(t){const s=[];e.forEach(i=>{s.push(this.componentData.get(i))}),s.sort(function(i,n){return i.weight-n.weight}),s.forEach(function(i){o.push(i.component)})}else e.forEach(s=>{o.push(this.componentData.get(s).component)});return o}};Ve.Capability=Ho,(function(e){e=e.ComponentWeight||(e.ComponentWeight={}),e[e.TOOLBOX_WEIGHT=0]="TOOLBOX_WEIGHT",e[e.FLYOUT_WEIGHT=1]="FLYOUT_WEIGHT",e[e.TRASHCAN_WEIGHT=2]="TRASHCAN_WEIGHT",e[e.ZOOM_CONTROLS_WEIGHT=3]="ZOOM_CONTROLS_WEIGHT"})(Ve||(Ve={})),Ve.ComponentWeight;var da=!1,$a=`
13
13
  .blocklySvg {
14
14
  background-color: #fff;
15
15
  outline: none;
@@ -458,7 +458,7 @@ input[type=number] {
458
458
  ) {
459
459
  outline: none;
460
460
  }
461
- `,da={};da.inject=pe,da.register=q;var P=class{constructor(e,t){this.x=e,this.y=t}clone(){return new P(this.x,this.y)}scale(e){return this.x*=e,this.y*=e,this}translate(e,t){return this.x+=e,this.y+=t,this}static equals(e,t){return e===t?!0:e&&t?e.x===t.x&&e.y===t.y:!1}static distance(e,t){const o=e.x-t.x;return e=e.y-t.y,Math.sqrt(o*o+e*e)}static magnitude(e){return Math.sqrt(e.x*e.x+e.y*e.y)}static difference(e,t){return new P(e.x-t.x,e.y-t.y)}static sum(e,t){return new P(e.x+t.x,e.y+t.y)}},R=class{constructor(e){this.tagName=e}toString(){return this.tagName}};R.ANIMATE=new R("animate"),R.CIRCLE=new R("circle"),R.CLIPPATH=new R("clipPath"),R.DEFS=new R("defs"),R.FECOMPOSITE=new R("feComposite"),R.FECOMPONENTTRANSFER=new R("feComponentTransfer"),R.FEFLOOD=new R("feFlood"),R.FEFUNCA=new R("feFuncA"),R.FEGAUSSIANBLUR=new R("feGaussianBlur"),R.FEPOINTLIGHT=new R("fePointLight"),R.FESPECULARLIGHTING=new R("feSpecularLighting"),R.FILTER=new R("filter"),R.FOREIGNOBJECT=new R("foreignObject"),R.G=new R("g"),R.IMAGE=new R("image"),R.LINE=new R("line"),R.PATH=new R("path"),R.PATTERN=new R("pattern"),R.POLYGON=new R("polygon"),R.RECT=new R("rect"),R.SVG=new R("svg"),R.TEXT=new R("text"),R.TSPAN=new R("tspan");var ye=class{constructor(e,t,o,s){this.top=e,this.bottom=t,this.left=o,this.right=s}static from(e){return new ye(e.y,e.y+e.height,e.x,e.x+e.width)}clone(){return new ye(this.top,this.bottom,this.left,this.right)}getHeight(){return this.bottom-this.top}getWidth(){return this.right-this.left}getOrigin(){return new P(this.left,this.top)}contains(e,t){return e>=this.left&&e<=this.right&&t>=this.top&&t<=this.bottom}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.bottom>=e.top&&this.top<=e.bottom}static equals(e,t){return e===t?!0:e&&t?e.top===t.top&&e.bottom===t.bottom&&e.left===t.left&&e.right===t.right:!1}static createFromPoint(e,t,o){const s=e.x;return e=e.y,new ye(e,e+o,s,s+t)}},ve=class{constructor(e,t){this.width=e,this.height=t}static equals(e,t){return e===t?!0:e&&t?e.width===t.width&&e.height===t.height:!1}static max(e,t){return new ve(Math.max(e.width,t.width),Math.max(e.height,t.height))}static min(e,t){return new ve(Math.min(e.width,t.width),Math.min(e.height,t.height))}},sg={getSizeInternal:fs},rs={TEST_ONLY:sg};rs.getBorderBox=Xl,rs.getComputedStyle=Mt,rs.getContainerOffsetToScrollInto=Kl,rs.getPageOffset=Zo,rs.getSize=Rt,rs.getViewportPageOffset=Yl,rs.scrollIntoContainerView=jl;var ig=/translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*)?/,rg=/transform:\s*translate(?:3d)?\(\s*([-+\d.e]+)\s*px([ ,]\s*([-+\d.e]+)\s*px)?/,gb={XY_REGEX:ig,XY_STYLE_REGEX:rg},ks={TEST_ONLY:gb};ks.getDocumentScroll=ql,ks.getInjectionDivXY=Br,ks.getRelativeXY=xi,ks.getViewportBBox=Jl,ks.screenToWsCoordinates=Zl,ks.wsToScreenCoordinates=Ys;var Ze=class{constructor(e,t,o,s,i){this.workspace=e,this.horizontal=t,this.oldHostMetrics=null,this.ratio=1,this.origin=new P(0,0),this.startDragHandle=this.handlePosition=this.handleLength=this.scrollbarLength=this.startDragMouse=0,this.containerVisible=this.isHandleVisible=!0,this.position=new P(0,0),this.onMouseMoveWrapper_=this.onMouseUpWrapper_=null,this.pair=o||!1,this.margin=i!==void 0?i:Ze.DEFAULT_SCROLLBAR_MARGIN,e="blocklyScrollbar"+(this.horizontal?"Horizontal":"Vertical"),s&&(e+=" "+s),this.outerSvg=v(R.SVG,{class:e}),s=v(R.G,{},this.outerSvg),this.svgBackground=v(R.RECT,{class:"blocklyScrollbarBackground"},s),e=Math.floor((Ze.scrollbarThickness-5)/2),this.svgHandle=v(R.RECT,{class:"blocklyScrollbarHandle",rx:e,ry:e},s),this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarColour","fill"),this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarOpacity","fill-opacity"),Qt(this.outerSvg,this.workspace.getParentSvg()),this.setInitialThickness(),t?(this.lengthAttribute_="width",this.positionAttribute_="x"):(this.lengthAttribute_="height",this.positionAttribute_="y"),this.onMouseDownBarWrapper_=z(this.svgBackground,"pointerdown",this,this.onMouseDownBar),this.onMouseDownHandleWrapper_=z(this.svgHandle,"pointerdown",this,this.onMouseDownHandle)}setInitialThickness(){const e=Ze.scrollbarThickness;this.horizontal?(this.svgBackground.setAttribute("height",String(e)),this.outerSvg.setAttribute("height",String(e)),this.svgHandle.setAttribute("height",String(e-5)),this.svgHandle.setAttribute("y","2.5")):(this.svgBackground.setAttribute("width",String(e)),this.outerSvg.setAttribute("width",String(e)),this.svgHandle.setAttribute("width",String(e-5)),this.svgHandle.setAttribute("x","2.5"))}dispose(){this.cleanUp(),te(this.onMouseDownBarWrapper_),te(this.onMouseDownHandleWrapper_),ke(this.outerSvg),this.workspace.getThemeManager().unsubscribe(this.svgHandle)}constrainHandleLength(e){return e=e<=0||isNaN(e)?0:Math.min(e,this.scrollbarLength)}setHandleLength(e){this.handleLength=e,this.svgHandle.setAttribute(this.lengthAttribute_,String(this.handleLength))}constrainHandlePosition(e){return e=e<=0||isNaN(e)?0:Math.min(e,this.scrollbarLength-this.handleLength)}setHandlePosition(e){this.handlePosition=e,this.svgHandle.setAttribute(this.positionAttribute_,String(this.handlePosition))}setScrollbarLength(e){this.scrollbarLength=e,this.outerSvg.setAttribute(this.lengthAttribute_,String(this.scrollbarLength)),this.svgBackground.setAttribute(this.lengthAttribute_,String(this.scrollbarLength))}setPosition(e,t){this.position.x=e,this.position.y=t,Mo(this.outerSvg,"translate("+(this.position.x+this.origin.x)+"px,"+(this.position.y+this.origin.y)+"px)")}resize(e){!e&&(e=this.workspace.getMetrics(),!e)||this.oldHostMetrics&&Ze.metricsAreEquivalent(e,this.oldHostMetrics)||(this.horizontal?this.resizeHorizontal(e):this.resizeVertical(e),this.oldHostMetrics=e,this.updateMetrics())}requiresViewResize(e){return this.oldHostMetrics?this.oldHostMetrics.viewWidth!==e.viewWidth||this.oldHostMetrics.viewHeight!==e.viewHeight||this.oldHostMetrics.absoluteLeft!==e.absoluteLeft||this.oldHostMetrics.absoluteTop!==e.absoluteTop:!0}resizeHorizontal(e){this.requiresViewResize(e)?this.resizeViewHorizontal(e):this.resizeContentHorizontal(e)}resizeViewHorizontal(e){var t=e.viewWidth-this.margin*2;this.pair&&(t-=Ze.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),t=e.absoluteLeft+this.margin,this.pair&&this.workspace.RTL&&(t+=Ze.scrollbarThickness),this.setPosition(t,e.absoluteTop+e.viewHeight-Ze.scrollbarThickness-this.margin),this.resizeContentHorizontal(e)}resizeContentHorizontal(e){if(e.viewWidth>=e.scrollWidth)this.setHandleLength(this.scrollbarLength),this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var t=this.scrollbarLength*e.viewWidth/e.scrollWidth;t=this.constrainHandleLength(t),this.setHandleLength(t),t=e.scrollWidth-e.viewWidth;var o=this.scrollbarLength-this.handleLength;e=(e.viewLeft-e.scrollLeft)/t*o,e=this.constrainHandlePosition(e),this.setHandlePosition(e),this.ratio=o/t}}resizeVertical(e){this.requiresViewResize(e)?this.resizeViewVertical(e):this.resizeContentVertical(e)}resizeViewVertical(e){let t=e.viewHeight-this.margin*2;this.pair&&(t-=Ze.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),this.setPosition(this.workspace.RTL?e.absoluteLeft+this.margin:e.absoluteLeft+e.viewWidth-Ze.scrollbarThickness-this.margin,e.absoluteTop+this.margin),this.resizeContentVertical(e)}resizeContentVertical(e){if(e.viewHeight>=e.scrollHeight)this.setHandleLength(this.scrollbarLength),this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var t=this.scrollbarLength*e.viewHeight/e.scrollHeight;t=this.constrainHandleLength(t),this.setHandleLength(t),t=e.scrollHeight-e.viewHeight;var o=this.scrollbarLength-this.handleLength;e=(e.viewTop-e.scrollTop)/t*o,e=this.constrainHandlePosition(e),this.setHandlePosition(e),this.ratio=o/t}}isVisible(){return this.isHandleVisible}setContainerVisible(e){const t=e!==this.containerVisible;this.containerVisible=e,t&&this.updateDisplay_()}setVisible(e){if(this.pair)throw Error("Unable to toggle visibility of paired scrollbars.");this.setVisibleInternal(e)}setVisibleInternal(e){const t=e!==this.isVisible();this.isHandleVisible=e,t&&this.updateDisplay_()}updateDisplay_(){this.containerVisible&&this.isVisible()?this.outerSvg.setAttribute("display","block"):this.outerSvg.setAttribute("display","none")}onMouseDownBar(e){if(this.workspace.markFocused(),ie(),this.cleanUp(),Ie(e))e.stopPropagation();else{var t=Ye(e,this.workspace.getParentSvg(),this.workspace.getInverseScreenCTM());t=this.horizontal?t.x:t.y;var o=Br(this.svgHandle);o=this.horizontal?o.x:o.y;var s=this.handlePosition,i=this.handleLength*.95;t<=o?s-=i:t>=o+this.handleLength&&(s+=i),this.setHandlePosition(this.constrainHandlePosition(s)),this.updateMetrics(),e.stopPropagation(),e.preventDefault()}}onMouseDownHandle(e){this.workspace.markFocused(),this.cleanUp(),Ie(e)?e.stopPropagation():(this.startDragHandle=this.handlePosition,this.startDragMouse=this.horizontal?e.clientX:e.clientY,this.onMouseUpWrapper_=z(document,"pointerup",this,this.onMouseUpHandle),this.onMouseMoveWrapper_=z(document,"pointermove",this,this.onMouseMoveHandle),e.stopPropagation(),e.preventDefault())}onMouseMoveHandle(e){this.setHandlePosition(this.constrainHandlePosition(this.startDragHandle+((this.horizontal?e.clientX:e.clientY)-this.startDragMouse))),this.updateMetrics()}onMouseUpHandle(){ie(),this.cleanUp()}cleanUp(){this.workspace.hideChaff(!0),this.onMouseUpWrapper_&&(te(this.onMouseUpWrapper_),this.onMouseUpWrapper_=null),this.onMouseMoveWrapper_&&(te(this.onMouseMoveWrapper_),this.onMouseMoveWrapper_=null)}getRatio_(){let e=this.handlePosition/(this.scrollbarLength-this.handleLength);return isNaN(e)&&(e=0),e}updateMetrics(){const e=this.getRatio_();this.horizontal?this.workspace.setMetrics({x:e}):this.workspace.setMetrics({y:e})}set(e,t){this.setHandlePosition(this.constrainHandlePosition(e*this.ratio)),(t||t===void 0)&&this.updateMetrics()}setOrigin(e,t){this.origin=new P(e,t)}static metricsAreEquivalent(e,t){return e.viewWidth===t.viewWidth&&e.viewHeight===t.viewHeight&&e.viewLeft===t.viewLeft&&e.viewTop===t.viewTop&&e.absoluteTop===t.absoluteTop&&e.absoluteLeft===t.absoluteLeft&&e.scrollWidth===t.scrollWidth&&e.scrollHeight===t.scrollHeight&&e.scrollLeft===t.scrollLeft&&e.scrollTop===t.scrollTop}};Ze.scrollbarThickness=Mp?25:15,Ze.DEFAULT_SCROLLBAR_MARGIN=.5;var Pn={parseFromString:function(){throw Error("DOMParser was not found in the global scope and was not properly injected using injectDependencies")}},$a={serializeToString:function(){throw Error("XMLSerializer was not foundin the global scope and was not properly injected using injectDependencies")}},{document:Fn,DOMParser:nr,XMLSerializer:lr}=globalThis;nr&&(Pn=new nr),lr&&($a=new lr);var ng="https://developers.google.com/blockly/xml",mb=/[\x00-\x09\x0B\x0C\x0E-\x1F]/g,di={NAME_SPACE:ng};di.createElement=r.createElement$$module$build$src$core$utils$xml,di.createTextNode=r.createTextNode$$module$build$src$core$utils$xml,di.domToText=Xs,di.injectDependencies=pd,di.textToDom=r.textToDom$$module$build$src$core$utils$xml;var pa="categoryToolbox",lg="flyoutToolbox",be;(function(e){e[e.TOP=0]="TOP",e[e.BOTTOM=1]="BOTTOM",e[e.LEFT=2]="LEFT",e[e.RIGHT=3]="RIGHT"})(be||(be={}));var cg={hasCategoriesInternal:fd},ns={};ns.Position=be,ns.TEST_ONLY=cg,ns.convertFlyoutDefToJsonArray=Bi,ns.convertToolboxDefToJson=Pr,ns.hasCategories=Fr,ns.isCategoryCollapsible=Ur,ns.parseToolboxTree=ec;var Go;(function(e){e[e.TOP=0]="TOP",e[e.BOTTOM=1]="BOTTOM"})(Go||(Go={}));var $i;(function(e){e[e.LEFT=0]="LEFT",e[e.RIGHT=1]="RIGHT"})($i||($i={}));var ls;(function(e){e[e.UP=0]="UP",e[e.DOWN=1]="DOWN"})(ls||(ls={}));var Rs={};Rs.bumpDirection=ls,Rs.bumpPositionRect=Wr,Rs.getCornerOppositeToolbox=Vr,Rs.getStartPositionRect=Gr,Rs.horizontalPosition=$i,Rs.verticalPosition=Go;var Dt={width:96,height:124,url:"sprites.png"},ug=class{constructor(e){this.workspace=e,this.id="zoomControls",this.boundEvents=[],this.zoomResetGroup=this.zoomOutGroup=this.zoomInGroup=null,this.HEIGHT=this.WIDTH=32,this.SMALL_SPACING=2,this.LARGE_SPACING=11,this.MARGIN_HORIZONTAL=this.MARGIN_VERTICAL=20,this.svgGroup=null,this.top=this.left=0,this.initialized=!1}createDom(){this.svgGroup=v(R.G,{});const e=String(Math.random()).substring(2);return this.createZoomOutSvg(e),this.createZoomInSvg(e),this.workspace.isMovable()&&this.createZoomResetSvg(e),this.svgGroup}init(){this.workspace.getComponentManager().addComponent({component:this,weight:Ve.ComponentWeight.ZOOM_CONTROLS_WEIGHT,capabilities:[Ve.Capability.POSITIONABLE]}),this.initialized=!0}dispose(){this.workspace.getComponentManager().removeComponent("zoomControls"),this.svgGroup&&ke(this.svgGroup);for(const e of this.boundEvents)te(e);this.boundEvents.length=0}getBoundingRectangle(){let e=this.SMALL_SPACING+2*this.HEIGHT;return this.zoomResetGroup&&(e+=this.LARGE_SPACING+this.HEIGHT),new ye(this.top,this.top+e,this.left,this.left+this.WIDTH)}position(e,t){if(this.initialized){var o=Vr(this.workspace,e),s=this.SMALL_SPACING+2*this.HEIGHT;if(this.zoomResetGroup&&(s+=this.LARGE_SPACING+this.HEIGHT),e=Gr(o,new ve(this.WIDTH,s),this.MARGIN_HORIZONTAL,this.MARGIN_VERTICAL,e,this.workspace),o=o.vertical,t=Wr(e,this.MARGIN_VERTICAL,o===Go.TOP?ls.DOWN:ls.UP,t),o===Go.TOP){var i=this.SMALL_SPACING+this.HEIGHT,n;(n=this.zoomInGroup)==null||n.setAttribute("transform","translate(0, "+i+")"),this.zoomResetGroup&&this.zoomResetGroup.setAttribute("transform","translate(0, "+(i+this.LARGE_SPACING+this.HEIGHT)+")")}else{n=this.zoomResetGroup?this.LARGE_SPACING+this.HEIGHT:0;let f;(f=this.zoomInGroup)==null||f.setAttribute("transform","translate(0, "+n+")"),n=n+this.SMALL_SPACING+this.HEIGHT,(i=this.zoomOutGroup)==null||i.setAttribute("transform","translate(0, "+n+")")}this.top=t.top,this.left=t.left;var d;(d=this.svgGroup)==null||d.setAttribute("transform","translate("+this.left+","+this.top+")")}}createZoomOutSvg(e){this.zoomOutGroup=v(R.G,{class:"blocklyZoom blocklyZoomOut"},this.svgGroup);const t=v(R.CLIPPATH,{id:"blocklyZoomoutClipPath"+e},this.zoomOutGroup);v(R.RECT,{width:32,height:32},t),v(R.IMAGE,{width:Dt.width,height:Dt.height,x:-64,y:-92,"clip-path":"url(#blocklyZoomoutClipPath"+e+")"},this.zoomOutGroup).setAttributeNS(Ht,"xlink:href",this.workspace.options.pathToMedia+Dt.url),this.boundEvents.push(z(this.zoomOutGroup,"pointerdown",null,this.zoom.bind(this,-1)))}createZoomInSvg(e){this.zoomInGroup=v(R.G,{class:"blocklyZoom blocklyZoomIn"},this.svgGroup);const t=v(R.CLIPPATH,{id:"blocklyZoominClipPath"+e},this.zoomInGroup);v(R.RECT,{width:32,height:32},t),v(R.IMAGE,{width:Dt.width,height:Dt.height,x:-32,y:-92,"clip-path":"url(#blocklyZoominClipPath"+e+")"},this.zoomInGroup).setAttributeNS(Ht,"xlink:href",this.workspace.options.pathToMedia+Dt.url),this.boundEvents.push(z(this.zoomInGroup,"pointerdown",null,this.zoom.bind(this,1)))}zoom(e,t){this.workspace.markFocused(),this.workspace.zoomCenter(e),this.fireZoomEvent(),ie(),t.stopPropagation(),t.preventDefault()}createZoomResetSvg(e){this.zoomResetGroup=v(R.G,{class:"blocklyZoom blocklyZoomReset"},this.svgGroup);const t=v(R.CLIPPATH,{id:"blocklyZoomresetClipPath"+e},this.zoomResetGroup);v(R.RECT,{width:32,height:32},t),v(R.IMAGE,{width:Dt.width,height:Dt.height,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+e+")"},this.zoomResetGroup).setAttributeNS(Ht,"xlink:href",this.workspace.options.pathToMedia+Dt.url),this.boundEvents.push(z(this.zoomResetGroup,"pointerdown",null,this.resetZoom.bind(this)))}resetZoom(e){this.workspace.markFocused();const t=Math.log(this.workspace.options.zoomOptions.startScale/this.workspace.scale)/Math.log(this.workspace.options.zoomOptions.scaleSpeed);this.workspace.beginCanvasTransition(),this.workspace.zoomCenter(t),this.workspace.scrollCenter(),setTimeout(this.workspace.endCanvasTransition.bind(this.workspace),500),this.fireZoomEvent(),ie(),e.stopPropagation(),e.preventDefault()}fireZoomEvent(){const e=new(U(w.CLICK))(null,this.workspace.id,"zoom_controls");_(e)}};q(`
461
+ `,pa={};pa.inject=pe,pa.register=q;var P=class{constructor(e,t){this.x=e,this.y=t}clone(){return new P(this.x,this.y)}scale(e){return this.x*=e,this.y*=e,this}translate(e,t){return this.x+=e,this.y+=t,this}static equals(e,t){return e===t?!0:e&&t?e.x===t.x&&e.y===t.y:!1}static distance(e,t){const o=e.x-t.x;return e=e.y-t.y,Math.sqrt(o*o+e*e)}static magnitude(e){return Math.sqrt(e.x*e.x+e.y*e.y)}static difference(e,t){return new P(e.x-t.x,e.y-t.y)}static sum(e,t){return new P(e.x+t.x,e.y+t.y)}},R=class{constructor(e){this.tagName=e}toString(){return this.tagName}};R.ANIMATE=new R("animate"),R.CIRCLE=new R("circle"),R.CLIPPATH=new R("clipPath"),R.DEFS=new R("defs"),R.FECOMPOSITE=new R("feComposite"),R.FECOMPONENTTRANSFER=new R("feComponentTransfer"),R.FEFLOOD=new R("feFlood"),R.FEFUNCA=new R("feFuncA"),R.FEGAUSSIANBLUR=new R("feGaussianBlur"),R.FEPOINTLIGHT=new R("fePointLight"),R.FESPECULARLIGHTING=new R("feSpecularLighting"),R.FILTER=new R("filter"),R.FOREIGNOBJECT=new R("foreignObject"),R.G=new R("g"),R.IMAGE=new R("image"),R.LINE=new R("line"),R.PATH=new R("path"),R.PATTERN=new R("pattern"),R.POLYGON=new R("polygon"),R.RECT=new R("rect"),R.SVG=new R("svg"),R.TEXT=new R("text"),R.TSPAN=new R("tspan");var ye=class{constructor(e,t,o,s){this.top=e,this.bottom=t,this.left=o,this.right=s}static from(e){return new ye(e.y,e.y+e.height,e.x,e.x+e.width)}clone(){return new ye(this.top,this.bottom,this.left,this.right)}getHeight(){return this.bottom-this.top}getWidth(){return this.right-this.left}getOrigin(){return new P(this.left,this.top)}contains(e,t){return e>=this.left&&e<=this.right&&t>=this.top&&t<=this.bottom}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.bottom>=e.top&&this.top<=e.bottom}static equals(e,t){return e===t?!0:e&&t?e.top===t.top&&e.bottom===t.bottom&&e.left===t.left&&e.right===t.right:!1}static createFromPoint(e,t,o){const s=e.x;return e=e.y,new ye(e,e+o,s,s+t)}},ve=class{constructor(e,t){this.width=e,this.height=t}static equals(e,t){return e===t?!0:e&&t?e.width===t.width&&e.height===t.height:!1}static max(e,t){return new ve(Math.max(e.width,t.width),Math.max(e.height,t.height))}static min(e,t){return new ve(Math.min(e.width,t.width),Math.min(e.height,t.height))}},ng={getSizeInternal:fs},rs={TEST_ONLY:ng};rs.getBorderBox=Kl,rs.getComputedStyle=Mt,rs.getContainerOffsetToScrollInto=ql,rs.getPageOffset=Zo,rs.getSize=Rt,rs.getViewportPageOffset=jl,rs.scrollIntoContainerView=Jl;var lg=/translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*)?/,cg=/transform:\s*translate(?:3d)?\(\s*([-+\d.e]+)\s*px([ ,]\s*([-+\d.e]+)\s*px)?/,_b={XY_REGEX:lg,XY_STYLE_REGEX:cg},ks={TEST_ONLY:_b};ks.getDocumentScroll=Ql,ks.getInjectionDivXY=Pr,ks.getRelativeXY=Bi,ks.getViewportBBox=Zl,ks.screenToWsCoordinates=ec,ks.wsToScreenCoordinates=Ys;var Ze=class{constructor(e,t,o,s,i){this.workspace=e,this.horizontal=t,this.oldHostMetrics=null,this.ratio=1,this.origin=new P(0,0),this.startDragHandle=this.handlePosition=this.handleLength=this.scrollbarLength=this.startDragMouse=0,this.containerVisible=this.isHandleVisible=!0,this.position=new P(0,0),this.onMouseMoveWrapper_=this.onMouseUpWrapper_=null,this.pair=o||!1,this.margin=i!==void 0?i:Ze.DEFAULT_SCROLLBAR_MARGIN,e="blocklyScrollbar"+(this.horizontal?"Horizontal":"Vertical"),s&&(e+=" "+s),this.outerSvg=v(R.SVG,{class:e}),s=v(R.G,{},this.outerSvg),this.svgBackground=v(R.RECT,{class:"blocklyScrollbarBackground"},s),e=Math.floor((Ze.scrollbarThickness-5)/2),this.svgHandle=v(R.RECT,{class:"blocklyScrollbarHandle",rx:e,ry:e},s),this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarColour","fill"),this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarOpacity","fill-opacity"),Qt(this.outerSvg,this.workspace.getParentSvg()),this.setInitialThickness(),t?(this.lengthAttribute_="width",this.positionAttribute_="x"):(this.lengthAttribute_="height",this.positionAttribute_="y"),this.onMouseDownBarWrapper_=z(this.svgBackground,"pointerdown",this,this.onMouseDownBar),this.onMouseDownHandleWrapper_=z(this.svgHandle,"pointerdown",this,this.onMouseDownHandle)}setInitialThickness(){const e=Ze.scrollbarThickness;this.horizontal?(this.svgBackground.setAttribute("height",String(e)),this.outerSvg.setAttribute("height",String(e)),this.svgHandle.setAttribute("height",String(e-5)),this.svgHandle.setAttribute("y","2.5")):(this.svgBackground.setAttribute("width",String(e)),this.outerSvg.setAttribute("width",String(e)),this.svgHandle.setAttribute("width",String(e-5)),this.svgHandle.setAttribute("x","2.5"))}dispose(){this.cleanUp(),te(this.onMouseDownBarWrapper_),te(this.onMouseDownHandleWrapper_),ke(this.outerSvg),this.workspace.getThemeManager().unsubscribe(this.svgHandle)}constrainHandleLength(e){return e=e<=0||isNaN(e)?0:Math.min(e,this.scrollbarLength)}setHandleLength(e){this.handleLength=e,this.svgHandle.setAttribute(this.lengthAttribute_,String(this.handleLength))}constrainHandlePosition(e){return e=e<=0||isNaN(e)?0:Math.min(e,this.scrollbarLength-this.handleLength)}setHandlePosition(e){this.handlePosition=e,this.svgHandle.setAttribute(this.positionAttribute_,String(this.handlePosition))}setScrollbarLength(e){this.scrollbarLength=e,this.outerSvg.setAttribute(this.lengthAttribute_,String(this.scrollbarLength)),this.svgBackground.setAttribute(this.lengthAttribute_,String(this.scrollbarLength))}setPosition(e,t){this.position.x=e,this.position.y=t,Mo(this.outerSvg,"translate("+(this.position.x+this.origin.x)+"px,"+(this.position.y+this.origin.y)+"px)")}resize(e){!e&&(e=this.workspace.getMetrics(),!e)||this.oldHostMetrics&&Ze.metricsAreEquivalent(e,this.oldHostMetrics)||(this.horizontal?this.resizeHorizontal(e):this.resizeVertical(e),this.oldHostMetrics=e,this.updateMetrics())}requiresViewResize(e){return this.oldHostMetrics?this.oldHostMetrics.viewWidth!==e.viewWidth||this.oldHostMetrics.viewHeight!==e.viewHeight||this.oldHostMetrics.absoluteLeft!==e.absoluteLeft||this.oldHostMetrics.absoluteTop!==e.absoluteTop:!0}resizeHorizontal(e){this.requiresViewResize(e)?this.resizeViewHorizontal(e):this.resizeContentHorizontal(e)}resizeViewHorizontal(e){var t=e.viewWidth-this.margin*2;this.pair&&(t-=Ze.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),t=e.absoluteLeft+this.margin,this.pair&&this.workspace.RTL&&(t+=Ze.scrollbarThickness),this.setPosition(t,e.absoluteTop+e.viewHeight-Ze.scrollbarThickness-this.margin),this.resizeContentHorizontal(e)}resizeContentHorizontal(e){if(e.viewWidth>=e.scrollWidth)this.setHandleLength(this.scrollbarLength),this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var t=this.scrollbarLength*e.viewWidth/e.scrollWidth;t=this.constrainHandleLength(t),this.setHandleLength(t),t=e.scrollWidth-e.viewWidth;var o=this.scrollbarLength-this.handleLength;e=(e.viewLeft-e.scrollLeft)/t*o,e=this.constrainHandlePosition(e),this.setHandlePosition(e),this.ratio=o/t}}resizeVertical(e){this.requiresViewResize(e)?this.resizeViewVertical(e):this.resizeContentVertical(e)}resizeViewVertical(e){let t=e.viewHeight-this.margin*2;this.pair&&(t-=Ze.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),this.setPosition(this.workspace.RTL?e.absoluteLeft+this.margin:e.absoluteLeft+e.viewWidth-Ze.scrollbarThickness-this.margin,e.absoluteTop+this.margin),this.resizeContentVertical(e)}resizeContentVertical(e){if(e.viewHeight>=e.scrollHeight)this.setHandleLength(this.scrollbarLength),this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var t=this.scrollbarLength*e.viewHeight/e.scrollHeight;t=this.constrainHandleLength(t),this.setHandleLength(t),t=e.scrollHeight-e.viewHeight;var o=this.scrollbarLength-this.handleLength;e=(e.viewTop-e.scrollTop)/t*o,e=this.constrainHandlePosition(e),this.setHandlePosition(e),this.ratio=o/t}}isVisible(){return this.isHandleVisible}setContainerVisible(e){const t=e!==this.containerVisible;this.containerVisible=e,t&&this.updateDisplay_()}setVisible(e){if(this.pair)throw Error("Unable to toggle visibility of paired scrollbars.");this.setVisibleInternal(e)}setVisibleInternal(e){const t=e!==this.isVisible();this.isHandleVisible=e,t&&this.updateDisplay_()}updateDisplay_(){this.containerVisible&&this.isVisible()?this.outerSvg.setAttribute("display","block"):this.outerSvg.setAttribute("display","none")}onMouseDownBar(e){if(this.workspace.markFocused(),ie(),this.cleanUp(),Ie(e))e.stopPropagation();else{var t=Ye(e,this.workspace.getParentSvg(),this.workspace.getInverseScreenCTM());t=this.horizontal?t.x:t.y;var o=Pr(this.svgHandle);o=this.horizontal?o.x:o.y;var s=this.handlePosition,i=this.handleLength*.95;t<=o?s-=i:t>=o+this.handleLength&&(s+=i),this.setHandlePosition(this.constrainHandlePosition(s)),this.updateMetrics(),e.stopPropagation(),e.preventDefault()}}onMouseDownHandle(e){this.workspace.markFocused(),this.cleanUp(),Ie(e)?e.stopPropagation():(this.startDragHandle=this.handlePosition,this.startDragMouse=this.horizontal?e.clientX:e.clientY,this.onMouseUpWrapper_=z(document,"pointerup",this,this.onMouseUpHandle),this.onMouseMoveWrapper_=z(document,"pointermove",this,this.onMouseMoveHandle),e.stopPropagation(),e.preventDefault())}onMouseMoveHandle(e){this.setHandlePosition(this.constrainHandlePosition(this.startDragHandle+((this.horizontal?e.clientX:e.clientY)-this.startDragMouse))),this.updateMetrics()}onMouseUpHandle(){ie(),this.cleanUp()}cleanUp(){this.workspace.hideChaff(!0),this.onMouseUpWrapper_&&(te(this.onMouseUpWrapper_),this.onMouseUpWrapper_=null),this.onMouseMoveWrapper_&&(te(this.onMouseMoveWrapper_),this.onMouseMoveWrapper_=null)}getRatio_(){let e=this.handlePosition/(this.scrollbarLength-this.handleLength);return isNaN(e)&&(e=0),e}updateMetrics(){const e=this.getRatio_();this.horizontal?this.workspace.setMetrics({x:e}):this.workspace.setMetrics({y:e})}set(e,t){this.setHandlePosition(this.constrainHandlePosition(e*this.ratio)),(t||t===void 0)&&this.updateMetrics()}setOrigin(e,t){this.origin=new P(e,t)}static metricsAreEquivalent(e,t){return e.viewWidth===t.viewWidth&&e.viewHeight===t.viewHeight&&e.viewLeft===t.viewLeft&&e.viewTop===t.viewTop&&e.absoluteTop===t.absoluteTop&&e.absoluteLeft===t.absoluteLeft&&e.scrollWidth===t.scrollWidth&&e.scrollHeight===t.scrollHeight&&e.scrollLeft===t.scrollLeft&&e.scrollTop===t.scrollTop}};Ze.scrollbarThickness=Bp?25:15,Ze.DEFAULT_SCROLLBAR_MARGIN=.5;var Fn={parseFromString:function(){throw Error("DOMParser was not found in the global scope and was not properly injected using injectDependencies")}},ga={serializeToString:function(){throw Error("XMLSerializer was not foundin the global scope and was not properly injected using injectDependencies")}},{document:Un,DOMParser:lr,XMLSerializer:cr}=globalThis;lr&&(Fn=new lr),cr&&(ga=new cr);var ug="https://developers.google.com/blockly/xml",bb=/[\x00-\x09\x0B\x0C\x0E-\x1F]/g,di={NAME_SPACE:ug};di.createElement=r.createElement$$module$build$src$core$utils$xml,di.createTextNode=r.createTextNode$$module$build$src$core$utils$xml,di.domToText=Xs,di.injectDependencies=fd,di.textToDom=r.textToDom$$module$build$src$core$utils$xml;var ma="categoryToolbox",ag="flyoutToolbox",be;(function(e){e[e.TOP=0]="TOP",e[e.BOTTOM=1]="BOTTOM",e[e.LEFT=2]="LEFT",e[e.RIGHT=3]="RIGHT"})(be||(be={}));var hg={hasCategoriesInternal:Td},ns={};ns.Position=be,ns.TEST_ONLY=hg,ns.convertFlyoutDefToJsonArray=Pi,ns.convertToolboxDefToJson=Fr,ns.hasCategories=Ur,ns.isCategoryCollapsible=Hr,ns.parseToolboxTree=oc;var Go;(function(e){e[e.TOP=0]="TOP",e[e.BOTTOM=1]="BOTTOM"})(Go||(Go={}));var $i;(function(e){e[e.LEFT=0]="LEFT",e[e.RIGHT=1]="RIGHT"})($i||($i={}));var ls;(function(e){e[e.UP=0]="UP",e[e.DOWN=1]="DOWN"})(ls||(ls={}));var Rs={};Rs.bumpDirection=ls,Rs.bumpPositionRect=zr,Rs.getCornerOppositeToolbox=Wr,Rs.getStartPositionRect=Vr,Rs.horizontalPosition=$i,Rs.verticalPosition=Go;var Dt={width:96,height:124,url:"sprites.png"},dg=class{constructor(e){this.workspace=e,this.id="zoomControls",this.boundEvents=[],this.zoomResetGroup=this.zoomOutGroup=this.zoomInGroup=null,this.HEIGHT=this.WIDTH=32,this.SMALL_SPACING=2,this.LARGE_SPACING=11,this.MARGIN_HORIZONTAL=this.MARGIN_VERTICAL=20,this.svgGroup=null,this.top=this.left=0,this.initialized=!1}createDom(){this.svgGroup=v(R.G,{});const e=String(Math.random()).substring(2);return this.createZoomOutSvg(e),this.createZoomInSvg(e),this.workspace.isMovable()&&this.createZoomResetSvg(e),this.svgGroup}init(){this.workspace.getComponentManager().addComponent({component:this,weight:Ve.ComponentWeight.ZOOM_CONTROLS_WEIGHT,capabilities:[Ve.Capability.POSITIONABLE]}),this.initialized=!0}dispose(){this.workspace.getComponentManager().removeComponent("zoomControls"),this.svgGroup&&ke(this.svgGroup);for(const e of this.boundEvents)te(e);this.boundEvents.length=0}getBoundingRectangle(){let e=this.SMALL_SPACING+2*this.HEIGHT;return this.zoomResetGroup&&(e+=this.LARGE_SPACING+this.HEIGHT),new ye(this.top,this.top+e,this.left,this.left+this.WIDTH)}position(e,t){if(this.initialized){var o=Wr(this.workspace,e),s=this.SMALL_SPACING+2*this.HEIGHT;if(this.zoomResetGroup&&(s+=this.LARGE_SPACING+this.HEIGHT),e=Vr(o,new ve(this.WIDTH,s),this.MARGIN_HORIZONTAL,this.MARGIN_VERTICAL,e,this.workspace),o=o.vertical,t=zr(e,this.MARGIN_VERTICAL,o===Go.TOP?ls.DOWN:ls.UP,t),o===Go.TOP){var i=this.SMALL_SPACING+this.HEIGHT,n;(n=this.zoomInGroup)==null||n.setAttribute("transform","translate(0, "+i+")"),this.zoomResetGroup&&this.zoomResetGroup.setAttribute("transform","translate(0, "+(i+this.LARGE_SPACING+this.HEIGHT)+")")}else{n=this.zoomResetGroup?this.LARGE_SPACING+this.HEIGHT:0;let f;(f=this.zoomInGroup)==null||f.setAttribute("transform","translate(0, "+n+")"),n=n+this.SMALL_SPACING+this.HEIGHT,(i=this.zoomOutGroup)==null||i.setAttribute("transform","translate(0, "+n+")")}this.top=t.top,this.left=t.left;var d;(d=this.svgGroup)==null||d.setAttribute("transform","translate("+this.left+","+this.top+")")}}createZoomOutSvg(e){this.zoomOutGroup=v(R.G,{class:"blocklyZoom blocklyZoomOut"},this.svgGroup);const t=v(R.CLIPPATH,{id:"blocklyZoomoutClipPath"+e},this.zoomOutGroup);v(R.RECT,{width:32,height:32},t),v(R.IMAGE,{width:Dt.width,height:Dt.height,x:-64,y:-92,"clip-path":"url(#blocklyZoomoutClipPath"+e+")"},this.zoomOutGroup).setAttributeNS(Ht,"xlink:href",this.workspace.options.pathToMedia+Dt.url),this.boundEvents.push(z(this.zoomOutGroup,"pointerdown",null,this.zoom.bind(this,-1)))}createZoomInSvg(e){this.zoomInGroup=v(R.G,{class:"blocklyZoom blocklyZoomIn"},this.svgGroup);const t=v(R.CLIPPATH,{id:"blocklyZoominClipPath"+e},this.zoomInGroup);v(R.RECT,{width:32,height:32},t),v(R.IMAGE,{width:Dt.width,height:Dt.height,x:-32,y:-92,"clip-path":"url(#blocklyZoominClipPath"+e+")"},this.zoomInGroup).setAttributeNS(Ht,"xlink:href",this.workspace.options.pathToMedia+Dt.url),this.boundEvents.push(z(this.zoomInGroup,"pointerdown",null,this.zoom.bind(this,1)))}zoom(e,t){this.workspace.markFocused(),this.workspace.zoomCenter(e),this.fireZoomEvent(),ie(),t.stopPropagation(),t.preventDefault()}createZoomResetSvg(e){this.zoomResetGroup=v(R.G,{class:"blocklyZoom blocklyZoomReset"},this.svgGroup);const t=v(R.CLIPPATH,{id:"blocklyZoomresetClipPath"+e},this.zoomResetGroup);v(R.RECT,{width:32,height:32},t),v(R.IMAGE,{width:Dt.width,height:Dt.height,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+e+")"},this.zoomResetGroup).setAttributeNS(Ht,"xlink:href",this.workspace.options.pathToMedia+Dt.url),this.boundEvents.push(z(this.zoomResetGroup,"pointerdown",null,this.resetZoom.bind(this)))}resetZoom(e){this.workspace.markFocused();const t=Math.log(this.workspace.options.zoomOptions.startScale/this.workspace.scale)/Math.log(this.workspace.options.zoomOptions.scaleSpeed);this.workspace.beginCanvasTransition(),this.workspace.zoomCenter(t),this.workspace.scrollCenter(),setTimeout(this.workspace.endCanvasTransition.bind(this.workspace),500),this.fireZoomEvent(),ie(),e.stopPropagation(),e.preventDefault()}fireZoomEvent(){const e=new(U(w.CLICK))(null,this.workspace.id,"zoom_controls");_(e)}};q(`
462
462
  .blocklyZoom>image, .blocklyZoom>svg>image {
463
463
  opacity: .4;
464
464
  }
@@ -470,8 +470,8 @@ input[type=number] {
470
470
  .blocklyZoom>image:active, .blocklyZoom>svg>image:active {
471
471
  opacity: .8;
472
472
  }
473
- `);var ag=100,hg=75,dg=50,$g=25,fb={BLOCKS:dg,PROCEDURES:hg,VARIABLES:ag,WORKSPACE_COMMENTS:$g},ga={};ga.register=Pi,ga.unregister=bd;var pg=class{constructor(){this.priority=$g}save(e){const t=[];for(const o of e.getTopComments())(e=js(o,{addCoordinates:!0,saveIds:!0}))&&t.push(e);return t.length?t:null}load(e,t){for(const o of e)Fi(o,t,{recordUndo:Ue()})}clear(e){for(const t of e.getTopComments())t.dispose()}};Pi("workspaceComments",new pg);var Un={};Un.WorkspaceCommentSerializer=pg,Un.append=Fi,Un.save=js;var ma={};ma.register=zr,ma.unregister=Td;var Hn=class{paste(e,t,o){e=e.commentState,o&&(e.x=o.x,e.y=o.y),r.disable$$module$build$src$core$events$utils();let s;try{s=Fi(e,t),Ed(s)}finally{r.enable$$module$build$src$core$events$utils()}return s?(J()&&_(new(U(w.COMMENT_CREATE))(s)),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(s),s):null}};Hn.TYPE="workspace-comment",zr(Hn.TYPE,new Hn);var fa;fa=28,r.config$$module$build$src$core$config={dragRadius:5,flyoutDragRadius:10,snapRadius:fa,connectingSnapRadius:fa,currentConnectionPreference:8,bumpDelay:250},r.config$$module$build$src$core$config;var _b="aria-",bb="role",Gt;(function(e){e.GRID="grid",e.GRIDCELL="gridcell",e.GROUP="group",e.LISTBOX="listbox",e.MENU="menu",e.MENUITEM="menuitem",e.MENUITEMCHECKBOX="menuitemcheckbox",e.OPTION="option",e.PRESENTATION="presentation",e.ROW="row",e.TREE="tree",e.TREEITEM="treeitem",e.SEPARATOR="separator",e.STATUS="status"})(Gt||(Gt={}));var Qe;(function(e){e.ACTIVEDESCENDANT="activedescendant",e.COLCOUNT="colcount",e.DISABLED="disabled",e.EXPANDED="expanded",e.INVALID="invalid",e.LABEL="label",e.LABELLEDBY="labelledby",e.LEVEL="level",e.ORIENTATION="orientation",e.POSINSET="posinset",e.ROWCOUNT="rowcount",e.SELECTED="selected",e.SETSIZE="setsize",e.VALUEMAX="valuemax",e.VALUEMIN="valuemin",e.LIVE="live",e.HIDDEN="hidden"})(Qe||(Qe={}));var cr={};cr.Role=Gt,cr.State=Qe,cr.setRole=po,cr.setState=it;var Gn=class{constructor(e,t){this.content=e,this.opt_value=t,this.enabled=!0,this.element=null,this.rightToLeft=!1,this.roleName=null,this.highlight=this.checked=this.checkable=!1,this.actionHandler=null}createDom(){const e=document.createElement("div");e.id=Re(),this.element=e,e.className="blocklyMenuItem "+(this.enabled?"":"blocklyMenuItemDisabled ")+(this.checked?"blocklyMenuItemSelected ":"")+(this.highlight?"blocklyMenuItemHighlight ":"")+(this.rightToLeft?"blocklyMenuItemRtl ":"");const t=document.createElement("div");if(t.className="blocklyMenuItemContent",this.checkable){var o=document.createElement("div");o.className="blocklyMenuItemCheckbox ",t.appendChild(o)}return o=this.content,typeof this.content=="string"&&(o=document.createTextNode(this.content)),t.appendChild(o),e.appendChild(t),this.roleName&&po(e,this.roleName),it(e,Qe.SELECTED,this.checkable&&this.checked||!1),it(e,Qe.DISABLED,!this.enabled),e}dispose(){this.element=null}getElement(){return this.element}getId(){return this.element.id}getValue(){let e;return(e=this.opt_value)!=null?e:null}setRightToLeft(e){this.rightToLeft=e}setRole(e){this.roleName=e}setCheckable(e){this.checkable=e}setChecked(e){this.checked=e}setHighlighted(e){this.highlight=e;const t=this.getElement();t&&this.isEnabled()&&(e?G(t,"blocklyMenuItemHighlight"):Te(t,"blocklyMenuItemHighlight"))}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}performAction(e){this.isEnabled()&&this.actionHandler&&this.actionHandler(this,e)}onAction(e,t){this.actionHandler=e.bind(t)}},_a=class{constructor(){this.menuItems=[],this.roleName=this.element=this.onKeyDownHandler=this.pointerLeaveHandler=this.pointerEnterHandler=this.clickHandler=this.pointerMoveHandler=this.highlightedItem=this.openingCoords=null}addChild(e){this.menuItems.push(e)}render(e){const t=document.createElement("div");t.className="blocklyMenu",t.tabIndex=0,this.roleName&&po(t,this.roleName),this.element=t;for(let o=0,s;s=this.menuItems[o];o++)t.appendChild(s.createDom());return this.pointerMoveHandler=z(t,"pointermove",this,this.handlePointerMove,!0),this.clickHandler=z(t,"pointerup",this,this.handleClick,!0),this.pointerEnterHandler=z(t,"pointerenter",this,this.handlePointerEnter,!0),this.pointerLeaveHandler=z(t,"pointerleave",this,this.handlePointerLeave,!0),this.onKeyDownHandler=z(t,"keydown",this,this.handleKeyEvent),e.appendChild(t),t}getElement(){return this.element}focus(){const e=this.getElement();e&&e.focus({preventScroll:!0})}blur(){const e=this.getElement();e&&e.blur()}setRole(e){this.roleName=e}dispose(){this.pointerMoveHandler&&(te(this.pointerMoveHandler),this.pointerMoveHandler=null),this.clickHandler&&(te(this.clickHandler),this.clickHandler=null),this.pointerEnterHandler&&(te(this.pointerEnterHandler),this.pointerEnterHandler=null),this.pointerLeaveHandler&&(te(this.pointerLeaveHandler),this.pointerLeaveHandler=null),this.onKeyDownHandler&&(te(this.onKeyDownHandler),this.onKeyDownHandler=null);for(let e=0,t;t=this.menuItems[e];e++)t.dispose();this.element=null}getMenuItem(e){const t=this.getElement();for(;e&&e!==t;){if(e.classList.contains("blocklyMenuItem")){const o=this.getMenuItems();for(let s=0,i;i=o[s];s++)if(i.getElement()===e)return i}e=e.parentElement}return null}setHighlighted(e){var t=this.highlightedItem;if(t&&(t.setHighlighted(!1),this.highlightedItem=null),e){e.setHighlighted(!0),this.highlightedItem=e,t=this.getElement();const o=e.getElement();t&&o&&(jl(o,t),it(t,Qe.ACTIVEDESCENDANT,e.getId()))}}highlightNext(){const e=this.highlightedItem?this.menuItems.indexOf(this.highlightedItem):-1;this.highlightHelper(e,1)}highlightPrevious(){const e=this.highlightedItem?this.menuItems.indexOf(this.highlightedItem):-1;this.highlightHelper(e<0?this.menuItems.length:e,-1)}highlightFirst(){this.highlightHelper(-1,1)}highlightLast(){this.highlightHelper(this.menuItems.length,-1)}highlightHelper(e,t){e+=t;let o;const s=this.getMenuItems();for(;o=s[e];){if(o.isEnabled()){this.setHighlighted(o);break}e+=t}}handlePointerMove(e){Math.max(Math.abs(e.movementX),Math.abs(e.movementY))!==0&&(e=this.getMenuItem(e.target))&&(e.isEnabled()?this.highlightedItem!==e&&this.setHighlighted(e):this.setHighlighted(null))}handleClick(e){var t=this.openingCoords;if(this.openingCoords=null,t&&typeof e.clientX=="number"){const o=new P(e.clientX,e.clientY);if(P.distance(t,o)<1)return}(t=this.getMenuItem(e.target))&&t.performAction(e)}handlePointerEnter(e){this.focus()}handlePointerLeave(e){this.getElement()&&this.setHighlighted(null)}handleKeyEvent(e){if(this.menuItems.length&&!(e.shiftKey||e.ctrlKey||e.metaKey||e.altKey)){var t=this.highlightedItem;switch(e.key){case"Enter":case" ":t&&t.performAction(e);break;case"ArrowUp":this.highlightPrevious();break;case"ArrowDown":this.highlightNext();break;case"PageUp":case"Home":this.highlightFirst();break;case"PageDown":case"End":this.highlightLast();break;default:return}e.preventDefault(),e.stopPropagation()}}getSize(){const e=this.getElement(),t=Rt(e);return t.height=e.scrollHeight,t}getMenuItems(){return this.menuItems.filter(e=>e instanceof Gn)}},gg=class{constructor(){this.element=null}createDom(){return this.element=document.createElement("hr"),this.element.className="blocklyMenuSeparator",po(this.element,Gt.SEPARATOR),this.element}dispose(){let e;(e=this.element)==null||e.remove(),this.element=null}},ur="_TEMP_COLLAPSED_INPUT",Vn="_TEMP_COLLAPSED_FIELD",Jt="MANUALLY_DISABLED",Tb={COLLAPSED_FIELD_NAME:Vn,COLLAPSED_INPUT_NAME:ur,MANUALLY_DISABLED:Jt};(function(e){e[e.VALUE=1]="VALUE",e[e.STATEMENT=3]="STATEMENT",e[e.DUMMY=5]="DUMMY",e[e.CUSTOM=6]="CUSTOM",e[e.END_ROW=7]="END_ROW"})(r.inputTypes$$module$build$src$core$inputs$input_types||(r.inputTypes$$module$build$src$core$inputs$input_types={})),r.inputTypes$$module$build$src$core$inputs$input_types;var Wn=new Set,ba=new WeakSet,Ta=new WeakMap,pi=null,Ea=null,mg=0,zn={};zn.finishQueuedRenders=go,zn.queueRender=tc,zn.triggerQueuedRenders=Qo;var ya,fg;r.Msg$$module$build$src$core$msg=Object.create(null),ya=function(e){Object.keys(e).forEach(function(t){r.Msg$$module$build$src$core$msg[t]=e[t]})},fg={Msg:r.Msg$$module$build$src$core$msg,setLocale:ya};var ar="blocklyToast",_g="blocklyToastMessage",bg="blocklyToastCloseButton",ws=class{static show(e,t){if(t.oncePerSession&&t.id){if(this.shownIds.has(t.id))return;this.shownIds.add(t.id)}this.hide(e);const o=this.createDom(e,t);requestAnimationFrame(()=>{o.style.bottom="2rem"})}static createDom(e,t){const{message:o,duration:s=5,assertiveness:i=ws.Assertiveness.POLITE}=t,n=document.createElement("div");e.getInjectionDiv().appendChild(n),n.dataset.toastId=t.id,n.className=ar,po(n,Gt.STATUS),it(n,Qe.LIVE,i),t=n.appendChild(document.createElement("div")),t.className=_g,t.innerText=o,t=n.appendChild(document.createElement("button")),t.className=bg,it(t,Qe.LABEL,r.Msg$$module$build$src$core$msg.CLOSE);var d=v(R.SVG,{width:24,height:24,viewBox:"0 0 24 24",fill:"none"},t);it(d,Qe.HIDDEN,!0),v(R.RECT,{x:19.7782,y:2.80762,width:2,height:24,transform:"rotate(45, 19.7782, 2.80762)",fill:"black"},d),v(R.RECT,{x:2.80762,y:4.22183,width:2,height:24,transform:"rotate(-45, 2.80762, 4.22183)",fill:"black"},d),t.addEventListener("click",()=>{n.remove(),e.markFocused()});let f;return t=()=>{f=setTimeout(()=>n.remove(),s*1e3)},d=()=>clearTimeout(f),n.addEventListener("focusin",d),n.addEventListener("focusout",t),n.addEventListener("mouseenter",d),n.addEventListener("mousemove",d),n.addEventListener("mouseleave",t),t(),n}static hide(e,t){e=e.getInjectionDiv().querySelector(`.${ar}`),e instanceof HTMLElement&&(!t||t===e.dataset.toastId)&&e.remove()}};ws.shownIds=new Set,(function(e){e=e.Assertiveness||(e.Assertiveness={}),e.ASSERTIVE="assertive",e.POLITE="polite"})(ws||(ws={})),q(`
474
- .${ar} {
473
+ `);var $g=100,pg=75,gg=50,mg=25,Tb={BLOCKS:gg,PROCEDURES:pg,VARIABLES:$g,WORKSPACE_COMMENTS:mg},fa={};fa.register=Fi,fa.unregister=yd;var fg=class{constructor(){this.priority=mg}save(e){const t=[];for(const o of e.getTopComments())(e=js(o,{addCoordinates:!0,saveIds:!0}))&&t.push(e);return t.length?t:null}load(e,t){for(const o of e)Ui(o,t,{recordUndo:Ue()})}clear(e){for(const t of e.getTopComments())t.dispose()}};Fi("workspaceComments",new fg);var Hn={};Hn.WorkspaceCommentSerializer=fg,Hn.append=Ui,Hn.save=js;var _a={};_a.register=Yr,_a.unregister=vd;var Gn=class{paste(e,t,o){e=e.commentState,o&&(e.x=o.x,e.y=o.y),r.disable$$module$build$src$core$events$utils();let s;try{s=Ui(e,t),Id(s)}finally{r.enable$$module$build$src$core$events$utils()}return s?(J()&&_(new(U(w.COMMENT_CREATE))(s)),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(s),s):null}};Gn.TYPE="workspace-comment",Yr(Gn.TYPE,new Gn);var ba;ba=28,r.config$$module$build$src$core$config={dragRadius:5,flyoutDragRadius:10,snapRadius:ba,connectingSnapRadius:ba,currentConnectionPreference:8,bumpDelay:250},r.config$$module$build$src$core$config;var Eb="aria-",yb="role",Gt;(function(e){e.GRID="grid",e.GRIDCELL="gridcell",e.GROUP="group",e.LISTBOX="listbox",e.MENU="menu",e.MENUITEM="menuitem",e.MENUITEMCHECKBOX="menuitemcheckbox",e.OPTION="option",e.PRESENTATION="presentation",e.ROW="row",e.TREE="tree",e.TREEITEM="treeitem",e.SEPARATOR="separator",e.STATUS="status"})(Gt||(Gt={}));var Qe;(function(e){e.ACTIVEDESCENDANT="activedescendant",e.COLCOUNT="colcount",e.DISABLED="disabled",e.EXPANDED="expanded",e.INVALID="invalid",e.LABEL="label",e.LABELLEDBY="labelledby",e.LEVEL="level",e.ORIENTATION="orientation",e.POSINSET="posinset",e.ROWCOUNT="rowcount",e.SELECTED="selected",e.SETSIZE="setsize",e.VALUEMAX="valuemax",e.VALUEMIN="valuemin",e.LIVE="live",e.HIDDEN="hidden"})(Qe||(Qe={}));var ur={};ur.Role=Gt,ur.State=Qe,ur.setRole=po,ur.setState=it;var Vn=class{constructor(e,t){this.content=e,this.opt_value=t,this.enabled=!0,this.element=null,this.rightToLeft=!1,this.roleName=null,this.highlight=this.checked=this.checkable=!1,this.actionHandler=null}createDom(){const e=document.createElement("div");e.id=Re(),this.element=e,e.className="blocklyMenuItem "+(this.enabled?"":"blocklyMenuItemDisabled ")+(this.checked?"blocklyMenuItemSelected ":"")+(this.highlight?"blocklyMenuItemHighlight ":"")+(this.rightToLeft?"blocklyMenuItemRtl ":"");const t=document.createElement("div");if(t.className="blocklyMenuItemContent",this.checkable){var o=document.createElement("div");o.className="blocklyMenuItemCheckbox ",t.appendChild(o)}return o=this.content,typeof this.content=="string"&&(o=document.createTextNode(this.content)),t.appendChild(o),e.appendChild(t),this.roleName&&po(e,this.roleName),it(e,Qe.SELECTED,this.checkable&&this.checked||!1),it(e,Qe.DISABLED,!this.enabled),e}dispose(){this.element=null}getElement(){return this.element}getId(){return this.element.id}getValue(){let e;return(e=this.opt_value)!=null?e:null}setRightToLeft(e){this.rightToLeft=e}setRole(e){this.roleName=e}setCheckable(e){this.checkable=e}setChecked(e){this.checked=e}setHighlighted(e){this.highlight=e;const t=this.getElement();t&&this.isEnabled()&&(e?G(t,"blocklyMenuItemHighlight"):Te(t,"blocklyMenuItemHighlight"))}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}performAction(e){this.isEnabled()&&this.actionHandler&&this.actionHandler(this,e)}onAction(e,t){this.actionHandler=e.bind(t)}},Ta=class{constructor(){this.menuItems=[],this.roleName=this.element=this.onKeyDownHandler=this.pointerLeaveHandler=this.pointerEnterHandler=this.clickHandler=this.pointerMoveHandler=this.highlightedItem=this.openingCoords=null}addChild(e){this.menuItems.push(e)}render(e){const t=document.createElement("div");t.className="blocklyMenu",t.tabIndex=0,this.roleName&&po(t,this.roleName),this.element=t;for(let o=0,s;s=this.menuItems[o];o++)t.appendChild(s.createDom());return this.pointerMoveHandler=z(t,"pointermove",this,this.handlePointerMove,!0),this.clickHandler=z(t,"pointerup",this,this.handleClick,!0),this.pointerEnterHandler=z(t,"pointerenter",this,this.handlePointerEnter,!0),this.pointerLeaveHandler=z(t,"pointerleave",this,this.handlePointerLeave,!0),this.onKeyDownHandler=z(t,"keydown",this,this.handleKeyEvent),e.appendChild(t),t}getElement(){return this.element}focus(){const e=this.getElement();e&&e.focus({preventScroll:!0})}blur(){const e=this.getElement();e&&e.blur()}setRole(e){this.roleName=e}dispose(){this.pointerMoveHandler&&(te(this.pointerMoveHandler),this.pointerMoveHandler=null),this.clickHandler&&(te(this.clickHandler),this.clickHandler=null),this.pointerEnterHandler&&(te(this.pointerEnterHandler),this.pointerEnterHandler=null),this.pointerLeaveHandler&&(te(this.pointerLeaveHandler),this.pointerLeaveHandler=null),this.onKeyDownHandler&&(te(this.onKeyDownHandler),this.onKeyDownHandler=null);for(let e=0,t;t=this.menuItems[e];e++)t.dispose();this.element=null}getMenuItem(e){const t=this.getElement();for(;e&&e!==t;){if(e.classList.contains("blocklyMenuItem")){const o=this.getMenuItems();for(let s=0,i;i=o[s];s++)if(i.getElement()===e)return i}e=e.parentElement}return null}setHighlighted(e){var t=this.highlightedItem;if(t&&(t.setHighlighted(!1),this.highlightedItem=null),e){e.setHighlighted(!0),this.highlightedItem=e,t=this.getElement();const o=e.getElement();t&&o&&(Jl(o,t),it(t,Qe.ACTIVEDESCENDANT,e.getId()))}}highlightNext(){const e=this.highlightedItem?this.menuItems.indexOf(this.highlightedItem):-1;this.highlightHelper(e,1)}highlightPrevious(){const e=this.highlightedItem?this.menuItems.indexOf(this.highlightedItem):-1;this.highlightHelper(e<0?this.menuItems.length:e,-1)}highlightFirst(){this.highlightHelper(-1,1)}highlightLast(){this.highlightHelper(this.menuItems.length,-1)}highlightHelper(e,t){e+=t;let o;const s=this.getMenuItems();for(;o=s[e];){if(o.isEnabled()){this.setHighlighted(o);break}e+=t}}handlePointerMove(e){Math.max(Math.abs(e.movementX),Math.abs(e.movementY))!==0&&(e=this.getMenuItem(e.target))&&(e.isEnabled()?this.highlightedItem!==e&&this.setHighlighted(e):this.setHighlighted(null))}handleClick(e){var t=this.openingCoords;if(this.openingCoords=null,t&&typeof e.clientX=="number"){const o=new P(e.clientX,e.clientY);if(P.distance(t,o)<1)return}(t=this.getMenuItem(e.target))&&t.performAction(e)}handlePointerEnter(e){this.focus()}handlePointerLeave(e){this.getElement()&&this.setHighlighted(null)}handleKeyEvent(e){if(this.menuItems.length&&!(e.shiftKey||e.ctrlKey||e.metaKey||e.altKey)){var t=this.highlightedItem;switch(e.key){case"Enter":case" ":t&&t.performAction(e);break;case"ArrowUp":this.highlightPrevious();break;case"ArrowDown":this.highlightNext();break;case"PageUp":case"Home":this.highlightFirst();break;case"PageDown":case"End":this.highlightLast();break;default:return}e.preventDefault(),e.stopPropagation()}}getSize(){const e=this.getElement(),t=Rt(e);return t.height=e.scrollHeight,t}getMenuItems(){return this.menuItems.filter(e=>e instanceof Vn)}},_g=class{constructor(){this.element=null}createDom(){return this.element=document.createElement("hr"),this.element.className="blocklyMenuSeparator",po(this.element,Gt.SEPARATOR),this.element}dispose(){let e;(e=this.element)==null||e.remove(),this.element=null}},ar="_TEMP_COLLAPSED_INPUT",Wn="_TEMP_COLLAPSED_FIELD",Jt="MANUALLY_DISABLED",vb={COLLAPSED_FIELD_NAME:Wn,COLLAPSED_INPUT_NAME:ar,MANUALLY_DISABLED:Jt};(function(e){e[e.VALUE=1]="VALUE",e[e.STATEMENT=3]="STATEMENT",e[e.DUMMY=5]="DUMMY",e[e.CUSTOM=6]="CUSTOM",e[e.END_ROW=7]="END_ROW"})(r.inputTypes$$module$build$src$core$inputs$input_types||(r.inputTypes$$module$build$src$core$inputs$input_types={})),r.inputTypes$$module$build$src$core$inputs$input_types;var zn=new Set,Ea=new WeakSet,ya=new WeakMap,pi=null,va=null,bg=0,Yn={};Yn.finishQueuedRenders=go,Yn.queueRender=sc,Yn.triggerQueuedRenders=Qo;var Ia,Tg;r.Msg$$module$build$src$core$msg=Object.create(null),Ia=function(e){Object.keys(e).forEach(function(t){r.Msg$$module$build$src$core$msg[t]=e[t]})},Tg={Msg:r.Msg$$module$build$src$core$msg,setLocale:Ia};var hr="blocklyToast",Eg="blocklyToastMessage",yg="blocklyToastCloseButton",ws=class{static show(e,t){if(t.oncePerSession&&t.id){if(this.shownIds.has(t.id))return;this.shownIds.add(t.id)}this.hide(e);const o=this.createDom(e,t);requestAnimationFrame(()=>{o.style.bottom="2rem"})}static createDom(e,t){const{message:o,duration:s=5,assertiveness:i=ws.Assertiveness.POLITE}=t,n=document.createElement("div");e.getInjectionDiv().appendChild(n),n.dataset.toastId=t.id,n.className=hr,po(n,Gt.STATUS),it(n,Qe.LIVE,i),t=n.appendChild(document.createElement("div")),t.className=Eg,t.innerText=o,t=n.appendChild(document.createElement("button")),t.className=yg,it(t,Qe.LABEL,r.Msg$$module$build$src$core$msg.CLOSE);var d=v(R.SVG,{width:24,height:24,viewBox:"0 0 24 24",fill:"none"},t);it(d,Qe.HIDDEN,!0),v(R.RECT,{x:19.7782,y:2.80762,width:2,height:24,transform:"rotate(45, 19.7782, 2.80762)",fill:"black"},d),v(R.RECT,{x:2.80762,y:4.22183,width:2,height:24,transform:"rotate(-45, 2.80762, 4.22183)",fill:"black"},d),t.addEventListener("click",()=>{n.remove(),e.markFocused()});let f;return t=()=>{f=setTimeout(()=>n.remove(),s*1e3)},d=()=>clearTimeout(f),n.addEventListener("focusin",d),n.addEventListener("focusout",t),n.addEventListener("mouseenter",d),n.addEventListener("mousemove",d),n.addEventListener("mouseleave",t),t(),n}static hide(e,t){e=e.getInjectionDiv().querySelector(`.${hr}`),e instanceof HTMLElement&&(!t||t===e.dataset.toastId)&&e.remove()}};ws.shownIds=new Set,(function(e){e=e.Assertiveness||(e.Assertiveness={}),e.ASSERTIVE="assertive",e.POLITE="polite"})(ws||(ws={})),q(`
474
+ .${hr} {
475
475
  font-size: 1.2rem;
476
476
  position: absolute;
477
477
  bottom: -10rem;
@@ -489,11 +489,11 @@ input[type=number] {
489
489
  transition: bottom 0.3s ease-out;
490
490
  }
491
491
 
492
- .${ar} .${_g} {
492
+ .${hr} .${Eg} {
493
493
  maxWidth: 18rem;
494
494
  }
495
495
 
496
- .${ar} .${bg} {
496
+ .${hr} .${yg} {
497
497
  margin: 0;
498
498
  padding: 0.2rem;
499
499
  background-color: transparent;
@@ -501,11 +501,11 @@ input[type=number] {
501
501
  border: none;
502
502
  cursor: pointer;
503
503
  }
504
- `);var Tg=function(e,t){window.alert(e),t&&t()},Eg=Tg,yg=function(e,t){t(window.confirm(e))},vg=yg,Ig=function(e,t,o){o(window.prompt(e,t))},Cg=Ig,Sg=ws.show.bind(ws),kg=Sg,Vo={};Vo.alert=Hi,Vo.confirm=Xr,Vo.prompt=jr,Vo.setAlert=Cd,Vo.setConfirm=Sd,Vo.setPrompt=kd,Vo.setToast=wd,Vo.toast=Rd;var Rg=new Set,wg={};wg.warn=pt;var va="VARIABLE",Ia="ijkmnopqrstuvwxyzabcdefgh",Og={generateUniqueNameInternal:Ad},et={CATEGORY_NAME:va,TEST_ONLY:Og,VAR_LETTER_OPTIONS:Ia};et.allDeveloperVariables=r.allDeveloperVariables$$module$build$src$core$variables,et.allUsedVarModels=r.allUsedVarModels$$module$build$src$core$variables,et.compareByName=Js,et.createVariableButtonHandler=_s,et.deleteVariable=r.deleteVariable$$module$build$src$core$variables,et.flyoutCategory=nc,et.flyoutCategoryBlocks=lc,et.generateUniqueName=cc,et.generateUniqueNameFromOptions=Zr,et.generateVariableFieldDom=bs,et.getAddedVariables=Gi,et.getOrCreateVariablePackage=r.getOrCreateVariablePackage$$module$build$src$core$variables,et.getVariable=r.getVariable$$module$build$src$core$variables,et.getVariableUsesById=qs,et.internalFlyoutCategory=Kr,et.jsonFlyoutCategoryBlocks=qr,et.nameUsedWithAnyType=uc,et.nameUsedWithConflictingParam=ac,et.promptName=Qr,et.renameVariable=r.renameVariable$$module$build$src$core$variables;var gi=class extends Error{},Ng=class extends gi{constructor(e){super("Expected to find a 'type' property, defining the block type"),this.state=e}},hr=class extends gi{constructor(e,t,o){super(`The block ${t.toDevString()} is missing a(n) ${e}
505
- connection`),this.block=t,this.state=o}},Ag=class extends gi{constructor(e,t,o,s){super(`The block ${o.toDevString()} could not connect its
506
- ${t} to its parent, because: ${e}`),this.childBlock=o,this.childState=s}},Lg=class extends gi{constructor(e){super(`Encountered a real block which is defined as a child of a shadow
504
+ `);var vg=function(e,t){window.alert(e),t&&t()},Ig=vg,Cg=function(e,t){t(window.confirm(e))},Sg=Cg,kg=function(e,t,o){o(window.prompt(e,t))},Rg=kg,wg=ws.show.bind(ws),Og=wg,Vo={};Vo.alert=Gi,Vo.confirm=jr,Vo.prompt=Kr,Vo.setAlert=Rd,Vo.setConfirm=wd,Vo.setPrompt=Od,Vo.setToast=Ad,Vo.toast=Nd;var Ng=new Set,Ag={};Ag.warn=pt;var Ca="VARIABLE",Sa="ijkmnopqrstuvwxyzabcdefgh",Lg={generateUniqueNameInternal:Dd},et={CATEGORY_NAME:Ca,TEST_ONLY:Lg,VAR_LETTER_OPTIONS:Sa};et.allDeveloperVariables=r.allDeveloperVariables$$module$build$src$core$variables,et.allUsedVarModels=r.allUsedVarModels$$module$build$src$core$variables,et.compareByName=Js,et.createVariableButtonHandler=_s,et.deleteVariable=r.deleteVariable$$module$build$src$core$variables,et.flyoutCategory=cc,et.flyoutCategoryBlocks=uc,et.generateUniqueName=ac,et.generateUniqueNameFromOptions=Qr,et.generateVariableFieldDom=bs,et.getAddedVariables=Vi,et.getOrCreateVariablePackage=r.getOrCreateVariablePackage$$module$build$src$core$variables,et.getVariable=r.getVariable$$module$build$src$core$variables,et.getVariableUsesById=qs,et.internalFlyoutCategory=Jr,et.jsonFlyoutCategoryBlocks=Zr,et.nameUsedWithAnyType=hc,et.nameUsedWithConflictingParam=dc,et.promptName=en,et.renameVariable=r.renameVariable$$module$build$src$core$variables;var gi=class extends Error{},Mg=class extends gi{constructor(e){super("Expected to find a 'type' property, defining the block type"),this.state=e}},dr=class extends gi{constructor(e,t,o){super(`The block ${t.toDevString()} is missing a(n) ${e}
505
+ connection`),this.block=t,this.state=o}},Dg=class extends gi{constructor(e,t,o,s){super(`The block ${o.toDevString()} could not connect its
506
+ ${t} to its parent, because: ${e}`),this.childBlock=o,this.childState=s}},xg=class extends gi{constructor(e){super(`Encountered a real block which is defined as a child of a shadow
507
507
  block. It is an invariant of Blockly that shadow blocks only have shadow
508
- children`),this.state=e}},Mg=class extends gi{constructor(e,t,o){super(`Cannot add an icon of type '${e}' to the block ${t.toDevString()}, because there is no icon registered with type '${e}'. Make sure that all of your icons have been registered.`),this.block=t,this.state=o}},Os={};Os.BadConnectionCheck=Ag,Os.DeserializationError=gi,Os.MissingBlockType=Ng,Os.MissingConnection=hr,Os.RealChildOfShadow=Lg,Os.UnregisteredIcon=Mg;var Dg=class{constructor(){this.priority=dg}save(e){const t=[];for(const o of e.getTopBlocks(!1))(e=jt(o,{addCoordinates:!0,doFullSerialization:!1}))&&t.push(e);return t.length?{languageVersion:0,blocks:t}:null}load(e,t){e=e.blocks;for(const o of e)es(o,t,{recordUndo:Ue()})}clear(e){for(const t of e.getTopBlocks(!1))t.dispose(!1)}};Pi("blocks",new Dg);var dr={};dr.BlockSerializer=Dg,dr.append=es,dr.appendInternal=Zs,dr.save=jt;var ut=class{constructor(e){this.name=e}toString(){return this.name}equals(e){return this.name===e.toString()}};ut.MUTATOR=new ut("mutator"),ut.WARNING=new ut("warning"),ut.COMMENT=new ut("comment");var Ns=class extends hi{constructor(e){super(),this.isBlank=!e,e&&(this.blockId=e.id,this.workspaceId=e.workspace.id)}toJson(){const e=super.toJson();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");return e.blockId=this.blockId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ns),t.blockId=e.blockId,t}},As=class extends Ns{constructor(e,t,o,s,i){super(e),this.type=w.BLOCK_CHANGE,e&&(this.element=t,this.name=o||void 0,this.oldValue=s,this.newValue=i)}toJson(){const e=super.toJson();if(!this.element)throw Error("The changed element is undefined. Either pass an element to the constructor, or call fromJson");return e.element=this.element,e.name=this.name,e.oldValue=this.oldValue,e.newValue=this.newValue,this.disabledReason&&(e.disabledReason=this.disabledReason),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new As),t.element=e.element,t.name=e.name,t.oldValue=e.oldValue,t.newValue=e.newValue,e.disabledReason!==void 0&&(t.disabledReason=e.disabledReason),t}setDisabledReason(e){if(this.element!=="disabled")throw Error('Cannot set the disabled reason for a BlockChange event if the element is not "disabled".');this.disabledReason=e}isNull(){return this.oldValue===this.newValue}run(e){var t=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");if(t=t.getBlockById(this.blockId),!t)throw Error("The associated block is undefined. Either pass a block to the constructor, or call fromJson");const o=t.getIcon(ut.MUTATOR);switch(o&&Ts(o)&&o.bubbleIsVisible()&&o.setBubbleVisible(!1),e=e?this.newValue:this.oldValue,this.element){case"field":(t=t.getField(this.name))?t.setValue(e):console.warn("Can't set non-existent field: "+this.name);break;case"comment":t.setCommentText(e||null);break;case"collapsed":t.setCollapsed(!!e);break;case"disabled":var s;t.setDisabledReason(!!e,(s=this.disabledReason)!=null?s:Jt);break;case"inline":t.setInputsInline(!!e);break;case"mutation":s=As.getExtraBlockState_(t),t.loadExtraState?t.loadExtraState(JSON.parse(e||"{}")):t.domToMutation&&t.domToMutation(r.textToDom$$module$build$src$core$utils$xml(e||"<mutation/>")),_(new As(t,"mutation",null,s,e));break;default:console.warn("Unknown change type: "+this.element)}}static getExtraBlockState_(e){return e.saveExtraState?(e=e.saveExtraState(!0))?JSON.stringify(e):"":e.mutationToDom&&(e=e.mutationToDom())?fo(e):""}};l(M.EVENT,w.BLOCK_CHANGE,As);var Yn={};Yn.clamp=Qs,Yn.toDegrees=e$,Yn.toRadians=en;var Xn=16,xg=1,Bg=12,Ca=16,jn=.25,Sa=null,Ls=null,Pg="",Fg="",Ke,$r,Ms,ka=null,cs=null,Ug=null,Kn=null,Jn=null,Ra={getBoundsInfo:function(){const e=Zo(ka),t=Rt(ka);return{left:e.x,right:e.x+t.width,top:e.y,bottom:e.y+t.height,width:t.width,height:t.height}},getPositionMetrics:function(e,t,o,s){const i=Ra.getBoundsInfo(),n=Rt(Ke);return t+n.height<i.bottom?yc(e,t,i,n):s-n.height>i.top?vc(o,s,i,n):t+n.height<document.documentElement.clientHeight?yc(e,t,i,n):s-n.height>document.documentElement.clientTop?vc(o,s,i,n):o$(e,i,n)}},wt={ANIMATION_TIME:jn,ARROW_HORIZONTAL_PADDING:Bg,ARROW_SIZE:Xn,BORDER_SIZE:xg,PADDING_Y:Ca,TEST_ONLY:Ra};wt.clearContent=sn,wt.createDom=tn,wt.getContentDiv=on,wt.getOwner=gc,wt.getPositionX=Vi,wt.hide=nn,wt.hideIfOwner=rn,wt.hideWithoutAnimation=mo,wt.isVisible=Ic,wt.repositionForWindowResize=Sc,wt.setBoundsElement=pc,wt.setColour=mc,wt.show=Ec,wt.showPositionedByBlock=t$,wt.showPositionedByField=fc;var mi={};mi.commonWordPrefix=kc,mi.commonWordSuffix=Rc,mi.isNumber=r.isNumber$$module$build$src$core$utils$string,mi.shortestStringLength=Wi,mi.wrap=r.wrap$$module$build$src$core$utils$string;var qn=void 0,pr=!1,fi=!1,Hg=50,Gg=0,Ds=0,wa=0,Oa=0,qt=null,gr=null,Na=0,Aa=10,Vg=10,Wg=750,Zn=5,at=null,Vt={HOVER_MS:Wg,LIMIT:Hg,MARGINS:Zn,OFFSET_X:Na,OFFSET_Y:Aa,RADIUS_OK:Vg};Vt.bindMouseEvents=zi,Vt.block=Dc,Vt.createDom=Nc,Vt.dispose=Mc,Vt.getCustomTooltip=n$,Vt.getDiv=c$,Vt.getTooltipOfObject=ei,Vt.hide=xo,Vt.isVisible=l$,Vt.setCustomTooltip=r$,Vt.unbindMouseEvents=Ac,Vt.unblock=xc;var La=.45,Ma=.65,zg={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00"},Zt={};Zt.blend=ys,Zt.getHsvSaturation=Bc,Zt.getHsvValue=Pc,Zt.hexToRgb=cn,Zt.hsvToHex=un,Zt.hueToHex=Fc,Zt.names=zg,Zt.parse=Es,Zt.rgbToHex=Yi,Zt.setHsvSaturation=g$,Zt.setHsvValue=m$;var mr={};mr.checkMessageReferences=f$,mr.parseBlockColour=ti,mr.replaceMessageReferences=Je,mr.tokenizeInterpolation=Uc;var we=class{get size_(){return this.size}set size_(e){this.size=e}constructor(e,t,o){this.DEFAULT_VALUE=null,this.name=void 0,this.tooltip=this.validator_=null,this.size=new ve(0,0),this.constants_=this.mouseDownWrapper=this.textContent_=this.textElement_=this.borderRect_=this.fieldGroup_=null,this.disposed=!1,this.maxDisplayLength=50,this.sourceBlock_=null,this.enabled_=this.visible_=this.isDirty_=!0,this.suffixField=this.prefixField=this.clickTarget_=null,this.EDITABLE=!0,this.SERIALIZABLE=!1,this.id_=null,this.value_="DEFAULT_VALUE"in new.target.prototype?new.target.prototype.DEFAULT_VALUE:this.DEFAULT_VALUE,this.size_=new ve(0,0),e!==we.SKIP_SETUP&&(o&&this.configure_(o),this.setValue(e),t&&this.setValidator(t))}configure_(e){e.tooltip&&this.setTooltip(Je(e.tooltip))}setSourceBlock(e){if(this.sourceBlock_)throw Error("Field already bound to a block");if(this.sourceBlock_=e,e.id.includes("_field"))throw Error(`Field ID indicator is contained in block ID. This may cause problems with focus: ${e.id}.`);this.id_=`${e.id}_field_${Re()}`}getConstants(){return!this.constants_&&this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()&&this.sourceBlock_.workspace.rendered&&(this.constants_=this.sourceBlock_.workspace.getRenderer().getConstants()),this.constants_}getSourceBlock(){return this.sourceBlock_}init(){if(!this.fieldGroup_){var e=this.id_;if(!e)throw Error("Expected ID to be defined prior to init.");this.fieldGroup_=v(R.G,{id:e}),this.isVisible()||(this.fieldGroup_.style.display="none"),this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_),this.initView(),this.updateEditable(),this.setTooltip(this.tooltip),this.bindEvents_(),this.initModel(),this.applyColour()}}initView(){this.createBorderRect_(),this.createTextElement_(),this.fieldGroup_&&G(this.fieldGroup_,"blocklyField")}initModel(){}isFullBlockField(){return!this.borderRect_}createBorderRect_(){this.borderRect_=v(R.RECT,{rx:this.getConstants().FIELD_BORDER_RECT_RADIUS,ry:this.getConstants().FIELD_BORDER_RECT_RADIUS,x:0,y:0,height:this.size_.height,width:this.size_.width,class:"blocklyFieldRect"},this.fieldGroup_)}createTextElement_(){this.textElement_=v(R.TEXT,{class:"blocklyText blocklyFieldText"},this.fieldGroup_),this.getConstants().FIELD_TEXT_BASELINE_CENTER&&this.textElement_.setAttribute("dominant-baseline","central"),this.textContent_=document.createTextNode(""),this.textElement_.appendChild(this.textContent_)}bindEvents_(){const e=this.getClickTarget_();if(!e)throw Error("A click target has not been set.");zi(e),this.mouseDownWrapper=z(e,"pointerdown",this,this.onMouseDown_)}fromXml(e){this.setValue(e.textContent)}toXml(e){return e.textContent=this.getValue(),e}saveState(e){return e=this.saveLegacyState(we),e!==null?e:this.getValue()}loadState(e){this.loadLegacyState(we,e)||this.setValue(e)}saveLegacyState(e){return e.prototype.saveState===this.saveState&&e.prototype.toXml!==this.toXml?(e=r.createElement$$module$build$src$core$utils$xml("field"),e.setAttribute("name",this.name||""),Xs(this.toXml(e)).replace(' xmlns="https://developers.google.com/blockly/xml"',"")):null}loadLegacyState(e,t){return e.prototype.loadState===this.loadState&&e.prototype.fromXml!==this.fromXml?(this.fromXml(r.textToDom$$module$build$src$core$utils$xml(t)),!0):!1}dispose(){rn(this),vs(this);let e;(e=this.getSourceBlock())!=null&&e.isDeadOrDying()||ke(this.fieldGroup_),this.disposed=!0}updateEditable(){const e=this.fieldGroup_,t=this.getSourceBlock();this.EDITABLE&&e&&t&&(this.enabled_&&t.isEditable()?(G(e,"blocklyEditableField"),Te(e,"blocklyNonEditableField")):(G(e,"blocklyNonEditableField"),Te(e,"blocklyEditableField")))}setEnabled(e){this.enabled_=e,this.updateEditable()}isEnabled(){return this.enabled_}isClickable(){return this.enabled_&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()&&this.showEditor_!==we.prototype.showEditor_}isClickableInFlyout(e){return!e}isCurrentlyEditable(){return this.enabled_&&this.EDITABLE&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()}isSerializable(){let e=!1;return this.name&&(this.SERIALIZABLE?e=!0:this.EDITABLE&&(console.warn("Detected an editable field that was not serializable. Please define SERIALIZABLE property as true on all editable custom fields. Proceeding with serialization."),e=!0)),e}isVisible(){return this.visible_}setVisible(e){if(this.visible_!==e){this.visible_=e;var t=this.fieldGroup_;t&&(t.style.display=e?"block":"none")}}setValidator(e){this.validator_=e}getValidator(){return this.validator_}getSvgRoot(){return this.fieldGroup_}getBorderRect(){if(!this.borderRect_)throw Error(`The border rectangle is ${this.borderRect_}.`);return this.borderRect_}getTextElement(){if(!this.textElement_)throw Error(`The text element is ${this.textElement_}.`);return this.textElement_}getTextContent(){if(!this.textContent_)throw Error(`The text content is ${this.textContent_}.`);return this.textContent_}applyColour(){}render_(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_()),this.updateSize_()}showEditor(e){this.isClickable()&&this.showEditor_(e)}showEditor_(e){}repositionForWindowResize(){return!1}updateSize_(e){const t=this.getConstants();e=e!==void 0?e:this.isFullBlockField()?0:this.getConstants().FIELD_BORDER_RECT_X_PADDING;let o=e*2,s=t.FIELD_TEXT_HEIGHT,i=0;this.textElement_&&(i=ot(this.textElement_),o+=i),this.isFullBlockField()||(s=Math.max(s,t.FIELD_BORDER_RECT_HEIGHT)),this.size_.height=s,this.size_.width=o,this.positionTextElement_(e,i),this.positionBorderRect_()}positionTextElement_(e,t){if(this.textElement_){var o=this.getConstants(),s=this.size_.height/2,i;this.textElement_.setAttribute("x",String((i=this.getSourceBlock())!=null&&i.RTL?this.size_.width-t-e:e)),this.textElement_.setAttribute("y",String(o.FIELD_TEXT_BASELINE_CENTER?s:s-o.FIELD_TEXT_HEIGHT/2+o.FIELD_TEXT_BASELINE))}}positionBorderRect_(){this.borderRect_&&(this.borderRect_.setAttribute("width",String(this.size_.width)),this.borderRect_.setAttribute("height",String(this.size_.height)),this.borderRect_.setAttribute("rx",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)),this.borderRect_.setAttribute("ry",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)))}getSize(){return this.isVisible()?(this.isDirty_&&(this.render_(),this.isDirty_=!1),this.size_):new ve(0,0)}getScaledBBox(){let e;var t=this.getSourceBlock();if(!t)throw new tt;if(this.isFullBlockField()){var o=this.sourceBlock_.getHeightWidth();const s=t.workspace.scale;e=this.getAbsoluteXY_(),t=(o.width+1)*s,o=(o.height+1)*s,Gp?(e.x+=1.5*s,e.y+=1.5*s):(e.x-=.5*s,e.y-=.5*s)}else o=this.borderRect_.getBoundingClientRect(),e=Zo(this.borderRect_),t=o.width,o=o.height;return new ye(e.y,e.y+o,e.x,e.x+t)}onLocationChange(e){}getDisplayText_(){let e=this.getText();return e.length>this.maxDisplayLength&&(e=e.substring(0,this.maxDisplayLength-2)+"…"),e=e.replace(/\s/g,we.NBSP),this.sourceBlock_&&this.sourceBlock_.RTL&&(e+="‏"),e}getText(){const e=this.getText_();return String(e!==null?e:this.getValue())}getText_(){return null}markDirty(){this.isDirty_=!0,this.constants_=null}forceRerender(){this.isDirty_=!0,this.sourceBlock_&&this.sourceBlock_.rendered&&this.sourceBlock_.queueRender()}setValue(e,t=!0){if(e!==null){var o=r.getGroup$$module$build$src$core$events$utils();o||r.setGroup$$module$build$src$core$events$utils(!0);try{const L=this.doClassValidation_(e),oe=this.processValidation(e,L,t);if(!(oe instanceof Error)){var s,i=(s=this.getValidator())==null?void 0:s.call(this,oe),n=this.processValidation(oe,i,t);if(!(n instanceof Error)){var d=this.sourceBlock_;if(!d||!d.disposed){var f=this.getValue();f===n?this.doValueUpdate_(n):(this.doValueUpdate_(n),t&&d&&J()&&_(new(U(w.BLOCK_CHANGE))(d,"field",this.name||null,f,n)),this.isDirty_&&this.forceRerender())}}}}finally{r.setGroup$$module$build$src$core$events$utils(o)}}}processValidation(e,t,o){return t===null?(this.doValueInvalid_(e,o),this.isDirty_&&this.forceRerender(),Error()):t===void 0?e:t}getValue(){return this.value_}doClassValidation_(e){return e??null}doValueUpdate_(e){this.value_=e,this.isDirty_=!0}doValueInvalid_(e,t){}onMouseDown_(e){this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()&&(e=this.sourceBlock_.workspace.getGesture(e))&&e.setStartField(this)}setTooltip(e){e||e===""||(e=this.sourceBlock_);const t=this.getClickTarget_();t?t.tooltip=e:this.tooltip=e}getTooltip(){const e=this.getClickTarget_();return ei(e||{tooltip:this.tooltip})}getClickTarget_(){return this.clickTarget_||this.getSvgRoot()}getAbsoluteXY_(){return Zo(this.getClickTarget_())}referencesVariables(){return!1}refreshVariableName(){}getParentInput(){let e=null;const t=this.getSourceBlock();if(!t)throw new tt;const o=t.inputList;for(let s=0;s<t.inputList.length;s++){const i=o[s],n=i.fieldRow;for(let d=0;d<n.length;d++)if(n[d]===this){e=i;break}}return e}getFlipRtl(){return!1}onShortcut(e){return!1}getFocusableElement(){if(!this.fieldGroup_)throw Error("This field currently has no representative DOM element.");return this.fieldGroup_}getFocusableTree(){const e=this.getSourceBlock();if(!e)throw new tt;return e.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}static fromJson(e){throw Error("Attempted to instantiate a field from the registry that hasn't defined a 'fromJson' method.")}};we.NBSP=" ",we.SKIP_SETUP=Symbol("SKIP_SETUP");var tt=class extends Error{constructor(){super("The field has not yet been attached to its input. Call appendField to attach it.")}},_i=null,Yg=null,Qn=null,Da="blocklyWidgetDiv",bi="",Ti="",Wt,el=null,lo={};lo.createDom=Hc,lo.getDiv=oi,lo.hide=si,lo.hideIfOwner=vs,lo.hideIfOwnerIsInWorkspace=Xi,lo.isVisible=Gc,lo.positionWithAnchor=Wc,lo.repositionForWindowResize=zc,lo.show=hn,lo.testOnly_setDiv=_$;var tl=null,Xg={},ol=null,xs={};xs.callbackFactory=r.callbackFactory$$module$build$src$core$contextmenu,xs.dispose=Xc,xs.getCurrentBlock=y$,xs.hide=ji,xs.setCurrentBlock=Yc,xs.show=ii;var Ee=class{constructor(){this.registeredItems=new Map,this.reset()}reset(){this.registeredItems.clear()}register(e){if(this.registeredItems.has(e.id))throw Error('Menu item with ID "'+e.id+'" is already registered.');this.registeredItems.set(e.id,e)}unregister(e){if(!this.registeredItems.has(e))throw Error('Menu item with ID "'+e+'" not found.');this.registeredItems.delete(e)}getItem(e){let t;return(t=this.registeredItems.get(e))!=null?t:null}getContextMenuOptions(e,t){const o=[];for(const s of this.registeredItems.values()){if(s.scopeType&&(s.scopeType===xa.BLOCK&&!e.block||s.scopeType===xa.COMMENT&&!e.comment||s.scopeType===xa.WORKSPACE&&!e.workspace))continue;let i;if(i={scope:e,weight:s.weight},s.separator)i=Object.assign({},i,{separator:!0});else{const n=s.preconditionFn(e,t);if(n==="hidden")continue;const d=typeof s.displayText=="function"?s.displayText(e):s.displayText;i=Object.assign({},i,{text:d,callback:s.callback,enabled:n==="enabled"})}o.push(i)}return o.sort(function(s,i){return s.weight-i.weight}),o}};(function(e){var t=e.ScopeType||(e.ScopeType={});t.BLOCK="block",t.WORKSPACE="workspace",t.COMMENT="comment",e.registry=new e})(Ee||(Ee={}));var xa=Ee.ScopeType,us=50,sl=100,Eb={BLOCK:us,BUBBLE:sl},jg=class{constructor(e){this.comment=e,this.startLoc=null,this.workspace=e.workspace}isMovable(){return this.comment.isOwnMovable()&&!this.comment.isDeadOrDying()&&!this.workspace.isReadOnly()}startDrag(){this.fireDragStartEvent(),this.startLoc=this.comment.getRelativeToSurfaceXY(),this.workspace.setResizesEnabled(!1);let e;(e=this.workspace.getLayerManager())==null||e.moveToDragLayer(this.comment),this.comment.setDragging(!0)}drag(e){this.comment.moveDuringDrag(e)}endDrag(){this.fireDragEndEvent(),this.fireMoveEvent();let e;(e=this.workspace.getLayerManager())==null||e.moveOffDragLayer(this.comment,us),this.comment.setDragging(!1),this.comment.snapToGrid(),this.workspace.setResizesEnabled(!0)}fireDragStartEvent(){const e=new(U(w.COMMENT_DRAG))(this.comment,!0);_(e)}fireDragEndEvent(){const e=new(U(w.COMMENT_DRAG))(this.comment,!1);_(e)}fireMoveEvent(){if(!this.comment.isDeadOrDying()){var e=new(U(w.COMMENT_MOVE))(this.comment);e.setReason(["drag"]),e.oldCoordinate_=this.startLoc,e.recordNew(),_(e)}}revertDrag(){this.startLoc&&this.comment.moveDuringDrag(this.startLoc)}},Kg=new WeakMap,il=class{constructor(e,t,o){this.id=e,this.workspace=t,this.container=o}isVisible(){return this.icon.checkVisibility()}getParentComment(){const e=this.workspace.getCommentById(this.id);if(!e)throw Error(`Comment bar button ${this.id} has no corresponding comment`);return e}getSize(e=!1){var t=this.icon.getBBox();return t=ye.from(t),e&&(e=this.getMargin(),t.left-=e,t.top-=e,t.bottom+=e,t.right+=e),t}getMargin(){return(this.container.getBBox().height-this.icon.getBBox().height)/2}getFocusableElement(){return this.icon}getFocusableTree(){return this.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return this.isVisible()}},Jg="_collapse_bar_button",qg=class extends il{constructor(e,t,o){super(e,t,o),this.id=e,this.workspace=t,this.container=o,this.icon=v(R.IMAGE,{class:"blocklyFoldoutIcon",href:`${this.workspace.options.pathToMedia}foldout-icon.svg`,id:`${this.id}${Jg}`},this.container),this.bindId=z(this.icon,"pointerdown",this,this.performAction.bind(this))}dispose(){te(this.bindId)}reposition(){const e=this.getMargin();this.icon.setAttribute("y",`${e}`),this.icon.setAttribute("x",`${e}`)}performAction(e){ie();const t=this.getParentComment();t.view.bringToFront(),e&&e instanceof PointerEvent&&Ie(e)?e.stopPropagation():(t.setCollapsed(!t.isCollapsed()),this.workspace.hideChaff(),e?.stopPropagation())}},Ba="_comment_textarea_",Zg=class{constructor(e,t,o){this.workspace=e,this.onFinishEditing=o,this.textChangeListeners=[],this.text="",this.foreignObject=v(R.FOREIGNOBJECT,{class:"blocklyCommentForeignObject"}),e=document.createElementNS(To,"body"),e.setAttribute("xmlns",To),e.className="blocklyMinimalBody",this.textArea=document.createElementNS(To,"textarea"),this.textArea.setAttribute("tabindex","-1"),G(this.textArea,"blocklyCommentText"),G(this.textArea,"blocklyTextarea"),G(this.textArea,"blocklyText"),e.appendChild(this.textArea),this.foreignObject.appendChild(e),t&&(this.id=t+Ba,this.textArea.setAttribute("id",this.id)),z(this.textArea,"change",this,this.onTextChange),z(this.textArea,"pointerdown",this,s=>{s.stopPropagation(),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this),ie()}),z(this.textArea,"keydown",this,this.handleKeyDown)}getDom(){return this.foreignObject}getText(){return this.text}setText(e){this.textArea.value=e,this.onTextChange()}onTextChange(){const e=this.text;this.text=this.textArea.value;for(let t=this.textChangeListeners.length-1;t>=0;t--)this.textChangeListeners[t](e,this.text)}handleKeyDown(e){(e.key==="Escape"||e.key==="Enter"&&(e.ctrlKey||e.metaKey))&&(this.onFinishEditing&&this.onFinishEditing(),e.stopPropagation())}addTextChangeListener(e){this.textChangeListeners.push(e)}removeTextChangeListener(e){this.textChangeListeners.splice(this.textChangeListeners.indexOf(e),1)}setPlaceholderText(e){this.textArea.placeholder=e}setEditable(e){e?this.textArea.removeAttribute("readonly"):this.textArea.setAttribute("readonly","true")}updateSize(e,t){this.foreignObject.setAttribute("height",`${e.height-t.height}`),this.foreignObject.setAttribute("width",`${e.width}`),this.foreignObject.setAttribute("y",`${t.height}`),this.workspace.RTL&&this.foreignObject.setAttribute("x",`${-e.width}`)}getFocusableElement(){return this.textArea}getFocusableTree(){return this.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!!this.id}},Qg="_delete_bar_button",em=class extends il{constructor(e,t,o){super(e,t,o),this.id=e,this.workspace=t,this.container=o,this.icon=v(R.IMAGE,{class:"blocklyDeleteIcon",href:`${this.workspace.options.pathToMedia}delete-icon.svg`,id:`${this.id}${Qg}`},o),this.bindId=z(this.icon,"pointerdown",this,this.performAction.bind(this))}dispose(){te(this.bindId)}reposition(){const e=this.getMargin();this.icon.setAttribute("x","0");const t=this.container.getBBox();this.icon.setAttribute("y",`${e}`),this.icon.setAttribute("x",`${t.width-this.getSize(!0).getWidth()}`)}performAction(e){ie(),e&&e instanceof PointerEvent&&Ie(e)?e.stopPropagation():(this.getParentComment().dispose(),e?.stopPropagation(),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.workspace))}},fr=class{constructor(e,t){this.workspace=e,this.commentId=t,this.collapsed=!1,this.editable=!0,this.location=new P(0,0),this.sizeChangeListeners=[],this.disposeListeners=[],this.collapseChangeListeners=[],this.resizePointerMoveListener=this.resizePointerUpListener=null,this.disposed=this.disposing=!1,this.svgRoot=v(R.G,{class:"blocklyComment blocklyEditable blocklyDraggable"}),this.highlightRect=this.createHighlightRect(this.svgRoot),{topBarGroup:this.topBarGroup,topBarBackground:this.topBarBackground,deleteButton:this.deleteButton,foldoutButton:this.foldoutButton,textPreview:this.textPreview,textPreviewNode:this.textPreviewNode}=this.createTopBar(this.svgRoot),this.commentEditor=this.createTextArea(),this.resizeHandle=this.createResizeHandle(this.svgRoot,e);let o;(o=e.getLayerManager())==null||o.append(this,us),this.size=fr.defaultCommentSize,this.setSizeWithoutFiringEvents(this.size),this.moveTo(new P(0,0))}createHighlightRect(e){return v(R.RECT,{class:"blocklyCommentHighlight"},e)}createTopBar(e){e=v(R.G,{class:"blocklyCommentTopbar"},e);const t=v(R.RECT,{class:"blocklyCommentTopbarBackground"},e),o=new em(this.commentId,this.workspace,e),s=new qg(this.commentId,this.workspace,e),i=v(R.TEXT,{class:"blocklyCommentPreview blocklyCommentText blocklyText"},e),n=document.createTextNode("");return i.appendChild(n),{topBarGroup:e,topBarBackground:t,deleteButton:o,foldoutButton:s,textPreview:i,textPreviewNode:n}}createTextArea(){const e=new Zg(this.workspace,this.commentId,()=>this.svgRoot.focus());return this.svgRoot.appendChild(e.getDom()),e.addTextChangeListener((t,o)=>{this.updateTextPreview(o),this.setSize(this.size)}),e}getEditorFocusableNode(){return this.commentEditor}createResizeHandle(e,t){return e=v(R.IMAGE,{class:"blocklyResizeHandle",href:`${t.options.pathToMedia}resize-handle.svg`},e),z(e,"pointerdown",this,this.onResizePointerDown),e}getSvgRoot(){return this.svgRoot}getSize(){return this.collapsed?this.topBarBackground.getBBox():this.size}setSizeWithoutFiringEvents(e){const t=this.topBarBackground.getBBox(),o=this.textPreview.getBBox(),s=this.resizeHandle.getBBox();this.size=e=ve.max(e,this.calcMinSize(t)),this.svgRoot.setAttribute("height",`${e.height}`),this.svgRoot.setAttribute("width",`${e.width}`),this.updateHighlightRect(e),this.updateTopBarSize(e),this.commentEditor.updateSize(e,t),this.deleteButton.reposition(),this.foldoutButton.reposition(),this.updateTextPreviewSize(e,t,o),this.updateResizeHandlePosition(e,s)}setSize(e){const t=this.preResizeSize||this.size;this.setSizeWithoutFiringEvents(e),this.onSizeChange(t,this.size)}calcMinSize(e){var t;this.updateTextPreview((t=this.commentEditor.getText())!=null?t:"");let o=t=ot(this.textPreview);return this.foldoutButton.isVisible()?o+=this.foldoutButton.getSize(!0).getWidth():t&&(o+=4),this.deleteButton.isVisible()?o+=this.deleteButton.getSize(!0).getWidth():t&&(o+=4),new ve(o,e.height+20)}updateHighlightRect(e){this.highlightRect.setAttribute("height",`${e.height}`),this.highlightRect.setAttribute("width",`${e.width}`),this.workspace.RTL&&this.highlightRect.setAttribute("x",`${-e.width}`)}updateTopBarSize(e){this.topBarBackground.setAttribute("width",`${e.width}`)}updateTextPreviewSize(e,t,o){t=(t.height-o.height)/2;const s=this.foldoutButton.getSize(!0),i=this.deleteButton.getSize(!0);e=e.width-s.getWidth()-i.getWidth(),this.textPreview.setAttribute("x",`${s.getWidth()}`),this.textPreview.setAttribute("y",`${t+o.height/2}`),this.textPreview.setAttribute("width",`${e}`)}updateResizeHandlePosition(e,t){this.resizeHandle.setAttribute("y",`${e.height-t.height}`),this.resizeHandle.setAttribute("x",`${e.width-t.width}`)}onSizeChange(e,t){for(let o=this.sizeChangeListeners.length-1;o>=0;o--)this.sizeChangeListeners[o](e,t)}addSizeChangeListener(e){this.sizeChangeListeners.push(e)}removeSizeChangeListener(e){this.sizeChangeListeners.splice(this.sizeChangeListeners.indexOf(e),1)}onResizePointerDown(e){this.isEditable()&&(this.bringToFront(),Ie(e)||(this.preResizeSize=this.getSize(),dn(this.workspace,e,new P(this.workspace.RTL?-this.getSize().width:this.getSize().width,this.getSize().height)),this.resizePointerUpListener=z(document,"pointerup",this,this.onResizePointerUp),this.resizePointerMoveListener=z(document,"pointermove",this,this.onResizePointerMove),this.workspace.hideChaff()),e.stopPropagation())}onResizePointerUp(e){ie(),this.resizePointerUpListener&&(te(this.resizePointerUpListener),this.resizePointerUpListener=null),this.resizePointerMoveListener&&(te(this.resizePointerMoveListener),this.resizePointerMoveListener=null),this.setSize(this.size),this.preResizeSize=void 0}onResizePointerMove(e){e=$n(this.workspace,e),this.setSizeWithoutFiringEvents(new ve(this.workspace.RTL?-e.x:e.x,e.y))}isCollapsed(){return this.collapsed}setCollapsed(e){(this.collapsed=e)?G(this.svgRoot,"blocklyCollapsed"):Te(this.svgRoot,"blocklyCollapsed"),this.setSizeWithoutFiringEvents(this.size),this.onCollapse()}onCollapse(){for(let e=this.collapseChangeListeners.length-1;e>=0;e--)this.collapseChangeListeners[e](this.collapsed)}addOnCollapseListener(e){this.collapseChangeListeners.push(e)}removeOnCollapseListener(e){this.collapseChangeListeners.splice(this.collapseChangeListeners.indexOf(e),1)}isEditable(){return this.editable}setEditable(e){(this.editable=e)?(G(this.svgRoot,"blocklyEditable"),Te(this.svgRoot,"blocklyReadonly")):(Te(this.svgRoot,"blocklyEditable"),G(this.svgRoot,"blocklyReadonly")),this.commentEditor.setEditable(e)}getRelativeToSurfaceXY(){return this.location}moveTo(e){this.location=e,this.svgRoot.setAttribute("transform",`translate(${e.x}, ${e.y})`)}getText(){return this.commentEditor.getText()}setText(e){this.commentEditor.setText(e)}setPlaceholderText(e){this.commentEditor.setPlaceholderText(e)}addTextChangeListener(e){this.commentEditor.addTextChangeListener(e)}removeTextChangeListener(e){this.commentEditor.removeTextChangeListener(e)}updateTextPreview(e){this.textPreviewNode.textContent=this.truncateText(e)}truncateText(e){return e.length>=12?`${e.substring(0,9)}...`:e}bringToFront(){const e=this.svgRoot.parentNode,t=e.childNodes;t[t.length-1]!==this.svgRoot&&e.appendChild(this.svgRoot)}onDeleteDown(e){ie(),Ie(e)||this.dispose(),e.stopPropagation()}dispose(){this.disposing=!0,this.foldoutButton.dispose(),this.deleteButton.dispose(),ke(this.svgRoot);for(let e=this.disposeListeners.length-1;e>=0;e--)this.disposeListeners[e]();this.disposed=!0}isDisposed(){return this.disposed}isDeadOrDying(){return this.disposing||this.disposed}addDisposeListener(e){this.disposeListeners.push(e)}removeDisposeListener(e){this.disposeListeners.splice(this.disposeListeners.indexOf(e),1)}getCommentBarButtons(){return[this.foldoutButton,this.deleteButton]}};fr.defaultCommentSize=new ve(120,100),q(`
508
+ children`),this.state=e}},Bg=class extends gi{constructor(e,t,o){super(`Cannot add an icon of type '${e}' to the block ${t.toDevString()}, because there is no icon registered with type '${e}'. Make sure that all of your icons have been registered.`),this.block=t,this.state=o}},Os={};Os.BadConnectionCheck=Dg,Os.DeserializationError=gi,Os.MissingBlockType=Mg,Os.MissingConnection=dr,Os.RealChildOfShadow=xg,Os.UnregisteredIcon=Bg;var Pg=class{constructor(){this.priority=gg}save(e){const t=[];for(const o of e.getTopBlocks(!1))(e=jt(o,{addCoordinates:!0,doFullSerialization:!1}))&&t.push(e);return t.length?{languageVersion:0,blocks:t}:null}load(e,t){e=e.blocks;for(const o of e)es(o,t,{recordUndo:Ue()})}clear(e){for(const t of e.getTopBlocks(!1))t.dispose(!1)}};Fi("blocks",new Pg);var $r={};$r.BlockSerializer=Pg,$r.append=es,$r.appendInternal=Zs,$r.save=jt;var ut=class{constructor(e){this.name=e}toString(){return this.name}equals(e){return this.name===e.toString()}};ut.MUTATOR=new ut("mutator"),ut.WARNING=new ut("warning"),ut.COMMENT=new ut("comment");var Ns=class extends hi{constructor(e){super(),this.isBlank=!e,e&&(this.blockId=e.id,this.workspaceId=e.workspace.id)}toJson(){const e=super.toJson();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");return e.blockId=this.blockId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ns),t.blockId=e.blockId,t}},As=class extends Ns{constructor(e,t,o,s,i){super(e),this.type=w.BLOCK_CHANGE,e&&(this.element=t,this.name=o||void 0,this.oldValue=s,this.newValue=i)}toJson(){const e=super.toJson();if(!this.element)throw Error("The changed element is undefined. Either pass an element to the constructor, or call fromJson");return e.element=this.element,e.name=this.name,e.oldValue=this.oldValue,e.newValue=this.newValue,this.disabledReason&&(e.disabledReason=this.disabledReason),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new As),t.element=e.element,t.name=e.name,t.oldValue=e.oldValue,t.newValue=e.newValue,e.disabledReason!==void 0&&(t.disabledReason=e.disabledReason),t}setDisabledReason(e){if(this.element!=="disabled")throw Error('Cannot set the disabled reason for a BlockChange event if the element is not "disabled".');this.disabledReason=e}isNull(){return this.oldValue===this.newValue}run(e){var t=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");if(t=t.getBlockById(this.blockId),!t)throw Error("The associated block is undefined. Either pass a block to the constructor, or call fromJson");const o=t.getIcon(ut.MUTATOR);switch(o&&Ts(o)&&o.bubbleIsVisible()&&o.setBubbleVisible(!1),e=e?this.newValue:this.oldValue,this.element){case"field":(t=t.getField(this.name))?t.setValue(e):console.warn("Can't set non-existent field: "+this.name);break;case"comment":t.setCommentText(e||null);break;case"collapsed":t.setCollapsed(!!e);break;case"disabled":var s;t.setDisabledReason(!!e,(s=this.disabledReason)!=null?s:Jt);break;case"inline":t.setInputsInline(!!e);break;case"mutation":s=As.getExtraBlockState_(t),t.loadExtraState?t.loadExtraState(JSON.parse(e||"{}")):t.domToMutation&&t.domToMutation(r.textToDom$$module$build$src$core$utils$xml(e||"<mutation/>")),_(new As(t,"mutation",null,s,e));break;default:console.warn("Unknown change type: "+this.element)}}static getExtraBlockState_(e){return e.saveExtraState?(e=e.saveExtraState(!0))?JSON.stringify(e):"":e.mutationToDom&&(e=e.mutationToDom())?fo(e):""}};l(M.EVENT,w.BLOCK_CHANGE,As);var Xn={};Xn.clamp=Qs,Xn.toDegrees=s$,Xn.toRadians=tn;var jn=16,Fg=1,Ug=12,ka=16,Kn=.25,Ra=null,Ls=null,Hg="",Gg="",Ke,pr,Ms,wa=null,cs=null,Vg=null,Jn=null,qn=null,Oa={getBoundsInfo:function(){const e=Zo(wa),t=Rt(wa);return{left:e.x,right:e.x+t.width,top:e.y,bottom:e.y+t.height,width:t.width,height:t.height}},getPositionMetrics:function(e,t,o,s){const i=Oa.getBoundsInfo(),n=Rt(Ke);return t+n.height<i.bottom?Ic(e,t,i,n):s-n.height>i.top?Cc(o,s,i,n):t+n.height<document.documentElement.clientHeight?Ic(e,t,i,n):s-n.height>document.documentElement.clientTop?Cc(o,s,i,n):r$(e,i,n)}},wt={ANIMATION_TIME:Kn,ARROW_HORIZONTAL_PADDING:Ug,ARROW_SIZE:jn,BORDER_SIZE:Fg,PADDING_Y:ka,TEST_ONLY:Oa};wt.clearContent=rn,wt.createDom=on,wt.getContentDiv=sn,wt.getOwner=fc,wt.getPositionX=Wi,wt.hide=ln,wt.hideIfOwner=nn,wt.hideWithoutAnimation=mo,wt.isVisible=Sc,wt.repositionForWindowResize=Rc,wt.setBoundsElement=mc,wt.setColour=_c,wt.show=vc,wt.showPositionedByBlock=i$,wt.showPositionedByField=bc;var mi={};mi.commonWordPrefix=wc,mi.commonWordSuffix=Oc,mi.isNumber=r.isNumber$$module$build$src$core$utils$string,mi.shortestStringLength=zi,mi.wrap=r.wrap$$module$build$src$core$utils$string;var Zn=void 0,gr=!1,fi=!1,Wg=50,zg=0,Ds=0,Na=0,Aa=0,qt=null,mr=null,La=0,Ma=10,Yg=10,Xg=750,Qn=5,at=null,Vt={HOVER_MS:Xg,LIMIT:Wg,MARGINS:Qn,OFFSET_X:La,OFFSET_Y:Ma,RADIUS_OK:Yg};Vt.bindMouseEvents=Yi,Vt.block=Bc,Vt.createDom=Lc,Vt.dispose=xc,Vt.getCustomTooltip=u$,Vt.getDiv=h$,Vt.getTooltipOfObject=ei,Vt.hide=xo,Vt.isVisible=a$,Vt.setCustomTooltip=c$,Vt.unbindMouseEvents=Mc,Vt.unblock=Pc;var Da=.45,xa=.65,jg={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00"},Zt={};Zt.blend=ys,Zt.getHsvSaturation=Fc,Zt.getHsvValue=Uc,Zt.hexToRgb=un,Zt.hsvToHex=an,Zt.hueToHex=Hc,Zt.names=jg,Zt.parse=Es,Zt.rgbToHex=Xi,Zt.setHsvSaturation=_$,Zt.setHsvValue=b$;var fr={};fr.checkMessageReferences=T$,fr.parseBlockColour=ti,fr.replaceMessageReferences=Je,fr.tokenizeInterpolation=Gc;var we=class{get size_(){return this.size}set size_(e){this.size=e}constructor(e,t,o){this.DEFAULT_VALUE=null,this.name=void 0,this.tooltip=this.validator_=null,this.size=new ve(0,0),this.constants_=this.mouseDownWrapper=this.textContent_=this.textElement_=this.borderRect_=this.fieldGroup_=null,this.disposed=!1,this.maxDisplayLength=50,this.sourceBlock_=null,this.enabled_=this.visible_=this.isDirty_=!0,this.suffixField=this.prefixField=this.clickTarget_=null,this.EDITABLE=!0,this.SERIALIZABLE=!1,this.id_=null,this.value_="DEFAULT_VALUE"in new.target.prototype?new.target.prototype.DEFAULT_VALUE:this.DEFAULT_VALUE,this.size_=new ve(0,0),e!==we.SKIP_SETUP&&(o&&this.configure_(o),this.setValue(e),t&&this.setValidator(t))}configure_(e){e.tooltip&&this.setTooltip(Je(e.tooltip))}setSourceBlock(e){if(this.sourceBlock_)throw Error("Field already bound to a block");if(this.sourceBlock_=e,e.id.includes("_field"))throw Error(`Field ID indicator is contained in block ID. This may cause problems with focus: ${e.id}.`);this.id_=`${e.id}_field_${Re()}`}getConstants(){return!this.constants_&&this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()&&this.sourceBlock_.workspace.rendered&&(this.constants_=this.sourceBlock_.workspace.getRenderer().getConstants()),this.constants_}getSourceBlock(){return this.sourceBlock_}init(){if(!this.fieldGroup_){var e=this.id_;if(!e)throw Error("Expected ID to be defined prior to init.");this.fieldGroup_=v(R.G,{id:e}),this.isVisible()||(this.fieldGroup_.style.display="none"),this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_),this.initView(),this.updateEditable(),this.setTooltip(this.tooltip),this.bindEvents_(),this.initModel(),this.applyColour()}}initView(){this.createBorderRect_(),this.createTextElement_(),this.fieldGroup_&&G(this.fieldGroup_,"blocklyField")}initModel(){}isFullBlockField(){return!this.borderRect_}createBorderRect_(){this.borderRect_=v(R.RECT,{rx:this.getConstants().FIELD_BORDER_RECT_RADIUS,ry:this.getConstants().FIELD_BORDER_RECT_RADIUS,x:0,y:0,height:this.size_.height,width:this.size_.width,class:"blocklyFieldRect"},this.fieldGroup_)}createTextElement_(){this.textElement_=v(R.TEXT,{class:"blocklyText blocklyFieldText"},this.fieldGroup_),this.getConstants().FIELD_TEXT_BASELINE_CENTER&&this.textElement_.setAttribute("dominant-baseline","central"),this.textContent_=document.createTextNode(""),this.textElement_.appendChild(this.textContent_)}bindEvents_(){const e=this.getClickTarget_();if(!e)throw Error("A click target has not been set.");Yi(e),this.mouseDownWrapper=z(e,"pointerdown",this,this.onMouseDown_)}fromXml(e){this.setValue(e.textContent)}toXml(e){return e.textContent=this.getValue(),e}saveState(e){return e=this.saveLegacyState(we),e!==null?e:this.getValue()}loadState(e){this.loadLegacyState(we,e)||this.setValue(e)}saveLegacyState(e){return e.prototype.saveState===this.saveState&&e.prototype.toXml!==this.toXml?(e=r.createElement$$module$build$src$core$utils$xml("field"),e.setAttribute("name",this.name||""),Xs(this.toXml(e)).replace(' xmlns="https://developers.google.com/blockly/xml"',"")):null}loadLegacyState(e,t){return e.prototype.loadState===this.loadState&&e.prototype.fromXml!==this.fromXml?(this.fromXml(r.textToDom$$module$build$src$core$utils$xml(t)),!0):!1}dispose(){nn(this),vs(this);let e;(e=this.getSourceBlock())!=null&&e.isDeadOrDying()||ke(this.fieldGroup_),this.disposed=!0}updateEditable(){const e=this.fieldGroup_,t=this.getSourceBlock();this.EDITABLE&&e&&t&&(this.enabled_&&t.isEditable()?(G(e,"blocklyEditableField"),Te(e,"blocklyNonEditableField")):(G(e,"blocklyNonEditableField"),Te(e,"blocklyEditableField")))}setEnabled(e){this.enabled_=e,this.updateEditable()}isEnabled(){return this.enabled_}isClickable(){return this.enabled_&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()&&this.showEditor_!==we.prototype.showEditor_}isClickableInFlyout(e){return!e}isCurrentlyEditable(){return this.enabled_&&this.EDITABLE&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()}isSerializable(){let e=!1;return this.name&&(this.SERIALIZABLE?e=!0:this.EDITABLE&&(console.warn("Detected an editable field that was not serializable. Please define SERIALIZABLE property as true on all editable custom fields. Proceeding with serialization."),e=!0)),e}isVisible(){return this.visible_}setVisible(e){if(this.visible_!==e){this.visible_=e;var t=this.fieldGroup_;t&&(t.style.display=e?"block":"none")}}setValidator(e){this.validator_=e}getValidator(){return this.validator_}getSvgRoot(){return this.fieldGroup_}getBorderRect(){if(!this.borderRect_)throw Error(`The border rectangle is ${this.borderRect_}.`);return this.borderRect_}getTextElement(){if(!this.textElement_)throw Error(`The text element is ${this.textElement_}.`);return this.textElement_}getTextContent(){if(!this.textContent_)throw Error(`The text content is ${this.textContent_}.`);return this.textContent_}applyColour(){}render_(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_()),this.updateSize_()}showEditor(e){this.isClickable()&&this.showEditor_(e)}showEditor_(e){}repositionForWindowResize(){return!1}updateSize_(e){const t=this.getConstants();e=e!==void 0?e:this.isFullBlockField()?0:this.getConstants().FIELD_BORDER_RECT_X_PADDING;let o=e*2,s=t.FIELD_TEXT_HEIGHT,i=0;this.textElement_&&(i=ot(this.textElement_),o+=i),this.isFullBlockField()||(s=Math.max(s,t.FIELD_BORDER_RECT_HEIGHT)),this.size_.height=s,this.size_.width=o,this.positionTextElement_(e,i),this.positionBorderRect_()}positionTextElement_(e,t){if(this.textElement_){var o=this.getConstants(),s=this.size_.height/2,i;this.textElement_.setAttribute("x",String((i=this.getSourceBlock())!=null&&i.RTL?this.size_.width-t-e:e)),this.textElement_.setAttribute("y",String(o.FIELD_TEXT_BASELINE_CENTER?s:s-o.FIELD_TEXT_HEIGHT/2+o.FIELD_TEXT_BASELINE))}}positionBorderRect_(){this.borderRect_&&(this.borderRect_.setAttribute("width",String(this.size_.width)),this.borderRect_.setAttribute("height",String(this.size_.height)),this.borderRect_.setAttribute("rx",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)),this.borderRect_.setAttribute("ry",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)))}getSize(){return this.isVisible()?(this.isDirty_&&(this.render_(),this.isDirty_=!1),this.size_):new ve(0,0)}getScaledBBox(){let e;var t=this.getSourceBlock();if(!t)throw new tt;if(this.isFullBlockField()){var o=this.sourceBlock_.getHeightWidth();const s=t.workspace.scale;e=this.getAbsoluteXY_(),t=(o.width+1)*s,o=(o.height+1)*s,zp?(e.x+=1.5*s,e.y+=1.5*s):(e.x-=.5*s,e.y-=.5*s)}else o=this.borderRect_.getBoundingClientRect(),e=Zo(this.borderRect_),t=o.width,o=o.height;return new ye(e.y,e.y+o,e.x,e.x+t)}onLocationChange(e){}getDisplayText_(){let e=this.getText();return e.length>this.maxDisplayLength&&(e=e.substring(0,this.maxDisplayLength-2)+"…"),e=e.replace(/\s/g,we.NBSP),this.sourceBlock_&&this.sourceBlock_.RTL&&(e+="‏"),e}getText(){const e=this.getText_();return String(e!==null?e:this.getValue())}getText_(){return null}markDirty(){this.isDirty_=!0,this.constants_=null}forceRerender(){this.isDirty_=!0,this.sourceBlock_&&this.sourceBlock_.rendered&&this.sourceBlock_.queueRender()}setValue(e,t=!0){if(e!==null){var o=r.getGroup$$module$build$src$core$events$utils();o||r.setGroup$$module$build$src$core$events$utils(!0);try{const L=this.doClassValidation_(e),oe=this.processValidation(e,L,t);if(!(oe instanceof Error)){var s,i=(s=this.getValidator())==null?void 0:s.call(this,oe),n=this.processValidation(oe,i,t);if(!(n instanceof Error)){var d=this.sourceBlock_;if(!d||!d.disposed){var f=this.getValue();f===n?this.doValueUpdate_(n):(this.doValueUpdate_(n),t&&d&&J()&&_(new(U(w.BLOCK_CHANGE))(d,"field",this.name||null,f,n)),this.isDirty_&&this.forceRerender())}}}}finally{r.setGroup$$module$build$src$core$events$utils(o)}}}processValidation(e,t,o){return t===null?(this.doValueInvalid_(e,o),this.isDirty_&&this.forceRerender(),Error()):t===void 0?e:t}getValue(){return this.value_}doClassValidation_(e){return e??null}doValueUpdate_(e){this.value_=e,this.isDirty_=!0}doValueInvalid_(e,t){}onMouseDown_(e){this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()&&(e=this.sourceBlock_.workspace.getGesture(e))&&e.setStartField(this)}setTooltip(e){e||e===""||(e=this.sourceBlock_);const t=this.getClickTarget_();t?t.tooltip=e:this.tooltip=e}getTooltip(){const e=this.getClickTarget_();return ei(e||{tooltip:this.tooltip})}getClickTarget_(){return this.clickTarget_||this.getSvgRoot()}getAbsoluteXY_(){return Zo(this.getClickTarget_())}referencesVariables(){return!1}refreshVariableName(){}getParentInput(){let e=null;const t=this.getSourceBlock();if(!t)throw new tt;const o=t.inputList;for(let s=0;s<t.inputList.length;s++){const i=o[s],n=i.fieldRow;for(let d=0;d<n.length;d++)if(n[d]===this){e=i;break}}return e}getFlipRtl(){return!1}onShortcut(e){return!1}getFocusableElement(){if(!this.fieldGroup_)throw Error("This field currently has no representative DOM element.");return this.fieldGroup_}getFocusableTree(){const e=this.getSourceBlock();if(!e)throw new tt;return e.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}static fromJson(e){throw Error("Attempted to instantiate a field from the registry that hasn't defined a 'fromJson' method.")}};we.NBSP=" ",we.SKIP_SETUP=Symbol("SKIP_SETUP");var tt=class extends Error{constructor(){super("The field has not yet been attached to its input. Call appendField to attach it.")}},_i=null,Kg=null,el=null,Ba="blocklyWidgetDiv",bi="",Ti="",Wt,tl=null,lo={};lo.createDom=Vc,lo.getDiv=oi,lo.hide=si,lo.hideIfOwner=vs,lo.hideIfOwnerIsInWorkspace=ji,lo.isVisible=Wc,lo.positionWithAnchor=Yc,lo.repositionForWindowResize=Xc,lo.show=dn,lo.testOnly_setDiv=E$;var ol=null,Jg={},sl=null,xs={};xs.callbackFactory=r.callbackFactory$$module$build$src$core$contextmenu,xs.dispose=Kc,xs.getCurrentBlock=C$,xs.hide=Ki,xs.setCurrentBlock=jc,xs.show=ii;var Ee=class{constructor(){this.registeredItems=new Map,this.reset()}reset(){this.registeredItems.clear()}register(e){if(this.registeredItems.has(e.id))throw Error('Menu item with ID "'+e.id+'" is already registered.');this.registeredItems.set(e.id,e)}unregister(e){if(!this.registeredItems.has(e))throw Error('Menu item with ID "'+e+'" not found.');this.registeredItems.delete(e)}getItem(e){let t;return(t=this.registeredItems.get(e))!=null?t:null}getContextMenuOptions(e,t){const o=[];for(const s of this.registeredItems.values()){if(s.scopeType&&(s.scopeType===Pa.BLOCK&&!e.block||s.scopeType===Pa.COMMENT&&!e.comment||s.scopeType===Pa.WORKSPACE&&!e.workspace))continue;let i;if(i={scope:e,weight:s.weight},s.separator)i=Object.assign({},i,{separator:!0});else{const n=s.preconditionFn(e,t);if(n==="hidden")continue;const d=typeof s.displayText=="function"?s.displayText(e):s.displayText;i=Object.assign({},i,{text:d,callback:s.callback,enabled:n==="enabled"})}o.push(i)}return o.sort(function(s,i){return s.weight-i.weight}),o}};(function(e){var t=e.ScopeType||(e.ScopeType={});t.BLOCK="block",t.WORKSPACE="workspace",t.COMMENT="comment",e.registry=new e})(Ee||(Ee={}));var Pa=Ee.ScopeType,us=50,il=100,Ib={BLOCK:us,BUBBLE:il},qg=class{constructor(e){this.comment=e,this.startLoc=null,this.workspace=e.workspace}isMovable(){return this.comment.isOwnMovable()&&!this.comment.isDeadOrDying()&&!this.workspace.isReadOnly()}startDrag(){this.fireDragStartEvent(),this.startLoc=this.comment.getRelativeToSurfaceXY(),this.workspace.setResizesEnabled(!1);let e;(e=this.workspace.getLayerManager())==null||e.moveToDragLayer(this.comment),this.comment.setDragging(!0)}drag(e){this.comment.moveDuringDrag(e)}endDrag(){this.fireDragEndEvent(),this.fireMoveEvent();let e;(e=this.workspace.getLayerManager())==null||e.moveOffDragLayer(this.comment,us),this.comment.setDragging(!1),this.comment.snapToGrid(),this.workspace.setResizesEnabled(!0)}fireDragStartEvent(){const e=new(U(w.COMMENT_DRAG))(this.comment,!0);_(e)}fireDragEndEvent(){const e=new(U(w.COMMENT_DRAG))(this.comment,!1);_(e)}fireMoveEvent(){if(!this.comment.isDeadOrDying()){var e=new(U(w.COMMENT_MOVE))(this.comment);e.setReason(["drag"]),e.oldCoordinate_=this.startLoc,e.recordNew(),_(e)}}revertDrag(){this.startLoc&&this.comment.moveDuringDrag(this.startLoc)}},Zg=new WeakMap,rl=class{constructor(e,t,o){this.id=e,this.workspace=t,this.container=o}isVisible(){return this.icon.checkVisibility()}getParentComment(){const e=this.workspace.getCommentById(this.id);if(!e)throw Error(`Comment bar button ${this.id} has no corresponding comment`);return e}getSize(e=!1){var t=this.icon.getBBox();return t=ye.from(t),e&&(e=this.getMargin(),t.left-=e,t.top-=e,t.bottom+=e,t.right+=e),t}getMargin(){return(this.container.getBBox().height-this.icon.getBBox().height)/2}getFocusableElement(){return this.icon}getFocusableTree(){return this.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return this.isVisible()}},Qg="_collapse_bar_button",em=class extends rl{constructor(e,t,o){super(e,t,o),this.id=e,this.workspace=t,this.container=o,this.icon=v(R.IMAGE,{class:"blocklyFoldoutIcon",href:`${this.workspace.options.pathToMedia}foldout-icon.svg`,id:`${this.id}${Qg}`},this.container),this.bindId=z(this.icon,"pointerdown",this,this.performAction.bind(this))}dispose(){te(this.bindId)}reposition(){const e=this.getMargin();this.icon.setAttribute("y",`${e}`),this.icon.setAttribute("x",`${e}`)}performAction(e){ie();const t=this.getParentComment();t.view.bringToFront(),e&&e instanceof PointerEvent&&Ie(e)?e.stopPropagation():(t.setCollapsed(!t.isCollapsed()),this.workspace.hideChaff(),e?.stopPropagation())}},Fa="_comment_textarea_",tm=class{constructor(e,t,o){this.workspace=e,this.onFinishEditing=o,this.textChangeListeners=[],this.text="",this.foreignObject=v(R.FOREIGNOBJECT,{class:"blocklyCommentForeignObject"}),e=document.createElementNS(To,"body"),e.setAttribute("xmlns",To),e.className="blocklyMinimalBody",this.textArea=document.createElementNS(To,"textarea"),this.textArea.setAttribute("tabindex","-1"),G(this.textArea,"blocklyCommentText"),G(this.textArea,"blocklyTextarea"),G(this.textArea,"blocklyText"),e.appendChild(this.textArea),this.foreignObject.appendChild(e),t&&(this.id=t+Fa,this.textArea.setAttribute("id",this.id)),z(this.textArea,"change",this,this.onTextChange),z(this.textArea,"pointerdown",this,s=>{s.stopPropagation(),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this),ie()}),z(this.textArea,"keydown",this,this.handleKeyDown)}getDom(){return this.foreignObject}getText(){return this.text}setText(e){this.textArea.value=e,this.onTextChange()}onTextChange(){const e=this.text;this.text=this.textArea.value;for(let t=this.textChangeListeners.length-1;t>=0;t--)this.textChangeListeners[t](e,this.text)}handleKeyDown(e){(e.key==="Escape"||e.key==="Enter"&&(e.ctrlKey||e.metaKey))&&(this.onFinishEditing&&this.onFinishEditing(),e.stopPropagation())}addTextChangeListener(e){this.textChangeListeners.push(e)}removeTextChangeListener(e){this.textChangeListeners.splice(this.textChangeListeners.indexOf(e),1)}setPlaceholderText(e){this.textArea.placeholder=e}setEditable(e){e?this.textArea.removeAttribute("readonly"):this.textArea.setAttribute("readonly","true")}updateSize(e,t){this.foreignObject.setAttribute("height",`${e.height-t.height}`),this.foreignObject.setAttribute("width",`${e.width}`),this.foreignObject.setAttribute("y",`${t.height}`),this.workspace.RTL&&this.foreignObject.setAttribute("x",`${-e.width}`)}getFocusableElement(){return this.textArea}getFocusableTree(){return this.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!!this.id}},om="_delete_bar_button",sm=class extends rl{constructor(e,t,o){super(e,t,o),this.id=e,this.workspace=t,this.container=o,this.icon=v(R.IMAGE,{class:"blocklyDeleteIcon",href:`${this.workspace.options.pathToMedia}delete-icon.svg`,id:`${this.id}${om}`},o),this.bindId=z(this.icon,"pointerdown",this,this.performAction.bind(this))}dispose(){te(this.bindId)}reposition(){const e=this.getMargin();this.icon.setAttribute("x","0");const t=this.container.getBBox();this.icon.setAttribute("y",`${e}`),this.icon.setAttribute("x",`${t.width-this.getSize(!0).getWidth()}`)}performAction(e){ie(),e&&e instanceof PointerEvent&&Ie(e)?e.stopPropagation():(this.getParentComment().dispose(),e?.stopPropagation(),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.workspace))}},_r=class{constructor(e,t){this.workspace=e,this.commentId=t,this.collapsed=!1,this.editable=!0,this.location=new P(0,0),this.sizeChangeListeners=[],this.disposeListeners=[],this.collapseChangeListeners=[],this.resizePointerMoveListener=this.resizePointerUpListener=null,this.disposed=this.disposing=!1,this.svgRoot=v(R.G,{class:"blocklyComment blocklyEditable blocklyDraggable"}),this.highlightRect=this.createHighlightRect(this.svgRoot),{topBarGroup:this.topBarGroup,topBarBackground:this.topBarBackground,deleteButton:this.deleteButton,foldoutButton:this.foldoutButton,textPreview:this.textPreview,textPreviewNode:this.textPreviewNode}=this.createTopBar(this.svgRoot),this.commentEditor=this.createTextArea(),this.resizeHandle=this.createResizeHandle(this.svgRoot,e);let o;(o=e.getLayerManager())==null||o.append(this,us),this.size=_r.defaultCommentSize,this.setSizeWithoutFiringEvents(this.size),this.moveTo(new P(0,0))}createHighlightRect(e){return v(R.RECT,{class:"blocklyCommentHighlight"},e)}createTopBar(e){e=v(R.G,{class:"blocklyCommentTopbar"},e);const t=v(R.RECT,{class:"blocklyCommentTopbarBackground"},e),o=new sm(this.commentId,this.workspace,e),s=new em(this.commentId,this.workspace,e),i=v(R.TEXT,{class:"blocklyCommentPreview blocklyCommentText blocklyText"},e),n=document.createTextNode("");return i.appendChild(n),{topBarGroup:e,topBarBackground:t,deleteButton:o,foldoutButton:s,textPreview:i,textPreviewNode:n}}createTextArea(){const e=new tm(this.workspace,this.commentId,()=>this.svgRoot.focus());return this.svgRoot.appendChild(e.getDom()),e.addTextChangeListener((t,o)=>{this.updateTextPreview(o),this.setSize(this.size)}),e}getEditorFocusableNode(){return this.commentEditor}createResizeHandle(e,t){return e=v(R.IMAGE,{class:"blocklyResizeHandle",href:`${t.options.pathToMedia}resize-handle.svg`},e),z(e,"pointerdown",this,this.onResizePointerDown),e}getSvgRoot(){return this.svgRoot}getSize(){return this.collapsed?this.topBarBackground.getBBox():this.size}setSizeWithoutFiringEvents(e){const t=this.topBarBackground.getBBox(),o=this.textPreview.getBBox(),s=this.resizeHandle.getBBox();this.size=e=ve.max(e,this.calcMinSize(t)),this.svgRoot.setAttribute("height",`${e.height}`),this.svgRoot.setAttribute("width",`${e.width}`),this.updateHighlightRect(e),this.updateTopBarSize(e),this.commentEditor.updateSize(e,t),this.deleteButton.reposition(),this.foldoutButton.reposition(),this.updateTextPreviewSize(e,t,o),this.updateResizeHandlePosition(e,s)}setSize(e){const t=this.preResizeSize||this.size;this.setSizeWithoutFiringEvents(e),this.onSizeChange(t,this.size)}calcMinSize(e){var t;this.updateTextPreview((t=this.commentEditor.getText())!=null?t:"");let o=t=ot(this.textPreview);return this.foldoutButton.isVisible()?o+=this.foldoutButton.getSize(!0).getWidth():t&&(o+=4),this.deleteButton.isVisible()?o+=this.deleteButton.getSize(!0).getWidth():t&&(o+=4),new ve(o,e.height+20)}updateHighlightRect(e){this.highlightRect.setAttribute("height",`${e.height}`),this.highlightRect.setAttribute("width",`${e.width}`),this.workspace.RTL&&this.highlightRect.setAttribute("x",`${-e.width}`)}updateTopBarSize(e){this.topBarBackground.setAttribute("width",`${e.width}`)}updateTextPreviewSize(e,t,o){t=(t.height-o.height)/2;const s=this.foldoutButton.getSize(!0),i=this.deleteButton.getSize(!0);e=e.width-s.getWidth()-i.getWidth(),this.textPreview.setAttribute("x",`${s.getWidth()}`),this.textPreview.setAttribute("y",`${t+o.height/2}`),this.textPreview.setAttribute("width",`${e}`)}updateResizeHandlePosition(e,t){this.resizeHandle.setAttribute("y",`${e.height-t.height}`),this.resizeHandle.setAttribute("x",`${e.width-t.width}`)}onSizeChange(e,t){for(let o=this.sizeChangeListeners.length-1;o>=0;o--)this.sizeChangeListeners[o](e,t)}addSizeChangeListener(e){this.sizeChangeListeners.push(e)}removeSizeChangeListener(e){this.sizeChangeListeners.splice(this.sizeChangeListeners.indexOf(e),1)}onResizePointerDown(e){this.isEditable()&&(this.bringToFront(),Ie(e)||(this.preResizeSize=this.getSize(),$n(this.workspace,e,new P(this.workspace.RTL?-this.getSize().width:this.getSize().width,this.getSize().height)),this.resizePointerUpListener=z(document,"pointerup",this,this.onResizePointerUp),this.resizePointerMoveListener=z(document,"pointermove",this,this.onResizePointerMove),this.workspace.hideChaff()),e.stopPropagation())}onResizePointerUp(e){ie(),this.resizePointerUpListener&&(te(this.resizePointerUpListener),this.resizePointerUpListener=null),this.resizePointerMoveListener&&(te(this.resizePointerMoveListener),this.resizePointerMoveListener=null),this.setSize(this.size),this.preResizeSize=void 0}onResizePointerMove(e){e=pn(this.workspace,e),this.setSizeWithoutFiringEvents(new ve(this.workspace.RTL?-e.x:e.x,e.y))}isCollapsed(){return this.collapsed}setCollapsed(e){(this.collapsed=e)?G(this.svgRoot,"blocklyCollapsed"):Te(this.svgRoot,"blocklyCollapsed"),this.setSizeWithoutFiringEvents(this.size),this.onCollapse()}onCollapse(){for(let e=this.collapseChangeListeners.length-1;e>=0;e--)this.collapseChangeListeners[e](this.collapsed)}addOnCollapseListener(e){this.collapseChangeListeners.push(e)}removeOnCollapseListener(e){this.collapseChangeListeners.splice(this.collapseChangeListeners.indexOf(e),1)}isEditable(){return this.editable}setEditable(e){(this.editable=e)?(G(this.svgRoot,"blocklyEditable"),Te(this.svgRoot,"blocklyReadonly")):(Te(this.svgRoot,"blocklyEditable"),G(this.svgRoot,"blocklyReadonly")),this.commentEditor.setEditable(e)}getRelativeToSurfaceXY(){return this.location}moveTo(e){this.location=e,this.svgRoot.setAttribute("transform",`translate(${e.x}, ${e.y})`)}getText(){return this.commentEditor.getText()}setText(e){this.commentEditor.setText(e)}setPlaceholderText(e){this.commentEditor.setPlaceholderText(e)}addTextChangeListener(e){this.commentEditor.addTextChangeListener(e)}removeTextChangeListener(e){this.commentEditor.removeTextChangeListener(e)}updateTextPreview(e){this.textPreviewNode.textContent=this.truncateText(e)}truncateText(e){return e.length>=12?`${e.substring(0,9)}...`:e}bringToFront(){const e=this.svgRoot.parentNode,t=e.childNodes;t[t.length-1]!==this.svgRoot&&e.appendChild(this.svgRoot)}onDeleteDown(e){ie(),Ie(e)||this.dispose(),e.stopPropagation()}dispose(){this.disposing=!0,this.foldoutButton.dispose(),this.deleteButton.dispose(),ke(this.svgRoot);for(let e=this.disposeListeners.length-1;e>=0;e--)this.disposeListeners[e]();this.disposed=!0}isDisposed(){return this.disposed}isDeadOrDying(){return this.disposing||this.disposed}addDisposeListener(e){this.disposeListeners.push(e)}removeDisposeListener(e){this.disposeListeners.splice(this.disposeListeners.indexOf(e),1)}getCommentBarButtons(){return[this.foldoutButton,this.deleteButton]}};_r.defaultCommentSize=new ve(120,100),q(`
509
509
  .injectionDiv {
510
510
  --commentFillColour: #FFFCC7;
511
511
  --commentBorderColour: #F2E49B;
@@ -614,13 +614,13 @@ children`),this.state=e}},Mg=class extends gi{constructor(e,t,o){super(`Cannot a
614
614
  stroke: #fc3;
615
615
  stroke-width: 3px;
616
616
  }
617
- `);var rl=class{constructor(e,t){this.workspace=e,this.text="",this.collapsed=!1,this.deletable=this.movable=this.editable=!0,this.location=new P(0,0),this.disposing=this.disposed=!1,this.id=t&&!e.getCommentById(t)?t:rt(),this.size=fr.defaultCommentSize,e.addTopComment(this),this.fireCreateEvent()}fireCreateEvent(){J()&&_(new(U(w.COMMENT_CREATE))(this))}fireDeleteEvent(){J()&&_(new(U(w.COMMENT_DELETE))(this))}fireChangeEvent(e,t){J()&&_(new(U(w.COMMENT_CHANGE))(this,e,t))}fireCollapseEvent(e){J()&&_(new(U(w.COMMENT_COLLAPSE))(this,e))}setText(e){const t=this.text;this.text=e,this.fireChangeEvent(t,e)}getText(){return this.text}setSize(e){const t=new(U(w.COMMENT_RESIZE))(this);this.size=e,t.recordCurrentSizeAsNewSize(),_(t)}getSize(){return this.size}setCollapsed(e){this.collapsed=e,this.fireCollapseEvent(e)}isCollapsed(){return this.collapsed}setEditable(e){this.editable=e}isEditable(){return this.isOwnEditable()&&!this.workspace.isReadOnly()}isOwnEditable(){return this.editable}setMovable(e){this.movable=e}isMovable(){return this.isOwnMovable()&&!this.workspace.isReadOnly()&&!this.workspace.isFlyout}isOwnMovable(){return this.movable}setDeletable(e){this.deletable=e}isDeletable(){return this.isOwnDeletable()&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()&&!this.workspace.isFlyout}isOwnDeletable(){return this.deletable}moveTo(e,t){const o=new(U(w.COMMENT_MOVE))(this);t&&o.setReason(t),this.location=e,o.recordNew(),_(o)}getRelativeToSurfaceXY(){return this.location}dispose(){this.disposing=!0,this.fireDeleteEvent(),this.workspace.removeTopComment(this),this.disposed=!0}isDisposed(){return this.disposed}isDeadOrDying(){return this.disposing||this.disposed}},yo=class extends rl{constructor(e,t){super(e,t),this.dragStrategy=new jg(this),this.workspace=e,this.view=new fr(e,this.id),this.view.setSize(this.getSize()),this.view.setEditable(this.isEditable()),this.view.getSvgRoot().setAttribute("data-id",this.id),this.view.getSvgRoot().setAttribute("id",this.id),this.addModelUpdateBindings(),z(this.view.getSvgRoot(),"pointerdown",this,this.startGesture),z(this.view.getSvgRoot(),"wheel",this,o=>{o.stopPropagation()})}addModelUpdateBindings(){this.view.addTextChangeListener((e,t)=>void super.setText(t)),this.view.addSizeChangeListener((e,t)=>void super.setSize(t)),this.view.addOnCollapseListener(()=>void super.setCollapsed(this.view.isCollapsed())),this.view.addDisposeListener(()=>{this.isDeadOrDying()||this.dispose()})}setText(e){this.view.setText(e)}setPlaceholderText(e){this.view.setPlaceholderText(e)}setSize(e){this.view.setSize(e)}setCollapsed(e){this.view.setCollapsed(e)}setEditable(e){super.setEditable(e),this.view.setEditable(this.isEditable())}getSvgRoot(){return this.view.getSvgRoot()}getSize(){return super.getSize()}getBoundingRectangle(){const e=this.getRelativeToSurfaceXY();var t,o;const s=(o=(t=this.view)==null?void 0:t.getSize())!=null?o:this.getSize();return this.workspace.RTL?(t=e.x-s.width,o=e.x):(t=e.x,o=e.x+s.width),new ye(e.y,e.y+s.height,t,o)}moveBy(e,t,o){const s=this.getRelativeToSurfaceXY();e=new P(s.x+e,s.y+t),this.moveTo(e,o)}moveTo(e,t){super.moveTo(e,t),this.view.moveTo(e)}moveDuringDrag(e){this.location=e,this.view.moveTo(e)}setDragging(e){e?G(this.getSvgRoot(),"blocklyDragging"):Te(this.getSvgRoot(),"blocklyDragging")}dispose(){this.disposing=!0;const e=r.getFocusManager$$module$build$src$core$focus_manager();e.getFocusedNode()===this&&setTimeout(()=>e.focusTree(this.workspace),0),this.view.isDeadOrDying()||this.view.dispose(),super.dispose()}startGesture(e){const t=this.workspace.getGesture(e);t&&(t.handleCommentStart(e,this),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this))}setDeleteStyle(e){e?G(this.getSvgRoot(),"blocklyDraggingDelete"):Te(this.getSvgRoot(),"blocklyDraggingDelete")}isCopyable(){return this.isOwnMovable()&&this.isOwnDeletable()}isMovable(){return this.dragStrategy.isMovable()}startDrag(){this.dragStrategy.startDrag()}drag(e){this.dragStrategy.drag(e)}endDrag(){this.dragStrategy.endDrag()}revertDrag(){this.dragStrategy.revertDrag()}select(){G(this.getSvgRoot(),"blocklySelected"),V(this)}unselect(){Te(this.getSvgRoot(),"blocklySelected"),V(null)}toCopyData(){return{paster:Hn.TYPE,commentState:js(this,{addCoordinates:!0})}}showContextMenu(e){const t=Ee.registry.getContextMenuOptions({comment:this,focusedNode:this},e);let o;o=e instanceof PointerEvent?new P(e.clientX,e.clientY):Ys(this.workspace,this.getRelativeToSurfaceXY()).translate(10,10),ii(e,t,this.workspace.RTL,this.workspace,o)}snapToGrid(){if(!this.isDeadOrDying()){var e=this.workspace.getGrid();if(e!=null&&e.shouldSnap()){var t=this.getRelativeToSurfaceXY();e=e.alignXY(t),e!==t&&this.moveTo(e,["snap"])}}}getEditorFocusableNode(){return this.view.getEditorFocusableNode()}getFocusableElement(){return this.getSvgRoot()}getFocusableTree(){return this.workspace}onNodeFocus(){this.select();let e;(e=this.workspace.getLayerManager())==null||e.append(this,us)}onNodeBlur(){this.unselect()}canBeFocused(){return!0}},Ot={};Ot.appendDomToWorkspace=A$,Ot.blockToDom=ts,Ot.blockToDomWithXY=Ji,Ot.clearWorkspaceAndLoadFromXml=N$,Ot.deleteNext=H$,Ot.domToBlock=r.domToBlock$$module$build$src$core$xml,Ot.domToBlockInternal=Is,Ot.domToPrettyText=O$,Ot.domToText=fo,Ot.domToVariables=Zc,Ot.domToWorkspace=r.domToWorkspace$$module$build$src$core$xml,Ot.loadWorkspaceComment=qc,Ot.saveWorkspaceComment=Ki,Ot.variablesToDom=Kc,Ot.workspaceToDom=k$;var Pa=class extends Ns{constructor(e){super(e),this.type=w.BLOCK_CREATE,e&&(e.isShadow()&&(this.recordUndo=!1),this.xml=Ji(e),this.ids=ce(e),this.json=jt(e,{addCoordinates:!0}))}toJson(){const e=super.toJson();if(!this.xml)throw Error("The block XML is undefined. Either pass a block to the constructor, or call fromJson");if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!this.json)throw Error("The block JSON is undefined. Either pass a block to the constructor, or call fromJson");return e.xml=fo(this.xml),e.ids=this.ids,e.json=this.json,this.recordUndo||(e.recordUndo=this.recordUndo),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Pa),t.xml=r.textToDom$$module$build$src$core$utils$xml(e.xml),t.ids=e.ids,t.json=e.json,e.recordUndo!==void 0&&(t.recordUndo=e.recordUndo),t}run(e){const t=this.getEventWorkspace_();if(!this.json)throw Error("The block JSON is undefined. Either pass a block to the constructor, or call fromJson");if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!yb(t,this.ids))if(e)es(this.json,t);else for(e=0;e<this.ids.length;e++){const o=this.ids[e],s=t.getBlockById(o);s?s.dispose(!1):o===this.blockId&&console.warn("Can't uncreate non-existent block: "+o)}}},yb=function(e,t){return t.map(o=>e.getBlockById(o)).filter(o=>o&&o.isShadow()).length===t.length};l(M.EVENT,w.BLOCK_CREATE,Pa);var Fa=class extends Eo{constructor(e,t){super(t),this.type=w.THEME_CHANGE,this.themeName=e}toJson(){const e=super.toJson();if(!this.themeName)throw Error("The theme name is undefined. Either pass a theme name to the constructor, or call fromJson");return e.themeName=this.themeName,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Fa),t.themeName=e.themeName,t}};l(M.EVENT,w.THEME_CHANGE,Fa);var Ua=class extends Eo{constructor(e,t,o,s,i){super(s),this.type=w.VIEWPORT_CHANGE,this.viewTop=e,this.viewLeft=t,this.scale=o,this.oldScale=i}toJson(){const e=super.toJson();if(this.viewTop===void 0)throw Error("The view top is undefined. Either pass a value to the constructor, or call fromJson");if(this.viewLeft===void 0)throw Error("The view left is undefined. Either pass a value to the constructor, or call fromJson");if(this.scale===void 0)throw Error("The scale is undefined. Either pass a value to the constructor, or call fromJson");if(this.oldScale===void 0)throw Error("The old scale is undefined. Either pass a value to the constructor, or call fromJson");return e.viewTop=this.viewTop,e.viewLeft=this.viewLeft,e.scale=this.scale,e.oldScale=this.oldScale,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ua),t.viewTop=e.viewTop,t.viewLeft=e.viewLeft,t.scale=e.scale,t.oldScale=e.oldScale,t}};l(M.EVENT,w.VIEWPORT_CHANGE,Ua);var Z;(function(e){e[e.INPUT_VALUE=1]="INPUT_VALUE",e[e.OUTPUT_VALUE=2]="OUTPUT_VALUE",e[e.NEXT_STATEMENT=3]="NEXT_STATEMENT",e[e.PREVIOUS_STATEMENT=4]="PREVIOUS_STATEMENT"})(Z||(Z={}));var Ei=class{constructor(e){this.connectionChecker=e,this.connections=[]}addConnection(e,t){t=this.calculateIndexForYPos(t),this.connections.splice(t,0,e)}findIndexOfConnection(e,t){if(!this.connections.length)return-1;const o=this.calculateIndexForYPos(t);if(o>=this.connections.length)return-1;t=e.y;let s=o;for(;s>=0&&this.connections[s].y===t;){if(this.connections[s]===e)return s;s--}for(s=o;s<this.connections.length&&this.connections[s].y===t;){if(this.connections[s]===e)return s;s++}return-1}calculateIndexForYPos(e){if(!this.connections.length)return 0;let t=0,o=this.connections.length;for(;t<o;){const s=Math.floor((t+o)/2);if(this.connections[s].y<e)t=s+1;else if(this.connections[s].y>e)o=s;else{t=s;break}}return t}removeConnection(e,t){if(e=this.findIndexOfConnection(e,t),e===-1)throw Error("Unable to find connection in connectionDB.");this.connections.splice(e,1)}getNeighbours(e,t){function o(oe){const ze=i-s[oe].x,Fe=n-s[oe].y;return Math.sqrt(ze*ze+Fe*Fe)<=t&&L.push(s[oe]),Fe<t}const s=this.connections,i=e.x,n=e.y;e=0;let d=s.length-2,f=d;for(;e<f;)s[f].y<n?e=f:d=f,f=Math.floor((e+d)/2);const L=[];if(d=e=f,s.length){for(;e>=0&&o(e);)e--;do d++;while(d<s.length&&o(d))}return L}isInYRange(e,t,o){return Math.abs(this.connections[e].y-t)<=o}searchForClosest(e,t,o){if(!this.connections.length)return{connection:null,radius:t};const s=e.y,i=e.x;e.x=i+o.x,e.y=s+o.y;var n=this.calculateIndexForYPos(e.y);o=null;let d=t,f,L=n-1;for(;L>=0&&this.isInYRange(L,e.y,t);)f=this.connections[L],this.connectionChecker.canConnect(e,f,!0,d)&&(o=f,d=f.distanceFrom(e)),L--;for(;n<this.connections.length&&this.isInYRange(n,e.y,t);)f=this.connections[n],this.connectionChecker.canConnect(e,f,!0,d)&&(o=f,d=f.distanceFrom(e)),n++;return e.x=i,e.y=s,{connection:o,radius:d}}static init(e){const t=[];return t[Z.INPUT_VALUE]=new Ei(e),t[Z.OUTPUT_VALUE]=new Ei(e),t[Z.NEXT_STATEMENT]=new Ei(e),t[Z.PREVIOUS_STATEMENT]=new Ei(e),t}},Ha=class extends Eo{constructor(e,t,o){super(o),this.type=w.SELECTED,this.oldElementId=e??void 0,this.newElementId=t??void 0}toJson(){const e=super.toJson();return e.oldElementId=this.oldElementId,e.newElementId=this.newElementId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ha),t.oldElementId=e.oldElementId,t.newElementId=e.newElementId,t}};l(M.EVENT,w.SELECTED,Ha);var Ga=class extends Ns{constructor(e){if(super(e),this.type=w.BLOCK_DELETE,e){if(e.getParent())throw Error("Connected blocks cannot be deleted.");e.isShadow()&&(this.recordUndo=!1),this.oldXml=Ji(e),this.ids=ce(e),this.wasShadow=e.isShadow(),this.oldJson=jt(e,{addCoordinates:!0})}}toJson(){const e=super.toJson();if(!this.oldXml)throw Error("The old block XML is undefined. Either pass a block to the constructor, or call fromJson");if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(this.wasShadow===void 0)throw Error("Whether the block was a shadow is undefined. Either pass a block to the constructor, or call fromJson");if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");return e.oldXml=fo(this.oldXml),e.ids=this.ids,e.wasShadow=this.wasShadow,e.oldJson=this.oldJson,this.recordUndo||(e.recordUndo=this.recordUndo),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ga),t.oldXml=r.textToDom$$module$build$src$core$utils$xml(e.oldXml),t.ids=e.ids,t.wasShadow=e.wasShadow||t.oldXml.tagName.toLowerCase()==="shadow",t.oldJson=e.oldJson,e.recordUndo!==void 0&&(t.recordUndo=e.recordUndo),t}run(e){const t=this.getEventWorkspace_();if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");if(e)for(e=0;e<this.ids.length;e++){const o=this.ids[e],s=t.getBlockById(o);s?s.dispose(!1):o===this.blockId&&console.warn("Can't delete non-existent block: "+o)}else es(this.oldJson,t)}};l(M.EVENT,w.BLOCK_DELETE,Ga);var tm={fromJsonInternal:V$},nl={TEST_ONLY:tm};nl.fromJson=r.fromJson$$module$build$src$core$field_registry,nl.register=_o,nl.unregister=G$;var yt=class extends we{constructor(e,t,o){super(we.SKIP_SETUP),this.svgArrow=this.arrow=this.imageElement=this.menu_=this.selectedMenuItem=null,this.SERIALIZABLE=!0,this.clickTarget_=this.suffixField=this.prefixField=this.generatedOptions=null,e!==we.SKIP_SETUP&&(this.setOptions(e),o&&this.configure_(o),t&&this.setValidator(t))}fromXml(e){this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e.textContent)}loadState(e){this.loadLegacyState(yt,e)||(this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e))}initView(){this.shouldAddBorderRect_()?this.createBorderRect_():this.clickTarget_=this.sourceBlock_.getSvgRoot(),this.createTextElement_(),this.imageElement=v(R.IMAGE,{},this.fieldGroup_),this.getConstants().FIELD_DROPDOWN_SVG_ARROW?this.createSVGArrow_():this.createTextArrow_(),this.borderRect_&&G(this.borderRect_,"blocklyDropdownRect"),this.fieldGroup_&&(G(this.fieldGroup_,"blocklyField"),G(this.fieldGroup_,"blocklyDropdownField"))}shouldAddBorderRect_(){let e;return!this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW||this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW&&!((e=this.getSourceBlock())!=null&&e.isShadow())}createTextArrow_(){this.arrow=v(R.TSPAN,{},this.textElement_);let e;this.arrow.appendChild(document.createTextNode((e=this.getSourceBlock())!=null&&e.RTL?yt.ARROW_CHAR+" ":" "+yt.ARROW_CHAR)),this.getConstants().FIELD_TEXT_BASELINE_CENTER&&this.arrow.setAttribute("dominant-baseline","central");let t;(t=this.getSourceBlock())!=null&&t.RTL?this.getTextElement().insertBefore(this.arrow,this.textContent_):this.getTextElement().appendChild(this.arrow)}createSVGArrow_(){this.svgArrow=v(R.IMAGE,{height:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px",width:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px"},this.fieldGroup_),this.svgArrow.setAttributeNS(Ht,"xlink:href",this.getConstants().FIELD_DROPDOWN_SVG_ARROW_DATAURI)}showEditor_(e){var t=this.getSourceBlock();if(!t)throw new tt;this.dropdownCreate(),this.menu_&&(this.menu_.openingCoords=e&&typeof e.clientX=="number"?new P(e.clientX,e.clientY):null,sn(),e=this.menu_.render(on()),G(e,"blocklyDropdownMenu"),this.getConstants().FIELD_DROPDOWN_COLOURED_DIV&&(t=t.getColour(),e=this.sourceBlock_.getColourTertiary(),mc(t,e)),fc(this,this.dropdownDispose_.bind(this)),on().style.height=`${this.menu_.getSize().height}px`,this.menu_.focus(),this.selectedMenuItem&&this.menu_.setHighlighted(this.selectedMenuItem),this.applyColour())}dropdownCreate(){const e=this.getSourceBlock();if(!e)throw new tt;const t=new _a;t.setRole(Gt.LISTBOX),this.menu_=t;const o=this.getOptions(!1);this.selectedMenuItem=null;for(let i=0;i<o.length;i++){var s=o[i];if(s===yt.SEPARATOR){t.addChild(new gg);continue}const[n,d]=s;ri(n)?(s=new Image(n.width,n.height),s.src=n.src,s.alt=n.alt):s=n,s=new Gn(s,d),s.setRole(Gt.OPTION),s.setRightToLeft(e.RTL),s.setCheckable(!0),t.addChild(s),s.setChecked(d===this.value_),d===this.value_&&(this.selectedMenuItem=s),s.onAction(this.handleMenuActionEvent,this)}}dropdownDispose_(){this.menu_&&this.menu_.dispose(),this.selectedMenuItem=this.menu_=null,this.applyColour()}handleMenuActionEvent(e){rn(this,!0),this.onItemSelected_(this.menu_,e)}onItemSelected_(e,t){this.setValue(t.getValue())}isOptionListDynamic(){return typeof this.menuGenerator_=="function"}getOptions(e){if(!this.menuGenerator_)throw TypeError("A menu generator was never defined.");return Array.isArray(this.menuGenerator_)?this.menuGenerator_:e&&this.generatedOptions?this.generatedOptions:(this.generatedOptions=this.menuGenerator_(),this.validateOptions(this.generatedOptions),this.generatedOptions)}setOptions(e){Array.isArray(e)?(this.validateOptions(e),e=this.trimOptions(e),this.menuGenerator_=e.options,this.prefixField=e.prefix||null,this.suffixField=e.suffix||null):this.menuGenerator_=e,this.selectedOption=this.getOptions(!1)[0],this.setValue(this.selectedOption[1])}doClassValidation_(e){return this.getOptions(!0).some(t=>t[1]===e)?e:(this.sourceBlock_&&console.warn("Cannot set the dropdown's value to an unavailable option. Block type: "+this.sourceBlock_.type+", Field name: "+this.name+", Value: "+e),null)}doValueUpdate_(e){super.doValueUpdate_(e),e=this.getOptions(!0);for(let t=0,o;o=e[t];t++)o[1]===this.value_&&(this.selectedOption=o)}applyColour(){const e=this.sourceBlock_;this.borderRect_&&(this.borderRect_.setAttribute("stroke",e.getColourTertiary()),this.menu_?this.borderRect_.setAttribute("fill",e.getColourTertiary()):this.borderRect_.setAttribute("fill","transparent")),e&&this.arrow&&(e.isShadow()?this.arrow.style.fill=e.getColourSecondary():this.arrow.style.fill=e.getColour())}render_(){this.getTextContent().nodeValue="",this.imageElement.style.display="none";const e=this.selectedOption&&this.selectedOption[0];ri(e)?this.renderSelectedImage(e):this.renderSelectedText(),this.positionBorderRect_()}renderSelectedImage(e){const t=this.getSourceBlock();if(!t)throw new tt;this.imageElement.style.display="",this.imageElement.setAttributeNS(Ht,"xlink:href",e.src),this.imageElement.setAttribute("height",String(e.height)),this.imageElement.setAttribute("width",String(e.width));const o=Number(e.height);e=Number(e.width);var s=!!this.borderRect_;const i=Math.max(s?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,o+yt.IMAGE_Y_PADDING);s=s?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;let n;n=this.svgArrow?this.positionSVGArrow(e+s,i/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2):ot(this.arrow),this.size_.width=e+n+s*2,this.size_.height=i;let d=0;t.RTL?this.imageElement.setAttribute("x",`${s+n}`):(d=e+n,this.getTextElement().setAttribute("text-anchor","end"),this.imageElement.setAttribute("x",`${s}`)),this.imageElement.setAttribute("y",String(i/2-o/2)),this.positionTextElement_(d+s,e+n)}renderSelectedText(){this.getTextContent().nodeValue=this.getDisplayText_();var e=this.getTextElement();G(e,"blocklyDropdownText"),e.setAttribute("text-anchor","start");var t=!!this.borderRect_;e=Math.max(t?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,this.getConstants().FIELD_TEXT_HEIGHT);const o=ot(this.getTextElement());t=t?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;let s=0;this.svgArrow&&(s=this.positionSVGArrow(o+t,e/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2)),this.size_.width=o+s+t*2,this.size_.height=e,this.positionTextElement_(t,o)}positionSVGArrow(e,t){if(!this.svgArrow)return 0;const o=this.getSourceBlock();if(!o)throw new tt;const s=this.borderRect_?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0,i=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_PADDING,n=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE;return this.svgArrow.setAttribute("transform","translate("+(o.RTL?s:e+i)+","+t+")"),n+i}getText_(){if(!this.selectedOption)return null;const e=this.selectedOption[0];if(ri(e))return e.alt;if(typeof HTMLElement<"u"&&e instanceof HTMLElement){let t,o;return(o=(t=e.title)!=null?t:e.ariaLabel)!=null?o:e.innerText}return typeof e=="string"?e:(console.warn("Can't get text for existing dropdown option. If you're using HTMLElement dropdown options in node, ensure you're using jsdom-global or similar."),null)}static fromJson(e){if(!e.options)throw Error("options are required for the dropdown field. The options property must be assigned an array of [humanReadableValue, languageNeutralValue] tuples.");return new this(e.options,void 0,e)}trimOptions(e){let t=!1;const o=e.map(d=>{if(d===yt.SEPARATOR)return d;const[f,L]=d;return typeof f=="string"?[Je(f),L]:(t=!0,[ri(f)?Object.assign({},f,{alt:Je(f.alt)}):Object.assign({},f),L])});if(t||e.length<2)return{options:o};var s=o.map(([d])=>d),i=Wi(s);e=kc(s,i);const n=Rc(s,i);return!e&&!n||i<=e+n?{options:o}:(i=e?s[0].substring(0,e-1):void 0,s=n?s[0].substr(1-n):void 0,{options:this.applyTrim(o,e,n),prefix:i,suffix:s})}applyTrim(e,t,o){return e.map(([s,i])=>[s.substring(t,s.length-o),i])}validateOptions(e){if(!Array.isArray(e))throw TypeError("FieldDropdown options must be an array.");if(!e.length)throw TypeError("FieldDropdown options must not be an empty array.");let t=!1;for(let o=0;o<e.length;o++){const s=e[o];Array.isArray(s)||s===yt.SEPARATOR?typeof s[1]!="string"?(t=!0,console.error(`Invalid option[${o}]: Each FieldDropdown option id must be a string.
617
+ `);var nl=class{constructor(e,t){this.workspace=e,this.text="",this.collapsed=!1,this.deletable=this.movable=this.editable=!0,this.location=new P(0,0),this.disposing=this.disposed=!1,this.id=t&&!e.getCommentById(t)?t:rt(),this.size=_r.defaultCommentSize,e.addTopComment(this),this.fireCreateEvent()}fireCreateEvent(){J()&&_(new(U(w.COMMENT_CREATE))(this))}fireDeleteEvent(){J()&&_(new(U(w.COMMENT_DELETE))(this))}fireChangeEvent(e,t){J()&&_(new(U(w.COMMENT_CHANGE))(this,e,t))}fireCollapseEvent(e){J()&&_(new(U(w.COMMENT_COLLAPSE))(this,e))}setText(e){const t=this.text;this.text=e,this.fireChangeEvent(t,e)}getText(){return this.text}setSize(e){const t=new(U(w.COMMENT_RESIZE))(this);this.size=e,t.recordCurrentSizeAsNewSize(),_(t)}getSize(){return this.size}setCollapsed(e){this.collapsed=e,this.fireCollapseEvent(e)}isCollapsed(){return this.collapsed}setEditable(e){this.editable=e}isEditable(){return this.isOwnEditable()&&!this.workspace.isReadOnly()}isOwnEditable(){return this.editable}setMovable(e){this.movable=e}isMovable(){return this.isOwnMovable()&&!this.workspace.isReadOnly()&&!this.workspace.isFlyout}isOwnMovable(){return this.movable}setDeletable(e){this.deletable=e}isDeletable(){return this.isOwnDeletable()&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()&&!this.workspace.isFlyout}isOwnDeletable(){return this.deletable}moveTo(e,t){const o=new(U(w.COMMENT_MOVE))(this);t&&o.setReason(t),this.location=e,o.recordNew(),_(o)}getRelativeToSurfaceXY(){return this.location}dispose(){this.disposing=!0,this.fireDeleteEvent(),this.workspace.removeTopComment(this),this.disposed=!0}isDisposed(){return this.disposed}isDeadOrDying(){return this.disposing||this.disposed}},yo=class extends nl{constructor(e,t){super(e,t),this.dragStrategy=new qg(this),this.workspace=e,this.view=new _r(e,this.id),this.view.setSize(this.getSize()),this.view.setEditable(this.isEditable()),this.view.getSvgRoot().setAttribute("data-id",this.id),this.view.getSvgRoot().setAttribute("id",this.id),this.addModelUpdateBindings(),z(this.view.getSvgRoot(),"pointerdown",this,this.startGesture),z(this.view.getSvgRoot(),"wheel",this,o=>{o.stopPropagation()})}addModelUpdateBindings(){this.view.addTextChangeListener((e,t)=>void super.setText(t)),this.view.addSizeChangeListener((e,t)=>void super.setSize(t)),this.view.addOnCollapseListener(()=>void super.setCollapsed(this.view.isCollapsed())),this.view.addDisposeListener(()=>{this.isDeadOrDying()||this.dispose()})}setText(e){this.view.setText(e)}setPlaceholderText(e){this.view.setPlaceholderText(e)}setSize(e){this.view.setSize(e)}setCollapsed(e){this.view.setCollapsed(e)}setEditable(e){super.setEditable(e),this.view.setEditable(this.isEditable())}getSvgRoot(){return this.view.getSvgRoot()}getSize(){return super.getSize()}getBoundingRectangle(){const e=this.getRelativeToSurfaceXY();var t,o;const s=(o=(t=this.view)==null?void 0:t.getSize())!=null?o:this.getSize();return this.workspace.RTL?(t=e.x-s.width,o=e.x):(t=e.x,o=e.x+s.width),new ye(e.y,e.y+s.height,t,o)}moveBy(e,t,o){const s=this.getRelativeToSurfaceXY();e=new P(s.x+e,s.y+t),this.moveTo(e,o)}moveTo(e,t){super.moveTo(e,t),this.view.moveTo(e)}moveDuringDrag(e){this.location=e,this.view.moveTo(e)}setDragging(e){e?G(this.getSvgRoot(),"blocklyDragging"):Te(this.getSvgRoot(),"blocklyDragging")}dispose(){this.disposing=!0;const e=r.getFocusManager$$module$build$src$core$focus_manager();e.getFocusedNode()===this&&setTimeout(()=>e.focusTree(this.workspace),0),this.view.isDeadOrDying()||this.view.dispose(),super.dispose()}startGesture(e){const t=this.workspace.getGesture(e);t&&(t.handleCommentStart(e,this),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this))}setDeleteStyle(e){e?G(this.getSvgRoot(),"blocklyDraggingDelete"):Te(this.getSvgRoot(),"blocklyDraggingDelete")}isCopyable(){return this.isOwnMovable()&&this.isOwnDeletable()}isMovable(){return this.dragStrategy.isMovable()}startDrag(){this.dragStrategy.startDrag()}drag(e){this.dragStrategy.drag(e)}endDrag(){this.dragStrategy.endDrag()}revertDrag(){this.dragStrategy.revertDrag()}select(){G(this.getSvgRoot(),"blocklySelected"),V(this)}unselect(){Te(this.getSvgRoot(),"blocklySelected"),V(null)}toCopyData(){return{paster:Gn.TYPE,commentState:js(this,{addCoordinates:!0})}}showContextMenu(e){const t=Ee.registry.getContextMenuOptions({comment:this,focusedNode:this},e);let o;o=e instanceof PointerEvent?new P(e.clientX,e.clientY):Ys(this.workspace,this.getRelativeToSurfaceXY()).translate(10,10),ii(e,t,this.workspace.RTL,this.workspace,o)}snapToGrid(){if(!this.isDeadOrDying()){var e=this.workspace.getGrid();if(e!=null&&e.shouldSnap()){var t=this.getRelativeToSurfaceXY();e=e.alignXY(t),e!==t&&this.moveTo(e,["snap"])}}}getEditorFocusableNode(){return this.view.getEditorFocusableNode()}getFocusableElement(){return this.getSvgRoot()}getFocusableTree(){return this.workspace}onNodeFocus(){this.select();let e;(e=this.workspace.getLayerManager())==null||e.append(this,us)}onNodeBlur(){this.unselect()}canBeFocused(){return!0}},Ot={};Ot.appendDomToWorkspace=D$,Ot.blockToDom=ts,Ot.blockToDomWithXY=qi,Ot.clearWorkspaceAndLoadFromXml=M$,Ot.deleteNext=W$,Ot.domToBlock=r.domToBlock$$module$build$src$core$xml,Ot.domToBlockInternal=Is,Ot.domToPrettyText=L$,Ot.domToText=fo,Ot.domToVariables=eu,Ot.domToWorkspace=r.domToWorkspace$$module$build$src$core$xml,Ot.loadWorkspaceComment=Qc,Ot.saveWorkspaceComment=Ji,Ot.variablesToDom=qc,Ot.workspaceToDom=O$;var Ua=class extends Ns{constructor(e){super(e),this.type=w.BLOCK_CREATE,e&&(e.isShadow()&&(this.recordUndo=!1),this.xml=qi(e),this.ids=ce(e),this.json=jt(e,{addCoordinates:!0}))}toJson(){const e=super.toJson();if(!this.xml)throw Error("The block XML is undefined. Either pass a block to the constructor, or call fromJson");if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!this.json)throw Error("The block JSON is undefined. Either pass a block to the constructor, or call fromJson");return e.xml=fo(this.xml),e.ids=this.ids,e.json=this.json,this.recordUndo||(e.recordUndo=this.recordUndo),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ua),t.xml=r.textToDom$$module$build$src$core$utils$xml(e.xml),t.ids=e.ids,t.json=e.json,e.recordUndo!==void 0&&(t.recordUndo=e.recordUndo),t}run(e){const t=this.getEventWorkspace_();if(!this.json)throw Error("The block JSON is undefined. Either pass a block to the constructor, or call fromJson");if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!Cb(t,this.ids))if(e)es(this.json,t);else for(e=0;e<this.ids.length;e++){const o=this.ids[e],s=t.getBlockById(o);s?s.dispose(!1):o===this.blockId&&console.warn("Can't uncreate non-existent block: "+o)}}},Cb=function(e,t){return t.map(o=>e.getBlockById(o)).filter(o=>o&&o.isShadow()).length===t.length};l(M.EVENT,w.BLOCK_CREATE,Ua);var Ha=class extends Eo{constructor(e,t){super(t),this.type=w.THEME_CHANGE,this.themeName=e}toJson(){const e=super.toJson();if(!this.themeName)throw Error("The theme name is undefined. Either pass a theme name to the constructor, or call fromJson");return e.themeName=this.themeName,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ha),t.themeName=e.themeName,t}};l(M.EVENT,w.THEME_CHANGE,Ha);var Ga=class extends Eo{constructor(e,t,o,s,i){super(s),this.type=w.VIEWPORT_CHANGE,this.viewTop=e,this.viewLeft=t,this.scale=o,this.oldScale=i}toJson(){const e=super.toJson();if(this.viewTop===void 0)throw Error("The view top is undefined. Either pass a value to the constructor, or call fromJson");if(this.viewLeft===void 0)throw Error("The view left is undefined. Either pass a value to the constructor, or call fromJson");if(this.scale===void 0)throw Error("The scale is undefined. Either pass a value to the constructor, or call fromJson");if(this.oldScale===void 0)throw Error("The old scale is undefined. Either pass a value to the constructor, or call fromJson");return e.viewTop=this.viewTop,e.viewLeft=this.viewLeft,e.scale=this.scale,e.oldScale=this.oldScale,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ga),t.viewTop=e.viewTop,t.viewLeft=e.viewLeft,t.scale=e.scale,t.oldScale=e.oldScale,t}};l(M.EVENT,w.VIEWPORT_CHANGE,Ga);var Z;(function(e){e[e.INPUT_VALUE=1]="INPUT_VALUE",e[e.OUTPUT_VALUE=2]="OUTPUT_VALUE",e[e.NEXT_STATEMENT=3]="NEXT_STATEMENT",e[e.PREVIOUS_STATEMENT=4]="PREVIOUS_STATEMENT"})(Z||(Z={}));var Ei=class{constructor(e){this.connectionChecker=e,this.connections=[]}addConnection(e,t){t=this.calculateIndexForYPos(t),this.connections.splice(t,0,e)}findIndexOfConnection(e,t){if(!this.connections.length)return-1;const o=this.calculateIndexForYPos(t);if(o>=this.connections.length)return-1;t=e.y;let s=o;for(;s>=0&&this.connections[s].y===t;){if(this.connections[s]===e)return s;s--}for(s=o;s<this.connections.length&&this.connections[s].y===t;){if(this.connections[s]===e)return s;s++}return-1}calculateIndexForYPos(e){if(!this.connections.length)return 0;let t=0,o=this.connections.length;for(;t<o;){const s=Math.floor((t+o)/2);if(this.connections[s].y<e)t=s+1;else if(this.connections[s].y>e)o=s;else{t=s;break}}return t}removeConnection(e,t){if(e=this.findIndexOfConnection(e,t),e===-1)throw Error("Unable to find connection in connectionDB.");this.connections.splice(e,1)}getNeighbours(e,t){function o(oe){const ze=i-s[oe].x,Fe=n-s[oe].y;return Math.sqrt(ze*ze+Fe*Fe)<=t&&L.push(s[oe]),Fe<t}const s=this.connections,i=e.x,n=e.y;e=0;let d=s.length-2,f=d;for(;e<f;)s[f].y<n?e=f:d=f,f=Math.floor((e+d)/2);const L=[];if(d=e=f,s.length){for(;e>=0&&o(e);)e--;do d++;while(d<s.length&&o(d))}return L}isInYRange(e,t,o){return Math.abs(this.connections[e].y-t)<=o}searchForClosest(e,t,o){if(!this.connections.length)return{connection:null,radius:t};const s=e.y,i=e.x;e.x=i+o.x,e.y=s+o.y;var n=this.calculateIndexForYPos(e.y);o=null;let d=t,f,L=n-1;for(;L>=0&&this.isInYRange(L,e.y,t);)f=this.connections[L],this.connectionChecker.canConnect(e,f,!0,d)&&(o=f,d=f.distanceFrom(e)),L--;for(;n<this.connections.length&&this.isInYRange(n,e.y,t);)f=this.connections[n],this.connectionChecker.canConnect(e,f,!0,d)&&(o=f,d=f.distanceFrom(e)),n++;return e.x=i,e.y=s,{connection:o,radius:d}}static init(e){const t=[];return t[Z.INPUT_VALUE]=new Ei(e),t[Z.OUTPUT_VALUE]=new Ei(e),t[Z.NEXT_STATEMENT]=new Ei(e),t[Z.PREVIOUS_STATEMENT]=new Ei(e),t}},Va=class extends Eo{constructor(e,t,o){super(o),this.type=w.SELECTED,this.oldElementId=e??void 0,this.newElementId=t??void 0}toJson(){const e=super.toJson();return e.oldElementId=this.oldElementId,e.newElementId=this.newElementId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Va),t.oldElementId=e.oldElementId,t.newElementId=e.newElementId,t}};l(M.EVENT,w.SELECTED,Va);var Wa=class extends Ns{constructor(e){if(super(e),this.type=w.BLOCK_DELETE,e){if(e.getParent())throw Error("Connected blocks cannot be deleted.");e.isShadow()&&(this.recordUndo=!1),this.oldXml=qi(e),this.ids=ce(e),this.wasShadow=e.isShadow(),this.oldJson=jt(e,{addCoordinates:!0})}}toJson(){const e=super.toJson();if(!this.oldXml)throw Error("The old block XML is undefined. Either pass a block to the constructor, or call fromJson");if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(this.wasShadow===void 0)throw Error("Whether the block was a shadow is undefined. Either pass a block to the constructor, or call fromJson");if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");return e.oldXml=fo(this.oldXml),e.ids=this.ids,e.wasShadow=this.wasShadow,e.oldJson=this.oldJson,this.recordUndo||(e.recordUndo=this.recordUndo),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Wa),t.oldXml=r.textToDom$$module$build$src$core$utils$xml(e.oldXml),t.ids=e.ids,t.wasShadow=e.wasShadow||t.oldXml.tagName.toLowerCase()==="shadow",t.oldJson=e.oldJson,e.recordUndo!==void 0&&(t.recordUndo=e.recordUndo),t}run(e){const t=this.getEventWorkspace_();if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");if(e)for(e=0;e<this.ids.length;e++){const o=this.ids[e],s=t.getBlockById(o);s?s.dispose(!1):o===this.blockId&&console.warn("Can't delete non-existent block: "+o)}else es(this.oldJson,t)}};l(M.EVENT,w.BLOCK_DELETE,Wa);var im={fromJsonInternal:Y$},ll={TEST_ONLY:im};ll.fromJson=r.fromJson$$module$build$src$core$field_registry,ll.register=_o,ll.unregister=z$;var yt=class extends we{constructor(e,t,o){super(we.SKIP_SETUP),this.svgArrow=this.arrow=this.imageElement=this.menu_=this.selectedMenuItem=null,this.SERIALIZABLE=!0,this.clickTarget_=this.suffixField=this.prefixField=this.generatedOptions=null,e!==we.SKIP_SETUP&&(this.setOptions(e),o&&this.configure_(o),t&&this.setValidator(t))}fromXml(e){this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e.textContent)}loadState(e){this.loadLegacyState(yt,e)||(this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e))}initView(){this.shouldAddBorderRect_()?this.createBorderRect_():this.clickTarget_=this.sourceBlock_.getSvgRoot(),this.createTextElement_(),this.imageElement=v(R.IMAGE,{},this.fieldGroup_),this.getConstants().FIELD_DROPDOWN_SVG_ARROW?this.createSVGArrow_():this.createTextArrow_(),this.borderRect_&&G(this.borderRect_,"blocklyDropdownRect"),this.fieldGroup_&&(G(this.fieldGroup_,"blocklyField"),G(this.fieldGroup_,"blocklyDropdownField"))}shouldAddBorderRect_(){let e;return!this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW||this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW&&!((e=this.getSourceBlock())!=null&&e.isShadow())}createTextArrow_(){this.arrow=v(R.TSPAN,{},this.textElement_);let e;this.arrow.appendChild(document.createTextNode((e=this.getSourceBlock())!=null&&e.RTL?yt.ARROW_CHAR+" ":" "+yt.ARROW_CHAR)),this.getConstants().FIELD_TEXT_BASELINE_CENTER&&this.arrow.setAttribute("dominant-baseline","central");let t;(t=this.getSourceBlock())!=null&&t.RTL?this.getTextElement().insertBefore(this.arrow,this.textContent_):this.getTextElement().appendChild(this.arrow)}createSVGArrow_(){this.svgArrow=v(R.IMAGE,{height:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px",width:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px"},this.fieldGroup_),this.svgArrow.setAttributeNS(Ht,"xlink:href",this.getConstants().FIELD_DROPDOWN_SVG_ARROW_DATAURI)}showEditor_(e){var t=this.getSourceBlock();if(!t)throw new tt;this.dropdownCreate(),this.menu_&&(this.menu_.openingCoords=e&&typeof e.clientX=="number"?new P(e.clientX,e.clientY):null,rn(),e=this.menu_.render(sn()),G(e,"blocklyDropdownMenu"),this.getConstants().FIELD_DROPDOWN_COLOURED_DIV&&(t=t.getColour(),e=this.sourceBlock_.getColourTertiary(),_c(t,e)),bc(this,this.dropdownDispose_.bind(this)),sn().style.height=`${this.menu_.getSize().height}px`,this.menu_.focus(),this.selectedMenuItem&&this.menu_.setHighlighted(this.selectedMenuItem),this.applyColour())}dropdownCreate(){const e=this.getSourceBlock();if(!e)throw new tt;const t=new Ta;t.setRole(Gt.LISTBOX),this.menu_=t;const o=this.getOptions(!1);this.selectedMenuItem=null;for(let i=0;i<o.length;i++){var s=o[i];if(s===yt.SEPARATOR){t.addChild(new _g);continue}const[n,d]=s;ri(n)?(s=new Image(n.width,n.height),s.src=n.src,s.alt=n.alt):s=n,s=new Vn(s,d),s.setRole(Gt.OPTION),s.setRightToLeft(e.RTL),s.setCheckable(!0),t.addChild(s),s.setChecked(d===this.value_),d===this.value_&&(this.selectedMenuItem=s),s.onAction(this.handleMenuActionEvent,this)}}dropdownDispose_(){this.menu_&&this.menu_.dispose(),this.selectedMenuItem=this.menu_=null,this.applyColour()}handleMenuActionEvent(e){nn(this,!0),this.onItemSelected_(this.menu_,e)}onItemSelected_(e,t){this.setValue(t.getValue())}isOptionListDynamic(){return typeof this.menuGenerator_=="function"}getOptions(e){if(!this.menuGenerator_)throw TypeError("A menu generator was never defined.");return Array.isArray(this.menuGenerator_)?this.menuGenerator_:e&&this.generatedOptions?this.generatedOptions:(this.generatedOptions=this.menuGenerator_(),this.validateOptions(this.generatedOptions),this.generatedOptions)}setOptions(e){Array.isArray(e)?(this.validateOptions(e),e=this.trimOptions(e),this.menuGenerator_=e.options,this.prefixField=e.prefix||null,this.suffixField=e.suffix||null):this.menuGenerator_=e,this.selectedOption=this.getOptions(!1)[0],this.setValue(this.selectedOption[1])}doClassValidation_(e){return this.getOptions(!0).some(t=>t[1]===e)?e:(this.sourceBlock_&&console.warn("Cannot set the dropdown's value to an unavailable option. Block type: "+this.sourceBlock_.type+", Field name: "+this.name+", Value: "+e),null)}doValueUpdate_(e){super.doValueUpdate_(e),e=this.getOptions(!0);for(let t=0,o;o=e[t];t++)o[1]===this.value_&&(this.selectedOption=o)}applyColour(){const e=this.sourceBlock_;this.borderRect_&&(this.borderRect_.setAttribute("stroke",e.getColourTertiary()),this.menu_?this.borderRect_.setAttribute("fill",e.getColourTertiary()):this.borderRect_.setAttribute("fill","transparent")),e&&this.arrow&&(e.isShadow()?this.arrow.style.fill=e.getColourSecondary():this.arrow.style.fill=e.getColour())}render_(){this.getTextContent().nodeValue="",this.imageElement.style.display="none";const e=this.selectedOption&&this.selectedOption[0];ri(e)?this.renderSelectedImage(e):this.renderSelectedText(),this.positionBorderRect_()}renderSelectedImage(e){const t=this.getSourceBlock();if(!t)throw new tt;this.imageElement.style.display="",this.imageElement.setAttributeNS(Ht,"xlink:href",e.src),this.imageElement.setAttribute("height",String(e.height)),this.imageElement.setAttribute("width",String(e.width));const o=Number(e.height);e=Number(e.width);var s=!!this.borderRect_;const i=Math.max(s?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,o+yt.IMAGE_Y_PADDING);s=s?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;let n;n=this.svgArrow?this.positionSVGArrow(e+s,i/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2):ot(this.arrow),this.size_.width=e+n+s*2,this.size_.height=i;let d=0;t.RTL?this.imageElement.setAttribute("x",`${s+n}`):(d=e+n,this.getTextElement().setAttribute("text-anchor","end"),this.imageElement.setAttribute("x",`${s}`)),this.imageElement.setAttribute("y",String(i/2-o/2)),this.positionTextElement_(d+s,e+n)}renderSelectedText(){this.getTextContent().nodeValue=this.getDisplayText_();var e=this.getTextElement();G(e,"blocklyDropdownText"),e.setAttribute("text-anchor","start");var t=!!this.borderRect_;e=Math.max(t?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,this.getConstants().FIELD_TEXT_HEIGHT);const o=ot(this.getTextElement());t=t?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;let s=0;this.svgArrow&&(s=this.positionSVGArrow(o+t,e/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2)),this.size_.width=o+s+t*2,this.size_.height=e,this.positionTextElement_(t,o)}positionSVGArrow(e,t){if(!this.svgArrow)return 0;const o=this.getSourceBlock();if(!o)throw new tt;const s=this.borderRect_?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0,i=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_PADDING,n=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE;return this.svgArrow.setAttribute("transform","translate("+(o.RTL?s:e+i)+","+t+")"),n+i}getText_(){if(!this.selectedOption)return null;const e=this.selectedOption[0];if(ri(e))return e.alt;if(typeof HTMLElement<"u"&&e instanceof HTMLElement){let t,o;return(o=(t=e.title)!=null?t:e.ariaLabel)!=null?o:e.innerText}return typeof e=="string"?e:(console.warn("Can't get text for existing dropdown option. If you're using HTMLElement dropdown options in node, ensure you're using jsdom-global or similar."),null)}static fromJson(e){if(!e.options)throw Error("options are required for the dropdown field. The options property must be assigned an array of [humanReadableValue, languageNeutralValue] tuples.");return new this(e.options,void 0,e)}trimOptions(e){let t=!1;const o=e.map(d=>{if(d===yt.SEPARATOR)return d;const[f,L]=d;return typeof f=="string"?[Je(f),L]:(t=!0,[ri(f)?Object.assign({},f,{alt:Je(f.alt)}):Object.assign({},f),L])});if(t||e.length<2)return{options:o};var s=o.map(([d])=>d),i=zi(s);e=wc(s,i);const n=Oc(s,i);return!e&&!n||i<=e+n?{options:o}:(i=e?s[0].substring(0,e-1):void 0,s=n?s[0].substr(1-n):void 0,{options:this.applyTrim(o,e,n),prefix:i,suffix:s})}applyTrim(e,t,o){return e.map(([s,i])=>[s.substring(t,s.length-o),i])}validateOptions(e){if(!Array.isArray(e))throw TypeError("FieldDropdown options must be an array.");if(!e.length)throw TypeError("FieldDropdown options must not be an empty array.");let t=!1;for(let o=0;o<e.length;o++){const s=e[o];Array.isArray(s)||s===yt.SEPARATOR?typeof s[1]!="string"?(t=!0,console.error(`Invalid option[${o}]: Each FieldDropdown option id must be a string.
618
618
  Found ${s[1]} in: ${s}`)):!s[0]||typeof s[0]=="string"||ri(s[0])||typeof HTMLElement<"u"&&s[0]instanceof HTMLElement||(t=!0,console.error(`Invalid option[${o}]: Each FieldDropdown option must have a string
619
619
  label, image description, or HTML element. Found ${s[0]} in: ${s}`)):(t=!0,console.error(`Invalid option[${o}]: Each FieldDropdown option must be an array or
620
- the string literal 'separator'. Found: ${s}`))}if(t)throw TypeError("Found invalid FieldDropdown options.")}};yt.SEPARATOR="separator",yt.ARROW_CHAR="▾",yt.IMAGE_Y_OFFSET=5,yt.IMAGE_Y_PADDING=yt.IMAGE_Y_OFFSET*2,_o("field_dropdown",yt);var Bs=class{constructor(e,t,o,s){this.name=e,this.startHats=!1,this.blockStyles=t||Object.create(null),this.categoryStyles=o||Object.create(null),this.componentStyles=s||Object.create(null),this.fontStyle=Object.create(null),l(M.THEME,e,this,!0)}getClassName(){return this.name+"-theme"}setBlockStyle(e,t){this.blockStyles[e]=t}setCategoryStyle(e,t){this.categoryStyles[e]=t}getComponentStyle(e){if(e=this.componentStyles[e],!e)return null;if(typeof e=="string"){const t=this.getComponentStyle(e);if(t)return t}return`${e}`}setComponentStyle(e,t){this.componentStyles[e]=t}setFontStyle(e){this.fontStyle=e}setStartHats(e){this.startHats=e}static defineTheme(e,t){e=e.toLowerCase();const o=new Bs(e);let s=t.base;if(s){if(typeof s=="string"){let i;s=(i=D(M.THEME,s))!=null?i:void 0}s instanceof Bs&&(He(o,s),o.name=e)}return He(o.blockStyles,t.blockStyles),He(o.categoryStyles,t.categoryStyles),He(o.componentStyles,t.componentStyles),He(o.fontStyle,t.fontStyle),t.startHats!==null&&(o.startHats=t.startHats),o}},vb={colour_blocks:{colourPrimary:"20"},list_blocks:{colourPrimary:"260"},logic_blocks:{colourPrimary:"210"},loop_blocks:{colourPrimary:"120"},math_blocks:{colourPrimary:"230"},procedure_blocks:{colourPrimary:"290"},text_blocks:{colourPrimary:"160"},variable_blocks:{colourPrimary:"330"},variable_dynamic_blocks:{colourPrimary:"310"},hat_blocks:{colourPrimary:"330",hat:"cap"}},Ib={colour_category:{colour:"20"},list_category:{colour:"260"},logic_category:{colour:"210"},loop_category:{colour:"120"},math_category:{colour:"230"},procedure_category:{colour:"290"},text_category:{colour:"160"},variable_category:{colour:"330"},variable_dynamic_category:{colour:"310"}},ll=new Bs("classic",vb,Ib),vo=class{constructor(e){this.gridPattern=null,this.getMetrics=this.setMetrics=void 0;let t=null,o=!1;var s=!1,i=!1,n=!1,d=!1,f=!1;const L=!!e.readOnly;if(!L){var oe;t=Pr((oe=e.toolbox)!=null?oe:null),o=Fr(t),s=e.trashcan,s=s===void 0?o:s,i=e.collapse,i=i===void 0?o:i,n=e.comments,n=n===void 0?o:n,d=e.disable,d=d===void 0?o:d,f=e.sounds,f=f===void 0?!0:f}oe=e.maxTrashcanContents,s?oe===void 0&&(oe=32):oe=0;const ze=!!e.rtl;let Fe=e.horizontalLayout;Fe===void 0&&(Fe=!1);var vt=e.toolboxPosition!=="end";vt=Fe?vt?be.TOP:be.BOTTOM:vt===ze?be.RIGHT:be.LEFT;let jo=e.css;jo===void 0&&(jo=!0);let Ao="https://blockly-demo.appspot.com/static/media/";e.media&&(Ao=e.media.endsWith("/")?e.media:e.media+"/");const Wf=e.oneBasedIndex,oT=e.renderer||"geras",sT=e.plugins||{};let Ph=e.modalInputs;Ph===void 0&&(Ph=!0),this.RTL=ze,this.oneBasedIndex=Wf===void 0?!0:Wf,this.collapse=i,this.comments=n,this.disable=d,this.readOnly=L,this.maxBlocks=e.maxBlocks||1/0;let zf;this.maxInstances=(zf=e.maxInstances)!=null?zf:null,this.modalInputs=Ph,this.pathToMedia=Ao,this.hasCategories=o,this.moveOptions=vo.parseMoveOptions(e,o),this.hasScrollbars=!!this.moveOptions.scrollbars,this.hasTrashcan=s,this.maxTrashcanContents=oe,this.hasSounds=f,this.hasCss=jo,this.horizontalLayout=Fe,this.languageTree=t,this.gridOptions=vo.parseGridOptions(e),this.zoomOptions=vo.parseZoomOptions(e),this.toolboxPosition=vt,this.theme=vo.parseThemeOptions(e),this.renderer=oT;let Yf;this.rendererOverrides=(Yf=e.rendererOverrides)!=null?Yf:null;let Xf;this.parentWorkspace=(Xf=e.parentWorkspace)!=null?Xf:null,this.plugins=sT}static parseMoveOptions(e,t){const o=e.move||{},s={};return o.scrollbars===void 0&&e.scrollbars===void 0?s.scrollbars=t:typeof o.scrollbars=="object"?(s.scrollbars={horizontal:!!o.scrollbars.horizontal,vertical:!!o.scrollbars.vertical},s.scrollbars.horizontal&&s.scrollbars.vertical?s.scrollbars=!0:s.scrollbars.horizontal||s.scrollbars.vertical||(s.scrollbars=!1)):s.scrollbars=!!o.scrollbars||!!e.scrollbars,s.wheel=s.scrollbars&&o.wheel!==void 0?!!o.wheel:typeof s.scrollbars=="object",s.drag=s.scrollbars?o.drag===void 0?!0:!!o.drag:!1,s}static parseZoomOptions(e){e=e.zoom||{};const t={};return t.controls=e.controls===void 0?!1:!!e.controls,t.wheel=e.wheel===void 0?!1:!!e.wheel,t.startScale=e.startScale===void 0?1:Number(e.startScale),t.maxScale=e.maxScale===void 0?3:Number(e.maxScale),t.minScale=e.minScale===void 0?.3:Number(e.minScale),t.scaleSpeed=e.scaleSpeed===void 0?1.2:Number(e.scaleSpeed),t.pinch=e.pinch===void 0?t.wheel||t.controls:!!e.pinch,t}static parseGridOptions(e){e=e.grid||{};const t={};return t.spacing=Number(e.spacing)||0,t.colour=e.colour||"#888",t.length=e.length===void 0?1:Number(e.length),t.snap=t.spacing>0&&!!e.snap,t}static parseThemeOptions(e){return e=e.theme||ll,typeof e=="string"?D(M.THEME,e):e instanceof Bs?e:Bs.defineTheme(e.name||"builtin"+Re(),e)}},om=class{constructor(e,t){this.bubble=e,this.workspace=t,this.startLoc=null}isMovable(){return!0}startDrag(){this.startLoc=this.bubble.getRelativeToSurfaceXY(),this.workspace.setResizesEnabled(!1);let e;(e=this.workspace.getLayerManager())==null||e.moveToDragLayer(this.bubble),this.bubble.setDragging&&this.bubble.setDragging(!0)}drag(e){this.bubble.moveDuringDrag(e)}endDrag(){this.workspace.setResizesEnabled(!0);let e;(e=this.workspace.getLayerManager())==null||e.moveOffDragLayer(this.bubble,sl),this.bubble.setDragging(!1)}revertDrag(){this.startLoc&&this.bubble.moveDuringDrag(this.startLoc)}},zt,Oe=class{constructor(e,t,o,s){this.workspace=e,this.anchor=t,this.ownerRect=o,this.size=new ve(0,0),this.colour="#ffffff",this.disposed=!1,this.relativeLeft=this.relativeTop=0,this.dragStrategy=new om(this,this.workspace),this.id=Re(),this.svgRoot=v(R.G,{class:"blocklyBubble"},e.getBubbleCanvas()),e=v(R.G,{class:"blocklyEmboss"},this.svgRoot),this.tail=v(R.PATH,{class:"blocklyBubbleTail"},e),this.background=v(R.RECT,{class:"blocklyDraggable",x:0,y:0,rx:zt.BORDER_WIDTH,ry:zt.BORDER_WIDTH},e),this.contentContainer=v(R.G,{},this.svgRoot),this.focusableElement=s??this.svgRoot,this.focusableElement.setAttribute("id",this.id),z(this.background,"pointerdown",this,this.onMouseDown)}dispose(){ke(this.svgRoot),this.disposed=!0}setAnchorLocation(e,t=!1){this.anchor=e,t?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor(),this.renderTail()}setPositionRelativeToAnchor(e,t){this.relativeLeft=e,this.relativeTop=t,this.positionRelativeToAnchor(),this.renderTail()}getSize(){return this.size}setSize(e,t=!1){e.width=Math.max(e.width,zt.MIN_SIZE),e.height=Math.max(e.height,zt.MIN_SIZE),this.size=e,this.background.setAttribute("width",`${e.width}`),this.background.setAttribute("height",`${e.height}`),t?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor(),this.renderTail()}getColour(){return this.colour}setColour(e){this.colour=e,this.tail.setAttribute("fill",e),this.background.setAttribute("fill",e)}onMouseDown(e){let t;(t=this.workspace.getGesture(e))==null||t.handleBubbleStart(e,this),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this)}positionRelativeToAnchor(){let e=this.anchor.x;e=this.workspace.RTL?e-(this.relativeLeft+this.size.width):e+this.relativeLeft,this.moveTo(e,this.relativeTop+this.anchor.y)}moveTo(e,t){this.svgRoot.setAttribute("transform",`translate(${e}, ${t})`)}positionByRect(e=new ye(0,0,0,0)){var t=this.workspace.getMetricsManager().getViewMetrics(!0),o=this.getOptimalRelativeLeft(t),s=this.getOptimalRelativeTop(t);const i={x:o,y:-this.size.height-this.workspace.getRenderer().getConstants().MIN_BLOCK_HEIGHT},n={x:-this.size.width-30,y:s};s={x:e.getWidth(),y:s};var d={x:o,y:e.getHeight()};o=e.getWidth()<e.getHeight()?s:d,e=e.getWidth()<e.getHeight()?d:s,s=this.getOverlap(i,t),d=this.getOverlap(n,t);const f=this.getOverlap(o,t);t=this.getOverlap(e,t),t=Math.max(s,d,f,t),s===t?(this.relativeLeft=i.x,this.relativeTop=i.y):d===t?(this.relativeLeft=n.x,this.relativeTop=n.y):f===t?(this.relativeLeft=o.x,this.relativeTop=o.y):(this.relativeLeft=e.x,this.relativeTop=e.y),this.positionRelativeToAnchor()}getOverlap(e,t){var o=this.workspace.RTL?this.anchor.x-e.x-this.size.width:e.x+this.anchor.x;return e=e.y+this.anchor.y,Math.max(0,Math.min(1,(Math.min(o+this.size.width,t.left+t.width)-Math.max(o,t.left))*(Math.min(e+this.size.height,t.top+t.height)-Math.max(e,t.top))/(this.size.width*this.size.height)))}getOptimalRelativeLeft(e){let t=-this.size.width/4;if(this.size.width>e.width)return t;if(e=this.getWorkspaceViewRect(e),this.workspace.RTL){var o=this.anchor.x-t;o-this.size.width<e.left?t=-(e.left-this.anchor.x+this.size.width):o>e.right&&(t=-(e.right-this.anchor.x))}else{o=t+this.anchor.x;const s=o+this.size.width;o<e.left?t=e.left-this.anchor.x:s>e.right&&(t=e.right-this.anchor.x-this.size.width)}return t}getOptimalRelativeTop(e){let t=-this.size.height/4;if(this.size.height>e.height)return t;const o=this.anchor.y+t,s=o+this.size.height;return e=this.getWorkspaceViewRect(e),o<e.top?t=e.top-this.anchor.y:s>e.bottom&&(t=e.bottom-this.anchor.y-this.size.height),t}getWorkspaceViewRect(e){const t=e.top;let o=e.top+e.height,s=e.left;return e=e.left+e.width,o-=this.getScrollbarThickness(),this.workspace.RTL?s-=this.getScrollbarThickness():e-=this.getScrollbarThickness(),new ye(t,o,s,e)}getScrollbarThickness(){return Ze.scrollbarThickness/this.workspace.scale}renderTail(){const e=[];var t=this.size.width/2,o=this.size.height/2,s=-this.relativeLeft,i=-this.relativeTop;if(t===s&&o===i)e.push("M "+t+","+o);else{i-=o,s-=t,this.workspace.RTL&&(s*=-1);var n=Math.sqrt(i*i+s*s),d=Math.acos(s/n);i<0&&(d=2*Math.PI-d);var f=d+Math.PI/2;f>Math.PI*2&&(f-=Math.PI*2);var L=Math.sin(f);const ze=Math.cos(f);let Fe=(this.size.width+this.size.height)/zt.TAIL_THICKNESS;Fe=Math.min(Fe,this.size.width,this.size.height)/4,f=1-zt.ANCHOR_RADIUS/n,s=t+f*s,i=o+f*i,f=t+Fe*ze;const vt=o+Fe*L;t-=Fe*ze,o-=Fe*L,L=en(this.workspace.RTL?-zt.TAIL_ANGLE:zt.TAIL_ANGLE),L=d+L,L>Math.PI*2&&(L-=Math.PI*2),d=Math.sin(L)*n/zt.TAIL_BEND,n=Math.cos(L)*n/zt.TAIL_BEND,e.push("M"+f+","+vt),e.push("C"+(f+n)+","+(vt+d)+" "+s+","+i+" "+s+","+i),e.push("C"+s+","+i+" "+(t+n)+","+(o+d)+" "+t+","+o)}e.push("z");let oe;(oe=this.tail)==null||oe.setAttribute("d",e.join(" "))}bringToFront(){let e;const t=(e=this.svgRoot)==null?void 0:e.parentNode;return this.svgRoot&&t?.lastChild!==this.svgRoot?(t?.appendChild(this.svgRoot),!0):!1}getRelativeToSurfaceXY(){return new P(this.workspace.RTL?-this.relativeLeft+this.anchor.x-this.size.width:this.anchor.x+this.relativeLeft,this.anchor.y+this.relativeTop)}getSvgRoot(){return this.svgRoot}moveDuringDrag(e){this.moveTo(e.x,e.y),this.relativeLeft=this.workspace.RTL?this.anchor.x-e.x-this.size.width:e.x-this.anchor.x,this.relativeTop=e.y-this.anchor.y,this.renderTail()}setDragging(e){}setDeleteStyle(e){}isDeletable(){return!1}showContextMenu(e){}isMovable(){return!0}startDrag(){this.dragStrategy.startDrag()}drag(e){this.dragStrategy.drag(e)}endDrag(){this.dragStrategy.endDrag()}revertDrag(){this.dragStrategy.revertDrag()}select(){V(this)}unselect(){V(null)}getFocusableElement(){return this.focusableElement}getFocusableTree(){return this.workspace}onNodeFocus(){this.select(),this.bringToFront()}onNodeBlur(){this.unselect()}canBeFocused(){return!0}};zt=Oe,Oe.BORDER_WIDTH=6,Oe.DOUBLE_BORDER=zt.BORDER_WIDTH*2,Oe.MIN_SIZE=zt.DOUBLE_BORDER,Oe.TAIL_THICKNESS=1,Oe.TAIL_ANGLE=20,Oe.TAIL_BEND=4,Oe.ANCHOR_RADIUS=8;var Wo=class extends Oe{constructor(e,t,o,s){super(t,o,s),this.workspace=t,this.anchor=o,this.ownerRect=s,this.autoLayout=!0,t=new vo(e),this.validateWorkspaceOptions(t),this.svgDialog=v(R.SVG,{x:Oe.BORDER_WIDTH,y:Oe.BORDER_WIDTH},this.contentContainer),e.parentWorkspace=this.workspace,this.miniWorkspace=this.newWorkspaceSvg(new vo(e)),this.miniWorkspace.internalIsMutator=!0,e=this.miniWorkspace.createDom("blocklyMutatorBackground"),this.svgDialog.appendChild(e),t.languageTree&&(e.insertBefore(this.miniWorkspace.addFlyout(R.G),this.miniWorkspace.getCanvas()),e=this.miniWorkspace.getFlyout(),e?.init(this.miniWorkspace),e?.show(t.languageTree)),G(this.svgRoot,"blocklyMiniWorkspaceBubble"),this.miniWorkspace.addChangeListener(this.onWorkspaceChange.bind(this));let i,n;(i=this.miniWorkspace.getFlyout())==null||(n=i.getWorkspace())==null||n.addChangeListener(this.onWorkspaceChange.bind(this)),this.updateBubbleSize()}dispose(){this.miniWorkspace.dispose(),super.dispose()}getWorkspace(){return this.miniWorkspace}addWorkspaceChangeListener(e){this.miniWorkspace.addChangeListener(e)}validateWorkspaceOptions(e){if(e.hasCategories)throw Error("The miniworkspace bubble does not support toolboxes with categories");if(e.hasTrashcan)throw Error("The miniworkspace bubble does not support trashcans");if(e.zoomOptions.controls||e.zoomOptions.wheel||e.zoomOptions.pinch)throw Error("The miniworkspace bubble does not support zooming");if(e.moveOptions.scrollbars||e.moveOptions.wheel||e.moveOptions.drag)throw Error("The miniworkspace bubble does not scrolling/moving the workspace");if(e.horizontalLayout)throw Error("The miniworkspace bubble does not support horizontal layouts")}onWorkspaceChange(){this.bumpBlocksIntoBounds(),this.updateBubbleSize()}bumpBlocksIntoBounds(){if(!this.miniWorkspace.isDragging()||this.miniWorkspace.keyboardMoveInProgress)for(const e of this.miniWorkspace.getTopBlocks(!1)){const t=e.getRelativeToSurfaceXY();if(t.y<20&&e.moveBy(0,20-t.y),e.RTL){let o=-20;const s=this.miniWorkspace.getFlyout();s&&(o-=s.getWidth()),t.x>o&&e.moveBy(o-t.x,0)}else t.x<20&&e.moveBy(20-t.x,0)}}updateBubbleSize(){if(!this.miniWorkspace.isDragging()||this.miniWorkspace.keyboardMoveInProgress){this.autoLayout&&(this.autoLayout=!this.miniWorkspace.keyboardMoveInProgress);var e=this.getSize(),t=this.calculateWorkspaceSize();Math.abs(e.width-t.width)<Wo.MINIMUM_VIEW_CHANGE&&Math.abs(e.height-t.height)<Wo.MINIMUM_VIEW_CHANGE||(this.svgDialog.setAttribute("width",`${t.width}px`),this.svgDialog.setAttribute("height",`${t.height}px`),this.miniWorkspace.setCachedParentSvgSize(t.width,t.height),this.miniWorkspace.RTL&&this.miniWorkspace.getCanvas().setAttribute("transform",`translate(${t.width}, 0)`),this.setSize(new ve(t.width+Oe.DOUBLE_BORDER,t.height+Oe.DOUBLE_BORDER),this.autoLayout),this.miniWorkspace.resize(),this.miniWorkspace.recordDragTargets())}}calculateWorkspaceSize(){var e=this.miniWorkspace.getCanvas().getBBox();let t=e.width+Wo.MARGIN;e=e.height+Wo.MARGIN;const o=this.miniWorkspace.getFlyout();if(o){const s=o.getWorkspace().getMetricsManager().getScrollMetrics();e=Math.max(e,s.height+20),t+=o.getWidth()}return new ve(t,e)}updateBlockStyles(){for(var e of this.miniWorkspace.getAllBlocks(!1))e.setStyle(e.getStyleName());let t;if(e=(t=this.miniWorkspace.getFlyout())==null?void 0:t.getWorkspace())for(const o of e.getAllBlocks(!1))o.setStyle(o.getStyleName())}moveDuringDrag(e){super.moveDuringDrag(e),this.autoLayout=!1}moveTo(e,t){super.moveTo(e,t),this.miniWorkspace.recordDragTargets()}newWorkspaceSvg(e){throw Error("The implementation of newWorkspaceSvg should be monkey-patched in by blockly.ts")}};Wo.MINIMUM_VIEW_CHANGE=10,Wo.MARGIN=Oe.DOUBLE_BORDER*3;var _r=class{constructor(e){this.sourceBlock=e,this.offsetInBlock=new P(0,0),this.workspaceLocation=new P(0,0),this.svgRoot=null,this.tooltip=e,this.id=Re()}getType(){throw Error("Icons must implement getType")}initView(e){if(!this.svgRoot){var t=this.sourceBlock;this.svgRoot=v(R.G,{class:"blocklyIconGroup",id:this.id}),t.getSvgRoot().appendChild(this.svgRoot),this.updateSvgRootOffset(),z(this.svgRoot,"pointerdown",this,e),this.svgRoot.tooltip=this,zi(this.svgRoot)}}dispose(){Ac(this.svgRoot),ke(this.svgRoot)}getWeight(){return-1}getSize(){return new ve(0,0)}setTooltip(e){this.tooltip=e??this.sourceBlock}getTooltip(){return this.tooltip}applyColour(){}updateEditable(){}updateCollapsed(){this.svgRoot&&(this.sourceBlock.isCollapsed()?this.svgRoot.style.display="none":this.svgRoot.style.display="block",Ts(this)&&this.setBubbleVisible(!1))}hideForInsertionMarker(){this.svgRoot&&(this.svgRoot.style.display="none")}isShownWhenCollapsed(){return!1}setOffsetInBlock(e){this.offsetInBlock=e,this.updateSvgRootOffset()}updateSvgRootOffset(){let e;(e=this.svgRoot)==null||e.setAttribute("transform",`translate(${this.offsetInBlock.x}, ${this.offsetInBlock.y})`)}onLocationChange(e){this.workspaceLocation=P.sum(e,this.offsetInBlock)}onClick(){}isClickableInFlyout(e){return!0}getFocusableElement(){const e=this.svgRoot;if(!e)throw Error("Attempting to focus uninitialized icon.");return e}getFocusableTree(){return this.sourceBlock.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}getSourceBlock(){return this.sourceBlock}},cl,ul;cl=17,ul=16,r.MutatorIcon$$module$build$src$core$icons$mutator_icon=class extends _r{constructor(e,t){super(t),this.flyoutBlockTypes=e,this.sourceBlock=t,this.saveConnectionsListener=this.updateWorkspacePid=this.rootBlock=this.miniWorkspaceBubble=null}getType(){return r.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE}initView(e){this.svgRoot||(super.initView(e),v(R.RECT,{class:"blocklyIconShape",rx:"4",ry:"4",height:"16",width:"16"},this.svgRoot),v(R.PATH,{class:"blocklyIconSymbol",d:"m4.203,7.296 0,1.368 -0.92,0.677 -0.11,0.41 0.9,1.559 0.41,0.11 1.043,-0.457 1.187,0.683 0.127,1.134 0.3,0.3 1.8,0 0.3,-0.299 0.127,-1.138 1.185,-0.682 1.046,0.458 0.409,-0.11 0.9,-1.559 -0.11,-0.41 -0.92,-0.677 0,-1.366 0.92,-0.677 0.11,-0.41 -0.9,-1.559 -0.409,-0.109 -1.046,0.458 -1.185,-0.682 -0.127,-1.138 -0.3,-0.299 -1.8,0 -0.3,0.3 -0.126,1.135 -1.187,0.682 -1.043,-0.457 -0.41,0.11 -0.899,1.559 0.108,0.409z"},this.svgRoot),v(R.CIRCLE,{class:"blocklyIconShape",r:"2.7",cx:"8",cy:"8"},this.svgRoot),G(this.svgRoot,"blocklyMutatorIcon"))}dispose(){super.dispose();let e;(e=this.miniWorkspaceBubble)==null||e.dispose()}getWeight(){return r.MutatorIcon$$module$build$src$core$icons$mutator_icon.WEIGHT}getSize(){return new ve(cl,cl)}applyColour(){super.applyColour();let e;(e=this.miniWorkspaceBubble)==null||e.setColour(this.sourceBlock.getColour());let t;(t=this.miniWorkspaceBubble)==null||t.updateBlockStyles()}updateCollapsed(){super.updateCollapsed(),this.sourceBlock.isCollapsed()&&this.setBubbleVisible(!1)}onLocationChange(e){super.onLocationChange(e);let t;(t=this.miniWorkspaceBubble)==null||t.setAnchorLocation(this.getAnchorLocation())}onClick(){super.onClick(),this.sourceBlock.isEditable()&&this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.miniWorkspaceBubble}setBubbleVisible(e){const t=this;return(0,N.asyncExecutePromiseGeneratorFunction)(function*(){if(t.bubbleIsVisible()!==e){if(yield go(),e){t.miniWorkspaceBubble=new Wo(t.getMiniWorkspaceConfig(),t.sourceBlock.workspace,t.getAnchorLocation(),t.getBubbleOwnerRect()),t.applyColour(),t.createRootBlock(),t.addSaveConnectionsListener();let o;(o=t.miniWorkspaceBubble)==null||o.addWorkspaceChangeListener(t.createMiniWorkspaceChangeListener())}else{let o;(o=t.miniWorkspaceBubble)==null||o.dispose(),t.miniWorkspaceBubble=null,t.saveConnectionsListener&&t.sourceBlock.workspace.removeChangeListener(t.saveConnectionsListener),t.saveConnectionsListener=null}_(new(U(w.BUBBLE_OPEN))(t.sourceBlock,e,"mutator"))}})}getBubble(){return this.miniWorkspaceBubble}getMiniWorkspaceConfig(){let e;const t={disable:!1,media:this.sourceBlock.workspace.options.pathToMedia,rtl:this.sourceBlock.RTL,renderer:this.sourceBlock.workspace.options.renderer,rendererOverrides:(e=this.sourceBlock.workspace.options.rendererOverrides)!=null?e:void 0};return this.flyoutBlockTypes.length&&(t.toolbox={kind:"flyoutToolbox",contents:this.flyoutBlockTypes.map(o=>({kind:"block",type:o}))}),t}getAnchorLocation(){const e=cl/2;return P.sum(this.workspaceLocation,new P(e,e))}getBubbleOwnerRect(){const e=this.sourceBlock.getSvgRoot().getBBox();return new ye(e.y,e.y+e.height,e.x,e.x+e.width)}createRootBlock(){if(!this.sourceBlock.decompose)throw Error("Blocks with mutator icons must include a decompose method");this.rootBlock=this.sourceBlock.decompose(this.miniWorkspaceBubble.getWorkspace());for(var e of this.rootBlock.getDescendants(!1))e.queueRender();this.rootBlock.setMovable(!1),this.rootBlock.setDeletable(!1);let t,o,s,i;e=(i=(t=this.miniWorkspaceBubble)==null||(o=t.getWorkspace())==null||(s=o.getFlyout())==null?void 0:s.getWidth())!=null?i:0,this.rootBlock.moveBy(this.rootBlock.RTL?-(e+ul):ul,ul)}addSaveConnectionsListener(){this.sourceBlock.saveConnections&&this.rootBlock&&(this.saveConnectionsListener=()=>{this.sourceBlock.saveConnections&&this.rootBlock&&this.sourceBlock.saveConnections(this.rootBlock)},this.saveConnectionsListener(),this.sourceBlock.workspace.addChangeListener(this.saveConnectionsListener))}createMiniWorkspaceChangeListener(){return e=>{r.MutatorIcon$$module$build$src$core$icons$mutator_icon.isIgnorableMutatorEvent(e)||this.updateWorkspacePid||(this.updateWorkspacePid=setTimeout(()=>{this.updateWorkspacePid=null,this.recomposeSourceBlock()},0))}}static isIgnorableMutatorEvent(e){return e.isUiEvent||bt(e)||Ct(e)&&e.element==="disabled"}recomposeSourceBlock(){if(this.rootBlock){if(!this.sourceBlock.compose)throw Error("Blocks with mutator icons must include a compose method");var e=r.getGroup$$module$build$src$core$events$utils();e||r.setGroup$$module$build$src$core$events$utils(!0);var t=As.getExtraBlockState_(this.sourceBlock);this.sourceBlock.compose(this.rootBlock);var o=As.getExtraBlockState_(this.sourceBlock);t!==o&&_(new(U(w.BLOCK_CHANGE))(this.sourceBlock,"mutation",null,t,o)),r.setGroup$$module$build$src$core$events$utils(e)}}getWorkspace(){let e;return(e=this.miniWorkspaceBubble)==null?void 0:e.getWorkspace()}},r.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE=ut.MUTATOR,r.MutatorIcon$$module$build$src$core$icons$mutator_icon.WEIGHT=1,r.MutatorIcon$$module$build$src$core$icons$mutator_icon;var yi=Object.create(null),Cb={allExtensions:yi};r.register$$module$build$src$core$extensions("parent_tooltip_when_inline",q$);var co={TEST_ONLY:Cb};co.apply=gn,co.buildTooltipForDropdown=r.buildTooltipForDropdown$$module$build$src$core$extensions,co.buildTooltipWithFieldText=r.buildTooltipWithFieldText$$module$build$src$core$extensions,co.isRegistered=tu,co.register=r.register$$module$build$src$core$extensions,co.registerMixin=r.registerMixin$$module$build$src$core$extensions,co.registerMutator=r.registerMutator$$module$build$src$core$extensions,co.runAfterPageLoad=K$,co.unregister=W$;var Le;(function(e){e[e.WIN_KEY_FF_LINUX=0]="WIN_KEY_FF_LINUX",e[e.MAC_ENTER=3]="MAC_ENTER",e[e.BACKSPACE=8]="BACKSPACE",e[e.TAB=9]="TAB",e[e.NUM_CENTER=12]="NUM_CENTER",e[e.ENTER=13]="ENTER",e[e.SHIFT=16]="SHIFT",e[e.CTRL=17]="CTRL",e[e.ALT=18]="ALT",e[e.PAUSE=19]="PAUSE",e[e.CAPS_LOCK=20]="CAPS_LOCK",e[e.ESC=27]="ESC",e[e.SPACE=32]="SPACE",e[e.PAGE_UP=33]="PAGE_UP",e[e.PAGE_DOWN=34]="PAGE_DOWN",e[e.END=35]="END",e[e.HOME=36]="HOME",e[e.LEFT=37]="LEFT",e[e.UP=38]="UP",e[e.RIGHT=39]="RIGHT",e[e.DOWN=40]="DOWN",e[e.PLUS_SIGN=43]="PLUS_SIGN",e[e.PRINT_SCREEN=44]="PRINT_SCREEN",e[e.INSERT=45]="INSERT",e[e.DELETE=46]="DELETE",e[e.ZERO=48]="ZERO",e[e.ONE=49]="ONE",e[e.TWO=50]="TWO",e[e.THREE=51]="THREE",e[e.FOUR=52]="FOUR",e[e.FIVE=53]="FIVE",e[e.SIX=54]="SIX",e[e.SEVEN=55]="SEVEN",e[e.EIGHT=56]="EIGHT",e[e.NINE=57]="NINE",e[e.FF_SEMICOLON=59]="FF_SEMICOLON",e[e.FF_EQUALS=61]="FF_EQUALS",e[e.FF_DASH=173]="FF_DASH",e[e.FF_HASH=163]="FF_HASH",e[e.QUESTION_MARK=63]="QUESTION_MARK",e[e.AT_SIGN=64]="AT_SIGN",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.META=91]="META",e[e.WIN_KEY_RIGHT=92]="WIN_KEY_RIGHT",e[e.CONTEXT_MENU=93]="CONTEXT_MENU",e[e.NUM_ZERO=96]="NUM_ZERO",e[e.NUM_ONE=97]="NUM_ONE",e[e.NUM_TWO=98]="NUM_TWO",e[e.NUM_THREE=99]="NUM_THREE",e[e.NUM_FOUR=100]="NUM_FOUR",e[e.NUM_FIVE=101]="NUM_FIVE",e[e.NUM_SIX=102]="NUM_SIX",e[e.NUM_SEVEN=103]="NUM_SEVEN",e[e.NUM_EIGHT=104]="NUM_EIGHT",e[e.NUM_NINE=105]="NUM_NINE",e[e.NUM_MULTIPLY=106]="NUM_MULTIPLY",e[e.NUM_PLUS=107]="NUM_PLUS",e[e.NUM_MINUS=109]="NUM_MINUS",e[e.NUM_PERIOD=110]="NUM_PERIOD",e[e.NUM_DIVISION=111]="NUM_DIVISION",e[e.F1=112]="F1",e[e.F2=113]="F2",e[e.F3=114]="F3",e[e.F4=115]="F4",e[e.F5=116]="F5",e[e.F6=117]="F6",e[e.F7=118]="F7",e[e.F8=119]="F8",e[e.F9=120]="F9",e[e.F10=121]="F10",e[e.F11=122]="F11",e[e.F12=123]="F12",e[e.NUMLOCK=144]="NUMLOCK",e[e.SCROLL_LOCK=145]="SCROLL_LOCK",e[e.FIRST_MEDIA_KEY=166]="FIRST_MEDIA_KEY",e[e.LAST_MEDIA_KEY=183]="LAST_MEDIA_KEY",e[e.SEMICOLON=186]="SEMICOLON",e[e.DASH=189]="DASH",e[e.EQUALS=187]="EQUALS",e[e.COMMA=188]="COMMA",e[e.PERIOD=190]="PERIOD",e[e.SLASH=191]="SLASH",e[e.APOSTROPHE=192]="APOSTROPHE",e[e.TILDE=192]="TILDE",e[e.SINGLE_QUOTE=222]="SINGLE_QUOTE",e[e.OPEN_SQUARE_BRACKET=219]="OPEN_SQUARE_BRACKET",e[e.BACKSLASH=220]="BACKSLASH",e[e.CLOSE_SQUARE_BRACKET=221]="CLOSE_SQUARE_BRACKET",e[e.WIN_KEY=224]="WIN_KEY",e[e.MAC_FF_META=224]="MAC_FF_META",e[e.MAC_WK_CMD_LEFT=91]="MAC_WK_CMD_LEFT",e[e.MAC_WK_CMD_RIGHT=93]="MAC_WK_CMD_RIGHT",e[e.WIN_IME=229]="WIN_IME",e[e.VK_NONAME=252]="VK_NONAME",e[e.PHANTOM=255]="PHANTOM"})(Le||(Le={}));var zo={};zo.arc=qe,zo.curve=Pt,zo.line=ni,zo.lineOnAxis=re,zo.lineTo=bo,zo.moveBy=je,zo.moveTo=gt,zo.point=se;var We={};We.Coordinate=P,We.KeyCodes=Le,We.Rect=ye,We.Size=ve,We.Svg=R,We.aria=cr,We.array=og,We.browserEvents=Po,We.colour=Zt,We.deprecation=wg,We.dom=mt,We.extensions=co,We.idGenerator=ia,We.math=Yn,We.object=Zp,We.parsing=mr,We.string=mi,We.style=rs,We.svgMath=ks,We.svgPaths=zo,We.toolbox=ns,We.userAgent=db,We.xml=di;var Ce=class{constructor(e,t){if(this.type=t,this.targetConnection=null,this.disposed=!1,this.shadowDom=this.check=null,this.y=this.x=0,this.shadowState=null,this.sourceBlock_=e,e.id.includes("_connection"))throw Error(`Connection ID indicator is contained in block ID. This will cause problems with focus: ${e.id}.`);this.id=`${e.id}_connection_${Re()}`}connect_(e){const t=Z.INPUT_VALUE,o=this.getSourceBlock();var s=e.getSourceBlock();e.isConnected()&&e.disconnectInternal(!1);let i;if(this.isConnected()){const d=this.stashShadowState(),f=this.targetBlock();f.isShadow()?f.dispose(!1):(this.disconnectInternal(),i=f),this.applyShadowState(d)}let n;J()&&(n=new(U(w.BLOCK_MOVE))(s),n.setReason(["connect"])),Z$(this,e),s.setParent(o),n&&(n.recordNew(),_(n)),i&&(e=this.type===t?i.outputConnection:i.previousConnection)&&((s=Ce.getConnectionForOrphanedConnection(s,e))?e.connect(s):e.onFailedConnect(this))}dispose(){if(this.isConnected()){this.isSuperior()&&this.setShadowStateInternal();const e=this.targetBlock();e&&!e.isDeadOrDying()&&e.unplug()}this.disposed=!0}getSourceBlock(){return this.sourceBlock_}isSuperior(){return this.type===Z.INPUT_VALUE||this.type===Z.NEXT_STATEMENT}isConnected(){return!!this.targetConnection}getConnectionChecker(){return this.sourceBlock_.workspace.connectionChecker}onFailedConnect(e){}connect(e){if(this.targetConnection===e)return!0;if(this.getConnectionChecker().canConnect(this,e,!1)){const t=r.getGroup$$module$build$src$core$events$utils();t||r.setGroup$$module$build$src$core$events$utils(!0),this.isSuperior()?this.connect_(e):e.connect_(this),r.setGroup$$module$build$src$core$events$utils(t)}return this.isConnected()}disconnect(){this.disconnectInternal()}disconnectInternal(e=!0){const{parentConnection:t,childConnection:o}=this.getParentAndChildConnections();if(!t||!o)throw Error("Source connection not connected.");const s=r.getGroup$$module$build$src$core$events$utils();s||r.setGroup$$module$build$src$core$events$utils(!0);let i;J()&&(i=new(U(w.BLOCK_MOVE))(o.getSourceBlock()),i.setReason(["disconnect"]));const n=this.targetConnection;n&&(n.targetConnection=null),this.targetConnection=null,e&&o.getSourceBlock().setParent(null),i&&(i.recordNew(),_(i)),o.getSourceBlock().isShadow()||t.respawnShadow_(),r.setGroup$$module$build$src$core$events$utils(s)}getParentAndChildConnections(){return this.targetConnection?this.isSuperior()?{parentConnection:this,childConnection:this.targetConnection}:{parentConnection:this.targetConnection,childConnection:this}:{}}respawnShadow_(){this.createShadowBlock(!0)}reconnect(e,t){if(this.getSourceBlock().isDeadOrDying())return!1;var o;return t=(o=e.getInput(t))==null?void 0:o.connection,o=this.targetBlock(),o&&o!==e||!t||t.targetConnection===this?!1:(t.isConnected()&&t.disconnect(),t.connect(this),!0)}targetBlock(){if(this.isConnected()){let e,t;return(t=(e=this.targetConnection)==null?void 0:e.getSourceBlock())!=null?t:null}return null}onCheckChanged_(){!this.isConnected()||this.targetConnection&&this.getConnectionChecker().canConnect(this,this.targetConnection,!1)||(this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug()}setCheck(e){return e?(Array.isArray(e)||(e=[e]),this.check=e,this.onCheckChanged_()):this.check=null,this}getCheck(){return this.check}setShadowDom(e){this.setShadowStateInternal({shadowDom:e})}getShadowDom(e){return e&&this.targetBlock().isShadow()?ts(this.targetBlock()):this.shadowDom}setShadowState(e){this.setShadowStateInternal({shadowState:e})}getShadowState(e){return e&&this.targetBlock()&&this.targetBlock().isShadow()?jt(this.targetBlock()):this.shadowState}neighbours(e){return[]}getParentInput(){let e=null;const t=this.sourceBlock_.inputList;for(let o=0;o<t.length;o++)if(t[o].connection===this){e=t[o];break}return e}toString(){const e=this.sourceBlock_;if(!e)return"Orphan Connection";if(e.outputConnection===this)var t="Output Connection of ";else if(e.previousConnection===this)t="Previous Connection of ";else if(e.nextConnection===this)t="Next Connection of ";else{t=null;for(let o=0,s;s=e.inputList[o];o++)if(s.connection===this){t=s;break}if(t)t='Input "'+t.name+'" connection on ';else return console.warn("Connection not actually connected to sourceBlock_"),"Orphan Connection"}return t+e.toDevString()}stashShadowState(){const e=this.getShadowDom(!0),t=this.getShadowState(!0);return this.shadowState=this.shadowDom=null,{shadowDom:e,shadowState:t}}applyShadowState({shadowDom:e,shadowState:t}){this.shadowDom=e,this.shadowState=t}setShadowStateInternal({shadowDom:e=null,shadowState:t=null}={}){this.shadowDom=e,this.shadowState=t,this.getSourceBlock().isDeadOrDying()||((e=this.targetBlock())?e.isShadow()?(e.dispose(!1),this.respawnShadow_(),this.targetBlock()&&this.targetBlock().isShadow()&&this.serializeShadow(this.targetBlock())):(e=this.createShadowBlock(!1),this.serializeShadow(e),e&&e.dispose(!1)):(this.respawnShadow_(),this.targetBlock()&&this.targetBlock().isShadow()&&this.serializeShadow(this.targetBlock())))}createShadowBlock(e){var t=this.getSourceBlock();const o=this.getShadowState(),s=this.getShadowDom();if(t.isDeadOrDying()||!o&&!s)return null;if(o)return t=Zs(o,t.workspace,{parentConnection:e?this:void 0,isShadow:!0,recordUndo:!1});if(s){if(t=Is(s,t.workspace),e)if(this.type===Z.INPUT_VALUE){if(!t.outputConnection)throw Error("Shadow block is missing an output connection");if(!this.connect(t.outputConnection))throw Error("Could not connect shadow block to connection")}else if(this.type===Z.NEXT_STATEMENT){if(!t.previousConnection)throw Error("Shadow block is missing previous connection");if(!this.connect(t.previousConnection))throw Error("Could not connect shadow block to connection")}else throw Error("Cannot connect a shadow block to a previous/output connection");return t}return null}serializeShadow(e){e&&(this.shadowDom=ts(e),this.shadowState=jt(e))}static getConnectionForOrphanedConnection(e,t){if(t.type===Z.OUTPUT_VALUE)return ep(e,t.getSourceBlock());e=e.lastConnectionInStack(!0);const o=t.getConnectionChecker();return e&&o.canConnect(t,e,!1)?e:null}};Ce.CAN_CONNECT=0,Ce.REASON_SELF_CONNECTION=1,Ce.REASON_WRONG_TYPE=2,Ce.REASON_TARGET_NULL=3,Ce.REASON_CHECKS_FAILED=4,Ce.REASON_DIFFERENT_WORKSPACES=5,Ce.REASON_SHADOW_PARENT=6,Ce.REASON_DRAG_CHECKS_FAILED=7,Ce.REASON_PREVIOUS_AND_OUTPUT=8;var sm=class extends Error{constructor(e){super(`Tried to append an icon of type ${e.getType()} when an icon of that type already exists on the block. Use getIcon to access the existing icon.`),this.icon=e}},im={};im.DuplicateIconType=sm,(function(e){e[e.LEFT=-1]="LEFT",e[e.CENTRE=0]="CENTRE",e[e.RIGHT=1]="RIGHT"})(r.Align$$module$build$src$core$inputs$align||(r.Align$$module$build$src$core$inputs$align={})),r.Align$$module$build$src$core$inputs$align;var Ps=class extends we{constructor(e,t,o){super(we.SKIP_SETUP),this.class=null,this.EDITABLE=!1,this.maxDisplayLength=1/0,e!==we.SKIP_SETUP&&(o?this.configure_(o):this.class=t||null,this.setValue(e))}configure_(e){super.configure_(e),e.class&&(this.class=e.class)}initView(){this.createTextElement_(),this.class&&G(this.getTextElement(),this.class),this.fieldGroup_&&G(this.fieldGroup_,"blocklyLabelField")}doClassValidation_(e){return e==null?null:`${e}`}setClass(e){this.textElement_&&(this.class&&Te(this.textElement_,this.class),e&&G(this.textElement_,e)),this.class=e}static fromJson(e){return new this(Je(e.text),void 0,e)}};_o("field_label",Ps),Ps.prototype.DEFAULT_VALUE="";var rm=30,Fs=[];Fs[Z.INPUT_VALUE]=Z.OUTPUT_VALUE,Fs[Z.OUTPUT_VALUE]=Z.INPUT_VALUE,Fs[Z.NEXT_STATEMENT]=Z.PREVIOUS_STATEMENT,Fs[Z.PREVIOUS_STATEMENT]=Z.NEXT_STATEMENT;var Va="RENAME_VARIABLE_ID",Wa="DELETE_VARIABLE_ID",nm=10,_t=class extends Ce{constructor(e,t){super(e,t),this.highlighted=!1,this.targetConnection=null,this.db=e.workspace.connectionDBList[t],this.dbOpposite=e.workspace.connectionDBList[Fs[t]],this.offsetInBlock=new P(0,0),this.trackedState=_t.TrackedState.WILL_TRACK}dispose(){super.dispose(),this.trackedState===_t.TrackedState.TRACKED&&this.db.removeConnection(this,this.y);let e,t;(t=(e=this.sourceBlock_.pathObject).removeConnectionHighlight)==null||t.call(e,this)}getSourceBlock(){return super.getSourceBlock()}targetBlock(){return super.targetBlock()}distanceFrom(e){const t=this.x-e.x;return e=this.y-e.y,Math.sqrt(t*t+e*e)}bumpAwayFrom(e,t=!1){if(!this.sourceBlock_.workspace.isDragging()){var o=r.config$$module$build$src$core$config.snapRadius+Math.floor(Math.random()*nm),s=r.config$$module$build$src$core$config.snapRadius+Math.floor(Math.random()*nm),i=e.sourceBlock_.getRootBlock(),n=this.sourceBlock_.getRootBlock();if(!i.isInFlyout&&!n.isInFlyout){var d=!0;if(n.isMovable())i.isMovable()&&t&&(s=-s);else if(i.isMovable())d=!1,o=-o,s=-s;else return;t=d?e:this,e=d?this:e,i=d?n:i,i.RTL&&(o=-o),i.moveBy(t.x+o-e.x,t.y+s-e.y,["bump"])}}}moveTo(e,t){let o=!1;return this.trackedState===_t.TrackedState.WILL_TRACK?(this.db.addConnection(this,t),this.trackedState=_t.TrackedState.TRACKED,o=!0):this.trackedState===_t.TrackedState.TRACKED&&(this.db.removeConnection(this,this.y),this.db.addConnection(this,t),o=!0),this.x=e,this.y=t,o}moveBy(e,t){return this.moveTo(this.x+e,this.y+t)}moveToOffset(e){return this.moveTo(e.x+this.offsetInBlock.x,e.y+this.offsetInBlock.y)}setOffsetInBlock(e,t){this.offsetInBlock.x=e,this.offsetInBlock.y=t}getOffsetInBlock(){return this.offsetInBlock}tightenEfficiently(){var e=this.targetConnection;const t=this.targetBlock();e&&t&&(e=P.difference(this.offsetInBlock,e.offsetInBlock),t.translate(e.x,e.y))}closest(e,t){return this.dbOpposite.searchForClosest(this,e,t)}highlight(){this.highlighted=!0;const e=this.findHighlightSvg();e&&(e.style.display="")}unhighlight(){this.highlighted=!1;const e=this.findHighlightSvg();e&&(e.style.display="none")}isHighlighted(){return this.highlighted}setTracking(e){e&&this.trackedState===_t.TrackedState.TRACKED||!e&&this.trackedState===_t.TrackedState.UNTRACKED||this.sourceBlock_.isInFlyout||(e?(this.db.addConnection(this,this.y),this.trackedState=_t.TrackedState.TRACKED):(this.trackedState===_t.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),this.trackedState=_t.TrackedState.UNTRACKED))}stopTrackingAll(){if(this.setTracking(!1),this.targetConnection){const e=this.targetBlock().getDescendants(!1);for(let t=0;t<e.length;t++){const o=e[t],s=o.getConnections_(!0);for(let i=0;i<s.length;i++)s[i].setTracking(!1);for(const i of o.getIcons())Ts(i)&&i.setBubbleVisible(!1)}}}startTrackingAll(){this.setTracking(!0);let e=[];if(this.type!==Z.INPUT_VALUE&&this.type!==Z.NEXT_STATEMENT)return e;const t=this.targetBlock();if(t){let o;t.isCollapsed()?(o=[],t.outputConnection&&o.push(t.outputConnection),t.nextConnection&&o.push(t.nextConnection),t.previousConnection&&o.push(t.previousConnection)):o=t.getConnections_(!0);for(let s=0;s<o.length;s++)e.push(...o[s].startTrackingAll());e.length||(e=[t])}return e}onFailedConnect(e){const t=this.getSourceBlock();if(Ue()){const o=r.getGroup$$module$build$src$core$events$utils();setTimeout((function(){t.isDisposed()||t.getParent()||(r.setGroup$$module$build$src$core$events$utils(o),this.bumpAwayFrom(e),r.setGroup$$module$build$src$core$events$utils(!1))}).bind(this),r.config$$module$build$src$core$config.bumpDelay)}}disconnectInternal(e=!0){const{parentConnection:t,childConnection:o}=this.getParentAndChildConnections();if(t&&o){var s=r.getGroup$$module$build$src$core$events$utils();s||r.setGroup$$module$build$src$core$events$utils(!0);var i=t.getSourceBlock(),n=o.getSourceBlock();super.disconnectInternal(e),i.queueRender(),n.updateDisabled(),n.queueRender(),n.getSvgRoot().style.display="block",r.setGroup$$module$build$src$core$events$utils(s)}}respawnShadow_(){super.respawnShadow_();const e=this.targetBlock();e&&(e.initSvg(),e.queueRender())}neighbours(e){return this.dbOpposite.getNeighbours(this,e)}connect_(e){super.connect_(e);var t=this.getSourceBlock();e=e.getSourceBlock(),t.updateDisabled(),e.updateDisabled(),e.queueRender(),(t=t.getInputWithBlock(e))&&(t=t.isVisible(),e.getSvgRoot().style.display=t?"block":"none")}onCheckChanged_(){!this.isConnected()||this.targetConnection&&this.getConnectionChecker().canConnect(this,this.targetConnection,!1)||(this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug()}setCheck(e){return super.setCheck(e),this.sourceBlock_.queueRender(),this}showContextMenu(e){const t=Ee.registry.getContextMenuOptions({focusedNode:this},e);if(t.length){var o=this.getSourceBlock(),s=o.workspace;if(e instanceof PointerEvent)var i=new P(e.clientX,e.clientY);else i=new P(this.x,this.y),i=Ys(s,i).translate(o.RTL?-5:5,5);ii(e,t,o.RTL,s,i)}}getFocusableElement(){const e=this.findHighlightSvg();if(e)return e;throw Error("No highlight SVG found corresponding to this connection.")}getFocusableTree(){return this.getSourceBlock().workspace}onNodeFocus(){this.highlight()}onNodeBlur(){this.unhighlight()}canBeFocused(){return!0}findHighlightSvg(){return document.getElementById(this.id)}};(function(e){e=e.TrackedState||(e.TrackedState={}),e[e.WILL_TRACK=-1]="WILL_TRACK",e[e.UNTRACKED=0]="UNTRACKED",e[e.TRACKED=1]="TRACKED"})(_t||(_t={})),_t.TrackedState;var vi=class{constructor(e,t){this.name=e,this.sourceBlock=t,this.fieldRow=[],this.align=r.Align$$module$build$src$core$inputs$align.LEFT,this.visible=!0,this.type=r.inputTypes$$module$build$src$core$inputs$input_types.CUSTOM,this.connection=null}getSourceBlock(){return this.sourceBlock}appendField(e,t){return this.insertFieldAt(this.fieldRow.length,e,t),this}insertFieldAt(e,t,o){if(e<0||e>this.fieldRow.length)throw Error("index "+e+" out of bounds.");return(t||t===""&&o)&&(typeof t=="string"&&(t=r.fromJson$$module$build$src$core$field_registry({type:"field_label",text:t})),t.setSourceBlock(this.sourceBlock),this.sourceBlock.initialized&&this.initField(t),t.name=o,t.setVisible(this.isVisible()),t.prefixField&&(e=this.insertFieldAt(e,t.prefixField)),this.fieldRow.splice(e,0,t),e++,t.suffixField&&(e=this.insertFieldAt(e,t.suffixField)),this.sourceBlock.rendered&&this.sourceBlock.queueRender()),e}removeField(e,t){for(let o=0,s;s=this.fieldRow[o];o++)if(s.name===e)return s.dispose(),this.fieldRow.splice(o,1),this.sourceBlock.rendered&&this.sourceBlock.queueRender(),!0;if(t)return!1;throw Error('Field "'+e+'" not found.')}isVisible(){return this.visible}setVisible(e){let t=[];if(this.visible===e)return t;this.visible=e;for(let o=0,s;s=this.fieldRow[o];o++)s.setVisible(e);if(this.connection&&this.connection instanceof _t){e?t=this.connection.startTrackingAll():this.connection.stopTrackingAll();const o=this.connection.targetBlock();o&&(o.getSvgRoot().style.display=e?"block":"none")}return t}markDirty(){for(let e=0,t;t=this.fieldRow[e];e++)t.markDirty()}setCheck(e){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.setCheck(e),this}setAlign(e){return this.align=e,this.sourceBlock.rendered&&this.sourceBlock.queueRender(),this}setShadowDom(e){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.setShadowDom(e),this}getShadowDom(){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.getShadowDom()}init(){for(const e of this.fieldRow)e.init()}initModel(){for(const e of this.fieldRow)e.initModel()}initField(e){this.sourceBlock.rendered?e.init():e.initModel()}dispose(){for(let e=0,t;t=this.fieldRow[e];e++)t.dispose();this.connection&&this.connection.dispose()}makeConnection(e){return this.sourceBlock.makeConnection_(e)}},Io=class extends vi{constructor(e,t){super(e,t),this.name=e,this.type=r.inputTypes$$module$build$src$core$inputs$input_types.DUMMY}},Yo=class extends vi{constructor(e,t){super(e,t),this.name=e,this.type=r.inputTypes$$module$build$src$core$inputs$input_types.END_ROW}},Yt=class extends vi{constructor(e,t){if(!e)throw Error("Statement inputs must have a non-empty name");super(e,t),this.name=e,this.type=r.inputTypes$$module$build$src$core$inputs$input_types.STATEMENT,this.connection=this.makeConnection(Z.NEXT_STATEMENT)}},lm;r.ValueInput$$module$build$src$core$inputs$value_input=class extends vi{constructor(e,t){if(!e)throw Error("Value inputs must have a non-empty name");super(e,t),this.name=e,this.type=r.inputTypes$$module$build$src$core$inputs$input_types.VALUE,this.connection=this.makeConnection(Z.INPUT_VALUE)}},lm={},lm.ValueInput=r.ValueInput$$module$build$src$core$inputs$value_input;var Ii=class{constructor(e,t,o){if(this.data=null,this.disposed=!1,this.hue=null,this.colour_="#000000",this.styleName_="",this.suppressPrefixSuffix=!1,this.previousConnection=this.nextConnection=this.outputConnection=null,this.inputList=[],this.icons=[],this.disabledReasons=new Set,this.tooltip="",this.contextMenu=!0,this.parentBlock_=null,this.childBlocks_=[],this.editable=this.movable=this.deletable=!0,this.collapsed_=this.shadow=!1,this.outputShape_=null,this.rendered=this.isInsertionMarker_=this.initialized=this.disposing=!1,this.onchangeWrapper=this.helpUrl=null,this.statementInputCount=0,this.workspace=e,this.id=o&&!e.getBlockById(o)?o:rt(),e.setBlockById(this.id,this),this.xy=new P(0,0),this.isInFlyout=e.isFlyout,this.isInMutator=e.isMutator,this.RTL=e.RTL,t){if(this.type=t,o=Ge[t],!o||typeof o!="object")throw TypeError("Invalid block definition for type: "+t);Object.assign(this,o)}e.addTopBlock(this),e.addTypedBlock(this),new.target===Ii&&this.doInit_()}doInit_(){const e=r.getGroup$$module$build$src$core$events$utils();e||r.setGroup$$module$build$src$core$events$utils(!0);const t=Ue();try{typeof this.init=="function"&&(r.setRecordUndo$$module$build$src$core$events$utils(!1),this.init(),r.setRecordUndo$$module$build$src$core$events$utils(t)),J()&&_(new(U(w.BLOCK_CREATE))(this))}finally{r.setGroup$$module$build$src$core$events$utils(e),r.setRecordUndo$$module$build$src$core$events$utils(t)}this.inputsInlineDefault=this.inputsInline,typeof this.onchange=="function"&&this.setOnChange(this.onchange)}dispose(e=!1){this.disposing=!0,this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper),this.unplug(e),J()&&_(new(U(w.BLOCK_DELETE))(this)),this.workspace.removeTopBlock(this),this.disposeInternal()}disposeInternal(){this.disposing=!0,this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper),this.workspace.removeTypedBlock(this),this.workspace.removeBlockById(this.id),typeof this.destroy=="function"&&this.destroy(),this.childBlocks_.forEach(e=>e.disposeInternal()),this.inputList.forEach(e=>e.dispose()),this.inputList.length=0,this.getConnections_(!0).forEach(e=>e.dispose()),this.disposed=!0}isDeadOrDying(){return this.disposing||this.disposed}initModel(){if(!this.initialized){for(const e of this.inputList)e.initModel();this.initialized=!0}}unplug(e){this.outputConnection&&this.unplugFromRow(e),this.previousConnection&&this.unplugFromStack(e)}unplugFromRow(e){let t=null,o;(o=this.outputConnection)!=null&&o.isConnected()&&(t=this.outputConnection.targetConnection,this.outputConnection.disconnect()),t&&e&&(e=this.getOnlyValueConnection())&&e.isConnected()&&!e.targetBlock().isShadow()&&(e=e.targetConnection,e?.disconnect(),this.workspace.connectionChecker.canConnect(e,t,!1)?t.connect(e):e?.onFailedConnect(t))}getOnlyValueConnection(){let e=null;for(let t=0;t<this.inputList.length;t++){const o=this.inputList[t].connection;if(o&&o.type===Z.INPUT_VALUE&&o.targetConnection){if(e)return null;e=o}}return e}unplugFromStack(e){let t=null;var o;if((o=this.previousConnection)!=null&&o.isConnected()&&(t=this.previousConnection.targetConnection,this.previousConnection.disconnect()),o=this.getNextBlock(),e&&o&&!o.isShadow()){let s,i;e=(i=(s=this.nextConnection)==null?void 0:s.targetConnection)!=null?i:null,e?.disconnect(),t&&this.workspace.connectionChecker.canConnect(t,e,!1)&&t.connect(e)}}getConnections_(e){e=[],this.outputConnection&&e.push(this.outputConnection),this.previousConnection&&e.push(this.previousConnection),this.nextConnection&&e.push(this.nextConnection);for(let t=0,o;o=this.inputList[t];t++)o.connection&&e.push(o.connection);return e}lastConnectionInStack(e){let t=this.nextConnection;for(;t;){const o=t.targetBlock();if(!o||e&&o.isShadow())return t;t=o.nextConnection}return null}bumpNeighbours(){}getParent(){return this.parentBlock_}getInputWithBlock(e){for(let t=0,o;o=this.inputList[t];t++)if(o.connection&&o.connection.targetBlock()===e)return o;return null}getSurroundParent(){let e=this,t;do if(t=e,e=e.getParent(),!e)return null;while(e.getNextBlock()===t);return e}getNextBlock(){return this.nextConnection&&this.nextConnection.targetBlock()}getPreviousBlock(){return this.previousConnection&&this.previousConnection.targetBlock()}getRootBlock(){let e,t=this;do e=t,t=e.parentBlock_;while(t);return e}getTopStackBlock(){let e=this,t;do t=e.getPreviousBlock();while(t&&t.getNextBlock()===e&&(e=t));return e}getChildren(e){if(!e)return this.childBlocks_;e=[];for(let o=0,s;s=this.inputList[o];o++)if(s.connection){var t=s.connection.targetBlock();t&&e.push(t)}return(t=this.getNextBlock())&&e.push(t),e}setParent(e){if(e!==this.parentBlock_){var t=this.previousConnection&&this.previousConnection.targetBlock()||this.outputConnection&&this.outputConnection.targetBlock(),o=!!t;if(o&&e&&t!==e)throw Error("Block connected to superior one that is not new parent.");if(!o&&e)throw Error("Block not connected to new parent.");if(o&&!e)throw Error("Cannot set parent to null while block is still connected to superior block.");this.parentBlock_?x(this.parentBlock_.childBlocks_,this):this.workspace.removeTopBlock(this),(this.parentBlock_=e)?e.childBlocks_.push(this):this.workspace.addTopBlock(this)}}getDescendants(e){const t=[this],o=this.getChildren(e);for(let s,i=0;s=o[i];i++)t.push(...s.getDescendants(e));return t}isDeletable(){return this.deletable&&!this.isInFlyout&&!this.shadow&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()}isOwnDeletable(){return this.deletable}setDeletable(e){this.deletable=e}isMovable(){return this.movable&&!this.isInFlyout&&!this.shadow&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()}isOwnMovable(){return this.movable}setMovable(e){this.movable=e}isDuplicatable(){return this.workspace.hasBlockLimits()?this.workspace.isCapacityAvailable(io(this,!0)):!0}isShadow(){return this.shadow}setShadow(e){this.shadow=e}isInsertionMarker(){return this.isInsertionMarker_}setInsertionMarker(e){this.isInsertionMarker_=e}isEditable(){return this.editable&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()}isOwnEditable(){return this.editable}setEditable(e){this.editable=e;for(const t of this.getFields())t.updateEditable()}isDisposed(){return this.disposed}isSimpleReporter(){if(!this.outputConnection)return!1;for(const e of this.inputList)if(e.connection||e.fieldRow.length>1)return!1;return!0}getMatchingConnection(e,t){const o=this.getConnections_(!0);if(e=e.getConnections_(!0),o.length!==e.length)throw Error("Connection lists did not match in length.");for(let s=0;s<e.length;s++)if(e[s]===t)return o[s];return null}setHelpUrl(e){this.helpUrl=e}setTooltip(e){this.tooltip=e}getTooltip(){return ei(this)}getColour(){return this.colour_}getStyleName(){return this.styleName_}getHue(){return this.hue}setColour(e){e=ti(e),this.hue=e.hue,this.colour_=e.hex}setStyle(e){this.styleName_=e}setOnChange(e){if(e&&typeof e!="function")throw Error("onchange must be a function.");this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper),this.onchange=e,this.onchangeWrapper=e.bind(this),this.workspace.addChangeListener(this.onchangeWrapper)}getField(e){if(typeof e!="string")throw TypeError("Block.prototype.getField expects a string with the field name but received "+(e===void 0?"nothing":e+" of type "+typeof e)+" instead");for(const t of this.getFields())if(t.name===e)return t;return null}*getFields(){for(const e of this.inputList)for(const t of e.fieldRow)yield t}getVars(){const e=[];for(const t of this.getFields())t.referencesVariables()&&e.push(t.getValue());return e}getVarModels(){const e=[];for(const t of this.getFields())if(t.referencesVariables()){const o=this.workspace.getVariableById(t.getValue());o&&e.push(o)}return e}updateVarName(e){for(const t of this.getFields())t.referencesVariables()&&e.getId()===t.getValue()&&t.refreshVariableName()}renameVarById(e,t){for(const o of this.getFields())o.referencesVariables()&&e===o.getValue()&&o.setValue(t)}getFieldValue(e){return(e=this.getField(e))?e.getValue():null}setFieldValue(e,t){const o=this.getField(t);if(!o)throw Error('Field "'+t+'" not found.');o.setValue(e)}setPreviousStatement(e,t){if(e)t===void 0&&(t=null),this.previousConnection||(this.previousConnection=this.makeConnection_(Z.PREVIOUS_STATEMENT)),this.previousConnection.setCheck(t);else if(this.previousConnection){if(this.previousConnection.isConnected())throw Error("Must disconnect previous statement before removing connection.");this.previousConnection.dispose(),this.previousConnection=null}}setNextStatement(e,t){if(e)t===void 0&&(t=null),this.nextConnection||(this.nextConnection=this.makeConnection_(Z.NEXT_STATEMENT)),this.nextConnection.setCheck(t);else if(this.nextConnection){if(this.nextConnection.isConnected())throw Error("Must disconnect next statement before removing connection.");this.nextConnection.dispose(),this.nextConnection=null}}setOutput(e,t){if(e)t===void 0&&(t=null),this.outputConnection||(this.outputConnection=this.makeConnection_(Z.OUTPUT_VALUE)),this.outputConnection.setCheck(t);else if(this.outputConnection){if(this.outputConnection.isConnected())throw Error("Must disconnect output value before removing connection.");this.outputConnection.dispose(),this.outputConnection=null}}setInputsInline(e){this.inputsInline!==e&&(_(new(U(w.BLOCK_CHANGE))(this,"inline",null,this.inputsInline,e)),this.inputsInline=e)}getInputsInline(){if(this.inputsInline!==void 0)return this.inputsInline;for(var e=1;e<this.inputList.length;e++)if(this.inputList[e-1]instanceof Io&&this.inputList[e]instanceof Io)return!1;for(e=1;e<this.inputList.length;e++)if(this.inputList[e-1]instanceof r.ValueInput$$module$build$src$core$inputs$value_input&&this.inputList[e]instanceof Io)return!0;for(e=0;e<this.inputList.length;e++)if(this.inputList[e]instanceof Yo)return!0;return!1}setOutputShape(e){this.outputShape_=e}getOutputShape(){return this.outputShape_}isEnabled(){return this.disabledReasons.size===0}setDisabledReason(e,t){e||this.workspace.options.disable||!this.hasDisabledReason(Jt)||t==Jt||this.setDisabledReason(!1,Jt),this.disabledReasons.has(t)!==e&&(e?this.disabledReasons.add(t):this.disabledReasons.delete(t),e=new(U(w.BLOCK_CHANGE))(this,"disabled",null,!e,e),e.setDisabledReason(t),_(e))}getInheritedDisabled(){let e=this.getSurroundParent();for(;e;){if(!e.isEnabled())return!0;e=e.getSurroundParent()}return!1}hasDisabledReason(e){return this.disabledReasons.has(e)}getDisabledReasons(){return this.disabledReasons}isCollapsed(){return this.collapsed_}setCollapsed(e){this.collapsed_!==e&&(_(new(U(w.BLOCK_CHANGE))(this,"collapsed",null,this.collapsed_,e)),this.collapsed_=e)}toString(e,t){t=this.toTokens(t);for(let s=2;s<t.length;s++)t[s-2]==="("&&t[s]===")"&&(t[s-2]=t[s-1],t.splice(s-1,2));let o="";return t=t.reduce((s,i)=>(s=s+(o==="("||i===")"?"":" ")+i,o=i[i.length-1],s),""),t=t.trim()||"???",e&&t.length>e&&(t=t.substring(0,e-3)+"..."),t}toTokens(e="?"){const t=[];for(const s of this.inputList)if(s.name!=ur){for(const i of s.fieldRow)t.push(i.getText());if(s.connection){const i=s.connection.targetBlock();if(i){var o=s.connection;let n=o.getCheck();!n&&o.targetConnection&&(n=o.targetConnection.getCheck()),(o=!!n&&(n.includes("Boolean")||n.includes("Number")))&&t.push("("),t.push(...i.toTokens(e)),o&&t.push(")")}else t.push(e)}}return t}appendValueInput(e){return this.appendInput(new r.ValueInput$$module$build$src$core$inputs$value_input(e,this))}appendStatementInput(e){return this.statementInputCount++,this.appendInput(new Yt(e,this))}appendDummyInput(e=""){return this.appendInput(new Io(e,this))}appendEndRowInput(e=""){return this.appendInput(new Yo(e,this))}appendInput(e){return this.inputList.push(e),e}appendInputFromRegistry(e,t){return(e=A(M.INPUT,e,!1))?this.appendInput(new e(t,this)):null}jsonInit(e){var t=e.type?'Block "'+e.type+'": ':"";if(e.output&&e.previousStatement)throw Error(t+"Must not have both an output and a previousStatement.");for(var o=0;e["args"+o];){if(e["message"+o]===void 0)throw Error(t+`args${o} must have a corresponding message (message${o}).`);o++}if(e.style&&e.style.hat&&(this.hat=e.style.hat,e.style=null),e.style&&e.colour)throw Error(t+"Must not have both a colour and a style.");for(e.style?this.jsonInitStyle(e,t):this.jsonInitColour(e,t),o=0;e["message"+o]!==void 0;)this.interpolate(e["message"+o],e["args"+o]||[],e["implicitAlign"+o]||e["lastDummyAlign"+o],t),o++;if(e.inputsInline!==void 0&&(r.disable$$module$build$src$core$events$utils(),this.setInputsInline(e.inputsInline),r.enable$$module$build$src$core$events$utils()),e.output!==void 0&&this.setOutput(!0,e.output),e.outputShape!==void 0&&this.setOutputShape(e.outputShape),e.previousStatement!==void 0&&this.setPreviousStatement(!0,e.previousStatement),e.nextStatement!==void 0&&this.setNextStatement(!0,e.nextStatement),e.tooltip!==void 0&&(o=Je(e.tooltip),this.setTooltip(o)),e.enableContextMenu!==void 0&&(this.contextMenu=!!e.enableContextMenu),e.suppressPrefixSuffix!==void 0&&(this.suppressPrefixSuffix=!!e.suppressPrefixSuffix),e.helpUrl!==void 0&&(o=Je(e.helpUrl),this.setHelpUrl(o)),typeof e.extensions=="string"&&(console.warn(t+"JSON attribute 'extensions' should be an array of strings. Found raw string in JSON for '"+e.type+"' block."),e.extensions=[e.extensions]),e.mutator!==void 0&&gn(e.mutator,this,!0),e=e.extensions,Array.isArray(e))for(t=0;t<e.length;t++)gn(e[t],this,!1)}jsonInitColour(e,t){if("colour"in e)if(e.colour===void 0)console.warn(t+"Undefined colour value.");else{e=e.colour;try{this.setColour(e)}catch{console.warn(t+"Illegal colour value: ",e)}}}jsonInitStyle(e,t){e=e.style;try{this.setStyle(e)}catch{console.warn(t+"Style does not exist: ",e)}}mixin(e,t){if(t!==void 0&&typeof t!="boolean")throw Error("opt_disableCheck must be a boolean if provided");if(!t){t=[];for(const o in e)this[o]!==void 0&&t.push(o);if(t.length)throw Error("Mixin will overwrite block members: "+JSON.stringify(t))}Object.assign(this,e)}interpolate(e,t,o,s){e=Uc(e),this.validateTokens(e,t.length),t=this.interpolateArguments(e,t,o),o=[];for(let i=0,n;n=t[i];i++)if(this.isInputKeyword(n.type)){if(e=this.inputFromJson(n,s)){for(let d=0,f;f=o[d];d++)e.appendField(f[0],f[1]);o.length=0}}else(e=this.fieldFromJson(n))&&o.push([e,n.name])}validateTokens(e,t){const o=[];let s=0;for(let i=0;i<e.length;i++){const n=e[i];if(typeof n=="number"){if(n<1||n>t)throw Error('Block "'+this.type+'": Message index %'+n+" out of range.");if(o[n])throw Error('Block "'+this.type+'": Message index %'+n+" duplicated.");o[n]=!0,s++}}if(s!==t)throw Error('Block "'+this.type+'": Message does not reference all '+t+" arg(s).")}interpolateArguments(e,t,o){const s=[];for(let n=0;n<e.length;n++){var i=e[n];if(typeof i=="number"&&(i=t[i-1]),typeof i=="string"){if(i===`
621
- `)i={type:"input_end_row"},o&&(i.align=o);else if(i=this.stringToFieldJson(i),!i)continue}s.push(i)}return(e=s.length)&&!this.isInputKeyword(s[e-1].type)&&(e={type:"input_dummy"},o&&(e.align=o),s.push(e)),s}fieldFromJson(e){const t=r.fromJson$$module$build$src$core$field_registry(e);return!t&&e.alt?typeof e.alt=="string"?(e=this.stringToFieldJson(e.alt))?this.fieldFromJson(e):null:this.fieldFromJson(e.alt):t}inputFromJson(e,t){var o={LEFT:r.Align$$module$build$src$core$inputs$align.LEFT,RIGHT:r.Align$$module$build$src$core$inputs$align.RIGHT,CENTRE:r.Align$$module$build$src$core$inputs$align.CENTRE,CENTER:r.Align$$module$build$src$core$inputs$align.CENTRE};let s;switch(e.type){case"input_value":s=this.appendValueInput(e.name);break;case"input_statement":s=this.appendStatementInput(e.name);break;case"input_dummy":s=this.appendDummyInput(e.name);break;case"input_end_row":s=this.appendEndRowInput(e.name);break;default:s=this.appendInputFromRegistry(e.type,e.name)}return s?(e.check&&s.setCheck(e.check),e.align&&(o=o[e.align.toUpperCase()],o===void 0?console.warn(t+"Illegal align value: ",e.align):s.setAlign(o)),s):null}isInputKeyword(e){return e==="input_value"||e==="input_statement"||e==="input_dummy"||e==="input_end_row"||k(M.INPUT,e)}stringToFieldJson(e){return(e=e.trim())?{type:"field_label",text:e}:null}moveInputBefore(e,t){if(e!==t){var o=-1,s=t?-1:this.inputList.length;for(let i=0,n;n=this.inputList[i];i++)if(n.name===e){if(o=i,s!==-1)break}else if(t&&n.name===t&&(s=i,o!==-1))break;if(o===-1)throw Error('Named input "'+e+'" not found.');if(s===-1)throw Error('Reference input "'+t+'" not found.');this.moveNumberedInputBefore(o,s)}}moveNumberedInputBefore(e,t){if(e===t)throw Error("Can't move input to itself.");if(e>=this.inputList.length)throw RangeError("Input index "+e+" out of bounds.");if(t>this.inputList.length)throw RangeError("Reference input "+t+" out of bounds.");const o=this.inputList[e];this.inputList.splice(e,1),e<t&&t--,this.inputList.splice(t,0,o)}removeInput(e,t){for(let o=0,s;s=this.inputList[o];o++)if(s.name===e)return s instanceof Yt&&this.statementInputCount--,s.dispose(),this.inputList.splice(o,1),!0;if(t)return!1;throw Error("Input not found: "+e)}getInput(e){for(let t=0,o;o=this.inputList[t];t++)if(o.name===e)return o;return null}getInputTargetBlock(e){return(e=this.getInput(e))&&e.connection&&e.connection.targetBlock()}getCommentText(){let e,t;return(t=(e=this.getIcon(ut.COMMENT))==null?void 0:e.getText())!=null?t:null}setCommentText(e){var t;let o;const s=(o=(t=this.getIcon(ut.COMMENT))==null?void 0:t.getText())!=null?o:null;if(s!==e){if(e!==null){if(t=this.getIcon(ut.COMMENT),!t){if(t=A(M.ICON,ut.COMMENT.toString(),!1),!t)throw Error("No comment icon class is registered, so a comment cannot be set");if(t=new t(this),!tp(t))throw Error("The class registered as a comment icon does not conform to the ICommentIcon interface");t=this.addIcon(t)}r.disable$$module$build$src$core$events$utils(),t.setText(e),r.enable$$module$build$src$core$events$utils()}else this.removeIcon(ut.COMMENT);_(new(U(w.BLOCK_CHANGE))(this,"comment",null,s,e))}}setWarningText(e,t){}setMutator(e){}addIcon(e){if(this.hasIcon(e.getType()))throw new sm(e);return this.icons.push(e),this.icons.sort((t,o)=>t.getWeight()-o.getWeight()),e}removeIcon(e){if(!this.hasIcon(e))return!1;let t;return(t=this.getIcon(e))==null||t.dispose(),this.icons=this.icons.filter(o=>!o.getType().equals(e)),!0}hasIcon(e){return this.icons.some(t=>t.getType().equals(e))}getIcon(e){return e instanceof ut?this.icons.find(t=>t.getType().equals(e)):this.icons.find(t=>t.getType().toString()===e)}getIcons(){return[...this.icons]}getRelativeToSurfaceXY(){return this.xy}moveBy(e,t,o){if(this.parentBlock_)throw Error("Block has parent");const s=new(U(w.BLOCK_MOVE))(this);o&&s.setReason(o),this.xy.translate(e,t),s.recordNew(),_(s)}makeConnection_(e){return new Ce(this,e)}allInputsFilled(e){if(e===void 0&&(e=!0),!e&&this.isShadow())return!1;for(let o=0,s;s=this.inputList[o];o++)if(s.connection){var t=s.connection.targetBlock();if(!t||!t.allInputsFilled(e))return!1}return(t=this.getNextBlock())?t.allInputsFilled(e):!0}toDevString(){let e=this.type?'"'+this.type+'" block':"Block";return this.id&&(e+=' (id="'+this.id+'")'),e}};Ii.COLLAPSED_INPUT_NAME=ur,Ii.COLLAPSED_FIELD_NAME=Vn;var al=null,br=null,Tr={};Tr.connectionUiEffect=nu,Tr.disconnectUiEffect=lu,Tr.disconnectUiStop=li,Tr.disposeUiEffect=_n;var Er=class{paste(e,t,o){if(!t.isCapacityAvailable(e.typeCounts))return null;o&&(e.blockState.x=o.x,e.blockState.y=o.y),o=o||new P(e.blockState.x||0,e.blockState.y||0),r.disable$$module$build$src$core$events$utils();let s;try{s=es(e.blockState,t),op(s,o)}finally{r.enable$$module$build$src$core$events$utils()}if(!s)return s;J()&&!s.isShadow()&&_(new(U(w.BLOCK_CREATE))(s));const i=s;return go().then(()=>r.getFocusManager$$module$build$src$core$focus_manager().focusNode(i)),s}};Er.TYPE="block",zr(Er.TYPE,new Er);var hl={};hl.bumpIntoBounds=ci,hl.bumpIntoBoundsHandler=uu,hl.bumpTopObjectsIntoBounds=bn;var cm=class{constructor(e){this.block=e,this.connectionPreviewer=this.connectionCandidate=this.startLoc=this.startChildConn=this.startParentConn=null,this.dragging=!1,this.dragOffset=new P(0,0),this.originalEventGroup="",this.workspace=e.workspace}isMovable(){if(this.block.isShadow()){let e,t;return(t=(e=this.block.getParent())==null?void 0:e.isMovable())!=null?t:!1}return this.block.isOwnMovable()&&!this.block.isDeadOrDying()&&!this.workspace.isReadOnly()&&!this.block.isInFlyout}startDrag(e){if(this.block.isShadow())this.startDraggingShadow(e);else{this.dragging=!0,this.fireDragStartEvent(),this.startLoc=this.block.getRelativeToSurfaceXY(),this.connectionCandidate=null,this.connectionPreviewer=new(W(M.CONNECTION_PREVIEWER,this.workspace.options))(this.block),eo(),this.workspace.setResizesEnabled(!1),li(),e=this.shouldHealStack(e),this.shouldDisconnect(e)&&this.disconnectBlock(e),this.block.setDragging(!0);var t;(t=this.workspace.getLayerManager())==null||t.moveToDragLayer(this.block)}}shouldHealStack(e){return!!e&&(e.altKey||e.ctrlKey||e.metaKey)}startDraggingShadow(e){const t=this.block.getParent();if(!t)throw Error("Tried to drag a shadow block with no parent. Shadow blocks should always have parents.");this.dragOffset=P.difference(t.getRelativeToSurfaceXY(),this.block.getRelativeToSurfaceXY()),t.startDrag(e)}shouldDisconnect(e){return!!(this.block.getParent()||e&&this.block.nextConnection&&this.block.nextConnection.targetBlock())}disconnectBlock(e){let t,o,s;if(this.startParentConn=(s=(t=this.block.outputConnection)==null?void 0:t.targetConnection)!=null?s:(o=this.block.previousConnection)==null?void 0:o.targetConnection,e){let i;this.startChildConn=(i=this.block.nextConnection)==null?void 0:i.targetConnection}this.block.unplug(e),lu(this.block)}fireDragStartEvent(){const e=new(U(w.BLOCK_DRAG))(this.block,!0,this.block.getDescendants(!1));_(e)}fireDragEndEvent(){const e=new(U(w.BLOCK_DRAG))(this.block,!1,this.block.getDescendants(!1));_(e)}fireMoveEvent(){if(!this.block.isDeadOrDying()){var e=new(U(w.BLOCK_MOVE))(this.block);e.setReason(["drag"]),e.oldCoordinate=this.startLoc,e.recordNew(),_(e)}}drag(e){if(this.block.isShadow()){let t;(t=this.block.getParent())==null||t.drag(P.sum(e,this.dragOffset))}else this.block.moveDuringDrag(e),this.updateConnectionPreview(this.block,P.difference(e,this.startLoc))}updateConnectionPreview(e,t){var o=this.connectionCandidate;const s=this.getConnectionCandidate(e,t);if(s){this.connectionCandidate=t=o&&this.currCandidateIsBetter(o,t,s)?o:s;var{local:i,neighbour:n}=t;t=i.type===Z.OUTPUT_VALUE||i.type===Z.PREVIOUS_STATEMENT;var d;if(o=n.isConnected()&&!((d=n.targetBlock())!=null&&d.isInsertionMarker()),t&&o&&!this.orphanCanConnectAtEnd(e,n.targetBlock(),i.type)){let L;(L=this.connectionPreviewer)==null||L.previewReplacement(i,n,n.targetBlock())}else{var f;(f=this.connectionPreviewer)==null||f.previewConnection(i,n)}}else{let L;(L=this.connectionPreviewer)==null||L.hidePreview(),this.connectionCandidate=null}}orphanCanConnectAtEnd(e,t,o){return!!Ce.getConnectionForOrphanedConnection(e,o===Z.OUTPUT_VALUE?t.outputConnection:t.previousConnection)}currCandidateIsBetter(e,t,o){const{local:s,neighbour:i}=e;e=new P(s.x,s.y);const n=new P(i.x,i.y);return t=P.distance(P.sum(e,t),n),o.distance>t-r.config$$module$build$src$core$config.currentConnectionPreference}getConnectionCandidate(e,t){e=this.getLocalConnections(e);let o=this.getSearchRadius(),s=null;for(const i of e){const{connection:n,radius:d}=i.closest(o,t);n&&(s={local:i,neighbour:n,distance:d},o=d)}return s}getSearchRadius(){return this.connectionCandidate?r.config$$module$build$src$core$config.connectingSnapRadius:r.config$$module$build$src$core$config.snapRadius}getLocalConnections(e){const t=e.getConnections_(!1),o=e.lastConnectionInStack(!0);return o&&o!==e.nextConnection&&t.push(o),t}endDrag(e){if(this.block.isShadow()){let o;(o=this.block.getParent())==null||o.endDrag(e)}else{this.originalEventGroup=r.getGroup$$module$build$src$core$events$utils(),this.fireDragEndEvent(),this.fireMoveEvent(),to(),li();var t;if((t=this.connectionPreviewer)==null||t.hidePreview(),!this.block.isDeadOrDying()&&this.dragging){let o;(o=this.workspace.getLayerManager())==null||o.moveOffDragLayer(this.block,us),this.block.setDragging(!1)}this.connectionCandidate?(this.applyConnections(this.connectionCandidate),this.disposeStep()):this.block.queueRender().then(()=>this.disposeStep())}}disposeStep(){const e=r.getGroup$$module$build$src$core$events$utils();r.setGroup$$module$build$src$core$events$utils(this.originalEventGroup),this.block.snapToGrid();let t;(t=this.connectionPreviewer)==null||t.dispose(),this.workspace.setResizesEnabled(!0),r.setGroup$$module$build$src$core$events$utils(e)}applyConnections(e){const{local:t,neighbour:o}=e;t.connect(o);const s=t.isSuperior()?o:t,i=this.block.getRootBlock();go().then(()=>{nu(s.getSourceBlock()),setTimeout(()=>{i.bringToFront()},0)})}revertDrag(){if(this.block.isShadow()){let o;(o=this.block.getParent())==null||o.revertDrag()}else{var e;(e=this.connectionPreviewer)==null||e.hidePreview(),this.connectionCandidate=null;var t;if((t=this.startChildConn)==null||t.connect(this.block.nextConnection),this.startParentConn)switch(this.startParentConn.type){case Z.INPUT_VALUE:this.startParentConn.connect(this.block.outputConnection);break;case Z.NEXT_STATEMENT:this.startParentConn.connect(this.block.previousConnection)}else{this.block.moveTo(this.startLoc,["drag"]);let o;(o=this.workspace.getLayerManager())==null||o.moveOffDragLayer(this.block,us),ci(this.workspace,this.workspace.getMetricsManager().getScrollMetrics(!0),this.block)}this.startParentConn=this.startChildConn=null,this.block.setDragging(!1),this.dragging=!1}}},um=class extends Oe{constructor(e,t,o,s){super(t,o,s),this.text=e,this.workspace=t,this.anchor=o,this.ownerRect=s,this.paragraph=this.stringToSvg(e,this.contentContainer),this.updateBubbleSize(),G(this.svgRoot,"blocklyTextBubble")}getText(){return this.text}setText(e){this.text=e,ke(this.paragraph),this.paragraph=this.stringToSvg(e,this.contentContainer),this.updateBubbleSize()}stringToSvg(e,t){return t=this.createParagraph(t),e=this.createTextFragments(t,e),this.workspace.RTL&&this.rightAlignTextFragments(t.getBBox().width,e),t}createParagraph(e){return v(R.G,{class:"blocklyText blocklyBubbleText blocklyNoPointerEvents",transform:`translate(0,${Oe.BORDER_WIDTH})`,style:`direction: ${this.workspace.RTL?"rtl":"ltr"}`},e)}createTextFragments(e,t){let o=1;return t.split(`
622
- `).map(s=>{const i=v(R.TEXT,{y:`${o}em`,x:Oe.BORDER_WIDTH},e);return s=document.createTextNode(s),i.appendChild(s),o+=1,i})}rightAlignTextFragments(e,t){for(const o of t)o.setAttribute("text-anchor","start"),o.setAttribute("x",`${e+Oe.BORDER_WIDTH}`)}updateBubbleSize(){const e=this.paragraph.getBBox();this.setSize(new ve(e.width+Oe.BORDER_WIDTH*2,e.height+Oe.BORDER_WIDTH*2),!0)}},za=17,Co=class extends _r{constructor(e){super(e),this.sourceBlock=e,this.textMap=new Map,this.textBubble=null}getType(){return Co.TYPE}initView(e){this.svgRoot||(super.initView(e),v(R.PATH,{class:"blocklyIconShape",d:"M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z"},this.svgRoot),v(R.PATH,{class:"blocklyIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},this.svgRoot),v(R.RECT,{class:"blocklyIconSymbol",x:"7",y:"11",height:"2",width:"2"},this.svgRoot),G(this.svgRoot,"blocklyWarningIcon"))}dispose(){super.dispose();let e;(e=this.textBubble)==null||e.dispose()}getWeight(){return Co.WEIGHT}getSize(){return new ve(za,za)}applyColour(){super.applyColour();let e;(e=this.textBubble)==null||e.setColour(this.sourceBlock.getColour())}updateCollapsed(){}isShownWhenCollapsed(){return!0}onLocationChange(e){super.onLocationChange(e);let t;(t=this.textBubble)==null||t.setAnchorLocation(this.getAnchorLocation())}addMessage(e,t){if(this.textMap.get(t)===e)return this;e?this.textMap.set(t,e):this.textMap.delete(t);let o;return(o=this.textBubble)==null||o.setText(this.getText()),this}getText(){return[...this.textMap.values()].join(`
623
- `)}onClick(){super.onClick(),this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.textBubble}setBubbleVisible(e){const t=this;return(0,N.asyncExecutePromiseGeneratorFunction)(function*(){if(t.bubbleIsVisible()!==e){if(yield go(),e)t.textBubble=new um(t.getText(),t.sourceBlock.workspace,t.getAnchorLocation(),t.getBubbleOwnerRect()),t.applyColour();else{let o;(o=t.textBubble)==null||o.dispose(),t.textBubble=null}_(new(U(w.BUBBLE_OPEN))(t.sourceBlock,e,"warning"))}})}getBubble(){return this.textBubble}getAnchorLocation(){const e=za/2;return P.sum(this.workspaceLocation,new P(e,e))}getBubbleOwnerRect(){const e=this.sourceBlock.getSvgRoot().getBBox();return new ye(e.y,e.y+e.height,e.x,e.x+e.width)}};Co.TYPE=ut.WARNING,Co.WEIGHT=2;var Be=class extends Ii{constructor(e,t,o){if(super(e,t,o),this.childlessWidth=this.width=this.height=0,this.warningTextDb=new Map,this.mutator=null,this.rendered=!0,this.visuallyDisabled=!1,this.translation="",this.dragging=!1,this.relativeCoords=new P(0,0),this.dragStrategy=new cm(this),!e.rendered)throw TypeError("Cannot create a rendered block in a headless workspace");this.workspace=e,this.svgGroup=v(R.G,{}),t&&G(this.svgGroup,t),this.style=e.getRenderer().getConstants().getBlockStyle(null),this.pathObject=e.getRenderer().makePathObject(this.svgGroup,this.style),e=this.pathObject.svgPath,e.tooltip=this,zi(e),this.svgGroup.setAttribute("data-id",this.id),e.id=Re(),this.doInit_()}initSvg(){if(!this.initialized){for(var e of this.inputList)e.init();for(const t of this.getIcons())t.initView(this.createIconPointerDownListener(t)),t.updateEditable();this.applyColour(),this.pathObject.updateMovable(this.isMovable()||this.isInFlyout),(e=this.getSvgRoot())&&z(e,"pointerdown",this,this.onMouseDown),e.parentNode||this.workspace.getCanvas().appendChild(e),this.initialized=!0}}getColourSecondary(){return this.style.colourSecondary}getColourTertiary(){return this.style.colourTertiary}select(){this.addSelect(),V(this)}unselect(){this.removeSelect(),V(null)}setParent(e){var t=this.parentBlock_;if(e!==t){eo(),super.setParent(e),to();var o=this.getSvgRoot();if(!this.workspace.isClearing&&o){var s=this.getRelativeToSurfaceXY(),i=r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode(),n,d=this.getSvgRoot().contains((n=i?.getFocusableElement())!=null?n:null);e?(e.getSvgRoot().appendChild(o),d&&i&&r.getFocusManager$$module$build$src$core$focus_manager().focusNode(i)):t&&(e=this.workspace.getCanvas().querySelector(".blocklyDragging"),t=e?.parentElement,n=this.workspace.getCanvas(),t===n?n.insertBefore(o,e):(n.appendChild(o),d&&i&&r.getFocusManager$$module$build$src$core$focus_manager().focusNode(i)),this.translate(s.x,s.y)),this.applyColour()}}}getRelativeToSurfaceXY(){const e=this.workspace.getLayerManager();if(!e)throw Error("Cannot calculate position because the workspace has not been appended");let t=0,o=0,s=this.getSvgRoot();if(s)do{const i=xi(s);t+=i.x,o+=i.y,s=s.parentNode}while(s&&!e.hasLayer(s));return new P(t,o)}moveBy(e,t,o){if(this.parentBlock_)throw Error("Block has parent");const s=J();let i=null;s&&(i=new(U(w.BLOCK_MOVE))(this),o&&i.setReason(o)),e=new P(e,t),t=this.getRelativeToSurfaceXY(),e=P.sum(t,e),this.translate(e.x,e.y),this.updateComponentLocations(e),s&&i&&(i.recordNew(),_(i)),this.workspace.resizeContents()}translate(e,t){this.translation=`translate(${e}, ${t})`,this.relativeCoords=new P(e,t),this.getSvgRoot().setAttribute("transform",this.getTranslation())}getTranslation(){return this.translation}moveTo(e,t){const o=this.getRelativeToSurfaceXY();this.moveBy(e.x-o.x,e.y-o.y,t)}moveDuringDrag(e){this.translate(e.x,e.y),this.getSvgRoot().setAttribute("transform",this.getTranslation()),this.updateComponentLocations(e)}snapToGrid(){if(!this.isDeadOrDying()&&!this.getParent()&&!this.isInFlyout){var e=this.workspace.getGrid();if(e!=null&&e.shouldSnap()){var t=this.getRelativeToSurfaceXY();e=e.alignXY(t),e!==t&&this.moveTo(e,["snap"])}}}getBoundingRectangle(){return this.getBoundingRectangleWithDimensions(this.getHeightWidth())}getBoundingRectangleWithoutChildren(){return this.getBoundingRectangleWithDimensions({height:this.height,width:this.childlessWidth})}getBoundingRectangleWithDimensions(e){const t=this.getRelativeToSurfaceXY();let o,s;return this.RTL?(o=t.x-e.width,s=t.x):(o=t.x,s=t.x+e.width),new ye(t.y,t.y+e.height,o,s)}markDirty(){this.pathObject.constants=this.workspace.getRenderer().getConstants();for(let e=0,t;t=this.inputList[e];e++)t.markDirty()}setCollapsed(e){this.collapsed_!==e&&(super.setCollapsed(e),this.updateCollapsed())}childHasWarning(){const e=this.getChildren(!1);for(const t of e)if(t.getIcon(Co.TYPE)||t.childHasWarning())return!0;return!1}updateCollapsed(){var e=this.isCollapsed();const t=ur,o=Vn;for(let i=0,n;n=this.inputList[i];i++)n.name!==t&&n.setVisible(!e);for(var s of this.getIcons())s.updateCollapsed();e?(G(this.svgGroup,"blocklyCollapsed"),this.childHasWarning()&&this.setWarningText(r.Msg$$module$build$src$core$msg.COLLAPSED_WARNINGS_WARNING,Be.COLLAPSED_WARNING_ID),e=this.toString(rm),(s=this.getField(o))?s.setValue(e):(this.getInput(t)||this.appendDummyInput(t)).appendField(new Ps(e),o)):(this.updateDisabled(),this.removeInput(t),Te(this.svgGroup,"blocklyCollapsed"),this.setWarningText(null,Be.COLLAPSED_WARNING_ID))}onMouseDown(e){if(!this.workspace.isReadOnly()){var t=this.workspace.getGesture(e);t&&t.handleBlockStart(e,this)}}showHelp(){const e=typeof this.helpUrl=="function"?this.helpUrl():this.helpUrl;e&&window.open(e)}generateContextMenu(e){return this.workspace.isReadOnly()||!this.contextMenu?null:(e=Ee.registry.getContextMenuOptions({block:this,focusedNode:this},e),this.customContextMenu&&this.customContextMenu(e),e)}calculateContextMenuLocation(e){if(e instanceof PointerEvent)return new P(e.clientX,e.clientY);e=Ys(this.workspace,this.getRelativeToSurfaceXY());let t,o;const s=(t=this.inputList.filter(i=>i.isVisible()).flatMap(i=>i.fieldRow).find(i=>i.isVisible()))==null||(o=t.getSvgRoot())==null?void 0:o.getBoundingClientRect();return new P(this.RTL?e.x-5:e.x+5,(s&&s.height?s.y+s.height:e.y+this.height)+5)}showContextMenu(e){const t=this.generateContextMenu(e),o=this.calculateContextMenuLocation(e);t&&t.length&&(ii(e,t,this.RTL,this.workspace,o),Yc(this))}updateComponentLocations(e){this.dragging||this.updateConnectionLocations(e),this.updateIconLocations(e),this.updateFieldLocations(e);for(const t of this.getChildren(!1))t.updateComponentLocations(P.sum(e,t.relativeCoords))}updateConnectionLocations(e){for(const t of this.getConnections_(!1))t.moveToOffset(e)}updateIconLocations(e){for(const t of this.getIcons())t.onLocationChange(e)}updateFieldLocations(e){for(const t of this.inputList)for(const o of t.fieldRow)o.onLocationChange(e)}addClass(e){G(this.svgGroup,e)}removeClass(e){Te(this.svgGroup,e)}setDragging(e){(this.dragging=e)?(this.translation="",rr.push(...this.getConnections_(!0)),this.addClass("blocklyDragging")):(rr.length=0,this.removeClass("blocklyDragging"));for(let t=0;t<this.childBlocks_.length;t++)this.childBlocks_[t].setDragging(e)}setMovable(e){super.setMovable(e),this.pathObject.updateMovable(e)}setEditable(e){super.setEditable(e),e?Te(this.svgGroup,"blocklyNotEditable"):G(this.svgGroup,"blocklyNotEditable"),e=this.getIcons();for(let t=0;t<e.length;t++)e[t].updateEditable()}setShadow(e){super.setShadow(e),this.applyColour()}setInsertionMarker(e){this.isInsertionMarker_!==e&&(this.isInsertionMarker_=e)&&(this.setColour(this.workspace.getRenderer().getConstants().INSERTION_MARKER_COLOUR),this.pathObject.updateInsertionMarker(!0))}getSvgRoot(){return this.svgGroup}dispose(e,t){this.disposing=!0,Mc(),ji();const o=r.getFocusManager$$module$build$src$core$focus_manager();var s,i;if(this.getSvgRoot().contains((i=(s=o.getFocusedNode())==null?void 0:s.getFocusableElement())!=null?i:null)){if(s=this.getParent(),!s){let n;if(i=(n=this.outputConnection)!=null?n:this.previousConnection){let d;s=(d=i.closest(0,new P(0,0)).connection)==null?void 0:d.getSourceBlock()}}s?o.focusNode(s):setTimeout(()=>o.focusTree(this.workspace),0)}t&&(this.unplug(e),_n(this)),super.dispose(!!e),ke(this.svgGroup)}disposeInternal(){this.disposing=!0,super.disposeInternal(),r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode()===this&&this.workspace.cancelCurrentGesture(),[...this.warningTextDb.values()].forEach(e=>clearTimeout(e)),this.warningTextDb.clear(),this.getIcons().forEach(e=>e.dispose())}checkAndDelete(){this.workspace.isFlyout||(r.setGroup$$module$build$src$core$events$utils(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),r.setGroup$$module$build$src$core$events$utils(!1))}toCopyData(){return this.isInsertionMarker_?null:{paster:Er.TYPE,blockState:jt(this,{addCoordinates:!0,addNextBlocks:!1}),typeCounts:io(this,!0)}}applyColour(){var e,t;for((t=(e=this.pathObject).applyColour)==null||t.call(e,this),e=this.getIcons(),t=0;t<e.length;t++)e[t].applyColour();for(const o of this.getFields())o.applyColour()}updateDisabled(){const e=!this.isEnabled()||this.getInheritedDisabled();if(this.visuallyDisabled===e){let t;(t=this.getNextBlock())==null||t.updateDisabled()}else{this.applyColour(),this.visuallyDisabled=e;for(const t of this.getChildren(!1))t.updateDisabled()}}setWarningText(e,t=""){if(t)this.warningTextDb.has(t)&&(clearTimeout(this.warningTextDb.get(t)),this.warningTextDb.delete(t));else{for(var o of this.warningTextDb.values())clearTimeout(o);this.warningTextDb.clear()}if(this.workspace.isDragging())this.warningTextDb.set(t,setTimeout(()=>{this.isDeadOrDying()||(this.warningTextDb.delete(t),this.setWarningText(e,t))},100));else if(this.isInFlyout&&(e=null),o=this.getIcon(Co.TYPE),e){let s=this.getSurroundParent(),i=null;for(;s;)s.isCollapsed()&&(i=s),s=s.getSurroundParent();i&&i.setWarningText(r.Msg$$module$build$src$core$msg.COLLAPSED_WARNINGS_WARNING,Be.COLLAPSED_WARNING_ID),o?o.addMessage(e,t):this.addIcon(new Co(this).addMessage(e,t))}else o&&(t?(o.addMessage("",t),o.getText()||this.removeIcon(Co.TYPE)):this.removeIcon(Co.TYPE))}setMutator(e){this.removeIcon(r.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE),e&&this.addIcon(e)}addIcon(e){return super.addIcon(e),e instanceof r.MutatorIcon$$module$build$src$core$icons$mutator_icon&&(this.mutator=e),e.initView(this.createIconPointerDownListener(e)),e.applyColour(),e.updateEditable(),this.queueRender(),e}createIconPointerDownListener(e){return t=>{this.isDeadOrDying()||(t=this.workspace.getGesture(t))&&t.setStartIcon(e)}}removeIcon(e){const t=super.removeIcon(e);return e.equals(r.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE)&&(this.mutator=null),this.queueRender(),t}setDisabledReason(e,t){const o=this.isEnabled();super.setDisabledReason(e,t),this.isEnabled()===o||this.getInheritedDisabled()||this.updateDisabled()}setDeletable(e){super.setDeletable(e),e?Te(this.svgGroup,"blocklyNotDeletable"):G(this.svgGroup,"blocklyNotDeletable")}setHighlighted(e){this.pathObject.updateHighlighted(e)}addSelect(){this.pathObject.updateSelected(!0)}removeSelect(){this.pathObject.updateSelected(!1)}setDeleteStyle(e){this.pathObject.updateDraggingDelete(e)}getColour(){return this.style.colourPrimary}setColour(e){super.setColour(e),e=this.workspace.getRenderer().getConstants().getBlockStyleForColour(this.colour_);let t,o;(o=(t=this.pathObject).setStyle)==null||o.call(t,e.style),this.style=e.style,this.styleName_=e.name,this.applyColour()}setStyle(e){const t=this.workspace.getRenderer().getConstants().getBlockStyle(e);if(this.styleName_&&Te(this.svgGroup,this.styleName_),t){this.hat=t.hat;let o,s;(s=(o=this.pathObject).setStyle)==null||s.call(o,t),this.colour_=t.colourPrimary,this.style=t,this.applyColour(),G(this.svgGroup,e),this.styleName_=e}else throw Error("Invalid style name: "+e)}getStyle(){return this.style}bringToFront(e=!1){const t=r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode();let o=this;if(!o.isDeadOrDying()){do{const s=o.getSvgRoot(),i=s.parentNode,n=i.childNodes;if(n[n.length-1]!==s&&i.appendChild(s),e)break;o=o.getParent()}while(o);t&&r.getFocusManager$$module$build$src$core$focus_manager().focusNode(t)}}setPreviousStatement(e,t){super.setPreviousStatement(e,t),this.queueRender()}setNextStatement(e,t){super.setNextStatement(e,t),this.queueRender()}setOutput(e,t){super.setOutput(e,t),this.queueRender()}setInputsInline(e){super.setInputsInline(e),this.queueRender()}removeInput(e,t){return e=super.removeInput(e,t),this.queueRender(),e}moveNumberedInputBefore(e,t){super.moveNumberedInputBefore(e,t),this.queueRender()}appendInput(e){return super.appendInput(e),this.queueRender(),e}setConnectionTracking(e){if(this.previousConnection&&this.previousConnection.setTracking(e),this.outputConnection&&this.outputConnection.setTracking(e),this.nextConnection){this.nextConnection.setTracking(e);var t=this.nextConnection.targetBlock();t&&t.setConnectionTracking(e)}if(!this.collapsed_)for(t=0;t<this.inputList.length;t++){var o=this.inputList[t].connection;o&&(o.setTracking(e),(o=o.targetBlock())&&o.setConnectionTracking(e))}}getConnections_(e){const t=[];if(this.outputConnection&&t.push(this.outputConnection),this.previousConnection&&t.push(this.previousConnection),this.nextConnection&&t.push(this.nextConnection),e||!this.collapsed_)for(let o=0,s;s=this.inputList[o];o++)s.connection&&t.push(s.connection);return t}lastConnectionInStack(e){return super.lastConnectionInStack(e)}getMatchingConnection(e,t){return super.getMatchingConnection(e,t)}makeConnection_(e){return new _t(this,e)}getNextBlock(){return super.getNextBlock()}getPreviousBlock(){return super.getPreviousBlock()}bumpNeighbours(){const e=this.getRootBlock();if(!(this.isDeadOrDying()||this.workspace.isDragging()||e.isInFlyout))for(const t of this.getConnections_(!1)){if(t.isSuperior()){let o;(o=t.targetBlock())==null||o.bumpNeighbours()}for(const o of t.neighbours(r.config$$module$build$src$core$config.snapRadius))o.getSourceBlock().getRootBlock()!==e&&(t.isConnected()&&o.isConnected()||(t.isSuperior()?o.bumpAwayFrom(t,!1):t.bumpAwayFrom(o,!0)))}}scheduleSnapAndBump(){this.snapToGrid(),this.bumpNeighbours()}positionNearConnection(e,t,o){if(e.type===Z.NEXT_STATEMENT||e.type===Z.INPUT_VALUE){let s=t.x;t=t.y,s+=o.x-e.getOffsetInBlock().x,t+=o.y-e.getOffsetInBlock().y,this.moveBy(s,t)}}getChildren(e){return super.getChildren(e)}queueRender(){return tc(this)}render(){this.queueRender(),Qo()}renderEfficiently(){eo(),this.isCollapsed()&&this.updateCollapsed(),this.isEnabled()||this.updateDisabled(),this.workspace.getRenderer().render(this),this.tightenChildrenEfficiently(),to()}tightenChildrenEfficiently(){for(const e of this.inputList){const t=e.connection;t&&t.tightenEfficiently()}this.nextConnection&&this.nextConnection.tightenEfficiently()}getHeightWidth(){let e=this.height,t=this.width;var o=this.getNextBlock();if(o){o=o.getHeightWidth();const s=this.workspace.getRenderer().getConstants().NOTCH_HEIGHT;e+=o.height-s,t=Math.max(t,o.width)}return{height:e,width:t}}fadeForReplacement(e){this.pathObject.updateReplacementFade(e)}highlightShapeForInput(e,t){this.pathObject.updateShapeForInputHighlight(e,t)}getDragStrategy(){return this.dragStrategy}setDragStrategy(e){this.dragStrategy=e}isCopyable(){return this.isOwnDeletable()&&this.isOwnMovable()}isMovable(){return this.dragStrategy.isMovable()}startDrag(e){this.dragStrategy.startDrag(e)}drag(e,t){this.dragStrategy.drag(e,t)}endDrag(e){this.dragStrategy.endDrag(e)}revertDrag(){this.dragStrategy.revertDrag()}toFlyoutInfo(){const e=Object.assign({},{kind:"BLOCK"},jt(this)),t=new Set(["id","height","width","pinned","enabled"]),o=function(s){for(const i in s)t.has(i)?delete s[i]:typeof s[i]=="object"&&o(s[i])};return o(e),[e]}jsonInit(e){super.jsonInit(e),e.classes&&this.addClass(Array.isArray(e.classes)?e.classes.join(" "):e.classes)}getFocusableElement(){return this.pathObject.svgPath}getFocusableTree(){return this.workspace}onNodeFocus(){this.select()}onNodeBlur(){this.unselect()}canBeFocused(){return!0}};Be.INLINE=-1,Be.COLLAPSED_WARNING_ID="TEMP_COLLAPSED_WARNING_";var am=class{constructor(){}onDragEnter(e){}onDragOver(e){}onDragExit(e){}onDrop(e){}getClientRect(){return null}shouldPreventMove(e){return!1}},dl=class extends am{constructor(){super(),this.wouldDelete_=!1}wouldDelete(e){return e instanceof Be?(e=!e.getParent()&&e.isDeletable(),this.updateWouldDelete_(e)):this.updateWouldDelete_(Kt(e)&&e.isDeletable()),this.wouldDelete_}updateWouldDelete_(e){this.wouldDelete_=e}},Ci=class{constructor(e,t){this.element=e,this.type=t}getElement(){return this.element}getType(){return this.type}},Ya=class{constructor(e){this.workspace_=e}getDimensionsPx_(e){let t=0,o=0;return e&&(t=e.getWidth(),o=e.getHeight()),new ve(t,o)}getFlyoutMetrics(e){return e=this.getDimensionsPx_(this.workspace_.getFlyout(e)),{width:e.width,height:e.height,position:this.workspace_.toolboxPosition}}getToolboxMetrics(){const e=this.getDimensionsPx_(this.workspace_.getToolbox());return{width:e.width,height:e.height,position:this.workspace_.toolboxPosition}}getSvgMetrics(){return this.workspace_.getCachedParentSvgSize()}getAbsoluteMetrics(){let e=0,t=0;const o=this.getToolboxMetrics(),s=this.getFlyoutMetrics(),i=!!this.workspace_.getToolbox();var n;const d=!((n=this.workspace_.getFlyout())!=null&&n.autoClose);n=i?o.position:s.position;const f=n===be.TOP;return n===be.LEFT&&(i&&(e+=o.width),d&&(e+=s.width)),f&&(i&&(t+=o.height),d&&(t+=s.height)),{top:t,left:e}}getViewMetrics(e){e=e?this.workspace_.scale:1;const t=this.getSvgMetrics(),o=this.getToolboxMetrics(),s=this.getFlyoutMetrics(),i=!!this.workspace_.getToolbox();var n;const d=!((n=this.workspace_.getFlyout())!=null&&n.autoClose);n=i?o.position:s.position;const f=n===be.LEFT||n===be.RIGHT;return(n===be.TOP||n===be.BOTTOM)&&(i&&(t.height-=o.height),d&&(t.height-=s.height)),f&&(i&&(t.width-=o.width),d&&(t.width-=s.width)),{height:t.height/e,width:t.width/e,top:-this.workspace_.scrollY/e,left:-this.workspace_.scrollX/e}}getContentMetrics(e){e=e?1:this.workspace_.scale;const t=this.workspace_.getBlocksBoundingBox();return{height:(t.bottom-t.top)*e,width:(t.right-t.left)*e,top:t.top*e,left:t.left*e}}hasFixedEdges(){return!this.workspace_.isMovableHorizontally()||!this.workspace_.isMovableVertically()}getComputedFixedEdges_(e){if(!this.hasFixedEdges())return{};const t=this.workspace_.isMovableHorizontally(),o=this.workspace_.isMovableVertically();e=e||this.getViewMetrics(!1);const s={};return o||(s.top=e.top,s.bottom=e.top+e.height),t||(s.left=e.left,s.right=e.left+e.width),s}getPaddedContent_(e,t){const o=t.top+t.height,s=t.left+t.width,i=e.width;e=e.height;const n=i/2,d=e/2;return{top:Math.min(t.top-d,o-e),bottom:Math.max(o+d,t.top+e),left:Math.min(t.left-n,s-i),right:Math.max(s+n,t.left+i)}}getScrollMetrics(e,t,o){e=e?this.workspace_.scale:1,t=t||this.getViewMetrics(!1);var s=o||this.getContentMetrics();o=this.getComputedFixedEdges_(t),t=this.getPaddedContent_(t,s),s=o.top!==void 0?o.top:t.top;const i=o.left!==void 0?o.left:t.left;return{top:s/e,left:i/e,width:((o.right!==void 0?o.right:t.right)-i)/e,height:((o.bottom!==void 0?o.bottom:t.bottom)-s)/e}}getUiMetrics(){return{viewMetrics:this.getViewMetrics(),absoluteMetrics:this.getAbsoluteMetrics(),toolboxMetrics:this.getToolboxMetrics()}}getMetrics(){const e=this.getToolboxMetrics(),t=this.getFlyoutMetrics(!0),o=this.getSvgMetrics(),s=this.getAbsoluteMetrics(),i=this.getViewMetrics(),n=this.getContentMetrics(),d=this.getScrollMetrics(!1,i,n);return{contentHeight:n.height,contentWidth:n.width,contentTop:n.top,contentLeft:n.left,scrollHeight:d.height,scrollWidth:d.width,scrollTop:d.top,scrollLeft:d.left,viewHeight:i.height,viewWidth:i.width,viewTop:i.top,viewLeft:i.left,absoluteTop:s.top,absoluteLeft:s.left,svgHeight:o.height,svgWidth:o.width,toolboxWidth:e.width,toolboxHeight:e.height,toolboxPosition:e.position,flyoutWidth:t.width,flyoutHeight:t.height}}};l(M.METRICS_MANAGER,Ft,Ya);var hm=class extends Ya{constructor(e,t){super(e),this.flyout_=t}getBoundingBox(){let e;try{e=this.workspace_.getCanvas().getBBox()}catch{e={height:0,y:0,width:0,x:0}}return e}getContentMetrics(e){const t=this.getBoundingBox();return e=e?1:this.workspace_.scale,{height:t.height*e,width:t.width*e,top:t.y*e,left:t.x*e}}getScrollMetrics(e,t,o){return t=o||this.getContentMetrics(),o=this.flyout_.MARGIN*this.workspace_.scale,e=e?this.workspace_.scale:1,{height:(t.height+2*o)/e,width:(t.width+t.left+o)/e,top:0,left:0}}},xt=class{constructor(e,t,o,s){this.workspace=e,this.targetWorkspace=t,this.isFlyoutLabel=s,this.height=this.width=0,this.cursorSvg=this.svgText=null,this.text=o.text,this.position=new P(0,0),this.callbackKey=o.callbackKey||o.callbackkey,this.cssClass=o["web-class"]||null,this.info=o,e=this.isFlyoutLabel?"blocklyFlyoutLabel":"blocklyFlyoutButton",this.cssClass&&(e+=" "+this.cssClass),this.id=Re(),this.svgGroup=v(R.G,{id:this.id,class:e},this.workspace.getCanvas());let i;this.isFlyoutLabel||(i=v(R.RECT,{class:"blocklyFlyoutButtonShadow",rx:xt.BORDER_RADIUS,ry:xt.BORDER_RADIUS,x:1,y:1},this.svgGroup)),e=v(R.RECT,{class:this.isFlyoutLabel?"blocklyFlyoutLabelBackground":"blocklyFlyoutButtonBackground",rx:xt.BORDER_RADIUS,ry:xt.BORDER_RADIUS},this.svgGroup),t=v(R.TEXT,{class:this.isFlyoutLabel?"blocklyFlyoutLabelText":"blocklyText",x:0,y:0,"text-anchor":"middle"},this.svgGroup),o=Je(this.text),this.workspace.RTL&&(o+="‏"),t.textContent=o,this.isFlyoutLabel&&(this.svgText=t,this.workspace.getThemeManager().subscribe(this.svgText,"flyoutForegroundColour","fill")),s=Mt(t,"fontSize");const n=Mt(t,"fontWeight"),d=Mt(t,"fontFamily");if(this.width=ho(t,s,n,d),o=E(o,s,n,d),this.height=this.height||o.height,!this.isFlyoutLabel){this.width+=2*xt.TEXT_MARGIN_X,this.height+=2*xt.TEXT_MARGIN_Y;let f;(f=i)==null||f.setAttribute("width",String(this.width));let L;(L=i)==null||L.setAttribute("height",String(this.height))}e.setAttribute("width",String(this.width)),e.setAttribute("height",String(this.height)),t.setAttribute("x",String(this.width/2)),t.setAttribute("y",String(this.height/2-o.height/2+o.baseline)),this.updateTransform(),this.onMouseDownWrapper=z(this.svgGroup,"pointerdown",this,this.onMouseDown),this.onMouseUpWrapper=z(this.svgGroup,"pointerup",this,this.onMouseUp)}createDom(){return this.svgGroup}show(){this.updateTransform(),this.svgGroup.setAttribute("display","block")}updateTransform(){this.svgGroup.setAttribute("transform","translate("+this.position.x+","+this.position.y+")")}moveTo(e,t){this.position.x=e,this.position.y=t,this.updateTransform()}moveBy(e,t,o){this.moveTo(this.position.x+e,this.position.y+t)}isLabel(){return this.isFlyoutLabel}getPosition(){return this.position}getBoundingRectangle(){return new ye(this.position.y,this.position.y+this.height,this.position.x,this.position.x+this.width)}getButtonText(){return this.text}getTargetWorkspace(){return this.targetWorkspace}getWorkspace(){return this.workspace}dispose(){te(this.onMouseDownWrapper),te(this.onMouseUpWrapper),this.svgGroup&&ke(this.svgGroup),this.svgText&&this.workspace.getThemeManager().unsubscribe(this.svgText)}setCursorSvg(e){e?this.svgGroup&&(this.svgGroup.appendChild(e),this.cursorSvg=e):this.cursorSvg=null}onMouseUp(e){(e=this.targetWorkspace.getGesture(e))&&e.cancel(),this.isFlyoutLabel&&this.callbackKey?console.warn("Labels should not have callbacks. Label text: "+this.text):this.isFlyoutLabel||this.callbackKey&&this.targetWorkspace.getButtonCallback(this.callbackKey)?this.isFlyoutLabel||(e=this.targetWorkspace.getButtonCallback(this.callbackKey))&&e(this):console.warn("Buttons should have callbacks. Button text: "+this.text)}onMouseDown(e){const t=this.targetWorkspace.getGesture(e),o=this.targetWorkspace.getFlyout();t&&o&&t.handleFlyoutStart(e,o)}getSvgRoot(){return this.svgGroup}getFocusableElement(){return this.svgGroup}getFocusableTree(){return this.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}};xt.TEXT_MARGIN_X=5,xt.TEXT_MARGIN_Y=2,xt.BORDER_RADIUS=4,q(`
620
+ the string literal 'separator'. Found: ${s}`))}if(t)throw TypeError("Found invalid FieldDropdown options.")}};yt.SEPARATOR="separator",yt.ARROW_CHAR="▾",yt.IMAGE_Y_OFFSET=5,yt.IMAGE_Y_PADDING=yt.IMAGE_Y_OFFSET*2,_o("field_dropdown",yt);var Bs=class{constructor(e,t,o,s){this.name=e,this.startHats=!1,this.blockStyles=t||Object.create(null),this.categoryStyles=o||Object.create(null),this.componentStyles=s||Object.create(null),this.fontStyle=Object.create(null),l(M.THEME,e,this,!0)}getClassName(){return this.name+"-theme"}setBlockStyle(e,t){this.blockStyles[e]=t}setCategoryStyle(e,t){this.categoryStyles[e]=t}getComponentStyle(e){if(e=this.componentStyles[e],!e)return null;if(typeof e=="string"){const t=this.getComponentStyle(e);if(t)return t}return`${e}`}setComponentStyle(e,t){this.componentStyles[e]=t}setFontStyle(e){this.fontStyle=e}setStartHats(e){this.startHats=e}static defineTheme(e,t){e=e.toLowerCase();const o=new Bs(e);let s=t.base;if(s){if(typeof s=="string"){let i;s=(i=D(M.THEME,s))!=null?i:void 0}s instanceof Bs&&(He(o,s),o.name=e)}return He(o.blockStyles,t.blockStyles),He(o.categoryStyles,t.categoryStyles),He(o.componentStyles,t.componentStyles),He(o.fontStyle,t.fontStyle),t.startHats!==null&&(o.startHats=t.startHats),o}},Sb={colour_blocks:{colourPrimary:"20"},list_blocks:{colourPrimary:"260"},logic_blocks:{colourPrimary:"210"},loop_blocks:{colourPrimary:"120"},math_blocks:{colourPrimary:"230"},procedure_blocks:{colourPrimary:"290"},text_blocks:{colourPrimary:"160"},variable_blocks:{colourPrimary:"330"},variable_dynamic_blocks:{colourPrimary:"310"},hat_blocks:{colourPrimary:"330",hat:"cap"}},kb={colour_category:{colour:"20"},list_category:{colour:"260"},logic_category:{colour:"210"},loop_category:{colour:"120"},math_category:{colour:"230"},procedure_category:{colour:"290"},text_category:{colour:"160"},variable_category:{colour:"330"},variable_dynamic_category:{colour:"310"}},cl=new Bs("classic",Sb,kb),vo=class{constructor(e){this.gridPattern=null,this.getMetrics=this.setMetrics=void 0;let t=null,o=!1;var s=!1,i=!1,n=!1,d=!1,f=!1;const L=!!e.readOnly;if(!L){var oe;t=Fr((oe=e.toolbox)!=null?oe:null),o=Ur(t),s=e.trashcan,s=s===void 0?o:s,i=e.collapse,i=i===void 0?o:i,n=e.comments,n=n===void 0?o:n,d=e.disable,d=d===void 0?o:d,f=e.sounds,f=f===void 0?!0:f}oe=e.maxTrashcanContents,s?oe===void 0&&(oe=32):oe=0;const ze=!!e.rtl;let Fe=e.horizontalLayout;Fe===void 0&&(Fe=!1);var vt=e.toolboxPosition!=="end";vt=Fe?vt?be.TOP:be.BOTTOM:vt===ze?be.RIGHT:be.LEFT;let jo=e.css;jo===void 0&&(jo=!0);let Ao="https://blockly-demo.appspot.com/static/media/";e.media&&(Ao=e.media.endsWith("/")?e.media:e.media+"/");const Xf=e.oneBasedIndex,rT=e.renderer||"geras",nT=e.plugins||{};let Uh=e.modalInputs;Uh===void 0&&(Uh=!0),this.RTL=ze,this.oneBasedIndex=Xf===void 0?!0:Xf,this.collapse=i,this.comments=n,this.disable=d,this.readOnly=L,this.maxBlocks=e.maxBlocks||1/0;let jf;this.maxInstances=(jf=e.maxInstances)!=null?jf:null,this.modalInputs=Uh,this.pathToMedia=Ao,this.hasCategories=o,this.moveOptions=vo.parseMoveOptions(e,o),this.hasScrollbars=!!this.moveOptions.scrollbars,this.hasTrashcan=s,this.maxTrashcanContents=oe,this.hasSounds=f,this.hasCss=jo,this.horizontalLayout=Fe,this.languageTree=t,this.gridOptions=vo.parseGridOptions(e),this.zoomOptions=vo.parseZoomOptions(e),this.toolboxPosition=vt,this.theme=vo.parseThemeOptions(e),this.renderer=rT;let Kf;this.rendererOverrides=(Kf=e.rendererOverrides)!=null?Kf:null;let Jf;this.parentWorkspace=(Jf=e.parentWorkspace)!=null?Jf:null,this.plugins=nT}static parseMoveOptions(e,t){const o=e.move||{},s={};return o.scrollbars===void 0&&e.scrollbars===void 0?s.scrollbars=t:typeof o.scrollbars=="object"?(s.scrollbars={horizontal:!!o.scrollbars.horizontal,vertical:!!o.scrollbars.vertical},s.scrollbars.horizontal&&s.scrollbars.vertical?s.scrollbars=!0:s.scrollbars.horizontal||s.scrollbars.vertical||(s.scrollbars=!1)):s.scrollbars=!!o.scrollbars||!!e.scrollbars,s.wheel=s.scrollbars&&o.wheel!==void 0?!!o.wheel:typeof s.scrollbars=="object",s.drag=s.scrollbars?o.drag===void 0?!0:!!o.drag:!1,s}static parseZoomOptions(e){e=e.zoom||{};const t={};return t.controls=e.controls===void 0?!1:!!e.controls,t.wheel=e.wheel===void 0?!1:!!e.wheel,t.startScale=e.startScale===void 0?1:Number(e.startScale),t.maxScale=e.maxScale===void 0?3:Number(e.maxScale),t.minScale=e.minScale===void 0?.3:Number(e.minScale),t.scaleSpeed=e.scaleSpeed===void 0?1.2:Number(e.scaleSpeed),t.pinch=e.pinch===void 0?t.wheel||t.controls:!!e.pinch,t}static parseGridOptions(e){e=e.grid||{};const t={};return t.spacing=Number(e.spacing)||0,t.colour=e.colour||"#888",t.length=e.length===void 0?1:Number(e.length),t.snap=t.spacing>0&&!!e.snap,t}static parseThemeOptions(e){return e=e.theme||cl,typeof e=="string"?D(M.THEME,e):e instanceof Bs?e:Bs.defineTheme(e.name||"builtin"+Re(),e)}},rm=class{constructor(e,t){this.bubble=e,this.workspace=t,this.startLoc=null}isMovable(){return!0}startDrag(){this.startLoc=this.bubble.getRelativeToSurfaceXY(),this.workspace.setResizesEnabled(!1);let e;(e=this.workspace.getLayerManager())==null||e.moveToDragLayer(this.bubble),this.bubble.setDragging&&this.bubble.setDragging(!0)}drag(e){this.bubble.moveDuringDrag(e)}endDrag(){this.workspace.setResizesEnabled(!0);let e;(e=this.workspace.getLayerManager())==null||e.moveOffDragLayer(this.bubble,il),this.bubble.setDragging(!1)}revertDrag(){this.startLoc&&this.bubble.moveDuringDrag(this.startLoc)}},zt,Oe=class{constructor(e,t,o,s){this.workspace=e,this.anchor=t,this.ownerRect=o,this.size=new ve(0,0),this.colour="#ffffff",this.disposed=!1,this.relativeLeft=this.relativeTop=0,this.dragStrategy=new rm(this,this.workspace),this.id=Re(),this.svgRoot=v(R.G,{class:"blocklyBubble"},e.getBubbleCanvas()),e=v(R.G,{class:"blocklyEmboss"},this.svgRoot),this.tail=v(R.PATH,{class:"blocklyBubbleTail"},e),this.background=v(R.RECT,{class:"blocklyDraggable",x:0,y:0,rx:zt.BORDER_WIDTH,ry:zt.BORDER_WIDTH},e),this.contentContainer=v(R.G,{},this.svgRoot),this.focusableElement=s??this.svgRoot,this.focusableElement.setAttribute("id",this.id),z(this.background,"pointerdown",this,this.onMouseDown)}dispose(){ke(this.svgRoot),this.disposed=!0}setAnchorLocation(e,t=!1){this.anchor=e,t?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor(),this.renderTail()}setPositionRelativeToAnchor(e,t){this.relativeLeft=e,this.relativeTop=t,this.positionRelativeToAnchor(),this.renderTail()}getSize(){return this.size}setSize(e,t=!1){e.width=Math.max(e.width,zt.MIN_SIZE),e.height=Math.max(e.height,zt.MIN_SIZE),this.size=e,this.background.setAttribute("width",`${e.width}`),this.background.setAttribute("height",`${e.height}`),t?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor(),this.renderTail()}getColour(){return this.colour}setColour(e){this.colour=e,this.tail.setAttribute("fill",e),this.background.setAttribute("fill",e)}onMouseDown(e){let t;(t=this.workspace.getGesture(e))==null||t.handleBubbleStart(e,this),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this)}positionRelativeToAnchor(){let e=this.anchor.x;e=this.workspace.RTL?e-(this.relativeLeft+this.size.width):e+this.relativeLeft,this.moveTo(e,this.relativeTop+this.anchor.y)}moveTo(e,t){this.svgRoot.setAttribute("transform",`translate(${e}, ${t})`)}positionByRect(e=new ye(0,0,0,0)){var t=this.workspace.getMetricsManager().getViewMetrics(!0),o=this.getOptimalRelativeLeft(t),s=this.getOptimalRelativeTop(t);const i={x:o,y:-this.size.height-this.workspace.getRenderer().getConstants().MIN_BLOCK_HEIGHT},n={x:-this.size.width-30,y:s};s={x:e.getWidth(),y:s};var d={x:o,y:e.getHeight()};o=e.getWidth()<e.getHeight()?s:d,e=e.getWidth()<e.getHeight()?d:s,s=this.getOverlap(i,t),d=this.getOverlap(n,t);const f=this.getOverlap(o,t);t=this.getOverlap(e,t),t=Math.max(s,d,f,t),s===t?(this.relativeLeft=i.x,this.relativeTop=i.y):d===t?(this.relativeLeft=n.x,this.relativeTop=n.y):f===t?(this.relativeLeft=o.x,this.relativeTop=o.y):(this.relativeLeft=e.x,this.relativeTop=e.y),this.positionRelativeToAnchor()}getOverlap(e,t){var o=this.workspace.RTL?this.anchor.x-e.x-this.size.width:e.x+this.anchor.x;return e=e.y+this.anchor.y,Math.max(0,Math.min(1,(Math.min(o+this.size.width,t.left+t.width)-Math.max(o,t.left))*(Math.min(e+this.size.height,t.top+t.height)-Math.max(e,t.top))/(this.size.width*this.size.height)))}getOptimalRelativeLeft(e){let t=-this.size.width/4;if(this.size.width>e.width)return t;if(e=this.getWorkspaceViewRect(e),this.workspace.RTL){var o=this.anchor.x-t;o-this.size.width<e.left?t=-(e.left-this.anchor.x+this.size.width):o>e.right&&(t=-(e.right-this.anchor.x))}else{o=t+this.anchor.x;const s=o+this.size.width;o<e.left?t=e.left-this.anchor.x:s>e.right&&(t=e.right-this.anchor.x-this.size.width)}return t}getOptimalRelativeTop(e){let t=-this.size.height/4;if(this.size.height>e.height)return t;const o=this.anchor.y+t,s=o+this.size.height;return e=this.getWorkspaceViewRect(e),o<e.top?t=e.top-this.anchor.y:s>e.bottom&&(t=e.bottom-this.anchor.y-this.size.height),t}getWorkspaceViewRect(e){const t=e.top;let o=e.top+e.height,s=e.left;return e=e.left+e.width,o-=this.getScrollbarThickness(),this.workspace.RTL?s-=this.getScrollbarThickness():e-=this.getScrollbarThickness(),new ye(t,o,s,e)}getScrollbarThickness(){return Ze.scrollbarThickness/this.workspace.scale}renderTail(){const e=[];var t=this.size.width/2,o=this.size.height/2,s=-this.relativeLeft,i=-this.relativeTop;if(t===s&&o===i)e.push("M "+t+","+o);else{i-=o,s-=t,this.workspace.RTL&&(s*=-1);var n=Math.sqrt(i*i+s*s),d=Math.acos(s/n);i<0&&(d=2*Math.PI-d);var f=d+Math.PI/2;f>Math.PI*2&&(f-=Math.PI*2);var L=Math.sin(f);const ze=Math.cos(f);let Fe=(this.size.width+this.size.height)/zt.TAIL_THICKNESS;Fe=Math.min(Fe,this.size.width,this.size.height)/4,f=1-zt.ANCHOR_RADIUS/n,s=t+f*s,i=o+f*i,f=t+Fe*ze;const vt=o+Fe*L;t-=Fe*ze,o-=Fe*L,L=tn(this.workspace.RTL?-zt.TAIL_ANGLE:zt.TAIL_ANGLE),L=d+L,L>Math.PI*2&&(L-=Math.PI*2),d=Math.sin(L)*n/zt.TAIL_BEND,n=Math.cos(L)*n/zt.TAIL_BEND,e.push("M"+f+","+vt),e.push("C"+(f+n)+","+(vt+d)+" "+s+","+i+" "+s+","+i),e.push("C"+s+","+i+" "+(t+n)+","+(o+d)+" "+t+","+o)}e.push("z");let oe;(oe=this.tail)==null||oe.setAttribute("d",e.join(" "))}bringToFront(){let e;const t=(e=this.svgRoot)==null?void 0:e.parentNode;return this.svgRoot&&t?.lastChild!==this.svgRoot?(t?.appendChild(this.svgRoot),!0):!1}getRelativeToSurfaceXY(){return new P(this.workspace.RTL?-this.relativeLeft+this.anchor.x-this.size.width:this.anchor.x+this.relativeLeft,this.anchor.y+this.relativeTop)}getSvgRoot(){return this.svgRoot}moveDuringDrag(e){this.moveTo(e.x,e.y),this.relativeLeft=this.workspace.RTL?this.anchor.x-e.x-this.size.width:e.x-this.anchor.x,this.relativeTop=e.y-this.anchor.y,this.renderTail()}setDragging(e){}setDeleteStyle(e){}isDeletable(){return!1}showContextMenu(e){}isMovable(){return!0}startDrag(){this.dragStrategy.startDrag()}drag(e){this.dragStrategy.drag(e)}endDrag(){this.dragStrategy.endDrag()}revertDrag(){this.dragStrategy.revertDrag()}select(){V(this)}unselect(){V(null)}getFocusableElement(){return this.focusableElement}getFocusableTree(){return this.workspace}onNodeFocus(){this.select(),this.bringToFront()}onNodeBlur(){this.unselect()}canBeFocused(){return!0}};zt=Oe,Oe.BORDER_WIDTH=6,Oe.DOUBLE_BORDER=zt.BORDER_WIDTH*2,Oe.MIN_SIZE=zt.DOUBLE_BORDER,Oe.TAIL_THICKNESS=1,Oe.TAIL_ANGLE=20,Oe.TAIL_BEND=4,Oe.ANCHOR_RADIUS=8;var Wo=class extends Oe{constructor(e,t,o,s){super(t,o,s),this.workspace=t,this.anchor=o,this.ownerRect=s,this.autoLayout=!0,t=new vo(e),this.validateWorkspaceOptions(t),this.svgDialog=v(R.SVG,{x:Oe.BORDER_WIDTH,y:Oe.BORDER_WIDTH},this.contentContainer),e.parentWorkspace=this.workspace,this.miniWorkspace=this.newWorkspaceSvg(new vo(e)),this.miniWorkspace.internalIsMutator=!0,e=this.miniWorkspace.createDom("blocklyMutatorBackground"),this.svgDialog.appendChild(e),t.languageTree&&(e.insertBefore(this.miniWorkspace.addFlyout(R.G),this.miniWorkspace.getCanvas()),e=this.miniWorkspace.getFlyout(),e?.init(this.miniWorkspace),e?.show(t.languageTree)),G(this.svgRoot,"blocklyMiniWorkspaceBubble"),this.miniWorkspace.addChangeListener(this.onWorkspaceChange.bind(this));let i,n;(i=this.miniWorkspace.getFlyout())==null||(n=i.getWorkspace())==null||n.addChangeListener(this.onWorkspaceChange.bind(this)),this.updateBubbleSize()}dispose(){this.miniWorkspace.dispose(),super.dispose()}getWorkspace(){return this.miniWorkspace}addWorkspaceChangeListener(e){this.miniWorkspace.addChangeListener(e)}validateWorkspaceOptions(e){if(e.hasCategories)throw Error("The miniworkspace bubble does not support toolboxes with categories");if(e.hasTrashcan)throw Error("The miniworkspace bubble does not support trashcans");if(e.zoomOptions.controls||e.zoomOptions.wheel||e.zoomOptions.pinch)throw Error("The miniworkspace bubble does not support zooming");if(e.moveOptions.scrollbars||e.moveOptions.wheel||e.moveOptions.drag)throw Error("The miniworkspace bubble does not scrolling/moving the workspace");if(e.horizontalLayout)throw Error("The miniworkspace bubble does not support horizontal layouts")}onWorkspaceChange(){this.bumpBlocksIntoBounds(),this.updateBubbleSize()}bumpBlocksIntoBounds(){if(!this.miniWorkspace.isDragging()||this.miniWorkspace.keyboardMoveInProgress)for(const e of this.miniWorkspace.getTopBlocks(!1)){const t=e.getRelativeToSurfaceXY();if(t.y<20&&e.moveBy(0,20-t.y),e.RTL){let o=-20;const s=this.miniWorkspace.getFlyout();s&&(o-=s.getWidth()),t.x>o&&e.moveBy(o-t.x,0)}else t.x<20&&e.moveBy(20-t.x,0)}}updateBubbleSize(){if(!this.miniWorkspace.isDragging()||this.miniWorkspace.keyboardMoveInProgress){this.autoLayout&&(this.autoLayout=!this.miniWorkspace.keyboardMoveInProgress);var e=this.getSize(),t=this.calculateWorkspaceSize();Math.abs(e.width-t.width)<Wo.MINIMUM_VIEW_CHANGE&&Math.abs(e.height-t.height)<Wo.MINIMUM_VIEW_CHANGE||(this.svgDialog.setAttribute("width",`${t.width}px`),this.svgDialog.setAttribute("height",`${t.height}px`),this.miniWorkspace.setCachedParentSvgSize(t.width,t.height),this.miniWorkspace.RTL&&this.miniWorkspace.getCanvas().setAttribute("transform",`translate(${t.width}, 0)`),this.setSize(new ve(t.width+Oe.DOUBLE_BORDER,t.height+Oe.DOUBLE_BORDER),this.autoLayout),this.miniWorkspace.resize(),this.miniWorkspace.recordDragTargets())}}calculateWorkspaceSize(){var e=this.miniWorkspace.getCanvas().getBBox();let t=e.width+Wo.MARGIN;e=e.height+Wo.MARGIN;const o=this.miniWorkspace.getFlyout();if(o){const s=o.getWorkspace().getMetricsManager().getScrollMetrics();e=Math.max(e,s.height+20),t+=o.getWidth()}return new ve(t,e)}updateBlockStyles(){for(var e of this.miniWorkspace.getAllBlocks(!1))e.setStyle(e.getStyleName());let t;if(e=(t=this.miniWorkspace.getFlyout())==null?void 0:t.getWorkspace())for(const o of e.getAllBlocks(!1))o.setStyle(o.getStyleName())}moveDuringDrag(e){super.moveDuringDrag(e),this.autoLayout=!1}moveTo(e,t){super.moveTo(e,t),this.miniWorkspace.recordDragTargets()}newWorkspaceSvg(e){throw Error("The implementation of newWorkspaceSvg should be monkey-patched in by blockly.ts")}};Wo.MINIMUM_VIEW_CHANGE=10,Wo.MARGIN=Oe.DOUBLE_BORDER*3;var br=class{constructor(e){this.sourceBlock=e,this.offsetInBlock=new P(0,0),this.workspaceLocation=new P(0,0),this.svgRoot=null,this.tooltip=e,this.id=Re()}getType(){throw Error("Icons must implement getType")}initView(e){if(!this.svgRoot){var t=this.sourceBlock;this.svgRoot=v(R.G,{class:"blocklyIconGroup",id:this.id}),t.getSvgRoot().appendChild(this.svgRoot),this.updateSvgRootOffset(),z(this.svgRoot,"pointerdown",this,e),this.svgRoot.tooltip=this,Yi(this.svgRoot)}}dispose(){Mc(this.svgRoot),ke(this.svgRoot)}getWeight(){return-1}getSize(){return new ve(0,0)}setTooltip(e){this.tooltip=e??this.sourceBlock}getTooltip(){return this.tooltip}applyColour(){}updateEditable(){}updateCollapsed(){this.svgRoot&&(this.sourceBlock.isCollapsed()?this.svgRoot.style.display="none":this.svgRoot.style.display="block",Ts(this)&&this.setBubbleVisible(!1))}hideForInsertionMarker(){this.svgRoot&&(this.svgRoot.style.display="none")}isShownWhenCollapsed(){return!1}setOffsetInBlock(e){this.offsetInBlock=e,this.updateSvgRootOffset()}updateSvgRootOffset(){let e;(e=this.svgRoot)==null||e.setAttribute("transform",`translate(${this.offsetInBlock.x}, ${this.offsetInBlock.y})`)}onLocationChange(e){this.workspaceLocation=P.sum(e,this.offsetInBlock)}onClick(){}isClickableInFlyout(e){return!0}getFocusableElement(){const e=this.svgRoot;if(!e)throw Error("Attempting to focus uninitialized icon.");return e}getFocusableTree(){return this.sourceBlock.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}getSourceBlock(){return this.sourceBlock}},ul,al;ul=17,al=16,r.MutatorIcon$$module$build$src$core$icons$mutator_icon=class extends br{constructor(e,t){super(t),this.flyoutBlockTypes=e,this.sourceBlock=t,this.saveConnectionsListener=this.updateWorkspacePid=this.rootBlock=this.miniWorkspaceBubble=null}getType(){return r.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE}initView(e){this.svgRoot||(super.initView(e),v(R.RECT,{class:"blocklyIconShape",rx:"4",ry:"4",height:"16",width:"16"},this.svgRoot),v(R.PATH,{class:"blocklyIconSymbol",d:"m4.203,7.296 0,1.368 -0.92,0.677 -0.11,0.41 0.9,1.559 0.41,0.11 1.043,-0.457 1.187,0.683 0.127,1.134 0.3,0.3 1.8,0 0.3,-0.299 0.127,-1.138 1.185,-0.682 1.046,0.458 0.409,-0.11 0.9,-1.559 -0.11,-0.41 -0.92,-0.677 0,-1.366 0.92,-0.677 0.11,-0.41 -0.9,-1.559 -0.409,-0.109 -1.046,0.458 -1.185,-0.682 -0.127,-1.138 -0.3,-0.299 -1.8,0 -0.3,0.3 -0.126,1.135 -1.187,0.682 -1.043,-0.457 -0.41,0.11 -0.899,1.559 0.108,0.409z"},this.svgRoot),v(R.CIRCLE,{class:"blocklyIconShape",r:"2.7",cx:"8",cy:"8"},this.svgRoot),G(this.svgRoot,"blocklyMutatorIcon"))}dispose(){super.dispose();let e;(e=this.miniWorkspaceBubble)==null||e.dispose()}getWeight(){return r.MutatorIcon$$module$build$src$core$icons$mutator_icon.WEIGHT}getSize(){return new ve(ul,ul)}applyColour(){super.applyColour();let e;(e=this.miniWorkspaceBubble)==null||e.setColour(this.sourceBlock.getColour());let t;(t=this.miniWorkspaceBubble)==null||t.updateBlockStyles()}updateCollapsed(){super.updateCollapsed(),this.sourceBlock.isCollapsed()&&this.setBubbleVisible(!1)}onLocationChange(e){super.onLocationChange(e);let t;(t=this.miniWorkspaceBubble)==null||t.setAnchorLocation(this.getAnchorLocation())}onClick(){super.onClick(),this.sourceBlock.isEditable()&&this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.miniWorkspaceBubble}setBubbleVisible(e){const t=this;return(0,N.asyncExecutePromiseGeneratorFunction)(function*(){if(t.bubbleIsVisible()!==e){if(yield go(),e){t.miniWorkspaceBubble=new Wo(t.getMiniWorkspaceConfig(),t.sourceBlock.workspace,t.getAnchorLocation(),t.getBubbleOwnerRect()),t.applyColour(),t.createRootBlock(),t.addSaveConnectionsListener();let o;(o=t.miniWorkspaceBubble)==null||o.addWorkspaceChangeListener(t.createMiniWorkspaceChangeListener())}else{let o;(o=t.miniWorkspaceBubble)==null||o.dispose(),t.miniWorkspaceBubble=null,t.saveConnectionsListener&&t.sourceBlock.workspace.removeChangeListener(t.saveConnectionsListener),t.saveConnectionsListener=null}_(new(U(w.BUBBLE_OPEN))(t.sourceBlock,e,"mutator"))}})}getBubble(){return this.miniWorkspaceBubble}getMiniWorkspaceConfig(){let e;const t={disable:!1,media:this.sourceBlock.workspace.options.pathToMedia,rtl:this.sourceBlock.RTL,renderer:this.sourceBlock.workspace.options.renderer,rendererOverrides:(e=this.sourceBlock.workspace.options.rendererOverrides)!=null?e:void 0};return this.flyoutBlockTypes.length&&(t.toolbox={kind:"flyoutToolbox",contents:this.flyoutBlockTypes.map(o=>({kind:"block",type:o}))}),t}getAnchorLocation(){const e=ul/2;return P.sum(this.workspaceLocation,new P(e,e))}getBubbleOwnerRect(){const e=this.sourceBlock.getSvgRoot().getBBox();return new ye(e.y,e.y+e.height,e.x,e.x+e.width)}createRootBlock(){if(!this.sourceBlock.decompose)throw Error("Blocks with mutator icons must include a decompose method");this.rootBlock=this.sourceBlock.decompose(this.miniWorkspaceBubble.getWorkspace());for(var e of this.rootBlock.getDescendants(!1))e.queueRender();this.rootBlock.setMovable(!1),this.rootBlock.setDeletable(!1);let t,o,s,i;e=(i=(t=this.miniWorkspaceBubble)==null||(o=t.getWorkspace())==null||(s=o.getFlyout())==null?void 0:s.getWidth())!=null?i:0,this.rootBlock.moveBy(this.rootBlock.RTL?-(e+al):al,al)}addSaveConnectionsListener(){this.sourceBlock.saveConnections&&this.rootBlock&&(this.saveConnectionsListener=()=>{this.sourceBlock.saveConnections&&this.rootBlock&&this.sourceBlock.saveConnections(this.rootBlock)},this.saveConnectionsListener(),this.sourceBlock.workspace.addChangeListener(this.saveConnectionsListener))}createMiniWorkspaceChangeListener(){return e=>{r.MutatorIcon$$module$build$src$core$icons$mutator_icon.isIgnorableMutatorEvent(e)||this.updateWorkspacePid||(this.updateWorkspacePid=setTimeout(()=>{this.updateWorkspacePid=null,this.recomposeSourceBlock()},0))}}static isIgnorableMutatorEvent(e){return e.isUiEvent||bt(e)||Ct(e)&&e.element==="disabled"}recomposeSourceBlock(){if(this.rootBlock){if(!this.sourceBlock.compose)throw Error("Blocks with mutator icons must include a compose method");var e=r.getGroup$$module$build$src$core$events$utils();e||r.setGroup$$module$build$src$core$events$utils(!0);var t=As.getExtraBlockState_(this.sourceBlock);this.sourceBlock.compose(this.rootBlock);var o=As.getExtraBlockState_(this.sourceBlock);t!==o&&_(new(U(w.BLOCK_CHANGE))(this.sourceBlock,"mutation",null,t,o)),r.setGroup$$module$build$src$core$events$utils(e)}}getWorkspace(){let e;return(e=this.miniWorkspaceBubble)==null?void 0:e.getWorkspace()}},r.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE=ut.MUTATOR,r.MutatorIcon$$module$build$src$core$icons$mutator_icon.WEIGHT=1,r.MutatorIcon$$module$build$src$core$icons$mutator_icon;var yi=Object.create(null),Rb={allExtensions:yi};r.register$$module$build$src$core$extensions("parent_tooltip_when_inline",ep);var co={TEST_ONLY:Rb};co.apply=mn,co.buildTooltipForDropdown=r.buildTooltipForDropdown$$module$build$src$core$extensions,co.buildTooltipWithFieldText=r.buildTooltipWithFieldText$$module$build$src$core$extensions,co.isRegistered=su,co.register=r.register$$module$build$src$core$extensions,co.registerMixin=r.registerMixin$$module$build$src$core$extensions,co.registerMutator=r.registerMutator$$module$build$src$core$extensions,co.runAfterPageLoad=Z$,co.unregister=X$;var Le;(function(e){e[e.WIN_KEY_FF_LINUX=0]="WIN_KEY_FF_LINUX",e[e.MAC_ENTER=3]="MAC_ENTER",e[e.BACKSPACE=8]="BACKSPACE",e[e.TAB=9]="TAB",e[e.NUM_CENTER=12]="NUM_CENTER",e[e.ENTER=13]="ENTER",e[e.SHIFT=16]="SHIFT",e[e.CTRL=17]="CTRL",e[e.ALT=18]="ALT",e[e.PAUSE=19]="PAUSE",e[e.CAPS_LOCK=20]="CAPS_LOCK",e[e.ESC=27]="ESC",e[e.SPACE=32]="SPACE",e[e.PAGE_UP=33]="PAGE_UP",e[e.PAGE_DOWN=34]="PAGE_DOWN",e[e.END=35]="END",e[e.HOME=36]="HOME",e[e.LEFT=37]="LEFT",e[e.UP=38]="UP",e[e.RIGHT=39]="RIGHT",e[e.DOWN=40]="DOWN",e[e.PLUS_SIGN=43]="PLUS_SIGN",e[e.PRINT_SCREEN=44]="PRINT_SCREEN",e[e.INSERT=45]="INSERT",e[e.DELETE=46]="DELETE",e[e.ZERO=48]="ZERO",e[e.ONE=49]="ONE",e[e.TWO=50]="TWO",e[e.THREE=51]="THREE",e[e.FOUR=52]="FOUR",e[e.FIVE=53]="FIVE",e[e.SIX=54]="SIX",e[e.SEVEN=55]="SEVEN",e[e.EIGHT=56]="EIGHT",e[e.NINE=57]="NINE",e[e.FF_SEMICOLON=59]="FF_SEMICOLON",e[e.FF_EQUALS=61]="FF_EQUALS",e[e.FF_DASH=173]="FF_DASH",e[e.FF_HASH=163]="FF_HASH",e[e.QUESTION_MARK=63]="QUESTION_MARK",e[e.AT_SIGN=64]="AT_SIGN",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.META=91]="META",e[e.WIN_KEY_RIGHT=92]="WIN_KEY_RIGHT",e[e.CONTEXT_MENU=93]="CONTEXT_MENU",e[e.NUM_ZERO=96]="NUM_ZERO",e[e.NUM_ONE=97]="NUM_ONE",e[e.NUM_TWO=98]="NUM_TWO",e[e.NUM_THREE=99]="NUM_THREE",e[e.NUM_FOUR=100]="NUM_FOUR",e[e.NUM_FIVE=101]="NUM_FIVE",e[e.NUM_SIX=102]="NUM_SIX",e[e.NUM_SEVEN=103]="NUM_SEVEN",e[e.NUM_EIGHT=104]="NUM_EIGHT",e[e.NUM_NINE=105]="NUM_NINE",e[e.NUM_MULTIPLY=106]="NUM_MULTIPLY",e[e.NUM_PLUS=107]="NUM_PLUS",e[e.NUM_MINUS=109]="NUM_MINUS",e[e.NUM_PERIOD=110]="NUM_PERIOD",e[e.NUM_DIVISION=111]="NUM_DIVISION",e[e.F1=112]="F1",e[e.F2=113]="F2",e[e.F3=114]="F3",e[e.F4=115]="F4",e[e.F5=116]="F5",e[e.F6=117]="F6",e[e.F7=118]="F7",e[e.F8=119]="F8",e[e.F9=120]="F9",e[e.F10=121]="F10",e[e.F11=122]="F11",e[e.F12=123]="F12",e[e.NUMLOCK=144]="NUMLOCK",e[e.SCROLL_LOCK=145]="SCROLL_LOCK",e[e.FIRST_MEDIA_KEY=166]="FIRST_MEDIA_KEY",e[e.LAST_MEDIA_KEY=183]="LAST_MEDIA_KEY",e[e.SEMICOLON=186]="SEMICOLON",e[e.DASH=189]="DASH",e[e.EQUALS=187]="EQUALS",e[e.COMMA=188]="COMMA",e[e.PERIOD=190]="PERIOD",e[e.SLASH=191]="SLASH",e[e.APOSTROPHE=192]="APOSTROPHE",e[e.TILDE=192]="TILDE",e[e.SINGLE_QUOTE=222]="SINGLE_QUOTE",e[e.OPEN_SQUARE_BRACKET=219]="OPEN_SQUARE_BRACKET",e[e.BACKSLASH=220]="BACKSLASH",e[e.CLOSE_SQUARE_BRACKET=221]="CLOSE_SQUARE_BRACKET",e[e.WIN_KEY=224]="WIN_KEY",e[e.MAC_FF_META=224]="MAC_FF_META",e[e.MAC_WK_CMD_LEFT=91]="MAC_WK_CMD_LEFT",e[e.MAC_WK_CMD_RIGHT=93]="MAC_WK_CMD_RIGHT",e[e.WIN_IME=229]="WIN_IME",e[e.VK_NONAME=252]="VK_NONAME",e[e.PHANTOM=255]="PHANTOM"})(Le||(Le={}));var zo={};zo.arc=qe,zo.curve=Pt,zo.line=ni,zo.lineOnAxis=re,zo.lineTo=bo,zo.moveBy=je,zo.moveTo=gt,zo.point=se;var We={};We.Coordinate=P,We.KeyCodes=Le,We.Rect=ye,We.Size=ve,We.Svg=R,We.aria=ur,We.array=rg,We.browserEvents=Po,We.colour=Zt,We.deprecation=Ag,We.dom=mt,We.extensions=co,We.idGenerator=na,We.math=Xn,We.object=tg,We.parsing=fr,We.string=mi,We.style=rs,We.svgMath=ks,We.svgPaths=zo,We.toolbox=ns,We.userAgent=gb,We.xml=di;var Ce=class{constructor(e,t){if(this.type=t,this.targetConnection=null,this.disposed=!1,this.shadowDom=this.check=null,this.y=this.x=0,this.shadowState=null,this.sourceBlock_=e,e.id.includes("_connection"))throw Error(`Connection ID indicator is contained in block ID. This will cause problems with focus: ${e.id}.`);this.id=`${e.id}_connection_${Re()}`}connect_(e){const t=Z.INPUT_VALUE,o=this.getSourceBlock();var s=e.getSourceBlock();e.isConnected()&&e.disconnectInternal(!1);let i;if(this.isConnected()){const d=this.stashShadowState(),f=this.targetBlock();f.isShadow()?f.dispose(!1):(this.disconnectInternal(),i=f),this.applyShadowState(d)}let n;J()&&(n=new(U(w.BLOCK_MOVE))(s),n.setReason(["connect"])),tp(this,e),s.setParent(o),n&&(n.recordNew(),_(n)),i&&(e=this.type===t?i.outputConnection:i.previousConnection)&&((s=Ce.getConnectionForOrphanedConnection(s,e))?e.connect(s):e.onFailedConnect(this))}dispose(){if(this.isConnected()){this.isSuperior()&&this.setShadowStateInternal();const e=this.targetBlock();e&&!e.isDeadOrDying()&&e.unplug()}this.disposed=!0}getSourceBlock(){return this.sourceBlock_}isSuperior(){return this.type===Z.INPUT_VALUE||this.type===Z.NEXT_STATEMENT}isConnected(){return!!this.targetConnection}getConnectionChecker(){return this.sourceBlock_.workspace.connectionChecker}onFailedConnect(e){}connect(e){if(this.targetConnection===e)return!0;if(this.getConnectionChecker().canConnect(this,e,!1)){const t=r.getGroup$$module$build$src$core$events$utils();t||r.setGroup$$module$build$src$core$events$utils(!0),this.isSuperior()?this.connect_(e):e.connect_(this),r.setGroup$$module$build$src$core$events$utils(t)}return this.isConnected()}disconnect(){this.disconnectInternal()}disconnectInternal(e=!0){const{parentConnection:t,childConnection:o}=this.getParentAndChildConnections();if(!t||!o)throw Error("Source connection not connected.");const s=r.getGroup$$module$build$src$core$events$utils();s||r.setGroup$$module$build$src$core$events$utils(!0);let i;J()&&(i=new(U(w.BLOCK_MOVE))(o.getSourceBlock()),i.setReason(["disconnect"]));const n=this.targetConnection;n&&(n.targetConnection=null),this.targetConnection=null,e&&o.getSourceBlock().setParent(null),i&&(i.recordNew(),_(i)),o.getSourceBlock().isShadow()||t.respawnShadow_(),r.setGroup$$module$build$src$core$events$utils(s)}getParentAndChildConnections(){return this.targetConnection?this.isSuperior()?{parentConnection:this,childConnection:this.targetConnection}:{parentConnection:this.targetConnection,childConnection:this}:{}}respawnShadow_(){this.createShadowBlock(!0)}reconnect(e,t){if(this.getSourceBlock().isDeadOrDying())return!1;var o;return t=(o=e.getInput(t))==null?void 0:o.connection,o=this.targetBlock(),o&&o!==e||!t||t.targetConnection===this?!1:(t.isConnected()&&t.disconnect(),t.connect(this),!0)}targetBlock(){if(this.isConnected()){let e,t;return(t=(e=this.targetConnection)==null?void 0:e.getSourceBlock())!=null?t:null}return null}onCheckChanged_(){!this.isConnected()||this.targetConnection&&this.getConnectionChecker().canConnect(this,this.targetConnection,!1)||(this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug()}setCheck(e){return e?(Array.isArray(e)||(e=[e]),this.check=e,this.onCheckChanged_()):this.check=null,this}getCheck(){return this.check}setShadowDom(e){this.setShadowStateInternal({shadowDom:e})}getShadowDom(e){return e&&this.targetBlock().isShadow()?ts(this.targetBlock()):this.shadowDom}setShadowState(e){this.setShadowStateInternal({shadowState:e})}getShadowState(e){return e&&this.targetBlock()&&this.targetBlock().isShadow()?jt(this.targetBlock()):this.shadowState}neighbours(e){return[]}getParentInput(){let e=null;const t=this.sourceBlock_.inputList;for(let o=0;o<t.length;o++)if(t[o].connection===this){e=t[o];break}return e}toString(){const e=this.sourceBlock_;if(!e)return"Orphan Connection";if(e.outputConnection===this)var t="Output Connection of ";else if(e.previousConnection===this)t="Previous Connection of ";else if(e.nextConnection===this)t="Next Connection of ";else{t=null;for(let o=0,s;s=e.inputList[o];o++)if(s.connection===this){t=s;break}if(t)t='Input "'+t.name+'" connection on ';else return console.warn("Connection not actually connected to sourceBlock_"),"Orphan Connection"}return t+e.toDevString()}stashShadowState(){const e=this.getShadowDom(!0),t=this.getShadowState(!0);return this.shadowState=this.shadowDom=null,{shadowDom:e,shadowState:t}}applyShadowState({shadowDom:e,shadowState:t}){this.shadowDom=e,this.shadowState=t}setShadowStateInternal({shadowDom:e=null,shadowState:t=null}={}){this.shadowDom=e,this.shadowState=t,this.getSourceBlock().isDeadOrDying()||((e=this.targetBlock())?e.isShadow()?(e.dispose(!1),this.respawnShadow_(),this.targetBlock()&&this.targetBlock().isShadow()&&this.serializeShadow(this.targetBlock())):(e=this.createShadowBlock(!1),this.serializeShadow(e),e&&e.dispose(!1)):(this.respawnShadow_(),this.targetBlock()&&this.targetBlock().isShadow()&&this.serializeShadow(this.targetBlock())))}createShadowBlock(e){var t=this.getSourceBlock();const o=this.getShadowState(),s=this.getShadowDom();if(t.isDeadOrDying()||!o&&!s)return null;if(o)return t=Zs(o,t.workspace,{parentConnection:e?this:void 0,isShadow:!0,recordUndo:!1});if(s){if(t=Is(s,t.workspace),e)if(this.type===Z.INPUT_VALUE){if(!t.outputConnection)throw Error("Shadow block is missing an output connection");if(!this.connect(t.outputConnection))throw Error("Could not connect shadow block to connection")}else if(this.type===Z.NEXT_STATEMENT){if(!t.previousConnection)throw Error("Shadow block is missing previous connection");if(!this.connect(t.previousConnection))throw Error("Could not connect shadow block to connection")}else throw Error("Cannot connect a shadow block to a previous/output connection");return t}return null}serializeShadow(e){e&&(this.shadowDom=ts(e),this.shadowState=jt(e))}static getConnectionForOrphanedConnection(e,t){if(t.type===Z.OUTPUT_VALUE)return sp(e,t.getSourceBlock());e=e.lastConnectionInStack(!0);const o=t.getConnectionChecker();return e&&o.canConnect(t,e,!1)?e:null}};Ce.CAN_CONNECT=0,Ce.REASON_SELF_CONNECTION=1,Ce.REASON_WRONG_TYPE=2,Ce.REASON_TARGET_NULL=3,Ce.REASON_CHECKS_FAILED=4,Ce.REASON_DIFFERENT_WORKSPACES=5,Ce.REASON_SHADOW_PARENT=6,Ce.REASON_DRAG_CHECKS_FAILED=7,Ce.REASON_PREVIOUS_AND_OUTPUT=8;var nm=class extends Error{constructor(e){super(`Tried to append an icon of type ${e.getType()} when an icon of that type already exists on the block. Use getIcon to access the existing icon.`),this.icon=e}},lm={};lm.DuplicateIconType=nm,(function(e){e[e.LEFT=-1]="LEFT",e[e.CENTRE=0]="CENTRE",e[e.RIGHT=1]="RIGHT"})(r.Align$$module$build$src$core$inputs$align||(r.Align$$module$build$src$core$inputs$align={})),r.Align$$module$build$src$core$inputs$align;var Ps=class extends we{constructor(e,t,o){super(we.SKIP_SETUP),this.class=null,this.EDITABLE=!1,this.maxDisplayLength=1/0,e!==we.SKIP_SETUP&&(o?this.configure_(o):this.class=t||null,this.setValue(e))}configure_(e){super.configure_(e),e.class&&(this.class=e.class)}initView(){this.createTextElement_(),this.class&&G(this.getTextElement(),this.class),this.fieldGroup_&&G(this.fieldGroup_,"blocklyLabelField")}doClassValidation_(e){return e==null?null:`${e}`}setClass(e){this.textElement_&&(this.class&&Te(this.textElement_,this.class),e&&G(this.textElement_,e)),this.class=e}static fromJson(e){return new this(Je(e.text),void 0,e)}};_o("field_label",Ps),Ps.prototype.DEFAULT_VALUE="";var cm=30,Fs=[];Fs[Z.INPUT_VALUE]=Z.OUTPUT_VALUE,Fs[Z.OUTPUT_VALUE]=Z.INPUT_VALUE,Fs[Z.NEXT_STATEMENT]=Z.PREVIOUS_STATEMENT,Fs[Z.PREVIOUS_STATEMENT]=Z.NEXT_STATEMENT;var za="RENAME_VARIABLE_ID",Ya="DELETE_VARIABLE_ID",um=10,_t=class extends Ce{constructor(e,t){super(e,t),this.highlighted=!1,this.targetConnection=null,this.db=e.workspace.connectionDBList[t],this.dbOpposite=e.workspace.connectionDBList[Fs[t]],this.offsetInBlock=new P(0,0),this.trackedState=_t.TrackedState.WILL_TRACK}dispose(){super.dispose(),this.trackedState===_t.TrackedState.TRACKED&&this.db.removeConnection(this,this.y);let e,t;(t=(e=this.sourceBlock_.pathObject).removeConnectionHighlight)==null||t.call(e,this)}getSourceBlock(){return super.getSourceBlock()}targetBlock(){return super.targetBlock()}distanceFrom(e){const t=this.x-e.x;return e=this.y-e.y,Math.sqrt(t*t+e*e)}bumpAwayFrom(e,t=!1){if(!this.sourceBlock_.workspace.isDragging()){var o=r.config$$module$build$src$core$config.snapRadius+Math.floor(Math.random()*um),s=r.config$$module$build$src$core$config.snapRadius+Math.floor(Math.random()*um),i=e.sourceBlock_.getRootBlock(),n=this.sourceBlock_.getRootBlock();if(!i.isInFlyout&&!n.isInFlyout){var d=!0;if(n.isMovable())i.isMovable()&&t&&(s=-s);else if(i.isMovable())d=!1,o=-o,s=-s;else return;t=d?e:this,e=d?this:e,i=d?n:i,i.RTL&&(o=-o),i.moveBy(t.x+o-e.x,t.y+s-e.y,["bump"])}}}moveTo(e,t){let o=!1;return this.trackedState===_t.TrackedState.WILL_TRACK?(this.db.addConnection(this,t),this.trackedState=_t.TrackedState.TRACKED,o=!0):this.trackedState===_t.TrackedState.TRACKED&&(this.db.removeConnection(this,this.y),this.db.addConnection(this,t),o=!0),this.x=e,this.y=t,o}moveBy(e,t){return this.moveTo(this.x+e,this.y+t)}moveToOffset(e){return this.moveTo(e.x+this.offsetInBlock.x,e.y+this.offsetInBlock.y)}setOffsetInBlock(e,t){this.offsetInBlock.x=e,this.offsetInBlock.y=t}getOffsetInBlock(){return this.offsetInBlock}tightenEfficiently(){var e=this.targetConnection;const t=this.targetBlock();e&&t&&(e=P.difference(this.offsetInBlock,e.offsetInBlock),t.translate(e.x,e.y))}closest(e,t){return this.dbOpposite.searchForClosest(this,e,t)}highlight(){this.highlighted=!0;const e=this.findHighlightSvg();e&&(e.style.display="")}unhighlight(){this.highlighted=!1;const e=this.findHighlightSvg();e&&(e.style.display="none")}isHighlighted(){return this.highlighted}setTracking(e){e&&this.trackedState===_t.TrackedState.TRACKED||!e&&this.trackedState===_t.TrackedState.UNTRACKED||this.sourceBlock_.isInFlyout||(e?(this.db.addConnection(this,this.y),this.trackedState=_t.TrackedState.TRACKED):(this.trackedState===_t.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),this.trackedState=_t.TrackedState.UNTRACKED))}stopTrackingAll(){if(this.setTracking(!1),this.targetConnection){const e=this.targetBlock().getDescendants(!1);for(let t=0;t<e.length;t++){const o=e[t],s=o.getConnections_(!0);for(let i=0;i<s.length;i++)s[i].setTracking(!1);for(const i of o.getIcons())Ts(i)&&i.setBubbleVisible(!1)}}}startTrackingAll(){this.setTracking(!0);let e=[];if(this.type!==Z.INPUT_VALUE&&this.type!==Z.NEXT_STATEMENT)return e;const t=this.targetBlock();if(t){let o;t.isCollapsed()?(o=[],t.outputConnection&&o.push(t.outputConnection),t.nextConnection&&o.push(t.nextConnection),t.previousConnection&&o.push(t.previousConnection)):o=t.getConnections_(!0);for(let s=0;s<o.length;s++)e.push(...o[s].startTrackingAll());e.length||(e=[t])}return e}onFailedConnect(e){const t=this.getSourceBlock();if(Ue()){const o=r.getGroup$$module$build$src$core$events$utils();setTimeout((function(){t.isDisposed()||t.getParent()||(r.setGroup$$module$build$src$core$events$utils(o),this.bumpAwayFrom(e),r.setGroup$$module$build$src$core$events$utils(!1))}).bind(this),r.config$$module$build$src$core$config.bumpDelay)}}disconnectInternal(e=!0){const{parentConnection:t,childConnection:o}=this.getParentAndChildConnections();if(t&&o){var s=r.getGroup$$module$build$src$core$events$utils();s||r.setGroup$$module$build$src$core$events$utils(!0);var i=t.getSourceBlock(),n=o.getSourceBlock();super.disconnectInternal(e),i.queueRender(),n.updateDisabled(),n.queueRender(),n.getSvgRoot().style.display="block",r.setGroup$$module$build$src$core$events$utils(s)}}respawnShadow_(){super.respawnShadow_();const e=this.targetBlock();e&&(e.initSvg(),e.queueRender())}neighbours(e){return this.dbOpposite.getNeighbours(this,e)}connect_(e){super.connect_(e);var t=this.getSourceBlock();e=e.getSourceBlock(),t.updateDisabled(),e.updateDisabled(),e.queueRender(),(t=t.getInputWithBlock(e))&&(t=t.isVisible(),e.getSvgRoot().style.display=t?"block":"none")}onCheckChanged_(){!this.isConnected()||this.targetConnection&&this.getConnectionChecker().canConnect(this,this.targetConnection,!1)||(this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug()}setCheck(e){return super.setCheck(e),this.sourceBlock_.queueRender(),this}showContextMenu(e){const t=Ee.registry.getContextMenuOptions({focusedNode:this},e);if(t.length){var o=this.getSourceBlock(),s=o.workspace;if(e instanceof PointerEvent)var i=new P(e.clientX,e.clientY);else i=new P(this.x,this.y),i=Ys(s,i).translate(o.RTL?-5:5,5);ii(e,t,o.RTL,s,i)}}getFocusableElement(){const e=this.findHighlightSvg();if(e)return e;throw Error("No highlight SVG found corresponding to this connection.")}getFocusableTree(){return this.getSourceBlock().workspace}onNodeFocus(){this.highlight()}onNodeBlur(){this.unhighlight()}canBeFocused(){return!0}findHighlightSvg(){return document.getElementById(this.id)}};(function(e){e=e.TrackedState||(e.TrackedState={}),e[e.WILL_TRACK=-1]="WILL_TRACK",e[e.UNTRACKED=0]="UNTRACKED",e[e.TRACKED=1]="TRACKED"})(_t||(_t={})),_t.TrackedState;var vi=class{constructor(e,t){this.name=e,this.sourceBlock=t,this.fieldRow=[],this.align=r.Align$$module$build$src$core$inputs$align.LEFT,this.visible=!0,this.type=r.inputTypes$$module$build$src$core$inputs$input_types.CUSTOM,this.connection=null}getSourceBlock(){return this.sourceBlock}appendField(e,t){return this.insertFieldAt(this.fieldRow.length,e,t),this}insertFieldAt(e,t,o){if(e<0||e>this.fieldRow.length)throw Error("index "+e+" out of bounds.");return(t||t===""&&o)&&(typeof t=="string"&&(t=r.fromJson$$module$build$src$core$field_registry({type:"field_label",text:t})),t.setSourceBlock(this.sourceBlock),this.sourceBlock.initialized&&this.initField(t),t.name=o,t.setVisible(this.isVisible()),t.prefixField&&(e=this.insertFieldAt(e,t.prefixField)),this.fieldRow.splice(e,0,t),e++,t.suffixField&&(e=this.insertFieldAt(e,t.suffixField)),this.sourceBlock.rendered&&this.sourceBlock.queueRender()),e}removeField(e,t){for(let o=0,s;s=this.fieldRow[o];o++)if(s.name===e)return s.dispose(),this.fieldRow.splice(o,1),this.sourceBlock.rendered&&this.sourceBlock.queueRender(),!0;if(t)return!1;throw Error('Field "'+e+'" not found.')}isVisible(){return this.visible}setVisible(e){let t=[];if(this.visible===e)return t;this.visible=e;for(let o=0,s;s=this.fieldRow[o];o++)s.setVisible(e);if(this.connection&&this.connection instanceof _t){e?t=this.connection.startTrackingAll():this.connection.stopTrackingAll();const o=this.connection.targetBlock();o&&(o.getSvgRoot().style.display=e?"block":"none")}return t}markDirty(){for(let e=0,t;t=this.fieldRow[e];e++)t.markDirty()}setCheck(e){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.setCheck(e),this}setAlign(e){return this.align=e,this.sourceBlock.rendered&&this.sourceBlock.queueRender(),this}setShadowDom(e){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.setShadowDom(e),this}getShadowDom(){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.getShadowDom()}init(){for(const e of this.fieldRow)e.init()}initModel(){for(const e of this.fieldRow)e.initModel()}initField(e){this.sourceBlock.rendered?e.init():e.initModel()}dispose(){for(let e=0,t;t=this.fieldRow[e];e++)t.dispose();this.connection&&this.connection.dispose()}makeConnection(e){return this.sourceBlock.makeConnection_(e)}},Io=class extends vi{constructor(e,t){super(e,t),this.name=e,this.type=r.inputTypes$$module$build$src$core$inputs$input_types.DUMMY}},Yo=class extends vi{constructor(e,t){super(e,t),this.name=e,this.type=r.inputTypes$$module$build$src$core$inputs$input_types.END_ROW}},Yt=class extends vi{constructor(e,t){if(!e)throw Error("Statement inputs must have a non-empty name");super(e,t),this.name=e,this.type=r.inputTypes$$module$build$src$core$inputs$input_types.STATEMENT,this.connection=this.makeConnection(Z.NEXT_STATEMENT)}},am;r.ValueInput$$module$build$src$core$inputs$value_input=class extends vi{constructor(e,t){if(!e)throw Error("Value inputs must have a non-empty name");super(e,t),this.name=e,this.type=r.inputTypes$$module$build$src$core$inputs$input_types.VALUE,this.connection=this.makeConnection(Z.INPUT_VALUE)}},am={},am.ValueInput=r.ValueInput$$module$build$src$core$inputs$value_input;var Ii=class{constructor(e,t,o){if(this.data=null,this.disposed=!1,this.hue=null,this.colour_="#000000",this.styleName_="",this.suppressPrefixSuffix=!1,this.previousConnection=this.nextConnection=this.outputConnection=null,this.inputList=[],this.icons=[],this.disabledReasons=new Set,this.tooltip="",this.contextMenu=!0,this.parentBlock_=null,this.childBlocks_=[],this.editable=this.movable=this.deletable=!0,this.collapsed_=this.shadow=!1,this.outputShape_=null,this.rendered=this.isInsertionMarker_=this.initialized=this.disposing=!1,this.onchangeWrapper=this.helpUrl=null,this.statementInputCount=0,this.workspace=e,this.id=o&&!e.getBlockById(o)?o:rt(),e.setBlockById(this.id,this),this.xy=new P(0,0),this.isInFlyout=e.isFlyout,this.isInMutator=e.isMutator,this.RTL=e.RTL,t){if(this.type=t,o=Ge[t],!o||typeof o!="object")throw TypeError("Invalid block definition for type: "+t);Object.assign(this,o)}e.addTopBlock(this),e.addTypedBlock(this),new.target===Ii&&this.doInit_()}doInit_(){const e=r.getGroup$$module$build$src$core$events$utils();e||r.setGroup$$module$build$src$core$events$utils(!0);const t=Ue();try{typeof this.init=="function"&&(r.setRecordUndo$$module$build$src$core$events$utils(!1),this.init(),r.setRecordUndo$$module$build$src$core$events$utils(t)),J()&&_(new(U(w.BLOCK_CREATE))(this))}finally{r.setGroup$$module$build$src$core$events$utils(e),r.setRecordUndo$$module$build$src$core$events$utils(t)}this.inputsInlineDefault=this.inputsInline,typeof this.onchange=="function"&&this.setOnChange(this.onchange)}dispose(e=!1){this.disposing=!0,this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper),this.unplug(e),J()&&_(new(U(w.BLOCK_DELETE))(this)),this.workspace.removeTopBlock(this),this.disposeInternal()}disposeInternal(){this.disposing=!0,this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper),this.workspace.removeTypedBlock(this),this.workspace.removeBlockById(this.id),typeof this.destroy=="function"&&this.destroy(),this.childBlocks_.forEach(e=>e.disposeInternal()),this.inputList.forEach(e=>e.dispose()),this.inputList.length=0,this.getConnections_(!0).forEach(e=>e.dispose()),this.disposed=!0}isDeadOrDying(){return this.disposing||this.disposed}initModel(){if(!this.initialized){for(const e of this.inputList)e.initModel();this.initialized=!0}}unplug(e){this.outputConnection&&this.unplugFromRow(e),this.previousConnection&&this.unplugFromStack(e)}unplugFromRow(e){let t=null,o;(o=this.outputConnection)!=null&&o.isConnected()&&(t=this.outputConnection.targetConnection,this.outputConnection.disconnect()),t&&e&&(e=this.getOnlyValueConnection())&&e.isConnected()&&!e.targetBlock().isShadow()&&(e=e.targetConnection,e?.disconnect(),this.workspace.connectionChecker.canConnect(e,t,!1)?t.connect(e):e?.onFailedConnect(t))}getOnlyValueConnection(){let e=null;for(let t=0;t<this.inputList.length;t++){const o=this.inputList[t].connection;if(o&&o.type===Z.INPUT_VALUE&&o.targetConnection){if(e)return null;e=o}}return e}unplugFromStack(e){let t=null;var o;if((o=this.previousConnection)!=null&&o.isConnected()&&(t=this.previousConnection.targetConnection,this.previousConnection.disconnect()),o=this.getNextBlock(),e&&o&&!o.isShadow()){let s,i;e=(i=(s=this.nextConnection)==null?void 0:s.targetConnection)!=null?i:null,e?.disconnect(),t&&this.workspace.connectionChecker.canConnect(t,e,!1)&&t.connect(e)}}getConnections_(e){e=[],this.outputConnection&&e.push(this.outputConnection),this.previousConnection&&e.push(this.previousConnection),this.nextConnection&&e.push(this.nextConnection);for(let t=0,o;o=this.inputList[t];t++)o.connection&&e.push(o.connection);return e}lastConnectionInStack(e){let t=this.nextConnection;for(;t;){const o=t.targetBlock();if(!o||e&&o.isShadow())return t;t=o.nextConnection}return null}bumpNeighbours(){}getParent(){return this.parentBlock_}getInputWithBlock(e){for(let t=0,o;o=this.inputList[t];t++)if(o.connection&&o.connection.targetBlock()===e)return o;return null}getSurroundParent(){let e=this,t;do if(t=e,e=e.getParent(),!e)return null;while(e.getNextBlock()===t);return e}getNextBlock(){return this.nextConnection&&this.nextConnection.targetBlock()}getPreviousBlock(){return this.previousConnection&&this.previousConnection.targetBlock()}getRootBlock(){let e,t=this;do e=t,t=e.parentBlock_;while(t);return e}getTopStackBlock(){let e=this,t;do t=e.getPreviousBlock();while(t&&t.getNextBlock()===e&&(e=t));return e}getChildren(e){if(!e)return this.childBlocks_;e=[];for(let o=0,s;s=this.inputList[o];o++)if(s.connection){var t=s.connection.targetBlock();t&&e.push(t)}return(t=this.getNextBlock())&&e.push(t),e}setParent(e){if(e!==this.parentBlock_){var t=this.previousConnection&&this.previousConnection.targetBlock()||this.outputConnection&&this.outputConnection.targetBlock(),o=!!t;if(o&&e&&t!==e)throw Error("Block connected to superior one that is not new parent.");if(!o&&e)throw Error("Block not connected to new parent.");if(o&&!e)throw Error("Cannot set parent to null while block is still connected to superior block.");this.parentBlock_?x(this.parentBlock_.childBlocks_,this):this.workspace.removeTopBlock(this),(this.parentBlock_=e)?e.childBlocks_.push(this):this.workspace.addTopBlock(this)}}getDescendants(e){const t=[this],o=this.getChildren(e);for(let s,i=0;s=o[i];i++)t.push(...s.getDescendants(e));return t}isDeletable(){return this.deletable&&!this.isInFlyout&&!this.shadow&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()}isOwnDeletable(){return this.deletable}setDeletable(e){this.deletable=e}isMovable(){return this.movable&&!this.isInFlyout&&!this.shadow&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()}isOwnMovable(){return this.movable}setMovable(e){this.movable=e}isDuplicatable(){return this.workspace.hasBlockLimits()?this.workspace.isCapacityAvailable(io(this,!0)):!0}isShadow(){return this.shadow}setShadow(e){this.shadow=e}isInsertionMarker(){return this.isInsertionMarker_}setInsertionMarker(e){this.isInsertionMarker_=e}isEditable(){return this.editable&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()}isOwnEditable(){return this.editable}setEditable(e){this.editable=e;for(const t of this.getFields())t.updateEditable()}isDisposed(){return this.disposed}isSimpleReporter(){if(!this.outputConnection)return!1;for(const e of this.inputList)if(e.connection||e.fieldRow.length>1)return!1;return!0}getMatchingConnection(e,t){const o=this.getConnections_(!0);if(e=e.getConnections_(!0),o.length!==e.length)throw Error("Connection lists did not match in length.");for(let s=0;s<e.length;s++)if(e[s]===t)return o[s];return null}setHelpUrl(e){this.helpUrl=e}setTooltip(e){this.tooltip=e}getTooltip(){return ei(this)}getColour(){return this.colour_}getStyleName(){return this.styleName_}getHue(){return this.hue}setColour(e){e=ti(e),this.hue=e.hue,this.colour_=e.hex}setStyle(e){this.styleName_=e}setOnChange(e){if(e&&typeof e!="function")throw Error("onchange must be a function.");this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper),this.onchange=e,this.onchangeWrapper=e.bind(this),this.workspace.addChangeListener(this.onchangeWrapper)}getField(e){if(typeof e!="string")throw TypeError("Block.prototype.getField expects a string with the field name but received "+(e===void 0?"nothing":e+" of type "+typeof e)+" instead");for(const t of this.getFields())if(t.name===e)return t;return null}*getFields(){for(const e of this.inputList)for(const t of e.fieldRow)yield t}getVars(){const e=[];for(const t of this.getFields())t.referencesVariables()&&e.push(t.getValue());return e}getVarModels(){const e=[];for(const t of this.getFields())if(t.referencesVariables()){const o=this.workspace.getVariableById(t.getValue());o&&e.push(o)}return e}updateVarName(e){for(const t of this.getFields())t.referencesVariables()&&e.getId()===t.getValue()&&t.refreshVariableName()}renameVarById(e,t){for(const o of this.getFields())o.referencesVariables()&&e===o.getValue()&&o.setValue(t)}getFieldValue(e){return(e=this.getField(e))?e.getValue():null}setFieldValue(e,t){const o=this.getField(t);if(!o)throw Error('Field "'+t+'" not found.');o.setValue(e)}setPreviousStatement(e,t){if(e)t===void 0&&(t=null),this.previousConnection||(this.previousConnection=this.makeConnection_(Z.PREVIOUS_STATEMENT)),this.previousConnection.setCheck(t);else if(this.previousConnection){if(this.previousConnection.isConnected())throw Error("Must disconnect previous statement before removing connection.");this.previousConnection.dispose(),this.previousConnection=null}}setNextStatement(e,t){if(e)t===void 0&&(t=null),this.nextConnection||(this.nextConnection=this.makeConnection_(Z.NEXT_STATEMENT)),this.nextConnection.setCheck(t);else if(this.nextConnection){if(this.nextConnection.isConnected())throw Error("Must disconnect next statement before removing connection.");this.nextConnection.dispose(),this.nextConnection=null}}setOutput(e,t){if(e)t===void 0&&(t=null),this.outputConnection||(this.outputConnection=this.makeConnection_(Z.OUTPUT_VALUE)),this.outputConnection.setCheck(t);else if(this.outputConnection){if(this.outputConnection.isConnected())throw Error("Must disconnect output value before removing connection.");this.outputConnection.dispose(),this.outputConnection=null}}setInputsInline(e){this.inputsInline!==e&&(_(new(U(w.BLOCK_CHANGE))(this,"inline",null,this.inputsInline,e)),this.inputsInline=e)}getInputsInline(){if(this.inputsInline!==void 0)return this.inputsInline;for(var e=1;e<this.inputList.length;e++)if(this.inputList[e-1]instanceof Io&&this.inputList[e]instanceof Io)return!1;for(e=1;e<this.inputList.length;e++)if(this.inputList[e-1]instanceof r.ValueInput$$module$build$src$core$inputs$value_input&&this.inputList[e]instanceof Io)return!0;for(e=0;e<this.inputList.length;e++)if(this.inputList[e]instanceof Yo)return!0;return!1}setOutputShape(e){this.outputShape_=e}getOutputShape(){return this.outputShape_}isEnabled(){return this.disabledReasons.size===0}setDisabledReason(e,t){e||this.workspace.options.disable||!this.hasDisabledReason(Jt)||t==Jt||this.setDisabledReason(!1,Jt),this.disabledReasons.has(t)!==e&&(e?this.disabledReasons.add(t):this.disabledReasons.delete(t),e=new(U(w.BLOCK_CHANGE))(this,"disabled",null,!e,e),e.setDisabledReason(t),_(e))}getInheritedDisabled(){let e=this.getSurroundParent();for(;e;){if(!e.isEnabled())return!0;e=e.getSurroundParent()}return!1}hasDisabledReason(e){return this.disabledReasons.has(e)}getDisabledReasons(){return this.disabledReasons}isCollapsed(){return this.collapsed_}setCollapsed(e){this.collapsed_!==e&&(_(new(U(w.BLOCK_CHANGE))(this,"collapsed",null,this.collapsed_,e)),this.collapsed_=e)}toString(e,t){t=this.toTokens(t);for(let s=2;s<t.length;s++)t[s-2]==="("&&t[s]===")"&&(t[s-2]=t[s-1],t.splice(s-1,2));let o="";return t=t.reduce((s,i)=>(s=s+(o==="("||i===")"?"":" ")+i,o=i[i.length-1],s),""),t=t.trim()||"???",e&&t.length>e&&(t=t.substring(0,e-3)+"..."),t}toTokens(e="?"){const t=[];for(const s of this.inputList)if(s.name!=ar){for(const i of s.fieldRow)t.push(i.getText());if(s.connection){const i=s.connection.targetBlock();if(i){var o=s.connection;let n=o.getCheck();!n&&o.targetConnection&&(n=o.targetConnection.getCheck()),(o=!!n&&(n.includes("Boolean")||n.includes("Number")))&&t.push("("),t.push(...i.toTokens(e)),o&&t.push(")")}else t.push(e)}}return t}appendValueInput(e){return this.appendInput(new r.ValueInput$$module$build$src$core$inputs$value_input(e,this))}appendStatementInput(e){return this.statementInputCount++,this.appendInput(new Yt(e,this))}appendDummyInput(e=""){return this.appendInput(new Io(e,this))}appendEndRowInput(e=""){return this.appendInput(new Yo(e,this))}appendInput(e){return this.inputList.push(e),e}appendInputFromRegistry(e,t){return(e=A(M.INPUT,e,!1))?this.appendInput(new e(t,this)):null}jsonInit(e){var t=e.type?'Block "'+e.type+'": ':"";if(e.output&&e.previousStatement)throw Error(t+"Must not have both an output and a previousStatement.");for(var o=0;e["args"+o];){if(e["message"+o]===void 0)throw Error(t+`args${o} must have a corresponding message (message${o}).`);o++}if(e.style&&e.style.hat&&(this.hat=e.style.hat,e.style=null),e.style&&e.colour)throw Error(t+"Must not have both a colour and a style.");for(e.style?this.jsonInitStyle(e,t):this.jsonInitColour(e,t),o=0;e["message"+o]!==void 0;)this.interpolate(e["message"+o],e["args"+o]||[],e["implicitAlign"+o]||e["lastDummyAlign"+o],t),o++;if(e.inputsInline!==void 0&&(r.disable$$module$build$src$core$events$utils(),this.setInputsInline(e.inputsInline),r.enable$$module$build$src$core$events$utils()),e.output!==void 0&&this.setOutput(!0,e.output),e.outputShape!==void 0&&this.setOutputShape(e.outputShape),e.previousStatement!==void 0&&this.setPreviousStatement(!0,e.previousStatement),e.nextStatement!==void 0&&this.setNextStatement(!0,e.nextStatement),e.tooltip!==void 0&&(o=Je(e.tooltip),this.setTooltip(o)),e.enableContextMenu!==void 0&&(this.contextMenu=!!e.enableContextMenu),e.suppressPrefixSuffix!==void 0&&(this.suppressPrefixSuffix=!!e.suppressPrefixSuffix),e.helpUrl!==void 0&&(o=Je(e.helpUrl),this.setHelpUrl(o)),typeof e.extensions=="string"&&(console.warn(t+"JSON attribute 'extensions' should be an array of strings. Found raw string in JSON for '"+e.type+"' block."),e.extensions=[e.extensions]),e.mutator!==void 0&&mn(e.mutator,this,!0),e=e.extensions,Array.isArray(e))for(t=0;t<e.length;t++)mn(e[t],this,!1)}jsonInitColour(e,t){if("colour"in e)if(e.colour===void 0)console.warn(t+"Undefined colour value.");else{e=e.colour;try{this.setColour(e)}catch{console.warn(t+"Illegal colour value: ",e)}}}jsonInitStyle(e,t){e=e.style;try{this.setStyle(e)}catch{console.warn(t+"Style does not exist: ",e)}}mixin(e,t){if(t!==void 0&&typeof t!="boolean")throw Error("opt_disableCheck must be a boolean if provided");if(!t){t=[];for(const o in e)this[o]!==void 0&&t.push(o);if(t.length)throw Error("Mixin will overwrite block members: "+JSON.stringify(t))}Object.assign(this,e)}interpolate(e,t,o,s){e=Gc(e),this.validateTokens(e,t.length),t=this.interpolateArguments(e,t,o),o=[];for(let i=0,n;n=t[i];i++)if(this.isInputKeyword(n.type)){if(e=this.inputFromJson(n,s)){for(let d=0,f;f=o[d];d++)e.appendField(f[0],f[1]);o.length=0}}else(e=this.fieldFromJson(n))&&o.push([e,n.name])}validateTokens(e,t){const o=[];let s=0;for(let i=0;i<e.length;i++){const n=e[i];if(typeof n=="number"){if(n<1||n>t)throw Error('Block "'+this.type+'": Message index %'+n+" out of range.");if(o[n])throw Error('Block "'+this.type+'": Message index %'+n+" duplicated.");o[n]=!0,s++}}if(s!==t)throw Error('Block "'+this.type+'": Message does not reference all '+t+" arg(s).")}interpolateArguments(e,t,o){const s=[];for(let n=0;n<e.length;n++){var i=e[n];if(typeof i=="number"&&(i=t[i-1]),typeof i=="string"){if(i===`
621
+ `)i={type:"input_end_row"},o&&(i.align=o);else if(i=this.stringToFieldJson(i),!i)continue}s.push(i)}return(e=s.length)&&!this.isInputKeyword(s[e-1].type)&&(e={type:"input_dummy"},o&&(e.align=o),s.push(e)),s}fieldFromJson(e){const t=r.fromJson$$module$build$src$core$field_registry(e);return!t&&e.alt?typeof e.alt=="string"?(e=this.stringToFieldJson(e.alt))?this.fieldFromJson(e):null:this.fieldFromJson(e.alt):t}inputFromJson(e,t){var o={LEFT:r.Align$$module$build$src$core$inputs$align.LEFT,RIGHT:r.Align$$module$build$src$core$inputs$align.RIGHT,CENTRE:r.Align$$module$build$src$core$inputs$align.CENTRE,CENTER:r.Align$$module$build$src$core$inputs$align.CENTRE};let s;switch(e.type){case"input_value":s=this.appendValueInput(e.name);break;case"input_statement":s=this.appendStatementInput(e.name);break;case"input_dummy":s=this.appendDummyInput(e.name);break;case"input_end_row":s=this.appendEndRowInput(e.name);break;default:s=this.appendInputFromRegistry(e.type,e.name)}return s?(e.check&&s.setCheck(e.check),e.align&&(o=o[e.align.toUpperCase()],o===void 0?console.warn(t+"Illegal align value: ",e.align):s.setAlign(o)),s):null}isInputKeyword(e){return e==="input_value"||e==="input_statement"||e==="input_dummy"||e==="input_end_row"||k(M.INPUT,e)}stringToFieldJson(e){return(e=e.trim())?{type:"field_label",text:e}:null}moveInputBefore(e,t){if(e!==t){var o=-1,s=t?-1:this.inputList.length;for(let i=0,n;n=this.inputList[i];i++)if(n.name===e){if(o=i,s!==-1)break}else if(t&&n.name===t&&(s=i,o!==-1))break;if(o===-1)throw Error('Named input "'+e+'" not found.');if(s===-1)throw Error('Reference input "'+t+'" not found.');this.moveNumberedInputBefore(o,s)}}moveNumberedInputBefore(e,t){if(e===t)throw Error("Can't move input to itself.");if(e>=this.inputList.length)throw RangeError("Input index "+e+" out of bounds.");if(t>this.inputList.length)throw RangeError("Reference input "+t+" out of bounds.");const o=this.inputList[e];this.inputList.splice(e,1),e<t&&t--,this.inputList.splice(t,0,o)}removeInput(e,t){for(let o=0,s;s=this.inputList[o];o++)if(s.name===e)return s instanceof Yt&&this.statementInputCount--,s.dispose(),this.inputList.splice(o,1),!0;if(t)return!1;throw Error("Input not found: "+e)}getInput(e){for(let t=0,o;o=this.inputList[t];t++)if(o.name===e)return o;return null}getInputTargetBlock(e){return(e=this.getInput(e))&&e.connection&&e.connection.targetBlock()}getCommentText(){let e,t;return(t=(e=this.getIcon(ut.COMMENT))==null?void 0:e.getText())!=null?t:null}setCommentText(e){var t;let o;const s=(o=(t=this.getIcon(ut.COMMENT))==null?void 0:t.getText())!=null?o:null;if(s!==e){if(e!==null){if(t=this.getIcon(ut.COMMENT),!t){if(t=A(M.ICON,ut.COMMENT.toString(),!1),!t)throw Error("No comment icon class is registered, so a comment cannot be set");if(t=new t(this),!ip(t))throw Error("The class registered as a comment icon does not conform to the ICommentIcon interface");t=this.addIcon(t)}r.disable$$module$build$src$core$events$utils(),t.setText(e),r.enable$$module$build$src$core$events$utils()}else this.removeIcon(ut.COMMENT);_(new(U(w.BLOCK_CHANGE))(this,"comment",null,s,e))}}setWarningText(e,t){}setMutator(e){}addIcon(e){if(this.hasIcon(e.getType()))throw new nm(e);return this.icons.push(e),this.icons.sort((t,o)=>t.getWeight()-o.getWeight()),e}removeIcon(e){if(!this.hasIcon(e))return!1;let t;return(t=this.getIcon(e))==null||t.dispose(),this.icons=this.icons.filter(o=>!o.getType().equals(e)),!0}hasIcon(e){return this.icons.some(t=>t.getType().equals(e))}getIcon(e){return e instanceof ut?this.icons.find(t=>t.getType().equals(e)):this.icons.find(t=>t.getType().toString()===e)}getIcons(){return[...this.icons]}getRelativeToSurfaceXY(){return this.xy}moveBy(e,t,o){if(this.parentBlock_)throw Error("Block has parent");const s=new(U(w.BLOCK_MOVE))(this);o&&s.setReason(o),this.xy.translate(e,t),s.recordNew(),_(s)}makeConnection_(e){return new Ce(this,e)}allInputsFilled(e){if(e===void 0&&(e=!0),!e&&this.isShadow())return!1;for(let o=0,s;s=this.inputList[o];o++)if(s.connection){var t=s.connection.targetBlock();if(!t||!t.allInputsFilled(e))return!1}return(t=this.getNextBlock())?t.allInputsFilled(e):!0}toDevString(){let e=this.type?'"'+this.type+'" block':"Block";return this.id&&(e+=' (id="'+this.id+'")'),e}};Ii.COLLAPSED_INPUT_NAME=ar,Ii.COLLAPSED_FIELD_NAME=Wn;var hl=null,Tr=null,Er={};Er.connectionUiEffect=cu,Er.disconnectUiEffect=uu,Er.disconnectUiStop=li,Er.disposeUiEffect=bn;var yr=class{paste(e,t,o){if(!t.isCapacityAvailable(e.typeCounts))return null;o&&(e.blockState.x=o.x,e.blockState.y=o.y),o=o||new P(e.blockState.x||0,e.blockState.y||0),r.disable$$module$build$src$core$events$utils();let s;try{s=es(e.blockState,t),rp(s,o)}finally{r.enable$$module$build$src$core$events$utils()}if(!s)return s;J()&&!s.isShadow()&&_(new(U(w.BLOCK_CREATE))(s));const i=s;return go().then(()=>r.getFocusManager$$module$build$src$core$focus_manager().focusNode(i)),s}};yr.TYPE="block",Yr(yr.TYPE,new yr);var dl={};dl.bumpIntoBounds=ci,dl.bumpIntoBoundsHandler=hu,dl.bumpTopObjectsIntoBounds=Tn;var hm=class{constructor(e){this.block=e,this.connectionPreviewer=this.connectionCandidate=this.startLoc=this.startChildConn=this.startParentConn=null,this.dragging=!1,this.dragOffset=new P(0,0),this.originalEventGroup="",this.workspace=e.workspace}isMovable(){if(this.block.isShadow()){let e,t;return(t=(e=this.block.getParent())==null?void 0:e.isMovable())!=null?t:!1}return this.block.isOwnMovable()&&!this.block.isDeadOrDying()&&!this.workspace.isReadOnly()&&!this.block.isInFlyout}startDrag(e){if(this.block.isShadow())this.startDraggingShadow(e);else{this.dragging=!0,this.fireDragStartEvent(),this.startLoc=this.block.getRelativeToSurfaceXY(),this.connectionCandidate=null,this.connectionPreviewer=new(W(M.CONNECTION_PREVIEWER,this.workspace.options))(this.block),eo(),this.workspace.setResizesEnabled(!1),li(),e=this.shouldHealStack(e),this.shouldDisconnect(e)&&this.disconnectBlock(e),this.block.setDragging(!0);var t;(t=this.workspace.getLayerManager())==null||t.moveToDragLayer(this.block)}}shouldHealStack(e){return!!e&&(e.altKey||e.ctrlKey||e.metaKey)}startDraggingShadow(e){const t=this.block.getParent();if(!t)throw Error("Tried to drag a shadow block with no parent. Shadow blocks should always have parents.");this.dragOffset=P.difference(t.getRelativeToSurfaceXY(),this.block.getRelativeToSurfaceXY()),t.startDrag(e)}shouldDisconnect(e){return!!(this.block.getParent()||e&&this.block.nextConnection&&this.block.nextConnection.targetBlock())}disconnectBlock(e){let t,o,s;if(this.startParentConn=(s=(t=this.block.outputConnection)==null?void 0:t.targetConnection)!=null?s:(o=this.block.previousConnection)==null?void 0:o.targetConnection,e){let i;this.startChildConn=(i=this.block.nextConnection)==null?void 0:i.targetConnection}this.block.unplug(e),uu(this.block)}fireDragStartEvent(){const e=new(U(w.BLOCK_DRAG))(this.block,!0,this.block.getDescendants(!1));_(e)}fireDragEndEvent(){const e=new(U(w.BLOCK_DRAG))(this.block,!1,this.block.getDescendants(!1));_(e)}fireMoveEvent(){if(!this.block.isDeadOrDying()){var e=new(U(w.BLOCK_MOVE))(this.block);e.setReason(["drag"]),e.oldCoordinate=this.startLoc,e.recordNew(),_(e)}}drag(e){if(this.block.isShadow()){let t;(t=this.block.getParent())==null||t.drag(P.sum(e,this.dragOffset))}else this.block.moveDuringDrag(e),this.updateConnectionPreview(this.block,P.difference(e,this.startLoc))}updateConnectionPreview(e,t){var o=this.connectionCandidate;const s=this.getConnectionCandidate(e,t);if(s){this.connectionCandidate=t=o&&this.currCandidateIsBetter(o,t,s)?o:s;var{local:i,neighbour:n}=t;t=i.type===Z.OUTPUT_VALUE||i.type===Z.PREVIOUS_STATEMENT;var d;if(o=n.isConnected()&&!((d=n.targetBlock())!=null&&d.isInsertionMarker()),t&&o&&!this.orphanCanConnectAtEnd(e,n.targetBlock(),i.type)){let L;(L=this.connectionPreviewer)==null||L.previewReplacement(i,n,n.targetBlock())}else{var f;(f=this.connectionPreviewer)==null||f.previewConnection(i,n)}}else{let L;(L=this.connectionPreviewer)==null||L.hidePreview(),this.connectionCandidate=null}}orphanCanConnectAtEnd(e,t,o){return!!Ce.getConnectionForOrphanedConnection(e,o===Z.OUTPUT_VALUE?t.outputConnection:t.previousConnection)}currCandidateIsBetter(e,t,o){const{local:s,neighbour:i}=e;e=new P(s.x,s.y);const n=new P(i.x,i.y);return t=P.distance(P.sum(e,t),n),o.distance>t-r.config$$module$build$src$core$config.currentConnectionPreference}getConnectionCandidate(e,t){e=this.getLocalConnections(e);let o=this.getSearchRadius(),s=null;for(const i of e){const{connection:n,radius:d}=i.closest(o,t);n&&(s={local:i,neighbour:n,distance:d},o=d)}return s}getSearchRadius(){return this.connectionCandidate?r.config$$module$build$src$core$config.connectingSnapRadius:r.config$$module$build$src$core$config.snapRadius}getLocalConnections(e){const t=e.getConnections_(!1),o=e.lastConnectionInStack(!0);return o&&o!==e.nextConnection&&t.push(o),t}endDrag(e){if(this.block.isShadow()){let o;(o=this.block.getParent())==null||o.endDrag(e)}else{this.originalEventGroup=r.getGroup$$module$build$src$core$events$utils(),this.fireDragEndEvent(),this.fireMoveEvent(),to(),li();var t;if((t=this.connectionPreviewer)==null||t.hidePreview(),!this.block.isDeadOrDying()&&this.dragging){let o;(o=this.workspace.getLayerManager())==null||o.moveOffDragLayer(this.block,us),this.block.setDragging(!1)}this.connectionCandidate?(this.applyConnections(this.connectionCandidate),this.disposeStep()):this.block.queueRender().then(()=>this.disposeStep())}}disposeStep(){const e=r.getGroup$$module$build$src$core$events$utils();r.setGroup$$module$build$src$core$events$utils(this.originalEventGroup),this.block.snapToGrid();let t;(t=this.connectionPreviewer)==null||t.dispose(),this.workspace.setResizesEnabled(!0),r.setGroup$$module$build$src$core$events$utils(e)}applyConnections(e){const{local:t,neighbour:o}=e;t.connect(o);const s=t.isSuperior()?o:t,i=this.block.getRootBlock();go().then(()=>{cu(s.getSourceBlock()),setTimeout(()=>{i.bringToFront()},0)})}revertDrag(){if(this.block.isShadow()){let o;(o=this.block.getParent())==null||o.revertDrag()}else{var e;(e=this.connectionPreviewer)==null||e.hidePreview(),this.connectionCandidate=null;var t;if((t=this.startChildConn)==null||t.connect(this.block.nextConnection),this.startParentConn)switch(this.startParentConn.type){case Z.INPUT_VALUE:this.startParentConn.connect(this.block.outputConnection);break;case Z.NEXT_STATEMENT:this.startParentConn.connect(this.block.previousConnection)}else{this.block.moveTo(this.startLoc,["drag"]);let o;(o=this.workspace.getLayerManager())==null||o.moveOffDragLayer(this.block,us),ci(this.workspace,this.workspace.getMetricsManager().getScrollMetrics(!0),this.block)}this.startParentConn=this.startChildConn=null,this.block.setDragging(!1),this.dragging=!1}}},dm=class extends Oe{constructor(e,t,o,s){super(t,o,s),this.text=e,this.workspace=t,this.anchor=o,this.ownerRect=s,this.paragraph=this.stringToSvg(e,this.contentContainer),this.updateBubbleSize(),G(this.svgRoot,"blocklyTextBubble")}getText(){return this.text}setText(e){this.text=e,ke(this.paragraph),this.paragraph=this.stringToSvg(e,this.contentContainer),this.updateBubbleSize()}stringToSvg(e,t){return t=this.createParagraph(t),e=this.createTextFragments(t,e),this.workspace.RTL&&this.rightAlignTextFragments(t.getBBox().width,e),t}createParagraph(e){return v(R.G,{class:"blocklyText blocklyBubbleText blocklyNoPointerEvents",transform:`translate(0,${Oe.BORDER_WIDTH})`,style:`direction: ${this.workspace.RTL?"rtl":"ltr"}`},e)}createTextFragments(e,t){let o=1;return t.split(`
622
+ `).map(s=>{const i=v(R.TEXT,{y:`${o}em`,x:Oe.BORDER_WIDTH},e);return s=document.createTextNode(s),i.appendChild(s),o+=1,i})}rightAlignTextFragments(e,t){for(const o of t)o.setAttribute("text-anchor","start"),o.setAttribute("x",`${e+Oe.BORDER_WIDTH}`)}updateBubbleSize(){const e=this.paragraph.getBBox();this.setSize(new ve(e.width+Oe.BORDER_WIDTH*2,e.height+Oe.BORDER_WIDTH*2),!0)}},Xa=17,Co=class extends br{constructor(e){super(e),this.sourceBlock=e,this.textMap=new Map,this.textBubble=null}getType(){return Co.TYPE}initView(e){this.svgRoot||(super.initView(e),v(R.PATH,{class:"blocklyIconShape",d:"M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z"},this.svgRoot),v(R.PATH,{class:"blocklyIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},this.svgRoot),v(R.RECT,{class:"blocklyIconSymbol",x:"7",y:"11",height:"2",width:"2"},this.svgRoot),G(this.svgRoot,"blocklyWarningIcon"))}dispose(){super.dispose();let e;(e=this.textBubble)==null||e.dispose()}getWeight(){return Co.WEIGHT}getSize(){return new ve(Xa,Xa)}applyColour(){super.applyColour();let e;(e=this.textBubble)==null||e.setColour(this.sourceBlock.getColour())}updateCollapsed(){}isShownWhenCollapsed(){return!0}onLocationChange(e){super.onLocationChange(e);let t;(t=this.textBubble)==null||t.setAnchorLocation(this.getAnchorLocation())}addMessage(e,t){if(this.textMap.get(t)===e)return this;e?this.textMap.set(t,e):this.textMap.delete(t);let o;return(o=this.textBubble)==null||o.setText(this.getText()),this}getText(){return[...this.textMap.values()].join(`
623
+ `)}onClick(){super.onClick(),this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.textBubble}setBubbleVisible(e){const t=this;return(0,N.asyncExecutePromiseGeneratorFunction)(function*(){if(t.bubbleIsVisible()!==e){if(yield go(),e)t.textBubble=new dm(t.getText(),t.sourceBlock.workspace,t.getAnchorLocation(),t.getBubbleOwnerRect()),t.applyColour();else{let o;(o=t.textBubble)==null||o.dispose(),t.textBubble=null}_(new(U(w.BUBBLE_OPEN))(t.sourceBlock,e,"warning"))}})}getBubble(){return this.textBubble}getAnchorLocation(){const e=Xa/2;return P.sum(this.workspaceLocation,new P(e,e))}getBubbleOwnerRect(){const e=this.sourceBlock.getSvgRoot().getBBox();return new ye(e.y,e.y+e.height,e.x,e.x+e.width)}};Co.TYPE=ut.WARNING,Co.WEIGHT=2;var Be=class extends Ii{constructor(e,t,o){if(super(e,t,o),this.childlessWidth=this.width=this.height=0,this.warningTextDb=new Map,this.mutator=null,this.rendered=!0,this.visuallyDisabled=!1,this.translation="",this.dragging=!1,this.relativeCoords=new P(0,0),this.dragStrategy=new hm(this),!e.rendered)throw TypeError("Cannot create a rendered block in a headless workspace");this.workspace=e,this.svgGroup=v(R.G,{}),t&&G(this.svgGroup,t),this.style=e.getRenderer().getConstants().getBlockStyle(null),this.pathObject=e.getRenderer().makePathObject(this.svgGroup,this.style),e=this.pathObject.svgPath,e.tooltip=this,Yi(e),this.svgGroup.setAttribute("data-id",this.id),e.id=Re(),this.doInit_()}initSvg(){if(!this.initialized){for(var e of this.inputList)e.init();for(const t of this.getIcons())t.initView(this.createIconPointerDownListener(t)),t.updateEditable();this.applyColour(),this.pathObject.updateMovable(this.isMovable()||this.isInFlyout),(e=this.getSvgRoot())&&z(e,"pointerdown",this,this.onMouseDown),e.parentNode||this.workspace.getCanvas().appendChild(e),this.initialized=!0}}getColourSecondary(){return this.style.colourSecondary}getColourTertiary(){return this.style.colourTertiary}select(){this.addSelect(),V(this)}unselect(){this.removeSelect(),V(null)}setParent(e){var t=this.parentBlock_;if(e!==t){eo(),super.setParent(e),to();var o=this.getSvgRoot();if(!this.workspace.isClearing&&o){var s=this.getRelativeToSurfaceXY(),i=r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode(),n,d=this.getSvgRoot().contains((n=i?.getFocusableElement())!=null?n:null);e?(e.getSvgRoot().appendChild(o),d&&i&&r.getFocusManager$$module$build$src$core$focus_manager().focusNode(i)):t&&(e=this.workspace.getCanvas().querySelector(".blocklyDragging"),t=e?.parentElement,n=this.workspace.getCanvas(),t===n?n.insertBefore(o,e):(n.appendChild(o),d&&i&&r.getFocusManager$$module$build$src$core$focus_manager().focusNode(i)),this.translate(s.x,s.y)),this.applyColour()}}}getRelativeToSurfaceXY(){const e=this.workspace.getLayerManager();if(!e)throw Error("Cannot calculate position because the workspace has not been appended");let t=0,o=0,s=this.getSvgRoot();if(s)do{const i=Bi(s);t+=i.x,o+=i.y,s=s.parentNode}while(s&&!e.hasLayer(s));return new P(t,o)}moveBy(e,t,o){if(this.parentBlock_)throw Error("Block has parent");const s=J();let i=null;s&&(i=new(U(w.BLOCK_MOVE))(this),o&&i.setReason(o)),e=new P(e,t),t=this.getRelativeToSurfaceXY(),e=P.sum(t,e),this.translate(e.x,e.y),this.updateComponentLocations(e),s&&i&&(i.recordNew(),_(i)),this.workspace.resizeContents()}translate(e,t){this.translation=`translate(${e}, ${t})`,this.relativeCoords=new P(e,t),this.getSvgRoot().setAttribute("transform",this.getTranslation())}getTranslation(){return this.translation}moveTo(e,t){const o=this.getRelativeToSurfaceXY();this.moveBy(e.x-o.x,e.y-o.y,t)}moveDuringDrag(e){this.translate(e.x,e.y),this.getSvgRoot().setAttribute("transform",this.getTranslation()),this.updateComponentLocations(e)}snapToGrid(){if(!this.isDeadOrDying()&&!this.getParent()&&!this.isInFlyout){var e=this.workspace.getGrid();if(e!=null&&e.shouldSnap()){var t=this.getRelativeToSurfaceXY();e=e.alignXY(t),e!==t&&this.moveTo(e,["snap"])}}}getBoundingRectangle(){return this.getBoundingRectangleWithDimensions(this.getHeightWidth())}getBoundingRectangleWithoutChildren(){return this.getBoundingRectangleWithDimensions({height:this.height,width:this.childlessWidth})}getBoundingRectangleWithDimensions(e){const t=this.getRelativeToSurfaceXY();let o,s;return this.RTL?(o=t.x-e.width,s=t.x):(o=t.x,s=t.x+e.width),new ye(t.y,t.y+e.height,o,s)}markDirty(){this.pathObject.constants=this.workspace.getRenderer().getConstants();for(let e=0,t;t=this.inputList[e];e++)t.markDirty()}setCollapsed(e){this.collapsed_!==e&&(super.setCollapsed(e),this.updateCollapsed())}childHasWarning(){const e=this.getChildren(!1);for(const t of e)if(t.getIcon(Co.TYPE)||t.childHasWarning())return!0;return!1}updateCollapsed(){var e=this.isCollapsed();const t=ar,o=Wn;for(let i=0,n;n=this.inputList[i];i++)n.name!==t&&n.setVisible(!e);for(var s of this.getIcons())s.updateCollapsed();e?(G(this.svgGroup,"blocklyCollapsed"),this.childHasWarning()&&this.setWarningText(r.Msg$$module$build$src$core$msg.COLLAPSED_WARNINGS_WARNING,Be.COLLAPSED_WARNING_ID),e=this.toString(cm),(s=this.getField(o))?s.setValue(e):(this.getInput(t)||this.appendDummyInput(t)).appendField(new Ps(e),o)):(this.updateDisabled(),this.removeInput(t),Te(this.svgGroup,"blocklyCollapsed"),this.setWarningText(null,Be.COLLAPSED_WARNING_ID))}onMouseDown(e){if(!this.workspace.isReadOnly()){var t=this.workspace.getGesture(e);t&&t.handleBlockStart(e,this)}}showHelp(){const e=typeof this.helpUrl=="function"?this.helpUrl():this.helpUrl;e&&window.open(e)}generateContextMenu(e){return this.workspace.isReadOnly()||!this.contextMenu?null:(e=Ee.registry.getContextMenuOptions({block:this,focusedNode:this},e),this.customContextMenu&&this.customContextMenu(e),e)}calculateContextMenuLocation(e){if(e instanceof PointerEvent)return new P(e.clientX,e.clientY);e=Ys(this.workspace,this.getRelativeToSurfaceXY());let t,o;const s=(t=this.inputList.filter(i=>i.isVisible()).flatMap(i=>i.fieldRow).find(i=>i.isVisible()))==null||(o=t.getSvgRoot())==null?void 0:o.getBoundingClientRect();return new P(this.RTL?e.x-5:e.x+5,(s&&s.height?s.y+s.height:e.y+this.height)+5)}showContextMenu(e){const t=this.generateContextMenu(e),o=this.calculateContextMenuLocation(e);t&&t.length&&(ii(e,t,this.RTL,this.workspace,o),jc(this))}updateComponentLocations(e){this.dragging||this.updateConnectionLocations(e),this.updateIconLocations(e),this.updateFieldLocations(e);for(const t of this.getChildren(!1))t.updateComponentLocations(P.sum(e,t.relativeCoords))}updateConnectionLocations(e){for(const t of this.getConnections_(!1))t.moveToOffset(e)}updateIconLocations(e){for(const t of this.getIcons())t.onLocationChange(e)}updateFieldLocations(e){for(const t of this.inputList)for(const o of t.fieldRow)o.onLocationChange(e)}addClass(e){G(this.svgGroup,e)}removeClass(e){Te(this.svgGroup,e)}setDragging(e){(this.dragging=e)?(this.translation="",nr.push(...this.getConnections_(!0)),this.addClass("blocklyDragging")):(nr.length=0,this.removeClass("blocklyDragging"));for(let t=0;t<this.childBlocks_.length;t++)this.childBlocks_[t].setDragging(e)}setMovable(e){super.setMovable(e),this.pathObject.updateMovable(e)}setEditable(e){super.setEditable(e),e?Te(this.svgGroup,"blocklyNotEditable"):G(this.svgGroup,"blocklyNotEditable"),e=this.getIcons();for(let t=0;t<e.length;t++)e[t].updateEditable()}setShadow(e){super.setShadow(e),this.applyColour()}setInsertionMarker(e){this.isInsertionMarker_!==e&&(this.isInsertionMarker_=e)&&(this.setColour(this.workspace.getRenderer().getConstants().INSERTION_MARKER_COLOUR),this.pathObject.updateInsertionMarker(!0))}getSvgRoot(){return this.svgGroup}dispose(e,t){this.disposing=!0,xc(),Ki();const o=r.getFocusManager$$module$build$src$core$focus_manager();var s,i;if(this.getSvgRoot().contains((i=(s=o.getFocusedNode())==null?void 0:s.getFocusableElement())!=null?i:null)){if(s=this.getParent(),!s){let n;if(i=(n=this.outputConnection)!=null?n:this.previousConnection){let d;s=(d=i.closest(0,new P(0,0)).connection)==null?void 0:d.getSourceBlock()}}s?o.focusNode(s):setTimeout(()=>o.focusTree(this.workspace),0)}t&&(this.unplug(e),bn(this)),super.dispose(!!e),ke(this.svgGroup)}disposeInternal(){this.disposing=!0,super.disposeInternal(),r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode()===this&&this.workspace.cancelCurrentGesture(),[...this.warningTextDb.values()].forEach(e=>clearTimeout(e)),this.warningTextDb.clear(),this.getIcons().forEach(e=>e.dispose())}checkAndDelete(){this.workspace.isFlyout||(r.setGroup$$module$build$src$core$events$utils(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),r.setGroup$$module$build$src$core$events$utils(!1))}toCopyData(){return this.isInsertionMarker_?null:{paster:yr.TYPE,blockState:jt(this,{addCoordinates:!0,addNextBlocks:!1}),typeCounts:io(this,!0)}}applyColour(){var e,t;for((t=(e=this.pathObject).applyColour)==null||t.call(e,this),e=this.getIcons(),t=0;t<e.length;t++)e[t].applyColour();for(const o of this.getFields())o.applyColour()}updateDisabled(){const e=!this.isEnabled()||this.getInheritedDisabled();if(this.visuallyDisabled===e){let t;(t=this.getNextBlock())==null||t.updateDisabled()}else{this.applyColour(),this.visuallyDisabled=e;for(const t of this.getChildren(!1))t.updateDisabled()}}setWarningText(e,t=""){if(t)this.warningTextDb.has(t)&&(clearTimeout(this.warningTextDb.get(t)),this.warningTextDb.delete(t));else{for(var o of this.warningTextDb.values())clearTimeout(o);this.warningTextDb.clear()}if(this.workspace.isDragging())this.warningTextDb.set(t,setTimeout(()=>{this.isDeadOrDying()||(this.warningTextDb.delete(t),this.setWarningText(e,t))},100));else if(this.isInFlyout&&(e=null),o=this.getIcon(Co.TYPE),e){let s=this.getSurroundParent(),i=null;for(;s;)s.isCollapsed()&&(i=s),s=s.getSurroundParent();i&&i.setWarningText(r.Msg$$module$build$src$core$msg.COLLAPSED_WARNINGS_WARNING,Be.COLLAPSED_WARNING_ID),o?o.addMessage(e,t):this.addIcon(new Co(this).addMessage(e,t))}else o&&(t?(o.addMessage("",t),o.getText()||this.removeIcon(Co.TYPE)):this.removeIcon(Co.TYPE))}setMutator(e){this.removeIcon(r.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE),e&&this.addIcon(e)}addIcon(e){return super.addIcon(e),e instanceof r.MutatorIcon$$module$build$src$core$icons$mutator_icon&&(this.mutator=e),e.initView(this.createIconPointerDownListener(e)),e.applyColour(),e.updateEditable(),this.queueRender(),e}createIconPointerDownListener(e){return t=>{this.isDeadOrDying()||(t=this.workspace.getGesture(t))&&t.setStartIcon(e)}}removeIcon(e){const t=super.removeIcon(e);return e.equals(r.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE)&&(this.mutator=null),this.queueRender(),t}setDisabledReason(e,t){const o=this.isEnabled();super.setDisabledReason(e,t),this.isEnabled()===o||this.getInheritedDisabled()||this.updateDisabled()}setDeletable(e){super.setDeletable(e),e?Te(this.svgGroup,"blocklyNotDeletable"):G(this.svgGroup,"blocklyNotDeletable")}setHighlighted(e){this.pathObject.updateHighlighted(e)}addSelect(){this.pathObject.updateSelected(!0)}removeSelect(){this.pathObject.updateSelected(!1)}setDeleteStyle(e){this.pathObject.updateDraggingDelete(e)}getColour(){return this.style.colourPrimary}setColour(e){super.setColour(e),e=this.workspace.getRenderer().getConstants().getBlockStyleForColour(this.colour_);let t,o;(o=(t=this.pathObject).setStyle)==null||o.call(t,e.style),this.style=e.style,this.styleName_=e.name,this.applyColour()}setStyle(e){const t=this.workspace.getRenderer().getConstants().getBlockStyle(e);if(this.styleName_&&Te(this.svgGroup,this.styleName_),t){this.hat=t.hat;let o,s;(s=(o=this.pathObject).setStyle)==null||s.call(o,t),this.colour_=t.colourPrimary,this.style=t,this.applyColour(),G(this.svgGroup,e),this.styleName_=e}else throw Error("Invalid style name: "+e)}getStyle(){return this.style}bringToFront(e=!1){const t=r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode();let o=this;if(!o.isDeadOrDying()){do{const s=o.getSvgRoot(),i=s.parentNode,n=i.childNodes;if(n[n.length-1]!==s&&i.appendChild(s),e)break;o=o.getParent()}while(o);t&&r.getFocusManager$$module$build$src$core$focus_manager().focusNode(t)}}setPreviousStatement(e,t){super.setPreviousStatement(e,t),this.queueRender()}setNextStatement(e,t){super.setNextStatement(e,t),this.queueRender()}setOutput(e,t){super.setOutput(e,t),this.queueRender()}setInputsInline(e){super.setInputsInline(e),this.queueRender()}removeInput(e,t){return e=super.removeInput(e,t),this.queueRender(),e}moveNumberedInputBefore(e,t){super.moveNumberedInputBefore(e,t),this.queueRender()}appendInput(e){return super.appendInput(e),this.queueRender(),e}setConnectionTracking(e){if(this.previousConnection&&this.previousConnection.setTracking(e),this.outputConnection&&this.outputConnection.setTracking(e),this.nextConnection){this.nextConnection.setTracking(e);var t=this.nextConnection.targetBlock();t&&t.setConnectionTracking(e)}if(!this.collapsed_)for(t=0;t<this.inputList.length;t++){var o=this.inputList[t].connection;o&&(o.setTracking(e),(o=o.targetBlock())&&o.setConnectionTracking(e))}}getConnections_(e){const t=[];if(this.outputConnection&&t.push(this.outputConnection),this.previousConnection&&t.push(this.previousConnection),this.nextConnection&&t.push(this.nextConnection),e||!this.collapsed_)for(let o=0,s;s=this.inputList[o];o++)s.connection&&t.push(s.connection);return t}lastConnectionInStack(e){return super.lastConnectionInStack(e)}getMatchingConnection(e,t){return super.getMatchingConnection(e,t)}makeConnection_(e){return new _t(this,e)}getNextBlock(){return super.getNextBlock()}getPreviousBlock(){return super.getPreviousBlock()}bumpNeighbours(){const e=this.getRootBlock();if(!(this.isDeadOrDying()||this.workspace.isDragging()||e.isInFlyout))for(const t of this.getConnections_(!1)){if(t.isSuperior()){let o;(o=t.targetBlock())==null||o.bumpNeighbours()}for(const o of t.neighbours(r.config$$module$build$src$core$config.snapRadius))o.getSourceBlock().getRootBlock()!==e&&(t.isConnected()&&o.isConnected()||(t.isSuperior()?o.bumpAwayFrom(t,!1):t.bumpAwayFrom(o,!0)))}}scheduleSnapAndBump(){this.snapToGrid(),this.bumpNeighbours()}positionNearConnection(e,t,o){if(e.type===Z.NEXT_STATEMENT||e.type===Z.INPUT_VALUE){let s=t.x;t=t.y,s+=o.x-e.getOffsetInBlock().x,t+=o.y-e.getOffsetInBlock().y,this.moveBy(s,t)}}getChildren(e){return super.getChildren(e)}queueRender(){return sc(this)}render(){this.queueRender(),Qo()}renderEfficiently(){eo(),this.isCollapsed()&&this.updateCollapsed(),this.isEnabled()||this.updateDisabled(),this.workspace.getRenderer().render(this),this.tightenChildrenEfficiently(),to()}tightenChildrenEfficiently(){for(const e of this.inputList){const t=e.connection;t&&t.tightenEfficiently()}this.nextConnection&&this.nextConnection.tightenEfficiently()}getHeightWidth(){let e=this.height,t=this.width;var o=this.getNextBlock();if(o){o=o.getHeightWidth();const s=this.workspace.getRenderer().getConstants().NOTCH_HEIGHT;e+=o.height-s,t=Math.max(t,o.width)}return{height:e,width:t}}fadeForReplacement(e){this.pathObject.updateReplacementFade(e)}highlightShapeForInput(e,t){this.pathObject.updateShapeForInputHighlight(e,t)}getDragStrategy(){return this.dragStrategy}setDragStrategy(e){this.dragStrategy=e}isCopyable(){return this.isOwnDeletable()&&this.isOwnMovable()}isMovable(){return this.dragStrategy.isMovable()}startDrag(e){this.dragStrategy.startDrag(e)}drag(e,t){this.dragStrategy.drag(e,t)}endDrag(e){this.dragStrategy.endDrag(e)}revertDrag(){this.dragStrategy.revertDrag()}toFlyoutInfo(){const e=Object.assign({},{kind:"BLOCK"},jt(this)),t=new Set(["id","height","width","pinned","enabled"]),o=function(s){for(const i in s)t.has(i)?delete s[i]:typeof s[i]=="object"&&o(s[i])};return o(e),[e]}jsonInit(e){super.jsonInit(e),e.classes&&this.addClass(Array.isArray(e.classes)?e.classes.join(" "):e.classes)}getFocusableElement(){return this.pathObject.svgPath}getFocusableTree(){return this.workspace}onNodeFocus(){this.select()}onNodeBlur(){this.unselect()}canBeFocused(){return!0}};Be.INLINE=-1,Be.COLLAPSED_WARNING_ID="TEMP_COLLAPSED_WARNING_";var $m=class{constructor(){}onDragEnter(e){}onDragOver(e){}onDragExit(e){}onDrop(e){}getClientRect(){return null}shouldPreventMove(e){return!1}},$l=class extends $m{constructor(){super(),this.wouldDelete_=!1}wouldDelete(e){return e instanceof Be?(e=!e.getParent()&&e.isDeletable(),this.updateWouldDelete_(e)):this.updateWouldDelete_(Kt(e)&&e.isDeletable()),this.wouldDelete_}updateWouldDelete_(e){this.wouldDelete_=e}},Ci=class{constructor(e,t){this.element=e,this.type=t}getElement(){return this.element}getType(){return this.type}},ja=class{constructor(e){this.workspace_=e}getDimensionsPx_(e){let t=0,o=0;return e&&(t=e.getWidth(),o=e.getHeight()),new ve(t,o)}getFlyoutMetrics(e){return e=this.getDimensionsPx_(this.workspace_.getFlyout(e)),{width:e.width,height:e.height,position:this.workspace_.toolboxPosition}}getToolboxMetrics(){const e=this.getDimensionsPx_(this.workspace_.getToolbox());return{width:e.width,height:e.height,position:this.workspace_.toolboxPosition}}getSvgMetrics(){return this.workspace_.getCachedParentSvgSize()}getAbsoluteMetrics(){let e=0,t=0;const o=this.getToolboxMetrics(),s=this.getFlyoutMetrics(),i=!!this.workspace_.getToolbox();var n;const d=!((n=this.workspace_.getFlyout())!=null&&n.autoClose);n=i?o.position:s.position;const f=n===be.TOP;return n===be.LEFT&&(i&&(e+=o.width),d&&(e+=s.width)),f&&(i&&(t+=o.height),d&&(t+=s.height)),{top:t,left:e}}getViewMetrics(e){e=e?this.workspace_.scale:1;const t=this.getSvgMetrics(),o=this.getToolboxMetrics(),s=this.getFlyoutMetrics(),i=!!this.workspace_.getToolbox();var n;const d=!((n=this.workspace_.getFlyout())!=null&&n.autoClose);n=i?o.position:s.position;const f=n===be.LEFT||n===be.RIGHT;return(n===be.TOP||n===be.BOTTOM)&&(i&&(t.height-=o.height),d&&(t.height-=s.height)),f&&(i&&(t.width-=o.width),d&&(t.width-=s.width)),{height:t.height/e,width:t.width/e,top:-this.workspace_.scrollY/e,left:-this.workspace_.scrollX/e}}getContentMetrics(e){e=e?1:this.workspace_.scale;const t=this.workspace_.getBlocksBoundingBox();return{height:(t.bottom-t.top)*e,width:(t.right-t.left)*e,top:t.top*e,left:t.left*e}}hasFixedEdges(){return!this.workspace_.isMovableHorizontally()||!this.workspace_.isMovableVertically()}getComputedFixedEdges_(e){if(!this.hasFixedEdges())return{};const t=this.workspace_.isMovableHorizontally(),o=this.workspace_.isMovableVertically();e=e||this.getViewMetrics(!1);const s={};return o||(s.top=e.top,s.bottom=e.top+e.height),t||(s.left=e.left,s.right=e.left+e.width),s}getPaddedContent_(e,t){const o=t.top+t.height,s=t.left+t.width,i=e.width;e=e.height;const n=i/2,d=e/2;return{top:Math.min(t.top-d,o-e),bottom:Math.max(o+d,t.top+e),left:Math.min(t.left-n,s-i),right:Math.max(s+n,t.left+i)}}getScrollMetrics(e,t,o){e=e?this.workspace_.scale:1,t=t||this.getViewMetrics(!1);var s=o||this.getContentMetrics();o=this.getComputedFixedEdges_(t),t=this.getPaddedContent_(t,s),s=o.top!==void 0?o.top:t.top;const i=o.left!==void 0?o.left:t.left;return{top:s/e,left:i/e,width:((o.right!==void 0?o.right:t.right)-i)/e,height:((o.bottom!==void 0?o.bottom:t.bottom)-s)/e}}getUiMetrics(){return{viewMetrics:this.getViewMetrics(),absoluteMetrics:this.getAbsoluteMetrics(),toolboxMetrics:this.getToolboxMetrics()}}getMetrics(){const e=this.getToolboxMetrics(),t=this.getFlyoutMetrics(!0),o=this.getSvgMetrics(),s=this.getAbsoluteMetrics(),i=this.getViewMetrics(),n=this.getContentMetrics(),d=this.getScrollMetrics(!1,i,n);return{contentHeight:n.height,contentWidth:n.width,contentTop:n.top,contentLeft:n.left,scrollHeight:d.height,scrollWidth:d.width,scrollTop:d.top,scrollLeft:d.left,viewHeight:i.height,viewWidth:i.width,viewTop:i.top,viewLeft:i.left,absoluteTop:s.top,absoluteLeft:s.left,svgHeight:o.height,svgWidth:o.width,toolboxWidth:e.width,toolboxHeight:e.height,toolboxPosition:e.position,flyoutWidth:t.width,flyoutHeight:t.height}}};l(M.METRICS_MANAGER,Ft,ja);var pm=class extends ja{constructor(e,t){super(e),this.flyout_=t}getBoundingBox(){let e;try{e=this.workspace_.getCanvas().getBBox()}catch{e={height:0,y:0,width:0,x:0}}return e}getContentMetrics(e){const t=this.getBoundingBox();return e=e?1:this.workspace_.scale,{height:t.height*e,width:t.width*e,top:t.y*e,left:t.x*e}}getScrollMetrics(e,t,o){return t=o||this.getContentMetrics(),o=this.flyout_.MARGIN*this.workspace_.scale,e=e?this.workspace_.scale:1,{height:(t.height+2*o)/e,width:(t.width+t.left+o)/e,top:0,left:0}}},xt=class{constructor(e,t,o,s){this.workspace=e,this.targetWorkspace=t,this.isFlyoutLabel=s,this.height=this.width=0,this.cursorSvg=this.svgText=null,this.text=o.text,this.position=new P(0,0),this.callbackKey=o.callbackKey||o.callbackkey,this.cssClass=o["web-class"]||null,this.info=o,e=this.isFlyoutLabel?"blocklyFlyoutLabel":"blocklyFlyoutButton",this.cssClass&&(e+=" "+this.cssClass),this.id=Re(),this.svgGroup=v(R.G,{id:this.id,class:e},this.workspace.getCanvas());let i;this.isFlyoutLabel||(i=v(R.RECT,{class:"blocklyFlyoutButtonShadow",rx:xt.BORDER_RADIUS,ry:xt.BORDER_RADIUS,x:1,y:1},this.svgGroup)),e=v(R.RECT,{class:this.isFlyoutLabel?"blocklyFlyoutLabelBackground":"blocklyFlyoutButtonBackground",rx:xt.BORDER_RADIUS,ry:xt.BORDER_RADIUS},this.svgGroup),t=v(R.TEXT,{class:this.isFlyoutLabel?"blocklyFlyoutLabelText":"blocklyText",x:0,y:0,"text-anchor":"middle"},this.svgGroup),o=Je(this.text),this.workspace.RTL&&(o+="‏"),t.textContent=o,this.isFlyoutLabel&&(this.svgText=t,this.workspace.getThemeManager().subscribe(this.svgText,"flyoutForegroundColour","fill")),s=Mt(t,"fontSize");const n=Mt(t,"fontWeight"),d=Mt(t,"fontFamily");if(this.width=ho(t,s,n,d),o=E(o,s,n,d),this.height=this.height||o.height,!this.isFlyoutLabel){this.width+=2*xt.TEXT_MARGIN_X,this.height+=2*xt.TEXT_MARGIN_Y;let f;(f=i)==null||f.setAttribute("width",String(this.width));let L;(L=i)==null||L.setAttribute("height",String(this.height))}e.setAttribute("width",String(this.width)),e.setAttribute("height",String(this.height)),t.setAttribute("x",String(this.width/2)),t.setAttribute("y",String(this.height/2-o.height/2+o.baseline)),this.updateTransform(),this.onMouseDownWrapper=z(this.svgGroup,"pointerdown",this,this.onMouseDown),this.onMouseUpWrapper=z(this.svgGroup,"pointerup",this,this.onMouseUp)}createDom(){return this.svgGroup}show(){this.updateTransform(),this.svgGroup.setAttribute("display","block")}updateTransform(){this.svgGroup.setAttribute("transform","translate("+this.position.x+","+this.position.y+")")}moveTo(e,t){this.position.x=e,this.position.y=t,this.updateTransform()}moveBy(e,t,o){this.moveTo(this.position.x+e,this.position.y+t)}isLabel(){return this.isFlyoutLabel}getPosition(){return this.position}getBoundingRectangle(){return new ye(this.position.y,this.position.y+this.height,this.position.x,this.position.x+this.width)}getButtonText(){return this.text}getTargetWorkspace(){return this.targetWorkspace}getWorkspace(){return this.workspace}dispose(){te(this.onMouseDownWrapper),te(this.onMouseUpWrapper),this.svgGroup&&ke(this.svgGroup),this.svgText&&this.workspace.getThemeManager().unsubscribe(this.svgText)}setCursorSvg(e){e?this.svgGroup&&(this.svgGroup.appendChild(e),this.cursorSvg=e):this.cursorSvg=null}onMouseUp(e){(e=this.targetWorkspace.getGesture(e))&&e.cancel(),this.isFlyoutLabel&&this.callbackKey?console.warn("Labels should not have callbacks. Label text: "+this.text):this.isFlyoutLabel||this.callbackKey&&this.targetWorkspace.getButtonCallback(this.callbackKey)?this.isFlyoutLabel||(e=this.targetWorkspace.getButtonCallback(this.callbackKey))&&e(this):console.warn("Buttons should have callbacks. Button text: "+this.text)}onMouseDown(e){const t=this.targetWorkspace.getGesture(e),o=this.targetWorkspace.getFlyout();t&&o&&t.handleFlyoutStart(e,o)}getSvgRoot(){return this.svgGroup}getFocusableElement(){return this.svgGroup}getFocusableTree(){return this.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}};xt.TEXT_MARGIN_X=5,xt.TEXT_MARGIN_Y=2,xt.BORDER_RADIUS=4,q(`
624
624
  .blocklyFlyoutButton {
625
625
  fill: #888;
626
626
  cursor: default;
@@ -641,8 +641,8 @@ children`),this.state=e}},Mg=class extends gi{constructor(e,t,o){super(`Cannot a
641
641
  .blocklyFlyoutLabelBackground {
642
642
  opacity: 0;
643
643
  }
644
- `);var dm=class{getFirstChild(e){return null}getParent(e){return e.getWorkspace()}getNextSibling(e){return null}getPreviousSibling(e){return null}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof xt}},$m=class{constructor(e,t){this.policy=e,this.flyout=t}getFirstChild(e){return null}getParent(e){return this.policy.getParent(e)}getNextSibling(e){const t=this.flyout.getContents();if(!t)return null;let o=t.findIndex(s=>s.getElement()===e);return o===-1?null:(o++,o>=t.length&&(o=0),t[o].getElement())}getPreviousSibling(e){const t=this.flyout.getContents();if(!t)return null;let o=t.findIndex(s=>s.getElement()===e);return o===-1?null:(o--,o<0&&(o=t.length-1),t[o].getElement())}isNavigable(e){return this.policy.isNavigable(e)}isApplicable(e){return this.policy.isApplicable(e)}},$l=class{constructor(e,t){this.gap=e,this.axis=t,this.y=this.x=0}getBoundingRectangle(){switch(this.axis){case"x":return new ye(this.y,this.y,this.x,this.x+this.gap);case"y":return new ye(this.y,this.y+this.gap,this.x,this.x)}}moveBy(e,t,o){this.x+=e,this.y+=t}isNavigable(){return!1}getFocusableElement(){throw Error("Cannot be focused")}getFocusableTree(){throw Error("Cannot be focused")}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!1}},pm=class{getFirstChild(e){return null}getParent(e){return null}getNextSibling(e){return null}getPreviousSibling(e){return null}isNavigable(e){return!1}isApplicable(e){return e instanceof $l}},gm=class{getFirstChild(e){return au(e,!0)[0]}getParent(e){var t;if((t=e.previousConnection)!=null&&t.targetBlock()){if(t=e.getSurroundParent())return t}else{let o;if((o=e.outputConnection)!=null&&o.targetBlock())return e.outputConnection.targetBlock()}return e.workspace}getNextSibling(e){let t;if((t=e.nextConnection)!=null&&t.targetBlock()){let s;return(s=e.nextConnection)==null?void 0:s.targetBlock()}let o;return(o=e.outputConnection)!=null&&o.targetBlock()?ro(e,1):e.getSurroundParent()?ro(e.getTopStackBlock(),1):this.getParent(e)instanceof At?ui(e,1):null}getPreviousSibling(e){let t;if((t=e.previousConnection)!=null&&t.targetBlock()){let s;return(s=e.previousConnection)==null?void 0:s.targetBlock()}let o;return(o=e.outputConnection)!=null&&o.targetBlock()?ro(e,-1):this.getParent(e)instanceof At?ui(e,-1):null}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof Be}},Sb=class{getFirstChild(e){return null}getParent(e){return e.getParentComment()}getNextSibling(e){const t=e.getParentComment().view.getCommentBarButtons();return e=t.indexOf(e),e>=0&&e+1<t.length?t[e+1]:null}getPreviousSibling(e){const t=e.getParentComment().view.getCommentBarButtons();return e=t.indexOf(e),e>0?t[e-1]:null}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof il}},mm=class{getFirstChild(e){return e.getParentInput()?e.targetConnection:null}getParent(e){return e.getSourceBlock()}getNextSibling(e){if(e.getParentInput())return ro(e,1);if(e.type===Z.NEXT_STATEMENT){const o=e.targetConnection;var t=e.getSourceBlock();if(!o&&t.getRootBlock().lastConnectionInStack(!1)===e){e=t.workspace.getTopBlocks(!0),t=e.indexOf(t.getRootBlock())+1,t>=e.length&&(t=0),t=e[t];let s;return(s=this.getParentConnection(t))!=null?s:t}return o}return e.getSourceBlock()}getPreviousSibling(e){if(e.getParentInput())return ro(e,-1);if(e.type===Z.PREVIOUS_STATEMENT||e.type===Z.OUTPUT_VALUE){const o=e.targetConnection&&!e.targetConnection.getParentInput()?e.targetConnection:null;var t=e.getSourceBlock();if(!o&&this.getParentConnection(t.getRootBlock())===e){e=t.workspace.getTopBlocks(!0),t=e.indexOf(t.getRootBlock())-1,t<0&&(t=e.length-1),t=e[t];let s;return(s=t.lastConnectionInStack(!1))!=null?s:t}return o}return e.type===Z.NEXT_STATEMENT?e.getSourceBlock():null}getParentConnection(e){let t;return!e.outputConnection||(t=e.previousConnection)!=null&&t.isConnected()?e.previousConnection:e.outputConnection}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof _t}},fm=class{getFirstChild(e){return null}getParent(e){return e.getSourceBlock()}getNextSibling(e){return ro(e,1)}getPreviousSibling(e){return ro(e,-1)}isNavigable(e){let t;return e.canBeFocused()&&e.isVisible()&&(e.isClickable()||e.isCurrentlyEditable())&&!((t=e.getSourceBlock())!=null&&t.isSimpleReporter()&&e.isFullBlockField())&&e.getParentInput().isVisible()}isApplicable(e){return e instanceof we}},kb=class{getFirstChild(e){if(e instanceof r.MutatorIcon$$module$build$src$core$icons$mutator_icon&&e.bubbleIsVisible()&&r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode()===e){let t,o;return(o=(t=e.getBubble())==null?void 0:t.getWorkspace())!=null?o:null}return null}getParent(e){return e.getSourceBlock()}getNextSibling(e){return ro(e,1)}getPreviousSibling(e){return ro(e,-1)}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof _r}},Rb=class{getFirstChild(e){return e.view.getCommentBarButtons()[0]}getParent(e){return e.workspace}getNextSibling(e){return ui(e,1)}getPreviousSibling(e){return ui(e,-1)}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof yo}},_m=class{getFirstChild(e){return e=e.getTopBlocks(!0),e.length?e[0]:null}getParent(e){return null}getNextSibling(e){return null}getPreviousSibling(e){return null}isNavigable(e){return e.canBeFocused()&&!e.isMutator}isApplicable(e){return e instanceof At}},Xa=class{constructor(){this.rules=[new gm,new fm,new mm,new _m,new kb,new Rb,new Sb]}addNavigationPolicy(e){this.rules.push(e)}get(e){return this.rules.find(t=>t.isApplicable(e))}getFirstChild(e){let t;const o=(t=this.get(e))==null?void 0:t.getFirstChild(e);if(!o)return null;let s;return(s=this.get(o))!=null&&s.isNavigable(o)?o:this.getFirstChild(o)||this.getNextSibling(o)}getParent(e){let t;const o=(t=this.get(e))==null?void 0:t.getParent(e);if(!o)return null;let s;return(s=this.get(o))!=null&&s.isNavigable(o)?o:this.getParent(o)}getNextSibling(e){let t;const o=(t=this.get(e))==null?void 0:t.getNextSibling(e);if(!o)return null;let s;return(s=this.get(o))!=null&&s.isNavigable(o)?o:this.getNextSibling(o)}getPreviousSibling(e){let t;const o=(t=this.get(e))==null?void 0:t.getPreviousSibling(e);if(!o)return null;let s;return(s=this.get(o))!=null&&s.isNavigable(o)?o:this.getPreviousSibling(o)}},bm=class extends Xa{constructor(e){super(),this.rules.push(new dm,new pm),this.rules=this.rules.map(t=>new $m(t,e))}},ja=class{constructor(e,t,o,s,i){this.workspace=e,this.oldHostMetrics=this.corner_=this.vScroll=this.hScroll=null,t=t===void 0?!0:t,o=o===void 0?!0:o;const n=t&&o;t&&(this.hScroll=new Ze(e,!0,n,s,i)),o&&(this.vScroll=new Ze(e,!1,n,s,i)),n&&(this.corner_=v(R.RECT,{height:Ze.scrollbarThickness,width:Ze.scrollbarThickness,class:"blocklyScrollbarBackground"}),Qt(this.corner_,e.getBubbleCanvas()))}dispose(){ke(this.corner_),this.oldHostMetrics=this.corner_=null,this.hScroll&&(this.hScroll.dispose(),this.hScroll=null),this.vScroll&&(this.vScroll.dispose(),this.vScroll=null)}resize(){const e=this.workspace.getMetrics();if(e){var t=!1,o=!1;if(this.oldHostMetrics&&this.oldHostMetrics.viewWidth===e.viewWidth&&this.oldHostMetrics.viewHeight===e.viewHeight&&this.oldHostMetrics.absoluteTop===e.absoluteTop&&this.oldHostMetrics.absoluteLeft===e.absoluteLeft?(this.oldHostMetrics&&this.oldHostMetrics.scrollWidth===e.scrollWidth&&this.oldHostMetrics.viewLeft===e.viewLeft&&this.oldHostMetrics.scrollLeft===e.scrollLeft||(t=!0),this.oldHostMetrics&&this.oldHostMetrics.scrollHeight===e.scrollHeight&&this.oldHostMetrics.viewTop===e.viewTop&&this.oldHostMetrics.scrollTop===e.scrollTop||(o=!0)):o=t=!0,t||o){try{r.disable$$module$build$src$core$events$utils(),this.hScroll&&t&&this.hScroll.resize(e),this.vScroll&&o&&this.vScroll.resize(e)}finally{r.enable$$module$build$src$core$events$utils()}this.workspace.maybeFireViewportChangeEvent()}if(this.hScroll&&this.vScroll){if(!this.oldHostMetrics||this.oldHostMetrics.viewWidth!==e.viewWidth||this.oldHostMetrics.absoluteLeft!==e.absoluteLeft){let s;(s=this.corner_)==null||s.setAttribute("x",String(this.vScroll.position.x))}if(!this.oldHostMetrics||this.oldHostMetrics.viewHeight!==e.viewHeight||this.oldHostMetrics.absoluteTop!==e.absoluteTop){let s;(s=this.corner_)==null||s.setAttribute("y",String(this.hScroll.position.y))}}this.oldHostMetrics=e}}canScrollHorizontally(){return!!this.hScroll}canScrollVertically(){return!!this.vScroll}setOrigin(e,t){this.hScroll&&this.hScroll.setOrigin(e,t),this.vScroll&&this.vScroll.setOrigin(e,t)}set(e,t,o){this.hScroll&&this.hScroll.set(e,!1),this.vScroll&&this.vScroll.set(t,!1),(o||o===void 0)&&(e={},this.hScroll&&(e.x=this.hScroll.getRatio_()),this.vScroll&&(e.y=this.vScroll.getRatio_()),this.workspace.setMetrics(e))}setX(e){this.hScroll&&this.hScroll.set(e,!0)}setY(e){this.vScroll&&this.vScroll.set(e,!0)}setContainerVisible(e){this.hScroll&&this.hScroll.setContainerVisible(e),this.vScroll&&this.vScroll.setContainerVisible(e)}isVisible(){let e=!1;return this.hScroll&&(e=this.hScroll.isVisible()),this.vScroll&&(e=e||this.vScroll.isVisible()),e}setVisible(e){this.hScroll&&this.hScroll.setVisibleInternal(e),this.vScroll&&this.vScroll.setVisibleInternal(e)}resizeContent(e){this.hScroll&&this.hScroll.resizeContentHorizontal(e),this.vScroll&&this.vScroll.resizeContentVertical(e)}resizeView(e){this.hScroll&&this.hScroll.resizeViewHorizontal(e),this.vScroll&&this.vScroll.resizeViewVertical(e)}},Si="sep",Tm=class{load(e,t){return e=new $l(0,t.horizontalLayout?"x":"y"),new Ci(e,Si)}gapForItem(e,t){let o;return(o=parseInt(String(e.gap)))!=null?o:t}disposeItem(e){}getType(){return Si}};l(M.FLYOUT_INFLATER,Si,Tm);var pl=class extends dl{constructor(e){super(),this.horizontalLayout=!1,this.boundEvents=[],this.reflowWrapper=null,this.contents=[],this.autoClose=!0,this.visible=!1,this.containerVisible=!0,this.CORNER_RADIUS=8,this.SCROLLBAR_MARGIN=2.5,this.height_=this.width_=0,this.dragAngleRange_=70,this.svgGroup_=this.svgBackground_=null,this.inflaters=new Map,e.setMetrics=this.setMetrics_.bind(this),this.workspace_=new At(e),this.workspace_.setMetricsManager(new hm(this.workspace_,this)),this.workspace_.internalIsFlyout=!0,this.workspace_.setVisible(this.visible),this.workspace_.setNavigator(new bm(this)),this.id=rt(),this.RTL=!!e.RTL,this.toolboxPosition_=e.toolboxPosition,this.tabWidth_=this.workspace_.getRenderer().getConstants().TAB_WIDTH,this.MARGIN=this.CORNER_RADIUS,this.GAP_X=this.MARGIN*3,this.GAP_Y=this.MARGIN*3}createDom(e){return this.svgGroup_=v(e,{class:"blocklyFlyout"}),this.svgGroup_.style.display="none",this.svgBackground_=v(R.PATH,{class:"blocklyFlyoutBackground"},this.svgGroup_),this.svgGroup_.appendChild(this.workspace_.createDom()),this.workspace_.getThemeManager().subscribe(this.svgBackground_,"flyoutBackgroundColour","fill"),this.workspace_.getThemeManager().subscribe(this.svgBackground_,"flyoutOpacity","fill-opacity"),this.svgGroup_}init(e){this.targetWorkspace=e,this.workspace_.targetWorkspace=e,this.workspace_.scrollbar=new ja(this.workspace_,this.horizontalLayout,!this.horizontalLayout,"blocklyFlyoutScrollbar",this.SCROLLBAR_MARGIN),this.hide(),this.boundEvents.push(z(this.svgGroup_,"wheel",this,this.wheel_)),this.boundEvents.push(z(this.svgBackground_,"pointerdown",this,this.onMouseDown)),this.workspace_.getGesture=this.targetWorkspace.getGesture.bind(this.targetWorkspace),this.workspace_.setVariableMap(this.targetWorkspace.getVariableMap()),this.workspace_.createPotentialVariableMap(),e.getComponentManager().addComponent({component:this,weight:Ve.ComponentWeight.FLYOUT_WEIGHT,capabilities:[Ve.Capability.AUTOHIDEABLE,Ve.Capability.DELETE_AREA,Ve.Capability.DRAG_TARGET]})}dispose(){this.hide(),this.targetWorkspace.getComponentManager().removeComponent(this.id);for(const e of this.boundEvents)te(e);this.boundEvents.length=0,this.workspace_&&(this.workspace_.getThemeManager().unsubscribe(this.svgBackground_),this.workspace_.dispose()),this.svgGroup_&&ke(this.svgGroup_)}getWidth(){return this.width_}getHeight(){return this.height_}getFlyoutScale(){return this.targetWorkspace.scale}getWorkspace(){return this.workspace_}setAutoClose(e){this.autoClose=e,this.targetWorkspace.recordDragTargets(),this.targetWorkspace.resizeContents()}autoHide(e){!e&&this.targetWorkspace.getFlyout(!0)===this&&this.autoClose&&this.hide()}getTargetWorkspace(){return this.targetWorkspace}isVisible(){return this.visible}setVisible(e){const t=e!==this.isVisible();this.visible=e,t&&(this.autoClose||this.targetWorkspace.recordDragTargets(),this.updateDisplay())}setContainerVisible(e){const t=e!==this.containerVisible;this.containerVisible=e,t&&this.updateDisplay()}getContents(){return this.contents}setContents(e){this.contents=e}updateDisplay(){let e;e=this.containerVisible?this.isVisible():!1,this.svgGroup_&&(this.svgGroup_.style.display=e?"block":"none");let t;(t=this.workspace_.scrollbar)==null||t.setContainerVisible(e)}positionAt_(e,t,o,s){let i;(i=this.svgGroup_)==null||i.setAttribute("width",`${e}`);let n;(n=this.svgGroup_)==null||n.setAttribute("height",`${t}`),this.workspace_.setCachedParentSvgSize(e,t),this.svgGroup_&&Mo(this.svgGroup_,"translate("+o+"px,"+s+"px)"),(e=this.workspace_.scrollbar)&&(e.setOrigin(o,s),e.resize(),e.hScroll&&e.hScroll.setPosition(e.hScroll.position.x,e.hScroll.position.y),e.vScroll&&e.vScroll.setPosition(e.vScroll.position.x,e.vScroll.position.y))}hide(){this.isVisible()&&(this.setVisible(!1),this.reflowWrapper&&(this.workspace_.removeChangeListener(this.reflowWrapper),this.reflowWrapper=null))}show(e){this.workspace_.setResizesEnabled(!1),this.hide(),this.clearOldBlocks(),typeof e=="string"&&(e=this.getDynamicCategoryContents(e)),this.setVisible(!0),e=Bi(e),e=this.createFlyoutInfo(e),Qo(this.workspace_),this.setContents(e),this.layout_(e),this.horizontalLayout?this.height_=0:this.width_=0,this.reflow(),this.workspace_.setResizesEnabled(!0),this.reflowWrapper=t=>{t.type!==w.BLOCK_CHANGE&&t.type!==w.BLOCK_FIELD_INTERMEDIATE_CHANGE||this.reflow()},this.workspace_.addChangeListener(this.reflowWrapper)}createFlyoutInfo(e){const t=[],o=this.horizontalLayout?this.GAP_X:this.GAP_Y;for(const s of e)"custom"in s&&(e=this.getDynamicCategoryContents(s.custom),e=Bi(e),t.push(...this.createFlyoutInfo(e))),e=s.kind.toLowerCase(),(e=this.getInflaterForType(e))&&(t.push(e.load(s,this)),(e=e.gapForItem(s,o))&&t.push(new Ci(new $l(e,this.horizontalLayout?"x":"y"),Si)));return this.normalizeSeparators(t)}normalizeSeparators(e){for(let t=e.length-1;t>0;t--){const o=e[t].getType().toLowerCase(),s=e[t-1].getType().toLowerCase();o===Si&&s===Si&&e.splice(t-1,1)}return e}getDynamicCategoryContents(e){if(e=this.workspace_.targetWorkspace.getToolboxCategoryCallback(e),typeof e!="function")throw TypeError("Couldn't find a callback function when opening a toolbox category.");return e(this.workspace_.targetWorkspace)}clearOldBlocks(){this.getContents().forEach(t=>{let o;(o=this.getInflaterForType(t.getType()))==null||o.disposeItem(t)});let e;(e=this.workspace_.getPotentialVariableMap())==null||e.clear()}onMouseDown(e){const t=this.targetWorkspace.getGesture(e);t&&t.handleFlyoutStart(e,this)}isBlockCreatable(e){return e.isEnabled()&&!this.getTargetWorkspace().isReadOnly()}createBlock(e){let t=null;r.disable$$module$build$src$core$events$utils();var o=this.targetWorkspace.getAllVariables();this.targetWorkspace.setResizesEnabled(!1);try{t=this.placeNewBlock(e)}finally{r.enable$$module$build$src$core$events$utils()}if(this.targetWorkspace.hideChaff(),e=Gi(this.targetWorkspace,o),J()){for(r.setGroup$$module$build$src$core$events$utils(!0),o=0;o<e.length;o++){const s=e[o];_(new(U(w.VAR_CREATE))(s))}_(new(U(w.BLOCK_CREATE))(t))}return this.autoClose&&this.hide(),t}reflow(){this.reflowWrapper&&this.workspace_.removeChangeListener(this.reflowWrapper),this.reflowInternal_(),this.reflowWrapper&&this.workspace_.addChangeListener(this.reflowWrapper)}isScrollable(){return this.workspace_.scrollbar?this.workspace_.scrollbar.isVisible():!1}placeNewBlock(e){var t=this.targetWorkspace;if(!e.getSvgRoot())throw Error("oldBlock is not rendered");const o=this.serializeBlock(e);return t.setResizesEnabled(!1),t=es(o,t),this.positionNewBlock(e,t),t}serializeBlock(e){return jt(e)}positionNewBlock(e,t){const o=this.targetWorkspace;var s=o.getOriginOffsetInPixels(),i=this.workspace_.getOriginOffsetInPixels();e=e.getRelativeToSurfaceXY(),e.scale(this.workspace_.scale),i=P.sum(i,e),s=P.difference(i,s),s.scale(1/o.scale),t.moveTo(new P(s.x,s.y))}getInflaterForType(e){if(this.inflaters.has(e)){var t;return(t=this.inflaters.get(e))!=null?t:null}return(t=A(M.FLYOUT_INFLATER,e))?(t=new t,this.inflaters.set(e,t),t):null}getFocusableElement(){throw Error("Flyouts are not directly focusable.")}getFocusableTree(){throw Error("Flyouts are not directly focusable.")}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!1}getRootFocusableNode(){throw Error("Flyouts are not directly focusable.")}getRestoredFocusableNode(e){throw Error("Flyouts are not directly focusable.")}getNestedTrees(){throw Error("Flyouts are not directly focusable.")}lookUpFocusableNode(e){throw Error("Flyouts are not directly focusable.")}onTreeFocus(e,t){}onTreeBlur(e){throw Error("Flyouts are not directly focusable.")}},Em=class{constructor(){this.isActive=!1,this.activeClassName="blocklyKeyboardNavigation"}setIsActive(e=!0){this.isActive=e,this.updateActiveVisualization()}getIsActive(){return this.isActive}updateActiveVisualization(){this.isActive?document.body.classList.add(this.activeClassName):document.body.classList.remove(this.activeClassName)}},gl=new Em,ym=class{constructor(e){this.workspace=e,this.horizontalScrollEnabled=this.workspace.isMovableHorizontally(),this.verticalScrollEnabled=this.workspace.isMovableVertically(),this.startScrollXY_=new P(e.scrollX,e.scrollY)}dispose(){this.workspace=null}startDrag(){}endDrag(e){this.drag(e)}drag(e){if(e=P.sum(this.startScrollXY_,e),this.horizontalScrollEnabled&&this.verticalScrollEnabled)this.workspace.scroll(e.x,e.y);else if(this.horizontalScrollEnabled)this.workspace.scroll(e.x,this.workspace.scrollY);else if(this.verticalScrollEnabled)this.workspace.scroll(this.workspace.scrollX,e.y);else throw new TypeError("Invalid state.")}},wb=5,Ob=6,ml=class{constructor(e,t){this.creatorWorkspace=t,this.mouseDownXY=new P(0,0),this.startWorkspace_=this.targetBlock=this.startComment=this.startBlock=this.startIcon=this.startField=this.startBubble=null,this.hasExceededDragRadius=!1,this.boundEvents=[],this.workspaceDragger=this.dragger=null,this.dragging=!1,this.flyout=null,this.multiTouch=this.isEnding_=this.gestureHasStarted=this.calledUpdateIsDragging=!1,this.cachedPoints=new Map,this.startDistance=this.previousScale=0,this.currentDropdownOwner=this.isPinchZoomEnabled=null,this.mostRecentEvent=e,this.currentDragDeltaXY=new P(0,0)}dispose(){ie(),xc(),this.creatorWorkspace.clearGesture();for(const e of this.boundEvents)te(e);this.boundEvents.length=0,this.workspaceDragger&&this.workspaceDragger.dispose()}updateFromEvent(e){const t=new P(e.clientX,e.clientY);this.updateDragDelta(t)&&(this.updateIsDragging(e),ue()),this.mostRecentEvent=e}updateDragDelta(e){return this.currentDragDeltaXY=P.difference(e,this.mouseDownXY),this.hasExceededDragRadius?!1:this.hasExceededDragRadius=P.magnitude(this.currentDragDeltaXY)>(this.flyout?r.config$$module$build$src$core$config.flyoutDragRadius:r.config$$module$build$src$core$config.dragRadius)}updateIsDraggingFromFlyout(){let e;if(!this.targetBlock||(e=this.flyout)==null||!e.isBlockCreatable(this.targetBlock))return!1;if(!this.flyout.targetWorkspace)throw Error(`Cannot update dragging from the flyout because the ' +
645
- 'flyout's target workspace is undefined`);return!this.flyout.isScrollable()||this.flyout.isDragTowardWorkspace(this.currentDragDeltaXY)?(this.startWorkspace_=this.flyout.targetWorkspace,this.startWorkspace_.updateScreenCalculationsIfScrolled(),r.getGroup$$module$build$src$core$events$utils()||r.setGroup$$module$build$src$core$events$utils(!0),this.startBlock=null,this.targetBlock=this.flyout.createBlock(this.targetBlock),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.targetBlock),!0):!1}updateIsDraggingWorkspace(){if(!this.startWorkspace_)throw Error("Cannot update dragging the workspace because the start workspace is undefined");(this.flyout?this.flyout.isScrollable():this.startWorkspace_&&this.startWorkspace_.isDraggable())&&(this.dragging=!0,this.workspaceDragger=new ym(this.startWorkspace_),this.workspaceDragger.startDrag())}updateIsDragging(e){if(!this.startWorkspace_)throw Error("Cannot update dragging because the start workspace is undefined");if(this.calledUpdateIsDragging)throw Error("updateIsDragging_ should only be called once per gesture.");this.calledUpdateIsDragging=!0,this.flyout&&this.updateIsDraggingFromFlyout();const t=I();t&&ai(t)&&t.isMovable()?(this.dragging=!0,this.dragger=this.createDragger(t,this.startWorkspace_),this.dragger.onDragStart(e),this.dragger.onDrag(e,this.currentDragDeltaXY)):this.updateIsDraggingWorkspace()}createDragger(e,t){return new(W(M.BLOCK_DRAGGER,this.creatorWorkspace.options,!0))(e,t)}doStart(e){if(!this.startWorkspace_)throw Error("Cannot start the touch gesture becauase the start workspace is undefined");this.isPinchZoomEnabled=this.startWorkspace_.options.zoomOptions&&this.startWorkspace_.options.zoomOptions.pinch,Y(e)?this.cancel():(this.gestureHasStarted=!0,li(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.currentDropdownOwner=gc(),this.startWorkspace_.hideChaff(!!this.flyout),this.startWorkspace_.markFocused(),this.mostRecentEvent=e,Dc(),Ie(e)?this.handleRightClick(e):(e.type.toLowerCase()==="pointerdown"&&e.pointerType!=="mouse"&&X(e,this),this.mouseDownXY=new P(e.clientX,e.clientY),this.bindMouseEvents(e),this.isEnding_||this.handleTouchStart(e)))}bindMouseEvents(e){this.boundEvents.push(z(document,"pointerdown",null,this.handleStart.bind(this),!0)),this.boundEvents.push(z(document,"pointermove",null,this.handleMove.bind(this),!0)),this.boundEvents.push(z(document,"pointerup",null,this.handleUp.bind(this),!0)),e.preventDefault(),e.stopPropagation()}handleStart(e){this.isDragging()||(this.handleTouchStart(e),this.isMultiTouch()&&ue())}handleMove(e){this.isDragging()&&K(e)||!this.isMultiTouch()?(this.updateFromEvent(e),this.workspaceDragger?this.workspaceDragger.drag(this.currentDragDeltaXY):this.dragger&&this.dragger.onDrag(this.mostRecentEvent,this.currentDragDeltaXY),e.preventDefault(),e.stopPropagation()):this.isMultiTouch()&&(this.handleTouchMove(e),ue())}handleUp(e){if(this.isDragging()||this.handleTouchEnd(e),!this.isMultiTouch()||this.isDragging()){if(!K(e))return;if(this.updateFromEvent(e),ue(),this.isEnding_){console.log("Trying to end a gesture recursively.");return}this.isEnding_=!0,this.dragger?(gl.setIsActive(!1),this.dragger.onDragEnd(e,this.currentDragDeltaXY)):this.workspaceDragger?(gl.setIsActive(!1),this.workspaceDragger.endDrag(this.currentDragDeltaXY)):this.isBubbleClick()||this.isCommentClick()||(this.isFieldClick()?this.doFieldClick():this.isIconClick()?this.doIconClick():this.isBlockClick()?this.doBlockClick():this.isWorkspaceClick()&&this.doWorkspaceClick(e))}e.preventDefault(),e.stopPropagation(),this.dispose()}handleTouchStart(e){var t=ee(e);this.cachedPoints.set(t,this.getTouchPoint(e));var o=Array.from(this.cachedPoints.keys());o.length===2&&(t=this.cachedPoints.get(o[0]),o=this.cachedPoints.get(o[1]),this.startDistance=P.distance(t,o),this.multiTouch=!0,e.preventDefault())}handleTouchMove(e){const t=ee(e);this.cachedPoints.set(t,this.getTouchPoint(e)),this.isPinchZoomEnabled&&this.cachedPoints.size===2?this.handlePinch(e):(this.updateFromEvent(e),this.workspaceDragger?this.workspaceDragger.drag(this.currentDragDeltaXY):this.dragger&&this.dragger.onDrag(this.mostRecentEvent,this.currentDragDeltaXY),e.preventDefault(),e.stopPropagation())}handlePinch(e){var t=Array.from(this.cachedPoints.keys()),o=this.cachedPoints.get(t[0]);if(t=this.cachedPoints.get(t[1]),o=P.distance(o,t)/this.startDistance,this.previousScale>0&&this.previousScale<1/0){if(t=o-this.previousScale,t=t>0?t*wb:t*Ob,!this.startWorkspace_)throw Error("Cannot handle a pinch because the start workspace is undefined");const s=this.startWorkspace_,i=Ye(e,s.getParentSvg(),s.getInverseScreenCTM());s.zoom(i.x,i.y,t)}this.previousScale=o,e.preventDefault()}handleTouchEnd(e){e=ee(e),this.cachedPoints.has(e)&&this.cachedPoints.delete(e),this.cachedPoints.size<2&&(this.cachedPoints.clear(),this.previousScale=0)}getTouchPoint(e){return this.startWorkspace_?new P(e.pageX,e.pageY):null}isMultiTouch(){return this.multiTouch}cancel(){this.isEnding_||(ue(),this.dragger?this.dragger.onDragEnd(this.mostRecentEvent,this.currentDragDeltaXY):this.workspaceDragger&&this.workspaceDragger.endDrag(this.currentDragDeltaXY),this.dispose())}handleRightClick(e){this.targetBlock?(this.bringBlockToFront(),this.targetBlock.workspace.hideChaff(!!this.flyout),this.targetBlock.showContextMenu(e)):this.startBubble?this.startBubble.showContextMenu(e):this.startComment?(this.startComment.workspace.hideChaff(),this.startComment.showContextMenu(e)):this.startWorkspace_&&!this.flyout&&(this.startWorkspace_.hideChaff(),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.startWorkspace_),this.startWorkspace_.showContextMenu(e)),e.preventDefault(),e.stopPropagation(),gl.setIsActive(!1),this.dispose()}handleWsStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleWsStart, but the gesture had already been started.");this.setStartWorkspace(t),this.mostRecentEvent=e,this.startBlock||this.startBubble||this.startComment?this.startBlock&&r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.startBlock):r.getFocusManager$$module$build$src$core$focus_manager().focusNode(t),this.doStart(e)}fireWorkspaceClick(e){_(new(U(w.CLICK))(null,e.id,"workspace"))}handleFlyoutStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleFlyoutStart, but the gesture had already been started.");this.setStartFlyout(t),this.handleWsStart(e,t.getWorkspace())}handleBlockStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBlockStart, but the gesture had already been started.");this.setStartBlock(t),this.mostRecentEvent=e}handleBubbleStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBubbleStart, but the gesture had already been started.");this.setStartBubble(t),this.mostRecentEvent=e}handleCommentStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleCommentStart, but the gesture had already been started.");this.setStartComment(t),this.mostRecentEvent=e}doFieldClick(){if(!this.startField)throw Error("Cannot do a field click because the start field is undefined");this.bringBlockToFront(),this.currentDropdownOwner!==this.startField&&this.startField.showEditor(this.mostRecentEvent)}doIconClick(){if(!this.startIcon)throw Error("Cannot do an icon click because the start icon is undefined");this.bringBlockToFront(),this.startIcon.onClick()}doBlockClick(){if(this.flyout&&this.flyout.autoClose){if(!this.targetBlock)throw Error("Cannot do a block click because the target block is undefined");if(this.flyout.isBlockCreatable(this.targetBlock)){r.getGroup$$module$build$src$core$events$utils()||r.setGroup$$module$build$src$core$events$utils(!0);var e=this.flyout.createBlock(this.targetBlock);e.snapToGrid(),e.bumpNeighbours(),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(e)}}else{if(!this.startWorkspace_)throw Error("Cannot do a block click because the start workspace is undefined");e=new(U(w.CLICK))(this.startBlock,this.startWorkspace_.id,"block"),_(e)}this.bringBlockToFront(),r.setGroup$$module$build$src$core$events$utils(!1)}doWorkspaceClick(e){this.fireWorkspaceClick(this.startWorkspace_||this.creatorWorkspace)}bringBlockToFront(){this.targetBlock&&!this.flyout&&(r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.targetBlock),this.targetBlock.bringToFront())}setStartField(e){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartField, but the gesture had already been started.");this.startField||(this.startField=e)}setStartIcon(e){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartIcon, but the gesture had already been started.");this.startIcon||(this.startIcon=e)}setStartBubble(e){this.startBubble||(this.startBubble=e)}setStartComment(e){this.startComment||(this.startComment=e)}setStartBlock(e){this.startBlock||this.startBubble||(this.startBlock=e,e.isInFlyout&&e!==e.getRootBlock()?this.setTargetBlock(e.getRootBlock()):this.setTargetBlock(e))}setTargetBlock(e){e.isShadow()?this.setTargetBlock(e.getParent()):(this.targetBlock=e,r.getFocusManager$$module$build$src$core$focus_manager().focusNode(e))}setStartWorkspace(e){this.startWorkspace_||(this.startWorkspace_=e)}setStartFlyout(e){this.flyout||(this.flyout=e)}isBubbleClick(){return!!this.startBubble&&!this.hasExceededDragRadius}isCommentClick(){return!!this.startComment&&!this.hasExceededDragRadius}isBlockClick(){return!!this.startBlock&&!this.hasExceededDragRadius&&!this.isFieldClick()&&!this.isIconClick()}isFieldClick(){return this.startField?this.startField.isClickable()&&!this.hasExceededDragRadius&&(!this.flyout||this.startField.isClickableInFlyout(this.flyout.autoClose)):!1}isIconClick(){if(!this.startIcon)return!1;const e=!this.flyout||!this.startIcon.isClickableInFlyout||this.startIcon.isClickableInFlyout(this.flyout.autoClose);return!this.hasExceededDragRadius&&e}isWorkspaceClick(){return!this.startBlock&&!this.startBubble&&!this.startField&&!this.hasExceededDragRadius}getCurrentDragger(){let e,t;return(t=(e=this.workspaceDragger)!=null?e:this.dragger)!=null?t:null}isDragging(){return this.dragging}hasStarted(){return this.gestureHasStarted}static inProgress(){const e=kt();for(let t=0,o;o=e[t];t++)if(o.currentGesture_)return!0;return!1}},Ka=class{constructor(e,t){this.pattern=e,this.scale=1;let o;this.spacing=(o=t.spacing)!=null?o:0;let s;this.length=(s=t.length)!=null?s:1,this.line2=(this.line1=e.firstChild)&&this.line1.nextSibling;let i;this.snapToGrid=(i=t.snap)!=null?i:!1}setSpacing(e){this.spacing=e,this.update(this.scale)}getSpacing(){return this.spacing}setLength(e){this.length=e,this.update(this.scale)}getLength(){return this.length}setSnapToGrid(e){this.snapToGrid=e}shouldSnap(){return this.snapToGrid}getPatternId(){return this.pattern.id}update(e){this.scale=e;var t=this.spacing*e;this.pattern.setAttribute("width",`${t}`),this.pattern.setAttribute("height",`${t}`),t=Math.floor(this.spacing/2)+.5;let o=t-this.length/2,s=t+this.length/2;t*=e,o*=e,s*=e,this.setLineAttributes(this.line1,e,o,s,t,t),this.setLineAttributes(this.line2,e,t,t,o,s)}setLineAttributes(e,t,o,s,i,n){e&&(e.setAttribute("stroke-width",`${t}`),e.setAttribute("x1",`${o}`),e.setAttribute("y1",`${i}`),e.setAttribute("x2",`${s}`),e.setAttribute("y2",`${n}`))}moveTo(e,t){this.pattern.setAttribute("x",`${e}`),this.pattern.setAttribute("y",`${t}`)}alignXY(e){var t=this.getSpacing();const o=t/2,s=Math.round(Math.round((e.x-o)/t)*t+o);return t=Math.round(Math.round((e.y-o)/t)*t+o),s===e.x&&t===e.y?e:new P(s,t)}static createDom(e,t,o,s){e=v(R.PATTERN,{id:"blocklyGridPattern"+e,patternUnits:"userSpaceOnUse"},o);let i,n;if(((i=t.length)!=null?i:1)>0&&((n=t.spacing)!=null?n:0)>0){v(R.LINE,{stroke:t.colour},e);let d;(d=t.length)!=null&&d&&v(R.LINE,{stroke:t.colour},e)}else v(R.LINE,{},e);return s&&s.style.setProperty("--blocklyGridPattern",`url(#${e.id})`),e}},Nb=class{constructor(e){this.workspace=e,this.layers=new Map,(e=e.getInjectionDiv())&&(this.dragLayer=this.createDragLayer(e),this.animationLayer=this.createAnimationLayer(e)),e=this.createLayer(us),G(e,"blocklyBlockCanvas"),e=this.createLayer(sl),G(e,"blocklyBubbleCanvas")}createDragLayer(e){const t=v(R.SVG,{class:"blocklyBlockDragSurface",xmlns:or,"xmlns:html":To,"xmlns:xlink":Ht,version:"1.1"});return e.append(t),v(R.G,{},t)}createAnimationLayer(e){const t=v(R.SVG,{class:"blocklyAnimationLayer",xmlns:or,"xmlns:html":To,"xmlns:xlink":Ht,version:"1.1"});return e.append(t),v(R.G,{},t)}appendToAnimationLayer(e){let t;const o=(t=this.dragLayer)==null?void 0:t.getAttribute("transform");if(o){let i;(i=this.animationLayer)==null||i.setAttribute("transform",o)}let s;(s=this.animationLayer)==null||s.appendChild(e.getSvgRoot())}translateLayers(e,t){e=`translate(${e.x}, ${e.y}) scale(${t})`;let o;(o=this.dragLayer)==null||o.setAttribute("transform",e);for(const[,s]of this.layers)s.setAttribute("transform",e)}moveToDragLayer(e){let t;(t=this.dragLayer)==null||t.appendChild(e.getSvgRoot()),e.canBeFocused()&&r.getFocusManager$$module$build$src$core$focus_manager().focusNode(e)}moveOffDragLayer(e,t){this.append(e,t),e.canBeFocused()&&r.getFocusManager$$module$build$src$core$focus_manager().focusNode(e)}append(e,t){this.layers.has(t)||this.createLayer(t),e=e.getSvgRoot();let o;if(((o=this.layers.get(t))==null?void 0:o.lastChild)!==e){let s;(s=this.layers.get(t))==null||s.appendChild(e)}}createLayer(e){const t=this.workspace.getSvgGroup(),o=v(R.G,{});let s=!1;const i=[...this.layers].sort((n,d)=>n[0]-d[0]);for(const[n,d]of i)if(e<n){t.insertBefore(o,d),s=!0;break}return s||t.appendChild(o),this.layers.set(e,o),o}hasLayer(e){return e===this.dragLayer||new Set(this.layers.values()).has(e)}getBlockLayer(){return this.layers.get(us)}getBubbleLayer(){return this.layers.get(sl)}},vm=class{constructor(){this.curNode=this.colour=null,this.type="marker"}getCurNode(){return this.curNode}setCurNode(e){this.curNode=e}dispose(){this.curNode=null}getSourceBlockFromNode(e){return e instanceof Be?e:e instanceof we||e instanceof _t?e.getSourceBlock():null}getSourceBlock(){return this.getSourceBlockFromNode(this.getCurNode())}},Ja=class extends vm{constructor(e){super(),this.workspace=e,this.type="cursor",this.potentialNodes=null}next(){var e=this.getCurNode();return e?((e=this.getNextNode(e,t=>{let o;return t instanceof Be&&!((o=t.outputConnection)!=null&&o.targetBlock())||t instanceof yo},!0))&&this.setCurNode(e),e):null}in(){var e=this.getCurNode();return e?((e=this.getNextNode(e,()=>!0,!0))&&this.setCurNode(e),e):null}prev(){var e=this.getCurNode();return e?((e=this.getPreviousNode(e,t=>{let o;return t instanceof Be&&!((o=t.outputConnection)!=null&&o.targetBlock())||t instanceof yo},!0))&&this.setCurNode(e),e):null}out(){var e=this.getCurNode();return e?((e=this.getPreviousNode(e,()=>!0,!0))&&this.setCurNode(e),e):null}atEndOfLine(){var e=this.getCurNode();if(!e)return!1;const t=this.getNextNode(e,()=>!0,!0);return e=this.getNextNode(e,o=>{let s;return o instanceof Be&&!((s=o.outputConnection)!=null&&s.targetBlock())},!0),t===e}getNextNodeImpl(e,t,o=new Set){if(!e||o.has(e))return null;let s=this.workspace.getNavigator().getFirstChild(e)||this.workspace.getNavigator().getNextSibling(e);for(var i=e;i&&!s&&(i=this.workspace.getNavigator().getParent(i),!!i);)s=this.workspace.getNavigator().getNextSibling(i);return t(s)?s:s?(o.add(e),this.getNextNodeImpl(s,t,o)):null}getNextNode(e,t,o){return!e||!o&&this.getLastNode()===e?null:this.getNextNodeImpl(e,t)}getPreviousNodeImpl(e,t,o=new Set){if(!e||o.has(e))return null;const s=this.getRightMostChild(this.workspace.getNavigator().getPreviousSibling(e),e)||this.workspace.getNavigator().getParent(e);return t(s)?s:s?(o.add(e),this.getPreviousNodeImpl(s,t,o)):null}getPreviousNode(e,t,o){return!e||!o&&this.getFirstNode()===e?null:this.getPreviousNodeImpl(e,t)}getRightMostChild(e,t){if(!e)return e;let o=this.workspace.getNavigator().getFirstChild(e);if(!o||o===t)return e;for(e=o;e&&e!==t;e=this.workspace.getNavigator().getNextSibling(o))o=e;return this.getRightMostChild(o,t)}preDelete(e){var t=this.getCurNode();t=t?[t]:[];var o;let s,i;const n=(i=(o=e.previousConnection)==null?void 0:o.targetConnection)!=null?i:(s=e.outputConnection)==null?void 0:s.targetConnection;n&&t.push(n),(o=e.getNextBlock())&&t.push(o),(e=e.getParent())&&t.push(e),t.push(this.workspace),this.potentialNodes=t}postDelete(){const e=this.potentialNodes;if(this.potentialNodes=null,!e)throw Error("must call preDelete first");for(const t of e){let o;if((o=this.getSourceBlockFromNode(t))==null||!o.disposed){this.setCurNode(t);return}}throw Error("no valid nodes in this.potentialNodes")}getCurNode(){return r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode()}setCurNode(e){r.getFocusManager$$module$build$src$core$focus_manager().focusNode(e),e instanceof Be?e.workspace.scrollBoundsIntoView(e.getBoundingRectangleWithoutChildren()):e instanceof we?(e=e.getSourceBlock(),e.workspace.scrollBoundsIntoView(e.getBoundingRectangleWithoutChildren())):e instanceof yo&&e.workspace.scrollBoundsIntoView(e.getBoundingRectangle())}getFirstNode(){return this.workspace.getNavigator().getFirstChild(this.workspace)}getLastNode(){const e=this.getFirstNode();return this.getPreviousNode(e,()=>!0,!0)}};l(M.CURSOR,Ft,Ja);var qa=class{constructor(e){this.workspace=e,this.markers=new Map,this.cursor=new Ja(this.workspace)}registerMarker(e,t){this.markers.has(e)&&this.unregisterMarker(e),this.markers.set(e,t)}unregisterMarker(e){const t=this.markers.get(e);if(t)t.dispose(),this.markers.delete(e);else throw Error("Marker with ID "+e+" does not exist. Can only unregister markers that exist.")}getCursor(){return this.cursor}getMarker(e){return this.markers.get(e)||null}setCursor(e){this.cursor=e}dispose(){const e=Object.keys(this.markers);for(let t=0,o;o=e[t];t++)this.unregisterMarker(o);this.markers.clear(),this.cursor.dispose()}};qa.LOCAL_MARKER="local_marker_1";var Za=class extends Oe{constructor(e,t,o){super(e,t,o,Za.createTextArea()),this.workspace=e,this.anchor=t,this.ownerRect=o,this.resizePointerMoveListener=this.resizePointerUpListener=null,this.textChangeListeners=[],this.sizeChangeListeners=[],this.locationChangeListeners=[],this.text="",this.DEFAULT_SIZE=new ve(160+Oe.DOUBLE_BORDER,80+Oe.DOUBLE_BORDER),this.MIN_SIZE=new ve(45+Oe.DOUBLE_BORDER,20+Oe.DOUBLE_BORDER),this.editable=!0,G(this.svgRoot,"blocklyTextInputBubble"),this.textArea=this.getFocusableElement(),this.inputRoot=this.createEditor(this.contentContainer,this.textArea),this.resizeGroup=this.createResizeHandle(this.svgRoot,e),this.setSize(this.DEFAULT_SIZE,!0)}getText(){return this.text}setText(e){this.text=e,this.textArea.value=e,this.onTextChange()}setEditable(e){(this.editable=e)?this.textArea.removeAttribute("readonly"):this.textArea.setAttribute("readonly","")}isEditable(){return this.editable}addTextChangeListener(e){this.textChangeListeners.push(e)}addSizeChangeListener(e){this.sizeChangeListeners.push(e)}addLocationChangeListener(e){this.locationChangeListeners.push(e)}static createTextArea(){const e=document.createElementNS(To,"textarea");return e.className="blocklyTextarea blocklyText",e}createEditor(e,t){e=v(R.FOREIGNOBJECT,{x:Oe.BORDER_WIDTH,y:Oe.BORDER_WIDTH},e);const o=document.createElementNS(To,"body");return o.setAttribute("xmlns",To),o.className="blocklyMinimalBody",t.setAttribute("dir",this.workspace.RTL?"RTL":"LTR"),o.appendChild(t),e.appendChild(o),this.bindTextAreaEvents(t),e}bindTextAreaEvents(e){z(e,"wheel",this,t=>{t.stopPropagation()}),z(e,"pointerdown",this,t=>{t.stopPropagation(),ie()}),z(e,"change",this,this.onTextChange)}createResizeHandle(e,t){return e=v(R.IMAGE,{class:"blocklyResizeHandle",href:`${t.options.pathToMedia}resize-handle.svg`},e),z(e,"pointerdown",this,this.onResizePointerDown),e}setSize(e,t=!1){e.width=Math.max(e.width,this.MIN_SIZE.width),e.height=Math.max(e.height,this.MIN_SIZE.height);const o=e.width-Oe.DOUBLE_BORDER,s=e.height-Oe.DOUBLE_BORDER;this.inputRoot.setAttribute("width",`${o}`),this.inputRoot.setAttribute("height",`${s}`),this.resizeGroup.setAttribute("y",`${s}`),this.workspace.RTL?this.resizeGroup.setAttribute("x",`${-Oe.DOUBLE_BORDER}`):this.resizeGroup.setAttribute("x",`${o}`),super.setSize(e,t),this.onSizeChange()}getSize(){return super.getSize()}moveDuringDrag(e){super.moveDuringDrag(e),this.onLocationChange()}setPositionRelativeToAnchor(e,t){super.setPositionRelativeToAnchor(e,t),this.onLocationChange()}positionByRect(e=new ye(0,0,0,0)){super.positionByRect(e),this.onLocationChange()}onResizePointerDown(e){this.bringToFront(),Ie(e)||(dn(this.workspace,e,new P(this.workspace.RTL?-this.getSize().width:this.getSize().width,this.getSize().height)),this.resizePointerUpListener=z(document,"pointerup",this,this.onResizePointerUp),this.resizePointerMoveListener=z(document,"pointermove",this,this.onResizePointerMove),this.workspace.hideChaff()),e.stopPropagation()}onResizePointerUp(e){ie(),this.resizePointerUpListener&&(te(this.resizePointerUpListener),this.resizePointerUpListener=null),this.resizePointerMoveListener&&(te(this.resizePointerMoveListener),this.resizePointerMoveListener=null)}onResizePointerMove(e){e=$n(this.workspace,e),this.setSize(new ve(this.workspace.RTL?-e.x:e.x,e.y),!1),this.onSizeChange()}onTextChange(){this.text=this.textArea.value;for(const e of this.textChangeListeners)e()}onSizeChange(){for(const e of this.sizeChangeListeners)e()}onLocationChange(){for(const e of this.locationChangeListeners)e()}};q(`
644
+ `);var gm=class{getFirstChild(e){return null}getParent(e){return e.getWorkspace()}getNextSibling(e){return null}getPreviousSibling(e){return null}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof xt}},mm=class{constructor(e,t){this.policy=e,this.flyout=t}getFirstChild(e){return null}getParent(e){return this.policy.getParent(e)}getNextSibling(e){const t=this.flyout.getContents();if(!t)return null;let o=t.findIndex(s=>s.getElement()===e);return o===-1?null:(o++,o>=t.length&&(o=0),t[o].getElement())}getPreviousSibling(e){const t=this.flyout.getContents();if(!t)return null;let o=t.findIndex(s=>s.getElement()===e);return o===-1?null:(o--,o<0&&(o=t.length-1),t[o].getElement())}isNavigable(e){return this.policy.isNavigable(e)}isApplicable(e){return this.policy.isApplicable(e)}},pl=class{constructor(e,t){this.gap=e,this.axis=t,this.y=this.x=0}getBoundingRectangle(){switch(this.axis){case"x":return new ye(this.y,this.y,this.x,this.x+this.gap);case"y":return new ye(this.y,this.y+this.gap,this.x,this.x)}}moveBy(e,t,o){this.x+=e,this.y+=t}isNavigable(){return!1}getFocusableElement(){throw Error("Cannot be focused")}getFocusableTree(){throw Error("Cannot be focused")}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!1}},fm=class{getFirstChild(e){return null}getParent(e){return null}getNextSibling(e){return null}getPreviousSibling(e){return null}isNavigable(e){return!1}isApplicable(e){return e instanceof pl}},_m=class{getFirstChild(e){return du(e,!0)[0]}getParent(e){var t;if((t=e.previousConnection)!=null&&t.targetBlock()){if(t=e.getSurroundParent())return t}else{let o;if((o=e.outputConnection)!=null&&o.targetBlock())return e.outputConnection.targetBlock()}return e.workspace}getNextSibling(e){let t;if((t=e.nextConnection)!=null&&t.targetBlock()){let s;return(s=e.nextConnection)==null?void 0:s.targetBlock()}let o;return(o=e.outputConnection)!=null&&o.targetBlock()?ro(e,1):e.getSurroundParent()?ro(e.getTopStackBlock(),1):this.getParent(e)instanceof At?ui(e,1):null}getPreviousSibling(e){let t;if((t=e.previousConnection)!=null&&t.targetBlock()){let s;return(s=e.previousConnection)==null?void 0:s.targetBlock()}let o;return(o=e.outputConnection)!=null&&o.targetBlock()?ro(e,-1):this.getParent(e)instanceof At?ui(e,-1):null}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof Be}},wb=class{getFirstChild(e){return null}getParent(e){return e.getParentComment()}getNextSibling(e){const t=e.getParentComment().view.getCommentBarButtons();return e=t.indexOf(e),e>=0&&e+1<t.length?t[e+1]:null}getPreviousSibling(e){const t=e.getParentComment().view.getCommentBarButtons();return e=t.indexOf(e),e>0?t[e-1]:null}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof rl}},bm=class{getFirstChild(e){return e.getParentInput()?e.targetConnection:null}getParent(e){return e.getSourceBlock()}getNextSibling(e){if(e.getParentInput())return ro(e,1);if(e.type===Z.NEXT_STATEMENT){const o=e.targetConnection;var t=e.getSourceBlock();if(!o&&t.getRootBlock().lastConnectionInStack(!1)===e){e=t.workspace.getTopBlocks(!0),t=e.indexOf(t.getRootBlock())+1,t>=e.length&&(t=0),t=e[t];let s;return(s=this.getParentConnection(t))!=null?s:t}return o}return e.getSourceBlock()}getPreviousSibling(e){if(e.getParentInput())return ro(e,-1);if(e.type===Z.PREVIOUS_STATEMENT||e.type===Z.OUTPUT_VALUE){const o=e.targetConnection&&!e.targetConnection.getParentInput()?e.targetConnection:null;var t=e.getSourceBlock();if(!o&&this.getParentConnection(t.getRootBlock())===e){e=t.workspace.getTopBlocks(!0),t=e.indexOf(t.getRootBlock())-1,t<0&&(t=e.length-1),t=e[t];let s;return(s=t.lastConnectionInStack(!1))!=null?s:t}return o}return e.type===Z.NEXT_STATEMENT?e.getSourceBlock():null}getParentConnection(e){let t;return!e.outputConnection||(t=e.previousConnection)!=null&&t.isConnected()?e.previousConnection:e.outputConnection}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof _t}},Tm=class{getFirstChild(e){return null}getParent(e){return e.getSourceBlock()}getNextSibling(e){return ro(e,1)}getPreviousSibling(e){return ro(e,-1)}isNavigable(e){let t;return e.canBeFocused()&&e.isVisible()&&(e.isClickable()||e.isCurrentlyEditable())&&!((t=e.getSourceBlock())!=null&&t.isSimpleReporter()&&e.isFullBlockField())&&e.getParentInput().isVisible()}isApplicable(e){return e instanceof we}},Ob=class{getFirstChild(e){if(e instanceof r.MutatorIcon$$module$build$src$core$icons$mutator_icon&&e.bubbleIsVisible()&&r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode()===e){let t,o;return(o=(t=e.getBubble())==null?void 0:t.getWorkspace())!=null?o:null}return null}getParent(e){return e.getSourceBlock()}getNextSibling(e){return ro(e,1)}getPreviousSibling(e){return ro(e,-1)}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof br}},Nb=class{getFirstChild(e){return e.view.getCommentBarButtons()[0]}getParent(e){return e.workspace}getNextSibling(e){return ui(e,1)}getPreviousSibling(e){return ui(e,-1)}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof yo}},Em=class{getFirstChild(e){return e=e.getTopBlocks(!0),e.length?e[0]:null}getParent(e){return null}getNextSibling(e){return null}getPreviousSibling(e){return null}isNavigable(e){return e.canBeFocused()&&!e.isMutator}isApplicable(e){return e instanceof At}},Ka=class{constructor(){this.rules=[new _m,new Tm,new bm,new Em,new Ob,new Nb,new wb]}addNavigationPolicy(e){this.rules.push(e)}get(e){return this.rules.find(t=>t.isApplicable(e))}getFirstChild(e){let t;const o=(t=this.get(e))==null?void 0:t.getFirstChild(e);if(!o)return null;let s;return(s=this.get(o))!=null&&s.isNavigable(o)?o:this.getFirstChild(o)||this.getNextSibling(o)}getParent(e){let t;const o=(t=this.get(e))==null?void 0:t.getParent(e);if(!o)return null;let s;return(s=this.get(o))!=null&&s.isNavigable(o)?o:this.getParent(o)}getNextSibling(e){let t;const o=(t=this.get(e))==null?void 0:t.getNextSibling(e);if(!o)return null;let s;return(s=this.get(o))!=null&&s.isNavigable(o)?o:this.getNextSibling(o)}getPreviousSibling(e){let t;const o=(t=this.get(e))==null?void 0:t.getPreviousSibling(e);if(!o)return null;let s;return(s=this.get(o))!=null&&s.isNavigable(o)?o:this.getPreviousSibling(o)}},ym=class extends Ka{constructor(e){super(),this.rules.push(new gm,new fm),this.rules=this.rules.map(t=>new mm(t,e))}},Ja=class{constructor(e,t,o,s,i){this.workspace=e,this.oldHostMetrics=this.corner_=this.vScroll=this.hScroll=null,t=t===void 0?!0:t,o=o===void 0?!0:o;const n=t&&o;t&&(this.hScroll=new Ze(e,!0,n,s,i)),o&&(this.vScroll=new Ze(e,!1,n,s,i)),n&&(this.corner_=v(R.RECT,{height:Ze.scrollbarThickness,width:Ze.scrollbarThickness,class:"blocklyScrollbarBackground"}),Qt(this.corner_,e.getBubbleCanvas()))}dispose(){ke(this.corner_),this.oldHostMetrics=this.corner_=null,this.hScroll&&(this.hScroll.dispose(),this.hScroll=null),this.vScroll&&(this.vScroll.dispose(),this.vScroll=null)}resize(){const e=this.workspace.getMetrics();if(e){var t=!1,o=!1;if(this.oldHostMetrics&&this.oldHostMetrics.viewWidth===e.viewWidth&&this.oldHostMetrics.viewHeight===e.viewHeight&&this.oldHostMetrics.absoluteTop===e.absoluteTop&&this.oldHostMetrics.absoluteLeft===e.absoluteLeft?(this.oldHostMetrics&&this.oldHostMetrics.scrollWidth===e.scrollWidth&&this.oldHostMetrics.viewLeft===e.viewLeft&&this.oldHostMetrics.scrollLeft===e.scrollLeft||(t=!0),this.oldHostMetrics&&this.oldHostMetrics.scrollHeight===e.scrollHeight&&this.oldHostMetrics.viewTop===e.viewTop&&this.oldHostMetrics.scrollTop===e.scrollTop||(o=!0)):o=t=!0,t||o){try{r.disable$$module$build$src$core$events$utils(),this.hScroll&&t&&this.hScroll.resize(e),this.vScroll&&o&&this.vScroll.resize(e)}finally{r.enable$$module$build$src$core$events$utils()}this.workspace.maybeFireViewportChangeEvent()}if(this.hScroll&&this.vScroll){if(!this.oldHostMetrics||this.oldHostMetrics.viewWidth!==e.viewWidth||this.oldHostMetrics.absoluteLeft!==e.absoluteLeft){let s;(s=this.corner_)==null||s.setAttribute("x",String(this.vScroll.position.x))}if(!this.oldHostMetrics||this.oldHostMetrics.viewHeight!==e.viewHeight||this.oldHostMetrics.absoluteTop!==e.absoluteTop){let s;(s=this.corner_)==null||s.setAttribute("y",String(this.hScroll.position.y))}}this.oldHostMetrics=e}}canScrollHorizontally(){return!!this.hScroll}canScrollVertically(){return!!this.vScroll}setOrigin(e,t){this.hScroll&&this.hScroll.setOrigin(e,t),this.vScroll&&this.vScroll.setOrigin(e,t)}set(e,t,o){this.hScroll&&this.hScroll.set(e,!1),this.vScroll&&this.vScroll.set(t,!1),(o||o===void 0)&&(e={},this.hScroll&&(e.x=this.hScroll.getRatio_()),this.vScroll&&(e.y=this.vScroll.getRatio_()),this.workspace.setMetrics(e))}setX(e){this.hScroll&&this.hScroll.set(e,!0)}setY(e){this.vScroll&&this.vScroll.set(e,!0)}setContainerVisible(e){this.hScroll&&this.hScroll.setContainerVisible(e),this.vScroll&&this.vScroll.setContainerVisible(e)}isVisible(){let e=!1;return this.hScroll&&(e=this.hScroll.isVisible()),this.vScroll&&(e=e||this.vScroll.isVisible()),e}setVisible(e){this.hScroll&&this.hScroll.setVisibleInternal(e),this.vScroll&&this.vScroll.setVisibleInternal(e)}resizeContent(e){this.hScroll&&this.hScroll.resizeContentHorizontal(e),this.vScroll&&this.vScroll.resizeContentVertical(e)}resizeView(e){this.hScroll&&this.hScroll.resizeViewHorizontal(e),this.vScroll&&this.vScroll.resizeViewVertical(e)}},Si="sep",vm=class{load(e,t){return e=new pl(0,t.horizontalLayout?"x":"y"),new Ci(e,Si)}gapForItem(e,t){let o;return(o=parseInt(String(e.gap)))!=null?o:t}disposeItem(e){}getType(){return Si}};l(M.FLYOUT_INFLATER,Si,vm);var gl=class extends $l{constructor(e){super(),this.horizontalLayout=!1,this.boundEvents=[],this.reflowWrapper=null,this.contents=[],this.autoClose=!0,this.visible=!1,this.containerVisible=!0,this.CORNER_RADIUS=8,this.SCROLLBAR_MARGIN=2.5,this.height_=this.width_=0,this.dragAngleRange_=70,this.svgGroup_=this.svgBackground_=null,this.inflaters=new Map,e.setMetrics=this.setMetrics_.bind(this),this.workspace_=new At(e),this.workspace_.setMetricsManager(new pm(this.workspace_,this)),this.workspace_.internalIsFlyout=!0,this.workspace_.setVisible(this.visible),this.workspace_.setNavigator(new ym(this)),this.id=rt(),this.RTL=!!e.RTL,this.toolboxPosition_=e.toolboxPosition,this.tabWidth_=this.workspace_.getRenderer().getConstants().TAB_WIDTH,this.MARGIN=this.CORNER_RADIUS,this.GAP_X=this.MARGIN*3,this.GAP_Y=this.MARGIN*3}createDom(e){return this.svgGroup_=v(e,{class:"blocklyFlyout"}),this.svgGroup_.style.display="none",this.svgBackground_=v(R.PATH,{class:"blocklyFlyoutBackground"},this.svgGroup_),this.svgGroup_.appendChild(this.workspace_.createDom()),this.workspace_.getThemeManager().subscribe(this.svgBackground_,"flyoutBackgroundColour","fill"),this.workspace_.getThemeManager().subscribe(this.svgBackground_,"flyoutOpacity","fill-opacity"),this.svgGroup_}init(e){this.targetWorkspace=e,this.workspace_.targetWorkspace=e,this.workspace_.scrollbar=new Ja(this.workspace_,this.horizontalLayout,!this.horizontalLayout,"blocklyFlyoutScrollbar",this.SCROLLBAR_MARGIN),this.hide(),this.boundEvents.push(z(this.svgGroup_,"wheel",this,this.wheel_)),this.boundEvents.push(z(this.svgBackground_,"pointerdown",this,this.onMouseDown)),this.workspace_.getGesture=this.targetWorkspace.getGesture.bind(this.targetWorkspace),this.workspace_.setVariableMap(this.targetWorkspace.getVariableMap()),this.workspace_.createPotentialVariableMap(),e.getComponentManager().addComponent({component:this,weight:Ve.ComponentWeight.FLYOUT_WEIGHT,capabilities:[Ve.Capability.AUTOHIDEABLE,Ve.Capability.DELETE_AREA,Ve.Capability.DRAG_TARGET]})}dispose(){this.hide(),this.targetWorkspace.getComponentManager().removeComponent(this.id);for(const e of this.boundEvents)te(e);this.boundEvents.length=0,this.workspace_&&(this.workspace_.getThemeManager().unsubscribe(this.svgBackground_),this.workspace_.dispose()),this.svgGroup_&&ke(this.svgGroup_)}getWidth(){return this.width_}getHeight(){return this.height_}getFlyoutScale(){return this.targetWorkspace.scale}getWorkspace(){return this.workspace_}setAutoClose(e){this.autoClose=e,this.targetWorkspace.recordDragTargets(),this.targetWorkspace.resizeContents()}autoHide(e){!e&&this.targetWorkspace.getFlyout(!0)===this&&this.autoClose&&this.hide()}getTargetWorkspace(){return this.targetWorkspace}isVisible(){return this.visible}setVisible(e){const t=e!==this.isVisible();this.visible=e,t&&(this.autoClose||this.targetWorkspace.recordDragTargets(),this.updateDisplay())}setContainerVisible(e){const t=e!==this.containerVisible;this.containerVisible=e,t&&this.updateDisplay()}getContents(){return this.contents}setContents(e){this.contents=e}updateDisplay(){let e;e=this.containerVisible?this.isVisible():!1,this.svgGroup_&&(this.svgGroup_.style.display=e?"block":"none");let t;(t=this.workspace_.scrollbar)==null||t.setContainerVisible(e)}positionAt_(e,t,o,s){let i;(i=this.svgGroup_)==null||i.setAttribute("width",`${e}`);let n;(n=this.svgGroup_)==null||n.setAttribute("height",`${t}`),this.workspace_.setCachedParentSvgSize(e,t),this.svgGroup_&&Mo(this.svgGroup_,"translate("+o+"px,"+s+"px)"),(e=this.workspace_.scrollbar)&&(e.setOrigin(o,s),e.resize(),e.hScroll&&e.hScroll.setPosition(e.hScroll.position.x,e.hScroll.position.y),e.vScroll&&e.vScroll.setPosition(e.vScroll.position.x,e.vScroll.position.y))}hide(){this.isVisible()&&(this.setVisible(!1),this.reflowWrapper&&(this.workspace_.removeChangeListener(this.reflowWrapper),this.reflowWrapper=null))}show(e){this.workspace_.setResizesEnabled(!1),this.hide(),this.clearOldBlocks(),typeof e=="string"&&(e=this.getDynamicCategoryContents(e)),this.setVisible(!0),e=Pi(e),e=this.createFlyoutInfo(e),Qo(this.workspace_),this.setContents(e),this.layout_(e),this.horizontalLayout?this.height_=0:this.width_=0,this.reflow(),this.workspace_.setResizesEnabled(!0),this.reflowWrapper=t=>{t.type!==w.BLOCK_CHANGE&&t.type!==w.BLOCK_FIELD_INTERMEDIATE_CHANGE||this.reflow()},this.workspace_.addChangeListener(this.reflowWrapper)}createFlyoutInfo(e){const t=[],o=this.horizontalLayout?this.GAP_X:this.GAP_Y;for(const s of e)"custom"in s&&(e=this.getDynamicCategoryContents(s.custom),e=Pi(e),t.push(...this.createFlyoutInfo(e))),e=s.kind.toLowerCase(),(e=this.getInflaterForType(e))&&(t.push(e.load(s,this)),(e=e.gapForItem(s,o))&&t.push(new Ci(new pl(e,this.horizontalLayout?"x":"y"),Si)));return this.normalizeSeparators(t)}normalizeSeparators(e){for(let t=e.length-1;t>0;t--){const o=e[t].getType().toLowerCase(),s=e[t-1].getType().toLowerCase();o===Si&&s===Si&&e.splice(t-1,1)}return e}getDynamicCategoryContents(e){if(e=this.workspace_.targetWorkspace.getToolboxCategoryCallback(e),typeof e!="function")throw TypeError("Couldn't find a callback function when opening a toolbox category.");return e(this.workspace_.targetWorkspace)}clearOldBlocks(){this.getContents().forEach(t=>{let o;(o=this.getInflaterForType(t.getType()))==null||o.disposeItem(t)});let e;(e=this.workspace_.getPotentialVariableMap())==null||e.clear()}onMouseDown(e){const t=this.targetWorkspace.getGesture(e);t&&t.handleFlyoutStart(e,this)}isBlockCreatable(e){return e.isEnabled()&&!this.getTargetWorkspace().isReadOnly()}createBlock(e){let t=null;r.disable$$module$build$src$core$events$utils();var o=this.targetWorkspace.getAllVariables();this.targetWorkspace.setResizesEnabled(!1);try{t=this.placeNewBlock(e)}finally{r.enable$$module$build$src$core$events$utils()}if(this.targetWorkspace.hideChaff(),e=Vi(this.targetWorkspace,o),J()){for(r.setGroup$$module$build$src$core$events$utils(!0),o=0;o<e.length;o++){const s=e[o];_(new(U(w.VAR_CREATE))(s))}_(new(U(w.BLOCK_CREATE))(t))}return this.autoClose&&this.hide(),t}reflow(){this.reflowWrapper&&this.workspace_.removeChangeListener(this.reflowWrapper),this.reflowInternal_(),this.reflowWrapper&&this.workspace_.addChangeListener(this.reflowWrapper)}isScrollable(){return this.workspace_.scrollbar?this.workspace_.scrollbar.isVisible():!1}placeNewBlock(e){var t=this.targetWorkspace;if(!e.getSvgRoot())throw Error("oldBlock is not rendered");const o=this.serializeBlock(e);return t.setResizesEnabled(!1),t=es(o,t),this.positionNewBlock(e,t),t}serializeBlock(e){return jt(e)}positionNewBlock(e,t){const o=this.targetWorkspace;var s=o.getOriginOffsetInPixels(),i=this.workspace_.getOriginOffsetInPixels();e=e.getRelativeToSurfaceXY(),e.scale(this.workspace_.scale),i=P.sum(i,e),s=P.difference(i,s),s.scale(1/o.scale),t.moveTo(new P(s.x,s.y))}getInflaterForType(e){if(this.inflaters.has(e)){var t;return(t=this.inflaters.get(e))!=null?t:null}return(t=A(M.FLYOUT_INFLATER,e))?(t=new t,this.inflaters.set(e,t),t):null}getFocusableElement(){throw Error("Flyouts are not directly focusable.")}getFocusableTree(){throw Error("Flyouts are not directly focusable.")}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!1}getRootFocusableNode(){throw Error("Flyouts are not directly focusable.")}getRestoredFocusableNode(e){throw Error("Flyouts are not directly focusable.")}getNestedTrees(){throw Error("Flyouts are not directly focusable.")}lookUpFocusableNode(e){throw Error("Flyouts are not directly focusable.")}onTreeFocus(e,t){}onTreeBlur(e){throw Error("Flyouts are not directly focusable.")}},Im=class{constructor(){this.isActive=!1,this.activeClassName="blocklyKeyboardNavigation"}setIsActive(e=!0){this.isActive=e,this.updateActiveVisualization()}getIsActive(){return this.isActive}updateActiveVisualization(){this.isActive?document.body.classList.add(this.activeClassName):document.body.classList.remove(this.activeClassName)}},ml=new Im,Cm=class{constructor(e){this.workspace=e,this.horizontalScrollEnabled=this.workspace.isMovableHorizontally(),this.verticalScrollEnabled=this.workspace.isMovableVertically(),this.startScrollXY_=new P(e.scrollX,e.scrollY)}dispose(){this.workspace=null}startDrag(){}endDrag(e){this.drag(e)}drag(e){if(e=P.sum(this.startScrollXY_,e),this.horizontalScrollEnabled&&this.verticalScrollEnabled)this.workspace.scroll(e.x,e.y);else if(this.horizontalScrollEnabled)this.workspace.scroll(e.x,this.workspace.scrollY);else if(this.verticalScrollEnabled)this.workspace.scroll(this.workspace.scrollX,e.y);else throw new TypeError("Invalid state.")}},Ab=5,Lb=6,fl=class{constructor(e,t){this.creatorWorkspace=t,this.mouseDownXY=new P(0,0),this.startWorkspace_=this.targetBlock=this.startComment=this.startBlock=this.startIcon=this.startField=this.startBubble=null,this.hasExceededDragRadius=!1,this.boundEvents=[],this.workspaceDragger=this.dragger=null,this.dragging=!1,this.flyout=null,this.multiTouch=this.isEnding_=this.gestureHasStarted=this.calledUpdateIsDragging=!1,this.cachedPoints=new Map,this.startDistance=this.previousScale=0,this.currentDropdownOwner=this.isPinchZoomEnabled=null,this.mostRecentEvent=e,this.currentDragDeltaXY=new P(0,0)}dispose(){ie(),Pc(),this.creatorWorkspace.clearGesture();for(const e of this.boundEvents)te(e);this.boundEvents.length=0,this.workspaceDragger&&this.workspaceDragger.dispose()}updateFromEvent(e){const t=new P(e.clientX,e.clientY);this.updateDragDelta(t)&&(this.updateIsDragging(e),ue()),this.mostRecentEvent=e}updateDragDelta(e){return this.currentDragDeltaXY=P.difference(e,this.mouseDownXY),this.hasExceededDragRadius?!1:this.hasExceededDragRadius=P.magnitude(this.currentDragDeltaXY)>(this.flyout?r.config$$module$build$src$core$config.flyoutDragRadius:r.config$$module$build$src$core$config.dragRadius)}updateIsDraggingFromFlyout(){let e;if(!this.targetBlock||(e=this.flyout)==null||!e.isBlockCreatable(this.targetBlock))return!1;if(!this.flyout.targetWorkspace)throw Error(`Cannot update dragging from the flyout because the ' +
645
+ 'flyout's target workspace is undefined`);return!this.flyout.isScrollable()||this.flyout.isDragTowardWorkspace(this.currentDragDeltaXY)?(this.startWorkspace_=this.flyout.targetWorkspace,this.startWorkspace_.updateScreenCalculationsIfScrolled(),r.getGroup$$module$build$src$core$events$utils()||r.setGroup$$module$build$src$core$events$utils(!0),this.startBlock=null,this.targetBlock=this.flyout.createBlock(this.targetBlock),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.targetBlock),!0):!1}updateIsDraggingWorkspace(){if(!this.startWorkspace_)throw Error("Cannot update dragging the workspace because the start workspace is undefined");(this.flyout?this.flyout.isScrollable():this.startWorkspace_&&this.startWorkspace_.isDraggable())&&(this.dragging=!0,this.workspaceDragger=new Cm(this.startWorkspace_),this.workspaceDragger.startDrag())}updateIsDragging(e){if(!this.startWorkspace_)throw Error("Cannot update dragging because the start workspace is undefined");if(this.calledUpdateIsDragging)throw Error("updateIsDragging_ should only be called once per gesture.");this.calledUpdateIsDragging=!0,this.flyout&&this.updateIsDraggingFromFlyout();const t=I();t&&ai(t)&&t.isMovable()?(this.dragging=!0,this.dragger=this.createDragger(t,this.startWorkspace_),this.dragger.onDragStart(e),this.dragger.onDrag(e,this.currentDragDeltaXY)):this.updateIsDraggingWorkspace()}createDragger(e,t){return new(W(M.BLOCK_DRAGGER,this.creatorWorkspace.options,!0))(e,t)}doStart(e){if(!this.startWorkspace_)throw Error("Cannot start the touch gesture becauase the start workspace is undefined");this.isPinchZoomEnabled=this.startWorkspace_.options.zoomOptions&&this.startWorkspace_.options.zoomOptions.pinch,Y(e)?this.cancel():(this.gestureHasStarted=!0,li(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.currentDropdownOwner=fc(),this.startWorkspace_.hideChaff(!!this.flyout),this.startWorkspace_.markFocused(),this.mostRecentEvent=e,Bc(),Ie(e)?this.handleRightClick(e):(e.type.toLowerCase()==="pointerdown"&&e.pointerType!=="mouse"&&X(e,this),this.mouseDownXY=new P(e.clientX,e.clientY),this.bindMouseEvents(e),this.isEnding_||this.handleTouchStart(e)))}bindMouseEvents(e){this.boundEvents.push(z(document,"pointerdown",null,this.handleStart.bind(this),!0)),this.boundEvents.push(z(document,"pointermove",null,this.handleMove.bind(this),!0)),this.boundEvents.push(z(document,"pointerup",null,this.handleUp.bind(this),!0)),e.preventDefault(),e.stopPropagation()}handleStart(e){this.isDragging()||(this.handleTouchStart(e),this.isMultiTouch()&&ue())}handleMove(e){this.isDragging()&&K(e)||!this.isMultiTouch()?(this.updateFromEvent(e),this.workspaceDragger?this.workspaceDragger.drag(this.currentDragDeltaXY):this.dragger&&this.dragger.onDrag(this.mostRecentEvent,this.currentDragDeltaXY),e.preventDefault(),e.stopPropagation()):this.isMultiTouch()&&(this.handleTouchMove(e),ue())}handleUp(e){if(this.isDragging()||this.handleTouchEnd(e),!this.isMultiTouch()||this.isDragging()){if(!K(e))return;if(this.updateFromEvent(e),ue(),this.isEnding_){console.log("Trying to end a gesture recursively.");return}this.isEnding_=!0,this.dragger?(ml.setIsActive(!1),this.dragger.onDragEnd(e,this.currentDragDeltaXY)):this.workspaceDragger?(ml.setIsActive(!1),this.workspaceDragger.endDrag(this.currentDragDeltaXY)):this.isBubbleClick()||this.isCommentClick()||(this.isFieldClick()?this.doFieldClick():this.isIconClick()?this.doIconClick():this.isBlockClick()?this.doBlockClick():this.isWorkspaceClick()&&this.doWorkspaceClick(e))}e.preventDefault(),e.stopPropagation(),this.dispose()}handleTouchStart(e){var t=ee(e);this.cachedPoints.set(t,this.getTouchPoint(e));var o=Array.from(this.cachedPoints.keys());o.length===2&&(t=this.cachedPoints.get(o[0]),o=this.cachedPoints.get(o[1]),this.startDistance=P.distance(t,o),this.multiTouch=!0,e.preventDefault())}handleTouchMove(e){const t=ee(e);this.cachedPoints.set(t,this.getTouchPoint(e)),this.isPinchZoomEnabled&&this.cachedPoints.size===2?this.handlePinch(e):(this.updateFromEvent(e),this.workspaceDragger?this.workspaceDragger.drag(this.currentDragDeltaXY):this.dragger&&this.dragger.onDrag(this.mostRecentEvent,this.currentDragDeltaXY),e.preventDefault(),e.stopPropagation())}handlePinch(e){var t=Array.from(this.cachedPoints.keys()),o=this.cachedPoints.get(t[0]);if(t=this.cachedPoints.get(t[1]),o=P.distance(o,t)/this.startDistance,this.previousScale>0&&this.previousScale<1/0){if(t=o-this.previousScale,t=t>0?t*Ab:t*Lb,!this.startWorkspace_)throw Error("Cannot handle a pinch because the start workspace is undefined");const s=this.startWorkspace_,i=Ye(e,s.getParentSvg(),s.getInverseScreenCTM());s.zoom(i.x,i.y,t)}this.previousScale=o,e.preventDefault()}handleTouchEnd(e){e=ee(e),this.cachedPoints.has(e)&&this.cachedPoints.delete(e),this.cachedPoints.size<2&&(this.cachedPoints.clear(),this.previousScale=0)}getTouchPoint(e){return this.startWorkspace_?new P(e.pageX,e.pageY):null}isMultiTouch(){return this.multiTouch}cancel(){this.isEnding_||(ue(),this.dragger?this.dragger.onDragEnd(this.mostRecentEvent,this.currentDragDeltaXY):this.workspaceDragger&&this.workspaceDragger.endDrag(this.currentDragDeltaXY),this.dispose())}handleRightClick(e){this.targetBlock?(this.bringBlockToFront(),this.targetBlock.workspace.hideChaff(!!this.flyout),this.targetBlock.showContextMenu(e)):this.startBubble?this.startBubble.showContextMenu(e):this.startComment?(this.startComment.workspace.hideChaff(),this.startComment.showContextMenu(e)):this.startWorkspace_&&!this.flyout&&(this.startWorkspace_.hideChaff(),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.startWorkspace_),this.startWorkspace_.showContextMenu(e)),e.preventDefault(),e.stopPropagation(),ml.setIsActive(!1),this.dispose()}handleWsStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleWsStart, but the gesture had already been started.");this.setStartWorkspace(t),this.mostRecentEvent=e,this.startBlock||this.startBubble||this.startComment?this.startBlock&&r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.startBlock):r.getFocusManager$$module$build$src$core$focus_manager().focusNode(t),this.doStart(e)}fireWorkspaceClick(e){_(new(U(w.CLICK))(null,e.id,"workspace"))}handleFlyoutStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleFlyoutStart, but the gesture had already been started.");this.setStartFlyout(t),this.handleWsStart(e,t.getWorkspace())}handleBlockStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBlockStart, but the gesture had already been started.");this.setStartBlock(t),this.mostRecentEvent=e}handleBubbleStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBubbleStart, but the gesture had already been started.");this.setStartBubble(t),this.mostRecentEvent=e}handleCommentStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleCommentStart, but the gesture had already been started.");this.setStartComment(t),this.mostRecentEvent=e}doFieldClick(){if(!this.startField)throw Error("Cannot do a field click because the start field is undefined");this.bringBlockToFront(),this.currentDropdownOwner!==this.startField&&this.startField.showEditor(this.mostRecentEvent)}doIconClick(){if(!this.startIcon)throw Error("Cannot do an icon click because the start icon is undefined");this.bringBlockToFront(),this.startIcon.onClick()}doBlockClick(){if(this.flyout&&this.flyout.autoClose){if(!this.targetBlock)throw Error("Cannot do a block click because the target block is undefined");if(this.flyout.isBlockCreatable(this.targetBlock)){r.getGroup$$module$build$src$core$events$utils()||r.setGroup$$module$build$src$core$events$utils(!0);var e=this.flyout.createBlock(this.targetBlock);e.snapToGrid(),e.bumpNeighbours(),r.getFocusManager$$module$build$src$core$focus_manager().focusNode(e)}}else{if(!this.startWorkspace_)throw Error("Cannot do a block click because the start workspace is undefined");e=new(U(w.CLICK))(this.startBlock,this.startWorkspace_.id,"block"),_(e)}this.bringBlockToFront(),r.setGroup$$module$build$src$core$events$utils(!1)}doWorkspaceClick(e){this.fireWorkspaceClick(this.startWorkspace_||this.creatorWorkspace)}bringBlockToFront(){this.targetBlock&&!this.flyout&&(r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.targetBlock),this.targetBlock.bringToFront())}setStartField(e){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartField, but the gesture had already been started.");this.startField||(this.startField=e)}setStartIcon(e){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartIcon, but the gesture had already been started.");this.startIcon||(this.startIcon=e)}setStartBubble(e){this.startBubble||(this.startBubble=e)}setStartComment(e){this.startComment||(this.startComment=e)}setStartBlock(e){this.startBlock||this.startBubble||(this.startBlock=e,e.isInFlyout&&e!==e.getRootBlock()?this.setTargetBlock(e.getRootBlock()):this.setTargetBlock(e))}setTargetBlock(e){e.isShadow()?this.setTargetBlock(e.getParent()):(this.targetBlock=e,r.getFocusManager$$module$build$src$core$focus_manager().focusNode(e))}setStartWorkspace(e){this.startWorkspace_||(this.startWorkspace_=e)}setStartFlyout(e){this.flyout||(this.flyout=e)}isBubbleClick(){return!!this.startBubble&&!this.hasExceededDragRadius}isCommentClick(){return!!this.startComment&&!this.hasExceededDragRadius}isBlockClick(){return!!this.startBlock&&!this.hasExceededDragRadius&&!this.isFieldClick()&&!this.isIconClick()}isFieldClick(){return this.startField?this.startField.isClickable()&&!this.hasExceededDragRadius&&(!this.flyout||this.startField.isClickableInFlyout(this.flyout.autoClose)):!1}isIconClick(){if(!this.startIcon)return!1;const e=!this.flyout||!this.startIcon.isClickableInFlyout||this.startIcon.isClickableInFlyout(this.flyout.autoClose);return!this.hasExceededDragRadius&&e}isWorkspaceClick(){return!this.startBlock&&!this.startBubble&&!this.startField&&!this.hasExceededDragRadius}getCurrentDragger(){let e,t;return(t=(e=this.workspaceDragger)!=null?e:this.dragger)!=null?t:null}isDragging(){return this.dragging}hasStarted(){return this.gestureHasStarted}static inProgress(){const e=kt();for(let t=0,o;o=e[t];t++)if(o.currentGesture_)return!0;return!1}},qa=class{constructor(e,t){this.pattern=e,this.scale=1;let o;this.spacing=(o=t.spacing)!=null?o:0;let s;this.length=(s=t.length)!=null?s:1,this.line2=(this.line1=e.firstChild)&&this.line1.nextSibling;let i;this.snapToGrid=(i=t.snap)!=null?i:!1}setSpacing(e){this.spacing=e,this.update(this.scale)}getSpacing(){return this.spacing}setLength(e){this.length=e,this.update(this.scale)}getLength(){return this.length}setSnapToGrid(e){this.snapToGrid=e}shouldSnap(){return this.snapToGrid}getPatternId(){return this.pattern.id}update(e){this.scale=e;var t=this.spacing*e;this.pattern.setAttribute("width",`${t}`),this.pattern.setAttribute("height",`${t}`),t=Math.floor(this.spacing/2)+.5;let o=t-this.length/2,s=t+this.length/2;t*=e,o*=e,s*=e,this.setLineAttributes(this.line1,e,o,s,t,t),this.setLineAttributes(this.line2,e,t,t,o,s)}setLineAttributes(e,t,o,s,i,n){e&&(e.setAttribute("stroke-width",`${t}`),e.setAttribute("x1",`${o}`),e.setAttribute("y1",`${i}`),e.setAttribute("x2",`${s}`),e.setAttribute("y2",`${n}`))}moveTo(e,t){this.pattern.setAttribute("x",`${e}`),this.pattern.setAttribute("y",`${t}`)}alignXY(e){var t=this.getSpacing();const o=t/2,s=Math.round(Math.round((e.x-o)/t)*t+o);return t=Math.round(Math.round((e.y-o)/t)*t+o),s===e.x&&t===e.y?e:new P(s,t)}static createDom(e,t,o,s){e=v(R.PATTERN,{id:"blocklyGridPattern"+e,patternUnits:"userSpaceOnUse"},o);let i,n;if(((i=t.length)!=null?i:1)>0&&((n=t.spacing)!=null?n:0)>0){v(R.LINE,{stroke:t.colour},e);let d;(d=t.length)!=null&&d&&v(R.LINE,{stroke:t.colour},e)}else v(R.LINE,{},e);return s&&s.style.setProperty("--blocklyGridPattern",`url(#${e.id})`),e}},Mb=class{constructor(e){this.workspace=e,this.layers=new Map,(e=e.getInjectionDiv())&&(this.dragLayer=this.createDragLayer(e),this.animationLayer=this.createAnimationLayer(e)),e=this.createLayer(us),G(e,"blocklyBlockCanvas"),e=this.createLayer(il),G(e,"blocklyBubbleCanvas")}createDragLayer(e){const t=v(R.SVG,{class:"blocklyBlockDragSurface",xmlns:sr,"xmlns:html":To,"xmlns:xlink":Ht,version:"1.1"});return e.append(t),v(R.G,{},t)}createAnimationLayer(e){const t=v(R.SVG,{class:"blocklyAnimationLayer",xmlns:sr,"xmlns:html":To,"xmlns:xlink":Ht,version:"1.1"});return e.append(t),v(R.G,{},t)}appendToAnimationLayer(e){let t;const o=(t=this.dragLayer)==null?void 0:t.getAttribute("transform");if(o){let i;(i=this.animationLayer)==null||i.setAttribute("transform",o)}let s;(s=this.animationLayer)==null||s.appendChild(e.getSvgRoot())}translateLayers(e,t){e=`translate(${e.x}, ${e.y}) scale(${t})`;let o;(o=this.dragLayer)==null||o.setAttribute("transform",e);for(const[,s]of this.layers)s.setAttribute("transform",e)}moveToDragLayer(e){let t;(t=this.dragLayer)==null||t.appendChild(e.getSvgRoot()),e.canBeFocused()&&r.getFocusManager$$module$build$src$core$focus_manager().focusNode(e)}moveOffDragLayer(e,t){this.append(e,t),e.canBeFocused()&&r.getFocusManager$$module$build$src$core$focus_manager().focusNode(e)}append(e,t){this.layers.has(t)||this.createLayer(t),e=e.getSvgRoot();let o;if(((o=this.layers.get(t))==null?void 0:o.lastChild)!==e){let s;(s=this.layers.get(t))==null||s.appendChild(e)}}createLayer(e){const t=this.workspace.getSvgGroup(),o=v(R.G,{});let s=!1;const i=[...this.layers].sort((n,d)=>n[0]-d[0]);for(const[n,d]of i)if(e<n){t.insertBefore(o,d),s=!0;break}return s||t.appendChild(o),this.layers.set(e,o),o}hasLayer(e){return e===this.dragLayer||new Set(this.layers.values()).has(e)}getBlockLayer(){return this.layers.get(us)}getBubbleLayer(){return this.layers.get(il)}},Sm=class{constructor(){this.curNode=this.colour=null,this.type="marker"}getCurNode(){return this.curNode}setCurNode(e){this.curNode=e}dispose(){this.curNode=null}getSourceBlockFromNode(e){return e instanceof Be?e:e instanceof we||e instanceof _t?e.getSourceBlock():null}getSourceBlock(){return this.getSourceBlockFromNode(this.getCurNode())}},Za=class extends Sm{constructor(e){super(),this.workspace=e,this.type="cursor",this.potentialNodes=null}next(){var e=this.getCurNode();return e?((e=this.getNextNode(e,t=>{let o;return t instanceof Be&&!((o=t.outputConnection)!=null&&o.targetBlock())||t instanceof yo},!0))&&this.setCurNode(e),e):null}in(){var e=this.getCurNode();return e?((e=this.getNextNode(e,()=>!0,!0))&&this.setCurNode(e),e):null}prev(){var e=this.getCurNode();return e?((e=this.getPreviousNode(e,t=>{let o;return t instanceof Be&&!((o=t.outputConnection)!=null&&o.targetBlock())||t instanceof yo},!0))&&this.setCurNode(e),e):null}out(){var e=this.getCurNode();return e?((e=this.getPreviousNode(e,()=>!0,!0))&&this.setCurNode(e),e):null}atEndOfLine(){var e=this.getCurNode();if(!e)return!1;const t=this.getNextNode(e,()=>!0,!0);return e=this.getNextNode(e,o=>{let s;return o instanceof Be&&!((s=o.outputConnection)!=null&&s.targetBlock())},!0),t===e}getNextNodeImpl(e,t,o=new Set){if(!e||o.has(e))return null;let s=this.workspace.getNavigator().getFirstChild(e)||this.workspace.getNavigator().getNextSibling(e);for(var i=e;i&&!s&&(i=this.workspace.getNavigator().getParent(i),!!i);)s=this.workspace.getNavigator().getNextSibling(i);return t(s)?s:s?(o.add(e),this.getNextNodeImpl(s,t,o)):null}getNextNode(e,t,o){return!e||!o&&this.getLastNode()===e?null:this.getNextNodeImpl(e,t)}getPreviousNodeImpl(e,t,o=new Set){if(!e||o.has(e))return null;const s=this.getRightMostChild(this.workspace.getNavigator().getPreviousSibling(e),e)||this.workspace.getNavigator().getParent(e);return t(s)?s:s?(o.add(e),this.getPreviousNodeImpl(s,t,o)):null}getPreviousNode(e,t,o){return!e||!o&&this.getFirstNode()===e?null:this.getPreviousNodeImpl(e,t)}getRightMostChild(e,t){if(!e)return e;let o=this.workspace.getNavigator().getFirstChild(e);if(!o||o===t)return e;for(e=o;e&&e!==t;e=this.workspace.getNavigator().getNextSibling(o))o=e;return this.getRightMostChild(o,t)}preDelete(e){var t=this.getCurNode();t=t?[t]:[];var o;let s,i;const n=(i=(o=e.previousConnection)==null?void 0:o.targetConnection)!=null?i:(s=e.outputConnection)==null?void 0:s.targetConnection;n&&t.push(n),(o=e.getNextBlock())&&t.push(o),(e=e.getParent())&&t.push(e),t.push(this.workspace),this.potentialNodes=t}postDelete(){const e=this.potentialNodes;if(this.potentialNodes=null,!e)throw Error("must call preDelete first");for(const t of e){let o;if((o=this.getSourceBlockFromNode(t))==null||!o.disposed){this.setCurNode(t);return}}throw Error("no valid nodes in this.potentialNodes")}getCurNode(){return r.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode()}setCurNode(e){r.getFocusManager$$module$build$src$core$focus_manager().focusNode(e),e instanceof Be?e.workspace.scrollBoundsIntoView(e.getBoundingRectangleWithoutChildren()):e instanceof we?(e=e.getSourceBlock(),e.workspace.scrollBoundsIntoView(e.getBoundingRectangleWithoutChildren())):e instanceof yo&&e.workspace.scrollBoundsIntoView(e.getBoundingRectangle())}getFirstNode(){return this.workspace.getNavigator().getFirstChild(this.workspace)}getLastNode(){const e=this.getFirstNode();return this.getPreviousNode(e,()=>!0,!0)}};l(M.CURSOR,Ft,Za);var Qa=class{constructor(e){this.workspace=e,this.markers=new Map,this.cursor=new Za(this.workspace)}registerMarker(e,t){this.markers.has(e)&&this.unregisterMarker(e),this.markers.set(e,t)}unregisterMarker(e){const t=this.markers.get(e);if(t)t.dispose(),this.markers.delete(e);else throw Error("Marker with ID "+e+" does not exist. Can only unregister markers that exist.")}getCursor(){return this.cursor}getMarker(e){return this.markers.get(e)||null}setCursor(e){this.cursor=e}dispose(){const e=Object.keys(this.markers);for(let t=0,o;o=e[t];t++)this.unregisterMarker(o);this.markers.clear(),this.cursor.dispose()}};Qa.LOCAL_MARKER="local_marker_1";var eh=class extends Oe{constructor(e,t,o){super(e,t,o,eh.createTextArea()),this.workspace=e,this.anchor=t,this.ownerRect=o,this.resizePointerMoveListener=this.resizePointerUpListener=null,this.textChangeListeners=[],this.sizeChangeListeners=[],this.locationChangeListeners=[],this.text="",this.DEFAULT_SIZE=new ve(160+Oe.DOUBLE_BORDER,80+Oe.DOUBLE_BORDER),this.MIN_SIZE=new ve(45+Oe.DOUBLE_BORDER,20+Oe.DOUBLE_BORDER),this.editable=!0,G(this.svgRoot,"blocklyTextInputBubble"),this.textArea=this.getFocusableElement(),this.inputRoot=this.createEditor(this.contentContainer,this.textArea),this.resizeGroup=this.createResizeHandle(this.svgRoot,e),this.setSize(this.DEFAULT_SIZE,!0)}getText(){return this.text}setText(e){this.text=e,this.textArea.value=e,this.onTextChange()}setEditable(e){(this.editable=e)?this.textArea.removeAttribute("readonly"):this.textArea.setAttribute("readonly","")}isEditable(){return this.editable}addTextChangeListener(e){this.textChangeListeners.push(e)}addSizeChangeListener(e){this.sizeChangeListeners.push(e)}addLocationChangeListener(e){this.locationChangeListeners.push(e)}static createTextArea(){const e=document.createElementNS(To,"textarea");return e.className="blocklyTextarea blocklyText",e}createEditor(e,t){e=v(R.FOREIGNOBJECT,{x:Oe.BORDER_WIDTH,y:Oe.BORDER_WIDTH},e);const o=document.createElementNS(To,"body");return o.setAttribute("xmlns",To),o.className="blocklyMinimalBody",t.setAttribute("dir",this.workspace.RTL?"RTL":"LTR"),o.appendChild(t),e.appendChild(o),this.bindTextAreaEvents(t),e}bindTextAreaEvents(e){z(e,"wheel",this,t=>{t.stopPropagation()}),z(e,"pointerdown",this,t=>{t.stopPropagation(),ie()}),z(e,"change",this,this.onTextChange)}createResizeHandle(e,t){return e=v(R.IMAGE,{class:"blocklyResizeHandle",href:`${t.options.pathToMedia}resize-handle.svg`},e),z(e,"pointerdown",this,this.onResizePointerDown),e}setSize(e,t=!1){e.width=Math.max(e.width,this.MIN_SIZE.width),e.height=Math.max(e.height,this.MIN_SIZE.height);const o=e.width-Oe.DOUBLE_BORDER,s=e.height-Oe.DOUBLE_BORDER;this.inputRoot.setAttribute("width",`${o}`),this.inputRoot.setAttribute("height",`${s}`),this.resizeGroup.setAttribute("y",`${s}`),this.workspace.RTL?this.resizeGroup.setAttribute("x",`${-Oe.DOUBLE_BORDER}`):this.resizeGroup.setAttribute("x",`${o}`),super.setSize(e,t),this.onSizeChange()}getSize(){return super.getSize()}moveDuringDrag(e){super.moveDuringDrag(e),this.onLocationChange()}setPositionRelativeToAnchor(e,t){super.setPositionRelativeToAnchor(e,t),this.onLocationChange()}positionByRect(e=new ye(0,0,0,0)){super.positionByRect(e),this.onLocationChange()}onResizePointerDown(e){this.bringToFront(),Ie(e)||($n(this.workspace,e,new P(this.workspace.RTL?-this.getSize().width:this.getSize().width,this.getSize().height)),this.resizePointerUpListener=z(document,"pointerup",this,this.onResizePointerUp),this.resizePointerMoveListener=z(document,"pointermove",this,this.onResizePointerMove),this.workspace.hideChaff()),e.stopPropagation()}onResizePointerUp(e){ie(),this.resizePointerUpListener&&(te(this.resizePointerUpListener),this.resizePointerUpListener=null),this.resizePointerMoveListener&&(te(this.resizePointerMoveListener),this.resizePointerMoveListener=null)}onResizePointerMove(e){e=pn(this.workspace,e),this.setSize(new ve(this.workspace.RTL?-e.x:e.x,e.y),!1),this.onSizeChange()}onTextChange(){this.text=this.textArea.value;for(const e of this.textChangeListeners)e()}onSizeChange(){for(const e of this.sizeChangeListeners)e()}onLocationChange(){for(const e of this.locationChangeListeners)e()}};q(`
646
646
  .blocklyTextInputBubble .blocklyTextarea {
647
647
  background-color: var(--commentFillColour);
648
648
  border: 0;
@@ -654,19 +654,19 @@ children`),this.state=e}},Mg=class extends gi{constructor(e,t,o){super(`Cannot a
654
654
  width: 100%;
655
655
  height: 100%;
656
656
  }
657
- `);var Qa={};Qa.register=du,Qa.unregister=np;var eh=17,Im=160,Cm=80,Xo=class extends _r{constructor(e){super(e),this.sourceBlock=e,this.textInputBubble=null,this.text="",this.bubbleSize=new ve(Im,Cm),this.bubbleVisiblity=!1}getType(){return Xo.TYPE}initView(e){this.svgRoot||(super.initView(e),v(R.CIRCLE,{class:"blocklyIconShape",r:"8",cx:"8",cy:"8"},this.svgRoot),v(R.PATH,{class:"blocklyIconSymbol",d:"m6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.4050.607,-5.534 -3.765,-3.874v1.7c3.12,-1.657 3.698,0.118 2.336,1.25-1.201,0.998 -1.201,1.528 -1.204,2.19z"},this.svgRoot),v(R.RECT,{class:"blocklyIconSymbol",x:"6.8",y:"10.78",height:"2",width:"2"},this.svgRoot),G(this.svgRoot,"blocklyCommentIcon"))}dispose(){super.dispose();let e;(e=this.textInputBubble)==null||e.dispose()}getWeight(){return Xo.WEIGHT}getSize(){return new ve(eh,eh)}applyColour(){super.applyColour();const e=this.sourceBlock.getColour();let t;(t=this.textInputBubble)==null||t.setColour(e)}updateEditable(){const e=this,t=()=>super.updateEditable;return(0,N.asyncExecutePromiseGeneratorFunction)(function*(){t().call(e),e.bubbleIsVisible()&&(yield e.setBubbleVisible(!1),yield e.setBubbleVisible(!0))})}onLocationChange(e){const t=this.workspaceLocation;super.onLocationChange(e),this.bubbleLocation&&(e=P.difference(this.workspaceLocation,t),this.bubbleLocation=P.sum(this.bubbleLocation,e)),e=this.getAnchorLocation();let o;(o=this.textInputBubble)==null||o.setAnchorLocation(e)}setText(e){const t=this.text;_(new(U(w.BLOCK_CHANGE))(this.sourceBlock,"comment",null,t,e)),this.text=e;let o;(o=this.textInputBubble)==null||o.setText(this.text)}getText(){return this.text}setBubbleSize(e){this.bubbleSize=e;let t;(t=this.textInputBubble)==null||t.setSize(this.bubbleSize,!0)}getBubbleSize(){return this.bubbleSize}setBubbleLocation(e){this.bubbleLocation=e;let t;(t=this.textInputBubble)==null||t.moveDuringDrag(e)}getBubbleLocation(){return this.bubbleLocation}saveState(){if(this.text){const e={text:this.text,pinned:this.bubbleIsVisible(),height:this.bubbleSize.height,width:this.bubbleSize.width},t=this.getBubbleLocation();return t&&(e.x=this.sourceBlock.workspace.RTL?this.sourceBlock.workspace.getWidth()-(t.x+this.bubbleSize.width):t.x,e.y=t.y),e}return null}loadState(e){let t;this.text=(t=e.text)!=null?t:"";let o,s;this.bubbleSize=new ve((o=e.width)!=null?o:Im,(s=e.height)!=null?s:Cm);let i;this.bubbleVisiblity=(i=e.pinned)!=null?i:!1,this.setBubbleVisible(this.bubbleVisiblity);let n=e.x;const d=e.y;go().then(()=>{n&&d&&(n=this.sourceBlock.workspace.RTL?this.sourceBlock.workspace.getWidth()-(n+this.bubbleSize.width):n,this.setBubbleLocation(new P(n,d)))})}onClick(){super.onClick(),this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}onTextChange(){if(this.textInputBubble){var e=this.textInputBubble.getText();this.text!==e&&(_(new(U(w.BLOCK_CHANGE))(this.sourceBlock,"comment",null,this.text,e)),this.text=e)}}onSizeChange(){this.textInputBubble&&(this.bubbleSize=this.textInputBubble.getSize())}onBubbleLocationChange(){this.textInputBubble&&(this.bubbleLocation=this.textInputBubble.getRelativeToSurfaceXY())}bubbleIsVisible(){return this.bubbleVisiblity}setBubbleVisible(e){const t=this;return(0,N.asyncExecutePromiseGeneratorFunction)(function*(){t.bubbleVisiblity!==e&&(t.bubbleVisiblity=e,yield go(),!t.sourceBlock.rendered||t.sourceBlock.isInFlyout||t.sourceBlock.isInsertionMarker()||(e?(t.sourceBlock.isEditable()?t.showEditableBubble():t.showNonEditableBubble(),t.applyColour()):t.hideBubble(),_(new(U(w.BUBBLE_OPEN))(t.sourceBlock,e,"comment"))))})}getBubble(){return this.textInputBubble}showEditableBubble(){this.createBubble();let e;(e=this.textInputBubble)==null||e.addTextChangeListener(()=>this.onTextChange());let t;(t=this.textInputBubble)==null||t.addSizeChangeListener(()=>this.onSizeChange())}showNonEditableBubble(){this.createBubble();let e;(e=this.textInputBubble)==null||e.setEditable(!1)}createBubble(){this.textInputBubble=new Za(this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect()),this.textInputBubble.setText(this.getText()),this.textInputBubble.setSize(this.bubbleSize,!0),this.bubbleLocation&&this.textInputBubble.moveDuringDrag(this.bubbleLocation),this.textInputBubble.addTextChangeListener(()=>this.onTextChange()),this.textInputBubble.addSizeChangeListener(()=>this.onSizeChange()),this.textInputBubble.addLocationChangeListener(()=>this.onBubbleLocationChange())}hideBubble(){let e;(e=this.textInputBubble)==null||e.dispose(),this.textInputBubble=null}getAnchorLocation(){const e=eh/2;return P.sum(this.workspaceLocation,new P(e,e))}getBubbleOwnerRect(){return this.sourceBlock.getBoundingRectangleWithoutChildren()}};Xo.TYPE=ut.COMMENT,Xo.WEIGHT=3,du(Xo.TYPE,Xo);var as={};as.CommentIcon=Xo,as.Icon=_r,as.IconType=ut,as.MutatorIcon=r.MutatorIcon$$module$build$src$core$icons$mutator_icon,as.WarningIcon=Co,as.exceptions=im,as.registry=Qa,r.Names$$module$build$src$core$names=class{constructor(e,t){this.db=new Map,this.dbReverse=new Set,this.variableMap=null,this.variablePrefix=t||"",this.reservedWords=new Set(e?e.split(","):[])}reset(){this.db.clear(),this.dbReverse.clear(),this.variableMap=null}setVariableMap(e){this.variableMap=e}getNameForUserVariable(e){return this.variableMap?(e=this.variableMap.getVariableById(e))?e.getName():null:(console.warn(`Deprecated call to Names.prototype.getName without defining a variable map. To fix, add the following code in your generator's init() function:
658
- Blockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());`),null)}populateVariables(e){e=r.allUsedVarModels$$module$build$src$core$variables(e);for(let t=0;t<e.length;t++)this.getName(e[t].getId(),r.NameType$$module$build$src$core$names.VARIABLE)}populateProcedures(e){throw Error("The implementation of populateProcedures should be monkey-patched in by blockly.ts")}getName(e,t){let o=e;t===r.NameType$$module$build$src$core$names.VARIABLE&&(e=this.getNameForUserVariable(e))&&(o=e),e=o.toLowerCase();const s=t===r.NameType$$module$build$src$core$names.VARIABLE||t===r.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE?this.variablePrefix:"";this.db.has(t)||this.db.set(t,new Map);const i=this.db.get(t);return i.has(e)?s+i.get(e):(t=this.getDistinctName(o,t),i.set(e,t.substr(s.length)),t)}getUserNames(e){let t;return(e=(t=this.db.get(e))==null?void 0:t.keys())?Array.from(e):[]}getDistinctName(e,t){e=this.safeName(e);let o=null,s,i;for(;this.dbReverse.has(e+((s=o)!=null?s:""))||this.reservedWords.has(e+((i=o)!=null?i:""));)o=o?o+1:2;let n;return e+=(n=o)!=null?n:"",this.dbReverse.add(e),(t===r.NameType$$module$build$src$core$names.VARIABLE||t===r.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE?this.variablePrefix:"")+e}safeName(e){return e?(e=encodeURI(e.replace(/ /g,"_")).replace(/[^\w]/g,"_"),"0123456789".includes(e[0])&&(e="my_"+e)):e=r.Msg$$module$build$src$core$msg.UNNAMED_KEY||"unnamed",e}static equals(e,t){return e.toLowerCase()===t.toLowerCase()}},(function(e){e=e.NameType||(e.NameType={}),e.DEVELOPER_VARIABLE="DEVELOPER_VARIABLE",e.VARIABLE="VARIABLE",e.PROCEDURE="PROCEDURE"})(r.Names$$module$build$src$core$names||(r.Names$$module$build$src$core$names={})),r.NameType$$module$build$src$core$names=r.Names$$module$build$src$core$names.NameType,r.Names$$module$build$src$core$names.DEVELOPER_VARIABLE_TYPE=r.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE,r.NameType$$module$build$src$core$names,r.Names$$module$build$src$core$names;var Sm=class extends Map{constructor(){super()}set(e,t){return this.get(e)===t?this:(super.set(e,t),Tn(t)&&t.startPublishing(),this)}delete(e){const t=this.get(e);return e=super.delete(e),e&&(Tn(t)&&t.stopPublishing(),e)}clear(){if(this.size)for(const e of this.keys())this.delete(e)}add(e){return this.set(e.getId(),e)}getProcedures(){return[...this.values()]}},fl,Nt;fl="PROCEDURE",r.DEFAULT_ARG$$module$build$src$core$procedures="x",Nt={CATEGORY_NAME:fl,DEFAULT_ARG:r.DEFAULT_ARG$$module$build$src$core$procedures},Nt.ObservableProcedureMap=Sm,Nt.allProcedures=qi,Nt.findLegalName=r.findLegalName$$module$build$src$core$procedures,Nt.flyoutCategory=gu,Nt.getCallers=_u,Nt.getDefinition=r.getDefinition$$module$build$src$core$procedures,Nt.internalFlyoutCategory=En,Nt.isNameUsed=pu,Nt.isProcedureBlock=os,Nt.mutateCallers=r.mutateCallers$$module$build$src$core$procedures,Nt.mutatorOpenListener=fu,Nt.rename=r.rename$$module$build$src$core$procedures;var Ab=class{constructor(){this.NONE=0,this.FIELD=1,this.HAT=2,this.ICON=4,this.SPACER=8,this.BETWEEN_ROW_SPACER=16,this.IN_ROW_SPACER=32,this.EXTERNAL_VALUE_INPUT=64,this.INPUT=128,this.INLINE_INPUT=256,this.STATEMENT_INPUT=512,this.CONNECTION=1024,this.PREVIOUS_CONNECTION=2048,this.NEXT_CONNECTION=4096,this.OUTPUT_CONNECTION=8192,this.CORNER=16384,this.LEFT_SQUARE_CORNER=32768,this.LEFT_ROUND_CORNER=65536,this.RIGHT_SQUARE_CORNER=131072,this.RIGHT_ROUND_CORNER=262144,this.JAGGED_EDGE=524288,this.ROW=1048576,this.TOP_ROW=2097152,this.BOTTOM_ROW=4194304,this.INPUT_ROW=8388608,this.LEFT_CORNER=this.LEFT_SQUARE_CORNER|this.LEFT_ROUND_CORNER,this.RIGHT_CORNER=this.RIGHT_SQUARE_CORNER|this.RIGHT_ROUND_CORNER,this.nextTypeValue_=16777216}getType(e){return Object.prototype.hasOwnProperty.call(this,e)||(this[e]=this.nextTypeValue_,this.nextTypeValue_<<=1),this[e]}isField(e){return(e.type&this.FIELD)>=1}isHat(e){return(e.type&this.HAT)>=1}isIcon(e){return(e.type&this.ICON)>=1}isSpacer(e){return(e.type&this.SPACER)>=1}isInRowSpacer(e){return(e.type&this.IN_ROW_SPACER)>=1}isSpacerRow(e){return(e.type&this.BETWEEN_ROW_SPACER)>=1}isInput(e){return(e.type&this.INPUT)>=1}isExternalInput(e){return(e.type&this.EXTERNAL_VALUE_INPUT)>=1}isInlineInput(e){return(e.type&this.INLINE_INPUT)>=1}isStatementInput(e){return(e.type&this.STATEMENT_INPUT)>=1}isPreviousConnection(e){return(e.type&this.PREVIOUS_CONNECTION)>=1}isNextConnection(e){return(e.type&this.NEXT_CONNECTION)>=1}isPreviousOrNextConnection(e){return this.isPreviousConnection(e)||this.isNextConnection(e)}isRoundCorner(e){return(e.type&this.LEFT_ROUND_CORNER)>=1||(e.type&this.RIGHT_ROUND_CORNER)>=1}isLeftRoundedCorner(e){return this.isRoundCorner(e)&&(e.type&this.LEFT_ROUND_CORNER)>=1}isRightRoundedCorner(e){return this.isRoundCorner(e)&&(e.type&this.RIGHT_ROUND_CORNER)>=1}isLeftSquareCorner(e){return(e.type&this.LEFT_SQUARE_CORNER)>=1}isRightSquareCorner(e){return(e.type&this.RIGHT_SQUARE_CORNER)>=1}isCorner(e){return(e.type&this.CORNER)>=1}isJaggedEdge(e){return(e.type&this.JAGGED_EDGE)>=1}isRow(e){return(e.type&this.ROW)>=1}isBetweenRowSpacer(e){return(e.type&this.BETWEEN_ROW_SPACER)>=1}isTopRow(e){return(e.type&this.TOP_ROW)>=1}isBottomRow(e){return(e.type&this.BOTTOM_ROW)>=1}isTopOrBottomRow(e){return this.isTopRow(e)||this.isBottomRow(e)}isInputRow(e){return(e.type&this.INPUT_ROW)>=1}},T=new Ab,So=class{constructor(e){this.centerline=this.xPos=this.height=this.width=0,this.constants_=e,this.type=T.NONE,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}},yr=class{constructor(e){this.elements=[],this.xPos=this.yPos=this.widthWithConnectedBlocks=this.minWidth=this.minHeight=this.width=this.height=0,this.hasStatement=this.hasExternalInput=!1,this.statementEdge=0,this.hasJaggedEdge=this.hasDummyInput=this.hasInlineInput=!1,this.align=null,this.constants_=e,this.type=T.ROW,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}getLastInput(){for(let e=this.elements.length-1;e>=0;e--){const t=this.elements[e];if(T.isInput(t))return t}return null}measure(){throw Error("Unexpected attempt to measure a base Row.")}startsWithElemSpacer(){return!0}endsWithElemSpacer(){return!0}getFirstSpacer(){for(let e=0;e<this.elements.length;e++){const t=this.elements[e];if(T.isInRowSpacer(t))return t}return null}getLastSpacer(){for(let e=this.elements.length-1;e>=0;e--){const t=this.elements[e];if(T.isInRowSpacer(t))return t}return null}},th=class extends yr{constructor(e){super(e),this.hasNextConnection=!1,this.connection=null,this.baseline=this.descenderHeight=0,this.type|=T.BOTTOM_ROW}hasLeftSquareCorner(e){return!!e.outputConnection||!!e.getNextBlock()}hasRightSquareCorner(e){return!0}measure(){let e=0,t=0,o=0;for(let s=0;s<this.elements.length;s++){const i=this.elements[s];t+=i.width,T.isSpacer(i)||(T.isNextConnection(i)?o=Math.max(o,i.height):e=Math.max(e,i.height))}this.width=Math.max(this.minWidth,t),this.height=Math.max(this.minHeight,e)+o,this.descenderHeight=o,this.widthWithConnectedBlocks=this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}},Us=class extends So{constructor(e,t){super(e),this.connectionModel=t,this.type|=T.CONNECTION,this.shape=this.constants_.shapeFor(t),this.isDynamicShape="isDynamic"in this.shape&&this.shape.isDynamic,this.highlighted=t.isHighlighted()}},_l=class extends Us{constructor(e,t){super(e,t.connection),this.input=t,this.connectionOffsetY=this.connectionOffsetX=0,this.type|=T.INPUT,this.align=t.align,(this.connectedBlock=t.connection&&t.connection.targetBlock()?t.connection.targetBlock():null)?(e=this.connectedBlock.getHeightWidth(),this.connectedBlockWidth=e.width,this.connectedBlockHeight=e.height):this.connectedBlockHeight=this.connectedBlockWidth=0}},oh=class extends _l{constructor(e,t){super(e,t),this.height=0,this.type|=T.EXTERNAL_VALUE_INPUT,this.height=this.connectedBlock?this.connectedBlockHeight-this.constants_.TAB_OFFSET_FROM_TOP-this.constants_.MEDIUM_PADDING:this.shape.height,this.width=this.shape.width+this.constants_.EXTERNAL_VALUE_INPUT_PADDING,this.connectionOffsetY=this.constants_.TAB_OFFSET_FROM_TOP,this.connectionHeight=this.shape.height,this.connectionWidth=this.shape.width}},sh=class extends So{constructor(e,t,o){super(e),this.field=t,this.parentInput=o,this.isEditable=t.EDITABLE,this.flipRtl=t.getFlipRtl(),this.type|=T.FIELD,e=this.field.getSize(),this.height=e.height,this.width=e.width}},km=class extends So{constructor(e){super(e),this.type|=T.HAT,this.height=this.constants_.START_HAT.height,this.width=this.constants_.START_HAT.width,this.ascenderHeight=this.height}},Rm=class extends So{constructor(e,t){super(e),this.icon=t,this.flipRtl=!1,this.type|=T.ICON,e=t.getSize(),this.height=e.height,this.width=e.width}},Xt=class extends So{constructor(e,t){super(e),this.type|=T.SPACER|T.IN_ROW_SPACER,this.width=t,this.height=this.constants_.SPACER_DEFAULT_HEIGHT}},ih=class extends _l{constructor(e,t){super(e,t),this.type|=T.INLINE_INPUT,this.connectedBlock?(this.width=this.connectedBlockWidth,this.height=this.connectedBlockHeight):(this.height=this.constants_.EMPTY_INLINE_INPUT_HEIGHT,this.width=this.constants_.EMPTY_INLINE_INPUT_PADDING),this.connectionHeight=this.isDynamicShape?this.shape.height(this.height):this.shape.height,this.connectionWidth=this.isDynamicShape?this.shape.width(this.height):this.shape.width,this.connectedBlock||(this.width+=this.connectionWidth*(this.isDynamicShape?2:1)),this.connectionOffsetY="connectionOffsetY"in this.shape?this.shape.connectionOffsetY(this.connectionHeight):this.constants_.TAB_OFFSET_FROM_TOP,this.connectionOffsetX="connectionOffsetX"in this.shape?this.shape.connectionOffsetX(this.connectionWidth):0}},rh=class extends yr{constructor(e){super(e),this.connectedBlockWidths=0,this.type|=T.INPUT_ROW}measure(){this.width=this.minWidth,this.height=this.minHeight;let e=0;for(let t=0;t<this.elements.length;t++){const o=this.elements[t];this.width+=o.width,T.isInput(o)&&(T.isStatementInput(o)?e+=o.connectedBlockWidth:T.isExternalInput(o)&&o.connectedBlockWidth!==0&&(e+=o.connectedBlockWidth-o.connectionWidth)),T.isSpacer(o)||(this.height=Math.max(this.height,o.height))}this.connectedBlockWidths=e,this.widthWithConnectedBlocks=this.width+e}endsWithElemSpacer(){return!this.hasExternalInput&&!this.hasStatement}},wm=class extends So{constructor(e){super(e),this.type|=T.JAGGED_EDGE,this.height=this.constants_.JAGGED_TEETH.height,this.width=this.constants_.JAGGED_TEETH.width}},Om=class extends Us{constructor(e,t){super(e,t),this.type|=T.NEXT_CONNECTION,this.height=this.shape.height,this.width=this.shape.width}},Nm=class extends Us{constructor(e,t){super(e,t),this.connectionOffsetX=0,this.type|=T.OUTPUT_CONNECTION,this.height=this.isDynamicShape?0:this.shape.height,this.startX=this.width=this.isDynamicShape?0:this.shape.width,this.connectionOffsetY=this.constants_.TAB_OFFSET_FROM_TOP}},Am=class extends Us{constructor(e,t){super(e,t),this.type|=T.PREVIOUS_CONNECTION,this.height=this.shape.height,this.width=this.shape.width}},vr=class extends So{constructor(e,t){super(e),this.type=(t&&t!=="left"?T.RIGHT_ROUND_CORNER:T.LEFT_ROUND_CORNER)|T.CORNER,this.width=this.constants_.CORNER_RADIUS,this.height=this.constants_.CORNER_RADIUS/2}},nh=class extends yr{constructor(e,t,o){super(e),this.height=t,this.width=o,this.precedesStatement=this.followsStatement=!1,this.widthWithConnectedBlocks=0,this.type|=T.SPACER|T.BETWEEN_ROW_SPACER,this.elements=[new Xt(this.constants_,o)]}measure(){}},Ir=class extends So{constructor(e,t){super(e),this.type=(t&&t!=="left"?T.RIGHT_SQUARE_CORNER:T.LEFT_SQUARE_CORNER)|T.CORNER,this.width=this.height=this.constants_.NO_PADDING}},bl=class extends _l{constructor(e,t){super(e,t),this.type|=T.STATEMENT_INPUT,this.height=this.connectedBlock?this.connectedBlockHeight+this.constants_.STATEMENT_BOTTOM_SPACER:this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT,this.width=this.constants_.STATEMENT_INPUT_NOTCH_OFFSET+this.shape.width}},lh=class extends yr{constructor(e){super(e),this.ascenderHeight=this.capline=0,this.hasPreviousConnection=!1,this.connection=null,this.type|=T.TOP_ROW}hasLeftSquareCorner(e){const t=(e.hat?e.hat==="cap":this.constants_.ADD_START_HATS)&&!e.outputConnection&&!e.previousConnection,o=e.getPreviousBlock();return!!e.outputConnection||t||(o?o.getNextBlock()===e:!1)}hasRightSquareCorner(e){return!0}measure(){let e=0,t=0,o=0;for(let s=0;s<this.elements.length;s++){const i=this.elements[s];t+=i.width,T.isSpacer(i)||(T.isHat(i)?o=Math.max(o,i.ascenderHeight):e=Math.max(e,i.height))}this.width=Math.max(this.minWidth,t),this.height=Math.max(this.minHeight,e)+o,this.capline=this.ascenderHeight=o,this.widthWithConnectedBlocks=this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}},Tl=class{constructor(){this.NO_PADDING=0,this.SMALL_PADDING=3,this.MEDIUM_PADDING=5,this.MEDIUM_LARGE_PADDING=8,this.LARGE_PADDING=10,this.TAB_HEIGHT=15,this.TAB_OFFSET_FROM_TOP=5,this.TAB_VERTICAL_OVERLAP=2.5,this.TAB_WIDTH=8,this.NOTCH_WIDTH=15,this.NOTCH_HEIGHT=4,this.MIN_BLOCK_WIDTH=12,this.EMPTY_BLOCK_SPACER_HEIGHT=16,this.CORNER_RADIUS=8,this.NOTCH_OFFSET_LEFT=15,this.STATEMENT_BOTTOM_SPACER=0,this.STATEMENT_INPUT_PADDING_LEFT=20,this.BETWEEN_STATEMENT_PADDING_Y=4,this.ADD_START_HATS=!1,this.START_HAT_HEIGHT=15,this.START_HAT_WIDTH=100,this.SPACER_DEFAULT_HEIGHT=15,this.MIN_BLOCK_HEIGHT=24,this.EMPTY_INLINE_INPUT_PADDING=14.5,this.EXTERNAL_VALUE_INPUT_PADDING=2,this.JAGGED_TEETH_HEIGHT=12,this.JAGGED_TEETH_WIDTH=6,this.FIELD_TEXT_FONTSIZE=11,this.FIELD_TEXT_FONTWEIGHT="normal",this.FIELD_TEXT_FONTFAMILY="sans-serif",this.FIELD_TEXT_BASELINE=this.FIELD_TEXT_HEIGHT=-1,this.FIELD_BORDER_RECT_RADIUS=4,this.FIELD_BORDER_RECT_HEIGHT=16,this.FIELD_BORDER_RECT_X_PADDING=5,this.FIELD_BORDER_RECT_Y_PADDING=3,this.FIELD_BORDER_RECT_COLOUR="#fff",this.FIELD_DROPDOWN_SVG_ARROW=this.FIELD_DROPDOWN_COLOURED_DIV=this.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW=!1,this.FIELD_DROPDOWN_SVG_ARROW_SIZE=12,this.FIELD_COLOUR_FULL_BLOCK=this.FIELD_TEXTINPUT_BOX_SHADOW=!1,this.FIELD_COLOUR_DEFAULT_WIDTH=26,this.defs=null,this.embossFilterId="",this.embossFilter=null,this.disabledPatternId="",this.disabledPattern=null,this.debugFilterId="",this.cssNode=this.debugFilter=null,this.CURSOR_COLOUR="#cc0a0a",this.MARKER_COLOUR="#4286f4",this.CURSOR_WS_WIDTH=100,this.WS_CURSOR_HEIGHT=5,this.CURSOR_STACK_PADDING=10,this.CURSOR_BLOCK_PADDING=2,this.CURSOR_STROKE_WIDTH=4,this.FULL_BLOCK_FIELDS=!1,this.INSERTION_MARKER_COLOUR="#000000",this.INSERTION_MARKER_OPACITY=.2,this.SHAPES={PUZZLE:1,NOTCH:2},this.TALL_INPUT_FIELD_OFFSET_Y=this.MEDIUM_PADDING,this.DUMMY_INPUT_SHADOW_MIN_HEIGHT=this.DUMMY_INPUT_MIN_HEIGHT=this.TAB_HEIGHT,this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT,this.TOP_ROW_MIN_HEIGHT=this.MEDIUM_PADDING,this.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING,this.BOTTOM_ROW_MIN_HEIGHT=this.MEDIUM_PADDING,this.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING,this.EMPTY_INLINE_INPUT_HEIGHT=this.TAB_HEIGHT+11,this.EMPTY_STATEMENT_INPUT_HEIGHT=this.MIN_BLOCK_HEIGHT,this.START_POINT=je(0,0),this.FIELD_TEXT_BASELINE_CENTER=!0,this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT,this.FIELD_DROPDOWN_SVG_ARROW_PADDING=this.FIELD_BORDER_RECT_X_PADDING,this.FIELD_DROPDOWN_SVG_ARROW_DATAURI="data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMi43MSIgaGVpZ2h0PSI4Ljc5IiB2aWV3Qm94PSIwIDAgMTIuNzEgOC43OSI+PHRpdGxlPmRyb3Bkb3duLWFycm93PC90aXRsZT48ZyBvcGFjaXR5PSIwLjEiPjxwYXRoIGQ9Ik0xMi43MSwyLjQ0QTIuNDEsMi40MSwwLDAsMSwxMiw0LjE2TDguMDgsOC4wOGEyLjQ1LDIuNDUsMCwwLDEtMy40NSwwTDAuNzIsNC4xNkEyLjQyLDIuNDIsMCwwLDEsMCwyLjQ0LDIuNDgsMi40OCwwLDAsMSwuNzEuNzFDMSwwLjQ3LDEuNDMsMCw2LjM2LDBTMTEuNzUsMC40NiwxMiwuNzFBMi40NCwyLjQ0LDAsMCwxLDEyLjcxLDIuNDRaIiBmaWxsPSIjMjMxZjIwIi8+PC9nPjxwYXRoIGQ9Ik02LjM2LDcuNzlhMS40MywxLjQzLDAsMCwxLTEtLjQyTDEuNDIsMy40NWExLjQ0LDEuNDQsMCwwLDEsMC0yYzAuNTYtLjU2LDkuMzEtMC41Niw5Ljg3LDBhMS40NCwxLjQ0LDAsMCwxLDAsMkw3LjM3LDcuMzdBMS40MywxLjQzLDAsMCwxLDYuMzYsNy43OVoiIGZpbGw9IiNmZmYiLz48L3N2Zz4=",this.FIELD_COLOUR_DEFAULT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT,this.FIELD_CHECKBOX_X_OFFSET=this.FIELD_BORDER_RECT_X_PADDING-3,this.randomIdentifier=String(Math.random()).substring(2)}init(){this.JAGGED_TEETH=this.makeJaggedTeeth(),this.NOTCH=this.makeNotch(),this.START_HAT=this.makeStartHat(),this.PUZZLE_TAB=this.makePuzzleTab(),this.INSIDE_CORNERS=this.makeInsideCorners(),this.OUTSIDE_CORNERS=this.makeOutsideCorners()}setTheme(e){this.blockStyles=Object.create(null);const t=e.blockStyles;for(const o in t)this.blockStyles[o]=this.validatedBlockStyle_(t[o]);this.setDynamicProperties_(e)}setDynamicProperties_(e){this.setFontConstants_(e),this.setComponentConstants_(e),this.ADD_START_HATS=e.startHats!==void 0?e.startHats:this.ADD_START_HATS}setFontConstants_(e){e.fontStyle&&e.fontStyle.family&&(this.FIELD_TEXT_FONTFAMILY=e.fontStyle.family),e.fontStyle&&e.fontStyle.weight&&(this.FIELD_TEXT_FONTWEIGHT=e.fontStyle.weight),e.fontStyle&&e.fontStyle.size&&(this.FIELD_TEXT_FONTSIZE=e.fontStyle.size),e=E("Hg",this.FIELD_TEXT_FONTSIZE+"pt",this.FIELD_TEXT_FONTWEIGHT,this.FIELD_TEXT_FONTFAMILY),this.FIELD_TEXT_HEIGHT=e.height,this.FIELD_TEXT_BASELINE=e.baseline}setComponentConstants_(e){this.CURSOR_COLOUR=e.getComponentStyle("cursorColour")||this.CURSOR_COLOUR,this.MARKER_COLOUR=e.getComponentStyle("markerColour")||this.MARKER_COLOUR,this.INSERTION_MARKER_COLOUR=e.getComponentStyle("insertionMarkerColour")||this.INSERTION_MARKER_COLOUR,this.INSERTION_MARKER_OPACITY=Number(e.getComponentStyle("insertionMarkerOpacity"))||this.INSERTION_MARKER_OPACITY}getBlockStyleForColour(e){const t="auto_"+e;return this.blockStyles[t]||(this.blockStyles[t]=this.createBlockStyle_(e)),{style:this.blockStyles[t],name:t}}getBlockStyle(e){return this.blockStyles[e||""]||(e&&e.startsWith("auto_")?this.getBlockStyleForColour(e.substring(5)).style:this.createBlockStyle_("#000000"))}createBlockStyle_(e){return this.validatedBlockStyle_({colourPrimary:e})}validatedBlockStyle_(e){const t={};return e&&Object.assign(t,e),e=ti(t.colourPrimary||"#000"),t.colourPrimary=e.hex,t.colourSecondary=t.colourSecondary?ti(t.colourSecondary).hex:this.generateSecondaryColour_(t.colourPrimary),t.colourTertiary=t.colourTertiary?ti(t.colourTertiary).hex:this.generateTertiaryColour_(t.colourPrimary),t.hat=t.hat||"",t}generateSecondaryColour_(e){return ys("#fff",e,.6)||e}generateTertiaryColour_(e){return ys("#fff",e,.3)||e}dispose(){this.embossFilter&&ke(this.embossFilter),this.disabledPattern&&ke(this.disabledPattern),this.debugFilter&&ke(this.debugFilter),this.cssNode=null}makeJaggedTeeth(){const e=this.JAGGED_TEETH_HEIGHT,t=this.JAGGED_TEETH_WIDTH,o=ni([se(t,e/4),se(-t*2,e/2),se(t,e/4)]);return{height:e,width:t,path:o}}makeStartHat(){const e=this.START_HAT_HEIGHT,t=this.START_HAT_WIDTH,o=Pt("c",[se(30,-e),se(70,-e),se(t,0)]);return{height:e*.75,width:t,path:o}}makePuzzleTab(){function e(n){n=n?-1:1;const d=-n;var f=o/2;const L=f+2.5,oe=f+.5,ze=se(-t,n*f);return f=se(t,n*f),Pt("c",[se(0,n*L),se(-t,d*oe),ze])+Pt("s",[se(t,d*2.5),f])}const t=this.TAB_WIDTH,o=this.TAB_HEIGHT,s=e(!0),i=e(!1);return{type:this.SHAPES.PUZZLE,width:t,height:o,pathDown:i,pathUp:s}}makeNotch(){function e(d){return ni([se(d*s,o),se(d*3,0),se(d*s,-o)])}const t=this.NOTCH_WIDTH,o=this.NOTCH_HEIGHT,s=(t-3)/2,i=e(1),n=e(-1);return{type:this.SHAPES.NOTCH,width:t,height:o,pathLeft:i,pathRight:n}}makeInsideCorners(){const e=this.CORNER_RADIUS,t=qe("a","0 0,0",e,se(-e,e)),o=qe("a","0 0,0",e,se(e,e));return{width:e,height:e,pathTop:t,pathBottom:o}}makeOutsideCorners(){const e=this.CORNER_RADIUS,t=je(0,e)+qe("a","0 0,1",e,se(e,-e)),o=qe("a","0 0,1",e,se(e,e)),s=qe("a","0 0,1",e,se(-e,-e)),i=qe("a","0 0,1",e,se(-e,e));return{topLeft:t,topRight:o,bottomRight:i,bottomLeft:s,rightHeight:e}}shapeFor(e){switch(e.type){case Z.INPUT_VALUE:case Z.OUTPUT_VALUE:return this.PUZZLE_TAB;case Z.PREVIOUS_STATEMENT:case Z.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown connection type")}}createDom(e,t,o,s){this.injectCSS_(t,o),this.defs=v(R.DEFS,{},e),e=v(R.FILTER,{id:"blocklyEmbossFilter"+this.randomIdentifier},this.defs),v(R.FEGAUSSIANBLUR,{in:"SourceAlpha",stdDeviation:1,result:"blur"},e),t=v(R.FESPECULARLIGHTING,{in:"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},e),v(R.FEPOINTLIGHT,{x:-5e3,y:-1e4,z:2e4},t),v(R.FECOMPOSITE,{in:"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},e),v(R.FECOMPOSITE,{in:"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},e),this.embossFilterId=e.id,this.embossFilter=e,e=v(R.PATTERN,{id:"blocklyDisabledPattern"+this.randomIdentifier,patternUnits:"userSpaceOnUse",width:10,height:10},this.defs),v(R.RECT,{width:10,height:10,fill:"#aaa"},e),v(R.PATH,{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},e),this.disabledPatternId=e.id,this.disabledPattern=e,this.createDebugFilter(),s&&(s.style.setProperty("--blocklyEmbossFilter",`url(#${this.embossFilterId})`),s.style.setProperty("--blocklyDisabledPattern",`url(#${this.disabledPatternId})`),s.style.setProperty("--blocklyDebugFilter",`url(#${this.debugFilterId})`))}createDebugFilter(){if(!this.debugFilter){const e=v(R.FILTER,{id:"blocklyDebugFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},this.defs),t=v(R.FECOMPONENTTRANSFER,{result:"outBlur"},e);v(R.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},t),v(R.FEFLOOD,{"flood-color":"#ff0000","flood-opacity":.5,result:"outColor"},e),v(R.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},e),this.debugFilterId=e.id,this.debugFilter=e}}injectCSS_(e,t){t=this.getCSS_(t),e="blockly-renderer-style-"+e,this.cssNode=document.getElementById(e);const o=t.join(`
659
- `);this.cssNode?this.cssNode.firstChild.textContent=o:(t=document.createElement("style"),t.id=e,e=document.createTextNode(o),t.appendChild(e),document.head.insertBefore(t,document.head.firstChild),this.cssNode=t)}getCSS_(e){return[`${e} .blocklyText, `,`${e} .blocklyFlyoutLabelText {`,`font: ${this.FIELD_TEXT_FONTWEIGHT} ${this.FIELD_TEXT_FONTSIZE}pt ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${e} .blocklyText {`,"fill: #fff;","}",`${e} .blocklyNonEditableField>rect,`,`${e} .blocklyEditableField>rect {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"fill-opacity: .6;","stroke: none;","}",`${e} .blocklyNonEditableField>text,`,`${e} .blocklyEditableField>text {`,"fill: #000;","}",`${e} .blocklyFlyoutLabelText {`,"fill: #000;","}",`${e} .blocklyText.blocklyBubbleText {`,"fill: #000;","}",`${e} .blocklyEditableField:not(.blocklyEditing):hover>rect {`,"stroke: #fff;","stroke-width: 2;","}",`${e} .blocklyHtmlInput {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"}",`${e} .blocklySelected>.blocklyPath {`,"stroke: #fc3;","stroke-width: 3px;","}",`${e} .blocklyHighlightedConnectionPath {`,"stroke: #fc3;","}",`${e} .blocklyReplaceable .blocklyPath {`,"fill-opacity: .5;","}",`${e} .blocklyReplaceable .blocklyPathLight,`,`${e} .blocklyReplaceable .blocklyPathDark {`,"display: none;","}",`${e} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"]}},El=class{constructor(e,t){this.inlinePath_=this.outlinePath_="",this.block_=e,this.info_=t,this.topLeft_=e.getRelativeToSurfaceXY(),this.constants_=t.getRenderer().getConstants()}draw(){this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights(),this.block_.pathObject.setPath(this.outlinePath_+`
660
- `+this.inlinePath_),this.info_.RTL&&this.block_.pathObject.flipRTL(),this.recordSizeOnBlock_()}recordSizeOnBlock_(){this.block_.height=this.info_.height,this.block_.width=this.info_.widthWithChildren,this.block_.childlessWidth=this.info_.width}drawOutline_(){this.drawTop_();for(let e=1;e<this.info_.rows.length-1;e++){const t=this.info_.rows[e];t.hasJaggedEdge?this.drawJaggedEdge_(t):t.hasStatement?this.drawStatementInput_(t):t.hasExternalInput?this.drawValueInput_(t):this.drawRightSideRow_(t)}this.drawBottom_(),this.drawLeft_()}drawTop_(){const e=this.info_.topRow,t=e.elements;this.positionPreviousConnection_(),this.outlinePath_+=je(e.xPos,this.info_.startY);for(let o=0,s;s=t[o];o++)T.isLeftRoundedCorner(s)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topLeft:T.isRightRoundedCorner(s)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topRight:T.isPreviousConnection(s)?this.outlinePath_+=s.shape.pathLeft:T.isHat(s)?this.outlinePath_+=this.constants_.START_HAT.path:T.isSpacer(s)&&(this.outlinePath_+=re("h",s.width));this.outlinePath_+=re("v",e.height)}drawJaggedEdge_(e){this.outlinePath_+=this.constants_.JAGGED_TEETH.path+re("v",e.height-this.constants_.JAGGED_TEETH.height)}drawValueInput_(e){const t=e.getLastInput();this.positionExternalValueConnection_(e);const o=yn(t.shape)?t.shape.pathDown(t.height):t.shape.pathDown;this.outlinePath_+=re("H",t.xPos+t.width)+o+re("v",e.height-t.connectionHeight)}drawStatementInput_(e){var t=e.getLastInput();if(t){var o=t.xPos+t.notchOffset+t.shape.width;t=t.shape.pathRight+re("h",-(t.notchOffset-this.constants_.INSIDE_CORNERS.width))+this.constants_.INSIDE_CORNERS.pathTop;var s=e.height-2*this.constants_.INSIDE_CORNERS.height;this.outlinePath_+=re("H",o)+t+re("v",s)+this.constants_.INSIDE_CORNERS.pathBottom+re("H",e.xPos+e.width),this.positionStatementInputConnection_(e)}}drawRightSideRow_(e){this.outlinePath_+=re("V",e.yPos+e.height)}drawBottom_(){const e=this.info_.bottomRow,t=e.elements;this.positionNextConnection_();let o=0,s="";for(let i=t.length-1,n;n=t[i];i--)T.isNextConnection(n)?s+=n.shape.pathRight:T.isLeftSquareCorner(n)?s+=re("H",e.xPos):T.isLeftRoundedCorner(n)?s+=this.constants_.OUTSIDE_CORNERS.bottomLeft:T.isRightRoundedCorner(n)?(s+=this.constants_.OUTSIDE_CORNERS.bottomRight,o=this.constants_.OUTSIDE_CORNERS.rightHeight):T.isSpacer(n)&&(s+=re("h",n.width*-1));this.outlinePath_+=re("V",e.baseline-o),this.outlinePath_+=s}drawLeft_(){var e=this.info_.outputConnection;if(this.positionOutputConnection_(),e){const t=e.connectionOffsetY+e.height;e=yn(e.shape)?e.shape.pathUp(e.height):e.shape.pathUp,this.outlinePath_+=re("V",t)+e}this.outlinePath_+="z"}drawInternals_(){for(let e=0,t;t=this.info_.rows[e];e++)for(let o=0,s;s=t.elements[o];o++)T.isInlineInput(s)?this.drawInlineInput_(s):(T.isIcon(s)||T.isField(s))&&this.layoutField_(s)}layoutField_(e){const t=e.centerline-e.height/2;let o=e.xPos;var s="";this.info_.RTL&&(o=-(o+e.width),e.flipRtl&&(o+=e.width,s="scale(-1 1)")),T.isIcon(e)?(s=e.icon,s.setOffsetInBlock(new P(o,t)),this.info_.isInsertionMarker&&s.hideForInsertionMarker()):(e=e.field.getSvgRoot(),e.setAttribute("transform","translate("+o+","+t+")"+s),this.info_.isInsertionMarker&&e.setAttribute("display","none"))}drawInlineInput_(e){const t=e.width,o=e.height,s=e.connectionOffsetY,i=e.connectionHeight+s;this.inlinePath_+=gt(e.xPos+e.connectionWidth,e.centerline-o/2)+re("v",s)+e.shape.pathDown+re("v",o-i)+re("h",t-e.connectionWidth)+re("v",-o)+"z",this.positionInlineInputConnection_(e)}positionInlineInputConnection_(e){const t=e.centerline-e.height/2;if(e.connectionModel){let o=e.xPos+e.connectionWidth+e.connectionOffsetX;this.info_.RTL&&(o*=-1),e.connectionModel.setOffsetInBlock(o,t+e.connectionOffsetY)}}positionStatementInputConnection_(e){const t=e.getLastInput();if(t!=null&&t.connectionModel){let o=e.xPos+e.statementEdge+t.notchOffset;this.info_.RTL&&(o*=-1),t.connectionModel.setOffsetInBlock(o,e.yPos)}}positionExternalValueConnection_(e){const t=e.getLastInput();if(t&&t.connectionModel){let o=e.xPos+e.width;this.info_.RTL&&(o*=-1),t.connectionModel.setOffsetInBlock(o,e.yPos)}}positionPreviousConnection_(){const e=this.info_.topRow;if(e.connection){const t=e.xPos+e.notchOffset;e.connection.connectionModel.setOffsetInBlock(this.info_.RTL?-t:t,0)}}positionNextConnection_(){const e=this.info_.bottomRow;if(e.connection){const t=e.connection,o=t.xPos;t.connectionModel.setOffsetInBlock(this.info_.RTL?-o:o,e.baseline)}}positionOutputConnection_(){if(this.info_.outputConnection){const e=this.info_.startX+this.info_.outputConnection.connectionOffsetX;this.block_.outputConnection.setOffsetInBlock(this.info_.RTL?-e:e,this.info_.outputConnection.connectionOffsetY)}}updateConnectionHighlights(){for(const e of this.info_.rows)for(const t of e.elements){if(!(t instanceof Us))continue;const o=this.drawConnectionHighlightPath(t);o&&(o.style.display=t.highlighted?"":"none")}}drawConnectionHighlightPath(e){const t=e.connectionModel;e=t.type===Z.INPUT_VALUE||t.type===Z.OUTPUT_VALUE?this.getExpressionConnectionHighlightPath(e):this.getStatementConnectionHighlightPath(e);const o=t.getSourceBlock();let s,i;return(i=(s=o.pathObject).addConnectionHighlight)==null?void 0:i.call(s,t,e,t.getOffsetInBlock(),o.RTL)}getExpressionConnectionHighlightPath(e){let t="";return yn(e.shape)?t=e.shape.pathDown(e.height):hp(e.shape)&&(t=e.shape.pathDown),e=this.constants_.TAB_OFFSET_FROM_TOP,je(0,-e)+re("v",e)+t+re("v",e)}getStatementConnectionHighlightPath(e){if(!dp(e.shape))throw Error("Statement connections should have notch shapes");const t=this.constants_.NOTCH_OFFSET_LEFT-this.constants_.CORNER_RADIUS;return je(-t,0)+re("h",t)+e.shape.pathLeft+re("h",t)}},Cr=class{constructor(e,t){this.statementEdge=this.width=this.widthWithChildren=this.height=0,this.rows=[],this.inputRows=[],this.startY=this.startX=0,this.renderer_=e,this.block_=t,this.constants_=this.renderer_.getConstants(),this.outputConnection=t.outputConnection?new Nm(this.constants_,t.outputConnection):null,this.isInline=t.getInputsInline()&&!t.isCollapsed(),this.isCollapsed=t.isCollapsed(),this.isInsertionMarker=t.isInsertionMarker(),this.RTL=t.RTL,this.topRow=new lh(this.constants_),this.bottomRow=new th(this.constants_)}getRenderer(){return this.renderer_}measure(){this.createRows_(),this.addElemSpacing_(),this.addRowSpacing_(),this.computeBounds_(),this.alignRowElements_(),this.finalize_()}createRows_(){this.populateTopRow_(),this.rows.push(this.topRow);let e=new rh(this.constants_);this.inputRows.push(e);var t=this.block_.getIcons();for(let o=0,s;s=t[o];o++){const i=new Rm(this.constants_,s);this.isCollapsed&&!s.isShownWhenCollapsed()||e.elements.push(i)}t=void 0;for(let o=0,s;s=this.block_.inputList[o];o++)if(s.isVisible()){this.shouldStartNewRow_(s,t)&&(this.rows.push(e),e=new rh(this.constants_),this.inputRows.push(e));for(let i=0,n;n=s.fieldRow[i];i++)e.elements.push(new sh(this.constants_,n,s));this.addInput_(s,e),t=s}this.isCollapsed&&(e.hasJaggedEdge=!0,e.elements.push(new wm(this.constants_))),(e.elements.length||e.hasDummyInput)&&this.rows.push(e),this.populateBottomRow_(),this.rows.push(this.bottomRow)}populateTopRow_(){var e=!!this.block_.previousConnection;const t=(this.block_.hat?this.block_.hat==="cap":this.constants_.ADD_START_HATS)&&!this.outputConnection&&!e;let o=this.topRow.hasLeftSquareCorner(this.block_)?Ir:vr;this.topRow.elements.push(new o(this.constants_)),t?(e=new km(this.constants_),this.topRow.elements.push(e)):e&&(this.topRow.hasPreviousConnection=!0,this.topRow.connection=new Am(this.constants_,this.block_.previousConnection),this.topRow.elements.push(this.topRow.connection)),this.block_.inputList.length&&this.block_.inputList[0]instanceof Yt&&!this.block_.isCollapsed()?this.topRow.minHeight=this.constants_.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT:this.topRow.minHeight=this.constants_.TOP_ROW_MIN_HEIGHT,o=this.topRow.hasRightSquareCorner(this.block_)?Ir:vr,this.topRow.elements.push(new o(this.constants_,"right"))}populateBottomRow_(){this.bottomRow.hasNextConnection=!!this.block_.nextConnection,this.bottomRow.minHeight=this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof Yt?this.constants_.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT:this.constants_.BOTTOM_ROW_MIN_HEIGHT,this.bottomRow.hasLeftSquareCorner(this.block_)?this.bottomRow.elements.push(new Ir(this.constants_)):this.bottomRow.elements.push(new vr(this.constants_)),this.bottomRow.hasNextConnection&&(this.bottomRow.connection=new Om(this.constants_,this.block_.nextConnection),this.bottomRow.elements.push(this.bottomRow.connection)),this.bottomRow.hasRightSquareCorner(this.block_)?this.bottomRow.elements.push(new Ir(this.constants_,"right")):this.bottomRow.elements.push(new vr(this.constants_,"right"))}addInput_(e,t){this.isInline&&e instanceof r.ValueInput$$module$build$src$core$inputs$value_input?(t.elements.push(new ih(this.constants_,e)),t.hasInlineInput=!0):e instanceof Yt?(t.elements.push(new bl(this.constants_,e)),t.hasStatement=!0):e instanceof r.ValueInput$$module$build$src$core$inputs$value_input?(t.elements.push(new oh(this.constants_,e)),t.hasExternalInput=!0):(e instanceof Io||e instanceof Yo)&&(t.minHeight=Math.max(t.minHeight,e.getSourceBlock()&&e.getSourceBlock().isShadow()?this.constants_.DUMMY_INPUT_SHADOW_MIN_HEIGHT:this.constants_.DUMMY_INPUT_MIN_HEIGHT),t.hasDummyInput=!0),t.align===null&&(t.align=e.align)}shouldStartNewRow_(e,t){return t?t instanceof Yo||e instanceof Yt||t instanceof Yt?!0:e instanceof r.ValueInput$$module$build$src$core$inputs$value_input||e instanceof Io||t instanceof r.ValueInput$$module$build$src$core$inputs$value_input?!this.isInline:!1:!1}addElemSpacing_(){for(let e=0,t;t=this.rows[e];e++){const o=t.elements;if(t.elements=[],t.startsWithElemSpacer()&&t.elements.push(new Xt(this.constants_,this.getInRowSpacing_(null,o[0]))),o.length){for(let s=0;s<o.length-1;s++){t.elements.push(o[s]);const i=this.getInRowSpacing_(o[s],o[s+1]);t.elements.push(new Xt(this.constants_,i))}t.elements.push(o[o.length-1]),t.endsWithElemSpacer()&&t.elements.push(new Xt(this.constants_,this.getInRowSpacing_(o[o.length-1],null)))}}}getInRowSpacing_(e,t){if(!e&&t&&T.isStatementInput(t))return this.constants_.STATEMENT_INPUT_PADDING_LEFT;if(e&&T.isInput(e)&&!t){if(T.isExternalInput(e))return this.constants_.NO_PADDING;if(T.isInlineInput(e))return this.constants_.LARGE_PADDING;if(T.isStatementInput(e))return this.constants_.NO_PADDING}return e&&T.isLeftSquareCorner(e)&&t&&(T.isPreviousConnection(t)||T.isNextConnection(t))?t.notchOffset:e&&T.isLeftRoundedCorner(e)&&t&&(T.isPreviousConnection(t)||T.isNextConnection(t))?t.notchOffset-this.constants_.CORNER_RADIUS:e&&T.isField(e)&&e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING}computeBounds_(){let e=0,t=0,o=0;for(let i=0,n;n=this.rows[i];i++){if(n.measure(),t=Math.max(t,n.width),n.hasStatement){var s=n.getLastInput();let d,f;s=n.width-((f=(d=s)==null?void 0:d.width)!=null?f:0),e=Math.max(e,s)}o=Math.max(o,n.widthWithConnectedBlocks)}this.statementEdge=e,this.width=t;for(let i=0,n;n=this.rows[i];i++)n.hasStatement&&(n.statementEdge=this.statementEdge);this.widthWithChildren=Math.max(t,o),this.outputConnection&&(this.startX=this.outputConnection.width,this.width+=this.outputConnection.width,this.widthWithChildren+=this.outputConnection.width)}alignRowElements_(){for(let t=0,o;o=this.rows[t];t++)if(o.hasStatement)this.alignStatementRow_(o);else{var e=o.width;e=this.getDesiredRowWidth_(o)-e,e>0&&this.addAlignmentPadding_(o,e),T.isTopOrBottomRow(o)&&(o.widthWithConnectedBlocks=o.width)}}getDesiredRowWidth_(e){return this.width-this.startX}addAlignmentPadding_(e,t){const o=e.getFirstSpacer(),s=e.getLastSpacer();if((e.hasExternalInput||e.hasStatement)&&(e.widthWithConnectedBlocks+=t),e.align===r.Align$$module$build$src$core$inputs$align.LEFT&&s)s.width+=t;else if(e.align===r.Align$$module$build$src$core$inputs$align.CENTRE&&o&&s)o.width+=t/2,s.width+=t/2;else if(e.align===r.Align$$module$build$src$core$inputs$align.RIGHT&&o)o.width+=t;else if(s)s.width+=t;else return;e.width+=t}alignStatementRow_(e){const t=e.getLastInput();if(t){var o=e.width-t.width,s=this.statementEdge;o=s-o,o>0&&this.addAlignmentPadding_(e,o),o=e.width,s=this.getDesiredRowWidth_(e),t.width+=s-o,t.height=Math.max(t.height,e.height),e.width+=s-o,e.widthWithConnectedBlocks=Math.max(e.width,this.statementEdge+e.connectedBlockWidths)}}addRowSpacing_(){const e=this.rows;this.rows=[];for(let t=0;t<e.length;t++)this.rows.push(e[t]),t!==e.length-1&&this.rows.push(this.makeSpacerRow_(e[t],e[t+1]))}makeSpacerRow_(e,t){var o=this.getSpacerRowHeight_(e,t);const s=this.getSpacerRowWidth_(e,t);return o=new nh(this.constants_,o,s),e.hasStatement&&(o.followsStatement=!0),t.hasStatement&&(o.precedesStatement=!0),o}getSpacerRowWidth_(e,t){return this.width-this.startX}getSpacerRowHeight_(e,t){return this.constants_.MEDIUM_PADDING}getElemCenterline_(e,t){return T.isSpacer(t)?e.yPos+t.height/2:T.isBottomRow(e)?(e=e.yPos+e.height-e.descenderHeight,T.isNextConnection(t)?e+t.height/2:e-t.height/2):T.isTopRow(e)?T.isHat(t)?e.capline-t.height/2:e.capline+t.height/2:e.yPos+e.height/2}recordElemPositions_(e){let t=e.xPos;for(let o=0,s;s=e.elements[o];o++)T.isSpacer(s)&&(s.height=e.height),s.xPos=t,s.centerline=this.getElemCenterline_(e,s),t+=s.width}finalize_(){let e=0,t=0;for(let o=0,s;s=this.rows[o];o++)s.yPos=t,s.xPos=this.startX,t+=s.height,e=Math.max(e,s.widthWithConnectedBlocks),this.recordElemPositions_(s);if(this.outputConnection&&this.block_.nextConnection){const o=this.block_.nextConnection.targetBlock();o&&(e=Math.max(e,o.getHeightWidth().width))}this.widthWithChildren=e+this.startX,this.height=t,this.startY=this.topRow.capline,this.bottomRow.baseline=t-this.bottomRow.descenderHeight}getMeasureableForConnection(e){let t;if(((t=this.outputConnection)==null?void 0:t.connectionModel)===e)return this.outputConnection;for(const o of this.rows)for(const s of o.elements)if(s instanceof Us&&s.connectionModel===e)return s;return null}},yl=class{constructor(e,t,o){this.connectionHighlights=new WeakMap,this.highlightOffsets=new WeakMap,this.constants=o,this.style=t,this.svgRoot=e,this.svgPath=v(R.PATH,{class:"blocklyPath"},this.svgRoot),this.setClass_("blocklyBlock",!0)}setPath(e){this.svgPath.setAttribute("d",e)}flipRTL(){this.svgPath.setAttribute("transform","scale(-1 1)")}applyColour(e){this.svgPath.setAttribute("stroke",this.style.colourTertiary),this.svgPath.setAttribute("fill",this.style.colourPrimary),this.updateShadow_(e.isShadow()),this.updateDisabled_(!e.isEnabled()||e.getInheritedDisabled())}setStyle(e){this.style=e}setClass_(e,t){e&&(t?G(this.svgRoot,e):Te(this.svgRoot,e))}updateHighlighted(e){e?this.setClass_("blocklyHighlighted",!0):this.setClass_("blocklyHighlighted",!1)}updateShadow_(e){e?(this.setClass_("blocklyShadow",!0),this.svgPath.setAttribute("stroke","none"),this.svgPath.setAttribute("fill",this.style.colourSecondary)):this.setClass_("blocklyShadow",!1)}updateDisabled_(e){this.setClass_("blocklyDisabled",e),this.setClass_("blocklyDisabledPattern",e)}updateSelected(e){this.setClass_("blocklySelected",e)}updateDraggingDelete(e){this.setClass_("blocklyDraggingDelete",e)}updateInsertionMarker(e){this.setClass_("blocklyInsertionMarker",e)}updateMovable(e){this.setClass_("blocklyDraggable",e)}updateReplacementFade(e){this.setClass_("blocklyReplaceable",e)}updateShapeForInputHighlight(e,t){}addConnectionHighlight(e,t,o,s){return o=`translate(${o.x}, ${o.y})`+(s?" scale(-1 1)":""),(s=this.connectionHighlights.get(e))?(s.setAttribute("d",t),s.setAttribute("transform",o),s):(t=v(R.PATH,{id:e.id,class:"blocklyHighlightedConnectionPath",style:"display: none;",d:t,transform:o},this.svgRoot),this.connectionHighlights.set(e,t),t)}removeConnectionHighlight(e){const t=this.connectionHighlights.get(e);t&&(ke(t),this.connectionHighlights.delete(e))}},vl=class{constructor(e){this.overrides=null,this.name=e}getClassName(){return this.name+"-renderer"}init(e,t){this.constants_=this.makeConstants_(),t&&(this.overrides=t,Object.assign(this.constants_,t)),this.constants_.setTheme(e),this.constants_.init()}createDom(e,t,o){this.constants_.createDom(e,this.name+"-"+t.name,"."+this.getClassName()+"."+t.getClassName(),o)}refreshDom(e,t,o){const s=this.getConstants();s.dispose(),this.constants_=this.makeConstants_(),this.overrides&&Object.assign(this.constants_,this.overrides),this.constants_.randomIdentifier=s.randomIdentifier,this.constants_.setTheme(t),this.constants_.init(),this.createDom(e,t,o)}dispose(){this.constants_&&this.constants_.dispose()}makeConstants_(){return new Tl}makeRenderInfo_(e){return new Cr(this,e)}makeDrawer_(e,t){return new El(e,t)}makePathObject(e,t){return new yl(e,t,this.constants_)}getConstants(){return this.constants_}shouldHighlightConnection(e){return!0}orphanCanConnectAtEnd(e,t,o){return!!Ce.getConnectionForOrphanedConnection(e,o===Z.OUTPUT_VALUE?t.outputConnection:t.previousConnection)}render(e){const t=this.makeRenderInfo_(e);t.measure(),this.makeDrawer_(e,t).draw()}},Ne={};Ne.BottomRow=th,Ne.Connection=Us,Ne.ConstantProvider=Tl,Ne.Drawer=El,Ne.ExternalValueInput=oh,Ne.Field=sh,Ne.Hat=km,Ne.Icon=Rm,Ne.InRowSpacer=Xt,Ne.InlineInput=ih,Ne.InputConnection=_l,Ne.InputRow=rh,Ne.JaggedEdge=wm,Ne.Measurable=So,Ne.NextConnection=Om,Ne.OutputConnection=Nm,Ne.PathObject=yl,Ne.PreviousConnection=Am,Ne.RenderInfo=Cr,Ne.Renderer=vl,Ne.RoundCorner=vr,Ne.Row=yr,Ne.SpacerRow=nh,Ne.SquareCorner=Ir,Ne.StatementInput=bl,Ne.TopRow=lh,Ne.Types=T,Ne.init=bu,Ne.register=Zi,Ne.unregister=$p;var Lm=class{constructor(e,t){this.workspace=e,this.theme=t,this.subscribedWorkspaces=[],this.componentDB=new Map}getTheme(){return this.theme}setTheme(e){var t=this.theme;this.theme=e,(e=this.workspace.getInjectionDiv())&&(t&&(t=t.getClassName())&&Te(e,t),(t=this.theme.getClassName())&&G(e,t));for(let o=0,s;s=this.subscribedWorkspaces[o];o++)s.refreshTheme();for(const[o,s]of this.componentDB)for(const i of s){e=i.element,t=i.propertyName;const n=this.theme&&this.theme.getComponentStyle(o);e.style.setProperty(t,n||"")}for(const o of this.subscribedWorkspaces)o.hideChaff()}subscribeWorkspace(e){this.subscribedWorkspaces.push(e)}unsubscribeWorkspace(e){if(!x(this.subscribedWorkspaces,e))throw Error("Cannot unsubscribe a workspace that hasn't been subscribed.")}subscribe(e,t,o){this.componentDB.has(t)||this.componentDB.set(t,[]),this.componentDB.get(t).push({element:e,propertyName:o}),t=this.theme&&this.theme.getComponentStyle(t),e.style.setProperty(o,t||"")}unsubscribe(e){if(e)for(const[t,o]of this.componentDB){for(let s=o.length-1;s>=0;s--)o[s].element===e&&o.splice(s,1);o.length||this.componentDB.delete(t)}}dispose(){this.subscribedWorkspaces.length=0,this.componentDB.clear()}},ch="VARIABLE_DYNAMIC",hs={CATEGORY_NAME:ch};hs.flyoutCategory=Tu,hs.flyoutCategoryBlocks=Eu,hs.internalFlyoutCategory=Sn,hs.onCreateVariableButtonClick_Colour=Cn,hs.onCreateVariableButtonClick_Number=In,hs.onCreateVariableButtonClick_String=vn;var Mm=class{canConnect(e,t,o,s){return this.canConnectWithReason(e,t,o,s)===Ce.CAN_CONNECT}canConnectWithReason(e,t,o,s){const i=this.doSafetyChecks(e,t);return i!==Ce.CAN_CONNECT?i:this.doTypeChecks(e,t)?o&&!this.doDragChecks(e,t,s||0)?Ce.REASON_DRAG_CHECKS_FAILED:Ce.CAN_CONNECT:Ce.REASON_CHECKS_FAILED}getErrorMessage(e,t,o){switch(e){case Ce.REASON_SELF_CONNECTION:return"Attempted to connect a block to itself.";case Ce.REASON_DIFFERENT_WORKSPACES:return"Blocks not on same workspace.";case Ce.REASON_WRONG_TYPE:return"Attempt to connect incompatible types.";case Ce.REASON_TARGET_NULL:return"Target connection is null.";case Ce.REASON_CHECKS_FAILED:return"Connection checks failed. "+(t+" expected "+t.getCheck()+", found "+o.getCheck());case Ce.REASON_SHADOW_PARENT:return"Connecting non-shadow to shadow block.";case Ce.REASON_DRAG_CHECKS_FAILED:return"Drag checks failed.";case Ce.REASON_PREVIOUS_AND_OUTPUT:return"Block would have an output and a previous connection.";default:return"Unknown connection failure: this should never happen!"}}doSafetyChecks(e,t){if(!e||!t)return Ce.REASON_TARGET_NULL;let o,s,i;return e.isSuperior()?(o=e.getSourceBlock(),s=t.getSourceBlock(),i=t):(s=e.getSourceBlock(),o=t.getSourceBlock(),i=e,e=t),o===s?Ce.REASON_SELF_CONNECTION:i.type!==Fs[e.type]?Ce.REASON_WRONG_TYPE:o.workspace!==s.workspace?Ce.REASON_DIFFERENT_WORKSPACES:o.isShadow()&&!s.isShadow()?Ce.REASON_SHADOW_PARENT:i.type===Z.OUTPUT_VALUE&&s.previousConnection&&s.previousConnection.isConnected()||i.type===Z.PREVIOUS_STATEMENT&&s.outputConnection&&s.outputConnection.isConnected()?Ce.REASON_PREVIOUS_AND_OUTPUT:Ce.CAN_CONNECT}doTypeChecks(e,t){if(e=e.getCheck(),t=t.getCheck(),!e||!t)return!0;for(let o=0;o<e.length;o++)if(t.includes(e[o]))return!0;return!1}doDragChecks(e,t,o){if(e.distanceFrom(t)>o||t.getSourceBlock().isInsertionMarker())return!1;switch(t.type){case Z.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(e,t);case Z.OUTPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isInsertionMarker()||e.isConnected())return!1;break;case Z.INPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isMovable()&&!t.targetBlock().isShadow())return!1;break;case Z.NEXT_STATEMENT:if(t.isConnected()&&!e.getSourceBlock().nextConnection&&!t.targetBlock().isShadow()&&t.targetBlock().nextConnection||t.targetBlock()&&!t.targetBlock().isMovable()&&!t.targetBlock().isShadow())return!1;break;default:return!1}return!rr.includes(t)}canConnectToPrevious_(e,t){return e.targetConnection||rr.includes(t)?!1:t.targetConnection?(e=t.targetBlock(),e.isInsertionMarker()?!e.getPreviousBlock():!1):!0}};l(M.CONNECTION_CHECKER,Ft,Mm);var ki=class{get isFlyout(){return this.internalIsFlyout}get isMutator(){return this.internalIsMutator}constructor(e){this.isClearing=this.internalIsMutator=this.internalIsFlyout=this.rendered=!1,this.MAX_UNDO=1024,this.connectionDBList=[],this.topBlocks=[],this.topComments=[],this.commentDB=new Map,this.listeners=[],this.undoStack_=[],this.redoStack_=[],this.blockDB=new Map,this.typedBlocksDB=new Map,this.procedureMap=new Sm,this.readOnly=!1,this.potentialVariableMap=null,this.id=rt(),st(this),this.options=e||new vo({}),this.RTL=!!this.options.RTL,this.horizontalLayout=!!this.options.horizontalLayout,this.toolboxPosition=this.options.toolboxPosition,this.connectionChecker=new(W(M.CONNECTION_CHECKER,this.options,!0))(this),this.variableMap=new(this.getVariableMapClass())(this),this.setIsReadOnly(this.options.readOnly)}dispose(){this.listeners.length=0,this.clear(),Ut(this)}sortObjects(e,t){const o=s=>({getBoundingRectangle:()=>{const i=s.getRelativeToSurfaceXY();return new ye(i.y,i.y,i.x,i.x)},moveBy:()=>{}});return this.sortByOrigin(o(e),o(t))}sortByOrigin(e,t){const o=Math.sin(en(ki.SCAN_ANGLE))*(this.RTL?-1:1);return e=e.getBoundingRectangle().getOrigin(),t=t.getBoundingRectangle().getOrigin(),e.y+o*e.x-(t.y+o*t.x)}addTopBlock(e){this.topBlocks.push(e)}removeTopBlock(e){if(!x(this.topBlocks,e))throw Error("Block not present in workspace's list of top-most blocks.")}getTopBlocks(e=!1){const t=[].concat(this.topBlocks);return e&&t.length>1&&t.sort(this.sortObjects.bind(this)),t}addTypedBlock(e){this.typedBlocksDB.has(e.type)||this.typedBlocksDB.set(e.type,[]),this.typedBlocksDB.get(e.type).push(e)}removeTypedBlock(e){x(this.typedBlocksDB.get(e.type),e),this.typedBlocksDB.get(e.type).length||this.typedBlocksDB.delete(e.type)}getBlocksByType(e,t=!1){return this.typedBlocksDB.has(e)?(e=this.typedBlocksDB.get(e).slice(0),t&&e&&e.length>1&&e.sort(this.sortObjects.bind(this)),e.filter(o=>!o.isInsertionMarker())):[]}addTopComment(e){this.topComments.push(e),this.commentDB.has(e.id)&&console.warn('Overriding an existing comment on this workspace, with id "'+e.id+'"'),this.commentDB.set(e.id,e)}removeTopComment(e){if(!x(this.topComments,e))throw Error("Comment not present in workspace's list of top-most comments.");this.commentDB.delete(e.id)}getTopComments(e=!1){const t=[].concat(this.topComments);return e&&t.length>1&&t.sort(this.sortObjects.bind(this)),t}getAllBlocks(e=!1){if(e){var t=this.getTopBlocks(!0);e=[];for(let o=0;o<t.length;o++)e.push(...t[o].getDescendants(!0))}else for(e=this.getTopBlocks(!1),t=0;t<e.length;t++)e.push(...e[t].getChildren(!1));return e.filter(o=>!o.isInsertionMarker())}clear(){this.isClearing=!0;try{const e=r.getGroup$$module$build$src$core$events$utils();for(e||r.setGroup$$module$build$src$core$events$utils(!0);this.topBlocks.length;)this.topBlocks[0].dispose(!1);for(;this.topComments.length;)this.topComments[this.topComments.length-1].dispose();r.setGroup$$module$build$src$core$events$utils(e),this.isFlyout||this.variableMap.clear(),this.potentialVariableMap&&this.potentialVariableMap.clear()}finally{this.isClearing=!1}}renameVariableById(e,t){pt("Blockly.Workspace.renameVariableById","v12","v13","Blockly.Workspace.getVariableMap().renameVariable"),(e=this.variableMap.getVariableById(e))&&this.variableMap.renameVariable(e,t)}createVariable(e,t,o){return pt("Blockly.Workspace.createVariable","v12","v13","Blockly.Workspace.getVariableMap().createVariable"),this.variableMap.createVariable(e,t??void 0,o??void 0)}getVariableUsesById(e){return pt("Blockly.Workspace.getVariableUsesById","v12","v13","Blockly.Workspace.getVariableMap().getVariableUsesById"),qs(this,e)}deleteVariableById(e){pt("Blockly.Workspace.deleteVariableById","v12","v13","Blockly.Workspace.getVariableMap().deleteVariable");const t=this.variableMap.getVariableById(e);t?r.deleteVariable$$module$build$src$core$variables(this,t):console.warn(`Can't delete non-existent variable: ${e}`)}getVariable(e,t){return pt("Blockly.Workspace.getVariable","v12","v13","Blockly.Workspace.getVariableMap().getVariable"),this.variableMap.getVariable(e,t)}getVariableById(e){return pt("Blockly.Workspace.getVariableById","v12","v13","Blockly.Workspace.getVariableMap().getVariableById"),this.variableMap.getVariableById(e)}getVariablesOfType(e){return pt("Blockly.Workspace.getVariablesOfType","v12","v13","Blockly.Workspace.getVariableMap().getVariablesOfType"),this.variableMap.getVariablesOfType(e??"")}getAllVariables(){return pt("Blockly.Workspace.getAllVariables","v12","v13","Blockly.Workspace.getVariableMap().getAllVariables"),this.variableMap.getAllVariables()}getAllVariableNames(){return pt("Blockly.Workspace.getAllVariableNames","v12","v13","Blockly.Workspace.getVariableMap().getAllVariables"),this.variableMap.getAllVariables().map(e=>e.getName())}getWidth(){return 0}newBlock(e,t){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts")}newComment(e){throw Error("The implementation of newComment should be monkey-patched in by blockly.ts")}remainingCapacity(){return isNaN(this.options.maxBlocks)?1/0:this.options.maxBlocks-this.getAllBlocks(!1).length}remainingCapacityOfType(e){return this.options.maxInstances?(this.options.maxInstances[e]!==void 0?this.options.maxInstances[e]:1/0)-this.getBlocksByType(e,!1).length:1/0}isCapacityAvailable(e){if(!this.hasBlockLimits())return!0;let t=0;for(const o in e){if(e[o]>this.remainingCapacityOfType(o))return!1;t+=e[o]}return!(t>this.remainingCapacity())}hasBlockLimits(){return this.options.maxBlocks!==1/0||!!this.options.maxInstances}getUndoStack(){return this.undoStack_}getRedoStack(){return this.redoStack_}undo(e){var t=e?this.redoStack_:this.undoStack_,o=e?this.undoStack_:this.redoStack_;const s=t.pop();if(s){for(var i=[s];t.length&&s.group&&s.group===t[t.length-1].group;){const n=t.pop();n&&i.push(n)}for(t=0;t<i.length;t++)o.push(i[t]);r.setRecordUndo$$module$build$src$core$events$utils(!1);try{for(o=0;o<i.length;o++)i[o].run(e)}finally{r.setRecordUndo$$module$build$src$core$events$utils(!0)}}}clearUndo(){this.undoStack_.length=0,this.redoStack_.length=0,he()}addChangeListener(e){return this.listeners.push(e),e}removeChangeListener(e){x(this.listeners,e)}fireChangeListener(e){if(e.recordUndo)for(this.undoStack_.push(e),this.redoStack_.length=0;this.undoStack_.length>this.MAX_UNDO&&this.MAX_UNDO>=0;)this.undoStack_.shift();for(let t=0;t<this.listeners.length;t++)(0,this.listeners[t])(e)}getBlockById(e){return this.blockDB.get(e)||null}setBlockById(e,t){this.blockDB.set(e,t)}removeBlockById(e){this.blockDB.delete(e)}getCommentById(e){let t;return(t=this.commentDB.get(e))!=null?t:null}allInputsFilled(e){const t=this.getTopBlocks(!1);for(let o=0;o<t.length;o++)if(!t[o].allInputsFilled(e))return!1;return!0}getPotentialVariableMap(){return this.potentialVariableMap}createPotentialVariableMap(){this.potentialVariableMap=new(this.getVariableMapClass())(this,!0)}getVariableMap(){return this.variableMap}setVariableMap(e){this.variableMap=e}getProcedureMap(){return this.procedureMap}getRootWorkspace(){let e=null;const t=this.options.parentWorkspace;return this.isFlyout?t&&t.options&&(e=t.options.parentWorkspace):t&&(e=t),e}static getById(e){return ct(e)}static getAll(){return kt()}getVariableMapClass(){const e=W(M.VARIABLE_MAP,this.options,!0);if(!e)throw Error("No variable map is registered.");return e}isReadOnly(){return this.readOnly}setIsReadOnly(e){this.readOnly=e,this.options.readOnly=e}};ki.SCAN_ANGLE=3;var Lb=100,Dm=class{constructor(e){this.parentWorkspace=e,this.sounds=new Map,this.lastSound=null,this.muted=!1}dispose(){this.sounds.clear()}load(e,t){if(e.length){try{var o=new globalThis.Audio}catch{return}for(let i=0;i<e.length;i++){const n=e[i],d=n.match(/\.(\w+)$/);if(d&&o.canPlayType("audio/"+d[1])){var s=new globalThis.Audio(n);break}}s&&this.sounds.set(t,s)}}preload(){for(const e of this.sounds.values()){e.volume=.01;const t=e.play();if(t!==void 0?t.then(e.pause).catch(function(){}):e.pause(),Bn||Vp)break}}play(e,t){if(!this.muted){var o=this.sounds.get(e);o?(e=new Date,this.lastSound!==null&&e.getTime()-this.lastSound.getTime()<Lb||(this.lastSound=e,o=Bn||oa?o:o.cloneNode(),o.volume=t===void 0?1:t,o.play())):this.parentWorkspace&&this.parentWorkspace.getAudioManager().play(e,t)}}setMuted(e){this.muted=e}getMuted(){return this.muted}},Mb=20,At=class extends ki{constructor(e){super(e),this.resizeHandlerWrapper=null,this.resizesEnabled=this.visible=this.rendered=!0,this.startScrollY=this.startScrollX=this.scrollY=this.scrollX=0,this.oldScale=this.scale=1,this.oldLeft=this.oldTop=0,this.inverseScreenCTM=this.targetWorkspace=this.dummyWheelListener=this.configureContextMenu=this.lastRecordedPageScroll=this.injectionDiv=this.currentGesture_=this.toolbox=this.flyout=this.scrollbar=this.trashcan=null,this.inverseScreenCTMDirty=!0,this.highlightedBlocks=[],this.toolboxCategoryCallbacks=new Map,this.flyoutButtonCallbacks=new Map,this.cachedParentSvg=null,this.keyboardMoveInProgress=this.keyboardAccessibilityMode=!1,this.topBoundedElements=[],this.dragTargetAreas=[],this.zoomControls_=this.layerManager=null,this.navigator=new Xa,this.metricsManager=new(W(M.METRICS_MANAGER,e,!0))(this),this.getMetrics=e.getMetrics||this.metricsManager.getMetrics.bind(this.metricsManager),this.setMetrics=e.setMetrics||At.setTopLevelWorkspaceMetrics,this.componentManager=new Ve,this.connectionDBList=Ei.init(this.connectionChecker),this.audioManager=new Dm(e.parentWorkspace),this.grid=this.options.gridPattern?new Ka(this.options.gridPattern,e.gridOptions):null,this.markerManager=new qa(this),et&&Kr&&this.registerToolboxCategoryCallback(va,Kr),hs&&Sn&&this.registerToolboxCategoryCallback(ch,Sn),Nt&&En&&(this.registerToolboxCategoryCallback(fl,En),this.addChangeListener(fu)),this.addChangeListener(this.variableChangeCallback.bind(this)),this.themeManager_=this.options.parentWorkspace?this.options.parentWorkspace.getThemeManager():new Lm(this,this.options.theme||ll),this.themeManager_.subscribeWorkspace(this);let t;this.renderer=bu(this.options.renderer||"geras",this.getTheme(),(t=this.options.rendererOverrides)!=null?t:void 0),this.cachedParentSvgSize=new ve(0,0)}getMarkerManager(){return this.markerManager}getMetricsManager(){return this.metricsManager}setMetricsManager(e){this.metricsManager=e,this.getMetrics=this.metricsManager.getMetrics.bind(this.metricsManager)}getComponentManager(){return this.componentManager}getMarker(e){return this.markerManager.getMarker(e)}getCursor(){return this.markerManager.getCursor()}getRenderer(){return this.renderer}getThemeManager(){return this.themeManager_}getTheme(){return this.themeManager_.getTheme()}setTheme(e){e||(e=ll),this.themeManager_.setTheme(e)}refreshTheme(){if(this.svgGroup_){var e=this.options.parentWorkspace===null;this.renderer.refreshDom(this.svgGroup_,this.getTheme(),e?this.getInjectionDiv():void 0)}this.updateBlockStyles(this.getAllBlocks(!1).filter(t=>!!t.getStyleName())),this.refreshToolboxSelection(),this.toolbox&&this.toolbox.refreshTheme(),this.isVisible()&&this.setVisible(!0),e=new(U(w.THEME_CHANGE))(this.getTheme().name,this.id),_(e)}updateBlockStyles(e){for(let t=0,o;o=e[t];t++){const s=o.getStyleName();s&&o.setStyle(s)}}getInverseScreenCTM(){if(this.inverseScreenCTMDirty){const e=this.getParentSvg().getScreenCTM();e&&(this.inverseScreenCTM=e.inverse(),this.inverseScreenCTMDirty=!1)}return this.inverseScreenCTM}updateInverseScreenCTM(){this.inverseScreenCTMDirty=!0}isVisible(){return this.visible}getSvgXY(e){let t=0,o=0,s=1;(this.getCanvas().contains(e)||this.getBubbleCanvas().contains(e))&&(s=this.scale);do{const i=xi(e);(e===this.getCanvas()||e===this.getBubbleCanvas())&&(s=1),t+=i.x*s,o+=i.y*s,e=e.parentNode}while(e&&e!==this.getParentSvg()&&e!==this.getInjectionDiv());return new P(t,o)}getCachedParentSvgSize(){const e=this.cachedParentSvgSize;return new ve(e.width,e.height)}getOriginOffsetInPixels(){return Br(this.getCanvas())}getInjectionDiv(){if(!this.injectionDiv){let e=this.svgGroup_;for(;e;){if((" "+(e.getAttribute("class")||"")+" ").includes(" injectionDiv ")){this.injectionDiv=e;break}e=e.parentNode}}return this.injectionDiv}getSvgGroup(){return this.svgGroup_}getBlockCanvas(){return this.getCanvas()}setResizeHandlerWrapper(e){this.resizeHandlerWrapper=e}createDom(e,t){return this.injectionDiv||(this.injectionDiv=t??null),this.svgGroup_=v(R.G,{class:"blocklyWorkspace",id:this.id}),t&&it(this.svgGroup_,Qe.LABEL,r.Msg$$module$build$src$core$msg.WORKSPACE_ARIA_LABEL),e&&(this.svgBackground_=v(R.RECT,{height:"100%",width:"100%",class:e},this.svgGroup_),e==="blocklyMainBackground"&&this.grid?this.svgBackground_.style.fill="var(--blocklyGridPattern)":this.themeManager_.subscribe(this.svgBackground_,"workspaceBackgroundColour","fill")),this.layerManager=new Nb(this),this.svgBlockCanvas_=this.layerManager.getBlockLayer(),this.svgBubbleCanvas_=this.layerManager.getBubbleLayer(),this.isFlyout||(z(this.svgGroup_,"pointerdown",this,this.onMouseDown,!1),this.dummyWheelListener=()=>{},document.body.addEventListener("wheel",this.dummyWheelListener),z(this.svgGroup_,"wheel",this,this.onMouseWheel)),this.options.hasCategories&&(this.toolbox=new(W(M.TOOLBOX,this.options,!0))(this)),this.grid&&this.grid.update(this.scale),this.recordDragTargets(),(e=W(M.CURSOR,this.options))&&this.markerManager.setCursor(new e(this)),e=this.options.parentWorkspace===null,this.renderer.createDom(this.svgGroup_,this.getTheme(),e?this.getInjectionDiv():void 0),r.getFocusManager$$module$build$src$core$focus_manager().registerTree(this,!!this.injectionDiv||this.isFlyout),this.svgGroup_}dispose(){if(this.rendered=!1,this.currentGesture_&&this.currentGesture_.cancel(),this.svgGroup_&&ke(this.svgGroup_),this.toolbox&&(this.toolbox.dispose(),this.toolbox=null),this.flyout&&(this.flyout.dispose(),this.flyout=null),this.trashcan&&(this.trashcan.dispose(),this.trashcan=null),this.scrollbar&&(this.scrollbar.dispose(),this.scrollbar=null),this.zoomControls_&&this.zoomControls_.dispose(),this.audioManager&&this.audioManager.dispose(),this.grid&&(this.grid=null),this.renderer.dispose(),this.markerManager.dispose(),super.dispose(),this.themeManager_&&(this.themeManager_.unsubscribeWorkspace(this),this.themeManager_.unsubscribe(this.svgBackground_),this.options.parentWorkspace||this.themeManager_.dispose()),this.connectionDBList.length=0,this.toolboxCategoryCallbacks.clear(),this.flyoutButtonCallbacks.clear(),!this.options.parentWorkspace){const e=this.getParentSvg();e&&e.parentNode&&ke(e.parentNode)}this.resizeHandlerWrapper&&(te(this.resizeHandlerWrapper),this.resizeHandlerWrapper=null),this.dummyWheelListener&&(document.body.removeEventListener("wheel",this.dummyWheelListener),this.dummyWheelListener=null),r.getFocusManager$$module$build$src$core$focus_manager().isRegistered(this)&&r.getFocusManager$$module$build$src$core$focus_manager().unregisterTree(this)}addTrashcan(){this.trashcan=At.newTrashcan(this);const e=this.trashcan.createDom();this.svgGroup_.insertBefore(e,this.getCanvas())}static newTrashcan(e){throw Error("The implementation of newTrashcan should be monkey-patched in by blockly.ts")}addZoomControls(){this.zoomControls_=new ug(this);const e=this.zoomControls_.createDom();this.svgGroup_.appendChild(e)}copyOptionsForFlyout(){return new vo({parentWorkspace:this,rtl:this.RTL,oneBasedIndex:this.options.oneBasedIndex,horizontalLayout:this.horizontalLayout,renderer:this.options.renderer,rendererOverrides:this.options.rendererOverrides,plugins:this.options.plugins,modalInputs:this.options.modalInputs,move:{scrollbars:!0}})}addFlyout(e){const t=this.copyOptionsForFlyout();return t.toolboxPosition=this.options.toolboxPosition,this.flyout=this.horizontalLayout?new(W(M.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(t):new(W(M.FLYOUTS_VERTICAL_TOOLBOX,this.options,!0))(t),this.flyout.autoClose=!1,this.flyout.getWorkspace().setVisible(!0),this.flyout.createDom(e)}getFlyout(e){return this.flyout||e?this.flyout:this.toolbox?this.toolbox.getFlyout():null}getToolbox(){return this.toolbox}updateScreenCalculations(){this.updateInverseScreenCTM(),this.recordDragTargets()}resizeContents(){this.resizesEnabled&&this.rendered&&(this.scrollbar&&this.scrollbar.resize(),this.updateInverseScreenCTM())}resize(){this.toolbox?this.toolbox.position():this.flyout&&this.flyout.position();const e=this.componentManager.getComponents(Ve.Capability.POSITIONABLE,!0),t=this.getMetricsManager().getUiMetrics(),o=[];for(let s=0,i;i=e[s];s++){i.position(t,o);const n=i.getBoundingRectangle();n&&o.push(n)}this.scrollbar&&this.scrollbar.resize(),this.updateScreenCalculations()}updateScreenCalculationsIfScrolled(){const e=ql();P.equals(this.lastRecordedPageScroll,e)||(this.lastRecordedPageScroll=e,this.updateScreenCalculations())}getLayerManager(){return this.layerManager}getCanvas(){return this.layerManager.getBlockLayer()}setCachedParentSvgSize(e,t){const o=this.getParentSvg();e!=null&&(this.cachedParentSvgSize.width=e,o.setAttribute("data-cached-width",`${e}`)),t!=null&&(this.cachedParentSvgSize.height=t,o.setAttribute("data-cached-height",`${t}`))}getBubbleCanvas(){return this.layerManager.getBubbleLayer()}getParentSvg(){if(!this.cachedParentSvg){let e=this.svgGroup_;for(;e;){if(e.tagName==="svg"){this.cachedParentSvg=e;break}e=e.parentNode}}return this.cachedParentSvg}maybeFireViewportChangeEvent(){if(J()){var e=this.scale,t=-this.scrollY,o=-this.scrollX;if(!(e===this.oldScale&&Math.abs(t-this.oldTop)<1&&Math.abs(o-this.oldLeft)<1)){var s=new(U(w.VIEWPORT_CHANGE))(t,o,e,this.id,this.oldScale);this.oldScale=e,this.oldTop=t,this.oldLeft=o,_(s)}}}translate(e,t){let o;(o=this.layerManager)==null||o.translateLayers(new P(e,t),this.scale);let s;(s=this.grid)==null||s.moveTo(e,t),this.maybeFireViewportChangeEvent()}getWidth(){const e=this.getMetrics();return e?e.viewWidth/this.scale:0}setVisible(e){this.visible=e,this.svgGroup_&&(this.scrollbar&&this.scrollbar.setContainerVisible(e),this.getFlyout()&&this.getFlyout().setContainerVisible(e),this.getParentSvg().style.display=e?"block":"none",this.toolbox&&this.toolbox.setVisible(e),e||this.hideChaff(!0))}render(){const e=this.getAllBlocks(!1);for(let t=e.length-1;t>=0;t--)e[t].queueRender();this.getTopBlocks().flatMap(t=>t.getDescendants(!1)).filter(t=>t.isInsertionMarker()).forEach(t=>t.queueRender())}highlightBlock(e,t){if(t===void 0){for(let o=0,s;s=this.highlightedBlocks[o];o++)s.setHighlighted(!1);this.highlightedBlocks.length=0}(e=e?this.getBlockById(e):null)&&((t=t===void 0||t)?this.highlightedBlocks.includes(e)||this.highlightedBlocks.push(e):x(this.highlightedBlocks,e),e.setHighlighted(t))}variableChangeCallback(e){switch(e.type){case w.VAR_CREATE:case w.VAR_DELETE:case w.VAR_RENAME:case w.VAR_TYPE_CHANGE:this.refreshToolboxSelection()}}refreshToolboxSelection(){const e=this.isFlyout?this.targetWorkspace:this;e&&!e.currentGesture_&&e.toolbox&&e.toolbox.getFlyout()&&e.toolbox.refreshSelection()}recordDragTargets(){const e=this.componentManager.getComponents(Ve.Capability.DRAG_TARGET,!0);this.dragTargetAreas=[];for(let t=0,o;o=e[t];t++){const s=o.getClientRect();s&&this.dragTargetAreas.push({component:o,clientRect:s})}}newBlock(e,t){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts")}newComment(e){throw Error("The implementation of newComment should be monkey-patched in by blockly.ts")}getDragTarget(e){for(let t=0,o;o=this.dragTargetAreas[t];t++)if(o.clientRect.contains(e.clientX,e.clientY))return o.component;return null}onMouseDown(e){const t=this.getGesture(e);t&&t.handleWsStart(e,this)}startDrag(e,t){dn(this,e,t)}moveDrag(e){return $n(this,e)}setKeyboardMoveInProgress(e){this.keyboardMoveInProgress=e}isDragging(){return this.keyboardMoveInProgress||this.currentGesture_!==null&&this.currentGesture_.isDragging()}isDraggable(){return this.options.moveOptions&&this.options.moveOptions.drag}isMovable(){return this.options.moveOptions&&!!this.options.moveOptions.scrollbars||this.options.moveOptions&&this.options.moveOptions.wheel||this.options.moveOptions&&this.options.moveOptions.drag||this.options.zoomOptions&&this.options.zoomOptions.wheel||this.options.zoomOptions&&this.options.zoomOptions.pinch}isMovableHorizontally(){const e=!!this.scrollbar;return this.isMovable()&&(!e||e&&this.scrollbar.canScrollHorizontally())}isMovableVertically(){const e=!!this.scrollbar;return this.isMovable()&&(!e||e&&this.scrollbar.canScrollVertically())}onMouseWheel(e){if(ml.inProgress())e.preventDefault(),e.stopPropagation();else{var t=this.options.zoomOptions&&this.options.zoomOptions.wheel,o=this.options.moveOptions&&this.options.moveOptions.wheel;if(t||o){var s=It(e);if(sa)var i=e.metaKey;t&&(e.ctrlKey||i||!o)?(s=-s.y/50,t=Ye(e,this.getParentSvg(),this.getInverseScreenCTM()),this.zoom(t.x,t.y,s)):(t=this.scrollX-s.x,o=this.scrollY-s.y,e.shiftKey&&!s.x&&(t=this.scrollX-s.y,o=this.scrollY),this.scroll(t,o)),e.preventDefault()}}}getBlocksBoundingBox(){const e=this.getTopBoundedElements();if(!e.length)return new ye(0,0,0,0);const t=e[0].getBoundingRectangle();for(let s=1;s<e.length;s++){var o=e[s];o.isInsertionMarker&&o.isInsertionMarker()||(o=o.getBoundingRectangle(),o.top<t.top&&(t.top=o.top),o.bottom>t.bottom&&(t.bottom=o.bottom),o.left<t.left&&(t.left=o.left),o.right>t.right&&(t.right=o.right))}return t}cleanUp(){this.setResizesEnabled(!1),r.setGroup$$module$build$src$core$events$utils(!0);var e=this.getTopBlocks(!0),t=e.filter(n=>n.isMovable());const o=e.filter(n=>!n.isMovable()).map(n=>n.getBoundingRectangle());e=function(n){for(const d of o)if(n.intersects(d))return d;return null};var s=0;const i=this.renderer.getConstants().MIN_BLOCK_HEIGHT;for(const n of t){for(t=n.getBoundingRectangle(),n.moveBy(-t.left,s-t.top,["cleanup"]),n.snapToGrid(),t=n.getBoundingRectangle(),s=e(t);s!=null;)s=s.top+s.getHeight()+i,n.moveBy(0,s-t.top,["cleanup"]),n.snapToGrid(),t=n.getBoundingRectangle(),s=e(t);s=n.getRelativeToSurfaceXY().y+n.getHeightWidth().height+i}r.setGroup$$module$build$src$core$events$utils(!1),this.setResizesEnabled(!0)}showContextMenu(e){if(!this.isReadOnly()&&!this.isFlyout){var t=Ee.registry.getContextMenuOptions({workspace:this,focusedNode:this},e);this.configureContextMenu&&this.configureContextMenu(t,e);var o=e instanceof PointerEvent?new P(e.clientX,e.clientY):Ys(this,new P(5,5));ii(e,t,this.RTL,this,o)}}updateToolbox(e){if(e=Pr(e)){if(!this.options.languageTree)throw Error("Existing toolbox is null. Can't create new toolbox.");if(Fr(e)){if(!this.toolbox)throw Error("Existing toolbox has no categories. Can't change mode.");this.options.languageTree=e,this.toolbox.render(e)}else{if(!this.flyout)throw Error("Existing toolbox has categories. Can't change mode.");this.options.languageTree=e,this.flyout.show(e)}}else if(this.options.languageTree)throw Error("Can't nullify an existing toolbox.")}markFocused(){this.options.parentWorkspace?this.options.parentWorkspace.markFocused():(p(this),this.getParentSvg().focus({preventScroll:!0}))}zoom(e,t,o){o=Math.pow(this.options.zoomOptions.scaleSpeed,o);const s=this.scale*o;if(this.scale!==s){s>this.options.zoomOptions.maxScale?o=this.options.zoomOptions.maxScale/this.scale:s<this.options.zoomOptions.minScale&&(o=this.options.zoomOptions.minScale/this.scale);var i=this.getCanvas().getCTM(),n=this.getParentSvg().createSVGPoint();n.x=e,n.y=t,n=n.matrixTransform(i.inverse()),e=n.x,t=n.y,i=i.translate(e*(1-o),t*(1-o)).scale(o),this.scrollX=i.e,this.scrollY=i.f,this.setScale(s)}}zoomCenter(e){var t=this.getMetrics();let o;this.flyout?(o=t.svgWidth?t.svgWidth/2:0,t=t.svgHeight?t.svgHeight/2:0):(o=t.viewWidth/2+t.absoluteLeft,t=t.viewHeight/2+t.absoluteTop),this.zoom(o,t,e)}zoomToFit(){if(this.isMovable()){var e=this.getMetrics(),t=e.viewWidth;e=e.viewHeight;var o=this.getBlocksBoundingBox(),s=Mb*2,i=o.right-o.left+s;if(o=o.bottom-o.top+s,i){this.flyout&&(this.horizontalLayout?(e+=this.flyout.getHeight(),o+=this.flyout.getHeight()/this.scale):(t+=this.flyout.getWidth(),i+=this.flyout.getWidth()/this.scale)),t/=i,e/=o,r.disable$$module$build$src$core$events$utils();try{this.setScale(Math.min(t,e)),this.scrollCenter()}finally{r.enable$$module$build$src$core$events$utils()}this.maybeFireViewportChangeEvent()}}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}beginCanvasTransition(){G(this.getCanvas(),"blocklyCanvasTransitioning"),G(this.getBubbleCanvas(),"blocklyCanvasTransitioning")}endCanvasTransition(){Te(this.getCanvas(),"blocklyCanvasTransitioning"),Te(this.getBubbleCanvas(),"blocklyCanvasTransitioning")}scrollCenter(){if(this.isMovable()){var e=this.getMetrics(),t=(e.scrollWidth-e.viewWidth)/2,o=(e.scrollHeight-e.viewHeight)/2;t=-t-e.scrollLeft,o=-o-e.scrollTop,this.scroll(t,o)}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}centerOnBlock(e,t){if(this.isMovable()){var o=e?this.getBlockById(e):null;if(o){e=o.getRelativeToSurfaceXY(),o=t?{height:o.height,width:o.width}:o.getHeightWidth();var s=this.scale;t=(e.x+(this.RTL?-1:1)*o.width/2)*s,e=(e.y+o.height/2)*s,o=this.getMetrics(),this.scroll(-(t-o.viewWidth/2),-(e-o.viewHeight/2))}}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}setScale(e){this.options.zoomOptions.maxScale&&e>this.options.zoomOptions.maxScale?e=this.options.zoomOptions.maxScale:this.options.zoomOptions.minScale&&e<this.options.zoomOptions.minScale&&(e=this.options.zoomOptions.minScale),this.scale=e,this.hideChaff(!1),(e=this.getFlyout(!1))&&e.isVisible()&&(e.reflow(),this.recordDragTargets()),this.grid&&this.grid.update(this.scale),e=this.getMetrics(),this.scrollX-=e.absoluteLeft,this.scrollY-=e.absoluteTop,e.viewLeft+=e.absoluteLeft,e.viewTop+=e.absoluteTop,this.scroll(this.scrollX,this.scrollY),this.scrollbar&&(this.flyout?this.scrollbar.resizeView(e):this.scrollbar.resizeContent(e))}getScale(){return this.scale}getAbsoluteScale(){const e=o=>{if(o.isFlyout){let s;const i=(s=o.targetWorkspace)==null?void 0:s.getFlyout();if(i instanceof pl)return i.getFlyoutScale()}return o.getScale()},t=(o,s)=>o.options.parentWorkspace&&o.options.parentWorkspace.getSvgGroup().contains(o.getSvgGroup())?t(o.options.parentWorkspace,s*e(o)):s*e(o);return t(this,1)}scroll(e,t){this.hideChaff(!0);const o=this.getMetrics();e=Math.min(e,-o.scrollLeft),t=Math.min(t,-o.scrollTop);const s=o.scrollTop+Math.max(0,o.scrollHeight-o.viewHeight);e=Math.max(e,-(o.scrollLeft+Math.max(0,o.scrollWidth-o.viewWidth))),t=Math.max(t,-s),this.scrollX=e,this.scrollY=t,this.scrollbar&&this.scrollbar.set(-(e+o.scrollLeft),-(t+o.scrollTop),!1),e+=o.absoluteLeft,t+=o.absoluteTop,this.translate(e,t)}getBlockById(e){return super.getBlockById(e)}getAllBlocks(e=!1){return super.getAllBlocks(e)}getTopBlocks(e=!1){return super.getTopBlocks(e)}addTopBlock(e){this.addTopBoundedElement(e),super.addTopBlock(e)}removeTopBlock(e){this.removeTopBoundedElement(e),super.removeTopBlock(e)}addTopComment(e){this.addTopBoundedElement(e),super.addTopComment(e)}removeTopComment(e){this.removeTopBoundedElement(e),super.removeTopComment(e)}getTopComments(e=!1){return super.getTopComments(e)}getCommentById(e){return super.getCommentById(e)}getRootWorkspace(){return super.getRootWorkspace()}addTopBoundedElement(e){this.topBoundedElements.push(e)}removeTopBoundedElement(e){x(this.topBoundedElements,e)}getTopBoundedElements(e=!1){const t=[].concat(this.topBoundedElements);return e&&t.sort(this.sortByOrigin.bind(this)),t}setResizesEnabled(e){const t=!this.resizesEnabled&&e;this.resizesEnabled=e,t&&this.resizeContents()}clear(){this.setResizesEnabled(!1),super.clear(),this.topBoundedElements=[],this.setResizesEnabled(!0)}registerButtonCallback(e,t){if(typeof t!="function")throw TypeError("Button callbacks must be functions.");this.flyoutButtonCallbacks.set(e,t)}getButtonCallback(e){let t;return(t=this.flyoutButtonCallbacks.get(e))!=null?t:null}removeButtonCallback(e){this.flyoutButtonCallbacks.delete(e)}registerToolboxCategoryCallback(e,t){if(typeof t!="function")throw TypeError("Toolbox category callbacks must be functions.");this.toolboxCategoryCallbacks.set(e,t)}getToolboxCategoryCallback(e){return this.toolboxCategoryCallbacks.get(e)||null}removeToolboxCategoryCallback(e){this.toolboxCategoryCallbacks.delete(e)}getGesture(e){if(this.keyboardMoveInProgress)return e.preventDefault(),e.stopPropagation(),null;const t=e.type==="pointerdown";let o;return t&&((o=this.currentGesture_)!=null&&o.hasStarted())&&(console.warn("Tried to start the same gesture twice."),this.currentGesture_.cancel()),!this.currentGesture_&&t&&(this.currentGesture_=new ml(e,this)),this.currentGesture_}clearGesture(){this.currentGesture_=null}cancelCurrentGesture(){this.currentGesture_&&this.currentGesture_.cancel()}getAudioManager(){return this.audioManager}getGrid(){return this.grid}hideChaff(e=!1){xo(),Xi(this),mo(),this.hideComponents(e)}hideComponents(e=!1){this.getComponentManager().getComponents(Ve.Capability.AUTOHIDEABLE,!0).forEach(t=>t.autoHide(e))}static setTopLevelWorkspaceMetrics(e){const t=this.getMetrics();typeof e.x=="number"&&(this.scrollX=-(t.scrollLeft+(t.scrollWidth-t.viewWidth)*e.x)),typeof e.y=="number"&&(this.scrollY=-(t.scrollTop+(t.scrollHeight-t.viewHeight)*e.y)),this.translate(this.scrollX+t.absoluteLeft,this.scrollY+t.absoluteTop)}addClass(e){this.injectionDiv&&G(this.injectionDiv,e)}removeClass(e){this.injectionDiv&&Te(this.injectionDiv,e)}setIsReadOnly(e){super.setIsReadOnly(e),e?this.addClass("blocklyReadOnly"):this.removeClass("blocklyReadOnly")}scrollBoundsIntoView(e,t=10){if(!ml.inProgress()){var o=this.getScale(),s=this.getMetricsManager().getViewMetrics(!0);if(s=new ye(s.top,s.top+s.height,s.left,s.left+s.width),!(e.left>=s.left&&e.top>=s.top&&e.right<=s.right&&e.bottom<=s.bottom)){e=e.clone(),e.top-=t,e.bottom+=t,e.left-=t,e.right+=t;var i=t=0;e.left<s.left?t=this.RTL?Math.min(s.left-e.left,s.right-e.right):s.left-e.left:e.right>s.right&&(t=this.RTL?s.right-e.right:Math.max(s.right-e.right,s.left-e.left)),e.top<s.top?i=s.top-e.top:e.bottom>s.bottom&&(i=Math.max(s.bottom-e.bottom,s.top-e.top)),this.scroll(this.scrollX+t*o,this.scrollY+i*o)}}}getFocusableElement(){return this.svgGroup_}getFocusableTree(){return this.isMutator&&this.options.parentWorkspace||this}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}getRootFocusableNode(){return this}getRestoredFocusableNode(e){if(e)return null;let t;return(t=this.getTopBlocks(!0)[0])!=null?t:null}getNestedTrees(){const e=this.getAllBlocks().map(o=>o.getIcons()).flat().filter(o=>o instanceof r.MutatorIcon$$module$build$src$core$icons$mutator_icon&&o.bubbleIsVisible()).map(o=>{let s;return(s=o.getBubble())==null?void 0:s.getWorkspace()}).filter(o=>!!o),t=this.getFlyout(!0);return t&&e.push(t.getWorkspace()),e}searchForWorkspaceComment(e){for(const t of this.getTopComments())if(t instanceof yo&&t.canBeFocused()&&t.getFocusableElement().id===e)return t}lookUpFocusableNode(e){var t;const o=(t=this.targetWorkspace)==null?void 0:t.getFlyout();if(this.isFlyout&&o){for(var s of o.getContents())if(t=s.getElement(),oo(t)&&t.canBeFocused()&&t.getFocusableElement().id===e)return t}if(s=e.indexOf("_field_"),t=e.indexOf("_connection_"),s!==-1){var i=e.substring(0,s);if(i=this.getBlockById(i)){for(var n of i.getFields())if(n.canBeFocused()&&n.getFocusableElement().id===e)return n}return null}if(t!==-1){if(i=e.substring(0,t),i=this.getBlockById(i)){for(const f of i.getConnections_(!0))if(f.id===e)return f}return null}if(n=Math.max(e.indexOf(Ba),e.indexOf(Jg),e.indexOf(Qg)),n!==-1&&(n=e.substring(0,n),n=this.searchForWorkspaceComment(n))){if(e.indexOf(Ba)>-1)return n.getEditorFocusableNode();var d;return(d=n.view.getCommentBarButtons().find(f=>f.getFocusableElement().id.includes(e)))!=null?d:null}if((d=this.getAllBlocks(!1).find(f=>f.getFocusableElement().id===e))||(d=this.searchForWorkspaceComment(e)))return d;d=this.getAllBlocks().map(f=>f.getIcons()).flat();for(i of d){if(i.canBeFocused()&&i.getFocusableElement().id===e)return i;if(Ts(i)&&(d=i.getBubble())&&d.canBeFocused()&&d.getFocusableElement().id===e)return d}return null}onTreeFocus(e,t){}onTreeBlur(e){if(this.isFlyout&&this.targetWorkspace&&!r.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()){var t=this.targetWorkspace.getFlyout(),o=this.targetWorkspace.getToolbox();o&&e===o||(o&&o.clearSelection(),t&&hu(t)&&t.autoHide(!1))}}getNavigator(){return this.navigator}setNavigator(e){this.navigator=e}},Ri=class extends hi{constructor(e){super(),this.isBlank=typeof e>"u",e&&(this.varId=e.getId(),this.workspaceId=e.getWorkspace().id)}toJson(){const e=super.toJson();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");return e.varId=this.varId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ri),t.varId=e.varId,t}},uh=class extends Ri{constructor(e){super(e),this.type=w.VAR_CREATE,e&&(this.varType=e.getType(),this.varName=e.getName())}toJson(){const e=super.toJson();if(this.varType===void 0)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");return e.varType=this.varType,e.varName=this.varName,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new uh),t.varType=e.varType,t.varName=e.varName,t}run(e){var t=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");t=t.getVariableMap(),e?t.createVariable(this.varName,this.varType,this.varId):(e=t.getVariableById(this.varId))&&t.deleteVariable(e)}};l(M.EVENT,w.VAR_CREATE,uh);var xm=class{constructor(e,t,o,s){this.workspace=e,this.name=t,this.type=o||"",this.id=s||rt()}getId(){return this.id}getName(){return this.name}setName(e){return this.name=e,this}getType(){return this.type}setType(e){return this.type=e,this}getWorkspace(){return this.workspace}save(){const e={name:this.getName(),id:this.getId()},t=this.getType();return t&&(e.type=t),e}static load(e,t){e=new this(t,e.name,e.type,e.id),t.getVariableMap().addVariable(e),_(new(U(w.VAR_CREATE))(e))}};l(M.VARIABLE_MODEL,Ft,xm);var ah=class extends Ri{constructor(e){super(e),this.type=w.VAR_DELETE,e&&(this.varType=e.getType(),this.varName=e.getName())}toJson(){const e=super.toJson();if(this.varType===void 0)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");return e.varType=this.varType,e.varName=this.varName,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new ah),t.varType=e.varType,t.varName=e.varName,t}run(e){var t=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");t=t.getVariableMap(),e?(e=t.getVariableById(this.varId))&&t.deleteVariable(e):t.createVariable(this.varName,this.varType,this.varId)}};l(M.EVENT,w.VAR_DELETE,ah);var hh=class extends Ri{constructor(e,t){super(e),this.type=w.VAR_RENAME,e&&(this.oldName=e.getName(),this.newName=typeof t>"u"?"":t)}toJson(){const e=super.toJson();if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");return e.oldName=this.oldName,e.newName=this.newName,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new hh),t.oldName=e.oldName,t.newName=e.newName,t}run(e){var t=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");t=t.getVariableMap();const o=t.getVariableById(this.varId);e?o&&t.renameVariable(o,this.newName):o&&t.renameVariable(o,this.oldName)}};l(M.EVENT,w.VAR_RENAME,hh);var Bm=class{constructor(e,t=!1){this.workspace=e,this.potentialMap=t,this.variableMap=new Map}clear(){for(const e of this.variableMap.values())for(const t of e.values())this.deleteVariable(t);if(this.variableMap.size!==0)throw Error("Non-empty variable map")}renameVariable(e,t){if(e.getName()===t)return e;var o=e.getType();o=this.getVariable(t,o);const s=this.workspace.getAllBlocks(!1);let i="";this.potentialMap||(i=r.getGroup$$module$build$src$core$events$utils())||r.setGroup$$module$build$src$core$events$utils(!0);try{o&&o.getId()!==e.getId()?this.renameVariableWithConflict(e,t,o,s):this.renameVariableAndUses(e,t,s)}finally{this.potentialMap||r.setGroup$$module$build$src$core$events$utils(i)}return e}changeVariableType(e,t){var o;(o=this.variableMap.get(e.getType()))==null||o.delete(e.getId()),e.setType(t);let s;return o=(s=this.variableMap.get(t))!=null?s:new Map,o.set(e.getId(),e),this.variableMap.has(t)||this.variableMap.set(t,o),e}renameVariableById(e,t){pt("VariableMap.renameVariableById","v12","v13","VariableMap.renameVariable");const o=this.getVariableById(e);if(!o)throw Error("Tried to rename a variable that didn't exist. ID: "+e);this.renameVariable(o,t)}renameVariableAndUses(e,t,o){for(this.potentialMap||_(new(U(w.VAR_RENAME))(e,t)),e.setName(t),t=0;t<o.length;t++)o[t].updateVarName(e)}renameVariableWithConflict(e,t,o,s){const i=e.getType(),n=o.getName();for(t!==n&&this.renameVariableAndUses(o,t,s),t=0;t<s.length;t++)s[t].renameVarById(e.getId(),o.getId());this.potentialMap||_(new(U(w.VAR_DELETE))(e));let d;(d=this.variableMap.get(i))==null||d.delete(e.getId())}createVariable(e,t,o){var s=this.getVariable(e,t);if(s){if(o&&s.getId()!==o)throw Error('Variable "'+e+'" is already in use and its id is "'+s.getId()+'" which conflicts with the passed in id, "'+o+'".');return s}if(o&&this.getVariableById(o))throw Error('Variable id, "'+o+'", is already in use.');if(s=o||rt(),t=t||"",o=D(M.VARIABLE_MODEL,Ft,!0),!o)throw Error("No variable model is registered.");s=new o(this.workspace,e,t,s);let i;return e=(i=this.variableMap.get(t))!=null?i:new Map,e.set(s.getId(),s),this.variableMap.has(t)||this.variableMap.set(t,e),this.potentialMap||_(new(U(w.VAR_CREATE))(s)),s}addVariable(e){const t=e.getType();this.variableMap.has(t)||this.variableMap.set(t,new Map);let o;(o=this.variableMap.get(t))==null||o.set(e.getId(),e)}deleteVariable(e){const t=qs(this.workspace,e.getId());let o="";this.potentialMap||(o=r.getGroup$$module$build$src$core$events$utils())||r.setGroup$$module$build$src$core$events$utils(!0);try{for(let i=0;i<t.length;i++)t[i].dispose(!0);const s=this.variableMap.get(e.getType());s&&s.has(e.getId())&&(s.delete(e.getId()),this.potentialMap||_(new(U(w.VAR_DELETE))(e)),s.size===0&&this.variableMap.delete(e.getType()))}finally{this.potentialMap||r.setGroup$$module$build$src$core$events$utils(o)}}deleteVariableById(e){pt("VariableMap.deleteVariableById","v12","v13","Blockly.Variables.deleteVariable"),(e=this.getVariableById(e))&&r.deleteVariable$$module$build$src$core$variables(this.workspace,e)}getVariable(e,t){if(t=this.variableMap.get(t||""),!t)return null;let o;return(o=[...t.values()].find(s=>r.Names$$module$build$src$core$names.equals(s.getName(),e)))!=null?o:null}getVariableById(e){for(const t of this.variableMap.values())if(t.has(e)){let o;return(o=t.get(e))!=null?o:null}return null}getVariablesOfType(e){return(e=this.variableMap.get(e||""))?[...e.values()]:[]}getTypes(){return[...this.variableMap.keys()]}getAllVariables(){let e=[];for(const t of this.variableMap.values())e=e.concat(...t.values());return e}getAllVariableNames(){pt("VariableMap.getAllVariableNames","v12","v13","Blockly.Variables.getAllVariables");const e=[];for(const t of this.variableMap.values())for(const o of t.values())e.push(o.getName());return e}getVariableUsesById(e){return pt("VariableMap.getVariableUsesById","v12","v13","Blockly.Variables.getVariableUsesById"),qs(this.workspace,e)}};l(M.VARIABLE_MAP,Ft,Bm);var dh=class extends Eo{constructor(e,t){super(t),this.type=w.TRASHCAN_OPEN,this.isOpen=e}toJson(){const e=super.toJson();if(this.isOpen===void 0)throw Error("Whether this is already open or not is undefined. Either pass a value to the constructor, or call fromJson");return e.isOpen=this.isOpen,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new dh),t.isOpen=e.isOpen,t}};l(M.EVENT,w.TRASHCAN_OPEN,dh);var Pm=class extends dl{constructor(e){super(),this.workspace=e,this.id="trashcan",this.contents=[],this.flyout=null,this.isLidOpen=!1,this.minOpenness=0,this.lidTask=this.svgLid=this.svgGroup=null,this.top=this.left=this.lidOpen=0,this.initialized=!1,this.workspace.options.maxTrashcanContents<=0||(e=this.workspace.copyOptionsForFlyout(),this.workspace.horizontalLayout?(e.toolboxPosition=this.workspace.toolboxPosition===be.TOP?be.BOTTOM:be.TOP,this.flyout=new(W(M.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(e)):(e.toolboxPosition=this.workspace.toolboxPosition===be.RIGHT?be.LEFT:be.RIGHT,this.flyout=new(W(M.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(e)),this.workspace.addChangeListener(this.onDelete.bind(this)))}createDom(){this.svgGroup=v(R.G,{class:"blocklyTrash"});let e;const t=String(Math.random()).substring(2);e=v(R.CLIPPATH,{id:"blocklyTrashBodyClipPath"+t},this.svgGroup),v(R.RECT,{width:wi,height:Il,y:Oi},e);const o=v(R.IMAGE,{width:Dt.width,x:-$h,height:Dt.height,y:-ph,"clip-path":"url(#blocklyTrashBodyClipPath"+t+")"},this.svgGroup);return o.setAttributeNS(Ht,"xlink:href",this.workspace.options.pathToMedia+Dt.url),e=v(R.CLIPPATH,{id:"blocklyTrashLidClipPath"+t},this.svgGroup),v(R.RECT,{width:wi,height:Oi},e),this.svgLid=v(R.IMAGE,{width:Dt.width,x:-$h,height:Dt.height,y:-ph,"clip-path":"url(#blocklyTrashLidClipPath"+t+")"},this.svgGroup),this.svgLid.setAttributeNS(Ht,"xlink:href",this.workspace.options.pathToMedia+Dt.url),ae(this.svgGroup,"pointerdown",this,this.blockMouseDownWhenOpenable),ae(this.svgGroup,"pointerup",this,this.click),ae(o,"pointerover",this,this.mouseOver),ae(o,"pointerout",this,this.mouseOut),this.animateLid(),this.svgGroup}init(){if(this.workspace.options.maxTrashcanContents>0){const e=this.flyout.createDom(R.SVG);G(e,"blocklyTrashcanFlyout"),Qt(e,this.workspace.getParentSvg()),this.flyout.init(this.workspace)}this.workspace.getComponentManager().addComponent({component:this,weight:Ve.ComponentWeight.TRASHCAN_WEIGHT,capabilities:[Ve.Capability.AUTOHIDEABLE,Ve.Capability.DELETE_AREA,Ve.Capability.DRAG_TARGET,Ve.Capability.POSITIONABLE]}),this.initialized=!0,this.setLidOpen(!1)}dispose(){this.workspace.getComponentManager().removeComponent("trashcan"),this.svgGroup&&ke(this.svgGroup),this.lidTask&&clearTimeout(this.lidTask)}hasContents(){return!!this.contents.length}contentsIsOpen(){return!!this.flyout&&this.flyout.isVisible()}openFlyout(){if(!this.contentsIsOpen()){var e=this.contents.map(function(o){return JSON.parse(o)}),t=this.workspace.getParentSvg().style;t.cursor="wait",setTimeout(()=>{let o;(o=this.flyout)==null||o.show(e),t.cursor="";let s;(s=this.workspace.scrollbar)==null||s.setVisible(!1)},10),this.fireUiEvent(!0)}}closeFlyout(){if(this.contentsIsOpen()){var e;(e=this.flyout)==null||e.hide();var t;(t=this.workspace.scrollbar)==null||t.setVisible(!0),this.fireUiEvent(!1),this.workspace.recordDragTargets()}}autoHide(e){!e&&this.flyout&&this.closeFlyout()}emptyContents(){this.hasContents()&&(this.contents.length=0,this.setMinOpenness(0),this.closeFlyout())}position(e,t){if(this.initialized){var o=Vr(this.workspace,e);e=Gr(o,new ve(wi,Il+Oi),Db,Fm,e,this.workspace),t=Wr(e,Fm,o.vertical===Go.TOP?ls.DOWN:ls.UP,t),this.top=t.top,this.left=t.left;var s;(s=this.svgGroup)==null||s.setAttribute("transform","translate("+this.left+","+this.top+")");var i;(i=this.flyout)==null||i.position()}}getBoundingRectangle(){return new ye(this.top,this.top+Il+Oi,this.left,this.left+wi)}getClientRect(){if(!this.svgGroup)return null;var e=this.svgGroup.getBoundingClientRect();const t=e.top+ph-Cl;return e=e.left+$h-Cl,new ye(t,t+Oi+Il+2*Cl,e,e+wi+2*Cl)}onDragOver(e){this.setLidOpen(this.wouldDelete_)}onDragExit(e){this.setLidOpen(!1)}onDrop(e){setTimeout(this.setLidOpen.bind(this,!1),100)}setLidOpen(e){this.isLidOpen!==e&&(this.lidTask&&clearTimeout(this.lidTask),this.isLidOpen=e,this.animateLid())}animateLid(){const e=Pb;var t=1/(e+1);this.lidOpen+=this.isLidOpen?t:-t,this.lidOpen=Math.min(Math.max(this.lidOpen,this.minOpenness),1),this.setLidAngle(this.lidOpen*Hm),t=Um+this.lidOpen*(Fb-Um),this.svgGroup&&(this.svgGroup.style.opacity=`${t}`),this.lidOpen>this.minOpenness&&this.lidOpen<1&&(this.lidTask=setTimeout(this.animateLid.bind(this),Bb/e))}setLidAngle(e){const t=this.workspace.toolboxPosition===be.RIGHT||this.workspace.horizontalLayout&&this.workspace.RTL;let o;(o=this.svgLid)==null||o.setAttribute("transform","rotate("+(t?-e:e)+","+(t?4:wi-4)+","+(Oi-2)+")")}setMinOpenness(e){this.minOpenness=e,this.isLidOpen||this.setLidAngle(e*Hm)}closeLid(){this.setLidOpen(!1)}click(){this.hasContents()&&!this.workspace.isDragging()&&this.openFlyout()}fireUiEvent(e){e=new(U(w.TRASHCAN_OPEN))(e,this.workspace.id),_(e)}blockMouseDownWhenOpenable(e){!this.contentsIsOpen()&&this.hasContents()&&e.stopPropagation()}mouseOver(){this.hasContents()&&this.setLidOpen(!0)}mouseOut(){this.setLidOpen(!1)}onDelete(e){if(!(this.workspace.options.maxTrashcanContents<=0||!Bt(e)||e.wasShadow)){if(!e.oldJson)throw Error("Encountered a delete event without proper oldJson");if(e=JSON.stringify(this.cleanBlockJson(e.oldJson)),!this.contents.includes(e)){for(this.contents.unshift(e);this.contents.length>this.workspace.options.maxTrashcanContents;)this.contents.pop();this.setMinOpenness(xb)}}}cleanBlockJson(e){function t(o){if(o){if(delete o.id,delete o.x,delete o.y,delete o.enabled,delete o.disabledReasons,o.icons&&o.icons.comment){var s=o.icons.comment;delete s.height,delete s.width,delete s.pinned}s=o.inputs;for(var i in s){var n=s[i];const d=n.block;n=n.shadow,d&&t(d),n&&t(n)}o.next&&(i=o.next,o=i.block,i=i.shadow,o&&t(o),i&&t(i))}}return e=JSON.parse(JSON.stringify(e)),t(e),Object.assign({},{kind:"BLOCK"},e)}},wi=47,Il=44,Oi=16,Fm=20,Db=20,Cl=10,$h=0,ph=32,xb=.1,Bb=80,Pb=4,Um=.4,Fb=.8,Hm=45,Sr=null,kr=null,Sl=void 0,uo={};uo.BlockPaster=Er,uo.copy=kn,uo.getLastCopiedData=Rn,uo.getLastCopiedLocation=yu,uo.getLastCopiedWorkspace=wn,uo.paste=ss,uo.registry=ma,uo.setLastCopiedData=gp,uo.setLastCopiedLocation=fp,uo.setLastCopiedWorkspace=mp;var ds={};ds.CollapseCommentBarButton=qg,ds.CommentBarButton=il,ds.CommentEditor=Zg,ds.CommentView=fr,ds.DeleteCommentBarButton=em,ds.RenderedWorkspaceComment=yo,ds.WorkspaceComment=rl;var ko;(function(e){e.ESCAPE="escape",e.DELETE="delete",e.COPY="copy",e.CUT="cut",e.PASTE="paste",e.UNDO="undo",e.REDO="redo"})(ko||(ko={})),Au();var Ro={};Ro.names=ko,Ro.registerCopy=ku,Ro.registerCut=Ru,Ro.registerDefaultShortcuts=Au,Ro.registerDelete=Cu,Ro.registerEscape=Iu,Ro.registerPaste=wu,Ro.registerRedo=Nu,Ro.registerUndo=Ou;var Ub=class{constructor(e,t){this.procedureModelClass=e,this.parameterModelClass=t,this.priority=hg}save(e){return e=e.getProcedureMap().getProcedures().map(t=>Lu(t)),e.length?e:null}load(e,t){const o=t.getProcedureMap();for(const s of e)o.add(Mu(this.procedureModelClass,this.parameterModelClass,s,t))}clear(e){e.getProcedureMap().clear()}},kl={};kl.ProcedureSerializer=Ub,kl.loadProcedure=Mu,kl.saveProcedure=Lu;var Gm=class{constructor(){this.priority=ag}save(e){return e=e.getAllVariables().map(t=>t.save()),e.length?e:null}load(e,t){const o=D(M.VARIABLE_MODEL,Ft);e.forEach(s=>{o?.load(s,t)})}clear(e){e.getVariableMap().clear()}};Pi("variables",new Gm);var Vm={};Vm.VariableSerializer=Gm;var gh={};gh.load=bp,gh.save=_p;var Hb={blocks:dr,exceptions:Os,priorities:fb,procedures:kl,registry:ga,variables:Vm,workspaceComments:Un,workspaces:gh};"Blockly"in globalThis||(globalThis.Blockly={Msg:fg});var mh="label",Wm=class{load(e,t){return e=new xt(t.getWorkspace(),t.targetWorkspace,e,!0),e.show(),new Ci(e,mh)}gapForItem(e,t){return t}disposeItem(e){e=e.getElement(),e instanceof xt&&e.dispose()}getType(){return mh}};l(M.FLYOUT_INFLATER,mh,Wm);var zm=class extends Tl{constructor(e){super(),this.GRID_UNIT=4,this.CURSOR_COLOUR="#ffa200",this.CURSOR_RADIUS=5,this.JAGGED_TEETH_WIDTH=this.JAGGED_TEETH_HEIGHT=0,this.START_HAT_HEIGHT=22,this.START_HAT_WIDTH=96,this.SHAPES={HEXAGONAL:1,ROUND:2,SQUARE:3,PUZZLE:4,NOTCH:5},this.SHAPE_IN_SHAPE_PADDING={1:{0:5*this.GRID_UNIT,1:2*this.GRID_UNIT,2:5*this.GRID_UNIT,3:5*this.GRID_UNIT},2:{0:3*this.GRID_UNIT,1:3*this.GRID_UNIT,2:1*this.GRID_UNIT,3:2*this.GRID_UNIT},3:{0:2*this.GRID_UNIT,1:2*this.GRID_UNIT,2:2*this.GRID_UNIT,3:2*this.GRID_UNIT}},this.FULL_BLOCK_FIELDS=!0,this.FIELD_TEXT_FONTWEIGHT="bold",this.FIELD_TEXT_FONTFAMILY='"Helvetica Neue", "Segoe UI", Helvetica, sans-serif',this.FIELD_COLOUR_FULL_BLOCK=this.FIELD_TEXTINPUT_BOX_SHADOW=this.FIELD_DROPDOWN_SVG_ARROW=this.FIELD_DROPDOWN_COLOURED_DIV=this.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW=!0,this.SELECTED_GLOW_COLOUR="#fff200",this.SELECTED_GLOW_SIZE=.5,this.REPLACEMENT_GLOW_COLOUR="#fff200",this.REPLACEMENT_GLOW_SIZE=2,this.selectedGlowFilterId="",this.selectedGlowFilter=null,this.replacementGlowFilterId="",this.SQUARED=this.ROUNDED=this.HEXAGONAL=this.replacementGlowFilter=null,e&&(this.GRID_UNIT=e),this.SMALL_PADDING=this.GRID_UNIT,this.MEDIUM_PADDING=2*this.GRID_UNIT,this.MEDIUM_LARGE_PADDING=3*this.GRID_UNIT,this.LARGE_PADDING=4*this.GRID_UNIT,this.CORNER_RADIUS=1*this.GRID_UNIT,this.NOTCH_WIDTH=9*this.GRID_UNIT,this.NOTCH_HEIGHT=2*this.GRID_UNIT,this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT=3*this.GRID_UNIT,this.MIN_BLOCK_WIDTH=2*this.GRID_UNIT,this.MIN_BLOCK_HEIGHT=12*this.GRID_UNIT,this.EMPTY_STATEMENT_INPUT_HEIGHT=6*this.GRID_UNIT,this.TOP_ROW_MIN_HEIGHT=this.CORNER_RADIUS,this.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING,this.BOTTOM_ROW_MIN_HEIGHT=this.CORNER_RADIUS,this.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT=6*this.GRID_UNIT,this.STATEMENT_BOTTOM_SPACER=-this.NOTCH_HEIGHT,this.STATEMENT_INPUT_SPACER_MIN_WIDTH=40*this.GRID_UNIT,this.STATEMENT_INPUT_PADDING_LEFT=4*this.GRID_UNIT,this.EMPTY_INLINE_INPUT_PADDING=4*this.GRID_UNIT,this.EMPTY_INLINE_INPUT_HEIGHT=8*this.GRID_UNIT,this.DUMMY_INPUT_MIN_HEIGHT=8*this.GRID_UNIT,this.DUMMY_INPUT_SHADOW_MIN_HEIGHT=6*this.GRID_UNIT,this.CURSOR_WS_WIDTH=20*this.GRID_UNIT,this.FIELD_TEXT_FONTSIZE=3*this.GRID_UNIT,this.FIELD_BORDER_RECT_RADIUS=this.CORNER_RADIUS,this.FIELD_BORDER_RECT_X_PADDING=2*this.GRID_UNIT,this.FIELD_BORDER_RECT_Y_PADDING=1.625*this.GRID_UNIT,this.FIELD_BORDER_RECT_HEIGHT=8*this.GRID_UNIT,this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=8*this.GRID_UNIT,this.FIELD_DROPDOWN_SVG_ARROW_PADDING=this.FIELD_BORDER_RECT_X_PADDING,this.FIELD_COLOUR_DEFAULT_WIDTH=6*this.GRID_UNIT,this.FIELD_COLOUR_DEFAULT_HEIGHT=8*this.GRID_UNIT,this.FIELD_CHECKBOX_X_OFFSET=1*this.GRID_UNIT,this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH=12*this.GRID_UNIT}setFontConstants_(e){super.setFontConstants_(e),this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT=this.FIELD_TEXT_HEIGHT+this.FIELD_BORDER_RECT_Y_PADDING*2}init(){super.init(),this.HEXAGONAL=this.makeHexagonal(),this.ROUNDED=this.makeRounded(),this.SQUARED=this.makeSquared(),this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT+this.INSIDE_CORNERS.rightWidth}setDynamicProperties_(e){super.setDynamicProperties_(e),this.SELECTED_GLOW_COLOUR=e.getComponentStyle("selectedGlowColour")||this.SELECTED_GLOW_COLOUR;const t=Number(e.getComponentStyle("selectedGlowSize"));this.SELECTED_GLOW_SIZE=t&&!isNaN(t)?t:this.SELECTED_GLOW_SIZE,this.REPLACEMENT_GLOW_COLOUR=e.getComponentStyle("replacementGlowColour")||this.REPLACEMENT_GLOW_COLOUR,this.REPLACEMENT_GLOW_SIZE=(e=Number(e.getComponentStyle("replacementGlowSize")))&&!isNaN(e)?e:this.REPLACEMENT_GLOW_SIZE}dispose(){super.dispose(),this.selectedGlowFilter&&ke(this.selectedGlowFilter),this.replacementGlowFilter&&ke(this.replacementGlowFilter)}makeStartHat(){const e=this.START_HAT_HEIGHT,t=this.START_HAT_WIDTH,o=Pt("c",[se(25,-e),se(71,-e),se(t,0)]);return{height:e*.75,width:t,path:o}}makeHexagonal(){function e(o,s,i){var n=o/2;return n=n>t?t:n,i=i?-1:1,o=(s?-1:1)*o/2,bo(-i*n,o)+bo(i*n,o)}const t=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH;return{type:this.SHAPES.HEXAGONAL,isDynamic:!0,width(o){return o/=2,o>t?t:o},height(o){return o},connectionOffsetY(o){return o/2},connectionOffsetX(o){return-o},pathDown(o){return e(o,!1,!1)},pathUp(o){return e(o,!0,!1)},pathRightDown(o){return e(o,!1,!0)},pathRightUp(o){return e(o,!1,!0)}}}makeRounded(){function e(s,i,n){const d=s>o?s-o:0;s=(s>o?o:s)/2;const f=n===i?"0":"1";return qe("a","0 0,"+f,s,se((n?1:-1)*s,(i?-1:1)*s))+re("v",(i?-1:1)*d)+qe("a","0 0,"+f,s,se((n?-1:1)*s,(i?-1:1)*s))}const t=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,o=t*2;return{type:this.SHAPES.ROUND,isDynamic:!0,width(s){return s/=2,s>t?t:s},height(s){return s},connectionOffsetY(s){return s/2},connectionOffsetX(s){return-s},pathDown(s){return e(s,!1,!1)},pathUp(s){return e(s,!0,!1)},pathRightDown(s){return e(s,!1,!0)},pathRightUp(s){return e(s,!1,!0)}}}makeSquared(){function e(o,s,i){o-=t*2;const n=i===s?"0":"1";return qe("a","0 0,"+n,t,se((i?1:-1)*t,(s?-1:1)*t))+re("v",(s?-1:1)*o)+qe("a","0 0,"+n,t,se((i?-1:1)*t,(s?-1:1)*t))}const t=this.CORNER_RADIUS;return{type:this.SHAPES.SQUARE,isDynamic:!0,width(o){return t},height(o){return o},connectionOffsetY(o){return o/2},connectionOffsetX(o){return-o},pathDown(o){return e(o,!1,!1)},pathUp(o){return e(o,!0,!1)},pathRightDown(o){return e(o,!1,!0)},pathRightUp(o){return e(o,!1,!0)}}}shapeFor(e){let t=e.getCheck();switch(!t&&e.targetConnection&&(t=e.targetConnection.getCheck()),e.type){case Z.INPUT_VALUE:case Z.OUTPUT_VALUE:if(e=e.getSourceBlock().getOutputShape(),e!==null)switch(e){case this.SHAPES.HEXAGONAL:return this.HEXAGONAL;case this.SHAPES.ROUND:return this.ROUNDED;case this.SHAPES.SQUARE:return this.SQUARED}return t&&t.includes("Boolean")?this.HEXAGONAL:t&&t.includes("Number")?this.ROUNDED:(t&&t.includes("String"),this.ROUNDED);case Z.PREVIOUS_STATEMENT:case Z.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown type")}}makeNotch(){function e(oe){return Pt("c",[se(oe*i/2,0),se(oe*i*3/4,d/2),se(oe*i,d)])+ni([se(oe*i,n)])+Pt("c",[se(oe*i/4,d/2),se(oe*i/2,d),se(oe*i,d)])+re("h",oe*s)+Pt("c",[se(oe*i/2,0),se(oe*i*3/4,-(d/2)),se(oe*i,-d)])+ni([se(oe*i,-n)])+Pt("c",[se(oe*i/4,-(d/2)),se(oe*i/2,-d),se(oe*i,-d)])}const t=this.NOTCH_WIDTH,o=this.NOTCH_HEIGHT,s=t/3,i=s/3,n=o/2,d=n/2,f=e(1),L=e(-1);return{type:this.SHAPES.NOTCH,width:t,height:o,pathLeft:f,pathRight:L}}makeInsideCorners(){const e=this.CORNER_RADIUS,t=qe("a","0 0,0",e,se(-e,e)),o=qe("a","0 0,1",e,se(-e,e)),s=qe("a","0 0,0",e,se(e,e)),i=qe("a","0 0,1",e,se(e,e));return{width:e,height:e,pathTop:t,pathBottom:s,rightWidth:e,rightHeight:e,pathTopRight:o,pathBottomRight:i}}generateSecondaryColour_(e){return ys("#000",e,.15)||e}generateTertiaryColour_(e){return ys("#000",e,.25)||e}createDom(e,t,o,s){super.createDom(e,t,o,s),e=v(R.DEFS,{},e),t=v(R.FILTER,{id:"blocklySelectedGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e),v(R.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.SELECTED_GLOW_SIZE},t),o=v(R.FECOMPONENTTRANSFER,{result:"outBlur"},t),v(R.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},o),v(R.FEFLOOD,{"flood-color":this.SELECTED_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},t),v(R.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},t),this.selectedGlowFilterId=t.id,this.selectedGlowFilter=t,e=v(R.FILTER,{id:"blocklyReplacementGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e),v(R.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.REPLACEMENT_GLOW_SIZE},e),t=v(R.FECOMPONENTTRANSFER,{result:"outBlur"},e),v(R.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},t),v(R.FEFLOOD,{"flood-color":this.REPLACEMENT_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},e),v(R.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},e),v(R.FECOMPOSITE,{in:"SourceGraphic",in2:"outGlow",operator:"over"},e),this.replacementGlowFilterId=e.id,this.replacementGlowFilter=e,s&&(s.style.setProperty("--blocklySelectedGlowFilter",`url(#${this.selectedGlowFilterId})`),s.style.setProperty("--blocklyReplacementGlowFilter",`url(#${this.replacementGlowFilterId})`))}getCSS_(e){return[`${e} .blocklyText,`,`${e} .blocklyFlyoutLabelText {`,`font: ${this.FIELD_TEXT_FONTWEIGHT} ${this.FIELD_TEXT_FONTSIZE}pt ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${e} .blocklyTextInputBubble textarea {`,"font-weight: normal;","}",`${e} .blocklyText {`,"fill: #fff;","}",`${e} .blocklyNonEditableField>rect:not(.blocklyDropdownRect),`,`${e} .blocklyEditableField>rect:not(.blocklyDropdownRect) {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"}",`${e} .blocklyNonEditableField>text,`,`${e} .blocklyEditableField>text,`,`${e} .blocklyNonEditableField>g>text,`,`${e} .blocklyEditableField>g>text {`,"fill: #575E75;","}",`${e} .blocklyFlyoutLabelText {`,"fill: #575E75;","}",`${e} .blocklyText.blocklyBubbleText {`,"fill: #575E75;","}",`${e} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableField:not(.blocklyEditing):hover>rect,",`${e} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableField:not(.blocklyEditing):hover>.blocklyPath {","stroke: #fff;","stroke-width: 2;","}",`${e} .blocklyHtmlInput {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"color: #575E75;","}",`${e} .blocklyDropdownText {`,"fill: #fff !important;","}",`${e}.blocklyWidgetDiv .blocklyMenuItem,`,`${e}.blocklyDropDownDiv .blocklyMenuItem {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${e}.blocklyDropDownDiv .blocklyMenuItemContent {`,"color: #fff;","}",`${e} .blocklyHighlightedConnectionPath {`,`stroke: ${this.SELECTED_GLOW_COLOUR};`,"}",`${e} .blocklyDisabledPattern > .blocklyOutlinePath {`,"fill: var(--blocklyDisabledPattern)","}",`${e} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}",`${e} .blocklySelected>.blocklyPath.blocklyPathSelected {`,"fill: none;","filter: var(--blocklySelectedGlowFilter);","}",`${e} .blocklyReplaceable>.blocklyPath {`,"filter: var(--blocklyReplacementGlowFilter);","}"]}},Ym=class extends El{constructor(e,t){super(e,t)}draw(){const e=this.block_.pathObject;e.beginDrawing(),this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights(),e.setPath(this.outlinePath_+`
661
- `+this.inlinePath_),this.info_.RTL&&e.flipRTL(),this.recordSizeOnBlock_(),this.info_.outputConnection&&(e.outputShapeType=this.info_.outputConnection.shape.type),e.endDrawing()}drawOutline_(){this.info_.outputConnection&&this.info_.outputConnection.isDynamicShape&&!this.info_.hasStatementInput&&!this.info_.bottomRow.hasNextConnection?(this.drawFlatTop_(),this.drawRightDynamicConnection_(),this.drawFlatBottom_(),this.drawLeftDynamicConnection_()):super.drawOutline_()}drawLeft_(){this.info_.outputConnection&&this.info_.outputConnection.isDynamicShape?this.drawLeftDynamicConnection_():super.drawLeft_()}drawRightSideRow_(e){if(!(e.height<=0)){if(T.isSpacer(e)){const s=e.precedesStatement;var t=e.followsStatement;if(s||t){const i=this.constants_.INSIDE_CORNERS;var o=i.rightHeight;o=e.height-(s?o:0),t=t?i.pathBottomRight:"",e=o>0?re("V",e.yPos+o):"",this.outlinePath_+=t+e+(s?i.pathTopRight:"");return}}this.outlinePath_+=re("V",e.yPos+e.height)}}drawRightDynamicConnection_(){if(!this.info_.outputConnection)throw Error("Cannot draw the output connection of a block that doesn't have one");this.outlinePath_+=this.info_.outputConnection.shape.pathRightDown(this.info_.outputConnection.height)}drawLeftDynamicConnection_(){if(!this.info_.outputConnection)throw Error("Cannot draw the output connection of a block that doesn't have one");this.positionOutputConnection_(),this.outlinePath_+=this.info_.outputConnection.shape.pathUp(this.info_.outputConnection.height),this.outlinePath_+="z"}drawFlatTop_(){const e=this.info_.topRow;this.positionPreviousConnection_(),this.outlinePath_+=je(e.xPos,this.info_.startY),this.outlinePath_+=re("h",e.width)}drawFlatBottom_(){const e=this.info_.bottomRow;this.positionNextConnection_(),this.outlinePath_+=re("V",e.baseline),this.outlinePath_+=re("h",-e.width)}drawInlineInput_(e){this.positionInlineInputConnection_(e);const t=e.input.name;e.connectedBlock||this.info_.isInsertionMarker||(e=gt(e.xPos+e.connectionWidth,e.centerline-e.height/2)+this.getInlineInputPath(e),this.block_.pathObject.setOutlinePath(t,e))}getInlineInputPath(e){const t=e.width-e.connectionWidth*2,o=e.height;return re("h",t)+e.shape.pathRightDown(o)+re("h",-t)+e.shape.pathUp(o)+"z"}drawStatementInput_(e){var t=e.getLastInput();const o=t.xPos+t.notchOffset+t.shape.width,s=this.constants_.INSIDE_CORNERS,i=t.shape.pathRight+re("h",-(t.notchOffset-s.width))+s.pathTop,n=e.height-2*s.height;t=s.pathBottom+re("h",t.notchOffset-s.width)+(t.connectedBottomNextConnection?"":t.shape.pathLeft),this.outlinePath_+=re("H",o)+i+re("v",n)+t+re("H",e.xPos+e.width),this.positionStatementInputConnection_(e)}drawConnectionHighlightPath(e){const t=e.connectionModel;if(t.type===Z.NEXT_STATEMENT||t.type===Z.PREVIOUS_STATEMENT||t.type===Z.OUTPUT_VALUE&&!e.isDynamicShape)return super.drawConnectionHighlightPath(e);e=t.type===Z.INPUT_VALUE?gt(e.connectionWidth,-e.height/2)+this.getInlineInputPath(e):gt(e.width,-e.height/2)+e.shape.pathDown(e.height);const o=t.getSourceBlock();let s,i;return(i=(s=o.pathObject).addConnectionHighlight)==null?void 0:i.call(s,t,e,t.getOffsetInBlock(),o.RTL)}},Hs=class extends we{constructor(e,t,o,s,i,n,d){if(super(we.SKIP_SETUP),this.imageElement=this.clickHandler=null,this.flipRtl=this.isDirty_=this.EDITABLE=!1,this.altText="",o=Number(Je(o)),t=Number(Je(t)),isNaN(o)||isNaN(t))throw Error("Height and width values of an image field must cast to numbers.");if(o<=0||t<=0)throw Error("Height and width values of an image field must be greater than 0.");this.size_=new ve(t,o+Hs.Y_PADDING),this.imageHeight=o,typeof i=="function"&&(this.clickHandler=i),e!==we.SKIP_SETUP&&(d?this.configure_(d):(this.flipRtl=!!n,this.altText=Je(s)||""),this.setValue(Je(e)))}configure_(e){super.configure_(e),e.flipRtl&&(this.flipRtl=e.flipRtl),e.alt&&(this.altText=Je(e.alt))}initView(){this.imageElement=v(R.IMAGE,{height:this.imageHeight+"px",width:this.size_.width+"px",alt:this.altText},this.fieldGroup_),this.imageElement.setAttributeNS(Ht,"xlink:href",this.value_),this.fieldGroup_&&G(this.fieldGroup_,"blocklyImageField"),this.clickHandler&&(this.imageElement.style.cursor="pointer")}updateSize_(){}doClassValidation_(e){return typeof e!="string"?null:e}doValueUpdate_(e){this.value_=e,this.imageElement&&this.imageElement.setAttributeNS(Ht,"xlink:href",this.value_)}getFlipRtl(){return this.flipRtl}setAlt(e){e!==this.altText&&(this.altText=e||"",this.imageElement&&this.imageElement.setAttribute("alt",this.altText))}isClickable(){return super.isClickable()&&!!this.clickHandler}showEditor_(){this.clickHandler&&this.clickHandler(this)}setOnClickHandler(e){this.clickHandler=e}getText_(){return this.altText}static fromJson(e){if(!e.src||!e.width||!e.height)throw Error("src, width, and height values for an image field arerequired. The width and height must be non-zero.");return new this(e.src,e.width,e.height,void 0,void 0,void 0,e)}};Hs.Y_PADDING=1,_o("field_image",Hs),Hs.prototype.DEFAULT_VALUE="";var Ni=class extends we{set size_(e){super.size_=e}get size_(){const e=super.size_;return e.width<14&&(e.width=14),e}constructor(e,t,o){super(we.SKIP_SETUP),this.spellcheck_=!0,this.htmlInput_=null,this.isTextValid_=this.isBeingEdited_=!1,this.onInputWrapper=this.onKeyDownWrapper=this.valueWhenEditorWasOpened_=null,this.fullBlockClickTarget_=!1,this.workspace_=null,this.SERIALIZABLE=!0,e!==we.SKIP_SETUP&&(o&&this.configure_(o),this.setValue(e),t&&this.setValidator(t))}configure_(e){super.configure_(e),e.spellcheck!==void 0&&(this.spellcheck_=e.spellcheck)}initView(){if(!this.getSourceBlock())throw new tt;super.initView(),this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot()),this.fieldGroup_&&G(this.fieldGroup_,"blocklyInputField")}isFullBlockField(){const e=this.getSourceBlock();if(!e)throw new tt;let t;return this.fullBlockClickTarget_=!((t=this.getConstants())==null||!t.FULL_BLOCK_FIELDS)&&e.isSimpleReporter()}doValueInvalid_(e,t=!0){this.isBeingEdited_&&(this.isDirty_=!0,this.isTextValid_=!1,e=this.value_,this.value_=this.valueWhenEditorWasOpened_,this.sourceBlock_&&J()&&this.value_!==e&&t&&_(new(U(w.BLOCK_CHANGE))(this.sourceBlock_,"field",this.name||null,e,this.value_)))}doValueUpdate_(e){this.isTextValid_=this.isDirty_=!0,this.value_=e}applyColour(){const e=this.getSourceBlock();if(!e)throw new tt;this.getConstants().FULL_BLOCK_FIELDS&&this.fieldGroup_&&(!this.isFullBlockField()&&this.borderRect_?(this.borderRect_.style.display="block",this.borderRect_.setAttribute("stroke",e.getColourTertiary())):(this.borderRect_.style.display="none",e.pathObject.svgPath.setAttribute("fill",this.getConstants().FIELD_BORDER_RECT_COLOUR)))}getSize(){let e;return(e=this.getConstants())!=null&&e.FULL_BLOCK_FIELDS&&(this.render_(),this.isDirty_=!1),super.getSize()}onLocationChange(){this.isBeingEdited_&&this.resizeEditor_()}render_(){if(super.render_(),this.isBeingEdited_){var e=this.htmlInput_;this.isTextValid_?(Te(e,"blocklyInvalidInput"),it(e,Qe.INVALID,!1)):(G(e,"blocklyInvalidInput"),it(e,Qe.INVALID,!0))}if(e=this.getSourceBlock(),!e)throw new tt;this.getConstants().FULL_BLOCK_FIELDS&&e.applyColour()}setSpellcheck(e){e!==this.spellcheck_&&(this.spellcheck_=e,this.htmlInput_&&this.htmlInput_.setAttribute("spellcheck",this.spellcheck_))}showEditor_(e,t=!1,o=!0){this.workspace_=this.sourceBlock_.workspace,!t&&this.workspace_.options.modalInputs&&(Wp||oa||Bn)?this.showPromptEditor():this.showInlineEditor(t,o)}showPromptEditor(){jr(r.Msg$$module$build$src$core$msg.CHANGE_VALUE_TITLE,this.getText(),e=>{e!==null&&this.setValue(this.getValueFromEditorText_(e)),this.onFinishEditing_(this.value_)})}showInlineEditor(e,t){const o=this.getSourceBlock();if(!o)throw new tt;hn(this,o.RTL,this.widgetDispose_.bind(this),this.workspace_,t),this.htmlInput_=this.widgetCreate_(),this.isBeingEdited_=!0,this.valueWhenEditorWasOpened_=this.value_,e||(this.htmlInput_.focus({preventScroll:!0}),this.htmlInput_.select())}widgetCreate_(){var e=this.getSourceBlock();if(!e)throw new tt;r.setGroup$$module$build$src$core$events$utils(!0);const t=oi();var o=this.getClickTarget_();if(!o)throw Error("A click target has not been set.");G(o,"blocklyEditing"),o=document.createElement("input"),o.className="blocklyHtmlInput",o.setAttribute("spellcheck",this.spellcheck_);const s=this.workspace_.getAbsoluteScale();var i=this.getConstants().FIELD_TEXT_FONTSIZE*s+"pt";return t.style.fontSize=i,o.style.fontSize=i,i=Ni.BORDERRADIUS*s+"px",this.isFullBlockField()&&(i=this.getScaledBBox(),i=(i.bottom-i.top)/2+"px",e=e.getParent()?e.getParent().getColourTertiary():this.sourceBlock_.getColourTertiary(),o.style.border=1*s+"px solid "+e,t.style.borderRadius=i,t.style.transition="box-shadow 0.25s ease 0s",this.getConstants().FIELD_TEXTINPUT_BOX_SHADOW&&(t.style.boxShadow="rgba(255, 255, 255, 0.3) 0 0 0 "+4*s+"px")),o.style.borderRadius=i,t.appendChild(o),o.value=o.defaultValue=this.getEditorText_(this.value_),o.setAttribute("data-untyped-default-value",String(this.value_)),this.resizeEditor_(),this.bindInputEvents_(o),o}widgetDispose_(){this.isBeingEdited_=!1,this.isTextValid_=!0,this.forceRerender(),this.onFinishEditing_(this.value_),this.sourceBlock_&&J()&&this.valueWhenEditorWasOpened_!==null&&this.valueWhenEditorWasOpened_!==this.value_&&(_(new(U(w.BLOCK_CHANGE))(this.sourceBlock_,"field",this.name||null,this.valueWhenEditorWasOpened_,this.value_)),this.valueWhenEditorWasOpened_=null),r.setGroup$$module$build$src$core$events$utils(!1),this.unbindInputEvents_();var e=oi().style;if(e.width="auto",e.height="auto",e.fontSize="",e.transition="",e.boxShadow="",this.htmlInput_=null,e=this.getClickTarget_(),!e)throw Error("A click target has not been set.");Te(e,"blocklyEditing")}onFinishEditing_(e){}bindInputEvents_(e){this.onKeyDownWrapper=z(e,"keydown",this,this.onHtmlInputKeyDown_),this.onInputWrapper=z(e,"input",this,this.onHtmlInputChange)}unbindInputEvents_(){this.onKeyDownWrapper&&(te(this.onKeyDownWrapper),this.onKeyDownWrapper=null),this.onInputWrapper&&(te(this.onInputWrapper),this.onInputWrapper=null)}onHtmlInputKeyDown_(e){if(e.key==="Enter")vs(this),mo();else if(e.key==="Escape")this.setValue(this.htmlInput_.getAttribute("data-untyped-default-value"),!1),vs(this),mo();else if(e.key==="Tab"){e.preventDefault();var t,o=(t=this.workspace_)==null?void 0:t.getCursor();t=s=>(s instanceof Ni||s instanceof Be&&s.isSimpleReporter())&&s!==this.getSourceBlock(),e=e.shiftKey?o?.getPreviousNode(this,t,!1):o?.getNextNode(this,t,!1),e=e instanceof Be&&e.isSimpleReporter()?e.getFields().next().value:e,e instanceof Ni&&(vs(this),mo(),o=e.getSourceBlock(),e.isFullBlockField()&&o&&o instanceof Be?r.getFocusManager$$module$build$src$core$focus_manager().focusNode(o):r.getFocusManager$$module$build$src$core$focus_manager().focusNode(e),e.showEditor())}}onHtmlInputChange(e){e=this.value_,this.setValue(this.getValueFromEditorText_(this.htmlInput_.value),!1),this.sourceBlock_&&J()&&this.value_!==e&&_(new(U(w.BLOCK_FIELD_INTERMEDIATE_CHANGE))(this.sourceBlock_,this.name||null,e,this.value_))}setEditorValue_(e,t=!0){this.isDirty_=!0,this.isBeingEdited_&&(this.htmlInput_.value=this.getEditorText_(e)),this.setValue(e,t)}resizeEditor_(){go().then(()=>{const e=this.getSourceBlock();if(!e)throw new tt;const t=oi(),o=this.getScaledBBox();t.style.width=o.right-o.left+"px",t.style.height=o.bottom-o.top+"px";const s=o.top;t.style.left=`${e.RTL?o.right-t.offsetWidth:o.left}px`,t.style.top=`${s}px`})}repositionForWindowResize(){let e;const t=(e=this.getSourceBlock())==null?void 0:e.getRootBlock();return t instanceof Be?(ci(this.workspace_,this.workspace_.getMetricsManager().getViewMetrics(!0),t)||this.resizeEditor_(),!0):!1}getText_(){return this.isBeingEdited_&&this.htmlInput_?this.htmlInput_.value:null}getEditorText_(e){return`${e}`}getValueFromEditorText_(e){return e}};Ni.BORDERRADIUS=4,r.FieldTextInput$$module$build$src$core$field_textinput=class extends Ni{constructor(e,t,o){super(e,t,o)}initView(){super.initView(),this.fieldGroup_&&G(this.fieldGroup_,"blocklyTextInputField")}doClassValidation_(e){return e===void 0?null:`${e}`}static fromJson(e){return new this(Je(e.text),void 0,e)}},_o("field_input",r.FieldTextInput$$module$build$src$core$field_textinput),r.FieldTextInput$$module$build$src$core$field_textinput.prototype.DEFAULT_VALUE="",r.FieldTextInput$$module$build$src$core$field_textinput;var Xm=class extends th{constructor(e){super(e)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(e){return!!e.outputConnection}hasRightSquareCorner(e){return!!e.outputConnection&&!e.statementInputCount&&!e.nextConnection}},Rl=class extends bl{constructor(e,t){if(super(e,t),this.connectedBottomNextConnection=!1,this.connectedBlock){for(e=this.connectedBlock;t=e.getNextBlock();)e=t;e.nextConnection||(this.height=this.connectedBlockHeight,this.connectedBottomNextConnection=!0)}}},jm=class extends So{constructor(e){super(e),this.width=this.height=0,this.type|=T.getType("RIGHT_CONNECTION")}},Km=class extends lh{constructor(e){super(e)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(e){const t=(e.hat?e.hat==="cap":this.constants_.ADD_START_HATS)&&!e.outputConnection&&!e.previousConnection;return!!e.outputConnection||t}hasRightSquareCorner(e){return!!e.outputConnection&&!e.statementInputCount&&!e.nextConnection}},Jm=class extends Cr{constructor(e,t){super(e,t),this.isInline=!0,this.renderer_=e,this.constants_=this.renderer_.getConstants(),this.topRow=new Km(this.constants_),this.bottomRow=new Xm(this.constants_),this.isMultiRow=!t.getInputsInline()||t.isCollapsed(),this.hasStatementInput=t.statementInputCount>0,this.rightSide=this.outputConnection?new jm(this.constants_):null,this.rightAlignedDummyInputs=new WeakMap}getRenderer(){return this.renderer_}measure(){this.createRows_(),this.addElemSpacing_(),this.addRowSpacing_(),this.adjustXPosition_(),this.computeBounds_(),this.alignRowElements_(),this.finalize_()}shouldStartNewRow_(e,t){return t?t instanceof Yo||e instanceof Yt||t instanceof Yt?!0:e instanceof r.ValueInput$$module$build$src$core$inputs$value_input||e instanceof Io||e instanceof Yo?!this.isInline||this.isMultiRow:!1:!1}getDesiredRowWidth_(e){return e.hasStatement?this.width-this.startX-(this.constants_.INSIDE_CORNERS.rightWidth||0):super.getDesiredRowWidth_(e)}getInRowSpacing_(e,t){return e&&t||!this.outputConnection||!this.outputConnection.isDynamicShape||this.hasStatementInput||this.bottomRow.hasNextConnection?!e&&t&&T.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:e&&T.isLeftRoundedCorner(e)&&t&&(T.isPreviousConnection(t)||T.isNextConnection(t))?t.notchOffset-this.constants_.CORNER_RADIUS:e&&T.isLeftSquareCorner(e)&&t&&T.isHat(t)||e&&T.isField(e)&&e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:this.constants_.NO_PADDING}getSpacerRowHeight_(e,t){if(T.isTopRow(e)&&T.isBottomRow(t))return this.constants_.EMPTY_BLOCK_SPACER_HEIGHT;const o=T.isInputRow(e)&&e.hasStatement,s=T.isInputRow(t)&&t.hasStatement;return s||o?(e=Math.max(this.constants_.NOTCH_HEIGHT,this.constants_.INSIDE_CORNERS.rightHeight||0),s&&o?Math.max(e,this.constants_.DUMMY_INPUT_MIN_HEIGHT):e):T.isTopRow(e)?e.hasPreviousConnection||this.outputConnection&&!this.hasStatementInput?this.constants_.NO_PADDING:Math.abs(this.constants_.NOTCH_HEIGHT-this.constants_.CORNER_RADIUS):T.isBottomRow(t)?this.outputConnection?!t.hasNextConnection&&this.hasStatementInput?Math.abs(this.constants_.NOTCH_HEIGHT-this.constants_.CORNER_RADIUS):this.constants_.NO_PADDING:Math.max(this.topRow.minHeight,Math.max(this.constants_.NOTCH_HEIGHT,this.constants_.CORNER_RADIUS))-this.constants_.CORNER_RADIUS:this.constants_.MEDIUM_PADDING}getSpacerRowWidth_(e,t){const o=this.width-this.startX;return T.isInputRow(e)&&e.hasStatement||T.isInputRow(t)&&t.hasStatement?Math.max(o,this.constants_.STATEMENT_INPUT_SPACER_MIN_WIDTH):o}getElemCenterline_(e,t){if(e.hasStatement&&!T.isSpacer(t)&&!T.isStatementInput(t))return e.yPos+this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT/2;if(T.isInlineInput(t)){const o=t.connectedBlock;if(o&&o.outputConnection&&o.nextConnection)return e.yPos+o.height/2}return super.getElemCenterline_(e,t)}addInput_(e,t){if((e instanceof Io||e instanceof Yo)&&t.hasDummyInput&&t.align===r.Align$$module$build$src$core$inputs$align.LEFT&&e.align===r.Align$$module$build$src$core$inputs$align.RIGHT)this.rightAlignedDummyInputs.set(t,e);else if(e instanceof Yt){t.elements.push(new Rl(this.constants_,e)),t.hasStatement=!0,t.align===null&&(t.align=e.align);return}super.addInput_(e,t)}addAlignmentPadding_(e,t){if(this.rightAlignedDummyInputs.get(e)){let o;for(let s=0;s<e.elements.length;s++){const i=e.elements[s];if(T.isSpacer(i)&&(o=i),T.isField(i)&&i.parentInput===this.rightAlignedDummyInputs.get(e))break}if(o){o.width+=t,e.width+=t;return}}super.addAlignmentPadding_(e,t)}adjustXPosition_(){const e=this.constants_.NOTCH_OFFSET_LEFT+this.constants_.NOTCH_WIDTH;let t=e;for(let i=2;i<this.rows.length-1;i+=2){var o=this.rows[i-1];const n=this.rows[i];var s=this.rows[i+1];if(o=i===2?!!this.topRow.hasPreviousConnection:!!o.followsStatement,s=i+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!s.precedesStatement,T.isInputRow(n)&&n.hasStatement){n.measure();let d,f;t=n.width-((f=(d=n.getLastInput())==null?void 0:d.width)!=null?f:0)+e}else if(o&&(i===2||s)&&T.isInputRow(n)&&!n.hasStatement){s=n.xPos,o=null;for(let d=0;d<n.elements.length;d++){const f=n.elements[d];T.isSpacer(f)&&(o=f),!(o&&(T.isField(f)||T.isInput(f))&&s<t)||T.isField(f)&&(f.field instanceof Ps||f.field instanceof Hs)||(o.width+=t-s),s+=f.width}}}}finalizeOutputConnection_(){if(this.outputConnection&&this.outputConnection.isDynamicShape){var e=this.outputConnection.shape;if("isDynamic"in e&&e.isDynamic){for(var t=0,o=0;o<this.rows.length;o++){const s=this.rows[o];s.yPos=t,t+=s.height}this.height=t,o=this.bottomRow.hasNextConnection?this.height-this.bottomRow.descenderHeight:this.height,t=e.height(o),o=e.width(o),this.outputConnection.height=t,this.outputConnection.width=o,this.outputConnection.startX=o,this.outputConnection.connectionOffsetY=e.connectionOffsetY(t),this.outputConnection.connectionOffsetX=e.connectionOffsetX(o),e=0,this.hasStatementInput||this.bottomRow.hasNextConnection||(e=o,this.rightSide.height=t,this.rightSide.width=e,this.rightSide.centerline=t/2,this.rightSide.xPos=this.width+e),this.startX=o,this.width+=o+e,this.widthWithChildren+=o+e}}}finalizeHorizontalAlignment_(){if(this.outputConnection&&!this.hasStatementInput&&!this.bottomRow.hasNextConnection){for(var e=0,t=0;t<this.rows.length;t++){var o=this.rows[t];if(!T.isInputRow(o))continue;e=o.elements[o.elements.length-2];let s=this.getNegativeSpacing_(o.elements[1]),i=this.getNegativeSpacing_(e);e=s+i;const n=this.constants_.MIN_BLOCK_WIDTH+this.outputConnection.width*2;this.width-e<n&&(e=this.width-n,s=e/2,i=e/2),o.elements.unshift(new Xt(this.constants_,-s)),o.elements.push(new Xt(this.constants_,-i))}if(e)for(this.width-=e,this.widthWithChildren-=e,this.rightSide.xPos-=e,t=0;t<this.rows.length;t++)o=this.rows[t],T.isTopOrBottomRow(o)&&(o.elements[1].width-=e),o.width-=e,o.widthWithConnectedBlocks-=e}}getNegativeSpacing_(e){if(!e||!this.outputConnection)return 0;const t=this.outputConnection.width;var o=this.outputConnection.shape.type;const s=this.constants_;if(this.inputRows.length>1)switch(o){case s.SHAPES.ROUND:return o=this.constants_.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,o=this.height/2>o?o:this.height/2,t-o*(1-Math.sin(Math.acos((o-this.constants_.SMALL_PADDING)/o)));default:return 0}if(T.isInlineInput(e)){const i=e.connectedBlock;return e=i?i.pathObject.outputShapeType:e.shape.type,e==null||i&&i.outputConnection&&(i.statementInputCount||i.nextConnection)||o===s.SHAPES.HEXAGONAL&&o!==e?0:t-this.constants_.SHAPE_IN_SHAPE_PADDING[o][e]}return T.isField(e)?o===s.SHAPES.ROUND&&e.field instanceof r.FieldTextInput$$module$build$src$core$field_textinput?t-2.75*s.GRID_UNIT:t-this.constants_.SHAPE_IN_SHAPE_PADDING[o][0]:T.isIcon(e)?this.constants_.SMALL_PADDING:0}finalizeVerticalAlignment_(){if(!this.outputConnection)for(let s=2;s<this.rows.length-1;s+=2){const i=this.rows[s-1],n=this.rows[s],d=this.rows[s+1];var e=s===2,t=s+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!d.precedesStatement;if(e?this.topRow.hasPreviousConnection:i.followsStatement){var o=n.elements[1];if(o=n.elements.length===3&&o instanceof sh&&(o.field instanceof Ps||o.field instanceof Hs),!e&&o)i.height-=this.constants_.SMALL_PADDING,d.height-=this.constants_.SMALL_PADDING,n.height-=this.constants_.MEDIUM_PADDING;else if(!e&&!t)i.height+=this.constants_.SMALL_PADDING;else if(t){for(e=!1,t=0;t<n.elements.length;t++)if(o=n.elements[t],T.isInlineInput(o)&&o.connectedBlock&&!o.connectedBlock.isShadow()&&o.connectedBlock.getHeightWidth().height>=40){e=!0;break}e&&(i.height-=this.constants_.SMALL_PADDING,d.height-=this.constants_.SMALL_PADDING)}}}}finalize_(){this.finalizeOutputConnection_(),this.finalizeHorizontalAlignment_(),this.finalizeVerticalAlignment_(),super.finalize_(),this.rightSide&&(this.widthWithChildren+=this.rightSide.width)}},qm=class extends yl{constructor(e,t,o){super(e,t,o),this.svgPathSelected=null,this.outlines=new Map,this.remainingOutlines=new Set,this.outputShapeType=null,this.constants=o}setPath(e){super.setPath(e),this.svgPathSelected&&this.svgPathSelected.setAttribute("d",e)}applyColour(e){super.applyColour(e);const t=e.getParent();e.isShadow()&&t&&this.svgPath.setAttribute("stroke",t.getColourTertiary());for(const o of this.outlines.values())o.setAttribute("fill",this.style.colourTertiary)}flipRTL(){super.flipRTL();for(const e of this.outlines.values())e.setAttribute("transform","scale(-1 1)")}updateSelected(e){this.setClass_("blocklySelected",e),e?this.svgPathSelected||(this.svgPathSelected=this.svgPath.cloneNode(!0),this.svgPathSelected.classList.add("blocklyPathSelected"),Te(this.svgPathSelected,Et.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),Te(this.svgPathSelected,Et.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME),this.svgPathSelected.removeAttribute("tabindex"),this.svgPathSelected.removeAttribute("id"),this.svgRoot.appendChild(this.svgPathSelected)):this.svgPathSelected&&(this.svgRoot.removeChild(this.svgPathSelected),this.svgPathSelected=null)}updateReplacementFade(e){this.setClass_("blocklyReplaceable",e)}updateShapeForInputHighlight(e,t){e=e.getParentInput().name,(e=this.getOutlinePath(e))&&(t?e.setAttribute("filter","url(#"+this.constants.replacementGlowFilterId+")"):e.removeAttribute("filter"))}beginDrawing(){this.remainingOutlines.clear();for(const e of this.outlines.keys())this.remainingOutlines.add(e)}endDrawing(){if(this.remainingOutlines.size)for(const e of this.remainingOutlines)this.removeOutlinePath(e);this.remainingOutlines.clear()}setOutlinePath(e,t){e=this.getOutlinePath(e),e.setAttribute("d",t),e.setAttribute("fill",this.style.colourTertiary)}getOutlinePath(e){return this.outlines.has(e)||this.outlines.set(e,v(R.PATH,{class:"blocklyOutlinePath",d:""},this.svgRoot)),this.remainingOutlines.delete(e),this.outlines.get(e)}removeOutlinePath(e){let t,o;(t=this.outlines.get(e))==null||(o=t.parentNode)==null||o.removeChild(this.outlines.get(e)),this.outlines.delete(e)}},fh=class extends vl{constructor(e){super(e)}makeConstants_(){return new zm}makeRenderInfo_(e){return new Jm(this,e)}makeDrawer_(e,t){return new Ym(e,t)}makePathObject(e,t){return new qm(e,t,this.getConstants())}getConstants(){return this.constants_}};Zi("zelos",fh);var Zm=class{constructor(e){this.staticConn=this.draggedConn=this.markerConn=this.fadedBlock=null,this.workspace=e.workspace}previewReplacement(e,t,o){r.disable$$module$build$src$core$events$utils();try{this.hidePreview(),this.fadedBlock=o,o.fadeForReplacement(!0),this.workspace.getRenderer().shouldHighlightConnection(t)&&(t.highlight(),this.staticConn=t)}finally{r.enable$$module$build$src$core$events$utils()}}previewConnection(e,t){if(e!==this.draggedConn||t!==this.staticConn){r.disable$$module$build$src$core$events$utils();try{this.hidePreview(),this.shouldUseMarkerPreview(e,t)&&(this.markerConn=this.previewMarker(e,t)),this.workspace.getRenderer().shouldHighlightConnection(t)&&t.highlight(),this.draggedConn=e,this.staticConn=t}finally{r.enable$$module$build$src$core$events$utils()}}}shouldUseMarkerPreview(e,t){return t.type===Z.PREVIOUS_STATEMENT||t.type===Z.NEXT_STATEMENT||!(this.workspace.getRenderer()instanceof fh)}previewMarker(e,t){const o=e.getSourceBlock(),s=this.createInsertionMarker(o),i=this.getMatchingConnection(o,s,e);if(!i)return null;s.queueRender(),Qo(),i.connect(t);const n={x:t.x-i.x,y:t.y-i.y},d=i.getOffsetInBlock().clone();return go().then(()=>{if(!s.isDeadOrDying()){r.disable$$module$build$src$core$events$utils();try{s?.positionNearConnection(i,n,d),s?.getSvgRoot().setAttribute("visibility","visible")}finally{r.enable$$module$build$src$core$events$utils()}}}),i}createInsertionMarker(e){const t=jt(e,{addCoordinates:!1,addInputBlocks:!1,addNextBlocks:!1,doFullSerialization:!1});if(!t)throw Error(`Failed to serialize source block. ${e.toDevString()}`);e=es(t,this.workspace);for(const o of e.getDescendants(!1))o.setInsertionMarker(!0);return e.initSvg(),e.getSvgRoot().setAttribute("visibility","hidden"),e}getMatchingConnection(e,t,o){if(e=e.getConnections_(!0),t=t.getConnections_(!0),e.length!==t.length)return null;for(let s=0;s<e.length;s++)if(e[s]===o)return t[s];return null}hidePreview(){r.disable$$module$build$src$core$events$utils();try{this.staticConn&&(this.staticConn.unhighlight(),this.staticConn=null),this.fadedBlock&&(this.fadedBlock.fadeForReplacement(!1),this.fadedBlock=null),this.markerConn&&(this.hideInsertionMarker(this.markerConn),this.draggedConn=this.markerConn=null)}finally{r.enable$$module$build$src$core$events$utils()}}hideInsertionMarker(e){const t=e.getSourceBlock(),o=t.outputConnection;let s;if((s=t.previousConnection)!=null&&s.targetConnection||o!=null&&o.targetConnection)t.unplug(!0);else{let i;(i=e.targetBlock())==null||i.unplug(!1)}t.dispose()}dispose(){this.hidePreview()}};l(M.CONNECTION_PREVIEWER,Ft,Zm);var $s={};$s.Align=r.Align$$module$build$src$core$inputs$align,$s.DummyInput=Io,$s.EndRowInput=Yo,$s.Input=vi,$s.StatementInput=Yt,$s.ValueInput=r.ValueInput$$module$build$src$core$inputs$value_input,$s.inputTypes=r.inputTypes$$module$build$src$core$inputs$input_types;var Qm=!1,ef;r.CodeGenerator$$module$build$src$core$generator=class{constructor(e){this.forBlock=Object.create(null),this.FUNCTION_NAME_PLACEHOLDER_="{leCUI8hutHZI4480Dc}",this.STATEMENT_SUFFIX=this.STATEMENT_PREFIX=this.INFINITE_LOOP_TRAP=null,this.INDENT=" ",this.COMMENT_WRAP=60,this.ORDER_OVERRIDES=[],this.isInitialized=null,this.RESERVED_WORDS_="",this.definitions_=Object.create(null),this.functionNames_=Object.create(null),this.nameDB_=void 0,this.name_=e,this.FUNCTION_NAME_PLACEHOLDER_REGEXP_=new RegExp(this.FUNCTION_NAME_PLACEHOLDER_,"g")}workspaceToCode(e){e||(console.warn("No workspace specified in workspaceToCode call. Guessing."),e=c());var t=[];this.init(e),e=e.getTopBlocks(!0);for(let o=0,s;s=e[o];o++){let i=this.blockToCode(s);Array.isArray(i)&&(i=i[0]),i&&(s.outputConnection&&(i=this.scrubNakedValue(i),this.STATEMENT_PREFIX&&!s.suppressPrefixSuffix&&(i=this.injectId(this.STATEMENT_PREFIX,s)+i),this.STATEMENT_SUFFIX&&!s.suppressPrefixSuffix&&(i+=this.injectId(this.STATEMENT_SUFFIX,s))),t.push(i))}return t=t.join(`
657
+ `);var th={};th.register=pu,th.unregister=up;var oh=17,km=160,Rm=80,Xo=class extends br{constructor(e){super(e),this.sourceBlock=e,this.textInputBubble=null,this.text="",this.bubbleSize=new ve(km,Rm),this.bubbleVisiblity=!1}getType(){return Xo.TYPE}initView(e){this.svgRoot||(super.initView(e),v(R.CIRCLE,{class:"blocklyIconShape",r:"8",cx:"8",cy:"8"},this.svgRoot),v(R.PATH,{class:"blocklyIconSymbol",d:"m6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.4050.607,-5.534 -3.765,-3.874v1.7c3.12,-1.657 3.698,0.118 2.336,1.25-1.201,0.998 -1.201,1.528 -1.204,2.19z"},this.svgRoot),v(R.RECT,{class:"blocklyIconSymbol",x:"6.8",y:"10.78",height:"2",width:"2"},this.svgRoot),G(this.svgRoot,"blocklyCommentIcon"))}dispose(){super.dispose();let e;(e=this.textInputBubble)==null||e.dispose()}getWeight(){return Xo.WEIGHT}getSize(){return new ve(oh,oh)}applyColour(){super.applyColour();const e=this.sourceBlock.getColour();let t;(t=this.textInputBubble)==null||t.setColour(e)}updateEditable(){const e=this,t=()=>super.updateEditable;return(0,N.asyncExecutePromiseGeneratorFunction)(function*(){t().call(e),e.bubbleIsVisible()&&(yield e.setBubbleVisible(!1),yield e.setBubbleVisible(!0))})}onLocationChange(e){const t=this.workspaceLocation;super.onLocationChange(e),this.bubbleLocation&&(e=P.difference(this.workspaceLocation,t),this.bubbleLocation=P.sum(this.bubbleLocation,e)),e=this.getAnchorLocation();let o;(o=this.textInputBubble)==null||o.setAnchorLocation(e)}setText(e){const t=this.text;_(new(U(w.BLOCK_CHANGE))(this.sourceBlock,"comment",null,t,e)),this.text=e;let o;(o=this.textInputBubble)==null||o.setText(this.text)}getText(){return this.text}setBubbleSize(e){this.bubbleSize=e;let t;(t=this.textInputBubble)==null||t.setSize(this.bubbleSize,!0)}getBubbleSize(){return this.bubbleSize}setBubbleLocation(e){this.bubbleLocation=e;let t;(t=this.textInputBubble)==null||t.moveDuringDrag(e)}getBubbleLocation(){return this.bubbleLocation}saveState(){if(this.text){const e={text:this.text,pinned:this.bubbleIsVisible(),height:this.bubbleSize.height,width:this.bubbleSize.width},t=this.getBubbleLocation();return t&&(e.x=this.sourceBlock.workspace.RTL?this.sourceBlock.workspace.getWidth()-(t.x+this.bubbleSize.width):t.x,e.y=t.y),e}return null}loadState(e){let t;this.text=(t=e.text)!=null?t:"";let o,s;this.bubbleSize=new ve((o=e.width)!=null?o:km,(s=e.height)!=null?s:Rm);let i;this.bubbleVisiblity=(i=e.pinned)!=null?i:!1,this.setBubbleVisible(this.bubbleVisiblity);let n=e.x;const d=e.y;go().then(()=>{n&&d&&(n=this.sourceBlock.workspace.RTL?this.sourceBlock.workspace.getWidth()-(n+this.bubbleSize.width):n,this.setBubbleLocation(new P(n,d)))})}onClick(){super.onClick(),this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}onTextChange(){if(this.textInputBubble){var e=this.textInputBubble.getText();this.text!==e&&(_(new(U(w.BLOCK_CHANGE))(this.sourceBlock,"comment",null,this.text,e)),this.text=e)}}onSizeChange(){this.textInputBubble&&(this.bubbleSize=this.textInputBubble.getSize())}onBubbleLocationChange(){this.textInputBubble&&(this.bubbleLocation=this.textInputBubble.getRelativeToSurfaceXY())}bubbleIsVisible(){return this.bubbleVisiblity}setBubbleVisible(e){const t=this;return(0,N.asyncExecutePromiseGeneratorFunction)(function*(){t.bubbleVisiblity!==e&&(t.bubbleVisiblity=e,yield go(),!t.sourceBlock.rendered||t.sourceBlock.isInFlyout||t.sourceBlock.isInsertionMarker()||(e?(t.sourceBlock.isEditable()?t.showEditableBubble():t.showNonEditableBubble(),t.applyColour()):t.hideBubble(),_(new(U(w.BUBBLE_OPEN))(t.sourceBlock,e,"comment"))))})}getBubble(){return this.textInputBubble}showEditableBubble(){this.createBubble();let e;(e=this.textInputBubble)==null||e.addTextChangeListener(()=>this.onTextChange());let t;(t=this.textInputBubble)==null||t.addSizeChangeListener(()=>this.onSizeChange())}showNonEditableBubble(){this.createBubble();let e;(e=this.textInputBubble)==null||e.setEditable(!1)}createBubble(){this.textInputBubble=new eh(this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect()),this.textInputBubble.setText(this.getText()),this.textInputBubble.setSize(this.bubbleSize,!0),this.bubbleLocation&&this.textInputBubble.moveDuringDrag(this.bubbleLocation),this.textInputBubble.addTextChangeListener(()=>this.onTextChange()),this.textInputBubble.addSizeChangeListener(()=>this.onSizeChange()),this.textInputBubble.addLocationChangeListener(()=>this.onBubbleLocationChange())}hideBubble(){let e;(e=this.textInputBubble)==null||e.dispose(),this.textInputBubble=null}getAnchorLocation(){const e=oh/2;return P.sum(this.workspaceLocation,new P(e,e))}getBubbleOwnerRect(){return this.sourceBlock.getBoundingRectangleWithoutChildren()}};Xo.TYPE=ut.COMMENT,Xo.WEIGHT=3,pu(Xo.TYPE,Xo);var as={};as.CommentIcon=Xo,as.Icon=br,as.IconType=ut,as.MutatorIcon=r.MutatorIcon$$module$build$src$core$icons$mutator_icon,as.WarningIcon=Co,as.exceptions=lm,as.registry=th,r.Names$$module$build$src$core$names=class{constructor(e,t){this.db=new Map,this.dbReverse=new Set,this.variableMap=null,this.variablePrefix=t||"",this.reservedWords=new Set(e?e.split(","):[])}reset(){this.db.clear(),this.dbReverse.clear(),this.variableMap=null}setVariableMap(e){this.variableMap=e}getNameForUserVariable(e){return this.variableMap?(e=this.variableMap.getVariableById(e))?e.getName():null:(console.warn(`Deprecated call to Names.prototype.getName without defining a variable map. To fix, add the following code in your generator's init() function:
658
+ Blockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());`),null)}populateVariables(e){e=r.allUsedVarModels$$module$build$src$core$variables(e);for(let t=0;t<e.length;t++)this.getName(e[t].getId(),r.NameType$$module$build$src$core$names.VARIABLE)}populateProcedures(e){throw Error("The implementation of populateProcedures should be monkey-patched in by blockly.ts")}getName(e,t){let o=e;t===r.NameType$$module$build$src$core$names.VARIABLE&&(e=this.getNameForUserVariable(e))&&(o=e),e=o.toLowerCase();const s=t===r.NameType$$module$build$src$core$names.VARIABLE||t===r.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE?this.variablePrefix:"";this.db.has(t)||this.db.set(t,new Map);const i=this.db.get(t);return i.has(e)?s+i.get(e):(t=this.getDistinctName(o,t),i.set(e,t.substr(s.length)),t)}getUserNames(e){let t;return(e=(t=this.db.get(e))==null?void 0:t.keys())?Array.from(e):[]}getDistinctName(e,t){e=this.safeName(e);let o=null,s,i;for(;this.dbReverse.has(e+((s=o)!=null?s:""))||this.reservedWords.has(e+((i=o)!=null?i:""));)o=o?o+1:2;let n;return e+=(n=o)!=null?n:"",this.dbReverse.add(e),(t===r.NameType$$module$build$src$core$names.VARIABLE||t===r.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE?this.variablePrefix:"")+e}safeName(e){return e?(e=encodeURI(e.replace(/ /g,"_")).replace(/[^\w]/g,"_"),"0123456789".includes(e[0])&&(e="my_"+e)):e=r.Msg$$module$build$src$core$msg.UNNAMED_KEY||"unnamed",e}static equals(e,t){return e.toLowerCase()===t.toLowerCase()}},(function(e){e=e.NameType||(e.NameType={}),e.DEVELOPER_VARIABLE="DEVELOPER_VARIABLE",e.VARIABLE="VARIABLE",e.PROCEDURE="PROCEDURE"})(r.Names$$module$build$src$core$names||(r.Names$$module$build$src$core$names={})),r.NameType$$module$build$src$core$names=r.Names$$module$build$src$core$names.NameType,r.Names$$module$build$src$core$names.DEVELOPER_VARIABLE_TYPE=r.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE,r.NameType$$module$build$src$core$names,r.Names$$module$build$src$core$names;var wm=class extends Map{constructor(){super()}set(e,t){return this.get(e)===t?this:(super.set(e,t),En(t)&&t.startPublishing(),this)}delete(e){const t=this.get(e);return e=super.delete(e),e&&(En(t)&&t.stopPublishing(),e)}clear(){if(this.size)for(const e of this.keys())this.delete(e)}add(e){return this.set(e.getId(),e)}getProcedures(){return[...this.values()]}},_l,Nt;_l="PROCEDURE",r.DEFAULT_ARG$$module$build$src$core$procedures="x",Nt={CATEGORY_NAME:_l,DEFAULT_ARG:r.DEFAULT_ARG$$module$build$src$core$procedures},Nt.ObservableProcedureMap=wm,Nt.allProcedures=Zi,Nt.findLegalName=r.findLegalName$$module$build$src$core$procedures,Nt.flyoutCategory=fu,Nt.getCallers=Tu,Nt.getDefinition=r.getDefinition$$module$build$src$core$procedures,Nt.internalFlyoutCategory=yn,Nt.isNameUsed=mu,Nt.isProcedureBlock=os,Nt.mutateCallers=r.mutateCallers$$module$build$src$core$procedures,Nt.mutatorOpenListener=bu,Nt.rename=r.rename$$module$build$src$core$procedures;var Db=class{constructor(){this.NONE=0,this.FIELD=1,this.HAT=2,this.ICON=4,this.SPACER=8,this.BETWEEN_ROW_SPACER=16,this.IN_ROW_SPACER=32,this.EXTERNAL_VALUE_INPUT=64,this.INPUT=128,this.INLINE_INPUT=256,this.STATEMENT_INPUT=512,this.CONNECTION=1024,this.PREVIOUS_CONNECTION=2048,this.NEXT_CONNECTION=4096,this.OUTPUT_CONNECTION=8192,this.CORNER=16384,this.LEFT_SQUARE_CORNER=32768,this.LEFT_ROUND_CORNER=65536,this.RIGHT_SQUARE_CORNER=131072,this.RIGHT_ROUND_CORNER=262144,this.JAGGED_EDGE=524288,this.ROW=1048576,this.TOP_ROW=2097152,this.BOTTOM_ROW=4194304,this.INPUT_ROW=8388608,this.LEFT_CORNER=this.LEFT_SQUARE_CORNER|this.LEFT_ROUND_CORNER,this.RIGHT_CORNER=this.RIGHT_SQUARE_CORNER|this.RIGHT_ROUND_CORNER,this.nextTypeValue_=16777216}getType(e){return Object.prototype.hasOwnProperty.call(this,e)||(this[e]=this.nextTypeValue_,this.nextTypeValue_<<=1),this[e]}isField(e){return(e.type&this.FIELD)>=1}isHat(e){return(e.type&this.HAT)>=1}isIcon(e){return(e.type&this.ICON)>=1}isSpacer(e){return(e.type&this.SPACER)>=1}isInRowSpacer(e){return(e.type&this.IN_ROW_SPACER)>=1}isSpacerRow(e){return(e.type&this.BETWEEN_ROW_SPACER)>=1}isInput(e){return(e.type&this.INPUT)>=1}isExternalInput(e){return(e.type&this.EXTERNAL_VALUE_INPUT)>=1}isInlineInput(e){return(e.type&this.INLINE_INPUT)>=1}isStatementInput(e){return(e.type&this.STATEMENT_INPUT)>=1}isPreviousConnection(e){return(e.type&this.PREVIOUS_CONNECTION)>=1}isNextConnection(e){return(e.type&this.NEXT_CONNECTION)>=1}isPreviousOrNextConnection(e){return this.isPreviousConnection(e)||this.isNextConnection(e)}isRoundCorner(e){return(e.type&this.LEFT_ROUND_CORNER)>=1||(e.type&this.RIGHT_ROUND_CORNER)>=1}isLeftRoundedCorner(e){return this.isRoundCorner(e)&&(e.type&this.LEFT_ROUND_CORNER)>=1}isRightRoundedCorner(e){return this.isRoundCorner(e)&&(e.type&this.RIGHT_ROUND_CORNER)>=1}isLeftSquareCorner(e){return(e.type&this.LEFT_SQUARE_CORNER)>=1}isRightSquareCorner(e){return(e.type&this.RIGHT_SQUARE_CORNER)>=1}isCorner(e){return(e.type&this.CORNER)>=1}isJaggedEdge(e){return(e.type&this.JAGGED_EDGE)>=1}isRow(e){return(e.type&this.ROW)>=1}isBetweenRowSpacer(e){return(e.type&this.BETWEEN_ROW_SPACER)>=1}isTopRow(e){return(e.type&this.TOP_ROW)>=1}isBottomRow(e){return(e.type&this.BOTTOM_ROW)>=1}isTopOrBottomRow(e){return this.isTopRow(e)||this.isBottomRow(e)}isInputRow(e){return(e.type&this.INPUT_ROW)>=1}},T=new Db,So=class{constructor(e){this.centerline=this.xPos=this.height=this.width=0,this.constants_=e,this.type=T.NONE,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}},vr=class{constructor(e){this.elements=[],this.xPos=this.yPos=this.widthWithConnectedBlocks=this.minWidth=this.minHeight=this.width=this.height=0,this.hasStatement=this.hasExternalInput=!1,this.statementEdge=0,this.hasJaggedEdge=this.hasDummyInput=this.hasInlineInput=!1,this.align=null,this.constants_=e,this.type=T.ROW,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}getLastInput(){for(let e=this.elements.length-1;e>=0;e--){const t=this.elements[e];if(T.isInput(t))return t}return null}measure(){throw Error("Unexpected attempt to measure a base Row.")}startsWithElemSpacer(){return!0}endsWithElemSpacer(){return!0}getFirstSpacer(){for(let e=0;e<this.elements.length;e++){const t=this.elements[e];if(T.isInRowSpacer(t))return t}return null}getLastSpacer(){for(let e=this.elements.length-1;e>=0;e--){const t=this.elements[e];if(T.isInRowSpacer(t))return t}return null}},sh=class extends vr{constructor(e){super(e),this.hasNextConnection=!1,this.connection=null,this.baseline=this.descenderHeight=0,this.type|=T.BOTTOM_ROW}hasLeftSquareCorner(e){return!!e.outputConnection||!!e.getNextBlock()}hasRightSquareCorner(e){return!0}measure(){let e=0,t=0,o=0;for(let s=0;s<this.elements.length;s++){const i=this.elements[s];t+=i.width,T.isSpacer(i)||(T.isNextConnection(i)?o=Math.max(o,i.height):e=Math.max(e,i.height))}this.width=Math.max(this.minWidth,t),this.height=Math.max(this.minHeight,e)+o,this.descenderHeight=o,this.widthWithConnectedBlocks=this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}},Us=class extends So{constructor(e,t){super(e),this.connectionModel=t,this.type|=T.CONNECTION,this.shape=this.constants_.shapeFor(t),this.isDynamicShape="isDynamic"in this.shape&&this.shape.isDynamic,this.highlighted=t.isHighlighted()}},bl=class extends Us{constructor(e,t){super(e,t.connection),this.input=t,this.connectionOffsetY=this.connectionOffsetX=0,this.type|=T.INPUT,this.align=t.align,(this.connectedBlock=t.connection&&t.connection.targetBlock()?t.connection.targetBlock():null)?(e=this.connectedBlock.getHeightWidth(),this.connectedBlockWidth=e.width,this.connectedBlockHeight=e.height):this.connectedBlockHeight=this.connectedBlockWidth=0}},ih=class extends bl{constructor(e,t){super(e,t),this.height=0,this.type|=T.EXTERNAL_VALUE_INPUT,this.height=this.connectedBlock?this.connectedBlockHeight-this.constants_.TAB_OFFSET_FROM_TOP-this.constants_.MEDIUM_PADDING:this.shape.height,this.width=this.shape.width+this.constants_.EXTERNAL_VALUE_INPUT_PADDING,this.connectionOffsetY=this.constants_.TAB_OFFSET_FROM_TOP,this.connectionHeight=this.shape.height,this.connectionWidth=this.shape.width}},rh=class extends So{constructor(e,t,o){super(e),this.field=t,this.parentInput=o,this.isEditable=t.EDITABLE,this.flipRtl=t.getFlipRtl(),this.type|=T.FIELD,e=this.field.getSize(),this.height=e.height,this.width=e.width}},Om=class extends So{constructor(e){super(e),this.type|=T.HAT,this.height=this.constants_.START_HAT.height,this.width=this.constants_.START_HAT.width,this.ascenderHeight=this.height}},Nm=class extends So{constructor(e,t){super(e),this.icon=t,this.flipRtl=!1,this.type|=T.ICON,e=t.getSize(),this.height=e.height,this.width=e.width}},Xt=class extends So{constructor(e,t){super(e),this.type|=T.SPACER|T.IN_ROW_SPACER,this.width=t,this.height=this.constants_.SPACER_DEFAULT_HEIGHT}},nh=class extends bl{constructor(e,t){super(e,t),this.type|=T.INLINE_INPUT,this.connectedBlock?(this.width=this.connectedBlockWidth,this.height=this.connectedBlockHeight):(this.height=this.constants_.EMPTY_INLINE_INPUT_HEIGHT,this.width=this.constants_.EMPTY_INLINE_INPUT_PADDING),this.connectionHeight=this.isDynamicShape?this.shape.height(this.height):this.shape.height,this.connectionWidth=this.isDynamicShape?this.shape.width(this.height):this.shape.width,this.connectedBlock||(this.width+=this.connectionWidth*(this.isDynamicShape?2:1)),this.connectionOffsetY="connectionOffsetY"in this.shape?this.shape.connectionOffsetY(this.connectionHeight):this.constants_.TAB_OFFSET_FROM_TOP,this.connectionOffsetX="connectionOffsetX"in this.shape?this.shape.connectionOffsetX(this.connectionWidth):0}},lh=class extends vr{constructor(e){super(e),this.connectedBlockWidths=0,this.type|=T.INPUT_ROW}measure(){this.width=this.minWidth,this.height=this.minHeight;let e=0;for(let t=0;t<this.elements.length;t++){const o=this.elements[t];this.width+=o.width,T.isInput(o)&&(T.isStatementInput(o)?e+=o.connectedBlockWidth:T.isExternalInput(o)&&o.connectedBlockWidth!==0&&(e+=o.connectedBlockWidth-o.connectionWidth)),T.isSpacer(o)||(this.height=Math.max(this.height,o.height))}this.connectedBlockWidths=e,this.widthWithConnectedBlocks=this.width+e}endsWithElemSpacer(){return!this.hasExternalInput&&!this.hasStatement}},Am=class extends So{constructor(e){super(e),this.type|=T.JAGGED_EDGE,this.height=this.constants_.JAGGED_TEETH.height,this.width=this.constants_.JAGGED_TEETH.width}},Lm=class extends Us{constructor(e,t){super(e,t),this.type|=T.NEXT_CONNECTION,this.height=this.shape.height,this.width=this.shape.width}},Mm=class extends Us{constructor(e,t){super(e,t),this.connectionOffsetX=0,this.type|=T.OUTPUT_CONNECTION,this.height=this.isDynamicShape?0:this.shape.height,this.startX=this.width=this.isDynamicShape?0:this.shape.width,this.connectionOffsetY=this.constants_.TAB_OFFSET_FROM_TOP}},Dm=class extends Us{constructor(e,t){super(e,t),this.type|=T.PREVIOUS_CONNECTION,this.height=this.shape.height,this.width=this.shape.width}},Ir=class extends So{constructor(e,t){super(e),this.type=(t&&t!=="left"?T.RIGHT_ROUND_CORNER:T.LEFT_ROUND_CORNER)|T.CORNER,this.width=this.constants_.CORNER_RADIUS,this.height=this.constants_.CORNER_RADIUS/2}},ch=class extends vr{constructor(e,t,o){super(e),this.height=t,this.width=o,this.precedesStatement=this.followsStatement=!1,this.widthWithConnectedBlocks=0,this.type|=T.SPACER|T.BETWEEN_ROW_SPACER,this.elements=[new Xt(this.constants_,o)]}measure(){}},Cr=class extends So{constructor(e,t){super(e),this.type=(t&&t!=="left"?T.RIGHT_SQUARE_CORNER:T.LEFT_SQUARE_CORNER)|T.CORNER,this.width=this.height=this.constants_.NO_PADDING}},Tl=class extends bl{constructor(e,t){super(e,t),this.type|=T.STATEMENT_INPUT,this.height=this.connectedBlock?this.connectedBlockHeight+this.constants_.STATEMENT_BOTTOM_SPACER:this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT,this.width=this.constants_.STATEMENT_INPUT_NOTCH_OFFSET+this.shape.width}},uh=class extends vr{constructor(e){super(e),this.ascenderHeight=this.capline=0,this.hasPreviousConnection=!1,this.connection=null,this.type|=T.TOP_ROW}hasLeftSquareCorner(e){const t=(e.hat?e.hat==="cap":this.constants_.ADD_START_HATS)&&!e.outputConnection&&!e.previousConnection,o=e.getPreviousBlock();return!!e.outputConnection||t||(o?o.getNextBlock()===e:!1)}hasRightSquareCorner(e){return!0}measure(){let e=0,t=0,o=0;for(let s=0;s<this.elements.length;s++){const i=this.elements[s];t+=i.width,T.isSpacer(i)||(T.isHat(i)?o=Math.max(o,i.ascenderHeight):e=Math.max(e,i.height))}this.width=Math.max(this.minWidth,t),this.height=Math.max(this.minHeight,e)+o,this.capline=this.ascenderHeight=o,this.widthWithConnectedBlocks=this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}},El=class{constructor(){this.NO_PADDING=0,this.SMALL_PADDING=3,this.MEDIUM_PADDING=5,this.MEDIUM_LARGE_PADDING=8,this.LARGE_PADDING=10,this.TAB_HEIGHT=15,this.TAB_OFFSET_FROM_TOP=5,this.TAB_VERTICAL_OVERLAP=2.5,this.TAB_WIDTH=8,this.NOTCH_WIDTH=15,this.NOTCH_HEIGHT=4,this.MIN_BLOCK_WIDTH=12,this.EMPTY_BLOCK_SPACER_HEIGHT=16,this.CORNER_RADIUS=8,this.NOTCH_OFFSET_LEFT=15,this.STATEMENT_BOTTOM_SPACER=0,this.STATEMENT_INPUT_PADDING_LEFT=20,this.BETWEEN_STATEMENT_PADDING_Y=4,this.ADD_START_HATS=!1,this.START_HAT_HEIGHT=15,this.START_HAT_WIDTH=100,this.SPACER_DEFAULT_HEIGHT=15,this.MIN_BLOCK_HEIGHT=24,this.EMPTY_INLINE_INPUT_PADDING=14.5,this.EXTERNAL_VALUE_INPUT_PADDING=2,this.JAGGED_TEETH_HEIGHT=12,this.JAGGED_TEETH_WIDTH=6,this.FIELD_TEXT_FONTSIZE=11,this.FIELD_TEXT_FONTWEIGHT="normal",this.FIELD_TEXT_FONTFAMILY="sans-serif",this.FIELD_TEXT_BASELINE=this.FIELD_TEXT_HEIGHT=-1,this.FIELD_BORDER_RECT_RADIUS=4,this.FIELD_BORDER_RECT_HEIGHT=16,this.FIELD_BORDER_RECT_X_PADDING=5,this.FIELD_BORDER_RECT_Y_PADDING=3,this.FIELD_BORDER_RECT_COLOUR="#fff",this.FIELD_DROPDOWN_SVG_ARROW=this.FIELD_DROPDOWN_COLOURED_DIV=this.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW=!1,this.FIELD_DROPDOWN_SVG_ARROW_SIZE=12,this.FIELD_COLOUR_FULL_BLOCK=this.FIELD_TEXTINPUT_BOX_SHADOW=!1,this.FIELD_COLOUR_DEFAULT_WIDTH=26,this.defs=null,this.embossFilterId="",this.embossFilter=null,this.disabledPatternId="",this.disabledPattern=null,this.debugFilterId="",this.cssNode=this.debugFilter=null,this.CURSOR_COLOUR="#cc0a0a",this.MARKER_COLOUR="#4286f4",this.CURSOR_WS_WIDTH=100,this.WS_CURSOR_HEIGHT=5,this.CURSOR_STACK_PADDING=10,this.CURSOR_BLOCK_PADDING=2,this.CURSOR_STROKE_WIDTH=4,this.FULL_BLOCK_FIELDS=!1,this.INSERTION_MARKER_COLOUR="#000000",this.INSERTION_MARKER_OPACITY=.2,this.SHAPES={PUZZLE:1,NOTCH:2},this.TALL_INPUT_FIELD_OFFSET_Y=this.MEDIUM_PADDING,this.DUMMY_INPUT_SHADOW_MIN_HEIGHT=this.DUMMY_INPUT_MIN_HEIGHT=this.TAB_HEIGHT,this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT,this.TOP_ROW_MIN_HEIGHT=this.MEDIUM_PADDING,this.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING,this.BOTTOM_ROW_MIN_HEIGHT=this.MEDIUM_PADDING,this.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING,this.EMPTY_INLINE_INPUT_HEIGHT=this.TAB_HEIGHT+11,this.EMPTY_STATEMENT_INPUT_HEIGHT=this.MIN_BLOCK_HEIGHT,this.START_POINT=je(0,0),this.FIELD_TEXT_BASELINE_CENTER=!0,this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT,this.FIELD_DROPDOWN_SVG_ARROW_PADDING=this.FIELD_BORDER_RECT_X_PADDING,this.FIELD_DROPDOWN_SVG_ARROW_DATAURI="data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMi43MSIgaGVpZ2h0PSI4Ljc5IiB2aWV3Qm94PSIwIDAgMTIuNzEgOC43OSI+PHRpdGxlPmRyb3Bkb3duLWFycm93PC90aXRsZT48ZyBvcGFjaXR5PSIwLjEiPjxwYXRoIGQ9Ik0xMi43MSwyLjQ0QTIuNDEsMi40MSwwLDAsMSwxMiw0LjE2TDguMDgsOC4wOGEyLjQ1LDIuNDUsMCwwLDEtMy40NSwwTDAuNzIsNC4xNkEyLjQyLDIuNDIsMCwwLDEsMCwyLjQ0LDIuNDgsMi40OCwwLDAsMSwuNzEuNzFDMSwwLjQ3LDEuNDMsMCw2LjM2LDBTMTEuNzUsMC40NiwxMiwuNzFBMi40NCwyLjQ0LDAsMCwxLDEyLjcxLDIuNDRaIiBmaWxsPSIjMjMxZjIwIi8+PC9nPjxwYXRoIGQ9Ik02LjM2LDcuNzlhMS40MywxLjQzLDAsMCwxLTEtLjQyTDEuNDIsMy40NWExLjQ0LDEuNDQsMCwwLDEsMC0yYzAuNTYtLjU2LDkuMzEtMC41Niw5Ljg3LDBhMS40NCwxLjQ0LDAsMCwxLDAsMkw3LjM3LDcuMzdBMS40MywxLjQzLDAsMCwxLDYuMzYsNy43OVoiIGZpbGw9IiNmZmYiLz48L3N2Zz4=",this.FIELD_COLOUR_DEFAULT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT,this.FIELD_CHECKBOX_X_OFFSET=this.FIELD_BORDER_RECT_X_PADDING-3,this.randomIdentifier=String(Math.random()).substring(2)}init(){this.JAGGED_TEETH=this.makeJaggedTeeth(),this.NOTCH=this.makeNotch(),this.START_HAT=this.makeStartHat(),this.PUZZLE_TAB=this.makePuzzleTab(),this.INSIDE_CORNERS=this.makeInsideCorners(),this.OUTSIDE_CORNERS=this.makeOutsideCorners()}setTheme(e){this.blockStyles=Object.create(null);const t=e.blockStyles;for(const o in t)this.blockStyles[o]=this.validatedBlockStyle_(t[o]);this.setDynamicProperties_(e)}setDynamicProperties_(e){this.setFontConstants_(e),this.setComponentConstants_(e),this.ADD_START_HATS=e.startHats!==void 0?e.startHats:this.ADD_START_HATS}setFontConstants_(e){e.fontStyle&&e.fontStyle.family&&(this.FIELD_TEXT_FONTFAMILY=e.fontStyle.family),e.fontStyle&&e.fontStyle.weight&&(this.FIELD_TEXT_FONTWEIGHT=e.fontStyle.weight),e.fontStyle&&e.fontStyle.size&&(this.FIELD_TEXT_FONTSIZE=e.fontStyle.size),e=E("Hg",this.FIELD_TEXT_FONTSIZE+"pt",this.FIELD_TEXT_FONTWEIGHT,this.FIELD_TEXT_FONTFAMILY),this.FIELD_TEXT_HEIGHT=e.height,this.FIELD_TEXT_BASELINE=e.baseline}setComponentConstants_(e){this.CURSOR_COLOUR=e.getComponentStyle("cursorColour")||this.CURSOR_COLOUR,this.MARKER_COLOUR=e.getComponentStyle("markerColour")||this.MARKER_COLOUR,this.INSERTION_MARKER_COLOUR=e.getComponentStyle("insertionMarkerColour")||this.INSERTION_MARKER_COLOUR,this.INSERTION_MARKER_OPACITY=Number(e.getComponentStyle("insertionMarkerOpacity"))||this.INSERTION_MARKER_OPACITY}getBlockStyleForColour(e){const t="auto_"+e;return this.blockStyles[t]||(this.blockStyles[t]=this.createBlockStyle_(e)),{style:this.blockStyles[t],name:t}}getBlockStyle(e){return this.blockStyles[e||""]||(e&&e.startsWith("auto_")?this.getBlockStyleForColour(e.substring(5)).style:this.createBlockStyle_("#000000"))}createBlockStyle_(e){return this.validatedBlockStyle_({colourPrimary:e})}validatedBlockStyle_(e){const t={};return e&&Object.assign(t,e),e=ti(t.colourPrimary||"#000"),t.colourPrimary=e.hex,t.colourSecondary=t.colourSecondary?ti(t.colourSecondary).hex:this.generateSecondaryColour_(t.colourPrimary),t.colourTertiary=t.colourTertiary?ti(t.colourTertiary).hex:this.generateTertiaryColour_(t.colourPrimary),t.hat=t.hat||"",t}generateSecondaryColour_(e){return ys("#fff",e,.6)||e}generateTertiaryColour_(e){return ys("#fff",e,.3)||e}dispose(){this.embossFilter&&ke(this.embossFilter),this.disabledPattern&&ke(this.disabledPattern),this.debugFilter&&ke(this.debugFilter),this.cssNode=null}makeJaggedTeeth(){const e=this.JAGGED_TEETH_HEIGHT,t=this.JAGGED_TEETH_WIDTH,o=ni([se(t,e/4),se(-t*2,e/2),se(t,e/4)]);return{height:e,width:t,path:o}}makeStartHat(){const e=this.START_HAT_HEIGHT,t=this.START_HAT_WIDTH,o=Pt("c",[se(30,-e),se(70,-e),se(t,0)]);return{height:e*.75,width:t,path:o}}makePuzzleTab(){function e(n){n=n?-1:1;const d=-n;var f=o/2;const L=f+2.5,oe=f+.5,ze=se(-t,n*f);return f=se(t,n*f),Pt("c",[se(0,n*L),se(-t,d*oe),ze])+Pt("s",[se(t,d*2.5),f])}const t=this.TAB_WIDTH,o=this.TAB_HEIGHT,s=e(!0),i=e(!1);return{type:this.SHAPES.PUZZLE,width:t,height:o,pathDown:i,pathUp:s}}makeNotch(){function e(d){return ni([se(d*s,o),se(d*3,0),se(d*s,-o)])}const t=this.NOTCH_WIDTH,o=this.NOTCH_HEIGHT,s=(t-3)/2,i=e(1),n=e(-1);return{type:this.SHAPES.NOTCH,width:t,height:o,pathLeft:i,pathRight:n}}makeInsideCorners(){const e=this.CORNER_RADIUS,t=qe("a","0 0,0",e,se(-e,e)),o=qe("a","0 0,0",e,se(e,e));return{width:e,height:e,pathTop:t,pathBottom:o}}makeOutsideCorners(){const e=this.CORNER_RADIUS,t=je(0,e)+qe("a","0 0,1",e,se(e,-e)),o=qe("a","0 0,1",e,se(e,e)),s=qe("a","0 0,1",e,se(-e,-e)),i=qe("a","0 0,1",e,se(-e,e));return{topLeft:t,topRight:o,bottomRight:i,bottomLeft:s,rightHeight:e}}shapeFor(e){switch(e.type){case Z.INPUT_VALUE:case Z.OUTPUT_VALUE:return this.PUZZLE_TAB;case Z.PREVIOUS_STATEMENT:case Z.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown connection type")}}createDom(e,t,o,s){this.injectCSS_(t,o),this.defs=v(R.DEFS,{},e),e=v(R.FILTER,{id:"blocklyEmbossFilter"+this.randomIdentifier},this.defs),v(R.FEGAUSSIANBLUR,{in:"SourceAlpha",stdDeviation:1,result:"blur"},e),t=v(R.FESPECULARLIGHTING,{in:"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},e),v(R.FEPOINTLIGHT,{x:-5e3,y:-1e4,z:2e4},t),v(R.FECOMPOSITE,{in:"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},e),v(R.FECOMPOSITE,{in:"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},e),this.embossFilterId=e.id,this.embossFilter=e,e=v(R.PATTERN,{id:"blocklyDisabledPattern"+this.randomIdentifier,patternUnits:"userSpaceOnUse",width:10,height:10},this.defs),v(R.RECT,{width:10,height:10,fill:"#aaa"},e),v(R.PATH,{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},e),this.disabledPatternId=e.id,this.disabledPattern=e,this.createDebugFilter(),s&&(s.style.setProperty("--blocklyEmbossFilter",`url(#${this.embossFilterId})`),s.style.setProperty("--blocklyDisabledPattern",`url(#${this.disabledPatternId})`),s.style.setProperty("--blocklyDebugFilter",`url(#${this.debugFilterId})`))}createDebugFilter(){if(!this.debugFilter){const e=v(R.FILTER,{id:"blocklyDebugFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},this.defs),t=v(R.FECOMPONENTTRANSFER,{result:"outBlur"},e);v(R.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},t),v(R.FEFLOOD,{"flood-color":"#ff0000","flood-opacity":.5,result:"outColor"},e),v(R.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},e),this.debugFilterId=e.id,this.debugFilter=e}}injectCSS_(e,t){t=this.getCSS_(t),e="blockly-renderer-style-"+e,this.cssNode=document.getElementById(e);const o=t.join(`
659
+ `);this.cssNode?this.cssNode.firstChild.textContent=o:(t=document.createElement("style"),t.id=e,e=document.createTextNode(o),t.appendChild(e),document.head.insertBefore(t,document.head.firstChild),this.cssNode=t)}getCSS_(e){return[`${e} .blocklyText, `,`${e} .blocklyFlyoutLabelText {`,`font: ${this.FIELD_TEXT_FONTWEIGHT} ${this.FIELD_TEXT_FONTSIZE}pt ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${e} .blocklyText {`,"fill: #fff;","}",`${e} .blocklyNonEditableField>rect,`,`${e} .blocklyEditableField>rect {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"fill-opacity: .6;","stroke: none;","}",`${e} .blocklyNonEditableField>text,`,`${e} .blocklyEditableField>text {`,"fill: #000;","}",`${e} .blocklyFlyoutLabelText {`,"fill: #000;","}",`${e} .blocklyText.blocklyBubbleText {`,"fill: #000;","}",`${e} .blocklyEditableField:not(.blocklyEditing):hover>rect {`,"stroke: #fff;","stroke-width: 2;","}",`${e} .blocklyHtmlInput {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"}",`${e} .blocklySelected>.blocklyPath {`,"stroke: #fc3;","stroke-width: 3px;","}",`${e} .blocklyHighlightedConnectionPath {`,"stroke: #fc3;","}",`${e} .blocklyReplaceable .blocklyPath {`,"fill-opacity: .5;","}",`${e} .blocklyReplaceable .blocklyPathLight,`,`${e} .blocklyReplaceable .blocklyPathDark {`,"display: none;","}",`${e} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"]}},yl=class{constructor(e,t){this.inlinePath_=this.outlinePath_="",this.block_=e,this.info_=t,this.topLeft_=e.getRelativeToSurfaceXY(),this.constants_=t.getRenderer().getConstants()}draw(){this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights(),this.block_.pathObject.setPath(this.outlinePath_+`
660
+ `+this.inlinePath_),this.info_.RTL&&this.block_.pathObject.flipRTL(),this.recordSizeOnBlock_()}recordSizeOnBlock_(){this.block_.height=this.info_.height,this.block_.width=this.info_.widthWithChildren,this.block_.childlessWidth=this.info_.width}drawOutline_(){this.drawTop_();for(let e=1;e<this.info_.rows.length-1;e++){const t=this.info_.rows[e];t.hasJaggedEdge?this.drawJaggedEdge_(t):t.hasStatement?this.drawStatementInput_(t):t.hasExternalInput?this.drawValueInput_(t):this.drawRightSideRow_(t)}this.drawBottom_(),this.drawLeft_()}drawTop_(){const e=this.info_.topRow,t=e.elements;this.positionPreviousConnection_(),this.outlinePath_+=je(e.xPos,this.info_.startY);for(let o=0,s;s=t[o];o++)T.isLeftRoundedCorner(s)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topLeft:T.isRightRoundedCorner(s)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topRight:T.isPreviousConnection(s)?this.outlinePath_+=s.shape.pathLeft:T.isHat(s)?this.outlinePath_+=this.constants_.START_HAT.path:T.isSpacer(s)&&(this.outlinePath_+=re("h",s.width));this.outlinePath_+=re("v",e.height)}drawJaggedEdge_(e){this.outlinePath_+=this.constants_.JAGGED_TEETH.path+re("v",e.height-this.constants_.JAGGED_TEETH.height)}drawValueInput_(e){const t=e.getLastInput();this.positionExternalValueConnection_(e);const o=vn(t.shape)?t.shape.pathDown(t.height):t.shape.pathDown;this.outlinePath_+=re("H",t.xPos+t.width)+o+re("v",e.height-t.connectionHeight)}drawStatementInput_(e){var t=e.getLastInput();if(t){var o=t.xPos+t.notchOffset+t.shape.width;t=t.shape.pathRight+re("h",-(t.notchOffset-this.constants_.INSIDE_CORNERS.width))+this.constants_.INSIDE_CORNERS.pathTop;var s=e.height-2*this.constants_.INSIDE_CORNERS.height;this.outlinePath_+=re("H",o)+t+re("v",s)+this.constants_.INSIDE_CORNERS.pathBottom+re("H",e.xPos+e.width),this.positionStatementInputConnection_(e)}}drawRightSideRow_(e){this.outlinePath_+=re("V",e.yPos+e.height)}drawBottom_(){const e=this.info_.bottomRow,t=e.elements;this.positionNextConnection_();let o=0,s="";for(let i=t.length-1,n;n=t[i];i--)T.isNextConnection(n)?s+=n.shape.pathRight:T.isLeftSquareCorner(n)?s+=re("H",e.xPos):T.isLeftRoundedCorner(n)?s+=this.constants_.OUTSIDE_CORNERS.bottomLeft:T.isRightRoundedCorner(n)?(s+=this.constants_.OUTSIDE_CORNERS.bottomRight,o=this.constants_.OUTSIDE_CORNERS.rightHeight):T.isSpacer(n)&&(s+=re("h",n.width*-1));this.outlinePath_+=re("V",e.baseline-o),this.outlinePath_+=s}drawLeft_(){var e=this.info_.outputConnection;if(this.positionOutputConnection_(),e){const t=e.connectionOffsetY+e.height;e=vn(e.shape)?e.shape.pathUp(e.height):e.shape.pathUp,this.outlinePath_+=re("V",t)+e}this.outlinePath_+="z"}drawInternals_(){for(let e=0,t;t=this.info_.rows[e];e++)for(let o=0,s;s=t.elements[o];o++)T.isInlineInput(s)?this.drawInlineInput_(s):(T.isIcon(s)||T.isField(s))&&this.layoutField_(s)}layoutField_(e){const t=e.centerline-e.height/2;let o=e.xPos;var s="";this.info_.RTL&&(o=-(o+e.width),e.flipRtl&&(o+=e.width,s="scale(-1 1)")),T.isIcon(e)?(s=e.icon,s.setOffsetInBlock(new P(o,t)),this.info_.isInsertionMarker&&s.hideForInsertionMarker()):(e=e.field.getSvgRoot(),e.setAttribute("transform","translate("+o+","+t+")"+s),this.info_.isInsertionMarker&&e.setAttribute("display","none"))}drawInlineInput_(e){const t=e.width,o=e.height,s=e.connectionOffsetY,i=e.connectionHeight+s;this.inlinePath_+=gt(e.xPos+e.connectionWidth,e.centerline-o/2)+re("v",s)+e.shape.pathDown+re("v",o-i)+re("h",t-e.connectionWidth)+re("v",-o)+"z",this.positionInlineInputConnection_(e)}positionInlineInputConnection_(e){const t=e.centerline-e.height/2;if(e.connectionModel){let o=e.xPos+e.connectionWidth+e.connectionOffsetX;this.info_.RTL&&(o*=-1),e.connectionModel.setOffsetInBlock(o,t+e.connectionOffsetY)}}positionStatementInputConnection_(e){const t=e.getLastInput();if(t!=null&&t.connectionModel){let o=e.xPos+e.statementEdge+t.notchOffset;this.info_.RTL&&(o*=-1),t.connectionModel.setOffsetInBlock(o,e.yPos)}}positionExternalValueConnection_(e){const t=e.getLastInput();if(t&&t.connectionModel){let o=e.xPos+e.width;this.info_.RTL&&(o*=-1),t.connectionModel.setOffsetInBlock(o,e.yPos)}}positionPreviousConnection_(){const e=this.info_.topRow;if(e.connection){const t=e.xPos+e.notchOffset;e.connection.connectionModel.setOffsetInBlock(this.info_.RTL?-t:t,0)}}positionNextConnection_(){const e=this.info_.bottomRow;if(e.connection){const t=e.connection,o=t.xPos;t.connectionModel.setOffsetInBlock(this.info_.RTL?-o:o,e.baseline)}}positionOutputConnection_(){if(this.info_.outputConnection){const e=this.info_.startX+this.info_.outputConnection.connectionOffsetX;this.block_.outputConnection.setOffsetInBlock(this.info_.RTL?-e:e,this.info_.outputConnection.connectionOffsetY)}}updateConnectionHighlights(){for(const e of this.info_.rows)for(const t of e.elements){if(!(t instanceof Us))continue;const o=this.drawConnectionHighlightPath(t);o&&(o.style.display=t.highlighted?"":"none")}}drawConnectionHighlightPath(e){const t=e.connectionModel;e=t.type===Z.INPUT_VALUE||t.type===Z.OUTPUT_VALUE?this.getExpressionConnectionHighlightPath(e):this.getStatementConnectionHighlightPath(e);const o=t.getSourceBlock();let s,i;return(i=(s=o.pathObject).addConnectionHighlight)==null?void 0:i.call(s,t,e,t.getOffsetInBlock(),o.RTL)}getExpressionConnectionHighlightPath(e){let t="";return vn(e.shape)?t=e.shape.pathDown(e.height):pp(e.shape)&&(t=e.shape.pathDown),e=this.constants_.TAB_OFFSET_FROM_TOP,je(0,-e)+re("v",e)+t+re("v",e)}getStatementConnectionHighlightPath(e){if(!gp(e.shape))throw Error("Statement connections should have notch shapes");const t=this.constants_.NOTCH_OFFSET_LEFT-this.constants_.CORNER_RADIUS;return je(-t,0)+re("h",t)+e.shape.pathLeft+re("h",t)}},Sr=class{constructor(e,t){this.statementEdge=this.width=this.widthWithChildren=this.height=0,this.rows=[],this.inputRows=[],this.startY=this.startX=0,this.renderer_=e,this.block_=t,this.constants_=this.renderer_.getConstants(),this.outputConnection=t.outputConnection?new Mm(this.constants_,t.outputConnection):null,this.isInline=t.getInputsInline()&&!t.isCollapsed(),this.isCollapsed=t.isCollapsed(),this.isInsertionMarker=t.isInsertionMarker(),this.RTL=t.RTL,this.topRow=new uh(this.constants_),this.bottomRow=new sh(this.constants_)}getRenderer(){return this.renderer_}measure(){this.createRows_(),this.addElemSpacing_(),this.addRowSpacing_(),this.computeBounds_(),this.alignRowElements_(),this.finalize_()}createRows_(){this.populateTopRow_(),this.rows.push(this.topRow);let e=new lh(this.constants_);this.inputRows.push(e);var t=this.block_.getIcons();for(let o=0,s;s=t[o];o++){const i=new Nm(this.constants_,s);this.isCollapsed&&!s.isShownWhenCollapsed()||e.elements.push(i)}t=void 0;for(let o=0,s;s=this.block_.inputList[o];o++)if(s.isVisible()){this.shouldStartNewRow_(s,t)&&(this.rows.push(e),e=new lh(this.constants_),this.inputRows.push(e));for(let i=0,n;n=s.fieldRow[i];i++)e.elements.push(new rh(this.constants_,n,s));this.addInput_(s,e),t=s}this.isCollapsed&&(e.hasJaggedEdge=!0,e.elements.push(new Am(this.constants_))),(e.elements.length||e.hasDummyInput)&&this.rows.push(e),this.populateBottomRow_(),this.rows.push(this.bottomRow)}populateTopRow_(){var e=!!this.block_.previousConnection;const t=(this.block_.hat?this.block_.hat==="cap":this.constants_.ADD_START_HATS)&&!this.outputConnection&&!e;let o=this.topRow.hasLeftSquareCorner(this.block_)?Cr:Ir;this.topRow.elements.push(new o(this.constants_)),t?(e=new Om(this.constants_),this.topRow.elements.push(e)):e&&(this.topRow.hasPreviousConnection=!0,this.topRow.connection=new Dm(this.constants_,this.block_.previousConnection),this.topRow.elements.push(this.topRow.connection)),this.block_.inputList.length&&this.block_.inputList[0]instanceof Yt&&!this.block_.isCollapsed()?this.topRow.minHeight=this.constants_.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT:this.topRow.minHeight=this.constants_.TOP_ROW_MIN_HEIGHT,o=this.topRow.hasRightSquareCorner(this.block_)?Cr:Ir,this.topRow.elements.push(new o(this.constants_,"right"))}populateBottomRow_(){this.bottomRow.hasNextConnection=!!this.block_.nextConnection,this.bottomRow.minHeight=this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof Yt?this.constants_.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT:this.constants_.BOTTOM_ROW_MIN_HEIGHT,this.bottomRow.hasLeftSquareCorner(this.block_)?this.bottomRow.elements.push(new Cr(this.constants_)):this.bottomRow.elements.push(new Ir(this.constants_)),this.bottomRow.hasNextConnection&&(this.bottomRow.connection=new Lm(this.constants_,this.block_.nextConnection),this.bottomRow.elements.push(this.bottomRow.connection)),this.bottomRow.hasRightSquareCorner(this.block_)?this.bottomRow.elements.push(new Cr(this.constants_,"right")):this.bottomRow.elements.push(new Ir(this.constants_,"right"))}addInput_(e,t){this.isInline&&e instanceof r.ValueInput$$module$build$src$core$inputs$value_input?(t.elements.push(new nh(this.constants_,e)),t.hasInlineInput=!0):e instanceof Yt?(t.elements.push(new Tl(this.constants_,e)),t.hasStatement=!0):e instanceof r.ValueInput$$module$build$src$core$inputs$value_input?(t.elements.push(new ih(this.constants_,e)),t.hasExternalInput=!0):(e instanceof Io||e instanceof Yo)&&(t.minHeight=Math.max(t.minHeight,e.getSourceBlock()&&e.getSourceBlock().isShadow()?this.constants_.DUMMY_INPUT_SHADOW_MIN_HEIGHT:this.constants_.DUMMY_INPUT_MIN_HEIGHT),t.hasDummyInput=!0),t.align===null&&(t.align=e.align)}shouldStartNewRow_(e,t){return t?t instanceof Yo||e instanceof Yt||t instanceof Yt?!0:e instanceof r.ValueInput$$module$build$src$core$inputs$value_input||e instanceof Io||t instanceof r.ValueInput$$module$build$src$core$inputs$value_input?!this.isInline:!1:!1}addElemSpacing_(){for(let e=0,t;t=this.rows[e];e++){const o=t.elements;if(t.elements=[],t.startsWithElemSpacer()&&t.elements.push(new Xt(this.constants_,this.getInRowSpacing_(null,o[0]))),o.length){for(let s=0;s<o.length-1;s++){t.elements.push(o[s]);const i=this.getInRowSpacing_(o[s],o[s+1]);t.elements.push(new Xt(this.constants_,i))}t.elements.push(o[o.length-1]),t.endsWithElemSpacer()&&t.elements.push(new Xt(this.constants_,this.getInRowSpacing_(o[o.length-1],null)))}}}getInRowSpacing_(e,t){if(!e&&t&&T.isStatementInput(t))return this.constants_.STATEMENT_INPUT_PADDING_LEFT;if(e&&T.isInput(e)&&!t){if(T.isExternalInput(e))return this.constants_.NO_PADDING;if(T.isInlineInput(e))return this.constants_.LARGE_PADDING;if(T.isStatementInput(e))return this.constants_.NO_PADDING}return e&&T.isLeftSquareCorner(e)&&t&&(T.isPreviousConnection(t)||T.isNextConnection(t))?t.notchOffset:e&&T.isLeftRoundedCorner(e)&&t&&(T.isPreviousConnection(t)||T.isNextConnection(t))?t.notchOffset-this.constants_.CORNER_RADIUS:e&&T.isField(e)&&e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING}computeBounds_(){let e=0,t=0,o=0;for(let i=0,n;n=this.rows[i];i++){if(n.measure(),t=Math.max(t,n.width),n.hasStatement){var s=n.getLastInput();let d,f;s=n.width-((f=(d=s)==null?void 0:d.width)!=null?f:0),e=Math.max(e,s)}o=Math.max(o,n.widthWithConnectedBlocks)}this.statementEdge=e,this.width=t;for(let i=0,n;n=this.rows[i];i++)n.hasStatement&&(n.statementEdge=this.statementEdge);this.widthWithChildren=Math.max(t,o),this.outputConnection&&(this.startX=this.outputConnection.width,this.width+=this.outputConnection.width,this.widthWithChildren+=this.outputConnection.width)}alignRowElements_(){for(let t=0,o;o=this.rows[t];t++)if(o.hasStatement)this.alignStatementRow_(o);else{var e=o.width;e=this.getDesiredRowWidth_(o)-e,e>0&&this.addAlignmentPadding_(o,e),T.isTopOrBottomRow(o)&&(o.widthWithConnectedBlocks=o.width)}}getDesiredRowWidth_(e){return this.width-this.startX}addAlignmentPadding_(e,t){const o=e.getFirstSpacer(),s=e.getLastSpacer();if((e.hasExternalInput||e.hasStatement)&&(e.widthWithConnectedBlocks+=t),e.align===r.Align$$module$build$src$core$inputs$align.LEFT&&s)s.width+=t;else if(e.align===r.Align$$module$build$src$core$inputs$align.CENTRE&&o&&s)o.width+=t/2,s.width+=t/2;else if(e.align===r.Align$$module$build$src$core$inputs$align.RIGHT&&o)o.width+=t;else if(s)s.width+=t;else return;e.width+=t}alignStatementRow_(e){const t=e.getLastInput();if(t){var o=e.width-t.width,s=this.statementEdge;o=s-o,o>0&&this.addAlignmentPadding_(e,o),o=e.width,s=this.getDesiredRowWidth_(e),t.width+=s-o,t.height=Math.max(t.height,e.height),e.width+=s-o,e.widthWithConnectedBlocks=Math.max(e.width,this.statementEdge+e.connectedBlockWidths)}}addRowSpacing_(){const e=this.rows;this.rows=[];for(let t=0;t<e.length;t++)this.rows.push(e[t]),t!==e.length-1&&this.rows.push(this.makeSpacerRow_(e[t],e[t+1]))}makeSpacerRow_(e,t){var o=this.getSpacerRowHeight_(e,t);const s=this.getSpacerRowWidth_(e,t);return o=new ch(this.constants_,o,s),e.hasStatement&&(o.followsStatement=!0),t.hasStatement&&(o.precedesStatement=!0),o}getSpacerRowWidth_(e,t){return this.width-this.startX}getSpacerRowHeight_(e,t){return this.constants_.MEDIUM_PADDING}getElemCenterline_(e,t){return T.isSpacer(t)?e.yPos+t.height/2:T.isBottomRow(e)?(e=e.yPos+e.height-e.descenderHeight,T.isNextConnection(t)?e+t.height/2:e-t.height/2):T.isTopRow(e)?T.isHat(t)?e.capline-t.height/2:e.capline+t.height/2:e.yPos+e.height/2}recordElemPositions_(e){let t=e.xPos;for(let o=0,s;s=e.elements[o];o++)T.isSpacer(s)&&(s.height=e.height),s.xPos=t,s.centerline=this.getElemCenterline_(e,s),t+=s.width}finalize_(){let e=0,t=0;for(let o=0,s;s=this.rows[o];o++)s.yPos=t,s.xPos=this.startX,t+=s.height,e=Math.max(e,s.widthWithConnectedBlocks),this.recordElemPositions_(s);if(this.outputConnection&&this.block_.nextConnection){const o=this.block_.nextConnection.targetBlock();o&&(e=Math.max(e,o.getHeightWidth().width))}this.widthWithChildren=e+this.startX,this.height=t,this.startY=this.topRow.capline,this.bottomRow.baseline=t-this.bottomRow.descenderHeight}getMeasureableForConnection(e){let t;if(((t=this.outputConnection)==null?void 0:t.connectionModel)===e)return this.outputConnection;for(const o of this.rows)for(const s of o.elements)if(s instanceof Us&&s.connectionModel===e)return s;return null}},vl=class{constructor(e,t,o){this.connectionHighlights=new WeakMap,this.highlightOffsets=new WeakMap,this.constants=o,this.style=t,this.svgRoot=e,this.svgPath=v(R.PATH,{class:"blocklyPath"},this.svgRoot),this.setClass_("blocklyBlock",!0)}setPath(e){this.svgPath.setAttribute("d",e)}flipRTL(){this.svgPath.setAttribute("transform","scale(-1 1)")}applyColour(e){this.svgPath.setAttribute("stroke",this.style.colourTertiary),this.svgPath.setAttribute("fill",this.style.colourPrimary),this.updateShadow_(e.isShadow()),this.updateDisabled_(!e.isEnabled()||e.getInheritedDisabled())}setStyle(e){this.style=e}setClass_(e,t){e&&(t?G(this.svgRoot,e):Te(this.svgRoot,e))}updateHighlighted(e){e?this.setClass_("blocklyHighlighted",!0):this.setClass_("blocklyHighlighted",!1)}updateShadow_(e){e?(this.setClass_("blocklyShadow",!0),this.svgPath.setAttribute("stroke","none"),this.svgPath.setAttribute("fill",this.style.colourSecondary)):this.setClass_("blocklyShadow",!1)}updateDisabled_(e){this.setClass_("blocklyDisabled",e),this.setClass_("blocklyDisabledPattern",e)}updateSelected(e){this.setClass_("blocklySelected",e)}updateDraggingDelete(e){this.setClass_("blocklyDraggingDelete",e)}updateInsertionMarker(e){this.setClass_("blocklyInsertionMarker",e)}updateMovable(e){this.setClass_("blocklyDraggable",e)}updateReplacementFade(e){this.setClass_("blocklyReplaceable",e)}updateShapeForInputHighlight(e,t){}addConnectionHighlight(e,t,o,s){return o=`translate(${o.x}, ${o.y})`+(s?" scale(-1 1)":""),(s=this.connectionHighlights.get(e))?(s.setAttribute("d",t),s.setAttribute("transform",o),s):(t=v(R.PATH,{id:e.id,class:"blocklyHighlightedConnectionPath",style:"display: none;",d:t,transform:o},this.svgRoot),this.connectionHighlights.set(e,t),t)}removeConnectionHighlight(e){const t=this.connectionHighlights.get(e);t&&(ke(t),this.connectionHighlights.delete(e))}},Il=class{constructor(e){this.overrides=null,this.name=e}getClassName(){return this.name+"-renderer"}init(e,t){this.constants_=this.makeConstants_(),t&&(this.overrides=t,Object.assign(this.constants_,t)),this.constants_.setTheme(e),this.constants_.init()}createDom(e,t,o){this.constants_.createDom(e,this.name+"-"+t.name,"."+this.getClassName()+"."+t.getClassName(),o)}refreshDom(e,t,o){const s=this.getConstants();s.dispose(),this.constants_=this.makeConstants_(),this.overrides&&Object.assign(this.constants_,this.overrides),this.constants_.randomIdentifier=s.randomIdentifier,this.constants_.setTheme(t),this.constants_.init(),this.createDom(e,t,o)}dispose(){this.constants_&&this.constants_.dispose()}makeConstants_(){return new El}makeRenderInfo_(e){return new Sr(this,e)}makeDrawer_(e,t){return new yl(e,t)}makePathObject(e,t){return new vl(e,t,this.constants_)}getConstants(){return this.constants_}shouldHighlightConnection(e){return!0}orphanCanConnectAtEnd(e,t,o){return!!Ce.getConnectionForOrphanedConnection(e,o===Z.OUTPUT_VALUE?t.outputConnection:t.previousConnection)}render(e){const t=this.makeRenderInfo_(e);t.measure(),this.makeDrawer_(e,t).draw()}},Ne={};Ne.BottomRow=sh,Ne.Connection=Us,Ne.ConstantProvider=El,Ne.Drawer=yl,Ne.ExternalValueInput=ih,Ne.Field=rh,Ne.Hat=Om,Ne.Icon=Nm,Ne.InRowSpacer=Xt,Ne.InlineInput=nh,Ne.InputConnection=bl,Ne.InputRow=lh,Ne.JaggedEdge=Am,Ne.Measurable=So,Ne.NextConnection=Lm,Ne.OutputConnection=Mm,Ne.PathObject=vl,Ne.PreviousConnection=Dm,Ne.RenderInfo=Sr,Ne.Renderer=Il,Ne.RoundCorner=Ir,Ne.Row=vr,Ne.SpacerRow=ch,Ne.SquareCorner=Cr,Ne.StatementInput=Tl,Ne.TopRow=uh,Ne.Types=T,Ne.init=Eu,Ne.register=Qi,Ne.unregister=mp;var xm=class{constructor(e,t){this.workspace=e,this.theme=t,this.subscribedWorkspaces=[],this.componentDB=new Map}getTheme(){return this.theme}setTheme(e){var t=this.theme;this.theme=e,(e=this.workspace.getInjectionDiv())&&(t&&(t=t.getClassName())&&Te(e,t),(t=this.theme.getClassName())&&G(e,t));for(let o=0,s;s=this.subscribedWorkspaces[o];o++)s.refreshTheme();for(const[o,s]of this.componentDB)for(const i of s){e=i.element,t=i.propertyName;const n=this.theme&&this.theme.getComponentStyle(o);e.style.setProperty(t,n||"")}for(const o of this.subscribedWorkspaces)o.hideChaff()}subscribeWorkspace(e){this.subscribedWorkspaces.push(e)}unsubscribeWorkspace(e){if(!x(this.subscribedWorkspaces,e))throw Error("Cannot unsubscribe a workspace that hasn't been subscribed.")}subscribe(e,t,o){this.componentDB.has(t)||this.componentDB.set(t,[]),this.componentDB.get(t).push({element:e,propertyName:o}),t=this.theme&&this.theme.getComponentStyle(t),e.style.setProperty(o,t||"")}unsubscribe(e){if(e)for(const[t,o]of this.componentDB){for(let s=o.length-1;s>=0;s--)o[s].element===e&&o.splice(s,1);o.length||this.componentDB.delete(t)}}dispose(){this.subscribedWorkspaces.length=0,this.componentDB.clear()}},ah="VARIABLE_DYNAMIC",hs={CATEGORY_NAME:ah};hs.flyoutCategory=yu,hs.flyoutCategoryBlocks=vu,hs.internalFlyoutCategory=kn,hs.onCreateVariableButtonClick_Colour=Sn,hs.onCreateVariableButtonClick_Number=Cn,hs.onCreateVariableButtonClick_String=In;var Bm=class{canConnect(e,t,o,s){return this.canConnectWithReason(e,t,o,s)===Ce.CAN_CONNECT}canConnectWithReason(e,t,o,s){const i=this.doSafetyChecks(e,t);return i!==Ce.CAN_CONNECT?i:this.doTypeChecks(e,t)?o&&!this.doDragChecks(e,t,s||0)?Ce.REASON_DRAG_CHECKS_FAILED:Ce.CAN_CONNECT:Ce.REASON_CHECKS_FAILED}getErrorMessage(e,t,o){switch(e){case Ce.REASON_SELF_CONNECTION:return"Attempted to connect a block to itself.";case Ce.REASON_DIFFERENT_WORKSPACES:return"Blocks not on same workspace.";case Ce.REASON_WRONG_TYPE:return"Attempt to connect incompatible types.";case Ce.REASON_TARGET_NULL:return"Target connection is null.";case Ce.REASON_CHECKS_FAILED:return"Connection checks failed. "+(t+" expected "+t.getCheck()+", found "+o.getCheck());case Ce.REASON_SHADOW_PARENT:return"Connecting non-shadow to shadow block.";case Ce.REASON_DRAG_CHECKS_FAILED:return"Drag checks failed.";case Ce.REASON_PREVIOUS_AND_OUTPUT:return"Block would have an output and a previous connection.";default:return"Unknown connection failure: this should never happen!"}}doSafetyChecks(e,t){if(!e||!t)return Ce.REASON_TARGET_NULL;let o,s,i;return e.isSuperior()?(o=e.getSourceBlock(),s=t.getSourceBlock(),i=t):(s=e.getSourceBlock(),o=t.getSourceBlock(),i=e,e=t),o===s?Ce.REASON_SELF_CONNECTION:i.type!==Fs[e.type]?Ce.REASON_WRONG_TYPE:o.workspace!==s.workspace?Ce.REASON_DIFFERENT_WORKSPACES:o.isShadow()&&!s.isShadow()?Ce.REASON_SHADOW_PARENT:i.type===Z.OUTPUT_VALUE&&s.previousConnection&&s.previousConnection.isConnected()||i.type===Z.PREVIOUS_STATEMENT&&s.outputConnection&&s.outputConnection.isConnected()?Ce.REASON_PREVIOUS_AND_OUTPUT:Ce.CAN_CONNECT}doTypeChecks(e,t){if(e=e.getCheck(),t=t.getCheck(),!e||!t)return!0;for(let o=0;o<e.length;o++)if(t.includes(e[o]))return!0;return!1}doDragChecks(e,t,o){if(e.distanceFrom(t)>o||t.getSourceBlock().isInsertionMarker())return!1;switch(t.type){case Z.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(e,t);case Z.OUTPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isInsertionMarker()||e.isConnected())return!1;break;case Z.INPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isMovable()&&!t.targetBlock().isShadow())return!1;break;case Z.NEXT_STATEMENT:if(t.isConnected()&&!e.getSourceBlock().nextConnection&&!t.targetBlock().isShadow()&&t.targetBlock().nextConnection||t.targetBlock()&&!t.targetBlock().isMovable()&&!t.targetBlock().isShadow())return!1;break;default:return!1}return!nr.includes(t)}canConnectToPrevious_(e,t){return e.targetConnection||nr.includes(t)?!1:t.targetConnection?(e=t.targetBlock(),e.isInsertionMarker()?!e.getPreviousBlock():!1):!0}};l(M.CONNECTION_CHECKER,Ft,Bm);var ki=class{get isFlyout(){return this.internalIsFlyout}get isMutator(){return this.internalIsMutator}constructor(e){this.isClearing=this.internalIsMutator=this.internalIsFlyout=this.rendered=!1,this.MAX_UNDO=1024,this.connectionDBList=[],this.topBlocks=[],this.topComments=[],this.commentDB=new Map,this.listeners=[],this.undoStack_=[],this.redoStack_=[],this.blockDB=new Map,this.typedBlocksDB=new Map,this.procedureMap=new wm,this.readOnly=!1,this.potentialVariableMap=null,this.id=rt(),st(this),this.options=e||new vo({}),this.RTL=!!this.options.RTL,this.horizontalLayout=!!this.options.horizontalLayout,this.toolboxPosition=this.options.toolboxPosition,this.connectionChecker=new(W(M.CONNECTION_CHECKER,this.options,!0))(this),this.variableMap=new(this.getVariableMapClass())(this),this.setIsReadOnly(this.options.readOnly)}dispose(){this.listeners.length=0,this.clear(),Ut(this)}sortObjects(e,t){const o=s=>({getBoundingRectangle:()=>{const i=s.getRelativeToSurfaceXY();return new ye(i.y,i.y,i.x,i.x)},moveBy:()=>{}});return this.sortByOrigin(o(e),o(t))}sortByOrigin(e,t){const o=Math.sin(tn(ki.SCAN_ANGLE))*(this.RTL?-1:1);return e=e.getBoundingRectangle().getOrigin(),t=t.getBoundingRectangle().getOrigin(),e.y+o*e.x-(t.y+o*t.x)}addTopBlock(e){this.topBlocks.push(e)}removeTopBlock(e){if(!x(this.topBlocks,e))throw Error("Block not present in workspace's list of top-most blocks.")}getTopBlocks(e=!1){const t=[].concat(this.topBlocks);return e&&t.length>1&&t.sort(this.sortObjects.bind(this)),t}addTypedBlock(e){this.typedBlocksDB.has(e.type)||this.typedBlocksDB.set(e.type,[]),this.typedBlocksDB.get(e.type).push(e)}removeTypedBlock(e){x(this.typedBlocksDB.get(e.type),e),this.typedBlocksDB.get(e.type).length||this.typedBlocksDB.delete(e.type)}getBlocksByType(e,t=!1){return this.typedBlocksDB.has(e)?(e=this.typedBlocksDB.get(e).slice(0),t&&e&&e.length>1&&e.sort(this.sortObjects.bind(this)),e.filter(o=>!o.isInsertionMarker())):[]}addTopComment(e){this.topComments.push(e),this.commentDB.has(e.id)&&console.warn('Overriding an existing comment on this workspace, with id "'+e.id+'"'),this.commentDB.set(e.id,e)}removeTopComment(e){if(!x(this.topComments,e))throw Error("Comment not present in workspace's list of top-most comments.");this.commentDB.delete(e.id)}getTopComments(e=!1){const t=[].concat(this.topComments);return e&&t.length>1&&t.sort(this.sortObjects.bind(this)),t}getAllBlocks(e=!1){if(e){var t=this.getTopBlocks(!0);e=[];for(let o=0;o<t.length;o++)e.push(...t[o].getDescendants(!0))}else for(e=this.getTopBlocks(!1),t=0;t<e.length;t++)e.push(...e[t].getChildren(!1));return e.filter(o=>!o.isInsertionMarker())}clear(){this.isClearing=!0;try{const e=r.getGroup$$module$build$src$core$events$utils();for(e||r.setGroup$$module$build$src$core$events$utils(!0);this.topBlocks.length;)this.topBlocks[0].dispose(!1);for(;this.topComments.length;)this.topComments[this.topComments.length-1].dispose();r.setGroup$$module$build$src$core$events$utils(e),this.isFlyout||this.variableMap.clear(),this.potentialVariableMap&&this.potentialVariableMap.clear()}finally{this.isClearing=!1}}renameVariableById(e,t){pt("Blockly.Workspace.renameVariableById","v12","v13","Blockly.Workspace.getVariableMap().renameVariable"),(e=this.variableMap.getVariableById(e))&&this.variableMap.renameVariable(e,t)}createVariable(e,t,o){return pt("Blockly.Workspace.createVariable","v12","v13","Blockly.Workspace.getVariableMap().createVariable"),this.variableMap.createVariable(e,t??void 0,o??void 0)}getVariableUsesById(e){return pt("Blockly.Workspace.getVariableUsesById","v12","v13","Blockly.Workspace.getVariableMap().getVariableUsesById"),qs(this,e)}deleteVariableById(e){pt("Blockly.Workspace.deleteVariableById","v12","v13","Blockly.Workspace.getVariableMap().deleteVariable");const t=this.variableMap.getVariableById(e);t?r.deleteVariable$$module$build$src$core$variables(this,t):console.warn(`Can't delete non-existent variable: ${e}`)}getVariable(e,t){return pt("Blockly.Workspace.getVariable","v12","v13","Blockly.Workspace.getVariableMap().getVariable"),this.variableMap.getVariable(e,t)}getVariableById(e){return pt("Blockly.Workspace.getVariableById","v12","v13","Blockly.Workspace.getVariableMap().getVariableById"),this.variableMap.getVariableById(e)}getVariablesOfType(e){return pt("Blockly.Workspace.getVariablesOfType","v12","v13","Blockly.Workspace.getVariableMap().getVariablesOfType"),this.variableMap.getVariablesOfType(e??"")}getAllVariables(){return pt("Blockly.Workspace.getAllVariables","v12","v13","Blockly.Workspace.getVariableMap().getAllVariables"),this.variableMap.getAllVariables()}getAllVariableNames(){return pt("Blockly.Workspace.getAllVariableNames","v12","v13","Blockly.Workspace.getVariableMap().getAllVariables"),this.variableMap.getAllVariables().map(e=>e.getName())}getWidth(){return 0}newBlock(e,t){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts")}newComment(e){throw Error("The implementation of newComment should be monkey-patched in by blockly.ts")}remainingCapacity(){return isNaN(this.options.maxBlocks)?1/0:this.options.maxBlocks-this.getAllBlocks(!1).length}remainingCapacityOfType(e){return this.options.maxInstances?(this.options.maxInstances[e]!==void 0?this.options.maxInstances[e]:1/0)-this.getBlocksByType(e,!1).length:1/0}isCapacityAvailable(e){if(!this.hasBlockLimits())return!0;let t=0;for(const o in e){if(e[o]>this.remainingCapacityOfType(o))return!1;t+=e[o]}return!(t>this.remainingCapacity())}hasBlockLimits(){return this.options.maxBlocks!==1/0||!!this.options.maxInstances}getUndoStack(){return this.undoStack_}getRedoStack(){return this.redoStack_}undo(e){var t=e?this.redoStack_:this.undoStack_,o=e?this.undoStack_:this.redoStack_;const s=t.pop();if(s){for(var i=[s];t.length&&s.group&&s.group===t[t.length-1].group;){const n=t.pop();n&&i.push(n)}for(t=0;t<i.length;t++)o.push(i[t]);r.setRecordUndo$$module$build$src$core$events$utils(!1);try{for(o=0;o<i.length;o++)i[o].run(e)}finally{r.setRecordUndo$$module$build$src$core$events$utils(!0)}}}clearUndo(){this.undoStack_.length=0,this.redoStack_.length=0,he()}addChangeListener(e){return this.listeners.push(e),e}removeChangeListener(e){x(this.listeners,e)}fireChangeListener(e){if(e.recordUndo)for(this.undoStack_.push(e),this.redoStack_.length=0;this.undoStack_.length>this.MAX_UNDO&&this.MAX_UNDO>=0;)this.undoStack_.shift();for(let t=0;t<this.listeners.length;t++)(0,this.listeners[t])(e)}getBlockById(e){return this.blockDB.get(e)||null}setBlockById(e,t){this.blockDB.set(e,t)}removeBlockById(e){this.blockDB.delete(e)}getCommentById(e){let t;return(t=this.commentDB.get(e))!=null?t:null}allInputsFilled(e){const t=this.getTopBlocks(!1);for(let o=0;o<t.length;o++)if(!t[o].allInputsFilled(e))return!1;return!0}getPotentialVariableMap(){return this.potentialVariableMap}createPotentialVariableMap(){this.potentialVariableMap=new(this.getVariableMapClass())(this,!0)}getVariableMap(){return this.variableMap}setVariableMap(e){this.variableMap=e}getProcedureMap(){return this.procedureMap}getRootWorkspace(){let e=null;const t=this.options.parentWorkspace;return this.isFlyout?t&&t.options&&(e=t.options.parentWorkspace):t&&(e=t),e}static getById(e){return ct(e)}static getAll(){return kt()}getVariableMapClass(){const e=W(M.VARIABLE_MAP,this.options,!0);if(!e)throw Error("No variable map is registered.");return e}isReadOnly(){return this.readOnly}setIsReadOnly(e){this.readOnly=e,this.options.readOnly=e}};ki.SCAN_ANGLE=3;var xb=100,Pm=class{constructor(e){this.parentWorkspace=e,this.sounds=new Map,this.lastSound=null,this.muted=!1}dispose(){this.sounds.clear()}load(e,t){if(e.length){try{var o=new globalThis.Audio}catch{return}for(let i=0;i<e.length;i++){const n=e[i],d=n.match(/\.(\w+)$/);if(d&&o.canPlayType("audio/"+d[1])){var s=new globalThis.Audio(n);break}}s&&this.sounds.set(t,s)}}preload(){for(const e of this.sounds.values()){e.volume=.01;const t=e.play();if(t!==void 0?t.then(e.pause).catch(function(){}):e.pause(),Pn||Yp)break}}play(e,t){if(!this.muted){var o=this.sounds.get(e);o?(e=new Date,this.lastSound!==null&&e.getTime()-this.lastSound.getTime()<xb||(this.lastSound=e,o=Pn||ia?o:o.cloneNode(),o.volume=t===void 0?1:t,o.play())):this.parentWorkspace&&this.parentWorkspace.getAudioManager().play(e,t)}}setMuted(e){this.muted=e}getMuted(){return this.muted}},Bb=20,At=class extends ki{constructor(e){super(e),this.resizeHandlerWrapper=null,this.resizesEnabled=this.visible=this.rendered=!0,this.startScrollY=this.startScrollX=this.scrollY=this.scrollX=0,this.oldScale=this.scale=1,this.oldLeft=this.oldTop=0,this.inverseScreenCTM=this.targetWorkspace=this.dummyWheelListener=this.configureContextMenu=this.lastRecordedPageScroll=this.injectionDiv=this.currentGesture_=this.toolbox=this.flyout=this.scrollbar=this.trashcan=null,this.inverseScreenCTMDirty=!0,this.highlightedBlocks=[],this.toolboxCategoryCallbacks=new Map,this.flyoutButtonCallbacks=new Map,this.cachedParentSvg=null,this.keyboardMoveInProgress=this.keyboardAccessibilityMode=!1,this.topBoundedElements=[],this.dragTargetAreas=[],this.zoomControls_=this.layerManager=null,this.navigator=new Ka,this.metricsManager=new(W(M.METRICS_MANAGER,e,!0))(this),this.getMetrics=e.getMetrics||this.metricsManager.getMetrics.bind(this.metricsManager),this.setMetrics=e.setMetrics||At.setTopLevelWorkspaceMetrics,this.componentManager=new Ve,this.connectionDBList=Ei.init(this.connectionChecker),this.audioManager=new Pm(e.parentWorkspace),this.grid=this.options.gridPattern?new qa(this.options.gridPattern,e.gridOptions):null,this.markerManager=new Qa(this),et&&Jr&&this.registerToolboxCategoryCallback(Ca,Jr),hs&&kn&&this.registerToolboxCategoryCallback(ah,kn),Nt&&yn&&(this.registerToolboxCategoryCallback(_l,yn),this.addChangeListener(bu)),this.addChangeListener(this.variableChangeCallback.bind(this)),this.themeManager_=this.options.parentWorkspace?this.options.parentWorkspace.getThemeManager():new xm(this,this.options.theme||cl),this.themeManager_.subscribeWorkspace(this);let t;this.renderer=Eu(this.options.renderer||"geras",this.getTheme(),(t=this.options.rendererOverrides)!=null?t:void 0),this.cachedParentSvgSize=new ve(0,0)}getMarkerManager(){return this.markerManager}getMetricsManager(){return this.metricsManager}setMetricsManager(e){this.metricsManager=e,this.getMetrics=this.metricsManager.getMetrics.bind(this.metricsManager)}getComponentManager(){return this.componentManager}getMarker(e){return this.markerManager.getMarker(e)}getCursor(){return this.markerManager.getCursor()}getRenderer(){return this.renderer}getThemeManager(){return this.themeManager_}getTheme(){return this.themeManager_.getTheme()}setTheme(e){e||(e=cl),this.themeManager_.setTheme(e)}refreshTheme(){if(this.svgGroup_){var e=this.options.parentWorkspace===null;this.renderer.refreshDom(this.svgGroup_,this.getTheme(),e?this.getInjectionDiv():void 0)}this.updateBlockStyles(this.getAllBlocks(!1).filter(t=>!!t.getStyleName())),this.refreshToolboxSelection(),this.toolbox&&this.toolbox.refreshTheme(),this.isVisible()&&this.setVisible(!0),e=new(U(w.THEME_CHANGE))(this.getTheme().name,this.id),_(e)}updateBlockStyles(e){for(let t=0,o;o=e[t];t++){const s=o.getStyleName();s&&o.setStyle(s)}}getInverseScreenCTM(){if(this.inverseScreenCTMDirty){const e=this.getParentSvg().getScreenCTM();e&&(this.inverseScreenCTM=e.inverse(),this.inverseScreenCTMDirty=!1)}return this.inverseScreenCTM}updateInverseScreenCTM(){this.inverseScreenCTMDirty=!0}isVisible(){return this.visible}getSvgXY(e){let t=0,o=0,s=1;(this.getCanvas().contains(e)||this.getBubbleCanvas().contains(e))&&(s=this.scale);do{const i=Bi(e);(e===this.getCanvas()||e===this.getBubbleCanvas())&&(s=1),t+=i.x*s,o+=i.y*s,e=e.parentNode}while(e&&e!==this.getParentSvg()&&e!==this.getInjectionDiv());return new P(t,o)}getCachedParentSvgSize(){const e=this.cachedParentSvgSize;return new ve(e.width,e.height)}getOriginOffsetInPixels(){return Pr(this.getCanvas())}getInjectionDiv(){if(!this.injectionDiv){let e=this.svgGroup_;for(;e;){if((" "+(e.getAttribute("class")||"")+" ").includes(" injectionDiv ")){this.injectionDiv=e;break}e=e.parentNode}}return this.injectionDiv}getSvgGroup(){return this.svgGroup_}getBlockCanvas(){return this.getCanvas()}setResizeHandlerWrapper(e){this.resizeHandlerWrapper=e}createDom(e,t){return this.injectionDiv||(this.injectionDiv=t??null),this.svgGroup_=v(R.G,{class:"blocklyWorkspace",id:this.id}),t&&it(this.svgGroup_,Qe.LABEL,r.Msg$$module$build$src$core$msg.WORKSPACE_ARIA_LABEL),e&&(this.svgBackground_=v(R.RECT,{height:"100%",width:"100%",class:e},this.svgGroup_),e==="blocklyMainBackground"&&this.grid?this.svgBackground_.style.fill="var(--blocklyGridPattern)":this.themeManager_.subscribe(this.svgBackground_,"workspaceBackgroundColour","fill")),this.layerManager=new Mb(this),this.svgBlockCanvas_=this.layerManager.getBlockLayer(),this.svgBubbleCanvas_=this.layerManager.getBubbleLayer(),this.isFlyout||(z(this.svgGroup_,"pointerdown",this,this.onMouseDown,!1),this.dummyWheelListener=()=>{},document.body.addEventListener("wheel",this.dummyWheelListener),z(this.svgGroup_,"wheel",this,this.onMouseWheel)),this.options.hasCategories&&(this.toolbox=new(W(M.TOOLBOX,this.options,!0))(this)),this.grid&&this.grid.update(this.scale),this.recordDragTargets(),(e=W(M.CURSOR,this.options))&&this.markerManager.setCursor(new e(this)),e=this.options.parentWorkspace===null,this.renderer.createDom(this.svgGroup_,this.getTheme(),e?this.getInjectionDiv():void 0),r.getFocusManager$$module$build$src$core$focus_manager().registerTree(this,!!this.injectionDiv||this.isFlyout),this.svgGroup_}dispose(){if(this.rendered=!1,this.currentGesture_&&this.currentGesture_.cancel(),this.svgGroup_&&ke(this.svgGroup_),this.toolbox&&(this.toolbox.dispose(),this.toolbox=null),this.flyout&&(this.flyout.dispose(),this.flyout=null),this.trashcan&&(this.trashcan.dispose(),this.trashcan=null),this.scrollbar&&(this.scrollbar.dispose(),this.scrollbar=null),this.zoomControls_&&this.zoomControls_.dispose(),this.audioManager&&this.audioManager.dispose(),this.grid&&(this.grid=null),this.renderer.dispose(),this.markerManager.dispose(),super.dispose(),this.themeManager_&&(this.themeManager_.unsubscribeWorkspace(this),this.themeManager_.unsubscribe(this.svgBackground_),this.options.parentWorkspace||this.themeManager_.dispose()),this.connectionDBList.length=0,this.toolboxCategoryCallbacks.clear(),this.flyoutButtonCallbacks.clear(),!this.options.parentWorkspace){const e=this.getParentSvg();e&&e.parentNode&&ke(e.parentNode)}this.resizeHandlerWrapper&&(te(this.resizeHandlerWrapper),this.resizeHandlerWrapper=null),this.dummyWheelListener&&(document.body.removeEventListener("wheel",this.dummyWheelListener),this.dummyWheelListener=null),r.getFocusManager$$module$build$src$core$focus_manager().isRegistered(this)&&r.getFocusManager$$module$build$src$core$focus_manager().unregisterTree(this)}addTrashcan(){this.trashcan=At.newTrashcan(this);const e=this.trashcan.createDom();this.svgGroup_.insertBefore(e,this.getCanvas())}static newTrashcan(e){throw Error("The implementation of newTrashcan should be monkey-patched in by blockly.ts")}addZoomControls(){this.zoomControls_=new dg(this);const e=this.zoomControls_.createDom();this.svgGroup_.appendChild(e)}copyOptionsForFlyout(){return new vo({parentWorkspace:this,rtl:this.RTL,oneBasedIndex:this.options.oneBasedIndex,horizontalLayout:this.horizontalLayout,renderer:this.options.renderer,rendererOverrides:this.options.rendererOverrides,plugins:this.options.plugins,modalInputs:this.options.modalInputs,move:{scrollbars:!0}})}addFlyout(e){const t=this.copyOptionsForFlyout();return t.toolboxPosition=this.options.toolboxPosition,this.flyout=this.horizontalLayout?new(W(M.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(t):new(W(M.FLYOUTS_VERTICAL_TOOLBOX,this.options,!0))(t),this.flyout.autoClose=!1,this.flyout.getWorkspace().setVisible(!0),this.flyout.createDom(e)}getFlyout(e){return this.flyout||e?this.flyout:this.toolbox?this.toolbox.getFlyout():null}getToolbox(){return this.toolbox}updateScreenCalculations(){this.updateInverseScreenCTM(),this.recordDragTargets()}resizeContents(){this.resizesEnabled&&this.rendered&&(this.scrollbar&&this.scrollbar.resize(),this.updateInverseScreenCTM())}resize(){this.toolbox?this.toolbox.position():this.flyout&&this.flyout.position();const e=this.componentManager.getComponents(Ve.Capability.POSITIONABLE,!0),t=this.getMetricsManager().getUiMetrics(),o=[];for(let s=0,i;i=e[s];s++){i.position(t,o);const n=i.getBoundingRectangle();n&&o.push(n)}this.scrollbar&&this.scrollbar.resize(),this.updateScreenCalculations()}updateScreenCalculationsIfScrolled(){const e=Ql();P.equals(this.lastRecordedPageScroll,e)||(this.lastRecordedPageScroll=e,this.updateScreenCalculations())}getLayerManager(){return this.layerManager}getCanvas(){return this.layerManager.getBlockLayer()}setCachedParentSvgSize(e,t){const o=this.getParentSvg();e!=null&&(this.cachedParentSvgSize.width=e,o.setAttribute("data-cached-width",`${e}`)),t!=null&&(this.cachedParentSvgSize.height=t,o.setAttribute("data-cached-height",`${t}`))}getBubbleCanvas(){return this.layerManager.getBubbleLayer()}getParentSvg(){if(!this.cachedParentSvg){let e=this.svgGroup_;for(;e;){if(e.tagName==="svg"){this.cachedParentSvg=e;break}e=e.parentNode}}return this.cachedParentSvg}maybeFireViewportChangeEvent(){if(J()){var e=this.scale,t=-this.scrollY,o=-this.scrollX;if(!(e===this.oldScale&&Math.abs(t-this.oldTop)<1&&Math.abs(o-this.oldLeft)<1)){var s=new(U(w.VIEWPORT_CHANGE))(t,o,e,this.id,this.oldScale);this.oldScale=e,this.oldTop=t,this.oldLeft=o,_(s)}}}translate(e,t){let o;(o=this.layerManager)==null||o.translateLayers(new P(e,t),this.scale);let s;(s=this.grid)==null||s.moveTo(e,t),this.maybeFireViewportChangeEvent()}getWidth(){const e=this.getMetrics();return e?e.viewWidth/this.scale:0}setVisible(e){this.visible=e,this.svgGroup_&&(this.scrollbar&&this.scrollbar.setContainerVisible(e),this.getFlyout()&&this.getFlyout().setContainerVisible(e),this.getParentSvg().style.display=e?"block":"none",this.toolbox&&this.toolbox.setVisible(e),e||this.hideChaff(!0))}render(){const e=this.getAllBlocks(!1);for(let t=e.length-1;t>=0;t--)e[t].queueRender();this.getTopBlocks().flatMap(t=>t.getDescendants(!1)).filter(t=>t.isInsertionMarker()).forEach(t=>t.queueRender())}highlightBlock(e,t){if(t===void 0){for(let o=0,s;s=this.highlightedBlocks[o];o++)s.setHighlighted(!1);this.highlightedBlocks.length=0}(e=e?this.getBlockById(e):null)&&((t=t===void 0||t)?this.highlightedBlocks.includes(e)||this.highlightedBlocks.push(e):x(this.highlightedBlocks,e),e.setHighlighted(t))}variableChangeCallback(e){switch(e.type){case w.VAR_CREATE:case w.VAR_DELETE:case w.VAR_RENAME:case w.VAR_TYPE_CHANGE:this.refreshToolboxSelection()}}refreshToolboxSelection(){const e=this.isFlyout?this.targetWorkspace:this;e&&!e.currentGesture_&&e.toolbox&&e.toolbox.getFlyout()&&e.toolbox.refreshSelection()}recordDragTargets(){const e=this.componentManager.getComponents(Ve.Capability.DRAG_TARGET,!0);this.dragTargetAreas=[];for(let t=0,o;o=e[t];t++){const s=o.getClientRect();s&&this.dragTargetAreas.push({component:o,clientRect:s})}}newBlock(e,t){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts")}newComment(e){throw Error("The implementation of newComment should be monkey-patched in by blockly.ts")}getDragTarget(e){for(let t=0,o;o=this.dragTargetAreas[t];t++)if(o.clientRect.contains(e.clientX,e.clientY))return o.component;return null}onMouseDown(e){const t=this.getGesture(e);t&&t.handleWsStart(e,this)}startDrag(e,t){$n(this,e,t)}moveDrag(e){return pn(this,e)}setKeyboardMoveInProgress(e){this.keyboardMoveInProgress=e}isDragging(){return this.keyboardMoveInProgress||this.currentGesture_!==null&&this.currentGesture_.isDragging()}isDraggable(){return this.options.moveOptions&&this.options.moveOptions.drag}isMovable(){return this.options.moveOptions&&!!this.options.moveOptions.scrollbars||this.options.moveOptions&&this.options.moveOptions.wheel||this.options.moveOptions&&this.options.moveOptions.drag||this.options.zoomOptions&&this.options.zoomOptions.wheel||this.options.zoomOptions&&this.options.zoomOptions.pinch}isMovableHorizontally(){const e=!!this.scrollbar;return this.isMovable()&&(!e||e&&this.scrollbar.canScrollHorizontally())}isMovableVertically(){const e=!!this.scrollbar;return this.isMovable()&&(!e||e&&this.scrollbar.canScrollVertically())}onMouseWheel(e){if(fl.inProgress())e.preventDefault(),e.stopPropagation();else{var t=this.options.zoomOptions&&this.options.zoomOptions.wheel,o=this.options.moveOptions&&this.options.moveOptions.wheel;if(t||o){var s=It(e);if(ra)var i=e.metaKey;t&&(e.ctrlKey||i||!o)?(s=-s.y/50,t=Ye(e,this.getParentSvg(),this.getInverseScreenCTM()),this.zoom(t.x,t.y,s)):(t=this.scrollX-s.x,o=this.scrollY-s.y,e.shiftKey&&!s.x&&(t=this.scrollX-s.y,o=this.scrollY),this.scroll(t,o)),e.preventDefault()}}}getBlocksBoundingBox(){const e=this.getTopBoundedElements();if(!e.length)return new ye(0,0,0,0);const t=e[0].getBoundingRectangle();for(let s=1;s<e.length;s++){var o=e[s];o.isInsertionMarker&&o.isInsertionMarker()||(o=o.getBoundingRectangle(),o.top<t.top&&(t.top=o.top),o.bottom>t.bottom&&(t.bottom=o.bottom),o.left<t.left&&(t.left=o.left),o.right>t.right&&(t.right=o.right))}return t}cleanUp(){this.setResizesEnabled(!1),r.setGroup$$module$build$src$core$events$utils(!0);var e=this.getTopBlocks(!0),t=e.filter(n=>n.isMovable());const o=e.filter(n=>!n.isMovable()).map(n=>n.getBoundingRectangle());e=function(n){for(const d of o)if(n.intersects(d))return d;return null};var s=0;const i=this.renderer.getConstants().MIN_BLOCK_HEIGHT;for(const n of t){for(t=n.getBoundingRectangle(),n.moveBy(-t.left,s-t.top,["cleanup"]),n.snapToGrid(),t=n.getBoundingRectangle(),s=e(t);s!=null;)s=s.top+s.getHeight()+i,n.moveBy(0,s-t.top,["cleanup"]),n.snapToGrid(),t=n.getBoundingRectangle(),s=e(t);s=n.getRelativeToSurfaceXY().y+n.getHeightWidth().height+i}r.setGroup$$module$build$src$core$events$utils(!1),this.setResizesEnabled(!0)}showContextMenu(e){if(!this.isReadOnly()&&!this.isFlyout){var t=Ee.registry.getContextMenuOptions({workspace:this,focusedNode:this},e);this.configureContextMenu&&this.configureContextMenu(t,e);var o=e instanceof PointerEvent?new P(e.clientX,e.clientY):Ys(this,new P(5,5));ii(e,t,this.RTL,this,o)}}updateToolbox(e){if(e=Fr(e)){if(!this.options.languageTree)throw Error("Existing toolbox is null. Can't create new toolbox.");if(Ur(e)){if(!this.toolbox)throw Error("Existing toolbox has no categories. Can't change mode.");this.options.languageTree=e,this.toolbox.render(e)}else{if(!this.flyout)throw Error("Existing toolbox has categories. Can't change mode.");this.options.languageTree=e,this.flyout.show(e)}}else if(this.options.languageTree)throw Error("Can't nullify an existing toolbox.")}markFocused(){this.options.parentWorkspace?this.options.parentWorkspace.markFocused():(p(this),this.getParentSvg().focus({preventScroll:!0}))}zoom(e,t,o){o=Math.pow(this.options.zoomOptions.scaleSpeed,o);const s=this.scale*o;if(this.scale!==s){s>this.options.zoomOptions.maxScale?o=this.options.zoomOptions.maxScale/this.scale:s<this.options.zoomOptions.minScale&&(o=this.options.zoomOptions.minScale/this.scale);var i=this.getCanvas().getCTM(),n=this.getParentSvg().createSVGPoint();n.x=e,n.y=t,n=n.matrixTransform(i.inverse()),e=n.x,t=n.y,i=i.translate(e*(1-o),t*(1-o)).scale(o),this.scrollX=i.e,this.scrollY=i.f,this.setScale(s)}}zoomCenter(e){var t=this.getMetrics();let o;this.flyout?(o=t.svgWidth?t.svgWidth/2:0,t=t.svgHeight?t.svgHeight/2:0):(o=t.viewWidth/2+t.absoluteLeft,t=t.viewHeight/2+t.absoluteTop),this.zoom(o,t,e)}zoomToFit(){if(this.isMovable()){var e=this.getMetrics(),t=e.viewWidth;e=e.viewHeight;var o=this.getBlocksBoundingBox(),s=Bb*2,i=o.right-o.left+s;if(o=o.bottom-o.top+s,i){this.flyout&&(this.horizontalLayout?(e+=this.flyout.getHeight(),o+=this.flyout.getHeight()/this.scale):(t+=this.flyout.getWidth(),i+=this.flyout.getWidth()/this.scale)),t/=i,e/=o,r.disable$$module$build$src$core$events$utils();try{this.setScale(Math.min(t,e)),this.scrollCenter()}finally{r.enable$$module$build$src$core$events$utils()}this.maybeFireViewportChangeEvent()}}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}beginCanvasTransition(){G(this.getCanvas(),"blocklyCanvasTransitioning"),G(this.getBubbleCanvas(),"blocklyCanvasTransitioning")}endCanvasTransition(){Te(this.getCanvas(),"blocklyCanvasTransitioning"),Te(this.getBubbleCanvas(),"blocklyCanvasTransitioning")}scrollCenter(){if(this.isMovable()){var e=this.getMetrics(),t=(e.scrollWidth-e.viewWidth)/2,o=(e.scrollHeight-e.viewHeight)/2;t=-t-e.scrollLeft,o=-o-e.scrollTop,this.scroll(t,o)}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}centerOnBlock(e,t){if(this.isMovable()){var o=e?this.getBlockById(e):null;if(o){e=o.getRelativeToSurfaceXY(),o=t?{height:o.height,width:o.width}:o.getHeightWidth();var s=this.scale;t=(e.x+(this.RTL?-1:1)*o.width/2)*s,e=(e.y+o.height/2)*s,o=this.getMetrics(),this.scroll(-(t-o.viewWidth/2),-(e-o.viewHeight/2))}}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}setScale(e){this.options.zoomOptions.maxScale&&e>this.options.zoomOptions.maxScale?e=this.options.zoomOptions.maxScale:this.options.zoomOptions.minScale&&e<this.options.zoomOptions.minScale&&(e=this.options.zoomOptions.minScale),this.scale=e,this.hideChaff(!1),(e=this.getFlyout(!1))&&e.isVisible()&&(e.reflow(),this.recordDragTargets()),this.grid&&this.grid.update(this.scale),e=this.getMetrics(),this.scrollX-=e.absoluteLeft,this.scrollY-=e.absoluteTop,e.viewLeft+=e.absoluteLeft,e.viewTop+=e.absoluteTop,this.scroll(this.scrollX,this.scrollY),this.scrollbar&&(this.flyout?this.scrollbar.resizeView(e):this.scrollbar.resizeContent(e))}getScale(){return this.scale}getAbsoluteScale(){const e=o=>{if(o.isFlyout){let s;const i=(s=o.targetWorkspace)==null?void 0:s.getFlyout();if(i instanceof gl)return i.getFlyoutScale()}return o.getScale()},t=(o,s)=>o.options.parentWorkspace&&o.options.parentWorkspace.getSvgGroup().contains(o.getSvgGroup())?t(o.options.parentWorkspace,s*e(o)):s*e(o);return t(this,1)}scroll(e,t){this.hideChaff(!0);const o=this.getMetrics();e=Math.min(e,-o.scrollLeft),t=Math.min(t,-o.scrollTop);const s=o.scrollTop+Math.max(0,o.scrollHeight-o.viewHeight);e=Math.max(e,-(o.scrollLeft+Math.max(0,o.scrollWidth-o.viewWidth))),t=Math.max(t,-s),this.scrollX=e,this.scrollY=t,this.scrollbar&&this.scrollbar.set(-(e+o.scrollLeft),-(t+o.scrollTop),!1),e+=o.absoluteLeft,t+=o.absoluteTop,this.translate(e,t)}getBlockById(e){return super.getBlockById(e)}getAllBlocks(e=!1){return super.getAllBlocks(e)}getTopBlocks(e=!1){return super.getTopBlocks(e)}addTopBlock(e){this.addTopBoundedElement(e),super.addTopBlock(e)}removeTopBlock(e){this.removeTopBoundedElement(e),super.removeTopBlock(e)}addTopComment(e){this.addTopBoundedElement(e),super.addTopComment(e)}removeTopComment(e){this.removeTopBoundedElement(e),super.removeTopComment(e)}getTopComments(e=!1){return super.getTopComments(e)}getCommentById(e){return super.getCommentById(e)}getRootWorkspace(){return super.getRootWorkspace()}addTopBoundedElement(e){this.topBoundedElements.push(e)}removeTopBoundedElement(e){x(this.topBoundedElements,e)}getTopBoundedElements(e=!1){const t=[].concat(this.topBoundedElements);return e&&t.sort(this.sortByOrigin.bind(this)),t}setResizesEnabled(e){const t=!this.resizesEnabled&&e;this.resizesEnabled=e,t&&this.resizeContents()}clear(){this.setResizesEnabled(!1),super.clear(),this.topBoundedElements=[],this.setResizesEnabled(!0)}registerButtonCallback(e,t){if(typeof t!="function")throw TypeError("Button callbacks must be functions.");this.flyoutButtonCallbacks.set(e,t)}getButtonCallback(e){let t;return(t=this.flyoutButtonCallbacks.get(e))!=null?t:null}removeButtonCallback(e){this.flyoutButtonCallbacks.delete(e)}registerToolboxCategoryCallback(e,t){if(typeof t!="function")throw TypeError("Toolbox category callbacks must be functions.");this.toolboxCategoryCallbacks.set(e,t)}getToolboxCategoryCallback(e){return this.toolboxCategoryCallbacks.get(e)||null}removeToolboxCategoryCallback(e){this.toolboxCategoryCallbacks.delete(e)}getGesture(e){if(this.keyboardMoveInProgress)return e.preventDefault(),e.stopPropagation(),null;const t=e.type==="pointerdown";let o;return t&&((o=this.currentGesture_)!=null&&o.hasStarted())&&(console.warn("Tried to start the same gesture twice."),this.currentGesture_.cancel()),!this.currentGesture_&&t&&(this.currentGesture_=new fl(e,this)),this.currentGesture_}clearGesture(){this.currentGesture_=null}cancelCurrentGesture(){this.currentGesture_&&this.currentGesture_.cancel()}getAudioManager(){return this.audioManager}getGrid(){return this.grid}hideChaff(e=!1){xo(),ji(this),mo(),this.hideComponents(e)}hideComponents(e=!1){this.getComponentManager().getComponents(Ve.Capability.AUTOHIDEABLE,!0).forEach(t=>t.autoHide(e))}static setTopLevelWorkspaceMetrics(e){const t=this.getMetrics();typeof e.x=="number"&&(this.scrollX=-(t.scrollLeft+(t.scrollWidth-t.viewWidth)*e.x)),typeof e.y=="number"&&(this.scrollY=-(t.scrollTop+(t.scrollHeight-t.viewHeight)*e.y)),this.translate(this.scrollX+t.absoluteLeft,this.scrollY+t.absoluteTop)}addClass(e){this.injectionDiv&&G(this.injectionDiv,e)}removeClass(e){this.injectionDiv&&Te(this.injectionDiv,e)}setIsReadOnly(e){super.setIsReadOnly(e),e?this.addClass("blocklyReadOnly"):this.removeClass("blocklyReadOnly")}scrollBoundsIntoView(e,t=10){if(!fl.inProgress()){var o=this.getScale(),s=this.getMetricsManager().getViewMetrics(!0);if(s=new ye(s.top,s.top+s.height,s.left,s.left+s.width),!(e.left>=s.left&&e.top>=s.top&&e.right<=s.right&&e.bottom<=s.bottom)){e=e.clone(),e.top-=t,e.bottom+=t,e.left-=t,e.right+=t;var i=t=0;e.left<s.left?t=this.RTL?Math.min(s.left-e.left,s.right-e.right):s.left-e.left:e.right>s.right&&(t=this.RTL?s.right-e.right:Math.max(s.right-e.right,s.left-e.left)),e.top<s.top?i=s.top-e.top:e.bottom>s.bottom&&(i=Math.max(s.bottom-e.bottom,s.top-e.top)),this.scroll(this.scrollX+t*o,this.scrollY+i*o)}}}getFocusableElement(){return this.svgGroup_}getFocusableTree(){return this.isMutator&&this.options.parentWorkspace||this}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}getRootFocusableNode(){return this}getRestoredFocusableNode(e){if(e)return null;let t;return(t=this.getTopBlocks(!0)[0])!=null?t:null}getNestedTrees(){const e=this.getAllBlocks().map(o=>o.getIcons()).flat().filter(o=>o instanceof r.MutatorIcon$$module$build$src$core$icons$mutator_icon&&o.bubbleIsVisible()).map(o=>{let s;return(s=o.getBubble())==null?void 0:s.getWorkspace()}).filter(o=>!!o),t=this.getFlyout(!0);return t&&e.push(t.getWorkspace()),e}searchForWorkspaceComment(e){for(const t of this.getTopComments())if(t instanceof yo&&t.canBeFocused()&&t.getFocusableElement().id===e)return t}lookUpFocusableNode(e){var t;const o=(t=this.targetWorkspace)==null?void 0:t.getFlyout();if(this.isFlyout&&o){for(var s of o.getContents())if(t=s.getElement(),oo(t)&&t.canBeFocused()&&t.getFocusableElement().id===e)return t}if(s=e.indexOf("_field_"),t=e.indexOf("_connection_"),s!==-1){var i=e.substring(0,s);if(i=this.getBlockById(i)){for(var n of i.getFields())if(n.canBeFocused()&&n.getFocusableElement().id===e)return n}return null}if(t!==-1){if(i=e.substring(0,t),i=this.getBlockById(i)){for(const f of i.getConnections_(!0))if(f.id===e)return f}return null}if(n=Math.max(e.indexOf(Fa),e.indexOf(Qg),e.indexOf(om)),n!==-1&&(n=e.substring(0,n),n=this.searchForWorkspaceComment(n))){if(e.indexOf(Fa)>-1)return n.getEditorFocusableNode();var d;return(d=n.view.getCommentBarButtons().find(f=>f.getFocusableElement().id.includes(e)))!=null?d:null}if((d=this.getAllBlocks(!1).find(f=>f.getFocusableElement().id===e))||(d=this.searchForWorkspaceComment(e)))return d;d=this.getAllBlocks().map(f=>f.getIcons()).flat();for(i of d){if(i.canBeFocused()&&i.getFocusableElement().id===e)return i;if(Ts(i)&&(d=i.getBubble())&&d.canBeFocused()&&d.getFocusableElement().id===e)return d}return null}onTreeFocus(e,t){}onTreeBlur(e){if(this.isFlyout&&this.targetWorkspace&&!r.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()){var t=this.targetWorkspace.getFlyout(),o=this.targetWorkspace.getToolbox();o&&e===o||(o&&o.clearSelection(),t&&$u(t)&&t.autoHide(!1))}}getNavigator(){return this.navigator}setNavigator(e){this.navigator=e}},Ri=class extends hi{constructor(e){super(),this.isBlank=typeof e>"u",e&&(this.varId=e.getId(),this.workspaceId=e.getWorkspace().id)}toJson(){const e=super.toJson();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");return e.varId=this.varId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ri),t.varId=e.varId,t}},hh=class extends Ri{constructor(e){super(e),this.type=w.VAR_CREATE,e&&(this.varType=e.getType(),this.varName=e.getName())}toJson(){const e=super.toJson();if(this.varType===void 0)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");return e.varType=this.varType,e.varName=this.varName,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new hh),t.varType=e.varType,t.varName=e.varName,t}run(e){var t=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");t=t.getVariableMap(),e?t.createVariable(this.varName,this.varType,this.varId):(e=t.getVariableById(this.varId))&&t.deleteVariable(e)}};l(M.EVENT,w.VAR_CREATE,hh);var Fm=class{constructor(e,t,o,s){this.workspace=e,this.name=t,this.type=o||"",this.id=s||rt()}getId(){return this.id}getName(){return this.name}setName(e){return this.name=e,this}getType(){return this.type}setType(e){return this.type=e,this}getWorkspace(){return this.workspace}save(){const e={name:this.getName(),id:this.getId()},t=this.getType();return t&&(e.type=t),e}static load(e,t){e=new this(t,e.name,e.type,e.id),t.getVariableMap().addVariable(e),_(new(U(w.VAR_CREATE))(e))}};l(M.VARIABLE_MODEL,Ft,Fm);var dh=class extends Ri{constructor(e){super(e),this.type=w.VAR_DELETE,e&&(this.varType=e.getType(),this.varName=e.getName())}toJson(){const e=super.toJson();if(this.varType===void 0)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");return e.varType=this.varType,e.varName=this.varName,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new dh),t.varType=e.varType,t.varName=e.varName,t}run(e){var t=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");t=t.getVariableMap(),e?(e=t.getVariableById(this.varId))&&t.deleteVariable(e):t.createVariable(this.varName,this.varType,this.varId)}};l(M.EVENT,w.VAR_DELETE,dh);var $h=class extends Ri{constructor(e,t){super(e),this.type=w.VAR_RENAME,e&&(this.oldName=e.getName(),this.newName=typeof t>"u"?"":t)}toJson(){const e=super.toJson();if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");return e.oldName=this.oldName,e.newName=this.newName,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new $h),t.oldName=e.oldName,t.newName=e.newName,t}run(e){var t=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");t=t.getVariableMap();const o=t.getVariableById(this.varId);e?o&&t.renameVariable(o,this.newName):o&&t.renameVariable(o,this.oldName)}};l(M.EVENT,w.VAR_RENAME,$h);var Um=class{constructor(e,t=!1){this.workspace=e,this.potentialMap=t,this.variableMap=new Map}clear(){for(const e of this.variableMap.values())for(const t of e.values())this.deleteVariable(t);if(this.variableMap.size!==0)throw Error("Non-empty variable map")}renameVariable(e,t){if(e.getName()===t)return e;var o=e.getType();o=this.getVariable(t,o);const s=this.workspace.getAllBlocks(!1);let i="";this.potentialMap||(i=r.getGroup$$module$build$src$core$events$utils())||r.setGroup$$module$build$src$core$events$utils(!0);try{o&&o.getId()!==e.getId()?this.renameVariableWithConflict(e,t,o,s):this.renameVariableAndUses(e,t,s)}finally{this.potentialMap||r.setGroup$$module$build$src$core$events$utils(i)}return e}changeVariableType(e,t){var o;(o=this.variableMap.get(e.getType()))==null||o.delete(e.getId()),e.setType(t);let s;return o=(s=this.variableMap.get(t))!=null?s:new Map,o.set(e.getId(),e),this.variableMap.has(t)||this.variableMap.set(t,o),e}renameVariableById(e,t){pt("VariableMap.renameVariableById","v12","v13","VariableMap.renameVariable");const o=this.getVariableById(e);if(!o)throw Error("Tried to rename a variable that didn't exist. ID: "+e);this.renameVariable(o,t)}renameVariableAndUses(e,t,o){for(this.potentialMap||_(new(U(w.VAR_RENAME))(e,t)),e.setName(t),t=0;t<o.length;t++)o[t].updateVarName(e)}renameVariableWithConflict(e,t,o,s){const i=e.getType(),n=o.getName();for(t!==n&&this.renameVariableAndUses(o,t,s),t=0;t<s.length;t++)s[t].renameVarById(e.getId(),o.getId());this.potentialMap||_(new(U(w.VAR_DELETE))(e));let d;(d=this.variableMap.get(i))==null||d.delete(e.getId())}createVariable(e,t,o){var s=this.getVariable(e,t);if(s){if(o&&s.getId()!==o)throw Error('Variable "'+e+'" is already in use and its id is "'+s.getId()+'" which conflicts with the passed in id, "'+o+'".');return s}if(o&&this.getVariableById(o))throw Error('Variable id, "'+o+'", is already in use.');if(s=o||rt(),t=t||"",o=D(M.VARIABLE_MODEL,Ft,!0),!o)throw Error("No variable model is registered.");s=new o(this.workspace,e,t,s);let i;return e=(i=this.variableMap.get(t))!=null?i:new Map,e.set(s.getId(),s),this.variableMap.has(t)||this.variableMap.set(t,e),this.potentialMap||_(new(U(w.VAR_CREATE))(s)),s}addVariable(e){const t=e.getType();this.variableMap.has(t)||this.variableMap.set(t,new Map);let o;(o=this.variableMap.get(t))==null||o.set(e.getId(),e)}deleteVariable(e){const t=qs(this.workspace,e.getId());let o="";this.potentialMap||(o=r.getGroup$$module$build$src$core$events$utils())||r.setGroup$$module$build$src$core$events$utils(!0);try{for(let i=0;i<t.length;i++)t[i].dispose(!0);const s=this.variableMap.get(e.getType());s&&s.has(e.getId())&&(s.delete(e.getId()),this.potentialMap||_(new(U(w.VAR_DELETE))(e)),s.size===0&&this.variableMap.delete(e.getType()))}finally{this.potentialMap||r.setGroup$$module$build$src$core$events$utils(o)}}deleteVariableById(e){pt("VariableMap.deleteVariableById","v12","v13","Blockly.Variables.deleteVariable"),(e=this.getVariableById(e))&&r.deleteVariable$$module$build$src$core$variables(this.workspace,e)}getVariable(e,t){if(t=this.variableMap.get(t||""),!t)return null;let o;return(o=[...t.values()].find(s=>r.Names$$module$build$src$core$names.equals(s.getName(),e)))!=null?o:null}getVariableById(e){for(const t of this.variableMap.values())if(t.has(e)){let o;return(o=t.get(e))!=null?o:null}return null}getVariablesOfType(e){return(e=this.variableMap.get(e||""))?[...e.values()]:[]}getTypes(){return[...this.variableMap.keys()]}getAllVariables(){let e=[];for(const t of this.variableMap.values())e=e.concat(...t.values());return e}getAllVariableNames(){pt("VariableMap.getAllVariableNames","v12","v13","Blockly.Variables.getAllVariables");const e=[];for(const t of this.variableMap.values())for(const o of t.values())e.push(o.getName());return e}getVariableUsesById(e){return pt("VariableMap.getVariableUsesById","v12","v13","Blockly.Variables.getVariableUsesById"),qs(this.workspace,e)}};l(M.VARIABLE_MAP,Ft,Um);var ph=class extends Eo{constructor(e,t){super(t),this.type=w.TRASHCAN_OPEN,this.isOpen=e}toJson(){const e=super.toJson();if(this.isOpen===void 0)throw Error("Whether this is already open or not is undefined. Either pass a value to the constructor, or call fromJson");return e.isOpen=this.isOpen,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new ph),t.isOpen=e.isOpen,t}};l(M.EVENT,w.TRASHCAN_OPEN,ph);var Hm=class extends $l{constructor(e){super(),this.workspace=e,this.id="trashcan",this.contents=[],this.flyout=null,this.isLidOpen=!1,this.minOpenness=0,this.lidTask=this.svgLid=this.svgGroup=null,this.top=this.left=this.lidOpen=0,this.initialized=!1,this.workspace.options.maxTrashcanContents<=0||(e=this.workspace.copyOptionsForFlyout(),this.workspace.horizontalLayout?(e.toolboxPosition=this.workspace.toolboxPosition===be.TOP?be.BOTTOM:be.TOP,this.flyout=new(W(M.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(e)):(e.toolboxPosition=this.workspace.toolboxPosition===be.RIGHT?be.LEFT:be.RIGHT,this.flyout=new(W(M.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(e)),this.workspace.addChangeListener(this.onDelete.bind(this)))}createDom(){this.svgGroup=v(R.G,{class:"blocklyTrash"});let e;const t=String(Math.random()).substring(2);e=v(R.CLIPPATH,{id:"blocklyTrashBodyClipPath"+t},this.svgGroup),v(R.RECT,{width:wi,height:Cl,y:Oi},e);const o=v(R.IMAGE,{width:Dt.width,x:-gh,height:Dt.height,y:-mh,"clip-path":"url(#blocklyTrashBodyClipPath"+t+")"},this.svgGroup);return o.setAttributeNS(Ht,"xlink:href",this.workspace.options.pathToMedia+Dt.url),e=v(R.CLIPPATH,{id:"blocklyTrashLidClipPath"+t},this.svgGroup),v(R.RECT,{width:wi,height:Oi},e),this.svgLid=v(R.IMAGE,{width:Dt.width,x:-gh,height:Dt.height,y:-mh,"clip-path":"url(#blocklyTrashLidClipPath"+t+")"},this.svgGroup),this.svgLid.setAttributeNS(Ht,"xlink:href",this.workspace.options.pathToMedia+Dt.url),ae(this.svgGroup,"pointerdown",this,this.blockMouseDownWhenOpenable),ae(this.svgGroup,"pointerup",this,this.click),ae(o,"pointerover",this,this.mouseOver),ae(o,"pointerout",this,this.mouseOut),this.animateLid(),this.svgGroup}init(){if(this.workspace.options.maxTrashcanContents>0){const e=this.flyout.createDom(R.SVG);G(e,"blocklyTrashcanFlyout"),Qt(e,this.workspace.getParentSvg()),this.flyout.init(this.workspace)}this.workspace.getComponentManager().addComponent({component:this,weight:Ve.ComponentWeight.TRASHCAN_WEIGHT,capabilities:[Ve.Capability.AUTOHIDEABLE,Ve.Capability.DELETE_AREA,Ve.Capability.DRAG_TARGET,Ve.Capability.POSITIONABLE]}),this.initialized=!0,this.setLidOpen(!1)}dispose(){this.workspace.getComponentManager().removeComponent("trashcan"),this.svgGroup&&ke(this.svgGroup),this.lidTask&&clearTimeout(this.lidTask)}hasContents(){return!!this.contents.length}contentsIsOpen(){return!!this.flyout&&this.flyout.isVisible()}openFlyout(){if(!this.contentsIsOpen()){var e=this.contents.map(function(o){return JSON.parse(o)}),t=this.workspace.getParentSvg().style;t.cursor="wait",setTimeout(()=>{let o;(o=this.flyout)==null||o.show(e),t.cursor="";let s;(s=this.workspace.scrollbar)==null||s.setVisible(!1)},10),this.fireUiEvent(!0)}}closeFlyout(){if(this.contentsIsOpen()){var e;(e=this.flyout)==null||e.hide();var t;(t=this.workspace.scrollbar)==null||t.setVisible(!0),this.fireUiEvent(!1),this.workspace.recordDragTargets()}}autoHide(e){!e&&this.flyout&&this.closeFlyout()}emptyContents(){this.hasContents()&&(this.contents.length=0,this.setMinOpenness(0),this.closeFlyout())}position(e,t){if(this.initialized){var o=Wr(this.workspace,e);e=Vr(o,new ve(wi,Cl+Oi),Pb,Gm,e,this.workspace),t=zr(e,Gm,o.vertical===Go.TOP?ls.DOWN:ls.UP,t),this.top=t.top,this.left=t.left;var s;(s=this.svgGroup)==null||s.setAttribute("transform","translate("+this.left+","+this.top+")");var i;(i=this.flyout)==null||i.position()}}getBoundingRectangle(){return new ye(this.top,this.top+Cl+Oi,this.left,this.left+wi)}getClientRect(){if(!this.svgGroup)return null;var e=this.svgGroup.getBoundingClientRect();const t=e.top+mh-Sl;return e=e.left+gh-Sl,new ye(t,t+Oi+Cl+2*Sl,e,e+wi+2*Sl)}onDragOver(e){this.setLidOpen(this.wouldDelete_)}onDragExit(e){this.setLidOpen(!1)}onDrop(e){setTimeout(this.setLidOpen.bind(this,!1),100)}setLidOpen(e){this.isLidOpen!==e&&(this.lidTask&&clearTimeout(this.lidTask),this.isLidOpen=e,this.animateLid())}animateLid(){const e=Hb;var t=1/(e+1);this.lidOpen+=this.isLidOpen?t:-t,this.lidOpen=Math.min(Math.max(this.lidOpen,this.minOpenness),1),this.setLidAngle(this.lidOpen*Wm),t=Vm+this.lidOpen*(Gb-Vm),this.svgGroup&&(this.svgGroup.style.opacity=`${t}`),this.lidOpen>this.minOpenness&&this.lidOpen<1&&(this.lidTask=setTimeout(this.animateLid.bind(this),Ub/e))}setLidAngle(e){const t=this.workspace.toolboxPosition===be.RIGHT||this.workspace.horizontalLayout&&this.workspace.RTL;let o;(o=this.svgLid)==null||o.setAttribute("transform","rotate("+(t?-e:e)+","+(t?4:wi-4)+","+(Oi-2)+")")}setMinOpenness(e){this.minOpenness=e,this.isLidOpen||this.setLidAngle(e*Wm)}closeLid(){this.setLidOpen(!1)}click(){this.hasContents()&&!this.workspace.isDragging()&&this.openFlyout()}fireUiEvent(e){e=new(U(w.TRASHCAN_OPEN))(e,this.workspace.id),_(e)}blockMouseDownWhenOpenable(e){!this.contentsIsOpen()&&this.hasContents()&&e.stopPropagation()}mouseOver(){this.hasContents()&&this.setLidOpen(!0)}mouseOut(){this.setLidOpen(!1)}onDelete(e){if(!(this.workspace.options.maxTrashcanContents<=0||!Bt(e)||e.wasShadow)){if(!e.oldJson)throw Error("Encountered a delete event without proper oldJson");if(e=JSON.stringify(this.cleanBlockJson(e.oldJson)),!this.contents.includes(e)){for(this.contents.unshift(e);this.contents.length>this.workspace.options.maxTrashcanContents;)this.contents.pop();this.setMinOpenness(Fb)}}}cleanBlockJson(e){function t(o){if(o){if(delete o.id,delete o.x,delete o.y,delete o.enabled,delete o.disabledReasons,o.icons&&o.icons.comment){var s=o.icons.comment;delete s.height,delete s.width,delete s.pinned}s=o.inputs;for(var i in s){var n=s[i];const d=n.block;n=n.shadow,d&&t(d),n&&t(n)}o.next&&(i=o.next,o=i.block,i=i.shadow,o&&t(o),i&&t(i))}}return e=JSON.parse(JSON.stringify(e)),t(e),Object.assign({},{kind:"BLOCK"},e)}},wi=47,Cl=44,Oi=16,Gm=20,Pb=20,Sl=10,gh=0,mh=32,Fb=.1,Ub=80,Hb=4,Vm=.4,Gb=.8,Wm=45,kr=null,Rr=null,kl=void 0,uo={};uo.BlockPaster=yr,uo.copy=Rn,uo.getLastCopiedData=wn,uo.getLastCopiedLocation=Iu,uo.getLastCopiedWorkspace=On,uo.paste=ss,uo.registry=_a,uo.setLastCopiedData=_p,uo.setLastCopiedLocation=Tp,uo.setLastCopiedWorkspace=bp;var ds={};ds.CollapseCommentBarButton=em,ds.CommentBarButton=rl,ds.CommentEditor=tm,ds.CommentView=_r,ds.DeleteCommentBarButton=sm,ds.RenderedWorkspaceComment=yo,ds.WorkspaceComment=nl;var ko;(function(e){e.ESCAPE="escape",e.DELETE="delete",e.COPY="copy",e.CUT="cut",e.PASTE="paste",e.UNDO="undo",e.REDO="redo"})(ko||(ko={})),Mu();var Ro={};Ro.names=ko,Ro.registerCopy=wu,Ro.registerCut=Ou,Ro.registerDefaultShortcuts=Mu,Ro.registerDelete=ku,Ro.registerEscape=Su,Ro.registerPaste=Nu,Ro.registerRedo=Lu,Ro.registerUndo=Au;var Vb=class{constructor(e,t){this.procedureModelClass=e,this.parameterModelClass=t,this.priority=pg}save(e){return e=e.getProcedureMap().getProcedures().map(t=>Du(t)),e.length?e:null}load(e,t){const o=t.getProcedureMap();for(const s of e)o.add(xu(this.procedureModelClass,this.parameterModelClass,s,t))}clear(e){e.getProcedureMap().clear()}},Rl={};Rl.ProcedureSerializer=Vb,Rl.loadProcedure=xu,Rl.saveProcedure=Du;var zm=class{constructor(){this.priority=$g}save(e){return e=e.getAllVariables().map(t=>t.save()),e.length?e:null}load(e,t){const o=D(M.VARIABLE_MODEL,Ft);e.forEach(s=>{o?.load(s,t)})}clear(e){e.getVariableMap().clear()}};Fi("variables",new zm);var Ym={};Ym.VariableSerializer=zm;var fh={};fh.load=yp,fh.save=Ep;var Wb={blocks:$r,exceptions:Os,priorities:Tb,procedures:Rl,registry:fa,variables:Ym,workspaceComments:Hn,workspaces:fh};"Blockly"in globalThis||(globalThis.Blockly={Msg:Tg});var _h="label",Xm=class{load(e,t){return e=new xt(t.getWorkspace(),t.targetWorkspace,e,!0),e.show(),new Ci(e,_h)}gapForItem(e,t){return t}disposeItem(e){e=e.getElement(),e instanceof xt&&e.dispose()}getType(){return _h}};l(M.FLYOUT_INFLATER,_h,Xm);var jm=class extends El{constructor(e){super(),this.GRID_UNIT=4,this.CURSOR_COLOUR="#ffa200",this.CURSOR_RADIUS=5,this.JAGGED_TEETH_WIDTH=this.JAGGED_TEETH_HEIGHT=0,this.START_HAT_HEIGHT=22,this.START_HAT_WIDTH=96,this.SHAPES={HEXAGONAL:1,ROUND:2,SQUARE:3,PUZZLE:4,NOTCH:5},this.SHAPE_IN_SHAPE_PADDING={1:{0:5*this.GRID_UNIT,1:2*this.GRID_UNIT,2:5*this.GRID_UNIT,3:5*this.GRID_UNIT},2:{0:3*this.GRID_UNIT,1:3*this.GRID_UNIT,2:1*this.GRID_UNIT,3:2*this.GRID_UNIT},3:{0:2*this.GRID_UNIT,1:2*this.GRID_UNIT,2:2*this.GRID_UNIT,3:2*this.GRID_UNIT}},this.FULL_BLOCK_FIELDS=!0,this.FIELD_TEXT_FONTWEIGHT="bold",this.FIELD_TEXT_FONTFAMILY='"Helvetica Neue", "Segoe UI", Helvetica, sans-serif',this.FIELD_COLOUR_FULL_BLOCK=this.FIELD_TEXTINPUT_BOX_SHADOW=this.FIELD_DROPDOWN_SVG_ARROW=this.FIELD_DROPDOWN_COLOURED_DIV=this.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW=!0,this.SELECTED_GLOW_COLOUR="#fff200",this.SELECTED_GLOW_SIZE=.5,this.REPLACEMENT_GLOW_COLOUR="#fff200",this.REPLACEMENT_GLOW_SIZE=2,this.selectedGlowFilterId="",this.selectedGlowFilter=null,this.replacementGlowFilterId="",this.SQUARED=this.ROUNDED=this.HEXAGONAL=this.replacementGlowFilter=null,e&&(this.GRID_UNIT=e),this.SMALL_PADDING=this.GRID_UNIT,this.MEDIUM_PADDING=2*this.GRID_UNIT,this.MEDIUM_LARGE_PADDING=3*this.GRID_UNIT,this.LARGE_PADDING=4*this.GRID_UNIT,this.CORNER_RADIUS=1*this.GRID_UNIT,this.NOTCH_WIDTH=9*this.GRID_UNIT,this.NOTCH_HEIGHT=2*this.GRID_UNIT,this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT=3*this.GRID_UNIT,this.MIN_BLOCK_WIDTH=2*this.GRID_UNIT,this.MIN_BLOCK_HEIGHT=12*this.GRID_UNIT,this.EMPTY_STATEMENT_INPUT_HEIGHT=6*this.GRID_UNIT,this.TOP_ROW_MIN_HEIGHT=this.CORNER_RADIUS,this.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING,this.BOTTOM_ROW_MIN_HEIGHT=this.CORNER_RADIUS,this.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT=6*this.GRID_UNIT,this.STATEMENT_BOTTOM_SPACER=-this.NOTCH_HEIGHT,this.STATEMENT_INPUT_SPACER_MIN_WIDTH=40*this.GRID_UNIT,this.STATEMENT_INPUT_PADDING_LEFT=4*this.GRID_UNIT,this.EMPTY_INLINE_INPUT_PADDING=4*this.GRID_UNIT,this.EMPTY_INLINE_INPUT_HEIGHT=8*this.GRID_UNIT,this.DUMMY_INPUT_MIN_HEIGHT=8*this.GRID_UNIT,this.DUMMY_INPUT_SHADOW_MIN_HEIGHT=6*this.GRID_UNIT,this.CURSOR_WS_WIDTH=20*this.GRID_UNIT,this.FIELD_TEXT_FONTSIZE=3*this.GRID_UNIT,this.FIELD_BORDER_RECT_RADIUS=this.CORNER_RADIUS,this.FIELD_BORDER_RECT_X_PADDING=2*this.GRID_UNIT,this.FIELD_BORDER_RECT_Y_PADDING=1.625*this.GRID_UNIT,this.FIELD_BORDER_RECT_HEIGHT=8*this.GRID_UNIT,this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=8*this.GRID_UNIT,this.FIELD_DROPDOWN_SVG_ARROW_PADDING=this.FIELD_BORDER_RECT_X_PADDING,this.FIELD_COLOUR_DEFAULT_WIDTH=6*this.GRID_UNIT,this.FIELD_COLOUR_DEFAULT_HEIGHT=8*this.GRID_UNIT,this.FIELD_CHECKBOX_X_OFFSET=1*this.GRID_UNIT,this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH=12*this.GRID_UNIT}setFontConstants_(e){super.setFontConstants_(e),this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT=this.FIELD_TEXT_HEIGHT+this.FIELD_BORDER_RECT_Y_PADDING*2}init(){super.init(),this.HEXAGONAL=this.makeHexagonal(),this.ROUNDED=this.makeRounded(),this.SQUARED=this.makeSquared(),this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT+this.INSIDE_CORNERS.rightWidth}setDynamicProperties_(e){super.setDynamicProperties_(e),this.SELECTED_GLOW_COLOUR=e.getComponentStyle("selectedGlowColour")||this.SELECTED_GLOW_COLOUR;const t=Number(e.getComponentStyle("selectedGlowSize"));this.SELECTED_GLOW_SIZE=t&&!isNaN(t)?t:this.SELECTED_GLOW_SIZE,this.REPLACEMENT_GLOW_COLOUR=e.getComponentStyle("replacementGlowColour")||this.REPLACEMENT_GLOW_COLOUR,this.REPLACEMENT_GLOW_SIZE=(e=Number(e.getComponentStyle("replacementGlowSize")))&&!isNaN(e)?e:this.REPLACEMENT_GLOW_SIZE}dispose(){super.dispose(),this.selectedGlowFilter&&ke(this.selectedGlowFilter),this.replacementGlowFilter&&ke(this.replacementGlowFilter)}makeStartHat(){const e=this.START_HAT_HEIGHT,t=this.START_HAT_WIDTH,o=Pt("c",[se(25,-e),se(71,-e),se(t,0)]);return{height:e*.75,width:t,path:o}}makeHexagonal(){function e(o,s,i){var n=o/2;return n=n>t?t:n,i=i?-1:1,o=(s?-1:1)*o/2,bo(-i*n,o)+bo(i*n,o)}const t=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH;return{type:this.SHAPES.HEXAGONAL,isDynamic:!0,width(o){return o/=2,o>t?t:o},height(o){return o},connectionOffsetY(o){return o/2},connectionOffsetX(o){return-o},pathDown(o){return e(o,!1,!1)},pathUp(o){return e(o,!0,!1)},pathRightDown(o){return e(o,!1,!0)},pathRightUp(o){return e(o,!1,!0)}}}makeRounded(){function e(s,i,n){const d=s>o?s-o:0;s=(s>o?o:s)/2;const f=n===i?"0":"1";return qe("a","0 0,"+f,s,se((n?1:-1)*s,(i?-1:1)*s))+re("v",(i?-1:1)*d)+qe("a","0 0,"+f,s,se((n?-1:1)*s,(i?-1:1)*s))}const t=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,o=t*2;return{type:this.SHAPES.ROUND,isDynamic:!0,width(s){return s/=2,s>t?t:s},height(s){return s},connectionOffsetY(s){return s/2},connectionOffsetX(s){return-s},pathDown(s){return e(s,!1,!1)},pathUp(s){return e(s,!0,!1)},pathRightDown(s){return e(s,!1,!0)},pathRightUp(s){return e(s,!1,!0)}}}makeSquared(){function e(o,s,i){o-=t*2;const n=i===s?"0":"1";return qe("a","0 0,"+n,t,se((i?1:-1)*t,(s?-1:1)*t))+re("v",(s?-1:1)*o)+qe("a","0 0,"+n,t,se((i?-1:1)*t,(s?-1:1)*t))}const t=this.CORNER_RADIUS;return{type:this.SHAPES.SQUARE,isDynamic:!0,width(o){return t},height(o){return o},connectionOffsetY(o){return o/2},connectionOffsetX(o){return-o},pathDown(o){return e(o,!1,!1)},pathUp(o){return e(o,!0,!1)},pathRightDown(o){return e(o,!1,!0)},pathRightUp(o){return e(o,!1,!0)}}}shapeFor(e){let t=e.getCheck();switch(!t&&e.targetConnection&&(t=e.targetConnection.getCheck()),e.type){case Z.INPUT_VALUE:case Z.OUTPUT_VALUE:if(e=e.getSourceBlock().getOutputShape(),e!==null)switch(e){case this.SHAPES.HEXAGONAL:return this.HEXAGONAL;case this.SHAPES.ROUND:return this.ROUNDED;case this.SHAPES.SQUARE:return this.SQUARED}return t&&t.includes("Boolean")?this.HEXAGONAL:t&&t.includes("Number")?this.ROUNDED:(t&&t.includes("String"),this.ROUNDED);case Z.PREVIOUS_STATEMENT:case Z.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown type")}}makeNotch(){function e(oe){return Pt("c",[se(oe*i/2,0),se(oe*i*3/4,d/2),se(oe*i,d)])+ni([se(oe*i,n)])+Pt("c",[se(oe*i/4,d/2),se(oe*i/2,d),se(oe*i,d)])+re("h",oe*s)+Pt("c",[se(oe*i/2,0),se(oe*i*3/4,-(d/2)),se(oe*i,-d)])+ni([se(oe*i,-n)])+Pt("c",[se(oe*i/4,-(d/2)),se(oe*i/2,-d),se(oe*i,-d)])}const t=this.NOTCH_WIDTH,o=this.NOTCH_HEIGHT,s=t/3,i=s/3,n=o/2,d=n/2,f=e(1),L=e(-1);return{type:this.SHAPES.NOTCH,width:t,height:o,pathLeft:f,pathRight:L}}makeInsideCorners(){const e=this.CORNER_RADIUS,t=qe("a","0 0,0",e,se(-e,e)),o=qe("a","0 0,1",e,se(-e,e)),s=qe("a","0 0,0",e,se(e,e)),i=qe("a","0 0,1",e,se(e,e));return{width:e,height:e,pathTop:t,pathBottom:s,rightWidth:e,rightHeight:e,pathTopRight:o,pathBottomRight:i}}generateSecondaryColour_(e){return ys("#000",e,.15)||e}generateTertiaryColour_(e){return ys("#000",e,.25)||e}createDom(e,t,o,s){super.createDom(e,t,o,s),e=v(R.DEFS,{},e),t=v(R.FILTER,{id:"blocklySelectedGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e),v(R.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.SELECTED_GLOW_SIZE},t),o=v(R.FECOMPONENTTRANSFER,{result:"outBlur"},t),v(R.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},o),v(R.FEFLOOD,{"flood-color":this.SELECTED_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},t),v(R.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},t),this.selectedGlowFilterId=t.id,this.selectedGlowFilter=t,e=v(R.FILTER,{id:"blocklyReplacementGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e),v(R.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.REPLACEMENT_GLOW_SIZE},e),t=v(R.FECOMPONENTTRANSFER,{result:"outBlur"},e),v(R.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},t),v(R.FEFLOOD,{"flood-color":this.REPLACEMENT_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},e),v(R.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},e),v(R.FECOMPOSITE,{in:"SourceGraphic",in2:"outGlow",operator:"over"},e),this.replacementGlowFilterId=e.id,this.replacementGlowFilter=e,s&&(s.style.setProperty("--blocklySelectedGlowFilter",`url(#${this.selectedGlowFilterId})`),s.style.setProperty("--blocklyReplacementGlowFilter",`url(#${this.replacementGlowFilterId})`))}getCSS_(e){return[`${e} .blocklyText,`,`${e} .blocklyFlyoutLabelText {`,`font: ${this.FIELD_TEXT_FONTWEIGHT} ${this.FIELD_TEXT_FONTSIZE}pt ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${e} .blocklyTextInputBubble textarea {`,"font-weight: normal;","}",`${e} .blocklyText {`,"fill: #fff;","}",`${e} .blocklyNonEditableField>rect:not(.blocklyDropdownRect),`,`${e} .blocklyEditableField>rect:not(.blocklyDropdownRect) {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"}",`${e} .blocklyNonEditableField>text,`,`${e} .blocklyEditableField>text,`,`${e} .blocklyNonEditableField>g>text,`,`${e} .blocklyEditableField>g>text {`,"fill: #575E75;","}",`${e} .blocklyFlyoutLabelText {`,"fill: #575E75;","}",`${e} .blocklyText.blocklyBubbleText {`,"fill: #575E75;","}",`${e} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableField:not(.blocklyEditing):hover>rect,",`${e} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableField:not(.blocklyEditing):hover>.blocklyPath {","stroke: #fff;","stroke-width: 2;","}",`${e} .blocklyHtmlInput {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"color: #575E75;","}",`${e} .blocklyDropdownText {`,"fill: #fff !important;","}",`${e}.blocklyWidgetDiv .blocklyMenuItem,`,`${e}.blocklyDropDownDiv .blocklyMenuItem {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${e}.blocklyDropDownDiv .blocklyMenuItemContent {`,"color: #fff;","}",`${e} .blocklyHighlightedConnectionPath {`,`stroke: ${this.SELECTED_GLOW_COLOUR};`,"}",`${e} .blocklyDisabledPattern > .blocklyOutlinePath {`,"fill: var(--blocklyDisabledPattern)","}",`${e} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}",`${e} .blocklySelected>.blocklyPath.blocklyPathSelected {`,"fill: none;","filter: var(--blocklySelectedGlowFilter);","}",`${e} .blocklyReplaceable>.blocklyPath {`,"filter: var(--blocklyReplacementGlowFilter);","}"]}},Km=class extends yl{constructor(e,t){super(e,t)}draw(){const e=this.block_.pathObject;e.beginDrawing(),this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights(),e.setPath(this.outlinePath_+`
661
+ `+this.inlinePath_),this.info_.RTL&&e.flipRTL(),this.recordSizeOnBlock_(),this.info_.outputConnection&&(e.outputShapeType=this.info_.outputConnection.shape.type),e.endDrawing()}drawOutline_(){this.info_.outputConnection&&this.info_.outputConnection.isDynamicShape&&!this.info_.hasStatementInput&&!this.info_.bottomRow.hasNextConnection?(this.drawFlatTop_(),this.drawRightDynamicConnection_(),this.drawFlatBottom_(),this.drawLeftDynamicConnection_()):super.drawOutline_()}drawLeft_(){this.info_.outputConnection&&this.info_.outputConnection.isDynamicShape?this.drawLeftDynamicConnection_():super.drawLeft_()}drawRightSideRow_(e){if(!(e.height<=0)){if(T.isSpacer(e)){const s=e.precedesStatement;var t=e.followsStatement;if(s||t){const i=this.constants_.INSIDE_CORNERS;var o=i.rightHeight;o=e.height-(s?o:0),t=t?i.pathBottomRight:"",e=o>0?re("V",e.yPos+o):"",this.outlinePath_+=t+e+(s?i.pathTopRight:"");return}}this.outlinePath_+=re("V",e.yPos+e.height)}}drawRightDynamicConnection_(){if(!this.info_.outputConnection)throw Error("Cannot draw the output connection of a block that doesn't have one");this.outlinePath_+=this.info_.outputConnection.shape.pathRightDown(this.info_.outputConnection.height)}drawLeftDynamicConnection_(){if(!this.info_.outputConnection)throw Error("Cannot draw the output connection of a block that doesn't have one");this.positionOutputConnection_(),this.outlinePath_+=this.info_.outputConnection.shape.pathUp(this.info_.outputConnection.height),this.outlinePath_+="z"}drawFlatTop_(){const e=this.info_.topRow;this.positionPreviousConnection_(),this.outlinePath_+=je(e.xPos,this.info_.startY),this.outlinePath_+=re("h",e.width)}drawFlatBottom_(){const e=this.info_.bottomRow;this.positionNextConnection_(),this.outlinePath_+=re("V",e.baseline),this.outlinePath_+=re("h",-e.width)}drawInlineInput_(e){this.positionInlineInputConnection_(e);const t=e.input.name;e.connectedBlock||this.info_.isInsertionMarker||(e=gt(e.xPos+e.connectionWidth,e.centerline-e.height/2)+this.getInlineInputPath(e),this.block_.pathObject.setOutlinePath(t,e))}getInlineInputPath(e){const t=e.width-e.connectionWidth*2,o=e.height;return re("h",t)+e.shape.pathRightDown(o)+re("h",-t)+e.shape.pathUp(o)+"z"}drawStatementInput_(e){var t=e.getLastInput();const o=t.xPos+t.notchOffset+t.shape.width,s=this.constants_.INSIDE_CORNERS,i=t.shape.pathRight+re("h",-(t.notchOffset-s.width))+s.pathTop,n=e.height-2*s.height;t=s.pathBottom+re("h",t.notchOffset-s.width)+(t.connectedBottomNextConnection?"":t.shape.pathLeft),this.outlinePath_+=re("H",o)+i+re("v",n)+t+re("H",e.xPos+e.width),this.positionStatementInputConnection_(e)}drawConnectionHighlightPath(e){const t=e.connectionModel;if(t.type===Z.NEXT_STATEMENT||t.type===Z.PREVIOUS_STATEMENT||t.type===Z.OUTPUT_VALUE&&!e.isDynamicShape)return super.drawConnectionHighlightPath(e);e=t.type===Z.INPUT_VALUE?gt(e.connectionWidth,-e.height/2)+this.getInlineInputPath(e):gt(e.width,-e.height/2)+e.shape.pathDown(e.height);const o=t.getSourceBlock();let s,i;return(i=(s=o.pathObject).addConnectionHighlight)==null?void 0:i.call(s,t,e,t.getOffsetInBlock(),o.RTL)}},Hs=class extends we{constructor(e,t,o,s,i,n,d){if(super(we.SKIP_SETUP),this.imageElement=this.clickHandler=null,this.flipRtl=this.isDirty_=this.EDITABLE=!1,this.altText="",o=Number(Je(o)),t=Number(Je(t)),isNaN(o)||isNaN(t))throw Error("Height and width values of an image field must cast to numbers.");if(o<=0||t<=0)throw Error("Height and width values of an image field must be greater than 0.");this.size_=new ve(t,o+Hs.Y_PADDING),this.imageHeight=o,typeof i=="function"&&(this.clickHandler=i),e!==we.SKIP_SETUP&&(d?this.configure_(d):(this.flipRtl=!!n,this.altText=Je(s)||""),this.setValue(Je(e)))}configure_(e){super.configure_(e),e.flipRtl&&(this.flipRtl=e.flipRtl),e.alt&&(this.altText=Je(e.alt))}initView(){this.imageElement=v(R.IMAGE,{height:this.imageHeight+"px",width:this.size_.width+"px",alt:this.altText},this.fieldGroup_),this.imageElement.setAttributeNS(Ht,"xlink:href",this.value_),this.fieldGroup_&&G(this.fieldGroup_,"blocklyImageField"),this.clickHandler&&(this.imageElement.style.cursor="pointer")}updateSize_(){}doClassValidation_(e){return typeof e!="string"?null:e}doValueUpdate_(e){this.value_=e,this.imageElement&&this.imageElement.setAttributeNS(Ht,"xlink:href",this.value_)}getFlipRtl(){return this.flipRtl}setAlt(e){e!==this.altText&&(this.altText=e||"",this.imageElement&&this.imageElement.setAttribute("alt",this.altText))}isClickable(){return super.isClickable()&&!!this.clickHandler}showEditor_(){this.clickHandler&&this.clickHandler(this)}setOnClickHandler(e){this.clickHandler=e}getText_(){return this.altText}static fromJson(e){if(!e.src||!e.width||!e.height)throw Error("src, width, and height values for an image field arerequired. The width and height must be non-zero.");return new this(e.src,e.width,e.height,void 0,void 0,void 0,e)}};Hs.Y_PADDING=1,_o("field_image",Hs),Hs.prototype.DEFAULT_VALUE="";var Ni=class extends we{set size_(e){super.size_=e}get size_(){const e=super.size_;return e.width<14&&(e.width=14),e}constructor(e,t,o){super(we.SKIP_SETUP),this.spellcheck_=!0,this.htmlInput_=null,this.isTextValid_=this.isBeingEdited_=!1,this.onInputWrapper=this.onKeyDownWrapper=this.valueWhenEditorWasOpened_=null,this.fullBlockClickTarget_=!1,this.workspace_=null,this.SERIALIZABLE=!0,e!==we.SKIP_SETUP&&(o&&this.configure_(o),this.setValue(e),t&&this.setValidator(t))}configure_(e){super.configure_(e),e.spellcheck!==void 0&&(this.spellcheck_=e.spellcheck)}initView(){if(!this.getSourceBlock())throw new tt;super.initView(),this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot()),this.fieldGroup_&&G(this.fieldGroup_,"blocklyInputField")}isFullBlockField(){const e=this.getSourceBlock();if(!e)throw new tt;let t;return this.fullBlockClickTarget_=!((t=this.getConstants())==null||!t.FULL_BLOCK_FIELDS)&&e.isSimpleReporter()}doValueInvalid_(e,t=!0){this.isBeingEdited_&&(this.isDirty_=!0,this.isTextValid_=!1,e=this.value_,this.value_=this.valueWhenEditorWasOpened_,this.sourceBlock_&&J()&&this.value_!==e&&t&&_(new(U(w.BLOCK_CHANGE))(this.sourceBlock_,"field",this.name||null,e,this.value_)))}doValueUpdate_(e){this.isTextValid_=this.isDirty_=!0,this.value_=e}applyColour(){const e=this.getSourceBlock();if(!e)throw new tt;this.getConstants().FULL_BLOCK_FIELDS&&this.fieldGroup_&&(!this.isFullBlockField()&&this.borderRect_?(this.borderRect_.style.display="block",this.borderRect_.setAttribute("stroke",e.getColourTertiary())):(this.borderRect_.style.display="none",e.pathObject.svgPath.setAttribute("fill",this.getConstants().FIELD_BORDER_RECT_COLOUR)))}getSize(){let e;return(e=this.getConstants())!=null&&e.FULL_BLOCK_FIELDS&&(this.render_(),this.isDirty_=!1),super.getSize()}onLocationChange(){this.isBeingEdited_&&this.resizeEditor_()}render_(){if(super.render_(),this.isBeingEdited_){var e=this.htmlInput_;this.isTextValid_?(Te(e,"blocklyInvalidInput"),it(e,Qe.INVALID,!1)):(G(e,"blocklyInvalidInput"),it(e,Qe.INVALID,!0))}if(e=this.getSourceBlock(),!e)throw new tt;this.getConstants().FULL_BLOCK_FIELDS&&e.applyColour()}setSpellcheck(e){e!==this.spellcheck_&&(this.spellcheck_=e,this.htmlInput_&&this.htmlInput_.setAttribute("spellcheck",this.spellcheck_))}showEditor_(e,t=!1,o=!0){this.workspace_=this.sourceBlock_.workspace,!t&&this.workspace_.options.modalInputs&&(Xp||ia||Pn)?this.showPromptEditor():this.showInlineEditor(t,o)}showPromptEditor(){Kr(r.Msg$$module$build$src$core$msg.CHANGE_VALUE_TITLE,this.getText(),e=>{e!==null&&this.setValue(this.getValueFromEditorText_(e)),this.onFinishEditing_(this.value_)})}showInlineEditor(e,t){const o=this.getSourceBlock();if(!o)throw new tt;dn(this,o.RTL,this.widgetDispose_.bind(this),this.workspace_,t),this.htmlInput_=this.widgetCreate_(),this.isBeingEdited_=!0,this.valueWhenEditorWasOpened_=this.value_,e||(this.htmlInput_.focus({preventScroll:!0}),this.htmlInput_.select())}widgetCreate_(){var e=this.getSourceBlock();if(!e)throw new tt;r.setGroup$$module$build$src$core$events$utils(!0);const t=oi();var o=this.getClickTarget_();if(!o)throw Error("A click target has not been set.");G(o,"blocklyEditing"),o=document.createElement("input"),o.className="blocklyHtmlInput",o.setAttribute("spellcheck",this.spellcheck_);const s=this.workspace_.getAbsoluteScale();var i=this.getConstants().FIELD_TEXT_FONTSIZE*s+"pt";return t.style.fontSize=i,o.style.fontSize=i,i=Ni.BORDERRADIUS*s+"px",this.isFullBlockField()&&(i=this.getScaledBBox(),i=(i.bottom-i.top)/2+"px",e=e.getParent()?e.getParent().getColourTertiary():this.sourceBlock_.getColourTertiary(),o.style.border=1*s+"px solid "+e,t.style.borderRadius=i,t.style.transition="box-shadow 0.25s ease 0s",this.getConstants().FIELD_TEXTINPUT_BOX_SHADOW&&(t.style.boxShadow="rgba(255, 255, 255, 0.3) 0 0 0 "+4*s+"px")),o.style.borderRadius=i,t.appendChild(o),o.value=o.defaultValue=this.getEditorText_(this.value_),o.setAttribute("data-untyped-default-value",String(this.value_)),this.resizeEditor_(),this.bindInputEvents_(o),o}widgetDispose_(){this.isBeingEdited_=!1,this.isTextValid_=!0,this.forceRerender(),this.onFinishEditing_(this.value_),this.sourceBlock_&&J()&&this.valueWhenEditorWasOpened_!==null&&this.valueWhenEditorWasOpened_!==this.value_&&(_(new(U(w.BLOCK_CHANGE))(this.sourceBlock_,"field",this.name||null,this.valueWhenEditorWasOpened_,this.value_)),this.valueWhenEditorWasOpened_=null),r.setGroup$$module$build$src$core$events$utils(!1),this.unbindInputEvents_();var e=oi().style;if(e.width="auto",e.height="auto",e.fontSize="",e.transition="",e.boxShadow="",this.htmlInput_=null,e=this.getClickTarget_(),!e)throw Error("A click target has not been set.");Te(e,"blocklyEditing")}onFinishEditing_(e){}bindInputEvents_(e){this.onKeyDownWrapper=z(e,"keydown",this,this.onHtmlInputKeyDown_),this.onInputWrapper=z(e,"input",this,this.onHtmlInputChange)}unbindInputEvents_(){this.onKeyDownWrapper&&(te(this.onKeyDownWrapper),this.onKeyDownWrapper=null),this.onInputWrapper&&(te(this.onInputWrapper),this.onInputWrapper=null)}onHtmlInputKeyDown_(e){if(e.key==="Enter")vs(this),mo();else if(e.key==="Escape")this.setValue(this.htmlInput_.getAttribute("data-untyped-default-value"),!1),vs(this),mo();else if(e.key==="Tab"){e.preventDefault();var t,o=(t=this.workspace_)==null?void 0:t.getCursor();t=s=>(s instanceof Ni||s instanceof Be&&s.isSimpleReporter())&&s!==this.getSourceBlock(),e=e.shiftKey?o?.getPreviousNode(this,t,!1):o?.getNextNode(this,t,!1),e=e instanceof Be&&e.isSimpleReporter()?e.getFields().next().value:e,e instanceof Ni&&(vs(this),mo(),o=e.getSourceBlock(),e.isFullBlockField()&&o&&o instanceof Be?r.getFocusManager$$module$build$src$core$focus_manager().focusNode(o):r.getFocusManager$$module$build$src$core$focus_manager().focusNode(e),e.showEditor())}}onHtmlInputChange(e){e=this.value_,this.setValue(this.getValueFromEditorText_(this.htmlInput_.value),!1),this.sourceBlock_&&J()&&this.value_!==e&&_(new(U(w.BLOCK_FIELD_INTERMEDIATE_CHANGE))(this.sourceBlock_,this.name||null,e,this.value_))}setEditorValue_(e,t=!0){this.isDirty_=!0,this.isBeingEdited_&&(this.htmlInput_.value=this.getEditorText_(e)),this.setValue(e,t)}resizeEditor_(){go().then(()=>{const e=this.getSourceBlock();if(!e)throw new tt;const t=oi(),o=this.getScaledBBox();t.style.width=o.right-o.left+"px",t.style.height=o.bottom-o.top+"px";const s=o.top;t.style.left=`${e.RTL?o.right-t.offsetWidth:o.left}px`,t.style.top=`${s}px`})}repositionForWindowResize(){let e;const t=(e=this.getSourceBlock())==null?void 0:e.getRootBlock();return t instanceof Be?(ci(this.workspace_,this.workspace_.getMetricsManager().getViewMetrics(!0),t)||this.resizeEditor_(),!0):!1}getText_(){return this.isBeingEdited_&&this.htmlInput_?this.htmlInput_.value:null}getEditorText_(e){return`${e}`}getValueFromEditorText_(e){return e}};Ni.BORDERRADIUS=4,r.FieldTextInput$$module$build$src$core$field_textinput=class extends Ni{constructor(e,t,o){super(e,t,o)}initView(){super.initView(),this.fieldGroup_&&G(this.fieldGroup_,"blocklyTextInputField")}doClassValidation_(e){return e===void 0?null:`${e}`}static fromJson(e){return new this(Je(e.text),void 0,e)}},_o("field_input",r.FieldTextInput$$module$build$src$core$field_textinput),r.FieldTextInput$$module$build$src$core$field_textinput.prototype.DEFAULT_VALUE="",r.FieldTextInput$$module$build$src$core$field_textinput;var Jm=class extends sh{constructor(e){super(e)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(e){return!!e.outputConnection}hasRightSquareCorner(e){return!!e.outputConnection&&!e.statementInputCount&&!e.nextConnection}},wl=class extends Tl{constructor(e,t){if(super(e,t),this.connectedBottomNextConnection=!1,this.connectedBlock){for(e=this.connectedBlock;t=e.getNextBlock();)e=t;e.nextConnection||(this.height=this.connectedBlockHeight,this.connectedBottomNextConnection=!0)}}},qm=class extends So{constructor(e){super(e),this.width=this.height=0,this.type|=T.getType("RIGHT_CONNECTION")}},Zm=class extends uh{constructor(e){super(e)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(e){const t=(e.hat?e.hat==="cap":this.constants_.ADD_START_HATS)&&!e.outputConnection&&!e.previousConnection;return!!e.outputConnection||t}hasRightSquareCorner(e){return!!e.outputConnection&&!e.statementInputCount&&!e.nextConnection}},Qm=class extends Sr{constructor(e,t){super(e,t),this.isInline=!0,this.renderer_=e,this.constants_=this.renderer_.getConstants(),this.topRow=new Zm(this.constants_),this.bottomRow=new Jm(this.constants_),this.isMultiRow=!t.getInputsInline()||t.isCollapsed(),this.hasStatementInput=t.statementInputCount>0,this.rightSide=this.outputConnection?new qm(this.constants_):null,this.rightAlignedDummyInputs=new WeakMap}getRenderer(){return this.renderer_}measure(){this.createRows_(),this.addElemSpacing_(),this.addRowSpacing_(),this.adjustXPosition_(),this.computeBounds_(),this.alignRowElements_(),this.finalize_()}shouldStartNewRow_(e,t){return t?t instanceof Yo||e instanceof Yt||t instanceof Yt?!0:e instanceof r.ValueInput$$module$build$src$core$inputs$value_input||e instanceof Io||e instanceof Yo?!this.isInline||this.isMultiRow:!1:!1}getDesiredRowWidth_(e){return e.hasStatement?this.width-this.startX-(this.constants_.INSIDE_CORNERS.rightWidth||0):super.getDesiredRowWidth_(e)}getInRowSpacing_(e,t){return e&&t||!this.outputConnection||!this.outputConnection.isDynamicShape||this.hasStatementInput||this.bottomRow.hasNextConnection?!e&&t&&T.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:e&&T.isLeftRoundedCorner(e)&&t&&(T.isPreviousConnection(t)||T.isNextConnection(t))?t.notchOffset-this.constants_.CORNER_RADIUS:e&&T.isLeftSquareCorner(e)&&t&&T.isHat(t)||e&&T.isField(e)&&e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:this.constants_.NO_PADDING}getSpacerRowHeight_(e,t){if(T.isTopRow(e)&&T.isBottomRow(t))return this.constants_.EMPTY_BLOCK_SPACER_HEIGHT;const o=T.isInputRow(e)&&e.hasStatement,s=T.isInputRow(t)&&t.hasStatement;return s||o?(e=Math.max(this.constants_.NOTCH_HEIGHT,this.constants_.INSIDE_CORNERS.rightHeight||0),s&&o?Math.max(e,this.constants_.DUMMY_INPUT_MIN_HEIGHT):e):T.isTopRow(e)?e.hasPreviousConnection||this.outputConnection&&!this.hasStatementInput?this.constants_.NO_PADDING:Math.abs(this.constants_.NOTCH_HEIGHT-this.constants_.CORNER_RADIUS):T.isBottomRow(t)?this.outputConnection?!t.hasNextConnection&&this.hasStatementInput?Math.abs(this.constants_.NOTCH_HEIGHT-this.constants_.CORNER_RADIUS):this.constants_.NO_PADDING:Math.max(this.topRow.minHeight,Math.max(this.constants_.NOTCH_HEIGHT,this.constants_.CORNER_RADIUS))-this.constants_.CORNER_RADIUS:this.constants_.MEDIUM_PADDING}getSpacerRowWidth_(e,t){const o=this.width-this.startX;return T.isInputRow(e)&&e.hasStatement||T.isInputRow(t)&&t.hasStatement?Math.max(o,this.constants_.STATEMENT_INPUT_SPACER_MIN_WIDTH):o}getElemCenterline_(e,t){if(e.hasStatement&&!T.isSpacer(t)&&!T.isStatementInput(t))return e.yPos+this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT/2;if(T.isInlineInput(t)){const o=t.connectedBlock;if(o&&o.outputConnection&&o.nextConnection)return e.yPos+o.height/2}return super.getElemCenterline_(e,t)}addInput_(e,t){if((e instanceof Io||e instanceof Yo)&&t.hasDummyInput&&t.align===r.Align$$module$build$src$core$inputs$align.LEFT&&e.align===r.Align$$module$build$src$core$inputs$align.RIGHT)this.rightAlignedDummyInputs.set(t,e);else if(e instanceof Yt){t.elements.push(new wl(this.constants_,e)),t.hasStatement=!0,t.align===null&&(t.align=e.align);return}super.addInput_(e,t)}addAlignmentPadding_(e,t){if(this.rightAlignedDummyInputs.get(e)){let o;for(let s=0;s<e.elements.length;s++){const i=e.elements[s];if(T.isSpacer(i)&&(o=i),T.isField(i)&&i.parentInput===this.rightAlignedDummyInputs.get(e))break}if(o){o.width+=t,e.width+=t;return}}super.addAlignmentPadding_(e,t)}adjustXPosition_(){const e=this.constants_.NOTCH_OFFSET_LEFT+this.constants_.NOTCH_WIDTH;let t=e;for(let i=2;i<this.rows.length-1;i+=2){var o=this.rows[i-1];const n=this.rows[i];var s=this.rows[i+1];if(o=i===2?!!this.topRow.hasPreviousConnection:!!o.followsStatement,s=i+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!s.precedesStatement,T.isInputRow(n)&&n.hasStatement){n.measure();let d,f;t=n.width-((f=(d=n.getLastInput())==null?void 0:d.width)!=null?f:0)+e}else if(o&&(i===2||s)&&T.isInputRow(n)&&!n.hasStatement){s=n.xPos,o=null;for(let d=0;d<n.elements.length;d++){const f=n.elements[d];T.isSpacer(f)&&(o=f),!(o&&(T.isField(f)||T.isInput(f))&&s<t)||T.isField(f)&&(f.field instanceof Ps||f.field instanceof Hs)||(o.width+=t-s),s+=f.width}}}}finalizeOutputConnection_(){if(this.outputConnection&&this.outputConnection.isDynamicShape){var e=this.outputConnection.shape;if("isDynamic"in e&&e.isDynamic){for(var t=0,o=0;o<this.rows.length;o++){const s=this.rows[o];s.yPos=t,t+=s.height}this.height=t,o=this.bottomRow.hasNextConnection?this.height-this.bottomRow.descenderHeight:this.height,t=e.height(o),o=e.width(o),this.outputConnection.height=t,this.outputConnection.width=o,this.outputConnection.startX=o,this.outputConnection.connectionOffsetY=e.connectionOffsetY(t),this.outputConnection.connectionOffsetX=e.connectionOffsetX(o),e=0,this.hasStatementInput||this.bottomRow.hasNextConnection||(e=o,this.rightSide.height=t,this.rightSide.width=e,this.rightSide.centerline=t/2,this.rightSide.xPos=this.width+e),this.startX=o,this.width+=o+e,this.widthWithChildren+=o+e}}}finalizeHorizontalAlignment_(){if(this.outputConnection&&!this.hasStatementInput&&!this.bottomRow.hasNextConnection){for(var e=0,t=0;t<this.rows.length;t++){var o=this.rows[t];if(!T.isInputRow(o))continue;e=o.elements[o.elements.length-2];let s=this.getNegativeSpacing_(o.elements[1]),i=this.getNegativeSpacing_(e);e=s+i;const n=this.constants_.MIN_BLOCK_WIDTH+this.outputConnection.width*2;this.width-e<n&&(e=this.width-n,s=e/2,i=e/2),o.elements.unshift(new Xt(this.constants_,-s)),o.elements.push(new Xt(this.constants_,-i))}if(e)for(this.width-=e,this.widthWithChildren-=e,this.rightSide.xPos-=e,t=0;t<this.rows.length;t++)o=this.rows[t],T.isTopOrBottomRow(o)&&(o.elements[1].width-=e),o.width-=e,o.widthWithConnectedBlocks-=e}}getNegativeSpacing_(e){if(!e||!this.outputConnection)return 0;const t=this.outputConnection.width;var o=this.outputConnection.shape.type;const s=this.constants_;if(this.inputRows.length>1)switch(o){case s.SHAPES.ROUND:return o=this.constants_.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,o=this.height/2>o?o:this.height/2,t-o*(1-Math.sin(Math.acos((o-this.constants_.SMALL_PADDING)/o)));default:return 0}if(T.isInlineInput(e)){const i=e.connectedBlock;return e=i?i.pathObject.outputShapeType:e.shape.type,e==null||i&&i.outputConnection&&(i.statementInputCount||i.nextConnection)||o===s.SHAPES.HEXAGONAL&&o!==e?0:t-this.constants_.SHAPE_IN_SHAPE_PADDING[o][e]}return T.isField(e)?o===s.SHAPES.ROUND&&e.field instanceof r.FieldTextInput$$module$build$src$core$field_textinput?t-2.75*s.GRID_UNIT:t-this.constants_.SHAPE_IN_SHAPE_PADDING[o][0]:T.isIcon(e)?this.constants_.SMALL_PADDING:0}finalizeVerticalAlignment_(){if(!this.outputConnection)for(let s=2;s<this.rows.length-1;s+=2){const i=this.rows[s-1],n=this.rows[s],d=this.rows[s+1];var e=s===2,t=s+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!d.precedesStatement;if(e?this.topRow.hasPreviousConnection:i.followsStatement){var o=n.elements[1];if(o=n.elements.length===3&&o instanceof rh&&(o.field instanceof Ps||o.field instanceof Hs),!e&&o)i.height-=this.constants_.SMALL_PADDING,d.height-=this.constants_.SMALL_PADDING,n.height-=this.constants_.MEDIUM_PADDING;else if(!e&&!t)i.height+=this.constants_.SMALL_PADDING;else if(t){for(e=!1,t=0;t<n.elements.length;t++)if(o=n.elements[t],T.isInlineInput(o)&&o.connectedBlock&&!o.connectedBlock.isShadow()&&o.connectedBlock.getHeightWidth().height>=40){e=!0;break}e&&(i.height-=this.constants_.SMALL_PADDING,d.height-=this.constants_.SMALL_PADDING)}}}}finalize_(){this.finalizeOutputConnection_(),this.finalizeHorizontalAlignment_(),this.finalizeVerticalAlignment_(),super.finalize_(),this.rightSide&&(this.widthWithChildren+=this.rightSide.width)}},ef=class extends vl{constructor(e,t,o){super(e,t,o),this.svgPathSelected=null,this.outlines=new Map,this.remainingOutlines=new Set,this.outputShapeType=null,this.constants=o}setPath(e){super.setPath(e),this.svgPathSelected&&this.svgPathSelected.setAttribute("d",e)}applyColour(e){super.applyColour(e);const t=e.getParent();e.isShadow()&&t&&this.svgPath.setAttribute("stroke",t.getColourTertiary());for(const o of this.outlines.values())o.setAttribute("fill",this.style.colourTertiary)}flipRTL(){super.flipRTL();for(const e of this.outlines.values())e.setAttribute("transform","scale(-1 1)")}updateSelected(e){this.setClass_("blocklySelected",e),e?this.svgPathSelected||(this.svgPathSelected=this.svgPath.cloneNode(!0),this.svgPathSelected.classList.add("blocklyPathSelected"),Te(this.svgPathSelected,Et.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),Te(this.svgPathSelected,Et.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME),this.svgPathSelected.removeAttribute("tabindex"),this.svgPathSelected.removeAttribute("id"),this.svgRoot.appendChild(this.svgPathSelected)):this.svgPathSelected&&(this.svgRoot.removeChild(this.svgPathSelected),this.svgPathSelected=null)}updateReplacementFade(e){this.setClass_("blocklyReplaceable",e)}updateShapeForInputHighlight(e,t){e=e.getParentInput().name,(e=this.getOutlinePath(e))&&(t?e.setAttribute("filter","url(#"+this.constants.replacementGlowFilterId+")"):e.removeAttribute("filter"))}beginDrawing(){this.remainingOutlines.clear();for(const e of this.outlines.keys())this.remainingOutlines.add(e)}endDrawing(){if(this.remainingOutlines.size)for(const e of this.remainingOutlines)this.removeOutlinePath(e);this.remainingOutlines.clear()}setOutlinePath(e,t){e=this.getOutlinePath(e),e.setAttribute("d",t),e.setAttribute("fill",this.style.colourTertiary)}getOutlinePath(e){return this.outlines.has(e)||this.outlines.set(e,v(R.PATH,{class:"blocklyOutlinePath",d:""},this.svgRoot)),this.remainingOutlines.delete(e),this.outlines.get(e)}removeOutlinePath(e){let t,o;(t=this.outlines.get(e))==null||(o=t.parentNode)==null||o.removeChild(this.outlines.get(e)),this.outlines.delete(e)}},bh=class extends Il{constructor(e){super(e)}makeConstants_(){return new jm}makeRenderInfo_(e){return new Qm(this,e)}makeDrawer_(e,t){return new Km(e,t)}makePathObject(e,t){return new ef(e,t,this.getConstants())}getConstants(){return this.constants_}};Qi("zelos",bh);var tf=class{constructor(e){this.staticConn=this.draggedConn=this.markerConn=this.fadedBlock=null,this.workspace=e.workspace}previewReplacement(e,t,o){r.disable$$module$build$src$core$events$utils();try{this.hidePreview(),this.fadedBlock=o,o.fadeForReplacement(!0),this.workspace.getRenderer().shouldHighlightConnection(t)&&(t.highlight(),this.staticConn=t)}finally{r.enable$$module$build$src$core$events$utils()}}previewConnection(e,t){if(e!==this.draggedConn||t!==this.staticConn){r.disable$$module$build$src$core$events$utils();try{this.hidePreview(),this.shouldUseMarkerPreview(e,t)&&(this.markerConn=this.previewMarker(e,t)),this.workspace.getRenderer().shouldHighlightConnection(t)&&t.highlight(),this.draggedConn=e,this.staticConn=t}finally{r.enable$$module$build$src$core$events$utils()}}}shouldUseMarkerPreview(e,t){return t.type===Z.PREVIOUS_STATEMENT||t.type===Z.NEXT_STATEMENT||!(this.workspace.getRenderer()instanceof bh)}previewMarker(e,t){const o=e.getSourceBlock(),s=this.createInsertionMarker(o),i=this.getMatchingConnection(o,s,e);if(!i)return null;s.queueRender(),Qo(),i.connect(t);const n={x:t.x-i.x,y:t.y-i.y},d=i.getOffsetInBlock().clone();return go().then(()=>{if(!s.isDeadOrDying()){r.disable$$module$build$src$core$events$utils();try{s?.positionNearConnection(i,n,d),s?.getSvgRoot().setAttribute("visibility","visible")}finally{r.enable$$module$build$src$core$events$utils()}}}),i}createInsertionMarker(e){const t=jt(e,{addCoordinates:!1,addInputBlocks:!1,addNextBlocks:!1,doFullSerialization:!1});if(!t)throw Error(`Failed to serialize source block. ${e.toDevString()}`);e=es(t,this.workspace);for(const o of e.getDescendants(!1))o.setInsertionMarker(!0);return e.initSvg(),e.getSvgRoot().setAttribute("visibility","hidden"),e}getMatchingConnection(e,t,o){if(e=e.getConnections_(!0),t=t.getConnections_(!0),e.length!==t.length)return null;for(let s=0;s<e.length;s++)if(e[s]===o)return t[s];return null}hidePreview(){r.disable$$module$build$src$core$events$utils();try{this.staticConn&&(this.staticConn.unhighlight(),this.staticConn=null),this.fadedBlock&&(this.fadedBlock.fadeForReplacement(!1),this.fadedBlock=null),this.markerConn&&(this.hideInsertionMarker(this.markerConn),this.draggedConn=this.markerConn=null)}finally{r.enable$$module$build$src$core$events$utils()}}hideInsertionMarker(e){const t=e.getSourceBlock(),o=t.outputConnection;let s;if((s=t.previousConnection)!=null&&s.targetConnection||o!=null&&o.targetConnection)t.unplug(!0);else{let i;(i=e.targetBlock())==null||i.unplug(!1)}t.dispose()}dispose(){this.hidePreview()}};l(M.CONNECTION_PREVIEWER,Ft,tf);var $s={};$s.Align=r.Align$$module$build$src$core$inputs$align,$s.DummyInput=Io,$s.EndRowInput=Yo,$s.Input=vi,$s.StatementInput=Yt,$s.ValueInput=r.ValueInput$$module$build$src$core$inputs$value_input,$s.inputTypes=r.inputTypes$$module$build$src$core$inputs$input_types;var of=!1,sf;r.CodeGenerator$$module$build$src$core$generator=class{constructor(e){this.forBlock=Object.create(null),this.FUNCTION_NAME_PLACEHOLDER_="{leCUI8hutHZI4480Dc}",this.STATEMENT_SUFFIX=this.STATEMENT_PREFIX=this.INFINITE_LOOP_TRAP=null,this.INDENT=" ",this.COMMENT_WRAP=60,this.ORDER_OVERRIDES=[],this.isInitialized=null,this.RESERVED_WORDS_="",this.definitions_=Object.create(null),this.functionNames_=Object.create(null),this.nameDB_=void 0,this.name_=e,this.FUNCTION_NAME_PLACEHOLDER_REGEXP_=new RegExp(this.FUNCTION_NAME_PLACEHOLDER_,"g")}workspaceToCode(e){e||(console.warn("No workspace specified in workspaceToCode call. Guessing."),e=c());var t=[];this.init(e),e=e.getTopBlocks(!0);for(let o=0,s;s=e[o];o++){let i=this.blockToCode(s);Array.isArray(i)&&(i=i[0]),i&&(s.outputConnection&&(i=this.scrubNakedValue(i),this.STATEMENT_PREFIX&&!s.suppressPrefixSuffix&&(i=this.injectId(this.STATEMENT_PREFIX,s)+i),this.STATEMENT_SUFFIX&&!s.suppressPrefixSuffix&&(i+=this.injectId(this.STATEMENT_SUFFIX,s))),t.push(i))}return t=t.join(`
662
662
  `),t=this.finish(t),t=t.replace(/^\s+\n/,""),t=t.replace(/\n\s+$/,`
663
663
  `),t=t.replace(/[ \t]+\n/g,`
664
664
  `)}prefixLines(e,t){return t+e.replace(/(?!\n$)\n/g,`
665
665
  `+t)}allNestedComments(e){const t=[];e=e.getDescendants(!0);for(let o=0;o<e.length;o++){const s=e[o].getCommentText();s&&t.push(s)}return t.length&&t.push(""),t.join(`
666
666
  `)}blockToCode(e,t){if(this.isInitialized===!1&&console.warn("CodeGenerator init was not called before blockToCode was called."),!e)return"";if(!e.isEnabled())return t?"":this.blockToCode(e.getNextBlock());if(e.isInsertionMarker())return t?"":this.blockToCode(e.getChildren(!1)[0]);var o=this.forBlock[e.type];if(typeof o!="function")throw Error(`${this.name_} generator does not know how to generate code for block type "${e.type}".`);if(o=o.call(e,e,this),Array.isArray(o)){if(!e.outputConnection)throw TypeError("Expecting string from statement block: "+e.type);return[this.scrub_(e,o[0],t),o[1]]}if(typeof o=="string")return this.STATEMENT_PREFIX&&!e.suppressPrefixSuffix&&(o=this.injectId(this.STATEMENT_PREFIX,e)+o),this.STATEMENT_SUFFIX&&!e.suppressPrefixSuffix&&(o+=this.injectId(this.STATEMENT_SUFFIX,e)),this.scrub_(e,o,t);if(o===null)return"";throw SyntaxError("Invalid code generated: "+o)}valueToCode(e,t,o){if(isNaN(o))throw TypeError("Expecting valid order from block: "+e.type);var s=e.getInputTargetBlock(t);if(!s&&!e.getInput(t))throw ReferenceError(`Input "${t}" doesn't exist on "${e.type}"`);if(!s||(t=this.blockToCode(s),t===""))return"";if(!Array.isArray(t))throw TypeError(`Expecting tuple from value block: ${s.type} See developers.google.com/blockly/guides/create-custom-blocks/generating-code for more information`);if(e=t[0],t=t[1],isNaN(t))throw TypeError("Expecting valid order from value block: "+s.type);if(!e)return"";s=!1;var i=Math.floor(o);const n=Math.floor(t);if(i<=n&&(i!==n||i!==0&&i!==99)){for(s=!0,i=0;i<this.ORDER_OVERRIDES.length;i++)if(this.ORDER_OVERRIDES[i][0]===o&&this.ORDER_OVERRIDES[i][1]===t){s=!1;break}}return s&&(e="("+e+")"),e}statementToCode(e,t){const o=e.getInputTargetBlock(t);if(!o&&!e.getInput(t))throw ReferenceError(`Input "${t}" doesn't exist on "${e.type}"`);if(e=this.blockToCode(o),typeof e!="string")throw TypeError("Expecting code from statement block: "+(o&&o.type));return e&&(e=this.prefixLines(e,this.INDENT)),e}addLoopTrap(e,t){return this.INFINITE_LOOP_TRAP&&(e=this.prefixLines(this.injectId(this.INFINITE_LOOP_TRAP,t),this.INDENT)+e),this.STATEMENT_SUFFIX&&!t.suppressPrefixSuffix&&(e=this.prefixLines(this.injectId(this.STATEMENT_SUFFIX,t),this.INDENT)+e),this.STATEMENT_PREFIX&&!t.suppressPrefixSuffix&&(e+=this.prefixLines(this.injectId(this.STATEMENT_PREFIX,t),this.INDENT)),e}injectId(e,t){return t=t.id.replace(/\$/g,"$$$$"),e.replace(/%1/g,"'"+t+"'")}addReservedWords(e){this.RESERVED_WORDS_+=e+","}provideFunction_(e,t){if(!this.definitions_[e]){const o=this.nameDB_.getDistinctName(e,r.NameType$$module$build$src$core$names.PROCEDURE);this.functionNames_[e]=o,Array.isArray(t)&&(t=t.join(`
667
- `)),t=t.trim().replace(this.FUNCTION_NAME_PLACEHOLDER_REGEXP_,o);let s;for(;s!==t;)s=t,t=t.replace(/^(( {2})*) {2}/gm,"$1\0");t=t.replace(/\0/g,this.INDENT),this.definitions_[e]=t}return this.functionNames_[e]}getVariableName(e){return this.getName(e,r.NameType$$module$build$src$core$names.VARIABLE)}getProcedureName(e){return this.getName(e,r.NameType$$module$build$src$core$names.PROCEDURE)}getName(e,t){if(!this.nameDB_)throw Error("Name database is not defined. You must initialize `nameDB_` in your generator class and call `init` first.");return this.nameDB_.getName(e,t)}init(e){this.definitions_=Object.create(null),this.functionNames_=Object.create(null)}scrub_(e,t,o){return t}finish(e){return this.definitions_=Object.create(null),this.functionNames_=Object.create(null),e}scrubNakedValue(e){return e}},ef={},ef.CodeGenerator=r.CodeGenerator$$module$build$src$core$generator;var _h=class extends pl{constructor(e){super(e)}setMetrics_(e){if(this.isVisible()){var t=this.workspace_.getMetricsManager(),o=t.getScrollMetrics(),s=t.getViewMetrics();t=t.getAbsoluteMetrics(),typeof e.y=="number"&&(this.workspace_.scrollY=-(o.top+(o.height-s.height)*e.y)),this.workspace_.translate(this.workspace_.scrollX+t.left,this.workspace_.scrollY+t.top)}}getX(){if(!this.isVisible())return 0;var e=this.targetWorkspace.getMetricsManager();const t=e.getAbsoluteMetrics(),o=e.getViewMetrics();return e=e.getToolboxMetrics(),this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?this.toolboxPosition_===be.LEFT?e.width:o.width-this.getWidth():this.toolboxPosition_===be.LEFT?0:o.width:this.toolboxPosition_===be.LEFT?0:o.width+t.left-this.getWidth()}getY(){return 0}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var e=this.targetWorkspace.getMetricsManager().getViewMetrics();this.height_=e.height;var t=this.getWidth()-this.CORNER_RADIUS;this.setBackgroundPath(t,e.height-2*this.CORNER_RADIUS),e=this.getX(),t=this.getY(),this.positionAt_(this.getWidth(),this.getHeight(),e,t)}}setBackgroundPath(e,t){const o=this.toolboxPosition_===be.RIGHT;var s=e+this.CORNER_RADIUS;s=["M "+(o?s:0)+",0"],s.push("h",o?-e:e),s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,o?0:1,o?-this.CORNER_RADIUS:this.CORNER_RADIUS,this.CORNER_RADIUS),s.push("v",Math.max(0,t)),s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,o?0:1,o?this.CORNER_RADIUS:-this.CORNER_RADIUS,this.CORNER_RADIUS),s.push("h",o?e:-e),s.push("z"),this.svgBackground_.setAttribute("d",s.join(" "))}scrollToStart(){let e;(e=this.workspace_.scrollbar)==null||e.setY(0)}wheel_(e){var t=It(e);if(t.y){const o=this.workspace_.getMetricsManager(),s=o.getScrollMetrics();t=o.getViewMetrics().top-s.top+t.y;let i;(i=this.workspace_.scrollbar)==null||i.setY(t),Xi(this.workspace_),mo()}e.preventDefault(),e.stopPropagation()}layout_(e){this.workspace_.scale=this.targetWorkspace.scale;var t=this.MARGIN;const o=this.RTL?t:t+this.tabWidth_;for(const s of e)s.getElement().moveBy(o,t),t+=s.getElement().getBoundingRectangle().getHeight()}isDragTowardWorkspace(e){e=Math.atan2(e.y,e.x)/Math.PI*180;const t=this.dragAngleRange_;return e<t&&e>-t||e<-180+t||e>180-t}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;const e=this.svgGroup_.getBoundingClientRect(),t=e.left;return this.toolboxPosition_===be.LEFT?new ye(-1e9,1e9,-1e9,t+e.width):new ye(-1e9,1e9,t,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let e=this.getContents().reduce((t,o)=>Math.max(t,o.getElement().getBoundingRectangle().getWidth()),0);if(e+=this.MARGIN*1.5+this.tabWidth_,e*=this.workspace_.scale,e+=Ze.scrollbarThickness,this.getWidth()!==e){if(this.RTL)for(const t of this.getContents()){const o=t.getElement().getBoundingRectangle().left,s=e/this.workspace_.scale-t.getElement().getBoundingRectangle().getWidth()-this.MARGIN-this.tabWidth_;t.getElement().moveBy(s-o,0)}this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==be.LEFT||this.targetWorkspace.translate(this.targetWorkspace.scrollX+e,this.targetWorkspace.scrollY),this.width_=e,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets()}}};_h.registryName="verticalFlyout",l(M.FLYOUTS_VERTICAL_TOOLBOX,Ft,_h);var tf=class extends pl{constructor(e){super(e),this.horizontalLayout=!0}setMetrics_(e){if(this.isVisible()){var t=this.workspace_.getMetricsManager(),o=t.getScrollMetrics(),s=t.getViewMetrics();t=t.getAbsoluteMetrics(),typeof e.x=="number"&&(this.workspace_.scrollX=-(o.left+(o.width-s.width)*e.x)),this.workspace_.translate(this.workspace_.scrollX+t.left,this.workspace_.scrollY+t.top)}}getX(){return 0}getY(){if(!this.isVisible())return 0;var e=this.targetWorkspace.getMetricsManager();const t=e.getAbsoluteMetrics(),o=e.getViewMetrics();e=e.getToolboxMetrics();const s=this.toolboxPosition_===be.TOP;return this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?s?e.height:o.height-this.getHeight():s?0:o.height:s?0:o.height+t.top-this.getHeight()}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var e=this.targetWorkspace.getMetricsManager().getViewMetrics();this.width_=e.width,e=e.width-2*this.CORNER_RADIUS;var t=this.getHeight()-this.CORNER_RADIUS;this.setBackgroundPath(e,t),e=this.getX(),t=this.getY(),this.positionAt_(this.getWidth(),this.getHeight(),e,t)}}setBackgroundPath(e,t){const o=this.toolboxPosition_===be.TOP,s=["M 0,"+(o?0:this.CORNER_RADIUS)];o?(s.push("h",e+2*this.CORNER_RADIUS),s.push("v",t),s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,-this.CORNER_RADIUS,this.CORNER_RADIUS),s.push("h",-e),s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,-this.CORNER_RADIUS,-this.CORNER_RADIUS)):(s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,this.CORNER_RADIUS,-this.CORNER_RADIUS),s.push("h",e),s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,this.CORNER_RADIUS,this.CORNER_RADIUS),s.push("v",t),s.push("h",-e-2*this.CORNER_RADIUS)),s.push("z"),this.svgBackground_.setAttribute("d",s.join(" "))}scrollToStart(){let e;(e=this.workspace_.scrollbar)==null||e.setX(this.RTL?1/0:0)}wheel_(e){var t=It(e);if(t=t.x||t.y){const o=this.workspace_.getMetricsManager(),s=o.getScrollMetrics();t=o.getViewMetrics().left-s.left+t;let i;(i=this.workspace_.scrollbar)==null||i.setX(t),Xi(this.workspace_),mo()}e.preventDefault(),e.stopPropagation()}layout_(e){this.workspace_.scale=this.targetWorkspace.scale;const t=this.MARGIN;let o=t+this.tabWidth_;this.RTL&&(e=e.reverse());for(const s of e)e=s.getElement().getBoundingRectangle(),e=this.RTL?o+e.getWidth():o,s.getElement().moveBy(e,t),o+=s.getElement().getBoundingRectangle().getWidth()}isDragTowardWorkspace(e){e=Math.atan2(e.y,e.x)/Math.PI*180;const t=this.dragAngleRange_;return e<90+t&&e>90-t||e>-90-t&&e<-90+t}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;const e=this.svgGroup_.getBoundingClientRect(),t=e.top;return this.toolboxPosition_===be.TOP?new ye(-1e9,t+e.height,-1e9,1e9):new ye(t,1e9,-1e9,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let e=this.getContents().reduce((t,o)=>Math.max(t,o.getElement().getBoundingRectangle().getHeight()),0);e+=this.MARGIN*1.5,e*=this.workspace_.scale,e+=Ze.scrollbarThickness,this.getHeight()!==e&&(this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==be.TOP||this.targetWorkspace.translate(this.targetWorkspace.scrollX,this.targetWorkspace.scrollY+e),this.height_=e,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets())}};l(M.FLYOUTS_HORIZONTAL_TOOLBOX,Ft,tf);var Rr=class extends yt{constructor(e,t,o,s,i){super(we.SKIP_SETUP),this.defaultType="",this.variableTypes=[],this.variable=null,this.SERIALIZABLE=!0,this.menuGenerator_=Rr.dropdownCreate,this.defaultVariableName=typeof e=="string"?e:"",this.size_=new ve(0,0),e!==we.SKIP_SETUP&&(i?this.configure_(i):this.setTypes(o,s),t&&this.setValidator(t))}configure_(e){super.configure_(e),this.setTypes(e.variableTypes,e.defaultType)}initModel(){var e=this.getSourceBlock();if(!e)throw new tt;this.variable||(e=r.getOrCreateVariablePackage$$module$build$src$core$variables(e.workspace,null,this.defaultVariableName,this.defaultType),this.doValueUpdate_(e.getId()))}initView(){super.initView(),G(this.fieldGroup_,"blocklyVariableField")}shouldAddBorderRect_(){const e=this.getSourceBlock();if(!e)throw new tt;return super.shouldAddBorderRect_()&&(!this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW||e.type!=="variables_get")}fromXml(e){var t=this.getSourceBlock();if(!t)throw new tt;const o=e.getAttribute("id"),s=e.textContent,i=e.getAttribute("variabletype")||e.getAttribute("variableType")||"";if(t=r.getOrCreateVariablePackage$$module$build$src$core$variables(t.workspace,o,s,i),i!==null&&i!==t.getType())throw Error("Serialized variable type with id '"+t.getId()+"' had type "+t.getType()+", and does not match variable field that references it: "+fo(e)+".");this.setValue(t.getId())}toXml(e){return this.initModel(),e.id=this.variable.getId(),e.textContent=this.variable.getName(),this.variable.getType()&&e.setAttribute("variabletype",this.variable.getType()),e}saveState(e){var t=this.saveLegacyState(Rr);return t!==null||(this.initModel(),t={id:this.variable.getId()},e&&(t.name=this.variable.getName(),t.type=this.variable.getType())),t}loadState(e){const t=this.getSourceBlock();if(!t)throw new tt;this.loadLegacyState(Rr,e)||(e=r.getOrCreateVariablePackage$$module$build$src$core$variables(t.workspace,e.id||null,e.name,e.type||""),this.setValue(e.getId()))}setSourceBlock(e){if(e.isShadow())throw Error("Variable fields are not allowed to exist on shadow blocks.");super.setSourceBlock(e)}getValue(){return this.variable?this.variable.getId():null}getText(){return this.variable?this.variable.getName():""}getVariable(){return this.variable}getDefaultType(){return this.defaultType}getValidator(){return this.variable?this.validator_:null}doClassValidation_(e){if(e===null)return null;var t=this.getSourceBlock();if(!t)throw new tt;return t=r.getVariable$$module$build$src$core$variables(t.workspace,e),t?(t=t.getType(),this.typeIsAllowed(t)?e:(console.warn("Variable type doesn't match this field! Type was "+t),null)):(console.warn("Variable id doesn't point to a real variable! ID was "+e),null)}doValueUpdate_(e){const t=this.getSourceBlock();if(!t)throw new tt;this.variable=r.getVariable$$module$build$src$core$variables(t.workspace,e),super.doValueUpdate_(e)}typeIsAllowed(e){const t=this.getVariableTypes();if(!t)return!0;for(let o=0;o<t.length;o++)if(e===t[o])return!0;return!1}getVariableTypes(){if(this.variableTypes)return this.variableTypes;if(!this.sourceBlock_||this.sourceBlock_.isDeadOrDying())return[""];let e=this.sourceBlock_.workspace.getVariableMap().getTypes();if(this.sourceBlock_.isInFlyout){const t=this.sourceBlock_.workspace.getPotentialVariableMap();if(!t)return e;e=Array.from(new Set([...e,...t.getTypes()]))}return e}setTypes(e=null,t=""){var o=this.getText();if(Array.isArray(e)){if(e.length===0)throw Error(`'variableTypes' of field variable ${o} was an empty list. If you want to include all variable types, pass 'null' instead.`);o=!1;for(let s=0;s<e.length;s++)e[s]===t&&(o=!0);if(!o)throw Error("Invalid default type '"+t+"' in the definition of a FieldVariable")}else if(e!==null)throw Error(`'variableTypes' was not an array or null in the definition of FieldVariable ${o}`);this.defaultType=t,this.variableTypes=e}refreshVariableName(){this.forceRerender()}onItemSelected_(e,t){if(e=t.getValue(),this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()){if(e===Va&&this.variable){r.renameVariable$$module$build$src$core$variables(this.sourceBlock_.workspace,this.variable);return}if(e===Wa&&this.variable){e=this.variable.getWorkspace(),r.deleteVariable$$module$build$src$core$variables(e,this.variable,this.sourceBlock_);return}}this.setValue(e)}referencesVariables(){return!0}static fromJson(e){return new this(Je(e.variable),void 0,void 0,void 0,e)}static dropdownCreate(){if(!this.variable)throw Error("Tried to call dropdownCreate on a variable field with no variable selected.");const e=this.getText();let t=[];var o=this.getSourceBlock();if(o&&!o.isDeadOrDying()){o=o.workspace;const n=this.getVariableTypes();for(let d=0;d<n.length;d++){const f=n[d],L=o.getVariableMap().getVariablesOfType(f);if(t=t.concat(L),o.isFlyout){var s=void 0,i=void 0;t=t.concat((i=(s=o.getPotentialVariableMap())==null?void 0:s.getVariablesOfType(f))!=null?i:[])}}}for(t.sort(Js),s=[],i=0;i<t.length;i++)s[i]=[t[i].getName(),t[i].getId()];return s.push([r.Msg$$module$build$src$core$msg.RENAME_VARIABLE,Va]),r.Msg$$module$build$src$core$msg.DELETE_VARIABLE&&s.push([r.Msg$$module$build$src$core$msg.DELETE_VARIABLE.replace("%1",e),Wa]),s}};_o("field_variable",Rr);var bh=class extends Ni{constructor(e,t,o,s,i,n){super(we.SKIP_SETUP),this.min_=-1/0,this.max_=1/0,this.precision_=0,this.decimalPlaces=null,this.spellcheck_=!1,e!==we.SKIP_SETUP&&(n?this.configure_(n):this.setConstraints(t,o,s),this.setValue(e),i&&this.setValidator(i))}configure_(e){super.configure_(e),this.setMinInternal(e.min),this.setMaxInternal(e.max),this.setPrecisionInternal(e.precision)}setConstraints(e,t,o){this.setMinInternal(e),this.setMaxInternal(t),this.setPrecisionInternal(o),this.setValue(this.getValue())}setMin(e){this.setMinInternal(e),this.setValue(this.getValue())}setMinInternal(e){e==null?this.min_=-1/0:(e=Number(e),isNaN(e)||(this.min_=e))}getMin(){return this.min_}setMax(e){this.setMaxInternal(e),this.setValue(this.getValue())}setMaxInternal(e){e==null?this.max_=1/0:(e=Number(e),isNaN(e)||(this.max_=e))}getMax(){return this.max_}setPrecision(e){this.setPrecisionInternal(e),this.setValue(this.getValue())}setPrecisionInternal(e){this.precision_=Number(e)||0;let t=String(this.precision_);t.includes("e")&&(t=this.precision_.toLocaleString("en-US",{maximumFractionDigits:20}));const o=t.indexOf(".");this.decimalPlaces=o===-1?e?0:null:t.length-o-1}getPrecision(){return this.precision_}doClassValidation_(e){return e===null||(e=`${e}`.replace(/O/gi,"0"),e=e.replace(/,/g,""),e=e.replace(/infinity/i,"Infinity"),e=Number(e||0),isNaN(e))?null:(e=Math.min(Math.max(e,this.min_),this.max_),this.precision_&&isFinite(e)&&(e=Math.round(e/this.precision_)*this.precision_),this.decimalPlaces!==null&&(e=Number(e.toFixed(this.decimalPlaces))),e)}widgetCreate_(){const e=super.widgetCreate_();return this.min_>-1/0&&(e.min=`${this.min_}`,it(e,Qe.VALUEMIN,this.min_)),this.max_<1/0&&(e.max=`${this.max_}`,it(e,Qe.VALUEMAX,this.max_)),e}initView(){super.initView(),this.fieldGroup_&&G(this.fieldGroup_,"blocklyNumberField")}static fromJson(e){return new this(e.value,void 0,void 0,void 0,void 0,e)}};_o("field_number",bh),bh.prototype.DEFAULT_VALUE=0;var of=class extends Ps{constructor(e,t,o){super(String(e??""),t,o),this.EDITABLE=!1,this.SERIALIZABLE=!0}static fromJson(e){return new this(Je(e.text),void 0,e)}};_o("field_label_serializable",of);var Gs=class extends we{constructor(e,t,o){super(we.SKIP_SETUP),this.SERIALIZABLE=!0,this.value_=this.value_,this.checkChar=Gs.CHECK_CHAR,e!==we.SKIP_SETUP&&(o&&this.configure_(o),this.setValue(e),t&&this.setValidator(t))}configure_(e){super.configure_(e),e.checkCharacter&&(this.checkChar=e.checkCharacter)}saveState(){const e=this.saveLegacyState(Gs);return e!==null?e:this.getValueBoolean()}initView(){super.initView();const e=this.getTextElement();G(this.fieldGroup_,"blocklyCheckboxField"),e.style.display=this.value_?"block":"none"}render_(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_()),this.updateSize_(this.getConstants().FIELD_CHECKBOX_X_OFFSET)}getDisplayText_(){return this.checkChar}setCheckCharacter(e){this.checkChar=e||Gs.CHECK_CHAR,this.forceRerender()}showEditor_(){this.setValue(!this.value_)}doClassValidation_(e){return e===!0||e==="TRUE"?"TRUE":e===!1||e==="FALSE"?"FALSE":null}doValueUpdate_(e){this.value_=this.convertValueToBool(e),this.textElement_&&(this.textElement_.style.display=this.value_?"block":"none")}getValue(){return this.value_?"TRUE":"FALSE"}getValueBoolean(){return this.value_}getText(){return String(this.convertValueToBool(this.value_))}convertValueToBool(e){return typeof e=="string"?e==="TRUE":!!e}static fromJson(e){return new this(e.checked,void 0,e)}};Gs.CHECK_CHAR="✓",_o("field_checkbox",Gs),Gs.prototype.DEFAULT_VALUE=!1;var sf=class{constructor(e,t){this.draggable=e,this.workspace=t,this.dragTarget=null,this.startLoc=e.getRelativeToSurfaceXY()}onDragStart(e){r.getGroup$$module$build$src$core$events$utils()||r.setGroup$$module$build$src$core$events$utils(!0),this.draggable.startDrag(e)}onDrag(e,t){this.moveDraggable(e,t),t=this.getRoot(this.draggable),Kt(t)&&t.setDeleteStyle(this.wouldDeleteDraggable(e,t)),this.updateDragTarget(e)}updateDragTarget(e){e=this.workspace.getDragTarget(e);const t=this.getRoot(this.draggable);if(this.dragTarget!==e){let o;(o=this.dragTarget)==null||o.onDragExit(t),e?.onDragEnter(t)}e?.onDragOver(t),this.dragTarget=e}moveDraggable(e,t){t=this.pixelsToWorkspaceUnits(t),t=P.sum(this.startLoc,t),this.draggable.drag(t,e)}wouldDeleteDraggable(e,t){return(e=this.workspace.getDragTarget(e))&&this.workspace.getComponentManager().hasCapability(e.id,Ve.Capability.DELETE_AREA)?e.wouldDelete(t):!1}onDragEnd(e){const t=r.getGroup$$module$build$src$core$events$utils();var o=this.workspace.getDragTarget(e);const s=this.getRoot(this.draggable);if(o){let i;(i=this.dragTarget)==null||i.onDrop(s)}this.shouldReturnToStart(e,s)&&this.draggable.revertDrag(),(o=Kt(s)&&this.wouldDeleteDraggable(e,s))&&this.draggable instanceof Be&&_n(this.draggable.getRootBlock()),this.draggable.endDrag(e),o&&Kt(s)&&(r.setGroup$$module$build$src$core$events$utils(t),s.dispose()),r.setGroup$$module$build$src$core$events$utils(!1),!o&&oo(this.draggable)&&r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.draggable)}getRoot(e){return e instanceof Be?e.getRootBlock():e}shouldReturnToStart(e,t){return(e=this.workspace.getDragTarget(e))?e.shouldPreventMove(t):!1}pixelsToWorkspaceUnits(e){return e=new P(e.x/this.workspace.scale,e.y/this.workspace.scale),this.workspace.isMutator&&e.scale(1/this.workspace.options.parentWorkspace.scale),e}};l(M.BLOCK_DRAGGER,Ft,sf);var wr={};wr.BlockDragStrategy=cm,wr.BubbleDragStrategy=om,wr.CommentDragStrategy=jg,wr.Dragger=sf;var Th=class extends Eo{constructor(e,t,o){super(e?e.workspace.id:void 0),this.type=w.BLOCK_DRAG,e&&(this.blockId=e.id,this.isStart=t,this.blocks=o)}toJson(){const e=super.toJson();if(this.isStart===void 0)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");if(this.blockId===void 0)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");return e.isStart=this.isStart,e.blockId=this.blockId,e.blocks=this.blocks,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Th),t.isStart=e.isStart,t.blockId=e.blockId,t.blocks=e.blocks,t}};l(M.EVENT,w.BLOCK_DRAG,Th);var Eh=class extends Ns{constructor(e,t,o,s){super(e),this.type=w.BLOCK_FIELD_INTERMEDIATE_CHANGE,this.recordUndo=!1,e&&(this.name=t,this.oldValue=o,this.newValue=s)}toJson(){const e=super.toJson();if(!this.name)throw Error("The changed field name is undefined. Either pass a name to the constructor, or call fromJson.");return e.name=this.name,e.oldValue=this.oldValue,e.newValue=this.newValue,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Eh),t.name=e.name,t.oldValue=e.oldValue,t.newValue=e.newValue,t}isNull(){return this.oldValue===this.newValue}run(e){var t=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");if(t=t.getBlockById(this.blockId),!t)throw Error("The associated block is undefined. Either pass a block to the constructor, or call fromJson");e=e?this.newValue:this.oldValue,(t=t.getField(this.name))?t.setValue(e):console.warn("Can't set non-existent field: "+this.name)}};l(M.EVENT,w.BLOCK_FIELD_INTERMEDIATE_CHANGE,Eh);var yh=class extends Ns{constructor(e){super(e),this.type=w.BLOCK_MOVE,e&&(e.isShadow()&&(this.recordUndo=!1),e=this.currentLocation(),this.oldParentId=e.parentId,this.oldInputName=e.inputName,this.oldCoordinate=e.coordinate)}toJson(){const e=super.toJson();return e.oldParentId=this.oldParentId,e.oldInputName=this.oldInputName,this.oldCoordinate&&(e.oldCoordinate=`${Math.round(this.oldCoordinate.x)}, ${Math.round(this.oldCoordinate.y)}`),e.newParentId=this.newParentId,e.newInputName=this.newInputName,this.newCoordinate&&(e.newCoordinate=`${Math.round(this.newCoordinate.x)}, ${Math.round(this.newCoordinate.y)}`),this.reason&&(e.reason=this.reason),this.recordUndo||(e.recordUndo=this.recordUndo),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new yh),t.oldParentId=e.oldParentId,t.oldInputName=e.oldInputName,e.oldCoordinate&&(o=e.oldCoordinate.split(","),t.oldCoordinate=new P(Number(o[0]),Number(o[1]))),t.newParentId=e.newParentId,t.newInputName=e.newInputName,e.newCoordinate&&(o=e.newCoordinate.split(","),t.newCoordinate=new P(Number(o[0]),Number(o[1]))),e.reason!==void 0&&(t.reason=e.reason),e.recordUndo!==void 0&&(t.recordUndo=e.recordUndo),t}recordNew(){const e=this.currentLocation();this.newParentId=e.parentId,this.newInputName=e.inputName,this.newCoordinate=e.coordinate}setReason(e){this.reason=e}currentLocation(){var e=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");var t=e.getBlockById(this.blockId);if(!t)throw Error("The block associated with the block move event could not be found");e={};const o=t.getParent();return o?(e.parentId=o.id,(t=o.getInputWithBlock(t))&&(e.inputName=t.name)):e.coordinate=t.getRelativeToSurfaceXY(),e}isNull(){return this.oldParentId===this.newParentId&&this.oldInputName===this.newInputName&&P.equals(this.oldCoordinate,this.newCoordinate)}run(e){var t=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");var o=t.getBlockById(this.blockId);if(o){var s=e?this.newParentId:this.oldParentId,i=e?this.newInputName:this.oldInputName;if(e=e?this.newCoordinate:this.oldCoordinate,s){var n=t.getBlockById(s);if(!n){console.warn("Can't connect to non-existent block: "+s);return}}if(o.getParent()&&o.unplug(),e)i=o.getRelativeToSurfaceXY(),o.moveBy(e.x-i.x,e.y-i.y,this.reason);else{t=o.outputConnection,(!t||o.previousConnection&&o.previousConnection.isConnected())&&(t=o.previousConnection);let d,f;o=(f=t)==null?void 0:f.type,i?(o=n.getInput(i))&&(d=o.connection):o===Z.PREVIOUS_STATEMENT&&(d=n.nextConnection),d&&t?t.connect(d):console.warn("Can't connect to non-existent input: "+i)}}else console.warn("Can't move non-existent block: "+this.blockId)}};l(M.EVENT,w.BLOCK_MOVE,yh);var vh=class extends Eo{constructor(e,t,o){super(e?e.workspace.id:void 0),this.type=w.BUBBLE_OPEN,e&&(this.blockId=e.id,this.isOpen=t,this.bubbleType=o)}toJson(){const e=super.toJson();if(this.isOpen===void 0)throw Error("Whether this event is for opening the bubble is undefined. Either pass the value to the constructor, or call fromJson");if(!this.bubbleType)throw Error("The type of bubble is undefined. Either pass the value to the constructor, or call fromJson");return e.isOpen=this.isOpen,e.bubbleType=this.bubbleType,e.blockId=this.blockId||"",e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new vh),t.isOpen=e.isOpen,t.bubbleType=e.bubbleType,t.blockId=e.blockId,t}},Ih;(function(e){e.MUTATOR="mutator",e.COMMENT="comment",e.WARNING="warning"})(Ih||(Ih={})),l(M.EVENT,w.BUBBLE_OPEN,vh);var wo=class extends hi{constructor(e){super(),this.isBlank=!e,e&&(this.commentId=e.id,this.workspaceId=e.workspace.id,this.group=r.getGroup$$module$build$src$core$events$utils(),this.recordUndo=Ue())}toJson(){const e=super.toJson();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");return e.commentId=this.commentId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new wo),t.commentId=e.commentId,t}static CommentCreateDeleteHelper(e,t){const o=e.getEventWorkspace_();if(t){if(!e.json)throw Error("Encountered a comment event without proper json");Fi(e.json,o)}else{if(!e.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");(t=o.getCommentById(e.commentId))?t.dispose():console.warn("Can't delete non-existent comment: "+e.commentId)}}},Ch=class extends wo{constructor(e,t,o){super(e),this.type=w.COMMENT_CHANGE,e&&(this.oldContents_=typeof t>"u"?"":t,this.newContents_=typeof o>"u"?"":o)}toJson(){const e=super.toJson();if(!this.oldContents_)throw Error("The old contents is undefined. Either pass a value to the constructor, or call fromJson");if(!this.newContents_)throw Error("The new contents is undefined. Either pass a value to the constructor, or call fromJson");return e.oldContents=this.oldContents_,e.newContents=this.newContents_,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ch),t.oldContents_=e.oldContents,t.newContents_=e.newContents,t}isNull(){return this.oldContents_===this.newContents_}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(t=t.getCommentById(this.commentId)){var o=e?this.newContents_:this.oldContents_;if(o===void 0)throw Error(e?"The new contents is undefined. Either pass a value to the constructor, or call fromJson":"The old contents is undefined. Either pass a value to the constructor, or call fromJson");t.setText(o)}else console.warn("Can't change non-existent comment: "+this.commentId)}};l(M.EVENT,w.COMMENT_CHANGE,Ch);var Sh=class extends wo{constructor(e,t){super(e),this.newCollapsed=t,this.type=w.COMMENT_COLLAPSE}toJson(){const e=super.toJson();if(this.newCollapsed===void 0)throw Error("The new collapse value undefined. Either call recordNew, or call fromJson");return e.newCollapsed=this.newCollapsed,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Sh),t.newCollapsed=e.newCollapsed,t}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");(t=t.getCommentById(this.commentId))?t.setCollapsed(e?!!this.newCollapsed:!this.newCollapsed):console.warn("Can't collapse or uncollapse non-existent comment: "+this.commentId)}};l(M.EVENT,w.COMMENT_COLLAPSE,Sh);var kh=class extends wo{constructor(e){super(e),this.type=w.COMMENT_CREATE,e&&(this.xml=Ki(e),this.json=js(e,{addCoordinates:!0}))}toJson(){const e=super.toJson();if(!this.xml)throw Error("The comment XML is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.json)throw Error("The comment JSON is undefined. Either pass a block to the constructor, or call fromJson");return e.xml=fo(this.xml),e.json=this.json,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new kh),t.xml=r.textToDom$$module$build$src$core$utils$xml(e.xml),t.json=e.json,t}run(e){wo.CommentCreateDeleteHelper(this,e)}};l(M.EVENT,w.COMMENT_CREATE,kh);var Rh=class extends wo{constructor(e){super(e),this.type=w.COMMENT_DELETE,e&&(this.xml=Ki(e),this.json=js(e,{addCoordinates:!0}))}run(e){wo.CommentCreateDeleteHelper(this,!e)}toJson(){const e=super.toJson();if(!this.xml)throw Error("The comment XML is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.json)throw Error("The comment JSON is undefined. Either pass a block to the constructor, or call fromJson");return e.xml=fo(this.xml),e.json=this.json,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Rh),t.xml=r.textToDom$$module$build$src$core$utils$xml(e.xml),t.json=e.json,t}};l(M.EVENT,w.COMMENT_DELETE,Rh);var wh=class extends Eo{constructor(e,t){super(e?e.workspace.id:void 0),this.type=w.COMMENT_DRAG,e&&(this.commentId=e.id,this.isStart=t)}toJson(){const e=super.toJson();if(this.isStart===void 0)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");if(this.commentId===void 0)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");return e.isStart=this.isStart,e.commentId=this.commentId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new wh),t.isStart=e.isStart,t.commentId=e.commentId,t}};l(M.EVENT,w.COMMENT_DRAG,wh);var Oh=class extends wo{constructor(e){super(e),this.type=w.COMMENT_MOVE,e&&(this.comment_=e,this.oldCoordinate_=e.getRelativeToSurfaceXY())}recordNew(){if(this.newCoordinate_)throw Error("Tried to record the new position of a comment on the same event twice.");if(!this.comment_)throw Error("The comment is undefined. Pass a comment to the constructor if you want to use the record functionality");this.newCoordinate_=this.comment_.getRelativeToSurfaceXY()}setReason(e){this.reason=e}setOldCoordinate(e){this.oldCoordinate_=e}toJson(){const e=super.toJson();if(!this.oldCoordinate_)throw Error("The old comment position is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.newCoordinate_)throw Error("The new comment position is undefined. Either call recordNew, or call fromJson");return e.oldCoordinate=`${Math.round(this.oldCoordinate_.x)}, ${Math.round(this.oldCoordinate_.y)}`,e.newCoordinate=Math.round(this.newCoordinate_.x)+","+Math.round(this.newCoordinate_.y),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Oh),o=e.oldCoordinate.split(","),t.oldCoordinate_=new P(Number(o[0]),Number(o[1])),o=e.newCoordinate.split(","),t.newCoordinate_=new P(Number(o[0]),Number(o[1])),t}isNull(){return P.equals(this.oldCoordinate_,this.newCoordinate_)}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(t=t.getCommentById(this.commentId)){if(e=e?this.newCoordinate_:this.oldCoordinate_,!e)throw Error("Either oldCoordinate_ or newCoordinate_ is undefined. Either pass a comment to the constructor and call recordNew, or call fromJson");t.moveTo(e)}else console.warn("Can't move non-existent comment: "+this.commentId)}};l(M.EVENT,w.COMMENT_MOVE,Oh);var Nh=class extends wo{constructor(e){super(e),this.type=w.COMMENT_RESIZE,e&&(this.oldSize=e.getSize())}recordCurrentSizeAsNewSize(){if(this.newSize)throw Error("Tried to record the new size of a comment on the same event twice.");var e=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(e=e.getCommentById(this.commentId),!e)throw Error("The comment associated with the comment resize event could not be found");this.newSize=e.getSize()}toJson(){const e=super.toJson();if(!this.oldSize)throw Error("The old comment size is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.newSize)throw Error("The new comment size is undefined. Either call recordCurrentSizeAsNewSize, or call fromJson");return e.oldWidth=Math.round(this.oldSize.width),e.oldHeight=Math.round(this.oldSize.height),e.newWidth=Math.round(this.newSize.width),e.newHeight=Math.round(this.newSize.height),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Nh),t.oldSize=new ve(e.oldWidth,e.oldHeight),t.newSize=new ve(e.newWidth,e.newHeight),t}isNull(){return ve.equals(this.oldSize,this.newSize)}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(t=t.getCommentById(this.commentId)){if(e=e?this.newSize:this.oldSize,!e)throw Error("Either oldSize or newSize is undefined. Either pass a comment to the constructor and call recordCurrentSizeAsNewSize, or call fromJson");t.setSize(e)}else console.warn("Can't resize non-existent comment: "+this.commentId)}};l(M.EVENT,w.COMMENT_RESIZE,Nh);var Ah=class extends Eo{constructor(e,t,o){super(o),this.type=w.TOOLBOX_ITEM_SELECT,this.oldItem=e??void 0,this.newItem=t??void 0}toJson(){const e=super.toJson();return e.oldItem=this.oldItem,e.newItem=this.newItem,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ah),t.oldItem=e.oldItem,t.newItem=e.newItem,t}};l(M.EVENT,w.TOOLBOX_ITEM_SELECT,Ah);var Lh=class extends Ri{constructor(e,t,o){super(e),this.oldType=t,this.newType=o,this.type=w.VAR_TYPE_CHANGE}toJson(){const e=super.toJson();if(!this.oldType||!this.newType)throw Error("The variable's types are undefined. Either pass them to the constructor, or call fromJson");return e.oldType=this.oldType,e.newType=this.newType,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Lh),t.oldType=e.oldType,t.newType=e.newType,t}run(e){const t=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.oldType||!this.newType)throw Error("The variable's types are undefined. Either pass them to the constructor, or call fromJson");const o=t.getVariableMap().getVariableById(this.varId);o&&(e?t.getVariableMap().changeVariableType(o,this.newType):t.getVariableMap().changeVariableType(o,this.oldType))}};l(M.EVENT,w.VAR_TYPE_CHANGE,Lh);var rf=class extends hi{constructor(e){super(),this.isBlank=!0,this.recordUndo=!1,this.type=w.FINISHED_LOADING,this.isBlank=!!e,e&&(this.workspaceId=e.id)}};l(M.EVENT,w.FINISHED_LOADING,rf);var nf,lf,cf,uf,af,hf,df,$f,pf,gf,mf,ff,_f,bf,Tf,Ef,yf,vf,If,Cf,Sf,kf,Rf,wf,j;r.BLOCK_CHANGE$$module$build$src$core$events$events=w.BLOCK_CHANGE,r.BLOCK_CREATE$$module$build$src$core$events$events=w.BLOCK_CREATE,r.BLOCK_DELETE$$module$build$src$core$events$events=w.BLOCK_DELETE,nf=w.BLOCK_DRAG,r.BLOCK_MOVE$$module$build$src$core$events$events=w.BLOCK_MOVE,lf=w.BLOCK_FIELD_INTERMEDIATE_CHANGE,cf=w.BUBBLE_OPEN,uf=w.BLOCK_CHANGE,af=w.CLICK,hf=w.COMMENT_CHANGE,df=w.COMMENT_CREATE,$f=w.COMMENT_DELETE,pf=w.COMMENT_MOVE,gf=w.COMMENT_RESIZE,mf=w.COMMENT_DRAG,ff=w.BLOCK_CREATE,_f=w.BLOCK_DELETE,bf=w.FINISHED_LOADING,Tf=w.BLOCK_MOVE,Ef=w.SELECTED,yf=w.THEME_CHANGE,vf=w.TOOLBOX_ITEM_SELECT,If=w.TRASHCAN_OPEN,Cf=w.UI,Sf=w.VAR_CREATE,kf=w.VAR_DELETE,Rf=w.VAR_RENAME,wf=w.VIEWPORT_CHANGE,j={},j.Abstract=hi,j.BLOCK_CHANGE=r.BLOCK_CHANGE$$module$build$src$core$events$events,j.BLOCK_CREATE=r.BLOCK_CREATE$$module$build$src$core$events$events,j.BLOCK_DELETE=r.BLOCK_DELETE$$module$build$src$core$events$events,j.BLOCK_DRAG=nf,j.BLOCK_FIELD_INTERMEDIATE_CHANGE=lf,j.BLOCK_MOVE=r.BLOCK_MOVE$$module$build$src$core$events$events,j.BUBBLE_OPEN=cf,j.BUMP_EVENTS=Xp,j.BlockBase=Ns,j.BlockChange=As,j.BlockCreate=Pa,j.BlockDelete=Ga,j.BlockDrag=Th,j.BlockFieldIntermediateChange=Eh,j.BlockMove=yh,j.BubbleOpen=vh,j.BubbleType=Ih,j.CHANGE=uf,j.CLICK=af,j.COMMENT_CHANGE=hf,j.COMMENT_CREATE=df,j.COMMENT_DELETE=$f,j.COMMENT_DRAG=mf,j.COMMENT_MOVE=pf,j.COMMENT_RESIZE=gf,j.CREATE=ff,j.Click=ca,j.ClickTarget=ua,j.CommentBase=wo,j.CommentChange=Ch,j.CommentCollapse=Sh,j.CommentCreate=kh,j.CommentDelete=Rh,j.CommentDrag=wh,j.CommentMove=Oh,j.CommentResize=Nh,j.DELETE=_f,j.FINISHED_LOADING=bf,j.FinishedLoading=rf,j.MOVE=Tf,j.SELECTED=Ef,j.Selected=Ha,j.THEME_CHANGE=yf,j.TOOLBOX_ITEM_SELECT=vf,j.TRASHCAN_OPEN=If,j.ThemeChange=Fa,j.ToolboxItemSelect=Ah,j.TrashcanOpen=dh,j.UI=Cf,j.UiBase=Eo,j.VAR_CREATE=Sf,j.VAR_DELETE=kf,j.VAR_RENAME=Rf,j.VIEWPORT_CHANGE=wf,j.VarBase=Ri,j.VarCreate=uh,j.VarDelete=ah,j.VarRename=hh,j.VarTypeChange=Lh,j.ViewportChange=Ua,j.clearPendingUndo=he,j.disable=r.disable$$module$build$src$core$events$utils,j.disableOrphans=Xe,j.enable=r.enable$$module$build$src$core$events$utils,j.filter=le,j.fire=_,j.fromJson=_e,j.get=U,j.getDescendantIds=ce,j.getGroup=r.getGroup$$module$build$src$core$events$utils,j.getRecordUndo=Ue,j.isEnabled=J,j.setGroup=r.setGroup$$module$build$src$core$events$utils,j.setRecordUndo=r.setRecordUndo$$module$build$src$core$events$utils;var Oo={};Oo.BottomRow=Xm,Oo.ConstantProvider=zm,Oo.Drawer=Ym,Oo.PathObject=qm,Oo.RenderInfo=Jm,Oo.Renderer=fh,Oo.RightConnectionShape=jm,Oo.StatementInput=Rl,Oo.TopRow=Km,Qu();var dt={};dt.registerCleanup=Bu,dt.registerCollapse=Fu,dt.registerCollapseExpandBlock=Yu,dt.registerComment=Wu,dt.registerCommentCreate=Zu,dt.registerCommentDelete=Ju,dt.registerCommentDuplicate=qu,dt.registerCommentOptions=wp,dt.registerDefaultOptions=Qu,dt.registerDelete=ju,dt.registerDeleteAll=Gu,dt.registerDisable=Xu,dt.registerDuplicate=Vu,dt.registerExpand=Uu,dt.registerHelp=Ku,dt.registerInline=zu,dt.registerRedo=xu,dt.registerUndo=Du;var Mh="button",Of=class{load(e,t){return e=new xt(t.getWorkspace(),t.targetWorkspace,e,!1),e.show(),new Ci(e,Mh)}gapForItem(e,t){return t}disposeItem(e){e=e.getElement(),e instanceof xt&&e.dispose()}getType(){return Mh}};l(M.FLYOUT_INFLATER,Mh,Of);var Or={};Or.Bubble=Oe,Or.MiniWorkspaceBubble=Wo,Or.TextBubble=um,Or.TextInputBubble=Za;var Gb="WORKSPACE_AT_BLOCK_CAPACITY",Dh="block",Nf=class{constructor(){this.permanentlyDisabledBlocks=new Set,this.listeners=new Map,this.capacityWrapper=this.filterFlyoutBasedOnCapacity.bind(this)}load(e,t){return this.setFlyout(t),e=this.createBlock(e,t.getWorkspace()),e.isEnabled()?this.updateStateBasedOnCapacity(e):this.permanentlyDisabledBlocks.add(e),e.getDescendants(!1).forEach(o=>o.isInFlyout=!0),this.addBlockListeners(e),new Ci(e,Dh)}createBlock(e,t){return e.blockxml?(e=typeof e.blockxml=="string"?r.textToDom$$module$build$src$core$utils$xml(e.blockxml):e.blockxml,t=Is(e,t)):(e.enabled===void 0&&(e.enabled=e.disabled!=="true"&&e.disabled!==!0),e.disabledReasons===void 0&&e.enabled===!1&&(e.disabledReasons=[Jt]),"x"in e&&delete e.x,"y"in e&&delete e.y,t=Zs(e,t)),t}gapForItem(e,t){let o;return e.gap?o=parseInt(String(e.gap)):e.blockxml&&(e=typeof e.blockxml=="string"?r.textToDom$$module$build$src$core$utils$xml(e.blockxml):e.blockxml,o=parseInt(e.getAttribute("gap"))),!o||isNaN(o)?t:o}disposeItem(e){e=e.getElement(),e instanceof Be&&(this.removeListeners(e.id),e.dispose(!1,!1))}removeListeners(e){let t;((t=this.listeners.get(e))!=null?t:[]).forEach(o=>te(o)),this.listeners.delete(e)}setFlyout(e){if(this.flyout!==e){if(this.flyout){let o;(o=this.flyout.targetWorkspace)==null||o.removeChangeListener(this.capacityWrapper)}this.flyout=e;var t;(t=this.flyout.targetWorkspace)==null||t.addChangeListener(this.capacityWrapper)}}updateStateBasedOnCapacity(e){let t,o;const s=(t=this.flyout)==null||(o=t.targetWorkspace)==null?void 0:o.isCapacityAvailable(io(e));for(;e;)e.setDisabledReason(!s,Gb),e=e.getNextBlock()}addBlockListeners(e){const t=[];t.push(z(e.getSvgRoot(),"pointerdown",e,o=>{let s,i;const n=(s=this.flyout)==null||(i=s.targetWorkspace)==null?void 0:i.getGesture(o);n&&this.flyout&&(n.setStartBlock(e),n.handleFlyoutStart(o,this.flyout))})),t.push(ae(e.getSvgRoot(),"pointermove",null,()=>{let o,s;!((o=this.flyout)==null||(s=o.targetWorkspace)==null)&&s.isDragging()||e.addSelect()})),t.push(ae(e.getSvgRoot(),"pointerleave",null,()=>{let o,s;!((o=this.flyout)==null||(s=o.targetWorkspace)==null)&&s.isDragging()||e.removeSelect()})),this.listeners.set(e.id,t)}filterFlyoutBasedOnCapacity(e){!this.flyout||e&&e.type!==w.BLOCK_CREATE&&e.type!==w.BLOCK_DELETE||this.flyout.getWorkspace().getTopBlocks(!1).forEach(t=>{this.permanentlyDisabledBlocks.has(t)||this.updateStateBasedOnCapacity(t)})}getType(){return Dh}};l(M.FLYOUT_INFLATER,Dh,Nf);var Af=class extends Tl{constructor(){super(),this.FIELD_TEXT_BASELINE_CENTER=!1,this.DARK_PATH_OFFSET=1,this.MAX_BOTTOM_WIDTH=30,this.STATEMENT_BOTTOM_SPACER=-this.NOTCH_HEIGHT/2}getCSS_(e){return super.getCSS_(e).concat([`${e} .blocklyInsertionMarker>.blocklyPathLight,`,`${e} .blocklyInsertionMarker>.blocklyPathDark {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"])}},Lf=class{constructor(e){this.inlineSteps_=this.steps_="",this.info_=e,this.RTL_=this.info_.RTL,e=e.getRenderer(),this.constants_=e.getConstants(),this.highlightConstants_=e.getHighlightConstants(),this.highlightOffset=this.highlightConstants_.OFFSET,this.outsideCornerPaths_=this.highlightConstants_.OUTSIDE_CORNER,this.insideCornerPaths_=this.highlightConstants_.INSIDE_CORNER,this.puzzleTabPaths_=this.highlightConstants_.PUZZLE_TAB,this.notchPaths_=this.highlightConstants_.NOTCH,this.startPaths_=this.highlightConstants_.START_HAT,this.jaggedTeethPaths_=this.highlightConstants_.JAGGED_TEETH}getPath(){return this.steps_+`
668
- `+this.inlineSteps_}drawTopCorner(e){this.steps_+=je(e.xPos,this.info_.startY);for(let t=0,o;o=e.elements[t];t++)T.isLeftSquareCorner(o)?this.steps_+=this.highlightConstants_.START_POINT:T.isLeftRoundedCorner(o)?this.steps_+=this.outsideCornerPaths_.topLeft(this.RTL_):T.isPreviousConnection(o)?this.steps_+=this.notchPaths_.pathLeft:T.isHat(o)?this.steps_+=this.startPaths_.path(this.RTL_):T.isSpacer(o)&&o.width!==0&&(this.steps_+=re("H",o.xPos+o.width-this.highlightOffset));this.steps_+=re("H",e.xPos+e.width-this.highlightOffset)}drawJaggedEdge_(e){this.info_.RTL&&(this.steps_+=this.jaggedTeethPaths_.pathLeft+re("v",e.height-this.jaggedTeethPaths_.height-this.highlightOffset))}drawValueInput(e){const t=e.getLastInput();if(this.RTL_){const o=e.height-t.connectionHeight;this.steps_+=gt(t.xPos+t.width-this.highlightOffset,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)+re("v",o)}else this.steps_+=gt(t.xPos+t.width,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)}drawStatementInput(e){const t=e.getLastInput();if(t)if(this.RTL_){const o=e.height-2*this.insideCornerPaths_.height;this.steps_+=gt(t.xPos,e.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+re("v",o)+this.insideCornerPaths_.pathBottom(this.RTL_)+bo(e.width-t.xPos-this.insideCornerPaths_.width,0)}else this.steps_+=gt(t.xPos,e.yPos+e.height)+this.insideCornerPaths_.pathBottom(this.RTL_)+bo(e.width-t.xPos-this.insideCornerPaths_.width,0)}drawRightSideRow(e){const t=e.xPos+e.width-this.highlightOffset;e instanceof nh&&e.followsStatement&&(this.steps_+=re("H",t)),this.RTL_&&(this.steps_+=re("H",t),e.height>this.highlightOffset&&(this.steps_+=re("V",e.yPos+e.height-this.highlightOffset)))}drawBottomRow(e){if(this.RTL_)this.steps_+=re("V",e.baseline-this.highlightOffset);else{const t=this.info_.bottomRow.elements[0];T.isLeftSquareCorner(t)?this.steps_+=gt(e.xPos+this.highlightOffset,e.baseline-this.highlightOffset):T.isLeftRoundedCorner(t)&&(this.steps_+=gt(e.xPos,e.baseline),this.steps_+=this.outsideCornerPaths_.bottomLeft())}}drawLeft(){var e=this.info_.outputConnection;e&&(e=e.connectionOffsetY+e.height,this.RTL_?this.steps_+=gt(this.info_.startX,e):(this.steps_+=gt(this.info_.startX+this.highlightOffset,this.info_.bottomRow.baseline-this.highlightOffset),this.steps_+=re("V",e)),this.steps_+=this.puzzleTabPaths_.pathUp(this.RTL_)),this.RTL_||(e=this.info_.topRow,T.isLeftRoundedCorner(e.elements[0])?this.steps_+=re("V",this.outsideCornerPaths_.height):this.steps_+=re("V",e.capline+this.highlightOffset))}drawInlineInput(e){const t=this.highlightOffset,o=e.xPos+e.connectionWidth;var s=e.centerline-e.height/2;const i=e.width-e.connectionWidth,n=s+t;this.RTL_?(s=e.connectionOffsetY-t,e=e.height-(e.connectionOffsetY+e.connectionHeight)+t,this.inlineSteps_+=gt(o-t,n)+re("v",s)+this.puzzleTabPaths_.pathDown(this.RTL_)+re("v",e)+re("h",i)):this.inlineSteps_+=gt(e.xPos+e.width+t,n)+re("v",e.height)+re("h",-i)+gt(o,s+e.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)}},Mf=class extends El{constructor(e,t){super(e,t),this.highlighter_=new Lf(t)}draw(){this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights();const e=this.block_.pathObject;e.setPath(this.outlinePath_+`
669
- `+this.inlinePath_),e.setHighlightPath(this.highlighter_.getPath()),this.info_.RTL&&e.flipRTL(),this.recordSizeOnBlock_()}drawTop_(){this.highlighter_.drawTopCorner(this.info_.topRow),this.highlighter_.drawRightSideRow(this.info_.topRow),super.drawTop_()}drawJaggedEdge_(e){this.highlighter_.drawJaggedEdge_(e),super.drawJaggedEdge_(e)}drawValueInput_(e){this.highlighter_.drawValueInput(e),super.drawValueInput_(e)}drawStatementInput_(e){this.highlighter_.drawStatementInput(e),super.drawStatementInput_(e)}drawRightSideRow_(e){this.highlighter_.drawRightSideRow(e),this.outlinePath_+=re("H",e.xPos+e.width)+re("V",e.yPos+e.height)}drawBottom_(){this.highlighter_.drawBottomRow(this.info_.bottomRow),super.drawBottom_()}drawLeft_(){this.highlighter_.drawLeft(),super.drawLeft_()}drawInlineInput_(e){this.highlighter_.drawInlineInput(e),super.drawInlineInput_(e)}positionInlineInputConnection_(e){const t=e.centerline-e.height/2;if(e.connectionModel){let o=e.xPos+e.connectionWidth+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(o*=-1),e.connectionModel.setOffsetInBlock(o,t+e.connectionOffsetY+this.constants_.DARK_PATH_OFFSET)}}positionStatementInputConnection_(e){const t=e.getLastInput();if(t!=null&&t.connectionModel){let o=e.xPos+e.statementEdge+t.notchOffset;o=this.info_.RTL?o*-1:o+this.constants_.DARK_PATH_OFFSET,t.connectionModel.setOffsetInBlock(o,e.yPos+this.constants_.DARK_PATH_OFFSET)}}positionExternalValueConnection_(e){const t=e.getLastInput();if(t&&t.connectionModel){let o=e.xPos+e.width+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(o*=-1),t.connectionModel.setOffsetInBlock(o,e.yPos)}}positionNextConnection_(){const e=this.info_.bottomRow;if(e.connection){const t=e.connection,o=t.xPos;t.connectionModel.setOffsetInBlock((this.info_.RTL?-o:o)+this.constants_.DARK_PATH_OFFSET/2,e.baseline+this.constants_.DARK_PATH_OFFSET)}}},Df=class{constructor(e){this.OFFSET=.5,this.constantProvider=e,this.START_POINT=je(this.OFFSET,this.OFFSET)}init(){this.INSIDE_CORNER=this.makeInsideCorner(),this.OUTSIDE_CORNER=this.makeOutsideCorner(),this.PUZZLE_TAB=this.makePuzzleTab(),this.NOTCH=this.makeNotch(),this.JAGGED_TEETH=this.makeJaggedTeeth(),this.START_HAT=this.makeStartHat()}makeInsideCorner(){const e=this.constantProvider.CORNER_RADIUS,t=this.OFFSET,o=(1-Math.SQRT1_2)*(e+t)-t,s=je(o,o)+qe("a","0 0,0",e,se(-o-t,e-o)),i=qe("a","0 0,0",e+t,se(e+t,e+t)),n=je(o,-o)+qe("a","0 0,0",e+t,se(e-o,o+t));return{width:e+t,height:e,pathTop(d){return d?s:""},pathBottom(d){return d?i:n}}}makeOutsideCorner(){const e=this.constantProvider.CORNER_RADIUS,t=this.OFFSET,o=(1-Math.SQRT1_2)*(e-t)+t,s=je(o,o)+qe("a","0 0,1",e-t,se(e-o,-o+t)),i=je(t,e)+qe("a","0 0,1",e-t,se(e,-e+t)),n=-o,d=je(o,n)+qe("a","0 0,1",e-t,se(-o+t,-n-e));return{height:e,topLeft(f){return f?s:i},bottomLeft(){return d}}}makePuzzleTab(){const e=this.constantProvider.TAB_WIDTH,t=this.constantProvider.TAB_HEIGHT,o=je(-2,-t+2.5+.9)+bo(e*-.45,-2.1),s=re("v",2.5)+je(-e*.97,2.5)+Pt("q",[se(-e*.05,10),se(e*.3,9.5)])+je(e*.67,-1.9)+re("v",2.5),i=re("v",-1.5)+je(e*-.92,-.5)+Pt("q",[se(e*-.19,-5.5),se(0,-11)])+je(e*.92,1),n=je(-5,t-.7)+bo(e*.46,-2.1);return{width:e,height:t,pathUp(d){return d?o:i},pathDown(d){return d?s:n}}}makeNotch(){return{pathLeft:re("h",this.OFFSET)+this.constantProvider.NOTCH.pathLeft}}makeJaggedTeeth(){return{pathLeft:bo(5.1,2.6)+je(-10.2,6.8)+bo(5.1,2.6),height:12,width:10.2}}makeStartHat(){const e=this.constantProvider.START_HAT.height,t=je(25,-8.7)+Pt("c",[se(29.7,-6.2),se(57.2,-.5),se(75,8.7)]),o=Pt("c",[se(17.8,-9.2),se(45.3,-14.9),se(75,-8.7)])+gt(100.5,e+.5);return{path(s){return s?t:o}}}},xf=class extends ih{constructor(e,t){super(e,t),this.constants_=e,this.connectedBlock&&(this.width+=this.constants_.DARK_PATH_OFFSET,this.height+=this.constants_.DARK_PATH_OFFSET)}},Bf=class extends bl{constructor(e,t){super(e,t),this.constants_=e,this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}},Pf=class extends Cr{constructor(e,t){super(e,t),this.renderer_=e}getRenderer(){return this.renderer_}populateBottomRow_(){super.populateBottomRow_(),this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof Yt||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(e,t){this.isInline&&e instanceof r.ValueInput$$module$build$src$core$inputs$value_input?(t.elements.push(new xf(this.constants_,e)),t.hasInlineInput=!0):e instanceof Yt?(t.elements.push(new Bf(this.constants_,e)),t.hasStatement=!0):e instanceof r.ValueInput$$module$build$src$core$inputs$value_input?(t.elements.push(new oh(this.constants_,e)),t.hasExternalInput=!0):(e instanceof Io||e instanceof Yo)&&(t.minHeight=Math.max(t.minHeight,this.constants_.DUMMY_INPUT_MIN_HEIGHT),t.hasDummyInput=!0),this.isInline||t.align!==null||(t.align=e.align)}addElemSpacing_(){let e=!1;for(let o=0,s;s=this.rows[o];o++)s.hasExternalInput&&(e=!0);for(let o=0,s;s=this.rows[o];o++){var t=s.elements;if(s.elements=[],s.startsWithElemSpacer()&&s.elements.push(new Xt(this.constants_,this.getInRowSpacing_(null,t[0]))),t.length){for(let i=0;i<t.length-1;i++){s.elements.push(t[i]);const n=this.getInRowSpacing_(t[i],t[i+1]);s.elements.push(new Xt(this.constants_,n))}s.elements.push(t[t.length-1]),s.endsWithElemSpacer()&&(t=this.getInRowSpacing_(t[t.length-1],null),e&&s.hasDummyInput&&(t+=this.constants_.TAB_WIDTH),s.elements.push(new Xt(this.constants_,t)))}}}getInRowSpacing_(e,t){if(!e)return t&&T.isField(t)&&t.isEditable?this.constants_.MEDIUM_PADDING:t&&T.isInlineInput(t)?this.constants_.MEDIUM_LARGE_PADDING:t&&T.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!T.isInput(e)&&(!t||T.isStatementInput(t)))return T.isField(e)&&e.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:T.isIcon(e)?this.constants_.LARGE_PADDING*2+1:T.isHat(e)?this.constants_.NO_PADDING:T.isPreviousOrNextConnection(e)?this.constants_.LARGE_PADDING:T.isLeftRoundedCorner(e)?this.constants_.MIN_BLOCK_WIDTH:T.isJaggedEdge(e)?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING;if(T.isInput(e)&&!t){if(T.isExternalInput(e))return this.constants_.NO_PADDING;if(T.isInlineInput(e))return this.constants_.LARGE_PADDING;if(T.isStatementInput(e))return this.constants_.NO_PADDING}if(!T.isInput(e)&&t&&T.isInput(t)){if(T.isField(e)&&e.isEditable){if(T.isInlineInput(t)||T.isExternalInput(t))return this.constants_.SMALL_PADDING}else{if(T.isInlineInput(t)||T.isExternalInput(t))return this.constants_.MEDIUM_LARGE_PADDING;if(T.isStatementInput(t))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-1}if(T.isIcon(e)&&t&&!T.isInput(t))return this.constants_.LARGE_PADDING;if(T.isInlineInput(e)&&t&&T.isField(t))return t.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;if(T.isLeftSquareCorner(e)&&t){if(T.isHat(t))return this.constants_.NO_PADDING;if(T.isPreviousConnection(t))return t.notchOffset;if(T.isNextConnection(t))return t.notchOffset+(this.RTL?1:-1)*this.constants_.DARK_PATH_OFFSET/2}if(T.isLeftRoundedCorner(e)&&t){if(T.isPreviousConnection(t))return t.notchOffset-this.constants_.CORNER_RADIUS;if(T.isNextConnection(t))return t.notchOffset-this.constants_.CORNER_RADIUS+(this.RTL?1:-1)*this.constants_.DARK_PATH_OFFSET/2}return T.isField(e)&&t&&T.isField(t)&&e.isEditable===t.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING:t&&T.isJaggedEdge(t)?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getSpacerRowHeight_(e,t){return T.isTopRow(e)&&T.isBottomRow(t)?this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:T.isTopRow(e)||T.isBottomRow(t)?this.constants_.NO_PADDING:e.hasExternalInput&&t.hasExternalInput?this.constants_.LARGE_PADDING:!e.hasStatement&&t.hasStatement?this.constants_.BETWEEN_STATEMENT_PADDING_Y:e.hasStatement&&t.hasStatement||!e.hasStatement&&t.hasDummyInput||e.hasDummyInput?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getElemCenterline_(e,t){if(T.isSpacer(t))return e.yPos+t.height/2;if(T.isBottomRow(e))return e=e.yPos+e.height-e.descenderHeight,T.isNextConnection(t)?e+t.height/2:e-t.height/2;if(T.isTopRow(e))return T.isHat(t)?e.capline-t.height/2:e.capline+t.height/2;let o=e.yPos;return T.isField(t)||T.isIcon(t)?(o+=t.height/2,(e.hasInlineInput||e.hasStatement)&&t.height+this.constants_.TALL_INPUT_FIELD_OFFSET_Y<=e.height&&(o+=this.constants_.TALL_INPUT_FIELD_OFFSET_Y)):o=T.isInlineInput(t)?o+t.height/2:o+e.height/2,o}alignRowElements_(){if(this.isInline){var e=0,t=new WeakMap,o=null;for(let s=this.rows.length-1,i;i=this.rows[s];s--)t.set(i,e),T.isInputRow(i)&&(i.hasStatement&&this.alignStatementRow_(i),o&&o.hasStatement&&i.width<o.width?t.set(i,o.width):e=i.hasStatement?i.width:Math.max(e,i.width),o=i);e=0;for(let s=0,i;i=this.rows[s];s++)i.hasStatement?e=this.getDesiredRowWidth_(i):T.isSpacer(i)?i.width=Math.max(e,t.get(i)):(o=i.width,e=Math.max(e,t.get(i))-o,e>0&&this.addAlignmentPadding_(i,e),e=i.width)}else super.alignRowElements_()}getDesiredRowWidth_(e){return this.isInline&&e.hasStatement?this.statementEdge+this.constants_.MAX_BOTTOM_WIDTH+this.startX:super.getDesiredRowWidth_(e)}finalize_(){let e=0,t=0;for(let s=0,i;i=this.rows[s];s++){i.yPos=t,i.xPos=this.startX,t+=i.height,e=Math.max(e,i.widthWithConnectedBlocks);var o=t-this.topRow.ascenderHeight;i===this.bottomRow&&o<this.constants_.MIN_BLOCK_HEIGHT&&(o=this.constants_.MIN_BLOCK_HEIGHT-o,this.bottomRow.height+=o,t+=o),this.recordElemPositions_(i)}this.outputConnection&&this.block_.nextConnection&&this.block_.nextConnection.isConnected()&&(o=this.block_.nextConnection.targetBlock())&&(e=Math.max(e,o.getHeightWidth().width-this.constants_.DARK_PATH_OFFSET)),this.bottomRow.baseline=t-this.bottomRow.descenderHeight,this.widthWithChildren=e+this.startX+this.constants_.DARK_PATH_OFFSET,this.width+=this.constants_.DARK_PATH_OFFSET,this.height=t+this.constants_.DARK_PATH_OFFSET,this.startY=this.topRow.capline}},Ff=class extends yl{constructor(e,t,o){super(e,t,o),this.constants=o,this.colourDark="#000000",this.svgPathDark=v(R.PATH,{class:"blocklyPathDark",transform:"translate(1,1)"}),this.svgRoot.insertBefore(this.svgPathDark,this.svgPath),this.svgPathLight=v(R.PATH,{class:"blocklyPathLight"},this.svgRoot)}setPath(e){this.svgPath.setAttribute("d",e),this.svgPathDark.setAttribute("d",e)}setHighlightPath(e){this.svgPathLight.setAttribute("d",e)}flipRTL(){this.svgPath.setAttribute("transform","scale(-1 1)"),this.svgPathLight.setAttribute("transform","scale(-1 1)"),this.svgPathDark.setAttribute("transform","translate(1,1) scale(-1 1)")}applyColour(e){if(this.svgPathLight.style.display="",this.svgPathDark.style.display="",!this.style.colourTertiary)throw Error("The renderer did not properly initialize the tertiary colour of the block style");this.svgPathLight.setAttribute("stroke",this.style.colourTertiary),this.svgPathDark.setAttribute("fill",this.colourDark),super.applyColour(e),this.svgPath.setAttribute("stroke","none")}setStyle(e){this.style=e,this.colourDark=ys("#000",this.style.colourPrimary,.2)||this.colourDark}updateHighlighted(e){super.updateHighlighted(e),this.svgPathLight.style.display=e?"none":"inline"}updateShadow_(e){if(e){if(this.svgPathLight.style.display="none",!this.style.colourSecondary)throw Error("The renderer did not properly initialize the secondary colour of the block style block style");this.svgPathDark.setAttribute("fill",this.style.colourSecondary),this.svgPath.setAttribute("stroke","none"),this.svgPath.setAttribute("fill",this.style.colourSecondary)}}updateDisabled_(e){super.updateDisabled_(e),e&&this.svgPath.setAttribute("stroke","none")}},Uf=class extends vl{constructor(e){super(e),this.highlightConstants=null}init(e,t){super.init(e,t),this.highlightConstants=this.makeHighlightConstants_(),this.highlightConstants.init()}refreshDom(e,t,o){super.refreshDom(e,t,o),this.getHighlightConstants().init()}makeConstants_(){return new Af}makeRenderInfo_(e){return new Pf(this,e)}makeDrawer_(e,t){return new Mf(e,t)}makePathObject(e,t){return new Ff(e,t,this.getConstants())}makeHighlightConstants_(){return new Df(this.getConstants())}getHighlightConstants(){if(!this.highlightConstants)throw Error("Cannot access the highlight constants because init has not been called");return this.highlightConstants}};Zi("geras",Uf);var No={};No.ConstantProvider=Af,No.Drawer=Mf,No.HighlightConstantProvider=Df,No.Highlighter=Lf,No.InlineInput=xf,No.PathObject=Ff,No.RenderInfo=Pf,No.Renderer=Uf,No.StatementInput=Bf;var Hf=class extends Cr{constructor(e,t){super(e,t)}getRenderer(){return this.renderer_}addElemSpacing_(){let e=!1;for(var t=0;t<this.rows.length;t++)if(this.rows[t].hasExternalInput){e=!0;break}for(t=0;t<this.rows.length;t++){const s=this.rows[t];var o=s.elements;if(s.elements=[],s.startsWithElemSpacer()&&s.elements.push(new Xt(this.constants_,this.getInRowSpacing_(null,o[0]))),o.length){for(let i=0;i<o.length-1;i++){s.elements.push(o[i]);const n=this.getInRowSpacing_(o[i],o[i+1]);s.elements.push(new Xt(this.constants_,n))}s.elements.push(o[o.length-1]),s.endsWithElemSpacer()&&(o=this.getInRowSpacing_(o[o.length-1],null),e&&s.hasDummyInput&&(o+=this.constants_.TAB_WIDTH),s.elements.push(new Xt(this.constants_,o)))}}}getInRowSpacing_(e,t){if(!e)return t&&T.isField(t)&&t.isEditable?this.constants_.MEDIUM_PADDING:t&&T.isInlineInput(t)?this.constants_.MEDIUM_LARGE_PADDING:t&&T.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!T.isInput(e)&&!t)return T.isField(e)&&e.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:T.isIcon(e)?this.constants_.LARGE_PADDING*2+1:T.isHat(e)?this.constants_.NO_PADDING:T.isPreviousOrNextConnection(e)?this.constants_.LARGE_PADDING:T.isLeftRoundedCorner(e)?this.constants_.MIN_BLOCK_WIDTH:T.isJaggedEdge(e)?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING;if(T.isInput(e)&&!t){if(T.isExternalInput(e))return this.constants_.NO_PADDING;if(T.isInlineInput(e))return this.constants_.LARGE_PADDING;if(T.isStatementInput(e))return this.constants_.NO_PADDING}if(!T.isInput(e)&&t&&T.isInput(t)){if(T.isField(e)&&e.isEditable){if(T.isInlineInput(t)||T.isExternalInput(t))return this.constants_.SMALL_PADDING}else{if(T.isInlineInput(t)||T.isExternalInput(t))return this.constants_.MEDIUM_LARGE_PADDING;if(T.isStatementInput(t))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-1}if(T.isIcon(e)&&t&&!T.isInput(t))return this.constants_.LARGE_PADDING;if(T.isInlineInput(e)&&t&&T.isField(t))return t.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;if(T.isLeftSquareCorner(e)&&t){if(T.isHat(t))return this.constants_.NO_PADDING;if(T.isPreviousConnection(t)||T.isNextConnection(t))return t.notchOffset}return T.isLeftRoundedCorner(e)&&t?t.notchOffset-this.constants_.CORNER_RADIUS:T.isField(e)&&t&&T.isField(t)&&e.isEditable===t.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING:t&&T.isJaggedEdge(t)?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getSpacerRowHeight_(e,t){return T.isTopRow(e)&&T.isBottomRow(t)?this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:T.isTopRow(e)||T.isBottomRow(t)?this.constants_.NO_PADDING:e.hasExternalInput&&t.hasExternalInput?this.constants_.LARGE_PADDING:!e.hasStatement&&t.hasStatement?this.constants_.BETWEEN_STATEMENT_PADDING_Y:e.hasStatement&&t.hasStatement||e.hasDummyInput||t.hasDummyInput?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getElemCenterline_(e,t){if(T.isSpacer(t))return e.yPos+t.height/2;if(T.isBottomRow(e))return e=e.yPos+e.height-e.descenderHeight,T.isNextConnection(t)?e+t.height/2:e-t.height/2;if(T.isTopRow(e))return T.isHat(t)?e.capline-t.height/2:e.capline+t.height/2;let o=e.yPos;return o=T.isField(t)&&e.hasStatement?o+(this.constants_.TALL_INPUT_FIELD_OFFSET_Y+t.height/2):o+e.height/2}finalize_(){let e=0,t=0;for(var o=0;o<this.rows.length;o++){const i=this.rows[o];i.yPos=t,i.xPos=this.startX,t+=i.height,e=Math.max(e,i.widthWithConnectedBlocks);var s=t-this.topRow.ascenderHeight;i===this.bottomRow&&s<this.constants_.MIN_BLOCK_HEIGHT&&(s=this.constants_.MIN_BLOCK_HEIGHT-s,this.bottomRow.height+=s,t+=s),this.recordElemPositions_(i)}this.outputConnection&&this.block_.nextConnection&&this.block_.nextConnection.isConnected()&&(o=this.block_.nextConnection.targetBlock())&&(e=Math.max(e,o.getHeightWidth().width)),this.bottomRow.baseline=t-this.bottomRow.descenderHeight,this.widthWithChildren=e+this.startX,this.height=t,this.startY=this.topRow.capline}},Gf=class extends vl{constructor(e){super(e)}makeRenderInfo_(e){return new Hf(this,e)}};Zi("thrasos",Gf);var xh={};xh.RenderInfo=Hf,xh.Renderer=Gf;var Vb={colour_blocks:{colourPrimary:"#CF63CF",colourSecondary:"#C94FC9",colourTertiary:"#BD42BD"},list_blocks:{colourPrimary:"#9966FF",colourSecondary:"#855CD6",colourTertiary:"#774DCB"},logic_blocks:{colourPrimary:"#4C97FF",colourSecondary:"#4280D7",colourTertiary:"#3373CC"},loop_blocks:{colourPrimary:"#0fBD8C",colourSecondary:"#0DA57A",colourTertiary:"#0B8E69"},math_blocks:{colourPrimary:"#59C059",colourSecondary:"#46B946",colourTertiary:"#389438"},procedure_blocks:{colourPrimary:"#FF6680",colourSecondary:"#FF4D6A",colourTertiary:"#FF3355"},text_blocks:{colourPrimary:"#FFBF00",colourSecondary:"#E6AC00",colourTertiary:"#CC9900"},variable_blocks:{colourPrimary:"#FF8C1A",colourSecondary:"#FF8000",colourTertiary:"#DB6E00"},variable_dynamic_blocks:{colourPrimary:"#FF8C1A",colourSecondary:"#FF8000",colourTertiary:"#DB6E00"},hat_blocks:{colourPrimary:"#4C97FF",colourSecondary:"#4280D7",colourTertiary:"#3373CC",hat:"cap"}},Wb={colour_category:{colour:"#CF63CF"},list_category:{colour:"#9966FF"},logic_category:{colour:"#4C97FF"},loop_category:{colour:"#0fBD8C"},math_category:{colour:"#59C059"},procedure_category:{colour:"#FF6680"},text_category:{colour:"#FFBF00"},variable_category:{colour:"#FF8C1A"},variable_dynamic_category:{colour:"#FF8C1A"}},zb=new Bs("zelos",Vb,Wb),Yb={Classic:ll,Zelos:zb},Bh=class{constructor(e,t,o){this.id_=e.toolboxitemid||Re(),this.level_=(this.parent_=o||null)?this.parent_.getLevel()+1:0,this.toolboxItemDef_=e,this.parentToolbox_=t,this.workspace_=this.parentToolbox_.getWorkspace()}init(){}getDiv(){return null}getClickTarget(){return null}getId(){return this.id_}getParent(){return null}getLevel(){return this.level_}isSelectable(){return!1}isCollapsible(){return!1}dispose(){}setVisible_(e){}getFocusableElement(){const e=this.getDiv();if(!e)throw Error("Trying to access toolbox item before DOM is initialized.");if(!(e instanceof HTMLElement))throw Error("Toolbox item div is unexpectedly not an HTML element.");return e}getFocusableTree(){return this.parentToolbox_}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}},ao=class extends Bh{constructor(e,t,o){super(e,t,o),this.colour_=this.name_="",this.labelDom_=this.iconDom_=this.rowContents_=this.rowDiv_=this.htmlDiv_=null,this.isDisabled_=this.isHidden_=!1,this.flyoutItems_=[],this.cssConfig_=this.makeDefaultCssConfig_()}init(){this.parseCategoryDef_(this.toolboxItemDef_),this.parseContents_(this.toolboxItemDef_),this.createDom_(),this.toolboxItemDef_.hidden==="true"&&this.hide()}makeDefaultCssConfig_(){return{container:"blocklyToolboxCategoryContainer",row:"blocklyToolboxCategory",rowcontentcontainer:"blocklyTreeRowContentContainer",icon:"blocklyToolboxCategoryIcon",label:"blocklyToolboxCategoryLabel",contents:"blocklyToolboxCategoryGroup",selected:"blocklyToolboxSelected",openicon:"blocklyToolboxCategoryIconOpen",closedicon:"blocklyToolboxCategoryIconClosed"}}parseContents_(e){if("custom"in e)this.flyoutItems_=e.custom;else if(e=e.contents)for(let t=0;t<e.length;t++){const o=e[t];Array.isArray(this.flyoutItems_)&&this.flyoutItems_.push(o)}}parseCategoryDef_(e){this.name_="name"in e?Je(e.name):"",this.colour_=this.getColour_(e),Object.assign(this.cssConfig_,e.cssconfig||e.cssConfig)}createDom_(){this.htmlDiv_=this.createContainer_(),po(this.htmlDiv_,Gt.TREEITEM),it(this.htmlDiv_,Qe.SELECTED,!1),it(this.htmlDiv_,Qe.LEVEL,this.level_+1),this.rowDiv_=this.createRowContainer_(),this.rowDiv_.style.pointerEvents="auto",this.htmlDiv_.appendChild(this.rowDiv_),this.rowContents_=this.createRowContentsContainer_(),this.rowContents_.style.pointerEvents="none",this.rowDiv_.appendChild(this.rowContents_),this.iconDom_=this.createIconDom_(),po(this.iconDom_,Gt.PRESENTATION),this.rowContents_.appendChild(this.iconDom_),this.labelDom_=this.createLabelDom_(this.name_),this.rowContents_.appendChild(this.labelDom_);const e=this.labelDom_.getAttribute("id");return e&&it(this.htmlDiv_,Qe.LABELLEDBY,e),this.addColourBorder_(this.colour_),this.htmlDiv_}createContainer_(){const e=document.createElement("div");e.tabIndex=-1,e.id=this.getId();const t=this.cssConfig_.container;return t&&G(e,t),e}createRowContainer_(){const e=document.createElement("div");var t=this.cssConfig_.row;return t&&G(e,t),t=`${ao.nestedPadding*this.getLevel()}px`,this.workspace_.RTL?e.style.paddingRight=t:e.style.paddingLeft=t,e}createRowContentsContainer_(){const e=document.createElement("div"),t=this.cssConfig_.rowcontentcontainer;return t&&G(e,t),e}createIconDom_(){const e=document.createElement("span");if(!this.parentToolbox_.isHorizontal()){const t=this.cssConfig_.icon;t&&G(e,t)}return e.style.display="inline-block",e}createLabelDom_(e){const t=document.createElement("span");return t.setAttribute("id",this.getId()+".label"),t.textContent=e,(e=this.cssConfig_.label)&&G(t,e),t}refreshTheme(){this.colour_=this.getColour_(this.toolboxItemDef_),this.addColourBorder_(this.colour_)}addColourBorder_(e){e&&(e=ao.borderWidth+"px solid "+(e||"#ddd"),this.workspace_.RTL?this.rowDiv_.style.borderRight=e:this.rowDiv_.style.borderLeft=e)}getColour_(e){const t=e.categorystyle||e.categoryStyle;if((e=e.colour)&&t)console.warn('Toolbox category "'+this.name_+'" must not have both a style and a colour');else{if(t)return this.getColourfromStyle(t);if(e)return this.parseColour(e)}return""}getColourfromStyle(e){var t=this.workspace_.getTheme();if(e&&t){if((t=t.categoryStyles[e])&&t.colour)return this.parseColour(t.colour);console.warn('Style "'+e+'" must exist and contain a colour value')}return""}getClickTarget(){return this.rowDiv_}parseColour(e){if(e=Je(e),e==null||e==="")return"";var t=Number(e);return isNaN(t)?(t=Es(e))?t:(console.warn('Toolbox category "'+this.name_+'" has unrecognized colour attribute: '+e),""):Fc(t)}openIcon_(e){if(e){var t=this.cssConfig_.closedicon;t&&Lt(e,t),(t=this.cssConfig_.openicon)&&G(e,t)}}closeIcon_(e){if(e){var t=this.cssConfig_.openicon;t&&Lt(e,t),(t=this.cssConfig_.closedicon)&&G(e,t)}}setVisible_(e){this.htmlDiv_.style.display=e?"block":"none",this.isHidden_=!e,this.parentToolbox_.getSelectedItem()===this&&this.parentToolbox_.clearSelection()}hide(){this.setVisible_(!1)}show(){this.setVisible_(!0)}isVisible(){return!this.isHidden_&&this.allAncestorsExpanded_()}allAncestorsExpanded_(){let e=this;for(;e.getParent();)if(e=e.getParent(),!e.isExpanded())return!1;return!0}isSelectable(){return this.isVisible()&&!this.isDisabled_}onClick(e){}setSelected(e){if(this.rowDiv_){var t=this.cssConfig_.selected;if(e){const o=this.parseColour(ao.defaultBackgroundColour);this.rowDiv_.style.backgroundColor=this.colour_||o,t&&G(this.rowDiv_,t)}else this.rowDiv_.style.backgroundColor="",t&&Te(this.rowDiv_,t);it(this.htmlDiv_,Qe.SELECTED,e)}}setDisabled(e){this.isDisabled_=e,this.getDiv().setAttribute("disabled",`${e}`),e?this.getDiv().setAttribute("disabled","true"):this.getDiv().removeAttribute("disabled")}getName(){return this.name_}getParent(){return this.parent_}getDiv(){return this.htmlDiv_}getContents(){return this.flyoutItems_}updateFlyoutContents(e){this.flyoutItems_=[],this.toolboxItemDef_=typeof e=="string"?{kind:this.toolboxItemDef_.kind,custom:e,id:this.toolboxItemDef_.id,categorystyle:this.toolboxItemDef_.categorystyle,colour:this.toolboxItemDef_.colour,cssconfig:this.toolboxItemDef_.cssconfig,hidden:this.toolboxItemDef_.hidden}:{kind:this.toolboxItemDef_.kind,name:"name"in this.toolboxItemDef_?this.toolboxItemDef_.name:"",contents:Bi(e),id:this.toolboxItemDef_.id,categorystyle:this.toolboxItemDef_.categorystyle,colour:this.toolboxItemDef_.colour,cssconfig:this.toolboxItemDef_.cssconfig,hidden:this.toolboxItemDef_.hidden},this.parseContents_(this.toolboxItemDef_)}dispose(){ke(this.htmlDiv_)}};ao.registrationName="category",ao.nestedPadding=19,ao.borderWidth=8,ao.defaultBackgroundColour="#57e",q(`
667
+ `)),t=t.trim().replace(this.FUNCTION_NAME_PLACEHOLDER_REGEXP_,o);let s;for(;s!==t;)s=t,t=t.replace(/^(( {2})*) {2}/gm,"$1\0");t=t.replace(/\0/g,this.INDENT),this.definitions_[e]=t}return this.functionNames_[e]}getVariableName(e){return this.getName(e,r.NameType$$module$build$src$core$names.VARIABLE)}getProcedureName(e){return this.getName(e,r.NameType$$module$build$src$core$names.PROCEDURE)}getName(e,t){if(!this.nameDB_)throw Error("Name database is not defined. You must initialize `nameDB_` in your generator class and call `init` first.");return this.nameDB_.getName(e,t)}init(e){this.definitions_=Object.create(null),this.functionNames_=Object.create(null)}scrub_(e,t,o){return t}finish(e){return this.definitions_=Object.create(null),this.functionNames_=Object.create(null),e}scrubNakedValue(e){return e}},sf={},sf.CodeGenerator=r.CodeGenerator$$module$build$src$core$generator;var Th=class extends gl{constructor(e){super(e)}setMetrics_(e){if(this.isVisible()){var t=this.workspace_.getMetricsManager(),o=t.getScrollMetrics(),s=t.getViewMetrics();t=t.getAbsoluteMetrics(),typeof e.y=="number"&&(this.workspace_.scrollY=-(o.top+(o.height-s.height)*e.y)),this.workspace_.translate(this.workspace_.scrollX+t.left,this.workspace_.scrollY+t.top)}}getX(){if(!this.isVisible())return 0;var e=this.targetWorkspace.getMetricsManager();const t=e.getAbsoluteMetrics(),o=e.getViewMetrics();return e=e.getToolboxMetrics(),this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?this.toolboxPosition_===be.LEFT?e.width:o.width-this.getWidth():this.toolboxPosition_===be.LEFT?0:o.width:this.toolboxPosition_===be.LEFT?0:o.width+t.left-this.getWidth()}getY(){return 0}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var e=this.targetWorkspace.getMetricsManager().getViewMetrics();this.height_=e.height;var t=this.getWidth()-this.CORNER_RADIUS;this.setBackgroundPath(t,e.height-2*this.CORNER_RADIUS),e=this.getX(),t=this.getY(),this.positionAt_(this.getWidth(),this.getHeight(),e,t)}}setBackgroundPath(e,t){const o=this.toolboxPosition_===be.RIGHT;var s=e+this.CORNER_RADIUS;s=["M "+(o?s:0)+",0"],s.push("h",o?-e:e),s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,o?0:1,o?-this.CORNER_RADIUS:this.CORNER_RADIUS,this.CORNER_RADIUS),s.push("v",Math.max(0,t)),s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,o?0:1,o?this.CORNER_RADIUS:-this.CORNER_RADIUS,this.CORNER_RADIUS),s.push("h",o?e:-e),s.push("z"),this.svgBackground_.setAttribute("d",s.join(" "))}scrollToStart(){let e;(e=this.workspace_.scrollbar)==null||e.setY(0)}wheel_(e){var t=It(e);if(t.y){const o=this.workspace_.getMetricsManager(),s=o.getScrollMetrics();t=o.getViewMetrics().top-s.top+t.y;let i;(i=this.workspace_.scrollbar)==null||i.setY(t),ji(this.workspace_),mo()}e.preventDefault(),e.stopPropagation()}layout_(e){this.workspace_.scale=this.targetWorkspace.scale;var t=this.MARGIN;const o=this.RTL?t:t+this.tabWidth_;for(const s of e)s.getElement().moveBy(o,t),t+=s.getElement().getBoundingRectangle().getHeight()}isDragTowardWorkspace(e){e=Math.atan2(e.y,e.x)/Math.PI*180;const t=this.dragAngleRange_;return e<t&&e>-t||e<-180+t||e>180-t}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;const e=this.svgGroup_.getBoundingClientRect(),t=e.left;return this.toolboxPosition_===be.LEFT?new ye(-1e9,1e9,-1e9,t+e.width):new ye(-1e9,1e9,t,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let e=this.getContents().reduce((t,o)=>Math.max(t,o.getElement().getBoundingRectangle().getWidth()),0);if(e+=this.MARGIN*1.5+this.tabWidth_,e*=this.workspace_.scale,e+=Ze.scrollbarThickness,this.getWidth()!==e){if(this.RTL)for(const t of this.getContents()){const o=t.getElement().getBoundingRectangle().left,s=e/this.workspace_.scale-t.getElement().getBoundingRectangle().getWidth()-this.MARGIN-this.tabWidth_;t.getElement().moveBy(s-o,0)}this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==be.LEFT||this.targetWorkspace.translate(this.targetWorkspace.scrollX+e,this.targetWorkspace.scrollY),this.width_=e,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets()}}};Th.registryName="verticalFlyout",l(M.FLYOUTS_VERTICAL_TOOLBOX,Ft,Th);var rf=class extends gl{constructor(e){super(e),this.horizontalLayout=!0}setMetrics_(e){if(this.isVisible()){var t=this.workspace_.getMetricsManager(),o=t.getScrollMetrics(),s=t.getViewMetrics();t=t.getAbsoluteMetrics(),typeof e.x=="number"&&(this.workspace_.scrollX=-(o.left+(o.width-s.width)*e.x)),this.workspace_.translate(this.workspace_.scrollX+t.left,this.workspace_.scrollY+t.top)}}getX(){return 0}getY(){if(!this.isVisible())return 0;var e=this.targetWorkspace.getMetricsManager();const t=e.getAbsoluteMetrics(),o=e.getViewMetrics();e=e.getToolboxMetrics();const s=this.toolboxPosition_===be.TOP;return this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?s?e.height:o.height-this.getHeight():s?0:o.height:s?0:o.height+t.top-this.getHeight()}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var e=this.targetWorkspace.getMetricsManager().getViewMetrics();this.width_=e.width,e=e.width-2*this.CORNER_RADIUS;var t=this.getHeight()-this.CORNER_RADIUS;this.setBackgroundPath(e,t),e=this.getX(),t=this.getY(),this.positionAt_(this.getWidth(),this.getHeight(),e,t)}}setBackgroundPath(e,t){const o=this.toolboxPosition_===be.TOP,s=["M 0,"+(o?0:this.CORNER_RADIUS)];o?(s.push("h",e+2*this.CORNER_RADIUS),s.push("v",t),s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,-this.CORNER_RADIUS,this.CORNER_RADIUS),s.push("h",-e),s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,-this.CORNER_RADIUS,-this.CORNER_RADIUS)):(s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,this.CORNER_RADIUS,-this.CORNER_RADIUS),s.push("h",e),s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,this.CORNER_RADIUS,this.CORNER_RADIUS),s.push("v",t),s.push("h",-e-2*this.CORNER_RADIUS)),s.push("z"),this.svgBackground_.setAttribute("d",s.join(" "))}scrollToStart(){let e;(e=this.workspace_.scrollbar)==null||e.setX(this.RTL?1/0:0)}wheel_(e){var t=It(e);if(t=t.x||t.y){const o=this.workspace_.getMetricsManager(),s=o.getScrollMetrics();t=o.getViewMetrics().left-s.left+t;let i;(i=this.workspace_.scrollbar)==null||i.setX(t),ji(this.workspace_),mo()}e.preventDefault(),e.stopPropagation()}layout_(e){this.workspace_.scale=this.targetWorkspace.scale;const t=this.MARGIN;let o=t+this.tabWidth_;this.RTL&&(e=e.reverse());for(const s of e)e=s.getElement().getBoundingRectangle(),e=this.RTL?o+e.getWidth():o,s.getElement().moveBy(e,t),o+=s.getElement().getBoundingRectangle().getWidth()}isDragTowardWorkspace(e){e=Math.atan2(e.y,e.x)/Math.PI*180;const t=this.dragAngleRange_;return e<90+t&&e>90-t||e>-90-t&&e<-90+t}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;const e=this.svgGroup_.getBoundingClientRect(),t=e.top;return this.toolboxPosition_===be.TOP?new ye(-1e9,t+e.height,-1e9,1e9):new ye(t,1e9,-1e9,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let e=this.getContents().reduce((t,o)=>Math.max(t,o.getElement().getBoundingRectangle().getHeight()),0);e+=this.MARGIN*1.5,e*=this.workspace_.scale,e+=Ze.scrollbarThickness,this.getHeight()!==e&&(this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==be.TOP||this.targetWorkspace.translate(this.targetWorkspace.scrollX,this.targetWorkspace.scrollY+e),this.height_=e,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets())}};l(M.FLYOUTS_HORIZONTAL_TOOLBOX,Ft,rf);var wr=class extends yt{constructor(e,t,o,s,i){super(we.SKIP_SETUP),this.defaultType="",this.variableTypes=[],this.variable=null,this.SERIALIZABLE=!0,this.menuGenerator_=wr.dropdownCreate,this.defaultVariableName=typeof e=="string"?e:"",this.size_=new ve(0,0),e!==we.SKIP_SETUP&&(i?this.configure_(i):this.setTypes(o,s),t&&this.setValidator(t))}configure_(e){super.configure_(e),this.setTypes(e.variableTypes,e.defaultType)}initModel(){var e=this.getSourceBlock();if(!e)throw new tt;this.variable||(e=r.getOrCreateVariablePackage$$module$build$src$core$variables(e.workspace,null,this.defaultVariableName,this.defaultType),this.doValueUpdate_(e.getId()))}initView(){super.initView(),G(this.fieldGroup_,"blocklyVariableField")}shouldAddBorderRect_(){const e=this.getSourceBlock();if(!e)throw new tt;return super.shouldAddBorderRect_()&&(!this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW||e.type!=="variables_get")}fromXml(e){var t=this.getSourceBlock();if(!t)throw new tt;const o=e.getAttribute("id"),s=e.textContent,i=e.getAttribute("variabletype")||e.getAttribute("variableType")||"";if(t=r.getOrCreateVariablePackage$$module$build$src$core$variables(t.workspace,o,s,i),i!==null&&i!==t.getType())throw Error("Serialized variable type with id '"+t.getId()+"' had type "+t.getType()+", and does not match variable field that references it: "+fo(e)+".");this.setValue(t.getId())}toXml(e){return this.initModel(),e.id=this.variable.getId(),e.textContent=this.variable.getName(),this.variable.getType()&&e.setAttribute("variabletype",this.variable.getType()),e}saveState(e){var t=this.saveLegacyState(wr);return t!==null||(this.initModel(),t={id:this.variable.getId()},e&&(t.name=this.variable.getName(),t.type=this.variable.getType())),t}loadState(e){const t=this.getSourceBlock();if(!t)throw new tt;this.loadLegacyState(wr,e)||(e=r.getOrCreateVariablePackage$$module$build$src$core$variables(t.workspace,e.id||null,e.name,e.type||""),this.setValue(e.getId()))}setSourceBlock(e){if(e.isShadow())throw Error("Variable fields are not allowed to exist on shadow blocks.");super.setSourceBlock(e)}getValue(){return this.variable?this.variable.getId():null}getText(){return this.variable?this.variable.getName():""}getVariable(){return this.variable}getDefaultType(){return this.defaultType}getValidator(){return this.variable?this.validator_:null}doClassValidation_(e){if(e===null)return null;var t=this.getSourceBlock();if(!t)throw new tt;return t=r.getVariable$$module$build$src$core$variables(t.workspace,e),t?(t=t.getType(),this.typeIsAllowed(t)?e:(console.warn("Variable type doesn't match this field! Type was "+t),null)):(console.warn("Variable id doesn't point to a real variable! ID was "+e),null)}doValueUpdate_(e){const t=this.getSourceBlock();if(!t)throw new tt;this.variable=r.getVariable$$module$build$src$core$variables(t.workspace,e),super.doValueUpdate_(e)}typeIsAllowed(e){const t=this.getVariableTypes();if(!t)return!0;for(let o=0;o<t.length;o++)if(e===t[o])return!0;return!1}getVariableTypes(){if(this.variableTypes)return this.variableTypes;if(!this.sourceBlock_||this.sourceBlock_.isDeadOrDying())return[""];let e=this.sourceBlock_.workspace.getVariableMap().getTypes();if(this.sourceBlock_.isInFlyout){const t=this.sourceBlock_.workspace.getPotentialVariableMap();if(!t)return e;e=Array.from(new Set([...e,...t.getTypes()]))}return e}setTypes(e=null,t=""){var o=this.getText();if(Array.isArray(e)){if(e.length===0)throw Error(`'variableTypes' of field variable ${o} was an empty list. If you want to include all variable types, pass 'null' instead.`);o=!1;for(let s=0;s<e.length;s++)e[s]===t&&(o=!0);if(!o)throw Error("Invalid default type '"+t+"' in the definition of a FieldVariable")}else if(e!==null)throw Error(`'variableTypes' was not an array or null in the definition of FieldVariable ${o}`);this.defaultType=t,this.variableTypes=e}refreshVariableName(){this.forceRerender()}onItemSelected_(e,t){if(e=t.getValue(),this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()){if(e===za&&this.variable){r.renameVariable$$module$build$src$core$variables(this.sourceBlock_.workspace,this.variable);return}if(e===Ya&&this.variable){e=this.variable.getWorkspace(),r.deleteVariable$$module$build$src$core$variables(e,this.variable,this.sourceBlock_);return}}this.setValue(e)}referencesVariables(){return!0}static fromJson(e){return new this(Je(e.variable),void 0,void 0,void 0,e)}static dropdownCreate(){if(!this.variable)throw Error("Tried to call dropdownCreate on a variable field with no variable selected.");const e=this.getText();let t=[];var o=this.getSourceBlock();if(o&&!o.isDeadOrDying()){o=o.workspace;const n=this.getVariableTypes();for(let d=0;d<n.length;d++){const f=n[d],L=o.getVariableMap().getVariablesOfType(f);if(t=t.concat(L),o.isFlyout){var s=void 0,i=void 0;t=t.concat((i=(s=o.getPotentialVariableMap())==null?void 0:s.getVariablesOfType(f))!=null?i:[])}}}for(t.sort(Js),s=[],i=0;i<t.length;i++)s[i]=[t[i].getName(),t[i].getId()];return s.push([r.Msg$$module$build$src$core$msg.RENAME_VARIABLE,za]),r.Msg$$module$build$src$core$msg.DELETE_VARIABLE&&s.push([r.Msg$$module$build$src$core$msg.DELETE_VARIABLE.replace("%1",e),Ya]),s}};_o("field_variable",wr);var Eh=class extends Ni{constructor(e,t,o,s,i,n){super(we.SKIP_SETUP),this.min_=-1/0,this.max_=1/0,this.precision_=0,this.decimalPlaces=null,this.spellcheck_=!1,e!==we.SKIP_SETUP&&(n?this.configure_(n):this.setConstraints(t,o,s),this.setValue(e),i&&this.setValidator(i))}configure_(e){super.configure_(e),this.setMinInternal(e.min),this.setMaxInternal(e.max),this.setPrecisionInternal(e.precision)}setConstraints(e,t,o){this.setMinInternal(e),this.setMaxInternal(t),this.setPrecisionInternal(o),this.setValue(this.getValue())}setMin(e){this.setMinInternal(e),this.setValue(this.getValue())}setMinInternal(e){e==null?this.min_=-1/0:(e=Number(e),isNaN(e)||(this.min_=e))}getMin(){return this.min_}setMax(e){this.setMaxInternal(e),this.setValue(this.getValue())}setMaxInternal(e){e==null?this.max_=1/0:(e=Number(e),isNaN(e)||(this.max_=e))}getMax(){return this.max_}setPrecision(e){this.setPrecisionInternal(e),this.setValue(this.getValue())}setPrecisionInternal(e){this.precision_=Number(e)||0;let t=String(this.precision_);t.includes("e")&&(t=this.precision_.toLocaleString("en-US",{maximumFractionDigits:20}));const o=t.indexOf(".");this.decimalPlaces=o===-1?e?0:null:t.length-o-1}getPrecision(){return this.precision_}doClassValidation_(e){return e===null||(e=`${e}`.replace(/O/gi,"0"),e=e.replace(/,/g,""),e=e.replace(/infinity/i,"Infinity"),e=Number(e||0),isNaN(e))?null:(e=Math.min(Math.max(e,this.min_),this.max_),this.precision_&&isFinite(e)&&(e=Math.round(e/this.precision_)*this.precision_),this.decimalPlaces!==null&&(e=Number(e.toFixed(this.decimalPlaces))),e)}widgetCreate_(){const e=super.widgetCreate_();return this.min_>-1/0&&(e.min=`${this.min_}`,it(e,Qe.VALUEMIN,this.min_)),this.max_<1/0&&(e.max=`${this.max_}`,it(e,Qe.VALUEMAX,this.max_)),e}initView(){super.initView(),this.fieldGroup_&&G(this.fieldGroup_,"blocklyNumberField")}static fromJson(e){return new this(e.value,void 0,void 0,void 0,void 0,e)}};_o("field_number",Eh),Eh.prototype.DEFAULT_VALUE=0;var nf=class extends Ps{constructor(e,t,o){super(String(e??""),t,o),this.EDITABLE=!1,this.SERIALIZABLE=!0}static fromJson(e){return new this(Je(e.text),void 0,e)}};_o("field_label_serializable",nf);var Gs=class extends we{constructor(e,t,o){super(we.SKIP_SETUP),this.SERIALIZABLE=!0,this.value_=this.value_,this.checkChar=Gs.CHECK_CHAR,e!==we.SKIP_SETUP&&(o&&this.configure_(o),this.setValue(e),t&&this.setValidator(t))}configure_(e){super.configure_(e),e.checkCharacter&&(this.checkChar=e.checkCharacter)}saveState(){const e=this.saveLegacyState(Gs);return e!==null?e:this.getValueBoolean()}initView(){super.initView();const e=this.getTextElement();G(this.fieldGroup_,"blocklyCheckboxField"),e.style.display=this.value_?"block":"none"}render_(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_()),this.updateSize_(this.getConstants().FIELD_CHECKBOX_X_OFFSET)}getDisplayText_(){return this.checkChar}setCheckCharacter(e){this.checkChar=e||Gs.CHECK_CHAR,this.forceRerender()}showEditor_(){this.setValue(!this.value_)}doClassValidation_(e){return e===!0||e==="TRUE"?"TRUE":e===!1||e==="FALSE"?"FALSE":null}doValueUpdate_(e){this.value_=this.convertValueToBool(e),this.textElement_&&(this.textElement_.style.display=this.value_?"block":"none")}getValue(){return this.value_?"TRUE":"FALSE"}getValueBoolean(){return this.value_}getText(){return String(this.convertValueToBool(this.value_))}convertValueToBool(e){return typeof e=="string"?e==="TRUE":!!e}static fromJson(e){return new this(e.checked,void 0,e)}};Gs.CHECK_CHAR="✓",_o("field_checkbox",Gs),Gs.prototype.DEFAULT_VALUE=!1;var lf=class{constructor(e,t){this.draggable=e,this.workspace=t,this.dragTarget=null,this.startLoc=e.getRelativeToSurfaceXY()}onDragStart(e){r.getGroup$$module$build$src$core$events$utils()||r.setGroup$$module$build$src$core$events$utils(!0),this.draggable.startDrag(e)}onDrag(e,t){this.moveDraggable(e,t),t=this.getRoot(this.draggable),Kt(t)&&t.setDeleteStyle(this.wouldDeleteDraggable(e,t)),this.updateDragTarget(e)}updateDragTarget(e){e=this.workspace.getDragTarget(e);const t=this.getRoot(this.draggable);if(this.dragTarget!==e){let o;(o=this.dragTarget)==null||o.onDragExit(t),e?.onDragEnter(t)}e?.onDragOver(t),this.dragTarget=e}moveDraggable(e,t){t=this.pixelsToWorkspaceUnits(t),t=P.sum(this.startLoc,t),this.draggable.drag(t,e)}wouldDeleteDraggable(e,t){return(e=this.workspace.getDragTarget(e))&&this.workspace.getComponentManager().hasCapability(e.id,Ve.Capability.DELETE_AREA)?e.wouldDelete(t):!1}onDragEnd(e){const t=r.getGroup$$module$build$src$core$events$utils();var o=this.workspace.getDragTarget(e);const s=this.getRoot(this.draggable);if(o){let i;(i=this.dragTarget)==null||i.onDrop(s)}this.shouldReturnToStart(e,s)&&this.draggable.revertDrag(),(o=Kt(s)&&this.wouldDeleteDraggable(e,s))&&this.draggable instanceof Be&&bn(this.draggable.getRootBlock()),this.draggable.endDrag(e),o&&Kt(s)&&(r.setGroup$$module$build$src$core$events$utils(t),s.dispose()),r.setGroup$$module$build$src$core$events$utils(!1),!o&&oo(this.draggable)&&r.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.draggable)}getRoot(e){return e instanceof Be?e.getRootBlock():e}shouldReturnToStart(e,t){return(e=this.workspace.getDragTarget(e))?e.shouldPreventMove(t):!1}pixelsToWorkspaceUnits(e){return e=new P(e.x/this.workspace.scale,e.y/this.workspace.scale),this.workspace.isMutator&&e.scale(1/this.workspace.options.parentWorkspace.scale),e}};l(M.BLOCK_DRAGGER,Ft,lf);var Or={};Or.BlockDragStrategy=hm,Or.BubbleDragStrategy=rm,Or.CommentDragStrategy=qg,Or.Dragger=lf;var yh=class extends Eo{constructor(e,t,o){super(e?e.workspace.id:void 0),this.type=w.BLOCK_DRAG,e&&(this.blockId=e.id,this.isStart=t,this.blocks=o)}toJson(){const e=super.toJson();if(this.isStart===void 0)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");if(this.blockId===void 0)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");return e.isStart=this.isStart,e.blockId=this.blockId,e.blocks=this.blocks,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new yh),t.isStart=e.isStart,t.blockId=e.blockId,t.blocks=e.blocks,t}};l(M.EVENT,w.BLOCK_DRAG,yh);var vh=class extends Ns{constructor(e,t,o,s){super(e),this.type=w.BLOCK_FIELD_INTERMEDIATE_CHANGE,this.recordUndo=!1,e&&(this.name=t,this.oldValue=o,this.newValue=s)}toJson(){const e=super.toJson();if(!this.name)throw Error("The changed field name is undefined. Either pass a name to the constructor, or call fromJson.");return e.name=this.name,e.oldValue=this.oldValue,e.newValue=this.newValue,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new vh),t.name=e.name,t.oldValue=e.oldValue,t.newValue=e.newValue,t}isNull(){return this.oldValue===this.newValue}run(e){var t=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");if(t=t.getBlockById(this.blockId),!t)throw Error("The associated block is undefined. Either pass a block to the constructor, or call fromJson");e=e?this.newValue:this.oldValue,(t=t.getField(this.name))?t.setValue(e):console.warn("Can't set non-existent field: "+this.name)}};l(M.EVENT,w.BLOCK_FIELD_INTERMEDIATE_CHANGE,vh);var Ih=class extends Ns{constructor(e){super(e),this.type=w.BLOCK_MOVE,e&&(e.isShadow()&&(this.recordUndo=!1),e=this.currentLocation(),this.oldParentId=e.parentId,this.oldInputName=e.inputName,this.oldCoordinate=e.coordinate)}toJson(){const e=super.toJson();return e.oldParentId=this.oldParentId,e.oldInputName=this.oldInputName,this.oldCoordinate&&(e.oldCoordinate=`${Math.round(this.oldCoordinate.x)}, ${Math.round(this.oldCoordinate.y)}`),e.newParentId=this.newParentId,e.newInputName=this.newInputName,this.newCoordinate&&(e.newCoordinate=`${Math.round(this.newCoordinate.x)}, ${Math.round(this.newCoordinate.y)}`),this.reason&&(e.reason=this.reason),this.recordUndo||(e.recordUndo=this.recordUndo),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ih),t.oldParentId=e.oldParentId,t.oldInputName=e.oldInputName,e.oldCoordinate&&(o=e.oldCoordinate.split(","),t.oldCoordinate=new P(Number(o[0]),Number(o[1]))),t.newParentId=e.newParentId,t.newInputName=e.newInputName,e.newCoordinate&&(o=e.newCoordinate.split(","),t.newCoordinate=new P(Number(o[0]),Number(o[1]))),e.reason!==void 0&&(t.reason=e.reason),e.recordUndo!==void 0&&(t.recordUndo=e.recordUndo),t}recordNew(){const e=this.currentLocation();this.newParentId=e.parentId,this.newInputName=e.inputName,this.newCoordinate=e.coordinate}setReason(e){this.reason=e}currentLocation(){var e=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");var t=e.getBlockById(this.blockId);if(!t)throw Error("The block associated with the block move event could not be found");e={};const o=t.getParent();return o?(e.parentId=o.id,(t=o.getInputWithBlock(t))&&(e.inputName=t.name)):e.coordinate=t.getRelativeToSurfaceXY(),e}isNull(){return this.oldParentId===this.newParentId&&this.oldInputName===this.newInputName&&P.equals(this.oldCoordinate,this.newCoordinate)}run(e){var t=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");var o=t.getBlockById(this.blockId);if(o){var s=e?this.newParentId:this.oldParentId,i=e?this.newInputName:this.oldInputName;if(e=e?this.newCoordinate:this.oldCoordinate,s){var n=t.getBlockById(s);if(!n){console.warn("Can't connect to non-existent block: "+s);return}}if(o.getParent()&&o.unplug(),e)i=o.getRelativeToSurfaceXY(),o.moveBy(e.x-i.x,e.y-i.y,this.reason);else{t=o.outputConnection,(!t||o.previousConnection&&o.previousConnection.isConnected())&&(t=o.previousConnection);let d,f;o=(f=t)==null?void 0:f.type,i?(o=n.getInput(i))&&(d=o.connection):o===Z.PREVIOUS_STATEMENT&&(d=n.nextConnection),d&&t?t.connect(d):console.warn("Can't connect to non-existent input: "+i)}}else console.warn("Can't move non-existent block: "+this.blockId)}};l(M.EVENT,w.BLOCK_MOVE,Ih);var Ch=class extends Eo{constructor(e,t,o){super(e?e.workspace.id:void 0),this.type=w.BUBBLE_OPEN,e&&(this.blockId=e.id,this.isOpen=t,this.bubbleType=o)}toJson(){const e=super.toJson();if(this.isOpen===void 0)throw Error("Whether this event is for opening the bubble is undefined. Either pass the value to the constructor, or call fromJson");if(!this.bubbleType)throw Error("The type of bubble is undefined. Either pass the value to the constructor, or call fromJson");return e.isOpen=this.isOpen,e.bubbleType=this.bubbleType,e.blockId=this.blockId||"",e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ch),t.isOpen=e.isOpen,t.bubbleType=e.bubbleType,t.blockId=e.blockId,t}},Sh;(function(e){e.MUTATOR="mutator",e.COMMENT="comment",e.WARNING="warning"})(Sh||(Sh={})),l(M.EVENT,w.BUBBLE_OPEN,Ch);var wo=class extends hi{constructor(e){super(),this.isBlank=!e,e&&(this.commentId=e.id,this.workspaceId=e.workspace.id,this.group=r.getGroup$$module$build$src$core$events$utils(),this.recordUndo=Ue())}toJson(){const e=super.toJson();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");return e.commentId=this.commentId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new wo),t.commentId=e.commentId,t}static CommentCreateDeleteHelper(e,t){const o=e.getEventWorkspace_();if(t){if(!e.json)throw Error("Encountered a comment event without proper json");Ui(e.json,o)}else{if(!e.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");(t=o.getCommentById(e.commentId))?t.dispose():console.warn("Can't delete non-existent comment: "+e.commentId)}}},kh=class extends wo{constructor(e,t,o){super(e),this.type=w.COMMENT_CHANGE,e&&(this.oldContents_=typeof t>"u"?"":t,this.newContents_=typeof o>"u"?"":o)}toJson(){const e=super.toJson();if(!this.oldContents_)throw Error("The old contents is undefined. Either pass a value to the constructor, or call fromJson");if(!this.newContents_)throw Error("The new contents is undefined. Either pass a value to the constructor, or call fromJson");return e.oldContents=this.oldContents_,e.newContents=this.newContents_,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new kh),t.oldContents_=e.oldContents,t.newContents_=e.newContents,t}isNull(){return this.oldContents_===this.newContents_}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(t=t.getCommentById(this.commentId)){var o=e?this.newContents_:this.oldContents_;if(o===void 0)throw Error(e?"The new contents is undefined. Either pass a value to the constructor, or call fromJson":"The old contents is undefined. Either pass a value to the constructor, or call fromJson");t.setText(o)}else console.warn("Can't change non-existent comment: "+this.commentId)}};l(M.EVENT,w.COMMENT_CHANGE,kh);var Rh=class extends wo{constructor(e,t){super(e),this.newCollapsed=t,this.type=w.COMMENT_COLLAPSE}toJson(){const e=super.toJson();if(this.newCollapsed===void 0)throw Error("The new collapse value undefined. Either call recordNew, or call fromJson");return e.newCollapsed=this.newCollapsed,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Rh),t.newCollapsed=e.newCollapsed,t}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");(t=t.getCommentById(this.commentId))?t.setCollapsed(e?!!this.newCollapsed:!this.newCollapsed):console.warn("Can't collapse or uncollapse non-existent comment: "+this.commentId)}};l(M.EVENT,w.COMMENT_COLLAPSE,Rh);var wh=class extends wo{constructor(e){super(e),this.type=w.COMMENT_CREATE,e&&(this.xml=Ji(e),this.json=js(e,{addCoordinates:!0}))}toJson(){const e=super.toJson();if(!this.xml)throw Error("The comment XML is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.json)throw Error("The comment JSON is undefined. Either pass a block to the constructor, or call fromJson");return e.xml=fo(this.xml),e.json=this.json,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new wh),t.xml=r.textToDom$$module$build$src$core$utils$xml(e.xml),t.json=e.json,t}run(e){wo.CommentCreateDeleteHelper(this,e)}};l(M.EVENT,w.COMMENT_CREATE,wh);var Oh=class extends wo{constructor(e){super(e),this.type=w.COMMENT_DELETE,e&&(this.xml=Ji(e),this.json=js(e,{addCoordinates:!0}))}run(e){wo.CommentCreateDeleteHelper(this,!e)}toJson(){const e=super.toJson();if(!this.xml)throw Error("The comment XML is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.json)throw Error("The comment JSON is undefined. Either pass a block to the constructor, or call fromJson");return e.xml=fo(this.xml),e.json=this.json,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Oh),t.xml=r.textToDom$$module$build$src$core$utils$xml(e.xml),t.json=e.json,t}};l(M.EVENT,w.COMMENT_DELETE,Oh);var Nh=class extends Eo{constructor(e,t){super(e?e.workspace.id:void 0),this.type=w.COMMENT_DRAG,e&&(this.commentId=e.id,this.isStart=t)}toJson(){const e=super.toJson();if(this.isStart===void 0)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");if(this.commentId===void 0)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");return e.isStart=this.isStart,e.commentId=this.commentId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Nh),t.isStart=e.isStart,t.commentId=e.commentId,t}};l(M.EVENT,w.COMMENT_DRAG,Nh);var Ah=class extends wo{constructor(e){super(e),this.type=w.COMMENT_MOVE,e&&(this.comment_=e,this.oldCoordinate_=e.getRelativeToSurfaceXY())}recordNew(){if(this.newCoordinate_)throw Error("Tried to record the new position of a comment on the same event twice.");if(!this.comment_)throw Error("The comment is undefined. Pass a comment to the constructor if you want to use the record functionality");this.newCoordinate_=this.comment_.getRelativeToSurfaceXY()}setReason(e){this.reason=e}setOldCoordinate(e){this.oldCoordinate_=e}toJson(){const e=super.toJson();if(!this.oldCoordinate_)throw Error("The old comment position is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.newCoordinate_)throw Error("The new comment position is undefined. Either call recordNew, or call fromJson");return e.oldCoordinate=`${Math.round(this.oldCoordinate_.x)}, ${Math.round(this.oldCoordinate_.y)}`,e.newCoordinate=Math.round(this.newCoordinate_.x)+","+Math.round(this.newCoordinate_.y),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ah),o=e.oldCoordinate.split(","),t.oldCoordinate_=new P(Number(o[0]),Number(o[1])),o=e.newCoordinate.split(","),t.newCoordinate_=new P(Number(o[0]),Number(o[1])),t}isNull(){return P.equals(this.oldCoordinate_,this.newCoordinate_)}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(t=t.getCommentById(this.commentId)){if(e=e?this.newCoordinate_:this.oldCoordinate_,!e)throw Error("Either oldCoordinate_ or newCoordinate_ is undefined. Either pass a comment to the constructor and call recordNew, or call fromJson");t.moveTo(e)}else console.warn("Can't move non-existent comment: "+this.commentId)}};l(M.EVENT,w.COMMENT_MOVE,Ah);var Lh=class extends wo{constructor(e){super(e),this.type=w.COMMENT_RESIZE,e&&(this.oldSize=e.getSize())}recordCurrentSizeAsNewSize(){if(this.newSize)throw Error("Tried to record the new size of a comment on the same event twice.");var e=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(e=e.getCommentById(this.commentId),!e)throw Error("The comment associated with the comment resize event could not be found");this.newSize=e.getSize()}toJson(){const e=super.toJson();if(!this.oldSize)throw Error("The old comment size is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.newSize)throw Error("The new comment size is undefined. Either call recordCurrentSizeAsNewSize, or call fromJson");return e.oldWidth=Math.round(this.oldSize.width),e.oldHeight=Math.round(this.oldSize.height),e.newWidth=Math.round(this.newSize.width),e.newHeight=Math.round(this.newSize.height),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Lh),t.oldSize=new ve(e.oldWidth,e.oldHeight),t.newSize=new ve(e.newWidth,e.newHeight),t}isNull(){return ve.equals(this.oldSize,this.newSize)}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(t=t.getCommentById(this.commentId)){if(e=e?this.newSize:this.oldSize,!e)throw Error("Either oldSize or newSize is undefined. Either pass a comment to the constructor and call recordCurrentSizeAsNewSize, or call fromJson");t.setSize(e)}else console.warn("Can't resize non-existent comment: "+this.commentId)}};l(M.EVENT,w.COMMENT_RESIZE,Lh);var Mh=class extends Eo{constructor(e,t,o){super(o),this.type=w.TOOLBOX_ITEM_SELECT,this.oldItem=e??void 0,this.newItem=t??void 0}toJson(){const e=super.toJson();return e.oldItem=this.oldItem,e.newItem=this.newItem,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Mh),t.oldItem=e.oldItem,t.newItem=e.newItem,t}};l(M.EVENT,w.TOOLBOX_ITEM_SELECT,Mh);var Dh=class extends Ri{constructor(e,t,o){super(e),this.oldType=t,this.newType=o,this.type=w.VAR_TYPE_CHANGE}toJson(){const e=super.toJson();if(!this.oldType||!this.newType)throw Error("The variable's types are undefined. Either pass them to the constructor, or call fromJson");return e.oldType=this.oldType,e.newType=this.newType,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Dh),t.oldType=e.oldType,t.newType=e.newType,t}run(e){const t=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.oldType||!this.newType)throw Error("The variable's types are undefined. Either pass them to the constructor, or call fromJson");const o=t.getVariableMap().getVariableById(this.varId);o&&(e?t.getVariableMap().changeVariableType(o,this.newType):t.getVariableMap().changeVariableType(o,this.oldType))}};l(M.EVENT,w.VAR_TYPE_CHANGE,Dh);var cf=class extends hi{constructor(e){super(),this.isBlank=!0,this.recordUndo=!1,this.type=w.FINISHED_LOADING,this.isBlank=!!e,e&&(this.workspaceId=e.id)}};l(M.EVENT,w.FINISHED_LOADING,cf);var uf,af,hf,df,$f,pf,gf,mf,ff,_f,bf,Tf,Ef,yf,vf,If,Cf,Sf,kf,Rf,wf,Of,Nf,Af,j;r.BLOCK_CHANGE$$module$build$src$core$events$events=w.BLOCK_CHANGE,r.BLOCK_CREATE$$module$build$src$core$events$events=w.BLOCK_CREATE,r.BLOCK_DELETE$$module$build$src$core$events$events=w.BLOCK_DELETE,uf=w.BLOCK_DRAG,r.BLOCK_MOVE$$module$build$src$core$events$events=w.BLOCK_MOVE,af=w.BLOCK_FIELD_INTERMEDIATE_CHANGE,hf=w.BUBBLE_OPEN,df=w.BLOCK_CHANGE,$f=w.CLICK,pf=w.COMMENT_CHANGE,gf=w.COMMENT_CREATE,mf=w.COMMENT_DELETE,ff=w.COMMENT_MOVE,_f=w.COMMENT_RESIZE,bf=w.COMMENT_DRAG,Tf=w.BLOCK_CREATE,Ef=w.BLOCK_DELETE,yf=w.FINISHED_LOADING,vf=w.BLOCK_MOVE,If=w.SELECTED,Cf=w.THEME_CHANGE,Sf=w.TOOLBOX_ITEM_SELECT,kf=w.TRASHCAN_OPEN,Rf=w.UI,wf=w.VAR_CREATE,Of=w.VAR_DELETE,Nf=w.VAR_RENAME,Af=w.VIEWPORT_CHANGE,j={},j.Abstract=hi,j.BLOCK_CHANGE=r.BLOCK_CHANGE$$module$build$src$core$events$events,j.BLOCK_CREATE=r.BLOCK_CREATE$$module$build$src$core$events$events,j.BLOCK_DELETE=r.BLOCK_DELETE$$module$build$src$core$events$events,j.BLOCK_DRAG=uf,j.BLOCK_FIELD_INTERMEDIATE_CHANGE=af,j.BLOCK_MOVE=r.BLOCK_MOVE$$module$build$src$core$events$events,j.BUBBLE_OPEN=hf,j.BUMP_EVENTS=Jp,j.BlockBase=Ns,j.BlockChange=As,j.BlockCreate=Ua,j.BlockDelete=Wa,j.BlockDrag=yh,j.BlockFieldIntermediateChange=vh,j.BlockMove=Ih,j.BubbleOpen=Ch,j.BubbleType=Sh,j.CHANGE=df,j.CLICK=$f,j.COMMENT_CHANGE=pf,j.COMMENT_CREATE=gf,j.COMMENT_DELETE=mf,j.COMMENT_DRAG=bf,j.COMMENT_MOVE=ff,j.COMMENT_RESIZE=_f,j.CREATE=Tf,j.Click=aa,j.ClickTarget=ha,j.CommentBase=wo,j.CommentChange=kh,j.CommentCollapse=Rh,j.CommentCreate=wh,j.CommentDelete=Oh,j.CommentDrag=Nh,j.CommentMove=Ah,j.CommentResize=Lh,j.DELETE=Ef,j.FINISHED_LOADING=yf,j.FinishedLoading=cf,j.MOVE=vf,j.SELECTED=If,j.Selected=Va,j.THEME_CHANGE=Cf,j.TOOLBOX_ITEM_SELECT=Sf,j.TRASHCAN_OPEN=kf,j.ThemeChange=Ha,j.ToolboxItemSelect=Mh,j.TrashcanOpen=ph,j.UI=Rf,j.UiBase=Eo,j.VAR_CREATE=wf,j.VAR_DELETE=Of,j.VAR_RENAME=Nf,j.VIEWPORT_CHANGE=Af,j.VarBase=Ri,j.VarCreate=hh,j.VarDelete=dh,j.VarRename=$h,j.VarTypeChange=Dh,j.ViewportChange=Ga,j.clearPendingUndo=he,j.disable=r.disable$$module$build$src$core$events$utils,j.disableOrphans=Xe,j.enable=r.enable$$module$build$src$core$events$utils,j.filter=le,j.fire=_,j.fromJson=_e,j.get=U,j.getDescendantIds=ce,j.getGroup=r.getGroup$$module$build$src$core$events$utils,j.getRecordUndo=Ue,j.isEnabled=J,j.setGroup=r.setGroup$$module$build$src$core$events$utils,j.setRecordUndo=r.setRecordUndo$$module$build$src$core$events$utils;var Oo={};Oo.BottomRow=Jm,Oo.ConstantProvider=jm,Oo.Drawer=Km,Oo.PathObject=ef,Oo.RenderInfo=Qm,Oo.Renderer=bh,Oo.RightConnectionShape=qm,Oo.StatementInput=wl,Oo.TopRow=Zm,ta();var dt={};dt.registerCleanup=Fu,dt.registerCollapse=Hu,dt.registerCollapseExpandBlock=ju,dt.registerComment=Yu,dt.registerCommentCreate=ea,dt.registerCommentDelete=Zu,dt.registerCommentDuplicate=Qu,dt.registerCommentOptions=Ap,dt.registerDefaultOptions=ta,dt.registerDelete=Ju,dt.registerDeleteAll=Wu,dt.registerDisable=Ku,dt.registerDuplicate=zu,dt.registerExpand=Gu,dt.registerHelp=qu,dt.registerInline=Xu,dt.registerRedo=Pu,dt.registerUndo=Bu;var xh="button",Lf=class{load(e,t){return e=new xt(t.getWorkspace(),t.targetWorkspace,e,!1),e.show(),new Ci(e,xh)}gapForItem(e,t){return t}disposeItem(e){e=e.getElement(),e instanceof xt&&e.dispose()}getType(){return xh}};l(M.FLYOUT_INFLATER,xh,Lf);var Nr={};Nr.Bubble=Oe,Nr.MiniWorkspaceBubble=Wo,Nr.TextBubble=dm,Nr.TextInputBubble=eh;var zb="WORKSPACE_AT_BLOCK_CAPACITY",Bh="block",Mf=class{constructor(){this.permanentlyDisabledBlocks=new Set,this.listeners=new Map,this.capacityWrapper=this.filterFlyoutBasedOnCapacity.bind(this)}load(e,t){return this.setFlyout(t),e=this.createBlock(e,t.getWorkspace()),e.isEnabled()?this.updateStateBasedOnCapacity(e):this.permanentlyDisabledBlocks.add(e),e.getDescendants(!1).forEach(o=>o.isInFlyout=!0),this.addBlockListeners(e),new Ci(e,Bh)}createBlock(e,t){return e.blockxml?(e=typeof e.blockxml=="string"?r.textToDom$$module$build$src$core$utils$xml(e.blockxml):e.blockxml,t=Is(e,t)):(e.enabled===void 0&&(e.enabled=e.disabled!=="true"&&e.disabled!==!0),e.disabledReasons===void 0&&e.enabled===!1&&(e.disabledReasons=[Jt]),"x"in e&&delete e.x,"y"in e&&delete e.y,t=Zs(e,t)),t}gapForItem(e,t){let o;return e.gap?o=parseInt(String(e.gap)):e.blockxml&&(e=typeof e.blockxml=="string"?r.textToDom$$module$build$src$core$utils$xml(e.blockxml):e.blockxml,o=parseInt(e.getAttribute("gap"))),!o||isNaN(o)?t:o}disposeItem(e){e=e.getElement(),e instanceof Be&&(this.removeListeners(e.id),e.dispose(!1,!1))}removeListeners(e){let t;((t=this.listeners.get(e))!=null?t:[]).forEach(o=>te(o)),this.listeners.delete(e)}setFlyout(e){if(this.flyout!==e){if(this.flyout){let o;(o=this.flyout.targetWorkspace)==null||o.removeChangeListener(this.capacityWrapper)}this.flyout=e;var t;(t=this.flyout.targetWorkspace)==null||t.addChangeListener(this.capacityWrapper)}}updateStateBasedOnCapacity(e){let t,o;const s=(t=this.flyout)==null||(o=t.targetWorkspace)==null?void 0:o.isCapacityAvailable(io(e));for(;e;)e.setDisabledReason(!s,zb),e=e.getNextBlock()}addBlockListeners(e){const t=[];t.push(z(e.getSvgRoot(),"pointerdown",e,o=>{let s,i;const n=(s=this.flyout)==null||(i=s.targetWorkspace)==null?void 0:i.getGesture(o);n&&this.flyout&&(n.setStartBlock(e),n.handleFlyoutStart(o,this.flyout))})),t.push(ae(e.getSvgRoot(),"pointermove",null,()=>{let o,s;!((o=this.flyout)==null||(s=o.targetWorkspace)==null)&&s.isDragging()||e.addSelect()})),t.push(ae(e.getSvgRoot(),"pointerleave",null,()=>{let o,s;!((o=this.flyout)==null||(s=o.targetWorkspace)==null)&&s.isDragging()||e.removeSelect()})),this.listeners.set(e.id,t)}filterFlyoutBasedOnCapacity(e){!this.flyout||e&&e.type!==w.BLOCK_CREATE&&e.type!==w.BLOCK_DELETE||this.flyout.getWorkspace().getTopBlocks(!1).forEach(t=>{this.permanentlyDisabledBlocks.has(t)||this.updateStateBasedOnCapacity(t)})}getType(){return Bh}};l(M.FLYOUT_INFLATER,Bh,Mf);var Df=class extends El{constructor(){super(),this.FIELD_TEXT_BASELINE_CENTER=!1,this.DARK_PATH_OFFSET=1,this.MAX_BOTTOM_WIDTH=30,this.STATEMENT_BOTTOM_SPACER=-this.NOTCH_HEIGHT/2}getCSS_(e){return super.getCSS_(e).concat([`${e} .blocklyInsertionMarker>.blocklyPathLight,`,`${e} .blocklyInsertionMarker>.blocklyPathDark {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"])}},xf=class{constructor(e){this.inlineSteps_=this.steps_="",this.info_=e,this.RTL_=this.info_.RTL,e=e.getRenderer(),this.constants_=e.getConstants(),this.highlightConstants_=e.getHighlightConstants(),this.highlightOffset=this.highlightConstants_.OFFSET,this.outsideCornerPaths_=this.highlightConstants_.OUTSIDE_CORNER,this.insideCornerPaths_=this.highlightConstants_.INSIDE_CORNER,this.puzzleTabPaths_=this.highlightConstants_.PUZZLE_TAB,this.notchPaths_=this.highlightConstants_.NOTCH,this.startPaths_=this.highlightConstants_.START_HAT,this.jaggedTeethPaths_=this.highlightConstants_.JAGGED_TEETH}getPath(){return this.steps_+`
668
+ `+this.inlineSteps_}drawTopCorner(e){this.steps_+=je(e.xPos,this.info_.startY);for(let t=0,o;o=e.elements[t];t++)T.isLeftSquareCorner(o)?this.steps_+=this.highlightConstants_.START_POINT:T.isLeftRoundedCorner(o)?this.steps_+=this.outsideCornerPaths_.topLeft(this.RTL_):T.isPreviousConnection(o)?this.steps_+=this.notchPaths_.pathLeft:T.isHat(o)?this.steps_+=this.startPaths_.path(this.RTL_):T.isSpacer(o)&&o.width!==0&&(this.steps_+=re("H",o.xPos+o.width-this.highlightOffset));this.steps_+=re("H",e.xPos+e.width-this.highlightOffset)}drawJaggedEdge_(e){this.info_.RTL&&(this.steps_+=this.jaggedTeethPaths_.pathLeft+re("v",e.height-this.jaggedTeethPaths_.height-this.highlightOffset))}drawValueInput(e){const t=e.getLastInput();if(this.RTL_){const o=e.height-t.connectionHeight;this.steps_+=gt(t.xPos+t.width-this.highlightOffset,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)+re("v",o)}else this.steps_+=gt(t.xPos+t.width,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)}drawStatementInput(e){const t=e.getLastInput();if(t)if(this.RTL_){const o=e.height-2*this.insideCornerPaths_.height;this.steps_+=gt(t.xPos,e.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+re("v",o)+this.insideCornerPaths_.pathBottom(this.RTL_)+bo(e.width-t.xPos-this.insideCornerPaths_.width,0)}else this.steps_+=gt(t.xPos,e.yPos+e.height)+this.insideCornerPaths_.pathBottom(this.RTL_)+bo(e.width-t.xPos-this.insideCornerPaths_.width,0)}drawRightSideRow(e){const t=e.xPos+e.width-this.highlightOffset;e instanceof ch&&e.followsStatement&&(this.steps_+=re("H",t)),this.RTL_&&(this.steps_+=re("H",t),e.height>this.highlightOffset&&(this.steps_+=re("V",e.yPos+e.height-this.highlightOffset)))}drawBottomRow(e){if(this.RTL_)this.steps_+=re("V",e.baseline-this.highlightOffset);else{const t=this.info_.bottomRow.elements[0];T.isLeftSquareCorner(t)?this.steps_+=gt(e.xPos+this.highlightOffset,e.baseline-this.highlightOffset):T.isLeftRoundedCorner(t)&&(this.steps_+=gt(e.xPos,e.baseline),this.steps_+=this.outsideCornerPaths_.bottomLeft())}}drawLeft(){var e=this.info_.outputConnection;e&&(e=e.connectionOffsetY+e.height,this.RTL_?this.steps_+=gt(this.info_.startX,e):(this.steps_+=gt(this.info_.startX+this.highlightOffset,this.info_.bottomRow.baseline-this.highlightOffset),this.steps_+=re("V",e)),this.steps_+=this.puzzleTabPaths_.pathUp(this.RTL_)),this.RTL_||(e=this.info_.topRow,T.isLeftRoundedCorner(e.elements[0])?this.steps_+=re("V",this.outsideCornerPaths_.height):this.steps_+=re("V",e.capline+this.highlightOffset))}drawInlineInput(e){const t=this.highlightOffset,o=e.xPos+e.connectionWidth;var s=e.centerline-e.height/2;const i=e.width-e.connectionWidth,n=s+t;this.RTL_?(s=e.connectionOffsetY-t,e=e.height-(e.connectionOffsetY+e.connectionHeight)+t,this.inlineSteps_+=gt(o-t,n)+re("v",s)+this.puzzleTabPaths_.pathDown(this.RTL_)+re("v",e)+re("h",i)):this.inlineSteps_+=gt(e.xPos+e.width+t,n)+re("v",e.height)+re("h",-i)+gt(o,s+e.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)}},Bf=class extends yl{constructor(e,t){super(e,t),this.highlighter_=new xf(t)}draw(){this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights();const e=this.block_.pathObject;e.setPath(this.outlinePath_+`
669
+ `+this.inlinePath_),e.setHighlightPath(this.highlighter_.getPath()),this.info_.RTL&&e.flipRTL(),this.recordSizeOnBlock_()}drawTop_(){this.highlighter_.drawTopCorner(this.info_.topRow),this.highlighter_.drawRightSideRow(this.info_.topRow),super.drawTop_()}drawJaggedEdge_(e){this.highlighter_.drawJaggedEdge_(e),super.drawJaggedEdge_(e)}drawValueInput_(e){this.highlighter_.drawValueInput(e),super.drawValueInput_(e)}drawStatementInput_(e){this.highlighter_.drawStatementInput(e),super.drawStatementInput_(e)}drawRightSideRow_(e){this.highlighter_.drawRightSideRow(e),this.outlinePath_+=re("H",e.xPos+e.width)+re("V",e.yPos+e.height)}drawBottom_(){this.highlighter_.drawBottomRow(this.info_.bottomRow),super.drawBottom_()}drawLeft_(){this.highlighter_.drawLeft(),super.drawLeft_()}drawInlineInput_(e){this.highlighter_.drawInlineInput(e),super.drawInlineInput_(e)}positionInlineInputConnection_(e){const t=e.centerline-e.height/2;if(e.connectionModel){let o=e.xPos+e.connectionWidth+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(o*=-1),e.connectionModel.setOffsetInBlock(o,t+e.connectionOffsetY+this.constants_.DARK_PATH_OFFSET)}}positionStatementInputConnection_(e){const t=e.getLastInput();if(t!=null&&t.connectionModel){let o=e.xPos+e.statementEdge+t.notchOffset;o=this.info_.RTL?o*-1:o+this.constants_.DARK_PATH_OFFSET,t.connectionModel.setOffsetInBlock(o,e.yPos+this.constants_.DARK_PATH_OFFSET)}}positionExternalValueConnection_(e){const t=e.getLastInput();if(t&&t.connectionModel){let o=e.xPos+e.width+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(o*=-1),t.connectionModel.setOffsetInBlock(o,e.yPos)}}positionNextConnection_(){const e=this.info_.bottomRow;if(e.connection){const t=e.connection,o=t.xPos;t.connectionModel.setOffsetInBlock((this.info_.RTL?-o:o)+this.constants_.DARK_PATH_OFFSET/2,e.baseline+this.constants_.DARK_PATH_OFFSET)}}},Pf=class{constructor(e){this.OFFSET=.5,this.constantProvider=e,this.START_POINT=je(this.OFFSET,this.OFFSET)}init(){this.INSIDE_CORNER=this.makeInsideCorner(),this.OUTSIDE_CORNER=this.makeOutsideCorner(),this.PUZZLE_TAB=this.makePuzzleTab(),this.NOTCH=this.makeNotch(),this.JAGGED_TEETH=this.makeJaggedTeeth(),this.START_HAT=this.makeStartHat()}makeInsideCorner(){const e=this.constantProvider.CORNER_RADIUS,t=this.OFFSET,o=(1-Math.SQRT1_2)*(e+t)-t,s=je(o,o)+qe("a","0 0,0",e,se(-o-t,e-o)),i=qe("a","0 0,0",e+t,se(e+t,e+t)),n=je(o,-o)+qe("a","0 0,0",e+t,se(e-o,o+t));return{width:e+t,height:e,pathTop(d){return d?s:""},pathBottom(d){return d?i:n}}}makeOutsideCorner(){const e=this.constantProvider.CORNER_RADIUS,t=this.OFFSET,o=(1-Math.SQRT1_2)*(e-t)+t,s=je(o,o)+qe("a","0 0,1",e-t,se(e-o,-o+t)),i=je(t,e)+qe("a","0 0,1",e-t,se(e,-e+t)),n=-o,d=je(o,n)+qe("a","0 0,1",e-t,se(-o+t,-n-e));return{height:e,topLeft(f){return f?s:i},bottomLeft(){return d}}}makePuzzleTab(){const e=this.constantProvider.TAB_WIDTH,t=this.constantProvider.TAB_HEIGHT,o=je(-2,-t+2.5+.9)+bo(e*-.45,-2.1),s=re("v",2.5)+je(-e*.97,2.5)+Pt("q",[se(-e*.05,10),se(e*.3,9.5)])+je(e*.67,-1.9)+re("v",2.5),i=re("v",-1.5)+je(e*-.92,-.5)+Pt("q",[se(e*-.19,-5.5),se(0,-11)])+je(e*.92,1),n=je(-5,t-.7)+bo(e*.46,-2.1);return{width:e,height:t,pathUp(d){return d?o:i},pathDown(d){return d?s:n}}}makeNotch(){return{pathLeft:re("h",this.OFFSET)+this.constantProvider.NOTCH.pathLeft}}makeJaggedTeeth(){return{pathLeft:bo(5.1,2.6)+je(-10.2,6.8)+bo(5.1,2.6),height:12,width:10.2}}makeStartHat(){const e=this.constantProvider.START_HAT.height,t=je(25,-8.7)+Pt("c",[se(29.7,-6.2),se(57.2,-.5),se(75,8.7)]),o=Pt("c",[se(17.8,-9.2),se(45.3,-14.9),se(75,-8.7)])+gt(100.5,e+.5);return{path(s){return s?t:o}}}},Ff=class extends nh{constructor(e,t){super(e,t),this.constants_=e,this.connectedBlock&&(this.width+=this.constants_.DARK_PATH_OFFSET,this.height+=this.constants_.DARK_PATH_OFFSET)}},Uf=class extends Tl{constructor(e,t){super(e,t),this.constants_=e,this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}},Hf=class extends Sr{constructor(e,t){super(e,t),this.renderer_=e}getRenderer(){return this.renderer_}populateBottomRow_(){super.populateBottomRow_(),this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof Yt||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(e,t){this.isInline&&e instanceof r.ValueInput$$module$build$src$core$inputs$value_input?(t.elements.push(new Ff(this.constants_,e)),t.hasInlineInput=!0):e instanceof Yt?(t.elements.push(new Uf(this.constants_,e)),t.hasStatement=!0):e instanceof r.ValueInput$$module$build$src$core$inputs$value_input?(t.elements.push(new ih(this.constants_,e)),t.hasExternalInput=!0):(e instanceof Io||e instanceof Yo)&&(t.minHeight=Math.max(t.minHeight,this.constants_.DUMMY_INPUT_MIN_HEIGHT),t.hasDummyInput=!0),this.isInline||t.align!==null||(t.align=e.align)}addElemSpacing_(){let e=!1;for(let o=0,s;s=this.rows[o];o++)s.hasExternalInput&&(e=!0);for(let o=0,s;s=this.rows[o];o++){var t=s.elements;if(s.elements=[],s.startsWithElemSpacer()&&s.elements.push(new Xt(this.constants_,this.getInRowSpacing_(null,t[0]))),t.length){for(let i=0;i<t.length-1;i++){s.elements.push(t[i]);const n=this.getInRowSpacing_(t[i],t[i+1]);s.elements.push(new Xt(this.constants_,n))}s.elements.push(t[t.length-1]),s.endsWithElemSpacer()&&(t=this.getInRowSpacing_(t[t.length-1],null),e&&s.hasDummyInput&&(t+=this.constants_.TAB_WIDTH),s.elements.push(new Xt(this.constants_,t)))}}}getInRowSpacing_(e,t){if(!e)return t&&T.isField(t)&&t.isEditable?this.constants_.MEDIUM_PADDING:t&&T.isInlineInput(t)?this.constants_.MEDIUM_LARGE_PADDING:t&&T.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!T.isInput(e)&&(!t||T.isStatementInput(t)))return T.isField(e)&&e.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:T.isIcon(e)?this.constants_.LARGE_PADDING*2+1:T.isHat(e)?this.constants_.NO_PADDING:T.isPreviousOrNextConnection(e)?this.constants_.LARGE_PADDING:T.isLeftRoundedCorner(e)?this.constants_.MIN_BLOCK_WIDTH:T.isJaggedEdge(e)?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING;if(T.isInput(e)&&!t){if(T.isExternalInput(e))return this.constants_.NO_PADDING;if(T.isInlineInput(e))return this.constants_.LARGE_PADDING;if(T.isStatementInput(e))return this.constants_.NO_PADDING}if(!T.isInput(e)&&t&&T.isInput(t)){if(T.isField(e)&&e.isEditable){if(T.isInlineInput(t)||T.isExternalInput(t))return this.constants_.SMALL_PADDING}else{if(T.isInlineInput(t)||T.isExternalInput(t))return this.constants_.MEDIUM_LARGE_PADDING;if(T.isStatementInput(t))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-1}if(T.isIcon(e)&&t&&!T.isInput(t))return this.constants_.LARGE_PADDING;if(T.isInlineInput(e)&&t&&T.isField(t))return t.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;if(T.isLeftSquareCorner(e)&&t){if(T.isHat(t))return this.constants_.NO_PADDING;if(T.isPreviousConnection(t))return t.notchOffset;if(T.isNextConnection(t))return t.notchOffset+(this.RTL?1:-1)*this.constants_.DARK_PATH_OFFSET/2}if(T.isLeftRoundedCorner(e)&&t){if(T.isPreviousConnection(t))return t.notchOffset-this.constants_.CORNER_RADIUS;if(T.isNextConnection(t))return t.notchOffset-this.constants_.CORNER_RADIUS+(this.RTL?1:-1)*this.constants_.DARK_PATH_OFFSET/2}return T.isField(e)&&t&&T.isField(t)&&e.isEditable===t.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING:t&&T.isJaggedEdge(t)?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getSpacerRowHeight_(e,t){return T.isTopRow(e)&&T.isBottomRow(t)?this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:T.isTopRow(e)||T.isBottomRow(t)?this.constants_.NO_PADDING:e.hasExternalInput&&t.hasExternalInput?this.constants_.LARGE_PADDING:!e.hasStatement&&t.hasStatement?this.constants_.BETWEEN_STATEMENT_PADDING_Y:e.hasStatement&&t.hasStatement||!e.hasStatement&&t.hasDummyInput||e.hasDummyInput?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getElemCenterline_(e,t){if(T.isSpacer(t))return e.yPos+t.height/2;if(T.isBottomRow(e))return e=e.yPos+e.height-e.descenderHeight,T.isNextConnection(t)?e+t.height/2:e-t.height/2;if(T.isTopRow(e))return T.isHat(t)?e.capline-t.height/2:e.capline+t.height/2;let o=e.yPos;return T.isField(t)||T.isIcon(t)?(o+=t.height/2,(e.hasInlineInput||e.hasStatement)&&t.height+this.constants_.TALL_INPUT_FIELD_OFFSET_Y<=e.height&&(o+=this.constants_.TALL_INPUT_FIELD_OFFSET_Y)):o=T.isInlineInput(t)?o+t.height/2:o+e.height/2,o}alignRowElements_(){if(this.isInline){var e=0,t=new WeakMap,o=null;for(let s=this.rows.length-1,i;i=this.rows[s];s--)t.set(i,e),T.isInputRow(i)&&(i.hasStatement&&this.alignStatementRow_(i),o&&o.hasStatement&&i.width<o.width?t.set(i,o.width):e=i.hasStatement?i.width:Math.max(e,i.width),o=i);e=0;for(let s=0,i;i=this.rows[s];s++)i.hasStatement?e=this.getDesiredRowWidth_(i):T.isSpacer(i)?i.width=Math.max(e,t.get(i)):(o=i.width,e=Math.max(e,t.get(i))-o,e>0&&this.addAlignmentPadding_(i,e),e=i.width)}else super.alignRowElements_()}getDesiredRowWidth_(e){return this.isInline&&e.hasStatement?this.statementEdge+this.constants_.MAX_BOTTOM_WIDTH+this.startX:super.getDesiredRowWidth_(e)}finalize_(){let e=0,t=0;for(let s=0,i;i=this.rows[s];s++){i.yPos=t,i.xPos=this.startX,t+=i.height,e=Math.max(e,i.widthWithConnectedBlocks);var o=t-this.topRow.ascenderHeight;i===this.bottomRow&&o<this.constants_.MIN_BLOCK_HEIGHT&&(o=this.constants_.MIN_BLOCK_HEIGHT-o,this.bottomRow.height+=o,t+=o),this.recordElemPositions_(i)}this.outputConnection&&this.block_.nextConnection&&this.block_.nextConnection.isConnected()&&(o=this.block_.nextConnection.targetBlock())&&(e=Math.max(e,o.getHeightWidth().width-this.constants_.DARK_PATH_OFFSET)),this.bottomRow.baseline=t-this.bottomRow.descenderHeight,this.widthWithChildren=e+this.startX+this.constants_.DARK_PATH_OFFSET,this.width+=this.constants_.DARK_PATH_OFFSET,this.height=t+this.constants_.DARK_PATH_OFFSET,this.startY=this.topRow.capline}},Gf=class extends vl{constructor(e,t,o){super(e,t,o),this.constants=o,this.colourDark="#000000",this.svgPathDark=v(R.PATH,{class:"blocklyPathDark",transform:"translate(1,1)"}),this.svgRoot.insertBefore(this.svgPathDark,this.svgPath),this.svgPathLight=v(R.PATH,{class:"blocklyPathLight"},this.svgRoot)}setPath(e){this.svgPath.setAttribute("d",e),this.svgPathDark.setAttribute("d",e)}setHighlightPath(e){this.svgPathLight.setAttribute("d",e)}flipRTL(){this.svgPath.setAttribute("transform","scale(-1 1)"),this.svgPathLight.setAttribute("transform","scale(-1 1)"),this.svgPathDark.setAttribute("transform","translate(1,1) scale(-1 1)")}applyColour(e){if(this.svgPathLight.style.display="",this.svgPathDark.style.display="",!this.style.colourTertiary)throw Error("The renderer did not properly initialize the tertiary colour of the block style");this.svgPathLight.setAttribute("stroke",this.style.colourTertiary),this.svgPathDark.setAttribute("fill",this.colourDark),super.applyColour(e),this.svgPath.setAttribute("stroke","none")}setStyle(e){this.style=e,this.colourDark=ys("#000",this.style.colourPrimary,.2)||this.colourDark}updateHighlighted(e){super.updateHighlighted(e),this.svgPathLight.style.display=e?"none":"inline"}updateShadow_(e){if(e){if(this.svgPathLight.style.display="none",!this.style.colourSecondary)throw Error("The renderer did not properly initialize the secondary colour of the block style block style");this.svgPathDark.setAttribute("fill",this.style.colourSecondary),this.svgPath.setAttribute("stroke","none"),this.svgPath.setAttribute("fill",this.style.colourSecondary)}}updateDisabled_(e){super.updateDisabled_(e),e&&this.svgPath.setAttribute("stroke","none")}},Vf=class extends Il{constructor(e){super(e),this.highlightConstants=null}init(e,t){super.init(e,t),this.highlightConstants=this.makeHighlightConstants_(),this.highlightConstants.init()}refreshDom(e,t,o){super.refreshDom(e,t,o),this.getHighlightConstants().init()}makeConstants_(){return new Df}makeRenderInfo_(e){return new Hf(this,e)}makeDrawer_(e,t){return new Bf(e,t)}makePathObject(e,t){return new Gf(e,t,this.getConstants())}makeHighlightConstants_(){return new Pf(this.getConstants())}getHighlightConstants(){if(!this.highlightConstants)throw Error("Cannot access the highlight constants because init has not been called");return this.highlightConstants}};Qi("geras",Vf);var No={};No.ConstantProvider=Df,No.Drawer=Bf,No.HighlightConstantProvider=Pf,No.Highlighter=xf,No.InlineInput=Ff,No.PathObject=Gf,No.RenderInfo=Hf,No.Renderer=Vf,No.StatementInput=Uf;var Wf=class extends Sr{constructor(e,t){super(e,t)}getRenderer(){return this.renderer_}addElemSpacing_(){let e=!1;for(var t=0;t<this.rows.length;t++)if(this.rows[t].hasExternalInput){e=!0;break}for(t=0;t<this.rows.length;t++){const s=this.rows[t];var o=s.elements;if(s.elements=[],s.startsWithElemSpacer()&&s.elements.push(new Xt(this.constants_,this.getInRowSpacing_(null,o[0]))),o.length){for(let i=0;i<o.length-1;i++){s.elements.push(o[i]);const n=this.getInRowSpacing_(o[i],o[i+1]);s.elements.push(new Xt(this.constants_,n))}s.elements.push(o[o.length-1]),s.endsWithElemSpacer()&&(o=this.getInRowSpacing_(o[o.length-1],null),e&&s.hasDummyInput&&(o+=this.constants_.TAB_WIDTH),s.elements.push(new Xt(this.constants_,o)))}}}getInRowSpacing_(e,t){if(!e)return t&&T.isField(t)&&t.isEditable?this.constants_.MEDIUM_PADDING:t&&T.isInlineInput(t)?this.constants_.MEDIUM_LARGE_PADDING:t&&T.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!T.isInput(e)&&!t)return T.isField(e)&&e.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:T.isIcon(e)?this.constants_.LARGE_PADDING*2+1:T.isHat(e)?this.constants_.NO_PADDING:T.isPreviousOrNextConnection(e)?this.constants_.LARGE_PADDING:T.isLeftRoundedCorner(e)?this.constants_.MIN_BLOCK_WIDTH:T.isJaggedEdge(e)?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING;if(T.isInput(e)&&!t){if(T.isExternalInput(e))return this.constants_.NO_PADDING;if(T.isInlineInput(e))return this.constants_.LARGE_PADDING;if(T.isStatementInput(e))return this.constants_.NO_PADDING}if(!T.isInput(e)&&t&&T.isInput(t)){if(T.isField(e)&&e.isEditable){if(T.isInlineInput(t)||T.isExternalInput(t))return this.constants_.SMALL_PADDING}else{if(T.isInlineInput(t)||T.isExternalInput(t))return this.constants_.MEDIUM_LARGE_PADDING;if(T.isStatementInput(t))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-1}if(T.isIcon(e)&&t&&!T.isInput(t))return this.constants_.LARGE_PADDING;if(T.isInlineInput(e)&&t&&T.isField(t))return t.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;if(T.isLeftSquareCorner(e)&&t){if(T.isHat(t))return this.constants_.NO_PADDING;if(T.isPreviousConnection(t)||T.isNextConnection(t))return t.notchOffset}return T.isLeftRoundedCorner(e)&&t?t.notchOffset-this.constants_.CORNER_RADIUS:T.isField(e)&&t&&T.isField(t)&&e.isEditable===t.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING:t&&T.isJaggedEdge(t)?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getSpacerRowHeight_(e,t){return T.isTopRow(e)&&T.isBottomRow(t)?this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:T.isTopRow(e)||T.isBottomRow(t)?this.constants_.NO_PADDING:e.hasExternalInput&&t.hasExternalInput?this.constants_.LARGE_PADDING:!e.hasStatement&&t.hasStatement?this.constants_.BETWEEN_STATEMENT_PADDING_Y:e.hasStatement&&t.hasStatement||e.hasDummyInput||t.hasDummyInput?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getElemCenterline_(e,t){if(T.isSpacer(t))return e.yPos+t.height/2;if(T.isBottomRow(e))return e=e.yPos+e.height-e.descenderHeight,T.isNextConnection(t)?e+t.height/2:e-t.height/2;if(T.isTopRow(e))return T.isHat(t)?e.capline-t.height/2:e.capline+t.height/2;let o=e.yPos;return o=T.isField(t)&&e.hasStatement?o+(this.constants_.TALL_INPUT_FIELD_OFFSET_Y+t.height/2):o+e.height/2}finalize_(){let e=0,t=0;for(var o=0;o<this.rows.length;o++){const i=this.rows[o];i.yPos=t,i.xPos=this.startX,t+=i.height,e=Math.max(e,i.widthWithConnectedBlocks);var s=t-this.topRow.ascenderHeight;i===this.bottomRow&&s<this.constants_.MIN_BLOCK_HEIGHT&&(s=this.constants_.MIN_BLOCK_HEIGHT-s,this.bottomRow.height+=s,t+=s),this.recordElemPositions_(i)}this.outputConnection&&this.block_.nextConnection&&this.block_.nextConnection.isConnected()&&(o=this.block_.nextConnection.targetBlock())&&(e=Math.max(e,o.getHeightWidth().width)),this.bottomRow.baseline=t-this.bottomRow.descenderHeight,this.widthWithChildren=e+this.startX,this.height=t,this.startY=this.topRow.capline}},zf=class extends Il{constructor(e){super(e)}makeRenderInfo_(e){return new Wf(this,e)}};Qi("thrasos",zf);var Ph={};Ph.RenderInfo=Wf,Ph.Renderer=zf;var Yb={colour_blocks:{colourPrimary:"#CF63CF",colourSecondary:"#C94FC9",colourTertiary:"#BD42BD"},list_blocks:{colourPrimary:"#9966FF",colourSecondary:"#855CD6",colourTertiary:"#774DCB"},logic_blocks:{colourPrimary:"#4C97FF",colourSecondary:"#4280D7",colourTertiary:"#3373CC"},loop_blocks:{colourPrimary:"#0fBD8C",colourSecondary:"#0DA57A",colourTertiary:"#0B8E69"},math_blocks:{colourPrimary:"#59C059",colourSecondary:"#46B946",colourTertiary:"#389438"},procedure_blocks:{colourPrimary:"#FF6680",colourSecondary:"#FF4D6A",colourTertiary:"#FF3355"},text_blocks:{colourPrimary:"#FFBF00",colourSecondary:"#E6AC00",colourTertiary:"#CC9900"},variable_blocks:{colourPrimary:"#FF8C1A",colourSecondary:"#FF8000",colourTertiary:"#DB6E00"},variable_dynamic_blocks:{colourPrimary:"#FF8C1A",colourSecondary:"#FF8000",colourTertiary:"#DB6E00"},hat_blocks:{colourPrimary:"#4C97FF",colourSecondary:"#4280D7",colourTertiary:"#3373CC",hat:"cap"}},Xb={colour_category:{colour:"#CF63CF"},list_category:{colour:"#9966FF"},logic_category:{colour:"#4C97FF"},loop_category:{colour:"#0fBD8C"},math_category:{colour:"#59C059"},procedure_category:{colour:"#FF6680"},text_category:{colour:"#FFBF00"},variable_category:{colour:"#FF8C1A"},variable_dynamic_category:{colour:"#FF8C1A"}},jb=new Bs("zelos",Yb,Xb),Kb={Classic:cl,Zelos:jb},Fh=class{constructor(e,t,o){this.id_=e.toolboxitemid||Re(),this.level_=(this.parent_=o||null)?this.parent_.getLevel()+1:0,this.toolboxItemDef_=e,this.parentToolbox_=t,this.workspace_=this.parentToolbox_.getWorkspace()}init(){}getDiv(){return null}getClickTarget(){return null}getId(){return this.id_}getParent(){return null}getLevel(){return this.level_}isSelectable(){return!1}isCollapsible(){return!1}dispose(){}setVisible_(e){}getFocusableElement(){const e=this.getDiv();if(!e)throw Error("Trying to access toolbox item before DOM is initialized.");if(!(e instanceof HTMLElement))throw Error("Toolbox item div is unexpectedly not an HTML element.");return e}getFocusableTree(){return this.parentToolbox_}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}},ao=class extends Fh{constructor(e,t,o){super(e,t,o),this.colour_=this.name_="",this.labelDom_=this.iconDom_=this.rowContents_=this.rowDiv_=this.htmlDiv_=null,this.isDisabled_=this.isHidden_=!1,this.flyoutItems_=[],this.cssConfig_=this.makeDefaultCssConfig_()}init(){this.parseCategoryDef_(this.toolboxItemDef_),this.parseContents_(this.toolboxItemDef_),this.createDom_(),this.toolboxItemDef_.hidden==="true"&&this.hide()}makeDefaultCssConfig_(){return{container:"blocklyToolboxCategoryContainer",row:"blocklyToolboxCategory",rowcontentcontainer:"blocklyTreeRowContentContainer",icon:"blocklyToolboxCategoryIcon",label:"blocklyToolboxCategoryLabel",contents:"blocklyToolboxCategoryGroup",selected:"blocklyToolboxSelected",openicon:"blocklyToolboxCategoryIconOpen",closedicon:"blocklyToolboxCategoryIconClosed"}}parseContents_(e){if("custom"in e)this.flyoutItems_=e.custom;else if(e=e.contents)for(let t=0;t<e.length;t++){const o=e[t];Array.isArray(this.flyoutItems_)&&this.flyoutItems_.push(o)}}parseCategoryDef_(e){this.name_="name"in e?Je(e.name):"",this.colour_=this.getColour_(e),Object.assign(this.cssConfig_,e.cssconfig||e.cssConfig)}createDom_(){this.htmlDiv_=this.createContainer_(),po(this.htmlDiv_,Gt.TREEITEM),it(this.htmlDiv_,Qe.SELECTED,!1),it(this.htmlDiv_,Qe.LEVEL,this.level_+1),this.rowDiv_=this.createRowContainer_(),this.rowDiv_.style.pointerEvents="auto",this.htmlDiv_.appendChild(this.rowDiv_),this.rowContents_=this.createRowContentsContainer_(),this.rowContents_.style.pointerEvents="none",this.rowDiv_.appendChild(this.rowContents_),this.iconDom_=this.createIconDom_(),po(this.iconDom_,Gt.PRESENTATION),this.rowContents_.appendChild(this.iconDom_),this.labelDom_=this.createLabelDom_(this.name_),this.rowContents_.appendChild(this.labelDom_);const e=this.labelDom_.getAttribute("id");return e&&it(this.htmlDiv_,Qe.LABELLEDBY,e),this.addColourBorder_(this.colour_),this.htmlDiv_}createContainer_(){const e=document.createElement("div");e.tabIndex=-1,e.id=this.getId();const t=this.cssConfig_.container;return t&&G(e,t),e}createRowContainer_(){const e=document.createElement("div");var t=this.cssConfig_.row;return t&&G(e,t),t=`${ao.nestedPadding*this.getLevel()}px`,this.workspace_.RTL?e.style.paddingRight=t:e.style.paddingLeft=t,e}createRowContentsContainer_(){const e=document.createElement("div"),t=this.cssConfig_.rowcontentcontainer;return t&&G(e,t),e}createIconDom_(){const e=document.createElement("span");if(!this.parentToolbox_.isHorizontal()){const t=this.cssConfig_.icon;t&&G(e,t)}return e.style.display="inline-block",e}createLabelDom_(e){const t=document.createElement("span");return t.setAttribute("id",this.getId()+".label"),t.textContent=e,(e=this.cssConfig_.label)&&G(t,e),t}refreshTheme(){this.colour_=this.getColour_(this.toolboxItemDef_),this.addColourBorder_(this.colour_)}addColourBorder_(e){e&&(e=ao.borderWidth+"px solid "+(e||"#ddd"),this.workspace_.RTL?this.rowDiv_.style.borderRight=e:this.rowDiv_.style.borderLeft=e)}getColour_(e){const t=e.categorystyle||e.categoryStyle;if((e=e.colour)&&t)console.warn('Toolbox category "'+this.name_+'" must not have both a style and a colour');else{if(t)return this.getColourfromStyle(t);if(e)return this.parseColour(e)}return""}getColourfromStyle(e){var t=this.workspace_.getTheme();if(e&&t){if((t=t.categoryStyles[e])&&t.colour)return this.parseColour(t.colour);console.warn('Style "'+e+'" must exist and contain a colour value')}return""}getClickTarget(){return this.rowDiv_}parseColour(e){if(e=Je(e),e==null||e==="")return"";var t=Number(e);return isNaN(t)?(t=Es(e))?t:(console.warn('Toolbox category "'+this.name_+'" has unrecognized colour attribute: '+e),""):Hc(t)}openIcon_(e){if(e){var t=this.cssConfig_.closedicon;t&&Lt(e,t),(t=this.cssConfig_.openicon)&&G(e,t)}}closeIcon_(e){if(e){var t=this.cssConfig_.openicon;t&&Lt(e,t),(t=this.cssConfig_.closedicon)&&G(e,t)}}setVisible_(e){this.htmlDiv_.style.display=e?"block":"none",this.isHidden_=!e,this.parentToolbox_.getSelectedItem()===this&&this.parentToolbox_.clearSelection()}hide(){this.setVisible_(!1)}show(){this.setVisible_(!0)}isVisible(){return!this.isHidden_&&this.allAncestorsExpanded_()}allAncestorsExpanded_(){let e=this;for(;e.getParent();)if(e=e.getParent(),!e.isExpanded())return!1;return!0}isSelectable(){return this.isVisible()&&!this.isDisabled_}onClick(e){}setSelected(e){if(this.rowDiv_){var t=this.cssConfig_.selected;if(e){const o=this.parseColour(ao.defaultBackgroundColour);this.rowDiv_.style.backgroundColor=this.colour_||o,t&&G(this.rowDiv_,t)}else this.rowDiv_.style.backgroundColor="",t&&Te(this.rowDiv_,t);it(this.htmlDiv_,Qe.SELECTED,e)}}setDisabled(e){this.isDisabled_=e,this.getDiv().setAttribute("disabled",`${e}`),e?this.getDiv().setAttribute("disabled","true"):this.getDiv().removeAttribute("disabled")}getName(){return this.name_}getParent(){return this.parent_}getDiv(){return this.htmlDiv_}getContents(){return this.flyoutItems_}updateFlyoutContents(e){this.flyoutItems_=[],this.toolboxItemDef_=typeof e=="string"?{kind:this.toolboxItemDef_.kind,custom:e,id:this.toolboxItemDef_.id,categorystyle:this.toolboxItemDef_.categorystyle,colour:this.toolboxItemDef_.colour,cssconfig:this.toolboxItemDef_.cssconfig,hidden:this.toolboxItemDef_.hidden}:{kind:this.toolboxItemDef_.kind,name:"name"in this.toolboxItemDef_?this.toolboxItemDef_.name:"",contents:Pi(e),id:this.toolboxItemDef_.id,categorystyle:this.toolboxItemDef_.categorystyle,colour:this.toolboxItemDef_.colour,cssconfig:this.toolboxItemDef_.cssconfig,hidden:this.toolboxItemDef_.hidden},this.parseContents_(this.toolboxItemDef_)}dispose(){ke(this.htmlDiv_)}};ao.registrationName="category",ao.nestedPadding=19,ao.borderWidth=8,ao.defaultBackgroundColour="#57e",q(`
670
670
  .blocklyToolboxCategory:not(.blocklyToolboxSelected):hover {
671
671
  background-color: rgba(255, 255, 255, .2);
672
672
  }
@@ -738,7 +738,7 @@ Blockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());`),
738
738
  .blocklyToolboxSelected .blocklyToolboxCategoryLabel {
739
739
  color: #fff;
740
740
  }
741
- `),l(M.TOOLBOX_ITEM,ao.registrationName,ao);var Nr=class extends Bh{constructor(e,t){super(e,t),this.cssConfig_={container:"blocklyTreeSeparator"},this.htmlDiv=null,Object.assign(this.cssConfig_,e.cssconfig||e.cssConfig)}init(){this.createDom_()}createDom_(){const e=document.createElement("div");e.tabIndex=-1,e.id=this.getId();const t=this.cssConfig_.container;return t&&G(e,t),this.htmlDiv=e}getDiv(){return this.htmlDiv}dispose(){ke(this.htmlDiv)}};Nr.registrationName="sep",q(`
741
+ `),l(M.TOOLBOX_ITEM,ao.registrationName,ao);var Ar=class extends Fh{constructor(e,t){super(e,t),this.cssConfig_={container:"blocklyTreeSeparator"},this.htmlDiv=null,Object.assign(this.cssConfig_,e.cssconfig||e.cssConfig)}init(){this.createDom_()}createDom_(){const e=document.createElement("div");e.tabIndex=-1,e.id=this.getId();const t=this.cssConfig_.container;return t&&G(e,t),this.htmlDiv=e}getDiv(){return this.htmlDiv}dispose(){ke(this.htmlDiv)}};Ar.registrationName="sep",q(`
742
742
  .blocklyTreeSeparator {
743
743
  border-bottom: solid #e5e5e5 1px;
744
744
  height: 0;
@@ -753,7 +753,7 @@ Blockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());`),
753
753
  padding: 5px 0;
754
754
  width: 0;
755
755
  }
756
- `),l(M.TOOLBOX_ITEM,Nr.registrationName,Nr);var Ai=class extends ao{constructor(e,t,o){super(e,t,o),this.subcategoriesDiv_=null,this.expanded_=!1,this.toolboxItems_=[]}makeDefaultCssConfig_(){const e=super.makeDefaultCssConfig_();return e.contents="blocklyToolboxCategoryGroup",e}parseContents_(e){if("custom"in e)this.flyoutItems_=e.custom;else{const t=e.contents;if(t){this.flyoutItems_=[],e=!0;for(let o=0;o<t.length;o++){const s=t[o];!k(M.TOOLBOX_ITEM,s.kind)||s.kind.toLowerCase()===Nr.registrationName&&e?(this.flyoutItems_.push(s),e=!0):(this.createToolboxItem(s),e=!1)}}}}createToolboxItem(e){let t=e.kind;t.toUpperCase()==="CATEGORY"&&Ur(e)&&(t=Ai.registrationName),e=new(A(M.TOOLBOX_ITEM,t))(e,this.parentToolbox_,this),this.toolboxItems_.push(e)}init(){super.init(),this.setExpanded(this.toolboxItemDef_.expanded==="true"||this.toolboxItemDef_.expanded===!0)}createDom_(){super.createDom_();const e=this.getChildToolboxItems();return this.subcategoriesDiv_=this.createSubCategoriesDom_(e),po(this.subcategoriesDiv_,Gt.GROUP),this.htmlDiv_.appendChild(this.subcategoriesDiv_),this.closeIcon_(this.iconDom_),it(this.htmlDiv_,Qe.EXPANDED,!1),this.htmlDiv_}createIconDom_(){const e=document.createElement("span");if(!this.parentToolbox_.isHorizontal()){const t=this.cssConfig_.icon;t&&G(e,t),e.style.visibility="visible"}return e.style.display="inline-block",e}createSubCategoriesDom_(e){const t=document.createElement("div");t.style.display="none";var o=this.cssConfig_.contents;for(o&&G(t,o),o=0;o<e.length;o++){const s=e[o];s.init();const i=s.getDiv();if(t.appendChild(i),s.getClickTarget){let n;(n=s.getClickTarget())==null||n.setAttribute("id",s.getId())}}return t}setExpanded(e){if(this.expanded_!==e){if(this.expanded_=e)this.subcategoriesDiv_.style.display="block",this.openIcon_(this.iconDom_);else{let t;(t=this.parentToolbox_.getFlyout())==null||t.setVisible(!1),this.subcategoriesDiv_.style.display="none",this.closeIcon_(this.iconDom_)}it(this.htmlDiv_,Qe.EXPANDED,e),this.parentToolbox_.handleToolboxItemResize()}}setVisible_(e){this.htmlDiv_.style.display=e?"block":"none";const t=this.getChildToolboxItems();for(let o=0;o<t.length;o++)t[o].setVisible_(e);this.isHidden_=!e,this.parentToolbox_.getSelectedItem()===this&&this.parentToolbox_.clearSelection()}isExpanded(){return this.expanded_}isCollapsible(){return!0}onClick(e){this.toggleExpanded()}toggleExpanded(){this.setExpanded(!this.expanded_)}getDiv(){return this.htmlDiv_}getChildToolboxItems(){return this.toolboxItems_}};Ai.registrationName="collapsibleCategory",l(M.TOOLBOX_ITEM,Ai.registrationName,Ai);var Vf=class extends dl{constructor(e){super(),this.id="toolbox",this.contentsDiv_=this.HtmlDiv=null,this.isVisible_=!1,this.height_=this.width_=0,this.flyout=null,this.contents=new Map,this.previouslySelectedItem_=this.selectedItem_=null,this.boundEvents_=[],this.workspace_=e,this.toolboxDef_=e.options.languageTree||{contents:[]},this.horizontalLayout=e.options.horizontalLayout,this.RTL=e.options.RTL,this.toolboxPosition=e.options.toolboxPosition}onShortcut(e){return!1}init(){var e=this.workspace_;const t=e.getParentSvg();this.flyout=this.createFlyout_(),this.HtmlDiv=this.createDom_(this.workspace_);const o=this.flyout.createDom("svg");G(o,"blocklyToolboxFlyout"),Qt(o,t),this.setVisible(!0),this.flyout.init(e),this.render(this.toolboxDef_),e=e.getThemeManager(),e.subscribe(this.HtmlDiv,"toolboxBackgroundColour","background-color"),e.subscribe(this.HtmlDiv,"toolboxForegroundColour","color"),this.workspace_.getComponentManager().addComponent({component:this,weight:Ve.ComponentWeight.TOOLBOX_WEIGHT,capabilities:[Ve.Capability.AUTOHIDEABLE,Ve.Capability.DELETE_AREA,Ve.Capability.DRAG_TARGET]}),r.getFocusManager$$module$build$src$core$focus_manager().registerTree(this,!0)}createDom_(e){e=e.getParentSvg();const t=this.createContainer_();return t.id=Re(),this.contentsDiv_=this.createContentsContainer_(),po(this.contentsDiv_,Gt.TREE),t.appendChild(this.contentsDiv_),e.parentNode.insertBefore(t,e),this.attachEvents_(t,this.contentsDiv_),t}createContainer_(){const e=document.createElement("div");return e.setAttribute("layout",this.isHorizontal()?"h":"v"),G(e,"blocklyToolbox"),e.setAttribute("dir",this.RTL?"RTL":"LTR"),e}createContentsContainer_(){const e=document.createElement("div");return G(e,"blocklyToolboxCategoryGroup"),this.isHorizontal()&&(e.style.flexDirection="row"),e}attachEvents_(e,t){e=z(e,"pointerdown",this,this.onClick_,!1),this.boundEvents_.push(e),t=z(t,"keydown",this,this.onKeyDown_,!1),this.boundEvents_.push(t)}onClick_(e){if(Ie(e)||e.target===this.HtmlDiv)c().hideChaff(!1);else{var t=e.target.getAttribute("id");t&&(t=this.getToolboxItemById(t),t.isSelectable()&&(this.setSelectedItem(t),t.onClick(e))),c().hideChaff(!0)}ie()}onKeyDown_(e){let t=!1;switch(e.key){case"ArrowDown":t=this.selectNext();break;case"ArrowUp":t=this.selectPrevious();break;case"ArrowLeft":t=this.selectParent();break;case"ArrowRight":t=this.selectChild();break;case"Enter":case" ":this.selectedItem_&&this.selectedItem_.isCollapsible()&&(this.selectedItem_.toggleExpanded(),t=!0);break;default:t=!1}!t&&this.selectedItem_&&this.selectedItem_.onKeyDown&&(t=this.selectedItem_.onKeyDown(e)),t&&e.preventDefault()}createFlyout_(){const e=this.workspace_,t=e.copyOptionsForFlyout();return t.toolboxPosition=e.options.toolboxPosition,new(e.horizontalLayout?W(M.FLYOUTS_HORIZONTAL_TOOLBOX,e.options,!0):W(M.FLYOUTS_VERTICAL_TOOLBOX,e.options,!0))(t)}render(e){this.toolboxDef_=e,this.contents.forEach(t=>t.dispose()),this.contents.clear(),this.renderContents_(e.contents),this.position(),this.handleToolboxItemResize()}renderContents_(e){const t=document.createDocumentFragment();for(let o=0;o<e.length;o++)this.createToolboxItem(e[o],t);this.contentsDiv_.appendChild(t)}createToolboxItem(e,t){var o=e.kind;o.toUpperCase()==="CATEGORY"&&Ur(e)&&(o=Ai.registrationName),(o=A(M.TOOLBOX_ITEM,o.toLowerCase()))&&(e=new o(e,this),e.init(),this.addToolboxItem_(e),(o=e.getDiv())&&t.appendChild(o),e.getClickTarget()&&e.getClickTarget().setAttribute("id",e.getId()))}addToolboxItem_(e){if(this.contents.set(e.getId(),e),e.isCollapsible()){e=e.getChildToolboxItems();for(let t=0;t<e.length;t++)this.addToolboxItem_(e[t])}}getToolboxItems(){return[...this.contents.values()]}addStyle(e){e&&this.HtmlDiv&&G(this.HtmlDiv,e)}removeStyle(e){e&&this.HtmlDiv&&Te(this.HtmlDiv,e)}getClientRect(){if(!this.HtmlDiv||!this.isVisible_)return null;var e=this.HtmlDiv.getBoundingClientRect();const t=e.top,o=t+e.height,s=e.left;return e=s+e.width,this.toolboxPosition===be.TOP?new ye(-1e7,o,-1e7,1e7):this.toolboxPosition===be.BOTTOM?new ye(t,1e7,-1e7,1e7):this.toolboxPosition===be.LEFT?new ye(-1e7,1e7,-1e7,e):new ye(-1e7,1e7,s,1e7)}wouldDelete(e){return e instanceof Be?this.updateWouldDelete_(!e.getParent()&&e.isDeletable()):this.updateWouldDelete_(Kt(e)&&e.isDeletable()),this.wouldDelete_}onDragEnter(e){this.updateCursorDeleteStyle_(!0)}onDragExit(e){this.updateCursorDeleteStyle_(!1)}onDrop(e){this.updateCursorDeleteStyle_(!1)}updateWouldDelete_(e){e!==this.wouldDelete_&&(this.updateCursorDeleteStyle_(!1),this.wouldDelete_=e,this.updateCursorDeleteStyle_(!0))}updateCursorDeleteStyle_(e){const t=this.wouldDelete_?"blocklyToolboxDelete":"blocklyToolboxGrab";e?this.addStyle(t):this.removeStyle(t)}getToolboxItemById(e){return this.contents.get(e)||null}getWidth(){return this.width_}getHeight(){return this.height_}getFlyout(){return this.flyout}getWorkspace(){return this.workspace_}getSelectedItem(){return this.selectedItem_}getPreviouslySelectedItem(){return this.previouslySelectedItem_}isHorizontal(){return this.horizontalLayout}position(){const e=this.workspace_.getMetrics(),t=this.HtmlDiv;t&&(this.horizontalLayout?(t.style.left="0",t.style.height="auto",t.style.width="100%",this.height_=t.offsetHeight,this.width_=e.viewWidth,this.toolboxPosition===be.TOP?t.style.top="0":t.style.bottom="0"):(this.toolboxPosition===be.RIGHT?t.style.right="0":t.style.left="0",t.style.height="100%",this.width_=t.offsetWidth,this.height_=e.viewHeight),this.flyout.position())}handleToolboxItemResize(){const e=this.workspace_;var t=this.HtmlDiv.getBoundingClientRect();const o=this.getFlyout(),s=this.toolboxPosition===be.LEFT?e.scrollX+t.width+(o!=null&&o.isVisible()?o.getWidth():0):e.scrollX;t=this.toolboxPosition===be.TOP?e.scrollY+t.height+(o!=null&&o.isVisible()?o.getHeight():0):e.scrollY,e.translate(s,t),$o(e)}clearSelection(){this.setSelectedItem(null)}refreshTheme(){this.contents.forEach(e=>{e.refreshTheme&&e.refreshTheme()})}refreshSelection(){this.selectedItem_&&this.selectedItem_.isSelectable()&&this.selectedItem_.getContents().length&&this.flyout.show(this.selectedItem_.getContents())}setVisible(e){this.isVisible_!==e&&(this.HtmlDiv.style.display=e?"block":"none",this.isVisible_=e,this.workspace_.recordDragTargets())}autoHide(e){!e&&this.flyout&&this.flyout.autoClose&&this.clearSelection()}setSelectedItem(e){const t=this.selectedItem_;!e&&!t||e&&!Ap(e)||(this.shouldDeselectItem_(t,e)&&t!==null&&this.deselectItem_(t),this.shouldSelectItem_(t,e)&&e!==null&&this.selectItem_(t,e),this.updateFlyout_(t,e),this.fireSelectEvent(t,e))}shouldDeselectItem_(e,t){return e!==null&&(!e.isCollapsible()||e!==t)}shouldSelectItem_(e,t){return t!==null&&t!==e}deselectItem_(e){this.selectedItem_=null,this.previouslySelectedItem_=e,e.setSelected(!1),it(this.contentsDiv_,Qe.ACTIVEDESCENDANT,"")}selectItem_(e,t){this.selectedItem_=t,this.previouslySelectedItem_=e,t.setSelected(!0),it(this.contentsDiv_,Qe.ACTIVEDESCENDANT,t.getId())}selectItemByPosition(e){(e=this.getToolboxItems()[e])&&this.setSelectedItem(e)}updateFlyout_(e,t){t&&(e!==t||t.isCollapsible())&&t.getContents().length?(this.flyout.show(t.getContents()),this.flyout.scrollToStart()):this.flyout.hide()}fireSelectEvent(e,t){const o=e&&e.getName();let s=t&&t.getName();e===t&&(s=null),e=new(U(w.TOOLBOX_ITEM_SELECT))(o,s,this.workspace_.id),_(e)}selectParent(){return this.selectedItem_?this.selectedItem_.isCollapsible()&&this.selectedItem_.isExpanded()?(this.selectedItem_.toggleExpanded(),!0):this.selectedItem_.getParent()&&this.selectedItem_.getParent().isSelectable()?(this.setSelectedItem(this.selectedItem_.getParent()),!0):!1:!1}selectChild(){if(!this.selectedItem_||!this.selectedItem_.isCollapsible())return!1;const e=this.selectedItem_;return e.isExpanded()?this.selectNext():e.toggleExpanded(),!0}selectNext(){if(!this.selectedItem_)return!1;const e=[...this.contents.values()];let t=e.indexOf(this.selectedItem_)+1;if(t>-1&&t<e.length){let o=e[t];for(;o&&!o.isSelectable();)o=e[++t];if(o&&o.isSelectable())return this.setSelectedItem(o),!0}return!1}selectPrevious(){if(!this.selectedItem_)return!1;const e=[...this.contents.values()];let t=e.indexOf(this.selectedItem_)-1;if(t>-1&&t<e.length){let o=e[t];for(;o&&!o.isSelectable();)o=e[--t];if(o&&o.isSelectable())return this.setSelectedItem(o),!0}return!1}dispose(){this.workspace_.getComponentManager().removeComponent("toolbox"),this.flyout.dispose(),this.contents.forEach(e=>e.dispose());for(let e=0;e<this.boundEvents_.length;e++)te(this.boundEvents_[e]);this.boundEvents_=[],this.contents.clear(),this.HtmlDiv&&(this.workspace_.getThemeManager().unsubscribe(this.HtmlDiv),ke(this.HtmlDiv)),r.getFocusManager$$module$build$src$core$focus_manager().unregisterTree(this)}getFocusableElement(){if(!this.HtmlDiv)throw Error("Toolbox DOM has not yet been created.");return this.HtmlDiv}getFocusableTree(){return this}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}getRootFocusableNode(){return this}getRestoredFocusableNode(e){if(!e||e===this){let t;return(t=this.getToolboxItems().find(o=>o.isSelectable()))!=null?t:null}return null}getNestedTrees(){return[]}lookUpFocusableNode(e){return this.getToolboxItemById(e)}onTreeFocus(e,t){e!==this?this.getSelectedItem()!==e&&this.setSelectedItem(e):this.clearSelection()}onTreeBlur(e){let t;e&&e===((t=this.flyout)==null?void 0:t.getWorkspace())||(this.clearSelection(),this.flyout&&hu(this.flyout)&&this.flyout.autoHide(!1))}};q(`
756
+ `),l(M.TOOLBOX_ITEM,Ar.registrationName,Ar);var Ai=class extends ao{constructor(e,t,o){super(e,t,o),this.subcategoriesDiv_=null,this.expanded_=!1,this.toolboxItems_=[]}makeDefaultCssConfig_(){const e=super.makeDefaultCssConfig_();return e.contents="blocklyToolboxCategoryGroup",e}parseContents_(e){if("custom"in e)this.flyoutItems_=e.custom;else{const t=e.contents;if(t){this.flyoutItems_=[],e=!0;for(let o=0;o<t.length;o++){const s=t[o];!k(M.TOOLBOX_ITEM,s.kind)||s.kind.toLowerCase()===Ar.registrationName&&e?(this.flyoutItems_.push(s),e=!0):(this.createToolboxItem(s),e=!1)}}}}createToolboxItem(e){let t=e.kind;t.toUpperCase()==="CATEGORY"&&Hr(e)&&(t=Ai.registrationName),e=new(A(M.TOOLBOX_ITEM,t))(e,this.parentToolbox_,this),this.toolboxItems_.push(e)}init(){super.init(),this.setExpanded(this.toolboxItemDef_.expanded==="true"||this.toolboxItemDef_.expanded===!0)}createDom_(){super.createDom_();const e=this.getChildToolboxItems();return this.subcategoriesDiv_=this.createSubCategoriesDom_(e),po(this.subcategoriesDiv_,Gt.GROUP),this.htmlDiv_.appendChild(this.subcategoriesDiv_),this.closeIcon_(this.iconDom_),it(this.htmlDiv_,Qe.EXPANDED,!1),this.htmlDiv_}createIconDom_(){const e=document.createElement("span");if(!this.parentToolbox_.isHorizontal()){const t=this.cssConfig_.icon;t&&G(e,t),e.style.visibility="visible"}return e.style.display="inline-block",e}createSubCategoriesDom_(e){const t=document.createElement("div");t.style.display="none";var o=this.cssConfig_.contents;for(o&&G(t,o),o=0;o<e.length;o++){const s=e[o];s.init();const i=s.getDiv();if(t.appendChild(i),s.getClickTarget){let n;(n=s.getClickTarget())==null||n.setAttribute("id",s.getId())}}return t}setExpanded(e){if(this.expanded_!==e){if(this.expanded_=e)this.subcategoriesDiv_.style.display="block",this.openIcon_(this.iconDom_);else{let t;(t=this.parentToolbox_.getFlyout())==null||t.setVisible(!1),this.subcategoriesDiv_.style.display="none",this.closeIcon_(this.iconDom_)}it(this.htmlDiv_,Qe.EXPANDED,e),this.parentToolbox_.handleToolboxItemResize()}}setVisible_(e){this.htmlDiv_.style.display=e?"block":"none";const t=this.getChildToolboxItems();for(let o=0;o<t.length;o++)t[o].setVisible_(e);this.isHidden_=!e,this.parentToolbox_.getSelectedItem()===this&&this.parentToolbox_.clearSelection()}isExpanded(){return this.expanded_}isCollapsible(){return!0}onClick(e){this.toggleExpanded()}toggleExpanded(){this.setExpanded(!this.expanded_)}getDiv(){return this.htmlDiv_}getChildToolboxItems(){return this.toolboxItems_}};Ai.registrationName="collapsibleCategory",l(M.TOOLBOX_ITEM,Ai.registrationName,Ai);var Yf=class extends $l{constructor(e){super(),this.id="toolbox",this.contentsDiv_=this.HtmlDiv=null,this.isVisible_=!1,this.height_=this.width_=0,this.flyout=null,this.contents=new Map,this.previouslySelectedItem_=this.selectedItem_=null,this.boundEvents_=[],this.workspace_=e,this.toolboxDef_=e.options.languageTree||{contents:[]},this.horizontalLayout=e.options.horizontalLayout,this.RTL=e.options.RTL,this.toolboxPosition=e.options.toolboxPosition}onShortcut(e){return!1}init(){var e=this.workspace_;const t=e.getParentSvg();this.flyout=this.createFlyout_(),this.HtmlDiv=this.createDom_(this.workspace_);const o=this.flyout.createDom("svg");G(o,"blocklyToolboxFlyout"),Qt(o,t),this.setVisible(!0),this.flyout.init(e),this.render(this.toolboxDef_),e=e.getThemeManager(),e.subscribe(this.HtmlDiv,"toolboxBackgroundColour","background-color"),e.subscribe(this.HtmlDiv,"toolboxForegroundColour","color"),this.workspace_.getComponentManager().addComponent({component:this,weight:Ve.ComponentWeight.TOOLBOX_WEIGHT,capabilities:[Ve.Capability.AUTOHIDEABLE,Ve.Capability.DELETE_AREA,Ve.Capability.DRAG_TARGET]}),r.getFocusManager$$module$build$src$core$focus_manager().registerTree(this,!0)}createDom_(e){e=e.getParentSvg();const t=this.createContainer_();return t.id=Re(),this.contentsDiv_=this.createContentsContainer_(),po(this.contentsDiv_,Gt.TREE),t.appendChild(this.contentsDiv_),e.parentNode.insertBefore(t,e),this.attachEvents_(t,this.contentsDiv_),t}createContainer_(){const e=document.createElement("div");return e.setAttribute("layout",this.isHorizontal()?"h":"v"),G(e,"blocklyToolbox"),e.setAttribute("dir",this.RTL?"RTL":"LTR"),e}createContentsContainer_(){const e=document.createElement("div");return G(e,"blocklyToolboxCategoryGroup"),this.isHorizontal()&&(e.style.flexDirection="row"),e}attachEvents_(e,t){e=z(e,"pointerdown",this,this.onClick_,!1),this.boundEvents_.push(e),t=z(t,"keydown",this,this.onKeyDown_,!1),this.boundEvents_.push(t)}onClick_(e){if(Ie(e)||e.target===this.HtmlDiv)c().hideChaff(!1);else{var t=e.target.getAttribute("id");t&&(t=this.getToolboxItemById(t),t.isSelectable()&&(this.setSelectedItem(t),t.onClick(e))),c().hideChaff(!0)}ie()}onKeyDown_(e){let t=!1;switch(e.key){case"ArrowDown":t=this.selectNext();break;case"ArrowUp":t=this.selectPrevious();break;case"ArrowLeft":t=this.selectParent();break;case"ArrowRight":t=this.selectChild();break;case"Enter":case" ":this.selectedItem_&&this.selectedItem_.isCollapsible()&&(this.selectedItem_.toggleExpanded(),t=!0);break;default:t=!1}!t&&this.selectedItem_&&this.selectedItem_.onKeyDown&&(t=this.selectedItem_.onKeyDown(e)),t&&e.preventDefault()}createFlyout_(){const e=this.workspace_,t=e.copyOptionsForFlyout();return t.toolboxPosition=e.options.toolboxPosition,new(e.horizontalLayout?W(M.FLYOUTS_HORIZONTAL_TOOLBOX,e.options,!0):W(M.FLYOUTS_VERTICAL_TOOLBOX,e.options,!0))(t)}render(e){this.toolboxDef_=e,this.contents.forEach(t=>t.dispose()),this.contents.clear(),this.renderContents_(e.contents),this.position(),this.handleToolboxItemResize()}renderContents_(e){const t=document.createDocumentFragment();for(let o=0;o<e.length;o++)this.createToolboxItem(e[o],t);this.contentsDiv_.appendChild(t)}createToolboxItem(e,t){var o=e.kind;o.toUpperCase()==="CATEGORY"&&Hr(e)&&(o=Ai.registrationName),(o=A(M.TOOLBOX_ITEM,o.toLowerCase()))&&(e=new o(e,this),e.init(),this.addToolboxItem_(e),(o=e.getDiv())&&t.appendChild(o),e.getClickTarget()&&e.getClickTarget().setAttribute("id",e.getId()))}addToolboxItem_(e){if(this.contents.set(e.getId(),e),e.isCollapsible()){e=e.getChildToolboxItems();for(let t=0;t<e.length;t++)this.addToolboxItem_(e[t])}}getToolboxItems(){return[...this.contents.values()]}addStyle(e){e&&this.HtmlDiv&&G(this.HtmlDiv,e)}removeStyle(e){e&&this.HtmlDiv&&Te(this.HtmlDiv,e)}getClientRect(){if(!this.HtmlDiv||!this.isVisible_)return null;var e=this.HtmlDiv.getBoundingClientRect();const t=e.top,o=t+e.height,s=e.left;return e=s+e.width,this.toolboxPosition===be.TOP?new ye(-1e7,o,-1e7,1e7):this.toolboxPosition===be.BOTTOM?new ye(t,1e7,-1e7,1e7):this.toolboxPosition===be.LEFT?new ye(-1e7,1e7,-1e7,e):new ye(-1e7,1e7,s,1e7)}wouldDelete(e){return e instanceof Be?this.updateWouldDelete_(!e.getParent()&&e.isDeletable()):this.updateWouldDelete_(Kt(e)&&e.isDeletable()),this.wouldDelete_}onDragEnter(e){this.updateCursorDeleteStyle_(!0)}onDragExit(e){this.updateCursorDeleteStyle_(!1)}onDrop(e){this.updateCursorDeleteStyle_(!1)}updateWouldDelete_(e){e!==this.wouldDelete_&&(this.updateCursorDeleteStyle_(!1),this.wouldDelete_=e,this.updateCursorDeleteStyle_(!0))}updateCursorDeleteStyle_(e){const t=this.wouldDelete_?"blocklyToolboxDelete":"blocklyToolboxGrab";e?this.addStyle(t):this.removeStyle(t)}getToolboxItemById(e){return this.contents.get(e)||null}getWidth(){return this.width_}getHeight(){return this.height_}getFlyout(){return this.flyout}getWorkspace(){return this.workspace_}getSelectedItem(){return this.selectedItem_}getPreviouslySelectedItem(){return this.previouslySelectedItem_}isHorizontal(){return this.horizontalLayout}position(){const e=this.workspace_.getMetrics(),t=this.HtmlDiv;t&&(this.horizontalLayout?(t.style.left="0",t.style.height="auto",t.style.width="100%",this.height_=t.offsetHeight,this.width_=e.viewWidth,this.toolboxPosition===be.TOP?t.style.top="0":t.style.bottom="0"):(this.toolboxPosition===be.RIGHT?t.style.right="0":t.style.left="0",t.style.height="100%",this.width_=t.offsetWidth,this.height_=e.viewHeight),this.flyout.position())}handleToolboxItemResize(){const e=this.workspace_;var t=this.HtmlDiv.getBoundingClientRect();const o=this.getFlyout(),s=this.toolboxPosition===be.LEFT?e.scrollX+t.width+(o!=null&&o.isVisible()?o.getWidth():0):e.scrollX;t=this.toolboxPosition===be.TOP?e.scrollY+t.height+(o!=null&&o.isVisible()?o.getHeight():0):e.scrollY,e.translate(s,t),$o(e)}clearSelection(){this.setSelectedItem(null)}refreshTheme(){this.contents.forEach(e=>{e.refreshTheme&&e.refreshTheme()})}refreshSelection(){this.selectedItem_&&this.selectedItem_.isSelectable()&&this.selectedItem_.getContents().length&&this.flyout.show(this.selectedItem_.getContents())}setVisible(e){this.isVisible_!==e&&(this.HtmlDiv.style.display=e?"block":"none",this.isVisible_=e,this.workspace_.recordDragTargets())}autoHide(e){!e&&this.flyout&&this.flyout.autoClose&&this.clearSelection()}setSelectedItem(e){const t=this.selectedItem_;!e&&!t||e&&!Dp(e)||(this.shouldDeselectItem_(t,e)&&t!==null&&this.deselectItem_(t),this.shouldSelectItem_(t,e)&&e!==null&&this.selectItem_(t,e),this.updateFlyout_(t,e),this.fireSelectEvent(t,e))}shouldDeselectItem_(e,t){return e!==null&&(!e.isCollapsible()||e!==t)}shouldSelectItem_(e,t){return t!==null&&t!==e}deselectItem_(e){this.selectedItem_=null,this.previouslySelectedItem_=e,e.setSelected(!1),it(this.contentsDiv_,Qe.ACTIVEDESCENDANT,"")}selectItem_(e,t){this.selectedItem_=t,this.previouslySelectedItem_=e,t.setSelected(!0),it(this.contentsDiv_,Qe.ACTIVEDESCENDANT,t.getId())}selectItemByPosition(e){(e=this.getToolboxItems()[e])&&this.setSelectedItem(e)}updateFlyout_(e,t){t&&(e!==t||t.isCollapsible())&&t.getContents().length?(this.flyout.show(t.getContents()),this.flyout.scrollToStart()):this.flyout.hide()}fireSelectEvent(e,t){const o=e&&e.getName();let s=t&&t.getName();e===t&&(s=null),e=new(U(w.TOOLBOX_ITEM_SELECT))(o,s,this.workspace_.id),_(e)}selectParent(){return this.selectedItem_?this.selectedItem_.isCollapsible()&&this.selectedItem_.isExpanded()?(this.selectedItem_.toggleExpanded(),!0):this.selectedItem_.getParent()&&this.selectedItem_.getParent().isSelectable()?(this.setSelectedItem(this.selectedItem_.getParent()),!0):!1:!1}selectChild(){if(!this.selectedItem_||!this.selectedItem_.isCollapsible())return!1;const e=this.selectedItem_;return e.isExpanded()?this.selectNext():e.toggleExpanded(),!0}selectNext(){if(!this.selectedItem_)return!1;const e=[...this.contents.values()];let t=e.indexOf(this.selectedItem_)+1;if(t>-1&&t<e.length){let o=e[t];for(;o&&!o.isSelectable();)o=e[++t];if(o&&o.isSelectable())return this.setSelectedItem(o),!0}return!1}selectPrevious(){if(!this.selectedItem_)return!1;const e=[...this.contents.values()];let t=e.indexOf(this.selectedItem_)-1;if(t>-1&&t<e.length){let o=e[t];for(;o&&!o.isSelectable();)o=e[--t];if(o&&o.isSelectable())return this.setSelectedItem(o),!0}return!1}dispose(){this.workspace_.getComponentManager().removeComponent("toolbox"),this.flyout.dispose(),this.contents.forEach(e=>e.dispose());for(let e=0;e<this.boundEvents_.length;e++)te(this.boundEvents_[e]);this.boundEvents_=[],this.contents.clear(),this.HtmlDiv&&(this.workspace_.getThemeManager().unsubscribe(this.HtmlDiv),ke(this.HtmlDiv)),r.getFocusManager$$module$build$src$core$focus_manager().unregisterTree(this)}getFocusableElement(){if(!this.HtmlDiv)throw Error("Toolbox DOM has not yet been created.");return this.HtmlDiv}getFocusableTree(){return this}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}getRootFocusableNode(){return this}getRestoredFocusableNode(e){if(!e||e===this){let t;return(t=this.getToolboxItems().find(o=>o.isSelectable()))!=null?t:null}return null}getNestedTrees(){return[]}lookUpFocusableNode(e){return this.getToolboxItemById(e)}onTreeFocus(e,t){e!==this?this.getSelectedItem()!==e&&this.setSelectedItem(e):this.clearSelection()}onTreeBlur(e){let t;e&&e===((t=this.flyout)==null?void 0:t.getWorkspace())||(this.clearSelection(),this.flyout&&$u(this.flyout)&&this.flyout.autoHide(!1))}};q(`
757
757
  .blocklyToolboxDelete {
758
758
  cursor: url("<<<PATH>>>/handdelete.cur"), auto;
759
759
  }
@@ -788,9 +788,9 @@ Blockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());`),
788
788
  .blocklyToolboxCategoryGroup:focus {
789
789
  outline: none;
790
790
  }
791
- `),l(M.TOOLBOX,Ft,Vf);var Xb="12.2.0",jb=Z.INPUT_VALUE,Kb=Z.OUTPUT_VALUE,Jb=Z.NEXT_STATEMENT,qb=Z.PREVIOUS_STATEMENT,Zb=be.TOP,Qb=be.BOTTOM,eT=be.LEFT,tT=be.RIGHT;ki.prototype.newBlock=function(e,t){return new Ii(this,e,t)},At.prototype.newBlock=function(e,t){return new Be(this,e,t)},ki.prototype.newComment=function(e){return new rl(this,e)},At.prototype.newComment=function(e){return new yo(this,e)},At.newTrashcan=function(e){return new Pm(e)},Wo.prototype.newWorkspaceSvg=function(e){return new At(e)},r.Names$$module$build$src$core$names.prototype.populateProcedures=function(e){e=qi(e),e=e[0].concat(e[1]);for(let t=0;t<e.length;t++)this.getName(e[t][0],r.Names$$module$build$src$core$names.NameType.PROCEDURE)};var O={};return O.Block=Ii,O.BlockFlyoutInflater=Nf,O.BlockNavigationPolicy=gm,O.BlockSvg=Be,O.Blocks=Ge,O.ButtonFlyoutInflater=Of,O.COLLAPSED_FIELD_NAME=Vn,O.COLLAPSED_INPUT_NAME=ur,O.COLLAPSE_CHARS=rm,O.CodeGenerator=r.CodeGenerator$$module$build$src$core$generator,O.CollapsibleToolboxCategory=Ai,O.ComponentManager=Ve,O.Connection=Ce,O.ConnectionChecker=Mm,O.ConnectionDB=Ei,O.ConnectionNavigationPolicy=mm,O.ConnectionType=Z,O.ContextMenu=xs,O.ContextMenuItems=dt,O.ContextMenuRegistry=Ee,O.Css=da,O.DELETE_VARIABLE_ID=Wa,O.DeleteArea=dl,O.DragTarget=am,O.DropDownDiv=wt,O.Events=j,O.Extensions=co,O.Field=we,O.FieldCheckbox=Gs,O.FieldDropdown=yt,O.FieldImage=Hs,O.FieldLabel=Ps,O.FieldLabelSerializable=of,O.FieldNavigationPolicy=fm,O.FieldNumber=bh,O.FieldTextInput=r.FieldTextInput$$module$build$src$core$field_textinput,O.FieldVariable=Rr,O.Flyout=pl,O.FlyoutButton=xt,O.FlyoutButtonNavigationPolicy=dm,O.FlyoutItem=Ci,O.FlyoutMetricsManager=hm,O.FlyoutNavigationPolicy=$m,O.FlyoutNavigator=bm,O.FlyoutSeparator=$l,O.FlyoutSeparatorNavigationPolicy=pm,O.FocusManager=Et,O.FocusableTreeTraverser=ft,O.Generator=r.CodeGenerator$$module$build$src$core$generator,O.Gesture=ml,O.Grid=Ka,O.HorizontalFlyout=tf,O.INPUT_VALUE=jb,O.Input=vi,O.InsertionMarkerPreviewer=Zm,O.KeyboardNavigationController=Em,O.LabelFlyoutInflater=Wm,O.LineCursor=Ja,O.Marker=vm,O.MarkerManager=qa,O.Menu=_a,O.MenuItem=Gn,O.MetricsManager=Ya,O.Msg=r.Msg$$module$build$src$core$msg,O.NEXT_STATEMENT=Jb,O.Names=r.Names$$module$build$src$core$names,O.Navigator=Xa,O.OPPOSITE_TYPE=Fs,O.OUTPUT_VALUE=Kb,O.Options=vo,O.PREVIOUS_STATEMENT=qb,O.PROCEDURE_CATEGORY_NAME=fl,O.Procedures=Nt,O.RENAME_VARIABLE_ID=Va,O.RenderedConnection=_t,O.Scrollbar=Ze,O.ScrollbarPair=ja,O.SeparatorFlyoutInflater=Tm,O.ShortcutItems=Ro,O.ShortcutRegistry=Pe,O.TOOLBOX_AT_BOTTOM=Qb,O.TOOLBOX_AT_LEFT=eT,O.TOOLBOX_AT_RIGHT=tT,O.TOOLBOX_AT_TOP=Zb,O.Theme=Bs,O.ThemeManager=Lm,O.Themes=Yb,O.Toast=ws,O.Toolbox=Vf,O.ToolboxCategory=ao,O.ToolboxItem=Bh,O.ToolboxSeparator=Nr,O.Tooltip=Vt,O.Touch=Ss,O.Trashcan=Pm,O.UnattachedFieldError=tt,O.VARIABLE_CATEGORY_NAME=va,O.VARIABLE_DYNAMIC_CATEGORY_NAME=ch,O.VERSION=Xb,O.VariableMap=Bm,O.VariableModel=xm,O.Variables=et,O.VariablesDynamic=hs,O.VerticalFlyout=_h,O.WidgetDiv=lo,O.Workspace=ki,O.WorkspaceAudio=Dm,O.WorkspaceDragger=ym,O.WorkspaceNavigationPolicy=_m,O.WorkspaceSvg=At,O.Xml=Ot,O.ZoomControls=ug,O.blockAnimations=Tr,O.blockRendering=Ne,O.browserEvents=Po,O.bubbles=Or,O.bumpObjects=hl,O.clipboard=uo,O.comments=ds,O.common=ht,O.config=r.config$$module$build$src$core$config,O.constants=Tb,O.defineBlocksWithJsonArray=$,O.dialog=Vo,O.dragging=wr,O.fieldRegistry=nl,O.geras=No,O.getFocusManager=r.getFocusManager$$module$build$src$core$focus_manager,O.getMainWorkspace=c,O.getSelected=I,O.hasBubble=Ts,O.hideChaff=Lp,O.icons=as,O.inject=Tp,O.inputs=$s,O.isCopyable=Qi,O.isDeletable=Kt,O.isDraggable=ai,O.isIcon=iu,O.isObservable=Tn,O.isPaster=Op,O.isRenderedElement=Np,O.isSelectable=Do,O.isSerializable=Ui,O.isVariableBackedParameterModel=rc,O.keyboardNavigationController=gl,O.layers=Eb,O.navigateBlock=ro,O.navigateStacks=ui,O.procedures=Nt,O.registry=Bo,O.renderManagement=zn,O.serialization=Hb,O.setLocale=ya,O.setParentContainer=so,O.svgResize=$o,O.thrasos=xh,O.uiPosition=Rs,O.utils=We,O.zelos=Oo,O.__namespace__=r,O})})(Ll)),Ll.exports}var nT=sd();const lT=Di(nT),{Block:cT,BlockFlyoutInflater:uT,BlockNavigationPolicy:aT,BlockSvg:hT,Blocks:dT,ButtonFlyoutInflater:$T,COLLAPSED_FIELD_NAME:pT,COLLAPSED_INPUT_NAME:gT,COLLAPSE_CHARS:mT,CodeGenerator:fT,CollapsibleToolboxCategory:_T,ComponentManager:bT,Connection:TT,ConnectionChecker:ET,ConnectionDB:yT,ConnectionNavigationPolicy:vT,ConnectionType:IT,ContextMenu:CT,ContextMenuItems:ST,ContextMenuRegistry:kT,Css:RT,DELETE_VARIABLE_ID:wT,DeleteArea:OT,DragTarget:NT,DropDownDiv:AT,Events:LT,Extensions:MT,Field:DT,FieldCheckbox:xT,FieldDropdown:BT,FieldImage:PT,FieldLabel:FT,FieldLabelSerializable:UT,FieldNavigationPolicy:HT,FieldNumber:GT,FieldTextInput:VT,FieldVariable:WT,Flyout:zT,FlyoutButton:YT,FlyoutButtonNavigationPolicy:XT,FlyoutItem:jT,FlyoutMetricsManager:KT,FlyoutNavigationPolicy:JT,FlyoutNavigator:qT,FlyoutSeparator:ZT,FlyoutSeparatorNavigationPolicy:QT,FocusManager:eE,FocusableTreeTraverser:tE,Generator:oE,Gesture:sE,Grid:iE,HorizontalFlyout:rE,INPUT_VALUE:nE,Input:lE,InsertionMarkerPreviewer:cE,KeyboardNavigationController:uE,LabelFlyoutInflater:aE,LineCursor:hE,Marker:dE,MarkerManager:$E,Menu:pE,MenuItem:gE,MetricsManager:mE,Msg:fE,NEXT_STATEMENT:_E,Names:bE,Navigator:TE,OPPOSITE_TYPE:EE,OUTPUT_VALUE:yE,Options:vE,PREVIOUS_STATEMENT:IE,PROCEDURE_CATEGORY_NAME:CE,Procedures:SE,RENAME_VARIABLE_ID:kE,RenderedConnection:RE,Scrollbar:wE,ScrollbarPair:OE,SeparatorFlyoutInflater:NE,ShortcutItems:AE,ShortcutRegistry:LE,TOOLBOX_AT_BOTTOM:ME,TOOLBOX_AT_LEFT:DE,TOOLBOX_AT_RIGHT:xE,TOOLBOX_AT_TOP:BE,Theme:PE,ThemeManager:FE,Themes:UE,Toast:HE,Toolbox:GE,ToolboxCategory:VE,ToolboxItem:WE,ToolboxSeparator:zE,Tooltip:YE,Touch:XE,Trashcan:jE,UnattachedFieldError:KE,VARIABLE_CATEGORY_NAME:JE,VARIABLE_DYNAMIC_CATEGORY_NAME:qE,VERSION:ZE,VariableMap:QE,VariableModel:ey,Variables:ty,VariablesDynamic:oy,VerticalFlyout:sy,WidgetDiv:iy,Workspace:ry,WorkspaceAudio:ny,WorkspaceDragger:ly,WorkspaceNavigationPolicy:cy,WorkspaceSvg:uy,Xml:ay,ZoomControls:hy,blockAnimations:dy,blockRendering:$y,browserEvents:py,bubbles:gy,bumpObjects:my,clipboard:fy,comments:_y,common:by,config:Ty,constants:Ey,defineBlocksWithJsonArray:yy,dialog:vy,dragging:Iy,fieldRegistry:Cy,geras:Sy,getFocusManager:ky,getMainWorkspace:Ry,getSelected:wy,hasBubble:Oy,hideChaff:Ny,icons:Ay,inject:Ly,inputs:My,isCopyable:Dy,isDeletable:xy,isDraggable:By,isIcon:Py,isObservable:Fy,isPaster:Uy,isRenderedElement:Hy,isSelectable:Gy,isSerializable:Vy,isVariableBackedParameterModel:Wy,keyboardNavigationController:zy,layers:Yy,navigateBlock:Xy,navigateStacks:jy,procedures:Ky,registry:Jy,renderManagement:qy,serialization:Zy,setLocale:jh,setParentContainer:Qy,svgResize:ev,thrasos:tv,uiPosition:ov,utils:sv,zelos:iv}=lT,id=Object.freeze(Object.defineProperty({__proto__:null,Block:cT,BlockFlyoutInflater:uT,BlockNavigationPolicy:aT,BlockSvg:hT,Blocks:dT,ButtonFlyoutInflater:$T,COLLAPSED_FIELD_NAME:pT,COLLAPSED_INPUT_NAME:gT,COLLAPSE_CHARS:mT,CodeGenerator:fT,CollapsibleToolboxCategory:_T,ComponentManager:bT,Connection:TT,ConnectionChecker:ET,ConnectionDB:yT,ConnectionNavigationPolicy:vT,ConnectionType:IT,ContextMenu:CT,ContextMenuItems:ST,ContextMenuRegistry:kT,Css:RT,DELETE_VARIABLE_ID:wT,DeleteArea:OT,DragTarget:NT,DropDownDiv:AT,Events:LT,Extensions:MT,Field:DT,FieldCheckbox:xT,FieldDropdown:BT,FieldImage:PT,FieldLabel:FT,FieldLabelSerializable:UT,FieldNavigationPolicy:HT,FieldNumber:GT,FieldTextInput:VT,FieldVariable:WT,Flyout:zT,FlyoutButton:YT,FlyoutButtonNavigationPolicy:XT,FlyoutItem:jT,FlyoutMetricsManager:KT,FlyoutNavigationPolicy:JT,FlyoutNavigator:qT,FlyoutSeparator:ZT,FlyoutSeparatorNavigationPolicy:QT,FocusManager:eE,FocusableTreeTraverser:tE,Generator:oE,Gesture:sE,Grid:iE,HorizontalFlyout:rE,INPUT_VALUE:nE,Input:lE,InsertionMarkerPreviewer:cE,KeyboardNavigationController:uE,LabelFlyoutInflater:aE,LineCursor:hE,Marker:dE,MarkerManager:$E,Menu:pE,MenuItem:gE,MetricsManager:mE,Msg:fE,NEXT_STATEMENT:_E,Names:bE,Navigator:TE,OPPOSITE_TYPE:EE,OUTPUT_VALUE:yE,Options:vE,PREVIOUS_STATEMENT:IE,PROCEDURE_CATEGORY_NAME:CE,Procedures:SE,RENAME_VARIABLE_ID:kE,RenderedConnection:RE,Scrollbar:wE,ScrollbarPair:OE,SeparatorFlyoutInflater:NE,ShortcutItems:AE,ShortcutRegistry:LE,TOOLBOX_AT_BOTTOM:ME,TOOLBOX_AT_LEFT:DE,TOOLBOX_AT_RIGHT:xE,TOOLBOX_AT_TOP:BE,Theme:PE,ThemeManager:FE,Themes:UE,Toast:HE,Toolbox:GE,ToolboxCategory:VE,ToolboxItem:WE,ToolboxSeparator:zE,Tooltip:YE,Touch:XE,Trashcan:jE,UnattachedFieldError:KE,VARIABLE_CATEGORY_NAME:JE,VARIABLE_DYNAMIC_CATEGORY_NAME:qE,VERSION:ZE,VariableMap:QE,VariableModel:ey,Variables:ty,VariablesDynamic:oy,VerticalFlyout:sy,WidgetDiv:iy,Workspace:ry,WorkspaceAudio:ny,WorkspaceDragger:ly,WorkspaceNavigationPolicy:cy,WorkspaceSvg:uy,Xml:ay,ZoomControls:hy,blockAnimations:dy,blockRendering:$y,browserEvents:py,bubbles:gy,bumpObjects:my,clipboard:fy,comments:_y,common:by,config:Ty,constants:Ey,defineBlocksWithJsonArray:yy,dialog:vy,dragging:Iy,fieldRegistry:Cy,geras:Sy,getFocusManager:ky,getMainWorkspace:Ry,getSelected:wy,hasBubble:Oy,hideChaff:Ny,icons:Ay,inject:Ly,inputs:My,isCopyable:Dy,isDeletable:xy,isDraggable:By,isIcon:Py,isObservable:Fy,isPaster:Uy,isRenderedElement:Hy,isSelectable:Gy,isSerializable:Vy,isVariableBackedParameterModel:Wy,keyboardNavigationController:zy,layers:Yy,navigateBlock:Xy,navigateStacks:jy,procedures:Ky,registry:Jy,renderManagement:qy,serialization:Zy,setLocale:jh,setParentContainer:Qy,svgResize:ev,thrasos:tv,uiPosition:ov,utils:sv,zelos:iv},Symbol.toStringTag,{value:"Module"}));var Ml={exports:{}},rv=Ml.exports,Jf;function nv(){return Jf||(Jf=1,(function(a,h){(function(r,l){a.exports=l(sd())})(rv,function(r){var l=r.__namespace__,g=l.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"variables_get_dynamic",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],output:null,style:"variable_dynamic_blocks",helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableDynamicSetterGetter"]},{type:"variables_set_dynamic",message0:"%{BKY_VARIABLES_SET}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"},{type:"input_value",name:"VALUE"}],previousStatement:null,nextStatement:null,style:"variable_dynamic_blocks",tooltip:"%{BKY_VARIABLES_SET_TOOLTIP}",helpUrl:"%{BKY_VARIABLES_SET_HELPURL}",extensions:["contextMenu_variableDynamicSetterGetter"]}]),m={customContextMenu:function(c){if(this.isInFlyout)(this.type==="variables_get_dynamic"||this.type==="variables_get_reporter_dynamic")&&(I={text:l.Msg$$module$build$src$core$msg.RENAME_VARIABLE,enabled:!0,callback:y(this)},C=this.getField("VAR").getText(),C={text:l.Msg$$module$build$src$core$msg.DELETE_VARIABLE.replace("%1",C),enabled:!0,callback:k(this)},c.unshift(I),c.unshift(C));else{if(this.type==="variables_get_dynamic")var p="variables_set_dynamic",I=l.Msg$$module$build$src$core$msg.VARIABLES_GET_CREATE_SET;else p="variables_get_dynamic",I=l.Msg$$module$build$src$core$msg.VARIABLES_SET_CREATE_GET;var C=this.getField("VAR");p={type:p,fields:{VAR:C.saveState(!0)}},c.push({enabled:this.workspace.remainingCapacity()>0,text:I.replace("%1",C.getText()),callback:l.callbackFactory$$module$build$src$core$contextmenu(this,p)})}},onchange:function(c){c=this.getFieldValue("VAR"),c=l.getVariable$$module$build$src$core$variables(this.workspace,c),this.type==="variables_get_dynamic"?this.outputConnection.setCheck(c.getType()):this.getInput("VALUE").connection.setCheck(c.getType())}},y=function(c){return function(){const p=c.workspace,I=c.getField("VAR").getVariable();l.renameVariable$$module$build$src$core$variables(p,I)}},k=function(c){return function(){const p=c.getField("VAR").getVariable();p&&l.deleteVariable$$module$build$src$core$variables(p.getWorkspace(),p,c)}};l.registerMixin$$module$build$src$core$extensions("contextMenu_variableDynamicSetterGetter",m),l.defineBlocks$$module$build$src$core$common(g);var A={blocks:g},D=l.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"variables_get",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],output:null,style:"variable_blocks",helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableSetterGetter"]},{type:"variables_set",message0:"%{BKY_VARIABLES_SET}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"},{type:"input_value",name:"VALUE"}],previousStatement:null,nextStatement:null,style:"variable_blocks",tooltip:"%{BKY_VARIABLES_SET_TOOLTIP}",helpUrl:"%{BKY_VARIABLES_SET_HELPURL}",extensions:["contextMenu_variableSetterGetter"]}]),H={customContextMenu:function(c){if(this.isInFlyout)(this.type==="variables_get"||this.type==="variables_get_reporter")&&(I={text:l.Msg$$module$build$src$core$msg.RENAME_VARIABLE,enabled:!0,callback:W(this)},C=this.getField("VAR").getText(),C={text:l.Msg$$module$build$src$core$msg.DELETE_VARIABLE.replace("%1",C),enabled:!0,callback:X(this)},c.unshift(I),c.unshift(C));else{if(this.type==="variables_get")var p="variables_set",I=l.Msg$$module$build$src$core$msg.VARIABLES_GET_CREATE_SET;else p="variables_get",I=l.Msg$$module$build$src$core$msg.VARIABLES_SET_CREATE_GET;var C=this.getField("VAR");p={type:p,fields:{VAR:C.saveState(!0)}},c.push({enabled:this.workspace.remainingCapacity()>0,text:I.replace("%1",C.getText()),callback:l.callbackFactory$$module$build$src$core$contextmenu(this,p)})}}},W=function(c){return function(){const p=c.workspace,I=c.getField("VAR").getVariable();l.renameVariable$$module$build$src$core$variables(p,I)}},X=function(c){return function(){const p=c.getField("VAR").getVariable();p&&l.deleteVariable$$module$build$src$core$variables(p.getWorkspace(),p,c)}};l.registerMixin$$module$build$src$core$extensions("contextMenu_variableSetterGetter",H),l.defineBlocks$$module$build$src$core$common(D);var ue={blocks:D},ie=l.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"text",message0:"%1",args0:[{type:"field_input",name:"TEXT",text:""}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_TEXT_HELPURL}",tooltip:"%{BKY_TEXT_TEXT_TOOLTIP}",extensions:["text_quotes","parent_tooltip_when_inline"]},{type:"text_join",message0:"",output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_JOIN_HELPURL}",tooltip:"%{BKY_TEXT_JOIN_TOOLTIP}",mutator:"text_join_mutator"},{type:"text_create_join_container",message0:"%{BKY_TEXT_CREATE_JOIN_TITLE_JOIN} %1 %2",args0:[{type:"input_dummy"},{type:"input_statement",name:"STACK"}],style:"text_blocks",tooltip:"%{BKY_TEXT_CREATE_JOIN_TOOLTIP}",enableContextMenu:!1},{type:"text_create_join_item",message0:"%{BKY_TEXT_CREATE_JOIN_ITEM_TITLE_ITEM}",previousStatement:null,nextStatement:null,style:"text_blocks",tooltip:"%{BKY_TEXT_CREATE_JOIN_ITEM_TOOLTIP}",enableContextMenu:!1},{type:"text_append",message0:"%{BKY_TEXT_APPEND_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_TEXT_APPEND_VARIABLE}"},{type:"input_value",name:"TEXT"}],previousStatement:null,nextStatement:null,style:"text_blocks",extensions:["text_append_tooltip"]},{type:"text_length",message0:"%{BKY_TEXT_LENGTH_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",style:"text_blocks",tooltip:"%{BKY_TEXT_LENGTH_TOOLTIP}",helpUrl:"%{BKY_TEXT_LENGTH_HELPURL}"},{type:"text_isEmpty",message0:"%{BKY_TEXT_ISEMPTY_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",style:"text_blocks",tooltip:"%{BKY_TEXT_ISEMPTY_TOOLTIP}",helpUrl:"%{BKY_TEXT_ISEMPTY_HELPURL}"},{type:"text_indexOf",message0:"%{BKY_TEXT_INDEXOF_TITLE}",args0:[{type:"input_value",name:"VALUE",check:"String"},{type:"field_dropdown",name:"END",options:[["%{BKY_TEXT_INDEXOF_OPERATOR_FIRST}","FIRST"],["%{BKY_TEXT_INDEXOF_OPERATOR_LAST}","LAST"]]},{type:"input_value",name:"FIND",check:"String"}],output:"Number",style:"text_blocks",helpUrl:"%{BKY_TEXT_INDEXOF_HELPURL}",inputsInline:!0,extensions:["text_indexOf_tooltip"]},{type:"text_charAt",message0:"%{BKY_TEXT_CHARAT_TITLE}",args0:[{type:"input_value",name:"VALUE",check:"String"},{type:"field_dropdown",name:"WHERE",options:[["%{BKY_TEXT_CHARAT_FROM_START}","FROM_START"],["%{BKY_TEXT_CHARAT_FROM_END}","FROM_END"],["%{BKY_TEXT_CHARAT_FIRST}","FIRST"],["%{BKY_TEXT_CHARAT_LAST}","LAST"],["%{BKY_TEXT_CHARAT_RANDOM}","RANDOM"]]}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_CHARAT_HELPURL}",inputsInline:!0,mutator:"text_charAt_mutator"}]),K={init:function(){this.WHERE_OPTIONS_1=[[l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_START_FROM_START,"FROM_START"],[l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_START_FROM_END,"FROM_END"],[l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_START_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_END_FROM_START,"FROM_START"],[l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_END_FROM_END,"FROM_END"],[l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_END_LAST,"LAST"]],this.setHelpUrl(l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_HELPURL),this.setStyle("text_blocks"),this.appendValueInput("STRING").setCheck("String").appendField(l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT);const c=p=>{const I=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:this["WHERE_OPTIONS_"+p]});return I.setValidator(function(C){const V=this.getValue();C=C==="FROM_START"||C==="FROM_END",C!==(V==="FROM_START"||V==="FROM_END")&&this.getSourceBlock().updateAt_(p,C)}),I};this.appendDummyInput("WHERE1_INPUT").appendField(c(1),"WHERE1"),this.appendDummyInput("AT1"),this.appendDummyInput("WHERE2_INPUT").appendField(c(2),"WHERE2"),this.appendDummyInput("AT2"),l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_TAIL&&this.appendDummyInput("TAIL").appendField(l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_TAIL),this.setInputsInline(!0),this.setOutput(!0,"String"),this.updateAt_(1,!0),this.updateAt_(2,!0),this.setTooltip(l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_TOOLTIP)},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");var p=this.getInput("AT1")instanceof l.ValueInput$$module$build$src$core$inputs$value_input;return c.setAttribute("at1",`${p}`),p=this.getInput("AT2")instanceof l.ValueInput$$module$build$src$core$inputs$value_input,c.setAttribute("at2",`${p}`),c},domToMutation:function(c){const p=c.getAttribute("at1")==="true";c=c.getAttribute("at2")==="true",this.updateAt_(1,p),this.updateAt_(2,c)},updateAt_:function(c,p){this.removeInput("AT"+c),this.removeInput("ORDINAL"+c,!0),p?(this.appendValueInput("AT"+c).setCheck("Number"),l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+c).appendField(l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+c),c===2&&l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField(l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_TAIL)),c===1&&(this.moveInputBefore("AT1","WHERE2_INPUT"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","WHERE2_INPUT"))}};ie.text_getSubstring=K,ie.text_changeCase={init:function(){const c=[[l.Msg$$module$build$src$core$msg.TEXT_CHANGECASE_OPERATOR_UPPERCASE,"UPPERCASE"],[l.Msg$$module$build$src$core$msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE,"LOWERCASE"],[l.Msg$$module$build$src$core$msg.TEXT_CHANGECASE_OPERATOR_TITLECASE,"TITLECASE"]];this.setHelpUrl(l.Msg$$module$build$src$core$msg.TEXT_CHANGECASE_HELPURL),this.setStyle("text_blocks"),this.appendValueInput("TEXT").setCheck("String").appendField(l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:c}),"CASE"),this.setOutput(!0,"String"),this.setTooltip(l.Msg$$module$build$src$core$msg.TEXT_CHANGECASE_TOOLTIP)}},ie.text_trim={init:function(){const c=[[l.Msg$$module$build$src$core$msg.TEXT_TRIM_OPERATOR_BOTH,"BOTH"],[l.Msg$$module$build$src$core$msg.TEXT_TRIM_OPERATOR_LEFT,"LEFT"],[l.Msg$$module$build$src$core$msg.TEXT_TRIM_OPERATOR_RIGHT,"RIGHT"]];this.setHelpUrl(l.Msg$$module$build$src$core$msg.TEXT_TRIM_HELPURL),this.setStyle("text_blocks"),this.appendValueInput("TEXT").setCheck("String").appendField(l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:c}),"MODE"),this.setOutput(!0,"String"),this.setTooltip(l.Msg$$module$build$src$core$msg.TEXT_TRIM_TOOLTIP)}},ie.text_print={init:function(){this.jsonInit({message0:l.Msg$$module$build$src$core$msg.TEXT_PRINT_TITLE,args0:[{type:"input_value",name:"TEXT"}],previousStatement:null,nextStatement:null,style:"text_blocks",tooltip:l.Msg$$module$build$src$core$msg.TEXT_PRINT_TOOLTIP,helpUrl:l.Msg$$module$build$src$core$msg.TEXT_PRINT_HELPURL})}};var ee={updateType_:function(c){this.outputConnection.setCheck(c==="NUMBER"?"Number":"String")},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");return c.setAttribute("type",this.getFieldValue("TYPE")),c},domToMutation:function(c){this.updateType_(c.getAttribute("type"))}};ie.text_prompt_ext=Object.assign({},ee,{init:function(){var c=[[l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];this.setHelpUrl(l.Msg$$module$build$src$core$msg.TEXT_PROMPT_HELPURL),this.setStyle("text_blocks"),c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:c}),c.setValidator(p=>{this.updateType_(p)}),this.appendValueInput("TEXT").appendField(c,"TYPE"),this.setOutput(!0,"String"),this.setTooltip(()=>this.getFieldValue("TYPE")==="TEXT"?l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_TEXT:l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_NUMBER)}}),ie.text_prompt=Object.assign({},ee,{init:function(){this.mixin(me);var c=[[l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];this.setHelpUrl(l.Msg$$module$build$src$core$msg.TEXT_PROMPT_HELPURL),this.setStyle("text_blocks"),c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:c}),c.setValidator(p=>{this.updateType_(p)}),this.appendDummyInput().appendField(c,"TYPE").appendField(this.newQuote_(!0)).appendField(l.fromJson$$module$build$src$core$field_registry({type:"field_input",text:""}),"TEXT").appendField(this.newQuote_(!1)),this.setOutput(!0,"String"),this.setTooltip(()=>this.getFieldValue("TYPE")==="TEXT"?l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_TEXT:l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_NUMBER)}}),ie.text_count={init:function(){this.jsonInit({message0:l.Msg$$module$build$src$core$msg.TEXT_COUNT_MESSAGE0,args0:[{type:"input_value",name:"SUB",check:"String"},{type:"input_value",name:"TEXT",check:"String"}],output:"Number",inputsInline:!0,style:"text_blocks",tooltip:l.Msg$$module$build$src$core$msg.TEXT_COUNT_TOOLTIP,helpUrl:l.Msg$$module$build$src$core$msg.TEXT_COUNT_HELPURL})}},ie.text_replace={init:function(){this.jsonInit({message0:l.Msg$$module$build$src$core$msg.TEXT_REPLACE_MESSAGE0,args0:[{type:"input_value",name:"FROM",check:"String"},{type:"input_value",name:"TO",check:"String"},{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:l.Msg$$module$build$src$core$msg.TEXT_REPLACE_TOOLTIP,helpUrl:l.Msg$$module$build$src$core$msg.TEXT_REPLACE_HELPURL})}},ie.text_reverse={init:function(){this.jsonInit({message0:l.Msg$$module$build$src$core$msg.TEXT_REVERSE_MESSAGE0,args0:[{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:l.Msg$$module$build$src$core$msg.TEXT_REVERSE_TOOLTIP,helpUrl:l.Msg$$module$build$src$core$msg.TEXT_REVERSE_HELPURL})}};var me={QUOTE_IMAGE_LEFT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC",QUOTE_IMAGE_RIGHT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==",QUOTE_IMAGE_WIDTH:12,QUOTE_IMAGE_HEIGHT:12,quoteField_:function(c){for(let p=0,I;I=this.inputList[p];p++)for(let C=0,V;V=I.fieldRow[C];C++)if(c===V.name){I.insertFieldAt(C,this.newQuote_(!0)),I.insertFieldAt(C+2,this.newQuote_(!1));return}console.warn('field named "'+c+'" not found in '+this.toDevString())},newQuote_:function(c){return c=this.RTL?!c:c,l.fromJson$$module$build$src$core$field_registry({type:"field_image",src:c?this.QUOTE_IMAGE_LEFT_DATAURI:this.QUOTE_IMAGE_RIGHT_DATAURI,width:this.QUOTE_IMAGE_WIDTH,height:this.QUOTE_IMAGE_HEIGHT,alt:c?"“":"”"})}},z=function(){this.mixin(me),this.quoteField_("TEXT")},ae={itemCount_:0,mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");return c.setAttribute("items",`${this.itemCount_}`),c},domToMutation:function(c){this.itemCount_=parseInt(c.getAttribute("items"),10),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(c){this.itemCount_=c.itemCount,this.updateShape_()},decompose:function(c){const p=c.newBlock("text_create_join_container");p.initSvg();let I=p.getInput("STACK").connection;for(let C=0;C<this.itemCount_;C++){const V=c.newBlock("text_create_join_item");V.initSvg(),I.connect(V.previousConnection),I=V.nextConnection}return p},compose:function(c){var p=c.getInputTargetBlock("STACK");for(c=[];p;)p.isInsertionMarker()||c.push(p.valueConnection_),p=p.getNextBlock();for(p=0;p<this.itemCount_;p++){const I=this.getInput("ADD"+p).connection.targetConnection;I&&!c.includes(I)&&I.disconnect()}for(this.itemCount_=c.length,this.updateShape_(),p=0;p<this.itemCount_;p++){let I;(I=c[p])==null||I.reconnect(this,"ADD"+p)}},saveConnections:function(c){c=c.getInputTargetBlock("STACK");let p=0;for(;c;){if(c.isInsertionMarker()){c=c.getNextBlock();continue}const I=this.getInput("ADD"+p);c.valueConnection_=I&&I.connection.targetConnection,c=c.getNextBlock(),p++}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(this.newQuote_(!0)).appendField(this.newQuote_(!1));for(var c=0;c<this.itemCount_;c++)if(!this.getInput("ADD"+c)){const p=this.appendValueInput("ADD"+c).setAlign(l.Align$$module$build$src$core$inputs$align.RIGHT);c===0&&p.appendField(l.Msg$$module$build$src$core$msg.TEXT_JOIN_TITLE_CREATEWITH)}for(c=this.itemCount_;this.getInput("ADD"+c);c++)this.removeInput("ADD"+c)}},te=function(){this.mixin(me),this.itemCount_=2,this.updateShape_(),this.setMutator(new l.MutatorIcon$$module$build$src$core$icons$mutator_icon(["text_create_join_item"],this))};l.register$$module$build$src$core$extensions("text_append_tooltip",l.buildTooltipWithFieldText$$module$build$src$core$extensions("%{BKY_TEXT_APPEND_TOOLTIP}","VAR"));var Y=function(){this.setTooltip(()=>l.Msg$$module$build$src$core$msg.TEXT_INDEXOF_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"0":"-1"))},Ie={isAt_:!1,mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");return c.setAttribute("at",`${this.isAt_}`),c},domToMutation:function(c){c=c.getAttribute("at")!=="false",this.updateAt_(c)},updateAt_:function(c){this.removeInput("AT",!0),this.removeInput("ORDINAL",!0),c&&(this.appendValueInput("AT").setCheck("Number"),l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)),l.Msg$$module$build$src$core$msg.TEXT_CHARAT_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField(l.Msg$$module$build$src$core$msg.TEXT_CHARAT_TAIL)),this.isAt_=c}},Ye=function(){this.getField("WHERE").setValidator(function(c){c=c==="FROM_START"||c==="FROM_END";const p=this.getSourceBlock();c!==p.isAt_&&p.updateAt_(c)}),this.updateAt_(!0),this.setTooltip(()=>{var c=this.getFieldValue("WHERE");let p=l.Msg$$module$build$src$core$msg.TEXT_CHARAT_TOOLTIP;return(c==="FROM_START"||c==="FROM_END")&&(c=c==="FROM_START"?l.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_START_TOOLTIP:l.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_END_TOOLTIP)&&(p+=" "+c.replace("%1",this.workspace.options.oneBasedIndex?"#1":"#0")),p})};l.register$$module$build$src$core$extensions("text_indexOf_tooltip",Y),l.register$$module$build$src$core$extensions("text_quotes",z),l.registerMixin$$module$build$src$core$extensions("quote_image_mixin",me),l.registerMutator$$module$build$src$core$extensions("text_join_mutator",ae,te),l.registerMutator$$module$build$src$core$extensions("text_charAt_mutator",Ie,Ye),l.defineBlocks$$module$build$src$core$common(ie);var It={blocks:ie},Re={},rt={setStatements_:function(c){this.hasStatements_!==c&&(c?(this.appendStatementInput("STACK").appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=c)},updateParams_:function(){let c="";this.arguments_.length&&(c=l.Msg$$module$build$src$core$msg.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", ")),l.disable$$module$build$src$core$events$utils();try{this.setFieldValue(c,"PARAMS")}finally{l.enable$$module$build$src$core$events$utils()}},mutationToDom:function(c){const p=l.createElement$$module$build$src$core$utils$xml("mutation");c&&p.setAttribute("name",this.getFieldValue("NAME"));for(let I=0;I<this.argumentVarModels_.length;I++){const C=l.createElement$$module$build$src$core$utils$xml("arg"),V=this.argumentVarModels_[I];C.setAttribute("name",V.getName()),C.setAttribute("varid",V.getId()),c&&this.paramIds_&&C.setAttribute("paramId",this.paramIds_[I]),p.appendChild(C)}return this.hasStatements_||p.setAttribute("statements","false"),p},domToMutation:function(c){this.arguments_=[],this.argumentVarModels_=[];for(let I=0,C;C=c.childNodes[I];I++)if(C.nodeName.toLowerCase()==="arg"){var p=C;const V=p.getAttribute("name");p=p.getAttribute("varid")||p.getAttribute("varId"),this.arguments_.push(V),p=l.getOrCreateVariablePackage$$module$build$src$core$variables(this.workspace,p,V,""),p!==null?this.argumentVarModels_.push(p):console.log(`Failed to create a variable named "${V}", ignoring.`)}this.updateParams_(),l.mutateCallers$$module$build$src$core$procedures(this),this.setStatements_(c.getAttribute("statements")!=="false")},saveExtraState:function(){if(!this.argumentVarModels_.length&&this.hasStatements_)return null;const c=Object.create(null);if(this.argumentVarModels_.length){c.params=[];for(let p=0;p<this.argumentVarModels_.length;p++)c.params.push({name:this.argumentVarModels_[p].getName(),id:this.argumentVarModels_[p].getId()})}return this.hasStatements_||(c.hasStatements=!1),c},loadExtraState:function(c){if(this.arguments_=[],this.argumentVarModels_=[],c.params)for(let I=0;I<c.params.length;I++){var p=c.params[I];p=l.getOrCreateVariablePackage$$module$build$src$core$variables(this.workspace,p.id,p.name,""),this.arguments_.push(p.getName()),this.argumentVarModels_.push(p)}this.updateParams_(),l.mutateCallers$$module$build$src$core$procedures(this),this.setStatements_(c.hasStatements!==!1)},decompose:function(c){const p=l.createElement$$module$build$src$core$utils$xml("block");p.setAttribute("type","procedures_mutatorcontainer");var I=l.createElement$$module$build$src$core$utils$xml("statement");I.setAttribute("name","STACK"),p.appendChild(I);for(let V=0;V<this.arguments_.length;V++){const Ae=l.createElement$$module$build$src$core$utils$xml("block");Ae.setAttribute("type","procedures_mutatorarg");var C=l.createElement$$module$build$src$core$utils$xml("field");C.setAttribute("name","NAME");const so=l.createTextNode$$module$build$src$core$utils$xml(this.arguments_[V]);C.appendChild(so),Ae.appendChild(C),C=l.createElement$$module$build$src$core$utils$xml("next"),Ae.appendChild(C),I.appendChild(Ae),I=C}return c=l.domToBlock$$module$build$src$core$xml(p,c),this.type==="procedures_defreturn"?c.setFieldValue(this.hasStatements_,"STATEMENTS"):c.removeInput("STATEMENT_INPUT"),l.mutateCallers$$module$build$src$core$procedures(this),c},compose:function(c){this.arguments_=[],this.paramIds_=[],this.argumentVarModels_=[];let p=c.getInputTargetBlock("STACK");for(;p&&!p.isInsertionMarker();){var I=p.getFieldValue("NAME");this.arguments_.push(I),I=this.workspace.getVariable(I,""),this.argumentVarModels_.push(I),this.paramIds_.push(p.id),p=p.nextConnection&&p.nextConnection.targetBlock()}if(this.updateParams_(),l.mutateCallers$$module$build$src$core$procedures(this),c=c.getFieldValue("STATEMENTS"),c!==null&&(c=c==="TRUE",this.hasStatements_!==c))if(c){this.setStatements_(!0);var C;(C=this.statementConnection_)==null||C.reconnect(this,"STACK"),this.statementConnection_=null}else C=this.getInput("STACK").connection,(this.statementConnection_=C.targetConnection)&&(C=C.targetBlock(),C.unplug(),C.bumpNeighbours()),this.setStatements_(!1)},getVars:function(){return this.arguments_},getVarModels:function(){return this.argumentVarModels_},renameVarById:function(c,p){var I=this.workspace.getVariableById(c);if(I.getType()===""){I=I.getName(),p=this.workspace.getVariableById(p);var C=!1;for(let V=0;V<this.argumentVarModels_.length;V++)this.argumentVarModels_[V].getId()===c&&(this.arguments_[V]=p.getName(),this.argumentVarModels_[V]=p,C=!0);C&&(this.displayRenamedVar_(I,p.getName()),l.mutateCallers$$module$build$src$core$procedures(this))}},updateVarName:function(c){const p=c.getName();let I=!1,C;for(let V=0;V<this.argumentVarModels_.length;V++)this.argumentVarModels_[V].getId()===c.getId()&&(C=this.arguments_[V],this.arguments_[V]=p,I=!0);I&&(this.displayRenamedVar_(C,p),l.mutateCallers$$module$build$src$core$procedures(this))},displayRenamedVar_:function(c,p){this.updateParams_();var I=this.getIcon(l.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE);if(I&&I.bubbleIsVisible()){I=I.getWorkspace().getAllBlocks(!1);for(let C=0,V;V=I[C];C++)V.type==="procedures_mutatorarg"&&l.Names$$module$build$src$core$names.equals(c,V.getFieldValue("NAME"))&&V.setFieldValue(p,"NAME")}},customContextMenu:function(c){if(!this.isInFlyout){var p=this.getFieldValue("NAME"),I={type:this.callType_,extraState:{name:p,params:this.arguments_}};if(c.push({enabled:!0,text:l.Msg$$module$build$src$core$msg.PROCEDURES_CREATE_DO.replace("%1",p),callback:l.callbackFactory$$module$build$src$core$contextmenu(this,I)}),!this.isCollapsed())for(p=0;p<this.argumentVarModels_.length;p++){I=this.argumentVarModels_[p];const C={type:"variables_get",fields:{VAR:{name:I.getName(),id:I.getId(),type:I.getType()}}};c.push({enabled:!0,text:l.Msg$$module$build$src$core$msg.VARIABLES_SET_CREATE_GET.replace("%1",I.getName()),callback:l.callbackFactory$$module$build$src$core$contextmenu(this,C)})}}}};Re.procedures_defnoreturn=Object.assign({},rt,{init:function(){var c=l.findLegalName$$module$build$src$core$procedures("",this);c=l.fromJson$$module$build$src$core$field_registry({type:"field_input",text:c}),c.setValidator(l.rename$$module$build$src$core$procedures),c.setSpellcheck(!1),this.appendDummyInput().appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_TITLE).appendField(c,"NAME").appendField("","PARAMS"),this.setMutator(new l.MutatorIcon$$module$build$src$core$icons$mutator_icon(["procedures_mutatorarg"],this)),(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&l.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_COMMENT&&this.setCommentText(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_COMMENT),this.setStyle("procedure_blocks"),this.setTooltip(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_TOOLTIP),this.setHelpUrl(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.setStatements_(!0),this.statementConnection_=null},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!1]},callType_:"procedures_callnoreturn"}),Re.procedures_defreturn=Object.assign({},rt,{init:function(){var c=l.findLegalName$$module$build$src$core$procedures("",this);c=l.fromJson$$module$build$src$core$field_registry({type:"field_input",text:c}),c.setValidator(l.rename$$module$build$src$core$procedures),c.setSpellcheck(!1),this.appendDummyInput().appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_TITLE).appendField(c,"NAME").appendField("","PARAMS"),this.appendValueInput("RETURN").setAlign(l.Align$$module$build$src$core$inputs$align.RIGHT).appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_RETURN),this.setMutator(new l.MutatorIcon$$module$build$src$core$icons$mutator_icon(["procedures_mutatorarg"],this)),(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_COMMENT&&this.setCommentText(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_COMMENT),this.setStyle("procedure_blocks"),this.setTooltip(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_TOOLTIP),this.setHelpUrl(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.setStatements_(!0),this.statementConnection_=null},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!0]},callType_:"procedures_callreturn"});var bt={init:function(){this.appendDummyInput().appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_MUTATORCONTAINER_TITLE),this.appendStatementInput("STACK"),this.appendDummyInput("STATEMENT_INPUT").appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_ALLOW_STATEMENTS).appendField(l.fromJson$$module$build$src$core$field_registry({type:"field_checkbox",checked:!0}),"STATEMENTS"),this.setStyle("procedure_blocks"),this.setTooltip(l.Msg$$module$build$src$core$msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP),this.contextMenu=!1}};Re.procedures_mutatorcontainer=bt;var Bt=class extends l.FieldTextInput$$module$build$src$core$field_textinput{constructor(){super(...arguments),this.editingInteractively=!1}showEditor_(c){super.showEditor_(c),this.editingInteractively=!0,this.editingVariable=void 0}onFinishEditing_(c){super.onFinishEditing_(c),this.editingInteractively=!1}},Ct={init:function(){const c=new Bt(l.DEFAULT_ARG$$module$build$src$core$procedures,this.validator_);this.appendDummyInput().appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_MUTATORARG_TITLE).appendField(c,"NAME"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle("procedure_blocks"),this.setTooltip(l.Msg$$module$build$src$core$msg.PROCEDURES_MUTATORARG_TOOLTIP),this.contextMenu=!1},validator_:function(c){var p=this.getSourceBlock();const I=p.workspace.getRootWorkspace();if(c=c.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,""),!c)return null;const C=(p.workspace.targetWorkspace||p.workspace).getAllBlocks(!1),V=c.toLowerCase();for(let Ae=0;Ae<C.length;Ae++){if(C[Ae].id===this.getSourceBlock().id)continue;const so=C[Ae].getFieldValue("NAME");if(so&&so.toLowerCase()===V)return null}return p.isInFlyout||((p=I.getVariable(c,""))&&p.getName()!==c&&I.renameVariableById(p.getId(),c),p||(this.editingInteractively?this.editingVariable?I.renameVariableById(this.editingVariable.getId(),c):this.editingVariable=I.createVariable(c,""):I.createVariable(c,""))),c}};Re.procedures_mutatorarg=Ct;var nt="DISABLED_PROCEDURE_DEFINITION",Tt={getProcedureCall:function(){return this.getFieldValue("NAME")},renameProcedure:function(c,p){l.Names$$module$build$src$core$names.equals(c,this.getProcedureCall())&&(this.setFieldValue(p,"NAME"),this.setTooltip((this.outputConnection?l.Msg$$module$build$src$core$msg.PROCEDURES_CALLRETURN_TOOLTIP:l.Msg$$module$build$src$core$msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",p)))},setProcedureParameters_:function(c,p){var I=l.getDefinition$$module$build$src$core$procedures(this.getProcedureCall(),this.workspace);if((I=(I=I&&I.getIcon(l.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE))&&I.bubbleIsVisible())?this.setCollapsed(!1):(this.quarkConnections_={},this.quarkIds_=null),c.join(`
791
+ `),l(M.TOOLBOX,Ft,Yf);var Jb="12.2.0",qb=Z.INPUT_VALUE,Zb=Z.OUTPUT_VALUE,Qb=Z.NEXT_STATEMENT,eT=Z.PREVIOUS_STATEMENT,tT=be.TOP,oT=be.BOTTOM,sT=be.LEFT,iT=be.RIGHT;ki.prototype.newBlock=function(e,t){return new Ii(this,e,t)},At.prototype.newBlock=function(e,t){return new Be(this,e,t)},ki.prototype.newComment=function(e){return new nl(this,e)},At.prototype.newComment=function(e){return new yo(this,e)},At.newTrashcan=function(e){return new Hm(e)},Wo.prototype.newWorkspaceSvg=function(e){return new At(e)},r.Names$$module$build$src$core$names.prototype.populateProcedures=function(e){e=Zi(e),e=e[0].concat(e[1]);for(let t=0;t<e.length;t++)this.getName(e[t][0],r.Names$$module$build$src$core$names.NameType.PROCEDURE)};var O={};return O.Block=Ii,O.BlockFlyoutInflater=Mf,O.BlockNavigationPolicy=_m,O.BlockSvg=Be,O.Blocks=Ge,O.ButtonFlyoutInflater=Lf,O.COLLAPSED_FIELD_NAME=Wn,O.COLLAPSED_INPUT_NAME=ar,O.COLLAPSE_CHARS=cm,O.CodeGenerator=r.CodeGenerator$$module$build$src$core$generator,O.CollapsibleToolboxCategory=Ai,O.ComponentManager=Ve,O.Connection=Ce,O.ConnectionChecker=Bm,O.ConnectionDB=Ei,O.ConnectionNavigationPolicy=bm,O.ConnectionType=Z,O.ContextMenu=xs,O.ContextMenuItems=dt,O.ContextMenuRegistry=Ee,O.Css=pa,O.DELETE_VARIABLE_ID=Ya,O.DeleteArea=$l,O.DragTarget=$m,O.DropDownDiv=wt,O.Events=j,O.Extensions=co,O.Field=we,O.FieldCheckbox=Gs,O.FieldDropdown=yt,O.FieldImage=Hs,O.FieldLabel=Ps,O.FieldLabelSerializable=nf,O.FieldNavigationPolicy=Tm,O.FieldNumber=Eh,O.FieldTextInput=r.FieldTextInput$$module$build$src$core$field_textinput,O.FieldVariable=wr,O.Flyout=gl,O.FlyoutButton=xt,O.FlyoutButtonNavigationPolicy=gm,O.FlyoutItem=Ci,O.FlyoutMetricsManager=pm,O.FlyoutNavigationPolicy=mm,O.FlyoutNavigator=ym,O.FlyoutSeparator=pl,O.FlyoutSeparatorNavigationPolicy=fm,O.FocusManager=Et,O.FocusableTreeTraverser=ft,O.Generator=r.CodeGenerator$$module$build$src$core$generator,O.Gesture=fl,O.Grid=qa,O.HorizontalFlyout=rf,O.INPUT_VALUE=qb,O.Input=vi,O.InsertionMarkerPreviewer=tf,O.KeyboardNavigationController=Im,O.LabelFlyoutInflater=Xm,O.LineCursor=Za,O.Marker=Sm,O.MarkerManager=Qa,O.Menu=Ta,O.MenuItem=Vn,O.MetricsManager=ja,O.Msg=r.Msg$$module$build$src$core$msg,O.NEXT_STATEMENT=Qb,O.Names=r.Names$$module$build$src$core$names,O.Navigator=Ka,O.OPPOSITE_TYPE=Fs,O.OUTPUT_VALUE=Zb,O.Options=vo,O.PREVIOUS_STATEMENT=eT,O.PROCEDURE_CATEGORY_NAME=_l,O.Procedures=Nt,O.RENAME_VARIABLE_ID=za,O.RenderedConnection=_t,O.Scrollbar=Ze,O.ScrollbarPair=Ja,O.SeparatorFlyoutInflater=vm,O.ShortcutItems=Ro,O.ShortcutRegistry=Pe,O.TOOLBOX_AT_BOTTOM=oT,O.TOOLBOX_AT_LEFT=sT,O.TOOLBOX_AT_RIGHT=iT,O.TOOLBOX_AT_TOP=tT,O.Theme=Bs,O.ThemeManager=xm,O.Themes=Kb,O.Toast=ws,O.Toolbox=Yf,O.ToolboxCategory=ao,O.ToolboxItem=Fh,O.ToolboxSeparator=Ar,O.Tooltip=Vt,O.Touch=Ss,O.Trashcan=Hm,O.UnattachedFieldError=tt,O.VARIABLE_CATEGORY_NAME=Ca,O.VARIABLE_DYNAMIC_CATEGORY_NAME=ah,O.VERSION=Jb,O.VariableMap=Um,O.VariableModel=Fm,O.Variables=et,O.VariablesDynamic=hs,O.VerticalFlyout=Th,O.WidgetDiv=lo,O.Workspace=ki,O.WorkspaceAudio=Pm,O.WorkspaceDragger=Cm,O.WorkspaceNavigationPolicy=Em,O.WorkspaceSvg=At,O.Xml=Ot,O.ZoomControls=dg,O.blockAnimations=Er,O.blockRendering=Ne,O.browserEvents=Po,O.bubbles=Nr,O.bumpObjects=dl,O.clipboard=uo,O.comments=ds,O.common=ht,O.config=r.config$$module$build$src$core$config,O.constants=vb,O.defineBlocksWithJsonArray=$,O.dialog=Vo,O.dragging=Or,O.fieldRegistry=ll,O.geras=No,O.getFocusManager=r.getFocusManager$$module$build$src$core$focus_manager,O.getMainWorkspace=c,O.getSelected=I,O.hasBubble=Ts,O.hideChaff=xp,O.icons=as,O.inject=vp,O.inputs=$s,O.isCopyable=er,O.isDeletable=Kt,O.isDraggable=ai,O.isIcon=nu,O.isObservable=En,O.isPaster=Lp,O.isRenderedElement=Mp,O.isSelectable=Do,O.isSerializable=Hi,O.isVariableBackedParameterModel=lc,O.keyboardNavigationController=ml,O.layers=Ib,O.navigateBlock=ro,O.navigateStacks=ui,O.procedures=Nt,O.registry=Bo,O.renderManagement=Yn,O.serialization=Wb,O.setLocale=Ia,O.setParentContainer=so,O.svgResize=$o,O.thrasos=Ph,O.uiPosition=Rs,O.utils=We,O.zelos=Oo,O.__namespace__=r,O})})(Ml)),Ml.exports}var uT=nd();const aT=xi(uT),{Block:hT,BlockFlyoutInflater:dT,BlockNavigationPolicy:$T,BlockSvg:pT,Blocks:gT,ButtonFlyoutInflater:mT,COLLAPSED_FIELD_NAME:fT,COLLAPSED_INPUT_NAME:_T,COLLAPSE_CHARS:bT,CodeGenerator:TT,CollapsibleToolboxCategory:ET,ComponentManager:yT,Connection:vT,ConnectionChecker:IT,ConnectionDB:CT,ConnectionNavigationPolicy:ST,ConnectionType:kT,ContextMenu:RT,ContextMenuItems:wT,ContextMenuRegistry:OT,Css:NT,DELETE_VARIABLE_ID:AT,DeleteArea:LT,DragTarget:MT,DropDownDiv:DT,Events:Dl,Extensions:xT,Field:BT,FieldCheckbox:PT,FieldDropdown:FT,FieldImage:UT,FieldLabel:HT,FieldLabelSerializable:GT,FieldNavigationPolicy:VT,FieldNumber:WT,FieldTextInput:zT,FieldVariable:YT,Flyout:XT,FlyoutButton:jT,FlyoutButtonNavigationPolicy:KT,FlyoutItem:JT,FlyoutMetricsManager:qT,FlyoutNavigationPolicy:ZT,FlyoutNavigator:QT,FlyoutSeparator:eE,FlyoutSeparatorNavigationPolicy:tE,FocusManager:oE,FocusableTreeTraverser:sE,Generator:iE,Gesture:rE,Grid:nE,HorizontalFlyout:lE,INPUT_VALUE:cE,Input:uE,InsertionMarkerPreviewer:aE,KeyboardNavigationController:hE,LabelFlyoutInflater:dE,LineCursor:$E,Marker:pE,MarkerManager:gE,Menu:mE,MenuItem:fE,MetricsManager:_E,Msg:bE,NEXT_STATEMENT:TE,Names:EE,Navigator:yE,OPPOSITE_TYPE:vE,OUTPUT_VALUE:IE,Options:CE,PREVIOUS_STATEMENT:SE,PROCEDURE_CATEGORY_NAME:kE,Procedures:RE,RENAME_VARIABLE_ID:wE,RenderedConnection:OE,Scrollbar:NE,ScrollbarPair:AE,SeparatorFlyoutInflater:LE,ShortcutItems:ME,ShortcutRegistry:DE,TOOLBOX_AT_BOTTOM:xE,TOOLBOX_AT_LEFT:BE,TOOLBOX_AT_RIGHT:PE,TOOLBOX_AT_TOP:FE,Theme:UE,ThemeManager:HE,Themes:GE,Toast:VE,Toolbox:WE,ToolboxCategory:zE,ToolboxItem:YE,ToolboxSeparator:XE,Tooltip:jE,Touch:KE,Trashcan:JE,UnattachedFieldError:qE,VARIABLE_CATEGORY_NAME:ZE,VARIABLE_DYNAMIC_CATEGORY_NAME:QE,VERSION:ey,VariableMap:ty,VariableModel:oy,Variables:sy,VariablesDynamic:iy,VerticalFlyout:ry,WidgetDiv:ny,Workspace:ly,WorkspaceAudio:cy,WorkspaceDragger:uy,WorkspaceNavigationPolicy:ay,WorkspaceSvg:hy,Xml:dy,ZoomControls:$y,blockAnimations:py,blockRendering:gy,browserEvents:my,bubbles:fy,bumpObjects:_y,clipboard:by,comments:Ty,common:Ey,config:yy,constants:vy,defineBlocksWithJsonArray:Iy,dialog:Cy,dragging:Sy,fieldRegistry:ky,geras:Ry,getFocusManager:wy,getMainWorkspace:Jh,getSelected:Oy,hasBubble:Ny,hideChaff:Ay,icons:Ly,inject:My,inputs:Dy,isCopyable:xy,isDeletable:By,isDraggable:Py,isIcon:Fy,isObservable:Uy,isPaster:Hy,isRenderedElement:Gy,isSelectable:Vy,isSerializable:Wy,isVariableBackedParameterModel:zy,keyboardNavigationController:Yy,layers:Xy,navigateBlock:jy,navigateStacks:Ky,procedures:Jy,registry:qy,renderManagement:Zy,serialization:Qy,setLocale:qh,setParentContainer:ev,svgResize:tv,thrasos:ov,uiPosition:sv,utils:iv,zelos:rv}=aT,ld=Object.freeze(Object.defineProperty({__proto__:null,Block:hT,BlockFlyoutInflater:dT,BlockNavigationPolicy:$T,BlockSvg:pT,Blocks:gT,ButtonFlyoutInflater:mT,COLLAPSED_FIELD_NAME:fT,COLLAPSED_INPUT_NAME:_T,COLLAPSE_CHARS:bT,CodeGenerator:TT,CollapsibleToolboxCategory:ET,ComponentManager:yT,Connection:vT,ConnectionChecker:IT,ConnectionDB:CT,ConnectionNavigationPolicy:ST,ConnectionType:kT,ContextMenu:RT,ContextMenuItems:wT,ContextMenuRegistry:OT,Css:NT,DELETE_VARIABLE_ID:AT,DeleteArea:LT,DragTarget:MT,DropDownDiv:DT,Events:Dl,Extensions:xT,Field:BT,FieldCheckbox:PT,FieldDropdown:FT,FieldImage:UT,FieldLabel:HT,FieldLabelSerializable:GT,FieldNavigationPolicy:VT,FieldNumber:WT,FieldTextInput:zT,FieldVariable:YT,Flyout:XT,FlyoutButton:jT,FlyoutButtonNavigationPolicy:KT,FlyoutItem:JT,FlyoutMetricsManager:qT,FlyoutNavigationPolicy:ZT,FlyoutNavigator:QT,FlyoutSeparator:eE,FlyoutSeparatorNavigationPolicy:tE,FocusManager:oE,FocusableTreeTraverser:sE,Generator:iE,Gesture:rE,Grid:nE,HorizontalFlyout:lE,INPUT_VALUE:cE,Input:uE,InsertionMarkerPreviewer:aE,KeyboardNavigationController:hE,LabelFlyoutInflater:dE,LineCursor:$E,Marker:pE,MarkerManager:gE,Menu:mE,MenuItem:fE,MetricsManager:_E,Msg:bE,NEXT_STATEMENT:TE,Names:EE,Navigator:yE,OPPOSITE_TYPE:vE,OUTPUT_VALUE:IE,Options:CE,PREVIOUS_STATEMENT:SE,PROCEDURE_CATEGORY_NAME:kE,Procedures:RE,RENAME_VARIABLE_ID:wE,RenderedConnection:OE,Scrollbar:NE,ScrollbarPair:AE,SeparatorFlyoutInflater:LE,ShortcutItems:ME,ShortcutRegistry:DE,TOOLBOX_AT_BOTTOM:xE,TOOLBOX_AT_LEFT:BE,TOOLBOX_AT_RIGHT:PE,TOOLBOX_AT_TOP:FE,Theme:UE,ThemeManager:HE,Themes:GE,Toast:VE,Toolbox:WE,ToolboxCategory:zE,ToolboxItem:YE,ToolboxSeparator:XE,Tooltip:jE,Touch:KE,Trashcan:JE,UnattachedFieldError:qE,VARIABLE_CATEGORY_NAME:ZE,VARIABLE_DYNAMIC_CATEGORY_NAME:QE,VERSION:ey,VariableMap:ty,VariableModel:oy,Variables:sy,VariablesDynamic:iy,VerticalFlyout:ry,WidgetDiv:ny,Workspace:ly,WorkspaceAudio:cy,WorkspaceDragger:uy,WorkspaceNavigationPolicy:ay,WorkspaceSvg:hy,Xml:dy,ZoomControls:$y,blockAnimations:py,blockRendering:gy,browserEvents:my,bubbles:fy,bumpObjects:_y,clipboard:by,comments:Ty,common:Ey,config:yy,constants:vy,defineBlocksWithJsonArray:Iy,dialog:Cy,dragging:Sy,fieldRegistry:ky,geras:Ry,getFocusManager:wy,getMainWorkspace:Jh,getSelected:Oy,hasBubble:Ny,hideChaff:Ay,icons:Ly,inject:My,inputs:Dy,isCopyable:xy,isDeletable:By,isDraggable:Py,isIcon:Fy,isObservable:Uy,isPaster:Hy,isRenderedElement:Gy,isSelectable:Vy,isSerializable:Wy,isVariableBackedParameterModel:zy,keyboardNavigationController:Yy,layers:Xy,navigateBlock:jy,navigateStacks:Ky,procedures:Jy,registry:qy,renderManagement:Zy,serialization:Qy,setLocale:qh,setParentContainer:ev,svgResize:tv,thrasos:ov,uiPosition:sv,utils:iv,zelos:rv},Symbol.toStringTag,{value:"Module"}));var xl={exports:{}},nv=xl.exports,Qf;function lv(){return Qf||(Qf=1,(function(h,a){(function(r,l){h.exports=l(nd())})(nv,function(r){var l=r.__namespace__,g=l.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"variables_get_dynamic",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],output:null,style:"variable_dynamic_blocks",helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableDynamicSetterGetter"]},{type:"variables_set_dynamic",message0:"%{BKY_VARIABLES_SET}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"},{type:"input_value",name:"VALUE"}],previousStatement:null,nextStatement:null,style:"variable_dynamic_blocks",tooltip:"%{BKY_VARIABLES_SET_TOOLTIP}",helpUrl:"%{BKY_VARIABLES_SET_HELPURL}",extensions:["contextMenu_variableDynamicSetterGetter"]}]),m={customContextMenu:function(c){if(this.isInFlyout)(this.type==="variables_get_dynamic"||this.type==="variables_get_reporter_dynamic")&&(I={text:l.Msg$$module$build$src$core$msg.RENAME_VARIABLE,enabled:!0,callback:y(this)},C=this.getField("VAR").getText(),C={text:l.Msg$$module$build$src$core$msg.DELETE_VARIABLE.replace("%1",C),enabled:!0,callback:k(this)},c.unshift(I),c.unshift(C));else{if(this.type==="variables_get_dynamic")var p="variables_set_dynamic",I=l.Msg$$module$build$src$core$msg.VARIABLES_GET_CREATE_SET;else p="variables_get_dynamic",I=l.Msg$$module$build$src$core$msg.VARIABLES_SET_CREATE_GET;var C=this.getField("VAR");p={type:p,fields:{VAR:C.saveState(!0)}},c.push({enabled:this.workspace.remainingCapacity()>0,text:I.replace("%1",C.getText()),callback:l.callbackFactory$$module$build$src$core$contextmenu(this,p)})}},onchange:function(c){c=this.getFieldValue("VAR"),c=l.getVariable$$module$build$src$core$variables(this.workspace,c),this.type==="variables_get_dynamic"?this.outputConnection.setCheck(c.getType()):this.getInput("VALUE").connection.setCheck(c.getType())}},y=function(c){return function(){const p=c.workspace,I=c.getField("VAR").getVariable();l.renameVariable$$module$build$src$core$variables(p,I)}},k=function(c){return function(){const p=c.getField("VAR").getVariable();p&&l.deleteVariable$$module$build$src$core$variables(p.getWorkspace(),p,c)}};l.registerMixin$$module$build$src$core$extensions("contextMenu_variableDynamicSetterGetter",m),l.defineBlocks$$module$build$src$core$common(g);var A={blocks:g},D=l.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"variables_get",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],output:null,style:"variable_blocks",helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableSetterGetter"]},{type:"variables_set",message0:"%{BKY_VARIABLES_SET}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"},{type:"input_value",name:"VALUE"}],previousStatement:null,nextStatement:null,style:"variable_blocks",tooltip:"%{BKY_VARIABLES_SET_TOOLTIP}",helpUrl:"%{BKY_VARIABLES_SET_HELPURL}",extensions:["contextMenu_variableSetterGetter"]}]),H={customContextMenu:function(c){if(this.isInFlyout)(this.type==="variables_get"||this.type==="variables_get_reporter")&&(I={text:l.Msg$$module$build$src$core$msg.RENAME_VARIABLE,enabled:!0,callback:W(this)},C=this.getField("VAR").getText(),C={text:l.Msg$$module$build$src$core$msg.DELETE_VARIABLE.replace("%1",C),enabled:!0,callback:X(this)},c.unshift(I),c.unshift(C));else{if(this.type==="variables_get")var p="variables_set",I=l.Msg$$module$build$src$core$msg.VARIABLES_GET_CREATE_SET;else p="variables_get",I=l.Msg$$module$build$src$core$msg.VARIABLES_SET_CREATE_GET;var C=this.getField("VAR");p={type:p,fields:{VAR:C.saveState(!0)}},c.push({enabled:this.workspace.remainingCapacity()>0,text:I.replace("%1",C.getText()),callback:l.callbackFactory$$module$build$src$core$contextmenu(this,p)})}}},W=function(c){return function(){const p=c.workspace,I=c.getField("VAR").getVariable();l.renameVariable$$module$build$src$core$variables(p,I)}},X=function(c){return function(){const p=c.getField("VAR").getVariable();p&&l.deleteVariable$$module$build$src$core$variables(p.getWorkspace(),p,c)}};l.registerMixin$$module$build$src$core$extensions("contextMenu_variableSetterGetter",H),l.defineBlocks$$module$build$src$core$common(D);var ue={blocks:D},ie=l.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"text",message0:"%1",args0:[{type:"field_input",name:"TEXT",text:""}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_TEXT_HELPURL}",tooltip:"%{BKY_TEXT_TEXT_TOOLTIP}",extensions:["text_quotes","parent_tooltip_when_inline"]},{type:"text_join",message0:"",output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_JOIN_HELPURL}",tooltip:"%{BKY_TEXT_JOIN_TOOLTIP}",mutator:"text_join_mutator"},{type:"text_create_join_container",message0:"%{BKY_TEXT_CREATE_JOIN_TITLE_JOIN} %1 %2",args0:[{type:"input_dummy"},{type:"input_statement",name:"STACK"}],style:"text_blocks",tooltip:"%{BKY_TEXT_CREATE_JOIN_TOOLTIP}",enableContextMenu:!1},{type:"text_create_join_item",message0:"%{BKY_TEXT_CREATE_JOIN_ITEM_TITLE_ITEM}",previousStatement:null,nextStatement:null,style:"text_blocks",tooltip:"%{BKY_TEXT_CREATE_JOIN_ITEM_TOOLTIP}",enableContextMenu:!1},{type:"text_append",message0:"%{BKY_TEXT_APPEND_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_TEXT_APPEND_VARIABLE}"},{type:"input_value",name:"TEXT"}],previousStatement:null,nextStatement:null,style:"text_blocks",extensions:["text_append_tooltip"]},{type:"text_length",message0:"%{BKY_TEXT_LENGTH_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",style:"text_blocks",tooltip:"%{BKY_TEXT_LENGTH_TOOLTIP}",helpUrl:"%{BKY_TEXT_LENGTH_HELPURL}"},{type:"text_isEmpty",message0:"%{BKY_TEXT_ISEMPTY_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",style:"text_blocks",tooltip:"%{BKY_TEXT_ISEMPTY_TOOLTIP}",helpUrl:"%{BKY_TEXT_ISEMPTY_HELPURL}"},{type:"text_indexOf",message0:"%{BKY_TEXT_INDEXOF_TITLE}",args0:[{type:"input_value",name:"VALUE",check:"String"},{type:"field_dropdown",name:"END",options:[["%{BKY_TEXT_INDEXOF_OPERATOR_FIRST}","FIRST"],["%{BKY_TEXT_INDEXOF_OPERATOR_LAST}","LAST"]]},{type:"input_value",name:"FIND",check:"String"}],output:"Number",style:"text_blocks",helpUrl:"%{BKY_TEXT_INDEXOF_HELPURL}",inputsInline:!0,extensions:["text_indexOf_tooltip"]},{type:"text_charAt",message0:"%{BKY_TEXT_CHARAT_TITLE}",args0:[{type:"input_value",name:"VALUE",check:"String"},{type:"field_dropdown",name:"WHERE",options:[["%{BKY_TEXT_CHARAT_FROM_START}","FROM_START"],["%{BKY_TEXT_CHARAT_FROM_END}","FROM_END"],["%{BKY_TEXT_CHARAT_FIRST}","FIRST"],["%{BKY_TEXT_CHARAT_LAST}","LAST"],["%{BKY_TEXT_CHARAT_RANDOM}","RANDOM"]]}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_CHARAT_HELPURL}",inputsInline:!0,mutator:"text_charAt_mutator"}]),K={init:function(){this.WHERE_OPTIONS_1=[[l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_START_FROM_START,"FROM_START"],[l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_START_FROM_END,"FROM_END"],[l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_START_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_END_FROM_START,"FROM_START"],[l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_END_FROM_END,"FROM_END"],[l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_END_LAST,"LAST"]],this.setHelpUrl(l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_HELPURL),this.setStyle("text_blocks"),this.appendValueInput("STRING").setCheck("String").appendField(l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT);const c=p=>{const I=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:this["WHERE_OPTIONS_"+p]});return I.setValidator(function(C){const V=this.getValue();C=C==="FROM_START"||C==="FROM_END",C!==(V==="FROM_START"||V==="FROM_END")&&this.getSourceBlock().updateAt_(p,C)}),I};this.appendDummyInput("WHERE1_INPUT").appendField(c(1),"WHERE1"),this.appendDummyInput("AT1"),this.appendDummyInput("WHERE2_INPUT").appendField(c(2),"WHERE2"),this.appendDummyInput("AT2"),l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_TAIL&&this.appendDummyInput("TAIL").appendField(l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_TAIL),this.setInputsInline(!0),this.setOutput(!0,"String"),this.updateAt_(1,!0),this.updateAt_(2,!0),this.setTooltip(l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_TOOLTIP)},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");var p=this.getInput("AT1")instanceof l.ValueInput$$module$build$src$core$inputs$value_input;return c.setAttribute("at1",`${p}`),p=this.getInput("AT2")instanceof l.ValueInput$$module$build$src$core$inputs$value_input,c.setAttribute("at2",`${p}`),c},domToMutation:function(c){const p=c.getAttribute("at1")==="true";c=c.getAttribute("at2")==="true",this.updateAt_(1,p),this.updateAt_(2,c)},updateAt_:function(c,p){this.removeInput("AT"+c),this.removeInput("ORDINAL"+c,!0),p?(this.appendValueInput("AT"+c).setCheck("Number"),l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+c).appendField(l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+c),c===2&&l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField(l.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_TAIL)),c===1&&(this.moveInputBefore("AT1","WHERE2_INPUT"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","WHERE2_INPUT"))}};ie.text_getSubstring=K,ie.text_changeCase={init:function(){const c=[[l.Msg$$module$build$src$core$msg.TEXT_CHANGECASE_OPERATOR_UPPERCASE,"UPPERCASE"],[l.Msg$$module$build$src$core$msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE,"LOWERCASE"],[l.Msg$$module$build$src$core$msg.TEXT_CHANGECASE_OPERATOR_TITLECASE,"TITLECASE"]];this.setHelpUrl(l.Msg$$module$build$src$core$msg.TEXT_CHANGECASE_HELPURL),this.setStyle("text_blocks"),this.appendValueInput("TEXT").setCheck("String").appendField(l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:c}),"CASE"),this.setOutput(!0,"String"),this.setTooltip(l.Msg$$module$build$src$core$msg.TEXT_CHANGECASE_TOOLTIP)}},ie.text_trim={init:function(){const c=[[l.Msg$$module$build$src$core$msg.TEXT_TRIM_OPERATOR_BOTH,"BOTH"],[l.Msg$$module$build$src$core$msg.TEXT_TRIM_OPERATOR_LEFT,"LEFT"],[l.Msg$$module$build$src$core$msg.TEXT_TRIM_OPERATOR_RIGHT,"RIGHT"]];this.setHelpUrl(l.Msg$$module$build$src$core$msg.TEXT_TRIM_HELPURL),this.setStyle("text_blocks"),this.appendValueInput("TEXT").setCheck("String").appendField(l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:c}),"MODE"),this.setOutput(!0,"String"),this.setTooltip(l.Msg$$module$build$src$core$msg.TEXT_TRIM_TOOLTIP)}},ie.text_print={init:function(){this.jsonInit({message0:l.Msg$$module$build$src$core$msg.TEXT_PRINT_TITLE,args0:[{type:"input_value",name:"TEXT"}],previousStatement:null,nextStatement:null,style:"text_blocks",tooltip:l.Msg$$module$build$src$core$msg.TEXT_PRINT_TOOLTIP,helpUrl:l.Msg$$module$build$src$core$msg.TEXT_PRINT_HELPURL})}};var ee={updateType_:function(c){this.outputConnection.setCheck(c==="NUMBER"?"Number":"String")},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");return c.setAttribute("type",this.getFieldValue("TYPE")),c},domToMutation:function(c){this.updateType_(c.getAttribute("type"))}};ie.text_prompt_ext=Object.assign({},ee,{init:function(){var c=[[l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];this.setHelpUrl(l.Msg$$module$build$src$core$msg.TEXT_PROMPT_HELPURL),this.setStyle("text_blocks"),c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:c}),c.setValidator(p=>{this.updateType_(p)}),this.appendValueInput("TEXT").appendField(c,"TYPE"),this.setOutput(!0,"String"),this.setTooltip(()=>this.getFieldValue("TYPE")==="TEXT"?l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_TEXT:l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_NUMBER)}}),ie.text_prompt=Object.assign({},ee,{init:function(){this.mixin(me);var c=[[l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];this.setHelpUrl(l.Msg$$module$build$src$core$msg.TEXT_PROMPT_HELPURL),this.setStyle("text_blocks"),c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:c}),c.setValidator(p=>{this.updateType_(p)}),this.appendDummyInput().appendField(c,"TYPE").appendField(this.newQuote_(!0)).appendField(l.fromJson$$module$build$src$core$field_registry({type:"field_input",text:""}),"TEXT").appendField(this.newQuote_(!1)),this.setOutput(!0,"String"),this.setTooltip(()=>this.getFieldValue("TYPE")==="TEXT"?l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_TEXT:l.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_NUMBER)}}),ie.text_count={init:function(){this.jsonInit({message0:l.Msg$$module$build$src$core$msg.TEXT_COUNT_MESSAGE0,args0:[{type:"input_value",name:"SUB",check:"String"},{type:"input_value",name:"TEXT",check:"String"}],output:"Number",inputsInline:!0,style:"text_blocks",tooltip:l.Msg$$module$build$src$core$msg.TEXT_COUNT_TOOLTIP,helpUrl:l.Msg$$module$build$src$core$msg.TEXT_COUNT_HELPURL})}},ie.text_replace={init:function(){this.jsonInit({message0:l.Msg$$module$build$src$core$msg.TEXT_REPLACE_MESSAGE0,args0:[{type:"input_value",name:"FROM",check:"String"},{type:"input_value",name:"TO",check:"String"},{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:l.Msg$$module$build$src$core$msg.TEXT_REPLACE_TOOLTIP,helpUrl:l.Msg$$module$build$src$core$msg.TEXT_REPLACE_HELPURL})}},ie.text_reverse={init:function(){this.jsonInit({message0:l.Msg$$module$build$src$core$msg.TEXT_REVERSE_MESSAGE0,args0:[{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:l.Msg$$module$build$src$core$msg.TEXT_REVERSE_TOOLTIP,helpUrl:l.Msg$$module$build$src$core$msg.TEXT_REVERSE_HELPURL})}};var me={QUOTE_IMAGE_LEFT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC",QUOTE_IMAGE_RIGHT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==",QUOTE_IMAGE_WIDTH:12,QUOTE_IMAGE_HEIGHT:12,quoteField_:function(c){for(let p=0,I;I=this.inputList[p];p++)for(let C=0,V;V=I.fieldRow[C];C++)if(c===V.name){I.insertFieldAt(C,this.newQuote_(!0)),I.insertFieldAt(C+2,this.newQuote_(!1));return}console.warn('field named "'+c+'" not found in '+this.toDevString())},newQuote_:function(c){return c=this.RTL?!c:c,l.fromJson$$module$build$src$core$field_registry({type:"field_image",src:c?this.QUOTE_IMAGE_LEFT_DATAURI:this.QUOTE_IMAGE_RIGHT_DATAURI,width:this.QUOTE_IMAGE_WIDTH,height:this.QUOTE_IMAGE_HEIGHT,alt:c?"“":"”"})}},z=function(){this.mixin(me),this.quoteField_("TEXT")},ae={itemCount_:0,mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");return c.setAttribute("items",`${this.itemCount_}`),c},domToMutation:function(c){this.itemCount_=parseInt(c.getAttribute("items"),10),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(c){this.itemCount_=c.itemCount,this.updateShape_()},decompose:function(c){const p=c.newBlock("text_create_join_container");p.initSvg();let I=p.getInput("STACK").connection;for(let C=0;C<this.itemCount_;C++){const V=c.newBlock("text_create_join_item");V.initSvg(),I.connect(V.previousConnection),I=V.nextConnection}return p},compose:function(c){var p=c.getInputTargetBlock("STACK");for(c=[];p;)p.isInsertionMarker()||c.push(p.valueConnection_),p=p.getNextBlock();for(p=0;p<this.itemCount_;p++){const I=this.getInput("ADD"+p).connection.targetConnection;I&&!c.includes(I)&&I.disconnect()}for(this.itemCount_=c.length,this.updateShape_(),p=0;p<this.itemCount_;p++){let I;(I=c[p])==null||I.reconnect(this,"ADD"+p)}},saveConnections:function(c){c=c.getInputTargetBlock("STACK");let p=0;for(;c;){if(c.isInsertionMarker()){c=c.getNextBlock();continue}const I=this.getInput("ADD"+p);c.valueConnection_=I&&I.connection.targetConnection,c=c.getNextBlock(),p++}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(this.newQuote_(!0)).appendField(this.newQuote_(!1));for(var c=0;c<this.itemCount_;c++)if(!this.getInput("ADD"+c)){const p=this.appendValueInput("ADD"+c).setAlign(l.Align$$module$build$src$core$inputs$align.RIGHT);c===0&&p.appendField(l.Msg$$module$build$src$core$msg.TEXT_JOIN_TITLE_CREATEWITH)}for(c=this.itemCount_;this.getInput("ADD"+c);c++)this.removeInput("ADD"+c)}},te=function(){this.mixin(me),this.itemCount_=2,this.updateShape_(),this.setMutator(new l.MutatorIcon$$module$build$src$core$icons$mutator_icon(["text_create_join_item"],this))};l.register$$module$build$src$core$extensions("text_append_tooltip",l.buildTooltipWithFieldText$$module$build$src$core$extensions("%{BKY_TEXT_APPEND_TOOLTIP}","VAR"));var Y=function(){this.setTooltip(()=>l.Msg$$module$build$src$core$msg.TEXT_INDEXOF_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"0":"-1"))},Ie={isAt_:!1,mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");return c.setAttribute("at",`${this.isAt_}`),c},domToMutation:function(c){c=c.getAttribute("at")!=="false",this.updateAt_(c)},updateAt_:function(c){this.removeInput("AT",!0),this.removeInput("ORDINAL",!0),c&&(this.appendValueInput("AT").setCheck("Number"),l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)),l.Msg$$module$build$src$core$msg.TEXT_CHARAT_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField(l.Msg$$module$build$src$core$msg.TEXT_CHARAT_TAIL)),this.isAt_=c}},Ye=function(){this.getField("WHERE").setValidator(function(c){c=c==="FROM_START"||c==="FROM_END";const p=this.getSourceBlock();c!==p.isAt_&&p.updateAt_(c)}),this.updateAt_(!0),this.setTooltip(()=>{var c=this.getFieldValue("WHERE");let p=l.Msg$$module$build$src$core$msg.TEXT_CHARAT_TOOLTIP;return(c==="FROM_START"||c==="FROM_END")&&(c=c==="FROM_START"?l.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_START_TOOLTIP:l.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_END_TOOLTIP)&&(p+=" "+c.replace("%1",this.workspace.options.oneBasedIndex?"#1":"#0")),p})};l.register$$module$build$src$core$extensions("text_indexOf_tooltip",Y),l.register$$module$build$src$core$extensions("text_quotes",z),l.registerMixin$$module$build$src$core$extensions("quote_image_mixin",me),l.registerMutator$$module$build$src$core$extensions("text_join_mutator",ae,te),l.registerMutator$$module$build$src$core$extensions("text_charAt_mutator",Ie,Ye),l.defineBlocks$$module$build$src$core$common(ie);var It={blocks:ie},Re={},rt={setStatements_:function(c){this.hasStatements_!==c&&(c?(this.appendStatementInput("STACK").appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=c)},updateParams_:function(){let c="";this.arguments_.length&&(c=l.Msg$$module$build$src$core$msg.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", ")),l.disable$$module$build$src$core$events$utils();try{this.setFieldValue(c,"PARAMS")}finally{l.enable$$module$build$src$core$events$utils()}},mutationToDom:function(c){const p=l.createElement$$module$build$src$core$utils$xml("mutation");c&&p.setAttribute("name",this.getFieldValue("NAME"));for(let I=0;I<this.argumentVarModels_.length;I++){const C=l.createElement$$module$build$src$core$utils$xml("arg"),V=this.argumentVarModels_[I];C.setAttribute("name",V.getName()),C.setAttribute("varid",V.getId()),c&&this.paramIds_&&C.setAttribute("paramId",this.paramIds_[I]),p.appendChild(C)}return this.hasStatements_||p.setAttribute("statements","false"),p},domToMutation:function(c){this.arguments_=[],this.argumentVarModels_=[];for(let I=0,C;C=c.childNodes[I];I++)if(C.nodeName.toLowerCase()==="arg"){var p=C;const V=p.getAttribute("name");p=p.getAttribute("varid")||p.getAttribute("varId"),this.arguments_.push(V),p=l.getOrCreateVariablePackage$$module$build$src$core$variables(this.workspace,p,V,""),p!==null?this.argumentVarModels_.push(p):console.log(`Failed to create a variable named "${V}", ignoring.`)}this.updateParams_(),l.mutateCallers$$module$build$src$core$procedures(this),this.setStatements_(c.getAttribute("statements")!=="false")},saveExtraState:function(){if(!this.argumentVarModels_.length&&this.hasStatements_)return null;const c=Object.create(null);if(this.argumentVarModels_.length){c.params=[];for(let p=0;p<this.argumentVarModels_.length;p++)c.params.push({name:this.argumentVarModels_[p].getName(),id:this.argumentVarModels_[p].getId()})}return this.hasStatements_||(c.hasStatements=!1),c},loadExtraState:function(c){if(this.arguments_=[],this.argumentVarModels_=[],c.params)for(let I=0;I<c.params.length;I++){var p=c.params[I];p=l.getOrCreateVariablePackage$$module$build$src$core$variables(this.workspace,p.id,p.name,""),this.arguments_.push(p.getName()),this.argumentVarModels_.push(p)}this.updateParams_(),l.mutateCallers$$module$build$src$core$procedures(this),this.setStatements_(c.hasStatements!==!1)},decompose:function(c){const p=l.createElement$$module$build$src$core$utils$xml("block");p.setAttribute("type","procedures_mutatorcontainer");var I=l.createElement$$module$build$src$core$utils$xml("statement");I.setAttribute("name","STACK"),p.appendChild(I);for(let V=0;V<this.arguments_.length;V++){const Ae=l.createElement$$module$build$src$core$utils$xml("block");Ae.setAttribute("type","procedures_mutatorarg");var C=l.createElement$$module$build$src$core$utils$xml("field");C.setAttribute("name","NAME");const so=l.createTextNode$$module$build$src$core$utils$xml(this.arguments_[V]);C.appendChild(so),Ae.appendChild(C),C=l.createElement$$module$build$src$core$utils$xml("next"),Ae.appendChild(C),I.appendChild(Ae),I=C}return c=l.domToBlock$$module$build$src$core$xml(p,c),this.type==="procedures_defreturn"?c.setFieldValue(this.hasStatements_,"STATEMENTS"):c.removeInput("STATEMENT_INPUT"),l.mutateCallers$$module$build$src$core$procedures(this),c},compose:function(c){this.arguments_=[],this.paramIds_=[],this.argumentVarModels_=[];let p=c.getInputTargetBlock("STACK");for(;p&&!p.isInsertionMarker();){var I=p.getFieldValue("NAME");this.arguments_.push(I),I=this.workspace.getVariable(I,""),this.argumentVarModels_.push(I),this.paramIds_.push(p.id),p=p.nextConnection&&p.nextConnection.targetBlock()}if(this.updateParams_(),l.mutateCallers$$module$build$src$core$procedures(this),c=c.getFieldValue("STATEMENTS"),c!==null&&(c=c==="TRUE",this.hasStatements_!==c))if(c){this.setStatements_(!0);var C;(C=this.statementConnection_)==null||C.reconnect(this,"STACK"),this.statementConnection_=null}else C=this.getInput("STACK").connection,(this.statementConnection_=C.targetConnection)&&(C=C.targetBlock(),C.unplug(),C.bumpNeighbours()),this.setStatements_(!1)},getVars:function(){return this.arguments_},getVarModels:function(){return this.argumentVarModels_},renameVarById:function(c,p){var I=this.workspace.getVariableById(c);if(I.getType()===""){I=I.getName(),p=this.workspace.getVariableById(p);var C=!1;for(let V=0;V<this.argumentVarModels_.length;V++)this.argumentVarModels_[V].getId()===c&&(this.arguments_[V]=p.getName(),this.argumentVarModels_[V]=p,C=!0);C&&(this.displayRenamedVar_(I,p.getName()),l.mutateCallers$$module$build$src$core$procedures(this))}},updateVarName:function(c){const p=c.getName();let I=!1,C;for(let V=0;V<this.argumentVarModels_.length;V++)this.argumentVarModels_[V].getId()===c.getId()&&(C=this.arguments_[V],this.arguments_[V]=p,I=!0);I&&(this.displayRenamedVar_(C,p),l.mutateCallers$$module$build$src$core$procedures(this))},displayRenamedVar_:function(c,p){this.updateParams_();var I=this.getIcon(l.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE);if(I&&I.bubbleIsVisible()){I=I.getWorkspace().getAllBlocks(!1);for(let C=0,V;V=I[C];C++)V.type==="procedures_mutatorarg"&&l.Names$$module$build$src$core$names.equals(c,V.getFieldValue("NAME"))&&V.setFieldValue(p,"NAME")}},customContextMenu:function(c){if(!this.isInFlyout){var p=this.getFieldValue("NAME"),I={type:this.callType_,extraState:{name:p,params:this.arguments_}};if(c.push({enabled:!0,text:l.Msg$$module$build$src$core$msg.PROCEDURES_CREATE_DO.replace("%1",p),callback:l.callbackFactory$$module$build$src$core$contextmenu(this,I)}),!this.isCollapsed())for(p=0;p<this.argumentVarModels_.length;p++){I=this.argumentVarModels_[p];const C={type:"variables_get",fields:{VAR:{name:I.getName(),id:I.getId(),type:I.getType()}}};c.push({enabled:!0,text:l.Msg$$module$build$src$core$msg.VARIABLES_SET_CREATE_GET.replace("%1",I.getName()),callback:l.callbackFactory$$module$build$src$core$contextmenu(this,C)})}}}};Re.procedures_defnoreturn=Object.assign({},rt,{init:function(){var c=l.findLegalName$$module$build$src$core$procedures("",this);c=l.fromJson$$module$build$src$core$field_registry({type:"field_input",text:c}),c.setValidator(l.rename$$module$build$src$core$procedures),c.setSpellcheck(!1),this.appendDummyInput().appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_TITLE).appendField(c,"NAME").appendField("","PARAMS"),this.setMutator(new l.MutatorIcon$$module$build$src$core$icons$mutator_icon(["procedures_mutatorarg"],this)),(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&l.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_COMMENT&&this.setCommentText(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_COMMENT),this.setStyle("procedure_blocks"),this.setTooltip(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_TOOLTIP),this.setHelpUrl(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.setStatements_(!0),this.statementConnection_=null},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!1]},callType_:"procedures_callnoreturn"}),Re.procedures_defreturn=Object.assign({},rt,{init:function(){var c=l.findLegalName$$module$build$src$core$procedures("",this);c=l.fromJson$$module$build$src$core$field_registry({type:"field_input",text:c}),c.setValidator(l.rename$$module$build$src$core$procedures),c.setSpellcheck(!1),this.appendDummyInput().appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_TITLE).appendField(c,"NAME").appendField("","PARAMS"),this.appendValueInput("RETURN").setAlign(l.Align$$module$build$src$core$inputs$align.RIGHT).appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_RETURN),this.setMutator(new l.MutatorIcon$$module$build$src$core$icons$mutator_icon(["procedures_mutatorarg"],this)),(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_COMMENT&&this.setCommentText(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_COMMENT),this.setStyle("procedure_blocks"),this.setTooltip(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_TOOLTIP),this.setHelpUrl(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.setStatements_(!0),this.statementConnection_=null},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!0]},callType_:"procedures_callreturn"});var bt={init:function(){this.appendDummyInput().appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_MUTATORCONTAINER_TITLE),this.appendStatementInput("STACK"),this.appendDummyInput("STATEMENT_INPUT").appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_ALLOW_STATEMENTS).appendField(l.fromJson$$module$build$src$core$field_registry({type:"field_checkbox",checked:!0}),"STATEMENTS"),this.setStyle("procedure_blocks"),this.setTooltip(l.Msg$$module$build$src$core$msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP),this.contextMenu=!1}};Re.procedures_mutatorcontainer=bt;var Bt=class extends l.FieldTextInput$$module$build$src$core$field_textinput{constructor(){super(...arguments),this.editingInteractively=!1}showEditor_(c){super.showEditor_(c),this.editingInteractively=!0,this.editingVariable=void 0}onFinishEditing_(c){super.onFinishEditing_(c),this.editingInteractively=!1}},Ct={init:function(){const c=new Bt(l.DEFAULT_ARG$$module$build$src$core$procedures,this.validator_);this.appendDummyInput().appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_MUTATORARG_TITLE).appendField(c,"NAME"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle("procedure_blocks"),this.setTooltip(l.Msg$$module$build$src$core$msg.PROCEDURES_MUTATORARG_TOOLTIP),this.contextMenu=!1},validator_:function(c){var p=this.getSourceBlock();const I=p.workspace.getRootWorkspace();if(c=c.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,""),!c)return null;const C=(p.workspace.targetWorkspace||p.workspace).getAllBlocks(!1),V=c.toLowerCase();for(let Ae=0;Ae<C.length;Ae++){if(C[Ae].id===this.getSourceBlock().id)continue;const so=C[Ae].getFieldValue("NAME");if(so&&so.toLowerCase()===V)return null}return p.isInFlyout||((p=I.getVariable(c,""))&&p.getName()!==c&&I.renameVariableById(p.getId(),c),p||(this.editingInteractively?this.editingVariable?I.renameVariableById(this.editingVariable.getId(),c):this.editingVariable=I.createVariable(c,""):I.createVariable(c,""))),c}};Re.procedures_mutatorarg=Ct;var nt="DISABLED_PROCEDURE_DEFINITION",Tt={getProcedureCall:function(){return this.getFieldValue("NAME")},renameProcedure:function(c,p){l.Names$$module$build$src$core$names.equals(c,this.getProcedureCall())&&(this.setFieldValue(p,"NAME"),this.setTooltip((this.outputConnection?l.Msg$$module$build$src$core$msg.PROCEDURES_CALLRETURN_TOOLTIP:l.Msg$$module$build$src$core$msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",p)))},setProcedureParameters_:function(c,p){var I=l.getDefinition$$module$build$src$core$procedures(this.getProcedureCall(),this.workspace);if((I=(I=I&&I.getIcon(l.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE))&&I.bubbleIsVisible())?this.setCollapsed(!1):(this.quarkConnections_={},this.quarkIds_=null),c.join(`
792
792
  `)===this.arguments_.join(`
793
- `))this.quarkIds_=p;else{if(p.length!==c.length)throw RangeError("paramNames and paramIds must be the same length.");this.quarkIds_||(this.quarkConnections_={},this.quarkIds_=[]);for(let V=0;V<this.arguments_.length;V++){var C=this.getInput("ARG"+V);C&&(C=C.connection.targetConnection,this.quarkConnections_[this.quarkIds_[V]]=C,I&&C&&!p.includes(this.quarkIds_[V])&&(C.disconnect(),C.getSourceBlock().bumpNeighbours()))}for(this.arguments_=[].concat(c),this.argumentVarModels_=[],c=0;c<this.arguments_.length;c++)I=l.getOrCreateVariablePackage$$module$build$src$core$variables(this.workspace,null,this.arguments_[c],""),this.argumentVarModels_.push(I);if(this.updateShape_(),this.quarkIds_=p){for(p=0;p<this.arguments_.length;p++)if(c=this.quarkIds_[p],c in this.quarkConnections_){let V;(V=this.quarkConnections_[c])!=null&&V.reconnect(this,"ARG"+p)||delete this.quarkConnections_[c]}}}},updateShape_:function(){for(var c=0;c<this.arguments_.length;c++){var p=this.getField("ARGNAME"+c);if(p){l.disable$$module$build$src$core$events$utils();try{p.setValue(this.arguments_[c])}finally{l.enable$$module$build$src$core$events$utils()}}else p=l.fromJson$$module$build$src$core$field_registry({type:"field_label",text:this.arguments_[c]}),this.appendValueInput("ARG"+c).setAlign(l.Align$$module$build$src$core$inputs$align.RIGHT).appendField(p,"ARGNAME"+c)}for(c=this.arguments_.length;this.getInput("ARG"+c);c++)this.removeInput("ARG"+c);(c=this.getInput("TOPROW"))&&(this.arguments_.length?this.getField("WITH")||c.appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_CALL_BEFORE_PARAMS,"WITH"):this.getField("WITH")&&c.removeField("WITH"))},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");c.setAttribute("name",this.getProcedureCall());for(let p=0;p<this.arguments_.length;p++){const I=l.createElement$$module$build$src$core$utils$xml("arg");I.setAttribute("name",this.arguments_[p]),c.appendChild(I)}return c},domToMutation:function(c){var p=c.getAttribute("name");this.renameProcedure(this.getProcedureCall(),p),p=[];const I=[];for(let C=0,V;V=c.childNodes[C];C++)V.nodeName.toLowerCase()==="arg"&&(p.push(V.getAttribute("name")),I.push(V.getAttribute("paramId")));this.setProcedureParameters_(p,I)},saveExtraState:function(){const c=Object.create(null);return c.name=this.getProcedureCall(),this.arguments_.length&&(c.params=this.arguments_),c},loadExtraState:function(c){if(this.renameProcedure(this.getProcedureCall(),c.name),c=c.params){const p=[];p.length=c.length,p.fill(null),this.setProcedureParameters_(c,p)}},getVars:function(){return this.arguments_},getVarModels:function(){return this.argumentVarModels_},onchange:function(c){if(this.workspace&&!this.workspace.isFlyout&&c.recordUndo)if(c.type===l.BLOCK_CREATE$$module$build$src$core$events$events&&c.ids.includes(this.id)){var p=this.getProcedureCall(),I=l.getDefinition$$module$build$src$core$procedures(p,this.workspace);if(!I||I.type===this.defType_&&JSON.stringify(I.getVars())===JSON.stringify(this.arguments_)||(I=null),I)I.isEnabled()||(this.setDisabledReason(!0,nt),this.setWarningText(l.Msg$$module$build$src$core$msg.PROCEDURES_CALL_DISABLED_DEF_WARNING.replace("%1",p)));else{l.setGroup$$module$build$src$core$events$utils(c.group),c=l.createElement$$module$build$src$core$utils$xml("xml"),p=l.createElement$$module$build$src$core$utils$xml("block"),p.setAttribute("type",this.defType_),I=this.getRelativeToSurfaceXY();var C=I.y+l.config$$module$build$src$core$config.snapRadius*2;p.setAttribute("x",`${I.x+l.config$$module$build$src$core$config.snapRadius*(this.RTL?-1:1)}`),p.setAttribute("y",`${C}`),I=this.mutationToDom(),p.appendChild(I),I=l.createElement$$module$build$src$core$utils$xml("field"),I.setAttribute("name","NAME"),C=this.getProcedureCall();const V=l.findLegalName$$module$build$src$core$procedures(C,this);C!==V&&this.renameProcedure(C,V),I.appendChild(l.createTextNode$$module$build$src$core$utils$xml(C)),p.appendChild(I),c.appendChild(p),l.domToWorkspace$$module$build$src$core$xml(c,this.workspace),l.setGroup$$module$build$src$core$events$utils(!1)}}else c.type===l.BLOCK_DELETE$$module$build$src$core$events$events?(p=this.getProcedureCall(),l.getDefinition$$module$build$src$core$procedures(p,this.workspace)||(l.setGroup$$module$build$src$core$events$utils(c.group),this.dispose(!0),l.setGroup$$module$build$src$core$events$utils(!1))):c.type===l.BLOCK_CHANGE$$module$build$src$core$events$events&&c.element==="disabled"&&(p=this.getProcedureCall(),(C=l.getDefinition$$module$build$src$core$procedures(p,this.workspace))&&C.id===c.blockId&&((I=l.getGroup$$module$build$src$core$events$utils())&&console.log("Saw an existing group while responding to a definition change"),l.setGroup$$module$build$src$core$events$utils(c.group),c=C.isEnabled(),this.setDisabledReason(!c,nt),this.setWarningText(c?null:l.Msg$$module$build$src$core$msg.PROCEDURES_CALL_DISABLED_DEF_WARNING.replace("%1",p)),l.setGroup$$module$build$src$core$events$utils(I)))},customContextMenu:function(c){if(this.workspace.isMovable()){var p=this.getProcedureCall(),I=this.workspace;c.push({enabled:!0,text:l.Msg$$module$build$src$core$msg.PROCEDURES_HIGHLIGHT_DEF,callback:function(){const C=l.getDefinition$$module$build$src$core$procedures(p,I);C&&(I.centerOnBlock(C.id),l.getFocusManager$$module$build$src$core$focus_manager().focusNode(C))}})}}};Re.procedures_callnoreturn=Object.assign({},Tt,{init:function(){this.appendDummyInput("TOPROW").appendField("","NAME"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle("procedure_blocks"),this.setHelpUrl(l.Msg$$module$build$src$core$msg.PROCEDURES_CALLNORETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.quarkConnections_={},this.quarkIds_=null},defType_:"procedures_defnoreturn"}),Re.procedures_callreturn=Object.assign({},Tt,{init:function(){this.appendDummyInput("TOPROW").appendField("","NAME"),this.setOutput(!0),this.setStyle("procedure_blocks"),this.setHelpUrl(l.Msg$$module$build$src$core$msg.PROCEDURES_CALLRETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.quarkConnections_={},this.quarkIds_=null},defType_:"procedures_defreturn"});var lt="UNPARENTED_IFRETURN",$t={init:function(){this.appendValueInput("CONDITION").setCheck("Boolean").appendField(l.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_IF),this.appendValueInput("VALUE").appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_RETURN),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle("procedure_blocks"),this.setTooltip(l.Msg$$module$build$src$core$msg.PROCEDURES_IFRETURN_TOOLTIP),this.setHelpUrl(l.Msg$$module$build$src$core$msg.PROCEDURES_IFRETURN_HELPURL),this.hasReturnValue_=!0},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");return c.setAttribute("value",String(Number(this.hasReturnValue_))),c},domToMutation:function(c){this.hasReturnValue_=c.getAttribute("value")==="1",this.hasReturnValue_||(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_RETURN))},onchange:function(c){if(!(this.workspace.isDragging&&this.workspace.isDragging()||c.type!==l.BLOCK_MOVE$$module$build$src$core$events$events&&c.type!==l.BLOCK_CREATE$$module$build$src$core$events$events)){c=!1;var p=this;do{if(this.FUNCTION_TYPES.includes(p.type)){c=!0;break}p=p.getSurroundParent()}while(p);if(c?(p.type==="procedures_defnoreturn"&&this.hasReturnValue_?(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!1):p.type!=="procedures_defreturn"||this.hasReturnValue_||(this.removeInput("VALUE"),this.appendValueInput("VALUE").appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!0),this.setWarningText(null)):this.setWarningText(l.Msg$$module$build$src$core$msg.PROCEDURES_IFRETURN_WARNING),!this.isInFlyout)try{l.setRecordUndo$$module$build$src$core$events$utils(!1),this.setDisabledReason(!c,lt)}finally{l.setRecordUndo$$module$build$src$core$events$utils(!0)}}},FUNCTION_TYPES:["procedures_defnoreturn","procedures_defreturn"]};Re.procedures_ifreturn=$t,l.defineBlocks$$module$build$src$core$common(Re);var St={blocks:Re},Ue=l.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"math_number",message0:"%1",args0:[{type:"field_number",name:"NUM",value:0}],output:"Number",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",style:"math_blocks",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_arithmetic",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Number"},{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ADDITION_SYMBOL}","ADD"],["%{BKY_MATH_SUBTRACTION_SYMBOL}","MINUS"],["%{BKY_MATH_MULTIPLICATION_SYMBOL}","MULTIPLY"],["%{BKY_MATH_DIVISION_SYMBOL}","DIVIDE"],["%{BKY_MATH_POWER_SYMBOL}","POWER"]]},{type:"input_value",name:"B",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_ARITHMETIC_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_single",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_SINGLE_OP_ROOT}","ROOT"],["%{BKY_MATH_SINGLE_OP_ABSOLUTE}","ABS"],["-","NEG"],["ln","LN"],["log10","LOG10"],["e^","EXP"],["10^","POW10"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_SINGLE_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_trig",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_TRIG_SIN}","SIN"],["%{BKY_MATH_TRIG_COS}","COS"],["%{BKY_MATH_TRIG_TAN}","TAN"],["%{BKY_MATH_TRIG_ASIN}","ASIN"],["%{BKY_MATH_TRIG_ACOS}","ACOS"],["%{BKY_MATH_TRIG_ATAN}","ATAN"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_TRIG_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_constant",message0:"%1",args0:[{type:"field_dropdown",name:"CONSTANT",options:[["π","PI"],["e","E"],["φ","GOLDEN_RATIO"],["sqrt(2)","SQRT2"],["sqrt(½)","SQRT1_2"],["∞","INFINITY"]]}],output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_CONSTANT_TOOLTIP}",helpUrl:"%{BKY_MATH_CONSTANT_HELPURL}"},{type:"math_number_property",message0:"%1 %2",args0:[{type:"input_value",name:"NUMBER_TO_CHECK",check:"Number"},{type:"field_dropdown",name:"PROPERTY",options:[["%{BKY_MATH_IS_EVEN}","EVEN"],["%{BKY_MATH_IS_ODD}","ODD"],["%{BKY_MATH_IS_PRIME}","PRIME"],["%{BKY_MATH_IS_WHOLE}","WHOLE"],["%{BKY_MATH_IS_POSITIVE}","POSITIVE"],["%{BKY_MATH_IS_NEGATIVE}","NEGATIVE"],["%{BKY_MATH_IS_DIVISIBLE_BY}","DIVISIBLE_BY"]]}],inputsInline:!0,output:"Boolean",style:"math_blocks",tooltip:"%{BKY_MATH_IS_TOOLTIP}",mutator:"math_is_divisibleby_mutator"},{type:"math_change",message0:"%{BKY_MATH_CHANGE_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_MATH_CHANGE_TITLE_ITEM}"},{type:"input_value",name:"DELTA",check:"Number"}],previousStatement:null,nextStatement:null,style:"variable_blocks",helpUrl:"%{BKY_MATH_CHANGE_HELPURL}",extensions:["math_change_tooltip"]},{type:"math_round",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ROUND_OPERATOR_ROUND}","ROUND"],["%{BKY_MATH_ROUND_OPERATOR_ROUNDUP}","ROUNDUP"],["%{BKY_MATH_ROUND_OPERATOR_ROUNDDOWN}","ROUNDDOWN"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_ROUND_HELPURL}",tooltip:"%{BKY_MATH_ROUND_TOOLTIP}"},{type:"math_on_list",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ONLIST_OPERATOR_SUM}","SUM"],["%{BKY_MATH_ONLIST_OPERATOR_MIN}","MIN"],["%{BKY_MATH_ONLIST_OPERATOR_MAX}","MAX"],["%{BKY_MATH_ONLIST_OPERATOR_AVERAGE}","AVERAGE"],["%{BKY_MATH_ONLIST_OPERATOR_MEDIAN}","MEDIAN"],["%{BKY_MATH_ONLIST_OPERATOR_MODE}","MODE"],["%{BKY_MATH_ONLIST_OPERATOR_STD_DEV}","STD_DEV"],["%{BKY_MATH_ONLIST_OPERATOR_RANDOM}","RANDOM"]]},{type:"input_value",name:"LIST",check:"Array"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_ONLIST_HELPURL}",mutator:"math_modes_of_list_mutator",extensions:["math_op_tooltip"]},{type:"math_modulo",message0:"%{BKY_MATH_MODULO_TITLE}",args0:[{type:"input_value",name:"DIVIDEND",check:"Number"},{type:"input_value",name:"DIVISOR",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_MODULO_TOOLTIP}",helpUrl:"%{BKY_MATH_MODULO_HELPURL}"},{type:"math_constrain",message0:"%{BKY_MATH_CONSTRAIN_TITLE}",args0:[{type:"input_value",name:"VALUE",check:"Number"},{type:"input_value",name:"LOW",check:"Number"},{type:"input_value",name:"HIGH",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_CONSTRAIN_TOOLTIP}",helpUrl:"%{BKY_MATH_CONSTRAIN_HELPURL}"},{type:"math_random_int",message0:"%{BKY_MATH_RANDOM_INT_TITLE}",args0:[{type:"input_value",name:"FROM",check:"Number"},{type:"input_value",name:"TO",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_RANDOM_INT_TOOLTIP}",helpUrl:"%{BKY_MATH_RANDOM_INT_HELPURL}"},{type:"math_random_float",message0:"%{BKY_MATH_RANDOM_FLOAT_TITLE_RANDOM}",output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_RANDOM_FLOAT_TOOLTIP}",helpUrl:"%{BKY_MATH_RANDOM_FLOAT_HELPURL}"},{type:"math_atan2",message0:"%{BKY_MATH_ATAN2_TITLE}",args0:[{type:"input_value",name:"X",check:"Number"},{type:"input_value",name:"Y",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_ATAN2_TOOLTIP}",helpUrl:"%{BKY_MATH_ATAN2_HELPURL}"}]),_={ADD:"%{BKY_MATH_ARITHMETIC_TOOLTIP_ADD}",MINUS:"%{BKY_MATH_ARITHMETIC_TOOLTIP_MINUS}",MULTIPLY:"%{BKY_MATH_ARITHMETIC_TOOLTIP_MULTIPLY}",DIVIDE:"%{BKY_MATH_ARITHMETIC_TOOLTIP_DIVIDE}",POWER:"%{BKY_MATH_ARITHMETIC_TOOLTIP_POWER}",ROOT:"%{BKY_MATH_SINGLE_TOOLTIP_ROOT}",ABS:"%{BKY_MATH_SINGLE_TOOLTIP_ABS}",NEG:"%{BKY_MATH_SINGLE_TOOLTIP_NEG}",LN:"%{BKY_MATH_SINGLE_TOOLTIP_LN}",LOG10:"%{BKY_MATH_SINGLE_TOOLTIP_LOG10}",EXP:"%{BKY_MATH_SINGLE_TOOLTIP_EXP}",POW10:"%{BKY_MATH_SINGLE_TOOLTIP_POW10}",SIN:"%{BKY_MATH_TRIG_TOOLTIP_SIN}",COS:"%{BKY_MATH_TRIG_TOOLTIP_COS}",TAN:"%{BKY_MATH_TRIG_TOOLTIP_TAN}",ASIN:"%{BKY_MATH_TRIG_TOOLTIP_ASIN}",ACOS:"%{BKY_MATH_TRIG_TOOLTIP_ACOS}",ATAN:"%{BKY_MATH_TRIG_TOOLTIP_ATAN}",SUM:"%{BKY_MATH_ONLIST_TOOLTIP_SUM}",MIN:"%{BKY_MATH_ONLIST_TOOLTIP_MIN}",MAX:"%{BKY_MATH_ONLIST_TOOLTIP_MAX}",AVERAGE:"%{BKY_MATH_ONLIST_TOOLTIP_AVERAGE}",MEDIAN:"%{BKY_MATH_ONLIST_TOOLTIP_MEDIAN}",MODE:"%{BKY_MATH_ONLIST_TOOLTIP_MODE}",STD_DEV:"%{BKY_MATH_ONLIST_TOOLTIP_STD_DEV}",RANDOM:"%{BKY_MATH_ONLIST_TOOLTIP_RANDOM}"};l.register$$module$build$src$core$extensions("math_op_tooltip",l.buildTooltipForDropdown$$module$build$src$core$extensions("OP",_));var F={mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation"),p=this.getFieldValue("PROPERTY")==="DIVISIBLE_BY";return c.setAttribute("divisor_input",String(p)),c},domToMutation:function(c){c=c.getAttribute("divisor_input")==="true",this.updateShape_(c)},updateShape_:function(c){const p=this.getInput("DIVISOR");c?p||this.appendValueInput("DIVISOR").setCheck("Number"):p&&this.removeInput("DIVISOR")}},Q=function(){this.getField("PROPERTY").setValidator(function(c){c=c==="DIVISIBLE_BY",this.getSourceBlock().updateShape_(c)})};l.registerMutator$$module$build$src$core$extensions("math_is_divisibleby_mutator",F,Q),l.register$$module$build$src$core$extensions("math_change_tooltip",l.buildTooltipWithFieldText$$module$build$src$core$extensions("%{BKY_MATH_CHANGE_TOOLTIP}","VAR"));var ne={updateType_:function(c){c==="MODE"?this.outputConnection.setCheck("Array"):this.outputConnection.setCheck("Number")},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");return c.setAttribute("op",this.getFieldValue("OP")),c},domToMutation:function(c){if(c=c.getAttribute("op"),c===null)throw new TypeError("xmlElement had no op attribute");this.updateType_(c)}},le=function(){this.getField("OP").setValidator((function(c){this.updateType_(c)}).bind(this))};l.registerMutator$$module$build$src$core$extensions("math_modes_of_list_mutator",ne,le),l.defineBlocks$$module$build$src$core$common(Ue);var he={blocks:Ue},J=l.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"controls_repeat_ext",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"input_value",name:"TIMES",check:"Number"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_repeat",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"field_number",name:"TIMES",value:10,min:0,precision:1}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_whileUntil",message0:"%1 %2",args0:[{type:"field_dropdown",name:"MODE",options:[["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_WHILE}","WHILE"],["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL}","UNTIL"]]},{type:"input_value",name:"BOOL",check:"Boolean"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_WHILEUNTIL_HELPURL}",extensions:["controls_whileUntil_tooltip"]},{type:"controls_for",message0:"%{BKY_CONTROLS_FOR_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"FROM",check:"Number",align:"RIGHT"},{type:"input_value",name:"TO",check:"Number",align:"RIGHT"},{type:"input_value",name:"BY",check:"Number",align:"RIGHT"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FOR_HELPURL}",extensions:["contextMenu_newGetVariableBlock","controls_for_tooltip"]},{type:"controls_forEach",message0:"%{BKY_CONTROLS_FOREACH_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"LIST",check:"Array"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FOREACH_HELPURL}",extensions:["contextMenu_newGetVariableBlock","controls_forEach_tooltip"]},{type:"controls_flow_statements",message0:"%1",args0:[{type:"field_dropdown",name:"FLOW",options:[["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK}","BREAK"],["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE}","CONTINUE"]]}],previousStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FLOW_STATEMENTS_HELPURL}",suppressPrefixSuffix:!0,extensions:["controls_flow_tooltip","controls_flow_in_loop_check"]}]),$e={WHILE:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE}",UNTIL:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}"};l.register$$module$build$src$core$extensions("controls_whileUntil_tooltip",l.buildTooltipForDropdown$$module$build$src$core$extensions("MODE",$e));var ce={BREAK:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK}",CONTINUE:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}"};l.register$$module$build$src$core$extensions("controls_flow_tooltip",l.buildTooltipForDropdown$$module$build$src$core$extensions("FLOW",ce));var _e={customContextMenu:function(c){if(!this.isInFlyout){var p=this.getField("VAR"),I=p.getVariable().getName();this.isCollapsed()||I===null||(p={type:"variables_get",fields:{VAR:p.saveState(!0)}},c.push({enabled:!0,text:l.Msg$$module$build$src$core$msg.VARIABLES_SET_CREATE_GET.replace("%1",I),callback:l.callbackFactory$$module$build$src$core$contextmenu(this,p)}))}}};l.registerMixin$$module$build$src$core$extensions("contextMenu_newGetVariableBlock",_e),l.register$$module$build$src$core$extensions("controls_for_tooltip",l.buildTooltipWithFieldText$$module$build$src$core$extensions("%{BKY_CONTROLS_FOR_TOOLTIP}","VAR")),l.register$$module$build$src$core$extensions("controls_forEach_tooltip",l.buildTooltipWithFieldText$$module$build$src$core$extensions("%{BKY_CONTROLS_FOREACH_TOOLTIP}","VAR"));var U=new Set(["controls_repeat","controls_repeat_ext","controls_forEach","controls_for","controls_whileUntil"]),Xe="CONTROL_FLOW_NOT_IN_LOOP",v={getSurroundLoop:function(){let c=this;do{if(U.has(c.type))return c;c=c.getSurroundParent()}while(c);return null},onchange:function(c){const p=this.workspace;if(p.isDragging&&!p.isDragging()&&(c.type===l.BLOCK_MOVE$$module$build$src$core$events$events||c.type===l.BLOCK_CREATE$$module$build$src$core$events$events)&&(c=!!this.getSurroundLoop(),this.setWarningText(c?null:l.Msg$$module$build$src$core$msg.CONTROLS_FLOW_STATEMENTS_WARNING),!this.isInFlyout))try{l.setRecordUndo$$module$build$src$core$events$utils(!1),this.setDisabledReason(!c,Xe)}finally{l.setRecordUndo$$module$build$src$core$events$utils(!0)}}};l.registerMixin$$module$build$src$core$extensions("controls_flow_in_loop_check",v),l.defineBlocks$$module$build$src$core$common(J);var G={blocks:J,loopTypes:U},Lt=l.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"logic_boolean",message0:"%1",args0:[{type:"field_dropdown",name:"BOOL",options:[["%{BKY_LOGIC_BOOLEAN_TRUE}","TRUE"],["%{BKY_LOGIC_BOOLEAN_FALSE}","FALSE"]]}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_BOOLEAN_TOOLTIP}",helpUrl:"%{BKY_LOGIC_BOOLEAN_HELPURL}"},{type:"controls_if",message0:"%{BKY_CONTROLS_IF_MSG_IF} %1",args0:[{type:"input_value",name:"IF0",check:"Boolean"}],message1:"%{BKY_CONTROLS_IF_MSG_THEN} %1",args1:[{type:"input_statement",name:"DO0"}],previousStatement:null,nextStatement:null,style:"logic_blocks",helpUrl:"%{BKY_CONTROLS_IF_HELPURL}",suppressPrefixSuffix:!0,mutator:"controls_if_mutator",extensions:["controls_if_tooltip"]},{type:"controls_ifelse",message0:"%{BKY_CONTROLS_IF_MSG_IF} %1",args0:[{type:"input_value",name:"IF0",check:"Boolean"}],message1:"%{BKY_CONTROLS_IF_MSG_THEN} %1",args1:[{type:"input_statement",name:"DO0"}],message2:"%{BKY_CONTROLS_IF_MSG_ELSE} %1",args2:[{type:"input_statement",name:"ELSE"}],previousStatement:null,nextStatement:null,style:"logic_blocks",tooltip:"%{BKYCONTROLS_IF_TOOLTIP_2}",helpUrl:"%{BKY_CONTROLS_IF_HELPURL}",suppressPrefixSuffix:!0,extensions:["controls_if_tooltip"]},{type:"logic_compare",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A"},{type:"field_dropdown",name:"OP",options:[["=","EQ"],["≠","NEQ"],["‏<","LT"],["‏≤","LTE"],["‏>","GT"],["‏≥","GTE"]]},{type:"input_value",name:"B"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_COMPARE_HELPURL}",extensions:["logic_compare","logic_op_tooltip"]},{type:"logic_operation",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Boolean"},{type:"field_dropdown",name:"OP",options:[["%{BKY_LOGIC_OPERATION_AND}","AND"],["%{BKY_LOGIC_OPERATION_OR}","OR"]]},{type:"input_value",name:"B",check:"Boolean"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_OPERATION_HELPURL}",extensions:["logic_op_tooltip"]},{type:"logic_negate",message0:"%{BKY_LOGIC_NEGATE_TITLE}",args0:[{type:"input_value",name:"BOOL",check:"Boolean"}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_NEGATE_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NEGATE_HELPURL}"},{type:"logic_null",message0:"%{BKY_LOGIC_NULL}",output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_NULL_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NULL_HELPURL}"},{type:"logic_ternary",message0:"%{BKY_LOGIC_TERNARY_CONDITION} %1",args0:[{type:"input_value",name:"IF",check:"Boolean"}],message1:"%{BKY_LOGIC_TERNARY_IF_TRUE} %1",args1:[{type:"input_value",name:"THEN"}],message2:"%{BKY_LOGIC_TERNARY_IF_FALSE} %1",args2:[{type:"input_value",name:"ELSE"}],output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_TERNARY_TOOLTIP}",helpUrl:"%{BKY_LOGIC_TERNARY_HELPURL}",extensions:["logic_ternary"]},{type:"controls_if_if",message0:"%{BKY_CONTROLS_IF_IF_TITLE_IF}",nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_IF_TOOLTIP}"},{type:"controls_if_elseif",message0:"%{BKY_CONTROLS_IF_ELSEIF_TITLE_ELSEIF}",previousStatement:null,nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSEIF_TOOLTIP}"},{type:"controls_if_else",message0:"%{BKY_CONTROLS_IF_ELSE_TITLE_ELSE}",previousStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSE_TOOLTIP}"}]),Te={EQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_EQ}",NEQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_NEQ}",LT:"%{BKY_LOGIC_COMPARE_TOOLTIP_LT}",LTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_LTE}",GT:"%{BKY_LOGIC_COMPARE_TOOLTIP_GT}",GTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_GTE}",AND:"%{BKY_LOGIC_OPERATION_TOOLTIP_AND}",OR:"%{BKY_LOGIC_OPERATION_TOOLTIP_OR}"};l.register$$module$build$src$core$extensions("logic_op_tooltip",l.buildTooltipForDropdown$$module$build$src$core$extensions("OP",Te));var qo={elseifCount_:0,elseCount_:0,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const c=l.createElement$$module$build$src$core$utils$xml("mutation");return this.elseifCount_&&c.setAttribute("elseif",String(this.elseifCount_)),this.elseCount_&&c.setAttribute("else","1"),c},domToMutation:function(c){this.elseifCount_=parseInt(c.getAttribute("elseif"),10)||0,this.elseCount_=parseInt(c.getAttribute("else"),10)||0,this.rebuildShape_()},saveExtraState:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const c=Object.create(null);return this.elseifCount_&&(c.elseIfCount=this.elseifCount_),this.elseCount_&&(c.hasElse=!0),c},loadExtraState:function(c){this.elseifCount_=c.elseIfCount||0,this.elseCount_=c.hasElse?1:0,this.updateShape_()},decompose:function(c){const p=c.newBlock("controls_if_if");p.initSvg();let I=p.nextConnection;for(let C=1;C<=this.elseifCount_;C++){const V=c.newBlock("controls_if_elseif");V.initSvg(),I.connect(V.previousConnection),I=V.nextConnection}return this.elseCount_&&(c=c.newBlock("controls_if_else"),c.initSvg(),I.connect(c.previousConnection)),p},compose:function(c){c=c.nextConnection.targetBlock(),this.elseCount_=this.elseifCount_=0;const p=[null],I=[null];let C=null;for(;c;){if(!c.isInsertionMarker())switch(c.type){case"controls_if_elseif":this.elseifCount_++,p.push(c.valueConnection_),I.push(c.statementConnection_);break;case"controls_if_else":this.elseCount_++,C=c.statementConnection_;break;default:throw TypeError("Unknown block type: "+c.type)}c=c.getNextBlock()}this.updateShape_(),this.reconnectChildBlocks_(p,I,C)},saveConnections:function(c){c=c.nextConnection.targetBlock();let p=1;for(;c;){if(!c.isInsertionMarker())switch(c.type){case"controls_if_elseif":var I=this.getInput("IF"+p);const C=this.getInput("DO"+p);c.valueConnection_=I&&I.connection.targetConnection,c.statementConnection_=C&&C.connection.targetConnection,p++;break;case"controls_if_else":I=this.getInput("ELSE"),c.statementConnection_=I&&I.connection.targetConnection;break;default:throw TypeError("Unknown block type: "+c.type)}c=c.getNextBlock()}},rebuildShape_:function(){const c=[null],p=[null];let I=null;this.getInput("ELSE")&&(I=this.getInput("ELSE").connection.targetConnection);for(let C=1;this.getInput("IF"+C);C++){const V=this.getInput("IF"+C),Ae=this.getInput("DO"+C);c.push(V.connection.targetConnection),p.push(Ae.connection.targetConnection)}this.updateShape_(),this.reconnectChildBlocks_(c,p,I)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var c=1;this.getInput("IF"+c);c++)this.removeInput("IF"+c),this.removeInput("DO"+c);for(c=1;c<=this.elseifCount_;c++)this.appendValueInput("IF"+c).setCheck("Boolean").appendField(l.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+c).appendField(l.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(l.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_ELSE)},reconnectChildBlocks_:function(c,p,I){for(let C=1;C<=this.elseifCount_;C++){let V;(V=c[C])==null||V.reconnect(this,"IF"+C);let Ae;(Ae=p[C])==null||Ae.reconnect(this,"DO"+C)}I?.reconnect(this,"ELSE")}};l.registerMutator$$module$build$src$core$extensions("controls_if_mutator",qo,null,["controls_if_elseif","controls_if_else"]);var ke=function(){this.setTooltip((function(){if(this.elseifCount_||this.elseCount_){if(!this.elseifCount_&&this.elseCount_)return l.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_2;if(this.elseifCount_&&!this.elseCount_)return l.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_3;if(this.elseifCount_&&this.elseCount_)return l.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_4}else return l.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_1;return""}).bind(this))};l.register$$module$build$src$core$extensions("controls_if_tooltip",ke);var Qt={onchange:function(c){this.prevBlocks_||(this.prevBlocks_=[null,null]);var p=this.getInputTargetBlock("A");const I=this.getInputTargetBlock("B");p&&I&&!this.workspace.connectionChecker.doTypeChecks(p.outputConnection,I.outputConnection)&&(l.setGroup$$module$build$src$core$events$utils(c.group),c=this.prevBlocks_[0],c!==p&&(p.unplug(),!c||c.isDisposed()||c.isShadow()||this.getInput("A").connection.connect(c.outputConnection)),p=this.prevBlocks_[1],p!==I&&(I.unplug(),!p||p.isDisposed()||p.isShadow()||this.getInput("B").connection.connect(p.outputConnection)),this.bumpNeighbours(),l.setGroup$$module$build$src$core$events$utils(!1)),this.prevBlocks_[0]=this.getInputTargetBlock("A"),this.prevBlocks_[1]=this.getInputTargetBlock("B")}},Mo=function(){this.mixin(Qt)};l.register$$module$build$src$core$extensions("logic_compare",Mo);var eo={prevParentConnection_:null,onchange:function(c){const p=this.getInputTargetBlock("THEN"),I=this.getInputTargetBlock("ELSE"),C=this.outputConnection.targetConnection;if((p||I)&&C)for(let V=0;V<2;V++){const Ae=V===1?p:I;Ae&&!Ae.workspace.connectionChecker.doTypeChecks(Ae.outputConnection,C)&&(l.setGroup$$module$build$src$core$events$utils(c.group),C===this.prevParentConnection_?(this.unplug(),C.getSourceBlock().bumpNeighbours()):(Ae.unplug(),Ae.bumpNeighbours()),l.setGroup$$module$build$src$core$events$utils(!1))}this.prevParentConnection_=C}};l.registerMixin$$module$build$src$core$extensions("logic_ternary",eo),l.defineBlocks$$module$build$src$core$common(Lt);var to={blocks:Lt},ot=l.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"lists_create_empty",message0:"%{BKY_LISTS_CREATE_EMPTY_TITLE}",output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_CREATE_EMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_CREATE_EMPTY_HELPURL}"},{type:"lists_repeat",message0:"%{BKY_LISTS_REPEAT_TITLE}",args0:[{type:"input_value",name:"ITEM"},{type:"input_value",name:"NUM",check:"Number"}],output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_LISTS_REPEAT_HELPURL}"},{type:"lists_reverse",message0:"%{BKY_LISTS_REVERSE_MESSAGE0}",args0:[{type:"input_value",name:"LIST",check:"Array"}],output:"Array",inputsInline:!0,style:"list_blocks",tooltip:"%{BKY_LISTS_REVERSE_TOOLTIP}",helpUrl:"%{BKY_LISTS_REVERSE_HELPURL}"},{type:"lists_isEmpty",message0:"%{BKY_LISTS_ISEMPTY_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",style:"list_blocks",tooltip:"%{BKY_LISTS_ISEMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_ISEMPTY_HELPURL}"},{type:"lists_length",message0:"%{BKY_LISTS_LENGTH_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",style:"list_blocks",tooltip:"%{BKY_LISTS_LENGTH_TOOLTIP}",helpUrl:"%{BKY_LISTS_LENGTH_HELPURL}"}]),ms={init:function(){this.setHelpUrl(l.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_HELPURL),this.setStyle("list_blocks"),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new l.MutatorIcon$$module$build$src$core$icons$mutator_icon(["lists_create_with_item"],this)),this.setTooltip(l.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");return c.setAttribute("items",String(this.itemCount_)),c},domToMutation:function(c){if(c=c.getAttribute("items"),!c)throw new TypeError("element did not have items");this.itemCount_=parseInt(c,10),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(c){this.itemCount_=c.itemCount,this.updateShape_()},decompose:function(c){const p=c.newBlock("lists_create_with_container");p.initSvg();let I=p.getInput("STACK").connection;for(let C=0;C<this.itemCount_;C++){const V=c.newBlock("lists_create_with_item");if(V.initSvg(),!V.previousConnection)throw Error("itemBlock has no previousConnection");I.connect(V.previousConnection),I=V.nextConnection}return p},compose:function(c){var p=c.getInputTargetBlock("STACK");for(c=[];p;)p.isInsertionMarker()||c.push(p.valueConnection_),p=p.getNextBlock();for(p=0;p<this.itemCount_;p++){const I=this.getInput("ADD"+p).connection.targetConnection;I&&!c.includes(I)&&I.disconnect()}for(this.itemCount_=c.length,this.updateShape_(),p=0;p<this.itemCount_;p++){let I;(I=c[p])==null||I.reconnect(this,"ADD"+p)}},saveConnections:function(c){c=c.getInputTargetBlock("STACK");let p=0;for(;c;){if(c.isInsertionMarker()){c=c.getNextBlock();continue}const I=this.getInput("ADD"+p);let C;c.valueConnection_=(C=I)==null?void 0:C.connection.targetConnection,c=c.getNextBlock(),p++}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(l.Msg$$module$build$src$core$msg.LISTS_CREATE_EMPTY_TITLE);for(var c=0;c<this.itemCount_;c++)if(!this.getInput("ADD"+c)){const p=this.appendValueInput("ADD"+c).setAlign(l.Align$$module$build$src$core$inputs$align.RIGHT);c===0&&p.appendField(l.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_INPUT_WITH)}for(c=this.itemCount_;this.getInput("ADD"+c);c++)this.removeInput("ADD"+c)}};ot.lists_create_with=ms;var ho={init:function(){this.setStyle("list_blocks"),this.appendDummyInput().appendField(l.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD),this.appendStatementInput("STACK"),this.setTooltip(l.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP),this.contextMenu=!1}};ot.lists_create_with_container=ho;var E={init:function(){this.setStyle("list_blocks"),this.appendDummyInput().appendField(l.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(l.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}};ot.lists_create_with_item=E;var oo={init:function(){var c=[[l.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_FIRST,"FIRST"],[l.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_LAST,"LAST"]];if(this.setHelpUrl(l.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_HELPURL),this.setStyle("list_blocks"),this.setOutput(!0,"Number"),this.appendValueInput("VALUE").setCheck("Array").appendField(l.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_INPUT_IN_LIST),c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:c}),!c)throw Error("field_dropdown not found");this.appendValueInput("FIND").appendField(c,"END"),this.setInputsInline(!0),this.setTooltip(()=>l.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"0":"-1"))}};ot.lists_indexOf=oo;var Do={init:function(){var c=[[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_GET,"GET"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_GET_REMOVE,"GET_REMOVE"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_REMOVE,"REMOVE"]];this.WHERE_OPTIONS=[[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FIRST,"FIRST"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_LAST,"LAST"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_HELPURL),this.setStyle("list_blocks"),c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:c}),c.setValidator(function(p){p=p==="REMOVE",this.getSourceBlock().updateStatement_(p)}),this.appendValueInput("VALUE").setCheck("Array").appendField(l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_INPUT_IN_LIST),this.appendDummyInput().appendField(c,"MODE").appendField("","SPACE"),c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:this.WHERE_OPTIONS}),c.setValidator(function(p){const I=this.getValue();p=p==="FROM_START"||p==="FROM_END",p!==(I==="FROM_START"||I==="FROM_END")&&this.getSourceBlock().updateAt_(p)}),this.appendDummyInput().appendField(c,"WHERE"),this.appendDummyInput("AT"),l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendField(l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TAIL),this.setInputsInline(!0),this.setOutput(!0),this.updateAt_(!0),this.setTooltip(()=>{const p=this.getFieldValue("MODE"),I=this.getFieldValue("WHERE");let C="";switch(p+" "+I){case"GET FROM_START":case"GET FROM_END":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM;break;case"GET FIRST":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST;break;case"GET LAST":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST;break;case"GET RANDOM":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM;break;case"GET_REMOVE FROM_START":case"GET_REMOVE FROM_END":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM;break;case"GET_REMOVE FIRST":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST;break;case"GET_REMOVE LAST":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST;break;case"GET_REMOVE RANDOM":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM;break;case"REMOVE FROM_START":case"REMOVE FROM_END":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM;break;case"REMOVE FIRST":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST;break;case"REMOVE LAST":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST;break;case"REMOVE RANDOM":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM}return(I==="FROM_START"||I==="FROM_END")&&(C+=" "+(I==="FROM_START"?l.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_START_TOOLTIP:l.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_END_TOOLTIP).replace("%1",this.workspace.options.oneBasedIndex?"#1":"#0")),C})},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");c.setAttribute("statement",String(!this.outputConnection));const p=this.getInput("AT")instanceof l.ValueInput$$module$build$src$core$inputs$value_input;return c.setAttribute("at",String(p)),c},domToMutation:function(c){const p=c.getAttribute("statement")==="true";this.updateStatement_(p),c=c.getAttribute("at")!=="false",this.updateAt_(c)},saveExtraState:function(){return this.outputConnection?null:{isStatement:!0}},loadExtraState:function(c){c.isStatement?this.updateStatement_(!0):typeof c=="string"&&this.domToMutation(l.textToDom$$module$build$src$core$utils$xml(c))},updateStatement_:function(c){c!==!this.outputConnection&&(this.unplug(!0,!0),c?(this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},updateAt_:function(c){this.removeInput("AT"),this.removeInput("ORDINAL",!0),c?(this.appendValueInput("AT").setCheck("Number"),l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"),l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",null)}};ot.lists_getIndex=Do;var He={init:function(){var c=[[l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_SET,"SET"],[l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_INSERT,"INSERT"]];this.WHERE_OPTIONS=[[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FIRST,"FIRST"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_LAST,"LAST"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("LIST").setCheck("Array").appendField(l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_INPUT_IN_LIST),c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:c}),this.appendDummyInput().appendField(c,"MODE").appendField("","SPACE"),c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:this.WHERE_OPTIONS}),c.setValidator(function(p){const I=this.getValue();p=p==="FROM_START"||p==="FROM_END",p!==(I==="FROM_START"||I==="FROM_END")&&this.getSourceBlock().updateAt_(p)}),this.appendDummyInput().appendField(c,"WHERE"),this.appendDummyInput("AT"),this.appendValueInput("TO").appendField(l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_INPUT_TO),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP),this.updateAt_(!0),this.setTooltip(()=>{const p=this.getFieldValue("MODE"),I=this.getFieldValue("WHERE");let C="";switch(p+" "+I){case"SET FROM_START":case"SET FROM_END":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM;break;case"SET FIRST":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_FIRST;break;case"SET LAST":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST;break;case"SET RANDOM":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM;break;case"INSERT FROM_START":case"INSERT FROM_END":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM;break;case"INSERT FIRST":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST;break;case"INSERT LAST":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST;break;case"INSERT RANDOM":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM}return(I==="FROM_START"||I==="FROM_END")&&(C+=" "+l.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_START_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"#1":"#0")),C})},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation"),p=this.getInput("AT")instanceof l.ValueInput$$module$build$src$core$inputs$value_input;return c.setAttribute("at",String(p)),c},domToMutation:function(c){c=c.getAttribute("at")!=="false",this.updateAt_(c)},saveExtraState:function(){return null},loadExtraState:function(){},updateAt_:function(c){this.removeInput("AT"),this.removeInput("ORDINAL",!0),c?(this.appendValueInput("AT").setCheck("Number"),l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"),this.moveInputBefore("AT","TO"),this.getInput("ORDINAL")&&this.moveInputBefore("ORDINAL","TO")}};ot.lists_setIndex=He;var ct={init:function(){this.WHERE_OPTIONS_1=[[l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_START_FROM_START,"FROM_START"],[l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_START_FROM_END,"FROM_END"],[l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_END_LAST,"LAST"]],this.setHelpUrl(l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("LIST").setCheck("Array").appendField(l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_INPUT_IN_LIST);const c=p=>{const I=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:this["WHERE_OPTIONS_"+p]});return I.setValidator(function(C){const V=this.getValue();C=C==="FROM_START"||C==="FROM_END",C!==(V==="FROM_START"||V==="FROM_END")&&this.getSourceBlock().updateAt_(p,C)}),I};this.appendDummyInput("WHERE1_INPUT").appendField(c(1),"WHERE1"),this.appendDummyInput("AT1"),this.appendDummyInput("WHERE2_INPUT").appendField(c(2),"WHERE2"),this.appendDummyInput("AT2"),l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TAIL&&this.appendDummyInput("TAIL").appendField(l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TAIL),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.updateAt_(1,!0),this.updateAt_(2,!0),this.setTooltip(l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");var p=this.getInput("AT1")instanceof l.ValueInput$$module$build$src$core$inputs$value_input;return c.setAttribute("at1",String(p)),p=this.getInput("AT2")instanceof l.ValueInput$$module$build$src$core$inputs$value_input,c.setAttribute("at2",String(p)),c},domToMutation:function(c){const p=c.getAttribute("at1")==="true";c=c.getAttribute("at2")==="true",this.updateAt_(1,p),this.updateAt_(2,c)},saveExtraState:function(){return null},loadExtraState:function(){},updateAt_:function(c,p){this.removeInput("AT"+c),this.removeInput("ORDINAL"+c,!0),p?(this.appendValueInput("AT"+c).setCheck("Number"),l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+c).appendField(l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+c),c===1&&(this.moveInputBefore("AT1","WHERE2_INPUT"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","WHERE2_INPUT")),l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)}};ot.lists_getSublist=ct,ot.lists_sort={init:function(){this.jsonInit({message0:"%{BKY_LISTS_SORT_TITLE}",args0:[{type:"field_dropdown",name:"TYPE",options:[["%{BKY_LISTS_SORT_TYPE_NUMERIC}","NUMERIC"],["%{BKY_LISTS_SORT_TYPE_TEXT}","TEXT"],["%{BKY_LISTS_SORT_TYPE_IGNORECASE}","IGNORE_CASE"]]},{type:"field_dropdown",name:"DIRECTION",options:[["%{BKY_LISTS_SORT_ORDER_ASCENDING}","1"],["%{BKY_LISTS_SORT_ORDER_DESCENDING}","-1"]]},{type:"input_value",name:"LIST",check:"Array"}],output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_SORT_TOOLTIP}",helpUrl:"%{BKY_LISTS_SORT_HELPURL}"})}},ot.lists_split={init:function(){const c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:[[l.Msg$$module$build$src$core$msg.LISTS_SPLIT_LIST_FROM_TEXT,"SPLIT"],[l.Msg$$module$build$src$core$msg.LISTS_SPLIT_TEXT_FROM_LIST,"JOIN"]]});if(!c)throw Error("field_dropdown not found");c.setValidator(p=>{this.updateType_(p)}),this.setHelpUrl(l.Msg$$module$build$src$core$msg.LISTS_SPLIT_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("INPUT").setCheck("String").appendField(c,"MODE"),this.appendValueInput("DELIM").setCheck("String").appendField(l.Msg$$module$build$src$core$msg.LISTS_SPLIT_WITH_DELIMITER),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.setTooltip(()=>{const p=this.getFieldValue("MODE");if(p==="SPLIT")return l.Msg$$module$build$src$core$msg.LISTS_SPLIT_TOOLTIP_SPLIT;if(p==="JOIN")return l.Msg$$module$build$src$core$msg.LISTS_SPLIT_TOOLTIP_JOIN;throw Error("Unknown mode: "+p)})},updateType_:function(c){if(this.getFieldValue("MODE")!==c){const p=this.getInput("INPUT").connection;p.setShadowDom(null);const I=p.targetBlock();I&&(p.disconnect(),I.isShadow()?I.dispose(!1):this.bumpNeighbours())}c==="SPLIT"?(this.outputConnection.setCheck("Array"),this.getInput("INPUT").setCheck("String")):(this.outputConnection.setCheck("String"),this.getInput("INPUT").setCheck("Array"))},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");return c.setAttribute("mode",this.getFieldValue("MODE")),c},domToMutation:function(c){this.updateType_(c.getAttribute("mode"))},saveExtraState:function(){return{mode:this.getFieldValue("MODE")}},loadExtraState:function(c){this.updateType_(c.mode)}},l.defineBlocks$$module$build$src$core$common(ot);var kt={blocks:ot},st=Object.assign({},ot,Lt,J,Ue,Re,ie,D,g),Ut={blocks:st,lists:kt,logic:to,loops:G,math:he,procedures:St,texts:It,variables:ue,variablesDynamic:A};return Ut.__namespace__=l,Ut})})(Ml)),Ml.exports}var lv=nv();const cv=Di(lv),{blocks:GI,lists:VI,logic:WI,loops:zI,math:YI,procedures:XI,texts:jI,variables:KI,variablesDynamic:JI}=cv;var Dl={exports:{}},uv=Dl.exports,qf;function av(){return qf||(qf=1,(function(a,h){(function(r,l){a.exports=l(sd())})(uv,function(r){var l=r.__namespace__,g=function(u,$){return["[]",E.ATOMIC]},m=function(u,$){const b=Array(u.itemCount_);for(let S=0;S<u.itemCount_;S++)b[S]=$.valueToCode(u,"ADD"+S,E.NONE)||"null";return["["+b.join(", ")+"]",E.ATOMIC]},y=function(u,$){const b=$.provideFunction_("listsRepeat",`
793
+ `))this.quarkIds_=p;else{if(p.length!==c.length)throw RangeError("paramNames and paramIds must be the same length.");this.quarkIds_||(this.quarkConnections_={},this.quarkIds_=[]);for(let V=0;V<this.arguments_.length;V++){var C=this.getInput("ARG"+V);C&&(C=C.connection.targetConnection,this.quarkConnections_[this.quarkIds_[V]]=C,I&&C&&!p.includes(this.quarkIds_[V])&&(C.disconnect(),C.getSourceBlock().bumpNeighbours()))}for(this.arguments_=[].concat(c),this.argumentVarModels_=[],c=0;c<this.arguments_.length;c++)I=l.getOrCreateVariablePackage$$module$build$src$core$variables(this.workspace,null,this.arguments_[c],""),this.argumentVarModels_.push(I);if(this.updateShape_(),this.quarkIds_=p){for(p=0;p<this.arguments_.length;p++)if(c=this.quarkIds_[p],c in this.quarkConnections_){let V;(V=this.quarkConnections_[c])!=null&&V.reconnect(this,"ARG"+p)||delete this.quarkConnections_[c]}}}},updateShape_:function(){for(var c=0;c<this.arguments_.length;c++){var p=this.getField("ARGNAME"+c);if(p){l.disable$$module$build$src$core$events$utils();try{p.setValue(this.arguments_[c])}finally{l.enable$$module$build$src$core$events$utils()}}else p=l.fromJson$$module$build$src$core$field_registry({type:"field_label",text:this.arguments_[c]}),this.appendValueInput("ARG"+c).setAlign(l.Align$$module$build$src$core$inputs$align.RIGHT).appendField(p,"ARGNAME"+c)}for(c=this.arguments_.length;this.getInput("ARG"+c);c++)this.removeInput("ARG"+c);(c=this.getInput("TOPROW"))&&(this.arguments_.length?this.getField("WITH")||c.appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_CALL_BEFORE_PARAMS,"WITH"):this.getField("WITH")&&c.removeField("WITH"))},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");c.setAttribute("name",this.getProcedureCall());for(let p=0;p<this.arguments_.length;p++){const I=l.createElement$$module$build$src$core$utils$xml("arg");I.setAttribute("name",this.arguments_[p]),c.appendChild(I)}return c},domToMutation:function(c){var p=c.getAttribute("name");this.renameProcedure(this.getProcedureCall(),p),p=[];const I=[];for(let C=0,V;V=c.childNodes[C];C++)V.nodeName.toLowerCase()==="arg"&&(p.push(V.getAttribute("name")),I.push(V.getAttribute("paramId")));this.setProcedureParameters_(p,I)},saveExtraState:function(){const c=Object.create(null);return c.name=this.getProcedureCall(),this.arguments_.length&&(c.params=this.arguments_),c},loadExtraState:function(c){if(this.renameProcedure(this.getProcedureCall(),c.name),c=c.params){const p=[];p.length=c.length,p.fill(null),this.setProcedureParameters_(c,p)}},getVars:function(){return this.arguments_},getVarModels:function(){return this.argumentVarModels_},onchange:function(c){if(this.workspace&&!this.workspace.isFlyout&&c.recordUndo)if(c.type===l.BLOCK_CREATE$$module$build$src$core$events$events&&c.ids.includes(this.id)){var p=this.getProcedureCall(),I=l.getDefinition$$module$build$src$core$procedures(p,this.workspace);if(!I||I.type===this.defType_&&JSON.stringify(I.getVars())===JSON.stringify(this.arguments_)||(I=null),I)I.isEnabled()||(this.setDisabledReason(!0,nt),this.setWarningText(l.Msg$$module$build$src$core$msg.PROCEDURES_CALL_DISABLED_DEF_WARNING.replace("%1",p)));else{l.setGroup$$module$build$src$core$events$utils(c.group),c=l.createElement$$module$build$src$core$utils$xml("xml"),p=l.createElement$$module$build$src$core$utils$xml("block"),p.setAttribute("type",this.defType_),I=this.getRelativeToSurfaceXY();var C=I.y+l.config$$module$build$src$core$config.snapRadius*2;p.setAttribute("x",`${I.x+l.config$$module$build$src$core$config.snapRadius*(this.RTL?-1:1)}`),p.setAttribute("y",`${C}`),I=this.mutationToDom(),p.appendChild(I),I=l.createElement$$module$build$src$core$utils$xml("field"),I.setAttribute("name","NAME"),C=this.getProcedureCall();const V=l.findLegalName$$module$build$src$core$procedures(C,this);C!==V&&this.renameProcedure(C,V),I.appendChild(l.createTextNode$$module$build$src$core$utils$xml(C)),p.appendChild(I),c.appendChild(p),l.domToWorkspace$$module$build$src$core$xml(c,this.workspace),l.setGroup$$module$build$src$core$events$utils(!1)}}else c.type===l.BLOCK_DELETE$$module$build$src$core$events$events?(p=this.getProcedureCall(),l.getDefinition$$module$build$src$core$procedures(p,this.workspace)||(l.setGroup$$module$build$src$core$events$utils(c.group),this.dispose(!0),l.setGroup$$module$build$src$core$events$utils(!1))):c.type===l.BLOCK_CHANGE$$module$build$src$core$events$events&&c.element==="disabled"&&(p=this.getProcedureCall(),(C=l.getDefinition$$module$build$src$core$procedures(p,this.workspace))&&C.id===c.blockId&&((I=l.getGroup$$module$build$src$core$events$utils())&&console.log("Saw an existing group while responding to a definition change"),l.setGroup$$module$build$src$core$events$utils(c.group),c=C.isEnabled(),this.setDisabledReason(!c,nt),this.setWarningText(c?null:l.Msg$$module$build$src$core$msg.PROCEDURES_CALL_DISABLED_DEF_WARNING.replace("%1",p)),l.setGroup$$module$build$src$core$events$utils(I)))},customContextMenu:function(c){if(this.workspace.isMovable()){var p=this.getProcedureCall(),I=this.workspace;c.push({enabled:!0,text:l.Msg$$module$build$src$core$msg.PROCEDURES_HIGHLIGHT_DEF,callback:function(){const C=l.getDefinition$$module$build$src$core$procedures(p,I);C&&(I.centerOnBlock(C.id),l.getFocusManager$$module$build$src$core$focus_manager().focusNode(C))}})}}};Re.procedures_callnoreturn=Object.assign({},Tt,{init:function(){this.appendDummyInput("TOPROW").appendField("","NAME"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle("procedure_blocks"),this.setHelpUrl(l.Msg$$module$build$src$core$msg.PROCEDURES_CALLNORETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.quarkConnections_={},this.quarkIds_=null},defType_:"procedures_defnoreturn"}),Re.procedures_callreturn=Object.assign({},Tt,{init:function(){this.appendDummyInput("TOPROW").appendField("","NAME"),this.setOutput(!0),this.setStyle("procedure_blocks"),this.setHelpUrl(l.Msg$$module$build$src$core$msg.PROCEDURES_CALLRETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.quarkConnections_={},this.quarkIds_=null},defType_:"procedures_defreturn"});var lt="UNPARENTED_IFRETURN",$t={init:function(){this.appendValueInput("CONDITION").setCheck("Boolean").appendField(l.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_IF),this.appendValueInput("VALUE").appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_RETURN),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle("procedure_blocks"),this.setTooltip(l.Msg$$module$build$src$core$msg.PROCEDURES_IFRETURN_TOOLTIP),this.setHelpUrl(l.Msg$$module$build$src$core$msg.PROCEDURES_IFRETURN_HELPURL),this.hasReturnValue_=!0},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");return c.setAttribute("value",String(Number(this.hasReturnValue_))),c},domToMutation:function(c){this.hasReturnValue_=c.getAttribute("value")==="1",this.hasReturnValue_||(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_RETURN))},onchange:function(c){if(!(this.workspace.isDragging&&this.workspace.isDragging()||c.type!==l.BLOCK_MOVE$$module$build$src$core$events$events&&c.type!==l.BLOCK_CREATE$$module$build$src$core$events$events)){c=!1;var p=this;do{if(this.FUNCTION_TYPES.includes(p.type)){c=!0;break}p=p.getSurroundParent()}while(p);if(c?(p.type==="procedures_defnoreturn"&&this.hasReturnValue_?(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!1):p.type!=="procedures_defreturn"||this.hasReturnValue_||(this.removeInput("VALUE"),this.appendValueInput("VALUE").appendField(l.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!0),this.setWarningText(null)):this.setWarningText(l.Msg$$module$build$src$core$msg.PROCEDURES_IFRETURN_WARNING),!this.isInFlyout)try{l.setRecordUndo$$module$build$src$core$events$utils(!1),this.setDisabledReason(!c,lt)}finally{l.setRecordUndo$$module$build$src$core$events$utils(!0)}}},FUNCTION_TYPES:["procedures_defnoreturn","procedures_defreturn"]};Re.procedures_ifreturn=$t,l.defineBlocks$$module$build$src$core$common(Re);var St={blocks:Re},Ue=l.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"math_number",message0:"%1",args0:[{type:"field_number",name:"NUM",value:0}],output:"Number",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",style:"math_blocks",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_arithmetic",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Number"},{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ADDITION_SYMBOL}","ADD"],["%{BKY_MATH_SUBTRACTION_SYMBOL}","MINUS"],["%{BKY_MATH_MULTIPLICATION_SYMBOL}","MULTIPLY"],["%{BKY_MATH_DIVISION_SYMBOL}","DIVIDE"],["%{BKY_MATH_POWER_SYMBOL}","POWER"]]},{type:"input_value",name:"B",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_ARITHMETIC_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_single",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_SINGLE_OP_ROOT}","ROOT"],["%{BKY_MATH_SINGLE_OP_ABSOLUTE}","ABS"],["-","NEG"],["ln","LN"],["log10","LOG10"],["e^","EXP"],["10^","POW10"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_SINGLE_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_trig",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_TRIG_SIN}","SIN"],["%{BKY_MATH_TRIG_COS}","COS"],["%{BKY_MATH_TRIG_TAN}","TAN"],["%{BKY_MATH_TRIG_ASIN}","ASIN"],["%{BKY_MATH_TRIG_ACOS}","ACOS"],["%{BKY_MATH_TRIG_ATAN}","ATAN"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_TRIG_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_constant",message0:"%1",args0:[{type:"field_dropdown",name:"CONSTANT",options:[["π","PI"],["e","E"],["φ","GOLDEN_RATIO"],["sqrt(2)","SQRT2"],["sqrt(½)","SQRT1_2"],["∞","INFINITY"]]}],output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_CONSTANT_TOOLTIP}",helpUrl:"%{BKY_MATH_CONSTANT_HELPURL}"},{type:"math_number_property",message0:"%1 %2",args0:[{type:"input_value",name:"NUMBER_TO_CHECK",check:"Number"},{type:"field_dropdown",name:"PROPERTY",options:[["%{BKY_MATH_IS_EVEN}","EVEN"],["%{BKY_MATH_IS_ODD}","ODD"],["%{BKY_MATH_IS_PRIME}","PRIME"],["%{BKY_MATH_IS_WHOLE}","WHOLE"],["%{BKY_MATH_IS_POSITIVE}","POSITIVE"],["%{BKY_MATH_IS_NEGATIVE}","NEGATIVE"],["%{BKY_MATH_IS_DIVISIBLE_BY}","DIVISIBLE_BY"]]}],inputsInline:!0,output:"Boolean",style:"math_blocks",tooltip:"%{BKY_MATH_IS_TOOLTIP}",mutator:"math_is_divisibleby_mutator"},{type:"math_change",message0:"%{BKY_MATH_CHANGE_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_MATH_CHANGE_TITLE_ITEM}"},{type:"input_value",name:"DELTA",check:"Number"}],previousStatement:null,nextStatement:null,style:"variable_blocks",helpUrl:"%{BKY_MATH_CHANGE_HELPURL}",extensions:["math_change_tooltip"]},{type:"math_round",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ROUND_OPERATOR_ROUND}","ROUND"],["%{BKY_MATH_ROUND_OPERATOR_ROUNDUP}","ROUNDUP"],["%{BKY_MATH_ROUND_OPERATOR_ROUNDDOWN}","ROUNDDOWN"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_ROUND_HELPURL}",tooltip:"%{BKY_MATH_ROUND_TOOLTIP}"},{type:"math_on_list",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ONLIST_OPERATOR_SUM}","SUM"],["%{BKY_MATH_ONLIST_OPERATOR_MIN}","MIN"],["%{BKY_MATH_ONLIST_OPERATOR_MAX}","MAX"],["%{BKY_MATH_ONLIST_OPERATOR_AVERAGE}","AVERAGE"],["%{BKY_MATH_ONLIST_OPERATOR_MEDIAN}","MEDIAN"],["%{BKY_MATH_ONLIST_OPERATOR_MODE}","MODE"],["%{BKY_MATH_ONLIST_OPERATOR_STD_DEV}","STD_DEV"],["%{BKY_MATH_ONLIST_OPERATOR_RANDOM}","RANDOM"]]},{type:"input_value",name:"LIST",check:"Array"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_ONLIST_HELPURL}",mutator:"math_modes_of_list_mutator",extensions:["math_op_tooltip"]},{type:"math_modulo",message0:"%{BKY_MATH_MODULO_TITLE}",args0:[{type:"input_value",name:"DIVIDEND",check:"Number"},{type:"input_value",name:"DIVISOR",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_MODULO_TOOLTIP}",helpUrl:"%{BKY_MATH_MODULO_HELPURL}"},{type:"math_constrain",message0:"%{BKY_MATH_CONSTRAIN_TITLE}",args0:[{type:"input_value",name:"VALUE",check:"Number"},{type:"input_value",name:"LOW",check:"Number"},{type:"input_value",name:"HIGH",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_CONSTRAIN_TOOLTIP}",helpUrl:"%{BKY_MATH_CONSTRAIN_HELPURL}"},{type:"math_random_int",message0:"%{BKY_MATH_RANDOM_INT_TITLE}",args0:[{type:"input_value",name:"FROM",check:"Number"},{type:"input_value",name:"TO",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_RANDOM_INT_TOOLTIP}",helpUrl:"%{BKY_MATH_RANDOM_INT_HELPURL}"},{type:"math_random_float",message0:"%{BKY_MATH_RANDOM_FLOAT_TITLE_RANDOM}",output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_RANDOM_FLOAT_TOOLTIP}",helpUrl:"%{BKY_MATH_RANDOM_FLOAT_HELPURL}"},{type:"math_atan2",message0:"%{BKY_MATH_ATAN2_TITLE}",args0:[{type:"input_value",name:"X",check:"Number"},{type:"input_value",name:"Y",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_ATAN2_TOOLTIP}",helpUrl:"%{BKY_MATH_ATAN2_HELPURL}"}]),_={ADD:"%{BKY_MATH_ARITHMETIC_TOOLTIP_ADD}",MINUS:"%{BKY_MATH_ARITHMETIC_TOOLTIP_MINUS}",MULTIPLY:"%{BKY_MATH_ARITHMETIC_TOOLTIP_MULTIPLY}",DIVIDE:"%{BKY_MATH_ARITHMETIC_TOOLTIP_DIVIDE}",POWER:"%{BKY_MATH_ARITHMETIC_TOOLTIP_POWER}",ROOT:"%{BKY_MATH_SINGLE_TOOLTIP_ROOT}",ABS:"%{BKY_MATH_SINGLE_TOOLTIP_ABS}",NEG:"%{BKY_MATH_SINGLE_TOOLTIP_NEG}",LN:"%{BKY_MATH_SINGLE_TOOLTIP_LN}",LOG10:"%{BKY_MATH_SINGLE_TOOLTIP_LOG10}",EXP:"%{BKY_MATH_SINGLE_TOOLTIP_EXP}",POW10:"%{BKY_MATH_SINGLE_TOOLTIP_POW10}",SIN:"%{BKY_MATH_TRIG_TOOLTIP_SIN}",COS:"%{BKY_MATH_TRIG_TOOLTIP_COS}",TAN:"%{BKY_MATH_TRIG_TOOLTIP_TAN}",ASIN:"%{BKY_MATH_TRIG_TOOLTIP_ASIN}",ACOS:"%{BKY_MATH_TRIG_TOOLTIP_ACOS}",ATAN:"%{BKY_MATH_TRIG_TOOLTIP_ATAN}",SUM:"%{BKY_MATH_ONLIST_TOOLTIP_SUM}",MIN:"%{BKY_MATH_ONLIST_TOOLTIP_MIN}",MAX:"%{BKY_MATH_ONLIST_TOOLTIP_MAX}",AVERAGE:"%{BKY_MATH_ONLIST_TOOLTIP_AVERAGE}",MEDIAN:"%{BKY_MATH_ONLIST_TOOLTIP_MEDIAN}",MODE:"%{BKY_MATH_ONLIST_TOOLTIP_MODE}",STD_DEV:"%{BKY_MATH_ONLIST_TOOLTIP_STD_DEV}",RANDOM:"%{BKY_MATH_ONLIST_TOOLTIP_RANDOM}"};l.register$$module$build$src$core$extensions("math_op_tooltip",l.buildTooltipForDropdown$$module$build$src$core$extensions("OP",_));var F={mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation"),p=this.getFieldValue("PROPERTY")==="DIVISIBLE_BY";return c.setAttribute("divisor_input",String(p)),c},domToMutation:function(c){c=c.getAttribute("divisor_input")==="true",this.updateShape_(c)},updateShape_:function(c){const p=this.getInput("DIVISOR");c?p||this.appendValueInput("DIVISOR").setCheck("Number"):p&&this.removeInput("DIVISOR")}},Q=function(){this.getField("PROPERTY").setValidator(function(c){c=c==="DIVISIBLE_BY",this.getSourceBlock().updateShape_(c)})};l.registerMutator$$module$build$src$core$extensions("math_is_divisibleby_mutator",F,Q),l.register$$module$build$src$core$extensions("math_change_tooltip",l.buildTooltipWithFieldText$$module$build$src$core$extensions("%{BKY_MATH_CHANGE_TOOLTIP}","VAR"));var ne={updateType_:function(c){c==="MODE"?this.outputConnection.setCheck("Array"):this.outputConnection.setCheck("Number")},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");return c.setAttribute("op",this.getFieldValue("OP")),c},domToMutation:function(c){if(c=c.getAttribute("op"),c===null)throw new TypeError("xmlElement had no op attribute");this.updateType_(c)}},le=function(){this.getField("OP").setValidator((function(c){this.updateType_(c)}).bind(this))};l.registerMutator$$module$build$src$core$extensions("math_modes_of_list_mutator",ne,le),l.defineBlocks$$module$build$src$core$common(Ue);var he={blocks:Ue},J=l.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"controls_repeat_ext",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"input_value",name:"TIMES",check:"Number"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_repeat",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"field_number",name:"TIMES",value:10,min:0,precision:1}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_whileUntil",message0:"%1 %2",args0:[{type:"field_dropdown",name:"MODE",options:[["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_WHILE}","WHILE"],["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL}","UNTIL"]]},{type:"input_value",name:"BOOL",check:"Boolean"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_WHILEUNTIL_HELPURL}",extensions:["controls_whileUntil_tooltip"]},{type:"controls_for",message0:"%{BKY_CONTROLS_FOR_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"FROM",check:"Number",align:"RIGHT"},{type:"input_value",name:"TO",check:"Number",align:"RIGHT"},{type:"input_value",name:"BY",check:"Number",align:"RIGHT"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FOR_HELPURL}",extensions:["contextMenu_newGetVariableBlock","controls_for_tooltip"]},{type:"controls_forEach",message0:"%{BKY_CONTROLS_FOREACH_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"LIST",check:"Array"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FOREACH_HELPURL}",extensions:["contextMenu_newGetVariableBlock","controls_forEach_tooltip"]},{type:"controls_flow_statements",message0:"%1",args0:[{type:"field_dropdown",name:"FLOW",options:[["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK}","BREAK"],["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE}","CONTINUE"]]}],previousStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FLOW_STATEMENTS_HELPURL}",suppressPrefixSuffix:!0,extensions:["controls_flow_tooltip","controls_flow_in_loop_check"]}]),$e={WHILE:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE}",UNTIL:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}"};l.register$$module$build$src$core$extensions("controls_whileUntil_tooltip",l.buildTooltipForDropdown$$module$build$src$core$extensions("MODE",$e));var ce={BREAK:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK}",CONTINUE:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}"};l.register$$module$build$src$core$extensions("controls_flow_tooltip",l.buildTooltipForDropdown$$module$build$src$core$extensions("FLOW",ce));var _e={customContextMenu:function(c){if(!this.isInFlyout){var p=this.getField("VAR"),I=p.getVariable().getName();this.isCollapsed()||I===null||(p={type:"variables_get",fields:{VAR:p.saveState(!0)}},c.push({enabled:!0,text:l.Msg$$module$build$src$core$msg.VARIABLES_SET_CREATE_GET.replace("%1",I),callback:l.callbackFactory$$module$build$src$core$contextmenu(this,p)}))}}};l.registerMixin$$module$build$src$core$extensions("contextMenu_newGetVariableBlock",_e),l.register$$module$build$src$core$extensions("controls_for_tooltip",l.buildTooltipWithFieldText$$module$build$src$core$extensions("%{BKY_CONTROLS_FOR_TOOLTIP}","VAR")),l.register$$module$build$src$core$extensions("controls_forEach_tooltip",l.buildTooltipWithFieldText$$module$build$src$core$extensions("%{BKY_CONTROLS_FOREACH_TOOLTIP}","VAR"));var U=new Set(["controls_repeat","controls_repeat_ext","controls_forEach","controls_for","controls_whileUntil"]),Xe="CONTROL_FLOW_NOT_IN_LOOP",v={getSurroundLoop:function(){let c=this;do{if(U.has(c.type))return c;c=c.getSurroundParent()}while(c);return null},onchange:function(c){const p=this.workspace;if(p.isDragging&&!p.isDragging()&&(c.type===l.BLOCK_MOVE$$module$build$src$core$events$events||c.type===l.BLOCK_CREATE$$module$build$src$core$events$events)&&(c=!!this.getSurroundLoop(),this.setWarningText(c?null:l.Msg$$module$build$src$core$msg.CONTROLS_FLOW_STATEMENTS_WARNING),!this.isInFlyout))try{l.setRecordUndo$$module$build$src$core$events$utils(!1),this.setDisabledReason(!c,Xe)}finally{l.setRecordUndo$$module$build$src$core$events$utils(!0)}}};l.registerMixin$$module$build$src$core$extensions("controls_flow_in_loop_check",v),l.defineBlocks$$module$build$src$core$common(J);var G={blocks:J,loopTypes:U},Lt=l.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"logic_boolean",message0:"%1",args0:[{type:"field_dropdown",name:"BOOL",options:[["%{BKY_LOGIC_BOOLEAN_TRUE}","TRUE"],["%{BKY_LOGIC_BOOLEAN_FALSE}","FALSE"]]}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_BOOLEAN_TOOLTIP}",helpUrl:"%{BKY_LOGIC_BOOLEAN_HELPURL}"},{type:"controls_if",message0:"%{BKY_CONTROLS_IF_MSG_IF} %1",args0:[{type:"input_value",name:"IF0",check:"Boolean"}],message1:"%{BKY_CONTROLS_IF_MSG_THEN} %1",args1:[{type:"input_statement",name:"DO0"}],previousStatement:null,nextStatement:null,style:"logic_blocks",helpUrl:"%{BKY_CONTROLS_IF_HELPURL}",suppressPrefixSuffix:!0,mutator:"controls_if_mutator",extensions:["controls_if_tooltip"]},{type:"controls_ifelse",message0:"%{BKY_CONTROLS_IF_MSG_IF} %1",args0:[{type:"input_value",name:"IF0",check:"Boolean"}],message1:"%{BKY_CONTROLS_IF_MSG_THEN} %1",args1:[{type:"input_statement",name:"DO0"}],message2:"%{BKY_CONTROLS_IF_MSG_ELSE} %1",args2:[{type:"input_statement",name:"ELSE"}],previousStatement:null,nextStatement:null,style:"logic_blocks",tooltip:"%{BKYCONTROLS_IF_TOOLTIP_2}",helpUrl:"%{BKY_CONTROLS_IF_HELPURL}",suppressPrefixSuffix:!0,extensions:["controls_if_tooltip"]},{type:"logic_compare",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A"},{type:"field_dropdown",name:"OP",options:[["=","EQ"],["≠","NEQ"],["‏<","LT"],["‏≤","LTE"],["‏>","GT"],["‏≥","GTE"]]},{type:"input_value",name:"B"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_COMPARE_HELPURL}",extensions:["logic_compare","logic_op_tooltip"]},{type:"logic_operation",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Boolean"},{type:"field_dropdown",name:"OP",options:[["%{BKY_LOGIC_OPERATION_AND}","AND"],["%{BKY_LOGIC_OPERATION_OR}","OR"]]},{type:"input_value",name:"B",check:"Boolean"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_OPERATION_HELPURL}",extensions:["logic_op_tooltip"]},{type:"logic_negate",message0:"%{BKY_LOGIC_NEGATE_TITLE}",args0:[{type:"input_value",name:"BOOL",check:"Boolean"}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_NEGATE_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NEGATE_HELPURL}"},{type:"logic_null",message0:"%{BKY_LOGIC_NULL}",output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_NULL_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NULL_HELPURL}"},{type:"logic_ternary",message0:"%{BKY_LOGIC_TERNARY_CONDITION} %1",args0:[{type:"input_value",name:"IF",check:"Boolean"}],message1:"%{BKY_LOGIC_TERNARY_IF_TRUE} %1",args1:[{type:"input_value",name:"THEN"}],message2:"%{BKY_LOGIC_TERNARY_IF_FALSE} %1",args2:[{type:"input_value",name:"ELSE"}],output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_TERNARY_TOOLTIP}",helpUrl:"%{BKY_LOGIC_TERNARY_HELPURL}",extensions:["logic_ternary"]},{type:"controls_if_if",message0:"%{BKY_CONTROLS_IF_IF_TITLE_IF}",nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_IF_TOOLTIP}"},{type:"controls_if_elseif",message0:"%{BKY_CONTROLS_IF_ELSEIF_TITLE_ELSEIF}",previousStatement:null,nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSEIF_TOOLTIP}"},{type:"controls_if_else",message0:"%{BKY_CONTROLS_IF_ELSE_TITLE_ELSE}",previousStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSE_TOOLTIP}"}]),Te={EQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_EQ}",NEQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_NEQ}",LT:"%{BKY_LOGIC_COMPARE_TOOLTIP_LT}",LTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_LTE}",GT:"%{BKY_LOGIC_COMPARE_TOOLTIP_GT}",GTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_GTE}",AND:"%{BKY_LOGIC_OPERATION_TOOLTIP_AND}",OR:"%{BKY_LOGIC_OPERATION_TOOLTIP_OR}"};l.register$$module$build$src$core$extensions("logic_op_tooltip",l.buildTooltipForDropdown$$module$build$src$core$extensions("OP",Te));var qo={elseifCount_:0,elseCount_:0,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const c=l.createElement$$module$build$src$core$utils$xml("mutation");return this.elseifCount_&&c.setAttribute("elseif",String(this.elseifCount_)),this.elseCount_&&c.setAttribute("else","1"),c},domToMutation:function(c){this.elseifCount_=parseInt(c.getAttribute("elseif"),10)||0,this.elseCount_=parseInt(c.getAttribute("else"),10)||0,this.rebuildShape_()},saveExtraState:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const c=Object.create(null);return this.elseifCount_&&(c.elseIfCount=this.elseifCount_),this.elseCount_&&(c.hasElse=!0),c},loadExtraState:function(c){this.elseifCount_=c.elseIfCount||0,this.elseCount_=c.hasElse?1:0,this.updateShape_()},decompose:function(c){const p=c.newBlock("controls_if_if");p.initSvg();let I=p.nextConnection;for(let C=1;C<=this.elseifCount_;C++){const V=c.newBlock("controls_if_elseif");V.initSvg(),I.connect(V.previousConnection),I=V.nextConnection}return this.elseCount_&&(c=c.newBlock("controls_if_else"),c.initSvg(),I.connect(c.previousConnection)),p},compose:function(c){c=c.nextConnection.targetBlock(),this.elseCount_=this.elseifCount_=0;const p=[null],I=[null];let C=null;for(;c;){if(!c.isInsertionMarker())switch(c.type){case"controls_if_elseif":this.elseifCount_++,p.push(c.valueConnection_),I.push(c.statementConnection_);break;case"controls_if_else":this.elseCount_++,C=c.statementConnection_;break;default:throw TypeError("Unknown block type: "+c.type)}c=c.getNextBlock()}this.updateShape_(),this.reconnectChildBlocks_(p,I,C)},saveConnections:function(c){c=c.nextConnection.targetBlock();let p=1;for(;c;){if(!c.isInsertionMarker())switch(c.type){case"controls_if_elseif":var I=this.getInput("IF"+p);const C=this.getInput("DO"+p);c.valueConnection_=I&&I.connection.targetConnection,c.statementConnection_=C&&C.connection.targetConnection,p++;break;case"controls_if_else":I=this.getInput("ELSE"),c.statementConnection_=I&&I.connection.targetConnection;break;default:throw TypeError("Unknown block type: "+c.type)}c=c.getNextBlock()}},rebuildShape_:function(){const c=[null],p=[null];let I=null;this.getInput("ELSE")&&(I=this.getInput("ELSE").connection.targetConnection);for(let C=1;this.getInput("IF"+C);C++){const V=this.getInput("IF"+C),Ae=this.getInput("DO"+C);c.push(V.connection.targetConnection),p.push(Ae.connection.targetConnection)}this.updateShape_(),this.reconnectChildBlocks_(c,p,I)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var c=1;this.getInput("IF"+c);c++)this.removeInput("IF"+c),this.removeInput("DO"+c);for(c=1;c<=this.elseifCount_;c++)this.appendValueInput("IF"+c).setCheck("Boolean").appendField(l.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+c).appendField(l.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(l.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_ELSE)},reconnectChildBlocks_:function(c,p,I){for(let C=1;C<=this.elseifCount_;C++){let V;(V=c[C])==null||V.reconnect(this,"IF"+C);let Ae;(Ae=p[C])==null||Ae.reconnect(this,"DO"+C)}I?.reconnect(this,"ELSE")}};l.registerMutator$$module$build$src$core$extensions("controls_if_mutator",qo,null,["controls_if_elseif","controls_if_else"]);var ke=function(){this.setTooltip((function(){if(this.elseifCount_||this.elseCount_){if(!this.elseifCount_&&this.elseCount_)return l.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_2;if(this.elseifCount_&&!this.elseCount_)return l.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_3;if(this.elseifCount_&&this.elseCount_)return l.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_4}else return l.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_1;return""}).bind(this))};l.register$$module$build$src$core$extensions("controls_if_tooltip",ke);var Qt={onchange:function(c){this.prevBlocks_||(this.prevBlocks_=[null,null]);var p=this.getInputTargetBlock("A");const I=this.getInputTargetBlock("B");p&&I&&!this.workspace.connectionChecker.doTypeChecks(p.outputConnection,I.outputConnection)&&(l.setGroup$$module$build$src$core$events$utils(c.group),c=this.prevBlocks_[0],c!==p&&(p.unplug(),!c||c.isDisposed()||c.isShadow()||this.getInput("A").connection.connect(c.outputConnection)),p=this.prevBlocks_[1],p!==I&&(I.unplug(),!p||p.isDisposed()||p.isShadow()||this.getInput("B").connection.connect(p.outputConnection)),this.bumpNeighbours(),l.setGroup$$module$build$src$core$events$utils(!1)),this.prevBlocks_[0]=this.getInputTargetBlock("A"),this.prevBlocks_[1]=this.getInputTargetBlock("B")}},Mo=function(){this.mixin(Qt)};l.register$$module$build$src$core$extensions("logic_compare",Mo);var eo={prevParentConnection_:null,onchange:function(c){const p=this.getInputTargetBlock("THEN"),I=this.getInputTargetBlock("ELSE"),C=this.outputConnection.targetConnection;if((p||I)&&C)for(let V=0;V<2;V++){const Ae=V===1?p:I;Ae&&!Ae.workspace.connectionChecker.doTypeChecks(Ae.outputConnection,C)&&(l.setGroup$$module$build$src$core$events$utils(c.group),C===this.prevParentConnection_?(this.unplug(),C.getSourceBlock().bumpNeighbours()):(Ae.unplug(),Ae.bumpNeighbours()),l.setGroup$$module$build$src$core$events$utils(!1))}this.prevParentConnection_=C}};l.registerMixin$$module$build$src$core$extensions("logic_ternary",eo),l.defineBlocks$$module$build$src$core$common(Lt);var to={blocks:Lt},ot=l.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"lists_create_empty",message0:"%{BKY_LISTS_CREATE_EMPTY_TITLE}",output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_CREATE_EMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_CREATE_EMPTY_HELPURL}"},{type:"lists_repeat",message0:"%{BKY_LISTS_REPEAT_TITLE}",args0:[{type:"input_value",name:"ITEM"},{type:"input_value",name:"NUM",check:"Number"}],output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_LISTS_REPEAT_HELPURL}"},{type:"lists_reverse",message0:"%{BKY_LISTS_REVERSE_MESSAGE0}",args0:[{type:"input_value",name:"LIST",check:"Array"}],output:"Array",inputsInline:!0,style:"list_blocks",tooltip:"%{BKY_LISTS_REVERSE_TOOLTIP}",helpUrl:"%{BKY_LISTS_REVERSE_HELPURL}"},{type:"lists_isEmpty",message0:"%{BKY_LISTS_ISEMPTY_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",style:"list_blocks",tooltip:"%{BKY_LISTS_ISEMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_ISEMPTY_HELPURL}"},{type:"lists_length",message0:"%{BKY_LISTS_LENGTH_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",style:"list_blocks",tooltip:"%{BKY_LISTS_LENGTH_TOOLTIP}",helpUrl:"%{BKY_LISTS_LENGTH_HELPURL}"}]),ms={init:function(){this.setHelpUrl(l.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_HELPURL),this.setStyle("list_blocks"),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new l.MutatorIcon$$module$build$src$core$icons$mutator_icon(["lists_create_with_item"],this)),this.setTooltip(l.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");return c.setAttribute("items",String(this.itemCount_)),c},domToMutation:function(c){if(c=c.getAttribute("items"),!c)throw new TypeError("element did not have items");this.itemCount_=parseInt(c,10),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(c){this.itemCount_=c.itemCount,this.updateShape_()},decompose:function(c){const p=c.newBlock("lists_create_with_container");p.initSvg();let I=p.getInput("STACK").connection;for(let C=0;C<this.itemCount_;C++){const V=c.newBlock("lists_create_with_item");if(V.initSvg(),!V.previousConnection)throw Error("itemBlock has no previousConnection");I.connect(V.previousConnection),I=V.nextConnection}return p},compose:function(c){var p=c.getInputTargetBlock("STACK");for(c=[];p;)p.isInsertionMarker()||c.push(p.valueConnection_),p=p.getNextBlock();for(p=0;p<this.itemCount_;p++){const I=this.getInput("ADD"+p).connection.targetConnection;I&&!c.includes(I)&&I.disconnect()}for(this.itemCount_=c.length,this.updateShape_(),p=0;p<this.itemCount_;p++){let I;(I=c[p])==null||I.reconnect(this,"ADD"+p)}},saveConnections:function(c){c=c.getInputTargetBlock("STACK");let p=0;for(;c;){if(c.isInsertionMarker()){c=c.getNextBlock();continue}const I=this.getInput("ADD"+p);let C;c.valueConnection_=(C=I)==null?void 0:C.connection.targetConnection,c=c.getNextBlock(),p++}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(l.Msg$$module$build$src$core$msg.LISTS_CREATE_EMPTY_TITLE);for(var c=0;c<this.itemCount_;c++)if(!this.getInput("ADD"+c)){const p=this.appendValueInput("ADD"+c).setAlign(l.Align$$module$build$src$core$inputs$align.RIGHT);c===0&&p.appendField(l.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_INPUT_WITH)}for(c=this.itemCount_;this.getInput("ADD"+c);c++)this.removeInput("ADD"+c)}};ot.lists_create_with=ms;var ho={init:function(){this.setStyle("list_blocks"),this.appendDummyInput().appendField(l.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD),this.appendStatementInput("STACK"),this.setTooltip(l.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP),this.contextMenu=!1}};ot.lists_create_with_container=ho;var E={init:function(){this.setStyle("list_blocks"),this.appendDummyInput().appendField(l.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(l.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}};ot.lists_create_with_item=E;var oo={init:function(){var c=[[l.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_FIRST,"FIRST"],[l.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_LAST,"LAST"]];if(this.setHelpUrl(l.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_HELPURL),this.setStyle("list_blocks"),this.setOutput(!0,"Number"),this.appendValueInput("VALUE").setCheck("Array").appendField(l.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_INPUT_IN_LIST),c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:c}),!c)throw Error("field_dropdown not found");this.appendValueInput("FIND").appendField(c,"END"),this.setInputsInline(!0),this.setTooltip(()=>l.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"0":"-1"))}};ot.lists_indexOf=oo;var Do={init:function(){var c=[[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_GET,"GET"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_GET_REMOVE,"GET_REMOVE"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_REMOVE,"REMOVE"]];this.WHERE_OPTIONS=[[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FIRST,"FIRST"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_LAST,"LAST"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_HELPURL),this.setStyle("list_blocks"),c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:c}),c.setValidator(function(p){p=p==="REMOVE",this.getSourceBlock().updateStatement_(p)}),this.appendValueInput("VALUE").setCheck("Array").appendField(l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_INPUT_IN_LIST),this.appendDummyInput().appendField(c,"MODE").appendField("","SPACE"),c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:this.WHERE_OPTIONS}),c.setValidator(function(p){const I=this.getValue();p=p==="FROM_START"||p==="FROM_END",p!==(I==="FROM_START"||I==="FROM_END")&&this.getSourceBlock().updateAt_(p)}),this.appendDummyInput().appendField(c,"WHERE"),this.appendDummyInput("AT"),l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendField(l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TAIL),this.setInputsInline(!0),this.setOutput(!0),this.updateAt_(!0),this.setTooltip(()=>{const p=this.getFieldValue("MODE"),I=this.getFieldValue("WHERE");let C="";switch(p+" "+I){case"GET FROM_START":case"GET FROM_END":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM;break;case"GET FIRST":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST;break;case"GET LAST":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST;break;case"GET RANDOM":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM;break;case"GET_REMOVE FROM_START":case"GET_REMOVE FROM_END":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM;break;case"GET_REMOVE FIRST":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST;break;case"GET_REMOVE LAST":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST;break;case"GET_REMOVE RANDOM":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM;break;case"REMOVE FROM_START":case"REMOVE FROM_END":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM;break;case"REMOVE FIRST":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST;break;case"REMOVE LAST":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST;break;case"REMOVE RANDOM":C=l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM}return(I==="FROM_START"||I==="FROM_END")&&(C+=" "+(I==="FROM_START"?l.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_START_TOOLTIP:l.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_END_TOOLTIP).replace("%1",this.workspace.options.oneBasedIndex?"#1":"#0")),C})},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");c.setAttribute("statement",String(!this.outputConnection));const p=this.getInput("AT")instanceof l.ValueInput$$module$build$src$core$inputs$value_input;return c.setAttribute("at",String(p)),c},domToMutation:function(c){const p=c.getAttribute("statement")==="true";this.updateStatement_(p),c=c.getAttribute("at")!=="false",this.updateAt_(c)},saveExtraState:function(){return this.outputConnection?null:{isStatement:!0}},loadExtraState:function(c){c.isStatement?this.updateStatement_(!0):typeof c=="string"&&this.domToMutation(l.textToDom$$module$build$src$core$utils$xml(c))},updateStatement_:function(c){c!==!this.outputConnection&&(this.unplug(!0,!0),c?(this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},updateAt_:function(c){this.removeInput("AT"),this.removeInput("ORDINAL",!0),c?(this.appendValueInput("AT").setCheck("Number"),l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"),l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",null)}};ot.lists_getIndex=Do;var He={init:function(){var c=[[l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_SET,"SET"],[l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_INSERT,"INSERT"]];this.WHERE_OPTIONS=[[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FIRST,"FIRST"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_LAST,"LAST"],[l.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("LIST").setCheck("Array").appendField(l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_INPUT_IN_LIST),c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:c}),this.appendDummyInput().appendField(c,"MODE").appendField("","SPACE"),c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:this.WHERE_OPTIONS}),c.setValidator(function(p){const I=this.getValue();p=p==="FROM_START"||p==="FROM_END",p!==(I==="FROM_START"||I==="FROM_END")&&this.getSourceBlock().updateAt_(p)}),this.appendDummyInput().appendField(c,"WHERE"),this.appendDummyInput("AT"),this.appendValueInput("TO").appendField(l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_INPUT_TO),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP),this.updateAt_(!0),this.setTooltip(()=>{const p=this.getFieldValue("MODE"),I=this.getFieldValue("WHERE");let C="";switch(p+" "+I){case"SET FROM_START":case"SET FROM_END":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM;break;case"SET FIRST":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_FIRST;break;case"SET LAST":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST;break;case"SET RANDOM":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM;break;case"INSERT FROM_START":case"INSERT FROM_END":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM;break;case"INSERT FIRST":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST;break;case"INSERT LAST":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST;break;case"INSERT RANDOM":C=l.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM}return(I==="FROM_START"||I==="FROM_END")&&(C+=" "+l.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_START_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"#1":"#0")),C})},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation"),p=this.getInput("AT")instanceof l.ValueInput$$module$build$src$core$inputs$value_input;return c.setAttribute("at",String(p)),c},domToMutation:function(c){c=c.getAttribute("at")!=="false",this.updateAt_(c)},saveExtraState:function(){return null},loadExtraState:function(){},updateAt_:function(c){this.removeInput("AT"),this.removeInput("ORDINAL",!0),c?(this.appendValueInput("AT").setCheck("Number"),l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"),this.moveInputBefore("AT","TO"),this.getInput("ORDINAL")&&this.moveInputBefore("ORDINAL","TO")}};ot.lists_setIndex=He;var ct={init:function(){this.WHERE_OPTIONS_1=[[l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_START_FROM_START,"FROM_START"],[l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_START_FROM_END,"FROM_END"],[l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_END_LAST,"LAST"]],this.setHelpUrl(l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("LIST").setCheck("Array").appendField(l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_INPUT_IN_LIST);const c=p=>{const I=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:this["WHERE_OPTIONS_"+p]});return I.setValidator(function(C){const V=this.getValue();C=C==="FROM_START"||C==="FROM_END",C!==(V==="FROM_START"||V==="FROM_END")&&this.getSourceBlock().updateAt_(p,C)}),I};this.appendDummyInput("WHERE1_INPUT").appendField(c(1),"WHERE1"),this.appendDummyInput("AT1"),this.appendDummyInput("WHERE2_INPUT").appendField(c(2),"WHERE2"),this.appendDummyInput("AT2"),l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TAIL&&this.appendDummyInput("TAIL").appendField(l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TAIL),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.updateAt_(1,!0),this.updateAt_(2,!0),this.setTooltip(l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");var p=this.getInput("AT1")instanceof l.ValueInput$$module$build$src$core$inputs$value_input;return c.setAttribute("at1",String(p)),p=this.getInput("AT2")instanceof l.ValueInput$$module$build$src$core$inputs$value_input,c.setAttribute("at2",String(p)),c},domToMutation:function(c){const p=c.getAttribute("at1")==="true";c=c.getAttribute("at2")==="true",this.updateAt_(1,p),this.updateAt_(2,c)},saveExtraState:function(){return null},loadExtraState:function(){},updateAt_:function(c,p){this.removeInput("AT"+c),this.removeInput("ORDINAL"+c,!0),p?(this.appendValueInput("AT"+c).setCheck("Number"),l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+c).appendField(l.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+c),c===1&&(this.moveInputBefore("AT1","WHERE2_INPUT"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","WHERE2_INPUT")),l.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)}};ot.lists_getSublist=ct,ot.lists_sort={init:function(){this.jsonInit({message0:"%{BKY_LISTS_SORT_TITLE}",args0:[{type:"field_dropdown",name:"TYPE",options:[["%{BKY_LISTS_SORT_TYPE_NUMERIC}","NUMERIC"],["%{BKY_LISTS_SORT_TYPE_TEXT}","TEXT"],["%{BKY_LISTS_SORT_TYPE_IGNORECASE}","IGNORE_CASE"]]},{type:"field_dropdown",name:"DIRECTION",options:[["%{BKY_LISTS_SORT_ORDER_ASCENDING}","1"],["%{BKY_LISTS_SORT_ORDER_DESCENDING}","-1"]]},{type:"input_value",name:"LIST",check:"Array"}],output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_SORT_TOOLTIP}",helpUrl:"%{BKY_LISTS_SORT_HELPURL}"})}},ot.lists_split={init:function(){const c=l.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:[[l.Msg$$module$build$src$core$msg.LISTS_SPLIT_LIST_FROM_TEXT,"SPLIT"],[l.Msg$$module$build$src$core$msg.LISTS_SPLIT_TEXT_FROM_LIST,"JOIN"]]});if(!c)throw Error("field_dropdown not found");c.setValidator(p=>{this.updateType_(p)}),this.setHelpUrl(l.Msg$$module$build$src$core$msg.LISTS_SPLIT_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("INPUT").setCheck("String").appendField(c,"MODE"),this.appendValueInput("DELIM").setCheck("String").appendField(l.Msg$$module$build$src$core$msg.LISTS_SPLIT_WITH_DELIMITER),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.setTooltip(()=>{const p=this.getFieldValue("MODE");if(p==="SPLIT")return l.Msg$$module$build$src$core$msg.LISTS_SPLIT_TOOLTIP_SPLIT;if(p==="JOIN")return l.Msg$$module$build$src$core$msg.LISTS_SPLIT_TOOLTIP_JOIN;throw Error("Unknown mode: "+p)})},updateType_:function(c){if(this.getFieldValue("MODE")!==c){const p=this.getInput("INPUT").connection;p.setShadowDom(null);const I=p.targetBlock();I&&(p.disconnect(),I.isShadow()?I.dispose(!1):this.bumpNeighbours())}c==="SPLIT"?(this.outputConnection.setCheck("Array"),this.getInput("INPUT").setCheck("String")):(this.outputConnection.setCheck("String"),this.getInput("INPUT").setCheck("Array"))},mutationToDom:function(){const c=l.createElement$$module$build$src$core$utils$xml("mutation");return c.setAttribute("mode",this.getFieldValue("MODE")),c},domToMutation:function(c){this.updateType_(c.getAttribute("mode"))},saveExtraState:function(){return{mode:this.getFieldValue("MODE")}},loadExtraState:function(c){this.updateType_(c.mode)}},l.defineBlocks$$module$build$src$core$common(ot);var kt={blocks:ot},st=Object.assign({},ot,Lt,J,Ue,Re,ie,D,g),Ut={blocks:st,lists:kt,logic:to,loops:G,math:he,procedures:St,texts:It,variables:ue,variablesDynamic:A};return Ut.__namespace__=l,Ut})})(xl)),xl.exports}var cv=lv();const uv=xi(cv),{blocks:VI,lists:WI,logic:zI,loops:YI,math:XI,procedures:jI,texts:KI,variables:JI,variablesDynamic:qI}=uv;var Bl={exports:{}},av=Bl.exports,e_;function hv(){return e_||(e_=1,(function(h,a){(function(r,l){h.exports=l(nd())})(av,function(r){var l=r.__namespace__,g=function(u,$){return["[]",E.ATOMIC]},m=function(u,$){const b=Array(u.itemCount_);for(let S=0;S<u.itemCount_;S++)b[S]=$.valueToCode(u,"ADD"+S,E.NONE)||"null";return["["+b.join(", ")+"]",E.ATOMIC]},y=function(u,$){const b=$.provideFunction_("listsRepeat",`
794
794
  function ${$.FUNCTION_NAME_PLACEHOLDER_}(value, n) {
795
795
  var array = [];
796
796
  for (var i = 0; i < n; i++) {
@@ -1007,7 +1007,7 @@ function ${$.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement) {
1007
1007
  `}quote_(u){return u=u.replace(/\\/g,"\\\\").replace(/\n/g,`\\
1008
1008
  `).replace(/'/g,"\\'"),"'"+u+"'"}multiline_quote_(u){return u.split(/\n/g).map(this.quote_).join(` + '\\n' +
1009
1009
  `)}scrub_(u,$,b=!1){let S="";if(!u.outputConnection||!u.outputConnection.targetConnection){var x=u.getCommentText();x&&(x=l.wrap$$module$build$src$core$utils$string(x,this.COMMENT_WRAP-3),S+=this.prefixLines(x+`
1010
- `,"// "));for(let q=0;q<u.inputList.length;q++)u.inputList[q].type===l.inputTypes$$module$build$src$core$inputs$input_types.VALUE&&(x=u.inputList[q].connection.targetBlock())&&(x=this.allNestedComments(x))&&(S+=this.prefixLines(x,"// "))}return u=u.nextConnection&&u.nextConnection.targetBlock(),b=b?"":this.blockToCode(u),S+$+b}getAdjusted(u,$,b=0,S=!1,x=E.NONE){u.workspace.options.oneBasedIndex&&b--;const q=u.workspace.options.oneBasedIndex?"1":"0";let pe=x;return b>0?pe=E.ADDITION:b<0?pe=E.SUBTRACTION:S&&(pe=E.UNARY_NEGATION),u=this.valueToCode(u,$,pe)||q,b===0&&!S?u:l.isNumber$$module$build$src$core$utils$string(u)?(u=String(Number(u)+b),S&&(u=String(-Number(u))),u):(b>0?u=`${u} + ${b}`:b<0&&(u=`${u} - ${-b}`),S&&(u=b?`-(${u})`:`-${u}`),Math.floor(x)>=Math.floor(pe)&&(u=`(${u})`),u)}},Do=function(u,$,b){return $==="FIRST"?"0":$==="FROM_END"?u+".length - 1 - "+b:$==="LAST"?u+".length - 1":b},He={};He.lists_create_empty=g,He.lists_create_with=m,He.lists_getIndex=H,He.lists_getSublist=X,He.lists_indexOf=D,He.lists_isEmpty=A,He.lists_length=k,He.lists_repeat=y,He.lists_reverse=K,He.lists_setIndex=W,He.lists_sort=ue,He.lists_split=ie;var ct={};ct.controls_if=ee,ct.controls_ifelse=ee,ct.logic_boolean=te,ct.logic_compare=me,ct.logic_negate=ae,ct.logic_null=Y,ct.logic_operation=z,ct.logic_ternary=Ie;var kt={};kt.controls_flow_statements=bt,kt.controls_for=Re,kt.controls_forEach=rt,kt.controls_repeat=Ye,kt.controls_repeat_ext=Ye,kt.controls_whileUntil=It;var st={};st.math_arithmetic=Ct,st.math_atan2=ne,st.math_change=$t,st.math_constant=Tt,st.math_constrain=_,st.math_modulo=Ue,st.math_number=Bt,st.math_number_property=lt,st.math_on_list=St,st.math_random_float=Q,st.math_random_int=F,st.math_round=nt,st.math_single=nt,st.math_trig=nt;var Ut={};Ut.procedures_callnoreturn=J,Ut.procedures_callreturn=he,Ut.procedures_defnoreturn=le,Ut.procedures_defreturn=le,Ut.procedures_ifreturn=$e;var c=/^\s*'([^']|\\')*'\s*$/,p=function(u){return c.test(u)?[u,E.ATOMIC]:["String("+u+")",E.FUNCTION_CALL]},I=function(u,$,b){return $==="FIRST"?"0":$==="FROM_END"?u+".length - 1 - "+b:$==="LAST"?u+".length - 1":b},C={};C.text=ce,C.text_append=U,C.text_changeCase=qo,C.text_charAt=Lt,C.text_count=eo,C.text_getSubstring=Te,C.text_indexOf=G,C.text_isEmpty=v,C.text_join=_e,C.text_length=Xe,C.text_print=Qt,C.text_prompt=Mo,C.text_prompt_ext=Mo,C.text_replace=to,C.text_reverse=ot,C.text_trim=ke;var V={};V.variables_get=ms,V.variables_set=ho;var Ae={};Ae.variables_get_dynamic=ms,Ae.variables_set_dynamic=ho;var so=new oo,$o=Object.assign({},He,ct,kt,st,Ut,C,V,Ae);for(const u in $o)so.forBlock[u]=$o[u];var io={};return io.JavascriptGenerator=oo,io.Order=E,io.javascriptGenerator=so,io.__namespace__=l,io})})(Dl)),Dl.exports}var hv=av();const dv=Di(hv),{JavascriptGenerator:qI,Order:ZI,javascriptGenerator:b_}=dv;let Bl=!1;function Gl(){if(!Bl)try{if(typeof id>"u")throw new Error("Blockly core is not available. Make sure Blockly is properly installed and imported.");if(typeof jh=="function")try{jh("en")}catch{}if(typeof b_>"u")throw new Error("Blockly JavaScript generator is not available. Make sure blockly/javascript is imported.");Bl=!0,console.log("Blockly initialized successfully for package usage")}catch(a){throw console.error("Failed to initialize Blockly:",a),a}}function rd(){return Bl&&typeof id<"u"}function Pl(){return rd()||Gl(),id}function xl(){return rd()||Gl(),b_}function $v(){Bl=!1}function pv(a,h){let r;return(...l)=>{clearTimeout(r),r=setTimeout(()=>a(...l),h)}}function gv(a,h){let r;return(...l)=>{r||(a(...l),r=!0,setTimeout(()=>r=!1,h))}}function mv(a=8){const h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let r="";for(let l=0;l<a;l++)r+=h.charAt(Math.floor(Math.random()*h.length));return r}function fv(a){return a.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}function _v(a,h={}){const r=new Date(a),l={year:"numeric",month:"long",day:"numeric",...h};return new Intl.DateTimeFormat("en-US",l).format(r)}function bv(a){const h=new Date,r=new Date(a),l=Math.floor((h.getTime()-r.getTime())/1e3);if(l<60)return"just now";const g=Math.floor(l/60);if(g<60)return`${g} minute${g===1?"":"s"} ago`;const m=Math.floor(g/60);if(m<24)return`${m} hour${m===1?"":"s"} ago`;const y=Math.floor(m/24);if(y<7)return`${y} day${y===1?"":"s"} ago`;const k=Math.floor(y/7);if(k<4)return`${k} week${k===1?"":"s"} ago`;const A=Math.floor(y/30);if(A<12)return`${A} month${A===1?"":"s"} ago`;const D=Math.floor(y/365);return`${D} year${D===1?"":"s"} ago`}function T_(a){return a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()}function Tv(a){return a.toLowerCase().split(" ").map(h=>T_(h)).join(" ")}function Ev(a,h,r="..."){return a.length<=h?a:a.substring(0,h-r.length)+r}function yv(a){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)}function vv(a){try{return new URL(a),!0}catch{return!1}}function Kh(a){if(a===null||typeof a!="object")return a;if(a instanceof Date)return new Date(a.getTime());if(a instanceof Array)return a.map(h=>Kh(h));if(typeof a=="object"){const h={};for(const r in a)Object.prototype.hasOwnProperty.call(a,r)&&(h[r]=Kh(a[r]));return h}return a}function E_(...a){return a.reduce((h,r)=>{for(const l in r)Object.prototype.hasOwnProperty.call(r,l)&&(typeof r[l]=="object"&&r[l]!==null&&!Array.isArray(r[l])?h[l]=E_(h[l]||{},r[l]):h[l]=r[l]);return h},{})}function Iv(a){const h={};for(const r in a)Object.prototype.hasOwnProperty.call(a,r)&&a[r]!==void 0&&a[r]!==null&&(h[r]=a[r]);return h}function Cv(a,h,r){const l=h.split(".");let g=a;for(const m of l)if(g&&typeof g=="object"&&m in g)g=g[m];else return r;return g}function Sv(a,h,r){const l=h.split("."),g={...a};let m=g;for(let y=0;y<l.length-1;y++){const k=l[y];(!(k in m)||typeof m[k]!="object")&&(m[k]={}),m=m[k]}return m[l[l.length-1]]=r,g}function y_(a,h){if(a===h)return!0;if(typeof a!="object"||typeof h!="object"||a===null||h===null)return!1;const r=Object.keys(a),l=Object.keys(h);if(r.length!==l.length)return!1;for(const g of r)if(!l.includes(g)||!y_(a[g],h[g]))return!1;return!0}function v_(a){return new Promise(h=>setTimeout(h,a))}async function kv(a,h=3,r=1e3){let l;for(let g=0;g<=h;g++)try{return await a()}catch(m){if(l=m,g===h)throw l;const y=r*Math.pow(2,g);await v_(y)}throw l}var wl={exports:{}},Ar={};/**
1010
+ `,"// "));for(let q=0;q<u.inputList.length;q++)u.inputList[q].type===l.inputTypes$$module$build$src$core$inputs$input_types.VALUE&&(x=u.inputList[q].connection.targetBlock())&&(x=this.allNestedComments(x))&&(S+=this.prefixLines(x,"// "))}return u=u.nextConnection&&u.nextConnection.targetBlock(),b=b?"":this.blockToCode(u),S+$+b}getAdjusted(u,$,b=0,S=!1,x=E.NONE){u.workspace.options.oneBasedIndex&&b--;const q=u.workspace.options.oneBasedIndex?"1":"0";let pe=x;return b>0?pe=E.ADDITION:b<0?pe=E.SUBTRACTION:S&&(pe=E.UNARY_NEGATION),u=this.valueToCode(u,$,pe)||q,b===0&&!S?u:l.isNumber$$module$build$src$core$utils$string(u)?(u=String(Number(u)+b),S&&(u=String(-Number(u))),u):(b>0?u=`${u} + ${b}`:b<0&&(u=`${u} - ${-b}`),S&&(u=b?`-(${u})`:`-${u}`),Math.floor(x)>=Math.floor(pe)&&(u=`(${u})`),u)}},Do=function(u,$,b){return $==="FIRST"?"0":$==="FROM_END"?u+".length - 1 - "+b:$==="LAST"?u+".length - 1":b},He={};He.lists_create_empty=g,He.lists_create_with=m,He.lists_getIndex=H,He.lists_getSublist=X,He.lists_indexOf=D,He.lists_isEmpty=A,He.lists_length=k,He.lists_repeat=y,He.lists_reverse=K,He.lists_setIndex=W,He.lists_sort=ue,He.lists_split=ie;var ct={};ct.controls_if=ee,ct.controls_ifelse=ee,ct.logic_boolean=te,ct.logic_compare=me,ct.logic_negate=ae,ct.logic_null=Y,ct.logic_operation=z,ct.logic_ternary=Ie;var kt={};kt.controls_flow_statements=bt,kt.controls_for=Re,kt.controls_forEach=rt,kt.controls_repeat=Ye,kt.controls_repeat_ext=Ye,kt.controls_whileUntil=It;var st={};st.math_arithmetic=Ct,st.math_atan2=ne,st.math_change=$t,st.math_constant=Tt,st.math_constrain=_,st.math_modulo=Ue,st.math_number=Bt,st.math_number_property=lt,st.math_on_list=St,st.math_random_float=Q,st.math_random_int=F,st.math_round=nt,st.math_single=nt,st.math_trig=nt;var Ut={};Ut.procedures_callnoreturn=J,Ut.procedures_callreturn=he,Ut.procedures_defnoreturn=le,Ut.procedures_defreturn=le,Ut.procedures_ifreturn=$e;var c=/^\s*'([^']|\\')*'\s*$/,p=function(u){return c.test(u)?[u,E.ATOMIC]:["String("+u+")",E.FUNCTION_CALL]},I=function(u,$,b){return $==="FIRST"?"0":$==="FROM_END"?u+".length - 1 - "+b:$==="LAST"?u+".length - 1":b},C={};C.text=ce,C.text_append=U,C.text_changeCase=qo,C.text_charAt=Lt,C.text_count=eo,C.text_getSubstring=Te,C.text_indexOf=G,C.text_isEmpty=v,C.text_join=_e,C.text_length=Xe,C.text_print=Qt,C.text_prompt=Mo,C.text_prompt_ext=Mo,C.text_replace=to,C.text_reverse=ot,C.text_trim=ke;var V={};V.variables_get=ms,V.variables_set=ho;var Ae={};Ae.variables_get_dynamic=ms,Ae.variables_set_dynamic=ho;var so=new oo,$o=Object.assign({},He,ct,kt,st,Ut,C,V,Ae);for(const u in $o)so.forBlock[u]=$o[u];var io={};return io.JavascriptGenerator=oo,io.Order=E,io.javascriptGenerator=so,io.__namespace__=l,io})})(Bl)),Bl.exports}var dv=hv();const $v=xi(dv),{JavascriptGenerator:ZI,Order:QI,javascriptGenerator:y_}=$v;let Fl=!1,Mi=null;function Wl(){return Fl?(console.log("[Blockly Setup] Already initialized, returning resolved promise"),Promise.resolve()):Mi?(console.log("[Blockly Setup] Initialization already in progress, returning existing promise"),Mi):(console.log("[Blockly Setup] Starting Blockly initialization..."),Mi=new Promise((h,a)=>{try{if(console.log("[Blockly Setup] Checking Blockly core availability..."),typeof ld>"u"){const r=new Error("Blockly core is not available. Make sure Blockly is properly installed and imported.");console.error("[Blockly Setup] Error:",r.message),a(r);return}if(console.log("[Blockly Setup] Blockly core is available"),console.log("[Blockly Setup] Setting up locale..."),typeof qh=="function")try{qh("en"),console.log("[Blockly Setup] Locale set to English")}catch(r){console.warn("[Blockly Setup] Locale setup failed, using default:",r)}if(console.log("[Blockly Setup] Initializing main workspace access..."),typeof Jh=="function")try{Jh(),console.log("[Blockly Setup] Main workspace access initialized")}catch(r){console.log("[Blockly Setup] Main workspace access failed (expected if no workspace exists):",r)}if(console.log("[Blockly Setup] Initializing event system..."),typeof Dl=="object"&&Dl.getGroup)try{Dl.getGroup(),console.log("[Blockly Setup] Event system initialized")}catch(r){console.log("[Blockly Setup] Event system initialization failed (may already be initialized):",r)}if(console.log("[Blockly Setup] Checking JavaScript generator..."),typeof y_>"u"){const r=new Error("Blockly JavaScript generator is not available. Make sure blockly/javascript is imported.");console.error("[Blockly Setup] Error:",r.message),a(r);return}console.log("[Blockly Setup] JavaScript generator is available"),Fl=!0,console.log("[Blockly Setup] ✅ Blockly initialized successfully for package usage"),h()}catch(r){console.error("[Blockly Setup] ❌ Failed to initialize Blockly:",r),Mi=null,a(r)}}),Mi)}function cd(){return Fl&&typeof ld<"u"}function Ul(){return cd()||Wl(),ld}function Pl(){return cd()||Wl(),y_}function pv(){console.log("[Blockly Setup] Resetting initialization state"),Fl=!1,Mi=null}function gv(h,a){let r;return(...l)=>{clearTimeout(r),r=setTimeout(()=>h(...l),a)}}function mv(h,a){let r;return(...l)=>{r||(h(...l),r=!0,setTimeout(()=>r=!1,a))}}function fv(h=8){const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let r="";for(let l=0;l<h;l++)r+=a.charAt(Math.floor(Math.random()*a.length));return r}function _v(h){return h.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}function bv(h,a={}){const r=new Date(h),l={year:"numeric",month:"long",day:"numeric",...a};return new Intl.DateTimeFormat("en-US",l).format(r)}function Tv(h){const a=new Date,r=new Date(h),l=Math.floor((a.getTime()-r.getTime())/1e3);if(l<60)return"just now";const g=Math.floor(l/60);if(g<60)return`${g} minute${g===1?"":"s"} ago`;const m=Math.floor(g/60);if(m<24)return`${m} hour${m===1?"":"s"} ago`;const y=Math.floor(m/24);if(y<7)return`${y} day${y===1?"":"s"} ago`;const k=Math.floor(y/7);if(k<4)return`${k} week${k===1?"":"s"} ago`;const A=Math.floor(y/30);if(A<12)return`${A} month${A===1?"":"s"} ago`;const D=Math.floor(y/365);return`${D} year${D===1?"":"s"} ago`}function v_(h){return h.charAt(0).toUpperCase()+h.slice(1).toLowerCase()}function Ev(h){return h.toLowerCase().split(" ").map(a=>v_(a)).join(" ")}function yv(h,a,r="..."){return h.length<=a?h:h.substring(0,a-r.length)+r}function vv(h){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h)}function Iv(h){try{return new URL(h),!0}catch{return!1}}function Zh(h){if(h===null||typeof h!="object")return h;if(h instanceof Date)return new Date(h.getTime());if(h instanceof Array)return h.map(a=>Zh(a));if(typeof h=="object"){const a={};for(const r in h)Object.prototype.hasOwnProperty.call(h,r)&&(a[r]=Zh(h[r]));return a}return h}function I_(...h){return h.reduce((a,r)=>{for(const l in r)Object.prototype.hasOwnProperty.call(r,l)&&(typeof r[l]=="object"&&r[l]!==null&&!Array.isArray(r[l])?a[l]=I_(a[l]||{},r[l]):a[l]=r[l]);return a},{})}function Cv(h){const a={};for(const r in h)Object.prototype.hasOwnProperty.call(h,r)&&h[r]!==void 0&&h[r]!==null&&(a[r]=h[r]);return a}function Sv(h,a,r){const l=a.split(".");let g=h;for(const m of l)if(g&&typeof g=="object"&&m in g)g=g[m];else return r;return g}function kv(h,a,r){const l=a.split("."),g={...h};let m=g;for(let y=0;y<l.length-1;y++){const k=l[y];(!(k in m)||typeof m[k]!="object")&&(m[k]={}),m=m[k]}return m[l[l.length-1]]=r,g}function C_(h,a){if(h===a)return!0;if(typeof h!="object"||typeof a!="object"||h===null||a===null)return!1;const r=Object.keys(h),l=Object.keys(a);if(r.length!==l.length)return!1;for(const g of r)if(!l.includes(g)||!C_(h[g],a[g]))return!1;return!0}function S_(h){return new Promise(a=>setTimeout(a,h))}async function Rv(h,a=3,r=1e3){let l;for(let g=0;g<=a;g++)try{return await h()}catch(m){if(l=m,g===a)throw l;const y=r*Math.pow(2,g);await S_(y)}throw l}var Ol={exports:{}},Lr={};/**
1011
1011
  * @license React
1012
1012
  * react-jsx-runtime.production.js
1013
1013
  *
@@ -1015,7 +1015,7 @@ function ${$.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement) {
1015
1015
  *
1016
1016
  * This source code is licensed under the MIT license found in the
1017
1017
  * LICENSE file in the root directory of this source tree.
1018
- */var Zf;function Rv(){if(Zf)return Ar;Zf=1;var a=Symbol.for("react.transitional.element"),h=Symbol.for("react.fragment");function r(l,g,m){var y=null;if(m!==void 0&&(y=""+m),g.key!==void 0&&(y=""+g.key),"key"in g){m={};for(var k in g)k!=="key"&&(m[k]=g[k])}else m=g;return g=m.ref,{$$typeof:a,type:l,key:y,ref:g!==void 0?g:null,props:m}}return Ar.Fragment=h,Ar.jsx=r,Ar.jsxs=r,Ar}var Lr={};/**
1018
+ */var t_;function wv(){if(t_)return Lr;t_=1;var h=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function r(l,g,m){var y=null;if(m!==void 0&&(y=""+m),g.key!==void 0&&(y=""+g.key),"key"in g){m={};for(var k in g)k!=="key"&&(m[k]=g[k])}else m=g;return g=m.ref,{$$typeof:h,type:l,key:y,ref:g!==void 0?g:null,props:m}}return Lr.Fragment=a,Lr.jsx=r,Lr.jsxs=r,Lr}var Mr={};/**
1019
1019
  * @license React
1020
1020
  * react-jsx-runtime.development.js
1021
1021
  *
@@ -1023,44 +1023,44 @@ function ${$.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement) {
1023
1023
  *
1024
1024
  * This source code is licensed under the MIT license found in the
1025
1025
  * LICENSE file in the root directory of this source tree.
1026
- */var Qf;function wv(){return Qf||(Qf=1,process.env.NODE_ENV!=="production"&&(function(){function a(_){if(_==null)return null;if(typeof _=="function")return _.$$typeof===rt?null:_.displayName||_.name||null;if(typeof _=="string")return _;switch(_){case K:return"Fragment";case me:return"Profiler";case ee:return"StrictMode";case Y:return"Suspense";case Ie:return"SuspenseList";case Re:return"Activity"}if(typeof _=="object")switch(typeof _.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),_.$$typeof){case ie:return"Portal";case ae:return(_.displayName||"Context")+".Provider";case z:return(_._context.displayName||"Context")+".Consumer";case te:var F=_.render;return _=_.displayName,_||(_=F.displayName||F.name||"",_=_!==""?"ForwardRef("+_+")":"ForwardRef"),_;case Ye:return F=_.displayName||null,F!==null?F:a(_.type)||"Memo";case It:F=_._payload,_=_._init;try{return a(_(F))}catch{}}return null}function h(_){return""+_}function r(_){try{h(_);var F=!1}catch{F=!0}if(F){F=console;var Q=F.error,ne=typeof Symbol=="function"&&Symbol.toStringTag&&_[Symbol.toStringTag]||_.constructor.name||"Object";return Q.call(F,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",ne),h(_)}}function l(_){if(_===K)return"<>";if(typeof _=="object"&&_!==null&&_.$$typeof===It)return"<...>";try{var F=a(_);return F?"<"+F+">":"<...>"}catch{return"<...>"}}function g(){var _=bt.A;return _===null?null:_.getOwner()}function m(){return Error("react-stack-top-frame")}function y(_){if(Bt.call(_,"key")){var F=Object.getOwnPropertyDescriptor(_,"key").get;if(F&&F.isReactWarning)return!1}return _.key!==void 0}function k(_,F){function Q(){Tt||(Tt=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",F))}Q.isReactWarning=!0,Object.defineProperty(_,"key",{get:Q,configurable:!0})}function A(){var _=a(this.type);return lt[_]||(lt[_]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),_=this.props.ref,_!==void 0?_:null}function D(_,F,Q,ne,le,he,J,$e){return Q=he.ref,_={$$typeof:ue,type:_,key:F,props:he,_owner:le},(Q!==void 0?Q:null)!==null?Object.defineProperty(_,"ref",{enumerable:!1,get:A}):Object.defineProperty(_,"ref",{enumerable:!1,value:null}),_._store={},Object.defineProperty(_._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(_,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(_,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.defineProperty(_,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:$e}),Object.freeze&&(Object.freeze(_.props),Object.freeze(_)),_}function H(_,F,Q,ne,le,he,J,$e){var ce=F.children;if(ce!==void 0)if(ne)if(Ct(ce)){for(ne=0;ne<ce.length;ne++)W(ce[ne]);Object.freeze&&Object.freeze(ce)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else W(ce);if(Bt.call(F,"key")){ce=a(_);var _e=Object.keys(F).filter(function(Xe){return Xe!=="key"});ne=0<_e.length?"{key: someKey, "+_e.join(": ..., ")+": ...}":"{key: someKey}",Ue[ce+ne]||(_e=0<_e.length?"{"+_e.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1026
+ */var o_;function Ov(){return o_||(o_=1,process.env.NODE_ENV!=="production"&&(function(){function h(_){if(_==null)return null;if(typeof _=="function")return _.$$typeof===rt?null:_.displayName||_.name||null;if(typeof _=="string")return _;switch(_){case K:return"Fragment";case me:return"Profiler";case ee:return"StrictMode";case Y:return"Suspense";case Ie:return"SuspenseList";case Re:return"Activity"}if(typeof _=="object")switch(typeof _.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),_.$$typeof){case ie:return"Portal";case ae:return(_.displayName||"Context")+".Provider";case z:return(_._context.displayName||"Context")+".Consumer";case te:var F=_.render;return _=_.displayName,_||(_=F.displayName||F.name||"",_=_!==""?"ForwardRef("+_+")":"ForwardRef"),_;case Ye:return F=_.displayName||null,F!==null?F:h(_.type)||"Memo";case It:F=_._payload,_=_._init;try{return h(_(F))}catch{}}return null}function a(_){return""+_}function r(_){try{a(_);var F=!1}catch{F=!0}if(F){F=console;var Q=F.error,ne=typeof Symbol=="function"&&Symbol.toStringTag&&_[Symbol.toStringTag]||_.constructor.name||"Object";return Q.call(F,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",ne),a(_)}}function l(_){if(_===K)return"<>";if(typeof _=="object"&&_!==null&&_.$$typeof===It)return"<...>";try{var F=h(_);return F?"<"+F+">":"<...>"}catch{return"<...>"}}function g(){var _=bt.A;return _===null?null:_.getOwner()}function m(){return Error("react-stack-top-frame")}function y(_){if(Bt.call(_,"key")){var F=Object.getOwnPropertyDescriptor(_,"key").get;if(F&&F.isReactWarning)return!1}return _.key!==void 0}function k(_,F){function Q(){Tt||(Tt=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",F))}Q.isReactWarning=!0,Object.defineProperty(_,"key",{get:Q,configurable:!0})}function A(){var _=h(this.type);return lt[_]||(lt[_]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),_=this.props.ref,_!==void 0?_:null}function D(_,F,Q,ne,le,he,J,$e){return Q=he.ref,_={$$typeof:ue,type:_,key:F,props:he,_owner:le},(Q!==void 0?Q:null)!==null?Object.defineProperty(_,"ref",{enumerable:!1,get:A}):Object.defineProperty(_,"ref",{enumerable:!1,value:null}),_._store={},Object.defineProperty(_._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(_,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(_,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.defineProperty(_,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:$e}),Object.freeze&&(Object.freeze(_.props),Object.freeze(_)),_}function H(_,F,Q,ne,le,he,J,$e){var ce=F.children;if(ce!==void 0)if(ne)if(Ct(ce)){for(ne=0;ne<ce.length;ne++)W(ce[ne]);Object.freeze&&Object.freeze(ce)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else W(ce);if(Bt.call(F,"key")){ce=h(_);var _e=Object.keys(F).filter(function(Xe){return Xe!=="key"});ne=0<_e.length?"{key: someKey, "+_e.join(": ..., ")+": ...}":"{key: someKey}",Ue[ce+ne]||(_e=0<_e.length?"{"+_e.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1027
1027
  let props = %s;
1028
1028
  <%s {...props} />
1029
1029
  React keys must be passed directly to JSX without using spread:
1030
1030
  let props = %s;
1031
- <%s key={someKey} {...props} />`,ne,ce,_e,ce),Ue[ce+ne]=!0)}if(ce=null,Q!==void 0&&(r(Q),ce=""+Q),y(F)&&(r(F.key),ce=""+F.key),"key"in F){Q={};for(var U in F)U!=="key"&&(Q[U]=F[U])}else Q=F;return ce&&k(Q,typeof _=="function"?_.displayName||_.name||"Unknown":_),D(_,ce,he,le,g(),Q,J,$e)}function W(_){typeof _=="object"&&_!==null&&_.$$typeof===ue&&_._store&&(_._store.validated=1)}var X=de,ue=Symbol.for("react.transitional.element"),ie=Symbol.for("react.portal"),K=Symbol.for("react.fragment"),ee=Symbol.for("react.strict_mode"),me=Symbol.for("react.profiler"),z=Symbol.for("react.consumer"),ae=Symbol.for("react.context"),te=Symbol.for("react.forward_ref"),Y=Symbol.for("react.suspense"),Ie=Symbol.for("react.suspense_list"),Ye=Symbol.for("react.memo"),It=Symbol.for("react.lazy"),Re=Symbol.for("react.activity"),rt=Symbol.for("react.client.reference"),bt=X.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Bt=Object.prototype.hasOwnProperty,Ct=Array.isArray,nt=console.createTask?console.createTask:function(){return null};X={react_stack_bottom_frame:function(_){return _()}};var Tt,lt={},$t=X.react_stack_bottom_frame.bind(X,m)(),St=nt(l(m)),Ue={};Lr.Fragment=K,Lr.jsx=function(_,F,Q,ne,le){var he=1e4>bt.recentlyCreatedOwnerStacks++;return H(_,F,Q,!1,ne,le,he?Error("react-stack-top-frame"):$t,he?nt(l(_)):St)},Lr.jsxs=function(_,F,Q,ne,le){var he=1e4>bt.recentlyCreatedOwnerStacks++;return H(_,F,Q,!0,ne,le,he?Error("react-stack-top-frame"):$t,he?nt(l(_)):St)}})()),Lr}var e_;function Ov(){return e_||(e_=1,process.env.NODE_ENV==="production"?wl.exports=Rv():wl.exports=wv()),wl.exports}var B=Ov(),Fh={exports:{}};/*!
1031
+ <%s key={someKey} {...props} />`,ne,ce,_e,ce),Ue[ce+ne]=!0)}if(ce=null,Q!==void 0&&(r(Q),ce=""+Q),y(F)&&(r(F.key),ce=""+F.key),"key"in F){Q={};for(var U in F)U!=="key"&&(Q[U]=F[U])}else Q=F;return ce&&k(Q,typeof _=="function"?_.displayName||_.name||"Unknown":_),D(_,ce,he,le,g(),Q,J,$e)}function W(_){typeof _=="object"&&_!==null&&_.$$typeof===ue&&_._store&&(_._store.validated=1)}var X=de,ue=Symbol.for("react.transitional.element"),ie=Symbol.for("react.portal"),K=Symbol.for("react.fragment"),ee=Symbol.for("react.strict_mode"),me=Symbol.for("react.profiler"),z=Symbol.for("react.consumer"),ae=Symbol.for("react.context"),te=Symbol.for("react.forward_ref"),Y=Symbol.for("react.suspense"),Ie=Symbol.for("react.suspense_list"),Ye=Symbol.for("react.memo"),It=Symbol.for("react.lazy"),Re=Symbol.for("react.activity"),rt=Symbol.for("react.client.reference"),bt=X.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Bt=Object.prototype.hasOwnProperty,Ct=Array.isArray,nt=console.createTask?console.createTask:function(){return null};X={react_stack_bottom_frame:function(_){return _()}};var Tt,lt={},$t=X.react_stack_bottom_frame.bind(X,m)(),St=nt(l(m)),Ue={};Mr.Fragment=K,Mr.jsx=function(_,F,Q,ne,le){var he=1e4>bt.recentlyCreatedOwnerStacks++;return H(_,F,Q,!1,ne,le,he?Error("react-stack-top-frame"):$t,he?nt(l(_)):St)},Mr.jsxs=function(_,F,Q,ne,le){var he=1e4>bt.recentlyCreatedOwnerStacks++;return H(_,F,Q,!0,ne,le,he?Error("react-stack-top-frame"):$t,he?nt(l(_)):St)}})()),Mr}var s_;function Nv(){return s_||(s_=1,process.env.NODE_ENV==="production"?Ol.exports=wv():Ol.exports=Ov()),Ol.exports}var B=Nv(),Hh={exports:{}};/*!
1032
1032
  Copyright (c) 2018 Jed Watson.
1033
1033
  Licensed under the MIT License (MIT), see
1034
1034
  http://jedwatson.github.io/classnames
1035
- */var t_;function Nv(){return t_||(t_=1,(function(a){(function(){var h={}.hasOwnProperty;function r(){for(var m="",y=0;y<arguments.length;y++){var k=arguments[y];k&&(m=g(m,l(k)))}return m}function l(m){if(typeof m=="string"||typeof m=="number")return m;if(typeof m!="object")return"";if(Array.isArray(m))return r.apply(null,m);if(m.toString!==Object.prototype.toString&&!m.toString.toString().includes("[native code]"))return m.toString();var y="";for(var k in m)h.call(m,k)&&m[k]&&(y=g(y,k));return y}function g(m,y){return y?m?m+" "+y:m+y:m}a.exports?(r.default=r,a.exports=r):window.classNames=r})()})(Fh)),Fh.exports}var Av=Nv();const Se=Di(Av);function Jh(){return Jh=Object.assign?Object.assign.bind():function(a){for(var h=1;h<arguments.length;h++){var r=arguments[h];for(var l in r)({}).hasOwnProperty.call(r,l)&&(a[l]=r[l])}return a},Jh.apply(null,arguments)}function I_(a,h){if(a==null)return{};var r={};for(var l in a)if({}.hasOwnProperty.call(a,l)){if(h.indexOf(l)!==-1)continue;r[l]=a[l]}return r}function o_(a){return"default"+a.charAt(0).toUpperCase()+a.substr(1)}function Lv(a){var h=Mv(a,"string");return typeof h=="symbol"?h:String(h)}function Mv(a,h){if(typeof a!="object"||a===null)return a;var r=a[Symbol.toPrimitive];if(r!==void 0){var l=r.call(a,h);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(a)}function Dv(a,h,r){var l=de.useRef(a!==void 0),g=de.useState(h),m=g[0],y=g[1],k=a!==void 0,A=l.current;return l.current=k,!k&&A&&m!==h&&y(h),[k?a:m,de.useCallback(function(D){for(var H=arguments.length,W=new Array(H>1?H-1:0),X=1;X<H;X++)W[X-1]=arguments[X];r&&r.apply(void 0,[D].concat(W)),y(D)},[r])]}function xv(a,h){return Object.keys(h).reduce(function(r,l){var g,m=r,y=m[o_(l)],k=m[l],A=I_(m,[o_(l),l].map(Lv)),D=h[l],H=Dv(k,y,a[D]),W=H[0],X=H[1];return Jh({},A,(g={},g[l]=W,g[D]=X,g))},a)}function qh(a,h){return qh=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,l){return r.__proto__=l,r},qh(a,h)}function Bv(a,h){a.prototype=Object.create(h.prototype),a.prototype.constructor=a,qh(a,h)}const Pv=["xxl","xl","lg","md","sm","xs"],Fv="xs",Vl=fe.createContext({prefixes:{},breakpoints:Pv,minBreakpoint:Fv}),{Consumer:QI,Provider:eC}=Vl;function xe(a,h){const{prefixes:r}=de.useContext(Vl);return a||r[h]||h}function C_(){const{breakpoints:a}=de.useContext(Vl);return a}function S_(){const{minBreakpoint:a}=de.useContext(Vl);return a}function Uv(a){return a&&a.ownerDocument||document}function Hv(a){var h=Uv(a);return h&&h.defaultView||window}function Gv(a,h){return Hv(a).getComputedStyle(a,h)}var Vv=/([A-Z])/g;function Wv(a){return a.replace(Vv,"-$1").toLowerCase()}var zv=/^ms-/;function Ol(a){return Wv(a).replace(zv,"-ms-")}var Yv=/^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i;function Xv(a){return!!(a&&Yv.test(a))}function k_(a,h){var r="",l="";if(typeof h=="string")return a.style.getPropertyValue(Ol(h))||Gv(a).getPropertyValue(Ol(h));Object.keys(h).forEach(function(g){var m=h[g];!m&&m!==0?a.style.removeProperty(Ol(g)):Xv(g)?l+=g+"("+m+") ":r+=Ol(g)+": "+m+";"}),l&&(r+="transform: "+l+";"),a.style.cssText+=";"+r}var Nl={exports:{}},Al={exports:{}},Me={};/** @license React v16.13.1
1035
+ */var i_;function Av(){return i_||(i_=1,(function(h){(function(){var a={}.hasOwnProperty;function r(){for(var m="",y=0;y<arguments.length;y++){var k=arguments[y];k&&(m=g(m,l(k)))}return m}function l(m){if(typeof m=="string"||typeof m=="number")return m;if(typeof m!="object")return"";if(Array.isArray(m))return r.apply(null,m);if(m.toString!==Object.prototype.toString&&!m.toString.toString().includes("[native code]"))return m.toString();var y="";for(var k in m)a.call(m,k)&&m[k]&&(y=g(y,k));return y}function g(m,y){return y?m?m+" "+y:m+y:m}h.exports?(r.default=r,h.exports=r):window.classNames=r})()})(Hh)),Hh.exports}var Lv=Av();const Se=xi(Lv);function Qh(){return Qh=Object.assign?Object.assign.bind():function(h){for(var a=1;a<arguments.length;a++){var r=arguments[a];for(var l in r)({}).hasOwnProperty.call(r,l)&&(h[l]=r[l])}return h},Qh.apply(null,arguments)}function k_(h,a){if(h==null)return{};var r={};for(var l in h)if({}.hasOwnProperty.call(h,l)){if(a.indexOf(l)!==-1)continue;r[l]=h[l]}return r}function r_(h){return"default"+h.charAt(0).toUpperCase()+h.substr(1)}function Mv(h){var a=Dv(h,"string");return typeof a=="symbol"?a:String(a)}function Dv(h,a){if(typeof h!="object"||h===null)return h;var r=h[Symbol.toPrimitive];if(r!==void 0){var l=r.call(h,a);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(h)}function xv(h,a,r){var l=de.useRef(h!==void 0),g=de.useState(a),m=g[0],y=g[1],k=h!==void 0,A=l.current;return l.current=k,!k&&A&&m!==a&&y(a),[k?h:m,de.useCallback(function(D){for(var H=arguments.length,W=new Array(H>1?H-1:0),X=1;X<H;X++)W[X-1]=arguments[X];r&&r.apply(void 0,[D].concat(W)),y(D)},[r])]}function Bv(h,a){return Object.keys(a).reduce(function(r,l){var g,m=r,y=m[r_(l)],k=m[l],A=k_(m,[r_(l),l].map(Mv)),D=a[l],H=xv(k,y,h[D]),W=H[0],X=H[1];return Qh({},A,(g={},g[l]=W,g[D]=X,g))},h)}function ed(h,a){return ed=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,l){return r.__proto__=l,r},ed(h,a)}function Pv(h,a){h.prototype=Object.create(a.prototype),h.prototype.constructor=h,ed(h,a)}const Fv=["xxl","xl","lg","md","sm","xs"],Uv="xs",zl=fe.createContext({prefixes:{},breakpoints:Fv,minBreakpoint:Uv}),{Consumer:eC,Provider:tC}=zl;function xe(h,a){const{prefixes:r}=de.useContext(zl);return h||r[a]||a}function R_(){const{breakpoints:h}=de.useContext(zl);return h}function w_(){const{minBreakpoint:h}=de.useContext(zl);return h}function Hv(h){return h&&h.ownerDocument||document}function Gv(h){var a=Hv(h);return a&&a.defaultView||window}function Vv(h,a){return Gv(h).getComputedStyle(h,a)}var Wv=/([A-Z])/g;function zv(h){return h.replace(Wv,"-$1").toLowerCase()}var Yv=/^ms-/;function Nl(h){return zv(h).replace(Yv,"-ms-")}var Xv=/^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i;function jv(h){return!!(h&&Xv.test(h))}function O_(h,a){var r="",l="";if(typeof a=="string")return h.style.getPropertyValue(Nl(a))||Vv(h).getPropertyValue(Nl(a));Object.keys(a).forEach(function(g){var m=a[g];!m&&m!==0?h.style.removeProperty(Nl(g)):jv(g)?l+=g+"("+m+") ":r+=Nl(g)+": "+m+";"}),l&&(r+="transform: "+l+";"),h.style.cssText+=";"+r}var Al={exports:{}},Ll={exports:{}},Me={};/** @license React v16.13.1
1036
1036
  * react-is.production.min.js
1037
1037
  *
1038
1038
  * Copyright (c) Facebook, Inc. and its affiliates.
1039
1039
  *
1040
1040
  * This source code is licensed under the MIT license found in the
1041
1041
  * LICENSE file in the root directory of this source tree.
1042
- */var s_;function jv(){if(s_)return Me;s_=1;var a=typeof Symbol=="function"&&Symbol.for,h=a?Symbol.for("react.element"):60103,r=a?Symbol.for("react.portal"):60106,l=a?Symbol.for("react.fragment"):60107,g=a?Symbol.for("react.strict_mode"):60108,m=a?Symbol.for("react.profiler"):60114,y=a?Symbol.for("react.provider"):60109,k=a?Symbol.for("react.context"):60110,A=a?Symbol.for("react.async_mode"):60111,D=a?Symbol.for("react.concurrent_mode"):60111,H=a?Symbol.for("react.forward_ref"):60112,W=a?Symbol.for("react.suspense"):60113,X=a?Symbol.for("react.suspense_list"):60120,ue=a?Symbol.for("react.memo"):60115,ie=a?Symbol.for("react.lazy"):60116,K=a?Symbol.for("react.block"):60121,ee=a?Symbol.for("react.fundamental"):60117,me=a?Symbol.for("react.responder"):60118,z=a?Symbol.for("react.scope"):60119;function ae(Y){if(typeof Y=="object"&&Y!==null){var Ie=Y.$$typeof;switch(Ie){case h:switch(Y=Y.type,Y){case A:case D:case l:case m:case g:case W:return Y;default:switch(Y=Y&&Y.$$typeof,Y){case k:case H:case ie:case ue:case y:return Y;default:return Ie}}case r:return Ie}}}function te(Y){return ae(Y)===D}return Me.AsyncMode=A,Me.ConcurrentMode=D,Me.ContextConsumer=k,Me.ContextProvider=y,Me.Element=h,Me.ForwardRef=H,Me.Fragment=l,Me.Lazy=ie,Me.Memo=ue,Me.Portal=r,Me.Profiler=m,Me.StrictMode=g,Me.Suspense=W,Me.isAsyncMode=function(Y){return te(Y)||ae(Y)===A},Me.isConcurrentMode=te,Me.isContextConsumer=function(Y){return ae(Y)===k},Me.isContextProvider=function(Y){return ae(Y)===y},Me.isElement=function(Y){return typeof Y=="object"&&Y!==null&&Y.$$typeof===h},Me.isForwardRef=function(Y){return ae(Y)===H},Me.isFragment=function(Y){return ae(Y)===l},Me.isLazy=function(Y){return ae(Y)===ie},Me.isMemo=function(Y){return ae(Y)===ue},Me.isPortal=function(Y){return ae(Y)===r},Me.isProfiler=function(Y){return ae(Y)===m},Me.isStrictMode=function(Y){return ae(Y)===g},Me.isSuspense=function(Y){return ae(Y)===W},Me.isValidElementType=function(Y){return typeof Y=="string"||typeof Y=="function"||Y===l||Y===D||Y===m||Y===g||Y===W||Y===X||typeof Y=="object"&&Y!==null&&(Y.$$typeof===ie||Y.$$typeof===ue||Y.$$typeof===y||Y.$$typeof===k||Y.$$typeof===H||Y.$$typeof===ee||Y.$$typeof===me||Y.$$typeof===z||Y.$$typeof===K)},Me.typeOf=ae,Me}var De={};/** @license React v16.13.1
1042
+ */var n_;function Kv(){if(n_)return Me;n_=1;var h=typeof Symbol=="function"&&Symbol.for,a=h?Symbol.for("react.element"):60103,r=h?Symbol.for("react.portal"):60106,l=h?Symbol.for("react.fragment"):60107,g=h?Symbol.for("react.strict_mode"):60108,m=h?Symbol.for("react.profiler"):60114,y=h?Symbol.for("react.provider"):60109,k=h?Symbol.for("react.context"):60110,A=h?Symbol.for("react.async_mode"):60111,D=h?Symbol.for("react.concurrent_mode"):60111,H=h?Symbol.for("react.forward_ref"):60112,W=h?Symbol.for("react.suspense"):60113,X=h?Symbol.for("react.suspense_list"):60120,ue=h?Symbol.for("react.memo"):60115,ie=h?Symbol.for("react.lazy"):60116,K=h?Symbol.for("react.block"):60121,ee=h?Symbol.for("react.fundamental"):60117,me=h?Symbol.for("react.responder"):60118,z=h?Symbol.for("react.scope"):60119;function ae(Y){if(typeof Y=="object"&&Y!==null){var Ie=Y.$$typeof;switch(Ie){case a:switch(Y=Y.type,Y){case A:case D:case l:case m:case g:case W:return Y;default:switch(Y=Y&&Y.$$typeof,Y){case k:case H:case ie:case ue:case y:return Y;default:return Ie}}case r:return Ie}}}function te(Y){return ae(Y)===D}return Me.AsyncMode=A,Me.ConcurrentMode=D,Me.ContextConsumer=k,Me.ContextProvider=y,Me.Element=a,Me.ForwardRef=H,Me.Fragment=l,Me.Lazy=ie,Me.Memo=ue,Me.Portal=r,Me.Profiler=m,Me.StrictMode=g,Me.Suspense=W,Me.isAsyncMode=function(Y){return te(Y)||ae(Y)===A},Me.isConcurrentMode=te,Me.isContextConsumer=function(Y){return ae(Y)===k},Me.isContextProvider=function(Y){return ae(Y)===y},Me.isElement=function(Y){return typeof Y=="object"&&Y!==null&&Y.$$typeof===a},Me.isForwardRef=function(Y){return ae(Y)===H},Me.isFragment=function(Y){return ae(Y)===l},Me.isLazy=function(Y){return ae(Y)===ie},Me.isMemo=function(Y){return ae(Y)===ue},Me.isPortal=function(Y){return ae(Y)===r},Me.isProfiler=function(Y){return ae(Y)===m},Me.isStrictMode=function(Y){return ae(Y)===g},Me.isSuspense=function(Y){return ae(Y)===W},Me.isValidElementType=function(Y){return typeof Y=="string"||typeof Y=="function"||Y===l||Y===D||Y===m||Y===g||Y===W||Y===X||typeof Y=="object"&&Y!==null&&(Y.$$typeof===ie||Y.$$typeof===ue||Y.$$typeof===y||Y.$$typeof===k||Y.$$typeof===H||Y.$$typeof===ee||Y.$$typeof===me||Y.$$typeof===z||Y.$$typeof===K)},Me.typeOf=ae,Me}var De={};/** @license React v16.13.1
1043
1043
  * react-is.development.js
1044
1044
  *
1045
1045
  * Copyright (c) Facebook, Inc. and its affiliates.
1046
1046
  *
1047
1047
  * This source code is licensed under the MIT license found in the
1048
1048
  * LICENSE file in the root directory of this source tree.
1049
- */var i_;function Kv(){return i_||(i_=1,process.env.NODE_ENV!=="production"&&(function(){var a=typeof Symbol=="function"&&Symbol.for,h=a?Symbol.for("react.element"):60103,r=a?Symbol.for("react.portal"):60106,l=a?Symbol.for("react.fragment"):60107,g=a?Symbol.for("react.strict_mode"):60108,m=a?Symbol.for("react.profiler"):60114,y=a?Symbol.for("react.provider"):60109,k=a?Symbol.for("react.context"):60110,A=a?Symbol.for("react.async_mode"):60111,D=a?Symbol.for("react.concurrent_mode"):60111,H=a?Symbol.for("react.forward_ref"):60112,W=a?Symbol.for("react.suspense"):60113,X=a?Symbol.for("react.suspense_list"):60120,ue=a?Symbol.for("react.memo"):60115,ie=a?Symbol.for("react.lazy"):60116,K=a?Symbol.for("react.block"):60121,ee=a?Symbol.for("react.fundamental"):60117,me=a?Symbol.for("react.responder"):60118,z=a?Symbol.for("react.scope"):60119;function ae(v){return typeof v=="string"||typeof v=="function"||v===l||v===D||v===m||v===g||v===W||v===X||typeof v=="object"&&v!==null&&(v.$$typeof===ie||v.$$typeof===ue||v.$$typeof===y||v.$$typeof===k||v.$$typeof===H||v.$$typeof===ee||v.$$typeof===me||v.$$typeof===z||v.$$typeof===K)}function te(v){if(typeof v=="object"&&v!==null){var G=v.$$typeof;switch(G){case h:var Lt=v.type;switch(Lt){case A:case D:case l:case m:case g:case W:return Lt;default:var Te=Lt&&Lt.$$typeof;switch(Te){case k:case H:case ie:case ue:case y:return Te;default:return G}}case r:return G}}}var Y=A,Ie=D,Ye=k,It=y,Re=h,rt=H,bt=l,Bt=ie,Ct=ue,nt=r,Tt=m,lt=g,$t=W,St=!1;function Ue(v){return St||(St=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),_(v)||te(v)===A}function _(v){return te(v)===D}function F(v){return te(v)===k}function Q(v){return te(v)===y}function ne(v){return typeof v=="object"&&v!==null&&v.$$typeof===h}function le(v){return te(v)===H}function he(v){return te(v)===l}function J(v){return te(v)===ie}function $e(v){return te(v)===ue}function ce(v){return te(v)===r}function _e(v){return te(v)===m}function U(v){return te(v)===g}function Xe(v){return te(v)===W}De.AsyncMode=Y,De.ConcurrentMode=Ie,De.ContextConsumer=Ye,De.ContextProvider=It,De.Element=Re,De.ForwardRef=rt,De.Fragment=bt,De.Lazy=Bt,De.Memo=Ct,De.Portal=nt,De.Profiler=Tt,De.StrictMode=lt,De.Suspense=$t,De.isAsyncMode=Ue,De.isConcurrentMode=_,De.isContextConsumer=F,De.isContextProvider=Q,De.isElement=ne,De.isForwardRef=le,De.isFragment=he,De.isLazy=J,De.isMemo=$e,De.isPortal=ce,De.isProfiler=_e,De.isStrictMode=U,De.isSuspense=Xe,De.isValidElementType=ae,De.typeOf=te})()),De}var r_;function R_(){return r_||(r_=1,process.env.NODE_ENV==="production"?Al.exports=jv():Al.exports=Kv()),Al.exports}/*
1049
+ */var l_;function Jv(){return l_||(l_=1,process.env.NODE_ENV!=="production"&&(function(){var h=typeof Symbol=="function"&&Symbol.for,a=h?Symbol.for("react.element"):60103,r=h?Symbol.for("react.portal"):60106,l=h?Symbol.for("react.fragment"):60107,g=h?Symbol.for("react.strict_mode"):60108,m=h?Symbol.for("react.profiler"):60114,y=h?Symbol.for("react.provider"):60109,k=h?Symbol.for("react.context"):60110,A=h?Symbol.for("react.async_mode"):60111,D=h?Symbol.for("react.concurrent_mode"):60111,H=h?Symbol.for("react.forward_ref"):60112,W=h?Symbol.for("react.suspense"):60113,X=h?Symbol.for("react.suspense_list"):60120,ue=h?Symbol.for("react.memo"):60115,ie=h?Symbol.for("react.lazy"):60116,K=h?Symbol.for("react.block"):60121,ee=h?Symbol.for("react.fundamental"):60117,me=h?Symbol.for("react.responder"):60118,z=h?Symbol.for("react.scope"):60119;function ae(v){return typeof v=="string"||typeof v=="function"||v===l||v===D||v===m||v===g||v===W||v===X||typeof v=="object"&&v!==null&&(v.$$typeof===ie||v.$$typeof===ue||v.$$typeof===y||v.$$typeof===k||v.$$typeof===H||v.$$typeof===ee||v.$$typeof===me||v.$$typeof===z||v.$$typeof===K)}function te(v){if(typeof v=="object"&&v!==null){var G=v.$$typeof;switch(G){case a:var Lt=v.type;switch(Lt){case A:case D:case l:case m:case g:case W:return Lt;default:var Te=Lt&&Lt.$$typeof;switch(Te){case k:case H:case ie:case ue:case y:return Te;default:return G}}case r:return G}}}var Y=A,Ie=D,Ye=k,It=y,Re=a,rt=H,bt=l,Bt=ie,Ct=ue,nt=r,Tt=m,lt=g,$t=W,St=!1;function Ue(v){return St||(St=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),_(v)||te(v)===A}function _(v){return te(v)===D}function F(v){return te(v)===k}function Q(v){return te(v)===y}function ne(v){return typeof v=="object"&&v!==null&&v.$$typeof===a}function le(v){return te(v)===H}function he(v){return te(v)===l}function J(v){return te(v)===ie}function $e(v){return te(v)===ue}function ce(v){return te(v)===r}function _e(v){return te(v)===m}function U(v){return te(v)===g}function Xe(v){return te(v)===W}De.AsyncMode=Y,De.ConcurrentMode=Ie,De.ContextConsumer=Ye,De.ContextProvider=It,De.Element=Re,De.ForwardRef=rt,De.Fragment=bt,De.Lazy=Bt,De.Memo=Ct,De.Portal=nt,De.Profiler=Tt,De.StrictMode=lt,De.Suspense=$t,De.isAsyncMode=Ue,De.isConcurrentMode=_,De.isContextConsumer=F,De.isContextProvider=Q,De.isElement=ne,De.isForwardRef=le,De.isFragment=he,De.isLazy=J,De.isMemo=$e,De.isPortal=ce,De.isProfiler=_e,De.isStrictMode=U,De.isSuspense=Xe,De.isValidElementType=ae,De.typeOf=te})()),De}var c_;function N_(){return c_||(c_=1,process.env.NODE_ENV==="production"?Ll.exports=Kv():Ll.exports=Jv()),Ll.exports}/*
1050
1050
  object-assign
1051
1051
  (c) Sindre Sorhus
1052
1052
  @license MIT
1053
- */var Uh,n_;function Jv(){if(n_)return Uh;n_=1;var a=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;function l(m){if(m==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(m)}function g(){try{if(!Object.assign)return!1;var m=new String("abc");if(m[5]="de",Object.getOwnPropertyNames(m)[0]==="5")return!1;for(var y={},k=0;k<10;k++)y["_"+String.fromCharCode(k)]=k;var A=Object.getOwnPropertyNames(y).map(function(H){return y[H]});if(A.join("")!=="0123456789")return!1;var D={};return"abcdefghijklmnopqrst".split("").forEach(function(H){D[H]=H}),Object.keys(Object.assign({},D)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Uh=g()?Object.assign:function(m,y){for(var k,A=l(m),D,H=1;H<arguments.length;H++){k=Object(arguments[H]);for(var W in k)h.call(k,W)&&(A[W]=k[W]);if(a){D=a(k);for(var X=0;X<D.length;X++)r.call(k,D[X])&&(A[D[X]]=k[D[X]])}}return A},Uh}var Hh,l_;function nd(){if(l_)return Hh;l_=1;var a="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Hh=a,Hh}var Gh,c_;function w_(){return c_||(c_=1,Gh=Function.call.bind(Object.prototype.hasOwnProperty)),Gh}var Vh,u_;function qv(){if(u_)return Vh;u_=1;var a=function(){};if(process.env.NODE_ENV!=="production"){var h=nd(),r={},l=w_();a=function(m){var y="Warning: "+m;typeof console<"u"&&console.error(y);try{throw new Error(y)}catch{}}}function g(m,y,k,A,D){if(process.env.NODE_ENV!=="production"){for(var H in m)if(l(m,H)){var W;try{if(typeof m[H]!="function"){var X=Error((A||"React class")+": "+k+" type `"+H+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof m[H]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw X.name="Invariant Violation",X}W=m[H](y,H,A,k,null,h)}catch(ie){W=ie}if(W&&!(W instanceof Error)&&a((A||"React class")+": type specification of "+k+" `"+H+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof W+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),W instanceof Error&&!(W.message in r)){r[W.message]=!0;var ue=D?D():"";a("Failed "+k+" type: "+W.message+(ue??""))}}}}return g.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(r={})},Vh=g,Vh}var Wh,a_;function Zv(){if(a_)return Wh;a_=1;var a=R_(),h=Jv(),r=nd(),l=w_(),g=qv(),m=function(){};process.env.NODE_ENV!=="production"&&(m=function(k){var A="Warning: "+k;typeof console<"u"&&console.error(A);try{throw new Error(A)}catch{}});function y(){return null}return Wh=function(k,A){var D=typeof Symbol=="function"&&Symbol.iterator,H="@@iterator";function W(_){var F=_&&(D&&_[D]||_[H]);if(typeof F=="function")return F}var X="<<anonymous>>",ue={array:me("array"),bigint:me("bigint"),bool:me("boolean"),func:me("function"),number:me("number"),object:me("object"),string:me("string"),symbol:me("symbol"),any:z(),arrayOf:ae,element:te(),elementType:Y(),instanceOf:Ie,node:rt(),objectOf:It,oneOf:Ye,oneOfType:Re,shape:Bt,exact:Ct};function ie(_,F){return _===F?_!==0||1/_===1/F:_!==_&&F!==F}function K(_,F){this.message=_,this.data=F&&typeof F=="object"?F:{},this.stack=""}K.prototype=Error.prototype;function ee(_){if(process.env.NODE_ENV!=="production")var F={},Q=0;function ne(he,J,$e,ce,_e,U,Xe){if(ce=ce||X,U=U||$e,Xe!==r){if(A){var v=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw v.name="Invariant Violation",v}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var G=ce+":"+$e;!F[G]&&Q<3&&(m("You are manually calling a React.PropTypes validation function for the `"+U+"` prop on `"+ce+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),F[G]=!0,Q++)}}return J[$e]==null?he?J[$e]===null?new K("The "+_e+" `"+U+"` is marked as required "+("in `"+ce+"`, but its value is `null`.")):new K("The "+_e+" `"+U+"` is marked as required in "+("`"+ce+"`, but its value is `undefined`.")):null:_(J,$e,ce,_e,U)}var le=ne.bind(null,!1);return le.isRequired=ne.bind(null,!0),le}function me(_){function F(Q,ne,le,he,J,$e){var ce=Q[ne],_e=lt(ce);if(_e!==_){var U=$t(ce);return new K("Invalid "+he+" `"+J+"` of type "+("`"+U+"` supplied to `"+le+"`, expected ")+("`"+_+"`."),{expectedType:_})}return null}return ee(F)}function z(){return ee(y)}function ae(_){function F(Q,ne,le,he,J){if(typeof _!="function")return new K("Property `"+J+"` of component `"+le+"` has invalid PropType notation inside arrayOf.");var $e=Q[ne];if(!Array.isArray($e)){var ce=lt($e);return new K("Invalid "+he+" `"+J+"` of type "+("`"+ce+"` supplied to `"+le+"`, expected an array."))}for(var _e=0;_e<$e.length;_e++){var U=_($e,_e,le,he,J+"["+_e+"]",r);if(U instanceof Error)return U}return null}return ee(F)}function te(){function _(F,Q,ne,le,he){var J=F[Q];if(!k(J)){var $e=lt(J);return new K("Invalid "+le+" `"+he+"` of type "+("`"+$e+"` supplied to `"+ne+"`, expected a single ReactElement."))}return null}return ee(_)}function Y(){function _(F,Q,ne,le,he){var J=F[Q];if(!a.isValidElementType(J)){var $e=lt(J);return new K("Invalid "+le+" `"+he+"` of type "+("`"+$e+"` supplied to `"+ne+"`, expected a single ReactElement type."))}return null}return ee(_)}function Ie(_){function F(Q,ne,le,he,J){if(!(Q[ne]instanceof _)){var $e=_.name||X,ce=Ue(Q[ne]);return new K("Invalid "+he+" `"+J+"` of type "+("`"+ce+"` supplied to `"+le+"`, expected ")+("instance of `"+$e+"`."))}return null}return ee(F)}function Ye(_){if(!Array.isArray(_))return process.env.NODE_ENV!=="production"&&(arguments.length>1?m("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):m("Invalid argument supplied to oneOf, expected an array.")),y;function F(Q,ne,le,he,J){for(var $e=Q[ne],ce=0;ce<_.length;ce++)if(ie($e,_[ce]))return null;var _e=JSON.stringify(_,function(Xe,v){var G=$t(v);return G==="symbol"?String(v):v});return new K("Invalid "+he+" `"+J+"` of value `"+String($e)+"` "+("supplied to `"+le+"`, expected one of "+_e+"."))}return ee(F)}function It(_){function F(Q,ne,le,he,J){if(typeof _!="function")return new K("Property `"+J+"` of component `"+le+"` has invalid PropType notation inside objectOf.");var $e=Q[ne],ce=lt($e);if(ce!=="object")return new K("Invalid "+he+" `"+J+"` of type "+("`"+ce+"` supplied to `"+le+"`, expected an object."));for(var _e in $e)if(l($e,_e)){var U=_($e,_e,le,he,J+"."+_e,r);if(U instanceof Error)return U}return null}return ee(F)}function Re(_){if(!Array.isArray(_))return process.env.NODE_ENV!=="production"&&m("Invalid argument supplied to oneOfType, expected an instance of array."),y;for(var F=0;F<_.length;F++){var Q=_[F];if(typeof Q!="function")return m("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+St(Q)+" at index "+F+"."),y}function ne(le,he,J,$e,ce){for(var _e=[],U=0;U<_.length;U++){var Xe=_[U],v=Xe(le,he,J,$e,ce,r);if(v==null)return null;v.data&&l(v.data,"expectedType")&&_e.push(v.data.expectedType)}var G=_e.length>0?", expected one of type ["+_e.join(", ")+"]":"";return new K("Invalid "+$e+" `"+ce+"` supplied to "+("`"+J+"`"+G+"."))}return ee(ne)}function rt(){function _(F,Q,ne,le,he){return nt(F[Q])?null:new K("Invalid "+le+" `"+he+"` supplied to "+("`"+ne+"`, expected a ReactNode."))}return ee(_)}function bt(_,F,Q,ne,le){return new K((_||"React class")+": "+F+" type `"+Q+"."+ne+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+le+"`.")}function Bt(_){function F(Q,ne,le,he,J){var $e=Q[ne],ce=lt($e);if(ce!=="object")return new K("Invalid "+he+" `"+J+"` of type `"+ce+"` "+("supplied to `"+le+"`, expected `object`."));for(var _e in _){var U=_[_e];if(typeof U!="function")return bt(le,he,J,_e,$t(U));var Xe=U($e,_e,le,he,J+"."+_e,r);if(Xe)return Xe}return null}return ee(F)}function Ct(_){function F(Q,ne,le,he,J){var $e=Q[ne],ce=lt($e);if(ce!=="object")return new K("Invalid "+he+" `"+J+"` of type `"+ce+"` "+("supplied to `"+le+"`, expected `object`."));var _e=h({},Q[ne],_);for(var U in _e){var Xe=_[U];if(l(_,U)&&typeof Xe!="function")return bt(le,he,J,U,$t(Xe));if(!Xe)return new K("Invalid "+he+" `"+J+"` key `"+U+"` supplied to `"+le+"`.\nBad object: "+JSON.stringify(Q[ne],null," ")+`
1054
- Valid keys: `+JSON.stringify(Object.keys(_),null," "));var v=Xe($e,U,le,he,J+"."+U,r);if(v)return v}return null}return ee(F)}function nt(_){switch(typeof _){case"number":case"string":case"undefined":return!0;case"boolean":return!_;case"object":if(Array.isArray(_))return _.every(nt);if(_===null||k(_))return!0;var F=W(_);if(F){var Q=F.call(_),ne;if(F!==_.entries){for(;!(ne=Q.next()).done;)if(!nt(ne.value))return!1}else for(;!(ne=Q.next()).done;){var le=ne.value;if(le&&!nt(le[1]))return!1}}else return!1;return!0;default:return!1}}function Tt(_,F){return _==="symbol"?!0:F?F["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&F instanceof Symbol:!1}function lt(_){var F=typeof _;return Array.isArray(_)?"array":_ instanceof RegExp?"object":Tt(F,_)?"symbol":F}function $t(_){if(typeof _>"u"||_===null)return""+_;var F=lt(_);if(F==="object"){if(_ instanceof Date)return"date";if(_ instanceof RegExp)return"regexp"}return F}function St(_){var F=$t(_);switch(F){case"array":case"object":return"an "+F;case"boolean":case"date":case"regexp":return"a "+F;default:return F}}function Ue(_){return!_.constructor||!_.constructor.name?X:_.constructor.name}return ue.checkPropTypes=g,ue.resetWarningCache=g.resetWarningCache,ue.PropTypes=ue,ue},Wh}var zh,h_;function Qv(){if(h_)return zh;h_=1;var a=nd();function h(){}function r(){}return r.resetWarningCache=h,zh=function(){function l(y,k,A,D,H,W){if(W!==a){var X=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw X.name="Invariant Violation",X}}l.isRequired=l;function g(){return l}var m={array:l,bigint:l,bool:l,func:l,number:l,object:l,string:l,symbol:l,any:l,arrayOf:g,element:l,elementType:l,instanceOf:g,node:l,objectOf:g,oneOf:g,oneOfType:g,shape:g,exact:g,checkPropTypes:r,resetWarningCache:h};return m.PropTypes=m,m},zh}var d_;function eI(){if(d_)return Nl.exports;if(d_=1,process.env.NODE_ENV!=="production"){var a=R_(),h=!0;Nl.exports=Zv()(a.isElement,h)}else Nl.exports=Qv()();return Nl.exports}var tI=eI();const ge=Di(tI),$_={disabled:!1};var oI=process.env.NODE_ENV!=="production"?ge.oneOfType([ge.number,ge.shape({enter:ge.number,exit:ge.number,appear:ge.number}).isRequired]):null;process.env.NODE_ENV!=="production"&&ge.oneOfType([ge.string,ge.shape({enter:ge.string,exit:ge.string,active:ge.string}),ge.shape({enter:ge.string,enterDone:ge.string,enterActive:ge.string,exit:ge.string,exitDone:ge.string,exitActive:ge.string})]);const O_=de.createContext(null);var sI=function(h){return h.scrollTop},Dr="unmounted",Vs="exited",ps="entering",Ws="entered",Zh="exiting",Jo=(function(a){Bv(h,a);function h(l,g){var m;m=a.call(this,l,g)||this;var y=g,k=y&&!y.isMounting?l.enter:l.appear,A;return m.appearStatus=null,l.in?k?(A=Vs,m.appearStatus=ps):A=Ws:l.unmountOnExit||l.mountOnEnter?A=Dr:A=Vs,m.state={status:A},m.nextCallback=null,m}h.getDerivedStateFromProps=function(g,m){var y=g.in;return y&&m.status===Dr?{status:Vs}:null};var r=h.prototype;return r.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},r.componentDidUpdate=function(g){var m=null;if(g!==this.props){var y=this.state.status;this.props.in?y!==ps&&y!==Ws&&(m=ps):(y===ps||y===Ws)&&(m=Zh)}this.updateStatus(!1,m)},r.componentWillUnmount=function(){this.cancelNextCallback()},r.getTimeouts=function(){var g=this.props.timeout,m,y,k;return m=y=k=g,g!=null&&typeof g!="number"&&(m=g.exit,y=g.enter,k=g.appear!==void 0?g.appear:y),{exit:m,enter:y,appear:k}},r.updateStatus=function(g,m){if(g===void 0&&(g=!1),m!==null)if(this.cancelNextCallback(),m===ps){if(this.props.unmountOnExit||this.props.mountOnEnter){var y=this.props.nodeRef?this.props.nodeRef.current:Mr.findDOMNode(this);y&&sI(y)}this.performEnter(g)}else this.performExit();else this.props.unmountOnExit&&this.state.status===Vs&&this.setState({status:Dr})},r.performEnter=function(g){var m=this,y=this.props.enter,k=this.context?this.context.isMounting:g,A=this.props.nodeRef?[k]:[Mr.findDOMNode(this),k],D=A[0],H=A[1],W=this.getTimeouts(),X=k?W.appear:W.enter;if(!g&&!y||$_.disabled){this.safeSetState({status:Ws},function(){m.props.onEntered(D)});return}this.props.onEnter(D,H),this.safeSetState({status:ps},function(){m.props.onEntering(D,H),m.onTransitionEnd(X,function(){m.safeSetState({status:Ws},function(){m.props.onEntered(D,H)})})})},r.performExit=function(){var g=this,m=this.props.exit,y=this.getTimeouts(),k=this.props.nodeRef?void 0:Mr.findDOMNode(this);if(!m||$_.disabled){this.safeSetState({status:Vs},function(){g.props.onExited(k)});return}this.props.onExit(k),this.safeSetState({status:Zh},function(){g.props.onExiting(k),g.onTransitionEnd(y.exit,function(){g.safeSetState({status:Vs},function(){g.props.onExited(k)})})})},r.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},r.safeSetState=function(g,m){m=this.setNextCallback(m),this.setState(g,m)},r.setNextCallback=function(g){var m=this,y=!0;return this.nextCallback=function(k){y&&(y=!1,m.nextCallback=null,g(k))},this.nextCallback.cancel=function(){y=!1},this.nextCallback},r.onTransitionEnd=function(g,m){this.setNextCallback(m);var y=this.props.nodeRef?this.props.nodeRef.current:Mr.findDOMNode(this),k=g==null&&!this.props.addEndListener;if(!y||k){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var A=this.props.nodeRef?[this.nextCallback]:[y,this.nextCallback],D=A[0],H=A[1];this.props.addEndListener(D,H)}g!=null&&setTimeout(this.nextCallback,g)},r.render=function(){var g=this.state.status;if(g===Dr)return null;var m=this.props,y=m.children;m.in,m.mountOnEnter,m.unmountOnExit,m.appear,m.enter,m.exit,m.timeout,m.addEndListener,m.onEnter,m.onEntering,m.onEntered,m.onExit,m.onExiting,m.onExited,m.nodeRef;var k=I_(m,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return de.createElement(O_.Provider,{value:null},typeof y=="function"?y(g,k):de.cloneElement(de.Children.only(y),k))},h})(de.Component);Jo.contextType=O_;Jo.propTypes=process.env.NODE_ENV!=="production"?{nodeRef:ge.shape({current:typeof Element>"u"?ge.any:function(a,h,r,l,g,m){var y=a[h];return ge.instanceOf(y&&"ownerDocument"in y?y.ownerDocument.defaultView.Element:Element)(a,h,r,l,g,m)}}),children:ge.oneOfType([ge.func.isRequired,ge.element.isRequired]).isRequired,in:ge.bool,mountOnEnter:ge.bool,unmountOnExit:ge.bool,appear:ge.bool,enter:ge.bool,exit:ge.bool,timeout:function(h){var r=oI;h.addEndListener||(r=r.isRequired);for(var l=arguments.length,g=new Array(l>1?l-1:0),m=1;m<l;m++)g[m-1]=arguments[m];return r.apply(void 0,[h].concat(g))},addEndListener:ge.func,onEnter:ge.func,onEntering:ge.func,onEntered:ge.func,onExit:ge.func,onExiting:ge.func,onExited:ge.func}:{};function Li(){}Jo.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:Li,onEntering:Li,onEntered:Li,onExit:Li,onExiting:Li,onExited:Li};Jo.UNMOUNTED=Dr;Jo.EXITED=Vs;Jo.ENTERING=ps;Jo.ENTERED=Ws;Jo.EXITING=Zh;function iI(){const a=fe.version.split(".");return{major:+a[0],minor:+a[1],patch:+a[2]}}function rI(a){if(!a||typeof a=="function")return null;const{major:h}=iI();return h>=19?a.props.ref:a.ref}const nI=!!(typeof window<"u"&&window.document&&window.document.createElement);var Qh=!1,ed=!1;try{var Yh={get passive(){return Qh=!0},get once(){return ed=Qh=!0}};nI&&(window.addEventListener("test",Yh,Yh),window.removeEventListener("test",Yh,!0))}catch{}function lI(a,h,r,l){if(l&&typeof l!="boolean"&&!ed){var g=l.once,m=l.capture,y=r;!ed&&g&&(y=r.__once||function k(A){this.removeEventListener(h,k,m),r.call(this,A)},r.__once=y),a.addEventListener(h,y,Qh?l:m)}a.addEventListener(h,r,l)}function cI(a,h,r,l){var g=l&&typeof l!="boolean"?l.capture:l;a.removeEventListener(h,r,g),r.__once&&a.removeEventListener(h,r.__once,g)}function N_(a,h,r,l){return lI(a,h,r,l),function(){cI(a,h,r,l)}}function uI(a,h,r,l){if(l===void 0&&(l=!0),a){var g=document.createEvent("HTMLEvents");g.initEvent(h,r,l),a.dispatchEvent(g)}}function aI(a){var h=k_(a,"transitionDuration")||"",r=h.indexOf("ms")===-1?1e3:1;return parseFloat(h)*r}function hI(a,h,r){r===void 0&&(r=5);var l=!1,g=setTimeout(function(){l||uI(a,"transitionend",!0)},h+r),m=N_(a,"transitionend",function(){l=!0},{once:!0});return function(){clearTimeout(g),m()}}function dI(a,h,r,l){r==null&&(r=aI(a)||0);var g=hI(a,r,l),m=N_(a,"transitionend",h);return function(){g(),m()}}function p_(a,h){const r=k_(a,h)||"",l=r.indexOf("ms")===-1?1e3:1;return parseFloat(r)*l}function $I(a,h){const r=p_(a,"transitionDuration"),l=p_(a,"transitionDelay"),g=dI(a,m=>{m.target===a&&(g(),h(m))},r+l)}function pI(a){a.offsetHeight}const g_=a=>!a||typeof a=="function"?a:h=>{a.current=h};function gI(a,h){const r=g_(a),l=g_(h);return g=>{r&&r(g),l&&l(g)}}function mI(a,h){return de.useMemo(()=>gI(a,h),[a,h])}function fI(a){return a&&"setState"in a?Mr.findDOMNode(a):a??null}const A_=de.forwardRef(({onEnter:a,onEntering:h,onEntered:r,onExit:l,onExiting:g,onExited:m,addEndListener:y,children:k,childRef:A,...D},H)=>{const W=de.useRef(null),X=mI(W,A),ue=Ie=>{X(fI(Ie))},ie=Ie=>Ye=>{Ie&&W.current&&Ie(W.current,Ye)},K=de.useCallback(ie(a),[a]),ee=de.useCallback(ie(h),[h]),me=de.useCallback(ie(r),[r]),z=de.useCallback(ie(l),[l]),ae=de.useCallback(ie(g),[g]),te=de.useCallback(ie(m),[m]),Y=de.useCallback(ie(y),[y]);return B.jsx(Jo,{ref:H,...D,onEnter:K,onEntered:me,onEntering:ee,onExit:z,onExited:te,onExiting:ae,addEndListener:Y,nodeRef:W,children:typeof k=="function"?(Ie,Ye)=>k(Ie,{...Ye,ref:ue}):de.cloneElement(k,{ref:ue})})});A_.displayName="TransitionWrapper";function _I(a){const h=de.useRef(a);return de.useEffect(()=>{h.current=a},[a]),h}function bI(a){const h=_I(a);return de.useCallback(function(...r){return h.current&&h.current(...r)},[h])}const ld=(a=>fe.forwardRef((h,r)=>B.jsx("div",{...h,ref:r,className:Se(h.className,a)}))),L_=ld("h4");L_.displayName="DivStyledAsH4";const M_=fe.forwardRef(({className:a,bsPrefix:h,as:r=L_,...l},g)=>(h=xe(h,"alert-heading"),B.jsx(r,{ref:g,className:Se(a,h),...l})));M_.displayName="AlertHeading";function TI(a){const h=de.useRef(a);return de.useEffect(()=>{h.current=a},[a]),h}function EI(a){const h=TI(a);return de.useCallback(function(...r){return h.current&&h.current(...r)},[h])}const yI=["as","disabled"];function vI(a,h){if(a==null)return{};var r={};for(var l in a)if({}.hasOwnProperty.call(a,l)){if(h.indexOf(l)>=0)continue;r[l]=a[l]}return r}function II(a){return!a||a.trim()==="#"}function cd({tagName:a,disabled:h,href:r,target:l,rel:g,role:m,onClick:y,tabIndex:k=0,type:A}){a||(r!=null||l!=null||g!=null?a="a":a="button");const D={tagName:a};if(a==="button")return[{type:A||"button",disabled:h},D];const H=X=>{if((h||a==="a"&&II(r))&&X.preventDefault(),h){X.stopPropagation();return}y?.(X)},W=X=>{X.key===" "&&(X.preventDefault(),H(X))};return a==="a"&&(r||(r="#"),h&&(r=void 0)),[{role:m??"button",disabled:void 0,tabIndex:h?void 0:k,href:r,target:a==="a"?l:void 0,"aria-disabled":h||void 0,rel:a==="a"?g:void 0,onClick:H,onKeyDown:W},D]}const CI=fe.forwardRef((a,h)=>{let{as:r,disabled:l}=a,g=vI(a,yI);const[m,{tagName:y}]=cd(Object.assign({tagName:r,disabled:l},g));return B.jsx(y,Object.assign({},g,m,{ref:h}))});CI.displayName="Button";const SI=["onKeyDown"];function kI(a,h){if(a==null)return{};var r={};for(var l in a)if({}.hasOwnProperty.call(a,l)){if(h.indexOf(l)>=0)continue;r[l]=a[l]}return r}function RI(a){return!a||a.trim()==="#"}const D_=fe.forwardRef((a,h)=>{let{onKeyDown:r}=a,l=kI(a,SI);const[g]=cd(Object.assign({tagName:"a"},l)),m=EI(y=>{g.onKeyDown(y),r?.(y)});return RI(l.href)||l.role==="button"?B.jsx("a",Object.assign({ref:h},l,g,{onKeyDown:m})):B.jsx("a",Object.assign({ref:h},l,{onKeyDown:r}))});D_.displayName="Anchor";const x_=fe.forwardRef(({className:a,bsPrefix:h,as:r=D_,...l},g)=>(h=xe(h,"alert-link"),B.jsx(r,{ref:g,className:Se(a,h),...l})));x_.displayName="AlertLink";const wI={[ps]:"show",[Ws]:"show"},td=fe.forwardRef(({className:a,children:h,transitionClasses:r={},onEnter:l,...g},m)=>{const y={in:!1,timeout:300,mountOnEnter:!1,unmountOnExit:!1,appear:!1,...g},k=de.useCallback((A,D)=>{pI(A),l?.(A,D)},[l]);return B.jsx(A_,{ref:m,addEndListener:$I,...y,onEnter:k,childRef:rI(h),children:(A,D)=>fe.cloneElement(h,{...D,className:Se("fade",a,h.props.className,wI[A],r[A])})})});td.displayName="Fade";const OI={"aria-label":ge.string,onClick:ge.func,variant:ge.oneOf(["white"])},ud=fe.forwardRef(({className:a,variant:h,"aria-label":r="Close",...l},g)=>B.jsx("button",{ref:g,type:"button",className:Se("btn-close",h&&`btn-close-${h}`,a),"aria-label":r,...l}));ud.displayName="CloseButton";ud.propTypes=OI;const B_=fe.forwardRef((a,h)=>{const{bsPrefix:r,show:l=!0,closeLabel:g="Close alert",closeVariant:m,className:y,children:k,variant:A="primary",onClose:D,dismissible:H,transition:W=td,...X}=xv(a,{show:"onClose"}),ue=xe(r,"alert"),ie=bI(me=>{D&&D(!1,me)}),K=W===!0?td:W,ee=B.jsxs("div",{role:"alert",...K?void 0:X,ref:h,className:Se(y,ue,A&&`${ue}-${A}`,H&&`${ue}-dismissible`),children:[H&&B.jsx(ud,{onClick:ie,"aria-label":g,variant:m}),k]});return K?B.jsx(K,{unmountOnExit:!0,...X,ref:void 0,in:l,children:ee}):l?ee:null});B_.displayName="Alert";const m_=Object.assign(B_,{Link:x_,Heading:M_}),Mi=fe.forwardRef(({bsPrefix:a,bg:h="primary",pill:r=!1,text:l,className:g,as:m="span",...y},k)=>{const A=xe(a,"badge");return B.jsx(m,{ref:k,...y,className:Se(g,A,r&&"rounded-pill",l&&`text-${l}`,h&&`bg-${h}`)})});Mi.displayName="Badge";const Lo=fe.forwardRef(({as:a,bsPrefix:h,variant:r="primary",size:l,active:g=!1,disabled:m=!1,className:y,...k},A)=>{const D=xe(h,"btn"),[H,{tagName:W}]=cd({tagName:a,disabled:m,...k}),X=W;return B.jsx(X,{...H,...k,ref:A,disabled:m,className:Se(y,D,g&&"active",r&&`${D}-${r}`,l&&`${D}-${l}`,k.href&&m&&"disabled")})});Lo.displayName="Button";const od=fe.forwardRef(({bsPrefix:a,size:h,vertical:r=!1,className:l,role:g="group",as:m="div",...y},k)=>{const A=xe(a,"btn-group");let D=A;return r&&(D=`${A}-vertical`),B.jsx(m,{...y,ref:k,role:g,className:Se(l,D,h&&`${A}-${h}`)})});od.displayName="ButtonGroup";const ad=fe.forwardRef(({className:a,bsPrefix:h,as:r="div",...l},g)=>(h=xe(h,"card-body"),B.jsx(r,{ref:g,className:Se(a,h),...l})));ad.displayName="CardBody";const P_=fe.forwardRef(({className:a,bsPrefix:h,as:r="div",...l},g)=>(h=xe(h,"card-footer"),B.jsx(r,{ref:g,className:Se(a,h),...l})));P_.displayName="CardFooter";const F_=fe.createContext(null);F_.displayName="CardHeaderContext";const U_=fe.forwardRef(({bsPrefix:a,className:h,as:r="div",...l},g)=>{const m=xe(a,"card-header"),y=de.useMemo(()=>({cardHeaderBsPrefix:m}),[m]);return B.jsx(F_.Provider,{value:y,children:B.jsx(r,{ref:g,...l,className:Se(h,m)})})});U_.displayName="CardHeader";const H_=fe.forwardRef(({bsPrefix:a,className:h,variant:r,as:l="img",...g},m)=>{const y=xe(a,"card-img");return B.jsx(l,{ref:m,className:Se(r?`${y}-${r}`:y,h),...g})});H_.displayName="CardImg";const G_=fe.forwardRef(({className:a,bsPrefix:h,as:r="div",...l},g)=>(h=xe(h,"card-img-overlay"),B.jsx(r,{ref:g,className:Se(a,h),...l})));G_.displayName="CardImgOverlay";const V_=fe.forwardRef(({className:a,bsPrefix:h,as:r="a",...l},g)=>(h=xe(h,"card-link"),B.jsx(r,{ref:g,className:Se(a,h),...l})));V_.displayName="CardLink";const NI=ld("h6"),W_=fe.forwardRef(({className:a,bsPrefix:h,as:r=NI,...l},g)=>(h=xe(h,"card-subtitle"),B.jsx(r,{ref:g,className:Se(a,h),...l})));W_.displayName="CardSubtitle";const z_=fe.forwardRef(({className:a,bsPrefix:h,as:r="p",...l},g)=>(h=xe(h,"card-text"),B.jsx(r,{ref:g,className:Se(a,h),...l})));z_.displayName="CardText";const AI=ld("h5"),Y_=fe.forwardRef(({className:a,bsPrefix:h,as:r=AI,...l},g)=>(h=xe(h,"card-title"),B.jsx(r,{ref:g,className:Se(a,h),...l})));Y_.displayName="CardTitle";const X_=fe.forwardRef(({bsPrefix:a,className:h,bg:r,text:l,border:g,body:m=!1,children:y,as:k="div",...A},D)=>{const H=xe(a,"card");return B.jsx(k,{ref:D,...A,className:Se(h,H,r&&`bg-${r}`,l&&`text-${l}`,g&&`border-${g}`),children:m?B.jsx(ad,{children:y}):y})});X_.displayName="Card";const xr=Object.assign(X_,{Img:H_,Title:Y_,Subtitle:W_,Body:ad,Link:V_,Text:z_,Header:U_,Footer:P_,ImgOverlay:G_});function LI(a,h){return fe.Children.toArray(a).some(r=>fe.isValidElement(r)&&r.type===h)}function MI({as:a,bsPrefix:h,className:r,...l}){h=xe(h,"col");const g=C_(),m=S_(),y=[],k=[];return g.forEach(A=>{const D=l[A];delete l[A];let H,W,X;typeof D=="object"&&D!=null?{span:H,offset:W,order:X}=D:H=D;const ue=A!==m?`-${A}`:"";H&&y.push(H===!0?`${h}${ue}`:`${h}${ue}-${H}`),X!=null&&k.push(`order${ue}-${X}`),W!=null&&k.push(`offset${ue}-${W}`)}),[{...l,className:Se(r,...y,...k)},{as:a,bsPrefix:h,spans:y}]}const gs=fe.forwardRef((a,h)=>{const[{className:r,...l},{as:g="div",bsPrefix:m,spans:y}]=MI(a);return B.jsx(g,{...l,ref:h,className:Se(r,!y.length&&m)})});gs.displayName="Col";const j_=fe.forwardRef(({bsPrefix:a,fluid:h=!1,as:r="div",className:l,...g},m)=>{const y=xe(a,"container"),k=typeof h=="string"?`-${h}`:"-fluid";return B.jsx(r,{ref:m,...g,className:Se(l,h?`${y}${k}`:y)})});j_.displayName="Container";var Xh,f_;function DI(){if(f_)return Xh;f_=1;var a=process.env.NODE_ENV!=="production",h=function(){};if(a){var r=function(g,m){var y=arguments.length;m=new Array(y>1?y-1:0);for(var k=1;k<y;k++)m[k-1]=arguments[k];var A=0,D="Warning: "+g.replace(/%s/g,function(){return m[A++]});typeof console<"u"&&console.error(D);try{throw new Error(D)}catch{}};h=function(l,g,m){var y=arguments.length;m=new Array(y>2?y-2:0);for(var k=2;k<y;k++)m[k-2]=arguments[k];if(g===void 0)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");l||r.apply(null,[g].concat(m))}}return Xh=h,Xh}var xI=DI();const K_=Di(xI),BI={type:ge.string,tooltip:ge.bool,as:ge.elementType},Wl=fe.forwardRef(({as:a="div",className:h,type:r="valid",tooltip:l=!1,...g},m)=>B.jsx(a,{...g,ref:m,className:Se(h,`${r}-${l?"tooltip":"feedback"}`)}));Wl.displayName="Feedback";Wl.propTypes=BI;const Ko=fe.createContext({}),hd=fe.forwardRef(({id:a,bsPrefix:h,className:r,type:l="checkbox",isValid:g=!1,isInvalid:m=!1,as:y="input",...k},A)=>{const{controlId:D}=de.useContext(Ko);return h=xe(h,"form-check-input"),B.jsx(y,{...k,ref:A,type:l,id:a||D,className:Se(r,h,g&&"is-valid",m&&"is-invalid")})});hd.displayName="FormCheckInput";const Fl=fe.forwardRef(({bsPrefix:a,className:h,htmlFor:r,...l},g)=>{const{controlId:m}=de.useContext(Ko);return a=xe(a,"form-check-label"),B.jsx("label",{...l,ref:g,htmlFor:r||m,className:Se(h,a)})});Fl.displayName="FormCheckLabel";const J_=fe.forwardRef(({id:a,bsPrefix:h,bsSwitchPrefix:r,inline:l=!1,reverse:g=!1,disabled:m=!1,isValid:y=!1,isInvalid:k=!1,feedbackTooltip:A=!1,feedback:D,feedbackType:H,className:W,style:X,title:ue="",type:ie="checkbox",label:K,children:ee,as:me="input",...z},ae)=>{h=xe(h,"form-check"),r=xe(r,"form-switch");const{controlId:te}=de.useContext(Ko),Y=de.useMemo(()=>({controlId:a||te}),[te,a]),Ie=!ee&&K!=null&&K!==!1||LI(ee,Fl),Ye=B.jsx(hd,{...z,type:ie==="switch"?"checkbox":ie,ref:ae,isValid:y,isInvalid:k,disabled:m,as:me});return B.jsx(Ko.Provider,{value:Y,children:B.jsx("div",{style:X,className:Se(W,Ie&&h,l&&`${h}-inline`,g&&`${h}-reverse`,ie==="switch"&&r),children:ee||B.jsxs(B.Fragment,{children:[Ye,Ie&&B.jsx(Fl,{title:ue,children:K}),D&&B.jsx(Wl,{type:H,tooltip:A,children:D})]})})})});J_.displayName="FormCheck";const Ul=Object.assign(J_,{Input:hd,Label:Fl}),q_=fe.forwardRef(({bsPrefix:a,type:h,size:r,htmlSize:l,id:g,className:m,isValid:y=!1,isInvalid:k=!1,plaintext:A,readOnly:D,as:H="input",...W},X)=>{const{controlId:ue}=de.useContext(Ko);return a=xe(a,"form-control"),process.env.NODE_ENV!=="production"&&K_(ue==null||!g,"`controlId` is ignored on `<FormControl>` when `id` is specified."),B.jsx(H,{...W,type:h,size:l,ref:X,readOnly:D,id:g||ue,className:Se(m,A?`${a}-plaintext`:a,r&&`${a}-${r}`,h==="color"&&`${a}-color`,y&&"is-valid",k&&"is-invalid")})});q_.displayName="FormControl";const PI=Object.assign(q_,{Feedback:Wl}),Z_=fe.forwardRef(({className:a,bsPrefix:h,as:r="div",...l},g)=>(h=xe(h,"form-floating"),B.jsx(r,{ref:g,className:Se(a,h),...l})));Z_.displayName="FormFloating";const dd=fe.forwardRef(({controlId:a,as:h="div",...r},l)=>{const g=de.useMemo(()=>({controlId:a}),[a]);return B.jsx(Ko.Provider,{value:g,children:B.jsx(h,{...r,ref:l})})});dd.displayName="FormGroup";const Q_=fe.forwardRef(({as:a="label",bsPrefix:h,column:r=!1,visuallyHidden:l=!1,className:g,htmlFor:m,...y},k)=>{const{controlId:A}=de.useContext(Ko);h=xe(h,"form-label");let D="col-form-label";typeof r=="string"&&(D=`${D} ${D}-${r}`);const H=Se(g,h,l&&"visually-hidden",r&&D);return process.env.NODE_ENV!=="production"&&K_(A==null||!m,"`controlId` is ignored on `<FormLabel>` when `htmlFor` is specified."),m=m||A,r?B.jsx(gs,{ref:k,as:"label",className:H,htmlFor:m,...y}):B.jsx(a,{ref:k,className:H,htmlFor:m,...y})});Q_.displayName="FormLabel";const eb=fe.forwardRef(({bsPrefix:a,className:h,id:r,...l},g)=>{const{controlId:m}=de.useContext(Ko);return a=xe(a,"form-range"),B.jsx("input",{...l,type:"range",ref:g,className:Se(h,a),id:r||m})});eb.displayName="FormRange";const tb=fe.forwardRef(({bsPrefix:a,size:h,htmlSize:r,className:l,isValid:g=!1,isInvalid:m=!1,id:y,...k},A)=>{const{controlId:D}=de.useContext(Ko);return a=xe(a,"form-select"),B.jsx("select",{...k,size:r,ref:A,className:Se(l,a,h&&`${a}-${h}`,g&&"is-valid",m&&"is-invalid"),id:y||D})});tb.displayName="FormSelect";const ob=fe.forwardRef(({bsPrefix:a,className:h,as:r="small",muted:l,...g},m)=>(a=xe(a,"form-text"),B.jsx(r,{...g,ref:m,className:Se(h,a,l&&"text-muted")})));ob.displayName="FormText";const sb=fe.forwardRef((a,h)=>B.jsx(Ul,{...a,ref:h,type:"switch"}));sb.displayName="Switch";const FI=Object.assign(sb,{Input:Ul.Input,Label:Ul.Label}),ib=fe.forwardRef(({bsPrefix:a,className:h,children:r,controlId:l,label:g,...m},y)=>(a=xe(a,"form-floating"),B.jsxs(dd,{ref:y,className:Se(h,a),controlId:l,...m,children:[r,B.jsx("label",{htmlFor:l,children:g})]})));ib.displayName="FloatingLabel";const UI={_ref:ge.any,validated:ge.bool,as:ge.elementType},$d=fe.forwardRef(({className:a,validated:h,as:r="form",...l},g)=>B.jsx(r,{...l,ref:g,className:Se(a,h&&"was-validated")}));$d.displayName="Form";$d.propTypes=UI;const __=Object.assign($d,{Group:dd,Control:PI,Floating:Z_,Check:Ul,Switch:FI,Label:Q_,Text:ob,Range:eb,Select:tb,FloatingLabel:ib}),Hl=fe.forwardRef(({bsPrefix:a,className:h,as:r="div",...l},g)=>{const m=xe(a,"row"),y=C_(),k=S_(),A=`${m}-cols`,D=[];return y.forEach(H=>{const W=l[H];delete l[H];let X;W!=null&&typeof W=="object"?{cols:X}=W:X=W;const ue=H!==k?`-${H}`:"";X!=null&&D.push(`${A}${ue}-${X}`)}),B.jsx(r,{ref:g,...l,className:Se(h,m,...D)})});Hl.displayName="Row";class rb extends de.Component{createMazeGrid(){const{width:h,height:r,walls:l,finishPosition:g}=this.props.config,m=[];for(let y=0;y<r;y++){m[y]=[];for(let k=0;k<h;k++){const A=l.some(H=>H.x===k&&H.y===y),D=g.x===k&&g.y===y;m[y][k]={isWall:A,isFinish:D,isSpider:!1,isPath:!A}}}return m}render(){const{config:h,cellSize:r}=this.props,{width:l,height:g}=h,m=this.createMazeGrid();return B.jsx("div",{style:{position:"relative",width:l*r,height:g*r,border:"2px solid #333",backgroundColor:"#f0f0f0"},children:m.map((y,k)=>y.map((A,D)=>B.jsxs("div",{style:{position:"absolute",left:D*r,top:k*r,width:r,height:r,backgroundColor:A.isWall?"#333":A.isFinish?"#90EE90":"#f0f0f0",border:"1px solid #ccc",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"bold"},children:[A.isFinish&&B.jsx("div",{style:{width:"80%",height:"80%",backgroundColor:"#32CD32",borderRadius:"50%",border:"3px solid #228B22",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontSize:"14px",fontWeight:"bold"},children:"🎯"}),A.isWall&&B.jsx("div",{style:{width:"100%",height:"100%",backgroundColor:"#333",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontSize:"12px"},children:"🧱"})]},`${D}-${k}`)))})}}class nb extends de.Component{render(){const{position:h,direction:r,size:l}=this.props,g=l,y={north:0,east:90,south:180,west:270}[r];return B.jsx("div",{style:{position:"absolute",left:h.x*g+g/2,top:h.y*g+g/2,width:g*.8,height:g*.8,transform:`translate(-50%, -50%) rotate(${y}deg)`,transition:"all 0.3s ease-in-out",zIndex:10},children:B.jsxs("div",{style:{width:"100%",height:"100%",backgroundColor:"#8B4513",borderRadius:"50%",border:"2px solid #654321",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:[B.jsx("div",{style:{width:"30%",height:"30%",backgroundColor:"#FF0000",borderRadius:"50%",position:"absolute",left:"20%",top:"20%",boxShadow:"0 0 5px #FF0000"}}),B.jsx("div",{style:{width:"30%",height:"30%",backgroundColor:"#FF0000",borderRadius:"50%",position:"absolute",right:"20%",top:"20%",boxShadow:"0 0 5px #FF0000"}})]})})}}const zl=Pl();zl.Blocks.maze_move_forward={init(){this.appendDummyInput().appendField("Move Forward"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(92),this.setTooltip("Move the spider forward one step"),this.setHelpUrl("")}};zl.Blocks.maze_turn_left={init(){this.appendDummyInput().appendField("🔄 Turn Left"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(92),this.setTooltip("Turn the spider 90 degrees to the left"),this.setHelpUrl("")}};zl.Blocks.maze_turn_right={init(){this.appendDummyInput().appendField("🔄 Turn Right"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(92),this.setTooltip("Turn the spider 90 degrees to the right"),this.setHelpUrl("")}};zl.Blocks.maze_turn_around={init(){this.appendDummyInput().appendField("🔄 Turn Around"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(92),this.setTooltip("Turn the spider 180 degrees around"),this.setHelpUrl("")}};class lb extends de.Component{constructor(h){super(h),this.state={workspace:null,isInitialized:!1},this.onAnyChange=this.onAnyChange.bind(this)}componentDidMount(){this.initializeBlockly()}componentDidUpdate(h){h.config.toolbox!==this.props.config.toolbox&&(this.disposeWorkspace(),this.initializeBlockly()),h.config.initialXml!==this.props.config.initialXml&&this.workspace&&this.loadXml(this.props.config.initialXml)}componentWillUnmount(){this.disposeWorkspace()}workspace=null;blocklyDivRef=de.createRef();initializeBlockly(){if(this.blocklyDivRef.current)try{Gl(),this.registerMazeGenerators();const h=Pl(),r=this.props.config.toolbox,l=h.utils.xml.textToDom(r);this.workspace=h.inject(this.blocklyDivRef.current,{toolbox:l,scrollbars:!0,trashcan:!0,grid:{spacing:20,length:3,colour:"#ccc",snap:!0},zoom:{controls:!0,wheel:!0,startScale:1,maxScale:3,minScale:.3,scaleSpeed:1.2}}),this.loadXml(this.props.config.initialXml),this.workspace.addChangeListener(this.onAnyChange),this.setState({workspace:this.workspace,isInitialized:!0}),this.props.onWorkspaceChange?.(this.workspace),setTimeout(()=>{this.generateCode()},100)}catch(h){console.error("Failed to initialize Blockly:",h)}}registerMazeGenerators(){try{const h=xl();h.maze_move_forward=function(){return`moveForward();
1055
- `},h.maze_turn_left=function(){return`turnLeft();
1056
- `},h.maze_turn_right=function(){return`turnRight();
1057
- `},h.maze_turn_around=function(){return`turnAround();
1058
- `};const r=h;r.forBlock&&(r.forBlock.maze_move_forward=function(){return`moveForward();
1053
+ */var Gh,u_;function qv(){if(u_)return Gh;u_=1;var h=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;function l(m){if(m==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(m)}function g(){try{if(!Object.assign)return!1;var m=new String("abc");if(m[5]="de",Object.getOwnPropertyNames(m)[0]==="5")return!1;for(var y={},k=0;k<10;k++)y["_"+String.fromCharCode(k)]=k;var A=Object.getOwnPropertyNames(y).map(function(H){return y[H]});if(A.join("")!=="0123456789")return!1;var D={};return"abcdefghijklmnopqrst".split("").forEach(function(H){D[H]=H}),Object.keys(Object.assign({},D)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Gh=g()?Object.assign:function(m,y){for(var k,A=l(m),D,H=1;H<arguments.length;H++){k=Object(arguments[H]);for(var W in k)a.call(k,W)&&(A[W]=k[W]);if(h){D=h(k);for(var X=0;X<D.length;X++)r.call(k,D[X])&&(A[D[X]]=k[D[X]])}}return A},Gh}var Vh,a_;function ud(){if(a_)return Vh;a_=1;var h="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Vh=h,Vh}var Wh,h_;function A_(){return h_||(h_=1,Wh=Function.call.bind(Object.prototype.hasOwnProperty)),Wh}var zh,d_;function Zv(){if(d_)return zh;d_=1;var h=function(){};if(process.env.NODE_ENV!=="production"){var a=ud(),r={},l=A_();h=function(m){var y="Warning: "+m;typeof console<"u"&&console.error(y);try{throw new Error(y)}catch{}}}function g(m,y,k,A,D){if(process.env.NODE_ENV!=="production"){for(var H in m)if(l(m,H)){var W;try{if(typeof m[H]!="function"){var X=Error((A||"React class")+": "+k+" type `"+H+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof m[H]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw X.name="Invariant Violation",X}W=m[H](y,H,A,k,null,a)}catch(ie){W=ie}if(W&&!(W instanceof Error)&&h((A||"React class")+": type specification of "+k+" `"+H+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof W+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),W instanceof Error&&!(W.message in r)){r[W.message]=!0;var ue=D?D():"";h("Failed "+k+" type: "+W.message+(ue??""))}}}}return g.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(r={})},zh=g,zh}var Yh,$_;function Qv(){if($_)return Yh;$_=1;var h=N_(),a=qv(),r=ud(),l=A_(),g=Zv(),m=function(){};process.env.NODE_ENV!=="production"&&(m=function(k){var A="Warning: "+k;typeof console<"u"&&console.error(A);try{throw new Error(A)}catch{}});function y(){return null}return Yh=function(k,A){var D=typeof Symbol=="function"&&Symbol.iterator,H="@@iterator";function W(_){var F=_&&(D&&_[D]||_[H]);if(typeof F=="function")return F}var X="<<anonymous>>",ue={array:me("array"),bigint:me("bigint"),bool:me("boolean"),func:me("function"),number:me("number"),object:me("object"),string:me("string"),symbol:me("symbol"),any:z(),arrayOf:ae,element:te(),elementType:Y(),instanceOf:Ie,node:rt(),objectOf:It,oneOf:Ye,oneOfType:Re,shape:Bt,exact:Ct};function ie(_,F){return _===F?_!==0||1/_===1/F:_!==_&&F!==F}function K(_,F){this.message=_,this.data=F&&typeof F=="object"?F:{},this.stack=""}K.prototype=Error.prototype;function ee(_){if(process.env.NODE_ENV!=="production")var F={},Q=0;function ne(he,J,$e,ce,_e,U,Xe){if(ce=ce||X,U=U||$e,Xe!==r){if(A){var v=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw v.name="Invariant Violation",v}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var G=ce+":"+$e;!F[G]&&Q<3&&(m("You are manually calling a React.PropTypes validation function for the `"+U+"` prop on `"+ce+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),F[G]=!0,Q++)}}return J[$e]==null?he?J[$e]===null?new K("The "+_e+" `"+U+"` is marked as required "+("in `"+ce+"`, but its value is `null`.")):new K("The "+_e+" `"+U+"` is marked as required in "+("`"+ce+"`, but its value is `undefined`.")):null:_(J,$e,ce,_e,U)}var le=ne.bind(null,!1);return le.isRequired=ne.bind(null,!0),le}function me(_){function F(Q,ne,le,he,J,$e){var ce=Q[ne],_e=lt(ce);if(_e!==_){var U=$t(ce);return new K("Invalid "+he+" `"+J+"` of type "+("`"+U+"` supplied to `"+le+"`, expected ")+("`"+_+"`."),{expectedType:_})}return null}return ee(F)}function z(){return ee(y)}function ae(_){function F(Q,ne,le,he,J){if(typeof _!="function")return new K("Property `"+J+"` of component `"+le+"` has invalid PropType notation inside arrayOf.");var $e=Q[ne];if(!Array.isArray($e)){var ce=lt($e);return new K("Invalid "+he+" `"+J+"` of type "+("`"+ce+"` supplied to `"+le+"`, expected an array."))}for(var _e=0;_e<$e.length;_e++){var U=_($e,_e,le,he,J+"["+_e+"]",r);if(U instanceof Error)return U}return null}return ee(F)}function te(){function _(F,Q,ne,le,he){var J=F[Q];if(!k(J)){var $e=lt(J);return new K("Invalid "+le+" `"+he+"` of type "+("`"+$e+"` supplied to `"+ne+"`, expected a single ReactElement."))}return null}return ee(_)}function Y(){function _(F,Q,ne,le,he){var J=F[Q];if(!h.isValidElementType(J)){var $e=lt(J);return new K("Invalid "+le+" `"+he+"` of type "+("`"+$e+"` supplied to `"+ne+"`, expected a single ReactElement type."))}return null}return ee(_)}function Ie(_){function F(Q,ne,le,he,J){if(!(Q[ne]instanceof _)){var $e=_.name||X,ce=Ue(Q[ne]);return new K("Invalid "+he+" `"+J+"` of type "+("`"+ce+"` supplied to `"+le+"`, expected ")+("instance of `"+$e+"`."))}return null}return ee(F)}function Ye(_){if(!Array.isArray(_))return process.env.NODE_ENV!=="production"&&(arguments.length>1?m("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):m("Invalid argument supplied to oneOf, expected an array.")),y;function F(Q,ne,le,he,J){for(var $e=Q[ne],ce=0;ce<_.length;ce++)if(ie($e,_[ce]))return null;var _e=JSON.stringify(_,function(Xe,v){var G=$t(v);return G==="symbol"?String(v):v});return new K("Invalid "+he+" `"+J+"` of value `"+String($e)+"` "+("supplied to `"+le+"`, expected one of "+_e+"."))}return ee(F)}function It(_){function F(Q,ne,le,he,J){if(typeof _!="function")return new K("Property `"+J+"` of component `"+le+"` has invalid PropType notation inside objectOf.");var $e=Q[ne],ce=lt($e);if(ce!=="object")return new K("Invalid "+he+" `"+J+"` of type "+("`"+ce+"` supplied to `"+le+"`, expected an object."));for(var _e in $e)if(l($e,_e)){var U=_($e,_e,le,he,J+"."+_e,r);if(U instanceof Error)return U}return null}return ee(F)}function Re(_){if(!Array.isArray(_))return process.env.NODE_ENV!=="production"&&m("Invalid argument supplied to oneOfType, expected an instance of array."),y;for(var F=0;F<_.length;F++){var Q=_[F];if(typeof Q!="function")return m("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+St(Q)+" at index "+F+"."),y}function ne(le,he,J,$e,ce){for(var _e=[],U=0;U<_.length;U++){var Xe=_[U],v=Xe(le,he,J,$e,ce,r);if(v==null)return null;v.data&&l(v.data,"expectedType")&&_e.push(v.data.expectedType)}var G=_e.length>0?", expected one of type ["+_e.join(", ")+"]":"";return new K("Invalid "+$e+" `"+ce+"` supplied to "+("`"+J+"`"+G+"."))}return ee(ne)}function rt(){function _(F,Q,ne,le,he){return nt(F[Q])?null:new K("Invalid "+le+" `"+he+"` supplied to "+("`"+ne+"`, expected a ReactNode."))}return ee(_)}function bt(_,F,Q,ne,le){return new K((_||"React class")+": "+F+" type `"+Q+"."+ne+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+le+"`.")}function Bt(_){function F(Q,ne,le,he,J){var $e=Q[ne],ce=lt($e);if(ce!=="object")return new K("Invalid "+he+" `"+J+"` of type `"+ce+"` "+("supplied to `"+le+"`, expected `object`."));for(var _e in _){var U=_[_e];if(typeof U!="function")return bt(le,he,J,_e,$t(U));var Xe=U($e,_e,le,he,J+"."+_e,r);if(Xe)return Xe}return null}return ee(F)}function Ct(_){function F(Q,ne,le,he,J){var $e=Q[ne],ce=lt($e);if(ce!=="object")return new K("Invalid "+he+" `"+J+"` of type `"+ce+"` "+("supplied to `"+le+"`, expected `object`."));var _e=a({},Q[ne],_);for(var U in _e){var Xe=_[U];if(l(_,U)&&typeof Xe!="function")return bt(le,he,J,U,$t(Xe));if(!Xe)return new K("Invalid "+he+" `"+J+"` key `"+U+"` supplied to `"+le+"`.\nBad object: "+JSON.stringify(Q[ne],null," ")+`
1054
+ Valid keys: `+JSON.stringify(Object.keys(_),null," "));var v=Xe($e,U,le,he,J+"."+U,r);if(v)return v}return null}return ee(F)}function nt(_){switch(typeof _){case"number":case"string":case"undefined":return!0;case"boolean":return!_;case"object":if(Array.isArray(_))return _.every(nt);if(_===null||k(_))return!0;var F=W(_);if(F){var Q=F.call(_),ne;if(F!==_.entries){for(;!(ne=Q.next()).done;)if(!nt(ne.value))return!1}else for(;!(ne=Q.next()).done;){var le=ne.value;if(le&&!nt(le[1]))return!1}}else return!1;return!0;default:return!1}}function Tt(_,F){return _==="symbol"?!0:F?F["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&F instanceof Symbol:!1}function lt(_){var F=typeof _;return Array.isArray(_)?"array":_ instanceof RegExp?"object":Tt(F,_)?"symbol":F}function $t(_){if(typeof _>"u"||_===null)return""+_;var F=lt(_);if(F==="object"){if(_ instanceof Date)return"date";if(_ instanceof RegExp)return"regexp"}return F}function St(_){var F=$t(_);switch(F){case"array":case"object":return"an "+F;case"boolean":case"date":case"regexp":return"a "+F;default:return F}}function Ue(_){return!_.constructor||!_.constructor.name?X:_.constructor.name}return ue.checkPropTypes=g,ue.resetWarningCache=g.resetWarningCache,ue.PropTypes=ue,ue},Yh}var Xh,p_;function eI(){if(p_)return Xh;p_=1;var h=ud();function a(){}function r(){}return r.resetWarningCache=a,Xh=function(){function l(y,k,A,D,H,W){if(W!==h){var X=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw X.name="Invariant Violation",X}}l.isRequired=l;function g(){return l}var m={array:l,bigint:l,bool:l,func:l,number:l,object:l,string:l,symbol:l,any:l,arrayOf:g,element:l,elementType:l,instanceOf:g,node:l,objectOf:g,oneOf:g,oneOfType:g,shape:g,exact:g,checkPropTypes:r,resetWarningCache:a};return m.PropTypes=m,m},Xh}var g_;function tI(){if(g_)return Al.exports;if(g_=1,process.env.NODE_ENV!=="production"){var h=N_(),a=!0;Al.exports=Qv()(h.isElement,a)}else Al.exports=eI()();return Al.exports}var oI=tI();const ge=xi(oI),m_={disabled:!1};var sI=process.env.NODE_ENV!=="production"?ge.oneOfType([ge.number,ge.shape({enter:ge.number,exit:ge.number,appear:ge.number}).isRequired]):null;process.env.NODE_ENV!=="production"&&ge.oneOfType([ge.string,ge.shape({enter:ge.string,exit:ge.string,active:ge.string}),ge.shape({enter:ge.string,enterDone:ge.string,enterActive:ge.string,exit:ge.string,exitDone:ge.string,exitActive:ge.string})]);const L_=de.createContext(null);var iI=function(a){return a.scrollTop},xr="unmounted",Vs="exited",ps="entering",Ws="entered",td="exiting",Jo=(function(h){Pv(a,h);function a(l,g){var m;m=h.call(this,l,g)||this;var y=g,k=y&&!y.isMounting?l.enter:l.appear,A;return m.appearStatus=null,l.in?k?(A=Vs,m.appearStatus=ps):A=Ws:l.unmountOnExit||l.mountOnEnter?A=xr:A=Vs,m.state={status:A},m.nextCallback=null,m}a.getDerivedStateFromProps=function(g,m){var y=g.in;return y&&m.status===xr?{status:Vs}:null};var r=a.prototype;return r.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},r.componentDidUpdate=function(g){var m=null;if(g!==this.props){var y=this.state.status;this.props.in?y!==ps&&y!==Ws&&(m=ps):(y===ps||y===Ws)&&(m=td)}this.updateStatus(!1,m)},r.componentWillUnmount=function(){this.cancelNextCallback()},r.getTimeouts=function(){var g=this.props.timeout,m,y,k;return m=y=k=g,g!=null&&typeof g!="number"&&(m=g.exit,y=g.enter,k=g.appear!==void 0?g.appear:y),{exit:m,enter:y,appear:k}},r.updateStatus=function(g,m){if(g===void 0&&(g=!1),m!==null)if(this.cancelNextCallback(),m===ps){if(this.props.unmountOnExit||this.props.mountOnEnter){var y=this.props.nodeRef?this.props.nodeRef.current:Dr.findDOMNode(this);y&&iI(y)}this.performEnter(g)}else this.performExit();else this.props.unmountOnExit&&this.state.status===Vs&&this.setState({status:xr})},r.performEnter=function(g){var m=this,y=this.props.enter,k=this.context?this.context.isMounting:g,A=this.props.nodeRef?[k]:[Dr.findDOMNode(this),k],D=A[0],H=A[1],W=this.getTimeouts(),X=k?W.appear:W.enter;if(!g&&!y||m_.disabled){this.safeSetState({status:Ws},function(){m.props.onEntered(D)});return}this.props.onEnter(D,H),this.safeSetState({status:ps},function(){m.props.onEntering(D,H),m.onTransitionEnd(X,function(){m.safeSetState({status:Ws},function(){m.props.onEntered(D,H)})})})},r.performExit=function(){var g=this,m=this.props.exit,y=this.getTimeouts(),k=this.props.nodeRef?void 0:Dr.findDOMNode(this);if(!m||m_.disabled){this.safeSetState({status:Vs},function(){g.props.onExited(k)});return}this.props.onExit(k),this.safeSetState({status:td},function(){g.props.onExiting(k),g.onTransitionEnd(y.exit,function(){g.safeSetState({status:Vs},function(){g.props.onExited(k)})})})},r.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},r.safeSetState=function(g,m){m=this.setNextCallback(m),this.setState(g,m)},r.setNextCallback=function(g){var m=this,y=!0;return this.nextCallback=function(k){y&&(y=!1,m.nextCallback=null,g(k))},this.nextCallback.cancel=function(){y=!1},this.nextCallback},r.onTransitionEnd=function(g,m){this.setNextCallback(m);var y=this.props.nodeRef?this.props.nodeRef.current:Dr.findDOMNode(this),k=g==null&&!this.props.addEndListener;if(!y||k){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var A=this.props.nodeRef?[this.nextCallback]:[y,this.nextCallback],D=A[0],H=A[1];this.props.addEndListener(D,H)}g!=null&&setTimeout(this.nextCallback,g)},r.render=function(){var g=this.state.status;if(g===xr)return null;var m=this.props,y=m.children;m.in,m.mountOnEnter,m.unmountOnExit,m.appear,m.enter,m.exit,m.timeout,m.addEndListener,m.onEnter,m.onEntering,m.onEntered,m.onExit,m.onExiting,m.onExited,m.nodeRef;var k=k_(m,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return de.createElement(L_.Provider,{value:null},typeof y=="function"?y(g,k):de.cloneElement(de.Children.only(y),k))},a})(de.Component);Jo.contextType=L_;Jo.propTypes=process.env.NODE_ENV!=="production"?{nodeRef:ge.shape({current:typeof Element>"u"?ge.any:function(h,a,r,l,g,m){var y=h[a];return ge.instanceOf(y&&"ownerDocument"in y?y.ownerDocument.defaultView.Element:Element)(h,a,r,l,g,m)}}),children:ge.oneOfType([ge.func.isRequired,ge.element.isRequired]).isRequired,in:ge.bool,mountOnEnter:ge.bool,unmountOnExit:ge.bool,appear:ge.bool,enter:ge.bool,exit:ge.bool,timeout:function(a){var r=sI;a.addEndListener||(r=r.isRequired);for(var l=arguments.length,g=new Array(l>1?l-1:0),m=1;m<l;m++)g[m-1]=arguments[m];return r.apply(void 0,[a].concat(g))},addEndListener:ge.func,onEnter:ge.func,onEntering:ge.func,onEntered:ge.func,onExit:ge.func,onExiting:ge.func,onExited:ge.func}:{};function Li(){}Jo.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:Li,onEntering:Li,onEntered:Li,onExit:Li,onExiting:Li,onExited:Li};Jo.UNMOUNTED=xr;Jo.EXITED=Vs;Jo.ENTERING=ps;Jo.ENTERED=Ws;Jo.EXITING=td;function rI(){const h=fe.version.split(".");return{major:+h[0],minor:+h[1],patch:+h[2]}}function nI(h){if(!h||typeof h=="function")return null;const{major:a}=rI();return a>=19?h.props.ref:h.ref}const lI=!!(typeof window<"u"&&window.document&&window.document.createElement);var od=!1,sd=!1;try{var jh={get passive(){return od=!0},get once(){return sd=od=!0}};lI&&(window.addEventListener("test",jh,jh),window.removeEventListener("test",jh,!0))}catch{}function cI(h,a,r,l){if(l&&typeof l!="boolean"&&!sd){var g=l.once,m=l.capture,y=r;!sd&&g&&(y=r.__once||function k(A){this.removeEventListener(a,k,m),r.call(this,A)},r.__once=y),h.addEventListener(a,y,od?l:m)}h.addEventListener(a,r,l)}function uI(h,a,r,l){var g=l&&typeof l!="boolean"?l.capture:l;h.removeEventListener(a,r,g),r.__once&&h.removeEventListener(a,r.__once,g)}function M_(h,a,r,l){return cI(h,a,r,l),function(){uI(h,a,r,l)}}function aI(h,a,r,l){if(l===void 0&&(l=!0),h){var g=document.createEvent("HTMLEvents");g.initEvent(a,r,l),h.dispatchEvent(g)}}function hI(h){var a=O_(h,"transitionDuration")||"",r=a.indexOf("ms")===-1?1e3:1;return parseFloat(a)*r}function dI(h,a,r){r===void 0&&(r=5);var l=!1,g=setTimeout(function(){l||aI(h,"transitionend",!0)},a+r),m=M_(h,"transitionend",function(){l=!0},{once:!0});return function(){clearTimeout(g),m()}}function $I(h,a,r,l){r==null&&(r=hI(h)||0);var g=dI(h,r,l),m=M_(h,"transitionend",a);return function(){g(),m()}}function f_(h,a){const r=O_(h,a)||"",l=r.indexOf("ms")===-1?1e3:1;return parseFloat(r)*l}function pI(h,a){const r=f_(h,"transitionDuration"),l=f_(h,"transitionDelay"),g=$I(h,m=>{m.target===h&&(g(),a(m))},r+l)}function gI(h){h.offsetHeight}const __=h=>!h||typeof h=="function"?h:a=>{h.current=a};function mI(h,a){const r=__(h),l=__(a);return g=>{r&&r(g),l&&l(g)}}function fI(h,a){return de.useMemo(()=>mI(h,a),[h,a])}function _I(h){return h&&"setState"in h?Dr.findDOMNode(h):h??null}const D_=de.forwardRef(({onEnter:h,onEntering:a,onEntered:r,onExit:l,onExiting:g,onExited:m,addEndListener:y,children:k,childRef:A,...D},H)=>{const W=de.useRef(null),X=fI(W,A),ue=Ie=>{X(_I(Ie))},ie=Ie=>Ye=>{Ie&&W.current&&Ie(W.current,Ye)},K=de.useCallback(ie(h),[h]),ee=de.useCallback(ie(a),[a]),me=de.useCallback(ie(r),[r]),z=de.useCallback(ie(l),[l]),ae=de.useCallback(ie(g),[g]),te=de.useCallback(ie(m),[m]),Y=de.useCallback(ie(y),[y]);return B.jsx(Jo,{ref:H,...D,onEnter:K,onEntered:me,onEntering:ee,onExit:z,onExited:te,onExiting:ae,addEndListener:Y,nodeRef:W,children:typeof k=="function"?(Ie,Ye)=>k(Ie,{...Ye,ref:ue}):de.cloneElement(k,{ref:ue})})});D_.displayName="TransitionWrapper";function bI(h){const a=de.useRef(h);return de.useEffect(()=>{a.current=h},[h]),a}function TI(h){const a=bI(h);return de.useCallback(function(...r){return a.current&&a.current(...r)},[a])}const ad=(h=>fe.forwardRef((a,r)=>B.jsx("div",{...a,ref:r,className:Se(a.className,h)}))),x_=ad("h4");x_.displayName="DivStyledAsH4";const B_=fe.forwardRef(({className:h,bsPrefix:a,as:r=x_,...l},g)=>(a=xe(a,"alert-heading"),B.jsx(r,{ref:g,className:Se(h,a),...l})));B_.displayName="AlertHeading";function EI(h){const a=de.useRef(h);return de.useEffect(()=>{a.current=h},[h]),a}function yI(h){const a=EI(h);return de.useCallback(function(...r){return a.current&&a.current(...r)},[a])}const vI=["as","disabled"];function II(h,a){if(h==null)return{};var r={};for(var l in h)if({}.hasOwnProperty.call(h,l)){if(a.indexOf(l)>=0)continue;r[l]=h[l]}return r}function CI(h){return!h||h.trim()==="#"}function hd({tagName:h,disabled:a,href:r,target:l,rel:g,role:m,onClick:y,tabIndex:k=0,type:A}){h||(r!=null||l!=null||g!=null?h="a":h="button");const D={tagName:h};if(h==="button")return[{type:A||"button",disabled:a},D];const H=X=>{if((a||h==="a"&&CI(r))&&X.preventDefault(),a){X.stopPropagation();return}y?.(X)},W=X=>{X.key===" "&&(X.preventDefault(),H(X))};return h==="a"&&(r||(r="#"),a&&(r=void 0)),[{role:m??"button",disabled:void 0,tabIndex:a?void 0:k,href:r,target:h==="a"?l:void 0,"aria-disabled":a||void 0,rel:h==="a"?g:void 0,onClick:H,onKeyDown:W},D]}const SI=fe.forwardRef((h,a)=>{let{as:r,disabled:l}=h,g=II(h,vI);const[m,{tagName:y}]=hd(Object.assign({tagName:r,disabled:l},g));return B.jsx(y,Object.assign({},g,m,{ref:a}))});SI.displayName="Button";const kI=["onKeyDown"];function RI(h,a){if(h==null)return{};var r={};for(var l in h)if({}.hasOwnProperty.call(h,l)){if(a.indexOf(l)>=0)continue;r[l]=h[l]}return r}function wI(h){return!h||h.trim()==="#"}const P_=fe.forwardRef((h,a)=>{let{onKeyDown:r}=h,l=RI(h,kI);const[g]=hd(Object.assign({tagName:"a"},l)),m=yI(y=>{g.onKeyDown(y),r?.(y)});return wI(l.href)||l.role==="button"?B.jsx("a",Object.assign({ref:a},l,g,{onKeyDown:m})):B.jsx("a",Object.assign({ref:a},l,{onKeyDown:r}))});P_.displayName="Anchor";const F_=fe.forwardRef(({className:h,bsPrefix:a,as:r=P_,...l},g)=>(a=xe(a,"alert-link"),B.jsx(r,{ref:g,className:Se(h,a),...l})));F_.displayName="AlertLink";const OI={[ps]:"show",[Ws]:"show"},id=fe.forwardRef(({className:h,children:a,transitionClasses:r={},onEnter:l,...g},m)=>{const y={in:!1,timeout:300,mountOnEnter:!1,unmountOnExit:!1,appear:!1,...g},k=de.useCallback((A,D)=>{gI(A),l?.(A,D)},[l]);return B.jsx(D_,{ref:m,addEndListener:pI,...y,onEnter:k,childRef:nI(a),children:(A,D)=>fe.cloneElement(a,{...D,className:Se("fade",h,a.props.className,OI[A],r[A])})})});id.displayName="Fade";const NI={"aria-label":ge.string,onClick:ge.func,variant:ge.oneOf(["white"])},dd=fe.forwardRef(({className:h,variant:a,"aria-label":r="Close",...l},g)=>B.jsx("button",{ref:g,type:"button",className:Se("btn-close",a&&`btn-close-${a}`,h),"aria-label":r,...l}));dd.displayName="CloseButton";dd.propTypes=NI;const U_=fe.forwardRef((h,a)=>{const{bsPrefix:r,show:l=!0,closeLabel:g="Close alert",closeVariant:m,className:y,children:k,variant:A="primary",onClose:D,dismissible:H,transition:W=id,...X}=Bv(h,{show:"onClose"}),ue=xe(r,"alert"),ie=TI(me=>{D&&D(!1,me)}),K=W===!0?id:W,ee=B.jsxs("div",{role:"alert",...K?void 0:X,ref:a,className:Se(y,ue,A&&`${ue}-${A}`,H&&`${ue}-dismissible`),children:[H&&B.jsx(dd,{onClick:ie,"aria-label":g,variant:m}),k]});return K?B.jsx(K,{unmountOnExit:!0,...X,ref:void 0,in:l,children:ee}):l?ee:null});U_.displayName="Alert";const b_=Object.assign(U_,{Link:F_,Heading:B_}),Di=fe.forwardRef(({bsPrefix:h,bg:a="primary",pill:r=!1,text:l,className:g,as:m="span",...y},k)=>{const A=xe(h,"badge");return B.jsx(m,{ref:k,...y,className:Se(g,A,r&&"rounded-pill",l&&`text-${l}`,a&&`bg-${a}`)})});Di.displayName="Badge";const Lo=fe.forwardRef(({as:h,bsPrefix:a,variant:r="primary",size:l,active:g=!1,disabled:m=!1,className:y,...k},A)=>{const D=xe(a,"btn"),[H,{tagName:W}]=hd({tagName:h,disabled:m,...k}),X=W;return B.jsx(X,{...H,...k,ref:A,disabled:m,className:Se(y,D,g&&"active",r&&`${D}-${r}`,l&&`${D}-${l}`,k.href&&m&&"disabled")})});Lo.displayName="Button";const rd=fe.forwardRef(({bsPrefix:h,size:a,vertical:r=!1,className:l,role:g="group",as:m="div",...y},k)=>{const A=xe(h,"btn-group");let D=A;return r&&(D=`${A}-vertical`),B.jsx(m,{...y,ref:k,role:g,className:Se(l,D,a&&`${A}-${a}`)})});rd.displayName="ButtonGroup";const $d=fe.forwardRef(({className:h,bsPrefix:a,as:r="div",...l},g)=>(a=xe(a,"card-body"),B.jsx(r,{ref:g,className:Se(h,a),...l})));$d.displayName="CardBody";const H_=fe.forwardRef(({className:h,bsPrefix:a,as:r="div",...l},g)=>(a=xe(a,"card-footer"),B.jsx(r,{ref:g,className:Se(h,a),...l})));H_.displayName="CardFooter";const G_=fe.createContext(null);G_.displayName="CardHeaderContext";const V_=fe.forwardRef(({bsPrefix:h,className:a,as:r="div",...l},g)=>{const m=xe(h,"card-header"),y=de.useMemo(()=>({cardHeaderBsPrefix:m}),[m]);return B.jsx(G_.Provider,{value:y,children:B.jsx(r,{ref:g,...l,className:Se(a,m)})})});V_.displayName="CardHeader";const W_=fe.forwardRef(({bsPrefix:h,className:a,variant:r,as:l="img",...g},m)=>{const y=xe(h,"card-img");return B.jsx(l,{ref:m,className:Se(r?`${y}-${r}`:y,a),...g})});W_.displayName="CardImg";const z_=fe.forwardRef(({className:h,bsPrefix:a,as:r="div",...l},g)=>(a=xe(a,"card-img-overlay"),B.jsx(r,{ref:g,className:Se(h,a),...l})));z_.displayName="CardImgOverlay";const Y_=fe.forwardRef(({className:h,bsPrefix:a,as:r="a",...l},g)=>(a=xe(a,"card-link"),B.jsx(r,{ref:g,className:Se(h,a),...l})));Y_.displayName="CardLink";const AI=ad("h6"),X_=fe.forwardRef(({className:h,bsPrefix:a,as:r=AI,...l},g)=>(a=xe(a,"card-subtitle"),B.jsx(r,{ref:g,className:Se(h,a),...l})));X_.displayName="CardSubtitle";const j_=fe.forwardRef(({className:h,bsPrefix:a,as:r="p",...l},g)=>(a=xe(a,"card-text"),B.jsx(r,{ref:g,className:Se(h,a),...l})));j_.displayName="CardText";const LI=ad("h5"),K_=fe.forwardRef(({className:h,bsPrefix:a,as:r=LI,...l},g)=>(a=xe(a,"card-title"),B.jsx(r,{ref:g,className:Se(h,a),...l})));K_.displayName="CardTitle";const J_=fe.forwardRef(({bsPrefix:h,className:a,bg:r,text:l,border:g,body:m=!1,children:y,as:k="div",...A},D)=>{const H=xe(h,"card");return B.jsx(k,{ref:D,...A,className:Se(a,H,r&&`bg-${r}`,l&&`text-${l}`,g&&`border-${g}`),children:m?B.jsx($d,{children:y}):y})});J_.displayName="Card";const Br=Object.assign(J_,{Img:W_,Title:K_,Subtitle:X_,Body:$d,Link:Y_,Text:j_,Header:V_,Footer:H_,ImgOverlay:z_});function MI(h,a){return fe.Children.toArray(h).some(r=>fe.isValidElement(r)&&r.type===a)}function DI({as:h,bsPrefix:a,className:r,...l}){a=xe(a,"col");const g=R_(),m=w_(),y=[],k=[];return g.forEach(A=>{const D=l[A];delete l[A];let H,W,X;typeof D=="object"&&D!=null?{span:H,offset:W,order:X}=D:H=D;const ue=A!==m?`-${A}`:"";H&&y.push(H===!0?`${a}${ue}`:`${a}${ue}-${H}`),X!=null&&k.push(`order${ue}-${X}`),W!=null&&k.push(`offset${ue}-${W}`)}),[{...l,className:Se(r,...y,...k)},{as:h,bsPrefix:a,spans:y}]}const gs=fe.forwardRef((h,a)=>{const[{className:r,...l},{as:g="div",bsPrefix:m,spans:y}]=DI(h);return B.jsx(g,{...l,ref:a,className:Se(r,!y.length&&m)})});gs.displayName="Col";const q_=fe.forwardRef(({bsPrefix:h,fluid:a=!1,as:r="div",className:l,...g},m)=>{const y=xe(h,"container"),k=typeof a=="string"?`-${a}`:"-fluid";return B.jsx(r,{ref:m,...g,className:Se(l,a?`${y}${k}`:y)})});q_.displayName="Container";var Kh,T_;function xI(){if(T_)return Kh;T_=1;var h=process.env.NODE_ENV!=="production",a=function(){};if(h){var r=function(g,m){var y=arguments.length;m=new Array(y>1?y-1:0);for(var k=1;k<y;k++)m[k-1]=arguments[k];var A=0,D="Warning: "+g.replace(/%s/g,function(){return m[A++]});typeof console<"u"&&console.error(D);try{throw new Error(D)}catch{}};a=function(l,g,m){var y=arguments.length;m=new Array(y>2?y-2:0);for(var k=2;k<y;k++)m[k-2]=arguments[k];if(g===void 0)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");l||r.apply(null,[g].concat(m))}}return Kh=a,Kh}var BI=xI();const Z_=xi(BI),PI={type:ge.string,tooltip:ge.bool,as:ge.elementType},Yl=fe.forwardRef(({as:h="div",className:a,type:r="valid",tooltip:l=!1,...g},m)=>B.jsx(h,{...g,ref:m,className:Se(a,`${r}-${l?"tooltip":"feedback"}`)}));Yl.displayName="Feedback";Yl.propTypes=PI;const Ko=fe.createContext({}),pd=fe.forwardRef(({id:h,bsPrefix:a,className:r,type:l="checkbox",isValid:g=!1,isInvalid:m=!1,as:y="input",...k},A)=>{const{controlId:D}=de.useContext(Ko);return a=xe(a,"form-check-input"),B.jsx(y,{...k,ref:A,type:l,id:h||D,className:Se(r,a,g&&"is-valid",m&&"is-invalid")})});pd.displayName="FormCheckInput";const Hl=fe.forwardRef(({bsPrefix:h,className:a,htmlFor:r,...l},g)=>{const{controlId:m}=de.useContext(Ko);return h=xe(h,"form-check-label"),B.jsx("label",{...l,ref:g,htmlFor:r||m,className:Se(a,h)})});Hl.displayName="FormCheckLabel";const Q_=fe.forwardRef(({id:h,bsPrefix:a,bsSwitchPrefix:r,inline:l=!1,reverse:g=!1,disabled:m=!1,isValid:y=!1,isInvalid:k=!1,feedbackTooltip:A=!1,feedback:D,feedbackType:H,className:W,style:X,title:ue="",type:ie="checkbox",label:K,children:ee,as:me="input",...z},ae)=>{a=xe(a,"form-check"),r=xe(r,"form-switch");const{controlId:te}=de.useContext(Ko),Y=de.useMemo(()=>({controlId:h||te}),[te,h]),Ie=!ee&&K!=null&&K!==!1||MI(ee,Hl),Ye=B.jsx(pd,{...z,type:ie==="switch"?"checkbox":ie,ref:ae,isValid:y,isInvalid:k,disabled:m,as:me});return B.jsx(Ko.Provider,{value:Y,children:B.jsx("div",{style:X,className:Se(W,Ie&&a,l&&`${a}-inline`,g&&`${a}-reverse`,ie==="switch"&&r),children:ee||B.jsxs(B.Fragment,{children:[Ye,Ie&&B.jsx(Hl,{title:ue,children:K}),D&&B.jsx(Yl,{type:H,tooltip:A,children:D})]})})})});Q_.displayName="FormCheck";const Gl=Object.assign(Q_,{Input:pd,Label:Hl}),eb=fe.forwardRef(({bsPrefix:h,type:a,size:r,htmlSize:l,id:g,className:m,isValid:y=!1,isInvalid:k=!1,plaintext:A,readOnly:D,as:H="input",...W},X)=>{const{controlId:ue}=de.useContext(Ko);return h=xe(h,"form-control"),process.env.NODE_ENV!=="production"&&Z_(ue==null||!g,"`controlId` is ignored on `<FormControl>` when `id` is specified."),B.jsx(H,{...W,type:a,size:l,ref:X,readOnly:D,id:g||ue,className:Se(m,A?`${h}-plaintext`:h,r&&`${h}-${r}`,a==="color"&&`${h}-color`,y&&"is-valid",k&&"is-invalid")})});eb.displayName="FormControl";const FI=Object.assign(eb,{Feedback:Yl}),tb=fe.forwardRef(({className:h,bsPrefix:a,as:r="div",...l},g)=>(a=xe(a,"form-floating"),B.jsx(r,{ref:g,className:Se(h,a),...l})));tb.displayName="FormFloating";const gd=fe.forwardRef(({controlId:h,as:a="div",...r},l)=>{const g=de.useMemo(()=>({controlId:h}),[h]);return B.jsx(Ko.Provider,{value:g,children:B.jsx(a,{...r,ref:l})})});gd.displayName="FormGroup";const ob=fe.forwardRef(({as:h="label",bsPrefix:a,column:r=!1,visuallyHidden:l=!1,className:g,htmlFor:m,...y},k)=>{const{controlId:A}=de.useContext(Ko);a=xe(a,"form-label");let D="col-form-label";typeof r=="string"&&(D=`${D} ${D}-${r}`);const H=Se(g,a,l&&"visually-hidden",r&&D);return process.env.NODE_ENV!=="production"&&Z_(A==null||!m,"`controlId` is ignored on `<FormLabel>` when `htmlFor` is specified."),m=m||A,r?B.jsx(gs,{ref:k,as:"label",className:H,htmlFor:m,...y}):B.jsx(h,{ref:k,className:H,htmlFor:m,...y})});ob.displayName="FormLabel";const sb=fe.forwardRef(({bsPrefix:h,className:a,id:r,...l},g)=>{const{controlId:m}=de.useContext(Ko);return h=xe(h,"form-range"),B.jsx("input",{...l,type:"range",ref:g,className:Se(a,h),id:r||m})});sb.displayName="FormRange";const ib=fe.forwardRef(({bsPrefix:h,size:a,htmlSize:r,className:l,isValid:g=!1,isInvalid:m=!1,id:y,...k},A)=>{const{controlId:D}=de.useContext(Ko);return h=xe(h,"form-select"),B.jsx("select",{...k,size:r,ref:A,className:Se(l,h,a&&`${h}-${a}`,g&&"is-valid",m&&"is-invalid"),id:y||D})});ib.displayName="FormSelect";const rb=fe.forwardRef(({bsPrefix:h,className:a,as:r="small",muted:l,...g},m)=>(h=xe(h,"form-text"),B.jsx(r,{...g,ref:m,className:Se(a,h,l&&"text-muted")})));rb.displayName="FormText";const nb=fe.forwardRef((h,a)=>B.jsx(Gl,{...h,ref:a,type:"switch"}));nb.displayName="Switch";const UI=Object.assign(nb,{Input:Gl.Input,Label:Gl.Label}),lb=fe.forwardRef(({bsPrefix:h,className:a,children:r,controlId:l,label:g,...m},y)=>(h=xe(h,"form-floating"),B.jsxs(gd,{ref:y,className:Se(a,h),controlId:l,...m,children:[r,B.jsx("label",{htmlFor:l,children:g})]})));lb.displayName="FloatingLabel";const HI={_ref:ge.any,validated:ge.bool,as:ge.elementType},md=fe.forwardRef(({className:h,validated:a,as:r="form",...l},g)=>B.jsx(r,{...l,ref:g,className:Se(h,a&&"was-validated")}));md.displayName="Form";md.propTypes=HI;const E_=Object.assign(md,{Group:gd,Control:FI,Floating:tb,Check:Gl,Switch:UI,Label:ob,Text:rb,Range:sb,Select:ib,FloatingLabel:lb}),Vl=fe.forwardRef(({bsPrefix:h,className:a,as:r="div",...l},g)=>{const m=xe(h,"row"),y=R_(),k=w_(),A=`${m}-cols`,D=[];return y.forEach(H=>{const W=l[H];delete l[H];let X;W!=null&&typeof W=="object"?{cols:X}=W:X=W;const ue=H!==k?`-${H}`:"";X!=null&&D.push(`${A}${ue}-${X}`)}),B.jsx(r,{ref:g,...l,className:Se(a,m,...D)})});Vl.displayName="Row";class cb extends de.Component{createMazeGrid(){const{width:a,height:r,walls:l,finishPosition:g}=this.props.config,m=[];for(let y=0;y<r;y++){m[y]=[];for(let k=0;k<a;k++){const A=l.some(H=>H.x===k&&H.y===y),D=g.x===k&&g.y===y;m[y][k]={isWall:A,isFinish:D,isSpider:!1,isPath:!A}}}return m}render(){const{config:a,cellSize:r}=this.props,{width:l,height:g}=a,m=this.createMazeGrid();return B.jsx("div",{style:{position:"relative",width:l*r,height:g*r,border:"2px solid #333",backgroundColor:"#f0f0f0"},children:m.map((y,k)=>y.map((A,D)=>B.jsxs("div",{style:{position:"absolute",left:D*r,top:k*r,width:r,height:r,backgroundColor:A.isWall?"#333":A.isFinish?"#90EE90":"#f0f0f0",border:"1px solid #ccc",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"bold"},children:[A.isFinish&&B.jsx("div",{style:{width:"80%",height:"80%",backgroundColor:"#32CD32",borderRadius:"50%",border:"3px solid #228B22",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontSize:"14px",fontWeight:"bold"},children:"🎯"}),A.isWall&&B.jsx("div",{style:{width:"100%",height:"100%",backgroundColor:"#333",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontSize:"12px"},children:"🧱"})]},`${D}-${k}`)))})}}class ub extends de.Component{render(){const{position:a,direction:r,size:l}=this.props,g=l,y={north:0,east:90,south:180,west:270}[r];return B.jsx("div",{style:{position:"absolute",left:a.x*g+g/2,top:a.y*g+g/2,width:g*.8,height:g*.8,transform:`translate(-50%, -50%) rotate(${y}deg)`,transition:"all 0.3s ease-in-out",zIndex:10},children:B.jsxs("div",{style:{width:"100%",height:"100%",backgroundColor:"#8B4513",borderRadius:"50%",border:"2px solid #654321",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:[B.jsx("div",{style:{width:"30%",height:"30%",backgroundColor:"#FF0000",borderRadius:"50%",position:"absolute",left:"20%",top:"20%",boxShadow:"0 0 5px #FF0000"}}),B.jsx("div",{style:{width:"30%",height:"30%",backgroundColor:"#FF0000",borderRadius:"50%",position:"absolute",right:"20%",top:"20%",boxShadow:"0 0 5px #FF0000"}})]})})}}const Xl=Ul();Xl.Blocks.maze_move_forward={init(){this.appendDummyInput().appendField("Move Forward"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(92),this.setTooltip("Move the spider forward one step"),this.setHelpUrl("")}};Xl.Blocks.maze_turn_left={init(){this.appendDummyInput().appendField("🔄 Turn Left"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(92),this.setTooltip("Turn the spider 90 degrees to the left"),this.setHelpUrl("")}};Xl.Blocks.maze_turn_right={init(){this.appendDummyInput().appendField("🔄 Turn Right"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(92),this.setTooltip("Turn the spider 90 degrees to the right"),this.setHelpUrl("")}};Xl.Blocks.maze_turn_around={init(){this.appendDummyInput().appendField("🔄 Turn Around"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(92),this.setTooltip("Turn the spider 180 degrees around"),this.setHelpUrl("")}};class ab extends de.Component{constructor(a){super(a),this.state={workspace:null,isInitialized:!1},this.onAnyChange=this.onAnyChange.bind(this)}componentDidMount(){console.log("[MazeBlocklyContainer] Component mounted, starting initialization..."),this.initializeBlockly()}componentDidUpdate(a){a.config.toolbox!==this.props.config.toolbox&&(this.disposeWorkspace(),this.initializeBlockly()),a.config.initialXml!==this.props.config.initialXml&&this.workspace&&this.loadXml(this.props.config.initialXml)}componentWillUnmount(){this.disposeWorkspace()}workspace=null;blocklyDivRef=de.createRef();async initializeBlockly(){if(!this.blocklyDivRef.current){console.error("[MazeBlocklyContainer] Blockly div ref is not available");return}try{console.log("[MazeBlocklyContainer] Starting Blockly initialization..."),console.log("[MazeBlocklyContainer] Calling initializeBlockly()..."),await Wl(),console.log("[MazeBlocklyContainer] Blockly initialization completed"),console.log("[MazeBlocklyContainer] Registering maze generators..."),this.registerMazeGenerators(),console.log("[MazeBlocklyContainer] Maze generators registered"),console.log("[MazeBlocklyContainer] Getting Blockly instance...");const a=Ul();console.log("[MazeBlocklyContainer] Blockly instance obtained:",!!a);const r=this.props.config.toolbox;console.log("[MazeBlocklyContainer] Parsing toolbox XML...");const l=a.utils.xml.textToDom(r);console.log("[MazeBlocklyContainer] Toolbox XML parsed successfully"),console.log("[MazeBlocklyContainer] Injecting Blockly workspace..."),this.workspace=a.inject(this.blocklyDivRef.current,{toolbox:l,scrollbars:!0,trashcan:!0,grid:{spacing:20,length:3,colour:"#ccc",snap:!0},zoom:{controls:!0,wheel:!0,startScale:1,maxScale:3,minScale:.3,scaleSpeed:1.2}}),console.log("[MazeBlocklyContainer] Workspace injected successfully:",!!this.workspace),console.log("[MazeBlocklyContainer] Loading initial XML..."),this.loadXml(this.props.config.initialXml),console.log("[MazeBlocklyContainer] Initial XML loaded"),console.log("[MazeBlocklyContainer] Adding change listener..."),this.workspace.addChangeListener(this.onAnyChange),console.log("[MazeBlocklyContainer] Change listener added"),this.setState({workspace:this.workspace,isInitialized:!0}),this.props.onWorkspaceChange?.(this.workspace),console.log("[MazeBlocklyContainer] Generating initial code..."),setTimeout(()=>{this.generateCode()},100),console.log("[MazeBlocklyContainer] ✅ Initialization completed successfully")}catch(a){console.error("[MazeBlocklyContainer] ❌ Failed to initialize Blockly:",a),console.error("[MazeBlocklyContainer] Error details:",a)}}registerMazeGenerators(){console.log("[MazeBlocklyContainer] Starting maze generator registration...");try{console.log("[MazeBlocklyContainer] Getting JavaScript generator...");const a=Pl();console.log("[MazeBlocklyContainer] JavaScript generator obtained:",!!a),console.log("[MazeBlocklyContainer] Registering generators via direct assignment..."),a.maze_move_forward=function(){return`moveForward();
1055
+ `},a.maze_turn_left=function(){return`turnLeft();
1056
+ `},a.maze_turn_right=function(){return`turnRight();
1057
+ `},a.maze_turn_around=function(){return`turnAround();
1058
+ `},console.log("[MazeBlocklyContainer] Direct assignment completed"),console.log("[MazeBlocklyContainer] Registering generators via forBlock property...");const r=a;r.forBlock?(r.forBlock.maze_move_forward=function(){return`moveForward();
1059
1059
  `},r.forBlock.maze_turn_left=function(){return`turnLeft();
1060
1060
  `},r.forBlock.maze_turn_right=function(){return`turnRight();
1061
1061
  `},r.forBlock.maze_turn_around=function(){return`turnAround();
1062
- `}),console.log("Maze generators registered successfully")}catch(h){console.error("Failed to register maze generators:",h)}}disposeWorkspace(){this.workspace&&(this.workspace.dispose(),this.workspace=null,this.setState({workspace:null,isInitialized:!1}))}onAnyChange(h){if(!this.workspace)return;const r=h?.type||"";(r==="block_create"||r==="block_move"||r==="block_delete"||r==="block_change")&&(this.props.onWorkspaceChange?.(this.workspace),this.generateCode())}generateCode(){if(!(!this.workspace||!this.props.onCodeChange))try{console.log("Generating code for workspace:",this.workspace),console.log("Available blocks:",this.workspace.getAllBlocks(!1));const r=xl().workspaceToCode(this.workspace);console.log("Generated code:",r),this.props.onCodeChange(r)}catch(h){console.error("Failed to generate code:",h),console.error("Error details:",h)}}loadXml(h){if(!(!this.workspace||!h))try{const r=Pl(),l=r.utils.xml.textToDom(h);r.Xml.domToWorkspace(l,this.workspace)}catch(r){console.error("Failed to load XML:",r)}}executeCode(){if(!this.workspace)return[];try{console.log("Executing maze code..."),console.log("Workspace state:",this.workspace);const r=xl().workspaceToCode(this.workspace);console.log("Executing maze code:",r);const l=this.parseMovementCode(r);return console.log("Parsed movement commands:",l),this.props.onExecuteCode&&this.props.onExecuteCode(l),l}catch(h){return console.error("Failed to execute code:",h),console.error("Error details:",h),[]}}parseMovementCode(h){const r=[],l=h.split(`
1063
- `);for(const g of l){const m=g.trim();m.includes("moveForward()")?r.push({type:"move_forward",direction:"north"}):m.includes("turnLeft()")?r.push({type:"turn_left",direction:"north"}):m.includes("turnRight()")?r.push({type:"turn_right",direction:"north"}):m.includes("turnAround()")&&r.push({type:"turn_around",direction:"north"})}return r}getWorkspace(){return this.workspace}clearWorkspace(){this.workspace?.clear()}render(){const{className:h="",style:r={}}=this.props,{isInitialized:l}=this.state;return B.jsxs("div",{className:`maze-blockly-container ${h}`,style:{width:"100%",height:"400px",position:"relative",...r},children:[B.jsx("div",{ref:this.blocklyDivRef,style:{width:"100%",height:"100%",position:"absolute",top:0,left:0}}),!l&&B.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:"#666",fontSize:16},children:"Loading Blockly..."})]})}}const cb=({config:a,onConfigChange:h,className:r})=>{const[l,g]=de.useState("wall"),[m,y]=de.useState(!1),k=(K,ee)=>{const me={...a};switch(l){case"start":{me.spiderStart={x:K,y:ee};break}case"finish":{me.finishPosition={x:K,y:ee};break}case"wall":{me.walls.findIndex(ae=>ae.x===K&&ae.y===ee)===-1&&me.walls.push({x:K,y:ee});break}case"empty":{me.walls=me.walls.filter(z=>!(z.x===K&&z.y===ee));break}}h(me)},A=(K,ee)=>{m&&l==="wall"&&k(K,ee)},D=(K,ee)=>a.walls.some(me=>me.x===K&&me.y===ee),H=(K,ee)=>a.spiderStart.x===K&&a.spiderStart.y===ee,W=(K,ee)=>a.finishPosition.x===K&&a.finishPosition.y===ee,X=(K,ee)=>H(K,ee)?"start":W(K,ee)?"finish":D(K,ee)?"wall":"empty",ue=()=>{const K={width:a.width,height:a.height,spiderStart:{x:1,y:1},finishPosition:{x:a.width-2,y:a.height-2},walls:[]},ee=a.width*a.height,me=Math.floor(ee*.2);for(let z=0;z<me;z++){const ae=Math.floor(Math.random()*a.width),te=Math.floor(Math.random()*a.height);ae===K.spiderStart.x&&te===K.spiderStart.y||ae===K.finishPosition.x&&te===K.finishPosition.y||K.walls.push({x:ae,y:te})}h(K)},ie=()=>{const K={...a,walls:[]};h(K)};return B.jsxs(xr,{className:r,children:[B.jsx(xr.Header,{children:B.jsxs(Hl,{className:"align-items-center",children:[B.jsx(gs,{children:B.jsx("h5",{className:"mb-0",children:"Maze Editor"})}),B.jsx(gs,{xs:"auto",children:B.jsxs(od,{size:"sm",children:[B.jsx(Lo,{variant:l==="wall"?"primary":"outline-primary",onClick:()=>g("wall"),children:"Wall"}),B.jsx(Lo,{variant:l==="empty"?"primary":"outline-primary",onClick:()=>g("empty"),children:"Clear"}),B.jsx(Lo,{variant:l==="start"?"primary":"outline-primary",onClick:()=>g("start"),children:"Start"}),B.jsx(Lo,{variant:l==="finish"?"primary":"outline-primary",onClick:()=>g("finish"),children:"Finish"})]})}),B.jsx(gs,{xs:"auto",children:B.jsxs(od,{size:"sm",children:[B.jsx(Lo,{variant:"outline-secondary",onClick:ue,children:"Regenerate"}),B.jsx(Lo,{variant:"outline-secondary",onClick:ie,children:"Clear All"})]})})]})}),B.jsx(xr.Body,{children:B.jsx("div",{className:"maze-grid",style:{display:"grid",gridTemplateColumns:`repeat(${a.width}, 30px)`,gap:"1px",backgroundColor:"#ccc",padding:"1px"},onMouseDown:()=>y(!0),onMouseUp:()=>y(!1),onMouseLeave:()=>y(!1),children:Array.from({length:a.height},(K,ee)=>Array.from({length:a.width},(me,z)=>{const ae=X(z,ee);return B.jsxs("div",{className:`maze-cell ${ae}`,style:{width:"30px",height:"30px",backgroundColor:ae==="wall"?"#333":ae==="start"?"#28a745":ae==="finish"?"#dc3545":"#fff",border:"1px solid #ccc",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",color:ae==="start"||ae==="finish"?"white":"black"},onClick:()=>k(z,ee),onMouseEnter:()=>A(z,ee),title:`${ae} at (${z}, ${ee})`,children:[ae==="start"&&"S",ae==="finish"&&"F"]},`${z}-${ee}`)}))})})]})};class HI extends de.Component{constructor(h){super(h),h.configuration&&(this.mazeConfig={...h.configuration}),this.state={gameState:{spiderPosition:{...this.mazeConfig.spiderStart},isGameWon:!1,isGameOver:!1,moveCount:0,maxMoves:h.maxMoves||50},currentDirection:"east",isExecuting:!1,currentCommandIndex:0,generatedCode:"",minSteps:8,isGenerating:!1},h.configuration||this.generateMaze()}componentWillUnmount(){this.executionInterval&&clearInterval(this.executionInterval)}mazeConfig={width:10,height:8,spiderStart:{x:1,y:1},finishPosition:{x:8,y:6},walls:[]};blocklyConfig={allowedTypes:new Set(["maze_move_forward","maze_turn_left","maze_turn_right","maze_turn_around","controls_repeat","controls_if"]),limits:{maze_move_forward:20,maze_turn_left:10,maze_turn_right:10,maze_turn_around:5,controls_repeat:5,controls_if:3},toolbox:`
1062
+ `},console.log("[MazeBlocklyContainer] forBlock registration completed")):console.log("[MazeBlocklyContainer] forBlock property not available, skipping"),console.log("[MazeBlocklyContainer] ✅ Maze generators registered successfully")}catch(a){console.error("[MazeBlocklyContainer] ❌ Failed to register maze generators:",a),console.error("[MazeBlocklyContainer] Error details:",a)}}disposeWorkspace(){this.workspace&&(this.workspace.dispose(),this.workspace=null,this.setState({workspace:null,isInitialized:!1}))}onAnyChange(a){if(!this.workspace)return;const r=a?.type||"";(r==="block_create"||r==="block_move"||r==="block_delete"||r==="block_change")&&(this.props.onWorkspaceChange?.(this.workspace),this.generateCode())}generateCode(){if(!(!this.workspace||!this.props.onCodeChange))try{console.log("Generating code for workspace:",this.workspace),console.log("Available blocks:",this.workspace.getAllBlocks(!1));const r=Pl().workspaceToCode(this.workspace);console.log("Generated code:",r),this.props.onCodeChange(r)}catch(a){console.error("Failed to generate code:",a),console.error("Error details:",a)}}loadXml(a){if(!(!this.workspace||!a))try{const r=Ul(),l=r.utils.xml.textToDom(a);r.Xml.domToWorkspace(l,this.workspace)}catch(r){console.error("Failed to load XML:",r)}}executeCode(){if(!this.workspace)return[];try{console.log("Executing maze code..."),console.log("Workspace state:",this.workspace);const r=Pl().workspaceToCode(this.workspace);console.log("Executing maze code:",r);const l=this.parseMovementCode(r);return console.log("Parsed movement commands:",l),this.props.onExecuteCode&&this.props.onExecuteCode(l),l}catch(a){return console.error("Failed to execute code:",a),console.error("Error details:",a),[]}}parseMovementCode(a){const r=[],l=a.split(`
1063
+ `);for(const g of l){const m=g.trim();m.includes("moveForward()")?r.push({type:"move_forward",direction:"north"}):m.includes("turnLeft()")?r.push({type:"turn_left",direction:"north"}):m.includes("turnRight()")?r.push({type:"turn_right",direction:"north"}):m.includes("turnAround()")&&r.push({type:"turn_around",direction:"north"})}return r}getWorkspace(){return this.workspace}clearWorkspace(){this.workspace?.clear()}render(){const{className:a="",style:r={}}=this.props,{isInitialized:l}=this.state;return B.jsxs("div",{className:`maze-blockly-container ${a}`,style:{width:"100%",height:"400px",position:"relative",...r},children:[B.jsx("div",{ref:this.blocklyDivRef,style:{width:"100%",height:"100%",position:"absolute",top:0,left:0}}),!l&&B.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:"#666",fontSize:16},children:"Loading Blockly..."})]})}}const hb=({config:h,onConfigChange:a,className:r})=>{const[l,g]=de.useState("wall"),[m,y]=de.useState(!1),k=(K,ee)=>{const me={...h};switch(l){case"start":{me.spiderStart={x:K,y:ee};break}case"finish":{me.finishPosition={x:K,y:ee};break}case"wall":{me.walls.findIndex(ae=>ae.x===K&&ae.y===ee)===-1&&me.walls.push({x:K,y:ee});break}case"empty":{me.walls=me.walls.filter(z=>!(z.x===K&&z.y===ee));break}}a(me)},A=(K,ee)=>{m&&l==="wall"&&k(K,ee)},D=(K,ee)=>h.walls.some(me=>me.x===K&&me.y===ee),H=(K,ee)=>h.spiderStart.x===K&&h.spiderStart.y===ee,W=(K,ee)=>h.finishPosition.x===K&&h.finishPosition.y===ee,X=(K,ee)=>H(K,ee)?"start":W(K,ee)?"finish":D(K,ee)?"wall":"empty",ue=()=>{const K={width:h.width,height:h.height,spiderStart:{x:1,y:1},finishPosition:{x:h.width-2,y:h.height-2},walls:[]},ee=h.width*h.height,me=Math.floor(ee*.2);for(let z=0;z<me;z++){const ae=Math.floor(Math.random()*h.width),te=Math.floor(Math.random()*h.height);ae===K.spiderStart.x&&te===K.spiderStart.y||ae===K.finishPosition.x&&te===K.finishPosition.y||K.walls.push({x:ae,y:te})}a(K)},ie=()=>{const K={...h,walls:[]};a(K)};return B.jsxs(Br,{className:r,children:[B.jsx(Br.Header,{children:B.jsxs(Vl,{className:"align-items-center",children:[B.jsx(gs,{children:B.jsx("h5",{className:"mb-0",children:"Maze Editor"})}),B.jsx(gs,{xs:"auto",children:B.jsxs(rd,{size:"sm",children:[B.jsx(Lo,{variant:l==="wall"?"primary":"outline-primary",onClick:()=>g("wall"),children:"Wall"}),B.jsx(Lo,{variant:l==="empty"?"primary":"outline-primary",onClick:()=>g("empty"),children:"Clear"}),B.jsx(Lo,{variant:l==="start"?"primary":"outline-primary",onClick:()=>g("start"),children:"Start"}),B.jsx(Lo,{variant:l==="finish"?"primary":"outline-primary",onClick:()=>g("finish"),children:"Finish"})]})}),B.jsx(gs,{xs:"auto",children:B.jsxs(rd,{size:"sm",children:[B.jsx(Lo,{variant:"outline-secondary",onClick:ue,children:"Regenerate"}),B.jsx(Lo,{variant:"outline-secondary",onClick:ie,children:"Clear All"})]})})]})}),B.jsx(Br.Body,{children:B.jsx("div",{className:"maze-grid",style:{display:"grid",gridTemplateColumns:`repeat(${h.width}, 30px)`,gap:"1px",backgroundColor:"#ccc",padding:"1px"},onMouseDown:()=>y(!0),onMouseUp:()=>y(!1),onMouseLeave:()=>y(!1),children:Array.from({length:h.height},(K,ee)=>Array.from({length:h.width},(me,z)=>{const ae=X(z,ee);return B.jsxs("div",{className:`maze-cell ${ae}`,style:{width:"30px",height:"30px",backgroundColor:ae==="wall"?"#333":ae==="start"?"#28a745":ae==="finish"?"#dc3545":"#fff",border:"1px solid #ccc",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",color:ae==="start"||ae==="finish"?"white":"black"},onClick:()=>k(z,ee),onMouseEnter:()=>A(z,ee),title:`${ae} at (${z}, ${ee})`,children:[ae==="start"&&"S",ae==="finish"&&"F"]},`${z}-${ee}`)}))})})]})};class GI extends de.Component{constructor(a){super(a),a.configuration&&(this.mazeConfig={...a.configuration}),this.state={gameState:{spiderPosition:{...this.mazeConfig.spiderStart},isGameWon:!1,isGameOver:!1,moveCount:0,maxMoves:a.maxMoves||50},currentDirection:"east",isExecuting:!1,currentCommandIndex:0,generatedCode:"",minSteps:8,isGenerating:!1},a.configuration||this.generateMaze()}componentWillUnmount(){this.executionInterval&&clearInterval(this.executionInterval)}mazeConfig={width:10,height:8,spiderStart:{x:1,y:1},finishPosition:{x:8,y:6},walls:[]};blocklyConfig={allowedTypes:new Set(["maze_move_forward","maze_turn_left","maze_turn_right","maze_turn_around","controls_repeat","controls_if"]),limits:{maze_move_forward:20,maze_turn_left:10,maze_turn_right:10,maze_turn_around:5,controls_repeat:5,controls_if:3},toolbox:`
1064
1064
  <xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display:none">
1065
1065
  <category name="Movement" colour="#5CA65C">
1066
1066
  <block type="maze_move_forward"></block>
@@ -1079,5 +1079,5 @@ Valid keys: `+JSON.stringify(Object.keys(_),null," "));var v=Xe($e,U,le,he,J+".
1079
1079
  <xml xmlns="https://developers.google.com/blockly/xml">
1080
1080
  <block type="maze_move_forward" x="20" y="20"></block>
1081
1081
  </xml>
1082
- `};executionInterval=null;blocklyRef=de.createRef();generateMaze=()=>{this.setState({isGenerating:!0}),setTimeout(()=>{const h=this.createMazeWithMinSteps(this.state.minSteps);this.mazeConfig=h,this.setState({gameState:{spiderPosition:{...h.spiderStart},isGameWon:!1,isGameOver:!1,moveCount:0,maxMoves:Math.max(50,(h.estimatedSteps||8)+10)},currentDirection:"east",isExecuting:!1,currentCommandIndex:0,isGenerating:!1}),this.blocklyRef.current&&this.blocklyRef.current.clearWorkspace()},100)};createMazeWithMinSteps(h){for(let m=0;m<50;m++){const y=this.generateRandomMaze(10,8),k=this.estimateOptimalSteps(y);if(k>=h&&this.isMazeSolvable(y))return{...y,estimatedSteps:k}}return this.generateFallbackMaze(10,8,h)}generateRandomMaze(h,r){const l=[],g={x:1,y:1},m={x:h-2,y:r-2},y=Math.floor(h*r*(.3+Math.random()*.1));for(let k=0;k<y;k++){const A=Math.floor(Math.random()*h),D=Math.floor(Math.random()*r);A===g.x&&D===g.y||A===m.x&&D===m.y||Math.abs(A-g.x)<=1&&Math.abs(D-g.y)<=1||Math.abs(A-m.x)<=1&&Math.abs(D-m.y)<=1||l.some(H=>H.x===A&&H.y===D)||l.push({x:A,y:D})}return{width:h,height:r,spiderStart:g,finishPosition:m,walls:l}}generateFallbackMaze(h,r,l){const g=[],m={x:1,y:1},y={x:h-2,y:r-2},k=[],A={...m};for(;A.x<y.x||A.y<y.y;)A.x<y.x&&(A.x++,k.push({...A})),A.y<y.y&&(A.y++,k.push({...A}));for(let D=0;D<Math.floor(l/2);D++){const H=Math.floor(Math.random()*(h-2))+1,W=Math.floor(Math.random()*(r-2))+1;!k.some(X=>X.x===H&&X.y===W)&&!g.some(X=>X.x===H&&X.y===W)&&g.push({x:H,y:W})}return{width:h,height:r,spiderStart:m,finishPosition:y,walls:g,estimatedSteps:l}}estimateOptimalSteps(h){const r=Math.abs(h.finishPosition.x-h.spiderStart.x)+Math.abs(h.finishPosition.y-h.spiderStart.y),l=Math.min(h.walls.length*.5,10);return Math.ceil(r+l)}isMazeSolvable(h){const r=new Set,l=[h.spiderStart];for(;l.length>0;){const g=l.shift(),m=`${g.x},${g.y}`;if(r.has(m))continue;if(r.add(m),g.x===h.finishPosition.x&&g.y===h.finishPosition.y)return!0;const y=[{x:g.x+1,y:g.y},{x:g.x-1,y:g.y},{x:g.x,y:g.y+1},{x:g.x,y:g.y-1}];for(const k of y)k.x>=0&&k.x<h.width&&k.y>=0&&k.y<h.height&&!h.walls.some(A=>A.x===k.x&&A.y===k.y)&&!r.has(`${k.x},${k.y}`)&&l.push(k)}return!1}handleCodeChange=h=>{this.setState({generatedCode:h})};handleConfigChange=h=>{this.mazeConfig=h,this.setState({gameState:{...this.state.gameState,spiderPosition:{...h.spiderStart},isGameWon:!1,isGameOver:!1,moveCount:0}}),this.props.onChange&&this.props.onChange(h)};handleExecuteCode=h=>{h.length!==0&&(this.setState({isExecuting:!0,currentCommandIndex:0}),this.executeCommands(h))};executeCommands(h){let r=0;this.executionInterval=setInterval(()=>{if(r>=h.length){this.stopExecution();return}const l=h[r];this.executeCommand(l),r++,this.setState({currentCommandIndex:r})},800)}executeCommand(h){switch(h.type){case"move_forward":this.moveSpiderForward();break;case"turn_left":this.turnSpider("left");break;case"turn_right":this.turnSpider("right");break;case"turn_around":this.turnSpider("around");break}}moveSpiderForward(){const{gameState:h,currentDirection:r}=this.state,l={...h.spiderPosition};switch(r){case"north":l.y=Math.max(0,l.y-1);break;case"south":l.y=Math.min(this.mazeConfig.height-1,l.y+1);break;case"east":l.x=Math.min(this.mazeConfig.width-1,l.x+1);break;case"west":l.x=Math.max(0,l.x-1);break}if(!this.isWall(l)){const g={...h,spiderPosition:l,moveCount:h.moveCount+1};if(this.isFinish(l)&&(g.isGameWon=!0,g.isGameOver=!0),g.moveCount>=h.maxMoves&&(g.isGameOver=!0),this.setState({gameState:g}),g.isGameOver&&this.props.onRunFinish){const m={steps:g.moveCount,reachedFinish:g.isGameWon,maxMovesExceeded:g.moveCount>=h.maxMoves,finalPosition:l,path:[],executionTime:0};this.props.onRunFinish(m)}}}turnSpider(h){const l={north:{left:"west",right:"east",around:"south"},south:{left:"east",right:"west",around:"north"},east:{left:"north",right:"south",around:"west"},west:{left:"south",right:"north",around:"east"}}[this.state.currentDirection][h];this.setState({currentDirection:l})}isWall(h){return this.mazeConfig.walls.some(r=>r.x===h.x&&r.y===h.y)}isFinish(h){return h.x===this.mazeConfig.finishPosition.x&&h.y===this.mazeConfig.finishPosition.y}stopExecution(){this.executionInterval&&(clearInterval(this.executionInterval),this.executionInterval=null),this.setState({isExecuting:!1})}resetGame=()=>{this.setState({gameState:{spiderPosition:{...this.mazeConfig.spiderStart},isGameWon:!1,isGameOver:!1,moveCount:0,maxMoves:Math.max(50,(this.mazeConfig.estimatedSteps||8)+10)},currentDirection:"east",isExecuting:!1,currentCommandIndex:0}),this.blocklyRef.current&&this.blocklyRef.current.clearWorkspace()};runCode=()=>{this.blocklyRef.current&&this.blocklyRef.current.executeCode()};handleGenerateNewMaze=()=>{this.generateMaze()};render(){const{gameState:h,currentDirection:r,isExecuting:l,generatedCode:g,isGenerating:m}=this.state,y=50;return B.jsx("div",{className:`maze-game ${this.props.className||""}`,children:B.jsx(j_,{fluid:!0,children:B.jsx(Hl,{children:B.jsx(gs,{children:B.jsx(xr,{children:B.jsx(xr.Body,{children:B.jsxs(Hl,{children:[B.jsxs(gs,{md:8,children:[B.jsxs("div",{className:"d-flex justify-content-between align-items-center mb-3",children:[B.jsxs("div",{children:[B.jsxs(Mi,{bg:"primary",className:"me-2",children:["Moves: ",h.moveCount,"/",h.maxMoves]}),B.jsx(Mi,{bg:r==="north"?"success":"secondary",className:"me-1",children:"↑"}),B.jsx(Mi,{bg:r==="east"?"success":"secondary",className:"me-1",children:"→"}),B.jsx(Mi,{bg:r==="south"?"success":"secondary",className:"me-1",children:"↓"}),B.jsx(Mi,{bg:r==="west"?"success":"secondary",className:"me-1",children:"←"})]}),B.jsxs("div",{children:[B.jsx(Lo,{variant:"success",onClick:this.runCode,disabled:l||h.isGameOver,className:"me-2",children:l?"Running...":"▶️ Run Code"}),B.jsx(Lo,{variant:"outline-secondary",onClick:this.resetGame,disabled:l,className:"me-2",children:"🔄 Reset"})]})]}),this.props.isEditable&&B.jsxs("div",{className:"d-flex align-items-center mb-3 p-3 bg-light rounded",children:[B.jsxs("div",{className:"me-3",children:[B.jsx(__.Label,{className:"mb-1 fw-bold",children:"Steps:"}),B.jsx("div",{className:"text-muted",children:this.mazeConfig.estimatedSteps||"Calculating..."})]}),B.jsxs("div",{className:"me-3",children:[B.jsx(__.Label,{className:"mb-1 fw-bold",children:"Walls:"}),B.jsx("div",{className:"text-muted",children:this.mazeConfig.walls.length})]}),B.jsx(Lo,{variant:"primary",onClick:this.handleGenerateNewMaze,disabled:l||m,className:"ms-auto",children:m?"🔄 Generating...":"🎲 Generate New Maze"})]}),h.isGameWon&&B.jsx(m_,{variant:"success",className:"mb-3",children:"🎉 Congratulations! You've reached the finish! 🎯"}),h.isGameOver&&!h.isGameWon&&B.jsx(m_,{variant:"danger",className:"mb-3",children:"❌ Game Over! You've exceeded the maximum moves."}),this.props.isEditable&&B.jsx("div",{className:"mb-4",children:B.jsx(cb,{config:this.mazeConfig,onConfigChange:this.handleConfigChange})}),B.jsxs("div",{style:{position:"relative",marginBottom:"20px"},children:[B.jsx(rb,{config:this.mazeConfig,cellSize:y}),B.jsx(nb,{position:h.spiderPosition,direction:r,size:y})]})]}),B.jsxs(gs,{md:4,children:[B.jsx("h5",{children:"Programming Blocks"}),B.jsx(lb,{ref:this.blocklyRef,config:this.blocklyConfig,onCodeChange:this.handleCodeChange,onExecuteCode:this.handleExecuteCode,style:{height:"300px"}}),B.jsxs("div",{className:"mt-3",children:[B.jsx("h6",{children:"Generated Code:"}),B.jsx("pre",{className:"bg-light p-2 rounded",style:{fontSize:"12px",maxHeight:"150px",overflow:"auto"},children:g||"// No code generated yet"})]})]})]})})})})})})})}}exports.EditableMazeGrid=cb;exports.MazeBlocklyContainer=lb;exports.MazeGame=HI;exports.MazeGrid=rb;exports.Spider=nb;exports.capitalize=T_;exports.debounce=pv;exports.deepClone=Kh;exports.formatDate=_v;exports.formatNumber=fv;exports.formatRelativeTime=bv;exports.generateId=mv;exports.getBlockly=Pl;exports.getJavaScriptGenerator=xl;exports.getNestedValue=Cv;exports.initializeBlockly=Gl;exports.isBlocklyReady=rd;exports.isDeepEqual=y_;exports.isValidEmail=yv;exports.isValidUrl=vv;exports.mergeObjects=E_;exports.removeEmptyValues=Iv;exports.resetBlocklyInitialization=$v;exports.retryWithBackoff=kv;exports.setNestedValue=Sv;exports.sleep=v_;exports.throttle=gv;exports.toTitleCase=Tv;exports.truncate=Ev;
1082
+ `};executionInterval=null;blocklyRef=de.createRef();generateMaze=()=>{this.setState({isGenerating:!0}),setTimeout(()=>{const a=this.createMazeWithMinSteps(this.state.minSteps);this.mazeConfig=a,this.setState({gameState:{spiderPosition:{...a.spiderStart},isGameWon:!1,isGameOver:!1,moveCount:0,maxMoves:Math.max(50,(a.estimatedSteps||8)+10)},currentDirection:"east",isExecuting:!1,currentCommandIndex:0,isGenerating:!1}),this.blocklyRef.current&&this.blocklyRef.current.clearWorkspace()},100)};createMazeWithMinSteps(a){for(let m=0;m<50;m++){const y=this.generateRandomMaze(10,8),k=this.estimateOptimalSteps(y);if(k>=a&&this.isMazeSolvable(y))return{...y,estimatedSteps:k}}return this.generateFallbackMaze(10,8,a)}generateRandomMaze(a,r){const l=[],g={x:1,y:1},m={x:a-2,y:r-2},y=Math.floor(a*r*(.3+Math.random()*.1));for(let k=0;k<y;k++){const A=Math.floor(Math.random()*a),D=Math.floor(Math.random()*r);A===g.x&&D===g.y||A===m.x&&D===m.y||Math.abs(A-g.x)<=1&&Math.abs(D-g.y)<=1||Math.abs(A-m.x)<=1&&Math.abs(D-m.y)<=1||l.some(H=>H.x===A&&H.y===D)||l.push({x:A,y:D})}return{width:a,height:r,spiderStart:g,finishPosition:m,walls:l}}generateFallbackMaze(a,r,l){const g=[],m={x:1,y:1},y={x:a-2,y:r-2},k=[],A={...m};for(;A.x<y.x||A.y<y.y;)A.x<y.x&&(A.x++,k.push({...A})),A.y<y.y&&(A.y++,k.push({...A}));for(let D=0;D<Math.floor(l/2);D++){const H=Math.floor(Math.random()*(a-2))+1,W=Math.floor(Math.random()*(r-2))+1;!k.some(X=>X.x===H&&X.y===W)&&!g.some(X=>X.x===H&&X.y===W)&&g.push({x:H,y:W})}return{width:a,height:r,spiderStart:m,finishPosition:y,walls:g,estimatedSteps:l}}estimateOptimalSteps(a){const r=Math.abs(a.finishPosition.x-a.spiderStart.x)+Math.abs(a.finishPosition.y-a.spiderStart.y),l=Math.min(a.walls.length*.5,10);return Math.ceil(r+l)}isMazeSolvable(a){const r=new Set,l=[a.spiderStart];for(;l.length>0;){const g=l.shift(),m=`${g.x},${g.y}`;if(r.has(m))continue;if(r.add(m),g.x===a.finishPosition.x&&g.y===a.finishPosition.y)return!0;const y=[{x:g.x+1,y:g.y},{x:g.x-1,y:g.y},{x:g.x,y:g.y+1},{x:g.x,y:g.y-1}];for(const k of y)k.x>=0&&k.x<a.width&&k.y>=0&&k.y<a.height&&!a.walls.some(A=>A.x===k.x&&A.y===k.y)&&!r.has(`${k.x},${k.y}`)&&l.push(k)}return!1}handleCodeChange=a=>{this.setState({generatedCode:a})};handleConfigChange=a=>{this.mazeConfig=a,this.setState({gameState:{...this.state.gameState,spiderPosition:{...a.spiderStart},isGameWon:!1,isGameOver:!1,moveCount:0}}),this.props.onChange&&this.props.onChange(a)};handleExecuteCode=a=>{a.length!==0&&(this.setState({isExecuting:!0,currentCommandIndex:0}),this.executeCommands(a))};executeCommands(a){let r=0;this.executionInterval=setInterval(()=>{if(r>=a.length){this.stopExecution();return}const l=a[r];this.executeCommand(l),r++,this.setState({currentCommandIndex:r})},800)}executeCommand(a){switch(a.type){case"move_forward":this.moveSpiderForward();break;case"turn_left":this.turnSpider("left");break;case"turn_right":this.turnSpider("right");break;case"turn_around":this.turnSpider("around");break}}moveSpiderForward(){const{gameState:a,currentDirection:r}=this.state,l={...a.spiderPosition};switch(r){case"north":l.y=Math.max(0,l.y-1);break;case"south":l.y=Math.min(this.mazeConfig.height-1,l.y+1);break;case"east":l.x=Math.min(this.mazeConfig.width-1,l.x+1);break;case"west":l.x=Math.max(0,l.x-1);break}if(!this.isWall(l)){const g={...a,spiderPosition:l,moveCount:a.moveCount+1};if(this.isFinish(l)&&(g.isGameWon=!0,g.isGameOver=!0),g.moveCount>=a.maxMoves&&(g.isGameOver=!0),this.setState({gameState:g}),g.isGameOver&&this.props.onRunFinish){const m={steps:g.moveCount,reachedFinish:g.isGameWon,maxMovesExceeded:g.moveCount>=a.maxMoves,finalPosition:l,path:[],executionTime:0};this.props.onRunFinish(m)}}}turnSpider(a){const l={north:{left:"west",right:"east",around:"south"},south:{left:"east",right:"west",around:"north"},east:{left:"north",right:"south",around:"west"},west:{left:"south",right:"north",around:"east"}}[this.state.currentDirection][a];this.setState({currentDirection:l})}isWall(a){return this.mazeConfig.walls.some(r=>r.x===a.x&&r.y===a.y)}isFinish(a){return a.x===this.mazeConfig.finishPosition.x&&a.y===this.mazeConfig.finishPosition.y}stopExecution(){this.executionInterval&&(clearInterval(this.executionInterval),this.executionInterval=null),this.setState({isExecuting:!1})}resetGame=()=>{this.setState({gameState:{spiderPosition:{...this.mazeConfig.spiderStart},isGameWon:!1,isGameOver:!1,moveCount:0,maxMoves:Math.max(50,(this.mazeConfig.estimatedSteps||8)+10)},currentDirection:"east",isExecuting:!1,currentCommandIndex:0}),this.blocklyRef.current&&this.blocklyRef.current.clearWorkspace()};runCode=()=>{this.blocklyRef.current&&this.blocklyRef.current.executeCode()};handleGenerateNewMaze=()=>{this.generateMaze()};render(){const{gameState:a,currentDirection:r,isExecuting:l,generatedCode:g,isGenerating:m}=this.state,y=50;return B.jsx("div",{className:`maze-game ${this.props.className||""}`,children:B.jsx(q_,{fluid:!0,children:B.jsx(Vl,{children:B.jsx(gs,{children:B.jsx(Br,{children:B.jsx(Br.Body,{children:B.jsxs(Vl,{children:[B.jsxs(gs,{md:8,children:[B.jsxs("div",{className:"d-flex justify-content-between align-items-center mb-3",children:[B.jsxs("div",{children:[B.jsxs(Di,{bg:"primary",className:"me-2",children:["Moves: ",a.moveCount,"/",a.maxMoves]}),B.jsx(Di,{bg:r==="north"?"success":"secondary",className:"me-1",children:"↑"}),B.jsx(Di,{bg:r==="east"?"success":"secondary",className:"me-1",children:"→"}),B.jsx(Di,{bg:r==="south"?"success":"secondary",className:"me-1",children:"↓"}),B.jsx(Di,{bg:r==="west"?"success":"secondary",className:"me-1",children:"←"})]}),B.jsxs("div",{children:[B.jsx(Lo,{variant:"success",onClick:this.runCode,disabled:l||a.isGameOver,className:"me-2",children:l?"Running...":"▶️ Run Code"}),B.jsx(Lo,{variant:"outline-secondary",onClick:this.resetGame,disabled:l,className:"me-2",children:"🔄 Reset"})]})]}),this.props.isEditable&&B.jsxs("div",{className:"d-flex align-items-center mb-3 p-3 bg-light rounded",children:[B.jsxs("div",{className:"me-3",children:[B.jsx(E_.Label,{className:"mb-1 fw-bold",children:"Steps:"}),B.jsx("div",{className:"text-muted",children:this.mazeConfig.estimatedSteps||"Calculating..."})]}),B.jsxs("div",{className:"me-3",children:[B.jsx(E_.Label,{className:"mb-1 fw-bold",children:"Walls:"}),B.jsx("div",{className:"text-muted",children:this.mazeConfig.walls.length})]}),B.jsx(Lo,{variant:"primary",onClick:this.handleGenerateNewMaze,disabled:l||m,className:"ms-auto",children:m?"🔄 Generating...":"🎲 Generate New Maze"})]}),a.isGameWon&&B.jsx(b_,{variant:"success",className:"mb-3",children:"🎉 Congratulations! You've reached the finish! 🎯"}),a.isGameOver&&!a.isGameWon&&B.jsx(b_,{variant:"danger",className:"mb-3",children:"❌ Game Over! You've exceeded the maximum moves."}),this.props.isEditable&&B.jsx("div",{className:"mb-4",children:B.jsx(hb,{config:this.mazeConfig,onConfigChange:this.handleConfigChange})}),B.jsxs("div",{style:{position:"relative",marginBottom:"20px"},children:[B.jsx(cb,{config:this.mazeConfig,cellSize:y}),B.jsx(ub,{position:a.spiderPosition,direction:r,size:y})]})]}),B.jsxs(gs,{md:4,children:[B.jsx("h5",{children:"Programming Blocks"}),B.jsx(ab,{ref:this.blocklyRef,config:this.blocklyConfig,onCodeChange:this.handleCodeChange,onExecuteCode:this.handleExecuteCode,style:{height:"300px"}}),B.jsxs("div",{className:"mt-3",children:[B.jsx("h6",{children:"Generated Code:"}),B.jsx("pre",{className:"bg-light p-2 rounded",style:{fontSize:"12px",maxHeight:"150px",overflow:"auto"},children:g||"// No code generated yet"})]})]})]})})})})})})})}}exports.EditableMazeGrid=hb;exports.MazeBlocklyContainer=ab;exports.MazeGame=GI;exports.MazeGrid=cb;exports.Spider=ub;exports.capitalize=v_;exports.debounce=gv;exports.deepClone=Zh;exports.formatDate=bv;exports.formatNumber=_v;exports.formatRelativeTime=Tv;exports.generateId=fv;exports.getBlockly=Ul;exports.getJavaScriptGenerator=Pl;exports.getNestedValue=Sv;exports.initializeBlockly=Wl;exports.isBlocklyReady=cd;exports.isDeepEqual=C_;exports.isValidEmail=vv;exports.isValidUrl=Iv;exports.mergeObjects=I_;exports.removeEmptyValues=Cv;exports.resetBlocklyInitialization=pv;exports.retryWithBackoff=Rv;exports.setNestedValue=kv;exports.sleep=S_;exports.throttle=mv;exports.toTitleCase=Ev;exports.truncate=yv;
1083
1083
  //# sourceMappingURL=index.cjs.js.map