@floless/app 0.142.0 → 0.144.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 (54) hide show
  1. package/dist/floless-server.cjs +218260 -189290
  2. package/dist/schemas/steel.model.v2.schema.json +50 -2
  3. package/dist/schemas/tekla.model.v1.schema.json +66 -0
  4. package/dist/schemas/tekla.model.v2.schema.json +69 -0
  5. package/dist/schemas/tekla.source-package.v1.schema.json +37 -0
  6. package/dist/skills/floless-app-steel-takeoff/SKILL.md +24 -1
  7. package/dist/skills/floless-app-workflows/SKILL.md +8 -2
  8. package/dist/skills/floless-app-workflows/references/workspace-data.md +25 -4
  9. package/dist/templates/floless-workspace-model-report.flo +27 -23
  10. package/dist/templates/revit-model.flo +6 -2
  11. package/dist/templates/tekla-model-report.flo +60 -0
  12. package/dist/templates/tekla-parser.flo +61 -0
  13. package/dist/web/app.css +89 -2
  14. package/dist/web/app.js +5 -4
  15. package/dist/web/aware.js +441 -47
  16. package/dist/web/chat.css +2 -0
  17. package/dist/web/chat.js +37 -3
  18. package/dist/web/commands-revit.js +4 -0
  19. package/dist/web/commands-shell.js +136 -3
  20. package/dist/web/commands-steel.js +8 -2
  21. package/dist/web/commands-tekla-parser.js +48 -0
  22. package/dist/web/commands.js +1 -1
  23. package/dist/web/filter-ai-context.js +35 -6
  24. package/dist/web/filter-ai-proposal.js +40 -4
  25. package/dist/web/grid-core.js +15 -0
  26. package/dist/web/index.html +40 -2
  27. package/dist/web/instructor.js +26 -14
  28. package/dist/web/left-pane.js +160 -10
  29. package/dist/web/model-artifact-loader.js +15 -0
  30. package/dist/web/model-display-units.js +89 -0
  31. package/dist/web/model-editor-revit-adapter.js +21 -4
  32. package/dist/web/model-editor.css +4 -2
  33. package/dist/web/model-measure.js +10 -6
  34. package/dist/web/model-panel-bridge.js +46 -3
  35. package/dist/web/model-pointer-dock.js +21 -1
  36. package/dist/web/model-property-display.js +91 -0
  37. package/dist/web/model-revit-module.js +9 -0
  38. package/dist/web/model-selection-tools.js +11 -0
  39. package/dist/web/model-spatial-panel.js +52 -21
  40. package/dist/web/model-structural-grid-view.js +334 -0
  41. package/dist/web/model-tekla-selection.js +32 -0
  42. package/dist/web/model-viewport-revit-adapter.js +119 -32
  43. package/dist/web/revit-editor.css +11 -1
  44. package/dist/web/revit-editor.html +4 -3
  45. package/dist/web/revit-editor.js +589 -111
  46. package/dist/web/steel-3d-view.js +58 -372
  47. package/dist/web/steel-editor.html +258 -17
  48. package/dist/web/steel-filter.html +17 -3
  49. package/dist/web/tekla-editor.html +71 -0
  50. package/dist/web/tekla-structural-grid-adapter.js +56 -0
  51. package/dist/web/workspaces.js +872 -97
  52. package/distribution-profile-production.mjs +4 -0
  53. package/distribution-resource-inventory.mjs +4 -2
  54. package/package.json +5 -2
@@ -891,7 +891,8 @@
891
891
  .chat-q{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:2px 8px;align-items:center;padding:6px 0;border-bottom:1px solid var(--line)}
892
892
  .chat-q:last-child{border-bottom:0}
