diff --git a/design-system/IMS Admin Spec.dc.html b/design-system/IMS Admin Spec.dc.html new file mode 100644 index 0000000..353f265 --- /dev/null +++ b/design-system/IMS Admin Spec.dc.html @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + +
+
+
IMS · UI REFRESH · HANDOFF SPEC
+
Patterns, tokens and states
+
Everything in IMS Admin.dc.html is built from the pieces below. Values are the ones used in the mockups; map them to Tailwind theme tokens once and the screens follow. Type is Geist (UI) and Geist Mono (references, keyboard hints).
+
+ +
+
1 · Color
+
+
{{ c.name }}
{{ c.hex }}
{{ c.use }}
+
+
Status pills
+
+{{ p.label }}{{ p.bg }} / {{ p.fg }} +
+
Pill text is always a dark ramp step on a light tint — never white on a saturated fill. Priority uses the same scale: Critical = red, High = orange, Medium = yellow, Low = neutral. Incident status and CAPA status share one palette so the dashboard reads consistently.
+
+ +
+
2 · Type, radius, shadow
+
+
+
{{ t.spec }}{{ t.sample }}
+
+
+
{{ s.k }}{{ s.v }}
+
+
+
+ +
+
3 · Buttons and controls
+
+
Primary · 32px · #303030, inset highlight{{ ic.plus }}Report incidenthover #1f1f1f · active #000 · focus 2px ring #0f766e offset 2px
+
Secondary · white, 1px #d4d4d4 ring{{ ic.download }}Exporthover bg #f7f7f7 · active bg #ebebeb
+
Icon button · 28px, ghost{{ ic.more }}rest transparent · hover #ebebeb
+
Filter chip · 28px
Owner{{ ic.chev12 }}Priority: Critical{{ ic.x12 }}
unset: chevron · set: teal tint + value + clear ×
+
Segmented · 2px padding on #e3e3e3
{{ ic.rows }}List{{ ic.kanban }}Board
+
Checkbox · 16px, radius 5
{{ ic.tick12 }}{{ ic.minus12 }}
off · on · indeterminate (header)
+
Text input · 36px desktop, 48px mobile
Placeholder
rest ring #8a8a8a · focus ring 2px #0f766e · error #b3261e
+
+
+ +
+
4 · Table card
+
One component wraps every list in the app. Anatomy top to bottom; every part is optional except the table and the card.
+
+
All 248
Open 37
{{ ic.plus }}
A · saved views · padding 8 · active #e3e3e3
+
{{ ic.search }}Search
Site{{ ic.chev12 }}B · search + filter chips · padding 10/12
+ + + + + +
Reference{{ ic.down12 }}Status{{ ic.sort12 }}C · header #f7f7f7 · 12px/550 · sorted column ink, others #c4c4c4
IMS-2026-0248InvestigatingD · row rest · #fff · 13px · 12px cell padding · 1px #ebebeb rule
IMS-2026-0247TriagedE · row hover · #f7f7f7 · quick actions appear right
{{ ic.eye }}{{ ic.more }}
{{ ic.tick12 }}IMS-2026-0246ReportedF · row selected · #f2f7f6
+
Showing 1–3 of 248G · footer #f7f7f7 · count left, pager right
{{ ic.chevLeft }}{{ ic.chevRight }}
+
{{ ic.tick12 }}1 selectedAssignExportH · bulk bar · floats centred above footer, appears on first selection
+
+
+
BehaviourWhole row is clickable and opens the record; the checkbox cell, links and quick actions stop propagation.Sorting is single-column; the sorted header shows a filled arrow, others a faint double chevron.Saved views are server-side filters; the + opens "Save current filters as view". Counts update live.Empty state replaces thead + tbody with a 64px icon tile, one line of copy and the primary action (see artboard 08).
+
MobileBelow 768px the table becomes a stacked list in the same card: reference + status on line one, type · zone on line two, date on line three, chevron right (artboard 10).Saved views become horizontally scrolling 999px chips; filters collapse to one "Filter" button opening a sheet.Bulk bar is replaced by a bottom sheet.
+
+
+ +
+
5 · Layout shell
+
+
DesktopTop bar 56px #1a1a1a: brand 224px · ⌘K search max 520px #303030 · bell + user chip 224px.Sidebar 240px #ebebeb, padding 12, items 32px radius 8; active item white with 1px ring and teal icon; badges 999px #dcdcdc.Main padding 24/32, column gap 16. Page title 20px/650 with actions right. Detail pages use 1fr + 320–340px side rail.Page background #f1f1f1; cards white, radius 12, ring rgba(0,0,0,.08) + 1px shadow.
+
Mobile (reporter)390px reference. Page title 22px/650, horizontal padding 16, card gap 12.Tab bar: white, 1px top rule, 3 items, 22px icons, 10.5px labels; active #0f766e.Form controls 48px tall, radius 12; primary button full width 48px. Footers sit on #f1f1f1 with a 1px top rule and 30px bottom safe area.Minimum hit target 44px everywhere.
+
+
+ +
+
6 · Screen index
+
+
{{ s.id }}{{ s.name }}{{ s.route }}
+
+
+
+
+ + + diff --git a/design-system/IMS Admin.dc.html b/design-system/IMS Admin.dc.html new file mode 100644 index 0000000..30835a2 --- /dev/null +++ b/design-system/IMS Admin.dc.html @@ -0,0 +1,536 @@ + + + + + + + + + + +
+
IMS · HSE INCIDENT MANAGEMENT · UI REFRESH
+
Admin redesign: rounded tables, commerce-admin ergonomics
+
Sixteen desktop screens and eight mobile screens rebuilt from the current IMS routes (HSE, Admin, Reporter). Neutral grey ground, white 12px-radius cards, dark primary buttons and one teal accent. Every list is a rounded index table with saved-view tabs, search and filter chips, sortable headers, bulk selection, hover quick actions and a pagination footer. Status colours map 1:1 to the existing workflow (Reported → Triaged → Investigating → CAPA Pending → Verification → Closed). Data shown is sample content.
+
+
+
01Incidents · index table
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.incidents.ini }}{{ nv.incidents.name }}
+

Incidents

{{ ic.download }}Export{{ ic.upload }}Bulk import{{ ic.plus }}New incident
+
+
{{ t.label }}{{ t.count }}
{{ ic.plus }}
{{ ic.search }}{{ ic.filter }}{{ ic.sort }}
+
{{ ic.search }}Search reference, site, zone or reporter
Site is Shah Alam DC, Port Klang Hub, Senai DC{{ ic.x12 }}Type{{ ic.chev12 }}Severity{{ ic.chev12 }}Reported date{{ ic.chev12 }}Add filter {{ ic.plus12 }}Clear all
CancelSave as view
+ + + + + + + + + + + +
{{ ic.minus12 }}Reference{{ ic.down12 }}Type{{ ic.sort12 }}Status{{ ic.sort12 }}Severity{{ ic.sort12 }}Site · Zone{{ ic.sort12 }}Reporter{{ ic.sort12 }}Reported{{ ic.sort12 }}
{{ ic.tick12 }}{{ r.ref }}
{{ r.type }}
Truck {{ r.truck }}
{{ r.st.label }}
{{ r.sevL }}
{{ r.site }}
{{ r.zone }}
{{ r.rep }}{{ r.date }}
{{ ic.eye }}{{ ic.pencil }}{{ ic.more }}
+
Showing 1–10 of 37 open incidents
Page 1 of 4
{{ ic.chevLeft }}{{ ic.chevRight }}
+
{{ ic.minus12 }}3 selectedAssign investigatorChange status{{ ic.download }}Export{{ ic.more }}
+
+
+
01bNotifications drawer
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.incidents.ini }}{{ nv.incidents.name }}
+

Incidents

{{ ic.download }}Export{{ ic.upload }}Bulk import{{ ic.plus }}New incident
+
+
{{ t.label }}{{ t.count }}
{{ ic.plus }}
{{ ic.search }}{{ ic.filter }}{{ ic.sort }}
+
{{ ic.search }}Search reference, site, zone or reporter
Site is Shah Alam DC, Port Klang Hub, Senai DC{{ ic.x12 }}Type{{ ic.chev12 }}Severity{{ ic.chev12 }}Reported date{{ ic.chev12 }}Add filter {{ ic.plus12 }}Clear all
CancelSave as view
+ + + + + + + + + + + +
{{ ic.minus12 }}Reference{{ ic.down12 }}Type{{ ic.sort12 }}Status{{ ic.sort12 }}Severity{{ ic.sort12 }}Site · Zone{{ ic.sort12 }}Reporter{{ ic.sort12 }}Reported{{ ic.sort12 }}
{{ ic.tick12 }}{{ r.ref }}
{{ r.type }}
Truck {{ r.truck }}
{{ r.st.label }}
{{ r.sevL }}
{{ r.site }}
{{ r.zone }}
{{ r.rep }}{{ r.date }}
{{ ic.eye }}{{ ic.pencil }}{{ ic.more }}
+
Showing 1–10 of 37 open incidents
Page 1 of 4
{{ ic.chevLeft }}{{ ic.chevRight }}
+
{{ ic.minus12 }}3 selectedAssign investigatorChange status{{ ic.download }}Export{{ ic.more }}
+
+
Notifications
Mark all read{{ ic.settings }}{{ ic.x }}
{{ t.label }}{{ t.count }}
{{ n.group }}
{{ n.icon }}
{{ n.title }}
{{ n.ref }}·{{ n.when }}·{{ n.ch }}
{{ n.action }}
Also sent by email and WhatsApp per your preferencesPreferences
+
02Incident detail
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.incidents.ini }}{{ nv.incidents.name }}
+
{{ ic.arrowLeft }}

IMS-2026-0247

TriagedDOSH reportable
Reported 25 Sep 2026, 14:32 by Muthu Kumar via zone QR · Port Klang Hub, Racking B
{{ ic.download }}Download PDFMore actions{{ ic.chev12 }}Start investigation
+
+
{{ ic.tick12 }}
Reported
25 Sep, 14:32
+
Triaged
25 Sep, 16:05 · Nadia H.
+
Investigating
+
CAPA pending
+
Verification
+
Closed
+
+
+
+
Incident summary

Reach-truck operator reported lower back strain after manually repositioning a pallet that had shifted on racking level 3 (upright B-14). First aid given on site; worker referred to panel clinic.

+
Body partLower back
Injury typeStrain
TreatmentPanel clinic
Days lostPending MC
+
Evidence 4
{{ ic.upload }}Add files
+
{{ ic.img24 }}rack-b14-01.jpg
{{ ic.img24 }}rack-b14-02.jpg
{{ ic.img24 }}pallet-shift.jpg
{{ ic.file }}clinic-referral.pdf
+
Corrective & preventive actions
{{ ic.plus }}Add CAPA
+ + +
ActionOwnerDueStatus
Retrain reach-truck operators on pallet shift handlingSarah Lim20 Sep 2026Overdue
Inspect racking level 3, bays B-12 to B-16Kumar Selvam04 Oct 2026Open
+
+
+
{{ ic.alert }}NADOPOD 2004 obligation
JKKP 6 required
Occupational injury with expected medical leave above 4 days. Submit to DOSH by 02 Oct 2026 (5 days left).
{{ ic.file }}Generate JKKP 6
+
Details
+
TypeInjury / Medical
+
Severity4 · Major
+
SitePort Klang Hub
+
ZoneRacking B
+
ReporterMuthu Kumar
+
Triaged byNadia Hassan
+
Similar incidents
{{ ic.sparkles }}AI match
+
IMS-2026-0188
Shoulder strain re-stacking pallet, Racking B
92%
+
IMS-2026-0152
Pallet overhang on level 3, near miss
87%
+
IMS-2025-0917
Manual handling injury, Senai DC
81%
+
+
+
02bTriage form
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.incidents.ini }}{{ nv.incidents.name }}
+
{{ ic.arrowLeft }}

Triage

Reported
IMS-2026-0246 · Hazard · Reported 25 Sep 2026, 09:12 by Lee Wei Jie · Shah Alam DC, Chiller Room
Save draftSave and mark triaged
+
ClassificationConfirm type and severity. Severity drives the CAPA due date and escalation.
+
Incident type
Hazard{{ ic.chev12 }}
Reporter selected Hazard. Change if the evidence says otherwise.
Zone
Chiller Room · Shah Alam DC{{ ic.chev12 }}
Filled from QR scan
+
Severity
{{ s.n }}{{ s.label }}{{ s.sub }}
+
Medical status
NoneFirst aidMedical treatmentLost-time injury
Lost days
0
Only for medical treatment or LTI
+
+
DOSH notificationTick anything that applies. Any tick marks the incident reportable and opens a JKKP 6 draft.
{{ ic.alert }}Reportable. DOSH must be notified within 7 days · due 02 Oct 2026. A JKKP 6 draft will be created on save.
+
Assignment
Lead investigator
RPRajesh Pillai · Engineering{{ ic.chev12 }}
Investigation due
09 Oct 2026{{ ic.calendar }}
Severity 4 default: 14 days
Triage notes
Reporter photo shows frost and ammonia odour reported at compressor line 2. Chiller isolated at 09:40 by shift supervisor. Treat as dangerous occurrence pending engineering confirmation.
Visible to the investigator and management. Not shown to the reporter.
Original reportOpen full
Strong ammonia smell near compressor line 2 in chiller room. Frost build-up on the pipe joint. Area cleared, told supervisor.
{{ ic.img24 }}
{{ ic.img24 }}
ReporterLee Wei Jie
Reported25 Sep 2026, 09:12
SourceZone QR · 2c77-0a5e
Injury involvedNo
+
{{ ic.sparkles }}Similar incidents
{{ m.ref }}{{ m.st.label }}
{{ m.desc }}
{{ m.meta }}
+
+
02cInvestigation form
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.incidents.ini }}{{ nv.incidents.name }}
+
{{ ic.arrowLeft }}

Investigation

