
import re

print("Starting script...")

raw_text_main = """1. Aluminium Doors & Windows Works


We design and install premium quality aluminium doors and windows that provide excellent ventilation, safety, and thermal insulation. Our systems are smooth in operation, strong in construction, and long-lasting.

• Sliding doors and windows
• Casement/openable windows
• Fixed glass windows
• Folding doors
• Balcony doors
• Soundproof doors
• Toughened glass doors
• Mosquito mesh windows
• Powder-coated and anodized finish options

2. Aluminium Partitions & Office Cabins

• Office glass partitions
• Aluminium framed partitions
• Modular cabins
• Conference room enclosures
• Workstation separators
• Reception partitions

3. Structural & Fabrication Works

• Aluminium frames
• Fabrication structures
• Louvers & grills
• Railings
• Staircase handrails
• Safety barriers
• Industrial sheds
• Support frameworks

4. ACP & Cladding Works

• ACP sheet cladding
• Building facades
• Elevation design
• Exterior wall covering
• Signboard frames
• Shopfront glazing

5. Glass & Glazing Works

• Toughened glass fixing
• Curtain wall glazing
• Structural glazing
• Spider glazing
• Skylights
• Glass railings

6. False Ceiling & Roofing

• Aluminium false ceiling
• Grid ceiling
• Industrial roofing sheets
• Polycarbonate sheets
• Canopies & sheds

7. Curtain Wall Systems

• Glass curtain wall
• Semi-unitized curtain wall
• Structural curtain wall
• High-rise facade systems
• Weather-sealed glazing

8. Aluminium Railings & Handrails

• Staircase handrails
• Balcony railings
• Terrace railings
• Glass railing systems
• Safety guard rails

9. Shopfront & Commercial Frontage

• Showroom front glazing
• Aluminium rolling shutters
• Entrance systems
• Automatic doors
• Display frames
"""

raw_text_single_lines = """10. Aluminium Sliding Systems
11. Aluminium Folding Doors
12. Aluminium Ventilators
13. Louvers & Sun Control Panels
14. Aluminium Skylights
15. Aluminium Pergola Structures
16. Aluminium Canopy Works
17. Terrace Covering Systems
18. Balcony Enclosures
19. Aluminium Mesh & Screens
20. Aluminium Security Doors
21. Industrial Aluminium Partitions
22. Clean Room Partitions
23. Modular Office Frames
24. Conference Room Glazing
25. Aluminium Display Cabinets
26. Aluminium Wall Panels
27. Decorative Aluminium Panels
28. Laser Cut Aluminium Designs
29. Aluminium Gates
30. Sliding Gate Systems
31. Aluminium Fencing Works
32. Aluminium Ladder Fabrication
33. Aluminium Storage Racks
34. Aluminium Workstations
35. Aluminium Kitchen Cabinets
36. Aluminium Wardrobes
37. Bathroom Shower Partitions
38. Aluminium Mirror Frames
39. Aluminium Shelving Units
40. Aluminium Display Racks
41. Aluminium Rolling Windows
42. Soundproof Window Systems
43. Double Glazed Units (DGU)
44. Energy Efficient Windows
45. Thermal Break Systems
46. Weatherproof Doors
47. Fire Rated Aluminium Doors
48. Bullet Resistant Glass Frames
49. Aluminium Sun Louvers
50. Aluminium Wall Cladding
51. ACP Elevation Works
52. Exterior Facade Decoration
53. Aluminium Sign Boards
54. Name Plate Frames
55. Billboard Structures
56. Bus Stop Shelters
57. Parking Shed Fabrication
58. Warehouse Roofing Systems
59. Factory Partitions
60. Machine Safety Covers
61. Aluminium Trusses
62. Aluminium Stage Structures
63. Exhibition Stall Fabrication
64. Kiosk Frames
65. Ticket Counter Cabins
66. Airport Cabin Structures
67. Railway Platform Shelters
68. Hospital Cubicle Partitions
69. School Classroom Partitions
70. Aluminium Doors for Labs
71. Aluminium Lift Cladding
72. Escalator Rail Frames
73. Aluminium Stair Covers
74. False Floor Frameworks
75. Aluminium Cable Trays
76. Aluminium Vent Covers
77. Aluminium Pipe Covers
78. Aluminium Frame Supports
79. Aluminium Structural Frames
80. Aluminium Wall Guards
81. Aluminium Window Mosquito Nets
82. Aluminium Vent Grills
83. Aluminium Decorative Screens
84. Aluminium Ceiling Panels
85. Modular Aluminium Furniture
86. Aluminium Benches
87. Aluminium Tables
88. Aluminium Storage Boxes
89. Aluminium Tool Cabinets
90. Aluminium Trolley Fabrication
91. Aluminium Platform Fabrication
92. Aluminium Roof Gutters
93. Aluminium Downpipes
94. Aluminium Door Frames
95. Aluminium Window Frames
96. Aluminium Wall Frames
97. Aluminium Maintenance Platforms
98. Aluminium Safety Barriers
99. Custom Aluminium Fabrication
100. Turnkey Aluminium Project Execution"""

