@nocobase/plugin-block-lowcode
Version:
A block for executing custom JavaScript code and dynamically updating HTML content.
10 lines (9 loc) • 26.6 kB
JavaScript
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client"),require("react-dom"),require("react"),require("@nocobase/flow-engine"),require("@formily/react"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-block-lowcode",["@nocobase/client","react-dom","react","@nocobase/flow-engine","@formily/react","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-block-lowcode"]=t(require("@nocobase/client"),require("react-dom"),require("react"),require("@nocobase/flow-engine"),require("@formily/react"),require("antd")):e["@nocobase/plugin-block-lowcode"]=t(e["@nocobase/client"],e["react-dom"],e.react,e["@nocobase/flow-engine"],e["@formily/react"],e.antd)}(self,function(e,t,n,r,o,i){return function(){var c,a,u,l,s,f,p={195:function(e,t,n){"use strict";var r=n(111);t.createRoot=r.createRoot,t.hydrateRoot=r.hydrateRoot},581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},505:function(e){"use strict";e.exports=o},772:function(t){"use strict";t.exports=e},667:function(e){"use strict";e.exports=r},721:function(e){"use strict";e.exports=i},156:function(e){"use strict";e.exports=n},111:function(e){"use strict";e.exports=t}},d={};function y(e){var t=d[e];if(void 0!==t)return t.exports;var n=d[e]={exports:{}};return p[e](n,n.exports,y),n.exports}y.m=p,y.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return y.d(t,{a:t}),t},y.d=function(e,t){for(var n in t)y.o(t,n)&&!y.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},y.f={},y.e=function(e){return Promise.all(Object.keys(y.f).reduce(function(t,n){return y.f[n](e,t),t},[]))},y.u=function(e){return""+({762:"af7720e2150a43ba",923:"73e77463d7efc4f9"})[e]+".js"},y.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),y.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c={},a="@nocobase/plugin-block-lowcode:",y.l=function(e,t,n,r){if(c[e])return void c[e].push(t);if(void 0!==n)for(var o,i,u=document.getElementsByTagName("script"),l=0;l<u.length;l++){var s=u[l];if(s.getAttribute("src")==e||s.getAttribute("data-webpack")==a+n){o=s;break}}o||(i=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,y.nc&&o.setAttribute("nonce",y.nc),o.setAttribute("data-webpack",a+n),o.src=e),c[e]=[t];var f=function(t,n){o.onerror=o.onload=null,clearTimeout(p);var r=c[e];if(delete c[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},p=setTimeout(f.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=f.bind(null,o.onerror),o.onload=f.bind(null,o.onload),i&&document.head.appendChild(o)},y.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(u=window.__nocobase_public_path__||"/").endsWith("/")||(u+="/"),y.p=u+"static/plugins/@nocobase/plugin-block-lowcode/dist/client/",l={909:0},y.f.j=function(e,t){var n=y.o(l,e)?l[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=l[e]=[t,r]});t.push(n[2]=r);var o=y.p+y.u(e),i=Error();y.l(o,function(t){if(y.o(l,e)&&(0!==(n=l[e])&&(l[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},s=function(e,t){var n,r,o=t[0],i=t[1],c=t[2],a=0;if(o.some(function(e){return 0!==l[e]})){for(n in i)y.o(i,n)&&(y.m[n]=i[n]);c&&c(y)}for(e&&e(t);a<o.length;a++)r=o[a],y.o(l,r)&&l[r]&&l[r][0](),l[r]=0},(f=self.webpackChunk_nocobase_plugin_block_lowcode=self.webpackChunk_nocobase_plugin_block_lowcode||[]).forEach(s.bind(null,0)),f.push=s.bind(null,f.push.bind(f));var b={};return!function(){"use strict";y.r(b),y.d(b,{PluginBlockLowcodeClient:function(){return q},default:function(){return B}});var e=y(772),t=y(667),n=y(721),r=y(156),o=y.n(r),i=JSON.parse('{"u2":"@nocobase/plugin-block-lowcode"}'),c=i.u2;function a(e){return"{{t(".concat(JSON.stringify(e),", { ns: ['").concat(i.u2,"', 'client'], nsMode: 'fallback' })}}")}function u(e,t,n,r,o,i,c){try{var a=e[i](c),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}var p=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t,n,o;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return t=r,n=arguments,t=l(t),e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,f()?Reflect.construct(t,n||[],l(this).constructor):t.apply(this,n)),(o="_mountedOnce")in e?Object.defineProperty(e,o,{value:!1,enumerable:!0,configurable:!0,writable:!0}):e[o]=!1,e}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&s(r,e),t=[{key:"render",value:function(){return o().createElement(n.Card,{id:"model-".concat(this.uid),className:"code-block"},o().createElement("div",{ref:this.context.ref}))}},{key:"onMount",value:function(){this._mountedOnce&&this.context.ref.current&&this.rerender(),this._mountedOnce=!0}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,t),r}(e.BlockModel);p.define({hide:!0,label:"JavaScript block"}),p.registerFlow({key:"jsSettings",title:"JavaScript settings",steps:{runJs:{title:"Write JavaScript",uiSchema:{code:{type:"string",title:"Write JavaScript","x-component":"CodeEditor","x-component-props":{minHeight:"400px",theme:"light",enableLinter:!0,wrapperStyle:{position:"fixed",inset:8}}}},uiMode:{type:"embed",props:{styles:{body:{transform:"translateX(0)"}}}},defaultParams:function(e){return{code:"// Welcome to the JavaScript block\n// Create powerful interactive components with JavaScript\nctx.element.innerHTML = `\n <div style=\"padding: 24px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; max-width: 600px;\">\n <h2 style=\"color: #1890ff; margin: 0 0 20px 0; font-size: 24px; font-weight: 600;\">\n \uD83D\uDE80 ${ctx.i18n.t('Welcome to JavaScript block', { ns: '"+c+"' })}\n </h2>\n\n <p style=\"color: #666; margin-bottom: 24px; font-size: 16px;\">\n ${ctx.i18n.t('Build interactive components with JavaScript and external libraries', { ns: '"+c+"' })}\n </p>\n\n <div style=\"background: #f8f9fa; border-radius: 8px; padding: 20px; margin-bottom: 20px;\">\n <h3 style=\"color: #333; margin: 0 0 16px 0; font-size: 18px;\">✨ ${ctx.i18n.t('Key Features', { ns: '"+c+"' })}</h3>\n <ul style=\"margin: 0; padding-left: 20px; color: #555;\">\n <li style=\"margin-bottom: 8px;\">\uD83C\uDFA8 <strong>${ctx.i18n.t('Custom JavaScript execution', { ns: '"+c+"' })}</strong> - ${ctx.i18n.t('Full programming capabilities', { ns: '"+c+"' })}</li>\n <li style=\"margin-bottom: 8px;\">\uD83D\uDCDA <strong>${ctx.i18n.t('External library support', { ns: '"+c+"' })}</strong> - ${ctx.i18n.t('Load any npm package or CDN library', { ns: '"+c+"' })}</li>\n <li style=\"margin-bottom: 8px;\">\uD83D\uDD17 <strong>${ctx.i18n.t('NocoBase API integration', { ns: '"+c+"' })}</strong> - ${ctx.i18n.t('Access your data and collections', { ns: '"+c+"' })}</li>\n <li style=\"margin-bottom: 8px;\">\uD83D\uDCA1 <strong>${ctx.i18n.t('Async/await support', { ns: '"+c+"' })}</strong> - ${ctx.i18n.t('Handle asynchronous operations', { ns: '"+c+"' })}</li>\n <li style=\"margin-bottom: 8px;\">\uD83C\uDFAF <strong>${ctx.i18n.t('Direct DOM manipulation', { ns: '"+c+"' })}</strong> - ${ctx.i18n.t('Full control over rendering', { ns: '"+c+"' })}</li>\n </ul>\n </div>\n\n <div style=\"background: #e6f7ff; border-left: 4px solid #1890ff; padding: 16px; border-radius: 4px;\">\n <p style=\"margin: 0; color: #333; font-size: 14px;\">\n \uD83D\uDCA1 <strong>${ctx.i18n.t('Ready to start?', { ns: '"+c+"' })}</strong> ${ctx.i18n.t('Replace this code with your custom JavaScript to build amazing components!', { ns: '"+c+"' })}\n </p>\n </div>\n </div>\n`;".trim()}},handler:function(e,n){var r,o,i=n.code,c=void 0===i?"":i;e.onRefReady(e.ref,(r=function(n){return function(e,t){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var u=[i,a];if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){c=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){c.label=u[1];break}if(6===u[0]&&c.label<o[1]){c.label=o[1],o=u;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(u);break}o[2]&&c.ops.pop(),c.trys.pop();continue}u=t.call(e,c)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){switch(r.label){case 0:return e.defineProperty("element",{get:function(){return new t.ElementProxy(n)}}),[4,e.runjs(c,{window:window,document:document})];case 1:return r.sent(),[2]}})},o=function(){var e=this,t=arguments;return new Promise(function(n,o){var i=r.apply(e,t);function c(e){u(i,n,o,c,a,"next",e)}function a(e){u(i,n,o,c,a,"throw",e)}c(void 0)})},function(e){return o.apply(this,arguments)}))}}}});var d=y(195);function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function h(e,t,n,r,o,i,c){try{var a=e[i](c),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function g(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function c(e){h(i,r,o,c,a,"next",e)}function a(e){h(i,r,o,c,a,"throw",e)}c(void 0)})}}function v(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function x(e){return(x=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function D(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(D=function(){return!!e})()}function S(e,t){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var u=[i,a];if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){c=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){c.label=u[1];break}if(6===u[0]&&c.label<o[1]){c.label=o[1],o=u;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(u);break}o[2]&&c.ops.pop(),c.trys.pop();continue}u=t.call(e,c)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var _=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,t,n;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return t=i,n=arguments,t=x(t),v(e=function(e,t){if(t&&("object"===k(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,D()?Reflect.construct(t,n||[],x(this).constructor):t.apply(this,n)),"ref",(0,r.createRef)()),v(e,"_mountedOnce",!1),e}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&w(i,e),t=[{key:"onMount",value:function(){this._mountedOnce&&this.ref.current&&this.rerender(),this._mountedOnce=!0}},{key:"render",value:function(){var e=this.props,t=e.loading,r=e.error;return r?o().createElement(n.Card,null,o().createElement("div",{style:{color:"red",padding:"16px"}},"Error loading code component: ",r)):o().createElement(n.Card,{id:"model-".concat(this.uid),className:"code-block"},o().createElement(n.Spin,{spinning:t,tip:"Loading code component..."},o().createElement("div",{ref:this.ref,style:{width:"100%"}})))}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(i.prototype,t),i}(e.BlockModel);_.define({label:"Code (Deprecated)",hide:!0,group:"Content",icon:"CloudOutlined",createModelOptions:{use:"LowcodeBlockModel",stepParams:{default:{executionStep:{code:"\n// Welcome to the lowcode block\n// Create powerful interactive components with JavaScript\nctx.element.innerHTML = `\n <div style=\"padding: 24px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; max-width: 600px;\">\n <h2 style=\"color: #1890ff; margin: 0 0 20px 0; font-size: 24px; font-weight: 600;\">\n \uD83D\uDE80 ${ctx.i18n.t('Welcome to code block', { ns: '"+c+"' })}\n </h2>\n \n <p style=\"color: #666; margin-bottom: 24px; font-size: 16px;\">\n ${ctx.i18n.t('Build interactive components with JavaScript and external libraries', { ns: '"+c+"' })}\n </p>\n \n <div style=\"background: #f8f9fa; border-radius: 8px; padding: 20px; margin-bottom: 20px;\">\n <h3 style=\"color: #333; margin: 0 0 16px 0; font-size: 18px;\">✨ ${ctx.i18n.t('Key Features', { ns: '"+c+"' })}</h3>\n <ul style=\"margin: 0; padding-left: 20px; color: #555;\">\n <li style=\"margin-bottom: 8px;\">\uD83C\uDFA8 <strong>${ctx.i18n.t('Custom JavaScript execution', { ns: '"+c+"' })}</strong> - ${ctx.i18n.t('Full programming capabilities', { ns: '"+c+"' })}</li>\n <li style=\"margin-bottom: 8px;\">\uD83D\uDCDA <strong>${ctx.i18n.t('External library support', { ns: '"+c+"' })}</strong> - ${ctx.i18n.t('Load any npm package or CDN library', { ns: '"+c+"' })}</li>\n <li style=\"margin-bottom: 8px;\">\uD83D\uDD17 <strong>${ctx.i18n.t('NocoBase API integration', { ns: '"+c+"' })}</strong> - ${ctx.i18n.t('Access your data and collections', { ns: '"+c+"' })}</li>\n <li style=\"margin-bottom: 8px;\">\uD83D\uDCA1 <strong>${ctx.i18n.t('Async/await support', { ns: '"+c+"' })}</strong> - ${ctx.i18n.t('Handle asynchronous operations', { ns: '"+c+"' })}</li>\n <li style=\"margin-bottom: 8px;\">\uD83C\uDFAF <strong>${ctx.i18n.t('Direct DOM manipulation', { ns: '"+c+"' })}</strong> - ${ctx.i18n.t('Full control over rendering', { ns: '"+c+"' })}</li>\n </ul>\n </div>\n \n <div style=\"background: #e6f7ff; border-left: 4px solid #1890ff; padding: 16px; border-radius: 4px;\">\n <p style=\"margin: 0; color: #333; font-size: 14px;\">\n \uD83D\uDCA1 <strong>${ctx.i18n.t('Ready to start?', { ns: '"+c+"' })}</strong> ${ctx.i18n.t('Replace this code with your custom JavaScript to build amazing components!', { ns: '"+c+"' })}\n </p>\n </div>\n </div>\n`;\n ".trim()}}}}}),_.registerFlow({key:"default",title:a("Configuration"),steps:{executionStep:{title:a("Code"),uiSchema:{code:{type:"string",title:a("Execution Code"),"x-component":"CodeEditor","x-component-props":{minHeight:"400px",theme:"light",enableLinter:!0}}},defaultParams:{code:"\n// Welcome to the code block\n// Create powerful interactive components with JavaScript\nctx.element.innerHTML = `\n <div style=\"padding: 24px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; max-width: 600px;\">\n <h2 style=\"color: #1890ff; margin: 0 0 20px 0; font-size: 24px; font-weight: 600;\">\n \uD83D\uDE80 ${ctx.i18n.t('Welcome to code block', { ns: '"+c+"' })}\n </h2>\n \n <p style=\"color: #666; margin-bottom: 24px; font-size: 16px;\">\n ${ctx.i18n.t('Build interactive components with JavaScript and external libraries', { ns: '"+c+"' })}\n </p>\n \n <div style=\"background: #f8f9fa; border-radius: 8px; padding: 20px; margin-bottom: 20px;\">\n <h3 style=\"color: #333; margin: 0 0 16px 0; font-size: 18px;\">✨ ${ctx.i18n.t('Key Features', { ns: '"+c+"' })}</h3>\n <ul style=\"margin: 0; padding-left: 20px; color: #555;\">\n <li style=\"margin-bottom: 8px;\">\uD83C\uDFA8 <strong>${ctx.i18n.t('Custom JavaScript execution', { ns: '"+c+"' })}</strong> - ${ctx.i18n.t('Full programming capabilities', { ns: '"+c+"' })}</li>\n <li style=\"margin-bottom: 8px;\">\uD83D\uDCDA <strong>${ctx.i18n.t('External library support', { ns: '"+c+"' })}</strong> - ${ctx.i18n.t('Load any npm package or CDN library', { ns: '"+c+"' })}</li>\n <li style=\"margin-bottom: 8px;\">\uD83D\uDD17 <strong>${ctx.i18n.t('NocoBase API integration', { ns: '"+c+"' })}</strong> - ${ctx.i18n.t('Access your data and collections', { ns: '"+c+"' })}</li>\n <li style=\"margin-bottom: 8px;\">\uD83D\uDCA1 <strong>${ctx.i18n.t('Async/await support', { ns: '"+c+"' })}</strong> - ${ctx.i18n.t('Handle asynchronous operations', { ns: '"+c+"' })}</li>\n <li style=\"margin-bottom: 8px;\">\uD83C\uDFAF <strong>${ctx.i18n.t('Direct DOM manipulation', { ns: '"+c+"' })}</strong> - ${ctx.i18n.t('Full control over rendering', { ns: '"+c+"' })}</li>\n </ul>\n </div>\n \n <div style=\"background: #e6f7ff; border-left: 4px solid #1890ff; padding: 16px; border-radius: 4px;\">\n <p style=\"margin: 0; color: #333; font-size: 14px;\">\n \uD83D\uDCA1 <strong>${ctx.i18n.t('Ready to start?', { ns: '"+c+"' })}</strong> ${ctx.i18n.t('Replace this code with your custom JavaScript to build amazing components!', { ns: '"+c+"' })}\n </p>\n </div>\n </div>\n`;\n ".trim()},uiMode:{type:"drawer",props:{width:"60%"}},handler:function(e,r){return g(function(){return S(this,function(i){var c;return window.location.href.endsWith("skip_nocobase_lowcode=true")?[2]:(e.model.setProps("loading",!0),e.model.setProps("error",null),e.reactView.onRefReady(e.model.ref,(c=g(function(i){var c,a,u,l,s,f,p,y,b,h;return S(this,function(g){switch(g.label){case 0:return g.trys.push([0,2,,3]),u=null==(a=e.app)||null==(c=a.requirejs)?void 0:c.requirejs,l=function(e){return new Promise(function(t,n){if(document.querySelector('link[href="'.concat(e,'"]')))return void t();var r=document.createElement("link");r.rel="stylesheet",r.href=e,r.onload=function(){return t()},r.onerror=function(){return n(Error("Failed to load CSS: ".concat(e)))},document.head.appendChild(r)})},s=function(e){return new Promise(function(t,n){if(!u)return void n(Error("requirejs is not available"));var r=Array.isArray(e)?e:[e];u(r,function(){for(var e=arguments.length,n=Array(e),o=0;o<e;o++)n[o]=arguments[o];t(1===r.length?n[0]:n)},n)})},f=function(t){return e.flowEngine.getModel(t)},p=e.flowEngine,y=e.api.request.bind(e.api),b=e.app.apiClient,[4,Function("\n return (async function(ctx) {\n ".concat(r.code,"\n }).apply(this, arguments);\n "))({Components:{antd:n},Resources:{APIResource:t.APIResource,BaseRecordResource:t.BaseRecordResource,SingleRecordResource:t.SingleRecordResource,MultiRecordResource:t.MultiRecordResource},React:o(),ReactDOM:d,flowEngine:p,element:i,model:e.model,router:e.app.router.router,i18n:e.app.i18n,request:y,requirejs:u,requireAsync:s,loadCSS:l,getModelById:f,initResource:function(t,n){if(e.model.resource)return e.model.resource;var r=new t;return r.setAPIClient(e.api),n&&(void 0===n?"undefined":k(n))==="object"&&Object.entries(n).forEach(function(e){var t=function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],c=!0,a=!1;try{for(o=o.call(e);!(c=(n=o.next()).done)&&(i.push(n.value),i.length!==t);c=!0);}catch(e){a=!0,r=e}finally{try{c||null==o.return||o.return()}finally{if(a)throw r}}return i}}(e,2)||function(e,t){if(e){if("string"==typeof e)return m(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return m(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),n=t[0],o=t[1];r.setRequestOptions(n,o)}),e.model.resource=r,r},flowContext:e,auth:{role:b.auth.role,locale:b.auth.locale,token:b.auth.token,user:e.user}})];case 1:return g.sent(),e.model.setProps("loading",!1),[3,3];case 2:return console.error("Code component execution error:",h=g.sent()),e.model.setProps("error",h.message),e.model.setProps("loading",!1),[3,3];case 3:return[2]}})}),function(e){return c.apply(this,arguments)})),[2])})})()}}}});var O=y(581);function C(e,t,n,r,o,i,c){try{var a=e[i](c),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function E(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function c(e){C(i,r,o,c,a,"next",e)}function a(e){C(i,r,o,c,a,"throw",e)}c(void 0)})}}function P(e,t,n){return(P=A()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&R(o,n.prototype),o}).apply(null,arguments)}function j(e){return(j=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function R(e,t){return(R=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function $(e){var t="function"==typeof Map?new Map:void 0;return($=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return P(e,arguments,j(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),R(n,e)})(e)}function A(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(A=function(){return!!e})()}function M(e,t){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var u=[i,a];if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){c=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){c.label=u[1];break}if(6===u[0]&&c.label<o[1]){c.label=o[1],o=u;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(u);break}o[2]&&c.ops.pop(),c.trys.pop();continue}u=t.call(e,c)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var F=(0,e.lazy)(function(){return O("imported_jvpd5h_component",Promise.all([y.e("762"),y.e("923")]).then(y.bind(y,144)))},"CodeEditor").CodeEditor,q=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=j(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,A()?Reflect.construct(e,t||[],j(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&R(n,e),t=[{key:"load",value:function(){var e=this;return E(function(){return M(this,function(t){var n;return e.flowEngine.flowSettings.registerComponents({CodeEditor:F}),e.flowEngine.registerModels({LowcodeBlockModel:_,JavaScriptBlockModel:p}),e.flowEngine.context.defineMethod("requireAsync",(n=E(function(t){return M(this,function(n){return[2,new Promise(function(n,r){e.app.requirejs.require([t],function(e){return n(e)},r)})]})}),function(e){return n.apply(this,arguments)})),[2]})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}($(e.Plugin)),B=q}(),b}()});