Investigating
IMS-2026-0246 · Hazard · Reported 25 Sep 2026, 09:12 by Lee Wei Jie · Shah Alam DC, Chiller Room
Save draftComplete investigation
+
{{ p.dot }}{{ p.label }}
+
Root cause analysisFive whys is the default. Switch method if the team used a fishbone.
Five whysFishboneOther
Autosaved 2 min ago
{{ w.n }}
{{ w.q }}
{{ w.a }}
Root cause summary
No preventive maintenance interval defined for chiller compressor line joints; last inspection 14 months ago. Ammonia detector in chiller room out of calibration since Mar 2026.
One or two sentences. This appears on the CAPA and the JKKP form.
+
Findings
Findings
Compressor line 2 flange gasket degraded, minor ammonia release detected at 09:05. Detector alarm did not trigger. Chiller isolated 09:40 by shift supervisor. No exposure symptoms reported by the four staff on shift.
Alcohol test
Not required{{ ic.chev12 }}
Urine test
Not required{{ ic.chev12 }}
Required for transport incidents
Witness statements
{{ ic.file }}Statement_LeeWeiJie_25Sep.pdf212 KB{{ ic.x12 }}
{{ ic.file }}Statement_Supervisor_Amir_25Sep.pdf188 KB{{ ic.x12 }}
{{ ic.upload }}Drop statements or photos, or browse
+
Corrective and preventive actionsAt least one action per root cause before the investigation can be completed.
{{ ic.plus }}Add action
{{ a.desc }}{{ a.rc }}
{{ a.ini }}{{ a.owner }}{{ a.pri.label }}Due {{ a.due }}
{{ ic.alert }}Root cause 2 (detector calibration) has no action yet.
Investigation
LeadRajesh Pillai
Started26 Sep 2026
Due09 Oct 2026 · 8 days left
Severity4 · Major
DOSHJKKP 6 pending
+
Completion checklist
{{ ic.tick12 }}{{ c.label }}
+
Evidence · investigation stage
{{ ic.img24 }}
{{ ic.img24 }}
{{ ic.plus }}
+
+
02dDOSH reporting · JKKP 6
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.incidents.ini }}{{ nv.incidents.name }}
+
{{ ic.arrowLeft }}

DOSH reporting

Reportable
IMS-2026-0246 · Hazard · Dangerous occurrence · Shah Alam DC, Chiller Room · Triaged 25 Sep 2026 by Nadia Hassan
{{ ic.download }}Download JKKP 6 PDFMark as submitted
+
Why this is reportable
{{ ic.alert }}{{ r.what }} · {{ r.law }}
{{ f.name }}{{ f.st.label }}
{{ f.desc }}{{ f.due }}
+
Borang JKKP 6 — Notis Kemalangan / Kejadian Berbahaya
JKKP 6JKKP 7
{{ ic.sparkles }}Fields are filled from the incident record. Edit anything here; changes are saved to the incident and audited.
+
RujukanReference
IMS-2026-0246
+
Nama & alamat majikanEmployer name and address
Setia Logistics Sdn Bhd · Lot 12, Jalan Perusahaan 3, Seksyen 23, 40300 Shah Alam, SelangorFrom Settings · Company profile
+
TapakSite
Shah Alam DC · Chiller RoomFrom incident
+
Tarikh & masa kejadianDate and time of occurrence
25 Sep 2026, 09:05From incident · reported 09:12
+
Jenis insidenIncident type
Hazard · Kejadian berbahaya / Dangerous occurrenceFrom triage
+
PeneranganDescription
Ammonia release from chiller compressor line 2 flange gasket. Detector alarm did not trigger. Chiller isolated at 09:40 by shift supervisor. No exposure symptoms reported by the four staff on shift.From triage notes · Edit
+
Kematian / FatalityTidak / No
Kecederaan serius / Serious bodily injuryTidak / No
Kejadian berbahaya / Dangerous occurrenceYa / Yes
Hari hilang kerja / Lost days—
+
Dilaporkan olehReported by
Lee Wei Jie · Warehouse Operator · lee.weijie@setia.com.myFrom incident
+
Pegawai bertanggungjawabResponsible officer
NHNadia Hassan · HSE Manager · 012-345 6789{{ ic.chev12 }}
+
LampiranAttachments
{{ ic.image }}Photo_compressor_line2.jpg{{ ic.image }}Photo_frost_joint.jpg{{ ic.file }}Incident_report_IMS-2026-0246.pdf{{ ic.plus12 }}Add
Submission record
JKKP 6 is submitted outside IMS on the DOSH MyKKP portal. Record it here so the deadline clears and the PDF is archived with the incident.
Submitted on
Select date{{ ic.calendar }}
MyKKP reference
e.g. JKKP/SEL/2026/00412
Acknowledgement
{{ ic.upload }}Upload receipt PDF
Mark as submitted
+
Deadline
1 dayleft · due 02 Oct 2026
7 days from 25 Sep 2026 occurrence, NADOPOD 2004 s.9(1). Reminders sent to Nadia Hassan and Azlan Ismail at 3 days and 1 day.
+
History
30 Sep 09:001-day reminder emailed and sent via WhatsApp
28 Sep 09:003-day reminder emailed
25 Sep 10:48JKKP 6 draft created on triage by Nadia Hassan
25 Sep 10:48Dangerous occurrence flagged · reportable
+
+
03HSE dashboard
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.dashboard.ini }}{{ nv.dashboard.name }}
+

Dashboard

OverviewTrendsCompliance
{{ ic.calendar }}Last 30 days{{ ic.chev12 }}All sites{{ ic.chev12 }}
+
+
Open incidents37{{ ic.trendUp }}4 vs prior 30 days
+
Leading (near miss + hazard)22{{ ic.trendUp }}More reporting, good sign
+
Lagging (injuries)3{{ ic.trendDown }}1 vs prior 30 days
+
CAPA on-time rate84%
+
DOSH filings pending2Next due 02 Oct (JKKP 6)
+
+
+
Incidents, last 12 months
LeadingLagging
+
+
{{ t.m }}
+
Rising-risk flags
{{ ic.sparkles }}AI
+
{{ ic.alert }}
Dock 3, Shah Alam DC
Near misses up 3× against the 90-day average. 4 involve forklift and pedestrian crossing.
+
{{ ic.alert }}
Battery Charging, Senai DC
Sev 5 fire event plus 2 open hazards in 14 days.
+
{{ ic.alert }}
Racking B, Port Klang Hub
Repeat manual-handling root cause across 3 incidents.
+
+
+
Zone heatmap, 90 days
{{ z.name }}
{{ z.site }}
{{ z.n }}
+
Top root causes
{{ c.name }}{{ c.n }}
+
+
Recent incidents
View all
ReferenceTypeStatusSite · ZoneReported
{{ r.ref }}{{ r.type }}{{ r.st.label }}{{ r.site }} · {{ r.zone }}{{ r.date }}
+
+
04CAPA · list view
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.capa.ini }}{{ nv.capa.name }}
+

CAPA

{{ ic.rows }}List{{ ic.kanban }}Board
{{ ic.download }}Export
+
+
{{ t.label }}{{ t.count }}
{{ ic.plus }}
{{ ic.search }}{{ ic.filter }}{{ ic.sort }}
+
{{ ic.search }}Search action or incident reference
Owner{{ ic.chev12 }}Department{{ ic.chev12 }}Priority{{ ic.chev12 }}Due date{{ ic.chev12 }}
+ + + + + + + + + + + +
{{ ic.minus12 }}Action{{ ic.sort12 }}Incident{{ ic.sort12 }}Owner{{ ic.sort12 }}Department{{ ic.sort12 }}Priority{{ ic.sort12 }}Due{{ ic.down12 }}Status{{ ic.sort12 }}
{{ ic.tick12 }}{{ r.desc }}{{ r.ref }}
{{ r.ini }}{{ r.owner }}
{{ r.dept }}{{ r.pri.label }}
{{ r.due }}
{{ r.dueSub }}
{{ r.st.label }}
{{ ic.eye }}{{ ic.clip }}{{ ic.more }}
+
Showing 1–8 of 42 actions
Page 1 of 6
{{ ic.chevLeft }}{{ ic.chevRight }}
+
{{ ic.minus12 }}2 selectedSend reminderReassign ownerEscalate{{ ic.more }}
+
+
+
04bCAPA · board view
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.capa.ini }}{{ nv.capa.name }}
+

CAPA

{{ ic.rows }}List{{ ic.kanban }}Board
{{ ic.download }}Export
+
{{ ic.search }}Search action or incident reference
Owner{{ ic.chev12 }}Department{{ ic.chev12 }}Priority{{ ic.chev12 }}
Group byStatus{{ ic.chev12 }}
+
{{ c.label }}{{ c.count }}{{ ic.plus }}
{{ k.pri.label }}{{ k.ref }}
{{ k.desc }}
{{ ic.cal12 }}{{ k.due }}{{ k.ini }}
{{ c.emptyText }}
+
+
04cCAPA detail · verification
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.capa.ini }}{{ nv.capa.name }}
+
{{ ic.arrowLeft }}

Anti-slip coating, Loading Bay 1 ramp

Pending verificationMedium
From IMS-2026-0243 · Near miss · Shah Alam DC, Loading Bay 1 · Root cause: Why #2 — ramp surface worn smooth
{{ ic.edit }}EditMore actions{{ ic.chev12 }}
+
{{ ic.tick12 }}{{ p.num }}
{{ p.label }}{{ p.sub }}
+
Verify this actionYou are verifying as Nadia Hassan · HSE
Verified — effectiveRoot cause addressed. A 30-day effectiveness recheck is scheduled automatically.
Reopen — ineffectiveReturns to the owner with a required reason and a new due date.
Verification note optional
Walked the ramp on 28 Sep, coating intact, slip test passed…
Recheck date will be set to 28 Oct 2026 (round 1 of 2).
Ask owner a question{{ ic.tick12 }}Confirm verification
Completion reportSubmitted by Tan Mei Ling · 27 Sep 2026, 16:05
Owner notesRamp ground back and two coats of aggregate anti-slip epoxy applied by contractor on 26 Sep. Cured 24 h, bay reopened 27 Sep 08:00. Wet-slip test with the drum trolley passed. Yellow edge marking repainted at the same time.
Completed27 Sep 2026
Due12 Sep 2026 · 15 days late
CostRM 4,200 · contractor
Evidence · 3 files
{{ ic.img24 }}
{{ ic.img24 }}
{{ ic.file }}Contractor_completion_cert.pdf340 KB
Activity
{{ g.ini }}
{{ g.who }} {{ g.what }}
{{ g.note }}
{{ g.when }}
NH
Add a comment for the owner…
Details
OwnerTMTan Mei Ling
DepartmentFacilities
PriorityMedium
Created22 Aug 2026 · Rajesh Pillai
Due12 Sep 2026
Completed27 Sep 2026
VerifierNHNadia Hassan
+
Effectiveness recheck
{{ ic.calendar }}
Round 1 · 28 Oct 2026Scheduled on verification · 30 days
HSE re-inspects the ramp and checks for repeat incidents in Loading Bay 1. A second round follows at 90 days if the first passes.
+
Related actions on this incident
Toolbox talk on ramp speed for all Bay 1 operatorsVerified
Add ramp gradient signage and floor arrowsIn progress
+
+
05Admin · users
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.admin.ini }}{{ nv.admin.name }}
+

Admin

Manage users, sites, zones, and trucks
{{ ic.upload }}Bulk import incidents{{ ic.plus }}Invite user
+
Users 24Sites & zones 3 · 26Trucks 18
+
+
{{ t.label }}{{ t.count }}
{{ ic.plus }}
{{ ic.search }}{{ ic.filter }}{{ ic.sort }}
+
{{ ic.search }}Search name or email
Role{{ ic.chev12 }}Site{{ ic.chev12 }}Department{{ ic.chev12 }}
+ + + + + + + + + +
Name{{ ic.down12 }}Role{{ ic.sort12 }}Department{{ ic.sort12 }}Site{{ ic.sort12 }}Status{{ ic.sort12 }}
{{ u.ini }}
{{ u.name }}
{{ u.email }}
{{ u.role }}{{ u.dept }}{{ u.site }}{{ u.st.label }}
{{ ic.pencil }}{{ ic.key }}{{ ic.more }}
+
Showing 1–8 of 24 users
Page 1 of 3
{{ ic.chevLeft }}{{ ic.chevRight }}
+
+
+
05bAdmin · sites & zones
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.admin.ini }}{{ nv.admin.name }}
+

Admin

Manage users, sites, zones, and trucks
{{ ic.download }}Export{{ ic.plus }}Add site
+
Users 24Sites & zones 3 · 26Trucks 18
+
{{ ic.search }}Search sites
{{ s.code }}
{{ s.name }}{{ s.region }} · {{ s.zones }} zones · {{ s.users }} users
{{ s.st.label }}
{{ ic.plus }}Add site
Shah Alam DCActive
Lot 12, Jalan Perusahaan 3, Seksyen 23, 40300 Shah Alam, Selangor · Central region
{{ ic.edit }}Edit site{{ ic.more }}
Zones 9Status: Active{{ ic.chev12 }}
{{ ic.qr }}Print all QR{{ ic.plus }}Add zone
Zone{{ ic.sort12 }}QR code{{ ic.sort12 }}Incidents · 12 mo{{ ic.sort12 }}Status{{ ic.sort12 }}
{{ z.name }}
{{ ic.qr }}{{ z.token }}{{ z.scans }}
{{ z.n }}
{{ z.st.label }}
{{ ic.download }}{{ ic.edit }}{{ ic.more }}
9 zones · 1 inactive hiddenShow inactive
+
+
05cAdmin · trucks
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.admin.ini }}{{ nv.admin.name }}
+

Admin