pvc_intro_text = "We provide complete PVC (Polyvinyl Chloride) fabrication and installation services for residential, commercial, and industrial projects. PVC products are lightweight, waterproof, termite-proof, rust-free, low maintenance, and highly durable, making them an ideal solution for modern interiors and exteriors. Our team specializes in customized PVC designs that enhance functionality, hygiene, and aesthetics while ensuring long-lasting performance. <br><br> We use premium-quality PVC sheets, boards, panels, and fittings to deliver cost-effective, stylish, and maintenance-free solutions for ceilings, partitions, doors, cabinets, and various interior applications."

pvc_groups = {
    "PVC Doors & Windows": """PVC panel doors
PVC bathroom doors
PVC printed doors
PVC flush doors
PVC sliding doors
PVC folding doors
PVC kitchen doors
PVC balcony doors
PVC windows
PVC ventilators""",

    "PVC Partitions & Cabins": """Office PVC partitions
Glass + PVC partitions
Modular PVC cabins
Room dividers
Washroom partitions
Hospital partitions
School partitions
Lab partitions
Clean room panels
Movable partitions""",

    "PVC Ceilings & Wall Paneling": """PVC false ceiling
Decorative ceiling panels
Printed ceiling sheets
Grid ceiling system
Waterproof ceiling
Kitchen ceiling
Bathroom ceiling
Office ceiling
Commercial ceiling
Designer ceiling patterns
Wall paneling sheets
Decorative wall panels
3D PVC wall panels
Wooden finish PVC panels
Marble finish panels
Waterproof wall sheets
Kitchen backsplash panels
Washroom wall cladding
Office wall covering
Exterior wall panels""",

    "PVC Furniture & Storage": """PVC kitchen cabinets
Modular PVC wardrobe
PVC cupboards
PVC storage cabinets
PVC shoe racks
PVC shelves
PVC TV units
PVC study tables
PVC office tables
PVC display racks""",

    "PVC Bathroom & Sanitary Works": """Shower partitions
PVC sink cabinets
Vanity units
Mirror frames
Toilet cubicles
Bathroom lockers
Waterproof cabinets
PVC soap stands
PVC towel racks
PVC utility shelves""",

    "PVC Exterior & Outdoor Works": """PVC fencing
PVC gates
PVC pergola
PVC sheds
PVC canopy
Outdoor wall panels
Balcony covers
Terrace enclosures
PVC garden structures
Weatherproof panels""",

    "PVC Industrial & Commercial Works": """Factory partitions
Warehouse cabins
Clean room doors
Cold storage panels
Insulated PVC panels
Electrical panel covers
Cable trunking
PVC ducts
Safety barriers
Machine covers""",

    "PVC Decorative & Utility Works": """PVC name boards
PVC sign boards
Advertising frames
PVC photo frames
PVC notice boards
PVC ceiling borders
Decorative strips
PVC molding work
PVC cornice designs
PVC skirting""",

    "PVC Fabrication & Miscellaneous": """Custom PVC fabrication
PVC ladders
PVC storage boxes
PVC trays
PVC trolleys
PVC covers
PVC door frames
PVC window frames
Repair & maintenance
Turnkey PVC project execution"""
}

