@xiaobuyu/nodesign 0.0.2 → 0.0.4

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 (111) hide show
  1. package/README.en.md +184 -0
  2. package/README.md +19 -25
  3. package/package.json +2 -1
  4. package/server/api/assets/helpers.js +20 -0
  5. package/server/api/assets/notes.js +50 -0
  6. package/server/api/assets.js +6 -11
  7. package/server/api/board.js +78 -1
  8. package/server/engine/agent/events.js +1 -0
  9. package/server/engine/agent/hooks/user-prompt-submit.js +43 -0
  10. package/server/engine/agent/prompts/nodesign-prelude.md +53 -1
  11. package/server/engine/agent/session-loop.js +11 -0
  12. package/server/engine/mcp/index.js +12 -0
  13. package/server/engine/mcp/tools/arrange-on-board.js +4 -4
  14. package/server/engine/mcp/tools/create-on-board.js +9 -12
  15. package/server/engine/mcp/tools/edit-sketch.js +167 -0
  16. package/server/engine/mcp/tools/look-at-board.js +124 -0
  17. package/server/engine/mcp/tools/read-board.js +121 -34
  18. package/server/engine/mcp/tools/read-user-view.js +59 -0
  19. package/server/engine/mcp/tools/relate-on-board.js +5 -3
  20. package/server/engine/mcp/tools/sketch-on-board.js +337 -0
  21. package/server/engine/mcp/tools/write-on-board.js +130 -0
  22. package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/SKILL.md +7 -0
  23. package/server/engine/plugins/nodesign/skills/docx-craft/SKILL.md +7 -0
  24. package/server/engine/plugins/nodesign/skills/rp-craft/SKILL.md +7 -0
  25. package/server/engine/plugins/nodesign/skills/site-craft/SKILL.md +7 -0
  26. package/server/engine/runs/board-tasklist.js +130 -0
  27. package/server/index.js +3 -0
  28. package/server/lib/binding-types.js +12 -0
  29. package/server/lib/board-graph-export.js +191 -0
  30. package/server/lib/board-groups.js +167 -0
  31. package/server/lib/board-hero.js +76 -0
  32. package/server/lib/board-kind-sizes.js +23 -0
  33. package/server/lib/board-relations.js +1 -1
  34. package/server/lib/chalk.js +121 -0
  35. package/server/lib/sketch-layout.js +277 -0
  36. package/server/projects/board-limits.js +12 -0
  37. package/server/projects/board-sanitize.js +252 -0
  38. package/server/projects/board-store.js +72 -205
  39. package/server/projects/ui-config.js +6 -0
  40. package/server/projects/viewpoint-store.js +78 -0
  41. package/server/ws/broker.js +3 -0
  42. package/web/dist/assets/{BrowserWindow-BYCgizHw.js → BrowserWindow-P_vIdh-G.js} +2 -2
  43. package/web/dist/assets/{DeckWindow-pNydEM4L.js → DeckWindow-BpLv5082.js} +3 -3
  44. package/web/dist/assets/{DocxWindow-PPgzh3Gq.js → DocxWindow-DSAU1-tD.js} +4 -4
  45. package/web/dist/assets/MermaidBlock-DR1GikCv.js +313 -0
  46. package/web/dist/assets/SiteWindow-92uBuRRR.js +18 -0
  47. package/web/dist/assets/abnfDiagram-VCTEODGH-uA8Esix4.js +1 -0
  48. package/web/dist/assets/arc-D_khH_xN.js +1 -0
  49. package/web/dist/assets/architectureDiagram-5GKGNRK7-DydJHqOt.js +36 -0
  50. package/web/dist/assets/blockDiagram-NRAW4CY4-B7wBbKiW.js +129 -0
  51. package/web/dist/assets/c4Diagram-UCG6FXSJ-6mrH0x7Y.js +38 -0
  52. package/web/dist/assets/channel-DGkccMO1.js +1 -0
  53. package/web/dist/assets/chunk-2Q5K7J3B-Cuikho5Q.js +1 -0
  54. package/web/dist/assets/chunk-5VM5RSS4-3-KZ5AUz.js +15 -0
  55. package/web/dist/assets/chunk-F27PBJKO-Bkwq2gGU.js +1 -0
  56. package/web/dist/assets/chunk-G27WJ6UU-BLyQzdGE.js +231 -0
  57. package/web/dist/assets/chunk-JWPE2WC7-B7HxxQds.js +1 -0
  58. package/web/dist/assets/chunk-LCL6LL3I-CtXrnUwF.js +206 -0
  59. package/web/dist/assets/chunk-POPQ4Y6H-dxddZlXt.js +1 -0
  60. package/web/dist/assets/chunk-SVP7TREG-DpkmrgHn.js +88 -0
  61. package/web/dist/assets/chunk-XXDRQBXY-BwZ7RbpQ.js +1 -0
  62. package/web/dist/assets/classDiagram-DTDB5LWJ-BGscw3OD.js +1 -0
  63. package/web/dist/assets/classDiagram-v2-JRS7N3AN-BGscw3OD.js +1 -0
  64. package/web/dist/assets/cose-bilkent-JH36ORCC-DGFOsMUt.js +1 -0
  65. package/web/dist/assets/cynefin-OW5HDTMX-DUwn3ehS.js +178 -0
  66. package/web/dist/assets/cynefinDiagram-5FMLGOSQ-DlLAOZ9x.js +62 -0
  67. package/web/dist/assets/cytoscape.esm-BjAbmLdb.js +331 -0
  68. package/web/dist/assets/dagre-3AP2YEHR-CyourLfz.js +4 -0
  69. package/web/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  70. package/web/dist/assets/diagram-S7CK7UJ4-BTMbx2np.js +30 -0
  71. package/web/dist/assets/diagram-UQ7AKVKN-UK94_1-P.js +41 -0
  72. package/web/dist/assets/diagram-VSXAHHWV-C7zS-v9v.js +3 -0
  73. package/web/dist/assets/diagram-VX7I27RA-DKJRa6CK.js +24 -0
  74. package/web/dist/assets/diagram-Z3DM3KII-kUbAfGAp.js +24 -0
  75. package/web/dist/assets/ebnfDiagram-PWID7BFC-CVW16_vb.js +1 -0
  76. package/web/dist/assets/erDiagram-SSCWMZ5O-BRQMFQ5y.js +99 -0
  77. package/web/dist/assets/flowDiagram-A5DVABFB-S34LpLtK.js +168 -0
  78. package/web/dist/assets/ganttDiagram-EL5Y4UJY-BFiqk1-G.js +292 -0
  79. package/web/dist/assets/gitGraphDiagram-WWUBYQGX-LZsrdyyv.js +106 -0
  80. package/web/dist/assets/index-GAamh1p4.js +2152 -0
  81. package/web/dist/assets/infoDiagram-RXCK75RN-0DvN6KIp.js +2 -0
  82. package/web/dist/assets/init-Gi6I4Gst.js +1 -0
  83. package/web/dist/assets/ishikawaDiagram-5VMMS53U-CaY3A-Bx.js +70 -0
  84. package/web/dist/assets/journeyDiagram-EYS64GPL-BBeiaCrj.js +139 -0
  85. package/web/dist/assets/kanban-definition-3QL26DDD-ux42DRXQ.js +89 -0
  86. package/web/dist/assets/layout-CnXiF_NB.js +1 -0
  87. package/web/dist/assets/linear-BMW0u6G6.js +1 -0
  88. package/web/dist/assets/mindmap-definition-FBJOCRG2-hUxSpdKn.js +96 -0
  89. package/web/dist/assets/ordinal-Cboi1Yqb.js +1 -0
  90. package/web/dist/assets/pegDiagram-XKGWAZYB-aCaQPH0w.js +1 -0
  91. package/web/dist/assets/{pending-edit-apply-C0I13CbD.js → pending-edit-apply-AcdOQ9Ij.js} +6 -6
  92. package/web/dist/assets/pieDiagram-E7YTZNPT-CmOEZ8zg.js +39 -0
  93. package/web/dist/assets/quadrantDiagram-AXDQQJYC-VW6fAhsV.js +7 -0
  94. package/web/dist/assets/railroadDiagram-O6MQD6OU-CKJ7Ba5K.js +1 -0
  95. package/web/dist/assets/requirementDiagram-EFPCY7ZU-pNGkq9Vw.js +84 -0
  96. package/web/dist/assets/{rotate-cw-B1UQ8Hld.js → rotate-cw-KAfChbGV.js} +1 -1
  97. package/web/dist/assets/sankeyDiagram-P5KCCOFB-BIMmDTfZ.js +40 -0
  98. package/web/dist/assets/sequenceDiagram-WJ2MYXX4-BBW7wzKY.js +162 -0
  99. package/web/dist/assets/sizeCapture-X5ZJPWSS-DdkXmLYR.js +1 -0
  100. package/web/dist/assets/{square-dashed-mouse-pointer-8lrgqmfv.js → square-dashed-mouse-pointer-CDUlhUP7.js} +1 -1
  101. package/web/dist/assets/stateDiagram-HBIQ2CUA-W313Uz16.js +1 -0
  102. package/web/dist/assets/stateDiagram-v2-4QOOHH4V-DDhJBZzf.js +1 -0
  103. package/web/dist/assets/swimlanes-XN3QIQJK-C29TL26K.js +1 -0
  104. package/web/dist/assets/swimlanesDiagram-VK2B7HYN-BfN-Xdmu.js +8 -0
  105. package/web/dist/assets/timeline-definition-24CTP7MA-CF0JMObX.js +120 -0
  106. package/web/dist/assets/vennDiagram-4TSXK5OY-DrDFsaH3.js +34 -0
  107. package/web/dist/assets/wardleyDiagram-VM6X3IG4-CVrnRIS_.js +78 -0
  108. package/web/dist/assets/xychartDiagram-S5SC5T6Z-BvkN1zsT.js +7 -0
  109. package/web/dist/index.html +1 -1
  110. package/web/dist/assets/SiteWindow-DM0LQPCO.js +0 -18
  111. package/web/dist/assets/index-BHTBJlpY.js +0 -2125