Manage users, sites, zones, and trucks
{{ ic.download }}Export{{ ic.plus }}Add truck
+
Users 24Sites & zones 3 · 26Trucks 18
+
{{ t.label }}{{ t.count }}
{{ ic.plus }}
{{ ic.search }}{{ ic.filter }}{{ ic.sort }}
+
{{ ic.search }}Search truck number or carrier
Carrier{{ ic.chev12 }}Status{{ ic.chev12 }}Last incident{{ ic.chev12 }}
+
Truck no.{{ ic.sort12 }}Carrier{{ ic.sort12 }}Incidents{{ ic.sort12 }}Last incident{{ ic.sort12 }}Added{{ ic.sort12 }}Status{{ ic.sort12 }}
{{ ic.truck }}{{ k.no }}
{{ k.carrier }}{{ k.n }}{{ k.last }}{{ k.lastDate }}—{{ k.added }}{{ k.st.label }}
{{ ic.list }}{{ ic.edit }}{{ ic.more }}
+
Showing 1–8 of 18 trucks
Page 1 of 3
{{ ic.chevLeft }}{{ ic.chevRight }}
+
+
05dAdmin · audit log
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.admin.ini }}{{ nv.admin.name }}
+

Admin

Manage users, sites, zones, and trucks
{{ ic.download }}Export{{ ic.plus }}Add truck
+
Users 24Sites & zones 3 · 26Trucks 18Audit log
+
{{ ic.search }}Search record, user or field
Table{{ ic.chev12 }}Action{{ ic.chev12 }}User: Nadia Hassan{{ ic.x12 }}Last 7 days{{ ic.chev12 }}
{{ ic.download }}Export CSV
+
When{{ ic.sort12 }}User{{ ic.sort12 }}Action{{ ic.sort12 }}Record{{ ic.sort12 }}Change
{{ a.when }}
{{ a.ini }}{{ a.who }}
{{ a.act.label }}{{ a.table }} {{ a.rec }}{{ a.summary }}{{ a.chev }}
Before
{{ d.k }}{{ d.old }}
After
{{ d.k }}{{ d.new }}
+
Showing 1–9 of 143 entries
Page 1 of 16
{{ ic.chevLeft }}{{ ic.chevRight }}
+
+
06Settings · API keys
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.settings.ini }}{{ nv.settings.name }}
+

Settings

+
+
API keys
API keys are stored securely in the database. Leave blank to use environment variables.
+
+
ServiceStored valueStatusUpdated
{{ k.name }}
{{ k.use }}
{{ k.val }}{{ k.st.label }}{{ k.upd }}Edit
+
Edit Resend API key
{{ ic.x }}
+
re_7Hk2
Currently falling back to RESEND_API_KEY from the server environment.
+
CancelSave key
+
+
+
07Reporter · My reports
{{ ic.shield }}IMSSetia HSE
{{ ic.search }}Search incidents, CAPAs, people⌘K
{{ ic.bell }}
{{ nv.reporter.ini }}{{ nv.reporter.name }}
+

My reports