893
893
  .chat-q-note{grid-column:1;font-size:12px;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
894
- .chat-q-meta,.chat-q-about{grid-column:1;font-size:10.5px;color:var(--mut);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
894
+ .chat-q-meta,.chat-q-about,.chat-q-ai{grid-column:1;font-size:10.5px;color:var(--mut);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
895
+ .chat-q-ai{font-style:italic}
895
896
  .chat-q-show{grid-column:2;grid-row:1/span 3;align-self:center}
896
897
  .chat-q-more>summary,.chat-q-orphans>summary{cursor:pointer;font-size:11px;color:var(--mut);padding:4px 0;list-style-position:inside}
897
898
  .chat-q-more>summary:hover,.chat-q-orphans>summary:hover{color:var(--text)}
@@ -1310,6 +1311,12 @@ rect.lblhot:focus-visible{outline:2px solid var(--brand);outline-offset:2px;stro
1310
1311
  #rfiList .rfiacts button{font-size:11px;padding:3px 8px}
1311
1312
  #rfiList .rfiacts [aria-disabled=true]{opacity:.48;cursor:progress;background:var(--btn);border-color:var(--ctrl-border)}
1312
1313
  #rfiList .rfiacts [aria-disabled=true]:hover{background:var(--btn);border-color:var(--ctrl-border);color:var(--text)}
1314
+ /* #1723 — a proposed height and a typed one share one row of controls. The height field is the RFI
1315
+ form's own input treatment, compressed to the button row's height; its label sits inline so the
1316
+ row stays one line on a wide list and wraps whole on a narrow one. */
1317
+ #rfiList .rfielev{display:inline-flex;align-items:center;gap:5px}
1318
+ #rfiList .rfielev .elab{font-size:10px;text-transform:uppercase;letter-spacing:.06em;color:var(--mut);margin:0}
1319
+ #rfiList .rfielev input{width:110px;font-size:11px;padding:3px 6px}
1313
1320
  #rfiList .rfigroup-toggle{width:100%;margin-top:8px;text-align:left;display:flex;justify-content:space-between;align-items:center}
1314
1321
  #rfiList .rfioccurrences{grid-column:1/-1;margin:4px 0 0;padding:0;list-style:none;border-top:1px solid var(--line)}
1315
1322
  #rfiList .rfioccurrence{padding:10px 0;border-bottom:1px solid var(--line)}
@@ -9121,7 +9128,7 @@ async function connModifyRequest(j){
9121
9128
  }
9122
9129
  function syncV2SelectionNotice(p){
9123
9130
  if(!p||!selIds.size||viewPropsId)return; // a view in the panel keeps the selection, not its notices
9124
- p.querySelectorAll('.v2-selection-notice,.v2-elevation-warning').forEach(el=>el.remove());
9131
+ p.querySelectorAll('.v2-selection-notice,.v2-elevation-warning,.v2-elevation-proposal').forEach(el=>el.remove());
9125
9132
  const ids=[...selIds].filter(id=>!!(C.members||[]).find(m=>m&&m.id===id));
9126
9133
  if(!ids.length)return;
9127
9134
  const other=[];
@@ -9178,8 +9185,67 @@ function syncV2SelectionNotice(p){
9178
9185
  const m=projected[0],canonical=selected[0];
9179
9186
  if(m&&canonical&&m.role==='column'){mark('bos',!Number.isFinite(canonical.from?.z?.known));mark('tosC',!Number.isFinite(canonical.to?.z?.known));}
9180
9187
  else if(m&&canonical){mark('tosA',!Number.isFinite(canonical.from?.z?.known));mark('tosB',!Number.isFinite(canonical.to?.z?.known));}
9188
+ if(m&&canonical)inspectorHeightNotes(m,canonical);
9181
9189
  }
9182
9190
  }
9191
+ /**
9192
+ * Under each elevation field of ONE selected member (#1723): say when the height shown is only where the
9193
+ * end is DRAWN — nothing on the drawings confirms it — and offer the heights the drawing states, with
9194
+ * the same Use control the questions list has. Every promised apply is reachable here even when the
9195
+ * questions list is capped, because the conversation names the member and its sheet.
9196
+ *
9197
+ * The first sentence is the model's own fact (`assumed`); the proposal and its wording are the server's,
9198
+ * from the last questions read — nothing here decides which height is right.
9199
+ */
9200
+ function inspectorHeightNotes(m,canonical){
9201
+ const ids=m.role==='column'?['bos','tosC']:['tosA','tosB'];
9202
+ [0,1].forEach(end=>{
9203
+ const input=document.getElementById(ids[end]);if(!input)return;
9204
+ const z=(end===0?canonical.from:canonical.to)?.z;
9205
+ const gapKey='unknown-elevation:'+canonical.id+':'+end;
9206
+ const live=rfiState.records.find(r=>r&&r.liveGap&&r.liveGap.gapKey===gapKey);
9207
+ const g=live&&live.liveGap,p=g&&g.proposal&&g.proposal.apply==='now'?g.proposal:null;
9208
+ const assumed=!!z&&z.assumed===true&&Number.isFinite(z.known);
9209
+ if(!assumed&&!p)return;
9210
+ const box=document.createElement('div');box.className='hint v2-elevation-proposal';box.setAttribute('role','note');
9211
+ // A whole row of the field grid, never one cell of it — squeezed into the value column the sentence
9212
+ // wraps a word per line beside the field it explains.
9213
+ box.style.cssText='margin:2px 0 6px;grid-column:1/-1;line-height:1.5';
9214
+ const parts=[];
9215
+ // The server's basis-aware sentence when the questions have been read; the model's own fact otherwise.
9216
+ // Otherwise the seam's own reason, which names the real basis (a plan's cut plane, the other end, the
9217
+ // read's own number) — a plan-placed end has no live question row, and must still say why.
9218
+ const drawn=g&&g.currentValue&&g.currentValue.note?g.currentValue.note
9219
+ :'Drawn at this height for now.'+(typeof z.why==='string'&&z.why.trim()?' '+z.why.trim():' The drawings do not confirm it.');
9220
+ const confirmsDrawn=!!p&&p.candidates.every(c=>c&&(c.readings||[]).every(rd=>rd&&rd.source==='server-placement'));
9221
+ if(assumed&&!p)parts.push(drawn+' Type the right height to settle it.');
9222
+ else if(assumed&&!confirmsDrawn)parts.push(drawn);
9223
+ if(p)parts.push(p.ask);
9224
+ const text=document.createElement('div');text.textContent=parts.join(' ');box.appendChild(text);
9225
+ if(p&&rfiEndUnresolved(canonical.id,end)){
9226
+ const acts=document.createElement('div');acts.className='row';acts.style.cssText='gap:5px;flex-wrap:wrap;margin-top:4px';
9227
+ for(const c of p.candidates){
9228
+ if(!c||typeof c.key!=='string'||!Number.isFinite(c.value))continue;
9229
+ const label=fmtDispElev(c.value),what='the top of steel at the '+rfiEndWords(end,m)+' of '+canonical.id;
9230
+ const verb=(c.readings||[]).every(rd=>rd&&rd.source==='server-placement')?'Confirm':'Use';
9231
+ const b=document.createElement('button');b.className='ghost';b.type='button';
9232
+ b.setAttribute('data-command-id','steel.inspector-use-height#'+canonical.id+' '+rfiEndWords(end,m)+'#'+c.key);
9233
+ b.setAttribute('data-command-instance-label',canonical.id+' '+rfiEndWords(end,m)+' — '+label);
9234
+ b.setAttribute('aria-label',verb+' '+label+' for '+what);b.textContent=verb+' '+label;
9235
+ if(rfiElevBusy){b.setAttribute('aria-disabled','true');b.setAttribute('data-blocked-reason','A height is still being saved — wait for it to finish');}
9236
+ b.onclick=()=>{if(b.getAttribute('aria-disabled')==='true')return;
9237
+ Promise.resolve(rfiApplyHeight(rfiRowKey('record',live.id),c.value,c.key)).then(()=>render()).catch(rfiGestureFailure);};
9238
+ acts.appendChild(b);
9239
+ }
9240
+ if(acts.childNodes.length)box.appendChild(acts);
9241
+ }
9242
+ // After the field's whole ROW (label + value), never inside the value cell: `.pval` is a flex cell a
9243
+ // sentence cannot wrap in. A layout without that row falls back to just after the field.
9244
+ const cell=input.closest('.pval'),row=cell&&cell.parentElement&&cell.parentElement!==document.getElementById('panel')?cell.parentElement:null;
9245
+ const anchor=row||(input.nextElementSibling&&input.nextElementSibling.classList.contains('edec')?input.nextElementSibling:input);
9246
+ anchor.after(box);
9247
+ });
9248
+ }
9183
9249
  /**
9184
9250
  * Does something else own the panel or the selection right now?
9185
9251
  *
@@ -14116,7 +14182,7 @@ function canonicalTargetItems(ids){
14116
14182
  function subjectLabelText(text){return [...String(text||'').replace(/[\u0000-\u001f\u007f]+/g,' ').replace(/\s+/g,' ').trim()].slice(0,120).join('').trimEnd();}
14117
14183
  function subjectLabel(item){
14118
14184
  if(item.kind==='member'){const m=(C.members||[]).find(x=>x&&x.id===item.id);return m?((m.mark||m.id)+(m.profile?' · '+m.profile:'')):item.id;}
14119
- if(item.kind==='joint'){const r=connRowById(item.id);return r?connLabel(r):('Connection '+item.id);}
14185
+ if(item.kind==='joint')return 'Connection '+item.id; // a placed joint (C.joints), never a connection-library row
14120
14186
  const d=(C.detail_placements||[]).find(x=>x&&x.id===item.id);return 'Detail '+((d&&d.detailName)||item.id);
14121
14187
  }
14122
14188
  // 64-bit FNV-1a over the WHOLE canonical list, so a pill left out for one selection returns for another even
@@ -14168,16 +14234,27 @@ function refreshChatLinks(force){
14168
14234
  }
14169
14235
  function chatSubjectResolves(link){
14170
14236
  if(link.kind==='member')return (C.members||[]).some(m=>m&&m.id===link.id);
14171
- if(link.kind==='joint')return (C.connections||[]).some(r=>r&&r.id===link.id)||Object.values(partsById||{}).some(part=>part&&part.conn===link.id);
14237
+ if(link.kind==='joint')return (C.joints||[]).some(j=>j&&j.id===link.id); // the model, never the 3D part cache, which can outlive a removed joint
14172
14238
  if(link.kind==='detail')return (C.detail_placements||[]).some(d=>d&&d.id===link.id);
14173
14239
  return false;
14174
14240
  }
14175
14241
  function chatQuestionDate(iso){const d=new Date(iso);return Number.isNaN(d.getTime())?'':d.toLocaleDateString(undefined,{day:'numeric',month:'short',year:'numeric'});}
14176
- // One row per question: the links of one message collapse into it, naming the objects it was about.
14242
+ // One row per question: the links of one message collapse into it, naming the objects it was about. A link is
14243
+ // the person's selection, the chat model's note on it, or its answer naming the object (#1653). What a row says
14244
+ // never depends on which link arrived first: every link of a question carries the same question line and time,
14245
+ // the newest note wins, and "named in the answer" is a fact of the set.
14177
14246
  function chatQuestionRows(links){
14178
14247
  const byMessage=new Map();
14179
- for(const link of links){const row=byMessage.get(link.messageEventId)||{link,labels:[]};row.labels.push(link.label||link.id);byMessage.set(link.messageEventId,row);}
14180
- return [...byMessage.values()].sort((a,b)=>String(b.link.createdAt).localeCompare(String(a.link.createdAt)));
14248
+ for(const link of links){
14249
+ let row=byMessage.get(link.messageEventId);
14250
+ if(!row){row={link,labels:[],seen:new Set(),selected:false,named:false,aiNote:'',aiSeq:-1};byMessage.set(link.messageEventId,row);}
14251
+ const key=link.kind+'\0'+link.id;
14252
+ if(!row.seen.has(key)){row.seen.add(key);row.labels.push(link.label||link.id);}
14253
+ if(link.origin==='ai-answer')row.named=true;else if(link.origin==='ai-note'){if(link.linkSequence>row.aiSeq){row.aiSeq=link.linkSequence;row.aiNote=link.aiNote||'';}}
14254
+ else{if(!row.selected)row.link=link;row.selected=true;} // "When asked" reads the label from when the person asked
14255
+ }
14256
+ const askedAt=row=>String(row.link.askedAt||row.link.createdAt);
14257
+ return [...byMessage.values()].sort((a,b)=>askedAt(b).localeCompare(askedAt(a))||(b.link.sequence-a.link.sequence));
14181
14258
  }
14182
14259
  // The id is all a link knows of its object, and a reader may give a removed member's id to a new one. So a row
14183
14260
  // whose object is named differently now says what it was called when asked, rather than quietly vouching for it.
@@ -14189,15 +14266,20 @@ function chatQuestionWas(row){
14189
14266
  function chatQuestionRow(row,{about,unresolved}){
14190
14267
  const link=row.link,li=document.createElement('div');li.className='chat-q';
14191
14268
  const note=document.createElement('div');note.className='chat-q-note';note.textContent=link.note;note.dataset.tip=link.note;
14269
+ li.append(note);
14270
+ // The chat model's own sentence, said to be its own: untrusted text, one line, textContent only.
14271
+ if(row.aiNote){const ai=document.createElement('div');ai.className='chat-q-ai';ai.textContent='AI note: '+row.aiNote;ai.dataset.tip=row.aiNote;li.append(ai);}
14192
14272
  const meta=document.createElement('div');meta.className='chat-q-meta';
14193
- meta.textContent=[link.chatTitle,chatQuestionDate(link.createdAt)].filter(Boolean).join(' · ')+(link.archived?' · archived':'');
14194
- li.append(note,meta);
14273
+ meta.textContent=[link.chatTitle,chatQuestionDate(link.askedAt||link.createdAt)].filter(Boolean).join(' · ')+(link.archived?' · archived':'');
14274
+ li.append(meta);
14275
+ if(row.named){const named=document.createElement('div');named.className='chat-q-about';named.textContent=row.selected?'Also named in the answer':'Named in the answer';li.append(named);}
14195
14276
  if(about){const who=document.createElement('div');who.className='chat-q-about';
14196
14277
  const names=row.labels.slice(0,3);who.textContent=(unresolved?'Was: ':'About ')+names.join(', ')+(row.labels.length>3?' and '+(row.labels.length-3)+' more':'');li.append(who);}
14197
14278
  else{const was=chatQuestionWas(row);if(was){const who=document.createElement('div');who.className='chat-q-about';who.textContent='When asked: '+was;li.append(who);}}
14198
14279
  const show=document.createElement('button');show.type='button';show.className='ghost chat-q-show';show.textContent='Show in chat';
14199
14280
  show.dataset.commandId='steel.chat-question-show#'+link.messageEventId;show.dataset.commandInstanceLabel=link.note;
14200
14281
  show.setAttribute('aria-label','Show in chat: '+link.note);
14282
+ show.style.gridRow='1/span '+li.children.length; // spans every line this row has, and no empty ones
14201
14283
  show.onclick=()=>{if(!modelPanelBridge||!modelPanelBridge.openChat(link.chatId,link.messageEventId,PROJECT))toast('AI Chat is not open for this project. Open the project in Workspaces, then choose Show in chat again.');};
14202
14284
  li.append(show);return li;
14203
14285
  }
@@ -14240,7 +14322,8 @@ function paintChatQuestions(p){
14240
14322
  const det=document.createElement('details');det.className='chat-q-orphans';det.open=chatQuestionsOpen;
14241
14323
  det.addEventListener('toggle',()=>{chatQuestionsOpen=det.open;});
14242
14324
  const sum=document.createElement('summary');sum.dataset.commandId='steel.chat-questions-orphans';
14243
- sum.textContent='Questions about objects no longer in the model ('+atLeast+orphans.length+')';det.append(sum);
14325
+ // Removed, or never there: an answer can name an id the model lacks.
14326
+ sum.textContent='Questions about objects not in the model ('+atLeast+orphans.length+')';det.append(sum);
14244
14327
  chatQuestionList(det,orphans,{about:true,unresolved:true});
14245
14328
  box.append(head,det);p.append(box);
14246
14329
  }
@@ -21586,11 +21669,14 @@ function rfiOccurrenceOnActiveSheet(occ){
21586
21669
  /** Every row the list can show, before the status filter. Records first (newest first, as the server
21587
21670
  * sorted them), then the symptoms nobody has filed. */
21588
21671
  function rfiRowsIn(scope){
21589
- const live=rfiLiveByGap(),closed=rfiClosedByGap(),rows=[];
21672
+ const live=rfiLiveByGap(),closed=rfiClosedByGap(),rows=[],settleable=[];
21590
21673
  for(const r of rfiState.records){
21591
21674
  if(scope==='sheet'&&!rfiRecordOnActiveSheet(r))continue;
21592
- rows.push({kind:'record',record:r});
21675
+ // A question one click can settle leads (#1723): the list is capped, and a proposal a read promised
21676
+ // must not fall below the cap behind rows that need a conversation. Otherwise the server's order stands.
21677
+ (r&&r.liveGap&&r.liveGap.proposal&&r.liveGap.proposal.apply==='now'?settleable:rows).push({kind:'record',record:r});
21593
21678
  }
21679
+ rows.unshift(...settleable);
21594
21680
  for(const m of rfiSymptomMembersIn(scope)){
21595
21681
  const gap=rfiSizeGapKey(m.id);
21596
21682
  if(live.has(gap))continue; // the record is already listed above
@@ -21674,7 +21760,7 @@ async function refreshRfiRecords(opts){
21674
21760
  ?'Source: '+dt.sheet+', page '+dt.page+(dt.elementId?', element '+dt.elementId:''):'';
21675
21761
  return {
21676
21762
  id:'live:'+g.id,gapKey:g.gapKey,kind:g.kind,question:g.question,status:'open',recordRevision:0,
21677
- text:[g.question,ids.length?'Member'+(ids.length===1?'':'s')+': '+ids.join(', '):'',source].filter(Boolean).join('\n'),
21763
+ text:[(g.proposal&&typeof g.proposal.ask==='string'&&g.proposal.ask)||g.question,ids.length?'Member'+(ids.length===1?'':'s')+': '+ids.join(', '):'',source].filter(Boolean).join('\n'),
21678
21764
  subjects,checked:g.checked||[],liveOnly:true,liveGap:g,
21679
21765
  targets,
21680
21766
  }});
@@ -23332,6 +23418,125 @@ function rfiResolveControls(memberId,locked){
23332
23418
  /** The one sentence a row prints when the model holds the member but cannot draw it anywhere. */
23333
23419
  const RFI_UNREACHABLE='FloLess cannot place this member on any sheet it can map, so its size cannot be set or located from here — the sheet it is drawn on needs its registration fixed first.';
23334
23420
 
23421
+ /* ── Heights the drawing states, proposed rather than asked for (#1723) ───────────────────────────
23422
+ The server's live question row for a member end can carry a PROPOSAL — heights read off the drawing,
23423
+ each with the sheet it was read on — plus the height the end is drawn at although nothing confirms
23424
+ it, and a count of readings it held back. The browser composes none of it: it shows the server's
23425
+ sentences and offers two ways to settle the end, both the SAME edit the Inspector's elevation field
23426
+ makes (a typed height, which clears the unconfirmed mark). Nothing here decides which height is
23427
+ right; a person clicks one or types one.
23428
+
23429
+ Every Use button carries the candidate's content KEY, never its position, and the handler re-reads
23430
+ the questions before applying: a list that changed between seeing and clicking refuses rather than
23431
+ applying a different reading than the one on screen. */
23432
+ let rfiElevBusy=null; // rowKey of the height being saved, one at a time
23433
+ let rfiElevNote=null; // {rowKey,text} — the last refusal on a height row, shown in that row
23434
+ /** The member end a height question is about, from its subject — never parsed out of the gap key. */
23435
+ function rfiElevationSubject(g){
23436
+ if(!g||g.kind!=='unknown-elevation')return null;
23437
+ const s=(g.subjects||[]).find(x=>x&&typeof x.memberId==='string'&&(x.end===0||x.end===1));
23438
+ return s?{memberId:s.memberId,end:s.end}:null;
23439
+ }
23440
+ /** Is this end still unsettled in the model on screen? A settled end offers nothing to apply. */
23441
+ function rfiEndUnresolved(memberId,end){
23442
+ const m=(C.members||[]).find(x=>x&&x.id===memberId);if(!m)return false;
23443
+ const point=end===0?m.from:m.to,z=point&&point.z;
23444
+ return !!z&&(z.unknown===true||z.assumed===true);
23445
+ }
23446
+ const rfiEndWords=(end,m)=>m&&m.role==='column'?(end===0?'bottom':'top'):(end===0?'start':'end');
23447
+ /** The server's own sentences for a height row, as notes. Never re-derived here. */
23448
+ function rfiElevationNotes(g){
23449
+ if(!g||g.kind!=='unknown-elevation')return [];
23450
+ const notes=[];
23451
+ // A proposal that only CONFIRMS the drawn height already says that height and where it came from; the
23452
+ // disclosure beside it would say the same thing twice.
23453
+ const confirmsDrawn=!!(g.proposal&&Array.isArray(g.proposal.candidates)&&g.proposal.candidates.length
23454
+ &&g.proposal.candidates.every(c=>c&&Array.isArray(c.readings)&&c.readings.every(r=>r&&r.source==='server-placement')));
23455
+ if(g.currentValue&&g.currentValue.note&&!confirmsDrawn)notes.push(esc(g.currentValue.note));
23456
+ // The server's own sentence, shown as given — the chat relays the same one, so the two cannot drift.
23457
+ if(g.withheldReadings&&typeof g.withheldReadings.note==='string')notes.push(esc(g.withheldReadings.note));
23458
+ return notes;
23459
+ }
23460
+ /** The two ways to settle an end: one Use button per proposed height, and a typed height. */
23461
+ function rfiElevationControls(rowKey,rowId,g){
23462
+ const subject=rfiElevationSubject(g);
23463
+ if(!subject||!rfiEndUnresolved(subject.memberId,subject.end))return '';
23464
+ const m=byId(subject.memberId);
23465
+ if(!m)return '<div class=rfinote>'+esc(RFI_UNREACHABLE)+'</div>';
23466
+ const busy=rfiElevBusy===rowKey,blocked=!!rfiElevBusy;
23467
+ const block=blocked?' aria-disabled="true" data-blocked-reason="A height is still being saved — wait for it to finish"':'';
23468
+ const what='the top of steel at the '+rfiEndWords(subject.end,m)+' of '+subject.memberId;
23469
+ const p=g.proposal&&g.proposal.apply==='now'&&Array.isArray(g.proposal.candidates)?g.proposal:null;
23470
+ // EQUAL WEIGHT, in the server's order and not ranked: every candidate renders with the same class and
23471
+ // none takes focus by default, because "which is right" is the person's question, not this list's.
23472
+ const uses=p?p.candidates.filter(c=>c&&typeof c.key==='string'&&Number.isFinite(c.value)).map(c=>{
23473
+ const label=fmtDispElev(c.value);
23474
+ // CONFIRM when the height is the one already drawn (the server placed it and its basis has provenance);
23475
+ // USE when it was read off the drawing. Same edit either way — the word tells the person which it is.
23476
+ const verb=(c.readings||[]).every(rd=>rd&&rd.source==='server-placement')?'Confirm':'Use';
23477
+ return '<button data-command-id="steel.rfi-use-height#'+esc(rowId)+'#'+esc(c.key)+'" data-command-instance-label="'+esc(subject.memberId+' '+rfiEndWords(subject.end,m)+' — '+label)+'" data-rfi-ctl="use:'+esc(c.key)+'" data-rfi-use="'+esc(c.key)+'" data-rfi-on="'+esc(rowKey)+'" data-rfi-mm="'+esc(String(c.value))+'" class=ghost aria-label="'+verb+' '+esc(label)+' for '+esc(what)+'"'+block+'>'+verb+' '+esc(label)+'</button>';
23478
+ }).join(''):'';
23479
+ const typed='<label class=rfielev><span class=elab>Height</span><input data-command-id="steel.rfi-height#'+esc(rowId)+'" data-rfi-ctl=height data-rfi-height="'+esc(rowKey)+'" inputmode=decimal autocomplete=off aria-label="Height for '+esc(what)+'" placeholder="'+esc(g.currentValue&&Number.isFinite(g.currentValue.value)?'e.g. '+fmtDispElev(g.currentValue.value):elevExample())+'"'+(blocked?' readonly aria-disabled="true"':'')+'></label>'
23480
+ +'<button data-command-id="steel.rfi-set-height#'+esc(rowId)+'" data-command-instance-label="'+esc(subject.memberId+' '+rfiEndWords(subject.end,m))+'" data-rfi-ctl=setheight data-rfi-setheight="'+esc(rowKey)+'" aria-label="Set '+esc(what)+'"'+(busy?' aria-busy="true"':'')+block+'>'+(busy?'Setting height…':'Set height')+'</button>';
23481
+ const note=rfiElevNote&&rfiElevNote.rowKey===rowKey?'<div class=rfifail role=note>'+esc(rfiElevNote.text)+'</div>':'';
23482
+ return note+'<div class="rfiacts rfielevacts" data-rfi-elev-member="'+esc(subject.memberId)+'" data-rfi-elev-end="'+subject.end+'">'+uses+typed+'</div>';
23483
+ }
23484
+ /** The live question row a height control belongs to, from the list as last read. */
23485
+ function rfiElevationRow(rowKey){
23486
+ const r=rfiState.records.find(x=>x&&rfiRowKey('record',x.id)===rowKey);
23487
+ return (r&&r.liveGap)||null;
23488
+ }
23489
+ /**
23490
+ * Apply a height to a member end — the Inspector's own typed-elevation edit, then save and re-read.
23491
+ * `candidateKey` is the Use button's reading: the questions are re-read FIRST and the key must still be
23492
+ * offered for the same end, so a list that moved under the person refuses instead of guessing.
23493
+ */
23494
+ async function rfiApplyHeight(rowKey,mm,candidateKey){
23495
+ if(rfiElevBusy){toast('A height is still being set — wait for it to finish, then try again.');return;}
23496
+ const g0=rfiElevationRow(rowKey),subject=rfiElevationSubject(g0);
23497
+ if(!subject){toast('That question is no longer listed — the list has been refreshed.');await refreshRfiRecords({force:true});return;}
23498
+ rfiElevNote=null;
23499
+ // BUSY FROM THE FIRST AWAIT, not from the edit: two quick clicks must not both re-read and both apply.
23500
+ rfiElevBusy=rowKey;renderRfiList();rfiSay('Setting height…');
23501
+ let saveError='';
23502
+ try{
23503
+ if(candidateKey){
23504
+ // The proposal is applied only when a FRESH, complete read of the questions still offers this exact
23505
+ // height. A read that failed, or was overtaken by a newer one, proves nothing — so nothing is applied.
23506
+ const current=await refreshRfiRecords({force:true});
23507
+ if(current===false||rfiState.status!=='ok'||rfiState.liveTruth!=='known'){
23508
+ rfiElevNote={rowKey,text:'FloLess could not re-check this question just now, so nothing was changed. Try again in a moment.'};
23509
+ return;
23510
+ }
23511
+ const g=[...rfiState.records].map(x=>x&&x.liveGap).find(x=>x&&x.gapKey===g0.gapKey);
23512
+ const still=g&&g.proposal&&g.proposal.apply==='now'&&(g.proposal.candidates||[]).some(c=>c&&c.key===candidateKey&&c.value===mm);
23513
+ if(!still||!rfiEndUnresolved(subject.memberId,subject.end)){
23514
+ rfiElevNote={rowKey,text:'That reading changed since the list was shown, so nothing was applied. Check the question again.'};
23515
+ return;
23516
+ }
23517
+ }
23518
+ const m=byId(subject.memberId);
23519
+ if(!m){rfiElevNote={rowKey,text:RFI_UNREACHABLE};return;}
23520
+ const applied=edit(()=>{
23521
+ if(m.role==='column'){if(subject.end===0)ModelCmd.setBosMm(m.col,mm);else ModelCmd.setTosValueMm(m.col,mm);}
23522
+ else ModelCmd.setTosValueMm(m.ends[subject.end],mm);
23523
+ });
23524
+ if(!applied)return;
23525
+ const flushed=await rfiFlushModel().catch(e=>{console.error('[steel] could not save a height set from the questions list',e);return 'failed';});
23526
+ // Whatever the save reported, the height IS in the model on screen; the sentence says that, and not the
23527
+ // save helper's own wording, which was written for answering a question rather than setting a height.
23528
+ if(flushed)saveError='Your height is in the model on screen, but FloLess could not confirm it was saved. Save again before relying on it.';
23529
+ rfiElevBusy=null;
23530
+ const said=saveError||('The top of steel at the '+rfiEndWords(subject.end,m)+' of '+subject.memberId+' is now '+fmtDispElev(mm)+'.');
23531
+ if(saveError)rfiElevNote={rowKey,text:saveError};
23532
+ await refreshRfiRecords({force:true,actingRow:rowKey,focusWasOnActingRow:false});
23533
+ if(!saveError)toast(said);
23534
+ rfiSay(said);
23535
+ }finally{
23536
+ if(rfiElevBusy===rowKey){rfiElevBusy=null;renderRfiList();if(rfiElevNote&&rfiElevNote.rowKey===rowKey)rfiSay(rfiElevNote.text);}
23537
+ }
23538
+ }
23539
+
23335
23540
  /**
23336
23541
  * What FloLess could not do, said out loud. SEPARATE from the row rendering because it must survive a
23337
23542
  * suppressed repaint: `#rfiBanner` sits outside `#rfiList`, so repainting it never disturbs a control
@@ -23633,10 +23838,16 @@ function rfiRecordRowHtml(r){
23633
23838
  const targets=rfiTargetControls(r);
23634
23839
  const copy='<button data-command-id="steel.rfi-copy#'+esc(r.id)+'" data-command-instance-label="'+esc(r.id+' — '+kind)+'" data-rfi-ctl=copy class=ghost data-rfi-copy="'+esc(r.id)+'" data-tip="Copy this current question with its member and source context">Copy question</button>';
23635
23840
  const meta=ids.map(id=>'<span>'+esc(id)+'</span>').concat(sheets.map(sh=>'<span>Sheet '+esc(sh)+'</span>')).join('');
23636
- return '<div class="rfirow" data-rfi-row="'+esc(rowKey)+'"><span class="rfikind sym">'+esc(kind)+'</span><div class=rfitx>'
23637
- +esc(r.question||'Register this source view before placing the member in the model.')
23638
- +'<div class=rfimeta>'+meta+'</div><div class=rfinote>This question comes from the current model and remains visible even when the filed RFI list is full.</div>'
23841
+ // A height question that can PROPOSE shows the server's own ask in place of the bare question (#1723).
23842
+ const g=r.liveGap,ask=g&&g.proposal&&typeof g.proposal.ask==='string'?g.proposal.ask:'';
23843
+ const elevNotes=rfiElevationNotes(g);
23844
+ return '<div class="rfirow" data-rfi-row="'+esc(rowKey)+'"'+(rfiElevBusy===rowKey?' aria-busy="true"':'')+'><span class="rfikind sym">'+esc(kind)+'</span><div class=rfitx>'
23845
+ +esc(ask||r.question||'Register this source view before placing the member in the model.')
23846
+ +'<div class=rfimeta>'+meta+'</div>'
23847
+ +(elevNotes.length?'<div class=rfinote data-rfi-elev-note>'+elevNotes.join(' ')+'</div>':'')
23848
+ +'<div class=rfinote>This question comes from the current model and remains visible even when the filed RFI list is full.</div>'
23639
23849
  +(rfiCopyFallbackId===r.id?'<div class=rfinote style="white-space:pre-wrap;user-select:text">'+esc(r.text)+'</div>':'')
23850
+ +rfiElevationControls(rowKey,r.id,g)
23640
23851
  +'<div class=rfiacts>'+copy+targets+'</div></div></div>';
23641
23852
  }
23642
23853
  const meta=['<span>'+esc(r.id)+'</span>','<span>'+esc(rfiStatusWords(r))+'</span>']
@@ -23644,7 +23855,17 @@ function rfiRecordRowHtml(r){
23644
23855
  .concat(sheets.map(sh=>'<span>Sheet '+esc(sh)+'</span>'))
23645
23856
  .join('');
23646
23857
  const notes=[];
23647
- if(r.liveGap&&!r.liveOnly)notes.push('Placement is still unresolved because the source view is not registered. The correspondence history below remains separate from the model question.');
23858
+ // A HEIGHT overlay is not a placement one (#1723): its live row carries the server's proposal and the
23859
+ // height the end is drawn at, and the placement sentence would be false about it.
23860
+ const elevSubject=r.liveGap&&!r.liveOnly?rfiElevationSubject(r.liveGap):null;
23861
+ const elevGap=elevSubject&&(C.members||[]).some(m=>m&&m.id===elevSubject.memberId)?r.liveGap:null;
23862
+ if(r.liveGap&&!r.liveOnly&&!elevGap)notes.push('Placement is still unresolved because the source view is not registered. The correspondence history below remains separate from the model question.');
23863
+ if(elevGap){
23864
+ notes.push(...rfiElevationNotes(elevGap));
23865
+ // The server's ask as given: it already says where its height came from — a drawing's own words, a
23866
+ // picture, or the height FloLess levelled — so a prefix claiming "from the drawing" would be false for some.
23867
+ if(elevGap.proposal&&typeof elevGap.proposal.ask==='string')notes.push(esc(elevGap.proposal.ask));
23868
+ }
23648
23869
  if(r.sent)notes.push((r.sent.via==='gmail'?'Sent with Gmail to ':'Marked sent to ')+esc(r.sent.to)+' on '+esc(rfiWhen(r.sent.at))+'.');
23649
23870
  if(r.answer)notes.push('Answer: '+esc(rfiSentence(rfiAnswerText(r.answer))));
23650
23871
  if(r.applied)notes.push('Recorded as applied to the model on '+esc(rfiWhen(r.applied.at))+'.');
@@ -23733,6 +23954,7 @@ function rfiRecordRowHtml(r){
23733
23954
  +(settling?'<div class=rfinote role="note" data-rfi-profile-settle>'+esc(settling.message)+'</div>':'')
23734
23955
  +deliveryHtml
23735
23956
  +(rfiCopyFallbackId===r.id&&r.text?'<div class=rfinote style="white-space:pre-wrap;user-select:text">'+esc(r.text)+'</div>':'')
23957
+ +(elevGap&&!formOpen&&!recovering?rfiElevationControls(rowKey,r.id,elevGap):'')
23736
23958
  // The outcome renders INSIDE the form when one is open (directly above Submit, where focus lands);
23737
23959
  // at row level only when there is no form to put it in.
23738
23960
  +(formOpen?'':rfiOutcomeHtml(rowKey))
@@ -24058,6 +24280,25 @@ function wireRfiList(){
24058
24280
  rfiFocusAfterSymptomProfilePick(modal,rowKey,m.id);
24059
24281
  }});});
24060
24282
  root.querySelectorAll('button[data-rfi-profile-retry]').forEach(b=>b.onclick=()=>rfiRetryProfileSettle(b));
24283
+ // #1723: a proposed height, applied with one click, or a typed one. Both are the Inspector's own edit.
24284
+ root.querySelectorAll('button[data-rfi-use]').forEach(b=>b.onclick=()=>{
24285
+ if(b.getAttribute('aria-disabled')==='true')return;
24286
+ Promise.resolve(rfiApplyHeight(b.dataset.rfiOn,Number(b.dataset.rfiMm),b.dataset.rfiUse)).catch(rfiGestureFailure);});
24287
+ const setTyped=b=>{
24288
+ if(!b||b.getAttribute('aria-disabled')==='true')return;
24289
+ const rowKey=b.dataset.rfiSetheight;
24290
+ const input=[...root.querySelectorAll('input[data-rfi-height]')].find(x=>x.dataset.rfiHeight===rowKey);
24291
+ const typed=input?input.value.trim():'';
24292
+ const mm=typed?parseElevMm(typed):null;
24293
+ if(mm==null||!Number.isFinite(mm)){
24294
+ rfiElevNote={rowKey,text:typed?'Enter a height FloLess can read, like '+elevExample()+'.':'Type the height first, like '+elevExample()+'.'};
24295
+ rfiFocusOverride={rows:[rowKey],ctl:'height'};renderRfiList();rfiSay(rfiElevNote.text);return;
24296
+ }
24297
+ Promise.resolve(rfiApplyHeight(rowKey,mm,null)).catch(rfiGestureFailure);};
24298
+ root.querySelectorAll('button[data-rfi-setheight]').forEach(b=>b.onclick=()=>setTyped(b));
24299
+ root.querySelectorAll('input[data-rfi-height]').forEach(inp=>inp.onkeydown=e=>{
24300
+ if(e.key!=='Enter')return;e.preventDefault();
24301
+ setTyped([...root.querySelectorAll('button[data-rfi-setheight]')].find(x=>x.dataset.rfiSetheight===inp.dataset.rfiHeight));});
24061
24302
  root.querySelectorAll('button[data-loc]').forEach(b=>b.onclick=()=>rfiLocate(b.dataset.loc));
24062
24303
  root.querySelectorAll('button[data-rfi-target]').forEach(b=>b.onclick=()=>rfiOpenTarget(b));
24063
24304
  // THE CATCH-UP. A record read that landed while somebody was typing in this list did not repaint it,
@@ -1044,15 +1044,29 @@ function filterAiChangeContext(instruction){
1044
1044
  let names = '', shown = 0;
1045
1045
  for(const key of unread){
1046
1046
  const next = (names ? names+', ' : '')+JSON.stringify(key);
1047
- if(next.length > 420) break;
1047
+ if(next.length > 4000) break;
1048
1048
  names = next; shown++;
1049
1049
  }
1050
1050
  if(shown) facts.push('Not read by FloLess, so they cannot be changed here: '+names
1051
1051
  +(shown < unread.length ? ' (and '+(unread.length-shown)+' more)' : ''));
1052
1052
  }
1053
+ // THE SHEET'S WORDS, not seven of them.
1054
+ //
1055
+ // This was `slice(0,7)` then `.slice(0,500)`: seven text items, cut at 500 characters, out of a
1056
+ // sheet with dozens. It is the list the AI answers a question about text FROM, and at that size
1057
+ // it mostly answered "I cannot tell from the samples". The sheet itself now travels with the
1058
+ // question as a picture, so this list no longer has to carry the whole burden — but there is also
1059
+ // no reason to ration it, and a wider one is what makes a text question answerable at all.
1053
1060
  const texts = filterAiSnapshot().sheetTextSamples || [];
1054
- if(texts.length) facts.push(('Text samples, incomplete: '+texts.slice(0,7).map(row=>JSON.stringify([row.layer,row.text,row.selected])).join(',')).slice(0,500));
1055
- if(facts.length > 12) throw new Error('This filter has too many values for one AI message. Ask about one specific layer instead.');
1061
+ if(texts.length) facts.push(('Text on this sheet: '+texts.map(row=>JSON.stringify([row.layer,row.text,row.selected])).join(',')).slice(0,18000));
1062
+ // NO REFUSAL ON COUNT. This used to throw above twelve facts and the person got
1063
+ // "This filter has too many values for one AI message. Ask about one specific layer instead." —
1064
+ // a busy sheet could not be asked about at all, which is the opposite of what a busy sheet needs.
1065
+ // The budget is generous and the honest line below says what was listed; nothing is refused for
1066
+ // being large.
1067
+ // Room left for what the server appends (the sheet note, the tiles sentence, one per attached
1068
+ // file). Clamping to exactly the server's 200 meant those pushed it over and the message died.
1069
+ if(facts.length > 150) facts.length = 150;
1056
1070
  return { context:{ subject:instruction, commandId:'filter.ask-ai-change', surface:'steel-filter', tone:'idle', facts }, allowed };
1057
1071
  }
1058
1072
  function filterAiSelectionCopy(){
@@ -0,0 +1,71 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <title>Tekla Parser · FloLess</title>
7
+ <link rel="stylesheet" href="model-editor.css">
8
+ <link rel="stylesheet" href="revit-editor.css">
9
+ </head>
10
+ <body class="revit-model-editor" data-model-kind="tekla-parser">
11
+ <header class="authority-bar">
12
+ <div class="authority-copy">
13
+ <span class="authority-kicker">Tekla Parser</span>
14
+ <strong id="modelName">Loading model…</strong>
15
+ <span id="sourceName" class="source-name"></span>
16
+ </div>
17
+ <div id="authorityChoices" class="authority-choices" role="group" aria-label="Model authority"></div>
18
+ <div id="modelUnits" class="model-display-units"></div>
19
+ <span class="read-only-chip" data-tip="FloLess displays a copied snapshot and cannot write to the source Tekla model.">Read-only</span>
20
+ </header>
21
+ <main id="editorRoot" class="editor-root">
22
+ <section id="modelStage" class="model-stage" aria-label="Tekla model snapshot viewport">
23
+ <canvas id="modelCanvas" tabindex="0" aria-label="Interactive Tekla model snapshot"></canvas>
24
+ <div id="m3dBar" class="model-view-toolbar" role="toolbar" aria-label="Model view controls"></div>
25
+ <div id="modelViewCube" class="model-view-cube-host" aria-label="Model orientation"></div>
26
+ <div id="modelWorldAxes" class="model-world-axes-host" aria-hidden="true"></div>
27
+ <div id="modelDimensionOverlay" aria-hidden="true"></div>
28
+ <div id="modelSelectionMarquee" aria-hidden="true"></div>
29
+ <div id="modelHoverSummary" role="status" aria-live="polite" hidden></div>
30
+ <div id="modelSpatialHud" class="model-spatial-hud" aria-live="polite">
31
+ <button id="modelFrameStatus" type="button" data-command-id="tekla-parser.spatial-controls" data-tip="Open coordinate frame, working plane, clip, and work-area controls">Global</button>
32
+ <span id="modelCursorCoordinates">X — · Y — · Z — mm</span>
33
+ </div>
34
+ <div id="modelBottomDock" class="model-bottom-dock">
35
+ <div id="modelModuleActions"></div>
36
+ <div id="modelPointerBars" class="model-pointer-bars">
37
+ <div id="modelSelectBar" role="group" aria-label="Selection filter"></div>
38
+ <div id="modelSnapBar" role="group" aria-label="Snap settings"></div>
39
+ </div>
40
+ </div>
41
+ <div id="modelExplorer" hidden>
42
+ <div id="revitExplorerClassification"></div>
43
+ <div id="revitExplorerTypes"></div>
44
+ </div>
45
+ <div id="revitPanelTabs" hidden>
46
+ <div id="revitClipListHost" class="revit-clip-list-host"></div>
47
+ <div id="teklaAuditHost" class="tekla-audit-host" hidden></div>
48
+ </div>
49
+ <div id="loadingState" class="viewport-state" aria-live="polite">
50
+ <span class="state-spinner" aria-hidden="true"></span>
51
+ <strong>Opening verified snapshot</strong>
52
+ <span>Reading the signed read-only model package.</span>
53
+ </div>
54
+ </section>
55
+ <div id="inspectorResizer" class="inspector-resizer model-inspector-resizer" role="separator" tabindex="0" aria-label="Resize Properties" aria-orientation="vertical" data-tip="Drag to resize · double-click to reset"></div>
56
+ <aside id="inspectorPanel" class="inspector-panel model-inspector-panel" aria-label="Properties">
57
+ <div class="panel-heading inspector-heading"><strong>Properties</strong></div>
58
+ <div id="inspectorBody" class="inspector-body"></div>
59
+ </aside>
60
+ <div id="inspectorStub" class="model-inspector-stub" aria-hidden="true"><span class="vertical-label">Properties</span></div>
61
+ <button id="inspectorToggle" class="model-inspector-toggle" type="button" data-command-id="tekla-parser.inspector-toggle" data-tip="Collapse Properties" aria-label="Collapse Properties" aria-controls="inspectorPanel" aria-expanded="true"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="m6 3 5 5-5 5"/></svg></button>
62
+ </main>
63
+ <div id="toast" role="status" aria-live="polite"></div>
64
+ <script src="commands.js"></script>
65
+ <script src="commands-tekla-parser.js"></script>
66
+ <script src="instructor-reporter.js"></script>
67
+ <script>InstructorReporter.mount({ surface: 'tekla-parser-editor', snapshot: function () { return window.__revitInstructorState || {}; } });</script>
68
+ <script type="importmap">{"imports":{"three":"./vendor/three.module.js","three/addons/":"./vendor/"}}</script>
69
+ <script type="module" src="revit-editor.js"></script>
70
+ </body>
71
+ </html>
@@ -0,0 +1,56 @@
1
+ const SCHEMA = 'floless.tekla-structural-grid/v1';
2
+ const text = (value, name) => {
3
+ if (typeof value !== 'string' || !value.trim()) throw new TypeError(`Tekla structural grid ${name} is missing.`);
4
+ return value;
5
+ };
6
+ const finiteNonnegative = (value, name) => {
7
+ if (!Number.isFinite(value) || value < 0) throw new TypeError(`Tekla structural grid ${name} is invalid.`);
8
+ return value;
9
+ };
10
+
11
+ /**
12
+ * Rename a server-validated Tekla grid facade into grid-core's provider-neutral input.
13
+ * Parsing, cumulative spacing, labels, IDs and geometry remain grid-core responsibilities.
14
+ */
15
+ export function teklaStructuralGridContract(entity) {
16
+ const payload = entity?.structuralGrid;
17
+ if (!payload) return null;
18
+ if (payload.schemaVersion !== SCHEMA || payload.entityId !== entity.id || payload.mapping?.kind !== 'symmetric') {
19
+ throw new TypeError('The authenticated Tekla structural grid facade is inconsistent.');
20
+ }
21
+ const extents = payload.mapping.extentsMm;
22
+ const values = ['xNegative', 'xPositive', 'yNegative', 'yPositive', 'zNegative', 'zPositive']
23
+ .map((name) => finiteNonnegative(extents?.[name], name));
24
+ if (!values.every((value) => value === values[0])) throw new TypeError('The Tekla structural grid is not symmetrically mapped.');
25
+ const origin = payload.mapping.originMm;
26
+ const originValues = ['x', 'y', 'z'].map((name) => {
27
+ const value = origin?.[name];
28
+ if (!Number.isFinite(value)) throw new TypeError(`Tekla structural grid origin ${name} is invalid.`);
29
+ return value;
30
+ });
31
+ const strings = payload.strings;
32
+ const objectGuid = text(payload.objectGuid, 'GUID');
33
+ return Object.freeze({
34
+ ownerId: entity.id,
35
+ source: payload,
36
+ grid: Object.freeze({
37
+ on: true,
38
+ origin: Object.freeze(originValues.slice(0, 2)),
39
+ x: text(strings?.xSpacing, 'X coordinates'),
40
+ y: text(strings?.ySpacing, 'Y coordinates'),
41
+ z: text(strings?.zLevels, 'Z coordinates'),
42
+ labels_x: text(strings?.xLabels, 'X labels'),
43
+ labels_y: text(strings?.yLabels, 'Y labels'),
44
+ labels_z: Object.freeze(text(strings?.zLabels, 'Z labels').trim().split(/\s+/)),
45
+ hidden_z: Object.freeze([]),
46
+ ext: values[0],
47
+ identity_scope: objectGuid,
48
+ }),
49
+ });
50
+ }
51
+
52
+ export function findTeklaStructuralGrid(entities = []) {
53
+ const values = entities.map(teklaStructuralGridContract).filter(Boolean);
54
+ if (values.length > 1) throw new TypeError('The verified snapshot contains more than one drawable structural grid.');
55
+ return values[0] ?? null;
56
+ }