const fs = require('fs')
const content = fs.readFileSync('src/pages/agent-system/asset-detail/index.vue', 'utf8')
const lines = content.split('\n')

let depth = 0
let issues = []

lines.forEach((line, index) => {
  const lineNum = index + 1
  const openTags = (line.match(/<view(?![^>]*\/>)/g) || []).length
  const closeTags = (line.match(/<\/view>/g) || []).length
  const selfClosing = (line.match(/<view[^>]*\/>/g) || []).length

  depth += openTags - closeTags

  if (depth < 0) {
    issues.push(`Line ${lineNum}: More closing than opening tags (depth: ${depth})`)
    issues.push(`  ${line.trim().substring(0, 100)}`)
  }
})

console.log(`Final depth: ${depth}`)
if (depth !== 0) {
  console.log(`Missing ${depth} closing </view> tags`)
}

if (issues.length > 0) {
  console.log('\nIssues found:')
  issues.forEach(issue => console.log(issue))
}
