@floless/app 0.174.1 → 0.175.0

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 (85) hide show
  1. package/autostart.mjs +117 -10
  2. package/dist/floless-server.cjs +2 -2
  3. package/dist/pdf-engine/floless_pdf/__init__.py +7 -3
  4. package/dist/pdf-engine/floless_pdf/backend_pdfium.py +292 -13
  5. package/dist/pdf-engine/floless_pdf/backend_pymupdf.py +25 -3
  6. package/dist/pdf-engine/floless_pdf/images.py +4 -3
  7. package/dist/pdf-engine/floless_pdf/pages.py +136 -0
  8. package/dist/schemas/steel.model.v2.schema.json +44 -1
  9. package/dist/skills/floless-app-approval/SKILL.md +28 -3
  10. package/dist/skills/floless-app-knowledge/SKILL.md +3 -2
  11. package/dist/skills/floless-app-sketches/SKILL.md +71 -0
  12. package/dist/skills/floless-app-sketches/references/steel-plate.md +15 -0
  13. package/dist/skills/floless-app-steel-model/SKILL.md +11 -1
  14. package/dist/skills/floless-app-steel-model/references/elements.md +90 -23
  15. package/dist/skills/floless-app-steel-takeoff/SKILL.md +11 -6
  16. package/dist/web/agents.js +1 -1
  17. package/dist/web/app.css +120 -15
  18. package/dist/web/app.js +89 -38
  19. package/dist/web/aware-hold.js +10 -0
  20. package/dist/web/aware.js +405 -51
  21. package/dist/web/boot-watchdog.js +249 -0
  22. package/dist/web/card-details.js +88 -0
  23. package/dist/web/chat.css +29 -0
  24. package/dist/web/chat.js +430 -128
  25. package/dist/web/commands-connection-design.js +23 -0
  26. package/dist/web/commands-revit.js +3 -0
  27. package/dist/web/commands-shell.js +226 -10
  28. package/dist/web/commands-steel.js +93 -4
  29. package/dist/web/commands-tekla-parser.js +21 -1
  30. package/dist/web/connection-design-editor.html +71 -0
  31. package/dist/web/connection-design-editor.js +794 -61
  32. package/dist/web/connection-design-handles.js +9 -3
  33. package/dist/web/element-approval.js +74 -0
  34. package/dist/web/element-context.js +76 -6
  35. package/dist/web/element-geometry.js +8 -2
  36. package/dist/web/element-holds.js +68 -5
  37. package/dist/web/element-type-actions.js +22 -3
  38. package/dist/web/element-types.js +12 -5
  39. package/dist/web/element-words.js +15 -11
  40. package/dist/web/grid-place.js +51 -0
  41. package/dist/web/guide.js +2 -0
  42. package/dist/web/index.html +13 -16
  43. package/dist/web/instructor.js +5 -2
  44. package/dist/web/missed-routines.js +6 -1
  45. package/dist/web/model-change-findings.js +100 -30
  46. package/dist/web/model-change-review.js +411 -27
  47. package/dist/web/model-clash-check.css +100 -0
  48. package/dist/web/model-clash-check.js +681 -0
  49. package/dist/web/model-clip-box.js +204 -0
  50. package/dist/web/model-clip-list.js +153 -3
  51. package/dist/web/model-clip-session.js +3 -3
  52. package/dist/web/model-clip-three-overlay.js +135 -25
  53. package/dist/web/model-editor.css +2 -0
  54. package/dist/web/model-elements.js +273 -18
  55. package/dist/web/model-fit-checks.js +354 -0
  56. package/dist/web/model-spatial-panel.js +9 -3
  57. package/dist/web/model-spatial-tools.js +12 -3
  58. package/dist/web/model-tekla-selection.js +74 -0
  59. package/dist/web/model-view-query.js +70 -14
  60. package/dist/web/model-viewport-revit-adapter.js +8 -7
  61. package/dist/web/model-viewport-toolbar.js +8 -4
  62. package/dist/web/pages.js +78 -1
  63. package/dist/web/project-history.js +31 -1
  64. package/dist/web/revit-editor.css +34 -1
  65. package/dist/web/revit-editor.js +174 -55
  66. package/dist/web/run-history.js +8 -0
  67. package/dist/web/sketch-editor.js +141 -2
  68. package/dist/web/sketches.js +192 -6
  69. package/dist/web/start-place.js +46 -0
  70. package/dist/web/steel-3d-core.js +70 -0
  71. package/dist/web/steel-3d-view.js +288 -47
  72. package/dist/web/steel-change-review.css +28 -0
  73. package/dist/web/steel-custom-connection.js +6 -0
  74. package/dist/web/steel-editor.html +532 -33
  75. package/dist/web/steel-filter.html +8 -3
  76. package/dist/web/steel-model-checks.css +76 -0
  77. package/dist/web/steel-model-v2-commands.js +17 -0
  78. package/dist/web/steel-view-generation.js +6 -2
  79. package/dist/web/teams.js +259 -19
  80. package/dist/web/tekla-editor.html +1 -0
  81. package/dist/web/terminal-requests.js +6 -0
  82. package/dist/web/vendor/connection-engine.js +886 -91
  83. package/dist/web/workspaces.js +630 -48
  84. package/package.json +2 -1
  85. package/preferences-file.mjs +27 -0
@@ -943,6 +943,9 @@
943
943
  #panel .divrow{margin:14px 0 6px;gap:9px}
944
944
  #panel .divrow hr:first-of-type{display:none}
945
945
  #panel .hint{font-size:11px;line-height:1.45}
946
+ /* #4027: a cut the 3D view could not draw on this member — amber left edge on the warning fill, hint-sized, top of Inspect */
947
+ #panel .cutnd{margin:4px 0 8px;padding:6px 8px 6px 9px;border-left:3px solid var(--warn);border-radius:0 4px 4px 0;background:var(--warn-bg);color:var(--warn);font-size:11px;line-height:1.45;overflow-wrap:anywhere}
948
+ #panel .cutnd>div+div{margin-top:4px}
946
949
  .divrow hr{flex:1;border:0;border-top:1px solid var(--line);margin:0}
947
950
  .ghost{background:transparent;border:1px solid var(--line);color:var(--mut);font-size:11px;padding:2px 8px;border-radius:4px;white-space:nowrap;cursor:pointer}
948
951
  .ghost:hover{color:var(--text);border-color:var(--brand)}
@@ -3312,6 +3315,8 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
3312
3315
  <script type="module">import * as FU from './steel-filter-usage.js';window.SteelFilterUsage=FU;</script>
3313
3316
  <script type="module">import { installShapeSketcher } from './steel-shape-sketcher.js';installShapeSketcher();</script>
3314
3317
  <link rel="stylesheet" href="./steel-change-review.css">
3318
+ <link rel="stylesheet" href="./steel-model-checks.css">
3319
+ <link rel="stylesheet" href="./model-clash-check.css">
3315
3320
  </head><body class=steel-model-editor>
3316
3321
  <header>
3317
3322
  <b>Steel Model</b>
@@ -3498,10 +3503,12 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
3498
3503
  </div>
3499
3504
  <button data-command-id="steel.menu-section#Model checks" id=secChecksHdr class=msec-hdr data-sec=checks aria-expanded=false data-tip="Find and fix modelling problems">Model checks<span class=chev aria-hidden=true>▸</span></button>
3500
3505
  <div class=msec-body data-reveal-by=".msec-hdr[data-sec=checks]">
3506
+ <button data-command-id="steel.clash-check-open" id=clashCheckB aria-haspopup=dialog aria-controls=clashCheckModal data-tip="Find parts in the saved model that overlap or touch. Nothing is changed.">Check for clashes…</button>
3501
3507
  <button data-command-id="steel.check-duplicates" id=dupB data-tip="Selects overlapping members drawn twice by mistake — review, then press Delete to remove the extra one.">Duplicates</button>
3502
3508
  <button data-command-id="steel.check-reversed" id=revB data-tip="Select beams drawn the wrong way — a mostly-horizontal beam should run left→right, a steep/skew beam bottom→up. Review, then press P to swap their direction.">Reversed beams</button>
3503
3509
  <button data-command-id="steel.check-member-ends" id=memberEndsB data-tip="Find beam and brace ends that may stop at support faces instead of support centerlines. Drawing reads automatically align only unambiguous cases; review the rest here.">Check member ends short of supports</button>
3504
3510
  <button data-command-id="steel.merge-collinear" id=mrgB data-tip="Joins straight, end-to-end runs of the same profile into one beam. Undoable.">Merge collinear beams</button>
3511
+ <button data-command-id="steel.element-fit-open" id=modelChecksB aria-expanded=false aria-controls=modelChecksDrawer data-tip="Measure how the walls, slabs and footings fit each other, and list what does not, where, with the numbers. Nothing in the model changes.">Fit of walls, slabs and footings…</button>
3505
3512
  </div>
3506
3513
  <button data-command-id="steel.menu-section#Coordinate system" class=msec-hdr data-sec=coords aria-expanded=false data-tip="Local vs global drawing axes (for skewed framing)">Coordinate system<span class=chev aria-hidden=true>▸</span></button>
3507
3514
  <div class=msec-body data-reveal-by=".msec-hdr[data-sec=coords]">
@@ -3544,6 +3551,14 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
3544
3551
  <aside id=changeReviewDrawer class=crv-drawer role=complementary aria-labelledby=changeReviewTitle data-reveal-by=#reviewChangesB hidden>
3545
3552
  <div class=mhead><b id=changeReviewTitle tabindex=-1>Review changes</b><button data-command-id="steel.dialog-close#Review changes" id=changeReviewClose aria-label="Close Review changes" data-tip="Close">✕</button></div>
3546
3553
  <div id=changeReviewHost class="tekla-audit-host tekla-changes-host" aria-label="Changes between versions of this model"></div>
3554
+ <!-- #4029: the clash check's results share this drawer; one host shows at a time (web/model-clash-check.js). -->
3555
+ <div id=clashCheckHost class="tekla-audit-host tekla-changes-host ccx-host" aria-label="Clashes in the saved model" hidden></div>
3556
+ </aside>
3557
+ <!-- #3690 E1d (F7): the Model checks drawer. Beside the model like Review changes, never modal. One <section> per check:
3558
+ the fit of walls, slabs and footings first (web/model-fit-checks.js); the clash check (#4029) joins it as a sibling. -->
3559
+ <aside id=modelChecksDrawer class=crv-drawer role=complementary aria-labelledby=modelChecksTitle data-reveal-by=#modelChecksB hidden>
3560
+ <div class=mhead><b id=modelChecksTitle tabindex=-1>Model checks</b><button data-command-id="steel.dialog-close#Model checks" id=modelChecksClose aria-label="Close Model checks" data-tip="Close">✕</button></div>
3561
+ <div id=modelChecksHost aria-label="Fit checks of this model"></div>
3547
3562
  </aside>
3548
3563
  <!-- #2521 row 6: the AI decisions strip. Always shown for a Quick (or possibly Quick) model, whatever is selected and
3549
3564
  whether or not the marks are switched on: it is where "unmarked members may still rest on AI decisions" lives.
@@ -3763,6 +3778,16 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
3763
3778
  <div id=vgFoot><button data-command-id="steel.dialog-cancel#Generate views" id=vgCancel class=ghost>Cancel</button><button data-command-id="steel.view-create" id=vgCreate disabled>Create 0 views</button></div>
3764
3779
  </div>
3765
3780
  </div>
3781
+ <!-- #4029: Check for clashes. The #viewGenModal shell with #confModal's focus trap; web/model-clash-check.js fills the body
3782
+ and the footer. Esc is Cancel. -->
3783
+ <div id=clashCheckModal role=dialog aria-modal=true aria-labelledby=clashCheckTitle>
3784
+ <div class=mbackdrop id=clashCheckBackdrop></div>
3785
+ <div class=mpanel>
3786
+ <div class=mhead><b id=clashCheckTitle>Check for clashes</b><button data-command-id="steel.dialog-close#Check for clashes" id=clashCheckClose aria-label="Close Check for clashes" data-tip="Close">✕</button></div>
3787
+ <div id=clashCheckBody></div>
3788
+ <div id=clashCheckFoot></div>
3789
+ </div>
3790
+ </div>
3766
3791
  <div id=detailsModal><div class=mbackdrop id=detailsBackdrop></div>
3767
3792
  <div class=mpanel><div class=mhead><b>Connection details</b><div style="display:flex;gap:8px;align-items:center"><button data-command-id="steel.detail-new" id=detailNew>+ New detail</button><button data-command-id="steel.dialog-close#Details" id=detailsClose>✕</button></div></div>
3768
3793
  <div id=detailNewForm style="display:none;padding:14px;border-bottom:1px solid var(--line)">
@@ -4088,7 +4113,7 @@ const EditorFocus = (() => {
4088
4113
  Promise.resolve().then(() => runner(job.req, current)).then(
4089
4114
  (outcome) => vacate(job, current() && outcome ? outcome : { superseded: true }),
4090
4115
  // The runner shows its own sentences; this is only the last line of defence, so the caller is never left waiting.
4091
- (error) => { console.error('[steel] could not show the connection asked for', error); vacate(job, current() ? { ok: false, said: job.req.makePrecise ? 'FloLess could not open Make precise. Press Open Make precise again, or open the AI decisions strip and press Make precise.' : job.req.rfiId ? 'FloLess could not show ' + job.req.rfiId + '. Find it on the RFIs page, or press it in the chat again.' : job.req.memberId ? 'The model could not show member ' + job.req.memberId + '. Press Show in the model again, or find it in the Model panel.' : 'The model could not show connection ' + job.req.jointId + '. Press Open in the model again, or find it in the Model panel.' } : { superseded: true }); });
4116
+ (error) => { console.error('[steel] could not show the connection asked for', error); vacate(job, current() ? { ok: false, said: job.req.clashCheckId ? 'FloLess could not open that clash check result. Open it from History again.' : job.req.makePrecise ? 'FloLess could not open Make precise. Press Open Make precise again, or open the AI decisions strip and press Make precise.' : job.req.rfiId ? 'FloLess could not show ' + job.req.rfiId + '. Find it on the RFIs page, or press it in the chat again.' : job.req.memberId ? 'The model could not show member ' + job.req.memberId + '. Press Show in the model again, or find it in the Model panel.' : 'The model could not show connection ' + job.req.jointId + '. Press Open in the model again, or find it in the Model panel.' } : { superseded: true }); });
4092
4117
  };
4093
4118
  window.flolessEditorState = { project: PROJECT, ready: false };
4094
4119
  const text = (value) => typeof value === 'string' && value ? value : '';
@@ -4100,13 +4125,15 @@ const EditorFocus = (() => {
4100
4125
  : req && text(req.memberId) ? { memberId: req.memberId }
4101
4126
  : req && text(req.rfiId) && /^RFI-\d{3,16}$/.test(req.rfiId) ? { rfiId: req.rfiId }
4102
4127
  // #2521 row 9: or Make precise itself, the chat's "Open Make precise" (the panel opens; nothing is confirmed).
4103
- : req && req.makePrecise === true ? { makePrecise: true } : null;
4128
+ : req && req.makePrecise === true ? { makePrecise: true }
4129
+ // #4029: or one clash check result, from the project's History.
4130
+ : req && text(req.clashCheckId) && /^[0-9a-f]{64}$/.test(req.clashCheckId) ? { clashCheckId: req.clashCheckId } : null;
4104
4131
  // The failure sentence names a connection; every other request is told what it asked for, worded as the shell words it (#2980).
4105
4132
  // The button to press again, and the step that explains, are the asker's own too.
4106
4133
  const failedFor = (req) => {
4107
- const asked = !req ? '' : req.makePrecise ? 'Make precise' : req.rfiId ? req.rfiId : req.memberId ? 'the member' : '';
4134
+ const asked = !req ? '' : req.clashCheckId ? 'the clash check result' : req.makePrecise ? 'Make precise' : req.rfiId ? req.rfiId : req.memberId ? 'the member' : '';
4108
4135
  if (!asked) return failed;
4109
- const again = req.makePrecise ? 'Open Make precise' : req.rfiId ? req.rfiId + ' in the chat' : 'Show in the model';
4136
+ const again = req.clashCheckId ? 'Open result' : req.makePrecise ? 'Open Make precise' : req.rfiId ? req.rfiId + ' in the chat' : 'Show in the model';
4110
4137
  const said = failed.replace(/the connection/g, asked).replace('press Open in the model again', 'press ' + again + ' again');
4111
4138
  return req.rfiId ? said.replace('The Model step says why', 'The RFIs step says why') : said;
4112
4139
  };
@@ -5045,7 +5072,7 @@ function startContractEvents(){
5045
5072
  if(assumptionEventMatches(m)){if(contractEventReady&&window.forgetConnectionAssumptions)window.forgetConnectionAssumptions();return;}
5046
5073
  if(connectionDisplayEventMatches(m)){if(window.reloadConnectionDisplay)window.reloadConnectionDisplay(m.rev);return;}
5047
5074
  if(reviewEventMatches(m)){if(!contractEventReady){if(reviewFrameOrderable(m)&&(!reviewEventWatermark||m.reviewRevision>=reviewEventWatermark.reviewRevision))reviewEventWatermark=m;}else handleReviewChanged(m);return;}
5048
- if(!contractEventMatches(m))return;if(!contractEventReady)bufferContractEvent(m);else handleContractChanged(m);};
5075
+ if(!contractEventMatches(m))return;if(!contractEventReady)bufferContractEvent(m);else handleContractChanged(m);if(window.SketchEditor&&window.SketchEditor.onModelChanged)window.SketchEditor.onModelChanged();}; // S1c: a converted shape shows or hides as its plate changes
5049
5076
  source.onerror=()=>{if(source!==contractEventSource)return;contractEventReady=false;if(source.readyState===EventSource.CLOSED){ownWrites.length=0;uncertainWrites.clear();console.warn('steel-editor: SSE channel closed — live updates paused');showAiUpdateBanner('Live updates disconnected — reload to resume change detection.');}};
5050
5077
  }catch(e){console.warn('steel-editor: could not open live updates',e&&e.message?e.message:e);}
5051
5078
  }