@@ -0,0 +1,96 @@
1
+ import{g as oe}from"./chunk-XXDRQBXY-BwZ7RbpQ.js";import{s as ce}from"./chunk-POPQ4Y6H-dxddZlXt.js";import{_ as h,l as R,u as le,v as he,y as de,B as W,c as U,i as H,b4 as ge,V as ue,W as pe,X as fe}from"./MermaidBlock-DR1GikCv.js";import"./index-GAamh1p4.js";const _=[];for(let t=0;t<256;++t)_.push((t+256).toString(16).slice(1));function me(t,e=0){return(_[t[e+0]]+_[t[e+1]]+_[t[e+2]]+_[t[e+3]]+"-"+_[t[e+4]]+_[t[e+5]]+"-"+_[t[e+6]]+_[t[e+7]]+"-"+_[t[e+8]]+_[t[e+9]]+"-"+_[t[e+10]]+_[t[e+11]]+_[t[e+12]]+_[t[e+13]]+_[t[e+14]]+_[t[e+15]]).toLowerCase()}const ye=new Uint8Array(16);function Ee(){return crypto.getRandomValues(ye)}function _e(t,e,o){return crypto.randomUUID?crypto.randomUUID():be(t)}function be(t,e,o){var n;t=t||{};const l=t.random??((n=t.rng)==null?void 0:n.call(t))??Ee();if(l.length<16)throw new Error("Random bytes length must be >= 16");return l[6]=l[6]&15|64,l[8]=l[8]&63|128,me(l)}var K=(function(){var t=h(function(O,s,i,a){for(i=i||{},a=O.length;a--;i[O[a]]=s);return i},"o"),e=[1,4],o=[1,13],l=[1,12],n=[1,15],d=[1,16],p=[1,20],y=[1,19],E=[6,7,8],k=[1,26],L=[1,24],D=[1,25],b=[6,7,11],$=[1,6,13,15,16,19,22],f=[1,33],B=[1,34],P=[1,6,7,11,13,15,16,19,22],X={trace:h(function(){},"trace"),yy:{},symbols_:{error:2,start:3,mindMap:4,spaceLines:5,SPACELINE:6,NL:7,MINDMAP:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,node:14,ICON:15,CLASS:16,nodeWithId:17,nodeWithoutId:18,NODE_DSTART:19,NODE_DESCR:20,NODE_DEND:21,NODE_ID:22,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"MINDMAP",11:"EOF",13:"SPACELIST",15:"ICON",16:"CLASS",19:"NODE_DSTART",20:"NODE_DESCR",21:"NODE_DEND",22:"NODE_ID"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,2],[12,2],[12,1],[12,1],[12,1],[12,1],[12,1],[14,1],[14,1],[18,3],[17,1],[17,4]],performAction:h(function(s,i,a,c,u,r,M){var g=r.length-1;switch(u){case 6:case 7:return c;case 8:c.getLogger().trace("Stop NL ");break;case 9:c.getLogger().trace("Stop EOF ");break;case 11:c.getLogger().trace("Stop NL2 ");break;case 12:c.getLogger().trace("Stop EOF2 ");break;case 15:c.getLogger().info("Node: ",r[g].id),c.addNode(r[g-1].length,r[g].id,r[g].descr,r[g].type);break;case 16:c.getLogger().trace("Icon: ",r[g]),c.decorateNode({icon:r[g]});break;case 17:case 21:c.decorateNode({class:r[g]});break;case 18:c.getLogger().trace("SPACELIST");break;case 19:c.getLogger().trace("Node: ",r[g].id),c.addNode(0,r[g].id,r[g].descr,r[g].type);break;case 20:c.decorateNode({icon:r[g]});break;case 25:c.getLogger().trace("node found ..",r[g-2]),this.$={id:r[g-1],descr:r[g-1],type:c.getType(r[g-2],r[g])};break;case 26:this.$={id:r[g],descr:r[g],type:c.nodeType.DEFAULT};break;case 27:c.getLogger().trace("node found ..",r[g-3]),this.$={id:r[g-3],descr:r[g-1],type:c.getType(r[g-2],r[g])};break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:e},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:e},{6:o,7:[1,10],9:9,12:11,13:l,14:14,15:n,16:d,17:17,18:18,19:p,22:y},t(E,[2,3]),{1:[2,2]},t(E,[2,4]),t(E,[2,5]),{1:[2,6],6:o,12:21,13:l,14:14,15:n,16:d,17:17,18:18,19:p,22:y},{6:o,9:22,12:11,13:l,14:14,15:n,16:d,17:17,18:18,19:p,22:y},{6:k,7:L,10:23,11:D},t(b,[2,22],{17:17,18:18,14:27,15:[1,28],16:[1,29],19:p,22:y}),t(b,[2,18]),t(b,[2,19]),t(b,[2,20]),t(b,[2,21]),t(b,[2,23]),t(b,[2,24]),t(b,[2,26],{19:[1,30]}),{20:[1,31]},{6:k,7:L,10:32,11:D},{1:[2,7],6:o,12:21,13:l,14:14,15:n,16:d,17:17,18:18,19:p,22:y},t($,[2,14],{7:f,11:B}),t(P,[2,8]),t(P,[2,9]),t(P,[2,10]),t(b,[2,15]),t(b,[2,16]),t(b,[2,17]),{20:[1,35]},{21:[1,36]},t($,[2,13],{7:f,11:B}),t(P,[2,11]),t(P,[2,12]),{21:[1,37]},t(b,[2,25]),t(b,[2,27])],defaultActions:{2:[2,1],6:[2,2]},parseError:h(function(s,i){if(i.recoverable)this.trace(s);else{var a=new Error(s);throw a.hash=i,a}},"parseError"),parse:h(function(s){var i=this,a=[0],c=[],u=[null],r=[],M=this.table,g="",F=0,Q=0,ie=2,Z=1,se=r.slice.call(arguments,1),m=Object.create(this.lexer),C={yy:{}};for(var z in this.yy)Object.prototype.hasOwnProperty.call(this.yy,z)&&(C.yy[z]=this.yy[z]);m.setInput(s,C.yy),C.yy.lexer=m,C.yy.parser=this,typeof m.yylloc>"u"&&(m.yylloc={});var Y=m.yylloc;r.push(Y);var re=m.options&&m.options.ranges;typeof C.yy.parseError=="function"?this.parseError=C.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ae(x){a.length=a.length-2*x,u.length=u.length-x,r.length=r.length-x}h(ae,"popStack");function ee(){var x;return x=c.pop()||m.lex()||Z,typeof x!="number"&&(x instanceof Array&&(c=x,x=c.pop()),x=i.symbols_[x]||x),x}h(ee,"lex");for(var S,I,N,q,w={},G,v,te,j;;){if(I=a[a.length-1],this.defaultActions[I]?N=this.defaultActions[I]:((S===null||typeof S>"u")&&(S=ee()),N=M[I]&&M[I][S]),typeof N>"u"||!N.length||!N[0]){var J="";j=[];for(G in M[I])this.terminals_[G]&&G>ie&&j.push("'"+this.terminals_[G]+"'");m.showPosition?J="Parse error on line "+(F+1)+`:
2
+ `+m.showPosition()+`
3
+ Expecting `+j.join(", ")+", got '"+(this.terminals_[S]||S)+"'":J="Parse error on line "+(F+1)+": Unexpected "+(S==Z?"end of input":"'"+(this.terminals_[S]||S)+"'"),this.parseError(J,{text:m.match,token:this.terminals_[S]||S,line:m.yylineno,loc:Y,expected:j})}if(N[0]instanceof Array&&N.length>1)throw new Error("Parse Error: multiple actions possible at state: "+I+", token: "+S);switch(N[0]){case 1:a.push(S),u.push(m.yytext),r.push(m.yylloc),a.push(N[1]),S=null,Q=m.yyleng,g=m.yytext,F=m.yylineno,Y=m.yylloc;break;case 2:if(v=this.productions_[N[1]][1],w.$=u[u.length-v],w._$={first_line:r[r.length-(v||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(v||1)].first_column,last_column:r[r.length-1].last_column},re&&(w._$.range=[r[r.length-(v||1)].range[0],r[r.length-1].range[1]]),q=this.performAction.apply(w,[g,Q,F,C.yy,N[1],u,r].concat(se)),typeof q<"u")return q;v&&(a=a.slice(0,-1*v*2),u=u.slice(0,-1*v),r=r.slice(0,-1*v)),a.push(this.productions_[N[1]][0]),u.push(w.$),r.push(w._$),te=M[a[a.length-2]][a[a.length-1]],a.push(te);break;case 3:return!0}}return!0},"parse")},ne=(function(){var O={EOF:1,parseError:h(function(i,a){if(this.yy.parser)this.yy.parser.parseError(i,a);else throw new Error(i)},"parseError"),setInput:h(function(s,i){return this.yy=i||this.yy||{},this._input=s,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:h(function(){var s=this._input[0];this.yytext+=s,this.yyleng++,this.offset++,this.match+=s,this.matched+=s;var i=s.match(/(?:\r\n?|\n).*/g);return i?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),s},"input"),unput:h(function(s){var i=s.length,a=s.split(/(?:\r\n?|\n)/g);this._input=s+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-i),this.offset-=i;var c=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),a.length-1&&(this.yylineno-=a.length-1);var u=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:a?(a.length===c.length?this.yylloc.first_column:0)+c[c.length-a.length].length-a[0].length:this.yylloc.first_column-i},this.options.ranges&&(this.yylloc.range=[u[0],u[0]+this.yyleng-i]),this.yyleng=this.yytext.length,this},"unput"),more:h(function(){return this._more=!0,this},"more"),reject:h(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
+ `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:h(function(s){this.unput(this.match.slice(s))},"less"),pastInput:h(function(){var s=this.matched.substr(0,this.matched.length-this.match.length);return(s.length>20?"...":"")+s.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:h(function(){var s=this.match;return s.length<20&&(s+=this._input.substr(0,20-s.length)),(s.substr(0,20)+(s.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:h(function(){var s=this.pastInput(),i=new Array(s.length+1).join("-");return s+this.upcomingInput()+`
5
+ `+i+"^"},"showPosition"),test_match:h(function(s,i){var a,c,u;if(this.options.backtrack_lexer&&(u={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(u.yylloc.range=this.yylloc.range.slice(0))),c=s[0].match(/(?:\r\n?|\n).*/g),c&&(this.yylineno+=c.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:c?c[c.length-1].length-c[c.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+s[0].length},this.yytext+=s[0],this.match+=s[0],this.matches=s,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(s[0].length),this.matched+=s[0],a=this.performAction.call(this,this.yy,this,i,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),a)return a;if(this._backtrack){for(var r in u)this[r]=u[r];return!1}return!1},"test_match"),next:h(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var s,i,a,c;this._more||(this.yytext="",this.match="");for(var u=this._currentRules(),r=0;r<u.length;r++)if(a=this._input.match(this.rules[u[r]]),a&&(!i||a[0].length>i[0].length)){if(i=a,c=r,this.options.backtrack_lexer){if(s=this.test_match(a,u[r]),s!==!1)return s;if(this._backtrack){i=!1;continue}else return!1}else if(!this.options.flex)break}return i?(s=this.test_match(i,u[c]),s!==!1?s:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
6
+ `+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:h(function(){var i=this.next();return i||this.lex()},"lex"),begin:h(function(i){this.conditionStack.push(i)},"begin"),popState:h(function(){var i=this.conditionStack.length-1;return i>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:h(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:h(function(i){return i=this.conditionStack.length-1-Math.abs(i||0),i>=0?this.conditionStack[i]:"INITIAL"},"topState"),pushState:h(function(i){this.begin(i)},"pushState"),stateStackSize:h(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:h(function(i,a,c,u){switch(c){case 0:return i.getLogger().trace("Found comment",a.yytext),6;case 1:return 8;case 2:this.begin("CLASS");break;case 3:return this.popState(),16;case 4:this.popState();break;case 5:i.getLogger().trace("Begin icon"),this.begin("ICON");break;case 6:return i.getLogger().trace("SPACELINE"),6;case 7:return 7;case 8:return 15;case 9:i.getLogger().trace("end icon"),this.popState();break;case 10:return i.getLogger().trace("Exploding node"),this.begin("NODE"),19;case 11:return i.getLogger().trace("Cloud"),this.begin("NODE"),19;case 12:return i.getLogger().trace("Explosion Bang"),this.begin("NODE"),19;case 13:return i.getLogger().trace("Cloud Bang"),this.begin("NODE"),19;case 14:return this.begin("NODE"),19;case 15:return this.begin("NODE"),19;case 16:return this.begin("NODE"),19;case 17:return this.begin("NODE"),19;case 18:return 13;case 19:return 22;case 20:return 11;case 21:this.begin("NSTR2");break;case 22:return"NODE_DESCR";case 23:this.popState();break;case 24:i.getLogger().trace("Starting NSTR"),this.begin("NSTR");break;case 25:return i.getLogger().trace("description:",a.yytext),"NODE_DESCR";case 26:this.popState();break;case 27:return this.popState(),i.getLogger().trace("node end ))"),"NODE_DEND";case 28:return this.popState(),i.getLogger().trace("node end )"),"NODE_DEND";case 29:return this.popState(),i.getLogger().trace("node end ...",a.yytext),"NODE_DEND";case 30:return this.popState(),i.getLogger().trace("node end (("),"NODE_DEND";case 31:return this.popState(),i.getLogger().trace("node end (-"),"NODE_DEND";case 32:return this.popState(),i.getLogger().trace("node end (-"),"NODE_DEND";case 33:return this.popState(),i.getLogger().trace("node end (("),"NODE_DEND";case 34:return this.popState(),i.getLogger().trace("node end (("),"NODE_DEND";case 35:return i.getLogger().trace("Long description:",a.yytext),20;case 36:return i.getLogger().trace("Long description:",a.yytext),20}},"anonymous"),rules:[/^(?:\s*%%.*)/i,/^(?:mindmap\b)/i,/^(?::::)/i,/^(?:.+)/i,/^(?:\n)/i,/^(?:::icon\()/i,/^(?:[\s]+[\n])/i,/^(?:[\n]+)/i,/^(?:[^\)]+)/i,/^(?:\))/i,/^(?:-\))/i,/^(?:\(-)/i,/^(?:\)\))/i,/^(?:\))/i,/^(?:\(\()/i,/^(?:\{\{)/i,/^(?:\()/i,/^(?:\[)/i,/^(?:[\s]+)/i,/^(?:[^\(\[\n\)\{\}]+)/i,/^(?:$)/i,/^(?:["][`])/i,/^(?:[^`"]+)/i,/^(?:[`]["])/i,/^(?:["])/i,/^(?:[^"]+)/i,/^(?:["])/i,/^(?:[\)]\))/i,/^(?:[\)])/i,/^(?:[\]])/i,/^(?:\}\})/i,/^(?:\(-)/i,/^(?:-\))/i,/^(?:\(\()/i,/^(?:\()/i,/^(?:[^\)\]\(\}]+)/i,/^(?:.+(?!\(\())/i],conditions:{CLASS:{rules:[3,4],inclusive:!1},ICON:{rules:[8,9],inclusive:!1},NSTR2:{rules:[22,23],inclusive:!1},NSTR:{rules:[25,26],inclusive:!1},NODE:{rules:[21,24,27,28,29,30,31,32,33,34,35,36],inclusive:!1},INITIAL:{rules:[0,1,2,5,6,7,10,11,12,13,14,15,16,17,18,19,20],inclusive:!0}}};return O})();X.lexer=ne;function V(){this.yy={}}return h(V,"Parser"),V.prototype=X,X.Parser=V,new V})();K.parser=K;var ke=K,Se=12,T={DEFAULT:0,NO_BORDER:0,ROUNDED_RECT:1,RECT:2,CIRCLE:3,CLOUD:4,BANG:5,HEXAGON:6},A,xe=(A=class{constructor(){this.nodes=[],this.count=0,this.elements={},this.getLogger=this.getLogger.bind(this),this.nodeType=T,this.clear(),this.getType=this.getType.bind(this),this.getElementById=this.getElementById.bind(this),this.getParent=this.getParent.bind(this),this.getMindmap=this.getMindmap.bind(this),this.addNode=this.addNode.bind(this),this.decorateNode=this.decorateNode.bind(this)}clear(){this.nodes=[],this.count=0,this.elements={},this.baseLevel=void 0}getParent(e){for(let o=this.nodes.length-1;o>=0;o--)if(this.nodes[o].level<e)return this.nodes[o];return null}getMindmap(){return this.nodes.length>0?this.nodes[0]:null}addNode(e,o,l,n){var L,D;R.info("addNode",e,o,l,n);let d=!1;this.nodes.length===0?(this.baseLevel=e,e=0,d=!0):this.baseLevel!==void 0&&(e=e-this.baseLevel,d=!1);const p=U();let y=((L=p.mindmap)==null?void 0:L.padding)??W.mindmap.padding;switch(n){case this.nodeType.ROUNDED_RECT:case this.nodeType.RECT:case this.nodeType.HEXAGON:y*=2;break}const E={id:this.count++,nodeId:H(o,p),level:e,descr:H(l,p),type:n,children:[],width:((D=p.mindmap)==null?void 0:D.maxNodeWidth)??W.mindmap.maxNodeWidth,padding:y,isRoot:d},k=this.getParent(e);if(k)k.children.push(E),this.nodes.push(E);else if(d)this.nodes.push(E);else throw new Error(`There can be only one root. No parent could be found for ("${E.descr}")`)}getType(e,o){switch(R.debug("In get type",e,o),e){case"[":return this.nodeType.RECT;case"(":return o===")"?this.nodeType.ROUNDED_RECT:this.nodeType.CLOUD;case"((":return this.nodeType.CIRCLE;case")":return this.nodeType.CLOUD;case"))":return this.nodeType.BANG;case"{{":return this.nodeType.HEXAGON;default:return this.nodeType.DEFAULT}}setElementForId(e,o){this.elements[e]=o}getElementById(e){return this.elements[e]}decorateNode(e){if(!e)return;const o=U(),l=this.nodes[this.nodes.length-1];e.icon&&(l.icon=H(e.icon,o)),e.class&&(l.class=H(e.class,o))}type2Str(e){switch(e){case this.nodeType.DEFAULT:return"no-border";case this.nodeType.RECT:return"rect";case this.nodeType.ROUNDED_RECT:return"rounded-rect";case this.nodeType.CIRCLE:return"circle";case this.nodeType.CLOUD:return"cloud";case this.nodeType.BANG:return"bang";case this.nodeType.HEXAGON:return"hexgon";default:return"no-border"}}assignSections(e,o){if(e.level===0?e.section=void 0:e.section=o,e.children)for(const[l,n]of e.children.entries()){const d=e.level===0?l%(Se-1):o;this.assignSections(n,d)}}flattenNodes(e,o){const l=U(),n=["mindmap-node"];e.isRoot===!0?n.push("section-root","section--1"):e.section!==void 0&&n.push(`section-${e.section}`),e.class&&n.push(e.class);const d=n.join(" "),p=h(E=>{var D;const L=(((D=l.theme)==null?void 0:D.toLowerCase())??"").includes("redux");switch(E){case T.CIRCLE:return"mindmapCircle";case T.RECT:return"rect";case T.ROUNDED_RECT:return"rounded";case T.CLOUD:return"cloud";case T.BANG:return"bang";case T.HEXAGON:return"hexagon";case T.DEFAULT:return L?"rounded":"defaultMindmapNode";case T.NO_BORDER:default:return"rect"}},"getShapeFromType"),y={id:e.id.toString(),domId:"node_"+e.id.toString(),label:e.descr,labelType:"markdown",isGroup:!1,shape:p(e.type),width:e.width,height:e.height??0,padding:e.padding,cssClasses:d,cssStyles:[],look:l.look,icon:e.icon,x:e.x,y:e.y,level:e.level,nodeId:e.nodeId,type:e.type,section:e.section};if(o.push(y),e.children)for(const E of e.children)this.flattenNodes(E,o)}generateEdges(e,o){if(!e.children)return;const l=U();for(const n of e.children){let d="edge";n.section!==void 0&&(d+=` section-edge-${n.section}`);const p=e.level+1;d+=` edge-depth-${p}`;const y={id:`edge_${e.id}_${n.id}`,start:e.id.toString(),end:n.id.toString(),type:"normal",curve:"basis",thickness:"normal",look:l.look,classes:d,depth:e.level,section:n.section};o.push(y),this.generateEdges(n,o)}}getData(){const e=this.getMindmap(),o=U(),n=ge().layout!==void 0,d=o;if(n||(d.layout="cose-bilkent"),!e)return{nodes:[],edges:[],config:d};R.debug("getData: mindmapRoot",e,o),this.assignSections(e);const p=[],y=[];this.flattenNodes(e,p),this.generateEdges(e,y),R.debug(`getData: processed ${p.length} nodes and ${y.length} edges`);const E=new Map;for(const k of p)E.set(k.id,{shape:k.shape,width:k.width,height:k.height,padding:k.padding});return{nodes:p,edges:y,config:d,rootNode:e,markers:["point"],direction:"TB",nodeSpacing:50,rankSpacing:50,shapes:Object.fromEntries(E),type:"mindmap",diagramId:"mindmap-"+_e()}}getLogger(){return R}},h(A,"MindmapDB"),A),Ne=h(async(t,e,o,l)=>{var b,$;R.debug(`Rendering mindmap diagram
7
+ `+t);const n=l.db,d=n.getData(),p=oe(e,d.config.securityLevel);if(d.type=l.type,d.layoutAlgorithm=le(d.config.layout,{fallback:"cose-bilkent"}),d.diagramId=e,!n.getMindmap())return;d.nodes.forEach(f=>{f.shape==="rounded"?(f.radius=15,f.taper=15,f.stroke="none",f.width=0,f.padding=15):f.shape==="circle"?f.padding=10:f.shape==="rect"?(f.width=0,f.padding=10):f.shape==="hexagon"&&(f.width=0,f.height=0)}),await he(d,p);const{themeVariables:E}=de(),{useGradient:k,gradientStart:L,gradientStop:D}=E;if(k&&L&&D){const f=p.attr("id"),B=p.append("defs").append("linearGradient").attr("id",`${f}-gradient`).attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");B.append("stop").attr("offset","0%").attr("stop-color",L).attr("stop-opacity",1),B.append("stop").attr("offset","100%").attr("stop-color",D).attr("stop-opacity",1)}ce(p,((b=d.config.mindmap)==null?void 0:b.padding)??W.mindmap.padding,"mindmapDiagram",(($=d.config.mindmap)==null?void 0:$.useMaxWidth)??W.mindmap.useMaxWidth)},"draw"),De={draw:Ne},Le=h(t=>{const{theme:e,look:o}=t;let l="";for(let n=0;n<t.THEME_COLOR_LIMIT;n++)t["lineColor"+n]=t["lineColor"+n]||t["cScaleInv"+n],ue(t["lineColor"+n])?t["lineColor"+n]=pe(t["lineColor"+n],20):t["lineColor"+n]=fe(t["lineColor"+n],20);for(let n=0;n<t.THEME_COLOR_LIMIT;n++){const d=""+(o==="neo"?Math.max(10-(n-1)*2,2):17-3*n);l+=`
8
+ .section-${n-1} rect, .section-${n-1} path, .section-${n-1} circle, .section-${n-1} polygon, .section-${n-1} path {
9
+ fill: ${t["cScale"+n]};
10
+ }
11
+ .section-${n-1} text {
12
+ fill: ${t["cScaleLabel"+n]};
13
+ }
14
+ .section-${n-1} span {
15
+ color: ${t["cScaleLabel"+n]};
16
+ }
17
+ .node-icon-${n-1} {
18
+ font-size: 40px;
19
+ color: ${t["cScaleLabel"+n]};
20
+ }
21
+ .section-edge-${n-1}{
22
+ stroke: ${t["cScale"+n]};
23
+ }
24
+ .edge-depth-${n-1}{
25
+ stroke-width: ${d};
26
+ }
27
+ .section-${n-1} line {
28
+ stroke: ${t["cScaleInv"+n]} ;
29
+ stroke-width: 3;
30
+ }
31
+
32
+ .disabled, .disabled circle, .disabled text {
33
+ fill: lightgray;
34
+ }
35
+ .disabled text {
36
+ fill: #efefef;
37
+ }
38
+ [data-look="neo"].mindmap-node.section-${n-1} rect, [data-look="neo"].mindmap-node.section-${n-1} path, [data-look="neo"].mindmap-node.section-${n-1} circle, [data-look="neo"].mindmap-node.section-${n-1} polygon {
39
+ fill: ${e==="redux"||e==="redux-dark"||e==="neutral"?t.mainBkg:t["cScale"+n]};
40
+ stroke: ${e==="redux"||e==="redux-dark"?t.nodeBorder:t["cScale"+n]};
41
+ stroke-width: ${t.strokeWidth??2}px;
42
+ }
43
+ [data-look="neo"].section-edge-${n-1}{
44
+ stroke: ${e!=null&&e.includes("redux")||e==="neo-dark"?t.nodeBorder:t["cScale"+n]};
45
+ }
46
+ [data-look="neo"].mindmap-node.section-${n-1} text {
47
+ fill: ${e==="redux"||e==="redux-dark"?t.nodeBorder:t["cScaleLabel"+(e==="neutral"?1:n)]};
48
+ }
49
+ `}return l},"genSections"),ve=h((t,e,o)=>{let l="";for(let n=0;n<t;n++)l+=`
50
+ [data-look="neo"].mindmap-node.section-${n-1} rect, [data-look="neo"].mindmap-node.section-${n-1} path, [data-look="neo"].mindmap-node.section-${n-1} circle, [data-look="neo"].mindmap-node.section-${n-1} polygon {
51
+ stroke: url(${e}-gradient);
52
+ fill: ${o};
53
+ }
54
+ .section-${n-1} line {
55
+ stroke-width: 0;
56
+ }`;return l},"genGradient"),Te=h(t=>{const{theme:e}=t,o=t.svgId,l=t.dropShadow?t.dropShadow.replace("url(#drop-shadow)",`url(${o}-drop-shadow)`):"none";return`
57
+ .edge {
58
+ stroke-width: 3;
59
+ }
60
+ ${Le(t)}
61
+ .section-root rect, .section-root path, .section-root circle, .section-root polygon {
62
+ fill: ${t.git0};
63
+ }
64
+ .section-root text {
65
+ fill: ${t.gitBranchLabel0};
66
+ }
67
+ .section-root span {
68
+ color: ${e!=null&&e.includes("redux")?t.nodeBorder:t.gitBranchLabel0};
69
+ }
70
+ .icon-container {
71
+ height:100%;
72
+ display: flex;
73
+ justify-content: center;
74
+ align-items: center;
75
+ }
76
+ .edge {
77
+ fill: none;
78
+ }
79
+ .mindmap-node-label {
80
+ dy: 1em;
81
+ alignment-baseline: middle;
82
+ text-anchor: middle;
83
+ dominant-baseline: middle;
84
+ text-align: center;
85
+ }
86
+ [data-look="neo"].mindmap-node {
87
+ filter: ${l};
88
+ }
89
+ [data-look="neo"].mindmap-node.section-root rect, [data-look="neo"].mindmap-node.section-root path, [data-look="neo"].mindmap-node.section-root circle, [data-look="neo"].mindmap-node.section-root polygon {
90
+ fill: ${e!=null&&e.includes("redux")?t.mainBkg:t.git0};
91
+ }
92
+ [data-look="neo"].mindmap-node.section-root .text-inner-tspan {
93
+ fill: ${e!=null&&e.includes("redux")?t.nodeBorder:t["cScaleLabel"+(e==="neutral"?1:0)]};
94
+ }
95
+ ${t.useGradient&&o&&t.mainBkg?ve(t.THEME_COLOR_LIMIT,o,t.mainBkg):""}
96
+ `},"getStyles"),Oe=Te,Ae={get db(){return new xe},renderer:De,parser:ke,styles:Oe};export{Ae as diagram};
@@ -0,0 +1 @@
1
+ import{i as a}from"./init-Gi6I4Gst.js";class o extends Map{constructor(n,t=g){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),n!=null)for(const[r,s]of n)this.set(r,s)}get(n){return super.get(c(this,n))}has(n){return super.has(c(this,n))}set(n,t){return super.set(l(this,n),t)}delete(n){return super.delete(p(this,n))}}function c({_intern:e,_key:n},t){const r=n(t);return e.has(r)?e.get(r):t}function l({_intern:e,_key:n},t){const r=n(t);return e.has(r)?e.get(r):(e.set(r,t),t)}function p({_intern:e,_key:n},t){const r=n(t);return e.has(r)&&(t=e.get(r),e.delete(r)),t}function g(e){return e!==null&&typeof e=="object"?e.valueOf():e}const f=Symbol("implicit");function h(){var e=new o,n=[],t=[],r=f;function s(u){let i=e.get(u);if(i===void 0){if(r!==f)return r;e.set(u,i=n.push(u)-1)}return t[i%t.length]}return s.domain=function(u){if(!arguments.length)return n.slice();n=[],e=new o;for(const i of u)e.has(i)||e.set(i,n.push(i)-1);return s},s.range=function(u){return arguments.length?(t=Array.from(u),s):t.slice()},s.unknown=function(u){return arguments.length?(r=u,s):r},s.copy=function(){return h(n,t).unknown(r)},a.apply(s,arguments),s}export{h as o};
@@ -0,0 +1 @@
1
+ import{g as l,r as m,d as a}from"./chunk-SVP7TREG-DpkmrgHn.js";import{p}from"./chunk-JWPE2WC7-B7HxxQds.js";import{_ as t,l as o}from"./MermaidBlock-DR1GikCv.js";import{M as u,d as c}from"./cynefin-OW5HDTMX-DUwn3ehS.js";import"./index-GAamh1p4.js";var f=c().RailroadPeg.parser.LangiumParser,i=t(e=>{const r=e.alternatives.map(d);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformOrderedChoice"),d=t(e=>{const r=e.elements.map(P);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformSequence"),P=t(e=>{const r=g(e.suffix);return e.operator?{type:"special",text:e.operator==="&"?`&${s(r)}`:`!${s(r)}`}:r},"transformPrefix"),s=t(e=>{switch(e.type){case"terminal":return`"${e.value}"`;case"nonterminal":return e.name;case"special":return e.text;default:return"(...)"}},"nodeToLabel"),g=t(e=>{const r=v(e.primary);if(!e.operator)return r;switch(e.operator){case"?":return{type:"optional",element:r};case"*":return{type:"repetition",element:r,min:0,max:1/0};case"+":return{type:"repetition",element:r,min:1,max:1/0};default:throw new Error(`Unsupported PEG suffix operator: ${e.operator}`)}},"transformSuffix"),v=t(e=>{switch(e.$type){case"PegLiteral":return{type:"terminal",value:e.value};case"PegIdentifier":return{type:"nonterminal",name:e.name};case"PegGroup":return i(e.element);case"PegAny":return{type:"special",text:e.dot};default:throw new Error(`Unsupported PEG primary node: ${e.$type}`)}},"transformPrimary"),y=t(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=t(e=>{p(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(y(r)))},"populateDb"),b={parse:t(e=>{a.clear(),o.debug("[PEG Parser] Starting Langium parse");const r=f.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new u(r);const n=r.value;o.debug("[PEG Parser] Parsed rules:",n.rules.length),h(n),o.debug("[PEG Parser] Parse complete")},"parse"),parser:{yy:a}},G={parser:b,db:a,renderer:m,styles:l};export{G as diagram};
@@ -1,4 +1,4 @@
1
- import{c as Ne,r as d,j as f,R as N,C as m,F as G,b as rt,G as b,k as ee,e as wt,a2 as Qe,A as We,X as ne,aj as Jt,ak as re,v as oe,al as Tt,am as tn,ad as en,ae as nn,an as rn,w as on,f as sn,l as ln,E as gt,t as Qt,ao as It,ap as jt}from"./index-BHTBJlpY.js";/**
1
+ import{c as Ne,r as d,j as f,R as N,d as m,F as G,a as rt,G as b,P as ee,e as wt,L as Qe,S as We,X as ne,at as Zt,au as re,o as oe,av as Tt,aw as tn,J as en,K as nn,ax as rn,ag as on,a0 as sn,a7 as ln,aj as gt,af as Qt,ay as It,az as jt}from"./index-GAamh1p4.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -8,8 +8,8 @@ import{c as Ne,r as d,j as f,R as N,C as m,F as G,b as rt,G as b,k as ee,e as wt
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const cn=Ne("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);function Ct(t){if(!t)return null;const e=t.offsetParent;if(!e)return null;const n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return{x:n.left-r.left+(e.scrollLeft||0),y:n.top-r.top+(e.scrollTop||0),iframeRect:n,containerRect:r}}function Be(t,e,n,r=1){return{left:t.x+e*r,top:t.y+n*r}}function Re(t,e,n,r){var I,j;const i=r.offset??12,{cardWidth:s,cardHeight:a}=r,o=((I=t.iframeRect)==null?void 0:I.width)??0,l=((j=t.iframeRect)==null?void 0:j.height)??0,u=t.x+e.left*n,p=t.y+e.top*n,c=e.width*n,W=t.x+i,k=t.x+o-i,O=t.y+i,L=t.y+l-i;let A=u+c+i;A+s>k&&(A=u-s-i),A<W&&(A=W);let T=p;return T+a>L&&(T=Math.max(O,L-a)),T<O&&(T=O),{left:A,top:T}}const un=3,dn=12;function fn(t,e){const n=Math.max(0,Math.min(t.x+t.w,e.x+e.w)-Math.max(t.x,e.x)),r=Math.max(0,Math.min(t.y+t.h,e.y+e.h)-Math.max(t.y,e.y));return n*r}const _t=t=>Math.max(0,t.w)*Math.max(0,t.h);function pn(t,e,n={}){const r=n.max??dn,i=n.contains||((l,u)=>{var p;return l!==u&&((p=l==null?void 0:l.contains)==null?void 0:p.call(l,u))}),s=_t(e);if(!s)return[];const a=[];for(const l of t){if(!(l!=null&&l.rect))continue;const u=fn(l.rect,e);if(u<=0)continue;const p=_t(l.rect);a.push({...l,overlap:u,coverage:p>0?u/p:0,own:p})}if(!a.length)return[];let o=a.filter(l=>l.own<=s*un);return o.length>1&&(o=o.filter(l=>!o.some(u=>i(l.el,u.el)))),o.length||(o=[a.reduce((u,p)=>p.own<u.own?p:u,a[0])]),o.sort((l,u)=>u.coverage-l.coverage||l.own-u.own),o.slice(0,r).map(({el:l,rect:u,coverage:p,overlap:c})=>({el:l,rect:u,coverage:p,overlap:c}))}function xe(t,e){return{x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}}const hn=400;function gn(t){return!!t&&t.w>4&&t.h>4&&t.w*t.h>=hn}function bn(t,e){const n=i=>i.x<=e.x&&i.y<=e.y&&i.x+i.w>=e.x+e.w&&i.y+i.h>=e.y+e.h;let r=null;for(const i of t)!(i!=null&&i.rect)||!n(i.rect)||(!r||_t(i.rect)<_t(r.rect))&&(r=i);return r}const xn=new Set(["SCRIPT","STYLE","LINK","META","TITLE","HEAD","BR","HTML","BODY"]),ye=300;function ve(t,e,n){const r=t.getBoundingClientRect();return{anchor:Jt(t),tag:t.tagName.toLowerCase(),...t.id?{id:t.id}:{},...typeof t.className=="string"&&t.className?{class:t.className.slice(0,80)}:{},text:(t.textContent||"").trim().replace(/\s+/g," ").slice(0,80),rect:{x:Math.round(r.left+e),y:Math.round(r.top+n),w:Math.round(r.width),h:Math.round(r.height)}}}function Jr({active:t,iframeRef:e,zoom:n=1,onSubmit:r,onExit:i}){const[s,a]=d.useState(null),[o,l]=d.useState(null),[u,p]=d.useState(""),[c,W]=d.useState(!1),[,k]=d.useState(0),O=d.useRef(null);d.useEffect(()=>{if(!t)return;const g=()=>k(h=>h+1);return window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[t]),d.useEffect(()=>{t||(a(null),l(null),p(""))},[t]);const L=d.useCallback(()=>{a(null),l(null),p("")},[]);d.useEffect(()=>{if(!t)return;const g=h=>{h.key==="Escape"&&(h.stopPropagation(),o||s?L():i==null||i())};return window.addEventListener("keydown",g,!0),()=>window.removeEventListener("keydown",g,!0)},[t,o,s,L,i]);const A=e==null?void 0:e.current,T=t&&A?Ct(A):null;if(!t||!T)return null;const I=A.contentDocument;if(!I)return null;const j=T.iframeRect.width,C=T.iframeRect.height,x=g=>{const h=O.current.getBoundingClientRect();return{x:Math.min(Math.max(0,g.clientX-h.left),j),y:Math.min(Math.max(0,g.clientY-h.top),C)}},y=g=>{var D,U;if(g.button!==0||o)return;g.preventDefault(),g.stopPropagation(),(U=(D=g.currentTarget).setPointerCapture)==null||U.call(D,g.pointerId);const h=x(g);a({from:h,to:h})},S=g=>{s&&(g.stopPropagation(),a(h=>h&&{...h,to:x(g)}))},J=g=>{if(!s)return;g.stopPropagation();const h=xe(s.from,s.to);if(a(null),!gn(h))return;const D={x:h.x/n,y:h.y/n,w:h.w/n,h:h.h/n},U=[];for(const Q of I.body.querySelectorAll("*")){if(xn.has(Q.tagName))continue;const Z=Q.getBoundingClientRect();Z.width<=0||Z.height<=0||U.push({el:Q,rect:{x:Z.left,y:Z.top,w:Z.width,h:Z.height}})}const Y=pn(U,D),ot=bn(U,D),$=I.scrollingElement||I.documentElement,v=($==null?void 0:$.scrollLeft)||0,M=($==null?void 0:$.scrollTop)||0,F=A.contentWindow;l({box:h,region:{x:Math.round(D.x+v),y:Math.round(D.y+M),w:Math.round(D.w),h:Math.round(D.h)},viewport:{width:Math.round((F==null?void 0:F.innerWidth)||j/n),height:Math.round((F==null?void 0:F.innerHeight)||C/n)},container:ot?ve(ot.el,v,M):null,elements:Y.map(({el:Q,coverage:Z})=>({...ve(Q,v,M),coverage:Math.round(Z*100)/100}))})},K=async()=>{if(!(!o||c)){W(!0);try{await(r==null?void 0:r({region:o.region,viewport:o.viewport,container:o.container,elements:o.elements,text:u.trim()})),L(),i==null||i()}finally{W(!1)}}},z=s?xe(s.from,s.to):null,R=(o==null?void 0:o.box)||z;let q=0,X=0;if(o){const g=o.box;q=g.y+g.h+10,q+190>C&&(q=Math.max(8,g.y-190-10)),X=Math.min(Math.max(8,g.x),Math.max(8,j-ye-8))}return f.jsxs("div",{ref:O,"data-no-pan":!0,onPointerDown:y,onPointerMove:S,onPointerUp:J,onPointerCancel:()=>a(null),style:{position:"absolute",left:T.x,top:T.y,width:j,height:C,zIndex:40,cursor:o?"default":"crosshair",background:o?"transparent":"rgba(32,26,14,0.10)",touchAction:"none"},children:[R&&f.jsxs(f.Fragment,{children:[f.jsx("div",{style:{position:"absolute",left:R.x,top:R.y,width:R.w,height:R.h,border:`2px solid ${m.btn}`,borderRadius:N.sm,background:"rgba(255,255,255,0.06)",boxShadow:"0 0 0 9999px rgba(32,26,14,0.18)",pointerEvents:"none"}}),o&&f.jsxs("div",{style:{position:"absolute",left:R.x,top:Math.max(0,R.y-20),padding:"1px 7px",borderRadius:N.sm,background:m.text,color:m.bgWhite,fontFamily:rt,fontSize:G.xxs,whiteSpace:"nowrap",pointerEvents:"none"},children:["框住 ",o.elements.length," 个元素"]})]}),o&&f.jsxs("div",{onPointerDown:g=>g.stopPropagation(),style:{position:"absolute",left:X,top:q,width:ye,background:m.bgWhite,borderRadius:N.lg,boxShadow:ee.far,padding:b.md,display:"flex",flexDirection:"column",gap:b.sm},children:[f.jsxs("div",{style:{fontFamily:wt,fontSize:G.xs,color:m.sub,lineHeight:1.5},children:[o.elements.slice(0,3).map(g=>`<${g.tag}>${g.text?` ${g.text.slice(0,14)}`:""}`).join("、"),o.elements.length>3?` 等 ${o.elements.length} 个`:""]}),f.jsx("textarea",{value:u,autoFocus:!0,onChange:g=>p(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.metaKey||g.ctrlKey)&&(g.preventDefault(),K())},placeholder:"这一块想说什么…(可以不写,框本身就是话)",style:{width:"100%",boxSizing:"border-box",minHeight:64,resize:"vertical",fontFamily:wt,fontSize:G.sm,color:m.text,lineHeight:1.6,border:`1px solid ${m.borderLt}`,borderRadius:N.md,padding:b.sm,outline:"none",background:m.bg}}),f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:b.sm},children:[f.jsxs("button",{onClick:K,disabled:c,style:{display:"inline-flex",alignItems:"center",gap:b.xs,padding:`5px ${b.lg}px`,borderRadius:N.pill,border:"none",background:m.btn,color:m.btnText,fontFamily:wt,fontSize:G.sm,fontWeight:600,cursor:c?"default":"pointer",opacity:c?.7:1},children:[c?f.jsxs(f.Fragment,{children:[f.jsx(Qe,{size:12,style:{animation:"spin 1s linear infinite"}})," 截图中…"]}):f.jsxs(f.Fragment,{children:[f.jsx(We,{size:12})," 发给 agent"]}),f.jsx("style",{children:"@keyframes spin{to{transform:rotate(360deg)}}"})]}),f.jsxs("button",{onClick:L,style:{display:"inline-flex",alignItems:"center",gap:b.xs,padding:`5px ${b.md}px`,borderRadius:N.pill,border:`1px solid ${m.borderLt}`,background:"transparent",color:m.sub,fontFamily:wt,fontSize:G.xs,cursor:"pointer"},children:[f.jsx(ne,{size:11})," 重画"]}),f.jsx("span",{style:{marginLeft:"auto",fontFamily:rt,fontSize:G.xxs,color:m.dim},children:"⌘↵"})]})]})]})}const me="__nodesignBridgeState";function Ke(t){return t[me]||(t[me]={})}function Qr(t,{onTextEdit:e,onSelect:n}={}){const r=Ge(t);if(!r)return;yn(t);const i=Ke(t),s=o=>{const l=o.target;if(!l||l.nodeType!==1||!vn(l)||pt(l))return;o.preventDefault(),o.stopPropagation(),l.setAttribute("contenteditable","true"),l.style.outline="2px solid #2d2418",l.style.outlineOffset="4px",l.focus();const u=r.createRange();u.selectNodeContents(l);const p=r.getSelection();p==null||p.removeAllRanges(),p==null||p.addRange(u);const c=l.textContent,W=()=>{l.removeEventListener("blur",k),l.removeEventListener("keydown",O),l.removeAttribute("contenteditable"),l.style.outline="",l.style.outlineOffset=""},k=()=>{const L=l.textContent;W(),L!==c&&(e==null||e({anchor:Jt(l),oldText:c,newText:L}))},O=L=>{if(L.key==="Escape")l.textContent=c,l.blur();else if(L.key==="Enter"&&!L.shiftKey){if(re(L))return;L.preventDefault(),l.blur()}};l.addEventListener("blur",k),l.addEventListener("keydown",O)},a=o=>{var u,p;if(((p=(u=o.target).getAttribute)==null?void 0:p.call(u,"contenteditable"))==="true")return;const l=o.target;if(!(!l||l.nodeType!==1)){if(l===r.body||l===r.documentElement){n==null||n({anchor:null});return}n==null||n({anchor:Jt(l)})}};r.addEventListener("dblclick",s,!0),r.addEventListener("click",a,!0),i.handleDblClick=s,i.handleClick=a,i.mode="edit"}function yn(t){const e=Ge(t);if(!e)return;const n=Ke(t);n.handleDblClick&&e.removeEventListener("dblclick",n.handleDblClick,!0),n.handleClick&&e.removeEventListener("click",n.handleClick,!0),e.querySelectorAll('[contenteditable="true"]').forEach(i=>{i.removeAttribute("contenteditable"),i.style.outline="",i.style.outlineOffset=""}),n.handleDblClick=null,n.handleClick=null,n.mode=null}function Ge(t){var e;try{return(t==null?void 0:t.contentDocument)||((e=t==null?void 0:t.contentWindow)==null?void 0:e.document)||null}catch{return null}}function vn(t){return!t||t.nodeType!==1||t.querySelector(":scope > div, :scope > section, :scope > article, :scope > main, :scope > header, :scope > footer, :scope > nav, :scope > ul, :scope > ol")?!1:["H1","H2","H3","H4","H5","H6","P","SPAN","LI","DIV","A","STRONG","EM","SMALL","LABEL","BUTTON"].includes(t.tagName)}function pt(t){let e=t;for(;e&&e.nodeType===1;){if(e.hasAttribute&&e.hasAttribute("data-react-mount"))return!0;if(e.tagName==="SECTION"&&e.hasAttribute("data-page")||e.tagName==="BODY"||e.tagName==="HTML")return!1;e=e.parentNode}return!1}function to({selectedAnchor:t,iframeRef:e,zoom:n=1}){const[,r]=d.useState(0);if(d.useEffect(()=>{if(!t)return;const T=e==null?void 0:e.current;if(!T)return;const I=T.contentWindow;if(!I)return;let j=null;const C=()=>{j||(j=requestAnimationFrame(()=>{j=null,r(x=>x+1)}))};try{I.addEventListener("scroll",C,{passive:!0,capture:!0}),I.addEventListener("resize",C),window.addEventListener("resize",C)}catch{}return()=>{try{I.removeEventListener("scroll",C,{capture:!0}),I.removeEventListener("resize",C),window.removeEventListener("resize",C)}catch{}j&&cancelAnimationFrame(j)}},[t,e]),!t||!(e!=null&&e.current))return null;const i=e.current,s=i.contentDocument;if(!s)return null;const a=oe(t,s.body);if(!a)return null;const o=a.getBoundingClientRect(),l=i.getBoundingClientRect(),u=i.contentWindow,p=(u==null?void 0:u.innerWidth)??l.width/n,c=(u==null?void 0:u.innerHeight)??l.height/n;if(o.bottom<=0||o.top>=c||o.right<=0||o.left>=p)return null;const W=Ct(i);if(!W)return null;const{top:k,left:O}=Be(W,o.left,o.top,n),L=o.width*n,A=o.height*n;return f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:k-4,left:O-4,width:L+8,height:A+8,border:`2px solid ${m.btn}`,borderRadius:N.sm,boxShadow:"0 0 0 4px rgba(45, 36, 24, 0.08)",zIndex:10}})}function we(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function mn(t){if(Array.isArray(t))return t}function wn(t,e,n){return(e=kn(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sn(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,s,a,o=[],l=!0,u=!1;try{if(s=(n=n.call(t)).next,e!==0)for(;!(l=(r=s.call(n)).done)&&(o.push(r.value),o.length!==e);l=!0);}catch(p){u=!0,i=p}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return o}}function Mn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
12
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Se(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Me(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Se(Object(n),!0).forEach(function(r){wn(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Se(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function En(t,e){if(t==null)return{};var n,r,i=Ln(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Ln(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function jn(t,e){return mn(t)||Sn(t,e)||On(t,e)||Mn()}function Cn(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function kn(t){var e=Cn(t,"string");return typeof e=="symbol"?e:e+""}function On(t,e){if(t){if(typeof t=="string")return we(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?we(t,e):void 0}}function Tn(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ee(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Le(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ee(Object(n),!0).forEach(function(r){Tn(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ee(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function In(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return function(r){return e.reduceRight(function(i,s){return s(i)},r)}}function Pt(t){return function e(){for(var n=this,r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];return i.length>=t.length?t.apply(this,i):function(){for(var a=arguments.length,o=new Array(a),l=0;l<a;l++)o[l]=arguments[l];return e.apply(n,[].concat(i,o))}}}function Vt(t){return{}.toString.call(t).includes("Object")}function An(t){return!Object.keys(t).length}function Ht(t){return typeof t=="function"}function zn(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function $n(t,e){return Vt(e)||St("changeType"),Object.keys(e).some(function(n){return!zn(t,n)})&&St("changeField"),e}function Dn(t){Ht(t)||St("selectorType")}function Pn(t){Ht(t)||Vt(t)||St("handlerType"),Vt(t)&&Object.values(t).some(function(e){return!Ht(e)})&&St("handlersType")}function Fn(t){t||St("initialIsRequired"),Vt(t)||St("initialType"),An(t)&&St("initialContent")}function Hn(t,e){throw new Error(t[e]||t.default)}var Nn={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},St=Pt(Hn)(Nn),Kt={changes:$n,selector:Dn,handler:Pn,initial:Fn};function Wn(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Kt.initial(t),Kt.handler(e);var n={current:t},r=Pt(Kn)(n,e),i=Pt(Rn)(n),s=Pt(Kt.changes)(t),a=Pt(Bn)(n);function o(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(p){return p};return Kt.selector(u),u(n.current)}function l(u){In(r,i,s,a)(u)}return[o,l]}function Bn(t,e){return Ht(e)?e(t.current):e}function Rn(t,e){return t.current=Le(Le({},t.current),e),e}function Kn(t,e,n){return Ht(e)?e(t.current):Object.keys(n).forEach(function(r){var i;return(i=e[r])===null||i===void 0?void 0:i.call(e,t.current[r])}),n}var Gn={create:Wn},_n={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Vn(t){return function e(){for(var n=this,r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];return i.length>=t.length?t.apply(this,i):function(){for(var a=arguments.length,o=new Array(a),l=0;l<a;l++)o[l]=arguments[l];return e.apply(n,[].concat(i,o))}}}function Xn(t){return{}.toString.call(t).includes("Object")}function Yn(t){return t||je("configIsRequired"),Xn(t)||je("configType"),t.urls?(qn(),{paths:{vs:t.urls.monacoBase}}):t}function qn(){console.warn(_e.deprecation)}function Un(t,e){throw new Error(t[e]||t.default)}var _e={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
11
+ */const cn=Ne("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);function Ct(t){if(!t)return null;const e=t.offsetParent;if(!e)return null;const n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return{x:n.left-r.left+(e.scrollLeft||0),y:n.top-r.top+(e.scrollTop||0),iframeRect:n,containerRect:r}}function Be(t,e,n,r=1){return{left:t.x+e*r,top:t.y+n*r}}function Re(t,e,n,r){var I,j;const i=r.offset??12,{cardWidth:s,cardHeight:a}=r,o=((I=t.iframeRect)==null?void 0:I.width)??0,l=((j=t.iframeRect)==null?void 0:j.height)??0,u=t.x+e.left*n,p=t.y+e.top*n,c=e.width*n,W=t.x+i,O=t.x+o-i,k=t.y+i,L=t.y+l-i;let A=u+c+i;A+s>O&&(A=u-s-i),A<W&&(A=W);let T=p;return T+a>L&&(T=Math.max(k,L-a)),T<k&&(T=k),{left:A,top:T}}const un=3,dn=12;function fn(t,e){const n=Math.max(0,Math.min(t.x+t.w,e.x+e.w)-Math.max(t.x,e.x)),r=Math.max(0,Math.min(t.y+t.h,e.y+e.h)-Math.max(t.y,e.y));return n*r}const _t=t=>Math.max(0,t.w)*Math.max(0,t.h);function pn(t,e,n={}){const r=n.max??dn,i=n.contains||((l,u)=>{var p;return l!==u&&((p=l==null?void 0:l.contains)==null?void 0:p.call(l,u))}),s=_t(e);if(!s)return[];const a=[];for(const l of t){if(!(l!=null&&l.rect))continue;const u=fn(l.rect,e);if(u<=0)continue;const p=_t(l.rect);a.push({...l,overlap:u,coverage:p>0?u/p:0,own:p})}if(!a.length)return[];let o=a.filter(l=>l.own<=s*un);return o.length>1&&(o=o.filter(l=>!o.some(u=>i(l.el,u.el)))),o.length||(o=[a.reduce((u,p)=>p.own<u.own?p:u,a[0])]),o.sort((l,u)=>u.coverage-l.coverage||l.own-u.own),o.slice(0,r).map(({el:l,rect:u,coverage:p,overlap:c})=>({el:l,rect:u,coverage:p,overlap:c}))}function xe(t,e){return{x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}}const hn=400;function gn(t){return!!t&&t.w>4&&t.h>4&&t.w*t.h>=hn}function bn(t,e){const n=i=>i.x<=e.x&&i.y<=e.y&&i.x+i.w>=e.x+e.w&&i.y+i.h>=e.y+e.h;let r=null;for(const i of t)!(i!=null&&i.rect)||!n(i.rect)||(!r||_t(i.rect)<_t(r.rect))&&(r=i);return r}const xn=new Set(["SCRIPT","STYLE","LINK","META","TITLE","HEAD","BR","HTML","BODY"]),ye=300;function ve(t,e,n){const r=t.getBoundingClientRect();return{anchor:Zt(t),tag:t.tagName.toLowerCase(),...t.id?{id:t.id}:{},...typeof t.className=="string"&&t.className?{class:t.className.slice(0,80)}:{},text:(t.textContent||"").trim().replace(/\s+/g," ").slice(0,80),rect:{x:Math.round(r.left+e),y:Math.round(r.top+n),w:Math.round(r.width),h:Math.round(r.height)}}}function Zr({active:t,iframeRef:e,zoom:n=1,onSubmit:r,onExit:i}){const[s,a]=d.useState(null),[o,l]=d.useState(null),[u,p]=d.useState(""),[c,W]=d.useState(!1),[,O]=d.useState(0),k=d.useRef(null);d.useEffect(()=>{if(!t)return;const g=()=>O(h=>h+1);return window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[t]),d.useEffect(()=>{t||(a(null),l(null),p(""))},[t]);const L=d.useCallback(()=>{a(null),l(null),p("")},[]);d.useEffect(()=>{if(!t)return;const g=h=>{h.key==="Escape"&&(h.stopPropagation(),o||s?L():i==null||i())};return window.addEventListener("keydown",g,!0),()=>window.removeEventListener("keydown",g,!0)},[t,o,s,L,i]);const A=e==null?void 0:e.current,T=t&&A?Ct(A):null;if(!t||!T)return null;const I=A.contentDocument;if(!I)return null;const j=T.iframeRect.width,C=T.iframeRect.height,x=g=>{const h=k.current.getBoundingClientRect();return{x:Math.min(Math.max(0,g.clientX-h.left),j),y:Math.min(Math.max(0,g.clientY-h.top),C)}},y=g=>{var D,U;if(g.button!==0||o)return;g.preventDefault(),g.stopPropagation(),(U=(D=g.currentTarget).setPointerCapture)==null||U.call(D,g.pointerId);const h=x(g);a({from:h,to:h})},S=g=>{s&&(g.stopPropagation(),a(h=>h&&{...h,to:x(g)}))},Z=g=>{if(!s)return;g.stopPropagation();const h=xe(s.from,s.to);if(a(null),!gn(h))return;const D={x:h.x/n,y:h.y/n,w:h.w/n,h:h.h/n},U=[];for(const Q of I.body.querySelectorAll("*")){if(xn.has(Q.tagName))continue;const J=Q.getBoundingClientRect();J.width<=0||J.height<=0||U.push({el:Q,rect:{x:J.left,y:J.top,w:J.width,h:J.height}})}const Y=pn(U,D),ot=bn(U,D),$=I.scrollingElement||I.documentElement,v=($==null?void 0:$.scrollLeft)||0,M=($==null?void 0:$.scrollTop)||0,F=A.contentWindow;l({box:h,region:{x:Math.round(D.x+v),y:Math.round(D.y+M),w:Math.round(D.w),h:Math.round(D.h)},viewport:{width:Math.round((F==null?void 0:F.innerWidth)||j/n),height:Math.round((F==null?void 0:F.innerHeight)||C/n)},container:ot?ve(ot.el,v,M):null,elements:Y.map(({el:Q,coverage:J})=>({...ve(Q,v,M),coverage:Math.round(J*100)/100}))})},K=async()=>{if(!(!o||c)){W(!0);try{await(r==null?void 0:r({region:o.region,viewport:o.viewport,container:o.container,elements:o.elements,text:u.trim()})),L(),i==null||i()}finally{W(!1)}}},z=s?xe(s.from,s.to):null,R=(o==null?void 0:o.box)||z;let q=0,X=0;if(o){const g=o.box;q=g.y+g.h+10,q+190>C&&(q=Math.max(8,g.y-190-10)),X=Math.min(Math.max(8,g.x),Math.max(8,j-ye-8))}return f.jsxs("div",{ref:k,"data-no-pan":!0,onPointerDown:y,onPointerMove:S,onPointerUp:Z,onPointerCancel:()=>a(null),style:{position:"absolute",left:T.x,top:T.y,width:j,height:C,zIndex:40,cursor:o?"default":"crosshair",background:o?"transparent":"rgba(32,26,14,0.10)",touchAction:"none"},children:[R&&f.jsxs(f.Fragment,{children:[f.jsx("div",{style:{position:"absolute",left:R.x,top:R.y,width:R.w,height:R.h,border:`2px solid ${m.btn}`,borderRadius:N.sm,background:"rgba(255,255,255,0.06)",boxShadow:"0 0 0 9999px rgba(32,26,14,0.18)",pointerEvents:"none"}}),o&&f.jsxs("div",{style:{position:"absolute",left:R.x,top:Math.max(0,R.y-20),padding:"1px 7px",borderRadius:N.sm,background:m.text,color:m.bgWhite,fontFamily:rt,fontSize:G.xxs,whiteSpace:"nowrap",pointerEvents:"none"},children:["框住 ",o.elements.length," 个元素"]})]}),o&&f.jsxs("div",{onPointerDown:g=>g.stopPropagation(),style:{position:"absolute",left:X,top:q,width:ye,background:m.bgWhite,borderRadius:N.lg,boxShadow:ee.far,padding:b.md,display:"flex",flexDirection:"column",gap:b.sm},children:[f.jsxs("div",{style:{fontFamily:wt,fontSize:G.xs,color:m.sub,lineHeight:1.5},children:[o.elements.slice(0,3).map(g=>`<${g.tag}>${g.text?` ${g.text.slice(0,14)}`:""}`).join("、"),o.elements.length>3?` 等 ${o.elements.length} 个`:""]}),f.jsx("textarea",{value:u,autoFocus:!0,onChange:g=>p(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.metaKey||g.ctrlKey)&&(g.preventDefault(),K())},placeholder:"这一块想说什么…(可以不写,框本身就是话)",style:{width:"100%",boxSizing:"border-box",minHeight:64,resize:"vertical",fontFamily:wt,fontSize:G.sm,color:m.text,lineHeight:1.6,border:`1px solid ${m.borderLt}`,borderRadius:N.md,padding:b.sm,outline:"none",background:m.bg}}),f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:b.sm},children:[f.jsxs("button",{onClick:K,disabled:c,style:{display:"inline-flex",alignItems:"center",gap:b.xs,padding:`5px ${b.lg}px`,borderRadius:N.pill,border:"none",background:m.btn,color:m.btnText,fontFamily:wt,fontSize:G.sm,fontWeight:600,cursor:c?"default":"pointer",opacity:c?.7:1},children:[c?f.jsxs(f.Fragment,{children:[f.jsx(Qe,{size:12,style:{animation:"spin 1s linear infinite"}})," 截图中…"]}):f.jsxs(f.Fragment,{children:[f.jsx(We,{size:12})," 发给 agent"]}),f.jsx("style",{children:"@keyframes spin{to{transform:rotate(360deg)}}"})]}),f.jsxs("button",{onClick:L,style:{display:"inline-flex",alignItems:"center",gap:b.xs,padding:`5px ${b.md}px`,borderRadius:N.pill,border:`1px solid ${m.borderLt}`,background:"transparent",color:m.sub,fontFamily:wt,fontSize:G.xs,cursor:"pointer"},children:[f.jsx(ne,{size:11})," 重画"]}),f.jsx("span",{style:{marginLeft:"auto",fontFamily:rt,fontSize:G.xxs,color:m.dim},children:"⌘↵"})]})]})]})}const me="__nodesignBridgeState";function Ke(t){return t[me]||(t[me]={})}function Qr(t,{onTextEdit:e,onSelect:n}={}){const r=Ge(t);if(!r)return;yn(t);const i=Ke(t),s=o=>{const l=o.target;if(!l||l.nodeType!==1||!vn(l)||pt(l))return;o.preventDefault(),o.stopPropagation(),l.setAttribute("contenteditable","true"),l.style.outline="2px solid #2d2418",l.style.outlineOffset="4px",l.focus();const u=r.createRange();u.selectNodeContents(l);const p=r.getSelection();p==null||p.removeAllRanges(),p==null||p.addRange(u);const c=l.textContent,W=()=>{l.removeEventListener("blur",O),l.removeEventListener("keydown",k),l.removeAttribute("contenteditable"),l.style.outline="",l.style.outlineOffset=""},O=()=>{const L=l.textContent;W(),L!==c&&(e==null||e({anchor:Zt(l),oldText:c,newText:L}))},k=L=>{if(L.key==="Escape")l.textContent=c,l.blur();else if(L.key==="Enter"&&!L.shiftKey){if(re(L))return;L.preventDefault(),l.blur()}};l.addEventListener("blur",O),l.addEventListener("keydown",k)},a=o=>{var u,p;if(((p=(u=o.target).getAttribute)==null?void 0:p.call(u,"contenteditable"))==="true")return;const l=o.target;if(!(!l||l.nodeType!==1)){if(l===r.body||l===r.documentElement){n==null||n({anchor:null});return}n==null||n({anchor:Zt(l)})}};r.addEventListener("dblclick",s,!0),r.addEventListener("click",a,!0),i.handleDblClick=s,i.handleClick=a,i.mode="edit"}function yn(t){const e=Ge(t);if(!e)return;const n=Ke(t);n.handleDblClick&&e.removeEventListener("dblclick",n.handleDblClick,!0),n.handleClick&&e.removeEventListener("click",n.handleClick,!0),e.querySelectorAll('[contenteditable="true"]').forEach(i=>{i.removeAttribute("contenteditable"),i.style.outline="",i.style.outlineOffset=""}),n.handleDblClick=null,n.handleClick=null,n.mode=null}function Ge(t){var e;try{return(t==null?void 0:t.contentDocument)||((e=t==null?void 0:t.contentWindow)==null?void 0:e.document)||null}catch{return null}}function vn(t){return!t||t.nodeType!==1||t.querySelector(":scope > div, :scope > section, :scope > article, :scope > main, :scope > header, :scope > footer, :scope > nav, :scope > ul, :scope > ol")?!1:["H1","H2","H3","H4","H5","H6","P","SPAN","LI","DIV","A","STRONG","EM","SMALL","LABEL","BUTTON"].includes(t.tagName)}function pt(t){let e=t;for(;e&&e.nodeType===1;){if(e.hasAttribute&&e.hasAttribute("data-react-mount"))return!0;if(e.tagName==="SECTION"&&e.hasAttribute("data-page")||e.tagName==="BODY"||e.tagName==="HTML")return!1;e=e.parentNode}return!1}function to({selectedAnchor:t,iframeRef:e,zoom:n=1}){const[,r]=d.useState(0);if(d.useEffect(()=>{if(!t)return;const T=e==null?void 0:e.current;if(!T)return;const I=T.contentWindow;if(!I)return;let j=null;const C=()=>{j||(j=requestAnimationFrame(()=>{j=null,r(x=>x+1)}))};try{I.addEventListener("scroll",C,{passive:!0,capture:!0}),I.addEventListener("resize",C),window.addEventListener("resize",C)}catch{}return()=>{try{I.removeEventListener("scroll",C,{capture:!0}),I.removeEventListener("resize",C),window.removeEventListener("resize",C)}catch{}j&&cancelAnimationFrame(j)}},[t,e]),!t||!(e!=null&&e.current))return null;const i=e.current,s=i.contentDocument;if(!s)return null;const a=oe(t,s.body);if(!a)return null;const o=a.getBoundingClientRect(),l=i.getBoundingClientRect(),u=i.contentWindow,p=(u==null?void 0:u.innerWidth)??l.width/n,c=(u==null?void 0:u.innerHeight)??l.height/n;if(o.bottom<=0||o.top>=c||o.right<=0||o.left>=p)return null;const W=Ct(i);if(!W)return null;const{top:O,left:k}=Be(W,o.left,o.top,n),L=o.width*n,A=o.height*n;return f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:O-4,left:k-4,width:L+8,height:A+8,border:`2px solid ${m.btn}`,borderRadius:N.sm,boxShadow:"0 0 0 4px rgba(45, 36, 24, 0.08)",zIndex:10}})}function we(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function mn(t){if(Array.isArray(t))return t}function wn(t,e,n){return(e=On(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sn(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,s,a,o=[],l=!0,u=!1;try{if(s=(n=n.call(t)).next,e!==0)for(;!(l=(r=s.call(n)).done)&&(o.push(r.value),o.length!==e);l=!0);}catch(p){u=!0,i=p}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return o}}function Mn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
12
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Se(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Me(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Se(Object(n),!0).forEach(function(r){wn(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Se(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function En(t,e){if(t==null)return{};var n,r,i=Ln(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Ln(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function jn(t,e){return mn(t)||Sn(t,e)||kn(t,e)||Mn()}function Cn(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function On(t){var e=Cn(t,"string");return typeof e=="symbol"?e:e+""}function kn(t,e){if(t){if(typeof t=="string")return we(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?we(t,e):void 0}}function Tn(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ee(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Le(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ee(Object(n),!0).forEach(function(r){Tn(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ee(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function In(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return function(r){return e.reduceRight(function(i,s){return s(i)},r)}}function Pt(t){return function e(){for(var n=this,r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];return i.length>=t.length?t.apply(this,i):function(){for(var a=arguments.length,o=new Array(a),l=0;l<a;l++)o[l]=arguments[l];return e.apply(n,[].concat(i,o))}}}function Vt(t){return{}.toString.call(t).includes("Object")}function An(t){return!Object.keys(t).length}function Ht(t){return typeof t=="function"}function zn(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function $n(t,e){return Vt(e)||St("changeType"),Object.keys(e).some(function(n){return!zn(t,n)})&&St("changeField"),e}function Dn(t){Ht(t)||St("selectorType")}function Pn(t){Ht(t)||Vt(t)||St("handlerType"),Vt(t)&&Object.values(t).some(function(e){return!Ht(e)})&&St("handlersType")}function Fn(t){t||St("initialIsRequired"),Vt(t)||St("initialType"),An(t)&&St("initialContent")}function Hn(t,e){throw new Error(t[e]||t.default)}var Nn={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},St=Pt(Hn)(Nn),Kt={changes:$n,selector:Dn,handler:Pn,initial:Fn};function Wn(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Kt.initial(t),Kt.handler(e);var n={current:t},r=Pt(Kn)(n,e),i=Pt(Rn)(n),s=Pt(Kt.changes)(t),a=Pt(Bn)(n);function o(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(p){return p};return Kt.selector(u),u(n.current)}function l(u){In(r,i,s,a)(u)}return[o,l]}function Bn(t,e){return Ht(e)?e(t.current):e}function Rn(t,e){return t.current=Le(Le({},t.current),e),e}function Kn(t,e,n){return Ht(e)?e(t.current):Object.keys(n).forEach(function(r){var i;return(i=e[r])===null||i===void 0?void 0:i.call(e,t.current[r])}),n}var Gn={create:Wn},_n={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Vn(t){return function e(){for(var n=this,r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];return i.length>=t.length?t.apply(this,i):function(){for(var a=arguments.length,o=new Array(a),l=0;l<a;l++)o[l]=arguments[l];return e.apply(n,[].concat(i,o))}}}function Xn(t){return{}.toString.call(t).includes("Object")}function Yn(t){return t||je("configIsRequired"),Xn(t)||je("configType"),t.urls?(qn(),{paths:{vs:t.urls.monacoBase}}):t}function qn(){console.warn(_e.deprecation)}function Un(t,e){throw new Error(t[e]||t.default)}var _e={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
13
13
  You are using deprecated way of configuration.
14
14
 
15
15
  Instead of using
@@ -18,14 +18,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
18
18
  monaco.config({ paths: { vs: '...' } })
19
19
 
20
20
  For more please check the link https://github.com/suren-atoyan/monaco-loader#config
21
- `},je=Vn(Un)(_e),Zn={config:Yn},Jn=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return function(i){return n.reduceRight(function(s,a){return a(s)},i)}};function Ve(t,e){return Object.keys(e).forEach(function(n){e[n]instanceof Object&&t[n]&&Object.assign(e[n],Ve(t[n],e[n]))}),Me(Me({},t),e)}var Qn={type:"cancelation",msg:"operation is manually canceled"};function Yt(t){var e=!1,n=new Promise(function(r,i){t.then(function(s){return e?i(Qn):r(s)}),t.catch(i)});return n.cancel=function(){return e=!0},n}var tr=["monaco"],er=Gn.create({config:_n,isInitialized:!1,resolve:null,reject:null,monaco:null}),Xe=jn(er,2),Nt=Xe[0],Xt=Xe[1];function nr(t){var e=Zn.config(t),n=e.monaco,r=En(e,tr);Xt(function(i){return{config:Ve(i.config,r),monaco:n}})}function rr(){var t=Nt(function(e){var n=e.monaco,r=e.isInitialized,i=e.resolve;return{monaco:n,isInitialized:r,resolve:i}});if(!t.isInitialized){if(Xt({isInitialized:!0}),t.monaco)return t.resolve(t.monaco),Yt(qt);if(window.monaco&&window.monaco.editor)return Ye(window.monaco),t.resolve(window.monaco),Yt(qt);Jn(or,sr)(lr)}return Yt(qt)}function or(t){return document.body.appendChild(t)}function ir(t){var e=document.createElement("script");return t&&(e.src=t),e}function sr(t){var e=Nt(function(r){var i=r.config,s=r.reject;return{config:i,reject:s}}),n=ir("".concat(e.config.paths.vs,"/loader.js"));return n.onload=function(){return t()},n.onerror=e.reject,n}function lr(){var t=Nt(function(n){var r=n.config,i=n.resolve,s=n.reject;return{config:r,resolve:i,reject:s}}),e=window.require;e.config(t.config),e(["vs/editor/editor.main"],function(n){var r=n.m||n;Ye(r),t.resolve(r)},function(n){t.reject(n)})}function Ye(t){Nt().monaco||Xt({monaco:t})}function ar(){return Nt(function(t){var e=t.monaco;return e})}var qt=new Promise(function(t,e){return Xt({resolve:t,reject:e})}),qe={config:nr,init:rr,__getMonacoInstance:ar},cr={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Ut=cr,ur={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},dr=ur;function fr({children:t}){return Tt.createElement("div",{style:dr.container},t)}var pr=fr,hr=pr;function gr({width:t,height:e,isEditorReady:n,loading:r,_ref:i,className:s,wrapperProps:a}){return Tt.createElement("section",{style:{...Ut.wrapper,width:t,height:e},...a},!n&&Tt.createElement(hr,null,r),Tt.createElement("div",{ref:i,style:{...Ut.fullWidth,...!n&&Ut.hide},className:s}))}var br=gr,Ue=d.memo(br);function xr(t){d.useEffect(t,[])}var Ze=xr;function yr(t,e,n=!0){let r=d.useRef(!0);d.useEffect(r.current||!n?()=>{r.current=!1}:t,e)}var ct=yr;function Ft(){}function Ot(t,e,n,r){return vr(t,r)||mr(t,e,n,r)}function vr(t,e){return t.editor.getModel(Je(t,e))}function mr(t,e,n,r){return t.editor.createModel(e,n,r?Je(t,r):void 0)}function Je(t,e){return t.Uri.parse(e)}function wr({original:t,modified:e,language:n,originalLanguage:r,modifiedLanguage:i,originalModelPath:s,modifiedModelPath:a,keepCurrentOriginalModel:o=!1,keepCurrentModifiedModel:l=!1,theme:u="light",loading:p="Loading...",options:c={},height:W="100%",width:k="100%",className:O,wrapperProps:L={},beforeMount:A=Ft,onMount:T=Ft}){let[I,j]=d.useState(!1),[C,x]=d.useState(!0),y=d.useRef(null),S=d.useRef(null),J=d.useRef(null),K=d.useRef(T),z=d.useRef(A),R=d.useRef(!1);Ze(()=>{let h=qe.init();return h.then(D=>(S.current=D)&&x(!1)).catch(D=>(D==null?void 0:D.type)!=="cancelation"&&console.error("Monaco initialization: error:",D)),()=>y.current?g():h.cancel()}),ct(()=>{if(y.current&&S.current){let h=y.current.getOriginalEditor(),D=Ot(S.current,t||"",r||n||"text",s||"");D!==h.getModel()&&h.setModel(D)}},[s],I),ct(()=>{if(y.current&&S.current){let h=y.current.getModifiedEditor(),D=Ot(S.current,e||"",i||n||"text",a||"");D!==h.getModel()&&h.setModel(D)}},[a],I),ct(()=>{let h=y.current.getModifiedEditor();h.getOption(S.current.editor.EditorOption.readOnly)?h.setValue(e||""):e!==h.getValue()&&(h.executeEdits("",[{range:h.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),h.pushUndoStop())},[e],I),ct(()=>{var h,D;(D=(h=y.current)==null?void 0:h.getModel())==null||D.original.setValue(t||"")},[t],I),ct(()=>{let{original:h,modified:D}=y.current.getModel();S.current.editor.setModelLanguage(h,r||n||"text"),S.current.editor.setModelLanguage(D,i||n||"text")},[n,r,i],I),ct(()=>{var h;(h=S.current)==null||h.editor.setTheme(u)},[u],I),ct(()=>{var h;(h=y.current)==null||h.updateOptions(c)},[c],I);let q=d.useCallback(()=>{var U;if(!S.current)return;z.current(S.current);let h=Ot(S.current,t||"",r||n||"text",s||""),D=Ot(S.current,e||"",i||n||"text",a||"");(U=y.current)==null||U.setModel({original:h,modified:D})},[n,e,i,t,r,s,a]),X=d.useCallback(()=>{var h;!R.current&&J.current&&(y.current=S.current.editor.createDiffEditor(J.current,{automaticLayout:!0,...c}),q(),(h=S.current)==null||h.editor.setTheme(u),j(!0),R.current=!0)},[c,u,q]);d.useEffect(()=>{I&&K.current(y.current,S.current)},[I]),d.useEffect(()=>{!C&&!I&&X()},[C,I,X]);function g(){var D,U,Y,ot;let h=(D=y.current)==null?void 0:D.getModel();o||((U=h==null?void 0:h.original)==null||U.dispose()),l||((Y=h==null?void 0:h.modified)==null||Y.dispose()),(ot=y.current)==null||ot.dispose()}return Tt.createElement(Ue,{width:k,height:W,isEditorReady:I,loading:p,_ref:J,className:O,wrapperProps:L})}var Sr=wr;d.memo(Sr);function Mr(t){let e=d.useRef();return d.useEffect(()=>{e.current=t},[t]),e.current}var Er=Mr,Gt=new Map;function Lr({defaultValue:t,defaultLanguage:e,defaultPath:n,value:r,language:i,path:s,theme:a="light",line:o,loading:l="Loading...",options:u={},overrideServices:p={},saveViewState:c=!0,keepCurrentModel:W=!1,width:k="100%",height:O="100%",className:L,wrapperProps:A={},beforeMount:T=Ft,onMount:I=Ft,onChange:j,onValidate:C=Ft}){let[x,y]=d.useState(!1),[S,J]=d.useState(!0),K=d.useRef(null),z=d.useRef(null),R=d.useRef(null),q=d.useRef(I),X=d.useRef(T),g=d.useRef(),h=d.useRef(r),D=Er(s),U=d.useRef(!1),Y=d.useRef(!1);Ze(()=>{let v=qe.init();return v.then(M=>(K.current=M)&&J(!1)).catch(M=>(M==null?void 0:M.type)!=="cancelation"&&console.error("Monaco initialization: error:",M)),()=>z.current?$():v.cancel()}),ct(()=>{var M,F,Q,Z;let v=Ot(K.current,t||r||"",e||i||"",s||n||"");v!==((M=z.current)==null?void 0:M.getModel())&&(c&&Gt.set(D,(F=z.current)==null?void 0:F.saveViewState()),(Q=z.current)==null||Q.setModel(v),c&&((Z=z.current)==null||Z.restoreViewState(Gt.get(s))))},[s],x),ct(()=>{var v;(v=z.current)==null||v.updateOptions(u)},[u],x),ct(()=>{!z.current||r===void 0||(z.current.getOption(K.current.editor.EditorOption.readOnly)?z.current.setValue(r):r!==z.current.getValue()&&(Y.current=!0,z.current.executeEdits("",[{range:z.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),z.current.pushUndoStop(),Y.current=!1))},[r],x),ct(()=>{var M,F;let v=(M=z.current)==null?void 0:M.getModel();v&&i&&((F=K.current)==null||F.editor.setModelLanguage(v,i))},[i],x),ct(()=>{var v;o!==void 0&&((v=z.current)==null||v.revealLine(o))},[o],x),ct(()=>{var v;(v=K.current)==null||v.editor.setTheme(a)},[a],x);let ot=d.useCallback(()=>{var v;if(!(!R.current||!K.current)&&!U.current){X.current(K.current);let M=s||n,F=Ot(K.current,r||t||"",e||i||"",M||"");z.current=(v=K.current)==null?void 0:v.editor.create(R.current,{model:F,automaticLayout:!0,...u},p),c&&z.current.restoreViewState(Gt.get(M)),K.current.editor.setTheme(a),o!==void 0&&z.current.revealLine(o),y(!0),U.current=!0}},[t,e,n,r,i,s,u,p,c,a,o]);d.useEffect(()=>{x&&q.current(z.current,K.current)},[x]),d.useEffect(()=>{!S&&!x&&ot()},[S,x,ot]),h.current=r,d.useEffect(()=>{var v,M;x&&j&&((v=g.current)==null||v.dispose(),g.current=(M=z.current)==null?void 0:M.onDidChangeModelContent(F=>{Y.current||j(z.current.getValue(),F)}))},[x,j]),d.useEffect(()=>{if(x){let v=K.current.editor.onDidChangeMarkers(M=>{var Q;let F=(Q=z.current.getModel())==null?void 0:Q.uri;if(F&&M.find(Z=>Z.path===F.path)){let Z=K.current.editor.getModelMarkers({resource:F});C==null||C(Z)}});return()=>{v==null||v.dispose()}}return()=>{}},[x,C]);function $(){var v,M;(v=g.current)==null||v.dispose(),W?c&&Gt.set(s,z.current.saveViewState()):(M=z.current.getModel())==null||M.dispose(),z.current.dispose()}return Tt.createElement(Ue,{width:k,height:O,isEditorReady:x,loading:l,_ref:R,className:L,wrapperProps:A})}var jr=Lr,Cr=d.memo(jr),kr=Cr;function eo({value:t="",onChange:e,readOnly:n=!1}){const[r,i]=d.useState(t),s=r!==t;d.useEffect(()=>{s||i(t)},[t]),d.useEffect(()=>{if(!s)return;const o=setTimeout(()=>e==null?void 0:e(r),800);return()=>clearTimeout(o)},[r,s,e]);const a=()=>{s&&(e==null||e(r))};return f.jsxs("div",{style:{flex:1,minHeight:0,position:"relative",background:m.bgCard,display:"flex",flexDirection:"column"},children:[f.jsxs("div",{style:{flexShrink:0,padding:`${b.sm}px ${b.lg}px`,background:"rgba(0,0,0,0.04)",borderBottom:`1px solid ${m.borderLt}`,fontFamily:rt,fontSize:G.xs,color:m.sub,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[f.jsxs("span",{children:["deck.html",s&&f.jsx("span",{style:{color:m.warn,marginLeft:b.sm},children:"· 已修改"})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:b.sm},children:[s&&f.jsxs("button",{onClick:a,style:{display:"inline-flex",alignItems:"center",gap:b.xs,padding:`${b.xxs}px ${b.md}px`,fontFamily:wt,fontSize:G.sm,fontWeight:500,color:m.btnText,background:m.btn,border:"none",borderRadius:N.sm,cursor:"pointer"},children:[f.jsx(tn,{size:10})," 应用"]}),f.jsx("span",{style:{fontSize:G.xs},children:n?"只读":"改完会同步到 Edit / Preview"})]})]}),f.jsx("div",{style:{flex:1,minHeight:0},children:f.jsx(kr,{defaultLanguage:"html",value:r,onChange:o=>i(o??""),theme:"light",options:{readOnly:n,minimap:{enabled:!1},fontSize:12,fontFamily:"'SF Mono', 'Cascadia Code', 'Menlo', monospace",lineNumbers:"on",renderLineHighlight:"none",scrollBeyondLastLine:!1,wordWrap:"on",tabSize:2},loading:f.jsx("div",{style:{padding:b.xl,fontFamily:rt,fontSize:G.sm,color:m.sub},children:"Monaco 加载中…"})})})]})}const Ce=340,Or=8,ke=520;function no({selectedAnchor:t,redactText:e=void 0,iframeDoc:n,iframeRef:r,iframeRect:i,zoom:s=1,comments:a=[],onClose:o,onAddComment:l,onResolveComment:u,onDeleteComment:p}){var D,U,Y,ot;const c=d.useRef(null),[,W]=d.useState(0),[k,O]=d.useState(""),[L,A]=d.useState(0);d.useEffect(()=>{if(!t||!(r!=null&&r.current))return;const v=r.current.contentWindow;if(!v)return;let M=null;const F=()=>{M||(M=requestAnimationFrame(()=>{M=null,W(Q=>Q+1)}))};try{v.addEventListener("scroll",F,{passive:!0,capture:!0}),v.addEventListener("resize",F),window.addEventListener("resize",F)}catch{}return()=>{try{v.removeEventListener("scroll",F,{capture:!0}),v.removeEventListener("resize",F),window.removeEventListener("resize",F)}catch{}M&&cancelAnimationFrame(M)}},[t,r]),d.useEffect(()=>{if(!c.current)return;const $=new ResizeObserver(()=>{var M;const v=((M=c.current)==null?void 0:M.offsetHeight)||0;A(F=>F!==v?v:F)});return $.observe(c.current),()=>$.disconnect()},[t]);const T=d.useMemo(()=>t&&n?oe(t,n.body):null,[t,n]),I=d.useMemo(()=>t?a.filter($=>{var v,M;return t.dataId&&((v=$.anchor)!=null&&v.dataId)?$.anchor.dataId===t.dataId:((M=$.anchor)==null?void 0:M.path)===t.path}):[],[a,t]),j=d.useCallback(()=>{const $=k.trim();if(!$||!T)return;const v=en(T,{redactText:e});l==null||l({anchor:e?nn(t):t,scope:"this",aiContext:v,text:$}),O("")},[k,T,t,l,e]),C=$=>{if($.key==="Enter"&&!$.shiftKey){if(re($))return;$.preventDefault(),j()}},x=d.useCallback(()=>{if(T)try{T.scrollIntoView({behavior:"smooth",block:"center"})}catch{}},[T]);if(!t||!T||!i||i.width===0)return null;const y=T.getBoundingClientRect(),S=((U=(D=r==null?void 0:r.current)==null?void 0:D.contentWindow)==null?void 0:U.innerWidth)??i.width/s,J=((ot=(Y=r==null?void 0:r.current)==null?void 0:Y.contentWindow)==null?void 0:ot.innerHeight)??i.height/s,K=y.bottom<=0||y.top>=J||y.right<=0||y.left>=S,z=Ct(r==null?void 0:r.current)||{x:0,y:0,iframeRect:i},{left:R,top:q}=Re(z,y,s,{cardWidth:Ce,cardHeight:L||ke,offset:Or}),X=rn(T),g=on(T),h=T.tagName.toLowerCase();return f.jsxs("div",{ref:c,style:{position:"absolute",left:R,top:q,width:Ce,maxHeight:ke,background:m.bgWhite,borderRadius:2,boxShadow:"0 2px 4px rgba(0,0,0,0.04), 0 8px 20px rgba(0,0,0,0.08), 0 24px 48px rgba(0,0,0,0.10), inset 0 1px 0 rgba(255,255,255,0.8)",zIndex:50,display:"flex",flexDirection:"column",overflow:"hidden"},onMouseDown:$=>$.stopPropagation(),children:[f.jsxs("div",{style:{padding:`${b.md}px ${b.lg}px`,display:"flex",alignItems:"center",gap:b.sm,borderBottom:`1px solid ${m.borderLt}`,flexShrink:0,background:"rgba(255,255,255,0.95)"},children:[f.jsxs("span",{style:{fontFamily:rt,fontSize:G.xs,color:m.text4,background:"rgba(0,0,0,0.05)",padding:`1px ${b.sm}px`,borderRadius:N.xs},children:["<",h,">"]}),f.jsxs("span",{style:{fontFamily:wt,fontSize:G.sm,fontWeight:500,color:m.text,flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[(g==null?void 0:g.index)!==void 0&&g.index!==null&&`第 ${g.index} 页 · `,X]}),K&&f.jsx("button",{onClick:x,title:"滚动到该元素",style:{padding:b.xs,color:m.text4,borderRadius:N.xs,background:"rgba(0,0,0,0.04)"},children:f.jsx(an,{size:11})}),f.jsx("button",{onClick:o,title:"关闭(ESC)",style:{padding:b.xs,color:m.text5,borderRadius:N.xs},children:f.jsx(ne,{size:12})})]}),f.jsx("div",{style:{flex:1,minHeight:0,overflowY:"auto"},children:f.jsxs("div",{style:{padding:`${b.md}px ${b.lg}px`,borderBottom:`1px solid ${m.borderLt}`,background:"rgba(0,0,0,0.015)"},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:b.xs,fontFamily:rt,fontSize:G.xs,color:m.sub,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:b.sm},children:[f.jsx(cn,{size:10}),"评论 ",I.length>0&&`(${I.length})`]}),I.length>0&&f.jsx("div",{style:{display:"flex",flexDirection:"column",gap:b.xs,marginBottom:b.sm},children:I.map($=>f.jsx(Tr,{comment:$,onResolve:()=>u==null?void 0:u($.id),onDelete:()=>p==null?void 0:p($.id)},$.id))}),f.jsx("textarea",{value:k,onChange:$=>O($.target.value),onKeyDown:C,placeholder:"评论这个元素,让 AI 看看…(Enter 提交,Shift+Enter 换行)",rows:2,style:{width:"100%",padding:`${b.sm}px ${b.md}px`,fontFamily:wt,fontSize:G.sm,color:m.text2,background:m.bgWhite,boxShadow:ee.far,borderRadius:N.sm,resize:"vertical",boxSizing:"border-box",outline:"none"},onFocus:$=>{$.currentTarget.style.borderColor=m.btn},onBlur:$=>{$.currentTarget.style.borderColor=m.borderLt}})]})})]})}function Tr({comment:t,onResolve:e,onDelete:n}){const r=t.status==="resolved";return f.jsxs("div",{style:{padding:`${b.xs}px ${b.sm}px`,background:m.bgWhite,boxShadow:ee.far,borderRadius:N.sm,display:"flex",flexDirection:"column",gap:b.xs,opacity:r?.5:1},children:[f.jsx("div",{style:{fontFamily:wt,fontSize:G.xs,color:m.text2,lineHeight:1.5,textDecoration:r?"line-through":"none",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t.text}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:b.xs},children:[f.jsx("button",{onClick:e,title:r?"取消解决":"标记解决",style:{padding:b.xxs,color:m.sub,borderRadius:N.xs},children:f.jsx(sn,{size:10})}),f.jsx("button",{onClick:n,title:"删除",style:{padding:b.xxs,color:m.sub,borderRadius:N.xs},children:f.jsx(ln,{size:10})})]})]})}function ro({comments:t=[],iframeRef:e,zoom:n=1,onSelectAnchor:r}){const[,i]=d.useState(0);d.useEffect(()=>{if(t.length===0)return;const k=e==null?void 0:e.current;if(!k)return;const O=k.contentWindow;if(!O)return;let L=null;const A=()=>{L||(L=requestAnimationFrame(()=>{L=null,i(T=>T+1)}))};try{O.addEventListener("scroll",A,{passive:!0,capture:!0}),O.addEventListener("resize",A),window.addEventListener("resize",A)}catch{}return()=>{try{O.removeEventListener("scroll",A,{capture:!0}),O.removeEventListener("resize",A),window.removeEventListener("resize",A)}catch{}L&&cancelAnimationFrame(L)}},[t.length,e]);const s=d.useMemo(()=>{const k=new Map;for(const O of t){if(O.status==="resolved"||!O.anchor)continue;const L=O.anchor.dataId||O.anchor.path;L&&(k.has(L)||k.set(L,{anchor:O.anchor,items:[]}),k.get(L).items.push(O))}return[...k.values()]},[t]);if(s.length===0||!(e!=null&&e.current))return null;const a=e.current,o=a.contentDocument;if(!o)return null;const l=a.getBoundingClientRect(),u=Ct(a);if(!u)return null;const p=a.contentWindow,c=(p==null?void 0:p.innerWidth)??l.width/n,W=(p==null?void 0:p.innerHeight)??l.height/n;return f.jsx(f.Fragment,{children:s.map((k,O)=>{var J;const L=oe(k.anchor,o.body);if(!L)return null;const A=L.getBoundingClientRect();if(A.bottom<=0||A.top>=W||A.right<=0||A.left>=c)return null;const{top:T,left:I}=Be(u,A.left,A.top,n),j=A.width*n,C=A.height*n,x=k.items.length,y=((J=k.items[0])==null?void 0:J.text)||"",S=y.length>28?y.slice(0,28)+"…":y;return f.jsxs("div",{style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:T-3,left:I-3,width:j+6,height:C+6,border:`2px solid ${Oe}`,borderRadius:N.sm,boxShadow:`0 0 0 3px ${Ir}`,zIndex:9}}),f.jsx("button",{onClick:()=>r==null?void 0:r(k.anchor),title:x>1?`${x} 条评论 — 点击查看`:`已评论:${y}`,style:{position:"absolute",pointerEvents:"auto",top:T-12,left:I+j-8,transform:"translateX(-100%)",padding:`${b.xxs}px ${b.sm}px`,fontFamily:rt,fontSize:G.xs,lineHeight:"14px",fontWeight:500,color:m.bgWhite,background:Oe,border:"none",borderRadius:N.xs,whiteSpace:"nowrap",cursor:"pointer",boxShadow:Qt.crisp,zIndex:11,maxWidth:Math.max(60,j),overflow:"hidden",textOverflow:"ellipsis"},children:x>1?`已评论 ${x}`:S||"已评论"})]},O)})})}const Oe=gt.orange,Ir="rgba(230, 126, 34, 0.18)";function Ar(t,e,n){var a;if(!t||!n)return null;const r=n.ownerDocument.defaultView;let i=t,s=0;for(;i&&i.nodeType===1&&i!==n&&i!==n.ownerDocument.documentElement;){if(e&&(i===e||e.contains(i))){i=i.parentElement,s++;continue}if(i.children&&i.children.length>=1){const o=(a=r==null?void 0:r.getComputedStyle)==null?void 0:a.call(r,i),l=(o==null?void 0:o.display)||"block",u=l==="block"||l==="flex"||l==="grid"||l==="inline-block"||l==="inline-flex"||l==="inline-grid"||l==="list-item"||l==="table"||l==="table-cell",p=!["A","BUTTON","LABEL","SPAN","CODE","STRONG","EM","I"].includes(i.tagName);if(u&&p)return{container:i,depth:s}}i=i.parentElement,s++}return n.children&&n.children.length>0?{container:n,depth:s}:null}function zr(t){if(!t||t.nodeType!==1||["A","BUTTON","LABEL","SPAN","CODE","STRONG","EM","I","IMG","SVG"].includes(t.tagName))return!1;const e=t.ownerDocument.defaultView;if(!e)return!1;const r=e.getComputedStyle(t).display;return r==="block"||r==="flex"||r==="grid"||r==="inline-block"||r==="inline-flex"||r==="inline-grid"||r==="list-item"||r==="table"||r==="table-cell"}function $r(t,e,n){if(!e||!t)return null;let r=e;for(;r&&r!==t;){if(n&&(r===n||n.contains(r)))return null;if(r.parentElement===t)return r;r=r.parentElement}return null}function Dr(t,e){const n=Array.from(t.children).filter(u=>u!==e&&u.nodeType===1);if(n.length<2){const u=t.ownerDocument.defaultView,p=u?u.getComputedStyle(t):null;return p&&(p.display==="flex"||p.display==="inline-flex")?(p.flexDirection||"row").startsWith("row"):!1}const r=n[0].getBoundingClientRect(),i=n[1].getBoundingClientRect(),s=!(r.right<=i.left||i.right<=r.left),a=!(r.bottom<=i.top||i.bottom<=r.top);if(!s&&a)return!0;if(s&&!a)return!1;const o=t.ownerDocument.defaultView,l=o?o.getComputedStyle(t):null;return l&&(l.display==="flex"||l.display==="inline-flex")?(l.flexDirection||"row").startsWith("row"):!1}function Pr(t,e,n,r){if(!t)return null;const i=Dr(t,n),s=$r(t,e,n);if(s&&s!==n){const o=s.getBoundingClientRect();let l,u;i?(l=(r.x-o.left)/o.width,u=o.width):(l=(r.y-o.top)/o.height,u=o.height),l=Math.max(0,Math.min(1,l));const p=u>=60&&zr(s),c=p?.25:.5,W=p?.75:.5;return l<c?{intent:"sibling-before",targetContainer:t,beforeEl:s,hitChild:s,caretRect:i?{x:o.left-1,y:o.top,w:2,h:o.height,vertical:!0}:{x:o.left,y:o.top-1,w:o.width,h:2,vertical:!1},zoneRect:null,horizontal:i}:l>=W?{intent:"sibling-after",targetContainer:t,beforeEl:s.nextElementSibling||null,hitChild:s,caretRect:i?{x:o.right-1,y:o.top,w:2,h:o.height,vertical:!0}:{x:o.left,y:o.bottom-1,w:o.width,h:2,vertical:!1},zoneRect:null,horizontal:i}:{intent:"child-of",targetContainer:s,beforeEl:null,hitChild:s,caretRect:null,zoneRect:{x:o.left,y:o.top,w:o.width,h:o.height},horizontal:i}}const a=Fr(t,n,r);return a?{intent:a.before?"sibling-before":"sibling-after",targetContainer:t,beforeEl:a.before,hitChild:null,caretRect:a.caretRect,zoneRect:null,horizontal:i}:null}function Fr(t,e,n){if(!t)return null;const r=Array.from(t.children).filter(a=>a!==e&&a.nodeType===1);if(r.length===0){const a=t.getBoundingClientRect();return{before:null,caretRect:{x:a.left+4,y:a.top+4,w:Math.max(2,a.width-8),h:2,vertical:!1}}}let i=!1;if(r.length>=2){const a=r[0].getBoundingClientRect(),o=r[1].getBoundingClientRect(),l=!(a.right<=o.left||o.right<=a.left),u=!(a.bottom<=o.top||o.bottom<=a.top);if(!l&&u)i=!0;else if(l&&!u)i=!1;else{const p=t.ownerDocument.defaultView.getComputedStyle(t),c=p.flexDirection||"row";i=(p.display==="flex"||p.display==="inline-flex")&&(c==="row"||c==="row-reverse")}}else{const a=r[0].getBoundingClientRect(),o=Math.abs(n.x-(a.left+a.width/2)),l=Math.abs(n.y-(a.top+a.height/2));i=o>l}for(let a=0;a<r.length;a++){const o=r[a].getBoundingClientRect();if(i){const l=o.left+o.width/2;if(n.x<l)return{before:r[a],caretRect:{x:o.left-1,y:o.top,w:2,h:o.height,vertical:!0}}}else{const l=o.top+o.height/2;if(n.y<l)return{before:r[a],caretRect:{x:o.left,y:o.top-1,w:o.width,h:2,vertical:!1}}}}const s=r[r.length-1].getBoundingClientRect();return i?{before:null,caretRect:{x:s.right-1,y:s.top,w:2,h:s.height,vertical:!0}}:{before:null,caretRect:{x:s.left,y:s.bottom-1,w:s.width,h:2,vertical:!1}}}const kt=5;function Te(t,e){const n=[];if(!t||!Array.isArray(e))return n;const r=t.left+t.width/2,i=t.top+t.height/2;for(const a of e){if(!a||!a.rect)continue;const o=a.rect,l=o.left+o.width/2,u=o.top+o.height/2;Math.abs(t.left-o.left)<=kt?n.push({axis:"x",value:o.left,hint:"edge-left",neighbor:a.el}):Math.abs(r-l)<=kt?n.push({axis:"x",value:l,hint:"center-x",neighbor:a.el}):Math.abs(t.right-o.right)<=kt&&n.push({axis:"x",value:o.right,hint:"edge-right",neighbor:a.el}),Math.abs(t.top-o.top)<=kt?n.push({axis:"y",value:o.top,hint:"edge-top",neighbor:a.el}):Math.abs(i-u)<=kt?n.push({axis:"y",value:u,hint:"center-y",neighbor:a.el}):Math.abs(t.bottom-o.bottom)<=kt&&n.push({axis:"y",value:o.bottom,hint:"edge-bottom",neighbor:a.el})}const s=new Set;return n.filter(a=>{const o=`${a.axis}:${Math.round(a.value)}`;return s.has(o)?!1:(s.add(o),!0)})}function Hr(t,e,n,r){return!t||!e?t:Math.abs(n)>=Math.abs(r)?{...t,top:e.top,bottom:e.top+t.height}:{...t,left:e.left,right:e.left+t.width}}function Nr(t,e,n=3){if(!t||!Array.isArray(e)||e.length===0)return t;let r=t.left,i=t.top;const s=t.left+t.width/2,a=t.top+t.height/2;for(const o of e)o.axis==="x"?o.hint==="edge-left"&&Math.abs(t.left-o.value)<=n?r=o.value:o.hint==="edge-right"&&Math.abs(t.right-o.value)<=n?r=o.value-t.width:o.hint==="center-x"&&Math.abs(s-o.value)<=n&&(r=o.value-t.width/2):o.axis==="y"&&(o.hint==="edge-top"&&Math.abs(t.top-o.value)<=n?i=o.value:o.hint==="edge-bottom"&&Math.abs(t.bottom-o.value)<=n?i=o.value-t.height:o.hint==="center-y"&&Math.abs(a-o.value)<=n&&(i=o.value-t.height/2));return{...t,left:r,top:i,right:r+t.width,bottom:i+t.height}}const Ie=4;function Wr(t,e){if(!t||!Array.isArray(e)||e.length<2)return[];const n=[],r=e.filter(s=>s.rect&&!(s.rect.bottom<t.top||s.rect.top>t.bottom));for(const s of r)for(const a of r){if(s===a||!s.rect||!a.rect||s.rect.right>=t.left||a.rect.left<=t.right)continue;const o=t.left-s.rect.right,l=a.rect.left-t.right;if(Math.abs(o-l)<=Ie){const u=(o+l)/2;n.push({side:"horizontal",gap:Math.round(u),snapTo:{left:s.rect.right+u},neighbors:[s.el,a.el]})}}const i=e.filter(s=>s.rect&&!(s.rect.right<t.left||s.rect.left>t.right));for(const s of i)for(const a of i){if(s===a||!s.rect||!a.rect||s.rect.bottom>=t.top||a.rect.top<=t.bottom)continue;const o=t.top-s.rect.bottom,l=a.rect.top-t.bottom;if(Math.abs(o-l)<=Ie){const u=(o+l)/2;n.push({side:"vertical",gap:Math.round(u),snapTo:{top:s.rect.bottom+u},neighbors:[s.el,a.el]})}}return n}function Ae(t,e){if(!t||!Array.isArray(e))return[];const n=[],r={top:{best:1/0,label:null},bottom:{best:1/0,label:null},left:{best:1/0,label:null},right:{best:1/0,label:null}};for(const i of e){if(!i||!i.rect)continue;const s=i.rect;if(!(s.right<t.left||s.left>t.right)){if(s.bottom<=t.top){const l=t.top-s.bottom;l<r.top.best&&(r.top.best=l,r.top.label={side:"top",gap:l,labelRect:{x:t.left+t.width/2-14,y:s.bottom+l/2-8,w:28,h:16}})}else if(s.top>=t.bottom){const l=s.top-t.bottom;l<r.bottom.best&&(r.bottom.best=l,r.bottom.label={side:"bottom",gap:l,labelRect:{x:t.left+t.width/2-14,y:t.bottom+l/2-8,w:28,h:16}})}}if(!(s.bottom<t.top||s.top>t.bottom)){if(s.right<=t.left){const l=t.left-s.right;l<r.left.best&&(r.left.best=l,r.left.label={side:"left",gap:l,labelRect:{x:s.right+l/2-14,y:t.top+t.height/2-8,w:28,h:16}})}else if(s.left>=t.right){const l=s.left-t.right;l<r.right.best&&(r.right.best=l,r.right.label={side:"right",gap:l,labelRect:{x:t.right+l/2-14,y:t.top+t.height/2-8,w:28,h:16}})}}}for(const i of Object.values(r))i.label&&i.label.gap>=0&&i.label.gap<200&&n.push(i.label);return n}function Zt(t,e,n="siblings"){if(!t)return[];const r=[],i=(a,o)=>{if(!(!a||o>2))for(const l of a.children)!l||l.nodeType!==1||e&&(l===e||e.contains(l))||(r.push({el:l,rect:l.getBoundingClientRect()}),n==="deep"&&o<2&&i(l,o+1))};i(t,0);const s=t.parentElement;if(s&&s!==t.ownerDocument.body)for(const a of s.children)a===t||a.nodeType!==1||e&&(a===e||e.contains(a))||r.push({el:a,rect:a.getBoundingClientRect()});return r}function ze({sourceEl:t,parentEl:e,left:n,top:r}){if(!t||!e)return null;It(t),It(e);const i=pt(t)||pt(e),s=e.ownerDocument.defaultView,a=s?s.getComputedStyle(e):null,o=a&&a.position==="static",l=t.getBoundingClientRect(),u=t.ownerDocument.defaultView,p=u?u.getComputedStyle(t):null,c={position:"absolute",left:`${n}px`,top:`${r}px`},W={width:`${Math.round(l.width)}px`,height:`${Math.round(l.height)}px`,margin:"0px",transform:"none"};return{sourceAnchor:jt(t),styleDelta:c,runtimeLocks:W,parentAnchor:jt(e),parentNeedsRelative:o,reactMount:i,aiContext:{sourceTag:t.tagName.toLowerCase(),sourceTextHint:(t.textContent||"").trim().slice(0,40),parentTag:e.tagName.toLowerCase(),parentNeedsRelative:o,preDragGeometry:{w:Math.round(l.width),h:Math.round(l.height)},neighbors:te(e,t),preDragLayout:p?{display:p.display,position:p.position,flex:p.flex,flexGrow:p.flexGrow,flexBasis:p.flexBasis,gridArea:p.gridArea,gridColumn:p.gridColumn,gridRow:p.gridRow,width:p.width,height:p.height,margin:p.margin,transform:p.transform}:null,hint:"free-position (absolute). User intent = position/left/top ONLY. preDragLayout shows source's pre-drag computed styles for your decision on whether additional width/height locks are needed to preserve geometry."}}}function te(t,e){if(!t)return[];const n=[];for(const r of t.children){if(!r||r.nodeType!==1||r===e)continue;It(r);const i=r.getBoundingClientRect();n.push({anchor:jt(r),tag:r.tagName.toLowerCase(),rect:{w:Math.round(i.width),h:Math.round(i.height)}})}return n}function Br({sourceEl:t,targetContainer:e,beforeEl:n,intent:r="sibling-before",alignmentHints:i=[]}){if(!t||!e)return null;It(t),It(e),n&&It(n);const s=pt(t)||pt(e),a=t.parentElement,o=te(a,t),l=e===a?o:te(e,t);return{sourceAnchor:jt(t),move:{container:jt(e),before:n?jt(n):null,intent:r},reactMount:s,aiContext:{sourceTag:t.tagName.toLowerCase(),sourceTextHint:(t.textContent||"").trim().slice(0,40),targetContainerTag:e.tagName.toLowerCase(),targetTextHint:(e.textContent||"").trim().slice(0,60),intent:r,alignmentHints:i,neighbors:{sourceParent:o,targetContainer:l}}}}const Rr="rgba(45, 36, 24, 0.85)",mt=gt.blue,$e=gt.magenta,Kr=gt.blue,Gr=3;function oo({active:t,iframeRef:e,zoom:n=1,freeMode:r=!1,onFreeModeChange:i,onCommitMove:s,onCommitFreePosition:a,onCancel:o,apiRef:l,onDraggingChange:u,onSelectionChange:p}){var se,le,ae,ce,ue,Wt,de,fe;const[c,W]=d.useState(null),[k,O]=d.useState(null),[,L]=d.useState(0);d.useEffect(()=>{if(!t)return;const w=e==null?void 0:e.current;if(!w)return;const E=w.contentWindow;if(!E)return;let B=null;const tt=()=>{B||(B=requestAnimationFrame(()=>{B=null,L(P=>P+1)}))};try{E.addEventListener("scroll",tt,{passive:!0,capture:!0}),E.addEventListener("resize",tt),window.addEventListener("resize",tt)}catch{}return()=>{try{E.removeEventListener("scroll",tt,{capture:!0}),E.removeEventListener("resize",tt),window.removeEventListener("resize",tt)}catch{}B&&cancelAnimationFrame(B)}},[t,e]),d.useEffect(()=>{if(!t)return;const w=e==null?void 0:e.current;if(!w)return;const E=_r(w);if(!E)return;const B=E.body;if(!B)return;const tt=B.style.userSelect;B.style.userSelect="none";let P={source:null,startX:0,startY:0,started:!1,altKey:!1,autoFree:!1};const dt=H=>{var nt;if(H.button!==0)return;const et=H.target;if(!et||et.nodeType!==1||et===B||et===E.documentElement)return;const V=Fe(et,B);if(!V)return;H.preventDefault(),H.stopPropagation();let lt=!1;try{const it=E.defaultView.getComputedStyle(V).position;lt=it==="absolute"||it==="fixed"}catch{}P={source:V,startX:H.clientX,startY:H.clientY,started:!1,altKey:H.altKey,autoFree:lt},(nt=X.current)==null||nt.call(X,!0)},At=(H,et,V)=>{var nt;if(!H)return;const lt=Pe(w,et,V,n);P={source:H,startX:lt.x,startY:lt.y,started:!1,altKey:!1,autoFree:!1},(nt=X.current)==null||nt.call(X,!0)};l&&(l.current={startDrag:At,pickDragSource:Fe});const zt=H=>{if(!P.source)return;let et,V;if(H.view===w.contentWindow)et=H.clientX,V=H.clientY;else{const st=Pe(w,H.clientX,H.clientY,n);et=st.x,V=st.y}const lt=et-P.startX,nt=V-P.startY;if(!P.started){if(Math.hypot(lt,nt)<Gr)return;P.started=!0}H.preventDefault();const it=P.source.getBoundingClientRect();let _={left:it.left+lt,top:it.top+nt,right:it.right+lt,bottom:it.bottom+nt,width:it.width,height:it.height};H.shiftKey&&(_=Hr(_,it,lt,nt));const bt=_.left+_.width/2,Mt=_.top+_.height/2,Et=C.current||P.autoFree;let ht=null,at=null,ut=[],xt=[];if(J.current=H,Et){const st=P.source.parentElement;if(st){const ft=Zt(st,P.source);ut=Te(_,ft),xt=Ae(_,ft)}}else{const st=P.source.style.pointerEvents;P.source.style.pointerEvents="none";const ft=E.elementFromPoint(bt,Mt);if(P.source.style.pointerEvents=st,ht=ft?Ar(ft,P.source,B):null,ht){at=Pr(ht.container,ft,P.source,{x:bt,y:Mt});const $t=Zt(ht.container,P.source);if(ut=Te(_,$t),xt=Ae(_,$t),at&&at.intent==="child-of"){const Lt=at.hitChild,Dt=Date.now();y.current===Lt||(x.current.hitChild===Lt?Dt-x.current.ts>=150?y.current=Lt:at=De(at):(x.current={hitChild:Lt,ts:Dt},y.current=null,at=De(at),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{S.current=null,P.source&&J.current&&zt(J.current)},160)))}else x.current={hitChild:null,ts:0},y.current=null,S.current&&(clearTimeout(S.current),S.current=null)}}ut.length>0&&(_=Nr(_,ut,3));let yt=[];if(Et){const st=P.source.parentElement;if(st){const ft=Zt(st,P.source);yt=Wr(_,ft)}}W({source:P.source,sourceRect:it,ghostRect:_,dropTarget:ht,dropIntent:at,alignGuides:ut,distanceLabels:xt,smartSpacing:yt,reactMount:pt(P.source),freeMode:Et,autoFree:P.autoFree,duplicate:P.altKey})},Bt=H=>{var xt,yt,st,ft,$t,Lt,Dt;if(!P.source)return;const et=P.started,V=P.source,lt=et?A.current:null,nt=et?T.current:null,it=et?I.current:[],_=et?j.current:null,bt=C.current||P.autoFree,Mt=P.altKey;if(P={source:null,startX:0,startY:0,started:!1,altKey:!1,autoFree:!1},W(null),(xt=X.current)==null||xt.call(X,!1),!et)return;if(bt&&_){const vt=V.parentElement;if(!vt){(yt=q.current)==null||yt.call(q);return}const pe=vt.getBoundingClientRect(),he=Math.round(_.left-pe.left),ge=Math.round(_.top-pe.top),be=ze({sourceEl:V,parentEl:vt,left:he,top:ge});be&&((st=R.current)==null||st.call(R,be,{sourceEl:V,parentEl:vt,left:he,top:ge}),K.current=V,(ft=g.current)==null||ft.call(g,V),requestAnimationFrame(()=>{try{O({rect:V.getBoundingClientRect(),ts:Date.now()}),setTimeout(()=>O(null),350)}catch{}}));return}if(!lt||!nt){($t=q.current)==null||$t.call(q);return}const Et=it.map(vt=>Vr(vt)),ht=nt.targetContainer,at=nt.beforeEl,ut=Br({sourceEl:V,targetContainer:ht,beforeEl:at,intent:nt.intent,alignmentHints:Et});ut&&(Mt&&(ut.duplicate=!0),(Lt=z.current)==null||Lt.call(z,ut,{sourceEl:V,targetContainer:ht,beforeEl:at,duplicate:Mt}),K.current=V,(Dt=g.current)==null||Dt.call(g,V),requestAnimationFrame(()=>{try{const vt=V.getBoundingClientRect();O({rect:vt,ts:Date.now()}),setTimeout(()=>O(null),350)}catch{}}))},Rt=H=>{var V,lt,nt,it;if(H.key==="Escape"&&P.source){H.preventDefault(),P={source:null,startX:0,startY:0,started:!1,altKey:!1,autoFree:!1},W(null),(V=X.current)==null||V.call(X,!1),(lt=q.current)==null||lt.call(q);return}if((H.key==="p"||H.key==="P")&&!H.metaKey&&!H.ctrlKey&&!H.altKey){H.preventDefault(),(nt=h.current)==null||nt.call(h,!C.current);return}if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(H.key)&&K.current&&C.current){const _=K.current;if(!_.isConnected){K.current=null;return}H.preventDefault();const bt=H.shiftKey?10:1,Mt=H.key==="ArrowLeft"?-bt:H.key==="ArrowRight"?bt:0,Et=H.key==="ArrowUp"?-bt:H.key==="ArrowDown"?bt:0,ht=parseFloat(_.style.left)||0,at=parseFloat(_.style.top)||0,ut=Math.round(ht+Mt),xt=Math.round(at+Et),yt=_.parentElement,st=ze({sourceEl:_,parentEl:yt,left:ut,top:xt});st&&((it=R.current)==null||it.call(R,st,{sourceEl:_,parentEl:yt,left:ut,top:xt}))}};return E.addEventListener("mousedown",dt,!0),window.addEventListener("mousemove",zt,!0),window.addEventListener("mouseup",Bt,!0),window.addEventListener("keydown",Rt),E.addEventListener("mousemove",zt,!0),E.addEventListener("mouseup",Bt,!0),E.addEventListener("keydown",Rt,!0),()=>{try{E.removeEventListener("mousedown",dt,!0),window.removeEventListener("mousemove",zt,!0),window.removeEventListener("mouseup",Bt,!0),window.removeEventListener("keydown",Rt),E.removeEventListener("mousemove",zt,!0),E.removeEventListener("mouseup",Bt,!0),E.removeEventListener("keydown",Rt,!0)}catch{}B.style.userSelect=tt,l&&(l.current=null),S.current&&(clearTimeout(S.current),S.current=null),x.current={hitChild:null,ts:0},y.current=null}},[t,n]);const A=d.useRef(null),T=d.useRef(null),I=d.useRef([]),j=d.useRef(null),C=d.useRef(!1),x=d.useRef({hitChild:null,ts:0}),y=d.useRef(null),S=d.useRef(null),J=d.useRef(null),K=d.useRef(null),z=d.useRef(s),R=d.useRef(a),q=d.useRef(o),X=d.useRef(u),g=d.useRef(p),h=d.useRef(i);if(z.current=s,R.current=a,q.current=o,X.current=u,g.current=p,h.current=i,d.useEffect(()=>{A.current=(c==null?void 0:c.dropTarget)||null,T.current=(c==null?void 0:c.dropIntent)||null,I.current=(c==null?void 0:c.alignGuides)||[],j.current=(c==null?void 0:c.ghostRect)||null},[c]),d.useEffect(()=>{C.current=r},[r]),!t||!(e!=null&&e.current))return null;const D=e.current;D.getBoundingClientRect();const U=Ct(D);if(!U)return null;const Y=(w,E,B,tt)=>({top:U.y+E*n,left:U.x+w*n,width:B*n,height:tt*n});if(!c){const w=k?(()=>{const E=Y(k.rect.left,k.rect.top,k.rect.width,k.rect.height);return f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:E.top-4,left:E.left-4,width:E.width+8,height:E.height+8,border:`3px solid ${mt}`,borderRadius:N.sm,background:"rgba(58, 122, 254, 0.12)",boxShadow:"0 0 16px rgba(58, 122, 254, 0.5)",zIndex:25,animation:"nd-drag-landing-flash 350ms ease-out forwards"}})})():null;return f.jsxs(f.Fragment,{children:[w,w&&f.jsx("style",{children:`
21
+ `},je=Vn(Un)(_e),Jn={config:Yn},Zn=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return function(i){return n.reduceRight(function(s,a){return a(s)},i)}};function Ve(t,e){return Object.keys(e).forEach(function(n){e[n]instanceof Object&&t[n]&&Object.assign(e[n],Ve(t[n],e[n]))}),Me(Me({},t),e)}var Qn={type:"cancelation",msg:"operation is manually canceled"};function Yt(t){var e=!1,n=new Promise(function(r,i){t.then(function(s){return e?i(Qn):r(s)}),t.catch(i)});return n.cancel=function(){return e=!0},n}var tr=["monaco"],er=Gn.create({config:_n,isInitialized:!1,resolve:null,reject:null,monaco:null}),Xe=jn(er,2),Nt=Xe[0],Xt=Xe[1];function nr(t){var e=Jn.config(t),n=e.monaco,r=En(e,tr);Xt(function(i){return{config:Ve(i.config,r),monaco:n}})}function rr(){var t=Nt(function(e){var n=e.monaco,r=e.isInitialized,i=e.resolve;return{monaco:n,isInitialized:r,resolve:i}});if(!t.isInitialized){if(Xt({isInitialized:!0}),t.monaco)return t.resolve(t.monaco),Yt(qt);if(window.monaco&&window.monaco.editor)return Ye(window.monaco),t.resolve(window.monaco),Yt(qt);Zn(or,sr)(lr)}return Yt(qt)}function or(t){return document.body.appendChild(t)}function ir(t){var e=document.createElement("script");return t&&(e.src=t),e}function sr(t){var e=Nt(function(r){var i=r.config,s=r.reject;return{config:i,reject:s}}),n=ir("".concat(e.config.paths.vs,"/loader.js"));return n.onload=function(){return t()},n.onerror=e.reject,n}function lr(){var t=Nt(function(n){var r=n.config,i=n.resolve,s=n.reject;return{config:r,resolve:i,reject:s}}),e=window.require;e.config(t.config),e(["vs/editor/editor.main"],function(n){var r=n.m||n;Ye(r),t.resolve(r)},function(n){t.reject(n)})}function Ye(t){Nt().monaco||Xt({monaco:t})}function ar(){return Nt(function(t){var e=t.monaco;return e})}var qt=new Promise(function(t,e){return Xt({resolve:t,reject:e})}),qe={config:nr,init:rr,__getMonacoInstance:ar},cr={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Ut=cr,ur={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},dr=ur;function fr({children:t}){return Tt.createElement("div",{style:dr.container},t)}var pr=fr,hr=pr;function gr({width:t,height:e,isEditorReady:n,loading:r,_ref:i,className:s,wrapperProps:a}){return Tt.createElement("section",{style:{...Ut.wrapper,width:t,height:e},...a},!n&&Tt.createElement(hr,null,r),Tt.createElement("div",{ref:i,style:{...Ut.fullWidth,...!n&&Ut.hide},className:s}))}var br=gr,Ue=d.memo(br);function xr(t){d.useEffect(t,[])}var Je=xr;function yr(t,e,n=!0){let r=d.useRef(!0);d.useEffect(r.current||!n?()=>{r.current=!1}:t,e)}var ct=yr;function Ft(){}function kt(t,e,n,r){return vr(t,r)||mr(t,e,n,r)}function vr(t,e){return t.editor.getModel(Ze(t,e))}function mr(t,e,n,r){return t.editor.createModel(e,n,r?Ze(t,r):void 0)}function Ze(t,e){return t.Uri.parse(e)}function wr({original:t,modified:e,language:n,originalLanguage:r,modifiedLanguage:i,originalModelPath:s,modifiedModelPath:a,keepCurrentOriginalModel:o=!1,keepCurrentModifiedModel:l=!1,theme:u="light",loading:p="Loading...",options:c={},height:W="100%",width:O="100%",className:k,wrapperProps:L={},beforeMount:A=Ft,onMount:T=Ft}){let[I,j]=d.useState(!1),[C,x]=d.useState(!0),y=d.useRef(null),S=d.useRef(null),Z=d.useRef(null),K=d.useRef(T),z=d.useRef(A),R=d.useRef(!1);Je(()=>{let h=qe.init();return h.then(D=>(S.current=D)&&x(!1)).catch(D=>(D==null?void 0:D.type)!=="cancelation"&&console.error("Monaco initialization: error:",D)),()=>y.current?g():h.cancel()}),ct(()=>{if(y.current&&S.current){let h=y.current.getOriginalEditor(),D=kt(S.current,t||"",r||n||"text",s||"");D!==h.getModel()&&h.setModel(D)}},[s],I),ct(()=>{if(y.current&&S.current){let h=y.current.getModifiedEditor(),D=kt(S.current,e||"",i||n||"text",a||"");D!==h.getModel()&&h.setModel(D)}},[a],I),ct(()=>{let h=y.current.getModifiedEditor();h.getOption(S.current.editor.EditorOption.readOnly)?h.setValue(e||""):e!==h.getValue()&&(h.executeEdits("",[{range:h.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),h.pushUndoStop())},[e],I),ct(()=>{var h,D;(D=(h=y.current)==null?void 0:h.getModel())==null||D.original.setValue(t||"")},[t],I),ct(()=>{let{original:h,modified:D}=y.current.getModel();S.current.editor.setModelLanguage(h,r||n||"text"),S.current.editor.setModelLanguage(D,i||n||"text")},[n,r,i],I),ct(()=>{var h;(h=S.current)==null||h.editor.setTheme(u)},[u],I),ct(()=>{var h;(h=y.current)==null||h.updateOptions(c)},[c],I);let q=d.useCallback(()=>{var U;if(!S.current)return;z.current(S.current);let h=kt(S.current,t||"",r||n||"text",s||""),D=kt(S.current,e||"",i||n||"text",a||"");(U=y.current)==null||U.setModel({original:h,modified:D})},[n,e,i,t,r,s,a]),X=d.useCallback(()=>{var h;!R.current&&Z.current&&(y.current=S.current.editor.createDiffEditor(Z.current,{automaticLayout:!0,...c}),q(),(h=S.current)==null||h.editor.setTheme(u),j(!0),R.current=!0)},[c,u,q]);d.useEffect(()=>{I&&K.current(y.current,S.current)},[I]),d.useEffect(()=>{!C&&!I&&X()},[C,I,X]);function g(){var D,U,Y,ot;let h=(D=y.current)==null?void 0:D.getModel();o||((U=h==null?void 0:h.original)==null||U.dispose()),l||((Y=h==null?void 0:h.modified)==null||Y.dispose()),(ot=y.current)==null||ot.dispose()}return Tt.createElement(Ue,{width:O,height:W,isEditorReady:I,loading:p,_ref:Z,className:k,wrapperProps:L})}var Sr=wr;d.memo(Sr);function Mr(t){let e=d.useRef();return d.useEffect(()=>{e.current=t},[t]),e.current}var Er=Mr,Gt=new Map;function Lr({defaultValue:t,defaultLanguage:e,defaultPath:n,value:r,language:i,path:s,theme:a="light",line:o,loading:l="Loading...",options:u={},overrideServices:p={},saveViewState:c=!0,keepCurrentModel:W=!1,width:O="100%",height:k="100%",className:L,wrapperProps:A={},beforeMount:T=Ft,onMount:I=Ft,onChange:j,onValidate:C=Ft}){let[x,y]=d.useState(!1),[S,Z]=d.useState(!0),K=d.useRef(null),z=d.useRef(null),R=d.useRef(null),q=d.useRef(I),X=d.useRef(T),g=d.useRef(),h=d.useRef(r),D=Er(s),U=d.useRef(!1),Y=d.useRef(!1);Je(()=>{let v=qe.init();return v.then(M=>(K.current=M)&&Z(!1)).catch(M=>(M==null?void 0:M.type)!=="cancelation"&&console.error("Monaco initialization: error:",M)),()=>z.current?$():v.cancel()}),ct(()=>{var M,F,Q,J;let v=kt(K.current,t||r||"",e||i||"",s||n||"");v!==((M=z.current)==null?void 0:M.getModel())&&(c&&Gt.set(D,(F=z.current)==null?void 0:F.saveViewState()),(Q=z.current)==null||Q.setModel(v),c&&((J=z.current)==null||J.restoreViewState(Gt.get(s))))},[s],x),ct(()=>{var v;(v=z.current)==null||v.updateOptions(u)},[u],x),ct(()=>{!z.current||r===void 0||(z.current.getOption(K.current.editor.EditorOption.readOnly)?z.current.setValue(r):r!==z.current.getValue()&&(Y.current=!0,z.current.executeEdits("",[{range:z.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),z.current.pushUndoStop(),Y.current=!1))},[r],x),ct(()=>{var M,F;let v=(M=z.current)==null?void 0:M.getModel();v&&i&&((F=K.current)==null||F.editor.setModelLanguage(v,i))},[i],x),ct(()=>{var v;o!==void 0&&((v=z.current)==null||v.revealLine(o))},[o],x),ct(()=>{var v;(v=K.current)==null||v.editor.setTheme(a)},[a],x);let ot=d.useCallback(()=>{var v;if(!(!R.current||!K.current)&&!U.current){X.current(K.current);let M=s||n,F=kt(K.current,r||t||"",e||i||"",M||"");z.current=(v=K.current)==null?void 0:v.editor.create(R.current,{model:F,automaticLayout:!0,...u},p),c&&z.current.restoreViewState(Gt.get(M)),K.current.editor.setTheme(a),o!==void 0&&z.current.revealLine(o),y(!0),U.current=!0}},[t,e,n,r,i,s,u,p,c,a,o]);d.useEffect(()=>{x&&q.current(z.current,K.current)},[x]),d.useEffect(()=>{!S&&!x&&ot()},[S,x,ot]),h.current=r,d.useEffect(()=>{var v,M;x&&j&&((v=g.current)==null||v.dispose(),g.current=(M=z.current)==null?void 0:M.onDidChangeModelContent(F=>{Y.current||j(z.current.getValue(),F)}))},[x,j]),d.useEffect(()=>{if(x){let v=K.current.editor.onDidChangeMarkers(M=>{var Q;let F=(Q=z.current.getModel())==null?void 0:Q.uri;if(F&&M.find(J=>J.path===F.path)){let J=K.current.editor.getModelMarkers({resource:F});C==null||C(J)}});return()=>{v==null||v.dispose()}}return()=>{}},[x,C]);function $(){var v,M;(v=g.current)==null||v.dispose(),W?c&&Gt.set(s,z.current.saveViewState()):(M=z.current.getModel())==null||M.dispose(),z.current.dispose()}return Tt.createElement(Ue,{width:O,height:k,isEditorReady:x,loading:l,_ref:R,className:L,wrapperProps:A})}var jr=Lr,Cr=d.memo(jr),Or=Cr;function eo({value:t="",onChange:e,readOnly:n=!1}){const[r,i]=d.useState(t),s=r!==t;d.useEffect(()=>{s||i(t)},[t]),d.useEffect(()=>{if(!s)return;const o=setTimeout(()=>e==null?void 0:e(r),800);return()=>clearTimeout(o)},[r,s,e]);const a=()=>{s&&(e==null||e(r))};return f.jsxs("div",{style:{flex:1,minHeight:0,position:"relative",background:m.bgCard,display:"flex",flexDirection:"column"},children:[f.jsxs("div",{style:{flexShrink:0,padding:`${b.sm}px ${b.lg}px`,background:"rgba(0,0,0,0.04)",borderBottom:`1px solid ${m.borderLt}`,fontFamily:rt,fontSize:G.xs,color:m.sub,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[f.jsxs("span",{children:["deck.html",s&&f.jsx("span",{style:{color:m.warn,marginLeft:b.sm},children:"· 已修改"})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:b.sm},children:[s&&f.jsxs("button",{onClick:a,style:{display:"inline-flex",alignItems:"center",gap:b.xs,padding:`${b.xxs}px ${b.md}px`,fontFamily:wt,fontSize:G.sm,fontWeight:500,color:m.btnText,background:m.btn,border:"none",borderRadius:N.sm,cursor:"pointer"},children:[f.jsx(tn,{size:10})," 应用"]}),f.jsx("span",{style:{fontSize:G.xs},children:n?"只读":"改完会同步到 Edit / Preview"})]})]}),f.jsx("div",{style:{flex:1,minHeight:0},children:f.jsx(Or,{defaultLanguage:"html",value:r,onChange:o=>i(o??""),theme:"light",options:{readOnly:n,minimap:{enabled:!1},fontSize:12,fontFamily:"'SF Mono', 'Cascadia Code', 'Menlo', monospace",lineNumbers:"on",renderLineHighlight:"none",scrollBeyondLastLine:!1,wordWrap:"on",tabSize:2},loading:f.jsx("div",{style:{padding:b.xl,fontFamily:rt,fontSize:G.sm,color:m.sub},children:"Monaco 加载中…"})})})]})}const Ce=340,kr=8,Oe=520;function no({selectedAnchor:t,redactText:e=void 0,iframeDoc:n,iframeRef:r,iframeRect:i,zoom:s=1,comments:a=[],onClose:o,onAddComment:l,onResolveComment:u,onDeleteComment:p}){var D,U,Y,ot;const c=d.useRef(null),[,W]=d.useState(0),[O,k]=d.useState(""),[L,A]=d.useState(0);d.useEffect(()=>{if(!t||!(r!=null&&r.current))return;const v=r.current.contentWindow;if(!v)return;let M=null;const F=()=>{M||(M=requestAnimationFrame(()=>{M=null,W(Q=>Q+1)}))};try{v.addEventListener("scroll",F,{passive:!0,capture:!0}),v.addEventListener("resize",F),window.addEventListener("resize",F)}catch{}return()=>{try{v.removeEventListener("scroll",F,{capture:!0}),v.removeEventListener("resize",F),window.removeEventListener("resize",F)}catch{}M&&cancelAnimationFrame(M)}},[t,r]),d.useEffect(()=>{if(!c.current)return;const $=new ResizeObserver(()=>{var M;const v=((M=c.current)==null?void 0:M.offsetHeight)||0;A(F=>F!==v?v:F)});return $.observe(c.current),()=>$.disconnect()},[t]);const T=d.useMemo(()=>t&&n?oe(t,n.body):null,[t,n]),I=d.useMemo(()=>t?a.filter($=>{var v,M;return t.dataId&&((v=$.anchor)!=null&&v.dataId)?$.anchor.dataId===t.dataId:((M=$.anchor)==null?void 0:M.path)===t.path}):[],[a,t]),j=d.useCallback(()=>{const $=O.trim();if(!$||!T)return;const v=en(T,{redactText:e});l==null||l({anchor:e?nn(t):t,scope:"this",aiContext:v,text:$}),k("")},[O,T,t,l,e]),C=$=>{if($.key==="Enter"&&!$.shiftKey){if(re($))return;$.preventDefault(),j()}},x=d.useCallback(()=>{if(T)try{T.scrollIntoView({behavior:"smooth",block:"center"})}catch{}},[T]);if(!t||!T||!i||i.width===0)return null;const y=T.getBoundingClientRect(),S=((U=(D=r==null?void 0:r.current)==null?void 0:D.contentWindow)==null?void 0:U.innerWidth)??i.width/s,Z=((ot=(Y=r==null?void 0:r.current)==null?void 0:Y.contentWindow)==null?void 0:ot.innerHeight)??i.height/s,K=y.bottom<=0||y.top>=Z||y.right<=0||y.left>=S,z=Ct(r==null?void 0:r.current)||{x:0,y:0,iframeRect:i},{left:R,top:q}=Re(z,y,s,{cardWidth:Ce,cardHeight:L||Oe,offset:kr}),X=rn(T),g=on(T),h=T.tagName.toLowerCase();return f.jsxs("div",{ref:c,style:{position:"absolute",left:R,top:q,width:Ce,maxHeight:Oe,background:m.bgWhite,borderRadius:2,boxShadow:"0 2px 4px rgba(0,0,0,0.04), 0 8px 20px rgba(0,0,0,0.08), 0 24px 48px rgba(0,0,0,0.10), inset 0 1px 0 rgba(255,255,255,0.8)",zIndex:50,display:"flex",flexDirection:"column",overflow:"hidden"},onMouseDown:$=>$.stopPropagation(),children:[f.jsxs("div",{style:{padding:`${b.md}px ${b.lg}px`,display:"flex",alignItems:"center",gap:b.sm,borderBottom:`1px solid ${m.borderLt}`,flexShrink:0,background:"rgba(255,255,255,0.95)"},children:[f.jsxs("span",{style:{fontFamily:rt,fontSize:G.xs,color:m.text4,background:"rgba(0,0,0,0.05)",padding:`1px ${b.sm}px`,borderRadius:N.xs},children:["<",h,">"]}),f.jsxs("span",{style:{fontFamily:wt,fontSize:G.sm,fontWeight:500,color:m.text,flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[(g==null?void 0:g.index)!==void 0&&g.index!==null&&`第 ${g.index} 页 · `,X]}),K&&f.jsx("button",{onClick:x,title:"滚动到该元素",style:{padding:b.xs,color:m.text4,borderRadius:N.xs,background:"rgba(0,0,0,0.04)"},children:f.jsx(an,{size:11})}),f.jsx("button",{onClick:o,title:"关闭(ESC)",style:{padding:b.xs,color:m.text5,borderRadius:N.xs},children:f.jsx(ne,{size:12})})]}),f.jsx("div",{style:{flex:1,minHeight:0,overflowY:"auto"},children:f.jsxs("div",{style:{padding:`${b.md}px ${b.lg}px`,borderBottom:`1px solid ${m.borderLt}`,background:"rgba(0,0,0,0.015)"},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:b.xs,fontFamily:rt,fontSize:G.xs,color:m.sub,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:b.sm},children:[f.jsx(cn,{size:10}),"评论 ",I.length>0&&`(${I.length})`]}),I.length>0&&f.jsx("div",{style:{display:"flex",flexDirection:"column",gap:b.xs,marginBottom:b.sm},children:I.map($=>f.jsx(Tr,{comment:$,onResolve:()=>u==null?void 0:u($.id),onDelete:()=>p==null?void 0:p($.id)},$.id))}),f.jsx("textarea",{value:O,onChange:$=>k($.target.value),onKeyDown:C,placeholder:"评论这个元素,让 AI 看看…(Enter 提交,Shift+Enter 换行)",rows:2,style:{width:"100%",padding:`${b.sm}px ${b.md}px`,fontFamily:wt,fontSize:G.sm,color:m.text2,background:m.bgWhite,boxShadow:ee.far,borderRadius:N.sm,resize:"vertical",boxSizing:"border-box",outline:"none"},onFocus:$=>{$.currentTarget.style.borderColor=m.btn},onBlur:$=>{$.currentTarget.style.borderColor=m.borderLt}})]})})]})}function Tr({comment:t,onResolve:e,onDelete:n}){const r=t.status==="resolved";return f.jsxs("div",{style:{padding:`${b.xs}px ${b.sm}px`,background:m.bgWhite,boxShadow:ee.far,borderRadius:N.sm,display:"flex",flexDirection:"column",gap:b.xs,opacity:r?.5:1},children:[f.jsx("div",{style:{fontFamily:wt,fontSize:G.xs,color:m.text2,lineHeight:1.5,textDecoration:r?"line-through":"none",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t.text}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:b.xs},children:[f.jsx("button",{onClick:e,title:r?"取消解决":"标记解决",style:{padding:b.xxs,color:m.sub,borderRadius:N.xs},children:f.jsx(sn,{size:10})}),f.jsx("button",{onClick:n,title:"删除",style:{padding:b.xxs,color:m.sub,borderRadius:N.xs},children:f.jsx(ln,{size:10})})]})]})}function ro({comments:t=[],iframeRef:e,zoom:n=1,onSelectAnchor:r}){const[,i]=d.useState(0);d.useEffect(()=>{if(t.length===0)return;const O=e==null?void 0:e.current;if(!O)return;const k=O.contentWindow;if(!k)return;let L=null;const A=()=>{L||(L=requestAnimationFrame(()=>{L=null,i(T=>T+1)}))};try{k.addEventListener("scroll",A,{passive:!0,capture:!0}),k.addEventListener("resize",A),window.addEventListener("resize",A)}catch{}return()=>{try{k.removeEventListener("scroll",A,{capture:!0}),k.removeEventListener("resize",A),window.removeEventListener("resize",A)}catch{}L&&cancelAnimationFrame(L)}},[t.length,e]);const s=d.useMemo(()=>{const O=new Map;for(const k of t){if(k.status==="resolved"||!k.anchor)continue;const L=k.anchor.dataId||k.anchor.path;L&&(O.has(L)||O.set(L,{anchor:k.anchor,items:[]}),O.get(L).items.push(k))}return[...O.values()]},[t]);if(s.length===0||!(e!=null&&e.current))return null;const a=e.current,o=a.contentDocument;if(!o)return null;const l=a.getBoundingClientRect(),u=Ct(a);if(!u)return null;const p=a.contentWindow,c=(p==null?void 0:p.innerWidth)??l.width/n,W=(p==null?void 0:p.innerHeight)??l.height/n;return f.jsx(f.Fragment,{children:s.map((O,k)=>{var Z;const L=oe(O.anchor,o.body);if(!L)return null;const A=L.getBoundingClientRect();if(A.bottom<=0||A.top>=W||A.right<=0||A.left>=c)return null;const{top:T,left:I}=Be(u,A.left,A.top,n),j=A.width*n,C=A.height*n,x=O.items.length,y=((Z=O.items[0])==null?void 0:Z.text)||"",S=y.length>28?y.slice(0,28)+"…":y;return f.jsxs("div",{style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:T-3,left:I-3,width:j+6,height:C+6,border:`2px solid ${ke}`,borderRadius:N.sm,boxShadow:`0 0 0 3px ${Ir}`,zIndex:9}}),f.jsx("button",{onClick:()=>r==null?void 0:r(O.anchor),title:x>1?`${x} 条评论 — 点击查看`:`已评论:${y}`,style:{position:"absolute",pointerEvents:"auto",top:T-12,left:I+j-8,transform:"translateX(-100%)",padding:`${b.xxs}px ${b.sm}px`,fontFamily:rt,fontSize:G.xs,lineHeight:"14px",fontWeight:500,color:m.bgWhite,background:ke,border:"none",borderRadius:N.xs,whiteSpace:"nowrap",cursor:"pointer",boxShadow:Qt.crisp,zIndex:11,maxWidth:Math.max(60,j),overflow:"hidden",textOverflow:"ellipsis"},children:x>1?`已评论 ${x}`:S||"已评论"})]},k)})})}const ke=gt.orange,Ir="rgba(230, 126, 34, 0.18)";function Ar(t,e,n){var a;if(!t||!n)return null;const r=n.ownerDocument.defaultView;let i=t,s=0;for(;i&&i.nodeType===1&&i!==n&&i!==n.ownerDocument.documentElement;){if(e&&(i===e||e.contains(i))){i=i.parentElement,s++;continue}if(i.children&&i.children.length>=1){const o=(a=r==null?void 0:r.getComputedStyle)==null?void 0:a.call(r,i),l=(o==null?void 0:o.display)||"block",u=l==="block"||l==="flex"||l==="grid"||l==="inline-block"||l==="inline-flex"||l==="inline-grid"||l==="list-item"||l==="table"||l==="table-cell",p=!["A","BUTTON","LABEL","SPAN","CODE","STRONG","EM","I"].includes(i.tagName);if(u&&p)return{container:i,depth:s}}i=i.parentElement,s++}return n.children&&n.children.length>0?{container:n,depth:s}:null}function zr(t){if(!t||t.nodeType!==1||["A","BUTTON","LABEL","SPAN","CODE","STRONG","EM","I","IMG","SVG"].includes(t.tagName))return!1;const e=t.ownerDocument.defaultView;if(!e)return!1;const r=e.getComputedStyle(t).display;return r==="block"||r==="flex"||r==="grid"||r==="inline-block"||r==="inline-flex"||r==="inline-grid"||r==="list-item"||r==="table"||r==="table-cell"}function $r(t,e,n){if(!e||!t)return null;let r=e;for(;r&&r!==t;){if(n&&(r===n||n.contains(r)))return null;if(r.parentElement===t)return r;r=r.parentElement}return null}function Dr(t,e){const n=Array.from(t.children).filter(u=>u!==e&&u.nodeType===1);if(n.length<2){const u=t.ownerDocument.defaultView,p=u?u.getComputedStyle(t):null;return p&&(p.display==="flex"||p.display==="inline-flex")?(p.flexDirection||"row").startsWith("row"):!1}const r=n[0].getBoundingClientRect(),i=n[1].getBoundingClientRect(),s=!(r.right<=i.left||i.right<=r.left),a=!(r.bottom<=i.top||i.bottom<=r.top);if(!s&&a)return!0;if(s&&!a)return!1;const o=t.ownerDocument.defaultView,l=o?o.getComputedStyle(t):null;return l&&(l.display==="flex"||l.display==="inline-flex")?(l.flexDirection||"row").startsWith("row"):!1}function Pr(t,e,n,r){if(!t)return null;const i=Dr(t,n),s=$r(t,e,n);if(s&&s!==n){const o=s.getBoundingClientRect();let l,u;i?(l=(r.x-o.left)/o.width,u=o.width):(l=(r.y-o.top)/o.height,u=o.height),l=Math.max(0,Math.min(1,l));const p=u>=60&&zr(s),c=p?.25:.5,W=p?.75:.5;return l<c?{intent:"sibling-before",targetContainer:t,beforeEl:s,hitChild:s,caretRect:i?{x:o.left-1,y:o.top,w:2,h:o.height,vertical:!0}:{x:o.left,y:o.top-1,w:o.width,h:2,vertical:!1},zoneRect:null,horizontal:i}:l>=W?{intent:"sibling-after",targetContainer:t,beforeEl:s.nextElementSibling||null,hitChild:s,caretRect:i?{x:o.right-1,y:o.top,w:2,h:o.height,vertical:!0}:{x:o.left,y:o.bottom-1,w:o.width,h:2,vertical:!1},zoneRect:null,horizontal:i}:{intent:"child-of",targetContainer:s,beforeEl:null,hitChild:s,caretRect:null,zoneRect:{x:o.left,y:o.top,w:o.width,h:o.height},horizontal:i}}const a=Fr(t,n,r);return a?{intent:a.before?"sibling-before":"sibling-after",targetContainer:t,beforeEl:a.before,hitChild:null,caretRect:a.caretRect,zoneRect:null,horizontal:i}:null}function Fr(t,e,n){if(!t)return null;const r=Array.from(t.children).filter(a=>a!==e&&a.nodeType===1);if(r.length===0){const a=t.getBoundingClientRect();return{before:null,caretRect:{x:a.left+4,y:a.top+4,w:Math.max(2,a.width-8),h:2,vertical:!1}}}let i=!1;if(r.length>=2){const a=r[0].getBoundingClientRect(),o=r[1].getBoundingClientRect(),l=!(a.right<=o.left||o.right<=a.left),u=!(a.bottom<=o.top||o.bottom<=a.top);if(!l&&u)i=!0;else if(l&&!u)i=!1;else{const p=t.ownerDocument.defaultView.getComputedStyle(t),c=p.flexDirection||"row";i=(p.display==="flex"||p.display==="inline-flex")&&(c==="row"||c==="row-reverse")}}else{const a=r[0].getBoundingClientRect(),o=Math.abs(n.x-(a.left+a.width/2)),l=Math.abs(n.y-(a.top+a.height/2));i=o>l}for(let a=0;a<r.length;a++){const o=r[a].getBoundingClientRect();if(i){const l=o.left+o.width/2;if(n.x<l)return{before:r[a],caretRect:{x:o.left-1,y:o.top,w:2,h:o.height,vertical:!0}}}else{const l=o.top+o.height/2;if(n.y<l)return{before:r[a],caretRect:{x:o.left,y:o.top-1,w:o.width,h:2,vertical:!1}}}}const s=r[r.length-1].getBoundingClientRect();return i?{before:null,caretRect:{x:s.right-1,y:s.top,w:2,h:s.height,vertical:!0}}:{before:null,caretRect:{x:s.left,y:s.bottom-1,w:s.width,h:2,vertical:!1}}}const Ot=5;function Te(t,e){const n=[];if(!t||!Array.isArray(e))return n;const r=t.left+t.width/2,i=t.top+t.height/2;for(const a of e){if(!a||!a.rect)continue;const o=a.rect,l=o.left+o.width/2,u=o.top+o.height/2;Math.abs(t.left-o.left)<=Ot?n.push({axis:"x",value:o.left,hint:"edge-left",neighbor:a.el}):Math.abs(r-l)<=Ot?n.push({axis:"x",value:l,hint:"center-x",neighbor:a.el}):Math.abs(t.right-o.right)<=Ot&&n.push({axis:"x",value:o.right,hint:"edge-right",neighbor:a.el}),Math.abs(t.top-o.top)<=Ot?n.push({axis:"y",value:o.top,hint:"edge-top",neighbor:a.el}):Math.abs(i-u)<=Ot?n.push({axis:"y",value:u,hint:"center-y",neighbor:a.el}):Math.abs(t.bottom-o.bottom)<=Ot&&n.push({axis:"y",value:o.bottom,hint:"edge-bottom",neighbor:a.el})}const s=new Set;return n.filter(a=>{const o=`${a.axis}:${Math.round(a.value)}`;return s.has(o)?!1:(s.add(o),!0)})}function Hr(t,e,n,r){return!t||!e?t:Math.abs(n)>=Math.abs(r)?{...t,top:e.top,bottom:e.top+t.height}:{...t,left:e.left,right:e.left+t.width}}function Nr(t,e,n=3){if(!t||!Array.isArray(e)||e.length===0)return t;let r=t.left,i=t.top;const s=t.left+t.width/2,a=t.top+t.height/2;for(const o of e)o.axis==="x"?o.hint==="edge-left"&&Math.abs(t.left-o.value)<=n?r=o.value:o.hint==="edge-right"&&Math.abs(t.right-o.value)<=n?r=o.value-t.width:o.hint==="center-x"&&Math.abs(s-o.value)<=n&&(r=o.value-t.width/2):o.axis==="y"&&(o.hint==="edge-top"&&Math.abs(t.top-o.value)<=n?i=o.value:o.hint==="edge-bottom"&&Math.abs(t.bottom-o.value)<=n?i=o.value-t.height:o.hint==="center-y"&&Math.abs(a-o.value)<=n&&(i=o.value-t.height/2));return{...t,left:r,top:i,right:r+t.width,bottom:i+t.height}}const Ie=4;function Wr(t,e){if(!t||!Array.isArray(e)||e.length<2)return[];const n=[],r=e.filter(s=>s.rect&&!(s.rect.bottom<t.top||s.rect.top>t.bottom));for(const s of r)for(const a of r){if(s===a||!s.rect||!a.rect||s.rect.right>=t.left||a.rect.left<=t.right)continue;const o=t.left-s.rect.right,l=a.rect.left-t.right;if(Math.abs(o-l)<=Ie){const u=(o+l)/2;n.push({side:"horizontal",gap:Math.round(u),snapTo:{left:s.rect.right+u},neighbors:[s.el,a.el]})}}const i=e.filter(s=>s.rect&&!(s.rect.right<t.left||s.rect.left>t.right));for(const s of i)for(const a of i){if(s===a||!s.rect||!a.rect||s.rect.bottom>=t.top||a.rect.top<=t.bottom)continue;const o=t.top-s.rect.bottom,l=a.rect.top-t.bottom;if(Math.abs(o-l)<=Ie){const u=(o+l)/2;n.push({side:"vertical",gap:Math.round(u),snapTo:{top:s.rect.bottom+u},neighbors:[s.el,a.el]})}}return n}function Ae(t,e){if(!t||!Array.isArray(e))return[];const n=[],r={top:{best:1/0,label:null},bottom:{best:1/0,label:null},left:{best:1/0,label:null},right:{best:1/0,label:null}};for(const i of e){if(!i||!i.rect)continue;const s=i.rect;if(!(s.right<t.left||s.left>t.right)){if(s.bottom<=t.top){const l=t.top-s.bottom;l<r.top.best&&(r.top.best=l,r.top.label={side:"top",gap:l,labelRect:{x:t.left+t.width/2-14,y:s.bottom+l/2-8,w:28,h:16}})}else if(s.top>=t.bottom){const l=s.top-t.bottom;l<r.bottom.best&&(r.bottom.best=l,r.bottom.label={side:"bottom",gap:l,labelRect:{x:t.left+t.width/2-14,y:t.bottom+l/2-8,w:28,h:16}})}}if(!(s.bottom<t.top||s.top>t.bottom)){if(s.right<=t.left){const l=t.left-s.right;l<r.left.best&&(r.left.best=l,r.left.label={side:"left",gap:l,labelRect:{x:s.right+l/2-14,y:t.top+t.height/2-8,w:28,h:16}})}else if(s.left>=t.right){const l=s.left-t.right;l<r.right.best&&(r.right.best=l,r.right.label={side:"right",gap:l,labelRect:{x:t.right+l/2-14,y:t.top+t.height/2-8,w:28,h:16}})}}}for(const i of Object.values(r))i.label&&i.label.gap>=0&&i.label.gap<200&&n.push(i.label);return n}function Jt(t,e,n="siblings"){if(!t)return[];const r=[],i=(a,o)=>{if(!(!a||o>2))for(const l of a.children)!l||l.nodeType!==1||e&&(l===e||e.contains(l))||(r.push({el:l,rect:l.getBoundingClientRect()}),n==="deep"&&o<2&&i(l,o+1))};i(t,0);const s=t.parentElement;if(s&&s!==t.ownerDocument.body)for(const a of s.children)a===t||a.nodeType!==1||e&&(a===e||e.contains(a))||r.push({el:a,rect:a.getBoundingClientRect()});return r}function ze({sourceEl:t,parentEl:e,left:n,top:r}){if(!t||!e)return null;It(t),It(e);const i=pt(t)||pt(e),s=e.ownerDocument.defaultView,a=s?s.getComputedStyle(e):null,o=a&&a.position==="static",l=t.getBoundingClientRect(),u=t.ownerDocument.defaultView,p=u?u.getComputedStyle(t):null,c={position:"absolute",left:`${n}px`,top:`${r}px`},W={width:`${Math.round(l.width)}px`,height:`${Math.round(l.height)}px`,margin:"0px",transform:"none"};return{sourceAnchor:jt(t),styleDelta:c,runtimeLocks:W,parentAnchor:jt(e),parentNeedsRelative:o,reactMount:i,aiContext:{sourceTag:t.tagName.toLowerCase(),sourceTextHint:(t.textContent||"").trim().slice(0,40),parentTag:e.tagName.toLowerCase(),parentNeedsRelative:o,preDragGeometry:{w:Math.round(l.width),h:Math.round(l.height)},neighbors:te(e,t),preDragLayout:p?{display:p.display,position:p.position,flex:p.flex,flexGrow:p.flexGrow,flexBasis:p.flexBasis,gridArea:p.gridArea,gridColumn:p.gridColumn,gridRow:p.gridRow,width:p.width,height:p.height,margin:p.margin,transform:p.transform}:null,hint:"free-position (absolute). User intent = position/left/top ONLY. preDragLayout shows source's pre-drag computed styles for your decision on whether additional width/height locks are needed to preserve geometry."}}}function te(t,e){if(!t)return[];const n=[];for(const r of t.children){if(!r||r.nodeType!==1||r===e)continue;It(r);const i=r.getBoundingClientRect();n.push({anchor:jt(r),tag:r.tagName.toLowerCase(),rect:{w:Math.round(i.width),h:Math.round(i.height)}})}return n}function Br({sourceEl:t,targetContainer:e,beforeEl:n,intent:r="sibling-before",alignmentHints:i=[]}){if(!t||!e)return null;It(t),It(e),n&&It(n);const s=pt(t)||pt(e),a=t.parentElement,o=te(a,t),l=e===a?o:te(e,t);return{sourceAnchor:jt(t),move:{container:jt(e),before:n?jt(n):null,intent:r},reactMount:s,aiContext:{sourceTag:t.tagName.toLowerCase(),sourceTextHint:(t.textContent||"").trim().slice(0,40),targetContainerTag:e.tagName.toLowerCase(),targetTextHint:(e.textContent||"").trim().slice(0,60),intent:r,alignmentHints:i,neighbors:{sourceParent:o,targetContainer:l}}}}const Rr="rgba(45, 36, 24, 0.85)",mt=gt.blue,$e=gt.magenta,Kr=gt.blue,Gr=3;function oo({active:t,iframeRef:e,zoom:n=1,freeMode:r=!1,onFreeModeChange:i,onCommitMove:s,onCommitFreePosition:a,onCancel:o,apiRef:l,onDraggingChange:u,onSelectionChange:p}){var se,le,ae,ce,ue,Wt,de,fe;const[c,W]=d.useState(null),[O,k]=d.useState(null),[,L]=d.useState(0);d.useEffect(()=>{if(!t)return;const w=e==null?void 0:e.current;if(!w)return;const E=w.contentWindow;if(!E)return;let B=null;const tt=()=>{B||(B=requestAnimationFrame(()=>{B=null,L(P=>P+1)}))};try{E.addEventListener("scroll",tt,{passive:!0,capture:!0}),E.addEventListener("resize",tt),window.addEventListener("resize",tt)}catch{}return()=>{try{E.removeEventListener("scroll",tt,{capture:!0}),E.removeEventListener("resize",tt),window.removeEventListener("resize",tt)}catch{}B&&cancelAnimationFrame(B)}},[t,e]),d.useEffect(()=>{if(!t)return;const w=e==null?void 0:e.current;if(!w)return;const E=_r(w);if(!E)return;const B=E.body;if(!B)return;const tt=B.style.userSelect;B.style.userSelect="none";let P={source:null,startX:0,startY:0,started:!1,altKey:!1,autoFree:!1};const dt=H=>{var nt;if(H.button!==0)return;const et=H.target;if(!et||et.nodeType!==1||et===B||et===E.documentElement)return;const V=Fe(et,B);if(!V)return;H.preventDefault(),H.stopPropagation();let lt=!1;try{const it=E.defaultView.getComputedStyle(V).position;lt=it==="absolute"||it==="fixed"}catch{}P={source:V,startX:H.clientX,startY:H.clientY,started:!1,altKey:H.altKey,autoFree:lt},(nt=X.current)==null||nt.call(X,!0)},At=(H,et,V)=>{var nt;if(!H)return;const lt=Pe(w,et,V,n);P={source:H,startX:lt.x,startY:lt.y,started:!1,altKey:!1,autoFree:!1},(nt=X.current)==null||nt.call(X,!0)};l&&(l.current={startDrag:At,pickDragSource:Fe});const zt=H=>{if(!P.source)return;let et,V;if(H.view===w.contentWindow)et=H.clientX,V=H.clientY;else{const st=Pe(w,H.clientX,H.clientY,n);et=st.x,V=st.y}const lt=et-P.startX,nt=V-P.startY;if(!P.started){if(Math.hypot(lt,nt)<Gr)return;P.started=!0}H.preventDefault();const it=P.source.getBoundingClientRect();let _={left:it.left+lt,top:it.top+nt,right:it.right+lt,bottom:it.bottom+nt,width:it.width,height:it.height};H.shiftKey&&(_=Hr(_,it,lt,nt));const bt=_.left+_.width/2,Mt=_.top+_.height/2,Et=C.current||P.autoFree;let ht=null,at=null,ut=[],xt=[];if(Z.current=H,Et){const st=P.source.parentElement;if(st){const ft=Jt(st,P.source);ut=Te(_,ft),xt=Ae(_,ft)}}else{const st=P.source.style.pointerEvents;P.source.style.pointerEvents="none";const ft=E.elementFromPoint(bt,Mt);if(P.source.style.pointerEvents=st,ht=ft?Ar(ft,P.source,B):null,ht){at=Pr(ht.container,ft,P.source,{x:bt,y:Mt});const $t=Jt(ht.container,P.source);if(ut=Te(_,$t),xt=Ae(_,$t),at&&at.intent==="child-of"){const Lt=at.hitChild,Dt=Date.now();y.current===Lt||(x.current.hitChild===Lt?Dt-x.current.ts>=150?y.current=Lt:at=De(at):(x.current={hitChild:Lt,ts:Dt},y.current=null,at=De(at),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{S.current=null,P.source&&Z.current&&zt(Z.current)},160)))}else x.current={hitChild:null,ts:0},y.current=null,S.current&&(clearTimeout(S.current),S.current=null)}}ut.length>0&&(_=Nr(_,ut,3));let yt=[];if(Et){const st=P.source.parentElement;if(st){const ft=Jt(st,P.source);yt=Wr(_,ft)}}W({source:P.source,sourceRect:it,ghostRect:_,dropTarget:ht,dropIntent:at,alignGuides:ut,distanceLabels:xt,smartSpacing:yt,reactMount:pt(P.source),freeMode:Et,autoFree:P.autoFree,duplicate:P.altKey})},Bt=H=>{var xt,yt,st,ft,$t,Lt,Dt;if(!P.source)return;const et=P.started,V=P.source,lt=et?A.current:null,nt=et?T.current:null,it=et?I.current:[],_=et?j.current:null,bt=C.current||P.autoFree,Mt=P.altKey;if(P={source:null,startX:0,startY:0,started:!1,altKey:!1,autoFree:!1},W(null),(xt=X.current)==null||xt.call(X,!1),!et)return;if(bt&&_){const vt=V.parentElement;if(!vt){(yt=q.current)==null||yt.call(q);return}const pe=vt.getBoundingClientRect(),he=Math.round(_.left-pe.left),ge=Math.round(_.top-pe.top),be=ze({sourceEl:V,parentEl:vt,left:he,top:ge});be&&((st=R.current)==null||st.call(R,be,{sourceEl:V,parentEl:vt,left:he,top:ge}),K.current=V,(ft=g.current)==null||ft.call(g,V),requestAnimationFrame(()=>{try{k({rect:V.getBoundingClientRect(),ts:Date.now()}),setTimeout(()=>k(null),350)}catch{}}));return}if(!lt||!nt){($t=q.current)==null||$t.call(q);return}const Et=it.map(vt=>Vr(vt)),ht=nt.targetContainer,at=nt.beforeEl,ut=Br({sourceEl:V,targetContainer:ht,beforeEl:at,intent:nt.intent,alignmentHints:Et});ut&&(Mt&&(ut.duplicate=!0),(Lt=z.current)==null||Lt.call(z,ut,{sourceEl:V,targetContainer:ht,beforeEl:at,duplicate:Mt}),K.current=V,(Dt=g.current)==null||Dt.call(g,V),requestAnimationFrame(()=>{try{const vt=V.getBoundingClientRect();k({rect:vt,ts:Date.now()}),setTimeout(()=>k(null),350)}catch{}}))},Rt=H=>{var V,lt,nt,it;if(H.key==="Escape"&&P.source){H.preventDefault(),P={source:null,startX:0,startY:0,started:!1,altKey:!1,autoFree:!1},W(null),(V=X.current)==null||V.call(X,!1),(lt=q.current)==null||lt.call(q);return}if((H.key==="p"||H.key==="P")&&!H.metaKey&&!H.ctrlKey&&!H.altKey){H.preventDefault(),(nt=h.current)==null||nt.call(h,!C.current);return}if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(H.key)&&K.current&&C.current){const _=K.current;if(!_.isConnected){K.current=null;return}H.preventDefault();const bt=H.shiftKey?10:1,Mt=H.key==="ArrowLeft"?-bt:H.key==="ArrowRight"?bt:0,Et=H.key==="ArrowUp"?-bt:H.key==="ArrowDown"?bt:0,ht=parseFloat(_.style.left)||0,at=parseFloat(_.style.top)||0,ut=Math.round(ht+Mt),xt=Math.round(at+Et),yt=_.parentElement,st=ze({sourceEl:_,parentEl:yt,left:ut,top:xt});st&&((it=R.current)==null||it.call(R,st,{sourceEl:_,parentEl:yt,left:ut,top:xt}))}};return E.addEventListener("mousedown",dt,!0),window.addEventListener("mousemove",zt,!0),window.addEventListener("mouseup",Bt,!0),window.addEventListener("keydown",Rt),E.addEventListener("mousemove",zt,!0),E.addEventListener("mouseup",Bt,!0),E.addEventListener("keydown",Rt,!0),()=>{try{E.removeEventListener("mousedown",dt,!0),window.removeEventListener("mousemove",zt,!0),window.removeEventListener("mouseup",Bt,!0),window.removeEventListener("keydown",Rt),E.removeEventListener("mousemove",zt,!0),E.removeEventListener("mouseup",Bt,!0),E.removeEventListener("keydown",Rt,!0)}catch{}B.style.userSelect=tt,l&&(l.current=null),S.current&&(clearTimeout(S.current),S.current=null),x.current={hitChild:null,ts:0},y.current=null}},[t,n]);const A=d.useRef(null),T=d.useRef(null),I=d.useRef([]),j=d.useRef(null),C=d.useRef(!1),x=d.useRef({hitChild:null,ts:0}),y=d.useRef(null),S=d.useRef(null),Z=d.useRef(null),K=d.useRef(null),z=d.useRef(s),R=d.useRef(a),q=d.useRef(o),X=d.useRef(u),g=d.useRef(p),h=d.useRef(i);if(z.current=s,R.current=a,q.current=o,X.current=u,g.current=p,h.current=i,d.useEffect(()=>{A.current=(c==null?void 0:c.dropTarget)||null,T.current=(c==null?void 0:c.dropIntent)||null,I.current=(c==null?void 0:c.alignGuides)||[],j.current=(c==null?void 0:c.ghostRect)||null},[c]),d.useEffect(()=>{C.current=r},[r]),!t||!(e!=null&&e.current))return null;const D=e.current;D.getBoundingClientRect();const U=Ct(D);if(!U)return null;const Y=(w,E,B,tt)=>({top:U.y+E*n,left:U.x+w*n,width:B*n,height:tt*n});if(!c){const w=O?(()=>{const E=Y(O.rect.left,O.rect.top,O.rect.width,O.rect.height);return f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:E.top-4,left:E.left-4,width:E.width+8,height:E.height+8,border:`3px solid ${mt}`,borderRadius:N.sm,background:"rgba(58, 122, 254, 0.12)",boxShadow:"0 0 16px rgba(58, 122, 254, 0.5)",zIndex:25,animation:"nd-drag-landing-flash 350ms ease-out forwards"}})})():null;return f.jsxs(f.Fragment,{children:[w,w&&f.jsx("style",{children:`
22
22
  @keyframes nd-drag-landing-flash {
23
23
  0% { opacity: 1; transform: scale(1.02); }
24
24
  100% { opacity: 0; transform: scale(1); }
25
25
  }
26
- `})]})}const ot=Y(c.ghostRect.left,c.ghostRect.top,c.ghostRect.width,c.ghostRect.height),$=Y(c.sourceRect.left,c.sourceRect.top,c.sourceRect.width,c.sourceRect.height),v=(se=c.dropIntent)==null?void 0:se.intent,M=v==="child-of",F=c.dropTarget&&c.source&&((le=c.dropIntent)==null?void 0:le.targetContainer)===c.source.parentElement;let Q=null;if(!M&&((ae=c.dropIntent)!=null&&ae.caretRect)){const w=c.dropIntent.caretRect,E=c.sourceRect.width,B=c.sourceRect.height;let tt,P,dt,At;w.vertical?(tt=w.x-E/2,P=w.y,dt=E,At=w.h):(tt=w.x,P=w.y-B/2,dt=w.w,At=B),Q=Y(tt,P,dt,At)}let Z=null,ie=null;if(M&&((ce=c.dropIntent)!=null&&ce.zoneRect)){const w=c.dropIntent.zoneRect;Z=Y(w.x,w.y,w.w,w.h),ie=((de=(Wt=(ue=c.dropIntent.hitChild)==null?void 0:ue.tagName)==null?void 0:Wt.toLowerCase)==null?void 0:de.call(Wt))||"container"}return f.jsxs(f.Fragment,{children:[f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:$.top,left:$.left,width:$.width,height:$.height,border:`2px dashed rgba(45, 36, 24, ${F?.18:.3})`,borderRadius:N.sm,zIndex:20,opacity:F?.5:1}}),f.jsxs("div",{style:{position:"absolute",pointerEvents:"none",top:ot.top,left:ot.left,width:ot.width,height:ot.height,background:c.freeMode?"rgba(20, 184, 166, 0.10)":"rgba(58, 122, 254, 0.08)",border:`2px solid ${c.freeMode?gt.teal:Rr}`,borderRadius:N.sm,boxShadow:c.freeMode?"0 8px 24px rgba(20, 184, 166, 0.30)":"0 8px 24px rgba(0,0,0,0.18)",zIndex:30,opacity:.92},children:[c.freeMode&&f.jsx("div",{style:{position:"absolute",top:-22,left:0,padding:`${b.xxs}px ${b.md}px`,fontSize:G.xs,lineHeight:"14px",fontWeight:600,fontFamily:rt,color:m.bgWhite,background:gt.teal,borderRadius:N.xs,whiteSpace:"nowrap",boxShadow:Qt.crisp},children:c.autoFree?"📌 绝对定位元素 · 拖动改坐标,不动 DOM 结构":"📌 自由模式 · 落到像素位置(再按 P 切回)"}),!c.freeMode&&c.reactMount&&f.jsx("div",{style:{position:"absolute",top:-22,left:0,padding:`${b.xxs}px ${b.sm}px`,fontSize:G.xs,lineHeight:"14px",fontFamily:rt,color:m.bgWhite,background:m.warn,borderRadius:N.xs,whiteSpace:"nowrap"},children:"React 区 · 落地改 JSX"}),c.duplicate&&f.jsx("div",{style:{position:"absolute",top:-22,right:0,padding:`${b.xxs}px ${b.md}px`,fontSize:G.xs,lineHeight:"14px",fontWeight:600,fontFamily:rt,color:m.bgWhite,background:gt.violet,borderRadius:N.xs,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(139,92,246,0.4)"},children:"⊕ 复制 (Alt-drag)"}),!c.freeMode&&f.jsx("div",{style:{position:"absolute",bottom:-20,right:0,padding:`1px ${b.sm}px`,fontSize:G.xxs,lineHeight:"14px",fontFamily:rt,color:"rgba(255,255,255,0.75)",background:"rgba(45,36,24,0.7)",borderRadius:N.xs,whiteSpace:"nowrap"},children:c.duplicate?"松开 Alt 取消复制":"按 P 切自由 · Alt 复制"})]}),!c.freeMode&&c.dropTarget&&(()=>{const w=c.dropTarget.container.getBoundingClientRect(),E=Y(w.left,w.top,w.width,w.height),B=M;return f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:E.top-2,left:E.left-2,width:E.width+4,height:E.height+4,border:F?`1px dashed ${mt}`:`${B?3:2}px solid ${mt}`,borderRadius:N.sm,background:F?"transparent":`rgba(58, 122, 254, ${B?.1:.04})`,zIndex:18,opacity:F?.45:1}})})(),!c.freeMode&&M&&Z&&f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:Z.top-3,left:Z.left-3,width:Z.width+6,height:Z.height+6,border:`3px solid ${mt}`,background:"rgba(58, 122, 254, 0.14)",borderRadius:5,zIndex:33},children:f.jsxs("div",{style:{position:"absolute",top:-24,left:"50%",transform:"translateX(-50%)",padding:`3px ${b.base}px`,fontSize:G.sm,lineHeight:"14px",fontWeight:600,fontFamily:rt,color:m.bgWhite,background:mt,borderRadius:N.sm,whiteSpace:"nowrap",boxShadow:"0 2px 6px rgba(58, 122, 254, 0.4)"},children:["进入 <",ie,"> 内"]})}),!c.freeMode&&!M&&Q&&f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:Q.top,left:Q.left,width:Q.width,height:Q.height,border:`2px dashed ${mt}`,background:"rgba(58, 122, 254, 0.10)",borderRadius:N.xs,zIndex:32},children:F&&f.jsx("div",{style:{position:"absolute",top:-22,left:"50%",transform:"translateX(-50%)",padding:`${b.xxs}px ${b.md}px`,fontSize:G.xs,lineHeight:"14px",fontWeight:600,fontFamily:rt,color:m.bgWhite,background:mt,borderRadius:N.xs,whiteSpace:"nowrap",boxShadow:Qt.crisp},children:v==="sibling-before"?"插到此 sibling 之前":"插到此 sibling 之后"})}),!c.freeMode&&!M&&((fe=c.dropIntent)==null?void 0:fe.caretRect)&&(()=>{const w=c.dropIntent.caretRect,E=Y(w.x,w.y,w.w,w.h);return f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:E.top,left:E.left,width:Math.max(E.width,2),height:Math.max(E.height,2),background:mt,boxShadow:"0 0 0 2px rgba(58, 122, 254, 0.25)",borderRadius:1,zIndex:35}})})(),c.alignGuides&&c.alignGuides.map((w,E)=>{if(w.axis==="x"){const tt=Y(w.value,0,0,9999);return f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:0,left:tt.left,width:1,height:"100%",borderLeft:`1px dashed ${$e}`,zIndex:28}},E)}const B=Y(0,w.value,9999,0);return f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:B.top,left:0,width:"100%",height:1,borderTop:`1px dashed ${$e}`,zIndex:28}},E)}),c.smartSpacing&&c.smartSpacing.map((w,E)=>{const B=w.side==="horizontal",tt=B?c.ghostRect.left-30:c.ghostRect.left+c.ghostRect.width/2-30,P=B?c.ghostRect.top+c.ghostRect.height/2-8:c.ghostRect.top-22,dt=Y(tt,P,60,16);return f.jsxs("div",{style:{position:"absolute",pointerEvents:"none",top:dt.top,left:dt.left,width:dt.width,height:dt.height,background:gt.green,color:m.bgWhite,borderRadius:N.xs,fontFamily:rt,fontSize:G.xs,lineHeight:"16px",textAlign:"center",fontWeight:600,boxShadow:"0 1px 3px rgba(22,163,74,0.3)",zIndex:37},children:["等距 ",w.gap]},`spc-${E}`)}),c.distanceLabels&&c.distanceLabels.map((w,E)=>{const B=Y(w.labelRect.x,w.labelRect.y,w.labelRect.w,w.labelRect.h);return f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:B.top,left:B.left,width:B.width,height:B.height,background:Kr,color:m.bgWhite,borderRadius:2,fontFamily:rt,fontSize:G.xs,lineHeight:"16px",textAlign:"center",fontWeight:500,zIndex:36},children:Math.round(w.gap)},E)})]})}function De(t){if(!t||!t.hitChild)return t;const e=t.hitChild.getBoundingClientRect(),n=t.horizontal;return{intent:"sibling-after",targetContainer:t.hitChild.parentElement,beforeEl:t.hitChild.nextElementSibling||null,hitChild:t.hitChild,caretRect:n?{x:e.right-1,y:e.top,w:2,h:e.height,vertical:!0}:{x:e.left,y:e.bottom-1,w:e.width,h:2,vertical:!1},zoneRect:null,horizontal:n}}function _r(t){var e;try{return(t==null?void 0:t.contentDocument)||((e=t==null?void 0:t.contentWindow)==null?void 0:e.document)||null}catch{return null}}function Pe(t,e,n,r){if(!t)return{x:e,y:n};const i=t.getBoundingClientRect(),s=r||1,a=t.contentWindow,o=(a==null?void 0:a.scrollX)||0,l=(a==null?void 0:a.scrollY)||0;return{x:(e-i.left)/s+o,y:(n-i.top)/s+l}}function Fe(t,e){let n=t;for(;n&&n.nodeType===1&&n!==e;){if(n===e.ownerDocument.documentElement)return null;const r=n.ownerDocument.defaultView;if(!r)return null;const s=r.getComputedStyle(n).display,a=n.getBoundingClientRect(),o=s&&(s==="block"||s==="flex"||s==="grid"||s==="inline-block"||s==="inline-flex"||s==="inline-grid"||s==="list-item"||s==="table"||s==="table-cell"),l=a.width>=20&&a.height>=20;if(n.tagName==="SECTION"&&n.hasAttribute("data-page"))return null;if(o&&l)return n;n=n.parentElement}return null}function Vr(t){var r,i,s;const e={"edge-left":"左对齐","edge-right":"右对齐","center-x":"水平居中","edge-top":"顶部对齐","edge-bottom":"底部对齐","center-y":"垂直居中"},n=((s=(i=(r=t.neighbor)==null?void 0:r.tagName)==null?void 0:i.toLowerCase)==null?void 0:s.call(i))||"邻居";return`${e[t.hint]||t.hint}(与 ${n})`}const Xr=gt.blue,Yr=m.warn;function io({active:t,iframeRef:e,zoom:n=1,pickDragSource:r,isDragging:i}){var j;const[s,a]=d.useState(null);d.useRef(null);const o=d.useRef(null),[,l]=d.useState(0),u=()=>{o.current&&(clearTimeout(o.current),o.current=null)},p=()=>{u(),o.current=setTimeout(()=>a(null),200)};if(d.useEffect(()=>{if(!t)return;const C=e==null?void 0:e.current;if(!C)return;const x=C.contentWindow;if(!x)return;let y=null;const S=()=>{y||(y=requestAnimationFrame(()=>{y=null,l(J=>J+1)}))};try{x.addEventListener("scroll",S,{passive:!0,capture:!0}),x.addEventListener("resize",S),window.addEventListener("resize",S)}catch{}return()=>{try{x.removeEventListener("scroll",S,{capture:!0}),x.removeEventListener("resize",S),window.removeEventListener("resize",S)}catch{}y&&cancelAnimationFrame(y)}},[t,e]),d.useEffect(()=>{if(!t||i){a(null);return}const C=e==null?void 0:e.current;if(!C)return;const x=C.contentDocument;if(!x)return;const y=x.body;if(!y)return;const S=K=>{const z=K.target;if(!z||z.nodeType!==1||z===y||z===x.documentElement){p();return}const R=r(z,y);if(!R){p();return}u(),a({source:R,rect:R.getBoundingClientRect(),reactMount:pt(R)})},J=()=>p();return x.addEventListener("mousemove",S,!0),x.addEventListener("mouseleave",J),()=>{try{x.removeEventListener("mousemove",S,!0),x.removeEventListener("mouseleave",J)}catch{}u()}},[t,e,r,i]),!t||!s||i||!(e!=null&&e.current))return null;const c=e.current,W=Ct(c);if(!W)return null;const k=s.rect,O=s.reactMount?Yr:Xr,L=W.y+k.top*n-2,A=W.x+k.left*n-2,T=k.width*n+4,I=k.height*n+4;return f.jsxs(f.Fragment,{children:[f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:L,left:A,width:T,height:I,border:`2px dashed ${O}`,borderRadius:N.sm,background:s.reactMount?"rgba(184,92,26,0.04)":"rgba(58,122,254,0.04)",boxShadow:`0 0 0 1px ${s.reactMount?"rgba(184,92,26,0.15)":"rgba(58,122,254,0.15)"}`,zIndex:8}}),f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:L-18,left:A,padding:`1px ${b.sm}px`,fontFamily:rt,fontSize:G.xxs,lineHeight:"14px",fontWeight:500,color:m.bgWhite,background:O,borderRadius:N.xs,whiteSpace:"nowrap",boxShadow:`0 1px 3px ${s.reactMount?"rgba(184,92,26,0.3)":"rgba(58,122,254,0.3)"}`,zIndex:9},children:s.reactMount?"⊕ 拖动(React 区·改 JSX)":"⊕ 拖动 "+(((j=s.source.tagName)==null?void 0:j.toLowerCase())||"")})]})}const He=260,qr=180;function so({active:t,iframeRef:e,zoom:n=1,sourceEl:r,hasPendingEditId:i,onSubmit:s,onDismiss:a}){const[o,l]=d.useState(""),[u,p]=d.useState(!1),c=d.useRef(null),[,W]=d.useState(0);if(d.useEffect(()=>{l("")},[r]),d.useEffect(()=>{if(!t||!(e!=null&&e.current))return;const C=e.current.contentWindow;if(!C)return;let x=null;const y=()=>{x||(x=requestAnimationFrame(()=>{x=null,W(S=>S+1)}))};try{C.addEventListener("scroll",y,{passive:!0,capture:!0}),C.addEventListener("resize",y),window.addEventListener("resize",y)}catch{}return()=>{try{C.removeEventListener("scroll",y,{capture:!0}),C.removeEventListener("resize",y),window.removeEventListener("resize",y)}catch{}x&&cancelAnimationFrame(x)}},[t,e]),d.useEffect(()=>{if(!t)return;const j=C=>{C.key==="Escape"&&(C.preventDefault(),a==null||a())};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[t,a]),!t||!r||!r.isConnected||!(e!=null&&e.current))return null;const k=Ct(e.current);if(!k)return null;const O=r.getBoundingClientRect(),{left:L,top:A}=Re(k,O,n,{cardWidth:He,cardHeight:qr,offset:10}),T=async()=>{if(!(!o.trim()||u)){p(!0);try{const j=jt(r);await(s==null?void 0:s(j,o)),l(""),a==null||a()}finally{p(!1)}}},I=j=>{if(j.key==="Enter"&&(j.metaKey||j.ctrlKey)){if(re(j))return;j.preventDefault(),T()}};return f.jsxs("div",{style:{position:"absolute",top:A,left:L,width:He,background:"rgba(255,255,255,0.99)",border:`1px solid ${m.borderHv}`,borderRadius:N.lg,boxShadow:"0 8px 24px rgba(0,0,0,0.15)",padding:b.md,zIndex:45,fontFamily:rt,pointerEvents:"auto"},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:b.sm},children:[f.jsx("span",{style:{fontSize:G.xxs,color:"rgba(45,36,24,0.6)",textTransform:"uppercase",letterSpacing:.5},children:"可选备注 · 默认最小改动"}),f.jsx("button",{onClick:()=>a==null?void 0:a(),title:"关闭(Esc)",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:16,padding:0,background:"transparent",border:"none",color:"rgba(45,36,24,0.4)",cursor:"pointer",borderRadius:N.xs},children:f.jsx(ne,{size:11})})]}),f.jsx("textarea",{ref:c,value:o,onChange:j=>l(j.target.value),onKeyDown:I,autoFocus:!1,placeholder:`agent 落地时默认:
26
+ `})]})}const ot=Y(c.ghostRect.left,c.ghostRect.top,c.ghostRect.width,c.ghostRect.height),$=Y(c.sourceRect.left,c.sourceRect.top,c.sourceRect.width,c.sourceRect.height),v=(se=c.dropIntent)==null?void 0:se.intent,M=v==="child-of",F=c.dropTarget&&c.source&&((le=c.dropIntent)==null?void 0:le.targetContainer)===c.source.parentElement;let Q=null;if(!M&&((ae=c.dropIntent)!=null&&ae.caretRect)){const w=c.dropIntent.caretRect,E=c.sourceRect.width,B=c.sourceRect.height;let tt,P,dt,At;w.vertical?(tt=w.x-E/2,P=w.y,dt=E,At=w.h):(tt=w.x,P=w.y-B/2,dt=w.w,At=B),Q=Y(tt,P,dt,At)}let J=null,ie=null;if(M&&((ce=c.dropIntent)!=null&&ce.zoneRect)){const w=c.dropIntent.zoneRect;J=Y(w.x,w.y,w.w,w.h),ie=((de=(Wt=(ue=c.dropIntent.hitChild)==null?void 0:ue.tagName)==null?void 0:Wt.toLowerCase)==null?void 0:de.call(Wt))||"container"}return f.jsxs(f.Fragment,{children:[f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:$.top,left:$.left,width:$.width,height:$.height,border:`2px dashed rgba(45, 36, 24, ${F?.18:.3})`,borderRadius:N.sm,zIndex:20,opacity:F?.5:1}}),f.jsxs("div",{style:{position:"absolute",pointerEvents:"none",top:ot.top,left:ot.left,width:ot.width,height:ot.height,background:c.freeMode?"rgba(20, 184, 166, 0.10)":"rgba(58, 122, 254, 0.08)",border:`2px solid ${c.freeMode?gt.teal:Rr}`,borderRadius:N.sm,boxShadow:c.freeMode?"0 8px 24px rgba(20, 184, 166, 0.30)":"0 8px 24px rgba(0,0,0,0.18)",zIndex:30,opacity:.92},children:[c.freeMode&&f.jsx("div",{style:{position:"absolute",top:-22,left:0,padding:`${b.xxs}px ${b.md}px`,fontSize:G.xs,lineHeight:"14px",fontWeight:600,fontFamily:rt,color:m.bgWhite,background:gt.teal,borderRadius:N.xs,whiteSpace:"nowrap",boxShadow:Qt.crisp},children:c.autoFree?"📌 绝对定位元素 · 拖动改坐标,不动 DOM 结构":"📌 自由模式 · 落到像素位置(再按 P 切回)"}),!c.freeMode&&c.reactMount&&f.jsx("div",{style:{position:"absolute",top:-22,left:0,padding:`${b.xxs}px ${b.sm}px`,fontSize:G.xs,lineHeight:"14px",fontFamily:rt,color:m.bgWhite,background:m.warn,borderRadius:N.xs,whiteSpace:"nowrap"},children:"React 区 · 落地改 JSX"}),c.duplicate&&f.jsx("div",{style:{position:"absolute",top:-22,right:0,padding:`${b.xxs}px ${b.md}px`,fontSize:G.xs,lineHeight:"14px",fontWeight:600,fontFamily:rt,color:m.bgWhite,background:gt.violet,borderRadius:N.xs,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(139,92,246,0.4)"},children:"⊕ 复制 (Alt-drag)"}),!c.freeMode&&f.jsx("div",{style:{position:"absolute",bottom:-20,right:0,padding:`1px ${b.sm}px`,fontSize:G.xxs,lineHeight:"14px",fontFamily:rt,color:"rgba(255,255,255,0.75)",background:"rgba(45,36,24,0.7)",borderRadius:N.xs,whiteSpace:"nowrap"},children:c.duplicate?"松开 Alt 取消复制":"按 P 切自由 · Alt 复制"})]}),!c.freeMode&&c.dropTarget&&(()=>{const w=c.dropTarget.container.getBoundingClientRect(),E=Y(w.left,w.top,w.width,w.height),B=M;return f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:E.top-2,left:E.left-2,width:E.width+4,height:E.height+4,border:F?`1px dashed ${mt}`:`${B?3:2}px solid ${mt}`,borderRadius:N.sm,background:F?"transparent":`rgba(58, 122, 254, ${B?.1:.04})`,zIndex:18,opacity:F?.45:1}})})(),!c.freeMode&&M&&J&&f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:J.top-3,left:J.left-3,width:J.width+6,height:J.height+6,border:`3px solid ${mt}`,background:"rgba(58, 122, 254, 0.14)",borderRadius:5,zIndex:33},children:f.jsxs("div",{style:{position:"absolute",top:-24,left:"50%",transform:"translateX(-50%)",padding:`3px ${b.base}px`,fontSize:G.sm,lineHeight:"14px",fontWeight:600,fontFamily:rt,color:m.bgWhite,background:mt,borderRadius:N.sm,whiteSpace:"nowrap",boxShadow:"0 2px 6px rgba(58, 122, 254, 0.4)"},children:["进入 <",ie,"> 内"]})}),!c.freeMode&&!M&&Q&&f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:Q.top,left:Q.left,width:Q.width,height:Q.height,border:`2px dashed ${mt}`,background:"rgba(58, 122, 254, 0.10)",borderRadius:N.xs,zIndex:32},children:F&&f.jsx("div",{style:{position:"absolute",top:-22,left:"50%",transform:"translateX(-50%)",padding:`${b.xxs}px ${b.md}px`,fontSize:G.xs,lineHeight:"14px",fontWeight:600,fontFamily:rt,color:m.bgWhite,background:mt,borderRadius:N.xs,whiteSpace:"nowrap",boxShadow:Qt.crisp},children:v==="sibling-before"?"插到此 sibling 之前":"插到此 sibling 之后"})}),!c.freeMode&&!M&&((fe=c.dropIntent)==null?void 0:fe.caretRect)&&(()=>{const w=c.dropIntent.caretRect,E=Y(w.x,w.y,w.w,w.h);return f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:E.top,left:E.left,width:Math.max(E.width,2),height:Math.max(E.height,2),background:mt,boxShadow:"0 0 0 2px rgba(58, 122, 254, 0.25)",borderRadius:1,zIndex:35}})})(),c.alignGuides&&c.alignGuides.map((w,E)=>{if(w.axis==="x"){const tt=Y(w.value,0,0,9999);return f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:0,left:tt.left,width:1,height:"100%",borderLeft:`1px dashed ${$e}`,zIndex:28}},E)}const B=Y(0,w.value,9999,0);return f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:B.top,left:0,width:"100%",height:1,borderTop:`1px dashed ${$e}`,zIndex:28}},E)}),c.smartSpacing&&c.smartSpacing.map((w,E)=>{const B=w.side==="horizontal",tt=B?c.ghostRect.left-30:c.ghostRect.left+c.ghostRect.width/2-30,P=B?c.ghostRect.top+c.ghostRect.height/2-8:c.ghostRect.top-22,dt=Y(tt,P,60,16);return f.jsxs("div",{style:{position:"absolute",pointerEvents:"none",top:dt.top,left:dt.left,width:dt.width,height:dt.height,background:gt.green,color:m.bgWhite,borderRadius:N.xs,fontFamily:rt,fontSize:G.xs,lineHeight:"16px",textAlign:"center",fontWeight:600,boxShadow:"0 1px 3px rgba(22,163,74,0.3)",zIndex:37},children:["等距 ",w.gap]},`spc-${E}`)}),c.distanceLabels&&c.distanceLabels.map((w,E)=>{const B=Y(w.labelRect.x,w.labelRect.y,w.labelRect.w,w.labelRect.h);return f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:B.top,left:B.left,width:B.width,height:B.height,background:Kr,color:m.bgWhite,borderRadius:2,fontFamily:rt,fontSize:G.xs,lineHeight:"16px",textAlign:"center",fontWeight:500,zIndex:36},children:Math.round(w.gap)},E)})]})}function De(t){if(!t||!t.hitChild)return t;const e=t.hitChild.getBoundingClientRect(),n=t.horizontal;return{intent:"sibling-after",targetContainer:t.hitChild.parentElement,beforeEl:t.hitChild.nextElementSibling||null,hitChild:t.hitChild,caretRect:n?{x:e.right-1,y:e.top,w:2,h:e.height,vertical:!0}:{x:e.left,y:e.bottom-1,w:e.width,h:2,vertical:!1},zoneRect:null,horizontal:n}}function _r(t){var e;try{return(t==null?void 0:t.contentDocument)||((e=t==null?void 0:t.contentWindow)==null?void 0:e.document)||null}catch{return null}}function Pe(t,e,n,r){if(!t)return{x:e,y:n};const i=t.getBoundingClientRect(),s=r||1,a=t.contentWindow,o=(a==null?void 0:a.scrollX)||0,l=(a==null?void 0:a.scrollY)||0;return{x:(e-i.left)/s+o,y:(n-i.top)/s+l}}function Fe(t,e){let n=t;for(;n&&n.nodeType===1&&n!==e;){if(n===e.ownerDocument.documentElement)return null;const r=n.ownerDocument.defaultView;if(!r)return null;const s=r.getComputedStyle(n).display,a=n.getBoundingClientRect(),o=s&&(s==="block"||s==="flex"||s==="grid"||s==="inline-block"||s==="inline-flex"||s==="inline-grid"||s==="list-item"||s==="table"||s==="table-cell"),l=a.width>=20&&a.height>=20;if(n.tagName==="SECTION"&&n.hasAttribute("data-page"))return null;if(o&&l)return n;n=n.parentElement}return null}function Vr(t){var r,i,s;const e={"edge-left":"左对齐","edge-right":"右对齐","center-x":"水平居中","edge-top":"顶部对齐","edge-bottom":"底部对齐","center-y":"垂直居中"},n=((s=(i=(r=t.neighbor)==null?void 0:r.tagName)==null?void 0:i.toLowerCase)==null?void 0:s.call(i))||"邻居";return`${e[t.hint]||t.hint}(与 ${n})`}const Xr=gt.blue,Yr=m.warn;function io({active:t,iframeRef:e,zoom:n=1,pickDragSource:r,isDragging:i}){var j;const[s,a]=d.useState(null);d.useRef(null);const o=d.useRef(null),[,l]=d.useState(0),u=()=>{o.current&&(clearTimeout(o.current),o.current=null)},p=()=>{u(),o.current=setTimeout(()=>a(null),200)};if(d.useEffect(()=>{if(!t)return;const C=e==null?void 0:e.current;if(!C)return;const x=C.contentWindow;if(!x)return;let y=null;const S=()=>{y||(y=requestAnimationFrame(()=>{y=null,l(Z=>Z+1)}))};try{x.addEventListener("scroll",S,{passive:!0,capture:!0}),x.addEventListener("resize",S),window.addEventListener("resize",S)}catch{}return()=>{try{x.removeEventListener("scroll",S,{capture:!0}),x.removeEventListener("resize",S),window.removeEventListener("resize",S)}catch{}y&&cancelAnimationFrame(y)}},[t,e]),d.useEffect(()=>{if(!t||i){a(null);return}const C=e==null?void 0:e.current;if(!C)return;const x=C.contentDocument;if(!x)return;const y=x.body;if(!y)return;const S=K=>{const z=K.target;if(!z||z.nodeType!==1||z===y||z===x.documentElement){p();return}const R=r(z,y);if(!R){p();return}u(),a({source:R,rect:R.getBoundingClientRect(),reactMount:pt(R)})},Z=()=>p();return x.addEventListener("mousemove",S,!0),x.addEventListener("mouseleave",Z),()=>{try{x.removeEventListener("mousemove",S,!0),x.removeEventListener("mouseleave",Z)}catch{}u()}},[t,e,r,i]),!t||!s||i||!(e!=null&&e.current))return null;const c=e.current,W=Ct(c);if(!W)return null;const O=s.rect,k=s.reactMount?Yr:Xr,L=W.y+O.top*n-2,A=W.x+O.left*n-2,T=O.width*n+4,I=O.height*n+4;return f.jsxs(f.Fragment,{children:[f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:L,left:A,width:T,height:I,border:`2px dashed ${k}`,borderRadius:N.sm,background:s.reactMount?"rgba(184,92,26,0.04)":"rgba(58,122,254,0.04)",boxShadow:`0 0 0 1px ${s.reactMount?"rgba(184,92,26,0.15)":"rgba(58,122,254,0.15)"}`,zIndex:8}}),f.jsx("div",{style:{position:"absolute",pointerEvents:"none",top:L-18,left:A,padding:`1px ${b.sm}px`,fontFamily:rt,fontSize:G.xxs,lineHeight:"14px",fontWeight:500,color:m.bgWhite,background:k,borderRadius:N.xs,whiteSpace:"nowrap",boxShadow:`0 1px 3px ${s.reactMount?"rgba(184,92,26,0.3)":"rgba(58,122,254,0.3)"}`,zIndex:9},children:s.reactMount?"⊕ 拖动(React 区·改 JSX)":"⊕ 拖动 "+(((j=s.source.tagName)==null?void 0:j.toLowerCase())||"")})]})}const He=260,qr=180;function so({active:t,iframeRef:e,zoom:n=1,sourceEl:r,hasPendingEditId:i,onSubmit:s,onDismiss:a}){const[o,l]=d.useState(""),[u,p]=d.useState(!1),c=d.useRef(null),[,W]=d.useState(0);if(d.useEffect(()=>{l("")},[r]),d.useEffect(()=>{if(!t||!(e!=null&&e.current))return;const C=e.current.contentWindow;if(!C)return;let x=null;const y=()=>{x||(x=requestAnimationFrame(()=>{x=null,W(S=>S+1)}))};try{C.addEventListener("scroll",y,{passive:!0,capture:!0}),C.addEventListener("resize",y),window.addEventListener("resize",y)}catch{}return()=>{try{C.removeEventListener("scroll",y,{capture:!0}),C.removeEventListener("resize",y),window.removeEventListener("resize",y)}catch{}x&&cancelAnimationFrame(x)}},[t,e]),d.useEffect(()=>{if(!t)return;const j=C=>{C.key==="Escape"&&(C.preventDefault(),a==null||a())};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[t,a]),!t||!r||!r.isConnected||!(e!=null&&e.current))return null;const O=Ct(e.current);if(!O)return null;const k=r.getBoundingClientRect(),{left:L,top:A}=Re(O,k,n,{cardWidth:He,cardHeight:qr,offset:10}),T=async()=>{if(!(!o.trim()||u)){p(!0);try{const j=jt(r);await(s==null?void 0:s(j,o)),l(""),a==null||a()}finally{p(!1)}}},I=j=>{if(j.key==="Enter"&&(j.metaKey||j.ctrlKey)){if(re(j))return;j.preventDefault(),T()}};return f.jsxs("div",{style:{position:"absolute",top:A,left:L,width:He,background:"rgba(255,255,255,0.99)",border:`1px solid ${m.borderHv}`,borderRadius:N.lg,boxShadow:"0 8px 24px rgba(0,0,0,0.15)",padding:b.md,zIndex:45,fontFamily:rt,pointerEvents:"auto"},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:b.sm},children:[f.jsx("span",{style:{fontSize:G.xxs,color:"rgba(45,36,24,0.6)",textTransform:"uppercase",letterSpacing:.5},children:"可选备注 · 默认最小改动"}),f.jsx("button",{onClick:()=>a==null?void 0:a(),title:"关闭(Esc)",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:16,padding:0,background:"transparent",border:"none",color:"rgba(45,36,24,0.4)",cursor:"pointer",borderRadius:N.xs},children:f.jsx(ne,{size:11})})]}),f.jsx("textarea",{ref:c,value:o,onChange:j=>l(j.target.value),onKeyDown:I,autoFocus:!1,placeholder:`agent 落地时默认:
27
27
  · 把你拖到的位置实现到位
28
28
  · 拿邻居信息自己判断,让邻居尽量不动
29
29
  · 保留元素原本的响应式 / 尺寸 / 边距
30
30
 
31
- 如有特殊指令请填……(Cmd+Enter 提交)`,rows:3,style:{width:"100%",padding:b.sm,fontFamily:"inherit",fontSize:G.sm,lineHeight:"15px",color:"rgba(45,36,24,0.9)",background:"rgba(0,0,0,0.02)",border:`1px solid ${m.borderMd}`,borderRadius:N.sm,resize:"vertical",outline:"none",boxSizing:"border-box"}}),f.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:b.sm,gap:b.xs},children:f.jsxs("button",{onClick:T,disabled:!o.trim()||u||!i,title:i?o.trim()?"关联到本次调整 (Cmd+Enter)":"请填写备注内容":"没有关联的 pending edit(请先拖一次元素)",style:{display:"inline-flex",alignItems:"center",gap:3,padding:`${b.xs}px ${b.base}px`,fontFamily:"inherit",fontSize:G.xs,fontWeight:600,color:m.bgWhite,background:gt.blue,border:"none",borderRadius:N.sm,cursor:!o.trim()||u||!i?"not-allowed":"pointer",opacity:!o.trim()||u||!i?.4:1,boxShadow:"0 1px 3px rgba(58,122,254,0.25)"},children:[f.jsx(We,{size:10})," ",u?"提交中…":"关联备注"]})})]})}function lo({iframeDoc:t,sourceEl:e,targetContainer:n,beforeEl:r}){if(!t||!e||!n)return{applied:"marker-only",markerInfo:{reason:"invalid"},revert:()=>{}};if(pt(e)||pt(n))return{applied:"marker-only",markerInfo:{reason:"react-mount",sourceRect:e.getBoundingClientRect(),targetRect:n.getBoundingClientRect()},revert:()=>{}};const i=e.parentElement,s=e.nextElementSibling;try{return r&&r.parentNode===n?n.insertBefore(e,r):n.appendChild(e),{applied:"dom",revert:()=>Ur({sourceEl:e,originalParent:i,originalNextSibling:s})}}catch(a){return{applied:"marker-only",markerInfo:{reason:"dom-error",message:a.message},revert:()=>{}}}}function ao({sourceEl:t,parentEl:e,styleDelta:n,runtimeLocks:r,parentNeedsRelative:i}){if(!t||!n)return{applied:"marker-only",reason:"invalid",revert:()=>{}};if(pt(t)||e&&pt(e))return{applied:"marker-only",reason:"react-mount",revert:()=>{}};const s={...n,...r||{}},a={};for(const l of Object.keys(s))a[l]=t.style[l]||"";const o=i&&e?e.style.position||"":null;try{i&&e&&(e.style.position="relative");for(const[l,u]of Object.entries(s))t.style[l]=u;return{applied:"dom",revert:()=>{try{for(const[l,u]of Object.entries(a))t.style[l]=u;o!==null&&e&&(e.style.position=o)}catch{}}}}catch(l){return{applied:"marker-only",reason:"dom-error",message:l.message,revert:()=>{}}}}function Ur({sourceEl:t,originalParent:e,originalNextSibling:n}){if(!(!t||!e))try{n&&n.parentNode===e?e.insertBefore(t,n):e.appendChild(t)}catch{}}export{ro as C,oo as D,to as E,io as G,no as I,an as M,so as P,Jr as R,Qr as a,ao as b,lo as c,yn as d,eo as e,Ct as o,Fe as p,Be as t};
31
+ 如有特殊指令请填……(Cmd+Enter 提交)`,rows:3,style:{width:"100%",padding:b.sm,fontFamily:"inherit",fontSize:G.sm,lineHeight:"15px",color:"rgba(45,36,24,0.9)",background:"rgba(0,0,0,0.02)",border:`1px solid ${m.borderMd}`,borderRadius:N.sm,resize:"vertical",outline:"none",boxSizing:"border-box"}}),f.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:b.sm,gap:b.xs},children:f.jsxs("button",{onClick:T,disabled:!o.trim()||u||!i,title:i?o.trim()?"关联到本次调整 (Cmd+Enter)":"请填写备注内容":"没有关联的 pending edit(请先拖一次元素)",style:{display:"inline-flex",alignItems:"center",gap:3,padding:`${b.xs}px ${b.base}px`,fontFamily:"inherit",fontSize:G.xs,fontWeight:600,color:m.bgWhite,background:gt.blue,border:"none",borderRadius:N.sm,cursor:!o.trim()||u||!i?"not-allowed":"pointer",opacity:!o.trim()||u||!i?.4:1,boxShadow:"0 1px 3px rgba(58,122,254,0.25)"},children:[f.jsx(We,{size:10})," ",u?"提交中…":"关联备注"]})})]})}function lo({iframeDoc:t,sourceEl:e,targetContainer:n,beforeEl:r}){if(!t||!e||!n)return{applied:"marker-only",markerInfo:{reason:"invalid"},revert:()=>{}};if(pt(e)||pt(n))return{applied:"marker-only",markerInfo:{reason:"react-mount",sourceRect:e.getBoundingClientRect(),targetRect:n.getBoundingClientRect()},revert:()=>{}};const i=e.parentElement,s=e.nextElementSibling;try{return r&&r.parentNode===n?n.insertBefore(e,r):n.appendChild(e),{applied:"dom",revert:()=>Ur({sourceEl:e,originalParent:i,originalNextSibling:s})}}catch(a){return{applied:"marker-only",markerInfo:{reason:"dom-error",message:a.message},revert:()=>{}}}}function ao({sourceEl:t,parentEl:e,styleDelta:n,runtimeLocks:r,parentNeedsRelative:i}){if(!t||!n)return{applied:"marker-only",reason:"invalid",revert:()=>{}};if(pt(t)||e&&pt(e))return{applied:"marker-only",reason:"react-mount",revert:()=>{}};const s={...n,...r||{}},a={};for(const l of Object.keys(s))a[l]=t.style[l]||"";const o=i&&e?e.style.position||"":null;try{i&&e&&(e.style.position="relative");for(const[l,u]of Object.entries(s))t.style[l]=u;return{applied:"dom",revert:()=>{try{for(const[l,u]of Object.entries(a))t.style[l]=u;o!==null&&e&&(e.style.position=o)}catch{}}}}catch(l){return{applied:"marker-only",reason:"dom-error",message:l.message,revert:()=>{}}}}function Ur({sourceEl:t,originalParent:e,originalNextSibling:n}){if(!(!t||!e))try{n&&n.parentNode===e?e.insertBefore(t,n):e.appendChild(t)}catch{}}export{ro as C,oo as D,to as E,io as G,no as I,an as M,so as P,Zr as R,lo as a,ao as b,Qr as c,yn as d,eo as e,Ct as o,Fe as p,Be as t};
@@ -0,0 +1,39 @@
1
+ import{p as rt}from"./chunk-JWPE2WC7-B7HxxQds.js";import{a4 as T,a7 as B,b3 as nt,g as it,s as ot,a as st,b as lt,o as ct,n as ut,_ as d,l as G,c as gt,A as dt,D as pt,L as ht,d as ft,p as mt,B as vt}from"./MermaidBlock-DR1GikCv.js";import{p as xt}from"./cynefin-OW5HDTMX-DUwn3ehS.js";import{d as J}from"./arc-D_khH_xN.js";import{o as St}from"./ordinal-Cboi1Yqb.js";import"./index-GAamh1p4.js";import"./init-Gi6I4Gst.js";function yt(t,n){return n<t?-1:n>t?1:n>=t?0:NaN}function wt(t){return t}function At(){var t=wt,n=yt,y=null,b=T(0),l=T(B),p=T(0);function i(e){var r,s=(e=nt(e)).length,h,w,$=0,f=new Array(s),o=new Array(s),D=+b.apply(this,arguments),E=Math.min(B,Math.max(-B,l.apply(this,arguments)-D)),k,R=Math.min(Math.abs(E)/s,p.apply(this,arguments)),u=R*(E<0?-1:1),A;for(r=0;r<s;++r)(A=o[f[r]=r]=+t(e[r],r,e))>0&&($+=A);for(n!=null?f.sort(function(M,m){return n(o[M],o[m])}):y!=null&&f.sort(function(M,m){return y(e[M],e[m])}),r=0,w=$?(E-s*u)/$:0;r<s;++r,D=k)h=f[r],A=o[h],k=D+(A>0?A*w:0)+u,o[h]={data:e[h],index:r,value:A,startAngle:D,endAngle:k,padAngle:R};return o}return i.value=function(e){return arguments.length?(t=typeof e=="function"?e:T(+e),i):t},i.sortValues=function(e){return arguments.length?(n=e,y=null,i):n},i.sort=function(e){return arguments.length?(y=e,n=null,i):y},i.startAngle=function(e){return arguments.length?(b=typeof e=="function"?e:T(+e),i):b},i.endAngle=function(e){return arguments.length?(l=typeof e=="function"?e:T(+e),i):l},i.padAngle=function(e){return arguments.length?(p=typeof e=="function"?e:T(+e),i):p},i}var Ct=vt.pie,I={sections:new Map,showData:!1},F=I.sections,V=I.showData,$t=structuredClone(Ct),Dt=d(()=>structuredClone($t),"getConfig"),Tt=d(()=>{F=new Map,V=I.showData,mt()},"clear"),bt=d(({label:t,value:n})=>{if(n<0)throw new Error(`"${t}" has invalid value: ${n}. Negative values are not allowed in pie charts. All slice values must be >= 0.`);F.has(t)||(F.set(t,n),G.debug(`added new section: ${t}, with value: ${n}`))},"addSection"),kt=d(()=>F,"getSections"),zt=d(t=>{V=t},"setShowData"),Et=d(()=>V,"getShowData"),K={getConfig:Dt,clear:Tt,setDiagramTitle:ut,getDiagramTitle:ct,setAccTitle:lt,getAccTitle:st,setAccDescription:ot,getAccDescription:it,addSection:bt,getSections:kt,setShowData:zt,getShowData:Et},Mt=d((t,n)=>{rt(t,n),n.setShowData(t.showData),t.sections.map(n.addSection)},"populateDb"),Lt={parse:d(async t=>{const n=await xt("pie",t);G.debug(n),Mt(n,K)},"parse")},Rt=d(t=>`
2
+ .pieCircle{
3
+ stroke: ${t.pieStrokeColor};
4
+ stroke-width : ${t.pieStrokeWidth};
5
+ opacity : ${t.pieOpacity};
6
+ }
7
+ .pieCircle.highlighted{
8
+ scale: 1.05;
9
+ opacity: 1;
10
+ }
11
+ .pieCircle.highlightedOnHover:hover{
12
+ transition-duration: 250ms;
13
+ scale: 1.05;
14
+ opacity: 1;
15
+ }
16
+ .pieOuterCircle{
17
+ stroke: ${t.pieOuterStrokeColor};
18
+ stroke-width: ${t.pieOuterStrokeWidth};
19
+ fill: none;
20
+ }
21
+ .pieTitleText {
22
+ text-anchor: middle;
23
+ font-size: ${t.pieTitleTextSize};
24
+ fill: ${t.pieTitleTextColor};
25
+ font-family: ${t.fontFamily};
26
+ }
27
+ .slice {
28
+ font-family: ${t.fontFamily};
29
+ fill: ${t.pieSectionTextColor};
30
+ font-size:${t.pieSectionTextSize};
31
+ // fill: white;
32
+ }
33
+ .legend text {
34
+ fill: ${t.pieLegendTextColor};
35
+ font-family: ${t.fontFamily};
36
+ font-size: ${t.pieLegendTextSize};
37
+ }
38
+ `,"getStyles"),Wt=Rt,_t=d(t=>{const n=[...t.values()].reduce((l,p)=>l+p,0),y=[...t.entries()].map(([l,p])=>({label:l,value:p})).filter(l=>l.value/n*100>=1);return At().value(l=>l.value).sort(null)(y)},"createPieArcs"),Ft=d((t,n,y,b)=>{var q;G.debug(`rendering pie chart
39
+ `+t);const l=b.db,p=gt(),i=dt(l.getConfig(),p.pie),e=40,r=18,s=4,h=450,w=h,$=pt(n),f=$.append("g");f.attr("transform","translate("+w/2+","+h/2+")");const{themeVariables:o}=p;let[D]=ht(o.pieOuterStrokeWidth);D??(D=2);const E=i.legendPosition,k=i.textPosition,R=i.donutHole>0&&i.donutHole<=.9?i.donutHole:0,u=Math.min(w,h)/2-e,A=J().innerRadius(R*u).outerRadius(u),M=J().innerRadius(u*k).outerRadius(u*k),m=f.append("g");m.append("circle").attr("cx",0).attr("cy",0).attr("r",u+D/2).attr("class","pieOuterCircle");const W=l.getSections(),Q=_t(W),Y=[o.pie1,o.pie2,o.pie3,o.pie4,o.pie5,o.pie6,o.pie7,o.pie8,o.pie9,o.pie10,o.pie11,o.pie12];let H=0;W.forEach(a=>{H+=a});const U=Q.filter(a=>(a.data.value/H*100).toFixed(0)!=="0"),N=St(Y).domain([...W.keys()]);m.selectAll("mySlices").data(U).enter().append("path").attr("d",A).attr("fill",a=>N(a.data.label)).attr("class",a=>{let c="pieCircle";return i.highlightSlice==="hover"?c+=" highlightedOnHover":i.highlightSlice===a.data.label&&(c+=" highlighted"),c}),m.selectAll("mySlices").data(U).enter().append("text").text(a=>(a.data.value/H*100).toFixed(0)+"%").attr("transform",a=>"translate("+M.centroid(a)+")").style("text-anchor","middle").attr("class","slice");const tt=f.append("text").text(l.getDiagramTitle()).attr("x",0).attr("y",-400/2).attr("class","pieTitleText"),L=[...W.entries()].map(([a,c])=>({label:a,value:c})),C=f.selectAll(".legend").data(L).enter().append("g").attr("class","legend");C.append("rect").attr("width",r).attr("height",r).style("fill",a=>N(a.label)).style("stroke",a=>N(a.label)),C.append("text").attr("x",r+s).attr("y",r-s).text(a=>l.getShowData()?`${a.label} [${a.value}]`:a.label);const z=Math.max(...C.selectAll("text").nodes().map(a=>(a==null?void 0:a.getBoundingClientRect().width)??0));let _=h,O=w+e;const g=r+s,P=L.length*g;switch(E){case"center":C.attr("transform",(a,c)=>{const v=g*L.length/2,x=-z/2-(r+s),S=c*g-v;return"translate("+x+","+S+")"});break;case"top":_+=P,C.attr("transform",(a,c)=>{const v=u,x=-z/2-(r+s),S=c*g-v;return`translate(${x}, ${S})`}),m.attr("transform",()=>`translate(0, ${P+g})`);break;case"bottom":_+=P,C.attr("transform",(a,c)=>{const v=-u-g,x=-z/2-(r+s),S=c*g-v;return"translate("+x+","+S+")"});break;case"left":O+=r+s+z,C.attr("transform",(a,c)=>{const v=g*L.length/2,x=-u-(r+s),S=c*g-v;return"translate("+x+","+S+")"}),m.attr("transform",()=>`translate(${z+r+s}, 0)`);break;case"right":default:O+=r+s+z,C.attr("transform",(a,c)=>{const v=g*L.length/2,x=12*r,S=c*g-v;return"translate("+x+","+S+")"});break}const j=((q=tt.node())==null?void 0:q.getBoundingClientRect().width)??0,et=w/2-j/2,at=w/2+j/2,X=Math.min(0,et),Z=Math.max(O,at)-X;$.attr("viewBox",`${X} 0 ${Z} ${_}`),ft($,_,Z,i.useMaxWidth)},"draw"),Ht={draw:Ft},jt={parser:Lt,db:K,renderer:Ht,styles:Wt};export{jt as diagram};