@meituan-nocode/vite-plugin-nocode-compiler 0.3.1-beta.9 → 0.4.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs +127 -19
  2. package/dist/index.js +118 -10
  3. package/package.json +3 -3
package/dist/index.cjs CHANGED
@@ -34,7 +34,8 @@ __export(index_exports, {
34
34
  default: () => index_default
35
35
  });
36
36
  module.exports = __toCommonJS(index_exports);
37
- var import_nocode_compiler_core = require("@meituan-nocode/nocode-compiler-core");
37
+ var import_nocode_compiler_core2 = require("@meituan-nocode/nocode-compiler-core");
38
+ var fs2 = __toESM(require("fs"), 1);
38
39
 
39
40
  // src/utils/index.ts
40
41
  var import_path = require("path");
@@ -178,11 +179,12 @@ function readJsonBody(req) {
178
179
  }
179
180
 
180
181
  // package.json
181
- var version = "0.3.1-beta.9";
182
+ var version = "0.4.1-beta.2";
182
183
 
183
184
  // src/design-mode/types.ts
184
185
  var SANDBOX_SCRIPT_PATH = "/sandbox-script.js";
185
186
  var VIRTUAL_CODE_API_PATH = "/api/virtual-code";
187
+ var SWAP_NODE_API_PATH = "/api/virtual-code/swap";
186
188
  var DEFAULT_DESIGN_MODE_OPTIONS = {
187
189
  enableVirtualCode: true,
188
190
  virtualCodeApiPath: VIRTUAL_CODE_API_PATH,
@@ -193,6 +195,8 @@ var DEFAULT_DESIGN_MODE_OPTIONS = {
193
195
 
194
196
  // src/design-mode/virtual-code.ts
195
197
  var path = __toESM(require("path"), 1);
198
+ var fs = __toESM(require("fs"), 1);
199
+ var import_nocode_compiler_core = require("@meituan-nocode/nocode-compiler-core");
196
200
  var virtualCodeMap = /* @__PURE__ */ new Map();
197
201
  function matchesDesignModePattern(id, options) {
198
202
  const exclude = options.exclude || [];
@@ -220,20 +224,96 @@ function loadVirtualCode(id, options) {
220
224
  const relativePath = extractRelativePath(id);
221
225
  if (!relativePath) return void 0;
222
226
  const code = virtualCodeMap.get(relativePath) || virtualCodeMap.get("/" + relativePath);
223
- if (code && options.verbose) {
224
- console.log(`[DesignMode] Using virtual code for: ${relativePath}`);
227
+ if (code) {
228
+ console.log(`[DesignMode] load hook: using virtual code for "${relativePath}" (${code.length} chars)`);
229
+ } else if (virtualCodeMap.size > 0) {
230
+ console.log(`[DesignMode] load hook: NO virtual code for "${relativePath}", map keys: [${Array.from(virtualCodeMap.keys()).join(", ")}]`);
225
231
  }
226
232
  return code;
227
233
  }
234
+ function createSwapNodeMiddleware(server, options, projectRoot) {
235
+ var _a;
236
+ const swapApiPath = SWAP_NODE_API_PATH;
237
+ const verbose = (_a = options.verbose) != null ? _a : false;
238
+ const compiler = new import_nocode_compiler_core.DesignModeCompiler({ rootPath: projectRoot });
239
+ return (req, res, next) => {
240
+ var _a2;
241
+ if (!((_a2 = req.url) == null ? void 0 : _a2.startsWith(swapApiPath))) {
242
+ return next();
243
+ }
244
+ if (req.method === "OPTIONS") {
245
+ res.setHeader("Access-Control-Allow-Origin", "*");
246
+ res.setHeader("Access-Control-Allow-Methods", "POST, OPTIONS");
247
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type");
248
+ res.statusCode = 204;
249
+ res.end();
250
+ return;
251
+ }
252
+ res.setHeader("Content-Type", "application/json");
253
+ res.setHeader("Access-Control-Allow-Origin", "*");
254
+ if (req.method !== "POST") {
255
+ res.statusCode = 405;
256
+ res.end(JSON.stringify({ error: "Method not allowed" }));
257
+ return;
258
+ }
259
+ let body = "";
260
+ req.on("data", (chunk) => body += chunk.toString());
261
+ req.on("end", () => {
262
+ try {
263
+ const { filePath, nodeAId, nodeBId } = JSON.parse(body);
264
+ if (!filePath || !nodeAId || !nodeBId) {
265
+ res.statusCode = 400;
266
+ res.end(JSON.stringify({ error: "filePath, nodeAId, and nodeBId are required" }));
267
+ return;
268
+ }
269
+ const fullPath = path.resolve(projectRoot, filePath);
270
+ if (!fs.existsSync(fullPath)) {
271
+ res.statusCode = 404;
272
+ res.end(JSON.stringify({ error: `File not found: ${filePath}` }));
273
+ return;
274
+ }
275
+ const cleanCode = fs.readFileSync(fullPath, "utf-8");
276
+ const result = compiler.swapNodes(cleanCode, fullPath, nodeAId, nodeBId);
277
+ if (!result) {
278
+ res.statusCode = 400;
279
+ res.end(JSON.stringify({ error: "Swap failed: nodes not found or not siblings" }));
280
+ return;
281
+ }
282
+ virtualCodeMap.set(filePath, result.dndCode);
283
+ console.log(`[DnD] virtualCodeMap key: "${filePath}", dndCode length: ${result.dndCode.length}`);
284
+ fs.writeFileSync(fullPath, result.cleanCode, "utf-8");
285
+ triggerHmrUpdate(server, fullPath, true);
286
+ if (verbose) {
287
+ console.log(`[DnD] Swap completed for: ${filePath}, ${nodeAId} \u2194 ${nodeBId}`);
288
+ }
289
+ res.end(
290
+ JSON.stringify({
291
+ success: true,
292
+ cleanCode: result.cleanCode,
293
+ dndCode: result.dndCode,
294
+ newSelectedId: result.newSelectedId
295
+ })
296
+ );
297
+ } catch (error) {
298
+ console.error("[DnD] Swap error:", error);
299
+ res.statusCode = 500;
300
+ res.end(JSON.stringify({ error: String(error) }));
301
+ }
302
+ });
303
+ };
304
+ }
228
305
  function createVirtualCodeMiddleware(server, options, projectRoot) {
229
306
  var _a;
230
307
  const apiPath = options.virtualCodeApiPath || VIRTUAL_CODE_API_PATH;
231
308
  const verbose = (_a = options.verbose) != null ? _a : false;
232
309
  return (req, res, next) => {
233
- var _a2;
310
+ var _a2, _b;
234
311
  if (!((_a2 = req.url) == null ? void 0 : _a2.startsWith(apiPath))) {
235
312
  return next();
236
313
  }
314
+ if ((_b = req.url) == null ? void 0 : _b.startsWith(SWAP_NODE_API_PATH)) {
315
+ return next();
316
+ }
237
317
  if (req.method === "OPTIONS") {
238
318
  res.setHeader("Access-Control-Allow-Origin", "*");
239
319
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
@@ -254,8 +334,6 @@ function createVirtualCodeMiddleware(server, options, projectRoot) {
254
334
  if (verbose) {
255
335
  console.log(`[DnD] Virtual code set for: ${filePath}`);
256
336
  }
257
- const fullPath = path.resolve(projectRoot, filePath);
258
- triggerHmrUpdate(server, fullPath, verbose);
259
337
  res.end(JSON.stringify({ success: true, filePath }));
260
338
  } catch (error) {
261
339
  res.statusCode = 500;
@@ -298,7 +376,7 @@ function createVirtualCodeMiddleware(server, options, projectRoot) {
298
376
 
299
377
  // src/design-mode/sandbox-script.ts
300
378
  function getSandboxScriptContent() {
301
- return '(()=>{var e={6:(e,t,n)=>{var r=n(714).Symbol;e.exports=r},12:(e,t,n)=>{var r=n(400),o=n(835),i=n(639),s=Math.max,a=Math.min;e.exports=function(e,t,n){var c,u,l,d,f,h,p=0,g=!1,m=!1,v=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){var n=c,r=u;return c=u=void 0,p=t,d=e.apply(r,n)}function b(e){var n=e-h;return void 0===h||n>=t||n<0||m&&e-p>=l}function w(){var e=o();if(b(e))return E(e);f=setTimeout(w,function(e){var n=t-(e-h);return m?a(n,l-(e-p)):n}(e))}function E(e){return f=void 0,v&&c?y(e):(c=u=void 0,d)}function N(){var e=o(),n=b(e);if(c=arguments,u=this,h=e,n){if(void 0===f)return function(e){return p=e,f=setTimeout(w,t),g?y(e):d}(h);if(m)return clearTimeout(f),f=setTimeout(w,t),y(h)}return void 0===f&&(f=setTimeout(w,t)),d}return t=i(t)||0,r(n)&&(g=!!n.leading,l=(m="maxWait"in n)?s(i(n.maxWait)||0,t):l,v="trailing"in n?!!n.trailing:v),N.cancel=function(){void 0!==f&&clearTimeout(f),p=0,c=h=u=f=void 0},N.flush=function(){return void 0===f?d:E(o())},N}},103:(e,t,n)=>{var r=n(997),o=/^\\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},271:(e,t,n)=>{var r=n(6),o=n(650),i=n(881),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?o(e):i(e)}},400:e=>{e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},583:e=>{e.exports=function(e){return null!=e&&"object"==typeof e}},603:(e,t,n)=>{var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},639:(e,t,n)=>{var r=n(103),o=n(400),i=n(975),s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=a.test(e);return n||c.test(e)?u(e.slice(2),n?2:8):s.test(e)?NaN:+e}},650:(e,t,n)=>{var r=n(6),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var o=s.call(e);return r&&(t?e[a]=n:delete e[a]),o}},714:(e,t,n)=>{var r=n(603),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();e.exports=i},835:(e,t,n)=>{var r=n(714);e.exports=function(){return r.Date.now()}},881:e=>{var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},975:(e,t,n)=>{var r=n(271),o=n(583);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},997:e=>{var t=/\\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=n(12),t=n.n(e),r=class extends Error{code;constructor(e,t){super(t),this.name="PenpalError",this.code=e}},o=e=>({name:e.name,message:e.message,stack:e.stack,penpalCode:e instanceof r?e.code:void 0}),i=Symbol("Reply"),s=class{value;transferables;#e=i;constructor(e,t){this.value=e,this.transferables=t?.transferables}},a="penpal",c=e=>"object"==typeof e&&null!==e,u=e=>"function"==typeof e,l=e=>"SYN"===e.type,d=e=>"ACK1"===e.type,f=e=>"ACK2"===e.type,h=e=>"CALL"===e.type,p=e=>"REPLY"===e.type,g=(e,t=[])=>{const n=[];for(const r of Object.keys(e)){const o=e[r];u(o)?n.push([...t,r]):c(o)&&n.push(...g(o,[...t,r]))}return n},m=e=>e.join("."),v=(e,t,n)=>({namespace:a,channel:e,type:"REPLY",callId:t,isError:!0,...n instanceof Error?{value:o(n),isSerializedErrorInstance:!0}:{value:n}}),y=crypto.randomUUID?.bind(crypto)??(()=>new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")),b=Symbol("CallOptions"),w=class{transferables;timeout;#e=b;constructor(e){this.transferables=e?.transferables,this.timeout=e?.timeout}},E=new Set(["apply","call","bind"]),N=(e,t,n=[])=>new Proxy(n.length?()=>{}:Object.create(null),{get(r,o){if("then"!==o)return n.length&&E.has(o)?Reflect.get(r,o):N(e,t,[...n,o])},apply:(t,r,o)=>e(n,o)}),S=e=>new r("CONNECTION_DESTROYED",`Method call ${m(e)}() failed due to destroyed connection`),C="deprecated-penpal",O=e=>e.join("."),x=e=>new r("TRANSMISSION_FAILED",`Unexpected message to translate: ${(e=>{try{return JSON.stringify(e)}catch(t){return String(e)}})(e)}`),T=({messenger:e,methods:t,timeout:n,channel:o,log:i})=>{const b=y();let E;const O=[];let x=!1;const T=g(t),{promise:I,resolve:M,reject:P}=(()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}})(),A=void 0!==n?setTimeout(()=>{P(new r("CONNECTION_TIMEOUT",`Connection timed out after ${n}ms`))},n):void 0,R=()=>{for(const e of O)e()},L=()=>{if(x)return;O.push(((e,t,n,o)=>{let i=!1;const l=async l=>{if(i)return;if(!h(l))return;o?.(`Received ${m(l.methodPath)}() call`,l);const{methodPath:d,args:f,id:p}=l;let g,y;try{const e=((e,t)=>{const n=e.reduce((e,t)=>c(e)?e[t]:void 0,t);return u(n)?n:void 0})(d,t);if(!e)throw new r("METHOD_NOT_FOUND",`Method \\`${m(d)}\\` is not found.`);let o=await e(...f);o instanceof s&&(y=o.transferables,o=await o.value),g={namespace:a,channel:n,type:"REPLY",callId:p,value:o}}catch(e){g=v(n,p,e)}if(!i)try{o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g,y)}catch(t){throw"DataCloneError"===t.name&&(g=v(n,p,t),o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g)),t}};return e.addMessageHandler(l),()=>{i=!0,e.removeMessageHandler(l)}})(e,t,o,i));const{remoteProxy:n,destroy:l}=((e,t,n)=>{let o=!1;const i=new Map,s=e=>{if(!p(e))return;const{callId:t,value:o,isError:s,isSerializedErrorInstance:a}=e,c=i.get(t);c&&(i.delete(t),n?.(`Received ${m(c.methodPath)}() call`,e),s?c.reject(a?(({name:e,message:t,stack:n,penpalCode:o})=>{const i=o?new r(o,t):new Error(t);return i.name=e,i.stack=n,i})(o):o):c.resolve(o))};return e.addMessageHandler(s),{remoteProxy:N((s,c)=>{if(o)throw S(s);const u=y(),l=c[c.length-1],d=l instanceof w,{timeout:f,transferables:h}=d?l:{},p=d?c.slice(0,-1):c;return new Promise((o,c)=>{const l=void 0!==f?window.setTimeout(()=>{i.delete(u),c(new r("METHOD_CALL_TIMEOUT",`Method call ${m(s)}() timed out after ${f}ms`))},f):void 0;i.set(u,{methodPath:s,resolve:o,reject:c,timeoutId:l});try{const r={namespace:a,channel:t,type:"CALL",id:u,methodPath:s,args:p};n?.(`Sending ${m(s)}() call`,r),e.sendMessage(r,h)}catch(e){c(new r("TRANSMISSION_FAILED",e.message))}})},n),destroy:()=>{o=!0,e.removeMessageHandler(s);for(const{methodPath:e,reject:t,timeoutId:n}of i.values())clearTimeout(n),t(S(e));i.clear()}}})(e,o,i);O.push(l),clearTimeout(A),x=!0,M({remoteProxy:n,destroy:R})},D=()=>{const t={namespace:a,type:"SYN",channel:o,participantId:b};i?.("Sending handshake SYN",t);try{e.sendMessage(t)}catch(e){P(new r("TRANSMISSION_FAILED",e.message))}},F=t=>{l(t)&&(t=>{if(i?.("Received handshake SYN",t),t.participantId===E&&E!==C)return;if(E=t.participantId,D(),!(b>E||E===C))return;const n={namespace:a,channel:o,type:"ACK1",methodPaths:T};i?.("Sending handshake ACK1",n);try{e.sendMessage(n)}catch(e){return void P(new r("TRANSMISSION_FAILED",e.message))}})(t),d(t)&&(t=>{i?.("Received handshake ACK1",t);const n={namespace:a,channel:o,type:"ACK2"};i?.("Sending handshake ACK2",n);try{e.sendMessage(n)}catch(e){return void P(new r("TRANSMISSION_FAILED",e.message))}L()})(t),f(t)&&(e=>{i?.("Received handshake ACK2",e),L()})(t)};return e.addMessageHandler(F),O.push(()=>e.removeMessageHandler(F)),D(),I},I=new WeakSet,M=class{#t;#n;#r;#o;#i;#s=new Set;#a;#c=!1;constructor({remoteWindow:e,allowedOrigins:t}){if(!e)throw new r("INVALID_ARGUMENT","remoteWindow must be defined");this.#t=e,this.#n=t?.length?t:[window.origin]}initialize=({log:e,validateReceivedMessage:t})=>{this.#r=e,this.#o=t,window.addEventListener("message",this.#u)};sendMessage=(e,t)=>{if(l(e)){const n=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:n,transfer:t})}if(d(e)||this.#c){const n=this.#c?(e=>{if(d(e))return{penpal:"synAck",methodNames:e.methodPaths.map(O)};if(h(e))return{penpal:"call",id:e.id,methodName:O(e.methodPath),args:e.args};if(p(e))return e.isError?{penpal:"reply",id:e.callId,resolution:"rejected",...e.isSerializedErrorInstance?{returnValue:e.value,returnValueIsError:!0}:{returnValue:e.value}}:{penpal:"reply",id:e.callId,resolution:"fulfilled",returnValue:e.value};throw x(e)})(e):e,r=this.#l(e);return void this.#t.postMessage(n,{targetOrigin:r,transfer:t})}if(f(e)){const{port1:n,port2:r}=new MessageChannel;this.#a=n,n.addEventListener("message",this.#d),n.start();const o=[r,...t||[]],i=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:i,transfer:o})}if(!this.#a)throw new r("TRANSMISSION_FAILED","Cannot send message because the MessagePort is not connected");this.#a.postMessage(e,{transfer:t})};addMessageHandler=e=>{this.#s.add(e)};removeMessageHandler=e=>{this.#s.delete(e)};destroy=()=>{window.removeEventListener("message",this.#u),this.#f(),this.#s.clear()};#h=e=>this.#n.some(t=>t instanceof RegExp?t.test(e):t===e||"*"===t);#l=e=>{if(l(e))return"*";if(!this.#i)throw new r("TRANSMISSION_FAILED","Cannot send message because the remote origin is not established");return"null"===this.#i&&this.#n.includes("*")?"*":this.#i};#f=()=>{this.#a?.removeEventListener("message",this.#d),this.#a?.close(),this.#a=void 0};#u=({source:e,origin:t,ports:n,data:r})=>{if(e===this.#t){if((e=>c(e)&&"penpal"in e)(r)){this.#r?.("Please upgrade the child window to the latest version of Penpal."),this.#c=!0;try{r=(e=>{if("syn"===e.penpal)return{namespace:a,channel:void 0,type:"SYN",participantId:C};if("ack"===e.penpal)return{namespace:a,channel:void 0,type:"ACK2"};if("call"===e.penpal)return{namespace:a,channel:void 0,type:"CALL",id:e.id,methodPath:(t=e.methodName,t.split(".")),args:e.args};var t;if("reply"===e.penpal)return"fulfilled"===e.resolution?{namespace:a,channel:void 0,type:"REPLY",callId:e.id,value:e.returnValue}:{namespace:a,channel:void 0,type:"REPLY",callId:e.id,isError:!0,...e.returnValueIsError?{value:e.returnValue,isSerializedErrorInstance:!0}:{value:e.returnValue}};throw x(e)})(r)}catch(e){return void this.#r?.(`Failed to translate deprecated message: ${e.message}`)}}if(this.#o?.(r))if(this.#h(t)){if(l(r)&&(this.#f(),this.#i=t),f(r)&&!this.#c){if(this.#a=n[0],!this.#a)return void this.#r?.("Ignoring ACK2 because it did not include a MessagePort");this.#a.addEventListener("message",this.#d),this.#a.start()}for(const e of this.#s)e(r)}else this.#r?.(`Received a message from origin \\`${t}\\` which did not match allowed origins \\`[${this.#n.join(", ")}]\\``)}};#d=({data:e})=>{if(this.#o?.(e))for(const t of this.#s)t(e)}},P=document,A=window,R=Array.prototype,L=R.filter,D=R.indexOf,F=R.map,j=R.push,_=R.reverse,$=R.slice,k=R.splice,W=/^#[\\w-]*$/,z=/^\\.[\\w-]*$/,H=/<.+>/,U=/^\\w+$/;function V(e,t){return void 0===t&&(t=P),z.test(e)?t.getElementsByClassName(e.slice(1)):U.test(e)?t.getElementsByTagName(e):t.querySelectorAll(e)}function B(e,t){if(void 0===t&&(t=P),e){if(e.__cash)return e;var n=e;if(te(e)){if(t.__cash&&(t=t[0]),!(n=W.test(e)?t.getElementById(e.slice(1)):H.test(e)?$e(e):V(e,t)))return}else if(ee(e))return this.ready(e);(n.nodeType||n===A)&&(n=[n]),this.length=n.length;for(var r=0,o=this.length;r<o;r++)this[r]=n[r]}}function Y(e,t){return new B(e,t)}var K=Y.fn=Y.prototype=B.prototype={constructor:Y,__cash:!0,length:0,splice:k};K.get=function(e){return void 0===e?$.call(this):this[e<0?e+this.length:e]},K.eq=function(e){return Y(this.get(e))},K.first=function(){return this.eq(0)},K.last=function(){return this.eq(-1)},K.map=function(e){return Y(F.call(this,function(t,n){return e.call(t,n,t)}))},K.slice=function(){return Y($.apply(this,arguments))};var q=/(?:^\\w|[A-Z]|\\b\\w)/g,G=/[\\s-_]+/g;function X(e){return e.replace(q,function(e,t){return e[t?"toUpperCase":"toLowerCase"]()}).replace(G,"")}function J(e,t){for(var n=0,r=e.length;n<r&&!1!==t.call(e[n],e[n],n,e);n++);}Y.camelCase=X,Y.each=J,K.each=function(e){return J(this,function(t,n){return e.call(t,n,t)}),this},K.removeProp=function(e){return this.each(function(t,n){delete n[e]})},Y.extend=K.extend=function(e){void 0===e&&(e=this);for(var t=arguments,n=t.length,r=n<2?0:1;r<n;r++)for(var o in t[r])e[o]=t[r][o];return e};var Z=1;function Q(e,t){var n=e&&(e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector);return!!n&&n.call(e,t)}function ee(e){return"function"==typeof e}function te(e){return"string"==typeof e}function ne(e){return!isNaN(parseFloat(e))&&isFinite(e)}Y.guid=Z,Y.matches=Q,Y.isFunction=ee,Y.isString=te,Y.isNumeric=ne;var re=Array.isArray;function oe(e){return te(e)?function(t,n){return Q(n,e)}:e.__cash?function(t,n){return e.is(n)}:function(e,t,n){return t===n}}Y.isArray=re,K.prop=function(e,t){if(e){if(te(e))return arguments.length<2?this[0]&&this[0][e]:this.each(function(n,r){r[e]=t});for(var n in e)this.prop(n,e[n]);return this}},K.filter=function(e){if(!e)return Y();var t=ee(e)?e:oe(e);return Y(L.call(this,function(n,r){return t.call(n,r,n,e)}))};var ie=/\\S+/g;function se(e){return te(e)&&e.match(ie)||[]}function ae(e){return e.filter(function(e,t,n){return n.indexOf(e)===t})}function ce(e,t,n){if(1===e.nodeType){var r=A.getComputedStyle(e,null);return t?n?r.getPropertyValue(t):r[t]:r}}function ue(e,t){return parseInt(ce(e,t),10)||0}K.hasClass=function(e){var t=se(e),n=!1;return t.length&&this.each(function(e,r){return!(n=r.classList.contains(t[0]))}),n},K.removeAttr=function(e){var t=se(e);return t.length?this.each(function(e,n){J(t,function(e){n.removeAttribute(e)})}):this},K.attr=function(e,t){if(e){if(te(e)){if(arguments.length<2){if(!this[0])return;var n=this[0].getAttribute(e);return null===n?void 0:n}return null===t?this.removeAttr(e):this.each(function(n,r){r.setAttribute(e,t)})}for(var r in e)this.attr(r,e[r]);return this}},K.toggleClass=function(e,t){var n=se(e),r=void 0!==t;return n.length?this.each(function(e,o){J(n,function(e){r?t?o.classList.add(e):o.classList.remove(e):o.classList.toggle(e)})}):this},K.addClass=function(e){return this.toggleClass(e,!0)},K.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},Y.unique=ae,K.add=function(e,t){return Y(ae(this.get().concat(Y(e,t).get())))};var le=/^--/;function de(e){return le.test(e)}var fe={},he=P.createElement("div").style,pe=["webkit","moz","ms","o"];function ge(e,t){if(void 0===t&&(t=de(e)),t)return e;if(!fe[e]){var n=X(e),r=""+n.charAt(0).toUpperCase()+n.slice(1);J((n+" "+pe.join(r+" ")+r).split(" "),function(t){if(t in he)return fe[e]=t,!1})}return fe[e]}Y.prefixedProp=ge;var me={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function ve(e,t,n){return void 0===n&&(n=de(e)),n||me[e]||!ne(t)?t:t+"px"}K.css=function(e,t){if(te(e)){var n=de(e);return e=ge(e,n),arguments.length<2?this[0]&&ce(this[0],e,n):e?(t=ve(e,t,n),this.each(function(r,o){1===o.nodeType&&(n?o.style.setProperty(e,t):o.style[e]=t)})):this}for(var r in e)this.css(r,e[r]);return this};var ye="__cashData",be=/^data-(.*)/;function we(e){return e[ye]=e[ye]||{}}function Ee(e,t){var n=we(e);if(t){if(!(t in n)){var r=e.dataset?e.dataset[t]||e.dataset[X(t)]:Y(e).attr("data-"+t);if(void 0!==r){try{r=JSON.parse(r)}catch(e){}n[t]=r}}return n[t]}return n}function Ne(e,t){return ue(e,"border"+(t?"Left":"Top")+"Width")+ue(e,"padding"+(t?"Left":"Top"))+ue(e,"padding"+(t?"Right":"Bottom"))+ue(e,"border"+(t?"Right":"Bottom")+"Width")}function Se(e,t){for(var n=0,r=t.length;n<r;n++)if(e.indexOf(t[n])<0)return!1;return!0}function Ce(e,t,n){J(e[n],function(e){e[0];var r=e[1];t.removeEventListener(n,r)}),delete e[n]}Y.hasData=function(e){return ye in e},K.data=function(e,t){var n=this;if(!e){if(!this[0])return;return J(this[0].attributes,function(e){var t=e.name.match(be);t&&n.data(t[1])}),Ee(this[0])}if(te(e))return void 0===t?this[0]&&Ee(this[0],e):this.each(function(n,r){return function(e,t,n){we(e)[t]=n}(r,e,t)});for(var r in e)this.data(r,e[r]);return this},K.removeData=function(e){return this.each(function(t,n){return function(e,t){void 0===t?delete e[ye]:delete we(e)[t]}(n,e)})},J(["Width","Height"],function(e){K["inner"+e]=function(){if(this[0])return this[0]===A?A["inner"+e]:this[0]["client"+e]}}),J(["width","height"],function(e,t){K[e]=function(n){return this[0]?arguments.length?(n=parseInt(n,10),this.each(function(r,o){if(1===o.nodeType){var i=ce(o,"boxSizing");o.style[e]=ve(e,n+("border-box"===i?Ne(o,!t):0))}})):this[0]===A?this[0][X("outer-"+e)]:this[0].getBoundingClientRect()[e]-Ne(this[0],!t):void 0===n?void 0:this}}),J(["Width","Height"],function(e,t){K["outer"+e]=function(n){if(this[0])return this[0]===A?A["outer"+e]:this[0]["offset"+e]+(n?ue(this[0],"margin"+(t?"Top":"Left"))+ue(this[0],"margin"+(t?"Bottom":"Right")):0)}});var Oe="__cashEvents";function xe(e){return e[Oe]=e[Oe]||{}}function Te(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Ie(e,t,n,r){var o=xe(e);if(t){var i=o[t];if(!i)return;r&&(r.guid=r.guid||Z++),o[t]=i.filter(function(o){var i=o[0],s=o[1];if(r&&s.guid!==r.guid||!Se(i,n))return!0;e.removeEventListener(t,s)})}else if(n&&n.length)for(t in o)Ie(e,t,n,r);else for(t in o)Ce(o,e,t)}K.off=function(e,t){var n=this;return void 0===e?this.each(function(e,t){return Ie(t)}):J(se(e),function(e){var r=Te(e),o=r[0],i=r[1];n.each(function(e,n){return Ie(n,o,i,t)})}),this},K.on=function(e,t,n,r){var o=this;if(!te(e)){for(var i in e)this.on(i,t,e[i]);return this}return ee(t)&&(n=t,t=!1),J(se(e),function(e){var i=Te(e),s=i[0],a=i[1];o.each(function(e,o){var i=function e(i){if(!i.namespace||Se(a,i.namespace.split("."))){var c=o;if(t){for(var u=i.target;!Q(u,t);){if(u===o)return;if(!(u=u.parentNode))return}c=u}i.namespace=i.namespace||"";var l=n.call(c,i,i.data);r&&Ie(o,s,a,e),!1===l&&(i.preventDefault(),i.stopPropagation())}};i.guid=n.guid=n.guid||Z++,function(e,t,n,r){r.guid=r.guid||Z++;var o=xe(e);o[t]=o[t]||[],o[t].push([n,r]),e.addEventListener(t,r)}(o,s,a,i)})}),this},K.one=function(e,t,n){return this.on(e,t,n,!0)},K.ready=function(e){var t=function(){return e(Y)};return"loading"!==P.readyState?setTimeout(t):P.addEventListener("DOMContentLoaded",t),this},K.trigger=function(e,t){var n=e;if(te(e)){var r=Te(e),o=r[0],i=r[1];(n=P.createEvent("HTMLEvents")).initEvent(o,!0,!0),n.namespace=i.join(".")}return n.data=t,this.each(function(e,t){t.dispatchEvent(n)})};var Me=/select-one/i,Pe=/select-multiple/i;function Ae(e){var t=e.type;return Me.test(t)?function(e){return e.selectedIndex<0?null:e.options[e.selectedIndex].value}(e):Pe.test(t)?function(e){var t=[];return J(e.options,function(e){!e.selected||e.disabled||e.parentNode.disabled||t.push(e.value)}),t}(e):e.value}var Re=/%20/g,Le=/file|reset|submit|button|image/i,De=/radio|checkbox/i;K.serialize=function(){var e="";return this.each(function(t,n){J(n.elements||[n],function(t){if(!t.disabled&&t.name&&"FIELDSET"!==t.tagName&&!Le.test(t.type)&&(!De.test(t.type)||t.checked)){var n=Ae(t);void 0!==n&&J(re(n)?n:[n],function(n){e+=function(e,t){return"&"+encodeURIComponent(e)+"="+encodeURIComponent(t).replace(Re,"+")}(t.name,n)})}})}),e.substr(1)},K.val=function(e){return void 0===e?this[0]&&Ae(this[0]):this.each(function(t,n){var r=Pe.test(n.type),o=null===e?r?[]:"":e;r&&re(o)?J(n.options,function(e){e.selected=o.indexOf(e.value)>=0}):n.value=o})},K.clone=function(){return this.map(function(e,t){return t.cloneNode(!0)})},K.detach=function(){return this.each(function(e,t){t.parentNode&&t.parentNode.removeChild(t)})};var Fe,je=/^\\s*<(\\w+)[^>]*>/,_e=/^\\s*<(\\w+)\\s*\\/?>(?:<\\/\\1>)?\\s*$/;function $e(e){if(function(){if(!Fe){var e=P.createElement("table"),t=P.createElement("tr");Fe={"*":P.createElement("div"),tr:P.createElement("tbody"),td:t,th:t,thead:e,tbody:e,tfoot:e}}}(),!te(e))return[];if(_e.test(e))return[P.createElement(RegExp.$1)];var t=je.test(e)&&RegExp.$1,n=Fe[t]||Fe["*"];return n.innerHTML=e,Y(n.childNodes).detach().get()}function ke(e,t,n){if(void 0!==t){var r=te(t);!r&&t.length?J(t,function(t){return ke(e,t,n)}):J(e,r?function(e){e.insertAdjacentHTML(n?"afterbegin":"beforeend",t)}:function(e,r){return function(e,t,n){n?e.insertBefore(t,e.childNodes[0]):e.appendChild(t)}(e,r?t.cloneNode(!0):t,n)})}}Y.parseHTML=$e,K.empty=function(){var e=this[0];if(e)for(;e.firstChild;)e.removeChild(e.firstChild);return this},K.append=function(){var e=this;return J(arguments,function(t){ke(e,t)}),this},K.appendTo=function(e){return ke(Y(e),this),this},K.html=function(e){if(void 0===e)return this[0]&&this[0].innerHTML;var t=e.nodeType?e[0].outerHTML:e;return this.each(function(e,n){n.innerHTML=t})},K.insertAfter=function(e){var t=this;return Y(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n.nextSibling)})}),this},K.after=function(){var e=this;return J(_.apply(arguments),function(t){_.apply(Y(t).slice()).insertAfter(e)}),this},K.insertBefore=function(e){var t=this;return Y(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n)})}),this},K.before=function(){var e=this;return J(arguments,function(t){Y(t).insertBefore(e)}),this},K.prepend=function(){var e=this;return J(arguments,function(t){ke(e,t,!0)}),this},K.prependTo=function(e){return ke(Y(e),_.apply(this.slice()),!0),this},K.remove=function(){return this.detach().off()},K.replaceWith=function(e){var t=this;return this.each(function(n,r){var o=r.parentNode;if(o){var i=n?Y(e).clone():Y(e);if(!i[0])return t.remove(),!1;o.replaceChild(i[0],r),Y(i[0]).after(i.slice(1))}})},K.replaceAll=function(e){return Y(e).replaceWith(this),this},K.text=function(e){return void 0===e?this[0]?this[0].textContent:"":this.each(function(t,n){n.textContent=e})};var We=P.documentElement;K.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+A.pageYOffset-We.clientTop,left:t.left+A.pageXOffset-We.clientLeft}}},K.offsetParent=function(){return Y(this[0]&&this[0].offsetParent)},K.position=function(){var e=this[0];if(e)return{left:e.offsetLeft,top:e.offsetTop}},K.children=function(e){var t=[];return this.each(function(e,n){j.apply(t,n.children)}),t=Y(ae(t)),e?t.filter(function(t,n){return Q(n,e)}):t},K.contents=function(){var e=[];return this.each(function(t,n){j.apply(e,"IFRAME"===n.tagName?[n.contentDocument]:n.childNodes)}),Y(e.length&&ae(e))},K.find=function(e){for(var t=[],n=0,r=this.length;n<r;n++){var o=V(e,this[n]);o.length&&j.apply(t,o)}return Y(t.length&&ae(t))},K.has=function(e){var t=te(e)?function(t,n){return!!V(e,n).length}:function(t,n){return n.contains(e)};return this.filter(t)},K.is=function(e){if(!e||!this[0])return!1;var t=oe(e),n=!1;return this.each(function(r,o){return!(n=t(r,o,e))}),n},K.next=function(){return Y(this[0]&&this[0].nextElementSibling)},K.not=function(e){if(!e||!this[0])return this;var t=oe(e);return this.filter(function(n,r){return!t(n,r,e)})},K.parent=function(){var e=[];return this.each(function(t,n){n&&n.parentNode&&e.push(n.parentNode)}),Y(ae(e))},K.index=function(e){var t=e?Y(e)[0]:this[0],n=e?this:Y(t).parent().children();return D.call(n,t)},K.closest=function(e){return e&&this[0]?this.is(e)?this.filter(e):this.parent().closest(e):Y()},K.parents=function(e){var t,n=[];return this.each(function(r,o){for(t=o;t&&t.parentNode&&t!==P.body.parentNode;)t=t.parentNode,(!e||e&&Q(t,e))&&n.push(t)}),Y(ae(n))},K.prev=function(){return Y(this[0]&&this[0].previousElementSibling)},K.siblings=function(){var e=this[0];return this.parent().children().filter(function(t,n){return n!==e})};const ze=Y,He=new class{getFiberNode(e){try{const t=Object.keys(e).find(e=>e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"));return t?e[t]:null}catch(e){return console.warn("[ReactFiberService] Error getting fiber node:",e),null}}getDebugOwner(e){const t=this.getFiberNode(e);return t?._debugOwner??null}getDebugSource(e){const t=this.getFiberNode(e);return t?._debugSource??null}getOwnerDebugSource(e){const t=this.getDebugOwner(e);return t?._debugSource??null}hasDirectSourceInfo(e){return!!e.getAttribute("data-nocode-id")||!!this.getDebugSource(e)}hasOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return!1;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n&&n.length>0}getOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return null;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n?n:null}isSelectableElement(e){if(this.hasDirectSourceInfo(e))return!0;const t=this.getFiberNode(e),n=this.getOwnerDebugSource(e);return!!(t?.return&&5!==t.return.tag&&this.hasOwnerNocodeId(e)&&n)}isComponent(e){if(!this.isSelectableElement(e))return!1;if(e.getAttribute("data-nocode-components-name"))return!0;if(this.getDebugSource(e))return!1;const t=this.getFiberNode(e);return!(!t?.return||5===t.return.tag)}getComponentName(e){const t=e.getAttribute("data-nocode-tag-name");if(t)return t;const n=this.getDebugOwner(e);if(n?.type){const e=n.type;if("function"==typeof e){const t=e.displayName||e.name||"Unknown";return this.normalizeComponentName(t)}if("string"==typeof e)return e}return e.tagName.toLowerCase()}normalizeComponentName(e){return e.replace(/\\d+$/,"")}getComponentProps(e){if(!this.isComponent(e))return;const t=this.getDebugOwner(e);return t?.memoizedProps?this.sanitizeProps(t.memoizedProps):void 0}sanitizeProps(e){const t={};for(const[n,r]of Object.entries(e)){if("children"===n||n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}sanitizeValue(e){if(null===e)return null;if(void 0===e)return;if("function"==typeof e)return;if("symbol"==typeof e)return;if("object"!=typeof e)return e;if("$$typeof"in e)return;if(e instanceof Node)return;if(Array.isArray(e)){const t=[];for(const n of e){const e=this.sanitizeValue(n);void 0!==e&&t.push(e)}return t}const t={};for(const[n,r]of Object.entries(e)){if(n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}buildComponentInfo(e){const t=this.isComponent(e),n={isComponent:t,componentType:t?"component":"host",name:t?this.getComponentName(e):e.tagName.toLowerCase()},r=e.getAttribute("data-nocode-components-name"),o=e.getAttribute("data-nocode-components-version");if(r&&(n.componentsName=r),o&&(n.componentsVersion=o),t){const t=this.getComponentProps(e)??{},r=this.removeSpecialProps(t);n.props=r}return n}removeSpecialProps(e){const t={};for(const[n,r]of Object.entries(e))"componentsName"!==n&&"componentsVersion"!==n&&(n.startsWith("data-nocode-")||(t[n]=r));return t}},Ue="data-dnd";function Ve(e){if(!e)return{};const t=e.split(":");if(t.length>=3){const n=t.pop(),r=t.pop(),o=t.join(":");return{id:e,filename:decodeURIComponent(o),component:r,codeId:n}}return 2===t.length?{id:e,component:t[0],codeId:t[1]}:{id:e}}const Be=`[${Ue}]`;function Ye(e){return document.querySelector(`[${Ue}="${e}"]`)}const Ke=(e,t)=>{const n=e.getBoundingClientRect(),{x:r,y:o}=((e,t)=>{let n=e.x,r=e.y;if(t){const e=t.getBoundingClientRect();n-=e.left,r-=e.top}return{x:n,y:r}})({x:n.left,y:n.top},t);return{width:e.offsetWidth,height:e.offsetHeight,top:o,left:r}},qe=(e,t)=>{const n=Ke(e,t),r=function(e){return e.dataset}(e),o=Ge(e),i=Xe(e),s=(e=>{const t=window.getComputedStyle(e);return{display:t.display,flexDirection:t.flexDirection,flexWrap:t.flexWrap,position:t.position}})(e),a=r.dnd||"",c=Ve(a),u=function(e){return He.buildComponentInfo(e)}(e),l=function(e){return"true"===e.getAttribute("data-nocode-container-placeholder")}(e),d=(e=>{const t=e.querySelectorAll(`:scope > ${Be}`);if(!t.length)return[];const n=[];return t.forEach(e=>{const t=e;n.push(Ke(t))}),n})(e);return{id:a,codeId:c.codeId,name:c.component||e.tagName.toLowerCase(),filename:c.filename,bounding:n,display:o,computedStyle:s,text:i,containerPlaceholder:l||void 0,componentInfo:u,childrenBoundings:d.length>0?d:void 0}},Ge=e=>ze(e).css("display"),Xe=e=>{const t=[];return e.childNodes.forEach(e=>{if(e.nodeType===Node.TEXT_NODE){const n=e.textContent?.trim()||"";n&&t.push(n)}}),t.join(" ")};function Je(e){const t=["div","p","section","article","main","header","footer","nav","h1","h2","h3","h4","h5","h6","span","a","button","i","input","textarea","select","label","form","ul","ol","li","table","thead","tbody","tr","td","th","img","video","audio","canvas","svg"];try{const n=e.tagName.toLowerCase();if(!t.includes(n))return!1;const r=window.getComputedStyle(e);if("none"===r.display||"hidden"===r.visibility||"0"===r.opacity)return!1;const o=e.getBoundingClientRect();return!("inline"!==r.display&&"inline-block"!==r.display&&(0===o.width||0===o.height))}catch(e){return console.warn("Element validation failed:",e),!1}}function Ze(e,t=20){let n=e,r=0;for(;n&&r<t;){if(n.getAttribute(Ue))return n;n=n.parentElement,r++}return null}function Qe(e){const t=window.getComputedStyle(e),n={};for(let e=0;e<t.length;e++){const r=t[e];n[r]=t.getPropertyValue(r)}return n}let et=null;function tt(e){return(...t)=>{try{const n=e(...t);return n&&"function"==typeof n.then?n.catch(n=>(console.error(`Async error in ${e.name}:`,n),console.error("Error stack:",n.stack),console.error("Function arguments:",t),null)):n}catch(n){return console.error(`Sync error in ${e.name}:`,n),n instanceof Error&&console.error("Error stack:",n.stack),console.error("Function arguments:",t),null}}}const nt={getDraggableParentsData:(e,t)=>{const n=function(e,t){const n=((e,t)=>{const n=document.elementFromPoint(e,t);if(!n)return null;const r=n=>{if(n?.shadowRoot){const o=n.shadowRoot.elementFromPoint(e,t);return o===n?n:o?.shadowRoot?r(o):o||n}return n};return r(n)})(e,t);if(!n)return null;let r=n;if(!Je(r)){let e=r.parentElement,t=0;const n=20;for(;e&&t<n;){if(Je(e)){r=e;break}e=e.parentElement,t++}if(!Je(r))return null}const o=Ze(r);return o&&Je(o)?o:null}(e.x,e.y);if(!n)return;const r=(e=>{const t=ze(e).closest(Be).get(0),n=ze(e).parents(Be).get();return n[0]!==t&&n.unshift(t),n})(n);if(r.length){if(t){const e=r.map(e=>qe(e));return{...e[0],computedStyle:Qe(n),parents:e.slice(1)}}return{...qe(r[0]),computedStyle:Qe(r[0])}}},getElementDataById:e=>{const t=Ye(e);if(t)return{...qe(t),computedStyle:Qe(t)};console.warn("[getElementDataById] Element not found for domId:",e)},getEditableTextElementAtPosition:e=>{const t=function(e,t){if(document.caretPositionFromPoint){const n=document.caretPositionFromPoint(e,t);return n?.offsetNode??null}if(document.caretRangeFromPoint){const n=document.caretRangeFromPoint(e,t);return n?.startContainer??null}return document.elementFromPoint(e,t)}(e.x,e.y);if(!t)return void console.log("[getEditableTextElementAtPosition] No node at point:",e);if(t.nodeType!==Node.TEXT_NODE)return void console.log("[getEditableTextElementAtPosition] Not a text node:",t.nodeType);const n=t.textContent?.trim();if(!n)return void console.log("[getEditableTextElementAtPosition] Empty text node");const r=t.parentElement;if(!r)return void console.log("[getEditableTextElementAtPosition] No parent element");const o=Ze(r);if(o){if(function(e){const t=e.childNodes;let n=!1;for(let e=0;e<t.length;e++){const r=t[e];if(r.nodeType===Node.ELEMENT_NODE)return!1;if(r.nodeType===Node.TEXT_NODE){const e=r.textContent?.trim();e&&(n=!0)}}return n}(o))return console.log("[getEditableTextElementAtPosition] Found editable text element:",o.tagName,o.textContent),{...qe(o),computedStyle:Qe(o)};console.log("[getEditableTextElementAtPosition] Element has child elements, cannot edit directly:",o.tagName)}else console.log("[getEditableTextElementAtPosition] No marked element found")},updateElementTextContent:(e,t)=>{const n=Ye(e);return n?(n.textContent=t,!0):(console.warn("[updateElementTextContent] Element not found:",e),!1)},scrollToElement:e=>{const t=Ye(e);return t?(t.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),!0):(console.warn("[scrollToElement] Element not found for domId:",e),!1)},scrollPageBy:(e,t)=>(window.scrollBy(e,t),!0),highlightElement:e=>{if(et&&(et.style.outline="",et.style.outlineOffset="",et=null),!e)return!0;const t=Ye(e);return t?(t.style.outline="2px solid rgba(54, 210, 190, 0.8)",t.style.outlineOffset="-1px",et=t,!0):(console.warn("[highlightElement] Element not found:",e),!1)},getProjectLibVersions:function(){try{const e=document.body;if(!e)return console.warn("[sandbox] document.body is not available"),null;const t=e.getAttribute("data-nocode-lib-versions");if(!t)return console.warn("[sandbox] data-nocode-lib-versions attribute not found on body"),null;const n=JSON.parse(t);return"object"!=typeof n||null===n?(console.warn("[sandbox] data-nocode-lib-versions is not a valid object"),null):n}catch(e){return console.error("[sandbox] Failed to parse data-nocode-lib-versions:",e),null}},getCompilerVersion:function(){try{const e=document.body;return e?e.getAttribute("data-nocode-compiler-version"):null}catch(e){return console.error("[sandbox] Failed to get compiler version:",e),null}},getRuntimeNodeTree:()=>{try{const e=document.querySelectorAll(Be);if(!e.length)return[];const t=new Map;e.forEach(e=>{const n=e.getAttribute(Ue)||"";if(!n)return;const r=Ve(n);t.set(e,{id:n,component:r.component||e.tagName.toLowerCase(),children:[]})});const n=[];e.forEach(e=>{const r=t.get(e);if(!r)return;let o,i=e.parentElement;for(;i;){if(t.has(i)){o=t.get(i);break}i=i.parentElement}o?o.children.push(r):n.push(r)});const r=e=>{e.children&&0===e.children.length?delete e.children:e.children&&e.children.forEach(r)};return n.forEach(r),n}catch(e){return console.error("[sandbox] Failed to build runtime node tree:",e),[]}}},rt=Object.fromEntries(Object.entries(nt).map(([e,t])=>[e,tt(t)])),ot="nocode-design-mode";let it=null,st=!1,at=null;const ct=t()(()=>{it?.onWindowMutated&&(console.log(`${ot} - Notifying parent of DOM mutation`),it.onWindowMutated({added:{},removed:{}}))},100),ut=async()=>{if(st||it)return it;st=!0,console.log(`${ot} - Creating penpal connection`);const e=(({messenger:e,methods:t={},timeout:n,channel:o,log:i})=>{if(!e)throw new r("INVALID_ARGUMENT","messenger must be defined");if(I.has(e))throw new r("INVALID_ARGUMENT","A messenger can only be used for a single connection");I.add(e);const s=[e.destroy],u=(e=>{let t,n=!1;return(...r)=>(n||(n=!0,t=e(...r)),t)})(t=>{if(t){const t={namespace:a,channel:o,type:"DESTROY"};try{e.sendMessage(t)}catch(e){}}for(const e of s)e();i?.("Connection destroyed")}),l=e=>(e=>c(e)&&e.namespace===a)(e)&&e.channel===o;return{promise:(async()=>{try{e.initialize({log:i,validateReceivedMessage:l}),e.addMessageHandler(e=>{(e=>"DESTROY"===e.type)(e)&&u(!1)});const{remoteProxy:r,destroy:a}=await T({messenger:e,methods:t,timeout:n,channel:o,log:i});return s.push(a),r}catch(e){throw u(!0),e}})(),destroy:()=>{u(!0)}}})({messenger:new M({remoteWindow:window===window.top?(console.warn(`${ot} - Not in an iframe, using window.parent as fallback`),window.parent):window.parent===window.top?window.parent:window.top?(console.log(`${ot} - Using window.top for nested iframe scenario`),window.top):window.parent,allowedOrigins:["*"]}),methods:rt});return e.promise.then(e=>{if(!e)return console.error(`${ot} - Failed to setup penpal connection: child is null`),void lt();it=e,console.log(`${ot} - Penpal connection set`),(()=>{if(at)return;at=new MutationObserver(e=>{e.some(e=>{const t=e.target;return"SCRIPT"!==t.tagName&&"STYLE"!==t.tagName&&("attributes"!==e.type||"style"===e.attributeName||"class"===e.attributeName)})&&ct()});const e=()=>{document.body&&at&&(at.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"],characterData:!0}),console.log(`${ot} - MutationObserver started`))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()})()}).finally(()=>{st=!1}),e.promise.catch(e=>{console.error(`${ot} - Failed to setup penpal connection:`,e),lt()}),it},lt=t()(()=>{st||(console.log(`${ot} - Reconnecting to penpal parent`),it=null,ut())},1e3);ut()})()})();';
379
+ return '(()=>{var e={6:(e,t,n)=>{var r=n(714).Symbol;e.exports=r},12:(e,t,n)=>{var r=n(400),o=n(835),i=n(639),s=Math.max,a=Math.min;e.exports=function(e,t,n){var c,u,l,d,f,h,p=0,g=!1,m=!1,v=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){var n=c,r=u;return c=u=void 0,p=t,d=e.apply(r,n)}function b(e){var n=e-h;return void 0===h||n>=t||n<0||m&&e-p>=l}function w(){var e=o();if(b(e))return E(e);f=setTimeout(w,function(e){var n=t-(e-h);return m?a(n,l-(e-p)):n}(e))}function E(e){return f=void 0,v&&c?y(e):(c=u=void 0,d)}function N(){var e=o(),n=b(e);if(c=arguments,u=this,h=e,n){if(void 0===f)return function(e){return p=e,f=setTimeout(w,t),g?y(e):d}(h);if(m)return clearTimeout(f),f=setTimeout(w,t),y(h)}return void 0===f&&(f=setTimeout(w,t)),d}return t=i(t)||0,r(n)&&(g=!!n.leading,l=(m="maxWait"in n)?s(i(n.maxWait)||0,t):l,v="trailing"in n?!!n.trailing:v),N.cancel=function(){void 0!==f&&clearTimeout(f),p=0,c=h=u=f=void 0},N.flush=function(){return void 0===f?d:E(o())},N}},103:(e,t,n)=>{var r=n(997),o=/^\\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},271:(e,t,n)=>{var r=n(6),o=n(650),i=n(881),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?o(e):i(e)}},400:e=>{e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},583:e=>{e.exports=function(e){return null!=e&&"object"==typeof e}},603:(e,t,n)=>{var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},639:(e,t,n)=>{var r=n(103),o=n(400),i=n(975),s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=a.test(e);return n||c.test(e)?u(e.slice(2),n?2:8):s.test(e)?NaN:+e}},650:(e,t,n)=>{var r=n(6),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var o=s.call(e);return r&&(t?e[a]=n:delete e[a]),o}},714:(e,t,n)=>{var r=n(603),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();e.exports=i},835:(e,t,n)=>{var r=n(714);e.exports=function(){return r.Date.now()}},881:e=>{var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},975:(e,t,n)=>{var r=n(271),o=n(583);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},997:e=>{var t=/\\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=n(12),t=n.n(e),r=class extends Error{code;constructor(e,t){super(t),this.name="PenpalError",this.code=e}},o=e=>({name:e.name,message:e.message,stack:e.stack,penpalCode:e instanceof r?e.code:void 0}),i=Symbol("Reply"),s=class{value;transferables;#e=i;constructor(e,t){this.value=e,this.transferables=t?.transferables}},a="penpal",c=e=>"object"==typeof e&&null!==e,u=e=>"function"==typeof e,l=e=>"SYN"===e.type,d=e=>"ACK1"===e.type,f=e=>"ACK2"===e.type,h=e=>"CALL"===e.type,p=e=>"REPLY"===e.type,g=(e,t=[])=>{const n=[];for(const r of Object.keys(e)){const o=e[r];u(o)?n.push([...t,r]):c(o)&&n.push(...g(o,[...t,r]))}return n},m=e=>e.join("."),v=(e,t,n)=>({namespace:a,channel:e,type:"REPLY",callId:t,isError:!0,...n instanceof Error?{value:o(n),isSerializedErrorInstance:!0}:{value:n}}),y=crypto.randomUUID?.bind(crypto)??(()=>new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")),b=Symbol("CallOptions"),w=class{transferables;timeout;#e=b;constructor(e){this.transferables=e?.transferables,this.timeout=e?.timeout}},E=new Set(["apply","call","bind"]),N=(e,t,n=[])=>new Proxy(n.length?()=>{}:Object.create(null),{get(r,o){if("then"!==o)return n.length&&E.has(o)?Reflect.get(r,o):N(e,t,[...n,o])},apply:(t,r,o)=>e(n,o)}),S=e=>new r("CONNECTION_DESTROYED",`Method call ${m(e)}() failed due to destroyed connection`),C="deprecated-penpal",x=e=>e.join("."),O=e=>new r("TRANSMISSION_FAILED",`Unexpected message to translate: ${(e=>{try{return JSON.stringify(e)}catch(t){return String(e)}})(e)}`),I=({messenger:e,methods:t,timeout:n,channel:o,log:i})=>{const b=y();let E;const x=[];let O=!1;const I=g(t),{promise:M,resolve:T,reject:P}=(()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}})(),A=void 0!==n?setTimeout(()=>{P(new r("CONNECTION_TIMEOUT",`Connection timed out after ${n}ms`))},n):void 0,R=()=>{for(const e of x)e()},L=()=>{if(O)return;x.push(((e,t,n,o)=>{let i=!1;const l=async l=>{if(i)return;if(!h(l))return;o?.(`Received ${m(l.methodPath)}() call`,l);const{methodPath:d,args:f,id:p}=l;let g,y;try{const e=((e,t)=>{const n=e.reduce((e,t)=>c(e)?e[t]:void 0,t);return u(n)?n:void 0})(d,t);if(!e)throw new r("METHOD_NOT_FOUND",`Method \\`${m(d)}\\` is not found.`);let o=await e(...f);o instanceof s&&(y=o.transferables,o=await o.value),g={namespace:a,channel:n,type:"REPLY",callId:p,value:o}}catch(e){g=v(n,p,e)}if(!i)try{o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g,y)}catch(t){throw"DataCloneError"===t.name&&(g=v(n,p,t),o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g)),t}};return e.addMessageHandler(l),()=>{i=!0,e.removeMessageHandler(l)}})(e,t,o,i));const{remoteProxy:n,destroy:l}=((e,t,n)=>{let o=!1;const i=new Map,s=e=>{if(!p(e))return;const{callId:t,value:o,isError:s,isSerializedErrorInstance:a}=e,c=i.get(t);c&&(i.delete(t),n?.(`Received ${m(c.methodPath)}() call`,e),s?c.reject(a?(({name:e,message:t,stack:n,penpalCode:o})=>{const i=o?new r(o,t):new Error(t);return i.name=e,i.stack=n,i})(o):o):c.resolve(o))};return e.addMessageHandler(s),{remoteProxy:N((s,c)=>{if(o)throw S(s);const u=y(),l=c[c.length-1],d=l instanceof w,{timeout:f,transferables:h}=d?l:{},p=d?c.slice(0,-1):c;return new Promise((o,c)=>{const l=void 0!==f?window.setTimeout(()=>{i.delete(u),c(new r("METHOD_CALL_TIMEOUT",`Method call ${m(s)}() timed out after ${f}ms`))},f):void 0;i.set(u,{methodPath:s,resolve:o,reject:c,timeoutId:l});try{const r={namespace:a,channel:t,type:"CALL",id:u,methodPath:s,args:p};n?.(`Sending ${m(s)}() call`,r),e.sendMessage(r,h)}catch(e){c(new r("TRANSMISSION_FAILED",e.message))}})},n),destroy:()=>{o=!0,e.removeMessageHandler(s);for(const{methodPath:e,reject:t,timeoutId:n}of i.values())clearTimeout(n),t(S(e));i.clear()}}})(e,o,i);x.push(l),clearTimeout(A),O=!0,T({remoteProxy:n,destroy:R})},D=()=>{const t={namespace:a,type:"SYN",channel:o,participantId:b};i?.("Sending handshake SYN",t);try{e.sendMessage(t)}catch(e){P(new r("TRANSMISSION_FAILED",e.message))}},F=t=>{l(t)&&(t=>{if(i?.("Received handshake SYN",t),t.participantId===E&&E!==C)return;if(E=t.participantId,D(),!(b>E||E===C))return;const n={namespace:a,channel:o,type:"ACK1",methodPaths:I};i?.("Sending handshake ACK1",n);try{e.sendMessage(n)}catch(e){return void P(new r("TRANSMISSION_FAILED",e.message))}})(t),d(t)&&(t=>{i?.("Received handshake ACK1",t);const n={namespace:a,channel:o,type:"ACK2"};i?.("Sending handshake ACK2",n);try{e.sendMessage(n)}catch(e){return void P(new r("TRANSMISSION_FAILED",e.message))}L()})(t),f(t)&&(e=>{i?.("Received handshake ACK2",e),L()})(t)};return e.addMessageHandler(F),x.push(()=>e.removeMessageHandler(F)),D(),M},M=new WeakSet,T=class{#t;#n;#r;#o;#i;#s=new Set;#a;#c=!1;constructor({remoteWindow:e,allowedOrigins:t}){if(!e)throw new r("INVALID_ARGUMENT","remoteWindow must be defined");this.#t=e,this.#n=t?.length?t:[window.origin]}initialize=({log:e,validateReceivedMessage:t})=>{this.#r=e,this.#o=t,window.addEventListener("message",this.#u)};sendMessage=(e,t)=>{if(l(e)){const n=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:n,transfer:t})}if(d(e)||this.#c){const n=this.#c?(e=>{if(d(e))return{penpal:"synAck",methodNames:e.methodPaths.map(x)};if(h(e))return{penpal:"call",id:e.id,methodName:x(e.methodPath),args:e.args};if(p(e))return e.isError?{penpal:"reply",id:e.callId,resolution:"rejected",...e.isSerializedErrorInstance?{returnValue:e.value,returnValueIsError:!0}:{returnValue:e.value}}:{penpal:"reply",id:e.callId,resolution:"fulfilled",returnValue:e.value};throw O(e)})(e):e,r=this.#l(e);return void this.#t.postMessage(n,{targetOrigin:r,transfer:t})}if(f(e)){const{port1:n,port2:r}=new MessageChannel;this.#a=n,n.addEventListener("message",this.#d),n.start();const o=[r,...t||[]],i=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:i,transfer:o})}if(!this.#a)throw new r("TRANSMISSION_FAILED","Cannot send message because the MessagePort is not connected");this.#a.postMessage(e,{transfer:t})};addMessageHandler=e=>{this.#s.add(e)};removeMessageHandler=e=>{this.#s.delete(e)};destroy=()=>{window.removeEventListener("message",this.#u),this.#f(),this.#s.clear()};#h=e=>this.#n.some(t=>t instanceof RegExp?t.test(e):t===e||"*"===t);#l=e=>{if(l(e))return"*";if(!this.#i)throw new r("TRANSMISSION_FAILED","Cannot send message because the remote origin is not established");return"null"===this.#i&&this.#n.includes("*")?"*":this.#i};#f=()=>{this.#a?.removeEventListener("message",this.#d),this.#a?.close(),this.#a=void 0};#u=({source:e,origin:t,ports:n,data:r})=>{if(e===this.#t){if((e=>c(e)&&"penpal"in e)(r)){this.#r?.("Please upgrade the child window to the latest version of Penpal."),this.#c=!0;try{r=(e=>{if("syn"===e.penpal)return{namespace:a,channel:void 0,type:"SYN",participantId:C};if("ack"===e.penpal)return{namespace:a,channel:void 0,type:"ACK2"};if("call"===e.penpal)return{namespace:a,channel:void 0,type:"CALL",id:e.id,methodPath:(t=e.methodName,t.split(".")),args:e.args};var t;if("reply"===e.penpal)return"fulfilled"===e.resolution?{namespace:a,channel:void 0,type:"REPLY",callId:e.id,value:e.returnValue}:{namespace:a,channel:void 0,type:"REPLY",callId:e.id,isError:!0,...e.returnValueIsError?{value:e.returnValue,isSerializedErrorInstance:!0}:{value:e.returnValue}};throw O(e)})(r)}catch(e){return void this.#r?.(`Failed to translate deprecated message: ${e.message}`)}}if(this.#o?.(r))if(this.#h(t)){if(l(r)&&(this.#f(),this.#i=t),f(r)&&!this.#c){if(this.#a=n[0],!this.#a)return void this.#r?.("Ignoring ACK2 because it did not include a MessagePort");this.#a.addEventListener("message",this.#d),this.#a.start()}for(const e of this.#s)e(r)}else this.#r?.(`Received a message from origin \\`${t}\\` which did not match allowed origins \\`[${this.#n.join(", ")}]\\``)}};#d=({data:e})=>{if(this.#o?.(e))for(const t of this.#s)t(e)}},P=document,A=window,R=Array.prototype,L=R.filter,D=R.indexOf,F=R.map,$=R.push,j=R.reverse,_=R.slice,k=R.splice,W=/^#[\\w-]*$/,z=/^\\.[\\w-]*$/,H=/<.+>/,U=/^\\w+$/;function V(e,t){return void 0===t&&(t=P),z.test(e)?t.getElementsByClassName(e.slice(1)):U.test(e)?t.getElementsByTagName(e):t.querySelectorAll(e)}function B(e,t){if(void 0===t&&(t=P),e){if(e.__cash)return e;var n=e;if(te(e)){if(t.__cash&&(t=t[0]),!(n=W.test(e)?t.getElementById(e.slice(1)):H.test(e)?_e(e):V(e,t)))return}else if(ee(e))return this.ready(e);(n.nodeType||n===A)&&(n=[n]),this.length=n.length;for(var r=0,o=this.length;r<o;r++)this[r]=n[r]}}function Y(e,t){return new B(e,t)}var q=Y.fn=Y.prototype=B.prototype={constructor:Y,__cash:!0,length:0,splice:k};q.get=function(e){return void 0===e?_.call(this):this[e<0?e+this.length:e]},q.eq=function(e){return Y(this.get(e))},q.first=function(){return this.eq(0)},q.last=function(){return this.eq(-1)},q.map=function(e){return Y(F.call(this,function(t,n){return e.call(t,n,t)}))},q.slice=function(){return Y(_.apply(this,arguments))};var K=/(?:^\\w|[A-Z]|\\b\\w)/g,G=/[\\s-_]+/g;function X(e){return e.replace(K,function(e,t){return e[t?"toUpperCase":"toLowerCase"]()}).replace(G,"")}function J(e,t){for(var n=0,r=e.length;n<r&&!1!==t.call(e[n],e[n],n,e);n++);}Y.camelCase=X,Y.each=J,q.each=function(e){return J(this,function(t,n){return e.call(t,n,t)}),this},q.removeProp=function(e){return this.each(function(t,n){delete n[e]})},Y.extend=q.extend=function(e){void 0===e&&(e=this);for(var t=arguments,n=t.length,r=n<2?0:1;r<n;r++)for(var o in t[r])e[o]=t[r][o];return e};var Z=1;function Q(e,t){var n=e&&(e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector);return!!n&&n.call(e,t)}function ee(e){return"function"==typeof e}function te(e){return"string"==typeof e}function ne(e){return!isNaN(parseFloat(e))&&isFinite(e)}Y.guid=Z,Y.matches=Q,Y.isFunction=ee,Y.isString=te,Y.isNumeric=ne;var re=Array.isArray;function oe(e){return te(e)?function(t,n){return Q(n,e)}:e.__cash?function(t,n){return e.is(n)}:function(e,t,n){return t===n}}Y.isArray=re,q.prop=function(e,t){if(e){if(te(e))return arguments.length<2?this[0]&&this[0][e]:this.each(function(n,r){r[e]=t});for(var n in e)this.prop(n,e[n]);return this}},q.filter=function(e){if(!e)return Y();var t=ee(e)?e:oe(e);return Y(L.call(this,function(n,r){return t.call(n,r,n,e)}))};var ie=/\\S+/g;function se(e){return te(e)&&e.match(ie)||[]}function ae(e){return e.filter(function(e,t,n){return n.indexOf(e)===t})}function ce(e,t,n){if(1===e.nodeType){var r=A.getComputedStyle(e,null);return t?n?r.getPropertyValue(t):r[t]:r}}function ue(e,t){return parseInt(ce(e,t),10)||0}q.hasClass=function(e){var t=se(e),n=!1;return t.length&&this.each(function(e,r){return!(n=r.classList.contains(t[0]))}),n},q.removeAttr=function(e){var t=se(e);return t.length?this.each(function(e,n){J(t,function(e){n.removeAttribute(e)})}):this},q.attr=function(e,t){if(e){if(te(e)){if(arguments.length<2){if(!this[0])return;var n=this[0].getAttribute(e);return null===n?void 0:n}return null===t?this.removeAttr(e):this.each(function(n,r){r.setAttribute(e,t)})}for(var r in e)this.attr(r,e[r]);return this}},q.toggleClass=function(e,t){var n=se(e),r=void 0!==t;return n.length?this.each(function(e,o){J(n,function(e){r?t?o.classList.add(e):o.classList.remove(e):o.classList.toggle(e)})}):this},q.addClass=function(e){return this.toggleClass(e,!0)},q.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},Y.unique=ae,q.add=function(e,t){return Y(ae(this.get().concat(Y(e,t).get())))};var le=/^--/;function de(e){return le.test(e)}var fe={},he=P.createElement("div").style,pe=["webkit","moz","ms","o"];function ge(e,t){if(void 0===t&&(t=de(e)),t)return e;if(!fe[e]){var n=X(e),r=""+n.charAt(0).toUpperCase()+n.slice(1);J((n+" "+pe.join(r+" ")+r).split(" "),function(t){if(t in he)return fe[e]=t,!1})}return fe[e]}Y.prefixedProp=ge;var me={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function ve(e,t,n){return void 0===n&&(n=de(e)),n||me[e]||!ne(t)?t:t+"px"}q.css=function(e,t){if(te(e)){var n=de(e);return e=ge(e,n),arguments.length<2?this[0]&&ce(this[0],e,n):e?(t=ve(e,t,n),this.each(function(r,o){1===o.nodeType&&(n?o.style.setProperty(e,t):o.style[e]=t)})):this}for(var r in e)this.css(r,e[r]);return this};var ye="__cashData",be=/^data-(.*)/;function we(e){return e[ye]=e[ye]||{}}function Ee(e,t){var n=we(e);if(t){if(!(t in n)){var r=e.dataset?e.dataset[t]||e.dataset[X(t)]:Y(e).attr("data-"+t);if(void 0!==r){try{r=JSON.parse(r)}catch(e){}n[t]=r}}return n[t]}return n}function Ne(e,t){return ue(e,"border"+(t?"Left":"Top")+"Width")+ue(e,"padding"+(t?"Left":"Top"))+ue(e,"padding"+(t?"Right":"Bottom"))+ue(e,"border"+(t?"Right":"Bottom")+"Width")}function Se(e,t){for(var n=0,r=t.length;n<r;n++)if(e.indexOf(t[n])<0)return!1;return!0}function Ce(e,t,n){J(e[n],function(e){e[0];var r=e[1];t.removeEventListener(n,r)}),delete e[n]}Y.hasData=function(e){return ye in e},q.data=function(e,t){var n=this;if(!e){if(!this[0])return;return J(this[0].attributes,function(e){var t=e.name.match(be);t&&n.data(t[1])}),Ee(this[0])}if(te(e))return void 0===t?this[0]&&Ee(this[0],e):this.each(function(n,r){return function(e,t,n){we(e)[t]=n}(r,e,t)});for(var r in e)this.data(r,e[r]);return this},q.removeData=function(e){return this.each(function(t,n){return function(e,t){void 0===t?delete e[ye]:delete we(e)[t]}(n,e)})},J(["Width","Height"],function(e){q["inner"+e]=function(){if(this[0])return this[0]===A?A["inner"+e]:this[0]["client"+e]}}),J(["width","height"],function(e,t){q[e]=function(n){return this[0]?arguments.length?(n=parseInt(n,10),this.each(function(r,o){if(1===o.nodeType){var i=ce(o,"boxSizing");o.style[e]=ve(e,n+("border-box"===i?Ne(o,!t):0))}})):this[0]===A?this[0][X("outer-"+e)]:this[0].getBoundingClientRect()[e]-Ne(this[0],!t):void 0===n?void 0:this}}),J(["Width","Height"],function(e,t){q["outer"+e]=function(n){if(this[0])return this[0]===A?A["outer"+e]:this[0]["offset"+e]+(n?ue(this[0],"margin"+(t?"Top":"Left"))+ue(this[0],"margin"+(t?"Bottom":"Right")):0)}});var xe="__cashEvents";function Oe(e){return e[xe]=e[xe]||{}}function Ie(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Me(e,t,n,r){var o=Oe(e);if(t){var i=o[t];if(!i)return;r&&(r.guid=r.guid||Z++),o[t]=i.filter(function(o){var i=o[0],s=o[1];if(r&&s.guid!==r.guid||!Se(i,n))return!0;e.removeEventListener(t,s)})}else if(n&&n.length)for(t in o)Me(e,t,n,r);else for(t in o)Ce(o,e,t)}q.off=function(e,t){var n=this;return void 0===e?this.each(function(e,t){return Me(t)}):J(se(e),function(e){var r=Ie(e),o=r[0],i=r[1];n.each(function(e,n){return Me(n,o,i,t)})}),this},q.on=function(e,t,n,r){var o=this;if(!te(e)){for(var i in e)this.on(i,t,e[i]);return this}return ee(t)&&(n=t,t=!1),J(se(e),function(e){var i=Ie(e),s=i[0],a=i[1];o.each(function(e,o){var i=function e(i){if(!i.namespace||Se(a,i.namespace.split("."))){var c=o;if(t){for(var u=i.target;!Q(u,t);){if(u===o)return;if(!(u=u.parentNode))return}c=u}i.namespace=i.namespace||"";var l=n.call(c,i,i.data);r&&Me(o,s,a,e),!1===l&&(i.preventDefault(),i.stopPropagation())}};i.guid=n.guid=n.guid||Z++,function(e,t,n,r){r.guid=r.guid||Z++;var o=Oe(e);o[t]=o[t]||[],o[t].push([n,r]),e.addEventListener(t,r)}(o,s,a,i)})}),this},q.one=function(e,t,n){return this.on(e,t,n,!0)},q.ready=function(e){var t=function(){return e(Y)};return"loading"!==P.readyState?setTimeout(t):P.addEventListener("DOMContentLoaded",t),this},q.trigger=function(e,t){var n=e;if(te(e)){var r=Ie(e),o=r[0],i=r[1];(n=P.createEvent("HTMLEvents")).initEvent(o,!0,!0),n.namespace=i.join(".")}return n.data=t,this.each(function(e,t){t.dispatchEvent(n)})};var Te=/select-one/i,Pe=/select-multiple/i;function Ae(e){var t=e.type;return Te.test(t)?function(e){return e.selectedIndex<0?null:e.options[e.selectedIndex].value}(e):Pe.test(t)?function(e){var t=[];return J(e.options,function(e){!e.selected||e.disabled||e.parentNode.disabled||t.push(e.value)}),t}(e):e.value}var Re=/%20/g,Le=/file|reset|submit|button|image/i,De=/radio|checkbox/i;q.serialize=function(){var e="";return this.each(function(t,n){J(n.elements||[n],function(t){if(!t.disabled&&t.name&&"FIELDSET"!==t.tagName&&!Le.test(t.type)&&(!De.test(t.type)||t.checked)){var n=Ae(t);void 0!==n&&J(re(n)?n:[n],function(n){e+=function(e,t){return"&"+encodeURIComponent(e)+"="+encodeURIComponent(t).replace(Re,"+")}(t.name,n)})}})}),e.substr(1)},q.val=function(e){return void 0===e?this[0]&&Ae(this[0]):this.each(function(t,n){var r=Pe.test(n.type),o=null===e?r?[]:"":e;r&&re(o)?J(n.options,function(e){e.selected=o.indexOf(e.value)>=0}):n.value=o})},q.clone=function(){return this.map(function(e,t){return t.cloneNode(!0)})},q.detach=function(){return this.each(function(e,t){t.parentNode&&t.parentNode.removeChild(t)})};var Fe,$e=/^\\s*<(\\w+)[^>]*>/,je=/^\\s*<(\\w+)\\s*\\/?>(?:<\\/\\1>)?\\s*$/;function _e(e){if(function(){if(!Fe){var e=P.createElement("table"),t=P.createElement("tr");Fe={"*":P.createElement("div"),tr:P.createElement("tbody"),td:t,th:t,thead:e,tbody:e,tfoot:e}}}(),!te(e))return[];if(je.test(e))return[P.createElement(RegExp.$1)];var t=$e.test(e)&&RegExp.$1,n=Fe[t]||Fe["*"];return n.innerHTML=e,Y(n.childNodes).detach().get()}function ke(e,t,n){if(void 0!==t){var r=te(t);!r&&t.length?J(t,function(t){return ke(e,t,n)}):J(e,r?function(e){e.insertAdjacentHTML(n?"afterbegin":"beforeend",t)}:function(e,r){return function(e,t,n){n?e.insertBefore(t,e.childNodes[0]):e.appendChild(t)}(e,r?t.cloneNode(!0):t,n)})}}Y.parseHTML=_e,q.empty=function(){var e=this[0];if(e)for(;e.firstChild;)e.removeChild(e.firstChild);return this},q.append=function(){var e=this;return J(arguments,function(t){ke(e,t)}),this},q.appendTo=function(e){return ke(Y(e),this),this},q.html=function(e){if(void 0===e)return this[0]&&this[0].innerHTML;var t=e.nodeType?e[0].outerHTML:e;return this.each(function(e,n){n.innerHTML=t})},q.insertAfter=function(e){var t=this;return Y(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n.nextSibling)})}),this},q.after=function(){var e=this;return J(j.apply(arguments),function(t){j.apply(Y(t).slice()).insertAfter(e)}),this},q.insertBefore=function(e){var t=this;return Y(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n)})}),this},q.before=function(){var e=this;return J(arguments,function(t){Y(t).insertBefore(e)}),this},q.prepend=function(){var e=this;return J(arguments,function(t){ke(e,t,!0)}),this},q.prependTo=function(e){return ke(Y(e),j.apply(this.slice()),!0),this},q.remove=function(){return this.detach().off()},q.replaceWith=function(e){var t=this;return this.each(function(n,r){var o=r.parentNode;if(o){var i=n?Y(e).clone():Y(e);if(!i[0])return t.remove(),!1;o.replaceChild(i[0],r),Y(i[0]).after(i.slice(1))}})},q.replaceAll=function(e){return Y(e).replaceWith(this),this},q.text=function(e){return void 0===e?this[0]?this[0].textContent:"":this.each(function(t,n){n.textContent=e})};var We=P.documentElement;q.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+A.pageYOffset-We.clientTop,left:t.left+A.pageXOffset-We.clientLeft}}},q.offsetParent=function(){return Y(this[0]&&this[0].offsetParent)},q.position=function(){var e=this[0];if(e)return{left:e.offsetLeft,top:e.offsetTop}},q.children=function(e){var t=[];return this.each(function(e,n){$.apply(t,n.children)}),t=Y(ae(t)),e?t.filter(function(t,n){return Q(n,e)}):t},q.contents=function(){var e=[];return this.each(function(t,n){$.apply(e,"IFRAME"===n.tagName?[n.contentDocument]:n.childNodes)}),Y(e.length&&ae(e))},q.find=function(e){for(var t=[],n=0,r=this.length;n<r;n++){var o=V(e,this[n]);o.length&&$.apply(t,o)}return Y(t.length&&ae(t))},q.has=function(e){var t=te(e)?function(t,n){return!!V(e,n).length}:function(t,n){return n.contains(e)};return this.filter(t)},q.is=function(e){if(!e||!this[0])return!1;var t=oe(e),n=!1;return this.each(function(r,o){return!(n=t(r,o,e))}),n},q.next=function(){return Y(this[0]&&this[0].nextElementSibling)},q.not=function(e){if(!e||!this[0])return this;var t=oe(e);return this.filter(function(n,r){return!t(n,r,e)})},q.parent=function(){var e=[];return this.each(function(t,n){n&&n.parentNode&&e.push(n.parentNode)}),Y(ae(e))},q.index=function(e){var t=e?Y(e)[0]:this[0],n=e?this:Y(t).parent().children();return D.call(n,t)},q.closest=function(e){return e&&this[0]?this.is(e)?this.filter(e):this.parent().closest(e):Y()},q.parents=function(e){var t,n=[];return this.each(function(r,o){for(t=o;t&&t.parentNode&&t!==P.body.parentNode;)t=t.parentNode,(!e||e&&Q(t,e))&&n.push(t)}),Y(ae(n))},q.prev=function(){return Y(this[0]&&this[0].previousElementSibling)},q.siblings=function(){var e=this[0];return this.parent().children().filter(function(t,n){return n!==e})};const ze=Y,He=new class{getFiberNode(e){try{const t=Object.keys(e).find(e=>e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"));return t?e[t]:null}catch(e){return console.warn("[ReactFiberService] Error getting fiber node:",e),null}}getDebugOwner(e){const t=this.getFiberNode(e);return t?._debugOwner??null}getDebugSource(e){const t=this.getFiberNode(e);return t?._debugSource??null}getOwnerDebugSource(e){const t=this.getDebugOwner(e);return t?._debugSource??null}hasDirectSourceInfo(e){return!!e.getAttribute("data-nocode-id")||!!this.getDebugSource(e)}hasOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return!1;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n&&n.length>0}getOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return null;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n?n:null}isSelectableElement(e){if(this.hasDirectSourceInfo(e))return!0;const t=this.getFiberNode(e),n=this.getOwnerDebugSource(e);return!!(t?.return&&5!==t.return.tag&&this.hasOwnerNocodeId(e)&&n)}isComponent(e){if(!this.isSelectableElement(e))return!1;if(e.getAttribute("data-nocode-components-name"))return!0;if(this.getDebugSource(e))return!1;const t=this.getFiberNode(e);return!(!t?.return||5===t.return.tag)}getComponentName(e){const t=e.getAttribute("data-nocode-tag-name");if(t)return t;const n=this.getDebugOwner(e);if(n?.type){const e=n.type;if("function"==typeof e){const t=e.displayName||e.name||"Unknown";return this.normalizeComponentName(t)}if("string"==typeof e)return e}return e.tagName.toLowerCase()}normalizeComponentName(e){return e.replace(/\\d+$/,"")}getComponentProps(e){if(!this.isComponent(e))return;const t=this.getDebugOwner(e);return t?.memoizedProps?this.sanitizeProps(t.memoizedProps):void 0}sanitizeProps(e){const t={};for(const[n,r]of Object.entries(e)){if("children"===n||n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}sanitizeValue(e){if(null===e)return null;if(void 0===e)return;if("function"==typeof e)return;if("symbol"==typeof e)return;if("object"!=typeof e)return e;if("$$typeof"in e)return;if(e instanceof Node)return;if(Array.isArray(e)){const t=[];for(const n of e){const e=this.sanitizeValue(n);void 0!==e&&t.push(e)}return t}const t={};for(const[n,r]of Object.entries(e)){if(n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}buildComponentInfo(e){const t=this.isComponent(e),n={isComponent:t,componentType:t?"component":"host",name:t?this.getComponentName(e):e.tagName.toLowerCase()},r=e.getAttribute("data-nocode-components-name"),o=e.getAttribute("data-nocode-components-version");if(r&&(n.componentsName=r),o&&(n.componentsVersion=o),t){const t=this.getComponentProps(e)??{},r=this.removeSpecialProps(t);n.props=r}return n}removeSpecialProps(e){const t={};for(const[n,r]of Object.entries(e))"componentsName"!==n&&"componentsVersion"!==n&&(n.startsWith("data-nocode-")||(t[n]=r));return t}},Ue="data-dnd";function Ve(e){if(!e)return{};const t=e.split(":");if(t.length>=3){const n=t.pop(),r=t.pop(),o=t.join(":");return{id:e,filename:decodeURIComponent(o),component:r,codeId:n}}return 2===t.length?{id:e,component:t[0],codeId:t[1]}:{id:e}}const Be=`[${Ue}]`;function Ye(e,t){const n=t??0;return 0===n?document.querySelector(`[${Ue}="${e}"]`):document.querySelectorAll(`[${Ue}="${e}"]`)[n]??null}const qe=(e,t)=>{const n=e.getBoundingClientRect(),{x:r,y:o}=((e,t)=>{let n=e.x,r=e.y;if(t){const e=t.getBoundingClientRect();n-=e.left,r-=e.top}return{x:n,y:r}})({x:n.left,y:n.top},t);return{width:e.offsetWidth||Math.round(n.width),height:e.offsetHeight||Math.round(n.height),top:o,left:r}},Ke=(e,t)=>{const n=qe(e,t),r=function(e){return e.dataset}(e),o=Ge(e),i=Xe(e),s=(e=>{const t=window.getComputedStyle(e);return{display:t.display,flexDirection:t.flexDirection,flexWrap:t.flexWrap,position:t.position}})(e),a=r.dnd||"",c=Ve(a),u=function(e){return He.buildComponentInfo(e)}(e),l=function(e){return"true"===e.getAttribute("data-nocode-container-placeholder")}(e),d=(e=>{const t=e.querySelectorAll(`:scope > ${Be}`);if(!t.length)return[];const n=[];return t.forEach(e=>{const t=e;n.push(qe(t))}),n})(e);let f;if(a){const t=document.querySelectorAll(`[${Ue}="${a}"]`);if(t.length>1)for(let n=0;n<t.length;n++)if(t[n]===e){f=n;break}}return{id:a,codeId:c.codeId,name:c.component||e.tagName.toLowerCase(),filename:c.filename,bounding:n,display:o,computedStyle:s,text:i,containerPlaceholder:l||void 0,componentInfo:u,childrenBoundings:d.length>0?d:void 0,dndIndex:f}},Ge=e=>ze(e).css("display"),Xe=e=>{const t=[];return e.childNodes.forEach(e=>{if(e.nodeType===Node.TEXT_NODE){const n=e.textContent?.trim()||"";n&&t.push(n)}}),t.join(" ")};function Je(e){const t=["div","p","section","article","main","header","footer","nav","h1","h2","h3","h4","h5","h6","span","a","button","i","input","textarea","select","label","form","ul","ol","li","table","thead","tbody","tr","td","th","img","video","audio","canvas","svg"];try{const n=e.tagName.toLowerCase();if(!t.includes(n))return!1;const r=window.getComputedStyle(e);if("none"===r.display||"hidden"===r.visibility||"0"===r.opacity)return!1;const o=e.getBoundingClientRect();return!("inline"!==r.display&&"inline-block"!==r.display&&(0===o.width||0===o.height))}catch(e){return console.warn("Element validation failed:",e),!1}}function Ze(e,t=20){let n=e,r=0;for(;n&&r<t;){if(n.getAttribute(Ue))return n;n=n.parentElement,r++}return null}function Qe(e){const t=window.getComputedStyle(e),n={};for(let e=0;e<t.length;e++){const r=t[e];n[r]=t.getPropertyValue(r)}return n}let et=null;function tt(e){return(...t)=>{try{const n=e(...t);return n&&"function"==typeof n.then?n.catch(n=>(console.error(`Async error in ${e.name}:`,n),console.error("Error stack:",n.stack),console.error("Function arguments:",t),null)):n}catch(n){return console.error(`Sync error in ${e.name}:`,n),n instanceof Error&&console.error("Error stack:",n.stack),console.error("Function arguments:",t),null}}}const nt={getDraggableParentsData:(e,t)=>{const n=function(e,t){const n=((e,t)=>{const n=document.elementFromPoint(e,t);if(!n)return null;const r=n=>{if(n?.shadowRoot){const o=n.shadowRoot.elementFromPoint(e,t);return o===n?n:o?.shadowRoot?r(o):o||n}return n};return r(n)})(e,t);if(!n)return null;let r=n;if(!Je(r)){let e=r.parentElement,t=0;const n=20;for(;e&&t<n;){if(Je(e)){r=e;break}e=e.parentElement,t++}if(!Je(r))return null}const o=Ze(r);return o&&Je(o)?o:null}(e.x,e.y);if(!n)return;const r=(e=>{const t=ze(e).closest(Be).get(0),n=ze(e).parents(Be).get();return n[0]!==t&&n.unshift(t),n})(n);if(r.length){if(t){const e=r.map(e=>Ke(e));return{...e[0],computedStyle:Qe(n),parents:e.slice(1)}}return{...Ke(r[0]),computedStyle:Qe(r[0])}}},getElementDataById:(e,t)=>{const n=Ye(e,t);if(n)return{...Ke(n),computedStyle:Qe(n)};console.warn("[getElementDataById] Element not found for domId:",e,"dndIndex:",t)},getEditableTextElementAtPosition:e=>{const t=function(e,t){if(document.caretPositionFromPoint){const n=document.caretPositionFromPoint(e,t);return n?.offsetNode??null}if(document.caretRangeFromPoint){const n=document.caretRangeFromPoint(e,t);return n?.startContainer??null}return document.elementFromPoint(e,t)}(e.x,e.y);if(!t)return void console.log("[getEditableTextElementAtPosition] No node at point:",e);if(t.nodeType!==Node.TEXT_NODE)return void console.log("[getEditableTextElementAtPosition] Not a text node:",t.nodeType);const n=t.textContent?.trim();if(!n)return void console.log("[getEditableTextElementAtPosition] Empty text node");const r=t.parentElement;if(!r)return void console.log("[getEditableTextElementAtPosition] No parent element");const o=Ze(r);if(o){if(function(e){const t=e.childNodes;let n=!1;for(let e=0;e<t.length;e++){const r=t[e];if(r.nodeType===Node.ELEMENT_NODE)return!1;if(r.nodeType===Node.TEXT_NODE){const e=r.textContent?.trim();e&&(n=!0)}}return n}(o))return console.log("[getEditableTextElementAtPosition] Found editable text element:",o.tagName,o.textContent),{...Ke(o),computedStyle:Qe(o)};console.log("[getEditableTextElementAtPosition] Element has child elements, cannot edit directly:",o.tagName)}else console.log("[getEditableTextElementAtPosition] No marked element found")},updateElementTextContent:(e,t)=>{const n=Ye(e);return n?(n.textContent=t,!0):(console.warn("[updateElementTextContent] Element not found:",e),!1)},scrollToElement:(e,t)=>{const n=Ye(e,t);return n?(n.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),!0):(console.warn("[scrollToElement] Element not found for domId:",e,"dndIndex:",t),!1)},scrollPageBy:(e,t)=>(window.scrollBy(e,t),!0),highlightElement:(e,t)=>{if(et&&(et.style.outline="",et.style.outlineOffset="",et=null),!e)return!0;const n=Ye(e,t);return n?(n.style.outline="2px solid rgba(54, 210, 190, 0.8)",n.style.outlineOffset="-1px",et=n,!0):(console.warn("[highlightElement] Element not found:",e,"dndIndex:",t),!1)},getProjectLibVersions:function(){try{const e=document.body;if(!e)return console.warn("[sandbox] document.body is not available"),null;const t=e.getAttribute("data-nocode-lib-versions");if(!t)return console.warn("[sandbox] data-nocode-lib-versions attribute not found on body"),null;const n=JSON.parse(t);return"object"!=typeof n||null===n?(console.warn("[sandbox] data-nocode-lib-versions is not a valid object"),null):n}catch(e){return console.error("[sandbox] Failed to parse data-nocode-lib-versions:",e),null}},getCompilerVersion:function(){try{const e=document.body;return e?e.getAttribute("data-nocode-compiler-version"):null}catch(e){return console.error("[sandbox] Failed to get compiler version:",e),null}},getRuntimeNodeTree:()=>{try{const e=document.querySelectorAll(Be);if(!e.length)return[];const t=new Map;e.forEach(e=>{const n=e.getAttribute(Ue)||"";if(!n)return;const r=Ve(n);t.set(e,{id:n,component:r.component||e.tagName.toLowerCase(),children:[]})});const n=[];e.forEach(e=>{const r=t.get(e);if(!r)return;let o,i=e.parentElement;for(;i;){if(t.has(i)){o=t.get(i);break}i=i.parentElement}o?o.children.push(r):n.push(r)});const r=e=>{e.children&&0===e.children.length?delete e.children:e.children&&e.children.forEach(r)};return n.forEach(r),n}catch(e){return console.error("[sandbox] Failed to build runtime node tree:",e),[]}},setElementStyle:function(e,t){const n=function(e){return document.querySelector(`[${Ue}="${e}"]`)}(e);return n?(Object.entries(t).forEach(([e,t])=>{n.style[e]=t}),!0):(console.warn("[setElementStyle] Element not found for domId:",e),!1)}},rt=Object.fromEntries(Object.entries(nt).map(([e,t])=>[e,tt(t)])),ot="nocode-design-mode";let it=null,st=!1,at=null;const ct=t()(()=>{it?.onWindowMutated&&(console.log(`${ot} - Notifying parent of DOM mutation`),it.onWindowMutated({added:{},removed:{}}))},100),ut=async()=>{if(st||it)return it;st=!0,console.log(`${ot} - Creating penpal connection`);const e=(({messenger:e,methods:t={},timeout:n,channel:o,log:i})=>{if(!e)throw new r("INVALID_ARGUMENT","messenger must be defined");if(M.has(e))throw new r("INVALID_ARGUMENT","A messenger can only be used for a single connection");M.add(e);const s=[e.destroy],u=(e=>{let t,n=!1;return(...r)=>(n||(n=!0,t=e(...r)),t)})(t=>{if(t){const t={namespace:a,channel:o,type:"DESTROY"};try{e.sendMessage(t)}catch(e){}}for(const e of s)e();i?.("Connection destroyed")}),l=e=>(e=>c(e)&&e.namespace===a)(e)&&e.channel===o;return{promise:(async()=>{try{e.initialize({log:i,validateReceivedMessage:l}),e.addMessageHandler(e=>{(e=>"DESTROY"===e.type)(e)&&u(!1)});const{remoteProxy:r,destroy:a}=await I({messenger:e,methods:t,timeout:n,channel:o,log:i});return s.push(a),r}catch(e){throw u(!0),e}})(),destroy:()=>{u(!0)}}})({messenger:new T({remoteWindow:window===window.top?(console.warn(`${ot} - Not in an iframe, using window.parent as fallback`),window.parent):window.parent===window.top?window.parent:window.top?(console.log(`${ot} - Using window.top for nested iframe scenario`),window.top):window.parent,allowedOrigins:["*"]}),methods:rt});return e.promise.then(e=>{if(!e)return console.error(`${ot} - Failed to setup penpal connection: child is null`),void lt();it=e,console.log(`${ot} - Penpal connection set`),(()=>{if(at)return;at=new MutationObserver(e=>{e.some(e=>{const t=e.target;return"SCRIPT"!==t.tagName&&"STYLE"!==t.tagName&&("attributes"!==e.type||"style"===e.attributeName||"class"===e.attributeName)})&&ct()});const e=()=>{document.body&&at&&(at.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"],characterData:!0}),console.log(`${ot} - MutationObserver started`))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()})()}).finally(()=>{st=!1}),e.promise.catch(e=>{console.error(`${ot} - Failed to setup penpal connection:`,e),lt()}),it},lt=t()(()=>{st||(console.log(`${ot} - Reconnecting to penpal parent`),it=null,ut())},1e3);ut()})()})();';
302
380
  }
303
381
  function createSandboxScriptMiddleware(options) {
304
382
  var _a;
@@ -431,21 +509,43 @@ function componentCompiler(options = {}) {
431
509
  ...DEFAULT_DESIGN_MODE_OPTIONS,
432
510
  ...options.designModeOptions
433
511
  };
434
- const monitorService = new import_nocode_compiler_core.MonitorService({
512
+ const monitorService = new import_nocode_compiler_core2.MonitorService({
435
513
  pluginName: "vite-plugin-nocode-compiler",
436
514
  framework: "vite",
437
515
  pluginVersion: version
438
516
  });
439
- monitorService.reportMetrics(import_nocode_compiler_core.MetricType.PLUGIN_USE, 1);
440
- const vueCompiler = new import_nocode_compiler_core.VueCompiler(options);
441
- const jsxCompiler = new import_nocode_compiler_core.JSXCompiler(options);
442
- const designModeCompiler = new import_nocode_compiler_core.DesignModeCompiler(options);
517
+ monitorService.reportMetrics(import_nocode_compiler_core2.MetricType.PLUGIN_USE, 1);
518
+ const vueCompiler = new import_nocode_compiler_core2.VueCompiler(options);
519
+ const jsxCompiler = new import_nocode_compiler_core2.JSXCompiler(options);
520
+ const designModeCompiler = new import_nocode_compiler_core2.DesignModeCompiler(options);
443
521
  let server;
444
522
  let pkgRegistry;
445
523
  let projectRoot = "";
446
524
  return {
447
525
  name: PLUGIN_NAME,
448
526
  enforce: "pre",
527
+ /**
528
+ * 修改 Vite 配置:
529
+ * 在开发环境下,如果检测到项目使用了 shadcn 组件库,
530
+ * 将 shadcn 组件依赖的 npm 包加入 optimizeDeps.include,
531
+ * 确保 Vite 在启动时预构建这些包及其深层子依赖,
532
+ * 避免运行时首次拖拽组件时触发 optimizeDeps 重新预构建导致 full-reload。
533
+ */
534
+ config(userConfig, { command }) {
535
+ var _a;
536
+ if (command === "serve" && designModeOptions.enableVirtualCode) {
537
+ const root = userConfig.root || process.cwd();
538
+ if (!(0, import_nocode_compiler_core2.detectShadcnProject)(root)) {
539
+ return;
540
+ }
541
+ console.log(`[DesignMode] Shadcn project detected, adding ${import_nocode_compiler_core2.SHADCN_NPM_DEPS.length} deps to optimizeDeps.include`);
542
+ return {
543
+ optimizeDeps: {
544
+ include: [...Array.isArray((_a = userConfig.optimizeDeps) == null ? void 0 : _a.include) ? userConfig.optimizeDeps.include : [], ...import_nocode_compiler_core2.SHADCN_NPM_DEPS]
545
+ }
546
+ };
547
+ }
548
+ },
449
549
  /**
450
550
  * 配置解析完成后:
451
551
  * 1. 将本插件移到插件列表最前面,确保在所有 enforce: 'pre' 插件中第一个执行
@@ -454,9 +554,9 @@ function componentCompiler(options = {}) {
454
554
  */
455
555
  configResolved(config) {
456
556
  ensurePluginFirst(config, (error) => monitorService.reportError(error, { scene: "ensurePluginFirst" }));
457
- pkgRegistry = new import_nocode_compiler_core.PackageVersionRegistry(config.root);
557
+ pkgRegistry = new import_nocode_compiler_core2.PackageVersionRegistry(config.root);
458
558
  projectRoot = config.root;
459
- (0, import_nocode_compiler_core.preloadDependencyVersions)(pkgRegistry);
559
+ (0, import_nocode_compiler_core2.preloadDependencyVersions)(pkgRegistry);
460
560
  },
461
561
  /**
462
562
  * 配置开发服务器,添加 Override 中间件和设计模式中间件
@@ -476,6 +576,7 @@ function componentCompiler(options = {}) {
476
576
  server.middlewares.use(createOverrideMiddleware(server));
477
577
  server.middlewares.use(createSandboxScriptMiddleware(designModeOptions));
478
578
  if (designModeOptions.enableVirtualCode) {
579
+ server.middlewares.use(createSwapNodeMiddleware(server, designModeOptions, projectRoot));
479
580
  server.middlewares.use(createVirtualCodeMiddleware(server, designModeOptions, projectRoot));
480
581
  console.log(`[DesignMode] Virtual code API enabled at ${designModeOptions.virtualCodeApiPath}`);
481
582
  }
@@ -487,8 +588,8 @@ function componentCompiler(options = {}) {
487
588
  * 兼容 Vite 2.x - 6.x(transformIndexHtml 从 Vite 2 起就支持简单函数形式)
488
589
  */
489
590
  transformIndexHtml(html) {
490
- const metadata = (0, import_nocode_compiler_core.generateBodyMetadata)(pkgRegistry, version);
491
- html = (0, import_nocode_compiler_core.injectBodyMetadata)(html, metadata);
591
+ const metadata = (0, import_nocode_compiler_core2.generateBodyMetadata)(pkgRegistry, version);
592
+ html = (0, import_nocode_compiler_core2.injectBodyMetadata)(html, metadata);
492
593
  html = injectSandboxScript(html);
493
594
  return html;
494
595
  },
@@ -517,12 +618,19 @@ function componentCompiler(options = {}) {
517
618
  code = result.code;
518
619
  }
519
620
  }
520
- const { useJSXCompiler, useVueCompiler } = (0, import_nocode_compiler_core.detectCompileScenario)({
621
+ const { useJSXCompiler, useVueCompiler } = (0, import_nocode_compiler_core2.detectCompileScenario)({
521
622
  filePath,
522
623
  query
523
624
  });
524
625
  if (useJSXCompiler) {
525
- return jsxCompiler.compile(code, filePath, pkgRegistry) || code;
626
+ let diskCode;
627
+ if (hasVirtualCode(id)) {
628
+ try {
629
+ diskCode = fs2.readFileSync(filePath, "utf-8");
630
+ } catch {
631
+ }
632
+ }
633
+ return jsxCompiler.compile(code, filePath, pkgRegistry, diskCode) || code;
526
634
  }
527
635
  if (useVueCompiler) {
528
636
  return vueCompiler.compile(code, filePath, pkgRegistry) || code;
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // src/index.ts
2
- import { JSXCompiler, VueCompiler, DesignModeCompiler, detectCompileScenario, PackageVersionRegistry, MonitorService, MetricType, preloadDependencyVersions, generateBodyMetadata, injectBodyMetadata } from "@meituan-nocode/nocode-compiler-core";
2
+ import { DesignModeCompiler as DesignModeCompiler2, detectCompileScenario, detectShadcnProject, generateBodyMetadata, injectBodyMetadata, JSXCompiler, MetricType, MonitorService, PackageVersionRegistry, preloadDependencyVersions, SHADCN_NPM_DEPS, VueCompiler } from "@meituan-nocode/nocode-compiler-core";
3
+ import * as fs2 from "fs";
3
4
 
4
5
  // src/utils/index.ts
5
6
  import { normalize, dirname, isAbsolute, join } from "path";
@@ -143,11 +144,12 @@ function readJsonBody(req) {
143
144
  }
144
145
 
145
146
  // package.json
146
- var version = "0.3.1-beta.9";
147
+ var version = "0.4.1-beta.2";
147
148
 
148
149
  // src/design-mode/types.ts
149
150
  var SANDBOX_SCRIPT_PATH = "/sandbox-script.js";
150
151
  var VIRTUAL_CODE_API_PATH = "/api/virtual-code";
152
+ var SWAP_NODE_API_PATH = "/api/virtual-code/swap";
151
153
  var DEFAULT_DESIGN_MODE_OPTIONS = {
152
154
  enableVirtualCode: true,
153
155
  virtualCodeApiPath: VIRTUAL_CODE_API_PATH,
@@ -158,6 +160,8 @@ var DEFAULT_DESIGN_MODE_OPTIONS = {
158
160
 
159
161
  // src/design-mode/virtual-code.ts
160
162
  import * as path from "path";
163
+ import * as fs from "fs";
164
+ import { DesignModeCompiler } from "@meituan-nocode/nocode-compiler-core";
161
165
  var virtualCodeMap = /* @__PURE__ */ new Map();
162
166
  function matchesDesignModePattern(id, options) {
163
167
  const exclude = options.exclude || [];
@@ -185,20 +189,96 @@ function loadVirtualCode(id, options) {
185
189
  const relativePath = extractRelativePath(id);
186
190
  if (!relativePath) return void 0;
187
191
  const code = virtualCodeMap.get(relativePath) || virtualCodeMap.get("/" + relativePath);
188
- if (code && options.verbose) {
189
- console.log(`[DesignMode] Using virtual code for: ${relativePath}`);
192
+ if (code) {
193
+ console.log(`[DesignMode] load hook: using virtual code for "${relativePath}" (${code.length} chars)`);
194
+ } else if (virtualCodeMap.size > 0) {
195
+ console.log(`[DesignMode] load hook: NO virtual code for "${relativePath}", map keys: [${Array.from(virtualCodeMap.keys()).join(", ")}]`);
190
196
  }
191
197
  return code;
192
198
  }
199
+ function createSwapNodeMiddleware(server, options, projectRoot) {
200
+ var _a;
201
+ const swapApiPath = SWAP_NODE_API_PATH;
202
+ const verbose = (_a = options.verbose) != null ? _a : false;
203
+ const compiler = new DesignModeCompiler({ rootPath: projectRoot });
204
+ return (req, res, next) => {
205
+ var _a2;
206
+ if (!((_a2 = req.url) == null ? void 0 : _a2.startsWith(swapApiPath))) {
207
+ return next();
208
+ }
209
+ if (req.method === "OPTIONS") {
210
+ res.setHeader("Access-Control-Allow-Origin", "*");
211
+ res.setHeader("Access-Control-Allow-Methods", "POST, OPTIONS");
212
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type");
213
+ res.statusCode = 204;
214
+ res.end();
215
+ return;
216
+ }
217
+ res.setHeader("Content-Type", "application/json");
218
+ res.setHeader("Access-Control-Allow-Origin", "*");
219
+ if (req.method !== "POST") {
220
+ res.statusCode = 405;
221
+ res.end(JSON.stringify({ error: "Method not allowed" }));
222
+ return;
223
+ }
224
+ let body = "";
225
+ req.on("data", (chunk) => body += chunk.toString());
226
+ req.on("end", () => {
227
+ try {
228
+ const { filePath, nodeAId, nodeBId } = JSON.parse(body);
229
+ if (!filePath || !nodeAId || !nodeBId) {
230
+ res.statusCode = 400;
231
+ res.end(JSON.stringify({ error: "filePath, nodeAId, and nodeBId are required" }));
232
+ return;
233
+ }
234
+ const fullPath = path.resolve(projectRoot, filePath);
235
+ if (!fs.existsSync(fullPath)) {
236
+ res.statusCode = 404;
237
+ res.end(JSON.stringify({ error: `File not found: ${filePath}` }));
238
+ return;
239
+ }
240
+ const cleanCode = fs.readFileSync(fullPath, "utf-8");
241
+ const result = compiler.swapNodes(cleanCode, fullPath, nodeAId, nodeBId);
242
+ if (!result) {
243
+ res.statusCode = 400;
244
+ res.end(JSON.stringify({ error: "Swap failed: nodes not found or not siblings" }));
245
+ return;
246
+ }
247
+ virtualCodeMap.set(filePath, result.dndCode);
248
+ console.log(`[DnD] virtualCodeMap key: "${filePath}", dndCode length: ${result.dndCode.length}`);
249
+ fs.writeFileSync(fullPath, result.cleanCode, "utf-8");
250
+ triggerHmrUpdate(server, fullPath, true);
251
+ if (verbose) {
252
+ console.log(`[DnD] Swap completed for: ${filePath}, ${nodeAId} \u2194 ${nodeBId}`);
253
+ }
254
+ res.end(
255
+ JSON.stringify({
256
+ success: true,
257
+ cleanCode: result.cleanCode,
258
+ dndCode: result.dndCode,
259
+ newSelectedId: result.newSelectedId
260
+ })
261
+ );
262
+ } catch (error) {
263
+ console.error("[DnD] Swap error:", error);
264
+ res.statusCode = 500;
265
+ res.end(JSON.stringify({ error: String(error) }));
266
+ }
267
+ });
268
+ };
269
+ }
193
270
  function createVirtualCodeMiddleware(server, options, projectRoot) {
194
271
  var _a;
195
272
  const apiPath = options.virtualCodeApiPath || VIRTUAL_CODE_API_PATH;
196
273
  const verbose = (_a = options.verbose) != null ? _a : false;
197
274
  return (req, res, next) => {
198
- var _a2;
275
+ var _a2, _b;
199
276
  if (!((_a2 = req.url) == null ? void 0 : _a2.startsWith(apiPath))) {
200
277
  return next();
201
278
  }
279
+ if ((_b = req.url) == null ? void 0 : _b.startsWith(SWAP_NODE_API_PATH)) {
280
+ return next();
281
+ }
202
282
  if (req.method === "OPTIONS") {
203
283
  res.setHeader("Access-Control-Allow-Origin", "*");
204
284
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
@@ -219,8 +299,6 @@ function createVirtualCodeMiddleware(server, options, projectRoot) {
219
299
  if (verbose) {
220
300
  console.log(`[DnD] Virtual code set for: ${filePath}`);
221
301
  }
222
- const fullPath = path.resolve(projectRoot, filePath);
223
- triggerHmrUpdate(server, fullPath, verbose);
224
302
  res.end(JSON.stringify({ success: true, filePath }));
225
303
  } catch (error) {
226
304
  res.statusCode = 500;
@@ -263,7 +341,7 @@ function createVirtualCodeMiddleware(server, options, projectRoot) {
263
341
 
264
342
  // src/design-mode/sandbox-script.ts
265
343
  function getSandboxScriptContent() {
266
- return '(()=>{var e={6:(e,t,n)=>{var r=n(714).Symbol;e.exports=r},12:(e,t,n)=>{var r=n(400),o=n(835),i=n(639),s=Math.max,a=Math.min;e.exports=function(e,t,n){var c,u,l,d,f,h,p=0,g=!1,m=!1,v=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){var n=c,r=u;return c=u=void 0,p=t,d=e.apply(r,n)}function b(e){var n=e-h;return void 0===h||n>=t||n<0||m&&e-p>=l}function w(){var e=o();if(b(e))return E(e);f=setTimeout(w,function(e){var n=t-(e-h);return m?a(n,l-(e-p)):n}(e))}function E(e){return f=void 0,v&&c?y(e):(c=u=void 0,d)}function N(){var e=o(),n=b(e);if(c=arguments,u=this,h=e,n){if(void 0===f)return function(e){return p=e,f=setTimeout(w,t),g?y(e):d}(h);if(m)return clearTimeout(f),f=setTimeout(w,t),y(h)}return void 0===f&&(f=setTimeout(w,t)),d}return t=i(t)||0,r(n)&&(g=!!n.leading,l=(m="maxWait"in n)?s(i(n.maxWait)||0,t):l,v="trailing"in n?!!n.trailing:v),N.cancel=function(){void 0!==f&&clearTimeout(f),p=0,c=h=u=f=void 0},N.flush=function(){return void 0===f?d:E(o())},N}},103:(e,t,n)=>{var r=n(997),o=/^\\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},271:(e,t,n)=>{var r=n(6),o=n(650),i=n(881),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?o(e):i(e)}},400:e=>{e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},583:e=>{e.exports=function(e){return null!=e&&"object"==typeof e}},603:(e,t,n)=>{var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},639:(e,t,n)=>{var r=n(103),o=n(400),i=n(975),s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=a.test(e);return n||c.test(e)?u(e.slice(2),n?2:8):s.test(e)?NaN:+e}},650:(e,t,n)=>{var r=n(6),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var o=s.call(e);return r&&(t?e[a]=n:delete e[a]),o}},714:(e,t,n)=>{var r=n(603),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();e.exports=i},835:(e,t,n)=>{var r=n(714);e.exports=function(){return r.Date.now()}},881:e=>{var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},975:(e,t,n)=>{var r=n(271),o=n(583);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},997:e=>{var t=/\\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=n(12),t=n.n(e),r=class extends Error{code;constructor(e,t){super(t),this.name="PenpalError",this.code=e}},o=e=>({name:e.name,message:e.message,stack:e.stack,penpalCode:e instanceof r?e.code:void 0}),i=Symbol("Reply"),s=class{value;transferables;#e=i;constructor(e,t){this.value=e,this.transferables=t?.transferables}},a="penpal",c=e=>"object"==typeof e&&null!==e,u=e=>"function"==typeof e,l=e=>"SYN"===e.type,d=e=>"ACK1"===e.type,f=e=>"ACK2"===e.type,h=e=>"CALL"===e.type,p=e=>"REPLY"===e.type,g=(e,t=[])=>{const n=[];for(const r of Object.keys(e)){const o=e[r];u(o)?n.push([...t,r]):c(o)&&n.push(...g(o,[...t,r]))}return n},m=e=>e.join("."),v=(e,t,n)=>({namespace:a,channel:e,type:"REPLY",callId:t,isError:!0,...n instanceof Error?{value:o(n),isSerializedErrorInstance:!0}:{value:n}}),y=crypto.randomUUID?.bind(crypto)??(()=>new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")),b=Symbol("CallOptions"),w=class{transferables;timeout;#e=b;constructor(e){this.transferables=e?.transferables,this.timeout=e?.timeout}},E=new Set(["apply","call","bind"]),N=(e,t,n=[])=>new Proxy(n.length?()=>{}:Object.create(null),{get(r,o){if("then"!==o)return n.length&&E.has(o)?Reflect.get(r,o):N(e,t,[...n,o])},apply:(t,r,o)=>e(n,o)}),S=e=>new r("CONNECTION_DESTROYED",`Method call ${m(e)}() failed due to destroyed connection`),C="deprecated-penpal",O=e=>e.join("."),x=e=>new r("TRANSMISSION_FAILED",`Unexpected message to translate: ${(e=>{try{return JSON.stringify(e)}catch(t){return String(e)}})(e)}`),T=({messenger:e,methods:t,timeout:n,channel:o,log:i})=>{const b=y();let E;const O=[];let x=!1;const T=g(t),{promise:I,resolve:M,reject:P}=(()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}})(),A=void 0!==n?setTimeout(()=>{P(new r("CONNECTION_TIMEOUT",`Connection timed out after ${n}ms`))},n):void 0,R=()=>{for(const e of O)e()},L=()=>{if(x)return;O.push(((e,t,n,o)=>{let i=!1;const l=async l=>{if(i)return;if(!h(l))return;o?.(`Received ${m(l.methodPath)}() call`,l);const{methodPath:d,args:f,id:p}=l;let g,y;try{const e=((e,t)=>{const n=e.reduce((e,t)=>c(e)?e[t]:void 0,t);return u(n)?n:void 0})(d,t);if(!e)throw new r("METHOD_NOT_FOUND",`Method \\`${m(d)}\\` is not found.`);let o=await e(...f);o instanceof s&&(y=o.transferables,o=await o.value),g={namespace:a,channel:n,type:"REPLY",callId:p,value:o}}catch(e){g=v(n,p,e)}if(!i)try{o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g,y)}catch(t){throw"DataCloneError"===t.name&&(g=v(n,p,t),o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g)),t}};return e.addMessageHandler(l),()=>{i=!0,e.removeMessageHandler(l)}})(e,t,o,i));const{remoteProxy:n,destroy:l}=((e,t,n)=>{let o=!1;const i=new Map,s=e=>{if(!p(e))return;const{callId:t,value:o,isError:s,isSerializedErrorInstance:a}=e,c=i.get(t);c&&(i.delete(t),n?.(`Received ${m(c.methodPath)}() call`,e),s?c.reject(a?(({name:e,message:t,stack:n,penpalCode:o})=>{const i=o?new r(o,t):new Error(t);return i.name=e,i.stack=n,i})(o):o):c.resolve(o))};return e.addMessageHandler(s),{remoteProxy:N((s,c)=>{if(o)throw S(s);const u=y(),l=c[c.length-1],d=l instanceof w,{timeout:f,transferables:h}=d?l:{},p=d?c.slice(0,-1):c;return new Promise((o,c)=>{const l=void 0!==f?window.setTimeout(()=>{i.delete(u),c(new r("METHOD_CALL_TIMEOUT",`Method call ${m(s)}() timed out after ${f}ms`))},f):void 0;i.set(u,{methodPath:s,resolve:o,reject:c,timeoutId:l});try{const r={namespace:a,channel:t,type:"CALL",id:u,methodPath:s,args:p};n?.(`Sending ${m(s)}() call`,r),e.sendMessage(r,h)}catch(e){c(new r("TRANSMISSION_FAILED",e.message))}})},n),destroy:()=>{o=!0,e.removeMessageHandler(s);for(const{methodPath:e,reject:t,timeoutId:n}of i.values())clearTimeout(n),t(S(e));i.clear()}}})(e,o,i);O.push(l),clearTimeout(A),x=!0,M({remoteProxy:n,destroy:R})},D=()=>{const t={namespace:a,type:"SYN",channel:o,participantId:b};i?.("Sending handshake SYN",t);try{e.sendMessage(t)}catch(e){P(new r("TRANSMISSION_FAILED",e.message))}},F=t=>{l(t)&&(t=>{if(i?.("Received handshake SYN",t),t.participantId===E&&E!==C)return;if(E=t.participantId,D(),!(b>E||E===C))return;const n={namespace:a,channel:o,type:"ACK1",methodPaths:T};i?.("Sending handshake ACK1",n);try{e.sendMessage(n)}catch(e){return void P(new r("TRANSMISSION_FAILED",e.message))}})(t),d(t)&&(t=>{i?.("Received handshake ACK1",t);const n={namespace:a,channel:o,type:"ACK2"};i?.("Sending handshake ACK2",n);try{e.sendMessage(n)}catch(e){return void P(new r("TRANSMISSION_FAILED",e.message))}L()})(t),f(t)&&(e=>{i?.("Received handshake ACK2",e),L()})(t)};return e.addMessageHandler(F),O.push(()=>e.removeMessageHandler(F)),D(),I},I=new WeakSet,M=class{#t;#n;#r;#o;#i;#s=new Set;#a;#c=!1;constructor({remoteWindow:e,allowedOrigins:t}){if(!e)throw new r("INVALID_ARGUMENT","remoteWindow must be defined");this.#t=e,this.#n=t?.length?t:[window.origin]}initialize=({log:e,validateReceivedMessage:t})=>{this.#r=e,this.#o=t,window.addEventListener("message",this.#u)};sendMessage=(e,t)=>{if(l(e)){const n=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:n,transfer:t})}if(d(e)||this.#c){const n=this.#c?(e=>{if(d(e))return{penpal:"synAck",methodNames:e.methodPaths.map(O)};if(h(e))return{penpal:"call",id:e.id,methodName:O(e.methodPath),args:e.args};if(p(e))return e.isError?{penpal:"reply",id:e.callId,resolution:"rejected",...e.isSerializedErrorInstance?{returnValue:e.value,returnValueIsError:!0}:{returnValue:e.value}}:{penpal:"reply",id:e.callId,resolution:"fulfilled",returnValue:e.value};throw x(e)})(e):e,r=this.#l(e);return void this.#t.postMessage(n,{targetOrigin:r,transfer:t})}if(f(e)){const{port1:n,port2:r}=new MessageChannel;this.#a=n,n.addEventListener("message",this.#d),n.start();const o=[r,...t||[]],i=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:i,transfer:o})}if(!this.#a)throw new r("TRANSMISSION_FAILED","Cannot send message because the MessagePort is not connected");this.#a.postMessage(e,{transfer:t})};addMessageHandler=e=>{this.#s.add(e)};removeMessageHandler=e=>{this.#s.delete(e)};destroy=()=>{window.removeEventListener("message",this.#u),this.#f(),this.#s.clear()};#h=e=>this.#n.some(t=>t instanceof RegExp?t.test(e):t===e||"*"===t);#l=e=>{if(l(e))return"*";if(!this.#i)throw new r("TRANSMISSION_FAILED","Cannot send message because the remote origin is not established");return"null"===this.#i&&this.#n.includes("*")?"*":this.#i};#f=()=>{this.#a?.removeEventListener("message",this.#d),this.#a?.close(),this.#a=void 0};#u=({source:e,origin:t,ports:n,data:r})=>{if(e===this.#t){if((e=>c(e)&&"penpal"in e)(r)){this.#r?.("Please upgrade the child window to the latest version of Penpal."),this.#c=!0;try{r=(e=>{if("syn"===e.penpal)return{namespace:a,channel:void 0,type:"SYN",participantId:C};if("ack"===e.penpal)return{namespace:a,channel:void 0,type:"ACK2"};if("call"===e.penpal)return{namespace:a,channel:void 0,type:"CALL",id:e.id,methodPath:(t=e.methodName,t.split(".")),args:e.args};var t;if("reply"===e.penpal)return"fulfilled"===e.resolution?{namespace:a,channel:void 0,type:"REPLY",callId:e.id,value:e.returnValue}:{namespace:a,channel:void 0,type:"REPLY",callId:e.id,isError:!0,...e.returnValueIsError?{value:e.returnValue,isSerializedErrorInstance:!0}:{value:e.returnValue}};throw x(e)})(r)}catch(e){return void this.#r?.(`Failed to translate deprecated message: ${e.message}`)}}if(this.#o?.(r))if(this.#h(t)){if(l(r)&&(this.#f(),this.#i=t),f(r)&&!this.#c){if(this.#a=n[0],!this.#a)return void this.#r?.("Ignoring ACK2 because it did not include a MessagePort");this.#a.addEventListener("message",this.#d),this.#a.start()}for(const e of this.#s)e(r)}else this.#r?.(`Received a message from origin \\`${t}\\` which did not match allowed origins \\`[${this.#n.join(", ")}]\\``)}};#d=({data:e})=>{if(this.#o?.(e))for(const t of this.#s)t(e)}},P=document,A=window,R=Array.prototype,L=R.filter,D=R.indexOf,F=R.map,j=R.push,_=R.reverse,$=R.slice,k=R.splice,W=/^#[\\w-]*$/,z=/^\\.[\\w-]*$/,H=/<.+>/,U=/^\\w+$/;function V(e,t){return void 0===t&&(t=P),z.test(e)?t.getElementsByClassName(e.slice(1)):U.test(e)?t.getElementsByTagName(e):t.querySelectorAll(e)}function B(e,t){if(void 0===t&&(t=P),e){if(e.__cash)return e;var n=e;if(te(e)){if(t.__cash&&(t=t[0]),!(n=W.test(e)?t.getElementById(e.slice(1)):H.test(e)?$e(e):V(e,t)))return}else if(ee(e))return this.ready(e);(n.nodeType||n===A)&&(n=[n]),this.length=n.length;for(var r=0,o=this.length;r<o;r++)this[r]=n[r]}}function Y(e,t){return new B(e,t)}var K=Y.fn=Y.prototype=B.prototype={constructor:Y,__cash:!0,length:0,splice:k};K.get=function(e){return void 0===e?$.call(this):this[e<0?e+this.length:e]},K.eq=function(e){return Y(this.get(e))},K.first=function(){return this.eq(0)},K.last=function(){return this.eq(-1)},K.map=function(e){return Y(F.call(this,function(t,n){return e.call(t,n,t)}))},K.slice=function(){return Y($.apply(this,arguments))};var q=/(?:^\\w|[A-Z]|\\b\\w)/g,G=/[\\s-_]+/g;function X(e){return e.replace(q,function(e,t){return e[t?"toUpperCase":"toLowerCase"]()}).replace(G,"")}function J(e,t){for(var n=0,r=e.length;n<r&&!1!==t.call(e[n],e[n],n,e);n++);}Y.camelCase=X,Y.each=J,K.each=function(e){return J(this,function(t,n){return e.call(t,n,t)}),this},K.removeProp=function(e){return this.each(function(t,n){delete n[e]})},Y.extend=K.extend=function(e){void 0===e&&(e=this);for(var t=arguments,n=t.length,r=n<2?0:1;r<n;r++)for(var o in t[r])e[o]=t[r][o];return e};var Z=1;function Q(e,t){var n=e&&(e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector);return!!n&&n.call(e,t)}function ee(e){return"function"==typeof e}function te(e){return"string"==typeof e}function ne(e){return!isNaN(parseFloat(e))&&isFinite(e)}Y.guid=Z,Y.matches=Q,Y.isFunction=ee,Y.isString=te,Y.isNumeric=ne;var re=Array.isArray;function oe(e){return te(e)?function(t,n){return Q(n,e)}:e.__cash?function(t,n){return e.is(n)}:function(e,t,n){return t===n}}Y.isArray=re,K.prop=function(e,t){if(e){if(te(e))return arguments.length<2?this[0]&&this[0][e]:this.each(function(n,r){r[e]=t});for(var n in e)this.prop(n,e[n]);return this}},K.filter=function(e){if(!e)return Y();var t=ee(e)?e:oe(e);return Y(L.call(this,function(n,r){return t.call(n,r,n,e)}))};var ie=/\\S+/g;function se(e){return te(e)&&e.match(ie)||[]}function ae(e){return e.filter(function(e,t,n){return n.indexOf(e)===t})}function ce(e,t,n){if(1===e.nodeType){var r=A.getComputedStyle(e,null);return t?n?r.getPropertyValue(t):r[t]:r}}function ue(e,t){return parseInt(ce(e,t),10)||0}K.hasClass=function(e){var t=se(e),n=!1;return t.length&&this.each(function(e,r){return!(n=r.classList.contains(t[0]))}),n},K.removeAttr=function(e){var t=se(e);return t.length?this.each(function(e,n){J(t,function(e){n.removeAttribute(e)})}):this},K.attr=function(e,t){if(e){if(te(e)){if(arguments.length<2){if(!this[0])return;var n=this[0].getAttribute(e);return null===n?void 0:n}return null===t?this.removeAttr(e):this.each(function(n,r){r.setAttribute(e,t)})}for(var r in e)this.attr(r,e[r]);return this}},K.toggleClass=function(e,t){var n=se(e),r=void 0!==t;return n.length?this.each(function(e,o){J(n,function(e){r?t?o.classList.add(e):o.classList.remove(e):o.classList.toggle(e)})}):this},K.addClass=function(e){return this.toggleClass(e,!0)},K.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},Y.unique=ae,K.add=function(e,t){return Y(ae(this.get().concat(Y(e,t).get())))};var le=/^--/;function de(e){return le.test(e)}var fe={},he=P.createElement("div").style,pe=["webkit","moz","ms","o"];function ge(e,t){if(void 0===t&&(t=de(e)),t)return e;if(!fe[e]){var n=X(e),r=""+n.charAt(0).toUpperCase()+n.slice(1);J((n+" "+pe.join(r+" ")+r).split(" "),function(t){if(t in he)return fe[e]=t,!1})}return fe[e]}Y.prefixedProp=ge;var me={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function ve(e,t,n){return void 0===n&&(n=de(e)),n||me[e]||!ne(t)?t:t+"px"}K.css=function(e,t){if(te(e)){var n=de(e);return e=ge(e,n),arguments.length<2?this[0]&&ce(this[0],e,n):e?(t=ve(e,t,n),this.each(function(r,o){1===o.nodeType&&(n?o.style.setProperty(e,t):o.style[e]=t)})):this}for(var r in e)this.css(r,e[r]);return this};var ye="__cashData",be=/^data-(.*)/;function we(e){return e[ye]=e[ye]||{}}function Ee(e,t){var n=we(e);if(t){if(!(t in n)){var r=e.dataset?e.dataset[t]||e.dataset[X(t)]:Y(e).attr("data-"+t);if(void 0!==r){try{r=JSON.parse(r)}catch(e){}n[t]=r}}return n[t]}return n}function Ne(e,t){return ue(e,"border"+(t?"Left":"Top")+"Width")+ue(e,"padding"+(t?"Left":"Top"))+ue(e,"padding"+(t?"Right":"Bottom"))+ue(e,"border"+(t?"Right":"Bottom")+"Width")}function Se(e,t){for(var n=0,r=t.length;n<r;n++)if(e.indexOf(t[n])<0)return!1;return!0}function Ce(e,t,n){J(e[n],function(e){e[0];var r=e[1];t.removeEventListener(n,r)}),delete e[n]}Y.hasData=function(e){return ye in e},K.data=function(e,t){var n=this;if(!e){if(!this[0])return;return J(this[0].attributes,function(e){var t=e.name.match(be);t&&n.data(t[1])}),Ee(this[0])}if(te(e))return void 0===t?this[0]&&Ee(this[0],e):this.each(function(n,r){return function(e,t,n){we(e)[t]=n}(r,e,t)});for(var r in e)this.data(r,e[r]);return this},K.removeData=function(e){return this.each(function(t,n){return function(e,t){void 0===t?delete e[ye]:delete we(e)[t]}(n,e)})},J(["Width","Height"],function(e){K["inner"+e]=function(){if(this[0])return this[0]===A?A["inner"+e]:this[0]["client"+e]}}),J(["width","height"],function(e,t){K[e]=function(n){return this[0]?arguments.length?(n=parseInt(n,10),this.each(function(r,o){if(1===o.nodeType){var i=ce(o,"boxSizing");o.style[e]=ve(e,n+("border-box"===i?Ne(o,!t):0))}})):this[0]===A?this[0][X("outer-"+e)]:this[0].getBoundingClientRect()[e]-Ne(this[0],!t):void 0===n?void 0:this}}),J(["Width","Height"],function(e,t){K["outer"+e]=function(n){if(this[0])return this[0]===A?A["outer"+e]:this[0]["offset"+e]+(n?ue(this[0],"margin"+(t?"Top":"Left"))+ue(this[0],"margin"+(t?"Bottom":"Right")):0)}});var Oe="__cashEvents";function xe(e){return e[Oe]=e[Oe]||{}}function Te(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Ie(e,t,n,r){var o=xe(e);if(t){var i=o[t];if(!i)return;r&&(r.guid=r.guid||Z++),o[t]=i.filter(function(o){var i=o[0],s=o[1];if(r&&s.guid!==r.guid||!Se(i,n))return!0;e.removeEventListener(t,s)})}else if(n&&n.length)for(t in o)Ie(e,t,n,r);else for(t in o)Ce(o,e,t)}K.off=function(e,t){var n=this;return void 0===e?this.each(function(e,t){return Ie(t)}):J(se(e),function(e){var r=Te(e),o=r[0],i=r[1];n.each(function(e,n){return Ie(n,o,i,t)})}),this},K.on=function(e,t,n,r){var o=this;if(!te(e)){for(var i in e)this.on(i,t,e[i]);return this}return ee(t)&&(n=t,t=!1),J(se(e),function(e){var i=Te(e),s=i[0],a=i[1];o.each(function(e,o){var i=function e(i){if(!i.namespace||Se(a,i.namespace.split("."))){var c=o;if(t){for(var u=i.target;!Q(u,t);){if(u===o)return;if(!(u=u.parentNode))return}c=u}i.namespace=i.namespace||"";var l=n.call(c,i,i.data);r&&Ie(o,s,a,e),!1===l&&(i.preventDefault(),i.stopPropagation())}};i.guid=n.guid=n.guid||Z++,function(e,t,n,r){r.guid=r.guid||Z++;var o=xe(e);o[t]=o[t]||[],o[t].push([n,r]),e.addEventListener(t,r)}(o,s,a,i)})}),this},K.one=function(e,t,n){return this.on(e,t,n,!0)},K.ready=function(e){var t=function(){return e(Y)};return"loading"!==P.readyState?setTimeout(t):P.addEventListener("DOMContentLoaded",t),this},K.trigger=function(e,t){var n=e;if(te(e)){var r=Te(e),o=r[0],i=r[1];(n=P.createEvent("HTMLEvents")).initEvent(o,!0,!0),n.namespace=i.join(".")}return n.data=t,this.each(function(e,t){t.dispatchEvent(n)})};var Me=/select-one/i,Pe=/select-multiple/i;function Ae(e){var t=e.type;return Me.test(t)?function(e){return e.selectedIndex<0?null:e.options[e.selectedIndex].value}(e):Pe.test(t)?function(e){var t=[];return J(e.options,function(e){!e.selected||e.disabled||e.parentNode.disabled||t.push(e.value)}),t}(e):e.value}var Re=/%20/g,Le=/file|reset|submit|button|image/i,De=/radio|checkbox/i;K.serialize=function(){var e="";return this.each(function(t,n){J(n.elements||[n],function(t){if(!t.disabled&&t.name&&"FIELDSET"!==t.tagName&&!Le.test(t.type)&&(!De.test(t.type)||t.checked)){var n=Ae(t);void 0!==n&&J(re(n)?n:[n],function(n){e+=function(e,t){return"&"+encodeURIComponent(e)+"="+encodeURIComponent(t).replace(Re,"+")}(t.name,n)})}})}),e.substr(1)},K.val=function(e){return void 0===e?this[0]&&Ae(this[0]):this.each(function(t,n){var r=Pe.test(n.type),o=null===e?r?[]:"":e;r&&re(o)?J(n.options,function(e){e.selected=o.indexOf(e.value)>=0}):n.value=o})},K.clone=function(){return this.map(function(e,t){return t.cloneNode(!0)})},K.detach=function(){return this.each(function(e,t){t.parentNode&&t.parentNode.removeChild(t)})};var Fe,je=/^\\s*<(\\w+)[^>]*>/,_e=/^\\s*<(\\w+)\\s*\\/?>(?:<\\/\\1>)?\\s*$/;function $e(e){if(function(){if(!Fe){var e=P.createElement("table"),t=P.createElement("tr");Fe={"*":P.createElement("div"),tr:P.createElement("tbody"),td:t,th:t,thead:e,tbody:e,tfoot:e}}}(),!te(e))return[];if(_e.test(e))return[P.createElement(RegExp.$1)];var t=je.test(e)&&RegExp.$1,n=Fe[t]||Fe["*"];return n.innerHTML=e,Y(n.childNodes).detach().get()}function ke(e,t,n){if(void 0!==t){var r=te(t);!r&&t.length?J(t,function(t){return ke(e,t,n)}):J(e,r?function(e){e.insertAdjacentHTML(n?"afterbegin":"beforeend",t)}:function(e,r){return function(e,t,n){n?e.insertBefore(t,e.childNodes[0]):e.appendChild(t)}(e,r?t.cloneNode(!0):t,n)})}}Y.parseHTML=$e,K.empty=function(){var e=this[0];if(e)for(;e.firstChild;)e.removeChild(e.firstChild);return this},K.append=function(){var e=this;return J(arguments,function(t){ke(e,t)}),this},K.appendTo=function(e){return ke(Y(e),this),this},K.html=function(e){if(void 0===e)return this[0]&&this[0].innerHTML;var t=e.nodeType?e[0].outerHTML:e;return this.each(function(e,n){n.innerHTML=t})},K.insertAfter=function(e){var t=this;return Y(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n.nextSibling)})}),this},K.after=function(){var e=this;return J(_.apply(arguments),function(t){_.apply(Y(t).slice()).insertAfter(e)}),this},K.insertBefore=function(e){var t=this;return Y(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n)})}),this},K.before=function(){var e=this;return J(arguments,function(t){Y(t).insertBefore(e)}),this},K.prepend=function(){var e=this;return J(arguments,function(t){ke(e,t,!0)}),this},K.prependTo=function(e){return ke(Y(e),_.apply(this.slice()),!0),this},K.remove=function(){return this.detach().off()},K.replaceWith=function(e){var t=this;return this.each(function(n,r){var o=r.parentNode;if(o){var i=n?Y(e).clone():Y(e);if(!i[0])return t.remove(),!1;o.replaceChild(i[0],r),Y(i[0]).after(i.slice(1))}})},K.replaceAll=function(e){return Y(e).replaceWith(this),this},K.text=function(e){return void 0===e?this[0]?this[0].textContent:"":this.each(function(t,n){n.textContent=e})};var We=P.documentElement;K.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+A.pageYOffset-We.clientTop,left:t.left+A.pageXOffset-We.clientLeft}}},K.offsetParent=function(){return Y(this[0]&&this[0].offsetParent)},K.position=function(){var e=this[0];if(e)return{left:e.offsetLeft,top:e.offsetTop}},K.children=function(e){var t=[];return this.each(function(e,n){j.apply(t,n.children)}),t=Y(ae(t)),e?t.filter(function(t,n){return Q(n,e)}):t},K.contents=function(){var e=[];return this.each(function(t,n){j.apply(e,"IFRAME"===n.tagName?[n.contentDocument]:n.childNodes)}),Y(e.length&&ae(e))},K.find=function(e){for(var t=[],n=0,r=this.length;n<r;n++){var o=V(e,this[n]);o.length&&j.apply(t,o)}return Y(t.length&&ae(t))},K.has=function(e){var t=te(e)?function(t,n){return!!V(e,n).length}:function(t,n){return n.contains(e)};return this.filter(t)},K.is=function(e){if(!e||!this[0])return!1;var t=oe(e),n=!1;return this.each(function(r,o){return!(n=t(r,o,e))}),n},K.next=function(){return Y(this[0]&&this[0].nextElementSibling)},K.not=function(e){if(!e||!this[0])return this;var t=oe(e);return this.filter(function(n,r){return!t(n,r,e)})},K.parent=function(){var e=[];return this.each(function(t,n){n&&n.parentNode&&e.push(n.parentNode)}),Y(ae(e))},K.index=function(e){var t=e?Y(e)[0]:this[0],n=e?this:Y(t).parent().children();return D.call(n,t)},K.closest=function(e){return e&&this[0]?this.is(e)?this.filter(e):this.parent().closest(e):Y()},K.parents=function(e){var t,n=[];return this.each(function(r,o){for(t=o;t&&t.parentNode&&t!==P.body.parentNode;)t=t.parentNode,(!e||e&&Q(t,e))&&n.push(t)}),Y(ae(n))},K.prev=function(){return Y(this[0]&&this[0].previousElementSibling)},K.siblings=function(){var e=this[0];return this.parent().children().filter(function(t,n){return n!==e})};const ze=Y,He=new class{getFiberNode(e){try{const t=Object.keys(e).find(e=>e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"));return t?e[t]:null}catch(e){return console.warn("[ReactFiberService] Error getting fiber node:",e),null}}getDebugOwner(e){const t=this.getFiberNode(e);return t?._debugOwner??null}getDebugSource(e){const t=this.getFiberNode(e);return t?._debugSource??null}getOwnerDebugSource(e){const t=this.getDebugOwner(e);return t?._debugSource??null}hasDirectSourceInfo(e){return!!e.getAttribute("data-nocode-id")||!!this.getDebugSource(e)}hasOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return!1;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n&&n.length>0}getOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return null;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n?n:null}isSelectableElement(e){if(this.hasDirectSourceInfo(e))return!0;const t=this.getFiberNode(e),n=this.getOwnerDebugSource(e);return!!(t?.return&&5!==t.return.tag&&this.hasOwnerNocodeId(e)&&n)}isComponent(e){if(!this.isSelectableElement(e))return!1;if(e.getAttribute("data-nocode-components-name"))return!0;if(this.getDebugSource(e))return!1;const t=this.getFiberNode(e);return!(!t?.return||5===t.return.tag)}getComponentName(e){const t=e.getAttribute("data-nocode-tag-name");if(t)return t;const n=this.getDebugOwner(e);if(n?.type){const e=n.type;if("function"==typeof e){const t=e.displayName||e.name||"Unknown";return this.normalizeComponentName(t)}if("string"==typeof e)return e}return e.tagName.toLowerCase()}normalizeComponentName(e){return e.replace(/\\d+$/,"")}getComponentProps(e){if(!this.isComponent(e))return;const t=this.getDebugOwner(e);return t?.memoizedProps?this.sanitizeProps(t.memoizedProps):void 0}sanitizeProps(e){const t={};for(const[n,r]of Object.entries(e)){if("children"===n||n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}sanitizeValue(e){if(null===e)return null;if(void 0===e)return;if("function"==typeof e)return;if("symbol"==typeof e)return;if("object"!=typeof e)return e;if("$$typeof"in e)return;if(e instanceof Node)return;if(Array.isArray(e)){const t=[];for(const n of e){const e=this.sanitizeValue(n);void 0!==e&&t.push(e)}return t}const t={};for(const[n,r]of Object.entries(e)){if(n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}buildComponentInfo(e){const t=this.isComponent(e),n={isComponent:t,componentType:t?"component":"host",name:t?this.getComponentName(e):e.tagName.toLowerCase()},r=e.getAttribute("data-nocode-components-name"),o=e.getAttribute("data-nocode-components-version");if(r&&(n.componentsName=r),o&&(n.componentsVersion=o),t){const t=this.getComponentProps(e)??{},r=this.removeSpecialProps(t);n.props=r}return n}removeSpecialProps(e){const t={};for(const[n,r]of Object.entries(e))"componentsName"!==n&&"componentsVersion"!==n&&(n.startsWith("data-nocode-")||(t[n]=r));return t}},Ue="data-dnd";function Ve(e){if(!e)return{};const t=e.split(":");if(t.length>=3){const n=t.pop(),r=t.pop(),o=t.join(":");return{id:e,filename:decodeURIComponent(o),component:r,codeId:n}}return 2===t.length?{id:e,component:t[0],codeId:t[1]}:{id:e}}const Be=`[${Ue}]`;function Ye(e){return document.querySelector(`[${Ue}="${e}"]`)}const Ke=(e,t)=>{const n=e.getBoundingClientRect(),{x:r,y:o}=((e,t)=>{let n=e.x,r=e.y;if(t){const e=t.getBoundingClientRect();n-=e.left,r-=e.top}return{x:n,y:r}})({x:n.left,y:n.top},t);return{width:e.offsetWidth,height:e.offsetHeight,top:o,left:r}},qe=(e,t)=>{const n=Ke(e,t),r=function(e){return e.dataset}(e),o=Ge(e),i=Xe(e),s=(e=>{const t=window.getComputedStyle(e);return{display:t.display,flexDirection:t.flexDirection,flexWrap:t.flexWrap,position:t.position}})(e),a=r.dnd||"",c=Ve(a),u=function(e){return He.buildComponentInfo(e)}(e),l=function(e){return"true"===e.getAttribute("data-nocode-container-placeholder")}(e),d=(e=>{const t=e.querySelectorAll(`:scope > ${Be}`);if(!t.length)return[];const n=[];return t.forEach(e=>{const t=e;n.push(Ke(t))}),n})(e);return{id:a,codeId:c.codeId,name:c.component||e.tagName.toLowerCase(),filename:c.filename,bounding:n,display:o,computedStyle:s,text:i,containerPlaceholder:l||void 0,componentInfo:u,childrenBoundings:d.length>0?d:void 0}},Ge=e=>ze(e).css("display"),Xe=e=>{const t=[];return e.childNodes.forEach(e=>{if(e.nodeType===Node.TEXT_NODE){const n=e.textContent?.trim()||"";n&&t.push(n)}}),t.join(" ")};function Je(e){const t=["div","p","section","article","main","header","footer","nav","h1","h2","h3","h4","h5","h6","span","a","button","i","input","textarea","select","label","form","ul","ol","li","table","thead","tbody","tr","td","th","img","video","audio","canvas","svg"];try{const n=e.tagName.toLowerCase();if(!t.includes(n))return!1;const r=window.getComputedStyle(e);if("none"===r.display||"hidden"===r.visibility||"0"===r.opacity)return!1;const o=e.getBoundingClientRect();return!("inline"!==r.display&&"inline-block"!==r.display&&(0===o.width||0===o.height))}catch(e){return console.warn("Element validation failed:",e),!1}}function Ze(e,t=20){let n=e,r=0;for(;n&&r<t;){if(n.getAttribute(Ue))return n;n=n.parentElement,r++}return null}function Qe(e){const t=window.getComputedStyle(e),n={};for(let e=0;e<t.length;e++){const r=t[e];n[r]=t.getPropertyValue(r)}return n}let et=null;function tt(e){return(...t)=>{try{const n=e(...t);return n&&"function"==typeof n.then?n.catch(n=>(console.error(`Async error in ${e.name}:`,n),console.error("Error stack:",n.stack),console.error("Function arguments:",t),null)):n}catch(n){return console.error(`Sync error in ${e.name}:`,n),n instanceof Error&&console.error("Error stack:",n.stack),console.error("Function arguments:",t),null}}}const nt={getDraggableParentsData:(e,t)=>{const n=function(e,t){const n=((e,t)=>{const n=document.elementFromPoint(e,t);if(!n)return null;const r=n=>{if(n?.shadowRoot){const o=n.shadowRoot.elementFromPoint(e,t);return o===n?n:o?.shadowRoot?r(o):o||n}return n};return r(n)})(e,t);if(!n)return null;let r=n;if(!Je(r)){let e=r.parentElement,t=0;const n=20;for(;e&&t<n;){if(Je(e)){r=e;break}e=e.parentElement,t++}if(!Je(r))return null}const o=Ze(r);return o&&Je(o)?o:null}(e.x,e.y);if(!n)return;const r=(e=>{const t=ze(e).closest(Be).get(0),n=ze(e).parents(Be).get();return n[0]!==t&&n.unshift(t),n})(n);if(r.length){if(t){const e=r.map(e=>qe(e));return{...e[0],computedStyle:Qe(n),parents:e.slice(1)}}return{...qe(r[0]),computedStyle:Qe(r[0])}}},getElementDataById:e=>{const t=Ye(e);if(t)return{...qe(t),computedStyle:Qe(t)};console.warn("[getElementDataById] Element not found for domId:",e)},getEditableTextElementAtPosition:e=>{const t=function(e,t){if(document.caretPositionFromPoint){const n=document.caretPositionFromPoint(e,t);return n?.offsetNode??null}if(document.caretRangeFromPoint){const n=document.caretRangeFromPoint(e,t);return n?.startContainer??null}return document.elementFromPoint(e,t)}(e.x,e.y);if(!t)return void console.log("[getEditableTextElementAtPosition] No node at point:",e);if(t.nodeType!==Node.TEXT_NODE)return void console.log("[getEditableTextElementAtPosition] Not a text node:",t.nodeType);const n=t.textContent?.trim();if(!n)return void console.log("[getEditableTextElementAtPosition] Empty text node");const r=t.parentElement;if(!r)return void console.log("[getEditableTextElementAtPosition] No parent element");const o=Ze(r);if(o){if(function(e){const t=e.childNodes;let n=!1;for(let e=0;e<t.length;e++){const r=t[e];if(r.nodeType===Node.ELEMENT_NODE)return!1;if(r.nodeType===Node.TEXT_NODE){const e=r.textContent?.trim();e&&(n=!0)}}return n}(o))return console.log("[getEditableTextElementAtPosition] Found editable text element:",o.tagName,o.textContent),{...qe(o),computedStyle:Qe(o)};console.log("[getEditableTextElementAtPosition] Element has child elements, cannot edit directly:",o.tagName)}else console.log("[getEditableTextElementAtPosition] No marked element found")},updateElementTextContent:(e,t)=>{const n=Ye(e);return n?(n.textContent=t,!0):(console.warn("[updateElementTextContent] Element not found:",e),!1)},scrollToElement:e=>{const t=Ye(e);return t?(t.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),!0):(console.warn("[scrollToElement] Element not found for domId:",e),!1)},scrollPageBy:(e,t)=>(window.scrollBy(e,t),!0),highlightElement:e=>{if(et&&(et.style.outline="",et.style.outlineOffset="",et=null),!e)return!0;const t=Ye(e);return t?(t.style.outline="2px solid rgba(54, 210, 190, 0.8)",t.style.outlineOffset="-1px",et=t,!0):(console.warn("[highlightElement] Element not found:",e),!1)},getProjectLibVersions:function(){try{const e=document.body;if(!e)return console.warn("[sandbox] document.body is not available"),null;const t=e.getAttribute("data-nocode-lib-versions");if(!t)return console.warn("[sandbox] data-nocode-lib-versions attribute not found on body"),null;const n=JSON.parse(t);return"object"!=typeof n||null===n?(console.warn("[sandbox] data-nocode-lib-versions is not a valid object"),null):n}catch(e){return console.error("[sandbox] Failed to parse data-nocode-lib-versions:",e),null}},getCompilerVersion:function(){try{const e=document.body;return e?e.getAttribute("data-nocode-compiler-version"):null}catch(e){return console.error("[sandbox] Failed to get compiler version:",e),null}},getRuntimeNodeTree:()=>{try{const e=document.querySelectorAll(Be);if(!e.length)return[];const t=new Map;e.forEach(e=>{const n=e.getAttribute(Ue)||"";if(!n)return;const r=Ve(n);t.set(e,{id:n,component:r.component||e.tagName.toLowerCase(),children:[]})});const n=[];e.forEach(e=>{const r=t.get(e);if(!r)return;let o,i=e.parentElement;for(;i;){if(t.has(i)){o=t.get(i);break}i=i.parentElement}o?o.children.push(r):n.push(r)});const r=e=>{e.children&&0===e.children.length?delete e.children:e.children&&e.children.forEach(r)};return n.forEach(r),n}catch(e){return console.error("[sandbox] Failed to build runtime node tree:",e),[]}}},rt=Object.fromEntries(Object.entries(nt).map(([e,t])=>[e,tt(t)])),ot="nocode-design-mode";let it=null,st=!1,at=null;const ct=t()(()=>{it?.onWindowMutated&&(console.log(`${ot} - Notifying parent of DOM mutation`),it.onWindowMutated({added:{},removed:{}}))},100),ut=async()=>{if(st||it)return it;st=!0,console.log(`${ot} - Creating penpal connection`);const e=(({messenger:e,methods:t={},timeout:n,channel:o,log:i})=>{if(!e)throw new r("INVALID_ARGUMENT","messenger must be defined");if(I.has(e))throw new r("INVALID_ARGUMENT","A messenger can only be used for a single connection");I.add(e);const s=[e.destroy],u=(e=>{let t,n=!1;return(...r)=>(n||(n=!0,t=e(...r)),t)})(t=>{if(t){const t={namespace:a,channel:o,type:"DESTROY"};try{e.sendMessage(t)}catch(e){}}for(const e of s)e();i?.("Connection destroyed")}),l=e=>(e=>c(e)&&e.namespace===a)(e)&&e.channel===o;return{promise:(async()=>{try{e.initialize({log:i,validateReceivedMessage:l}),e.addMessageHandler(e=>{(e=>"DESTROY"===e.type)(e)&&u(!1)});const{remoteProxy:r,destroy:a}=await T({messenger:e,methods:t,timeout:n,channel:o,log:i});return s.push(a),r}catch(e){throw u(!0),e}})(),destroy:()=>{u(!0)}}})({messenger:new M({remoteWindow:window===window.top?(console.warn(`${ot} - Not in an iframe, using window.parent as fallback`),window.parent):window.parent===window.top?window.parent:window.top?(console.log(`${ot} - Using window.top for nested iframe scenario`),window.top):window.parent,allowedOrigins:["*"]}),methods:rt});return e.promise.then(e=>{if(!e)return console.error(`${ot} - Failed to setup penpal connection: child is null`),void lt();it=e,console.log(`${ot} - Penpal connection set`),(()=>{if(at)return;at=new MutationObserver(e=>{e.some(e=>{const t=e.target;return"SCRIPT"!==t.tagName&&"STYLE"!==t.tagName&&("attributes"!==e.type||"style"===e.attributeName||"class"===e.attributeName)})&&ct()});const e=()=>{document.body&&at&&(at.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"],characterData:!0}),console.log(`${ot} - MutationObserver started`))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()})()}).finally(()=>{st=!1}),e.promise.catch(e=>{console.error(`${ot} - Failed to setup penpal connection:`,e),lt()}),it},lt=t()(()=>{st||(console.log(`${ot} - Reconnecting to penpal parent`),it=null,ut())},1e3);ut()})()})();';
344
+ return '(()=>{var e={6:(e,t,n)=>{var r=n(714).Symbol;e.exports=r},12:(e,t,n)=>{var r=n(400),o=n(835),i=n(639),s=Math.max,a=Math.min;e.exports=function(e,t,n){var c,u,l,d,f,h,p=0,g=!1,m=!1,v=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){var n=c,r=u;return c=u=void 0,p=t,d=e.apply(r,n)}function b(e){var n=e-h;return void 0===h||n>=t||n<0||m&&e-p>=l}function w(){var e=o();if(b(e))return E(e);f=setTimeout(w,function(e){var n=t-(e-h);return m?a(n,l-(e-p)):n}(e))}function E(e){return f=void 0,v&&c?y(e):(c=u=void 0,d)}function N(){var e=o(),n=b(e);if(c=arguments,u=this,h=e,n){if(void 0===f)return function(e){return p=e,f=setTimeout(w,t),g?y(e):d}(h);if(m)return clearTimeout(f),f=setTimeout(w,t),y(h)}return void 0===f&&(f=setTimeout(w,t)),d}return t=i(t)||0,r(n)&&(g=!!n.leading,l=(m="maxWait"in n)?s(i(n.maxWait)||0,t):l,v="trailing"in n?!!n.trailing:v),N.cancel=function(){void 0!==f&&clearTimeout(f),p=0,c=h=u=f=void 0},N.flush=function(){return void 0===f?d:E(o())},N}},103:(e,t,n)=>{var r=n(997),o=/^\\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},271:(e,t,n)=>{var r=n(6),o=n(650),i=n(881),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?o(e):i(e)}},400:e=>{e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},583:e=>{e.exports=function(e){return null!=e&&"object"==typeof e}},603:(e,t,n)=>{var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},639:(e,t,n)=>{var r=n(103),o=n(400),i=n(975),s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=a.test(e);return n||c.test(e)?u(e.slice(2),n?2:8):s.test(e)?NaN:+e}},650:(e,t,n)=>{var r=n(6),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var o=s.call(e);return r&&(t?e[a]=n:delete e[a]),o}},714:(e,t,n)=>{var r=n(603),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();e.exports=i},835:(e,t,n)=>{var r=n(714);e.exports=function(){return r.Date.now()}},881:e=>{var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},975:(e,t,n)=>{var r=n(271),o=n(583);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},997:e=>{var t=/\\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=n(12),t=n.n(e),r=class extends Error{code;constructor(e,t){super(t),this.name="PenpalError",this.code=e}},o=e=>({name:e.name,message:e.message,stack:e.stack,penpalCode:e instanceof r?e.code:void 0}),i=Symbol("Reply"),s=class{value;transferables;#e=i;constructor(e,t){this.value=e,this.transferables=t?.transferables}},a="penpal",c=e=>"object"==typeof e&&null!==e,u=e=>"function"==typeof e,l=e=>"SYN"===e.type,d=e=>"ACK1"===e.type,f=e=>"ACK2"===e.type,h=e=>"CALL"===e.type,p=e=>"REPLY"===e.type,g=(e,t=[])=>{const n=[];for(const r of Object.keys(e)){const o=e[r];u(o)?n.push([...t,r]):c(o)&&n.push(...g(o,[...t,r]))}return n},m=e=>e.join("."),v=(e,t,n)=>({namespace:a,channel:e,type:"REPLY",callId:t,isError:!0,...n instanceof Error?{value:o(n),isSerializedErrorInstance:!0}:{value:n}}),y=crypto.randomUUID?.bind(crypto)??(()=>new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")),b=Symbol("CallOptions"),w=class{transferables;timeout;#e=b;constructor(e){this.transferables=e?.transferables,this.timeout=e?.timeout}},E=new Set(["apply","call","bind"]),N=(e,t,n=[])=>new Proxy(n.length?()=>{}:Object.create(null),{get(r,o){if("then"!==o)return n.length&&E.has(o)?Reflect.get(r,o):N(e,t,[...n,o])},apply:(t,r,o)=>e(n,o)}),S=e=>new r("CONNECTION_DESTROYED",`Method call ${m(e)}() failed due to destroyed connection`),C="deprecated-penpal",x=e=>e.join("."),O=e=>new r("TRANSMISSION_FAILED",`Unexpected message to translate: ${(e=>{try{return JSON.stringify(e)}catch(t){return String(e)}})(e)}`),I=({messenger:e,methods:t,timeout:n,channel:o,log:i})=>{const b=y();let E;const x=[];let O=!1;const I=g(t),{promise:M,resolve:T,reject:P}=(()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}})(),A=void 0!==n?setTimeout(()=>{P(new r("CONNECTION_TIMEOUT",`Connection timed out after ${n}ms`))},n):void 0,R=()=>{for(const e of x)e()},L=()=>{if(O)return;x.push(((e,t,n,o)=>{let i=!1;const l=async l=>{if(i)return;if(!h(l))return;o?.(`Received ${m(l.methodPath)}() call`,l);const{methodPath:d,args:f,id:p}=l;let g,y;try{const e=((e,t)=>{const n=e.reduce((e,t)=>c(e)?e[t]:void 0,t);return u(n)?n:void 0})(d,t);if(!e)throw new r("METHOD_NOT_FOUND",`Method \\`${m(d)}\\` is not found.`);let o=await e(...f);o instanceof s&&(y=o.transferables,o=await o.value),g={namespace:a,channel:n,type:"REPLY",callId:p,value:o}}catch(e){g=v(n,p,e)}if(!i)try{o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g,y)}catch(t){throw"DataCloneError"===t.name&&(g=v(n,p,t),o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g)),t}};return e.addMessageHandler(l),()=>{i=!0,e.removeMessageHandler(l)}})(e,t,o,i));const{remoteProxy:n,destroy:l}=((e,t,n)=>{let o=!1;const i=new Map,s=e=>{if(!p(e))return;const{callId:t,value:o,isError:s,isSerializedErrorInstance:a}=e,c=i.get(t);c&&(i.delete(t),n?.(`Received ${m(c.methodPath)}() call`,e),s?c.reject(a?(({name:e,message:t,stack:n,penpalCode:o})=>{const i=o?new r(o,t):new Error(t);return i.name=e,i.stack=n,i})(o):o):c.resolve(o))};return e.addMessageHandler(s),{remoteProxy:N((s,c)=>{if(o)throw S(s);const u=y(),l=c[c.length-1],d=l instanceof w,{timeout:f,transferables:h}=d?l:{},p=d?c.slice(0,-1):c;return new Promise((o,c)=>{const l=void 0!==f?window.setTimeout(()=>{i.delete(u),c(new r("METHOD_CALL_TIMEOUT",`Method call ${m(s)}() timed out after ${f}ms`))},f):void 0;i.set(u,{methodPath:s,resolve:o,reject:c,timeoutId:l});try{const r={namespace:a,channel:t,type:"CALL",id:u,methodPath:s,args:p};n?.(`Sending ${m(s)}() call`,r),e.sendMessage(r,h)}catch(e){c(new r("TRANSMISSION_FAILED",e.message))}})},n),destroy:()=>{o=!0,e.removeMessageHandler(s);for(const{methodPath:e,reject:t,timeoutId:n}of i.values())clearTimeout(n),t(S(e));i.clear()}}})(e,o,i);x.push(l),clearTimeout(A),O=!0,T({remoteProxy:n,destroy:R})},D=()=>{const t={namespace:a,type:"SYN",channel:o,participantId:b};i?.("Sending handshake SYN",t);try{e.sendMessage(t)}catch(e){P(new r("TRANSMISSION_FAILED",e.message))}},F=t=>{l(t)&&(t=>{if(i?.("Received handshake SYN",t),t.participantId===E&&E!==C)return;if(E=t.participantId,D(),!(b>E||E===C))return;const n={namespace:a,channel:o,type:"ACK1",methodPaths:I};i?.("Sending handshake ACK1",n);try{e.sendMessage(n)}catch(e){return void P(new r("TRANSMISSION_FAILED",e.message))}})(t),d(t)&&(t=>{i?.("Received handshake ACK1",t);const n={namespace:a,channel:o,type:"ACK2"};i?.("Sending handshake ACK2",n);try{e.sendMessage(n)}catch(e){return void P(new r("TRANSMISSION_FAILED",e.message))}L()})(t),f(t)&&(e=>{i?.("Received handshake ACK2",e),L()})(t)};return e.addMessageHandler(F),x.push(()=>e.removeMessageHandler(F)),D(),M},M=new WeakSet,T=class{#t;#n;#r;#o;#i;#s=new Set;#a;#c=!1;constructor({remoteWindow:e,allowedOrigins:t}){if(!e)throw new r("INVALID_ARGUMENT","remoteWindow must be defined");this.#t=e,this.#n=t?.length?t:[window.origin]}initialize=({log:e,validateReceivedMessage:t})=>{this.#r=e,this.#o=t,window.addEventListener("message",this.#u)};sendMessage=(e,t)=>{if(l(e)){const n=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:n,transfer:t})}if(d(e)||this.#c){const n=this.#c?(e=>{if(d(e))return{penpal:"synAck",methodNames:e.methodPaths.map(x)};if(h(e))return{penpal:"call",id:e.id,methodName:x(e.methodPath),args:e.args};if(p(e))return e.isError?{penpal:"reply",id:e.callId,resolution:"rejected",...e.isSerializedErrorInstance?{returnValue:e.value,returnValueIsError:!0}:{returnValue:e.value}}:{penpal:"reply",id:e.callId,resolution:"fulfilled",returnValue:e.value};throw O(e)})(e):e,r=this.#l(e);return void this.#t.postMessage(n,{targetOrigin:r,transfer:t})}if(f(e)){const{port1:n,port2:r}=new MessageChannel;this.#a=n,n.addEventListener("message",this.#d),n.start();const o=[r,...t||[]],i=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:i,transfer:o})}if(!this.#a)throw new r("TRANSMISSION_FAILED","Cannot send message because the MessagePort is not connected");this.#a.postMessage(e,{transfer:t})};addMessageHandler=e=>{this.#s.add(e)};removeMessageHandler=e=>{this.#s.delete(e)};destroy=()=>{window.removeEventListener("message",this.#u),this.#f(),this.#s.clear()};#h=e=>this.#n.some(t=>t instanceof RegExp?t.test(e):t===e||"*"===t);#l=e=>{if(l(e))return"*";if(!this.#i)throw new r("TRANSMISSION_FAILED","Cannot send message because the remote origin is not established");return"null"===this.#i&&this.#n.includes("*")?"*":this.#i};#f=()=>{this.#a?.removeEventListener("message",this.#d),this.#a?.close(),this.#a=void 0};#u=({source:e,origin:t,ports:n,data:r})=>{if(e===this.#t){if((e=>c(e)&&"penpal"in e)(r)){this.#r?.("Please upgrade the child window to the latest version of Penpal."),this.#c=!0;try{r=(e=>{if("syn"===e.penpal)return{namespace:a,channel:void 0,type:"SYN",participantId:C};if("ack"===e.penpal)return{namespace:a,channel:void 0,type:"ACK2"};if("call"===e.penpal)return{namespace:a,channel:void 0,type:"CALL",id:e.id,methodPath:(t=e.methodName,t.split(".")),args:e.args};var t;if("reply"===e.penpal)return"fulfilled"===e.resolution?{namespace:a,channel:void 0,type:"REPLY",callId:e.id,value:e.returnValue}:{namespace:a,channel:void 0,type:"REPLY",callId:e.id,isError:!0,...e.returnValueIsError?{value:e.returnValue,isSerializedErrorInstance:!0}:{value:e.returnValue}};throw O(e)})(r)}catch(e){return void this.#r?.(`Failed to translate deprecated message: ${e.message}`)}}if(this.#o?.(r))if(this.#h(t)){if(l(r)&&(this.#f(),this.#i=t),f(r)&&!this.#c){if(this.#a=n[0],!this.#a)return void this.#r?.("Ignoring ACK2 because it did not include a MessagePort");this.#a.addEventListener("message",this.#d),this.#a.start()}for(const e of this.#s)e(r)}else this.#r?.(`Received a message from origin \\`${t}\\` which did not match allowed origins \\`[${this.#n.join(", ")}]\\``)}};#d=({data:e})=>{if(this.#o?.(e))for(const t of this.#s)t(e)}},P=document,A=window,R=Array.prototype,L=R.filter,D=R.indexOf,F=R.map,$=R.push,j=R.reverse,_=R.slice,k=R.splice,W=/^#[\\w-]*$/,z=/^\\.[\\w-]*$/,H=/<.+>/,U=/^\\w+$/;function V(e,t){return void 0===t&&(t=P),z.test(e)?t.getElementsByClassName(e.slice(1)):U.test(e)?t.getElementsByTagName(e):t.querySelectorAll(e)}function B(e,t){if(void 0===t&&(t=P),e){if(e.__cash)return e;var n=e;if(te(e)){if(t.__cash&&(t=t[0]),!(n=W.test(e)?t.getElementById(e.slice(1)):H.test(e)?_e(e):V(e,t)))return}else if(ee(e))return this.ready(e);(n.nodeType||n===A)&&(n=[n]),this.length=n.length;for(var r=0,o=this.length;r<o;r++)this[r]=n[r]}}function Y(e,t){return new B(e,t)}var q=Y.fn=Y.prototype=B.prototype={constructor:Y,__cash:!0,length:0,splice:k};q.get=function(e){return void 0===e?_.call(this):this[e<0?e+this.length:e]},q.eq=function(e){return Y(this.get(e))},q.first=function(){return this.eq(0)},q.last=function(){return this.eq(-1)},q.map=function(e){return Y(F.call(this,function(t,n){return e.call(t,n,t)}))},q.slice=function(){return Y(_.apply(this,arguments))};var K=/(?:^\\w|[A-Z]|\\b\\w)/g,G=/[\\s-_]+/g;function X(e){return e.replace(K,function(e,t){return e[t?"toUpperCase":"toLowerCase"]()}).replace(G,"")}function J(e,t){for(var n=0,r=e.length;n<r&&!1!==t.call(e[n],e[n],n,e);n++);}Y.camelCase=X,Y.each=J,q.each=function(e){return J(this,function(t,n){return e.call(t,n,t)}),this},q.removeProp=function(e){return this.each(function(t,n){delete n[e]})},Y.extend=q.extend=function(e){void 0===e&&(e=this);for(var t=arguments,n=t.length,r=n<2?0:1;r<n;r++)for(var o in t[r])e[o]=t[r][o];return e};var Z=1;function Q(e,t){var n=e&&(e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector);return!!n&&n.call(e,t)}function ee(e){return"function"==typeof e}function te(e){return"string"==typeof e}function ne(e){return!isNaN(parseFloat(e))&&isFinite(e)}Y.guid=Z,Y.matches=Q,Y.isFunction=ee,Y.isString=te,Y.isNumeric=ne;var re=Array.isArray;function oe(e){return te(e)?function(t,n){return Q(n,e)}:e.__cash?function(t,n){return e.is(n)}:function(e,t,n){return t===n}}Y.isArray=re,q.prop=function(e,t){if(e){if(te(e))return arguments.length<2?this[0]&&this[0][e]:this.each(function(n,r){r[e]=t});for(var n in e)this.prop(n,e[n]);return this}},q.filter=function(e){if(!e)return Y();var t=ee(e)?e:oe(e);return Y(L.call(this,function(n,r){return t.call(n,r,n,e)}))};var ie=/\\S+/g;function se(e){return te(e)&&e.match(ie)||[]}function ae(e){return e.filter(function(e,t,n){return n.indexOf(e)===t})}function ce(e,t,n){if(1===e.nodeType){var r=A.getComputedStyle(e,null);return t?n?r.getPropertyValue(t):r[t]:r}}function ue(e,t){return parseInt(ce(e,t),10)||0}q.hasClass=function(e){var t=se(e),n=!1;return t.length&&this.each(function(e,r){return!(n=r.classList.contains(t[0]))}),n},q.removeAttr=function(e){var t=se(e);return t.length?this.each(function(e,n){J(t,function(e){n.removeAttribute(e)})}):this},q.attr=function(e,t){if(e){if(te(e)){if(arguments.length<2){if(!this[0])return;var n=this[0].getAttribute(e);return null===n?void 0:n}return null===t?this.removeAttr(e):this.each(function(n,r){r.setAttribute(e,t)})}for(var r in e)this.attr(r,e[r]);return this}},q.toggleClass=function(e,t){var n=se(e),r=void 0!==t;return n.length?this.each(function(e,o){J(n,function(e){r?t?o.classList.add(e):o.classList.remove(e):o.classList.toggle(e)})}):this},q.addClass=function(e){return this.toggleClass(e,!0)},q.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},Y.unique=ae,q.add=function(e,t){return Y(ae(this.get().concat(Y(e,t).get())))};var le=/^--/;function de(e){return le.test(e)}var fe={},he=P.createElement("div").style,pe=["webkit","moz","ms","o"];function ge(e,t){if(void 0===t&&(t=de(e)),t)return e;if(!fe[e]){var n=X(e),r=""+n.charAt(0).toUpperCase()+n.slice(1);J((n+" "+pe.join(r+" ")+r).split(" "),function(t){if(t in he)return fe[e]=t,!1})}return fe[e]}Y.prefixedProp=ge;var me={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function ve(e,t,n){return void 0===n&&(n=de(e)),n||me[e]||!ne(t)?t:t+"px"}q.css=function(e,t){if(te(e)){var n=de(e);return e=ge(e,n),arguments.length<2?this[0]&&ce(this[0],e,n):e?(t=ve(e,t,n),this.each(function(r,o){1===o.nodeType&&(n?o.style.setProperty(e,t):o.style[e]=t)})):this}for(var r in e)this.css(r,e[r]);return this};var ye="__cashData",be=/^data-(.*)/;function we(e){return e[ye]=e[ye]||{}}function Ee(e,t){var n=we(e);if(t){if(!(t in n)){var r=e.dataset?e.dataset[t]||e.dataset[X(t)]:Y(e).attr("data-"+t);if(void 0!==r){try{r=JSON.parse(r)}catch(e){}n[t]=r}}return n[t]}return n}function Ne(e,t){return ue(e,"border"+(t?"Left":"Top")+"Width")+ue(e,"padding"+(t?"Left":"Top"))+ue(e,"padding"+(t?"Right":"Bottom"))+ue(e,"border"+(t?"Right":"Bottom")+"Width")}function Se(e,t){for(var n=0,r=t.length;n<r;n++)if(e.indexOf(t[n])<0)return!1;return!0}function Ce(e,t,n){J(e[n],function(e){e[0];var r=e[1];t.removeEventListener(n,r)}),delete e[n]}Y.hasData=function(e){return ye in e},q.data=function(e,t){var n=this;if(!e){if(!this[0])return;return J(this[0].attributes,function(e){var t=e.name.match(be);t&&n.data(t[1])}),Ee(this[0])}if(te(e))return void 0===t?this[0]&&Ee(this[0],e):this.each(function(n,r){return function(e,t,n){we(e)[t]=n}(r,e,t)});for(var r in e)this.data(r,e[r]);return this},q.removeData=function(e){return this.each(function(t,n){return function(e,t){void 0===t?delete e[ye]:delete we(e)[t]}(n,e)})},J(["Width","Height"],function(e){q["inner"+e]=function(){if(this[0])return this[0]===A?A["inner"+e]:this[0]["client"+e]}}),J(["width","height"],function(e,t){q[e]=function(n){return this[0]?arguments.length?(n=parseInt(n,10),this.each(function(r,o){if(1===o.nodeType){var i=ce(o,"boxSizing");o.style[e]=ve(e,n+("border-box"===i?Ne(o,!t):0))}})):this[0]===A?this[0][X("outer-"+e)]:this[0].getBoundingClientRect()[e]-Ne(this[0],!t):void 0===n?void 0:this}}),J(["Width","Height"],function(e,t){q["outer"+e]=function(n){if(this[0])return this[0]===A?A["outer"+e]:this[0]["offset"+e]+(n?ue(this[0],"margin"+(t?"Top":"Left"))+ue(this[0],"margin"+(t?"Bottom":"Right")):0)}});var xe="__cashEvents";function Oe(e){return e[xe]=e[xe]||{}}function Ie(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Me(e,t,n,r){var o=Oe(e);if(t){var i=o[t];if(!i)return;r&&(r.guid=r.guid||Z++),o[t]=i.filter(function(o){var i=o[0],s=o[1];if(r&&s.guid!==r.guid||!Se(i,n))return!0;e.removeEventListener(t,s)})}else if(n&&n.length)for(t in o)Me(e,t,n,r);else for(t in o)Ce(o,e,t)}q.off=function(e,t){var n=this;return void 0===e?this.each(function(e,t){return Me(t)}):J(se(e),function(e){var r=Ie(e),o=r[0],i=r[1];n.each(function(e,n){return Me(n,o,i,t)})}),this},q.on=function(e,t,n,r){var o=this;if(!te(e)){for(var i in e)this.on(i,t,e[i]);return this}return ee(t)&&(n=t,t=!1),J(se(e),function(e){var i=Ie(e),s=i[0],a=i[1];o.each(function(e,o){var i=function e(i){if(!i.namespace||Se(a,i.namespace.split("."))){var c=o;if(t){for(var u=i.target;!Q(u,t);){if(u===o)return;if(!(u=u.parentNode))return}c=u}i.namespace=i.namespace||"";var l=n.call(c,i,i.data);r&&Me(o,s,a,e),!1===l&&(i.preventDefault(),i.stopPropagation())}};i.guid=n.guid=n.guid||Z++,function(e,t,n,r){r.guid=r.guid||Z++;var o=Oe(e);o[t]=o[t]||[],o[t].push([n,r]),e.addEventListener(t,r)}(o,s,a,i)})}),this},q.one=function(e,t,n){return this.on(e,t,n,!0)},q.ready=function(e){var t=function(){return e(Y)};return"loading"!==P.readyState?setTimeout(t):P.addEventListener("DOMContentLoaded",t),this},q.trigger=function(e,t){var n=e;if(te(e)){var r=Ie(e),o=r[0],i=r[1];(n=P.createEvent("HTMLEvents")).initEvent(o,!0,!0),n.namespace=i.join(".")}return n.data=t,this.each(function(e,t){t.dispatchEvent(n)})};var Te=/select-one/i,Pe=/select-multiple/i;function Ae(e){var t=e.type;return Te.test(t)?function(e){return e.selectedIndex<0?null:e.options[e.selectedIndex].value}(e):Pe.test(t)?function(e){var t=[];return J(e.options,function(e){!e.selected||e.disabled||e.parentNode.disabled||t.push(e.value)}),t}(e):e.value}var Re=/%20/g,Le=/file|reset|submit|button|image/i,De=/radio|checkbox/i;q.serialize=function(){var e="";return this.each(function(t,n){J(n.elements||[n],function(t){if(!t.disabled&&t.name&&"FIELDSET"!==t.tagName&&!Le.test(t.type)&&(!De.test(t.type)||t.checked)){var n=Ae(t);void 0!==n&&J(re(n)?n:[n],function(n){e+=function(e,t){return"&"+encodeURIComponent(e)+"="+encodeURIComponent(t).replace(Re,"+")}(t.name,n)})}})}),e.substr(1)},q.val=function(e){return void 0===e?this[0]&&Ae(this[0]):this.each(function(t,n){var r=Pe.test(n.type),o=null===e?r?[]:"":e;r&&re(o)?J(n.options,function(e){e.selected=o.indexOf(e.value)>=0}):n.value=o})},q.clone=function(){return this.map(function(e,t){return t.cloneNode(!0)})},q.detach=function(){return this.each(function(e,t){t.parentNode&&t.parentNode.removeChild(t)})};var Fe,$e=/^\\s*<(\\w+)[^>]*>/,je=/^\\s*<(\\w+)\\s*\\/?>(?:<\\/\\1>)?\\s*$/;function _e(e){if(function(){if(!Fe){var e=P.createElement("table"),t=P.createElement("tr");Fe={"*":P.createElement("div"),tr:P.createElement("tbody"),td:t,th:t,thead:e,tbody:e,tfoot:e}}}(),!te(e))return[];if(je.test(e))return[P.createElement(RegExp.$1)];var t=$e.test(e)&&RegExp.$1,n=Fe[t]||Fe["*"];return n.innerHTML=e,Y(n.childNodes).detach().get()}function ke(e,t,n){if(void 0!==t){var r=te(t);!r&&t.length?J(t,function(t){return ke(e,t,n)}):J(e,r?function(e){e.insertAdjacentHTML(n?"afterbegin":"beforeend",t)}:function(e,r){return function(e,t,n){n?e.insertBefore(t,e.childNodes[0]):e.appendChild(t)}(e,r?t.cloneNode(!0):t,n)})}}Y.parseHTML=_e,q.empty=function(){var e=this[0];if(e)for(;e.firstChild;)e.removeChild(e.firstChild);return this},q.append=function(){var e=this;return J(arguments,function(t){ke(e,t)}),this},q.appendTo=function(e){return ke(Y(e),this),this},q.html=function(e){if(void 0===e)return this[0]&&this[0].innerHTML;var t=e.nodeType?e[0].outerHTML:e;return this.each(function(e,n){n.innerHTML=t})},q.insertAfter=function(e){var t=this;return Y(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n.nextSibling)})}),this},q.after=function(){var e=this;return J(j.apply(arguments),function(t){j.apply(Y(t).slice()).insertAfter(e)}),this},q.insertBefore=function(e){var t=this;return Y(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n)})}),this},q.before=function(){var e=this;return J(arguments,function(t){Y(t).insertBefore(e)}),this},q.prepend=function(){var e=this;return J(arguments,function(t){ke(e,t,!0)}),this},q.prependTo=function(e){return ke(Y(e),j.apply(this.slice()),!0),this},q.remove=function(){return this.detach().off()},q.replaceWith=function(e){var t=this;return this.each(function(n,r){var o=r.parentNode;if(o){var i=n?Y(e).clone():Y(e);if(!i[0])return t.remove(),!1;o.replaceChild(i[0],r),Y(i[0]).after(i.slice(1))}})},q.replaceAll=function(e){return Y(e).replaceWith(this),this},q.text=function(e){return void 0===e?this[0]?this[0].textContent:"":this.each(function(t,n){n.textContent=e})};var We=P.documentElement;q.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+A.pageYOffset-We.clientTop,left:t.left+A.pageXOffset-We.clientLeft}}},q.offsetParent=function(){return Y(this[0]&&this[0].offsetParent)},q.position=function(){var e=this[0];if(e)return{left:e.offsetLeft,top:e.offsetTop}},q.children=function(e){var t=[];return this.each(function(e,n){$.apply(t,n.children)}),t=Y(ae(t)),e?t.filter(function(t,n){return Q(n,e)}):t},q.contents=function(){var e=[];return this.each(function(t,n){$.apply(e,"IFRAME"===n.tagName?[n.contentDocument]:n.childNodes)}),Y(e.length&&ae(e))},q.find=function(e){for(var t=[],n=0,r=this.length;n<r;n++){var o=V(e,this[n]);o.length&&$.apply(t,o)}return Y(t.length&&ae(t))},q.has=function(e){var t=te(e)?function(t,n){return!!V(e,n).length}:function(t,n){return n.contains(e)};return this.filter(t)},q.is=function(e){if(!e||!this[0])return!1;var t=oe(e),n=!1;return this.each(function(r,o){return!(n=t(r,o,e))}),n},q.next=function(){return Y(this[0]&&this[0].nextElementSibling)},q.not=function(e){if(!e||!this[0])return this;var t=oe(e);return this.filter(function(n,r){return!t(n,r,e)})},q.parent=function(){var e=[];return this.each(function(t,n){n&&n.parentNode&&e.push(n.parentNode)}),Y(ae(e))},q.index=function(e){var t=e?Y(e)[0]:this[0],n=e?this:Y(t).parent().children();return D.call(n,t)},q.closest=function(e){return e&&this[0]?this.is(e)?this.filter(e):this.parent().closest(e):Y()},q.parents=function(e){var t,n=[];return this.each(function(r,o){for(t=o;t&&t.parentNode&&t!==P.body.parentNode;)t=t.parentNode,(!e||e&&Q(t,e))&&n.push(t)}),Y(ae(n))},q.prev=function(){return Y(this[0]&&this[0].previousElementSibling)},q.siblings=function(){var e=this[0];return this.parent().children().filter(function(t,n){return n!==e})};const ze=Y,He=new class{getFiberNode(e){try{const t=Object.keys(e).find(e=>e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"));return t?e[t]:null}catch(e){return console.warn("[ReactFiberService] Error getting fiber node:",e),null}}getDebugOwner(e){const t=this.getFiberNode(e);return t?._debugOwner??null}getDebugSource(e){const t=this.getFiberNode(e);return t?._debugSource??null}getOwnerDebugSource(e){const t=this.getDebugOwner(e);return t?._debugSource??null}hasDirectSourceInfo(e){return!!e.getAttribute("data-nocode-id")||!!this.getDebugSource(e)}hasOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return!1;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n&&n.length>0}getOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return null;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n?n:null}isSelectableElement(e){if(this.hasDirectSourceInfo(e))return!0;const t=this.getFiberNode(e),n=this.getOwnerDebugSource(e);return!!(t?.return&&5!==t.return.tag&&this.hasOwnerNocodeId(e)&&n)}isComponent(e){if(!this.isSelectableElement(e))return!1;if(e.getAttribute("data-nocode-components-name"))return!0;if(this.getDebugSource(e))return!1;const t=this.getFiberNode(e);return!(!t?.return||5===t.return.tag)}getComponentName(e){const t=e.getAttribute("data-nocode-tag-name");if(t)return t;const n=this.getDebugOwner(e);if(n?.type){const e=n.type;if("function"==typeof e){const t=e.displayName||e.name||"Unknown";return this.normalizeComponentName(t)}if("string"==typeof e)return e}return e.tagName.toLowerCase()}normalizeComponentName(e){return e.replace(/\\d+$/,"")}getComponentProps(e){if(!this.isComponent(e))return;const t=this.getDebugOwner(e);return t?.memoizedProps?this.sanitizeProps(t.memoizedProps):void 0}sanitizeProps(e){const t={};for(const[n,r]of Object.entries(e)){if("children"===n||n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}sanitizeValue(e){if(null===e)return null;if(void 0===e)return;if("function"==typeof e)return;if("symbol"==typeof e)return;if("object"!=typeof e)return e;if("$$typeof"in e)return;if(e instanceof Node)return;if(Array.isArray(e)){const t=[];for(const n of e){const e=this.sanitizeValue(n);void 0!==e&&t.push(e)}return t}const t={};for(const[n,r]of Object.entries(e)){if(n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}buildComponentInfo(e){const t=this.isComponent(e),n={isComponent:t,componentType:t?"component":"host",name:t?this.getComponentName(e):e.tagName.toLowerCase()},r=e.getAttribute("data-nocode-components-name"),o=e.getAttribute("data-nocode-components-version");if(r&&(n.componentsName=r),o&&(n.componentsVersion=o),t){const t=this.getComponentProps(e)??{},r=this.removeSpecialProps(t);n.props=r}return n}removeSpecialProps(e){const t={};for(const[n,r]of Object.entries(e))"componentsName"!==n&&"componentsVersion"!==n&&(n.startsWith("data-nocode-")||(t[n]=r));return t}},Ue="data-dnd";function Ve(e){if(!e)return{};const t=e.split(":");if(t.length>=3){const n=t.pop(),r=t.pop(),o=t.join(":");return{id:e,filename:decodeURIComponent(o),component:r,codeId:n}}return 2===t.length?{id:e,component:t[0],codeId:t[1]}:{id:e}}const Be=`[${Ue}]`;function Ye(e,t){const n=t??0;return 0===n?document.querySelector(`[${Ue}="${e}"]`):document.querySelectorAll(`[${Ue}="${e}"]`)[n]??null}const qe=(e,t)=>{const n=e.getBoundingClientRect(),{x:r,y:o}=((e,t)=>{let n=e.x,r=e.y;if(t){const e=t.getBoundingClientRect();n-=e.left,r-=e.top}return{x:n,y:r}})({x:n.left,y:n.top},t);return{width:e.offsetWidth||Math.round(n.width),height:e.offsetHeight||Math.round(n.height),top:o,left:r}},Ke=(e,t)=>{const n=qe(e,t),r=function(e){return e.dataset}(e),o=Ge(e),i=Xe(e),s=(e=>{const t=window.getComputedStyle(e);return{display:t.display,flexDirection:t.flexDirection,flexWrap:t.flexWrap,position:t.position}})(e),a=r.dnd||"",c=Ve(a),u=function(e){return He.buildComponentInfo(e)}(e),l=function(e){return"true"===e.getAttribute("data-nocode-container-placeholder")}(e),d=(e=>{const t=e.querySelectorAll(`:scope > ${Be}`);if(!t.length)return[];const n=[];return t.forEach(e=>{const t=e;n.push(qe(t))}),n})(e);let f;if(a){const t=document.querySelectorAll(`[${Ue}="${a}"]`);if(t.length>1)for(let n=0;n<t.length;n++)if(t[n]===e){f=n;break}}return{id:a,codeId:c.codeId,name:c.component||e.tagName.toLowerCase(),filename:c.filename,bounding:n,display:o,computedStyle:s,text:i,containerPlaceholder:l||void 0,componentInfo:u,childrenBoundings:d.length>0?d:void 0,dndIndex:f}},Ge=e=>ze(e).css("display"),Xe=e=>{const t=[];return e.childNodes.forEach(e=>{if(e.nodeType===Node.TEXT_NODE){const n=e.textContent?.trim()||"";n&&t.push(n)}}),t.join(" ")};function Je(e){const t=["div","p","section","article","main","header","footer","nav","h1","h2","h3","h4","h5","h6","span","a","button","i","input","textarea","select","label","form","ul","ol","li","table","thead","tbody","tr","td","th","img","video","audio","canvas","svg"];try{const n=e.tagName.toLowerCase();if(!t.includes(n))return!1;const r=window.getComputedStyle(e);if("none"===r.display||"hidden"===r.visibility||"0"===r.opacity)return!1;const o=e.getBoundingClientRect();return!("inline"!==r.display&&"inline-block"!==r.display&&(0===o.width||0===o.height))}catch(e){return console.warn("Element validation failed:",e),!1}}function Ze(e,t=20){let n=e,r=0;for(;n&&r<t;){if(n.getAttribute(Ue))return n;n=n.parentElement,r++}return null}function Qe(e){const t=window.getComputedStyle(e),n={};for(let e=0;e<t.length;e++){const r=t[e];n[r]=t.getPropertyValue(r)}return n}let et=null;function tt(e){return(...t)=>{try{const n=e(...t);return n&&"function"==typeof n.then?n.catch(n=>(console.error(`Async error in ${e.name}:`,n),console.error("Error stack:",n.stack),console.error("Function arguments:",t),null)):n}catch(n){return console.error(`Sync error in ${e.name}:`,n),n instanceof Error&&console.error("Error stack:",n.stack),console.error("Function arguments:",t),null}}}const nt={getDraggableParentsData:(e,t)=>{const n=function(e,t){const n=((e,t)=>{const n=document.elementFromPoint(e,t);if(!n)return null;const r=n=>{if(n?.shadowRoot){const o=n.shadowRoot.elementFromPoint(e,t);return o===n?n:o?.shadowRoot?r(o):o||n}return n};return r(n)})(e,t);if(!n)return null;let r=n;if(!Je(r)){let e=r.parentElement,t=0;const n=20;for(;e&&t<n;){if(Je(e)){r=e;break}e=e.parentElement,t++}if(!Je(r))return null}const o=Ze(r);return o&&Je(o)?o:null}(e.x,e.y);if(!n)return;const r=(e=>{const t=ze(e).closest(Be).get(0),n=ze(e).parents(Be).get();return n[0]!==t&&n.unshift(t),n})(n);if(r.length){if(t){const e=r.map(e=>Ke(e));return{...e[0],computedStyle:Qe(n),parents:e.slice(1)}}return{...Ke(r[0]),computedStyle:Qe(r[0])}}},getElementDataById:(e,t)=>{const n=Ye(e,t);if(n)return{...Ke(n),computedStyle:Qe(n)};console.warn("[getElementDataById] Element not found for domId:",e,"dndIndex:",t)},getEditableTextElementAtPosition:e=>{const t=function(e,t){if(document.caretPositionFromPoint){const n=document.caretPositionFromPoint(e,t);return n?.offsetNode??null}if(document.caretRangeFromPoint){const n=document.caretRangeFromPoint(e,t);return n?.startContainer??null}return document.elementFromPoint(e,t)}(e.x,e.y);if(!t)return void console.log("[getEditableTextElementAtPosition] No node at point:",e);if(t.nodeType!==Node.TEXT_NODE)return void console.log("[getEditableTextElementAtPosition] Not a text node:",t.nodeType);const n=t.textContent?.trim();if(!n)return void console.log("[getEditableTextElementAtPosition] Empty text node");const r=t.parentElement;if(!r)return void console.log("[getEditableTextElementAtPosition] No parent element");const o=Ze(r);if(o){if(function(e){const t=e.childNodes;let n=!1;for(let e=0;e<t.length;e++){const r=t[e];if(r.nodeType===Node.ELEMENT_NODE)return!1;if(r.nodeType===Node.TEXT_NODE){const e=r.textContent?.trim();e&&(n=!0)}}return n}(o))return console.log("[getEditableTextElementAtPosition] Found editable text element:",o.tagName,o.textContent),{...Ke(o),computedStyle:Qe(o)};console.log("[getEditableTextElementAtPosition] Element has child elements, cannot edit directly:",o.tagName)}else console.log("[getEditableTextElementAtPosition] No marked element found")},updateElementTextContent:(e,t)=>{const n=Ye(e);return n?(n.textContent=t,!0):(console.warn("[updateElementTextContent] Element not found:",e),!1)},scrollToElement:(e,t)=>{const n=Ye(e,t);return n?(n.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),!0):(console.warn("[scrollToElement] Element not found for domId:",e,"dndIndex:",t),!1)},scrollPageBy:(e,t)=>(window.scrollBy(e,t),!0),highlightElement:(e,t)=>{if(et&&(et.style.outline="",et.style.outlineOffset="",et=null),!e)return!0;const n=Ye(e,t);return n?(n.style.outline="2px solid rgba(54, 210, 190, 0.8)",n.style.outlineOffset="-1px",et=n,!0):(console.warn("[highlightElement] Element not found:",e,"dndIndex:",t),!1)},getProjectLibVersions:function(){try{const e=document.body;if(!e)return console.warn("[sandbox] document.body is not available"),null;const t=e.getAttribute("data-nocode-lib-versions");if(!t)return console.warn("[sandbox] data-nocode-lib-versions attribute not found on body"),null;const n=JSON.parse(t);return"object"!=typeof n||null===n?(console.warn("[sandbox] data-nocode-lib-versions is not a valid object"),null):n}catch(e){return console.error("[sandbox] Failed to parse data-nocode-lib-versions:",e),null}},getCompilerVersion:function(){try{const e=document.body;return e?e.getAttribute("data-nocode-compiler-version"):null}catch(e){return console.error("[sandbox] Failed to get compiler version:",e),null}},getRuntimeNodeTree:()=>{try{const e=document.querySelectorAll(Be);if(!e.length)return[];const t=new Map;e.forEach(e=>{const n=e.getAttribute(Ue)||"";if(!n)return;const r=Ve(n);t.set(e,{id:n,component:r.component||e.tagName.toLowerCase(),children:[]})});const n=[];e.forEach(e=>{const r=t.get(e);if(!r)return;let o,i=e.parentElement;for(;i;){if(t.has(i)){o=t.get(i);break}i=i.parentElement}o?o.children.push(r):n.push(r)});const r=e=>{e.children&&0===e.children.length?delete e.children:e.children&&e.children.forEach(r)};return n.forEach(r),n}catch(e){return console.error("[sandbox] Failed to build runtime node tree:",e),[]}},setElementStyle:function(e,t){const n=function(e){return document.querySelector(`[${Ue}="${e}"]`)}(e);return n?(Object.entries(t).forEach(([e,t])=>{n.style[e]=t}),!0):(console.warn("[setElementStyle] Element not found for domId:",e),!1)}},rt=Object.fromEntries(Object.entries(nt).map(([e,t])=>[e,tt(t)])),ot="nocode-design-mode";let it=null,st=!1,at=null;const ct=t()(()=>{it?.onWindowMutated&&(console.log(`${ot} - Notifying parent of DOM mutation`),it.onWindowMutated({added:{},removed:{}}))},100),ut=async()=>{if(st||it)return it;st=!0,console.log(`${ot} - Creating penpal connection`);const e=(({messenger:e,methods:t={},timeout:n,channel:o,log:i})=>{if(!e)throw new r("INVALID_ARGUMENT","messenger must be defined");if(M.has(e))throw new r("INVALID_ARGUMENT","A messenger can only be used for a single connection");M.add(e);const s=[e.destroy],u=(e=>{let t,n=!1;return(...r)=>(n||(n=!0,t=e(...r)),t)})(t=>{if(t){const t={namespace:a,channel:o,type:"DESTROY"};try{e.sendMessage(t)}catch(e){}}for(const e of s)e();i?.("Connection destroyed")}),l=e=>(e=>c(e)&&e.namespace===a)(e)&&e.channel===o;return{promise:(async()=>{try{e.initialize({log:i,validateReceivedMessage:l}),e.addMessageHandler(e=>{(e=>"DESTROY"===e.type)(e)&&u(!1)});const{remoteProxy:r,destroy:a}=await I({messenger:e,methods:t,timeout:n,channel:o,log:i});return s.push(a),r}catch(e){throw u(!0),e}})(),destroy:()=>{u(!0)}}})({messenger:new T({remoteWindow:window===window.top?(console.warn(`${ot} - Not in an iframe, using window.parent as fallback`),window.parent):window.parent===window.top?window.parent:window.top?(console.log(`${ot} - Using window.top for nested iframe scenario`),window.top):window.parent,allowedOrigins:["*"]}),methods:rt});return e.promise.then(e=>{if(!e)return console.error(`${ot} - Failed to setup penpal connection: child is null`),void lt();it=e,console.log(`${ot} - Penpal connection set`),(()=>{if(at)return;at=new MutationObserver(e=>{e.some(e=>{const t=e.target;return"SCRIPT"!==t.tagName&&"STYLE"!==t.tagName&&("attributes"!==e.type||"style"===e.attributeName||"class"===e.attributeName)})&&ct()});const e=()=>{document.body&&at&&(at.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"],characterData:!0}),console.log(`${ot} - MutationObserver started`))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()})()}).finally(()=>{st=!1}),e.promise.catch(e=>{console.error(`${ot} - Failed to setup penpal connection:`,e),lt()}),it},lt=t()(()=>{st||(console.log(`${ot} - Reconnecting to penpal parent`),it=null,ut())},1e3);ut()})()})();';
267
345
  }
268
346
  function createSandboxScriptMiddleware(options) {
269
347
  var _a;
@@ -404,13 +482,35 @@ function componentCompiler(options = {}) {
404
482
  monitorService.reportMetrics(MetricType.PLUGIN_USE, 1);
405
483
  const vueCompiler = new VueCompiler(options);
406
484
  const jsxCompiler = new JSXCompiler(options);
407
- const designModeCompiler = new DesignModeCompiler(options);
485
+ const designModeCompiler = new DesignModeCompiler2(options);
408
486
  let server;
409
487
  let pkgRegistry;
410
488
  let projectRoot = "";
411
489
  return {
412
490
  name: PLUGIN_NAME,
413
491
  enforce: "pre",
492
+ /**
493
+ * 修改 Vite 配置:
494
+ * 在开发环境下,如果检测到项目使用了 shadcn 组件库,
495
+ * 将 shadcn 组件依赖的 npm 包加入 optimizeDeps.include,
496
+ * 确保 Vite 在启动时预构建这些包及其深层子依赖,
497
+ * 避免运行时首次拖拽组件时触发 optimizeDeps 重新预构建导致 full-reload。
498
+ */
499
+ config(userConfig, { command }) {
500
+ var _a;
501
+ if (command === "serve" && designModeOptions.enableVirtualCode) {
502
+ const root = userConfig.root || process.cwd();
503
+ if (!detectShadcnProject(root)) {
504
+ return;
505
+ }
506
+ console.log(`[DesignMode] Shadcn project detected, adding ${SHADCN_NPM_DEPS.length} deps to optimizeDeps.include`);
507
+ return {
508
+ optimizeDeps: {
509
+ include: [...Array.isArray((_a = userConfig.optimizeDeps) == null ? void 0 : _a.include) ? userConfig.optimizeDeps.include : [], ...SHADCN_NPM_DEPS]
510
+ }
511
+ };
512
+ }
513
+ },
414
514
  /**
415
515
  * 配置解析完成后:
416
516
  * 1. 将本插件移到插件列表最前面,确保在所有 enforce: 'pre' 插件中第一个执行
@@ -441,6 +541,7 @@ function componentCompiler(options = {}) {
441
541
  server.middlewares.use(createOverrideMiddleware(server));
442
542
  server.middlewares.use(createSandboxScriptMiddleware(designModeOptions));
443
543
  if (designModeOptions.enableVirtualCode) {
544
+ server.middlewares.use(createSwapNodeMiddleware(server, designModeOptions, projectRoot));
444
545
  server.middlewares.use(createVirtualCodeMiddleware(server, designModeOptions, projectRoot));
445
546
  console.log(`[DesignMode] Virtual code API enabled at ${designModeOptions.virtualCodeApiPath}`);
446
547
  }
@@ -487,7 +588,14 @@ function componentCompiler(options = {}) {
487
588
  query
488
589
  });
489
590
  if (useJSXCompiler) {
490
- return jsxCompiler.compile(code, filePath, pkgRegistry) || code;
591
+ let diskCode;
592
+ if (hasVirtualCode(id)) {
593
+ try {
594
+ diskCode = fs2.readFileSync(filePath, "utf-8");
595
+ } catch {
596
+ }
597
+ }
598
+ return jsxCompiler.compile(code, filePath, pkgRegistry, diskCode) || code;
491
599
  }
492
600
  if (useVueCompiler) {
493
601
  return vueCompiler.compile(code, filePath, pkgRegistry) || code;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meituan-nocode/vite-plugin-nocode-compiler",
3
- "version": "0.3.1-beta.9",
3
+ "version": "0.4.1-beta.2",
4
4
  "description": "Vite plugin for nocode compiler",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,8 +17,8 @@
17
17
  "dist"
18
18
  ],
19
19
  "dependencies": {
20
- "@meituan-nocode/nocode-compiler-core": "0.2.9-beta.6",
21
- "@meituan-nocode/nocode-design-mode-sandbox-script": "0.1.0-beta.2"
20
+ "@meituan-nocode/nocode-compiler-core": "0.2.9-beta.9",
21
+ "@meituan-nocode/nocode-design-mode-sandbox-script": "0.1.0-beta.4"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/node": "^20.19.31",