x-block-lib 0.11.1 → 0.11.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/{i18n-en.fzzizejc.js → i18n-en.l65xil3y.js} +1 -1
- package/dist/{i18n-zhHans.b0wqxx8d.js → i18n-zhHans.fm8rc300.js} +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +84 -84
- package/dist/{rolldown-runtime.81faoggt.js → rolldown-runtime.bt10cbti.js} +1 -1
- package/dist/vendor.d4yexy6y.js +1103 -0
- package/package.json +2 -2
- package/dist/vendor.chw9q9nj.js +0 -2160
|
@@ -0,0 +1,1103 @@
|
|
|
1
|
+
import{i as e,r as t,t as n}from"./rolldown-runtime.bt10cbti.js";import{computed as r,defineComponent as i,getCurrentInstance as a,getCurrentScope as o,h as s,isRef as c,nextTick as l,onMounted as u,onScopeDispose as d,onUnmounted as f,reactive as p,ref as m,shallowRef as h,toRefs as g,toValue as _,unref as v,watch as y}from"vue";var b=n(((e,t)=>{(function(n,r){typeof define==`function`&&define.amd?define([],r):typeof e==`object`?t.exports=r():n.Blockly=r()})(e,function(){var e={},t=function(e,t,r,i){if(!(e instanceof P)&&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.`);let a=t.toLowerCase();if(!r)throw Error(`Can not register a null value`);let o=sc[e],s=lc[e];if(o||(o=sc[e]=Object.create(null),s=lc[e]=Object.create(null)),n(e,r),!i&&o[a]&&o[a]!==r)throw Error(`Name "`+a+`" with type "`+e+`" already registered.`);o[a]=r,s[a]=t},n=function(e,t){switch(e){case String(P.FIELD):if(typeof t.fromJson!=`function`)throw Error(`Type "`+e+`" must have a fromJson function`)}},r=function(e,t){e=`${e}`.toLowerCase(),t=t.toLowerCase();let n=sc[e];n&&n[t]?(delete sc[e][t],delete lc[e][t]):console.warn(`Unable to unregister [`+t+`][`+e+`] from the registry.`)},i=function(e,t,n){e=`${e}`.toLowerCase(),t=t.toLowerCase();let r=sc[e];if(!r||!r[t]){if(t=`Unable to find [`+t+`][`+e+`] in the registry.`,n)throw Error(t+` You must require or register a `+e+` plugin.`);return console.warn(t),null}return r[t]},a=function(e,t){return e=`${e}`.toLowerCase(),t=t.toLowerCase(),(e=sc[e])?!!e[t]:!1},o=function(e,t,n){return i(e,t,n)},s=function(e,t,n){return i(e,t,n)},c=function(e,t,n){e=`${e}`.toLowerCase();var r=sc[e];if(!r){if(r=`Unable to find [${e}] in the registry.`,n)throw Error(`${r} You must require or register a ${e} plugin.`);return console.warn(r),null}if(!t)return r;e=lc[e],n=Object.create(null);for(let t of Object.keys(r))n[e[t]]=r[t];return n},l=function(e,t,n){return t=t.plugins[String(e)]||uc,typeof t==`function`?t:o(e,t,n)},u=function(e,t){d(),_c=setTimeout(function(){t&&t.handleRightClick(e)},pc)},d=function(){_c&&(clearTimeout(_c),_c=0)},f=function(){hc=null},p=function(e){return!e.type.startsWith(`pointer`)||e instanceof PointerEvent&&h(e)},m=function(e){return`${e.pointerId}`},h=function(e){let t=m(e);return hc?hc===t:e.type===`pointerdown`?(hc=t,!0):!1},g=function(e,t,n,r,i,a){function o(e){(i||p(e))&&(n?r.call(n,e):r(e))}let s=[];if(t in gc)for(let n=0;n<gc[t].length;n++){let r=gc[t][n];e.addEventListener(r,o,Object.assign({},{capture:!1},a)),s.push([e,r,o])}else e.addEventListener(t,o,Object.assign({},{capture:!1},a)),s.push([e,t,o]);return s},_=function(e,t,n,r,i){function a(e){n?r.call(n,e):r(e)}let o=[];if(t in gc)for(let n=0;n<gc[t].length;n++){let r=gc[t][n];e.addEventListener(r,a,Object.assign({},{capture:!1},i)),o.push([e,r,a])}else e.addEventListener(t,a,Object.assign({},{capture:!1},i)),o.push([e,t,a]);return o},v=function(e){let t=e[e.length-1][2];for(;e.length;){let[t,n,r]=e.pop();t.removeEventListener(n,r,!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},b=function(e){return e.ctrlKey&&Fc?!0:e.button===2},ee=function(e,t,n){let r=t.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,n||(n=t.getScreenCTM().inverse()),r.matrixTransform(n)},te=function(e){switch(e.deltaMode){default:return{x:e.deltaX,y:e.deltaY};case 1:return{x:e.deltaX*Rc,y:e.deltaY*Rc};case 2:return{x:e.deltaX*zc,y:e.deltaY*zc}}},ne=function(){return`blockly-`+(Gc++).toString(36)},re=function(){return Wc.genUid()},ie=function(e){return e.type===F.BLOCK_CREATE},ae=function(e){return e.type===F.BLOCK_DELETE},x=function(e){return e.type===F.BLOCK_CHANGE},oe=function(e){return e.type===F.BLOCK_FIELD_INTERMEDIATE_CHANGE},se=function(e){return e.type===F.BLOCK_MOVE},S=function(e){return e.type===F.VAR_CREATE},ce=function(e){return e.type===F.VAR_DELETE},le=function(e){return e.type===F.VAR_RENAME},ue=function(e){return e.type===F.BLOCK_DRAG},C=function(e){return e.type===F.SELECTED},de=function(e){return e.type===F.CLICK},fe=function(e){return e.type===F.BUBBLE_OPEN},pe=function(e){return e.type===F.TRASHCAN_OPEN},me=function(e){return e.type===F.TOOLBOX_ITEM_SELECT},he=function(e){return e.type===F.THEME_CHANGE},ge=function(e){return e.type===F.VIEWPORT_CHANGE},_e=function(e){return e.type===F.COMMENT_CREATE},ve=function(e){return e.type===F.COMMENT_DELETE},ye=function(e){return e.type===F.COMMENT_CHANGE},be=function(e){return e.type===F.COMMENT_MOVE},xe=function(e){return e.type===F.COMMENT_RESIZE},Se=function(e){return e.type===F.COMMENT_DRAG},Ce=function(e){return e.type===F.COMMENT_COLLAPSE},we=function(e){return e.type===F.FINISHED_LOADING},Te,w,Ee,De,Oe,ke,Ae,je,Me,Ne,T,E,Pe,D,O,Fe,k,Ie,A,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et,tt,nt,rt,it,at,ot,st,ct,lt,ut,dt,ft,pt,mt,ht,gt,_t,vt,yt,bt,xt,St,Ct,wt,Tt,Et,Dt,Ot,kt,At,jt,Mt,Nt,Pt,Ft,It,Lt,Rt,zt,Bt,Vt,Ht,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt,Zt,Qt,$t,en,tn,nn,rn,an,on,sn,cn,ln,un,dn,fn,pn,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n,er,tr,nr,rr,ir,ar,or,sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr,zr,Br,Vr,Hr,Ur,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr,$r,ei,ti,ni,ri,ii,ai,oi,si,ci,li,ui,di,fi,pi,mi,hi,gi,_i,vi,yi,bi,xi,Si,Ci,wi,Ti,Ei,Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,$i,ea,ta,na,ra,ia,aa,oa,sa,ca,la,ua,da,fa,pa,ma,ha,ga,_a,va,ya,ba,xa,Sa,Ca,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia,La,Ra,za,Ba,Va,Ha,Ua,Wa,Ga,j,Ka,qa,Ja,Ya,Xa,M,Za,Qa,$a,eo,to,no,ro,io,ao,oo,so,co,lo,uo,fo,po,mo,ho,go,_o,vo,yo,bo,xo,So,Co,wo,To,Eo,Do,Oo,ko,Ao,jo,Mo,No,Po,Fo,Io,Lo,Ro,zo,Bo,Vo,Ho,Uo,Wo,Go,Ko,qo,Jo,Yo,Xo,Zo,Qo,$o,es,ts,ns,rs,is,as,os,ss,cs,ls,us,ds,fs,ps,ms,hs,gs,_s,vs,ys,bs,xs,Ss,Cs,ws,Ts,Es,Ds,Os,ks,As,js,Ms,Ns,Ps,Fs,Is,Ls,Rs,zs,Bs,Vs,Hs,Us,Ws,Gs,Ks,qs,Js,Ys,Xs,Zs,Qs,$s,ec,tc,nc,rc,ic,ac,oc,N;e.setRecordUndo$$module$build$src$core$events$utils=function(e){Yc=e},Te=function(){return Yc},w=function(e){$c.fireInternal(e)},Ee=function(e){if(je()){if(!Qc.length)try{requestAnimationFrame(()=>{setTimeout(De,0)})}catch{setTimeout(De,0)}Oe(e)}},De=function(){let e=ke(Qc);Qc.length=0;for(let t of e){if(!t.workspaceId)continue;let e;(e=Je(t.workspaceId))==null||e.fireChangeListener(t)}},Oe=function(e){if(x(e)&&e.element===`mutation`){let t;for(t=Qc.length;t>0;t--){let n=Qc[t-1];if(n.group!==e.group||n.workspaceId!==e.workspaceId||!se(n)||n.newParentId!==e.blockId)break}Qc.splice(t,0,e)}else Qc.push(e)},ke=function(e){let t=[];for(let n of e)e=t[t.length-1],!n.isNull()&&(e&&e.workspaceId===n.workspaceId&&e.group===n.group?se(n)&&se(e)&&n.blockId===e.blockId?(e.newParentId=n.newParentId,e.newInputName=n.newInputName,e.newCoordinate=n.newCoordinate,(e.reason||n.reason)&&(e.reason=Array.from(new Set((e.reason??[]).concat(n.reason??[]))))):x(n)&&x(e)&&n.blockId===e.blockId&&n.element===e.element&&n.name===e.name?e.newValue=n.newValue:ge(n)&&ge(e)?(e.viewTop=n.viewTop,e.viewLeft=n.viewLeft,e.scale=n.scale,e.oldScale=n.oldScale):de(n)&&fe(e)||t.push(n):t.push(n));return e=t.filter(e=>!e.isNull())},Ae=function(){for(let e=0,t;t=Qc[e];e++)t.recordUndo=!1},e.disable$$module$build$src$core$events$utils=function(){Xc++},e.enable$$module$build$src$core$events$utils=function(){Xc--},je=function(){return Xc===0},e.getGroup$$module$build$src$core$events$utils=function(){return Jc},e.setGroup$$module$build$src$core$events$utils=function(e){$c.setGroupInternal(e)},Me=function(e){Jc=typeof e==`boolean`?e?re():``:e},Ne=function(e){let t=[];e=e.getDescendants(!1);for(let n=0,r;r=e[n];n++)t[n]=r.id;return t},T=function(e,t){let n=E(e.type);if(!n)throw Error(`Unknown event type.`);return n.fromJson(e,t)},E=function(e){let t=o(P.EVENT,e);if(!t)throw Error(`Event type ${e} not found in registry.`);return t},Pe=function(e){if((se(e)||ie(e))&&e.workspaceId){var t=Je(e.workspaceId);if(!e.blockId)throw Error(`Encountered a blockEvent without a proper blockId`);if(e=t.getBlockById(e.blockId)){let n=Yc;try{Yc=!1;let n=e.getParent();if(n&&!n.hasDisabledReason(Zc)){let t=e.getDescendants(!1);for(let e=0,n;n=t[e];e++)n.setDisabledReason(!1,Zc)}else if((e.outputConnection||e.previousConnection)&&!t.isDragging())do e.setDisabledReason(!0,Zc),e=e.getNextBlock();while(e)}finally{Yc=n}}}},D=function(e,t,n){e=document.createElementNS(tl,`${e}`);for(let n in t)e.setAttribute(n,`${t[n]}`);return n&&n.appendChild(e),e},O=function(e,t){return t=t.split(` `),t.every(t=>e.classList.contains(t))?!1:(e.classList.add(...t),!0)},Fe=function(e,t){e.classList.remove(...t.split(` `))},k=function(e,t){return t=t.split(` `),t.every(t=>!e.classList.contains(t))?!1:(e.classList.remove(...t),!0)},Ie=function(e,t){return e.classList.contains(t)},A=function(e){return e&&e.parentNode?e.parentNode.removeChild(e):null},Le=function(e,t){let n=t.nextSibling;if(t=t.parentNode,!t)throw Error(`Reference node has no parent.`);n?t.insertBefore(e,n):t.appendChild(e)},Re=function(e,t){e.style.transform=t,e.style[`-webkit-transform`]=t},ze=function(){ol++,al||(al=Object.create(null))},Be=function(){ol--,ol||(al=null)},Ve=function(e){let t=e.textContent+`
|
|
2
|
+
`+e.className.baseVal;var n;return al&&(n=al[t])?n:(n=window.getComputedStyle(e),n=Ue(e,n.fontSize,n.fontWeight,n.fontFamily),al&&(al[t]=n),n)},He=function(e,t,n,r){return Ue(e,t+`pt`,n,r)},Ue=function(e,t,n,r){let i=e.textContent;e=i+`
|
|
3
|
+
`+e.className.baseVal;var a;return al&&(a=al[e])?a:(sl||(a=document.createElement(`canvas`),a.className=`blocklyComputeCanvas`,document.body.appendChild(a),sl=a.getContext(`2d`)),i&&sl?(sl.font=n+` `+t+` `+r,a=sl.measureText(i).width):a=0,al&&(al[e]=a),a)},We=function(e,t,n,r){let i=document.createElement(`span`);i.style.font=n+` `+t+` `+r,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),n={height:0,baseline:0};try{t.style.alignItems=`baseline`,n.baseline=e.offsetTop-i.offsetTop,t.style.alignItems=`flex-end`,n.height=e.offsetTop-i.offsetTop}finally{document.body.removeChild(t)}return n},e.getFocusManager$$module$build$src$core$focus_manager=function(){return fl.getFocusManager()},Ge=function(e){return e&&typeof e.getFocusableElement==`function`&&typeof e.getFocusableTree==`function`&&typeof e.onNodeFocus==`function`&&typeof e.onNodeBlur==`function`&&typeof e.canBeFocused==`function`},Ke=function(e){return Ge(e)&&typeof e.id==`string`&&typeof e.workspace==`object`&&typeof e.select==`function`&&typeof e.unselect==`function`},qe=function(e,t){for(let n in t)t[n]!==null&&Array.isArray(t[n])?e[n]=qe(e[n]||[],t[n]):e[n]=t[n]!==null&&typeof t[n]==`object`?qe(e[n]||Object.create(null),t[n]):t[n];return e},Je=function(e){return yl[e]||null},Ye=function(){let e=[];for(let t in yl)e.push(yl[t]);return e},Xe=function(e){yl[e.id]=e},Ze=function(e){delete yl[e.id]},Qe=function(){return bl},$e=function(e){bl=e},et=function(){let t=e.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode();return t&&Ke(t)?t:null},tt=function(t){e.getFocusManager$$module$build$src$core$focus_manager().focusNode(t)},nt=function(e){let t=et(),n=new(E(F.SELECTED))(t?.id??null,e?.id??null,e?.workspace.id??t?.workspace.id??``);w(n)},rt=function(){return xl},it=function(e){xl=e},at=function(e){for(;e.options.parentWorkspace;)e=e.options.parentWorkspace;let t=e.getParentSvg(),n=e.getCachedParentSvgSize();var r=t.parentElement;if(r instanceof HTMLElement){var i=r.offsetWidth;r=r.offsetHeight,n.width!==i&&(t.setAttribute(`width`,i+`px`),e.setCachedParentSvgSize(i,null)),n.height!==r&&(t.setAttribute(`height`,r+`px`),e.setCachedParentSvgSize(null,r)),e.resize()}},ot=function(e,t){let n=Object.create(null),r=e.getDescendants(!0);t&&(e=e.getNextBlock())&&(e=r.indexOf(e),r.splice(e,r.length-e));for(let e=0,t;t=r[e];e++)n[t.type]?n[t.type]++:n[t.type]=1;return n},st=function(e){return function(){this.jsonInit(e)}},ct=function(e){Cl.defineBlocksWithJsonArrayInternal(e)},lt=function(t){e.defineBlocks$$module$build$src$core$common(e.createBlockDefinitionsFromJsonArray$$module$build$src$core$common(t))},e.createBlockDefinitionsFromJsonArray$$module$build$src$core$common=function(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(!r){console.warn(`Block definition #${n} in JSON array is ${r}. Skipping`);continue}let i=r.type;i?t[i]={init:st(r)}:console.warn(`Block definition #${n} in JSON array is missing a type attribute. Skipping.`)}return t},e.defineBlocks$$module$build$src$core$common=function(e){for(let t of Object.keys(e)){let n=e[t];t in fc&&console.warn(`Block definition "${t}" overwrites previous definition.`),fc[t]=n}},ut=function(t){let n=Qe(),r=e.getFocusManager$$module$build$src$core$focus_manager().getFocusedTree();for(let e of Ye())if(r===e){n=e;break}!y(t)&&n&&(!n.rendered||n.isFlyout||n.isVisible())&&_l.registry.onKeyDown(n,t)},dt=function(e,t){return t=e.indexOf(t),t===-1?!1:(e.splice(t,1),!0)},ft=function(e){if(Ll)throw Error(`CSS already injected`);Rl+=`
|
|
4
|
+
`+e},pt=function(e,t){Ll||(Ll=!0,e&&(e=t.replace(/[\\/]$/,``),t=Rl.replace(/<<<PATH>>>/g,e),Rl=``,e=document.createElement(`style`),e.id=`blockly-common-style`,t=document.createTextNode(t),e.appendChild(t),document.head.insertBefore(e,document.head.firstChild)))},mt=function(e){return Wl.getSizeInternal(e)},ht=function(e){if(_t(e,`display`)!==`none`)return gt(e);let t=e.style,n=t.display,r=t.visibility,i=t.position;t.visibility=`hidden`,t.position=`absolute`,t.display=`inline`;let a=e.offsetWidth;return e=e.offsetHeight,t.display=n,t.position=i,t.visibility=r,new z(a,e)},gt=function(e){return new z(e.offsetWidth,e.offsetHeight)},_t=function(e,t){return e=window.getComputedStyle(e),e[t]||e.getPropertyValue(t)},vt=function(e){let t=new I(0,0);e=e.getBoundingClientRect();var n=document.documentElement;return n=new I(window.pageXOffset||n.scrollLeft,window.pageYOffset||n.scrollTop),t.x=e.left+n.x,t.y=e.top+n.y,t},yt=function(){let e=document.body,t=document.documentElement;return new I(e.scrollLeft||t.scrollLeft,e.scrollTop||t.scrollTop)},bt=function(e){let t=parseFloat(_t(e,`borderLeftWidth`)),n=parseFloat(_t(e,`borderRightWidth`)),r=parseFloat(_t(e,`borderTopWidth`));return e=parseFloat(_t(e,`borderBottomWidth`)),new R(r,e,t,n)},xt=function(e,t,n){e=St(e,t,n),t.scrollLeft=e.x,t.scrollTop=e.y},St=function(e,t,n){var r=vt(e),i=vt(t),a=bt(t);let o=r.x-i.x-a.left;return r=r.y-i.y-a.top,i=gt(e),e=t.clientWidth-i.width,i=t.clientHeight-i.height,a=t.scrollLeft,t=t.scrollTop,n?(a+=o-e/2,t+=r-i/2):(a+=Math.min(o,Math.max(o-e,0)),t+=Math.min(r,Math.max(r-i,0))),new I(a,t)},Ct=function(e){let t=new I(0,0);var n=e.x&&e.getAttribute(`x`);let r=e.y&&e.getAttribute(`y`);return n&&(t.x=parseInt(n)),r&&(t.y=parseInt(r)),(n=(n=e.getAttribute(`transform`))&&n.match(Kl))&&(t.x+=Number(n[1]),n[3]&&(t.y+=Number(n[3]))),(e=e.getAttribute(`style`))&&e.includes(`translate`)&&(e=e.match(ql))&&(t.x+=Number(e[1]),e[3]&&(t.y+=Number(e[3]))),t},wt=function(e){let t=0,n=0;for(;e;){let r=Ct(e);if(t+=r.x,n+=r.y,(` `+(e.getAttribute(`class`)||``)+` `).includes(` injectionDiv `))break;e=e.parentNode}return new I(t,n)},Tt=function(){let e=yt();return new R(e.y,document.documentElement.clientHeight+e.y,e.x,document.documentElement.clientWidth+e.x)},Et=function(){let e=document.documentElement,t=window;return new I(t.pageXOffset||e.scrollLeft,t.pageYOffset||e.scrollTop)},Dt=function(e,t){var n=t.x;t=t.y;let r=e.getInjectionDiv().getBoundingClientRect();return n=new I(n-r.left,t-r.top),t=e.getOriginOffsetInPixels(),I.difference(n,t).scale(1/e.scale)},Ot=function(e,t){var n=t.scale(e.scale);t=n.x,n=n.y;let r=e.getInjectionDiv().getBoundingClientRect();return e=e.getOriginOffsetInPixels(),new I(t+r.left+e.x,n+r.top+e.y)},kt=function(e){({document:$l=$l,DOMParser:eu=eu,XMLSerializer:tu=tu}=e),Zl=new eu,Ql=new tu},e.createElement$$module$build$src$core$utils$xml=function(e){return $l.createElementNS(nu,e)},e.createTextNode$$module$build$src$core$utils$xml=function(e){return $l.createTextNode(e)},e.textToDom$$module$build$src$core$utils$xml=function(e){let t=Zl.parseFromString(e,`text/xml`);if(t&&t.documentElement&&!t.getElementsByTagName(`parsererror`).length)return t.documentElement;if((t=Zl.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}`)},At=function(e){return jt(Ql.serializeToString(e))},jt=function(e){return e.replace(ru,e=>`&#${e.charCodeAt(0)};`)},Mt=function(e){return e?((e instanceof Element||typeof e==`string`)&&(e=Vt(e),e=Rt(e)),Nt(e),e):null},Nt=function(e){let t=e.kind;if(e=e.contents,t&&t!==ou&&t!==au)throw Error(`Invalid toolbox kind `+t+`. Please supply either `+ou+` or `+au);if(!e)throw Error(`Toolbox must have a contents attribute.`)},Pt=function(e){return e?e.contents?e.contents:Array.isArray(e)&&e.length>0&&!e[0].nodeType?e:zt(e):[]},Ft=function(e){return su.hasCategoriesInternal(e)},It=function(e){if(!e)return!1;let t=e.kind;return t?t===au:!!e.contents.filter(e=>e.kind.toUpperCase()===`CATEGORY`).length},Lt=function(e){return e&&e.contents?!!e.contents.filter(function(e){return e.kind.toUpperCase()===`CATEGORY`}).length:!1},Rt=function(e){let t={contents:zt(e)};return e instanceof Node&&Bt(e,t),t},zt=function(e){let t=[],n=e.childNodes;n||(n=e);for(let r=0,i;i=n[r];r++){if(!i.tagName)continue;e={};let n=i.tagName.toUpperCase();e.kind=n,n===`BLOCK`?e.blockxml=i:i.childNodes&&i.childNodes.length>0&&(e.contents=zt(i)),Bt(i,e),t.push(e)}return t},Bt=function(e,t){for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];r.nodeName.includes(`css-`)?(t.cssconfig=t.cssconfig||{},t.cssconfig[r.nodeName.replace(`css-`,``)]=r.value):t[r.nodeName]=r.value}},Vt=function(t){let n=null;if(t)if(typeof t==`string`){if(n=e.textToDom$$module$build$src$core$utils$xml(t),n.nodeName.toLowerCase()!==`xml`)throw TypeError(`Toolbox should be an <xml> document.`)}else t instanceof Element&&(n=t);return n},Ht=function(e,t,n,r,i,a){let o=a.scrollbar&&a.scrollbar.canScrollVertically();return e.horizontal===uu.LEFT?(n=i.absoluteMetrics.left+n,o&&a.RTL&&(n+=Yl.scrollbarThickness)):(n=i.absoluteMetrics.left+i.viewMetrics.width-t.width-n,o&&!a.RTL&&(n-=Yl.scrollbarThickness)),e.vertical===lu.TOP?e=i.absoluteMetrics.top+r:(e=i.absoluteMetrics.top+i.viewMetrics.height-t.height-r,a.scrollbar&&a.scrollbar.canScrollHorizontally()&&(e-=Yl.scrollbarThickness)),new R(e,e+t.height,n,n+t.width)},Ut=function(e,t){return{horizontal:t.toolboxMetrics.position===B.LEFT||e.horizontalLayout&&!e.RTL?uu.RIGHT:uu.LEFT,vertical:t.toolboxMetrics.position===B.BOTTOM?lu.TOP:lu.BOTTOM}},Wt=function(e,t,n,r){let i=e.left,a=e.right-e.left,o=e.bottom-e.top;for(let s=0;s<r.length;s++){let c=r[s];e.intersects(c)&&(e=n===du.UP?c.top-o-t:c.bottom+t,e=new R(e,e+o,i,i+a),s=-1)}return e},Gt=function(e,n){t(P.SERIALIZER,e,n)},Kt=function(e){r(P.SERIALIZER,e)},qt=function(e,{addCoordinates:t=!1,saveIds:n=!0}={}){let r=e.workspace,i=Object.create(null);return i.height=e.getSize().height,i.width=e.getSize().width,n&&(i.id=e.id),t&&(t=e.getRelativeToSurfaceXY(),i.x=r.RTL?r.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},Jt=function(t,n,{recordUndo:r=!1}={}){let i=Te();if(e.setRecordUndo$$module$build$src$core$events$utils(r),r=n.newComment(t.id),t.text!==void 0&&r.setText(t.text),t.x!==void 0||t.y!==void 0){let e=r.getRelativeToSurfaceXY(),i=t.x??e.x;i=n.RTL?n.getWidth()-i:i;var a;n=(a=t.y)??e.y,r.moveTo(new I(i,n))}return(t.width!==void 0||t.height)&&(a=r.getSize(),r.setSize(new z(t.width??a.width,t.height??a.height))),t.collapsed!==void 0&&r.setCollapsed(t.collapsed),t.editable!==void 0&&r.setEditable(t.editable),t.movable!==void 0&&r.setMovable(t.movable),t.deletable!==void 0&&r.setDeletable(t.deletable),e.setRecordUndo$$module$build$src$core$events$utils(i),r},Yt=function(e,n){t(P.PASTER,e,n)},Xt=function(e){r(P.PASTER,e)},Zt=function(e){let t=e.workspace,n=e.getRelativeToSurfaceXY(),r=new I(0,0),i=t.getTopComments(!1).filter(t=>t.id!==e.id).map(e=>e.getRelativeToSurfaceXY());for(;Qt(I.sum(n,r),i);)r.translate(t.RTL?-30:30,30);e.moveTo(I.sum(n,r))},Qt=function(e,t){return t.some(t=>Math.abs(t.x-e.x)<=1&&Math.abs(t.y-e.y)<=1)},$t=function(e,t){e.setAttribute(ku,t)},en=function(e,t,n){Array.isArray(n)&&(n=n.join(` `)),e.setAttribute(Ou+t,`${n}`)},tn=function(e){return e&&typeof e.saveState==`function`&&typeof e.loadState==`function`},nn=function(e){return sn(e),on()?(cn(),Promise.resolve()):(qu||(qu=new Promise(e=>{Ju=e,Yu=window.requestAnimationFrame(()=>{cn(),e()})})),qu)},rn=function(){return qu||Promise.resolve()},an=function(e){e||window.cancelAnimationFrame(Yu),cn(e),!e&&Ju&&Ju()},on=function(){return Ac},sn=function(t){Gu.add(t),Ku.set(t,e.getGroup$$module$build$src$core$events$utils());let n=t.getParent();n?sn(n):V.add(t)},cn=function(t){let n=t?new Set([t]):new Set([...V].map(e=>e.workspace)),r=[...V].filter(un).filter(e=>n.has(e.workspace));for(var i of r)dn(i);for(let e of n)e.resizeContents();for(var a of r)i=a.getRelativeToSurfaceXY(),a.updateComponentLocations(i);for(let t of r)a=e.getGroup$$module$build$src$core$events$utils(),(i=Ku.get(t))&&e.setGroup$$module$build$src$core$events$utils(i),t.bumpNeighbours(),e.setGroup$$module$build$src$core$events$utils(a);for(let e of r)ln(e);t||(qu=null)},ln=function(e){V.delete(e),Gu.delete(e),Ku.delete(e);for(let t of e.getChildren(!1))ln(t)},un=function(e){return!e.isDisposed()&&!e.getParent()},dn=function(e){if(Gu.has(e)&&e.initialized){for(let t of e.getChildren(!1))dn(t);e.renderEfficiently()}},fn=function(e,t){id(e,t)},pn=function(e=rd){id=e},mn=function(e,t){od(e,t)},hn=function(e=ad){od=e},gn=function(e,t,n){cd(e,t,n)},_n=function(e=sd){cd=e},vn=function(e,t){ud(e,t)},yn=function(e=ld){ud=e},bn=function(e){return e&&typeof e.getProcedureDef==`function`},xn=function(e){return e&&typeof e.getProcedureCall==`function`&&typeof e.renameProcedure==`function`},Sn=function(e){return e.getVariableModel!==void 0},Cn=function(e,t,n,r){e=e+` was deprecated in `+t+` and will be deleted in `+n+`.`,r&&(e+=`
|
|
5
|
+
Use `+r+` instead.`),md.has(e)||(md.add(e),console.warn(e))},e.allUsedVarModels$$module$build$src$core$variables=function(e){e=e.getAllBlocks(!1);let t=new Set;for(let n=0;n<e.length;n++){let r=e[n].getVarModels();if(r)for(let e=0;e<r.length;e++){let n=r[e];n.getId()&&t.add(n)}}return Array.from(t.values())},e.allDeveloperVariables$$module$build$src$core$variables=function(e){e=e.getAllBlocks(!1);let t=new Set;for(let r=0,i;i=e[r];r++){var n=i.getDeveloperVariables;if(n){n=n();for(let e=0;e<n.length;e++)t.add(n[e])}}return Array.from(t.values())},wn=function(e){return Tn(e,!1)},Tn=function(e,t=!0){return fc.variables_set||fc.variables_get||console.warn(`There are no variable blocks, but there is a variable category.`),t?(Cn(`The XML return value of Blockly.Variables.flyoutCategory()`,`v12`,`v13`,`the same method, but handle a return type of FlyoutItemInfo[] (JSON) instead.`),On(e)):(e.registerButtonCallback(`CREATE_VARIABLE`,function(e){Nn(e.getTargetWorkspace())}),[{kind:`button`,text:`%{BKY_NEW_VARIABLE}`,callbackkey:`CREATE_VARIABLE`},...Dn(e,e.getVariableMap().getVariablesOfType(``),!0)])},En=function(e){return{VAR:{name:e.getName(),type:e.getType()}}},Dn=function(e,t,n,r=`variables_get`,i=`variables_set`){n&&(n=fc.math_change),e=[];let a=t.slice(-1)[0];return a&&(fc[i]&&e.push({kind:`block`,type:i,gap:n?8:24,fields:En(a)}),n&&e.push({kind:`block`,type:`math_change`,gap:fc[r]?20:8,fields:En(a),inputs:{DELTA:{shadow:{type:`math_number`,fields:{NUM:1}}}}})),fc[r]&&e.push(...t.sort(Un).map(e=>({kind:`block`,type:r,gap:8,fields:En(e)}))),e},On=function(e){let t=[],n=document.createElement(`button`);return n.setAttribute(`text`,`%{BKY_NEW_VARIABLE}`),n.setAttribute(`callbackKey`,`CREATE_VARIABLE`),e.registerButtonCallback(`CREATE_VARIABLE`,function(e){Nn(e.getTargetWorkspace())}),t.push(n),e=kn(e),t=t.concat(e)},kn=function(t){t=t.getVariableMap().getVariablesOfType(``);let n=[];if(t.length>0){var r=t[t.length-1];if(fc.variables_set){var i=e.createElement$$module$build$src$core$utils$xml(`block`);i.setAttribute(`type`,`variables_set`),i.setAttribute(`gap`,fc.math_change?`8`:`24`),i.appendChild(Bn(r)),n.push(i)}if(fc.math_change&&(i=e.createElement$$module$build$src$core$utils$xml(`block`),i.setAttribute(`type`,`math_change`),i.setAttribute(`gap`,fc.variables_get?`20`:`8`),i.appendChild(Bn(r)),r=e.textToDom$$module$build$src$core$utils$xml(`<value name="DELTA"><shadow type="math_number"><field name="NUM">1</field></shadow></value>`),i.appendChild(r),n.push(i)),fc.variables_get){t.sort(Un);for(let i=0,a;a=t[i];i++)r=e.createElement$$module$build$src$core$utils$xml(`block`),r.setAttribute(`type`,`variables_get`),r.setAttribute(`gap`,`8`),r.appendChild(Bn(a)),n.push(r)}}return n},An=function(e){return vd.generateUniqueNameInternal(e)},jn=function(e){return Mn(_d.charAt(0),e.getVariableMap().getAllVariables().map(e=>e.getName()))},Mn=function(e,t){if(!t.length)return e;let n=_d,r=``,i=n.indexOf(e);for(;;){let a=!1;for(let n=0;n<t.length;n++)if(t[n].toLowerCase()===e){a=!0;break}if(!a)break;i++,i===n.length&&(i=0,r=`${Number(r)+1}`),e=n.charAt(i)+r}return e},Nn=function(t,n,r){function i(r){Pn(e.Msg$$module$build$src$core$msg.NEW_VARIABLE_TITLE,r,function(r){if(r){var o=In(r,t);if(o){if(o.getType()===a)var s=e.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS.replace(`%1`,o.getName());else s=e.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE,s=s.replace(`%1`,o.getName()).replace(`%2`,o.getType());fn(s,function(){i(r)})}else t.getVariableMap().createVariable(r,a),n&&n(r)}else n&&n(null)})}let a=r||``;i(``)},e.renameVariable$$module$build$src$core$variables=function(t,n,r){function i(a){let o=e.Msg$$module$build$src$core$msg.RENAME_VARIABLE_TITLE.replace(`%1`,n.getName());Pn(o,a,function(a){if(a){var o=Fn(a,n.getType(),t),s=Ln(n.getName(),a,t);if(o||s){var c=``;o?c=e.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE.replace(`%1`,o.getName()).replace(`%2`,o.getType()):s&&(c=e.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS_FOR_A_PARAMETER.replace(`%1`,a).replace(`%2`,s)),fn(c,function(){i(a)})}else t.getVariableMap().renameVariable(n,a),r&&r(a)}else r&&r(null)})}i(``)},Pn=function(t,n,r){gn(t,n,function(t){t&&(t=t.replace(/[\s\xa0]+/g,` `).trim(),t===e.Msg$$module$build$src$core$msg.RENAME_VARIABLE||t===e.Msg$$module$build$src$core$msg.NEW_VARIABLE)&&(t=null),r(t)})},Fn=function(e,t,n){n=n.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let r=0,i;i=n[r];r++)if(i.getName().toLowerCase()===e&&i.getType()!==t)return i;return null},In=function(e,t){t=t.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let n=0,r;r=t[n];n++)if(r.getName().toLowerCase()===e)return r;return null},Ln=function(e,t,n){return n.getProcedureMap().getProcedures().length?Rn(e,t,n):zn(e,t,n)},Rn=function(e,t,n){e=e.toLowerCase(),t=t.toLowerCase(),n=n.getProcedureMap().getProcedures();for(let i of n){var r=i.getParameters().filter(Sn).map(e=>e.getVariableModel().getName());if(r&&(n=r.some(t=>t.toLowerCase()===e),r=r.some(e=>e.toLowerCase()===t),n&&r))return i.getName()}return null},zn=function(e,t,n){e=e.toLowerCase(),t=t.toLowerCase(),n=n.getAllBlocks(!1);for(let i of n){if(!bn(i))continue;n=i.getProcedureDef();var r=n[1];let a=r.some(t=>t.toLowerCase()===e);if(r=r.some(e=>e.toLowerCase()===t),a&&r)return n[0]}return null},Bn=function(t){let n=e.createElement$$module$build$src$core$utils$xml(`field`);return n.setAttribute(`name`,`VAR`),n.setAttribute(`id`,t.getId()),n.setAttribute(`variabletype`,t.getType()),t=e.createTextNode$$module$build$src$core$utils$xml(t.getName()),n.appendChild(t),n},e.getOrCreateVariablePackage$$module$build$src$core$variables=function(t,n,r,i){let a=e.getVariable$$module$build$src$core$variables(t,n,r,i);return a||(a=Vn(t,n,r,i)),a},e.getVariable$$module$build$src$core$variables=function(e,t,n,r){let i=e.getPotentialVariableMap(),a=null;if(t&&(a=e.getVariableMap().getVariableById(t),!a&&i&&(a=i.getVariableById(t)),a))return a;if(n){if(r===void 0)throw Error(`Tried to look up a variable by name without a type`);a=e.getVariableMap().getVariable(n,r),!a&&i&&(a=i.getVariable(n,r))}return a},Vn=function(e,t,n,r){let i=e.getVariableMap(),a=e.getPotentialVariableMap();return n||(n=An(e.isFlyout?e.targetWorkspace:e)),a?a.createVariable(n,r,t??void 0):i.createVariable(n,r,t)},Hn=function(e,t){e=e.getVariableMap().getAllVariables();let n=[];if(t.length!==e.length)for(let r=0;r<e.length;r++){let i=e[r];t.includes(i)||n.push(i)}return n},Un=function(e,t){return e.getName().localeCompare(t.getName(),void 0,{sensitivity:`base`})},Wn=function(e,t){let n=[];e=e.getAllBlocks(!1);for(let r=0;r<e.length;r++){let i=e[r].getVarModels();if(i)for(let a=0;a<i.length;a++)i[a].getId()===t&&n.push(e[r])}return n},e.deleteVariable$$module$build$src$core$variables=function(t,n,r){var i=n.getName();let a=Wn(t,n.getId());for(let t=a.length-1;t>=0;t--){let n=a[t];if(n.type===`procedures_defnoreturn`||n.type===`procedures_defreturn`){r=String(n.getFieldValue(`NAME`)),i=e.Msg$$module$build$src$core$msg.CANNOT_DELETE_VARIABLE_PROCEDURE.replace(`%1`,i).replace(`%2`,r),fn(i);return}n===r&&a.splice(t,1)}r&&a.length||a.length>1?(i=e.Msg$$module$build$src$core$msg.DELETE_VARIABLE_CONFIRMATION.replace(`%1`,String(a.length+(r&&!r.workspace.isFlyout?1:0))).replace(`%2`,i),mn(i,e=>{e&&n&&t.getVariableMap().deleteVariable(n)})):t.getVariableMap().deleteVariable(n)},Gn=function(e,{addCoordinates:t=!1,addInputBlocks:n=!0,addNextBlocks:r=!0,doFullSerialization:i=!0,saveIds:a=!0}={}){if(e.isInsertionMarker())return null;let o={type:e.type,id:a?e.id:void 0};return t&&qn(e,o),Kn(e,o),Jn(e,o,i),Yn(e,o,i),Xn(e,o,i),n&&Zn(e,o,i,a),r&&Qn(e,o,i,a),o},Kn=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)},qn=function(e,t){let n=e.workspace;e=e.getRelativeToSurfaceXY(),t.x=Math.round(n.RTL?n.getWidth()-e.x:e.x),t.y=Math.round(e.y)},Jn=function(e,t,n){e.saveExtraState?(e=e.saveExtraState(n),e!==null&&(t.extraState=e)):e.mutationToDom&&(e=e.mutationToDom(),e!==null&&(t.extraState=la(e).replace(` xmlns="https://developers.google.com/blockly/xml"`,``)))},Yn=function(e,t,n){let r=Object.create(null);for(let t of e.getIcons())tn(t)&&(e=t.saveState(n))&&(r[t.getType().toString()]=e);Object.keys(r).length&&(t.icons=r)},Xn=function(e,t,n){let r=Object.create(null);for(let t of e.getFields())t.isSerializable()&&(r[t.name]=t.saveState(n));Object.keys(r).length&&(t.fields=r)},Zn=function(e,t,n,r){let i=Object.create(null);for(let t=0;t<e.inputList.length;t++){let a=e.inputList[t];if(!a.connection)continue;let o=$n(a.connection,n,r);o&&(i[a.name]=o)}Object.keys(i).length&&(t.inputs=i)},Qn=function(e,t,n,r){e.nextConnection&&(e=$n(e.nextConnection,n,r))&&(t.next=e)},$n=function(e,t,n){let r=e.getShadowState(!0);if(e=e.targetBlock(),!r&&!e)return null;let i=Object.create(null);return r&&(i.shadow=r),e&&!e.isShadow()&&(i.block=Gn(e,{doFullSerialization:t,saveIds:n})),i},er=function(e,t,{recordUndo:n=!1}={}){return e=tr(e,t,{recordUndo:n}),t.rendered&&an(),e},tr=function(t,n,{parentConnection:r,isShadow:i=!1,recordUndo:a=!1}={}){let o=Te();e.setRecordUndo$$module$build$src$core$events$utils(a),(a=e.getGroup$$module$build$src$core$events$utils())||e.setGroup$$module$build$src$core$events$utils(!0),e.disable$$module$build$src$core$events$utils();let s=n.getVariableMap().getAllVariables(),c;try{c=nr(t,n,{parentConnection:r,isShadow:i})}finally{e.enable$$module$build$src$core$events$utils()}if(rr(n,s),je()&&w(new(E(F.BLOCK_CREATE))(c)),e.setGroup$$module$build$src$core$events$utils(a),e.setRecordUndo$$module$build$src$core$events$utils(o),n.rendered){let e=c;setTimeout(()=>{e.disposed||e.setConnectionTracking(!0)},1)}return c},nr=function(e,t,{parentConnection:n,isShadow:r=!1}={}){if(!e.type)throw new xd(e);let i=t.newBlock(e.type,e.id);return i.setShadow(r),ir(i,e),ar(i,e),or(i,e),sr(n,i,e),cr(i,e),lr(i,e),ur(i,e),dr(i,e),pr(i,t.rendered),i},rr=function(e,t){if(je())for(e=Hn(e,t),t=0;t<e.length;t++){let n=e[t];w(new(E(F.VAR_CREATE))(n))}},ir=function(e,t){let n=t.x===void 0?0:t.x;t=t.y===void 0?0:t.y;let r=e.workspace;n=r.RTL?r.getWidth()-n:n,e.moveBy(n,t)},ar=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,Vu),Array.isArray(t.disabledReasons))for(let n of t.disabledReasons)e.setDisabledReason(!0,n);t.inline!==void 0&&e.setInputsInline(t.inline),t.data!==void 0&&(e.data=t.data)},or=function(t,n){n.extraState&&(t.loadExtraState?t.loadExtraState(n.extraState):t.domToMutation&&t.domToMutation(e.textToDom$$module$build$src$core$utils$xml(n.extraState)))},sr=function(t,n,r){if(t){if(t.getSourceBlock().isShadow()&&!n.isShadow())throw new wd(r);if(t.type===e.inputTypes$$module$build$src$core$inputs$input_types.VALUE){var i=n.outputConnection;if(!i)throw new Sd(`output`,n,r)}else if(i=n.previousConnection,!i)throw new Sd(`previous`,n,r);if(!t.connect(i)){let a=n.workspace.connectionChecker;throw new Cd(a.getErrorMessage(a.canConnectWithReason(i,t,!1),i,t),t.type===e.inputTypes$$module$build$src$core$inputs$input_types.VALUE?`output connection`:`previous connection`,n,r)}}},cr=function(e,t){if(t.icons){var n=Object.keys(t.icons);for(let i of n){n=t.icons[i];var r=e.getIcon(i);if(!r){if(r=o(P.ICON,i,!1),!r)throw new Td(i,e,t);r=new r(e),e.addIcon(r)}tn(r)&&r.loadState(n)}}},lr=function(e,t){if(t.fields){var n=Object.keys(t.fields);for(let r=0;r<n.length;r++){let i=n[r],a=t.fields[i],o=e.getField(i);o?o.loadState(a):console.warn(`Ignoring non-existant field ${i} in block ${e.type}`)}}},ur=function(e,t){if(t.inputs){var n=Object.keys(t.inputs);for(let r=0;r<n.length;r++){let i=n[r],a=e.getInput(i);if(!a||!a.connection)throw new Sd(i,e,t);fr(a.connection,t.inputs[i])}}},dr=function(e,t){if(t.next){if(!e.nextConnection)throw new Sd(`next`,e,t);fr(e.nextConnection,t.next)}},fr=function(e,t){t.shadow&&e.setShadowState(t.shadow),t.block&&nr(t.block,e.getSourceBlock().workspace,{parentConnection:e})},pr=function(e,t){if(t){e.setConnectionTracking(!1),e.initSvg(),e.queueRender();for(let t of e.getIcons())t.onLocationChange(e.getRelativeToSurfaceXY())}else e.initModel()},mr=function(e){return typeof e.bubbleIsVisible==`function`&&typeof e.setBubbleVisible==`function`&&typeof e.getBubble==`function`},hr=function(e){return e*Math.PI/180},gr=function(e){return e*180/Math.PI},_r=function(e,t,n){if(n<e){let t=n;n=e,e=t}return Math.max(e,Math.min(t,n))},vr=function(){document.querySelector(`.blocklyDropDownDiv`)||(Hd=document.createElement(`div`),Hd.className=`blocklyDropDownDiv`,Hd.tabIndex=-1,(rt()||document.body).appendChild(Hd),Ud=document.createElement(`div`),Ud.className=`blocklyDropDownContent`,Hd.appendChild(Ud),Yd=g(Ud,`keydown`,null,ut),Wd=document.createElement(`div`),Wd.className=`blocklyDropDownArrow`,Hd.appendChild(Wd),Hd.style.opacity=`0`,Hd.style.transition=`transform `+Ld+`s, opacity `+Ld+`s`)},yr=function(e){Gd=e},br=function(){return Kd},xr=function(){return Ud},Sr=function(){Yd&&(v(Yd),Yd=null),Hd.remove(),vr()},Cr=function(e,t){Hd.style.backgroundColor=e,Hd.style.borderColor=t},wr=function(e,t,n,r,i=!0){return Or(Er(t),e,i,n,r)},Tr=function(e,t,n,r=!0){return qd=!0,Or(Dr(e),e,r,t,n)},Er=function(e){var t=e.getSvgRoot();let n=e.workspace.scale,r=e.height*n;return e=e.width*n,t=vt(t),new R(t.y,t.y+r,t.x,t.x+e)},Dr=function(e){return e=e.getScaledBBox(),new R(e.top,e.bottom,e.left,e.right)},Or=function(e,t,n,r,i){let a=e.left+(e.right-e.left)/2,o=e.bottom;e=e.top,i&&(e+=i),i=t.getSourceBlock();let s=i.workspace;for(;s.options.parentWorkspace;)s=s.options.parentWorkspace;return yr(s.getParentSvg().parentNode),kr(t,i.RTL,a,o,a,e,n,r)},kr=function(t,n,r,i,a,o,s,c){return Kd=t,zd=c||null,Hd.style.direction=n?`rtl`:`ltr`,t=Qe(),Bd=t.getRenderer().getClassName(),Vd=t.getTheme().getClassName(),O(Hd,Bd),O(Hd,Vd),r=Rr(r,i,a,o),s&&(Jd=e.getFocusManager$$module$build$src$core$focus_manager().takeEphemeralFocus(Hd)),r},Ar=function(e,t,n,r){return e=Nr(e,n.left,n.right,r.width),{initialX:e.divX,initialY:t,finalX:e.divX,finalY:t+Id,arrowX:e.arrowX,arrowY:-(Nd/2+Pd),arrowAtTop:!0,arrowVisible:!0}},jr=function(e,t,n,r){return e=Nr(e,n.left,n.right,r.width),{initialX:e.divX,initialY:t-r.height,finalX:e.divX,finalY:t-r.height-Id,arrowX:e.arrowX,arrowY:r.height-Pd*2-Nd/2,arrowAtTop:!1,arrowVisible:!0}},Mr=function(e,t,n){return e=Nr(e,t.left,t.right,n.width),{initialX:e.divX,initialY:0,finalX:e.divX,finalY:0,arrowAtTop:null,arrowX:null,arrowY:null,arrowVisible:!1}},Nr=function(e,t,n,r){return t=_r(t,e-r/2,n-r),e=e-Nd/2-t,n=Fd,e=_r(n,e,r-n-Nd),{arrowX:e,divX:t}},Pr=function(){return!!Kd},Fr=function(e,t){return Kd===e?(t?Lr():Ir(),!0):!1},Ir=function(){Hd.style.transform=`translate(0, 0)`,Hd.style.opacity=`0`,Rd=setTimeout(function(){Lr()},Ld*1e3),zd&&(zd(),zd=null)},Lr=function(){Pr()&&(Rd&&clearTimeout(Rd),zd&&(zd(),zd=null),Sr(),Kd=null,Qe().markFocused(),Jd&&(Jd(),Jd=null))},Rr=function(e,t,n,r){e=Xd.getPositionMetrics(e,t,n,r),e.arrowVisible?(t=e.arrowX,n=e.arrowY,r=e.arrowAtTop?45:225,Wd.style.display=``,Wd.style.transform=`translate(${t}px, ${n}px) rotate(${r}deg)`,Wd.setAttribute(`class`,`blocklyDropDownArrow`)):Wd.style.display=`none`,t=Math.floor(e.initialX),n=Math.floor(e.initialY),r=Math.floor(e.finalX);let i=Math.floor(e.finalY);return Hd.style.left=t+`px`,Hd.style.top=n+`px`,Hd.style.display=`block`,Hd.style.opacity=`1`,Hd.style.transform=`translate(`+(r-t)+`px,`+(i-n)+`px)`,!!e.arrowAtTop},zr=function(){if(Kd){var e=Kd.getSourceBlock();e=qd?Dr(Kd):Er(e);let t=e.left+(e.right-e.left)/2;Rr(t,e.bottom,t,e.top)}else Ir()},Br=function(e){return e.length?e.reduce(function(e,t){return e.length<t.length?e:t}).length:0},Vr=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;let n=0;t=t||Br(e);let r;for(r=0;r<t;r++){for(var i=e[0][r],a=1;a<e.length;a++)if(i!==e[a][r])return n;i===` `&&(n=r+1)}for(i=1;i<e.length;i++)if((a=e[i][r])&&a!==` `)return n;return t},Hr=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;let n=0;t=t||Br(e);let r;for(r=0;r<t;r++){for(var i=e[0].substr(-r-1,1),a=1;a<e.length;a++)if(i!==e[a].substr(-r-1,1))return n;i===` `&&(n=r+1)}for(i=1;i<e.length;i++)if((a=e[i].charAt(e[i].length-r-1))&&a!==` `)return n;return t},e.wrap$$module$build$src$core$utils$string=function(e,t){e=e.split(`
|
|
6
|
+
`);for(let n=0;n<e.length;n++)e[n]=Ur(e[n],t);return e.join(`
|
|
7
|
+
`)},Ur=function(e,t){if(e.length<=t)return e;let n=e.trim().split(/\s+/);for(var r=0;r<n.length;r++)n[r].length>t&&(t=n[r].length);var i=-1/0;let a,o=1;do{r=i,a=e,e=[],i=n.length/o;let s=1;for(let t=0;t<n.length-1;t++)s<(t+1.5)/i?(s++,e[t]=!0):e[t]=!1;e=Gr(n,e,t),i=Wr(n,e,t),e=Kr(n,e),o++}while(i>r);return a},Wr=function(e,t,n){let r=[0],i=[];for(var a=0;a<e.length;a++)r[r.length-1]+=e[a].length,t[a]===!0?(r.push(0),i.push(e[a].charAt(e[a].length-1))):t[a]===!1&&r[r.length-1]++;for(e=Math.max(...r),t=0,a=0;a<r.length;a++)t-=Math.abs(n-r[a])**1.5*2,t-=(e-r[a])**1.5,`.?!`.includes(i[a])?t+=n/3:`,;)]}`.includes(i[a])&&(t+=n/4);return r.length>1&&r[r.length-1]<=r[r.length-2]&&(t+=.5),t},Gr=function(e,t,n){let r=Wr(e,t,n),i;for(let a=0;a<t.length-1;a++){if(t[a]===t[a+1])continue;let o=[].concat(t);o[a]=!o[a],o[a+1]=!o[a+1];let s=Wr(e,o,n);s>r&&(r=s,i=o)}return i?Gr(e,i,n):t},Kr=function(e,t){let n=[];for(let r=0;r<e.length;r++)n.push(e[r]),t[r]!==void 0&&n.push(t[r]?`
|
|
8
|
+
`:` `);return n.join(``)},e.isNumber$$module$build$src$core$utils$string=function(e){return/^\s*-?\d+(\.\d+)?\s*$/.test(e)},qr=function(e){$d=e},Jr=function(){return $d},Yr=function(){return ef},Xr=function(){return q},Zr=function(e){if(e=Qr(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``},Qr=function(e){for(;e&&e.tooltip;){if(typeof e.tooltip==`string`||typeof e.tooltip==`function`)return e;e=e.tooltip}return null},$r=function(){document.querySelector(`.blocklyTooltipDiv`)||(q=document.createElement(`div`),q.className=`blocklyTooltipDiv`,(rt()||document.body).appendChild(q))},ei=function(e){e.mouseOverWrapper_=_(e,`pointerover`,null,ni),e.mouseOutWrapper_=_(e,`pointerout`,null,ri),e.addEventListener(`pointermove`,ii,!1)},ti=function(e){e&&(v(e.mouseOverWrapper_),v(e.mouseOutWrapper_),e.removeEventListener(`pointermove`,ii))},ni=function(e){tf||(e=Qr(e.currentTarget),cf!==e&&(oi(),lf=null,cf=e),clearTimeout(rf))},ri=function(e){tf||(rf=setTimeout(function(){lf=cf=null,oi()},1),clearTimeout(af),af=0)},ii=function(e){if(cf&&cf.tooltip&&!tf)if(ef){let t=of-e.pageX;e=sf-e.pageY,Math.sqrt(t*t+e*e)>ff&&oi()}else lf!==cf&&(clearTimeout(af),of=e.pageX,sf=e.pageY,af=setTimeout(fi,pf))},ai=function(){lf=cf=null,oi()},oi=function(){ef&&(ef=!1,q&&(q.style.display=`none`)),af&&(clearTimeout(af),af=0)},si=function(){oi(),tf=!0},ci=function(){tf=!1},li=function(){q&&cf&&(typeof $d==`function`?$d(q,cf):ui())},ui=function(){var t=Zr(cf);t=e.wrap$$module$build$src$core$utils$string(t,nf),t=t.split(`
|
|
9
|
+
`);for(let e=0;e<t.length;e++){let n=document.createElement(`div`);n.appendChild(document.createTextNode(t[e])),q.appendChild(n)}},di=function(e){let t=document.documentElement.clientWidth,n=document.documentElement.clientHeight,r=of;r=e?r-(uf+q.offsetWidth):r+uf;let i=sf+df;return i+q.offsetHeight>n+window.scrollY&&(i-=q.offsetHeight+2*df),e?r=Math.max(mf-window.scrollX,r):r+q.offsetWidth>t+window.scrollX-2*mf&&(r=t-q.offsetWidth-2*mf),{x:r,y:i}},fi=function(){if(!tf&&(lf=cf,q)){q.textContent=``,li();var e=cf.RTL;q.style.direction=e?`rtl`:`ltr`,q.style.display=`block`,ef=!0;var{x:t,y:n}=di(e);q.style.left=t+`px`,q.style.top=n+`px`}},pi=function(){return gf},mi=function(e){gf=e},hi=function(){return _f},gi=function(e){_f=e},_i=function(e){e=`${e}`.toLowerCase().trim();var t=vf[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 n=e.match(/^(?:rgb)?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);return n&&(e=Number(n[1]),t=Number(n[2]),n=Number(n[3]),e>=0&&e<256&&t>=0&&t<256&&n>=0&&n<256)?vi(e,t,n):null},vi=function(e,t,n){return t=e<<16|t<<8|n,e<16?`#`+(16777216|t).toString(16).substr(1):`#`+t.toString(16)},yi=function(e){return e=_i(e),e?(e=parseInt(e.substr(1),16),[e>>16,e>>8&255,e&255]):[0,0,0]},bi=function(e,t,n){let r=0,i=0,a=0;if(t===0)a=i=r=n;else{let o=Math.floor(e/60),s=e/60-o;e=n*(1-t);let c=n*(1-t*s);switch(t=n*(1-t*(1-s)),o){case 1:r=c,i=n,a=e;break;case 2:r=e,i=n,a=t;break;case 3:r=e,i=c,a=n;break;case 4:r=t,i=e,a=n;break;case 5:r=n,i=e,a=c;break;case 6:case 0:r=n,i=t,a=e}}return vi(Math.floor(r),Math.floor(i),Math.floor(a))},xi=function(e,t,n){return e=_i(e),!e||(t=_i(t),!t)?null:(e=yi(e),t=yi(t),vi(Math.round(t[0]+n*(e[0]-t[0])),Math.round(t[1]+n*(e[1]-t[1])),Math.round(t[2]+n*(e[2]-t[2]))))},Si=function(e){return bi(e,gf,_f*255)},Ci=function(t,n,r){let i=[];var a=t.split(``);a.push(``);var o=0;t=[];let s=null;for(let u=0;u<a.length;u++){var c=a[u];if(o===0)if(c===`%`)(o=t.join(``))&&i.push(o),t.length=0,o=1;else if(r&&c===`
|
|
10
|
+
`){let e=t.join(``);e&&i.push(e),t.length=0,i.push(c)}else t.push(c);else if(o===1)c===`%`?(t.push(c),o=0):n&&`0`<=c&&c<=`9`?(o=2,s=c,(c=t.join(``))&&i.push(c),t.length=0):c===`{`?o=3:(t.push(`%`,c),o=0);else if(o===2)if(`0`<=c&&c<=`9`)s+=c;else{var l=void 0;i.push(parseInt((l=s)??``,10)),u--,o=0}else o===3&&(c===``?(t.splice(0,0,`%{`),u--,o=0):c===`}`?(o=t.join(``),/[A-Z]\w*/i.test(o)?(c=o.toUpperCase(),(c=c.startsWith(`BKY_`)?c.substring(4):null)&&c in e.Msg$$module$build$src$core$msg?(o=e.Msg$$module$build$src$core$msg[c],typeof o==`string`?Array.prototype.push.apply(i,Ci(o,n,r)):n?i.push(`${o}`):i.push(o)):i.push(`%{`+o+`}`)):i.push(`%{`+o+`}`),o=t.length=0):t.push(c))}for((n=t.join(``))&&i.push(n),l=[],t.length=0,a=0;a<i.length;a++)typeof i[a]!=`string`||r&&i[a]===`
|
|
11
|
+
`?((n=t.join(``))&&l.push(n),t.length=0,l.push(i[a])):t.push(i[a]);return(n=t.join(``))&&l.push(n),t.length=0,l},wi=function(e){return Ci(e,!0,!0)},Ti=function(e){return typeof e==`string`?(e=Ci(e,!1,!1),e.length?String(e[0]):``):e},Ei=function(t){let n=!0,r=e.Msg$$module$build$src$core$msg,i=t.match(/%{BKY_[A-Z]\w*}/gi);if(i)for(let e=0;e<i.length;e++)r[i[e].toUpperCase().slice(6,-1)]===void 0&&(console.warn(`No message string for `+i[e]+` in `+t),n=!1);return n},Di=function(e){let t=typeof e==`string`?Ti(e):e;var n=Number(t);if(!isNaN(n)&&0<=n&&n<=360)return{hue:n,hex:bi(n,pi(),hi()*255)};if(n=_i(t))return{hue:null,hex:n};throw n=`Invalid colour: "`+t+`"`,e!==t&&(n+=` (from "`+e+`")`),Error(n)},Oi=function(){return Af},ki=function(e){if(Af=e,e===null){let e;(e=document.querySelector(`.`+Df))==null||e.remove()}},Ai=function(){let e=rt()||document.body,t=document.querySelector(`div.`+Df);t?Af=t:(Af=document.createElement(`div`),Af.className=Df,Af.tabIndex=-1),g(Af,`keydown`,null,ut),e.appendChild(Af)},ji=function(t,n,r,i,a=!0){Mi(),wf=t,Ef=r,(r=Af)&&(r.style.direction=n?`rtl`:`ltr`,r.style.display=`block`,!i&&t instanceof xf&&(i=t.getSourceBlock()?.workspace),Tf=i??null,t=i??Qe(),Of=t.getRenderer().getClassName(),kf=t.getTheme().getClassName(),Of&&O(r,Of),kf&&O(r,kf),a&&(jf=e.getFocusManager$$module$build$src$core$focus_manager().takeEphemeralFocus(r)))},Mi=function(){if(Ni()){wf=null;var e=Af;e&&(e.style.display=`none`,e.style.left=``,e.style.top=``,Ef&&(Ef(),Ef=null),e.textContent=``,Of&&(k(e,Of),Of=``),kf&&(k(e,kf),kf=``),Qe().markFocused(),jf&&(jf(),jf=null))}},Ni=function(){return!!wf},Pi=function(e){wf===e&&Mi()},Fi=function(e){let t=Tf===null,n=e;for(;!t&&n;){if(n===e){t=!0;break}n=e.options.parentWorkspace}t&&Mi()},Ii=function(e,t,n){Af.style.left=e+`px`,Af.style.top=t+`px`,Af.style.height=n+`px`},Li=function(e,t,n,r){let i=zi(e,t,n);e=Ri(e,t,n,r),i<0?Ii(e,0,n.height+i):Ii(e,i,n.height)},Ri=function(e,t,n,r){return r?Math.min(Math.max(t.right-n.width,e.left),e.right-n.width):Math.max(Math.min(t.left,e.right-n.width),e.left)},zi=function(e,t,n){return t.bottom+n.height>=e.bottom?t.top-n.height:t.bottom},Bi=function(e){return!(e==null||!e.repositionForWindowResize)},Vi=function(){Bi(wf)&&wf.repositionForWindowResize()||Mi()},Hi=function(){return Nf},Ui=function(e){Nf=e},Wi=function(e,t,n,r,i){if(ji(Pf,n,Xi,r),t.length){i||(e instanceof PointerEvent?i=new I(e.clientX,e.clientY):(console.warn(`Context menu opened with keyboard but no location given`),i=new I(0,0)));var a=Gi(t,n,e,i);Ff=a,Ki(a,n,i),setTimeout(function(){a.focus()},1),Nf=null}else Yi()},Gi=function(e,t,n,r){let i=new Fu;i.setRole(Au.MENU);for(let a=0;a<e.length;a++){let o=e[a];if(o.separator){i.addChild(new Lu);continue}let s=new Nu(o.text);s.setRightToLeft(t),s.setRole(Au.MENUITEM),i.addChild(s),s.setEnabled(o.enabled),o.enabled&&s.onAction(function(e,t){Yi(),requestAnimationFrame(()=>{setTimeout(()=>{o.callback(o.scope,n,t,r)},0)})},{})}return i},Ki=function(e,t,n){let r=Tt();n=new R(n.y+r.top,n.y+r.top,n.x+r.left,n.x+r.left),qi(e);let i=e.getSize();t&&(n.left+=i.width,n.right+=i.width,r.left+=i.width,r.right+=i.width),Li(r,n,i,t),e.focus()},qi=function(e){var t=Oi();if(!t)throw Error(`Attempting to create a context menu when widget div is null`);t=e.render(t),O(t,`blocklyContextMenu`),g(t,`contextmenu`,null,Ji),e.focus()},Ji=function(e){e.preventDefault(),e.stopPropagation()},Yi=function(){Pi(Pf),Nf=null;let e;(e=Ff)==null||e.dispose(),Ff=null},Xi=function(){Ff&&(Ff.dispose(),Ff=null)},e.callbackFactory$$module$build$src$core$contextmenu=function(t,n){return()=>{e.disable$$module$build$src$core$events$utils();let r;try{r=n instanceof Element?ma(n,t.workspace):tr(n,t.workspace);let i=t.getRelativeToSurfaceXY();i.x=t.RTL?i.x-e.config$$module$build$src$core$config.snapRadius:i.x+e.config$$module$build$src$core$config.snapRadius,i.y+=e.config$$module$build$src$core$config.snapRadius*2,r.moveBy(i.x,i.y)}finally{e.enable$$module$build$src$core$events$utils()}return je()&&!r.isShadow()&&w(new(E(F.BLOCK_CREATE))(r)),e.getFocusManager$$module$build$src$core$focus_manager().focusNode(r),r}},Zi=function(){return Ff},Qi=function(e,t){return t=ee(t,e.getParentSvg(),e.getInverseScreenCTM()),t.x/=e.scale,t.y/=e.scale,t},$i=function(e,t,n){t=Qi(e,t),Wf.set(e,I.difference(n,t))},ea=function(e,t){if(t=Qi(e,t),e=Wf.get(e),!e)throw Error(`Drag not initialized`);return I.sum(e,t)},ta=function(t,n=!1){let r=e.createElement$$module$build$src$core$utils$xml(`xml`);var i=ra(e.allUsedVarModels$$module$build$src$core$variables(t));i.hasChildNodes()&&r.appendChild(i);for(let e of t.getTopComments())r.appendChild(na(e,n));for(t=t.getTopBlocks(!0),i=0;i<t.length;i++)r.appendChild(ia(t[i],n));return r},na=function(t,n=!1){let r=e.createElement$$module$build$src$core$utils$xml(`comment`);n||r.setAttribute(`id`,t.id),n=t.workspace;let i=t.getRelativeToSurfaceXY().clone();return i.x=n.RTL?n.getWidth()-i.x:i.x,r.setAttribute(`x`,`${i.x}`),r.setAttribute(`y`,`${i.y}`),r.setAttribute(`w`,`${t.getSize().width}`),r.setAttribute(`h`,`${t.getSize().height}`),t.getText()&&(r.textContent=t.getText()),t.isCollapsed()&&r.setAttribute(`collapsed`,`true`),t.isOwnEditable()||r.setAttribute(`editable`,`false`),t.isOwnMovable()||r.setAttribute(`movable`,`false`),t.isOwnDeletable()||r.setAttribute(`deletable`,`false`),r},ra=function(t){let n=e.createElement$$module$build$src$core$utils$xml(`variables`);for(let r=0;r<t.length;r++){let i=t[r],a=e.createElement$$module$build$src$core$utils$xml(`variable`);a.appendChild(e.createTextNode$$module$build$src$core$utils$xml(i.getName())),i.getType()&&a.setAttribute(`type`,i.getType()),a.id=i.getId(),n.appendChild(a)}return n},ia=function(e,t){if(e.isInsertionMarker()&&(e=e.getChildren(!1)[0],!e))return new DocumentFragment;let n=0;if(e.workspace.RTL&&(n=e.workspace.getWidth()),t=sa(e,t),Da(t)){let r=e.getRelativeToSurfaceXY();t.setAttribute(`x`,String(Math.round(e.workspace.RTL?n-r.x:r.x))),t.setAttribute(`y`,String(Math.round(r.y)))}return t},aa=function(t){if(t.isSerializable()){let n=e.createElement$$module$build$src$core$utils$xml(`field`);return n.setAttribute(`name`,t.name||``),t.toXml(n)}return null},oa=function(e,t){for(let n of e.getFields())(e=aa(n))&&t.appendChild(e)},sa=function(t,n){if(t.isInsertionMarker())return(n=t.getChildren(!1)[0])?sa(n):new DocumentFragment;let r=e.createElement$$module$build$src$core$utils$xml(t.isShadow()?`shadow`:`block`);if(r.setAttribute(`type`,t.type),n||(r.id=t.id),t.mutationToDom){var i=t.mutationToDom();i&&(i.hasChildNodes()||i.hasAttributes())&&r.appendChild(i)}if(oa(t,r),i=t.getCommentText()){var a=t.getIcon(G.COMMENT),o=a.getBubbleSize(),s=a.bubbleIsVisible();a=a.getBubbleLocation();var c=e.createElement$$module$build$src$core$utils$xml(`comment`);c.appendChild(e.createTextNode$$module$build$src$core$utils$xml(i)),c.setAttribute(`pinned`,`${s}`),c.setAttribute(`h`,`${o.height}`),c.setAttribute(`w`,`${o.width}`),a&&(c.setAttribute(`x`,`${t.workspace.RTL?t.workspace.getWidth()-(a.x+o.width):a.x}`),c.setAttribute(`y`,`${a.y}`)),r.appendChild(c)}for(t.data&&(i=e.createElement$$module$build$src$core$utils$xml(`data`),i.appendChild(e.createTextNode$$module$build$src$core$utils$xml(t.data)),r.appendChild(i)),i=0;i<t.inputList.length;i++){o=t.inputList[i];var l=void 0;s=!0,o.type!==e.inputTypes$$module$build$src$core$inputs$input_types.DUMMY&&o.type!==e.inputTypes$$module$build$src$core$inputs$input_types.END_ROW&&(a=o.connection.targetBlock(),o.type===e.inputTypes$$module$build$src$core$inputs$input_types.VALUE?l=e.createElement$$module$build$src$core$utils$xml(`value`):o.type===e.inputTypes$$module$build$src$core$inputs$input_types.STATEMENT&&(l=e.createElement$$module$build$src$core$utils$xml(`statement`)),c=o.connection.getShadowDom(),!c||a&&a.isShadow()||l.appendChild(ca(c,n)),a&&(a=sa(a,n),a.nodeType===il.ELEMENT_NODE&&(l.appendChild(a),s=!1)),l.setAttribute(`name`,o.name),s||r.appendChild(l))}t.inputsInline!==void 0&&t.inputsInline!==t.inputsInlineDefault&&r.setAttribute(`inline`,String(t.inputsInline)),t.isCollapsed()&&r.setAttribute(`collapsed`,`true`),t.isEnabled()||r.setAttribute(`disabled-reasons`,Array.from(t.getDisabledReasons()).map(encodeURIComponent).join(`,`)),t.isOwnDeletable()||r.setAttribute(`deletable`,`false`),t.isOwnMovable()||r.setAttribute(`movable`,`false`),t.isOwnEditable()||r.setAttribute(`editable`,`false`),l=t.getNextBlock();let u;return l&&(i=sa(l,n),i.nodeType===il.ELEMENT_NODE&&(u=e.createElement$$module$build$src$core$utils$xml(`next`),u.appendChild(i),r.appendChild(u))),t=t.nextConnection&&t.nextConnection.getShadowDom(),!t||l&&l.isShadow()||u.appendChild(ca(t,n)),r},ca=function(e,t){let n=e=e.cloneNode(!0),r;for(;n;)if(t&&n.nodeName===`shadow`&&n.removeAttribute(`id`),n.firstChild)n=n.firstChild;else{for(;n&&!n.nextSibling;)r=n,n=n.parentNode,r.nodeType===il.TEXT_NODE&&r.data.trim()===``&&n?.firstChild!==r&&A(r);n&&(r=n,n=n.nextSibling,r.nodeType===il.TEXT_NODE&&r.data.trim()===``&&A(r))}return e},la=function(e){return At(e).replace(/<(\w+)([^<]*)\/>/g,`<$1$2></$1>`)},ua=function(e){e=la(e).split(`<`);let t=``;for(let n=1;n<e.length;n++){let r=e[n];r[0]===`/`&&(t=t.substring(2)),e[n]=t+`<`+r,r[0]!==`/`&&r.slice(-2)!==`/>`&&(t+=` `)}return e=e.join(`
|
|
12
|
+
`),e=e.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,`$1</$2>`),e.replace(/^\n/,``)},da=function(t,n){return n.setResizesEnabled(!1),n.clear(),t=e.domToWorkspace$$module$build$src$core$xml(t,n),n.setResizesEnabled(!0),t},e.domToWorkspace$$module$build$src$core$xml=function(t,n){let r=0;n.RTL&&(r=n.getWidth());let i=[];ze();let a=e.getGroup$$module$build$src$core$events$utils();a||e.setGroup$$module$build$src$core$events$utils(!0),n.setResizesEnabled&&n.setResizesEnabled(!1);let o=!0;try{for(let e=0,a;a=t.childNodes[e];e++){let e=a.nodeName.toLowerCase(),t=a;if(e===`block`||e===`shadow`&&!Te()){let e=ma(t,n);i.push(e.id);let a=parseInt(t.getAttribute(`x`)??`10`,10),s=parseInt(t.getAttribute(`y`)??`10`,10);isNaN(a)||isNaN(s)||e.moveBy(n.RTL?r-a:a,s,[`create`]),o=!1}else{if(e===`shadow`)throw TypeError(`Shadow block cannot be a top-level block.`);if(e===`comment`)fa(t,n);else if(e===`variables`){if(o)ha(t,n);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.`);o=!1}}}}finally{e.setGroup$$module$build$src$core$events$utils(a),n.setResizesEnabled&&n.setResizesEnabled(!0),n.rendered&&an(),Be()}return w(new(E(F.FINISHED_LOADING))(n)),i},fa=function(e,t){var n;let r=(n=e.getAttribute(`id`))??void 0;n=t.rendered?new sp(t,r):new ap(t,r);var i;n.setText((i=e.textContent)??``);var a;i=parseInt((a=e.getAttribute(`x`))??``,10),a=parseInt(e.getAttribute(`y`)??``,10),isNaN(i)||isNaN(a)||(i=t.RTL?t.getWidth()-i:i,n.moveTo(new I(i,a)));var o;return t=parseInt((o=e.getAttribute(`w`))??``,10),o=parseInt(e.getAttribute(`h`)??``,10),isNaN(t)||isNaN(o)||n.setSize(new z(t,o)),e.getAttribute(`collapsed`)===`true`&&n.setCollapsed(!0),e.getAttribute(`editable`)===`false`&&n.setEditable(!1),e.getAttribute(`movable`)===`false`&&n.setMovable(!1),e.getAttribute(`deletable`)===`false`&&n.setDeletable(!1),n},pa=function(t,n){if(!n.getBlocksBoundingBox)return e.domToWorkspace$$module$build$src$core$xml(t,n);var r=n.getBlocksBoundingBox();if(t=e.domToWorkspace$$module$build$src$core$xml(t,n),r&&r.top!==r.bottom){var i=r.bottom;r=n.RTL?r.right:r.left;var a=1/0;let e=-1/0,o=1/0;for(let r=0;r<t.length;r++){let i=n.getBlockById(t[r]).getRelativeToSurfaceXY();i.y<o&&(o=i.y),i.x<a&&(a=i.x),i.x>e&&(e=i.x)}for(i=i-o+10,r=n.RTL?r-e:r-a,a=0;a<t.length;a++)n.getBlockById(t[a]).moveBy(r,i,[`create`])}return t},e.domToBlock$$module$build$src$core$xml=function(e,t){return e=ma(e,t),t.rendered&&an(),e},ma=function(t,n){e.disable$$module$build$src$core$events$utils();var r=n.getVariableMap().getAllVariables();let i;try{if(i=wa(t,n),n.rendered){let e=i,t=i.getDescendants(!1);e.setConnectionTracking(!1);for(let e=t.length-1;e>=0;e--)t[e].initSvg();for(let e=t.length-1;e>=0;e--)t[e].queueRender();setTimeout(function(){e.disposed||e.setConnectionTracking(!0)},1),n.resizeContents()}else{let e=i.getDescendants(!1);for(let t=e.length-1;t>=0;t--)e[t].initModel()}}finally{e.enable$$module$build$src$core$events$utils()}if(je()){for(t=Hn(n,r),n=0;n<t.length;n++)r=t[n],w(new(E(F.VAR_CREATE))(r));w(new(E(F.BLOCK_CREATE))(i))}return i},ha=function(e,t){for(let r=0;r<e.children.length;r++){var n=e.children[r];let i=n.getAttribute(`type`),a=n.getAttribute(`id`);if(n=n.textContent,!n)break;t.getVariableMap().createVariable(n,i??void 0,a)}},ga=function(e){let t={mutation:[],comment:[],data:[],field:[],input:[],next:[]};for(let n=0;n<e.children.length;n++){let r=e.children[n];if(r.nodeType!==il.TEXT_NODE)switch(r.nodeName.toLowerCase()){case`mutation`:t.mutation.push(r);break;case`comment`:t.comment.push(r);break;case`data`:t.data.push(r);break;case`title`:case`field`:t.field.push(r);break;case`value`:case`statement`:t.input.push(r);break;case`next`:t.next.push(r);break;default:console.warn(`Ignoring unknown tag: `+r.nodeName)}}return t},_a=function(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];t.domToMutation&&(t.domToMutation(i),t.initSvg&&(n=!0))}return n},va=function(e,t){for(let n=0;n<e.length;n++){let r=e[n],i=r.textContent,a=r.getAttribute(`pinned`)===`true`,o=parseInt(r.getAttribute(`w`)??`50`,10),s=parseInt(r.getAttribute(`h`)??`50`,10),c=parseInt(r.getAttribute(`x`)??``,10),l=parseInt(r.getAttribute(`y`)??``,10);t.setCommentText(i);let u=t.getIcon(G.COMMENT);isNaN(o)||isNaN(s)||u.setBubbleSize(new z(o,s)),u.setBubbleVisible(a),setTimeout(()=>{isNaN(c)||isNaN(l)||(c=t.workspace.RTL?t.workspace.getWidth()-(c+o):c,u.setBubbleLocation(new I(c,l))),u.setBubbleVisible(a)},1)}},ya=function(e,t){for(let n=0;n<e.length;n++)t.data=e[n].textContent},ba=function(e,t){for(let n=0;n<e.length;n++){let r=e[n],i=r.getAttribute(`name`);i?Ta(t,i,r):console.warn(`Ignoring unnamed field in block ${t.type}`)}},xa=function(e){let t=null,n=null;for(let r=0;r<e.childNodes.length;r++){let i=e.childNodes[r];Da(i)&&(i.nodeName.toLowerCase()===`block`?t=i:i.nodeName.toLowerCase()===`shadow`&&(n=i))}return{childBlockElement:t,childShadowElement:n}},Sa=function(e,t,n,r){for(let a=0;a<e.length;a++){var i=e[a];let o=i.getAttribute(`name`),s=o?n.getInput(o):null;if(!s){console.warn(`Ignoring non-existent input `+o+` in block `+r);break}if(i=xa(i),i.childBlockElement){if(!s.connection)throw TypeError(`Input connection does not exist.`);wa(i.childBlockElement,t,s.connection,!1)}if(i.childShadowElement){let e;(e=s.connection)==null||e.setShadowDom(i.childShadowElement)}}},Ca=function(e,t,n){for(let r=0;r<e.length;r++){let i=xa(e[r]);if(i.childBlockElement){if(!n.nextConnection)throw TypeError(`Next statement does not exist.`);if(n.nextConnection.isConnected())throw TypeError(`Next statement is already connected.`);wa(i.childBlockElement,t,n.nextConnection,!0)}i.childShadowElement&&n.nextConnection&&n.nextConnection.setShadowDom(i.childShadowElement)}},wa=function(e,t,n,r){var i;let a=e.getAttribute(`type`);if(!a)throw TypeError(`Block type unspecified: `+e.outerHTML);var o=(i=e.getAttribute(`id`))??void 0;i=t.newBlock(a,o),o=ga(e);let s=_a(o.mutation,i);if(va(o.comment,i),ya(o.data,i),n)if(r)if(i.previousConnection)n.connect(i.previousConnection);else throw TypeError(`Next block does not have previous statement.`);else if(i.outputConnection)n.connect(i.outputConnection);else if(i.previousConnection)n.connect(i.previousConnection);else throw TypeError(`Child block does not have output or previous statement.`);if(ba(o.field,i),Sa(o.input,t,i,a),Ca(o.next,t,i),s&&i.initSvg(),(t=e.getAttribute(`inline`))&&i.setInputsInline(t===`true`),(t=e.getAttribute(`disabled`))&&i.setDisabledReason(t===`true`||t===`disabled`,Vu),t=e.getAttribute(`disabled-reasons`),t!==null)for(var c of t.split(`,`))i.setDisabledReason(!0,decodeURIComponent(c));if((c=e.getAttribute(`deletable`))&&i.setDeletable(c===`true`),(c=e.getAttribute(`movable`))&&i.setMovable(c===`true`),(c=e.getAttribute(`editable`))&&i.setEditable(c===`true`),(c=e.getAttribute(`collapsed`))&&i.setCollapsed(c===`true`),e.nodeName.toLowerCase()===`shadow`){for(e=i.getChildren(!1),c=0;c<e.length;c++)if(!e[c].isShadow())throw TypeError(`Shadow block not allowed non-shadow child.`);i.setShadow(!0)}return i},Ta=function(e,t,n){let r=e.getField(t);r?r.fromXml(n):console.warn(`Ignoring non-existent field `+t+` in block `+e.type)},Ea=function(e){for(let t=0;t<e.childNodes.length;t++){let n=e.childNodes[t];if(n.nodeName.toLowerCase()===`next`){e.removeChild(n);break}}},Da=function(e){return e.nodeType===il.ELEMENT_NODE},Oa=function(e,n){t(P.FIELD,e,n,!0)},ka=function(e){r(P.FIELD,e)},e.fromJson$$module$build$src$core$field_registry=function(e){return _p.fromJsonInternal(e)},Aa=function(e){let t=s(P.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)},ja=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`},e.register$$module$build$src$core$extensions=function(e,t){if(typeof e!=`string`||e.trim()===``)throw Error(`Error: Invalid extension name "`+e+`"`);if(Rp[e])throw Error(`Error: Extension "`+e+`" is already registered.`);if(typeof t!=`function`)throw Error(`Error: Extension "`+e+`" must be a function`);Rp[e]=t},e.registerMixin$$module$build$src$core$extensions=function(t,n){if(!n||typeof n!=`object`)throw Error(`Error: Mixin "`+t+`" must be a object`);e.register$$module$build$src$core$extensions(t,function(){this.mixin(n)})},e.registerMutator$$module$build$src$core$extensions=function(t,n,r,i){let a=`Error when registering mutator "`+t+`": `;Ba(a,n);let o=Ra(n,a);if(r&&typeof r!=`function`)throw Error(a+`Extension "`+t+`" is not a function`);e.register$$module$build$src$core$extensions(t,function(){o&&this.setMutator(new e.MutatorIcon$$module$build$src$core$icons$mutator_icon(i||[],this)),this.mixin(n),r&&r.apply(this)})},Ma=function(e){Na(e)?delete Rp[e]:console.warn(`No extension mapping for name "`+e+`" found to unregister`)},Na=function(e){return!!Rp[e]},Pa=function(e,t,n){let r=Rp[e];if(typeof r!=`function`)throw Error(`Error: Extension "`+e+`" not found.`);let i;if(n?Fa(e,t):i=Va(t),r.apply(t),n)Ba(`Error after applying mutator "`+e+`": `,t);else if(!Ha(i,t))throw Error(`Error when applying extension "`+e+`": mutation properties changed when applying a non-mutator extension.`)},Fa=function(e,t){if(Va(t).length)throw Error(`Error: tried to apply mutation "`+e+`" to a block that already has mutator functions. Block id: `+t.id)},Ia=function(e,t){return za(e.mutationToDom,e.domToMutation,t+` mutationToDom/domToMutation`)},La=function(e,t){return za(e.saveExtraState,e.loadExtraState,t+` saveExtraState/loadExtraState`)},Ra=function(e,t){return za(e.compose,e.decompose,t+` compose/decompose`)},za=function(e,t,n){if(e&&t){if(typeof e!=`function`||typeof t!=`function`)throw Error(n+` must be a function`);return!0}if(!e&&!t)return!1;throw Error(n+`Must have both or neither functions`)},Ba=function(e,t){let n=Ia(t,e),r=La(t,e);if(!n&&!r)throw Error(e+`Mutations must contain either XML hooks, or JSON hooks, or both`);Ra(t,e)},Va=function(e){let 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},Ha=function(e,t){if(t=Va(t),t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0},Ua=function(e){if(typeof document!=`object`)throw Error(`runAfterPageLoad() requires browser document.`);if(document.readyState===`complete`)e();else{let t=setInterval(function(){document.readyState===`complete`&&(clearInterval(t),e())},10)}},e.buildTooltipForDropdown$$module$build$src$core$extensions=function(e,t){let n=[];return function(){n.includes(this.type)||(Wa(this,e,t),n.push(this.type)),this.setTooltip(function(){let n=String(this.getFieldValue(e));return Ti(t[n])}.bind(this))}},Wa=function(e,t,n){var r=e.getField(t);if(r instanceof yp&&!r.isOptionListDynamic()){r=r.getOptions();for(let i of r)i!==yp.SEPARATOR&&([,r]=i,n[r]===void 0&&console.warn(`No tooltip mapping for value ${r} of field ${t} of block type ${e.type}.`))}},e.buildTooltipWithFieldText$$module$build$src$core$extensions=function(e,t){return function(){this.setTooltip(function(){let n=this.getField(t);return Ti(e).replace(`%1`,n?n.getText():``)}.bind(this))}},Ga=function(){let e=this.tooltip;this.setTooltip(function(){let t=this.getParent();return t&&t.getInputsInline()&&t.tooltip||e}.bind(this))},j=function(e,t){return` `+e+`,`+t+` `},Ka=function(e,t){return` `+e+t.join(``)},qa=function(e,t){return` M `+e+`,`+t+` `},Ja=function(e,t){return` m `+e+`,`+t+` `},Ya=function(e,t){return` l `+e+`,`+t+` `},Xa=function(e){return` l`+e.join(``)},M=function(e,t){return` `+e+` `+t+` `},Za=function(e,t,n,r){return e+` `+n+` `+n+` `+t+r},Qa=function(e,t){if(!e||!t)throw Error(`Cannot connect null connections.`);e.targetConnection=t,t.targetConnection=e},$a=function(e,t){let n=null;t=t.outputConnection;let r=t?.getConnectionChecker();for(let i=0,a;a=e.inputList[i];i++){let e=a.connection,i;if(e&&(i=r)!=null&&i.canConnect(t,e,!1)){if(n)return null;n=e}}return n},eo=function(e,t){let n;for(;n=$a(e,t);)if(e=n.targetBlock(),!e||e.isShadow())return n;return null},to=function(e){return Ge(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`},no=function(e){return to(e)&&mr(e)&&tn(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()===G.COMMENT},ro=function(e){if(!(e.getDescendants(!1).length>100)){var t=e.workspace,n=e.getSvgRoot();t.getAudioManager().play(`delete`);var r=e.getRelativeToSurfaceXY(),i=n.cloneNode(!0);i.setAttribute(`transform`,`translate(`+r.x+`,`+r.y+`)`);var a;(a=t.getLayerManager())==null||a.appendToAnimationLayer({getSvgRoot:()=>i}),io(i,{x:r.x,y:r.y,width:e.width,height:e.height},t.RTL,new Date)}},io=function(e,t,n,r){let i=(new Date().getTime()-r.getTime())/150;i>1?A(e):(e.setAttribute(`transform`,`translate(`+(t.x+(n?-1:1)*t.width/2*i)+`,`+(t.y+t.height/2*i)+`) scale(`+(1-i)+`)`),setTimeout(io,10,e,t,n,r))},ao=function(e){var t=e.workspace;let n=t.scale;if(t.getAudioManager().play(`click`),!(n<1)){var r=t.getSvgXY(e.getSvgRoot());e.outputConnection?(r.x+=(e.RTL?3:-3)*n,r.y+=13*n):e.previousConnection&&(r.x+=(e.RTL?-23:23)*n,r.y+=3*n);var i=D(L.CIRCLE,{cx:r.x,cy:r.y,r:0,fill:`none`,stroke:`#888`,"stroke-width":10},t.getParentSvg());e=D(L.ANIMATE,{id:`animationCircle`,begin:`indefinite`,attributeName:`r`,dur:`150ms`,from:0,to:25*n},i),t=D(L.ANIMATE,{id:`animationOpacity`,begin:`indefinite`,attributeName:`opacity`,dur:`150ms`,from:1,to:0},i),e.beginElement(),t.beginElement(),setTimeout(()=>void A(i),150)}},oo=function(e){if(co(),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),Om=e,so(e,t,new Date,0)}},so=function(e,t,n,r){let i=[.66,1,.66,0,-.66,-1,-.66,0],a=``;n.getTime()+200>new Date().getTime()&&(a=`skewX(${Math.round(i[r%i.length]*t)})`,Dm=setTimeout(so,15,e,t,n,r+1)),e.getSvgRoot().setAttribute(`transform`,`${e.getTranslation()} ${a}`)},co=function(){Om&&(Dm&&(clearTimeout(Dm),Dm=null),Om.getSvgRoot().setAttribute(`transform`,Om.getTranslation()),Om=null)},lo=function(t,n){t.workspace.RTL&&(n.x=t.workspace.getWidth()-n.x);let r=t.workspace,i=e.config$$module$build$src$core$config.snapRadius,a=I.difference(n,t.getRelativeToSurfaceXY()),o=new I(0,0),s=r.getAllBlocks(!1).filter(e=>e.id!=t.id).map(e=>e.getRelativeToSurfaceXY());for(;uo(I.sum(n,o),s)||fo(t,I.sum(a,o),i);)r.RTL?o.translate(-i,i*2):o.translate(i,i*2);t.moveTo(I.sum(n,o))},uo=function(e,t){return t.some(t=>Math.abs(t.x-e.x)<=1&&Math.abs(t.y-e.y)<=1)},fo=function(e,t,n){return e.getConnections_(!1).some(e=>!!e.closest(n,t).connection)},po=function(e,t,n){let r=n.getBoundingRectangle(),i=r.right-r.left,a=_r(t.top,r.top,t.top+t.height-(r.bottom-r.top))-r.top,o=t.left;return t=t.left+t.width-i,e.RTL?o=Math.min(t,o):t=Math.max(o,t),(e=_r(o,r.left,t)-r.left)||a?(n.moveBy(e,a,[`inbounds`]),!0):!1},mo=function(t){return n=>{var r=t.getMetricsManager();if(r.hasFixedEdges()&&!t.isDragging()){var i;if(Vc.includes((i=n.type)??``)){i=r.getScrollMetrics(!0);let a=ho(t,n);a&&(r=e.getGroup$$module$build$src$core$events$utils()||!1,e.setGroup$$module$build$src$core$events$utils(n.group),po(t,i,a)&&!n.group&&console.warn(`Moved object in bounds but there was no event group. This may break undo.`),e.setGroup$$module$build$src$core$events$utils(r))}else ge(n)&&n.scale&&n.oldScale&&n.scale>n.oldScale&&go(t)}}},ho=function(e,t){let n=null;switch(t.type){case F.BLOCK_CREATE:case F.BLOCK_MOVE:(n=e.getBlockById(t.blockId))&&(n=n.getRootBlock());break;case F.COMMENT_CREATE:case F.COMMENT_MOVE:case F.COMMENT_RESIZE:n=e.getCommentById(t.commentId)}return n},go=function(e){var t=e.getMetricsManager();if(t.hasFixedEdges()&&!e.isDragging()){t=t.getScrollMetrics(!0);var n=e.getTopBoundedElements();for(let r=0,i;i=n[r];r++)po(e,t,i)}},_o=function(e){return e&&typeof e.isDeletable==`function`&&typeof e.dispose==`function`&&typeof e.setDeleteStyle==`function`},vo=function(e,t){let n=e.getIcons();for(let r of e.inputList){if(!r.isVisible())continue;n.push(...r.fieldRow);let i;(i=r.connection)!=null&&i.targetBlock()?(e=r.connection.targetBlock(),(r.connection.type!==Y.NEXT_STATEMENT||t||(e=e.lastConnectionInStack(!1)?.getSourceBlock()))&&n.push(e)):r.connection?.type===Y.INPUT_VALUE&&n.push(r.connection)}return n},yo=function(e,t){let n=e.workspace.getTopBoundedElements(!0).filter(e=>Ge(e));e=n.indexOf(e instanceof Bm?e.getRootBlock():e)+t;let r=null;return e>=0&&e<n.length?r=n[e]:e<0?r=n[n.length-1]:e>=n.length&&(r=n[0]),t<0&&r instanceof Bm?r.lastConnectionInStack(!1)?.getSourceBlock()??r:r},bo=function(e,t){var n;let r=e instanceof Bm?(n=e.outputConnection)?.targetBlock()??e.getSurroundParent():e.getSourceBlock();return!(r instanceof Bm)||(n=vo(r,t>0),e=n.indexOf(e),e===-1)?null:(t=e+t,t>=0&&t<n.length?n[t]:null)},xo=function(e,n){t(P.ICON,e.toString(),n)},So=function(e){r(P.ICON,e)},Co=function(e){return e&&typeof e.showContextMenu==`function`},wo=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`},To=function(e){return e&&typeof e.autoHide==`function`},Eo=function(e){return typeof e.getProcedureModel==`function`&&typeof e.doProcedureUpdate==`function`&&typeof e.isProcedureDef==`function`},Do=function(e){return e&&typeof e.startPublishing==`function`&&typeof e.stopPublishing==`function`},Oo=function(e){let t=e.getProcedureMap().getProcedures().filter(e=>!e.getReturnTypes()).map(e=>[e.getName(),e.getParameters().map(e=>e.getName()),!1]);e.getBlocksByType(`procedures_defnoreturn`,!1).forEach(e=>{!Eo(e)&&bn(e)&&t.push(e.getProcedureDef())});let n=e.getProcedureMap().getProcedures().filter(e=>!!e.getReturnTypes()).map(e=>[e.getName(),e.getParameters().map(e=>e.getName()),!0]);return e.getBlocksByType(`procedures_defreturn`,!1).forEach(e=>{!Eo(e)&&bn(e)&&n.push(e.getProcedureDef())}),t.sort(ko),n.sort(ko),[t,n]},ko=function(e,t){return e[0].localeCompare(t[0],void 0,{sensitivity:`base`})},e.findLegalName$$module$build$src$core$procedures=function(t,n){if(n.isInFlyout)return t;for(t=t||e.Msg$$module$build$src$core$msg.UNNAMED_KEY||`unnamed`;!Ao(t,n.workspace,n);){let e=t.match(/^(.*?)(\d+)$/);t=e?e[1]+(parseInt(e[2])+1):t+`2`}return t},Ao=function(e,t,n){return!jo(e,t,n)},jo=function(t,n,r){for(let i of n.getAllBlocks(!1))if(i!==r&&bn(i)&&e.Names$$module$build$src$core$names.equals(i.getProcedureDef()[0],t))return!0;r=r&&Eo(r)?r?.getProcedureModel():void 0;for(let i of n.getProcedureMap().getProcedures())if(i!==r&&e.Names$$module$build$src$core$names.equals(i.getName(),t))return!0;return!1},e.rename$$module$build$src$core$procedures=function(t){var n=this.getSourceBlock();if(!n)throw new Sf;t=t.trim();let r=e.findLegalName$$module$build$src$core$procedures(t,n);Eo(n)&&!n.isInsertionMarker()&&n.getProcedureModel().setName(r);let i=this.getValue();if(i!==t&&i!==r)for(t=n.workspace.getAllBlocks(!1),n=0;n<t.length;n++){let e=t[n];e.renameProcedure&&e.renameProcedure(i,r)}return r},Mo=function(t){function n(t,n){for(let a=0;a<t.length;a++){var i=t[a][0];let o=t[a][1],s=e.createElement$$module$build$src$core$utils$xml(`block`);s.setAttribute(`type`,n),s.setAttribute(`gap`,`16`);let c=e.createElement$$module$build$src$core$utils$xml(`mutation`);for(c.setAttribute(`name`,i),s.appendChild(c),i=0;i<o.length;i++){let t=e.createElement$$module$build$src$core$utils$xml(`arg`);t.setAttribute(`name`,o[i]),c.appendChild(t)}r.push(s)}}let r=[];if(fc.procedures_defnoreturn){var i=e.createElement$$module$build$src$core$utils$xml(`block`);i.setAttribute(`type`,`procedures_defnoreturn`),i.setAttribute(`gap`,`16`);var a=e.createElement$$module$build$src$core$utils$xml(`field`);a.setAttribute(`name`,`NAME`),a.appendChild(e.createTextNode$$module$build$src$core$utils$xml(e.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_PROCEDURE)),i.appendChild(a),r.push(i)}return fc.procedures_defreturn&&(i=e.createElement$$module$build$src$core$utils$xml(`block`),i.setAttribute(`type`,`procedures_defreturn`),i.setAttribute(`gap`,`16`),a=e.createElement$$module$build$src$core$utils$xml(`field`),a.setAttribute(`name`,`NAME`),a.appendChild(e.createTextNode$$module$build$src$core$utils$xml(e.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_PROCEDURE)),i.appendChild(a),r.push(i)),fc.procedures_ifreturn&&(i=e.createElement$$module$build$src$core$utils$xml(`block`),i.setAttribute(`type`,`procedures_ifreturn`),i.setAttribute(`gap`,`16`),r.push(i)),r.length&&r[r.length-1].setAttribute(`gap`,`24`),t=Oo(t),n(t[0],`procedures_callnoreturn`),n(t[1],`procedures_callreturn`),r},No=function(e){return Po(e,!1)},Po=function(t,n=!0){function r(e,t){for(let[n,r]of e)i.push({kind:`block`,type:t,gap:16,extraState:{name:n,params:r}})}if(n)return Cn(`The XML return value of Blockly.Procedures.flyoutCategory()`,`v12`,`v13`,`the same method, but handle a return type of FlyoutItemInfo[] (JSON) instead.`),Mo(t);let i=[];return fc.procedures_defnoreturn&&i.push({kind:`block`,type:`procedures_defnoreturn`,gap:16,fields:{NAME:e.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_PROCEDURE}}),fc.procedures_defreturn&&i.push({kind:`block`,type:`procedures_defreturn`,gap:16,fields:{NAME:e.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_PROCEDURE}}),fc.procedures_ifreturn&&i.push({kind:`block`,type:`procedures_ifreturn`,gap:16}),i.length&&(i[i.length-1].gap=24),t=Oo(t),r(t[0],`procedures_callnoreturn`),r(t[1],`procedures_callreturn`),i},Fo=function(t){var n=[],r=t.getBlocksByType(`procedures_mutatorarg`,!1);for(let e=0,t;t=r[e];e++)n.push(t.getFieldValue(`NAME`));r=e.createElement$$module$build$src$core$utils$xml(`xml`);let i=e.createElement$$module$build$src$core$utils$xml(`block`);i.setAttribute(`type`,`procedures_mutatorarg`);let a=e.createElement$$module$build$src$core$utils$xml(`field`);a.setAttribute(`name`,`NAME`),n=Mn(e.DEFAULT_ARG$$module$build$src$core$procedures,n),n=e.createTextNode$$module$build$src$core$utils$xml(n),a.appendChild(n),i.appendChild(a),r.appendChild(i),t.updateToolbox(r)},Io=function(t){if(fe(t)&&t.bubbleType===`mutator`&&t.isOpen&&t.blockId){t=Je(t.workspaceId).getBlockById(t.blockId);var n=t.type;(n===`procedures_defnoreturn`||n===`procedures_defreturn`)&&(t=t.getIcon(e.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE).getWorkspace(),Fo(t),t.addChangeListener(Lo))}},Lo=function(e){(ie(e)||ae(e)||x(e)||oe(e))&&(e=Je(e.workspaceId),Fo(e))},Ro=function(t,n){return n.getAllBlocks(!1).filter(n=>zo(n,t)||xn(n)&&e.Names$$module$build$src$core$names.equals(n.getProcedureCall(),t))},zo=function(t,n){return Eo(t)&&!t.isProcedureDef()&&t.getProcedureModel()&&e.Names$$module$build$src$core$names.equals(t.getProcedureModel().getName(),n)},e.mutateCallers$$module$build$src$core$procedures=function(t){let n=Te();var r=t.getProcedureDef()[0];let i=t.mutationToDom(!0);t=Ro(r,t.workspace);for(let o=0,s;s=t[o];o++){r=(r=s.mutationToDom())&&At(r),s.domToMutation&&s.domToMutation(i);var a=s.mutationToDom();a=a&&At(a),r!==a&&(e.setRecordUndo$$module$build$src$core$events$utils(!1),w(new(E(F.BLOCK_CHANGE))(s,`mutation`,null,r,a)),e.setRecordUndo$$module$build$src$core$events$utils(n))}},e.getDefinition$$module$build$src$core$procedures=function(t,n){for(let r of n.getAllBlocks(!1))if(Eo(r)&&r.isProcedureDef()&&e.Names$$module$build$src$core$names.equals(r.getProcedureModel().getName(),t)||bn(r)&&e.Names$$module$build$src$core$names.equals(r.getProcedureDef()[0],t))return r;return null},Bo=function(e){return e.isDynamic},Vo=function(e){return e.pathDown!==void 0&&e.pathUp!==void 0},Ho=function(e){return e.pathLeft!==void 0&&e.pathRight!==void 0},Uo=function(e,n){t(P.RENDERER,e,n)},Wo=function(e){r(P.RENDERER,e)},Go=function(e,t,n){return e=new(o(P.RENDERER,e))(e),e.init(t,n),e},Ko=function(e){Nn(e.getTargetWorkspace(),void 0,`String`)},qo=function(e){Nn(e.getTargetWorkspace(),void 0,`Number`)},Jo=function(e){Nn(e.getTargetWorkspace(),void 0,`Colour`)},Yo=function(e){return Xo(e,!1)},Xo=function(t,n=!0){return fc.variables_set_dynamic||fc.variables_get_dynamic||console.warn(`There are no dynamic variable blocks, but there is a dynamic variable category.`),n?(Cn(`The XML return value of Blockly.VariablesDynamic.flyoutCategory()`,`v12`,`v13`,`the same method, but handle a return type of FlyoutItemInfo[] (JSON) instead.`),Zo(t)):(t.registerButtonCallback(`CREATE_VARIABLE_STRING`,Ko),t.registerButtonCallback(`CREATE_VARIABLE_NUMBER`,qo),t.registerButtonCallback(`CREATE_VARIABLE_COLOUR`,Jo),[{kind:`button`,text:e.Msg$$module$build$src$core$msg.NEW_STRING_VARIABLE,callbackkey:`CREATE_VARIABLE_STRING`},{kind:`button`,text:e.Msg$$module$build$src$core$msg.NEW_NUMBER_VARIABLE,callbackkey:`CREATE_VARIABLE_NUMBER`},{kind:`button`,text:e.Msg$$module$build$src$core$msg.NEW_COLOUR_VARIABLE,callbackkey:`CREATE_VARIABLE_COLOUR`},...Dn(t,t.getVariableMap().getAllVariables(),!1,`variables_get_dynamic`,`variables_set_dynamic`)])},Zo=function(t){let n=[],r=document.createElement(`button`);return r.setAttribute(`text`,e.Msg$$module$build$src$core$msg.NEW_STRING_VARIABLE),r.setAttribute(`callbackKey`,`CREATE_VARIABLE_STRING`),n.push(r),r=document.createElement(`button`),r.setAttribute(`text`,e.Msg$$module$build$src$core$msg.NEW_NUMBER_VARIABLE),r.setAttribute(`callbackKey`,`CREATE_VARIABLE_NUMBER`),n.push(r),r=document.createElement(`button`),r.setAttribute(`text`,e.Msg$$module$build$src$core$msg.NEW_COLOUR_VARIABLE),r.setAttribute(`callbackKey`,`CREATE_VARIABLE_COLOUR`),n.push(r),t.registerButtonCallback(`CREATE_VARIABLE_STRING`,Ko),t.registerButtonCallback(`CREATE_VARIABLE_NUMBER`,qo),t.registerButtonCallback(`CREATE_VARIABLE_COLOUR`,Jo),t=Qo(t),n=n.concat(t)},Qo=function(t){t=t.getVariableMap().getAllVariables();let n=[];if(t.length>0){if(fc.variables_set_dynamic){var r=t[t.length-1];let i=e.createElement$$module$build$src$core$utils$xml(`block`);i.setAttribute(`type`,`variables_set_dynamic`),i.setAttribute(`gap`,`24`),i.appendChild(Bn(r)),n.push(i)}if(fc.variables_get_dynamic){t.sort(Un);for(let i=0,a;a=t[i];i++)r=e.createElement$$module$build$src$core$utils$xml(`block`),r.setAttribute(`type`,`variables_get_dynamic`),r.setAttribute(`gap`,`8`),r.appendChild(Bn(a)),n.push(r)}}return n},$o=function(e){e.resizeContents()},es=function(e,t){let n=e.toCopyData();return lv=n,uv=Ke(e)&&e.workspace instanceof j_?e.workspace:null,dv=t,n},ts=function(){return lv},ns=function(e){lv=e},rs=function(){return uv},is=function(e){uv=e},as=function(){return dv},os=function(e){dv=e},ss=function(e,t,n){return e&&t?cs(e,t,n):lv&&uv?cs(lv,uv,dv):null},cs=function(e,t,n){return t=t.isMutator?t:t.options.parentWorkspace??t,s(P.PASTER,e.paster,!1)?.paste(e,t,n)??null},ls=function(e){return e&&typeof e.toCopyData==`function`},us=function(){_l.registry.register({name:hv.ESCAPE,preconditionFn(e){return!e.isReadOnly()},callback(e){return e.hideChaff(),!0},keyCodes:[Vp.ESC]})},ds=function(){_l.registry.register({name:hv.DELETE,preconditionFn(t,n){return n=n.focusedNode,!t.isReadOnly()&&n!=null&&_o(n)&&n.isDeletable()&&!t.isDragging()&&!e.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()},callback(t,n,r,i){return n.preventDefault(),t=i.focusedNode,t instanceof Bm?t.checkAndDelete():_o(t)&&t.isDeletable()&&(e.setGroup$$module$build$src$core$events$utils(!0),t.dispose(),e.setGroup$$module$build$src$core$events$utils(!1)),!0},keyCodes:[Vp.DELETE,Vp.BACKSPACE]})},fs=function(e){return ls(e)&&_o(e)&&wo(e)?e.isCopyable?e.isCopyable():e instanceof Bm||e instanceof sp?e.isOwnDeletable()&&e.isOwnMovable():e.isDeletable()&&e.isMovable():!1},ps=function(e){return fs(e)&&_o(e)&&e.isDeletable()},ms=function(){let t=_l.registry.createSerializedKey(Vp.C,[Vp.CTRL_CMD]);_l.registry.register({name:hv.COPY,preconditionFn(t,n){return n=n.focusedNode,t=t.isFlyout?t.targetWorkspace:t,!!n&&!!t&&!t.isDragging()&&!e.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()&&fs(n)},callback(e,t,n,r){return t.preventDefault(),t=r.focusedNode,!t||!ls(t)||!fs(t)||(e=e.isFlyout?e.targetWorkspace:e,!e)?!1:(t.workspace.isFlyout||e.hideChaff(),e=wo(t)&&t.workspace==e?t.getRelativeToSurfaceXY():void 0,!!es(t,e))},keyCodes:[t]})},hs=function(){let t=_l.registry.createSerializedKey(Vp.X,[Vp.CTRL_CMD]);_l.registry.register({name:hv.CUT,preconditionFn(t,n){return n=n.focusedNode,!!n&&!t.isReadOnly()&&!t.isDragging()&&!e.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()&&ps(n)},callback(e,t,n,r){return e=r.focusedNode,!e||!ps(e)||!ls(e)?!1:(t=wo(e)?e.getRelativeToSurfaceXY():void 0,t=es(e,t),e instanceof Bm?e.checkAndDelete():_o(e)&&e.dispose(),!!t)},keyCodes:[t]})},gs=function(){let t=_l.registry.createSerializedKey(Vp.V,[Vp.CTRL_CMD]);_l.registry.register({name:hv.PASTE,preconditionFn(){var t=rs();return!t||!t.rendered?!1:(t=t.isFlyout?t.targetWorkspace:t,!!ts()&&!!t&&!t.isReadOnly()&&!t.isDragging()&&!e.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken())},callback(e,t){if(e=ts(),!e)return!1;var n=rs();if(!n||(n=n.isFlyout?n.targetWorkspace:n,!n||n.isReadOnly()))return!1;if(t instanceof PointerEvent)return t=Dt(n,new I(t.clientX,t.clientY)),!!ss(e,n,t);if(t=as(),!t)return!!ss(e,n);let{left:r,top:i,width:a,height:o}=n.getMetricsManager().getViewMetrics(!0);return new R(i,i+o,r,r+a).contains(t.x,t.y)?!!ss(e,n):(t=new I(r+a/2,i+o/2),!!ss(e,n,t))},keyCodes:[t]})},_s=function(){let t=_l.registry.createSerializedKey(Vp.Z,[Vp.CTRL_CMD]);_l.registry.register({name:hv.UNDO,preconditionFn(t){return!t.isReadOnly()&&!t.isDragging()&&!e.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()},callback(e,t){return e.hideChaff(),e.undo(!1),t.preventDefault(),!0},keyCodes:[t]})},vs=function(){let t=_l.registry.createSerializedKey(Vp.Z,[Vp.CTRL_CMD,Vp.SHIFT]),n=_l.registry.createSerializedKey(Vp.Y,[Vp.CTRL]);_l.registry.register({name:hv.REDO,preconditionFn(t){return!t.isDragging()&&!t.isReadOnly()&&!e.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()},callback(e,t){return e.hideChaff(),e.undo(!0),t.preventDefault(),!0},keyCodes:[t,n]})},ys=function(){let t=_l.registry.createSerializedKey(Vp.ENTER,[Vp.CTRL_CMD]);_l.registry.register({name:hv.MENU,preconditionFn:e=>!e.isDragging(),callback:(t,n)=>{if(t=e.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode(),Co(t)){t.showContextMenu(n);let e;return(e=Zi())==null||e.highlightNext(),!0}return!1},keyCodes:[t]})},bs=function(){us(),ds(),ms(),hs(),gs(),_s(),vs(),ys()},xs=function(e){let t=e.saveState();return e.getParameters().length&&(t.parameters=e.getParameters().map(e=>e.saveState())),t},Ss=function(e,t,n,r){if(e=e.loadState(n,r),!n.parameters)return e;for(let[i,a]of n.parameters.entries())e.insertParameter(t.loadState(a,r),i);return e},Cs=function(e){let t=Object.create(null),n=c(P.SERIALIZER,!0);for(let r in n){let i=n[r]?.save(e);i&&(t[r]=i)}return t},ws=function(t,n,{recordUndo:r=!1}={}){var i=c(P.SERIALIZER,!0);if(i){i=Object.entries(i).sort((e,t)=>t[1].priority-e[1].priority);var a=Te();e.setRecordUndo$$module$build$src$core$events$utils(r),(r=e.getGroup$$module$build$src$core$events$utils())||e.setGroup$$module$build$src$core$events$utils(!0),ze(),n instanceof j_&&n.setResizesEnabled(!1);for(let[,e]of i.reverse()){let t;(t=e)==null||t.clear(n)}for(let[e,r]of i.reverse())if(t[e]){let i;(i=r)==null||i.load(t[e],n)}n instanceof j_&&n.setResizesEnabled(!0),Be(),w(new(E(F.FINISHED_LOADING))(n)),e.setGroup$$module$build$src$core$events$utils(r),e.setRecordUndo$$module$build$src$core$events$utils(a)}},Ts=function(e,t){let n=null;n=typeof e==`string`?document.getElementById(e)||document.querySelector(e):e;var r;if(!document.contains(n)&&document!==(r=n)?.ownerDocument)throw Error(`Error: container is not in current document`);e=new wp(t||{}),r=document.createElement(`div`),O(r,`injectionDiv`),t!=null&&t.rtl&&O(r,`blocklyRTL`),n.appendChild(r),t=Es(r,e);let i=Ds(r,t,e);return Os(i),$e(i),at(i),r.addEventListener(`focusin`,function(){$e(i)}),g(r,`keydown`,null,ut),i},Es=function(e,t){e.setAttribute(`dir`,`LTR`),pt(t.hasCss,t.pathToMedia);let n=D(L.SVG,{xmlns:tl,"xmlns:html":nl,"xmlns:xlink":rl,version:`1.1`,class:`blocklySvg`},e),r=D(L.DEFS,{},n),i=String(Math.random()).substring(2);return t.gridPattern=tg.createDom(i,t.gridOptions,r,e),n},Ds=function(e,t,n){n.parentWorkspace=null,n=new j_(n);let r=n.options;n.scale=r.zoomOptions.startScale,t.appendChild(n.createDom(`blocklyMainBackground`,e));var i=n.getRenderer().getClassName();return i&&O(e,i),(i=n.getTheme().getClassName())&&O(e,i),!r.hasCategories&&r.languageTree&&(e=n.addFlyout(L.SVG),Le(e,t)),r.hasTrashcan&&n.addTrashcan(),r.zoomOptions&&r.zoomOptions.controls&&n.addZoomControls(),n.getThemeManager().subscribe(t,`workspaceBackgroundColour`,`background-color`),n.translate(0,0),n.addChangeListener(mo(n)),at(n),Ai(),vr(),$r(),n},Os=function(e){let t=e.options;var n=e.getParentSvg();if(g(n.parentNode,`contextmenu`,null,function(e){y(e)||e.preventDefault()}),n=g(window,`resize`,null,function(){oi(),e.hideComponents(!0),zr(),Vi(),at(e),go(e)}),e.setResizeHandlerWrapper(n),ks(),t.languageTree){n=e.getToolbox();let r=e.getFlyout(!0);n?n.init():r&&(r.init(e),r.show(t.languageTree),typeof r.scrollToStart==`function`&&r.scrollToStart())}t.hasTrashcan&&e.trashcan.init(),t.zoomOptions&&t.zoomOptions.controls&&e.zoomControls_.init(),t.moveOptions&&t.moveOptions.scrollbars?(e.scrollbar=new Lh(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&&As(t.pathToMedia,e)},ks=function(){$v||(g(document,`scroll`,null,function(){let e=Ye();for(let t=0,n;n=e[t];t++)n instanceof j_&&n.updateInverseScreenCTM()}),_(document,`touchend`,null,d),_(document,`touchcancel`,null,d)),$v=!0},As=function(e,t){t=t.getAudioManager(),t.load([`${e}click.mp3`],`click`),t.load([`${e}disconnect.mp3`],`disconnect`),t.load([`${e}delete.mp3`],`delete`)},js=function(e){return!e||!e.isSimpleReporter()?!1:e.getFields().next().value?.isFullBlockField()},Ms=function(){J.registry.register({displayText(){return e.Msg$$module$build$src$core$msg.UNDO},preconditionFn(e){return e.workspace.getUndoStack().length>0?`enabled`:`disabled`},callback(e){e.workspace.undo(!1)},scopeType:J.ScopeType.WORKSPACE,id:`undoWorkspace`,weight:1})},Ns=function(){J.registry.register({displayText(){return e.Msg$$module$build$src$core$msg.REDO},preconditionFn(e){return e.workspace.getRedoStack().length>0?`enabled`:`disabled`},callback(e){e.workspace.undo(!0)},scopeType:J.ScopeType.WORKSPACE,id:`redoWorkspace`,weight:2})},Ps=function(){J.registry.register({displayText(){return e.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:J.ScopeType.WORKSPACE,id:`cleanWorkspace`,weight:3})},Fs=function(t,n){function r(n){a--,n.setCollapsed(t),a===0&&e.setGroup$$module$build$src$core$events$utils(!1)}let i=0,a=0;e.setGroup$$module$build$src$core$events$utils(!0);for(let e=0;e<n.length;e++){let t=n[e];for(;t;)a++,setTimeout(r.bind(null,t),i),t=t.getNextBlock(),i+=10}},Is=function(){J.registry.register({displayText(){return e.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 n=e[t];for(;n;){if(!n.isCollapsed())return`enabled`;n=n.getNextBlock()}}return`disabled`}return`hidden`},callback(e){Fs(!0,e.workspace.getTopBlocks(!0))},scopeType:J.ScopeType.WORKSPACE,id:`collapseWorkspace`,weight:4})},Ls=function(){J.registry.register({displayText(){return e.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 n=e[t];for(;n;){if(n.isCollapsed())return`enabled`;n=n.getNextBlock()}}return`disabled`}return`hidden`},callback(e){Fs(!1,e.workspace.getTopBlocks(!0))},scopeType:J.ScopeType.WORKSPACE,id:`expandWorkspace`,weight:5})},Rs=function(e,t){if(e.isDeletable())Array.prototype.push.apply(t,e.getDescendants(!1));else{e=e.getChildren(!1);for(let n=0;n<e.length;n++)Rs(e[n],t)}},zs=function(e){let t=[];e=e.getTopBlocks(!0);for(let n=0;n<e.length;n++)Rs(e[n],t);return t},Bs=function(t,n){n?e.setGroup$$module$build$src$core$events$utils(n):(e.setGroup$$module$build$src$core$events$utils(!0),n=e.getGroup$$module$build$src$core$events$utils());let r=t.shift();r&&(r.isDeadOrDying()?Bs(t,n):(r.dispose(!1,!0),setTimeout(Bs,10,t,n))),e.setGroup$$module$build$src$core$events$utils(!1)},Vs=function(){J.registry.register({displayText(t){return t.workspace?(t=zs(t.workspace).length,t===1?e.Msg$$module$build$src$core$msg.DELETE_BLOCK:e.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace(`%1`,`${t}`)):``},preconditionFn(e){return e.workspace&&zs(e.workspace).length>0?`enabled`:`disabled`},callback(t){if(t.workspace){t.workspace.cancelCurrentGesture();var n=zs(t.workspace);n.length<2?Bs(n):mn(e.Msg$$module$build$src$core$msg.DELETE_ALL_BLOCKS.replace(`%1`,String(n.length)),function(e){e&&Bs(n)})}},scopeType:J.ScopeType.WORKSPACE,id:`workspaceDelete`,weight:6})},Hs=function(){Ms(),Ns(),Ps(),Is(),Ls(),Vs()},Us=function(){J.registry.register({displayText(){return e.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:J.ScopeType.BLOCK,id:`blockDuplicate`,weight:1})},Ws=function(){J.registry.register({displayText(t){return t.block.hasIcon(Th.TYPE)?e.Msg$$module$build$src$core$msg.REMOVE_COMMENT:e.Msg$$module$build$src$core$msg.ADD_COMMENT},preconditionFn(e){return e=e.block,!e||e.isInFlyout||!e.workspace.options.comments||e.isCollapsed()||!e.isEditable()||!e.hasIcon(Th.TYPE)&&js(e)?`hidden`:`enabled`},callback(e){(e=e.block)&&e.hasIcon(Th.TYPE)?e.setCommentText(null):e.setCommentText(``)},scopeType:J.ScopeType.BLOCK,id:`blockComment`,weight:2})},Gs=function(){J.registry.register({displayText(t){return t.block.getInputsInline()?e.Msg$$module$build$src$core$msg.EXTERNAL_INPUTS:e.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 Rv||e.inputList[t]instanceof Rv))return`enabled`}return`hidden`},callback(e){e.block.setInputsInline(!e.block.getInputsInline())},scopeType:J.ScopeType.BLOCK,id:`blockInline`,weight:3})},Ks=function(){J.registry.register({displayText(t){return t.block.isCollapsed()?e.Msg$$module$build$src$core$msg.EXPAND_BLOCK:e.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:J.ScopeType.BLOCK,id:`blockCollapseExpand`,weight:4})},qs=function(){J.registry.register({displayText(t){return t.block.hasDisabledReason(Vu)?e.Msg$$module$build$src$core$msg.ENABLE_BLOCK:e.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(Vu),e.getInheritedDisabled()||t?`disabled`:`enabled`}return`hidden`},callback(t){t=t.block;let n=e.getGroup$$module$build$src$core$events$utils();n||e.setGroup$$module$build$src$core$events$utils(!0),t.setDisabledReason(!t.hasDisabledReason(Vu),Vu),e.setGroup$$module$build$src$core$events$utils(n)},scopeType:J.ScopeType.BLOCK,id:`blockDisable`,weight:5})},Js=function(){J.registry.register({displayText(t){var n=t.block;return t=n.getDescendants(!1).length,(n=n.getNextBlock())&&(t-=n.getDescendants(!1).length),t===1?e.Msg$$module$build$src$core$msg.DELETE_BLOCK:e.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace(`%1`,`${t}`)},preconditionFn(e){return!e.block.isInFlyout&&e.block.isDeletable()?`enabled`:`hidden`},callback(e){e.block&&e.block.checkAndDelete()},scopeType:J.ScopeType.BLOCK,id:`blockDelete`,weight:6})},Ys=function(){J.registry.register({displayText(){return e.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:J.ScopeType.BLOCK,id:`blockHelp`,weight:7})},Xs=function(){J.registry.register({displayText:()=>e.Msg$$module$build$src$core$msg.REMOVE_COMMENT,preconditionFn(e){let t;return(t=e.comment)!=null&&t.isDeletable()?`enabled`:`hidden`},callback(t){e.setGroup$$module$build$src$core$events$utils(!0);let n;(n=t.comment)==null||n.dispose(),e.setGroup$$module$build$src$core$events$utils(!1)},scopeType:J.ScopeType.COMMENT,id:`commentDelete`,weight:6})},Zs=function(){J.registry.register({displayText:()=>e.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:J.ScopeType.COMMENT,id:`commentDuplicate`,weight:1})},Qs=function(){J.registry.register({displayText:()=>e.Msg$$module$build$src$core$msg.ADD_COMMENT,preconditionFn:e=>{let t;return(t=e.workspace)!=null&&t.isMutator?`hidden`:`enabled`},callback:(t,n,r,i)=>{(t=t.workspace)&&(e.setGroup$$module$build$src$core$events$utils(!0),n=new sp(t),n.moveTo(Dt(t,new I(i.x,i.y))),e.getFocusManager$$module$build$src$core$focus_manager().focusNode(n),e.setGroup$$module$build$src$core$events$utils(!1))},scopeType:J.ScopeType.WORKSPACE,id:`commentCreate`,weight:8})},$s=function(){Us(),Ws(),Gs(),Ks(),qs(),Js(),Ys()},ec=function(){Zs(),Xs(),Qs()},tc=function(){Hs(),$s()},nc=function(e){return e&&typeof e.paste==`function`},rc=function(e){return e&&typeof e.getSvgRoot==`function`},ic=function(e){return e.isSelectable()},ac=function(e){Qe().hideChaff(e)},oc=function(e){return e&&typeof e.getRootFocusableNode==`function`&&typeof e.getRestoredFocusableNode==`function`&&typeof e.getNestedTrees==`function`&&typeof e.lookUpFocusableNode==`function`&&typeof e.onTreeFocus==`function`&&typeof e.onTreeBlur==`function`},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,n){return e==Array.prototype||e==Object.prototype||(e[t]=n.value),e},N.getGlobal=function(e){e=[typeof globalThis==`object`&&globalThis,e,typeof window==`object`&&window,typeof self==`object`&&self,typeof global==`object`&&global];for(var t=0;t<e.length;++t){var n=e[t];if(n&&n.Math==Math)return n}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.TYPED_ARRAY_CLASSES=function(){var e=`Int8 Uint8 Uint8Clamped Int16 Uint16 Int32 Uint32 Float32 Float64`.split(` `);return N.global.BigInt64Array&&(e.push(`BigInt64`),e.push(`BigUint64`)),e}(),N.polyfillTypedArrayMethod=function(e,t,n,r){if(t)for(var i=0;i<N.TYPED_ARRAY_CLASSES.length;i++){var a=N.TYPED_ARRAY_CLASSES[i]+`Array.prototype.`+e;N.ISOLATE_POLYFILLS?N.polyfillIsolated(a,t,n,r):N.polyfillUnisolated(a,t,n,r)}},N.polyfill=function(e,t,n,r){t&&(N.ISOLATE_POLYFILLS?N.polyfillIsolated(e,t,n,r):N.polyfillUnisolated(e,t,n,r))},N.polyfillUnisolated=function(e,t,n,r){for(n=N.global,e=e.split(`.`),r=0;r<e.length-1;r++){var i=e[r];if(!(i in n))return;n=n[i]}e=e[e.length-1],r=n[e],t=t(r),t!=r&&t!=null&&N.defineProperty(n,e,{configurable:!0,writable:!0,value:t})},N.polyfillIsolated=function(e,t,n,r){var i=e.split(`.`);e=i.length===1,r=i[0],r=!e&&r in N.polyfills?N.polyfills:N.global;for(var a=0;a<i.length-1;a++){var o=i[a];if(!(o in r))return;r=r[o]}i=i[i.length-1],n=N.IS_SYMBOL_NATIVE&&n===`es6`?r[i]:null,t=t(n),t!=null&&(e?N.defineProperty(N.polyfills,i,{configurable:!0,writable:!0,value:t}):t!==n&&(N.propertyToPolyfillSymbol[i]===void 0&&(n=Math.random()*1e9>>>0,N.propertyToPolyfillSymbol[i]=N.IS_SYMBOL_NATIVE?N.global.Symbol(i):N.POLYFILL_PREFIX+n+`$`+i),N.defineProperty(r,N.propertyToPolyfillSymbol[i],{configurable:!0,writable:!0,value:t})))},N.getConstructImplementation=function(){function e(){function e(){}return new e,Reflect.construct(e,[],function(){}),new e instanceof e}if(N.TRUST_ES6_POLYFILLS&&typeof Reflect<`u`&&Reflect.construct){if(e())return Reflect.construct;var t=Reflect.construct;return function(e,n,r){return e=t(e,n),r&&Reflect.setPrototypeOf(e,r.prototype),e}}return function(e,t,n){return n===void 0&&(n=e),n=N.objectCreate(n.prototype||Object.prototype),Function.prototype.apply.call(e,n,t)||n}},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 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 n=N.setPrototypeOf;n(e,t)}else for(n in t)if(n!=`prototype`)if(Object.defineProperties){var r=Object.getOwnPropertyDescriptor(t,n);r&&Object.defineProperty(e,n,r)}else e[n]=t[n];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,n=[];!(t=e.next()).done;)n.push(t.value);return n},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 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 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.getNextAddress=function(){return this.nextAddress},N.generator.Context.prototype.getNextAddress=N.generator.Context.prototype.getNextAddress,N.generator.Context.prototype.getYieldResult=function(){return this.yieldResult},N.generator.Context.prototype.getYieldResult=N.generator.Context.prototype.getYieldResult,N.generator.Context.prototype.return=function(e){this.abruptCompletion_={return:e},this.nextAddress=this.finallyAddress_},N.generator.Context.prototype.return=N.generator.Context.prototype.return,N.generator.Context.prototype.jumpThroughFinallyBlocks=function(e){this.abruptCompletion_={jumpTo:e},this.nextAddress=this.finallyAddress_},N.generator.Context.prototype.jumpThroughFinallyBlocks=N.generator.Context.prototype.jumpThroughFinallyBlocks,N.generator.Context.prototype.yield=function(e,t){return this.nextAddress=t,{value:e}},N.generator.Context.prototype.yield=N.generator.Context.prototype.yield,N.generator.Context.prototype.yieldAll=function(e,t){e=N.makeIterator(e);var n=e.next();if(N.generator.ensureIteratorResultIsObject_(n),n.done)this.yieldResult=n.value,this.nextAddress=t;else return this.yieldAllIterator_=e,this.yield(n.value,t)},N.generator.Context.prototype.yieldAll=N.generator.Context.prototype.yieldAll,N.generator.Context.prototype.jumpTo=function(e){this.nextAddress=e},N.generator.Context.prototype.jumpTo=N.generator.Context.prototype.jumpTo,N.generator.Context.prototype.jumpToEnd=function(){this.nextAddress=0},N.generator.Context.prototype.jumpToEnd=N.generator.Context.prototype.jumpToEnd,N.generator.Context.prototype.setCatchFinallyBlocks=function(e,t){this.catchAddress_=e,t!=null&&(this.finallyAddress_=t)},N.generator.Context.prototype.setCatchFinallyBlocks=N.generator.Context.prototype.setCatchFinallyBlocks,N.generator.Context.prototype.setFinallyBlock=function(e){this.catchAddress_=0,this.finallyAddress_=e||0},N.generator.Context.prototype.setFinallyBlock=N.generator.Context.prototype.setFinallyBlock,N.generator.Context.prototype.leaveTryBlock=function(e,t){this.nextAddress=e,this.catchAddress_=t||0},N.generator.Context.prototype.leaveTryBlock=N.generator.Context.prototype.leaveTryBlock,N.generator.Context.prototype.enterCatchBlock=function(e){return this.catchAddress_=e||0,e=this.abruptCompletion_.exception,this.abruptCompletion_=null,e},N.generator.Context.prototype.enterCatchBlock=N.generator.Context.prototype.enterCatchBlock,N.generator.Context.prototype.enterFinallyBlock=function(e,t,n){n?this.finallyContexts_[n]=this.abruptCompletion_:this.finallyContexts_=[this.abruptCompletion_],this.catchAddress_=e||0,this.finallyAddress_=t||0},N.generator.Context.prototype.enterFinallyBlock=N.generator.Context.prototype.enterFinallyBlock,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.leaveFinallyBlock=N.generator.Context.prototype.leaveFinallyBlock,N.generator.Context.prototype.forIn=function(e){return new N.generator.Context.PropertyIterator(e)},N.generator.Context.prototype.forIn=N.generator.Context.prototype.forIn,N.generator.Context.PropertyIterator=function(e){for(var t in this.object_=e,this.properties_=[],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.Context.PropertyIterator.prototype.getNext=N.generator.Context.PropertyIterator.prototype.getNext,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(e){return{value:e,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,n){try{var r=e.call(this.context_.yieldAllIterator_,t);if(N.generator.ensureIteratorResultIsObject_(r),!r.done)return this.context_.stop_(),r;var i=r.value}catch(e){return this.context_.yieldAllIterator_=null,this.context_.throw_(e),this.nextStep_()}return this.context_.yieldAllIterator_=null,n.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(e){this.context_.yieldResult=void 0,this.context_.throw_(e)}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(t){return e.next(t)}function n(t){return e.throw(t)}return new Promise(function(r,i){function a(e){e.done?r(e.value):Promise.resolve(e.value).then(t,n).then(a,i)}a(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(e,t){var n=this;n instanceof String&&(n=String(n));var r=n.length;for(t=t||0,t<0&&(t=Math.max(t+r,0));t<r;t++){var i=n[t];if(i===e||Object.is(i,e))return!0}return!1}},`es7`,`es3`),N.checkEs6ConformanceViaProxy=function(){try{var e={},t=Object.create(new N.global.Proxy(e,{get:function(n,r,i){return n==e&&r==`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(e){N.checkIsSetInstance(this),N.checkIsSetLike(e);var t=N.getSmallerAndLargerSets(this,e);e=new Set(this);var n=t.smallerSetIterator;t=t.largerSet;for(var r=n.next();!r.done;)t.has(r.value)&&e.delete(r.value),r=n.next();return e}},`es_next`,`es6`),N.checkIsSetLike=function(e){if(typeof e!=`object`||!e||typeof e.size!=`number`||e.size<0||typeof e.keys!=`function`||typeof e.has!=`function`)throw TypeError(`Argument must be set-like`)},N.checkIsValidIterator=function(e){if(typeof e!=`object`||!e||typeof e.next!=`function`)throw 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 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 n=0,r=!1,i={next:function(){if(!r&&n<e.length){var i=n++;return{value:t(i,e[i]),done:!1}}return r=!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(e,t){return t})}},`es8`,`es3`),N.polyfill(`Array.prototype.flatMap`,function(e){return e||function(e,t){var n=[];return Array.prototype.forEach.call(this,function(r,i){r=e.call(t,r,i,this),Array.isArray(r)?n.push.apply(n,r):n.push(r)}),n}},`es9`,`es5`),N.polyfill(`Array.prototype.flat`,function(e){return e||function(e){e=e===void 0?1:e;var t=[];return Array.prototype.forEach.call(this,function(n){Array.isArray(n)&&e>0?(n=Array.prototype.flat.call(n,e-1),t.push.apply(t,n)):t.push(n)}),t}},`es9`,`es5`),N.polyfill(`Object.entries`,function(e){return e||function(e){var t=[],n;for(n in e)N.owns(e,n)&&t.push([n,e[n]]);return t}},`es8`,`es3`),N.polyfill(`Object.values`,function(e){return e||function(e){var t=[],n;for(n in e)N.owns(e,n)&&t.push(e[n]);return t}},`es8`,`es3`);var sc=Object.create(null),cc={typeMap:sc},lc=Object.create(null),uc=`default`,P=class{constructor(e){this.name=e}toString(){return this.name}};P.CONNECTION_CHECKER=new P(`connectionChecker`),P.CONNECTION_PREVIEWER=new P(`connectionPreviewer`),P.CURSOR=new P(`cursor`),P.EVENT=new P(`event`),P.FIELD=new P(`field`),P.INPUT=new P(`input`),P.RENDERER=new P(`renderer`),P.TOOLBOX=new P(`toolbox`),P.THEME=new P(`theme`),P.TOOLBOX_ITEM=new P(`toolboxItem`),P.FLYOUTS_VERTICAL_TOOLBOX=new P(`flyoutsVerticalToolbox`),P.FLYOUTS_HORIZONTAL_TOOLBOX=new P(`flyoutsHorizontalToolbox`),P.FLYOUT_INFLATER=new P(`flyoutInflater`),P.METRICS_MANAGER=new P(`metricsManager`),P.BLOCK_DRAGGER=new P(`blockDragger`),P.SERIALIZER=new P(`serializer`),P.ICON=new P(`icon`),P.PASTER=new P(`paster`),P.VARIABLE_MODEL=new P(`variableModel`),P.VARIABLE_MAP=new P(`variableMap`);var dc={DEFAULT:uc,TEST_ONLY:cc};dc.Type=P,dc.getAllItems=c,dc.getClass=o,dc.getClassFromOptions=l,dc.getObject=s,dc.hasItem=a,dc.register=t,dc.unregister=r;var fc=Object.create(null),pc=750,mc=`ontouchstart`in globalThis||!!(globalThis.document&&document.documentElement&&`ontouchstart`in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),hc=null,gc={mousedown:[`pointerdown`],mouseenter:[`pointerenter`],mouseleave:[`pointerleave`],mousemove:[`pointermove`],mouseout:[`pointerout`],mouseover:[`pointerover`],mouseup:[`pointerup`,`pointercancel`],touchend:[`pointerup`],touchcancel:[`pointercancel`]},_c=0,vc={TOUCH_ENABLED:mc,TOUCH_MAP:gc};vc.checkTouchIdentifier=h,vc.clearTouchIdentifier=f,vc.getTouchIdentifierFromEvent=m,vc.longStart=u,vc.longStop=d,vc.shouldHandleEvent=p;var yc,bc,xc,Sc,Cc,wc,Tc,Ec,Dc,Oc;(function(e){function t(e){return n.includes(e.toUpperCase())}yc=e;let n=yc.toUpperCase();bc=t(`JavaFX`),xc=t(`WebKit`),Sc=t(`Gecko`)&&!xc,Cc=t(`Android`),e=globalThis.navigator&&globalThis.navigator.maxTouchPoints,wc=t(`iPad`)||t(`Macintosh`)&&e>0,Tc=t(`iPhone`)&&!wc,Ec=t(`Macintosh`),Dc=wc||Cc&&!t(`Mobile`)||t(`Silk`),Oc=!Dc&&(Tc||Cc)})(globalThis.navigator&&globalThis.navigator.userAgent||``);var kc=yc,Ac=bc,jc=Sc,Mc=Cc,Nc=wc,Pc=Tc,Fc=Ec,Ic=Oc,Lc={ANDROID:Mc,GECKO:jc,IPAD:Nc,IPHONE:Pc,JavaFx:Ac,MAC:Fc,MOBILE:Ic,raw:kc},Rc=40,zc=125,Bc={};Bc.bind=_,Bc.conditionalBind=g,Bc.getScrollDeltaPixels=te,Bc.isRightButton=b,Bc.isTargetInput=y,Bc.mouseToSvg=ee,Bc.unbind=v;var F;(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`})(F||(F={}));var Vc=[F.BLOCK_CREATE,F.BLOCK_MOVE,F.COMMENT_CREATE,F.COMMENT_MOVE],Hc={BUMP_EVENTS:Vc};Hc.EventType=F;var Uc="!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Wc={genUid:()=>{let e=Uc.length,t=[];for(let n=0;n<20;n++)t[n]=Uc.charAt(Math.random()*e);return t.join(``)}},Gc=0,Kc={TEST_ONLY:Wc};Kc.genUid=re,Kc.getNextUniqueId=ne;var qc={};qc.isBlockChange=x,qc.isBlockCreate=ie,qc.isBlockDelete=ae,qc.isBlockDrag=ue,qc.isBlockFieldIntermediateChange=oe,qc.isBlockMove=se,qc.isBubbleOpen=fe,qc.isClick=de,qc.isCommentChange=ye,qc.isCommentCollapse=Ce,qc.isCommentCreate=_e,qc.isCommentDelete=ve,qc.isCommentDrag=Se,qc.isCommentMove=be,qc.isCommentResize=xe,qc.isFinishedLoading=we,qc.isSelected=C,qc.isThemeChange=he,qc.isToolboxItemSelect=me,qc.isTrashcanOpen=pe,qc.isVarCreate=S,qc.isVarDelete=ce,qc.isVarRename=le,qc.isViewportChange=ge;var Jc=``,Yc=!0,Xc=0,Zc=`ORPHANED_BLOCK`,Qc=[],$c={FIRE_QUEUE:Qc,enqueueEvent:Oe,fireNow:De,fireInternal:Ee,setGroupInternal:Me},el={TEST_ONLY:$c};el.clearPendingUndo=Ae,el.disable=e.disable$$module$build$src$core$events$utils,el.disableOrphans=Pe,el.enable=e.enable$$module$build$src$core$events$utils,el.filter=ke,el.fire=w,el.fromJson=T,el.get=E,el.getDescendantIds=Ne,el.getGroup=e.getGroup$$module$build$src$core$events$utils,el.getRecordUndo=Te,el.isEnabled=je,el.setGroup=e.setGroup$$module$build$src$core$events$utils,el.setRecordUndo=e.setRecordUndo$$module$build$src$core$events$utils;var tl=`http://www.w3.org/2000/svg`,nl=`http://www.w3.org/1999/xhtml`,rl=`http://www.w3.org/1999/xlink`,il;(function(e){e[e.ELEMENT_NODE=1]=`ELEMENT_NODE`,e[e.TEXT_NODE=3]=`TEXT_NODE`,e[e.COMMENT_NODE=8]=`COMMENT_NODE`})(il||(il={}));var al=null,ol=0,sl=null,cl={HTML_NS:nl};cl.NodeType=il,cl.SVG_NS=tl,cl.XLINK_NS=rl,cl.addClass=O,cl.createSvgElement=D,cl.getFastTextWidth=He,cl.getFastTextWidthWithSizeString=Ue,cl.getTextWidth=Ve,cl.hasClass=Ie,cl.insertAfter=Le,cl.measureFontMetrics=We,cl.removeClass=k,cl.removeClasses=Fe,cl.removeNode=A,cl.setCssTransform=Re,cl.startTextWidthCache=ze,cl.stopTextWidthCache=Be;var ll=class{static findFocusedNode(e){var t=e.getRootFocusableNode();if(!t.canBeFocused())return null;var n=t.getFocusableElement();return Ie(n,ll.ACTIVE_CLASS_NAME)||Ie(n,ll.PASSIVE_CSS_CLASS_NAME)||(t=n.querySelector(this.ACTIVE_FOCUS_NODE_CSS_SELECTOR),(t instanceof HTMLElement||t instanceof SVGElement)&&(t=ll.findFocusableNodeFor(t,e)))?t:(n=n.querySelector(this.PASSIVE_FOCUS_NODE_CSS_SELECTOR),(n instanceof HTMLElement||n instanceof SVGElement)&&(e=ll.findFocusableNodeFor(n,e))?e:null)}static findFocusableNodeFor(e,t){if(!e.id||e.id===`null`||t.getNestedTrees().map(t=>ll.findFocusableNodeFor(e,t)).findIndex(e=>!!e)!==-1)return null;var n=t.getRootFocusableNode();if(n.canBeFocused()&&e===n.getFocusableElement())return n;var r;return(n=(r=t.lookUpFocusableNode(e.id))??null)?n:(r=e.parentElement,!n&&r?ll.findFocusableNodeFor(r,t):null)}};ll.ACTIVE_CLASS_NAME=`blocklyActiveFocus`,ll.PASSIVE_CSS_CLASS_NAME=`blocklyPassiveFocus`,ll.ACTIVE_FOCUS_NODE_CSS_SELECTOR=`.${ll.ACTIVE_CLASS_NAME}`,ll.PASSIVE_FOCUS_NODE_CSS_SELECTOR=`.${ll.PASSIVE_CSS_CLASS_NAME}`;var ul={};ul.FocusableTreeTraverser=ll;var dl=class{constructor(e,t){this.tree=e,this.rootShouldBeAutoTabbable=t}},fl=class{constructor(e){this.previouslyFocusedNode=this.focusedNode=null,this.registeredTrees=[],this.isUpdatingFocusedNode=this.recentlyLostAllFocus=this.lockFocusStateChanges=this.currentlyHoldsEphemeralFocus=!1;let t=e=>{if(!this.isUpdatingFocusedNode){this.recentlyLostAllFocus=!e;var t=null;if(e instanceof HTMLElement||e instanceof SVGElement){for(var n of this.registeredTrees)if(t=ll.findFocusableNodeFor(e,n.tree))break}t&&t.canBeFocused()?(e=t.getFocusableTree(),n=this.focusedNode?.getFocusableTree(),t===e.getRootFocusableNode()&&e!==n?this.focusTree(e):this.focusNode(t)):this.defocusCurrentFocusedNode()}};e(`focusin`,e=>{e instanceof FocusEvent&&t(document.activeElement)}),e(`focusout`,e=>{e instanceof FocusEvent&&t(e.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 dl(e,t));let n=e.getRootFocusableNode().getFocusableElement();if(!n.id||n.id===`null`)throw Error(`Attempting to register a tree with a root element that has an invalid ID: ${e}.`);t&&(n.tabIndex=0)}isRegistered(e){return!!this.lookUpRegistration(e)}lookUpRegistration(e){return this.registeredTrees.find(t=>t.tree===e)??null}unregisterTree(e){if(this.ensureManagerIsUnlocked(),!this.isRegistered(e))throw Error(`Attempted to unregister not registered tree: ${e}.`);var t=this.registeredTrees.findIndex(t=>t.tree===e);let n=this.registeredTrees[t];this.registeredTrees.splice(t,1),t=ll.findFocusedNode(e);let r=e.getRootFocusableNode();t&&this.removeHighlight(t),this.focusedNode!==t&&this.focusedNode!==r||this.updateFocusedNode(null),this.removeHighlight(r),n.rootShouldBeAutoTabbable&&e.getRootFocusableNode().getFocusableElement().removeAttribute(`tabindex`)}getFocusedTree(){return this.focusedNode?.getFocusableTree()??null}getFocusedNode(){return this.focusedNode}focusTree(e){if(this.ensureManagerIsUnlocked(),!this.isRegistered(e))throw Error(`Attempted to focus unregistered tree: ${e}.`);let t=ll.findFocusedNode(e),n=e.getRestoredFocusableNode(t);e=e.getRootFocusableNode(),this.focusNode(n??t??e)}focusNode(e){this.ensureManagerIsUnlocked();let t=!this.currentlyHoldsEphemeralFocus;t&&(this.isUpdatingFocusedNode=!0);var n,r=(n=this.focusedNode)?.getFocusableElement()!==document.activeElement;if(this.focusedNode!==e||r)if(e.canBeFocused()){if(n=e.getFocusableTree(),!this.isRegistered(n))throw Error(`Attempted to focus unregistered node: ${e}.`);r=e.getFocusableElement(),r.id&&r.id!==`null`||console.warn(`Trying to focus a node that has an invalid ID.`);var i=ll.findFocusableNodeFor(r,n);r=ll.findFocusedNode(n);var a=e;if(i!==e){a=n.getRestoredFocusableNode(r),e=n.getRootFocusableNode();var o;a=(o=a??r)??e}e=this.focusedNode,o=e?.getFocusableTree(),e&&this.passivelyFocusNode(e,n),n=n.getRootFocusableNode(),r&&this.removeHighlight(r),n!==a&&this.removeHighlight(n),this.currentlyHoldsEphemeralFocus||this.activelyFocusNode(a,o??null),this.updateFocusedNode(a)}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({preventScroll:!0});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);let e=this.focusedNode;setTimeout(()=>{!this.focusedNode&&this.previouslyFocusedNode===e&&this.recentlyLostAllFocus&&this.focusNode(e)},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;let n=e.getFocusableTree(),r=e.getFocusableElement(),i=this.lookUpRegistration(n)?.rootShouldBeAutoTabbable;n!==t&&(n.onTreeFocus(e,t),i&&(n.getRootFocusableNode().getFocusableElement().tabIndex=-1)),e.onNodeFocus(),this.lockFocusStateChanges=!1,i&&e===n.getRootFocusableNode()||r.hasAttribute(`tabindex`)||(r.tabIndex=-1),this.setNodeToVisualActiveFocus(e),r.focus({preventScroll:!0})}passivelyFocusNode(e,t){this.lockFocusStateChanges=!0;let n=e.getFocusableTree();if(n!==t){n.onTreeBlur(t);let e;(e=this.lookUpRegistration(n))!=null&&e.rootShouldBeAutoTabbable&&(n.getRootFocusableNode().getFocusableElement().tabIndex=0)}e.onNodeBlur(),this.lockFocusStateChanges=!1,n!==t&&this.setNodeToVisualPassiveFocus(e)}setNodeToVisualActiveFocus(e){e=e.getFocusableElement(),O(e,fl.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),k(e,fl.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}setNodeToVisualPassiveFocus(e){e=e.getFocusableElement(),k(e,fl.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),O(e,fl.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}removeHighlight(e){e=e.getFocusableElement(),k(e,fl.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),k(e,fl.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}static getFocusManager(){return fl.focusManager||(fl.focusManager=new fl(document.addEventListener)),fl.focusManager}};fl.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME=`blocklyActiveFocus`,fl.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME=`blocklyPassiveFocus`,fl.focusManager=null;var pl={};pl.FocusManager=fl,pl.getFocusManager=e.getFocusManager$$module$build$src$core$focus_manager;var ml={};ml.isFocusableNode=Ge;var hl={};hl.isSelectable=Ke;var gl={};gl.deepMerge=qe;var _l=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(let n of t)this.addKeyMapping(n,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,n){e=`${e}`;let r=this.keyMap.get(e);if(r&&!n)throw Error(`Shortcut named "${t}" collides with shortcuts "${r}"`);r&&n?r.unshift(t):this.keyMap.set(e,[t])}removeKeyMapping(e,t,n){let r=this.keyMap.get(e);if(!r)return n||console.warn(`No keyboard shortcut named "${t}" registered with key code "${e}"`),!1;let i=r.indexOf(t);return i>-1?(r.splice(i,1),r.length===0&&this.keyMap.delete(e),!0):(n||console.warn(`No keyboard shortcut named "${t}" registered with key code "${e}"`),!1)}removeAllKeyMappings(e){for(let t of this.keyMap.keys())this.removeKeyMapping(t,e,!0)}setKeyMap(e){this.keyMap.clear();for(let t in e)this.keyMap.set(t,e[t])}getKeyMap(){let e=Object.create(null);for(let[t,n]of this.keyMap)e[t]=n;return e}getRegistry(){let e=Object.create(null);for(let[t,n]of this.shortcuts)e[t]=n;return qe(Object.create(null),e)}onKeyDown(t,n){var r=this.serializeKeyEvent(n);if(r=this.getShortcutNamesByKeyCode(r),!r)return!1;for(let i of r){if(r=this.shortcuts.get(i),!r||r.preconditionFn&&!r.preconditionFn(t,{focusedNode:e.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode()??void 0}))continue;let a,o;if((o=(a=r).callback)!=null&&o.call(a,t,n,r,{focusedNode:e.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode()??void 0}))return!0}return!1}getShortcutNamesByKeyCode(e){return this.keyMap.get(e)?.slice()||[]}getKeyCodesByShortcutName(e){let t=[];for(let[n,r]of this.keyMap)r.indexOf(e)>-1&&t.push(n);return t}serializeKeyEvent(e){let t=``;for(let n in _l.modifierKeys)e.getModifierState(n)&&(t!==``&&(t+=`+`),t+=n);return t!==``&&e.keyCode?t+=`+`+e.keyCode:e.keyCode&&(t=String(e.keyCode)),t}checkModifiers(e){for(let t of e)if(!(t in _l.modifierKeys))throw Error(t+` is not a valid modifier key.`)}createSerializedKey(e,t){let n=``;if(t){this.checkModifiers(t);for(let e in _l.modifierKeys)t.includes(_l.modifierKeys[e])&&(n!==``&&(n+=`+`),n+=e)}return n!==``&&e?n+=`+`+e:e&&(n=`${e}`),n}};_l.registry=new _l,(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`})(_l||(_l={}));var vl={};vl.ShortcutRegistry=_l;var yl=Object.create(null),bl,xl,Sl=[],Cl={defineBlocksWithJsonArrayInternal:lt},wl={TEST_ONLY:Cl};wl.createBlockDefinitionsFromJsonArray=e.createBlockDefinitionsFromJsonArray$$module$build$src$core$common,wl.defineBlocks=e.defineBlocks$$module$build$src$core$common,wl.defineBlocksWithJsonArray=ct,wl.draggingConnections=Sl,wl.fireSelectedEvent=nt,wl.getAllWorkspaces=Ye,wl.getBlockTypeCounts=ot,wl.getMainWorkspace=Qe,wl.getParentContainer=rt,wl.getSelected=et,wl.getWorkspaceById=Je,wl.globalShortcutHandler=ut,wl.registerWorkspace=Xe,wl.setMainWorkspace=$e,wl.setParentContainer=it,wl.setSelected=tt,wl.svgResize=at,wl.unregisterWorkpace=Ze;var Tl=class{constructor(){this.workspaceId=void 0,this.isUiEvent=!1,this.type=``,this.group=e.getGroup$$module$build$src$core$events$utils(),this.recordUndo=Te()}toJson(){return{type:this.type,group:this.group}}static fromJson(e,t,n){return n.isBlank=!1,n.group=e.group||``,n.workspaceId=t.id,n}isNull(){return!1}run(e){}getEventWorkspace_(){let e;if(this.workspaceId&&(e=Je(this.workspaceId)),!e)throw Error(`Workspace is null. Event must have been generated from real Blockly events.`);return e}},El={};El.Abstract=Tl;var Dl=class extends Tl{constructor(e){super(),this.isBlank=!0,this.recordUndo=!1,this.isUiEvent=!0,this.isBlank=e===void 0,this.workspaceId=e||``}},Ol={};Ol.UiBase=Dl;var kl=class extends Dl{constructor(e,t,n){t=e?e.workspace.id:t,t===null&&(t=void 0),super(t),this.type=F.CLICK,this.blockId=e?e.id:void 0,this.targetType=n}toJson(){let 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,n){return t=Dl.fromJson(e,t,n??new kl),t.targetType=e.targetType,t.blockId=e.blockId,t}},Al;(function(e){e.BLOCK=`block`,e.WORKSPACE=`workspace`,e.ZOOM_CONTROLS=`zoom_controls`})(Al||(Al={})),t(P.EVENT,F.CLICK,kl);var jl={};jl.Click=kl,jl.ClickTarget=Al;var Ml={};Ml.removeElem=dt;var Nl=class{constructor(e){this.name=e}toString(){return this.name}};Nl.POSITIONABLE=new Nl(`positionable`),Nl.DRAG_TARGET=new Nl(`drag_target`),Nl.DELETE_AREA=new Nl(`delete_area`),Nl.AUTOHIDEABLE=new Nl(`autohideable`);var Pl=class{constructor(){this.componentData=new Map,this.capabilityToComponentIds=new Map}addComponent(e,t){let n=e.component.id;if(!t&&this.componentData.has(n)){var r;throw Error(`Plugin "`+n+`" with capabilities "`+(r=this.componentData.get(n))?.capabilities+`" already added.`)}for(this.componentData.set(n,e),t=[],r=0;r<e.capabilities.length;r++){let i=String(e.capabilities[r]).toLowerCase();if(t.push(i),this.capabilityToComponentIds.has(i)){let e;(e=this.capabilityToComponentIds.get(i))==null||e.push(n)}else this.capabilityToComponentIds.set(i,[n])}this.componentData.get(n).capabilities=t}removeComponent(e){let t=this.componentData.get(e);if(t){for(let n=0;n<t.capabilities.length;n++){let r=String(t.capabilities[n]).toLowerCase();dt(this.capabilityToComponentIds.get(r),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 n;(n=this.componentData.get(e))==null||n.capabilities.push(t);var r;(r=this.capabilityToComponentIds.get(t))==null||r.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(),dt(this.componentData.get(e).capabilities,t),dt(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){return this.componentData.get(e)?.component}getComponents(e,t){if(e=`${e}`.toLowerCase(),e=this.capabilityToComponentIds.get(e),!e)return[];let n=[];if(t){let t=[];e.forEach(e=>{t.push(this.componentData.get(e))}),t.sort(function(e,t){return e.weight-t.weight}),t.forEach(function(e){n.push(e.component)})}else e.forEach(e=>{n.push(this.componentData.get(e).component)});return n}};Pl.Capability=Nl,(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`})(Pl||(Pl={}));var Fl=Pl.ComponentWeight,Il={};Il.ComponentManager=Pl,Il.ComponentWeight=Fl;var Ll=!1,Rl=`
|
|
13
|
+
.blocklySvg {
|
|
14
|
+
background-color: #fff;
|
|
15
|
+
outline: none;
|
|
16
|
+
overflow: hidden; /* IE overflows by default. */
|
|
17
|
+
position: absolute;
|
|
18
|
+
display: block;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.blocklyWidgetDiv {
|
|
22
|
+
display: none;
|
|
23
|
+
position: absolute;
|
|
24
|
+
z-index: 99999; /* big value for bootstrap3 compatibility */
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.injectionDiv {
|
|
28
|
+
height: 100%;
|
|
29
|
+
position: relative;
|
|
30
|
+
overflow: hidden; /* So blocks in drag surface disappear at edges */
|
|
31
|
+
touch-action: none;
|
|
32
|
+
user-select: none;
|
|
33
|
+
-webkit-user-select: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.blocklyBlockCanvas.blocklyCanvasTransitioning,
|
|
37
|
+
.blocklyBubbleCanvas.blocklyCanvasTransitioning {
|
|
38
|
+
transition: transform .5s;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.blocklyEmboss {
|
|
42
|
+
filter: var(--blocklyEmbossFilter);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.blocklyTooltipDiv {
|
|
46
|
+
background-color: #ffffc7;
|
|
47
|
+
border: 1px solid #ddc;
|
|
48
|
+
box-shadow: 4px 4px 20px 1px rgba(0,0,0,.15);
|
|
49
|
+
color: #000;
|
|
50
|
+
display: none;
|
|
51
|
+
font: 9pt sans-serif;
|
|
52
|
+
opacity: .9;
|
|
53
|
+
padding: 2px;
|
|
54
|
+
position: absolute;
|
|
55
|
+
z-index: 100000; /* big value for bootstrap3 compatibility */
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.blocklyDropDownDiv {
|
|
59
|
+
position: absolute;
|
|
60
|
+
left: 0;
|
|
61
|
+
top: 0;
|
|
62
|
+
z-index: 1000;
|
|
63
|
+
display: none;
|
|
64
|
+
border: 1px solid;
|
|
65
|
+
border-color: #dadce0;
|
|
66
|
+
background-color: #fff;
|
|
67
|
+
border-radius: 2px;
|
|
68
|
+
padding: 4px;
|
|
69
|
+
box-shadow: 0 0 3px 1px rgba(0,0,0,.3);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.blocklyDropDownDiv:focus {
|
|
73
|
+
box-shadow: 0 0 6px 1px rgba(0,0,0,.3);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.blocklyDropDownContent {
|
|
77
|
+
max-height: 300px; /* @todo: spec for maximum height. */
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.blocklyDropDownArrow {
|
|
81
|
+
position: absolute;
|
|
82
|
+
left: 0;
|
|
83
|
+
top: 0;
|
|
84
|
+
width: 16px;
|
|
85
|
+
height: 16px;
|
|
86
|
+
z-index: -1;
|
|
87
|
+
background-color: inherit;
|
|
88
|
+
border-color: inherit;
|
|
89
|
+
border-top: 1px solid;
|
|
90
|
+
border-left: 1px solid;
|
|
91
|
+
border-top-left-radius: 4px;
|
|
92
|
+
border-color: inherit;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.blocklyHighlighted>.blocklyPath {
|
|
96
|
+
filter: var(--blocklyEmbossFilter);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.blocklyHighlightedConnectionPath {
|
|
100
|
+
fill: none;
|
|
101
|
+
stroke: #fc3;
|
|
102
|
+
stroke-width: 4px;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.blocklyPathLight {
|
|
106
|
+
fill: none;
|
|
107
|
+
stroke-linecap: round;
|
|
108
|
+
stroke-width: 1;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.blocklySelected>.blocklyPathLight {
|
|
112
|
+
display: none;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.blocklyDraggable {
|
|
116
|
+
cursor: grab;
|
|
117
|
+
cursor: -webkit-grab;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.blocklyDragging {
|
|
121
|
+
cursor: grabbing;
|
|
122
|
+
cursor: -webkit-grabbing;
|
|
123
|
+
/* Drag surface disables events to not block the toolbox, so we have to
|
|
124
|
+
* reenable them here for the cursor values to work. */
|
|
125
|
+
pointer-events: auto;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* Changes cursor on mouse down. Not effective in Firefox because of
|
|
129
|
+
https://bugzilla.mozilla.org/show_bug.cgi?id=771241 */
|
|
130
|
+
.blocklyDraggable:active {
|
|
131
|
+
cursor: grabbing;
|
|
132
|
+
cursor: -webkit-grabbing;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.blocklyDragging.blocklyDraggingDelete,
|
|
136
|
+
.blocklyDragging.blocklyDraggingDelete .blocklyField {
|
|
137
|
+
cursor: url("<<<PATH>>>/handdelete.cur"), auto;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.blocklyDragging>.blocklyPath,
|
|
141
|
+
.blocklyDragging>.blocklyPathLight {
|
|
142
|
+
fill-opacity: .8;
|
|
143
|
+
stroke-opacity: .8;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.blocklyDragging>.blocklyPathDark {
|
|
147
|
+
display: none;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.blocklyDisabledPattern>.blocklyPath {
|
|
151
|
+
fill: var(--blocklyDisabledPattern);
|
|
152
|
+
fill-opacity: .5;
|
|
153
|
+
stroke-opacity: .5;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.blocklyDisabled>.blocklyPathLight,
|
|
157
|
+
.blocklyDisabled>.blocklyPathDark {
|
|
158
|
+
display: none;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.blocklyInsertionMarker>.blocklyPath,
|
|
162
|
+
.blocklyInsertionMarker>.blocklyPathLight,
|
|
163
|
+
.blocklyInsertionMarker>.blocklyPathDark {
|
|
164
|
+
fill-opacity: .2;
|
|
165
|
+
stroke: none;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.blocklyNonEditableField>text {
|
|
169
|
+
pointer-events: none;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.blocklyFlyout {
|
|
173
|
+
position: absolute;
|
|
174
|
+
z-index: 20;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.blocklyText text {
|
|
178
|
+
cursor: default;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/*
|
|
182
|
+
Don't allow users to select text. It gets annoying when trying to
|
|
183
|
+
drag a block and selected text moves instead.
|
|
184
|
+
*/
|
|
185
|
+
.blocklySvg text {
|
|
186
|
+
user-select: none;
|
|
187
|
+
-ms-user-select: none;
|
|
188
|
+
-webkit-user-select: none;
|
|
189
|
+
cursor: inherit;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.blocklyIconGroup {
|
|
193
|
+
cursor: default;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.blocklyIconGroup:not(:hover):not(:focus),
|
|
197
|
+
.blocklyIconGroupReadonly {
|
|
198
|
+
opacity: .6;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.blocklyIconShape {
|
|
202
|
+
fill: #00f;
|
|
203
|
+
stroke: #fff;
|
|
204
|
+
stroke-width: 1px;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.blocklyIconSymbol {
|
|
208
|
+
fill: #fff;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.blocklyMinimalBody {
|
|
212
|
+
margin: 0;
|
|
213
|
+
padding: 0;
|
|
214
|
+
height: 100%;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.blocklyHtmlInput {
|
|
218
|
+
border: none;
|
|
219
|
+
border-radius: 4px;
|
|
220
|
+
height: 100%;
|
|
221
|
+
margin: 0;
|
|
222
|
+
outline: none;
|
|
223
|
+
padding: 0;
|
|
224
|
+
width: 100%;
|
|
225
|
+
text-align: center;
|
|
226
|
+
display: block;
|
|
227
|
+
box-sizing: border-box;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/* Remove the increase and decrease arrows on the field number editor */
|
|
231
|
+
input.blocklyHtmlInput[type=number]::-webkit-inner-spin-button,
|
|
232
|
+
input.blocklyHtmlInput[type=number]::-webkit-outer-spin-button {
|
|
233
|
+
-webkit-appearance: none;
|
|
234
|
+
margin: 0;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
input[type=number] {
|
|
238
|
+
-moz-appearance: textfield;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.blocklyMainBackground {
|
|
242
|
+
stroke-width: 1;
|
|
243
|
+
stroke: #c6c6c6; /* Equates to #ddd due to border being off-pixel. */
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.blocklyMutatorBackground {
|
|
247
|
+
fill: #fff;
|
|
248
|
+
stroke: #ddd;
|
|
249
|
+
stroke-width: 1;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.blocklyFlyoutBackground {
|
|
253
|
+
fill: #ddd;
|
|
254
|
+
fill-opacity: .8;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.blocklyMainWorkspaceScrollbar {
|
|
258
|
+
z-index: 20;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.blocklyFlyoutScrollbar {
|
|
262
|
+
z-index: 30;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.blocklyScrollbarHorizontal,
|
|
266
|
+
.blocklyScrollbarVertical {
|
|
267
|
+
position: absolute;
|
|
268
|
+
outline: none;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.blocklyScrollbarBackground {
|
|
272
|
+
opacity: 0;
|
|
273
|
+
pointer-events: none;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.blocklyScrollbarHandle {
|
|
277
|
+
fill: #ccc;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,
|
|
281
|
+
.blocklyScrollbarHandle:hover {
|
|
282
|
+
fill: #bbb;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/* Darken flyout scrollbars due to being on a grey background. */
|
|
286
|
+
/* By contrast, workspace scrollbars are on a white background. */
|
|
287
|
+
.blocklyFlyout .blocklyScrollbarHandle {
|
|
288
|
+
fill: #bbb;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.blocklyFlyout .blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,
|
|
292
|
+
.blocklyFlyout .blocklyScrollbarHandle:hover {
|
|
293
|
+
fill: #aaa;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.blocklyInvalidInput {
|
|
297
|
+
background: #faa;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.blocklyVerticalMarker {
|
|
301
|
+
stroke-width: 3px;
|
|
302
|
+
fill: rgba(255,255,255,.5);
|
|
303
|
+
pointer-events: none;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.blocklyComputeCanvas {
|
|
307
|
+
position: absolute;
|
|
308
|
+
width: 0;
|
|
309
|
+
height: 0;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.blocklyNoPointerEvents {
|
|
313
|
+
pointer-events: none;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.blocklyContextMenu {
|
|
317
|
+
border-radius: 4px;
|
|
318
|
+
max-height: 100%;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.blocklyDropdownMenu {
|
|
322
|
+
border-radius: 2px;
|
|
323
|
+
padding: 0 !important;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.blocklyDropdownMenu .blocklyMenuItem {
|
|
327
|
+
/* 28px on the left for icon or checkbox. */
|
|
328
|
+
padding-left: 28px;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/* BiDi override for the resting state. */
|
|
332
|
+
.blocklyDropdownMenu .blocklyMenuItemRtl {
|
|
333
|
+
/* Flip left/right padding for BiDi. */
|
|
334
|
+
padding-left: 5px;
|
|
335
|
+
padding-right: 28px;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.blocklyWidgetDiv .blocklyMenu {
|
|
339
|
+
user-select: none;
|
|
340
|
+
-ms-user-select: none;
|
|
341
|
+
-webkit-user-select: none;
|
|
342
|
+
background: #fff;
|
|
343
|
+
border: 1px solid transparent;
|
|
344
|
+
box-shadow: 0 0 3px 1px rgba(0,0,0,.3);
|
|
345
|
+
font: normal 13px Arial, sans-serif;
|
|
346
|
+
margin: 0;
|
|
347
|
+
outline: none;
|
|
348
|
+
padding: 4px 0;
|
|
349
|
+
position: absolute;
|
|
350
|
+
overflow-y: auto;
|
|
351
|
+
overflow-x: hidden;
|
|
352
|
+
max-height: 100%;
|
|
353
|
+
z-index: 20000; /* Arbitrary, but some apps depend on it... */
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.blocklyWidgetDiv .blocklyMenu:focus {
|
|
357
|
+
box-shadow: 0 0 6px 1px rgba(0,0,0,.3);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.blocklyDropDownDiv .blocklyMenu {
|
|
361
|
+
user-select: none;
|
|
362
|
+
-ms-user-select: none;
|
|
363
|
+
-webkit-user-select: none;
|
|
364
|
+
background: inherit; /* Compatibility with gapi, reset from goog-menu */
|
|
365
|
+
border: inherit; /* Compatibility with gapi, reset from goog-menu */
|
|
366
|
+
font: normal 13px "Helvetica Neue", Helvetica, sans-serif;
|
|
367
|
+
outline: none;
|
|
368
|
+
overflow-y: auto;
|
|
369
|
+
overflow-x: hidden;
|
|
370
|
+
max-height: 100%;
|
|
371
|
+
z-index: 20000; /* Arbitrary, but some apps depend on it... */
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/* State: resting. */
|
|
375
|
+
.blocklyMenuItem {
|
|
376
|
+
border: none;
|
|
377
|
+
color: #000;
|
|
378
|
+
cursor: pointer;
|
|
379
|
+
list-style: none;
|
|
380
|
+
margin: 0;
|
|
381
|
+
/* 7em on the right for shortcut. */
|
|
382
|
+
min-width: 7em;
|
|
383
|
+
padding: 6px 15px;
|
|
384
|
+
white-space: nowrap;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/* State: disabled. */
|
|
388
|
+
.blocklyMenuItemDisabled {
|
|
389
|
+
color: #ccc;
|
|
390
|
+
cursor: inherit;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/* State: hover. */
|
|
394
|
+
.blocklyMenuItemHighlight {
|
|
395
|
+
background-color: rgba(0,0,0,.1);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/* State: selected/checked. */
|
|
399
|
+
.blocklyMenuItemSelected .blocklyMenuItemCheckbox {
|
|
400
|
+
background: url(<<<PATH>>>/sprites.png) no-repeat -48px -16px;
|
|
401
|
+
float: left;
|
|
402
|
+
margin-left: -24px;
|
|
403
|
+
width: 16px;
|
|
404
|
+
height: 16px;
|
|
405
|
+
position: static; /* Scroll with the menu. */
|
|
406
|
+
display: block;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
.blocklyMenuItemRtl .blocklyMenuItemCheckbox {
|
|
410
|
+
float: right;
|
|
411
|
+
margin-right: -24px;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.blocklyMenuSeparator {
|
|
415
|
+
background-color: #ccc;
|
|
416
|
+
height: 1px;
|
|
417
|
+
border: 0;
|
|
418
|
+
margin-left: 4px;
|
|
419
|
+
margin-right: 4px;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
.blocklyBlockDragSurface, .blocklyAnimationLayer {
|
|
423
|
+
position: absolute;
|
|
424
|
+
top: 0;
|
|
425
|
+
left: 0;
|
|
426
|
+
right: 0;
|
|
427
|
+
bottom: 0;
|
|
428
|
+
overflow: visible !important;
|
|
429
|
+
z-index: 80;
|
|
430
|
+
pointer-events: none;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
.blocklyField {
|
|
434
|
+
cursor: default;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.blocklyInputField {
|
|
438
|
+
cursor: text;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
.blocklyDragging .blocklyField,
|
|
442
|
+
.blocklyDragging .blocklyIconGroup {
|
|
443
|
+
cursor: grabbing;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
.blocklyActiveFocus:is(
|
|
447
|
+
.blocklyFlyout,
|
|
448
|
+
.blocklyWorkspace,
|
|
449
|
+
.blocklyField,
|
|
450
|
+
.blocklyPath,
|
|
451
|
+
.blocklyHighlightedConnectionPath,
|
|
452
|
+
.blocklyComment,
|
|
453
|
+
.blocklyBubble,
|
|
454
|
+
.blocklyIconGroup,
|
|
455
|
+
.blocklyTextarea
|
|
456
|
+
) {
|
|
457
|
+
outline: none;
|
|
458
|
+
}
|
|
459
|
+
`,zl={};zl.inject=pt,zl.register=ft;var I=class{constructor(e,t){this.x=e,this.y=t}clone(){return new I(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){let n=e.x-t.x;return e=e.y-t.y,Math.sqrt(n*n+e*e)}static magnitude(e){return Math.sqrt(e.x*e.x+e.y*e.y)}static difference(e,t){return new I(e.x-t.x,e.y-t.y)}static sum(e,t){return new I(e.x+t.x,e.y+t.y)}},Bl={};Bl.Coordinate=I;var L=class{constructor(e){this.tagName=e}toString(){return this.tagName}};L.ANIMATE=new L(`animate`),L.CIRCLE=new L(`circle`),L.CLIPPATH=new L(`clipPath`),L.DEFS=new L(`defs`),L.FECOMPOSITE=new L(`feComposite`),L.FECOMPONENTTRANSFER=new L(`feComponentTransfer`),L.FEFLOOD=new L(`feFlood`),L.FEFUNCA=new L(`feFuncA`),L.FEGAUSSIANBLUR=new L(`feGaussianBlur`),L.FEPOINTLIGHT=new L(`fePointLight`),L.FESPECULARLIGHTING=new L(`feSpecularLighting`),L.FILTER=new L(`filter`),L.FOREIGNOBJECT=new L(`foreignObject`),L.G=new L(`g`),L.IMAGE=new L(`image`),L.LINE=new L(`line`),L.PATH=new L(`path`),L.PATTERN=new L(`pattern`),L.POLYGON=new L(`polygon`),L.RECT=new L(`rect`),L.SVG=new L(`svg`),L.TEXT=new L(`text`),L.TSPAN=new L(`tspan`);var Vl={};Vl.Svg=L;var R=class{constructor(e,t,n,r){this.top=e,this.bottom=t,this.left=n,this.right=r}static from(e){return new R(e.y,e.y+e.height,e.x,e.x+e.width)}clone(){return new R(this.top,this.bottom,this.left,this.right)}getHeight(){return this.bottom-this.top}getWidth(){return this.right-this.left}getOrigin(){return new I(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,n){let r=e.x;return e=e.y,new R(e,e+n,r,r+t)}},Hl={};Hl.Rect=R;var z=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 z(Math.max(e.width,t.width),Math.max(e.height,t.height))}static min(e,t){return new z(Math.min(e.width,t.width),Math.min(e.height,t.height))}},Ul={};Ul.Size=z;var Wl={getSizeInternal:ht},Gl={TEST_ONLY:Wl};Gl.getBorderBox=bt,Gl.getComputedStyle=_t,Gl.getContainerOffsetToScrollInto=St,Gl.getPageOffset=vt,Gl.getSize=mt,Gl.getViewportPageOffset=yt,Gl.scrollIntoContainerView=xt;var Kl=/translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*)?/,ql=/transform:\s*translate(?:3d)?\(\s*([-+\d.e]+)\s*px([ ,]\s*([-+\d.e]+)\s*px)?/,Jl={TEST_ONLY:{XY_REGEX:Kl,XY_STYLE_REGEX:ql}};Jl.getDocumentScroll=Et,Jl.getInjectionDivXY=wt,Jl.getRelativeXY=Ct,Jl.getViewportBBox=Tt,Jl.screenToWsCoordinates=Dt,Jl.wsToScreenCoordinates=Ot;var Yl=class{constructor(e,t,n,r,i){this.workspace=e,this.horizontal=t,this.oldHostMetrics=null,this.ratio=1,this.origin=new I(0,0),this.startDragHandle=this.handlePosition=this.handleLength=this.scrollbarLength=this.startDragMouse=0,this.containerVisible=this.isHandleVisible=!0,this.position=new I(0,0),this.onMouseMoveWrapper_=this.onMouseUpWrapper_=null,this.pair=n||!1,this.margin=i===void 0?Yl.DEFAULT_SCROLLBAR_MARGIN:i,e=`blocklyScrollbar`+(this.horizontal?`Horizontal`:`Vertical`),r&&(e+=` `+r),this.outerSvg=D(L.SVG,{class:e}),r=D(L.G,{},this.outerSvg),this.svgBackground=D(L.RECT,{class:`blocklyScrollbarBackground`},r),e=Math.floor((Yl.scrollbarThickness-5)/2),this.svgHandle=D(L.RECT,{class:`blocklyScrollbarHandle`,rx:e,ry:e},r),this.workspace.getThemeManager().subscribe(this.svgHandle,`scrollbarColour`,`fill`),this.workspace.getThemeManager().subscribe(this.svgHandle,`scrollbarOpacity`,`fill-opacity`),Le(this.outerSvg,this.workspace.getParentSvg()),this.setInitialThickness(),t?(this.lengthAttribute_=`width`,this.positionAttribute_=`x`):(this.lengthAttribute_=`height`,this.positionAttribute_=`y`),this.onMouseDownBarWrapper_=g(this.svgBackground,`pointerdown`,this,this.onMouseDownBar),this.onMouseDownHandleWrapper_=g(this.svgHandle,`pointerdown`,this,this.onMouseDownHandle)}setInitialThickness(){let e=Yl.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(),v(this.onMouseDownBarWrapper_),v(this.onMouseDownHandleWrapper_),A(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,Re(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&&Yl.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-=Yl.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),t=e.absoluteLeft+this.margin,this.pair&&this.workspace.RTL&&(t+=Yl.scrollbarThickness),this.setPosition(t,e.absoluteTop+e.viewHeight-Yl.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 n=this.scrollbarLength-this.handleLength;e=(e.viewLeft-e.scrollLeft)/t*n,e=this.constrainHandlePosition(e),this.setHandlePosition(e),this.ratio=n/t}}resizeVertical(e){this.requiresViewResize(e)?this.resizeViewVertical(e):this.resizeContentVertical(e)}resizeViewVertical(e){let t=e.viewHeight-this.margin*2;this.pair&&(t-=Yl.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),this.setPosition(this.workspace.RTL?e.absoluteLeft+this.margin:e.absoluteLeft+e.viewWidth-Yl.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 n=this.scrollbarLength-this.handleLength;e=(e.viewTop-e.scrollTop)/t*n,e=this.constrainHandlePosition(e),this.setHandlePosition(e),this.ratio=n/t}}isVisible(){return this.isHandleVisible}setContainerVisible(e){let 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){let 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(),f(),this.cleanUp(),b(e))e.stopPropagation();else{var t=ee(e,this.workspace.getParentSvg(),this.workspace.getInverseScreenCTM());t=this.horizontal?t.x:t.y;var n=wt(this.svgHandle);n=this.horizontal?n.x:n.y;var r=this.handlePosition,i=this.handleLength*.95;t<=n?r-=i:t>=n+this.handleLength&&(r+=i),this.setHandlePosition(this.constrainHandlePosition(r)),this.updateMetrics(),e.stopPropagation(),e.preventDefault()}}onMouseDownHandle(e){this.workspace.markFocused(),this.cleanUp(),b(e)?e.stopPropagation():(this.startDragHandle=this.handlePosition,this.startDragMouse=this.horizontal?e.clientX:e.clientY,this.onMouseUpWrapper_=g(document,`pointerup`,this,this.onMouseUpHandle),this.onMouseMoveWrapper_=g(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(){f(),this.cleanUp()}cleanUp(){this.workspace.hideChaff(!0),this.onMouseUpWrapper_&&(v(this.onMouseUpWrapper_),this.onMouseUpWrapper_=null),this.onMouseMoveWrapper_&&(v(this.onMouseMoveWrapper_),this.onMouseMoveWrapper_=null)}getRatio_(){let e=this.handlePosition/(this.scrollbarLength-this.handleLength);return isNaN(e)&&(e=0),e}updateMetrics(){let 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 I(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}};Yl.scrollbarThickness=mc?25:15,Yl.DEFAULT_SCROLLBAR_MARGIN=.5;var Xl={};Xl.Scrollbar=Yl;var Zl={parseFromString:function(){throw Error(`DOMParser was not found in the global scope and was not properly injected using injectDependencies`)}},Ql={serializeToString:function(){throw Error(`XMLSerializer was not foundin the global scope and was not properly injected using injectDependencies`)}},{document:$l,DOMParser:eu,XMLSerializer:tu}=globalThis;eu&&(Zl=new eu),tu&&(Ql=new tu);var nu=`https://developers.google.com/blockly/xml`,ru=/[\x00-\x09\x0B\x0C\x0E-\x1F]/g,iu={NAME_SPACE:nu};iu.createElement=e.createElement$$module$build$src$core$utils$xml,iu.createTextNode=e.createTextNode$$module$build$src$core$utils$xml,iu.domToText=At,iu.injectDependencies=kt,iu.textToDom=e.textToDom$$module$build$src$core$utils$xml;var au=`categoryToolbox`,ou=`flyoutToolbox`,B;(function(e){e[e.TOP=0]=`TOP`,e[e.BOTTOM=1]=`BOTTOM`,e[e.LEFT=2]=`LEFT`,e[e.RIGHT=3]=`RIGHT`})(B||(B={}));var su={hasCategoriesInternal:It},cu={};cu.Position=B,cu.TEST_ONLY=su,cu.convertFlyoutDefToJsonArray=Pt,cu.convertToolboxDefToJson=Mt,cu.hasCategories=Ft,cu.isCategoryCollapsible=Lt,cu.parseToolboxTree=Vt;var lu;(function(e){e[e.TOP=0]=`TOP`,e[e.BOTTOM=1]=`BOTTOM`})(lu||(lu={}));var uu;(function(e){e[e.LEFT=0]=`LEFT`,e[e.RIGHT=1]=`RIGHT`})(uu||(uu={}));var du;(function(e){e[e.UP=0]=`UP`,e[e.DOWN=1]=`DOWN`})(du||(du={}));var fu={};fu.bumpDirection=du,fu.bumpPositionRect=Wt,fu.getCornerOppositeToolbox=Ut,fu.getStartPositionRect=Ht,fu.horizontalPosition=uu,fu.verticalPosition=lu;var pu={width:96,height:124,url:`sprites.png`},mu=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=D(L.G,{});let 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:Pl.ComponentWeight.ZOOM_CONTROLS_WEIGHT,capabilities:[Pl.Capability.POSITIONABLE]}),this.initialized=!0}dispose(){this.workspace.getComponentManager().removeComponent(`zoomControls`),this.svgGroup&&A(this.svgGroup);for(let e of this.boundEvents)v(e);this.boundEvents.length=0}getBoundingRectangle(){let e=this.SMALL_SPACING+2*this.HEIGHT;return this.zoomResetGroup&&(e+=this.LARGE_SPACING+this.HEIGHT),new R(this.top,this.top+e,this.left,this.left+this.WIDTH)}position(e,t){if(this.initialized){var n=Ut(this.workspace,e),r=this.SMALL_SPACING+2*this.HEIGHT;if(this.zoomResetGroup&&(r+=this.LARGE_SPACING+this.HEIGHT),e=Ht(n,new z(this.WIDTH,r),this.MARGIN_HORIZONTAL,this.MARGIN_VERTICAL,e,this.workspace),n=n.vertical,t=Wt(e,this.MARGIN_VERTICAL,n===lu.TOP?du.DOWN:du.UP,t),n===lu.TOP){var i=this.SMALL_SPACING+this.HEIGHT,a;(a=this.zoomInGroup)==null||a.setAttribute(`transform`,`translate(0, `+i+`)`),this.zoomResetGroup&&this.zoomResetGroup.setAttribute(`transform`,`translate(0, `+(i+this.LARGE_SPACING+this.HEIGHT)+`)`)}else{a=this.zoomResetGroup?this.LARGE_SPACING+this.HEIGHT:0;let e;(e=this.zoomInGroup)==null||e.setAttribute(`transform`,`translate(0, `+a+`)`),a=a+this.SMALL_SPACING+this.HEIGHT,(i=this.zoomOutGroup)==null||i.setAttribute(`transform`,`translate(0, `+a+`)`)}this.top=t.top,this.left=t.left;var o;(o=this.svgGroup)==null||o.setAttribute(`transform`,`translate(`+this.left+`,`+this.top+`)`)}}createZoomOutSvg(e){this.zoomOutGroup=D(L.G,{class:`blocklyZoom blocklyZoomOut`},this.svgGroup);let t=D(L.CLIPPATH,{id:`blocklyZoomoutClipPath`+e},this.zoomOutGroup);D(L.RECT,{width:32,height:32},t),D(L.IMAGE,{width:pu.width,height:pu.height,x:-64,y:-92,"clip-path":`url(#blocklyZoomoutClipPath`+e+`)`},this.zoomOutGroup).setAttributeNS(rl,`xlink:href`,this.workspace.options.pathToMedia+pu.url),this.boundEvents.push(g(this.zoomOutGroup,`pointerdown`,null,this.zoom.bind(this,-1)))}createZoomInSvg(e){this.zoomInGroup=D(L.G,{class:`blocklyZoom blocklyZoomIn`},this.svgGroup);let t=D(L.CLIPPATH,{id:`blocklyZoominClipPath`+e},this.zoomInGroup);D(L.RECT,{width:32,height:32},t),D(L.IMAGE,{width:pu.width,height:pu.height,x:-32,y:-92,"clip-path":`url(#blocklyZoominClipPath`+e+`)`},this.zoomInGroup).setAttributeNS(rl,`xlink:href`,this.workspace.options.pathToMedia+pu.url),this.boundEvents.push(g(this.zoomInGroup,`pointerdown`,null,this.zoom.bind(this,1)))}zoom(e,t){this.workspace.markFocused(),this.workspace.zoomCenter(e),this.fireZoomEvent(),f(),t.stopPropagation(),t.preventDefault()}createZoomResetSvg(e){this.zoomResetGroup=D(L.G,{class:`blocklyZoom blocklyZoomReset`},this.svgGroup);let t=D(L.CLIPPATH,{id:`blocklyZoomresetClipPath`+e},this.zoomResetGroup);D(L.RECT,{width:32,height:32},t),D(L.IMAGE,{width:pu.width,height:pu.height,y:-92,"clip-path":`url(#blocklyZoomresetClipPath`+e+`)`},this.zoomResetGroup).setAttributeNS(rl,`xlink:href`,this.workspace.options.pathToMedia+pu.url),this.boundEvents.push(g(this.zoomResetGroup,`pointerdown`,null,this.resetZoom.bind(this)))}resetZoom(e){this.workspace.markFocused();let 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(),f(),e.stopPropagation(),e.preventDefault()}fireZoomEvent(){let e=new(E(F.CLICK))(null,this.workspace.id,`zoom_controls`);w(e)}};ft(`
|
|
460
|
+
.blocklyZoom>image, .blocklyZoom>svg>image {
|
|
461
|
+
opacity: .4;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
.blocklyZoom>image:hover, .blocklyZoom>svg>image:hover {
|
|
465
|
+
opacity: .6;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
.blocklyZoom>image:active, .blocklyZoom>svg>image:active {
|
|
469
|
+
opacity: .8;
|
|
470
|
+
}
|
|
471
|
+
`);var hu={};hu.ZoomControls=mu;var gu=100,_u=75,vu=50,yu=25,bu={BLOCKS:vu,PROCEDURES:_u,VARIABLES:gu,WORKSPACE_COMMENTS:yu},xu={};xu.register=Gt,xu.unregister=Kt;var Su=class{constructor(){this.priority=yu}save(e){let t=[];for(let n of e.getTopComments())(e=qt(n,{addCoordinates:!0,saveIds:!0}))&&t.push(e);return t.length?t:null}load(e,t){for(let n of e)Jt(n,t,{recordUndo:Te()})}clear(e){for(let t of e.getTopComments())t.dispose()}};Gt(`workspaceComments`,new Su);var Cu={};Cu.WorkspaceCommentSerializer=Su,Cu.append=Jt,Cu.save=qt;var wu={};wu.register=Yt,wu.unregister=Xt;var Tu=class{paste(t,n,r){t=t.commentState,r&&(t.x=r.x,t.y=r.y),e.disable$$module$build$src$core$events$utils();let i;try{i=Jt(t,n),Zt(i)}finally{e.enable$$module$build$src$core$events$utils()}return i?(je()&&w(new(E(F.COMMENT_CREATE))(i)),e.getFocusManager$$module$build$src$core$focus_manager().focusNode(i),i):null}};Tu.TYPE=`workspace-comment`,Yt(Tu.TYPE,new Tu);var Eu={};Eu.WorkspaceCommentPaster=Tu;var Du=28;e.config$$module$build$src$core$config={dragRadius:5,flyoutDragRadius:10,snapRadius:Du,connectingSnapRadius:Du,currentConnectionPreference:8,bumpDelay:250},e.config$$module$build$src$core$config;var Ou=`aria-`,ku=`role`,Au;(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`})(Au||(Au={}));var ju;(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`})(ju||(ju={}));var Mu={};Mu.Role=Au,Mu.State=ju,Mu.setRole=$t,Mu.setState=en;var Nu=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(){let e=document.createElement(`div`);e.id=ne(),this.element=e,e.className=`blocklyMenuItem `+(this.enabled?``:`blocklyMenuItemDisabled `)+(this.checked?`blocklyMenuItemSelected `:``)+(this.highlight?`blocklyMenuItemHighlight `:``)+(this.rightToLeft?`blocklyMenuItemRtl `:``);let t=document.createElement(`div`);t.className=`blocklyMenuItemContent`;let n=this.content;return typeof this.content==`string`&&(n=document.createTextNode(this.content)),t.appendChild(n),e.appendChild(t),this.checkable&&this.toggleHasCheckbox(!0),this.roleName&&$t(e,this.roleName),en(e,ju.SELECTED,this.checkable&&this.checked||!1),en(e,ju.DISABLED,!this.enabled),e}dispose(){this.element=null}getElement(){return this.element}getId(){return this.element.id}getValue(){return this.opt_value??null}setRightToLeft(e){this.rightToLeft=e;let t;(t=this.getElement())==null||t.classList.toggle(`blocklyMenuItemRtl`,this.rightToLeft)}setRole(e){this.roleName=e}setCheckable(e){(this.checkable=e)||this.setChecked(!1),this.toggleHasCheckbox(e)}setChecked(e){(!e||this.checkable)&&(this.checked=e,(e=this.getElement())&&(e.classList.toggle(`blocklyMenuItemSelected`,this.checked),en(e,ju.SELECTED,this.checked)))}setHighlighted(e){if(this.highlight=e,this.isEnabled()){let e;(e=this.getElement())==null||e.classList.toggle(`blocklyMenuItemHighlight`,this.highlight)}}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e,(e=this.getElement())&&(e.classList.toggle(`blocklyMenuItemDisabled`,!this.enabled),en(e,ju.DISABLED,!this.enabled))}performAction(e){this.isEnabled()&&this.actionHandler&&this.actionHandler(this,e)}onAction(e,t){this.actionHandler=e.bind(t)}toggleHasCheckbox(e){if(e){let r;if((r=this.getElement())==null||!r.querySelector(`.blocklyMenuItemContent .blocklyMenuItemCheckbox`)){e=document.createElement(`div`),e.className=`blocklyMenuItemCheckbox `;var t,n;(t=this.getElement())==null||(n=t.querySelector(`.blocklyMenuItemContent`))==null||n.prepend(e)}}else{let e,t;(e=this.getElement())==null||(t=e.querySelector(`.blocklyMenuItemContent .blocklyMenuItemCheckbox`))==null||t.remove()}}},Pu={};Pu.MenuItem=Nu;var Fu=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){let t=document.createElement(`div`);t.className=`blocklyMenu`,t.tabIndex=0,this.roleName&&$t(t,this.roleName),this.element=t;for(let e=0,n;n=this.menuItems[e];e++)t.appendChild(n.createDom());return this.pointerMoveHandler=g(t,`pointermove`,this,this.handlePointerMove,!0),this.clickHandler=g(t,`pointerup`,this,this.handleClick,!0),this.pointerEnterHandler=g(t,`pointerenter`,this,this.handlePointerEnter,!0),this.pointerLeaveHandler=g(t,`pointerleave`,this,this.handlePointerLeave,!0),this.onKeyDownHandler=g(t,`keydown`,this,this.handleKeyEvent),e.appendChild(t),t}getElement(){return this.element}focus(){let e=this.getElement();e&&e.focus({preventScroll:!0})}blur(){let e=this.getElement();e&&e.blur()}setRole(e){this.roleName=e}dispose(){this.pointerMoveHandler&&(v(this.pointerMoveHandler),this.pointerMoveHandler=null),this.clickHandler&&(v(this.clickHandler),this.clickHandler=null),this.pointerEnterHandler&&(v(this.pointerEnterHandler),this.pointerEnterHandler=null),this.pointerLeaveHandler&&(v(this.pointerLeaveHandler),this.pointerLeaveHandler=null),this.onKeyDownHandler&&(v(this.onKeyDownHandler),this.onKeyDownHandler=null);for(let e=0,t;t=this.menuItems[e];e++)t.dispose();this.element=null}getMenuItem(e){let t=this.getElement();for(;e&&e!==t;){if(e.classList.contains(`blocklyMenuItem`)){let t=this.getMenuItems();for(let n=0,r;r=t[n];n++)if(r.getElement()===e)return r}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();let n=e.getElement();t&&n&&(xt(n,t),en(t,ju.ACTIVEDESCENDANT,e.getId()))}}highlightNext(){let e=this.highlightedItem?this.getMenuItems().indexOf(this.highlightedItem):-1;this.highlightHelper(e,1)}highlightPrevious(){let e=this.highlightedItem?this.getMenuItems().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 n,r=this.getMenuItems();for(;n=r[e];){if(n.isEnabled()){this.setHighlighted(n);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`){let n=new I(e.clientX,e.clientY);if(I.distance(t,n)<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(){let e=this.getElement(),t=mt(e);return t.height=e.scrollHeight,t}getMenuItems(){return this.menuItems.filter(e=>e instanceof Nu)}},Iu={};Iu.Menu=Fu;var Lu=class{constructor(){this.element=null}createDom(){return this.element=document.createElement(`hr`),this.element.className=`blocklyMenuSeparator`,$t(this.element,Au.SEPARATOR),this.element}dispose(){let e;(e=this.element)==null||e.remove(),this.element=null}},Ru={};Ru.MenuSeparator=Lu;var zu=`_TEMP_COLLAPSED_INPUT`,Bu=`_TEMP_COLLAPSED_FIELD`,Vu=`MANUALLY_DISABLED`,Hu={COLLAPSED_FIELD_NAME:Bu,COLLAPSED_INPUT_NAME:zu,MANUALLY_DISABLED:Vu};(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`})(e.inputTypes$$module$build$src$core$inputs$input_types||(e.inputTypes$$module$build$src$core$inputs$input_types={}));var Uu={};Uu.inputTypes=e.inputTypes$$module$build$src$core$inputs$input_types;var Wu={};Wu.isSerializable=tn;var V=new Set,Gu=new WeakSet,Ku=new WeakMap,qu=null,Ju=null,Yu=0,H={};H.finishQueuedRenders=rn,H.queueRender=nn,H.triggerQueuedRenders=an;var Xu,Zu;e.Msg$$module$build$src$core$msg=Object.create(null),Xu=function(t){Object.keys(t).forEach(function(n){e.Msg$$module$build$src$core$msg[n]=t[n]})},Zu={Msg:e.Msg$$module$build$src$core$msg,setLocale:Xu};var Qu=`blocklyToast`,$u=`blocklyToastMessage`,ed=`blocklyToastCloseButton`,td=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);let n=this.createDom(e,t);requestAnimationFrame(()=>{n.style.bottom=`2rem`})}static createDom(t,n){let{message:r,duration:i=5,assertiveness:a=td.Assertiveness.POLITE}=n,o=document.createElement(`div`);t.getInjectionDiv().appendChild(o),o.dataset.toastId=n.id,o.className=Qu,$t(o,Au.STATUS),en(o,ju.LIVE,a),n=o.appendChild(document.createElement(`div`)),n.className=$u,n.innerText=r,n=o.appendChild(document.createElement(`button`)),n.className=ed,en(n,ju.LABEL,e.Msg$$module$build$src$core$msg.CLOSE);var s=D(L.SVG,{width:24,height:24,viewBox:`0 0 24 24`,fill:`none`},n);en(s,ju.HIDDEN,!0),D(L.RECT,{x:19.7782,y:2.80762,width:2,height:24,transform:`rotate(45, 19.7782, 2.80762)`,fill:`black`},s),D(L.RECT,{x:2.80762,y:4.22183,width:2,height:24,transform:`rotate(-45, 2.80762, 4.22183)`,fill:`black`},s),n.addEventListener(`click`,()=>{o.remove(),t.markFocused()});let c;return n=()=>{c=setTimeout(()=>o.remove(),i*1e3)},s=()=>clearTimeout(c),o.addEventListener(`focusin`,s),o.addEventListener(`focusout`,n),o.addEventListener(`mouseenter`,s),o.addEventListener(`mousemove`,s),o.addEventListener(`mouseleave`,n),n(),o}static hide(e,t){e=e.getInjectionDiv().querySelector(`.${Qu}`),e instanceof HTMLElement&&(!t||t===e.dataset.toastId)&&e.remove()}};td.shownIds=new Set,(function(e){e=e.Assertiveness||(e.Assertiveness={}),e.ASSERTIVE=`assertive`,e.POLITE=`polite`})(td||(td={})),ft(`
|
|
472
|
+
.${Qu} {
|
|
473
|
+
font-size: 1.2rem;
|
|
474
|
+
position: absolute;
|
|
475
|
+
bottom: -10rem;
|
|
476
|
+
right: 2rem;
|
|
477
|
+
padding: 1rem;
|
|
478
|
+
color: black;
|
|
479
|
+
background-color: white;
|
|
480
|
+
border: 2px solid black;
|
|
481
|
+
border-radius: 0.4rem;
|
|
482
|
+
z-index: 999;
|
|
483
|
+
display: flex;
|
|
484
|
+
align-items: center;
|
|
485
|
+
gap: 0.8rem;
|
|
486
|
+
line-height: 1.5;
|
|
487
|
+
transition: bottom 0.3s ease-out;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
.${Qu} .${$u} {
|
|
491
|
+
maxWidth: 18rem;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
.${Qu} .${ed} {
|
|
495
|
+
margin: 0;
|
|
496
|
+
padding: 0.2rem;
|
|
497
|
+
background-color: transparent;
|
|
498
|
+
color: black;
|
|
499
|
+
border: none;
|
|
500
|
+
cursor: pointer;
|
|
501
|
+
}
|
|
502
|
+
`);var nd={};nd.Toast=td;var rd=function(e,t){window.alert(e),t&&t()},id=rd,ad=function(e,t){t(window.confirm(e))},od=ad,sd=function(e,t,n){n(window.prompt(e,t))},cd=sd,ld=td.show.bind(td),ud=ld,dd={};dd.alert=fn,dd.confirm=mn,dd.prompt=gn,dd.setAlert=pn,dd.setConfirm=hn,dd.setPrompt=_n,dd.setToast=yn,dd.toast=vn;var fd={};fd.isLegacyProcedureCallBlock=xn,fd.isLegacyProcedureDefBlock=bn;var pd={};pd.isVariableBackedParameterModel=Sn;var md=new Set,hd={};hd.warn=Cn;var gd=`VARIABLE`,_d=`ijkmnopqrstuvwxyzabcdefgh`,vd={generateUniqueNameInternal:jn},yd={CATEGORY_NAME:gd,TEST_ONLY:vd,VAR_LETTER_OPTIONS:_d};yd.allDeveloperVariables=e.allDeveloperVariables$$module$build$src$core$variables,yd.allUsedVarModels=e.allUsedVarModels$$module$build$src$core$variables,yd.compareByName=Un,yd.createVariableButtonHandler=Nn,yd.deleteVariable=e.deleteVariable$$module$build$src$core$variables,yd.flyoutCategory=Tn,yd.flyoutCategoryBlocks=kn,yd.generateUniqueName=An,yd.generateUniqueNameFromOptions=Mn,yd.generateVariableFieldDom=Bn,yd.getAddedVariables=Hn,yd.getOrCreateVariablePackage=e.getOrCreateVariablePackage$$module$build$src$core$variables,yd.getVariable=e.getVariable$$module$build$src$core$variables,yd.getVariableUsesById=Wn,yd.internalFlyoutCategory=wn,yd.jsonFlyoutCategoryBlocks=Dn,yd.nameUsedWithAnyType=In,yd.nameUsedWithConflictingParam=Ln,yd.promptName=Pn,yd.renameVariable=e.renameVariable$$module$build$src$core$variables;var bd=class extends Error{},xd=class extends bd{constructor(e){super(`Expected to find a 'type' property, defining the block type`),this.state=e}},Sd=class extends bd{constructor(e,t,n){super(`The block ${t.toDevString()} is missing a(n) ${e}
|
|
503
|
+
connection`),this.block=t,this.state=n}},Cd=class extends bd{constructor(e,t,n,r){super(`The block ${n.toDevString()} could not connect its
|
|
504
|
+
${t} to its parent, because: ${e}`),this.childBlock=n,this.childState=r}},wd=class extends bd{constructor(e){super(`Encountered a real block which is defined as a child of a shadow
|
|
505
|
+
block. It is an invariant of Blockly that shadow blocks only have shadow
|
|
506
|
+
children`),this.state=e}},Td=class extends bd{constructor(e,t,n){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=n}},U={};U.BadConnectionCheck=Cd,U.DeserializationError=bd,U.MissingBlockType=xd,U.MissingConnection=Sd,U.RealChildOfShadow=wd,U.UnregisteredIcon=Td;var Ed=class{constructor(){this.priority=vu}save(e){let t=[];for(let n of e.getTopBlocks(!1))(e=Gn(n,{addCoordinates:!0,doFullSerialization:!1}))&&t.push(e);return t.length?{languageVersion:0,blocks:t}:null}load(e,t){e=e.blocks;for(let n of e)er(n,t,{recordUndo:Te()})}clear(e){for(let t of e.getTopBlocks(!1))t.dispose(!1)}};Gt(`blocks`,new Ed);var W={};W.BlockSerializer=Ed,W.append=er,W.appendInternal=tr,W.save=Gn;var G=class{constructor(e){this.name=e}toString(){return this.name}equals(e){return this.name===e.toString()}};G.MUTATOR=new G(`mutator`),G.WARNING=new G(`warning`),G.COMMENT=new G(`comment`);var Dd={};Dd.IconType=G;var Od={};Od.hasBubble=mr;var K=class extends Tl{constructor(e){super(),this.isBlank=!0,this.isBlank=!e,e&&(this.blockId=e.id,this.workspaceId=e.workspace.id)}toJson(){let 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,n){return t=Tl.fromJson(e,t,n??new K),t.blockId=e.blockId,t}},kd={};kd.BlockBase=K;var Ad=class extends K{constructor(e,t,n,r,i){super(e),this.type=F.BLOCK_CHANGE,e&&(this.element=t,this.name=n||void 0,this.oldValue=r,this.newValue=i)}toJson(){let 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,n){return t=K.fromJson(e,t,n??new Ad),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(t){var n=this.getEventWorkspace_();if(!this.blockId)throw Error(`The block ID is undefined. Either pass a block to the constructor, or call fromJson`);if(n=n.getBlockById(this.blockId),!n)throw Error(`The associated block is undefined. Either pass a block to the constructor, or call fromJson`);let r=n.getIcon(G.MUTATOR);switch(r&&mr(r)&&r.bubbleIsVisible()&&r.setBubbleVisible(!1),t=t?this.newValue:this.oldValue,this.element){case`field`:(n=n.getField(this.name))?n.setValue(t):console.warn(`Can't set non-existent field: `+this.name);break;case`comment`:n.setCommentText(t??null);break;case`collapsed`:n.setCollapsed(!!t);break;case`disabled`:var i;n.setDisabledReason(!!t,(i=this.disabledReason)??Vu);break;case`inline`:n.setInputsInline(!!t);break;case`mutation`:i=Ad.getExtraBlockState_(n),n.loadExtraState?n.loadExtraState(JSON.parse(t||`{}`)):n.domToMutation&&n.domToMutation(e.textToDom$$module$build$src$core$utils$xml(t||`<mutation/>`)),w(new Ad(n,`mutation`,null,i,t));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())?la(e):``}};t(P.EVENT,F.BLOCK_CHANGE,Ad);var jd={};jd.BlockChange=Ad;var Md={};Md.clamp=_r,Md.toDegrees=gr,Md.toRadians=hr;var Nd=16,Pd=1,Fd=12,Id=16,Ld=.25,Rd=null,zd=null,Bd=``,Vd=``,Hd,Ud,Wd,Gd=null,Kd=null,qd=null,Jd=null,Yd=null,Xd={getBoundsInfo:function(){let e=vt(Gd),t=mt(Gd);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,n,r){let i=Xd.getBoundsInfo(),a=mt(Hd);return t+a.height<i.bottom?Ar(e,t,i,a):r-a.height>i.top?jr(n,r,i,a):t+a.height<document.documentElement.clientHeight?Ar(e,t,i,a):r-a.height>document.documentElement.clientTop?jr(n,r,i,a):Mr(e,i,a)}},Zd={ANIMATION_TIME:Ld,ARROW_HORIZONTAL_PADDING:Fd,ARROW_SIZE:Nd,BORDER_SIZE:Pd,PADDING_Y:Id,TEST_ONLY:Xd};Zd.clearContent=Sr,Zd.createDom=vr,Zd.getContentDiv=xr,Zd.getOwner=br,Zd.getPositionX=Nr,Zd.hide=Ir,Zd.hideIfOwner=Fr,Zd.hideWithoutAnimation=Lr,Zd.isVisible=Pr,Zd.repositionForWindowResize=zr,Zd.setBoundsElement=yr,Zd.setColour=Cr,Zd.show=kr,Zd.showPositionedByBlock=wr,Zd.showPositionedByField=Tr;var Qd={};Qd.commonWordPrefix=Vr,Qd.commonWordSuffix=Hr,Qd.isNumber=e.isNumber$$module$build$src$core$utils$string,Qd.shortestStringLength=Br,Qd.wrap=e.wrap$$module$build$src$core$utils$string;var $d=void 0,ef=!1,tf=!1,nf=50,rf=0,af=0,of=0,sf=0,cf=null,lf=null,uf=0,df=10,ff=10,pf=750,mf=5,q=null,hf={HOVER_MS:pf,LIMIT:nf,MARGINS:mf,OFFSET_X:uf,OFFSET_Y:df,RADIUS_OK:ff};hf.bindMouseEvents=ei,hf.block=si,hf.createDom=$r,hf.dispose=ai,hf.getCustomTooltip=Jr,hf.getDiv=Xr,hf.getTooltipOfObject=Zr,hf.hide=oi,hf.isVisible=Yr,hf.setCustomTooltip=qr,hf.unbindMouseEvents=ti,hf.unblock=ci;var gf=.45,_f=.65,vf={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`},yf={};yf.blend=xi,yf.getHsvSaturation=pi,yf.getHsvValue=hi,yf.hexToRgb=yi,yf.hsvToHex=bi,yf.hueToHex=Si,yf.names=vf,yf.parse=_i,yf.rgbToHex=vi,yf.setHsvSaturation=mi,yf.setHsvValue=gi;var bf={};bf.checkMessageReferences=Ei,bf.parseBlockColour=Di,bf.replaceMessageReferences=Ti,bf.tokenizeInterpolation=wi;var xf=class{get size_(){return this.size}set size_(e){this.size=e}constructor(e,t,n){this.DEFAULT_VALUE=null,this.name=void 0,this.tooltip=this.validator_=null,this.size=new z(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 z(0,0),e!==xf.SKIP_SETUP&&(n&&this.configure_(n),this.setValue(e),t&&this.setValidator(t))}configure_(e){e.tooltip&&this.setTooltip(Ti(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_${ne()}`}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_=D(L.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_&&O(this.fieldGroup_,`blocklyField`)}initModel(){}isFullBlockField(){return!this.borderRect_}createBorderRect_(){this.borderRect_=D(L.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_=D(L.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_(){let e=this.getClickTarget_();if(!e)throw Error(`A click target has not been set.`);ei(e),this.mouseDownWrapper=g(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(xf),e===null?this.getValue():e}loadState(e){this.loadLegacyState(xf,e)||this.setValue(e)}saveLegacyState(t){return t.prototype.saveState===this.saveState&&t.prototype.toXml!==this.toXml?(t=e.createElement$$module$build$src$core$utils$xml(`field`),t.setAttribute(`name`,this.name||``),At(this.toXml(t)).replace(` xmlns="https://developers.google.com/blockly/xml"`,``)):null}loadLegacyState(t,n){return t.prototype.loadState===this.loadState&&t.prototype.fromXml!==this.fromXml?(this.fromXml(e.textToDom$$module$build$src$core$utils$xml(n)),!0):!1}dispose(){Fr(this),Pi(this);let e;(e=this.getSourceBlock())!=null&&e.isDeadOrDying()||A(this.fieldGroup_),this.disposed=!0}updateEditable(){let e=this.fieldGroup_,t=this.getSourceBlock();this.EDITABLE&&e&&t&&(this.enabled_&&t.isEditable()?(O(e,`blocklyEditableField`),k(e,`blocklyNonEditableField`)):(O(e,`blocklyNonEditableField`),k(e,`blocklyEditableField`)))}setEnabled(e){this.enabled_=e,this.updateEditable()}isEnabled(){return this.enabled_}isClickable(){return this.enabled_&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()&&this.showEditor_!==xf.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){let t=this.getConstants();e=e===void 0?this.isFullBlockField()?0:this.getConstants().FIELD_BORDER_RECT_X_PADDING:e;let n=e*2,r=t.FIELD_TEXT_HEIGHT,i=0;this.textElement_&&(i=Ve(this.textElement_),n+=i),this.isFullBlockField()||(r=Math.max(r,t.FIELD_BORDER_RECT_HEIGHT)),this.size_=new z(n,r),this.positionTextElement_(e,i),this.positionBorderRect_()}positionTextElement_(e,t){if(this.textElement_){var n=this.getConstants(),r=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(n.FIELD_TEXT_BASELINE_CENTER?r:r-n.FIELD_TEXT_HEIGHT/2+n.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 z(0,0)}getScaledBBox(){let e;var t=this.getSourceBlock();if(!t)throw new Sf;if(this.isFullBlockField()){var n=this.sourceBlock_.getHeightWidth();let r=t.workspace.scale;e=this.getAbsoluteXY_(),t=(n.width+1)*r,n=(n.height+1)*r,jc?(e.x+=1.5*r,e.y+=1.5*r):(e.x-=.5*r,e.y-=.5*r)}else n=this.borderRect_.getBoundingClientRect(),e=vt(this.borderRect_),t=n.width,n=n.height;return new R(e.y,e.y+n,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,xf.NBSP),this.sourceBlock_&&this.sourceBlock_.RTL&&(e+=``),e}getText(){let e=this.getText_();return String(e===null?this.getValue():e)}getText_(){return null}markDirty(){this.isDirty_=!0,this.constants_=null}forceRerender(){this.isDirty_=!0,this.sourceBlock_&&this.sourceBlock_.rendered&&this.sourceBlock_.queueRender()}setValue(t,n=!0){if(t!==null){var r=e.getGroup$$module$build$src$core$events$utils();r||e.setGroup$$module$build$src$core$events$utils(!0);try{let e=this.doClassValidation_(t),r=this.processValidation(t,e,n);if(!(r instanceof Error)){var i=this.getValidator()?.call(this,r),a=this.processValidation(r,i,n);if(!(a instanceof Error)){var o=this.sourceBlock_;if(!o||!o.disposed){var s=this.getValue();s===a?this.doValueUpdate_(a):(this.doValueUpdate_(a),n&&o&&je()&&w(new(E(F.BLOCK_CHANGE))(o,`field`,this.name||null,s,a)),this.isDirty_&&this.forceRerender())}}}}finally{e.setGroup$$module$build$src$core$events$utils(r)}}}processValidation(e,t,n){return t===null?(this.doValueInvalid_(e,n),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_);let t=this.getClickTarget_();t?t.tooltip=e:this.tooltip=e}getTooltip(){let e=this.getClickTarget_();return Zr(e||{tooltip:this.tooltip})}getClickTarget_(){return this.clickTarget_||this.getSvgRoot()}getAbsoluteXY_(){return vt(this.getClickTarget_())}referencesVariables(){return!1}refreshVariableName(){}getParentInput(){let e=null,t=this.getSourceBlock();if(!t)throw new Sf;let n=t.inputList;for(let r=0;r<t.inputList.length;r++){let t=n[r],i=t.fieldRow;for(let n=0;n<i.length;n++)if(i[n]===this){e=t;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(){let e=this.getSourceBlock();if(!e)throw new Sf;return e.workspace}onNodeFocus(){let e=this.getSourceBlock();e.workspace.scrollBoundsIntoView(e.getBoundingRectangleWithoutChildren())}onNodeBlur(){}canBeFocused(){return!0}static fromJson(e){throw Error(`Attempted to instantiate a field from the registry that hasn't defined a 'fromJson' method.`)}};xf.NBSP=`\xA0`,xf.SKIP_SETUP=Symbol(`SKIP_SETUP`);var Sf=class extends Error{constructor(){super(`The field has not yet been attached to its input. Call appendField to attach it.`)}},Cf={};Cf.Field=xf,Cf.UnattachedFieldError=Sf;var wf=null,Tf=null,Ef=null,Df=`blocklyWidgetDiv`,Of=``,kf=``,Af,jf=null,Mf={};Mf.createDom=Ai,Mf.getDiv=Oi,Mf.hide=Mi,Mf.hideIfOwner=Pi,Mf.hideIfOwnerIsInWorkspace=Fi,Mf.isVisible=Ni,Mf.positionWithAnchor=Li,Mf.repositionForWindowResize=Vi,Mf.show=ji,Mf.testOnly_setDiv=ki;var Nf=null,Pf={},Ff=null,If={};If.callbackFactory=e.callbackFactory$$module$build$src$core$contextmenu,If.dispose=Xi,If.getCurrentBlock=Hi,If.getMenu=Zi,If.hide=Yi,If.setCurrentBlock=Ui,If.show=Wi;var J=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){return this.registeredItems.get(e)??null}getContextMenuOptions(e,t){let n=[];for(let r of this.registeredItems.values()){if(r.scopeType&&(r.scopeType===Lf.BLOCK&&!e.block||r.scopeType===Lf.COMMENT&&!e.comment||r.scopeType===Lf.WORKSPACE&&!e.workspace))continue;let i;i={scope:e,weight:r.weight};let a,o=(a=r).preconditionFn?.call(a,e,t);if(o!==`hidden`){if(r.separator)i=Object.assign({},i,{separator:!0});else{let t=typeof r.displayText==`function`?r.displayText(e):r.displayText;i=Object.assign({},i,{text:t,callback:r.callback,enabled:o===`enabled`})}n.push(i)}}return n.sort(function(e,t){return e.weight-t.weight}),n}};(function(e){var t=e.ScopeType||(e.ScopeType={});t.BLOCK=`block`,t.WORKSPACE=`workspace`,t.COMMENT=`comment`,e.registry=new e})(J||(J={}));var Lf=J.ScopeType,Rf={};Rf.ContextMenuRegistry=J,Rf.ScopeType=Lf;var zf=50,Bf=100,Vf={BLOCK:zf,BUBBLE:Bf},Hf=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,zf),this.comment.setDragging(!1),this.comment.snapToGrid(),this.workspace.setResizesEnabled(!0)}fireDragStartEvent(){let e=new(E(F.COMMENT_DRAG))(this.comment,!0);w(e)}fireDragEndEvent(){let e=new(E(F.COMMENT_DRAG))(this.comment,!1);w(e)}fireMoveEvent(){if(!this.comment.isDeadOrDying()){var e=new(E(F.COMMENT_MOVE))(this.comment);e.setReason([`drag`]),e.oldCoordinate_=this.startLoc,e.recordNew(),w(e)}}revertDrag(){this.startLoc&&this.comment.moveDuringDrag(this.startLoc)}},Uf={};Uf.CommentDragStrategy=Hf;var Wf=new WeakMap,Gf={};Gf.move=ea,Gf.start=$i;var Kf=class{constructor(e,t,n,r){this.id=e,this.workspace=t,this.container=n,this.commentView=r}isVisible(){return this.icon.checkVisibility()}getCommentView(){return this.commentView}getSize(e=!1){var t=this.icon.getBBox();return t=R.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(){let e=this.getCommentView();var t=e.getRelativeToSurfaceXY();let n=e.getSize();t=new R(t.y,t.y+n.height,t.x,t.x+n.width),e.workspace.scrollBoundsIntoView(t)}onNodeBlur(){}canBeFocused(){return this.isVisible()}},qf={};qf.CommentBarButton=Kf;var Jf=`_collapse_bar_button`,Yf=class extends Kf{constructor(e,t,n,r){super(e,t,n,r),this.id=e,this.workspace=t,this.container=n,this.commentView=r,this.icon=D(L.IMAGE,{class:`blocklyFoldoutIcon`,href:`${this.workspace.options.pathToMedia}foldout-icon.svg`,id:`${this.id}${Jf}`},this.container),this.bindId=g(this.icon,`pointerdown`,this,this.performAction.bind(this))}dispose(){v(this.bindId)}reposition(){let e=this.getMargin();this.icon.setAttribute(`y`,`${e}`),this.icon.setAttribute(`x`,`${e}`)}performAction(e){f(),this.getCommentView().bringToFront(),e&&e instanceof PointerEvent&&b(e)?e.stopPropagation():(this.getCommentView().setCollapsed(!this.getCommentView().isCollapsed()),this.workspace.hideChaff(),e?.stopPropagation())}},Xf={COMMENT_COLLAPSE_BAR_BUTTON_FOCUS_IDENTIFIER:Jf};Xf.CollapseCommentBarButton=Yf;var Zf=`_comment_textarea_`,Qf=class{constructor(t,n,r){this.workspace=t,this.onFinishEditing=r,this.textChangeListeners=[],this.text=``,this.foreignObject=D(L.FOREIGNOBJECT,{class:`blocklyCommentForeignObject`}),t=document.createElementNS(nl,`body`),t.setAttribute(`xmlns`,nl),t.className=`blocklyMinimalBody`,this.textArea=document.createElementNS(nl,`textarea`),this.textArea.setAttribute(`tabindex`,`-1`),this.textArea.setAttribute(`dir`,this.workspace.RTL?`RTL`:`LTR`),this.textArea.setAttribute(`placeholder`,e.Msg$$module$build$src$core$msg.WORKSPACE_COMMENT_DEFAULT_TEXT),O(this.textArea,`blocklyCommentText`),O(this.textArea,`blocklyTextarea`),O(this.textArea,`blocklyText`),t.appendChild(this.textArea),this.foreignObject.appendChild(t),n&&(this.id=n+Zf,this.textArea.setAttribute(`id`,this.id)),g(this.textArea,`change`,this,this.onTextChange),g(this.textArea,`pointerdown`,this,t=>{t.stopPropagation(),e.getFocusManager$$module$build$src$core$focus_manager().focusNode(this),f()}),g(this.textArea,`wheel`,this,e=>{e.stopPropagation()},!1,{passive:!0}),g(this.textArea,`keydown`,this,this.handleKeyDown)}getDom(){return this.foreignObject}getText(){return this.text}setText(e){this.textArea.value=e,this.onTextChange()}onTextChange(){let 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(){let e=R.from(this.foreignObject.getBoundingClientRect());this.workspace.scrollBoundsIntoView(R.createFromPoint(Dt(this.workspace,e.getOrigin()),e.getWidth(),e.getHeight()))}onNodeBlur(){}canBeFocused(){return!!this.id}},$f={COMMENT_EDITOR_FOCUS_IDENTIFIER:Zf};$f.CommentEditor=Qf;var ep=`_delete_bar_button`,tp=class extends Kf{constructor(e,t,n,r){super(e,t,n,r),this.id=e,this.workspace=t,this.container=n,this.commentView=r,this.icon=D(L.IMAGE,{class:`blocklyDeleteIcon`,href:`${this.workspace.options.pathToMedia}delete-icon.svg`,id:`${this.id}${ep}`},n),this.bindId=g(this.icon,`pointerdown`,this,this.performAction.bind(this))}dispose(){v(this.bindId)}reposition(){let e=this.getMargin();this.icon.setAttribute(`x`,`0`);let t=this.container.getBBox();this.icon.setAttribute(`y`,`${e}`),this.icon.setAttribute(`x`,`${t.width-this.getSize(!0).getWidth()}`)}performAction(t){f(),t&&t instanceof PointerEvent&&b(t)?t.stopPropagation():(this.getCommentView().dispose(),t?.stopPropagation(),e.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.workspace))}},np={COMMENT_DELETE_BAR_BUTTON_FOCUS_IDENTIFIER:ep};np.DeleteCommentBarButton=tp;var rp=class{constructor(e,t){this.workspace=e,this.commentId=t,this.collapsed=!1,this.editable=!0,this.location=new I(0,0),this.sizeChangeListeners=[],this.disposeListeners=[],this.collapseChangeListeners=[],this.resizePointerMoveListener=this.resizePointerUpListener=null,this.disposed=this.disposing=!1,this.svgRoot=D(L.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 n;(n=e.getLayerManager())==null||n.append(this,zf),this.size=rp.defaultCommentSize,this.setSizeWithoutFiringEvents(this.size),this.moveTo(new I(0,0))}createHighlightRect(e){return D(L.RECT,{class:`blocklyCommentHighlight`},e)}createTopBar(e){e=D(L.G,{class:`blocklyCommentTopbar`},e);let t=D(L.RECT,{class:`blocklyCommentTopbarBackground`},e),n=new tp(this.commentId,this.workspace,e,this),r=new Yf(this.commentId,this.workspace,e,this);this.addDisposeListener(()=>{n.dispose(),r.dispose()});let i=D(L.TEXT,{class:`blocklyCommentPreview blocklyCommentText blocklyText`},e),a=document.createTextNode(``);return i.appendChild(a),{topBarGroup:e,topBarBackground:t,deleteButton:n,foldoutButton:r,textPreview:i,textPreviewNode:a}}createTextArea(){let e=new Qf(this.workspace,this.commentId,()=>this.svgRoot.focus());return this.svgRoot.appendChild(e.getDom()),e.addTextChangeListener((e,t)=>{this.updateTextPreview(t),this.setSize(this.size)}),e}getEditorFocusableNode(){return this.commentEditor}createResizeHandle(e,t){return e=D(L.IMAGE,{class:`blocklyResizeHandle`,href:`${t.options.pathToMedia}resize-handle.svg`},e),g(e,`pointerdown`,this,this.onResizePointerDown),e}getSvgRoot(){return this.svgRoot}getSize(){return this.collapsed?this.topBarBackground.getBBox():this.size}setSizeWithoutFiringEvents(e){let t=this.topBarBackground.getBBox(),n=this.textPreview.getBBox(),r=this.resizeHandle.getBBox();this.size=e=z.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,n),this.updateResizeHandlePosition(e,r)}setSize(e){let t=this.preResizeSize||this.size;this.setSizeWithoutFiringEvents(e),this.onSizeChange(t,this.size)}calcMinSize(e){var t;this.updateTextPreview((t=this.commentEditor.getText())??``);let n=t=Ve(this.textPreview);return this.foldoutButton.isVisible()?n+=this.foldoutButton.getSize(!0).getWidth():t&&(n+=4),this.deleteButton.isVisible()?n+=this.deleteButton.getSize(!0).getWidth():t&&(n+=4),new z(n,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,n){t=(t.height-n.height)/2;let r=this.foldoutButton.getSize(!0),i=this.deleteButton.getSize(!0);e=e.width-r.getWidth()-i.getWidth(),this.textPreview.setAttribute(`x`,`${(this.workspace.RTL?-1:1)*r.getWidth()}`),this.textPreview.setAttribute(`y`,`${t+n.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 n=this.sizeChangeListeners.length-1;n>=0;n--)this.sizeChangeListeners[n](e,t)}addSizeChangeListener(e){this.sizeChangeListeners.push(e)}removeSizeChangeListener(e){this.sizeChangeListeners.splice(this.sizeChangeListeners.indexOf(e),1)}onResizePointerDown(e){this.isEditable()&&(this.bringToFront(),b(e)||(this.preResizeSize=this.getSize(),$i(this.workspace,e,new I(this.workspace.RTL?-this.getSize().width:this.getSize().width,this.getSize().height)),this.resizePointerUpListener=g(document,`pointerup`,this,this.onResizePointerUp),this.resizePointerMoveListener=g(document,`pointermove`,this,this.onResizePointerMove),this.workspace.hideChaff()),e.stopPropagation())}onResizePointerUp(e){f(),this.resizePointerUpListener&&(v(this.resizePointerUpListener),this.resizePointerUpListener=null),this.resizePointerMoveListener&&(v(this.resizePointerMoveListener),this.resizePointerMoveListener=null),this.setSize(this.size),this.preResizeSize=void 0}onResizePointerMove(e){e=ea(this.workspace,e),this.setSizeWithoutFiringEvents(new z(this.workspace.RTL?-e.x:e.x,e.y))}isCollapsed(){return this.collapsed}setCollapsed(e){(this.collapsed=e)?O(this.svgRoot,`blocklyCollapsed`):k(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)?(O(this.svgRoot,`blocklyEditable`),k(this.svgRoot,`blocklyReadonly`)):(k(this.svgRoot,`blocklyEditable`),O(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(){let e=this.svgRoot.parentNode,t=e.childNodes;t[t.length-1]!==this.svgRoot&&e.appendChild(this.svgRoot)}onDeleteDown(e){f(),b(e)||this.dispose(),e.stopPropagation()}dispose(){this.disposing=!0,A(this.svgRoot);for(let e=this.disposeListeners.length-1;e>=0;e--)this.disposeListeners[e]();this.disposeListeners.length=0,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]}};rp.defaultCommentSize=new z(120,100),ft(`
|
|
507
|
+
.injectionDiv {
|
|
508
|
+
--commentFillColour: #FFFCC7;
|
|
509
|
+
--commentBorderColour: #F2E49B;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.blocklyComment .blocklyTextarea {
|
|
513
|
+
background-color: var(--commentFillColour);
|
|
514
|
+
border: 1px solid var(--commentBorderColour);
|
|
515
|
+
box-sizing: border-box;
|
|
516
|
+
display: block;
|
|
517
|
+
outline: 0;
|
|
518
|
+
padding: 5px;
|
|
519
|
+
resize: none;
|
|
520
|
+
width: 100%;
|
|
521
|
+
height: 100%;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
.blocklyReadonly.blocklyComment .blocklyTextarea {
|
|
525
|
+
cursor: inherit;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
.blocklyDeleteIcon {
|
|
529
|
+
width: 20px;
|
|
530
|
+
height: 20px;
|
|
531
|
+
display: none;
|
|
532
|
+
cursor: pointer;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.blocklyFoldoutIcon {
|
|
536
|
+
width: 20px;
|
|
537
|
+
height: 20px;
|
|
538
|
+
transform-origin: 12px 12px;
|
|
539
|
+
cursor: pointer;
|
|
540
|
+
}
|
|
541
|
+
.blocklyResizeHandle {
|
|
542
|
+
width: 12px;
|
|
543
|
+
height: 12px;
|
|
544
|
+
cursor: se-resize;
|
|
545
|
+
}
|
|
546
|
+
.blocklyReadonly.blocklyComment .blocklyResizeHandle {
|
|
547
|
+
cursor: inherit;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
.blocklyCommentTopbarBackground {
|
|
551
|
+
fill: var(--commentBorderColour);
|
|
552
|
+
height: 24px;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
.blocklyComment .blocklyCommentPreview.blocklyText {
|
|
556
|
+
fill: #000;
|
|
557
|
+
dominant-baseline: middle;
|
|
558
|
+
visibility: hidden;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
.blocklyCollapsed.blocklyComment .blocklyCommentPreview {
|
|
562
|
+
visibility: visible;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
.blocklyCollapsed.blocklyComment .blocklyCommentForeignObject,
|
|
566
|
+
.blocklyCollapsed.blocklyComment .blocklyResizeHandle {
|
|
567
|
+
display: none;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
.blocklyCollapsed.blocklyComment .blocklyFoldoutIcon {
|
|
571
|
+
transform: rotate(-90deg);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
.blocklyRTL .blocklyCommentTopbar {
|
|
575
|
+
transform: scale(-1, 1);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
.blocklyRTL .blocklyCommentForeignObject {
|
|
579
|
+
direction: rtl;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
.blocklyRTL .blocklyCommentPreview {
|
|
583
|
+
/* Revert the scale and control RTL using direction instead. */
|
|
584
|
+
transform: scale(-1, 1);
|
|
585
|
+
direction: rtl;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
.blocklyRTL .blocklyResizeHandle {
|
|
589
|
+
transform: scale(-1, 1);
|
|
590
|
+
cursor: sw-resize;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
.blocklyCommentHighlight {
|
|
594
|
+
fill: none;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
.blocklyCommentText.blocklyActiveFocus {
|
|
598
|
+
border-color: #fc3;
|
|
599
|
+
border-width: 2px;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
.blocklySelected .blocklyCommentHighlight {
|
|
603
|
+
stroke: #fc3;
|
|
604
|
+
stroke-width: 3px;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.blocklyCollapsed.blocklySelected .blocklyCommentHighlight {
|
|
608
|
+
stroke: none;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
.blocklyCollapsed.blocklySelected .blocklyCommentTopbarBackground {
|
|
612
|
+
stroke: #fc3;
|
|
613
|
+
stroke-width: 3px;
|
|
614
|
+
}
|
|
615
|
+
`);var ip={};ip.CommentView=rp;var ap=class{constructor(e,t){this.workspace=e,this.text=``,this.collapsed=!1,this.deletable=this.movable=this.editable=!0,this.location=new I(0,0),this.disposing=this.disposed=!1,this.id=t&&!e.getCommentById(t)?t:re(),this.size=rp.defaultCommentSize,e.addTopComment(this),this.fireCreateEvent()}fireCreateEvent(){je()&&w(new(E(F.COMMENT_CREATE))(this))}fireDeleteEvent(){je()&&w(new(E(F.COMMENT_DELETE))(this))}fireChangeEvent(e,t){je()&&w(new(E(F.COMMENT_CHANGE))(this,e,t))}fireCollapseEvent(e){je()&&w(new(E(F.COMMENT_COLLAPSE))(this,e))}setText(e){let t=this.text;this.text=e,this.fireChangeEvent(t,e)}getText(){return this.text}setSize(e){let t=new(E(F.COMMENT_RESIZE))(this);this.size=e,t.recordCurrentSizeAsNewSize(),w(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){let n=new(E(F.COMMENT_MOVE))(this);t&&n.setReason(t),this.location=e,n.recordNew(),w(n)}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}},op={};op.WorkspaceComment=ap;var sp=class extends ap{constructor(e,t){super(e,t),this.dragStrategy=new Hf(this),this.workspace=e,this.view=new rp(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(),g(this.view.getSvgRoot(),`pointerdown`,this,this.startGesture)}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(){let e=this.getRelativeToSurfaceXY();var t,n;let r=(n=(t=this.view)?.getSize())??this.getSize();return this.workspace.RTL?(t=e.x-r.width,n=e.x):(t=e.x,n=e.x+r.width),new R(e.y,e.y+r.height,t,n)}moveBy(e,t,n){let r=this.getRelativeToSurfaceXY();e=new I(r.x+e,r.y+t),this.moveTo(e,n)}moveTo(e,t){super.moveTo(e,t),this.view.moveTo(e)}moveDuringDrag(e){this.location=e,this.view.moveTo(e)}setDragging(e){e?O(this.getSvgRoot(),`blocklyDragging`):k(this.getSvgRoot(),`blocklyDragging`)}dispose(){this.disposing=!0;let t=e.getFocusManager$$module$build$src$core$focus_manager();t.getFocusedNode()===this&&setTimeout(()=>t.focusTree(this.workspace),0),this.view.isDeadOrDying()||this.view.dispose(),super.dispose()}startGesture(t){let n=this.workspace.getGesture(t);n&&(n.handleCommentStart(t,this),e.getFocusManager$$module$build$src$core$focus_manager().focusNode(this))}setDeleteStyle(e){e?O(this.getSvgRoot(),`blocklyDraggingDelete`):k(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(){O(this.getSvgRoot(),`blocklySelected`),nt(this)}unselect(){k(this.getSvgRoot(),`blocklySelected`),nt(null)}toCopyData(){return{paster:Tu.TYPE,commentState:qt(this,{addCoordinates:!0,saveIds:!1})}}showContextMenu(e){let t=J.registry.getContextMenuOptions({comment:this,focusedNode:this},e),n;n=e instanceof PointerEvent?new I(e.clientX,e.clientY):Ot(this.workspace,this.getRelativeToSurfaceXY()).translate(10,10),Wi(e,t,this.workspace.RTL,this.workspace,n)}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.getSvgRoot().parentElement)==null||e.appendChild(this.getSvgRoot()),this.workspace.scrollBoundsIntoView(this.getBoundingRectangle())}onNodeBlur(){this.unselect()}canBeFocused(){return!0}},cp={};cp.RenderedWorkspaceComment=sp;var lp={};lp.appendDomToWorkspace=pa,lp.blockToDom=sa,lp.blockToDomWithXY=ia,lp.clearWorkspaceAndLoadFromXml=da,lp.deleteNext=Ea,lp.domToBlock=e.domToBlock$$module$build$src$core$xml,lp.domToBlockInternal=ma,lp.domToPrettyText=ua,lp.domToText=la,lp.domToVariables=ha,lp.domToWorkspace=e.domToWorkspace$$module$build$src$core$xml,lp.loadWorkspaceComment=fa,lp.saveWorkspaceComment=na,lp.variablesToDom=ra,lp.workspaceToDom=ta;var up=class extends K{constructor(e){super(e),this.type=F.BLOCK_CREATE,e&&(e.isShadow()&&(this.recordUndo=!1),this.xml=ia(e),this.ids=Ne(e),this.json=Gn(e,{addCoordinates:!0}))}toJson(){let 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=la(this.xml),e.ids=this.ids,e.json=this.json,this.recordUndo||(e.recordUndo=this.recordUndo),e}static fromJson(t,n,r){return n=K.fromJson(t,n,r??new up),n.xml=e.textToDom$$module$build$src$core$utils$xml(t.xml),n.ids=t.ids,n.json=t.json,t.recordUndo!==void 0&&(n.recordUndo=t.recordUndo),n}run(e){let 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(!dp(t,this.ids))if(e)er(this.json,t);else for(e=0;e<this.ids.length;e++){let n=this.ids[e],r=t.getBlockById(n);r?r.dispose(!1):n===this.blockId&&console.warn(`Can't uncreate non-existent block: `+n)}}},dp=function(e,t){return t.map(t=>e.getBlockById(t)).filter(e=>e&&e.isShadow()).length===t.length};t(P.EVENT,F.BLOCK_CREATE,up);var fp={};fp.BlockCreate=up;var pp=class extends Dl{constructor(e,t){super(t),this.type=F.THEME_CHANGE,this.themeName=e}toJson(){let 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,n){return t=Dl.fromJson(e,t,n??new pp),t.themeName=e.themeName,t}};t(P.EVENT,F.THEME_CHANGE,pp);var mp={};mp.ThemeChange=pp;var hp=class extends Dl{constructor(e,t,n,r,i){super(r),this.type=F.VIEWPORT_CHANGE,this.viewTop=e,this.viewLeft=t,this.scale=n,this.oldScale=i}toJson(){let 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,n){return t=Dl.fromJson(e,t,n??new hp),t.viewTop=e.viewTop,t.viewLeft=e.viewLeft,t.scale=e.scale,t.oldScale=e.oldScale,t}};t(P.EVENT,F.VIEWPORT_CHANGE,hp);var gp={};gp.ViewportChange=hp;var _p={fromJsonInternal:Aa},vp={TEST_ONLY:_p};vp.fromJson=e.fromJson$$module$build$src$core$field_registry,vp.register=Oa,vp.unregister=ka;var yp=class extends xf{constructor(e,t,n){super(xf.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!==xf.SKIP_SETUP&&(this.setOptions(e),n&&this.configure_(n),t&&this.setValidator(t))}fromXml(e){this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e.textContent)}loadState(e){this.loadLegacyState(yp,e)||(this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e))}initView(){this.shouldAddBorderRect_()?this.createBorderRect_():this.clickTarget_=this.sourceBlock_.getSvgRoot(),this.createTextElement_(),this.imageElement=D(L.IMAGE,{},this.fieldGroup_),this.getConstants().FIELD_DROPDOWN_SVG_ARROW?this.createSVGArrow_():this.createTextArrow_(),this.borderRect_&&O(this.borderRect_,`blocklyDropdownRect`),this.fieldGroup_&&(O(this.fieldGroup_,`blocklyField`),O(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=D(L.TSPAN,{},this.textElement_);let e;this.arrow.appendChild(document.createTextNode((e=this.getSourceBlock())!=null&&e.RTL?yp.ARROW_CHAR+` `:` `+yp.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=D(L.IMAGE,{height:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+`px`,width:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+`px`},this.fieldGroup_),this.svgArrow.setAttributeNS(rl,`xlink:href`,this.getConstants().FIELD_DROPDOWN_SVG_ARROW_DATAURI)}showEditor_(e){var t=this.getSourceBlock();if(!t)throw new Sf;this.dropdownCreate(),this.menu_&&(this.menu_.openingCoords=e&&typeof e.clientX==`number`?new I(e.clientX,e.clientY):null,Sr(),e=this.menu_.render(xr()),O(e,`blocklyDropdownMenu`),this.getConstants().FIELD_DROPDOWN_COLOURED_DIV&&(t=t.getColour(),e=this.sourceBlock_.getColourTertiary(),Cr(t,e)),Tr(this,this.dropdownDispose_.bind(this)),xr().style.height=`${this.menu_.getSize().height}px`,this.menu_.focus(),this.selectedMenuItem&&this.menu_.setHighlighted(this.selectedMenuItem),this.applyColour())}dropdownCreate(){let e=this.getSourceBlock();if(!e)throw new Sf;let t=new Fu;t.setRole(Au.LISTBOX),this.menu_=t;let n=this.getOptions(!1);this.selectedMenuItem=null;for(let i=0;i<n.length;i++){var r=n[i];if(r===yp.SEPARATOR){t.addChild(new Lu);continue}let[a,o]=r;ja(a)?(r=new Image(a.width,a.height),r.src=a.src,r.alt=a.alt):r=a,r=new Nu(r,o),r.setRole(Au.OPTION),r.setRightToLeft(e.RTL),r.setCheckable(!0),t.addChild(r),r.setChecked(o===this.value_),o===this.value_&&(this.selectedMenuItem=r),r.onAction(this.handleMenuActionEvent,this)}}dropdownDispose_(){this.menu_&&this.menu_.dispose(),this.selectedMenuItem=this.menu_=null,this.applyColour()}handleMenuActionEvent(e){Fr(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,n;n=e[t];t++)n[1]===this.value_&&(this.selectedOption=n)}applyColour(){let 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`;let e=this.selectedOption&&this.selectedOption[0];ja(e)?this.renderSelectedImage(e):this.renderSelectedText(),this.positionBorderRect_()}renderSelectedImage(e){let t=this.getSourceBlock();if(!t)throw new Sf;this.imageElement.style.display=``,this.imageElement.setAttributeNS(rl,`xlink:href`,e.src),this.imageElement.setAttribute(`height`,String(e.height)),this.imageElement.setAttribute(`width`,String(e.width));let n=Number(e.height);e=Number(e.width);var r=!!this.borderRect_;let i=Math.max(r?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,n+yp.IMAGE_Y_PADDING);r=r?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;let a;a=this.svgArrow?this.positionSVGArrow(e+r,i/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2):Ve(this.arrow),this.size_=new z(e+a+r*2,i);let o=0;t.RTL?this.imageElement.setAttribute(`x`,`${r+a}`):(o=e+a,this.getTextElement().setAttribute(`text-anchor`,`end`),this.imageElement.setAttribute(`x`,`${r}`)),this.imageElement.setAttribute(`y`,String(i/2-n/2)),this.positionTextElement_(o+r,e+a)}renderSelectedText(){this.getTextContent().nodeValue=this.getDisplayText_();var e=this.getTextElement();O(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);let n=Ve(this.getTextElement());t=t?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;let r=0;this.svgArrow&&(r=this.positionSVGArrow(n+t,e/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2)),this.size_=new z(n+r+t*2,e),this.positionTextElement_(t,n)}positionSVGArrow(e,t){if(!this.svgArrow)return 0;let n=this.getSourceBlock();if(!n)throw new Sf;let r=this.borderRect_?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0,i=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_PADDING,a=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE;return this.svgArrow.setAttribute(`transform`,`translate(`+(n.RTL?r:e+i)+`,`+t+`)`),a+i}getText_(){if(!this.selectedOption)return null;let e=this.selectedOption[0];return ja(e)?e.alt:typeof HTMLElement<`u`&&e instanceof HTMLElement?e.title??e.ariaLabel??e.innerText: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,n=e.map(e=>{if(e===yp.SEPARATOR)return t=!0,e;let[n,r]=e;return typeof n==`string`?[Ti(n),r]:(t=!0,[ja(n)?Object.assign({},n,{alt:Ti(n.alt)}):n,r])});if(t||e.length<2)return{options:n};var r=n.map(([e])=>e),i=Br(r);e=Vr(r,i);let a=Hr(r,i);return!e&&!a||i<=e+a?{options:n}:(i=e?r[0].substring(0,e-1):void 0,r=a?r[0].substr(1-a):void 0,{options:this.applyTrim(n,e,a),prefix:i,suffix:r})}applyTrim(e,t,n){return e.map(([e,r])=>[e.substring(t,e.length-n),r])}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 n=0;n<e.length;n++){let r=e[n];Array.isArray(r)||r===yp.SEPARATOR?typeof r[1]==`string`?!r[0]||typeof r[0]==`string`||ja(r[0])||typeof HTMLElement<`u`&&r[0]instanceof HTMLElement||(t=!0,console.error(`Invalid option[${n}]: Each FieldDropdown option must have a string
|
|
616
|
+
label, image description, or HTML element. Found ${r[0]} in: ${r}`)):(t=!0,console.error(`Invalid option[${n}]: Each FieldDropdown option id must be a string.
|
|
617
|
+
Found ${r[1]} in: ${r}`)):(t=!0,console.error(`Invalid option[${n}]: Each FieldDropdown option must be an array or
|
|
618
|
+
the string literal 'separator'. Found: ${r}`))}if(t)throw TypeError(`Found invalid FieldDropdown options.`)}};yp.SEPARATOR=`separator`,yp.ARROW_CHAR=`▾`,yp.IMAGE_Y_OFFSET=5,yp.IMAGE_Y_PADDING=yp.IMAGE_Y_OFFSET*2,Oa(`field_dropdown`,yp);var bp={};bp.FieldDropdown=yp;var xp=class{constructor(e,n,r,i){this.name=e,this.startHats=!1,this.blockStyles=n||Object.create(null),this.categoryStyles=r||Object.create(null),this.componentStyles=i||Object.create(null),this.fontStyle=Object.create(null),t(P.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`){let 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();let n=new xp(e),r=t.base;return r&&(typeof r==`string`&&(r=s(P.THEME,r)??void 0),r instanceof xp&&(qe(n,r),n.name=e)),qe(n.blockStyles,t.blockStyles),qe(n.categoryStyles,t.categoryStyles),qe(n.componentStyles,t.componentStyles),qe(n.fontStyle,t.fontStyle),t.startHats!==null&&(n.startHats=t.startHats),n}},Sp={};Sp.Theme=xp;var Cp=new xp(`classic`,{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`}},{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`}}),wp=class{constructor(e){this.gridPattern=null,this.getMetrics=this.setMetrics=void 0;let t=null,n=!1;var r=!1,i=!1,a=!1,o=!1,s=!1;let c=!!e.readOnly;if(!c){var l;t=Mt((l=e.toolbox)??null),n=Ft(t),r=e.trashcan,r=r===void 0?n:r,i=e.collapse,i=i===void 0?n:i,a=e.comments,a=a===void 0?n:a,o=e.disable,o=o===void 0?n:o,s=e.sounds,s=s===void 0?!0:s}l=e.maxTrashcanContents,r?l===void 0&&(l=32):l=0;let u=!!e.rtl,d=e.horizontalLayout;d===void 0&&(d=!1);var f=e.toolboxPosition!==`end`;f=d?f?B.TOP:B.BOTTOM:f===u?B.RIGHT:B.LEFT;let p=e.css;p===void 0&&(p=!0);let m=`https://blockly-demo.appspot.com/static/media/`;e.media&&(m=e.media.endsWith(`/`)?e.media:e.media+`/`);let h=e.oneBasedIndex,g=e.renderer||`geras`,_=e.plugins||{},v=e.modalInputs;v===void 0&&(v=!0),this.RTL=u,this.oneBasedIndex=h===void 0?!0:h,this.collapse=i,this.comments=a,this.disable=o,this.readOnly=c,this.maxBlocks=e.maxBlocks||1/0,this.maxInstances=e.maxInstances??null,this.modalInputs=v,this.pathToMedia=m,this.hasCategories=n,this.moveOptions=wp.parseMoveOptions(e,n),this.hasScrollbars=!!this.moveOptions.scrollbars,this.hasTrashcan=r,this.maxTrashcanContents=l,this.hasSounds=s,this.hasCss=p,this.horizontalLayout=d,this.languageTree=t,this.gridOptions=wp.parseGridOptions(e),this.zoomOptions=wp.parseZoomOptions(e),this.toolboxPosition=f,this.theme=wp.parseThemeOptions(e),this.renderer=g,this.rendererOverrides=e.rendererOverrides??null,this.parentWorkspace=e.parentWorkspace??null,this.plugins=_}static parseMoveOptions(e,t){let n=e.move||{},r={};return n.scrollbars===void 0&&e.scrollbars===void 0?r.scrollbars=t:typeof n.scrollbars==`object`?(r.scrollbars={horizontal:!!n.scrollbars.horizontal,vertical:!!n.scrollbars.vertical},r.scrollbars.horizontal&&r.scrollbars.vertical?r.scrollbars=!0:r.scrollbars.horizontal||r.scrollbars.vertical||(r.scrollbars=!1)):r.scrollbars=!!n.scrollbars||!!e.scrollbars,r.wheel=r.scrollbars&&n.wheel!==void 0?!!n.wheel:typeof r.scrollbars==`object`,r.drag=r.scrollbars?n.drag===void 0?!0:!!n.drag:!1,r}static parseZoomOptions(e){e=e.zoom||{};let 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||{};let 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||Cp,typeof e==`string`?s(P.THEME,e):e instanceof xp?e:xp.defineTheme(e.name||`builtin`+ne(),e)}},Tp={};Tp.Options=wp;var Ep=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,Bf),this.bubble.setDragging(!1)}revertDrag(){this.startLoc&&this.bubble.moveDuringDrag(this.startLoc)}},Dp={};Dp.BubbleDragStrategy=Ep;var Op,kp=class{constructor(e,t,n,r,i){this.workspace=e,this.anchor=t,this.ownerRect=n,this.owner=i,this.size=new z(0,0),this.colour=`#ffffff`,this.disposed=!1,this.relativeLeft=this.relativeTop=0,this.dragStrategy=new Ep(this,this.workspace),this.id=ne(),this.svgRoot=D(L.G,{class:`blocklyBubble`},e.getBubbleCanvas()),e=D(L.G,{class:`blocklyEmboss`},this.svgRoot),this.tail=D(L.PATH,{class:`blocklyBubbleTail`},e),this.background=D(L.RECT,{class:`blocklyDraggable`,x:0,y:0,rx:Op.BORDER_WIDTH,ry:Op.BORDER_WIDTH},e),this.contentContainer=D(L.G,{},this.svgRoot),this.focusableElement=r??this.svgRoot,this.focusableElement.setAttribute(`id`,this.id),g(this.background,`pointerdown`,this,this.onMouseDown),g(this.focusableElement,`keydown`,this,this.onKeyDown)}dispose(){A(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,Op.MIN_SIZE),e.height=Math.max(e.height,Op.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(t){let n;(n=this.workspace.getGesture(t))==null||n.handleBubbleStart(t,this),e.getFocusManager$$module$build$src$core$focus_manager().focusNode(this)}onKeyDown(t){t.key===`Escape`&&this.owner&&(this.owner.setBubbleVisible(!1),e.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.owner))}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 R(0,0,0,0)){var t=this.workspace.getMetricsManager().getViewMetrics(!0),n=this.getOptimalRelativeLeft(t),r=this.getOptimalRelativeTop(t);let i={x:n,y:-this.size.height-this.workspace.getRenderer().getConstants().MIN_BLOCK_HEIGHT},a={x:-this.size.width-30,y:r};r={x:e.getWidth(),y:r};var o={x:n,y:e.getHeight()};n=e.getWidth()<e.getHeight()?r:o,e=e.getWidth()<e.getHeight()?o:r,r=this.getOverlap(i,t),o=this.getOverlap(a,t);let s=this.getOverlap(n,t);t=this.getOverlap(e,t),t=Math.max(r,o,s,t),r===t?(this.relativeLeft=i.x,this.relativeTop=i.y):o===t?(this.relativeLeft=a.x,this.relativeTop=a.y):s===t?(this.relativeLeft=n.x,this.relativeTop=n.y):(this.relativeLeft=e.x,this.relativeTop=e.y),this.positionRelativeToAnchor()}getOverlap(e,t){var n=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(n+this.size.width,t.left+t.width)-Math.max(n,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 n=this.anchor.x-t;n-this.size.width<e.left?t=-(e.left-this.anchor.x+this.size.width):n>e.right&&(t=-(e.right-this.anchor.x))}else{n=t+this.anchor.x;let r=n+this.size.width;n<e.left?t=e.left-this.anchor.x:r>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;let n=this.anchor.y+t,r=n+this.size.height;return e=this.getWorkspaceViewRect(e),n<e.top?t=e.top-this.anchor.y:r>e.bottom&&(t=e.bottom-this.anchor.y-this.size.height),t}getWorkspaceViewRect(e){let t=e.top,n=e.top+e.height,r=e.left;return e=e.left+e.width,n-=this.getScrollbarThickness(),this.workspace.RTL?r-=this.getScrollbarThickness():e-=this.getScrollbarThickness(),new R(t,n,r,e)}getScrollbarThickness(){return Yl.scrollbarThickness/this.workspace.scale}renderTail(){let e=[];var t=this.size.width/2,n=this.size.height/2,r=-this.relativeLeft,i=-this.relativeTop;if(t===r&&n===i)e.push(`M `+t+`,`+n);else{i-=n,r-=t,this.workspace.RTL&&(r*=-1);var a=Math.sqrt(i*i+r*r),o=Math.acos(r/a);i<0&&(o=2*Math.PI-o);var s=o+Math.PI/2;s>Math.PI*2&&(s-=Math.PI*2);var c=Math.sin(s);let l=Math.cos(s),u=(this.size.width+this.size.height)/Op.TAIL_THICKNESS;u=Math.min(u,this.size.width,this.size.height)/4,s=1-Op.ANCHOR_RADIUS/a,r=t+s*r,i=n+s*i,s=t+u*l;let d=n+u*c;t-=u*l,n-=u*c,c=hr(this.workspace.RTL?-Op.TAIL_ANGLE:Op.TAIL_ANGLE),c=o+c,c>Math.PI*2&&(c-=Math.PI*2),o=Math.sin(c)*a/Op.TAIL_BEND,a=Math.cos(c)*a/Op.TAIL_BEND,e.push(`M`+s+`,`+d),e.push(`C`+(s+a)+`,`+(d+o)+` `+r+`,`+i+` `+r+`,`+i),e.push(`C`+r+`,`+i+` `+(t+a)+`,`+(n+o)+` `+t+`,`+n)}e.push(`z`);let l;(l=this.tail)==null||l.setAttribute(`d`,e.join(` `))}bringToFront(){let e=this.svgRoot?.parentNode;return this.svgRoot&&e?.lastChild!==this.svgRoot?(e?.appendChild(this.svgRoot),!0):!1}getRelativeToSurfaceXY(){return new I(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(){nt(this)}unselect(){nt(null)}getFocusableElement(){return this.focusableElement}getFocusableTree(){return this.workspace}onNodeFocus(){this.select(),this.bringToFront();var e=this.getRelativeToSurfaceXY();let t=this.getSize();e=new R(e.y,e.y+t.height,e.x,e.x+t.width),this.workspace.scrollBoundsIntoView(e)}onNodeBlur(){this.unselect()}canBeFocused(){return!0}getOwner(){return this.owner}};Op=kp,kp.BORDER_WIDTH=6,kp.DOUBLE_BORDER=Op.BORDER_WIDTH*2,kp.MIN_SIZE=Op.DOUBLE_BORDER,kp.TAIL_THICKNESS=1,kp.TAIL_ANGLE=20,kp.TAIL_BEND=4,kp.ANCHOR_RADIUS=8;var Ap={};Ap.Bubble=kp;var jp=class extends kp{constructor(e,t,n,r){super(t,n,r),this.workspace=t,this.anchor=n,this.ownerRect=r,this.autoLayout=!0,t=new wp(e),this.validateWorkspaceOptions(t),this.svgDialog=D(L.SVG,{x:kp.BORDER_WIDTH,y:kp.BORDER_WIDTH},this.contentContainer),e.parentWorkspace=this.workspace,this.miniWorkspace=this.newWorkspaceSvg(new wp(e)),this.miniWorkspace.internalIsMutator=!0,e=this.miniWorkspace.createDom(`blocklyMutatorBackground`),this.svgDialog.appendChild(e),t.languageTree&&(e.insertBefore(this.miniWorkspace.addFlyout(L.G),this.miniWorkspace.getCanvas()),e=this.miniWorkspace.getFlyout(),e?.init(this.miniWorkspace),e?.show(t.languageTree)),O(this.svgRoot,`blocklyMiniWorkspaceBubble`),this.miniWorkspace.addChangeListener(this.onWorkspaceChange.bind(this));let i,a;(i=this.miniWorkspace.getFlyout())==null||(a=i.getWorkspace())==null||a.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(let e of this.miniWorkspace.getTopBlocks(!1)){let t=e.getRelativeToSurfaceXY();if(t.y<20&&e.moveBy(0,20-t.y),e.RTL){let n=-20,r=this.miniWorkspace.getFlyout();r&&(n-=r.getWidth()),t.x>n&&e.moveBy(n-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)<jp.MINIMUM_VIEW_CHANGE&&Math.abs(e.height-t.height)<jp.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 z(t.width+kp.DOUBLE_BORDER,t.height+kp.DOUBLE_BORDER),this.autoLayout),this.miniWorkspace.resize(),this.miniWorkspace.recordDragTargets())}}calculateWorkspaceSize(){var e=this.miniWorkspace.getCanvas().getBBox();let t=e.width+jp.MARGIN;e=e.height+jp.MARGIN;let n=this.miniWorkspace.getFlyout();if(n){let r=n.getWorkspace().getMetricsManager().getScrollMetrics();e=Math.max(e,r.height+20),t+=n.getWidth()}return new z(t,e)}updateBlockStyles(){for(var e of this.miniWorkspace.getAllBlocks(!1))e.setStyle(e.getStyleName());if(e=this.miniWorkspace.getFlyout()?.getWorkspace())for(let t of e.getAllBlocks(!1))t.setStyle(t.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`)}};jp.MINIMUM_VIEW_CHANGE=10,jp.MARGIN=kp.DOUBLE_BORDER*3;var Mp={};Mp.MiniWorkspaceBubble=jp;var Np=class{constructor(e){this.sourceBlock=e,this.offsetInBlock=new I(0,0),this.workspaceLocation=new I(0,0),this.svgRoot=null,this.tooltip=e,this.id=ne()}getType(){throw Error(`Icons must implement getType`)}initView(e){if(!this.svgRoot){var t=this.sourceBlock;this.svgRoot=D(L.G,{class:`blocklyIconGroup`,id:this.id}),t.getSvgRoot().appendChild(this.svgRoot),this.updateSvgRootOffset(),g(this.svgRoot,`pointerdown`,this,e),this.svgRoot.tooltip=this,ei(this.svgRoot)}}dispose(){ti(this.svgRoot),A(this.svgRoot)}getWeight(){return-1}getSize(){return new z(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`,mr(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=I.sum(e,this.offsetInBlock)}onClick(){}isClickableInFlyout(e){return!0}getFocusableElement(){let e=this.svgRoot;if(!e)throw Error(`Attempting to focus uninitialized icon.`);return e}getFocusableTree(){return this.sourceBlock.workspace}onNodeFocus(){var e=this.sourceBlock.getBoundingRectangle();e=new R(e.top+this.offsetInBlock.y,e.top+this.offsetInBlock.y+this.getSize().height,e.left+this.offsetInBlock.x,e.left+this.offsetInBlock.x+this.getSize().width),this.sourceBlock.workspace.scrollBoundsIntoView(e)}onNodeBlur(){}canBeFocused(){return!0}getSourceBlock(){return this.sourceBlock}showContextMenu(e){this.getSourceBlock().showContextMenu(e)}},Pp={};Pp.Icon=Np;var Fp=17,Ip=16;e.MutatorIcon$$module$build$src$core$icons$mutator_icon=class extends Np{constructor(e,t){super(t),this.flyoutBlockTypes=e,this.sourceBlock=t,this.saveConnectionsListener=this.updateWorkspacePid=this.rootBlock=this.miniWorkspaceBubble=null}getType(){return e.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE}initView(e){this.svgRoot||(super.initView(e),D(L.RECT,{class:`blocklyIconShape`,rx:`4`,ry:`4`,height:`16`,width:`16`},this.svgRoot),D(L.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),D(L.CIRCLE,{class:`blocklyIconShape`,r:`2.7`,cx:`8`,cy:`8`},this.svgRoot),O(this.svgRoot,`blocklyMutatorIcon`))}dispose(){super.dispose();let e;(e=this.miniWorkspaceBubble)==null||e.dispose()}getWeight(){return e.MutatorIcon$$module$build$src$core$icons$mutator_icon.WEIGHT}getSize(){return new z(Fp,Fp)}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){let t=this;return(0,N.asyncExecutePromiseGeneratorFunction)(function*(){if(t.bubbleIsVisible()!==e){if(yield rn(),e){t.miniWorkspaceBubble=new jp(t.getMiniWorkspaceConfig(),t.sourceBlock.workspace,t.getAnchorLocation(),t.getBubbleOwnerRect()),t.applyColour(),t.createRootBlock(),t.addSaveConnectionsListener();let e;(e=t.miniWorkspaceBubble)==null||e.addWorkspaceChangeListener(t.createMiniWorkspaceChangeListener())}else{let e;(e=t.miniWorkspaceBubble)==null||e.dispose(),t.miniWorkspaceBubble=null,t.saveConnectionsListener&&t.sourceBlock.workspace.removeChangeListener(t.saveConnectionsListener),t.saveConnectionsListener=null}w(new(E(F.BUBBLE_OPEN))(t.sourceBlock,e,`mutator`))}})}getBubble(){return this.miniWorkspaceBubble}getMiniWorkspaceConfig(){let e={disable:!1,media:this.sourceBlock.workspace.options.pathToMedia,rtl:this.sourceBlock.RTL,renderer:this.sourceBlock.workspace.options.renderer,rendererOverrides:this.sourceBlock.workspace.options.rendererOverrides??void 0};return this.flyoutBlockTypes.length&&(e.toolbox={kind:`flyoutToolbox`,contents:this.flyoutBlockTypes.map(e=>({kind:`block`,type:e}))}),e}getAnchorLocation(){let e=Fp/2;return I.sum(this.workspaceLocation,new I(e,e))}getBubbleOwnerRect(){let e=this.sourceBlock.getSvgRoot().getBBox();return new R(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,n;e=((t=this.miniWorkspaceBubble)==null||(n=t.getWorkspace())==null?void 0:n.getFlyout()?.getWidth())??0,this.rootBlock.moveBy(this.rootBlock.RTL?-(e+Ip):Ip,Ip)}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 t=>{e.MutatorIcon$$module$build$src$core$icons$mutator_icon.isIgnorableMutatorEvent(t)||this.updateWorkspacePid||(this.updateWorkspacePid=setTimeout(()=>{this.updateWorkspacePid=null,this.recomposeSourceBlock()},0))}}static isIgnorableMutatorEvent(e){return e.isUiEvent||ie(e)||x(e)&&e.element===`disabled`}recomposeSourceBlock(){if(this.rootBlock){if(!this.sourceBlock.compose)throw Error(`Blocks with mutator icons must include a compose method`);var t=e.getGroup$$module$build$src$core$events$utils();t||e.setGroup$$module$build$src$core$events$utils(!0);var n=Ad.getExtraBlockState_(this.sourceBlock);this.sourceBlock.compose(this.rootBlock);var r=Ad.getExtraBlockState_(this.sourceBlock);n!==r&&w(new(E(F.BLOCK_CHANGE))(this.sourceBlock,`mutation`,null,n,r)),e.setGroup$$module$build$src$core$events$utils(t)}}getWorkspace(){return this.miniWorkspaceBubble?.getWorkspace()}},e.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE=G.MUTATOR,e.MutatorIcon$$module$build$src$core$icons$mutator_icon.WEIGHT=1;var Lp={};Lp.MutatorIcon=e.MutatorIcon$$module$build$src$core$icons$mutator_icon;var Rp=Object.create(null),zp={allExtensions:Rp};e.register$$module$build$src$core$extensions(`parent_tooltip_when_inline`,Ga);var Bp={TEST_ONLY:zp};Bp.apply=Pa,Bp.buildTooltipForDropdown=e.buildTooltipForDropdown$$module$build$src$core$extensions,Bp.buildTooltipWithFieldText=e.buildTooltipWithFieldText$$module$build$src$core$extensions,Bp.isRegistered=Na,Bp.register=e.register$$module$build$src$core$extensions,Bp.registerMixin=e.registerMixin$$module$build$src$core$extensions,Bp.registerMutator=e.registerMutator$$module$build$src$core$extensions,Bp.runAfterPageLoad=Ua,Bp.unregister=Ma;var Vp;(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`,e[e.CTRL_CMD=Fc||Pc||Nc?e.MAC_WK_CMD_LEFT:e.CTRL]=`CTRL_CMD`})(Vp||(Vp={}));var Hp={};Hp.KeyCodes=Vp;var Up={};Up.arc=Za,Up.curve=Ka,Up.line=Xa,Up.lineOnAxis=M,Up.lineTo=Ya,Up.moveBy=Ja,Up.moveTo=qa,Up.point=j;var Wp={};Wp.Coordinate=I,Wp.KeyCodes=Vp,Wp.Rect=R,Wp.Size=z,Wp.Svg=L,Wp.aria=Mu,Wp.array=Ml,Wp.browserEvents=Bc,Wp.colour=yf,Wp.deprecation=hd,Wp.dom=cl,Wp.extensions=Bp,Wp.idGenerator=Kc,Wp.math=Md,Wp.object=gl,Wp.parsing=bf,Wp.string=Qd,Wp.style=Gl,Wp.svgMath=Jl,Wp.svgPaths=Up,Wp.toolbox=cu,Wp.userAgent=Lc,Wp.xml=iu;var Gp=class extends kp{constructor(t,n,r,i){super(t,n,r,void 0,i),this.workspace=t,this.anchor=n,this.ownerRect=r,this.owner=i,this.resizePointerMoveListener=this.resizePointerUpListener=null,this.sizeChangeListeners=[],this.locationChangeListeners=[],this.DEFAULT_SIZE=new z(160+kp.DOUBLE_BORDER,80+kp.DOUBLE_BORDER),this.MIN_SIZE=new z(45+kp.DOUBLE_BORDER,20+kp.DOUBLE_BORDER),this.editable=!0,O(this.svgRoot,`blocklyTextInputBubble`),this.editor=new Qf(t,this.id,()=>{e.getFocusManager$$module$build$src$core$focus_manager().focusNode(this)}),this.contentContainer.appendChild(this.editor.getDom()),this.resizeGroup=this.createResizeHandle(this.svgRoot,t),this.setSize(this.DEFAULT_SIZE,!0)}getText(){return this.editor.getText()}setText(e){this.editor.setText(e)}setEditable(e){this.editable=e,this.editor.setEditable(e)}isEditable(){return this.editable}addTextChangeListener(e){this.editor.addTextChangeListener(e)}addSizeChangeListener(e){this.sizeChangeListeners.push(e)}addLocationChangeListener(e){this.locationChangeListeners.push(e)}createResizeHandle(e,t){return e=D(L.IMAGE,{class:`blocklyResizeHandle`,href:`${t.options.pathToMedia}resize-handle.svg`},e),g(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);let n=e.width-kp.DOUBLE_BORDER,r=e.height-kp.DOUBLE_BORDER;this.editor.updateSize(new z(n,r),new z(0,0)),this.editor.getDom().setAttribute(`x`,`${kp.DOUBLE_BORDER/2}`),this.editor.getDom().setAttribute(`y`,`${kp.DOUBLE_BORDER/2}`),this.resizeGroup.setAttribute(`y`,`${r}`),this.workspace.RTL?this.resizeGroup.setAttribute(`x`,`${-kp.DOUBLE_BORDER}`):this.resizeGroup.setAttribute(`x`,`${n}`),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 R(0,0,0,0)){super.positionByRect(e),this.onLocationChange()}onResizePointerDown(e){this.bringToFront(),b(e)||($i(this.workspace,e,new I(this.workspace.RTL?-this.getSize().width:this.getSize().width,this.getSize().height)),this.resizePointerUpListener=g(document,`pointerup`,this,this.onResizePointerUp),this.resizePointerMoveListener=g(document,`pointermove`,this,this.onResizePointerMove),this.workspace.hideChaff()),e.stopPropagation()}onResizePointerUp(e){f(),this.resizePointerUpListener&&(v(this.resizePointerUpListener),this.resizePointerUpListener=null),this.resizePointerMoveListener&&(v(this.resizePointerMoveListener),this.resizePointerMoveListener=null)}onResizePointerMove(e){e=ea(this.workspace,e),this.setSize(new z(this.workspace.RTL?-e.x:e.x,e.y),!1),this.onSizeChange()}onSizeChange(){for(let e of this.sizeChangeListeners)e()}onLocationChange(){for(let e of this.locationChangeListeners)e()}getEditor(){return this.editor}};ft(`
|
|
619
|
+
.blocklyTextInputBubble .blocklyTextarea {
|
|
620
|
+
background-color: var(--commentFillColour);
|
|
621
|
+
border: 0;
|
|
622
|
+
box-sizing: border-box;
|
|
623
|
+
display: block;
|
|
624
|
+
outline: 0;
|
|
625
|
+
padding: 5px;
|
|
626
|
+
resize: none;
|
|
627
|
+
width: 100%;
|
|
628
|
+
height: 100%;
|
|
629
|
+
}
|
|
630
|
+
`);var Kp={};Kp.TextInputBubble=Gp;var Y;(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`})(Y||(Y={}));var qp={};qp.ConnectionType=Y;var Jp=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;let n=this.calculateIndexForYPos(t);if(n>=this.connections.length)return-1;t=e.y;let r=n;for(;r>=0&&this.connections[r].y===t;){if(this.connections[r]===e)return r;r--}for(r=n;r<this.connections.length&&this.connections[r].y===t;){if(this.connections[r]===e)return r;r++}return-1}calculateIndexForYPos(e){if(!this.connections.length)return 0;let t=0,n=this.connections.length;for(;t<n;){let r=Math.floor((t+n)/2);if(this.connections[r].y<e)t=r+1;else if(this.connections[r].y>e)n=r;else{t=r;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 n(e){let n=i-r[e].x,o=a-r[e].y;return Math.sqrt(n*n+o*o)<=t&&c.push(r[e]),o<t}let r=this.connections,i=e.x,a=e.y;e=0;let o=r.length-2,s=o;for(;e<s;)r[s].y<a?e=s:o=s,s=Math.floor((e+o)/2);let c=[];if(o=e=s,r.length){for(;e>=0&&n(e);)e--;do o++;while(o<r.length&&n(o))}return c}isInYRange(e,t,n){return Math.abs(this.connections[e].y-t)<=n}searchForClosest(e,t,n){if(!this.connections.length)return{connection:null,radius:t};let r=e.y,i=e.x;e.x=i+n.x,e.y=r+n.y;var a=this.calculateIndexForYPos(e.y);n=null;let o=t,s,c=a-1;for(;c>=0&&this.isInYRange(c,e.y,t);)s=this.connections[c],this.connectionChecker.canConnect(e,s,!0,o)&&(n=s,o=s.distanceFrom(e)),c--;for(;a<this.connections.length&&this.isInYRange(a,e.y,t);)s=this.connections[a],this.connectionChecker.canConnect(e,s,!0,o)&&(n=s,o=s.distanceFrom(e)),a++;return e.x=i,e.y=r,{connection:n,radius:o}}static init(e){let t=[];return t[Y.INPUT_VALUE]=new Jp(e),t[Y.OUTPUT_VALUE]=new Jp(e),t[Y.NEXT_STATEMENT]=new Jp(e),t[Y.PREVIOUS_STATEMENT]=new Jp(e),t}},Yp={};Yp.ConnectionDB=Jp;var Xp=class extends Dl{constructor(e,t,n){super(n),this.type=F.SELECTED,this.oldElementId=e??void 0,this.newElementId=t??void 0}toJson(){let e=super.toJson();return e.oldElementId=this.oldElementId,e.newElementId=this.newElementId,e}static fromJson(e,t,n){return t=Dl.fromJson(e,t,n??new Xp),t.oldElementId=e.oldElementId,t.newElementId=e.newElementId,t}};t(P.EVENT,F.SELECTED,Xp);var Zp={};Zp.Selected=Xp;var Qp=class extends K{constructor(e){if(super(e),this.type=F.BLOCK_DELETE,e){if(e.getParent())throw Error(`Connected blocks cannot be deleted.`);e.isShadow()&&(this.recordUndo=!1),this.oldXml=ia(e),this.ids=Ne(e),this.wasShadow=e.isShadow(),this.oldJson=Gn(e,{addCoordinates:!0})}}toJson(){let 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=la(this.oldXml),e.ids=this.ids,e.wasShadow=this.wasShadow,e.oldJson=this.oldJson,this.recordUndo||(e.recordUndo=this.recordUndo),e}static fromJson(t,n,r){return n=K.fromJson(t,n,r??new Qp),n.oldXml=e.textToDom$$module$build$src$core$utils$xml(t.oldXml),n.ids=t.ids,n.wasShadow=t.wasShadow||n.oldXml.tagName.toLowerCase()===`shadow`,n.oldJson=t.oldJson,t.recordUndo!==void 0&&(n.recordUndo=t.recordUndo),n}run(e){let 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++){let n=this.ids[e],r=t.getBlockById(n);r?r.dispose(!1):n===this.blockId&&console.warn(`Can't delete non-existent block: `+n)}else er(this.oldJson,t)}};t(P.EVENT,F.BLOCK_DELETE,Qp);var $p={};$p.BlockDelete=Qp;var X=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_${ne()}`}connect_(e){let t=Y.INPUT_VALUE,n=this.getSourceBlock();var r=e.getSourceBlock();e.isConnected()&&e.disconnectInternal(!1);let i;if(this.isConnected()){let e=this.stashShadowState(),t=this.targetBlock();t.isShadow()?t.dispose(!1):(this.disconnectInternal(),i=t),this.applyShadowState(e)}let a;je()&&(a=new(E(F.BLOCK_MOVE))(r),a.setReason([`connect`])),Qa(this,e),r.setParent(n),a&&(a.recordNew(),w(a)),i&&(e=this.type===t?i.outputConnection:i.previousConnection)&&((r=X.getConnectionForOrphanedConnection(r,e))?e.connect(r):e.onFailedConnect(this))}dispose(){if(this.isConnected()){this.isSuperior()&&this.setShadowStateInternal();let e=this.targetBlock();e&&!e.isDeadOrDying()&&e.unplug()}this.disposed=!0}getSourceBlock(){return this.sourceBlock_}isSuperior(){return this.type===Y.INPUT_VALUE||this.type===Y.NEXT_STATEMENT}isConnected(){return!!this.targetConnection}getConnectionChecker(){return this.sourceBlock_.workspace.connectionChecker}onFailedConnect(e){}connect(t){if(this.targetConnection===t)return!0;if(this.getConnectionChecker().canConnect(this,t,!1)){let n=e.getGroup$$module$build$src$core$events$utils();n||e.setGroup$$module$build$src$core$events$utils(!0),this.isSuperior()?this.connect_(t):t.connect_(this),e.setGroup$$module$build$src$core$events$utils(n)}return this.isConnected()}disconnect(){this.disconnectInternal()}disconnectInternal(t=!0){let{parentConnection:n,childConnection:r}=this.getParentAndChildConnections();if(!n||!r)throw Error(`Source connection not connected.`);let i=e.getGroup$$module$build$src$core$events$utils();i||e.setGroup$$module$build$src$core$events$utils(!0);let a;je()&&(a=new(E(F.BLOCK_MOVE))(r.getSourceBlock()),a.setReason([`disconnect`]));let o=this.targetConnection;o&&(o.targetConnection=null),this.targetConnection=null,t&&r.getSourceBlock().setParent(null),a&&(a.recordNew(),w(a)),r.getSourceBlock().isShadow()||n.respawnShadow_(),e.setGroup$$module$build$src$core$events$utils(i)}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 n;return t=(n=e.getInput(t))?.connection,n=this.targetBlock(),n&&n!==e||!t||t.targetConnection===this?!1:(t.isConnected()&&t.disconnect(),t.connect(this),!0)}targetBlock(){return this.isConnected()?this.targetConnection?.getSourceBlock()??null: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()?sa(this.targetBlock()):this.shadowDom}setShadowState(e){this.setShadowStateInternal({shadowState:e})}getShadowState(e){return e&&this.targetBlock()&&this.targetBlock().isShadow()?Gn(this.targetBlock()):this.shadowState}neighbours(e){return[]}getParentInput(){let e=null,t=this.sourceBlock_.inputList;for(let n=0;n<t.length;n++)if(t[n].connection===this){e=t[n];break}return e}toString(){let 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 n=0,r;r=e.inputList[n];n++)if(r.connection===this){t=r;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(){let 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();let n=this.getShadowState(),r=this.getShadowDom();if(t.isDeadOrDying()||!n&&!r)return null;if(n)return t=tr(n,t.workspace,{parentConnection:e?this:void 0,isShadow:!0,recordUndo:!1});if(r){if(t=ma(r,t.workspace),e)if(this.type===Y.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===Y.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=sa(e),this.shadowState=Gn(e))}static getConnectionForOrphanedConnection(e,t){if(t.type===Y.OUTPUT_VALUE)return eo(e,t.getSourceBlock());e=e.lastConnectionInStack(!0);let n=t.getConnectionChecker();return e&&n.canConnect(t,e,!1)?e:null}};X.CAN_CONNECT=0,X.REASON_SELF_CONNECTION=1,X.REASON_WRONG_TYPE=2,X.REASON_TARGET_NULL=3,X.REASON_CHECKS_FAILED=4,X.REASON_DIFFERENT_WORKSPACES=5,X.REASON_SHADOW_PARENT=6,X.REASON_DRAG_CHECKS_FAILED=7,X.REASON_PREVIOUS_AND_OUTPUT=8;var em={};em.Connection=X;var tm=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}},nm={};nm.DuplicateIconType=tm,(function(e){e[e.LEFT=-1]=`LEFT`,e[e.CENTRE=0]=`CENTRE`,e[e.RIGHT=1]=`RIGHT`})(e.Align$$module$build$src$core$inputs$align||(e.Align$$module$build$src$core$inputs$align={}));var rm={};rm.Align=e.Align$$module$build$src$core$inputs$align;var im=class extends xf{constructor(e,t,n){super(xf.SKIP_SETUP),this.class=null,this.EDITABLE=!1,this.maxDisplayLength=1/0,e!==xf.SKIP_SETUP&&(n?this.configure_(n):this.class=t||null,this.setValue(e))}configure_(e){super.configure_(e),e.class&&(this.class=e.class)}initView(){this.createTextElement_(),this.class&&O(this.getTextElement(),this.class),this.fieldGroup_&&O(this.fieldGroup_,`blocklyLabelField`)}doClassValidation_(e){return e==null?null:`${e}`}setClass(e){this.textElement_&&(this.class&&k(this.textElement_,this.class),e&&O(this.textElement_,e)),this.class=e}static fromJson(e){return new this(Ti(e.text),void 0,e)}};Oa(`field_label`,im),im.prototype.DEFAULT_VALUE=``;var am={};am.FieldLabel=im;var om=30,sm=[];sm[Y.INPUT_VALUE]=Y.OUTPUT_VALUE,sm[Y.OUTPUT_VALUE]=Y.INPUT_VALUE,sm[Y.NEXT_STATEMENT]=Y.PREVIOUS_STATEMENT,sm[Y.PREVIOUS_STATEMENT]=Y.NEXT_STATEMENT;var cm=`RENAME_VARIABLE_ID`,lm=`DELETE_VARIABLE_ID`,um=10,dm=class extends X{constructor(e,t){super(e,t),this.highlighted=!1,this.targetConnection=null,this.db=e.workspace.connectionDBList[t],this.dbOpposite=e.workspace.connectionDBList[sm[t]],this.offsetInBlock=new I(0,0),this.trackedState=dm.TrackedState.WILL_TRACK}dispose(){super.dispose(),this.trackedState===dm.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){let t=this.x-e.x;return e=this.y-e.y,Math.sqrt(t*t+e*e)}bumpAwayFrom(t,n=!1){if(!this.sourceBlock_.workspace.isDragging()){var r=e.config$$module$build$src$core$config.snapRadius+Math.floor(Math.random()*um),i=e.config$$module$build$src$core$config.snapRadius+Math.floor(Math.random()*um),a=t.sourceBlock_.getRootBlock(),o=this.sourceBlock_.getRootBlock();if(!a.isInFlyout&&!o.isInFlyout){var s=!0;if(o.isMovable())a.isMovable()&&n&&(i=-i);else if(a.isMovable())s=!1,r=-r,i=-i;else return;n=s?t:this,t=s?this:t,a=s?o:a,a.RTL&&(r=-r),a.moveBy(n.x+r-t.x,n.y+i-t.y,[`bump`])}}}moveTo(e,t){let n=!1;return this.trackedState===dm.TrackedState.WILL_TRACK?(this.db.addConnection(this,t),this.trackedState=dm.TrackedState.TRACKED,n=!0):this.trackedState===dm.TrackedState.TRACKED&&(this.db.removeConnection(this,this.y),this.db.addConnection(this,t),n=!0),this.x=e,this.y=t,n}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;let t=this.targetBlock();e&&t&&(e=I.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;let e=this.findHighlightSvg();e&&(e.style.display=``)}unhighlight(){this.highlighted=!1;let e=this.findHighlightSvg();e&&(e.style.display=`none`)}isHighlighted(){return this.highlighted}setTracking(e){e&&this.trackedState===dm.TrackedState.TRACKED||!e&&this.trackedState===dm.TrackedState.UNTRACKED||this.sourceBlock_.isInFlyout||(e?(this.db.addConnection(this,this.y),this.trackedState=dm.TrackedState.TRACKED):(this.trackedState===dm.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),this.trackedState=dm.TrackedState.UNTRACKED))}stopTrackingAll(){if(this.setTracking(!1),this.targetConnection){let e=this.targetBlock().getDescendants(!1);for(let t=0;t<e.length;t++){let n=e[t],r=n.getConnections_(!0);for(let e=0;e<r.length;e++)r[e].setTracking(!1);for(let e of n.getIcons())mr(e)&&e.setBubbleVisible(!1)}}}startTrackingAll(){this.setTracking(!0);let e=[];if(this.type!==Y.INPUT_VALUE&&this.type!==Y.NEXT_STATEMENT)return e;let t=this.targetBlock();if(t){let n;t.isCollapsed()?(n=[],t.outputConnection&&n.push(t.outputConnection),t.nextConnection&&n.push(t.nextConnection),t.previousConnection&&n.push(t.previousConnection)):n=t.getConnections_(!0);for(let t=0;t<n.length;t++)e.push(...n[t].startTrackingAll());e.length||(e=[t])}return e}onFailedConnect(t){let n=this.getSourceBlock();if(Te()){let r=e.getGroup$$module$build$src$core$events$utils();setTimeout(function(){n.isDisposed()||n.getParent()||(e.setGroup$$module$build$src$core$events$utils(r),this.bumpAwayFrom(t),e.setGroup$$module$build$src$core$events$utils(!1))}.bind(this),e.config$$module$build$src$core$config.bumpDelay)}}disconnectInternal(t=!0){let{parentConnection:n,childConnection:r}=this.getParentAndChildConnections();if(n&&r){var i=e.getGroup$$module$build$src$core$events$utils();i||e.setGroup$$module$build$src$core$events$utils(!0);var a=n.getSourceBlock(),o=r.getSourceBlock();super.disconnectInternal(t),a.queueRender(),o.updateDisabled(),o.queueRender(),o.getSvgRoot().style.display=`block`,e.setGroup$$module$build$src$core$events$utils(i)}}respawnShadow_(){super.respawnShadow_();let 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){let t=J.registry.getContextMenuOptions({focusedNode:this},e);if(t.length){var n=this.getSourceBlock(),r=n.workspace;if(e instanceof PointerEvent)var i=new I(e.clientX,e.clientY);else i=new I(this.x,this.y),i=Ot(r,i).translate(n.RTL?-5:5,5);Wi(e,t,n.RTL,r,i)}}getFocusableElement(){let 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(),this.getSourceBlock().workspace.scrollBoundsIntoView(this.getSourceBlock().getBoundingRectangleWithoutChildren())}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`})(dm||(dm={}));var fm=dm.TrackedState,pm={};pm.RenderedConnection=dm,pm.TrackedState=fm;var mm=class{constructor(t,n){this.name=t,this.sourceBlock=n,this.fieldRow=[],this.align=e.Align$$module$build$src$core$inputs$align.LEFT,this.visible=!0,this.type=e.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(t,n,r){if(t<0||t>this.fieldRow.length)throw Error(`index `+t+` out of bounds.`);return n||n===``&&r?(typeof n==`string`&&(n=e.fromJson$$module$build$src$core$field_registry({type:`field_label`,text:n})),n.setSourceBlock(this.sourceBlock),this.sourceBlock.initialized&&this.initField(n),n.name=r,n.setVisible(this.isVisible()),n.prefixField&&(t=this.insertFieldAt(t,n.prefixField)),this.fieldRow.splice(t,0,n),t++,n.suffixField&&(t=this.insertFieldAt(t,n.suffixField)),this.sourceBlock.rendered&&this.sourceBlock.queueRender(),t):t}removeField(e,t){for(let t=0,n;n=this.fieldRow[t];t++)if(n.name===e)return n.dispose(),this.fieldRow.splice(t,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 t=0,n;n=this.fieldRow[t];t++)n.setVisible(e);if(this.connection&&this.connection instanceof dm){e?t=this.connection.startTrackingAll():this.connection.stopTrackingAll();let n=this.connection.targetBlock();n&&(n.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(let e of this.fieldRow)e.init()}initModel(){for(let 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)}},hm={};hm.Input=mm;var gm=class extends mm{constructor(t,n){super(t,n),this.name=t,this.type=e.inputTypes$$module$build$src$core$inputs$input_types.DUMMY}},_m={};_m.DummyInput=gm;var vm=class extends mm{constructor(t,n){super(t,n),this.name=t,this.type=e.inputTypes$$module$build$src$core$inputs$input_types.END_ROW}},ym={};ym.EndRowInput=vm;var bm=class extends mm{constructor(t,n){if(!t)throw Error(`Statement inputs must have a non-empty name`);super(t,n),this.name=t,this.type=e.inputTypes$$module$build$src$core$inputs$input_types.STATEMENT,this.connection=this.makeConnection(Y.NEXT_STATEMENT)}},xm={};xm.StatementInput=bm;var Sm;e.ValueInput$$module$build$src$core$inputs$value_input=class extends mm{constructor(t,n){if(!t)throw Error(`Value inputs must have a non-empty name`);super(t,n),this.name=t,this.type=e.inputTypes$$module$build$src$core$inputs$input_types.VALUE,this.connection=this.makeConnection(Y.INPUT_VALUE)}},Sm={},Sm.ValueInput=e.ValueInput$$module$build$src$core$inputs$value_input;var Cm={};Cm.isIcon=to;var wm={};wm.isCommentIcon=no;var Tm=class{constructor(e,t,n){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=n&&!e.getBlockById(n)?n:re(),e.setBlockById(this.id,this),this.xy=new I(0,0),this.isInFlyout=e.isFlyout,this.isInMutator=e.isMutator,this.RTL=e.RTL,t){if(this.type=t,n=fc[t],!n||typeof n!=`object`)throw TypeError(`Invalid block definition for type: `+t);Object.assign(this,n)}e.addTopBlock(this),e.addTypedBlock(this),new.target===Tm&&this.doInit_()}doInit_(){let t=e.getGroup$$module$build$src$core$events$utils();t||e.setGroup$$module$build$src$core$events$utils(!0);let n=Te();try{typeof this.init==`function`&&(e.setRecordUndo$$module$build$src$core$events$utils(!1),this.init(),e.setRecordUndo$$module$build$src$core$events$utils(n)),je()&&w(new(E(F.BLOCK_CREATE))(this))}finally{e.setGroup$$module$build$src$core$events$utils(t),e.setRecordUndo$$module$build$src$core$events$utils(n)}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),je()&&w(new(E(F.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(let 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,n;(n=this.outputConnection)!=null&&n.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++){let n=this.inputList[t].connection;if(n&&n.type===Y.INPUT_VALUE&&n.targetConnection){if(e)return null;e=n}}return e}unplugFromStack(e){let t=null,n;if((n=this.previousConnection)!=null&&n.isConnected()&&(t=this.previousConnection.targetConnection,this.previousConnection.disconnect()),e){for(e=this.getNextBlock();e&&(e.isShadow()||!e.isMovable());)e=e.getNextBlock();if(e){var r,i;e=((r=e.previousConnection)==null||(i=r.targetBlock())==null?void 0:i.nextConnection?.targetConnection)??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,n;n=this.inputList[t];t++)n.connection&&e.push(n.connection);return e}lastConnectionInStack(e){let t=this.nextConnection;for(;t;){let n=t.targetBlock();if(!n||e&&n.isShadow())return t;t=n.nextConnection}return null}bumpNeighbours(){}getParent(){return this.parentBlock_}getInputWithBlock(e){for(let t=0,n;n=this.inputList[t];t++)if(n.connection&&n.connection.targetBlock()===e)return n;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 n=0,r;r=this.inputList[n];n++)if(r.connection){var t=r.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(),n=!!t;if(n&&e&&t!==e)throw Error(`Block connected to superior one that is not new parent.`);if(!n&&e)throw Error(`Block not connected to new parent.`);if(n&&!e)throw Error(`Cannot set parent to null while block is still connected to superior block.`);this.parentBlock_?dt(this.parentBlock_.childBlocks_,this):this.workspace.removeTopBlock(this),(this.parentBlock_=e)?e.childBlocks_.push(this):this.workspace.addTopBlock(this)}}getDescendants(e){let t=[this],n=this.getChildren(e);for(let r,i=0;r=n[i];i++)t.push(...r.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(ot(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(let e of this.getFields())e.updateEditable()}isDisposed(){return this.disposed}isSimpleReporter(){if(!this.outputConnection)return!1;for(let e of this.inputList)if(e.connection||e.fieldRow.length>1)return!1;return!0}getMatchingConnection(e,t){let n=this.getConnections_(!0);if(e=e.getConnections_(!0),n.length!==e.length)throw Error(`Connection lists did not match in length.`);for(let r=0;r<e.length;r++)if(e[r]===t)return n[r];return null}setHelpUrl(e){this.helpUrl=e}setTooltip(e){this.tooltip=e}getTooltip(){return Zr(this)}getColour(){return this.colour_}getStyleName(){return this.styleName_}getHue(){return this.hue}setColour(e){e=Di(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(let t of this.getFields())if(t.name===e)return t;return null}*getFields(){for(let e of this.inputList)for(let t of e.fieldRow)yield t}getVars(){let e=[];for(let t of this.getFields())t.referencesVariables()&&e.push(t.getValue());return e}getVarModels(){let e=[];for(let t of this.getFields())if(t.referencesVariables()){let n=this.workspace.getVariableMap().getVariableById(t.getValue());n&&e.push(n)}return e}updateVarName(e){for(let t of this.getFields())t.referencesVariables()&&e.getId()===t.getValue()&&t.refreshVariableName()}renameVarById(e,t){for(let n of this.getFields())n.referencesVariables()&&e===n.getValue()&&n.setValue(t)}getFieldValue(e){return(e=this.getField(e))?e.getValue():null}setFieldValue(e,t){let n=this.getField(t);if(!n)throw Error(`Field "`+t+`" not found.`);n.setValue(e)}setPreviousStatement(e,t){if(e)t===void 0&&(t=null),this.previousConnection||(this.previousConnection=this.makeConnection_(Y.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_(Y.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_(Y.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&&(w(new(E(F.BLOCK_CHANGE))(this,`inline`,null,this.inputsInline,e)),this.inputsInline=e)}getInputsInline(){if(this.inputsInline!==void 0)return this.inputsInline;for(var t=1;t<this.inputList.length;t++)if(this.inputList[t-1]instanceof gm&&this.inputList[t]instanceof gm)return!1;for(t=1;t<this.inputList.length;t++)if(this.inputList[t-1]instanceof e.ValueInput$$module$build$src$core$inputs$value_input&&this.inputList[t]instanceof gm)return!0;for(t=0;t<this.inputList.length;t++)if(this.inputList[t]instanceof vm)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(Vu)||t==Vu||this.setDisabledReason(!1,Vu),this.disabledReasons.has(t)!==e&&(e?this.disabledReasons.add(t):this.disabledReasons.delete(t),e=new(E(F.BLOCK_CHANGE))(this,`disabled`,null,!e,e),e.setDisabledReason(t),w(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&&(w(new(E(F.BLOCK_CHANGE))(this,`collapsed`,null,this.collapsed_,e)),this.collapsed_=e)}toString(e,t){t=this.toTokens(t);for(let e=2;e<t.length;e++)t[e-2]===`(`&&t[e]===`)`&&(t[e-2]=t[e-1],t.splice(e-1,2));let n=``;return t=t.reduce((e,t)=>(e=e+(n===`(`||t===`)`?``:` `)+t,n=t[t.length-1],e),``),t=t.trim()||`???`,e&&t.length>e&&(t=t.substring(0,e-3)+`...`),t}toTokens(e=`?`){let t=[];for(let r of this.inputList)if(r.name!=zu){for(let e of r.fieldRow)t.push(e.getText());if(r.connection){let i=r.connection.targetBlock();if(i){var n=r.connection;let a=n.getCheck();!a&&n.targetConnection&&(a=n.targetConnection.getCheck()),(n=!!a&&(a.includes(`Boolean`)||a.includes(`Number`)))&&t.push(`(`),t.push(...i.toTokens(e)),n&&t.push(`)`)}else t.push(e)}}return t}appendValueInput(t){return this.appendInput(new e.ValueInput$$module$build$src$core$inputs$value_input(t,this))}appendStatementInput(e){return this.statementInputCount++,this.appendInput(new bm(e,this))}appendDummyInput(e=``){return this.appendInput(new gm(e,this))}appendEndRowInput(e=``){return this.appendInput(new vm(e,this))}appendInput(e){return this.inputList.push(e),e}appendInputFromRegistry(e,t){return(e=o(P.INPUT,e,!1))?this.appendInput(new e(t,this)):null}jsonInit(t){var n=t.type?`Block "`+t.type+`": `:``;if(t.output&&t.previousStatement)throw Error(n+`Must not have both an output and a previousStatement.`);for(var r=0;t[`args`+r];){if(t[`message`+r]===void 0)throw Error(n+`args${r} must have a corresponding message (message${r}).`);r++}if(t.style&&t.style.hat&&(this.hat=t.style.hat,t.style=null),t.style&&t.colour)throw Error(n+`Must not have both a colour and a style.`);for(t.style?this.jsonInitStyle(t,n):this.jsonInitColour(t,n),r=0;t[`message`+r]!==void 0;)this.interpolate(t[`message`+r],t[`args`+r]||[],t[`implicitAlign`+r]||t[`lastDummyAlign`+r],n),r++;if(t.inputsInline!==void 0&&(e.disable$$module$build$src$core$events$utils(),this.setInputsInline(t.inputsInline),e.enable$$module$build$src$core$events$utils()),t.output!==void 0&&this.setOutput(!0,t.output),t.outputShape!==void 0&&this.setOutputShape(t.outputShape),t.previousStatement!==void 0&&this.setPreviousStatement(!0,t.previousStatement),t.nextStatement!==void 0&&this.setNextStatement(!0,t.nextStatement),t.tooltip!==void 0&&(r=Ti(t.tooltip),this.setTooltip(r)),t.enableContextMenu!==void 0&&(this.contextMenu=!!t.enableContextMenu),t.suppressPrefixSuffix!==void 0&&(this.suppressPrefixSuffix=!!t.suppressPrefixSuffix),t.helpUrl!==void 0&&(r=Ti(t.helpUrl),this.setHelpUrl(r)),typeof t.extensions==`string`&&(console.warn(n+`JSON attribute 'extensions' should be an array of strings. Found raw string in JSON for '`+t.type+`' block.`),t.extensions=[t.extensions]),t.mutator!==void 0&&Pa(t.mutator,this,!0),t=t.extensions,Array.isArray(t))for(n=0;n<t.length;n++)Pa(t[n],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(let n in e)this[n]!==void 0&&t.push(n);if(t.length)throw Error(`Mixin will overwrite block members: `+JSON.stringify(t))}Object.assign(this,e)}interpolate(e,t,n,r){e=wi(e),this.validateTokens(e,t.length),t=this.interpolateArguments(e,t,n),n=[];for(let i=0,a;a=t[i];i++)if(this.isInputKeyword(a.type)){if(e=this.inputFromJson(a,r)){for(let t=0,r;r=n[t];t++)e.appendField(r[0],r[1]);n.length=0}}else(e=this.fieldFromJson(a))&&n.push([e,a.name])}validateTokens(e,t){let n=[],r=0;for(let i=0;i<e.length;i++){let a=e[i];if(typeof a==`number`){if(a<1||a>t)throw Error(`Block "`+this.type+`": Message index %`+a+` out of range.`);if(n[a])throw Error(`Block "`+this.type+`": Message index %`+a+` duplicated.`);n[a]=!0,r++}}if(r!==t)throw Error(`Block "`+this.type+`": Message does not reference all `+t+` arg(s).`)}interpolateArguments(e,t,n){let r=[];for(let a=0;a<e.length;a++){var i=e[a];if(typeof i==`number`&&(i=t[i-1]),typeof i==`string`){if(i===`
|
|
631
|
+
`)i={type:`input_end_row`},n&&(i.align=n);else if(i=this.stringToFieldJson(i),!i)continue}r.push(i)}return(e=r.length)&&!this.isInputKeyword(r[e-1].type)&&(e={type:`input_dummy`},n&&(e.align=n),r.push(e)),r}fieldFromJson(t){let n=e.fromJson$$module$build$src$core$field_registry(t);return!n&&t.alt?typeof t.alt==`string`?(t=this.stringToFieldJson(t.alt))?this.fieldFromJson(t):null:this.fieldFromJson(t.alt):n}inputFromJson(t,n){var r={LEFT:e.Align$$module$build$src$core$inputs$align.LEFT,RIGHT:e.Align$$module$build$src$core$inputs$align.RIGHT,CENTRE:e.Align$$module$build$src$core$inputs$align.CENTRE,CENTER:e.Align$$module$build$src$core$inputs$align.CENTRE};let i;switch(t.type){case`input_value`:i=this.appendValueInput(t.name);break;case`input_statement`:i=this.appendStatementInput(t.name);break;case`input_dummy`:i=this.appendDummyInput(t.name);break;case`input_end_row`:i=this.appendEndRowInput(t.name);break;default:i=this.appendInputFromRegistry(t.type,t.name)}return i?(t.check&&i.setCheck(t.check),t.align&&(r=r[t.align.toUpperCase()],r===void 0?console.warn(n+`Illegal align value: `,t.align):i.setAlign(r)),i):null}isInputKeyword(e){return e===`input_value`||e===`input_statement`||e===`input_dummy`||e===`input_end_row`||a(P.INPUT,e)}stringToFieldJson(e){return(e=e.trim())?{type:`field_label`,text:e}:null}moveInputBefore(e,t){if(e!==t){var n=-1,r=t?-1:this.inputList.length;for(let i=0,a;a=this.inputList[i];i++)if(a.name===e){if(n=i,r!==-1)break}else if(t&&a.name===t&&(r=i,n!==-1))break;if(n===-1)throw Error(`Named input "`+e+`" not found.`);if(r===-1)throw Error(`Reference input "`+t+`" not found.`);this.moveNumberedInputBefore(n,r)}}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.`);let n=this.inputList[e];this.inputList.splice(e,1),e<t&&t--,this.inputList.splice(t,0,n)}removeInput(e,t){for(let t=0,n;n=this.inputList[t];t++)if(n.name===e)return n instanceof bm&&this.statementInputCount--,n.dispose(),this.inputList.splice(t,1),!0;if(t)return!1;throw Error(`Input not found: `+e)}getInput(e){for(let t=0,n;n=this.inputList[t];t++)if(n.name===e)return n;return null}getInputTargetBlock(e){return(e=this.getInput(e))&&e.connection&&e.connection.targetBlock()}getCommentText(){return this.getIcon(G.COMMENT)?.getText()??null}setCommentText(t){var n;let r=(n=this.getIcon(G.COMMENT))?.getText()??null;if(r!==t){if(t!==null){if(n=this.getIcon(G.COMMENT),!n){if(n=o(P.ICON,G.COMMENT.toString(),!1),!n)throw Error(`No comment icon class is registered, so a comment cannot be set`);if(n=new n(this),!no(n))throw Error(`The class registered as a comment icon does not conform to the ICommentIcon interface`);n=this.addIcon(n)}e.disable$$module$build$src$core$events$utils(),n.setText(t),e.enable$$module$build$src$core$events$utils()}else this.removeIcon(G.COMMENT);w(new(E(F.BLOCK_CHANGE))(this,`comment`,null,r,t))}}setWarningText(e,t){}setMutator(e){}addIcon(e){if(this.hasIcon(e.getType()))throw new tm(e);return this.icons.push(e),this.icons.sort((e,t)=>e.getWeight()-t.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(t=>!t.getType().equals(e)),!0}hasIcon(e){return this.icons.some(t=>t.getType().equals(e))}getIcon(e){return e instanceof G?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,n){if(this.parentBlock_)throw Error(`Block has parent`);let r=new(E(F.BLOCK_MOVE))(this);n&&r.setReason(n),this.xy.translate(e,t),r.recordNew(),w(r)}makeConnection_(e){return new X(this,e)}allInputsFilled(e){if(e===void 0&&(e=!0),!e&&this.isShadow())return!1;for(let n=0,r;r=this.inputList[n];n++)if(r.connection){var t=r.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}};Tm.COLLAPSED_INPUT_NAME=zu,Tm.COLLAPSED_FIELD_NAME=Bu;var Em={};Em.Block=Tm;var Dm=null,Om=null,km={};km.connectionUiEffect=ao,km.disconnectUiEffect=oo,km.disconnectUiStop=co,km.disposeUiEffect=ro;var Am=class{paste(t,n,r){if(!n.isCapacityAvailable(t.typeCounts))return null;r&&(t.blockState.x=r.x,t.blockState.y=r.y),r=r||new I(t.blockState.x||0,t.blockState.y||0),e.disable$$module$build$src$core$events$utils();let i;try{i=er(t.blockState,n),lo(i,r)}finally{e.enable$$module$build$src$core$events$utils()}if(!i)return i;je()&&!i.isShadow()&&w(new(E(F.BLOCK_CREATE))(i));let a=i;return rn().then(()=>e.getFocusManager$$module$build$src$core$focus_manager().focusNode(a)),i}};Am.TYPE=`block`,Yt(Am.TYPE,new Am);var jm={};jm.BlockPaster=Am,jm.moveBlockToNotConflict=lo;var Mm={};Mm.bumpIntoBounds=po,Mm.bumpIntoBoundsHandler=mo,Mm.bumpTopObjectsIntoBounds=go;var Nm=class{constructor(e){this.block=e,this.connectionPreviewer=this.connectionCandidate=this.startLoc=this.startChildConn=this.startParentConn=null,this.dragging=!1,this.dragOffset=new I(0,0),this.originalEventGroup=``,this.workspace=e.workspace}isMovable(){return this.block.isShadow()?this.block.getParent()?.isMovable()??!1: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(l(P.CONNECTION_PREVIEWER,this.workspace.options))(this.block),ze(),this.workspace.setResizesEnabled(!1),co(),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),this.getVisibleBubbles(this.block).forEach(e=>{let t;(t=this.workspace.getLayerManager())==null||t.moveToDragLayer(e,!1)})}}getVisibleBubbles(e){return e.getDescendants(!1).flatMap(e=>e.getIcons()).filter(e=>mr(e)&&e.bubbleIsVisible()).map(e=>e.getBubble()).filter(e=>!!e).sort((e,t)=>(e=e.getSvgRoot().compareDocumentPosition(t.getSvgRoot()),e&Node.DOCUMENT_POSITION_PRECEDING?1:e&Node.DOCUMENT_POSITION_FOLLOWING?-1:0))}shouldHealStack(e){return!!e&&(e.altKey||e.ctrlKey||e.metaKey)}startDraggingShadow(e){let 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=I.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){this.startParentConn=this.block.outputConnection?.targetConnection??this.block.previousConnection?.targetConnection,e&&(this.startChildConn=this.block.nextConnection?.targetConnection),this.block.unplug(e),oo(this.block)}fireDragStartEvent(){let e=new(E(F.BLOCK_DRAG))(this.block,!0,this.block.getDescendants(!1));w(e)}fireDragEndEvent(){let e=new(E(F.BLOCK_DRAG))(this.block,!1,this.block.getDescendants(!1));w(e)}fireMoveEvent(){if(!this.block.isDeadOrDying()){var e=new(E(F.BLOCK_MOVE))(this.block);e.setReason([`drag`]),e.oldCoordinate=this.startLoc,e.recordNew(),w(e)}}drag(e){if(this.block.isShadow()){let t;(t=this.block.getParent())==null||t.drag(I.sum(e,this.dragOffset))}else this.block.moveDuringDrag(e),this.updateConnectionPreview(this.block,I.difference(e,this.startLoc))}updateConnectionPreview(e,t){var n=this.connectionCandidate;let r=this.getConnectionCandidate(e,t);if(r){this.connectionCandidate=t=n&&this.currCandidateIsBetter(n,t,r)?n:r;var{local:i,neighbour:a}=t;t=i.type===Y.OUTPUT_VALUE||i.type===Y.PREVIOUS_STATEMENT;var o;if(n=a.isConnected()&&!((o=a.targetBlock())!=null&&o.isInsertionMarker()),t&&n&&!this.orphanCanConnectAtEnd(e,a.targetBlock(),i.type)){let e;(e=this.connectionPreviewer)==null||e.previewReplacement(i,a,a.targetBlock())}else{var s;(s=this.connectionPreviewer)==null||s.previewConnection(i,a)}}else{let e;(e=this.connectionPreviewer)==null||e.hidePreview(),this.connectionCandidate=null}}orphanCanConnectAtEnd(e,t,n){return!!X.getConnectionForOrphanedConnection(e,n===Y.OUTPUT_VALUE?t.outputConnection:t.previousConnection)}currCandidateIsBetter(t,n,r){let{local:i,neighbour:a}=t;t=new I(i.x,i.y);let o=new I(a.x,a.y);return n=I.distance(I.sum(t,n),o),r.distance>n-e.config$$module$build$src$core$config.currentConnectionPreference}getConnectionCandidate(e,t){e=this.getLocalConnections(e);let n=this.getSearchRadius(),r=null;for(let i of e){let{connection:e,radius:a}=i.closest(n,t);e&&(r={local:i,neighbour:e,distance:a},n=a)}return r}getSearchRadius(){return this.connectionCandidate?e.config$$module$build$src$core$config.connectingSnapRadius:e.config$$module$build$src$core$config.snapRadius}getLocalConnections(e){let t=e.getConnections_(!1),n=e.lastConnectionInStack(!0);return n&&n!==e.nextConnection&&t.push(n),t}endDrag(t){if(this.block.isShadow()){let e;(e=this.block.getParent())==null||e.endDrag(t)}else{this.originalEventGroup=e.getGroup$$module$build$src$core$events$utils(),this.fireDragEndEvent(),this.fireMoveEvent(),Be(),co();var n;if((n=this.connectionPreviewer)==null||n.hidePreview(),!this.block.isDeadOrDying()&&this.dragging){let e;(e=this.workspace.getLayerManager())==null||e.moveOffDragLayer(this.block,zf),this.getVisibleBubbles(this.block).forEach(e=>this.workspace.getLayerManager()?.moveOffDragLayer(e,Bf,!1)),this.block.setDragging(!1)}this.connectionCandidate?(this.applyConnections(this.connectionCandidate),this.disposeStep()):this.block.queueRender().then(()=>this.disposeStep())}}disposeStep(){let t=e.getGroup$$module$build$src$core$events$utils();e.setGroup$$module$build$src$core$events$utils(this.originalEventGroup),this.block.snapToGrid();let n;(n=this.connectionPreviewer)==null||n.dispose(),this.workspace.setResizesEnabled(!0),e.setGroup$$module$build$src$core$events$utils(t)}applyConnections(e){let{local:t,neighbour:n}=e;t.connect(n);let r=t.isSuperior()?n:t,i=this.block.getRootBlock();rn().then(()=>{ao(r.getSourceBlock()),setTimeout(()=>{i.bringToFront()},0)})}revertDrag(){if(this.block.isShadow()){let e;(e=this.block.getParent())==null||e.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 Y.INPUT_VALUE:this.startParentConn.connect(this.block.outputConnection);break;case Y.NEXT_STATEMENT:this.startParentConn.connect(this.block.previousConnection)}else{this.block.moveTo(this.startLoc,[`drag`]);let e;(e=this.workspace.getLayerManager())==null||e.moveOffDragLayer(this.block,zf),this.getVisibleBubbles(this.block).forEach(e=>this.workspace.getLayerManager()?.moveOffDragLayer(e,Bf,!1)),po(this.workspace,this.workspace.getMetricsManager().getScrollMetrics(!0),this.block)}this.startParentConn=this.startChildConn=null,this.block.setDragging(!1),this.dragging=!1}}},Pm={};Pm.BlockDragStrategy=Nm;var Fm=class extends kp{constructor(e,t,n,r){super(t,n,r),this.text=e,this.workspace=t,this.anchor=n,this.ownerRect=r,this.paragraph=this.stringToSvg(e,this.contentContainer),this.updateBubbleSize(),O(this.svgRoot,`blocklyTextBubble`)}getText(){return this.text}setText(e){this.text=e,A(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 D(L.G,{class:`blocklyText blocklyBubbleText blocklyNoPointerEvents`,transform:`translate(0,${kp.BORDER_WIDTH})`,style:`direction: ${this.workspace.RTL?`rtl`:`ltr`}`},e)}createTextFragments(e,t){let n=1;return t.split(`
|
|
632
|
+
`).map(t=>{let r=D(L.TEXT,{y:`${n}em`,x:kp.BORDER_WIDTH},e);return t=document.createTextNode(t),r.appendChild(t),n+=1,r})}rightAlignTextFragments(e,t){for(let n of t)n.setAttribute(`text-anchor`,`start`),n.setAttribute(`x`,`${e+kp.BORDER_WIDTH}`)}updateBubbleSize(){let e=this.paragraph.getBBox();this.setSize(new z(e.width+kp.BORDER_WIDTH*2,e.height+kp.BORDER_WIDTH*2),!0)}},Im={};Im.TextBubble=Fm;var Lm=17,Rm=class extends Np{constructor(e){super(e),this.sourceBlock=e,this.textMap=new Map,this.textBubble=null}getType(){return Rm.TYPE}initView(e){this.svgRoot||(super.initView(e),D(L.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),D(L.PATH,{class:`blocklyIconSymbol`,d:`m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z`},this.svgRoot),D(L.RECT,{class:`blocklyIconSymbol`,x:`7`,y:`11`,height:`2`,width:`2`},this.svgRoot),O(this.svgRoot,`blocklyWarningIcon`))}dispose(){super.dispose();let e;(e=this.textBubble)==null||e.dispose()}getWeight(){return Rm.WEIGHT}getSize(){return new z(Lm,Lm)}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 n;return(n=this.textBubble)==null||n.setText(this.getText()),this}getText(){return[...this.textMap.values()].join(`
|
|
633
|
+
`)}onClick(){super.onClick(),this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.textBubble}setBubbleVisible(e){let t=this;return(0,N.asyncExecutePromiseGeneratorFunction)(function*(){if(t.bubbleIsVisible()!==e){if(yield rn(),e)t.textBubble=new Fm(t.getText(),t.sourceBlock.workspace,t.getAnchorLocation(),t.getBubbleOwnerRect()),t.applyColour();else{let e;(e=t.textBubble)==null||e.dispose(),t.textBubble=null}w(new(E(F.BUBBLE_OPEN))(t.sourceBlock,e,`warning`))}})}getBubble(){return this.textBubble}getAnchorLocation(){let e=Lm/2;return I.sum(this.workspaceLocation,new I(e,e))}getBubbleOwnerRect(){let e=this.sourceBlock.getSvgRoot().getBBox();return new R(e.y,e.y+e.height,e.x,e.x+e.width)}};Rm.TYPE=G.WARNING,Rm.WEIGHT=2;var zm={};zm.WarningIcon=Rm;var Bm=class extends Tm{constructor(e,t,n){if(super(e,t,n),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 I(0,0),this.dragStrategy=new Nm(this),!e.rendered)throw TypeError(`Cannot create a rendered block in a headless workspace`);this.workspace=e,this.svgGroup=D(L.G,{}),t&&O(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,ei(e),this.svgGroup.setAttribute(`data-id`,this.id),e.id=ne(),this.doInit_()}initSvg(){if(!this.initialized){for(var e of this.inputList)e.init();for(let e of this.getIcons())e.initView(this.createIconPointerDownListener(e)),e.updateEditable();this.applyColour(),this.pathObject.updateMovable(this.isMovable()||this.isInFlyout),(e=this.getSvgRoot())&&g(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(),nt(this)}unselect(){this.removeSelect(),nt(null)}setParent(t){var n=this.parentBlock_;if(t!==n){ze(),super.setParent(t),Be();var r=this.getSvgRoot();if(!this.workspace.isClearing&&r){var i=this.getRelativeToSurfaceXY(),a=e.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode(),o,s=this.getSvgRoot().contains((o=a?.getFocusableElement())??null);t?(t.getSvgRoot().appendChild(r),s&&a&&e.getFocusManager$$module$build$src$core$focus_manager().focusNode(a)):n&&(t=this.workspace.getCanvas().querySelector(`.blocklyDragging`),n=t?.parentElement,o=this.workspace.getCanvas(),n===o?o.insertBefore(r,t):(o.appendChild(r),s&&a&&e.getFocusManager$$module$build$src$core$focus_manager().focusNode(a)),this.translate(i.x,i.y)),this.applyColour()}}}getRelativeToSurfaceXY(){let e=this.workspace.getLayerManager();if(!e)throw Error(`Cannot calculate position because the workspace has not been appended`);let t=0,n=0,r=this.getSvgRoot();if(r)do{let e=Ct(r);t+=e.x,n+=e.y,r=r.parentNode}while(r&&!e.hasLayer(r));return new I(t,n)}moveBy(e,t,n){if(this.parentBlock_)throw Error(`Block has parent`);let r=je(),i=null;r&&(i=new(E(F.BLOCK_MOVE))(this),n&&i.setReason(n)),e=new I(e,t),t=this.getRelativeToSurfaceXY(),e=I.sum(t,e),this.translate(e.x,e.y),this.updateComponentLocations(e),r&&i&&(i.recordNew(),w(i)),this.workspace.resizeContents()}translate(e,t){this.translation=`translate(${e}, ${t})`,this.relativeCoords=new I(e,t),this.getSvgRoot().setAttribute(`transform`,this.getTranslation())}getTranslation(){return this.translation}moveTo(e,t){let n=this.getRelativeToSurfaceXY();this.moveBy(e.x-n.x,e.y-n.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){let t=this.getRelativeToSurfaceXY(),n,r;return this.RTL?(n=t.x-e.width,r=t.x):(n=t.x,r=t.x+e.width),new R(t.y,t.y+e.height,n,r)}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(){var e=this.getNextBlock();e=e?new Set(e.getDescendants(!1)):null;let t=this.getDescendants(!1);for(let n of t){if(n===this)continue;let t;if(((t=e)==null||!t.has(n))&&n.getIcon(Rm.TYPE))return!0}return!1}updateCollapsed(){var t=this.isCollapsed();let n=zu,r=Bu;for(let e=0,r;r=this.inputList[e];e++)r.name!==n&&r.setVisible(!t);for(var i of this.getIcons())i.updateCollapsed();t?(O(this.svgGroup,`blocklyCollapsed`),this.childHasWarning()&&this.setWarningText(e.Msg$$module$build$src$core$msg.COLLAPSED_WARNINGS_WARNING,Bm.COLLAPSED_WARNING_ID),t=this.toString(om),(i=this.getField(r))?i.setValue(t):(this.getInput(n)||this.appendDummyInput(n)).appendField(new im(t),r)):(this.updateDisabled(),this.removeInput(n),k(this.svgGroup,`blocklyCollapsed`),this.setWarningText(null,Bm.COLLAPSED_WARNING_ID))}onMouseDown(e){if(!this.workspace.isReadOnly()){var t=this.workspace.getGesture(e);t&&t.handleBlockStart(e,this)}}showHelp(){let e=typeof this.helpUrl==`function`?this.helpUrl():this.helpUrl;e&&window.open(e)}generateContextMenu(e){return this.workspace.isReadOnly()||!this.contextMenu?null:(e=J.registry.getContextMenuOptions({block:this,focusedNode:this},e),this.customContextMenu&&this.customContextMenu(e),e)}calculateContextMenuLocation(e){if(e instanceof PointerEvent)return new I(e.clientX,e.clientY);e=Ot(this.workspace,this.getRelativeToSurfaceXY());let t=this.inputList.filter(e=>e.isVisible()).flatMap(e=>e.fieldRow).find(e=>e.isVisible())?.getSvgRoot()?.getBoundingClientRect();return new I(this.RTL?e.x-5:e.x+5,(t&&t.height?t.y+t.height:e.y+this.height)+5)}showContextMenu(e){let t=this.generateContextMenu(e),n=this.calculateContextMenuLocation(e);t&&t.length&&(Wi(e,t,this.RTL,this.workspace,n),Ui(this))}updateComponentLocations(e){this.dragging||this.updateConnectionLocations(e),this.updateIconLocations(e),this.updateFieldLocations(e);for(let t of this.getChildren(!1))t.updateComponentLocations(I.sum(e,t.relativeCoords))}updateConnectionLocations(e){for(let t of this.getConnections_(!1))t.moveToOffset(e)}updateIconLocations(e){for(let t of this.getIcons())t.onLocationChange(e)}updateFieldLocations(e){for(let t of this.inputList)for(let n of t.fieldRow)n.onLocationChange(e)}addClass(e){O(this.svgGroup,e)}removeClass(e){k(this.svgGroup,e)}setDragging(e){(this.dragging=e)?(this.translation=``,Sl.push(...this.getConnections_(!0)),this.addClass(`blocklyDragging`)):(Sl.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?k(this.svgGroup,`blocklyNotEditable`):O(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}getNearestNeighbour(){if(!this.workspace.rendered)return null;var e=this.workspace.getAllBlocks(!1).filter(e=>!e.isDeadOrDying());let t=null,n=2**53-1,r=this.getRelativeToSurfaceXY();for(let i of e)e=i.getRelativeToSurfaceXY(),e=Math.sqrt((e.x-r.x)**2+(e.y-r.y)**2),e<n&&(t=i,n=e);return t}dispose(t,n){this.disposing=!0,ai(),Yi();let r=e.getFocusManager$$module$build$src$core$focus_manager();var i,a;if(this.getSvgRoot().contains((a=(i=r.getFocusedNode())?.getFocusableElement())??null)){if(i=this.getParent(),!i){var o;(a=(o=this.outputConnection)??this.previousConnection)&&(i=a.closest(0,new I(0,0)).connection?.getSourceBlock())}i?r.focusNode(i):(o=this.getNearestNeighbour())?r.focusNode(o):setTimeout(()=>{this.workspace.rendered&&r.focusTree(this.workspace)},0)}n&&(this.unplug(t),ro(this)),super.dispose(!!t),A(this.svgGroup)}disposeInternal(){this.disposing=!0,super.disposeInternal(),e.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||(e.setGroup$$module$build$src$core$events$utils(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),e.setGroup$$module$build$src$core$events$utils(!1))}toCopyData(e=!1){return this.isInsertionMarker_?null:{paster:Am.TYPE,blockState:Gn(this,{addCoordinates:!0,addNextBlocks:e,saveIds:!1}),typeCounts:ot(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(let e of this.getFields())e.applyColour()}updateDisabled(){let e=!this.isEnabled()||this.getInheritedDisabled();if(this.visuallyDisabled===e){let e;(e=this.getNextBlock())==null||e.updateDisabled()}else{this.applyColour(),this.visuallyDisabled=e;for(let e of this.getChildren(!1))e.updateDisabled()}}setWarningText(t,n=``){if(n)this.warningTextDb.has(n)&&(clearTimeout(this.warningTextDb.get(n)),this.warningTextDb.delete(n));else{for(var r of this.warningTextDb.values())clearTimeout(r);this.warningTextDb.clear()}if(this.workspace.isDragging())this.warningTextDb.set(n,setTimeout(()=>{this.isDeadOrDying()||(this.warningTextDb.delete(n),this.setWarningText(t,n))},100));else if(this.isInFlyout&&(t=null),r=this.getIcon(Rm.TYPE),t){let i=this.getSurroundParent(),a=null;for(;i;)i.isCollapsed()&&(a=i),i=i.getSurroundParent();a&&a.setWarningText(e.Msg$$module$build$src$core$msg.COLLAPSED_WARNINGS_WARNING,Bm.COLLAPSED_WARNING_ID),r?r.addMessage(t,n):this.addIcon(new Rm(this).addMessage(t,n))}else r&&(n?(r.addMessage(``,n),r.getText()||this.removeIcon(Rm.TYPE)):this.removeIcon(Rm.TYPE))}setMutator(t){this.removeIcon(e.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE),t&&this.addIcon(t)}addIcon(t){return super.addIcon(t),t instanceof e.MutatorIcon$$module$build$src$core$icons$mutator_icon&&(this.mutator=t),t.initView(this.createIconPointerDownListener(t)),t.applyColour(),t.updateEditable(),this.queueRender(),t}createIconPointerDownListener(t){return n=>{!this.isDeadOrDying()&&(n=this.workspace.getGesture(n))&&(this.bringToFront(),n.setStartIcon(t),e.getFocusManager$$module$build$src$core$focus_manager().focusNode(t))}}removeIcon(t){let n=super.removeIcon(t);return t.equals(e.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE)&&(this.mutator=null),this.queueRender(),n}setDisabledReason(e,t){let n=this.isEnabled();super.setDisabledReason(e,t),this.isEnabled()===n||this.getInheritedDisabled()||this.updateDisabled()}setDeletable(e){super.setDeletable(e),e?k(this.svgGroup,`blocklyNotDeletable`):O(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,n;(n=(t=this.pathObject).setStyle)==null||n.call(t,e.style),this.style=e.style,this.styleName_=e.name,this.applyColour()}setStyle(e){let t=this.workspace.getRenderer().getConstants().getBlockStyle(e);if(this.styleName_&&k(this.svgGroup,this.styleName_),t){this.hat=t.hat;let n,r;(r=(n=this.pathObject).setStyle)==null||r.call(n,t),this.colour_=t.colourPrimary,this.style=t,this.applyColour(),O(this.svgGroup,e),this.styleName_=e}else throw Error(`Invalid style name: `+e)}getStyle(){return this.style}bringToFront(t=!1){let n=e.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode(),r=this;if(!r.isDeadOrDying()){do{let e=r.getSvgRoot(),n=e.parentNode,i=n.childNodes;if(i[i.length-1]!==e&&n.appendChild(e),t)break;r=r.getParent()}while(r);n&&e.getFocusManager$$module$build$src$core$focus_manager().focusNode(n)}}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 n=this.inputList[t].connection;n&&(n.setTracking(e),(n=n.targetBlock())&&n.setConnectionTracking(e))}}getConnections_(e){let 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 e=0,n;n=this.inputList[e];e++)n.connection&&t.push(n.connection);return t}lastConnectionInStack(e){return super.lastConnectionInStack(e)}getMatchingConnection(e,t){return super.getMatchingConnection(e,t)}makeConnection_(e){return new dm(this,e)}getNextBlock(){return super.getNextBlock()}getPreviousBlock(){return super.getPreviousBlock()}bumpNeighbours(){let t=this.getRootBlock();if(!(this.isDeadOrDying()||this.workspace.isDragging()||t.isInFlyout))for(let n of this.getConnections_(!1)){if(n.isSuperior()){let e;(e=n.targetBlock())==null||e.bumpNeighbours()}for(let r of n.neighbours(e.config$$module$build$src$core$config.snapRadius))r.getSourceBlock().getRootBlock()!==t&&(n.isConnected()&&r.isConnected()||(n.isSuperior()?r.bumpAwayFrom(n,!1):n.bumpAwayFrom(r,!0)))}}scheduleSnapAndBump(){this.snapToGrid(),this.bumpNeighbours()}positionNearConnection(e,t,n){if(e.type===Y.NEXT_STATEMENT||e.type===Y.INPUT_VALUE){let r=t.x;t=t.y,r+=n.x-e.getOffsetInBlock().x,t+=n.y-e.getOffsetInBlock().y,this.moveBy(r,t)}}getChildren(e){return super.getChildren(e)}queueRender(){return nn(this)}render(){this.queueRender(),an()}renderEfficiently(){ze(),this.isCollapsed()&&this.updateCollapsed(),this.isEnabled()||this.updateDisabled(),this.workspace.getRenderer().render(this),this.tightenChildrenEfficiently(),Be()}tightenChildrenEfficiently(){for(let e of this.inputList){let t=e.connection;t&&t.tightenEfficiently()}this.nextConnection&&this.nextConnection.tightenEfficiently()}getHeightWidth(){let e=this.height,t=this.width;var n=this.getNextBlock();if(n){n=n.getHeightWidth();let r=this.workspace.getRenderer().getConstants().NOTCH_HEIGHT;e+=n.height-r,t=Math.max(t,n.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(){let e=Object.assign({},{kind:`BLOCK`},Gn(this)),t=new Set([`id`,`height`,`width`,`pinned`,`enabled`]),n=function(e){for(let r in e)t.has(r)?delete e[r]:typeof e[r]==`object`&&n(e[r])};return n(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(),this.workspace.scrollBoundsIntoView(this.getBoundingRectangleWithoutChildren())}onNodeBlur(){this.unselect()}canBeFocused(){return!0}};Bm.INLINE=-1,Bm.COLLAPSED_WARNING_ID=`TEMP_COLLAPSED_WARNING_`;var Vm={};Vm.BlockSvg=Bm;var Hm=class{constructor(){}onDragEnter(e){}onDragOver(e){}onDragExit(e){}onDrop(e){}getClientRect(){return null}shouldPreventMove(e){return!1}},Um={};Um.DragTarget=Hm;var Wm={};Wm.isDeletable=_o;var Gm=class extends Hm{constructor(){super(),this.wouldDelete_=!1}wouldDelete(e){return e instanceof Bm?(e=!e.getParent()&&e.isDeletable(),this.updateWouldDelete_(e)):this.updateWouldDelete_(_o(e)&&e.isDeletable()),this.wouldDelete_}updateWouldDelete_(e){this.wouldDelete_=e}},Km={};Km.DeleteArea=Gm;var qm=class{constructor(e,t){this.element=e,this.type=t}getElement(){return this.element}getType(){return this.type}},Jm={};Jm.FlyoutItem=qm;var Ym=class{constructor(e){this.workspace_=e}getDimensionsPx_(e){let t=0,n=0;return e&&(t=e.getWidth(),n=e.getHeight()),new z(t,n)}getFlyoutMetrics(e){return e=this.getDimensionsPx_(this.workspace_.getFlyout(e)),{width:e.width,height:e.height,position:this.workspace_.toolboxPosition}}getToolboxMetrics(){let 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,n=this.getToolboxMetrics(),r=this.getFlyoutMetrics(),i=!!this.workspace_.getToolbox();var a;let o=!((a=this.workspace_.getFlyout())!=null&&a.autoClose);a=i?n.position:r.position;let s=a===B.TOP;return a===B.LEFT&&(i&&(e+=n.width),o&&(e+=r.width)),s&&(i&&(t+=n.height),o&&(t+=r.height)),{top:t,left:e}}getViewMetrics(e){e=e?this.workspace_.scale:1;let t=this.getSvgMetrics(),n=this.getToolboxMetrics(),r=this.getFlyoutMetrics(),i=!!this.workspace_.getToolbox();var a;let o=!((a=this.workspace_.getFlyout())!=null&&a.autoClose);a=i?n.position:r.position;let s=a===B.LEFT||a===B.RIGHT;return(a===B.TOP||a===B.BOTTOM)&&(i&&(t.height-=n.height),o&&(t.height-=r.height)),s&&(i&&(t.width-=n.width),o&&(t.width-=r.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;let 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{};let t=this.workspace_.isMovableHorizontally(),n=this.workspace_.isMovableVertically();e=e||this.getViewMetrics(!1);let r={};return n||(r.top=e.top,r.bottom=e.top+e.height),t||(r.left=e.left,r.right=e.left+e.width),r}getPaddedContent_(e,t){let n=t.top+t.height,r=t.left+t.width,i=e.width;e=e.height;let a=i/2,o=e/2;return{top:Math.min(t.top-o,n-e),bottom:Math.max(n+o,t.top+e),left:Math.min(t.left-a,r-i),right:Math.max(r+a,t.left+i)}}getScrollMetrics(e,t,n){e=e?this.workspace_.scale:1,t=t||this.getViewMetrics(!1);var r=n||this.getContentMetrics();n=this.getComputedFixedEdges_(t),t=this.getPaddedContent_(t,r),r=n.top===void 0?t.top:n.top;let i=n.left===void 0?t.left:n.left;return{top:r/e,left:i/e,width:((n.right===void 0?t.right:n.right)-i)/e,height:((n.bottom===void 0?t.bottom:n.bottom)-r)/e}}getUiMetrics(){return{viewMetrics:this.getViewMetrics(),absoluteMetrics:this.getAbsoluteMetrics(),toolboxMetrics:this.getToolboxMetrics()}}getMetrics(){let e=this.getToolboxMetrics(),t=this.getFlyoutMetrics(!0),n=this.getSvgMetrics(),r=this.getAbsoluteMetrics(),i=this.getViewMetrics(),a=this.getContentMetrics(),o=this.getScrollMetrics(!1,i,a);return{contentHeight:a.height,contentWidth:a.width,contentTop:a.top,contentLeft:a.left,scrollHeight:o.height,scrollWidth:o.width,scrollTop:o.top,scrollLeft:o.left,viewHeight:i.height,viewWidth:i.width,viewTop:i.top,viewLeft:i.left,absoluteTop:r.top,absoluteLeft:r.left,svgHeight:n.height,svgWidth:n.width,toolboxWidth:e.width,toolboxHeight:e.height,toolboxPosition:e.position,flyoutWidth:t.width,flyoutHeight:t.height}}};t(P.METRICS_MANAGER,uc,Ym);var Xm={};Xm.MetricsManager=Ym;var Zm=class extends Ym{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){let 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,n){return t=n||this.getContentMetrics(),n=this.flyout_.MARGIN*this.workspace_.scale,e=e?this.workspace_.scale:1,{height:(t.height+2*n)/e,width:(t.width+t.left+n)/e,top:0,left:0}}},Qm={};Qm.FlyoutMetricsManager=Zm;var $m=class{constructor(e,t,n,r){this.workspace=e,this.targetWorkspace=t,this.isFlyoutLabel=r,this.height=this.width=0,this.cursorSvg=this.svgText=null,this.text=n.text,this.position=new I(0,0),this.callbackKey=n.callbackKey||n.callbackkey,this.cssClass=n[`web-class`]||null,this.info=n,e=this.isFlyoutLabel?`blocklyFlyoutLabel`:`blocklyFlyoutButton`,this.cssClass&&(e+=` `+this.cssClass),this.id=ne(),this.svgGroup=D(L.G,{id:this.id,class:e},this.workspace.getCanvas());let i;this.isFlyoutLabel||(i=D(L.RECT,{class:`blocklyFlyoutButtonShadow`,rx:$m.BORDER_RADIUS,ry:$m.BORDER_RADIUS,x:1,y:1},this.svgGroup)),e=D(L.RECT,{class:this.isFlyoutLabel?`blocklyFlyoutLabelBackground`:`blocklyFlyoutButtonBackground`,rx:$m.BORDER_RADIUS,ry:$m.BORDER_RADIUS},this.svgGroup),t=D(L.TEXT,{class:this.isFlyoutLabel?`blocklyFlyoutLabelText`:`blocklyText`,x:0,y:0,"text-anchor":`middle`},this.svgGroup),n=Ti(this.text),this.workspace.RTL&&(n+=``),t.textContent=n,this.isFlyoutLabel&&(this.svgText=t,this.workspace.getThemeManager().subscribe(this.svgText,`flyoutForegroundColour`,`fill`)),r=_t(t,`fontSize`);let a=_t(t,`fontWeight`),o=_t(t,`fontFamily`);if(this.width=Ue(t,r,a,o),n=We(n,r,a,o),this.height=this.height||n.height,!this.isFlyoutLabel){this.width+=2*$m.TEXT_MARGIN_X,this.height+=2*$m.TEXT_MARGIN_Y;let e;(e=i)==null||e.setAttribute(`width`,String(this.width));let t;(t=i)==null||t.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-n.height/2+n.baseline)),this.updateTransform(),this.onMouseDownWrapper=g(this.svgGroup,`pointerdown`,this,this.onMouseDown),this.onMouseUpWrapper=g(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,n){this.moveTo(this.position.x+e,this.position.y+t)}isLabel(){return this.isFlyoutLabel}getPosition(){return this.position}getBoundingRectangle(){return new R(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(){v(this.onMouseDownWrapper),v(this.onMouseUpWrapper),this.svgGroup&&A(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){let t=this.targetWorkspace.getGesture(e),n=this.targetWorkspace.getFlyout();t&&n&&t.handleFlyoutStart(e,n)}getSvgRoot(){return this.svgGroup}getFocusableElement(){return this.svgGroup}getFocusableTree(){return this.workspace}onNodeFocus(){var e=this.getPosition();e=new R(e.y,e.y+this.height,e.x,e.x+this.width),this.workspace.scrollBoundsIntoView(e)}onNodeBlur(){}canBeFocused(){return!0}};$m.TEXT_MARGIN_X=5,$m.TEXT_MARGIN_Y=2,$m.BORDER_RADIUS=4,ft(`
|
|
634
|
+
.blocklyFlyoutButton {
|
|
635
|
+
fill: #888;
|
|
636
|
+
cursor: default;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
.blocklyFlyoutButtonShadow {
|
|
640
|
+
fill: #666;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
@media (hover: hover) {
|
|
644
|
+
.blocklyFlyoutButton:hover {
|
|
645
|
+
fill: #aaa;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
.blocklyFlyoutButton:active {
|
|
650
|
+
fill: #aaa;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
.blocklyFlyoutLabel {
|
|
654
|
+
cursor: default;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
.blocklyFlyoutLabelBackground {
|
|
658
|
+
opacity: 0;
|
|
659
|
+
}
|
|
660
|
+
`);var eh={};eh.FlyoutButton=$m;var th=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 $m}},nh={};nh.FlyoutButtonNavigationPolicy=th;var rh=class{constructor(e,t){this.policy=e,this.flyout=t}getFirstChild(e){return null}getParent(e){return this.policy.getParent(e)}getNextSibling(e){let t=this.flyout.getContents();if(!t)return null;let n=t.findIndex(t=>t.getElement()===e);return n===-1?null:(n++,n>=t.length&&(n=0),t[n].getElement())}getPreviousSibling(e){let t=this.flyout.getContents();if(!t)return null;let n=t.findIndex(t=>t.getElement()===e);return n===-1?null:(n--,n<0&&(n=t.length-1),t[n].getElement())}isNavigable(e){return this.policy.isNavigable(e)}isApplicable(e){return this.policy.isApplicable(e)}},ih={};ih.FlyoutNavigationPolicy=rh;var ah=class{constructor(e,t){this.gap=e,this.axis=t,this.y=this.x=0}getBoundingRectangle(){switch(this.axis){case`x`:return new R(this.y,this.y,this.x,this.x+this.gap);case`y`:return new R(this.y,this.y+this.gap,this.x,this.x)}}moveBy(e,t,n){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}},oh={};oh.FlyoutSeparator=ah;var sh=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 ah}},ch={};ch.FlyoutSeparatorNavigationPolicy=sh;var lh=class{getFirstChild(e){return e.getEditor()}getParent(e){return e.getOwner()??null}getNextSibling(e){return null}getPreviousSibling(e){return null}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof Gp}},uh={};uh.BlockCommentNavigationPolicy=lh;var dh=class{getFirstChild(e){return vo(e,!0)[0]}getParent(e){var t;if((t=e.previousConnection)!=null&&t.targetBlock()){if(t=e.getSurroundParent())return t}else{let t;if((t=e.outputConnection)!=null&&t.targetBlock())return e.outputConnection.targetBlock()}return e.workspace}getNextSibling(e){let t;if((t=e.nextConnection)!=null&&t.targetBlock())return e.nextConnection?.targetBlock();let n;return(n=e.outputConnection)!=null&&n.targetBlock()?bo(e,1):e.getSurroundParent()?bo(e.getTopStackBlock(),1):this.getParent(e)instanceof j_?yo(e,1):null}getPreviousSibling(e){let t;if((t=e.previousConnection)!=null&&t.targetBlock())return e.previousConnection?.targetBlock();let n;return(n=e.outputConnection)!=null&&n.targetBlock()?bo(e,-1):this.getParent(e)instanceof j_?yo(e,-1):null}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof Bm}},fh={};fh.BlockNavigationPolicy=dh,fh.navigateBlock=bo,fh.navigateStacks=yo;var ph=class{getFirstChild(e){return null}getParent(e){return e.getCommentView().workspace.getCommentById(e.getCommentView().commentId)}getNextSibling(e){let t=e.getCommentView().getCommentBarButtons();return e=t.indexOf(e),e>=0&&e+1<t.length?t[e+1]:null}getPreviousSibling(e){let t=e.getCommentView().getCommentBarButtons();return e=t.indexOf(e),e>0?t[e-1]:null}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof Kf}},mh={};mh.CommentBarButtonNavigationPolicy=ph;var hh=class{getFirstChild(e){return null}getParent(e){return null}getNextSibling(e){return null}getPreviousSibling(e){return null}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof Qf}},gh={};gh.CommentEditorNavigationPolicy=hh;var _h=class{getFirstChild(e){return e.getParentInput()?e.targetConnection:null}getParent(e){return e.getSourceBlock()}getNextSibling(e){if(e.getParentInput())return bo(e,1);if(e.type===Y.NEXT_STATEMENT){let n=e.targetConnection;var t=e.getSourceBlock();return!n&&t.getRootBlock().lastConnectionInStack(!1)===e?(e=t.workspace.getTopBlocks(!0),t=e.indexOf(t.getRootBlock())+1,t>=e.length&&(t=0),t=e[t],this.getParentConnection(t)??t):n}return e.getSourceBlock()}getPreviousSibling(e){if(e.getParentInput())return bo(e,-1);if(e.type===Y.PREVIOUS_STATEMENT||e.type===Y.OUTPUT_VALUE){let n=e.targetConnection&&!e.targetConnection.getParentInput()?e.targetConnection:null;var t=e.getSourceBlock();return!n&&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],t.lastConnectionInStack(!1)??t):n}return e.type===Y.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 dm}},vh={};vh.ConnectionNavigationPolicy=_h;var yh=class{getFirstChild(e){return null}getParent(e){return e.getSourceBlock()}getNextSibling(e){return bo(e,1)}getPreviousSibling(e){return bo(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 xf}},bh={};bh.FieldNavigationPolicy=yh;var xh={};xh.register=xo,xh.unregister=So;var Sh=17,Ch=160,wh=80,Th=class extends Np{constructor(e){super(e),this.sourceBlock=e,this.textInputBubble=null,this.text=``,this.bubbleSize=new z(Ch,wh),this.bubbleVisiblity=!1}getType(){return Th.TYPE}initView(e){this.svgRoot||(super.initView(e),D(L.CIRCLE,{class:`blocklyIconShape`,r:`8`,cx:`8`,cy:`8`},this.svgRoot),D(L.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),D(L.RECT,{class:`blocklyIconSymbol`,x:`6.8`,y:`10.78`,height:`2`,width:`2`},this.svgRoot),O(this.svgRoot,`blocklyCommentIcon`))}dispose(){super.dispose();let e;(e=this.textInputBubble)==null||e.dispose()}getWeight(){return Th.WEIGHT}getSize(){return new z(Sh,Sh)}applyColour(){super.applyColour();let e=this.sourceBlock.getColour(),t;(t=this.textInputBubble)==null||t.setColour(e)}updateEditable(){let 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){let t=this.workspaceLocation;super.onLocationChange(e),this.bubbleLocation&&(e=I.difference(this.workspaceLocation,t),this.bubbleLocation=I.sum(this.bubbleLocation,e)),e=this.getAnchorLocation();let n;(n=this.textInputBubble)==null||n.setAnchorLocation(e)}setText(e){let t=this.text;w(new(E(F.BLOCK_CHANGE))(this.sourceBlock,`comment`,null,t,e)),this.text=e;let n;(n=this.textInputBubble)==null||n.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){let 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){this.text=e.text??``,this.bubbleSize=new z(e.width??Ch,e.height??wh),this.bubbleVisiblity=e.pinned??!1,this.setBubbleVisible(this.bubbleVisiblity);let t=e.x,n=e.y;rn().then(()=>{t&&n&&(t=this.sourceBlock.workspace.RTL?this.sourceBlock.workspace.getWidth()-(t+this.bubbleSize.width):t,this.setBubbleLocation(new I(t,n)))})}onClick(){super.onClick(),this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}onTextChange(){if(this.textInputBubble){var e=this.textInputBubble.getText();this.text!==e&&(w(new(E(F.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){let t=this;return(0,N.asyncExecutePromiseGeneratorFunction)(function*(){t.bubbleVisiblity!==e&&(t.bubbleVisiblity=e,yield rn(),!t.sourceBlock.rendered||t.sourceBlock.isInFlyout||t.sourceBlock.isInsertionMarker()||(e?(t.sourceBlock.isEditable()?t.showEditableBubble():t.showNonEditableBubble(),t.applyColour()):t.hideBubble(),w(new(E(F.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 Gp(this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect(),this),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(){let e=Sh/2;return I.sum(this.workspaceLocation,new I(e,e))}getBubbleOwnerRect(){return this.sourceBlock.getBoundingRectangleWithoutChildren()}};Th.TYPE=G.COMMENT,Th.WEIGHT=3,xo(Th.TYPE,Th);var Eh={};Eh.CommentIcon=Th;var Dh=class{getFirstChild(t){return t instanceof e.MutatorIcon$$module$build$src$core$icons$mutator_icon&&t.bubbleIsVisible()&&e.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode()===t?t.getBubble()?.getWorkspace()??null:t instanceof Th&&t.bubbleIsVisible()&&e.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode()===t?t.getBubble()?.getEditor()??null:null}getParent(e){return e.getSourceBlock()}getNextSibling(e){return bo(e,1)}getPreviousSibling(e){return bo(e,-1)}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof Np}},Oh={};Oh.IconNavigationPolicy=Dh;var kh=class{getFirstChild(e){return e.view.getCommentBarButtons()[0]}getParent(e){return e.workspace}getNextSibling(e){return yo(e,1)}getPreviousSibling(e){return yo(e,-1)}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof sp}},Ah={};Ah.WorkspaceCommentNavigationPolicy=kh;var jh=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 j_}},Mh={};Mh.WorkspaceNavigationPolicy=jh;var Nh=class{constructor(){this.rules=[new dh,new yh,new _h,new jh,new Dh,new kh,new ph,new lh,new hh]}addNavigationPolicy(e){this.rules.push(e)}get(e){return this.rules.find(t=>t.isApplicable(e))}getFirstChild(e){let t=this.get(e)?.getFirstChild(e);if(!t)return null;let n;return(n=this.get(t))!=null&&n.isNavigable(t)?t:this.getFirstChild(t)||this.getNextSibling(t)}getParent(e){let t=this.get(e)?.getParent(e);if(!t)return null;let n;return(n=this.get(t))!=null&&n.isNavigable(t)?t:this.getParent(t)}getNextSibling(e){let t=this.get(e)?.getNextSibling(e);if(!t)return null;let n;return(n=this.get(t))!=null&&n.isNavigable(t)?t:this.getNextSibling(t)}getPreviousSibling(e){let t=this.get(e)?.getPreviousSibling(e);if(!t)return null;let n;return(n=this.get(t))!=null&&n.isNavigable(t)?t:this.getPreviousSibling(t)}},Ph={};Ph.Navigator=Nh;var Fh=class extends Nh{constructor(e){super(),this.rules.push(new th,new sh),this.rules=this.rules.map(t=>new rh(t,e))}},Ih={};Ih.FlyoutNavigator=Fh;var Lh=class{constructor(e,t,n,r,i){this.workspace=e,this.oldHostMetrics=this.corner_=this.vScroll=this.hScroll=null,t=t===void 0?!0:t,n=n===void 0?!0:n;let a=t&&n;t&&(this.hScroll=new Yl(e,!0,a,r,i)),n&&(this.vScroll=new Yl(e,!1,a,r,i)),a&&(this.corner_=D(L.RECT,{height:Yl.scrollbarThickness,width:Yl.scrollbarThickness,class:`blocklyScrollbarBackground`}),Le(this.corner_,e.getBubbleCanvas()))}dispose(){A(this.corner_),this.oldHostMetrics=this.corner_=null,this.hScroll&&(this.hScroll.dispose(),this.hScroll=null),this.vScroll&&(this.vScroll.dispose(),this.vScroll=null)}resize(){let t=this.workspace.getMetrics();if(t){var n=!1,r=!1;if(this.oldHostMetrics&&this.oldHostMetrics.viewWidth===t.viewWidth&&this.oldHostMetrics.viewHeight===t.viewHeight&&this.oldHostMetrics.absoluteTop===t.absoluteTop&&this.oldHostMetrics.absoluteLeft===t.absoluteLeft?(this.oldHostMetrics&&this.oldHostMetrics.scrollWidth===t.scrollWidth&&this.oldHostMetrics.viewLeft===t.viewLeft&&this.oldHostMetrics.scrollLeft===t.scrollLeft||(n=!0),this.oldHostMetrics&&this.oldHostMetrics.scrollHeight===t.scrollHeight&&this.oldHostMetrics.viewTop===t.viewTop&&this.oldHostMetrics.scrollTop===t.scrollTop||(r=!0)):r=n=!0,n||r){try{e.disable$$module$build$src$core$events$utils(),this.hScroll&&n&&this.hScroll.resize(t),this.vScroll&&r&&this.vScroll.resize(t)}finally{e.enable$$module$build$src$core$events$utils()}this.workspace.maybeFireViewportChangeEvent()}if(this.hScroll&&this.vScroll){if(!this.oldHostMetrics||this.oldHostMetrics.viewWidth!==t.viewWidth||this.oldHostMetrics.absoluteLeft!==t.absoluteLeft){let e;(e=this.corner_)==null||e.setAttribute(`x`,String(this.vScroll.position.x))}if(!this.oldHostMetrics||this.oldHostMetrics.viewHeight!==t.viewHeight||this.oldHostMetrics.absoluteTop!==t.absoluteTop){let e;(e=this.corner_)==null||e.setAttribute(`y`,String(this.hScroll.position.y))}}this.oldHostMetrics=t}}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,n){this.hScroll&&this.hScroll.set(e,!1),this.vScroll&&this.vScroll.set(t,!1),(n||n===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)}},Rh={};Rh.ScrollbarPair=Lh;var zh=`sep`,Bh=class{load(e,t){return e=new ah(0,t.horizontalLayout?`x`:`y`),new qm(e,zh)}gapForItem(e,t){return parseInt(String(e.gap))??t}disposeItem(e){}getType(){return zh}};t(P.FLYOUT_INFLATER,zh,Bh);var Vh={SEPARATOR_TYPE:zh};Vh.SeparatorFlyoutInflater=Bh;var Hh=class extends Gm{constructor(e){super(),this.horizontalLayout=!1,this.boundEvents=[],this.reflowWrapper=null,this.inhibitReflowWrapper=!1,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 j_(e),this.workspace_.setMetricsManager(new Zm(this.workspace_,this)),this.workspace_.internalIsFlyout=!0,this.workspace_.setVisible(this.visible),this.workspace_.setNavigator(new Fh(this)),this.id=re(),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_=D(e,{class:`blocklyFlyout`}),this.svgGroup_.style.display=`none`,this.svgBackground_=D(L.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 Lh(this.workspace_,this.horizontalLayout,!this.horizontalLayout,`blocklyFlyoutScrollbar`,this.SCROLLBAR_MARGIN),this.hide(),this.boundEvents.push(g(this.svgGroup_,`wheel`,this,this.wheel_,!1,{passive:!1})),this.boundEvents.push(g(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:Pl.ComponentWeight.FLYOUT_WEIGHT,capabilities:[Pl.Capability.AUTOHIDEABLE,Pl.Capability.DELETE_AREA,Pl.Capability.DRAG_TARGET]})}dispose(){this.hide(),this.targetWorkspace.getComponentManager().removeComponent(this.id);for(let e of this.boundEvents)v(e);this.boundEvents.length=0,this.workspace_&&(this.workspace_.getThemeManager().unsubscribe(this.svgBackground_),this.workspace_.dispose()),this.svgGroup_&&A(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){let t=e!==this.isVisible();this.visible=e,t&&(this.autoClose||this.targetWorkspace.recordDragTargets(),this.updateDisplay())}setContainerVisible(e){let 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,n,r){let i;(i=this.svgGroup_)==null||i.setAttribute(`width`,`${e}`);let a;(a=this.svgGroup_)==null||a.setAttribute(`height`,`${t}`),this.workspace_.setCachedParentSvgSize(e,t),this.svgGroup_&&Re(this.svgGroup_,`translate(`+n+`px,`+r+`px)`),(e=this.workspace_.scrollbar)&&(e.setOrigin(n,r),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(t){this.workspace_.setResizesEnabled(!1),e.setRecordUndo$$module$build$src$core$events$utils(!1),this.hide(),this.clearOldBlocks(),typeof t==`string`&&(t=this.getDynamicCategoryContents(t)),this.setVisible(!0),t=Pt(t),t=this.createFlyoutInfo(t),an(this.workspace_),this.setContents(t),this.layout_(t),this.horizontalLayout?this.height_=0:this.width_=0,this.reflow(),e.setRecordUndo$$module$build$src$core$events$utils(!0),this.workspace_.setResizesEnabled(!0),this.reflowWrapper=e=>{this.inhibitReflowWrapper||e.type!==F.BLOCK_CHANGE&&e.type!==F.BLOCK_FIELD_INTERMEDIATE_CHANGE||this.reflow()},this.workspace_.addChangeListener(this.reflowWrapper)}createFlyoutInfo(e){let t=[],n=this.horizontalLayout?this.GAP_X:this.GAP_Y;for(let r of e)`custom`in r&&(e=this.getDynamicCategoryContents(r.custom),e=Pt(e),t.push(...this.createFlyoutInfo(e))),e=r.kind.toLowerCase(),(e=this.getInflaterForType(e))&&(t.push(e.load(r,this)),(e=e.gapForItem(r,n))&&t.push(new qm(new ah(e,this.horizontalLayout?`x`:`y`),zh)));return this.normalizeSeparators(t)}normalizeSeparators(e){for(let t=e.length-1;t>0;t--){let n=e[t].getType().toLowerCase(),r=e[t-1].getType().toLowerCase();n===zh&&r===zh&&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(e=>{let t;(t=this.getInflaterForType(e.getType()))==null||t.disposeItem(e)});let e;(e=this.workspace_.getPotentialVariableMap())==null||e.clear()}onMouseDown(e){let t=this.targetWorkspace.getGesture(e);t&&t.handleFlyoutStart(e,this)}isBlockCreatable(e){return e.isEnabled()&&!this.getTargetWorkspace().isReadOnly()}createBlock(e){let t=this.targetWorkspace;if(!e.getSvgRoot())throw Error(`oldBlock is not rendered`);var n=this.serializeBlock(e);return t.setResizesEnabled(!1),n=tr(n,t,{recordUndo:!0}),this.positionNewBlock(e,n),t.hideChaff(),n}reflow(){this.inhibitReflowWrapper=!0,this.reflowInternal_(),this.inhibitReflowWrapper=!1}isScrollable(){return this.workspace_.scrollbar?this.workspace_.scrollbar.isVisible():!1}serializeBlock(e){return Gn(e)}positionNewBlock(e,t){let n=this.targetWorkspace;var r=n.getOriginOffsetInPixels(),i=this.workspace_.getOriginOffsetInPixels();e=e.getRelativeToSurfaceXY(),e.scale(this.workspace_.scale),i=I.sum(i,e),r=I.difference(i,r),r.scale(1/n.scale),t.moveTo(new I(r.x,r.y))}getInflaterForType(e){if(this.inflaters.has(e)){var t;return(t=this.inflaters.get(e))??null}return(t=o(P.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.`)}},Uh={};Uh.Flyout=Hh;var Wh={};Wh.hasContextMenu=Co;var Gh={};Gh.isDraggable=wo;var Kh=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)}},qh=new Kh,Jh={};Jh.KeyboardNavigationController=Kh,Jh.keyboardNavigationController=qh;var Yh=class{constructor(e){this.workspace=e,this.horizontalScrollEnabled=this.workspace.isMovableHorizontally(),this.verticalScrollEnabled=this.workspace.isMovableVertically(),this.startScrollXY_=new I(e.scrollX,e.scrollY)}startDrag(){}endDrag(e){this.drag(e)}drag(e){if(e=I.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 TypeError(`Invalid state.`)}},Xh={};Xh.WorkspaceDragger=Yh;var Zh=5,Qh=6,$h=class{constructor(e,t){this.creatorWorkspace=t,this.mouseDownXY=new I(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 I(0,0)}dispose(){f(),ci(),this.creatorWorkspace.clearGesture();for(let e of this.boundEvents)v(e);this.boundEvents.length=0}updateFromEvent(e){let t=new I(e.clientX,e.clientY);this.updateDragDelta(t)&&(this.updateIsDragging(e),d()),this.mostRecentEvent=e}updateDragDelta(t){return this.currentDragDeltaXY=I.difference(t,this.mouseDownXY),this.hasExceededDragRadius?!1:this.hasExceededDragRadius=I.magnitude(this.currentDragDeltaXY)>(this.flyout?e.config$$module$build$src$core$config.flyoutDragRadius:e.config$$module$build$src$core$config.dragRadius)}updateIsDraggingFromFlyout(){let t;if(!this.targetBlock||(t=this.flyout)==null||!t.isBlockCreatable(this.targetBlock))return!1;if(!this.flyout.targetWorkspace)throw Error(`Cannot update dragging from the flyout because the ' +
|
|
661
|
+
'flyout's target workspace is undefined`);return this.startWorkspace_=this.flyout.targetWorkspace,this.startWorkspace_.updateScreenCalculationsIfScrolled(),e.getGroup$$module$build$src$core$events$utils()||e.setGroup$$module$build$src$core$events$utils(!0),this.startBlock=null,this.targetBlock=this.flyout.createBlock(this.targetBlock),e.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.targetBlock),!0}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 Yh(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();let t=et();t&&wo(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(l(P.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,co(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.currentDropdownOwner=br(),this.startWorkspace_.hideChaff(!!this.flyout),this.startWorkspace_.markFocused(),this.mostRecentEvent=e,si(),b(e)?this.handleRightClick(e):(e.type.toLowerCase()===`pointerdown`&&e.pointerType!==`mouse`&&u(e,this),this.mouseDownXY=new I(e.clientX,e.clientY),this.bindMouseEvents(e),this.isEnding_||this.handleTouchStart(e)))}bindMouseEvents(e){this.boundEvents.push(g(document,`pointerdown`,null,this.handleStart.bind(this),!0)),this.boundEvents.push(g(document,`pointermove`,null,this.handleMove.bind(this),!0)),this.boundEvents.push(g(document,`pointerup`,null,this.handleUp.bind(this),!0)),this.boundEvents.push(g(document,`pointercancel`,null,this.handleUp.bind(this),!0)),e.preventDefault(),e.stopPropagation()}handleStart(e){this.isDragging()||(this.handleTouchStart(e),this.isMultiTouch()&&d())}handleMove(e){this.isDragging()&&p(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),d())}handleUp(e){if(this.isDragging()||this.handleTouchEnd(e),!this.isMultiTouch()||this.isDragging()){if(!p(e))return;if(this.updateFromEvent(e),d(),this.isEnding_){console.log(`Trying to end a gesture recursively.`);return}this.isEnding_=!0,this.dragger?(qh.setIsActive(!1),this.dragger.onDragEnd(e,this.currentDragDeltaXY)):this.workspaceDragger?(qh.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=m(e);this.cachedPoints.set(t,this.getTouchPoint(e));var n=Array.from(this.cachedPoints.keys());n.length===2&&(t=this.cachedPoints.get(n[0]),n=this.cachedPoints.get(n[1]),this.startDistance=I.distance(t,n),this.multiTouch=!0,e.preventDefault())}handleTouchMove(e){let t=m(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()),n=this.cachedPoints.get(t[0]);if(t=this.cachedPoints.get(t[1]),n=I.distance(n,t)/this.startDistance,this.previousScale>0&&this.previousScale<1/0){if(t=n-this.previousScale,t=t>0?t*Zh:t*Qh,!this.startWorkspace_)throw Error(`Cannot handle a pinch because the start workspace is undefined`);let r=this.startWorkspace_,i=ee(e,r.getParentSvg(),r.getInverseScreenCTM());r.zoom(i.x,i.y,t)}this.previousScale=n,e.preventDefault()}handleTouchEnd(e){e=m(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 I(e.pageX,e.pageY):null}isMultiTouch(){return this.multiTouch}cancel(){this.isEnding_||(d(),this.dragger?this.dragger.onDragEnd(this.mostRecentEvent,this.currentDragDeltaXY):this.workspaceDragger&&this.workspaceDragger.endDrag(this.currentDragDeltaXY),this.dispose())}handleRightClick(t){let n=e.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode();if(Co(n)){let e;(e=this.startWorkspace_)==null||e.hideChaff(!!this.flyout),n.showContextMenu(t)}t.preventDefault(),t.stopPropagation(),qh.setIsActive(!1),this.dispose()}handleWsStart(t,n){if(this.gestureHasStarted)throw Error(`Tried to call gesture.handleWsStart, but the gesture had already been started.`);this.setStartWorkspace(n),this.mostRecentEvent=t,this.targetBlock||this.startBubble||this.startComment||this.startIcon||e.getFocusManager$$module$build$src$core$focus_manager().focusNode(n),this.doStart(t)}fireWorkspaceClick(e){w(new(E(F.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.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.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)){e.getGroup$$module$build$src$core$events$utils()||e.setGroup$$module$build$src$core$events$utils(!0);var t=this.flyout.createBlock(this.targetBlock);t.snapToGrid(),t.bumpNeighbours(),e.getFocusManager$$module$build$src$core$focus_manager().focusNode(t)}}else{if(!this.startWorkspace_)throw Error(`Cannot do a block click because the start workspace is undefined`);t=new(E(F.CLICK))(this.startBlock,this.startWorkspace_.id,`block`),w(t)}e.setGroup$$module$build$src$core$events$utils(!1)}doWorkspaceClick(e){this.fireWorkspaceClick(this.startWorkspace_||this.creatorWorkspace)}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.startIcon||(this.startBlock=e,e.isInFlyout&&e!==e.getRootBlock()?this.setTargetBlock(e.getRootBlock()):this.setTargetBlock(e))}setTargetBlock(t){t.isShadow()?this.setTargetBlock(t.getParent()):(this.targetBlock=t,e.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.targetBlock),this.targetBlock.bringToFront())}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;let 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(){return this.workspaceDragger??this.dragger??null}isDragging(){return this.dragging}hasStarted(){return this.gestureHasStarted}static inProgress(){let e=Ye();for(let t=0,n;n=e[t];t++)if(n.currentGesture_)return!0;return!1}},eg={};eg.Gesture=$h;var tg=class{constructor(e,t){this.pattern=e,this.scale=1,this.spacing=t.spacing??0,this.length=t.length??1,this.line2=(this.line1=e.firstChild)&&this.line1.nextSibling,this.snapToGrid=t.snap??!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 n=t-this.length/2,r=t+this.length/2;t*=e,n*=e,r*=e,this.setLineAttributes(this.line1,e,n,r,t,t),this.setLineAttributes(this.line2,e,t,t,n,r)}setLineAttributes(e,t,n,r,i,a){e&&(e.setAttribute(`stroke-width`,`${t}`),e.setAttribute(`x1`,`${n}`),e.setAttribute(`y1`,`${i}`),e.setAttribute(`x2`,`${r}`),e.setAttribute(`y2`,`${a}`))}moveTo(e,t){this.pattern.setAttribute(`x`,`${e}`),this.pattern.setAttribute(`y`,`${t}`)}alignXY(e){var t=this.getSpacing();let n=t/2,r=Math.round(Math.round((e.x-n)/t)*t+n);return t=Math.round(Math.round((e.y-n)/t)*t+n),r===e.x&&t===e.y?e:new I(r,t)}static createDom(e,t,n,r){if(e=D(L.PATTERN,{id:`blocklyGridPattern`+e,patternUnits:`userSpaceOnUse`},n),(t.length??1)>0&&(t.spacing??0)>0){D(L.LINE,{stroke:t.colour},e);let n;(n=t.length)!=null&&n&&D(L.LINE,{stroke:t.colour},e)}else D(L.LINE,{},e);return r&&r.style.setProperty(`--blocklyGridPattern`,`url(#${e.id})`),e}},ng={};ng.Grid=tg;var rg={};rg.isAutoHideable=To;var ig=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(zf),O(e,`blocklyBlockCanvas`),e=this.createLayer(Bf),O(e,`blocklyBubbleCanvas`)}createDragLayer(e){let t=D(L.SVG,{class:`blocklyBlockDragSurface`,xmlns:tl,"xmlns:html":nl,"xmlns:xlink":rl,version:`1.1`});return e.append(t),D(L.G,{},t)}createAnimationLayer(e){let t=D(L.SVG,{class:`blocklyAnimationLayer`,xmlns:tl,"xmlns:html":nl,"xmlns:xlink":rl,version:`1.1`});return e.append(t),D(L.G,{},t)}appendToAnimationLayer(e){let t=this.dragLayer?.getAttribute(`transform`);if(t){let e;(e=this.animationLayer)==null||e.setAttribute(`transform`,t)}let n;(n=this.animationLayer)==null||n.appendChild(e.getSvgRoot())}translateLayers(e,t){e=`translate(${e.x}, ${e.y}) scale(${t})`;let n;(n=this.dragLayer)==null||n.setAttribute(`transform`,e);for(let[,t]of this.layers)t.setAttribute(`transform`,e)}moveToDragLayer(t,n=!0){let r;(r=this.dragLayer)==null||r.appendChild(t.getSvgRoot()),n&&t.canBeFocused()&&e.getFocusManager$$module$build$src$core$focus_manager().focusNode(t)}moveOffDragLayer(t,n,r=!0){this.append(t,n),r&&t.canBeFocused()&&e.getFocusManager$$module$build$src$core$focus_manager().focusNode(t)}append(e,t){if(this.layers.has(t)||this.createLayer(t),e=e.getSvgRoot(),this.layers.get(t)?.lastChild!==e){let n;(n=this.layers.get(t))==null||n.appendChild(e)}}createLayer(e){let t=this.workspace.getSvgGroup(),n=D(L.G,{}),r=!1,i=[...this.layers].sort((e,t)=>e[0]-t[0]);for(let[a,o]of i)if(e<a){t.insertBefore(n,o),r=!0;break}return r||t.appendChild(n),this.layers.set(e,n),n}hasLayer(e){return e===this.dragLayer||new Set(this.layers.values()).has(e)}getBlockLayer(){return this.layers.get(zf)}getBubbleLayer(){return this.layers.get(Bf)}getDragLayer(){return this.dragLayer}},ag={};ag.LayerManager=ig;var og=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 Bm?e:e instanceof xf||e instanceof dm||e instanceof Np?e.getSourceBlock():null}getSourceBlock(){return this.getSourceBlockFromNode(this.getCurNode())}},sg={};sg.Marker=og;var cg=class extends og{constructor(e){super(),this.workspace=e,this.type=`cursor`,this.potentialNodes=null}next(){var e=this.getCurNode();return e?((e=this.getNextNode(e,e=>{let t;return e instanceof Bm&&!((t=e.outputConnection)!=null&&t.targetBlock())||e instanceof sp},!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,e=>{let t;return e instanceof Bm&&!((t=e.outputConnection)!=null&&t.targetBlock())||e instanceof sp},!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;let t=this.getNextNode(e,()=>!0,!0);return e=this.getNextNode(e,e=>{let t;return e instanceof Bm&&!((t=e.outputConnection)!=null&&t.targetBlock())},!0),t===e}getNextNodeImpl(e,t,n=new Set){if(!e||n.has(e))return null;let r=this.workspace.getNavigator().getFirstChild(e)||this.workspace.getNavigator().getNextSibling(e);for(var i=e;i&&!r&&(i=this.workspace.getNavigator().getParent(i),i);)r=this.workspace.getNavigator().getNextSibling(i);return t(r)?r:r?(n.add(e),this.getNextNodeImpl(r,t,n)):null}getNextNode(e,t,n){return!e||!n&&this.getLastNode()===e?null:this.getNextNodeImpl(e,t)}getPreviousNodeImpl(e,t,n=new Set){if(!e||n.has(e))return null;let r=this.getRightMostChild(this.workspace.getNavigator().getPreviousSibling(e),e)||this.workspace.getNavigator().getParent(e);return t(r)?r:r?(n.add(e),this.getPreviousNodeImpl(r,t,n)):null}getPreviousNode(e,t,n){return!e||!n&&this.getFirstNode()===e?null:this.getPreviousNodeImpl(e,t)}getRightMostChild(e,t){if(!e)return e;let n=this.workspace.getNavigator().getFirstChild(e);if(!n||n===t)return e;for(e=n;e&&e!==t;e=this.workspace.getNavigator().getNextSibling(n))n=e;return this.getRightMostChild(n,t)}preDelete(e){var t=this.getCurNode();t=t?[t]:[];var n;let r=(n=e.previousConnection)?.targetConnection??e.outputConnection?.targetConnection;r&&t.push(r),(n=e.getNextBlock())&&t.push(n),(e=e.getParent())&&t.push(e),t.push(this.workspace),this.potentialNodes=t}postDelete(){let e=this.potentialNodes;if(this.potentialNodes=null,!e)throw Error(`must call preDelete first`);for(let t of e){let e;if((e=this.getSourceBlockFromNode(t))==null||!e.disposed){this.setCurNode(t);return}}throw Error(`no valid nodes in this.potentialNodes`)}getCurNode(){return e.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode()}setCurNode(t){e.getFocusManager$$module$build$src$core$focus_manager().focusNode(t)}getFirstNode(){return this.workspace.getNavigator().getFirstChild(this.workspace)}getLastNode(){let e=this.getFirstNode();return this.getPreviousNode(e,()=>!0,!0)}};t(P.CURSOR,uc,cg);var lg={};lg.LineCursor=cg;var ug=class{constructor(e){this.workspace=e,this.markers=new Map,this.cursor=new cg(this.workspace)}registerMarker(e,t){this.markers.has(e)&&this.unregisterMarker(e),this.markers.set(e,t)}unregisterMarker(e){let 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(){let e=Object.keys(this.markers);for(let t=0,n;n=e[t];t++)this.unregisterMarker(n);this.markers.clear(),this.cursor.dispose()}};ug.LOCAL_MARKER=`local_marker_1`;var dg={};dg.MarkerManager=ug;var fg={};fg.CommentIcon=Th,fg.Icon=Np,fg.IconType=G,fg.MutatorIcon=e.MutatorIcon$$module$build$src$core$icons$mutator_icon,fg.WarningIcon=Rm,fg.exceptions=nm,fg.registry=xh;var pg={};pg.isProcedureBlock=Eo,e.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:
|
|
662
|
+
Blockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());`),null)}populateVariables(t){t=e.allUsedVarModels$$module$build$src$core$variables(t);for(let n=0;n<t.length;n++)this.getName(t[n].getId(),e.NameType$$module$build$src$core$names.VARIABLE)}populateProcedures(e){throw Error(`The implementation of populateProcedures should be monkey-patched in by blockly.ts`)}getName(t,n){let r=t;n===e.NameType$$module$build$src$core$names.VARIABLE&&(t=this.getNameForUserVariable(t))&&(r=t),t=r.toLowerCase();let i=n===e.NameType$$module$build$src$core$names.VARIABLE||n===e.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE?this.variablePrefix:``;this.db.has(n)||this.db.set(n,new Map);let a=this.db.get(n);return a.has(t)?i+a.get(t):(n=this.getDistinctName(r,n),a.set(t,n.substr(i.length)),n)}getUserNames(e){return(e=this.db.get(e)?.keys())?Array.from(e):[]}getDistinctName(t,n){t=this.safeName(t);let r=null;for(;this.dbReverse.has(t+(r??``))||this.reservedWords.has(t+(r??``));)r=r?r+1:2;return t+=r??``,this.dbReverse.add(t),(n===e.NameType$$module$build$src$core$names.VARIABLE||n===e.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE?this.variablePrefix:``)+t}safeName(t){return t?(t=encodeURI(t.replace(/ /g,`_`)).replace(/[^\w]/g,`_`),`0123456789`.includes(t[0])&&(t=`my_`+t)):t=e.Msg$$module$build$src$core$msg.UNNAMED_KEY||`unnamed`,t}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`})(e.Names$$module$build$src$core$names||(e.Names$$module$build$src$core$names={})),e.NameType$$module$build$src$core$names=e.Names$$module$build$src$core$names.NameType,e.Names$$module$build$src$core$names.DEVELOPER_VARIABLE_TYPE=e.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE;var mg={NameType:e.NameType$$module$build$src$core$names};mg.Names=e.Names$$module$build$src$core$names;var hg={};hg.isObservable=Do;var gg=class extends Map{constructor(){super()}set(e,t){return this.get(e)===t?this:(super.set(e,t),Do(t)&&t.startPublishing(),this)}delete(e){let t=this.get(e);return e=super.delete(e),e&&(Do(t)&&t.stopPublishing(),e)}clear(){if(this.size)for(let e of this.keys())this.delete(e)}add(e){return this.set(e.getId(),e)}getProcedures(){return[...this.values()]}},_g={};_g.ObservableProcedureMap=gg;var vg=`PROCEDURE`,yg;e.DEFAULT_ARG$$module$build$src$core$procedures=`x`,yg={CATEGORY_NAME:vg,DEFAULT_ARG:e.DEFAULT_ARG$$module$build$src$core$procedures},yg.ObservableProcedureMap=gg,yg.allProcedures=Oo,yg.findLegalName=e.findLegalName$$module$build$src$core$procedures,yg.flyoutCategory=Po,yg.getCallers=Ro,yg.getDefinition=e.getDefinition$$module$build$src$core$procedures,yg.internalFlyoutCategory=No,yg.isNameUsed=jo,yg.isProcedureBlock=Eo,yg.mutateCallers=e.mutateCallers$$module$build$src$core$procedures,yg.mutatorOpenListener=Io,yg.rename=e.rename$$module$build$src$core$procedures;var Z=new 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}},bg=class{constructor(e){this.centerline=this.xPos=this.height=this.width=0,this.constants_=e,this.type=Z.NONE,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}},xg={};xg.Measurable=bg;var Sg=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=Z.ROW,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}getLastInput(){for(let e=this.elements.length-1;e>=0;e--){let t=this.elements[e];if(Z.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++){let t=this.elements[e];if(Z.isInRowSpacer(t))return t}return null}getLastSpacer(){for(let e=this.elements.length-1;e>=0;e--){let t=this.elements[e];if(Z.isInRowSpacer(t))return t}return null}},Cg={};Cg.Row=Sg;var wg=class extends Sg{constructor(e){super(e),this.hasNextConnection=!1,this.connection=null,this.baseline=this.descenderHeight=0,this.type|=Z.BOTTOM_ROW}hasLeftSquareCorner(e){return!!e.outputConnection||!!e.getNextBlock()}hasRightSquareCorner(e){return!0}measure(){let e=0,t=0,n=0;for(let r=0;r<this.elements.length;r++){let i=this.elements[r];t+=i.width,Z.isSpacer(i)||(Z.isNextConnection(i)?n=Math.max(n,i.height):e=Math.max(e,i.height))}this.width=Math.max(this.minWidth,t),this.height=Math.max(this.minHeight,e)+n,this.descenderHeight=n,this.widthWithConnectedBlocks=this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}},Tg={};Tg.BottomRow=wg;var Eg=class extends bg{constructor(e,t){super(e),this.connectionModel=t,this.type|=Z.CONNECTION,this.shape=this.constants_.shapeFor(t),this.isDynamicShape=`isDynamic`in this.shape&&this.shape.isDynamic,this.highlighted=t.isHighlighted()}},Dg={};Dg.Connection=Eg;var Og=class extends Eg{constructor(e,t){super(e,t.connection),this.input=t,this.connectionOffsetY=this.connectionOffsetX=0,this.type|=Z.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}},kg={};kg.InputConnection=Og;var Ag=class extends Og{constructor(e,t){super(e,t),this.height=0,this.type|=Z.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}},jg={};jg.ExternalValueInput=Ag;var Mg=class extends bg{constructor(e,t,n){super(e),this.field=t,this.parentInput=n,this.isEditable=t.EDITABLE,this.flipRtl=t.getFlipRtl(),this.type|=Z.FIELD,e=this.field.getSize(),this.height=e.height,this.width=e.width}},Ng={};Ng.Field=Mg;var Pg=class extends bg{constructor(e){super(e),this.type|=Z.HAT,this.height=this.constants_.START_HAT.height,this.width=this.constants_.START_HAT.width,this.ascenderHeight=this.height}},Fg={};Fg.Hat=Pg;var Ig=class extends bg{constructor(e,t){super(e),this.icon=t,this.flipRtl=!1,this.type|=Z.ICON,e=t.getSize(),this.height=e.height,this.width=e.width}},Lg={};Lg.Icon=Ig;var Rg=class extends bg{constructor(e,t){super(e),this.type|=Z.SPACER|Z.IN_ROW_SPACER,this.width=t,this.height=this.constants_.SPACER_DEFAULT_HEIGHT}},zg={};zg.InRowSpacer=Rg;var Bg=class extends Og{constructor(e,t){super(e,t),this.type|=Z.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}},Vg={};Vg.InlineInput=Bg;var Hg=class extends Sg{constructor(e){super(e),this.connectedBlockWidths=0,this.type|=Z.INPUT_ROW}measure(){this.width=this.minWidth,this.height=this.minHeight;let e=0;for(let t=0;t<this.elements.length;t++){let n=this.elements[t];this.width+=n.width,Z.isInput(n)&&(Z.isStatementInput(n)?e+=n.connectedBlockWidth:Z.isExternalInput(n)&&n.connectedBlockWidth!==0&&(e+=n.connectedBlockWidth-n.connectionWidth)),Z.isSpacer(n)||(this.height=Math.max(this.height,n.height))}this.connectedBlockWidths=e,this.widthWithConnectedBlocks=this.width+e}endsWithElemSpacer(){return!this.hasExternalInput&&!this.hasStatement}},Ug={};Ug.InputRow=Hg;var Wg=class extends bg{constructor(e){super(e),this.type|=Z.JAGGED_EDGE,this.height=this.constants_.JAGGED_TEETH.height,this.width=this.constants_.JAGGED_TEETH.width}},Gg={};Gg.JaggedEdge=Wg;var Kg=class extends Eg{constructor(e,t){super(e,t),this.type|=Z.NEXT_CONNECTION,this.height=this.shape.height,this.width=this.shape.width}},qg={};qg.NextConnection=Kg;var Jg=class extends Eg{constructor(e,t){super(e,t),this.connectionOffsetX=0,this.type|=Z.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}},Yg={};Yg.OutputConnection=Jg;var Xg=class extends Eg{constructor(e,t){super(e,t),this.type|=Z.PREVIOUS_CONNECTION,this.height=this.shape.height,this.width=this.shape.width}},Zg={};Zg.PreviousConnection=Xg;var Qg=class extends bg{constructor(e,t){super(e),this.type=(t&&t!==`left`?Z.RIGHT_ROUND_CORNER:Z.LEFT_ROUND_CORNER)|Z.CORNER,this.width=this.constants_.CORNER_RADIUS,this.height=this.constants_.CORNER_RADIUS/2}},$g={};$g.RoundCorner=Qg;var e_=class extends Sg{constructor(e,t,n){super(e),this.height=t,this.width=n,this.precedesStatement=this.followsStatement=!1,this.widthWithConnectedBlocks=0,this.type|=Z.SPACER|Z.BETWEEN_ROW_SPACER,this.elements=[new Rg(this.constants_,n)]}measure(){}},t_={};t_.SpacerRow=e_;var n_=class extends bg{constructor(e,t){super(e),this.type=(t&&t!==`left`?Z.RIGHT_SQUARE_CORNER:Z.LEFT_SQUARE_CORNER)|Z.CORNER,this.width=this.height=this.constants_.NO_PADDING}},r_={};r_.SquareCorner=n_;var i_=class extends Og{constructor(e,t){super(e,t),this.type|=Z.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}},a_={};a_.StatementInput=i_;var o_=class extends Sg{constructor(e){super(e),this.ascenderHeight=this.capline=0,this.hasPreviousConnection=!1,this.connection=null,this.type|=Z.TOP_ROW}hasLeftSquareCorner(e){let t=(e.hat?e.hat===`cap`:this.constants_.ADD_START_HATS)&&!e.outputConnection&&!e.previousConnection,n=e.getPreviousBlock();return!!e.outputConnection||t||(n?n.getNextBlock()===e:!1)}hasRightSquareCorner(e){return!0}measure(){let e=0,t=0,n=0;for(let r=0;r<this.elements.length;r++){let i=this.elements[r];t+=i.width,Z.isSpacer(i)||(Z.isHat(i)?n=Math.max(n,i.ascenderHeight):e=Math.max(e,i.height))}this.width=Math.max(this.minWidth,t),this.height=Math.max(this.minHeight,e)+n,this.capline=this.ascenderHeight=n,this.widthWithConnectedBlocks=this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}},s_={};s_.TopRow=o_;var c_=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=Ja(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);let t=e.blockStyles;for(let e in t)this.blockStyles[e]=this.validatedBlockStyle_(t[e]);this.setDynamicProperties_(e)}setDynamicProperties_(e){this.setFontConstants_(e),this.setComponentConstants_(e),this.ADD_START_HATS=e.startHats===void 0?this.ADD_START_HATS:e.startHats}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=We(`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){let 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){let t={};return e&&Object.assign(t,e),e=Di(t.colourPrimary||`#000`),t.colourPrimary=e.hex,t.colourSecondary=t.colourSecondary?Di(t.colourSecondary).hex:this.generateSecondaryColour_(t.colourPrimary),t.colourTertiary=t.colourTertiary?Di(t.colourTertiary).hex:this.generateTertiaryColour_(t.colourPrimary),t.hat=t.hat||``,t}generateSecondaryColour_(e){return xi(`#fff`,e,.6)||e}generateTertiaryColour_(e){return xi(`#fff`,e,.3)||e}dispose(){this.embossFilter&&A(this.embossFilter),this.disabledPattern&&A(this.disabledPattern),this.debugFilter&&A(this.debugFilter),this.cssNode=null}makeJaggedTeeth(){let e=this.JAGGED_TEETH_HEIGHT,t=this.JAGGED_TEETH_WIDTH;return{height:e,width:t,path:Xa([j(t,e/4),j(-t*2,e/2),j(t,e/4)])}}makeStartHat(){let e=this.START_HAT_HEIGHT,t=this.START_HAT_WIDTH,n=Ka(`c`,[j(30,-e),j(70,-e),j(t,0)]);return{height:e*.75,width:t,path:n}}makePuzzleTab(){function e(e){e=e?-1:1;let r=-e;var i=n/2;let a=i+2.5,o=i+.5,s=j(-t,e*i);return i=j(t,e*i),Ka(`c`,[j(0,e*a),j(-t,r*o),s])+Ka(`s`,[j(t,r*2.5),i])}let t=this.TAB_WIDTH,n=this.TAB_HEIGHT,r=e(!0),i=e(!1);return{type:this.SHAPES.PUZZLE,width:t,height:n,pathDown:i,pathUp:r}}makeNotch(){function e(e){return Xa([j(e*r,n),j(e*3,0),j(e*r,-n)])}let t=this.NOTCH_WIDTH,n=this.NOTCH_HEIGHT,r=(t-3)/2,i=e(1),a=e(-1);return{type:this.SHAPES.NOTCH,width:t,height:n,pathLeft:i,pathRight:a}}makeInsideCorners(){let e=this.CORNER_RADIUS;return{width:e,height:e,pathTop:Za(`a`,`0 0,0`,e,j(-e,e)),pathBottom:Za(`a`,`0 0,0`,e,j(e,e))}}makeOutsideCorners(){let e=this.CORNER_RADIUS,t=Ja(0,e)+Za(`a`,`0 0,1`,e,j(e,-e)),n=Za(`a`,`0 0,1`,e,j(e,e)),r=Za(`a`,`0 0,1`,e,j(-e,-e));return{topLeft:t,topRight:n,bottomRight:Za(`a`,`0 0,1`,e,j(-e,e)),bottomLeft:r,rightHeight:e}}shapeFor(e){switch(e.type){case Y.INPUT_VALUE:case Y.OUTPUT_VALUE:return this.PUZZLE_TAB;case Y.PREVIOUS_STATEMENT:case Y.NEXT_STATEMENT:return this.NOTCH;default:throw Error(`Unknown connection type`)}}createDom(e,t,n,r){this.injectCSS_(t,n),this.defs=D(L.DEFS,{},e),e=D(L.FILTER,{id:`blocklyEmbossFilter`+this.randomIdentifier},this.defs),D(L.FEGAUSSIANBLUR,{in:`SourceAlpha`,stdDeviation:1,result:`blur`},e),t=D(L.FESPECULARLIGHTING,{in:`blur`,surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":`white`,result:`specOut`},e),D(L.FEPOINTLIGHT,{x:-5e3,y:-1e4,z:2e4},t),D(L.FECOMPOSITE,{in:`specOut`,in2:`SourceAlpha`,operator:`in`,result:`specOut`},e),D(L.FECOMPOSITE,{in:`SourceGraphic`,in2:`specOut`,operator:`arithmetic`,k1:0,k2:1,k3:1,k4:0},e),this.embossFilterId=e.id,this.embossFilter=e,e=D(L.PATTERN,{id:`blocklyDisabledPattern`+this.randomIdentifier,patternUnits:`userSpaceOnUse`,width:10,height:10},this.defs),D(L.RECT,{width:10,height:10,fill:`#aaa`},e),D(L.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(),r&&(r.style.setProperty(`--blocklyEmbossFilter`,`url(#${this.embossFilterId})`),r.style.setProperty(`--blocklyDisabledPattern`,`url(#${this.disabledPatternId})`),r.style.setProperty(`--blocklyDebugFilter`,`url(#${this.debugFilterId})`))}createDebugFilter(){if(!this.debugFilter){let e=D(L.FILTER,{id:`blocklyDebugFilter`+this.randomIdentifier,height:`160%`,width:`180%`,y:`-30%`,x:`-40%`},this.defs),t=D(L.FECOMPONENTTRANSFER,{result:`outBlur`},e);D(L.FEFUNCA,{type:`table`,tableValues:`0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1`},t),D(L.FEFLOOD,{"flood-color":`#ff0000`,"flood-opacity":.5,result:`outColor`},e),D(L.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);let n=t.join(`
|
|
663
|
+
`);this.cssNode?this.cssNode.firstChild.textContent=n:(t=document.createElement(`style`),t.id=e,e=document.createTextNode(n),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;`,`}`]}},l_={};l_.ConstantProvider=c_,l_.isDynamicShape=Bo,l_.isNotch=Ho,l_.isPuzzleTab=Vo;var u_=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_+`
|
|
664
|
+
`+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++){let 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_(){let e=this.info_.topRow,t=e.elements;this.positionPreviousConnection_(),this.outlinePath_+=Ja(e.xPos,this.info_.startY);for(let e=0,n;n=t[e];e++)Z.isLeftRoundedCorner(n)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topLeft:Z.isRightRoundedCorner(n)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topRight:Z.isPreviousConnection(n)?this.outlinePath_+=n.shape.pathLeft:Z.isHat(n)?this.outlinePath_+=this.constants_.START_HAT.path:Z.isSpacer(n)&&(this.outlinePath_+=M(`h`,n.width));this.outlinePath_+=M(`v`,e.height-e.ascenderHeight)}drawJaggedEdge_(e){this.outlinePath_+=this.constants_.JAGGED_TEETH.path+M(`v`,e.height-this.constants_.JAGGED_TEETH.height)}drawValueInput_(e){let t=e.getLastInput();this.positionExternalValueConnection_(e);let n=Bo(t.shape)?t.shape.pathDown(t.height):t.shape.pathDown;this.outlinePath_+=M(`H`,t.xPos+t.width)+n+M(`v`,e.height-t.connectionHeight)}drawStatementInput_(e){var t=e.getLastInput();if(t){var n=t.xPos+t.notchOffset+t.shape.width;t=t.shape.pathRight+M(`h`,-(t.notchOffset-this.constants_.INSIDE_CORNERS.width))+this.constants_.INSIDE_CORNERS.pathTop;var r=e.height-2*this.constants_.INSIDE_CORNERS.height;this.outlinePath_+=M(`H`,n)+t+M(`v`,r)+this.constants_.INSIDE_CORNERS.pathBottom+M(`H`,e.xPos+e.width),this.positionStatementInputConnection_(e)}}drawRightSideRow_(e){this.outlinePath_+=M(`V`,e.yPos+e.height)}drawBottom_(){let e=this.info_.bottomRow,t=e.elements;this.positionNextConnection_();let n=0,r=``;for(let i=t.length-1,a;a=t[i];i--)Z.isNextConnection(a)?r+=a.shape.pathRight:Z.isLeftSquareCorner(a)?r+=M(`H`,e.xPos):Z.isLeftRoundedCorner(a)?r+=this.constants_.OUTSIDE_CORNERS.bottomLeft:Z.isRightRoundedCorner(a)?(r+=this.constants_.OUTSIDE_CORNERS.bottomRight,n=this.constants_.OUTSIDE_CORNERS.rightHeight):Z.isSpacer(a)&&(r+=M(`h`,a.width*-1));this.outlinePath_+=M(`V`,e.baseline-n),this.outlinePath_+=r}drawLeft_(){var e=this.info_.outputConnection;if(this.positionOutputConnection_(),e){let t=e.connectionOffsetY+e.height;e=Bo(e.shape)?e.shape.pathUp(e.height):e.shape.pathUp,this.outlinePath_+=M(`V`,t)+e}this.outlinePath_+=`z`}drawInternals_(){for(let e=0,t;t=this.info_.rows[e];e++)for(let e=0,n;n=t.elements[e];e++)Z.isInlineInput(n)?this.drawInlineInput_(n):(Z.isIcon(n)||Z.isField(n))&&this.layoutField_(n)}layoutField_(e){let t=e.centerline-e.height/2,n=e.xPos;var r=``;this.info_.RTL&&(n=-(n+e.width),e.flipRtl&&(n+=e.width,r=`scale(-1 1)`)),Z.isIcon(e)?(r=e.icon,r.setOffsetInBlock(new I(n,t)),this.info_.isInsertionMarker&&r.hideForInsertionMarker()):(e=e.field.getSvgRoot(),e.setAttribute(`transform`,`translate(`+n+`,`+t+`)`+r),this.info_.isInsertionMarker&&e.setAttribute(`display`,`none`))}drawInlineInput_(e){let t=e.width,n=e.height,r=e.connectionOffsetY,i=e.connectionHeight+r;this.inlinePath_+=qa(e.xPos+e.connectionWidth,e.centerline-n/2)+M(`v`,r)+e.shape.pathDown+M(`v`,n-i)+M(`h`,t-e.connectionWidth)+M(`v`,-n)+`z`,this.positionInlineInputConnection_(e)}positionInlineInputConnection_(e){let t=e.centerline-e.height/2;if(e.connectionModel){let n=e.xPos+e.connectionWidth+e.connectionOffsetX;this.info_.RTL&&(n*=-1),e.connectionModel.setOffsetInBlock(n,t+e.connectionOffsetY)}}positionStatementInputConnection_(e){let t=e.getLastInput();if(t!=null&&t.connectionModel){let n=e.xPos+e.statementEdge+t.notchOffset;this.info_.RTL&&(n*=-1),t.connectionModel.setOffsetInBlock(n,e.yPos)}}positionExternalValueConnection_(e){let t=e.getLastInput();if(t&&t.connectionModel){let n=e.xPos+e.width;this.info_.RTL&&(n*=-1),t.connectionModel.setOffsetInBlock(n,e.yPos)}}positionPreviousConnection_(){let e=this.info_.topRow;if(e.connection){let t=e.xPos+e.notchOffset;e.connection.connectionModel.setOffsetInBlock(this.info_.RTL?-t:t,0)}}positionNextConnection_(){let e=this.info_.bottomRow;if(e.connection){let t=e.connection,n=t.xPos;t.connectionModel.setOffsetInBlock(this.info_.RTL?-n:n,e.baseline)}}positionOutputConnection_(){if(this.info_.outputConnection){let e=this.info_.startX+this.info_.outputConnection.connectionOffsetX;this.block_.outputConnection.setOffsetInBlock(this.info_.RTL?-e:e,this.info_.outputConnection.connectionOffsetY)}}updateConnectionHighlights(){for(let e of this.info_.rows)for(let t of e.elements){if(!(t instanceof Eg))continue;let e=this.drawConnectionHighlightPath(t);e&&(e.style.display=t.highlighted?``:`none`)}}drawConnectionHighlightPath(e){let t=e.connectionModel;e=t.type===Y.INPUT_VALUE||t.type===Y.OUTPUT_VALUE?this.getExpressionConnectionHighlightPath(e):this.getStatementConnectionHighlightPath(e);let n=t.getSourceBlock(),r;return(r=n.pathObject).addConnectionHighlight?.call(r,t,e,t.getOffsetInBlock(),n.RTL)}getExpressionConnectionHighlightPath(e){let t=``;return Bo(e.shape)?t=e.shape.pathDown(e.height):Vo(e.shape)&&(t=e.shape.pathDown),e=this.constants_.TAB_OFFSET_FROM_TOP,Ja(0,-e)+M(`v`,e)+t+M(`v`,e)}getStatementConnectionHighlightPath(e){if(!Ho(e.shape))throw Error(`Statement connections should have notch shapes`);let t=this.constants_.NOTCH_OFFSET_LEFT-this.constants_.CORNER_RADIUS;return Ja(-t,0)+M(`h`,t)+e.shape.pathLeft+M(`h`,t)}},d_={};d_.Drawer=u_;var f_=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 Jg(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 o_(this.constants_),this.bottomRow=new wg(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 Hg(this.constants_);this.inputRows.push(e);var t=this.block_.getIcons();for(let n=0,r;r=t[n];n++){let t=new Ig(this.constants_,r);this.isCollapsed&&!r.isShownWhenCollapsed()||e.elements.push(t)}t=void 0;for(let n=0,r;r=this.block_.inputList[n];n++)if(r.isVisible()){this.shouldStartNewRow_(r,t)&&(this.rows.push(e),e=new Hg(this.constants_),this.inputRows.push(e));for(let t=0,n;n=r.fieldRow[t];t++)e.elements.push(new Mg(this.constants_,n,r));this.addInput_(r,e),t=r}this.isCollapsed&&(e.hasJaggedEdge=!0,e.elements.push(new Wg(this.constants_))),(e.elements.length||e.hasDummyInput)&&this.rows.push(e),this.populateBottomRow_(),this.rows.push(this.bottomRow)}populateTopRow_(){var e=!!this.block_.previousConnection;let t=(this.block_.hat?this.block_.hat===`cap`:this.constants_.ADD_START_HATS)&&!this.outputConnection&&!e,n=this.topRow.hasLeftSquareCorner(this.block_)?n_:Qg;this.topRow.elements.push(new n(this.constants_)),t?(e=new Pg(this.constants_),this.topRow.elements.push(e)):e&&(this.topRow.hasPreviousConnection=!0,this.topRow.connection=new Xg(this.constants_,this.block_.previousConnection),this.topRow.elements.push(this.topRow.connection)),this.block_.inputList.length&&this.block_.inputList[0]instanceof bm&&!this.block_.isCollapsed()?this.topRow.minHeight=this.constants_.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT:this.topRow.minHeight=this.constants_.TOP_ROW_MIN_HEIGHT,n=this.topRow.hasRightSquareCorner(this.block_)?n_:Qg,this.topRow.elements.push(new n(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 bm?this.constants_.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT:this.constants_.BOTTOM_ROW_MIN_HEIGHT,this.bottomRow.hasLeftSquareCorner(this.block_)?this.bottomRow.elements.push(new n_(this.constants_)):this.bottomRow.elements.push(new Qg(this.constants_)),this.bottomRow.hasNextConnection&&(this.bottomRow.connection=new Kg(this.constants_,this.block_.nextConnection),this.bottomRow.elements.push(this.bottomRow.connection)),this.bottomRow.hasRightSquareCorner(this.block_)?this.bottomRow.elements.push(new n_(this.constants_,`right`)):this.bottomRow.elements.push(new Qg(this.constants_,`right`))}addInput_(t,n){this.isInline&&t instanceof e.ValueInput$$module$build$src$core$inputs$value_input?(n.elements.push(new Bg(this.constants_,t)),n.hasInlineInput=!0):t instanceof bm?(n.elements.push(new i_(this.constants_,t)),n.hasStatement=!0):t instanceof e.ValueInput$$module$build$src$core$inputs$value_input?(n.elements.push(new Ag(this.constants_,t)),n.hasExternalInput=!0):(t instanceof gm||t instanceof vm)&&(n.minHeight=Math.max(n.minHeight,t.getSourceBlock()&&t.getSourceBlock().isShadow()?this.constants_.DUMMY_INPUT_SHADOW_MIN_HEIGHT:this.constants_.DUMMY_INPUT_MIN_HEIGHT),n.hasDummyInput=!0),n.align===null&&(n.align=t.align)}shouldStartNewRow_(t,n){return n?n instanceof vm||t instanceof bm||n instanceof bm?!0:t instanceof e.ValueInput$$module$build$src$core$inputs$value_input||t instanceof gm||n instanceof e.ValueInput$$module$build$src$core$inputs$value_input?!this.isInline:!1:!1}addElemSpacing_(){for(let e=0,t;t=this.rows[e];e++){let e=t.elements;if(t.elements=[],t.startsWithElemSpacer()&&t.elements.push(new Rg(this.constants_,this.getInRowSpacing_(null,e[0]))),e.length){for(let n=0;n<e.length-1;n++){t.elements.push(e[n]);let r=this.getInRowSpacing_(e[n],e[n+1]);t.elements.push(new Rg(this.constants_,r))}t.elements.push(e[e.length-1]),t.endsWithElemSpacer()&&t.elements.push(new Rg(this.constants_,this.getInRowSpacing_(e[e.length-1],null)))}}}getInRowSpacing_(e,t){if(!e&&t&&Z.isStatementInput(t))return this.constants_.STATEMENT_INPUT_PADDING_LEFT;if(e&&Z.isInput(e)&&!t){if(Z.isExternalInput(e))return this.constants_.NO_PADDING;if(Z.isInlineInput(e))return this.constants_.LARGE_PADDING;if(Z.isStatementInput(e))return this.constants_.NO_PADDING}return e&&Z.isLeftSquareCorner(e)&&t&&(Z.isPreviousConnection(t)||Z.isNextConnection(t))?t.notchOffset:e&&Z.isLeftRoundedCorner(e)&&t&&(Z.isPreviousConnection(t)||Z.isNextConnection(t))?t.notchOffset-this.constants_.CORNER_RADIUS:e&&Z.isField(e)&&e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING}computeBounds_(){let e=0,t=0,n=0;for(let i=0,a;a=this.rows[i];i++){if(a.measure(),t=Math.max(t,a.width),a.hasStatement){var r=a.getLastInput();r=a.width-(r?.width??0),e=Math.max(e,r)}n=Math.max(n,a.widthWithConnectedBlocks)}this.statementEdge=e,this.width=t;for(let e=0,t;t=this.rows[e];e++)t.hasStatement&&(t.statementEdge=this.statementEdge);this.widthWithChildren=Math.max(t,n),this.outputConnection&&(this.startX=this.outputConnection.width,this.width+=this.outputConnection.width,this.widthWithChildren+=this.outputConnection.width)}alignRowElements_(){for(let t=0,n;n=this.rows[t];t++)if(n.hasStatement)this.alignStatementRow_(n);else{var e=n.width;e=this.getDesiredRowWidth_(n)-e,e>0&&this.addAlignmentPadding_(n,e),Z.isTopOrBottomRow(n)&&(n.widthWithConnectedBlocks=n.width)}}getDesiredRowWidth_(e){return this.width-this.startX}addAlignmentPadding_(t,n){let r=t.getFirstSpacer(),i=t.getLastSpacer();if((t.hasExternalInput||t.hasStatement)&&(t.widthWithConnectedBlocks+=n),t.align===e.Align$$module$build$src$core$inputs$align.LEFT&&i)i.width+=n;else if(t.align===e.Align$$module$build$src$core$inputs$align.CENTRE&&r&&i)r.width+=n/2,i.width+=n/2;else if(t.align===e.Align$$module$build$src$core$inputs$align.RIGHT&&r)r.width+=n;else if(i)i.width+=n;else return;t.width+=n}alignStatementRow_(e){let t=e.getLastInput();if(t){var n=e.width-t.width,r=this.statementEdge;n=r-n,n>0&&this.addAlignmentPadding_(e,n),n=e.width,r=this.getDesiredRowWidth_(e),t.width+=r-n,t.height=Math.max(t.height,e.height),e.width+=r-n,e.widthWithConnectedBlocks=Math.max(e.width,this.statementEdge+e.connectedBlockWidths)}}addRowSpacing_(){let 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 n=this.getSpacerRowHeight_(e,t);let r=this.getSpacerRowWidth_(e,t);return n=new e_(this.constants_,n,r),e.hasStatement&&(n.followsStatement=!0),t.hasStatement&&(n.precedesStatement=!0),n}getSpacerRowWidth_(e,t){return this.width-this.startX}getSpacerRowHeight_(e,t){return this.constants_.MEDIUM_PADDING}getElemCenterline_(e,t){return Z.isSpacer(t)?e.yPos+t.height/2:Z.isBottomRow(e)?(e=e.yPos+e.height-e.descenderHeight,Z.isNextConnection(t)?e+t.height/2:e-t.height/2):Z.isTopRow(e)?Z.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 n=0,r;r=e.elements[n];n++)Z.isSpacer(r)&&(r.height=e.height),r.xPos=t,r.centerline=this.getElemCenterline_(e,r),t+=r.width}finalize_(){let e=0,t=0;for(let n=0,r;r=this.rows[n];n++)r.yPos=t,r.xPos=this.startX,t+=r.height,e=Math.max(e,r.widthWithConnectedBlocks),this.recordElemPositions_(r);if(this.outputConnection&&this.block_.nextConnection){let t=this.block_.nextConnection.targetBlock();t&&(e=Math.max(e,t.getHeightWidth().width))}this.widthWithChildren=e+this.startX,this.height=t,this.startY=this.topRow.capline,this.bottomRow.baseline=t-this.bottomRow.descenderHeight}getMeasureableForConnection(e){if(this.outputConnection?.connectionModel===e)return this.outputConnection;for(let t of this.rows)for(let n of t.elements)if(n instanceof Eg&&n.connectionModel===e)return n;return null}},p_={};p_.RenderInfo=f_;var m_=class{constructor(e,t,n){this.connectionHighlights=new WeakMap,this.highlightOffsets=new WeakMap,this.constants=n,this.style=t,this.svgRoot=e,this.svgPath=D(L.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?O(this.svgRoot,e):k(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,n,r){return n=`translate(${n.x}, ${n.y})`+(r?` scale(-1 1)`:``),(r=this.connectionHighlights.get(e))?(r.setAttribute(`d`,t),r.setAttribute(`transform`,n),r):(t=D(L.PATH,{id:e.id,class:`blocklyHighlightedConnectionPath`,style:`display: none;`,d:t,transform:n},this.svgRoot),this.connectionHighlights.set(e,t),t)}removeConnectionHighlight(e){let t=this.connectionHighlights.get(e);t&&(A(t),this.connectionHighlights.delete(e))}},h_={};h_.PathObject=m_;var g_=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,n){this.constants_.createDom(e,this.name+`-`+t.name,`.`+this.getClassName()+`.`+t.getClassName(),n)}refreshDom(e,t,n){let r=this.getConstants();r.dispose(),this.constants_=this.makeConstants_(),this.overrides&&Object.assign(this.constants_,this.overrides),this.constants_.randomIdentifier=r.randomIdentifier,this.constants_.setTheme(t),this.constants_.init(),this.createDom(e,t,n)}dispose(){this.constants_&&this.constants_.dispose()}makeConstants_(){return new c_}makeRenderInfo_(e){return new f_(this,e)}makeDrawer_(e,t){return new u_(e,t)}makePathObject(e,t){return new m_(e,t,this.constants_)}getConstants(){return this.constants_}shouldHighlightConnection(e){return!0}orphanCanConnectAtEnd(e,t,n){return!!X.getConnectionForOrphanedConnection(e,n===Y.OUTPUT_VALUE?t.outputConnection:t.previousConnection)}render(e){let t=this.makeRenderInfo_(e);t.measure(),this.makeDrawer_(e,t).draw()}},__={};__.Renderer=g_;var v_={};v_.BottomRow=wg,v_.Connection=Eg,v_.ConstantProvider=c_,v_.Drawer=u_,v_.ExternalValueInput=Ag,v_.Field=Mg,v_.Hat=Pg,v_.Icon=Ig,v_.InRowSpacer=Rg,v_.InlineInput=Bg,v_.InputConnection=Og,v_.InputRow=Hg,v_.JaggedEdge=Wg,v_.Measurable=bg,v_.NextConnection=Kg,v_.OutputConnection=Jg,v_.PathObject=m_,v_.PreviousConnection=Xg,v_.RenderInfo=f_,v_.Renderer=g_,v_.RoundCorner=Qg,v_.Row=Sg,v_.SpacerRow=e_,v_.SquareCorner=n_,v_.StatementInput=i_,v_.TopRow=o_,v_.Types=Z,v_.init=Go,v_.register=Uo,v_.unregister=Wo;var y_=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())&&k(e,t),(t=this.theme.getClassName())&&O(e,t));for(let e=0,t;t=this.subscribedWorkspaces[e];e++)t.refreshTheme();for(let[n,r]of this.componentDB)for(let i of r){e=i.element,t=i.propertyName;let r=this.theme&&this.theme.getComponentStyle(n);e.style.setProperty(t,r||``)}for(let e of this.subscribedWorkspaces)e.hideChaff()}subscribeWorkspace(e){this.subscribedWorkspaces.push(e)}unsubscribeWorkspace(e){if(!dt(this.subscribedWorkspaces,e))throw Error(`Cannot unsubscribe a workspace that hasn't been subscribed.`)}subscribe(e,t,n){this.componentDB.has(t)||this.componentDB.set(t,[]),this.componentDB.get(t).push({element:e,propertyName:n}),t=this.theme&&this.theme.getComponentStyle(t),e.style.setProperty(n,t||``)}unsubscribe(e){if(e)for(let[t,n]of this.componentDB){for(let t=n.length-1;t>=0;t--)n[t].element===e&&n.splice(t,1);n.length||this.componentDB.delete(t)}}dispose(){this.subscribedWorkspaces.length=0,this.componentDB.clear()}},b_={};b_.ThemeManager=y_;var x_=`VARIABLE_DYNAMIC`,S_={CATEGORY_NAME:x_};S_.flyoutCategory=Xo,S_.flyoutCategoryBlocks=Qo,S_.internalFlyoutCategory=Yo,S_.onCreateVariableButtonClick_Colour=Jo,S_.onCreateVariableButtonClick_Number=qo,S_.onCreateVariableButtonClick_String=Ko;var C_=class{canConnect(e,t,n,r){return this.canConnectWithReason(e,t,n,r)===X.CAN_CONNECT}canConnectWithReason(e,t,n,r){let i=this.doSafetyChecks(e,t);return i===X.CAN_CONNECT?this.doTypeChecks(e,t)?n&&!this.doDragChecks(e,t,r||0)?X.REASON_DRAG_CHECKS_FAILED:X.CAN_CONNECT:X.REASON_CHECKS_FAILED:i}getErrorMessage(e,t,n){switch(e){case X.REASON_SELF_CONNECTION:return`Attempted to connect a block to itself.`;case X.REASON_DIFFERENT_WORKSPACES:return`Blocks not on same workspace.`;case X.REASON_WRONG_TYPE:return`Attempt to connect incompatible types.`;case X.REASON_TARGET_NULL:return`Target connection is null.`;case X.REASON_CHECKS_FAILED:return`Connection checks failed. `+(t+` expected `+t.getCheck()+`, found `+n.getCheck());case X.REASON_SHADOW_PARENT:return`Connecting non-shadow to shadow block.`;case X.REASON_DRAG_CHECKS_FAILED:return`Drag checks failed.`;case X.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 X.REASON_TARGET_NULL;let n,r,i;return e.isSuperior()?(n=e.getSourceBlock(),r=t.getSourceBlock(),i=t):(r=e.getSourceBlock(),n=t.getSourceBlock(),i=e,e=t),n===r?X.REASON_SELF_CONNECTION:i.type===sm[e.type]?n.workspace===r.workspace?n.isShadow()&&!r.isShadow()?X.REASON_SHADOW_PARENT:i.type===Y.OUTPUT_VALUE&&r.previousConnection&&r.previousConnection.isConnected()||i.type===Y.PREVIOUS_STATEMENT&&r.outputConnection&&r.outputConnection.isConnected()?X.REASON_PREVIOUS_AND_OUTPUT:X.CAN_CONNECT:X.REASON_DIFFERENT_WORKSPACES:X.REASON_WRONG_TYPE}doTypeChecks(e,t){if(e=e.getCheck(),t=t.getCheck(),!e||!t)return!0;for(let n=0;n<e.length;n++)if(t.includes(e[n]))return!0;return!1}doDragChecks(e,t,n){if(e.distanceFrom(t)>n||t.getSourceBlock().isInsertionMarker())return!1;switch(t.type){case Y.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(e,t);case Y.OUTPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isInsertionMarker()||e.isConnected())return!1;break;case Y.INPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isMovable()&&!t.targetBlock().isShadow())return!1;break;case Y.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!Sl.includes(t)}canConnectToPrevious_(e,t){return e.targetConnection||Sl.includes(t)?!1:t.targetConnection?(e=t.targetBlock(),e.isInsertionMarker()?!e.getPreviousBlock():!1):!0}};t(P.CONNECTION_CHECKER,uc,C_);var w_={};w_.ConnectionChecker=C_;var T_=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 gg,this.readOnly=!1,this.potentialVariableMap=null,this.id=re(),Xe(this),this.options=e||new wp({}),this.RTL=!!this.options.RTL,this.horizontalLayout=!!this.options.horizontalLayout,this.toolboxPosition=this.options.toolboxPosition,this.connectionChecker=new(l(P.CONNECTION_CHECKER,this.options,!0))(this),this.variableMap=new(this.getVariableMapClass())(this),this.setIsReadOnly(this.options.readOnly)}dispose(){this.listeners.length=0,this.clear(),Ze(this)}sortObjects(e,t){let n=e=>({getBoundingRectangle:()=>{let t=e.getRelativeToSurfaceXY();return new R(t.y,t.y,t.x,t.x)},moveBy:()=>{}});return this.sortByOrigin(n(e),n(t))}sortByOrigin(e,t){let n=Math.sin(hr(T_.SCAN_ANGLE))*(this.RTL?-1:1);return e=e.getBoundingRectangle().getOrigin(),t=t.getBoundingRectangle().getOrigin(),e.y+n*e.x-(t.y+n*t.x)}addTopBlock(e){this.topBlocks.push(e)}removeTopBlock(e){if(!dt(this.topBlocks,e))throw Error(`Block not present in workspace's list of top-most blocks.`)}getTopBlocks(e=!1){let 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){dt(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(e=>!e.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(!dt(this.topComments,e))throw Error(`Comment not present in workspace's list of top-most comments.`);this.commentDB.delete(e.id)}getTopComments(e=!1){let 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 n=0;n<t.length;n++)e.push(...t[n].getDescendants(!0))}else for(e=this.getTopBlocks(!1),t=0;t<e.length;t++)e.push(...e[t].getChildren(!1));return e.filter(e=>!e.isInsertionMarker())}clear(){this.isClearing=!0;try{let t=e.getGroup$$module$build$src$core$events$utils();for(t||e.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();e.setGroup$$module$build$src$core$events$utils(t),this.isFlyout||this.variableMap.clear(),this.potentialVariableMap&&this.potentialVariableMap.clear()}finally{this.isClearing=!1}}renameVariableById(e,t){Cn(`Blockly.Workspace.renameVariableById`,`v12`,`v13`,`Blockly.Workspace.getVariableMap().renameVariable`),(e=this.variableMap.getVariableById(e))&&this.variableMap.renameVariable(e,t)}createVariable(e,t,n){return Cn(`Blockly.Workspace.createVariable`,`v12`,`v13`,`Blockly.Workspace.getVariableMap().createVariable`),this.variableMap.createVariable(e,t??void 0,n??void 0)}getVariableUsesById(e){return Cn(`Blockly.Workspace.getVariableUsesById`,`v12`,`v13`,`Blockly.Variables.getVariableUsesById`),Wn(this,e)}deleteVariableById(t){Cn(`Blockly.Workspace.deleteVariableById`,`v12`,`v13`,`Blockly.Workspace.getVariableMap().deleteVariable`);let n=this.variableMap.getVariableById(t);n?e.deleteVariable$$module$build$src$core$variables(this,n):console.warn(`Can't delete non-existent variable: ${t}`)}getVariable(e,t){return Cn(`Blockly.Workspace.getVariable`,`v12`,`v13`,`Blockly.Workspace.getVariableMap().getVariable`),this.variableMap.getVariable(e,t)}getVariableById(e){return Cn(`Blockly.Workspace.getVariableById`,`v12`,`v13`,`Blockly.Workspace.getVariableMap().getVariableById`),this.variableMap.getVariableById(e)}getVariablesOfType(e){return Cn(`Blockly.Workspace.getVariablesOfType`,`v12`,`v13`,`Blockly.Workspace.getVariableMap().getVariablesOfType`),this.variableMap.getVariablesOfType(e??``)}getAllVariables(){return Cn(`Blockly.Workspace.getAllVariables`,`v12`,`v13`,`Blockly.Workspace.getVariableMap().getAllVariables`),this.variableMap.getAllVariables()}getAllVariableNames(){return Cn(`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?1/0:this.options.maxInstances[e])-this.getBlocksByType(e,!1).length:1/0}isCapacityAvailable(e){if(!this.hasBlockLimits())return!0;let t=0;for(let n in e){if(e[n]>this.remainingCapacityOfType(n))return!1;t+=e[n]}return!(t>this.remainingCapacity())}hasBlockLimits(){return this.options.maxBlocks!==1/0||!!this.options.maxInstances}getUndoStack(){return this.undoStack_}getRedoStack(){return this.redoStack_}undo(t){var n=t?this.redoStack_:this.undoStack_,r=t?this.undoStack_:this.redoStack_;let i=n.pop();if(i){for(var a=[i];n.length&&i.group&&i.group===n[n.length-1].group;){let e=n.pop();e&&a.push(e)}for(n=0;n<a.length;n++)r.push(a[n]);e.setRecordUndo$$module$build$src$core$events$utils(!1);try{for(r=0;r<a.length;r++)a[r].run(t)}finally{e.setRecordUndo$$module$build$src$core$events$utils(!0)}}}clearUndo(){this.undoStack_.length=0,this.redoStack_.length=0,Ae()}addChangeListener(e){return this.listeners.push(e),e}removeChangeListener(e){dt(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){return this.commentDB.get(e)??null}allInputsFilled(e){let t=this.getTopBlocks(!1);for(let n=0;n<t.length;n++)if(!t[n].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,t=this.options.parentWorkspace;return this.isFlyout?t&&t.options&&(e=t.options.parentWorkspace):t&&(e=t),e}static getById(e){return Je(e)}static getAll(){return Ye()}getVariableMapClass(){let e=l(P.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}};T_.SCAN_ANGLE=3;var E_={};E_.Workspace=T_;var D_=100,O_=class{constructor(e){this.parentWorkspace=e,this.sounds=new Map,this.lastSound=null,this.muted=!1,window.AudioContext&&(this.context=new AudioContext)}dispose(){this.sounds.clear();let e;(e=this.context)==null||e.close()}load(e,t){let n=this;return(0,N.asyncExecutePromiseGeneratorFunction)(function*(){if(e.length){var r=yield(yield fetch(e[0])).arrayBuffer(),i;(i=n.context)==null||i.decodeAudioData(r,e=>{n.sounds.set(t,e)})}})}play(e,t){let n=this;return(0,N.asyncExecutePromiseGeneratorFunction)(function*(){if(!n.muted&&t!==0&&n.context){var r=n.sounds.get(e);if(r){let e=new Date;if(!(n.lastSound!==null&&e.getTime()-n.lastSound.getTime()<D_)){n.lastSound=e,n.context.state===`suspended`&&(yield n.context.resume());var i=n.context.createBufferSource(),a=n.context.createGain();a.gain.value=t??1,a.connect(n.context.destination),i.buffer=r,i.connect(a),i.addEventListener(`ended`,()=>{i.disconnect(),a.disconnect()}),i.start()}}else n.parentWorkspace&&n.parentWorkspace.getAudioManager().play(e,t)}})}setMuted(e){this.muted=e}getMuted(){return this.muted}},k_={};k_.WorkspaceAudio=O_;var A_=20,j_=class extends T_{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 Nh,this.metricsManager=new(l(P.METRICS_MANAGER,e,!0))(this),this.getMetrics=e.getMetrics||this.metricsManager.getMetrics.bind(this.metricsManager),this.setMetrics=e.setMetrics||j_.setTopLevelWorkspaceMetrics,this.componentManager=new Pl,this.connectionDBList=Jp.init(this.connectionChecker),this.audioManager=new O_(e.parentWorkspace),this.grid=this.options.gridPattern?new tg(this.options.gridPattern,e.gridOptions):null,this.markerManager=new ug(this),yd&&wn&&this.registerToolboxCategoryCallback(gd,wn),S_&&Yo&&this.registerToolboxCategoryCallback(x_,Yo),yg&&No&&(this.registerToolboxCategoryCallback(vg,No),this.addChangeListener(Io)),this.addChangeListener(this.variableChangeCallback.bind(this)),this.themeManager_=this.options.parentWorkspace?this.options.parentWorkspace.getThemeManager():new y_(this,this.options.theme||Cp),this.themeManager_.subscribeWorkspace(this),this.renderer=Go(this.options.renderer||`geras`,this.getTheme(),this.options.rendererOverrides??void 0),this.cachedParentSvgSize=new z(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=Cp),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(e=>!!e.getStyleName())),this.refreshToolboxSelection(),this.toolbox&&this.toolbox.refreshTheme(),this.isVisible()&&this.setVisible(!0),e=new(E(F.THEME_CHANGE))(this.getTheme().name,this.id),w(e)}updateBlockStyles(e){for(let t=0,n;n=e[t];t++){let e=n.getStyleName();e&&n.setStyle(e)}}getInverseScreenCTM(){if(this.inverseScreenCTMDirty){let 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,n=0,r=1;(this.getCanvas().contains(e)||this.getBubbleCanvas().contains(e))&&(r=this.scale);do{let i=Ct(e);(e===this.getCanvas()||e===this.getBubbleCanvas())&&(r=1),t+=i.x*r,n+=i.y*r,e=e.parentNode}while(e&&e!==this.getParentSvg()&&e!==this.getInjectionDiv());return new I(t,n)}getCachedParentSvgSize(){let e=this.cachedParentSvgSize;return new z(e.width,e.height)}getOriginOffsetInPixels(){return wt(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(t,n){return this.injectionDiv||(this.injectionDiv=n??null),this.svgGroup_=D(L.G,{class:`blocklyWorkspace`,id:this.id}),n&&en(this.svgGroup_,ju.LABEL,e.Msg$$module$build$src$core$msg.WORKSPACE_ARIA_LABEL),t&&(this.svgBackground_=D(L.RECT,{height:`100%`,width:`100%`,class:t},this.svgGroup_),t===`blocklyMainBackground`&&this.grid?this.svgBackground_.style.fill=`var(--blocklyGridPattern)`:this.themeManager_.subscribe(this.svgBackground_,`workspaceBackgroundColour`,`fill`)),this.layerManager=new ig(this),this.svgBlockCanvas_=this.layerManager.getBlockLayer(),this.svgBubbleCanvas_=this.layerManager.getBubbleLayer(),this.isFlyout||(g(this.svgGroup_,`pointerdown`,this,this.onMouseDown,!1),this.dummyWheelListener=()=>{},document.body.addEventListener(`wheel`,this.dummyWheelListener,{passive:!0}),g(this.svgGroup_,`wheel`,this,this.onMouseWheel,!1,{passive:!1})),this.options.hasCategories&&(this.toolbox=new(l(P.TOOLBOX,this.options,!0))(this)),this.grid&&this.grid.update(this.scale),this.recordDragTargets(),(t=l(P.CURSOR,this.options))&&this.markerManager.setCursor(new t(this)),t=this.options.parentWorkspace===null,this.renderer.createDom(this.svgGroup_,this.getTheme(),t?this.getInjectionDiv():void 0),e.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_&&A(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){let e=this.getParentSvg();e&&e.parentNode&&A(e.parentNode)}this.resizeHandlerWrapper&&(v(this.resizeHandlerWrapper),this.resizeHandlerWrapper=null),this.dummyWheelListener&&(document.body.removeEventListener(`wheel`,this.dummyWheelListener),this.dummyWheelListener=null),e.getFocusManager$$module$build$src$core$focus_manager().isRegistered(this)&&e.getFocusManager$$module$build$src$core$focus_manager().unregisterTree(this)}addTrashcan(){this.trashcan=j_.newTrashcan(this);let 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 mu(this);let e=this.zoomControls_.createDom();this.svgGroup_.appendChild(e)}copyOptionsForFlyout(){return new wp({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){let t=this.copyOptionsForFlyout();return t.toolboxPosition=this.options.toolboxPosition,this.flyout=this.horizontalLayout?new(l(P.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(t):new(l(P.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();let e=this.componentManager.getComponents(Pl.Capability.POSITIONABLE,!0),t=this.getMetricsManager().getUiMetrics(),n=[];for(let r=0,i;i=e[r];r++){i.position(t,n);let e=i.getBoundingRectangle();e&&n.push(e)}this.scrollbar&&this.scrollbar.resize(),this.updateScreenCalculations()}updateScreenCalculationsIfScrolled(){let e=Et();I.equals(this.lastRecordedPageScroll,e)||(this.lastRecordedPageScroll=e,this.updateScreenCalculations())}getLayerManager(){return this.layerManager}getCanvas(){return this.layerManager.getBlockLayer()}setCachedParentSvgSize(e,t){let n=this.getParentSvg();e!=null&&(this.cachedParentSvgSize.width=e,n.setAttribute(`data-cached-width`,`${e}`)),t!=null&&(this.cachedParentSvgSize.height=t,n.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(je()){var e=this.scale,t=-this.scrollY,n=-this.scrollX;if(!(e===this.oldScale&&Math.abs(t-this.oldTop)<1&&Math.abs(n-this.oldLeft)<1)){var r=new(E(F.VIEWPORT_CHANGE))(t,n,e,this.id,this.oldScale);this.oldScale=e,this.oldTop=t,this.oldLeft=n,w(r)}}}translate(e,t){let n;(n=this.layerManager)==null||n.translateLayers(new I(e,t),this.scale);let r;(r=this.grid)==null||r.moveTo(e,t),this.maybeFireViewportChangeEvent()}getWidth(){let 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(){let e=this.getAllBlocks(!1);for(let t=e.length-1;t>=0;t--)e[t].queueRender();this.getTopBlocks().flatMap(e=>e.getDescendants(!1)).filter(e=>e.isInsertionMarker()).forEach(e=>e.queueRender())}highlightBlock(e,t){if(t===void 0){for(let e=0,t;t=this.highlightedBlocks[e];e++)t.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):dt(this.highlightedBlocks,e),e.setHighlighted(t))}variableChangeCallback(e){switch(e.type){case F.VAR_CREATE:case F.VAR_DELETE:case F.VAR_RENAME:case F.VAR_TYPE_CHANGE:this.refreshToolboxSelection()}}refreshToolboxSelection(){let e=this.isFlyout?this.targetWorkspace:this;e&&!e.currentGesture_&&e.toolbox&&e.toolbox.getFlyout()&&e.toolbox.refreshSelection()}recordDragTargets(){let e=this.componentManager.getComponents(Pl.Capability.DRAG_TARGET,!0);this.dragTargetAreas=[];for(let t=0,n;n=e[t];t++){let e=n.getClientRect();e&&this.dragTargetAreas.push({component:n,clientRect:e})}}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,n;n=this.dragTargetAreas[t];t++)if(n.clientRect.contains(e.clientX,e.clientY))return n.component;return null}onMouseDown(e){let t=this.getGesture(e);t&&t.handleWsStart(e,this)}startDrag(e,t){$i(this,e,t)}moveDrag(e){return ea(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(){let e=!!this.scrollbar;return this.isMovable()&&(!e||e&&this.scrollbar.canScrollHorizontally())}isMovableVertically(){let e=!!this.scrollbar;return this.isMovable()&&(!e||e&&this.scrollbar.canScrollVertically())}onMouseWheel(e){if($h.inProgress())e.preventDefault(),e.stopPropagation();else{var t=this.options.zoomOptions&&this.options.zoomOptions.wheel,n=this.options.moveOptions&&this.options.moveOptions.wheel;if(t||n){var r=te(e);if(Fc)var i=e.metaKey;t&&(e.ctrlKey||i||!n)?(r=-r.y/50,t=ee(e,this.getParentSvg(),this.getInverseScreenCTM()),this.zoom(t.x,t.y,r)):(t=this.scrollX-r.x,n=this.scrollY-r.y,e.shiftKey&&!r.x&&(t=this.scrollX-r.y,n=this.scrollY),this.scroll(t,n)),e.preventDefault()}}}getBlocksBoundingBox(){let e=this.getTopBoundedElements();if(!e.length)return new R(0,0,0,0);let t=e[0].getBoundingRectangle();for(let r=1;r<e.length;r++){var n=e[r];n.isInsertionMarker&&n.isInsertionMarker()||(n=n.getBoundingRectangle(),n.top<t.top&&(t.top=n.top),n.bottom>t.bottom&&(t.bottom=n.bottom),n.left<t.left&&(t.left=n.left),n.right>t.right&&(t.right=n.right))}return t}cleanUp(){this.setResizesEnabled(!1);let t=e.getGroup$$module$build$src$core$events$utils();t||e.setGroup$$module$build$src$core$events$utils(!0);var n=this.getTopBlocks(!0),r=n.filter(e=>e.isMovable());let i=n.filter(e=>!e.isMovable()).map(e=>e.getBoundingRectangle());n=function(e){for(let t of i)if(e.intersects(t))return t;return null};var a=0;let o=this.renderer.getConstants().MIN_BLOCK_HEIGHT;for(let e of r){for(r=e.getBoundingRectangle(),e.moveBy(-r.left,a-r.top,[`cleanup`]),e.snapToGrid(),r=e.getBoundingRectangle(),a=n(r);a!=null;)a=a.top+a.getHeight()+o,e.moveBy(0,a-r.top,[`cleanup`]),e.snapToGrid(),r=e.getBoundingRectangle(),a=n(r);a=e.getRelativeToSurfaceXY().y+e.getHeightWidth().height+o}e.setGroup$$module$build$src$core$events$utils(t),this.setResizesEnabled(!0)}showContextMenu(e){if(!this.isReadOnly()&&!this.isFlyout){var t=J.registry.getContextMenuOptions({workspace:this,focusedNode:this},e);this.configureContextMenu&&this.configureContextMenu(t,e);var n=e instanceof PointerEvent?new I(e.clientX,e.clientY):Ot(this,new I(5,5));Wi(e,t,this.RTL,this,n)}}updateToolbox(e){if(e=Mt(e)){if(!this.options.languageTree)throw Error(`Existing toolbox is null. Can't create new toolbox.`);if(Ft(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():($e(this),this.getParentSvg().focus({preventScroll:!0}))}zoom(e,t,n){n=this.options.zoomOptions.scaleSpeed**+n;let r=this.scale*n;if(this.scale!==r){r>this.options.zoomOptions.maxScale?n=this.options.zoomOptions.maxScale/this.scale:r<this.options.zoomOptions.minScale&&(n=this.options.zoomOptions.minScale/this.scale);var i=this.getCanvas().getCTM(),a=this.getParentSvg().createSVGPoint();a.x=e,a.y=t,a=a.matrixTransform(i.inverse()),e=a.x,t=a.y,i=i.translate(e*(1-n),t*(1-n)).scale(n),this.scrollX=i.e,this.scrollY=i.f,this.setScale(r)}}zoomCenter(e){var t=this.getMetrics();let n;this.flyout?(n=t.svgWidth?t.svgWidth/2:0,t=t.svgHeight?t.svgHeight/2:0):(n=t.viewWidth/2+t.absoluteLeft,t=t.viewHeight/2+t.absoluteTop),this.zoom(n,t,e)}zoomToFit(){if(this.isMovable()){var t=this.getMetrics(),n=t.viewWidth;t=t.viewHeight;var r=this.getBlocksBoundingBox(),i=A_*2,a=r.right-r.left+i;if(r=r.bottom-r.top+i,a){this.flyout&&(this.horizontalLayout?(t+=this.flyout.getHeight(),r+=this.flyout.getHeight()/this.scale):(n+=this.flyout.getWidth(),a+=this.flyout.getWidth()/this.scale)),n/=a,t/=r,e.disable$$module$build$src$core$events$utils();try{this.setScale(Math.min(n,t)),this.scrollCenter()}finally{e.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(){O(this.getCanvas(),`blocklyCanvasTransitioning`),O(this.getBubbleCanvas(),`blocklyCanvasTransitioning`)}endCanvasTransition(){k(this.getCanvas(),`blocklyCanvasTransitioning`),k(this.getBubbleCanvas(),`blocklyCanvasTransitioning`)}scrollCenter(){if(this.isMovable()){var e=this.getMetrics(),t=(e.scrollWidth-e.viewWidth)/2,n=(e.scrollHeight-e.viewHeight)/2;t=-t-e.scrollLeft,n=-n-e.scrollTop,this.scroll(t,n)}else console.warn(`Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.`)}centerOnBlock(e,t){if(this.isMovable()){var n=e?this.getBlockById(e):null;if(n){e=n.getRelativeToSurfaceXY(),n=t?{height:n.height,width:n.width}:n.getHeightWidth();var r=this.scale;t=(e.x+(this.RTL?-1:1)*n.width/2)*r,e=(e.y+n.height/2)*r,n=this.getMetrics(),this.scroll(-(t-n.viewWidth/2),-(e-n.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(){let e=e=>{if(e.isFlyout){let t=e.targetWorkspace?.getFlyout();if(t instanceof Hh)return t.getFlyoutScale()}return e.getScale()},t=(n,r)=>n.options.parentWorkspace&&n.options.parentWorkspace.getSvgGroup().contains(n.getSvgGroup())?t(n.options.parentWorkspace,r*e(n)):r*e(n);return t(this,1)}scroll(e,t){this.hideChaff(!0);let n=this.getMetrics();e=Math.min(e,-n.scrollLeft),t=Math.min(t,-n.scrollTop);let r=n.scrollTop+Math.max(0,n.scrollHeight-n.viewHeight);e=Math.max(e,-(n.scrollLeft+Math.max(0,n.scrollWidth-n.viewWidth))),t=Math.max(t,-r),this.scrollX=e,this.scrollY=t,this.scrollbar&&this.scrollbar.set(-(e+n.scrollLeft),-(t+n.scrollTop),!1),e+=n.absoluteLeft,t+=n.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){dt(this.topBoundedElements,e)}getTopBoundedElements(e=!1){let t=[].concat(this.topBoundedElements);return e&&t.sort(this.sortByOrigin.bind(this)),t}setResizesEnabled(e){let 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){return this.flyoutButtonCallbacks.get(e)??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;let t=e?.type===`pointerdown`,n;return t&&(n=this.currentGesture_)!=null&&n.hasStarted()&&(console.warn(`Tried to start the same gesture twice.`),this.currentGesture_.cancel()),!this.currentGesture_&&t&&(this.currentGesture_=new $h(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){oi(),Fi(this),Lr(),this.hideComponents(e)}hideComponents(e=!1){this.getComponentManager().getComponents(Pl.Capability.AUTOHIDEABLE,!0).forEach(t=>t.autoHide(e))}static setTopLevelWorkspaceMetrics(e){let 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&&O(this.injectionDiv,e)}removeClass(e){this.injectionDiv&&k(this.injectionDiv,e)}setIsReadOnly(e){super.setIsReadOnly(e),e?this.addClass(`blocklyReadOnly`):this.removeClass(`blocklyReadOnly`)}scrollBoundsIntoView(e,t=10){if(!$h.inProgress()){var n=this.getScale(),r=this.getMetricsManager().getViewMetrics(!0);if(r=new R(r.top,r.top+r.height,r.left,r.left+r.width),!(e.left>=r.left&&e.top>=r.top&&e.right<=r.right&&e.bottom<=r.bottom)){e=e.clone(),e.top-=t,e.bottom+=t,e.left-=t,e.right+=t;var i=t=0;e.left<r.left?t=this.RTL?Math.min(r.left-e.left,r.right-e.right):r.left-e.left:e.right>r.right&&(t=this.RTL?r.right-e.right:Math.max(r.right-e.right,r.left-e.left)),e.top<r.top?i=r.top-e.top:e.bottom>r.bottom&&(i=Math.max(r.bottom-e.bottom,r.top-e.top)),this.scroll(this.scrollX+t*n,this.scrollY+i*n)}}}getFocusableElement(){return this.svgGroup_}getFocusableTree(){return this.isMutator&&this.options.parentWorkspace||this}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}getRootFocusableNode(){return this}getRestoredFocusableNode(e){return e?null:(e=this.targetWorkspace?.getFlyout(),this.isFlyout&&e?e.getContents().find(e=>(e=e.getElement(),Ge(e)&&e.canBeFocused()))?.getElement()??null:this.getTopBlocks(!0)[0]??null)}getNestedTrees(){let t=this.getAllBlocks().map(e=>e.getIcons()).flat().filter(t=>t instanceof e.MutatorIcon$$module$build$src$core$icons$mutator_icon&&t.bubbleIsVisible()).map(e=>e.getBubble()?.getWorkspace()).filter(e=>!!e),n=this.getFlyout(!0);return n&&t.push(n.getWorkspace()),t}searchForWorkspaceComment(e){for(let t of this.getTopComments())if(t instanceof sp&&t.canBeFocused()&&t.getFocusableElement().id===e)return t}lookUpFocusableNode(e){var t;let n=(t=this.targetWorkspace)?.getFlyout();if(this.isFlyout&&n){for(var r of n.getContents())if(t=r.getElement(),Ge(t)&&t.canBeFocused()&&t.getFocusableElement().id===e)return t}if(r=e.indexOf(`_field_`),t=e.indexOf(`_connection_`),r!==-1){var i=e.substring(0,r);if(i=this.getBlockById(i)){for(var a of i.getFields())if(a.canBeFocused()&&a.getFocusableElement().id===e)return a}return null}if(t!==-1){if(i=e.substring(0,t),i=this.getBlockById(i)){for(let t of i.getConnections_(!0))if(t.id===e)return t}return null}if(a=Math.max(e.indexOf(Zf),e.indexOf(Jf),e.indexOf(ep)),a!==-1&&(a=e.substring(0,a),a=this.searchForWorkspaceComment(a))){if(e.indexOf(Zf)>-1)return a.getEditorFocusableNode();var o;return(o=a.view.getCommentBarButtons().find(t=>t.getFocusableElement().id.includes(e)))??null}if((o=this.getAllBlocks(!1).find(t=>t.getFocusableElement().id===e))||(o=this.searchForWorkspaceComment(e)))return o;o=this.getAllBlocks().map(e=>e.getIcons()).flat();for(i of o){if(i.canBeFocused()&&i.getFocusableElement().id===e)return i;if(mr(i)){if((o=i.getBubble())&&o.canBeFocused()&&o.getFocusableElement().id===e)return o;if(o instanceof Gp&&o.getEditor().getFocusableElement().id===e)return o.getEditor()}}return null}onTreeFocus(e,t){}onTreeBlur(t){if(this.isFlyout&&this.targetWorkspace&&!e.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()){var n=this.targetWorkspace.getToolbox();n&&t===n||To(n)&&n.autoHide(!1)}}getNavigator(){return this.navigator}setNavigator(e){this.navigator=e}},M_={};M_.WorkspaceSvg=j_,M_.resizeSvgContents=$o;var N_=class extends Tl{constructor(e){super(),this.isBlank=!0,this.isBlank=e===void 0,e&&(this.varId=e.getId(),this.workspaceId=e.getWorkspace().id)}toJson(){let 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,n){return t=Tl.fromJson(e,t,n??new N_),t.varId=e.varId,t}},P_={};P_.VarBase=N_;var F_=class extends N_{constructor(e){super(e),this.type=F.VAR_CREATE,e&&(this.varType=e.getType(),this.varName=e.getName())}toJson(){let 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,n){return t=N_.fromJson(e,t,n??new F_),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)}};t(P.EVENT,F.VAR_CREATE,F_);var I_={};I_.VarCreate=F_;var L_=class{constructor(e,t,n,r){this.workspace=e,this.name=t,this.type=n||``,this.id=r||re()}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(){let 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),w(new(E(F.VAR_CREATE))(e))}};t(P.VARIABLE_MODEL,uc,L_);var R_={};R_.VariableModel=L_;var z_=class extends N_{constructor(e){super(e),this.type=F.VAR_DELETE,e&&(this.varType=e.getType(),this.varName=e.getName())}toJson(){let 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,n){return t=N_.fromJson(e,t,n??new z_),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)}};t(P.EVENT,F.VAR_DELETE,z_);var B_={};B_.VarDelete=z_;var V_=class extends N_{constructor(e,t){super(e),this.type=F.VAR_RENAME,e&&(this.oldName=e.getName(),this.newName=t===void 0?``:t)}toJson(){let 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,n){return t=N_.fromJson(e,t,n??new V_),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();let n=t.getVariableById(this.varId);e?n&&t.renameVariable(n,this.newName):n&&t.renameVariable(n,this.oldName)}};t(P.EVENT,F.VAR_RENAME,V_);var H_={};H_.VarRename=V_;var U_=class{constructor(e,t=!1){this.workspace=e,this.potentialMap=t,this.variableMap=new Map}clear(){for(let e of this.variableMap.values())for(let t of e.values())this.deleteVariable(t);if(this.variableMap.size!==0)throw Error(`Non-empty variable map`)}renameVariable(t,n){if(t.getName()===n)return t;var r=t.getType();r=this.getVariable(n,r);let i=this.workspace.getAllBlocks(!1),a=``;this.potentialMap||(a=e.getGroup$$module$build$src$core$events$utils())||e.setGroup$$module$build$src$core$events$utils(!0);try{r&&r.getId()!==t.getId()?this.renameVariableWithConflict(t,n,r,i):this.renameVariableAndUses(t,n,i)}finally{this.potentialMap||e.setGroup$$module$build$src$core$events$utils(a)}return t}changeVariableType(e,t){let n=e.getType();if(n===t)return e;var r=this.variableMap.get(n);return r?.delete(e.getId()),r?.size===0&&this.variableMap.delete(n),e.setType(t),r=this.variableMap.get(t)??new Map,r.set(e.getId(),e),this.variableMap.has(t)||this.variableMap.set(t,r),w(new(E(F.VAR_TYPE_CHANGE))(e,n,t)),e}renameVariableById(e,t){Cn(`VariableMap.renameVariableById`,`v12`,`v13`,`VariableMap.renameVariable`);let n=this.getVariableById(e);if(!n)throw Error(`Tried to rename a variable that didn't exist. ID: `+e);this.renameVariable(n,t)}renameVariableAndUses(e,t,n){for(this.potentialMap||w(new(E(F.VAR_RENAME))(e,t)),e.setName(t),t=0;t<n.length;t++)n[t].updateVarName(e)}renameVariableWithConflict(e,t,n,r){let i=e.getType(),a=n.getName();for(t!==a&&this.renameVariableAndUses(n,t,r),t=0;t<r.length;t++)r[t].renameVarById(e.getId(),n.getId());this.potentialMap||w(new(E(F.VAR_DELETE))(e));let o;(o=this.variableMap.get(i))==null||o.delete(e.getId())}createVariable(e,t,n){var r=this.getVariable(e,t);if(r){if(n&&r.getId()!==n)throw Error(`Variable "`+e+`" is already in use and its id is "`+r.getId()+`" which conflicts with the passed in id, "`+n+`".`);return r}if(n&&this.getVariableById(n))throw Error(`Variable id, "`+n+`", is already in use.`);if(r=n||re(),t=t||``,n=l(P.VARIABLE_MODEL,this.workspace.options,!0),!n)throw Error(`No variable model is registered.`);return r=new n(this.workspace,e,t,r),e=this.variableMap.get(t)??new Map,e.set(r.getId(),r),this.variableMap.has(t)||this.variableMap.set(t,e),this.potentialMap||w(new(E(F.VAR_CREATE))(r)),r}addVariable(e){let t=e.getType();this.variableMap.has(t)||this.variableMap.set(t,new Map);let n;(n=this.variableMap.get(t))==null||n.set(e.getId(),e)}deleteVariable(t){let n=Wn(this.workspace,t.getId()),r=``;this.potentialMap||(r=e.getGroup$$module$build$src$core$events$utils())||e.setGroup$$module$build$src$core$events$utils(!0);try{for(let e=0;e<n.length;e++)n[e].isDeadOrDying()||n[e].dispose(!0);let e=this.variableMap.get(t.getType());e&&e.has(t.getId())&&(e.delete(t.getId()),this.potentialMap||w(new(E(F.VAR_DELETE))(t)),e.size===0&&this.variableMap.delete(t.getType()))}finally{this.potentialMap||e.setGroup$$module$build$src$core$events$utils(r)}}deleteVariableById(t){Cn(`VariableMap.deleteVariableById`,`v12`,`v13`,`Blockly.Variables.deleteVariable`),(t=this.getVariableById(t))&&e.deleteVariable$$module$build$src$core$variables(this.workspace,t)}getVariable(t,n){return n=this.variableMap.get(n||``),n?[...n.values()].find(n=>e.Names$$module$build$src$core$names.equals(n.getName(),t))??null:null}getVariableById(e){for(let t of this.variableMap.values())if(t.has(e))return t.get(e)??null;return null}getVariablesOfType(e){return(e=this.variableMap.get(e||``))?[...e.values()]:[]}getTypes(){return[...this.variableMap.keys()]}getAllVariables(){let e=[];for(let t of this.variableMap.values())e=e.concat(...t.values());return e}getAllVariableNames(){Cn(`VariableMap.getAllVariableNames`,`v12`,`v13`,`Blockly.Variables.getAllVariables`);let e=[];for(let t of this.variableMap.values())for(let n of t.values())e.push(n.getName());return e}getVariableUsesById(e){return Cn(`VariableMap.getVariableUsesById`,`v12`,`v13`,`Blockly.Variables.getVariableUsesById`),Wn(this.workspace,e)}};t(P.VARIABLE_MAP,uc,U_);var W_={};W_.VariableMap=U_;var G_=class extends Dl{constructor(e,t){super(t),this.type=F.TRASHCAN_OPEN,this.isOpen=e}toJson(){let 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,n){return t=Dl.fromJson(e,t,n??new G_),t.isOpen=e.isOpen,t}};t(P.EVENT,F.TRASHCAN_OPEN,G_);var K_={};K_.TrashcanOpen=G_;var q_=class extends Gm{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===B.TOP?B.BOTTOM:B.TOP,this.flyout=new(l(P.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(e)):(e.toolboxPosition=this.workspace.toolboxPosition===B.RIGHT?B.LEFT:B.RIGHT,this.flyout=new(l(P.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(e)),this.workspace.addChangeListener(this.onDelete.bind(this)))}createDom(){this.svgGroup=D(L.G,{class:`blocklyTrash`});let e,t=String(Math.random()).substring(2);e=D(L.CLIPPATH,{id:`blocklyTrashBodyClipPath`+t},this.svgGroup),D(L.RECT,{width:J_,height:Y_,y:X_},e);let n=D(L.IMAGE,{width:pu.width,x:-ev,height:pu.height,y:-tv,"clip-path":`url(#blocklyTrashBodyClipPath`+t+`)`},this.svgGroup);return n.setAttributeNS(rl,`xlink:href`,this.workspace.options.pathToMedia+pu.url),e=D(L.CLIPPATH,{id:`blocklyTrashLidClipPath`+t},this.svgGroup),D(L.RECT,{width:J_,height:X_},e),this.svgLid=D(L.IMAGE,{width:pu.width,x:-ev,height:pu.height,y:-tv,"clip-path":`url(#blocklyTrashLidClipPath`+t+`)`},this.svgGroup),this.svgLid.setAttributeNS(rl,`xlink:href`,this.workspace.options.pathToMedia+pu.url),_(this.svgGroup,`pointerdown`,this,this.blockMouseDownWhenOpenable),_(this.svgGroup,`pointerup`,this,this.click),_(n,`pointerover`,this,this.mouseOver),_(n,`pointerout`,this,this.mouseOut),this.animateLid(),this.svgGroup}init(){if(this.workspace.options.maxTrashcanContents>0){let e=this.flyout.createDom(L.SVG);O(e,`blocklyTrashcanFlyout`),Le(e,this.workspace.getParentSvg()),this.flyout.init(this.workspace)}this.workspace.getComponentManager().addComponent({component:this,weight:Pl.ComponentWeight.TRASHCAN_WEIGHT,capabilities:[Pl.Capability.AUTOHIDEABLE,Pl.Capability.DELETE_AREA,Pl.Capability.DRAG_TARGET,Pl.Capability.POSITIONABLE]}),this.initialized=!0,this.setLidOpen(!1)}dispose(){this.workspace.getComponentManager().removeComponent(`trashcan`),this.svgGroup&&A(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(e){return JSON.parse(e)}),t=this.workspace.getParentSvg().style;t.cursor=`wait`,setTimeout(()=>{let n;(n=this.flyout)==null||n.show(e),t.cursor=``;let r;(r=this.workspace.scrollbar)==null||r.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 n=Ut(this.workspace,e);e=Ht(n,new z(J_,Y_+X_),Q_,Z_,e,this.workspace),t=Wt(e,Z_,n.vertical===lu.TOP?du.DOWN:du.UP,t),this.top=t.top,this.left=t.left;var r;(r=this.svgGroup)==null||r.setAttribute(`transform`,`translate(`+this.left+`,`+this.top+`)`);var i;(i=this.flyout)==null||i.position()}}getBoundingRectangle(){return new R(this.top,this.top+Y_+X_,this.left,this.left+J_)}getClientRect(){if(!this.svgGroup)return null;var e=this.svgGroup.getBoundingClientRect();let t=e.top+tv-$_;return e=e.left+ev-$_,new R(t,t+X_+Y_+2*$_,e,e+J_+2*$_)}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(){let e=iv;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*sv),t=av+this.lidOpen*(ov-av),this.svgGroup&&(this.svgGroup.style.opacity=`${t}`),this.lidOpen>this.minOpenness&&this.lidOpen<1&&(this.lidTask=setTimeout(this.animateLid.bind(this),rv/e))}setLidAngle(e){let t=this.workspace.toolboxPosition===B.RIGHT||this.workspace.horizontalLayout&&this.workspace.RTL,n;(n=this.svgLid)==null||n.setAttribute(`transform`,`rotate(`+(t?-e:e)+`,`+(t?4:J_-4)+`,`+(X_-2)+`)`)}setMinOpenness(e){this.minOpenness=e,this.isLidOpen||this.setLidAngle(e*sv)}closeLid(){this.setLidOpen(!1)}click(){this.hasContents()&&!this.workspace.isDragging()&&this.openFlyout()}fireUiEvent(e){e=new(E(F.TRASHCAN_OPEN))(e,this.workspace.id),w(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||!ae(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(nv)}}}cleanBlockJson(e){function t(e){if(e){if(delete e.id,delete e.x,delete e.y,delete e.enabled,delete e.disabledReasons,e.icons&&e.icons.comment){var n=e.icons.comment;delete n.height,delete n.width,delete n.pinned}for(var r in n=e.inputs,n){var i=n[r];let e=i.block;i=i.shadow,e&&t(e),i&&t(i)}e.next&&(r=e.next,e=r.block,r=r.shadow,e&&t(e),r&&t(r))}}return e=JSON.parse(JSON.stringify(e)),t(e),Object.assign({},{kind:`BLOCK`},e)}},J_=47,Y_=44,X_=16,Z_=20,Q_=20,$_=10,ev=0,tv=32,nv=.1,rv=80,iv=4,av=.4,ov=.8,sv=45,cv={};cv.Trashcan=q_;var lv=null,uv=null,dv=void 0,fv={};fv.BlockPaster=Am,fv.copy=es,fv.getLastCopiedData=ts,fv.getLastCopiedLocation=as,fv.getLastCopiedWorkspace=rs,fv.paste=ss,fv.registry=wu,fv.setLastCopiedData=ns,fv.setLastCopiedLocation=os,fv.setLastCopiedWorkspace=is;var pv={};pv.CollapseCommentBarButton=Yf,pv.CommentBarButton=Kf,pv.CommentEditor=Qf,pv.CommentView=rp,pv.DeleteCommentBarButton=tp,pv.RenderedWorkspaceComment=sp,pv.WorkspaceComment=ap;var mv={};mv.isCopyable=ls;var hv;(function(e){e.ESCAPE=`escape`,e.DELETE=`delete`,e.COPY=`copy`,e.CUT=`cut`,e.PASTE=`paste`,e.UNDO=`undo`,e.REDO=`redo`,e.MENU=`menu`})(hv||(hv={})),bs();var gv={};gv.names=hv,gv.registerCopy=ms,gv.registerCut=hs,gv.registerDefaultShortcuts=bs,gv.registerDelete=ds,gv.registerEscape=us,gv.registerPaste=gs,gv.registerRedo=vs,gv.registerShowContextMenu=ys,gv.registerUndo=_s;var _v=class{constructor(e,t){this.procedureModelClass=e,this.parameterModelClass=t,this.priority=_u}save(e){return e=e.getProcedureMap().getProcedures().map(e=>xs(e)),e.length?e:null}load(e,t){let n=t.getProcedureMap();for(let r of e)n.add(Ss(this.procedureModelClass,this.parameterModelClass,r,t))}clear(e){e.getProcedureMap().clear()}},vv={};vv.ProcedureSerializer=_v,vv.loadProcedure=Ss,vv.saveProcedure=xs;var yv=class{constructor(){this.priority=gu}save(e){return e=e.getVariableMap().getAllVariables().map(e=>e.save()),e.length?e:null}load(e,t){let n=s(P.VARIABLE_MODEL,uc);e.forEach(e=>{n?.load(e,t)})}clear(e){e.getVariableMap().clear()}};Gt(`variables`,new yv);var bv={};bv.VariableSerializer=yv;var xv={};xv.load=ws,xv.save=Cs;var Sv={blocks:W,exceptions:U,priorities:bu,procedures:vv,registry:xu,variables:bv,workspaceComments:Cu,workspaces:xv};`Blockly`in globalThis||(globalThis.Blockly={Msg:Zu});var Cv=`label`,wv=class{load(e,t){return e=new $m(t.getWorkspace(),t.targetWorkspace,e,!0),e.show(),new qm(e,Cv)}gapForItem(e,t){return t}disposeItem(e){e=e.getElement(),e instanceof $m&&e.dispose()}getType(){return Cv}};t(P.FLYOUT_INFLATER,Cv,wv);var Tv={};Tv.LabelFlyoutInflater=wv;var Ev=class extends c_{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;let 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&&A(this.selectedGlowFilter),this.replacementGlowFilter&&A(this.replacementGlowFilter)}makeStartHat(){let e=this.START_HAT_HEIGHT,t=this.START_HAT_WIDTH,n=Ka(`c`,[j(25,-e),j(71,-e),j(t,0)]);return{height:e*.75,width:t,path:n}}makeHexagonal(){function e(e,n,r){var i=e/2;return i=i>t?t:i,r=r?-1:1,e=(n?-1:1)*e/2,Ya(-r*i,e)+Ya(r*i,e)}let t=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH;return{type:this.SHAPES.HEXAGONAL,isDynamic:!0,width(e){return e/=2,e>t?t:e},height(e){return e},connectionOffsetY(e){return e/2},connectionOffsetX(e){return-e},pathDown(t){return e(t,!1,!1)},pathUp(t){return e(t,!0,!1)},pathRightDown(t){return e(t,!1,!0)},pathRightUp(t){return e(t,!1,!0)}}}makeRounded(){function e(e,t,r){let i=e>n?e-n:0;e=(e>n?n:e)/2;let a=r===t?`0`:`1`;return Za(`a`,`0 0,`+a,e,j((r?1:-1)*e,(t?-1:1)*e))+M(`v`,(t?-1:1)*i)+Za(`a`,`0 0,`+a,e,j((r?-1:1)*e,(t?-1:1)*e))}let t=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,n=t*2;return{type:this.SHAPES.ROUND,isDynamic:!0,width(e){return e/=2,e>t?t:e},height(e){return e},connectionOffsetY(e){return e/2},connectionOffsetX(e){return-e},pathDown(t){return e(t,!1,!1)},pathUp(t){return e(t,!0,!1)},pathRightDown(t){return e(t,!1,!0)},pathRightUp(t){return e(t,!1,!0)}}}makeSquared(){function e(e,n,r){e-=t*2;let i=r===n?`0`:`1`;return Za(`a`,`0 0,`+i,t,j((r?1:-1)*t,(n?-1:1)*t))+M(`v`,(n?-1:1)*e)+Za(`a`,`0 0,`+i,t,j((r?-1:1)*t,(n?-1:1)*t))}let t=this.CORNER_RADIUS;return{type:this.SHAPES.SQUARE,isDynamic:!0,width(e){return t},height(e){return e},connectionOffsetY(e){return e/2},connectionOffsetX(e){return-e},pathDown(t){return e(t,!1,!1)},pathUp(t){return e(t,!0,!1)},pathRightDown(t){return e(t,!1,!0)},pathRightUp(t){return e(t,!1,!0)}}}shapeFor(e){let t=e.getCheck();switch(!t&&e.targetConnection&&(t=e.targetConnection.getCheck()),e.type){case Y.INPUT_VALUE:case Y.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`)||t&&t.includes(`String`),this.ROUNDED);case Y.PREVIOUS_STATEMENT:case Y.NEXT_STATEMENT:return this.NOTCH;default:throw Error(`Unknown type`)}}makeNotch(){function e(e){return Ka(`c`,[j(e*i/2,0),j(e*i*3/4,o/2),j(e*i,o)])+Xa([j(e*i,a)])+Ka(`c`,[j(e*i/4,o/2),j(e*i/2,o),j(e*i,o)])+M(`h`,e*r)+Ka(`c`,[j(e*i/2,0),j(e*i*3/4,-(o/2)),j(e*i,-o)])+Xa([j(e*i,-a)])+Ka(`c`,[j(e*i/4,-(o/2)),j(e*i/2,-o),j(e*i,-o)])}let t=this.NOTCH_WIDTH,n=this.NOTCH_HEIGHT,r=t/3,i=r/3,a=n/2,o=a/2,s=e(1),c=e(-1);return{type:this.SHAPES.NOTCH,width:t,height:n,pathLeft:s,pathRight:c}}makeInsideCorners(){let e=this.CORNER_RADIUS,t=Za(`a`,`0 0,0`,e,j(-e,e)),n=Za(`a`,`0 0,1`,e,j(-e,e));return{width:e,height:e,pathTop:t,pathBottom:Za(`a`,`0 0,0`,e,j(e,e)),rightWidth:e,rightHeight:e,pathTopRight:n,pathBottomRight:Za(`a`,`0 0,1`,e,j(e,e))}}generateSecondaryColour_(e){return xi(`#000`,e,.15)||e}generateTertiaryColour_(e){return xi(`#000`,e,.25)||e}createDom(e,t,n,r){super.createDom(e,t,n,r),e=D(L.DEFS,{},e),t=D(L.FILTER,{id:`blocklySelectedGlowFilter`+this.randomIdentifier,height:`160%`,width:`180%`,y:`-30%`,x:`-40%`},e),D(L.FEGAUSSIANBLUR,{in:`SourceGraphic`,stdDeviation:this.SELECTED_GLOW_SIZE},t),n=D(L.FECOMPONENTTRANSFER,{result:`outBlur`},t),D(L.FEFUNCA,{type:`table`,tableValues:`0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1`},n),D(L.FEFLOOD,{"flood-color":this.SELECTED_GLOW_COLOUR,"flood-opacity":1,result:`outColor`},t),D(L.FECOMPOSITE,{in:`outColor`,in2:`outBlur`,operator:`in`,result:`outGlow`},t),this.selectedGlowFilterId=t.id,this.selectedGlowFilter=t,e=D(L.FILTER,{id:`blocklyReplacementGlowFilter`+this.randomIdentifier,height:`160%`,width:`180%`,y:`-30%`,x:`-40%`},e),D(L.FEGAUSSIANBLUR,{in:`SourceGraphic`,stdDeviation:this.REPLACEMENT_GLOW_SIZE},e),t=D(L.FECOMPONENTTRANSFER,{result:`outBlur`},e),D(L.FEFUNCA,{type:`table`,tableValues:`0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1`},t),D(L.FEFLOOD,{"flood-color":this.REPLACEMENT_GLOW_COLOUR,"flood-opacity":1,result:`outColor`},e),D(L.FECOMPOSITE,{in:`outColor`,in2:`outBlur`,operator:`in`,result:`outGlow`},e),D(L.FECOMPOSITE,{in:`SourceGraphic`,in2:`outGlow`,operator:`over`},e),this.replacementGlowFilterId=e.id,this.replacementGlowFilter=e,r&&(r.style.setProperty(`--blocklySelectedGlowFilter`,`url(#${this.selectedGlowFilterId})`),r.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);`,`}`]}},Dv={};Dv.ConstantProvider=Ev;var Ov=class extends u_{constructor(e,t){super(e,t)}draw(){let e=this.block_.pathObject;e.beginDrawing(),this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights(),e.setPath(this.outlinePath_+`
|
|
665
|
+
`+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(Z.isSpacer(e)){let r=e.precedesStatement;var t=e.followsStatement;if(r||t){let i=this.constants_.INSIDE_CORNERS;var n=i.rightHeight;n=e.height-(r?n:0),t=t?i.pathBottomRight:``,e=n>0?M(`V`,e.yPos+n):``,this.outlinePath_+=t+e+(r?i.pathTopRight:``);return}}this.outlinePath_+=M(`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_(){let e=this.info_.topRow;this.positionPreviousConnection_(),this.outlinePath_+=Ja(e.xPos,this.info_.startY),this.outlinePath_+=M(`h`,e.width)}drawFlatBottom_(){let e=this.info_.bottomRow;this.positionNextConnection_(),this.outlinePath_+=M(`V`,e.baseline),this.outlinePath_+=M(`h`,-e.width)}drawInlineInput_(e){this.positionInlineInputConnection_(e);let t=e.input.name;e.connectedBlock||this.info_.isInsertionMarker||(e=qa(e.xPos+e.connectionWidth,e.centerline-e.height/2)+this.getInlineInputPath(e),this.block_.pathObject.setOutlinePath(t,e))}getInlineInputPath(e){let t=e.width-e.connectionWidth*2,n=e.height;return M(`h`,t)+e.shape.pathRightDown(n)+M(`h`,-t)+e.shape.pathUp(n)+`z`}drawStatementInput_(e){var t=e.getLastInput();let n=t.xPos+t.notchOffset+t.shape.width,r=this.constants_.INSIDE_CORNERS,i=t.shape.pathRight+M(`h`,-(t.notchOffset-r.width))+r.pathTop,a=e.height-2*r.height;t=r.pathBottom+M(`h`,t.notchOffset-r.width)+(t.connectedBottomNextConnection?``:t.shape.pathLeft),this.outlinePath_+=M(`H`,n)+i+M(`v`,a)+t+M(`H`,e.xPos+e.width),this.positionStatementInputConnection_(e)}drawConnectionHighlightPath(e){let t=e.connectionModel;if(t.type===Y.NEXT_STATEMENT||t.type===Y.PREVIOUS_STATEMENT||t.type===Y.OUTPUT_VALUE&&!e.isDynamicShape)return super.drawConnectionHighlightPath(e);e=t.type===Y.INPUT_VALUE?qa(e.connectionWidth,-e.height/2)+this.getInlineInputPath(e):qa(e.width,-e.height/2)+e.shape.pathDown(e.height);let n=t.getSourceBlock(),r;return(r=n.pathObject).addConnectionHighlight?.call(r,t,e,t.getOffsetInBlock(),n.RTL)}},kv={};kv.Drawer=Ov;var Av=class extends xf{constructor(e,t,n,r,i,a,o){if(super(xf.SKIP_SETUP),this.imageElement=this.clickHandler=null,this.flipRtl=this.isDirty_=this.EDITABLE=!1,this.altText=``,n=Number(Ti(n)),t=Number(Ti(t)),isNaN(n)||isNaN(t))throw Error(`Height and width values of an image field must cast to numbers.`);if(n<=0||t<=0)throw Error(`Height and width values of an image field must be greater than 0.`);this.size_=new z(t,n+Av.Y_PADDING),this.imageHeight=n,typeof i==`function`&&(this.clickHandler=i),e!==xf.SKIP_SETUP&&(o?this.configure_(o):(this.flipRtl=!!a,this.altText=Ti(r)||``),this.setValue(Ti(e)))}configure_(e){super.configure_(e),e.flipRtl&&(this.flipRtl=e.flipRtl),e.alt&&(this.altText=Ti(e.alt))}initView(){this.imageElement=D(L.IMAGE,{height:this.imageHeight+`px`,width:this.size_.width+`px`,alt:this.altText},this.fieldGroup_),this.imageElement.setAttributeNS(rl,`xlink:href`,this.value_),this.fieldGroup_&&O(this.fieldGroup_,`blocklyImageField`),this.clickHandler&&(this.imageElement.style.cursor=`pointer`)}updateSize_(){}doClassValidation_(e){return typeof e==`string`?e:null}doValueUpdate_(e){this.value_=e,this.imageElement&&this.imageElement.setAttributeNS(rl,`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)}};Av.Y_PADDING=1,Oa(`field_image`,Av),Av.prototype.DEFAULT_VALUE=``;var jv={};jv.FieldImage=Av;var Mv=14,Nv=class extends xf{set size_(e){super.size_=e}get size_(){let e=super.size_;return e.width<Mv&&(e.width=Mv),e}constructor(e,t,n){super(xf.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!==xf.SKIP_SETUP&&(n&&this.configure_(n),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 Sf;super.initView(),this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot()),this.fieldGroup_&&O(this.fieldGroup_,`blocklyInputField`)}isFullBlockField(){let e=this.getSourceBlock();if(!e)throw new Sf;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_&&je()&&this.value_!==e&&t&&w(new(E(F.BLOCK_CHANGE))(this.sourceBlock_,`field`,this.name||null,e,this.value_)))}doValueUpdate_(e){this.isTextValid_=this.isDirty_=!0,this.value_=e}applyColour(){let e=this.getSourceBlock();if(!e)throw new Sf;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_?(k(e,`blocklyInvalidInput`),en(e,ju.INVALID,!1)):(O(e,`blocklyInvalidInput`),en(e,ju.INVALID,!0))}if(e=this.getSourceBlock(),!e)throw new Sf;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,n=!0){this.workspace_=this.sourceBlock_.workspace,!t&&this.workspace_.options.modalInputs&&(Ic||Mc||Nc)?this.showPromptEditor():this.showInlineEditor(t,n)}showPromptEditor(){gn(e.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){let n=this.getSourceBlock();if(!n)throw new Sf;ji(this,n.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 t=this.getSourceBlock();if(!t)throw new Sf;e.setGroup$$module$build$src$core$events$utils(!0);let n=Oi();var r=this.getClickTarget_();if(!r)throw Error(`A click target has not been set.`);O(r,`blocklyEditing`),r=document.createElement(`input`),r.className=`blocklyHtmlInput`,r.setAttribute(`spellcheck`,this.spellcheck_);let i=this.workspace_.getAbsoluteScale();var a=this.getConstants().FIELD_TEXT_FONTSIZE*i+`pt`;return n.style.fontSize=a,r.style.fontSize=a,a=Nv.BORDERRADIUS*i+`px`,this.isFullBlockField()&&(a=this.getScaledBBox(),a=(a.bottom-a.top)/2+`px`,t=t.getParent()?t.getParent().getColourTertiary():this.sourceBlock_.getColourTertiary(),r.style.border=1*i+`px solid `+t,n.style.borderRadius=a,n.style.transition=`box-shadow 0.25s ease 0s`,this.getConstants().FIELD_TEXTINPUT_BOX_SHADOW&&(n.style.boxShadow=`rgba(255, 255, 255, 0.3) 0 0 0 `+4*i+`px`)),r.style.borderRadius=a,n.appendChild(r),r.value=r.defaultValue=this.getEditorText_(this.value_),r.setAttribute(`data-untyped-default-value`,String(this.value_)),this.resizeEditor_(),this.bindInputEvents_(r),r}widgetDispose_(){this.isBeingEdited_=!1,this.isTextValid_=!0,this.forceRerender(),this.onFinishEditing_(this.value_),this.sourceBlock_&&je()&&this.valueWhenEditorWasOpened_!==null&&this.valueWhenEditorWasOpened_!==this.value_&&(w(new(E(F.BLOCK_CHANGE))(this.sourceBlock_,`field`,this.name||null,this.valueWhenEditorWasOpened_,this.value_)),this.valueWhenEditorWasOpened_=null),e.setGroup$$module$build$src$core$events$utils(!1),this.unbindInputEvents_();var t=Oi().style;if(t.width=`auto`,t.height=`auto`,t.fontSize=``,t.transition=``,t.boxShadow=``,this.htmlInput_=null,t=this.getClickTarget_(),!t)throw Error(`A click target has not been set.`);k(t,`blocklyEditing`)}onFinishEditing_(e){}bindInputEvents_(e){this.onKeyDownWrapper=g(e,`keydown`,this,this.onHtmlInputKeyDown_),this.onInputWrapper=g(e,`input`,this,this.onHtmlInputChange)}unbindInputEvents_(){this.onKeyDownWrapper&&(v(this.onKeyDownWrapper),this.onKeyDownWrapper=null),this.onInputWrapper&&(v(this.onInputWrapper),this.onInputWrapper=null)}onHtmlInputKeyDown_(t){if(t.key===`Enter`)Pi(this),Lr();else if(t.key===`Escape`)this.setValue(this.htmlInput_.getAttribute(`data-untyped-default-value`),!1),Pi(this),Lr();else if(t.key===`Tab`){t.preventDefault();var n,r=(n=this.workspace_)?.getCursor();n=e=>(e instanceof Nv||e instanceof Bm&&e.isSimpleReporter())&&e!==this.getSourceBlock(),t=t.shiftKey?r?.getPreviousNode(this,n,!1):r?.getNextNode(this,n,!1),t=t instanceof Bm&&t.isSimpleReporter()?t.getFields().next().value:t,t instanceof Nv&&(Pi(this),Lr(),r=t.getSourceBlock(),t.isFullBlockField()&&r&&r instanceof Bm?e.getFocusManager$$module$build$src$core$focus_manager().focusNode(r):e.getFocusManager$$module$build$src$core$focus_manager().focusNode(t),t.showEditor())}}onHtmlInputChange(e){e=this.value_,this.setValue(this.getValueFromEditorText_(this.htmlInput_.value),!1),this.sourceBlock_&&je()&&this.value_!==e&&w(new(E(F.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_(){rn().then(()=>{let e=this.getSourceBlock();if(!e)throw new Sf;let t=Oi(),n=this.getScaledBBox();t.style.width=n.right-n.left+`px`,t.style.height=n.bottom-n.top+`px`;let r=n.top;t.style.left=`${e.RTL?n.right-t.offsetWidth:n.left}px`,t.style.top=`${r}px`})}repositionForWindowResize(){let e=this.getSourceBlock()?.getRootBlock();return e instanceof Bm?(po(this.workspace_,this.workspace_.getMetricsManager().getViewMetrics(!0),e)||this.resizeEditor_(),!0):!1}positionTextElement_(e,t){let n=e*2+t;super.positionTextElement_(e+(n<Mv?(Mv-n)/2:0),t)}getText_(){return this.isBeingEdited_&&this.htmlInput_?this.htmlInput_.value:null}getEditorText_(e){return`${e}`}getValueFromEditorText_(e){return e}};Nv.BORDERRADIUS=4;var Pv={};Pv.FieldInput=Nv,e.FieldTextInput$$module$build$src$core$field_textinput=class extends Nv{constructor(e,t,n){super(e,t,n)}initView(){super.initView(),this.fieldGroup_&&O(this.fieldGroup_,`blocklyTextInputField`)}doClassValidation_(e){return e===void 0?null:`${e}`}static fromJson(e){return new this(Ti(e.text),void 0,e)}},Oa(`field_input`,e.FieldTextInput$$module$build$src$core$field_textinput),e.FieldTextInput$$module$build$src$core$field_textinput.prototype.DEFAULT_VALUE=``;var Fv={};Fv.FieldTextInput=e.FieldTextInput$$module$build$src$core$field_textinput;var Iv=class extends wg{constructor(e){super(e)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(e){return!!e.outputConnection}hasRightSquareCorner(e){return!!e.outputConnection&&!e.statementInputCount&&!e.nextConnection}},Lv={};Lv.BottomRow=Iv;var Rv=class extends i_{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)}}},zv={};zv.StatementInput=Rv;var Bv=class extends bg{constructor(e){super(e),this.width=this.height=0,this.type|=Z.getType(`RIGHT_CONNECTION`)}},Vv={};Vv.RightConnectionShape=Bv;var Hv=class extends o_{constructor(e){super(e)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(e){let 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}},Uv={};Uv.TopRow=Hv;var Wv=class extends f_{constructor(e,t){super(e,t),this.isInline=!0,this.renderer_=e,this.constants_=this.renderer_.getConstants(),this.topRow=new Hv(this.constants_),this.bottomRow=new Iv(this.constants_),this.isMultiRow=!t.getInputsInline()||t.isCollapsed(),this.hasStatementInput=t.statementInputCount>0,this.rightSide=this.outputConnection?new Bv(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_(t,n){return n?n instanceof vm||t instanceof bm||n instanceof bm?!0:t instanceof e.ValueInput$$module$build$src$core$inputs$value_input||t instanceof gm||t instanceof vm?!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&&Z.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:e&&Z.isLeftRoundedCorner(e)&&t&&(Z.isPreviousConnection(t)||Z.isNextConnection(t))?t.notchOffset-this.constants_.CORNER_RADIUS:e&&Z.isLeftSquareCorner(e)&&t&&Z.isHat(t)||e&&Z.isField(e)&&e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:this.constants_.NO_PADDING}getSpacerRowHeight_(e,t){if(Z.isTopRow(e)&&Z.isBottomRow(t))return this.constants_.EMPTY_BLOCK_SPACER_HEIGHT;let n=Z.isInputRow(e)&&e.hasStatement,r=Z.isInputRow(t)&&t.hasStatement;return r||n?(e=Math.max(this.constants_.NOTCH_HEIGHT,this.constants_.INSIDE_CORNERS.rightHeight||0),r&&n?Math.max(e,this.constants_.DUMMY_INPUT_MIN_HEIGHT):e):Z.isTopRow(e)?e.hasPreviousConnection||this.outputConnection&&!this.hasStatementInput?this.constants_.NO_PADDING:Math.abs(this.constants_.NOTCH_HEIGHT-this.constants_.CORNER_RADIUS):Z.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){let n=this.width-this.startX;return Z.isInputRow(e)&&e.hasStatement||Z.isInputRow(t)&&t.hasStatement?Math.max(n,this.constants_.STATEMENT_INPUT_SPACER_MIN_WIDTH):n}getElemCenterline_(e,t){if(e.hasStatement&&!Z.isSpacer(t)&&!Z.isStatementInput(t))return e.yPos+this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT/2;if(Z.isInlineInput(t)){let n=t.connectedBlock;if(n&&n.outputConnection&&n.nextConnection)return e.yPos+n.height/2}return super.getElemCenterline_(e,t)}addInput_(t,n){if((t instanceof gm||t instanceof vm)&&n.hasDummyInput&&n.align===e.Align$$module$build$src$core$inputs$align.LEFT&&t.align===e.Align$$module$build$src$core$inputs$align.RIGHT)this.rightAlignedDummyInputs.set(n,t);else if(t instanceof bm){n.elements.push(new Rv(this.constants_,t)),n.hasStatement=!0,n.align===null&&(n.align=t.align);return}super.addInput_(t,n)}addAlignmentPadding_(e,t){if(this.rightAlignedDummyInputs.get(e)){let n;for(let t=0;t<e.elements.length;t++){let r=e.elements[t];if(Z.isSpacer(r)&&(n=r),Z.isField(r)&&r.parentInput===this.rightAlignedDummyInputs.get(e))break}if(n){n.width+=t,e.width+=t;return}}super.addAlignmentPadding_(e,t)}adjustXPosition_(){let e=this.constants_.NOTCH_OFFSET_LEFT+this.constants_.NOTCH_WIDTH,t=e;for(let i=2;i<this.rows.length-1;i+=2){var n=this.rows[i-1];let a=this.rows[i];var r=this.rows[i+1];if(n=i===2?!!this.topRow.hasPreviousConnection:!!n.followsStatement,r=i+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!r.precedesStatement,Z.isInputRow(a)&&a.hasStatement)a.measure(),t=a.width-(a.getLastInput()?.width??0)+e;else if(n&&(i===2||r)&&Z.isInputRow(a)&&!a.hasStatement){r=a.xPos,n=null;for(let e=0;e<a.elements.length;e++){let i=a.elements[e];Z.isSpacer(i)&&(n=i),!(n&&(Z.isField(i)||Z.isInput(i))&&r<t)||Z.isField(i)&&(i.field instanceof im||i.field instanceof Av)||(n.width+=t-r),r+=i.width}}}}finalizeOutputConnection_(){if(this.outputConnection&&this.outputConnection.isDynamicShape){var e=this.outputConnection.shape;if(`isDynamic`in e&&e.isDynamic){for(var t=0,n=0;n<this.rows.length;n++){let e=this.rows[n];e.yPos=t,t+=e.height}this.height=t,n=this.bottomRow.hasNextConnection?this.height-this.bottomRow.descenderHeight:this.height,t=e.height(n),n=e.width(n),this.outputConnection.height=t,this.outputConnection.width=n,this.outputConnection.startX=n,this.outputConnection.connectionOffsetY=e.connectionOffsetY(t),this.outputConnection.connectionOffsetX=e.connectionOffsetX(n),e=0,this.hasStatementInput||this.bottomRow.hasNextConnection||(e=n,this.rightSide.height=t,this.rightSide.width=e,this.rightSide.centerline=t/2,this.rightSide.xPos=this.width+e),this.startX=n,this.width+=n+e,this.widthWithChildren+=n+e}}}finalizeHorizontalAlignment_(){if(this.outputConnection&&!this.hasStatementInput&&!this.bottomRow.hasNextConnection){for(var e=0,t=0;t<this.rows.length;t++){var n=this.rows[t];if(!Z.isInputRow(n))continue;e=n.elements[n.elements.length-2];let r=this.getNegativeSpacing_(n.elements[1]),i=this.getNegativeSpacing_(e);e=r+i;let a=this.constants_.MIN_BLOCK_WIDTH+this.outputConnection.width*2;this.width-e<a&&(e=this.width-a,r=e/2,i=e/2),n.elements.unshift(new Rg(this.constants_,-r)),n.elements.push(new Rg(this.constants_,-i))}if(e)for(this.width-=e,this.widthWithChildren-=e,this.rightSide.xPos-=e,t=0;t<this.rows.length;t++)n=this.rows[t],Z.isTopOrBottomRow(n)&&(n.elements[1].width-=e),n.width-=e,n.widthWithConnectedBlocks-=e}}getNegativeSpacing_(t){if(!t||!this.outputConnection)return 0;let n=this.outputConnection.width;var r=this.outputConnection.shape.type;let i=this.constants_;if(this.inputRows.length>1)switch(r){case i.SHAPES.ROUND:return r=this.constants_.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,r=this.height/2>r?r:this.height/2,n-r*(1-Math.sin(Math.acos((r-this.constants_.SMALL_PADDING)/r)));default:return 0}if(Z.isInlineInput(t)){let e=t.connectedBlock;return t=e?e.pathObject.outputShapeType:t.shape.type,t==null||e&&e.outputConnection&&(e.statementInputCount||e.nextConnection)||r===i.SHAPES.HEXAGONAL&&r!==t?0:n-this.constants_.SHAPE_IN_SHAPE_PADDING[r][t]}return Z.isField(t)?r===i.SHAPES.ROUND&&t.field instanceof e.FieldTextInput$$module$build$src$core$field_textinput?n-2.75*i.GRID_UNIT:n-this.constants_.SHAPE_IN_SHAPE_PADDING[r][0]:Z.isIcon(t)?this.constants_.SMALL_PADDING:0}finalizeVerticalAlignment_(){if(!this.outputConnection)for(let r=2;r<this.rows.length-1;r+=2){let i=this.rows[r-1],a=this.rows[r],o=this.rows[r+1];var e=r===2,t=r+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!o.precedesStatement;if(e?this.topRow.hasPreviousConnection:i.followsStatement){var n=a.elements[1];if(n=a.elements.length===3&&n instanceof Mg&&(n.field instanceof im||n.field instanceof Av),!e&&n)i.height-=this.constants_.SMALL_PADDING,o.height-=this.constants_.SMALL_PADDING,a.height-=this.constants_.MEDIUM_PADDING;else if(!e&&!t)i.height+=this.constants_.SMALL_PADDING;else if(t){for(e=!1,t=0;t<a.elements.length;t++)if(n=a.elements[t],Z.isInlineInput(n)&&n.connectedBlock&&!n.connectedBlock.isShadow()&&n.connectedBlock.getHeightWidth().height>=40){e=!0;break}e&&(i.height-=this.constants_.SMALL_PADDING,o.height-=this.constants_.SMALL_PADDING)}}}}finalize_(){this.finalizeOutputConnection_(),this.finalizeHorizontalAlignment_(),this.finalizeVerticalAlignment_(),super.finalize_(),this.rightSide&&(this.widthWithChildren+=this.rightSide.width)}},Gv={};Gv.RenderInfo=Wv;var Kv=class extends m_{constructor(e,t,n){super(e,t,n),this.svgPathSelected=null,this.outlines=new Map,this.remainingOutlines=new Set,this.outputShapeType=null,this.constants=n}setPath(e){super.setPath(e),this.svgPathSelected&&this.svgPathSelected.setAttribute(`d`,e)}applyColour(e){super.applyColour(e);let t=e.getParent();e.isShadow()&&t&&this.svgPath.setAttribute(`stroke`,t.getColourTertiary());for(let e of this.outlines.values())e.setAttribute(`fill`,this.style.colourTertiary)}flipRTL(){super.flipRTL();for(let 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`),k(this.svgPathSelected,fl.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),k(this.svgPathSelected,fl.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(let e of this.outlines.keys())this.remainingOutlines.add(e)}endDrawing(){if(this.remainingOutlines.size)for(let 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,D(L.PATH,{class:`blocklyOutlinePath`,d:``},this.svgRoot)),this.remainingOutlines.delete(e),this.outlines.get(e)}removeOutlinePath(e){let t,n;(t=this.outlines.get(e))==null||(n=t.parentNode)==null||n.removeChild(this.outlines.get(e)),this.outlines.delete(e)}},qv={};qv.PathObject=Kv;var Jv=class extends g_{constructor(e){super(e)}makeConstants_(){return new Ev}makeRenderInfo_(e){return new Wv(this,e)}makeDrawer_(e,t){return new Ov(e,t)}makePathObject(e,t){return new Kv(e,t,this.getConstants())}getConstants(){return this.constants_}};Uo(`zelos`,Jv);var Yv={};Yv.Renderer=Jv;var Xv=class{constructor(e){this.staticConn=this.draggedConn=this.markerConn=this.fadedBlock=null,this.workspace=e.workspace}previewReplacement(t,n,r){e.disable$$module$build$src$core$events$utils();try{this.hidePreview(),this.fadedBlock=r,r.fadeForReplacement(!0),this.workspace.getRenderer().shouldHighlightConnection(n)&&(n.highlight(),this.staticConn=n)}finally{e.enable$$module$build$src$core$events$utils()}}previewConnection(t,n){if(t!==this.draggedConn||n!==this.staticConn){e.disable$$module$build$src$core$events$utils();try{this.hidePreview(),this.shouldUseMarkerPreview(t,n)&&(this.markerConn=this.previewMarker(t,n)),this.workspace.getRenderer().shouldHighlightConnection(n)&&n.highlight(),this.draggedConn=t,this.staticConn=n}finally{e.enable$$module$build$src$core$events$utils()}}}shouldUseMarkerPreview(e,t){return t.type===Y.PREVIOUS_STATEMENT||t.type===Y.NEXT_STATEMENT||!(this.workspace.getRenderer()instanceof Jv)}previewMarker(t,n){let r=t.getSourceBlock(),i=this.createInsertionMarker(r),a=this.getMatchingConnection(r,i,t);if(!a)return null;i.queueRender(),an(),a.connect(n);let o={x:n.x-a.x,y:n.y-a.y},s=a.getOffsetInBlock().clone();return rn().then(()=>{if(!i.isDeadOrDying()){e.disable$$module$build$src$core$events$utils();try{i?.positionNearConnection(a,o,s),i?.getSvgRoot().setAttribute(`visibility`,`visible`)}finally{e.enable$$module$build$src$core$events$utils()}}}),a}serializeBlockToInsertionMarker(e){let t=Gn(e,{addCoordinates:!1,addInputBlocks:!1,addNextBlocks:!1,doFullSerialization:!1});if(!t)throw Error(`Failed to serialize source block. ${e.toDevString()}`);return t}createInsertionMarker(e){e=this.serializeBlockToInsertionMarker(e),e=er(e,this.workspace);for(let t of e.getDescendants(!1))t.setInsertionMarker(!0);return e.initSvg(),e.getSvgRoot().setAttribute(`visibility`,`hidden`),e}getMatchingConnection(e,t,n){if(e=e.getConnections_(!0),t=t.getConnections_(!0),e.length!==t.length)return null;for(let r=0;r<e.length;r++)if(e[r]===n)return t[r];return null}hidePreview(){e.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{e.enable$$module$build$src$core$events$utils()}}hideInsertionMarker(e){let t=e.getSourceBlock(),n=t.outputConnection,r;if((r=t.previousConnection)!=null&&r.targetConnection||n!=null&&n.targetConnection)t.unplug(!0);else{let t;(t=e.targetBlock())==null||t.unplug(!1)}t.dispose()}dispose(){this.hidePreview()}};t(P.CONNECTION_PREVIEWER,uc,Xv);var Zv={};Zv.InsertionMarkerPreviewer=Xv;var Qv={};Qv.Align=e.Align$$module$build$src$core$inputs$align,Qv.DummyInput=gm,Qv.EndRowInput=vm,Qv.Input=mm,Qv.StatementInput=bm,Qv.ValueInput=e.ValueInput$$module$build$src$core$inputs$value_input,Qv.inputTypes=e.inputTypes$$module$build$src$core$inputs$input_types;var $v=!1,ey={};ey.inject=Ts;var ty;e.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=Qe());var t=[];this.init(e),e=e.getTopBlocks(!0);for(let n=0,r;r=e[n];n++){let e=this.blockToCode(r);Array.isArray(e)&&(e=e[0]),e&&(r.outputConnection&&(e=this.scrubNakedValue(e),this.STATEMENT_PREFIX&&!r.suppressPrefixSuffix&&(e=this.injectId(this.STATEMENT_PREFIX,r)+e),this.STATEMENT_SUFFIX&&!r.suppressPrefixSuffix&&(e+=this.injectId(this.STATEMENT_SUFFIX,r))),t.push(e))}return t=t.join(`
|
|
666
|
+
`),t=this.finish(t),t=t.replace(/^\s+\n/,``),t=t.replace(/\n\s+$/,`
|
|
667
|
+
`),t=t.replace(/[ \t]+\n/g,`
|
|
668
|
+
`)}prefixLines(e,t){return t+e.replace(/(?!\n$)\n/g,`
|
|
669
|
+
`+t)}allNestedComments(e){let t=[];e=e.getDescendants(!0);for(let n=0;n<e.length;n++){let r=e[n].getCommentText();r&&t.push(r)}return t.length&&t.push(``),t.join(`
|
|
670
|
+
`)}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 n=this.forBlock[e.type];if(typeof n!=`function`)throw Error(`${this.name_} generator does not know how to generate code for block type "${e.type}".`);if(n=n.call(e,e,this),Array.isArray(n)){if(!e.outputConnection)throw TypeError(`Expecting string from statement block: `+e.type);return[this.scrub_(e,n[0],t),n[1]]}if(typeof n==`string`)return this.STATEMENT_PREFIX&&!e.suppressPrefixSuffix&&(n=this.injectId(this.STATEMENT_PREFIX,e)+n),this.STATEMENT_SUFFIX&&!e.suppressPrefixSuffix&&(n+=this.injectId(this.STATEMENT_SUFFIX,e)),this.scrub_(e,n,t);if(n===null)return``;throw SyntaxError(`Invalid code generated: `+n)}valueToCode(e,t,n){if(isNaN(n))throw TypeError(`Expecting valid order from block: `+e.type);var r=e.getInputTargetBlock(t);if(!r&&!e.getInput(t))throw ReferenceError(`Input "${t}" doesn't exist on "${e.type}"`);if(!r||(t=this.blockToCode(r),t===``))return``;if(!Array.isArray(t))throw TypeError(`Expecting tuple from value block: ${r.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: `+r.type);if(!e)return``;r=!1;var i=Math.floor(n);let a=Math.floor(t);if(i<=a&&(i!==a||i!==0&&i!==99)){for(r=!0,i=0;i<this.ORDER_OVERRIDES.length;i++)if(this.ORDER_OVERRIDES[i][0]===n&&this.ORDER_OVERRIDES[i][1]===t){r=!1;break}}return r&&(e=`(`+e+`)`),e}statementToCode(e,t){let n=e.getInputTargetBlock(t);if(!n&&!e.getInput(t))throw ReferenceError(`Input "${t}" doesn't exist on "${e.type}"`);if(e=this.blockToCode(n),typeof e!=`string`)throw TypeError(`Expecting code from statement block: `+(n&&n.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_(t,n){if(!this.definitions_[t]){let r=this.nameDB_.getDistinctName(t,e.NameType$$module$build$src$core$names.PROCEDURE);this.functionNames_[t]=r,Array.isArray(n)&&(n=n.join(`
|
|
671
|
+
`)),n=n.trim().replace(this.FUNCTION_NAME_PLACEHOLDER_REGEXP_,r);let i;for(;i!==n;)i=n,n=n.replace(/^(( {2})*) {2}/gm,`$1\0`);n=n.replace(/\0/g,this.INDENT),this.definitions_[t]=n}return this.functionNames_[t]}getVariableName(t){return this.getName(t,e.NameType$$module$build$src$core$names.VARIABLE)}getProcedureName(t){return this.getName(t,e.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,n){return t}finish(e){return this.definitions_=Object.create(null),this.functionNames_=Object.create(null),e}scrubNakedValue(e){return e}},ty={},ty.CodeGenerator=e.CodeGenerator$$module$build$src$core$generator;var ny=class extends Hh{constructor(e){super(e)}setMetrics_(e){if(this.isVisible()){var t=this.workspace_.getMetricsManager(),n=t.getScrollMetrics(),r=t.getViewMetrics();t=t.getAbsoluteMetrics(),typeof e.y==`number`&&(this.workspace_.scrollY=-(n.top+(n.height-r.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();let t=e.getAbsoluteMetrics(),n=e.getViewMetrics();return e=e.getToolboxMetrics(),this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?this.toolboxPosition_===B.LEFT?e.width:n.width-this.getWidth():this.toolboxPosition_===B.LEFT?0:n.width:this.toolboxPosition_===B.LEFT?0:n.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){let n=this.toolboxPosition_===B.RIGHT;var r=e+this.CORNER_RADIUS;r=[`M `+(n?r:0)+`,0`],r.push(`h`,n?-e:e),r.push(`a`,this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,+!n,n?-this.CORNER_RADIUS:this.CORNER_RADIUS,this.CORNER_RADIUS),r.push(`v`,Math.max(0,t)),r.push(`a`,this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,+!n,n?this.CORNER_RADIUS:-this.CORNER_RADIUS,this.CORNER_RADIUS),r.push(`h`,n?e:-e),r.push(`z`),this.svgBackground_.setAttribute(`d`,r.join(` `))}scrollToStart(){let e;(e=this.workspace_.scrollbar)==null||e.setY(0)}wheel_(e){var t=te(e);if(t.y){let e=this.workspace_.getMetricsManager(),n=e.getScrollMetrics();t=e.getViewMetrics().top-n.top+t.y;let r;(r=this.workspace_.scrollbar)==null||r.setY(t),Fi(this.workspace_),Lr()}e.preventDefault(),e.stopPropagation()}layout_(e){this.workspace_.scale=this.targetWorkspace.scale;var t=this.MARGIN;let n=this.RTL?t:t+this.tabWidth_;for(let r of e)r.getElement().moveBy(n,t),t+=r.getElement().getBoundingRectangle().getHeight()}isDragTowardWorkspace(e){e=Math.atan2(e.y,e.x)/Math.PI*180;let t=this.dragAngleRange_;return e<t&&e>-t||e<-180+t||e>180-t}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;let e=this.svgGroup_.getBoundingClientRect(),t=e.left;return this.toolboxPosition_===B.LEFT?new R(-1e9,1e9,-1e9,t+e.width):new R(-1e9,1e9,t,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let e=this.getContents().reduce((e,t)=>Math.max(e,t.getElement().getBoundingRectangle().getWidth()),0);if(e+=this.MARGIN*1.5+this.tabWidth_,e*=this.workspace_.scale,e+=Yl.scrollbarThickness,this.getWidth()!==e){if(this.RTL)for(let t of this.getContents()){let n=t.getElement().getBoundingRectangle().left,r=e/this.workspace_.scale-t.getElement().getBoundingRectangle().getWidth()-this.MARGIN-this.tabWidth_;t.getElement().moveBy(r-n,0)}this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==B.LEFT||this.targetWorkspace.translate(this.targetWorkspace.scrollX+e,this.targetWorkspace.scrollY),this.width_=e,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets()}}};ny.registryName=`verticalFlyout`,t(P.FLYOUTS_VERTICAL_TOOLBOX,uc,ny);var ry={};ry.VerticalFlyout=ny;var iy=class extends Hh{constructor(e){super(e),this.horizontalLayout=!0}setMetrics_(e){if(this.isVisible()){var t=this.workspace_.getMetricsManager(),n=t.getScrollMetrics(),r=t.getViewMetrics();t=t.getAbsoluteMetrics(),typeof e.x==`number`&&(this.workspace_.scrollX=-(n.left+(n.width-r.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();let t=e.getAbsoluteMetrics(),n=e.getViewMetrics();e=e.getToolboxMetrics();let r=this.toolboxPosition_===B.TOP;return this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?r?e.height:n.height-this.getHeight():r?0:n.height:r?0:n.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){let n=this.toolboxPosition_===B.TOP,r=[`M 0,`+(n?0:this.CORNER_RADIUS)];n?(r.push(`h`,e+2*this.CORNER_RADIUS),r.push(`v`,t),r.push(`a`,this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,-this.CORNER_RADIUS,this.CORNER_RADIUS),r.push(`h`,-e),r.push(`a`,this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,-this.CORNER_RADIUS,-this.CORNER_RADIUS)):(r.push(`a`,this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,this.CORNER_RADIUS,-this.CORNER_RADIUS),r.push(`h`,e),r.push(`a`,this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,this.CORNER_RADIUS,this.CORNER_RADIUS),r.push(`v`,t),r.push(`h`,-e-2*this.CORNER_RADIUS)),r.push(`z`),this.svgBackground_.setAttribute(`d`,r.join(` `))}scrollToStart(){let e;(e=this.workspace_.scrollbar)==null||e.setX(this.RTL?1/0:0)}wheel_(e){var t=te(e);if(t=t.x||t.y){let e=this.workspace_.getMetricsManager(),n=e.getScrollMetrics();t=e.getViewMetrics().left-n.left+t;let r;(r=this.workspace_.scrollbar)==null||r.setX(t),Fi(this.workspace_),Lr()}e.preventDefault(),e.stopPropagation()}layout_(e){this.workspace_.scale=this.targetWorkspace.scale;let t=this.MARGIN,n=t+this.tabWidth_;this.RTL&&(e=e.reverse());for(let r of e)e=r.getElement().getBoundingRectangle(),e=this.RTL?n+e.getWidth():n,r.getElement().moveBy(e,t),n+=r.getElement().getBoundingRectangle().getWidth()}isDragTowardWorkspace(e){e=Math.atan2(e.y,e.x)/Math.PI*180;let 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;let e=this.svgGroup_.getBoundingClientRect(),t=e.top;return this.toolboxPosition_===B.TOP?new R(-1e9,t+e.height,-1e9,1e9):new R(t,1e9,-1e9,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let e=this.getContents().reduce((e,t)=>Math.max(e,t.getElement().getBoundingRectangle().getHeight()),0);e+=this.MARGIN*1.5,e*=this.workspace_.scale,e+=Yl.scrollbarThickness,this.getHeight()!==e&&(this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==B.TOP||this.targetWorkspace.translate(this.targetWorkspace.scrollX,this.targetWorkspace.scrollY+e),this.height_=e,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets())}};t(P.FLYOUTS_HORIZONTAL_TOOLBOX,uc,iy);var ay={};ay.HorizontalFlyout=iy;var oy=class extends yp{constructor(e,t,n,r,i){super(xf.SKIP_SETUP),this.defaultType=``,this.variableTypes=[],this.variable=null,this.SERIALIZABLE=!0,this.menuGenerator_=oy.dropdownCreate,this.defaultVariableName=typeof e==`string`?e:``,this.size_=new z(0,0),e!==xf.SKIP_SETUP&&(i?this.configure_(i):this.setTypes(n,r),t&&this.setValidator(t))}configure_(e){super.configure_(e),this.setTypes(e.variableTypes,e.defaultType)}initModel(){var t=this.getSourceBlock();if(!t)throw new Sf;this.variable||(t=e.getOrCreateVariablePackage$$module$build$src$core$variables(t.workspace,null,this.defaultVariableName,this.defaultType),this.doValueUpdate_(t.getId()))}initView(){super.initView(),O(this.fieldGroup_,`blocklyVariableField`)}shouldAddBorderRect_(){let e=this.getSourceBlock();if(!e)throw new Sf;return super.shouldAddBorderRect_()&&(!this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW||e.type!==`variables_get`)}fromXml(t){var n=this.getSourceBlock();if(!n)throw new Sf;let r=t.getAttribute(`id`),i=t.textContent,a=t.getAttribute(`variabletype`)||t.getAttribute(`variableType`)||``;if(n=e.getOrCreateVariablePackage$$module$build$src$core$variables(n.workspace,r,i,a),a!==null&&a!==n.getType())throw Error(`Serialized variable type with id '`+n.getId()+`' had type `+n.getType()+`, and does not match variable field that references it: `+la(t)+`.`);this.setValue(n.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(oy);return t===null?(this.initModel(),t={id:this.variable.getId()},e&&(t.name=this.variable.getName(),t.type=this.variable.getType()),t):t}loadState(t){let n=this.getSourceBlock();if(!n)throw new Sf;this.loadLegacyState(oy,t)||(t=e.getOrCreateVariablePackage$$module$build$src$core$variables(n.workspace,t.id||null,t.name,t.type||``),this.setValue(t.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_(t){if(t===null)return null;var n=this.getSourceBlock();if(!n)throw new Sf;return n=e.getVariable$$module$build$src$core$variables(n.workspace,t),n?(n=n.getType(),this.typeIsAllowed(n)?t:(console.warn(`Variable type doesn't match this field! Type was `+n),null)):(console.warn(`Variable id doesn't point to a real variable! ID was `+t),null)}doValueUpdate_(t){let n=this.getSourceBlock();if(!n)throw new Sf;this.variable=e.getVariable$$module$build$src$core$variables(n.workspace,t),super.doValueUpdate_(t)}typeIsAllowed(e){let t=this.getVariableTypes();if(!t)return!0;for(let n=0;n<t.length;n++)if(e===t[n])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){let t=this.sourceBlock_.workspace.getPotentialVariableMap();if(!t)return e;e=Array.from(new Set([...e,...t.getTypes()]))}return e}setTypes(e=null,t=``){var n=this.getText();if(Array.isArray(e)){if(e.length===0)throw Error(`'variableTypes' of field variable ${n} was an empty list. If you want to include all variable types, pass 'null' instead.`);n=!1;for(let r=0;r<e.length;r++)e[r]===t&&(n=!0);if(!n)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 ${n}`);this.defaultType=t,this.variableTypes=e}refreshVariableName(){this.forceRerender()}onItemSelected_(t,n){if(t=n.getValue(),this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()){if(t===cm&&this.variable){e.renameVariable$$module$build$src$core$variables(this.sourceBlock_.workspace,this.variable);return}if(t===lm&&this.variable){t=this.variable.getWorkspace(),e.deleteVariable$$module$build$src$core$variables(t,this.variable,this.sourceBlock_);return}}this.setValue(t)}referencesVariables(){return!0}static fromJson(e){return new this(Ti(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.`);let t=this.getText(),n=[];var r=this.getSourceBlock();if(r&&!r.isDeadOrDying()){r=r.workspace;let e=this.getVariableTypes();for(let t=0;t<e.length;t++){let o=e[t],s=r.getVariableMap().getVariablesOfType(o);if(n=n.concat(s),r.isFlyout){var i=void 0,a=void 0;n=n.concat((a=(i=r.getPotentialVariableMap())?.getVariablesOfType(o))??[])}}}for(n.sort(Un),i=[],a=0;a<n.length;a++)i[a]=[n[a].getName(),n[a].getId()];return i.push([e.Msg$$module$build$src$core$msg.RENAME_VARIABLE,cm]),e.Msg$$module$build$src$core$msg.DELETE_VARIABLE&&i.push([e.Msg$$module$build$src$core$msg.DELETE_VARIABLE.replace(`%1`,t),lm]),i}};Oa(`field_variable`,oy);var sy={};sy.FieldVariable=oy;var cy=class extends Nv{constructor(e,t,n,r,i,a){super(xf.SKIP_SETUP),this.min_=-1/0,this.max_=1/0,this.precision_=0,this.decimalPlaces=null,this.spellcheck_=!1,e!==xf.SKIP_SETUP&&(a?this.configure_(a):this.setConstraints(t,n,r),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,n){this.setMinInternal(e),this.setMaxInternal(t),this.setPrecisionInternal(n),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}));let n=t.indexOf(`.`);this.decimalPlaces=n===-1?e?0:null:t.length-n-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_(){let e=super.widgetCreate_();return this.min_>-1/0&&(e.min=`${this.min_}`,en(e,ju.VALUEMIN,this.min_)),this.max_<1/0&&(e.max=`${this.max_}`,en(e,ju.VALUEMAX,this.max_)),e}initView(){super.initView(),this.fieldGroup_&&O(this.fieldGroup_,`blocklyNumberField`)}static fromJson(e){return new this(e.value,void 0,void 0,void 0,void 0,e)}};Oa(`field_number`,cy),cy.prototype.DEFAULT_VALUE=0;var ly={};ly.FieldNumber=cy;var uy=class extends im{constructor(e,t,n){super(String(e??``),t,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}static fromJson(e){return new this(Ti(e.text),void 0,e)}};Oa(`field_label_serializable`,uy);var dy={};dy.FieldLabelSerializable=uy;var fy=class extends xf{constructor(e,t,n){super(xf.SKIP_SETUP),this.SERIALIZABLE=!0,this.value_=this.value_,this.checkChar=fy.CHECK_CHAR,e!==xf.SKIP_SETUP&&(n&&this.configure_(n),this.setValue(e),t&&this.setValidator(t))}configure_(e){super.configure_(e),e.checkCharacter&&(this.checkChar=e.checkCharacter)}saveState(){let e=this.saveLegacyState(fy);return e===null?this.getValueBoolean():e}initView(){super.initView();let e=this.getTextElement();O(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||fy.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)}};fy.CHECK_CHAR=`✓`,Oa(`field_checkbox`,fy),fy.prototype.DEFAULT_VALUE=!1;var py={};py.FieldCheckbox=fy;var my=class{constructor(e,t){this.draggable=e,this.workspace=t,this.dragTarget=null,this.startLoc=e.getRelativeToSurfaceXY()}onDragStart(t){e.getGroup$$module$build$src$core$events$utils()||e.setGroup$$module$build$src$core$events$utils(!0),this.draggable.startDrag(t)}onDrag(e,t){this.moveDraggable(e,t),t=this.getRoot(this.draggable),_o(t)&&t.setDeleteStyle(this.wouldDeleteDraggable(e,t)),this.updateDragTarget(e)}updateDragTarget(e){e=this.workspace.getDragTarget(e);let t=this.getRoot(this.draggable);if(this.dragTarget!==e){let n;(n=this.dragTarget)==null||n.onDragExit(t),e?.onDragEnter(t)}e?.onDragOver(t),this.dragTarget=e}moveDraggable(e,t){t=this.pixelsToWorkspaceUnits(t),t=I.sum(this.startLoc,t),this.draggable.drag(t,e)}wouldDeleteDraggable(e,t){return(e=this.workspace.getDragTarget(e))&&this.workspace.getComponentManager().hasCapability(e.id,Pl.Capability.DELETE_AREA)?e.wouldDelete(t):!1}onDragEnd(t){let n=e.getGroup$$module$build$src$core$events$utils();var r=this.workspace.getDragTarget(t);let i=this.getRoot(this.draggable);if(r){let e;(e=this.dragTarget)==null||e.onDrop(i)}this.shouldReturnToStart(t,i)&&this.draggable.revertDrag(),(r=_o(i)&&this.wouldDeleteDraggable(t,i))&&this.draggable instanceof Bm&&ro(this.draggable.getRootBlock()),this.draggable.endDrag(t),r&&_o(i)&&(e.setGroup$$module$build$src$core$events$utils(n),i.dispose()),e.setGroup$$module$build$src$core$events$utils(!1),!r&&Ge(this.draggable)&&e.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.draggable)}getRoot(e){return e instanceof Bm?e.getRootBlock():e}shouldReturnToStart(e,t){return(e=this.workspace.getDragTarget(e))?e.shouldPreventMove(t):!1}pixelsToWorkspaceUnits(e){return e=new I(e.x/this.workspace.scale,e.y/this.workspace.scale),this.workspace.isMutator&&e.scale(1/this.workspace.options.parentWorkspace.scale),e}};t(P.BLOCK_DRAGGER,uc,my);var hy={};hy.Dragger=my;var gy={};gy.BlockDragStrategy=Nm,gy.BubbleDragStrategy=Ep,gy.CommentDragStrategy=Hf,gy.Dragger=my;var _y=class extends Dl{constructor(e,t,n){super(e?e.workspace.id:void 0),this.type=F.BLOCK_DRAG,e&&(this.blockId=e.id,this.isStart=t,this.blocks=n)}toJson(){let 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,n){return t=Dl.fromJson(e,t,n??new _y),t.isStart=e.isStart,t.blockId=e.blockId,t.blocks=e.blocks,t}};t(P.EVENT,F.BLOCK_DRAG,_y);var vy={};vy.BlockDrag=_y;var yy=class extends K{constructor(e,t,n,r){super(e),this.type=F.BLOCK_FIELD_INTERMEDIATE_CHANGE,this.recordUndo=!1,e&&(this.name=t,this.oldValue=n,this.newValue=r)}toJson(){let 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,n){return t=K.fromJson(e,t,n??new yy),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)}};t(P.EVENT,F.BLOCK_FIELD_INTERMEDIATE_CHANGE,yy);var by={};by.BlockFieldIntermediateChange=yy;var xy=class extends K{constructor(e){super(e),this.type=F.BLOCK_MOVE,e&&(e.isShadow()&&(this.recordUndo=!1),e=this.currentLocation(),this.oldParentId=e.parentId,this.oldInputName=e.inputName,this.oldCoordinate=e.coordinate)}toJson(){let 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,n){return t=K.fromJson(e,t,n??new xy),t.oldParentId=e.oldParentId,t.oldInputName=e.oldInputName,e.oldCoordinate&&(n=e.oldCoordinate.split(`,`),t.oldCoordinate=new I(Number(n[0]),Number(n[1]))),t.newParentId=e.newParentId,t.newInputName=e.newInputName,e.newCoordinate&&(n=e.newCoordinate.split(`,`),t.newCoordinate=new I(Number(n[0]),Number(n[1]))),e.reason!==void 0&&(t.reason=e.reason),e.recordUndo!==void 0&&(t.recordUndo=e.recordUndo),t}recordNew(){let 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={};let n=t.getParent();return n?(e.parentId=n.id,(t=n.getInputWithBlock(t))&&(e.inputName=t.name)):e.coordinate=t.getRelativeToSurfaceXY(),e}isNull(){return this.oldParentId===this.newParentId&&this.oldInputName===this.newInputName&&I.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 n=t.getBlockById(this.blockId);if(n){var r=e?this.newParentId:this.oldParentId,i=e?this.newInputName:this.oldInputName;if(e=e?this.newCoordinate:this.oldCoordinate,r){var a=t.getBlockById(r);if(!a){console.warn(`Can't connect to non-existent block: `+r);return}}if(n.getParent()&&n.unplug(),e)i=n.getRelativeToSurfaceXY(),n.moveBy(e.x-i.x,e.y-i.y,this.reason);else{t=n.outputConnection,(!t||n.previousConnection&&n.previousConnection.isConnected())&&(t=n.previousConnection);let e;n=t?.type,i?(n=a.getInput(i))&&(e=n.connection):n===Y.PREVIOUS_STATEMENT&&(e=a.nextConnection),e&&t?t.connect(e):console.warn(`Can't connect to non-existent input: `+i)}}else console.warn(`Can't move non-existent block: `+this.blockId)}};t(P.EVENT,F.BLOCK_MOVE,xy);var Sy={};Sy.BlockMove=xy;var Cy=class extends Dl{constructor(e,t,n){super(e?e.workspace.id:void 0),this.type=F.BUBBLE_OPEN,e&&(this.blockId=e.id,this.isOpen=t,this.bubbleType=n)}toJson(){let 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,n){return t=Dl.fromJson(e,t,n??new Cy),t.isOpen=e.isOpen,t.bubbleType=e.bubbleType,t.blockId=e.blockId,t}},wy;(function(e){e.MUTATOR=`mutator`,e.COMMENT=`comment`,e.WARNING=`warning`})(wy||(wy={})),t(P.EVENT,F.BUBBLE_OPEN,Cy);var Ty={};Ty.BubbleOpen=Cy,Ty.BubbleType=wy;var Ey=class extends Tl{constructor(t){super(),this.isBlank=!0,this.isBlank=!t,t&&(this.commentId=t.id,this.workspaceId=t.workspace.id,this.group=e.getGroup$$module$build$src$core$events$utils(),this.recordUndo=Te())}toJson(){let 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,n){return t=Tl.fromJson(e,t,n??new Ey),t.commentId=e.commentId,t}static CommentCreateDeleteHelper(e,t){let n=e.getEventWorkspace_();if(t){if(!e.json)throw Error(`Encountered a comment event without proper json`);Jt(e.json,n)}else{if(!e.commentId)throw Error(`The comment ID is undefined. Either pass a comment to the constructor, or call fromJson`);(t=n.getCommentById(e.commentId))?t.dispose():console.warn(`Can't delete non-existent comment: `+e.commentId)}}},Dy={};Dy.CommentBase=Ey;var Oy=class extends Ey{constructor(e,t,n){super(e),this.type=F.COMMENT_CHANGE,e&&(this.oldContents_=t===void 0?``:t,this.newContents_=n===void 0?``:n)}toJson(){let 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,n){return t=Ey.fromJson(e,t,n??new Oy),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 n=e?this.newContents_:this.oldContents_;if(n===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(n)}else console.warn(`Can't change non-existent comment: `+this.commentId)}};t(P.EVENT,F.COMMENT_CHANGE,Oy);var ky={};ky.CommentChange=Oy;var Ay=class extends Ey{constructor(e,t){super(e),this.newCollapsed=t,this.type=F.COMMENT_COLLAPSE}toJson(){let 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,n){return t=Ey.fromJson(e,t,n??new Ay),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)}};t(P.EVENT,F.COMMENT_COLLAPSE,Ay);var jy={};jy.CommentCollapse=Ay;var My=class extends Ey{constructor(e){super(e),this.type=F.COMMENT_CREATE,e&&(this.xml=na(e),this.json=qt(e,{addCoordinates:!0}))}toJson(){let 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=la(this.xml),e.json=this.json,e}static fromJson(t,n,r){return n=Ey.fromJson(t,n,r??new My),n.xml=e.textToDom$$module$build$src$core$utils$xml(t.xml),n.json=t.json,n}run(e){Ey.CommentCreateDeleteHelper(this,e)}};t(P.EVENT,F.COMMENT_CREATE,My);var Ny={};Ny.CommentCreate=My;var Py=class extends Ey{constructor(e){super(e),this.type=F.COMMENT_DELETE,e&&(this.xml=na(e),this.json=qt(e,{addCoordinates:!0}))}run(e){Ey.CommentCreateDeleteHelper(this,!e)}toJson(){let 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=la(this.xml),e.json=this.json,e}static fromJson(t,n,r){return n=Ey.fromJson(t,n,r??new Py),n.xml=e.textToDom$$module$build$src$core$utils$xml(t.xml),n.json=t.json,n}};t(P.EVENT,F.COMMENT_DELETE,Py);var Fy={};Fy.CommentDelete=Py;var Iy=class extends Dl{constructor(e,t){super(e?e.workspace.id:void 0),this.type=F.COMMENT_DRAG,e&&(this.commentId=e.id,this.isStart=t)}toJson(){let 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,n){return t=Dl.fromJson(e,t,n??new Iy),t.isStart=e.isStart,t.commentId=e.commentId,t}};t(P.EVENT,F.COMMENT_DRAG,Iy);var Ly={};Ly.CommentDrag=Iy;var Ry=class extends Ey{constructor(e){super(e),this.type=F.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(){let 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,n){return t=Ey.fromJson(e,t,n??new Ry),n=e.oldCoordinate.split(`,`),t.oldCoordinate_=new I(Number(n[0]),Number(n[1])),n=e.newCoordinate.split(`,`),t.newCoordinate_=new I(Number(n[0]),Number(n[1])),t}isNull(){return I.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)}};t(P.EVENT,F.COMMENT_MOVE,Ry);var zy={};zy.CommentMove=Ry;var By=class extends Ey{constructor(e){super(e),this.type=F.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(){let 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,n){return t=Ey.fromJson(e,t,n??new By),t.oldSize=new z(e.oldWidth,e.oldHeight),t.newSize=new z(e.newWidth,e.newHeight),t}isNull(){return z.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)}};t(P.EVENT,F.COMMENT_RESIZE,By);var Vy={};Vy.CommentResize=By;var Hy=class extends Dl{constructor(e,t,n){super(n),this.type=F.TOOLBOX_ITEM_SELECT,this.oldItem=e??void 0,this.newItem=t??void 0}toJson(){let e=super.toJson();return e.oldItem=this.oldItem,e.newItem=this.newItem,e}static fromJson(e,t,n){return t=Dl.fromJson(e,t,n??new Hy),t.oldItem=e.oldItem,t.newItem=e.newItem,t}};t(P.EVENT,F.TOOLBOX_ITEM_SELECT,Hy);var Uy={};Uy.ToolboxItemSelect=Hy;var Wy=class extends N_{constructor(e,t,n){super(e),this.oldType=t,this.newType=n,this.type=F.VAR_TYPE_CHANGE}toJson(){let 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,n){return t=N_.fromJson(e,t,n??new Wy),t.oldType=e.oldType,t.newType=e.newType,t}run(e){let 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`);let n=t.getVariableMap().getVariableById(this.varId);n&&(e?t.getVariableMap().changeVariableType(n,this.newType):t.getVariableMap().changeVariableType(n,this.oldType))}};t(P.EVENT,F.VAR_TYPE_CHANGE,Wy);var Gy={};Gy.VarTypeChange=Wy;var Ky=class extends Tl{constructor(e){super(),this.isBlank=!0,this.recordUndo=!1,this.type=F.FINISHED_LOADING,this.isBlank=!!e,e&&(this.workspaceId=e.id)}};t(P.EVENT,F.FINISHED_LOADING,Ky);var qy={};qy.FinishedLoading=Ky;var Jy,Yy,Xy,Zy,Qy,$y,eb,tb,nb,rb,ib,ab,ob,sb,cb,lb,ub,db,fb,pb,mb,hb,gb,_b,Q;e.BLOCK_CHANGE$$module$build$src$core$events$events=F.BLOCK_CHANGE,e.BLOCK_CREATE$$module$build$src$core$events$events=F.BLOCK_CREATE,e.BLOCK_DELETE$$module$build$src$core$events$events=F.BLOCK_DELETE,Jy=F.BLOCK_DRAG,e.BLOCK_MOVE$$module$build$src$core$events$events=F.BLOCK_MOVE,Yy=F.BLOCK_FIELD_INTERMEDIATE_CHANGE,Xy=F.BUBBLE_OPEN,Zy=F.BLOCK_CHANGE,Qy=F.CLICK,$y=F.COMMENT_CHANGE,eb=F.COMMENT_CREATE,tb=F.COMMENT_DELETE,nb=F.COMMENT_MOVE,rb=F.COMMENT_RESIZE,ib=F.COMMENT_DRAG,ab=F.BLOCK_CREATE,ob=F.BLOCK_DELETE,sb=F.FINISHED_LOADING,cb=F.BLOCK_MOVE,lb=F.SELECTED,ub=F.THEME_CHANGE,db=F.TOOLBOX_ITEM_SELECT,fb=F.TRASHCAN_OPEN,pb=F.UI,mb=F.VAR_CREATE,hb=F.VAR_DELETE,gb=F.VAR_RENAME,_b=F.VIEWPORT_CHANGE,Q={},Q.Abstract=Tl,Q.BLOCK_CHANGE=e.BLOCK_CHANGE$$module$build$src$core$events$events,Q.BLOCK_CREATE=e.BLOCK_CREATE$$module$build$src$core$events$events,Q.BLOCK_DELETE=e.BLOCK_DELETE$$module$build$src$core$events$events,Q.BLOCK_DRAG=Jy,Q.BLOCK_FIELD_INTERMEDIATE_CHANGE=Yy,Q.BLOCK_MOVE=e.BLOCK_MOVE$$module$build$src$core$events$events,Q.BUBBLE_OPEN=Xy,Q.BUMP_EVENTS=Vc,Q.BlockBase=K,Q.BlockChange=Ad,Q.BlockCreate=up,Q.BlockDelete=Qp,Q.BlockDrag=_y,Q.BlockFieldIntermediateChange=yy,Q.BlockMove=xy,Q.BubbleOpen=Cy,Q.BubbleType=wy,Q.CHANGE=Zy,Q.CLICK=Qy,Q.COMMENT_CHANGE=$y,Q.COMMENT_CREATE=eb,Q.COMMENT_DELETE=tb,Q.COMMENT_DRAG=ib,Q.COMMENT_MOVE=nb,Q.COMMENT_RESIZE=rb,Q.CREATE=ab,Q.Click=kl,Q.ClickTarget=Al,Q.CommentBase=Ey,Q.CommentChange=Oy,Q.CommentCollapse=Ay,Q.CommentCreate=My,Q.CommentDelete=Py,Q.CommentDrag=Iy,Q.CommentMove=Ry,Q.CommentResize=By,Q.DELETE=ob,Q.FINISHED_LOADING=sb,Q.FinishedLoading=Ky,Q.MOVE=cb,Q.SELECTED=lb,Q.Selected=Xp,Q.THEME_CHANGE=ub,Q.TOOLBOX_ITEM_SELECT=db,Q.TRASHCAN_OPEN=fb,Q.ThemeChange=pp,Q.ToolboxItemSelect=Hy,Q.TrashcanOpen=G_,Q.UI=pb,Q.UiBase=Dl,Q.VAR_CREATE=mb,Q.VAR_DELETE=hb,Q.VAR_RENAME=gb,Q.VIEWPORT_CHANGE=_b,Q.VarBase=N_,Q.VarCreate=F_,Q.VarDelete=z_,Q.VarRename=V_,Q.VarTypeChange=Wy,Q.ViewportChange=hp,Q.clearPendingUndo=Ae,Q.disable=e.disable$$module$build$src$core$events$utils,Q.disableOrphans=Pe,Q.enable=e.enable$$module$build$src$core$events$utils,Q.filter=ke,Q.fire=w,Q.fromJson=T,Q.get=E,Q.getDescendantIds=Ne,Q.getGroup=e.getGroup$$module$build$src$core$events$utils,Q.getRecordUndo=Te,Q.isEnabled=je,Q.setGroup=e.setGroup$$module$build$src$core$events$utils,Q.setRecordUndo=e.setRecordUndo$$module$build$src$core$events$utils;var vb={};vb.BottomRow=Iv,vb.ConstantProvider=Ev,vb.Drawer=Ov,vb.PathObject=Kv,vb.RenderInfo=Wv,vb.Renderer=Jv,vb.RightConnectionShape=Bv,vb.StatementInput=Rv,vb.TopRow=Hv,tc();var yb={};yb.registerCleanup=Ps,yb.registerCollapse=Is,yb.registerCollapseExpandBlock=Ks,yb.registerComment=Ws,yb.registerCommentCreate=Qs,yb.registerCommentDelete=Xs,yb.registerCommentDuplicate=Zs,yb.registerCommentOptions=ec,yb.registerDefaultOptions=tc,yb.registerDelete=Js,yb.registerDeleteAll=Vs,yb.registerDisable=qs,yb.registerDuplicate=Us,yb.registerExpand=Ls,yb.registerHelp=Ys,yb.registerInline=Gs,yb.registerRedo=Ns,yb.registerUndo=Ms;var bb=`button`,xb=class{load(e,t){return e=new $m(t.getWorkspace(),t.targetWorkspace,e,!1),e.show(),new qm(e,bb)}gapForItem(e,t){return t}disposeItem(e){e=e.getElement(),e instanceof $m&&e.dispose()}getType(){return bb}};t(P.FLYOUT_INFLATER,bb,xb);var Sb={};Sb.ButtonFlyoutInflater=xb;var Cb={};Cb.Bubble=kp,Cb.MiniWorkspaceBubble=jp,Cb.TextBubble=Fm,Cb.TextInputBubble=Gp;var wb=`WORKSPACE_AT_BLOCK_CAPACITY`,Tb=`block`,Eb=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(e=>e.isInFlyout=!0),this.addBlockListeners(e),new qm(e,Tb)}createBlock(t,n){return t.blockxml?(t=typeof t.blockxml==`string`?e.textToDom$$module$build$src$core$utils$xml(t.blockxml):t.blockxml,n=ma(t,n)):(t.enabled===void 0&&(t.enabled=t.disabled!==`true`&&t.disabled!==!0),t.disabledReasons===void 0&&t.enabled===!1&&(t.disabledReasons=[Vu]),`x`in t&&delete t.x,`y`in t&&delete t.y,n=tr(t,n)),n}gapForItem(t,n){let r;return t.gap?r=parseInt(String(t.gap)):t.blockxml&&(t=typeof t.blockxml==`string`?e.textToDom$$module$build$src$core$utils$xml(t.blockxml):t.blockxml,r=parseInt(t.getAttribute(`gap`))),!r||isNaN(r)?n:r}disposeItem(e){e=e.getElement(),e instanceof Bm&&(this.removeListeners(e.id),e.dispose(!1,!1))}removeListeners(e){(this.listeners.get(e)??[]).forEach(e=>v(e)),this.listeners.delete(e)}setFlyout(e){if(this.flyout!==e){if(this.flyout){let e;(e=this.flyout.targetWorkspace)==null||e.removeChangeListener(this.capacityWrapper)}this.flyout=e;var t;(t=this.flyout.targetWorkspace)==null||t.addChangeListener(this.capacityWrapper)}}updateStateBasedOnCapacity(e){let t=this.flyout?.targetWorkspace?.isCapacityAvailable(ot(e));for(;e;)e.setDisabledReason(!t,wb),e=e.getNextBlock()}addBlockListeners(e){let t=[];t.push(g(e.getSvgRoot(),`pointerdown`,e,t=>{let n=this.flyout?.targetWorkspace?.getGesture(t);n&&this.flyout&&(n.setStartBlock(e),n.handleFlyoutStart(t,this.flyout))})),t.push(_(e.getSvgRoot(),`pointermove`,null,()=>{let t,n;(t=this.flyout)!=null&&(n=t.targetWorkspace)!=null&&n.isDragging()||e.addSelect()})),t.push(_(e.getSvgRoot(),`pointerleave`,null,()=>{let t,n;(t=this.flyout)!=null&&(n=t.targetWorkspace)!=null&&n.isDragging()||e.removeSelect()})),this.listeners.set(e.id,t)}filterFlyoutBasedOnCapacity(e){!this.flyout||e&&e.type!==F.BLOCK_CREATE&&e.type!==F.BLOCK_DELETE||this.flyout.getWorkspace().getTopBlocks(!1).forEach(e=>{this.permanentlyDisabledBlocks.has(e)||this.updateStateBasedOnCapacity(e)})}getType(){return Tb}};t(P.FLYOUT_INFLATER,Tb,Eb);var Db={};Db.BlockFlyoutInflater=Eb;var Ob={};Ob.isPaster=nc;var kb={};kb.isRenderedElement=rc;var Ab=class extends c_{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;`,`}`])}},jb={};jb.ConstantProvider=Ab;var Mb=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_+`
|
|
672
|
+
`+this.inlineSteps_}drawTopCorner(e){this.steps_+=Ja(e.xPos,this.info_.startY);for(let t=0,n;n=e.elements[t];t++)Z.isLeftSquareCorner(n)?this.steps_+=this.highlightConstants_.START_POINT:Z.isLeftRoundedCorner(n)?this.steps_+=this.outsideCornerPaths_.topLeft(this.RTL_):Z.isPreviousConnection(n)?this.steps_+=this.notchPaths_.pathLeft:Z.isHat(n)?this.steps_+=this.startPaths_.path(this.RTL_):Z.isSpacer(n)&&n.width!==0&&(this.steps_+=M(`H`,n.xPos+n.width-this.highlightOffset));this.steps_+=M(`H`,e.xPos+e.width-this.highlightOffset)}drawJaggedEdge_(e){this.info_.RTL&&(this.steps_+=this.jaggedTeethPaths_.pathLeft+M(`v`,e.height-this.jaggedTeethPaths_.height-this.highlightOffset))}drawValueInput(e){let t=e.getLastInput();if(this.RTL_){let n=e.height-t.connectionHeight;this.steps_+=qa(t.xPos+t.width-this.highlightOffset,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)+M(`v`,n)}else this.steps_+=qa(t.xPos+t.width,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)}drawStatementInput(e){let t=e.getLastInput();if(t)if(this.RTL_){let n=e.height-2*this.insideCornerPaths_.height;this.steps_+=qa(t.xPos,e.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+M(`v`,n)+this.insideCornerPaths_.pathBottom(this.RTL_)+Ya(e.width-t.xPos-this.insideCornerPaths_.width,0)}else this.steps_+=qa(t.xPos,e.yPos+e.height)+this.insideCornerPaths_.pathBottom(this.RTL_)+Ya(e.width-t.xPos-this.insideCornerPaths_.width,0)}drawRightSideRow(e){let t=e.xPos+e.width-this.highlightOffset;e instanceof e_&&e.followsStatement&&(this.steps_+=M(`H`,t)),this.RTL_&&(this.steps_+=M(`H`,t),e.height>this.highlightOffset&&(this.steps_+=M(`V`,e.yPos+e.height-this.highlightOffset)))}drawBottomRow(e){if(this.RTL_)this.steps_+=M(`V`,e.baseline-this.highlightOffset);else{let t=this.info_.bottomRow.elements[0];Z.isLeftSquareCorner(t)?this.steps_+=qa(e.xPos+this.highlightOffset,e.baseline-this.highlightOffset):Z.isLeftRoundedCorner(t)&&(this.steps_+=qa(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_+=qa(this.info_.startX,e):(this.steps_+=qa(this.info_.startX+this.highlightOffset,this.info_.bottomRow.baseline-this.highlightOffset),this.steps_+=M(`V`,e)),this.steps_+=this.puzzleTabPaths_.pathUp(this.RTL_)),this.RTL_||(e=this.info_.topRow,Z.isLeftRoundedCorner(e.elements[0])?this.steps_+=M(`V`,this.outsideCornerPaths_.height):this.steps_+=M(`V`,e.capline+this.highlightOffset))}drawInlineInput(e){let t=this.highlightOffset,n=e.xPos+e.connectionWidth;var r=e.centerline-e.height/2;let i=e.width-e.connectionWidth,a=r+t;this.RTL_?(r=e.connectionOffsetY-t,e=e.height-(e.connectionOffsetY+e.connectionHeight)+t,this.inlineSteps_+=qa(n-t,a)+M(`v`,r)+this.puzzleTabPaths_.pathDown(this.RTL_)+M(`v`,e)+M(`h`,i)):this.inlineSteps_+=qa(e.xPos+e.width+t,a)+M(`v`,e.height)+M(`h`,-i)+qa(n,r+e.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)}},Nb={};Nb.Highlighter=Mb;var Pb=class extends u_{constructor(e,t){super(e,t),this.highlighter_=new Mb(t)}draw(){this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights();let e=this.block_.pathObject;e.setPath(this.outlinePath_+`
|
|
673
|
+
`+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_+=M(`H`,e.xPos+e.width)+M(`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){let t=e.centerline-e.height/2;if(e.connectionModel){let n=e.xPos+e.connectionWidth+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(n*=-1),e.connectionModel.setOffsetInBlock(n,t+e.connectionOffsetY+this.constants_.DARK_PATH_OFFSET)}}positionStatementInputConnection_(e){let t=e.getLastInput();if(t!=null&&t.connectionModel){let n=e.xPos+e.statementEdge+t.notchOffset;n=this.info_.RTL?n*-1:n+this.constants_.DARK_PATH_OFFSET,t.connectionModel.setOffsetInBlock(n,e.yPos+this.constants_.DARK_PATH_OFFSET)}}positionExternalValueConnection_(e){let t=e.getLastInput();if(t&&t.connectionModel){let n=e.xPos+e.width+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(n*=-1),t.connectionModel.setOffsetInBlock(n,e.yPos)}}positionNextConnection_(){let e=this.info_.bottomRow;if(e.connection){let t=e.connection,n=t.xPos;t.connectionModel.setOffsetInBlock((this.info_.RTL?-n:n)+this.constants_.DARK_PATH_OFFSET/2,e.baseline+this.constants_.DARK_PATH_OFFSET)}}},Fb={};Fb.Drawer=Pb;var Ib=class{constructor(e){this.OFFSET=.5,this.constantProvider=e,this.START_POINT=Ja(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(){let e=this.constantProvider.CORNER_RADIUS,t=this.OFFSET,n=(1-Math.SQRT1_2)*(e+t)-t,r=Ja(n,n)+Za(`a`,`0 0,0`,e,j(-n-t,e-n)),i=Za(`a`,`0 0,0`,e+t,j(e+t,e+t)),a=Ja(n,-n)+Za(`a`,`0 0,0`,e+t,j(e-n,n+t));return{width:e+t,height:e,pathTop(e){return e?r:``},pathBottom(e){return e?i:a}}}makeOutsideCorner(){let e=this.constantProvider.CORNER_RADIUS,t=this.OFFSET,n=(1-Math.SQRT1_2)*(e-t)+t,r=Ja(n,n)+Za(`a`,`0 0,1`,e-t,j(e-n,-n+t)),i=Ja(t,e)+Za(`a`,`0 0,1`,e-t,j(e,-e+t)),a=-n,o=Ja(n,a)+Za(`a`,`0 0,1`,e-t,j(-n+t,-a-e));return{height:e,topLeft(e){return e?r:i},bottomLeft(){return o}}}makePuzzleTab(){let e=this.constantProvider.TAB_WIDTH,t=this.constantProvider.TAB_HEIGHT,n=Ja(-2,-t+2.5+.9)+Ya(e*-.45,-2.1),r=M(`v`,2.5)+Ja(-e*.97,2.5)+Ka(`q`,[j(-e*.05,10),j(e*.3,9.5)])+Ja(e*.67,-1.9)+M(`v`,2.5),i=M(`v`,-1.5)+Ja(e*-.92,-.5)+Ka(`q`,[j(e*-.19,-5.5),j(0,-11)])+Ja(e*.92,1),a=Ja(-5,t-.7)+Ya(e*.46,-2.1);return{width:e,height:t,pathUp(e){return e?n:i},pathDown(e){return e?r:a}}}makeNotch(){return{pathLeft:M(`h`,this.OFFSET)+this.constantProvider.NOTCH.pathLeft}}makeJaggedTeeth(){return{pathLeft:Ya(5.1,2.6)+Ja(-10.2,6.8)+Ya(5.1,2.6),height:12,width:10.2}}makeStartHat(){let e=this.constantProvider.START_HAT.height,t=Ja(25,-8.7)+Ka(`c`,[j(29.7,-6.2),j(57.2,-.5),j(75,8.7)]),n=Ka(`c`,[j(17.8,-9.2),j(45.3,-14.9),j(75,-8.7)])+qa(100.5,e+.5);return{path(e){return e?t:n}}}},Lb={};Lb.HighlightConstantProvider=Ib;var Rb=class extends Bg{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)}},zb={};zb.InlineInput=Rb;var Bb=class extends i_{constructor(e,t){super(e,t),this.constants_=e,this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}},Vb={};Vb.StatementInput=Bb;var Hb=class extends f_{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 bm||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(t,n){this.isInline&&t instanceof e.ValueInput$$module$build$src$core$inputs$value_input?(n.elements.push(new Rb(this.constants_,t)),n.hasInlineInput=!0):t instanceof bm?(n.elements.push(new Bb(this.constants_,t)),n.hasStatement=!0):t instanceof e.ValueInput$$module$build$src$core$inputs$value_input?(n.elements.push(new Ag(this.constants_,t)),n.hasExternalInput=!0):(t instanceof gm||t instanceof vm)&&(n.minHeight=Math.max(n.minHeight,this.constants_.DUMMY_INPUT_MIN_HEIGHT),n.hasDummyInput=!0),this.isInline||n.align!==null||(n.align=t.align)}addElemSpacing_(){let e=!1;for(let t=0,n;n=this.rows[t];t++)n.hasExternalInput&&(e=!0);for(let n=0,r;r=this.rows[n];n++){var t=r.elements;if(r.elements=[],r.startsWithElemSpacer()&&r.elements.push(new Rg(this.constants_,this.getInRowSpacing_(null,t[0]))),t.length){for(let e=0;e<t.length-1;e++){r.elements.push(t[e]);let n=this.getInRowSpacing_(t[e],t[e+1]);r.elements.push(new Rg(this.constants_,n))}r.elements.push(t[t.length-1]),r.endsWithElemSpacer()&&(t=this.getInRowSpacing_(t[t.length-1],null),e&&r.hasDummyInput&&(t+=this.constants_.TAB_WIDTH),r.elements.push(new Rg(this.constants_,t)))}}}getInRowSpacing_(e,t){if(!e)return t&&Z.isField(t)&&t.isEditable?this.constants_.MEDIUM_PADDING:t&&Z.isInlineInput(t)?this.constants_.MEDIUM_LARGE_PADDING:t&&Z.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!Z.isInput(e)&&(!t||Z.isStatementInput(t)))return Z.isField(e)&&e.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:Z.isIcon(e)?this.constants_.LARGE_PADDING*2+1:Z.isHat(e)?this.constants_.NO_PADDING:Z.isPreviousOrNextConnection(e)?this.constants_.LARGE_PADDING:Z.isLeftRoundedCorner(e)?this.constants_.MIN_BLOCK_WIDTH:Z.isJaggedEdge(e)?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING;if(Z.isInput(e)&&!t){if(Z.isExternalInput(e))return this.constants_.NO_PADDING;if(Z.isInlineInput(e))return this.constants_.LARGE_PADDING;if(Z.isStatementInput(e))return this.constants_.NO_PADDING}if(!Z.isInput(e)&&t&&Z.isInput(t)){if(Z.isField(e)&&e.isEditable){if(Z.isInlineInput(t)||Z.isExternalInput(t))return this.constants_.SMALL_PADDING}else{if(Z.isInlineInput(t)||Z.isExternalInput(t))return this.constants_.MEDIUM_LARGE_PADDING;if(Z.isStatementInput(t))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-1}if(Z.isIcon(e)&&t&&!Z.isInput(t))return this.constants_.LARGE_PADDING;if(Z.isInlineInput(e)&&t&&Z.isField(t))return t.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;if(Z.isLeftSquareCorner(e)&&t){if(Z.isHat(t))return this.constants_.NO_PADDING;if(Z.isPreviousConnection(t))return t.notchOffset;if(Z.isNextConnection(t))return t.notchOffset+(this.RTL?1:-1)*this.constants_.DARK_PATH_OFFSET/2}if(Z.isLeftRoundedCorner(e)&&t){if(Z.isPreviousConnection(t))return t.notchOffset-this.constants_.CORNER_RADIUS;if(Z.isNextConnection(t))return t.notchOffset-this.constants_.CORNER_RADIUS+(this.RTL?1:-1)*this.constants_.DARK_PATH_OFFSET/2}return Z.isField(e)&&t&&Z.isField(t)&&e.isEditable===t.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING:t&&Z.isJaggedEdge(t)?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getSpacerRowHeight_(e,t){return Z.isTopRow(e)&&Z.isBottomRow(t)?this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:Z.isTopRow(e)||Z.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(Z.isSpacer(t))return e.yPos+t.height/2;if(Z.isBottomRow(e))return e=e.yPos+e.height-e.descenderHeight,Z.isNextConnection(t)?e+t.height/2:e-t.height/2;if(Z.isTopRow(e))return Z.isHat(t)?e.capline-t.height/2:e.capline+t.height/2;let n=e.yPos;return Z.isField(t)||Z.isIcon(t)?(n+=t.height/2,(e.hasInlineInput||e.hasStatement)&&t.height+this.constants_.TALL_INPUT_FIELD_OFFSET_Y<=e.height&&(n+=this.constants_.TALL_INPUT_FIELD_OFFSET_Y)):n=Z.isInlineInput(t)?n+t.height/2:n+e.height/2,n}alignRowElements_(){if(this.isInline){var e=0,t=new WeakMap,n=null;for(let r=this.rows.length-1,i;i=this.rows[r];r--)t.set(i,e),Z.isInputRow(i)&&(i.hasStatement&&this.alignStatementRow_(i),n&&n.hasStatement&&i.width<n.width?t.set(i,n.width):e=i.hasStatement?i.width:Math.max(e,i.width),n=i);e=0;for(let r=0,i;i=this.rows[r];r++)i.hasStatement?e=this.getDesiredRowWidth_(i):Z.isSpacer(i)?i.width=Math.max(e,t.get(i)):(n=i.width,e=Math.max(e,t.get(i))-n,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 r=0,i;i=this.rows[r];r++){i.yPos=t,i.xPos=this.startX,t+=i.height,e=Math.max(e,i.widthWithConnectedBlocks);var n=t-this.topRow.ascenderHeight;i===this.bottomRow&&n<this.constants_.MIN_BLOCK_HEIGHT&&(n=this.constants_.MIN_BLOCK_HEIGHT-n,this.bottomRow.height+=n,t+=n),this.recordElemPositions_(i)}this.outputConnection&&this.block_.nextConnection&&this.block_.nextConnection.isConnected()&&(n=this.block_.nextConnection.targetBlock())&&(e=Math.max(e,n.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}},Ub={};Ub.RenderInfo=Hb;var Wb=class extends m_{constructor(e,t,n){super(e,t,n),this.constants=n,this.colourDark=`#000000`,this.svgPathDark=D(L.PATH,{class:`blocklyPathDark`,transform:`translate(1,1)`}),this.svgRoot.insertBefore(this.svgPathDark,this.svgPath),this.svgPathLight=D(L.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){this.svgPathLight.style.display=``,this.svgPathDark.style.display=``,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=xi(`#000`,this.style.colourPrimary,.2)||this.colourDark}updateHighlighted(e){super.updateHighlighted(e),this.svgPathLight.style.display=e?`none`:`inline`}updateShadow_(e){super.updateShadow_(e),e&&(this.svgPathLight.style.display=`none`,this.svgPathDark.setAttribute(`fill`,this.style.colourSecondary))}updateDisabled_(e){super.updateDisabled_(e),e&&this.svgPath.setAttribute(`stroke`,`none`)}},Gb={};Gb.PathObject=Wb;var Kb=class extends g_{constructor(e){super(e),this.highlightConstants=null}init(e,t){super.init(e,t),this.highlightConstants=this.makeHighlightConstants_(),this.highlightConstants.init()}refreshDom(e,t,n){super.refreshDom(e,t,n),this.getHighlightConstants().init()}makeConstants_(){return new Ab}makeRenderInfo_(e){return new Hb(this,e)}makeDrawer_(e,t){return new Pb(e,t)}makePathObject(e,t){return new Wb(e,t,this.getConstants())}makeHighlightConstants_(){return new Ib(this.getConstants())}getHighlightConstants(){if(!this.highlightConstants)throw Error(`Cannot access the highlight constants because init has not been called`);return this.highlightConstants}};Uo(`geras`,Kb);var qb={};qb.Renderer=Kb;var Jb={};Jb.ConstantProvider=Ab,Jb.Drawer=Pb,Jb.HighlightConstantProvider=Ib,Jb.Highlighter=Mb,Jb.InlineInput=Rb,Jb.PathObject=Wb,Jb.RenderInfo=Hb,Jb.Renderer=Kb,Jb.StatementInput=Bb;var Yb=class extends f_{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++){let r=this.rows[t];var n=r.elements;if(r.elements=[],r.startsWithElemSpacer()&&r.elements.push(new Rg(this.constants_,this.getInRowSpacing_(null,n[0]))),n.length){for(let e=0;e<n.length-1;e++){r.elements.push(n[e]);let t=this.getInRowSpacing_(n[e],n[e+1]);r.elements.push(new Rg(this.constants_,t))}r.elements.push(n[n.length-1]),r.endsWithElemSpacer()&&(n=this.getInRowSpacing_(n[n.length-1],null),e&&r.hasDummyInput&&(n+=this.constants_.TAB_WIDTH),r.elements.push(new Rg(this.constants_,n)))}}}getInRowSpacing_(e,t){if(!e)return t&&Z.isField(t)&&t.isEditable?this.constants_.MEDIUM_PADDING:t&&Z.isInlineInput(t)?this.constants_.MEDIUM_LARGE_PADDING:t&&Z.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!Z.isInput(e)&&!t)return Z.isField(e)&&e.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:Z.isIcon(e)?this.constants_.LARGE_PADDING*2+1:Z.isHat(e)?this.constants_.NO_PADDING:Z.isPreviousOrNextConnection(e)?this.constants_.LARGE_PADDING:Z.isLeftRoundedCorner(e)?this.constants_.MIN_BLOCK_WIDTH:Z.isJaggedEdge(e)?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING;if(Z.isInput(e)&&!t){if(Z.isExternalInput(e))return this.constants_.NO_PADDING;if(Z.isInlineInput(e))return this.constants_.LARGE_PADDING;if(Z.isStatementInput(e))return this.constants_.NO_PADDING}if(!Z.isInput(e)&&t&&Z.isInput(t)){if(Z.isField(e)&&e.isEditable){if(Z.isInlineInput(t)||Z.isExternalInput(t))return this.constants_.SMALL_PADDING}else{if(Z.isInlineInput(t)||Z.isExternalInput(t))return this.constants_.MEDIUM_LARGE_PADDING;if(Z.isStatementInput(t))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-1}if(Z.isIcon(e)&&t&&!Z.isInput(t))return this.constants_.LARGE_PADDING;if(Z.isInlineInput(e)&&t&&Z.isField(t))return t.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;if(Z.isLeftSquareCorner(e)&&t){if(Z.isHat(t))return this.constants_.NO_PADDING;if(Z.isPreviousConnection(t)||Z.isNextConnection(t))return t.notchOffset}return Z.isLeftRoundedCorner(e)&&t?t.notchOffset-this.constants_.CORNER_RADIUS:Z.isField(e)&&t&&Z.isField(t)&&e.isEditable===t.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING:t&&Z.isJaggedEdge(t)?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getSpacerRowHeight_(e,t){return Z.isTopRow(e)&&Z.isBottomRow(t)?this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:Z.isTopRow(e)||Z.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(Z.isSpacer(t))return e.yPos+t.height/2;if(Z.isBottomRow(e))return e=e.yPos+e.height-e.descenderHeight,Z.isNextConnection(t)?e+t.height/2:e-t.height/2;if(Z.isTopRow(e))return Z.isHat(t)?e.capline-t.height/2:e.capline+t.height/2;let n=e.yPos;return n=Z.isField(t)&&e.hasStatement?n+(this.constants_.TALL_INPUT_FIELD_OFFSET_Y+t.height/2):n+e.height/2}finalize_(){let e=0,t=0;for(var n=0;n<this.rows.length;n++){let i=this.rows[n];i.yPos=t,i.xPos=this.startX,t+=i.height,e=Math.max(e,i.widthWithConnectedBlocks);var r=t-this.topRow.ascenderHeight;i===this.bottomRow&&r<this.constants_.MIN_BLOCK_HEIGHT&&(r=this.constants_.MIN_BLOCK_HEIGHT-r,this.bottomRow.height+=r,t+=r),this.recordElemPositions_(i)}this.outputConnection&&this.block_.nextConnection&&this.block_.nextConnection.isConnected()&&(n=this.block_.nextConnection.targetBlock())&&(e=Math.max(e,n.getHeightWidth().width)),this.bottomRow.baseline=t-this.bottomRow.descenderHeight,this.widthWithChildren=e+this.startX,this.height=t,this.startY=this.topRow.capline}},Xb={};Xb.RenderInfo=Yb;var Zb=class extends g_{constructor(e){super(e)}makeRenderInfo_(e){return new Yb(this,e)}};Uo(`thrasos`,Zb);var Qb={};Qb.Renderer=Zb;var $b={};$b.RenderInfo=Yb,$b.Renderer=Zb;var ex={Classic:Cp,Zelos:new xp(`zelos`,{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`}},{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`}})},tx=class{constructor(e,t,n){this.id_=e.toolboxitemid||ne(),this.level_=(this.parent_=n||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(){let 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}},nx={};nx.ToolboxItem=tx;var rx=class extends tx{constructor(e,t,n){super(e,t,n),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++){let n=e[t];Array.isArray(this.flyoutItems_)&&this.flyoutItems_.push(n)}}parseCategoryDef_(e){this.name_=`name`in e?Ti(e.name):``,this.colour_=this.getColour_(e),Object.assign(this.cssConfig_,e.cssconfig||e.cssConfig)}createDom_(){this.htmlDiv_=this.createContainer_(),$t(this.htmlDiv_,Au.TREEITEM),en(this.htmlDiv_,ju.SELECTED,!1),en(this.htmlDiv_,ju.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_(),$t(this.iconDom_,Au.PRESENTATION),this.rowContents_.appendChild(this.iconDom_),this.labelDom_=this.createLabelDom_(this.name_),this.rowContents_.appendChild(this.labelDom_);let e=this.labelDom_.getAttribute(`id`);return e&&en(this.htmlDiv_,ju.LABELLEDBY,e),this.addColourBorder_(this.colour_),this.htmlDiv_}createContainer_(){let e=document.createElement(`div`);e.tabIndex=-1,e.id=this.getId();let t=this.cssConfig_.container;return t&&O(e,t),e}createRowContainer_(){let e=document.createElement(`div`);var t=this.cssConfig_.row;return t&&O(e,t),t=`${rx.nestedPadding*this.getLevel()}px`,this.workspace_.RTL?e.style.paddingRight=t:e.style.paddingLeft=t,e}createRowContentsContainer_(){let e=document.createElement(`div`),t=this.cssConfig_.rowcontentcontainer;return t&&O(e,t),e}createIconDom_(){let e=document.createElement(`span`);if(!this.parentToolbox_.isHorizontal()){let t=this.cssConfig_.icon;t&&O(e,t)}return e.style.display=`inline-block`,e}createLabelDom_(e){let t=document.createElement(`span`);return t.setAttribute(`id`,this.getId()+`.label`),t.textContent=e,(e=this.cssConfig_.label)&&O(t,e),t}refreshTheme(){this.colour_=this.getColour_(this.toolboxItemDef_),this.addColourBorder_(this.colour_)}addColourBorder_(e){e&&(e=rx.borderWidth+`px solid `+(e||`#ddd`),this.workspace_.RTL?this.rowDiv_.style.borderRight=e:this.rowDiv_.style.borderLeft=e)}getColour_(e){let 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=Ti(e),e==null||e===``)return``;var t=Number(e);return isNaN(t)?(t=_i(e))?t:(console.warn(`Toolbox category "`+this.name_+`" has unrecognized colour attribute: `+e),``):Si(t)}openIcon_(e){if(e){var t=this.cssConfig_.closedicon;t&&Fe(e,t),(t=this.cssConfig_.openicon)&&O(e,t)}}closeIcon_(e){if(e){var t=this.cssConfig_.openicon;t&&Fe(e,t),(t=this.cssConfig_.closedicon)&&O(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){let e=this.parseColour(rx.defaultBackgroundColour);this.rowDiv_.style.backgroundColor=this.colour_||e,t&&O(this.rowDiv_,t)}else this.rowDiv_.style.backgroundColor=``,t&&k(this.rowDiv_,t);en(this.htmlDiv_,ju.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:Pt(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(){A(this.htmlDiv_)}};rx.registrationName=`category`,rx.nestedPadding=19,rx.borderWidth=8,rx.defaultBackgroundColour=`#57e`,ft(`
|
|
674
|
+
.blocklyToolboxCategory:not(.blocklyToolboxSelected):hover {
|
|
675
|
+
background-color: rgba(255, 255, 255, .2);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
.blocklyToolbox[layout="h"] .blocklyToolboxCategoryContainer {
|
|
679
|
+
margin: 1px 5px 1px 0;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
.blocklyToolbox[dir="RTL"][layout="h"] .blocklyToolboxCategoryContainer {
|
|
683
|
+
margin: 1px 0 1px 5px;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
.blocklyToolboxCategory {
|
|
687
|
+
height: 22px;
|
|
688
|
+
line-height: 22px;
|
|
689
|
+
margin-bottom: 3px;
|
|
690
|
+
padding-right: 8px;
|
|
691
|
+
white-space: nowrap;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
.blocklyToolbox[dir="RTL"] .blocklyToolboxCategory {
|
|
695
|
+
margin-left: 8px;
|
|
696
|
+
padding-right: 0;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
.blocklyToolboxCategoryIcon {
|
|
700
|
+
background-image: url(<<<PATH>>>/sprites.png);
|
|
701
|
+
height: 16px;
|
|
702
|
+
vertical-align: middle;
|
|
703
|
+
visibility: hidden;
|
|
704
|
+
width: 16px;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
.blocklyToolboxCategoryIconClosed {
|
|
708
|
+
background-position: -32px -1px;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
.blocklyToolbox[dir="RTL"] .blocklyToolboxCategoryIconClosed {
|
|
712
|
+
background-position: 0 -1px;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
.blocklyToolboxSelected>.blocklyToolboxCategoryIconClosed {
|
|
716
|
+
background-position: -32px -17px;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
.blocklyToolbox[dir="RTL"] .blocklyToolboxSelected>.blocklyToolboxCategoryIconClosed {
|
|
720
|
+
background-position: 0 -17px;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
.blocklyToolboxCategoryIconOpen {
|
|
724
|
+
background-position: -16px -1px;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
.blocklyToolboxSelected>.blocklyToolboxCategoryIconOpen {
|
|
728
|
+
background-position: -16px -17px;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
.blocklyToolboxCategoryLabel {
|
|
732
|
+
cursor: default;
|
|
733
|
+
font: 16px sans-serif;
|
|
734
|
+
padding: 0 3px;
|
|
735
|
+
vertical-align: middle;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
.blocklyToolboxDelete .blocklyToolboxCategoryLabel {
|
|
739
|
+
cursor: url("<<<PATH>>>/handdelete.cur"), auto;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
.blocklyToolboxSelected .blocklyToolboxCategoryLabel {
|
|
743
|
+
color: #fff;
|
|
744
|
+
}
|
|
745
|
+
`),t(P.TOOLBOX_ITEM,rx.registrationName,rx);var ix={};ix.ToolboxCategory=rx;var ax=class extends tx{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_(){let e=document.createElement(`div`);e.tabIndex=-1,e.id=this.getId();let t=this.cssConfig_.container;return t&&O(e,t),this.htmlDiv=e}getDiv(){return this.htmlDiv}dispose(){A(this.htmlDiv)}};ax.registrationName=`sep`,ft(`
|
|
746
|
+
.blocklyTreeSeparator {
|
|
747
|
+
border-bottom: solid #e5e5e5 1px;
|
|
748
|
+
height: 0;
|
|
749
|
+
margin: 5px 0;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
.blocklyToolbox[layout="h"] .blocklyTreeSeparator {
|
|
753
|
+
border-right: solid #e5e5e5 1px;
|
|
754
|
+
border-bottom: none;
|
|
755
|
+
height: auto;
|
|
756
|
+
margin: 0 5px 0 5px;
|
|
757
|
+
padding: 5px 0;
|
|
758
|
+
width: 0;
|
|
759
|
+
}
|
|
760
|
+
`),t(P.TOOLBOX_ITEM,ax.registrationName,ax);var ox={};ox.ToolboxSeparator=ax;var sx=class extends rx{constructor(e,t,n){super(e,t,n),this.subcategoriesDiv_=null,this.expanded_=!1,this.toolboxItems_=[]}makeDefaultCssConfig_(){let e=super.makeDefaultCssConfig_();return e.contents=`blocklyToolboxCategoryGroup`,e}parseContents_(e){if(`custom`in e)this.flyoutItems_=e.custom;else{let t=e.contents;if(t){this.flyoutItems_=[],e=!0;for(let n=0;n<t.length;n++){let r=t[n];!a(P.TOOLBOX_ITEM,r.kind)||r.kind.toLowerCase()===ax.registrationName&&e?(this.flyoutItems_.push(r),e=!0):(this.createToolboxItem(r),e=!1)}}}}createToolboxItem(e){let t=e.kind;t.toUpperCase()===`CATEGORY`&&Lt(e)&&(t=sx.registrationName),e=new(o(P.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_();let e=this.getChildToolboxItems();return this.subcategoriesDiv_=this.createSubCategoriesDom_(e),$t(this.subcategoriesDiv_,Au.GROUP),this.htmlDiv_.appendChild(this.subcategoriesDiv_),this.closeIcon_(this.iconDom_),en(this.htmlDiv_,ju.EXPANDED,!1),this.htmlDiv_}createIconDom_(){let e=document.createElement(`span`);if(!this.parentToolbox_.isHorizontal()){let t=this.cssConfig_.icon;t&&O(e,t),e.style.visibility=`visible`}return e.style.display=`inline-block`,e}createSubCategoriesDom_(e){let t=document.createElement(`div`);t.style.display=`none`;var n=this.cssConfig_.contents;for(n&&O(t,n),n=0;n<e.length;n++){let r=e[n];r.init();let i=r.getDiv();if(t.appendChild(i),r.getClickTarget){let e;(e=r.getClickTarget())==null||e.setAttribute(`id`,r.getId())}}return t}setExpanded(e){if(this.expanded_!==e){if(this.expanded_=e)this.subcategoriesDiv_.style.display=`block`,this.openIcon_(this.iconDom_);else{let e;(e=this.parentToolbox_.getFlyout())==null||e.setVisible(!1),this.subcategoriesDiv_.style.display=`none`,this.closeIcon_(this.iconDom_)}en(this.htmlDiv_,ju.EXPANDED,e),this.parentToolbox_.handleToolboxItemResize()}}setVisible_(e){this.htmlDiv_.style.display=e?`block`:`none`;let t=this.getChildToolboxItems();for(let n=0;n<t.length;n++)t[n].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_}};sx.registrationName=`collapsibleCategory`,t(P.TOOLBOX_ITEM,sx.registrationName,sx);var cx={};cx.CollapsibleToolboxCategory=sx;var lx={};lx.isSelectableToolboxItem=ic;var ux=class extends Gm{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.mouseDown=!1,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 t=this.workspace_;let n=t.getParentSvg();this.flyout=this.createFlyout_(),this.HtmlDiv=this.createDom_(this.workspace_);let r=this.flyout.createDom(`svg`);O(r,`blocklyToolboxFlyout`),Le(r,n),this.setVisible(!0),this.flyout.init(t),this.render(this.toolboxDef_),t=t.getThemeManager(),t.subscribe(this.HtmlDiv,`toolboxBackgroundColour`,`background-color`),t.subscribe(this.HtmlDiv,`toolboxForegroundColour`,`color`),this.workspace_.getComponentManager().addComponent({component:this,weight:Pl.ComponentWeight.TOOLBOX_WEIGHT,capabilities:[Pl.Capability.AUTOHIDEABLE,Pl.Capability.DELETE_AREA,Pl.Capability.DRAG_TARGET]}),e.getFocusManager$$module$build$src$core$focus_manager().registerTree(this,!0)}createDom_(e){e=e.getParentSvg();let t=this.createContainer_();t.id=ne(),this.contentsDiv_=this.createContentsContainer_(),$t(this.contentsDiv_,Au.TREE),t.appendChild(this.contentsDiv_);let n;return(n=e.parentNode)==null||n.insertBefore(t,e),this.attachEvents_(t,this.contentsDiv_),t}createContainer_(){let e=document.createElement(`div`);return e.setAttribute(`layout`,this.isHorizontal()?`h`:`v`),O(e,`blocklyToolbox`),e.setAttribute(`dir`,this.RTL?`RTL`:`LTR`),e}createContentsContainer_(){let e=document.createElement(`div`);return O(e,`blocklyToolboxCategoryGroup`),this.isHorizontal()&&(e.style.flexDirection=`row`),e}attachEvents_(e,t){let n=g(e,`pointerdown`,this,this.onClick_,!1);this.boundEvents_.push(n),e=_(e,`pointerup`,this,()=>{this.mouseDown=!1}),this.boundEvents_.push(e),t=g(t,`keydown`,this,this.onKeyDown_,!1),this.boundEvents_.push(t)}onClick_(e){if(this.mouseDown=!0,b(e)||e.target===this.HtmlDiv)Qe().hideChaff(!1);else{var t=e.target.getAttribute(`id`);t&&(t=this.getToolboxItemById(t),t!=null&&t.isSelectable())&&(this.setSelectedItem(t),t.onClick(e)),Qe().hideChaff(!0)}f()}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_(){let e=this.workspace_,t=e.copyOptionsForFlyout();return t.toolboxPosition=e.options.toolboxPosition,new(e.horizontalLayout?l(P.FLYOUTS_HORIZONTAL_TOOLBOX,e.options,!0):l(P.FLYOUTS_VERTICAL_TOOLBOX,e.options,!0))(t)}render(e){this.toolboxDef_=e,this.contents.forEach(e=>e.dispose()),this.contents.clear(),this.renderContents_(e.contents),this.position(),this.handleToolboxItemResize()}renderContents_(e){let t=document.createDocumentFragment();for(let n=0;n<e.length;n++)this.createToolboxItem(e[n],t);let n;(n=this.contentsDiv_)==null||n.appendChild(t)}createToolboxItem(e,t){var n=e.kind;if(n.toUpperCase()===`CATEGORY`&&Lt(e)&&(n=sx.registrationName),n=o(P.TOOLBOX_ITEM,n.toLowerCase())){e=new n(e,this),e.init(),this.addToolboxItem_(e),(n=e.getDiv())&&t.appendChild(n);let r;(r=e.getClickTarget())==null||r.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&&O(this.HtmlDiv,e)}removeStyle(e){e&&this.HtmlDiv&&k(this.HtmlDiv,e)}getClientRect(){if(!this.HtmlDiv||!this.isVisible_)return null;var e=this.HtmlDiv.getBoundingClientRect();let t=e.top,n=t+e.height,r=e.left;return e=r+e.width,this.toolboxPosition===B.TOP?new R(-1e7,n,-1e7,1e7):this.toolboxPosition===B.BOTTOM?new R(t,1e7,-1e7,1e7):this.toolboxPosition===B.LEFT?new R(-1e7,1e7,-1e7,e):new R(-1e7,1e7,r,1e7)}wouldDelete(e){return e instanceof Bm?this.updateWouldDelete_(!e.getParent()&&e.isDeletable()):this.updateWouldDelete_(_o(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){let 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(){let e=this.workspace_.getMetrics(),t=this.HtmlDiv;if(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===B.TOP?t.style.top=`0`:t.style.bottom=`0`):(this.toolboxPosition===B.RIGHT?t.style.right=`0`:t.style.left=`0`,t.style.height=`100%`,this.width_=t.offsetWidth,this.height_=e.viewHeight);var n;(n=this.flyout)==null||n.position()}}handleToolboxItemResize(){if(this.HtmlDiv){var e=this.workspace_,t=this.HtmlDiv.getBoundingClientRect(),n=this.getFlyout(),r=this.toolboxPosition===B.LEFT?e.scrollX+t.width+(n!=null&&n.isVisible()?n.getWidth():0):e.scrollX;t=this.toolboxPosition===B.TOP?e.scrollY+t.height+(n!=null&&n.isVisible()?n.getHeight():0):e.scrollY,e.translate(r,t),at(e)}}clearSelection(){this.setSelectedItem(null)}refreshTheme(){this.contents.forEach(e=>{e.refreshTheme&&e.refreshTheme()})}refreshSelection(){if(this.selectedItem_&&this.selectedItem_.isSelectable()&&this.selectedItem_.getContents().length){let e;(e=this.flyout)==null||e.show(this.selectedItem_.getContents())}}setVisible(e){this.isVisible_!==e&&(this.HtmlDiv&&(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){let t=this.selectedItem_;!e&&!t||e&&!ic(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),en(this.contentsDiv_,ju.ACTIVEDESCENDANT,``)}selectItem_(e,t){this.selectedItem_=t,this.previouslySelectedItem_=e,t.setSelected(!0),en(this.contentsDiv_,ju.ACTIVEDESCENDANT,t.getId())}selectItemByPosition(e){(e=this.getToolboxItems()[e])&&this.setSelectedItem(e)}updateFlyout_(e,t){if(t&&(e!==t||t.isCollapsible())&&t.getContents().length){let e;(e=this.flyout)==null||e.show(t.getContents());let n;(n=this.flyout)==null||n.scrollToStart()}else{let e;(e=this.flyout)==null||e.hide()}}fireSelectEvent(e,t){let n=e&&e.getName(),r=t&&t.getName();e===t&&(r=null),e=new(E(F.TOOLBOX_ITEM_SELECT))(n,r,this.workspace_.id),w(e)}selectParent(){if(!this.selectedItem_)return!1;if(this.selectedItem_.isCollapsible()&&this.selectedItem_.isExpanded())return this.selectedItem_.toggleExpanded(),!0;let e;return(e=this.selectedItem_.getParent())!=null&&e.isSelectable()?(this.setSelectedItem(this.selectedItem_.getParent()),!0):!1}selectChild(){if(!this.selectedItem_||!this.selectedItem_.isCollapsible())return!1;let e=this.selectedItem_;return e.isExpanded()?this.selectNext():e.toggleExpanded(),!0}selectNext(){if(!this.selectedItem_)return!1;let e=[...this.contents.values()],t=e.indexOf(this.selectedItem_)+1;if(t>-1&&t<e.length){let n=e[t];for(;n&&!n.isSelectable();)n=e[++t];if(n&&n.isSelectable())return this.setSelectedItem(n),!0}return!1}selectPrevious(){if(!this.selectedItem_)return!1;let e=[...this.contents.values()],t=e.indexOf(this.selectedItem_)-1;if(t>-1&&t<e.length){let n=e[t];for(;n&&!n.isSelectable();)n=e[--t];if(n&&n.isSelectable())return this.setSelectedItem(n),!0}return!1}dispose(){this.workspace_.getComponentManager().removeComponent(`toolbox`);var t;for((t=this.flyout)==null||t.dispose(),this.contents.forEach(e=>e.dispose()),t=0;t<this.boundEvents_.length;t++)v(this.boundEvents_[t]);this.boundEvents_=[],this.contents.clear(),this.HtmlDiv&&(this.workspace_.getThemeManager().unsubscribe(this.HtmlDiv),A(this.HtmlDiv)),e.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){return!e||e===this?this.getToolboxItems().find(e=>e.isSelectable())??null:null}getNestedTrees(){return[]}lookUpFocusableNode(e){return this.getToolboxItemById(e)}onTreeFocus(e,t){e===this?this.clearSelection():this.getSelectedItem()===e||this.mouseDown||this.setSelectedItem(e)}onTreeBlur(e){e&&e===this.flyout?.getWorkspace()||this.autoHide(!1)}};ft(`
|
|
761
|
+
.blocklyToolboxDelete {
|
|
762
|
+
cursor: url("<<<PATH>>>/handdelete.cur"), auto;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
.blocklyToolboxGrab {
|
|
766
|
+
cursor: url("<<<PATH>>>/handclosed.cur"), auto;
|
|
767
|
+
cursor: grabbing;
|
|
768
|
+
cursor: -webkit-grabbing;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
/* Category tree in Toolbox. */
|
|
772
|
+
.blocklyToolbox {
|
|
773
|
+
box-sizing: border-box;
|
|
774
|
+
user-select: none;
|
|
775
|
+
-ms-user-select: none;
|
|
776
|
+
-webkit-user-select: none;
|
|
777
|
+
background-color: #ddd;
|
|
778
|
+
overflow-x: visible;
|
|
779
|
+
overflow-y: auto;
|
|
780
|
+
padding: 4px 0 4px 0;
|
|
781
|
+
position: absolute;
|
|
782
|
+
z-index: 70; /* so blocks go under toolbox when dragging */
|
|
783
|
+
-webkit-tap-highlight-color: transparent; /* issue #1345 */
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
.blocklyToolboxCategoryGroup {
|
|
787
|
+
display: flex;
|
|
788
|
+
flex-wrap: wrap;
|
|
789
|
+
flex-direction: column;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
.blocklyToolboxCategoryGroup:focus {
|
|
793
|
+
outline: none;
|
|
794
|
+
}
|
|
795
|
+
`),t(P.TOOLBOX,uc,ux);var dx={};dx.Toolbox=ux;var fx=`12.5.1`,px=Y.INPUT_VALUE,mx=Y.OUTPUT_VALUE,hx=Y.NEXT_STATEMENT,gx=Y.PREVIOUS_STATEMENT,_x=B.TOP,vx=B.BOTTOM,yx=B.LEFT,bx=B.RIGHT;T_.prototype.newBlock=function(e,t){return new Tm(this,e,t)},j_.prototype.newBlock=function(e,t){return new Bm(this,e,t)},T_.prototype.newComment=function(e){return new ap(this,e)},j_.prototype.newComment=function(e){return new sp(this,e)},j_.newTrashcan=function(e){return new q_(e)},jp.prototype.newWorkspaceSvg=function(e){return new j_(e)},e.Names$$module$build$src$core$names.prototype.populateProcedures=function(t){t=Oo(t),t=t[0].concat(t[1]);for(let n=0;n<t.length;n++)this.getName(t[n][0],e.Names$$module$build$src$core$names.NameType.PROCEDURE)};var $={};$.Block=Tm,$.BlockFlyoutInflater=Eb,$.BlockNavigationPolicy=dh,$.BlockSvg=Bm,$.Blocks=fc,$.ButtonFlyoutInflater=xb,$.COLLAPSED_FIELD_NAME=Bu,$.COLLAPSED_INPUT_NAME=zu,$.COLLAPSE_CHARS=om,$.CodeGenerator=e.CodeGenerator$$module$build$src$core$generator,$.CollapsibleToolboxCategory=sx,$.ComponentManager=Pl,$.Connection=X,$.ConnectionChecker=C_,$.ConnectionDB=Jp,$.ConnectionNavigationPolicy=_h,$.ConnectionType=Y,$.ContextMenu=If,$.ContextMenuItems=yb,$.ContextMenuRegistry=J,$.Css=zl,$.DELETE_VARIABLE_ID=lm,$.DeleteArea=Gm,$.DragTarget=Hm,$.DropDownDiv=Zd,$.Events=Q,$.Extensions=Bp,$.Field=xf,$.FieldCheckbox=fy,$.FieldDropdown=yp,$.FieldImage=Av,$.FieldLabel=im,$.FieldLabelSerializable=uy,$.FieldNavigationPolicy=yh,$.FieldNumber=cy,$.FieldTextInput=e.FieldTextInput$$module$build$src$core$field_textinput,$.FieldVariable=oy,$.Flyout=Hh,$.FlyoutButton=$m,$.FlyoutButtonNavigationPolicy=th,$.FlyoutItem=qm,$.FlyoutMetricsManager=Zm,$.FlyoutNavigationPolicy=rh,$.FlyoutNavigator=Fh,$.FlyoutSeparator=ah,$.FlyoutSeparatorNavigationPolicy=sh,$.FocusManager=fl,$.FocusableTreeTraverser=ll,$.Generator=e.CodeGenerator$$module$build$src$core$generator,$.Gesture=$h,$.Grid=tg,$.HorizontalFlyout=iy,$.INPUT_VALUE=px,$.Input=mm,$.InsertionMarkerPreviewer=Xv,$.KeyboardNavigationController=Kh,$.LabelFlyoutInflater=wv,$.LineCursor=cg,$.Marker=og,$.MarkerManager=ug,$.Menu=Fu,$.MenuItem=Nu,$.MetricsManager=Ym,$.Msg=e.Msg$$module$build$src$core$msg,$.NEXT_STATEMENT=hx,$.Names=e.Names$$module$build$src$core$names,$.Navigator=Nh,$.OPPOSITE_TYPE=sm,$.OUTPUT_VALUE=mx,$.Options=wp,$.PREVIOUS_STATEMENT=gx,$.PROCEDURE_CATEGORY_NAME=vg,$.Procedures=yg,$.RENAME_VARIABLE_ID=cm,$.RenderedConnection=dm,$.Scrollbar=Yl,$.ScrollbarPair=Lh,$.SeparatorFlyoutInflater=Bh,$.ShortcutItems=gv,$.ShortcutRegistry=_l,$.TOOLBOX_AT_BOTTOM=vx,$.TOOLBOX_AT_LEFT=yx,$.TOOLBOX_AT_RIGHT=bx,$.TOOLBOX_AT_TOP=_x,$.Theme=xp,$.ThemeManager=y_,$.Themes=ex,$.Toast=td,$.Toolbox=ux,$.ToolboxCategory=rx,$.ToolboxItem=tx,$.ToolboxSeparator=ax,$.Tooltip=hf,$.Touch=vc,$.Trashcan=q_,$.UnattachedFieldError=Sf,$.VARIABLE_CATEGORY_NAME=gd,$.VARIABLE_DYNAMIC_CATEGORY_NAME=x_,$.VERSION=fx,$.VariableMap=U_,$.VariableModel=L_,$.Variables=yd,$.VariablesDynamic=S_,$.VerticalFlyout=ny,$.WidgetDiv=Mf,$.Workspace=T_,$.WorkspaceAudio=O_,$.WorkspaceDragger=Yh,$.WorkspaceNavigationPolicy=jh,$.WorkspaceSvg=j_,$.Xml=lp,$.ZoomControls=mu,$.blockAnimations=km,$.blockRendering=v_,$.browserEvents=Bc,$.bubbles=Cb,$.bumpObjects=Mm,$.clipboard=fv,$.comments=pv,$.common=wl,$.config=e.config$$module$build$src$core$config,$.constants=Hu,$.defineBlocksWithJsonArray=ct,$.dialog=dd,$.dragging=gy,$.fieldRegistry=vp,$.geras=Jb,$.getFocusManager=e.getFocusManager$$module$build$src$core$focus_manager,$.getMainWorkspace=Qe,$.getSelected=et,$.hasBubble=mr,$.hideChaff=ac,$.icons=fg,$.inject=Ts,$.inputs=Qv,$.isCopyable=ls,$.isDeletable=_o,$.isDraggable=wo,$.isIcon=to,$.isObservable=Do,$.isPaster=nc,$.isRenderedElement=rc,$.isSelectable=Ke,$.isSerializable=tn,$.isVariableBackedParameterModel=Sn,$.keyboardNavigationController=qh,$.layers=Vf,$.navigateBlock=bo,$.navigateStacks=yo,$.procedures=yg,$.registry=dc,$.renderManagement=H,$.serialization=Sv,$.setLocale=Xu,$.setParentContainer=it,$.svgResize=at,$.thrasos=$b,$.uiPosition=fu,$.utils=Wp,$.zelos=vb;var xx={};return xx.isFocusableTree=oc,$.__namespace__=e,$})}));const{Block:ee,BlockFlyoutInflater:te,BlockNavigationPolicy:ne,BlockSvg:re,Blocks:ie,ButtonFlyoutInflater:ae,COLLAPSED_FIELD_NAME:x,COLLAPSED_INPUT_NAME:oe,COLLAPSE_CHARS:se,CodeGenerator:S,CollapsibleToolboxCategory:ce,ComponentManager:le,Connection:ue,ConnectionChecker:C,ConnectionDB:de,ConnectionNavigationPolicy:fe,ConnectionType:pe,ContextMenu:me,ContextMenuItems:he,ContextMenuRegistry:ge,Css:_e,DELETE_VARIABLE_ID:ve,DeleteArea:ye,DragTarget:be,DropDownDiv:xe,Events:Se,Extensions:Ce,Field:we,FieldCheckbox:Te,FieldDropdown:w,FieldImage:Ee,FieldLabel:De,FieldLabelSerializable:Oe,FieldNavigationPolicy:ke,FieldNumber:Ae,FieldTextInput:je,FieldVariable:Me,Flyout:Ne,FlyoutButton:T,FlyoutButtonNavigationPolicy:E,FlyoutItem:Pe,FlyoutMetricsManager:D,FlyoutNavigationPolicy:O,FlyoutNavigator:Fe,FlyoutSeparator:k,FlyoutSeparatorNavigationPolicy:Ie,FocusManager:A,FocusableTreeTraverser:Le,Generator:Re,Gesture:ze,Grid:Be,HorizontalFlyout:Ve,INPUT_VALUE:He,Input:Ue,InsertionMarkerPreviewer:We,KeyboardNavigationController:Ge,LabelFlyoutInflater:Ke,LineCursor:qe,Marker:Je,MarkerManager:Ye,Menu:Xe,MenuItem:Ze,MetricsManager:Qe,Msg:$e,NEXT_STATEMENT:et,Names:tt,Navigator:nt,OPPOSITE_TYPE:rt,OUTPUT_VALUE:it,Options:at,PREVIOUS_STATEMENT:ot,PROCEDURE_CATEGORY_NAME:st,Procedures:ct,RENAME_VARIABLE_ID:lt,RenderedConnection:ut,Scrollbar:dt,ScrollbarPair:ft,SeparatorFlyoutInflater:pt,ShortcutItems:mt,ShortcutRegistry:ht,TOOLBOX_AT_BOTTOM:gt,TOOLBOX_AT_LEFT:_t,TOOLBOX_AT_RIGHT:vt,TOOLBOX_AT_TOP:yt,Theme:bt,ThemeManager:xt,Themes:St,Toast:Ct,Toolbox:wt,ToolboxCategory:Tt,ToolboxItem:Et,ToolboxSeparator:Dt,Tooltip:Ot,Touch:kt,Trashcan:At,UnattachedFieldError:jt,VARIABLE_CATEGORY_NAME:Mt,VARIABLE_DYNAMIC_CATEGORY_NAME:Nt,VERSION:Pt,VariableMap:Ft,VariableModel:It,Variables:Lt,VariablesDynamic:Rt,VerticalFlyout:zt,WidgetDiv:Bt,Workspace:Vt,WorkspaceAudio:Ht,WorkspaceDragger:Ut,WorkspaceNavigationPolicy:Wt,WorkspaceSvg:Gt,Xml:Kt,ZoomControls:qt,blockAnimations:Jt,blockRendering:Yt,browserEvents:Xt,bubbles:Zt,bumpObjects:Qt,clipboard:$t,comments:en,common:tn,config:nn,constants:rn,defineBlocksWithJsonArray:an,dialog:on,dragging:sn,fieldRegistry:cn,geras:ln,getFocusManager:un,getMainWorkspace:dn,getSelected:fn,hasBubble:pn,hideChaff:mn,icons:hn,inject:gn,inputs:_n,isCopyable:vn,isDeletable:yn,isDraggable:bn,isIcon:xn,isObservable:Sn,isPaster:Cn,isRenderedElement:wn,isSelectable:Tn,isSerializable:En,isVariableBackedParameterModel:Dn,keyboardNavigationController:On,layers:kn,navigateBlock:An,navigateStacks:jn,procedures:Mn,registry:Nn,renderManagement:Pn,serialization:Fn,setLocale:In,setParentContainer:Ln,svgResize:Rn,thrasos:zn,uiPosition:Bn,utils:Vn,zelos:Hn}=e(b(),1).default;var Un=n(((e,t)=>{(function(n,r){typeof define==`function`&&define.amd?define([`./blockly_compressed.js`],r):typeof e==`object`?t.exports=r(b()):(n.javascript=r(n.Blockly),n.Blockly.JavaScript=n.javascript.javascriptGenerator)})(e,function(e){var t=e.__namespace__,n=function(e,t){return[`[]`,T.ATOMIC]},r=function(e,t){let n=Array(e.itemCount_);for(let r=0;r<e.itemCount_;r++)n[r]=t.valueToCode(e,`ADD`+r,T.NONE)||`null`;return[`[`+n.join(`, `)+`]`,T.ATOMIC]},i=function(e,t){let n=t.provideFunction_(`listsRepeat`,`
|
|
796
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(value, n) {
|
|
797
|
+
var array = [];
|
|
798
|
+
for (var i = 0; i < n; i++) {
|
|
799
|
+
array[i] = value;
|
|
800
|
+
}
|
|
801
|
+
return array;
|
|
802
|
+
}
|
|
803
|
+
`),r=t.valueToCode(e,`ITEM`,T.NONE)||`null`;return e=t.valueToCode(e,`NUM`,T.NONE)||`0`,[n+`(`+r+`, `+e+`)`,T.FUNCTION_CALL]},a=function(e,t){return[(t.valueToCode(e,`VALUE`,T.MEMBER)||`[]`)+`.length`,T.MEMBER]},o=function(e,t){return[`!`+(t.valueToCode(e,`VALUE`,T.MEMBER)||`[]`)+`.length`,T.LOGICAL_NOT]},s=function(e,t){let n=e.getFieldValue(`END`)===`FIRST`?`indexOf`:`lastIndexOf`,r=t.valueToCode(e,`FIND`,T.NONE)||`''`;return t=(t.valueToCode(e,`VALUE`,T.MEMBER)||`[]`)+`.`+n+`(`+r+`)`,e.workspace.options.oneBasedIndex?[t+` + 1`,T.ADDITION]:[t,T.FUNCTION_CALL]},c=function(e,t){let n=e.getFieldValue(`MODE`)||`GET`,r=e.getFieldValue(`WHERE`)||`FROM_START`;var i=t.valueToCode(e,`VALUE`,r===`RANDOM`?T.NONE:T.MEMBER)||`[]`;switch(r){case`FIRST`:if(n===`GET`)return[i+`[0]`,T.MEMBER];if(n===`GET_REMOVE`)return[i+`.shift()`,T.MEMBER];if(n===`REMOVE`)return i+`.shift();
|
|
804
|
+
`;break;case`LAST`:if(n===`GET`)return[i+`.slice(-1)[0]`,T.MEMBER];if(n===`GET_REMOVE`)return[i+`.pop()`,T.MEMBER];if(n===`REMOVE`)return i+`.pop();
|
|
805
|
+
`;break;case`FROM_START`:if(e=t.getAdjusted(e,`AT`),n===`GET`)return[i+`[`+e+`]`,T.MEMBER];if(n===`GET_REMOVE`)return[i+`.splice(`+e+`, 1)[0]`,T.FUNCTION_CALL];if(n===`REMOVE`)return i+`.splice(`+e+`, 1);
|
|
806
|
+
`;break;case`FROM_END`:if(e=t.getAdjusted(e,`AT`,1,!0),n===`GET`)return[i+`.slice(`+e+`)[0]`,T.FUNCTION_CALL];if(n===`GET_REMOVE`)return[i+`.splice(`+e+`, 1)[0]`,T.FUNCTION_CALL];if(n===`REMOVE`)return i+`.splice(`+e+`, 1);`;break;case`RANDOM`:if(i=t.provideFunction_(`listsGetRandomItem`,`
|
|
807
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(list, remove) {
|
|
808
|
+
var x = Math.floor(Math.random() * list.length);
|
|
809
|
+
if (remove) {
|
|
810
|
+
return list.splice(x, 1)[0];
|
|
811
|
+
} else {
|
|
812
|
+
return list[x];
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
`)+`(`+i+`, `+(n!==`GET`)+`)`,n===`GET`||n===`GET_REMOVE`)return[i,T.FUNCTION_CALL];if(n===`REMOVE`)return i+`;
|
|
816
|
+
`}throw Error(`Unhandled combination (lists_getIndex).`)},l=function(e,n){function r(){if(i.match(/^\w+$/))return``;let e=n.nameDB_.getDistinctName(`tmpList`,t.NameType$$module$build$src$core$names.VARIABLE),r=`var `+e+` = `+i+`;
|
|
817
|
+
`;return i=e,r}let i=n.valueToCode(e,`LIST`,T.MEMBER)||`[]`,a=e.getFieldValue(`MODE`)||`GET`;var o=e.getFieldValue(`WHERE`)||`FROM_START`;let s=n.valueToCode(e,`TO`,T.ASSIGNMENT)||`null`;switch(o){case`FIRST`:if(a===`SET`)return i+`[0] = `+s+`;
|
|
818
|
+
`;if(a===`INSERT`)return i+`.unshift(`+s+`);
|
|
819
|
+
`;break;case`LAST`:if(a===`SET`)return r()+(i+`[`+i+`.length - 1] = `+s+`;
|
|
820
|
+
`);if(a===`INSERT`)return i+`.push(`+s+`);
|
|
821
|
+
`;break;case`FROM_START`:if(e=n.getAdjusted(e,`AT`),a===`SET`)return i+`[`+e+`] = `+s+`;
|
|
822
|
+
`;if(a===`INSERT`)return i+`.splice(`+e+`, 0, `+s+`);
|
|
823
|
+
`;break;case`FROM_END`:if(e=n.getAdjusted(e,`AT`,1,!1,T.SUBTRACTION),o=r(),a===`SET`)return o+(i+`[`+i+`.length - `+e+`] = `+s+`;
|
|
824
|
+
`);if(a===`INSERT`)return o+(i+`.splice(`+i+`.length - `+e+`, 0, `+s+`);
|
|
825
|
+
`);break;case`RANDOM`:if(e=r(),o=n.nameDB_.getDistinctName(`tmpX`,t.NameType$$module$build$src$core$names.VARIABLE),e+=`var `+o+` = Math.floor(Math.random() * `+i+`.length);
|
|
826
|
+
`,a===`SET`)return e+(i+`[`+o+`] = `+s+`;
|
|
827
|
+
`);if(a===`INSERT`)return e+(i+`.splice(`+o+`, 0, `+s+`);
|
|
828
|
+
`)}throw Error(`Unhandled combination (lists_setIndex).`)},u=function(e,t){var n={FIRST:`First`,LAST:`Last`,FROM_START:`FromStart`,FROM_END:`FromEnd`},r=t.valueToCode(e,`LIST`,T.MEMBER)||`[]`;let i=e.getFieldValue(`WHERE1`),a=e.getFieldValue(`WHERE2`);if(i===`FIRST`&&a===`LAST`)r+=`.slice(0)`;else if(r.match(/^\w+$/)||i!==`FROM_END`&&a===`FROM_START`){switch(i){case`FROM_START`:n=t.getAdjusted(e,`AT1`);break;case`FROM_END`:n=t.getAdjusted(e,`AT1`,1,!1,T.SUBTRACTION),n=r+`.length - `+n;break;case`FIRST`:n=`0`;break;default:throw Error(`Unhandled option (lists_getSublist).`)}switch(a){case`FROM_START`:t=t.getAdjusted(e,`AT2`,1);break;case`FROM_END`:t=t.getAdjusted(e,`AT2`,0,!1,T.SUBTRACTION),t=r+`.length - `+t;break;case`LAST`:t=r+`.length`;break;default:throw Error(`Unhandled option (lists_getSublist).`)}r=r+`.slice(`+n+`, `+t+`)`}else{let o=t.getAdjusted(e,`AT1`);e=t.getAdjusted(e,`AT2`),r=t.provideFunction_(`subsequence`+n[i]+n[a],`
|
|
829
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(sequence${i===`FROM_END`||i===`FROM_START`?`, at1`:``}${a===`FROM_END`||a===`FROM_START`?`, at2`:``}) {
|
|
830
|
+
var start = ${D(`sequence`,i,`at1`)};
|
|
831
|
+
var end = ${D(`sequence`,a,`at2`)} + 1;
|
|
832
|
+
return sequence.slice(start, end);
|
|
833
|
+
}
|
|
834
|
+
`)+`(`+r+(i===`FROM_END`||i===`FROM_START`?`, `+o:``)+(a===`FROM_END`||a===`FROM_START`?`, `+e:``)+`)`}return[r,T.FUNCTION_CALL]},d=function(e,t){let n=t.valueToCode(e,`LIST`,T.FUNCTION_CALL)||`[]`,r=e.getFieldValue(`DIRECTION`)===`1`?1:-1;return e=e.getFieldValue(`TYPE`),t=t.provideFunction_(`listsGetSortCompare`,`
|
|
835
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(type, direction) {
|
|
836
|
+
var compareFuncs = {
|
|
837
|
+
'NUMERIC': function(a, b) {
|
|
838
|
+
return Number(a) - Number(b); },
|
|
839
|
+
'TEXT': function(a, b) {
|
|
840
|
+
return String(a) > String(b) ? 1 : -1; },
|
|
841
|
+
'IGNORE_CASE': function(a, b) {
|
|
842
|
+
return String(a).toLowerCase() > String(b).toLowerCase() ? 1 : -1; },
|
|
843
|
+
};
|
|
844
|
+
var compare = compareFuncs[type];
|
|
845
|
+
return function(a, b) { return compare(a, b) * direction; };
|
|
846
|
+
}
|
|
847
|
+
`),[n+`.slice().sort(`+t+`("`+e+`", `+r+`))`,T.FUNCTION_CALL]},f=function(e,t){let n=t.valueToCode(e,`INPUT`,T.MEMBER);if(t=t.valueToCode(e,`DELIM`,T.NONE)||`''`,e=e.getFieldValue(`MODE`),e===`SPLIT`)n||(n=`''`),e=`split`;else if(e===`JOIN`)n||(n=`[]`),e=`join`;else throw Error(`Unknown mode: `+e);return[n+`.`+e+`(`+t+`)`,T.FUNCTION_CALL]},p=function(e,t){return[(t.valueToCode(e,`LIST`,T.FUNCTION_CALL)||`[]`)+`.slice().reverse()`,T.FUNCTION_CALL]},m=function(e,t){var n=0;let r=``;t.STATEMENT_PREFIX&&(r+=t.injectId(t.STATEMENT_PREFIX,e));do{let i=t.valueToCode(e,`IF`+n,T.NONE)||`false`,a=t.statementToCode(e,`DO`+n);t.STATEMENT_SUFFIX&&(a=t.prefixLines(t.injectId(t.STATEMENT_SUFFIX,e),t.INDENT)+a),r+=(n>0?` else `:``)+`if (`+i+`) {
|
|
848
|
+
`+a+`}`,n++}while(e.getInput(`IF`+n));return(e.getInput(`ELSE`)||t.STATEMENT_SUFFIX)&&(n=e.getInput(`ELSE`)?t.statementToCode(e,`ELSE`):``,t.STATEMENT_SUFFIX&&(n=t.prefixLines(t.injectId(t.STATEMENT_SUFFIX,e),t.INDENT)+n),r+=` else {
|
|
849
|
+
`+n+`}`),r+`
|
|
850
|
+
`},h=function(e,t){let n={EQ:`==`,NEQ:`!=`,LT:`<`,LTE:`<=`,GT:`>`,GTE:`>=`}[e.getFieldValue(`OP`)],r=n===`==`||n===`!=`?T.EQUALITY:T.RELATIONAL,i=t.valueToCode(e,`A`,r)||`0`;return e=t.valueToCode(e,`B`,r)||`0`,[i+` `+n+` `+e,r]},g=function(e,t){let n=e.getFieldValue(`OP`)===`AND`?`&&`:`||`,r=n===`&&`?T.LOGICAL_AND:T.LOGICAL_OR,i=t.valueToCode(e,`A`,r);return e=t.valueToCode(e,`B`,r),i||e?(t=n===`&&`?`true`:`false`,i||(i=t),e||(e=t)):e=i=`false`,[i+` `+n+` `+e,r]},_=function(e,t){let n=T.LOGICAL_NOT;return[`!`+(t.valueToCode(e,`BOOL`,n)||`true`),n]},v=function(e,t){return[e.getFieldValue(`BOOL`)===`TRUE`?`true`:`false`,T.ATOMIC]},y=function(e,t){return[`null`,T.ATOMIC]},b=function(e,t){let n=t.valueToCode(e,`IF`,T.CONDITIONAL)||`false`,r=t.valueToCode(e,`THEN`,T.CONDITIONAL)||`null`;return e=t.valueToCode(e,`ELSE`,T.CONDITIONAL)||`null`,[n+` ? `+r+` : `+e,T.CONDITIONAL]},ee=function(e,n){let r;r=e.getField(`TIMES`)?String(Number(e.getFieldValue(`TIMES`))):n.valueToCode(e,`TIMES`,T.ASSIGNMENT)||`0`;let i=n.statementToCode(e,`DO`);i=n.addLoopTrap(i,e),e=``;let a=n.nameDB_.getDistinctName(`count`,t.NameType$$module$build$src$core$names.VARIABLE),o=r;return r.match(/^\w+$/)||t.isNumber$$module$build$src$core$utils$string(r)||(o=n.nameDB_.getDistinctName(`repeat_end`,t.NameType$$module$build$src$core$names.VARIABLE),e+=`var `+o+` = `+r+`;
|
|
851
|
+
`),e+(`for (var `+a+` = 0; `+a+` < `+o+`; `+a+`++) {
|
|
852
|
+
`+i+`}
|
|
853
|
+
`)},te=function(e,t){let n=e.getFieldValue(`MODE`)===`UNTIL`,r=t.valueToCode(e,`BOOL`,n?T.LOGICAL_NOT:T.NONE)||`false`,i=t.statementToCode(e,`DO`);return i=t.addLoopTrap(i,e),n&&(r=`!`+r),`while (`+r+`) {
|
|
854
|
+
`+i+`}
|
|
855
|
+
`},ne=function(e,n){var r=n.getVariableName(e.getFieldValue(`VAR`)),i=n.valueToCode(e,`FROM`,T.ASSIGNMENT)||`0`,a=n.valueToCode(e,`TO`,T.ASSIGNMENT)||`0`;let o=n.valueToCode(e,`BY`,T.ASSIGNMENT)||`1`,s=n.statementToCode(e,`DO`);if(s=n.addLoopTrap(s,e),t.isNumber$$module$build$src$core$utils$string(i)&&t.isNumber$$module$build$src$core$utils$string(a)&&t.isNumber$$module$build$src$core$utils$string(o))n=Number(i)<=Number(a),e=`for (`+r+` = `+i+`; `+r+(n?` <= `:` >= `)+a+`; `+r,r=Math.abs(Number(o)),e=r===1?e+(n?`++`:`--`):e+((n?` += `:` -= `)+r),e+=`) {
|
|
856
|
+
`+s+`}
|
|
857
|
+
`;else{e=``;let c=i;i.match(/^\w+$/)||t.isNumber$$module$build$src$core$utils$string(i)||(c=n.nameDB_.getDistinctName(r+`_start`,t.NameType$$module$build$src$core$names.VARIABLE),e+=`var `+c+` = `+i+`;
|
|
858
|
+
`),i=a,a.match(/^\w+$/)||t.isNumber$$module$build$src$core$utils$string(a)||(i=n.nameDB_.getDistinctName(r+`_end`,t.NameType$$module$build$src$core$names.VARIABLE),e+=`var `+i+` = `+a+`;
|
|
859
|
+
`),a=n.nameDB_.getDistinctName(r+`_inc`,t.NameType$$module$build$src$core$names.VARIABLE),e+=`var `+a+` = `,e=t.isNumber$$module$build$src$core$utils$string(o)?e+(Math.abs(Number(o))+`;
|
|
860
|
+
`):e+(`Math.abs(`+o+`);
|
|
861
|
+
`),e+=`if (`+c+` > `+i+`) {
|
|
862
|
+
`,e+=n.INDENT+a+` = -`+a+`;
|
|
863
|
+
`,e=e+`}
|
|
864
|
+
for (`+(r+` = `+c+`; `+a+` >= 0 ? `+r+` <= `+i+` : `+r+` >= `+i+`; `+r+` += `+a+`) {
|
|
865
|
+
`+s+`}
|
|
866
|
+
`)}return e},re=function(e,n){let r=n.getVariableName(e.getFieldValue(`VAR`));var i=n.valueToCode(e,`LIST`,T.ASSIGNMENT)||`[]`;let a=n.statementToCode(e,`DO`);a=n.addLoopTrap(a,e),e=``;let o=i;return i.match(/^\w+$/)||(o=n.nameDB_.getDistinctName(r+`_list`,t.NameType$$module$build$src$core$names.VARIABLE),e+=`var `+o+` = `+i+`;
|
|
867
|
+
`),i=n.nameDB_.getDistinctName(r+`_index`,t.NameType$$module$build$src$core$names.VARIABLE),a=n.INDENT+r+` = `+o+`[`+i+`];
|
|
868
|
+
`+a,e+(`for (var `+i+` in `+o+`) {
|
|
869
|
+
`+a+`}
|
|
870
|
+
`)},ie=function(e,t){let n=``;if(t.STATEMENT_PREFIX&&(n+=t.injectId(t.STATEMENT_PREFIX,e)),t.STATEMENT_SUFFIX&&(n+=t.injectId(t.STATEMENT_SUFFIX,e)),t.STATEMENT_PREFIX){let r=e.getSurroundLoop();r&&!r.suppressPrefixSuffix&&(n+=t.injectId(t.STATEMENT_PREFIX,r))}switch(e.getFieldValue(`FLOW`)){case`BREAK`:return n+`break;
|
|
871
|
+
`;case`CONTINUE`:return n+`continue;
|
|
872
|
+
`}throw Error(`Unknown flow statement.`)},ae=function(e,t){return e=Number(e.getFieldValue(`NUM`)),[String(e),e>=0?T.ATOMIC:T.UNARY_NEGATION]},x=function(e,t){var n={ADD:[` + `,T.ADDITION],MINUS:[` - `,T.SUBTRACTION],MULTIPLY:[` * `,T.MULTIPLICATION],DIVIDE:[` / `,T.DIVISION],POWER:[null,T.NONE]}[e.getFieldValue(`OP`)];let r=n[0];n=n[1];let i=t.valueToCode(e,`A`,n)||`0`;return e=t.valueToCode(e,`B`,n)||`0`,r?[i+r+e,n]:[`Math.pow(`+i+`, `+e+`)`,T.FUNCTION_CALL]},oe=function(e,t){let n=e.getFieldValue(`OP`),r;if(n===`NEG`)return e=t.valueToCode(e,`NUM`,T.UNARY_NEGATION)||`0`,e[0]===`-`&&(e=` `+e),[`-`+e,T.UNARY_NEGATION];switch(e=n===`SIN`||n===`COS`||n===`TAN`?t.valueToCode(e,`NUM`,T.DIVISION)||`0`:t.valueToCode(e,`NUM`,T.NONE)||`0`,n){case`ABS`:r=`Math.abs(`+e+`)`;break;case`ROOT`:r=`Math.sqrt(`+e+`)`;break;case`LN`:r=`Math.log(`+e+`)`;break;case`EXP`:r=`Math.exp(`+e+`)`;break;case`POW10`:r=`Math.pow(10,`+e+`)`;break;case`ROUND`:r=`Math.round(`+e+`)`;break;case`ROUNDUP`:r=`Math.ceil(`+e+`)`;break;case`ROUNDDOWN`:r=`Math.floor(`+e+`)`;break;case`SIN`:r=`Math.sin(`+e+` / 180 * Math.PI)`;break;case`COS`:r=`Math.cos(`+e+` / 180 * Math.PI)`;break;case`TAN`:r=`Math.tan(`+e+` / 180 * Math.PI)`}if(r)return[r,T.FUNCTION_CALL];switch(n){case`LOG10`:r=`Math.log(`+e+`) / Math.log(10)`;break;case`ASIN`:r=`Math.asin(`+e+`) / Math.PI * 180`;break;case`ACOS`:r=`Math.acos(`+e+`) / Math.PI * 180`;break;case`ATAN`:r=`Math.atan(`+e+`) / Math.PI * 180`;break;default:throw Error(`Unknown math operator: `+n)}return[r,T.DIVISION]},se=function(e,t){return{PI:[`Math.PI`,T.MEMBER],E:[`Math.E`,T.MEMBER],GOLDEN_RATIO:[`(1 + Math.sqrt(5)) / 2`,T.DIVISION],SQRT2:[`Math.SQRT2`,T.MEMBER],SQRT1_2:[`Math.SQRT1_2`,T.MEMBER],INFINITY:[`Infinity`,T.ATOMIC]}[e.getFieldValue(`CONSTANT`)]},S=function(e,t){var n={EVEN:[` % 2 === 0`,T.MODULUS,T.EQUALITY],ODD:[` % 2 === 1`,T.MODULUS,T.EQUALITY],WHOLE:[` % 1 === 0`,T.MODULUS,T.EQUALITY],POSITIVE:[` > 0`,T.RELATIONAL,T.RELATIONAL],NEGATIVE:[` < 0`,T.RELATIONAL,T.RELATIONAL],DIVISIBLE_BY:[null,T.MODULUS,T.EQUALITY],PRIME:[null,T.NONE,T.FUNCTION_CALL]};let r=e.getFieldValue(`PROPERTY`),[i,a,o]=n[r];return n=t.valueToCode(e,`NUMBER_TO_CHECK`,a)||`0`,r===`PRIME`?e=t.provideFunction_(`mathIsPrime`,`
|
|
873
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(n) {
|
|
874
|
+
// https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
|
875
|
+
if (n == 2 || n == 3) {
|
|
876
|
+
return true;
|
|
877
|
+
}
|
|
878
|
+
// False if n is NaN, negative, is 1, or not whole.
|
|
879
|
+
// And false if n is divisible by 2 or 3.
|
|
880
|
+
if (isNaN(n) || n <= 1 || n % 1 !== 0 || n % 2 === 0 || n % 3 === 0) {
|
|
881
|
+
return false;
|
|
882
|
+
}
|
|
883
|
+
// Check all the numbers of form 6k +/- 1, up to sqrt(n).
|
|
884
|
+
for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {
|
|
885
|
+
if (n % (x - 1) === 0 || n % (x + 1) === 0) {
|
|
886
|
+
return false;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
return true;
|
|
890
|
+
}
|
|
891
|
+
`)+`(`+n+`)`:r===`DIVISIBLE_BY`?(e=t.valueToCode(e,`DIVISOR`,T.MODULUS)||`0`,e=n+` % `+e+` === 0`):e=n+i,[e,o]},ce=function(e,t){let n=t.valueToCode(e,`DELTA`,T.ADDITION)||`0`;return e=t.getVariableName(e.getFieldValue(`VAR`)),e+` = (typeof `+e+` === 'number' ? `+e+` : 0) + `+n+`;
|
|
892
|
+
`},le=function(e,t){var n=e.getFieldValue(`OP`);switch(n){case`SUM`:e=t.valueToCode(e,`LIST`,T.MEMBER)||`[]`,e+=`.reduce(function(x, y) {return x + y;}, 0)`;break;case`MIN`:e=t.valueToCode(e,`LIST`,T.NONE)||`[]`,e=`Math.min.apply(null, `+e+`)`;break;case`MAX`:e=t.valueToCode(e,`LIST`,T.NONE)||`[]`,e=`Math.max.apply(null, `+e+`)`;break;case`AVERAGE`:n=t.provideFunction_(`mathMean`,`
|
|
893
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(myList) {
|
|
894
|
+
return myList.reduce(function(x, y) {return x + y;}, 0) / myList.length;
|
|
895
|
+
}
|
|
896
|
+
`),e=t.valueToCode(e,`LIST`,T.NONE)||`[]`,e=n+`(`+e+`)`;break;case`MEDIAN`:n=t.provideFunction_(`mathMedian`,`
|
|
897
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(myList) {
|
|
898
|
+
var localList = myList.filter(function (x) {return typeof x === 'number';});
|
|
899
|
+
if (!localList.length) return null;
|
|
900
|
+
localList.sort(function(a, b) {return b - a;});
|
|
901
|
+
if (localList.length % 2 === 0) {
|
|
902
|
+
return (localList[localList.length / 2 - 1] + localList[localList.length / 2]) / 2;
|
|
903
|
+
} else {
|
|
904
|
+
return localList[(localList.length - 1) / 2];
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
`),e=t.valueToCode(e,`LIST`,T.NONE)||`[]`,e=n+`(`+e+`)`;break;case`MODE`:n=t.provideFunction_(`mathModes`,`
|
|
908
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(values) {
|
|
909
|
+
var modes = [];
|
|
910
|
+
var counts = [];
|
|
911
|
+
var maxCount = 0;
|
|
912
|
+
for (var i = 0; i < values.length; i++) {
|
|
913
|
+
var value = values[i];
|
|
914
|
+
var found = false;
|
|
915
|
+
var thisCount;
|
|
916
|
+
for (var j = 0; j < counts.length; j++) {
|
|
917
|
+
if (counts[j][0] === value) {
|
|
918
|
+
thisCount = ++counts[j][1];
|
|
919
|
+
found = true;
|
|
920
|
+
break;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
if (!found) {
|
|
924
|
+
counts.push([value, 1]);
|
|
925
|
+
thisCount = 1;
|
|
926
|
+
}
|
|
927
|
+
maxCount = Math.max(thisCount, maxCount);
|
|
928
|
+
}
|
|
929
|
+
for (var j = 0; j < counts.length; j++) {
|
|
930
|
+
if (counts[j][1] === maxCount) {
|
|
931
|
+
modes.push(counts[j][0]);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return modes;
|
|
935
|
+
}
|
|
936
|
+
`),e=t.valueToCode(e,`LIST`,T.NONE)||`[]`,e=n+`(`+e+`)`;break;case`STD_DEV`:n=t.provideFunction_(`mathStandardDeviation`,`
|
|
937
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(numbers) {
|
|
938
|
+
var n = numbers.length;
|
|
939
|
+
if (!n) return null;
|
|
940
|
+
var mean = numbers.reduce(function(x, y) {return x + y;}) / n;
|
|
941
|
+
var variance = 0;
|
|
942
|
+
for (var j = 0; j < n; j++) {
|
|
943
|
+
variance += Math.pow(numbers[j] - mean, 2);
|
|
944
|
+
}
|
|
945
|
+
variance /= n;
|
|
946
|
+
return Math.sqrt(variance);
|
|
947
|
+
}
|
|
948
|
+
`),e=t.valueToCode(e,`LIST`,T.NONE)||`[]`,e=n+`(`+e+`)`;break;case`RANDOM`:n=t.provideFunction_(`mathRandomList`,`
|
|
949
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(list) {
|
|
950
|
+
var x = Math.floor(Math.random() * list.length);
|
|
951
|
+
return list[x];
|
|
952
|
+
}
|
|
953
|
+
`),e=t.valueToCode(e,`LIST`,T.NONE)||`[]`,e=n+`(`+e+`)`;break;default:throw Error(`Unknown operator: `+n)}return[e,T.FUNCTION_CALL]},ue=function(e,t){let n=t.valueToCode(e,`DIVIDEND`,T.MODULUS)||`0`;return e=t.valueToCode(e,`DIVISOR`,T.MODULUS)||`0`,[n+` % `+e,T.MODULUS]},C=function(e,t){let n=t.valueToCode(e,`VALUE`,T.NONE)||`0`,r=t.valueToCode(e,`LOW`,T.NONE)||`0`;return e=t.valueToCode(e,`HIGH`,T.NONE)||`Infinity`,[`Math.min(Math.max(`+n+`, `+r+`), `+e+`)`,T.FUNCTION_CALL]},de=function(e,t){let n=t.valueToCode(e,`FROM`,T.NONE)||`0`;return e=t.valueToCode(e,`TO`,T.NONE)||`0`,[t.provideFunction_(`mathRandomInt`,`
|
|
954
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(a, b) {
|
|
955
|
+
if (a > b) {
|
|
956
|
+
// Swap a and b to ensure a is smaller.
|
|
957
|
+
var c = a;
|
|
958
|
+
a = b;
|
|
959
|
+
b = c;
|
|
960
|
+
}
|
|
961
|
+
return Math.floor(Math.random() * (b - a + 1) + a);
|
|
962
|
+
}
|
|
963
|
+
`)+`(`+n+`, `+e+`)`,T.FUNCTION_CALL]},fe=function(e,t){return[`Math.random()`,T.FUNCTION_CALL]},pe=function(e,t){let n=t.valueToCode(e,`X`,T.NONE)||`0`;return[`Math.atan2(`+(t.valueToCode(e,`Y`,T.NONE)||`0`)+`, `+n+`) / Math.PI * 180`,T.DIVISION]},me=function(e,t){let n=t.getProcedureName(e.getFieldValue(`NAME`));var r=``;t.STATEMENT_PREFIX&&(r+=t.injectId(t.STATEMENT_PREFIX,e)),t.STATEMENT_SUFFIX&&(r+=t.injectId(t.STATEMENT_SUFFIX,e)),r&&(r=t.prefixLines(r,t.INDENT));let i=``;t.INFINITE_LOOP_TRAP&&(i=t.prefixLines(t.injectId(t.INFINITE_LOOP_TRAP,e),t.INDENT));let a=``;e.getInput(`STACK`)&&(a=t.statementToCode(e,`STACK`));let o=``;e.getInput(`RETURN`)&&(o=t.valueToCode(e,`RETURN`,T.NONE)||``);let s=``;a&&o&&(s=r),o&&(o=t.INDENT+`return `+o+`;
|
|
964
|
+
`);let c=[],l=e.getVars();for(let e=0;e<l.length;e++)c[e]=t.getVariableName(l[e]);return r=`function `+n+`(`+c.join(`, `)+`) {
|
|
965
|
+
`+r+i+a+s+o+`}`,r=t.scrub_(e,r),t.definitions_[`%`+n]=r,null},he=function(e,t){let n=t.getProcedureName(e.getFieldValue(`NAME`)),r=[],i=e.getVars();for(let n=0;n<i.length;n++)r[n]=t.valueToCode(e,`ARG`+n,T.NONE)||`null`;return[n+`(`+r.join(`, `)+`)`,T.FUNCTION_CALL]},ge=function(e,t){return t.forBlock.procedures_callreturn(e,t)[0]+`;
|
|
966
|
+
`},_e=function(e,t){let n=`if (`+(t.valueToCode(e,`CONDITION`,T.NONE)||`false`)+`) {
|
|
967
|
+
`;return t.STATEMENT_SUFFIX&&(n+=t.prefixLines(t.injectId(t.STATEMENT_SUFFIX,e),t.INDENT)),e.hasReturnValue_?(e=t.valueToCode(e,`VALUE`,T.NONE)||`null`,n+=t.INDENT+`return `+e+`;
|
|
968
|
+
`):n+=t.INDENT+`return;
|
|
969
|
+
`,n+`}
|
|
970
|
+
`},ve=function(e,t){return[t.quote_(e.getFieldValue(`TEXT`)),T.ATOMIC]},ye=function(e,t){switch(e.itemCount_){case 0:return[`''`,T.ATOMIC];case 1:return e=t.valueToCode(e,`ADD0`,T.NONE)||`''`,Re(e);case 2:var n=t.valueToCode(e,`ADD0`,T.NONE)||`''`;return e=t.valueToCode(e,`ADD1`,T.NONE)||`''`,[Re(n)[0]+` + `+Re(e)[0],T.ADDITION];default:n=Array(e.itemCount_);for(let r=0;r<e.itemCount_;r++)n[r]=t.valueToCode(e,`ADD`+r,T.NONE)||`''`;return[`[`+n.join(`,`)+`].join('')`,T.FUNCTION_CALL]}},be=function(e,t){let n=t.getVariableName(e.getFieldValue(`VAR`));return e=t.valueToCode(e,`TEXT`,T.NONE)||`''`,n+` += `+Re(e)[0]+`;
|
|
971
|
+
`},xe=function(e,t){return[(t.valueToCode(e,`VALUE`,T.MEMBER)||`''`)+`.length`,T.MEMBER]},Se=function(e,t){return[`!`+(t.valueToCode(e,`VALUE`,T.MEMBER)||`''`)+`.length`,T.LOGICAL_NOT]},Ce=function(e,t){let n=e.getFieldValue(`END`)===`FIRST`?`indexOf`:`lastIndexOf`,r=t.valueToCode(e,`FIND`,T.NONE)||`''`;return t=(t.valueToCode(e,`VALUE`,T.MEMBER)||`''`)+`.`+n+`(`+r+`)`,e.workspace.options.oneBasedIndex?[t+` + 1`,T.ADDITION]:[t,T.FUNCTION_CALL]},we=function(e,t){let n=e.getFieldValue(`WHERE`)||`FROM_START`,r=t.valueToCode(e,`VALUE`,n===`RANDOM`?T.NONE:T.MEMBER)||`''`;switch(n){case`FIRST`:return[r+`.charAt(0)`,T.FUNCTION_CALL];case`LAST`:return[r+`.slice(-1)`,T.FUNCTION_CALL];case`FROM_START`:return e=t.getAdjusted(e,`AT`),[r+`.charAt(`+e+`)`,T.FUNCTION_CALL];case`FROM_END`:return e=t.getAdjusted(e,`AT`,1,!0),[r+`.slice(`+e+`).charAt(0)`,T.FUNCTION_CALL];case`RANDOM`:return[t.provideFunction_(`textRandomLetter`,`
|
|
972
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(text) {
|
|
973
|
+
var x = Math.floor(Math.random() * text.length);
|
|
974
|
+
return text[x];
|
|
975
|
+
}
|
|
976
|
+
`)+`(`+r+`)`,T.FUNCTION_CALL]}throw Error(`Unhandled option (text_charAt).`)},Te=function(e,t){var n={FIRST:`First`,LAST:`Last`,FROM_START:`FromStart`,FROM_END:`FromEnd`};let r=e.getFieldValue(`WHERE1`),i=e.getFieldValue(`WHERE2`);var a=r!==`FROM_END`&&r!==`LAST`&&i!==`FROM_END`&&i!==`LAST`,o=t.valueToCode(e,`STRING`,a?T.MEMBER:T.NONE)||`''`;if(r===`FIRST`&&i===`LAST`)return[o,T.NONE];if(o.match(/^'?\w+'?$/)||a){switch(r){case`FROM_START`:n=t.getAdjusted(e,`AT1`);break;case`FROM_END`:n=t.getAdjusted(e,`AT1`,1,!1,T.SUBTRACTION),n=o+`.length - `+n;break;case`FIRST`:n=`0`;break;default:throw Error(`Unhandled option (text_getSubstring).`)}switch(i){case`FROM_START`:t=t.getAdjusted(e,`AT2`,1);break;case`FROM_END`:t=t.getAdjusted(e,`AT2`,0,!1,T.SUBTRACTION),t=o+`.length - `+t;break;case`LAST`:t=o+`.length`;break;default:throw Error(`Unhandled option (text_getSubstring).`)}o=o+`.slice(`+n+`, `+t+`)`}else a=t.getAdjusted(e,`AT1`),e=t.getAdjusted(e,`AT2`),o=t.provideFunction_(`subsequence`+n[r]+n[i],`
|
|
977
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(sequence${r===`FROM_END`||r===`FROM_START`?`, at1`:``}${i===`FROM_END`||i===`FROM_START`?`, at2`:``}) {
|
|
978
|
+
var start = ${ze(`sequence`,r,`at1`)};
|
|
979
|
+
var end = ${ze(`sequence`,i,`at2`)} + 1;
|
|
980
|
+
return sequence.slice(start, end);
|
|
981
|
+
}
|
|
982
|
+
`)+`(`+o+(r===`FROM_END`||r===`FROM_START`?`, `+a:``)+(i===`FROM_END`||i===`FROM_START`?`, `+e:``)+`)`;return[o,T.FUNCTION_CALL]},w=function(e,t){let n={UPPERCASE:`.toUpperCase()`,LOWERCASE:`.toLowerCase()`,TITLECASE:null}[e.getFieldValue(`CASE`)];return e=t.valueToCode(e,`TEXT`,n?T.MEMBER:T.NONE)||`''`,[n?e+n:t.provideFunction_(`textToTitleCase`,`
|
|
983
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(str) {
|
|
984
|
+
return str.replace(/\\S+/g,
|
|
985
|
+
function(txt) {return txt[0].toUpperCase() + txt.substring(1).toLowerCase();});
|
|
986
|
+
}
|
|
987
|
+
`)+`(`+e+`)`,T.FUNCTION_CALL]},Ee=function(e,t){let n={LEFT:`.replace(/^[\\s\\xa0]+/, '')`,RIGHT:`.replace(/[\\s\\xa0]+$/, '')`,BOTH:`.trim()`}[e.getFieldValue(`MODE`)];return[(t.valueToCode(e,`TEXT`,T.MEMBER)||`''`)+n,T.FUNCTION_CALL]},De=function(e,t){return`window.alert(`+(t.valueToCode(e,`TEXT`,T.NONE)||`''`)+`);
|
|
988
|
+
`},Oe=function(e,t){return t=`window.prompt(`+(e.getField(`TEXT`)?t.quote_(e.getFieldValue(`TEXT`)):t.valueToCode(e,`TEXT`,T.NONE)||`''`)+`)`,e.getFieldValue(`TYPE`)===`NUMBER`&&(t=`Number(`+t+`)`),[t,T.FUNCTION_CALL]},ke=function(e,t){let n=t.valueToCode(e,`TEXT`,T.NONE)||`''`;return e=t.valueToCode(e,`SUB`,T.NONE)||`''`,[t.provideFunction_(`textCount`,`
|
|
989
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle) {
|
|
990
|
+
if (needle.length === 0) {
|
|
991
|
+
return haystack.length + 1;
|
|
992
|
+
} else {
|
|
993
|
+
return haystack.split(needle).length - 1;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
`)+`(`+n+`, `+e+`)`,T.FUNCTION_CALL]},Ae=function(e,t){let n=t.valueToCode(e,`TEXT`,T.NONE)||`''`,r=t.valueToCode(e,`FROM`,T.NONE)||`''`;return e=t.valueToCode(e,`TO`,T.NONE)||`''`,[t.provideFunction_(`textReplace`,`
|
|
997
|
+
function ${t.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement) {
|
|
998
|
+
needle = needle.replace(/([-()\\[\\]{}+?*.$\\^|,:#<!\\\\])/g, '\\\\$1')
|
|
999
|
+
.replace(/\\x08/g, '\\\\x08');
|
|
1000
|
+
return haystack.replace(new RegExp(needle, 'g'), replacement);
|
|
1001
|
+
}
|
|
1002
|
+
`)+`(`+n+`, `+r+`, `+e+`)`,T.FUNCTION_CALL]},je=function(e,t){return[(t.valueToCode(e,`TEXT`,T.MEMBER)||`''`)+`.split('').reverse().join('')`,T.FUNCTION_CALL]},Me=function(e,t){return[t.getVariableName(e.getFieldValue(`VAR`)),T.ATOMIC]},Ne=function(e,t){let n=t.valueToCode(e,`VALUE`,T.ASSIGNMENT)||`0`;return t.getVariableName(e.getFieldValue(`VAR`))+` = `+n+`;
|
|
1003
|
+
`},T;(function(e){e[e.ATOMIC=0]=`ATOMIC`,e[e.NEW=1.1]=`NEW`,e[e.MEMBER=1.2]=`MEMBER`,e[e.FUNCTION_CALL=2]=`FUNCTION_CALL`,e[e.INCREMENT=3]=`INCREMENT`,e[e.DECREMENT=3]=`DECREMENT`,e[e.BITWISE_NOT=4.1]=`BITWISE_NOT`,e[e.UNARY_PLUS=4.2]=`UNARY_PLUS`,e[e.UNARY_NEGATION=4.3]=`UNARY_NEGATION`,e[e.LOGICAL_NOT=4.4]=`LOGICAL_NOT`,e[e.TYPEOF=4.5]=`TYPEOF`,e[e.VOID=4.6]=`VOID`,e[e.DELETE=4.7]=`DELETE`,e[e.AWAIT=4.8]=`AWAIT`,e[e.EXPONENTIATION=5]=`EXPONENTIATION`,e[e.MULTIPLICATION=5.1]=`MULTIPLICATION`,e[e.DIVISION=5.2]=`DIVISION`,e[e.MODULUS=5.3]=`MODULUS`,e[e.SUBTRACTION=6.1]=`SUBTRACTION`,e[e.ADDITION=6.2]=`ADDITION`,e[e.BITWISE_SHIFT=7]=`BITWISE_SHIFT`,e[e.RELATIONAL=8]=`RELATIONAL`,e[e.IN=8]=`IN`,e[e.INSTANCEOF=8]=`INSTANCEOF`,e[e.EQUALITY=9]=`EQUALITY`,e[e.BITWISE_AND=10]=`BITWISE_AND`,e[e.BITWISE_XOR=11]=`BITWISE_XOR`,e[e.BITWISE_OR=12]=`BITWISE_OR`,e[e.LOGICAL_AND=13]=`LOGICAL_AND`,e[e.LOGICAL_OR=14]=`LOGICAL_OR`,e[e.CONDITIONAL=15]=`CONDITIONAL`,e[e.ASSIGNMENT=16]=`ASSIGNMENT`,e[e.YIELD=17]=`YIELD`,e[e.COMMA=18]=`COMMA`,e[e.NONE=99]=`NONE`})(T||(T={}));var E=class extends t.CodeGenerator$$module$build$src$core$generator{constructor(e=`JavaScript`){super(e),this.ORDER_OVERRIDES=[[T.FUNCTION_CALL,T.MEMBER],[T.FUNCTION_CALL,T.FUNCTION_CALL],[T.MEMBER,T.MEMBER],[T.MEMBER,T.FUNCTION_CALL],[T.LOGICAL_NOT,T.LOGICAL_NOT],[T.MULTIPLICATION,T.MULTIPLICATION],[T.ADDITION,T.ADDITION],[T.LOGICAL_AND,T.LOGICAL_AND],[T.LOGICAL_OR,T.LOGICAL_OR]],this.isInitialized=!1;for(let t in T)e=T[t],typeof e!=`string`&&(this[`ORDER_`+t]=e);this.addReservedWords(`break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,in,instanceof,new,return,super,switch,this,throw,try,typeof,var,void,while,with,yield,enum,implements,interface,let,package,private,protected,public,static,await,null,true,false,arguments,`+Object.getOwnPropertyNames(globalThis).join(`,`))}init(e){super.init(e),this.nameDB_?this.nameDB_.reset():this.nameDB_=new t.Names$$module$build$src$core$names(this.RESERVED_WORDS_),this.nameDB_.setVariableMap(e.getVariableMap()),this.nameDB_.populateVariables(e),this.nameDB_.populateProcedures(e);let n=[];var r=t.allDeveloperVariables$$module$build$src$core$variables(e);for(let e=0;e<r.length;e++)n.push(this.nameDB_.getName(r[e],t.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));for(e=t.allUsedVarModels$$module$build$src$core$variables(e),r=0;r<e.length;r++)n.push(this.nameDB_.getName(e[r].getId(),t.NameType$$module$build$src$core$names.VARIABLE));n.length&&(this.definitions_.variables=`var `+n.join(`, `)+`;`),this.isInitialized=!0}finish(e){let t=Object.values(this.definitions_);return super.finish(e),this.isInitialized=!1,this.nameDB_.reset(),t.join(`
|
|
1004
|
+
|
|
1005
|
+
`)+`
|
|
1006
|
+
|
|
1007
|
+
|
|
1008
|
+
`+e}scrubNakedValue(e){return e+`;
|
|
1009
|
+
`}quote_(e){return e=e.replace(/\\/g,`\\\\`).replace(/\n/g,`\\
|
|
1010
|
+
`).replace(/'/g,`\\'`),`'`+e+`'`}multiline_quote_(e){return e.split(/\n/g).map(this.quote_).join(` + '\\n' +
|
|
1011
|
+
`)}scrub_(e,n,r=!1){let i=``;if(!e.outputConnection||!e.outputConnection.targetConnection){var a=e.getCommentText();a&&(a=t.wrap$$module$build$src$core$utils$string(a,this.COMMENT_WRAP-3),i+=this.prefixLines(a+`
|
|
1012
|
+
`,`// `));for(let n=0;n<e.inputList.length;n++)e.inputList[n].type===t.inputTypes$$module$build$src$core$inputs$input_types.VALUE&&(a=e.inputList[n].connection.targetBlock())&&(a=this.allNestedComments(a))&&(i+=this.prefixLines(a,`// `))}return e=e.nextConnection&&e.nextConnection.targetBlock(),r=r?``:this.blockToCode(e),i+n+r}getAdjusted(e,n,r=0,i=!1,a=T.NONE){e.workspace.options.oneBasedIndex&&r--;let o=e.workspace.options.oneBasedIndex?`1`:`0`,s=a;return r>0?s=T.ADDITION:r<0?s=T.SUBTRACTION:i&&(s=T.UNARY_NEGATION),e=this.valueToCode(e,n,s)||o,r===0&&!i?e:t.isNumber$$module$build$src$core$utils$string(e)?(e=String(Number(e)+r),i&&(e=String(-Number(e))),e):(r>0?e=`${e} + ${r}`:r<0&&(e=`${e} - ${-r}`),i&&(e=r?`-(${e})`:`-${e}`),Math.floor(a)>=Math.floor(s)&&(e=`(${e})`),e)}},Pe={};Pe.JavascriptGenerator=E,Pe.Order=T;var D=function(e,t,n){return t===`FIRST`?`0`:t===`FROM_END`?e+`.length - 1 - `+n:t===`LAST`?e+`.length - 1`:n},O={};O.lists_create_empty=n,O.lists_create_with=r,O.lists_getIndex=c,O.lists_getSublist=u,O.lists_indexOf=s,O.lists_isEmpty=o,O.lists_length=a,O.lists_repeat=i,O.lists_reverse=p,O.lists_setIndex=l,O.lists_sort=d,O.lists_split=f;var Fe={};Fe.controls_if=m,Fe.controls_ifelse=m,Fe.logic_boolean=v,Fe.logic_compare=h,Fe.logic_negate=_,Fe.logic_null=y,Fe.logic_operation=g,Fe.logic_ternary=b;var k={};k.controls_flow_statements=ie,k.controls_for=ne,k.controls_forEach=re,k.controls_repeat=ee,k.controls_repeat_ext=ee,k.controls_whileUntil=te;var Ie={};Ie.math_arithmetic=x,Ie.math_atan2=pe,Ie.math_change=ce,Ie.math_constant=se,Ie.math_constrain=C,Ie.math_modulo=ue,Ie.math_number=ae,Ie.math_number_property=S,Ie.math_on_list=le,Ie.math_random_float=fe,Ie.math_random_int=de,Ie.math_round=oe,Ie.math_single=oe,Ie.math_trig=oe;var A={};A.procedures_callnoreturn=ge,A.procedures_callreturn=he,A.procedures_defnoreturn=me,A.procedures_defreturn=me,A.procedures_ifreturn=_e;var Le=/^\s*'([^']|\\')*'\s*$/,Re=function(e){return Le.test(e)?[e,T.ATOMIC]:[`String(`+e+`)`,T.FUNCTION_CALL]},ze=function(e,t,n){return t===`FIRST`?`0`:t===`FROM_END`?e+`.length - 1 - `+n:t===`LAST`?e+`.length - 1`:n},Be={};Be.text=ve,Be.text_append=be,Be.text_changeCase=w,Be.text_charAt=we,Be.text_count=ke,Be.text_getSubstring=Te,Be.text_indexOf=Ce,Be.text_isEmpty=Se,Be.text_join=ye,Be.text_length=xe,Be.text_print=De,Be.text_prompt=Oe,Be.text_prompt_ext=Oe,Be.text_replace=Ae,Be.text_reverse=je,Be.text_trim=Ee;var Ve={};Ve.variables_get=Me,Ve.variables_set=Ne;var He={};He.variables_get_dynamic=Me,He.variables_set_dynamic=Ne;var Ue=new E,We=Object.assign({},O,Fe,k,Ie,A,Be,Ve,He);for(let e in We)Ue.forBlock[e]=We[e];var Ge={};return Ge.JavascriptGenerator=E,Ge.Order=T,Ge.javascriptGenerator=Ue,Ge.__namespace__=t,Ge})}));const{JavascriptGenerator:Wn,Order:Gn,javascriptGenerator:Kn}=e(Un(),1).default;function qn(){this.__data__=[],this.size=0}function Jn(e,t){return e===t||e!==e&&t!==t}function Yn(e,t){for(var n=e.length;n--;)if(Jn(e[n][0],t))return n;return-1}var Xn=Array.prototype.splice;function Zn(e){var t=this.__data__,n=Yn(t,e);return n<0?!1:(n==t.length-1?t.pop():Xn.call(t,n,1),--this.size,!0)}function Qn(e){var t=this.__data__,n=Yn(t,e);return n<0?void 0:t[n][1]}function $n(e){return Yn(this.__data__,e)>-1}function er(e,t){var n=this.__data__,r=Yn(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function tr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}tr.prototype.clear=qn,tr.prototype.delete=Zn,tr.prototype.get=Qn,tr.prototype.has=$n,tr.prototype.set=er;function nr(){this.__data__=new tr,this.size=0}function rr(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function ir(e){return this.__data__.get(e)}function ar(e){return this.__data__.has(e)}var or=typeof global==`object`&&global&&global.Object===Object&&global,sr=typeof self==`object`&&self&&self.Object===Object&&self,cr=or||sr||Function(`return this`)(),lr=cr.Symbol,ur=Object.prototype,dr=ur.hasOwnProperty,fr=ur.toString,pr=lr?lr.toStringTag:void 0;function mr(e){var t=dr.call(e,pr),n=e[pr];try{e[pr]=void 0;var r=!0}catch{}var i=fr.call(e);return r&&(t?e[pr]=n:delete e[pr]),i}var hr=Object.prototype.toString;function gr(e){return hr.call(e)}var _r=`[object Null]`,vr=`[object Undefined]`,yr=lr?lr.toStringTag:void 0;function br(e){return e==null?e===void 0?vr:_r:yr&&yr in Object(e)?mr(e):gr(e)}function xr(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var Sr=`[object AsyncFunction]`,Cr=`[object Function]`,wr=`[object GeneratorFunction]`,Tr=`[object Proxy]`;function Er(e){if(!xr(e))return!1;var t=br(e);return t==Cr||t==wr||t==Sr||t==Tr}var Dr=cr[`__core-js_shared__`],Or=function(){var e=/[^.]+$/.exec(Dr&&Dr.keys&&Dr.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function kr(e){return!!Or&&Or in e}var Ar=Function.prototype.toString;function jr(e){if(e!=null){try{return Ar.call(e)}catch{}try{return e+``}catch{}}return``}var Mr=/[\\^$.*+?()[\]{}|]/g,Nr=/^\[object .+?Constructor\]$/,Pr=Function.prototype,Fr=Object.prototype,Ir=Pr.toString,Lr=Fr.hasOwnProperty,Rr=RegExp(`^`+Ir.call(Lr).replace(Mr,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function zr(e){return!xr(e)||kr(e)?!1:(Er(e)?Rr:Nr).test(jr(e))}function Br(e,t){return e?.[t]}function Vr(e,t){var n=Br(e,t);return zr(n)?n:void 0}var Hr=Vr(cr,`Map`),Ur=Vr(Object,`create`);function Wr(){this.__data__=Ur?Ur(null):{},this.size=0}function Gr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var Kr=`__lodash_hash_undefined__`,qr=Object.prototype.hasOwnProperty;function Jr(e){var t=this.__data__;if(Ur){var n=t[e];return n===Kr?void 0:n}return qr.call(t,e)?t[e]:void 0}var Yr=Object.prototype.hasOwnProperty;function Xr(e){var t=this.__data__;return Ur?t[e]!==void 0:Yr.call(t,e)}var Zr=`__lodash_hash_undefined__`;function Qr(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=Ur&&t===void 0?Zr:t,this}function $r(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}$r.prototype.clear=Wr,$r.prototype.delete=Gr,$r.prototype.get=Jr,$r.prototype.has=Xr,$r.prototype.set=Qr;function ei(){this.size=0,this.__data__={hash:new $r,map:new(Hr||tr),string:new $r}}function ti(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function ni(e,t){var n=e.__data__;return ti(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function ri(e){var t=ni(this,e).delete(e);return this.size-=+!!t,t}function ii(e){return ni(this,e).get(e)}function ai(e){return ni(this,e).has(e)}function oi(e,t){var n=ni(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function si(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}si.prototype.clear=ei,si.prototype.delete=ri,si.prototype.get=ii,si.prototype.has=ai,si.prototype.set=oi;var ci=200;function li(e,t){var n=this.__data__;if(n instanceof tr){var r=n.__data__;if(!Hr||r.length<ci-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new si(r)}return n.set(e,t),this.size=n.size,this}function ui(e){var t=this.__data__=new tr(e);this.size=t.size}ui.prototype.clear=nr,ui.prototype.delete=rr,ui.prototype.get=ir,ui.prototype.has=ar,ui.prototype.set=li;function di(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}var fi=function(){try{var e=Vr(Object,`defineProperty`);return e({},``,{}),e}catch{}}();function pi(e,t,n){t==`__proto__`&&fi?fi(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}var mi=Object.prototype.hasOwnProperty;function hi(e,t,n){var r=e[t];(!(mi.call(e,t)&&Jn(r,n))||n===void 0&&!(t in e))&&pi(e,t,n)}function gi(e,t,n,r){var i=!n;n||(n={});for(var a=-1,o=t.length;++a<o;){var s=t[a],c=r?r(n[s],e[s],s,n,e):void 0;c===void 0&&(c=e[s]),i?pi(n,s,c):hi(n,s,c)}return n}function _i(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function vi(e){return typeof e==`object`&&!!e}var yi=`[object Arguments]`;function bi(e){return vi(e)&&br(e)==yi}var xi=Object.prototype,Si=xi.hasOwnProperty,Ci=xi.propertyIsEnumerable,wi=bi(function(){return arguments}())?bi:function(e){return vi(e)&&Si.call(e,`callee`)&&!Ci.call(e,`callee`)},Ti=Array.isArray;function Ei(){return!1}var Di=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Oi=Di&&typeof module==`object`&&module&&!module.nodeType&&module,ki=Oi&&Oi.exports===Di?cr.Buffer:void 0,Ai=(ki?ki.isBuffer:void 0)||Ei,ji=9007199254740991,Mi=/^(?:0|[1-9]\d*)$/;function Ni(e,t){var n=typeof e;return t=t??ji,!!t&&(n==`number`||n!=`symbol`&&Mi.test(e))&&e>-1&&e%1==0&&e<t}var Pi=9007199254740991;function Fi(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=Pi}var Ii=`[object Arguments]`,Li=`[object Array]`,Ri=`[object Boolean]`,zi=`[object Date]`,Bi=`[object Error]`,Vi=`[object Function]`,Hi=`[object Map]`,Ui=`[object Number]`,Wi=`[object Object]`,Gi=`[object RegExp]`,Ki=`[object Set]`,qi=`[object String]`,Ji=`[object WeakMap]`,Yi=`[object ArrayBuffer]`,Xi=`[object DataView]`,Zi=`[object Float32Array]`,Qi=`[object Float64Array]`,$i=`[object Int8Array]`,ea=`[object Int16Array]`,ta=`[object Int32Array]`,na=`[object Uint8Array]`,ra=`[object Uint8ClampedArray]`,ia=`[object Uint16Array]`,aa=`[object Uint32Array]`,oa={};oa[Zi]=oa[Qi]=oa[$i]=oa[ea]=oa[ta]=oa[na]=oa[ra]=oa[ia]=oa[aa]=!0,oa[Ii]=oa[Li]=oa[Yi]=oa[Ri]=oa[Xi]=oa[zi]=oa[Bi]=oa[Vi]=oa[Hi]=oa[Ui]=oa[Wi]=oa[Gi]=oa[Ki]=oa[qi]=oa[Ji]=!1;function sa(e){return vi(e)&&Fi(e.length)&&!!oa[br(e)]}function ca(e){return function(t){return e(t)}}var la=typeof exports==`object`&&exports&&!exports.nodeType&&exports,ua=la&&typeof module==`object`&&module&&!module.nodeType&&module,da=ua&&ua.exports===la&&or.process,fa=function(){try{return ua&&ua.require&&ua.require(`util`).types||da&&da.binding&&da.binding(`util`)}catch{}}(),pa=fa&&fa.isTypedArray,ma=pa?ca(pa):sa,ha=Object.prototype.hasOwnProperty;function ga(e,t){var n=Ti(e),r=!n&&wi(e),i=!n&&!r&&Ai(e),a=!n&&!r&&!i&&ma(e),o=n||r||i||a,s=o?_i(e.length,String):[],c=s.length;for(var l in e)(t||ha.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||Ni(l,c)))&&s.push(l);return s}var _a=Object.prototype;function va(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||_a)}function ya(e,t){return function(n){return e(t(n))}}var ba=ya(Object.keys,Object),xa=Object.prototype.hasOwnProperty;function Sa(e){if(!va(e))return ba(e);var t=[];for(var n in Object(e))xa.call(e,n)&&n!=`constructor`&&t.push(n);return t}function Ca(e){return e!=null&&Fi(e.length)&&!Er(e)}function wa(e){return Ca(e)?ga(e):Sa(e)}function Ta(e,t){return e&&gi(t,wa(t),e)}function Ea(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var Da=Object.prototype.hasOwnProperty;function Oa(e){if(!xr(e))return Ea(e);var t=va(e),n=[];for(var r in e)r==`constructor`&&(t||!Da.call(e,r))||n.push(r);return n}function ka(e){return Ca(e)?ga(e,!0):Oa(e)}function Aa(e,t){return e&&gi(t,ka(t),e)}var ja=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Ma=ja&&typeof module==`object`&&module&&!module.nodeType&&module,Na=Ma&&Ma.exports===ja?cr.Buffer:void 0,Pa=Na?Na.allocUnsafe:void 0;function Fa(e,t){if(t)return e.slice();var n=e.length,r=Pa?Pa(n):new e.constructor(n);return e.copy(r),r}function Ia(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}function La(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function Ra(){return[]}var za=Object.prototype.propertyIsEnumerable,Ba=Object.getOwnPropertySymbols,Va=Ba?function(e){return e==null?[]:(e=Object(e),La(Ba(e),function(t){return za.call(e,t)}))}:Ra;function Ha(e,t){return gi(e,Va(e),t)}function Ua(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var Wa=ya(Object.getPrototypeOf,Object),Ga=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)Ua(t,Va(e)),e=Wa(e);return t}:Ra;function j(e,t){return gi(e,Ga(e),t)}function Ka(e,t,n){var r=t(e);return Ti(e)?r:Ua(r,n(e))}function qa(e){return Ka(e,wa,Va)}function Ja(e){return Ka(e,ka,Ga)}var Ya=Vr(cr,`DataView`),Xa=Vr(cr,`Promise`),M=Vr(cr,`Set`),Za=Vr(cr,`WeakMap`),Qa=`[object Map]`,$a=`[object Object]`,eo=`[object Promise]`,to=`[object Set]`,no=`[object WeakMap]`,ro=`[object DataView]`,io=jr(Ya),ao=jr(Hr),oo=jr(Xa),so=jr(M),co=jr(Za),lo=br;(Ya&&lo(new Ya(new ArrayBuffer(1)))!=ro||Hr&&lo(new Hr)!=Qa||Xa&&lo(Xa.resolve())!=eo||M&&lo(new M)!=to||Za&&lo(new Za)!=no)&&(lo=function(e){var t=br(e),n=t==$a?e.constructor:void 0,r=n?jr(n):``;if(r)switch(r){case io:return ro;case ao:return Qa;case oo:return eo;case so:return to;case co:return no}return t});var uo=lo,fo=Object.prototype.hasOwnProperty;function po(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&fo.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}var mo=cr.Uint8Array;function ho(e){var t=new e.constructor(e.byteLength);return new mo(t).set(new mo(e)),t}function go(e,t){var n=t?ho(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}var _o=/\w*$/;function vo(e){var t=new e.constructor(e.source,_o.exec(e));return t.lastIndex=e.lastIndex,t}var yo=lr?lr.prototype:void 0,bo=yo?yo.valueOf:void 0;function xo(e){return bo?Object(bo.call(e)):{}}function So(e,t){var n=t?ho(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var Co=`[object Boolean]`,wo=`[object Date]`,To=`[object Map]`,Eo=`[object Number]`,Do=`[object RegExp]`,Oo=`[object Set]`,ko=`[object String]`,Ao=`[object Symbol]`,jo=`[object ArrayBuffer]`,Mo=`[object DataView]`,No=`[object Float32Array]`,Po=`[object Float64Array]`,Fo=`[object Int8Array]`,Io=`[object Int16Array]`,Lo=`[object Int32Array]`,Ro=`[object Uint8Array]`,zo=`[object Uint8ClampedArray]`,Bo=`[object Uint16Array]`,Vo=`[object Uint32Array]`;function Ho(e,t,n){var r=e.constructor;switch(t){case jo:return ho(e);case Co:case wo:return new r(+e);case Mo:return go(e,n);case No:case Po:case Fo:case Io:case Lo:case Ro:case zo:case Bo:case Vo:return So(e,n);case To:return new r;case Eo:case ko:return new r(e);case Do:return vo(e);case Oo:return new r;case Ao:return xo(e)}}var Uo=Object.create,Wo=function(){function e(){}return function(t){if(!xr(t))return{};if(Uo)return Uo(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function Go(e){return typeof e.constructor==`function`&&!va(e)?Wo(Wa(e)):{}}var Ko=`[object Map]`;function qo(e){return vi(e)&&uo(e)==Ko}var Jo=fa&&fa.isMap,Yo=Jo?ca(Jo):qo,Xo=`[object Set]`;function Zo(e){return vi(e)&&uo(e)==Xo}var Qo=fa&&fa.isSet,$o=Qo?ca(Qo):Zo,es=1,ts=2,ns=4,rs=`[object Arguments]`,is=`[object Array]`,as=`[object Boolean]`,os=`[object Date]`,ss=`[object Error]`,cs=`[object Function]`,ls=`[object GeneratorFunction]`,us=`[object Map]`,ds=`[object Number]`,fs=`[object Object]`,ps=`[object RegExp]`,ms=`[object Set]`,hs=`[object String]`,gs=`[object Symbol]`,_s=`[object WeakMap]`,vs=`[object ArrayBuffer]`,ys=`[object DataView]`,bs=`[object Float32Array]`,xs=`[object Float64Array]`,Ss=`[object Int8Array]`,Cs=`[object Int16Array]`,ws=`[object Int32Array]`,Ts=`[object Uint8Array]`,Es=`[object Uint8ClampedArray]`,Ds=`[object Uint16Array]`,Os=`[object Uint32Array]`,ks={};ks[rs]=ks[is]=ks[vs]=ks[ys]=ks[as]=ks[os]=ks[bs]=ks[xs]=ks[Ss]=ks[Cs]=ks[ws]=ks[us]=ks[ds]=ks[fs]=ks[ps]=ks[ms]=ks[hs]=ks[gs]=ks[Ts]=ks[Es]=ks[Ds]=ks[Os]=!0,ks[ss]=ks[cs]=ks[_s]=!1;function As(e,t,n,r,i,a){var o,s=t&es,c=t&ts,l=t&ns;if(n&&(o=i?n(e,r,i,a):n(e)),o!==void 0)return o;if(!xr(e))return e;var u=Ti(e);if(u){if(o=po(e),!s)return Ia(e,o)}else{var d=uo(e),f=d==cs||d==ls;if(Ai(e))return Fa(e,s);if(d==fs||d==rs||f&&!i){if(o=c||f?{}:Go(e),!s)return c?j(e,Aa(o,e)):Ha(e,Ta(o,e))}else{if(!ks[d])return i?e:{};o=Ho(e,d,s)}}a||(a=new ui);var p=a.get(e);if(p)return p;a.set(e,o),$o(e)?e.forEach(function(r){o.add(As(r,t,n,r,e,a))}):Yo(e)&&e.forEach(function(r,i){o.set(i,As(r,t,n,i,e,a))});var m=u?void 0:(l?c?Ja:qa:c?ka:wa)(e);return di(m||e,function(r,i){m&&(i=r,r=e[i]),hi(o,i,As(r,t,n,i,e,a))}),o}var js=1,Ms=4;function Ns(e){return As(e,js|Ms)}var Ps=function(){return cr.Date.now()},Fs=/\s/;function Is(e){for(var t=e.length;t--&&Fs.test(e.charAt(t)););return t}var Ls=/^\s+/;function Rs(e){return e&&e.slice(0,Is(e)+1).replace(Ls,``)}var zs=`[object Symbol]`;function Bs(e){return typeof e==`symbol`||vi(e)&&br(e)==zs}var Vs=NaN,Hs=/^[-+]0x[0-9a-f]+$/i,Us=/^0b[01]+$/i,Ws=/^0o[0-7]+$/i,Gs=parseInt;function Ks(e){if(typeof e==`number`)return e;if(Bs(e))return Vs;if(xr(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=xr(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=Rs(e);var n=Us.test(e);return n||Ws.test(e)?Gs(e.slice(2),n?2:8):Hs.test(e)?Vs:+e}var qs=`Expected a function`,Js=Math.max,Ys=Math.min;function Xs(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0;if(typeof e!=`function`)throw TypeError(qs);t=Ks(t)||0,xr(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?Js(Ks(n.maxWait)||0,t):a,f=`trailing`in n?!!n.trailing:f);function p(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function m(e){return l=e,s=setTimeout(_,t),u?p(e):o}function h(e){var n=e-c,r=e-l,i=t-n;return d?Ys(i,a-r):i}function g(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function _(){var e=Ps();if(g(e))return v(e);s=setTimeout(_,h(e))}function v(e){return s=void 0,f&&r?p(e):(r=i=void 0,o)}function y(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function b(){return s===void 0?o:v(Ps())}function ee(){var e=Ps(),n=g(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return m(c);if(d)return clearTimeout(s),s=setTimeout(_,t),p(c)}return s===void 0&&(s=setTimeout(_,t)),o}return ee.cancel=y,ee.flush=b,ee}var Zs=`__lodash_hash_undefined__`;function Qs(e){return this.__data__.set(e,Zs),this}function $s(e){return this.__data__.has(e)}function ec(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new si;++t<n;)this.add(e[t])}ec.prototype.add=ec.prototype.push=Qs,ec.prototype.has=$s;function tc(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function nc(e,t){return e.has(t)}var rc=1,ic=2;function ac(e,t,n,r,i,a){var o=n&rc,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=n&ic?new ec:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!tc(t,function(e,t){if(!nc(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)})){f=!1;break}}else if(!(m===h||i(m,h,n,r,a))){f=!1;break}}return a.delete(e),a.delete(t),f}function oc(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function N(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var sc=1,cc=2,lc=`[object Boolean]`,uc=`[object Date]`,P=`[object Error]`,dc=`[object Map]`,fc=`[object Number]`,pc=`[object RegExp]`,mc=`[object Set]`,hc=`[object String]`,gc=`[object Symbol]`,_c=`[object ArrayBuffer]`,vc=`[object DataView]`,yc=lr?lr.prototype:void 0,bc=yc?yc.valueOf:void 0;function xc(e,t,n,r,i,a,o){switch(n){case vc:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case _c:return!(e.byteLength!=t.byteLength||!a(new mo(e),new mo(t)));case lc:case uc:case fc:return Jn(+e,+t);case P:return e.name==t.name&&e.message==t.message;case pc:case hc:return e==t+``;case dc:var s=oc;case mc:var c=r≻if(s||(s=N),e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=cc,o.set(e,t);var u=ac(s(e),s(t),r,i,a,o);return o.delete(e),u;case gc:if(bc)return bc.call(e)==bc.call(t)}return!1}var Sc=1,Cc=Object.prototype.hasOwnProperty;function wc(e,t,n,r,i,a){var o=n&Sc,s=qa(e),c=s.length;if(c!=qa(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:Cc.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){u=s[l];var h=e[u],g=t[u];if(r)var _=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(_===void 0?h===g||i(h,g,n,r,a):_)){p=!1;break}m||(m=u==`constructor`)}if(p&&!m){var v=e.constructor,y=t.constructor;v!=y&&`constructor`in e&&`constructor`in t&&!(typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y)&&(p=!1)}return a.delete(e),a.delete(t),p}var Tc=1,Ec=`[object Arguments]`,Dc=`[object Array]`,Oc=`[object Object]`,kc=Object.prototype.hasOwnProperty;function Ac(e,t,n,r,i,a){var o=Ti(e),s=Ti(t),c=o?Dc:uo(e),l=s?Dc:uo(t);c=c==Ec?Oc:c,l=l==Ec?Oc:l;var u=c==Oc,d=l==Oc,f=c==l;if(f&&Ai(e)){if(!Ai(t))return!1;o=!0,u=!1}if(f&&!u)return a||(a=new ui),o||ma(e)?ac(e,t,n,r,i,a):xc(e,t,c,n,r,i,a);if(!(n&Tc)){var p=u&&kc.call(e,`__wrapped__`),m=d&&kc.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||(a=new ui),i(h,g,n,r,a)}}return f?(a||(a=new ui),wc(e,t,n,r,i,a)):!1}function jc(e,t,n,r,i){return e===t?!0:e==null||t==null||!vi(e)&&!vi(t)?e!==e&&t!==t:Ac(e,t,n,r,jc,i)}function Mc(e,t){return jc(e,t)}function Nc(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var Pc=1/0,Fc=lr?lr.prototype:void 0,Ic=Fc?Fc.toString:void 0;function Lc(e){if(typeof e==`string`)return e;if(Ti(e))return Nc(e,Lc)+``;if(Bs(e))return Ic?Ic.call(e):``;var t=e+``;return t==`0`&&1/e==-Pc?`-0`:t}function Rc(e){return e==null?``:Lc(e)}var zc=/^\s+/,Bc=cr.parseInt;function F(e,t,n){return n||t==null?t=0:t&&(t=+t),Bc(Rc(e).replace(zc,``),t||0)}function Vc(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function Hc(e){return function(t){return e?.[t]}}var Uc=Hc({À:`A`,Á:`A`,Â:`A`,Ã:`A`,Ä:`A`,Å:`A`,à:`a`,á:`a`,â:`a`,ã:`a`,ä:`a`,å:`a`,Ç:`C`,ç:`c`,Ð:`D`,ð:`d`,È:`E`,É:`E`,Ê:`E`,Ë:`E`,è:`e`,é:`e`,ê:`e`,ë:`e`,Ì:`I`,Í:`I`,Î:`I`,Ï:`I`,ì:`i`,í:`i`,î:`i`,ï:`i`,Ñ:`N`,ñ:`n`,Ò:`O`,Ó:`O`,Ô:`O`,Õ:`O`,Ö:`O`,Ø:`O`,ò:`o`,ó:`o`,ô:`o`,õ:`o`,ö:`o`,ø:`o`,Ù:`U`,Ú:`U`,Û:`U`,Ü:`U`,ù:`u`,ú:`u`,û:`u`,ü:`u`,Ý:`Y`,ý:`y`,ÿ:`y`,Æ:`Ae`,æ:`ae`,Þ:`Th`,þ:`th`,ß:`ss`,Ā:`A`,Ă:`A`,Ą:`A`,ā:`a`,ă:`a`,ą:`a`,Ć:`C`,Ĉ:`C`,Ċ:`C`,Č:`C`,ć:`c`,ĉ:`c`,ċ:`c`,č:`c`,Ď:`D`,Đ:`D`,ď:`d`,đ:`d`,Ē:`E`,Ĕ:`E`,Ė:`E`,Ę:`E`,Ě:`E`,ē:`e`,ĕ:`e`,ė:`e`,ę:`e`,ě:`e`,Ĝ:`G`,Ğ:`G`,Ġ:`G`,Ģ:`G`,ĝ:`g`,ğ:`g`,ġ:`g`,ģ:`g`,Ĥ:`H`,Ħ:`H`,ĥ:`h`,ħ:`h`,Ĩ:`I`,Ī:`I`,Ĭ:`I`,Į:`I`,İ:`I`,ĩ:`i`,ī:`i`,ĭ:`i`,į:`i`,ı:`i`,Ĵ:`J`,ĵ:`j`,Ķ:`K`,ķ:`k`,ĸ:`k`,Ĺ:`L`,Ļ:`L`,Ľ:`L`,Ŀ:`L`,Ł:`L`,ĺ:`l`,ļ:`l`,ľ:`l`,ŀ:`l`,ł:`l`,Ń:`N`,Ņ:`N`,Ň:`N`,Ŋ:`N`,ń:`n`,ņ:`n`,ň:`n`,ŋ:`n`,Ō:`O`,Ŏ:`O`,Ő:`O`,ō:`o`,ŏ:`o`,ő:`o`,Ŕ:`R`,Ŗ:`R`,Ř:`R`,ŕ:`r`,ŗ:`r`,ř:`r`,Ś:`S`,Ŝ:`S`,Ş:`S`,Š:`S`,ś:`s`,ŝ:`s`,ş:`s`,š:`s`,Ţ:`T`,Ť:`T`,Ŧ:`T`,ţ:`t`,ť:`t`,ŧ:`t`,Ũ:`U`,Ū:`U`,Ŭ:`U`,Ů:`U`,Ű:`U`,Ų:`U`,ũ:`u`,ū:`u`,ŭ:`u`,ů:`u`,ű:`u`,ų:`u`,Ŵ:`W`,ŵ:`w`,Ŷ:`Y`,ŷ:`y`,Ÿ:`Y`,Ź:`Z`,Ż:`Z`,Ž:`Z`,ź:`z`,ż:`z`,ž:`z`,IJ:`IJ`,ij:`ij`,Œ:`Oe`,œ:`oe`,ʼn:`'n`,ſ:`s`}),Wc=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Gc=RegExp(`[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]`,`g`);function Kc(e){return e=Rc(e),e&&e.replace(Wc,Uc).replace(Gc,``)}var qc=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Jc(e){return e.match(qc)||[]}var Yc=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function Xc(e){return Yc.test(e)}var Zc=`\\ud800-\\udfff`,Qc=`\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff`,$c=`\\u2700-\\u27bf`,el=`a-z\\xdf-\\xf6\\xf8-\\xff`,tl=`\\xac\\xb1\\xd7\\xf7`,nl=`\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf`,rl=`\\u2000-\\u206f`,il=` \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000`,al=`A-Z\\xc0-\\xd6\\xd8-\\xde`,ol=`\\ufe0e\\ufe0f`,sl=tl+nl+rl+il,cl=`['’]`,ll=`[`+sl+`]`,ul=`[`+Qc+`]`,dl=`\\d+`,fl=`[`+$c+`]`,pl=`[`+el+`]`,ml=`[^`+Zc+sl+dl+$c+el+al+`]`,hl=`(?:`+ul+`|\\ud83c[\\udffb-\\udfff])`,gl=`[^`+Zc+`]`,_l=`(?:\\ud83c[\\udde6-\\uddff]){2}`,vl=`[\\ud800-\\udbff][\\udc00-\\udfff]`,yl=`[`+al+`]`,bl=`\\u200d`,xl=`(?:`+pl+`|`+ml+`)`,Sl=`(?:`+yl+`|`+ml+`)`,Cl=`(?:`+cl+`(?:d|ll|m|re|s|t|ve))?`,wl=`(?:`+cl+`(?:D|LL|M|RE|S|T|VE))?`,Tl=hl+`?`,El=`[`+ol+`]?`,Dl=`(?:`+bl+`(?:`+[gl,_l,vl].join(`|`)+`)`+El+Tl+`)*`,Ol=`\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])`,kl=`\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])`,Al=El+Tl+Dl,jl=`(?:`+[fl,_l,vl].join(`|`)+`)`+Al,Ml=RegExp([yl+`?`+pl+`+`+Cl+`(?=`+[ll,yl,`$`].join(`|`)+`)`,Sl+`+`+wl+`(?=`+[ll,yl+xl,`$`].join(`|`)+`)`,yl+`?`+xl+`+`+Cl,yl+`+`+wl,kl,Ol,dl,jl].join(`|`),`g`);function Nl(e){return e.match(Ml)||[]}function Pl(e,t,n){return e=Rc(e),t=n?void 0:t,t===void 0?Xc(e)?Nl(e):Jc(e):e.match(t)||[]}var Fl=RegExp(`['’]`,`g`);function Il(e){return function(t){return Vc(Pl(Kc(t).replace(Fl,``)),e,``)}}var Ll=Il(function(e,t,n){return e+(n?`_`:``)+t.toLowerCase()}),Rl=Il(function(e,t,n){return e+(n?` `:``)+t.toUpperCase()}),zl=n(((e,n)=>{
|
|
1013
|
+
/*! For license information please see index.js.LICENSE.txt */
|
|
1014
|
+
(function(r,i){if(typeof e==`object`&&typeof n==`object`)n.exports=i(b(),Un(),t(`blockly/dart`),t(`blockly/lua`),t(`blockly/php`),t(`blockly/python`));else if(typeof define==`function`&&define.amd)define([`blockly/core`,`blockly/javascript`,`blockly/dart`,`blockly/lua`,`blockly/php`,`blockly/python`],i);else{var a=typeof e==`object`?i(b(),Un(),t(`blockly/dart`),t(`blockly/lua`),t(`blockly/php`),t(`blockly/python`)):i(r.Blockly,r[`Blockly.JavaScript`],r[`Blockly.Dart`],r[`Blockly.Lua`],r[`Blockly.PHP`],r[`Blockly.Python`]);for(var o in a)(typeof e==`object`?e:r)[o]=a[o]}})(e,(e,t,n,r,i,a)=>(()=>{var o={127:e=>{e.exports=t},157:e=>{e.exports=r},370:t=>{t.exports=e},379:e=>{e.exports=n},462:function(e,t,n){e.exports=(e=>(()=>{var t={370:t=>{t.exports=e}},n={};function r(e){var i=n[e];if(i!==void 0)return i.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};r.r(i),r.d(i,{FieldGridDropdown:()=>c});var a=r(370);class o{constructor(e,t,n,r){this.value=n,this.selected=!1,this.selectionCallback=r,this.element=document.createElement(`button`),this.element.id=a.utils.idGenerator.getNextUniqueId(),this.element.className=`blocklyFieldGridItem`,this.clickHandler=a.browserEvents.conditionalBind(this.element,`click`,this,this.onClick,!0),e.appendChild(this.element);let i=typeof t==`string`?document.createTextNode(t):t;this.element.appendChild(i),a.utils.aria.setRole(this.element,a.utils.aria.Role.GRIDCELL)}dispose(){this.selectionCallback=null,this.element.remove(),this.clickHandler&&(a.browserEvents.unbind(this.clickHandler),this.clickHandler=null)}getId(){return this.element.id}getValue(){return this.value}isSelected(){return this.selected}setSelected(e){this.selected=e,a.utils.aria.setState(this.element,a.utils.aria.State.SELECTED,this.selected),this.element.classList.toggle(`blocklyFieldGridItemSelected`,this.selected),this.isSelected()&&this.focus()}onClick(){var e;this.setSelected(!0),(e=this.selectionCallback)==null||e.call(this,this)}focus(){this.element.focus({preventScroll:!0});let e=this.element.offsetParent;if(!e)return;let t=this.element.offsetTop,n=e.scrollTop,r=this.getInterItemSpacing();t<n?e.scrollTo(0,t-r):t+this.element.offsetHeight>n+e.clientHeight&&e.scrollBy(0,t+this.element.clientHeight-(n+e.clientHeight)+r)}getInterItemSpacing(){let e=this.element.closest(`.blocklyFieldGrid`);if(!e)return 0;let t=[...e.querySelectorAll(`.blocklyFieldGridItem`)];if(!t.length)return 0;let n=t[0].offsetTop,r=t[0].offsetHeight;for(let e of t)if(e.offsetTop!==n)return e.offsetTop-r-n;return 0}}class s{constructor(e,t,n,r,i){if(this.columns=n,this.rtl=r,this.itemIndices=new Map,this.items=[],this.keyDownHandler=null,this.pointerMoveHandler=null,this.selectionCallback=i,this.root=document.createElement(`div`),this.root.className=`blocklyFieldGrid`,this.root.tabIndex=0,a.utils.aria.setRole(this.root,a.utils.aria.Role.GRID),e.appendChild(this.root),this.populateItems(t),this.keyDownHandler=a.browserEvents.conditionalBind(this.root,`keydown`,this,this.onKeyDown),this.pointerMoveHandler=a.browserEvents.conditionalBind(this.root,`pointermove`,this,this.onPointerMove,!0),!(n>=1))throw Error(`Number of columns must be >= 1; got ${n}`);this.columns=n,this.root.style.setProperty(`--grid-columns`,`${this.columns}`)}populateItems(e){let t=document.createElement(`div`);for(let[n,r]of e.entries()){if(r===a.FieldDropdown.SEPARATOR)continue;n%this.columns===0&&(t=document.createElement(`div`),t.className=`blocklyFieldGridRow`,a.utils.aria.setRole(t,a.utils.aria.Role.ROW),this.root.appendChild(t));let[e,i]=r,s=(()=>{if((t=e)&&typeof t==`object`&&`src`in t&&typeof t.src==`string`&&`alt`in t&&typeof t.alt==`string`&&`width`in t&&typeof t.width==`number`&&`height`in t&&typeof t.height==`number`){let t=new Image(e.width,e.height);return t.src=e.src,t.alt=e.alt||``,t}var t;return e})(),c=new o(t,s,i,e=>{var t;this.setSelectedValue(e.getValue()),(t=this.selectionCallback)==null||t.call(this,e)});this.itemIndices.set(c.getId(),this.itemIndices.size),this.items.push(c)}}dispose(){this.selectionCallback=void 0;for(let e of this.items)e.dispose();this.itemIndices.clear(),this.items.length=0,this.keyDownHandler&&(a.browserEvents.unbind(this.keyDownHandler),this.keyDownHandler=null),this.pointerMoveHandler&&(a.browserEvents.unbind(this.pointerMoveHandler),this.pointerMoveHandler=null),this.root.remove()}onKeyDown(e){if(!(!this.items.length||e.shiftKey||e.ctrlKey||e.metaKey||e.altKey)){switch(e.key){case`ArrowUp`:this.moveFocus(-1*this.columns,!0);break;case`ArrowDown`:this.moveFocus(this.columns,!0);break;case`ArrowLeft`:this.moveFocus(-1*(this.rtl?-1:1),!0);break;case`ArrowRight`:this.moveFocus(1*(this.rtl?-1:1),!0);break;case`PageUp`:case`Home`:this.moveFocus(0,!1);break;case`PageDown`:case`End`:this.moveFocus(this.items.length-1,!1);break;case`Enter`:case`Space`:e.stopPropagation();return;default:return}e.preventDefault(),e.stopPropagation()}}onPointerMove(e){if(!e.movementX&&!e.movementY||!(e.target instanceof Element))return;let t=e.target.closest(`.blocklyFieldGridItem`);if(!t)return;let n=t.id,r=this.itemIndices.get(n);r!==void 0&&this.moveFocus(r,!1)}setSelectedValue(e){for(let[t,n]of this.items.entries()){let r=n.getValue()===e;n.setSelected(r),r&&this.moveFocus(t,!1)}}moveFocus(e,t){let n=e;if(t){let e=this.getFocusedItem();if(!e)return;n+=this.indexOfItem(e)}let r=this.itemAtIndex(n);r&&(r.focus(),a.utils.aria.setState(this.root,a.utils.aria.State.ACTIVEDESCENDANT,r.getId()))}indexOfItem(e){return this.itemIndices.get(e.getId())??-1}itemAtIndex(e){return this.items[e]}getFocusedItem(){let e=this.root.querySelector(`.blocklyFieldGridItem:focus`)??this.root.querySelector(`.blocklyFieldGridItem`);if(!e||!e.id)return;let t=this.itemIndices.get(e.id);return t===void 0?void 0:this.itemAtIndex(t)}}class c extends a.FieldDropdown{constructor(e,t,n){super(e,t,n),this.columns=3,n!=null&&n.columns&&this.setColumns(parseInt(`${n.columns}`)),n&&n.primaryColour&&(this.primaryColour=n.primaryColour),n&&n.borderColour&&(this.borderColour=n.borderColour)}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)}setColumns(e){var t;!isNaN(e)&&e>=1&&(this.columns=e,a.DropDownDiv.getOwner()===this&&a.DropDownDiv.isVisible()&&((t=this.grid)==null||t.dispose(),this.showEditor_()))}showEditor_(e){a.DropDownDiv.clearContent();let t=!!this.getSourceBlock()?.workspace.RTL;this.grid=new s(a.DropDownDiv.getContentDiv(),this.getOptions(!1),this.columns,t,e=>{a.DropDownDiv.hideIfOwner(this),this.setValue(e.getValue())}),a.DropDownDiv.getContentDiv().classList.add(`blocklyFieldGridContainer`);let n=this.getColours();n&&n.border&&a.DropDownDiv.setColour(n.primary,n.border),a.DropDownDiv.showPositionedByField(this,this.dropdownDispose_.bind(this));let r=this.getValue();r&&this.grid.setSelectedValue(r)}doValueUpdate_(e){var t;super.doValueUpdate_(e),(t=this.grid)==null||t.setSelectedValue(e)}getColours(){if(this.primaryColour&&this.borderColour)return{primary:this.primaryColour,border:this.borderColour};let e=this.getSourceBlock();if(!(e instanceof a.BlockSvg))return;let t=e.isShadow()?e.getParent():e;return t?{primary:this.primaryColour??t.getColour(),border:this.borderColour??t.getColourTertiary()}:void 0}}return a.fieldRegistry.register(`field_grid_dropdown`,c),a.Css.register(`
|
|
1015
|
+
.blocklyFieldGridContainer {
|
|
1016
|
+
padding: 7px;
|
|
1017
|
+
overflow: auto;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
.blocklyFieldGrid {
|
|
1021
|
+
display: grid;
|
|
1022
|
+
grid-gap: 7px;
|
|
1023
|
+
grid-template-columns: repeat(var(--grid-columns), min-content);
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
.blocklyFieldGrid .blocklyFieldGridItem {
|
|
1027
|
+
border: 1px solid rgba(1, 1, 1, 0.5);
|
|
1028
|
+
border-radius: 4px;
|
|
1029
|
+
color: white;
|
|
1030
|
+
min-width: auto;
|
|
1031
|
+
background: none;
|
|
1032
|
+
white-space: nowrap;
|
|
1033
|
+
cursor: pointer;
|
|
1034
|
+
padding: 6px 15px;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
.blocklyFieldGrid .blocklyFieldGridRow {
|
|
1038
|
+
display: contents;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
.blocklyFieldGrid .blocklyFieldGridItem.blocklyFieldGridItemSelected {
|
|
1042
|
+
background-color: rgba(1, 1, 1, 0.25);
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
.blocklyFieldGrid .blocklyFieldGridItem:focus {
|
|
1046
|
+
box-shadow: 0 0 0 4px hsla(0, 0%, 100%, .2);
|
|
1047
|
+
outline: none;
|
|
1048
|
+
}
|
|
1049
|
+
`),i})())(n(370))},537:e=>{e.exports=i},557:e=>{e.exports=a}},s={};function c(e){var t=s[e];if(t!==void 0)return t.exports;var n=s[e]={exports:{}};return o[e].call(n.exports,n,n.exports,c),n.exports}c.d=(e,t)=>{for(var n in t)c.o(t,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c.r=e=>{typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{c.r(l),c.d(l,{FieldColour:()=>s,colourBlend:()=>r,colourPicker:()=>e,colourRandom:()=>t,colourRgb:()=>n,installAllBlocks:()=>Me,registerFieldColour:()=>d});var e={};c.r(e),c.d(e,{BLOCK_NAME:()=>_,blockDefinition:()=>ie,installBlock:()=>ae,toDart:()=>b,toJavascript:()=>y,toLua:()=>ee,toPhp:()=>te,toPython:()=>ne});var t={};c.r(t),c.d(t,{BLOCK_NAME:()=>x,blockDefinition:()=>de,installBlock:()=>fe,toDart:()=>S,toJavascript:()=>se,toLua:()=>ce,toPhp:()=>le,toPython:()=>ue});var n={};c.r(n),c.d(n,{BLOCK_NAME:()=>pe,blockDefinition:()=>xe,installBlock:()=>Se,toDart:()=>ge,toJavascript:()=>he,toLua:()=>_e,toPhp:()=>ve,toPython:()=>ye});var r={};c.r(r),c.d(r,{BLOCK_NAME:()=>Ce,blockDefinition:()=>Ae,installBlock:()=>je,toDart:()=>w,toJavascript:()=>Te,toLua:()=>Ee,toPhp:()=>De,toPython:()=>Oe});var i=c(370),a=c(462);let o=`#ffffff.#cccccc.#c0c0c0.#999999.#666666.#333333.#000000.#ffcccc.#ff6666.#ff0000.#cc0000.#990000.#660000.#330000.#ffcc99.#ff9966.#ff9900.#ff6600.#cc6600.#993300.#663300.#ffff99.#ffff66.#ffcc66.#ffcc33.#cc9933.#996633.#663333.#ffffcc.#ffff33.#ffff00.#ffcc00.#999900.#666600.#333300.#99ff99.#66ff99.#33ff33.#33cc00.#009900.#006600.#003300.#99ffff.#33ffff.#66cccc.#00cccc.#339999.#336666.#003333.#ccffff.#66ffff.#33ccff.#3366ff.#3333ff.#000099.#000066.#ccccff.#9999ff.#6666cc.#6633ff.#6600cc.#333399.#330099.#ffccff.#ff99ff.#cc66cc.#cc33cc.#993399.#663366.#330033`.split(`.`);class s extends a.FieldGridDropdown{constructor(e,t,n){super(u(n?.colourOptions??o),t,Object.assign(Object.assign({},n),{columns:n?.columns??7})),this.isDirty_=!1,e!==i.Field.SKIP_SETUP&&this.setValue(e)}trimOptions(e){return{options:e}}configure_(e){super.configure_(e),e.colourOptions&&this.setColours(e.colourOptions,e.colourTitles)}initView(){let e=this.getConstants();if(!e)throw Error(`Constants not found`);this.size_=new i.utils.Size(e.FIELD_COLOUR_DEFAULT_WIDTH,e.FIELD_COLOUR_DEFAULT_HEIGHT),this.createBorderRect_(),this.getBorderRect().style.fillOpacity=`1`,this.getBorderRect().setAttribute(`stroke`,`#fff`),this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot())}showEditor_(e){super.showEditor_(e),i.DropDownDiv.getContentDiv().classList.add(`blocklyFieldColour`),i.DropDownDiv.repositionForWindowResize()}isFullBlockField(){if(!this.getSourceBlock())throw new i.UnattachedFieldError;let e=this.getConstants();return this.blockIsSimpleReporter()&&!!e?.FIELD_COLOUR_FULL_BLOCK}blockIsSimpleReporter(){let e=this.getSourceBlock();if(!e)throw new i.UnattachedFieldError;if(!e.outputConnection)return!1;for(let t of e.inputList)if(t.connection||t.fieldRow.length>1)return!1;return!0}applyColour(){let e=this.getSourceBlock();if(!e)throw new i.UnattachedFieldError;if(!this.fieldGroup_)return;let t=this.borderRect_;if(!t)throw Error(`The border rect has not been initialized`);this.isFullBlockField()?(t.style.display=`none`,e.pathObject.svgPath.setAttribute(`fill`,this.getValue()),e.pathObject.svgPath.setAttribute(`stroke`,`#fff`)):(t.style.display=`block`,t.style.fill=this.getValue())}getSize(){var e;return(e=this.getConstants())!=null&&e.FIELD_COLOUR_FULL_BLOCK&&(this.render_(),this.isDirty_=!1),super.getSize()}render_(){this.updateSize_();let e=this.getSourceBlock();if(!e)throw new i.UnattachedFieldError;e.applyColour()}updateSize_(e){let t=this.getConstants();if(!t)return;let n,r;this.isFullBlockField()?(n=2*(e??0),r=t.FIELD_TEXT_HEIGHT):(n=t.FIELD_COLOUR_DEFAULT_WIDTH,r=t.FIELD_COLOUR_DEFAULT_HEIGHT),this.size_.height=r,this.size_.width=n,this.positionBorderRect_()}doClassValidation_(e){return typeof e==`string`?i.utils.colour.parse(e):null}getText(){let e=this.value_;return/^#(.)\1(.)\2(.)\3$/.test(e)&&(e=`#`+e[1]+e[3]+e[5]),e}setColours(e,t){let n=u(e,t);return this.setOptions(n),this}static fromJson(e){return new this(e.colour,void 0,e)}}function u(e,t){return e.map((e,n)=>{let r=document.createElement(`div`);return r.className=`blocklyColourSwatch`,r.style.backgroundColor=e,t&&n<t.length&&(r.title=t[n]),[r,e]})}function d(){i.fieldRegistry.register(`field_colour`,s)}s.prototype.DEFAULT_VALUE=`#ffffff`,i.Css.register(`
|
|
1050
|
+
.blocklyFieldColour .blocklyFieldGridItemSelected,
|
|
1051
|
+
.blocklyFieldGridItemSelected:hover {
|
|
1052
|
+
border-color: #eee !important;
|
|
1053
|
+
outline: 1px solid #333;
|
|
1054
|
+
position: relative;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
.blocklyColourSwatch {
|
|
1058
|
+
width: 20px;
|
|
1059
|
+
height: 20px;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
.blocklyGridContainer {
|
|
1063
|
+
padding: 0px;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
.blocklyFieldColour .blocklyFieldGrid {
|
|
1067
|
+
grid-gap: 0px;
|
|
1068
|
+
row-gap: 4px;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
.blocklyFieldColour .blocklyFieldGrid .blocklyGridItem {
|
|
1072
|
+
border-radius: 0;
|
|
1073
|
+
padding: 0;
|
|
1074
|
+
border: 0.5px solid #888;
|
|
1075
|
+
cursor: pointer;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
.blocklyFieldColour .blocklyFieldGrid .blocklyFieldGridItem {
|
|
1079
|
+
border: 0.5px solid #888;
|
|
1080
|
+
padding: 0;
|
|
1081
|
+
margin: 0;
|
|
1082
|
+
border-radius: 0;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
.blocklyFieldColour .blocklyFieldGrid .blocklyFieldGridItem:focus {
|
|
1086
|
+
border-color: #eee;
|
|
1087
|
+
box-shadow: 2px 2px 7px 2px rgba(0, 0, 0, 0.3);
|
|
1088
|
+
position: relative;
|
|
1089
|
+
border-radius: 0;
|
|
1090
|
+
outline: none;
|
|
1091
|
+
}
|
|
1092
|
+
`);var f=c(127),p=c(379),m=c(157),h=c(537),g=c(557);let _=`colour_picker`,v={type:_,message0:`%1`,args0:[{type:`field_colour`,name:`COLOUR`,colour:`#ff0000`}],output:`Colour`,helpUrl:`%{BKY_COLOUR_PICKER_HELPURL}`,style:`colour_blocks`,tooltip:`%{BKY_COLOUR_PICKER_TOOLTIP}`,extensions:[`parent_tooltip_when_inline`]};function y(e,t){return[t.quote_(e.getFieldValue(`COLOUR`)),f.Order.ATOMIC]}function b(e,t){return[t.quote_(e.getFieldValue(`COLOUR`)),p.Order.ATOMIC]}function ee(e,t){return[t.quote_(e.getFieldValue(`COLOUR`)),m.Order.ATOMIC]}function te(e,t){return[t.quote_(e.getFieldValue(`COLOUR`)),h.Order.ATOMIC]}function ne(e,t){return[t.quote_(e.getFieldValue(`COLOUR`)),g.Order.ATOMIC]}let re=i.common.createBlockDefinitionsFromJsonArray([v]),ie=re[_];function ae(e={}){d(),i.common.defineBlocks(re),e.javascript&&(e.javascript.forBlock[_]=y),e.dart&&(e.dart.forBlock[_]=b),e.lua&&(e.lua.forBlock[_]=ee),e.php&&(e.php.forBlock[_]=te),e.python&&(e.python.forBlock[_]=ne)}let x=`colour_random`,oe={type:x,message0:`%{BKY_COLOUR_RANDOM_TITLE}`,output:`Colour`,helpUrl:`%{BKY_COLOUR_RANDOM_HELPURL}`,style:`colour_blocks`,tooltip:`%{BKY_COLOUR_RANDOM_TOOLTIP}`};function se(e,t){return[t.provideFunction_(`colourRandom`,`\nfunction ${t.FUNCTION_NAME_PLACEHOLDER_}() {\n var num = Math.floor(Math.random() * 0x1000000);\n return '#' + ('00000' + num.toString(16)).substr(-6);\n}\n`)+`()`,f.Order.FUNCTION_CALL]}function S(e,t){return t.definitions_.import_dart_math=`import 'dart:math' as Math;`,[t.provideFunction_(`colour_random`,`\nString ${t.FUNCTION_NAME_PLACEHOLDER_}() {\n String hex = '0123456789abcdef';\n var rnd = new Math.Random();\n return '#\${hex[rnd.nextInt(16)]}\${hex[rnd.nextInt(16)]}'\n '\${hex[rnd.nextInt(16)]}\${hex[rnd.nextInt(16)]}'\n '\${hex[rnd.nextInt(16)]}\${hex[rnd.nextInt(16)]}';\n}\n`)+`()`,p.Order.UNARY_POSTFIX]}function ce(e,t){return[`string.format("#%06x", math.random(0, 2^24 - 1))`,m.Order.HIGH]}function le(e,t){return[t.provideFunction_(`colour_random`,`\nfunction ${t.FUNCTION_NAME_PLACEHOLDER_}() {\n return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);\n}\n`)+`()`,h.Order.FUNCTION_CALL]}function ue(e,t){return t.definitions_.import_random=`import random`,[`'#%06x' % random.randint(0, 2**24 - 1)`,g.Order.FUNCTION_CALL]}let C=i.common.createBlockDefinitionsFromJsonArray([oe]),de=C[x];function fe(e={}){d(),i.common.defineBlocks(C),e.javascript&&(e.javascript.forBlock[x]=se),e.dart&&(e.dart.forBlock[x]=S),e.lua&&(e.lua.forBlock[x]=ce),e.php&&(e.php.forBlock[x]=le),e.python&&(e.python.forBlock[x]=ue)}let pe=`colour_rgb`,me={type:pe,message0:`%{BKY_COLOUR_RGB_TITLE} %{BKY_COLOUR_RGB_RED} %1 %{BKY_COLOUR_RGB_GREEN} %2 %{BKY_COLOUR_RGB_BLUE} %3`,args0:[{type:`input_value`,name:`RED`,check:`Number`,align:`RIGHT`},{type:`input_value`,name:`GREEN`,check:`Number`,align:`RIGHT`},{type:`input_value`,name:`BLUE`,check:`Number`,align:`RIGHT`}],output:`Colour`,helpUrl:`%{BKY_COLOUR_RGB_HELPURL}`,style:`colour_blocks`,tooltip:`%{BKY_COLOUR_RGB_TOOLTIP}`};function he(e,t){let n=t.valueToCode(e,`RED`,f.Order.NONE)||0,r=t.valueToCode(e,`GREEN`,f.Order.NONE)||0,i=t.valueToCode(e,`BLUE`,f.Order.NONE)||0;return[`${t.provideFunction_(`colourRgb`,`\nfunction ${t.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) {\n r = Math.max(Math.min(Number(r), 100), 0) * 2.55;\n g = Math.max(Math.min(Number(g), 100), 0) * 2.55;\n b = Math.max(Math.min(Number(b), 100), 0) * 2.55;\n r = ('0' + (Math.round(r) || 0).toString(16)).slice(-2);\n g = ('0' + (Math.round(g) || 0).toString(16)).slice(-2);\n b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2);\n return '#' + r + g + b;\n}\n`)}(${n}, ${r}, ${i})`,f.Order.FUNCTION_CALL]}function ge(e,t){let n=t.valueToCode(e,`RED`,p.Order.NONE)||0,r=t.valueToCode(e,`GREEN`,p.Order.NONE)||0,i=t.valueToCode(e,`BLUE`,p.Order.NONE)||0;return t.definitions_.import_dart_math=`import 'dart:math' as Math;`,[`${t.provideFunction_(`colour_rgb`,`\nString ${t.FUNCTION_NAME_PLACEHOLDER_}(num r, num g, num b) {\n num rn = (Math.max(Math.min(r, 100), 0) * 2.55).round();\n String rs = rn.toInt().toRadixString(16);\n rs = '0$rs';\n rs = rs.substring(rs.length - 2);\n num gn = (Math.max(Math.min(g, 100), 0) * 2.55).round();\n String gs = gn.toInt().toRadixString(16);\n gs = '0$gs';\n gs = gs.substring(gs.length - 2);\n num bn = (Math.max(Math.min(b, 100), 0) * 2.55).round();\n String bs = bn.toInt().toRadixString(16);\n bs = '0$bs';\n bs = bs.substring(bs.length - 2);\n return '#$rs$gs$bs';\n}\n`)}(${n}, ${r}, ${i})`,p.Order.UNARY_POSTFIX]}function _e(e,t){return[`${t.provideFunction_(`colour_rgb`,`\nfunction ${t.FUNCTION_NAME_PLACEHOLDER_}(r, g, b)\n r = math.floor(math.min(100, math.max(0, r)) * 2.55 + .5)\n g = math.floor(math.min(100, math.max(0, g)) * 2.55 + .5)\n b = math.floor(math.min(100, math.max(0, b)) * 2.55 + .5)\n return string.format("#%02x%02x%02x", r, g, b)\nend\n`)}(${t.valueToCode(e,`RED`,m.Order.NONE)||0}, ${t.valueToCode(e,`GREEN`,m.Order.NONE)||0}, ${t.valueToCode(e,`BLUE`,m.Order.NONE)||0})`,m.Order.HIGH]}function ve(e,t){let n=t.valueToCode(e,`RED`,h.Order.NONE)||0,r=t.valueToCode(e,`GREEN`,h.Order.NONE)||0,i=t.valueToCode(e,`BLUE`,h.Order.NONE)||0;return[`${t.provideFunction_(`colour_rgb`,`\nfunction ${t.FUNCTION_NAME_PLACEHOLDER_}($r, $g, $b) {\n $r = round(max(min($r, 100), 0) * 2.55);\n $g = round(max(min($g, 100), 0) * 2.55);\n $b = round(max(min($b, 100), 0) * 2.55);\n $hex = '#';\n $hex .= str_pad(dechex($r), 2, '0', STR_PAD_LEFT);\n $hex .= str_pad(dechex($g), 2, '0', STR_PAD_LEFT);\n $hex .= str_pad(dechex($b), 2, '0', STR_PAD_LEFT);\n return $hex;\n}\n`)}(${n}, ${r}, ${i})`,h.Order.FUNCTION_CALL]}function ye(e,t){return[t.provideFunction_(`colour_rgb`,`\ndef ${t.FUNCTION_NAME_PLACEHOLDER_}(r, g, b):\n r = round(min(100, max(0, r)) * 2.55)\n g = round(min(100, max(0, g)) * 2.55)\n b = round(min(100, max(0, b)) * 2.55)\n return '#%02x%02x%02x' % (r, g, b)\n`)+`(`+(t.valueToCode(e,`RED`,g.Order.NONE)||0)+`, `+(t.valueToCode(e,`GREEN`,g.Order.NONE)||0)+`, `+(t.valueToCode(e,`BLUE`,g.Order.NONE)||0)+`)`,g.Order.FUNCTION_CALL]}let be=i.common.createBlockDefinitionsFromJsonArray([me]),xe=be[pe];function Se(e={}){d(),i.common.defineBlocks(be),e.javascript&&(e.javascript.forBlock[pe]=he),e.dart&&(e.dart.forBlock[pe]=ge,e.dart.addReservedWords(`Math`)),e.lua&&(e.lua.forBlock[pe]=_e),e.php&&(e.php.forBlock[pe]=ve),e.python&&(e.python.forBlock[pe]=ye)}let Ce=`colour_blend`,we={type:Ce,message0:`%{BKY_COLOUR_BLEND_TITLE} %{BKY_COLOUR_BLEND_COLOUR1} %1 %{BKY_COLOUR_BLEND_COLOUR2} %2 %{BKY_COLOUR_BLEND_RATIO} %3`,args0:[{type:`input_value`,name:`COLOUR1`,check:`Colour`,align:`RIGHT`},{type:`input_value`,name:`COLOUR2`,check:`Colour`,align:`RIGHT`},{type:`input_value`,name:`RATIO`,check:`Number`,align:`RIGHT`}],output:`Colour`,helpUrl:`%{BKY_COLOUR_BLEND_HELPURL}`,style:`colour_blocks`,tooltip:`%{BKY_COLOUR_BLEND_TOOLTIP}`};function Te(e,t){let n=t.valueToCode(e,`COLOUR1`,f.Order.NONE)||`'#000000'`,r=t.valueToCode(e,`COLOUR2`,f.Order.NONE)||`'#000000'`,i=t.valueToCode(e,`RATIO`,f.Order.NONE)||.5;return[`${t.provideFunction_(`colourBlend`,`\nfunction ${t.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) {\n ratio = Math.max(Math.min(Number(ratio), 1), 0);\n var r1 = parseInt(c1.substring(1, 3), 16);\n var g1 = parseInt(c1.substring(3, 5), 16);\n var b1 = parseInt(c1.substring(5, 7), 16);\n var r2 = parseInt(c2.substring(1, 3), 16);\n var g2 = parseInt(c2.substring(3, 5), 16);\n var b2 = parseInt(c2.substring(5, 7), 16);\n var r = Math.round(r1 * (1 - ratio) + r2 * ratio);\n var g = Math.round(g1 * (1 - ratio) + g2 * ratio);\n var b = Math.round(b1 * (1 - ratio) + b2 * ratio);\n r = ('0' + (r || 0).toString(16)).slice(-2);\n g = ('0' + (g || 0).toString(16)).slice(-2);\n b = ('0' + (b || 0).toString(16)).slice(-2);\n return '#' + r + g + b;\n}\n`)}(${n}, ${r}, ${i})`,f.Order.FUNCTION_CALL]}function w(e,t){let n=t.valueToCode(e,`COLOUR1`,p.Order.NONE)||`'#000000'`,r=t.valueToCode(e,`COLOUR2`,p.Order.NONE)||`'#000000'`,i=t.valueToCode(e,`RATIO`,p.Order.NONE)||.5;return t.definitions_.import_dart_math=`import 'dart:math' as Math;`,[`${t.provideFunction_(`colour_blend`,`\nString ${t.FUNCTION_NAME_PLACEHOLDER_}(String c1, String c2, num ratio) {\n ratio = Math.max(Math.min(ratio, 1), 0);\n int r1 = int.parse('0x\${c1.substring(1, 3)}');\n int g1 = int.parse('0x\${c1.substring(3, 5)}');\n int b1 = int.parse('0x\${c1.substring(5, 7)}');\n int r2 = int.parse('0x\${c2.substring(1, 3)}');\n int g2 = int.parse('0x\${c2.substring(3, 5)}');\n int b2 = int.parse('0x\${c2.substring(5, 7)}');\n num rn = (r1 * (1 - ratio) + r2 * ratio).round();\n String rs = rn.toInt().toRadixString(16);\n num gn = (g1 * (1 - ratio) + g2 * ratio).round();\n String gs = gn.toInt().toRadixString(16);\n num bn = (b1 * (1 - ratio) + b2 * ratio).round();\n String bs = bn.toInt().toRadixString(16);\n rs = '0$rs';\n rs = rs.substring(rs.length - 2);\n gs = '0$gs';\n gs = gs.substring(gs.length - 2);\n bs = '0$bs';\n bs = bs.substring(bs.length - 2);\n return '#$rs$gs$bs';\n}\n`)}(${n}, ${r}, ${i})`,p.Order.UNARY_POSTFIX]}function Ee(e,t){return[`${t.provideFunction_(`colour_blend`,`\nfunction ${t.FUNCTION_NAME_PLACEHOLDER_}(colour1, colour2, ratio)\n local r1 = tonumber(string.sub(colour1, 2, 3), 16)\n local r2 = tonumber(string.sub(colour2, 2, 3), 16)\n local g1 = tonumber(string.sub(colour1, 4, 5), 16)\n local g2 = tonumber(string.sub(colour2, 4, 5), 16)\n local b1 = tonumber(string.sub(colour1, 6, 7), 16)\n local b2 = tonumber(string.sub(colour2, 6, 7), 16)\n local ratio = math.min(1, math.max(0, ratio))\n local r = math.floor(r1 * (1 - ratio) + r2 * ratio + .5)\n local g = math.floor(g1 * (1 - ratio) + g2 * ratio + .5)\n local b = math.floor(b1 * (1 - ratio) + b2 * ratio + .5)\n return string.format("#%02x%02x%02x", r, g, b)\nend\n`)}(${t.valueToCode(e,`COLOUR1`,m.Order.NONE)||`'#000000'`}, ${t.valueToCode(e,`COLOUR2`,m.Order.NONE)||`'#000000'`}, ${t.valueToCode(e,`RATIO`,m.Order.NONE)||0})`,m.Order.HIGH]}function De(e,t){let n=t.valueToCode(e,`COLOUR1`,h.Order.NONE)||`'#000000'`,r=t.valueToCode(e,`COLOUR2`,h.Order.NONE)||`'#000000'`,i=t.valueToCode(e,`RATIO`,h.Order.NONE)||.5;return[`${t.provideFunction_(`colour_blend`,`\nfunction ${t.FUNCTION_NAME_PLACEHOLDER_}($c1, $c2, $ratio) {\n $ratio = max(min($ratio, 1), 0);\n $r1 = hexdec(substr($c1, 1, 2));\n $g1 = hexdec(substr($c1, 3, 2));\n $b1 = hexdec(substr($c1, 5, 2));\n $r2 = hexdec(substr($c2, 1, 2));\n $g2 = hexdec(substr($c2, 3, 2));\n $b2 = hexdec(substr($c2, 5, 2));\n $r = round($r1 * (1 - $ratio) + $r2 * $ratio);\n $g = round($g1 * (1 - $ratio) + $g2 * $ratio);\n $b = round($b1 * (1 - $ratio) + $b2 * $ratio);\n $hex = '#';\n $hex .= str_pad(dechex($r), 2, '0', STR_PAD_LEFT);\n $hex .= str_pad(dechex($g), 2, '0', STR_PAD_LEFT);\n $hex .= str_pad(dechex($b), 2, '0', STR_PAD_LEFT);\n return $hex;\n}\n`)}(${n}, ${r}, ${i})`,h.Order.FUNCTION_CALL]}function Oe(e,t){return[`${t.provideFunction_(`colour_blend`,`\ndef ${t.FUNCTION_NAME_PLACEHOLDER_}(colour1, colour2, ratio):\n r1, r2 = int(colour1[1:3], 16), int(colour2[1:3], 16)\n g1, g2 = int(colour1[3:5], 16), int(colour2[3:5], 16)\n b1, b2 = int(colour1[5:7], 16), int(colour2[5:7], 16)\n ratio = min(1, max(0, ratio))\n r = round(r1 * (1 - ratio) + r2 * ratio)\n g = round(g1 * (1 - ratio) + g2 * ratio)\n b = round(b1 * (1 - ratio) + b2 * ratio)\n return '#%02x%02x%02x' % (r, g, b)\n`)}(${t.valueToCode(e,`COLOUR1`,g.Order.NONE)||`'#000000'`}, ${t.valueToCode(e,`COLOUR2`,g.Order.NONE)||`'#000000'`}, ${t.valueToCode(e,`RATIO`,g.Order.NONE)||0})`,g.Order.FUNCTION_CALL]}let ke=i.common.createBlockDefinitionsFromJsonArray([we]),Ae=ke[Ce];function je(e={}){d(),i.common.defineBlocks(ke),e.javascript&&(e.javascript.forBlock[Ce]=Te),e.dart&&(e.dart.forBlock[Ce]=w,e.dart.addReservedWords(`Math`)),e.lua&&(e.lua.forBlock[Ce]=Ee),e.php&&(e.php.forBlock[Ce]=De),e.python&&(e.python.forBlock[Ce]=Oe)}function Me(e={}){ae(e),Se(e),fe(e),je(e)}})(),l})())}));function I(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function Bl(e,t){I(e,t),t.add(e)}function L(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}const Vl=62n,R=new globalThis.TextEncoder,Hl=new globalThis.TextDecoder;function z(e,t){if(typeof e!=`string`)throw TypeError(`The \`${t}\` parameter must be a string, got \`${e}\` (${typeof e}).`)}function Ul(e){if(typeof e!=`string`)throw TypeError(`The alphabet must be a string, got \`${e}\` (${typeof e}).`);if(e.length!==62)throw TypeError(`The alphabet must be exactly 62 characters long, got ${e.length}.`);let t=new Set(e);if(t.size!==62)throw TypeError(`The alphabet must contain 62 unique characters, got ${t.size}.`)}var Wl=new WeakSet,Gl=class{constructor(e={}){Bl(this,Wl);let t=e.alphabet??`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`;Ul(t),this.alphabet=[...t],this.indices=new Map(this.alphabet.map((e,t)=>[e,t]))}encodeString(e){return z(e,`string`),this.encodeBytes(R.encode(e))}decodeString(e){return z(e,`encodedString`),Hl.decode(this.decodeBytes(e))}encodeBytes(e){if(!(e instanceof Uint8Array))throw TypeError("The `bytes` parameter must be an instance of Uint8Array.");if(e.length===0)return``;let t=1n;for(let n of e)t=t<<8n|BigInt(n);return this.encodeBigInt(t)}decodeBytes(e){if(z(e,`encodedString`),e.length===0)return new Uint8Array;let t=this.decodeBigInt(e),n=[];for(;t>0n;)n.push(Number(t&255n)),t>>=8n;return Uint8Array.from(n.reverse().slice(1))}encodeInteger(e){if(!Number.isInteger(e))throw TypeError(`Expected an integer, got \`${e}\` (${typeof e}).`);if(e<0)throw TypeError(`The integer must be non-negative.`);if(e===0)return this.alphabet[0];let t=``;for(;e>0;)t=this.alphabet[e%62]+t,e=Math.floor(e/62);return t}decodeInteger(e){z(e,`encodedString`);let t=0;for(let n of e)t=t*62+L(Wl,this,Kl).call(this,n);return t}encodeBigInt(e){if(typeof e!=`bigint`)throw TypeError(`Expected a bigint, got \`${e}\` (${typeof e}).`);if(e<0)throw TypeError(`The bigint must be non-negative.`);if(e===0n)return this.alphabet[0];let t=``;for(;e>0n;)t=this.alphabet[Number(e%Vl)]+t,e/=Vl;return t}decodeBigInt(e){z(e,`encodedString`);let t=0n;for(let n of e)t=t*Vl+BigInt(L(Wl,this,Kl).call(this,n));return t}};function Kl(e){let t=this.indices.get(e);if(t===void 0)throw TypeError(`Unexpected character for Base62 encoding: \`${e}\`.`);return t}const ql=new Gl,Jl=e=>ql.encodeString(e);var Yl=n(((e,t)=>{(function(n,r){if(typeof e==`object`&&typeof t==`object`)t.exports=r(b());else if(typeof define==`function`&&define.amd)define([`blockly/core`],r);else{var i=r(typeof e==`object`?b():n.Blockly);for(var a in i)(typeof e==`object`?e:n)[a]=i[a]}})(e,e=>(()=>{var t={370:t=>{t.exports=e}},n={};function r(e){var i=n[e];if(i!==void 0)return i.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};r.r(i),r.d(i,{CrossTabCopyPaste:()=>l});var a,o=r(370);function s(e){return!!(o.isCopyable(e)&&o.isDeletable(e)&&o.isDraggable(e))&&(e.isCopyable?e.isCopyable():e instanceof o.BlockSvg||e instanceof o.comments.RenderedWorkspaceComment?e.isOwnDeletable()&&e.isOwnMovable():e.isDeletable()&&e.isMovable())}function c(e){return s(e)&&o.isDeletable(e)&&e.isDeletable()}(function(e){e.ENABLED=`enabled`,e.DISABLED=`disabled`,e.HIDDEN=`hidden`})(a||(a={}));class l{constructor(){this.localStorageKey=`blocklyStash`}init({contextMenu:e=!0,shortcut:t=!0}={contextMenu:!0,shortcut:!0},n,r){r&&(this.localStorageKey=r),e&&(this.blockCopyToStorageContextMenu(),this.blockPasteFromStorageContextMenu(n)),t&&(o.ShortcutRegistry.registry.unregister(o.ShortcutItems.names.COPY),o.ShortcutRegistry.registry.unregister(o.ShortcutItems.names.CUT),o.ShortcutRegistry.registry.unregister(o.ShortcutItems.names.PASTE),this.blockCopyToStorageShortcut(),this.blockCutToStorageShortcut(),this.blockPasteFromStorageShortcut(n))}getCopyData(){let e=localStorage.getItem(this.localStorageKey);if(e)return JSON.parse(e)}copyPrecondition(e,t){let n=e.focusedNode;if(!n||!o.isCopyable(n)||(t||(t=n.workspace),!(t instanceof o.WorkspaceSvg)))return a.HIDDEN;let r=t.isFlyout?t.targetWorkspace:t;return n&&r&&!r.isDragging()&&!o.getFocusManager().ephemeralFocusTaken()&&s(n)?a.ENABLED:a.DISABLED}copyCallback(e,t){let n=e.focusedNode;if(!n||!o.isCopyable(n)||!s(n)||!(t instanceof o.WorkspaceSvg))return!1;let r=t.isFlyout?t.targetWorkspace:t;if(!r)return!1;n.workspace.isFlyout||r.hideChaff();let i=n.toCopyData();return!!i&&(localStorage.setItem(this.localStorageKey,JSON.stringify(i)),!0)}pastePrecondition(e){let t=this.getCopyData();return t?`typeCounts`in t&&!e?.isCapacityAvailable(t.typeCounts)||!e||e.isReadOnly()||e.isDragging()||o.getFocusManager().ephemeralFocusTaken()?a.DISABLED:a.ENABLED:a.DISABLED}getContextMenuText(e){return e.indexOf(`)`)===e.length-1&&(e=e.split(` (`)[0]),e}blockCopyToStorageContextMenu(){o.ContextMenuRegistry.registry.register({displayText:()=>o.Msg.CROSS_TAB_COPY?o.Msg.CROSS_TAB_COPY:this.getContextMenuText(o.Msg.COPY_SHORTCUT),preconditionFn:e=>this.copyPrecondition(e),callback:e=>{let t=e.focusedNode;if(!t||!o.isCopyable(t))return!1;let n=t.workspace;return this.copyCallback(e,n)},id:`blockCopyToStorage`,weight:0})}blockPasteFromStorageContextMenu(e){o.ContextMenuRegistry.registry.register({displayText:()=>o.Msg.CROSS_TAB_PASTE?o.Msg.CROSS_TAB_PASTE:this.getContextMenuText(o.Msg.PASTE_SHORTCUT),preconditionFn:e=>{if(!(e.focusedNode instanceof o.WorkspaceSvg)||e.focusedNode.isFlyout)return a.HIDDEN;let t=e.focusedNode;return this.pastePrecondition(t)},callback:(t,n,r,i)=>{let a=this.getCopyData();if(!a)return!1;let s=t.focusedNode;if(!(s instanceof o.WorkspaceSvg))return!1;let c=o.utils.svgMath.screenToWsCoordinates(s,i);try{return!!o.clipboard.paste(a,s,c)}catch(t){if(!(t instanceof TypeError&&e))throw t;e()}},id:`blockPasteFromStorage`,weight:0})}blockCopyToStorageShortcut(){let e=o.ShortcutRegistry.registry.createSerializedKey(o.utils.KeyCodes.C,[o.utils.KeyCodes.CTRL]),t=o.ShortcutRegistry.registry.createSerializedKey(o.utils.KeyCodes.C,[o.utils.KeyCodes.META]),n={name:o.ShortcutItems.names.COPY,keyCodes:[e,t],preconditionFn:(e,t)=>this.copyPrecondition(t,e)===a.ENABLED,callback:(e,t,n,r)=>(t.preventDefault(),this.copyCallback(r,e))};o.ShortcutRegistry.registry.register(n)}blockCutToStorageShortcut(){let e=o.ShortcutRegistry.registry.createSerializedKey(o.utils.KeyCodes.X,[o.utils.KeyCodes.CTRL]),t=o.ShortcutRegistry.registry.createSerializedKey(o.utils.KeyCodes.X,[o.utils.KeyCodes.META]),n={name:o.ShortcutItems.names.CUT,keyCodes:[e,t],preconditionFn:(e,t)=>{let n=t.focusedNode;return!!n&&!e.isReadOnly()&&!e.isDragging()&&!o.getFocusManager().ephemeralFocusTaken()&&c(n)},callback:(e,t,n,r)=>{t.preventDefault();let i=r.focusedNode;if(!i||!c(i)||!o.isCopyable(i))return!1;let a=i.toCopyData();if(!a)return!1;if(i instanceof o.BlockSvg)i.checkAndDelete();else if(o.isDeletable(i)){let e=o.Events.getGroup();o.Events.setGroup(!0),i.dispose(),o.Events.setGroup(e)}return localStorage.setItem(this.localStorageKey,JSON.stringify(a)),!0}};o.ShortcutRegistry.registry.register(n)}blockPasteFromStorageShortcut(e){let t=o.ShortcutRegistry.registry.createSerializedKey(o.utils.KeyCodes.V,[o.utils.KeyCodes.CTRL]),n=o.ShortcutRegistry.registry.createSerializedKey(o.utils.KeyCodes.V,[o.utils.KeyCodes.META]),r={name:o.ShortcutItems.names.PASTE,keyCodes:[t,n],preconditionFn:e=>{let t=e.isFlyout?e.targetWorkspace:e;return!!t&&this.pastePrecondition(t)===a.ENABLED},callback:(t,n)=>{n.preventDefault();let r=this.getCopyData();if(!r)return!1;let i=t.isFlyout?t.targetWorkspace:t;if(!i)return!1;try{if(n instanceof PointerEvent){let e=o.utils.svgMath.screenToWsCoordinates(i,new o.utils.Coordinate(n.clientX,n.clientY));return!!o.clipboard.paste(r,i,e)}return!!o.clipboard.paste(r,i)}catch(t){if(!(t instanceof TypeError&&e))throw t;e()}return!0}};o.ShortcutRegistry.registry.register(r)}}return i})())}));function Xl(e,t){return o()?(d(e,t),!0):!1}const Zl=typeof window<`u`&&typeof document<`u`;typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;const Ql=Zl?window:void 0;Zl&&window.document,Zl&&window.navigator,Zl&&window.location;function $l(e){let t=_(e);return t?.$el??t}function eu(){let e=h(!1),t=a();return t&&u(()=>{e.value=!0},t),e}function tu(e){let t=eu();return r(()=>(t.value,!!e()))}function nu(e,t,n={}){let{window:i=Ql,...a}=n,o,s=tu(()=>i&&`ResizeObserver`in i),c=()=>{o&&(o.disconnect(),o=void 0)},l=y(r(()=>{let t=_(e);return Array.isArray(t)?t.map(e=>$l(e)):[$l(t)]}),e=>{if(c(),s.value&&i){o=new ResizeObserver(t);for(let t of e)t&&o.observe(t,a)}},{immediate:!0,flush:`post`}),u=()=>{c(),l()};return Xl(u),{isSupported:s,stop:u}}var ru=Object.defineProperty,iu=Object.getOwnPropertySymbols,au=Object.prototype.hasOwnProperty,ou=Object.prototype.propertyIsEnumerable,B=(e,t,n)=>t in e?ru(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,su=(e,t)=>{for(var n in t||(t={}))au.call(t,n)&&B(e,n,t[n]);if(iu)for(var n of iu(t))ou.call(t,n)&&B(e,n,t[n]);return e},cu=(e,t)=>{var n={};for(var r in e)au.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&iu)for(var r of iu(e))t.indexOf(r)<0&&ou.call(e,r)&&(n[r]=e[r]);return n};const lu=`[vue-draggable-plus]: `;function uu(e){console.warn(lu+e)}function du(e){console.error(lu+e)}function fu(e,t,n){return n>=0&&n<e.length&&e.splice(n,0,e.splice(t,1)[0]),e}function pu(e){return e.replace(/-(\w)/g,(e,t)=>t?t.toUpperCase():``)}function mu(e){return Object.keys(e).reduce((t,n)=>(e[n]!==void 0&&(t[pu(n)]=e[n]),t),{})}function hu(e,t){return Array.isArray(e)&&e.splice(t,1),e}function gu(e,t,n){return Array.isArray(e)&&e.splice(t,0,n),e}function _u(e){return e===void 0}function vu(e){return typeof e==`string`}function yu(e,t,n){let r=e.children[n];e.insertBefore(t,r)}function bu(e){e.parentNode&&e.parentNode.removeChild(e)}function xu(e,t=document){let n=null;return n=typeof t?.querySelector==`function`?(t?.querySelector)?.call(t,e):document.querySelector(e),n||uu(`Element not found: ${e}`),n}function Su(e,t,n=null){return function(...r){return e.apply(n,r),t.apply(n,r)}}function Cu(e,t){let n=su({},e);return Object.keys(t).forEach(r=>{n[r]?n[r]=Su(e[r],t[r]):n[r]=t[r]}),n}function wu(e){return e instanceof HTMLElement}function Tu(e,t){Object.keys(e).forEach(n=>{t(n,e[n])})}function Eu(e){return e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97)}const Du=Object.assign;
|
|
1093
|
+
/**!
|
|
1094
|
+
* Sortable 1.15.2
|
|
1095
|
+
* @author RubaXa <trash@rubaxa.org>
|
|
1096
|
+
* @author owenm <owen23355@gmail.com>
|
|
1097
|
+
* @license MIT
|
|
1098
|
+
*/
|
|
1099
|
+
function Ou(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ku(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ou(Object(n),!0).forEach(function(t){ju(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ou(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Au(e){"@babel/helpers - typeof";return Au=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Au(e)}function ju(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Mu(){return Mu=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Mu.apply(this,arguments)}function Nu(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function Pu(e,t){if(e==null)return{};var n=Nu(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}var Fu=`1.15.2`;function Iu(e){if(typeof window<`u`&&window.navigator)return!!navigator.userAgent.match(e)}var Lu=Iu(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Ru=Iu(/Edge/i),zu=Iu(/firefox/i),Bu=Iu(/safari/i)&&!Iu(/chrome/i)&&!Iu(/android/i),Vu=Iu(/iP(ad|od|hone)/i),Hu=Iu(/chrome/i)&&Iu(/android/i),Uu={capture:!1,passive:!1};function Wu(e,t,n){e.addEventListener(t,n,!Lu&&Uu)}function V(e,t,n){e.removeEventListener(t,n,!Lu&&Uu)}function Gu(e,t){if(t){if(t[0]===`>`&&(t=t.substring(1)),e)try{if(e.matches)return e.matches(t);if(e.msMatchesSelector)return e.msMatchesSelector(t);if(e.webkitMatchesSelector)return e.webkitMatchesSelector(t)}catch{return!1}return!1}}function Ku(e){return e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode}function qu(e,t,n,r){if(e){n=n||document;do{if(t!=null&&(t[0]===`>`?e.parentNode===n&&Gu(e,t):Gu(e,t))||r&&e===n)return e;if(e===n)break}while(e=Ku(e))}return null}var Ju=/\s+/g;function Yu(e,t,n){e&&t&&(e.classList?e.classList[n?`add`:`remove`](t):e.className=((` `+e.className+` `).replace(Ju,` `).replace(` `+t+` `,` `)+(n?` `+t:``)).replace(Ju,` `))}function H(e,t,n){var r=e&&e.style;if(r){if(n===void 0)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(e,``):e.currentStyle&&(n=e.currentStyle),t===void 0?n:n[t];!(t in r)&&t.indexOf(`webkit`)===-1&&(t=`-webkit-`+t),r[t]=n+(typeof n==`string`?``:`px`)}}function Xu(e,t){var n=``;if(typeof e==`string`)n=e;else do{var r=H(e,`transform`);r&&r!==`none`&&(n=r+` `+n)}while(!t&&(e=e.parentNode));var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return i&&new i(n)}function Zu(e,t,n){if(e){var r=e.getElementsByTagName(t),i=0,a=r.length;if(n)for(;i<a;i++)n(r[i],i);return r}return[]}function Qu(){return document.scrollingElement||document.documentElement}function $u(e,t,n,r,i){if(!(!e.getBoundingClientRect&&e!==window)){var a,o,s,c,l,u,d;if(e!==window&&e.parentNode&&e!==Qu()?(a=e.getBoundingClientRect(),o=a.top,s=a.left,c=a.bottom,l=a.right,u=a.height,d=a.width):(o=0,s=0,c=window.innerHeight,l=window.innerWidth,u=window.innerHeight,d=window.innerWidth),(t||n)&&e!==window&&(i=i||e.parentNode,!Lu))do if(i&&i.getBoundingClientRect&&(H(i,`transform`)!==`none`||n&&H(i,`position`)!==`static`)){var f=i.getBoundingClientRect();o-=f.top+parseInt(H(i,`border-top-width`)),s-=f.left+parseInt(H(i,`border-left-width`)),c=o+a.height,l=s+a.width;break}while(i=i.parentNode);if(r&&e!==window){var p=Xu(i||e),m=p&&p.a,h=p&&p.d;p&&(o/=h,s/=m,d/=m,u/=h,c=o+u,l=s+d)}return{top:o,left:s,bottom:c,right:l,width:d,height:u}}}function ed(e,t,n){for(var r=od(e,!0),i=$u(e)[t];r;){var a=$u(r)[n],o=void 0;if(o=i>=a,!o)return r;if(r===Qu())break;r=od(r,!1)}return!1}function td(e,t,n,r){for(var i=0,a=0,o=e.children;a<o.length;){if(o[a].style.display!==`none`&&o[a]!==q.ghost&&(r||o[a]!==q.dragged)&&qu(o[a],n.draggable,e,!1)){if(i===t)return o[a];i++}a++}return null}function nd(e,t){for(var n=e.lastElementChild;n&&(n===q.ghost||H(n,`display`)===`none`||t&&!Gu(n,t));)n=n.previousElementSibling;return n||null}function rd(e,t){var n=0;if(!e||!e.parentNode)return-1;for(;e=e.previousElementSibling;)e.nodeName.toUpperCase()!==`TEMPLATE`&&e!==q.clone&&(!t||Gu(e,t))&&n++;return n}function id(e){var t=0,n=0,r=Qu();if(e)do{var i=Xu(e),a=i.a,o=i.d;t+=e.scrollLeft*a,n+=e.scrollTop*o}while(e!==r&&(e=e.parentNode));return[t,n]}function ad(e,t){for(var n in e)if(e.hasOwnProperty(n)){for(var r in t)if(t.hasOwnProperty(r)&&t[r]===e[n][r])return Number(n)}return-1}function od(e,t){if(!e||!e.getBoundingClientRect)return Qu();var n=e,r=!1;do if(n.clientWidth<n.scrollWidth||n.clientHeight<n.scrollHeight){var i=H(n);if(n.clientWidth<n.scrollWidth&&(i.overflowX==`auto`||i.overflowX==`scroll`)||n.clientHeight<n.scrollHeight&&(i.overflowY==`auto`||i.overflowY==`scroll`)){if(!n.getBoundingClientRect||n===document.body)return Qu();if(r||t)return n;r=!0}}while(n=n.parentNode);return Qu()}function sd(e,t){if(e&&t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function cd(e,t){return Math.round(e.top)===Math.round(t.top)&&Math.round(e.left)===Math.round(t.left)&&Math.round(e.height)===Math.round(t.height)&&Math.round(e.width)===Math.round(t.width)}var ld;function ud(e,t){return function(){if(!ld){var n=arguments,r=this;n.length===1?e.call(r,n[0]):e.apply(r,n),ld=setTimeout(function(){ld=void 0},t)}}}function dd(){clearTimeout(ld),ld=void 0}function fd(e,t,n){e.scrollLeft+=t,e.scrollTop+=n}function pd(e){var t=window.Polymer,n=window.jQuery||window.Zepto;return t&&t.dom?t.dom(e).cloneNode(!0):n?n(e).clone(!0)[0]:e.cloneNode(!0)}function md(e,t,n){var r={};return Array.from(e.children).forEach(function(i){if(!(!qu(i,t.draggable,e,!1)||i.animated||i===n)){var a=$u(i);r.left=Math.min(r.left??1/0,a.left),r.top=Math.min(r.top??1/0,a.top),r.right=Math.max(r.right??-1/0,a.right),r.bottom=Math.max(r.bottom??-1/0,a.bottom)}}),r.width=r.right-r.left,r.height=r.bottom-r.top,r.x=r.left,r.y=r.top,r}var hd=`Sortable`+new Date().getTime();function gd(){var e=[],t;return{captureAnimationState:function(){e=[],this.options.animation&&[].slice.call(this.el.children).forEach(function(t){if(!(H(t,`display`)===`none`||t===q.ghost)){e.push({target:t,rect:$u(t)});var n=ku({},e[e.length-1].rect);if(t.thisAnimationDuration){var r=Xu(t,!0);r&&(n.top-=r.f,n.left-=r.e)}t.fromRect=n}})},addAnimationState:function(t){e.push(t)},removeAnimationState:function(t){e.splice(ad(e,{target:t}),1)},animateAll:function(n){var r=this;if(!this.options.animation){clearTimeout(t),typeof n==`function`&&n();return}var i=!1,a=0;e.forEach(function(e){var t=0,n=e.target,o=n.fromRect,s=$u(n),c=n.prevFromRect,l=n.prevToRect,u=e.rect,d=Xu(n,!0);d&&(s.top-=d.f,s.left-=d.e),n.toRect=s,n.thisAnimationDuration&&cd(c,s)&&!cd(o,s)&&(u.top-s.top)/(u.left-s.left)===(o.top-s.top)/(o.left-s.left)&&(t=vd(u,c,l,r.options)),cd(s,o)||(n.prevFromRect=o,n.prevToRect=s,t||(t=r.options.animation),r.animate(n,u,s,t)),t&&(i=!0,a=Math.max(a,t),clearTimeout(n.animationResetTimer),n.animationResetTimer=setTimeout(function(){n.animationTime=0,n.prevFromRect=null,n.fromRect=null,n.prevToRect=null,n.thisAnimationDuration=null},t),n.thisAnimationDuration=t)}),clearTimeout(t),i?t=setTimeout(function(){typeof n==`function`&&n()},a):typeof n==`function`&&n(),e=[]},animate:function(e,t,n,r){if(r){H(e,`transition`,``),H(e,`transform`,``);var i=Xu(this.el),a=i&&i.a,o=i&&i.d,s=(t.left-n.left)/(a||1),c=(t.top-n.top)/(o||1);e.animatingX=!!s,e.animatingY=!!c,H(e,`transform`,`translate3d(`+s+`px,`+c+`px,0)`),this.forRepaintDummy=_d(e),H(e,`transition`,`transform `+r+`ms`+(this.options.easing?` `+this.options.easing:``)),H(e,`transform`,`translate3d(0,0,0)`),typeof e.animated==`number`&&clearTimeout(e.animated),e.animated=setTimeout(function(){H(e,`transition`,``),H(e,`transform`,``),e.animated=!1,e.animatingX=!1,e.animatingY=!1},r)}}}}function _d(e){return e.offsetWidth}function vd(e,t,n,r){return Math.sqrt((t.top-e.top)**2+(t.left-e.left)**2)/Math.sqrt((t.top-n.top)**2+(t.left-n.left)**2)*r.animation}var yd=[],bd={initializeByDefault:!0},xd={mount:function(e){for(var t in bd)bd.hasOwnProperty(t)&&!(t in e)&&(e[t]=bd[t]);yd.forEach(function(t){if(t.pluginName===e.pluginName)throw`Sortable: Cannot mount plugin ${e.pluginName} more than once`}),yd.push(e)},pluginEvent:function(e,t,n){var r=this;this.eventCanceled=!1,n.cancel=function(){r.eventCanceled=!0};var i=e+`Global`;yd.forEach(function(r){t[r.pluginName]&&(t[r.pluginName][i]&&t[r.pluginName][i](ku({sortable:t},n)),t.options[r.pluginName]&&t[r.pluginName][e]&&t[r.pluginName][e](ku({sortable:t},n)))})},initializePlugins:function(e,t,n,r){for(var i in yd.forEach(function(r){var i=r.pluginName;if(!(!e.options[i]&&!r.initializeByDefault)){var a=new r(e,t,e.options);a.sortable=e,a.options=e.options,e[i]=a,Mu(n,a.defaults)}}),e.options)if(e.options.hasOwnProperty(i)){var a=this.modifyOption(e,i,e.options[i]);a!==void 0&&(e.options[i]=a)}},getEventProperties:function(e,t){var n={};return yd.forEach(function(r){typeof r.eventProperties==`function`&&Mu(n,r.eventProperties.call(t[r.pluginName],e))}),n},modifyOption:function(e,t,n){var r;return yd.forEach(function(i){e[i.pluginName]&&i.optionListeners&&typeof i.optionListeners[t]==`function`&&(r=i.optionListeners[t].call(e[i.pluginName],n))}),r}};function Sd(e){var t=e.sortable,n=e.rootEl,r=e.name,i=e.targetEl,a=e.cloneEl,o=e.toEl,s=e.fromEl,c=e.oldIndex,l=e.newIndex,u=e.oldDraggableIndex,d=e.newDraggableIndex,f=e.originalEvent,p=e.putSortable,m=e.extraEventProperties;if(t=t||n&&n[hd],t){var h,g=t.options,_=`on`+r.charAt(0).toUpperCase()+r.substr(1);window.CustomEvent&&!Lu&&!Ru?h=new CustomEvent(r,{bubbles:!0,cancelable:!0}):(h=document.createEvent(`Event`),h.initEvent(r,!0,!0)),h.to=o||n,h.from=s||n,h.item=i||n,h.clone=a,h.oldIndex=c,h.newIndex=l,h.oldDraggableIndex=u,h.newDraggableIndex=d,h.originalEvent=f,h.pullMode=p?p.lastPutMode:void 0;var v=ku(ku({},m),xd.getEventProperties(r,t));for(var y in v)h[y]=v[y];n&&n.dispatchEvent(h),g[_]&&g[_].call(t,h)}}var Cd=[`evt`],wd=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.evt,i=Pu(n,Cd);xd.pluginEvent.bind(q)(e,t,ku({dragEl:U,parentEl:Ed,ghostEl:W,rootEl:G,nextEl:Dd,lastDownEl:Od,cloneEl:K,cloneHidden:kd,dragStarted:Gd,putSortable:Fd,activeSortable:q.active,originalEvent:r,oldIndex:Ad,oldDraggableIndex:Md,newIndex:jd,newDraggableIndex:Nd,hideGhostForTarget:df,unhideGhostForTarget:ff,cloneNowHidden:function(){kd=!0},cloneNowShown:function(){kd=!1},dispatchSortableEvent:function(e){Td({sortable:t,name:e,originalEvent:r})}},i))};function Td(e){Sd(ku({putSortable:Fd,cloneEl:K,targetEl:U,rootEl:G,oldIndex:Ad,oldDraggableIndex:Md,newIndex:jd,newDraggableIndex:Nd},e))}var U,Ed,W,G,Dd,Od,K,kd,Ad,jd,Md,Nd,Pd,Fd,Id=!1,Ld=!1,Rd=[],zd,Bd,Vd,Hd,Ud,Wd,Gd,Kd,qd,Jd=!1,Yd=!1,Xd,Zd,Qd=[],$d=!1,ef=[],tf=typeof document<`u`,nf=Vu,rf=Ru||Lu?`cssFloat`:`float`,af=tf&&!Hu&&!Vu&&`draggable`in document.createElement(`div`),of=function(){if(tf){if(Lu)return!1;var e=document.createElement(`x`);return e.style.cssText=`pointer-events:auto`,e.style.pointerEvents===`auto`}}(),sf=function(e,t){var n=H(e),r=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),i=td(e,0,t),a=td(e,1,t),o=i&&H(i),s=a&&H(a),c=o&&parseInt(o.marginLeft)+parseInt(o.marginRight)+$u(i).width,l=s&&parseInt(s.marginLeft)+parseInt(s.marginRight)+$u(a).width;if(n.display===`flex`)return n.flexDirection===`column`||n.flexDirection===`column-reverse`?`vertical`:`horizontal`;if(n.display===`grid`)return n.gridTemplateColumns.split(` `).length<=1?`vertical`:`horizontal`;if(i&&o.float&&o.float!==`none`){var u=o.float===`left`?`left`:`right`;return a&&(s.clear===`both`||s.clear===u)?`vertical`:`horizontal`}return i&&(o.display===`block`||o.display===`flex`||o.display===`table`||o.display===`grid`||c>=r&&n[rf]===`none`||a&&n[rf]===`none`&&c+l>r)?`vertical`:`horizontal`},cf=function(e,t,n){var r=n?e.left:e.top,i=n?e.right:e.bottom,a=n?e.width:e.height,o=n?t.left:t.top,s=n?t.right:t.bottom,c=n?t.width:t.height;return r===o||i===s||r+a/2===o+c/2},lf=function(e,t){var n;return Rd.some(function(r){var i=r[hd].options.emptyInsertThreshold;if(!(!i||nd(r))){var a=$u(r),o=e>=a.left-i&&e<=a.right+i,s=t>=a.top-i&&t<=a.bottom+i;if(o&&s)return n=r}}),n},uf=function(e){function t(e,n){return function(r,i,a,o){var s=r.options.group.name&&i.options.group.name&&r.options.group.name===i.options.group.name;if(e==null&&(n||s))return!0;if(e==null||e===!1)return!1;if(n&&e===`clone`)return e;if(typeof e==`function`)return t(e(r,i,a,o),n)(r,i,a,o);var c=(n?r:i).options.group.name;return e===!0||typeof e==`string`&&e===c||e.join&&e.indexOf(c)>-1}}var n={},r=e.group;(!r||Au(r)!=`object`)&&(r={name:r}),n.name=r.name,n.checkPull=t(r.pull,!0),n.checkPut=t(r.put),n.revertClone=r.revertClone,e.group=n},df=function(){!of&&W&&H(W,`display`,`none`)},ff=function(){!of&&W&&H(W,`display`,``)};tf&&!Hu&&document.addEventListener(`click`,function(e){if(Ld)return e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.stopImmediatePropagation&&e.stopImmediatePropagation(),Ld=!1,!1},!0);var pf=function(e){if(U){e=e.touches?e.touches[0]:e;var t=lf(e.clientX,e.clientY);if(t){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);n.target=n.rootEl=t,n.preventDefault=void 0,n.stopPropagation=void 0,t[hd]._onDragOver(n)}}},mf=function(e){U&&U.parentNode[hd]._isOutsideThisEl(e.target)};function q(e,t){if(!(e&&e.nodeType&&e.nodeType===1))throw`Sortable: \`el\` must be an HTMLElement, not ${{}.toString.call(e)}`;this.el=e,this.options=t=Mu({},t),e[hd]=this;var n={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(e.nodeName)?`>li`:`>*`,swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return sf(e,this.options)},ghostClass:`sortable-ghost`,chosenClass:`sortable-chosen`,dragClass:`sortable-drag`,ignore:`a, img`,filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(e,t){e.setData(`Text`,t.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:`data-id`,delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:`sortable-fallback`,fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:q.supportPointer!==!1&&`PointerEvent`in window&&!Bu,emptyInsertThreshold:5};for(var r in xd.initializePlugins(this,e,n),n)!(r in t)&&(t[r]=n[r]);for(var i in uf(t),this)i.charAt(0)===`_`&&typeof this[i]==`function`&&(this[i]=this[i].bind(this));this.nativeDraggable=t.forceFallback?!1:af,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?Wu(e,`pointerdown`,this._onTapStart):(Wu(e,`mousedown`,this._onTapStart),Wu(e,`touchstart`,this._onTapStart)),this.nativeDraggable&&(Wu(e,`dragover`,this),Wu(e,`dragenter`,this)),Rd.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),Mu(this,gd())}q.prototype={constructor:q,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(Kd=null)},_getDirection:function(e,t){return typeof this.options.direction==`function`?this.options.direction.call(this,e,t,U):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,n=this.el,r=this.options,i=r.preventOnFilter,a=e.type,o=e.touches&&e.touches[0]||e.pointerType&&e.pointerType===`touch`&&e,s=(o||e).target,c=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||s,l=r.filter;if(wf(n),!U&&!(/mousedown|pointerdown/.test(a)&&e.button!==0||r.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&Bu&&s&&s.tagName.toUpperCase()===`SELECT`)&&(s=qu(s,r.draggable,n,!1),!(s&&s.animated)&&Od!==s)){if(Ad=rd(s),Md=rd(s,r.draggable),typeof l==`function`){if(l.call(this,e,s,this)){Td({sortable:t,rootEl:c,name:`filter`,targetEl:s,toEl:n,fromEl:n}),wd(`filter`,t,{evt:e}),i&&e.cancelable&&e.preventDefault();return}}else if(l&&(l=l.split(`,`).some(function(r){if(r=qu(c,r.trim(),n,!1),r)return Td({sortable:t,rootEl:r,name:`filter`,targetEl:s,fromEl:n,toEl:n}),wd(`filter`,t,{evt:e}),!0}),l)){i&&e.cancelable&&e.preventDefault();return}r.handle&&!qu(c,r.handle,n,!1)||this._prepareDragStart(e,o,s)}}},_prepareDragStart:function(e,t,n){var r=this,i=r.el,a=r.options,o=i.ownerDocument,s;if(n&&!U&&n.parentNode===i){var c=$u(n);if(G=i,U=n,Ed=U.parentNode,Dd=U.nextSibling,Od=n,Pd=a.group,q.dragged=U,zd={target:U,clientX:(t||e).clientX,clientY:(t||e).clientY},Ud=zd.clientX-c.left,Wd=zd.clientY-c.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,U.style[`will-change`]=`all`,s=function(){if(wd(`delayEnded`,r,{evt:e}),q.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents(),!zu&&r.nativeDraggable&&(U.draggable=!0),r._triggerDragStart(e,t),Td({sortable:r,name:`choose`,originalEvent:e}),Yu(U,a.chosenClass,!0)},a.ignore.split(`,`).forEach(function(e){Zu(U,e.trim(),_f)}),Wu(o,`dragover`,pf),Wu(o,`mousemove`,pf),Wu(o,`touchmove`,pf),Wu(o,`mouseup`,r._onDrop),Wu(o,`touchend`,r._onDrop),Wu(o,`touchcancel`,r._onDrop),zu&&this.nativeDraggable&&(this.options.touchStartThreshold=4,U.draggable=!0),wd(`delayStart`,this,{evt:e}),a.delay&&(!a.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(Ru||Lu))){if(q.eventCanceled){this._onDrop();return}Wu(o,`mouseup`,r._disableDelayedDrag),Wu(o,`touchend`,r._disableDelayedDrag),Wu(o,`touchcancel`,r._disableDelayedDrag),Wu(o,`mousemove`,r._delayedDragTouchMoveHandler),Wu(o,`touchmove`,r._delayedDragTouchMoveHandler),a.supportPointer&&Wu(o,`pointermove`,r._delayedDragTouchMoveHandler),r._dragStartTimer=setTimeout(s,a.delay)}else s()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){U&&_f(U),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;V(e,`mouseup`,this._disableDelayedDrag),V(e,`touchend`,this._disableDelayedDrag),V(e,`touchcancel`,this._disableDelayedDrag),V(e,`mousemove`,this._delayedDragTouchMoveHandler),V(e,`touchmove`,this._delayedDragTouchMoveHandler),V(e,`pointermove`,this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType==`touch`&&e,!this.nativeDraggable||t?this.options.supportPointer?Wu(document,`pointermove`,this._onTouchMove):t?Wu(document,`touchmove`,this._onTouchMove):Wu(document,`mousemove`,this._onTouchMove):(Wu(U,`dragend`,this),Wu(G,`dragstart`,this._onDragStart));try{document.selection?Tf(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(Id=!1,G&&U){wd(`dragStarted`,this,{evt:t}),this.nativeDraggable&&Wu(document,`dragover`,mf);var n=this.options;!e&&Yu(U,n.dragClass,!1),Yu(U,n.ghostClass,!0),q.active=this,e&&this._appendGhost(),Td({sortable:this,name:`start`,originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(Bd){this._lastX=Bd.clientX,this._lastY=Bd.clientY,df();for(var e=document.elementFromPoint(Bd.clientX,Bd.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(Bd.clientX,Bd.clientY),e!==t);)t=e;if(U.parentNode[hd]._isOutsideThisEl(e),t)do{if(t[hd]){var n=void 0;if(n=t[hd]._onDragOver({clientX:Bd.clientX,clientY:Bd.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);ff()}},_onTouchMove:function(e){if(zd){var t=this.options,n=t.fallbackTolerance,r=t.fallbackOffset,i=e.touches?e.touches[0]:e,a=W&&Xu(W,!0),o=W&&a&&a.a,s=W&&a&&a.d,c=nf&&Zd&&id(Zd),l=(i.clientX-zd.clientX+r.x)/(o||1)+(c?c[0]-Qd[0]:0)/(o||1),u=(i.clientY-zd.clientY+r.y)/(s||1)+(c?c[1]-Qd[1]:0)/(s||1);if(!q.active&&!Id){if(n&&Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))<n)return;this._onDragStart(e,!0)}if(W){a?(a.e+=l-(Vd||0),a.f+=u-(Hd||0)):a={a:1,b:0,c:0,d:1,e:l,f:u};var d=`matrix(${a.a},${a.b},${a.c},${a.d},${a.e},${a.f})`;H(W,`webkitTransform`,d),H(W,`mozTransform`,d),H(W,`msTransform`,d),H(W,`transform`,d),Vd=l,Hd=u,Bd=i}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!W){var e=this.options.fallbackOnBody?document.body:G,t=$u(U,!0,nf,!0,e),n=this.options;if(nf){for(Zd=e;H(Zd,`position`)===`static`&&H(Zd,`transform`)===`none`&&Zd!==document;)Zd=Zd.parentNode;Zd!==document.body&&Zd!==document.documentElement?(Zd===document&&(Zd=Qu()),t.top+=Zd.scrollTop,t.left+=Zd.scrollLeft):Zd=Qu(),Qd=id(Zd)}W=U.cloneNode(!0),Yu(W,n.ghostClass,!1),Yu(W,n.fallbackClass,!0),Yu(W,n.dragClass,!0),H(W,`transition`,``),H(W,`transform`,``),H(W,`box-sizing`,`border-box`),H(W,`margin`,0),H(W,`top`,t.top),H(W,`left`,t.left),H(W,`width`,t.width),H(W,`height`,t.height),H(W,`opacity`,`0.8`),H(W,`position`,nf?`absolute`:`fixed`),H(W,`zIndex`,`100000`),H(W,`pointerEvents`,`none`),q.ghost=W,e.appendChild(W),H(W,`transform-origin`,Ud/parseInt(W.style.width)*100+`% `+Wd/parseInt(W.style.height)*100+`%`)}},_onDragStart:function(e,t){var n=this,r=e.dataTransfer,i=n.options;if(wd(`dragStart`,this,{evt:e}),q.eventCanceled){this._onDrop();return}wd(`setupClone`,this),q.eventCanceled||(K=pd(U),K.removeAttribute(`id`),K.draggable=!1,K.style[`will-change`]=``,this._hideClone(),Yu(K,this.options.chosenClass,!1),q.clone=K),n.cloneId=Tf(function(){wd(`clone`,n),!q.eventCanceled&&(n.options.removeCloneOnHide||G.insertBefore(K,U),n._hideClone(),Td({sortable:n,name:`clone`}))}),!t&&Yu(U,i.dragClass,!0),t?(Ld=!0,n._loopId=setInterval(n._emulateDragOver,50)):(V(document,`mouseup`,n._onDrop),V(document,`touchend`,n._onDrop),V(document,`touchcancel`,n._onDrop),r&&(r.effectAllowed=`move`,i.setData&&i.setData.call(n,r,U)),Wu(document,`drop`,n),H(U,`transform`,`translateZ(0)`)),Id=!0,n._dragStartId=Tf(n._dragStarted.bind(n,t,e)),Wu(document,`selectstart`,n),Gd=!0,Bu&&H(document.body,`user-select`,`none`)},_onDragOver:function(e){var t=this.el,n=e.target,r,i,a,o=this.options,s=o.group,c=q.active,l=Pd===s,u=o.sort,d=Fd||c,f,p=this,m=!1;if($d)return;function h(o,s){wd(o,p,ku({evt:e,isOwner:l,axis:f?`vertical`:`horizontal`,revert:a,dragRect:r,targetRect:i,canSort:u,fromSortable:d,target:n,completed:_,onMove:function(n,i){return gf(G,t,U,r,n,$u(n),e,i)},changed:v},s))}function g(){h(`dragOverAnimationCapture`),p.captureAnimationState(),p!==d&&d.captureAnimationState()}function _(r){return h(`dragOverCompleted`,{insertion:r}),r&&(l?c._hideClone():c._showClone(p),p!==d&&(Yu(U,Fd?Fd.options.ghostClass:c.options.ghostClass,!1),Yu(U,o.ghostClass,!0)),Fd!==p&&p!==q.active?Fd=p:p===q.active&&Fd&&(Fd=null),d===p&&(p._ignoreWhileAnimating=n),p.animateAll(function(){h(`dragOverAnimationComplete`),p._ignoreWhileAnimating=null}),p!==d&&(d.animateAll(),d._ignoreWhileAnimating=null)),(n===U&&!U.animated||n===t&&!n.animated)&&(Kd=null),!o.dragoverBubble&&!e.rootEl&&n!==document&&(U.parentNode[hd]._isOutsideThisEl(e.target),!r&&pf(e)),!o.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),m=!0}function v(){jd=rd(U),Nd=rd(U,o.draggable),Td({sortable:p,name:`change`,toEl:t,newIndex:jd,newDraggableIndex:Nd,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),n=qu(n,o.draggable,t,!0),h(`dragOver`),q.eventCanceled)return m;if(U.contains(e.target)||n.animated&&n.animatingX&&n.animatingY||p._ignoreWhileAnimating===n)return _(!1);if(Ld=!1,c&&!o.disabled&&(l?u||(a=Ed!==G):Fd===this||(this.lastPutMode=Pd.checkPull(this,c,U,e))&&s.checkPut(this,c,U,e))){if(f=this._getDirection(e,n)===`vertical`,r=$u(U),h(`dragOverValid`),q.eventCanceled)return m;if(a)return Ed=G,g(),this._hideClone(),h(`revert`),q.eventCanceled||(Dd?G.insertBefore(U,Dd):G.appendChild(U)),_(!0);var y=nd(t,o.draggable);if(!y||bf(e,f,this)&&!y.animated){if(y===U)return _(!1);if(y&&t===e.target&&(n=y),n&&(i=$u(n)),gf(G,t,U,r,n,i,e,!!n)!==!1)return g(),y&&y.nextSibling?t.insertBefore(U,y.nextSibling):t.appendChild(U),Ed=t,v(),_(!0)}else if(y&&yf(e,f,this)){var b=td(t,0,o,!0);if(b===U)return _(!1);if(n=b,i=$u(n),gf(G,t,U,r,n,i,e,!1)!==!1)return g(),t.insertBefore(U,b),Ed=t,v(),_(!0)}else if(n.parentNode===t){i=$u(n);var ee=0,te,ne=U.parentNode!==t,re=!cf(U.animated&&U.toRect||r,n.animated&&n.toRect||i,f),ie=f?`top`:`left`,ae=ed(n,`top`,`top`)||ed(U,`top`,`top`),x=ae?ae.scrollTop:void 0;Kd!==n&&(te=i[ie],Jd=!1,Yd=!re&&o.invertSwap||ne),ee=xf(e,n,i,f,re?1:o.swapThreshold,o.invertedSwapThreshold==null?o.swapThreshold:o.invertedSwapThreshold,Yd,Kd===n);var oe;if(ee!==0){var se=rd(U);do se-=ee,oe=Ed.children[se];while(oe&&(H(oe,`display`)===`none`||oe===W))}if(ee===0||oe===n)return _(!1);Kd=n,qd=ee;var S=n.nextElementSibling,ce=!1;ce=ee===1;var le=gf(G,t,U,r,n,i,e,ce);if(le!==!1)return(le===1||le===-1)&&(ce=le===1),$d=!0,setTimeout(vf,30),g(),ce&&!S?t.appendChild(U):n.parentNode.insertBefore(U,ce?S:n),ae&&fd(ae,0,x-ae.scrollTop),Ed=U.parentNode,te!==void 0&&!Yd&&(Xd=Math.abs(te-$u(n)[ie])),v(),_(!0)}if(t.contains(U))return _(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){V(document,`mousemove`,this._onTouchMove),V(document,`touchmove`,this._onTouchMove),V(document,`pointermove`,this._onTouchMove),V(document,`dragover`,pf),V(document,`mousemove`,pf),V(document,`touchmove`,pf)},_offUpEvents:function(){var e=this.el.ownerDocument;V(e,`mouseup`,this._onDrop),V(e,`touchend`,this._onDrop),V(e,`pointerup`,this._onDrop),V(e,`touchcancel`,this._onDrop),V(document,`selectstart`,this)},_onDrop:function(e){var t=this.el,n=this.options;if(jd=rd(U),Nd=rd(U,n.draggable),wd(`drop`,this,{evt:e}),Ed=U&&U.parentNode,jd=rd(U),Nd=rd(U,n.draggable),q.eventCanceled){this._nulling();return}Id=!1,Yd=!1,Jd=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Ef(this.cloneId),Ef(this._dragStartId),this.nativeDraggable&&(V(document,`drop`,this),V(t,`dragstart`,this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Bu&&H(document.body,`user-select`,``),H(U,`transform`,``),e&&(Gd&&(e.cancelable&&e.preventDefault(),!n.dropBubble&&e.stopPropagation()),W&&W.parentNode&&W.parentNode.removeChild(W),(G===Ed||Fd&&Fd.lastPutMode!==`clone`)&&K&&K.parentNode&&K.parentNode.removeChild(K),U&&(this.nativeDraggable&&V(U,`dragend`,this),_f(U),U.style[`will-change`]=``,Gd&&!Id&&Yu(U,Fd?Fd.options.ghostClass:this.options.ghostClass,!1),Yu(U,this.options.chosenClass,!1),Td({sortable:this,name:`unchoose`,toEl:Ed,newIndex:null,newDraggableIndex:null,originalEvent:e}),G===Ed?jd!==Ad&&jd>=0&&(Td({sortable:this,name:`update`,toEl:Ed,originalEvent:e}),Td({sortable:this,name:`sort`,toEl:Ed,originalEvent:e})):(jd>=0&&(Td({rootEl:Ed,name:`add`,toEl:Ed,fromEl:G,originalEvent:e}),Td({sortable:this,name:`remove`,toEl:Ed,originalEvent:e}),Td({rootEl:Ed,name:`sort`,toEl:Ed,fromEl:G,originalEvent:e}),Td({sortable:this,name:`sort`,toEl:Ed,originalEvent:e})),Fd&&Fd.save()),q.active&&((jd==null||jd===-1)&&(jd=Ad,Nd=Md),Td({sortable:this,name:`end`,toEl:Ed,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){wd(`nulling`,this),G=U=Ed=W=Dd=K=Od=kd=zd=Bd=Gd=jd=Nd=Ad=Md=Kd=qd=Fd=Pd=q.dragged=q.ghost=q.clone=q.active=null,ef.forEach(function(e){e.checked=!0}),ef.length=Vd=Hd=0},handleEvent:function(e){switch(e.type){case`drop`:case`dragend`:this._onDrop(e);break;case`dragenter`:case`dragover`:U&&(this._onDragOver(e),hf(e));break;case`selectstart`:e.preventDefault();break}},toArray:function(){for(var e=[],t,n=this.el.children,r=0,i=n.length,a=this.options;r<i;r++)t=n[r],qu(t,a.draggable,this.el,!1)&&e.push(t.getAttribute(a.dataIdAttr)||Cf(t));return e},sort:function(e,t){var n={},r=this.el;this.toArray().forEach(function(e,t){var i=r.children[t];qu(i,this.options.draggable,r,!1)&&(n[e]=i)},this),t&&this.captureAnimationState(),e.forEach(function(e){n[e]&&(r.removeChild(n[e]),r.appendChild(n[e]))}),t&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,t){return qu(e,t||this.options.draggable,this.el,!1)},option:function(e,t){var n=this.options;if(t===void 0)return n[e];var r=xd.modifyOption(this,e,t);r===void 0?n[e]=t:n[e]=r,e===`group`&&uf(n)},destroy:function(){wd(`destroy`,this);var e=this.el;e[hd]=null,V(e,`mousedown`,this._onTapStart),V(e,`touchstart`,this._onTapStart),V(e,`pointerdown`,this._onTapStart),this.nativeDraggable&&(V(e,`dragover`,this),V(e,`dragenter`,this)),Array.prototype.forEach.call(e.querySelectorAll(`[draggable]`),function(e){e.removeAttribute(`draggable`)}),this._onDrop(),this._disableDelayedDragEvents(),Rd.splice(Rd.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!kd){if(wd(`hideClone`,this),q.eventCanceled)return;H(K,`display`,`none`),this.options.removeCloneOnHide&&K.parentNode&&K.parentNode.removeChild(K),kd=!0}},_showClone:function(e){if(e.lastPutMode!==`clone`){this._hideClone();return}if(kd){if(wd(`showClone`,this),q.eventCanceled)return;U.parentNode==G&&!this.options.group.revertClone?G.insertBefore(K,U):Dd?G.insertBefore(K,Dd):G.appendChild(K),this.options.group.revertClone&&this.animate(U,K),H(K,`display`,``),kd=!1}}};function hf(e){e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),e.cancelable&&e.preventDefault()}function gf(e,t,n,r,i,a,o,s){var c,l=e[hd],u=l.options.onMove,d;return window.CustomEvent&&!Lu&&!Ru?c=new CustomEvent(`move`,{bubbles:!0,cancelable:!0}):(c=document.createEvent(`Event`),c.initEvent(`move`,!0,!0)),c.to=t,c.from=e,c.dragged=n,c.draggedRect=r,c.related=i||t,c.relatedRect=a||$u(t),c.willInsertAfter=s,c.originalEvent=o,e.dispatchEvent(c),u&&(d=u.call(l,c,o)),d}function _f(e){e.draggable=!1}function vf(){$d=!1}function yf(e,t,n){var r=$u(td(n.el,0,n.options,!0)),i=md(n.el,n.options,W),a=10;return t?e.clientX<i.left-a||e.clientY<r.top&&e.clientX<r.right:e.clientY<i.top-a||e.clientY<r.bottom&&e.clientX<r.left}function bf(e,t,n){var r=$u(nd(n.el,n.options.draggable)),i=md(n.el,n.options,W),a=10;return t?e.clientX>i.right+a||e.clientY>r.bottom&&e.clientX>r.left:e.clientY>i.bottom+a||e.clientX>r.right&&e.clientY>r.top}function xf(e,t,n,r,i,a,o,s){var c=r?e.clientY:e.clientX,l=r?n.height:n.width,u=r?n.top:n.left,d=r?n.bottom:n.right,f=!1;if(!o){if(s&&Xd<l*i){if(!Jd&&(qd===1?c>u+l*a/2:c<d-l*a/2)&&(Jd=!0),Jd)f=!0;else if(qd===1?c<u+Xd:c>d-Xd)return-qd}else if(c>u+l*(1-i)/2&&c<d-l*(1-i)/2)return Sf(t)}return f=f||o,f&&(c<u+l*a/2||c>d-l*a/2)?c>u+l/2?1:-1:0}function Sf(e){return rd(U)<rd(e)?1:-1}function Cf(e){for(var t=e.tagName+e.className+e.src+e.href+e.textContent,n=t.length,r=0;n--;)r+=t.charCodeAt(n);return r.toString(36)}function wf(e){ef.length=0;for(var t=e.getElementsByTagName(`input`),n=t.length;n--;){var r=t[n];r.checked&&ef.push(r)}}function Tf(e){return setTimeout(e,0)}function Ef(e){return clearTimeout(e)}tf&&Wu(document,`touchmove`,function(e){(q.active||Id)&&e.cancelable&&e.preventDefault()}),q.utils={on:Wu,off:V,css:H,find:Zu,is:function(e,t){return!!qu(e,t,e,!1)},extend:sd,throttle:ud,closest:qu,toggleClass:Yu,clone:pd,index:rd,nextTick:Tf,cancelNextTick:Ef,detectDirection:sf,getChild:td},q.get=function(e){return e[hd]},q.mount=function(){var e=[...arguments];e[0].constructor===Array&&(e=e[0]),e.forEach(function(e){if(!e.prototype||!e.prototype.constructor)throw`Sortable: Mounted plugin must be a constructor function, not ${{}.toString.call(e)}`;e.utils&&(q.utils=ku(ku({},q.utils),e.utils)),xd.mount(e)})},q.create=function(e,t){return new q(e,t)},q.version=Fu;var Df=[],Of,kf,Af=!1,jf,Mf,Nf,Pf;function Ff(){function e(){for(var e in this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0},this)e.charAt(0)===`_`&&typeof this[e]==`function`&&(this[e]=this[e].bind(this))}return e.prototype={dragStarted:function(e){var t=e.originalEvent;this.sortable.nativeDraggable?Wu(document,`dragover`,this._handleAutoScroll):this.options.supportPointer?Wu(document,`pointermove`,this._handleFallbackAutoScroll):t.touches?Wu(document,`touchmove`,this._handleFallbackAutoScroll):Wu(document,`mousemove`,this._handleFallbackAutoScroll)},dragOverCompleted:function(e){var t=e.originalEvent;!this.options.dragOverBubble&&!t.rootEl&&this._handleAutoScroll(t)},drop:function(){this.sortable.nativeDraggable?V(document,`dragover`,this._handleAutoScroll):(V(document,`pointermove`,this._handleFallbackAutoScroll),V(document,`touchmove`,this._handleFallbackAutoScroll),V(document,`mousemove`,this._handleFallbackAutoScroll)),J(),If(),dd()},nulling:function(){Nf=kf=Of=Af=Pf=jf=Mf=null,Df.length=0},_handleFallbackAutoScroll:function(e){this._handleAutoScroll(e,!0)},_handleAutoScroll:function(e,t){var n=this,r=(e.touches?e.touches[0]:e).clientX,i=(e.touches?e.touches[0]:e).clientY,a=document.elementFromPoint(r,i);if(Nf=e,t||this.options.forceAutoScrollFallback||Ru||Lu||Bu){Lf(e,this.options,a,t);var o=od(a,!0);Af&&(!Pf||r!==jf||i!==Mf)&&(Pf&&J(),Pf=setInterval(function(){var a=od(document.elementFromPoint(r,i),!0);a!==o&&(o=a,If()),Lf(e,n.options,a,t)},10),jf=r,Mf=i)}else{if(!this.options.bubbleScroll||od(a,!0)===Qu()){If();return}Lf(e,this.options,od(a,!1),!1)}}},Mu(e,{pluginName:`scroll`,initializeByDefault:!0})}function If(){Df.forEach(function(e){clearInterval(e.pid)}),Df=[]}function J(){clearInterval(Pf)}var Lf=ud(function(e,t,n,r){if(t.scroll){var i=(e.touches?e.touches[0]:e).clientX,a=(e.touches?e.touches[0]:e).clientY,o=t.scrollSensitivity,s=t.scrollSpeed,c=Qu(),l=!1,u;kf!==n&&(kf=n,If(),Of=t.scroll,u=t.scrollFn,Of===!0&&(Of=od(n,!0)));var d=0,f=Of;do{var p=f,m=$u(p),h=m.top,g=m.bottom,_=m.left,v=m.right,y=m.width,b=m.height,ee=void 0,te=void 0,ne=p.scrollWidth,re=p.scrollHeight,ie=H(p),ae=p.scrollLeft,x=p.scrollTop;p===c?(ee=y<ne&&(ie.overflowX===`auto`||ie.overflowX===`scroll`||ie.overflowX===`visible`),te=b<re&&(ie.overflowY===`auto`||ie.overflowY===`scroll`||ie.overflowY===`visible`)):(ee=y<ne&&(ie.overflowX===`auto`||ie.overflowX===`scroll`),te=b<re&&(ie.overflowY===`auto`||ie.overflowY===`scroll`));var oe=ee&&(Math.abs(v-i)<=o&&ae+y<ne)-(Math.abs(_-i)<=o&&!!ae),se=te&&(Math.abs(g-a)<=o&&x+b<re)-(Math.abs(h-a)<=o&&!!x);if(!Df[d])for(var S=0;S<=d;S++)Df[S]||(Df[S]={});(Df[d].vx!=oe||Df[d].vy!=se||Df[d].el!==p)&&(Df[d].el=p,Df[d].vx=oe,Df[d].vy=se,clearInterval(Df[d].pid),(oe!=0||se!=0)&&(l=!0,Df[d].pid=setInterval(function(){r&&this.layer===0&&q.active._onTouchMove(Nf);var t=Df[this.layer].vy?Df[this.layer].vy*s:0,n=Df[this.layer].vx?Df[this.layer].vx*s:0;typeof u==`function`&&u.call(q.dragged.parentNode[hd],n,t,e,Nf,Df[this.layer].el)!==`continue`||fd(Df[this.layer].el,n,t)}.bind({layer:d}),24))),d++}while(t.bubbleScroll&&f!==c&&(f=od(f,!1)));Af=l}},30),Rf=function(e){var t=e.originalEvent,n=e.putSortable,r=e.dragEl,i=e.activeSortable,a=e.dispatchSortableEvent,o=e.hideGhostForTarget,s=e.unhideGhostForTarget;if(t){var c=n||i;o();var l=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,u=document.elementFromPoint(l.clientX,l.clientY);s(),c&&!c.el.contains(u)&&(a(`spill`),this.onSpill({dragEl:r,putSortable:n}))}};function zf(){}zf.prototype={startIndex:null,dragStart:function(e){var t=e.oldDraggableIndex;this.startIndex=t},onSpill:function(e){var t=e.dragEl,n=e.putSortable;this.sortable.captureAnimationState(),n&&n.captureAnimationState();var r=td(this.sortable.el,this.startIndex,this.options);r?this.sortable.el.insertBefore(t,r):this.sortable.el.appendChild(t),this.sortable.animateAll(),n&&n.animateAll()},drop:Rf},Mu(zf,{pluginName:`revertOnSpill`});function Bf(){}Bf.prototype={onSpill:function(e){var t=e.dragEl,n=e.putSortable||this.sortable;n.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),n.animateAll()},drop:Rf},Mu(Bf,{pluginName:`removeOnSpill`}),q.mount(new Ff),q.mount(Bf,zf);function Vf(e){return e==null?e:JSON.parse(JSON.stringify(e))}function Hf(e){a()&&f(e)}function Uf(e){a()?u(e):l(e)}let Wf=null,Gf=null;function Kf(e=null,t=null){Wf=e,Gf=t}function qf(){return{data:Wf,clonedData:Gf}}const Jf=Symbol(`cloneElement`);function Yf(...e){let t=a()?.proxy,n=null,r=e[0],[,i,o]=e;Array.isArray(v(i))||(o=i,i=null);let s=null,{immediate:u=!0,clone:d=Vf,forceFallback:f,fallbackOnBody:p,customUpdate:m}=v(o)??{};function h(e){let{from:t,oldIndex:r,item:a}=e,o=Array.from(t.childNodes);n=f&&!p?o.slice(0,-1):o;let s=v(v(i)?.[r]),c=d(s);Kf(s,c),a[Jf]=c}function g(e){let t=e.item[Jf];if(!_u(t)){if(bu(e.item),c(i)){let n=[...v(i)];i.value=gu(n,e.newDraggableIndex,t);return}gu(v(i),e.newDraggableIndex,t)}}function _(e){let{from:t,item:n,oldIndex:r,oldDraggableIndex:a,pullMode:o,clone:s}=e;if(yu(t,n,r),o===`clone`){bu(s);return}if(c(i)){let e=[...v(i)];i.value=hu(e,a);return}hu(v(i),a)}function b(e){if(m){m(e);return}let{from:t,item:n,oldIndex:r,oldDraggableIndex:a,newDraggableIndex:o}=e;if(bu(n),yu(t,n,r),c(i)){let e=[...v(i)];i.value=fu(e,a,o);return}fu(v(i),a,o)}function ee(e){let{newIndex:t,oldIndex:r,from:i,to:a}=e,o=null,s=t===r&&i===a;try{if(s){let e=null;n?.some((t,r)=>{if(e&&n?.length!==a.childNodes.length)return i.insertBefore(e,t.nextSibling),!0;let o=a.childNodes[r];e=a?.replaceChild(t,o)})}}catch(e){o=e}finally{n=null}l(()=>{if(Kf(),o)throw o})}let te={onUpdate:b,onStart:h,onAdd:g,onRemove:_,onEnd:ee};function ne(e){let n=v(r);return e||(e=vu(n)?xu(n,t?.$el):n),e&&!wu(e)&&(e=e.$el),e||du(`Root element not found`),e}function re(){let e=v(o)??{},{immediate:t,clone:n}=e,r=cu(e,[`immediate`,`clone`]);return Tu(r,(e,t)=>{Eu(e)&&(r[e]=(e,...n)=>(Du(e,qf()),t(e,...n)))}),Cu(i===null?{}:te,r)}let ie=e=>{e=ne(e),s&&ae.destroy(),s=new q(e,re())};y(()=>o,()=>{s&&Tu(re(),(e,t)=>{s?.option(e,t)})},{deep:!0});let ae={option:(e,t)=>s?.option(e,t),destroy:()=>{s?.destroy(),s=null},save:()=>s?.save(),toArray:()=>s?.toArray(),closest:(...e)=>s?.closest(...e)};return Uf(()=>{u&&ie()}),Hf(ae.destroy),su({start:ie,pause:()=>ae?.option(`disabled`,!0),resume:()=>ae?.option(`disabled`,!1)},ae)}const Xf=[`update`,`start`,`add`,`remove`,`choose`,`unchoose`,`end`,`sort`,`filter`,`clone`,`move`,`change`],Zf=i({name:`VueDraggable`,model:{prop:`modelValue`,event:`update:modelValue`},props:[`clone`,`animation`,`ghostClass`,`group`,`sort`,`disabled`,`store`,`handle`,`draggable`,`swapThreshold`,`invertSwap`,`invertedSwapThreshold`,`removeCloneOnHide`,`direction`,`chosenClass`,`dragClass`,`ignore`,`filter`,`preventOnFilter`,`easing`,`setData`,`dropBubble`,`dragoverBubble`,`dataIdAttr`,`delay`,`delayOnTouchOnly`,`touchStartThreshold`,`forceFallback`,`fallbackClass`,`fallbackOnBody`,`fallbackTolerance`,`fallbackOffset`,`supportPointer`,`emptyInsertThreshold`,`scroll`,`forceAutoScrollFallback`,`scrollSensitivity`,`scrollSpeed`,`bubbleScroll`,`modelValue`,`tag`,`target`,`customUpdate`,...Xf.map(e=>`on${e.replace(/^\S/,e=>e.toUpperCase())}`)],emits:[`update:modelValue`,...Xf],setup(e,{slots:t,emit:n,expose:i,attrs:a}){let o=Xf.reduce((e,t)=>{let r=`on${t.replace(/^\S/,e=>e.toUpperCase())}`;return e[r]=(...e)=>n(t,...e),e},{}),c=r(()=>{let t=g(e),{modelValue:n}=t,r=cu(t,[`modelValue`]),i=Object.entries(r).reduce((e,[t,n])=>{let r=v(n);return r!==void 0&&(e[t]=r),e},{});return su(su({},o),mu(su(su({},a),i)))}),l=r({get:()=>e.modelValue,set:e=>n(`update:modelValue`,e)}),u=m(),d=p(Yf(e.target||u,l,c));return i(d),()=>s(e.tag||`div`,{ref:u},(t?.default)?.call(t,d))}}),Qf={mounted:`mounted`,unmounted:`unmounted`};Qf.mounted,Qf.unmounted;var $f=n(((e,t)=>{
|
|
1100
|
+
/*! For license information please see index.js.LICENSE.txt */
|
|
1101
|
+
(function(n,r){if(typeof e==`object`&&typeof t==`object`)t.exports=r(b());else if(typeof define==`function`&&define.amd)define([`blockly/core`],r);else{var i=r(typeof e==`object`?b():n.Blockly);for(var a in i)(typeof e==`object`?e:n)[a]=i[a]}})(e,e=>(()=>{var t={370:t=>{t.exports=e}},n={};function r(e){var i=n[e];if(i!==void 0)return i.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};r.r(i),r.d(i,{BlockShadowStateChange:()=>o,shadowBlockConversionChangeListener:()=>c});var a=r(370);class o extends a.Events.BlockBase{constructor(e,t,n){super(e),this.type=o.EVENT_TYPE,this.inputIndexInParent=t,this.shadowState=n}toJson(){let e=super.toJson();return e.inputIndexInParent=this.inputIndexInParent,e.shadowState=this.shadowState,e}static fromJson(e,t,n){let r=super.fromJson(e,t,n);return r.inputIndexInParent=e.inputIndexInParent,r.shadowState=e.shadowState,n}isNull(){return!1}run(e){let t=this.getEventWorkspace_();if(!this.blockId)throw Error(`The block ID is undefined. Either pass a block to the constructor, or call fromJson`);let n=t.getBlockById(this.blockId);if(!n)throw Error(`The associated block is undefined. Either pass a block to the constructor, or call fromJson`);let r=n.getConnections_(!0),i;if(this.inputIndexInParent===null)i=n.nextConnection;else{if(typeof this.inputIndexInParent!=`number`||this.inputIndexInParent<0||this.inputIndexInParent>=r.length)throw Error(`inputIndexInParent was invalid.`);i=n.inputList[this.inputIndexInParent].connection}if(i===null)throw Error(`No matching connection was found.`);e&&i.setShadowState(this.shadowState||null),a.getFocusManager().focusNode(n)}}function s(e,t=!1){var n;let r=null,i=!1;if(e.previousConnection?.isConnected()?r=e.previousConnection.targetConnection:(n=e.outputConnection)!=null&&n.isConnected()&&(r=e.outputConnection.targetConnection,i=!0),r===null)return e;let c=r.getSourceBlock(),l=r.getParentInput(),u=l?c.inputList.indexOf(l):null,d=r.getShadowState(!1),f=a.serialization.blocks.save(e,{addCoordinates:!1,addInputBlocks:!0,addNextBlocks:!0,doFullSerialization:!1});if(d===null||f===null)return e;if(c.isShadow()){let e=s(c);if(e===null)throw Error(`No parent block was created, so we can't recreate the current block either.`);if(c=e,u===null)r=c.nextConnection;else{if(u<0||u>=c.inputList.length)throw Error(`inputIndexInParent is invalid.`);r=c.inputList[u].connection}if(r===null)throw Error(`Couldn't find the corresponding connection on the new version of the parent block.`)}f.id=void 0;let p=a.serialization.blocks.append(f,c.workspace,{recordUndo:!0}),m=i?p.outputConnection:p.previousConnection;return m&&r.connect(m),r.setShadowState(d),a.Events.fire(new o(c,u,d)),t&&a.getFocusManager().focusNode(p),p}function c(e){if(!e.recordUndo||e.type!=a.Events.BLOCK_CHANGE)return;let t=e;if(!t.workspaceId||!t.blockId)return;let n=a.Workspace.getById(t.workspaceId);if(!n)return;let r=n.getBlockById(t.blockId);if(!r||!r.isShadow())return;let i=a.Events.getGroup();t.group?a.Events.setGroup(t.group):a.Events.setGroup(!0),s(r,!0),a.Events.setGroup(i)}return o.EVENT_TYPE=`block_shadow_state_change`,a.registry.register(a.registry.Type.EVENT,o.EVENT_TYPE,o),i})())})),ep=e(n(((e,t)=>{function n(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw Error(`map is read-only`)}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw Error(`set is read-only`)}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{let r=e[t],i=typeof r;(i===`object`||i===`function`)&&!Object.isFrozen(r)&&n(r)}),e}var r=class{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function i(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function a(e,...t){let n=Object.create(null);for(let t in e)n[t]=e[t];return t.forEach(function(e){for(let t in e)n[t]=e[t]}),n}let o=e=>!!e.scope,s=(e,{prefix:t})=>{if(e.startsWith(`language:`))return e.replace(`language:`,`language-`);if(e.includes(`.`)){let n=e.split(`.`);return[`${t}${n.shift()}`,...n.map((e,t)=>`${e}${`_`.repeat(t+1)}`)].join(` `)}return`${t}${e}`};var c=class{constructor(e,t){this.buffer=``,this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!o(e))return;let t=s(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){o(e)&&(this.buffer+=`</span>`)}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}};let l=(e={})=>{let t={children:[]};return Object.assign(t,e),t};var u=class e{constructor(){this.rootNode=l(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let t=l({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return typeof t==`string`?e.addText(t):t.children&&(e.openNode(t),t.children.forEach(t=>this._walk(e,t)),e.closeNode(t)),e}static _collapse(t){typeof t!=`string`&&t.children&&(t.children.every(e=>typeof e==`string`)?t.children=[t.children.join(``)]:t.children.forEach(t=>{e._collapse(t)}))}},d=class extends u{constructor(e){super(),this.options=e}addText(e){e!==``&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){let n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function f(e){return e?typeof e==`string`?e:e.source:null}function p(e){return g(`(?=`,e,`)`)}function m(e){return g(`(?:`,e,`)*`)}function h(e){return g(`(?:`,e,`)?`)}function g(...e){return e.map(e=>f(e)).join(``)}function _(e){let t=e[e.length-1];return typeof t==`object`&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function v(...e){return`(`+(_(e).capture?``:`?:`)+e.map(e=>f(e)).join(`|`)+`)`}function y(e){return RegExp(e.toString()+`|`).exec(``).length-1}function b(e,t){let n=e&&e.exec(t);return n&&n.index===0}let ee=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function te(e,{joinWith:t}){let n=0;return e.map(e=>{n+=1;let t=n,r=f(e),i=``;for(;r.length>0;){let e=ee.exec(r);if(!e){i+=r;break}i+=r.substring(0,e.index),r=r.substring(e.index+e[0].length),e[0][0]===`\\`&&e[1]?i+=`\\`+String(Number(e[1])+t):(i+=e[0],e[0]===`(`&&n++)}return i}).map(e=>`(${e})`).join(t)}let ne=/\b\B/,re=`[a-zA-Z]\\w*`,ie=`[a-zA-Z_]\\w*`,ae=`\\b\\d+(\\.\\d+)?`,x=`(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)`,oe=`\\b(0b[01]+)`,se=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=g(t,/.*\b/,e.binary,/\b.*/)),a({scope:`meta`,begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{e.index!==0&&t.ignoreMatch()}},e)},S={begin:`\\\\[\\s\\S]`,relevance:0},ce={scope:`string`,begin:`'`,end:`'`,illegal:`\\n`,contains:[S]},le={scope:`string`,begin:`"`,end:`"`,illegal:`\\n`,contains:[S]},ue={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},C=function(e,t,n={}){let r=a({scope:`comment`,begin:e,end:t,contains:[]},n);r.contains.push({scope:`doctag`,begin:`[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)`,end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let i=v(`I`,`a`,`is`,`so`,`us`,`to`,`at`,`if`,`in`,`it`,`on`,/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:g(/[ ]+/,`(`,i,/[.]?[:]?([.][ ]|[ ])/,`){3}`)}),r},de=C(`//`,`$`),fe=C(`/\\*`,`\\*/`),pe=C(`#`,`$`);var me=Object.freeze({__proto__:null,APOS_STRING_MODE:ce,BACKSLASH_ESCAPE:S,BINARY_NUMBER_MODE:{scope:`number`,begin:oe,relevance:0},BINARY_NUMBER_RE:oe,COMMENT:C,C_BLOCK_COMMENT_MODE:fe,C_LINE_COMMENT_MODE:de,C_NUMBER_MODE:{scope:`number`,begin:x,relevance:0},C_NUMBER_RE:x,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:pe,IDENT_RE:re,MATCH_NOTHING_RE:ne,METHOD_GUARD:{begin:`\\.\\s*[a-zA-Z_]\\w*`,relevance:0},NUMBER_MODE:{scope:`number`,begin:ae,relevance:0},NUMBER_RE:ae,PHRASAL_WORDS_MODE:ue,QUOTE_STRING_MODE:le,REGEXP_MODE:{scope:`regexp`,begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[S,{begin:/\[/,end:/\]/,relevance:0,contains:[S]}]},RE_STARTERS_RE:`!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~`,SHEBANG:se,TITLE_MODE:{scope:`title`,begin:re,relevance:0},UNDERSCORE_IDENT_RE:ie,UNDERSCORE_TITLE_MODE:{scope:`title`,begin:ie,relevance:0}});function he(e,t){e.input[e.index-1]===`.`&&t.ignoreMatch()}function ge(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function _e(e,t){t&&e.beginKeywords&&(e.begin=`\\b(`+e.beginKeywords.split(` `).join(`|`)+`)(?!\\.)(?=\\b|\\s)`,e.__beforeBegin=he,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function ve(e,t){Array.isArray(e.illegal)&&(e.illegal=v(...e.illegal))}function ye(e,t){if(e.match){if(e.begin||e.end)throw Error(`begin & end are not supported with match`);e.begin=e.match,delete e.match}}function be(e,t){e.relevance===void 0&&(e.relevance=1)}let xe=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw Error(`beforeMatch cannot be used with starts`);let n=Object.assign({},e);Object.keys(e).forEach(t=>{delete e[t]}),e.keywords=n.keywords,e.begin=g(n.beforeMatch,p(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},Se=[`of`,`and`,`for`,`in`,`not`,`or`,`if`,`then`,`parent`,`list`,`value`];function Ce(e,t,n=`keyword`){let r=Object.create(null);return typeof e==`string`?i(n,e.split(` `)):Array.isArray(e)?i(n,e):Object.keys(e).forEach(function(n){Object.assign(r,Ce(e[n],t,n))}),r;function i(e,n){t&&(n=n.map(e=>e.toLowerCase())),n.forEach(function(t){let n=t.split(`|`);r[n[0]]=[e,we(n[0],n[1])]})}}function we(e,t){return t?Number(t):+!Te(e)}function Te(e){return Se.includes(e.toLowerCase())}let w={},Ee=e=>{console.error(e)},De=(e,...t)=>{console.log(`WARN: ${e}`,...t)},Oe=(e,t)=>{w[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),w[`${e}/${t}`]=!0)},ke=Error();function Ae(e,t,{key:n}){let r=0,i=e[n],a={},o={};for(let e=1;e<=t.length;e++)o[e+r]=i[e],a[e+r]=!0,r+=y(t[e-1]);e[n]=o,e[n]._emit=a,e[n]._multi=!0}function je(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw Ee(`skip, excludeBegin, returnBegin not compatible with beginScope: {}`),ke;if(typeof e.beginScope!=`object`||e.beginScope===null)throw Ee(`beginScope must be object`),ke;Ae(e,e.begin,{key:`beginScope`}),e.begin=te(e.begin,{joinWith:``})}}function Me(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw Ee(`skip, excludeEnd, returnEnd not compatible with endScope: {}`),ke;if(typeof e.endScope!=`object`||e.endScope===null)throw Ee(`endScope must be object`),ke;Ae(e,e.end,{key:`endScope`}),e.end=te(e.end,{joinWith:``})}}function Ne(e){e.scope&&typeof e.scope==`object`&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function T(e){Ne(e),typeof e.beginScope==`string`&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope==`string`&&(e.endScope={_wrap:e.endScope}),je(e),Me(e)}function E(e){function t(t,n){return new RegExp(f(t),`m`+(e.case_insensitive?`i`:``)+(e.unicodeRegex?`u`:``)+(n?`g`:``))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=y(e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let e=this.regexes.map(e=>e[1]);this.matcherRe=t(te(e,{joinWith:`|`}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;let t=this.matcherRe.exec(e);if(!t)return null;let n=t.findIndex((e,t)=>t>0&&e!==void 0),r=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,r)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];let t=new n;return this.rules.slice(e).forEach(([e,n])=>t.addRule(e,n)),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),t.type===`begin`&&this.count++}exec(e){let t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition()&&!(n&&n.index===this.lastIndex)){let t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}function i(e){let t=new r;return e.contains.forEach(e=>t.addRule(e.begin,{rule:e,type:`begin`})),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:`end`}),e.illegal&&t.addRule(e.illegal,{type:`illegal`}),t}function o(n,r){let a=n;if(n.isCompiled)return a;[ge,ye,T,xe].forEach(e=>e(n,r)),e.compilerExtensions.forEach(e=>e(n,r)),n.__beforeBegin=null,[_e,ve,be].forEach(e=>e(n,r)),n.isCompiled=!0;let s=null;return typeof n.keywords==`object`&&n.keywords.$pattern&&(n.keywords=Object.assign({},n.keywords),s=n.keywords.$pattern,delete n.keywords.$pattern),s=s||/\w+/,n.keywords&&(n.keywords=Ce(n.keywords,e.case_insensitive)),a.keywordPatternRe=t(s,!0),r&&(n.begin||(n.begin=/\B|\b/),a.beginRe=t(a.begin),!n.end&&!n.endsWithParent&&(n.end=/\B|\b/),n.end&&(a.endRe=t(a.end)),a.terminatorEnd=f(a.end)||``,n.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(n.end?`|`:``)+r.terminatorEnd)),n.illegal&&(a.illegalRe=t(n.illegal)),n.contains||(n.contains=[]),n.contains=[].concat(...n.contains.map(function(e){return D(e===`self`?n:e)})),n.contains.forEach(function(e){o(e,a)}),n.starts&&o(n.starts,r),a.matcher=i(a),a}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes(`self`))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=a(e.classNameAliases||{}),o(e)}function Pe(e){return e?e.endsWithParent||Pe(e.starts):!1}function D(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return a(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:Pe(e)?a(e,{starts:e.starts?a(e.starts):null}):Object.isFrozen(e)?a(e):e}var O=`11.11.1`,Fe=class extends Error{constructor(e,t){super(e),this.name=`HTMLInjectionError`,this.html=t}};let k=i,Ie=a,A=Symbol(`nomatch`),Le=function(e){let t=Object.create(null),i=Object.create(null),a=[],o=!0,s=`Could not find the language '{}', did you forget to load/include a language module?`,c={disableAutodetect:!0,name:`Plain text`,contains:[]},l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:`hljs-`,cssSelector:`pre code`,languages:null,__emitter:d};function u(e){return l.noHighlightRe.test(e)}function f(e){let t=e.className+` `;t+=e.parentNode?e.parentNode.className:``;let n=l.languageDetectRe.exec(t);if(n){let t=ue(n[1]);return t||(De(s.replace(`{}`,n[1])),De(`Falling back to no-highlight mode for this block.`,e)),t?n[1]:`no-highlight`}return t.split(/\s+/).find(e=>u(e)||ue(e))}function _(e,t,n){let r=``,i=``;typeof t==`object`?(r=e,n=t.ignoreIllegals,i=t.language):(Oe(`10.7.0`,`highlight(lang, code, ...args) has been deprecated.`),Oe(`10.7.0`,`Please use highlight(code, options) instead.
|
|
1102
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(n=!0);let a={code:r,language:i};ge(`before:highlight`,a);let o=a.result?a.result:y(a.language,a.code,n);return o.code=a.code,ge(`after:highlight`,o),o}function y(e,n,i,a){let c=Object.create(null);function u(e,t){return e.keywords[t]}function d(){if(!S.keywords){le.addText(C);return}let e=0;S.keywordPatternRe.lastIndex=0;let t=S.keywordPatternRe.exec(C),n=``;for(;t;){n+=C.substring(e,t.index);let r=x.case_insensitive?t[0].toLowerCase():t[0],i=u(S,r);if(i){let[e,a]=i;if(le.addText(n),n=``,c[r]=(c[r]||0)+1,c[r]<=7&&(de+=a),e.startsWith(`_`))n+=t[0];else{let n=x.classNameAliases[e]||e;m(t[0],n)}}else n+=t[0];e=S.keywordPatternRe.lastIndex,t=S.keywordPatternRe.exec(C)}n+=C.substring(e),le.addText(n)}function f(){if(C===``)return;let e=null;if(typeof S.subLanguage==`string`){if(!t[S.subLanguage]){le.addText(C);return}e=y(S.subLanguage,C,!0,ce[S.subLanguage]),ce[S.subLanguage]=e._top}else e=te(C,S.subLanguage.length?S.subLanguage:null);S.relevance>0&&(de+=e.relevance),le.__addSublanguage(e._emitter,e.language)}function p(){S.subLanguage==null?d():f(),C=``}function m(e,t){e!==``&&(le.startScope(t),le.addText(e),le.endScope())}function h(e,t){let n=1,r=t.length-1;for(;n<=r;){if(!e._emit[n]){n++;continue}let r=x.classNameAliases[e[n]]||e[n],i=t[n];r?m(i,r):(C=i,d(),C=``),n++}}function g(e,t){return e.scope&&typeof e.scope==`string`&&le.openNode(x.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(m(C,x.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),C=``):e.beginScope._multi&&(h(e.beginScope,t),C=``)),S=Object.create(e,{parent:{value:S}}),S}function _(e,t,n){let i=b(e.endRe,n);if(i){if(e[`on:end`]){let n=new r(e);e[`on:end`](t,n),n.isMatchIgnored&&(i=!1)}if(i){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return _(e.parent,t,n)}function v(e){return S.matcher.regexIndex===0?(C+=e[0],1):(me=!0,0)}function ee(e){let t=e[0],n=e.rule,i=new r(n),a=[n.__beforeBegin,n[`on:begin`]];for(let n of a)if(n&&(n(e,i),i.isMatchIgnored))return v(t);return n.skip?C+=t:(n.excludeBegin&&(C+=t),p(),!n.returnBegin&&!n.excludeBegin&&(C=t)),g(n,e),n.returnBegin?0:t.length}function ne(e){let t=e[0],r=n.substring(e.index),i=_(S,e,r);if(!i)return A;let a=S;S.endScope&&S.endScope._wrap?(p(),m(t,S.endScope._wrap)):S.endScope&&S.endScope._multi?(p(),h(S.endScope,e)):a.skip?C+=t:(a.returnEnd||a.excludeEnd||(C+=t),p(),a.excludeEnd&&(C=t));do S.scope&&le.closeNode(),!S.skip&&!S.subLanguage&&(de+=S.relevance),S=S.parent;while(S!==i.parent);return i.starts&&g(i.starts,e),a.returnEnd?0:t.length}function re(){let e=[];for(let t=S;t!==x;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach(e=>le.openNode(e))}let ie={};function ae(t,r){let a=r&&r[0];if(C+=t,a==null)return p(),0;if(ie.type===`begin`&&r.type===`end`&&ie.index===r.index&&a===``){if(C+=n.slice(r.index,r.index+1),!o){let t=Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=ie.rule,t}return 1}if(ie=r,r.type===`begin`)return ee(r);if(r.type===`illegal`&&!i){let e=Error(`Illegal lexeme "`+a+`" for mode "`+(S.scope||`<unnamed>`)+`"`);throw e.mode=S,e}else if(r.type===`end`){let e=ne(r);if(e!==A)return e}if(r.type===`illegal`&&a===``)return C+=`
|
|
1103
|
+
`,1;if(pe>1e5&&pe>r.index*3)throw Error(`potential infinite loop, way more iterations than matches`);return C+=a,a.length}let x=ue(e);if(!x)throw Ee(s.replace(`{}`,e)),Error(`Unknown language: "`+e+`"`);let oe=E(x),se=``,S=a||oe,ce={},le=new l.__emitter(l);re();let C=``,de=0,fe=0,pe=0,me=!1;try{if(x.__emitTokens)x.__emitTokens(n,le);else{for(S.matcher.considerAll();;){pe++,me?me=!1:S.matcher.considerAll(),S.matcher.lastIndex=fe;let e=S.matcher.exec(n);if(!e)break;let t=ae(n.substring(fe,e.index),e);fe=e.index+t}ae(n.substring(fe))}return le.finalize(),se=le.toHTML(),{language:e,value:se,relevance:de,illegal:!1,_emitter:le,_top:S}}catch(t){if(t.message&&t.message.includes(`Illegal`))return{language:e,value:k(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:fe,context:n.slice(fe-100,fe+100),mode:t.mode,resultSoFar:se},_emitter:le};if(o)return{language:e,value:k(n),illegal:!1,relevance:0,errorRaised:t,_emitter:le,_top:S};throw t}}function ee(e){let t={value:k(e),illegal:!1,relevance:0,_top:c,_emitter:new l.__emitter(l)};return t._emitter.addText(e),t}function te(e,n){n=n||l.languages||Object.keys(t);let r=ee(e),i=n.filter(ue).filter(de).map(t=>y(t,e,!1));i.unshift(r);let[a,o]=i.sort((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(ue(e.language).supersetOf===t.language)return 1;if(ue(t.language).supersetOf===e.language)return-1}return 0}),s=a;return s.secondBest=o,s}function ne(e,t,n){let r=t&&i[t]||n;e.classList.add(`hljs`),e.classList.add(`language-${r}`)}function re(e){let t=null,n=f(e);if(u(n))return;if(ge(`before:highlightElement`,{el:e,language:n}),e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);return}if(e.children.length>0&&(l.ignoreUnescapedHTML||(console.warn(`One of your code blocks includes unescaped HTML. This is a potentially serious security risk.`),console.warn(`https://github.com/highlightjs/highlight.js/wiki/security`),console.warn(`The element with unescaped HTML:`),console.warn(e)),l.throwUnescapedHTML))throw new Fe(`One of your code blocks includes unescaped HTML.`,e.innerHTML);t=e;let r=t.textContent,i=n?_(r,{language:n,ignoreIllegals:!0}):te(r);e.innerHTML=i.value,e.dataset.highlighted=`yes`,ne(e,n,i.language),e.result={language:i.language,re:i.relevance,relevance:i.relevance},i.secondBest&&(e.secondBest={language:i.secondBest.language,relevance:i.secondBest.relevance}),ge(`after:highlightElement`,{el:e,result:i,text:r})}function ie(e){l=Ie(l,e)}let ae=()=>{se(),Oe(`10.6.0`,`initHighlighting() deprecated. Use highlightAll() now.`)};function x(){se(),Oe(`10.6.0`,`initHighlightingOnLoad() deprecated. Use highlightAll() now.`)}let oe=!1;function se(){function e(){se()}if(document.readyState===`loading`){oe||window.addEventListener(`DOMContentLoaded`,e,!1),oe=!0;return}document.querySelectorAll(l.cssSelector).forEach(re)}function S(n,r){let i=null;try{i=r(e)}catch(e){if(Ee(`Language definition for '{}' could not be registered.`.replace(`{}`,n)),o)Ee(e);else throw e;i=c}i.name||(i.name=n),t[n]=i,i.rawDefinition=r.bind(null,e),i.aliases&&C(i.aliases,{languageName:n})}function ce(e){delete t[e];for(let t of Object.keys(i))i[t]===e&&delete i[t]}function le(){return Object.keys(t)}function ue(e){return e=(e||``).toLowerCase(),t[e]||t[i[e]]}function C(e,{languageName:t}){typeof e==`string`&&(e=[e]),e.forEach(e=>{i[e.toLowerCase()]=t})}function de(e){let t=ue(e);return t&&!t.disableAutodetect}function fe(e){e[`before:highlightBlock`]&&!e[`before:highlightElement`]&&(e[`before:highlightElement`]=t=>{e[`before:highlightBlock`](Object.assign({block:t.el},t))}),e[`after:highlightBlock`]&&!e[`after:highlightElement`]&&(e[`after:highlightElement`]=t=>{e[`after:highlightBlock`](Object.assign({block:t.el},t))})}function pe(e){fe(e),a.push(e)}function he(e){let t=a.indexOf(e);t!==-1&&a.splice(t,1)}function ge(e,t){let n=e;a.forEach(function(e){e[n]&&e[n](t)})}function _e(e){return Oe(`10.7.0`,`highlightBlock will be removed entirely in v12.0`),Oe(`10.7.0`,`Please use highlightElement now.`),re(e)}Object.assign(e,{highlight:_,highlightAuto:te,highlightAll:se,highlightElement:re,highlightBlock:_e,configure:ie,initHighlighting:ae,initHighlightingOnLoad:x,registerLanguage:S,unregisterLanguage:ce,listLanguages:le,getLanguage:ue,registerAliases:C,autoDetection:de,inherit:Ie,addPlugin:pe,removePlugin:he}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=O,e.regex={concat:g,lookahead:p,either:v,optional:h,anyNumberOfTimes:m};for(let e in me)typeof me[e]==`object`&&n(me[e]);return Object.assign(e,me),e},Re=Le({});Re.newInstance=()=>Le({}),t.exports=Re,Re.HighlightJS=Re,Re.default=Re}))()).default,tp=i({props:{code:{type:String,required:!0},language:{type:String,default:``},autodetect:{type:Boolean,default:!0},ignoreIllegals:{type:Boolean,default:!0}},setup:function(e){var t=m(e.language);y((function(){return e.language}),(function(e){t.value=e}));var n=r((function(){return e.autodetect||!t.value})),i=r((function(){return!n.value&&!ep.getLanguage(t.value)}));return{className:r((function(){return i.value?``:`hljs `+t.value})),highlightedCode:r((function(){if(i.value)return console.warn(`The language "`+t.value+`" you specified could not be found.`),e.code.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`);if(n.value){var r=ep.highlightAuto(e.code);return t.value=r.language??``,r.value}return(r=ep.highlight(e.code,{language:t.value,ignoreIllegals:e.ignoreIllegals})).value}))}},render:function(){return s(`pre`,{},[s(`code`,{class:this.className,innerHTML:this.highlightedCode})])}}),np={install:function(e){e.component(`highlightjs`,tp)},component:tp};const rp=`[A-Za-z$_][0-9A-Za-z$_]*`,ip=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),ap=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],op=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),sp=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],cp=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],lp=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],up=[].concat(cp,op,sp);function dp(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=rp,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:rp,keyword:ip,literal:ap,built_in:up,"variable.language":lp},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:`[A-Za-z$_][0-9A-Za-z$_]*(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),ee={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},te={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},ne={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...op,...sp]}},re={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},ie={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[ee],illegal:/%/},ae={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function x(e){return t.concat(`(?!`,e.join(`|`),`)`)}let oe={match:t.concat(/\b/,x([...cp,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},se={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},S={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},ee]},ce=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,le={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ce)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[ee]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:ne},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),re,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,ne,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},le,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:ce,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},ie,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[ee,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},se,{match:`\\$[A-Za-z$_][0-9A-Za-z$_]*`,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[ee]},oe,ae,te,S,{match:/\$[(.]/}]}}export{tt as A,an as B,Te as C,Ae as D,De as E,St as F,gn as G,dn as H,Lt as I,Fn as J,_n as K,Gt as L,mt as M,ht as N,je as O,bt as P,Vn as Q,Kt as R,Ce as S,Ee as T,fn as U,on as V,hn as W,Ln as X,In as Y,Rn as Z,Kn as _,Zf as a,ge as b,Jl as c,Ll as d,F as f,Gn as g,Ns as h,$f as i,ct as j,$e as k,zl as l,Xs as m,np as n,nu as o,Mc as p,Nn as q,ep as r,Yl as s,dp as t,Rl as u,ie as v,w,Se as x,me as y,tn as z};
|