# Image cycling
images = [
    'our servies image/Our Services/Aluminium_work.jpeg',
    'our servies image/Our Services/fabrication_wor.jpeg',
    'our servies image/Our Services/Construction_of_Building.jpeg',
    'our servies image/Services php/d2/bedroom.png',
    'our servies image/Our Services/interior_work.jpeg'
]

php_output = "<?php\n$aluminium_steps = [\n"

# Process First 9 Detailed Steps
blocks = re.split(r'\n(?=\d+\.)', raw_text_main.strip())
for block in blocks:
    if not block.strip():
        continue
    match = re.match(r'(\d+)\.\s*(.+)', block)
    if not match:
        continue
    number = int(match.group(1))
    title = match.group(2).strip()
    rest_of_text = block[match.end():].strip()
    
    # Simple bullet parsing
    lines = rest_of_text.split('\n')
    bullets = []
    intro = []
    for line in lines:
        line = line.strip()
        if not line: continue
        if line.startswith('•'):
            bullets.append(line)
        else:
            intro.append(line)
            
    content_html = ""
    if intro:
        content_html += f"{' '.join(intro)} <br><br>"
    if bullets:
        content_html += "<ul class=\"custom-list\">"
        for b in bullets:
            content_html += f"<li>{b} <br><br></li>"
        content_html += "</ul>"
        
    image_index = (number - 1) % len(images)
    image_path = images[image_index]
    
    php_output += "    [\n"
    php_output += f"        'number' => {number},\n"
    php_output += f"        'title' => '{title}',\n"
    php_output += f"        'content' => '{content_html}',\n"
    php_output += f"        'image' => '{image_path}'\n"
    php_output += "    ],\n"

# Process 10-100 Single Lines
single_lines = raw_text_single_lines.strip().split('\n')
for line in single_lines:
    match = re.match(r'(\d+)\.\s*(.+)', line.strip())
    if match:
        number = int(match.group(1))
        title = match.group(2).strip()
        content = f"Professional fabrication and installation of {title}. customized to client specifications using high-grade materials."
        
        image_index = (number - 1) % len(images)
        image_path = images[image_index]
        
        php_output += "    [\n"
        php_output += f"        'number' => {number},\n"
        php_output += f"        'title' => '{title}',\n"
        php_output += f"        'content' => '{content}',\n"
        php_output += f"        'image' => '{image_path}'\n"
        php_output += "    ],\n"

# Process PVC Section (Starting at 101)
# Step 101: PVC Intro
php_output += "    [\n"
php_output += f"        'number' => 101,\n"
php_output += f"        'title' => 'PVC Fabrication & Installation Services (Overview)',\n"
php_output += f"        'content' => '{pvc_intro_text}',\n"
php_output += f"        'image' => '{images[0]}'\n"
php_output += "    ],\n"

pvc_start_num = 102
for group_title, items_str in pvc_groups.items():
    items = items_str.strip().split('\n')
    content_html = "<ul class=\"custom-list\">"
    for item in items:
        content_html += f"<li>• {item.strip()} <br><br></li>"
    content_html += "</ul>"
    
    image_index = (pvc_start_num - 1) % len(images)
    image_path = images[image_index]

    php_output += "    [\n"
    php_output += f"        'number' => {pvc_start_num},\n"
    php_output += f"        'title' => '{group_title}',\n"
    php_output += f"        'content' => '{content_html}',\n"
    php_output += f"        'image' => '{image_path}'\n"
    php_output += "    ],\n"
    pvc_start_num += 1

php_output += "];\n?>"

with open('aluminium_steps.php', 'w', encoding='utf-8') as f:
    f.write(php_output)
    print("File written successfully to aluminium_steps.php")