{{ ic.qr }}Scan zone QR{{ ic.plus }}Report incident
+
{{ ic.wifiOff }}1 report saved offline. It will sync automatically when you are back online.Sync now
+
+
{{ t.label }}{{ t.count }}
{{ ic.plus }}
{{ ic.search }}
+ + + + + + + + +
Reference{{ ic.sort12 }}Type{{ ic.sort12 }}Site · Zone{{ ic.sort12 }}Status{{ ic.sort12 }}Reported{{ ic.down12 }}Latest update{{ ic.sort12 }}
{{ r.ref }}{{ r.type }}{{ r.site }} · {{ r.zone }}{{ r.st.label }}{{ r.date }}{{ r.note }}
+
Showing 5 of 5 reports
Page 1 of 1
{{ ic.chevLeft }}{{ ic.chevRight }}
+
+
+
08Empty state · no matching incidents
+
+
{{ t.label }}{{ t.count }}
{{ ic.plus }}
+
{{ ic.search }}forklift battery
Type is Fire / Emergency{{ ic.x12 }}Site is Port Klang Hub{{ ic.x12 }}Severity{{ ic.chev12 }}Clear all
+
{{ ic.big }}
No incidents match these filters
Try a different search term, or remove a filter to widen the results.
Clear filters{{ ic.plus }}New incident
+
+
+
+
09Mobile · Reporter home
9:41
+
My reports
AR
+
+{{ ic.plus }}Report incident +
{{ ic.wifiOff }}1 report waiting to syncSync
+
All 5Open 3Closed 1
+
{{ r.ref }}{{ r.st.label }}
{{ r.type }} · {{ r.zone }}
{{ r.date }}
{{ ic.chevRight }}
+
+
{{ ic.m.list }}My Reports
{{ ic.m.plus }}New Incident
{{ ic.m.logout }}Logout
+
+
10Mobile · HSE incidents
9:41
+
Incidents
{{ ic.search }}{{ ic.filter }}
+
+
{{ t.label }} {{ t.count }}
+
{{ r.ref }}{{ r.st.label }}
{{ r.type }}
{{ r.site }} · {{ r.zone }}
+
+
{{ ic.m.chart }}Dashboard
{{ ic.m.list }}Incidents
{{ ic.m.check }}CAPA
{{ ic.m.settings }}Settings
+
+
11Mobile · Incident detail
9:41
+
{{ ic.arrowLeft }}IMS-2026-0247{{ ic.more }}
+
+
TriagedDOSH reportable
Step 2 of 6 · next: Investigation
+
{{ ic.alert }}JKKP 6 due 02 Oct 2026
Occupational injury, expected MC above 4 days. 5 days left to notify DOSH.
+
TypeInjury / Medical
Severity4 · Major
LocationPort Klang Hub · Racking B
ReporterMuthu Kumar
Evidence4 files
+
Reach-truck operator reported lower back strain after manually repositioning a pallet that had shifted on racking level 3 (upright B-14).
+
+
PDFStart investigation
+
+
12Mobile · New incident 1/3
9:41
+
{{ ic.arrowLeft }}Report incident1 of 3
{{ ic.qr }}
Shah Alam DC · Dock 3Zone detected from QR scan
Change
What happened? *
{{ ty.icon }}{{ ty.label }}
Truck *
{{ ic.truck }}WXY 4821 · Setia Logistics{{ ic.chev12 }}
Required for transport incidents
Continue
+
13Mobile · New incident 2/3
9:41
+
{{ ic.arrowLeft }}Report incident2 of 3
Describe what happened *
Reach truck reversed out of Dock 3 without horn. Pedestrian in walkway stepped back, no contact. Mirror at corner is missing.
{{ ic.sparkles }}
Quality check · 62/100Add the approximate time and the truck operator's name if known.Submit anyway
Photos
{{ ic.img24 }}{{ ic.x12 }}
{{ ic.img24 }}{{ ic.x12 }}
{{ ic.image }}Add
Up to 6 · taken now, stored on device until synced
Anyone injured?
Asset or equipment damaged?
BackContinue
+
14Mobile · Review (offline)
9:41
+
{{ ic.arrowLeft }}Review3 of 3
{{ ic.wifiOff }}You're offline. The report saves to this phone and syncs automatically.
TypeNear miss
WhereShah Alam DC · Dock 3
TruckWXY 4821
InjuryNo
Asset damageNo
Photos2 attached
DescriptionReach truck reversed out of Dock 3 without horn. Pedestrian in walkway stepped back, no contact. Mirror at corner is missing.
Reported as Aina Rahman · 25 Sep 2026, 14:32. A reference number is assigned when the report syncs.
Back{{ ic.download }}Save on this phone
+
15Mobile · Saved offline
9:41
+
{{ ic.checkBig }}
Saved on this phoneIt will sync when you're back online and appear in My reports as Pending sync. Your supervisor is notified the moment it lands.
Near miss · Dock 3Pending sync
Report anotherDone
+
16Mobile · CAPA owner action
9:41
+
{{ ic.arrowLeft }}My action{{ ic.more }}
+
Overdue · 2 daysCritical
Replace damaged racking upright B-14 and re-inspect bay
From IMS-2026-0245 · Senai DC, MHE Bay
+
Due25 Sep 2026
Root causeWhy #1 — forklift impact
Assigned byRajesh Pillai
DescriptionIsolate bays B-12 to B-16, replace bent upright, torque check and re-certify load rating before restocking.
+
Progress note
Upright delivered 26 Sep. Contractor on site tomorrow 08:00, bay stays isolated.
{{ ic.img24 }}
{{ ic.image }}
+
Save note{{ ic.tick12 }}Mark complete
+
+
+ + + diff --git a/design-system/design.md b/design-system/design.md new file mode 100644 index 0000000..5155e26 --- /dev/null +++ b/design-system/design.md @@ -0,0 +1,210 @@ +# IMS Design System: Admin refresh + +Source of truth for IMS UI. Derived from `IMS Admin Spec.dc.html` (patterns, tokens, states) and `IMS Admin.dc.html` (25 artboards: 7 desktop screens plus variants, 9 mobile screens). When this file and the mockups disagree, fix this file and say so in the PR. The earlier Modernist system (`design-system/_ds/`) is retired. + +Rules in `CLAUDE.md` ("Design system") summarise this file. Tokens in `app/globals.css` mirror §2. + +## 1. Principles + +- Neutral commerce-admin look: grey ground, white cards, dark primary action, one teal accent used sparingly. +- Every list is a `TableCard` (§4.9). Do not hand-build tables. +- Status is always a dark text step on a light tint, with a text label (§4.2). Never white text on a saturated fill, never colour alone. +- Rules are 1px. Corners come from the radius scale in §2.3. Text and headings are flush left. +- Minimum hit target 44px on mobile. + +## 2. Tokens + +### 2.1 Colour + +| Token | Hex | Use | +| --- | --- | --- | +| `ink` | `#1f1f1f` | Primary text, active sidebar text | +| `ink-2` | `#303030` | Primary button, chip text | +| `ink-3` | `#4a4a4a` | Secondary text, icons | +| `muted` | `#616161` | Labels, helper text | +| `faint` | `#8a8a8a` | Placeholders, input ring | +| `rule` | `#ebebeb` | Row rules, sidebar background | +| `rule-2` | `#e3e3e3` | Header rule, segmented background | +| `ring` | `#d4d4d4` | Secondary button and chip ring | +| `surface` | `#ffffff` | Cards, rows, inputs | +| `surface-2` | `#f7f7f7` | Table header, footer, row hover | +| `ground` | `#f1f1f1` | Page background | +| `accent` | `#0f766e` | Checks, links, focus ring, active tab icon | +| `accent-tint` | `#f2f7f6` | Selected row, selected card | +| `accent-tint-2` | `#e6f4f1` | Set filter chip (ring `#9fd3c7`, text `#0b4f47`) | +| `danger` | `#b3261e` | Overdue text, required marks, input error | +| `topbar` | `#1a1a1a` | App header (its controls use `#303030`, ring `#3d3d3d`, text `#a3a3a3`) | + +Tailwind names: `bg-ground`, `bg-surface`, `bg-surface-2`, `text-ink`, `text-ink-2`, `text-ink-3`, `text-muted`, `text-faint`, `border-rule`, `border-rule-2`, `border-ring`, `bg-accent`, `text-accent`, `bg-accent-tint`, `bg-accent-tint-2`, `text-danger`, `bg-topbar`. + +### 2.2 Type + +Geist for UI, Geist Mono for references and keyboard hints. Exposed as `--font-geist` and `--font-geist-mono`. + +| Spec | Use | +| --- | --- | +| 32 / 600 / -0.02em | Cover title | +| 22 / 650 / -0.02em | Mobile page title | +| 20 / 650 / -0.01em | Page title | +| 16 / 650 / -0.01em | Card title (detail) | +| 14 / 600 | Section heading | +| 13 / 400-550 | Body, table cells, buttons | +| 12 / 550 | Table header, pill, helper | +| 12.5 mono / 500 | References such as `IMS-2026-0247` | + +### 2.3 Radius, shadow, spacing, icons + +- **Radius:** 12 cards and phones; 10 mobile drawer and mobile inputs; 8 buttons, chips, inputs, pills, sidebar items; 6 avatars (24px); 5 checkbox; 999 badges. Tailwind: `rounded-md` = 8, `rounded-xl` = 12, `rounded-[5px]` checkbox. +- **Card shadow** (`shadow-card`): `0 0 0 1px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06)`. +- **Floating shadow** (`shadow-float`, bulk bar): `0 0 0 1px rgba(0,0,0,.1), 0 12px 32px rgba(0,0,0,.18)`. Drawer: `0 0 0 1px rgba(0,0,0,.1), 0 24px 60px rgba(0,0,0,.24)`. +- **Focus:** `outline: 2px solid accent; outline-offset: 2px` on every interactive element. +- **Spacing:** 4, 6, 8, 10, 12, 16, 20, 24, 32. Card padding 16-20, table cell 12, toolbar 10/12. +- **Icons:** Lucide. 16px stroke 2 in UI; 12px stroke 2.5 inside chips and checks; 22px stroke 1.8 in the mobile tab bar. +- **Motion:** transitions 120ms on background and shadow only. + +## 3. Layout shell + +**Desktop (`AppShell`)** +- Top bar 56px `topbar`: brand 224px (28px teal tile radius 8, "IMS", muted "Setia HSE"), search max 520px (34px, radius 10, shows a Cmd-K hint), bell and user chip on the right. +- Sidebar 240px `rule` background, 1px right border `#e0e0e0`, padding 12, items 32px radius 8, 13px. Active item: white, 1px ring, teal icon. Badges 999 `#dcdcdc`, 11px/600. Footer block has a 1px `#dcdcdc` top rule. +- Main: padding 24/32, column gap 16. Page title 20px/650 with actions on the right. Detail pages use `1fr` plus a 320-340px side rail. +- Page background `ground`; cards `surface`, radius 12, `shadow-card`. + +**Mobile (`MobileShell`, reporter and CAPA owner)** +- 390px reference. Page title 22px/650, horizontal padding 16, card gap 12. +- Tab bar: white, 1px top rule, 3 items, 22px icons, 10.5px labels, active `accent`. +- Controls 48px tall, radius 12; primary button full width 48px. Footers sit on `ground` with a 1px top rule and 30px bottom safe area. + +## 4. Components + +Hover and active values below are per component. Every interactive element also gets the global focus ring (§2.3). Disabled controls drop to 45% opacity. + +### 4.1 Button +- **Primary** 32px, radius 8, `#303030`, white 13px/600, inset highlight `inset 0 -1px 0 #000, inset 0 1px 0 rgba(255,255,255,.18), 0 1px 2px rgba(0,0,0,.2)`. Hover `#1f1f1f`, active `#000`. +- **Secondary** white, 13px/550, ring `inset 0 0 0 1px #d4d4d4, 0 1px 0 rgba(0,0,0,.05)`. Hover `#f7f7f7`, active `#ebebeb`. +- **Icon** 28px ghost, radius 8, `ink-3`. Hover `#ebebeb`. +- Mobile primary: full width, 48px, radius 12. + +### 4.2 StatusTag and PriorityTag +Pill: `inline-flex`, padding 2px 8px, radius 8, 12px/550, no wrap. Dark text on a light tint. Incident status and CAPA status share one palette. + +| Label | Background | Text | +| --- | --- | --- | +| Reported | `#fff1c2` | `#6b4a00` | +| Triaged | `#e0efff` | `#00527c` | +| Investigating | `#ede7ff` | `#4b2e99` | +| CAPA pending | `#ffe6cf` | `#7a3a00` | +| Verification | `#e3e8ff` | `#2c3e8f` | +| Closed | `#d7f4e3` | `#0c5132` | +| Open | `#ebebeb` | `#4a4a4a` | +| In progress | `#e0efff` | `#00527c` | +| Overdue / Critical | `#fee3e0` | `#8e1f0b` | +| High | `#ffe6cf` | `#7a3a00` | +| Medium | `#fff1c2` | `#6b4a00` | +| Low | `#ebebeb` | `#4a4a4a` | +| Active | `#d7f4e3` | `#0c5132` | +| Verified | `#d7f4e3` | `#0c5132` | +| Reopened | `#fee3e0` | `#8e1f0b` | + +Mapping from the data model: incident `reported/triaged/investigating/capa_pending/verification/closed` use the matching rows; CAPA `open/in_progress/overdue/pending_verification/verified/reopened/closed` map to Open, In progress, Overdue, Verification, Verified, Reopened, Closed; priority `high/med/low` map to High, Medium, Low. Severity 5 and Critical use the Overdue / Critical row. Tailwind: `st--bg` / `st--fg` pairs. No icon required; the text label is always present. + +### 4.3 FilterChip +28px, radius 8, 12.5px, padding 0 10px. Unset: white, ring `#d4d4d4`, text `#303030`, trailing 12px chevron. Set: `accent-tint-2`, ring `#9fd3c7`, text `#0b4f47`, shows "Label: value" and a clear x. + +### 4.4 Segmented +Container padding 2px, background `#e3e3e3`, radius 10. Option 13px, padding 5px 10px, radius 8. Active: white, 13px/600, `0 1px 2px rgba(0,0,0,.1)`. Used for List / Board. + +### 4.5 Checkbox +16px, radius 5. Off: white with `inset 0 0 0 1.5px #8a8a8a`. On and indeterminate (header): `accent` fill, white 12px tick or minus at stroke 3. + +### 4.6 Field and Input +Input 36px desktop, 48px mobile, padding 0 12px, radius 8 (12 on mobile), 13px, white. Rest ring `inset 0 0 0 1px #8a8a8a`; focus ring 2px `accent`; error ring `danger`. Placeholder `faint`. Label 12px `muted`, 5px above. Textarea and Select share the ring. + +### 4.7 Avatar +24px, radius 6, background `#c5e8e0`, text `#0b4f47`, 11px/650, initials. Top bar variant sits in a `#303030` chip. + +### 4.8 Card +White, radius 12, `shadow-card`, padding 16-20. Selected card uses `accent-tint`. Detail card title 16px/650. + +### 4.9 TableCard +One component wraps every list. Parts top to bottom, all optional except the table and the card: +- **A. Saved views:** padding 8, bottom rule `#ebebeb`. View chip 28px radius 8, 13px; active `#e3e3e3` 13px/600 with a faint count (12px `#8a8a8a`); trailing + button opens "Save current filters as view". Saved views are server-side filters; counts update live. +- **B. Toolbar:** padding 10/12, bottom rule. Search 32px, radius 8, ring `#8a8a8a`, min-width 260. Filter chips (§4.3). Right-aligned actions. +- **C. Header:** `surface-2`, 12px/550 `muted`, padding 9/12, bottom rule `#e3e3e3`. Single-column sort: sorted column shows a filled arrow in `ink`, others a faint `#c4c4c4` double chevron. +- **D. Row rest:** white, 13px, cell padding 12, 1px `#ebebeb` rule. References in Geist Mono 12.5px in `accent`. +- **E. Row hover:** `surface-2`; quick actions (eye, more) appear on the right as 28px icon buttons. +- **F. Row selected:** `accent-tint` and a filled checkbox. +- **G. Footer:** `surface-2`, padding 10/16, "Showing 1-3 of 248" left, pager right (32px segmented chevrons, radius 8 on outer ends, ring `#d4d4d4`). +- **H. Bulk bar:** floats centred above the footer on first selection. White, radius 12, `shadow-float`, padding 6 6 6 12; checkbox, "N selected", divider, ghost actions (Assign, Export). +- **Empty state:** replaces thead and tbody: 64px icon tile, one line of copy, the primary action. + +Behaviour: the whole row opens the record; the checkbox cell, links and quick actions stop propagation. + +**Mobile:** below 768px the table becomes a stacked list in the same card: reference + status on line one, type and zone on line two, date on line three, chevron right. Saved views become horizontally scrolling 999px chips; filters collapse to one "Filter" button opening a sheet; the bulk bar becomes a bottom sheet. + +### 4.10 Drawer +Notifications drawer: absolute, top/right/bottom 8px, width 420px, white, radius 14, shadow `0 0 0 1px rgba(0,0,0,.1), 0 24px 60px rgba(0,0,0,.24)`; scrim `rgba(0,0,0,.28)`. Header 16px/650 title with "Mark all read" (12.5px/550 `accent`), settings and close icon buttons. Tab row of 28px view chips with counts. Group labels 11.5px/600 uppercase `faint`. Items: 32px radius-9 icon tile, padding 12/16, rule `#f0f0f0`, unread items tinted. + +## 5. Screen index + +| Id | Screen | Route | +| --- | --- | --- | +| 01 | Incidents list | `/hse/incidents` | +| 01b | Notifications drawer | global | +| 02 | Incident detail | `/hse/incidents/[id]` | +| 02b | Triage form | `/hse/incidents/[id]` triage | +| 02c | Investigation form | `/hse/incidents/[id]` investigation | +| 02d | DOSH reporting (JKKP 6) | `/hse/incidents/[id]` new | +| 03 | Dashboard | `/hse/dashboard` | +| 04 | CAPA list | `/hse/capa` | +| 04b | CAPA board | `/hse/capa` board | +| 04c | CAPA detail, verification | `/hse/capa` new | +| 05 | Admin, users | `/admin` | +| 05b | Admin, sites and zones | `/admin` tab | +| 05c | Admin, trucks | `/admin` tab | +| 05d | Admin, audit log | `/admin` new tab | +| 06 | Settings, API keys | `/hse/settings` | +| 07 | Reporter, my reports | `/reporter` | +| 08 | Empty state | pattern | +| 09 | Mobile, reporter home | `/reporter` | +| 10 | Mobile, incidents | `/hse/incidents` | +| 11 | Mobile, incident detail | `/hse/incidents/[id]` | +| 12-15 | Mobile, new incident 1/3 to saved offline | `/report` | +| 16 | Mobile, CAPA owner action | `/capa-owner` | + +New routes in the mockup that do not exist yet: audit log (05d), DOSH reporting entry (02d), and any "new tab" marked above. Treat them as separate features; do not build them as part of the restyle. + +## 6. Accessibility + +- Text on tints passes contrast because pills use dark steps. Body text is `ink` or `ink-3` on white or `ground`; `faint` is for placeholders only. +- Focus ring on every interactive element; nothing relies on colour alone. +- Hit targets 44px minimum on mobile. + +## 7. Scope + +This file covers look and component structure. Routes, queries, permissions and audit logging do not change as part of a restyle. + +## 8. Build order + +1. **Tokens:** replace the Modernist tokens in `app/globals.css` with §2 (`@theme static`), Geist via `next/font`, `shadow-card`, `shadow-float`, `st-*` pairs. Keep the `gray-*`/`blue-*`/`red-*` remaps pointing at the new neutral and teal values so unmigrated pages stay readable. +2. **UI primitives:** `Button`, `StatusTag`, `PriorityTag`, `Checkbox`, `Field`/`Input`/`Select`/`Textarea`, `FilterChip`, `Segmented`, `Avatar`, `Card`, `Drawer` in `components/ui/`. +3. **TableCard** (§4.9) with the desktop and mobile variants. +4. **Shells:** `AppShell` (top bar, sidebar, notifications drawer) and `MobileShell`. +5. **Migrate the Incidents list** (screen 01 and 10) as the first full screen. +6. **Remaining screens**, in §5 order, one plan per group. + +Gate first: before step 1, update `scripts/check-design-gates.mjs` to allow `rounded-*`, flag `border-b-2` and `border-2`, and flag Archivo and `#ec3013`. `npm run check:design` must pass at the end of each step. + +## 9. What changes from the live Modernist build + +| Area | Now (Modernist) | After | +| --- | --- | --- | +| Font | Archivo | Geist and Geist Mono | +| Accent | `#ec3013` red | `#0f766e` teal (used sparingly) | +| Primary button | red, flush left | `#303030`, 32px, radius 8 | +| Radius | 0 everywhere | 8 / 10 / 12 scale | +| Rules | 2px section rules | 1px | +| Status | mono tags (accent, outline, neutral) | coloured pills (§4.2) | +| Sidebar | flat, 2px rule | dark top bar plus `#ebebeb` sidebar | +| Lists | per-page tables | `TableCard` | +| Gate | no rounded, 2px rules | rounded allowed, 2px flagged | diff --git a/design-system/support.js b/design-system/support.js new file mode 100644 index 0000000..cb009b6 --- /dev/null +++ b/design-system/support.js @@ -0,0 +1,1911 @@ +// GENERATED from dc-runtime/src/*.ts — do not edit. Rebuild with `cd dc-runtime && bun run build`. +"use strict"; +(() => { + var __defProp = Object.defineProperty; + var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; + var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); + + // src/react.ts + function getReact() { + const R = window.React; + if (!R) throw new Error("dc-runtime: window.React is not available yet"); + return R; + } + function getReactDOM() { + const RD = window.ReactDOM; + if (!RD) throw new Error("dc-runtime: window.ReactDOM is not available yet"); + return RD; + } + var h = ((...args) => getReact().createElement( + ...args + )); + + // src/parse.ts + function parseDcDocument(doc) { + const dc = doc.querySelector("x-dc"); + if (!dc) return null; + const scriptEl = doc.querySelector("script[data-dc-script]"); + const { props, preview } = parseDataProps( + scriptEl?.getAttribute("data-props") ?? null + ); + return { + template: dc.innerHTML, + js: scriptEl ? scriptEl.textContent || "" : "", + props, + preview + }; + } + function parseDcText(src) { + const openMatch = /]*)?>/.exec(src); + if (!openMatch) return null; + const close = src.lastIndexOf(""); + if (close === -1 || close < openMatch.index) return null; + const template = src.slice(openMatch.index + openMatch[0].length, close); + const doc = new DOMParser().parseFromString(src, "text/html"); + const scriptEl = doc.querySelector("script[data-dc-script]"); + const { props, preview } = parseDataProps( + scriptEl?.getAttribute("data-props") ?? null + ); + return { + template, + js: scriptEl ? scriptEl.textContent || "" : "", + props, + preview + }; + } + function parseDataProps(raw) { + if (!raw) return { props: null, preview: null }; + let parsed; + try { + parsed = JSON.parse(raw); + } catch { + return { props: null, preview: null }; + } + if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) { + return { props: null, preview: null }; + } + const obj = parsed; + const preview = obj.$preview && typeof obj.$preview === "object" ? obj.$preview : null; + const rest = {}; + for (const k of Object.keys(obj)) { + if (k[0] !== "$") rest[k] = obj[k]; + } + return { props: Object.keys(rest).length ? rest : null, preview }; + } + function dcNameFromPath(pathname) { + let p = pathname || ""; + try { + p = decodeURIComponent(p); + } catch { + } + const base = p.split("/").pop() || "Root"; + return base.replace(/\.dc\.html$/, "").replace(/\.html?$/, "") || "Root"; + } + + // src/boot.ts + var BASE_CSS = ` + .sc-placeholder{background:color-mix(in srgb,currentColor 8%,transparent); + border:1px solid color-mix(in srgb,currentColor 50%,transparent); + border-radius:2px;box-sizing:border-box;overflow:hidden} + @keyframes sc-shine{0%{background-position:100% 50%}100%{background-position:0% 50%}} + html.sc-dc-streaming .sc-placeholder, + html.sc-dc-streaming .sc-interp.sc-missing{position:relative; + background:color-mix(in srgb,currentColor 5%,transparent); + border-color:transparent} + html.sc-dc-streaming .sc-placeholder::before, + html.sc-dc-streaming .sc-interp.sc-missing::before{content:''; + position:absolute;inset:0;pointer-events:none; + background:linear-gradient(90deg,rgba(217,119,87,0) 25%,rgba(247,225,211,.95) 37%,rgba(217,119,87,0) 63%); + background-size:400% 100%;animation:sc-shine 1.4s ease infinite} + html.sc-dc-streaming .sc-placeholder:nth-child(n+9 of .sc-placeholder)::before, + html.sc-dc-streaming .sc-interp.sc-missing:nth-child(n+9 of .sc-interp.sc-missing)::before{animation:none; + background:color-mix(in srgb,currentColor 8%,transparent)} + .sc-placeholder-error{padding:4px 8px;font:11px/1.4 ui-monospace,monospace; + color:color-mix(in srgb,currentColor 70%,transparent);word-break:break-word} + .sc-interp.sc-missing{display:inline-block;width:2em;height:1em;overflow:hidden; + vertical-align:text-bottom;background:rgba(255,255,255,.3);border:1px solid rgba(0,0,0,.5); + border-radius:2px;box-sizing:border-box;color:transparent; + user-select:none} + .sc-interp.sc-unresolved{font-family:ui-monospace,monospace;font-size:.85em; + color:color-mix(in srgb,currentColor 50%,transparent); + background:color-mix(in srgb,currentColor 10%,transparent);border-radius:3px; + padding:0 3px} + .sc-host.sc-has-error{position:relative} + .sc-logic-error{position:absolute;top:8px;left:8px;z-index:2147483647;max-width:60ch; + padding:6px 10px;background:#b00020;color:#fff;font:12px/1.4 ui-monospace,monospace; + border-radius:4px;white-space:pre-wrap;pointer-events:none} + /* Mirrors PRINT_BASELINE_CSS in apps/web deck-stage-export.ts \u2014 keep both + in sync until dc-runtime regains a build step. */ + @media print { + @page { margin: 0.5cm; } + figure, table { break-inside: avoid; } + #dc-root, #dc-root > .sc-host { height: auto; } + *, *::before, *::after { + print-color-adjust: exact; -webkit-print-color-adjust: exact; + backdrop-filter: none !important; -webkit-backdrop-filter: none !important; + animation-delay: -99s !important; animation-duration: .001s !important; + animation-iteration-count: 1 !important; animation-fill-mode: both !important; + animation-play-state: running !important; transition-duration: 0s !important; + } + } + `; + var FULL_PAGE_CSS = "html,body{height:100%;margin:0}#dc-root,#dc-root>.sc-host{height:100%}"; + function rootNameForDocument(doc, loc) { + let bootPath = loc.pathname || ""; + if (!/\.dc\.html?$/i.test(safeDecode(bootPath))) { + try { + bootPath = new URL(doc.baseURI || "/").pathname; + } catch { + } + } + return dcNameFromPath(bootPath); + } + function safeDecode(s) { + try { + return decodeURIComponent(s); + } catch { + return s; + } + } + function boot(runtime, doc = document) { + const parsed = parseDcDocument(doc); + if (!parsed) return null; + const React = getReact(); + const rootName = rootNameForDocument(doc, location); + runtime.markFetched(rootName); + runtime.setRootName(rootName); + runtime.adoptParsed(rootName, parsed); + if (!window.__resources) { + fetch(location.href).then((res) => res.ok ? res.text() : "").then((t) => { + const raw = t ? parseDcText(t) : null; + if (raw?.template) runtime.updateHtml(rootName, raw.template); + }).catch(() => { + }); + } + const dc = doc.querySelector("x-dc"); + const hostEl = doc.createElement("div"); + hostEl.id = "dc-root"; + dc.replaceWith(hostEl); + if (!parsed.preview) { + const s = doc.createElement("style"); + s.textContent = FULL_PAGE_CSS; + doc.head.appendChild(s); + } + const Root = runtime.getDC(rootName); + const entry = runtime.registry.get(rootName); + function StandaloneRoot() { + const [, setTick] = React.useState(0); + React.useEffect(() => { + const sub = () => setTick((n) => n + 1); + entry.subs.add(sub); + return () => { + entry.subs.delete(sub); + }; + }, []); + const defaults = React.useMemo(() => { + const d = {}; + for (const k in entry.propsMeta || {}) { + const v = entry.propsMeta?.[k]?.default; + if (v !== void 0) d[k] = v; + } + return d; + }, [entry.propsMeta]); + return h(Root, { ...defaults, ...entry.propOverrides || {} }); + } + const ReactDOM = getReactDOM(); + if (ReactDOM.createRoot) + ReactDOM.createRoot(hostEl).render(h(StandaloneRoot)); + else ReactDOM.render(h(StandaloneRoot), hostEl); + return rootName; + } + + // src/expr.ts + var IDENT_RE = /^[A-Za-z_$][A-Za-z0-9_$]*/; + var NUMBER_RE = /^-?\d+(\.\d+)?$/; + function resolve(vals, src) { + const expr = String(src).trim(); + if (!expr) return void 0; + if (expr[0] === "(" && expr[expr.length - 1] === ")" && parensWrapWhole(expr)) { + return resolve(vals, expr.slice(1, -1)); + } + const eq = findTopLevelEquality(expr); + if (eq) { + const lv = resolve(vals, expr.slice(0, eq.index)); + const rv = resolve(vals, expr.slice(eq.index + eq.op.length)); + switch (eq.op) { + case "===": + return lv === rv; + case "!==": + return lv !== rv; + case "==": + return lv == rv; + default: + return lv != rv; + } + } + if (expr[0] === "!") return !resolve(vals, expr.slice(1)); + if (expr === "true") return true; + if (expr === "false") return false; + if (expr === "null") return null; + if (expr === "undefined") return void 0; + if (NUMBER_RE.test(expr)) return Number(expr); + if (expr.length >= 2 && (expr[0] === '"' || expr[0] === "'") && expr[expr.length - 1] === expr[0]) { + return expr.slice(1, -1); + } + return resolvePath(vals, expr); + } + function parensWrapWhole(expr) { + let depth = 0; + for (let i = 0; i < expr.length - 1; i++) { + if (expr[i] === "(") depth++; + else if (expr[i] === ")") { + depth--; + if (depth === 0) return false; + } + } + return true; + } + function findTopLevelEquality(expr) { + let depth = 0; + for (let i = 0; i < expr.length; i++) { + const c = expr[i]; + if (c === "[" || c === "(") depth++; + else if (c === "]" || c === ")") depth--; + else if (depth === 0 && (c === "=" || c === "!") && expr[i + 1] === "=") { + if (i > 0 && (expr[i - 1] === "=" || expr[i - 1] === "!")) continue; + if (!expr.slice(0, i).trim()) continue; + const op = expr[i + 2] === "=" ? c + "==" : c + "="; + return { index: i, op }; + } + } + return null; + } + function resolvePath(vals, expr) { + const head = expr.match(IDENT_RE); + if (!head) return void 0; + let cur = vals == null ? void 0 : vals[head[0]]; + let i = head[0].length; + while (i < expr.length) { + if (expr[i] === ".") { + const m = expr.slice(i + 1).match(IDENT_RE) || expr.slice(i + 1).match(/^\d+/); + if (!m) return void 0; + cur = cur == null ? void 0 : cur[m[0]]; + i += 1 + m[0].length; + } else if (expr[i] === "[") { + let depth = 1; + let j = i + 1; + while (j < expr.length && depth > 0) { + if (expr[j] === "[") depth++; + else if (expr[j] === "]") { + depth--; + if (depth === 0) break; + } + j++; + } + if (depth !== 0) return void 0; + const key = resolve(vals, expr.slice(i + 1, j)); + cur = cur == null ? void 0 : cur[key]; + i = j + 1; + } else { + return void 0; + } + } + return cur; + } + + // src/encode.ts + var CAMEL_ATTR = "sc-camel-"; + var INLINE_TEXT_TAGS = new Set( + "a abbr b bdi bdo br cite code del dfn em i ins kbd mark q s samp small span strike strong sub sup u var wbr".split( + " " + ) + ); + var RAW_WRAP = { + select: "sc-raw-select", + table: "sc-raw-table", + tbody: "sc-raw-tbody", + thead: "sc-raw-thead", + tfoot: "sc-raw-tfoot", + tr: "sc-raw-tr", + td: "sc-raw-td", + th: "sc-raw-th", + caption: "sc-raw-caption" + }; + var RAW_UNWRAP = Object.fromEntries( + Object.entries(RAW_WRAP).map(([k, v]) => [v, k]) + ); + var EVENT_MAP = { + onclick: "onClick", + onchange: "onChange", + oninput: "onInput", + onsubmit: "onSubmit", + onkeydown: "onKeyDown", + onkeyup: "onKeyUp", + onkeypress: "onKeyPress", + onmousedown: "onMouseDown", + onmouseup: "onMouseUp", + onmouseenter: "onMouseEnter", + onmouseleave: "onMouseLeave", + onfocus: "onFocus", + onblur: "onBlur", + ondoubleclick: "onDoubleClick", + oncontextmenu: "onContextMenu", + onmousemove: "onMouseMove", + onmouseover: "onMouseOver", + onmouseout: "onMouseOut", + onpointerdown: "onPointerDown", + onpointerup: "onPointerUp", + onpointermove: "onPointerMove", + onpointerenter: "onPointerEnter", + onpointerleave: "onPointerLeave", + onpointercancel: "onPointerCancel", + onpointerover: "onPointerOver", + onpointerout: "onPointerOut", + ongotpointercapture: "onGotPointerCapture", + onlostpointercapture: "onLostPointerCapture", + ontouchstart: "onTouchStart", + ontouchend: "onTouchEnd", + ontouchmove: "onTouchMove", + ontouchcancel: "onTouchCancel", + ondragstart: "onDragStart", + ondragend: "onDragEnd", + ondragenter: "onDragEnter", + ondragleave: "onDragLeave", + ondragover: "onDragOver", + onanimationstart: "onAnimationStart", + onanimationend: "onAnimationEnd", + onanimationiteration: "onAnimationIteration", + ontransitionend: "onTransitionEnd" + }; + var ATTRS = `(?:[^>"']|"[^"]*"|'[^']*')*`; + var IMPORT_SELF_CLOSE_RE = new RegExp( + "<(x-import|dc-import)(" + ATTRS + ")/>", + "gi" + ); + var CAMEL_ATTR_RE = /(\s)([a-z]+[A-Z][A-Za-z0-9]*)(\s*=)/g; + function encodeCamelAttrs(html) { + return html.replace( + CAMEL_ATTR_RE, + (_, sp, name, eq) => sp + CAMEL_ATTR + name.replace(/[A-Z]/g, (c) => "-" + c.toLowerCase()) + eq + ); + } + function encodeCase(html) { + html = html.replace( + IMPORT_SELF_CLOSE_RE, + (_, t, a) => "<" + t + a + ">" + ); + html = html.replace(/)/gi, "/gi, ""); + html = encodeCamelAttrs(html); + for (const [real, alias] of Object.entries(RAW_WRAP)) { + html = html.replace( + new RegExp("(])", "gi"), + "$1" + alias + ); + } + return html; + } + function kebabToCamel(s) { + return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase()); + } + function cssToObj(css) { + const o = {}; + for (const decl of css.split(";")) { + const i = decl.indexOf(":"); + if (i < 0) continue; + const prop = decl.slice(0, i).trim(); + o[prop.startsWith("--") ? prop : kebabToCamel(prop)] = decl.slice(i + 1).trim(); + } + return o; + } + function compileAttr(raw) { + const whole = raw.match(/^\s*\{\{([\s\S]+?)\}\}\s*$/); + if (whole) { + const path = whole[1]; + return (vals) => resolve(vals, path); + } + if (raw.includes("{{")) { + const parts = raw.split(/\{\{([\s\S]+?)\}\}/g); + return (vals) => parts.map((s, i) => i & 1 ? resolve(vals, s) ?? "" : s).join(""); + } + return () => raw; + } + + // src/compile.ts + function collectProps(node, kind, host) { + const propGetters = []; + const pseudoClasses = []; + let hintSize = null; + for (const { name, value } of [...node.attributes]) { + if (name === "sc-name" || name === "data-dc-tpl") continue; + let key = name; + if (key.startsWith(CAMEL_ATTR)) + key = kebabToCamel(key.slice(CAMEL_ATTR.length)); + if (key === "hint-size") { + hintSize = value; + continue; + } + if (key.startsWith("style-")) { + pseudoClasses.push(host.pseudoClass(key.slice(6), value)); + continue; + } + if (kind !== "dom") { + if (key.includes("-") && !(kind === "x-import" && (key.startsWith("aria-") || key.startsWith("data-")))) + key = kebabToCamel(key); + } else { + if (key === "class") key = "className"; + else if (key === "for") key = "htmlFor"; + else if (key.startsWith("on")) + key = EVENT_MAP[key] || "on" + key[2].toUpperCase() + key.slice(3); + } + propGetters.push([key, compileAttr(value)]); + } + return { propGetters, pseudoClasses, hintSize }; + } + var HOST_STYLE_PROPS = /* @__PURE__ */ new Set([ + "position", + "left", + "right", + "top", + "bottom", + "inset", + "width", + "height", + "z-index", + "transform" + ]); + function hostPositionStyle(style) { + const all = typeof style === "string" ? cssToObj(style) : style != null && typeof style === "object" ? style : null; + if (!all) return void 0; + const out = {}; + for (const [k, v] of Object.entries(all)) { + const kebab = k.replace(/[A-Z]/g, (c) => "-" + c.toLowerCase()); + if (HOST_STYLE_PROPS.has(kebab)) out[k] = v; + } + return Object.keys(out).length ? out : void 0; + } + function compileTemplate(html, host) { + const tpl = document.createElement("template"); + //! nosemgrep: direct-inner-html-assignment + tpl.innerHTML = encodeCase(html); + let tplN = 0; + (function stamp(node) { + if (node.nodeType === Node.ELEMENT_NODE) { + node.setAttribute("data-dc-tpl", String(tplN++)); + } + for (const c of node.childNodes) stamp(c); + })(tpl.content); + const builders = walkChildren(tpl.content, host); + const render = ((vals, ctx) => builders.map((b, i) => b(vals || {}, ctx, i))); + render.__annotated = tpl.innerHTML; + return render; + } + function walkChildren(node, host) { + return [...node.childNodes].map((c) => walk(c, host)).filter((b) => b != null); + } + var SLIDE_ID_VALUE_RE = /^[0-9a-f]{8}$/; + var DECK_CONTROL_FLOW_RE = /^(sc-if|sc-for|sc-else|dc-import|x-import)$/; + var DECK_AUX_RE = /^(template|script|style|sc-helmet|helmet)$/; + function isDeckMountTag(el) { + if (el.localName === "deck-stage") return true; + return el.localName === "x-import" && (el.getAttribute("component-from-global-scope") || "") === "deck-stage"; + } + function walkDeckChildren(el, host) { + const pairs = [...el.childNodes].map((c) => ({ c, b: walk(c, host) })).filter((p) => p.b !== null); + const kids = pairs.map((p) => p.b); + const seen = /* @__PURE__ */ new Set(); + const wsSeen = /* @__PURE__ */ new Map(); + const keys = []; + const nextSlideId = new Array(pairs.length); + { + let upcoming = null; + for (let j = pairs.length - 1; j >= 0; j--) { + const n = pairs[j].c; + if (n.nodeType === Node.ELEMENT_NODE) { + const t = n.localName; + upcoming = !DECK_AUX_RE.test(t) && !DECK_CONTROL_FLOW_RE.test(t) ? n.getAttribute("data-om-slide-id") : null; + } + nextSlideId[j] = upcoming; + } + } + for (let j = 0; j < pairs.length; j++) { + const { c } = pairs[j]; + if (c.nodeType === Node.TEXT_NODE) { + if ((c.nodeValue ?? "").trim() === "") { + const base = nextSlideId[j] ? "omid-ws:" + nextSlideId[j] : "omid-ws:aux"; + const n = wsSeen.get(base) ?? 0; + wsSeen.set(base, n + 1); + keys.push(n === 0 ? base : base + ":" + n); + continue; + } + return { kids, keys: null }; + } + if (c.nodeType !== Node.ELEMENT_NODE) { + keys.push(j); + continue; + } + const child = c; + const tag = child.localName; + if (DECK_AUX_RE.test(tag)) { + keys.push(j); + continue; + } + if (DECK_CONTROL_FLOW_RE.test(tag)) return { kids, keys: null }; + const v = child.getAttribute("data-om-slide-id"); + if (!v || !SLIDE_ID_VALUE_RE.test(v) || seen.has(v)) { + return { kids, keys: null }; + } + seen.add(v); + keys.push("omid:" + v); + } + return { kids, keys }; + } + function renderDeckKids(kids, kidKeys, vals, ctx) { + return kids.map((b, j) => { + const k = kidKeys ? kidKeys[j] : j; + const out = b(vals, ctx, k); + return kidKeys != null && typeof out === "string" ? h(getReact().Fragment, { key: k }, out) : out; + }); + } + function walk(node, host) { + if (node.nodeType === Node.TEXT_NODE) return walkText(node); + if (node.nodeType !== Node.ELEMENT_NODE) return null; + const el = node; + const tag = el.tagName.toLowerCase(); + if (tag === "sc-for") return walkFor(el, host); + if (tag === "sc-if") return walkIf(el, host); + if (tag === "x-import") return walkXImport(el, host); + if (tag === "sc-helmet") return host.helmet(el); + if (tag === "dc-import") return walkComponent(el, host); + return walkElement(el, host); + } + var warnedHoles = /* @__PURE__ */ new Set(); + function warnUnresolved(ctx, what) { + const key = (ctx?.__name || "?") + "\0" + what; + if (warnedHoles.has(key)) return; + warnedHoles.add(key); + console.warn("[dc-runtime] " + (ctx?.__name || "template") + ": " + what); + } + function walkText(node) { + const txt = node.nodeValue ?? ""; + if (!txt.includes("{{")) { + if (!txt.trim() && !txt.includes(" ")) return null; + return () => txt; + } + const parts = txt.split(/\{\{([\s\S]+?)\}\}/g); + return (vals, ctx, key) => h( + getReact().Fragment, + { key }, + ...parts.map((p, i) => { + if (!(i & 1)) return p; + const v = resolve(vals, p); + if (v === void 0) { + if (!ctx?.__streamingNow) { + if (document.body?.hasAttribute("data-dc-editor-on")) { + return h( + "span", + { key: i, className: "sc-interp sc-unresolved" }, + "{{ " + p.trim() + " }}" + ); + } + warnUnresolved( + ctx, + "{{ " + p.trim() + " }} never resolved \u2014 rendered as empty" + ); + return null; + } + return h( + "span", + { key: i, className: "sc-interp sc-missing" }, + p.trim() + ); + } + if (getReact().isValidElement(v) || Array.isArray(v)) { + return h(getReact().Fragment, { key: i }, v); + } + if (v === null || typeof v === "boolean") return null; + return h("span", { key: i, className: "sc-interp" }, String(v)); + }) + ); + } + function walkFor(el, host) { + const listGet = compileAttr(el.getAttribute("list") || ""); + const asName = el.getAttribute("as") || "item"; + const hintN = parseInt(el.getAttribute("hint-placeholder-count") || "0", 10); + const kids = walkChildren(el, host); + const listSrc = el.getAttribute("list") || ""; + return (vals, ctx, key) => { + let list = listGet(vals); + if (!Array.isArray(list)) { + if (!ctx?.__streamingNow) { + if (list !== void 0 && list !== null) { + warnUnresolved( + ctx, + 'sc-for list="' + listSrc + '" is not an array (' + typeof list + ")" + ); + } + list = []; + } else { + list = hintN > 0 ? Array(hintN).fill(void 0) : []; + } + } + return h( + getReact().Fragment, + { key }, + list.map((item, i) => { + const sub = { ...vals, [asName]: item, $index: i }; + return h( + getReact().Fragment, + { key: i }, + kids.map((b, j) => b(sub, ctx, j)) + ); + }) + ); + }; + } + function walkIf(el, host) { + const valGet = compileAttr(el.getAttribute("value") || ""); + const hintRaw = el.getAttribute("hint-placeholder-val"); + const hintGet = hintRaw != null ? compileAttr(hintRaw) : null; + const kids = walkChildren(el, host); + return (vals, ctx, key) => { + let v = valGet(vals); + if (v === void 0 && hintGet && ctx?.__streamingNow) v = hintGet(vals); + return v ? h( + getReact().Fragment, + { key }, + kids.map((b, j) => b(vals, ctx, j)) + ) : null; + }; + } + function walkComponent(el, host) { + const name = el.getAttribute("name") || el.getAttribute("component") || ""; + el.removeAttribute("name"); + el.removeAttribute("component"); + const tplId = el.getAttribute("data-dc-tpl"); + const styleRaw = el.getAttribute("style"); + el.removeAttribute("style"); + const styleGet = styleRaw != null ? compileAttr(styleRaw) : null; + const { propGetters, hintSize } = collectProps(el, "dc-import", host); + const kids = walkChildren(el, host); + return (vals, ctx, key) => { + const props = { + key, + __hintSize: hintSize, + __tplId: tplId, + __hostStyle: styleGet ? hostPositionStyle(styleGet(vals)) : void 0 + }; + for (const [k, g] of propGetters) { + const v = g(vals); + if (k === "dcProps") { + if (v && typeof v === "object") Object.assign(props, v); + continue; + } + props[k] = v; + } + if (kids.length) props.children = kids.map((b, j) => b(vals, ctx, j)); + return h(host.component(name), props); + }; + } + function walkXImport(el, host) { + const globalNameGet = compileAttr( + el.getAttribute("component-from-global-scope") || "" + ); + const exportNameGet = compileAttr( + el.getAttribute("component") || el.getAttribute("name") || "" + ); + const fromRaw = el.getAttribute("from") || (el.getAttribute("component-from-global-scope") ? "" : el.getAttribute("src") || el.getAttribute("import") || ""); + const urls = fromRaw.trim() ? fromRaw.trim().split(/\s+/) : []; + const url = urls.length ? urls[urls.length - 1] : ""; + const kindOf = (u) => /\.(jsx|tsx)(\?|#|$)/i.test(u) ? "jsx" : "js"; + const tplId = el.getAttribute("data-dc-tpl"); + const styleRaw = el.getAttribute("style"); + el.removeAttribute("style"); + const styleGet = styleRaw != null ? compileAttr(styleRaw) : null; + const wrap = tplId != null || styleGet != null; + const { propGetters, hintSize } = collectProps(el, "x-import", host); + const hasContent = el.children.length > 0 || !!(el.textContent || "").trim(); + const deckKeyed = hasContent && isDeckMountTag(el) ? walkDeckChildren(el, host) : null; + const kids = deckKeyed ? deckKeyed.kids : hasContent ? walkChildren(el, host) : []; + const kidKeys = deckKeyed?.keys ?? null; + const urlBindable = fromRaw.includes("{{"); + if (urls.length && !urlBindable) { + let prev; + for (const u of urls) prev = host.loadExternal(kindOf(u), u, prev); + } + const evalName = (g, vals) => { + const v = g(vals); + const s = v == null ? "" : String(v); + return s.includes("{{") ? "" : s; + }; + return (vals, ctx, key) => { + const globalName = evalName(globalNameGet, vals); + const name = globalName || evalName(exportNameGet, vals); + const C = !name || urlBindable ? null : globalName ? host.resolveExternalGlobal(url, globalName) : host.resolveExternal(url, name); + const hostStyle = styleGet ? hostPositionStyle(styleGet(vals)) : void 0; + const wrapper = wrap ? { + key, + className: "sc-host-x", + "data-dc-tpl": tplId, + style: hostStyle || { display: "contents" } + } : null; + if (!C) { + const error = urlBindable ? "x-import `from` cannot contain {{ \u2026 }} \u2014 module URLs are resolved at parse time; use a literal URL" : host.resolveExternalError(url, name); + const ph = host.placeholder({ + key: wrapper ? void 0 : key, + name, + hintSize, + error + }); + return wrapper ? h("div", wrapper, ph) : ph; + } + const props = wrapper ? {} : { key }; + let unresolvedHole = false; + for (const [k, g] of propGetters) { + if (k === "component" || k === "componentFromGlobalScope" || k === "from") { + continue; + } + const v = g(vals); + if (v === void 0) unresolvedHole = true; + if (k === "dcProps") { + if (v && typeof v === "object") Object.assign(props, v); + continue; + } + props[k] = v; + } + if (unresolvedHole && ctx?.__htmlStreamingNow) { + const ph = host.placeholder({ + key: wrapper ? void 0 : key, + name, + hintSize, + error: null + }); + return wrapper ? h("div", wrapper, ph) : ph; + } + if (kids.length) { + props.children = renderDeckKids(kids, kidKeys, vals, ctx); + } + return wrapper ? h("div", wrapper, h(C, props)) : h(C, props); + }; + } + function contentKey(el) { + const clone = el.cloneNode(true); + for (const d of clone.querySelectorAll("*")) { + while (d.attributes.length) d.removeAttribute(d.attributes[0].name); + } + const s = clone.innerHTML; + let h2 = 5381; + for (let i = 0; i < s.length; i++) h2 = (h2 << 5) + h2 + s.charCodeAt(i) | 0; + return s.length + "." + (h2 >>> 0).toString(36); + } + var NEVER_CONTENT_KEYED = new Set( + "script style textarea option title select canvas iframe video audio".split( + " " + ) + ); + var NOT_INLINE_SELECTOR = ":not(" + [...INLINE_TEXT_TAGS].join(",") + ")"; + function walkElement(el, host) { + const realTag = RAW_UNWRAP[el.localName] || el.localName; + const tplId = el.getAttribute("data-dc-tpl"); + const inlineOnly = el.childNodes.length > 0 && !NEVER_CONTENT_KEYED.has(realTag) && el.querySelector(NOT_INLINE_SELECTOR) === null; + const keySuffix = inlineOnly ? "|" + contentKey(el) : ""; + const { propGetters, pseudoClasses } = collectProps(el, "dom", host); + const deckKeyed = isDeckMountTag(el) ? walkDeckChildren(el, host) : null; + const kids = deckKeyed ? deckKeyed.kids : walkChildren(el, host); + const kidKeys = deckKeyed?.keys ?? null; + return (vals, ctx, key) => { + const props = { + key: key + keySuffix, + "data-dc-tpl": tplId + }; + for (const [k, g] of propGetters) { + let v = g(vals); + if (k === "style" && typeof v === "string") v = cssToObj(v); + if ((k === "value" || k === "checked") && v === void 0) { + v = k === "checked" ? false : ""; + } + props[k] = v; + } + if (pseudoClasses.length) { + props.className = [props.className, ...pseudoClasses].filter(Boolean).join(" "); + } + return h(realTag, props, ...renderDeckKids(kids, kidKeys, vals, ctx)); + }; + } + + // src/logic.ts + var StreamableLogic = class { + constructor(props) { + __publicField(this, "props"); + __publicField(this, "state", {}); + /** Back-pointer to the wrapper component, installed after construction. */ + __publicField(this, "__host"); + this.props = props || {}; + } + setState(update, cb) { + this.__host && this.__host.__setLogicState(update, cb); + } + forceUpdate() { + this.__host && this.__host.forceUpdate(); + } + componentDidMount() { + } + componentDidUpdate(_prevProps) { + } + componentWillUnmount() { + } + /** The flat object the template renders against (merged over props). */ + renderVals() { + return {}; + } + }; + function evalDcLogic(src) { + //! nosemgrep: eval-and-function-constructor + const fn = new Function( + "DCLogic", + "StreamableLogic", + "React", + src + '\n;return (typeof Component!=="undefined"&&Component)||undefined;' + ); + return fn(StreamableLogic, StreamableLogic, getReact()); + } + + // src/component.ts + function shallowEqual(a, b) { + if (!b) return false; + const ak = Object.keys(a).filter((k) => k !== "children"); + const bk = Object.keys(b).filter((k) => k !== "children"); + if (ak.length !== bk.length) return false; + for (const k of ak) if (a[k] !== b[k]) return false; + return true; + } + function Placeholder({ + name, + hintSize, + streaming, + error + }) { + const [w, hgt] = (hintSize || "100%,60px").split(","); + return h( + "div", + { + className: "sc-placeholder" + (streaming ? " sc-streaming" : ""), + style: { width: w.trim(), height: hgt && hgt.trim() }, + title: name + }, + error ? h( + "div", + { className: "sc-placeholder-error" }, + (name ? name + ": " : "") + error + ) : null + ); + } + function hintToMin(hint) { + if (!hint) return void 0; + const [w, hgt] = hint.split(","); + return { minWidth: w.trim(), minHeight: hgt && hgt.trim() }; + } + function createComponentFactory(registry, ensureFetched) { + const React = getReact(); + const AncestorContext = React.createContext([]); + class StreamableComponent extends React.Component { + constructor(props) { + super(props); + __publicField(this, "__name"); + __publicField(this, "__sub"); + __publicField(this, "__needsDidMount", false); + /** Snapshot of the registry's streaming flags taken at render time — + * builders read it off the RenderCtx (this) to pick placeholder vs + * render-nothing for unresolved values. */ + __publicField(this, "__streamingNow", false); + __publicField(this, "__htmlStreamingNow", false); + /** When a construct throws, remember the (class, registry.ver, props) + * triple so render-time reconcile doesn't re-attempt it on every parent + * re-render. A registry bump (new class, template, external module + * resolving via bumpAll) changes `ver` and breaks the memo so an + * env-dependent constructor can self-heal. */ + __publicField(this, "__failedLogic", null); + __publicField(this, "__failedUserProps", null); + __publicField(this, "__failedVer", -1); + /** Per-instance constructor error — kept here (not on the registry entry) + * so one instance's successful construct can't hide a sibling's failure, + * and a construct can never wipe an eval error `updateJs` recorded on + * `r.logicError`. */ + __publicField(this, "__ctorError", null); + __publicField(this, "logic"); + this.__name = props.__name; + this.state = { __v: 0, __err: null }; + this.__sub = () => { + if (this.state.__err) this.setState({ __err: null }); + this.forceUpdate(); + }; + this.__makeLogic(registry.get(this.__name).Logic, null); + ensureFetched(this.__name); + } + /** Error-boundary hook: a render crash anywhere in this DC's subtree + * (its own template, an x-import'd component, a child DC without its + * own deeper boundary) lands here instead of unmounting the page. */ + static getDerivedStateFromError(e) { + return { __err: e instanceof Error && e.message ? e.message : String(e) }; + } + componentDidCatch(e, info) { + console.error( + "[dc-runtime] render error in <" + this.__name + ">:", + e, + info?.componentStack || "" + ); + } + /** Instantiate the logic class (or the no-op base) and adopt `prevState` + * over its initial state — used both at mount and on hot-swap. */ + __makeLogic(Logic, prevState) { + const L = Logic || StreamableLogic; + try { + this.logic = new L(this.__userProps()); + this.__failedLogic = null; + this.__failedUserProps = null; + this.__ctorError = null; + } catch (e) { + console.error(e); + this.__failedLogic = Logic; + this.__failedUserProps = this.__userProps(); + this.__failedVer = registry.get(this.__name).ver; + this.__ctorError = this.__name + ": " + (e instanceof Error && e.message ? e.message : String(e)); + this.logic = new StreamableLogic( + this.__userProps() + ); + } + this.logic.__host = this; + if (prevState) + this.logic.state = { ...this.logic.state || {}, ...prevState }; + } + /** The props the author's logic + template see — internal __-prefixed + * wiring stripped. */ + __userProps() { + const { __name, __hintSize, __tplId, __hostStyle, ...rest } = this.props; + return rest; + } + __setLogicState(update, cb) { + const prev = this.logic.state; + const patch = typeof update === "function" ? update(prev) : update; + this.logic.state = { ...prev, ...patch }; + this.setState((s) => ({ __v: s.__v + 1 }), cb); + } + /** Swap the logic instance when the registry's Logic class changed + * (streaming completion, hot reload). State carries over; didMount + * re-fires after the swap commits so refs exist. */ + __reconcileLogic() { + const r = registry.get(this.__name); + const Next = r.Logic; + const Cur = this.logic.constructor; + if (Next === Cur || !Next && Cur === StreamableLogic || Next === this.__failedLogic && r.ver === this.__failedVer && shallowEqual(this.__userProps(), this.__failedUserProps)) { + return; + } + if (!this.__needsDidMount) { + try { + this.logic.componentWillUnmount(); + } catch (e) { + console.error(e); + } + } + this.__makeLogic(Next, this.logic.state); + this.__needsDidMount = true; + } + componentDidMount() { + registry.get(this.__name).subs.add(this.__sub); + try { + this.logic.componentDidMount(); + } catch (e) { + console.error(e); + } + } + componentDidUpdate(prevProps) { + this.logic.props = this.__userProps(); + if (this.__needsDidMount) { + if (this.state.__err || !registry.get(this.__name).tpl) return; + this.__needsDidMount = false; + try { + this.logic.componentDidMount(); + } catch (e) { + console.error(e); + } + } else { + try { + this.logic.componentDidUpdate(prevProps); + } catch (e) { + console.error(e); + } + } + } + componentWillUnmount() { + registry.get(this.__name).subs.delete(this.__sub); + if (!this.__needsDidMount) { + try { + this.logic.componentWillUnmount(); + } catch (e) { + console.error(e); + } + } + } + render() { + const r = registry.get(this.__name); + const cls = "sc-host" + (r.htmlStreaming ? " sc-streaming-html" : "") + (r.jsStreaming ? " sc-streaming-js" : ""); + const hintStyle = r.htmlStreaming ? hintToMin(this.props.__hintSize) : void 0; + const hostStyle = this.props.__hostStyle || hintStyle ? { ...hintStyle || {}, ...this.props.__hostStyle || {} } : void 0; + const hostBase = { + className: cls, + style: hostStyle, + "data-sc-name": this.__name, + "data-dc-tpl": this.props.__tplId + }; + const chain = Array.isArray(this.context) ? this.context : []; + if (chain.includes(this.__name)) { + const cycle = [ + ...chain.slice(chain.indexOf(this.__name)), + this.__name + ].join(" \u2192 "); + return h( + "div", + { ...hostBase, className: cls + " sc-has-error" }, + h(Placeholder, { + name: this.__name, + hintSize: this.props.__hintSize, + error: "circular import: " + cycle + }) + ); + } + if (this.state.__err) { + return h( + "div", + { ...hostBase, className: cls + " sc-has-error" }, + h( + "div", + { className: "sc-logic-error", "data-omelette-chrome": "" }, + this.__name + ": " + this.state.__err + ), + h(Placeholder, { + name: this.__name, + hintSize: this.props.__hintSize, + error: this.state.__err + }) + ); + } + this.__reconcileLogic(); + if (!r.tpl) { + return h( + "div", + hostBase, + h(Placeholder, { name: this.__name, hintSize: this.props.__hintSize }) + ); + } + const userProps = this.__userProps(); + this.logic.props = userProps; + let vals = userProps; + let renderErr = r.logicError || this.__ctorError; + try { + vals = { ...userProps, ...this.logic.renderVals() || {} }; + } catch (e) { + console.error(e); + renderErr = this.__name + ".renderVals(): " + (e instanceof Error && e.message ? e.message : String(e)); + } + this.__streamingNow = !!(r.htmlStreaming || r.jsStreaming); + this.__htmlStreamingNow = !!r.htmlStreaming; + return h( + "div", + { ...hostBase, className: cls + (renderErr ? " sc-has-error" : "") }, + renderErr && h( + "div", + { className: "sc-logic-error", "data-omelette-chrome": "" }, + renderErr + ), + h( + AncestorContext.Provider, + { value: [...chain, this.__name] }, + r.tpl(vals, this) + ) + ); + } + } + __publicField(StreamableComponent, "contextType", AncestorContext); + const named = /* @__PURE__ */ new Map(); + function getDC(name) { + const hit = named.get(name); + if (hit) return hit; + function Dispatcher(p) { + const [, setTick] = React.useState(0); + React.useEffect(() => { + const sub = () => setTick((n) => n + 1); + registry.get(name).subs.add(sub); + return () => { + registry.get(name).subs.delete(sub); + }; + }, []); + ensureFetched(name); + return h(StreamableComponent, { ...p, __name: name }); + } + Dispatcher.displayName = name; + named.set(name, Dispatcher); + return Dispatcher; + } + return { + getDC, + StreamableComponent + }; + } + + // src/bundled.ts + function bundledBlob(url) { + const blobs = window.__resourceBlobs; + const b = blobs ? blobs[url.split("#")[0]] : void 0; + return b instanceof Blob ? b : null; + } + + // src/cdn.ts + var REACT_URL = "https://unpkg.com/react@18.3.1/umd/react.production.min.js"; + var REACT_SRI = "sha384-DGyLxAyjq0f9SPpVevD6IgztCFlnMF6oW/XQGmfe+IsZ8TqEiDrcHkMLKI6fiB/Z"; + var REACT_DOM_URL = "https://unpkg.com/react-dom@18.3.1/umd/react-dom.production.min.js"; + var REACT_DOM_SRI = "sha384-gTGxhz21lVGYNMcdJOyq01Edg0jhn/c22nsx0kyqP0TxaV5WVdsSH1fSDUf5YJj1"; + var BABEL_URL = "https://unpkg.com/@babel/standalone@7.29.0/babel.min.js"; + var BABEL_SRI = "sha384-m08KidiNqLdpJqLq95G/LEi8Qvjl/xUYll3QILypMoQ65QorJ9Lvtp2RXYGBFj1y"; + function cdnScriptFor(url, sri) { + const res = window.__resources; + const v = res ? res[url] : void 0; + return typeof v === "string" && v ? { src: v } : { src: url, integrity: sri }; + } + + // src/external.ts + var isCustomElementName = (n) => !n.includes(".") && n.includes("-"); + function isRenderableType(g) { + if (typeof g === "function") return !isElementClass(g); + return typeof g === "object" && g !== null && typeof g.$$typeof === "symbol"; + } + function resolveDottedPath(root, name) { + let cur = root; + for (const seg of name.split(".")) { + if (cur == null) return void 0; + cur = cur[seg]; + } + return cur; + } + var GLOBAL_POLL_INTERVAL_MS = 50; + var GLOBAL_POLL_TIMEOUT_MS = 3e4; + function createExternalModules(onResolved) { + const cache = /* @__PURE__ */ new Map(); + let babelLoading = null; + const reportedMissing = /* @__PURE__ */ new Map(); + const polling = /* @__PURE__ */ new Set(); + function ensureBabel() { + if (window.Babel) return Promise.resolve(); + if (babelLoading) return babelLoading; + const babel = cdnScriptFor(BABEL_URL, BABEL_SRI); + babelLoading = new Promise((res, rej) => { + const s = document.createElement("script"); + s.src = babel.src; + if (babel.integrity) { + s.integrity = babel.integrity; + s.crossOrigin = "anonymous"; + } + s.onload = () => res(); + s.onerror = rej; + document.head.appendChild(s); + }); + return babelLoading; + } + const pending = /* @__PURE__ */ new Map(); + function load(kind, url, after) { + const existing = pending.get(url); + if (existing) return existing; + cache.set(url, null); + console.info("[dc-runtime] x-import: loading", url, "(" + kind + ")"); + const ready = Promise.all([ + kind === "jsx" ? ensureBabel() : Promise.resolve(), + after ?? Promise.resolve() + ]); + const p = ready.then(() => { + const pre = bundledBlob(url); + if (pre) return pre.text(); + return fetch(url).then((r) => { + if (!r.ok) throw new Error("HTTP " + r.status); + return r.text(); + }); + }).then((src) => { + const code = kind === "jsx" ? window.Babel.transform(src, { + filename: url, + presets: ["react", "typescript"] + }).code : src; + const module = { exports: {} }; + const before = new Set(Object.keys(window)); + //! nosemgrep: eval-and-function-constructor + new Function("React", "module", "exports", "require", code)( + getReact(), + module, + module.exports, + () => ({}) + ); + const globals = {}; + for (const k of Object.keys(window)) { + if (!before.has(k) && typeof window[k] === "function") { + globals[k] = window[k]; + } + } + cache.set(url, { mod: module.exports, globals }); + console.info( + "[dc-runtime] x-import: loaded", + url, + "\u2014 exports:", + Object.keys(module.exports), + "window globals:", + Object.keys(globals) + ); + onResolved(); + }).catch((e) => { + cache.set(url, { + mod: {}, + globals: {}, + error: "failed to load: " + (e instanceof Error && e.message ? e.message : String(e)) + }); + console.error( + "[dc-runtime] x-import: FAILED to load", + url, + "(" + kind + ")", + e + ); + onResolved(); + }); + pending.set(url, p); + return p; + } + function resolve2(url, name) { + const entry = cache.get(url); + if (!entry) return null; + const { mod, globals } = entry; + const C = mod && mod[name] || globals && globals[name] || typeof window !== "undefined" && window[name] || mod && mod.default; + if (typeof C === "function") return C; + const key = url + "\0" + name; + if (!reportedMissing.has(key)) { + reportedMissing.set( + key, + entry.error || 'no export named "' + name + '" (has: ' + Object.keys(mod).join(", ") + ")" + ); + console.error( + "[dc-runtime] x-import: module", + url, + "loaded but has no component named", + JSON.stringify(name), + "\u2014 available exports:", + Object.keys(mod), + "window globals:", + Object.keys(globals), + ". The module must `module.exports = {" + name + "}` or set `window." + name + "`." + ); + } + return null; + } + function waitForGlobal(name) { + if (polling.has(name)) return; + polling.add(name); + const started = Date.now(); + const isCE = isCustomElementName(name); + const tick = () => { + const found = isCE ? customElements.get(name) : isRenderableType(resolveDottedPath(window, name)); + if (found) { + polling.delete(name); + onResolved(); + return; + } + if (Date.now() - started >= GLOBAL_POLL_TIMEOUT_MS) { + console.warn( + "[dc-runtime] x-import: global", + JSON.stringify(name), + "never appeared on window after " + GLOBAL_POLL_TIMEOUT_MS + "ms" + ); + return; + } + setTimeout(tick, GLOBAL_POLL_INTERVAL_MS); + }; + setTimeout(tick, GLOBAL_POLL_INTERVAL_MS); + } + function resolveGlobal(url, name) { + const isCE = isCustomElementName(name); + if (!url) { + if (isCE) { + if (customElements.get(name)) return name; + waitForGlobal(name); + return null; + } + const g2 = resolveDottedPath(window, name); + if (isRenderableType(g2)) return g2; + waitForGlobal(name); + return null; + } + const entry = cache.get(url); + if (!entry) return null; + if (isCE && customElements.get(name)) return name; + const g = entry.globals[name] ?? resolveDottedPath(window, name); + if (isRenderableType(g)) return g; + if (name.includes(".")) return null; + const key = url + "\0global\0" + name; + if (!reportedMissing.has(key)) { + reportedMissing.set(key, null); + if (isCE && !customElements.get(name)) { + console.warn( + "[dc-runtime] x-import:", + url, + "loaded but no custom element", + JSON.stringify(name), + "is registered and window." + name + " is not a function \u2014 rendering <" + name + "> as an unknown element." + ); + } + } + return name; + } + function getError(url, name) { + const entry = cache.get(url); + if (entry?.error) return entry.error; + return reportedMissing.get(url + "\0" + name) || null; + } + return { load, resolve: resolve2, resolveGlobal, getError }; + } + function isElementClass(g) { + try { + return typeof g === "function" && typeof HTMLElement !== "undefined" && g.prototype instanceof HTMLElement; + } catch { + return false; + } + } + + // src/atomics.ts + var ATOMIC_CSS = ( + // layout + ".fx{display:flex}.col{display:flex;flex-direction:column}.grid{display:grid}.ac{align-items:center}.jc{justify-content:center}.jb{justify-content:space-between}.f1{flex:1}.noshrink{flex-shrink:0}.wrap{flex-wrap:wrap}.fw5{font-weight:500}.fw6{font-weight:600}.fw7{font-weight:700}.fw8{font-weight:800}.fs11{font-size:11px}.fs12{font-size:12px}.fs13{font-size:13px}.fs14{font-size:14px}.fs15{font-size:15px}.fs16{font-size:16px}.fs20{font-size:20px}.fs22{font-size:22px}.upper{text-transform:uppercase}.tc{text-align:center}.nowrap{white-space:nowrap}.gap8{gap:8px}.gap10{gap:10px}.gap12{gap:12px}.gap16{gap:16px}.gap24{gap:24px}.m0{margin:0}.mt8{margin-top:8px}.mt12{margin-top:12px}.mt16{margin-top:16px}.mb8{margin-bottom:8px}.mb12{margin-bottom:12px}.mb16{margin-bottom:16px}.posrel{position:relative}.posabs{position:absolute}.round{border-radius:50%}.ohide{overflow:hidden}.bbox{box-sizing:border-box}.pointer{cursor:pointer}.w100{width:100%}.b0{border:none}" + ); + + // src/helmet.ts + var DESIGN_DOC_MODE_RE = /]*\bname\s*=\s*["']design_doc_mode["'][^>]*\b(?:content|value)\s*=\s*["'](\w+)["']/i; + var CANVAS_BG_LIGHT = "#f0eee6"; + var CANVAS_BG_DARK = "#2e2c26"; + function createHelmetManager(doc, isStreaming) { + const mounted = /* @__PURE__ */ new Set(); + const live = /* @__PURE__ */ new Map(); + let designDocMode = null; + let canvasStyleEl = null; + let appTheme = "light"; + try { + const ds = doc.documentElement.dataset.theme; + appTheme = ds === "dark" || ds === "light" ? ds : new URLSearchParams(doc.defaultView?.location.search ?? "").get( + "theme" + ) === "dark" ? "dark" : "light"; + } catch { + } + function applyCanvasBg() { + if (!canvasStyleEl) return; + const bg = appTheme === "dark" ? CANVAS_BG_DARK : CANVAS_BG_LIGHT; + canvasStyleEl.textContent = `html,body{background:${bg}}#dc-root>.sc-host{position:relative}`; + } + function postDesignMode(mode) { + if (window.parent === window) return; + try { + window.parent.postMessage({ type: "__dc_design_mode", mode }, "*"); + } catch { + } + } + function setDesignDocMode(mode) { + if (mode === designDocMode) return; + designDocMode = mode; + postDesignMode(mode); + if (mode === "canvas") { + doc.documentElement.setAttribute("data-dc-canvas", ""); + canvasStyleEl = doc.createElement("style"); + canvasStyleEl.setAttribute("data-dc-canvas", ""); + applyCanvasBg(); + doc.head.appendChild(canvasStyleEl); + } else { + doc.documentElement.removeAttribute("data-dc-canvas"); + canvasStyleEl?.remove(); + canvasStyleEl = null; + } + } + window.addEventListener("message", (e) => { + const type = e.data && e.data.type; + if (type === "__dc_theme") { + const t = e.data.theme; + if (t === "light" || t === "dark") { + appTheme = t; + applyCanvasBg(); + } + return; + } + if (!designDocMode || type !== "__dc_probe") return; + postDesignMode(designDocMode); + }); + function compile(node) { + const raw = [...node.children]; + const helmetClosed = node.nextSibling != null || node.parentNode?.nextSibling != null; + if (node.hasAttribute("data-dc-atomics") && !mounted.has("__dc-atomics")) { + mounted.add("__dc-atomics"); + const el = doc.createElement("style"); + el.id = "__dc-atomics"; + el.textContent = ATOMIC_CSS; + doc.head.appendChild(el); + } + return (_vals, ctx) => { + const name = ctx && ctx.__name || ""; + const streaming = !!(name && isStreaming(name)); + for (let i = 0; i < raw.length; i++) { + const child = raw[i]; + const tag = child.tagName; + const mayBePartial = streaming && !helmetClosed && i === raw.length - 1; + if (tag === "SCRIPT") { + if (mayBePartial) continue; + const key = "SCRIPT|" + (child.getAttribute("src") || child.textContent || ""); + if (mounted.has(key)) continue; + mounted.add(key); + const el = doc.createElement("script"); + for (const { name: an, value } of [...child.attributes]) + el.setAttribute(an, value); + if (child.textContent) el.textContent = child.textContent; + doc.head.appendChild(el); + } else if (tag === "LINK" || tag === "META") { + if (mayBePartial) continue; + const key = tag + "|" + (child.getAttribute("href") || child.getAttribute("src") || child.outerHTML); + if (mounted.has(key)) continue; + mounted.add(key); + if (tag === "LINK") { + const rel = (child.getAttribute("rel") || "").toLowerCase().split(/\s+/); + const href = (child.getAttribute("href") || "").trim(); + const res = window.__resources; + const pre = res && rel.includes("stylesheet") && !rel.includes("alternate") ? res[href] : void 0; + const blob = typeof pre === "string" && pre ? bundledBlob(pre) : null; + if (blob) { + const el = doc.createElement("style"); + if (child.hasAttribute("disabled")) { + el.setAttribute("media", "not all"); + } else if (child.getAttribute("media")) { + el.setAttribute("media", child.getAttribute("media")); + } + if (child.getAttribute("title")) + el.setAttribute("title", child.getAttribute("title")); + void blob.text().then((css) => { + el.textContent = css; + }); + doc.head.appendChild(el); + continue; + } + } + doc.head.appendChild(child.cloneNode(true)); + } else { + const key = name + "|" + i; + let el = live.get(key); + if (!el || el.tagName !== tag) { + if (el) el.remove(); + el = doc.createElement(tag.toLowerCase()); + live.set(key, el); + doc.head.appendChild(el); + } + for (const { name: an, value } of [...child.attributes]) { + if (el.getAttribute(an) !== value) el.setAttribute(an, value); + } + if (el.textContent !== child.textContent) + el.textContent = child.textContent; + } + } + return null; + }; + } + return { compile, setDesignDocMode }; + } + + // src/pseudo.ts + function scanUnquotedUrl(css, i) { + if (css[i] !== "u" && css[i] !== "U" || css.slice(i, i + 4).toLowerCase() !== "url(" || /[a-z0-9_-]/i.test(css[i - 1] ?? "")) { + return -1; + } + let j = i + 4; + while (j < css.length && /\s/.test(css[j])) j++; + if (css[j] === '"' || css[j] === "'") return -1; + while (j < css.length && css[j] !== ")") { + if (css[j] === "\\") j++; + j++; + } + return j < css.length ? j + 1 : css.length; + } + function stripComments(css) { + let out = ""; + let quote = ""; + for (let i = 0; i < css.length; i++) { + const c = css[i]; + if (quote) { + if (c === "\\") { + out += c + (css[i + 1] ?? ""); + i++; + continue; + } + if (c === quote) quote = ""; + out += c; + } else if (c === "'" || c === '"') { + quote = c; + out += c; + } else if (c === "/" && css[i + 1] === "*") { + const end = css.indexOf("*/", i + 2); + i = end === -1 ? css.length : end + 1; + out += " "; + } else { + const end = scanUnquotedUrl(css, i); + if (end === -1) out += c; + else { + out += css.slice(i, end); + i = end - 1; + } + } + } + return out; + } + function importantify(css) { + css = stripComments(css); + const decls = []; + let start = 0; + let depth = 0; + let quote = ""; + for (let i = 0; i < css.length; i++) { + const c = css[i]; + if (quote) { + if (c === "\\") i++; + else if (c === quote) quote = ""; + } else if (c === "'" || c === '"') quote = c; + else if (c === "(") depth++; + else if (c === ")") depth = Math.max(0, depth - 1); + else if (c === ";" && depth === 0) { + decls.push(css.slice(start, i)); + start = i + 1; + } else { + const end = scanUnquotedUrl(css, i); + if (end !== -1) i = end - 1; + } + } + decls.push(css.slice(start)); + return decls.map((d) => d.trim()).filter(Boolean).map((d) => /!\s*important$/i.test(d) ? d : d + " !important").join(";"); + } + function createPseudoSheet(doc) { + let el = null; + const cache = /* @__PURE__ */ new Map(); + let n = 0; + return (pseudo, css) => { + const k = pseudo + "|" + css; + const hit = cache.get(k); + if (hit) return hit; + if (!el) { + el = doc.createElement("style"); + doc.head.appendChild(el); + } + const cls = "scp" + (n++).toString(36); + const isPseudoElement = pseudo === "before" || pseudo === "after"; + const sel = isPseudoElement ? "." + cls + "::" + pseudo : "." + cls + ":" + pseudo; + el.sheet.insertRule( + sel + "{" + (isPseudoElement ? css : importantify(css)) + "}", + el.sheet.cssRules.length + ); + cache.set(k, cls); + return cls; + }; + } + + // src/registry.ts + function createRegistry() { + const entries = /* @__PURE__ */ Object.create(null); + function get(name) { + return entries[name] || (entries[name] = { + html: "", + tpl: null, + Logic: null, + jsStreaming: false, + htmlStreaming: false, + ver: 0, + subs: /* @__PURE__ */ new Set(), + fetched: false + }); + } + function bump(name) { + const r = get(name); + r.ver++; + for (const fn of r.subs) fn(); + } + return { + entries, + get, + bump, + bumpAll() { + for (const n in entries) bump(n); + } + }; + } + + // src/runtime.ts + var COMPONENT_DIR = "."; + function createRuntime(doc = document) { + const registry = createRegistry(); + const pseudoClass = createPseudoSheet(doc); + const helmet = createHelmetManager( + doc, + (name) => registry.get(name).htmlStreaming + ); + const external = createExternalModules(() => registry.bumpAll()); + const factory = createComponentFactory(registry, ensureFetched); + const host = { + component: (name) => factory.getDC(name), + placeholder: (props) => h(Placeholder, props), + helmet: (node) => helmet.compile(node), + loadExternal: (kind, url, after) => external.load(kind, url, after), + resolveExternal: (url, name) => external.resolve(url, name), + resolveExternalGlobal: (url, name) => external.resolveGlobal(url, name), + resolveExternalError: (url, name) => external.getError(url, name), + pseudoClass + }; + function ensureFetched(name) { + const r = registry.get(name); + if (r.fetched) return; + r.fetched = true; + const url = COMPONENT_DIR + "/" + encodeURIComponent(name) + ".dc.html"; + const res = window.__resources; + const pre = res ? res[url] : void 0; + const target = typeof pre === "string" && pre ? pre : url; + const blob = bundledBlob(target); + (blob ? blob.text() : fetch(target).then((res2) => { + if (!res2.ok) { + console.error( + '[dc-runtime] sibling fetch for "' + name + '" failed:', + url, + "returned", + res2.status, + "\u2014 the reference renders as an empty placeholder." + ); + return ""; + } + return res2.text(); + })).then((t) => { + if (!t) return; + const parsed = parseDcText(t); + if (!parsed) { + console.error( + '[dc-runtime] sibling fetch for "' + name + '":', + url, + "has no block \u2014 not a Design Component." + ); + return; + } + if (parsed.props) r.propsMeta = parsed.props; + if (parsed.preview) r.preview = parsed.preview; + if (parsed.template && !r.html) updateHtml(name, parsed.template); + if (parsed.js && !r.Logic) updateJs(name, parsed.js); + }).catch( + (e) => console.error( + '[dc-runtime] sibling fetch for "' + name + '" threw:', + url, + e + ) + ); + } + let rootName = null; + function updateHtml(name, html) { + const r = registry.get(name); + r.html = html; + if (name === rootName) { + const mode = DESIGN_DOC_MODE_RE.exec(html)?.[1] ?? null; + if (mode || !r.htmlStreaming) helmet.setDesignDocMode(mode); + } + try { + r.tpl = compileTemplate(html, host); + } catch (e) { + console.error("[dc-runtime] template compile FAILED for", name, e); + } + registry.bump(name); + } + function updateJs(name, src) { + const r = registry.get(name); + const seq = r.jsSeq = (r.jsSeq || 0) + 1; + try { + const Cls = evalDcLogic(src); + if (r.jsSeq !== seq) return; + if (typeof Cls !== "function") { + r.logicError = name + ".dc.html: