{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "point-gas-detector",
  "type": "registry:component",
  "title": "Point gas detector",
  "description": "Point gas detector in two real forms. ir: optical detector screwed horizontally into the side wall of an Ex d junction box (bolted lid, earth stud, gland and stopping plug), with perforated weather protection, a hollow sunshade/deluge hood and a remote gassing line to a capped calibration port. catalytic: Ex d transmitter with %LEL/ppm display and a down-pointing sinter head under a weather cap with calibration nozzle, plus an Ex d junction box. Free-standing stanchion or wall bracket; height sets the sensor elevation.",
  "dependencies": [
    "three",
    "@react-three/fiber",
    "@react-three/drei"
  ],
  "registryDependencies": [
    "https://deck-twin-library.demoareeb.workers.dev/r/core.json"
  ],
  "files": [
    {
      "path": "safety/point-gas-detector.tsx",
      "type": "registry:file",
      "target": "components/deck-twin/safety/point-gas-detector.tsx",
      "content": "// Point gas detector: IR detector screwed horizontally into an Ex d junction box under a sunshade/deluge hood with remote gassing line, or a catalytic transmitter with display and down-pointing sensor; stanchion or wall bracket. IEC 60079-29-1, IEC 60079-29-2.\nimport * as THREE from 'three'\nimport { Kit, mat4, type V3 } from '../lib/kit'\nimport { KitMesh, useKit, type GroupProps } from '../lib/mesh'\nimport { tagPlate } from '../lib/parts'\nimport { LED_GREEN, canvasMat, cable, cableToDeck, exdBox, faceZ, mounted, polePlate, stopPlug, type Mount } from './_fg'\n\nexport interface PointGasDetectorProps {\n  mount?: Mount\n  /** sensor centre above the deck, m (above the leak source for lighter-than-air gas, below it for heavier) */\n  height?: number\n  /** ir: horizontal optical detector on an Ex d box; catalytic: transmitter with display, sensor pointing down */\n  sensor?: 'ir' | 'catalytic'\n  /** target gas shown on the transmitter display */\n  gas?: string\n  /** sunshade/deluge hood over the IR detector */\n  sunshade?: boolean\n  /** remote gassing line to a calibration port at hand height */\n  gassing?: boolean\n  /** separate Ex d junction box under a catalytic transmitter */\n  junction?: boolean\n  tag?: string\n}\n\nexport const defaults = { mount: 'pole' as Mount, height: 1.2, sensor: 'ir' as 'ir' | 'catalytic', gas: 'CH4', sunshade: true, gassing: true, junction: true, tag: 'GD-2101' }\n\nexport function PointGasDetector(props: PointGasDetectorProps & GroupProps) {\n  const { mount, height, sensor, gas, sunshade, gassing, junction, tag, ...group } = { ...defaults, ...props }\n  const h = Math.max(0.5, height)\n  const data = useKit(\n    (k) => (sensor === 'ir' ? buildIr(k, mount, h, sunshade, gassing, tag) : buildCat(k, mount, h, gas, junction, tag)),\n    [mount, h, sensor, gas, sunshade, gassing, junction, tag],\n  )\n  return (\n    <group {...group}>\n      <KitMesh data={data} />\n    </group>\n  )\n}\n\nexport default PointGasDetector\n\nconst BOX: V3 = [0.16, 0.16, 0.11]\n\n/** IR detector along +X from the box side wall; origin on the bracket face, detector axis at y = 0. */\nfunction buildIr(k: Kit, mount: Mount, h: number, sunshade: boolean, gassing: boolean, tag: string) {\n  const zf = faceZ(mount)\n  const za = BOX[2] * 0.31 // detector axis out from the bracket face\n  const x0 = BOX[0] / 2 // box side wall\n  const L1 = 0.1 // stainless body\n  const L2 = 0.075 // weather protection\n  let entry: V3 = [0, 0, 0]\n  mounted(k, mount, h, [0.2, 0.24], () => {\n    entry = exdBox(k, [0, 0, 0], BOX, 2, 1)[0]\n    tagPlate(k, tag, [0, 0, BOX[2] + 0.001], 'z', 0.1)\n    // threaded boss and locknut in the box wall, stainless body, weather protection with gas holes on the underside\n    k.cyl('stainless', 0.016, 0.02, [x0 + 0.01, 0, za], 'x', 14)\n    k.hex('stainless', 0.042, 0.01, [x0 + 0.016, 0, za], 'x')\n    k.cyl('stainless', 0.03, L1, [x0 + 0.02 + L1 / 2, 0, za], 'x', 28)\n    for (const dx of [0.03, 0.07]) k.torus('stainless', 0.031, 0.0025, [x0 + 0.02 + dx, 0, za], 'x', 6, 28)\n    const xw = x0 + 0.02 + L1\n    k.lathe('rubberBlack', [[0.03, 0], [0.037, 0.002], [0.037, L2], [0.03, L2]], [xw, 0, za], 'x', 32)\n    k.disc('rubberBlack', 0.03, [xw + L2, 0, za], 'x', 32)\n    // semicircular hole pattern on the lower half of the end face, gas venting slot on the side\n    for (let i = 0; i < 7; i++) {\n      const a = Math.PI * (1.1 + (0.8 * i) / 6)\n      k.disc('pipeBore', 0.0035, [xw + L2 + 0.0006, Math.sin(a) * 0.021, za + Math.cos(a) * 0.021], 'x', 8)\n    }\n    k.box('pipeBore', [0.03, 0.004, 0.006], [xw + L2 * 0.55, -0.0368, za])\n    if (gassing) {\n      // gassing nipple on the weather protection and stainless 1/8\" line down the bracket to a capped port\n      const n: V3 = [xw + L2 * 0.45, -0.036, za]\n      k.cyl('stainless', 0.004, 0.012, [n[0], n[1] - 0.006, n[2]], 'y', 8)\n      k.tube('tubing', [[n[0], n[1] - 0.012, n[2]], [n[0], -0.1, n[2]], [0.09, -0.1, za]], 0.0032, 6, 0.02)\n      k.box('stainless', [0.03, 0.026, za], [0.072, -0.1, za / 2])\n      k.cyl('stainless', 0.006, 0.016, [0.072, -0.1, za + 0.008], 'z', 10)\n      k.cyl('actuatorRed', 0.009, 0.012, [0.072, -0.1, za + 0.02], 'z', 12)\n    }\n    if (sunshade) {\n      // hollow stainless sunshade/deluge hood over the top, clamped round the base of the weather protection\n      const xs = x0 + 0.004\n      const Ls = L1 + L2 + 0.04\n      const R = 0.055\n      const a0 = 0.9 * Math.PI\n      const al = 1.2 * Math.PI\n      k.lathe('stainless', [[R - 0.002, 0], [R, 0], [R, Ls], [R - 0.002, Ls], [R - 0.002, 0]], [xs, 0, za], 'x', 28, a0, al)\n      for (const phi of [a0, a0 + al]) {\n        const q = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(1, 0, 0), Math.atan2(Math.cos(phi), -Math.sin(phi)))\n        k.box('stainless', [Ls, 0.002, 0.0016], [xs + Ls / 2, -(R - 0.001) * Math.sin(phi), za + (R - 0.001) * Math.cos(phi)], q)\n      }\n      k.torus('stainless', 0.0385, 0.003, [xw + 0.012, 0, za], 'x', 6, 28)\n      for (const s of [-1, 1]) {\n        k.rod('stainless', [xw + 0.012, 0.03, za + s * 0.024], [xw + 0.012, R * 0.82, za + s * 0.032], 0.002, 6)\n        k.hex('nut', 0.01, 0.005, [xw + 0.012, 0.03, za + s * 0.024], 'y')\n      }\n    }\n  })\n  cableToDeck(k, mount, [entry[0], entry[1] + h + 0.005, entry[2] + zf])\n}\n\nfunction lcdMat(gas: string) {\n  return canvasMat(`gd-lcd-${gas}`, 256, 256, (g) => {\n    g.fillStyle = '#9fb59a'\n    g.fillRect(0, 0, 256, 256)\n    g.fillStyle = '#1c2a1d'\n    g.textAlign = 'center'\n    g.textBaseline = 'middle'\n    g.font = 'bold 84px \"Courier New\", monospace'\n    g.fillText('0', 128, 112)\n    g.font = 'bold 32px Arial, sans-serif'\n    g.fillText(gas === 'H2S' || gas === 'CO' ? 'ppm' : '%LEL', 128, 176)\n    g.font = 'bold 26px Arial, sans-serif'\n    g.fillText(gas, 128, 58)\n    g.fillRect(56, 204, 144, 5)\n  }, { emissive: 0.25 })\n}\n\n/** Catalytic transmitter: Ex d housing with display facing +Z, sensor and weather cap pointing down. */\nfunction buildCat(k: Kit, mount: Mount, h: number, gas: string, junction: boolean, tag: string) {\n  const zc = 0.07\n  let gland = new THREE.Vector3()\n  mounted(k, mount, h, [0.14, 0.22], (zf) => {\n    k.box('stainless', [0.16, 0.03, 0.012], [0, 0.02, 0.006])\n    for (const sx of [-1, 1]) k.hex('nut', 0.014, 0.007, [sx * 0.068, 0.02, 0.0155], 'z')\n    k.box('stainless', [0.03, 0.03, zc - 0.03], [0, 0.02, 0.012 + (zc - 0.03) / 2])\n    k.cyl('actuatorYellow', 0.062, 0.085, [0, 0, zc - 0.005], 'z', 28)\n    k.cyl('actuatorYellow', 0.066, 0.022, [0, 0, zc + 0.048], 'z', 28)\n    k.torus('nut', 0.058, 0.004, [0, 0, zc + 0.06], 'z', 6, 28)\n    k.add(lcdMat(gas), new THREE.CircleGeometry(0.034, 24), mat4([0, 0, zc + 0.0595]))\n    k.disc('glass', 0.04, [0, 0, zc + 0.0615], 'z', 24)\n    k.sphere(LED_GREEN, 0.005, [0.045, 0.022, zc + 0.059], undefined, 8)\n    for (const s of [-1, 1]) k.cyl('nut', 0.006, 0.006, [s * 0.05, -0.03, zc + 0.06], 'z', 8)\n    // sensor down: adaptor, sinter head under a hollow weather cap with calibration nozzle\n    k.cyl('actuatorYellow', 0.03, 0.02, [0, -0.068, zc], 'y', 18)\n    k.hex('stainless', 0.05, 0.016, [0, -0.085, zc], 'y')\n    k.cyl('stainless', 0.03, 0.05, [0, -0.118, zc], 'y', 20)\n    k.cyl('castIron', 0.024, 0.012, [0, -0.149, zc], 'y', 18)\n    k.lathe('plasticGrey', [[0.03, 0], [0.042, 0], [0.042, 0.06], [0.036, 0.06], [0.036, 0.006], [0.03, 0.006], [0.03, 0]], [0, -0.1, zc], '-y', 24)\n    k.cyl('plasticGrey', 0.006, 0.026, [0, -0.135, zc + 0.052], 'z', 10)\n    k.cyl('actuatorRed', 0.009, 0.012, [0, -0.135, zc + 0.07], 'z', 12)\n    // cable entries: one gland, one stopping plug\n    k.hex('brass', 0.03, 0.02, [0.042, -0.052, zc - 0.012], 'y')\n    stopPlug(k, [-0.042, -0.048, zc - 0.012], '-y')\n    gland = new THREE.Vector3(0.042, h - 0.064, zf + zc - 0.012)\n  })\n  const zf = faceZ(mount)\n  if (junction) {\n    const jy = h - 0.42\n    const jz = mount === 'pole' ? polePlate(k, jy, 0.24, 0.24) : 0.008\n    if (mount === 'wall') k.box('stainless', [0.24, 0.24, 0.008], [0, jy, 0.004])\n    const e = exdBox(k, [0, jy, jz], [0.18, 0.16, 0.11], 3, 2)\n    tagPlate(k, tag, [0, jy + 0.02, jz + 0.11 + 0.001], 'z', 0.1)\n    cable(k, [gland.toArray() as V3, [gland.x + 0.06, gland.y - 0.1, gland.z], [0.13, jy + 0.1, e[1][2] + 0.03], [0.13, e[1][1] - 0.05, e[1][2]], [e[1][0], e[1][1] - 0.04, e[1][2]], e[1]])\n    cableToDeck(k, mount, e[0])\n  } else {\n    tagPlate(k, tag, [0, h - 0.085, zf + 0.001], 'z', 0.09)\n    cableToDeck(k, mount, gland.toArray() as V3)\n  }\n}\n"
    },
    {
      "path": "safety/_fg.ts",
      "type": "registry:file",
      "target": "components/deck-twin/safety/_fg.ts",
      "content": "// Shared fire & gas hardware: galvanised pole stanchion, pole and wall brackets, field cable, LEDs, lenses and canvas faces.\nimport * as THREE from 'three'\nimport { Kit, type MatKey, type V3 } from '../lib/kit'\nimport { paint, weather } from '../lib/materials'\nimport { pipeOD } from '../lib/standards'\n\nexport type Mount = 'pole' | 'wall'\n\nexport const LENS: MatKey = paint('#15202b', { metalness: 0.3, roughness: 0.06 })\nexport const WHITE: MatKey = paint('#eceae4', { metalness: 0.05, roughness: 0.55 })\nexport const LED_GREEN: MatKey = paint('#2bff6e', { emissive: '#2bff6e', emissiveIntensity: 0.9, roughness: 0.3 })\nexport const LED_RED: MatKey = paint('#ff3b30', { emissive: '#ff3b30', emissiveIntensity: 0.9, roughness: 0.3 })\n\n/** 2\" galvanised stanchion pipe */\nexport const POLE_R = pipeOD(2) / 2\nconst PLATE_T = 0.006\n\nconst deg = (d: number) => (d * Math.PI) / 180\nexport { deg }\n\n/** Free-standing stanchion: base plate with four anchor bolts and gussets, 2\" pole to `top`, welded cap. Pole on the origin. */\nexport function poleStanchion(k: Kit, top: number, mat: MatKey = 'galvanised') {\n  const B = 0.26\n  k.box(mat, [B, 0.016, B], [0, 0.008, 0])\n  for (const sx of [-1, 1])\n    for (const sz of [-1, 1]) {\n      const p: V3 = [sx * (B / 2 - 0.035), 0, sz * (B / 2 - 0.035)]\n      k.cyl('galvanised', 0.008, 0.05, [p[0], 0.035, p[2]], 'y', 8)\n      k.hex('nut', 0.03, 0.014, [p[0], 0.023, p[2]], 'y')\n      k.cyl('galvanised', 0.017, 0.003, [p[0], 0.0175, p[2]], 'y', 12)\n    }\n  k.cyl(mat, POLE_R, top - 0.016, [0, 0.016 + (top - 0.016) / 2, 0], 'y', 20)\n  k.cyl(mat, POLE_R + 0.004, 0.008, [0, top + 0.004, 0], 'y', 20)\n  const g = new THREE.Shape()\n  g.moveTo(0, 0).lineTo(0.09, 0).lineTo(0, 0.16).closePath()\n  for (let i = 0; i < 4; i++) {\n    const a = (i * Math.PI) / 2 + Math.PI / 4\n    const q = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), a)\n    const m = new THREE.Matrix4().compose(new THREE.Vector3(0, 0.016, 0).add(new THREE.Vector3(POLE_R, 0, -0.004).applyQuaternion(q)), q, new THREE.Vector3(1, 1, 1))\n    k.extrude(mat, g, 0.008, m)\n  }\n}\n\n/** Plate clamped to the front (+Z) of the pole by two U-bolts. Returns the z of the plate front face. */\nexport function polePlate(k: Kit, y: number, w: number, h: number, mat: MatKey = 'stainless') {\n  const z0 = POLE_R + 0.004\n  k.box(mat, [w, h, PLATE_T], [0, y, z0 + PLATE_T / 2])\n  for (const s of [-1, 1]) {\n    const yy = y + s * (h / 2 - 0.025)\n    k.torus('galvanised', POLE_R + 0.006, 0.005, [0, yy, 0], 'y', 6, 20, Math.PI)\n    k.rod('galvanised', [-(POLE_R + 0.006), yy, 0], [-(POLE_R + 0.006), yy, z0 + PLATE_T + 0.012], 0.005, 6)\n    k.rod('galvanised', [POLE_R + 0.006, yy, 0], [POLE_R + 0.006, yy, z0 + PLATE_T + 0.012], 0.005, 6)\n    for (const sx of [-1, 1]) k.hex('nut', 0.017, 0.008, [sx * (POLE_R + 0.006), yy, z0 + PLATE_T + 0.005], 'z')\n  }\n  // the U-bolt arcs sit behind the pole (torus half facing -Z)\n  return z0 + PLATE_T\n}\n\n/** Stainless wall plate in the XY plane (back face on z = 0), four fixings. Returns the front face z. */\nexport function wallPlate(k: Kit, y: number, w: number, h: number) {\n  k.box('stainless', [w, h, 0.008], [0, y, 0.004])\n  for (const sx of [-1, 1]) for (const sy of [-1, 1]) k.hex('nut', 0.016, 0.008, [sx * (w / 2 - 0.014), y + sy * (h / 2 - 0.014), 0.012], 'z')\n  return 0.008\n}\n\n/** z of the bracket face that mounted() builds on. */\nexport const faceZ = (mount: Mount) => (mount === 'pole' ? POLE_R + 0.004 + PLATE_T : 0.008)\n\n/** Builds the stanchion (pole) or wall plate, then runs `fn` with the origin on the bracket face at `y`, +Z out of the bracket. */\nexport function mounted(k: Kit, mount: Mount, y: number, plate: [number, number], fn: (zFace: number) => void, poleTop = y + plate[1] / 2 + 0.05) {\n  let zf: number\n  if (mount === 'pole') {\n    poleStanchion(k, poleTop)\n    zf = polePlate(k, y, plate[0], plate[1])\n  } else zf = wallPlate(k, y, plate[0], plate[1])\n  k.at([0, y, zf], undefined, () => fn(zf))\n  return zf\n}\n\n/** Armoured field cable (SWA, black sheath). */\nexport function cable(k: Kit, pts: V3[], r = 0.0065) {\n  k.spline('cable', pts, r, 6, Math.max(16, pts.length * 8))\n}\n\n/** Cable from `from` down the left side of the pole (or the wall) to the deck, cleated every ~0.5 m. */\nexport function cableToDeck(k: Kit, mount: Mount, from: V3, r = 0.0065) {\n  const x = mount === 'pole' ? -(POLE_R + r + 0.001) : from[0]\n  const z = mount === 'pole' ? 0 : r + 0.009\n  const yTop = Math.min(from[1] - 0.08, from[1])\n  cable(k, [from, [from[0], from[1] - 0.05, from[2]], [(from[0] + x) / 2, yTop - 0.05, (from[2] + z) / 2], [x, yTop - 0.14, z], [x, 0.2, z]], r)\n  k.tube('cable', [[x, 0.2, z], [x, 0.03, z], mount === 'pole' ? [x - 0.2, 0.03, z] : [x, 0.03, z + 0.2]], r, 6, 0.06)\n  for (let y = 0.4; y < yTop - 0.2; y += 0.5) {\n    if (mount === 'pole') k.torus('stainless', POLE_R + 0.002, 0.003, [0, y, 0], 'y', 4, 18)\n    else k.box('stainless', [0.03, 0.012, 0.004], [x, y, 2 * r + 0.011])\n  }\n}\n\n// ------------------------------------------------------------------ canvas faces (created lazily, browser only)\n\nconst texCache = new Map<string, THREE.MeshStandardMaterial>()\n\nexport function canvasMat(key: string, w: number, h: number, draw: (g: CanvasRenderingContext2D) => void, opts: { emissive?: number; roughness?: number } = {}) {\n  let m = texCache.get(key)\n  if (m) return m\n  const c = document.createElement('canvas')\n  c.width = w\n  c.height = h\n  draw(c.getContext('2d')!)\n  const tex = new THREE.CanvasTexture(c)\n  tex.colorSpace = THREE.SRGBColorSpace\n  tex.anisotropy = 4\n  m = new THREE.MeshStandardMaterial({ map: tex, metalness: 0.1, roughness: opts.roughness ?? 0.45 })\n  if (opts.emissive) {\n    m.emissive = new THREE.Color('#ffffff')\n    m.emissiveMap = tex\n    m.emissiveIntensity = opts.emissive\n  }\n  m.name = key\n  weather(m, 0.3)\n  texCache.set(key, m)\n  return m\n}\n\nfunction fit(g: CanvasRenderingContext2D, text: string, max: number, size: number, weight = 'bold') {\n  g.font = `${weight} ${size}px Arial, sans-serif`\n  while (g.measureText(text).width > max && size > 10) g.font = `${weight} ${(size -= 2)}px Arial, sans-serif`\n}\n\n/** ISO 7010-style sign: coloured field, white border, optional pictogram square on the left, one or two text lines. */\nexport function signMat(lines: string[], bg: string, fg = '#ffffff', icon?: (g: CanvasRenderingContext2D, s: number) => void) {\n  return canvasMat(`fgsign-${lines.join('|')}-${bg}-${fg}-${icon ? 1 : 0}`, 512, 256, (g) => {\n    g.fillStyle = bg\n    g.fillRect(0, 0, 512, 256)\n    g.strokeStyle = fg\n    g.lineWidth = 8\n    g.strokeRect(10, 10, 492, 236)\n    let x0 = 256\n    let w = 460\n    if (icon) {\n      g.save()\n      g.translate(28, 28)\n      icon(g, 200)\n      g.restore()\n      x0 = 370\n      w = 250\n    }\n    g.fillStyle = fg\n    g.textAlign = 'center'\n    g.textBaseline = 'middle'\n    const n = lines.length\n    lines.forEach((t, i) => {\n      fit(g, t, w, n > 2 ? 46 : 60)\n      g.fillText(t, x0, 128 + (i - (n - 1) / 2) * (n > 2 ? 58 : 72))\n    })\n  })\n}\n\n/** Black/yellow hazard-bordered warning plate. */\nexport function warnMat(lines: string[]) {\n  return canvasMat(`fgwarn-${lines.join('|')}`, 512, 256, (g) => {\n    g.fillStyle = '#f2c318'\n    g.fillRect(0, 0, 512, 256)\n    g.save()\n    g.beginPath()\n    g.rect(0, 0, 512, 256)\n    g.rect(22, 22, 468, 212)\n    g.clip('evenodd')\n    g.fillStyle = '#141414'\n    for (let x = -256; x < 768; x += 44) {\n      g.beginPath()\n      g.moveTo(x, 0)\n      g.lineTo(x + 22, 0)\n      g.lineTo(x - 234, 256)\n      g.lineTo(x - 256, 256)\n      g.closePath()\n      g.fill()\n    }\n    g.restore()\n    g.fillStyle = '#141414'\n    g.textAlign = 'center'\n    g.textBaseline = 'middle'\n    lines.forEach((t, i) => {\n      fit(g, t, 440, i === 0 ? 70 : 44)\n      g.fillText(t, 256, lines.length === 1 ? 128 : i === 0 ? 100 : 176)\n    })\n  })\n}\n\n/** White pictogram helpers drawn into an s × s square. */\nexport const ICON = {\n  flame(g: CanvasRenderingContext2D, s: number) {\n    g.fillStyle = '#ffffff'\n    g.beginPath()\n    g.moveTo(s * 0.5, s * 0.08)\n    g.bezierCurveTo(s * 0.85, s * 0.4, s * 0.82, s * 0.7, s * 0.5, s * 0.9)\n    g.bezierCurveTo(s * 0.18, s * 0.7, s * 0.2, s * 0.45, s * 0.38, s * 0.3)\n    g.bezierCurveTo(s * 0.4, s * 0.45, s * 0.48, s * 0.5, s * 0.52, s * 0.42)\n    g.closePath()\n    g.fill()\n  },\n  shower(g: CanvasRenderingContext2D, s: number) {\n    g.fillStyle = '#ffffff'\n    g.strokeStyle = '#ffffff'\n    g.lineWidth = s * 0.04\n    g.beginPath()\n    g.arc(s * 0.62, s * 0.18, s * 0.12, Math.PI, 0)\n    g.fill()\n    for (let i = 0; i < 5; i++) {\n      g.beginPath()\n      g.moveTo(s * (0.52 + i * 0.05), s * 0.24)\n      g.lineTo(s * (0.48 + i * 0.05), s * 0.42)\n      g.stroke()\n    }\n    g.beginPath()\n    g.arc(s * 0.4, s * 0.38, s * 0.07, 0, Math.PI * 2)\n    g.fill()\n    g.fillRect(s * 0.34, s * 0.47, s * 0.12, s * 0.28)\n    g.fillRect(s * 0.34, s * 0.75, s * 0.05, s * 0.18)\n    g.fillRect(s * 0.41, s * 0.75, s * 0.05, s * 0.18)\n  },\n  extinguisher(g: CanvasRenderingContext2D, s: number) {\n    g.fillStyle = '#ffffff'\n    g.fillRect(s * 0.36, s * 0.3, s * 0.28, s * 0.6)\n    g.beginPath()\n    g.arc(s * 0.5, s * 0.3, s * 0.14, Math.PI, 0)\n    g.fill()\n    g.fillRect(s * 0.45, s * 0.1, s * 0.1, s * 0.08)\n    g.lineWidth = s * 0.04\n    g.strokeStyle = '#ffffff'\n    g.beginPath()\n    g.moveTo(s * 0.55, s * 0.14)\n    g.quadraticCurveTo(s * 0.85, s * 0.18, s * 0.8, s * 0.5)\n    g.stroke()\n  },\n  hose(g: CanvasRenderingContext2D, s: number) {\n    g.strokeStyle = '#ffffff'\n    g.lineWidth = s * 0.06\n    for (const r of [0.14, 0.24, 0.34]) {\n      g.beginPath()\n      g.arc(s * 0.45, s * 0.5, s * r, 0, Math.PI * 2)\n      g.stroke()\n    }\n    g.beginPath()\n    g.moveTo(s * 0.79, s * 0.5)\n    g.lineTo(s * 0.92, s * 0.85)\n    g.stroke()\n  },\n}\n\n/** Ex d stopping (blanking) plug in an unused cable entry, axis out of the entry. */\nexport function stopPlug(k: Kit, pos: V3, axis: 'x' | '-x' | 'y' | '-y' | 'z' | '-z', d = 0.026) {\n  k.hex('castIron', d, 0.006, pos, axis)\n  const v = { x: [1, 0, 0], '-x': [-1, 0, 0], y: [0, 1, 0], '-y': [0, -1, 0], z: [0, 0, 1], '-z': [0, 0, -1] }[axis]\n  k.cyl('castIron', d * 0.36, 0.006, [pos[0] + v[0] * 0.006, pos[1] + v[1] * 0.006, pos[2] + v[2] * 0.006], axis, 12)\n}\n\n/**\n * Flameproof (Ex d) cast junction box: body with a wide flamepath flange, bolted lid, earth stud and bottom entries.\n * Back face at `pos`, lid facing +Z. `used` entries get brass glands, the rest stopping plugs. Returns the entry centres (bottom face).\n */\nexport function exdBox(k: Kit, pos: V3, size: V3 = [0.18, 0.18, 0.12], entries = 2, used = 1, mat: MatKey = 'castIron'): V3[] {\n  const [w, h, d] = size\n  const [x, y, z] = pos\n  k.rbox(mat, [w, h, d * 0.62], 0.01, [x, y, z + d * 0.31])\n  k.rbox(mat, [w + 0.024, h + 0.024, d * 0.12], 0.006, [x, y, z + d * 0.68])\n  k.rbox(mat, [w, h, d * 0.26], 0.012, [x, y, z + d * 0.87])\n  // cover bolts round the flamepath flange\n  const nx = Math.max(2, Math.round(w / 0.05))\n  const ny = Math.max(2, Math.round(h / 0.05))\n  for (let i = 0; i <= nx; i++)\n    for (const s of [-1, 1]) k.cyl('stainless', 0.006, 0.006, [x - w / 2 + (w * i) / nx, y + s * (h / 2 + 0.006), z + d * 0.74 + 0.003], 'z', 8)\n  for (let i = 1; i < ny; i++)\n    for (const s of [-1, 1]) k.cyl('stainless', 0.006, 0.006, [x + s * (w / 2 + 0.006), y - h / 2 + (h * i) / ny, z + d * 0.74 + 0.003], 'z', 8)\n  // mounting lugs, earth stud\n  for (const s of [-1, 1]) {\n    k.box(mat, [0.03, 0.03, 0.012], [x + s * (w / 2 + 0.012), y + s * (h / 2 - 0.02), z + 0.006])\n    k.hex('nut', 0.014, 0.007, [x + s * (w / 2 + 0.014), y + s * (h / 2 - 0.02), z + 0.0155], 'z')\n  }\n  k.cyl('brass', 0.004, 0.025, [x + w / 2 + 0.012, y - h * 0.25, z + d * 0.35], 'x', 8)\n  k.hex('brass', 0.012, 0.006, [x + w / 2 + 0.018, y - h * 0.25, z + d * 0.35], 'x')\n  const out: V3[] = []\n  for (let i = 0; i < entries; i++) {\n    const ex = x + (entries === 1 ? 0 : -w * 0.3 + (w * 0.6 * i) / (entries - 1))\n    const p: V3 = [ex, y - h / 2, z + d * 0.31]\n    k.cyl(mat, 0.016, 0.008, [p[0], p[1] - 0.004, p[2]], 'y', 14)\n    if (i < used) {\n      k.hex('brass', 0.03, 0.014, [p[0], p[1] - 0.015, p[2]], 'y')\n      k.cyl('brass', 0.012, 0.02, [p[0], p[1] - 0.032, p[2]], 'y', 12)\n      k.cyl('rubberBlack', 0.0085, 0.012, [p[0], p[1] - 0.046, p[2]], 'y', 10)\n    } else stopPlug(k, [p[0], p[1] - 0.011, p[2]], '-y')\n    out.push([p[0], p[1] - 0.05, p[2]])\n  }\n  return out\n}\n"
    }
  ],
  "categories": [
    "safety"
  ],
  "meta": {
    "export": "PointGasDetector",
    "anchor": "base",
    "standards": [
      "IEC 60079-29-1",
      "IEC 60079-29-2",
      "IEC 60079-1",
      "IEC 60079-14"
    ]
  }
}