x-block-lib 0.10.39 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/vendor.chw9q9nj.js +2160 -0
- package/package.json +28 -13
- package/dist/vendor.oft3bmff.js +0 -2160
package/dist/vendor.oft3bmff.js
DELETED
|
@@ -1,2160 +0,0 @@
|
|
|
1
|
-
import{r as e,t}from"./rolldown-runtime.81faoggt.js";import{computed as n,defineComponent as r,getCurrentInstance as i,getCurrentScope as a,h as o,isRef as s,nextTick as c,onMounted as l,onScopeDispose as u,onUnmounted as d,reactive as f,ref as p,shallowRef as m,toRefs as h,toValue as g,unref as _,watch as v}from"vue";var y=t(((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 I)&&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=ac[e],s=sc[e];if(o||(o=ac[e]=Object.create(null),s=sc[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(I.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=ac[e];n&&n[t]?(delete ac[e][t],delete sc[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=ac[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=ac[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=ac[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=sc[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)]||cc,typeof t==`function`?t:o(e,t,n)},u=function(e,t){d(),hc=setTimeout(function(){t&&t.handleRightClick(e)},dc)},d=function(){hc&&=(clearTimeout(hc),0)},f=function(){pc=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 pc?pc===t:e.type===`pointerdown`?(pc=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 mc)for(let n=0;n<mc[t].length;n++){let r=mc[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 mc)for(let n=0;n<mc[t].length;n++){let r=mc[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},ee=function(e){return e.ctrlKey&&Nc?!0:e.button===2},b=function(e,t,n){let r=t.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,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*Ic,y:e.deltaY*Ic};case 2:return{x:e.deltaX*Lc,y:e.deltaY*Lc}}},ne=function(){return`blockly-`+(Uc++).toString(36)},re=function(){return Hc.genUid()},ie=function(e){return e.type===L.BLOCK_CREATE},ae=function(e){return e.type===L.BLOCK_DELETE},oe=function(e){return e.type===L.BLOCK_CHANGE},se=function(e){return e.type===L.BLOCK_FIELD_INTERMEDIATE_CHANGE},ce=function(e){return e.type===L.BLOCK_MOVE},x=function(e){return e.type===L.VAR_CREATE},le=function(e){return e.type===L.VAR_DELETE},ue=function(e){return e.type===L.VAR_RENAME},de=function(e){return e.type===L.BLOCK_DRAG},S=function(e){return e.type===L.SELECTED},fe=function(e){return e.type===L.CLICK},pe=function(e){return e.type===L.BUBBLE_OPEN},me=function(e){return e.type===L.TRASHCAN_OPEN},he=function(e){return e.type===L.TOOLBOX_ITEM_SELECT},ge=function(e){return e.type===L.THEME_CHANGE},_e=function(e){return e.type===L.VIEWPORT_CHANGE},ve=function(e){return e.type===L.COMMENT_CREATE},ye=function(e){return e.type===L.COMMENT_DELETE},be=function(e){return e.type===L.COMMENT_CHANGE},xe=function(e){return e.type===L.COMMENT_MOVE},Se=function(e){return e.type===L.COMMENT_RESIZE},Ce=function(e){return e.type===L.COMMENT_DRAG},we=function(e){return e.type===L.COMMENT_COLLAPSE},Te=function(e){return e.type===L.FINISHED_LOADING},Ee,C,De,Oe,ke,Ae,je,Me,Ne,Pe,w,T,Fe,E,D,O,k,A,j,Ie,M,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,N,Wa,Ga,Ka,qa,Ja,P,Ya,Xa,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,F;e.setRecordUndo$$module$build$src$core$events$utils=function(e){qc=e},Ee=function(){return qc},C=function(e){Zc.fireInternal(e)},De=function(e){if(Me()){if(!Xc.length)try{requestAnimationFrame(()=>{setTimeout(Oe,0)})}catch{setTimeout(Oe,0)}ke(e)}},Oe=function(){let e=Ae(Xc);Xc.length=0;for(let t of e){if(!t.workspaceId)continue;let e;(e=Ke(t.workspaceId))==null||e.fireChangeListener(t)}},ke=function(e){if(oe(e)&&e.element===`mutation`){let t;for(t=Xc.length;t>0;t--){let n=Xc[t-1];if(n.group!==e.group||n.workspaceId!==e.workspaceId||!ce(n)||n.newParentId!==e.blockId)break}Xc.splice(t,0,e)}else Xc.push(e)},Ae=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?ce(n)&&ce(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??[]))))):oe(n)&&oe(e)&&n.blockId===e.blockId&&n.element===e.element&&n.name===e.name?e.newValue=n.newValue:_e(n)&&_e(e)?(e.viewTop=n.viewTop,e.viewLeft=n.viewLeft,e.scale=n.scale,e.oldScale=n.oldScale):fe(n)&&pe(e)||t.push(n):t.push(n));return e=t.filter(e=>!e.isNull())},je=function(){for(let e=0,t;t=Xc[e];e++)t.recordUndo=!1},e.disable$$module$build$src$core$events$utils=function(){Jc++},e.enable$$module$build$src$core$events$utils=function(){Jc--},Me=function(){return Jc===0},e.getGroup$$module$build$src$core$events$utils=function(){return Kc},e.setGroup$$module$build$src$core$events$utils=function(e){Zc.setGroupInternal(e)},Ne=function(e){Kc=typeof e==`boolean`?e?re():``:e},Pe=function(e){let t=[];e=e.getDescendants(!1);for(let n=0,r;r=e[n];n++)t[n]=r.id;return t},w=function(e,t){let n=T(e.type);if(!n)throw Error(`Unknown event type.`);return n.fromJson(e,t)},T=function(e){let t=o(I.EVENT,e);if(!t)throw Error(`Event type ${e} not found in registry.`);return t},Fe=function(e){if((ce(e)||ie(e))&&e.workspaceId){var t=Ke(e.workspaceId);if(!e.blockId)throw Error(`Encountered a blockEvent without a proper blockId`);if(e=t.getBlockById(e.blockId)){let n=qc;try{qc=!1;let n=e.getParent();if(n&&!n.hasDisabledReason(Yc)){let t=e.getDescendants(!1);for(let e=0,n;n=t[e];e++)n.setDisabledReason(!1,Yc)}else if((e.outputConnection||e.previousConnection)&&!t.isDragging())do e.setDisabledReason(!0,Yc),e=e.getNextBlock();while(e)}finally{qc=n}}}},E=function(e,t,n){e=document.createElementNS($c,`${e}`);for(let n in t)e.setAttribute(n,`${t[n]}`);return n&&n.appendChild(e),e},D=function(e,t){return t=t.split(` `),t.every(t=>e.classList.contains(t))?!1:(e.classList.add(...t),!0)},O=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)},A=function(e,t){return e.classList.contains(t)},j=function(e){return e&&e.parentNode?e.parentNode.removeChild(e):null},Ie=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)},M=function(e,t){e.style.transform=t,e.style[`-webkit-transform`]=t},Le=function(){il++,rl||=Object.create(null)},Re=function(){il--,il||(rl=null)},ze=function(e){let t=e.textContent+`
|
|
2
|
-
`+e.className.baseVal;var n;return rl&&(n=rl[t])?n:(n=window.getComputedStyle(e),n=Ve(e,n.fontSize,n.fontWeight,n.fontFamily),rl&&(rl[t]=n),n)},Be=function(e,t,n,r){return Ve(e,t+`pt`,n,r)},Ve=function(e,t,n,r){let i=e.textContent;e=i+`
|
|
3
|
-
`+e.className.baseVal;var a;return rl&&(a=rl[e])?a:(al||=(a=document.createElement(`canvas`),a.className=`blocklyComputeCanvas`,document.body.appendChild(a),a.getContext(`2d`)),i&&al?(al.font=n+` `+t+` `+r,a=al.measureText(i).width):a=0,rl&&(rl[e]=a),a)},He=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 ul.getFocusManager()},Ue=function(e){return e&&typeof e.getFocusableElement==`function`&&typeof e.getFocusableTree==`function`&&typeof e.onNodeFocus==`function`&&typeof e.onNodeBlur==`function`&&typeof e.canBeFocused==`function`},We=function(e){return Ue(e)&&typeof e.id==`string`&&typeof e.workspace==`object`&&typeof e.select==`function`&&typeof e.unselect==`function`},Ge=function(e,t){for(let n in t)t[n]!==null&&Array.isArray(t[n])?e[n]=Ge(e[n]||[],t[n]):e[n]=t[n]!==null&&typeof t[n]==`object`?Ge(e[n]||Object.create(null),t[n]):t[n];return e},Ke=function(e){return _l[e]||null},qe=function(){let e=[];for(let t in _l)e.push(_l[t]);return e},Je=function(e){_l[e.id]=e},Ye=function(e){delete _l[e.id]},Xe=function(){return vl},Ze=function(e){vl=e},Qe=function(){let t=e.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode();return t&&We(t)?t:null},$e=function(t){e.getFocusManager$$module$build$src$core$focus_manager().focusNode(t)},et=function(e){let t=Qe(),n=new(T(L.SELECTED))(t?.id??null,e?.id??null,e?.workspace.id??t?.workspace.id??``);C(n)},tt=function(){return yl},nt=function(e){yl=e},rt=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()}},it=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},at=function(e){return function(){this.jsonInit(e)}},ot=function(e){xl.defineBlocksWithJsonArrayInternal(e)},st=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:at(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 uc&&console.warn(`Block definition "${t}" overwrites previous definition.`),uc[t]=n}},ct=function(t){let n=Xe(),r=e.getFocusManager$$module$build$src$core$focus_manager().getFocusedTree();for(let e of qe())if(r===e){n=e;break}!y(t)&&n&&(!n.rendered||n.isFlyout||n.isVisible())&&hl.registry.onKeyDown(n,t)},lt=function(e,t){return t=e.indexOf(t),t===-1?!1:(e.splice(t,1),!0)},ut=function(e){if(Fl)throw Error(`CSS already injected`);Il+=`
|
|
4
|
-
`+e},dt=function(e,t){Fl||(Fl=!0,e&&(e=t.replace(/[\\/]$/,``),t=Il.replace(/<<<PATH>>>/g,e),Il=``,e=document.createElement(`style`),e.id=`blockly-common-style`,t=document.createTextNode(t),e.appendChild(t),document.head.insertBefore(e,document.head.firstChild)))},ft=function(e){return Hl.getSizeInternal(e)},pt=function(e){if(ht(e,`display`)!==`none`)return mt(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 V(a,e)},mt=function(e){return new V(e.offsetWidth,e.offsetHeight)},ht=function(e,t){return e=window.getComputedStyle(e),e[t]||e.getPropertyValue(t)},gt=function(e){let t=new R(0,0);e=e.getBoundingClientRect();var n=document.documentElement;return n=new R(window.pageXOffset||n.scrollLeft,window.pageYOffset||n.scrollTop),t.x=e.left+n.x,t.y=e.top+n.y,t},_t=function(){let e=document.body,t=document.documentElement;return new R(e.scrollLeft||t.scrollLeft,e.scrollTop||t.scrollTop)},vt=function(e){let t=parseFloat(ht(e,`borderLeftWidth`)),n=parseFloat(ht(e,`borderRightWidth`)),r=parseFloat(ht(e,`borderTopWidth`));return e=parseFloat(ht(e,`borderBottomWidth`)),new B(r,e,t,n)},yt=function(e,t,n){e=bt(e,t,n),t.scrollLeft=e.x,t.scrollTop=e.y},bt=function(e,t,n){var r=gt(e),i=gt(t),a=vt(t);let o=r.x-i.x-a.left;return r=r.y-i.y-a.top,i=mt(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 R(a,t)},xt=function(e){let t=new R(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(Wl))&&(t.x+=Number(n[1]),n[3]&&(t.y+=Number(n[3]))),(e=e.getAttribute(`style`))&&e.includes(`translate`)&&(e=e.match(Gl))&&(t.x+=Number(e[1]),e[3]&&(t.y+=Number(e[3]))),t},St=function(e){let t=0,n=0;for(;e;){let r=xt(e);if(t+=r.x,n+=r.y,(` `+(e.getAttribute(`class`)||``)+` `).includes(` injectionDiv `))break;e=e.parentNode}return new R(t,n)},Ct=function(){let e=_t();return new B(e.y,document.documentElement.clientHeight+e.y,e.x,document.documentElement.clientWidth+e.x)},wt=function(){let e=document.documentElement,t=window;return new R(t.pageXOffset||e.scrollLeft,t.pageYOffset||e.scrollTop)},Tt=function(e,t){var n=t.x;t=t.y;let r=e.getInjectionDiv().getBoundingClientRect();return n=new R(n-r.left,t-r.top),t=e.getOriginOffsetInPixels(),R.difference(n,t).scale(1/e.scale)},Et=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 R(t+r.left+e.x,n+r.top+e.y)},Dt=function(e){({document:Zl=Zl,DOMParser:Ql=Ql,XMLSerializer:$l=$l}=e),Yl=new Ql,Xl=new $l},e.createElement$$module$build$src$core$utils$xml=function(e){return Zl.createElementNS(eu,e)},e.createTextNode$$module$build$src$core$utils$xml=function(e){return Zl.createTextNode(e)},e.textToDom$$module$build$src$core$utils$xml=function(e){let t=Yl.parseFromString(e,`text/xml`);if(t&&t.documentElement&&!t.getElementsByTagName(`parsererror`).length)return t.documentElement;if((t=Yl.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}`)},Ot=function(e){return kt(Xl.serializeToString(e))},kt=function(e){return e.replace(tu,e=>`&#${e.charCodeAt(0)};`)},At=function(e){return e?((e instanceof Element||typeof e==`string`)&&(e=zt(e),e=It(e)),jt(e),e):null},jt=function(e){let t=e.kind;if(e=e.contents,t&&t!==iu&&t!==ru)throw Error(`Invalid toolbox kind `+t+`. Please supply either `+iu+` or `+ru);if(!e)throw Error(`Toolbox must have a contents attribute.`)},Mt=function(e){return e?e.contents?e.contents:Array.isArray(e)&&e.length>0&&!e[0].nodeType?e:Lt(e):[]},Nt=function(e){return au.hasCategoriesInternal(e)},Pt=function(e){if(!e)return!1;let t=e.kind;return t?t===ru:!!e.contents.filter(e=>e.kind.toUpperCase()===`CATEGORY`).length},Ft=function(e){return e&&e.contents?!!e.contents.filter(function(e){return e.kind.toUpperCase()===`CATEGORY`}).length:!1},It=function(e){let t={contents:Lt(e)};return e instanceof Node&&Rt(e,t),t},Lt=function(e){let t=[],n=e.childNodes;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=Lt(i)),Rt(i,e),t.push(e)}return t},Rt=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}},zt=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},Bt=function(e,t,n,r,i,a){let o=a.scrollbar&&a.scrollbar.canScrollVertically();return e.horizontal===cu.LEFT?(n=i.absoluteMetrics.left+n,o&&a.RTL&&(n+=ql.scrollbarThickness)):(n=i.absoluteMetrics.left+i.viewMetrics.width-t.width-n,o&&!a.RTL&&(n-=ql.scrollbarThickness)),e.vertical===su.TOP?e=i.absoluteMetrics.top+r:(e=i.absoluteMetrics.top+i.viewMetrics.height-t.height-r,a.scrollbar&&a.scrollbar.canScrollHorizontally()&&(e-=ql.scrollbarThickness)),new B(e,e+t.height,n,n+t.width)},Vt=function(e,t){return{horizontal:t.toolboxMetrics.position===H.LEFT||e.horizontalLayout&&!e.RTL?cu.RIGHT:cu.LEFT,vertical:t.toolboxMetrics.position===H.BOTTOM?su.TOP:su.BOTTOM}},Ht=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===lu.UP?c.top-o-t:c.bottom+t,e=new B(e,e+o,i,i+a),s=-1)}return e},Ut=function(e,n){t(I.SERIALIZER,e,n)},Wt=function(e){r(I.SERIALIZER,e)},Gt=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},Kt=function(t,n,{recordUndo:r=!1}={}){let i=Ee();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 R(i,n))}return(t.width!==void 0||t.height)&&(a=r.getSize(),r.setSize(new V(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},qt=function(e,n){t(I.PASTER,e,n)},Jt=function(e){r(I.PASTER,e)},Yt=function(e){let t=e.workspace,n=e.getRelativeToSurfaceXY(),r=new R(0,0),i=t.getTopComments(!1).filter(t=>t.id!==e.id).map(e=>e.getRelativeToSurfaceXY());for(;Xt(R.sum(n,r),i);)r.translate(t.RTL?-30:30,30);e.moveTo(R.sum(n,r))},Xt=function(e,t){return t.some(t=>Math.abs(t.x-e.x)<=1&&Math.abs(t.y-e.y)<=1)},Zt=function(e,t){e.setAttribute(Du,t)},Qt=function(e,t,n){Array.isArray(n)&&(n=n.join(` `)),e.setAttribute(Eu+t,`${n}`)},$t=function(e){return e&&typeof e.saveState==`function`&&typeof e.loadState==`function`},en=function(e){return an(e),rn()?(on(),Promise.resolve()):(W||=new Promise(e=>{Gu=e,Ku=window.requestAnimationFrame(()=>{on(),e()})}),W)},tn=function(){return W||Promise.resolve()},nn=function(e){e||window.cancelAnimationFrame(Ku),on(e),!e&&Gu&&Gu()},rn=function(){return Oc},an=function(t){Uu.add(t),Wu.set(t,e.getGroup$$module$build$src$core$events$utils());let n=t.getParent();n?an(n):Hu.add(t)},on=function(t){let n=t?new Set([t]):new Set([...Hu].map(e=>e.workspace)),r=[...Hu].filter(cn).filter(e=>n.has(e.workspace));for(var i of r)ln(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=Wu.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)sn(e);t||(W=null)},sn=function(e){Hu.delete(e),Uu.delete(e),Wu.delete(e);for(let t of e.getChildren(!1))sn(t)},cn=function(e){return!e.isDisposed()&&!e.getParent()},ln=function(e){if(Uu.has(e)&&e.initialized){for(let t of e.getChildren(!1))ln(t);e.renderEfficiently()}},un=function(e,t){nd(e,t)},dn=function(e=td){nd=e},fn=function(e,t){id(e,t)},pn=function(e=rd){id=e},mn=function(e,t,n){od(e,t,n)},hn=function(e=ad){od=e},gn=function(e,t){cd(e,t)},_n=function(e=sd){cd=e},vn=function(e){return e&&typeof e.getProcedureDef==`function`},yn=function(e){return e&&typeof e.getProcedureCall==`function`&&typeof e.renameProcedure==`function`},bn=function(e){return e.getVariableModel!==void 0},xn=function(e,t,n,r){e=e+` was deprecated in `+t+` and will be deleted in `+n+`.`,r&&(e+=`
|
|
5
|
-
Use `+r+` instead.`),fd.has(e)||(fd.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())},Sn=function(e){return Cn(e,!1)},Cn=function(e,t=!0){return uc.variables_set||uc.variables_get||console.warn(`There are no variable blocks, but there is a variable category.`),t?(xn(`The XML return value of Blockly.Variables.flyoutCategory()`,`v12`,`v13`,`the same method, but handle a return type of FlyoutItemInfo[] (JSON) instead.`),En(e)):(e.registerButtonCallback(`CREATE_VARIABLE`,function(e){jn(e.getTargetWorkspace())}),[{kind:`button`,text:`%{BKY_NEW_VARIABLE}`,callbackkey:`CREATE_VARIABLE`},...Tn(e,e.getVariableMap().getVariablesOfType(``),!0)])},wn=function(e){return{VAR:{name:e.getName(),type:e.getType()}}},Tn=function(e,t,n,r=`variables_get`,i=`variables_set`){n&&=uc.math_change,e=[];let a=t.slice(-1)[0];return a&&(uc[i]&&e.push({kind:`block`,type:i,gap:n?8:24,fields:wn(a)}),n&&e.push({kind:`block`,type:`math_change`,gap:uc[r]?20:8,fields:wn(a),inputs:{DELTA:{shadow:{type:`math_number`,fields:{NUM:1}}}}})),uc[r]&&e.push(...t.sort(Vn).map(e=>({kind:`block`,type:r,gap:8,fields:wn(e)}))),e},En=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){jn(e.getTargetWorkspace())}),t.push(n),e=Dn(e),t=t.concat(e)},Dn=function(t){t=t.getVariableMap().getVariablesOfType(``);let n=[];if(t.length>0){var r=t[t.length-1];if(uc.variables_set){var i=e.createElement$$module$build$src$core$utils$xml(`block`);i.setAttribute(`type`,`variables_set`),i.setAttribute(`gap`,uc.math_change?`8`:`24`),i.appendChild(Rn(r)),n.push(i)}if(uc.math_change&&(i=e.createElement$$module$build$src$core$utils$xml(`block`),i.setAttribute(`type`,`math_change`),i.setAttribute(`gap`,uc.variables_get?`20`:`8`),i.appendChild(Rn(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)),uc.variables_get){t.sort(Vn);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(Rn(a)),n.push(r)}}return n},On=function(e){return gd.generateUniqueNameInternal(e)},kn=function(e){return An(hd.charAt(0),e.getVariableMap().getAllVariables().map(e=>e.getName()))},An=function(e,t){if(!t.length)return e;let n=hd,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},jn=function(t,n,r){function i(r){Mn(e.Msg$$module$build$src$core$msg.NEW_VARIABLE_TITLE,r,function(r){if(r){var o=Pn(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());un(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());Mn(o,a,function(a){if(a){var o=Nn(a,n.getType(),t),s=Fn(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)),un(c,function(){i(a)})}else t.getVariableMap().renameVariable(n,a),r&&r(a)}else r&&r(null)})}i(``)},Mn=function(t,n,r){mn(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)})},Nn=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},Pn=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},Fn=function(e,t,n){return n.getProcedureMap().getProcedures().length?In(e,t,n):Ln(e,t,n)},In=function(e,t,n){e=e.toLowerCase(),t=t.toLowerCase(),n=n.getProcedureMap().getProcedures();for(let i of n){var r=i.getParameters().filter(bn).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},Ln=function(e,t,n){e=e.toLowerCase(),t=t.toLowerCase(),n=n.getAllBlocks(!1);for(let i of n){if(!vn(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},Rn=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||=zn(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},zn=function(e,t,n,r){let i=e.getVariableMap(),a=e.getPotentialVariableMap();return n||=On(e.isFlyout?e.targetWorkspace:e),a?a.createVariable(n,r,t??void 0):i.createVariable(n,r,t)},Bn=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},Vn=function(e,t){return e.getName().localeCompare(t.getName(),void 0,{sensitivity:`base`})},Hn=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=Hn(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),un(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),fn(i,e=>{e&&n&&t.getVariableMap().deleteVariable(n)})):t.getVariableMap().deleteVariable(n)},Un=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&&Gn(e,o),Wn(e,o),Kn(e,o,i),qn(e,o,i),Jn(e,o,i),n&&Yn(e,o,i,a),r&&Xn(e,o,i,a),o},Wn=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)},Gn=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)},Kn=function(e,t,n){e.saveExtraState?(e=e.saveExtraState(n),e!==null&&(t.extraState=e)):e.mutationToDom&&(e=e.mutationToDom(),e!==null&&(t.extraState=sa(e).replace(` xmlns="https://developers.google.com/blockly/xml"`,``)))},qn=function(e,t,n){let r=Object.create(null);for(let t of e.getIcons())$t(t)&&(e=t.saveState(n))&&(r[t.getType().toString()]=e);Object.keys(r).length&&(t.icons=r)},Jn=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)},Yn=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=Zn(a.connection,n,r);o&&(i[a.name]=o)}Object.keys(i).length&&(t.inputs=i)},Xn=function(e,t,n,r){e.nextConnection&&(e=Zn(e.nextConnection,n,r))&&(t.next=e)},Zn=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=Un(e,{doFullSerialization:t,saveIds:n})),i},Qn=function(e,t,{recordUndo:n=!1}={}){return e=$n(e,t,{recordUndo:n}),t.rendered&&nn(),e},$n=function(t,n,{parentConnection:r,isShadow:i=!1,recordUndo:a=!1}={}){let o=Ee();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=er(t,n,{parentConnection:r,isShadow:i})}finally{e.enable$$module$build$src$core$events$utils()}if(tr(n,s),Me()&&C(new(T(L.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},er=function(e,t,{parentConnection:n,isShadow:r=!1}={}){if(!e.type)throw new yd(e);let i=t.newBlock(e.type,e.id);return i.setShadow(r),nr(i,e),rr(i,e),ir(i,e),ar(n,i,e),or(i,e),sr(i,e),cr(i,e),lr(i,e),dr(i,t.rendered),i},tr=function(e,t){if(Me())for(e=Bn(e,t),t=0;t<e.length;t++){let n=e[t];C(new(T(L.VAR_CREATE))(n))}},nr=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)},rr=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,U),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)},ir=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)))},ar=function(t,n,r){if(t){if(t.getSourceBlock().isShadow()&&!n.isShadow())throw new xd(r);if(t.type===e.inputTypes$$module$build$src$core$inputs$input_types.VALUE){var i=n.outputConnection;if(!i)throw new bd(`output`,n,r)}else if(i=n.previousConnection,!i)throw new bd(`previous`,n,r);if(!t.connect(i)){let a=n.workspace.connectionChecker;throw new G(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)}}},or=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(I.ICON,i,!1),!r)throw new K(i,e,t);r=new r(e),e.addIcon(r)}$t(r)&&r.loadState(n)}}},sr=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}`)}}},cr=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 bd(i,e,t);ur(a.connection,t.inputs[i])}}},lr=function(e,t){if(t.next){if(!e.nextConnection)throw new bd(`next`,e,t);ur(e.nextConnection,t.next)}},ur=function(e,t){t.shadow&&e.setShadowState(t.shadow),t.block&&er(t.block,e.getSourceBlock().workspace,{parentConnection:e})},dr=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()},fr=function(e){return typeof e.bubbleIsVisible==`function`&&typeof e.setBubbleVisible==`function`&&typeof e.getBubble==`function`},pr=function(e){return e*Math.PI/180},mr=function(e){return e*180/Math.PI},hr=function(e,t,n){if(n<e){let t=n;n=e,e=t}return Math.max(e,Math.min(t,n))},gr=function(){document.querySelector(`.blocklyDropDownDiv`)||(Vd=document.createElement(`div`),Vd.className=`blocklyDropDownDiv`,Vd.tabIndex=-1,(tt()||document.body).appendChild(Vd),Hd=document.createElement(`div`),Hd.className=`blocklyDropDownContent`,Vd.appendChild(Hd),Jd=g(Hd,`keydown`,null,ct),Ud=document.createElement(`div`),Ud.className=`blocklyDropDownArrow`,Vd.appendChild(Ud),Vd.style.opacity=`0`,Vd.style.transition=`transform `+Id+`s, opacity `+Id+`s`)},_r=function(e){Wd=e},vr=function(){return Gd},yr=function(){return Hd},br=function(){Jd&&=(v(Jd),null),Vd.remove(),gr()},xr=function(e,t){Vd.style.backgroundColor=e,Vd.style.borderColor=t},Sr=function(e,t,n,r,i=!0){return Er(wr(t),e,i,n,r)},Cr=function(e,t,n,r=!0){return Kd=!0,Er(Tr(e),e,r,t,n)},wr=function(e){var t=e.getSvgRoot();let n=e.workspace.scale,r=e.height*n;return e=e.width*n,t=gt(t),new B(t.y,t.y+r,t.x,t.x+e)},Tr=function(e){return e=e.getScaledBBox(),new B(e.top,e.bottom,e.left,e.right)},Er=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 _r(s.getParentSvg().parentNode),Dr(t,i.RTL,a,o,a,e,n,r)},Dr=function(t,n,r,i,a,o,s,c){return Gd=t,Rd=c||null,Vd.style.direction=n?`rtl`:`ltr`,t=Xe(),zd=t.getRenderer().getClassName(),Bd=t.getTheme().getClassName(),D(Vd,zd),D(Vd,Bd),r=Ir(r,i,a,o),s&&(qd=e.getFocusManager$$module$build$src$core$focus_manager().takeEphemeralFocus(Vd)),r},Or=function(e,t,n,r){return e=jr(e,n.left,n.right,r.width),{initialX:e.divX,initialY:t,finalX:e.divX,finalY:t+Fd,arrowX:e.arrowX,arrowY:-(Md/2+Nd),arrowAtTop:!0,arrowVisible:!0}},kr=function(e,t,n,r){return e=jr(e,n.left,n.right,r.width),{initialX:e.divX,initialY:t-r.height,finalX:e.divX,finalY:t-r.height-Fd,arrowX:e.arrowX,arrowY:r.height-Nd*2-Md/2,arrowAtTop:!1,arrowVisible:!0}},Ar=function(e,t,n){return e=jr(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}},jr=function(e,t,n,r){return t=hr(t,e-r/2,n-r),e=e-Md/2-t,n=Pd,e=hr(n,e,r-n-Md),{arrowX:e,divX:t}},Mr=function(){return!!Gd},Nr=function(e,t){return Gd===e?(t?Fr():Pr(),!0):!1},Pr=function(){Vd.style.transform=`translate(0, 0)`,Vd.style.opacity=`0`,Ld=setTimeout(function(){Fr()},Id*1e3),Rd&&=(Rd(),null)},Fr=function(){Mr()&&(Ld&&clearTimeout(Ld),Rd&&=(Rd(),null),br(),Gd=null,Xe().markFocused(),qd&&=(qd(),null))},Ir=function(e,t,n,r){e=Yd.getPositionMetrics(e,t,n,r),e.arrowVisible?(t=e.arrowX,n=e.arrowY,r=e.arrowAtTop?45:225,Ud.style.display=``,Ud.style.transform=`translate(${t}px, ${n}px) rotate(${r}deg)`,Ud.setAttribute(`class`,`blocklyDropDownArrow`)):Ud.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 Vd.style.left=t+`px`,Vd.style.top=n+`px`,Vd.style.display=`block`,Vd.style.opacity=`1`,Vd.style.transform=`translate(`+(r-t)+`px,`+(i-n)+`px)`,!!e.arrowAtTop},Lr=function(){if(Gd){var e=Gd.getSourceBlock();e=Kd?Tr(Gd):wr(e);let t=e.left+(e.right-e.left)/2;Ir(t,e.bottom,t,e.top)}else Pr()},Rr=function(e){return e.length?e.reduce(function(e,t){return e.length<t.length?e:t}).length:0},zr=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;let n=0;t||=Rr(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},Br=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;let n=0;t||=Rr(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]=Vr(e[n],t);return e.join(`
|
|
7
|
-
`)},Vr=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=Ur(n,e,t),i=Hr(n,e,t),e=Wr(n,e),o++}while(i>r);return a},Hr=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},Ur=function(e,t,n){let r=Hr(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=Hr(e,o,n);s>r&&(r=s,i=o)}return i?Ur(e,i,n):t},Wr=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)},Gr=function(e){Qd=e},Kr=function(){return Qd},qr=function(){return $d},Jr=function(){return pf},Yr=function(e){if(e=Xr(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``},Xr=function(e){for(;e&&e.tooltip;){if(typeof e.tooltip==`string`||typeof e.tooltip==`function`)return e;e=e.tooltip}return null},Zr=function(){document.querySelector(`.blocklyTooltipDiv`)||(pf=document.createElement(`div`),pf.className=`blocklyTooltipDiv`,(tt()||document.body).appendChild(pf))},Qr=function(e){e.mouseOverWrapper_=_(e,`pointerover`,null,ei),e.mouseOutWrapper_=_(e,`pointerout`,null,ti),e.addEventListener(`pointermove`,ni,!1)},$r=function(e){e&&(v(e.mouseOverWrapper_),v(e.mouseOutWrapper_),e.removeEventListener(`pointermove`,ni))},ei=function(e){ef||(e=Xr(e.currentTarget),sf!==e&&(ii(),cf=null,sf=e),clearTimeout(nf))},ti=function(e){ef||(nf=setTimeout(function(){cf=sf=null,ii()},1),clearTimeout(rf),rf=0)},ni=function(e){if(sf&&sf.tooltip&&!ef)if($d){let t=af-e.pageX;e=of-e.pageY,Math.sqrt(t*t+e*e)>J&&ii()}else cf!==sf&&(clearTimeout(rf),af=e.pageX,of=e.pageY,rf=setTimeout(ui,df))},ri=function(){cf=sf=null,ii()},ii=function(){$d&&($d=!1,pf&&(pf.style.display=`none`)),rf&&=(clearTimeout(rf),0)},ai=function(){ii(),ef=!0},oi=function(){ef=!1},si=function(){pf&&sf&&(typeof Qd==`function`?Qd(pf,sf):ci())},ci=function(){var t=Yr(sf);t=e.wrap$$module$build$src$core$utils$string(t,tf),t=t.split(`
|
|
9
|
-
`);for(let e=0;e<t.length;e++){let n=document.createElement(`div`);n.appendChild(document.createTextNode(t[e])),pf.appendChild(n)}},li=function(e){let t=document.documentElement.clientWidth,n=document.documentElement.clientHeight,r=af;r=e?r-(lf+pf.offsetWidth):r+lf;let i=of+uf;return i+pf.offsetHeight>n+window.scrollY&&(i-=pf.offsetHeight+2*uf),e?r=Math.max(ff-window.scrollX,r):r+pf.offsetWidth>t+window.scrollX-2*ff&&(r=t-pf.offsetWidth-2*ff),{x:r,y:i}},ui=function(){if(!ef&&(cf=sf,pf)){pf.textContent=``,si();var e=sf.RTL;pf.style.direction=e?`rtl`:`ltr`,pf.style.display=`block`,$d=!0;var{x:t,y:n}=li(e);pf.style.left=t+`px`,pf.style.top=n+`px`}},di=function(){return hf},fi=function(e){hf=e},pi=function(){return gf},mi=function(e){gf=e},hi=function(e){e=`${e}`.toLowerCase().trim();var t=_f[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)?gi(e,t,n):null},gi=function(e,t,n){return t=e<<16|t<<8|n,e<16?`#`+(16777216|t).toString(16).substr(1):`#`+t.toString(16)},_i=function(e){return e=hi(e),e?(e=parseInt(e.substr(1),16),[e>>16,e>>8&255,e&255]):[0,0,0]},vi=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 gi(Math.floor(r),Math.floor(i),Math.floor(a))},yi=function(e,t,n){return e=hi(e),!e||(t=hi(t),!t)?null:(e=_i(e),t=_i(t),gi(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]))))},bi=function(e){return vi(e,hf,gf*255)},xi=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,xi(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},Si=function(e){return xi(e,!0,!0)},Ci=function(e){return typeof e==`string`?(e=xi(e,!1,!1),e.length?String(e[0]):``):e},wi=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},Ti=function(e){let t=typeof e==`string`?Ci(e):e;var n=Number(t);if(!isNaN(n)&&0<=n&&n<=360)return{hue:n,hex:vi(n,di(),pi()*255)};if(n=hi(t))return{hue:null,hex:n};throw n=`Invalid colour: "`+t+`"`,e!==t&&(n+=` (from "`+e+`")`),Error(n)},Ei=function(){return kf},Di=function(e){if(kf=e,e===null){let e;(e=document.querySelector(`.`+Ef))==null||e.remove()}},Oi=function(){let e=tt()||document.body,t=document.querySelector(`div.`+Ef);t?kf=t:(kf=document.createElement(`div`),kf.className=Ef,kf.tabIndex=-1),g(kf,`keydown`,null,ct),e.appendChild(kf)},ki=function(t,n,r,i,a=!0){Ai(),Cf=t,Tf=r,(r=kf)&&(r.style.direction=n?`rtl`:`ltr`,r.style.display=`block`,!i&&t instanceof bf&&(i=t.getSourceBlock()?.workspace),wf=i??null,t=i??Xe(),Df=t.getRenderer().getClassName(),Of=t.getTheme().getClassName(),Df&&D(r,Df),Of&&D(r,Of),a&&(Af=e.getFocusManager$$module$build$src$core$focus_manager().takeEphemeralFocus(r)))},Ai=function(){if(ji()){Cf=null;var e=kf;e&&(e.style.display=`none`,e.style.left=``,e.style.top=``,Tf&&=(Tf(),null),e.textContent=``,Df&&=(k(e,Df),``),Of&&=(k(e,Of),``),Xe().markFocused(),Af&&=(Af(),null))}},ji=function(){return!!Cf},Mi=function(e){Cf===e&&Ai()},Ni=function(e){let t=wf===null,n=e;for(;!t&&n;){if(n===e){t=!0;break}n=e.options.parentWorkspace}t&&Ai()},Pi=function(e,t,n){kf.style.left=e+`px`,kf.style.top=t+`px`,kf.style.height=n+`px`},Fi=function(e,t,n,r){let i=Li(e,t,n);e=Ii(e,t,n,r),i<0?Pi(e,0,n.height+i):Pi(e,i,n.height)},Ii=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)},Li=function(e,t,n){return t.bottom+n.height>=e.bottom?t.top-n.height:t.bottom},Ri=function(e){return!(e==null||!e.repositionForWindowResize)},zi=function(){Ri(Cf)&&Cf.repositionForWindowResize()||Ai()},Bi=function(){return Mf},Vi=function(e){Mf=e},Hi=function(e,t,n,r,i){if(ki(Nf,n,Ji,r),t.length){i||(e instanceof PointerEvent?i=new R(e.clientX,e.clientY):(console.warn(`Context menu opened with keyboard but no location given`),i=new R(0,0)));var a=Ui(t,n,e,i);Pf=a,Wi(a,n,i),setTimeout(function(){a.focus()},1),Mf=null}else qi()},Ui=function(e,t,n,r){let i=new Nu;i.setRole(Ou.MENU);for(let a=0;a<e.length;a++){let o=e[a];if(o.separator){i.addChild(new Fu);continue}let s=new ju(o.text);s.setRightToLeft(t),s.setRole(Ou.MENUITEM),i.addChild(s),s.setEnabled(o.enabled),o.enabled&&s.onAction(function(e,t){qi(),requestAnimationFrame(()=>{setTimeout(()=>{o.callback(o.scope,n,t,r)},0)})},{})}return i},Wi=function(e,t,n){let r=Ct();n=new B(n.y+r.top,n.y+r.top,n.x+r.left,n.x+r.left),Gi(e);let i=e.getSize();t&&(n.left+=i.width,n.right+=i.width,r.left+=i.width,r.right+=i.width),Fi(r,n,i,t),e.focus()},Gi=function(e){var t=Ei();if(!t)throw Error(`Attempting to create a context menu when widget div is null`);t=e.render(t),D(t,`blocklyContextMenu`),g(t,`contextmenu`,null,Ki),e.focus()},Ki=function(e){e.preventDefault(),e.stopPropagation()},qi=function(){Mi(Nf),Mf=null;let e;(e=Pf)==null||e.dispose(),Pf=null},Ji=function(){Pf&&=(Pf.dispose(),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?fa(n,t.workspace):$n(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 Me()&&!r.isShadow()&&C(new(T(L.BLOCK_CREATE))(r)),e.getFocusManager$$module$build$src$core$focus_manager().focusNode(r),r}},Yi=function(){return Pf},Xi=function(e,t){return t=b(t,e.getParentSvg(),e.getInverseScreenCTM()),t.x/=e.scale,t.y/=e.scale,t},Zi=function(e,t,n){t=Xi(e,t),Uf.set(e,R.difference(n,t))},Qi=function(e,t){if(t=Xi(e,t),e=Uf.get(e),!e)throw Error(`Drag not initialized`);return R.sum(e,t)},$i=function(t,n=!1){let r=e.createElement$$module$build$src$core$utils$xml(`xml`);var i=ta(e.allUsedVarModels$$module$build$src$core$variables(t));i.hasChildNodes()&&r.appendChild(i);for(let e of t.getTopComments())r.appendChild(ea(e,n));for(t=t.getTopBlocks(!0),i=0;i<t.length;i++)r.appendChild(na(t[i],n));return r},ea=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},ta=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},na=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=aa(e,t),Ta(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},ra=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},ia=function(e,t){for(let n of e.getFields())(e=ra(n))&&t.appendChild(e)},aa=function(t,n){if(t.isInsertionMarker())return(n=t.getChildren(!1)[0])?aa(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(ia(t,r),i=t.getCommentText()){var a=t.getIcon(q.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(oa(c,n)),a&&(a=aa(a,n),a.nodeType===nl.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=aa(l,n),i.nodeType===nl.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(oa(t,n)),r},oa=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===nl.TEXT_NODE&&r.data.trim()===``&&n?.firstChild!==r&&j(r);n&&(r=n,n=n.nextSibling,r.nodeType===nl.TEXT_NODE&&r.data.trim()===``&&j(r))}return e},sa=function(e){return Ot(e).replace(/<(\w+)([^<]*)\/>/g,`<$1$2></$1>`)},ca=function(e){e=sa(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/,``)},la=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=[];Le();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`&&!Ee()){let e=fa(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`)ua(t,n);else if(e===`variables`){if(o)pa(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&&nn(),Re()}return C(new(T(L.FINISHED_LOADING))(n)),i},ua=function(e,t){var n;let r=(n=e.getAttribute(`id`))??void 0;n=t.rendered?new op(t,r):new ip(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 R(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 V(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},da=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=fa(e,t),t.rendered&&nn(),e},fa=function(t,n){e.disable$$module$build$src$core$events$utils();var r=n.getVariableMap().getAllVariables();let i;try{if(i=Sa(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(Me()){for(t=Bn(n,r),n=0;n<t.length;n++)r=t[n],C(new(T(L.VAR_CREATE))(r));C(new(T(L.BLOCK_CREATE))(i))}return i},pa=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)}},ma=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!==nl.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},ha=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},ga=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(q.COMMENT);isNaN(o)||isNaN(s)||u.setBubbleSize(new V(o,s)),u.setBubbleVisible(a),setTimeout(()=>{isNaN(c)||isNaN(l)||(c=t.workspace.RTL?t.workspace.getWidth()-(c+o):c,u.setBubbleLocation(new R(c,l))),u.setBubbleVisible(a)},1)}},_a=function(e,t){for(let n=0;n<e.length;n++)t.data=e[n].textContent},va=function(e,t){for(let n=0;n<e.length;n++){let r=e[n],i=r.getAttribute(`name`);i?Ca(t,i,r):console.warn(`Ignoring unnamed field in block ${t.type}`)}},ya=function(e){let t=null,n=null;for(let r=0;r<e.childNodes.length;r++){let i=e.childNodes[r];Ta(i)&&(i.nodeName.toLowerCase()===`block`?t=i:i.nodeName.toLowerCase()===`shadow`&&(n=i))}return{childBlockElement:t,childShadowElement:n}},ba=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=ya(i),i.childBlockElement){if(!s.connection)throw TypeError(`Input connection does not exist.`);Sa(i.childBlockElement,t,s.connection,!1)}if(i.childShadowElement){let e;(e=s.connection)==null||e.setShadowDom(i.childShadowElement)}}},xa=function(e,t,n){for(let r=0;r<e.length;r++){let i=ya(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.`);Sa(i.childBlockElement,t,n.nextConnection,!0)}i.childShadowElement&&n.nextConnection&&n.nextConnection.setShadowDom(i.childShadowElement)}},Sa=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=ma(e);let s=ha(o.mutation,i);if(ga(o.comment,i),_a(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(va(o.field,i),ba(o.input,t,i,a),xa(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`,U),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},Ca=function(e,t,n){let r=e.getField(t);r?r.fromXml(n):console.warn(`Ignoring non-existent field `+t+` in block `+e.type)},wa=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}}},Ta=function(e){return e.nodeType===nl.ELEMENT_NODE},Ea=function(e,n){t(I.FIELD,e,n,!0)},Da=function(e){r(I.FIELD,e)},e.fromJson$$module$build$src$core$field_registry=function(e){return gp.fromJsonInternal(e)},Oa=function(e){let t=s(I.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)},ka=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(Lp[e])throw Error(`Error: Extension "`+e+`" is already registered.`);if(typeof t!=`function`)throw Error(`Error: Extension "`+e+`" must be a function`);Lp[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+`": `;Ra(a,n);let o=Ia(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)})},Aa=function(e){ja(e)?delete Lp[e]:console.warn(`No extension mapping for name "`+e+`" found to unregister`)},ja=function(e){return!!Lp[e]},Ma=function(e,t,n){let r=Lp[e];if(typeof r!=`function`)throw Error(`Error: Extension "`+e+`" not found.`);let i;if(n?Na(e,t):i=za(t),r.apply(t),n)Ra(`Error after applying mutator "`+e+`": `,t);else if(!Ba(i,t))throw Error(`Error when applying extension "`+e+`": mutation properties changed when applying a non-mutator extension.`)},Na=function(e,t){if(za(t).length)throw Error(`Error: tried to apply mutation "`+e+`" to a block that already has mutator functions. Block id: `+t.id)},Pa=function(e,t){return La(e.mutationToDom,e.domToMutation,t+` mutationToDom/domToMutation`)},Fa=function(e,t){return La(e.saveExtraState,e.loadExtraState,t+` saveExtraState/loadExtraState`)},Ia=function(e,t){return La(e.compose,e.decompose,t+` compose/decompose`)},La=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`)},Ra=function(e,t){let n=Pa(t,e),r=Fa(t,e);if(!n&&!r)throw Error(e+`Mutations must contain either XML hooks, or JSON hooks, or both`);Ia(t,e)},za=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},Ba=function(e,t){if(t=za(t),t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0},Va=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)||(Ha(this,e,t),n.push(this.type)),this.setTooltip(function(){let n=String(this.getFieldValue(e));return Ci(t[n])}.bind(this))}},Ha=function(e,t,n){var r=e.getField(t);if(r instanceof vp&&!r.isOptionListDynamic()){r=r.getOptions();for(let i of r)i!==vp.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 Ci(e).replace(`%1`,n?n.getText():``)}.bind(this))}},Ua=function(){let e=this.tooltip;this.setTooltip(function(){let t=this.getParent();return t&&t.getInputsInline()&&t.tooltip||e}.bind(this))},N=function(e,t){return` `+e+`,`+t+` `},Wa=function(e,t){return` `+e+t.join(``)},Ga=function(e,t){return` M `+e+`,`+t+` `},Ka=function(e,t){return` m `+e+`,`+t+` `},qa=function(e,t){return` l `+e+`,`+t+` `},Ja=function(e){return` l`+e.join(``)},P=function(e,t){return` `+e+` `+t+` `},Ya=function(e,t,n,r){return e+` `+n+` `+n+` `+t+r},Xa=function(e,t){if(!e||!t)throw Error(`Cannot connect null connections.`);e.targetConnection=t,t.targetConnection=e},Za=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},Qa=function(e,t){let n;for(;n=Za(e,t);)if(e=n.targetBlock(),!e||e.isShadow())return n;return null},$a=function(e){return Ue(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`},eo=function(e){return $a(e)&&fr(e)&&$t(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()===q.COMMENT},to=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}),no(i,{x:r.x,y:r.y,width:e.width,height:e.height},t.RTL,new Date)}},no=function(e,t,n,r){let i=(new Date().getTime()-r.getTime())/150;i>1?j(e):(e.setAttribute(`transform`,`translate(`+(t.x+(n?-1:1)*t.width/2*i)+`,`+(t.y+t.height/2*i)+`) scale(`+(1-i)+`)`),setTimeout(no,10,e,t,n,r))},ro=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=E(z.CIRCLE,{cx:r.x,cy:r.y,r:0,fill:`none`,stroke:`#888`,"stroke-width":10},t.getParentSvg());e=E(z.ANIMATE,{id:`animationCircle`,begin:`indefinite`,attributeName:`r`,dur:`150ms`,from:0,to:25*n},i),t=E(z.ANIMATE,{id:`animationOpacity`,begin:`indefinite`,attributeName:`opacity`,dur:`150ms`,from:1,to:0},i),e.beginElement(),t.beginElement(),setTimeout(()=>void j(i),150)}},io=function(e){if(oo(),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,ao(e,t,new Date,0)}},ao=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(ao,15,e,t,n,r+1)),e.getSvgRoot().setAttribute(`transform`,`${e.getTranslation()} ${a}`)},oo=function(){Om&&=(Dm&&=(clearTimeout(Dm),null),Om.getSvgRoot().setAttribute(`transform`,Om.getTranslation()),null)},so=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=R.difference(n,t.getRelativeToSurfaceXY()),o=new R(0,0),s=r.getAllBlocks(!1).filter(e=>e.id!=t.id).map(e=>e.getRelativeToSurfaceXY());for(;co(R.sum(n,o),s)||lo(t,R.sum(a,o),i);)r.RTL?o.translate(-i,i*2):o.translate(i,i*2);t.moveTo(R.sum(n,o))},co=function(e,t){return t.some(t=>Math.abs(t.x-e.x)<=1&&Math.abs(t.y-e.y)<=1)},lo=function(e,t,n){return e.getConnections_(!1).some(e=>!!e.closest(n,t).connection)},uo=function(e,t,n){let r=n.getBoundingRectangle(),i=r.right-r.left,a=hr(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=hr(o,r.left,t)-r.left)||a?(n.moveBy(e,a,[`inbounds`]),!0):!1},fo=function(t){return n=>{var r=t.getMetricsManager();if(r.hasFixedEdges()&&!t.isDragging()){var i;if(zc.includes((i=n.type)??``)){i=r.getScrollMetrics(!0);let a=po(t,n);a&&(r=e.getGroup$$module$build$src$core$events$utils()||!1,e.setGroup$$module$build$src$core$events$utils(n.group),uo(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 _e(n)&&n.scale&&n.oldScale&&n.scale>n.oldScale&&mo(t)}}},po=function(e,t){let n=null;switch(t.type){case L.BLOCK_CREATE:case L.BLOCK_MOVE:(n=e.getBlockById(t.blockId))&&(n=n.getRootBlock());break;case L.COMMENT_CREATE:case L.COMMENT_MOVE:case L.COMMENT_RESIZE:n=e.getCommentById(t.commentId)}return n},mo=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++)uo(e,t,i)}},ho=function(e){return e&&typeof e.isDeletable==`function`&&typeof e.dispose==`function`&&typeof e.setDeleteStyle==`function`},go=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!==X.NEXT_STATEMENT||t||(e=e.lastConnectionInStack(!1)?.getSourceBlock()))&&n.push(e)):r.connection?.type===X.INPUT_VALUE&&n.push(r.connection)}return n},_o=function(e,t){let n=e.workspace.getTopBoundedElements(!0).filter(e=>Ue(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},vo=function(e,t){var n;let r=e instanceof Bm?(n=e.outputConnection)?.targetBlock()??e.getSurroundParent():e.getSourceBlock();return!(r instanceof Bm)||(n=go(r,t>0),e=n.indexOf(e),e===-1)?null:(t=e+t,t>=0&&t<n.length?n[t]:null)},yo=function(e,n){t(I.ICON,e.toString(),n)},bo=function(e){r(I.ICON,e)},xo=function(e){return e&&typeof e.showContextMenu==`function`},So=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`},Co=function(e){return e&&typeof e.autoHide==`function`},wo=function(e){return typeof e.getProcedureModel==`function`&&typeof e.doProcedureUpdate==`function`&&typeof e.isProcedureDef==`function`},To=function(e){return e&&typeof e.startPublishing==`function`&&typeof e.stopPublishing==`function`},Eo=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=>{!wo(e)&&vn(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=>{!wo(e)&&vn(e)&&n.push(e.getProcedureDef())}),t.sort(Do),n.sort(Do),[t,n]},Do=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`;!Oo(t,n.workspace,n);){let e=t.match(/^(.*?)(\d+)$/);t=e?e[1]+(parseInt(e[2])+1):t+`2`}return t},Oo=function(e,t,n){return!ko(e,t,n)},ko=function(t,n,r){for(let i of n.getAllBlocks(!1))if(i!==r&&vn(i)&&e.Names$$module$build$src$core$names.equals(i.getProcedureDef()[0],t))return!0;r=r&&wo(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 xf;t=t.trim();let r=e.findLegalName$$module$build$src$core$procedures(t,n);wo(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},Ao=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(uc.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 uc.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)),uc.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=Eo(t),n(t[0],`procedures_callnoreturn`),n(t[1],`procedures_callreturn`),r},jo=function(e){return Mo(e,!1)},Mo=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 xn(`The XML return value of Blockly.Procedures.flyoutCategory()`,`v12`,`v13`,`the same method, but handle a return type of FlyoutItemInfo[] (JSON) instead.`),Ao(t);let i=[];return uc.procedures_defnoreturn&&i.push({kind:`block`,type:`procedures_defnoreturn`,gap:16,fields:{NAME:e.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_PROCEDURE}}),uc.procedures_defreturn&&i.push({kind:`block`,type:`procedures_defreturn`,gap:16,fields:{NAME:e.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_PROCEDURE}}),uc.procedures_ifreturn&&i.push({kind:`block`,type:`procedures_ifreturn`,gap:16}),i.length&&(i[i.length-1].gap=24),t=Eo(t),r(t[0],`procedures_callnoreturn`),r(t[1],`procedures_callreturn`),i},No=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=An(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)},Po=function(t){if(pe(t)&&t.bubbleType===`mutator`&&t.isOpen&&t.blockId){t=Ke(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(),No(t),t.addChangeListener(Fo))}},Fo=function(e){(ie(e)||ae(e)||oe(e)||se(e))&&(e=Ke(e.workspaceId),No(e))},Io=function(t,n){return n.getAllBlocks(!1).filter(n=>Lo(n,t)||yn(n)&&e.Names$$module$build$src$core$names.equals(n.getProcedureCall(),t))},Lo=function(t,n){return wo(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=Ee();var r=t.getProcedureDef()[0];let i=t.mutationToDom(!0);t=Io(r,t.workspace);for(let o=0,s;s=t[o];o++){r=(r=s.mutationToDom())&&Ot(r),s.domToMutation&&s.domToMutation(i);var a=s.mutationToDom();a&&=Ot(a),r!==a&&(e.setRecordUndo$$module$build$src$core$events$utils(!1),C(new(T(L.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(wo(r)&&r.isProcedureDef()&&e.Names$$module$build$src$core$names.equals(r.getProcedureModel().getName(),t)||vn(r)&&e.Names$$module$build$src$core$names.equals(r.getProcedureDef()[0],t))return r;return null},Ro=function(e){return e.isDynamic},zo=function(e){return e.pathDown!==void 0&&e.pathUp!==void 0},Bo=function(e){return e.pathLeft!==void 0&&e.pathRight!==void 0},Vo=function(e,n){t(I.RENDERER,e,n)},Ho=function(e){r(I.RENDERER,e)},Uo=function(e,t,n){return e=new(o(I.RENDERER,e))(e),e.init(t,n),e},Wo=function(e){jn(e.getTargetWorkspace(),void 0,`String`)},Go=function(e){jn(e.getTargetWorkspace(),void 0,`Number`)},Ko=function(e){jn(e.getTargetWorkspace(),void 0,`Colour`)},qo=function(e){return Jo(e,!1)},Jo=function(t,n=!0){return uc.variables_set_dynamic||uc.variables_get_dynamic||console.warn(`There are no dynamic variable blocks, but there is a dynamic variable category.`),n?(xn(`The XML return value of Blockly.VariablesDynamic.flyoutCategory()`,`v12`,`v13`,`the same method, but handle a return type of FlyoutItemInfo[] (JSON) instead.`),Yo(t)):(t.registerButtonCallback(`CREATE_VARIABLE_STRING`,Wo),t.registerButtonCallback(`CREATE_VARIABLE_NUMBER`,Go),t.registerButtonCallback(`CREATE_VARIABLE_COLOUR`,Ko),[{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`},...Tn(t,t.getVariableMap().getAllVariables(),!1,`variables_get_dynamic`,`variables_set_dynamic`)])},Yo=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`,Wo),t.registerButtonCallback(`CREATE_VARIABLE_NUMBER`,Go),t.registerButtonCallback(`CREATE_VARIABLE_COLOUR`,Ko),t=Xo(t),n=n.concat(t)},Xo=function(t){t=t.getVariableMap().getAllVariables();let n=[];if(t.length>0){if(uc.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(Rn(r)),n.push(i)}if(uc.variables_get_dynamic){t.sort(Vn);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(Rn(a)),n.push(r)}}return n},Zo=function(e){e.resizeContents()},Qo=function(e,t){let n=e.toCopyData();return lv=n,uv=We(e)&&e.workspace instanceof j_?e.workspace:null,dv=t,n},$o=function(){return lv},es=function(e){lv=e},ts=function(){return uv},ns=function(e){uv=e},rs=function(){return dv},is=function(e){dv=e},as=function(e,t,n){return e&&t?os(e,t,n):lv&&uv?os(lv,uv,dv):null},os=function(e,t,n){return t=t.isMutator?t:t.options.parentWorkspace??t,s(I.PASTER,e.paster,!1)?.paste(e,t,n)??null},ss=function(e){return e&&typeof e.toCopyData==`function`},cs=function(){hl.registry.register({name:hv.ESCAPE,preconditionFn(e){return!e.isReadOnly()},callback(e){return e.hideChaff(),!0},keyCodes:[Bp.ESC]})},ls=function(){hl.registry.register({name:hv.DELETE,preconditionFn(t,n){return n=n.focusedNode,!t.isReadOnly()&&n!=null&&ho(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():ho(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:[Bp.DELETE,Bp.BACKSPACE]})},us=function(e){return ss(e)&&ho(e)&&So(e)?e.isCopyable?e.isCopyable():e instanceof Bm||e instanceof op?e.isOwnDeletable()&&e.isOwnMovable():e.isDeletable()&&e.isMovable():!1},ds=function(e){return us(e)&&ho(e)&&e.isDeletable()},fs=function(){let t=hl.registry.createSerializedKey(Bp.C,[Bp.CTRL_CMD]);hl.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()&&us(n)},callback(e,t,n,r){return t.preventDefault(),t=r.focusedNode,!t||!ss(t)||!us(t)||(e=e.isFlyout?e.targetWorkspace:e,!e)?!1:(t.workspace.isFlyout||e.hideChaff(),e=So(t)&&t.workspace==e?t.getRelativeToSurfaceXY():void 0,!!Qo(t,e))},keyCodes:[t]})},ps=function(){let t=hl.registry.createSerializedKey(Bp.X,[Bp.CTRL_CMD]);hl.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()&&ds(n)},callback(e,t,n,r){return e=r.focusedNode,!e||!ds(e)||!ss(e)?!1:(t=So(e)?e.getRelativeToSurfaceXY():void 0,t=Qo(e,t),e instanceof Bm?e.checkAndDelete():ho(e)&&e.dispose(),!!t)},keyCodes:[t]})},ms=function(){let t=hl.registry.createSerializedKey(Bp.V,[Bp.CTRL_CMD]);hl.registry.register({name:hv.PASTE,preconditionFn(){var t=ts();return!t||!t.rendered?!1:(t=t.isFlyout?t.targetWorkspace:t,!!$o()&&!!t&&!t.isReadOnly()&&!t.isDragging()&&!e.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken())},callback(e,t){if(e=$o(),!e)return!1;var n=ts();if(!n||(n=n.isFlyout?n.targetWorkspace:n,!n||n.isReadOnly()))return!1;if(t instanceof PointerEvent)return t=Tt(n,new R(t.clientX,t.clientY)),!!as(e,n,t);if(t=rs(),!t)return!!as(e,n);let{left:r,top:i,width:a,height:o}=n.getMetricsManager().getViewMetrics(!0);return new B(i,i+o,r,r+a).contains(t.x,t.y)?!!as(e,n):(t=new R(r+a/2,i+o/2),!!as(e,n,t))},keyCodes:[t]})},hs=function(){let t=hl.registry.createSerializedKey(Bp.Z,[Bp.CTRL_CMD]);hl.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]})},gs=function(){let t=hl.registry.createSerializedKey(Bp.Z,[Bp.CTRL_CMD,Bp.SHIFT]),n=hl.registry.createSerializedKey(Bp.Y,[Bp.CTRL]);hl.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]})},_s=function(){let t=hl.registry.createSerializedKey(Bp.ENTER,[Bp.CTRL_CMD]);hl.registry.register({name:hv.MENU,preconditionFn:e=>!e.isDragging(),callback:(t,n)=>{if(t=e.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode(),xo(t)){t.showContextMenu(n);let e;return(e=Yi())==null||e.highlightNext(),!0}return!1},keyCodes:[t]})},vs=function(){cs(),ls(),fs(),ps(),ms(),hs(),gs(),_s()},ys=function(e){let t=e.saveState();return e.getParameters().length&&(t.parameters=e.getParameters().map(e=>e.saveState())),t},bs=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},xs=function(e){let t=Object.create(null),n=c(I.SERIALIZER,!0);for(let r in n){let i=n[r]?.save(e);i&&(t[r]=i)}return t},Ss=function(t,n,{recordUndo:r=!1}={}){var i=c(I.SERIALIZER,!0);if(i){i=Object.entries(i).sort((e,t)=>t[1].priority-e[1].priority);var a=Ee();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),Le(),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),Re(),C(new(T(L.FINISHED_LOADING))(n)),e.setGroup$$module$build$src$core$events$utils(r),e.setRecordUndo$$module$build$src$core$events$utils(a)}},Cs=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 Cp(t||{}),r=document.createElement(`div`),D(r,`injectionDiv`),t!=null&&t.rtl&&D(r,`blocklyRTL`),n.appendChild(r),t=ws(r,e);let i=Ts(r,t,e);return Es(i),Ze(i),rt(i),r.addEventListener(`focusin`,function(){Ze(i)}),g(r,`keydown`,null,ct),i},ws=function(e,t){e.setAttribute(`dir`,`LTR`),dt(t.hasCss,t.pathToMedia);let n=E(z.SVG,{xmlns:$c,"xmlns:html":el,"xmlns:xlink":tl,version:`1.1`,class:`blocklySvg`},e),r=E(z.DEFS,{},n),i=String(Math.random()).substring(2);return t.gridPattern=tg.createDom(i,t.gridOptions,r,e),n},Ts=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&&D(e,i),(i=n.getTheme().getClassName())&&D(e,i),!r.hasCategories&&r.languageTree&&(e=n.addFlyout(z.SVG),Ie(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(fo(n)),rt(n),Oi(),gr(),Zr(),n},Es=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(){ii(),e.hideComponents(!0),Lr(),zi(),rt(e),mo(e)}),e.setResizeHandlerWrapper(n),Ds(),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&&Os(t.pathToMedia,e)},Ds=function(){$v||(g(document,`scroll`,null,function(){let e=qe();for(let t=0,n;n=e[t];t++)n instanceof j_&&n.updateInverseScreenCTM()}),_(document,`touchend`,null,d),_(document,`touchcancel`,null,d)),$v=!0},Os=function(e,t){t=t.getAudioManager(),t.load([`${e}click.mp3`],`click`),t.load([`${e}disconnect.mp3`],`disconnect`),t.load([`${e}delete.mp3`],`delete`)},ks=function(e){return!e||!e.isSimpleReporter()?!1:e.getFields().next().value?.isFullBlockField()},As=function(){Y.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:Y.ScopeType.WORKSPACE,id:`undoWorkspace`,weight:1})},js=function(){Y.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:Y.ScopeType.WORKSPACE,id:`redoWorkspace`,weight:2})},Ms=function(){Y.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:Y.ScopeType.WORKSPACE,id:`cleanWorkspace`,weight:3})},Ns=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}},Ps=function(){Y.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){Ns(!0,e.workspace.getTopBlocks(!0))},scopeType:Y.ScopeType.WORKSPACE,id:`collapseWorkspace`,weight:4})},Fs=function(){Y.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){Ns(!1,e.workspace.getTopBlocks(!0))},scopeType:Y.ScopeType.WORKSPACE,id:`expandWorkspace`,weight:5})},Is=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++)Is(e[n],t)}},Ls=function(e){let t=[];e=e.getTopBlocks(!0);for(let n=0;n<e.length;n++)Is(e[n],t);return t},Rs=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()?Rs(t,n):(r.dispose(!1,!0),setTimeout(Rs,10,t,n))),e.setGroup$$module$build$src$core$events$utils(!1)},zs=function(){Y.registry.register({displayText(t){return t.workspace?(t=Ls(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&&Ls(e.workspace).length>0?`enabled`:`disabled`},callback(t){if(t.workspace){t.workspace.cancelCurrentGesture();var n=Ls(t.workspace);n.length<2?Rs(n):fn(e.Msg$$module$build$src$core$msg.DELETE_ALL_BLOCKS.replace(`%1`,String(n.length)),function(e){e&&Rs(n)})}},scopeType:Y.ScopeType.WORKSPACE,id:`workspaceDelete`,weight:6})},Bs=function(){As(),js(),Ms(),Ps(),Fs(),zs()},Vs=function(){Y.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&&as(t,e.block.workspace)}},scopeType:Y.ScopeType.BLOCK,id:`blockDuplicate`,weight:1})},Hs=function(){Y.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)&&ks(e)?`hidden`:`enabled`},callback(e){(e=e.block)&&e.hasIcon(Th.TYPE)?e.setCommentText(null):e.setCommentText(``)},scopeType:Y.ScopeType.BLOCK,id:`blockComment`,weight:2})},Us=function(){Y.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:Y.ScopeType.BLOCK,id:`blockInline`,weight:3})},Ws=function(){Y.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:Y.ScopeType.BLOCK,id:`blockCollapseExpand`,weight:4})},Gs=function(){Y.registry.register({displayText(t){return t.block.hasDisabledReason(U)?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(U),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(U),U),e.setGroup$$module$build$src$core$events$utils(n)},scopeType:Y.ScopeType.BLOCK,id:`blockDisable`,weight:5})},Ks=function(){Y.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:Y.ScopeType.BLOCK,id:`blockDelete`,weight:6})},qs=function(){Y.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:Y.ScopeType.BLOCK,id:`blockHelp`,weight:7})},Js=function(){Y.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:Y.ScopeType.COMMENT,id:`commentDelete`,weight:6})},Ys=function(){Y.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&&as(t,e.comment.workspace)}},scopeType:Y.ScopeType.COMMENT,id:`commentDuplicate`,weight:1})},Xs=function(){Y.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 op(t),n.moveTo(Tt(t,new R(i.x,i.y))),e.getFocusManager$$module$build$src$core$focus_manager().focusNode(n),e.setGroup$$module$build$src$core$events$utils(!1))},scopeType:Y.ScopeType.WORKSPACE,id:`commentCreate`,weight:8})},Zs=function(){Vs(),Hs(),Us(),Ws(),Gs(),Ks(),qs()},Qs=function(){Ys(),Js(),Xs()},$s=function(){Bs(),Zs()},ec=function(e){return e&&typeof e.paste==`function`},tc=function(e){return e&&typeof e.getSvgRoot==`function`},nc=function(e){return e.isSelectable()},rc=function(e){Xe().hideChaff(e)},ic=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`},F||={},F.scope={},F.ASSUME_ES5=!1,F.ASSUME_ES6=!1,F.ASSUME_ES2020=!1,F.ASSUME_NO_NATIVE_MAP=!1,F.ASSUME_NO_NATIVE_SET=!1,F.ISOLATE_POLYFILLS=!1,F.FORCE_POLYFILL_PROMISE=!1,F.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1,F.INSTRUMENT_ASYNC_CONTEXT=!0,F.objectCreate=F.ASSUME_ES5||typeof Object.create==`function`?Object.create:function(e){var t=function(){};return t.prototype=e,new t},F.defineProperty=F.ASSUME_ES5||typeof Object.defineProperties==`function`?Object.defineProperty:function(e,t,n){return e==Array.prototype||e==Object.prototype||(e[t]=n.value),e},F.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`)},F.global=F.ASSUME_ES2020?globalThis:F.getGlobal(this),F.IS_SYMBOL_NATIVE=typeof Symbol==`function`&&typeof Symbol(`x`)==`symbol`,F.TRUST_ES6_POLYFILLS=!F.ISOLATE_POLYFILLS||F.IS_SYMBOL_NATIVE,F.polyfills={},F.propertyToPolyfillSymbol={},F.POLYFILL_PREFIX=`$jscp$`,F.TYPED_ARRAY_CLASSES=function(){var e=`Int8 Uint8 Uint8Clamped Int16 Uint16 Int32 Uint32 Float32 Float64`.split(` `);return F.global.BigInt64Array&&(e.push(`BigInt64`),e.push(`BigUint64`)),e}(),F.polyfillTypedArrayMethod=function(e,t,n,r){if(t)for(var i=0;i<F.TYPED_ARRAY_CLASSES.length;i++){var a=F.TYPED_ARRAY_CLASSES[i]+`Array.prototype.`+e;F.ISOLATE_POLYFILLS?F.polyfillIsolated(a,t,n,r):F.polyfillUnisolated(a,t,n,r)}},F.polyfill=function(e,t,n,r){t&&(F.ISOLATE_POLYFILLS?F.polyfillIsolated(e,t,n,r):F.polyfillUnisolated(e,t,n,r))},F.polyfillUnisolated=function(e,t,n,r){for(n=F.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&&F.defineProperty(n,e,{configurable:!0,writable:!0,value:t})},F.polyfillIsolated=function(e,t,n,r){var i=e.split(`.`);e=i.length===1,r=i[0],r=!e&&r in F.polyfills?F.polyfills:F.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=F.IS_SYMBOL_NATIVE&&n===`es6`?r[i]:null,t=t(n),t!=null&&(e?F.defineProperty(F.polyfills,i,{configurable:!0,writable:!0,value:t}):t!==n&&(F.propertyToPolyfillSymbol[i]===void 0&&(n=Math.random()*1e9>>>0,F.propertyToPolyfillSymbol[i]=F.IS_SYMBOL_NATIVE?F.global.Symbol(i):F.POLYFILL_PREFIX+n+`$`+i),F.defineProperty(r,F.propertyToPolyfillSymbol[i],{configurable:!0,writable:!0,value:t})))},F.getConstructImplementation=function(){function e(){function e(){}return new e,Reflect.construct(e,[],function(){}),new e instanceof e}if(F.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=F.objectCreate(n.prototype||Object.prototype),Function.prototype.apply.call(e,n,t)||n}},F.construct={valueOf:F.getConstructImplementation}.valueOf(),F.underscoreProtoCanBeSet=function(){var e={a:!0},t={};try{return t.__proto__=e,t.a}catch{}return!1},F.setPrototypeOf=F.ASSUME_ES6||F.TRUST_ES6_POLYFILLS&&typeof Object.setPrototypeOf==`function`?Object.setPrototypeOf:F.underscoreProtoCanBeSet()?function(e,t){if(e.__proto__=t,e.__proto__!==t)throw TypeError(e+` is not extensible`);return e}:null,F.inherits=function(e,t){if(e.prototype=F.objectCreate(t.prototype),e.prototype.constructor=e,F.ASSUME_ES6||F.setPrototypeOf){var n=F.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},F.arrayIteratorImpl=function(e){var t=0;return function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}},F.arrayIterator=function(e){return{next:F.arrayIteratorImpl(e)}},F.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 F.arrayIterator(e);throw Error(String(e)+` is not an iterable or ArrayLike`)},F.arrayFromIterator=function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n},F.arrayFromIterable=function(e){return e instanceof Array?e:F.arrayFromIterator(F.makeIterator(e))},F.generator={},F.generator.ensureIteratorResultIsObject_=function(e){if(!(e instanceof Object))throw TypeError(`Iterator result `+e+` is not an object`)},F.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},F.generator.Context.prototype.start_=function(){if(this.isRunning_)throw TypeError(`Generator is already running`);this.isRunning_=!0},F.generator.Context.prototype.stop_=function(){this.isRunning_=!1},F.generator.Context.prototype.jumpToErrorHandler_=function(){this.nextAddress=this.catchAddress_||this.finallyAddress_},F.generator.Context.prototype.next_=function(e){this.yieldResult=e},F.generator.Context.prototype.throw_=function(e){this.abruptCompletion_={exception:e,isException:!0},this.jumpToErrorHandler_()},F.generator.Context.prototype.getNextAddress=function(){return this.nextAddress},F.generator.Context.prototype.getNextAddress=F.generator.Context.prototype.getNextAddress,F.generator.Context.prototype.getYieldResult=function(){return this.yieldResult},F.generator.Context.prototype.getYieldResult=F.generator.Context.prototype.getYieldResult,F.generator.Context.prototype.return=function(e){this.abruptCompletion_={return:e},this.nextAddress=this.finallyAddress_},F.generator.Context.prototype.return=F.generator.Context.prototype.return,F.generator.Context.prototype.jumpThroughFinallyBlocks=function(e){this.abruptCompletion_={jumpTo:e},this.nextAddress=this.finallyAddress_},F.generator.Context.prototype.jumpThroughFinallyBlocks=F.generator.Context.prototype.jumpThroughFinallyBlocks,F.generator.Context.prototype.yield=function(e,t){return this.nextAddress=t,{value:e}},F.generator.Context.prototype.yield=F.generator.Context.prototype.yield,F.generator.Context.prototype.yieldAll=function(e,t){e=F.makeIterator(e);var n=e.next();if(F.generator.ensureIteratorResultIsObject_(n),n.done)this.yieldResult=n.value,this.nextAddress=t;else return this.yieldAllIterator_=e,this.yield(n.value,t)},F.generator.Context.prototype.yieldAll=F.generator.Context.prototype.yieldAll,F.generator.Context.prototype.jumpTo=function(e){this.nextAddress=e},F.generator.Context.prototype.jumpTo=F.generator.Context.prototype.jumpTo,F.generator.Context.prototype.jumpToEnd=function(){this.nextAddress=0},F.generator.Context.prototype.jumpToEnd=F.generator.Context.prototype.jumpToEnd,F.generator.Context.prototype.setCatchFinallyBlocks=function(e,t){this.catchAddress_=e,t!=null&&(this.finallyAddress_=t)},F.generator.Context.prototype.setCatchFinallyBlocks=F.generator.Context.prototype.setCatchFinallyBlocks,F.generator.Context.prototype.setFinallyBlock=function(e){this.catchAddress_=0,this.finallyAddress_=e||0},F.generator.Context.prototype.setFinallyBlock=F.generator.Context.prototype.setFinallyBlock,F.generator.Context.prototype.leaveTryBlock=function(e,t){this.nextAddress=e,this.catchAddress_=t||0},F.generator.Context.prototype.leaveTryBlock=F.generator.Context.prototype.leaveTryBlock,F.generator.Context.prototype.enterCatchBlock=function(e){return this.catchAddress_=e||0,e=this.abruptCompletion_.exception,this.abruptCompletion_=null,e},F.generator.Context.prototype.enterCatchBlock=F.generator.Context.prototype.enterCatchBlock,F.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},F.generator.Context.prototype.enterFinallyBlock=F.generator.Context.prototype.enterFinallyBlock,F.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},F.generator.Context.prototype.leaveFinallyBlock=F.generator.Context.prototype.leaveFinallyBlock,F.generator.Context.prototype.forIn=function(e){return new F.generator.Context.PropertyIterator(e)},F.generator.Context.prototype.forIn=F.generator.Context.prototype.forIn,F.generator.Context.PropertyIterator=function(e){for(var t in this.object_=e,this.properties_=[],e)this.properties_.push(t);this.properties_.reverse()},F.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},F.generator.Context.PropertyIterator.prototype.getNext=F.generator.Context.PropertyIterator.prototype.getNext,F.generator.Engine_=function(e){this.context_=new F.generator.Context,this.program_=e},F.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_())},F.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_())},F.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_())},F.generator.Engine_.prototype.yieldAllStep_=function(e,t,n){try{var r=e.call(this.context_.yieldAllIterator_,t);if(F.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_()},F.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}},F.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}},F.generator.createGenerator=function(e,t){return t=new F.generator.Generator_(new F.generator.Engine_(t)),F.setPrototypeOf&&e.prototype&&F.setPrototypeOf(t,e.prototype),t},F.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())})},F.asyncExecutePromiseGeneratorFunction=function(e){return F.asyncExecutePromiseGenerator(e())},F.asyncExecutePromiseGeneratorProgram=function(e){return F.asyncExecutePromiseGenerator(new F.generator.Generator_(new F.generator.Engine_(e)))},F.polyfill(`globalThis`,function(e){return e||F.global},`es_2020`,`es3`),F.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||=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`),F.checkEs6ConformanceViaProxy=function(){try{var e={},t=Object.create(new F.global.Proxy(e,{get:function(n,r,i){return n==e&&r==`q`&&i==t}}));return t.q===!0}catch{return!1}},F.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1,F.ES6_CONFORMANCE=F.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&F.checkEs6ConformanceViaProxy(),F.initSymbol=function(){},F.iteratorPrototype=function(e){return e={next:e},e[Symbol.iterator]=function(){return this},e},F.owns=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},F.MapEntry=function(){},F.polyfill(`Set.prototype.difference`,function(e){return e||function(e){F.checkIsSetInstance(this),F.checkIsSetLike(e);var t=F.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`),F.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`)},F.checkIsValidIterator=function(e){if(typeof e!=`object`||!e||typeof e.next!=`function`)throw TypeError(`Invalid iterator.`);return e},F.getSmallerAndLargerSets=function(e,t){return e.size<=t.size?{smallerSetIterator:e.keys(),largerSet:t}:{smallerSetIterator:F.checkIsValidIterator(t.keys()),largerSet:e}},F.checkIsSetInstance=function(e){if(!(e instanceof Set))throw TypeError(`Method must be called on an instance of Set.`)},F.iteratorFromArray=function(e,t){if(F.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},F.polyfill(`Array.prototype.values`,function(e){return e||function(){return F.iteratorFromArray(this,function(e,t){return t})}},`es8`,`es3`),F.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`),F.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`),F.polyfill(`Object.entries`,function(e){return e||function(e){var t=[],n;for(n in e)F.owns(e,n)&&t.push([n,e[n]]);return t}},`es8`,`es3`),F.polyfill(`Object.values`,function(e){return e||function(e){var t=[],n;for(n in e)F.owns(e,n)&&t.push(e[n]);return t}},`es8`,`es3`);var ac=Object.create(null),oc={typeMap:ac},sc=Object.create(null),cc=`default`,I=class{constructor(e){this.name=e}toString(){return this.name}};I.CONNECTION_CHECKER=new I(`connectionChecker`),I.CONNECTION_PREVIEWER=new I(`connectionPreviewer`),I.CURSOR=new I(`cursor`),I.EVENT=new I(`event`),I.FIELD=new I(`field`),I.INPUT=new I(`input`),I.RENDERER=new I(`renderer`),I.TOOLBOX=new I(`toolbox`),I.THEME=new I(`theme`),I.TOOLBOX_ITEM=new I(`toolboxItem`),I.FLYOUTS_VERTICAL_TOOLBOX=new I(`flyoutsVerticalToolbox`),I.FLYOUTS_HORIZONTAL_TOOLBOX=new I(`flyoutsHorizontalToolbox`),I.FLYOUT_INFLATER=new I(`flyoutInflater`),I.METRICS_MANAGER=new I(`metricsManager`),I.BLOCK_DRAGGER=new I(`blockDragger`),I.SERIALIZER=new I(`serializer`),I.ICON=new I(`icon`),I.PASTER=new I(`paster`),I.VARIABLE_MODEL=new I(`variableModel`),I.VARIABLE_MAP=new I(`variableMap`);var lc={DEFAULT:cc,TEST_ONLY:oc};lc.Type=I,lc.getAllItems=c,lc.getClass=o,lc.getClassFromOptions=l,lc.getObject=s,lc.hasItem=a,lc.register=t,lc.unregister=r;var uc=Object.create(null),dc=750,fc=`ontouchstart`in globalThis||!!(globalThis.document&&document.documentElement&&`ontouchstart`in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),pc=null,mc={mousedown:[`pointerdown`],mouseenter:[`pointerenter`],mouseleave:[`pointerleave`],mousemove:[`pointermove`],mouseout:[`pointerout`],mouseover:[`pointerover`],mouseup:[`pointerup`,`pointercancel`],touchend:[`pointerup`],touchcancel:[`pointercancel`]},hc=0,gc={TOUCH_ENABLED:fc,TOUCH_MAP:mc};gc.checkTouchIdentifier=h,gc.clearTouchIdentifier=f,gc.getTouchIdentifierFromEvent=m,gc.longStart=u,gc.longStop=d,gc.shouldHandleEvent=p;var _c,vc,yc,bc,xc,Sc,Cc,wc,Tc,Ec;(function(e){function t(e){return n.includes(e.toUpperCase())}_c=e;let n=_c.toUpperCase();vc=t(`JavaFX`),yc=t(`WebKit`),bc=t(`Gecko`)&&!yc,xc=t(`Android`),e=globalThis.navigator&&globalThis.navigator.maxTouchPoints,Sc=t(`iPad`)||t(`Macintosh`)&&e>0,Cc=t(`iPhone`)&&!Sc,wc=t(`Macintosh`),Tc=Sc||xc&&!t(`Mobile`)||t(`Silk`),Ec=!Tc&&(Cc||xc)})(globalThis.navigator&&globalThis.navigator.userAgent||``);var Dc=_c,Oc=vc,kc=bc,Ac=xc,jc=Sc,Mc=Cc,Nc=wc,Pc=Ec,Fc={ANDROID:Ac,GECKO:kc,IPAD:jc,IPHONE:Mc,JavaFx:Oc,MAC:Nc,MOBILE:Pc,raw:Dc},Ic=40,Lc=125,Rc={};Rc.bind=_,Rc.conditionalBind=g,Rc.getScrollDeltaPixels=te,Rc.isRightButton=ee,Rc.isTargetInput=y,Rc.mouseToSvg=b,Rc.unbind=v;var L;(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`})(L||={});var zc=[L.BLOCK_CREATE,L.BLOCK_MOVE,L.COMMENT_CREATE,L.COMMENT_MOVE],Bc={BUMP_EVENTS:zc};Bc.EventType=L;var Vc="!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Hc={genUid:()=>{let e=Vc.length,t=[];for(let n=0;n<20;n++)t[n]=Vc.charAt(Math.random()*e);return t.join(``)}},Uc=0,Wc={TEST_ONLY:Hc};Wc.genUid=re,Wc.getNextUniqueId=ne;var Gc={};Gc.isBlockChange=oe,Gc.isBlockCreate=ie,Gc.isBlockDelete=ae,Gc.isBlockDrag=de,Gc.isBlockFieldIntermediateChange=se,Gc.isBlockMove=ce,Gc.isBubbleOpen=pe,Gc.isClick=fe,Gc.isCommentChange=be,Gc.isCommentCollapse=we,Gc.isCommentCreate=ve,Gc.isCommentDelete=ye,Gc.isCommentDrag=Ce,Gc.isCommentMove=xe,Gc.isCommentResize=Se,Gc.isFinishedLoading=Te,Gc.isSelected=S,Gc.isThemeChange=ge,Gc.isToolboxItemSelect=he,Gc.isTrashcanOpen=me,Gc.isVarCreate=x,Gc.isVarDelete=le,Gc.isVarRename=ue,Gc.isViewportChange=_e;var Kc=``,qc=!0,Jc=0,Yc=`ORPHANED_BLOCK`,Xc=[],Zc={FIRE_QUEUE:Xc,enqueueEvent:ke,fireNow:Oe,fireInternal:De,setGroupInternal:Ne},Qc={TEST_ONLY:Zc};Qc.clearPendingUndo=je,Qc.disable=e.disable$$module$build$src$core$events$utils,Qc.disableOrphans=Fe,Qc.enable=e.enable$$module$build$src$core$events$utils,Qc.filter=Ae,Qc.fire=C,Qc.fromJson=w,Qc.get=T,Qc.getDescendantIds=Pe,Qc.getGroup=e.getGroup$$module$build$src$core$events$utils,Qc.getRecordUndo=Ee,Qc.isEnabled=Me,Qc.setGroup=e.setGroup$$module$build$src$core$events$utils,Qc.setRecordUndo=e.setRecordUndo$$module$build$src$core$events$utils;var $c=`http://www.w3.org/2000/svg`,el=`http://www.w3.org/1999/xhtml`,tl=`http://www.w3.org/1999/xlink`,nl;(function(e){e[e.ELEMENT_NODE=1]=`ELEMENT_NODE`,e[e.TEXT_NODE=3]=`TEXT_NODE`,e[e.COMMENT_NODE=8]=`COMMENT_NODE`})(nl||={});var rl=null,il=0,al=null,ol={HTML_NS:el};ol.NodeType=nl,ol.SVG_NS=$c,ol.XLINK_NS=tl,ol.addClass=D,ol.createSvgElement=E,ol.getFastTextWidth=Be,ol.getFastTextWidthWithSizeString=Ve,ol.getTextWidth=ze,ol.hasClass=A,ol.insertAfter=Ie,ol.measureFontMetrics=He,ol.removeClass=k,ol.removeClasses=O,ol.removeNode=j,ol.setCssTransform=M,ol.startTextWidthCache=Le,ol.stopTextWidthCache=Re;var sl=class{static findFocusedNode(e){var t=e.getRootFocusableNode();if(!t.canBeFocused())return null;var n=t.getFocusableElement();return A(n,sl.ACTIVE_CLASS_NAME)||A(n,sl.PASSIVE_CSS_CLASS_NAME)||(t=n.querySelector(this.ACTIVE_FOCUS_NODE_CSS_SELECTOR),(t instanceof HTMLElement||t instanceof SVGElement)&&(t=sl.findFocusableNodeFor(t,e)))?t:(n=n.querySelector(this.PASSIVE_FOCUS_NODE_CSS_SELECTOR),(n instanceof HTMLElement||n instanceof SVGElement)&&(e=sl.findFocusableNodeFor(n,e))?e:null)}static findFocusableNodeFor(e,t){if(!e.id||e.id===`null`||t.getNestedTrees().map(t=>sl.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?sl.findFocusableNodeFor(r,t):null)}};sl.ACTIVE_CLASS_NAME=`blocklyActiveFocus`,sl.PASSIVE_CSS_CLASS_NAME=`blocklyPassiveFocus`,sl.ACTIVE_FOCUS_NODE_CSS_SELECTOR=`.${sl.ACTIVE_CLASS_NAME}`,sl.PASSIVE_FOCUS_NODE_CSS_SELECTOR=`.${sl.PASSIVE_CSS_CLASS_NAME}`;var cl={};cl.FocusableTreeTraverser=sl;var ll=class{constructor(e,t){this.tree=e,this.rootShouldBeAutoTabbable=t}},ul=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=sl.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 ll(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=sl.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=sl.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=sl.findFocusableNodeFor(r,n);r=sl.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(),D(e,ul.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),k(e,ul.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}setNodeToVisualPassiveFocus(e){e=e.getFocusableElement(),k(e,ul.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),D(e,ul.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}removeHighlight(e){e=e.getFocusableElement(),k(e,ul.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),k(e,ul.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}static getFocusManager(){return ul.focusManager||=new ul(document.addEventListener),ul.focusManager}};ul.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME=`blocklyActiveFocus`,ul.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME=`blocklyPassiveFocus`,ul.focusManager=null;var dl={};dl.FocusManager=ul,dl.getFocusManager=e.getFocusManager$$module$build$src$core$focus_manager;var fl={};fl.isFocusableNode=Ue;var pl={};pl.isSelectable=We;var ml={};ml.deepMerge=Ge;var hl=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 Ge(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 hl.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 hl.modifierKeys))throw Error(t+` is not a valid modifier key.`)}createSerializedKey(e,t){let n=``;if(t){this.checkModifiers(t);for(let e in hl.modifierKeys)t.includes(hl.modifierKeys[e])&&(n!==``&&(n+=`+`),n+=e)}return n!==``&&e?n+=`+`+e:e&&(n=`${e}`),n}};hl.registry=new hl,(function(e){e=e.modifierKeys||={},e[e.Shift=16]=`Shift`,e[e.Control=17]=`Control`,e[e.Alt=18]=`Alt`,e[e.Meta=91]=`Meta`})(hl||={});var gl={};gl.ShortcutRegistry=hl;var _l=Object.create(null),vl,yl,bl=[],xl={defineBlocksWithJsonArrayInternal:st},Sl={TEST_ONLY:xl};Sl.createBlockDefinitionsFromJsonArray=e.createBlockDefinitionsFromJsonArray$$module$build$src$core$common,Sl.defineBlocks=e.defineBlocks$$module$build$src$core$common,Sl.defineBlocksWithJsonArray=ot,Sl.draggingConnections=bl,Sl.fireSelectedEvent=et,Sl.getAllWorkspaces=qe,Sl.getBlockTypeCounts=it,Sl.getMainWorkspace=Xe,Sl.getParentContainer=tt,Sl.getSelected=Qe,Sl.getWorkspaceById=Ke,Sl.globalShortcutHandler=ct,Sl.registerWorkspace=Je,Sl.setMainWorkspace=Ze,Sl.setParentContainer=nt,Sl.setSelected=$e,Sl.svgResize=rt,Sl.unregisterWorkpace=Ye;var Cl=class{constructor(){this.workspaceId=void 0,this.isUiEvent=!1,this.type=``,this.group=e.getGroup$$module$build$src$core$events$utils(),this.recordUndo=Ee()}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=Ke(this.workspaceId)),!e)throw Error(`Workspace is null. Event must have been generated from real Blockly events.`);return e}},wl={};wl.Abstract=Cl;var Tl=class extends Cl{constructor(e){super(),this.isBlank=!0,this.recordUndo=!1,this.isUiEvent=!0,this.isBlank=e===void 0,this.workspaceId=e||``}},El={};El.UiBase=Tl;var Dl=class extends Tl{constructor(e,t,n){t=e?e.workspace.id:t,t===null&&(t=void 0),super(t),this.type=L.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=Tl.fromJson(e,t,n??new Dl),t.targetType=e.targetType,t.blockId=e.blockId,t}},Ol;(function(e){e.BLOCK=`block`,e.WORKSPACE=`workspace`,e.ZOOM_CONTROLS=`zoom_controls`})(Ol||={}),t(I.EVENT,L.CLICK,Dl);var kl={};kl.Click=Dl,kl.ClickTarget=Ol;var Al={};Al.removeElem=lt;var jl=class{constructor(e){this.name=e}toString(){return this.name}};jl.POSITIONABLE=new jl(`positionable`),jl.DRAG_TARGET=new jl(`drag_target`),jl.DELETE_AREA=new jl(`delete_area`),jl.AUTOHIDEABLE=new jl(`autohideable`);var Ml=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();lt(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(),lt(this.componentData.get(e).capabilities,t),lt(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}};Ml.Capability=jl,(function(e){e=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`})(Ml||={});var Nl=Ml.ComponentWeight,Pl={};Pl.ComponentManager=Ml,Pl.ComponentWeight=Nl;var Fl=!1,Il=`
|
|
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
|
-
`,Ll={};Ll.inject=dt,Ll.register=ut;var R=class{constructor(e,t){this.x=e,this.y=t}clone(){return new R(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 R(e.x-t.x,e.y-t.y)}static sum(e,t){return new R(e.x+t.x,e.y+t.y)}},Rl={};Rl.Coordinate=R;var z=class{constructor(e){this.tagName=e}toString(){return this.tagName}};z.ANIMATE=new z(`animate`),z.CIRCLE=new z(`circle`),z.CLIPPATH=new z(`clipPath`),z.DEFS=new z(`defs`),z.FECOMPOSITE=new z(`feComposite`),z.FECOMPONENTTRANSFER=new z(`feComponentTransfer`),z.FEFLOOD=new z(`feFlood`),z.FEFUNCA=new z(`feFuncA`),z.FEGAUSSIANBLUR=new z(`feGaussianBlur`),z.FEPOINTLIGHT=new z(`fePointLight`),z.FESPECULARLIGHTING=new z(`feSpecularLighting`),z.FILTER=new z(`filter`),z.FOREIGNOBJECT=new z(`foreignObject`),z.G=new z(`g`),z.IMAGE=new z(`image`),z.LINE=new z(`line`),z.PATH=new z(`path`),z.PATTERN=new z(`pattern`),z.POLYGON=new z(`polygon`),z.RECT=new z(`rect`),z.SVG=new z(`svg`),z.TEXT=new z(`text`),z.TSPAN=new z(`tspan`);var zl={};zl.Svg=z;var B=class{constructor(e,t,n,r){this.top=e,this.bottom=t,this.left=n,this.right=r}static from(e){return new B(e.y,e.y+e.height,e.x,e.x+e.width)}clone(){return new B(this.top,this.bottom,this.left,this.right)}getHeight(){return this.bottom-this.top}getWidth(){return this.right-this.left}getOrigin(){return new R(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 B(e,e+n,r,r+t)}},Bl={};Bl.Rect=B;var V=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 V(Math.max(e.width,t.width),Math.max(e.height,t.height))}static min(e,t){return new V(Math.min(e.width,t.width),Math.min(e.height,t.height))}},Vl={};Vl.Size=V;var Hl={getSizeInternal:pt},Ul={TEST_ONLY:Hl};Ul.getBorderBox=vt,Ul.getComputedStyle=ht,Ul.getContainerOffsetToScrollInto=bt,Ul.getPageOffset=gt,Ul.getSize=ft,Ul.getViewportPageOffset=_t,Ul.scrollIntoContainerView=yt;var Wl=/translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*)?/,Gl=/transform:\s*translate(?:3d)?\(\s*([-+\d.e]+)\s*px([ ,]\s*([-+\d.e]+)\s*px)?/,Kl={TEST_ONLY:{XY_REGEX:Wl,XY_STYLE_REGEX:Gl}};Kl.getDocumentScroll=wt,Kl.getInjectionDivXY=St,Kl.getRelativeXY=xt,Kl.getViewportBBox=Ct,Kl.screenToWsCoordinates=Tt,Kl.wsToScreenCoordinates=Et;var ql=class{constructor(e,t,n,r,i){this.workspace=e,this.horizontal=t,this.oldHostMetrics=null,this.ratio=1,this.origin=new R(0,0),this.startDragHandle=this.handlePosition=this.handleLength=this.scrollbarLength=this.startDragMouse=0,this.containerVisible=this.isHandleVisible=!0,this.position=new R(0,0),this.onMouseMoveWrapper_=this.onMouseUpWrapper_=null,this.pair=n||!1,this.margin=i===void 0?ql.DEFAULT_SCROLLBAR_MARGIN:i,e=`blocklyScrollbar`+(this.horizontal?`Horizontal`:`Vertical`),r&&(e+=` `+r),this.outerSvg=E(z.SVG,{class:e}),r=E(z.G,{},this.outerSvg),this.svgBackground=E(z.RECT,{class:`blocklyScrollbarBackground`},r),e=Math.floor((ql.scrollbarThickness-5)/2),this.svgHandle=E(z.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`),Ie(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=ql.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_),j(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,M(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&&ql.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-=ql.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),t=e.absoluteLeft+this.margin,this.pair&&this.workspace.RTL&&(t+=ql.scrollbarThickness),this.setPosition(t,e.absoluteTop+e.viewHeight-ql.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-=ql.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),this.setPosition(this.workspace.RTL?e.absoluteLeft+this.margin:e.absoluteLeft+e.viewWidth-ql.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(),ee(e))e.stopPropagation();else{var t=b(e,this.workspace.getParentSvg(),this.workspace.getInverseScreenCTM());t=this.horizontal?t.x:t.y;var n=St(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(),ee(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_),null),this.onMouseMoveWrapper_&&=(v(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 R(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}};ql.scrollbarThickness=fc?25:15,ql.DEFAULT_SCROLLBAR_MARGIN=.5;var Jl={};Jl.Scrollbar=ql;var Yl={parseFromString:function(){throw Error(`DOMParser was not found in the global scope and was not properly injected using injectDependencies`)}},Xl={serializeToString:function(){throw Error(`XMLSerializer was not foundin the global scope and was not properly injected using injectDependencies`)}},{document:Zl,DOMParser:Ql,XMLSerializer:$l}=globalThis;Ql&&(Yl=new Ql),$l&&(Xl=new $l);var eu=`https://developers.google.com/blockly/xml`,tu=/[\x00-\x09\x0B\x0C\x0E-\x1F]/g,nu={NAME_SPACE:eu};nu.createElement=e.createElement$$module$build$src$core$utils$xml,nu.createTextNode=e.createTextNode$$module$build$src$core$utils$xml,nu.domToText=Ot,nu.injectDependencies=Dt,nu.textToDom=e.textToDom$$module$build$src$core$utils$xml;var ru=`categoryToolbox`,iu=`flyoutToolbox`,H;(function(e){e[e.TOP=0]=`TOP`,e[e.BOTTOM=1]=`BOTTOM`,e[e.LEFT=2]=`LEFT`,e[e.RIGHT=3]=`RIGHT`})(H||={});var au={hasCategoriesInternal:Pt},ou={};ou.Position=H,ou.TEST_ONLY=au,ou.convertFlyoutDefToJsonArray=Mt,ou.convertToolboxDefToJson=At,ou.hasCategories=Nt,ou.isCategoryCollapsible=Ft,ou.parseToolboxTree=zt;var su;(function(e){e[e.TOP=0]=`TOP`,e[e.BOTTOM=1]=`BOTTOM`})(su||={});var cu;(function(e){e[e.LEFT=0]=`LEFT`,e[e.RIGHT=1]=`RIGHT`})(cu||={});var lu;(function(e){e[e.UP=0]=`UP`,e[e.DOWN=1]=`DOWN`})(lu||={});var uu={};uu.bumpDirection=lu,uu.bumpPositionRect=Ht,uu.getCornerOppositeToolbox=Vt,uu.getStartPositionRect=Bt,uu.horizontalPosition=cu,uu.verticalPosition=su;var du={width:96,height:124,url:`sprites.png`},fu=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=E(z.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:Ml.ComponentWeight.ZOOM_CONTROLS_WEIGHT,capabilities:[Ml.Capability.POSITIONABLE]}),this.initialized=!0}dispose(){this.workspace.getComponentManager().removeComponent(`zoomControls`),this.svgGroup&&j(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 B(this.top,this.top+e,this.left,this.left+this.WIDTH)}position(e,t){if(this.initialized){var n=Vt(this.workspace,e),r=this.SMALL_SPACING+2*this.HEIGHT;if(this.zoomResetGroup&&(r+=this.LARGE_SPACING+this.HEIGHT),e=Bt(n,new V(this.WIDTH,r),this.MARGIN_HORIZONTAL,this.MARGIN_VERTICAL,e,this.workspace),n=n.vertical,t=Ht(e,this.MARGIN_VERTICAL,n===su.TOP?lu.DOWN:lu.UP,t),n===su.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=E(z.G,{class:`blocklyZoom blocklyZoomOut`},this.svgGroup);let t=E(z.CLIPPATH,{id:`blocklyZoomoutClipPath`+e},this.zoomOutGroup);E(z.RECT,{width:32,height:32},t),E(z.IMAGE,{width:du.width,height:du.height,x:-64,y:-92,"clip-path":`url(#blocklyZoomoutClipPath`+e+`)`},this.zoomOutGroup).setAttributeNS(tl,`xlink:href`,this.workspace.options.pathToMedia+du.url),this.boundEvents.push(g(this.zoomOutGroup,`pointerdown`,null,this.zoom.bind(this,-1)))}createZoomInSvg(e){this.zoomInGroup=E(z.G,{class:`blocklyZoom blocklyZoomIn`},this.svgGroup);let t=E(z.CLIPPATH,{id:`blocklyZoominClipPath`+e},this.zoomInGroup);E(z.RECT,{width:32,height:32},t),E(z.IMAGE,{width:du.width,height:du.height,x:-32,y:-92,"clip-path":`url(#blocklyZoominClipPath`+e+`)`},this.zoomInGroup).setAttributeNS(tl,`xlink:href`,this.workspace.options.pathToMedia+du.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=E(z.G,{class:`blocklyZoom blocklyZoomReset`},this.svgGroup);let t=E(z.CLIPPATH,{id:`blocklyZoomresetClipPath`+e},this.zoomResetGroup);E(z.RECT,{width:32,height:32},t),E(z.IMAGE,{width:du.width,height:du.height,y:-92,"clip-path":`url(#blocklyZoomresetClipPath`+e+`)`},this.zoomResetGroup).setAttributeNS(tl,`xlink:href`,this.workspace.options.pathToMedia+du.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(T(L.CLICK))(null,this.workspace.id,`zoom_controls`);C(e)}};ut(`
|
|
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 pu={};pu.ZoomControls=fu;var mu=100,hu=75,gu=50,_u=25,vu={BLOCKS:gu,PROCEDURES:hu,VARIABLES:mu,WORKSPACE_COMMENTS:_u},yu={};yu.register=Ut,yu.unregister=Wt;var bu=class{constructor(){this.priority=_u}save(e){let t=[];for(let n of e.getTopComments())(e=Gt(n,{addCoordinates:!0,saveIds:!0}))&&t.push(e);return t.length?t:null}load(e,t){for(let n of e)Kt(n,t,{recordUndo:Ee()})}clear(e){for(let t of e.getTopComments())t.dispose()}};Ut(`workspaceComments`,new bu);var xu={};xu.WorkspaceCommentSerializer=bu,xu.append=Kt,xu.save=Gt;var Su={};Su.register=qt,Su.unregister=Jt;var Cu=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=Kt(t,n),Yt(i)}finally{e.enable$$module$build$src$core$events$utils()}return i?(Me()&&C(new(T(L.COMMENT_CREATE))(i)),e.getFocusManager$$module$build$src$core$focus_manager().focusNode(i),i):null}};Cu.TYPE=`workspace-comment`,qt(Cu.TYPE,new Cu);var wu={};wu.WorkspaceCommentPaster=Cu;var Tu=28;e.config$$module$build$src$core$config={dragRadius:5,flyoutDragRadius:10,snapRadius:Tu,connectingSnapRadius:Tu,currentConnectionPreference:8,bumpDelay:250},e.config$$module$build$src$core$config;var Eu=`aria-`,Du=`role`,Ou;(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`})(Ou||={});var ku;(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`})(ku||={});var Au={};Au.Role=Ou,Au.State=ku,Au.setRole=Zt,Au.setState=Qt;var ju=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&&Zt(e,this.roleName),Qt(e,ku.SELECTED,this.checkable&&this.checked||!1),Qt(e,ku.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),Qt(e,ku.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),Qt(e,ku.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()}}},Mu={};Mu.MenuItem=ju;var Nu=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&&Zt(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),null),this.clickHandler&&=(v(this.clickHandler),null),this.pointerEnterHandler&&=(v(this.pointerEnterHandler),null),this.pointerLeaveHandler&&=(v(this.pointerLeaveHandler),null),this.onKeyDownHandler&&=(v(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&&(yt(n,t),Qt(t,ku.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 R(e.clientX,e.clientY);if(R.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=ft(e);return t.height=e.scrollHeight,t}getMenuItems(){return this.menuItems.filter(e=>e instanceof ju)}},Pu={};Pu.Menu=Nu;var Fu=class{constructor(){this.element=null}createDom(){return this.element=document.createElement(`hr`),this.element.className=`blocklyMenuSeparator`,Zt(this.element,Ou.SEPARATOR),this.element}dispose(){let e;(e=this.element)==null||e.remove(),this.element=null}},Iu={};Iu.MenuSeparator=Fu;var Lu=`_TEMP_COLLAPSED_INPUT`,Ru=`_TEMP_COLLAPSED_FIELD`,U=`MANUALLY_DISABLED`,zu={COLLAPSED_FIELD_NAME:Ru,COLLAPSED_INPUT_NAME:Lu,MANUALLY_DISABLED:U};(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||={});var Bu={};Bu.inputTypes=e.inputTypes$$module$build$src$core$inputs$input_types;var Vu={};Vu.isSerializable=$t;var Hu=new Set,Uu=new WeakSet,Wu=new WeakMap,W=null,Gu=null,Ku=0,qu={};qu.finishQueuedRenders=tn,qu.queueRender=en,qu.triggerQueuedRenders=nn;var Ju,Yu;e.Msg$$module$build$src$core$msg=Object.create(null),Ju=function(t){Object.keys(t).forEach(function(n){e.Msg$$module$build$src$core$msg[n]=t[n]})},Yu={Msg:e.Msg$$module$build$src$core$msg,setLocale:Ju};var Xu=`blocklyToast`,Zu=`blocklyToastMessage`,Qu=`blocklyToastCloseButton`,$u=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=$u.Assertiveness.POLITE}=n,o=document.createElement(`div`);t.getInjectionDiv().appendChild(o),o.dataset.toastId=n.id,o.className=Xu,Zt(o,Ou.STATUS),Qt(o,ku.LIVE,a),n=o.appendChild(document.createElement(`div`)),n.className=Zu,n.innerText=r,n=o.appendChild(document.createElement(`button`)),n.className=Qu,Qt(n,ku.LABEL,e.Msg$$module$build$src$core$msg.CLOSE);var s=E(z.SVG,{width:24,height:24,viewBox:`0 0 24 24`,fill:`none`},n);Qt(s,ku.HIDDEN,!0),E(z.RECT,{x:19.7782,y:2.80762,width:2,height:24,transform:`rotate(45, 19.7782, 2.80762)`,fill:`black`},s),E(z.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(`.${Xu}`),e instanceof HTMLElement&&(!t||t===e.dataset.toastId)&&e.remove()}};$u.shownIds=new Set,(function(e){e=e.Assertiveness||={},e.ASSERTIVE=`assertive`,e.POLITE=`polite`})($u||={}),ut(`
|
|
472
|
-
.${Xu} {
|
|
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
|
-
.${Xu} .${Zu} {
|
|
491
|
-
maxWidth: 18rem;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
.${Xu} .${Qu} {
|
|
495
|
-
margin: 0;
|
|
496
|
-
padding: 0.2rem;
|
|
497
|
-
background-color: transparent;
|
|
498
|
-
color: black;
|
|
499
|
-
border: none;
|
|
500
|
-
cursor: pointer;
|
|
501
|
-
}
|
|
502
|
-
`);var ed={};ed.Toast=$u;var td=function(e,t){window.alert(e),t&&t()},nd=td,rd=function(e,t){t(window.confirm(e))},id=rd,ad=function(e,t,n){n(window.prompt(e,t))},od=ad,sd=$u.show.bind($u),cd=sd,ld={};ld.alert=un,ld.confirm=fn,ld.prompt=mn,ld.setAlert=dn,ld.setConfirm=pn,ld.setPrompt=hn,ld.setToast=_n,ld.toast=gn;var ud={};ud.isLegacyProcedureCallBlock=yn,ud.isLegacyProcedureDefBlock=vn;var dd={};dd.isVariableBackedParameterModel=bn;var fd=new Set,pd={};pd.warn=xn;var md=`VARIABLE`,hd=`ijkmnopqrstuvwxyzabcdefgh`,gd={generateUniqueNameInternal:kn},_d={CATEGORY_NAME:md,TEST_ONLY:gd,VAR_LETTER_OPTIONS:hd};_d.allDeveloperVariables=e.allDeveloperVariables$$module$build$src$core$variables,_d.allUsedVarModels=e.allUsedVarModels$$module$build$src$core$variables,_d.compareByName=Vn,_d.createVariableButtonHandler=jn,_d.deleteVariable=e.deleteVariable$$module$build$src$core$variables,_d.flyoutCategory=Cn,_d.flyoutCategoryBlocks=Dn,_d.generateUniqueName=On,_d.generateUniqueNameFromOptions=An,_d.generateVariableFieldDom=Rn,_d.getAddedVariables=Bn,_d.getOrCreateVariablePackage=e.getOrCreateVariablePackage$$module$build$src$core$variables,_d.getVariable=e.getVariable$$module$build$src$core$variables,_d.getVariableUsesById=Hn,_d.internalFlyoutCategory=Sn,_d.jsonFlyoutCategoryBlocks=Tn,_d.nameUsedWithAnyType=Pn,_d.nameUsedWithConflictingParam=Fn,_d.promptName=Mn,_d.renameVariable=e.renameVariable$$module$build$src$core$variables;var vd=class extends Error{},yd=class extends vd{constructor(e){super(`Expected to find a 'type' property, defining the block type`),this.state=e}},bd=class extends vd{constructor(e,t,n){super(`The block ${t.toDevString()} is missing a(n) ${e}
|
|
503
|
-
connection`),this.block=t,this.state=n}},G=class extends vd{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}},xd=class extends vd{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}},K=class extends vd{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}},Sd={};Sd.BadConnectionCheck=G,Sd.DeserializationError=vd,Sd.MissingBlockType=yd,Sd.MissingConnection=bd,Sd.RealChildOfShadow=xd,Sd.UnregisteredIcon=K;var Cd=class{constructor(){this.priority=gu}save(e){let t=[];for(let n of e.getTopBlocks(!1))(e=Un(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)Qn(n,t,{recordUndo:Ee()})}clear(e){for(let t of e.getTopBlocks(!1))t.dispose(!1)}};Ut(`blocks`,new Cd);var wd={};wd.BlockSerializer=Cd,wd.append=Qn,wd.appendInternal=$n,wd.save=Un;var q=class{constructor(e){this.name=e}toString(){return this.name}equals(e){return this.name===e.toString()}};q.MUTATOR=new q(`mutator`),q.WARNING=new q(`warning`),q.COMMENT=new q(`comment`);var Td={};Td.IconType=q;var Ed={};Ed.hasBubble=fr;var Dd=class extends Cl{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=Cl.fromJson(e,t,n??new Dd),t.blockId=e.blockId,t}},Od={};Od.BlockBase=Dd;var kd=class extends Dd{constructor(e,t,n,r,i){super(e),this.type=L.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=Dd.fromJson(e,t,n??new kd),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(q.MUTATOR);switch(r&&fr(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)??U);break;case`inline`:n.setInputsInline(!!t);break;case`mutation`:i=kd.getExtraBlockState_(n),n.loadExtraState?n.loadExtraState(JSON.parse(t||`{}`)):n.domToMutation&&n.domToMutation(e.textToDom$$module$build$src$core$utils$xml(t||`<mutation/>`)),C(new kd(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())?sa(e):``}};t(I.EVENT,L.BLOCK_CHANGE,kd);var Ad={};Ad.BlockChange=kd;var jd={};jd.clamp=hr,jd.toDegrees=mr,jd.toRadians=pr;var Md=16,Nd=1,Pd=12,Fd=16,Id=.25,Ld=null,Rd=null,zd=``,Bd=``,Vd,Hd,Ud,Wd=null,Gd=null,Kd=null,qd=null,Jd=null,Yd={getBoundsInfo:function(){let e=gt(Wd),t=ft(Wd);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=Yd.getBoundsInfo(),a=ft(Vd);return t+a.height<i.bottom?Or(e,t,i,a):r-a.height>i.top?kr(n,r,i,a):t+a.height<document.documentElement.clientHeight?Or(e,t,i,a):r-a.height>document.documentElement.clientTop?kr(n,r,i,a):Ar(e,i,a)}},Xd={ANIMATION_TIME:Id,ARROW_HORIZONTAL_PADDING:Pd,ARROW_SIZE:Md,BORDER_SIZE:Nd,PADDING_Y:Fd,TEST_ONLY:Yd};Xd.clearContent=br,Xd.createDom=gr,Xd.getContentDiv=yr,Xd.getOwner=vr,Xd.getPositionX=jr,Xd.hide=Pr,Xd.hideIfOwner=Nr,Xd.hideWithoutAnimation=Fr,Xd.isVisible=Mr,Xd.repositionForWindowResize=Lr,Xd.setBoundsElement=_r,Xd.setColour=xr,Xd.show=Dr,Xd.showPositionedByBlock=Sr,Xd.showPositionedByField=Cr;var Zd={};Zd.commonWordPrefix=zr,Zd.commonWordSuffix=Br,Zd.isNumber=e.isNumber$$module$build$src$core$utils$string,Zd.shortestStringLength=Rr,Zd.wrap=e.wrap$$module$build$src$core$utils$string;var Qd=void 0,$d=!1,ef=!1,tf=50,nf=0,rf=0,af=0,of=0,sf=null,cf=null,lf=0,uf=10,J=10,df=750,ff=5,pf=null,mf={HOVER_MS:df,LIMIT:tf,MARGINS:ff,OFFSET_X:lf,OFFSET_Y:uf,RADIUS_OK:J};mf.bindMouseEvents=Qr,mf.block=ai,mf.createDom=Zr,mf.dispose=ri,mf.getCustomTooltip=Kr,mf.getDiv=Jr,mf.getTooltipOfObject=Yr,mf.hide=ii,mf.isVisible=qr,mf.setCustomTooltip=Gr,mf.unbindMouseEvents=$r,mf.unblock=oi;var hf=.45,gf=.65,_f={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`},vf={};vf.blend=yi,vf.getHsvSaturation=di,vf.getHsvValue=pi,vf.hexToRgb=_i,vf.hsvToHex=vi,vf.hueToHex=bi,vf.names=_f,vf.parse=hi,vf.rgbToHex=gi,vf.setHsvSaturation=fi,vf.setHsvValue=mi;var yf={};yf.checkMessageReferences=wi,yf.parseBlockColour=Ti,yf.replaceMessageReferences=Ci,yf.tokenizeInterpolation=Si;var bf=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 V(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 V(0,0),e!==bf.SKIP_SETUP&&(n&&this.configure_(n),this.setValue(e),t&&this.setValidator(t))}configure_(e){e.tooltip&&this.setTooltip(Ci(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_=E(z.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_&&D(this.fieldGroup_,`blocklyField`)}initModel(){}isFullBlockField(){return!this.borderRect_}createBorderRect_(){this.borderRect_=E(z.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_=E(z.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.`);Qr(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(bf),e===null?this.getValue():e}loadState(e){this.loadLegacyState(bf,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||``),Ot(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(){Nr(this),Mi(this);let e;(e=this.getSourceBlock())!=null&&e.isDeadOrDying()||j(this.fieldGroup_),this.disposed=!0}updateEditable(){let e=this.fieldGroup_,t=this.getSourceBlock();this.EDITABLE&&e&&t&&(this.enabled_&&t.isEditable()?(D(e,`blocklyEditableField`),k(e,`blocklyNonEditableField`)):(D(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_!==bf.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=ze(this.textElement_),n+=i),this.isFullBlockField()||(r=Math.max(r,t.FIELD_BORDER_RECT_HEIGHT)),this.size_=new V(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_(),!1),this.size_):new V(0,0)}getScaledBBox(){let e;var t=this.getSourceBlock();if(!t)throw new xf;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,kc?(e.x+=1.5*r,e.y+=1.5*r):(e.x-=.5*r,e.y-=.5*r)}else n=this.borderRect_.getBoundingClientRect(),e=gt(this.borderRect_),t=n.width,n=n.height;return new B(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,bf.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&&Me()&&C(new(T(L.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 Yr(e||{tooltip:this.tooltip})}getClickTarget_(){return this.clickTarget_||this.getSvgRoot()}getAbsoluteXY_(){return gt(this.getClickTarget_())}referencesVariables(){return!1}refreshVariableName(){}getParentInput(){let e=null,t=this.getSourceBlock();if(!t)throw new xf;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 xf;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.`)}};bf.NBSP=`\xA0`,bf.SKIP_SETUP=Symbol(`SKIP_SETUP`);var xf=class extends Error{constructor(){super(`The field has not yet been attached to its input. Call appendField to attach it.`)}},Sf={};Sf.Field=bf,Sf.UnattachedFieldError=xf;var Cf=null,wf=null,Tf=null,Ef=`blocklyWidgetDiv`,Df=``,Of=``,kf,Af=null,jf={};jf.createDom=Oi,jf.getDiv=Ei,jf.hide=Ai,jf.hideIfOwner=Mi,jf.hideIfOwnerIsInWorkspace=Ni,jf.isVisible=ji,jf.positionWithAnchor=Fi,jf.repositionForWindowResize=zi,jf.show=ki,jf.testOnly_setDiv=Di;var Mf=null,Nf={},Pf=null,Ff={};Ff.callbackFactory=e.callbackFactory$$module$build$src$core$contextmenu,Ff.dispose=Ji,Ff.getCurrentBlock=Bi,Ff.getMenu=Yi,Ff.hide=qi,Ff.setCurrentBlock=Vi,Ff.show=Hi;var Y=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===If.BLOCK&&!e.block||r.scopeType===If.COMMENT&&!e.comment||r.scopeType===If.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||={};t.BLOCK=`block`,t.WORKSPACE=`workspace`,t.COMMENT=`comment`,e.registry=new e})(Y||={});var If=Y.ScopeType,Lf={};Lf.ContextMenuRegistry=Y,Lf.ScopeType=If;var Rf=50,zf=100,Bf={BLOCK:Rf,BUBBLE:zf},Vf=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,Rf),this.comment.setDragging(!1),this.comment.snapToGrid(),this.workspace.setResizesEnabled(!0)}fireDragStartEvent(){let e=new(T(L.COMMENT_DRAG))(this.comment,!0);C(e)}fireDragEndEvent(){let e=new(T(L.COMMENT_DRAG))(this.comment,!1);C(e)}fireMoveEvent(){if(!this.comment.isDeadOrDying()){var e=new(T(L.COMMENT_MOVE))(this.comment);e.setReason([`drag`]),e.oldCoordinate_=this.startLoc,e.recordNew(),C(e)}}revertDrag(){this.startLoc&&this.comment.moveDuringDrag(this.startLoc)}},Hf={};Hf.CommentDragStrategy=Vf;var Uf=new WeakMap,Wf={};Wf.move=Qi,Wf.start=Zi;var Gf=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=B.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 B(t.y,t.y+n.height,t.x,t.x+n.width),e.workspace.scrollBoundsIntoView(t)}onNodeBlur(){}canBeFocused(){return this.isVisible()}},Kf={};Kf.CommentBarButton=Gf;var qf=`_collapse_bar_button`,Jf=class extends Gf{constructor(e,t,n,r){super(e,t,n,r),this.id=e,this.workspace=t,this.container=n,this.commentView=r,this.icon=E(z.IMAGE,{class:`blocklyFoldoutIcon`,href:`${this.workspace.options.pathToMedia}foldout-icon.svg`,id:`${this.id}${qf}`},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&&ee(e)?e.stopPropagation():(this.getCommentView().setCollapsed(!this.getCommentView().isCollapsed()),this.workspace.hideChaff(),e?.stopPropagation())}},Yf={COMMENT_COLLAPSE_BAR_BUTTON_FOCUS_IDENTIFIER:qf};Yf.CollapseCommentBarButton=Jf;var Xf=`_comment_textarea_`,Zf=class{constructor(t,n,r){this.workspace=t,this.onFinishEditing=r,this.textChangeListeners=[],this.text=``,this.foreignObject=E(z.FOREIGNOBJECT,{class:`blocklyCommentForeignObject`}),t=document.createElementNS(el,`body`),t.setAttribute(`xmlns`,el),t.className=`blocklyMinimalBody`,this.textArea=document.createElementNS(el,`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),D(this.textArea,`blocklyCommentText`),D(this.textArea,`blocklyTextarea`),D(this.textArea,`blocklyText`),t.appendChild(this.textArea),this.foreignObject.appendChild(t),n&&(this.id=n+Xf,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=B.from(this.foreignObject.getBoundingClientRect());this.workspace.scrollBoundsIntoView(B.createFromPoint(Tt(this.workspace,e.getOrigin()),e.getWidth(),e.getHeight()))}onNodeBlur(){}canBeFocused(){return!!this.id}},Qf={COMMENT_EDITOR_FOCUS_IDENTIFIER:Xf};Qf.CommentEditor=Zf;var $f=`_delete_bar_button`,ep=class extends Gf{constructor(e,t,n,r){super(e,t,n,r),this.id=e,this.workspace=t,this.container=n,this.commentView=r,this.icon=E(z.IMAGE,{class:`blocklyDeleteIcon`,href:`${this.workspace.options.pathToMedia}delete-icon.svg`,id:`${this.id}${$f}`},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&&ee(t)?t.stopPropagation():(this.getCommentView().dispose(),t?.stopPropagation(),e.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.workspace))}},tp={COMMENT_DELETE_BAR_BUTTON_FOCUS_IDENTIFIER:$f};tp.DeleteCommentBarButton=ep;var np=class{constructor(e,t){this.workspace=e,this.commentId=t,this.collapsed=!1,this.editable=!0,this.location=new R(0,0),this.sizeChangeListeners=[],this.disposeListeners=[],this.collapseChangeListeners=[],this.resizePointerMoveListener=this.resizePointerUpListener=null,this.disposed=this.disposing=!1,this.svgRoot=E(z.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,Rf),this.size=np.defaultCommentSize,this.setSizeWithoutFiringEvents(this.size),this.moveTo(new R(0,0))}createHighlightRect(e){return E(z.RECT,{class:`blocklyCommentHighlight`},e)}createTopBar(e){e=E(z.G,{class:`blocklyCommentTopbar`},e);let t=E(z.RECT,{class:`blocklyCommentTopbarBackground`},e),n=new ep(this.commentId,this.workspace,e,this),r=new Jf(this.commentId,this.workspace,e,this);this.addDisposeListener(()=>{n.dispose(),r.dispose()});let i=E(z.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 Zf(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=E(z.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=V.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=ze(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 V(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(),ee(e)||(this.preResizeSize=this.getSize(),Zi(this.workspace,e,new R(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),null),this.resizePointerMoveListener&&=(v(this.resizePointerMoveListener),null),this.setSize(this.size),this.preResizeSize=void 0}onResizePointerMove(e){e=Qi(this.workspace,e),this.setSizeWithoutFiringEvents(new V(this.workspace.RTL?-e.x:e.x,e.y))}isCollapsed(){return this.collapsed}setCollapsed(e){(this.collapsed=e)?D(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)?(D(this.svgRoot,`blocklyEditable`),k(this.svgRoot,`blocklyReadonly`)):(k(this.svgRoot,`blocklyEditable`),D(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(),ee(e)||this.dispose(),e.stopPropagation()}dispose(){this.disposing=!0,j(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]}};np.defaultCommentSize=new V(120,100),ut(`
|
|
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 rp={};rp.CommentView=np;var ip=class{constructor(e,t){this.workspace=e,this.text=``,this.collapsed=!1,this.deletable=this.movable=this.editable=!0,this.location=new R(0,0),this.disposing=this.disposed=!1,this.id=t&&!e.getCommentById(t)?t:re(),this.size=np.defaultCommentSize,e.addTopComment(this),this.fireCreateEvent()}fireCreateEvent(){Me()&&C(new(T(L.COMMENT_CREATE))(this))}fireDeleteEvent(){Me()&&C(new(T(L.COMMENT_DELETE))(this))}fireChangeEvent(e,t){Me()&&C(new(T(L.COMMENT_CHANGE))(this,e,t))}fireCollapseEvent(e){Me()&&C(new(T(L.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(T(L.COMMENT_RESIZE))(this);this.size=e,t.recordCurrentSizeAsNewSize(),C(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(T(L.COMMENT_MOVE))(this);t&&n.setReason(t),this.location=e,n.recordNew(),C(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}},ap={};ap.WorkspaceComment=ip;var op=class extends ip{constructor(e,t){super(e,t),this.dragStrategy=new Vf(this),this.workspace=e,this.view=new np(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 B(e.y,e.y+r.height,t,n)}moveBy(e,t,n){let r=this.getRelativeToSurfaceXY();e=new R(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?D(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?D(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(){D(this.getSvgRoot(),`blocklySelected`),et(this)}unselect(){k(this.getSvgRoot(),`blocklySelected`),et(null)}toCopyData(){return{paster:Cu.TYPE,commentState:Gt(this,{addCoordinates:!0,saveIds:!1})}}showContextMenu(e){let t=Y.registry.getContextMenuOptions({comment:this,focusedNode:this},e),n;n=e instanceof PointerEvent?new R(e.clientX,e.clientY):Et(this.workspace,this.getRelativeToSurfaceXY()).translate(10,10),Hi(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}},sp={};sp.RenderedWorkspaceComment=op;var cp={};cp.appendDomToWorkspace=da,cp.blockToDom=aa,cp.blockToDomWithXY=na,cp.clearWorkspaceAndLoadFromXml=la,cp.deleteNext=wa,cp.domToBlock=e.domToBlock$$module$build$src$core$xml,cp.domToBlockInternal=fa,cp.domToPrettyText=ca,cp.domToText=sa,cp.domToVariables=pa,cp.domToWorkspace=e.domToWorkspace$$module$build$src$core$xml,cp.loadWorkspaceComment=ua,cp.saveWorkspaceComment=ea,cp.variablesToDom=ta,cp.workspaceToDom=$i;var lp=class extends Dd{constructor(e){super(e),this.type=L.BLOCK_CREATE,e&&(e.isShadow()&&(this.recordUndo=!1),this.xml=na(e),this.ids=Pe(e),this.json=Un(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=sa(this.xml),e.ids=this.ids,e.json=this.json,this.recordUndo||(e.recordUndo=this.recordUndo),e}static fromJson(t,n,r){return n=Dd.fromJson(t,n,r??new lp),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(!up(t,this.ids))if(e)Qn(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)}}},up=function(e,t){return t.map(t=>e.getBlockById(t)).filter(e=>e&&e.isShadow()).length===t.length};t(I.EVENT,L.BLOCK_CREATE,lp);var dp={};dp.BlockCreate=lp;var fp=class extends Tl{constructor(e,t){super(t),this.type=L.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=Tl.fromJson(e,t,n??new fp),t.themeName=e.themeName,t}};t(I.EVENT,L.THEME_CHANGE,fp);var pp={};pp.ThemeChange=fp;var mp=class extends Tl{constructor(e,t,n,r,i){super(r),this.type=L.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=Tl.fromJson(e,t,n??new mp),t.viewTop=e.viewTop,t.viewLeft=e.viewLeft,t.scale=e.scale,t.oldScale=e.oldScale,t}};t(I.EVENT,L.VIEWPORT_CHANGE,mp);var hp={};hp.ViewportChange=mp;var gp={fromJsonInternal:Oa},_p={TEST_ONLY:gp};_p.fromJson=e.fromJson$$module$build$src$core$field_registry,_p.register=Ea,_p.unregister=Da;var vp=class extends bf{constructor(e,t,n){super(bf.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!==bf.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(vp,e)||(this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e))}initView(){this.shouldAddBorderRect_()?this.createBorderRect_():this.clickTarget_=this.sourceBlock_.getSvgRoot(),this.createTextElement_(),this.imageElement=E(z.IMAGE,{},this.fieldGroup_),this.getConstants().FIELD_DROPDOWN_SVG_ARROW?this.createSVGArrow_():this.createTextArrow_(),this.borderRect_&&D(this.borderRect_,`blocklyDropdownRect`),this.fieldGroup_&&(D(this.fieldGroup_,`blocklyField`),D(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=E(z.TSPAN,{},this.textElement_);let e;this.arrow.appendChild(document.createTextNode((e=this.getSourceBlock())!=null&&e.RTL?vp.ARROW_CHAR+` `:` `+vp.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=E(z.IMAGE,{height:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+`px`,width:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+`px`},this.fieldGroup_),this.svgArrow.setAttributeNS(tl,`xlink:href`,this.getConstants().FIELD_DROPDOWN_SVG_ARROW_DATAURI)}showEditor_(e){var t=this.getSourceBlock();if(!t)throw new xf;this.dropdownCreate(),this.menu_&&(this.menu_.openingCoords=e&&typeof e.clientX==`number`?new R(e.clientX,e.clientY):null,br(),e=this.menu_.render(yr()),D(e,`blocklyDropdownMenu`),this.getConstants().FIELD_DROPDOWN_COLOURED_DIV&&(t=t.getColour(),e=this.sourceBlock_.getColourTertiary(),xr(t,e)),Cr(this,this.dropdownDispose_.bind(this)),yr().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 xf;let t=new Nu;t.setRole(Ou.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===vp.SEPARATOR){t.addChild(new Fu);continue}let[a,o]=r;ka(a)?(r=new Image(a.width,a.height),r.src=a.src,r.alt=a.alt):r=a,r=new ju(r,o),r.setRole(Ou.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){Nr(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];ka(e)?this.renderSelectedImage(e):this.renderSelectedText(),this.positionBorderRect_()}renderSelectedImage(e){let t=this.getSourceBlock();if(!t)throw new xf;this.imageElement.style.display=``,this.imageElement.setAttributeNS(tl,`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+vp.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):ze(this.arrow),this.size_=new V(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();D(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=ze(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 V(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 xf;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 ka(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===vp.SEPARATOR)return t=!0,e;let[n,r]=e;return typeof n==`string`?[Ci(n),r]:(t=!0,[ka(n)?Object.assign({},n,{alt:Ci(n.alt)}):n,r])});if(t||e.length<2)return{options:n};var r=n.map(([e])=>e),i=Rr(r);e=zr(r,i);let a=Br(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===vp.SEPARATOR?typeof r[1]==`string`?!r[0]||typeof r[0]==`string`||ka(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.`)}};vp.SEPARATOR=`separator`,vp.ARROW_CHAR=`▾`,vp.IMAGE_Y_OFFSET=5,vp.IMAGE_Y_PADDING=vp.IMAGE_Y_OFFSET*2,Ea(`field_dropdown`,vp);var yp={};yp.FieldDropdown=vp;var bp=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(I.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 bp(e),r=t.base;return r&&(typeof r==`string`&&(r=s(I.THEME,r)??void 0),r instanceof bp&&(Ge(n,r),n.name=e)),Ge(n.blockStyles,t.blockStyles),Ge(n.categoryStyles,t.categoryStyles),Ge(n.componentStyles,t.componentStyles),Ge(n.fontStyle,t.fontStyle),t.startHats!==null&&(n.startHats=t.startHats),n}},xp={};xp.Theme=bp;var Sp=new bp(`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`}}),Cp=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=At((l=e.toolbox)??null),n=Nt(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?H.TOP:H.BOTTOM:f===u?H.RIGHT:H.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=Cp.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=Cp.parseGridOptions(e),this.zoomOptions=Cp.parseZoomOptions(e),this.toolboxPosition=f,this.theme=Cp.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||Sp,typeof e==`string`?s(I.THEME,e):e instanceof bp?e:bp.defineTheme(e.name||`builtin`+ne(),e)}},wp={};wp.Options=Cp;var Tp=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,zf),this.bubble.setDragging(!1)}revertDrag(){this.startLoc&&this.bubble.moveDuringDrag(this.startLoc)}},Ep={};Ep.BubbleDragStrategy=Tp;var Dp,Op=class{constructor(e,t,n,r,i){this.workspace=e,this.anchor=t,this.ownerRect=n,this.owner=i,this.size=new V(0,0),this.colour=`#ffffff`,this.disposed=!1,this.relativeLeft=this.relativeTop=0,this.dragStrategy=new Tp(this,this.workspace),this.id=ne(),this.svgRoot=E(z.G,{class:`blocklyBubble`},e.getBubbleCanvas()),e=E(z.G,{class:`blocklyEmboss`},this.svgRoot),this.tail=E(z.PATH,{class:`blocklyBubbleTail`},e),this.background=E(z.RECT,{class:`blocklyDraggable`,x:0,y:0,rx:Dp.BORDER_WIDTH,ry:Dp.BORDER_WIDTH},e),this.contentContainer=E(z.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(){j(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,Dp.MIN_SIZE),e.height=Math.max(e.height,Dp.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 B(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 B(t,n,r,e)}getScrollbarThickness(){return ql.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)/Dp.TAIL_THICKNESS;u=Math.min(u,this.size.width,this.size.height)/4,s=1-Dp.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=pr(this.workspace.RTL?-Dp.TAIL_ANGLE:Dp.TAIL_ANGLE),c=o+c,c>Math.PI*2&&(c-=Math.PI*2),o=Math.sin(c)*a/Dp.TAIL_BEND,a=Math.cos(c)*a/Dp.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 R(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(){et(this)}unselect(){et(null)}getFocusableElement(){return this.focusableElement}getFocusableTree(){return this.workspace}onNodeFocus(){this.select(),this.bringToFront();var e=this.getRelativeToSurfaceXY();let t=this.getSize();e=new B(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}};Dp=Op,Op.BORDER_WIDTH=6,Op.DOUBLE_BORDER=Dp.BORDER_WIDTH*2,Op.MIN_SIZE=Dp.DOUBLE_BORDER,Op.TAIL_THICKNESS=1,Op.TAIL_ANGLE=20,Op.TAIL_BEND=4,Op.ANCHOR_RADIUS=8;var kp={};kp.Bubble=Op;var Ap=class extends Op{constructor(e,t,n,r){super(t,n,r),this.workspace=t,this.anchor=n,this.ownerRect=r,this.autoLayout=!0,t=new Cp(e),this.validateWorkspaceOptions(t),this.svgDialog=E(z.SVG,{x:Op.BORDER_WIDTH,y:Op.BORDER_WIDTH},this.contentContainer),e.parentWorkspace=this.workspace,this.miniWorkspace=this.newWorkspaceSvg(new Cp(e)),this.miniWorkspace.internalIsMutator=!0,e=this.miniWorkspace.createDom(`blocklyMutatorBackground`),this.svgDialog.appendChild(e),t.languageTree&&(e.insertBefore(this.miniWorkspace.addFlyout(z.G),this.miniWorkspace.getCanvas()),e=this.miniWorkspace.getFlyout(),e?.init(this.miniWorkspace),e?.show(t.languageTree)),D(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.miniWorkspace.keyboardMoveInProgress;var e=this.getSize(),t=this.calculateWorkspaceSize();Math.abs(e.width-t.width)<Ap.MINIMUM_VIEW_CHANGE&&Math.abs(e.height-t.height)<Ap.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 V(t.width+Op.DOUBLE_BORDER,t.height+Op.DOUBLE_BORDER),this.autoLayout),this.miniWorkspace.resize(),this.miniWorkspace.recordDragTargets())}}calculateWorkspaceSize(){var e=this.miniWorkspace.getCanvas().getBBox();let t=e.width+Ap.MARGIN;e=e.height+Ap.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 V(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`)}};Ap.MINIMUM_VIEW_CHANGE=10,Ap.MARGIN=Op.DOUBLE_BORDER*3;var jp={};jp.MiniWorkspaceBubble=Ap;var Mp=class{constructor(e){this.sourceBlock=e,this.offsetInBlock=new R(0,0),this.workspaceLocation=new R(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=E(z.G,{class:`blocklyIconGroup`,id:this.id}),t.getSvgRoot().appendChild(this.svgRoot),this.updateSvgRootOffset(),g(this.svgRoot,`pointerdown`,this,e),this.svgRoot.tooltip=this,Qr(this.svgRoot)}}dispose(){$r(this.svgRoot),j(this.svgRoot)}getWeight(){return-1}getSize(){return new V(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`,fr(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=R.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 B(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)}},Np={};Np.Icon=Mp;var Pp=17,Fp=16;e.MutatorIcon$$module$build$src$core$icons$mutator_icon=class extends Mp{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),E(z.RECT,{class:`blocklyIconShape`,rx:`4`,ry:`4`,height:`16`,width:`16`},this.svgRoot),E(z.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),E(z.CIRCLE,{class:`blocklyIconShape`,r:`2.7`,cx:`8`,cy:`8`},this.svgRoot),D(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 V(Pp,Pp)}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,F.asyncExecutePromiseGeneratorFunction)(function*(){if(t.bubbleIsVisible()!==e){if(yield tn(),e){t.miniWorkspaceBubble=new Ap(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}C(new(T(L.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=Pp/2;return R.sum(this.workspaceLocation,new R(e,e))}getBubbleOwnerRect(){let e=this.sourceBlock.getSvgRoot().getBBox();return new B(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+Fp):Fp,Fp)}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)||oe(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=kd.getExtraBlockState_(this.sourceBlock);this.sourceBlock.compose(this.rootBlock);var r=kd.getExtraBlockState_(this.sourceBlock);n!==r&&C(new(T(L.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=q.MUTATOR,e.MutatorIcon$$module$build$src$core$icons$mutator_icon.WEIGHT=1;var Ip={};Ip.MutatorIcon=e.MutatorIcon$$module$build$src$core$icons$mutator_icon;var Lp=Object.create(null),Rp={allExtensions:Lp};e.register$$module$build$src$core$extensions(`parent_tooltip_when_inline`,Ua);var zp={TEST_ONLY:Rp};zp.apply=Ma,zp.buildTooltipForDropdown=e.buildTooltipForDropdown$$module$build$src$core$extensions,zp.buildTooltipWithFieldText=e.buildTooltipWithFieldText$$module$build$src$core$extensions,zp.isRegistered=ja,zp.register=e.register$$module$build$src$core$extensions,zp.registerMixin=e.registerMixin$$module$build$src$core$extensions,zp.registerMutator=e.registerMutator$$module$build$src$core$extensions,zp.runAfterPageLoad=Va,zp.unregister=Aa;var Bp;(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=Nc||Mc||jc?e.MAC_WK_CMD_LEFT:e.CTRL]=`CTRL_CMD`})(Bp||={});var Vp={};Vp.KeyCodes=Bp;var Hp={};Hp.arc=Ya,Hp.curve=Wa,Hp.line=Ja,Hp.lineOnAxis=P,Hp.lineTo=qa,Hp.moveBy=Ka,Hp.moveTo=Ga,Hp.point=N;var Up={};Up.Coordinate=R,Up.KeyCodes=Bp,Up.Rect=B,Up.Size=V,Up.Svg=z,Up.aria=Au,Up.array=Al,Up.browserEvents=Rc,Up.colour=vf,Up.deprecation=pd,Up.dom=ol,Up.extensions=zp,Up.idGenerator=Wc,Up.math=jd,Up.object=ml,Up.parsing=yf,Up.string=Zd,Up.style=Ul,Up.svgMath=Kl,Up.svgPaths=Hp,Up.toolbox=ou,Up.userAgent=Fc,Up.xml=nu;var Wp=class extends Op{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 V(160+Op.DOUBLE_BORDER,80+Op.DOUBLE_BORDER),this.MIN_SIZE=new V(45+Op.DOUBLE_BORDER,20+Op.DOUBLE_BORDER),this.editable=!0,D(this.svgRoot,`blocklyTextInputBubble`),this.editor=new Zf(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=E(z.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-Op.DOUBLE_BORDER,r=e.height-Op.DOUBLE_BORDER;this.editor.updateSize(new V(n,r),new V(0,0)),this.editor.getDom().setAttribute(`x`,`${Op.DOUBLE_BORDER/2}`),this.editor.getDom().setAttribute(`y`,`${Op.DOUBLE_BORDER/2}`),this.resizeGroup.setAttribute(`y`,`${r}`),this.workspace.RTL?this.resizeGroup.setAttribute(`x`,`${-Op.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 B(0,0,0,0)){super.positionByRect(e),this.onLocationChange()}onResizePointerDown(e){this.bringToFront(),ee(e)||(Zi(this.workspace,e,new R(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),null),this.resizePointerMoveListener&&=(v(this.resizePointerMoveListener),null)}onResizePointerMove(e){e=Qi(this.workspace,e),this.setSize(new V(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}};ut(`
|
|
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 Gp={};Gp.TextInputBubble=Wp;var X;(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`})(X||={});var Kp={};Kp.ConnectionType=X;var qp=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[X.INPUT_VALUE]=new qp(e),t[X.OUTPUT_VALUE]=new qp(e),t[X.NEXT_STATEMENT]=new qp(e),t[X.PREVIOUS_STATEMENT]=new qp(e),t}},Jp={};Jp.ConnectionDB=qp;var Yp=class extends Tl{constructor(e,t,n){super(n),this.type=L.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=Tl.fromJson(e,t,n??new Yp),t.oldElementId=e.oldElementId,t.newElementId=e.newElementId,t}};t(I.EVENT,L.SELECTED,Yp);var Xp={};Xp.Selected=Yp;var Zp=class extends Dd{constructor(e){if(super(e),this.type=L.BLOCK_DELETE,e){if(e.getParent())throw Error(`Connected blocks cannot be deleted.`);e.isShadow()&&(this.recordUndo=!1),this.oldXml=na(e),this.ids=Pe(e),this.wasShadow=e.isShadow(),this.oldJson=Un(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=sa(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=Dd.fromJson(t,n,r??new Zp),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 Qn(this.oldJson,t)}};t(I.EVENT,L.BLOCK_DELETE,Zp);var Qp={};Qp.BlockDelete=Zp;var $p=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=X.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;Me()&&(a=new(T(L.BLOCK_MOVE))(r),a.setReason([`connect`])),Xa(this,e),r.setParent(n),a&&(a.recordNew(),C(a)),i&&(e=this.type===t?i.outputConnection:i.previousConnection)&&((r=$p.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===X.INPUT_VALUE||this.type===X.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;Me()&&(a=new(T(L.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(),C(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()?aa(this.targetBlock()):this.shadowDom}setShadowState(e){this.setShadowStateInternal({shadowState:e})}getShadowState(e){return e&&this.targetBlock()&&this.targetBlock().isShadow()?Un(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=$n(n,t.workspace,{parentConnection:e?this:void 0,isShadow:!0,recordUndo:!1});if(r){if(t=fa(r,t.workspace),e)if(this.type===X.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===X.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=aa(e),this.shadowState=Un(e))}static getConnectionForOrphanedConnection(e,t){if(t.type===X.OUTPUT_VALUE)return Qa(e,t.getSourceBlock());e=e.lastConnectionInStack(!0);let n=t.getConnectionChecker();return e&&n.canConnect(t,e,!1)?e:null}};$p.CAN_CONNECT=0,$p.REASON_SELF_CONNECTION=1,$p.REASON_WRONG_TYPE=2,$p.REASON_TARGET_NULL=3,$p.REASON_CHECKS_FAILED=4,$p.REASON_DIFFERENT_WORKSPACES=5,$p.REASON_SHADOW_PARENT=6,$p.REASON_DRAG_CHECKS_FAILED=7,$p.REASON_PREVIOUS_AND_OUTPUT=8;var em={};em.Connection=$p;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||={});var rm={};rm.Align=e.Align$$module$build$src$core$inputs$align;var im=class extends bf{constructor(e,t,n){super(bf.SKIP_SETUP),this.class=null,this.EDITABLE=!1,this.maxDisplayLength=1/0,e!==bf.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&&D(this.getTextElement(),this.class),this.fieldGroup_&&D(this.fieldGroup_,`blocklyLabelField`)}doClassValidation_(e){return e==null?null:`${e}`}setClass(e){this.textElement_&&(this.class&&k(this.textElement_,this.class),e&&D(this.textElement_,e)),this.class=e}static fromJson(e){return new this(Ci(e.text),void 0,e)}};Ea(`field_label`,im),im.prototype.DEFAULT_VALUE=``;var am={};am.FieldLabel=im;var om=30,sm=[];sm[X.INPUT_VALUE]=X.OUTPUT_VALUE,sm[X.OUTPUT_VALUE]=X.INPUT_VALUE,sm[X.NEXT_STATEMENT]=X.PREVIOUS_STATEMENT,sm[X.PREVIOUS_STATEMENT]=X.NEXT_STATEMENT;var cm=`RENAME_VARIABLE_ID`,lm=`DELETE_VARIABLE_ID`,um=10,dm=class extends $p{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 R(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=R.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())fr(e)&&e.setBubbleVisible(!1)}}}startTrackingAll(){this.setTracking(!0);let e=[];if(this.type!==X.INPUT_VALUE&&this.type!==X.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(Ee()){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=Y.registry.getContextMenuOptions({focusedNode:this},e);if(t.length){var n=this.getSourceBlock(),r=n.workspace;if(e instanceof PointerEvent)var i=new R(e.clientX,e.clientY);else i=new R(this.x,this.y),i=Et(r,i).translate(n.RTL?-5:5,5);Hi(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[e.WILL_TRACK=-1]=`WILL_TRACK`,e[e.UNTRACKED=0]=`UNTRACKED`,e[e.TRACKED=1]=`TRACKED`})(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(X.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(X.INPUT_VALUE)}},Sm={},Sm.ValueInput=e.ValueInput$$module$build$src$core$inputs$value_input;var Cm={};Cm.isIcon=$a;var wm={};wm.isCommentIcon=eo;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 R(0,0),this.isInFlyout=e.isFlyout,this.isInMutator=e.isMutator,this.RTL=e.RTL,t){if(this.type=t,n=uc[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=Ee();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)),Me()&&C(new(T(L.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),Me()&&C(new(T(L.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===X.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_?lt(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(it(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 Yr(this)}getColour(){return this.colour_}getStyleName(){return this.styleName_}getHue(){return this.hue}setColour(e){e=Ti(e),this.hue=e.hue,this.colour_=e.hex}setStyle(e){this.styleName_=e}setOnChange(e){if(e&&typeof e!=`function`)throw Error(`onchange must be a function.`);this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper),this.onchange=e,this.onchangeWrapper=e.bind(this),this.workspace.addChangeListener(this.onchangeWrapper)}getField(e){if(typeof e!=`string`)throw TypeError(`Block.prototype.getField expects a string with the field name but received `+(e===void 0?`nothing`:e+` of type `+typeof e)+` instead`);for(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.makeConnection_(X.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.makeConnection_(X.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.makeConnection_(X.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&&(C(new(T(L.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(U)||t==U||this.setDisabledReason(!1,U),this.disabledReasons.has(t)!==e&&(e?this.disabledReasons.add(t):this.disabledReasons.delete(t),e=new(T(L.BLOCK_CHANGE))(this,`disabled`,null,!e,e),e.setDisabledReason(t),C(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&&(C(new(T(L.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!=Lu){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(I.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=Ci(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=Ci(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&&Ma(t.mutator,this,!0),t=t.extensions,Array.isArray(t))for(n=0;n<t.length;n++)Ma(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=Si(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(I.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(q.COMMENT)?.getText()??null}setCommentText(t){var n;let r=(n=this.getIcon(q.COMMENT))?.getText()??null;if(r!==t){if(t!==null){if(n=this.getIcon(q.COMMENT),!n){if(n=o(I.ICON,q.COMMENT.toString(),!1),!n)throw Error(`No comment icon class is registered, so a comment cannot be set`);if(n=new n(this),!eo(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(q.COMMENT);C(new(T(L.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 q?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(T(L.BLOCK_MOVE))(this);n&&r.setReason(n),this.xy.translate(e,t),r.recordNew(),C(r)}makeConnection_(e){return new $p(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=Lu,Tm.COLLAPSED_FIELD_NAME=Ru;var Em={};Em.Block=Tm;var Dm=null,Om=null,km={};km.connectionUiEffect=ro,km.disconnectUiEffect=io,km.disconnectUiStop=oo,km.disposeUiEffect=to;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||=new R(t.blockState.x||0,t.blockState.y||0),e.disable$$module$build$src$core$events$utils();let i;try{i=Qn(t.blockState,n),so(i,r)}finally{e.enable$$module$build$src$core$events$utils()}if(!i)return i;Me()&&!i.isShadow()&&C(new(T(L.BLOCK_CREATE))(i));let a=i;return tn().then(()=>e.getFocusManager$$module$build$src$core$focus_manager().focusNode(a)),i}};Am.TYPE=`block`,qt(Am.TYPE,new Am);var jm={};jm.BlockPaster=Am,jm.moveBlockToNotConflict=so;var Mm={};Mm.bumpIntoBounds=uo,Mm.bumpIntoBoundsHandler=fo,Mm.bumpTopObjectsIntoBounds=mo;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 R(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(I.CONNECTION_PREVIEWER,this.workspace.options))(this.block),Le(),this.workspace.setResizesEnabled(!1),oo(),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=>fr(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=R.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),io(this.block)}fireDragStartEvent(){let e=new(T(L.BLOCK_DRAG))(this.block,!0,this.block.getDescendants(!1));C(e)}fireDragEndEvent(){let e=new(T(L.BLOCK_DRAG))(this.block,!1,this.block.getDescendants(!1));C(e)}fireMoveEvent(){if(!this.block.isDeadOrDying()){var e=new(T(L.BLOCK_MOVE))(this.block);e.setReason([`drag`]),e.oldCoordinate=this.startLoc,e.recordNew(),C(e)}}drag(e){if(this.block.isShadow()){let t;(t=this.block.getParent())==null||t.drag(R.sum(e,this.dragOffset))}else this.block.moveDuringDrag(e),this.updateConnectionPreview(this.block,R.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===X.OUTPUT_VALUE||i.type===X.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!!$p.getConnectionForOrphanedConnection(e,n===X.OUTPUT_VALUE?t.outputConnection:t.previousConnection)}currCandidateIsBetter(t,n,r){let{local:i,neighbour:a}=t;t=new R(i.x,i.y);let o=new R(a.x,a.y);return n=R.distance(R.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(),Re(),oo();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,Rf),this.getVisibleBubbles(this.block).forEach(e=>this.workspace.getLayerManager()?.moveOffDragLayer(e,zf,!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();tn().then(()=>{ro(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 X.INPUT_VALUE:this.startParentConn.connect(this.block.outputConnection);break;case X.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,Rf),this.getVisibleBubbles(this.block).forEach(e=>this.workspace.getLayerManager()?.moveOffDragLayer(e,zf,!1)),uo(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 Op{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(),D(this.svgRoot,`blocklyTextBubble`)}getText(){return this.text}setText(e){this.text=e,j(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 E(z.G,{class:`blocklyText blocklyBubbleText blocklyNoPointerEvents`,transform:`translate(0,${Op.BORDER_WIDTH})`,style:`direction: ${this.workspace.RTL?`rtl`:`ltr`}`},e)}createTextFragments(e,t){let n=1;return t.split(`
|
|
632
|
-
`).map(t=>{let r=E(z.TEXT,{y:`${n}em`,x:Op.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+Op.BORDER_WIDTH}`)}updateBubbleSize(){let e=this.paragraph.getBBox();this.setSize(new V(e.width+Op.BORDER_WIDTH*2,e.height+Op.BORDER_WIDTH*2),!0)}},Im={};Im.TextBubble=Fm;var Lm=17,Rm=class extends Mp{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),E(z.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),E(z.PATH,{class:`blocklyIconSymbol`,d:`m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z`},this.svgRoot),E(z.RECT,{class:`blocklyIconSymbol`,x:`7`,y:`11`,height:`2`,width:`2`},this.svgRoot),D(this.svgRoot,`blocklyWarningIcon`))}dispose(){super.dispose();let e;(e=this.textBubble)==null||e.dispose()}getWeight(){return Rm.WEIGHT}getSize(){return new V(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,F.asyncExecutePromiseGeneratorFunction)(function*(){if(t.bubbleIsVisible()!==e){if(yield tn(),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}C(new(T(L.BUBBLE_OPEN))(t.sourceBlock,e,`warning`))}})}getBubble(){return this.textBubble}getAnchorLocation(){let e=Lm/2;return R.sum(this.workspaceLocation,new R(e,e))}getBubbleOwnerRect(){let e=this.sourceBlock.getSvgRoot().getBBox();return new B(e.y,e.y+e.height,e.x,e.x+e.width)}};Rm.TYPE=q.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 R(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=E(z.G,{}),t&&D(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,Qr(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(),et(this)}unselect(){this.removeSelect(),et(null)}setParent(t){var n=this.parentBlock_;if(t!==n){Le(),super.setParent(t),Re();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=xt(r);t+=e.x,n+=e.y,r=r.parentNode}while(r&&!e.hasLayer(r));return new R(t,n)}moveBy(e,t,n){if(this.parentBlock_)throw Error(`Block has parent`);let r=Me(),i=null;r&&(i=new(T(L.BLOCK_MOVE))(this),n&&i.setReason(n)),e=new R(e,t),t=this.getRelativeToSurfaceXY(),e=R.sum(t,e),this.translate(e.x,e.y),this.updateComponentLocations(e),r&&i&&(i.recordNew(),C(i)),this.workspace.resizeContents()}translate(e,t){this.translation=`translate(${e}, ${t})`,this.relativeCoords=new R(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 B(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=Lu,r=Ru;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?(D(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=Y.registry.getContextMenuOptions({block:this,focusedNode:this},e),this.customContextMenu&&this.customContextMenu(e),e)}calculateContextMenuLocation(e){if(e instanceof PointerEvent)return new R(e.clientX,e.clientY);e=Et(this.workspace,this.getRelativeToSurfaceXY());let t=this.inputList.filter(e=>e.isVisible()).flatMap(e=>e.fieldRow).find(e=>e.isVisible())?.getSvgRoot()?.getBoundingClientRect();return new R(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&&(Hi(e,t,this.RTL,this.workspace,n),Vi(this))}updateComponentLocations(e){this.dragging||this.updateConnectionLocations(e),this.updateIconLocations(e),this.updateFieldLocations(e);for(let t of this.getChildren(!1))t.updateComponentLocations(R.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){D(this.svgGroup,e)}removeClass(e){k(this.svgGroup,e)}setDragging(e){(this.dragging=e)?(this.translation=``,bl.push(...this.getConnections_(!0)),this.addClass(`blocklyDragging`)):(bl.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`):D(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,ri(),qi();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 R(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),to(this)),super.dispose(!!t),j(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:Un(this,{addCoordinates:!0,addNextBlocks:e,saveIds:!1}),typeCounts:it(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`):D(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(),D(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===X.NEXT_STATEMENT||e.type===X.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 en(this)}render(){this.queueRender(),nn()}renderEfficiently(){Le(),this.isCollapsed()&&this.updateCollapsed(),this.isEnabled()||this.updateDisabled(),this.workspace.getRenderer().render(this),this.tightenChildrenEfficiently(),Re()}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`},Un(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=ho;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_(ho(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 V(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===H.TOP;return a===H.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===H.LEFT||a===H.RIGHT;return(a===H.TOP||a===H.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||=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||=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(I.METRICS_MANAGER,cc,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 R(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=E(z.G,{id:this.id,class:e},this.workspace.getCanvas());let i;this.isFlyoutLabel||(i=E(z.RECT,{class:`blocklyFlyoutButtonShadow`,rx:$m.BORDER_RADIUS,ry:$m.BORDER_RADIUS,x:1,y:1},this.svgGroup)),e=E(z.RECT,{class:this.isFlyoutLabel?`blocklyFlyoutLabelBackground`:`blocklyFlyoutButtonBackground`,rx:$m.BORDER_RADIUS,ry:$m.BORDER_RADIUS},this.svgGroup),t=E(z.TEXT,{class:this.isFlyoutLabel?`blocklyFlyoutLabelText`:`blocklyText`,x:0,y:0,"text-anchor":`middle`},this.svgGroup),n=Ci(this.text),this.workspace.RTL&&(n+=``),t.textContent=n,this.isFlyoutLabel&&(this.svgText=t,this.workspace.getThemeManager().subscribe(this.svgText,`flyoutForegroundColour`,`fill`)),r=ht(t,`fontSize`);let a=ht(t,`fontWeight`),o=ht(t,`fontFamily`);if(this.width=Ve(t,r,a,o),n=He(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 B(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&&j(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 B(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,ut(`
|
|
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 B(this.y,this.y,this.x,this.x+this.gap);case`y`:return new B(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 Wp}},uh={};uh.BlockCommentNavigationPolicy=lh;var dh=class{getFirstChild(e){return go(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()?vo(e,1):e.getSurroundParent()?vo(e.getTopStackBlock(),1):this.getParent(e)instanceof j_?_o(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()?vo(e,-1):this.getParent(e)instanceof j_?_o(e,-1):null}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof Bm}},fh={};fh.BlockNavigationPolicy=dh,fh.navigateBlock=vo,fh.navigateStacks=_o;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 Gf}},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 Zf}},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 vo(e,1);if(e.type===X.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 vo(e,-1);if(e.type===X.PREVIOUS_STATEMENT||e.type===X.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===X.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 vo(e,1)}getPreviousSibling(e){return vo(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 bf}},bh={};bh.FieldNavigationPolicy=yh;var xh={};xh.register=yo,xh.unregister=bo;var Sh=17,Ch=160,wh=80,Th=class extends Mp{constructor(e){super(e),this.sourceBlock=e,this.textInputBubble=null,this.text=``,this.bubbleSize=new V(Ch,wh),this.bubbleVisiblity=!1}getType(){return Th.TYPE}initView(e){this.svgRoot||(super.initView(e),E(z.CIRCLE,{class:`blocklyIconShape`,r:`8`,cx:`8`,cy:`8`},this.svgRoot),E(z.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),E(z.RECT,{class:`blocklyIconSymbol`,x:`6.8`,y:`10.78`,height:`2`,width:`2`},this.svgRoot),D(this.svgRoot,`blocklyCommentIcon`))}dispose(){super.dispose();let e;(e=this.textInputBubble)==null||e.dispose()}getWeight(){return Th.WEIGHT}getSize(){return new V(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,F.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=R.difference(this.workspaceLocation,t),R.sum(this.bubbleLocation,e)),e=this.getAnchorLocation();let n;(n=this.textInputBubble)==null||n.setAnchorLocation(e)}setText(e){let t=this.text;C(new(T(L.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 V(e.width??Ch,e.height??wh),this.bubbleVisiblity=e.pinned??!1,this.setBubbleVisible(this.bubbleVisiblity);let t=e.x,n=e.y;tn().then(()=>{t&&n&&(t=this.sourceBlock.workspace.RTL?this.sourceBlock.workspace.getWidth()-(t+this.bubbleSize.width):t,this.setBubbleLocation(new R(t,n)))})}onClick(){super.onClick(),this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}onTextChange(){if(this.textInputBubble){var e=this.textInputBubble.getText();this.text!==e&&(C(new(T(L.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,F.asyncExecutePromiseGeneratorFunction)(function*(){t.bubbleVisiblity!==e&&(t.bubbleVisiblity=e,yield tn(),!t.sourceBlock.rendered||t.sourceBlock.isInFlyout||t.sourceBlock.isInsertionMarker()||(e?(t.sourceBlock.isEditable()?t.showEditableBubble():t.showNonEditableBubble(),t.applyColour()):t.hideBubble(),C(new(T(L.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 Wp(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 R.sum(this.workspaceLocation,new R(e,e))}getBubbleOwnerRect(){return this.sourceBlock.getBoundingRectangleWithoutChildren()}};Th.TYPE=q.COMMENT,Th.WEIGHT=3,yo(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 vo(e,1)}getPreviousSibling(e){return vo(e,-1)}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof Mp}},Oh={};Oh.IconNavigationPolicy=Dh;var kh=class{getFirstChild(e){return e.view.getCommentBarButtons()[0]}getParent(e){return e.workspace}getNextSibling(e){return _o(e,1)}getPreviousSibling(e){return _o(e,-1)}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof op}},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 ql(e,!0,a,r,i)),n&&(this.vScroll=new ql(e,!1,a,r,i)),a&&(this.corner_=E(z.RECT,{height:ql.scrollbarThickness,width:ql.scrollbarThickness,class:`blocklyScrollbarBackground`}),Ie(this.corner_,e.getBubbleCanvas()))}dispose(){j(this.corner_),this.oldHostMetrics=this.corner_=null,this.hScroll&&=(this.hScroll.dispose(),null),this.vScroll&&=(this.vScroll.dispose(),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||=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(I.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_=E(e,{class:`blocklyFlyout`}),this.svgGroup_.style.display=`none`,this.svgBackground_=E(z.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:Ml.ComponentWeight.FLYOUT_WEIGHT,capabilities:[Ml.Capability.AUTOHIDEABLE,Ml.Capability.DELETE_AREA,Ml.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_&&j(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_&&M(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),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=Mt(t),t=this.createFlyoutInfo(t),nn(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!==L.BLOCK_CHANGE&&e.type!==L.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=Mt(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=$n(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 Un(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=R.sum(i,e),r=R.difference(i,r),r.scale(1/n.scale),t.moveTo(new R(r.x,r.y))}getInflaterForType(e){if(this.inflaters.has(e)){var t;return(t=this.inflaters.get(e))??null}return(t=o(I.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=xo;var Gh={};Gh.isDraggable=So;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 R(e.scrollX,e.scrollY)}startDrag(){}endDrag(e){this.drag(e)}drag(e){if(e=R.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 R(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 R(0,0)}dispose(){f(),oi(),this.creatorWorkspace.clearGesture();for(let e of this.boundEvents)v(e);this.boundEvents.length=0}updateFromEvent(e){let t=new R(e.clientX,e.clientY);this.updateDragDelta(t)&&(this.updateIsDragging(e),d()),this.mostRecentEvent=e}updateDragDelta(t){return this.currentDragDeltaXY=R.difference(t,this.mouseDownXY),this.hasExceededDragRadius?!1:this.hasExceededDragRadius=R.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=Qe();t&&So(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(I.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,oo(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.currentDropdownOwner=vr(),this.startWorkspace_.hideChaff(!!this.flyout),this.startWorkspace_.markFocused(),this.mostRecentEvent=e,ai(),ee(e)?this.handleRightClick(e):(e.type.toLowerCase()===`pointerdown`&&e.pointerType!==`mouse`&&u(e,this),this.mouseDownXY=new R(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=R.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=R.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=b(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 R(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(xo(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){C(new(T(L.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(T(L.CLICK))(this.startBlock,this.startWorkspace_.id,`block`),C(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||=e}setStartIcon(e){if(this.gestureHasStarted)throw Error(`Tried to call gesture.setStartIcon, but the gesture had already been started.`);this.startIcon||=e}setStartBubble(e){this.startBubble||=e}setStartComment(e){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_||=e}setStartFlyout(e){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=qe();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 R(r,t)}static createDom(e,t,n,r){if(e=E(z.PATTERN,{id:`blocklyGridPattern`+e,patternUnits:`userSpaceOnUse`},n),(t.length??1)>0&&(t.spacing??0)>0){E(z.LINE,{stroke:t.colour},e);let n;(n=t.length)!=null&&n&&E(z.LINE,{stroke:t.colour},e)}else E(z.LINE,{},e);return r&&r.style.setProperty(`--blocklyGridPattern`,`url(#${e.id})`),e}},ng={};ng.Grid=tg;var rg={};rg.isAutoHideable=Co;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(Rf),D(e,`blocklyBlockCanvas`),e=this.createLayer(zf),D(e,`blocklyBubbleCanvas`)}createDragLayer(e){let t=E(z.SVG,{class:`blocklyBlockDragSurface`,xmlns:$c,"xmlns:html":el,"xmlns:xlink":tl,version:`1.1`});return e.append(t),E(z.G,{},t)}createAnimationLayer(e){let t=E(z.SVG,{class:`blocklyAnimationLayer`,xmlns:$c,"xmlns:html":el,"xmlns:xlink":tl,version:`1.1`});return e.append(t),E(z.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=E(z.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(Rf)}getBubbleLayer(){return this.layers.get(zf)}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 bf||e instanceof dm||e instanceof Mp?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 op},!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 op},!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(I.CURSOR,cc,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=Mp,fg.IconType=q,fg.MutatorIcon=e.MutatorIcon$$module$build$src$core$icons$mutator_icon,fg.WarningIcon=Rm,fg.exceptions=nm,fg.registry=xh;var pg={};pg.isProcedureBlock=wo,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.DEVELOPER_VARIABLE=`DEVELOPER_VARIABLE`,e.VARIABLE=`VARIABLE`,e.PROCEDURE=`PROCEDURE`})(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=To;var gg=class extends Map{constructor(){super()}set(e,t){return this.get(e)===t?this:(super.set(e,t),To(t)&&t.startPublishing(),this)}delete(e){let t=this.get(e);return e=super.delete(e),e&&(To(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=Eo,yg.findLegalName=e.findLegalName$$module$build$src$core$procedures,yg.flyoutCategory=Mo,yg.getCallers=Io,yg.getDefinition=e.getDefinition$$module$build$src$core$procedures,yg.internalFlyoutCategory=jo,yg.isNameUsed=ko,yg.isProcedureBlock=wo,yg.mutateCallers=e.mutateCallers$$module$build$src$core$procedures,yg.mutatorOpenListener=Po,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=Ka(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=He(`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=Ti(t.colourPrimary||`#000`),t.colourPrimary=e.hex,t.colourSecondary=t.colourSecondary?Ti(t.colourSecondary).hex:this.generateSecondaryColour_(t.colourPrimary),t.colourTertiary=t.colourTertiary?Ti(t.colourTertiary).hex:this.generateTertiaryColour_(t.colourPrimary),t.hat=t.hat||``,t}generateSecondaryColour_(e){return yi(`#fff`,e,.6)||e}generateTertiaryColour_(e){return yi(`#fff`,e,.3)||e}dispose(){this.embossFilter&&j(this.embossFilter),this.disabledPattern&&j(this.disabledPattern),this.debugFilter&&j(this.debugFilter),this.cssNode=null}makeJaggedTeeth(){let e=this.JAGGED_TEETH_HEIGHT,t=this.JAGGED_TEETH_WIDTH;return{height:e,width:t,path:Ja([N(t,e/4),N(-t*2,e/2),N(t,e/4)])}}makeStartHat(){let e=this.START_HAT_HEIGHT,t=this.START_HAT_WIDTH,n=Wa(`c`,[N(30,-e),N(70,-e),N(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=N(-t,e*i);return i=N(t,e*i),Wa(`c`,[N(0,e*a),N(-t,r*o),s])+Wa(`s`,[N(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 Ja([N(e*r,n),N(e*3,0),N(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:Ya(`a`,`0 0,0`,e,N(-e,e)),pathBottom:Ya(`a`,`0 0,0`,e,N(e,e))}}makeOutsideCorners(){let e=this.CORNER_RADIUS,t=Ka(0,e)+Ya(`a`,`0 0,1`,e,N(e,-e)),n=Ya(`a`,`0 0,1`,e,N(e,e)),r=Ya(`a`,`0 0,1`,e,N(-e,-e));return{topLeft:t,topRight:n,bottomRight:Ya(`a`,`0 0,1`,e,N(-e,e)),bottomLeft:r,rightHeight:e}}shapeFor(e){switch(e.type){case X.INPUT_VALUE:case X.OUTPUT_VALUE:return this.PUZZLE_TAB;case X.PREVIOUS_STATEMENT:case X.NEXT_STATEMENT:return this.NOTCH;default:throw Error(`Unknown connection type`)}}createDom(e,t,n,r){this.injectCSS_(t,n),this.defs=E(z.DEFS,{},e),e=E(z.FILTER,{id:`blocklyEmbossFilter`+this.randomIdentifier},this.defs),E(z.FEGAUSSIANBLUR,{in:`SourceAlpha`,stdDeviation:1,result:`blur`},e),t=E(z.FESPECULARLIGHTING,{in:`blur`,surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":`white`,result:`specOut`},e),E(z.FEPOINTLIGHT,{x:-5e3,y:-1e4,z:2e4},t),E(z.FECOMPOSITE,{in:`specOut`,in2:`SourceAlpha`,operator:`in`,result:`specOut`},e),E(z.FECOMPOSITE,{in:`SourceGraphic`,in2:`specOut`,operator:`arithmetic`,k1:0,k2:1,k3:1,k4:0},e),this.embossFilterId=e.id,this.embossFilter=e,e=E(z.PATTERN,{id:`blocklyDisabledPattern`+this.randomIdentifier,patternUnits:`userSpaceOnUse`,width:10,height:10},this.defs),E(z.RECT,{width:10,height:10,fill:`#aaa`},e),E(z.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=E(z.FILTER,{id:`blocklyDebugFilter`+this.randomIdentifier,height:`160%`,width:`180%`,y:`-30%`,x:`-40%`},this.defs),t=E(z.FECOMPONENTTRANSFER,{result:`outBlur`},e);E(z.FEFUNCA,{type:`table`,tableValues:`0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1`},t),E(z.FEFLOOD,{"flood-color":`#ff0000`,"flood-opacity":.5,result:`outColor`},e),E(z.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=Ro,l_.isNotch=Bo,l_.isPuzzleTab=zo;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_+=Ka(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_+=P(`h`,n.width));this.outlinePath_+=P(`v`,e.height-e.ascenderHeight)}drawJaggedEdge_(e){this.outlinePath_+=this.constants_.JAGGED_TEETH.path+P(`v`,e.height-this.constants_.JAGGED_TEETH.height)}drawValueInput_(e){let t=e.getLastInput();this.positionExternalValueConnection_(e);let n=Ro(t.shape)?t.shape.pathDown(t.height):t.shape.pathDown;this.outlinePath_+=P(`H`,t.xPos+t.width)+n+P(`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+P(`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_+=P(`H`,n)+t+P(`v`,r)+this.constants_.INSIDE_CORNERS.pathBottom+P(`H`,e.xPos+e.width),this.positionStatementInputConnection_(e)}}drawRightSideRow_(e){this.outlinePath_+=P(`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+=P(`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+=P(`h`,a.width*-1));this.outlinePath_+=P(`V`,e.baseline-n),this.outlinePath_+=r}drawLeft_(){var e=this.info_.outputConnection;if(this.positionOutputConnection_(),e){let t=e.connectionOffsetY+e.height;e=Ro(e.shape)?e.shape.pathUp(e.height):e.shape.pathUp,this.outlinePath_+=P(`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 R(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_+=Ga(e.xPos+e.connectionWidth,e.centerline-n/2)+P(`v`,r)+e.shape.pathDown+P(`v`,n-i)+P(`h`,t-e.connectionWidth)+P(`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===X.INPUT_VALUE||t.type===X.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 Ro(e.shape)?t=e.shape.pathDown(e.height):zo(e.shape)&&(t=e.shape.pathDown),e=this.constants_.TAB_OFFSET_FROM_TOP,Ka(0,-e)+P(`v`,e)+t+P(`v`,e)}getStatementConnectionHighlightPath(e){if(!Bo(e.shape))throw Error(`Statement connections should have notch shapes`);let t=this.constants_.NOTCH_OFFSET_LEFT-this.constants_.CORNER_RADIUS;return Ka(-t,0)+P(`h`,t)+e.shape.pathLeft+P(`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=E(z.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?D(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=E(z.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&&(j(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!!$p.getConnectionForOrphanedConnection(e,n===X.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=Uo,v_.register=Vo,v_.unregister=Ho;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.getClassName())&&k(e,t),(t=this.theme.getClassName())&&D(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(!lt(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=Jo,S_.flyoutCategoryBlocks=Xo,S_.internalFlyoutCategory=qo,S_.onCreateVariableButtonClick_Colour=Ko,S_.onCreateVariableButtonClick_Number=Go,S_.onCreateVariableButtonClick_String=Wo;var C_=class{canConnect(e,t,n,r){return this.canConnectWithReason(e,t,n,r)===$p.CAN_CONNECT}canConnectWithReason(e,t,n,r){let i=this.doSafetyChecks(e,t);return i===$p.CAN_CONNECT?this.doTypeChecks(e,t)?n&&!this.doDragChecks(e,t,r||0)?$p.REASON_DRAG_CHECKS_FAILED:$p.CAN_CONNECT:$p.REASON_CHECKS_FAILED:i}getErrorMessage(e,t,n){switch(e){case $p.REASON_SELF_CONNECTION:return`Attempted to connect a block to itself.`;case $p.REASON_DIFFERENT_WORKSPACES:return`Blocks not on same workspace.`;case $p.REASON_WRONG_TYPE:return`Attempt to connect incompatible types.`;case $p.REASON_TARGET_NULL:return`Target connection is null.`;case $p.REASON_CHECKS_FAILED:return`Connection checks failed. `+(t+` expected `+t.getCheck()+`, found `+n.getCheck());case $p.REASON_SHADOW_PARENT:return`Connecting non-shadow to shadow block.`;case $p.REASON_DRAG_CHECKS_FAILED:return`Drag checks failed.`;case $p.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 $p.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?$p.REASON_SELF_CONNECTION:i.type===sm[e.type]?n.workspace===r.workspace?n.isShadow()&&!r.isShadow()?$p.REASON_SHADOW_PARENT:i.type===X.OUTPUT_VALUE&&r.previousConnection&&r.previousConnection.isConnected()||i.type===X.PREVIOUS_STATEMENT&&r.outputConnection&&r.outputConnection.isConnected()?$p.REASON_PREVIOUS_AND_OUTPUT:$p.CAN_CONNECT:$p.REASON_DIFFERENT_WORKSPACES:$p.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 X.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(e,t);case X.OUTPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isInsertionMarker()||e.isConnected())return!1;break;case X.INPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isMovable()&&!t.targetBlock().isShadow())return!1;break;case X.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!bl.includes(t)}canConnectToPrevious_(e,t){return e.targetConnection||bl.includes(t)?!1:t.targetConnection?(e=t.targetBlock(),e.isInsertionMarker()?!e.getPreviousBlock():!1):!0}};t(I.CONNECTION_CHECKER,cc,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(),Je(this),this.options=e||new Cp({}),this.RTL=!!this.options.RTL,this.horizontalLayout=!!this.options.horizontalLayout,this.toolboxPosition=this.options.toolboxPosition,this.connectionChecker=new(l(I.CONNECTION_CHECKER,this.options,!0))(this),this.variableMap=new(this.getVariableMapClass())(this),this.setIsReadOnly(this.options.readOnly)}dispose(){this.listeners.length=0,this.clear(),Ye(this)}sortObjects(e,t){let n=e=>({getBoundingRectangle:()=>{let t=e.getRelativeToSurfaceXY();return new B(t.y,t.y,t.x,t.x)},moveBy:()=>{}});return this.sortByOrigin(n(e),n(t))}sortByOrigin(e,t){let n=Math.sin(pr(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(!lt(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){lt(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(!lt(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){xn(`Blockly.Workspace.renameVariableById`,`v12`,`v13`,`Blockly.Workspace.getVariableMap().renameVariable`),(e=this.variableMap.getVariableById(e))&&this.variableMap.renameVariable(e,t)}createVariable(e,t,n){return xn(`Blockly.Workspace.createVariable`,`v12`,`v13`,`Blockly.Workspace.getVariableMap().createVariable`),this.variableMap.createVariable(e,t??void 0,n??void 0)}getVariableUsesById(e){return xn(`Blockly.Workspace.getVariableUsesById`,`v12`,`v13`,`Blockly.Variables.getVariableUsesById`),Hn(this,e)}deleteVariableById(t){xn(`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 xn(`Blockly.Workspace.getVariable`,`v12`,`v13`,`Blockly.Workspace.getVariableMap().getVariable`),this.variableMap.getVariable(e,t)}getVariableById(e){return xn(`Blockly.Workspace.getVariableById`,`v12`,`v13`,`Blockly.Workspace.getVariableMap().getVariableById`),this.variableMap.getVariableById(e)}getVariablesOfType(e){return xn(`Blockly.Workspace.getVariablesOfType`,`v12`,`v13`,`Blockly.Workspace.getVariableMap().getVariablesOfType`),this.variableMap.getVariablesOfType(e??``)}getAllVariables(){return xn(`Blockly.Workspace.getAllVariables`,`v12`,`v13`,`Blockly.Workspace.getVariableMap().getAllVariables`),this.variableMap.getAllVariables()}getAllVariableNames(){return xn(`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,je()}addChangeListener(e){return this.listeners.push(e),e}removeChangeListener(e){lt(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 Ke(e)}static getAll(){return qe()}getVariableMapClass(){let e=l(I.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,F.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,F.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(I.METRICS_MANAGER,e,!0))(this),this.getMetrics=e.getMetrics||this.metricsManager.getMetrics.bind(this.metricsManager),this.setMetrics=e.setMetrics||j_.setTopLevelWorkspaceMetrics,this.componentManager=new Ml,this.connectionDBList=qp.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),_d&&Sn&&this.registerToolboxCategoryCallback(md,Sn),S_&&qo&&this.registerToolboxCategoryCallback(x_,qo),yg&&jo&&(this.registerToolboxCategoryCallback(vg,jo),this.addChangeListener(Po)),this.addChangeListener(this.variableChangeCallback.bind(this)),this.themeManager_=this.options.parentWorkspace?this.options.parentWorkspace.getThemeManager():new y_(this,this.options.theme||Sp),this.themeManager_.subscribeWorkspace(this),this.renderer=Uo(this.options.renderer||`geras`,this.getTheme(),this.options.rendererOverrides??void 0),this.cachedParentSvgSize=new V(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||=Sp,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(T(L.THEME_CHANGE))(this.getTheme().name,this.id),C(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=xt(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 R(t,n)}getCachedParentSvgSize(){let e=this.cachedParentSvgSize;return new V(e.width,e.height)}getOriginOffsetInPixels(){return St(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||=n??null,this.svgGroup_=E(z.G,{class:`blocklyWorkspace`,id:this.id}),n&&Qt(this.svgGroup_,ku.LABEL,e.Msg$$module$build$src$core$msg.WORKSPACE_ARIA_LABEL),t&&(this.svgBackground_=E(z.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(I.TOOLBOX,this.options,!0))(this)),this.grid&&this.grid.update(this.scale),this.recordDragTargets(),(t=l(I.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_&&j(this.svgGroup_),this.toolbox&&=(this.toolbox.dispose(),null),this.flyout&&=(this.flyout.dispose(),null),this.trashcan&&=(this.trashcan.dispose(),null),this.scrollbar&&=(this.scrollbar.dispose(),null),this.zoomControls_&&this.zoomControls_.dispose(),this.audioManager&&this.audioManager.dispose(),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&&j(e.parentNode)}this.resizeHandlerWrapper&&=(v(this.resizeHandlerWrapper),null),this.dummyWheelListener&&=(document.body.removeEventListener(`wheel`,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 fu(this);let e=this.zoomControls_.createDom();this.svgGroup_.appendChild(e)}copyOptionsForFlyout(){return new Cp({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(I.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(t):new(l(I.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(Ml.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=wt();R.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(Me()){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(T(L.VIEWPORT_CHANGE))(t,n,e,this.id,this.oldScale);this.oldScale=e,this.oldTop=t,this.oldLeft=n,C(r)}}}translate(e,t){let n;(n=this.layerManager)==null||n.translateLayers(new R(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):lt(this.highlightedBlocks,e),e.setHighlighted(t))}variableChangeCallback(e){switch(e.type){case L.VAR_CREATE:case L.VAR_DELETE:case L.VAR_RENAME:case L.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(Ml.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){Zi(this,e,t)}moveDrag(e){return Qi(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(Nc)var i=e.metaKey;t&&(e.ctrlKey||i||!n)?(r=-r.y/50,t=b(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 B(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=Y.registry.getContextMenuOptions({workspace:this,focusedNode:this},e);this.configureContextMenu&&this.configureContextMenu(t,e);var n=e instanceof PointerEvent?new R(e.clientX,e.clientY):Et(this,new R(5,5));Hi(e,t,this.RTL,this,n)}}updateToolbox(e){if(e=At(e)){if(!this.options.languageTree)throw Error(`Existing toolbox is null. Can't create new toolbox.`);if(Nt(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():(Ze(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(){D(this.getCanvas(),`blocklyCanvasTransitioning`),D(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){lt(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){ii(),Ni(this),Fr(),this.hideComponents(e)}hideComponents(e=!1){this.getComponentManager().getComponents(Ml.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&&D(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 B(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(),Ue(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 op&&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(),Ue(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(Xf),e.indexOf(qf),e.indexOf($f)),a!==-1&&(a=e.substring(0,a),a=this.searchForWorkspaceComment(a))){if(e.indexOf(Xf)>-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(fr(i)){if((o=i.getBubble())&&o.canBeFocused()&&o.getFocusableElement().id===e)return o;if(o instanceof Wp&&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||Co(n)&&n.autoHide(!1)}}getNavigator(){return this.navigator}setNavigator(e){this.navigator=e}},M_={};M_.WorkspaceSvg=j_,M_.resizeSvgContents=Zo;var N_=class extends Cl{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=Cl.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=L.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(I.EVENT,L.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),C(new(T(L.VAR_CREATE))(e))}};t(I.VARIABLE_MODEL,cc,L_);var R_={};R_.VariableModel=L_;var z_=class extends N_{constructor(e){super(e),this.type=L.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(I.EVENT,L.VAR_DELETE,z_);var B_={};B_.VarDelete=z_;var V_=class extends N_{constructor(e,t){super(e),this.type=L.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(I.EVENT,L.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),C(new(T(L.VAR_TYPE_CHANGE))(e,n,t)),e}renameVariableById(e,t){xn(`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||C(new(T(L.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||C(new(T(L.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||=``,n=l(I.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||C(new(T(L.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=Hn(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||C(new(T(L.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){xn(`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(){xn(`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 xn(`VariableMap.getVariableUsesById`,`v12`,`v13`,`Blockly.Variables.getVariableUsesById`),Hn(this.workspace,e)}};t(I.VARIABLE_MAP,cc,U_);var W_={};W_.VariableMap=U_;var G_=class extends Tl{constructor(e,t){super(t),this.type=L.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=Tl.fromJson(e,t,n??new G_),t.isOpen=e.isOpen,t}};t(I.EVENT,L.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===H.TOP?H.BOTTOM:H.TOP,this.flyout=new(l(I.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(e)):(e.toolboxPosition=this.workspace.toolboxPosition===H.RIGHT?H.LEFT:H.RIGHT,this.flyout=new(l(I.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(e)),this.workspace.addChangeListener(this.onDelete.bind(this)))}createDom(){this.svgGroup=E(z.G,{class:`blocklyTrash`});let e,t=String(Math.random()).substring(2);e=E(z.CLIPPATH,{id:`blocklyTrashBodyClipPath`+t},this.svgGroup),E(z.RECT,{width:J_,height:Y_,y:X_},e);let n=E(z.IMAGE,{width:du.width,x:-ev,height:du.height,y:-tv,"clip-path":`url(#blocklyTrashBodyClipPath`+t+`)`},this.svgGroup);return n.setAttributeNS(tl,`xlink:href`,this.workspace.options.pathToMedia+du.url),e=E(z.CLIPPATH,{id:`blocklyTrashLidClipPath`+t},this.svgGroup),E(z.RECT,{width:J_,height:X_},e),this.svgLid=E(z.IMAGE,{width:du.width,x:-ev,height:du.height,y:-tv,"clip-path":`url(#blocklyTrashLidClipPath`+t+`)`},this.svgGroup),this.svgLid.setAttributeNS(tl,`xlink:href`,this.workspace.options.pathToMedia+du.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(z.SVG);D(e,`blocklyTrashcanFlyout`),Ie(e,this.workspace.getParentSvg()),this.flyout.init(this.workspace)}this.workspace.getComponentManager().addComponent({component:this,weight:Ml.ComponentWeight.TRASHCAN_WEIGHT,capabilities:[Ml.Capability.AUTOHIDEABLE,Ml.Capability.DELETE_AREA,Ml.Capability.DRAG_TARGET,Ml.Capability.POSITIONABLE]}),this.initialized=!0,this.setLidOpen(!1)}dispose(){this.workspace.getComponentManager().removeComponent(`trashcan`),this.svgGroup&&j(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=Vt(this.workspace,e);e=Bt(n,new V(J_,Y_+X_),Q_,Z_,e,this.workspace),t=Ht(e,Z_,n.vertical===su.TOP?lu.DOWN:lu.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 B(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 B(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===H.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(T(L.TRASHCAN_OPEN))(e,this.workspace.id),C(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=Qo,fv.getLastCopiedData=$o,fv.getLastCopiedLocation=rs,fv.getLastCopiedWorkspace=ts,fv.paste=as,fv.registry=Su,fv.setLastCopiedData=es,fv.setLastCopiedLocation=is,fv.setLastCopiedWorkspace=ns;var pv={};pv.CollapseCommentBarButton=Jf,pv.CommentBarButton=Gf,pv.CommentEditor=Zf,pv.CommentView=np,pv.DeleteCommentBarButton=ep,pv.RenderedWorkspaceComment=op,pv.WorkspaceComment=ip;var mv={};mv.isCopyable=ss;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||={}),vs();var gv={};gv.names=hv,gv.registerCopy=fs,gv.registerCut=ps,gv.registerDefaultShortcuts=vs,gv.registerDelete=ls,gv.registerEscape=cs,gv.registerPaste=ms,gv.registerRedo=gs,gv.registerShowContextMenu=_s,gv.registerUndo=hs;var _v=class{constructor(e,t){this.procedureModelClass=e,this.parameterModelClass=t,this.priority=hu}save(e){return e=e.getProcedureMap().getProcedures().map(e=>ys(e)),e.length?e:null}load(e,t){let n=t.getProcedureMap();for(let r of e)n.add(bs(this.procedureModelClass,this.parameterModelClass,r,t))}clear(e){e.getProcedureMap().clear()}},vv={};vv.ProcedureSerializer=_v,vv.loadProcedure=bs,vv.saveProcedure=ys;var yv=class{constructor(){this.priority=mu}save(e){return e=e.getVariableMap().getAllVariables().map(e=>e.save()),e.length?e:null}load(e,t){let n=s(I.VARIABLE_MODEL,cc);e.forEach(e=>{n?.load(e,t)})}clear(e){e.getVariableMap().clear()}};Ut(`variables`,new yv);var bv={};bv.VariableSerializer=yv;var xv={};xv.load=Ss,xv.save=xs;var Sv={blocks:wd,exceptions:Sd,priorities:vu,procedures:vv,registry:yu,variables:bv,workspaceComments:xu,workspaces:xv};`Blockly`in globalThis||(globalThis.Blockly={Msg:Yu});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(I.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&&j(this.selectedGlowFilter),this.replacementGlowFilter&&j(this.replacementGlowFilter)}makeStartHat(){let e=this.START_HAT_HEIGHT,t=this.START_HAT_WIDTH,n=Wa(`c`,[N(25,-e),N(71,-e),N(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,qa(-r*i,e)+qa(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 Ya(`a`,`0 0,`+a,e,N((r?1:-1)*e,(t?-1:1)*e))+P(`v`,(t?-1:1)*i)+Ya(`a`,`0 0,`+a,e,N((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 Ya(`a`,`0 0,`+i,t,N((r?1:-1)*t,(n?-1:1)*t))+P(`v`,(n?-1:1)*e)+Ya(`a`,`0 0,`+i,t,N((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 X.INPUT_VALUE:case X.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 X.PREVIOUS_STATEMENT:case X.NEXT_STATEMENT:return this.NOTCH;default:throw Error(`Unknown type`)}}makeNotch(){function e(e){return Wa(`c`,[N(e*i/2,0),N(e*i*3/4,o/2),N(e*i,o)])+Ja([N(e*i,a)])+Wa(`c`,[N(e*i/4,o/2),N(e*i/2,o),N(e*i,o)])+P(`h`,e*r)+Wa(`c`,[N(e*i/2,0),N(e*i*3/4,-(o/2)),N(e*i,-o)])+Ja([N(e*i,-a)])+Wa(`c`,[N(e*i/4,-(o/2)),N(e*i/2,-o),N(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=Ya(`a`,`0 0,0`,e,N(-e,e)),n=Ya(`a`,`0 0,1`,e,N(-e,e));return{width:e,height:e,pathTop:t,pathBottom:Ya(`a`,`0 0,0`,e,N(e,e)),rightWidth:e,rightHeight:e,pathTopRight:n,pathBottomRight:Ya(`a`,`0 0,1`,e,N(e,e))}}generateSecondaryColour_(e){return yi(`#000`,e,.15)||e}generateTertiaryColour_(e){return yi(`#000`,e,.25)||e}createDom(e,t,n,r){super.createDom(e,t,n,r),e=E(z.DEFS,{},e),t=E(z.FILTER,{id:`blocklySelectedGlowFilter`+this.randomIdentifier,height:`160%`,width:`180%`,y:`-30%`,x:`-40%`},e),E(z.FEGAUSSIANBLUR,{in:`SourceGraphic`,stdDeviation:this.SELECTED_GLOW_SIZE},t),n=E(z.FECOMPONENTTRANSFER,{result:`outBlur`},t),E(z.FEFUNCA,{type:`table`,tableValues:`0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1`},n),E(z.FEFLOOD,{"flood-color":this.SELECTED_GLOW_COLOUR,"flood-opacity":1,result:`outColor`},t),E(z.FECOMPOSITE,{in:`outColor`,in2:`outBlur`,operator:`in`,result:`outGlow`},t),this.selectedGlowFilterId=t.id,this.selectedGlowFilter=t,e=E(z.FILTER,{id:`blocklyReplacementGlowFilter`+this.randomIdentifier,height:`160%`,width:`180%`,y:`-30%`,x:`-40%`},e),E(z.FEGAUSSIANBLUR,{in:`SourceGraphic`,stdDeviation:this.REPLACEMENT_GLOW_SIZE},e),t=E(z.FECOMPONENTTRANSFER,{result:`outBlur`},e),E(z.FEFUNCA,{type:`table`,tableValues:`0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1`},t),E(z.FEFLOOD,{"flood-color":this.REPLACEMENT_GLOW_COLOUR,"flood-opacity":1,result:`outColor`},e),E(z.FECOMPOSITE,{in:`outColor`,in2:`outBlur`,operator:`in`,result:`outGlow`},e),E(z.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?P(`V`,e.yPos+n):``,this.outlinePath_+=t+e+(r?i.pathTopRight:``);return}}this.outlinePath_+=P(`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_+=Ka(e.xPos,this.info_.startY),this.outlinePath_+=P(`h`,e.width)}drawFlatBottom_(){let e=this.info_.bottomRow;this.positionNextConnection_(),this.outlinePath_+=P(`V`,e.baseline),this.outlinePath_+=P(`h`,-e.width)}drawInlineInput_(e){this.positionInlineInputConnection_(e);let t=e.input.name;e.connectedBlock||this.info_.isInsertionMarker||(e=Ga(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 P(`h`,t)+e.shape.pathRightDown(n)+P(`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+P(`h`,-(t.notchOffset-r.width))+r.pathTop,a=e.height-2*r.height;t=r.pathBottom+P(`h`,t.notchOffset-r.width)+(t.connectedBottomNextConnection?``:t.shape.pathLeft),this.outlinePath_+=P(`H`,n)+i+P(`v`,a)+t+P(`H`,e.xPos+e.width),this.positionStatementInputConnection_(e)}drawConnectionHighlightPath(e){let t=e.connectionModel;if(t.type===X.NEXT_STATEMENT||t.type===X.PREVIOUS_STATEMENT||t.type===X.OUTPUT_VALUE&&!e.isDynamicShape)return super.drawConnectionHighlightPath(e);e=t.type===X.INPUT_VALUE?Ga(e.connectionWidth,-e.height/2)+this.getInlineInputPath(e):Ga(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 bf{constructor(e,t,n,r,i,a,o){if(super(bf.SKIP_SETUP),this.imageElement=this.clickHandler=null,this.flipRtl=this.isDirty_=this.EDITABLE=!1,this.altText=``,n=Number(Ci(n)),t=Number(Ci(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 V(t,n+Av.Y_PADDING),this.imageHeight=n,typeof i==`function`&&(this.clickHandler=i),e!==bf.SKIP_SETUP&&(o?this.configure_(o):(this.flipRtl=!!a,this.altText=Ci(r)||``),this.setValue(Ci(e)))}configure_(e){super.configure_(e),e.flipRtl&&(this.flipRtl=e.flipRtl),e.alt&&(this.altText=Ci(e.alt))}initView(){this.imageElement=E(z.IMAGE,{height:this.imageHeight+`px`,width:this.size_.width+`px`,alt:this.altText},this.fieldGroup_),this.imageElement.setAttributeNS(tl,`xlink:href`,this.value_),this.fieldGroup_&&D(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(tl,`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,Ea(`field_image`,Av),Av.prototype.DEFAULT_VALUE=``;var jv={};jv.FieldImage=Av;var Mv=14,Nv=class extends bf{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(bf.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!==bf.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 xf;super.initView(),this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot()),this.fieldGroup_&&D(this.fieldGroup_,`blocklyInputField`)}isFullBlockField(){let e=this.getSourceBlock();if(!e)throw new xf;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_&&Me()&&this.value_!==e&&t&&C(new(T(L.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 xf;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`),Qt(e,ku.INVALID,!1)):(D(e,`blocklyInvalidInput`),Qt(e,ku.INVALID,!0))}if(e=this.getSourceBlock(),!e)throw new xf;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&&(Pc||Ac||jc)?this.showPromptEditor():this.showInlineEditor(t,n)}showPromptEditor(){mn(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 xf;ki(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 xf;e.setGroup$$module$build$src$core$events$utils(!0);let n=Ei();var r=this.getClickTarget_();if(!r)throw Error(`A click target has not been set.`);D(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_&&Me()&&this.valueWhenEditorWasOpened_!==null&&this.valueWhenEditorWasOpened_!==this.value_&&(C(new(T(L.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=Ei().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),null),this.onInputWrapper&&=(v(this.onInputWrapper),null)}onHtmlInputKeyDown_(t){if(t.key===`Enter`)Mi(this),Fr();else if(t.key===`Escape`)this.setValue(this.htmlInput_.getAttribute(`data-untyped-default-value`),!1),Mi(this),Fr();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&&(Mi(this),Fr(),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_&&Me()&&this.value_!==e&&C(new(T(L.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_(){tn().then(()=>{let e=this.getSourceBlock();if(!e)throw new xf;let t=Ei(),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?(uo(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_&&D(this.fieldGroup_,`blocklyTextInputField`)}doClassValidation_(e){return e===void 0?null:`${e}`}static fromJson(e){return new this(Ci(e.text),void 0,e)}},Ea(`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,ul.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),k(this.svgPathSelected,ul.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),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,E(z.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_}};Vo(`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===X.PREVIOUS_STATEMENT||t.type===X.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(),nn(),a.connect(n);let o={x:n.x-a.x,y:n.y-a.y},s=a.getOffsetInBlock().clone();return tn().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=Un(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=Qn(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(),null),this.fadedBlock&&=(this.fadedBlock.fadeForReplacement(!1),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(I.CONNECTION_PREVIEWER,cc,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=Cs;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.`),Xe());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&&=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_===H.LEFT?e.width:n.width-this.getWidth():this.toolboxPosition_===H.LEFT?0:n.width:this.toolboxPosition_===H.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_===H.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),Ni(this.workspace_),Fr()}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_===H.LEFT?new B(-1e9,1e9,-1e9,t+e.width):new B(-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+=ql.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_!==H.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(I.FLYOUTS_VERTICAL_TOOLBOX,cc,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_===H.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_===H.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),Ni(this.workspace_),Fr()}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_===H.TOP?new B(-1e9,t+e.height,-1e9,1e9):new B(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+=ql.scrollbarThickness,this.getHeight()!==e&&(this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==H.TOP||this.targetWorkspace.translate(this.targetWorkspace.scrollX,this.targetWorkspace.scrollY+e),this.height_=e,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets())}};t(I.FLYOUTS_HORIZONTAL_TOOLBOX,cc,iy);var ay={};ay.HorizontalFlyout=iy;var oy=class extends vp{constructor(e,t,n,r,i){super(bf.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 V(0,0),e!==bf.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 xf;this.variable||(t=e.getOrCreateVariablePackage$$module$build$src$core$variables(t.workspace,null,this.defaultVariableName,this.defaultType),this.doValueUpdate_(t.getId()))}initView(){super.initView(),D(this.fieldGroup_,`blocklyVariableField`)}shouldAddBorderRect_(){let e=this.getSourceBlock();if(!e)throw new xf;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 xf;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: `+sa(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 xf;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 xf;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 xf;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(Ci(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(Vn),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}};Ea(`field_variable`,oy);var sy={};sy.FieldVariable=oy;var cy=class extends Nv{constructor(e,t,n,r,i,a){super(bf.SKIP_SETUP),this.min_=-1/0,this.max_=1/0,this.precision_=0,this.decimalPlaces=null,this.spellcheck_=!1,e!==bf.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_}`,Qt(e,ku.VALUEMIN,this.min_)),this.max_<1/0&&(e.max=`${this.max_}`,Qt(e,ku.VALUEMAX,this.max_)),e}initView(){super.initView(),this.fieldGroup_&&D(this.fieldGroup_,`blocklyNumberField`)}static fromJson(e){return new this(e.value,void 0,void 0,void 0,void 0,e)}};Ea(`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(Ci(e.text),void 0,e)}};Ea(`field_label_serializable`,uy);var dy={};dy.FieldLabelSerializable=uy;var fy=class extends bf{constructor(e,t,n){super(bf.SKIP_SETUP),this.SERIALIZABLE=!0,this.value_=this.value_,this.checkChar=fy.CHECK_CHAR,e!==bf.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();D(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=`✓`,Ea(`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),ho(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=R.sum(this.startLoc,t),this.draggable.drag(t,e)}wouldDeleteDraggable(e,t){return(e=this.workspace.getDragTarget(e))&&this.workspace.getComponentManager().hasCapability(e.id,Ml.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=ho(i)&&this.wouldDeleteDraggable(t,i))&&this.draggable instanceof Bm&&to(this.draggable.getRootBlock()),this.draggable.endDrag(t),r&&ho(i)&&(e.setGroup$$module$build$src$core$events$utils(n),i.dispose()),e.setGroup$$module$build$src$core$events$utils(!1),!r&&Ue(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 R(e.x/this.workspace.scale,e.y/this.workspace.scale),this.workspace.isMutator&&e.scale(1/this.workspace.options.parentWorkspace.scale),e}};t(I.BLOCK_DRAGGER,cc,my);var hy={};hy.Dragger=my;var gy={};gy.BlockDragStrategy=Nm,gy.BubbleDragStrategy=Tp,gy.CommentDragStrategy=Vf,gy.Dragger=my;var _y=class extends Tl{constructor(e,t,n){super(e?e.workspace.id:void 0),this.type=L.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=Tl.fromJson(e,t,n??new _y),t.isStart=e.isStart,t.blockId=e.blockId,t.blocks=e.blocks,t}};t(I.EVENT,L.BLOCK_DRAG,_y);var vy={};vy.BlockDrag=_y;var yy=class extends Dd{constructor(e,t,n,r){super(e),this.type=L.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=Dd.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(I.EVENT,L.BLOCK_FIELD_INTERMEDIATE_CHANGE,yy);var by={};by.BlockFieldIntermediateChange=yy;var xy=class extends Dd{constructor(e){super(e),this.type=L.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=Dd.fromJson(e,t,n??new xy),t.oldParentId=e.oldParentId,t.oldInputName=e.oldInputName,e.oldCoordinate&&(n=e.oldCoordinate.split(`,`),t.oldCoordinate=new R(Number(n[0]),Number(n[1]))),t.newParentId=e.newParentId,t.newInputName=e.newInputName,e.newCoordinate&&(n=e.newCoordinate.split(`,`),t.newCoordinate=new R(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&&R.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===X.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(I.EVENT,L.BLOCK_MOVE,xy);var Sy={};Sy.BlockMove=xy;var Cy=class extends Tl{constructor(e,t,n){super(e?e.workspace.id:void 0),this.type=L.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=Tl.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||={}),t(I.EVENT,L.BUBBLE_OPEN,Cy);var Ty={};Ty.BubbleOpen=Cy,Ty.BubbleType=wy;var Ey=class extends Cl{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=Ee())}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=Cl.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`);Kt(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=L.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(I.EVENT,L.COMMENT_CHANGE,Oy);var ky={};ky.CommentChange=Oy;var Ay=class extends Ey{constructor(e,t){super(e),this.newCollapsed=t,this.type=L.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(I.EVENT,L.COMMENT_COLLAPSE,Ay);var jy={};jy.CommentCollapse=Ay;var My=class extends Ey{constructor(e){super(e),this.type=L.COMMENT_CREATE,e&&(this.xml=ea(e),this.json=Gt(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=sa(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(I.EVENT,L.COMMENT_CREATE,My);var Ny={};Ny.CommentCreate=My;var Py=class extends Ey{constructor(e){super(e),this.type=L.COMMENT_DELETE,e&&(this.xml=ea(e),this.json=Gt(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=sa(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(I.EVENT,L.COMMENT_DELETE,Py);var Fy={};Fy.CommentDelete=Py;var Iy=class extends Tl{constructor(e,t){super(e?e.workspace.id:void 0),this.type=L.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=Tl.fromJson(e,t,n??new Iy),t.isStart=e.isStart,t.commentId=e.commentId,t}};t(I.EVENT,L.COMMENT_DRAG,Iy);var Ly={};Ly.CommentDrag=Iy;var Ry=class extends Ey{constructor(e){super(e),this.type=L.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 R(Number(n[0]),Number(n[1])),n=e.newCoordinate.split(`,`),t.newCoordinate_=new R(Number(n[0]),Number(n[1])),t}isNull(){return R.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(I.EVENT,L.COMMENT_MOVE,Ry);var zy={};zy.CommentMove=Ry;var By=class extends Ey{constructor(e){super(e),this.type=L.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 V(e.oldWidth,e.oldHeight),t.newSize=new V(e.newWidth,e.newHeight),t}isNull(){return V.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(I.EVENT,L.COMMENT_RESIZE,By);var Vy={};Vy.CommentResize=By;var Hy=class extends Tl{constructor(e,t,n){super(n),this.type=L.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=Tl.fromJson(e,t,n??new Hy),t.oldItem=e.oldItem,t.newItem=e.newItem,t}};t(I.EVENT,L.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=L.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(I.EVENT,L.VAR_TYPE_CHANGE,Wy);var Gy={};Gy.VarTypeChange=Wy;var Ky=class extends Cl{constructor(e){super(),this.isBlank=!0,this.recordUndo=!1,this.type=L.FINISHED_LOADING,this.isBlank=!!e,e&&(this.workspaceId=e.id)}};t(I.EVENT,L.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=L.BLOCK_CHANGE,e.BLOCK_CREATE$$module$build$src$core$events$events=L.BLOCK_CREATE,e.BLOCK_DELETE$$module$build$src$core$events$events=L.BLOCK_DELETE,Jy=L.BLOCK_DRAG,e.BLOCK_MOVE$$module$build$src$core$events$events=L.BLOCK_MOVE,Yy=L.BLOCK_FIELD_INTERMEDIATE_CHANGE,Xy=L.BUBBLE_OPEN,Zy=L.BLOCK_CHANGE,Qy=L.CLICK,$y=L.COMMENT_CHANGE,eb=L.COMMENT_CREATE,tb=L.COMMENT_DELETE,nb=L.COMMENT_MOVE,rb=L.COMMENT_RESIZE,ib=L.COMMENT_DRAG,ab=L.BLOCK_CREATE,ob=L.BLOCK_DELETE,sb=L.FINISHED_LOADING,cb=L.BLOCK_MOVE,lb=L.SELECTED,ub=L.THEME_CHANGE,db=L.TOOLBOX_ITEM_SELECT,fb=L.TRASHCAN_OPEN,pb=L.UI,mb=L.VAR_CREATE,hb=L.VAR_DELETE,gb=L.VAR_RENAME,_b=L.VIEWPORT_CHANGE,Q={},Q.Abstract=Cl,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=zc,Q.BlockBase=Dd,Q.BlockChange=kd,Q.BlockCreate=lp,Q.BlockDelete=Zp,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=Dl,Q.ClickTarget=Ol,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=Yp,Q.THEME_CHANGE=ub,Q.TOOLBOX_ITEM_SELECT=db,Q.TRASHCAN_OPEN=fb,Q.ThemeChange=fp,Q.ToolboxItemSelect=Hy,Q.TrashcanOpen=G_,Q.UI=pb,Q.UiBase=Tl,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=mp,Q.clearPendingUndo=je,Q.disable=e.disable$$module$build$src$core$events$utils,Q.disableOrphans=Fe,Q.enable=e.enable$$module$build$src$core$events$utils,Q.filter=Ae,Q.fire=C,Q.fromJson=w,Q.get=T,Q.getDescendantIds=Pe,Q.getGroup=e.getGroup$$module$build$src$core$events$utils,Q.getRecordUndo=Ee,Q.isEnabled=Me,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,$s();var yb={};yb.registerCleanup=Ms,yb.registerCollapse=Ps,yb.registerCollapseExpandBlock=Ws,yb.registerComment=Hs,yb.registerCommentCreate=Xs,yb.registerCommentDelete=Js,yb.registerCommentDuplicate=Ys,yb.registerCommentOptions=Qs,yb.registerDefaultOptions=$s,yb.registerDelete=Ks,yb.registerDeleteAll=zs,yb.registerDisable=Gs,yb.registerDuplicate=Vs,yb.registerExpand=Fs,yb.registerHelp=qs,yb.registerInline=Us,yb.registerRedo=js,yb.registerUndo=As;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(I.FLYOUT_INFLATER,bb,xb);var Sb={};Sb.ButtonFlyoutInflater=xb;var Cb={};Cb.Bubble=Op,Cb.MiniWorkspaceBubble=Ap,Cb.TextBubble=Fm,Cb.TextInputBubble=Wp;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=fa(t,n)):(t.enabled===void 0&&(t.enabled=t.disabled!==`true`&&t.disabled!==!0),t.disabledReasons===void 0&&t.enabled===!1&&(t.disabledReasons=[U]),`x`in t&&delete t.x,`y`in t&&delete t.y,n=$n(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(it(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!==L.BLOCK_CREATE&&e.type!==L.BLOCK_DELETE||this.flyout.getWorkspace().getTopBlocks(!1).forEach(e=>{this.permanentlyDisabledBlocks.has(e)||this.updateStateBasedOnCapacity(e)})}getType(){return Tb}};t(I.FLYOUT_INFLATER,Tb,Eb);var Db={};Db.BlockFlyoutInflater=Eb;var Ob={};Ob.isPaster=ec;var kb={};kb.isRenderedElement=tc;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_+=Ka(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_+=P(`H`,n.xPos+n.width-this.highlightOffset));this.steps_+=P(`H`,e.xPos+e.width-this.highlightOffset)}drawJaggedEdge_(e){this.info_.RTL&&(this.steps_+=this.jaggedTeethPaths_.pathLeft+P(`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_+=Ga(t.xPos+t.width-this.highlightOffset,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)+P(`v`,n)}else this.steps_+=Ga(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_+=Ga(t.xPos,e.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+P(`v`,n)+this.insideCornerPaths_.pathBottom(this.RTL_)+qa(e.width-t.xPos-this.insideCornerPaths_.width,0)}else this.steps_+=Ga(t.xPos,e.yPos+e.height)+this.insideCornerPaths_.pathBottom(this.RTL_)+qa(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_+=P(`H`,t)),this.RTL_&&(this.steps_+=P(`H`,t),e.height>this.highlightOffset&&(this.steps_+=P(`V`,e.yPos+e.height-this.highlightOffset)))}drawBottomRow(e){if(this.RTL_)this.steps_+=P(`V`,e.baseline-this.highlightOffset);else{let t=this.info_.bottomRow.elements[0];Z.isLeftSquareCorner(t)?this.steps_+=Ga(e.xPos+this.highlightOffset,e.baseline-this.highlightOffset):Z.isLeftRoundedCorner(t)&&(this.steps_+=Ga(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_+=Ga(this.info_.startX,e):(this.steps_+=Ga(this.info_.startX+this.highlightOffset,this.info_.bottomRow.baseline-this.highlightOffset),this.steps_+=P(`V`,e)),this.steps_+=this.puzzleTabPaths_.pathUp(this.RTL_)),this.RTL_||(e=this.info_.topRow,Z.isLeftRoundedCorner(e.elements[0])?this.steps_+=P(`V`,this.outsideCornerPaths_.height):this.steps_+=P(`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_+=Ga(n-t,a)+P(`v`,r)+this.puzzleTabPaths_.pathDown(this.RTL_)+P(`v`,e)+P(`h`,i)):this.inlineSteps_+=Ga(e.xPos+e.width+t,a)+P(`v`,e.height)+P(`h`,-i)+Ga(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_+=P(`H`,e.xPos+e.width)+P(`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=Ka(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=Ka(n,n)+Ya(`a`,`0 0,0`,e,N(-n-t,e-n)),i=Ya(`a`,`0 0,0`,e+t,N(e+t,e+t)),a=Ka(n,-n)+Ya(`a`,`0 0,0`,e+t,N(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=Ka(n,n)+Ya(`a`,`0 0,1`,e-t,N(e-n,-n+t)),i=Ka(t,e)+Ya(`a`,`0 0,1`,e-t,N(e,-e+t)),a=-n,o=Ka(n,a)+Ya(`a`,`0 0,1`,e-t,N(-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=Ka(-2,-t+2.5+.9)+qa(e*-.45,-2.1),r=P(`v`,2.5)+Ka(-e*.97,2.5)+Wa(`q`,[N(-e*.05,10),N(e*.3,9.5)])+Ka(e*.67,-1.9)+P(`v`,2.5),i=P(`v`,-1.5)+Ka(e*-.92,-.5)+Wa(`q`,[N(e*-.19,-5.5),N(0,-11)])+Ka(e*.92,1),a=Ka(-5,t-.7)+qa(e*.46,-2.1);return{width:e,height:t,pathUp(e){return e?n:i},pathDown(e){return e?r:a}}}makeNotch(){return{pathLeft:P(`h`,this.OFFSET)+this.constantProvider.NOTCH.pathLeft}}makeJaggedTeeth(){return{pathLeft:qa(5.1,2.6)+Ka(-10.2,6.8)+qa(5.1,2.6),height:12,width:10.2}}makeStartHat(){let e=this.constantProvider.START_HAT.height,t=Ka(25,-8.7)+Wa(`c`,[N(29.7,-6.2),N(57.2,-.5),N(75,8.7)]),n=Wa(`c`,[N(17.8,-9.2),N(45.3,-14.9),N(75,-8.7)])+Ga(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=E(z.PATH,{class:`blocklyPathDark`,transform:`translate(1,1)`}),this.svgRoot.insertBefore(this.svgPathDark,this.svgPath),this.svgPathLight=E(z.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=yi(`#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}};Vo(`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)}};Vo(`thrasos`,Zb);var Qb={};Qb.Renderer=Zb;var $b={};$b.RenderInfo=Yb,$b.Renderer=Zb;var ex={Classic:Sp,Zelos:new bp(`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?Ci(e.name):``,this.colour_=this.getColour_(e),Object.assign(this.cssConfig_,e.cssconfig||e.cssConfig)}createDom_(){this.htmlDiv_=this.createContainer_(),Zt(this.htmlDiv_,Ou.TREEITEM),Qt(this.htmlDiv_,ku.SELECTED,!1),Qt(this.htmlDiv_,ku.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_(),Zt(this.iconDom_,Ou.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&&Qt(this.htmlDiv_,ku.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&&D(e,t),e}createRowContainer_(){let e=document.createElement(`div`);var t=this.cssConfig_.row;return t&&D(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&&D(e,t),e}createIconDom_(){let e=document.createElement(`span`);if(!this.parentToolbox_.isHorizontal()){let t=this.cssConfig_.icon;t&&D(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)&&D(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=Ci(e),e==null||e===``)return``;var t=Number(e);return isNaN(t)?(t=hi(e))?t:(console.warn(`Toolbox category "`+this.name_+`" has unrecognized colour attribute: `+e),``):bi(t)}openIcon_(e){if(e){var t=this.cssConfig_.closedicon;t&&O(e,t),(t=this.cssConfig_.openicon)&&D(e,t)}}closeIcon_(e){if(e){var t=this.cssConfig_.openicon;t&&O(e,t),(t=this.cssConfig_.closedicon)&&D(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&&D(this.rowDiv_,t)}else this.rowDiv_.style.backgroundColor=``,t&&k(this.rowDiv_,t);Qt(this.htmlDiv_,ku.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:Mt(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(){j(this.htmlDiv_)}};rx.registrationName=`category`,rx.nestedPadding=19,rx.borderWidth=8,rx.defaultBackgroundColour=`#57e`,ut(`
|
|
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(I.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&&D(e,t),this.htmlDiv=e}getDiv(){return this.htmlDiv}dispose(){j(this.htmlDiv)}};ax.registrationName=`sep`,ut(`
|
|
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(I.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(I.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`&&Ft(e)&&(t=sx.registrationName),e=new(o(I.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),Zt(this.subcategoriesDiv_,Ou.GROUP),this.htmlDiv_.appendChild(this.subcategoriesDiv_),this.closeIcon_(this.iconDom_),Qt(this.htmlDiv_,ku.EXPANDED,!1),this.htmlDiv_}createIconDom_(){let e=document.createElement(`span`);if(!this.parentToolbox_.isHorizontal()){let t=this.cssConfig_.icon;t&&D(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&&D(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_)}Qt(this.htmlDiv_,ku.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(I.TOOLBOX_ITEM,sx.registrationName,sx);var cx={};cx.CollapsibleToolboxCategory=sx;var lx={};lx.isSelectableToolboxItem=nc;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`);D(r,`blocklyToolboxFlyout`),Ie(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:Ml.ComponentWeight.TOOLBOX_WEIGHT,capabilities:[Ml.Capability.AUTOHIDEABLE,Ml.Capability.DELETE_AREA,Ml.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_(),Zt(this.contentsDiv_,Ou.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`),D(e,`blocklyToolbox`),e.setAttribute(`dir`,this.RTL?`RTL`:`LTR`),e}createContentsContainer_(){let e=document.createElement(`div`);return D(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,ee(e)||e.target===this.HtmlDiv)Xe().hideChaff(!1);else{var t=e.target.getAttribute(`id`);t&&(t=this.getToolboxItemById(t),t!=null&&t.isSelectable())&&(this.setSelectedItem(t),t.onClick(e)),Xe().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(I.FLYOUTS_HORIZONTAL_TOOLBOX,e.options,!0):l(I.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`&&Ft(e)&&(n=sx.registrationName),n=o(I.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&&D(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===H.TOP?new B(-1e7,n,-1e7,1e7):this.toolboxPosition===H.BOTTOM?new B(t,1e7,-1e7,1e7):this.toolboxPosition===H.LEFT?new B(-1e7,1e7,-1e7,e):new B(-1e7,1e7,r,1e7)}wouldDelete(e){return e instanceof Bm?this.updateWouldDelete_(!e.getParent()&&e.isDeletable()):this.updateWouldDelete_(ho(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===H.TOP?t.style.top=`0`:t.style.bottom=`0`):(this.toolboxPosition===H.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===H.LEFT?e.scrollX+t.width+(n!=null&&n.isVisible()?n.getWidth():0):e.scrollX;t=this.toolboxPosition===H.TOP?e.scrollY+t.height+(n!=null&&n.isVisible()?n.getHeight():0):e.scrollY,e.translate(r,t),rt(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&&!nc(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),Qt(this.contentsDiv_,ku.ACTIVEDESCENDANT,``)}selectItem_(e,t){this.selectedItem_=t,this.previouslySelectedItem_=e,t.setSelected(!0),Qt(this.contentsDiv_,ku.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(T(L.TOOLBOX_ITEM_SELECT))(n,r,this.workspace_.id),C(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),j(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)}};ut(`
|
|
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(I.TOOLBOX,cc,ux);var dx={};dx.Toolbox=ux;var fx=`12.5.1`,px=X.INPUT_VALUE,mx=X.OUTPUT_VALUE,hx=X.NEXT_STATEMENT,gx=X.PREVIOUS_STATEMENT,_x=H.TOP,vx=H.BOTTOM,yx=H.LEFT,bx=H.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 ip(this,e)},j_.prototype.newComment=function(e){return new op(this,e)},j_.newTrashcan=function(e){return new q_(e)},Ap.prototype.newWorkspaceSvg=function(e){return new j_(e)},e.Names$$module$build$src$core$names.prototype.populateProcedures=function(t){t=Eo(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=uc,$.ButtonFlyoutInflater=xb,$.COLLAPSED_FIELD_NAME=Ru,$.COLLAPSED_INPUT_NAME=Lu,$.COLLAPSE_CHARS=om,$.CodeGenerator=e.CodeGenerator$$module$build$src$core$generator,$.CollapsibleToolboxCategory=sx,$.ComponentManager=Ml,$.Connection=$p,$.ConnectionChecker=C_,$.ConnectionDB=qp,$.ConnectionNavigationPolicy=_h,$.ConnectionType=X,$.ContextMenu=Ff,$.ContextMenuItems=yb,$.ContextMenuRegistry=Y,$.Css=Ll,$.DELETE_VARIABLE_ID=lm,$.DeleteArea=Gm,$.DragTarget=Hm,$.DropDownDiv=Xd,$.Events=Q,$.Extensions=zp,$.Field=bf,$.FieldCheckbox=fy,$.FieldDropdown=vp,$.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=ul,$.FocusableTreeTraverser=sl,$.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=Nu,$.MenuItem=ju,$.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=Cp,$.PREVIOUS_STATEMENT=gx,$.PROCEDURE_CATEGORY_NAME=vg,$.Procedures=yg,$.RENAME_VARIABLE_ID=cm,$.RenderedConnection=dm,$.Scrollbar=ql,$.ScrollbarPair=Lh,$.SeparatorFlyoutInflater=Bh,$.ShortcutItems=gv,$.ShortcutRegistry=hl,$.TOOLBOX_AT_BOTTOM=vx,$.TOOLBOX_AT_LEFT=yx,$.TOOLBOX_AT_RIGHT=bx,$.TOOLBOX_AT_TOP=_x,$.Theme=bp,$.ThemeManager=y_,$.Themes=ex,$.Toast=$u,$.Toolbox=ux,$.ToolboxCategory=rx,$.ToolboxItem=tx,$.ToolboxSeparator=ax,$.Tooltip=mf,$.Touch=gc,$.Trashcan=q_,$.UnattachedFieldError=xf,$.VARIABLE_CATEGORY_NAME=md,$.VARIABLE_DYNAMIC_CATEGORY_NAME=x_,$.VERSION=fx,$.VariableMap=U_,$.VariableModel=L_,$.Variables=_d,$.VariablesDynamic=S_,$.VerticalFlyout=ny,$.WidgetDiv=jf,$.Workspace=T_,$.WorkspaceAudio=O_,$.WorkspaceDragger=Yh,$.WorkspaceNavigationPolicy=jh,$.WorkspaceSvg=j_,$.Xml=cp,$.ZoomControls=fu,$.blockAnimations=km,$.blockRendering=v_,$.browserEvents=Rc,$.bubbles=Cb,$.bumpObjects=Mm,$.clipboard=fv,$.comments=pv,$.common=Sl,$.config=e.config$$module$build$src$core$config,$.constants=zu,$.defineBlocksWithJsonArray=ot,$.dialog=ld,$.dragging=gy,$.fieldRegistry=_p,$.geras=Jb,$.getFocusManager=e.getFocusManager$$module$build$src$core$focus_manager,$.getMainWorkspace=Xe,$.getSelected=Qe,$.hasBubble=fr,$.hideChaff=rc,$.icons=fg,$.inject=Cs,$.inputs=Qv,$.isCopyable=ss,$.isDeletable=ho,$.isDraggable=So,$.isIcon=$a,$.isObservable=To,$.isPaster=ec,$.isRenderedElement=tc,$.isSelectable=We,$.isSerializable=$t,$.isVariableBackedParameterModel=bn,$.keyboardNavigationController=qh,$.layers=Bf,$.navigateBlock=vo,$.navigateStacks=_o,$.procedures=yg,$.registry=lc,$.renderManagement=qu,$.serialization=Sv,$.setLocale=Ju,$.setParentContainer=nt,$.svgResize=rt,$.thrasos=$b,$.uiPosition=uu,$.utils=Up,$.zelos=vb;var xx={};return xx.isFocusableTree=ic,$.__namespace__=e,$})}));const{Block:ee,BlockFlyoutInflater:b,BlockNavigationPolicy:te,BlockSvg:ne,Blocks:re,ButtonFlyoutInflater:ie,COLLAPSED_FIELD_NAME:ae,COLLAPSED_INPUT_NAME:oe,COLLAPSE_CHARS:se,CodeGenerator:ce,CollapsibleToolboxCategory:x,ComponentManager:le,Connection:ue,ConnectionChecker:de,ConnectionDB:S,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:Ee,FieldImage:C,FieldLabel:De,FieldLabelSerializable:Oe,FieldNavigationPolicy:ke,FieldNumber:Ae,FieldTextInput:je,FieldVariable:Me,Flyout:Ne,FlyoutButton:Pe,FlyoutButtonNavigationPolicy:w,FlyoutItem:T,FlyoutMetricsManager:Fe,FlyoutNavigationPolicy:E,FlyoutNavigator:D,FlyoutSeparator:O,FlyoutSeparatorNavigationPolicy:k,FocusManager:A,FocusableTreeTraverser:j,Generator:Ie,Gesture:M,Grid:Le,HorizontalFlyout:Re,INPUT_VALUE:ze,Input:Be,InsertionMarkerPreviewer:Ve,KeyboardNavigationController:He,LabelFlyoutInflater:Ue,LineCursor:We,Marker:Ge,MarkerManager:Ke,Menu:qe,MenuItem:Je,MetricsManager:Ye,Msg:Xe,NEXT_STATEMENT:Ze,Names:Qe,Navigator:$e,OPPOSITE_TYPE:et,OUTPUT_VALUE:tt,Options:nt,PREVIOUS_STATEMENT:rt,PROCEDURE_CATEGORY_NAME:it,Procedures:at,RENAME_VARIABLE_ID:ot,RenderedConnection:st,Scrollbar:ct,ScrollbarPair:lt,SeparatorFlyoutInflater:ut,ShortcutItems:dt,ShortcutRegistry:ft,TOOLBOX_AT_BOTTOM:pt,TOOLBOX_AT_LEFT:mt,TOOLBOX_AT_RIGHT:ht,TOOLBOX_AT_TOP:gt,Theme:_t,ThemeManager:vt,Themes:yt,Toast:bt,Toolbox:xt,ToolboxCategory:St,ToolboxItem:Ct,ToolboxSeparator:wt,Tooltip:Tt,Touch:Et,Trashcan:Dt,UnattachedFieldError:Ot,VARIABLE_CATEGORY_NAME:kt,VARIABLE_DYNAMIC_CATEGORY_NAME:At,VERSION:jt,VariableMap:Mt,VariableModel:Nt,Variables:Pt,VariablesDynamic:Ft,VerticalFlyout:It,WidgetDiv:Lt,Workspace:Rt,WorkspaceAudio:zt,WorkspaceDragger:Bt,WorkspaceNavigationPolicy:Vt,WorkspaceSvg:Ht,Xml:Ut,ZoomControls:Wt,blockAnimations:Gt,blockRendering:Kt,browserEvents:qt,bubbles:Jt,bumpObjects:Yt,clipboard:Xt,comments:Zt,common:Qt,config:$t,constants:en,defineBlocksWithJsonArray:tn,dialog:nn,dragging:rn,fieldRegistry:an,geras:on,getFocusManager:sn,getMainWorkspace:cn,getSelected:ln,hasBubble:un,hideChaff:dn,icons:fn,inject:pn,inputs:mn,isCopyable:hn,isDeletable:gn,isDraggable:_n,isIcon:vn,isObservable:yn,isPaster:bn,isRenderedElement:xn,isSelectable:Sn,isSerializable:Cn,isVariableBackedParameterModel:wn,keyboardNavigationController:Tn,layers:En,navigateBlock:Dn,navigateStacks:On,procedures:kn,registry:An,renderManagement:jn,serialization:Mn,setLocale:Nn,setParentContainer:Pn,svgResize:Fn,thrasos:In,uiPosition:Ln,utils:Rn,zelos:zn}=e(y(),1).default;var Bn=t(((e,t)=>{(function(n,r){typeof define==`function`&&define.amd?define([`./blockly_compressed.js`],r):typeof e==`object`?t.exports=r(y()):(n.javascript=r(n.Blockly),n.Blockly.JavaScript=n.javascript.javascriptGenerator)})(e,function(e){var t=e.__namespace__,n=function(e,t){return[`[]`,w.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,w.NONE)||`null`;return[`[`+n.join(`, `)+`]`,w.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`,w.NONE)||`null`;return e=t.valueToCode(e,`NUM`,w.NONE)||`0`,[n+`(`+r+`, `+e+`)`,w.FUNCTION_CALL]},a=function(e,t){return[(t.valueToCode(e,`VALUE`,w.MEMBER)||`[]`)+`.length`,w.MEMBER]},o=function(e,t){return[`!`+(t.valueToCode(e,`VALUE`,w.MEMBER)||`[]`)+`.length`,w.LOGICAL_NOT]},s=function(e,t){let n=e.getFieldValue(`END`)===`FIRST`?`indexOf`:`lastIndexOf`,r=t.valueToCode(e,`FIND`,w.NONE)||`''`;return t=(t.valueToCode(e,`VALUE`,w.MEMBER)||`[]`)+`.`+n+`(`+r+`)`,e.workspace.options.oneBasedIndex?[t+` + 1`,w.ADDITION]:[t,w.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`?w.NONE:w.MEMBER)||`[]`;switch(r){case`FIRST`:if(n===`GET`)return[i+`[0]`,w.MEMBER];if(n===`GET_REMOVE`)return[i+`.shift()`,w.MEMBER];if(n===`REMOVE`)return i+`.shift();
|
|
804
|
-
`;break;case`LAST`:if(n===`GET`)return[i+`.slice(-1)[0]`,w.MEMBER];if(n===`GET_REMOVE`)return[i+`.pop()`,w.MEMBER];if(n===`REMOVE`)return i+`.pop();
|
|
805
|
-
`;break;case`FROM_START`:if(e=t.getAdjusted(e,`AT`),n===`GET`)return[i+`[`+e+`]`,w.MEMBER];if(n===`GET_REMOVE`)return[i+`.splice(`+e+`, 1)[0]`,w.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]`,w.FUNCTION_CALL];if(n===`GET_REMOVE`)return[i+`.splice(`+e+`, 1)[0]`,w.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,w.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`,w.MEMBER)||`[]`,a=e.getFieldValue(`MODE`)||`GET`;var o=e.getFieldValue(`WHERE`)||`FROM_START`;let s=n.valueToCode(e,`TO`,w.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,w.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`,w.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,w.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,w.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 = ${E(`sequence`,i,`at1`)};
|
|
831
|
-
var end = ${E(`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,w.FUNCTION_CALL]},d=function(e,t){let n=t.valueToCode(e,`LIST`,w.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+`))`,w.FUNCTION_CALL]},f=function(e,t){let n=t.valueToCode(e,`INPUT`,w.MEMBER);if(t=t.valueToCode(e,`DELIM`,w.NONE)||`''`,e=e.getFieldValue(`MODE`),e===`SPLIT`)n||=`''`,e=`split`;else if(e===`JOIN`)n||=`[]`,e=`join`;else throw Error(`Unknown mode: `+e);return[n+`.`+e+`(`+t+`)`,w.FUNCTION_CALL]},p=function(e,t){return[(t.valueToCode(e,`LIST`,w.FUNCTION_CALL)||`[]`)+`.slice().reverse()`,w.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,w.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===`!=`?w.EQUALITY:w.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===`&&`?w.LOGICAL_AND:w.LOGICAL_OR,i=t.valueToCode(e,`A`,r);return e=t.valueToCode(e,`B`,r),i||e?(t=n===`&&`?`true`:`false`,i||=t,e||=t):e=i=`false`,[i+` `+n+` `+e,r]},_=function(e,t){let n=w.LOGICAL_NOT;return[`!`+(t.valueToCode(e,`BOOL`,n)||`true`),n]},v=function(e,t){return[e.getFieldValue(`BOOL`)===`TRUE`?`true`:`false`,w.ATOMIC]},y=function(e,t){return[`null`,w.ATOMIC]},ee=function(e,t){let n=t.valueToCode(e,`IF`,w.CONDITIONAL)||`false`,r=t.valueToCode(e,`THEN`,w.CONDITIONAL)||`null`;return e=t.valueToCode(e,`ELSE`,w.CONDITIONAL)||`null`,[n+` ? `+r+` : `+e,w.CONDITIONAL]},b=function(e,n){let r;r=e.getField(`TIMES`)?String(Number(e.getFieldValue(`TIMES`))):n.valueToCode(e,`TIMES`,w.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?w.LOGICAL_NOT:w.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`,w.ASSIGNMENT)||`0`,a=n.valueToCode(e,`TO`,w.ASSIGNMENT)||`0`;let o=n.valueToCode(e,`BY`,w.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`,w.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?w.ATOMIC:w.UNARY_NEGATION]},oe=function(e,t){var n={ADD:[` + `,w.ADDITION],MINUS:[` - `,w.SUBTRACTION],MULTIPLY:[` * `,w.MULTIPLICATION],DIVIDE:[` / `,w.DIVISION],POWER:[null,w.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+`)`,w.FUNCTION_CALL]},se=function(e,t){let n=e.getFieldValue(`OP`),r;if(n===`NEG`)return e=t.valueToCode(e,`NUM`,w.UNARY_NEGATION)||`0`,e[0]===`-`&&(e=` `+e),[`-`+e,w.UNARY_NEGATION];switch(e=n===`SIN`||n===`COS`||n===`TAN`?t.valueToCode(e,`NUM`,w.DIVISION)||`0`:t.valueToCode(e,`NUM`,w.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,w.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,w.DIVISION]},ce=function(e,t){return{PI:[`Math.PI`,w.MEMBER],E:[`Math.E`,w.MEMBER],GOLDEN_RATIO:[`(1 + Math.sqrt(5)) / 2`,w.DIVISION],SQRT2:[`Math.SQRT2`,w.MEMBER],SQRT1_2:[`Math.SQRT1_2`,w.MEMBER],INFINITY:[`Infinity`,w.ATOMIC]}[e.getFieldValue(`CONSTANT`)]},x=function(e,t){var n={EVEN:[` % 2 === 0`,w.MODULUS,w.EQUALITY],ODD:[` % 2 === 1`,w.MODULUS,w.EQUALITY],WHOLE:[` % 1 === 0`,w.MODULUS,w.EQUALITY],POSITIVE:[` > 0`,w.RELATIONAL,w.RELATIONAL],NEGATIVE:[` < 0`,w.RELATIONAL,w.RELATIONAL],DIVISIBLE_BY:[null,w.MODULUS,w.EQUALITY],PRIME:[null,w.NONE,w.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`,w.MODULUS)||`0`,e=n+` % `+e+` === 0`):e=n+i,[e,o]},le=function(e,t){let n=t.valueToCode(e,`DELTA`,w.ADDITION)||`0`;return e=t.getVariableName(e.getFieldValue(`VAR`)),e+` = (typeof `+e+` === 'number' ? `+e+` : 0) + `+n+`;
|
|
892
|
-
`},ue=function(e,t){var n=e.getFieldValue(`OP`);switch(n){case`SUM`:e=t.valueToCode(e,`LIST`,w.MEMBER)||`[]`,e+=`.reduce(function(x, y) {return x + y;}, 0)`;break;case`MIN`:e=t.valueToCode(e,`LIST`,w.NONE)||`[]`,e=`Math.min.apply(null, `+e+`)`;break;case`MAX`:e=t.valueToCode(e,`LIST`,w.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`,w.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`,w.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`,w.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`,w.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`,w.NONE)||`[]`,e=n+`(`+e+`)`;break;default:throw Error(`Unknown operator: `+n)}return[e,w.FUNCTION_CALL]},de=function(e,t){let n=t.valueToCode(e,`DIVIDEND`,w.MODULUS)||`0`;return e=t.valueToCode(e,`DIVISOR`,w.MODULUS)||`0`,[n+` % `+e,w.MODULUS]},S=function(e,t){let n=t.valueToCode(e,`VALUE`,w.NONE)||`0`,r=t.valueToCode(e,`LOW`,w.NONE)||`0`;return e=t.valueToCode(e,`HIGH`,w.NONE)||`Infinity`,[`Math.min(Math.max(`+n+`, `+r+`), `+e+`)`,w.FUNCTION_CALL]},fe=function(e,t){let n=t.valueToCode(e,`FROM`,w.NONE)||`0`;return e=t.valueToCode(e,`TO`,w.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+`)`,w.FUNCTION_CALL]},pe=function(e,t){return[`Math.random()`,w.FUNCTION_CALL]},me=function(e,t){let n=t.valueToCode(e,`X`,w.NONE)||`0`;return[`Math.atan2(`+(t.valueToCode(e,`Y`,w.NONE)||`0`)+`, `+n+`) / Math.PI * 180`,w.DIVISION]},he=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&&=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`,w.NONE)||``);let s=``;a&&o&&(s=r),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},ge=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,w.NONE)||`null`;return[n+`(`+r.join(`, `)+`)`,w.FUNCTION_CALL]},_e=function(e,t){return t.forBlock.procedures_callreturn(e,t)[0]+`;
|
|
966
|
-
`},ve=function(e,t){let n=`if (`+(t.valueToCode(e,`CONDITION`,w.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`,w.NONE)||`null`,n+=t.INDENT+`return `+e+`;
|
|
968
|
-
`):n+=t.INDENT+`return;
|
|
969
|
-
`,n+`}
|
|
970
|
-
`},ye=function(e,t){return[t.quote_(e.getFieldValue(`TEXT`)),w.ATOMIC]},be=function(e,t){switch(e.itemCount_){case 0:return[`''`,w.ATOMIC];case 1:return e=t.valueToCode(e,`ADD0`,w.NONE)||`''`,M(e);case 2:var n=t.valueToCode(e,`ADD0`,w.NONE)||`''`;return e=t.valueToCode(e,`ADD1`,w.NONE)||`''`,[M(n)[0]+` + `+M(e)[0],w.ADDITION];default:n=Array(e.itemCount_);for(let r=0;r<e.itemCount_;r++)n[r]=t.valueToCode(e,`ADD`+r,w.NONE)||`''`;return[`[`+n.join(`,`)+`].join('')`,w.FUNCTION_CALL]}},xe=function(e,t){let n=t.getVariableName(e.getFieldValue(`VAR`));return e=t.valueToCode(e,`TEXT`,w.NONE)||`''`,n+` += `+M(e)[0]+`;
|
|
971
|
-
`},Se=function(e,t){return[(t.valueToCode(e,`VALUE`,w.MEMBER)||`''`)+`.length`,w.MEMBER]},Ce=function(e,t){return[`!`+(t.valueToCode(e,`VALUE`,w.MEMBER)||`''`)+`.length`,w.LOGICAL_NOT]},we=function(e,t){let n=e.getFieldValue(`END`)===`FIRST`?`indexOf`:`lastIndexOf`,r=t.valueToCode(e,`FIND`,w.NONE)||`''`;return t=(t.valueToCode(e,`VALUE`,w.MEMBER)||`''`)+`.`+n+`(`+r+`)`,e.workspace.options.oneBasedIndex?[t+` + 1`,w.ADDITION]:[t,w.FUNCTION_CALL]},Te=function(e,t){let n=e.getFieldValue(`WHERE`)||`FROM_START`,r=t.valueToCode(e,`VALUE`,n===`RANDOM`?w.NONE:w.MEMBER)||`''`;switch(n){case`FIRST`:return[r+`.charAt(0)`,w.FUNCTION_CALL];case`LAST`:return[r+`.slice(-1)`,w.FUNCTION_CALL];case`FROM_START`:return e=t.getAdjusted(e,`AT`),[r+`.charAt(`+e+`)`,w.FUNCTION_CALL];case`FROM_END`:return e=t.getAdjusted(e,`AT`,1,!0),[r+`.slice(`+e+`).charAt(0)`,w.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+`)`,w.FUNCTION_CALL]}throw Error(`Unhandled option (text_charAt).`)},Ee=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?w.MEMBER:w.NONE)||`''`;if(r===`FIRST`&&i===`LAST`)return[o,w.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,w.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,w.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 = ${Le(`sequence`,r,`at1`)};
|
|
979
|
-
var end = ${Le(`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,w.FUNCTION_CALL]},C=function(e,t){let n={UPPERCASE:`.toUpperCase()`,LOWERCASE:`.toLowerCase()`,TITLECASE:null}[e.getFieldValue(`CASE`)];return e=t.valueToCode(e,`TEXT`,n?w.MEMBER:w.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+`)`,w.FUNCTION_CALL]},De=function(e,t){let n={LEFT:`.replace(/^[\\s\\xa0]+/, '')`,RIGHT:`.replace(/[\\s\\xa0]+$/, '')`,BOTH:`.trim()`}[e.getFieldValue(`MODE`)];return[(t.valueToCode(e,`TEXT`,w.MEMBER)||`''`)+n,w.FUNCTION_CALL]},Oe=function(e,t){return`window.alert(`+(t.valueToCode(e,`TEXT`,w.NONE)||`''`)+`);
|
|
988
|
-
`},ke=function(e,t){return t=`window.prompt(`+(e.getField(`TEXT`)?t.quote_(e.getFieldValue(`TEXT`)):t.valueToCode(e,`TEXT`,w.NONE)||`''`)+`)`,e.getFieldValue(`TYPE`)===`NUMBER`&&(t=`Number(`+t+`)`),[t,w.FUNCTION_CALL]},Ae=function(e,t){let n=t.valueToCode(e,`TEXT`,w.NONE)||`''`;return e=t.valueToCode(e,`SUB`,w.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+`)`,w.FUNCTION_CALL]},je=function(e,t){let n=t.valueToCode(e,`TEXT`,w.NONE)||`''`,r=t.valueToCode(e,`FROM`,w.NONE)||`''`;return e=t.valueToCode(e,`TO`,w.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+`)`,w.FUNCTION_CALL]},Me=function(e,t){return[(t.valueToCode(e,`TEXT`,w.MEMBER)||`''`)+`.split('').reverse().join('')`,w.FUNCTION_CALL]},Ne=function(e,t){return[t.getVariableName(e.getFieldValue(`VAR`)),w.ATOMIC]},Pe=function(e,t){let n=t.valueToCode(e,`VALUE`,w.ASSIGNMENT)||`0`;return t.getVariableName(e.getFieldValue(`VAR`))+` = `+n+`;
|
|
1003
|
-
`},w;(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`})(w||={});var T=class extends t.CodeGenerator$$module$build$src$core$generator{constructor(e=`JavaScript`){super(e),this.ORDER_OVERRIDES=[[w.FUNCTION_CALL,w.MEMBER],[w.FUNCTION_CALL,w.FUNCTION_CALL],[w.MEMBER,w.MEMBER],[w.MEMBER,w.FUNCTION_CALL],[w.LOGICAL_NOT,w.LOGICAL_NOT],[w.MULTIPLICATION,w.MULTIPLICATION],[w.ADDITION,w.ADDITION],[w.LOGICAL_AND,w.LOGICAL_AND],[w.LOGICAL_OR,w.LOGICAL_OR]],this.isInitialized=!1;for(let t in w)e=w[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=w.NONE){e.workspace.options.oneBasedIndex&&r--;let o=e.workspace.options.oneBasedIndex?`1`:`0`,s=a;return r>0?s=w.ADDITION:r<0?s=w.SUBTRACTION:i&&(s=w.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)}},Fe={};Fe.JavascriptGenerator=T,Fe.Order=w;var E=function(e,t,n){return t===`FIRST`?`0`:t===`FROM_END`?e+`.length - 1 - `+n:t===`LAST`?e+`.length - 1`:n},D={};D.lists_create_empty=n,D.lists_create_with=r,D.lists_getIndex=c,D.lists_getSublist=u,D.lists_indexOf=s,D.lists_isEmpty=o,D.lists_length=a,D.lists_repeat=i,D.lists_reverse=p,D.lists_setIndex=l,D.lists_sort=d,D.lists_split=f;var O={};O.controls_if=m,O.controls_ifelse=m,O.logic_boolean=v,O.logic_compare=h,O.logic_negate=_,O.logic_null=y,O.logic_operation=g,O.logic_ternary=ee;var k={};k.controls_flow_statements=ie,k.controls_for=ne,k.controls_forEach=re,k.controls_repeat=b,k.controls_repeat_ext=b,k.controls_whileUntil=te;var A={};A.math_arithmetic=oe,A.math_atan2=me,A.math_change=le,A.math_constant=ce,A.math_constrain=S,A.math_modulo=de,A.math_number=ae,A.math_number_property=x,A.math_on_list=ue,A.math_random_float=pe,A.math_random_int=fe,A.math_round=se,A.math_single=se,A.math_trig=se;var j={};j.procedures_callnoreturn=_e,j.procedures_callreturn=ge,j.procedures_defnoreturn=he,j.procedures_defreturn=he,j.procedures_ifreturn=ve;var Ie=/^\s*'([^']|\\')*'\s*$/,M=function(e){return Ie.test(e)?[e,w.ATOMIC]:[`String(`+e+`)`,w.FUNCTION_CALL]},Le=function(e,t,n){return t===`FIRST`?`0`:t===`FROM_END`?e+`.length - 1 - `+n:t===`LAST`?e+`.length - 1`:n},Re={};Re.text=ye,Re.text_append=xe,Re.text_changeCase=C,Re.text_charAt=Te,Re.text_count=Ae,Re.text_getSubstring=Ee,Re.text_indexOf=we,Re.text_isEmpty=Ce,Re.text_join=be,Re.text_length=Se,Re.text_print=Oe,Re.text_prompt=ke,Re.text_prompt_ext=ke,Re.text_replace=je,Re.text_reverse=Me,Re.text_trim=De;var ze={};ze.variables_get=Ne,ze.variables_set=Pe;var Be={};Be.variables_get_dynamic=Ne,Be.variables_set_dynamic=Pe;var Ve=new T,He=Object.assign({},D,O,k,A,j,Re,ze,Be);for(let e in He)Ve.forBlock[e]=He[e];var Ue={};return Ue.JavascriptGenerator=T,Ue.Order=w,Ue.javascriptGenerator=Ve,Ue.__namespace__=t,Ue})}));const{JavascriptGenerator:Vn,Order:Hn,javascriptGenerator:Un}=e(Bn(),1).default;function Wn(){this.__data__=[],this.size=0}function Gn(e,t){return e===t||e!==e&&t!==t}function Kn(e,t){for(var n=e.length;n--;)if(Gn(e[n][0],t))return n;return-1}var qn=Array.prototype.splice;function Jn(e){var t=this.__data__,n=Kn(t,e);return n<0?!1:(n==t.length-1?t.pop():qn.call(t,n,1),--this.size,!0)}function Yn(e){var t=this.__data__,n=Kn(t,e);return n<0?void 0:t[n][1]}function Xn(e){return Kn(this.__data__,e)>-1}function Zn(e,t){var n=this.__data__,r=Kn(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Qn(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])}}Qn.prototype.clear=Wn,Qn.prototype.delete=Jn,Qn.prototype.get=Yn,Qn.prototype.has=Xn,Qn.prototype.set=Zn;function $n(){this.__data__=new Qn,this.size=0}function er(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function tr(e){return this.__data__.get(e)}function nr(e){return this.__data__.has(e)}var rr=typeof global==`object`&&global&&global.Object===Object&&global,ir=typeof self==`object`&&self&&self.Object===Object&&self,ar=rr||ir||Function(`return this`)(),or=ar.Symbol,sr=Object.prototype,cr=sr.hasOwnProperty,lr=sr.toString,ur=or?or.toStringTag:void 0;function dr(e){var t=cr.call(e,ur),n=e[ur];try{e[ur]=void 0;var r=!0}catch{}var i=lr.call(e);return r&&(t?e[ur]=n:delete e[ur]),i}var fr=Object.prototype.toString;function pr(e){return fr.call(e)}var mr=`[object Null]`,hr=`[object Undefined]`,gr=or?or.toStringTag:void 0;function _r(e){return e==null?e===void 0?hr:mr:gr&&gr in Object(e)?dr(e):pr(e)}function vr(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var yr=`[object AsyncFunction]`,br=`[object Function]`,xr=`[object GeneratorFunction]`,Sr=`[object Proxy]`;function Cr(e){if(!vr(e))return!1;var t=_r(e);return t==br||t==xr||t==yr||t==Sr}var wr=ar[`__core-js_shared__`],Tr=function(){var e=/[^.]+$/.exec(wr&&wr.keys&&wr.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function Er(e){return!!Tr&&Tr in e}var Dr=Function.prototype.toString;function Or(e){if(e!=null){try{return Dr.call(e)}catch{}try{return e+``}catch{}}return``}var kr=/[\\^$.*+?()[\]{}|]/g,Ar=/^\[object .+?Constructor\]$/,jr=Function.prototype,Mr=Object.prototype,Nr=jr.toString,Pr=Mr.hasOwnProperty,Fr=RegExp(`^`+Nr.call(Pr).replace(kr,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function Ir(e){return!vr(e)||Er(e)?!1:(Cr(e)?Fr:Ar).test(Or(e))}function Lr(e,t){return e?.[t]}function Rr(e,t){var n=Lr(e,t);return Ir(n)?n:void 0}var zr=Rr(ar,`Map`),Br=Rr(Object,`create`);function Vr(){this.__data__=Br?Br(null):{},this.size=0}function Hr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var Ur=`__lodash_hash_undefined__`,Wr=Object.prototype.hasOwnProperty;function Gr(e){var t=this.__data__;if(Br){var n=t[e];return n===Ur?void 0:n}return Wr.call(t,e)?t[e]:void 0}var Kr=Object.prototype.hasOwnProperty;function qr(e){var t=this.__data__;return Br?t[e]!==void 0:Kr.call(t,e)}var Jr=`__lodash_hash_undefined__`;function Yr(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=Br&&t===void 0?Jr:t,this}function Xr(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])}}Xr.prototype.clear=Vr,Xr.prototype.delete=Hr,Xr.prototype.get=Gr,Xr.prototype.has=qr,Xr.prototype.set=Yr;function Zr(){this.size=0,this.__data__={hash:new Xr,map:new(zr||Qn),string:new Xr}}function Qr(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function $r(e,t){var n=e.__data__;return Qr(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function ei(e){var t=$r(this,e).delete(e);return this.size-=+!!t,t}function ti(e){return $r(this,e).get(e)}function ni(e){return $r(this,e).has(e)}function ri(e,t){var n=$r(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function ii(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])}}ii.prototype.clear=Zr,ii.prototype.delete=ei,ii.prototype.get=ti,ii.prototype.has=ni,ii.prototype.set=ri;var ai=200;function oi(e,t){var n=this.__data__;if(n instanceof Qn){var r=n.__data__;if(!zr||r.length<ai-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ii(r)}return n.set(e,t),this.size=n.size,this}function si(e){var t=this.__data__=new Qn(e);this.size=t.size}si.prototype.clear=$n,si.prototype.delete=er,si.prototype.get=tr,si.prototype.has=nr,si.prototype.set=oi;function ci(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}var li=function(){try{var e=Rr(Object,`defineProperty`);return e({},``,{}),e}catch{}}();function ui(e,t,n){t==`__proto__`&&li?li(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}var di=Object.prototype.hasOwnProperty;function fi(e,t,n){var r=e[t];(!(di.call(e,t)&&Gn(r,n))||n===void 0&&!(t in e))&&ui(e,t,n)}function pi(e,t,n,r){var i=!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?ui(n,s,c):fi(n,s,c)}return n}function mi(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function hi(e){return typeof e==`object`&&!!e}var gi=`[object Arguments]`;function _i(e){return hi(e)&&_r(e)==gi}var vi=Object.prototype,yi=vi.hasOwnProperty,bi=vi.propertyIsEnumerable,xi=_i(function(){return arguments}())?_i:function(e){return hi(e)&&yi.call(e,`callee`)&&!bi.call(e,`callee`)},Si=Array.isArray;function Ci(){return!1}var wi=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Ti=wi&&typeof module==`object`&&module&&!module.nodeType&&module,Ei=Ti&&Ti.exports===wi?ar.Buffer:void 0,Di=(Ei?Ei.isBuffer:void 0)||Ci,Oi=9007199254740991,ki=/^(?:0|[1-9]\d*)$/;function Ai(e,t){var n=typeof e;return t??=Oi,!!t&&(n==`number`||n!=`symbol`&&ki.test(e))&&e>-1&&e%1==0&&e<t}var ji=9007199254740991;function Mi(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=ji}var Ni=`[object Arguments]`,Pi=`[object Array]`,Fi=`[object Boolean]`,Ii=`[object Date]`,Li=`[object Error]`,Ri=`[object Function]`,zi=`[object Map]`,Bi=`[object Number]`,Vi=`[object Object]`,Hi=`[object RegExp]`,Ui=`[object Set]`,Wi=`[object String]`,Gi=`[object WeakMap]`,Ki=`[object ArrayBuffer]`,qi=`[object DataView]`,Ji=`[object Float32Array]`,Yi=`[object Float64Array]`,Xi=`[object Int8Array]`,Zi=`[object Int16Array]`,Qi=`[object Int32Array]`,$i=`[object Uint8Array]`,ea=`[object Uint8ClampedArray]`,ta=`[object Uint16Array]`,na=`[object Uint32Array]`,ra={};ra[Ji]=ra[Yi]=ra[Xi]=ra[Zi]=ra[Qi]=ra[$i]=ra[ea]=ra[ta]=ra[na]=!0,ra[Ni]=ra[Pi]=ra[Ki]=ra[Fi]=ra[qi]=ra[Ii]=ra[Li]=ra[Ri]=ra[zi]=ra[Bi]=ra[Vi]=ra[Hi]=ra[Ui]=ra[Wi]=ra[Gi]=!1;function ia(e){return hi(e)&&Mi(e.length)&&!!ra[_r(e)]}function aa(e){return function(t){return e(t)}}var oa=typeof exports==`object`&&exports&&!exports.nodeType&&exports,sa=oa&&typeof module==`object`&&module&&!module.nodeType&&module,ca=sa&&sa.exports===oa&&rr.process,la=function(){try{return sa&&sa.require&&sa.require(`util`).types||ca&&ca.binding&&ca.binding(`util`)}catch{}}(),ua=la&&la.isTypedArray,da=ua?aa(ua):ia,fa=Object.prototype.hasOwnProperty;function pa(e,t){var n=Si(e),r=!n&&xi(e),i=!n&&!r&&Di(e),a=!n&&!r&&!i&&da(e),o=n||r||i||a,s=o?mi(e.length,String):[],c=s.length;for(var l in e)(t||fa.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||Ai(l,c)))&&s.push(l);return s}var ma=Object.prototype;function ha(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||ma)}function ga(e,t){return function(n){return e(t(n))}}var _a=ga(Object.keys,Object),va=Object.prototype.hasOwnProperty;function ya(e){if(!ha(e))return _a(e);var t=[];for(var n in Object(e))va.call(e,n)&&n!=`constructor`&&t.push(n);return t}function ba(e){return e!=null&&Mi(e.length)&&!Cr(e)}function xa(e){return ba(e)?pa(e):ya(e)}function Sa(e,t){return e&&pi(t,xa(t),e)}function Ca(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var wa=Object.prototype.hasOwnProperty;function Ta(e){if(!vr(e))return Ca(e);var t=ha(e),n=[];for(var r in e)r==`constructor`&&(t||!wa.call(e,r))||n.push(r);return n}function Ea(e){return ba(e)?pa(e,!0):Ta(e)}function Da(e,t){return e&&pi(t,Ea(t),e)}var Oa=typeof exports==`object`&&exports&&!exports.nodeType&&exports,ka=Oa&&typeof module==`object`&&module&&!module.nodeType&&module,Aa=ka&&ka.exports===Oa?ar.Buffer:void 0,ja=Aa?Aa.allocUnsafe:void 0;function Ma(e,t){if(t)return e.slice();var n=e.length,r=ja?ja(n):new e.constructor(n);return e.copy(r),r}function Na(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}function Pa(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 Fa(){return[]}var Ia=Object.prototype.propertyIsEnumerable,La=Object.getOwnPropertySymbols,Ra=La?function(e){return e==null?[]:(e=Object(e),Pa(La(e),function(t){return Ia.call(e,t)}))}:Fa;function za(e,t){return pi(e,Ra(e),t)}function Ba(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var Va=ga(Object.getPrototypeOf,Object),Ha=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)Ba(t,Ra(e)),e=Va(e);return t}:Fa;function Ua(e,t){return pi(e,Ha(e),t)}function N(e,t,n){var r=t(e);return Si(e)?r:Ba(r,n(e))}function Wa(e){return N(e,xa,Ra)}function Ga(e){return N(e,Ea,Ha)}var Ka=Rr(ar,`DataView`),qa=Rr(ar,`Promise`),Ja=Rr(ar,`Set`),P=Rr(ar,`WeakMap`),Ya=`[object Map]`,Xa=`[object Object]`,Za=`[object Promise]`,Qa=`[object Set]`,$a=`[object WeakMap]`,eo=`[object DataView]`,to=Or(Ka),no=Or(zr),ro=Or(qa),io=Or(Ja),ao=Or(P),oo=_r;(Ka&&oo(new Ka(new ArrayBuffer(1)))!=eo||zr&&oo(new zr)!=Ya||qa&&oo(qa.resolve())!=Za||Ja&&oo(new Ja)!=Qa||P&&oo(new P)!=$a)&&(oo=function(e){var t=_r(e),n=t==Xa?e.constructor:void 0,r=n?Or(n):``;if(r)switch(r){case to:return eo;case no:return Ya;case ro:return Za;case io:return Qa;case ao:return $a}return t});var so=oo,co=Object.prototype.hasOwnProperty;function lo(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&co.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}var uo=ar.Uint8Array;function fo(e){var t=new e.constructor(e.byteLength);return new uo(t).set(new uo(e)),t}function po(e,t){var n=t?fo(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}var mo=/\w*$/;function ho(e){var t=new e.constructor(e.source,mo.exec(e));return t.lastIndex=e.lastIndex,t}var go=or?or.prototype:void 0,_o=go?go.valueOf:void 0;function vo(e){return _o?Object(_o.call(e)):{}}function yo(e,t){var n=t?fo(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var bo=`[object Boolean]`,xo=`[object Date]`,So=`[object Map]`,Co=`[object Number]`,wo=`[object RegExp]`,To=`[object Set]`,Eo=`[object String]`,Do=`[object Symbol]`,Oo=`[object ArrayBuffer]`,ko=`[object DataView]`,Ao=`[object Float32Array]`,jo=`[object Float64Array]`,Mo=`[object Int8Array]`,No=`[object Int16Array]`,Po=`[object Int32Array]`,Fo=`[object Uint8Array]`,Io=`[object Uint8ClampedArray]`,Lo=`[object Uint16Array]`,Ro=`[object Uint32Array]`;function zo(e,t,n){var r=e.constructor;switch(t){case Oo:return fo(e);case bo:case xo:return new r(+e);case ko:return po(e,n);case Ao:case jo:case Mo:case No:case Po:case Fo:case Io:case Lo:case Ro:return yo(e,n);case So:return new r;case Co:case Eo:return new r(e);case wo:return ho(e);case To:return new r;case Do:return vo(e)}}var Bo=Object.create,Vo=function(){function e(){}return function(t){if(!vr(t))return{};if(Bo)return Bo(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function Ho(e){return typeof e.constructor==`function`&&!ha(e)?Vo(Va(e)):{}}var Uo=`[object Map]`;function Wo(e){return hi(e)&&so(e)==Uo}var Go=la&&la.isMap,Ko=Go?aa(Go):Wo,qo=`[object Set]`;function Jo(e){return hi(e)&&so(e)==qo}var Yo=la&&la.isSet,Xo=Yo?aa(Yo):Jo,Zo=1,Qo=2,$o=4,es=`[object Arguments]`,ts=`[object Array]`,ns=`[object Boolean]`,rs=`[object Date]`,is=`[object Error]`,as=`[object Function]`,os=`[object GeneratorFunction]`,ss=`[object Map]`,cs=`[object Number]`,ls=`[object Object]`,us=`[object RegExp]`,ds=`[object Set]`,fs=`[object String]`,ps=`[object Symbol]`,ms=`[object WeakMap]`,hs=`[object ArrayBuffer]`,gs=`[object DataView]`,_s=`[object Float32Array]`,vs=`[object Float64Array]`,ys=`[object Int8Array]`,bs=`[object Int16Array]`,xs=`[object Int32Array]`,Ss=`[object Uint8Array]`,Cs=`[object Uint8ClampedArray]`,ws=`[object Uint16Array]`,Ts=`[object Uint32Array]`,Es={};Es[es]=Es[ts]=Es[hs]=Es[gs]=Es[ns]=Es[rs]=Es[_s]=Es[vs]=Es[ys]=Es[bs]=Es[xs]=Es[ss]=Es[cs]=Es[ls]=Es[us]=Es[ds]=Es[fs]=Es[ps]=Es[Ss]=Es[Cs]=Es[ws]=Es[Ts]=!0,Es[is]=Es[as]=Es[ms]=!1;function Ds(e,t,n,r,i,a){var o,s=t&Zo,c=t&Qo,l=t&$o;if(n&&(o=i?n(e,r,i,a):n(e)),o!==void 0)return o;if(!vr(e))return e;var u=Si(e);if(u){if(o=lo(e),!s)return Na(e,o)}else{var d=so(e),f=d==as||d==os;if(Di(e))return Ma(e,s);if(d==ls||d==es||f&&!i){if(o=c||f?{}:Ho(e),!s)return c?Ua(e,Da(o,e)):za(e,Sa(o,e))}else{if(!Es[d])return i?e:{};o=zo(e,d,s)}}a||=new si;var p=a.get(e);if(p)return p;a.set(e,o),Xo(e)?e.forEach(function(r){o.add(Ds(r,t,n,r,e,a))}):Ko(e)&&e.forEach(function(r,i){o.set(i,Ds(r,t,n,i,e,a))});var m=u?void 0:(l?c?Ga:Wa:c?Ea:xa)(e);return ci(m||e,function(r,i){m&&(i=r,r=e[i]),fi(o,i,Ds(r,t,n,i,e,a))}),o}var Os=1,ks=4;function As(e){return Ds(e,Os|ks)}var js=function(){return ar.Date.now()},Ms=/\s/;function Ns(e){for(var t=e.length;t--&&Ms.test(e.charAt(t)););return t}var Ps=/^\s+/;function Fs(e){return e&&e.slice(0,Ns(e)+1).replace(Ps,``)}var Is=`[object Symbol]`;function Ls(e){return typeof e==`symbol`||hi(e)&&_r(e)==Is}var Rs=NaN,zs=/^[-+]0x[0-9a-f]+$/i,Bs=/^0b[01]+$/i,Vs=/^0o[0-7]+$/i,Hs=parseInt;function Us(e){if(typeof e==`number`)return e;if(Ls(e))return Rs;if(vr(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=vr(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=Fs(e);var n=Bs.test(e);return n||Vs.test(e)?Hs(e.slice(2),n?2:8):zs.test(e)?Rs:+e}var Ws=`Expected a function`,Gs=Math.max,Ks=Math.min;function qs(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0;if(typeof e!=`function`)throw TypeError(Ws);t=Us(t)||0,vr(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?Gs(Us(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?Ks(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=js();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 ee(){return s===void 0?o:v(js())}function b(){var e=js(),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 b.cancel=y,b.flush=ee,b}var Js=`__lodash_hash_undefined__`;function Ys(e){return this.__data__.set(e,Js),this}function Xs(e){return this.__data__.has(e)}function Zs(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new ii;++t<n;)this.add(e[t])}Zs.prototype.add=Zs.prototype.push=Ys,Zs.prototype.has=Xs;function Qs(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 $s(e,t){return e.has(t)}var ec=1,tc=2;function nc(e,t,n,r,i,a){var o=n&ec,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&tc?new Zs: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(!Qs(t,function(e,t){if(!$s(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 rc(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function ic(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var F=1,ac=2,oc=`[object Boolean]`,sc=`[object Date]`,cc=`[object Error]`,I=`[object Map]`,lc=`[object Number]`,uc=`[object RegExp]`,dc=`[object Set]`,fc=`[object String]`,pc=`[object Symbol]`,mc=`[object ArrayBuffer]`,hc=`[object DataView]`,gc=or?or.prototype:void 0,_c=gc?gc.valueOf:void 0;function vc(e,t,n,r,i,a,o){switch(n){case hc:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case mc:return!(e.byteLength!=t.byteLength||!a(new uo(e),new uo(t)));case oc:case sc:case lc:return Gn(+e,+t);case cc:return e.name==t.name&&e.message==t.message;case uc:case fc:return e==t+``;case I:var s=rc;case dc:var c=r&F;if(s||=ic,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=ac,o.set(e,t);var u=nc(s(e),s(t),r,i,a,o);return o.delete(e),u;case pc:if(_c)return _c.call(e)==_c.call(t)}return!1}var yc=1,bc=Object.prototype.hasOwnProperty;function xc(e,t,n,r,i,a){var o=n&yc,s=Wa(e),c=s.length;if(c!=Wa(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:bc.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||=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 Sc=1,Cc=`[object Arguments]`,wc=`[object Array]`,Tc=`[object Object]`,Ec=Object.prototype.hasOwnProperty;function Dc(e,t,n,r,i,a){var o=Si(e),s=Si(t),c=o?wc:so(e),l=s?wc:so(t);c=c==Cc?Tc:c,l=l==Cc?Tc:l;var u=c==Tc,d=l==Tc,f=c==l;if(f&&Di(e)){if(!Di(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new si,o||da(e)?nc(e,t,n,r,i,a):vc(e,t,c,n,r,i,a);if(!(n&Sc)){var p=u&&Ec.call(e,`__wrapped__`),m=d&&Ec.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||=new si,i(h,g,n,r,a)}}return f?(a||=new si,xc(e,t,n,r,i,a)):!1}function Oc(e,t,n,r,i){return e===t?!0:e==null||t==null||!hi(e)&&!hi(t)?e!==e&&t!==t:Dc(e,t,n,r,Oc,i)}function kc(e,t){return Oc(e,t)}function Ac(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 jc=1/0,Mc=or?or.prototype:void 0,Nc=Mc?Mc.toString:void 0;function Pc(e){if(typeof e==`string`)return e;if(Si(e))return Ac(e,Pc)+``;if(Ls(e))return Nc?Nc.call(e):``;var t=e+``;return t==`0`&&1/e==-jc?`-0`:t}function Fc(e){return e==null?``:Pc(e)}var Ic=/^\s+/,Lc=ar.parseInt;function Rc(e,t,n){return n||t==null?t=0:t&&=+t,Lc(Fc(e).replace(Ic,``),t||0)}function L(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 zc(e){return function(t){return e?.[t]}}var Bc=zc({À:`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`}),Vc=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Hc=RegExp(`[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]`,`g`);function Uc(e){return e=Fc(e),e&&e.replace(Vc,Bc).replace(Hc,``)}var Wc=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Gc(e){return e.match(Wc)||[]}var Kc=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function qc(e){return Kc.test(e)}var Jc=`\\ud800-\\udfff`,Yc=`\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff`,Xc=`\\u2700-\\u27bf`,Zc=`a-z\\xdf-\\xf6\\xf8-\\xff`,Qc=`\\xac\\xb1\\xd7\\xf7`,$c=`\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf`,el=`\\u2000-\\u206f`,tl=` \\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`,nl=`A-Z\\xc0-\\xd6\\xd8-\\xde`,rl=`\\ufe0e\\ufe0f`,il=Qc+$c+el+tl,al=`['’]`,ol=`[`+il+`]`,sl=`[`+Yc+`]`,cl=`\\d+`,ll=`[`+Xc+`]`,ul=`[`+Zc+`]`,dl=`[^`+Jc+il+cl+Xc+Zc+nl+`]`,fl=`(?:`+sl+`|\\ud83c[\\udffb-\\udfff])`,pl=`[^`+Jc+`]`,ml=`(?:\\ud83c[\\udde6-\\uddff]){2}`,hl=`[\\ud800-\\udbff][\\udc00-\\udfff]`,gl=`[`+nl+`]`,_l=`\\u200d`,vl=`(?:`+ul+`|`+dl+`)`,yl=`(?:`+gl+`|`+dl+`)`,bl=`(?:`+al+`(?:d|ll|m|re|s|t|ve))?`,xl=`(?:`+al+`(?:D|LL|M|RE|S|T|VE))?`,Sl=fl+`?`,Cl=`[`+rl+`]?`,wl=`(?:`+_l+`(?:`+[pl,ml,hl].join(`|`)+`)`+Cl+Sl+`)*`,Tl=`\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])`,El=`\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])`,Dl=Cl+Sl+wl,Ol=`(?:`+[ll,ml,hl].join(`|`)+`)`+Dl,kl=RegExp([gl+`?`+ul+`+`+bl+`(?=`+[ol,gl,`$`].join(`|`)+`)`,yl+`+`+xl+`(?=`+[ol,gl+vl,`$`].join(`|`)+`)`,gl+`?`+vl+`+`+bl,gl+`+`+xl,El,Tl,cl,Ol].join(`|`),`g`);function Al(e){return e.match(kl)||[]}function jl(e,t,n){return e=Fc(e),t=n?void 0:t,t===void 0?qc(e)?Al(e):Gc(e):e.match(t)||[]}var Ml=RegExp(`['’]`,`g`);function Nl(e){return function(t){return L(jl(Uc(t).replace(Ml,``)),e,``)}}var Pl=Nl(function(e,t,n){return e+(n?`_`:``)+t.toLowerCase()}),Fl=Nl(function(e,t,n){return e+(n?` `:``)+t.toUpperCase()}),Il=t(((e,t)=>{(function(n,r){typeof define==`function`&&define.amd?define([`./blockly_compressed.js`],r):typeof e==`object`?t.exports=r(y()):(n.dart=r(n.Blockly),n.Blockly.Dart=n.dart.dartGenerator)})(e,function(e){var t=e.__namespace__,n=function(e,t){return[`[]`,w.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,w.NONE)||`null`;return[`[`+n.join(`, `)+`]`,w.ATOMIC]},i=function(e,t){let n=t.valueToCode(e,`ITEM`,w.NONE)||`null`;return[`new List.filled(`+(t.valueToCode(e,`NUM`,w.NONE)||`0`)+`, `+n+`)`,w.UNARY_POSTFIX]},a=function(e,t){return[(t.valueToCode(e,`VALUE`,w.UNARY_POSTFIX)||`[]`)+`.length`,w.UNARY_POSTFIX]},o=function(e,t){return[(t.valueToCode(e,`VALUE`,w.UNARY_POSTFIX)||`[]`)+`.isEmpty`,w.UNARY_POSTFIX]},s=function(e,t){let n=e.getFieldValue(`END`)===`FIRST`?`indexOf`:`lastIndexOf`,r=t.valueToCode(e,`FIND`,w.NONE)||`''`;return t=(t.valueToCode(e,`VALUE`,w.UNARY_POSTFIX)||`[]`)+`.`+n+`(`+r+`)`,e.workspace.options.oneBasedIndex?[t+` + 1`,w.ADDITIVE]:[t,w.UNARY_POSTFIX]},c=function(e,n){function r(){let e=n.nameDB_.getDistinctName(`tmp_list`,t.NameType$$module$build$src$core$names.VARIABLE),r=`List `+e+` = `+o+`;
|
|
1013
|
-
`;return o=e,r}var i=e.getFieldValue(`MODE`)||`GET`;let a=e.getFieldValue(`WHERE`)||`FROM_START`,o=n.valueToCode(e,`VALUE`,a===`RANDOM`||a===`FROM_END`?w.NONE:w.UNARY_POSTFIX)||`[]`;if((a!==`RANDOM`||i!==`REMOVE`)&&a!==`FROM_END`||o.match(/^\w+$/))switch(a){case`FIRST`:if(i===`GET`)return[o+`.first`,w.UNARY_POSTFIX];if(i===`GET_REMOVE`)return[o+`.removeAt(0)`,w.UNARY_POSTFIX];if(i===`REMOVE`)return o+`.removeAt(0);
|
|
1014
|
-
`;break;case`LAST`:if(i===`GET`)return[o+`.last`,w.UNARY_POSTFIX];if(i===`GET_REMOVE`)return[o+`.removeLast()`,w.UNARY_POSTFIX];if(i===`REMOVE`)return o+`.removeLast();
|
|
1015
|
-
`;break;case`FROM_START`:if(e=n.getAdjusted(e,`AT`),i===`GET`)return[o+`[`+e+`]`,w.UNARY_POSTFIX];if(i===`GET_REMOVE`)return[o+`.removeAt(`+e+`)`,w.UNARY_POSTFIX];if(i===`REMOVE`)return o+`.removeAt(`+e+`);
|
|
1016
|
-
`;break;case`FROM_END`:if(e=n.getAdjusted(e,`AT`,1,!1,w.ADDITIVE),i===`GET`)return[o+`[`+o+`.length - `+e+`]`,w.UNARY_POSTFIX];if(i===`GET_REMOVE`||i===`REMOVE`){if(e=o+`.removeAt(`+o+`.length - `+e+`)`,i===`GET_REMOVE`)return[e,w.UNARY_POSTFIX];if(i===`REMOVE`)return e+`;
|
|
1017
|
-
`}break;case`RANDOM`:if(n.definitions_.import_dart_math=`import 'dart:math' as Math;`,i===`REMOVE`)return i=n.nameDB_.getDistinctName(`tmp_x`,t.NameType$$module$build$src$core$names.VARIABLE),`int `+i+` = new Math.Random().nextInt(`+o+`.length);
|
|
1018
|
-
`+(o+`.removeAt(`+i+`);
|
|
1019
|
-
`);if(i===`GET`)return[n.provideFunction_(`lists_get_random_item`,`
|
|
1020
|
-
dynamic ${n.FUNCTION_NAME_PLACEHOLDER_}(List my_list) {
|
|
1021
|
-
int x = new Math.Random().nextInt(my_list.length);
|
|
1022
|
-
return my_list[x];
|
|
1023
|
-
}
|
|
1024
|
-
`)+`(`+o+`)`,w.UNARY_POSTFIX];if(i===`GET_REMOVE`)return[n.provideFunction_(`lists_remove_random_item`,`
|
|
1025
|
-
dynamic ${n.FUNCTION_NAME_PLACEHOLDER_}(List my_list) {
|
|
1026
|
-
int x = new Math.Random().nextInt(my_list.length);
|
|
1027
|
-
return my_list.removeAt(x);
|
|
1028
|
-
}
|
|
1029
|
-
`)+`(`+o+`)`,w.UNARY_POSTFIX]}else{if(a===`RANDOM`)return n.definitions_.import_dart_math=`import 'dart:math' as Math;`,i=r(),e=n.nameDB_.getDistinctName(`tmp_x`,t.NameType$$module$build$src$core$names.VARIABLE),i+(`int `+e+` = new Math.Random().nextInt(`+o+`.length);
|
|
1030
|
-
`)+(o+`.removeAt(`+e+`);
|
|
1031
|
-
`);if(i===`REMOVE`)return i=n.getAdjusted(e,`AT`,1,!1,w.ADDITIVE),r()+(o+`.removeAt(`+o+`.length - `+i+`);
|
|
1032
|
-
`);if(i===`GET`)return i=n.getAdjusted(e,`AT`,1),[n.provideFunction_(`lists_get_from_end`,`
|
|
1033
|
-
dynamic ${n.FUNCTION_NAME_PLACEHOLDER_}(List my_list, num x) {
|
|
1034
|
-
x = my_list.length - x;
|
|
1035
|
-
return my_list[x];
|
|
1036
|
-
}
|
|
1037
|
-
`)+`(`+o+`, `+i+`)`,w.UNARY_POSTFIX];if(i===`GET_REMOVE`)return i=n.getAdjusted(e,`AT`,1),[n.provideFunction_(`lists_remove_from_end`,`
|
|
1038
|
-
dynamic ${n.FUNCTION_NAME_PLACEHOLDER_}(List my_list, num x) {
|
|
1039
|
-
x = my_list.length - x;
|
|
1040
|
-
return my_list.removeAt(x);
|
|
1041
|
-
}
|
|
1042
|
-
`)+`(`+o+`, `+i+`)`,w.UNARY_POSTFIX]}throw Error(`Unhandled combination (lists_getIndex).`)},l=function(e,n){function r(){if(o.match(/^\w+$/))return``;let e=n.nameDB_.getDistinctName(`tmp_list`,t.NameType$$module$build$src$core$names.VARIABLE),r=`List `+e+` = `+o+`;
|
|
1043
|
-
`;return o=e,r}let i=e.getFieldValue(`MODE`)||`GET`;var a=e.getFieldValue(`WHERE`)||`FROM_START`;let o=n.valueToCode(e,`LIST`,w.UNARY_POSTFIX)||`[]`,s=n.valueToCode(e,`TO`,w.ASSIGNMENT)||`null`;switch(a){case`FIRST`:if(i===`SET`)return o+`[0] = `+s+`;
|
|
1044
|
-
`;if(i===`INSERT`)return o+`.insert(0, `+s+`);
|
|
1045
|
-
`;break;case`LAST`:if(i===`SET`)return r()+(o+`[`+o+`.length - 1] = `+s+`;
|
|
1046
|
-
`);if(i===`INSERT`)return o+`.add(`+s+`);
|
|
1047
|
-
`;break;case`FROM_START`:if(e=n.getAdjusted(e,`AT`),i===`SET`)return o+`[`+e+`] = `+s+`;
|
|
1048
|
-
`;if(i===`INSERT`)return o+`.insert(`+e+`, `+s+`);
|
|
1049
|
-
`;break;case`FROM_END`:if(e=n.getAdjusted(e,`AT`,1,!1,w.ADDITIVE),a=r(),i===`SET`)return a+(o+`[`+o+`.length - `+e+`] = `+s+`;
|
|
1050
|
-
`);if(i===`INSERT`)return a+(o+`.insert(`+o+`.length - `+e+`, `+s+`);
|
|
1051
|
-
`);break;case`RANDOM`:if(n.definitions_.import_dart_math=`import 'dart:math' as Math;`,e=r(),a=n.nameDB_.getDistinctName(`tmp_x`,t.NameType$$module$build$src$core$names.VARIABLE),e+=`int `+a+` = new Math.Random().nextInt(`+o+`.length);
|
|
1052
|
-
`,i===`SET`)return e+(o+`[`+a+`] = `+s+`;
|
|
1053
|
-
`);if(i===`INSERT`)return e+(o+`.insert(`+a+`, `+s+`);
|
|
1054
|
-
`)}throw Error(`Unhandled combination (lists_setIndex).`)},u=function(e,t){let n=t.valueToCode(e,`LIST`,w.UNARY_POSTFIX)||`[]`;var r=e.getFieldValue(`WHERE1`);let i=e.getFieldValue(`WHERE2`);if(n.match(/^\w+$/)||r!==`FROM_END`&&i===`FROM_START`){switch(r){case`FROM_START`:r=t.getAdjusted(e,`AT1`);break;case`FROM_END`:r=t.getAdjusted(e,`AT1`,1,!1,w.ADDITIVE),r=n+`.length - `+r;break;case`FIRST`:r=`0`;break;default:throw Error(`Unhandled option (lists_getSublist).`)}switch(i){case`FROM_START`:var a=t.getAdjusted(e,`AT2`,1);break;case`FROM_END`:a=t.getAdjusted(e,`AT2`,0,!1,w.ADDITIVE),a=n+`.length - `+a;break;case`LAST`:break;default:throw Error(`Unhandled option (lists_getSublist).`)}t=i===`LAST`?n+`.sublist(`+r+`)`:n+`.sublist(`+r+`, `+a+`)`}else a=t.getAdjusted(e,`AT1`),e=t.getAdjusted(e,`AT2`),t=t.provideFunction_(`lists_get_sublist`,`
|
|
1055
|
-
List ${t.FUNCTION_NAME_PLACEHOLDER_}(List list, String where1, num at1, String where2, num at2) {
|
|
1056
|
-
int getAt(String where, num at) {
|
|
1057
|
-
if (where == 'FROM_END') {
|
|
1058
|
-
at = list.length - 1 - at;
|
|
1059
|
-
} else if (where == 'FIRST') {
|
|
1060
|
-
at = 0;
|
|
1061
|
-
} else if (where == 'LAST') {
|
|
1062
|
-
at = list.length - 1;
|
|
1063
|
-
} else if (where != 'FROM_START') {
|
|
1064
|
-
throw 'Unhandled option (lists_getSublist).';
|
|
1065
|
-
}
|
|
1066
|
-
return at;
|
|
1067
|
-
}
|
|
1068
|
-
at1 = getAt(where1, at1);
|
|
1069
|
-
at2 = getAt(where2, at2) + 1;
|
|
1070
|
-
return list.sublist(at1, at2);
|
|
1071
|
-
}
|
|
1072
|
-
`)+`(`+n+`, '`+r+`', `+a+`, '`+i+`', `+e+`)`;return[t,w.UNARY_POSTFIX]},d=function(e,t){let n=t.valueToCode(e,`LIST`,w.NONE)||`[]`,r=e.getFieldValue(`DIRECTION`)===`1`?1:-1;return e=e.getFieldValue(`TYPE`),[t.provideFunction_(`lists_sort`,`
|
|
1073
|
-
List ${t.FUNCTION_NAME_PLACEHOLDER_}(List list, String type, int direction) {
|
|
1074
|
-
var compareFuncs = {
|
|
1075
|
-
'NUMERIC': (a, b) => (direction * a.compareTo(b)).toInt(),
|
|
1076
|
-
'TEXT': (a, b) => direction * a.toString().compareTo(b.toString()),
|
|
1077
|
-
'IGNORE_CASE':
|
|
1078
|
-
(a, b) => direction *
|
|
1079
|
-
a.toString().toLowerCase().compareTo(b.toString().toLowerCase())
|
|
1080
|
-
};
|
|
1081
|
-
list = new List.from(list);
|
|
1082
|
-
var compare = compareFuncs[type];
|
|
1083
|
-
list.sort(compare);
|
|
1084
|
-
return list;
|
|
1085
|
-
}
|
|
1086
|
-
`)+`(`+n+`, "`+e+`", `+r+`)`,w.UNARY_POSTFIX]},f=function(e,t){let n=t.valueToCode(e,`INPUT`,w.UNARY_POSTFIX);if(t=t.valueToCode(e,`DELIM`,w.NONE)||`''`,e=e.getFieldValue(`MODE`),e===`SPLIT`)n||=`''`,e=`split`;else if(e===`JOIN`)n||=`[]`,e=`join`;else throw Error(`Unknown mode: `+e);return[n+`.`+e+`(`+t+`)`,w.UNARY_POSTFIX]},p=function(e,t){return[`new List.from(`+(t.valueToCode(e,`LIST`,w.NONE)||`[]`)+`.reversed)`,w.UNARY_POSTFIX]},m=function(e,t){let n=0,r=``,i,a;t.STATEMENT_PREFIX&&(r+=t.injectId(t.STATEMENT_PREFIX,e));do a=t.valueToCode(e,`IF`+n,w.NONE)||`false`,i=t.statementToCode(e,`DO`+n),t.STATEMENT_SUFFIX&&(i=t.prefixLines(t.injectId(t.STATEMENT_SUFFIX,e),t.INDENT)+i),r+=(n>0?`else `:``)+`if (`+a+`) {
|
|
1087
|
-
`+i+`}`,n++;while(e.getInput(`IF`+n));return(e.getInput(`ELSE`)||t.STATEMENT_SUFFIX)&&(i=e.getInput(`ELSE`)?t.statementToCode(e,`ELSE`):``,t.STATEMENT_SUFFIX&&(i=t.prefixLines(t.injectId(t.STATEMENT_SUFFIX,e),t.INDENT)+i),r+=` else {
|
|
1088
|
-
`+i+`}`),r+`
|
|
1089
|
-
`},h=function(e,t){let n={EQ:`==`,NEQ:`!=`,LT:`<`,LTE:`<=`,GT:`>`,GTE:`>=`}[e.getFieldValue(`OP`)],r=n===`==`||n===`!=`?w.EQUALITY:w.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===`&&`?w.LOGICAL_AND:w.LOGICAL_OR,i=t.valueToCode(e,`A`,r);return e=t.valueToCode(e,`B`,r),i||e?(t=n===`&&`?`true`:`false`,i||=t,e||=t):e=i=`false`,[i+` `+n+` `+e,r]},_=function(e,t){let n=w.UNARY_PREFIX;return[`!`+(t.valueToCode(e,`BOOL`,n)||`true`),n]},v=function(e,t){return[e.getFieldValue(`BOOL`)===`TRUE`?`true`:`false`,w.ATOMIC]},y=function(e,t){return[`null`,w.ATOMIC]},ee=function(e,t){let n=t.valueToCode(e,`IF`,w.CONDITIONAL)||`false`,r=t.valueToCode(e,`THEN`,w.CONDITIONAL)||`null`;return e=t.valueToCode(e,`ELSE`,w.CONDITIONAL)||`null`,[n+` ? `+r+` : `+e,w.CONDITIONAL]},b=function(e,n){let r;r=e.getField(`TIMES`)?String(Number(e.getFieldValue(`TIMES`))):n.valueToCode(e,`TIMES`,w.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+`;
|
|
1090
|
-
`),e+(`for (int `+a+` = 0; `+a+` < `+o+`; `+a+`++) {
|
|
1091
|
-
`+i+`}
|
|
1092
|
-
`)},te=function(e,t){let n=e.getFieldValue(`MODE`)===`UNTIL`,r=t.valueToCode(e,`BOOL`,n?w.UNARY_PREFIX:w.NONE)||`false`,i=t.statementToCode(e,`DO`);return i=t.addLoopTrap(i,e),n&&(r=`!`+r),`while (`+r+`) {
|
|
1093
|
-
`+i+`}
|
|
1094
|
-
`},ne=function(e,n){var r=n.getVariableName(e.getFieldValue(`VAR`)),i=n.valueToCode(e,`FROM`,w.ASSIGNMENT)||`0`,a=n.valueToCode(e,`TO`,w.ASSIGNMENT)||`0`;let o=n.valueToCode(e,`BY`,w.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+=`) {
|
|
1095
|
-
`+s+`}
|
|
1096
|
-
`;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+`;
|
|
1097
|
-
`),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+`;
|
|
1098
|
-
`),a=n.nameDB_.getDistinctName(r+`_inc`,t.NameType$$module$build$src$core$names.VARIABLE),e+=`num `+a+` = `,e=t.isNumber$$module$build$src$core$utils$string(o)?e+(Math.abs(Number(o))+`;
|
|
1099
|
-
`):e+(`(`+o+`).abs();
|
|
1100
|
-
`),e+=`if (`+c+` > `+i+`) {
|
|
1101
|
-
`,e+=n.INDENT+a+` = -`+a+`;
|
|
1102
|
-
`,e=e+`}
|
|
1103
|
-
for (`+(r+` = `+c+`; `+a+` >= 0 ? `+r+` <= `+i+` : `+r+` >= `+i+`; `+r+` += `+a+`) {
|
|
1104
|
-
`+s+`}
|
|
1105
|
-
`)}return e},re=function(e,t){let n=t.getVariableName(e.getFieldValue(`VAR`)),r=t.valueToCode(e,`LIST`,w.ASSIGNMENT)||`[]`,i=t.statementToCode(e,`DO`);return i=t.addLoopTrap(i,e),`for (var `+n+` in `+r+`) {
|
|
1106
|
-
`+i+`}
|
|
1107
|
-
`},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;
|
|
1108
|
-
`;case`CONTINUE`:return n+`continue;
|
|
1109
|
-
`}throw Error(`Unknown flow statement.`)},ae=function(e,t){return e=Number(e.getFieldValue(`NUM`)),e===1/0?[`double.infinity`,w.UNARY_POSTFIX]:e===-1/0?[`-double.infinity`,w.UNARY_PREFIX]:[String(e),e<0?w.UNARY_PREFIX:w.ATOMIC]},oe=function(e,t){var n={ADD:[` + `,w.ADDITIVE],MINUS:[` - `,w.ADDITIVE],MULTIPLY:[` * `,w.MULTIPLICATIVE],DIVIDE:[` / `,w.MULTIPLICATIVE],POWER:[null,w.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]:(t.definitions_.import_dart_math=`import 'dart:math' as Math;`,[`Math.pow(`+i+`, `+e+`)`,w.UNARY_POSTFIX])},se=function(e,t){let n=e.getFieldValue(`OP`),r;if(n===`NEG`)return e=t.valueToCode(e,`NUM`,w.UNARY_PREFIX)||`0`,e[0]===`-`&&(e=` `+e),[`-`+e,w.UNARY_PREFIX];switch(t.definitions_.import_dart_math=`import 'dart:math' as Math;`,e=n===`ABS`||n.substring(0,5)===`ROUND`?t.valueToCode(e,`NUM`,w.UNARY_POSTFIX)||`0`:n===`SIN`||n===`COS`||n===`TAN`?t.valueToCode(e,`NUM`,w.MULTIPLICATIVE)||`0`:t.valueToCode(e,`NUM`,w.NONE)||`0`,n){case`ABS`:r=e+`.abs()`;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=e+`.round()`;break;case`ROUNDUP`:r=e+`.ceil()`;break;case`ROUNDDOWN`:r=e+`.floor()`;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,w.UNARY_POSTFIX];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,w.MULTIPLICATIVE]},ce=function(e,t){let n={PI:[`Math.pi`,w.UNARY_POSTFIX],E:[`Math.e`,w.UNARY_POSTFIX],GOLDEN_RATIO:[`(1 + Math.sqrt(5)) / 2`,w.MULTIPLICATIVE],SQRT2:[`Math.sqrt2`,w.UNARY_POSTFIX],SQRT1_2:[`Math.sqrt1_2`,w.UNARY_POSTFIX],INFINITY:[`double.infinity`,w.ATOMIC]};return e=e.getFieldValue(`CONSTANT`),e!==`INFINITY`&&(t.definitions_.import_dart_math=`import 'dart:math' as Math;`),n[e]},x=function(e,t){var n={EVEN:[` % 2 == 0`,w.MULTIPLICATIVE,w.EQUALITY],ODD:[` % 2 == 1`,w.MULTIPLICATIVE,w.EQUALITY],WHOLE:[` % 1 == 0`,w.MULTIPLICATIVE,w.EQUALITY],POSITIVE:[` > 0`,w.RELATIONAL,w.RELATIONAL],NEGATIVE:[` < 0`,w.RELATIONAL,w.RELATIONAL],DIVISIBLE_BY:[null,w.MULTIPLICATIVE,w.EQUALITY],PRIME:[null,w.NONE,w.UNARY_POSTFIX]};let r=e.getFieldValue(`PROPERTY`),[i,a,o]=n[r];if(n=t.valueToCode(e,`NUMBER_TO_CHECK`,a)||`0`,r===`PRIME`)t.definitions_.import_dart_math=`import 'dart:math' as Math;`,e=t.provideFunction_(`math_isPrime`,`
|
|
1110
|
-
bool ${t.FUNCTION_NAME_PLACEHOLDER_}(n) {
|
|
1111
|
-
// https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
|
1112
|
-
if (n == 2 || n == 3) {
|
|
1113
|
-
return true;
|
|
1114
|
-
}
|
|
1115
|
-
// False if n is null, negative, is 1, or not whole.
|
|
1116
|
-
// And false if n is divisible by 2 or 3.
|
|
1117
|
-
if (n == null || n <= 1 || n % 1 != 0 || n % 2 == 0 || n % 3 == 0) {
|
|
1118
|
-
return false;
|
|
1119
|
-
}
|
|
1120
|
-
// Check all the numbers of form 6k +/- 1, up to sqrt(n).
|
|
1121
|
-
for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {
|
|
1122
|
-
if (n % (x - 1) == 0 || n % (x + 1) == 0) {
|
|
1123
|
-
return false;
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
return true;
|
|
1127
|
-
}
|
|
1128
|
-
`)+`(`+n+`)`;else if(r===`DIVISIBLE_BY`){if(e=t.valueToCode(e,`DIVISOR`,w.MULTIPLICATIVE)||`0`,e===`0`)return[`false`,w.ATOMIC];e=n+` % `+e+` == 0`}else e=n+i;return[e,o]},le=function(e,t){let n=t.valueToCode(e,`DELTA`,w.ADDITIVE)||`0`;return e=t.getVariableName(e.getFieldValue(`VAR`)),e+` = (`+e+` is num ? `+e+` : 0) + `+n+`;
|
|
1129
|
-
`},ue=function(e,t){let n=e.getFieldValue(`OP`);switch(e=t.valueToCode(e,`LIST`,w.NONE)||`[]`,n){case`SUM`:t=t.provideFunction_(`math_sum`,`
|
|
1130
|
-
num ${t.FUNCTION_NAME_PLACEHOLDER_}(List<num> myList) {
|
|
1131
|
-
num sumVal = 0;
|
|
1132
|
-
myList.forEach((num entry) {sumVal += entry;});
|
|
1133
|
-
return sumVal;
|
|
1134
|
-
}
|
|
1135
|
-
`)+`(`+e+`)`;break;case`MIN`:t.definitions_.import_dart_math=`import 'dart:math' as Math;`,t=t.provideFunction_(`math_min`,`
|
|
1136
|
-
num ${t.FUNCTION_NAME_PLACEHOLDER_}(List<num> myList) {
|
|
1137
|
-
if (myList.isEmpty) return null;
|
|
1138
|
-
num minVal = myList[0];
|
|
1139
|
-
myList.forEach((num entry) {minVal = Math.min(minVal, entry);});
|
|
1140
|
-
return minVal;
|
|
1141
|
-
}
|
|
1142
|
-
`)+`(`+e+`)`;break;case`MAX`:t.definitions_.import_dart_math=`import 'dart:math' as Math;`,t=t.provideFunction_(`math_max`,`
|
|
1143
|
-
num ${t.FUNCTION_NAME_PLACEHOLDER_}(List<num> myList) {
|
|
1144
|
-
if (myList.isEmpty) return null;
|
|
1145
|
-
num maxVal = myList[0];
|
|
1146
|
-
myList.forEach((num entry) {maxVal = Math.max(maxVal, entry);});
|
|
1147
|
-
return maxVal;
|
|
1148
|
-
}
|
|
1149
|
-
`)+`(`+e+`)`;break;case`AVERAGE`:t=t.provideFunction_(`math_mean`,`
|
|
1150
|
-
num ${t.FUNCTION_NAME_PLACEHOLDER_}(List myList) {
|
|
1151
|
-
// First filter list for numbers only.
|
|
1152
|
-
List localList = new List.from(myList);
|
|
1153
|
-
localList.removeWhere((a) => a is! num);
|
|
1154
|
-
if (localList.isEmpty) return null;
|
|
1155
|
-
num sumVal = 0;
|
|
1156
|
-
localList.forEach((var entry) {sumVal += entry;});
|
|
1157
|
-
return sumVal / localList.length;
|
|
1158
|
-
}
|
|
1159
|
-
`)+`(`+e+`)`;break;case`MEDIAN`:t=t.provideFunction_(`math_median`,`
|
|
1160
|
-
num ${t.FUNCTION_NAME_PLACEHOLDER_}(List myList) {
|
|
1161
|
-
// First filter list for numbers only, then sort, then return middle value
|
|
1162
|
-
// or the average of two middle values if list has an even number of elements.
|
|
1163
|
-
List localList = new List.from(myList);
|
|
1164
|
-
localList.removeWhere((a) => a is! num);
|
|
1165
|
-
if (localList.isEmpty) return null;
|
|
1166
|
-
localList.sort((a, b) => (a - b));
|
|
1167
|
-
int index = localList.length ~/ 2;
|
|
1168
|
-
if (localList.length % 2 == 1) {
|
|
1169
|
-
return localList[index];
|
|
1170
|
-
} else {
|
|
1171
|
-
return (localList[index - 1] + localList[index]) / 2;
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
`)+`(`+e+`)`;break;case`MODE`:t.definitions_.import_dart_math=`import 'dart:math' as Math;`,t=t.provideFunction_(`math_modes`,`
|
|
1175
|
-
List ${t.FUNCTION_NAME_PLACEHOLDER_}(List values) {
|
|
1176
|
-
List modes = [];
|
|
1177
|
-
List counts = [];
|
|
1178
|
-
int maxCount = 0;
|
|
1179
|
-
for (int i = 0; i < values.length; i++) {
|
|
1180
|
-
var value = values[i];
|
|
1181
|
-
bool found = false;
|
|
1182
|
-
int thisCount;
|
|
1183
|
-
for (int j = 0; j < counts.length; j++) {
|
|
1184
|
-
if (counts[j][0] == value) {
|
|
1185
|
-
thisCount = ++counts[j][1];
|
|
1186
|
-
found = true;
|
|
1187
|
-
break;
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
if (!found) {
|
|
1191
|
-
counts.add([value, 1]);
|
|
1192
|
-
thisCount = 1;
|
|
1193
|
-
}
|
|
1194
|
-
maxCount = Math.max(thisCount, maxCount);
|
|
1195
|
-
}
|
|
1196
|
-
for (int j = 0; j < counts.length; j++) {
|
|
1197
|
-
if (counts[j][1] == maxCount) {
|
|
1198
|
-
modes.add(counts[j][0]);
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
return modes;
|
|
1202
|
-
}
|
|
1203
|
-
`)+`(`+e+`)`;break;case`STD_DEV`:t.definitions_.import_dart_math=`import 'dart:math' as Math;`,t=t.provideFunction_(`math_standard_deviation`,`
|
|
1204
|
-
num ${t.FUNCTION_NAME_PLACEHOLDER_}(List myList) {
|
|
1205
|
-
// First filter list for numbers only.
|
|
1206
|
-
List numbers = new List.from(myList);
|
|
1207
|
-
numbers.removeWhere((a) => a is! num);
|
|
1208
|
-
if (numbers.isEmpty) return null;
|
|
1209
|
-
num n = numbers.length;
|
|
1210
|
-
num sum = 0;
|
|
1211
|
-
numbers.forEach((x) => sum += x);
|
|
1212
|
-
num mean = sum / n;
|
|
1213
|
-
num sumSquare = 0;
|
|
1214
|
-
numbers.forEach((x) => sumSquare += Math.pow(x - mean, 2));
|
|
1215
|
-
return Math.sqrt(sumSquare / n);
|
|
1216
|
-
}
|
|
1217
|
-
`)+`(`+e+`)`;break;case`RANDOM`:t.definitions_.import_dart_math=`import 'dart:math' as Math;`,t=t.provideFunction_(`math_random_item`,`
|
|
1218
|
-
dynamic ${t.FUNCTION_NAME_PLACEHOLDER_}(List myList) {
|
|
1219
|
-
int x = new Math.Random().nextInt(myList.length);
|
|
1220
|
-
return myList[x];
|
|
1221
|
-
}
|
|
1222
|
-
`)+`(`+e+`)`;break;default:throw Error(`Unknown operator: `+n)}return[t,w.UNARY_POSTFIX]},de=function(e,t){let n=t.valueToCode(e,`DIVIDEND`,w.MULTIPLICATIVE)||`0`;return e=t.valueToCode(e,`DIVISOR`,w.MULTIPLICATIVE)||`0`,[n+` % `+e,w.MULTIPLICATIVE]},S=function(e,t){t.definitions_.import_dart_math=`import 'dart:math' as Math;`;let n=t.valueToCode(e,`VALUE`,w.NONE)||`0`,r=t.valueToCode(e,`LOW`,w.NONE)||`0`;return e=t.valueToCode(e,`HIGH`,w.NONE)||`double.infinity`,[`Math.min(Math.max(`+n+`, `+r+`), `+e+`)`,w.UNARY_POSTFIX]},fe=function(e,t){t.definitions_.import_dart_math=`import 'dart:math' as Math;`;let n=t.valueToCode(e,`FROM`,w.NONE)||`0`;return e=t.valueToCode(e,`TO`,w.NONE)||`0`,[t.provideFunction_(`math_random_int`,`
|
|
1223
|
-
int ${t.FUNCTION_NAME_PLACEHOLDER_}(num a, num b) {
|
|
1224
|
-
if (a > b) {
|
|
1225
|
-
// Swap a and b to ensure a is smaller.
|
|
1226
|
-
num c = a;
|
|
1227
|
-
a = b;
|
|
1228
|
-
b = c;
|
|
1229
|
-
}
|
|
1230
|
-
return new Math.Random().nextInt(b - a + 1) + a;
|
|
1231
|
-
}
|
|
1232
|
-
`)+`(`+n+`, `+e+`)`,w.UNARY_POSTFIX]},pe=function(e,t){return t.definitions_.import_dart_math=`import 'dart:math' as Math;`,[`new Math.Random().nextDouble()`,w.UNARY_POSTFIX]},me=function(e,t){t.definitions_.import_dart_math=`import 'dart:math' as Math;`;let n=t.valueToCode(e,`X`,w.NONE)||`0`;return[`Math.atan2(`+(t.valueToCode(e,`Y`,w.NONE)||`0`)+`, `+n+`) / Math.pi * 180`,w.MULTIPLICATIVE]},he=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&&=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`,w.NONE)||``);let s=``;a&&o&&(s=r),o&&=t.INDENT+`return `+o+`;
|
|
1233
|
-
`;let c=o?`dynamic`:`void`,l=[],u=e.getVars();for(let e=0;e<u.length;e++)l[e]=t.getVariableName(u[e]);return r=c+` `+n+`(`+l.join(`, `)+`) {
|
|
1234
|
-
`+r+i+a+s+o+`}`,r=t.scrub_(e,r),t.definitions_[`%`+n]=r,null},ge=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,w.NONE)||`null`;return[n+`(`+r.join(`, `)+`)`,w.UNARY_POSTFIX]},_e=function(e,t){return t.forBlock.procedures_callreturn(e,t)[0]+`;
|
|
1235
|
-
`},ve=function(e,t){let n=`if (`+(t.valueToCode(e,`CONDITION`,w.NONE)||`false`)+`) {
|
|
1236
|
-
`;return t.STATEMENT_SUFFIX&&(n+=t.prefixLines(t.injectId(t.STATEMENT_SUFFIX,e),t.INDENT)),e.hasReturnValue_?(e=t.valueToCode(e,`VALUE`,w.NONE)||`null`,n+=t.INDENT+`return `+e+`;
|
|
1237
|
-
`):n+=t.INDENT+`return;
|
|
1238
|
-
`,n+`}
|
|
1239
|
-
`},ye=function(e,t){return[t.quote_(e.getFieldValue(`TEXT`)),w.ATOMIC]},be=function(e,t){switch(e.itemCount_){case 0:return[`''`,w.ATOMIC];case 1:return[(t.valueToCode(e,`ADD0`,w.UNARY_POSTFIX)||`''`)+`.toString()`,w.UNARY_POSTFIX];default:let n=Array(e.itemCount_);for(let r=0;r<e.itemCount_;r++)n[r]=t.valueToCode(e,`ADD`+r,w.NONE)||`''`;return[`[`+n.join(`,`)+`].join()`,w.UNARY_POSTFIX]}},xe=function(e,t){let n=t.getVariableName(e.getFieldValue(`VAR`));return e=t.valueToCode(e,`TEXT`,w.NONE)||`''`,n+` = [`+n+`, `+e+`].join();
|
|
1240
|
-
`},Se=function(e,t){return[(t.valueToCode(e,`VALUE`,w.UNARY_POSTFIX)||`''`)+`.length`,w.UNARY_POSTFIX]},Ce=function(e,t){return[(t.valueToCode(e,`VALUE`,w.UNARY_POSTFIX)||`''`)+`.isEmpty`,w.UNARY_POSTFIX]},we=function(e,t){let n=e.getFieldValue(`END`)===`FIRST`?`indexOf`:`lastIndexOf`,r=t.valueToCode(e,`FIND`,w.NONE)||`''`;return t=(t.valueToCode(e,`VALUE`,w.UNARY_POSTFIX)||`''`)+`.`+n+`(`+r+`)`,e.workspace.options.oneBasedIndex?[t+` + 1`,w.ADDITIVE]:[t,w.UNARY_POSTFIX]},Te=function(e,t){let n=e.getFieldValue(`WHERE`)||`FROM_START`,r=t.valueToCode(e,`VALUE`,n===`FIRST`||n===`FROM_START`?w.UNARY_POSTFIX:w.NONE)||`''`;switch(n){case`FIRST`:return[r+`[0]`,w.UNARY_POSTFIX];case`FROM_START`:return e=t.getAdjusted(e,`AT`),[r+`[`+e+`]`,w.UNARY_POSTFIX];case`LAST`:case`FROM_END`:return e=n===`LAST`?1:t.getAdjusted(e,`AT`,1),[`${t.provideFunction_(`text_get_from_end`,`
|
|
1241
|
-
String ${t.FUNCTION_NAME_PLACEHOLDER_}(String text, num x) {
|
|
1242
|
-
return text[text.length - x];
|
|
1243
|
-
}
|
|
1244
|
-
`)}(${r}, ${e})`,w.UNARY_POSTFIX];case`RANDOM`:return t.definitions_.import_dart_math=`import 'dart:math' as Math;`,[t.provideFunction_(`text_random_letter`,`
|
|
1245
|
-
String ${t.FUNCTION_NAME_PLACEHOLDER_}(String text) {
|
|
1246
|
-
int x = new Math.Random().nextInt(text.length);
|
|
1247
|
-
return text[x];
|
|
1248
|
-
}
|
|
1249
|
-
`)+`(`+r+`)`,w.UNARY_POSTFIX]}throw Error(`Unhandled option (text_charAt).`)},Ee=function(e,t){var n=e.getFieldValue(`WHERE1`);let r=e.getFieldValue(`WHERE2`),i=n!==`FROM_END`&&r===`FROM_START`,a=t.valueToCode(e,`STRING`,i?w.UNARY_POSTFIX:w.NONE)||`''`;if(n===`FIRST`&&r===`LAST`)return[a,w.NONE];if(a.match(/^'?\w+'?$/)||i){switch(n){case`FROM_START`:n=t.getAdjusted(e,`AT1`);break;case`FROM_END`:n=t.getAdjusted(e,`AT1`,1,!1,w.ADDITIVE),n=a+`.length - `+n;break;case`FIRST`:n=`0`;break;default:throw Error(`Unhandled option (text_getSubstring).`)}switch(r){case`FROM_START`:var o=t.getAdjusted(e,`AT2`,1);break;case`FROM_END`:o=t.getAdjusted(e,`AT2`,0,!1,w.ADDITIVE),o=a+`.length - `+o;break;case`LAST`:break;default:throw Error(`Unhandled option (text_getSubstring).`)}t=r===`LAST`?a+`.substring(`+n+`)`:a+`.substring(`+n+`, `+o+`)`}else o=t.getAdjusted(e,`AT1`),e=t.getAdjusted(e,`AT2`),t=t.provideFunction_(`text_get_substring`,`
|
|
1250
|
-
String ${t.FUNCTION_NAME_PLACEHOLDER_}(String text, String where1, num at1, String where2, num at2) {
|
|
1251
|
-
int getAt(String where, num at) {
|
|
1252
|
-
if (where == 'FROM_END') {
|
|
1253
|
-
at = text.length - 1 - at;
|
|
1254
|
-
} else if (where == 'FIRST') {
|
|
1255
|
-
at = 0;
|
|
1256
|
-
} else if (where == 'LAST') {
|
|
1257
|
-
at = text.length - 1;
|
|
1258
|
-
} else if (where != 'FROM_START') {
|
|
1259
|
-
throw 'Unhandled option (text_getSubstring).';
|
|
1260
|
-
}
|
|
1261
|
-
return at;
|
|
1262
|
-
}
|
|
1263
|
-
at1 = getAt(where1, at1);
|
|
1264
|
-
at2 = getAt(where2, at2) + 1;
|
|
1265
|
-
return text.substring(at1, at2);
|
|
1266
|
-
}
|
|
1267
|
-
`)+`(`+a+`, '`+n+`', `+o+`, '`+r+`', `+e+`)`;return[t,w.UNARY_POSTFIX]},C=function(e,t){let n={UPPERCASE:`.toUpperCase()`,LOWERCASE:`.toLowerCase()`,TITLECASE:null}[e.getFieldValue(`CASE`)];return e=t.valueToCode(e,`TEXT`,n?w.UNARY_POSTFIX:w.NONE)||`''`,[n?e+n:t.provideFunction_(`text_toTitleCase`,`
|
|
1268
|
-
String ${t.FUNCTION_NAME_PLACEHOLDER_}(String str) {
|
|
1269
|
-
RegExp exp = new RegExp(r'\\b');
|
|
1270
|
-
List<String> list = str.split(exp);
|
|
1271
|
-
final title = new StringBuffer();
|
|
1272
|
-
for (String part in list) {
|
|
1273
|
-
if (part.length > 0) {
|
|
1274
|
-
title.write(part[0].toUpperCase());
|
|
1275
|
-
if (part.length > 0) {
|
|
1276
|
-
title.write(part.substring(1).toLowerCase());
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
return title.toString();
|
|
1281
|
-
}
|
|
1282
|
-
`)+`(`+e+`)`,w.UNARY_POSTFIX]},De=function(e,t){let n={LEFT:`.replaceFirst(new RegExp(r'^\\s+'), '')`,RIGHT:`.replaceFirst(new RegExp(r'\\s+$'), '')`,BOTH:`.trim()`}[e.getFieldValue(`MODE`)];return[(t.valueToCode(e,`TEXT`,w.UNARY_POSTFIX)||`''`)+n,w.UNARY_POSTFIX]},Oe=function(e,t){return`print(`+(t.valueToCode(e,`TEXT`,w.NONE)||`''`)+`);
|
|
1283
|
-
`},ke=function(e,t){t.definitions_.import_dart_html=`import 'dart:html' as Html;`;let n=`Html.window.prompt(`+(e.getField(`TEXT`)?t.quote_(e.getFieldValue(`TEXT`)):t.valueToCode(e,`TEXT`,w.NONE)||`''`)+`, '')`;return e.getFieldValue(`TYPE`)===`NUMBER`&&(t.definitions_.import_dart_math=`import 'dart:math' as Math;`,n=`Math.parseDouble(`+n+`)`),[n,w.UNARY_POSTFIX]},Ae=function(e,t){let n=t.valueToCode(e,`TEXT`,w.NONE)||`''`;return e=t.valueToCode(e,`SUB`,w.NONE)||`''`,[t.provideFunction_(`text_count`,`
|
|
1284
|
-
int ${t.FUNCTION_NAME_PLACEHOLDER_}(String haystack, String needle) {
|
|
1285
|
-
if (needle.length == 0) {
|
|
1286
|
-
return haystack.length + 1;
|
|
1287
|
-
}
|
|
1288
|
-
int index = 0;
|
|
1289
|
-
int count = 0;
|
|
1290
|
-
while (index != -1) {
|
|
1291
|
-
index = haystack.indexOf(needle, index);
|
|
1292
|
-
if (index != -1) {
|
|
1293
|
-
count++;
|
|
1294
|
-
index += needle.length;
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
return count;
|
|
1298
|
-
}
|
|
1299
|
-
`)+`(`+n+`, `+e+`)`,w.UNARY_POSTFIX]},je=function(e,t){let n=t.valueToCode(e,`TEXT`,w.UNARY_POSTFIX)||`''`,r=t.valueToCode(e,`FROM`,w.NONE)||`''`;return e=t.valueToCode(e,`TO`,w.NONE)||`''`,[n+`.replaceAll(`+r+`, `+e+`)`,w.UNARY_POSTFIX]},Me=function(e,t){return[`new String.fromCharCodes(`+(t.valueToCode(e,`TEXT`,w.UNARY_POSTFIX)||`''`)+`.runes.toList().reversed)`,w.UNARY_PREFIX]},Ne=function(e,t){return[t.getVariableName(e.getFieldValue(`VAR`)),w.ATOMIC]},Pe=function(e,t){let n=t.valueToCode(e,`VALUE`,w.ASSIGNMENT)||`0`;return t.getVariableName(e.getFieldValue(`VAR`))+` = `+n+`;
|
|
1300
|
-
`},w;(function(e){e[e.ATOMIC=0]=`ATOMIC`,e[e.UNARY_POSTFIX=1]=`UNARY_POSTFIX`,e[e.UNARY_PREFIX=2]=`UNARY_PREFIX`,e[e.MULTIPLICATIVE=3]=`MULTIPLICATIVE`,e[e.ADDITIVE=4]=`ADDITIVE`,e[e.SHIFT=5]=`SHIFT`,e[e.BITWISE_AND=6]=`BITWISE_AND`,e[e.BITWISE_XOR=7]=`BITWISE_XOR`,e[e.BITWISE_OR=8]=`BITWISE_OR`,e[e.RELATIONAL=9]=`RELATIONAL`,e[e.EQUALITY=10]=`EQUALITY`,e[e.LOGICAL_AND=11]=`LOGICAL_AND`,e[e.LOGICAL_OR=12]=`LOGICAL_OR`,e[e.IF_NULL=13]=`IF_NULL`,e[e.CONDITIONAL=14]=`CONDITIONAL`,e[e.CASCADE=15]=`CASCADE`,e[e.ASSIGNMENT=16]=`ASSIGNMENT`,e[e.NONE=99]=`NONE`})(w||={});var T=class extends t.CodeGenerator$$module$build$src$core$generator{constructor(e=`Dart`){super(e),this.isInitialized=!1;for(let t in w)e=w[t],typeof e!=`string`&&(this[`ORDER_`+t]=e);this.addReservedWords(`assert,break,case,catch,class,const,continue,default,do,else,enum,extends,false,final,finally,for,if,in,is,new,null,rethrow,return,super,switch,this,throw,true,try,var,void,while,with,print,identityHashCode,identical,BidirectionalIterator,Comparable,double,Function,int,Invocation,Iterable,Iterator,List,Map,Match,num,Pattern,RegExp,Set,StackTrace,String,StringSink,Type,bool,DateTime,Deprecated,Duration,Expando,Null,Object,RuneIterator,Runes,Stopwatch,StringBuffer,Symbol,Uri,Comparator,AbstractClassInstantiationError,ArgumentError,AssertionError,CastError,ConcurrentModificationError,CyclicInitializationError,Error,Exception,FallThroughError,FormatException,IntegerDivisionByZeroException,NoSuchMethodError,NullThrownError,OutOfMemoryError,RangeError,StackOverflowError,StateError,TypeError,UnimplementedError,UnsupportedError`)}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){e&&=this.prefixLines(e,this.INDENT),e=`main() {
|
|
1301
|
-
`+e+`}`;let t=[],n=[];for(let e in this.definitions_){let r=this.definitions_[e];r.match(/^import\s/)?t.push(r):n.push(r)}return e=super.finish(e),this.isInitialized=!1,this.nameDB_.reset(),(t.join(`
|
|
1302
|
-
`)+`
|
|
1303
|
-
|
|
1304
|
-
`+n.join(`
|
|
1305
|
-
|
|
1306
|
-
`)).replace(/\n\n+/g,`
|
|
1307
|
-
|
|
1308
|
-
`).replace(/\n*$/,`
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
`)+e}scrubNakedValue(e){return e+`;
|
|
1312
|
-
`}quote_(e){return e=e.replace(/\\/g,`\\\\`).replace(/\n/g,`\\
|
|
1313
|
-
`).replace(/\$/g,`\\$`).replace(/'/g,`\\'`),`'`+e+`'`}multiline_quote_(e){return e.split(/\n/g).map(this.quote_).join(` + '\\n' +
|
|
1314
|
-
`)}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=`getProcedureDef`in e?i+this.prefixLines(a+`
|
|
1315
|
-
`,`/// `):i+this.prefixLines(a+`
|
|
1316
|
-
`,`// `));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=w.NONE){e.workspace.options.oneBasedIndex&&r--;let o=e.workspace.options.oneBasedIndex?`1`:`0`,s=a;return r?s=w.ADDITIVE:i&&(s=w.UNARY_PREFIX),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)}},Fe={};Fe.DartGenerator=T,Fe.Order=w;var E={};E.lists_create_empty=n,E.lists_create_with=r,E.lists_getIndex=c,E.lists_getSublist=u,E.lists_indexOf=s,E.lists_isEmpty=o,E.lists_length=a,E.lists_repeat=i,E.lists_reverse=p,E.lists_setIndex=l,E.lists_sort=d,E.lists_split=f;var D={};D.controls_if=m,D.controls_ifelse=m,D.logic_boolean=v,D.logic_compare=h,D.logic_negate=_,D.logic_null=y,D.logic_operation=g,D.logic_ternary=ee;var O={};O.controls_flow_statements=ie,O.controls_for=ne,O.controls_forEach=re,O.controls_repeat=b,O.controls_repeat_ext=b,O.controls_whileUntil=te;var k={};k.math_arithmetic=oe,k.math_atan2=me,k.math_change=le,k.math_constant=ce,k.math_constrain=S,k.math_modulo=de,k.math_number=ae,k.math_number_property=x,k.math_on_list=ue,k.math_random_float=pe,k.math_random_int=fe,k.math_round=se,k.math_single=se,k.math_trig=se;var A={};A.procedures_callnoreturn=_e,A.procedures_callreturn=ge,A.procedures_defnoreturn=he,A.procedures_defreturn=he,A.procedures_ifreturn=ve;var j={};j.text=ye,j.text_append=xe,j.text_changeCase=C,j.text_charAt=Te,j.text_count=Ae,j.text_getSubstring=Ee,j.text_indexOf=we,j.text_isEmpty=Ce,j.text_join=be,j.text_length=Se,j.text_print=Oe,j.text_prompt=ke,j.text_prompt_ext=ke,j.text_replace=je,j.text_reverse=Me,j.text_trim=De;var Ie={};Ie.variables_get=Ne,Ie.variables_set=Pe;var M={};M.variables_get_dynamic=Ne,M.variables_set_dynamic=Pe;var Le=new T;Le.addReservedWords(`Html,Math`);var Re=Object.assign({},E,D,O,k,A,j,Ie,M);for(let e in Re)Le.forBlock[e]=Re[e];var ze={};return ze.DartGenerator=T,ze.Order=w,ze.dartGenerator=Le,ze.__namespace__=t,ze})})),Ll=t(((e,t)=>{(function(n,r){typeof define==`function`&&define.amd?define([`./blockly_compressed.js`],r):typeof e==`object`?t.exports=r(y()):(n.lua=r(n.Blockly),n.Blockly.Lua=n.lua.luaGenerator)})(e,function(e){var t=e.__namespace__,n=function(e,t){return[`{}`,T.HIGH]},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)||`nil`;return[`{`+n.join(`, `)+`}`,T.HIGH]},i=function(e,t){let n=t.provideFunction_(`create_list_repeated`,`
|
|
1317
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(item, count)
|
|
1318
|
-
local t = {}
|
|
1319
|
-
for i = 1, count do
|
|
1320
|
-
table.insert(t, item)
|
|
1321
|
-
end
|
|
1322
|
-
return t
|
|
1323
|
-
end
|
|
1324
|
-
`),r=t.valueToCode(e,`ITEM`,T.NONE)||`nil`;return e=t.valueToCode(e,`NUM`,T.NONE)||`0`,[n+`(`+r+`, `+e+`)`,T.HIGH]},a=function(e,t){return[`#`+(t.valueToCode(e,`VALUE`,T.UNARY)||`{}`),T.UNARY]},o=function(e,t){return[`#`+(t.valueToCode(e,`VALUE`,T.UNARY)||`{}`)+` == 0`,T.RELATIONAL]},s=function(e,t){let n=t.valueToCode(e,`FIND`,T.NONE)||`''`,r=t.valueToCode(e,`VALUE`,T.NONE)||`{}`;return[(e.getFieldValue(`END`)===`FIRST`?t.provideFunction_(`first_index`,`
|
|
1325
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(t, elem)
|
|
1326
|
-
for k, v in ipairs(t) do
|
|
1327
|
-
if v == elem then
|
|
1328
|
-
return k
|
|
1329
|
-
end
|
|
1330
|
-
end
|
|
1331
|
-
return 0
|
|
1332
|
-
end
|
|
1333
|
-
`):t.provideFunction_(`last_index`,`
|
|
1334
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(t, elem)
|
|
1335
|
-
for i = #t, 1, -1 do
|
|
1336
|
-
if t[i] == elem then
|
|
1337
|
-
return i
|
|
1338
|
-
end
|
|
1339
|
-
end
|
|
1340
|
-
return 0
|
|
1341
|
-
end
|
|
1342
|
-
`))+`(`+r+`, `+n+`)`,T.HIGH]},c=function(e,n){var r=e.getFieldValue(`MODE`)||`GET`,i=e.getFieldValue(`WHERE`)||`FROM_START`;let a=n.valueToCode(e,`VALUE`,T.HIGH)||`({})`;return i!==`LAST`&&i!==`FROM_END`&&i!==`RANDOM`||a.match(/^\w+$/)?(n=n.valueToCode(e,`AT`,r===`GET`&&i===`FROM_END`?T.ADDITIVE:T.NONE)||`1`,n=D(a,i,n),r===`GET`?[a+`[`+n+`]`,T.HIGH]:(i=`table.remove(`+a+`, `+n+`)`,r===`GET_REMOVE`?[i,T.HIGH]:i+`
|
|
1343
|
-
`)):r===`REMOVE`?(r=n.valueToCode(e,`AT`,i===`FROM_END`?T.ADDITIVE:T.NONE)||`1`,n=n.nameDB_.getDistinctName(`tmp_list`,t.NameType$$module$build$src$core$names.VARIABLE),r=D(n,i,r),n+` = `+a+`
|
|
1344
|
-
table.remove(`+n+`, `+r+`)
|
|
1345
|
-
`):(e=n.valueToCode(e,`AT`,T.NONE)||`1`,[(r===`GET`?n.provideFunction_(`list_get_`+i.toLowerCase(),[`function `+n.FUNCTION_NAME_PLACEHOLDER_+`(t`+(i===`FROM_END`||i===`FROM_START`?`, at)`:`)`),` return t[`+D(`t`,i,`at`)+`]`,`end`]):n.provideFunction_(`list_remove_`+i.toLowerCase(),[`function `+n.FUNCTION_NAME_PLACEHOLDER_+`(t`+(i===`FROM_END`||i===`FROM_START`?`, at)`:`)`),` return table.remove(t, `+D(`t`,i,`at`)+`)`,`end`]))+`(`+a+(i===`FROM_END`||i===`FROM_START`?`, `+e:``)+`)`,T.HIGH])},l=function(e,n){let r=n.valueToCode(e,`LIST`,T.HIGH)||`{}`,i=e.getFieldValue(`MODE`)||`SET`,a=e.getFieldValue(`WHERE`)||`FROM_START`,o=n.valueToCode(e,`AT`,T.ADDITIVE)||`1`;e=n.valueToCode(e,`TO`,T.NONE)||`Nil`;let s=``;return a!==`LAST`&&a!==`FROM_END`&&a!==`RANDOM`||r.match(/^\w+$/)||(n=n.nameDB_.getDistinctName(`tmp_list`,t.NameType$$module$build$src$core$names.VARIABLE),s=n+` = `+r+`
|
|
1346
|
-
`,r=n),s=i===`SET`?s+(r+`[`+D(r,a,o)+`] = `+e):s+(`table.insert(`+r+`, `+(D(r,a,o)+(a===`LAST`?` + 1`:``))+`, `+e+`)`),s+`
|
|
1347
|
-
`},u=function(e,t){let n=t.valueToCode(e,`LIST`,T.NONE)||`{}`,r=e.getFieldValue(`WHERE1`),i=e.getFieldValue(`WHERE2`),a=t.valueToCode(e,`AT1`,T.NONE)||`1`;e=t.valueToCode(e,`AT2`,T.NONE)||`1`;let o=r===`FROM_END`||r===`FROM_START`?`, at1`:``,s=i===`FROM_END`||i===`FROM_START`?`, at2`:``;return[t.provideFunction_(`list_sublist_`+r.toLowerCase()+`_`+i.toLowerCase(),`
|
|
1348
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(source${o}${s})
|
|
1349
|
-
local t = {}
|
|
1350
|
-
local start = ${D(`source`,r,`at1`)}
|
|
1351
|
-
local finish = ${D(`source`,i,`at2`)}
|
|
1352
|
-
for i = start, finish do
|
|
1353
|
-
table.insert(t, source[i])
|
|
1354
|
-
end
|
|
1355
|
-
return t
|
|
1356
|
-
end
|
|
1357
|
-
`)+`(`+n+(r===`FROM_END`||r===`FROM_START`?`, `+a:``)+(i===`FROM_END`||i===`FROM_START`?`, `+e:``)+`)`,T.HIGH]},d=function(e,t){let n=t.valueToCode(e,`LIST`,T.NONE)||`{}`,r=e.getFieldValue(`DIRECTION`)===`1`?1:-1;return e=e.getFieldValue(`TYPE`),[t.provideFunction_(`list_sort`,`
|
|
1358
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(list, typev, direction)
|
|
1359
|
-
local t = {}
|
|
1360
|
-
for n,v in pairs(list) do table.insert(t, v) end
|
|
1361
|
-
local compareFuncs = {
|
|
1362
|
-
NUMERIC = function(a, b)
|
|
1363
|
-
return (tonumber(tostring(a)) or 0)
|
|
1364
|
-
< (tonumber(tostring(b)) or 0) end,
|
|
1365
|
-
TEXT = function(a, b)
|
|
1366
|
-
return tostring(a) < tostring(b) end,
|
|
1367
|
-
IGNORE_CASE = function(a, b)
|
|
1368
|
-
return string.lower(tostring(a)) < string.lower(tostring(b)) end
|
|
1369
|
-
}
|
|
1370
|
-
local compareTemp = compareFuncs[typev]
|
|
1371
|
-
local compare = compareTemp
|
|
1372
|
-
if direction == -1
|
|
1373
|
-
then compare = function(a, b) return compareTemp(b, a) end
|
|
1374
|
-
end
|
|
1375
|
-
table.sort(t, compare)
|
|
1376
|
-
return t
|
|
1377
|
-
end
|
|
1378
|
-
`)+`(`+n+`,"`+e+`", `+r+`)`,T.HIGH]},f=function(e,t){let n=t.valueToCode(e,`INPUT`,T.NONE),r=t.valueToCode(e,`DELIM`,T.NONE)||`''`;if(e=e.getFieldValue(`MODE`),e===`SPLIT`)n||=`''`,t=t.provideFunction_(`list_string_split`,`
|
|
1379
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(input, delim)
|
|
1380
|
-
local t = {}
|
|
1381
|
-
local pos = 1
|
|
1382
|
-
while true do
|
|
1383
|
-
next_delim = string.find(input, delim, pos)
|
|
1384
|
-
if next_delim == nil then
|
|
1385
|
-
table.insert(t, string.sub(input, pos))
|
|
1386
|
-
break
|
|
1387
|
-
else
|
|
1388
|
-
table.insert(t, string.sub(input, pos, next_delim-1))
|
|
1389
|
-
pos = next_delim + #delim
|
|
1390
|
-
end
|
|
1391
|
-
end
|
|
1392
|
-
return t
|
|
1393
|
-
end
|
|
1394
|
-
`);else if(e===`JOIN`)n||=`{}`,t=`table.concat`;else throw Error(`Unknown mode: `+e);return[t+`(`+n+`, `+r+`)`,T.HIGH]},p=function(e,t){return e=t.valueToCode(e,`LIST`,T.NONE)||`{}`,[t.provideFunction_(`list_reverse`,`
|
|
1395
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(input)
|
|
1396
|
-
local reversed = {}
|
|
1397
|
-
for i = #input, 1, -1 do
|
|
1398
|
-
table.insert(reversed, input[i])
|
|
1399
|
-
end
|
|
1400
|
-
return reversed
|
|
1401
|
-
end
|
|
1402
|
-
`)+`(`+e+`)`,T.HIGH]},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+` then
|
|
1403
|
-
`+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
|
|
1404
|
-
`+n),r+`end
|
|
1405
|
-
`},h=function(e,t){let n={EQ:`==`,NEQ:`~=`,LT:`<`,LTE:`<=`,GT:`>`,GTE:`>=`}[e.getFieldValue(`OP`)],r=t.valueToCode(e,`A`,T.RELATIONAL)||`0`;return e=t.valueToCode(e,`B`,T.RELATIONAL)||`0`,[r+` `+n+` `+e,T.RELATIONAL]},g=function(e,t){let n=e.getFieldValue(`OP`)===`AND`?`and`:`or`,r=n===`and`?T.AND:T.OR,i=t.valueToCode(e,`A`,r);return e=t.valueToCode(e,`B`,r),i||e?(t=n===`and`?`true`:`false`,i||=t,e||=t):e=i=`false`,[i+` `+n+` `+e,r]},_=function(e,t){return[`not `+(t.valueToCode(e,`BOOL`,T.UNARY)||`true`),T.UNARY]},v=function(e,t){return[e.getFieldValue(`BOOL`)===`TRUE`?`true`:`false`,T.ATOMIC]},y=function(e,t){return[`nil`,T.ATOMIC]},ee=function(e,t){let n=t.valueToCode(e,`IF`,T.AND)||`false`,r=t.valueToCode(e,`THEN`,T.AND)||`nil`;return e=t.valueToCode(e,`ELSE`,T.OR)||`nil`,[n+` and `+r+` or `+e,T.OR]},b=function(e,t){return e.includes(A)?e+t+`::continue::
|
|
1406
|
-
`:e},te=function(e,n){let r;r=e.getField(`TIMES`)?String(Number(e.getFieldValue(`TIMES`))):n.valueToCode(e,`TIMES`,T.NONE)||`0`,r=t.isNumber$$module$build$src$core$utils$string(r)?parseInt(r,10):`math.floor(`+r+`)`;let i=n.statementToCode(e,`DO`);return i=n.addLoopTrap(i,e),i=b(i,n.INDENT),`for `+n.nameDB_.getDistinctName(`count`,t.NameType$$module$build$src$core$names.VARIABLE)+` = 1, `+r+` do
|
|
1407
|
-
`+i+`end
|
|
1408
|
-
`},ne=function(e,t){let n=e.getFieldValue(`MODE`)===`UNTIL`,r=t.valueToCode(e,`BOOL`,n?T.UNARY:T.NONE)||`false`,i=t.statementToCode(e,`DO`);return i=t.addLoopTrap(i,e),i=b(i,t.INDENT),n&&(r=`not `+r),`while `+r+` do
|
|
1409
|
-
`+i+`end
|
|
1410
|
-
`},re=function(e,n){let r=n.getVariableName(e.getFieldValue(`VAR`)),i=n.valueToCode(e,`FROM`,T.NONE)||`0`,a=n.valueToCode(e,`TO`,T.NONE)||`0`,o=n.valueToCode(e,`BY`,T.NONE)||`1`,s=n.statementToCode(e,`DO`);s=n.addLoopTrap(s,e),s=b(s,n.INDENT),e=``;let c;return 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)?c=(Number(i)<=Number(a)?``:`-`)+Math.abs(Number(o)):(e=``,c=n.nameDB_.getDistinctName(r+`_inc`,t.NameType$$module$build$src$core$names.VARIABLE),e+=c+` = `,e=t.isNumber$$module$build$src$core$utils$string(o)?e+(Math.abs(o)+`
|
|
1411
|
-
`):e+(`math.abs(`+o+`)
|
|
1412
|
-
`),e=e+(`if (`+i+`) > (`+a+`) then
|
|
1413
|
-
`)+(n.INDENT+c+` = -`+c+`
|
|
1414
|
-
`),e+=`end
|
|
1415
|
-
`),e+(`for `+r+` = `+i+`, `+a+`, `+c)+(` do
|
|
1416
|
-
`+s+`end
|
|
1417
|
-
`)},ie=function(e,t){let n=t.getVariableName(e.getFieldValue(`VAR`)),r=t.valueToCode(e,`LIST`,T.NONE)||`{}`,i=t.statementToCode(e,`DO`);return i=t.addLoopTrap(i,e),i=b(i,t.INDENT),`for _, `+n+` in ipairs(`+r+`) do
|
|
1418
|
-
`+i+`end
|
|
1419
|
-
`},ae=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
|
|
1420
|
-
`;case`CONTINUE`:return n+A}throw Error(`Unknown flow statement.`)},oe=function(e,t){return e=Number(e.getFieldValue(`NUM`)),[String(e),e<0?T.UNARY:T.ATOMIC]},se=function(e,t){var n={ADD:[` + `,T.ADDITIVE],MINUS:[` - `,T.ADDITIVE],MULTIPLY:[` * `,T.MULTIPLICATIVE],DIVIDE:[` / `,T.MULTIPLICATIVE],POWER:[` ^ `,T.EXPONENTIATION]}[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`,[i+r+e,n]},ce=function(e,t){var n=e.getFieldValue(`OP`);if(n===`NEG`)return e=t.valueToCode(e,`NUM`,T.UNARY)||`0`,[`-`+e,T.UNARY];if(n===`POW10`)return e=t.valueToCode(e,`NUM`,T.EXPONENTIATION)||`0`,[`10 ^ `+e,T.EXPONENTIATION];switch(e=n===`ROUND`?t.valueToCode(e,`NUM`,T.ADDITIVE)||`0`:t.valueToCode(e,`NUM`,T.NONE)||`0`,n){case`ABS`:n=`math.abs(`+e+`)`;break;case`ROOT`:n=`math.sqrt(`+e+`)`;break;case`LN`:n=`math.log(`+e+`)`;break;case`LOG10`:n=`math.log(`+e+`, 10)`;break;case`EXP`:n=`math.exp(`+e+`)`;break;case`ROUND`:n=`math.floor(`+e+` + .5)`;break;case`ROUNDUP`:n=`math.ceil(`+e+`)`;break;case`ROUNDDOWN`:n=`math.floor(`+e+`)`;break;case`SIN`:n=`math.sin(math.rad(`+e+`))`;break;case`COS`:n=`math.cos(math.rad(`+e+`))`;break;case`TAN`:n=`math.tan(math.rad(`+e+`))`;break;case`ASIN`:n=`math.deg(math.asin(`+e+`))`;break;case`ACOS`:n=`math.deg(math.acos(`+e+`))`;break;case`ATAN`:n=`math.deg(math.atan(`+e+`))`;break;default:throw Error(`Unknown math operator: `+n)}return[n,T.HIGH]},x=function(e,t){return{PI:[`math.pi`,T.HIGH],E:[`math.exp(1)`,T.HIGH],GOLDEN_RATIO:[`(1 + math.sqrt(5)) / 2`,T.MULTIPLICATIVE],SQRT2:[`math.sqrt(2)`,T.HIGH],SQRT1_2:[`math.sqrt(1 / 2)`,T.HIGH],INFINITY:[`math.huge`,T.HIGH]}[e.getFieldValue(`CONSTANT`)]},le=function(e,t){var n={EVEN:[` % 2 == 0`,T.MULTIPLICATIVE,T.RELATIONAL],ODD:[` % 2 == 1`,T.MULTIPLICATIVE,T.RELATIONAL],WHOLE:[` % 1 == 0`,T.MULTIPLICATIVE,T.RELATIONAL],POSITIVE:[` > 0`,T.RELATIONAL,T.RELATIONAL],NEGATIVE:[` < 0`,T.RELATIONAL,T.RELATIONAL],DIVISIBLE_BY:[null,T.MULTIPLICATIVE,T.RELATIONAL],PRIME:[null,T.NONE,T.HIGH]};let r=e.getFieldValue(`PROPERTY`),[i,a,o]=n[r];if(n=t.valueToCode(e,`NUMBER_TO_CHECK`,a)||`0`,r===`PRIME`)e=t.provideFunction_(`math_isPrime`,`
|
|
1421
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(n)
|
|
1422
|
-
-- https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
|
1423
|
-
if n == 2 or n == 3 then
|
|
1424
|
-
return true
|
|
1425
|
-
end
|
|
1426
|
-
-- False if n is NaN, negative, is 1, or not whole.
|
|
1427
|
-
-- And false if n is divisible by 2 or 3.
|
|
1428
|
-
if not(n > 1) or n % 1 ~= 0 or n % 2 == 0 or n % 3 == 0 then
|
|
1429
|
-
return false
|
|
1430
|
-
end
|
|
1431
|
-
-- Check all the numbers of form 6k +/- 1, up to sqrt(n).
|
|
1432
|
-
for x = 6, math.sqrt(n) + 1.5, 6 do
|
|
1433
|
-
if n % (x - 1) == 0 or n % (x + 1) == 0 then
|
|
1434
|
-
return false
|
|
1435
|
-
end
|
|
1436
|
-
end
|
|
1437
|
-
return true
|
|
1438
|
-
end
|
|
1439
|
-
`)+`(`+n+`)`;else if(r===`DIVISIBLE_BY`){if(e=t.valueToCode(e,`DIVISOR`,T.MULTIPLICATIVE)||`0`,e===`0`)return[`nil`,T.ATOMIC];e=n+` % `+e+` == 0`}else e=n+i;return[e,o]},ue=function(e,t){let n=t.valueToCode(e,`DELTA`,T.ADDITIVE)||`0`;return e=t.getVariableName(e.getFieldValue(`VAR`)),e+` = `+e+` + `+n+`
|
|
1440
|
-
`},de=function(e,t){function n(){return t.provideFunction_(`math_sum`,`
|
|
1441
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1442
|
-
local result = 0
|
|
1443
|
-
for _, v in ipairs(t) do
|
|
1444
|
-
result = result + v
|
|
1445
|
-
end
|
|
1446
|
-
return result
|
|
1447
|
-
end
|
|
1448
|
-
`)}var r=e.getFieldValue(`OP`);switch(e=t.valueToCode(e,`LIST`,T.NONE)||`{}`,r){case`SUM`:r=n();break;case`MIN`:r=t.provideFunction_(`math_min`,`
|
|
1449
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1450
|
-
if #t == 0 then
|
|
1451
|
-
return 0
|
|
1452
|
-
end
|
|
1453
|
-
local result = math.huge
|
|
1454
|
-
for _, v in ipairs(t) do
|
|
1455
|
-
if v < result then
|
|
1456
|
-
result = v
|
|
1457
|
-
end
|
|
1458
|
-
end
|
|
1459
|
-
return result
|
|
1460
|
-
end
|
|
1461
|
-
`);break;case`AVERAGE`:r=t.provideFunction_(`math_average`,`
|
|
1462
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1463
|
-
if #t == 0 then
|
|
1464
|
-
return 0
|
|
1465
|
-
end
|
|
1466
|
-
return ${n()}(t) / #t
|
|
1467
|
-
end
|
|
1468
|
-
`);break;case`MAX`:r=t.provideFunction_(`math_max`,`
|
|
1469
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1470
|
-
if #t == 0 then
|
|
1471
|
-
return 0
|
|
1472
|
-
end
|
|
1473
|
-
local result = -math.huge
|
|
1474
|
-
for _, v in ipairs(t) do
|
|
1475
|
-
if v > result then
|
|
1476
|
-
result = v
|
|
1477
|
-
end
|
|
1478
|
-
end
|
|
1479
|
-
return result
|
|
1480
|
-
end
|
|
1481
|
-
`);break;case`MEDIAN`:r=t.provideFunction_(`math_median`,`
|
|
1482
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1483
|
-
-- Source: http://lua-users.org/wiki/SimpleStats
|
|
1484
|
-
if #t == 0 then
|
|
1485
|
-
return 0
|
|
1486
|
-
end
|
|
1487
|
-
local temp = {}
|
|
1488
|
-
for _, v in ipairs(t) do
|
|
1489
|
-
if type(v) == 'number' then
|
|
1490
|
-
table.insert(temp, v)
|
|
1491
|
-
end
|
|
1492
|
-
end
|
|
1493
|
-
table.sort(temp)
|
|
1494
|
-
if #temp % 2 == 0 then
|
|
1495
|
-
return (temp[#temp / 2] + temp[(#temp / 2) + 1]) / 2
|
|
1496
|
-
else
|
|
1497
|
-
return temp[math.ceil(#temp / 2)]
|
|
1498
|
-
end
|
|
1499
|
-
end
|
|
1500
|
-
`);break;case`MODE`:r=t.provideFunction_(`math_modes`,`
|
|
1501
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1502
|
-
-- Source: http://lua-users.org/wiki/SimpleStats
|
|
1503
|
-
local counts = {}
|
|
1504
|
-
for _, v in ipairs(t) do
|
|
1505
|
-
if counts[v] == nil then
|
|
1506
|
-
counts[v] = 1
|
|
1507
|
-
else
|
|
1508
|
-
counts[v] = counts[v] + 1
|
|
1509
|
-
end
|
|
1510
|
-
end
|
|
1511
|
-
local biggestCount = 0
|
|
1512
|
-
for _, v in pairs(counts) do
|
|
1513
|
-
if v > biggestCount then
|
|
1514
|
-
biggestCount = v
|
|
1515
|
-
end
|
|
1516
|
-
end
|
|
1517
|
-
local temp = {}
|
|
1518
|
-
for k, v in pairs(counts) do
|
|
1519
|
-
if v == biggestCount then
|
|
1520
|
-
table.insert(temp, k)
|
|
1521
|
-
end
|
|
1522
|
-
end
|
|
1523
|
-
return temp
|
|
1524
|
-
end
|
|
1525
|
-
`);break;case`STD_DEV`:r=t.provideFunction_(`math_standard_deviation`,`
|
|
1526
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1527
|
-
local m
|
|
1528
|
-
local vm
|
|
1529
|
-
local total = 0
|
|
1530
|
-
local count = 0
|
|
1531
|
-
local result
|
|
1532
|
-
m = #t == 0 and 0 or ${n()}(t) / #t
|
|
1533
|
-
for _, v in ipairs(t) do
|
|
1534
|
-
if type(v) == 'number' then
|
|
1535
|
-
vm = v - m
|
|
1536
|
-
total = total + (vm * vm)
|
|
1537
|
-
count = count + 1
|
|
1538
|
-
end
|
|
1539
|
-
end
|
|
1540
|
-
result = math.sqrt(total / (count-1))
|
|
1541
|
-
return result
|
|
1542
|
-
end
|
|
1543
|
-
`);break;case`RANDOM`:r=t.provideFunction_(`math_random_list`,`
|
|
1544
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1545
|
-
if #t == 0 then
|
|
1546
|
-
return nil
|
|
1547
|
-
end
|
|
1548
|
-
return t[math.random(#t)]
|
|
1549
|
-
end
|
|
1550
|
-
`);break;default:throw Error(`Unknown operator: `+r)}return[r+`(`+e+`)`,T.HIGH]},S=function(e,t){let n=t.valueToCode(e,`DIVIDEND`,T.MULTIPLICATIVE)||`0`;return e=t.valueToCode(e,`DIVISOR`,T.MULTIPLICATIVE)||`0`,[n+` % `+e,T.MULTIPLICATIVE]},fe=function(e,t){let n=t.valueToCode(e,`VALUE`,T.NONE)||`0`,r=t.valueToCode(e,`LOW`,T.NONE)||`-math.huge`;return e=t.valueToCode(e,`HIGH`,T.NONE)||`math.huge`,[`math.min(math.max(`+n+`, `+r+`), `+e+`)`,T.HIGH]},pe=function(e,t){let n=t.valueToCode(e,`FROM`,T.NONE)||`0`;return e=t.valueToCode(e,`TO`,T.NONE)||`0`,[`math.random(`+n+`, `+e+`)`,T.HIGH]},me=function(e,t){return[`math.random()`,T.HIGH]},he=function(e,t){let n=t.valueToCode(e,`X`,T.NONE)||`0`;return[`math.deg(math.atan2(`+(t.valueToCode(e,`Y`,T.NONE)||`0`)+`, `+n+`))`,T.HIGH]},ge=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&&=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+`
|
|
1551
|
-
`:a||=``;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(`, `)+`)
|
|
1552
|
-
`+r+i+a+s+o+`end
|
|
1553
|
-
`,r=t.scrub_(e,r),t.definitions_[`%`+n]=r,null},_e=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)||`nil`;return[n+`(`+r.join(`, `)+`)`,T.HIGH]},ve=function(e,t){return t.forBlock.procedures_callreturn(e,t)[0]+`
|
|
1554
|
-
`},ye=function(e,t){let n=`if `+(t.valueToCode(e,`CONDITION`,T.NONE)||`false`)+` then
|
|
1555
|
-
`;return t.STATEMENT_SUFFIX&&(n+=t.prefixLines(t.injectId(t.STATEMENT_SUFFIX,e),t.INDENT)),e.hasReturnValue_?(e=t.valueToCode(e,`VALUE`,T.NONE)||`nil`,n+=t.INDENT+`return `+e+`
|
|
1556
|
-
`):n+=t.INDENT+`return
|
|
1557
|
-
`,n+`end
|
|
1558
|
-
`},be=function(e,t){return[t.quote_(e.getFieldValue(`TEXT`)),T.ATOMIC]},xe=function(e,t){if(e.itemCount_===0)return[`''`,T.ATOMIC];if(e.itemCount_===1)return[`tostring(`+(t.valueToCode(e,`ADD0`,T.NONE)||`''`)+`)`,T.HIGH];if(e.itemCount_===2){var n=t.valueToCode(e,`ADD0`,T.CONCATENATION)||`''`;return e=t.valueToCode(e,`ADD1`,T.CONCATENATION)||`''`,[n+` .. `+e,T.CONCATENATION]}n=[];for(let r=0;r<e.itemCount_;r++)n[r]=t.valueToCode(e,`ADD`+r,T.NONE)||`''`;return[`table.concat({`+n.join(`, `)+`})`,T.HIGH]},Se=function(e,t){let n=t.getVariableName(e.getFieldValue(`VAR`));return e=t.valueToCode(e,`TEXT`,T.CONCATENATION)||`''`,n+` = `+n+` .. `+e+`
|
|
1559
|
-
`},Ce=function(e,t){return[`#`+(t.valueToCode(e,`VALUE`,T.UNARY)||`''`),T.UNARY]},we=function(e,t){return[`#`+(t.valueToCode(e,`VALUE`,T.UNARY)||`''`)+` == 0`,T.RELATIONAL]},Te=function(e,t){let n=t.valueToCode(e,`FIND`,T.NONE)||`''`,r=t.valueToCode(e,`VALUE`,T.NONE)||`''`;return[(e.getFieldValue(`END`)===`FIRST`?t.provideFunction_(`firstIndexOf`,`
|
|
1560
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(str, substr)
|
|
1561
|
-
local i = string.find(str, substr, 1, true)
|
|
1562
|
-
if i == nil then
|
|
1563
|
-
return 0
|
|
1564
|
-
end
|
|
1565
|
-
return i
|
|
1566
|
-
end
|
|
1567
|
-
`):t.provideFunction_(`lastIndexOf`,`
|
|
1568
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(str, substr)
|
|
1569
|
-
local i = string.find(string.reverse(str), string.reverse(substr), 1, true)
|
|
1570
|
-
if i then
|
|
1571
|
-
return #str + 2 - i - #substr
|
|
1572
|
-
end
|
|
1573
|
-
return 0
|
|
1574
|
-
end
|
|
1575
|
-
`))+`(`+r+`, `+n+`)`,T.HIGH]},Ee=function(e,t){var n=e.getFieldValue(`WHERE`)||`FROM_START`;let r=t.valueToCode(e,`VALUE`,T.NONE)||`''`;if(n===`RANDOM`)t=t.provideFunction_(`text_random_letter`,`
|
|
1576
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(str)
|
|
1577
|
-
local index = math.random(string.len(str))
|
|
1578
|
-
return string.sub(str, index, index)
|
|
1579
|
-
end
|
|
1580
|
-
`)+`(`+r+`)`;else{if(n===`FIRST`)n=`1`;else if(n===`LAST`)n=`-1`;else if(e=t.valueToCode(e,`AT`,n===`FROM_END`?T.UNARY:T.NONE)||`1`,n===`FROM_START`)n=e;else if(n===`FROM_END`)n=`-`+e;else throw Error(`Unhandled option (text_charAt).`);t=n.match(/^-?\w*$/)?`string.sub(`+r+`, `+n+`, `+n+`)`:t.provideFunction_(`text_char_at`,`
|
|
1581
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(str, index)
|
|
1582
|
-
return string.sub(str, index, index)
|
|
1583
|
-
end
|
|
1584
|
-
`)+`(`+r+`, `+n+`)`}return[t,T.HIGH]},C=function(e,t){let n=t.valueToCode(e,`STRING`,T.NONE)||`''`;var r=e.getFieldValue(`WHERE1`),i=t.valueToCode(e,`AT1`,r===`FROM_END`?T.UNARY:T.NONE)||`1`;if(r===`FIRST`)r=1;else if(r===`FROM_START`)r=i;else if(r===`FROM_END`)r=`-`+i;else throw Error(`Unhandled option (text_getSubstring)`);if(i=e.getFieldValue(`WHERE2`),e=t.valueToCode(e,`AT2`,i===`FROM_END`?T.UNARY:T.NONE)||`1`,i===`LAST`)e=-1;else if(i!==`FROM_START`)if(i===`FROM_END`)e=`-`+e;else throw Error(`Unhandled option (text_getSubstring)`);return[`string.sub(`+n+`, `+r+`, `+e+`)`,T.HIGH]},De=function(e,t){let n=e.getFieldValue(`CASE`);e=t.valueToCode(e,`TEXT`,T.NONE)||`''`;let r;return n===`UPPERCASE`?r=`string.upper`:n===`LOWERCASE`?r=`string.lower`:n===`TITLECASE`&&(r=t.provideFunction_(`text_titlecase`,`
|
|
1585
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(str)
|
|
1586
|
-
local buf = {}
|
|
1587
|
-
local inWord = false
|
|
1588
|
-
for i = 1, #str do
|
|
1589
|
-
local c = string.sub(str, i, i)
|
|
1590
|
-
if inWord then
|
|
1591
|
-
table.insert(buf, string.lower(c))
|
|
1592
|
-
if string.find(c, "%s") then
|
|
1593
|
-
inWord = false
|
|
1594
|
-
end
|
|
1595
|
-
else
|
|
1596
|
-
table.insert(buf, string.upper(c))
|
|
1597
|
-
inWord = true
|
|
1598
|
-
end
|
|
1599
|
-
end
|
|
1600
|
-
return table.concat(buf)
|
|
1601
|
-
end
|
|
1602
|
-
`)),[r+`(`+e+`)`,T.HIGH]},Oe=function(e,t){let n={LEFT:`^%s*(,-)`,RIGHT:`(.-)%s*$`,BOTH:`^%s*(.-)%s*$`}[e.getFieldValue(`MODE`)];return[`string.gsub(`+(t.valueToCode(e,`TEXT`,T.NONE)||`''`)+`, "`+n+`", "%1")`,T.HIGH]},ke=function(e,t){return`print(`+(t.valueToCode(e,`TEXT`,T.NONE)||`''`)+`)
|
|
1603
|
-
`},Ae=function(e,t){let n;return n=e.getField(`TEXT`)?t.quote_(e.getFieldValue(`TEXT`)):t.valueToCode(e,`TEXT`,T.NONE)||`''`,t=t.provideFunction_(`text_prompt`,`
|
|
1604
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(msg)
|
|
1605
|
-
io.write(msg)
|
|
1606
|
-
io.flush()
|
|
1607
|
-
return io.read()
|
|
1608
|
-
end
|
|
1609
|
-
`)+`(`+n+`)`,e.getFieldValue(`TYPE`)===`NUMBER`&&(t=`tonumber(`+t+`, 10)`),[t,T.HIGH]},je=function(e,t){let n=t.valueToCode(e,`TEXT`,T.NONE)||`''`;return e=t.valueToCode(e,`SUB`,T.NONE)||`''`,[t.provideFunction_(`text_count`,`
|
|
1610
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle)
|
|
1611
|
-
if #needle == 0 then
|
|
1612
|
-
return #haystack + 1
|
|
1613
|
-
end
|
|
1614
|
-
local i = 1
|
|
1615
|
-
local count = 0
|
|
1616
|
-
while true do
|
|
1617
|
-
i = string.find(haystack, needle, i, true)
|
|
1618
|
-
if i == nil then
|
|
1619
|
-
break
|
|
1620
|
-
end
|
|
1621
|
-
count = count + 1
|
|
1622
|
-
i = i + #needle
|
|
1623
|
-
end
|
|
1624
|
-
return count
|
|
1625
|
-
end
|
|
1626
|
-
`)+`(`+n+`, `+e+`)`,T.HIGH]},Me=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_(`text_replace`,`
|
|
1627
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement)
|
|
1628
|
-
local buf = {}
|
|
1629
|
-
local i = 1
|
|
1630
|
-
while i <= #haystack do
|
|
1631
|
-
if string.sub(haystack, i, i + #needle - 1) == needle then
|
|
1632
|
-
for j = 1, #replacement do
|
|
1633
|
-
table.insert(buf, string.sub(replacement, j, j))
|
|
1634
|
-
end
|
|
1635
|
-
i = i + #needle
|
|
1636
|
-
else
|
|
1637
|
-
table.insert(buf, string.sub(haystack, i, i))
|
|
1638
|
-
i = i + 1
|
|
1639
|
-
end
|
|
1640
|
-
end
|
|
1641
|
-
return table.concat(buf)
|
|
1642
|
-
end
|
|
1643
|
-
`)+`(`+n+`, `+r+`, `+e+`)`,T.HIGH]},Ne=function(e,t){return[`string.reverse(`+(t.valueToCode(e,`TEXT`,T.NONE)||`''`)+`)`,T.HIGH]},Pe=function(e,t){return[t.getVariableName(e.getFieldValue(`VAR`)),T.ATOMIC]},w=function(e,t){let n=t.valueToCode(e,`VALUE`,T.NONE)||`0`;return t.getVariableName(e.getFieldValue(`VAR`))+` = `+n+`
|
|
1644
|
-
`},T;(function(e){e[e.ATOMIC=0]=`ATOMIC`,e[e.HIGH=1]=`HIGH`,e[e.EXPONENTIATION=2]=`EXPONENTIATION`,e[e.UNARY=3]=`UNARY`,e[e.MULTIPLICATIVE=4]=`MULTIPLICATIVE`,e[e.ADDITIVE=5]=`ADDITIVE`,e[e.CONCATENATION=6]=`CONCATENATION`,e[e.RELATIONAL=7]=`RELATIONAL`,e[e.AND=8]=`AND`,e[e.OR=9]=`OR`,e[e.NONE=99]=`NONE`})(T||={});var Fe=class extends t.CodeGenerator$$module$build$src$core$generator{constructor(e=`Lua`){super(e),this.isInitialized=!1;for(let t in T)e=T[t],typeof e!=`string`&&(this[`ORDER_`+t]=e);this.addReservedWords(`_,__inext,assert,bit,colors,colours,coroutine,disk,dofile,error,fs,fetfenv,getmetatable,gps,help,io,ipairs,keys,loadfile,loadstring,math,native,next,os,paintutils,pairs,parallel,pcall,peripheral,print,printError,rawequal,rawget,rawset,read,rednet,redstone,rs,select,setfenv,setmetatable,sleep,string,table,term,textutils,tonumber,tostring,turtle,type,unpack,vector,write,xpcall,_VERSION,__indext,HTTP,and,break,do,else,elseif,end,false,for,function,if,in,local,nil,not,or,repeat,return,then,true,until,while,add,sub,mul,div,mod,pow,unm,concat,len,eq,lt,le,index,newindex,call,assert,collectgarbage,dofile,error,_G,getmetatable,inpairs,load,loadfile,next,pairs,pcall,print,rawequal,rawget,rawlen,rawset,select,setmetatable,tonumber,tostring,type,_VERSION,xpcall,require,package,string,table,math,bit32,io,file,os,debug`)}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),this.isInitialized=!0}finish(e){let t=Object.values(this.definitions_);return e=super.finish(e),this.isInitialized=!1,this.nameDB_.reset(),t.join(`
|
|
1645
|
-
|
|
1646
|
-
`)+`
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
`+e}scrubNakedValue(e){return`local _ = `+e+`
|
|
1650
|
-
`}quote_(e){return e=e.replace(/\\/g,`\\\\`).replace(/\n/g,`\\
|
|
1651
|
-
`).replace(/'/g,`\\'`),`'`+e+`'`}multiline_quote_(e){return e.split(/\n/g).map(this.quote_).join(` .. '\\n' ..
|
|
1652
|
-
`)}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,`-- `)+`
|
|
1653
|
-
`);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}},E={};E.LuaGenerator=Fe,E.Order=T;var D=function(e,t,n){return t===`FIRST`?`1`:t===`FROM_END`?`#`+e+` + 1 - `+n:t===`LAST`?`#`+e:t===`RANDOM`?`math.random(#`+e+`)`: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 k={};k.controls_if=m,k.controls_ifelse=m,k.logic_boolean=v,k.logic_compare=h,k.logic_negate=_,k.logic_null=y,k.logic_operation=g,k.logic_ternary=ee;var A=`goto continue
|
|
1654
|
-
`,j={};j.controls_flow_statements=ae,j.controls_for=re,j.controls_forEach=ie,j.controls_repeat=te,j.controls_repeat_ext=te,j.controls_whileUntil=ne;var Ie={};Ie.math_arithmetic=se,Ie.math_atan2=he,Ie.math_change=ue,Ie.math_constant=x,Ie.math_constrain=fe,Ie.math_modulo=S,Ie.math_number=oe,Ie.math_number_property=le,Ie.math_on_list=de,Ie.math_random_float=me,Ie.math_random_int=pe,Ie.math_round=ce,Ie.math_single=ce,Ie.math_trig=ce;var M={};M.procedures_callnoreturn=ve,M.procedures_callreturn=_e,M.procedures_defnoreturn=ge,M.procedures_defreturn=ge,M.procedures_ifreturn=ye;var Le={};Le.text=be,Le.text_append=Se,Le.text_changeCase=De,Le.text_charAt=Ee,Le.text_count=je,Le.text_getSubstring=C,Le.text_indexOf=Te,Le.text_isEmpty=we,Le.text_join=xe,Le.text_length=Ce,Le.text_print=ke,Le.text_prompt=Ae,Le.text_prompt_ext=Ae,Le.text_replace=Me,Le.text_reverse=Ne,Le.text_trim=Oe;var Re={};Re.variables_get=Pe,Re.variables_set=w;var ze={};ze.variables_get_dynamic=Pe,ze.variables_set_dynamic=w;var Be=new Fe,Ve=Object.assign({},O,k,j,Ie,M,Le,Re,ze);for(let e in Ve)Be.forBlock[e]=Ve[e];var He={};return He.LuaGenerator=Fe,He.Order=T,He.luaGenerator=Be,He.__namespace__=t,He})})),R=t(((e,t)=>{(function(n,r){typeof define==`function`&&define.amd?define([`./blockly_compressed.js`],r):typeof e==`object`?t.exports=r(y()):(n.php=r(n.Blockly),n.Blockly.PHP=n.php.phpGenerator)})(e,function(e){var t=e.__namespace__,n=function(e,t){return[`array()`,w.FUNCTION_CALL]},r=function(e,t){let n=Array(e.itemCount_);for(let r=0;r<e.itemCount_;r++)n[r]=t.valueToCode(e,`ADD`+r,w.NONE)||`null`;return[`array(`+n.join(`, `)+`)`,w.FUNCTION_CALL]},i=function(e,t){let n=t.provideFunction_(`lists_repeat`,`
|
|
1655
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($value, $count) {
|
|
1656
|
-
$array = array();
|
|
1657
|
-
for ($index = 0; $index < $count; $index++) {
|
|
1658
|
-
$array[] = $value;
|
|
1659
|
-
}
|
|
1660
|
-
return $array;
|
|
1661
|
-
}
|
|
1662
|
-
`),r=t.valueToCode(e,`ITEM`,w.NONE)||`null`;return e=t.valueToCode(e,`NUM`,w.NONE)||`0`,[n+`(`+r+`, `+e+`)`,w.FUNCTION_CALL]},a=function(e,t){let n=t.provideFunction_(`length`,`
|
|
1663
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($value) {
|
|
1664
|
-
if (is_string($value)) {
|
|
1665
|
-
return strlen($value);
|
|
1666
|
-
} else {
|
|
1667
|
-
return count($value);
|
|
1668
|
-
}
|
|
1669
|
-
}
|
|
1670
|
-
`);return e=t.valueToCode(e,`VALUE`,w.NONE)||`''`,[n+`(`+e+`)`,w.FUNCTION_CALL]},o=function(e,t){return[`empty(`+(t.valueToCode(e,`VALUE`,w.FUNCTION_CALL)||`array()`)+`)`,w.FUNCTION_CALL]},s=function(e,t){let n=t.valueToCode(e,`FIND`,w.NONE)||`''`,r=t.valueToCode(e,`VALUE`,w.MEMBER)||`[]`,i=` -1`,a=``;return e.workspace.options.oneBasedIndex&&(i=` 0`,a=` + 1`),[(e.getFieldValue(`END`)===`FIRST`?t.provideFunction_(`indexOf`,`
|
|
1671
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($haystack, $needle) {
|
|
1672
|
-
for ($index = 0; $index < count($haystack); $index++) {
|
|
1673
|
-
if ($haystack[$index] == $needle) return $index${a};
|
|
1674
|
-
}
|
|
1675
|
-
return ${i};
|
|
1676
|
-
}
|
|
1677
|
-
`):t.provideFunction_(`lastIndexOf`,`
|
|
1678
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($haystack, $needle) {
|
|
1679
|
-
$last = ${i};
|
|
1680
|
-
for ($index = 0; $index < count($haystack); $index++) {
|
|
1681
|
-
if ($haystack[$index] == $needle) $last = $index${a};
|
|
1682
|
-
}
|
|
1683
|
-
return $last;
|
|
1684
|
-
}
|
|
1685
|
-
`))+`(`+r+`, `+n+`)`,w.FUNCTION_CALL]},c=function(e,t){var n=e.getFieldValue(`MODE`)||`GET`;switch(e.getFieldValue(`WHERE`)||`FROM_START`){case`FIRST`:if(n===`GET`)return[(t.valueToCode(e,`VALUE`,w.MEMBER)||`array()`)+`[0]`,w.MEMBER];if(n===`GET_REMOVE`)return[`array_shift(`+(t.valueToCode(e,`VALUE`,w.NONE)||`array()`)+`)`,w.FUNCTION_CALL];if(n===`REMOVE`)return`array_shift(`+(t.valueToCode(e,`VALUE`,w.NONE)||`array()`)+`);
|
|
1686
|
-
`;break;case`LAST`:if(n===`GET`)return[`end(`+(t.valueToCode(e,`VALUE`,w.NONE)||`array()`)+`)`,w.FUNCTION_CALL];if(n===`GET_REMOVE`)return[`array_pop(`+(t.valueToCode(e,`VALUE`,w.NONE)||`array()`)+`)`,w.FUNCTION_CALL];if(n===`REMOVE`)return`array_pop(`+(t.valueToCode(e,`VALUE`,w.NONE)||`array()`)+`);
|
|
1687
|
-
`;break;case`FROM_START`:var r=t.getAdjusted(e,`AT`);if(n===`GET`)return[(t.valueToCode(e,`VALUE`,w.MEMBER)||`array()`)+`[`+r+`]`,w.MEMBER];if(n===`GET_REMOVE`)return[`array_splice(`+(t.valueToCode(e,`VALUE`,w.NONE)||`array()`)+`, `+r+`, 1)[0]`,w.FUNCTION_CALL];if(n===`REMOVE`)return`array_splice(`+(t.valueToCode(e,`VALUE`,w.NONE)||`array()`)+`, `+r+`, 1);
|
|
1688
|
-
`;break;case`FROM_END`:if(n===`GET`)return n=t.valueToCode(e,`VALUE`,w.NONE)||`array()`,t=t.getAdjusted(e,`AT`,1,!0),[`array_slice(`+n+`, `+t+`, 1)[0]`,w.FUNCTION_CALL];if(n===`GET_REMOVE`||n===`REMOVE`){if(r=t.valueToCode(e,`VALUE`,w.NONE)||`array()`,t=t.getAdjusted(e,`AT`,1,!1,w.SUBTRACTION),t=`array_splice(`+r+`, count(`+r+`) - `+t+`, 1)[0]`,n===`GET_REMOVE`)return[t,w.FUNCTION_CALL];if(n===`REMOVE`)return t+`;
|
|
1689
|
-
`}break;case`RANDOM`:if(e=t.valueToCode(e,`VALUE`,w.NONE)||`array()`,n===`GET`)return[t.provideFunction_(`lists_get_random_item`,`
|
|
1690
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($list) {
|
|
1691
|
-
return $list[rand(0,count($list)-1)];
|
|
1692
|
-
}
|
|
1693
|
-
`)+`(`+e+`)`,w.FUNCTION_CALL];if(n===`GET_REMOVE`)return[t.provideFunction_(`lists_get_remove_random_item`,`
|
|
1694
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(&$list) {
|
|
1695
|
-
$x = rand(0,count($list)-1);
|
|
1696
|
-
unset($list[$x]);
|
|
1697
|
-
return array_values($list);
|
|
1698
|
-
}
|
|
1699
|
-
`)+`(`+e+`)`,w.FUNCTION_CALL];if(n===`REMOVE`)return t.provideFunction_(`lists_remove_random_item`,`
|
|
1700
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}(&$list) {
|
|
1701
|
-
unset($list[rand(0,count($list)-1)]);
|
|
1702
|
-
}
|
|
1703
|
-
`)+`(`+e+`);
|
|
1704
|
-
`}throw Error(`Unhandled combination (lists_getIndex).`)},l=function(e,n){let r=e.getFieldValue(`MODE`)||`GET`;var i=e.getFieldValue(`WHERE`)||`FROM_START`;let a=n.valueToCode(e,`TO`,w.ASSIGNMENT)||`null`;switch(i){case`FIRST`:if(r===`SET`)return(n.valueToCode(e,`LIST`,w.MEMBER)||`array()`)+`[0] = `+a+`;
|
|
1705
|
-
`;if(r===`INSERT`)return`array_unshift(`+(n.valueToCode(e,`LIST`,w.NONE)||`array()`)+`, `+a+`);
|
|
1706
|
-
`;break;case`LAST`:if(e=n.valueToCode(e,`LIST`,w.NONE)||`array()`,r===`SET`)return n.provideFunction_(`lists_set_last_item`,`
|
|
1707
|
-
function ${n.FUNCTION_NAME_PLACEHOLDER_}(&$list, $value) {
|
|
1708
|
-
$list[count($list) - 1] = $value;
|
|
1709
|
-
}
|
|
1710
|
-
`)+`(`+e+`, `+a+`);
|
|
1711
|
-
`;if(r===`INSERT`)return`array_push(`+e+`, `+a+`);
|
|
1712
|
-
`;break;case`FROM_START`:if(i=n.getAdjusted(e,`AT`),r===`SET`)return(n.valueToCode(e,`LIST`,w.MEMBER)||`array()`)+`[`+i+`] = `+a+`;
|
|
1713
|
-
`;if(r===`INSERT`)return`array_splice(`+(n.valueToCode(e,`LIST`,w.NONE)||`array()`)+`, `+i+`, 0, `+a+`);
|
|
1714
|
-
`;break;case`FROM_END`:if(i=n.valueToCode(e,`LIST`,w.NONE)||`array()`,e=n.getAdjusted(e,`AT`,1),r===`SET`)return n.provideFunction_(`lists_set_from_end`,`
|
|
1715
|
-
function ${n.FUNCTION_NAME_PLACEHOLDER_}(&$list, $at, $value) {
|
|
1716
|
-
$list[count($list) - $at] = $value;
|
|
1717
|
-
}
|
|
1718
|
-
`)+`(`+i+`, `+e+`, `+a+`);
|
|
1719
|
-
`;if(r===`INSERT`)return n.provideFunction_(`lists_insert_from_end`,`
|
|
1720
|
-
function ${n.FUNCTION_NAME_PLACEHOLDER_}(&$list, $at, $value) {
|
|
1721
|
-
return array_splice($list, count($list) - $at, 0, $value);
|
|
1722
|
-
}
|
|
1723
|
-
`)+`(`+i+`, `+e+`, `+a+`);
|
|
1724
|
-
`;break;case`RANDOM`:if(e=n.valueToCode(e,`LIST`,w.REFERENCE)||`array()`,e.match(/^\$\w+$/))i=``;else{i=n.nameDB_.getDistinctName(`tmp_list`,t.NameType$$module$build$src$core$names.VARIABLE);var o=i+` = &`+e+`;
|
|
1725
|
-
`;e=i,i=o}if(n=n.nameDB_.getDistinctName(`tmp_x`,t.NameType$$module$build$src$core$names.VARIABLE),i+=n+` = rand(0, count(`+e+`)-1);
|
|
1726
|
-
`,r===`SET`)return i+(e+`[`+n+`] = `+a+`;
|
|
1727
|
-
`);if(r===`INSERT`)return i+(`array_splice(`+e+`, `+n+`, 0, `+a+`);
|
|
1728
|
-
`)}throw Error(`Unhandled combination (lists_setIndex).`)},u=function(e,n){var r=n.valueToCode(e,`LIST`,w.NONE)||`array()`,i=e.getFieldValue(`WHERE1`);let a=e.getFieldValue(`WHERE2`);if(i!==`FIRST`||a!==`LAST`)if(r.match(/^\$\w+$/)||i!==`FROM_END`&&a===`FROM_START`){switch(i){case`FROM_START`:i=n.getAdjusted(e,`AT1`);break;case`FROM_END`:i=n.getAdjusted(e,`AT1`,1,!1,w.SUBTRACTION),i=`count(`+r+`) - `+i;break;case`FIRST`:i=`0`;break;default:throw Error(`Unhandled option (lists_getSublist).`)}switch(a){case`FROM_START`:n=n.getAdjusted(e,`AT2`,0,!1,w.SUBTRACTION),n+=` - `,n=t.isNumber$$module$build$src$core$utils$string(String(i))||String(i).match(/^\(.+\)$/)?n+i:n+(`(`+i+`)`),n+=` + 1`;break;case`FROM_END`:n=n.getAdjusted(e,`AT2`,0,!1,w.SUBTRACTION),n=`count(`+r+`) - `+n+` - `,n=t.isNumber$$module$build$src$core$utils$string(String(i))||String(i).match(/^\(.+\)$/)?n+i:n+(`(`+i+`)`);break;case`LAST`:n=`count(`+r+`) - `,n=t.isNumber$$module$build$src$core$utils$string(String(i))||String(i).match(/^\(.+\)$/)?n+i:n+(`(`+i+`)`);break;default:throw Error(`Unhandled option (lists_getSublist).`)}r=`array_slice(`+r+`, `+i+`, `+n+`)`}else{let t=n.getAdjusted(e,`AT1`);e=n.getAdjusted(e,`AT2`),r=n.provideFunction_(`lists_get_sublist`,`
|
|
1729
|
-
function ${n.FUNCTION_NAME_PLACEHOLDER_}($list, $where1, $at1, $where2, $at2) {
|
|
1730
|
-
if ($where1 == 'FROM_END') {
|
|
1731
|
-
$at1 = count($list) - 1 - $at1;
|
|
1732
|
-
} else if ($where1 == 'FIRST') {
|
|
1733
|
-
$at1 = 0;
|
|
1734
|
-
} else if ($where1 != 'FROM_START') {
|
|
1735
|
-
throw new Exception('Unhandled option (lists_get_sublist).');
|
|
1736
|
-
}
|
|
1737
|
-
$length = 0;
|
|
1738
|
-
if ($where2 == 'FROM_START') {
|
|
1739
|
-
$length = $at2 - $at1 + 1;
|
|
1740
|
-
} else if ($where2 == 'FROM_END') {
|
|
1741
|
-
$length = count($list) - $at1 - $at2;
|
|
1742
|
-
} else if ($where2 == 'LAST') {
|
|
1743
|
-
$length = count($list) - $at1;
|
|
1744
|
-
} else {
|
|
1745
|
-
throw new Exception('Unhandled option (lists_get_sublist).');
|
|
1746
|
-
}
|
|
1747
|
-
return array_slice($list, $at1, $length);
|
|
1748
|
-
}
|
|
1749
|
-
`)+`(`+r+`, '`+i+`', `+t+`, '`+a+`', `+e+`)`}return[r,w.FUNCTION_CALL]},d=function(e,t){let n=t.valueToCode(e,`LIST`,w.NONE)||`array()`,r=e.getFieldValue(`DIRECTION`)===`1`?1:-1;return e=e.getFieldValue(`TYPE`),[t.provideFunction_(`lists_sort`,`
|
|
1750
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($list, $type, $direction) {
|
|
1751
|
-
$sortCmpFuncs = array(
|
|
1752
|
-
'NUMERIC' => 'strnatcasecmp',
|
|
1753
|
-
'TEXT' => 'strcmp',
|
|
1754
|
-
'IGNORE_CASE' => 'strcasecmp'
|
|
1755
|
-
);
|
|
1756
|
-
$sortCmp = $sortCmpFuncs[$type];
|
|
1757
|
-
$list2 = $list;
|
|
1758
|
-
usort($list2, $sortCmp);
|
|
1759
|
-
if ($direction == -1) {
|
|
1760
|
-
$list2 = array_reverse($list2);
|
|
1761
|
-
}
|
|
1762
|
-
return $list2;
|
|
1763
|
-
}
|
|
1764
|
-
`)+`(`+n+`, "`+e+`", `+r+`)`,w.FUNCTION_CALL]},f=function(e,t){let n=t.valueToCode(e,`INPUT`,w.NONE);if(t=t.valueToCode(e,`DELIM`,w.NONE)||`''`,e=e.getFieldValue(`MODE`),e===`SPLIT`)n||=`''`,e=`explode`;else if(e===`JOIN`)n||=`array()`,e=`implode`;else throw Error(`Unknown mode: `+e);return[e+`(`+t+`, `+n+`)`,w.FUNCTION_CALL]},p=function(e,t){return[`array_reverse(`+(t.valueToCode(e,`LIST`,w.NONE)||`[]`)+`)`,w.FUNCTION_CALL]},m=function(e,t){let n=0,r=``,i,a;t.STATEMENT_PREFIX&&(r+=t.injectId(t.STATEMENT_PREFIX,e));do a=t.valueToCode(e,`IF`+n,w.NONE)||`false`,i=t.statementToCode(e,`DO`+n),t.STATEMENT_SUFFIX&&(i=t.prefixLines(t.injectId(t.STATEMENT_SUFFIX,e),t.INDENT)+i),r+=(n>0?` else `:``)+`if (`+a+`) {
|
|
1765
|
-
`+i+`}`,n++;while(e.getInput(`IF`+n));return(e.getInput(`ELSE`)||t.STATEMENT_SUFFIX)&&(i=e.getInput(`ELSE`)?t.statementToCode(e,`ELSE`):``,t.STATEMENT_SUFFIX&&(i=t.prefixLines(t.injectId(t.STATEMENT_SUFFIX,e),t.INDENT)+i),r+=` else {
|
|
1766
|
-
`+i+`}`),r+`
|
|
1767
|
-
`},h=function(e,t){let n={EQ:`==`,NEQ:`!=`,LT:`<`,LTE:`<=`,GT:`>`,GTE:`>=`}[e.getFieldValue(`OP`)],r=n===`==`||n===`!=`?w.EQUALITY:w.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===`&&`?w.LOGICAL_AND:w.LOGICAL_OR,i=t.valueToCode(e,`A`,r);return e=t.valueToCode(e,`B`,r),i||e?(t=n===`&&`?`true`:`false`,i||=t,e||=t):e=i=`false`,[i+` `+n+` `+e,r]},_=function(e,t){let n=w.LOGICAL_NOT;return[`!`+(t.valueToCode(e,`BOOL`,n)||`true`),n]},v=function(e,t){return[e.getFieldValue(`BOOL`)===`TRUE`?`true`:`false`,w.ATOMIC]},y=function(e,t){return[`null`,w.ATOMIC]},ee=function(e,t){let n=t.valueToCode(e,`IF`,w.CONDITIONAL)||`false`,r=t.valueToCode(e,`THEN`,w.CONDITIONAL)||`null`;return e=t.valueToCode(e,`ELSE`,w.CONDITIONAL)||`null`,[n+` ? `+r+` : `+e,w.CONDITIONAL]},b=function(e,n){let r;r=e.getField(`TIMES`)?String(Number(e.getFieldValue(`TIMES`))):n.valueToCode(e,`TIMES`,w.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+=o+` = `+r+`;
|
|
1768
|
-
`),e+(`for (`+a+` = 0; `+a+` < `+o+`; `+a+`++) {
|
|
1769
|
-
`+i+`}
|
|
1770
|
-
`)},te=function(e,t){let n=e.getFieldValue(`MODE`)===`UNTIL`,r=t.valueToCode(e,`BOOL`,n?w.LOGICAL_NOT:w.NONE)||`false`,i=t.statementToCode(e,`DO`);return i=t.addLoopTrap(i,e),n&&(r=`!`+r),`while (`+r+`) {
|
|
1771
|
-
`+i+`}
|
|
1772
|
-
`},ne=function(e,n){var r=n.getVariableName(e.getFieldValue(`VAR`)),i=n.valueToCode(e,`FROM`,w.ASSIGNMENT)||`0`,a=n.valueToCode(e,`TO`,w.ASSIGNMENT)||`0`;let o=n.valueToCode(e,`BY`,w.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+=`) {
|
|
1773
|
-
`+s+`}
|
|
1774
|
-
`;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+=c+` = `+i+`;
|
|
1775
|
-
`),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+=i+` = `+a+`;
|
|
1776
|
-
`),a=n.nameDB_.getDistinctName(r+`_inc`,t.NameType$$module$build$src$core$names.VARIABLE),e+=a+` = `,e=t.isNumber$$module$build$src$core$utils$string(o)?e+(Math.abs(Number(o))+`;
|
|
1777
|
-
`):e+(`abs(`+o+`);
|
|
1778
|
-
`),e+=`if (`+c+` > `+i+`) {
|
|
1779
|
-
`,e+=n.INDENT+a+` = -`+a+`;
|
|
1780
|
-
`,e=e+`}
|
|
1781
|
-
for (`+(r+` = `+c+`; `+a+` >= 0 ? `+r+` <= `+i+` : `+r+` >= `+i+`; `+r+` += `+a+`) {
|
|
1782
|
-
`+s+`}
|
|
1783
|
-
`)}return e},re=function(e,t){let n=t.getVariableName(e.getFieldValue(`VAR`)),r=t.valueToCode(e,`LIST`,w.ASSIGNMENT)||`[]`,i=t.statementToCode(e,`DO`);return i=t.addLoopTrap(i,e),`foreach (`+r+` as `+n+`) {
|
|
1784
|
-
`+i+`}
|
|
1785
|
-
`},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;
|
|
1786
|
-
`;case`CONTINUE`:return n+`continue;
|
|
1787
|
-
`}throw Error(`Unknown flow statement.`)},ae=function(e,t){return e=Number(e.getFieldValue(`NUM`)),e===1/0?[`INF`,w.ATOMIC]:e===-1/0?[`-INF`,w.UNARY_NEGATION]:[String(e),e>=0?w.ATOMIC:w.UNARY_NEGATION]},oe=function(e,t){var n={ADD:[` + `,w.ADDITION],MINUS:[` - `,w.SUBTRACTION],MULTIPLY:[` * `,w.MULTIPLICATION],DIVIDE:[` / `,w.DIVISION],POWER:[` ** `,w.POWER]}[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`,[i+r+e,n]},se=function(e,t){let n=e.getFieldValue(`OP`),r;if(n===`NEG`)return e=t.valueToCode(e,`NUM`,w.UNARY_NEGATION)||`0`,e[0]===`-`&&(e=` `+e),[`-`+e,w.UNARY_NEGATION];switch(e=n===`SIN`||n===`COS`||n===`TAN`?t.valueToCode(e,`NUM`,w.DIVISION)||`0`:t.valueToCode(e,`NUM`,w.NONE)||`0`,n){case`ABS`:r=`abs(`+e+`)`;break;case`ROOT`:r=`sqrt(`+e+`)`;break;case`LN`:r=`log(`+e+`)`;break;case`EXP`:r=`exp(`+e+`)`;break;case`POW10`:r=`pow(10,`+e+`)`;break;case`ROUND`:r=`round(`+e+`)`;break;case`ROUNDUP`:r=`ceil(`+e+`)`;break;case`ROUNDDOWN`:r=`floor(`+e+`)`;break;case`SIN`:r=`sin(`+e+` / 180 * pi())`;break;case`COS`:r=`cos(`+e+` / 180 * pi())`;break;case`TAN`:r=`tan(`+e+` / 180 * pi())`}if(r)return[r,w.FUNCTION_CALL];switch(n){case`LOG10`:r=`log(`+e+`) / log(10)`;break;case`ASIN`:r=`asin(`+e+`) / pi() * 180`;break;case`ACOS`:r=`acos(`+e+`) / pi() * 180`;break;case`ATAN`:r=`atan(`+e+`) / pi() * 180`;break;default:throw Error(`Unknown math operator: `+n)}return[r,w.DIVISION]},ce=function(e,t){return{PI:[`M_PI`,w.ATOMIC],E:[`M_E`,w.ATOMIC],GOLDEN_RATIO:[`(1 + sqrt(5)) / 2`,w.DIVISION],SQRT2:[`M_SQRT2`,w.ATOMIC],SQRT1_2:[`M_SQRT1_2`,w.ATOMIC],INFINITY:[`INF`,w.ATOMIC]}[e.getFieldValue(`CONSTANT`)]},x=function(e,t){var n={EVEN:[``,` % 2 == 0`,w.MODULUS,w.EQUALITY],ODD:[``,` % 2 == 1`,w.MODULUS,w.EQUALITY],WHOLE:[`is_int(`,`)`,w.NONE,w.FUNCTION_CALL],POSITIVE:[``,` > 0`,w.RELATIONAL,w.RELATIONAL],NEGATIVE:[``,` < 0`,w.RELATIONAL,w.RELATIONAL],DIVISIBLE_BY:[null,null,w.MODULUS,w.EQUALITY],PRIME:[null,null,w.NONE,w.FUNCTION_CALL]};let r=e.getFieldValue(`PROPERTY`),[i,a,o,s]=n[r];if(n=t.valueToCode(e,`NUMBER_TO_CHECK`,o)||`0`,r===`PRIME`)e=t.provideFunction_(`math_isPrime`,`
|
|
1788
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($n) {
|
|
1789
|
-
// https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
|
1790
|
-
if ($n == 2 || $n == 3) {
|
|
1791
|
-
return true;
|
|
1792
|
-
}
|
|
1793
|
-
// False if n is NaN, negative, is 1, or not whole.
|
|
1794
|
-
// And false if n is divisible by 2 or 3.
|
|
1795
|
-
if (!is_numeric($n) || $n <= 1 || $n % 1 != 0 || $n % 2 == 0 || $n % 3 == 0) {
|
|
1796
|
-
return false;
|
|
1797
|
-
}
|
|
1798
|
-
// Check all the numbers of form 6k +/- 1, up to sqrt(n).
|
|
1799
|
-
for ($x = 6; $x <= sqrt($n) + 1; $x += 6) {
|
|
1800
|
-
if ($n % ($x - 1) == 0 || $n % ($x + 1) == 0) {
|
|
1801
|
-
return false;
|
|
1802
|
-
}
|
|
1803
|
-
}
|
|
1804
|
-
return true;
|
|
1805
|
-
}
|
|
1806
|
-
`)+`(`+n+`)`;else if(r===`DIVISIBLE_BY`){if(e=t.valueToCode(e,`DIVISOR`,w.MODULUS)||`0`,e===`0`)return[`false`,w.ATOMIC];e=n+` % `+e+` == 0`}else e=i+n+a;return[e,s]},le=function(e,t){let n=t.valueToCode(e,`DELTA`,w.ADDITION)||`0`;return t.getVariableName(e.getFieldValue(`VAR`))+` += `+n+`;
|
|
1807
|
-
`},ue=function(e,t){var n=e.getFieldValue(`OP`);switch(n){case`SUM`:e=t.valueToCode(e,`LIST`,w.FUNCTION_CALL)||`array()`,e=`array_sum(`+e+`)`;break;case`MIN`:e=t.valueToCode(e,`LIST`,w.FUNCTION_CALL)||`array()`,e=`min(`+e+`)`;break;case`MAX`:e=t.valueToCode(e,`LIST`,w.FUNCTION_CALL)||`array()`,e=`max(`+e+`)`;break;case`AVERAGE`:n=t.provideFunction_(`math_mean`,`
|
|
1808
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($myList) {
|
|
1809
|
-
return array_sum($myList) / count($myList);
|
|
1810
|
-
}
|
|
1811
|
-
`),e=t.valueToCode(e,`LIST`,w.NONE)||`array()`,e=n+`(`+e+`)`;break;case`MEDIAN`:n=t.provideFunction_(`math_median`,`
|
|
1812
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($arr) {
|
|
1813
|
-
sort($arr,SORT_NUMERIC);
|
|
1814
|
-
return (count($arr) % 2) ? $arr[floor(count($arr) / 2)] :
|
|
1815
|
-
($arr[floor(count($arr) / 2)] + $arr[floor(count($arr) / 2) - 1]) / 2;
|
|
1816
|
-
}
|
|
1817
|
-
`),e=t.valueToCode(e,`LIST`,w.NONE)||`[]`,e=n+`(`+e+`)`;break;case`MODE`:n=t.provideFunction_(`math_modes`,`
|
|
1818
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($values) {
|
|
1819
|
-
if (empty($values)) return array();
|
|
1820
|
-
$counts = array_count_values($values);
|
|
1821
|
-
arsort($counts); // Sort counts in descending order
|
|
1822
|
-
$modes = array_keys($counts, current($counts), true);
|
|
1823
|
-
return $modes;
|
|
1824
|
-
}
|
|
1825
|
-
`),e=t.valueToCode(e,`LIST`,w.NONE)||`[]`,e=n+`(`+e+`)`;break;case`STD_DEV`:n=t.provideFunction_(`math_standard_deviation`,`
|
|
1826
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($numbers) {
|
|
1827
|
-
$n = count($numbers);
|
|
1828
|
-
if (!$n) return null;
|
|
1829
|
-
$mean = array_sum($numbers) / count($numbers);
|
|
1830
|
-
foreach($numbers as $key => $num) $devs[$key] = pow($num - $mean, 2);
|
|
1831
|
-
return sqrt(array_sum($devs) / (count($devs) - 1));
|
|
1832
|
-
}
|
|
1833
|
-
`),e=t.valueToCode(e,`LIST`,w.NONE)||`[]`,e=n+`(`+e+`)`;break;case`RANDOM`:n=t.provideFunction_(`math_random_list`,`
|
|
1834
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($list) {
|
|
1835
|
-
$x = rand(0, count($list)-1);
|
|
1836
|
-
return $list[$x];
|
|
1837
|
-
}
|
|
1838
|
-
`),e=t.valueToCode(e,`LIST`,w.NONE)||`[]`,e=n+`(`+e+`)`;break;default:throw Error(`Unknown operator: `+n)}return[e,w.FUNCTION_CALL]},de=function(e,t){let n=t.valueToCode(e,`DIVIDEND`,w.MODULUS)||`0`;return e=t.valueToCode(e,`DIVISOR`,w.MODULUS)||`0`,[n+` % `+e,w.MODULUS]},S=function(e,t){let n=t.valueToCode(e,`VALUE`,w.NONE)||`0`,r=t.valueToCode(e,`LOW`,w.NONE)||`0`;return e=t.valueToCode(e,`HIGH`,w.NONE)||`Infinity`,[`min(max(`+n+`, `+r+`), `+e+`)`,w.FUNCTION_CALL]},fe=function(e,t){let n=t.valueToCode(e,`FROM`,w.NONE)||`0`;return e=t.valueToCode(e,`TO`,w.NONE)||`0`,[t.provideFunction_(`math_random_int`,`
|
|
1839
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($a, $b) {
|
|
1840
|
-
if ($a > $b) {
|
|
1841
|
-
return rand($b, $a);
|
|
1842
|
-
}
|
|
1843
|
-
return rand($a, $b);
|
|
1844
|
-
}
|
|
1845
|
-
`)+`(`+n+`, `+e+`)`,w.FUNCTION_CALL]},pe=function(e,t){return[`(float)rand()/(float)getrandmax()`,w.FUNCTION_CALL]},me=function(e,t){let n=t.valueToCode(e,`X`,w.NONE)||`0`;return[`atan2(`+(t.valueToCode(e,`Y`,w.NONE)||`0`)+`, `+n+`) / pi() * 180`,w.DIVISION]},he=function(e,n){var r=[],i=e.workspace,a=t.allUsedVarModels$$module$build$src$core$variables(i)||[];for(var o of a)a=o.getName(),e.getVars().includes(a)||r.push(n.getVariableName(a));for(i=t.allDeveloperVariables$$module$build$src$core$variables(i),o=0;o<i.length;o++)r.push(n.nameDB_.getName(i[o],t.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));i=r.length?n.INDENT+`global `+r.join(`, `)+`;
|
|
1846
|
-
`:``,r=n.getProcedureName(e.getFieldValue(`NAME`)),o=``,n.STATEMENT_PREFIX&&(o+=n.injectId(n.STATEMENT_PREFIX,e)),n.STATEMENT_SUFFIX&&(o+=n.injectId(n.STATEMENT_SUFFIX,e)),o&&=n.prefixLines(o,n.INDENT),a=``,n.INFINITE_LOOP_TRAP&&(a=n.prefixLines(n.injectId(n.INFINITE_LOOP_TRAP,e),n.INDENT));let s=``;e.getInput(`STACK`)&&(s=n.statementToCode(e,`STACK`));let c=``;e.getInput(`RETURN`)&&(c=n.valueToCode(e,`RETURN`,w.NONE)||``);let l=``;s&&c&&(l=o),c&&=n.INDENT+`return `+c+`;
|
|
1847
|
-
`;let u=[],d=e.getVars();for(let e=0;e<d.length;e++)u[e]=n.getVariableName(d[e]);return i=`function `+r+`(`+u.join(`, `)+`) {
|
|
1848
|
-
`+i+o+a+s+l+c+`}`,i=n.scrub_(e,i),n.definitions_[`%`+r]=i,null},ge=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,w.NONE)||`null`;return[n+`(`+r.join(`, `)+`)`,w.FUNCTION_CALL]},_e=function(e,t){return t.forBlock.procedures_callreturn(e,t)[0]+`;
|
|
1849
|
-
`},ve=function(e,t){let n=`if (`+(t.valueToCode(e,`CONDITION`,w.NONE)||`false`)+`) {
|
|
1850
|
-
`;return t.STATEMENT_SUFFIX&&(n+=t.prefixLines(t.injectId(t.STATEMENT_SUFFIX,e),t.INDENT)),e.hasReturnValue_?(e=t.valueToCode(e,`VALUE`,w.NONE)||`null`,n+=t.INDENT+`return `+e+`;
|
|
1851
|
-
`):n+=t.INDENT+`return;
|
|
1852
|
-
`,n+`}
|
|
1853
|
-
`},ye=function(e,t){return[t.quote_(e.getFieldValue(`TEXT`)),w.ATOMIC]},be=function(e,t){if(e.itemCount_===0)return[`''`,w.ATOMIC];if(e.itemCount_===1)return[t.valueToCode(e,`ADD0`,w.NONE)||`''`,w.NONE];if(e.itemCount_===2){var n=t.valueToCode(e,`ADD0`,w.STRING_CONCAT)||`''`;return e=t.valueToCode(e,`ADD1`,w.STRING_CONCAT)||`''`,[n+` . `+e,w.STRING_CONCAT]}n=Array(e.itemCount_);for(let r=0;r<e.itemCount_;r++)n[r]=t.valueToCode(e,`ADD`+r,w.NONE)||`''`;return[`implode('', array(`+n.join(`,`)+`))`,w.FUNCTION_CALL]},xe=function(e,t){let n=t.getVariableName(e.getFieldValue(`VAR`));return e=t.valueToCode(e,`TEXT`,w.ASSIGNMENT)||`''`,n+` .= `+e+`;
|
|
1854
|
-
`},Se=function(e,t){let n=t.provideFunction_(`length`,`
|
|
1855
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($value) {
|
|
1856
|
-
if (is_string($value)) {
|
|
1857
|
-
return strlen($value);
|
|
1858
|
-
}
|
|
1859
|
-
return count($value);
|
|
1860
|
-
}
|
|
1861
|
-
`);return e=t.valueToCode(e,`VALUE`,w.NONE)||`''`,[n+`(`+e+`)`,w.FUNCTION_CALL]},Ce=function(e,t){return[`empty(`+(t.valueToCode(e,`VALUE`,w.NONE)||`''`)+`)`,w.FUNCTION_CALL]},we=function(e,t){let n=e.getFieldValue(`END`)===`FIRST`?`strpos`:`strrpos`,r=t.valueToCode(e,`FIND`,w.NONE)||`''`,i=t.valueToCode(e,`VALUE`,w.NONE)||`''`,a=` -1`,o=``;return e.workspace.options.oneBasedIndex&&(a=` 0`,o=` + 1`),[t.provideFunction_(e.getFieldValue(`END`)===`FIRST`?`text_indexOf`:`text_lastIndexOf`,`
|
|
1862
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($text, $search) {
|
|
1863
|
-
$pos = ${n}($text, $search);
|
|
1864
|
-
return $pos === false ? ${a} : $pos${o};
|
|
1865
|
-
}
|
|
1866
|
-
`)+`(`+i+`, `+r+`)`,w.FUNCTION_CALL]},Te=function(e,t){let n=e.getFieldValue(`WHERE`)||`FROM_START`,r=t.valueToCode(e,`VALUE`,w.NONE)||`''`;switch(n){case`FIRST`:return[`substr(`+r+`, 0, 1)`,w.FUNCTION_CALL];case`LAST`:return[`substr(`+r+`, -1)`,w.FUNCTION_CALL];case`FROM_START`:return e=t.getAdjusted(e,`AT`),[`substr(`+r+`, `+e+`, 1)`,w.FUNCTION_CALL];case`FROM_END`:return e=t.getAdjusted(e,`AT`,1,!0),[`substr(`+r+`, `+e+`, 1)`,w.FUNCTION_CALL];case`RANDOM`:return[t.provideFunction_(`text_random_letter`,`
|
|
1867
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($text) {
|
|
1868
|
-
return $text[rand(0, strlen($text) - 1)];
|
|
1869
|
-
}
|
|
1870
|
-
`)+`(`+r+`)`,w.FUNCTION_CALL]}throw Error(`Unhandled option (text_charAt).`)},Ee=function(e,t){let n=e.getFieldValue(`WHERE1`),r=e.getFieldValue(`WHERE2`),i=t.valueToCode(e,`STRING`,w.NONE)||`''`;if(n===`FIRST`&&r===`LAST`)return[i,w.NONE];let a=t.getAdjusted(e,`AT1`);return e=t.getAdjusted(e,`AT2`),[t.provideFunction_(`text_get_substring`,`
|
|
1871
|
-
function ${t.FUNCTION_NAME_PLACEHOLDER_}($text, $where1, $at1, $where2, $at2) {
|
|
1872
|
-
if ($where1 == 'FROM_END') {
|
|
1873
|
-
$at1 = strlen($text) - 1 - $at1;
|
|
1874
|
-
} else if ($where1 == 'FIRST') {
|
|
1875
|
-
$at1 = 0;
|
|
1876
|
-
} else if ($where1 != 'FROM_START') {
|
|
1877
|
-
throw new Exception('Unhandled option (text_get_substring).');
|
|
1878
|
-
}
|
|
1879
|
-
$length = 0;
|
|
1880
|
-
if ($where2 == 'FROM_START') {
|
|
1881
|
-
$length = $at2 - $at1 + 1;
|
|
1882
|
-
} else if ($where2 == 'FROM_END') {
|
|
1883
|
-
$length = strlen($text) - $at1 - $at2;
|
|
1884
|
-
} else if ($where2 == 'LAST') {
|
|
1885
|
-
$length = strlen($text) - $at1;
|
|
1886
|
-
} else {
|
|
1887
|
-
throw new Exception('Unhandled option (text_get_substring).');
|
|
1888
|
-
}
|
|
1889
|
-
return substr($text, $at1, $length);
|
|
1890
|
-
}
|
|
1891
|
-
`)+`(`+i+`, '`+n+`', `+a+`, '`+r+`', `+e+`)`,w.FUNCTION_CALL]},C=function(e,t){t=t.valueToCode(e,`TEXT`,w.NONE)||`''`;let n;return e.getFieldValue(`CASE`)===`UPPERCASE`?n=`strtoupper(`+t+`)`:e.getFieldValue(`CASE`)===`LOWERCASE`?n=`strtolower(`+t+`)`:e.getFieldValue(`CASE`)===`TITLECASE`&&(n=`ucwords(strtolower(`+t+`))`),[n,w.FUNCTION_CALL]},De=function(e,t){let n={LEFT:`ltrim`,RIGHT:`rtrim`,BOTH:`trim`}[e.getFieldValue(`MODE`)];return e=t.valueToCode(e,`TEXT`,w.NONE)||`''`,[n+`(`+e+`)`,w.FUNCTION_CALL]},Oe=function(e,t){return`print(`+(t.valueToCode(e,`TEXT`,w.NONE)||`''`)+`);
|
|
1892
|
-
`},ke=function(e,t){return t=`readline(`+(e.getField(`TEXT`)?t.quote_(e.getFieldValue(`TEXT`)):t.valueToCode(e,`TEXT`,w.NONE)||`''`)+`)`,e.getFieldValue(`TYPE`)===`NUMBER`&&(t=`floatval(`+t+`)`),[t,w.FUNCTION_CALL]},Ae=function(e,t){let n=t.valueToCode(e,`TEXT`,w.NONE)||`''`;return e=t.valueToCode(e,`SUB`,w.NONE)||`''`,[`strlen(`+e+`) === 0 ? strlen(`+n+`) + 1 : substr_count(`+n+`, `+e+`)`,w.CONDITIONAL]},je=function(e,t){let n=t.valueToCode(e,`TEXT`,w.NONE)||`''`,r=t.valueToCode(e,`FROM`,w.NONE)||`''`;return e=t.valueToCode(e,`TO`,w.NONE)||`''`,[`str_replace(`+r+`, `+e+`, `+n+`)`,w.FUNCTION_CALL]},Me=function(e,t){return[`strrev(`+(t.valueToCode(e,`TEXT`,w.NONE)||`''`)+`)`,w.FUNCTION_CALL]},Ne=function(e,t){return[t.getVariableName(e.getFieldValue(`VAR`)),w.ATOMIC]},Pe=function(e,t){let n=t.valueToCode(e,`VALUE`,w.ASSIGNMENT)||`0`;return t.getVariableName(e.getFieldValue(`VAR`))+` = `+n+`;
|
|
1893
|
-
`},w;(function(e){e[e.ATOMIC=0]=`ATOMIC`,e[e.CLONE=1]=`CLONE`,e[e.NEW=1]=`NEW`,e[e.MEMBER=2.1]=`MEMBER`,e[e.FUNCTION_CALL=2.2]=`FUNCTION_CALL`,e[e.POWER=3]=`POWER`,e[e.INCREMENT=4]=`INCREMENT`,e[e.DECREMENT=4]=`DECREMENT`,e[e.BITWISE_NOT=4]=`BITWISE_NOT`,e[e.CAST=4]=`CAST`,e[e.SUPPRESS_ERROR=4]=`SUPPRESS_ERROR`,e[e.INSTANCEOF=5]=`INSTANCEOF`,e[e.LOGICAL_NOT=6]=`LOGICAL_NOT`,e[e.UNARY_PLUS=7.1]=`UNARY_PLUS`,e[e.UNARY_NEGATION=7.2]=`UNARY_NEGATION`,e[e.MULTIPLICATION=8.1]=`MULTIPLICATION`,e[e.DIVISION=8.2]=`DIVISION`,e[e.MODULUS=8.3]=`MODULUS`,e[e.ADDITION=9.1]=`ADDITION`,e[e.SUBTRACTION=9.2]=`SUBTRACTION`,e[e.STRING_CONCAT=9.3]=`STRING_CONCAT`,e[e.BITWISE_SHIFT=10]=`BITWISE_SHIFT`,e[e.RELATIONAL=11]=`RELATIONAL`,e[e.EQUALITY=12]=`EQUALITY`,e[e.REFERENCE=13]=`REFERENCE`,e[e.BITWISE_AND=13]=`BITWISE_AND`,e[e.BITWISE_XOR=14]=`BITWISE_XOR`,e[e.BITWISE_OR=15]=`BITWISE_OR`,e[e.LOGICAL_AND=16]=`LOGICAL_AND`,e[e.LOGICAL_OR=17]=`LOGICAL_OR`,e[e.IF_NULL=18]=`IF_NULL`,e[e.CONDITIONAL=19]=`CONDITIONAL`,e[e.ASSIGNMENT=20]=`ASSIGNMENT`,e[e.LOGICAL_AND_WEAK=21]=`LOGICAL_AND_WEAK`,e[e.LOGICAL_XOR=22]=`LOGICAL_XOR`,e[e.LOGICAL_OR_WEAK=23]=`LOGICAL_OR_WEAK`,e[e.NONE=99]=`NONE`})(w||={});var T=class extends t.CodeGenerator$$module$build$src$core$generator{constructor(e=`PHP`){super(e),this.ORDER_OVERRIDES=[[w.MEMBER,w.FUNCTION_CALL],[w.MEMBER,w.MEMBER],[w.LOGICAL_NOT,w.LOGICAL_NOT],[w.MULTIPLICATION,w.MULTIPLICATION],[w.ADDITION,w.ADDITION],[w.LOGICAL_AND,w.LOGICAL_AND],[w.LOGICAL_OR,w.LOGICAL_OR]],this.isInitialized=!1;for(let t in w)e=w[t],typeof e!=`string`&&(this[`ORDER_`+t]=e);this.addReservedWords(`__halt_compiler,abstract,and,array,as,break,callable,case,catch,class,clone,const,continue,declare,default,die,do,echo,else,elseif,empty,enddeclare,endfor,endforeach,endif,endswitch,endwhile,eval,exit,extends,final,for,foreach,function,global,goto,if,implements,include,include_once,instanceof,insteadof,interface,isset,list,namespace,new,or,print,private,protected,public,require,require_once,return,static,switch,throw,trait,try,unset,use,var,while,xor,PHP_VERSION,PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION,PHP_VERSION_ID,PHP_EXTRA_VERSION,PHP_ZTS,PHP_DEBUG,PHP_MAXPATHLEN,PHP_OS,PHP_SAPI,PHP_EOL,PHP_INT_MAX,PHP_INT_SIZE,DEFAULT_INCLUDE_PATH,PEAR_INSTALL_DIR,PEAR_EXTENSION_DIR,PHP_EXTENSION_DIR,PHP_PREFIX,PHP_BINDIR,PHP_BINARY,PHP_MANDIR,PHP_LIBDIR,PHP_DATADIR,PHP_SYSCONFDIR,PHP_LOCALSTATEDIR,PHP_CONFIG_FILE_PATH,PHP_CONFIG_FILE_SCAN_DIR,PHP_SHLIB_SUFFIX,E_ERROR,E_WARNING,E_PARSE,E_NOTICE,E_CORE_ERROR,E_CORE_WARNING,E_COMPILE_ERROR,E_COMPILE_WARNING,E_USER_ERROR,E_USER_WARNING,E_USER_NOTICE,E_DEPRECATED,E_USER_DEPRECATED,E_ALL,E_STRICT,__COMPILER_HALT_OFFSET__,TRUE,FALSE,NULL,__CLASS__,__DIR__,__FILE__,__FUNCTION__,__LINE__,__METHOD__,__NAMESPACE__,__TRAIT__`)}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),this.isInitialized=!0}finish(e){let t=Object.values(this.definitions_);return e=super.finish(e),this.isInitialized=!1,this.nameDB_.reset(),t.join(`
|
|
1894
|
-
|
|
1895
|
-
`)+`
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
`+e}scrubNakedValue(e){return e+`;
|
|
1899
|
-
`}quote_(e){return e=e.replace(/\\/g,`\\\\`).replace(/\n/g,`\\
|
|
1900
|
-
`).replace(/'/g,`\\'`),`'`+e+`'`}multiline_quote_(e){return e.split(/\n/g).map(this.quote_).join(` . "\\n" .
|
|
1901
|
-
`)}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,`// `)+`
|
|
1902
|
-
`);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=w.NONE){e.workspace.options.oneBasedIndex&&r--;let o=e.workspace.options.oneBasedIndex?`1`:`0`,s=a;return r>0?s=w.ADDITION:r<0?s=w.SUBTRACTION:i&&(s=w.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)}},Fe={};Fe.Order=w,Fe.PhpGenerator=T;var E={};E.lists_create_empty=n,E.lists_create_with=r,E.lists_getIndex=c,E.lists_getSublist=u,E.lists_indexOf=s,E.lists_isEmpty=o,E.lists_length=a,E.lists_repeat=i,E.lists_reverse=p,E.lists_setIndex=l,E.lists_sort=d,E.lists_split=f;var D={};D.controls_if=m,D.controls_ifelse=m,D.logic_boolean=v,D.logic_compare=h,D.logic_negate=_,D.logic_null=y,D.logic_operation=g,D.logic_ternary=ee;var O={};O.controls_flow_statements=ie,O.controls_for=ne,O.controls_forEach=re,O.controls_repeat=b,O.controls_repeat_ext=b,O.controls_whileUntil=te;var k={};k.math_arithmetic=oe,k.math_atan2=me,k.math_change=le,k.math_constant=ce,k.math_constrain=S,k.math_modulo=de,k.math_number=ae,k.math_number_property=x,k.math_on_list=ue,k.math_random_float=pe,k.math_random_int=fe,k.math_round=se,k.math_single=se,k.math_trig=se;var A={};A.procedures_callnoreturn=_e,A.procedures_callreturn=ge,A.procedures_defnoreturn=he,A.procedures_defreturn=he,A.procedures_ifreturn=ve;var j={};j.text=ye,j.text_append=xe,j.text_changeCase=C,j.text_charAt=Te,j.text_count=Ae,j.text_getSubstring=Ee,j.text_indexOf=we,j.text_isEmpty=Ce,j.text_join=be,j.text_length=Se,j.text_print=Oe,j.text_prompt=ke,j.text_prompt_ext=ke,j.text_replace=je,j.text_reverse=Me,j.text_trim=De;var Ie={};Ie.variables_get=Ne,Ie.variables_set=Pe;var M={};M.variables_get_dynamic=Ne,M.variables_set_dynamic=Pe;var Le=new T,Re=Object.assign({},E,D,O,k,A,j,Ie,M);for(let e in Re)Le.forBlock[e]=Re[e];var ze={};return ze.Order=w,ze.PhpGenerator=T,ze.phpGenerator=Le,ze.__namespace__=t,ze})})),Rl=t(((e,t)=>{(function(n,r){typeof define==`function`&&define.amd?define([`./blockly_compressed.js`],r):typeof e==`object`?t.exports=r(y()):(n.python=r(n.Blockly),n.Blockly.Python=n.python.pythonGenerator)})(e,function(e){var t=e.__namespace__,n=function(e,t){return[`[]`,w.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,w.NONE)||`None`;return[`[`+n.join(`, `)+`]`,w.ATOMIC]},i=function(e,t){let n=t.valueToCode(e,`ITEM`,w.NONE)||`None`;return e=t.valueToCode(e,`NUM`,w.MULTIPLICATIVE)||`0`,[`[`+n+`] * `+e,w.MULTIPLICATIVE]},a=function(e,t){return[`len(`+(t.valueToCode(e,`VALUE`,w.NONE)||`[]`)+`)`,w.FUNCTION_CALL]},o=function(e,t){return[`not len(`+(t.valueToCode(e,`VALUE`,w.NONE)||`[]`)+`)`,w.LOGICAL_NOT]},s=function(e,t){let n=t.valueToCode(e,`FIND`,w.NONE)||`[]`,r=t.valueToCode(e,`VALUE`,w.NONE)||`''`,i=` -1`,a=``,o=` - 1`;return e.workspace.options.oneBasedIndex&&(i=` 0`,a=` + 1`,o=``),[(e.getFieldValue(`END`)===`FIRST`?t.provideFunction_(`first_index`,`
|
|
1903
|
-
def ${t.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
|
|
1904
|
-
try: index = my_list.index(elem)${a}
|
|
1905
|
-
except: index =${i}
|
|
1906
|
-
return index
|
|
1907
|
-
`):t.provideFunction_(`last_index`,`
|
|
1908
|
-
def ${t.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
|
|
1909
|
-
try: index = len(my_list) - my_list[::-1].index(elem)${o}
|
|
1910
|
-
except: index =${i}
|
|
1911
|
-
return index
|
|
1912
|
-
`))+`(`+r+`, `+n+`)`,w.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`?w.NONE:w.MEMBER)||`[]`;switch(r){case`FIRST`:if(n===`GET`)return[i+`[0]`,w.MEMBER];if(n===`GET_REMOVE`)return[i+`.pop(0)`,w.FUNCTION_CALL];if(n===`REMOVE`)return i+`.pop(0)
|
|
1913
|
-
`;break;case`LAST`:if(n===`GET`)return[i+`[-1]`,w.MEMBER];if(n===`GET_REMOVE`)return[i+`.pop()`,w.FUNCTION_CALL];if(n===`REMOVE`)return i+`.pop()
|
|
1914
|
-
`;break;case`FROM_START`:if(e=t.getAdjustedInt(e,`AT`),n===`GET`)return[i+`[`+e+`]`,w.MEMBER];if(n===`GET_REMOVE`)return[i+`.pop(`+e+`)`,w.FUNCTION_CALL];if(n===`REMOVE`)return i+`.pop(`+e+`)
|
|
1915
|
-
`;break;case`FROM_END`:if(e=t.getAdjustedInt(e,`AT`,1,!0),n===`GET`)return[i+`[`+e+`]`,w.MEMBER];if(n===`GET_REMOVE`)return[i+`.pop(`+e+`)`,w.FUNCTION_CALL];if(n===`REMOVE`)return i+`.pop(`+e+`)
|
|
1916
|
-
`;break;case`RANDOM`:if(t.definitions_.import_random=`import random`,n===`GET`)return[`random.choice(`+i+`)`,w.FUNCTION_CALL];if(i=t.provideFunction_(`lists_remove_random_item`,`
|
|
1917
|
-
def ${t.FUNCTION_NAME_PLACEHOLDER_}(myList):
|
|
1918
|
-
x = int(random.random() * len(myList))
|
|
1919
|
-
return myList.pop(x)
|
|
1920
|
-
`)+`(`+i+`)`,n===`GET_REMOVE`)return[i,w.FUNCTION_CALL];if(n===`REMOVE`)return i+`
|
|
1921
|
-
`}throw Error(`Unhandled combination (lists_getIndex).`)},l=function(e,n){let r=n.valueToCode(e,`LIST`,w.MEMBER)||`[]`,i=e.getFieldValue(`MODE`)||`GET`;var a=e.getFieldValue(`WHERE`)||`FROM_START`;let o=n.valueToCode(e,`TO`,w.NONE)||`None`;switch(a){case`FIRST`:if(i===`SET`)return r+`[0] = `+o+`
|
|
1922
|
-
`;if(i===`INSERT`)return r+`.insert(0, `+o+`)
|
|
1923
|
-
`;break;case`LAST`:if(i===`SET`)return r+`[-1] = `+o+`
|
|
1924
|
-
`;if(i===`INSERT`)return r+`.append(`+o+`)
|
|
1925
|
-
`;break;case`FROM_START`:if(n=n.getAdjustedInt(e,`AT`),i===`SET`)return r+`[`+n+`] = `+o+`
|
|
1926
|
-
`;if(i===`INSERT`)return r+`.insert(`+n+`, `+o+`)
|
|
1927
|
-
`;break;case`FROM_END`:if(n=n.getAdjustedInt(e,`AT`,1,!0),i===`SET`)return r+`[`+n+`] = `+o+`
|
|
1928
|
-
`;if(i===`INSERT`)return r+`.insert(`+n+`, `+o+`)
|
|
1929
|
-
`;break;case`RANDOM`:if(n.definitions_.import_random=`import random`,r.match(/^\w+$/)?e=``:(e=n.nameDB_.getDistinctName(`tmp_list`,t.NameType$$module$build$src$core$names.VARIABLE),a=e+` = `+r+`
|
|
1930
|
-
`,r=e,e=a),n=n.nameDB_.getDistinctName(`tmp_x`,t.NameType$$module$build$src$core$names.VARIABLE),e+=n+` = int(random.random() * len(`+r+`))
|
|
1931
|
-
`,i===`SET`)return e+(r+`[`+n+`] = `+o+`
|
|
1932
|
-
`);if(i===`INSERT`)return e+(r+`.insert(`+n+`, `+o+`)
|
|
1933
|
-
`)}throw Error(`Unhandled combination (lists_setIndex).`)},u=function(e,n){let r=n.valueToCode(e,`LIST`,w.MEMBER)||`[]`;var i=e.getFieldValue(`WHERE1`);let a=e.getFieldValue(`WHERE2`);switch(i){case`FROM_START`:i=n.getAdjustedInt(e,`AT1`),i===0&&(i=``);break;case`FROM_END`:i=n.getAdjustedInt(e,`AT1`,1,!0);break;case`FIRST`:i=``;break;default:throw Error(`Unhandled option (lists_getSublist)`)}switch(a){case`FROM_START`:e=n.getAdjustedInt(e,`AT2`,1);break;case`FROM_END`:e=n.getAdjustedInt(e,`AT2`,0,!0),t.isNumber$$module$build$src$core$utils$string(String(e))?e===0&&(e=``):(n.definitions_.import_sys=`import sys`,e+=` or sys.maxsize`);break;case`LAST`:e=``;break;default:throw Error(`Unhandled option (lists_getSublist)`)}return[r+`[`+i+` : `+e+`]`,w.MEMBER]},d=function(e,t){let n=t.valueToCode(e,`LIST`,w.NONE)||`[]`,r=e.getFieldValue(`TYPE`);return e=e.getFieldValue(`DIRECTION`)===`1`?`False`:`True`,[t.provideFunction_(`lists_sort`,`
|
|
1934
|
-
def ${t.FUNCTION_NAME_PLACEHOLDER_}(my_list, type, reverse):
|
|
1935
|
-
def try_float(s):
|
|
1936
|
-
try:
|
|
1937
|
-
return float(s)
|
|
1938
|
-
except:
|
|
1939
|
-
return 0
|
|
1940
|
-
key_funcs = {
|
|
1941
|
-
"NUMERIC": try_float,
|
|
1942
|
-
"TEXT": str,
|
|
1943
|
-
"IGNORE_CASE": lambda s: str(s).lower()
|
|
1944
|
-
}
|
|
1945
|
-
key_func = key_funcs[type]
|
|
1946
|
-
list_cpy = list(my_list)
|
|
1947
|
-
return sorted(list_cpy, key=key_func, reverse=reverse)
|
|
1948
|
-
`)+`(`+n+`, "`+r+`", `+e+`)`,w.FUNCTION_CALL]},f=function(e,t){var n=e.getFieldValue(`MODE`);if(n===`SPLIT`)n=t.valueToCode(e,`INPUT`,w.MEMBER)||`''`,e=t.valueToCode(e,`DELIM`,w.NONE),e=n+`.split(`+e+`)`;else if(n===`JOIN`)n=t.valueToCode(e,`INPUT`,w.NONE)||`[]`,e=(t.valueToCode(e,`DELIM`,w.MEMBER)||`''`)+`.join(`+n+`)`;else throw Error(`Unknown mode: `+n);return[e,w.FUNCTION_CALL]},p=function(e,t){return[`list(reversed(`+(t.valueToCode(e,`LIST`,w.NONE)||`[]`)+`))`,w.FUNCTION_CALL]},m=function(e,t){let n=0,r=``,i,a;t.STATEMENT_PREFIX&&(r+=t.injectId(t.STATEMENT_PREFIX,e));do a=t.valueToCode(e,`IF`+n,w.NONE)||`False`,i=t.statementToCode(e,`DO`+n)||t.PASS,t.STATEMENT_SUFFIX&&(i=t.prefixLines(t.injectId(t.STATEMENT_SUFFIX,e),t.INDENT)+i),r+=(n===0?`if `:`elif `)+a+`:
|
|
1949
|
-
`+i,n++;while(e.getInput(`IF`+n));return(e.getInput(`ELSE`)||t.STATEMENT_SUFFIX)&&(i=e.getInput(`ELSE`)&&t.statementToCode(e,`ELSE`)||t.PASS,t.STATEMENT_SUFFIX&&(i=t.prefixLines(t.injectId(t.STATEMENT_SUFFIX,e),t.INDENT)+i),r+=`else:
|
|
1950
|
-
`+i),r},h=function(e,t){let n={EQ:`==`,NEQ:`!=`,LT:`<`,LTE:`<=`,GT:`>`,GTE:`>=`}[e.getFieldValue(`OP`)],r=w.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`?`and`:`or`,r=n===`and`?w.LOGICAL_AND:w.LOGICAL_OR,i=t.valueToCode(e,`A`,r);return e=t.valueToCode(e,`B`,r),i||e?(t=n===`and`?`True`:`False`,i||=t,e||=t):e=i=`False`,[i+` `+n+` `+e,r]},_=function(e,t){return[`not `+(t.valueToCode(e,`BOOL`,w.LOGICAL_NOT)||`True`),w.LOGICAL_NOT]},v=function(e,t){return[e.getFieldValue(`BOOL`)===`TRUE`?`True`:`False`,w.ATOMIC]},y=function(e,t){return[`None`,w.ATOMIC]},ee=function(e,t){let n=t.valueToCode(e,`IF`,w.CONDITIONAL)||`False`,r=t.valueToCode(e,`THEN`,w.CONDITIONAL)||`None`;return e=t.valueToCode(e,`ELSE`,w.CONDITIONAL)||`None`,[r+` if `+n+` else `+e,w.CONDITIONAL]},b=function(e,n){let r;r=e.getField(`TIMES`)?String(parseInt(e.getFieldValue(`TIMES`),10)):n.valueToCode(e,`TIMES`,w.NONE)||`0`,r=t.isNumber$$module$build$src$core$utils$string(r)?parseInt(r,10):`int(`+r+`)`;let i=n.statementToCode(e,`DO`);return i=n.addLoopTrap(i,e)||n.PASS,`for `+n.nameDB_.getDistinctName(`count`,t.NameType$$module$build$src$core$names.VARIABLE)+` in range(`+r+`):
|
|
1951
|
-
`+i},te=function(e,t){let n=e.getFieldValue(`MODE`)===`UNTIL`,r=t.valueToCode(e,`BOOL`,n?w.LOGICAL_NOT:w.NONE)||`False`,i=t.statementToCode(e,`DO`);return i=t.addLoopTrap(i,e)||t.PASS,n&&(r=`not `+r),`while `+r+`:
|
|
1952
|
-
`+i},ne=function(e,n){let r=n.getVariableName(e.getFieldValue(`VAR`));var i=n.valueToCode(e,`FROM`,w.NONE)||`0`,a=n.valueToCode(e,`TO`,w.NONE)||`0`,o=n.valueToCode(e,`BY`,w.NONE)||`1`;let s=n.statementToCode(e,`DO`);s=n.addLoopTrap(s,e)||n.PASS;let c=``;e=function(){return n.provideFunction_(`upRange`,`
|
|
1953
|
-
def ${n.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):
|
|
1954
|
-
while start <= stop:
|
|
1955
|
-
yield start
|
|
1956
|
-
start += abs(step)
|
|
1957
|
-
`)};let l=function(){return n.provideFunction_(`downRange`,`
|
|
1958
|
-
def ${n.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):
|
|
1959
|
-
while start >= stop:
|
|
1960
|
-
yield start
|
|
1961
|
-
start -= abs(step)
|
|
1962
|
-
`)};if(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))i=Number(i),a=Number(a),o=Math.abs(Number(o)),i%1==0&&a%1==0&&o%1==0?(i<=a?(a++,e=i===0&&o===1?a:i+`, `+a,o!==1&&(e+=`, `+o)):(a--,e=i+`, `+a+`, -`+o),e=`range(`+e+`)`):(e=i<a?e():l(),e+=`(`+i+`, `+a+`, `+o+`)`);else{let s=function(e,i){return t.isNumber$$module$build$src$core$utils$string(e)?e=String(Number(e)):e.match(/^\w+$/)||(i=n.nameDB_.getDistinctName(r+i,t.NameType$$module$build$src$core$names.VARIABLE),c+=i+` = `+e+`
|
|
1963
|
-
`,e=i),e};i=s(i,`_start`),a=s(a,`_end`),o=s(o,`_inc`),typeof i==`number`&&typeof a==`number`?(e=i<a?e():l(),e+=`(`+i+`, `+a+`, `+o+`)`):e=`(`+i+` <= `+a+`) and `+e()+`(`+i+`, `+a+`, `+o+`) or `+l()+`(`+i+`, `+a+`, `+o+`)`}return c+=`for `+r+` in `+e+`:
|
|
1964
|
-
`+s},re=function(e,t){let n=t.getVariableName(e.getFieldValue(`VAR`)),r=t.valueToCode(e,`LIST`,w.RELATIONAL)||`[]`,i=t.statementToCode(e,`DO`);return i=t.addLoopTrap(i,e)||t.PASS,`for `+n+` in `+r+`:
|
|
1965
|
-
`+i},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
|
|
1966
|
-
`;case`CONTINUE`:return n+`continue
|
|
1967
|
-
`}throw Error(`Unknown flow statement.`)},ae=function(e,t){return e=Number(e.getFieldValue(`NUM`)),e===1/0?[`float("inf")`,w.FUNCTION_CALL]:e===-1/0?[`-float("inf")`,w.UNARY_SIGN]:[String(e),e<0?w.UNARY_SIGN:w.ATOMIC]},oe=function(e,t){var n={ADD:[` + `,w.ADDITIVE],MINUS:[` - `,w.ADDITIVE],MULTIPLY:[` * `,w.MULTIPLICATIVE],DIVIDE:[` / `,w.MULTIPLICATIVE],POWER:[` ** `,w.EXPONENTIATION]}[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`,[i+r+e,n]},se=function(e,t){let n=e.getFieldValue(`OP`),r;if(n===`NEG`)return r=t.valueToCode(e,`NUM`,w.UNARY_SIGN)||`0`,[`-`+r,w.UNARY_SIGN];switch(t.definitions_.import_math=`import math`,e=n===`SIN`||n===`COS`||n===`TAN`?t.valueToCode(e,`NUM`,w.MULTIPLICATIVE)||`0`:t.valueToCode(e,`NUM`,w.NONE)||`0`,n){case`ABS`:r=`math.fabs(`+e+`)`;break;case`ROOT`:r=`math.sqrt(`+e+`)`;break;case`LN`:r=`math.log(`+e+`)`;break;case`LOG10`:r=`math.log10(`+e+`)`;break;case`EXP`:r=`math.exp(`+e+`)`;break;case`POW10`:r=`math.pow(10,`+e+`)`;break;case`ROUND`:r=`round(`+e+`)`;break;case`ROUNDUP`:r=`math.ceil(`+e+`)`;break;case`ROUNDDOWN`:r=`math.floor(`+e+`)`;break;case`SIN`:r=`math.sin(`+e+` / 180.0 * math.pi)`;break;case`COS`:r=`math.cos(`+e+` / 180.0 * math.pi)`;break;case`TAN`:r=`math.tan(`+e+` / 180.0 * math.pi)`}if(r)return[r,w.FUNCTION_CALL];switch(n){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,w.MULTIPLICATIVE]},ce=function(e,t){let n={PI:[`math.pi`,w.MEMBER],E:[`math.e`,w.MEMBER],GOLDEN_RATIO:[`(1 + math.sqrt(5)) / 2`,w.MULTIPLICATIVE],SQRT2:[`math.sqrt(2)`,w.MEMBER],SQRT1_2:[`math.sqrt(1.0 / 2)`,w.MEMBER],INFINITY:[`float('inf')`,w.ATOMIC]};return e=e.getFieldValue(`CONSTANT`),e!==`INFINITY`&&(t.definitions_.import_math=`import math`),n[e]},x=function(e,t){var n={EVEN:[` % 2 == 0`,w.MULTIPLICATIVE,w.RELATIONAL],ODD:[` % 2 == 1`,w.MULTIPLICATIVE,w.RELATIONAL],WHOLE:[` % 1 == 0`,w.MULTIPLICATIVE,w.RELATIONAL],POSITIVE:[` > 0`,w.RELATIONAL,w.RELATIONAL],NEGATIVE:[` < 0`,w.RELATIONAL,w.RELATIONAL],DIVISIBLE_BY:[null,w.MULTIPLICATIVE,w.RELATIONAL],PRIME:[null,w.NONE,w.FUNCTION_CALL]};let r=e.getFieldValue(`PROPERTY`),[i,a,o]=n[r];if(n=t.valueToCode(e,`NUMBER_TO_CHECK`,a)||`0`,r===`PRIME`)t.definitions_.import_math=`import math`,t.definitions_.from_numbers_import_Number=`from numbers import Number`,e=t.provideFunction_(`math_isPrime`,`
|
|
1968
|
-
def ${t.FUNCTION_NAME_PLACEHOLDER_}(n):
|
|
1969
|
-
# https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
|
1970
|
-
# If n is not a number but a string, try parsing it.
|
|
1971
|
-
if not isinstance(n, Number):
|
|
1972
|
-
try:
|
|
1973
|
-
n = float(n)
|
|
1974
|
-
except:
|
|
1975
|
-
return False
|
|
1976
|
-
if n == 2 or n == 3:
|
|
1977
|
-
return True
|
|
1978
|
-
# False if n is negative, is 1, or not whole, or if n is divisible by 2 or 3.
|
|
1979
|
-
if n <= 1 or n % 1 != 0 or n % 2 == 0 or n % 3 == 0:
|
|
1980
|
-
return False
|
|
1981
|
-
# Check all the numbers of form 6k +/- 1, up to sqrt(n).
|
|
1982
|
-
for x in range(6, int(math.sqrt(n)) + 2, 6):
|
|
1983
|
-
if n % (x - 1) == 0 or n % (x + 1) == 0:
|
|
1984
|
-
return False
|
|
1985
|
-
return True
|
|
1986
|
-
`)+`(`+n+`)`;else if(r===`DIVISIBLE_BY`){if(e=t.valueToCode(e,`DIVISOR`,w.MULTIPLICATIVE)||`0`,e===`0`)return[`False`,w.ATOMIC];e=n+` % `+e+` == 0`}else e=n+i;return[e,o]},le=function(e,t){t.definitions_.from_numbers_import_Number=`from numbers import Number`;let n=t.valueToCode(e,`DELTA`,w.ADDITIVE)||`0`;return e=t.getVariableName(e.getFieldValue(`VAR`)),e+` = (`+e+` if isinstance(`+e+`, Number) else 0) + `+n+`
|
|
1987
|
-
`},ue=function(e,t){let n=e.getFieldValue(`OP`);switch(e=t.valueToCode(e,`LIST`,w.NONE)||`[]`,n){case`SUM`:t=`sum(`+e+`)`;break;case`MIN`:t=`min(`+e+`)`;break;case`MAX`:t=`max(`+e+`)`;break;case`AVERAGE`:t.definitions_.from_numbers_import_Number=`from numbers import Number`,t=t.provideFunction_(`math_mean`,`
|
|
1988
|
-
def ${t.FUNCTION_NAME_PLACEHOLDER_}(myList):
|
|
1989
|
-
localList = [e for e in myList if isinstance(e, Number)]
|
|
1990
|
-
if not localList: return
|
|
1991
|
-
return float(sum(localList)) / len(localList)
|
|
1992
|
-
`)+`(`+e+`)`;break;case`MEDIAN`:t.definitions_.from_numbers_import_Number=`from numbers import Number`,t=t.provideFunction_(`math_median`,`
|
|
1993
|
-
def ${t.FUNCTION_NAME_PLACEHOLDER_}(myList):
|
|
1994
|
-
localList = sorted([e for e in myList if isinstance(e, Number)])
|
|
1995
|
-
if not localList: return
|
|
1996
|
-
if len(localList) % 2 == 0:
|
|
1997
|
-
return (localList[len(localList) // 2 - 1] + localList[len(localList) // 2]) / 2.0
|
|
1998
|
-
else:
|
|
1999
|
-
return localList[(len(localList) - 1) // 2]
|
|
2000
|
-
`)+`(`+e+`)`;break;case`MODE`:t=t.provideFunction_(`math_modes`,`
|
|
2001
|
-
def ${t.FUNCTION_NAME_PLACEHOLDER_}(some_list):
|
|
2002
|
-
modes = []
|
|
2003
|
-
# Using a lists of [item, count] to keep count rather than dict
|
|
2004
|
-
# to avoid "unhashable" errors when the counted item is itself a list or dict.
|
|
2005
|
-
counts = []
|
|
2006
|
-
maxCount = 1
|
|
2007
|
-
for item in some_list:
|
|
2008
|
-
found = False
|
|
2009
|
-
for count in counts:
|
|
2010
|
-
if count[0] == item:
|
|
2011
|
-
count[1] += 1
|
|
2012
|
-
maxCount = max(maxCount, count[1])
|
|
2013
|
-
found = True
|
|
2014
|
-
if not found:
|
|
2015
|
-
counts.append([item, 1])
|
|
2016
|
-
for counted_item, item_count in counts:
|
|
2017
|
-
if item_count == maxCount:
|
|
2018
|
-
modes.append(counted_item)
|
|
2019
|
-
return modes
|
|
2020
|
-
`)+`(`+e+`)`;break;case`STD_DEV`:t.definitions_.import_math=`import math`,t=t.provideFunction_(`math_standard_deviation`,`
|
|
2021
|
-
def ${t.FUNCTION_NAME_PLACEHOLDER_}(numbers):
|
|
2022
|
-
n = len(numbers)
|
|
2023
|
-
if n == 0: return
|
|
2024
|
-
mean = float(sum(numbers)) / n
|
|
2025
|
-
variance = sum((x - mean) ** 2 for x in numbers) / n
|
|
2026
|
-
return math.sqrt(variance)
|
|
2027
|
-
`)+`(`+e+`)`;break;case`RANDOM`:t.definitions_.import_random=`import random`,t=`random.choice(`+e+`)`;break;default:throw Error(`Unknown operator: `+n)}return[t,w.FUNCTION_CALL]},de=function(e,t){let n=t.valueToCode(e,`DIVIDEND`,w.MULTIPLICATIVE)||`0`;return e=t.valueToCode(e,`DIVISOR`,w.MULTIPLICATIVE)||`0`,[n+` % `+e,w.MULTIPLICATIVE]},S=function(e,t){let n=t.valueToCode(e,`VALUE`,w.NONE)||`0`,r=t.valueToCode(e,`LOW`,w.NONE)||`0`;return e=t.valueToCode(e,`HIGH`,w.NONE)||`float('inf')`,[`min(max(`+n+`, `+r+`), `+e+`)`,w.FUNCTION_CALL]},fe=function(e,t){t.definitions_.import_random=`import random`;let n=t.valueToCode(e,`FROM`,w.NONE)||`0`;return e=t.valueToCode(e,`TO`,w.NONE)||`0`,[`random.randint(`+n+`, `+e+`)`,w.FUNCTION_CALL]},pe=function(e,t){return t.definitions_.import_random=`import random`,[`random.random()`,w.FUNCTION_CALL]},me=function(e,t){t.definitions_.import_math=`import math`;let n=t.valueToCode(e,`X`,w.NONE)||`0`;return[`math.atan2(`+(t.valueToCode(e,`Y`,w.NONE)||`0`)+`, `+n+`) / math.pi * 180`,w.MULTIPLICATIVE]},he=function(e,n){var r=[],i=e.workspace,a=t.allUsedVarModels$$module$build$src$core$variables(i)||[];for(var o of a)a=o.getName(),e.getVars().includes(a)||r.push(n.getVariableName(a));for(i=t.allDeveloperVariables$$module$build$src$core$variables(i),o=0;o<i.length;o++)r.push(n.nameDB_.getName(i[o],t.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));i=r.length?n.INDENT+`global `+r.join(`, `)+`
|
|
2028
|
-
`:``,r=n.getProcedureName(e.getFieldValue(`NAME`)),o=``,n.STATEMENT_PREFIX&&(o+=n.injectId(n.STATEMENT_PREFIX,e)),n.STATEMENT_SUFFIX&&(o+=n.injectId(n.STATEMENT_SUFFIX,e)),o&&=n.prefixLines(o,n.INDENT),a=``,n.INFINITE_LOOP_TRAP&&(a=n.prefixLines(n.injectId(n.INFINITE_LOOP_TRAP,e),n.INDENT));let s=``;e.getInput(`STACK`)&&(s=n.statementToCode(e,`STACK`));let c=``;e.getInput(`RETURN`)&&(c=n.valueToCode(e,`RETURN`,w.NONE)||``);let l=``;s&&c&&(l=o),c?c=n.INDENT+`return `+c+`
|
|
2029
|
-
`:s||=n.PASS;let u=[],d=e.getVars();for(let e=0;e<d.length;e++)u[e]=n.getVariableName(d[e]);return i=`def `+r+`(`+u.join(`, `)+`):
|
|
2030
|
-
`+i+o+a+s+l+c,i=n.scrub_(e,i),n.definitions_[`%`+r]=i,null},ge=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,w.NONE)||`None`;return[n+`(`+r.join(`, `)+`)`,w.FUNCTION_CALL]},_e=function(e,t){return t.forBlock.procedures_callreturn(e,t)[0]+`
|
|
2031
|
-
`},ve=function(e,t){let n=`if `+(t.valueToCode(e,`CONDITION`,w.NONE)||`False`)+`:
|
|
2032
|
-
`;return t.STATEMENT_SUFFIX&&(n+=t.prefixLines(t.injectId(t.STATEMENT_SUFFIX,e),t.INDENT)),e.hasReturnValue_?(e=t.valueToCode(e,`VALUE`,w.NONE)||`None`,n+=t.INDENT+`return `+e+`
|
|
2033
|
-
`):n+=t.INDENT+`return
|
|
2034
|
-
`,n},ye=function(e,t){return[t.quote_(e.getFieldValue(`TEXT`)),w.ATOMIC]},be=function(e,n){switch(e.itemCount_){case 0:return[`''`,w.ATOMIC];case 1:return e=n.valueToCode(e,`ADD0`,w.NONE)||`''`,Ie(e);case 2:var r=n.valueToCode(e,`ADD0`,w.NONE)||`''`;return e=n.valueToCode(e,`ADD1`,w.NONE)||`''`,[Ie(r)[0]+` + `+Ie(e)[0],w.ADDITIVE];default:r=[];for(let t=0;t<e.itemCount_;t++)r[t]=n.valueToCode(e,`ADD`+t,w.NONE)||`''`;return e=n.nameDB_.getDistinctName(`x`,t.NameType$$module$build$src$core$names.VARIABLE),[`''.join([str(`+e+`) for `+e+` in [`+r.join(`, `)+`]])`,w.FUNCTION_CALL]}},xe=function(e,t){let n=t.getVariableName(e.getFieldValue(`VAR`));return e=t.valueToCode(e,`TEXT`,w.NONE)||`''`,n+` = str(`+n+`) + `+Ie(e)[0]+`
|
|
2035
|
-
`},Se=function(e,t){return[`len(`+(t.valueToCode(e,`VALUE`,w.NONE)||`''`)+`)`,w.FUNCTION_CALL]},Ce=function(e,t){return[`not len(`+(t.valueToCode(e,`VALUE`,w.NONE)||`''`)+`)`,w.LOGICAL_NOT]},we=function(e,t){let n=e.getFieldValue(`END`)===`FIRST`?`find`:`rfind`,r=t.valueToCode(e,`FIND`,w.NONE)||`''`;return t=(t.valueToCode(e,`VALUE`,w.MEMBER)||`''`)+`.`+n+`(`+r+`)`,e.workspace.options.oneBasedIndex?[t+` + 1`,w.ADDITIVE]:[t,w.FUNCTION_CALL]},Te=function(e,t){let n=e.getFieldValue(`WHERE`)||`FROM_START`,r=t.valueToCode(e,`VALUE`,n===`RANDOM`?w.NONE:w.MEMBER)||`''`;switch(n){case`FIRST`:return[r+`[0]`,w.MEMBER];case`LAST`:return[r+`[-1]`,w.MEMBER];case`FROM_START`:return e=t.getAdjustedInt(e,`AT`),[r+`[`+e+`]`,w.MEMBER];case`FROM_END`:return e=t.getAdjustedInt(e,`AT`,1,!0),[r+`[`+e+`]`,w.MEMBER];case`RANDOM`:return t.definitions_.import_random=`import random`,[t.provideFunction_(`text_random_letter`,`
|
|
2036
|
-
def ${t.FUNCTION_NAME_PLACEHOLDER_}(text):
|
|
2037
|
-
x = int(random.random() * len(text))
|
|
2038
|
-
return text[x]
|
|
2039
|
-
`)+`(`+r+`)`,w.FUNCTION_CALL]}throw Error(`Unhandled option (text_charAt).`)},Ee=function(e,n){var r=e.getFieldValue(`WHERE1`);let i=e.getFieldValue(`WHERE2`),a=n.valueToCode(e,`STRING`,w.MEMBER)||`''`;switch(r){case`FROM_START`:r=n.getAdjustedInt(e,`AT1`),r===0&&(r=``);break;case`FROM_END`:r=n.getAdjustedInt(e,`AT1`,1,!0);break;case`FIRST`:r=``;break;default:throw Error(`Unhandled option (text_getSubstring)`)}switch(i){case`FROM_START`:e=n.getAdjustedInt(e,`AT2`,1);break;case`FROM_END`:e=n.getAdjustedInt(e,`AT2`,0,!0),t.isNumber$$module$build$src$core$utils$string(String(e))?e===0&&(e=``):(n.definitions_.import_sys=`import sys`,e+=` or sys.maxsize`);break;case`LAST`:e=``;break;default:throw Error(`Unhandled option (text_getSubstring)`)}return[a+`[`+r+` : `+e+`]`,w.MEMBER]},C=function(e,t){let n={UPPERCASE:`.upper()`,LOWERCASE:`.lower()`,TITLECASE:`.title()`}[e.getFieldValue(`CASE`)];return[(t.valueToCode(e,`TEXT`,w.MEMBER)||`''`)+n,w.FUNCTION_CALL]},De=function(e,t){let n={LEFT:`.lstrip()`,RIGHT:`.rstrip()`,BOTH:`.strip()`}[e.getFieldValue(`MODE`)];return[(t.valueToCode(e,`TEXT`,w.MEMBER)||`''`)+n,w.FUNCTION_CALL]},Oe=function(e,t){return`print(`+(t.valueToCode(e,`TEXT`,w.NONE)||`''`)+`)
|
|
2040
|
-
`},ke=function(e,t){var n=t.provideFunction_(`text_prompt`,`
|
|
2041
|
-
def ${t.FUNCTION_NAME_PLACEHOLDER_}(msg):
|
|
2042
|
-
try:
|
|
2043
|
-
return raw_input(msg)
|
|
2044
|
-
except NameError:
|
|
2045
|
-
return input(msg)
|
|
2046
|
-
`);return t=e.getField(`TEXT`)?t.quote_(e.getFieldValue(`TEXT`)):t.valueToCode(e,`TEXT`,w.NONE)||`''`,n=n+`(`+t+`)`,e.getFieldValue(`TYPE`)===`NUMBER`&&(n=`float(`+n+`)`),[n,w.FUNCTION_CALL]},Ae=function(e,t){let n=t.valueToCode(e,`TEXT`,w.MEMBER)||`''`;return e=t.valueToCode(e,`SUB`,w.NONE)||`''`,[n+`.count(`+e+`)`,w.FUNCTION_CALL]},je=function(e,t){let n=t.valueToCode(e,`TEXT`,w.MEMBER)||`''`,r=t.valueToCode(e,`FROM`,w.NONE)||`''`;return e=t.valueToCode(e,`TO`,w.NONE)||`''`,[n+`.replace(`+r+`, `+e+`)`,w.MEMBER]},Me=function(e,t){return[(t.valueToCode(e,`TEXT`,w.MEMBER)||`''`)+`[::-1]`,w.MEMBER]},Ne=function(e,t){return[t.getVariableName(e.getFieldValue(`VAR`)),w.ATOMIC]},Pe=function(e,t){let n=t.valueToCode(e,`VALUE`,w.NONE)||`0`;return t.getVariableName(e.getFieldValue(`VAR`))+` = `+n+`
|
|
2047
|
-
`},w;(function(e){e[e.ATOMIC=0]=`ATOMIC`,e[e.COLLECTION=1]=`COLLECTION`,e[e.STRING_CONVERSION=1]=`STRING_CONVERSION`,e[e.MEMBER=2.1]=`MEMBER`,e[e.FUNCTION_CALL=2.2]=`FUNCTION_CALL`,e[e.EXPONENTIATION=3]=`EXPONENTIATION`,e[e.UNARY_SIGN=4]=`UNARY_SIGN`,e[e.BITWISE_NOT=4]=`BITWISE_NOT`,e[e.MULTIPLICATIVE=5]=`MULTIPLICATIVE`,e[e.ADDITIVE=6]=`ADDITIVE`,e[e.BITWISE_SHIFT=7]=`BITWISE_SHIFT`,e[e.BITWISE_AND=8]=`BITWISE_AND`,e[e.BITWISE_XOR=9]=`BITWISE_XOR`,e[e.BITWISE_OR=10]=`BITWISE_OR`,e[e.RELATIONAL=11]=`RELATIONAL`,e[e.LOGICAL_NOT=12]=`LOGICAL_NOT`,e[e.LOGICAL_AND=13]=`LOGICAL_AND`,e[e.LOGICAL_OR=14]=`LOGICAL_OR`,e[e.CONDITIONAL=15]=`CONDITIONAL`,e[e.LAMBDA=16]=`LAMBDA`,e[e.NONE=99]=`NONE`})(w||={});var T=class extends t.CodeGenerator$$module$build$src$core$generator{constructor(e=`Python`){super(e),this.ORDER_OVERRIDES=[[w.FUNCTION_CALL,w.MEMBER],[w.FUNCTION_CALL,w.FUNCTION_CALL],[w.MEMBER,w.MEMBER],[w.MEMBER,w.FUNCTION_CALL],[w.LOGICAL_NOT,w.LOGICAL_NOT],[w.LOGICAL_AND,w.LOGICAL_AND],[w.LOGICAL_OR,w.LOGICAL_OR]],this.PASS=``,this.isInitialized=!1;for(let t in w)e=w[t],typeof e!=`string`&&(this[`ORDER_`+t]=e);this.addReservedWords(`False,None,True,and,as,assert,break,class,continue,def,del,elif,else,except,exec,finally,for,from,global,if,import,in,is,lambda,nonlocal,not,or,pass,print,raise,return,try,while,with,yield,NotImplemented,Ellipsis,__debug__,quit,exit,copyright,license,credits,ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EnvironmentError,Exception,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StandardError,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,ZeroDivisionError,_,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,all,any,apply,ascii,basestring,bin,bool,buffer,bytearray,bytes,callable,chr,classmethod,cmp,coerce,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,execfile,exit,file,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,intern,isinstance,issubclass,iter,len,license,list,locals,long,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,raw_input,reduce,reload,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,unichr,unicode,vars,xrange,zip`)}init(e){super.init(e),this.PASS=this.INDENT+`pass
|
|
2048
|
-
`,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.Names$$module$build$src$core$names.DEVELOPER_VARIABLE_TYPE)+` = None`);for(e=t.allUsedVarModels$$module$build$src$core$variables(e),r=0;r<e.length;r++)n.push(this.getVariableName(e[r].getId())+` = None`);this.definitions_.variables=n.join(`
|
|
2049
|
-
`),this.isInitialized=!0}finish(e){let t=[],n=[];for(let e in this.definitions_){let r=this.definitions_[e];r.match(/^(from\s+\S+\s+)?import\s+\S+/)?t.push(r):n.push(r)}return e=super.finish(e),this.isInitialized=!1,this.nameDB_.reset(),(t.join(`
|
|
2050
|
-
`)+`
|
|
2051
|
-
|
|
2052
|
-
`+n.join(`
|
|
2053
|
-
|
|
2054
|
-
`)).replace(/\n\n+/g,`
|
|
2055
|
-
|
|
2056
|
-
`).replace(/\n*$/,`
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
`)+e}scrubNakedValue(e){return e+`
|
|
2060
|
-
`}quote_(e){e=e.replace(/\\/g,`\\\\`).replace(/\n/g,`\\
|
|
2061
|
-
`);let t=`'`;return e.includes(`'`)&&(e.includes(`"`)?e=e.replace(/'/g,`\\'`):t=`"`),t+e+t}multiline_quote_(e){return e.split(/\n/g).map(this.quote_).join(` + '\\n' +
|
|
2062
|
-
`)}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+`
|
|
2063
|
-
`,`# `));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}getAdjustedInt(e,n,r=0,i=!1){e.workspace.options.oneBasedIndex&&r--;let a=e.workspace.options.oneBasedIndex?`1`:`0`;return e=this.valueToCode(e,n,r?w.ADDITIVE:w.NONE)||a,t.isNumber$$module$build$src$core$utils$string(e)?(e=parseInt(e,10)+r,i&&(e=-e)):(e=r>0?`int(`+e+` + `+r+`)`:r<0?`int(`+e+` - `+-r+`)`:`int(`+e+`)`,i&&(e=`-`+e)),e}},Fe={};Fe.Order=w,Fe.PythonGenerator=T;var E={};E.lists_create_empty=n,E.lists_create_with=r,E.lists_getIndex=c,E.lists_getSublist=u,E.lists_indexOf=s,E.lists_isEmpty=o,E.lists_length=a,E.lists_repeat=i,E.lists_reverse=p,E.lists_setIndex=l,E.lists_sort=d,E.lists_split=f;var D={};D.controls_if=m,D.controls_ifelse=m,D.logic_boolean=v,D.logic_compare=h,D.logic_negate=_,D.logic_null=y,D.logic_operation=g,D.logic_ternary=ee;var O={};O.controls_flow_statements=ie,O.controls_for=ne,O.controls_forEach=re,O.controls_repeat=b,O.controls_repeat_ext=b,O.controls_whileUntil=te;var k={};k.math_arithmetic=oe,k.math_atan2=me,k.math_change=le,k.math_constant=ce,k.math_constrain=S,k.math_modulo=de,k.math_number=ae,k.math_number_property=x,k.math_on_list=ue,k.math_random_float=pe,k.math_random_int=fe,k.math_round=se,k.math_single=se,k.math_trig=se;var A={};A.procedures_callnoreturn=_e,A.procedures_callreturn=ge,A.procedures_defnoreturn=he,A.procedures_defreturn=he,A.procedures_ifreturn=ve;var j=/^\s*'([^']|\\')*'\s*$/,Ie=function(e){return j.test(e)?[e,w.ATOMIC]:[`str(`+e+`)`,w.FUNCTION_CALL]},M={};M.text=ye,M.text_append=xe,M.text_changeCase=C,M.text_charAt=Te,M.text_count=Ae,M.text_getSubstring=Ee,M.text_indexOf=we,M.text_isEmpty=Ce,M.text_join=be,M.text_length=Se,M.text_print=Oe,M.text_prompt=ke,M.text_prompt_ext=ke,M.text_replace=je,M.text_reverse=Me,M.text_trim=De;var Le={};Le.variables_get=Ne,Le.variables_set=Pe;var Re={};Re.variables_get_dynamic=Ne,Re.variables_set_dynamic=Pe;var ze=new T;ze.addReservedWords(`math,random,Number`);var Be=Object.assign({},E,D,O,k,A,M,Le,Re);for(let e in Be)ze.forBlock[e]=Be[e];var Ve={};return Ve.Order=w,Ve.PythonGenerator=T,Ve.pythonGenerator=ze,Ve.__namespace__=t,Ve})})),z=t(((e,t)=>{
|
|
2064
|
-
/*! For license information please see index.js.LICENSE.txt */
|
|
2065
|
-
(function(n,r){if(typeof e==`object`&&typeof t==`object`)t.exports=r(y(),Bn(),Il(),Ll(),R(),Rl());else if(typeof define==`function`&&define.amd)define([`blockly/core`,`blockly/javascript`,`blockly/dart`,`blockly/lua`,`blockly/php`,`blockly/python`],r);else{var i=typeof e==`object`?r(y(),Bn(),Il(),Ll(),R(),Rl()):r(n.Blockly,n[`Blockly.JavaScript`],n[`Blockly.Dart`],n[`Blockly.Lua`],n[`Blockly.PHP`],n[`Blockly.Python`]);for(var a in i)(typeof e==`object`?e:n)[a]=i[a]}})(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),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),null),this.pointerMoveHandler&&=(a.browserEvents.unbind(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(`
|
|
2066
|
-
.blocklyFieldGridContainer {
|
|
2067
|
-
padding: 7px;
|
|
2068
|
-
overflow: auto;
|
|
2069
|
-
}
|
|
2070
|
-
|
|
2071
|
-
.blocklyFieldGrid {
|
|
2072
|
-
display: grid;
|
|
2073
|
-
grid-gap: 7px;
|
|
2074
|
-
grid-template-columns: repeat(var(--grid-columns), min-content);
|
|
2075
|
-
}
|
|
2076
|
-
|
|
2077
|
-
.blocklyFieldGrid .blocklyFieldGridItem {
|
|
2078
|
-
border: 1px solid rgba(1, 1, 1, 0.5);
|
|
2079
|
-
border-radius: 4px;
|
|
2080
|
-
color: white;
|
|
2081
|
-
min-width: auto;
|
|
2082
|
-
background: none;
|
|
2083
|
-
white-space: nowrap;
|
|
2084
|
-
cursor: pointer;
|
|
2085
|
-
padding: 6px 15px;
|
|
2086
|
-
}
|
|
2087
|
-
|
|
2088
|
-
.blocklyFieldGrid .blocklyFieldGridRow {
|
|
2089
|
-
display: contents;
|
|
2090
|
-
}
|
|
2091
|
-
|
|
2092
|
-
.blocklyFieldGrid .blocklyFieldGridItem.blocklyFieldGridItemSelected {
|
|
2093
|
-
background-color: rgba(1, 1, 1, 0.25);
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2096
|
-
.blocklyFieldGrid .blocklyFieldGridItem:focus {
|
|
2097
|
-
box-shadow: 0 0 0 4px hsla(0, 0%, 100%, .2);
|
|
2098
|
-
outline: none;
|
|
2099
|
-
}
|
|
2100
|
-
`),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:()=>Ne,registerFieldColour:()=>d});var e={};c.r(e),c.d(e,{BLOCK_NAME:()=>_,blockDefinition:()=>ie,installBlock:()=>ae,toDart:()=>ee,toJavascript:()=>y,toLua:()=>b,toPhp:()=>te,toPython:()=>ne});var t={};c.r(t),c.d(t,{BLOCK_NAME:()=>oe,blockDefinition:()=>fe,installBlock:()=>pe,toDart:()=>x,toJavascript:()=>ce,toLua:()=>le,toPhp:()=>ue,toPython:()=>de});var n={};c.r(n),c.d(n,{BLOCK_NAME:()=>me,blockDefinition:()=>Se,installBlock:()=>Ce,toDart:()=>_e,toJavascript:()=>ge,toLua:()=>ve,toPhp:()=>ye,toPython:()=>be});var r={};c.r(r),c.d(r,{BLOCK_NAME:()=>we,blockDefinition:()=>je,installBlock:()=>Me,toDart:()=>C,toJavascript:()=>Ee,toLua:()=>De,toPhp:()=>Oe,toPython:()=>ke});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(`
|
|
2101
|
-
.blocklyFieldColour .blocklyFieldGridItemSelected,
|
|
2102
|
-
.blocklyFieldGridItemSelected:hover {
|
|
2103
|
-
border-color: #eee !important;
|
|
2104
|
-
outline: 1px solid #333;
|
|
2105
|
-
position: relative;
|
|
2106
|
-
}
|
|
2107
|
-
|
|
2108
|
-
.blocklyColourSwatch {
|
|
2109
|
-
width: 20px;
|
|
2110
|
-
height: 20px;
|
|
2111
|
-
}
|
|
2112
|
-
|
|
2113
|
-
.blocklyGridContainer {
|
|
2114
|
-
padding: 0px;
|
|
2115
|
-
}
|
|
2116
|
-
|
|
2117
|
-
.blocklyFieldColour .blocklyFieldGrid {
|
|
2118
|
-
grid-gap: 0px;
|
|
2119
|
-
row-gap: 4px;
|
|
2120
|
-
}
|
|
2121
|
-
|
|
2122
|
-
.blocklyFieldColour .blocklyFieldGrid .blocklyGridItem {
|
|
2123
|
-
border-radius: 0;
|
|
2124
|
-
padding: 0;
|
|
2125
|
-
border: 0.5px solid #888;
|
|
2126
|
-
cursor: pointer;
|
|
2127
|
-
}
|
|
2128
|
-
|
|
2129
|
-
.blocklyFieldColour .blocklyFieldGrid .blocklyFieldGridItem {
|
|
2130
|
-
border: 0.5px solid #888;
|
|
2131
|
-
padding: 0;
|
|
2132
|
-
margin: 0;
|
|
2133
|
-
border-radius: 0;
|
|
2134
|
-
}
|
|
2135
|
-
|
|
2136
|
-
.blocklyFieldColour .blocklyFieldGrid .blocklyFieldGridItem:focus {
|
|
2137
|
-
border-color: #eee;
|
|
2138
|
-
box-shadow: 2px 2px 7px 2px rgba(0, 0, 0, 0.3);
|
|
2139
|
-
position: relative;
|
|
2140
|
-
border-radius: 0;
|
|
2141
|
-
outline: none;
|
|
2142
|
-
}
|
|
2143
|
-
`);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 ee(e,t){return[t.quote_(e.getFieldValue(`COLOUR`)),p.Order.ATOMIC]}function b(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[_]=ee),e.lua&&(e.lua.forBlock[_]=b),e.php&&(e.php.forBlock[_]=te),e.python&&(e.python.forBlock[_]=ne)}let oe=`colour_random`,se={type:oe,message0:`%{BKY_COLOUR_RANDOM_TITLE}`,output:`Colour`,helpUrl:`%{BKY_COLOUR_RANDOM_HELPURL}`,style:`colour_blocks`,tooltip:`%{BKY_COLOUR_RANDOM_TOOLTIP}`};function ce(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 x(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 le(e,t){return[`string.format("#%06x", math.random(0, 2^24 - 1))`,m.Order.HIGH]}function ue(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 de(e,t){return t.definitions_.import_random=`import random`,[`'#%06x' % random.randint(0, 2**24 - 1)`,g.Order.FUNCTION_CALL]}let S=i.common.createBlockDefinitionsFromJsonArray([se]),fe=S[oe];function pe(e={}){d(),i.common.defineBlocks(S),e.javascript&&(e.javascript.forBlock[oe]=ce),e.dart&&(e.dart.forBlock[oe]=x),e.lua&&(e.lua.forBlock[oe]=le),e.php&&(e.php.forBlock[oe]=ue),e.python&&(e.python.forBlock[oe]=de)}let me=`colour_rgb`,he={type:me,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 ge(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 _e(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 ve(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 ye(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 be(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 xe=i.common.createBlockDefinitionsFromJsonArray([he]),Se=xe[me];function Ce(e={}){d(),i.common.defineBlocks(xe),e.javascript&&(e.javascript.forBlock[me]=ge),e.dart&&(e.dart.forBlock[me]=_e,e.dart.addReservedWords(`Math`)),e.lua&&(e.lua.forBlock[me]=ve),e.php&&(e.php.forBlock[me]=ye),e.python&&(e.python.forBlock[me]=be)}let we=`colour_blend`,Te={type:we,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 Ee(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 C(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 De(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 Oe(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 ke(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 Ae=i.common.createBlockDefinitionsFromJsonArray([Te]),je=Ae[we];function Me(e={}){d(),i.common.defineBlocks(Ae),e.javascript&&(e.javascript.forBlock[we]=Ee),e.dart&&(e.dart.forBlock[we]=C,e.dart.addReservedWords(`Math`)),e.lua&&(e.lua.forBlock[we]=De),e.php&&(e.php.forBlock[we]=Oe),e.python&&(e.python.forBlock[we]=ke)}function Ne(e={}){ae(e),Ce(e),pe(e),Me(e)}})(),l})())}));const zl=62n,B=new globalThis.TextEncoder,Bl=new globalThis.TextDecoder;function V(e,t){if(typeof e!=`string`)throw TypeError(`The \`${t}\` parameter must be a string, got \`${e}\` (${typeof e}).`)}function Vl(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}.`)}const Hl=new class{constructor(e={}){let t=e.alphabet??`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`;Vl(t),this.alphabet=[...t],this.indices=new Map(this.alphabet.map((e,t)=>[e,t]))}#e(e){let t=this.indices.get(e);if(t===void 0)throw TypeError(`Unexpected character for Base62 encoding: \`${e}\`.`);return t}encodeString(e){return V(e,`string`),this.encodeBytes(B.encode(e))}decodeString(e){return V(e,`encodedString`),Bl.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(V(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){V(e,`encodedString`);let t=0;for(let n of e)t=t*62+this.#e(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%zl)]+t,e/=zl;return t}decodeBigInt(e){V(e,`encodedString`);let t=0n;for(let n of e)t=t*zl+BigInt(this.#e(n));return t}},Ul=e=>Hl.encodeString(e);var Wl=t(((e,t)=>{(function(n,r){if(typeof e==`object`&&typeof t==`object`)t.exports=r(y());else if(typeof define==`function`&&define.amd)define([`blockly/core`],r);else{var i=r(typeof e==`object`?y():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||={});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||=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 Gl(e,t){return a()?(u(e,t),!0):!1}const Kl=typeof window<`u`&&typeof document<`u`;typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;const ql=Kl?window:void 0;Kl&&window.document,Kl&&window.navigator,Kl&&window.location;function Jl(e){let t=g(e);return t?.$el??t}function Yl(){let e=m(!1),t=i();return t&&l(()=>{e.value=!0},t),e}function Xl(e){let t=Yl();return n(()=>(t.value,!!e()))}function Zl(e,t,r={}){let{window:i=ql,...a}=r,o,s=Xl(()=>i&&`ResizeObserver`in i),c=()=>{o&&=(o.disconnect(),void 0)},l=v(n(()=>{let t=g(e);return Array.isArray(t)?t.map(e=>Jl(e)):[Jl(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 Gl(u),{isSupported:s,stop:u}}var Ql=Object.defineProperty,$l=Object.getOwnPropertySymbols,eu=Object.prototype.hasOwnProperty,tu=Object.prototype.propertyIsEnumerable,nu=(e,t,n)=>t in e?Ql(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ru=(e,t)=>{for(var n in t||={})eu.call(t,n)&&nu(e,n,t[n]);if($l)for(var n of $l(t))tu.call(t,n)&&nu(e,n,t[n]);return e},iu=(e,t)=>{var n={};for(var r in e)eu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&$l)for(var r of $l(e))t.indexOf(r)<0&&tu.call(e,r)&&(n[r]=e[r]);return n};const H=`[vue-draggable-plus]: `;function au(e){console.warn(H+e)}function ou(e){console.error(H+e)}function su(e,t,n){return n>=0&&n<e.length&&e.splice(n,0,e.splice(t,1)[0]),e}function cu(e){return e.replace(/-(\w)/g,(e,t)=>t?t.toUpperCase():``)}function lu(e){return Object.keys(e).reduce((t,n)=>(e[n]!==void 0&&(t[cu(n)]=e[n]),t),{})}function uu(e,t){return Array.isArray(e)&&e.splice(t,1),e}function du(e,t,n){return Array.isArray(e)&&e.splice(t,0,n),e}function fu(e){return e===void 0}function pu(e){return typeof e==`string`}function mu(e,t,n){let r=e.children[n];e.insertBefore(t,r)}function hu(e){e.parentNode&&e.parentNode.removeChild(e)}function gu(e,t=document){let n=null;return n=typeof t?.querySelector==`function`?(t?.querySelector)?.call(t,e):document.querySelector(e),n||au(`Element not found: ${e}`),n}function _u(e,t,n=null){return function(...r){return e.apply(n,r),t.apply(n,r)}}function vu(e,t){let n=ru({},e);return Object.keys(t).forEach(r=>{n[r]?n[r]=_u(e[r],t[r]):n[r]=t[r]}),n}function yu(e){return e instanceof HTMLElement}function bu(e,t){Object.keys(e).forEach(n=>{t(n,e[n])})}function xu(e){return e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97)}const Su=Object.assign;
|
|
2144
|
-
/**!
|
|
2145
|
-
* Sortable 1.15.2
|
|
2146
|
-
* @author RubaXa <trash@rubaxa.org>
|
|
2147
|
-
* @author owenm <owen23355@gmail.com>
|
|
2148
|
-
* @license MIT
|
|
2149
|
-
*/
|
|
2150
|
-
function Cu(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 wu(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Cu(Object(n),!0).forEach(function(t){Eu(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Cu(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Tu(e){"@babel/helpers - typeof";return Tu=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},Tu(e)}function Eu(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Du(){return Du=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},Du.apply(this,arguments)}function Ou(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 ku(e,t){if(e==null)return{};var n=Ou(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 Au=`1.15.2`;function ju(e){if(typeof window<`u`&&window.navigator)return!!navigator.userAgent.match(e)}var Mu=ju(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Nu=ju(/Edge/i),Pu=ju(/firefox/i),Fu=ju(/safari/i)&&!ju(/chrome/i)&&!ju(/android/i),Iu=ju(/iP(ad|od|hone)/i),Lu=ju(/chrome/i)&&ju(/android/i),Ru={capture:!1,passive:!1};function U(e,t,n){e.addEventListener(t,n,!Mu&&Ru)}function zu(e,t,n){e.removeEventListener(t,n,!Mu&&Ru)}function Bu(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 Vu(e){return e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode}function Hu(e,t,n,r){if(e){n||=document;do{if(t!=null&&(t[0]===`>`?e.parentNode===n&&Bu(e,t):Bu(e,t))||r&&e===n)return e;if(e===n)break}while(e=Vu(e))}return null}var Uu=/\s+/g;function Wu(e,t,n){e&&t&&(e.classList?e.classList[n?`add`:`remove`](t):e.className=((` `+e.className+` `).replace(Uu,` `).replace(` `+t+` `,` `)+(n?` `+t:``)).replace(Uu,` `))}function W(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 Gu(e,t){var n=``;if(typeof e==`string`)n=e;else do{var r=W(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 Ku(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 Ju(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||=e.parentNode,!Mu))do if(i&&i.getBoundingClientRect&&(W(i,`transform`)!==`none`||n&&W(i,`position`)!==`static`)){var f=i.getBoundingClientRect();o-=f.top+parseInt(W(i,`border-top-width`)),s-=f.left+parseInt(W(i,`border-left-width`)),c=o+a.height,l=s+a.width;break}while(i=i.parentNode);if(r&&e!==window){var p=Gu(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 Yu(e,t,n){for(var r=td(e,!0),i=Ju(e)[t];r;){var a=Ju(r)[n],o=void 0;if(o=i>=a,!o)return r;if(r===qu())break;r=td(r,!1)}return!1}function Xu(e,t,n,r){for(var i=0,a=0,o=e.children;a<o.length;){if(o[a].style.display!==`none`&&o[a]!==J.ghost&&(r||o[a]!==J.dragged)&&Hu(o[a],n.draggable,e,!1)){if(i===t)return o[a];i++}a++}return null}function Zu(e,t){for(var n=e.lastElementChild;n&&(n===J.ghost||W(n,`display`)===`none`||t&&!Bu(n,t));)n=n.previousElementSibling;return n||null}function Qu(e,t){var n=0;if(!e||!e.parentNode)return-1;for(;e=e.previousElementSibling;)e.nodeName.toUpperCase()!==`TEMPLATE`&&e!==J.clone&&(!t||Bu(e,t))&&n++;return n}function $u(e){var t=0,n=0,r=qu();if(e)do{var i=Gu(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 ed(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 td(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=W(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 nd(e,t){if(e&&t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function rd(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 id;function ad(e,t){return function(){if(!id){var n=arguments,r=this;n.length===1?e.call(r,n[0]):e.apply(r,n),id=setTimeout(function(){id=void 0},t)}}}function od(){clearTimeout(id),id=void 0}function sd(e,t,n){e.scrollLeft+=t,e.scrollTop+=n}function cd(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 ld(e,t,n){var r={};return Array.from(e.children).forEach(function(i){if(!(!Hu(i,t.draggable,e,!1)||i.animated||i===n)){var a=Ju(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 ud=`Sortable`+new Date().getTime();function dd(){var e=[],t;return{captureAnimationState:function(){e=[],this.options.animation&&[].slice.call(this.el.children).forEach(function(t){if(!(W(t,`display`)===`none`||t===J.ghost)){e.push({target:t,rect:Ju(t)});var n=wu({},e[e.length-1].rect);if(t.thisAnimationDuration){var r=Gu(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(ed(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=Ju(n),c=n.prevFromRect,l=n.prevToRect,u=e.rect,d=Gu(n,!0);d&&(s.top-=d.f,s.left-=d.e),n.toRect=s,n.thisAnimationDuration&&rd(c,s)&&!rd(o,s)&&(u.top-s.top)/(u.left-s.left)===(o.top-s.top)/(o.left-s.left)&&(t=pd(u,c,l,r.options)),rd(s,o)||(n.prevFromRect=o,n.prevToRect=s,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){W(e,`transition`,``),W(e,`transform`,``);var i=Gu(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,W(e,`transform`,`translate3d(`+s+`px,`+c+`px,0)`),this.forRepaintDummy=fd(e),W(e,`transition`,`transform `+r+`ms`+(this.options.easing?` `+this.options.easing:``)),W(e,`transform`,`translate3d(0,0,0)`),typeof e.animated==`number`&&clearTimeout(e.animated),e.animated=setTimeout(function(){W(e,`transition`,``),W(e,`transform`,``),e.animated=!1,e.animatingX=!1,e.animatingY=!1},r)}}}}function fd(e){return e.offsetWidth}function pd(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 md=[],hd={initializeByDefault:!0},gd={mount:function(e){for(var t in hd)hd.hasOwnProperty(t)&&!(t in e)&&(e[t]=hd[t]);md.forEach(function(t){if(t.pluginName===e.pluginName)throw`Sortable: Cannot mount plugin ${e.pluginName} more than once`}),md.push(e)},pluginEvent:function(e,t,n){var r=this;this.eventCanceled=!1,n.cancel=function(){r.eventCanceled=!0};var i=e+`Global`;md.forEach(function(r){t[r.pluginName]&&(t[r.pluginName][i]&&t[r.pluginName][i](wu({sortable:t},n)),t.options[r.pluginName]&&t[r.pluginName][e]&&t[r.pluginName][e](wu({sortable:t},n)))})},initializePlugins:function(e,t,n,r){for(var i in md.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,Du(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 md.forEach(function(r){typeof r.eventProperties==`function`&&Du(n,r.eventProperties.call(t[r.pluginName],e))}),n},modifyOption:function(e,t,n){var r;return md.forEach(function(i){e[i.pluginName]&&i.optionListeners&&typeof i.optionListeners[t]==`function`&&(r=i.optionListeners[t].call(e[i.pluginName],n))}),r}};function _d(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||=n&&n[ud],t){var h,g=t.options,_=`on`+r.charAt(0).toUpperCase()+r.substr(1);window.CustomEvent&&!Mu&&!Nu?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=wu(wu({},m),gd.getEventProperties(r,t));for(var y in v)h[y]=v[y];n&&n.dispatchEvent(h),g[_]&&g[_].call(t,h)}}var vd=[`evt`],yd=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.evt,i=ku(n,vd);gd.pluginEvent.bind(J)(e,t,wu({dragEl:G,parentEl:xd,ghostEl:K,rootEl:Sd,nextEl:Cd,lastDownEl:wd,cloneEl:q,cloneHidden:Td,dragStarted:Vd,putSortable:jd,activeSortable:J.active,originalEvent:r,oldIndex:Ed,oldDraggableIndex:Od,newIndex:Dd,newDraggableIndex:kd,hideGhostForTarget:sf,unhideGhostForTarget:cf,cloneNowHidden:function(){Td=!0},cloneNowShown:function(){Td=!1},dispatchSortableEvent:function(e){bd({sortable:t,name:e,originalEvent:r})}},i))};function bd(e){_d(wu({putSortable:jd,cloneEl:q,targetEl:G,rootEl:Sd,oldIndex:Ed,oldDraggableIndex:Od,newIndex:Dd,newDraggableIndex:kd},e))}var G,xd,K,Sd,Cd,wd,q,Td,Ed,Dd,Od,kd,Ad,jd,Md=!1,Nd=!1,Pd=[],Fd,Id,Ld,Rd,zd,Bd,Vd,Hd,Ud,Wd=!1,Gd=!1,Kd,qd,Jd=[],Yd=!1,Xd=[],Zd=typeof document<`u`,Qd=Iu,$d=Nu||Mu?`cssFloat`:`float`,ef=Zd&&!Lu&&!Iu&&`draggable`in document.createElement(`div`),tf=function(){if(Zd){if(Mu)return!1;var e=document.createElement(`x`);return e.style.cssText=`pointer-events:auto`,e.style.pointerEvents===`auto`}}(),nf=function(e,t){var n=W(e),r=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),i=Xu(e,0,t),a=Xu(e,1,t),o=i&&W(i),s=a&&W(a),c=o&&parseInt(o.marginLeft)+parseInt(o.marginRight)+Ju(i).width,l=s&&parseInt(s.marginLeft)+parseInt(s.marginRight)+Ju(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[$d]===`none`||a&&n[$d]===`none`&&c+l>r)?`vertical`:`horizontal`},rf=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},af=function(e,t){var n;return Pd.some(function(r){var i=r[ud].options.emptyInsertThreshold;if(!(!i||Zu(r))){var a=Ju(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},of=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||Tu(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},sf=function(){!tf&&K&&W(K,`display`,`none`)},cf=function(){!tf&&K&&W(K,`display`,``)};Zd&&!Lu&&document.addEventListener(`click`,function(e){if(Nd)return e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.stopImmediatePropagation&&e.stopImmediatePropagation(),Nd=!1,!1},!0);var lf=function(e){if(G){e=e.touches?e.touches[0]:e;var t=af(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[ud]._onDragOver(n)}}},uf=function(e){G&&G.parentNode[ud]._isOutsideThisEl(e.target)};function J(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=Du({},t),e[ud]=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 nf(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:J.supportPointer!==!1&&`PointerEvent`in window&&!Fu,emptyInsertThreshold:5};for(var r in gd.initializePlugins(this,e,n),n)!(r in t)&&(t[r]=n[r]);for(var i in of(t),this)i.charAt(0)===`_`&&typeof this[i]==`function`&&(this[i]=this[i].bind(this));this.nativeDraggable=t.forceFallback?!1:ef,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?U(e,`pointerdown`,this._onTapStart):(U(e,`mousedown`,this._onTapStart),U(e,`touchstart`,this._onTapStart)),this.nativeDraggable&&(U(e,`dragover`,this),U(e,`dragenter`,this)),Pd.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),Du(this,dd())}J.prototype={constructor:J,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(Hd=null)},_getDirection:function(e,t){return typeof this.options.direction==`function`?this.options.direction.call(this,e,t,G):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(bf(n),!G&&!(/mousedown|pointerdown/.test(a)&&e.button!==0||r.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&Fu&&s&&s.tagName.toUpperCase()===`SELECT`)&&(s=Hu(s,r.draggable,n,!1),!(s&&s.animated)&&wd!==s)){if(Ed=Qu(s),Od=Qu(s,r.draggable),typeof l==`function`){if(l.call(this,e,s,this)){bd({sortable:t,rootEl:c,name:`filter`,targetEl:s,toEl:n,fromEl:n}),yd(`filter`,t,{evt:e}),i&&e.cancelable&&e.preventDefault();return}}else if(l&&(l=l.split(`,`).some(function(r){if(r=Hu(c,r.trim(),n,!1),r)return bd({sortable:t,rootEl:r,name:`filter`,targetEl:s,fromEl:n,toEl:n}),yd(`filter`,t,{evt:e}),!0}),l)){i&&e.cancelable&&e.preventDefault();return}r.handle&&!Hu(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&&!G&&n.parentNode===i){var c=Ju(n);if(Sd=i,G=n,xd=G.parentNode,Cd=G.nextSibling,wd=n,Ad=a.group,J.dragged=G,Fd={target:G,clientX:(t||e).clientX,clientY:(t||e).clientY},zd=Fd.clientX-c.left,Bd=Fd.clientY-c.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,G.style[`will-change`]=`all`,s=function(){if(yd(`delayEnded`,r,{evt:e}),J.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents(),!Pu&&r.nativeDraggable&&(G.draggable=!0),r._triggerDragStart(e,t),bd({sortable:r,name:`choose`,originalEvent:e}),Wu(G,a.chosenClass,!0)},a.ignore.split(`,`).forEach(function(e){Ku(G,e.trim(),pf)}),U(o,`dragover`,lf),U(o,`mousemove`,lf),U(o,`touchmove`,lf),U(o,`mouseup`,r._onDrop),U(o,`touchend`,r._onDrop),U(o,`touchcancel`,r._onDrop),Pu&&this.nativeDraggable&&(this.options.touchStartThreshold=4,G.draggable=!0),yd(`delayStart`,this,{evt:e}),a.delay&&(!a.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(Nu||Mu))){if(J.eventCanceled){this._onDrop();return}U(o,`mouseup`,r._disableDelayedDrag),U(o,`touchend`,r._disableDelayedDrag),U(o,`touchcancel`,r._disableDelayedDrag),U(o,`mousemove`,r._delayedDragTouchMoveHandler),U(o,`touchmove`,r._delayedDragTouchMoveHandler),a.supportPointer&&U(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(){G&&pf(G),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;zu(e,`mouseup`,this._disableDelayedDrag),zu(e,`touchend`,this._disableDelayedDrag),zu(e,`touchcancel`,this._disableDelayedDrag),zu(e,`mousemove`,this._delayedDragTouchMoveHandler),zu(e,`touchmove`,this._delayedDragTouchMoveHandler),zu(e,`pointermove`,this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t||=e.pointerType==`touch`&&e,!this.nativeDraggable||t?this.options.supportPointer?U(document,`pointermove`,this._onTouchMove):t?U(document,`touchmove`,this._onTouchMove):U(document,`mousemove`,this._onTouchMove):(U(G,`dragend`,this),U(Sd,`dragstart`,this._onDragStart));try{document.selection?xf(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(Md=!1,Sd&&G){yd(`dragStarted`,this,{evt:t}),this.nativeDraggable&&U(document,`dragover`,uf);var n=this.options;!e&&Wu(G,n.dragClass,!1),Wu(G,n.ghostClass,!0),J.active=this,e&&this._appendGhost(),bd({sortable:this,name:`start`,originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(Id){this._lastX=Id.clientX,this._lastY=Id.clientY,sf();for(var e=document.elementFromPoint(Id.clientX,Id.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(Id.clientX,Id.clientY),e!==t);)t=e;if(G.parentNode[ud]._isOutsideThisEl(e),t)do{if(t[ud]){var n=void 0;if(n=t[ud]._onDragOver({clientX:Id.clientX,clientY:Id.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);cf()}},_onTouchMove:function(e){if(Fd){var t=this.options,n=t.fallbackTolerance,r=t.fallbackOffset,i=e.touches?e.touches[0]:e,a=K&&Gu(K,!0),o=K&&a&&a.a,s=K&&a&&a.d,c=Qd&&qd&&$u(qd),l=(i.clientX-Fd.clientX+r.x)/(o||1)+(c?c[0]-Jd[0]:0)/(o||1),u=(i.clientY-Fd.clientY+r.y)/(s||1)+(c?c[1]-Jd[1]:0)/(s||1);if(!J.active&&!Md){if(n&&Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))<n)return;this._onDragStart(e,!0)}if(K){a?(a.e+=l-(Ld||0),a.f+=u-(Rd||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})`;W(K,`webkitTransform`,d),W(K,`mozTransform`,d),W(K,`msTransform`,d),W(K,`transform`,d),Ld=l,Rd=u,Id=i}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!K){var e=this.options.fallbackOnBody?document.body:Sd,t=Ju(G,!0,Qd,!0,e),n=this.options;if(Qd){for(qd=e;W(qd,`position`)===`static`&&W(qd,`transform`)===`none`&&qd!==document;)qd=qd.parentNode;qd!==document.body&&qd!==document.documentElement?(qd===document&&(qd=qu()),t.top+=qd.scrollTop,t.left+=qd.scrollLeft):qd=qu(),Jd=$u(qd)}K=G.cloneNode(!0),Wu(K,n.ghostClass,!1),Wu(K,n.fallbackClass,!0),Wu(K,n.dragClass,!0),W(K,`transition`,``),W(K,`transform`,``),W(K,`box-sizing`,`border-box`),W(K,`margin`,0),W(K,`top`,t.top),W(K,`left`,t.left),W(K,`width`,t.width),W(K,`height`,t.height),W(K,`opacity`,`0.8`),W(K,`position`,Qd?`absolute`:`fixed`),W(K,`zIndex`,`100000`),W(K,`pointerEvents`,`none`),J.ghost=K,e.appendChild(K),W(K,`transform-origin`,zd/parseInt(K.style.width)*100+`% `+Bd/parseInt(K.style.height)*100+`%`)}},_onDragStart:function(e,t){var n=this,r=e.dataTransfer,i=n.options;if(yd(`dragStart`,this,{evt:e}),J.eventCanceled){this._onDrop();return}yd(`setupClone`,this),J.eventCanceled||(q=cd(G),q.removeAttribute(`id`),q.draggable=!1,q.style[`will-change`]=``,this._hideClone(),Wu(q,this.options.chosenClass,!1),J.clone=q),n.cloneId=xf(function(){yd(`clone`,n),!J.eventCanceled&&(n.options.removeCloneOnHide||Sd.insertBefore(q,G),n._hideClone(),bd({sortable:n,name:`clone`}))}),!t&&Wu(G,i.dragClass,!0),t?(Nd=!0,n._loopId=setInterval(n._emulateDragOver,50)):(zu(document,`mouseup`,n._onDrop),zu(document,`touchend`,n._onDrop),zu(document,`touchcancel`,n._onDrop),r&&(r.effectAllowed=`move`,i.setData&&i.setData.call(n,r,G)),U(document,`drop`,n),W(G,`transform`,`translateZ(0)`)),Md=!0,n._dragStartId=xf(n._dragStarted.bind(n,t,e)),U(document,`selectstart`,n),Vd=!0,Fu&&W(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=J.active,l=Ad===s,u=o.sort,d=jd||c,f,p=this,m=!1;if(Yd)return;function h(o,s){yd(o,p,wu({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 ff(Sd,t,G,r,n,Ju(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&&(Wu(G,jd?jd.options.ghostClass:c.options.ghostClass,!1),Wu(G,o.ghostClass,!0)),jd!==p&&p!==J.active?jd=p:p===J.active&&jd&&(jd=null),d===p&&(p._ignoreWhileAnimating=n),p.animateAll(function(){h(`dragOverAnimationComplete`),p._ignoreWhileAnimating=null}),p!==d&&(d.animateAll(),d._ignoreWhileAnimating=null)),(n===G&&!G.animated||n===t&&!n.animated)&&(Hd=null),!o.dragoverBubble&&!e.rootEl&&n!==document&&(G.parentNode[ud]._isOutsideThisEl(e.target),!r&&lf(e)),!o.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),m=!0}function v(){Dd=Qu(G),kd=Qu(G,o.draggable),bd({sortable:p,name:`change`,toEl:t,newIndex:Dd,newDraggableIndex:kd,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),n=Hu(n,o.draggable,t,!0),h(`dragOver`),J.eventCanceled)return m;if(G.contains(e.target)||n.animated&&n.animatingX&&n.animatingY||p._ignoreWhileAnimating===n)return _(!1);if(Nd=!1,c&&!o.disabled&&(l?u||(a=xd!==Sd):jd===this||(this.lastPutMode=Ad.checkPull(this,c,G,e))&&s.checkPut(this,c,G,e))){if(f=this._getDirection(e,n)===`vertical`,r=Ju(G),h(`dragOverValid`),J.eventCanceled)return m;if(a)return xd=Sd,g(),this._hideClone(),h(`revert`),J.eventCanceled||(Cd?Sd.insertBefore(G,Cd):Sd.appendChild(G)),_(!0);var y=Zu(t,o.draggable);if(!y||gf(e,f,this)&&!y.animated){if(y===G)return _(!1);if(y&&t===e.target&&(n=y),n&&(i=Ju(n)),ff(Sd,t,G,r,n,i,e,!!n)!==!1)return g(),y&&y.nextSibling?t.insertBefore(G,y.nextSibling):t.appendChild(G),xd=t,v(),_(!0)}else if(y&&hf(e,f,this)){var ee=Xu(t,0,o,!0);if(ee===G)return _(!1);if(n=ee,i=Ju(n),ff(Sd,t,G,r,n,i,e,!1)!==!1)return g(),t.insertBefore(G,ee),xd=t,v(),_(!0)}else if(n.parentNode===t){i=Ju(n);var b=0,te,ne=G.parentNode!==t,re=!rf(G.animated&&G.toRect||r,n.animated&&n.toRect||i,f),ie=f?`top`:`left`,ae=Yu(n,`top`,`top`)||Yu(G,`top`,`top`),oe=ae?ae.scrollTop:void 0;Hd!==n&&(te=i[ie],Wd=!1,Gd=!re&&o.invertSwap||ne),b=_f(e,n,i,f,re?1:o.swapThreshold,o.invertedSwapThreshold==null?o.swapThreshold:o.invertedSwapThreshold,Gd,Hd===n);var se;if(b!==0){var ce=Qu(G);do ce-=b,se=xd.children[ce];while(se&&(W(se,`display`)===`none`||se===K))}if(b===0||se===n)return _(!1);Hd=n,Ud=b;var x=n.nextElementSibling,le=!1;le=b===1;var ue=ff(Sd,t,G,r,n,i,e,le);if(ue!==!1)return(ue===1||ue===-1)&&(le=ue===1),Yd=!0,setTimeout(mf,30),g(),le&&!x?t.appendChild(G):n.parentNode.insertBefore(G,le?x:n),ae&&sd(ae,0,oe-ae.scrollTop),xd=G.parentNode,te!==void 0&&!Gd&&(Kd=Math.abs(te-Ju(n)[ie])),v(),_(!0)}if(t.contains(G))return _(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){zu(document,`mousemove`,this._onTouchMove),zu(document,`touchmove`,this._onTouchMove),zu(document,`pointermove`,this._onTouchMove),zu(document,`dragover`,lf),zu(document,`mousemove`,lf),zu(document,`touchmove`,lf)},_offUpEvents:function(){var e=this.el.ownerDocument;zu(e,`mouseup`,this._onDrop),zu(e,`touchend`,this._onDrop),zu(e,`pointerup`,this._onDrop),zu(e,`touchcancel`,this._onDrop),zu(document,`selectstart`,this)},_onDrop:function(e){var t=this.el,n=this.options;if(Dd=Qu(G),kd=Qu(G,n.draggable),yd(`drop`,this,{evt:e}),xd=G&&G.parentNode,Dd=Qu(G),kd=Qu(G,n.draggable),J.eventCanceled){this._nulling();return}Md=!1,Gd=!1,Wd=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Sf(this.cloneId),Sf(this._dragStartId),this.nativeDraggable&&(zu(document,`drop`,this),zu(t,`dragstart`,this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Fu&&W(document.body,`user-select`,``),W(G,`transform`,``),e&&(Vd&&(e.cancelable&&e.preventDefault(),!n.dropBubble&&e.stopPropagation()),K&&K.parentNode&&K.parentNode.removeChild(K),(Sd===xd||jd&&jd.lastPutMode!==`clone`)&&q&&q.parentNode&&q.parentNode.removeChild(q),G&&(this.nativeDraggable&&zu(G,`dragend`,this),pf(G),G.style[`will-change`]=``,Vd&&!Md&&Wu(G,jd?jd.options.ghostClass:this.options.ghostClass,!1),Wu(G,this.options.chosenClass,!1),bd({sortable:this,name:`unchoose`,toEl:xd,newIndex:null,newDraggableIndex:null,originalEvent:e}),Sd===xd?Dd!==Ed&&Dd>=0&&(bd({sortable:this,name:`update`,toEl:xd,originalEvent:e}),bd({sortable:this,name:`sort`,toEl:xd,originalEvent:e})):(Dd>=0&&(bd({rootEl:xd,name:`add`,toEl:xd,fromEl:Sd,originalEvent:e}),bd({sortable:this,name:`remove`,toEl:xd,originalEvent:e}),bd({rootEl:xd,name:`sort`,toEl:xd,fromEl:Sd,originalEvent:e}),bd({sortable:this,name:`sort`,toEl:xd,originalEvent:e})),jd&&jd.save()),J.active&&((Dd==null||Dd===-1)&&(Dd=Ed,kd=Od),bd({sortable:this,name:`end`,toEl:xd,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){yd(`nulling`,this),Sd=G=xd=K=Cd=q=wd=Td=Fd=Id=Vd=Dd=kd=Ed=Od=Hd=Ud=jd=Ad=J.dragged=J.ghost=J.clone=J.active=null,Xd.forEach(function(e){e.checked=!0}),Xd.length=Ld=Rd=0},handleEvent:function(e){switch(e.type){case`drop`:case`dragend`:this._onDrop(e);break;case`dragenter`:case`dragover`:G&&(this._onDragOver(e),df(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],Hu(t,a.draggable,this.el,!1)&&e.push(t.getAttribute(a.dataIdAttr)||yf(t));return e},sort:function(e,t){var n={},r=this.el;this.toArray().forEach(function(e,t){var i=r.children[t];Hu(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 Hu(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=gd.modifyOption(this,e,t);r===void 0?n[e]=t:n[e]=r,e===`group`&&of(n)},destroy:function(){yd(`destroy`,this);var e=this.el;e[ud]=null,zu(e,`mousedown`,this._onTapStart),zu(e,`touchstart`,this._onTapStart),zu(e,`pointerdown`,this._onTapStart),this.nativeDraggable&&(zu(e,`dragover`,this),zu(e,`dragenter`,this)),Array.prototype.forEach.call(e.querySelectorAll(`[draggable]`),function(e){e.removeAttribute(`draggable`)}),this._onDrop(),this._disableDelayedDragEvents(),Pd.splice(Pd.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!Td){if(yd(`hideClone`,this),J.eventCanceled)return;W(q,`display`,`none`),this.options.removeCloneOnHide&&q.parentNode&&q.parentNode.removeChild(q),Td=!0}},_showClone:function(e){if(e.lastPutMode!==`clone`){this._hideClone();return}if(Td){if(yd(`showClone`,this),J.eventCanceled)return;G.parentNode==Sd&&!this.options.group.revertClone?Sd.insertBefore(q,G):Cd?Sd.insertBefore(q,Cd):Sd.appendChild(q),this.options.group.revertClone&&this.animate(G,q),W(q,`display`,``),Td=!1}}};function df(e){e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),e.cancelable&&e.preventDefault()}function ff(e,t,n,r,i,a,o,s){var c,l=e[ud],u=l.options.onMove,d;return window.CustomEvent&&!Mu&&!Nu?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||Ju(t),c.willInsertAfter=s,c.originalEvent=o,e.dispatchEvent(c),u&&(d=u.call(l,c,o)),d}function pf(e){e.draggable=!1}function mf(){Yd=!1}function hf(e,t,n){var r=Ju(Xu(n.el,0,n.options,!0)),i=ld(n.el,n.options,K),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 gf(e,t,n){var r=Ju(Zu(n.el,n.options.draggable)),i=ld(n.el,n.options,K),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 _f(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&&Kd<l*i){if(!Wd&&(Ud===1?c>u+l*a/2:c<d-l*a/2)&&(Wd=!0),Wd)f=!0;else if(Ud===1?c<u+Kd:c>d-Kd)return-Ud}else if(c>u+l*(1-i)/2&&c<d-l*(1-i)/2)return vf(t)}return f||=o,f&&(c<u+l*a/2||c>d-l*a/2)?c>u+l/2?1:-1:0}function vf(e){return Qu(G)<Qu(e)?1:-1}function yf(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 bf(e){Xd.length=0;for(var t=e.getElementsByTagName(`input`),n=t.length;n--;){var r=t[n];r.checked&&Xd.push(r)}}function xf(e){return setTimeout(e,0)}function Sf(e){return clearTimeout(e)}Zd&&U(document,`touchmove`,function(e){(J.active||Md)&&e.cancelable&&e.preventDefault()}),J.utils={on:U,off:zu,css:W,find:Ku,is:function(e,t){return!!Hu(e,t,e,!1)},extend:nd,throttle:ad,closest:Hu,toggleClass:Wu,clone:cd,index:Qu,nextTick:xf,cancelNextTick:Sf,detectDirection:nf,getChild:Xu},J.get=function(e){return e[ud]},J.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&&(J.utils=wu(wu({},J.utils),e.utils)),gd.mount(e)})},J.create=function(e,t){return new J(e,t)},J.version=Au;var Cf=[],wf,Tf,Ef=!1,Df,Of,kf,Af;function jf(){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?U(document,`dragover`,this._handleAutoScroll):this.options.supportPointer?U(document,`pointermove`,this._handleFallbackAutoScroll):t.touches?U(document,`touchmove`,this._handleFallbackAutoScroll):U(document,`mousemove`,this._handleFallbackAutoScroll)},dragOverCompleted:function(e){var t=e.originalEvent;!this.options.dragOverBubble&&!t.rootEl&&this._handleAutoScroll(t)},drop:function(){this.sortable.nativeDraggable?zu(document,`dragover`,this._handleAutoScroll):(zu(document,`pointermove`,this._handleFallbackAutoScroll),zu(document,`touchmove`,this._handleFallbackAutoScroll),zu(document,`mousemove`,this._handleFallbackAutoScroll)),Nf(),Mf(),od()},nulling:function(){kf=Tf=wf=Ef=Af=Df=Of=null,Cf.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(kf=e,t||this.options.forceAutoScrollFallback||Nu||Mu||Fu){Pf(e,this.options,a,t);var o=td(a,!0);Ef&&(!Af||r!==Df||i!==Of)&&(Af&&Nf(),Af=setInterval(function(){var a=td(document.elementFromPoint(r,i),!0);a!==o&&(o=a,Mf()),Pf(e,n.options,a,t)},10),Df=r,Of=i)}else{if(!this.options.bubbleScroll||td(a,!0)===qu()){Mf();return}Pf(e,this.options,td(a,!1),!1)}}},Du(e,{pluginName:`scroll`,initializeByDefault:!0})}function Mf(){Cf.forEach(function(e){clearInterval(e.pid)}),Cf=[]}function Nf(){clearInterval(Af)}var Pf=ad(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;Tf!==n&&(Tf=n,Mf(),wf=t.scroll,u=t.scrollFn,wf===!0&&(wf=td(n,!0)));var d=0,f=wf;do{var p=f,m=Ju(p),h=m.top,g=m.bottom,_=m.left,v=m.right,y=m.width,ee=m.height,b=void 0,te=void 0,ne=p.scrollWidth,re=p.scrollHeight,ie=W(p),ae=p.scrollLeft,oe=p.scrollTop;p===c?(b=y<ne&&(ie.overflowX===`auto`||ie.overflowX===`scroll`||ie.overflowX===`visible`),te=ee<re&&(ie.overflowY===`auto`||ie.overflowY===`scroll`||ie.overflowY===`visible`)):(b=y<ne&&(ie.overflowX===`auto`||ie.overflowX===`scroll`),te=ee<re&&(ie.overflowY===`auto`||ie.overflowY===`scroll`));var se=b&&(Math.abs(v-i)<=o&&ae+y<ne)-(Math.abs(_-i)<=o&&!!ae),ce=te&&(Math.abs(g-a)<=o&&oe+ee<re)-(Math.abs(h-a)<=o&&!!oe);if(!Cf[d])for(var x=0;x<=d;x++)Cf[x]||(Cf[x]={});(Cf[d].vx!=se||Cf[d].vy!=ce||Cf[d].el!==p)&&(Cf[d].el=p,Cf[d].vx=se,Cf[d].vy=ce,clearInterval(Cf[d].pid),(se!=0||ce!=0)&&(l=!0,Cf[d].pid=setInterval(function(){r&&this.layer===0&&J.active._onTouchMove(kf);var t=Cf[this.layer].vy?Cf[this.layer].vy*s:0,n=Cf[this.layer].vx?Cf[this.layer].vx*s:0;typeof u==`function`&&u.call(J.dragged.parentNode[ud],n,t,e,kf,Cf[this.layer].el)!==`continue`||sd(Cf[this.layer].el,n,t)}.bind({layer:d}),24))),d++}while(t.bubbleScroll&&f!==c&&(f=td(f,!1)));Ef=l}},30),Ff=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 Y(){}Y.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=Xu(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:Ff},Du(Y,{pluginName:`revertOnSpill`});function If(){}If.prototype={onSpill:function(e){var t=e.dragEl,n=e.putSortable||this.sortable;n.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),n.animateAll()},drop:Ff},Du(If,{pluginName:`removeOnSpill`}),J.mount(new jf),J.mount(If,Y);function Lf(e){return e==null?e:JSON.parse(JSON.stringify(e))}function Rf(e){i()&&d(e)}function zf(e){i()?l(e):c(e)}let Bf=null,Vf=null;function Hf(e=null,t=null){Bf=e,Vf=t}function Uf(){return{data:Bf,clonedData:Vf}}const Wf=Symbol(`cloneElement`);function Gf(...e){let t=i()?.proxy,n=null,r=e[0],[,a,o]=e;Array.isArray(_(a))||(o=a,a=null);let l=null,{immediate:u=!0,clone:d=Lf,forceFallback:f,fallbackOnBody:p,customUpdate:m}=_(o)??{};function h(e){let{from:t,oldIndex:r,item:i}=e,o=Array.from(t.childNodes);n=f&&!p?o.slice(0,-1):o;let s=_(_(a)?.[r]),c=d(s);Hf(s,c),i[Wf]=c}function g(e){let t=e.item[Wf];if(!fu(t)){if(hu(e.item),s(a)){let n=[..._(a)];a.value=du(n,e.newDraggableIndex,t);return}du(_(a),e.newDraggableIndex,t)}}function y(e){let{from:t,item:n,oldIndex:r,oldDraggableIndex:i,pullMode:o,clone:c}=e;if(mu(t,n,r),o===`clone`){hu(c);return}if(s(a)){let e=[..._(a)];a.value=uu(e,i);return}uu(_(a),i)}function ee(e){if(m){m(e);return}let{from:t,item:n,oldIndex:r,oldDraggableIndex:i,newDraggableIndex:o}=e;if(hu(n),mu(t,n,r),s(a)){let e=[..._(a)];a.value=su(e,i,o);return}su(_(a),i,o)}function b(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}c(()=>{if(Hf(),o)throw o})}let te={onUpdate:ee,onStart:h,onAdd:g,onRemove:y,onEnd:b};function ne(e){let n=_(r);return e||=pu(n)?gu(n,t?.$el):n,e&&!yu(e)&&(e=e.$el),e||ou(`Root element not found`),e}function re(){let e=_(o)??{},{immediate:t,clone:n}=e,r=iu(e,[`immediate`,`clone`]);return bu(r,(e,t)=>{xu(e)&&(r[e]=(e,...n)=>(Su(e,Uf()),t(e,...n)))}),vu(a===null?{}:te,r)}let ie=e=>{e=ne(e),l&&ae.destroy(),l=new J(e,re())};v(()=>o,()=>{l&&bu(re(),(e,t)=>{l?.option(e,t)})},{deep:!0});let ae={option:(e,t)=>l?.option(e,t),destroy:()=>{l?.destroy(),l=null},save:()=>l?.save(),toArray:()=>l?.toArray(),closest:(...e)=>l?.closest(...e)};return zf(()=>{u&&ie()}),Rf(ae.destroy),ru({start:ie,pause:()=>ae?.option(`disabled`,!0),resume:()=>ae?.option(`disabled`,!1)},ae)}const Kf=[`update`,`start`,`add`,`remove`,`choose`,`unchoose`,`end`,`sort`,`filter`,`clone`,`move`,`change`],qf=r({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`,...Kf.map(e=>`on${e.replace(/^\S/,e=>e.toUpperCase())}`)],emits:[`update:modelValue`,...Kf],setup(e,{slots:t,emit:r,expose:i,attrs:a}){let s=Kf.reduce((e,t)=>{let n=`on${t.replace(/^\S/,e=>e.toUpperCase())}`;return e[n]=(...e)=>r(t,...e),e},{}),c=n(()=>{let t=h(e),{modelValue:n}=t,r=iu(t,[`modelValue`]),i=Object.entries(r).reduce((e,[t,n])=>{let r=_(n);return r!==void 0&&(e[t]=r),e},{});return ru(ru({},s),lu(ru(ru({},a),i)))}),l=n({get:()=>e.modelValue,set:e=>r(`update:modelValue`,e)}),u=p(),d=f(Gf(e.target||u,l,c));return i(d),()=>o(e.tag||`div`,{ref:u},(t?.default)?.call(t,d))}}),Jf={mounted:`mounted`,unmounted:`unmounted`};Jf.mounted,Jf.unmounted;var Yf=t(((e,t)=>{
|
|
2151
|
-
/*! For license information please see index.js.LICENSE.txt */
|
|
2152
|
-
(function(n,r){if(typeof e==`object`&&typeof t==`object`)t.exports=r(y());else if(typeof define==`function`&&define.amd)define([`blockly/core`],r);else{var i=r(typeof e==`object`?y():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})())})),Xf=e(t(((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 ee(e,t){let n=e&&e.exec(t);return n&&n.index===0}let b=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([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=b.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+)?`,oe=`(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)`,se=`\\b(0b[01]+)`,ce=(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)},x={begin:`\\\\[\\s\\S]`,relevance:0},le={scope:`string`,begin:`'`,end:`'`,illegal:`\\n`,contains:[x]},ue={scope:`string`,begin:`"`,end:`"`,illegal:`\\n`,contains:[x]},de={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/},S=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},fe=S(`//`,`$`),pe=S(`/\\*`,`\\*/`),me=S(`#`,`$`);var he=Object.freeze({__proto__:null,APOS_STRING_MODE:le,BACKSLASH_ESCAPE:x,BINARY_NUMBER_MODE:{scope:`number`,begin:se,relevance:0},BINARY_NUMBER_RE:se,COMMENT:S,C_BLOCK_COMMENT_MODE:pe,C_LINE_COMMENT_MODE:fe,C_NUMBER_MODE:{scope:`number`,begin:oe,relevance:0},C_NUMBER_RE:oe,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:me,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:de,QUOTE_STRING_MODE:ue,REGEXP_MODE:{scope:`regexp`,begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[x,{begin:/\[/,end:/\]/,relevance:0,contains:[x]}]},RE_STARTERS_RE:`!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~`,SHEBANG:ce,TITLE_MODE:{scope:`title`,begin:re,relevance:0},UNDERSCORE_IDENT_RE:ie,UNDERSCORE_TITLE_MODE:{scope:`title`,begin:ie,relevance:0}});function ge(e,t){e.input[e.index-1]===`.`&&t.ignoreMatch()}function _e(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function ve(e,t){t&&e.beginKeywords&&(e.begin=`\\b(`+e.beginKeywords.split(` `).join(`|`)+`)(?!\\.)(?=\\b|\\s)`,e.__beforeBegin=ge,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function ye(e,t){Array.isArray(e.illegal)&&(e.illegal=v(...e.illegal))}function be(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 xe(e,t){e.relevance===void 0&&(e.relevance=1)}let Se=(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},Ce=[`of`,`and`,`for`,`in`,`not`,`or`,`if`,`then`,`parent`,`list`,`value`];function we(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,we(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,Te(n[0],n[1])]})}}function Te(e,t){return t?Number(t):+!Ee(e)}function Ee(e){return Ce.includes(e.toLowerCase())}let C={},De=e=>{console.error(e)},Oe=(e,...t)=>{console.log(`WARN: ${e}`,...t)},ke=(e,t)=>{C[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),C[`${e}/${t}`]=!0)},Ae=Error();function je(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 Me(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw De(`skip, excludeBegin, returnBegin not compatible with beginScope: {}`),Ae;if(typeof e.beginScope!=`object`||e.beginScope===null)throw De(`beginScope must be object`),Ae;je(e,e.begin,{key:`beginScope`}),e.begin=te(e.begin,{joinWith:``})}}function Ne(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw De(`skip, excludeEnd, returnEnd not compatible with endScope: {}`),Ae;if(typeof e.endScope!=`object`||e.endScope===null)throw De(`endScope must be object`),Ae;je(e,e.end,{key:`endScope`}),e.end=te(e.end,{joinWith:``})}}function Pe(e){e.scope&&typeof e.scope==`object`&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function w(e){Pe(e),typeof e.beginScope==`string`&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope==`string`&&(e.endScope={_wrap:e.endScope}),Me(e),Ne(e)}function T(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;[_e,be,w,Se].forEach(e=>e(n,r)),e.compilerExtensions.forEach(e=>e(n,r)),n.__beforeBegin=null,[ve,ye,xe].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||=/\w+/,n.keywords&&=we(n.keywords,e.case_insensitive),a.keywordPatternRe=t(s,!0),r&&(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=[].concat(...n.contains.map(function(e){return E(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.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 Fe(e){return e?e.endsWithParent||Fe(e.starts):!1}function E(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return a(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:Fe(e)?a(e,{starts:e.starts?a(e.starts):null}):Object.isFrozen(e)?a(e):e}var D=`11.11.1`,O=class extends Error{constructor(e,t){super(e),this.name=`HTMLInjectionError`,this.html=t}};let k=i,A=a,j=Symbol(`nomatch`),Ie=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=de(n[1]);return t||(Oe(s.replace(`{}`,n[1])),Oe(`Falling back to no-highlight mode for this block.`,e)),t?n[1]:`no-highlight`}return t.split(/\s+/).find(e=>u(e)||de(e))}function _(e,t,n){let r=``,i=``;typeof t==`object`?(r=e,n=t.ignoreIllegals,i=t.language):(ke(`10.7.0`,`highlight(lang, code, ...args) has been deprecated.`),ke(`10.7.0`,`Please use highlight(code, options) instead.
|
|
2153
|
-
https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(n=!0);let a={code:r,language:i};_e(`before:highlight`,a);let o=a.result?a.result:y(a.language,a.code,n);return o.code=a.code,_e(`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(!x.keywords){ue.addText(S);return}let e=0;x.keywordPatternRe.lastIndex=0;let t=x.keywordPatternRe.exec(S),n=``;for(;t;){n+=S.substring(e,t.index);let r=oe.case_insensitive?t[0].toLowerCase():t[0],i=u(x,r);if(i){let[e,a]=i;if(ue.addText(n),n=``,c[r]=(c[r]||0)+1,c[r]<=7&&(fe+=a),e.startsWith(`_`))n+=t[0];else{let n=oe.classNameAliases[e]||e;m(t[0],n)}}else n+=t[0];e=x.keywordPatternRe.lastIndex,t=x.keywordPatternRe.exec(S)}n+=S.substring(e),ue.addText(n)}function f(){if(S===``)return;let e=null;if(typeof x.subLanguage==`string`){if(!t[x.subLanguage]){ue.addText(S);return}e=y(x.subLanguage,S,!0,le[x.subLanguage]),le[x.subLanguage]=e._top}else e=te(S,x.subLanguage.length?x.subLanguage:null);x.relevance>0&&(fe+=e.relevance),ue.__addSublanguage(e._emitter,e.language)}function p(){x.subLanguage==null?d():f(),S=``}function m(e,t){e!==``&&(ue.startScope(t),ue.addText(e),ue.endScope())}function h(e,t){let n=1,r=t.length-1;for(;n<=r;){if(!e._emit[n]){n++;continue}let r=oe.classNameAliases[e[n]]||e[n],i=t[n];r?m(i,r):(S=i,d(),S=``),n++}}function g(e,t){return e.scope&&typeof e.scope==`string`&&ue.openNode(oe.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(m(S,oe.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),S=``):e.beginScope._multi&&(h(e.beginScope,t),S=``)),x=Object.create(e,{parent:{value:x}}),x}function _(e,t,n){let i=ee(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 x.matcher.regexIndex===0?(S+=e[0],1):(he=!0,0)}function b(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?S+=t:(n.excludeBegin&&(S+=t),p(),!n.returnBegin&&!n.excludeBegin&&(S=t)),g(n,e),n.returnBegin?0:t.length}function ne(e){let t=e[0],r=n.substring(e.index),i=_(x,e,r);if(!i)return j;let a=x;x.endScope&&x.endScope._wrap?(p(),m(t,x.endScope._wrap)):x.endScope&&x.endScope._multi?(p(),h(x.endScope,e)):a.skip?S+=t:(a.returnEnd||a.excludeEnd||(S+=t),p(),a.excludeEnd&&(S=t));do x.scope&&ue.closeNode(),!x.skip&&!x.subLanguage&&(fe+=x.relevance),x=x.parent;while(x!==i.parent);return i.starts&&g(i.starts,e),a.returnEnd?0:t.length}function re(){let e=[];for(let t=x;t!==oe;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach(e=>ue.openNode(e))}let ie={};function ae(t,r){let a=r&&r[0];if(S+=t,a==null)return p(),0;if(ie.type===`begin`&&r.type===`end`&&ie.index===r.index&&a===``){if(S+=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 b(r);if(r.type===`illegal`&&!i){let e=Error(`Illegal lexeme "`+a+`" for mode "`+(x.scope||`<unnamed>`)+`"`);throw e.mode=x,e}else if(r.type===`end`){let e=ne(r);if(e!==j)return e}if(r.type===`illegal`&&a===``)return S+=`
|
|
2154
|
-
`,1;if(me>1e5&&me>r.index*3)throw Error(`potential infinite loop, way more iterations than matches`);return S+=a,a.length}let oe=de(e);if(!oe)throw De(s.replace(`{}`,e)),Error(`Unknown language: "`+e+`"`);let se=T(oe),ce=``,x=a||se,le={},ue=new l.__emitter(l);re();let S=``,fe=0,pe=0,me=0,he=!1;try{if(oe.__emitTokens)oe.__emitTokens(n,ue);else{for(x.matcher.considerAll();;){me++,he?he=!1:x.matcher.considerAll(),x.matcher.lastIndex=pe;let e=x.matcher.exec(n);if(!e)break;let t=ae(n.substring(pe,e.index),e);pe=e.index+t}ae(n.substring(pe))}return ue.finalize(),ce=ue.toHTML(),{language:e,value:ce,relevance:fe,illegal:!1,_emitter:ue,_top:x}}catch(t){if(t.message&&t.message.includes(`Illegal`))return{language:e,value:k(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:pe,context:n.slice(pe-100,pe+100),mode:t.mode,resultSoFar:ce},_emitter:ue};if(o)return{language:e,value:k(n),illegal:!1,relevance:0,errorRaised:t,_emitter:ue,_top:x};throw t}}function b(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=b(e),i=n.filter(de).filter(fe).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(de(e.language).supersetOf===t.language)return 1;if(de(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(_e(`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 O(`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}),_e(`after:highlightElement`,{el:e,result:i,text:r})}function ie(e){l=A(l,e)}let ae=()=>{ce(),ke(`10.6.0`,`initHighlighting() deprecated. Use highlightAll() now.`)};function oe(){ce(),ke(`10.6.0`,`initHighlightingOnLoad() deprecated. Use highlightAll() now.`)}let se=!1;function ce(){function e(){ce()}if(document.readyState===`loading`){se||window.addEventListener(`DOMContentLoaded`,e,!1),se=!0;return}document.querySelectorAll(l.cssSelector).forEach(re)}function x(n,r){let i=null;try{i=r(e)}catch(e){if(De(`Language definition for '{}' could not be registered.`.replace(`{}`,n)),o)De(e);else throw e;i=c}i.name||=n,t[n]=i,i.rawDefinition=r.bind(null,e),i.aliases&&S(i.aliases,{languageName:n})}function le(e){delete t[e];for(let t of Object.keys(i))i[t]===e&&delete i[t]}function ue(){return Object.keys(t)}function de(e){return e=(e||``).toLowerCase(),t[e]||t[i[e]]}function S(e,{languageName:t}){typeof e==`string`&&(e=[e]),e.forEach(e=>{i[e.toLowerCase()]=t})}function fe(e){let t=de(e);return t&&!t.disableAutodetect}function pe(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 me(e){pe(e),a.push(e)}function ge(e){let t=a.indexOf(e);t!==-1&&a.splice(t,1)}function _e(e,t){let n=e;a.forEach(function(e){e[n]&&e[n](t)})}function ve(e){return ke(`10.7.0`,`highlightBlock will be removed entirely in v12.0`),ke(`10.7.0`,`Please use highlightElement now.`),re(e)}Object.assign(e,{highlight:_,highlightAuto:te,highlightAll:ce,highlightElement:re,highlightBlock:ve,configure:ie,initHighlighting:ae,initHighlightingOnLoad:oe,registerLanguage:x,unregisterLanguage:le,listLanguages:ue,getLanguage:de,registerAliases:S,autoDetection:fe,inherit:A,addPlugin:me,removePlugin:ge}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=D,e.regex={concat:g,lookahead:p,either:v,optional:h,anyNumberOfTimes:m};for(let e in he)typeof he[e]==`object`&&n(he[e]);return Object.assign(e,he),e},M=Ie({});M.newInstance=()=>Ie({}),t.exports=M,M.HighlightJS=M,M.default=M}))()).default,Zf=r({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=p(e.language);v((function(){return e.language}),(function(e){t.value=e}));var r=n((function(){return e.autodetect||!t.value})),i=n((function(){return!r.value&&!Xf.getLanguage(t.value)}));return{className:n((function(){return i.value?``:`hljs `+t.value})),highlightedCode:n((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(r.value){var n=Xf.highlightAuto(e.code);return t.value=n.language??``,n.value}return(n=Xf.highlight(e.code,{language:t.value,ignoreIllegals:e.ignoreIllegals})).value}))}},render:function(){return o(`pre`,{},[o(`code`,{class:this.className,innerHTML:this.highlightedCode})])}}),Qf={install:function(e){e.component(`highlightjs`,Zf)},component:Zf};const $f=`[A-Za-z$_][0-9A-Za-z$_]*`,ep=`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(`.`),tp=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],np=`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(`.`),rp=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],ip=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],ap=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],op=[].concat(ip,np,rp);function sp(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=$f,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:$f,keyword:ep,literal:tp,built_in:op,"variable.language":ap},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),ee=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),b={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:ee},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:{_:[...np,...rp]}},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:[b],illegal:/%/},ae={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function oe(e){return t.concat(`(?!`,e.join(`|`),`)`)}let se={match:t.concat(/\b/,oe([...ip,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},ce={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},x={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},b]},le=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,ue={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(le)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[b]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:ee,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},ue,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:le,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:ee}]}]},{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:[b,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},ce,{match:`\\$[A-Za-z$_][0-9A-Za-z$_]*`,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[b]},se,ae,te,x,{match:/\$[(.]/}]}}
|
|
2155
|
-
/**
|
|
2156
|
-
* @license
|
|
2157
|
-
* Copyright 2021 Google LLC
|
|
2158
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
2159
|
-
*/
|
|
2160
|
-
var cp=[628,()=>[lp,lp],[``,``,``,``]],lp=[629,()=>[cp,cp],[``,``,``,``,``,``,``,``,``,``,``,``,``,``,``,``,``,``,``,``,``,``]];export{Rn as $,Xe as A,Qt as B,Ce as C,De as D,C as E,_t as F,fn as G,nn as H,yt as I,An as J,pn as K,Pt as L,at as M,dt as N,Ae as O,ft as P,Fn as Q,Ht as R,Se as S,Ee as T,cn as U,tn as V,ln as W,Nn as X,Mn as Y,Pn as Z,Hn as _,Yf as a,me as b,Wl as c,Fl as d,Pl as f,As as g,qs as h,Xf as i,Qe as j,je as k,Ul as l,kc as m,sp as n,qf as o,Rc as p,mn as q,Qf as r,Zl as s,lp as t,z as u,Un as v,Te as w,ge as x,re as y,Ut as z};
|