@@ -6704,7 +6731,7 @@ function mpRestHtml(state){
6704
6731
  }
6705
6732
  const chosen=r.files.filter(f=>rs.chosen.has(f.sha256)),k=chosen.length,isDefault=k===Math.min(n,r.max)&&r.files.slice(0,r.max).every(f=>rs.chosen.has(f.sha256));
6706
6733
  const label=!k?'Read the rest':isDefault?(n>r.max?`Read the rest (${r.max} of ${n})`:`Read the rest (${n} file${s(n)})`):`Read ${k} chosen file${s(k)}`;
6707
- const mode=m=>`<label class=mp-rest-mode><input type=radio name=mpRestMode value=${esc(m)} data-mp-rest-mode=${esc(m)} data-mp-key="rm:${esc(m)}" data-command-id="steel.make-precise-read-rest-mode#${esc(m)}" data-command-instance-label="${m==='quick'?'Quick':'Precise'}"${rs.mode===m?' checked':''}${dis}> ${m==='quick'?'Quick: faster. The model is labelled Quick model until you review its AI decisions.':'Precise: takes longer; the read asks you where the drawings leave something open.'}</label>`;
6734
+ const mode=m=>`<label class=mp-rest-mode><input type=radio name=mpRestMode value=${esc(m)} data-mp-rest-mode=${esc(m)} data-mp-key="rm:${esc(m)}" data-command-id="steel.make-precise-read-rest-mode#${esc(m)}" data-command-instance-label="${m==='quick'?'Quick':'Precise'}"${rs.mode===m?' checked':''}${dis}> ${m==='quick'?'Quick: faster. The model is labelled Quick model until you review its AI decisions. The read still stops for you to save the Drawing Filter.':'Precise: takes longer; the read asks you where the drawings leave something open.'}</label>`; // #3820: a later Quick read never lets the AI choose the Filter (owner ruling 2026-10-26), so it is said before queuing
6708
6735
  h+=`<div class=mp-rest role=group aria-label="Read the files left for later">`;
6709
6736
  h+=`<div class=mp-rest-modes role=radiogroup aria-label="Read as"><span class=hint>Read as</span>${mode('precise')}${mode('quick')}</div>`;
6710
6737
  if(rs.msg)h+=`<div class="${rs.msgKind==='alert'?'mp-banner':'hint'}" role=${rs.msgKind==='alert'?'alert':'status'}>${esc(rs.msg)}</div>`;
@@ -6761,7 +6788,8 @@ async function mpRestQueue(state){
6761
6788
  const left=r.files.length-files.length,moved=' The list of files left for later has changed since; check it before reading more.';
6762
6789
  if(res&&res.ok&&body&&body.ok){
6763
6790
  const asked=body.buildModeNotice?' '+body.buildModeNotice:'';
6764
- rs.queued='A read of '+files.length+' file'+(files.length===1?' is':'s is')+' queued'+(rs.mode==='quick'&&!body.buildModeNotice?' as Quick':'')+'. It waits in Requests until the AI chat reads it, and the review comes back to you there.'+(left?' '+left+' file'+(left===1?' stays':'s stay')+' left for later.':'')+asked;
6791
+ const quick=rs.mode==='quick'&&!body.buildModeNotice;
6792
+ rs.queued='A read of '+files.length+' file'+(files.length===1?' is':'s is')+' queued'+(quick?' as Quick':'')+'. It waits in Requests until the AI chat reads it'+(quick?'. The read then stops for you to save the Drawing Filter, and':', and')+' the review comes back to you there.'+(left?' '+left+' file'+(left===1?' stays':'s stay')+' left for later.':'')+asked;
6765
6793
  state.live=same?'':rs.queued+moved;state.focus={key:'title'};panel();return; // same offer: the section says it (role=status), once
6766
6794
  }
6767
6795
  const code=body&&body.code;
@@ -7108,7 +7136,7 @@ function memberEndChoicesForReport(report,previous){
7108
7136
  function memberEndDistance(f,t){const a=f.currentPoint,z=a&&a.z&&Number.isFinite(a.z.known)?a.z.known:t.point.z.known;return Math.hypot(t.point.x-a.x,t.point.y-a.y,t.point.z.known-z);}
7109
7137
  // `id` rides in the snapshot, not just in the restore lookup (#938): restoring BY view id from a
7110
7138
  // snapshot that only recorded the page still collapses two views on one sheet onto each other.
7111
- function memberEndSnapshot(doc){return {v2:true,members:doc.members,provisional_members:doc.provisional_members||[],grid:doc.grid||null,plans:(doc.plans||[]).map(p=>({id:p.id,sheet:p.sheet,...(Object.hasOwn(p,'dims')?{dims:p.dims||[]}:{}),memberRefs:p.memberRefs||[],...(Object.hasOwn(p,'memberObservations')?{memberObservations:p.memberObservations||[]}:{}),...(Object.hasOwn(p,'frame')?{frame:p.frame||null}:{}),datum_ref:p.datum_ref,control2_ref:p.control2_ref})),joints:doc.joints||[],connections:doc.connections||[],details:doc.detail_placements||[],views:doc.views||[],member_types:doc.member_types||[],dim_style:doc.dim_style||null,member_styles:doc.member_styles||{},...(Array.isArray(doc.reference_models)?{reference_models:doc.reference_models}:{})};}
7139
+ function memberEndSnapshot(doc){return {v2:true,members:doc.members,provisional_members:doc.provisional_members||[],grid:doc.grid||null,plans:(doc.plans||[]).map(p=>({id:p.id,sheet:p.sheet,...(Object.hasOwn(p,'dims')?{dims:p.dims||[]}:{}),memberRefs:p.memberRefs||[],...(Object.hasOwn(p,'memberObservations')?{memberObservations:p.memberObservations||[]}:{}),...(Object.hasOwn(p,'frame')?{frame:p.frame||null}:{}),datum_ref:p.datum_ref,control2_ref:p.control2_ref})),joints:doc.joints||[],connections:doc.connections||[],details:doc.detail_placements||[],views:doc.views||[],member_types:doc.member_types||[],dim_style:doc.dim_style||null,member_styles:doc.member_styles||{},...(Array.isArray(doc.reference_models)?{reference_models:doc.reference_models}:{}),fitSetting:{value:Object.hasOwn(doc,'element_fit')?doc.element_fit:null}};} // #3690 E1d: a server document carries its fit setting (null = absent, FloLess's default), so the next save sends it back unchanged
7112
7140
  function installMemberEndContract(doc,etag,revision,keepHistory){
7113
7141
  const seenCopy=lastSeenText(doc); // #2209 - the server's document for this tag, taken BEFORE the session adopts (and later mutates) its parts
7114
7142
  V2_SESSION.restoreSnapshot(memberEndSnapshot(doc));V2_PROJECTIONS.clear();
@@ -7320,16 +7348,16 @@ function elevationDisarmTools(){
7320
7348
  and the files use) and sends their outlines in world mm; element-plan.js picks the ones this plan's cut meets and
7321
7349
  turns them into its pixels through the sheet's own registration. Fetched again only when the model's elements change
7322
7350
  (a reload replaces the list); a failed read draws none and says so. */
7323
- let elemFootprints=null,elemFootprintsSrc=null,elemFootprintsError=false,elemPlanLeftOut=null;
7351
+ let elemFootprints=null,elemFootprintsSrc=null,elemFootprintsError=false,elemPlanLeftOut=null,elemFitSummary=null;
7324
7352
  function refreshElementFootprints(){
7325
7353
  const list=C&&Array.isArray(C.elements)?C.elements:null;
7326
7354
  if(list===elemFootprintsSrc)return;
7327
- elemFootprintsSrc=list;elemFootprintsError=false;elemPlanLeftOut=null;
7355
+ elemFootprintsSrc=list;elemFootprintsError=false;elemPlanLeftOut=null;elemFitSummary=null;
7328
7356
  if(!list||!list.length||!PROJECT_QS){elemFootprints=null;return;}
7329
7357
  const asked=list;
7330
7358
  fetch('/api/contract/'+encodeURIComponent(APP_ID)+'/elements/evaluate'+PROJECT_QS+'&footprints=1',{method:'POST',headers:{'content-type':'application/json'},body:'{}'})
7331
7359
  .then(r=>r.ok?r.json():Promise.reject(new Error('HTTP '+r.status)))
7332
- .then(body=>{if(elemFootprintsSrc!==asked)return;elemFootprints=Array.isArray(body&&body.footprints)?body.footprints:[];elemPlanLeftOut=body&&body.planLeftOut&&typeof body.planLeftOut.sentence==='string'?body.planLeftOut.sentence:null;render();})
7360
+ .then(body=>{if(elemFootprintsSrc!==asked)return;elemFootprints=Array.isArray(body&&body.footprints)?body.footprints:[];elemPlanLeftOut=body&&body.planLeftOut&&typeof body.planLeftOut.sentence==='string'?body.planLeftOut.sentence:null;elemFitSummary=body&&body.fit&&typeof body.fit.summary==='string'?body.fit.summary:null;render();})
7333
7361
  .catch(err=>{if(elemFootprintsSrc!==asked)return;console.warn('[steel] walls, slabs and footings could not be read for the plan: '+(err&&err.message||err));elemFootprints=null;elemFootprintsError=true;paintElementPlanNote(null);});
7334
7362
  }
7335
7363
  function paintElementPlanNote(note){
@@ -7341,11 +7369,11 @@ function elementsPlanSvg(){
7341
7369
  refreshElementFootprints();
7342
7370
  if(!ElementPlan||!elemFootprints||NO_PLAN_VIEW){paintElementPlanNote(null);return '';}
7343
7371
  // The elements it cannot draw are named whether or not anything else is drawn (never a silent drop).
7344
- if(!elemFootprints.length){paintElementPlanNote(ElementPlan.elementPlanNote({leftOut:elemPlanLeftOut}));return '';}
7372
+ if(!elemFootprints.length){paintElementPlanNote(ElementPlan.elementPlanNote({leftOut:elemPlanLeftOut,fitSummary:elemFitSummary}));return '';}
7345
7373
  const plan={...P,modelGrid:C.grid};
7346
7374
  const res=ElementPlan.elementPlanShapes(elemFootprints,P,(x,y)=>PlanXf.worldToSheetPx({x,y,z:{unknown:true}},plan));
7347
- // The note always says what the fit check does not cover yet: nothing on a plan reads as fitting.
7348
- paintElementPlanNote(ElementPlan.elementPlanNote({cutNote:res.note,leftOut:elemPlanLeftOut,shown:res.shapes.length}));
7375
+ // The note always carries the fit summary (measured, found, not measured, not checked): nothing on a plan reads as fitting.
7376
+ paintElementPlanNote(ElementPlan.elementPlanNote({cutNote:res.note,leftOut:elemPlanLeftOut,shown:res.shapes.length,fitSummary:elemFitSummary}));
7349
7377
  // The view frames what it draws: elements past the steel grow it (never shrink it), so the first view, Fit and Home
7350
7378
  // bring them in. The sheet's backdrop stays at the sheet (SHEET); re-fit once, after this render, when it grew.
7351
7379
  const grown=ElementPlan.planExtentWith([X0,Y0,X1,Y1],res.bounds);
@@ -9033,6 +9061,10 @@ async function persistServer(force,token){profileCardEndPreview();const seq=save
9033
9061
  // Apply ONLY a report we can prove is current; otherwise do nothing — the server re-decides an
9034
9062
  // introduced joint on the next save, so a missed removal cannot survive (see the note above).
9035
9063
  if(bodyReadable&&usable&&seq===saveSeq)applyRevalidation(d.revalidation);
9064
+ // #3690 E1d 7.1: a save never changes the fit setting (it is the person's, from the fit list or a confirmed card); the
9065
+ // server kept the stored one and says so here, so nothing changes in silence.
9066
+ const fitKept=bodyReadable&&Array.isArray(d.warnings)?d.warnings.find(w=>w&&w.code==='element-fit-setting-kept'&&typeof w.message==='string'):null;
9067
+ if(fitKept)toast(fitKept.message);
9036
9068
  if(!bodyReadable)recoverStoredDecisions(seq); // #1938 - committed, body lost: the tag moved but a staled decision did not
9037
9069
  } // chain the next edit off the new tag, and install any server-staled endpoint authority instead of leaving the browser on bytes the server deliberately transformed; then tell the user what the write-boundary revalidation did to their connections
9038
9070
  else releaseMutation(mid); // 400/500: nothing was written, so nothing will echo
@@ -12657,6 +12689,7 @@ function updateConnCrumb(){
12657
12689
  const cs=view3dShown?connSelInfo():null;
12658
12690
  if(!cs){ el.style.display='none'; el.innerHTML=''; return; }
12659
12691
  const name=connKindLabel(cs.kind)+' · '+cs.main;
12692
+ const fitList=plateFitDiags(cs.conn),fitHead=fitList.length?plateFitWords(fitList).head:'';
12660
12693
  let html='<button data-command-id="steel.connection-breadcrumb#model" class=seg data-lvl=root data-tip="Back to the model (deselect)">Model</button><span class=sep>▸</span>';
12661
12694
  if(cs.whole){ html+='<span class="seg cur">'+esc(name)+'</span>'; }
12662
12695
  else{
@@ -12665,6 +12698,7 @@ function updateConnCrumb(){
12665
12698
  const pel=(partsById||{})[partId]; const plbl=(pel&&pel.meta&&pel.meta.label)||'Part';
12666
12699
  html+='<span class="seg cur">'+esc(plbl)+'</span>';
12667
12700
  }
12701
+ if(fitHead)html+='<span class=sep>·</span><span role=note style="color:var(--warn-soft)">'+esc(fitHead)+'</span>'; // 3D: what is built differently, named where the connection is
12668
12702
  el.innerHTML=html; el.style.display='flex';
12669
12703
  {const b=el.querySelector('[data-lvl=root]'); if(b)b.onclick=()=>{ if(modelEditor.isReady()&&modelEditor.steel.clearConnSel)modelEditor.steel.clearConnSel(); else{modelSelection.replaceMembers();render();} };}
12670
12704
  {const b=el.querySelector('[data-lvl=whole]'); if(b)b.onclick=()=>{ if(window.Steel3DView&&modelEditor.steel.selectWholeConn)modelEditor.steel.selectWholeConn(cs.conn); };}
@@ -13649,6 +13683,12 @@ function panel(){
13649
13683
  const fitRow=r=>{const w=CustomConn.fitCheckRow(r);
13650
13684
  return kv(w.label,`<span style="color:var(${w.status==='within'?'--mut':'--warn'})">${esc(w.statusText)}</span>`)
13651
13685
  +(w.detail?`<div class="row hint" style="margin:0 0 6px;font-size:11px">${esc(w.detail)}</div>`:'');};
13686
+ // Sketches S1c (#3643, plan §8): a connection converted from a sketch says which sketch and version, and opens it.
13687
+ const skLink=j.provenance&&j.provenance.source==='sketch'&&j.provenance.sketch&&typeof j.provenance.sketch.id==='string'?j.provenance.sketch:null;
13688
+ const skName=skLink&&window.SketchEditor&&window.SketchEditor.sketchName?window.SketchEditor.sketchName(skLink.id):undefined;
13689
+ const skRow=!skLink?'':skName===null
13690
+ ?`<div class="row hint" id=ccSketchRow style="margin:0 0 6px;font-size:11px">Made from a sketch that was deleted (version ${Number(skLink.version)}). Its versions are kept.</div>`
13691
+ :`<div class="row hint" id=ccSketchRow style="margin:0 0 6px;font-size:11px">Made from sketch <span class=sk-name data-tip="${esc(skName||'')}">“${esc(skName||'a sketch')}”</span> (version ${Number(skLink.version)}) · <button data-command-id="steel.connection-show-sketch" class=pilllink id=ccSketch data-tip="Open Sketches on the sketch this connection was made from">Show it</button></div>`;
13652
13692
  const failRows=v.notMet.map(fitRow).join('');
13653
13693
  const showPassing=v.passing.length<=6||ccShowAllChecks===j.id;
13654
13694
  const passRows=v.passing.map(fitRow).join('');
@@ -13675,6 +13715,7 @@ function panel(){
13675
13715
  ${assumptionChipFor(j.id)}
13676
13716
  <div class="row hint" style="margin:0 0 2px">${onLine}</div>
13677
13717
  <div class="row hint" style="margin:0 0 6px;font-size:11px">${esc(v.name)} — built from standard parts. <b>Esc</b> steps back.</div>
13718
+ ${skRow}
13678
13719
  ${sec('What it is')}${features}
13679
13720
  ${sec('Fit checks')}${checks}
13680
13721
  ${assumptions}
@@ -13686,6 +13727,7 @@ function panel(){
13686
13727
  </div>`;
13687
13728
  {const b=document.getElementById('cmpMember');if(b)b.onclick=()=>{if(modelEditor.isReady()&&modelEditor.steel.clearConnSel)modelEditor.steel.clearConnSel();modelSelection.replaceMembers([j.main]);selDimIds.clear();sel3dDimIds.clear();modelSelection.clearGrids();render();};}
13688
13729
  {const b=document.getElementById('ccChecksToggle');if(b)b.onclick=()=>{ccShowAllChecks=ccShowAllChecks===j.id?null:j.id;panel();const t=document.getElementById('ccChecksToggle');if(t)t.focus();};}
13730
+ {const b=document.getElementById('ccSketch');if(b&&skLink)b.onclick=()=>{const sh=sketchShell();try{if(sh&&sh.flolessSketches&&sh.flolessSketches.open){sh.flolessSketches.open(PROJECT,skLink.id);return;}}catch(_){}toast('Open Sketches from the menu to see this sketch.');};}
13689
13731
  {const b=document.getElementById('ccLabelModel');if(b)b.onchange=()=>setConnectionLabel({model:b.checked?'shown':'hidden'},'ccLabelModel');}
13690
13732
  {const b=document.getElementById('ccLabelJoint');if(b)b.onchange=()=>setConnectionLabel({joint:{id:j.id,label:b.checked?'shown':'hidden'}},'ccLabelJoint');}
13691
13733
  requestAnimationFrame(applyCcAfterRender); // after the frame: the same render pass may rewrite the panel again around this branch
@@ -13701,12 +13743,13 @@ function panel(){
13701
13743
  const sz=plate?dim(plate.width)+' × '+dim(plate.depth):'<span style="color:var(--mut)">auto</span>';
13702
13744
  let body='';
13703
13745
  if(isBP)body=sec('Plate')+kv('Size',sz)+kv('Thickness',plate?dim(plate.thickness):dim(pp.thickness))+sec('Anchors')+kv('Grid (cols × rows)',esc(`${pp.boltCols||2} × ${pp.boltRows||2}`))+kv('Diameter',pp.boltDia?dim(pp.boltDia):dim(24));
13704
- else body=sec('Plate')+kv('Size',sz)+kv('Thickness',plate?dim(plate.thickness):dim(pp.plateThickness))+sec('Bolts')+kv('Grid (cols × rows)',esc(`${pp.boltCols||1} × ${pp.boltRows||3}`))+kv('Diameter',pp.boltDia?dim(pp.boltDia):dim(20))+sec('Weld')+kv('Leg',pp.weldLeg?dim(pp.weldLeg):dim(6));
13746
+ else body=sec('Plate')+kv('Size',sz)+kv('Thickness',plate?dim(plate.thickness):dim(pp.plateThickness))+sec('Bolts')+kv('Grid (cols × rows)',esc(`${pp.boltCols||1} × ${plateFitRows(j.id,pp.boltRows||3)}`))+kv('Diameter',pp.boltDia?dim(pp.boltDia):dim(20))+sec('Weld')+kv('Leg',pp.weldLeg?dim(pp.weldLeg):dim(6));
13705
13747
  p.innerHTML=`<span class=badge>${connKindLabel(cs.kind)}</span>
13706
13748
  <div class=row style="margin:0 0 6px"><span class=chip style="border-color:var(--brand);color:var(--info-ink)">Parametric — editable</span></div>
13707
13749
  ${assumptionChipFor(j.id)}
13708
13750
  <div class="row hint" style="margin:0 0 2px">On <button data-command-id="steel.connection-select-member" class=pilllink id=cmpMember data-tip="Select ${esc(j.main)}">${esc(j.main)}</button> · ${cs.childIds.length} parts</div>
13709
13751
  <div class="row hint" style="margin:0 0 6px;font-size:11px">Double-click to enter and pick a part · <b>Esc</b> steps back.</div>
13752
+ <div id=cmpFit data-plate-fit-for="${esc(j.id)}">${plateFitNote(j.id,{full:true,key:'cmp'})}</div>
13710
13753
  ${body}
13711
13754
  <div class=divrow><hr></div>
13712
13755
  <div class="row f" style="gap:6px;flex-wrap:wrap">
@@ -13720,6 +13763,7 @@ function panel(){
13720
13763
  {const b=document.getElementById('cmpMember');if(b)b.onclick=toMember;}
13721
13764
  {const b=document.getElementById('cmpEdit');if(b)b.onclick=toMember;}
13722
13765
  {const b=document.getElementById('cmpTrim');if(b)b.onclick=()=>armBaseTrim(j.main);}
13766
+ wirePlateFitNote(document.getElementById('cmpFit'),j.id);
13723
13767
  {const b=document.getElementById('cmpAsk');if(b)b.onclick=()=>connModifyRequest(j);}
13724
13768
  {const b=document.getElementById('cmpDel');if(b)b.onclick=()=>edit(()=>{C.joints=(C.joints||[]).filter(x=>x!==j);modelSelection.clearMembers();});}
13725
13769
  {const b=document.getElementById('cmpFav');if(b)b.onclick=()=>openFavModalFor(j);}
@@ -13769,7 +13813,7 @@ function panel(){
13769
13813
  // so `clearance` is never read (steel-joints.ts — "the setback IS the clearance"). Showing it would put an
13770
13814
  // editable 1/2" default in front of the user that changes nothing.
13771
13815
  if(pk==='plate'&&(j.kind==='shear-plate'||j.kind==='brace-gusset'))body=sec('Plate')+kv('Width',dim(el&&el.width))+kv('Height',dim(el&&el.depth))+kv('Thickness',dim(el&&el.thickness))+kv('Weld leg',v('weldLeg','mm'))+(j.kind==='brace-gusset'?kv('Set back',dim(el&&el.meta&&el.meta.setbackMm)):kv('Clearance',v('clearance','mm')));
13772
- else if(pk==='bolt')body=sec('Bolts')+kv('Grid (cols × rows)',esc(`${pp.boltCols||1} × ${pp.boltRows||3}`))+kv('Diameter',v('boltDia','mm'))+kv('Grade',pp.boltGrade?esc(pp.boltGrade):'A325'+dft)+kv('Row pitch',v('boltPitch','mm'))+((Number(pp.boltCols)||1)>1?kv('Column pitch',pp.boltColPitch!=null?v('boltColPitch','mm'):dim(Number(pp.boltPitch!=null?pp.boltPitch:70))):'')+kv('Length','<span style="color:var(--mut)">auto (from grip)</span>');
13816
+ else if(pk==='bolt')body=sec('Bolts')+kv('Grid (cols × rows)',esc(`${pp.boltCols||1} × ${plateFitRows(j.id,pp.boltRows||3)}`))+kv('Diameter',v('boltDia','mm'))+kv('Grade',pp.boltGrade?esc(pp.boltGrade):'A325'+dft)+kv('Row pitch',v('boltPitch','mm'))+((Number(pp.boltCols)||1)>1?kv('Column pitch',pp.boltColPitch!=null?v('boltColPitch','mm'):dim(Number(pp.boltPitch!=null?pp.boltPitch:70))):'')+kv('Length','<span style="color:var(--mut)">auto (from grip)</span>');
13773
13817
  else if(pk==='weld')body=sec('Weld')+kv('Leg',v('weldLeg','mm'));
13774
13818
  else if(pk==='cope')body=sec('Cope')+kv('Length',dim(el&&el.width))+kv('Depth',dim(el&&el.depth))+kv('Re-entrant radius',v('copeRadius','mm'));
13775
13819
  else if(pk==='stiff')body=sec('Stiffener')+`<div class=hint style="margin:0">Opposite-side web stiffener on the support.</div>`;
@@ -14113,12 +14157,17 @@ function panel(){
14113
14157
  // #2449: a connection that is not built has no parts to select, so what rests on an assumption is said here.
14114
14158
  return `<div class=drow><div style="flex:1 1 100%;min-width:0"><div class="dmsg warn">${esc(truth.head)}</div><div class=hint role=note style="margin-top:3px">${esc(truth.detail)}</div>${joint?assumptionChipFor(joint.id):''}</div></div>`;
14115
14159
  }
14160
+ const fitNote=truthId?plateFitNote(truthId,{key:id,preview:!joint}):'';
14161
+ if(fitNote&&!(diag&&diag.code==='bolt-gauge-adjusted')){
14162
+ const preview=!joint;
14163
+ return `<div class=drow>${fitNote}`+(r.ok?`<button data-command-id="steel.connection-build#${esc(endName2(id))}" id=${id}_ap class=ghostw data-tip="${preview?'Build this connection from the detail':'Build it again from the detail, replacing what is here'}">${preview?'Build it':'Rebuild it'}</button>`:'')+`${capBtn}</div>`;
14164
+ }
14116
14165
  if(diag&&diag.code==='bolt-gauge-adjusted'){
14117
14166
  const authored=fmtDisp(Number(diag.authored)),built=fmtDisp(Number(diag.built));
14118
14167
  const preview=!joint;
14119
14168
  return `<div class=drow><div style="flex:1 1 100%;min-width:0"><div class="dmsg warn">${preview?'Would build':'Built'} with adjusted bolt gauge</div>`
14120
- +`<div class=hint role=note style="margin-top:3px"><div>Authored bolt gauge <b>${esc(authored)}</b></div><div>Bolt gauge (${preview?'after build / in exports':'built / exported'}) <b>${esc(built)}</b></div>`
14121
- +`<div style="margin-top:3px">The bolted region cannot fit the authored gauge. ${preview?'Building this detail would make':'The 3D model, IFC, and Tekla export use'} ${esc(built)}${preview?' the gauge used by the 3D model, IFC, and Tekla export.':'.'}</div></div></div>`
14169
+ +`<div class=hint role=note style="margin-top:3px"><div>${diag.valueSet===false?'Default':'Authored'} bolt gauge <b>${esc(authored)}</b></div><div>Bolt gauge (${preview?'after build / in exports':'built / exported'}) <b>${esc(built)}</b></div>`
14170
+ +`<div style="margin-top:3px">The bolted region cannot fit that gauge. ${preview?'Building this detail would make':'The 3D model, IFC, and Tekla export use'} ${esc(built)}${preview?' the gauge used by the 3D model, IFC, and Tekla export.':'.'}</div></div></div>${fitNote}`
14122
14171
  +(r.ok?`<button data-command-id="steel.connection-build#${esc(endName2(id))}" id=${id}_ap class=ghostw data-tip="${preview?'Build this connection from the detail':'Build it again from the detail, replacing what is here'}">${preview?'Build it':'Rebuild it'}</button>`:'')+`${capBtn}</div>`;
14123
14172
  }
14124
14173
  if(!o.detail&&!o.conn)return '';
@@ -14174,19 +14223,32 @@ function panel(){
14174
14223
  // joints[].id can't inject into an attribute position; the handlers below close over the real joint.
14175
14224
  const spF=(e,j,key,label,ph,unit)=>{const raw=j&&j.params&&j.params[key]!=null?j.params[key]:null;const val=raw==null?'':(unit==='mm'?esc(fmtDisp(Number(raw))):esc(String(raw)));
14176
14225
  return `<div class=elab>${label}</div><input data-command-id="steel.connection-parameter#${esc((e===1?'end':'start')+' '+label.toLowerCase())}" aria-label="${esc((e===1?'End ':'Start ')+label)}" id="spf_e${e}_${key}" inputmode=decimal placeholder="${esc(ph)}" value="${val}" autocomplete=off>${unit&&unit!=='mm'?`<span class=edec>${unit}</span>`:''}`;}; // mm params shown/entered in the project's units
14226
+ // "Set X, built Y": a plate size the person set squeezed the bolt grid (#4053). Said under the fields it came from, never changed in the model.
14227
+ const gridNotes=(j,fields)=>{const rows=connectionDiagnostics.filter(d=>d&&d.jointId===j.id&&d.code==='bolt-grid-adjusted'&&fields.includes(d.field));if(!rows.length)return '';
14228
+ const names={boltPitch:'Row spacing',plateHeight:'End distance',plateWidth:'Side distance'};
14229
+ return `<div class=hint role=note style="margin:3px 0">${rows.map(d=>{const [a,b]=plateFitApart(d.authored,d.built);return `<div>${esc(names[d.field]||'Bolt spacing')}: ${esc(a)} ${d.valueSet===false?'default':'set'}, ${esc(b)} built.</div>`;}).join('')}</div>`;};
14177
14230
  const spBlock=({e,j})=>{const dot=e===1?dotE:dotS,lbl=e===1?'End':'Start',st=!!(j.params&&j.params.stiffener);const gus=j.kind==='brace-gusset';
14178
14231
  const gaugeDiag=connectionDiagnostics.find(d=>d&&d.jointId===j.id&&d.code==='bolt-gauge-adjusted');
14179
14232
  const builtGauge=gaugeDiag?`<div style="display:flex;justify-content:space-between;gap:8px;font-size:12px;margin:3px 0" role=note><span style="color:var(--mut)">Bolt gauge (built / exported)</span><span style="font-variant-numeric:tabular-nums">${esc(fmtDisp(Number(gaugeDiag.built)))}</span></div>`:'';
14180
14233
  return `<div class=divrow><hr><span class=sect style="margin:0">${dot}${lbl} · ${gus?'Gusset plate':'Shear plate'}</span><hr></div>
14181
- ${spF(e,j,'plateWidth','Plate width','auto','mm')}${spF(e,j,'plateHeight','Plate height','auto','mm')}${spF(e,j,'plateThickness','Thickness','3/8"','mm')}${spF(e,j,'weldLeg','Weld leg','1/4"','mm')}${gus?spF(e,j,'plateCount','Plates (1 or 2)','2',''):spF(e,j,'clearance','Clearance (beam gap)','1/2"','mm')}
14234
+ ${gus?'':`<div id="spfit_e${e}" data-plate-fit-for="${esc(j.id)}">${plateFitNote(j.id,{full:true,key:'e'+e})}</div>`}
14235
+ ${spF(e,j,'plateWidth','Plate width','auto','mm')}${spF(e,j,'plateHeight','Plate height','auto','mm')}${spF(e,j,'plateThickness','Thickness',gus?'3/8"':fmtDisp(10),'mm')}${spF(e,j,'weldLeg','Weld leg',gus?'1/4"':fmtDisp(6),'mm')}${gus?spF(e,j,'plateCount','Plates (1 or 2)','2',''):spF(e,j,'clearance','Clearance (beam gap)',fmtDisp(12.7),'mm')}
14182
14236
  <div class=elabrow><span class=elab>${gus?'Lapped side':'Web side'}</span></div>
14183
14237
  <div class=seg2 style="margin-top:0"><button data-command-id="steel.connection-web-side#${esc(lbl+' near')}" id="spside_e${e}_n" class="${(j.params&&j.params.webSide<0)?'':'on'}" aria-pressed="${(j.params&&j.params.webSide<0)?'false':'true'}">Near</button><button data-command-id="steel.connection-web-side#${esc(lbl+' far')}" id="spside_e${e}_f" class="${(j.params&&j.params.webSide<0)?'on':''}" aria-pressed="${(j.params&&j.params.webSide<0)?'true':'false'}">Far</button></div>
14184
14238
  ${gus?'':`<div class=elabrow><span class=elab>Weld sides</span></div>
14185
14239
  <div class=seg2 style="margin-top:0"><button data-command-id="steel.connection-weld-side#${esc(lbl+' near')}" id="spw_e${e}_n" class="${(j.params&&j.params.weldSide==='near')?'on':''}" aria-pressed="${(j.params&&j.params.weldSide==='near')?'true':'false'}">Near</button><button data-command-id="steel.connection-weld-side#${esc(lbl+' far')}" id="spw_e${e}_f" class="${(j.params&&j.params.weldSide==='far')?'on':''}" aria-pressed="${(j.params&&j.params.weldSide==='far')?'true':'false'}">Far</button><button data-command-id="steel.connection-weld-side#${esc(lbl+' both')}" id="spw_e${e}_b" class="${(!j.params||!j.params.weldSide||j.params.weldSide==='both')?'on':''}" aria-pressed="${(!j.params||!j.params.weldSide||j.params.weldSide==='both')?'true':'false'}">Both</button></div>`}
14186
14240
  <div class=elab style="margin-top:7px;opacity:.7">Bolts</div>
14187
- ${spF(e,j,'boltCols','Bolt columns','1','')}${spF(e,j,'boltRows','Bolt rows','3','')}${spF(e,j,'boltDia','Bolt ⌀','3/4"','mm')}${spF(e,j,'boltPitch','Row spacing','2 3/4"','mm')}${(Number(j.params&&j.params.boltCols)>1)?spF(e,j,'boltColPitch','Authored bolt gauge',(j.params&&j.params.boltPitch!=null?fmtDisp(Number(j.params.boltPitch)):'2 3/4"'),'mm'):''}${builtGauge}
14241
+ ${spF(e,j,'boltCols','Bolt columns','1','')}${spF(e,j,'boltRows','Bolt rows','3','')}${spF(e,j,'boltDia','Bolt ⌀',gus?'3/4"':fmtDisp(20),'mm')}${spF(e,j,'boltPitch','Row spacing',gus?'2 3/4"':fmtDisp(70),'mm')}${gus?'':gridNotes(j,['boltPitch'])}${(Number(j.params&&j.params.boltCols)>1)?spF(e,j,'boltColPitch','Bolt gauge',(j.params&&j.params.boltPitch!=null?fmtDisp(Number(j.params.boltPitch)):gus?'2 3/4"':fmtDisp(70)),'mm'):''}${builtGauge}
14242
+ ${gus?'':`${spF(e,j,'edgeDist','End / edge distance','auto','mm')}${gridNotes(j,['plateHeight','plateWidth'])}${spF(e,j,'holeClearance','Hole oversize','standard hole','mm')}`}
14188
14243
  <div class=elabrow><span class=elab>Bolt grade</span></div>
14189
14244
  <div class=seg2 style="margin-top:0"><button data-command-id="steel.connection-bolt-grade#${esc(lbl+' A325')}" id="spg_e${e}_325" class="${(j.params&&j.params.boltGrade==='A490')?'':'on'}" aria-pressed="${(j.params&&j.params.boltGrade==='A490')?'false':'true'}">A325</button><button data-command-id="steel.connection-bolt-grade#${esc(lbl+' A490')}" id="spg_e${e}_490" class="${(j.params&&j.params.boltGrade==='A490')?'on':''}" aria-pressed="${(j.params&&j.params.boltGrade==='A490')?'true':'false'}">A490</button></div>
14245
+ ${gus?'':spF(e,j,'fastenerStandard','Bolt standard','from bolt grade','').replace('inputmode=decimal','inputmode=text')}
14246
+ ${gus?'':`<div class=elabrow><span class=elab data-tip="Shop is the default until you choose Site">Bolt type</span></div>
14247
+ <div class=seg2 style="margin-top:0"><button data-command-id="steel.connection-bolt-type#${esc(lbl+' shop')}" id="spbt_e${e}_shop" class="${(j.params&&j.params.boltType==='site')?'':'on'}" aria-pressed="${(j.params&&j.params.boltType==='site')?'false':'true'}">Shop</button><button data-command-id="steel.connection-bolt-type#${esc(lbl+' site')}" id="spbt_e${e}_site" class="${(j.params&&j.params.boltType==='site')?'on':''}" aria-pressed="${(j.params&&j.params.boltType==='site')?'true':'false'}">Site</button></div>
14248
+ <div class=hint style="margin:4px 0 0">Left empty, the bolt standard follows the bolt grade, and the material is left for the host program to fill in.</div>
14249
+ ${spF(e,j,'plateMaterial','Plate material','from the project','').replace('inputmode=decimal','inputmode=text')}${spF(e,j,'fastenerMaterial','Bolt material','from the project','').replace('inputmode=decimal','inputmode=text')}
14250
+ <div class=elab style="margin-top:7px;opacity:.7" data-tip="Applies where this beam end meets a girder. Empty uses the default.">Cope settings (at a girder)</div>
14251
+ ${spF(e,j,'copeRadius','Cope radius',fmtDisp(12.7),'mm')}${spF(e,j,'copeKClear','Fillet clearance',fmtDisp(12.7),'mm')}${spF(e,j,'copeMinLength','Minimum cope length',fmtDisp(31.75),'mm')}`}
14190
14252
  <div class=hint style="margin:4px 0 0">Bolt length auto-sizes from the grip (AISC) → shown on the bolt callout.</div>
14191
14253
  ${gus?`<div class=hint style="margin:4px 0 0">The brace is set back to the support face automatically — a gusset has no erection gap to enter.</div>`:`<div class=elabrow><span class=elab>Opposite stiffener</span><label class=defck><input data-command-id="steel.connection-stiffener#${esc(lbl)}" aria-label="${esc(lbl+' opposite stiffener')}" type=checkbox id="spck_e${e}"${st?' checked':''}>add</label></div>`}
14192
14254
  <div class="row f"><button data-command-id="steel.connection-end-remove#${esc(lbl)}" class="ghostw" id="sprm_e${e}" data-tip="Delete this end's ${gus?'gusset':'shear plate'}" style="color:var(--err);border-color:var(--err-edge)">Remove ${gus?'gusset':'shear plate'}</button></div>`;};
@@ -14318,6 +14380,7 @@ function panel(){
14318
14380
  // below, where a backtick and a ${...} in the prose are not prose at all: they closed the literal and
14319
14381
  // the rest parsed as code. An HTML comment inside a template literal is still template text.
14320
14382
  p.innerHTML=`<h3>Member <span style="text-transform:none">${esc(m.id)}</span></h3>
14383
+ ${cutsNotDrawnHTML(m)}
14321
14384
  <div class="row hint" id=memberMark>${memberMarks(m.id).length?'Mark <b style="overflow-wrap:anywhere">'+esc(memberMarks(m.id).join(', '))+'</b>':'No mark'}</div>
14322
14385
  ${drawingLinkRow(m)}
14323
14386
  ${typeFilterHTML(arr)}
@@ -14526,16 +14589,19 @@ function panel(){
14526
14589
  if(b)b.onclick=()=>{if(isBrace(m))return;edit(()=>{ModelCmd.copyEndTo(m,1,0);});};}
14527
14590
  // shear-plate inspector wiring (per detailed end) — every mutation rides edit() → undoable; editing
14528
14591
  // makes the plate user-owned (survives the auto-detail "Clear"). Bolt grid capped (rows×cols = parts).
14529
- for(const {e,j} of spjs){const jid=j.id,MAXC=20,MAXD=100000; // jid is a JS closure var (the find key), never placed in the DOM
14592
+ for(const {e,j} of spjs){const jid=j.id,MAXC=20,MAXD=100000,ZERO_OK=['clearance','edgeDist','holeClearance','copeKClear','copeMinLength']; // jid is a JS closure var (the find key), never placed in the DOM
14530
14593
  const wsp=(key,isInt)=>{const i=document.getElementById('spf_e'+e+'_'+key);if(!i)return;i.onchange=ev=>{
14531
14594
  const raw=(ev.target.value||'').trim();let n;if(isInt){n=raw===''?NaN:Math.round(Number(raw.replace(',','.')));}else{const pl=parseLenMm(raw);n=(pl==null)?NaN:pl;} // dimensional fields entered in ft-in/inches → store mm
14595
+ if(isFinite(n)&&n>(isInt?MAXC:MAXD))toast('Set '+raw+', kept at '+(isInt?MAXC:fmtDisp(MAXD))+': the most this panel takes.');
14532
14596
  edit(()=>{const jj=(C.joints||[]).find(x=>x&&x.id===jid);if(!jj)return;if(!jj.params)jj.params={};
14533
- if(isFinite(n)&&n>0)jj.params[key]=Math.min(isInt?MAXC:MAXD,n);else delete jj.params[key];
14597
+ if(isFinite(n)&&(n>0||(n===0&&ZERO_OK.includes(key))))jj.params[key]=Math.min(isInt?MAXC:MAXD,n);else delete jj.params[key]; // a typed 0 is a value where the engine takes one (a gap, an edge, a hole oversize, a cope clearance)
14534
14598
  // Enabling multiple columns: seed the column pitch from the current row pitch so the two axes are
14535
14599
  // DECOUPLED (else an absent boltColPitch silently inherits boltPitch and later row-pitch edits move both).
14536
14600
  if((Number(jj.params.boltCols)||1)>1&&jj.params.boltColPitch==null)jj.params.boltColPitch=jj.params.boltPitch!=null?jj.params.boltPitch:70;
14537
14601
  markJointTuned(jj);});};};
14538
- ['plateWidth','plateHeight','plateThickness','weldLeg','clearance','boltDia','boltPitch','boltColPitch'].forEach(k=>wsp(k,false));['boltCols','boltRows','plateCount'].forEach(k=>wsp(k,true));
14602
+ ['plateWidth','plateHeight','plateThickness','weldLeg','clearance','boltDia','boltPitch','boltColPitch','edgeDist','holeClearance','copeRadius','copeKClear','copeMinLength'].forEach(k=>wsp(k,false));
14603
+ for(const k of ['fastenerStandard','plateMaterial','fastenerMaterial']){const t=document.getElementById('spf_e'+e+'_'+k);if(t)t.onchange=ev=>{const v=(ev.target.value||'').trim().slice(0,60);edit(()=>{const jj=(C.joints||[]).find(x=>x&&x.id===jid);if(!jj)return;if(!jj.params)jj.params={};if(v)jj.params[k]=v;else delete jj.params[k];markJointTuned(jj);});};}
14604
+ ['boltCols','boltRows','plateCount'].forEach(k=>wsp(k,true));
14539
14605
  {const setSide=(s)=>edit(()=>{const jj=(C.joints||[]).find(x=>x&&x.id===jid);if(!jj)return;if(!jj.params)jj.params={};jj.params.webSide=s;markJointTuned(jj);}); // which face of the web the plate laps
14540
14606
  const n=document.getElementById('spside_e'+e+'_n');if(n)n.onclick=()=>setSide(1);
14541
14607
  const f=document.getElementById('spside_e'+e+'_f');if(f)f.onclick=()=>setSide(-1);}
@@ -14543,10 +14609,14 @@ function panel(){
14543
14609
  const wn=document.getElementById('spw_e'+e+'_n');if(wn)wn.onclick=()=>setWeld('near');
14544
14610
  const wf=document.getElementById('spw_e'+e+'_f');if(wf)wf.onclick=()=>setWeld('far');
14545
14611
  const wb=document.getElementById('spw_e'+e+'_b');if(wb)wb.onclick=()=>setWeld('both');}
14612
+ {const setType=(t)=>edit(()=>{const jj=(C.joints||[]).find(x=>x&&x.id===jid);if(!jj)return;if(!jj.params)jj.params={};jj.params.boltType=t;markJointTuned(jj);}); // shop or site bolts
14613
+ const sh=document.getElementById('spbt_e'+e+'_shop');if(sh)sh.onclick=()=>setType('shop');
14614
+ const si=document.getElementById('spbt_e'+e+'_site');if(si)si.onclick=()=>setType('site');}
14546
14615
  {const setGrade=(g)=>edit(()=>{const jj=(C.joints||[]).find(x=>x&&x.id===jid);if(!jj)return;if(!jj.params)jj.params={};jj.params.boltGrade=g;markJointTuned(jj);}); // AISC bolt grade (length auto-sizes from grip in the engine)
14547
14616
  const a=document.getElementById('spg_e'+e+'_325');if(a)a.onclick=()=>setGrade('A325');
14548
14617
  const b=document.getElementById('spg_e'+e+'_490');if(b)b.onclick=()=>setGrade('A490');}
14549
14618
  {const ck=document.getElementById('spck_e'+e);if(ck)ck.onchange=ev=>edit(()=>{const jj=(C.joints||[]).find(x=>x&&x.id===jid);if(!jj)return;if(!jj.params)jj.params={};jj.params.stiffener=ev.target.checked;markJointTuned(jj);});}
14619
+ wirePlateFitNote(document.getElementById('spfit_e'+e),jid);
14550
14620
  {const rm=document.getElementById('sprm_e'+e);if(rm)rm.onclick=()=>edit(()=>{C.joints=(C.joints||[]).filter(x=>x!==j);});}} // Remove is undoable
14551
14621
  }
14552
14622
  // Definition points (F14) — each coord commits through edit() (undo + 2D + 3D + autosave). Enter = commit(blur),
@@ -15453,6 +15523,7 @@ function connPropRows(cs){
15453
15523
  const plate=(partsById||{})[cs.conn+':plate']||(partsById||{})[cs.conn+':plateA']||null; // …same for the gusset pair
15454
15524
  const dim=mm=>(mm==null?'—':fmtDisp(Number(mm)));
15455
15525
  const cols=pp.boltCols||(isBP?2:1),rows=pp.boltRows||(isBP?2:3);
15526
+ const fitRows=connectionDiagnostics.find(d=>d&&d.jointId===cs.conn&&d.code==='plate-fit-adjusted'&&d.field==='boltRows'),builtRows=fitRows?fitRows.built:rows;
15456
15527
  return [
15457
15528
  {label:'Type', value:connKindLabel(cs.kind)},
15458
15529
  {label:'On member', value:cs.main},
@@ -15460,9 +15531,9 @@ function connPropRows(cs){
15460
15531
  {label:'Plate height', value:plate?dim(plate.depth):'—'},
15461
15532
  {label:'Plate thickness', value:plate?dim(plate.thickness):dim(pp[isBP?'thickness':'plateThickness'])},
15462
15533
  {label:'Weld leg', value:dim(pp.weldLeg||(isBP?8:6))},
15463
- {label:isBP?'Anchor grid':'Bolt grid', value:cols+' × '+rows},
15534
+ {label:isBP?'Anchor grid':'Bolt grid', value:cols+' × '+plateFitRows(cs.conn,rows)},
15464
15535
  {label:isBP?'Anchor diameter':'Bolt diameter', value:dim(pp.boltDia||(isBP?24:20))},
15465
- {label:isBP?'Anchor count':'Bolt count', value:String(cols*rows)},
15536
+ {label:isBP?'Anchor count':'Bolt count', value:String(cols*builtRows)},
15466
15537
  {label:'Parts', value:String(cs.childIds.length)},
15467
15538
  ];}
15468
15539
  function openConnPop(x,y){propPopConn=true;const el=propPopEl();const sr=el.querySelector('#ppSearch');
@@ -17606,6 +17677,24 @@ document.getElementById('cpLevelB').onclick=()=>openLevelModal('copy');
17606
17677
  // member Inspector can show a read-only "Cope (auto)" note (a coped beam otherwise looks like an error).
17607
17678
  let connectionFitByJoint=new Map(), connectionPartsByJoint=new Map(); // #2303 slice A: a custom connection's fit and built parts, from the last connection bake
17608
17679
  let copesByMember={}, partsById={}, connectionDiagnostics=[], connectionDiagnosticsStatus='pending', connectionDiagnosticsSeq=0, connectionDiagnosticsTimer=null, connectionPreviewJointByEnd=new WeakMap(), shownConnectionDiagnosticSignatures=new Set();
17680
+ // #4027: the cuts the 3D view could NOT draw on each member (copes, end cuts, bolt holes, openings), pushed by
17681
+ // Steel3DView after every build (view3dApi.onCutsNotDrawn), plus the copes it drew square. The member Inspect states
17682
+ // them in words at its top; the 3D view marks each with an amber "!" ring. Kept per build, never persisted.
17683
+ let cutsNotDrawnByMember={}, squareCopesByMember={}, cutsNotDrawnSig='';
17684
+ function cutsNotDrawnHTML(m){
17685
+ if(!view3dShown||!m)return '';
17686
+ const list=cutsNotDrawnByMember[m.id]||[], square=squareCopesByMember[m.id]||[];
17687
+ if(!list.length&&!square.length)return '';
17688
+ const marks=memberMarks(m.id), who=(marks.length?marks.join(', '):'member '+m.id)+(m.profile?' ('+m.profile+')':'');
17689
+ const plural={'the cope':'copes','the end cut':'end cuts','a bolt hole':'bolt holes','an opening':'openings'};
17690
+ const groups=new Map(); // one line per distinct cut: identical bolt holes read "3 bolt holes (⌀ …)", not three copies
17691
+ for(const r of list){const dia=Number(r.diameterMm)>0?` (⌀ ${fmtDisp(Number(r.diameterMm))})`:'';const k=r.label+'|'+dia;const g=groups.get(k);if(g)g.n++;else groups.set(k,{label:r.label,dia,n:1});}
17692
+ const lines=[...groups.values()].map(g=>{const what=g.n>1?`${g.n} ${plural[g.label]||'cuts'}${g.dia}`:`${g.label}${g.dia}`;
17693
+ return `<div>The 3D view couldn&#39;t cut ${esc(what)} from ${esc(who)}, so it is drawn uncut there. ${g.n>1?'The cuts are still in the model; only the 3D picture is missing them.':'The cut is still in the model; only the 3D picture is missing it.'}</div>`;});
17694
+ const callout=lines.length?`<div class=cutnd id=cutsNotDrawn role=note>${lines.join('')}</div>`:'';
17695
+ const sq=square.length?`<div class="row hint" id=copesDrawnSquare role=note>The 3D view draws ${square.length>1?square.length+' copes':'the cope'} on ${esc(who)} with a square inner corner; the model keeps the rounded one.</div>`:'';
17696
+ return callout+sq;
17697
+ }
17609
17698
  const connectionDiagnosticSignature=d=>[d.jointId,d.code,d.severity,d.field||'',d.authored==null?'':d.authored,d.built==null?'':d.built,d.supportId||''].join('|');
17610
17699
  function announceConnectionTruth(message,busy){
17611
17700
  const p=document.getElementById('panel'),s=document.getElementById('connectionTruthStatus');
@@ -17616,6 +17705,184 @@ function supportSectionWarningCopy(d){
17616
17705
  const support=d.supportId||'the named support',profile=d.profile||'this section';
17617
17706
  return {head:'Built with limited support-side fit',detail:'Support '+support+' ('+profile+') is not an I-shaped section, so the support-side cope or web-face shift was not applied. Review this connection before fabrication.'};
17618
17707
  }
17708
+ // #3997/#4011: a shear plate with a changed layout (fewer bolt rows, moved, shortened), or one whose bolts
17709
+ // or plate do not sit fully where they should. One renderer for every place the editor shows a connection: `full` carries the
17710
+ // choices (parameter block, whole connection), `compact` is the same words read-only. Amber never carries it alone: the heading
17711
+ // says what happened. FloLess checks no strength, so a reduced bolt group always says so.
17712
+ // The kind each code is, as `plate-fit-words.ts` has it (a test holds the two together).
17713
+ const PLATE_FIT_CODES=['plate-fit-adjusted','plate-fit-failed','plate-edge-short','support-face-partial','support-face-clash','support-face-close','plate-bolt-out','plate-bolt-edge','plate-weld-off','plate-unmeasured','plate-root-unknown','plate-one-row','plate-corner-fillet','plate-end-min','plate-bolt-size','plate-bolt-standard','bolt-grid-adjusted'];
17714
+ const plateFitRimOut={end:'out of the beam’s end','far-end':'out of the beam’s far end',flange:'into the beam’s flange',fillet:'past the beam’s flat web, into its root fillet or flange',leg:'into the beam’s other leg','ply-edge':'out of the beam’s edge',cope:'out of the beam at its cope',opening:'into an opening in the beam'};
17715
+ const plateFitRimNear={end:'the beam’s end','far-end':'the beam’s far end',opening:'an opening in the beam'};
17716
+ const plateFitDiags=jid=>connectionDiagnostics.filter(d=>d&&d.jointId===jid&&PLATE_FIT_CODES.includes(d.code));
17717
+ const PLACEMENT_NOUN='parameters'; // the word on this panel's own button, "Edit parameters on …"; the server's `plate-fit-words.ts` uses the same
17718
+ const plateFitLimits=ls=>(Array.isArray(ls)?ls:[]).map(l=>{const at=w=>l.clearMm==null?'':' ('+fmtDisp(l.clearMm)+' '+w+')';
17719
+ return l.what==='support-flange'?'the support’s '+l.side+' flange'+at('clear'):l.what==='support-fillet'?'the support’s '+l.side+' root fillet'+at('clear'):l.what==='beam-flange'?'the beam’s own '+l.side+' flange'+(l.noRoot?' (no root radius used)':' and root fillet'):l.what==='beam-cope'?'the beam’s '+l.side+' cope'+at('edge distance'):l.what==='set-height'?'the plate height that was set':'the bolts that are built';}).map((w,i,a)=>i===0?w:(i===a.length-1?' and ':', ')+w).join('');
17720
+ // Two small lengths whose difference is the point, the first the larger: in the project's own units, to as many places as keep them apart (`finePair` in plate-fit-words.ts).
17721
+ // Two lengths a warning sets side by side, in the project's own units, so that they never read the same (`apart` in plate-fit-words.ts).
17722
+ const plateFitApart=(a,b)=>{const x=fmtDisp(Number(a)),y=fmtDisp(Number(b));if(x!==y||Math.abs(Number(a)-Number(b))<1e-9)return [x,y];return Number(a)>=Number(b)?plateFitFine(a,b):plateFitFine(b,a).reverse();};
17723
+ const plateFitFine=(over,limit)=>{const inch=typeof displayUnits==='function'&&displayUnits()==='ft-in',k=inch?IN_TO_MM:1,u=inch?' in.':' mm';
17724
+ for(let n=inch?4:3;n<=(inch?10:9);n++){const a=Math.round(Number(over)/k*10**n)/10**n,b=Math.round(Number(limit)/k*10**n)/10**n;if(a!==b)return [a+u,b+u];}
17725
+ const b=Math.round(Number(limit)/k*1e4)/1e4+u;return ['just over '+b,b];};
17726
+ // A plate size that squeezed the bolt grid, in the words of `gridSqueezeSentence` (plate-fit-words.ts).
17727
+ const gridLine=d=>{const nm=d.field==='boltPitch'?'Row spacing':d.field==='plateWidth'?'Side distance':'End distance',[a,b]=plateFitApart(d.authored,d.built),size='the plate '+(d.field==='plateWidth'?'width':'height')+(d.sizeSet?' that was set':'');
17728
+ return nm+': '+b+' built ('+a+(d.valueSet===false?' default':' set')+'), because '+(d.field==='boltPitch'?size+' leaves room for no more':'an edge distance can use at most 40% of '+size)+'. Change the plate size, or leave it.';};
17729
+ function plateFitWords(list,preview){
17730
+ const did=preview?'Would be built':'Built';
17731
+ const of=(code,field)=>list.find(d=>d.code===code&&(field===undefined||d.field===field)),L=v=>fmtDisp(Number(v)),
17732
+ // A length too small for the project's own rounding is never said as 0.
17733
+ LS=v=>{const n=Number(v);if(!(n>0)||fmtDisp(n)!==fmtDisp(0))return L(n);const q=[0.1,0.5,1,IN_TO_MM/16,IN_TO_MM/8].find(x=>fmtDisp(x)!==fmtDisp(0));return q===undefined?L(n):'less than '+L(q);};
17734
+ const rows=of('plate-fit-adjusted','boltRows'),height=of('plate-fit-adjusted','plateHeight'),off=of('plate-fit-adjusted','plateOffset'),edge=of('plate-fit-adjusted','edgeDist');
17735
+ const short=of('plate-edge-short'),failed=of('plate-fit-failed'),partial=of('support-face-partial'),clash=of('support-face-clash'),close=of('support-face-close'),hole=of('plate-bolt-out'),near=of('plate-bolt-edge'),weld=of('plate-weld-off'),blind=of('plate-unmeasured'),root=of('plate-root-unknown'),oneRow=of('plate-one-row'),corner=of('plate-corner-fillet'),size=of('plate-bolt-size'),boltStd=of('plate-bolt-standard'),endMin=of('plate-end-min'),lines=[];
17736
+ const set=list[0]&&list[0].layoutSet,from=set===false?'from the default layout':'to its '+PLACEMENT_NOUN;
17737
+ let head='';
17738
+ if(failed)head='The plate does not fit. This is drawn '+from+', not a layout that works';
17739
+ else if(clash)head='The beam’s end runs into the column flange';
17740
+ else if(hole)head=hole.field==='fillet'?'A bolt hole is past the beam’s flat web':'A bolt hole runs '+(plateFitRimOut[hole.field]||plateFitRimOut.end);
17741
+ else if(rows)head=rows.built===1?did+' with a single bolt row ('+rows.authored+' '+(rows.valueSet===false?'by default':'authored')+')':did+' with '+rows.built+' of '+rows.authored+(rows.valueSet===false?'':' authored')+' bolt rows';
17742
+ else if(height||off||edge)head=did+' with the plate moved or resized';
17743
+ else if(list.some(d=>d.code==='bolt-grid-adjusted'))head=did+' with the bolt spacing or edge distance cut to the plate size';
17744
+ else if(short)head='A bolt is close to the beam’s cope';
17745
+ else if(partial)head='The plate does not bear fully on the column flange';
17746
+ else if(close)head='The beam’s end is close to the column flange';
17747
+ else if(near)head='A bolt is close to '+(plateFitRimNear[near.field]||plateFitRimNear.end);
17748
+ else if(weld)head=weld.field==='web'?'The plate’s weld is off the column’s '+(weld.part||'web'):'The plate’s weld is off the column';
17749
+ else if(blind)head=/^weld/.test(blind.field||'')?'The plate’s weld was not measured':'The fit was not measured';
17750
+ else if(root)head='Holes checked on an assumption';
17751
+ else if(endMin)head=endMin.field==='none'?'The minimum end distance is not known':endMin.edge==='side'?'A side distance is below the code minimum':endMin.edge==='both'?'The end and side distances are below the code minimum':'An end distance is below the code minimum';
17752
+ else if(size)head='The design code does not list this bolt size';
17753
+ else if(boltStd)head='The bolt standard may not list this bolt size';
17754
+ else if(oneRow)head='One bolt row: check the engineer accepts it';
17755
+ else if(corner)head='Checked on an assumption';
17756
+ const expected=d=>'the '+(d.valueSet===false?'default ':'authored ')+'clearance is '+L(d.authored)+(d.least!=null?', and at least '+L(d.least)+' is expected':'');
17757
+ // Heaviest first, since a read-only copy shows the first line only: strength, what does not fit, the layout, placement, what was not measured, assumptions.
17758
+ if(rows)lines.push('Not strength-checked: check the reduced bolt group.');
17759
+ const [failHas,failNeeds]=failed?plateFitApart(failed.built,failed.authored):['',''];
17760
+ if(failed&&failed.field==='plateHeight')lines.push('The plate height that was set, '+failHas+', cannot hold one bolt row, which needs '+failNeeds+'.');
17761
+ else if(failed)lines.push('One bolt row needs '+failNeeds+' of plate, and there is '+failHas+(failed.limits&&failed.limits.length?' between '+plateFitLimits(failed.limits):'')+'.');
17762
+ if(clash)lines.push('The beam’s end runs '+LS(-clash.built)+' into the column flange; '+expected(clash)+'. Built '+from+'.');
17763
+ if(hole)lines.push('A bolt hole '+(hole.built<-1e-6?'runs '+LS(-hole.built):'reaches')+' '+(plateFitRimOut[hole.field]||plateFitRimOut.end)+'. Built '+from+'.');
17764
+ if(short){const sa=plateFitApart(short.built,short.authored),sm=short.minimum?plateFitApart(short.built,short.minimum.mm):['',''];lines.push(sa[0]+' from bolt to cope, under the '+(short.valueSet===false?'default ':'authored ')+sa[1]+(short.minimum&&short.built<short.minimum.mm?' and the rule minimum '+sm[1]+' ('+short.minimum.clause+')':'')+'. Built '+from+'.');}
17765
+ if(close)lines.push('The beam’s end is '+LS(close.built)+' from the column flange; '+expected(close)+'. Built '+from+'.');
17766
+ if(near){const np=plateFitApart(near.built,near.authored);lines.push('A bolt stands '+(np[0]===L(near.built)?LS(near.built):np[0])+' from '+(plateFitRimNear[near.field]||plateFitRimNear.end)+', under the '+(near.valueSet===false?'default ':'authored ')+'edge distance '+np[1]+'. Built '+from+'.');}
17767
+ if(weld&&weld.field==='web'){const [off,ok]=plateFitFine(weld.built,weld.authored);lines.push('The plate’s weld lies '+off+' off the column’s '+(weld.part||'web')+' it welds to, where '+ok+' is allowed, so the connection is not fully built. Built '+from+'.');}
17768
+ else if(weld)lines.push('The plate’s weld lies '+LS(weld.built)+' off the column it welds to. Built '+from+'.');
17769
+ if(rows&&rows.limits&&rows.limits.length)lines.push('The rows are limited by '+plateFitLimits(rows.limits)+'.');
17770
+ const by=d=>d.limits&&d.limits.length?', limited by '+plateFitLimits(d.limits):'';
17771
+ if(height)lines.push('Plate height '+L(height.built)+' ('+(height.valueSet===false?'worked out as ':'authored ')+L(height.authored)+')'+(height.limits&&height.limits.length===1&&height.limits[0].what==='bolts'?', to suit the bolts that are built':by(height))+'.');
17772
+ if(off)lines.push('Plate moved '+L(Math.abs(off.built))+(off.built>0?' up':' down')+' from the beam’s centre'+by(off)+'.');
17773
+ if(edge&&Number(edge.built)<Number(edge.authored))lines.push('End distance '+L(edge.built)+' ('+(edge.valueSet===false?'default ':'authored ')+L(edge.authored)+'), to keep two bolt rows on the beam’s flat web.');
17774
+ else if(edge)lines.push('Edge distance '+L(edge.built)+' ('+(edge.valueSet===false?'default ':'authored ')+L(edge.authored)+', too little to keep the hole off the plate’s edge).');
17775
+ if(rows||height||off||edge)lines.push(set===false?'This differs from the default layout.':'This differs from its '+PLACEMENT_NOUN+', which are unchanged in the model.');
17776
+ for(const d of list)if(d.code==='bolt-grid-adjusted')lines.push(gridLine(d));
17777
+ if(size)lines.push(String(size.said||'').replace(/^./,c=>c.toUpperCase())+'.');
17778
+ if(boltStd)lines.push(boltStd.bolt+' is a metric size, and its bolt standard '+boltStd.said+', the default, is an inch one that a bolt catalogue may not list at that size. Set the bolt standard (A325M for a metric bolt) if it does not.');
17779
+ if(endMin){if(endMin.field==='none')lines.push('Minimum end distance not known for '+String(endMin.bolt||'').replace(/\.$/,'')+'.');else{const eb=plateFitApart(endMin.built,endMin.minimum.mm),sb=plateFitApart(endMin.builtSide,endMin.minimum.mm),sv=plateFitApart(endMin.authored,endMin.built),sizeSet=endMin.field==='plateWidth'||endMin.field==='plateHeight';
17780
+ lines.push((endMin.edge==='side'?'Side distance':endMin.edge==='both'?'End and side distances':'End distance')+' below the code minimum for '+endMin.bolt+': '+(endMin.edge==='both'?eb[0]+' end and '+sb[0]+' side':eb[0])+', minimum '+eb[1]+' ('+endMin.minimum.clause+'). '+(sizeSet?(endMin.edge==='both'?'The plate size that was set leaves it so. Built as it is set.':'The plate '+(endMin.field==='plateWidth'?'width':'height')+' that was set, '+L(endMin.authored)+', leaves it so. Built as it is set.'):Math.abs(Number(endMin.built)-Number(endMin.authored))<1e-6?'Built as it is set.':'Set to '+sv[0]+', built at '+sv[1]+'.'));}}
17781
+ if(list.some(d=>d.codeAssumed))lines.push('AISC 360 assumed: no design code set for this model.');
17782
+ if(partial&&head!=='The plate does not bear fully on the column flange')lines.push('The plate does not bear fully on the column flange.');
17783
+ else if(partial)lines.push('The beam is not square to the flange, or the plate passes its edge. No part of the plate is in the flange. Built '+from+'.');
17784
+ for(const blind of list.filter(d=>d.code==='plate-unmeasured'))lines.push(/^weld/.test(blind.field||'')?'The plate’s weld on column '+(blind.supportId||'')+' was not measured'+(blind.field==='weld-cut'?': a cut in the column cannot be built in the solid it is measured on.':(blind.profile?' ('+blind.profile+')':'')+': FloLess has no solid of the column to measure it on.'):blind.field==='cut'?'Fit not measured: a cut in the beam or its column cannot be built in the solid it is measured on.':blind.field==='opening'?'Fit not measured: an opening is cut where the beam meets its column, and the solid it is measured on does not have it.':blind.field==='lost'?'Holes not fully measured: a cut drawn in the beam is not in the solid they were measured on.':'Fit not measured for this section'+(blind.profile?' ('+blind.profile+')':'')+': FloLess has no solid of it to measure on.');
17785
+ if(root&&root.field==='leg')lines.push('Heel fillet not checked: holes were checked against the other leg’s inner face, not the flat leg'+(root.profile?' ('+root.profile+')':'')+'.');
17786
+ else if(root)lines.push((root.field==='taper'?'Root radius not used, because the flanges taper':root.field==='unusable'?'The catalogue’s root radius cannot be used on this section':'Root radius not in the catalogue')+': holes were checked against the flange’s inner face, not the flat web'+(root.profile?' ('+root.profile+')':'')+'.');
17787
+ if(oneRow&&head!=='One bolt row: check the engineer accepts it')lines.push('One bolt row: check the engineer accepts it.');
17788
+ if(corner)lines.push('Stiffener corners not checked at the support’s fillet. Corner clips are not modelled yet.');
17789
+ if(root||oneRow||corner||size||endMin&&endMin.field==='none')lines.push('Estimated, not a clean pass.');
17790
+ const offWeb=!!hole&&['fillet','flange','leg','ply-edge','cope'].includes(hole.field);
17791
+ const laid=!hole&&(rows||failed)&&(rows||failed).onFlatWeb;
17792
+ return {head,lines,needsRows:!!(rows||failed||short||hole||size),rowsLost:!!(rows||failed),offWeb:!!hole&&!(rows||failed||short)||!!laid,laid:!!laid&&!!rows,sizeOnly:!!size&&!(rows||failed||short||hole),
17793
+ place:hole&&!offWeb?'in the beam’s steel':(root&&root.field==='leg')||hole&&hole.field==='leg'?'clear of the beam’s other leg':root?'clear of the flange’s inner face':'on the beam’s flat web'};
17794
+ }
17795
+ function plateFitNote(jid,opts){
17796
+ const list=plateFitDiags(jid);if(!list.length)return '';
17797
+ const o=opts||{},w=plateFitWords(list,o.preview),hid='pf_'+(o.key||'x');
17798
+ // Read-only copies carry the heading and its first line (the not-strength-checked clause when rows were lost); the full one sits with the parameters.
17799
+ const text=`<div class="dmsg warn" id="${hid}">${esc(w.head)}</div><div class=hint style="margin-top:3px">${(o.full?w.lines:w.lines.slice(0,1)).map(t=>`<div>${esc(t)}</div>`).join('')}</div>`;
17800
+ if(!o.full)return `<div role=note aria-labelledby="${hid}" style="flex:1 1 100%;min-width:0;margin:0 0 6px">${text}</div>`;
17801
+ return `<div role=group aria-labelledby="${hid}" style="margin:0 0 8px">${text}
17802
+ <div class="row f" style="gap:6px;flex-wrap:wrap;margin:6px 0 2px"><button class=ghostw data-command-id="steel.connection-fit-rfi" data-plate-fit-rfi data-tip="Ask about this connection in an RFI. Nothing is filed until you file it">Raise an RFI…</button>${plateFitAssume(list)}</div>
17803
+ <div data-plate-fit-choices role=status tabindex=-1 style="min-height:44px;outline:none">${plateFitChoicesHtml(jid,w)}</div></div>`;
17804
+ }
17805
+ // A beam end in or near the flange: the person may go on with it as built. That is an assumption, and only a person records one, by
17806
+ // confirming the AI's card, so this only puts the request in the chat box. Off the FloLess window there is no chat to put it in.
17807
+ const plateFitBeamEnd=list=>list.some(d=>d.code==='support-face-clash'||d.code==='support-face-close');
17808
+ const plateFitWeldWeb=list=>!plateFitBeamEnd(list)&&!list.some(d=>d.code==='plate-bolt-out')&&list.some(d=>d.code==='plate-weld-off'&&d.field==='web');
17809
+ const plateFitAssumes=list=>plateFitBeamEnd(list)||list.some(d=>d.code==='plate-bolt-out')||plateFitWeldWeb(list);
17810
+ const plateFitChat=()=>{try{const s=window.parent&&window.parent!==window?window.parent:null;return s&&s.flolessChat&&typeof s.flolessChat.fillMessageBox==='function'?s.flolessChat:null;}catch(_){return null;}};
17811
+ function plateFitAssume(list){
17812
+ if(!plateFitAssumes(list))return '';
17813
+ return plateFitChat()?'<button class=ghostw style="white-space:normal;height:auto;min-height:28px;padding:4px 8px;line-height:1.35" data-command-id="steel.connection-fit-assume" data-plate-fit-assume data-tip="Puts a request in the AI chat box. Nothing is sent or recorded until you send it and confirm the card">Ask AI to record leaving it as built…</button>'
17814
+ :'<div class=hint>In the FloLess window, AI chat can record leaving it as built.</div>';
17815
+ }
17816
+ // The connection's id is the file's own text, so it goes into the request as a quoted value: one line, nothing invisible, capped.
17817
+ const plateFitAssumeText=(jid,beamEnd=true,weldWeb=false)=>'Propose an assumption on connection '+JSON.stringify(String(jid).replace(/[\p{C}\p{Zl}\p{Zp}]/gu,'').slice(0,120))+' that I accept '+(weldWeb?'the plate weld as built, for its check shear-plate:weld-on-steel':beamEnd?'the beam end as built, for its check shear-plate:beam-end':'the bolt holes as built, for its check shear-plate:bolt-in-beam')+'. Read it with the connection readiness first, show me the card, and I will read and confirm it. Do not change the model.';
17818
+ // What would build every row is worked out only once a warning is opened here, on the very document the warning came from
17819
+ // (`connectionDiagnosticsSeq`): an edit moves that number, so a list from before it is never shown or applied. Waiting, failed
17820
+ // and found are three states of their own; "none" is said only of a list that was really worked out.
17821
+ const plateFitAsked=new Map();
17822
+ const plateFitAnswer=jid=>{const a=plateFitAsked.get(jid);return a&&a.seq===connectionDiagnosticsSeq?a:null;};
17823
+ function plateFitChoicesHtml(jid,w){
17824
+ if(!w.needsRows)return '<div class=hint>Leave it to keep it as built.</div>';
17825
+ const a=plateFitAnswer(jid);
17826
+ if(!a||a.status==='loading')return '<div class=hint>'+(w.offWeb?'Checking which changes would keep every hole '+w.place+'…':w.rowsLost?'Checking which changes would fit every bolt row…':'Checking which changes would keep the edge distance…')+'</div>';
17827
+ if(a.status==='error')return `<div class="dmsg warn">FloLess could not work out what would fit: ${esc(a.why)} The connection is unchanged.</div>
17828
+ <div class="row f" style="gap:6px;flex-wrap:wrap;margin:6px 0 2px"><button class=ghostw data-command-id="steel.connection-fit-retry" data-plate-fit-retry>Try again</button></div><div class=hint>Leave it to keep it as built.</div>`;
17829
+ if(a.not)return '<div class=hint><div>'+(a.not==='support-cut'?'Nothing was worked out: the support is cut here.':a.not==='end'?'Nothing was worked out: a change of rows, spacing or bolt does not move this hole.':a.not==='cut'?'Nothing was worked out: a cut drawn here is not in the solid the holes are measured on.':'Nothing was worked out: no change of rows, spacing or bolt would build this connection, because something else on it does not fit.')+'</div><div>Leave it to keep it as built.</div></div>';
17830
+ const pick=a.choices.map((c,i)=>{const rowsChoice=c.param==='boltRows',one=rowsChoice&&c.value===1,what=rowsChoice?(one?'one bolt row':c.value+' bolt rows'):c.param==='boltPitch'?'row spacing':'bolt ⌀',say=c.param==='edgeDist'?'two rows: end distance below the code minimum':c.name?'bolt '+c.name+(c.smaller?' (smaller than drawn, not strength-checked)':''):rowsChoice?what:what+' '+fmtDisp(c.value),min=c.param==='edgeDist'?' ('+fmtDisp(c.value)+' vs '+fmtDisp(c.belowMinimum.mm)+', '+c.belowMinimum.clause+')':c.belowMinimum?' (below the '+fmtDisp(c.belowMinimum.mm)+' minimum, '+c.belowMinimum.clause+')':'';
17831
+ return `<button class=ghostw style="white-space:normal;height:auto;min-height:24px;padding:4px 8px;line-height:1.35" data-command-id="steel.connection-fit-choice#${esc(say)}" data-plate-fit="${i}" data-tip="${esc((c.name?'Uses a bolt size the design code lists, built and measured':c.param==='edgeDist'?'Builds two rows with the end distance the flat web leaves. Not strength-checked':w.offWeb?(rowsChoice?'Builds '+what+', every hole '+w.place+'. Not strength-checked':'Builds all '+c.rows+' rows with every hole '+w.place):'Builds all '+c.rows+' rows at their full edge distance')+'. Undo restores the value before')}">${esc('Use '+say+(one?': check the engineer accepts it':rowsChoice?(w.place==='on the beam’s flat web'?' (fits the flat web)':' ('+w.place+')'):'')+min)}</button>`;}).join('');
17832
+ if(w.offWeb||w.sizeOnly){
17833
+ const has=p=>a.choices.some(c=>c.param===p),missing=(w.sizeOnly?[]:[['boltRows','No smaller number of bolt rows'],['boltPitch','No smaller row spacing'],['boltDia','No smaller bolt']]).filter(m=>!has(m[0])&&!(w.laid&&m[0]==='boltRows')).map(m=>'<div>'+m[1]+' keeps every hole '+w.place+' and its full edge distance.</div>').join('');
17834
+ return `${pick?`<div class="row f" style="gap:6px;flex-wrap:wrap;margin:6px 0 2px">${pick}</div>`:''}<div class=hint>${missing}${a.choices.some(c=>c.param==='boltRows'&&c.value>1)?'<div>Fewer rows are not strength-checked: check the reduced bolt group.</div>':''}<div>Leave it to keep it as built.</div></div>`;
17835
+ }
17836
+ const none=!a.choices.some(c=>c.param==='boltDia')?`<div>${w.rowsLost?'No smaller bolt gives the rows back.':'No smaller bolt keeps the edge distance.'}</div>`:'';
17837
+ const noPitch=!a.choices.some(c=>c.param==='boltPitch')?`<div>No smaller row spacing keeps the edge distance.</div>`:'';
17838
+ return `${pick?`<div class="row f" style="gap:6px;flex-wrap:wrap;margin:6px 0 2px">${pick}</div>`:''}<div class=hint>${noPitch}${none}<div>Leave it to keep it as built.</div></div>`;
17839
+ }
17840
+ /** The note's own buttons. A choice is the parameter field's edit: one undoable change of the person's own. */
17841
+ function wirePlateFitNote(root,jid){
17842
+ if(!root)return;
17843
+ const rfi=root.querySelector('[data-plate-fit-rfi]');
17844
+ if(rfi)rfi.onclick=()=>{const why=openRaiseRfi(jid,null,rfi);if(why)statusToast(()=>why);};
17845
+ const assume=root.querySelector('[data-plate-fit-assume]');
17846
+ if(assume)assume.onclick=()=>{const chat=plateFitChat();if(!chat){statusToast(()=>'The AI chat is not open here.');return;}
17847
+ chat.fillMessageBox(plateFitAssumeText(jid,plateFitBeamEnd(plateFitDiags(jid)),plateFitWeldWeb(plateFitDiags(jid))));statusToast(()=>'The request is in the AI chat box. Nothing is recorded until you send it and confirm the card.');};
17848
+ const list=plateFitDiags(jid);if(!list.length)return;
17849
+ const w=plateFitWords(list);
17850
+ if(w.needsRows&&!plateFitAnswer(jid))askPlateFitChoices(jid);
17851
+ const retry=root.querySelector('[data-plate-fit-retry]');
17852
+ if(retry)retry.onclick=()=>{plateFitAsked.delete(jid);askPlateFitChoices(jid);showPlateFitChoices(jid);};
17853
+ root.querySelectorAll('[data-plate-fit]').forEach(b=>{b.onclick=()=>{const a=plateFitAnswer(jid),c=a&&a.status==='ready'?a.choices[Number(b.dataset.plateFit)]:null;
17854
+ if(!c){statusToast(()=>'The model changed since this was worked out, so FloLess is checking it again.');invalidateConnectionDiagnostics(true);panel();return;}
17855
+ edit(()=>{const jj=(C.joints||[]).find(x=>x&&x.id===jid);if(!jj)return;if(!jj.params)jj.params={};jj.params[c.param]=c.value;markJointTuned(jj);});};});
17856
+ }
17857
+ /** Draw a connection's choices again wherever its note is open, leaving everything else in the panel (and the focus) alone. */
17858
+ function showPlateFitChoices(jid){
17859
+ document.querySelectorAll('[data-plate-fit-for]').forEach(root=>{if(root.dataset.plateFitFor!==jid)return;
17860
+ const at=root.querySelector('[data-plate-fit-choices]'),list=plateFitDiags(jid);if(!at||!list.length)return;
17861
+ const again=at.contains(document.activeElement);
17862
+ at.setAttribute('aria-busy',String((plateFitAnswer(jid)||{}).status==='loading'));
17863
+ at.innerHTML=plateFitChoicesHtml(jid,plateFitWords(list));wirePlateFitNote(root,jid);
17864
+ if(again){(at.querySelector('button')||at).focus();}});
17865
+ }
17866
+ const plateFitSaid=list=>JSON.stringify(list.map(({choices:_c,choicesNot:_n,...d})=>d));
17867
+ async function askPlateFitChoices(jid){
17868
+ const seq=connectionDiagnosticsSeq,mine={seq,status:'loading',choices:[],why:''},shown=plateFitSaid(plateFitDiags(jid));plateFitAsked.set(jid,mine);
17869
+ try{
17870
+ const j=await fetchScenePayload(connectionTruthRequest().contract,{fitChoicesFor:[jid]});
17871
+ if(seq!==connectionDiagnosticsSeq)return; // the model moved: its own check asks again
17872
+ const now=(Array.isArray(j.diagnostics)?j.diagnostics:[]).filter(d=>d&&d.jointId===jid&&PLATE_FIT_CODES.includes(d.code));
17873
+ if(plateFitSaid(now)!==shown){statusToast(()=>'The model changed since this was worked out, so FloLess is checking it again.');invalidateConnectionDiagnostics(true);panel();return;}
17874
+ const sizes=now.find(d=>d.code==='plate-bolt-size'&&Array.isArray(d.choices)),rest=now.find(d=>d!==sizes&&Array.isArray(d.choices)),has=rest||sizes;
17875
+ if(!has)throw Object.assign(new Error('the reply lists no choices for '+jid),{forPerson:true,message:'the answer came back without them'});
17876
+ mine.choices=[...(sizes?sizes.choices:[]),...(rest?rest.choices:[])];mine.not=mine.choices.length?undefined:has.choicesNot;mine.status='ready';
17877
+ }catch(e){
17878
+ if(seq!==connectionDiagnosticsSeq)return;
17879
+ console.warn('Plate fit choices unavailable:',(e&&e.message)||e);
17880
+ mine.status='error';mine.why=e&&e.forPerson?e.message:e&&e.status?'the model could not be built ('+e.status+').':'FloLess did not answer.';
17881
+ }
17882
+ showPlateFitChoices(jid);
17883
+ }
17884
+ /** "2 (3 authored)" where a connection's built rows differ. */
17885
+ function plateFitRows(jid,authored){const d=connectionDiagnostics.find(x=>x&&x.jointId===jid&&x.code==='plate-fit-adjusted'&&x.field==='boltRows');return d?d.built+' ('+d.authored+(d.valueSet===false?' by default)':' authored)'):String(authored);}
17619
17886
  function connectionRefusalCopy(d,m){
17620
17887
  const support=d.supportId||'the named support',main=d.mainId||m.id,profile=d.profile||m.profile||'This profile';
17621
17888
  if(d.code==='closed-section-unsupported'){
@@ -17738,6 +18005,10 @@ function connectionStatusLine(){
17738
18005
  const bits=[];
17739
18006
  if(refused)bits.push(refused+' connection'+(refused>1?'s':'')+' not built');
17740
18007
  if(adjusted)bits.push(adjusted+' built with an adjusted bolt gauge');
18008
+ {const fit=fresh.filter(d=>/^(plate-(fit|edge|end|bolt|weld|unmeasured)|support-face-|bolt-grid)/.test(d.code)&&d.code!=='plate-bolt-size'&&!String(d.jointId).startsWith('preview-connection-')),restOn=[...new Set(fresh.filter(d=>(d.code==='plate-root-unknown'||d.code==='plate-one-row'||d.code==='plate-corner-fillet'||d.code==='plate-bolt-size')&&!String(d.jointId).startsWith('preview-connection-')&&!fit.some(f=>f.jointId===d.jointId)).map(d=>d.jointId))],ids=[...new Set(fit.map(d=>d.jointId))],rows=fit.find(d=>d.code==='plate-fit-adjusted'&&d.field==='boltRows'),failed=fit.some(d=>d.code==='plate-fit-failed'),inFlange=fit.some(d=>d.code==='support-face-clash'),holeOut=fit.some(d=>d.code==='plate-bolt-out');
18009
+ if(ids.length===1)bits.push('connection '+ids[0]+(rows?' built with '+(rows.built===1?'a single bolt row':rows.built+' bolt rows')+' of '+rows.authored+(rows.valueSet===false?'':' authored')+', not strength-checked':failed?' has a plate that does not fit':inFlange?' has a beam end in the column flange':holeOut?' has a bolt hole out of the beam':fit.some(d=>d.code==='plate-fit-adjusted'||d.code==='bolt-grid-adjusted')?' has a changed plate layout':' has a plate that needs a check'));
18010
+ else if(ids.length)bits.push(ids.length+' shear plates need a check'+(failed||inFlange||holeOut?', some do not fit':'')+(rows?', some with fewer bolt rows, not strength-checked':''));
18011
+ if(restOn.length)bits.push(restOn.length===1?'connection '+restOn[0]+' checked on an assumption':restOn.length+' connections checked on an assumption');}
17741
18012
  if(limited)bits.push(limited+' connection'+(limited>1?'s':'')+' built with limited support-side fit');
17742
18013
  if(sk.unreported)bits.push(sk.unreported+' connection'+(sk.unreported>1?'s':'')+' not shown in 3D');
17743
18014
  if(sk.noFit)bits.push(sk.noFit+' member'+(sk.noFit>1?'s':'')+' priced but not drawn — no tabulated footprint');
@@ -17777,7 +18048,7 @@ function applyConnectionBakeTruth(j,announce=true){
17777
18048
  // to the scene it is given. Only the 3D view's own fetch uses it (`cache:true`).
17778
18049
  // (the cache itself is declared at page scope, beside the #3887 scaffold state, so the review install outside main() can empty it)
17779
18050
  async function fetchScenePayload(contract=C,opts){
17780
- const body=JSON.stringify({contract});
18051
+ const body=JSON.stringify(opts&&opts.fitChoicesFor?{contract,fitChoicesFor:opts.fitChoicesFor}:{contract});
17781
18052
  const side=opts&&opts.cache?sceneSideEpoch:0; // the uncached path touches no cache state at all
17782
18053
  const key=opts&&opts.cache?serverDocEpoch+'|'+side+'|'+PROJECT_QS+'|'+body:null;
17783
18054
  if(key&&opts.serve&&sceneReplyCache.has(key)){const text=sceneReplyCache.get(key);sceneReplyCache.delete(key);sceneReplyCache.set(key,text);return JSON.parse(text);}
@@ -18141,7 +18412,12 @@ const view3dApi={
18141
18412
  // (The image bytes live in custom_details, which — as it always has — rides in the contract to the
18142
18413
  // localhost host; the point is that they are never turned into exported geometry.)
18143
18414
  for(const p of (C.detail_placements||[])){if(!p||!p.id)continue;const raw=C.custom_details[p.detailName];if(raw==null)continue;const url=String(raw).startsWith('data:')?raw:'data:image/jpeg;base64,'+raw;const el={kind:'image',id:'det:'+p.id,group:'detail',url,pos:p.pos||[0,0,0],u:p.u,n:p.n,rotZ:p.rotZ||0,size:p.size||1000,opacity:p.opacity==null?1:p.opacity};sc.elements.push(el);pb[el.id]=el;}
18415
+ sc.cutOperations=Array.isArray(j.operations)?j.operations:[]; // #4027: bolt arrays + boolean-cut cylinders → the viewer drills member holes/openings
18144
18416
  copesByMember=cm;partsById=pb;return sc;}, // cache resolved parts by id (real dims for the part Inspector) AND cope labels per member; placed details ride in as image elements
18417
+ // #4027: after every 3D build, the cuts it could not draw (and the copes it drew square). Re-render Inspect only when
18418
+ // that changed, so a routine rebuild does not repaint the panel.
18419
+ onCutsNotDrawn:(list,extra)=>{const by={},sq={};for(const r of list||[])(by[r.memberId]||(by[r.memberId]=[])).push(r);for(const r of (extra&&extra.squareCopes)||[])(sq[r.memberId]||(sq[r.memberId]=[])).push(r);
18420
+ const sig=JSON.stringify([by,sq]);if(sig===cutsNotDrawnSig)return;cutsNotDrawnSig=sig;cutsNotDrawnByMember=by;squareCopesByMember=sq;if(mode==='sel'&&selIds.size)panel();},
18145
18421
 
18146
18422
  onSelect:(id,additive)=>{if(id&&!selIdOK(id))return;releaseViewProps();aiMarkSel=null;if(id)clearWholeReferenceSelection();selDimIds.clear();sel3dDimIds.clear();if(!id){modelSelection.replaceMembers();if(!additive)modelSelection.clearGrids();}else{if(additive){selIds.has(id)?modelSelection.removeMember(id):modelSelection.addMember(id);}else{modelSelection.replaceMembers([id]);modelSelection.clearGrids();}}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // 3D pick → shared model-wide selection (byId/selArr span all sheets, so no plan switch needed; clears dimension + non-additive grid selection so Delete is unambiguous). A filtered object (Select switch off) is inert.
18147
18423
  onSelectMany:(ids,additive)=>{const ids2=selectableIds(ids||[]); // 3D box / whole-connection → gate each framed id through the Select switches (members by type, connection parts by kind)
@@ -24553,7 +24829,7 @@ function build3DLegend(){const host=legendBody('objects'),vis=legendVis(),in3d=l
24553
24829
  const refocus=(()=>{const a=host.ownerDocument.activeElement;return a&&host.contains(a)&&a.closest?legendRowId(a.closest('.lrow')):'';})();
24554
24830
  // …and a group header or its box (#3208: Instructor focuses them, and Enter / Space on one rebuilds the list).
24555
24831
  const refocusHdr=(()=>{const a=host.ownerDocument.activeElement,h=a&&host.contains(a)&&a.closest?a.closest('.cat-hdr'):null;return h?{cat:h.dataset.cat,box:!!(a.classList&&a.classList.contains('cat-tog'))}:null;})();
24556
- const groups=in3d?window.Steel3DView.getGroups():planGroups(),placedDetails=in3d?(C.detail_placements||[]).filter(d=>d&&d.id):[];host.replaceChildren(); // 2D: only what is drawn on this sheet
24832
+ const groups=in3d?window.Steel3DView.getGroups():planGroups(),placedDetails=in3d?(C.detail_placements||[]).filter(d=>d&&d.id):[];if(in3d&&build3DLegend.clipHost&&build3DLegend.clipHost.parentNode===host){for(const n of Array.from(host.childNodes))if(n!==build3DLegend.clipHost)n.remove();}else host.replaceChildren(); // 2D: only what is drawn on this sheet
24557
24833
  const empty=!groups.length&&!placedDetails.length;
24558
24834
  if(empty){host.appendChild(Object.assign(document.createElement('div'),{className:'lsempty',textContent:in3d?'No objects in the model yet.':'No members on this sheet yet.'}));
24559
24835
  if(in3d||!((P.dims||[]).length||gridOf()))return;} // the other tabs are independent of scene parts; a sheet with no members still lists its dimensions and grid
@@ -24737,8 +25013,13 @@ function build3DLegend(){const host=legendBody('objects'),vis=legendVis(),in3d=l
24737
25013
  }
24738
25014
  // CLIP — one provider-neutral list and interaction session is mounted by the shared 3D layer.
24739
25015
  // Steel and Revit therefore share selection, range selection, rename, enable, delete and empty-state behavior.
24740
- if(in3d){const clipHost=Object.assign(document.createElement('div'),{id:'m3dSharedClipList'});host.appendChild(clipHost);
24741
- modelEditor.steel.mountClipList(clipHost);}
25016
+ // The host is kept across rebuilds (a clip change rebuilds this list) and never leaves the page while it does: the rows
25017
+ // above it move instead. A press whose blur commit caused the rebuild then still clicks the live control it was aimed at
25018
+ // (the browser drops a click whose pressed node was taken out of the page, even if put back).
25019
+ // It lives on the function (build3DLegend.clipHost) so the one element outlasts every call.
25020
+ if(in3d){const clipHost=build3DLegend.clipHost||=Object.assign(document.createElement('div'),{id:'m3dSharedClipList'});
25021
+ if(clipHost.parentNode===host)while(clipHost.nextSibling)host.insertBefore(clipHost.nextSibling,clipHost);else host.appendChild(clipHost);
25022
+ modelEditor.steel.mountClipList(clipHost);}
24742
25023
  {const rst=Object.assign(document.createElement('div'),{className:'lreset',id:'m3dLegendReset',textContent:'Show all'});rst.setAttribute('role','button');rst.dataset.tip=in3d?'Restore hidden or isolated objects and turn off Ghost Unselected':'Show every member on this sheet again';rst.addEventListener('click',legendReset);host.insertBefore(rst,host.firstChild);} // Show-all reset — body's first child (above the mode toggle); visibility set by updateLegendReset (via refresh3DLegend)
24743
25024
  refresh3DLegend();applyLegendFilter();refreshLegendSel();
24744
25025
  // ONE tab stop for every keyboard-operable row, applied over the FINISHED list: the kinds are appended
@@ -29408,6 +29689,7 @@ function rfiTargetControls(r,occurrenceIndex){
29408
29689
  const EDITOR_FOCUS_3D_WAIT_MS=20000;
29409
29690
  /** The last-resort sentence when showing what was asked for failed in a way the runner did not foresee. */
29410
29691
  function editorFocusFailed(req){
29692
+ if(req.clashCheckId)return 'FloLess could not open that clash check result. Open it from History again.';
29411
29693
  if(req.makePrecise)return 'FloLess could not open Make precise. Press Open Make precise again, or open the AI decisions strip and press Make precise.';
29412
29694
  if(req.rfiId)return 'FloLess could not show '+req.rfiId+'. Find it on the RFIs page, or press it in the chat again.';
29413
29695
  return req.memberId?'The model could not show member '+req.memberId+'. Press Show in the model again, or find it in the Model panel.'
@@ -29499,6 +29781,8 @@ async function runMakePreciseFocus(current){
29499
29781
  return {ok:false,said:'Make precise could not open because a check on the member ends is still running. Press Open Make precise again when it finishes.'};
29500
29782
  }
29501
29783
  async function runEditorFocus(req,current){
29784
+ // #4029: one clash check result in the drawer; what it could not show is the drawer's own sentence.
29785
+ if(req.clashCheckId){const r=await openClashCheckResult(req.clashCheckId);if(!current())return null;return r&&r.superseded?null:r&&r.ok?{ok:true}:{ok:false,said:(r&&r.said)||editorFocusFailed(req)};}
29502
29786
  if(req.makePrecise)return runMakePreciseFocus(current);
29503
29787
  if(req.rfiId)return runRfiFocus(req.rfiId,current);
29504
29788
  const until=Date.now()+EDITOR_FOCUS_3D_WAIT_MS;
@@ -33793,6 +34077,9 @@ function mountSketches(){
33793
34077
  publishSelection:(items)=>modelPanelPublishPick(items),
33794
34078
  // The note being typed, so a tool switch, a pause or leaving the mode adds it instead of losing it.
33795
34079
  noteText:()=>{const b=document.getElementById('skTextBox');return b&&!b.hidden?document.getElementById('skTextIn').value:'';},
34080
+ // Sketches S1c (#3643): Convert with AI saves the model first; Re-attach to another face arms the ◇ Plane menu's Pick face.
34081
+ flushModel:async()=>{try{const f=await window.flushContract();return{ok:!!(f&&f.etag)};}catch(e){return{ok:false};}},
34082
+ pickFace:()=>{try{modelEditor.dispatch('model.work-plane.pick','face');return true;}catch(_){return false;}},
33796
34083
  askChat:(text)=>{const sh=sketchShell();try{if(sh&&sh.flolessChat&&sh.flolessChat.fillMessageBox){sh.flolessChat.fillMessageBox(text);return true;}}catch(_){}return false;},
33797
34084
  });
33798
34085
  window.SketchEditor=ed;
@@ -34095,16 +34382,29 @@ async function changeReviewJson(url,options){
34095
34382
  if(!response.ok||value.ok===false)throw Object.assign(new Error('change review request'),{status:response.status,body:value});
34096
34383
  return value;
34097
34384
  }
34098
- function changeReviewIsOpen(){const d=document.getElementById('changeReviewDrawer');return !!d&&!d.hidden;}
34385
+ function changeReviewIsOpen(){const d=document.getElementById('changeReviewDrawer');return !!d&&!d.hidden&&changeReviewMode==='review';}
34386
+ // #4029: the drawer shows Review changes or the clash check's results, one at a time; each keeps its own host and state.
34387
+ let changeReviewMode='review';
34388
+ function setDrawerMode(mode){
34389
+ changeReviewMode=mode;
34390
+ const clash=mode==='clash';
34391
+ document.getElementById('changeReviewHost').hidden=clash;
34392
+ document.getElementById('clashCheckHost').hidden=!clash;
34393
+ document.getElementById('changeReviewTitle').textContent=clash?'Clashes':'Review changes';
34394
+ document.getElementById('changeReviewClose').setAttribute('aria-label',clash?'Close Clashes':'Close Review changes');
34395
+ document.getElementById('reviewChangesB').setAttribute('aria-expanded',String(!clash&&!document.getElementById('changeReviewDrawer').hidden));
34396
+ }
34099
34397
  function closeChangeReview(restoreFocus){
34100
34398
  const d=document.getElementById('changeReviewDrawer');if(!d||d.hidden)return;
34101
34399
  d.hidden=true;document.getElementById('reviewChangesB').setAttribute('aria-expanded','false');
34102
34400
  changeReview.seq++; // a Show in 3D still waiting on the view is no longer wanted
34401
+ clashCheck.seq++;
34103
34402
  if(restoreFocus!==false){try{document.getElementById('moreBtn').focus({preventScroll:true});}catch(_){/* focus is a courtesy */}}
34104
34403
  }
34105
34404
  async function openChangeReview(){
34106
34405
  const d=document.getElementById('changeReviewDrawer'),host=document.getElementById('changeReviewHost');
34107
- d.hidden=false;document.getElementById('reviewChangesB').setAttribute('aria-expanded','true');
34406
+ if(modelChecksIsOpen())closeModelChecks(false); // one drawer at a time: both sit at the right edge
34407
+ d.hidden=false;setDrawerMode('review');document.getElementById('reviewChangesB').setAttribute('aria-expanded','true');
34108
34408
  try{document.getElementById('changeReviewTitle').focus({preventScroll:true});}catch(_){/* focus is a courtesy */}
34109
34409
  if(!changeReview.ui){
34110
34410
  if(!changeReview.opening)changeReview.opening=(async()=>{
@@ -34130,16 +34430,215 @@ async function openChangeReview(){
34130
34430
  // Every opening lists the versions again: the draft is whatever it is now.
34131
34431
  if(changeReview.ui&&changeReviewIsOpen())changeReview.ui.load();
34132
34432
  }
34433
+ // ── Check for clashes (#4029) ───────────────────────────────────────────────────────────────────────────────────
34434
+ // The saved model, checked for parts that overlap or touch, at the tolerance the person sets. The dialog and the results
34435
+ // are web/model-clash-check.js; the results use this same drawer. The check reads the saved model and changes nothing.
34436
+ const clashCheck={ui:null,opening:null,seq:0,returnFocus:null};
34437
+ /** Show a clash check's part (a plate, a bolt, a weld) in 3D, with any member beside it; its connection where a part cannot be selected on its own. */
34438
+ async function focusClashParts(ids,opts){
34439
+ const o=opts||{},current=o.current||(()=>true);
34440
+ const choice=viewChoiceSeq;
34441
+ let ready=await requestFocusView();
34442
+ if(!current())return null;
34443
+ ready=await view3dSettled(ready,current,choice);
34444
+ if(ready===null)return null;
34445
+ if(!ready||!window.Steel3DView)return {ok:false,reason:'view',said:'The 3D view could not show these parts.'};
34446
+ const members=ids.filter(id=>(C.members||[]).some(m=>m&&m.id===id));
34447
+ const parts=ids.filter(id=>partsById&&partsById[id]);
34448
+ const shown=[...members,...parts];
34449
+ if(!shown.length)return {ok:false,reason:'missing',said:'These parts are not in the current model (the model may have changed since this check).'};
34450
+ const filtered=members.filter(id=>!selIdOK(id));
34451
+ if(filtered.length)return {ok:false,reason:'filter',said:'Member '+filtered[0]+' is excluded by the selection filter. Turn on that member type under Select, then try again.'};
34452
+ if(viewMode==='split')setActivePane('3d');
34453
+ if(modelEditor.isReady()&&modelEditor.steel.clearConnSel)modelEditor.steel.clearConnSel();
34454
+ modelSelection.replaceMembers(shown);selDimIds.clear();sel3dDimIds.clear();modelSelection.clearGrids();render();
34455
+ if(!shown.every(id=>selIds.has(id))){
34456
+ // A part the 3D view will not select on its own is shown with its connection, and the person is told so.
34457
+ const conn=parts.map(id=>partsById[id]&&partsById[id].conn).find(Boolean);
34458
+ if(!conn)return {ok:false,reason:'select',said:'The 3D view could not select these parts.'};
34459
+ const r=await focusConnection(conn,{current,fallbackToMain:true});
34460
+ if(!r)return null;
34461
+ return r.ok?{ok:true,said:'The part could not be selected on its own, so its connection '+conn+' is shown.'}:r;
34462
+ }
34463
+ if(modelEditor.dispatch('model.fit-selection')===false)return {ok:false,reason:'frame',said:'These parts are selected, but they are hidden in the 3D view. Use Show all in the Visibility menu, then press Show in 3D again.'};
34464
+ const missing=ids.length-shown.length;
34465
+ return missing?{ok:true,said:(missing===1?'One of them is':missing+' of them are')+' not in the current model, so not shown.'}:{ok:true};
34466
+ }
34467
+ /** The objects a check result points at, shown in 3D: members as Review changes shows them, a part as itself, a joint as its connection. */
34468
+ function focusClashTarget(target){
34469
+ const mine=++clashCheck.seq,current=()=>mine===clashCheck.seq;
34470
+ const ids=(target&&Array.isArray(target.ids)?target.ids:[]).filter(id=>typeof id==='string'&&id);
34471
+ if(!ids.length)return Promise.resolve({ok:false,said:'FloLess could not tell which objects these are, so they cannot be shown in 3D.'});
34472
+ if(target.kind==='joint')return focusConnection(ids[0],{current,fallbackToMain:true});
34473
+ if(target.kind==='part')return focusClashParts(ids,{current});
34474
+ const gone=ids.filter(id=>!(C.members||[]).some(m=>m&&m.id===id));
34475
+ if(gone.length)return Promise.resolve({ok:false,reason:'missing',said:'Member '+gone[0]+' is not in the current model (the model may have changed since this check).'});
34476
+ return focusReviewMembers(ids,{current});
34477
+ }
34478
+ function clashDialogOpen(){return document.getElementById('clashCheckModal').style.display==='flex';}
34479
+ function openClashDialog(){
34480
+ clashCheck.returnFocus=document.activeElement&&document.activeElement!==document.body?document.activeElement:document.getElementById('moreBtn');
34481
+ document.getElementById('clashCheckModal').style.display='flex';
34482
+ }
34483
+ function closeClashDialog(){
34484
+ if(!clashDialogOpen())return;
34485
+ document.getElementById('clashCheckModal').style.display='none';
34486
+ const back=clashCheck.returnFocus;clashCheck.returnFocus=null;
34487
+ try{(back&&back.isConnected?back:document.getElementById('moreBtn')).focus({preventScroll:true});}catch(_){/* focus is a courtesy */}
34488
+ }
34489
+ /** The ids of what is selected now, as the check names them: members, connection parts and connections. */
34490
+ function clashSelectionIds(){
34491
+ const out=[];
34492
+ for(const id of selIds){
34493
+ if(typeof id!=='string'||/^det:/.test(id))continue;
34494
+ if((C.members||[]).some(m=>m&&m.id===id)||(partsById&&partsById[id]))out.push(id);
34495
+ }
34496
+ return out;
34497
+ }
34498
+ function clashWorkArea(){
34499
+ try{const st=modelEditor.isReady()?modelEditor.steel.clipState():null;const wa=st&&st.workArea;
34500
+ return wa&&wa.enabled&&wa.box&&Array.isArray(wa.box.min)&&Array.isArray(wa.box.max)?{min:wa.box.min,max:wa.box.max}:null;}
34501
+ catch(_){return null;}
34502
+ }
34503
+ function showClashDrawer(){
34504
+ const d=document.getElementById('changeReviewDrawer');
34505
+ const wasHidden=d.hidden||changeReviewMode!=='clash';
34506
+ if(modelChecksIsOpen())closeModelChecks(false); // one drawer at a time: both sit at the right edge (#3690)
34507
+ d.hidden=false;setDrawerMode('clash');
34508
+ if(wasHidden){try{document.getElementById('changeReviewTitle').focus({preventScroll:true});}catch(_){/* focus is a courtesy */}}
34509
+ }
34510
+ async function clashCheckUi(){
34511
+ if(clashCheck.ui)return clashCheck.ui;
34512
+ if(!clashCheck.opening)clashCheck.opening=(async()=>{
34513
+ try{
34514
+ const panel=await import('./model-clash-check.js');
34515
+ clashCheck.ui=panel.mountClashCheck({host:document.getElementById('clashCheckHost'),doc:document,projectId:PROJECT,fetchJson:changeReviewJson,
34516
+ locate:focusClashTarget,showDrawer:showClashDrawer,updateAware:clashUpdateAware,
34517
+ dialog:{body:document.getElementById('clashCheckBody'),foot:document.getElementById('clashCheckFoot'),open:openClashDialog,close:closeClashDialog,isOpen:clashDialogOpen},
34518
+ editor:{selection:clashSelectionIds,workArea:clashWorkArea,hasUnsavedEdits:()=>{try{return !!editorHasUnsavedWork();}catch{return false;}},
34519
+ // The editor's own save (the one Approve and Ctrl+S use), so "Save and check" checks what is on screen.
34520
+ save:()=>window.flushContract()}});
34521
+ }catch(e){
34522
+ console.error('[steel] Check for clashes could not be opened',e);
34523
+ toast('Check for clashes could not be opened. Reload the page and try again; if it keeps happening, use Report an issue.');
34524
+ }finally{clashCheck.opening=null;}
34525
+ })();
34526
+ await clashCheck.opening;
34527
+ return clashCheck.ui;
34528
+ }
34529
+ /**
34530
+ * The clash check's "Update AWARE…": FloLess's own AWARE update, opened through the footer's Upgrade AWARE pill in the
34531
+ * shell (the Agent Library's "Update AWARE →" does the same). True when it opened; otherwise what to tell the person.
34532
+ */
34533
+ function clashUpdateAware(){
34534
+ let shell=null;try{shell=window.parent&&window.parent!==window?window.parent:null;}catch(_){shell=null;}
34535
+ let pill=null;try{pill=shell?shell.document.getElementById('aware-update'):null;}catch(_){pill=null;}
34536
+ if(pill&&!pill.hidden&&!pill.disabled){pill.click();return true;}
34537
+ return shell?'FloLess has no newer AWARE to offer this computer yet. When one is available, Upgrade AWARE shows beside the AWARE version at the bottom of the window.':'Open this model in FloLess to update AWARE.';
34538
+ }
34539
+ /** ⋯ → Model checks → Check for clashes…: the settings dialog. */
34540
+ async function openClashCheck(){const ui=await clashCheckUi();if(ui)ui.openSettings({});}
34541
+ /** One stored check in the drawer (History's row, a link from the chat). Resolves the editor focus answer. */
34542
+ async function openClashCheckResult(checkId){
34543
+ const ui=await clashCheckUi();
34544
+ if(!ui)return {ok:false,said:'Check for clashes could not be opened. Reload the page and try again.'};
34545
+ showClashDrawer();
34546
+ return ui.showCheck(checkId);
34547
+ }
34133
34548
  if(PROJECT){
34134
- document.body.classList.add('has-project'); // steel-change-review.css reveals #reviewChangesB (+ its separator)
34549
+ document.body.classList.add('has-project'); // steel-change-review.css reveals #reviewChangesB (+ its separator); model-clash-check.css reveals #clashCheckB
34135
34550
  document.getElementById('reviewChangesB').onclick=()=>{if(changeReviewIsOpen())closeChangeReview();else openChangeReview();};
34136
34551
  document.getElementById('changeReviewClose').onclick=()=>closeChangeReview();
34552
+ document.getElementById('clashCheckB').onclick=()=>{openClashCheck();};
34553
+ document.getElementById('clashCheckClose').onclick=()=>closeClashDialog();
34554
+ document.getElementById('clashCheckBackdrop').onclick=()=>closeClashDialog();
34137
34555
  // Keys pressed in the drawer stay in the drawer: Delete or Ctrl+Z on one of its buttons must not reach the model
34138
34556
  // behind it. Escape closes it, unless something inside (an open list, a finding's choice) already took the key.
34139
34557
  document.getElementById('changeReviewDrawer').addEventListener('keydown',e=>{
34140
34558
  e.stopPropagation();
34141
34559
  if(e.key==='Escape'&&!e.defaultPrevented){e.preventDefault();closeChangeReview();}
34142
34560
  });
34561
+ // The dialog keeps the keys too: Escape is Cancel, and Tab stays inside it (#confModal's trap).
34562
+ document.getElementById('clashCheckModal').addEventListener('keydown',e=>{
34563
+ e.stopPropagation();
34564
+ if(e.key==='Escape'){e.preventDefault();closeClashDialog();return;}
34565
+ if(e.key!=='Tab')return;
34566
+ const f=[...document.querySelectorAll('#clashCheckModal button,#clashCheckModal input,#clashCheckModal summary,#clashCheckModal [tabindex]:not([tabindex="-1"])')].filter(n=>!n.disabled&&n.offsetParent!==null);
34567
+ if(!f.length)return;const first=f[0],last=f[f.length-1];
34568
+ if(e.shiftKey&&document.activeElement===first){e.preventDefault();last.focus();}else if(!e.shiftKey&&document.activeElement===last){e.preventDefault();first.focus();}
34569
+ });
34570
+ // A standalone tab opened on one result (/steel-editor.html?project=…&clashCheck=<id>). The shell itself hands a result
34571
+ // over through flolessEditorFocus({clashCheckId}), never through the address (see EditorFocus).
34572
+ const askedCheck=new URLSearchParams(location.search).get('clashCheck');
34573
+ if(askedCheck&&/^[0-9a-f]{64}$/.test(askedCheck))setTimeout(()=>{openClashCheckResult(askedCheck);},0);
34574
+ }
34575
+ // ── Model checks: the fit of walls, slabs and footings (#3690 E1d, ruling F7) ─────────────────────────────────────────
34576
+ // The server measures and words everything (element-fit.ts); the drawer lists it and sends back only the person's own
34577
+ // choices: an assumption (the assumption log, outside the model) and the fold limit (the element edit route's
34578
+ // set-fit-limit, as the person). Imported on first use, like Review changes.
34579
+ const modelChecks={ui:null,opening:null};
34580
+ function modelChecksIsOpen(){const d=document.getElementById('modelChecksDrawer');return !!d&&!d.hidden;}
34581
+ function closeModelChecks(restoreFocus){
34582
+ const d=document.getElementById('modelChecksDrawer');if(!d||d.hidden)return;
34583
+ d.hidden=true;document.getElementById('modelChecksB').setAttribute('aria-expanded','false');
34584
+ if(restoreFocus!==false){try{document.getElementById('moreBtn').focus({preventScroll:true});}catch(_){/* focus is a courtesy */}}
34585
+ }
34586
+ async function modelChecksJson(url,options){
34587
+ const response=await fetch(url,{credentials:'same-origin',...(options||{})});
34588
+ const value=await response.json().catch(()=>({}));
34589
+ if(!response.ok||value.ok===false)throw Object.assign(new Error('model checks request'),{status:response.status,body:value});
34590
+ return value;
34591
+ }
34592
+ /** The fold limit, set as the person through the element edit route; the model the reply holds becomes the editor's. */
34593
+ async function setFitFoldLimit(deg){
34594
+ await window.flushContract();
34595
+ const mid=newMutationId(),headers={'content-type':'application/json','x-floless-mutation-id':mid};if(serverEtag)headers['if-match']=serverEtag;claimMutation(mid);
34596
+ let res;try{res=await fetch('/api/contract/'+encodeURIComponent(APP_ID)+'/elements/edit'+PROJECT_QS,{method:'POST',credentials:'same-origin',headers,body:JSON.stringify({operations:[{op:'set-fit-limit',deg}]})});}
34597
+ catch(e){releaseMutation(mid);throw Object.assign(new Error('no answer'),{cause:e});}
34598
+ const d=await res.json().catch(()=>({}));
34599
+ if(!res.ok||d.ok===false){releaseMutation(mid);throw Object.assign(new Error('set-fit-limit refused'),{status:res.status,body:d});}
34600
+ if(d.contract&&typeof d.etag==='string'&&Number.isSafeInteger(d.storeRevision))installMemberEndContract(d.contract,d.etag,d.storeRevision);
34601
+ else if(typeof d.etag==='string'){
34602
+ // The reply names the setting it committed (`value: null` after a reset). The live document takes it with the tag, so
34603
+ // the next ordinary save sends it back unchanged instead of the old one, which the server would keep and warn about.
34604
+ if(d.elementFit&&typeof d.elementFit==='object'&&Object.hasOwn(d.elementFit,'value')){V2_SESSION.adoptFitSetting(d.elementFit.value);}
34605
+ const prev=serverEtag;serverEtag=d.etag;if(restampDraftBase(prev,d.etag))persist();
34606
+ }
34607
+ return d;
34608
+ }
34609
+ async function openModelChecks(){
34610
+ closeMore();
34611
+ // The shared right-edge drawer closes in either of its modes, Review changes or the clash check's results (#4029).
34612
+ if(!document.getElementById('changeReviewDrawer').hidden)closeChangeReview(false);
34613
+ const d=document.getElementById('modelChecksDrawer'),host=document.getElementById('modelChecksHost');
34614
+ d.hidden=false;document.getElementById('modelChecksB').setAttribute('aria-expanded','true');
34615
+ try{document.getElementById('modelChecksTitle').focus({preventScroll:true});}catch(_){/* focus is a courtesy */}
34616
+ if(!modelChecks.ui){
34617
+ if(!modelChecks.opening)modelChecks.opening=(async()=>{
34618
+ try{
34619
+ const panel=await import('./model-fit-checks.js');
34620
+ const q=PROJECT_QS,app=encodeURIComponent(APP_ID);
34621
+ modelChecks.ui=panel.mountFitChecks({host,doc:document,fetchJson:modelChecksJson,setFoldLimit:setFitFoldLimit,
34622
+ copyText:t=>navigator.clipboard.writeText(t),
34623
+ urls:{evaluate:'/api/contract/'+app+'/elements/evaluate'+q,assumptions:'/api/contract/'+app+'/elements/fit-assumptions'+q,
34624
+ rfiQuestion:id=>'/api/projects/'+encodeURIComponent(PROJECT)+'/element-fit/'+encodeURIComponent(id)+'/rfi-question'}});
34625
+ }catch(e){
34626
+ console.error('[steel] Model checks could not be opened',e);
34627
+ const note=document.createElement('p');note.className='mfc-state';note.setAttribute('role','alert');note.textContent='Model checks could not be opened. Close it and open it again; if it keeps happening, reload the page or use Report an issue.';host.replaceChildren(note);
34628
+ }finally{modelChecks.opening=null;}
34629
+ })();
34630
+ await modelChecks.opening;
34631
+ }
34632
+ // Every opening measures the saved model again: the fit is whatever it is now. Pending edits are saved first.
34633
+ if(modelChecks.ui&&modelChecksIsOpen()){let unsavedEdits=false;try{await window.flushContract();}catch(_){unsavedEdits=true;/* the save pill says so; the drawer says the fit is of the saved model */}modelChecks.ui.load(false,{unsavedEdits});}
34634
+ }
34635
+ if(PROJECT){
34636
+ document.getElementById('modelChecksB').onclick=()=>{if(modelChecksIsOpen())closeModelChecks();else openModelChecks();};
34637
+ document.getElementById('modelChecksClose').onclick=()=>closeModelChecks();
34638
+ document.getElementById('modelChecksDrawer').addEventListener('keydown',e=>{
34639
+ e.stopPropagation();
34640
+ if(e.key==='Escape'&&!e.defaultPrevented){e.preventDefault();closeModelChecks();}
34641
+ });
34143
34642
  }
34144
34643
  captureBootScaffold(); // #3887: the defaults boot() and main() set up, taken BEFORE a browser draft lands on top — a value the draft restores is the person's, never a default to strip
34145
34644
  const _restored=restoreSaved(bootRecordedBase);bootDraftRestored=!!_restored; // bring back this browser's saved edits before first paint
@@ -34992,7 +35491,7 @@ function askAiShell(){
34992
35491
  async function askAiRefreshRuntimes(){
34993
35492
  let info=null;
34994
35493
  try{const shell=askAiShell();info=shell?await shell.readOnlyRequestOptions():await (await fetch('/api/terminal-runtimes')).json();}catch(_){info=null;}
34995
- askAiRuntimes=Array.isArray(info?.found)?info.found:(Array.isArray(info?.runtimes)?info.runtimes.filter(r=>r&&r.state==='found'&&r.canRunReadOnly===true):[]);
35494
+ askAiRuntimes=Array.isArray(info?.found)?info.found:(Array.isArray(info?.runtimes)?info.runtimes.filter(r=>r&&r.readiness==='ready'&&r.canRunReadOnly===true):[]);
34996
35495
  askAiProvider=askAiRuntimes.some(r=>r.id===info?.provider)?info.provider:(askAiRuntimes[0]?.id||null);
34997
35496
  askAiRenderRuntimeMenu();askAiPaintDelivery();
34998
35497
  }