from django.urls import path
from . import views

app_name = "bengkel"

urlpatterns = [
    # ── Penganjur home ───────────────────────────────────────────────────────
    path("home/",                     views.penganjur_home,     name="penganjur_home"),

    # ── Peserta reference ────────────────────────────────────────────────────
    path("<int:pk>/reference/",       views.peserta_reference,  name="peserta_reference"),
    path("<int:pk>/spaf/",            views.peserta_spaf,       name="peserta_spaf"),

    # ── Workshop CRUD ────────────────────────────────────────────────────────
    path("",                          views.bengkel_list,       name="list"),
    path("baru/",                     views.bengkel_create,     name="create"),
    path("<int:pk>/",                 views.bengkel_detail,     name="detail"),
    path("<int:pk>/edit/",            views.bengkel_edit,       name="edit"),
    path("<int:pk>/delete/",          views.bengkel_delete,     name="delete"),

    # ── Invitation management (admin) ────────────────────────────────────────
    path("<int:pk>/jemputan/",        views.jemputan_list,       name="jemputan_list"),
    path("<int:pk>/jemput/",           views.jemput,              name="jemput"),
    path("jemputan/csv-template/",     views.jemputan_csv_template, name="jemputan_csv_template"),
    path("jemputan/<int:jid>/",        views.jemputan_info,       name="jemputan_info"),
    path("jemputan/<int:jid>/delete/", views.jemputan_delete,     name="jemputan_delete"),
    path("jemputan/<int:jid>/approve/", views.jemputan_approve,   name="jemputan_approve"),
    path("jemputan/<int:jid>/reject/",  views.jemputan_reject,    name="jemputan_reject"),
    path("jemputan/<int:jid>/qr/",     views.jemputan_qr_image,   name="jemputan_qr"),
    path("jemputan/<int:jid>/email/",  views.jemputan_send_email, name="jemputan_send_email"),
    # Open registration link management
    path("<int:pk>/reg/toggle/",       views.reg_toggle,          name="reg_toggle"),
    path("<int:pk>/reg/reset/",        views.reg_reset,           name="reg_reset"),
    path("<int:pk>/reg/",              views.open_reg_info,       name="open_reg_info"),
    path("<int:pk>/reg/qr/",           views.open_reg_qr_image,   name="open_reg_qr"),

    # ── Master QR & Self Check-in ───────────────────────────────────────────
    path("<int:pk>/master-qr/",           views.papar_master_qr,    name="papar_master_qr"),
    
    # API Penganjur: Tarik data kehadiran live ke skrin Master QR
    path("<int:pk>/master-qr/live/",      views.master_qr_live_ajax, name="master_qr_live_ajax"),
    
    # URL Peserta: Membuka skrin kamera bimbit peserta
    path("<int:pk>/pengimbas-peserta/",   views.peserta_scan_kamera, name="peserta_scan_kamera"),
    
    # API Peserta: Menghantar token yang telah diimbas ke pelayan
    path("check-in/self/<uuid:master_token>/", views.peserta_self_check_in, name="peserta_self_check_in"),

    # ── User dashboard (login required) ─────────────────────────────────────
    path("dashboard/",            views.user_dashboard,  name="dashboard"),
    path("profil/edit/",          views.edit_profile,    name="edit_profile"),
    path("profil/kata-laluan/",   views.change_password, name="change_password"),
    path("mohon-penganjur/",      views.mohon_penganjur, name="mohon_penganjur"),
    path("peserta/",              views.peserta_saya,    name="peserta_saya"),

    # ── Attendee problem statement submission (token-based, no login needed) ─
    path("i/<uuid:token>/hantar/", views.submit_pernyataan, name="submit_pernyataan"),

    # ── Public Portal — peserta daftar sendiri (no login) ────────────────────
    path("portal/",               views.portal_list,   name="portal_list"),
    path("portal/<int:pk>/",      views.portal_detail, name="portal_detail"),
    path("portal/tiket/<uuid:token>/", views.portal_tiket, name="portal_tiket"),

    # ── Public invitation pages (no login required) ──────────────────────────
    path("i/<uuid:token>/",           views.invitation_response, name="response"),
    path("i/<uuid:token>/terima/",    views.invitation_accept,   name="accept"),
    path("i/<uuid:token>/tolak/",     views.invitation_reject,   name="reject"),
    path("i/<uuid:token>/tiket/",     views.invitation_ticket,   name="tiket"),
    # Open registration (no login — anyone with the link)
    path("r/<uuid:reg_token>/",       views.open_reg,            name="open_reg"),

    # ── Contribution (file upload + comment) ─────────────────────────────────
    path("i/<uuid:token>/sumbangan/", views.contribute,          name="contribute"),

    # ── LLM Laporan ──────────────────────────────────────────────────────────
    path("<int:pk>/laporan/",         views.laporan_list,        name="laporan_list"),

    # ── Tentative (jadual program) ────────────────────────────────────────────
    path("<int:pk>/tentative/",                  views.tentative_manage, name="tentative"),
    path("<int:pk>/tentative/<int:tid>/edit/",   views.tentative_edit,   name="tentative_edit"),
    path("<int:pk>/tentative/<int:tid>/delete/", views.tentative_delete, name="tentative_delete"),

    # ── Situational Analysis Tools ────────────────────────────────────────────
    path("analisis/swot/",              views.analisis_swot,         name="analisis_swot"),
    path("analisis/swot/<int:pk>/del/", views.analisis_swot_delete,  name="analisis_swot_delete"),
    path("analisis/pestel/",              views.analisis_pestel,        name="analisis_pestel"),
    path("analisis/pestel/<int:pk>/del/", views.analisis_pestel_delete, name="analisis_pestel_delete"),
    path("analisis/vmost/",              views.analisis_vmost,         name="analisis_vmost"),
    path("analisis/vmost/<int:pk>/del/", views.analisis_vmost_delete,  name="analisis_vmost_delete"),
    path("analisis/5c/",              views.analisis_5c,            name="analisis_5c"),
    path("analisis/5c/<int:pk>/del/", views.analisis_5c_delete,     name="analisis_5c_delete"),
    path("analisis/soar/",              views.analisis_soar,          name="analisis_soar"),
    path("analisis/soar/<int:pk>/del/", views.analisis_soar_delete,   name="analisis_soar_delete"),

    # SPAF — Situational Problem Analysis Framework
    path("analisis/spaf/",                              views.spaf_hub,                      name="spaf_hub"),
    path("analisis/spaf/pain-point/",                   views.spaf_pain_point,               name="spaf_pain_point"),
    path("analisis/spaf/pain-point/<int:pk>/del/",      views.spaf_pain_point_delete,        name="spaf_pain_point_delete"),
    path("analisis/spaf/problem-statement/",            views.spaf_problem_statement,        name="spaf_problem_statement"),
    path("analisis/spaf/problem-statement/<int:pk>/del/", views.spaf_problem_statement_delete, name="spaf_problem_statement_delete"),
    path("analisis/spaf/rca/",                          views.spaf_rca,                      name="spaf_rca"),
    path("analisis/spaf/rca/<int:pk>/del/",             views.spaf_rca_delete,               name="spaf_rca_delete"),
    path("analisis/spaf/rcv/",                          views.spaf_rcv,                      name="spaf_rcv"),
    path("analisis/spaf/rcv/<int:pk>/del/",             views.spaf_rcv_delete,               name="spaf_rcv_delete"),
    path("analisis/spaf/risk/",                         views.spaf_risk,                     name="spaf_risk"),
    path("analisis/spaf/risk/<int:pk>/del/",            views.spaf_risk_delete,              name="spaf_risk_delete"),

    # ── Blueprint Peserta ─────────────────────────────────────────────────────
    path("<int:pk>/lobi/", views.peserta_lobi, name="peserta_lobi"),
    path("<int:pk>/lobi/forum/cipta/", views.cipta_forum_thread, name="cipta_forum_thread"),
    path("lobi/forum/balas/<int:thread_id>/", views.balas_forum_thread, name="balas_forum_thread"),
    path("<int:pk>/blueprint/", views.blueprint_peserta, name="peserta_overview"),
    path("<int:pk>/blueprint/spaf/painpoint/", views.peserta_painpoint, name="peserta_painpoint"),
    path("<int:pk>/blueprint/spaf/situational/", views.peserta_situational, name="peserta_situational"),
    path("<int:pk>/blueprint/spaf/problem/", views.peserta_problem, name="peserta_problem"),
    path("<int:pk>/blueprint/spaf/rca/", views.peserta_rca, name="peserta_rca"),
    path("<int:pk>/blueprint/spaf/rca-validation/", views.peserta_rca_validation, name="peserta_rca_validation"),
    path("<int:pk>/blueprint/spaf/risk/", views.peserta_risk, name="peserta_risk"),
    path("<int:pk>/blueprint/theme/", views.peserta_theme, name="peserta_theme"),
    path("<int:pk>/blueprint/pillar/", views.peserta_pillar, name="peserta_pillar"),
    path("<int:pk>/blueprint/strategi/", views.peserta_strategi, name="peserta_strategi"),
    path("<int:pk>/blueprint/action-plan/", views.peserta_action_plan, name="peserta_action_plan"),
    path("<int:pk>/blueprint/indikator/", views.peserta_indikator, name="peserta_indikator"),
    path("<int:pk>/blueprint/peruntukan/", views.peserta_peruntukan, name="peserta_peruntukan"),
    
    # Laluan Analisis Untuk Penganjur
    path("<int:pk>/overview-map/", views.overview_map, name="overview_map"),
    path("<int:pk>/analisis-korpus/", views.analisis_korpus, name="analisis_korpus"),
    path('<int:pk>/analisis-korpus/live/', views.korpus_live_data_ajax, name='korpus_live_data_ajax'),
    path("<int:pk>/analisis-spaf/", views.analisis_spaf, name="analisis_spaf"),
    path("<int:pk>/analisis-tema/", views.analisis_tema, name="analisis_tema"),
    path('<int:pk>/analisis-tema/live/', views.tema_live_data_ajax, name='tema_live_data_ajax'),
    path("<int:pk>/analisis-pillar/", views.analisis_pillar, name="analisis_pillar"),
    path('<int:pk>/analisis-pillar/live/', views.pillar_live_data_ajax, name='pillar_live_data_ajax'),
    path("<int:pk>/analisis-strategi/", views.analisis_strategi, name="analisis_strategi"),
    path("<int:pk>/analisis-action-plan/", views.analisis_action_plan, name="analisis_action_plan"),
    path("<int:pk>/analisis-indikator/", views.analisis_indikator, name="analisis_indikator"),
    path("<int:pk>/analisis-peruntukan/", views.analisis_peruntukan, name="analisis_peruntukan"),
    path("<int:pk>/analitik-sme/", views.analitik_sme, name="analitik_sme"),
    path("<int:pk>/trigger-ai/", views.trigger_ai_laporan, name="trigger_ai_laporan"),
    path('api/worker-webhook/', views.worker_webhook, name='worker_webhook'),
    path("<int:pk>/analisis-painpoint/jana-master/", views.jana_master_problem_statement, name="jana_master_ps"),

    #-----------------------------------------------------
    path("<int:pk>/analisis-painpoint/", views.analisis_painpoint, name="analisis_painpoint"),
    path("<int:pk>/analisis-problem/", views.analisis_problem, name="analisis_problem"),
    path("<int:pk>/analisis-situational/", views.analisis_situational, name="analisis_situational"),
    path("<int:pk>/analisis-rca/", views.analisis_rca, name="analisis_rca"),
    path('<int:pk>/analisis-rca/live/', views.rca_live_data_ajax, name='rca_live_data_ajax'),
    path("<int:pk>/analisis-rca-validation/", views.analisis_rca_validation, name="analisis_rca_validation"),
    path('<int:pk>/analisis-rca-validation/live/', views.rca_validation_live_data_ajax, name='rca_validation_live_data_ajax'),
    path("<int:pk>/analisis-risk/", views.analisis_risk, name="analisis_risk"),
    path('<int:pk>/analisis-risk/live/', views.risk_live_data_ajax, name='risk_live_data_ajax'),

    #-------------------------------------------------------
    # Profil Kognitif AI (Dwi-Fungsi: Peserta & Penganjur)
    path("profil-kognitif/<int:uid>/", views.profil_kognitif, name="profil_kognitif"),
    path('profil-kognitif/<int:uid>/jana-ai/', views.jana_profil_kognitif_ajax, name='jana_profil_kognitif_ajax'),


    path("<int:pk>/ask-ai/", views.ask_ai_rag, name="ask_ai_rag"),
    path('<int:pk>/spaf/painpoint/jana-cetusan/', views.jana_cetusan_ai, name='jana_cetusan_ai'),
    path('<int:pk>/spaf/painpoint/simpan/', views.simpan_painpoint_ajax, name='simpan_painpoint_ajax'),
    path('<int:pk>/spaf/problem/simpan-komen/', views.simpan_komen_pembaikan_ajax, name='simpan_komen_pembaikan_ajax'),
    path('<int:pk>/spaf/problem/sintesis-komen/', views.sintesis_semula_komen_ajax, name='sintesis_semula_komen_ajax'),
    path('<int:pk>/spaf/problem/status/', views.simpan_status_semakan_ajax, name='simpan_status_semakan'),

    # Laluan AJAX untuk menyimpan analisis situasi
    path('<int:pk>/spaf/situational/simpan/', views.simpan_situational_ajax, name='simpan_situational_ajax'),
    # Laluan AJAX untuk simpan RCA
    path('<int:pk>/spaf/rca/simpan/', views.simpan_rca_ajax, name='simpan_rca_ajax'),
    # Laluan AJAX untuk simpan pengesahan RCA
    path('<int:pk>/spaf/rca-validation/simpan/', views.simpan_rca_validation_ajax, name='simpan_rca_validation_ajax'),
    # Laluan AJAX untuk simpan penilaian Risiko
    path('<int:pk>/spaf/risk/simpan/', views.simpan_risk_ajax, name='simpan_risk_ajax'),
    # Laluan baharu untuk AJAX Tema
    path('<int:pk>/undi-tema/', views.undi_tema_ajax, name='undi_tema_ajax'),
    path('<int:pk>/simpan-idea-tema/', views.simpan_idea_tema_ajax, name='simpan_idea_tema_ajax'),
    # Tambahkan di bawah laluan AJAX Tema yang anda buat sebelum ini
    path('<int:pk>/jana-tema-penganjur/', views.jana_tema_penganjur_ajax, name='jana_tema_penganjur_ajax'),

    # Laluan baharu untuk AJAX Teras (Pillars) - Node 4
    path('<int:pk>/jana-pillar-penganjur/', views.jana_pillar_penganjur_ajax, name='jana_pillar_penganjur_ajax'),
    path('<int:pk>/sokong-pillar/', views.sokong_pillar_ajax, name='sokong_pillar_ajax'),
    path('<int:pk>/simpan-idea-pillar/', views.simpan_idea_pillar_ajax, name='simpan_idea_pillar_ajax'),

    # Laluan baharu untuk AJAX Strategi (Roadmap 30 Tahun) - Node 5
    path('<int:pk>/jana-strategi-penganjur/', views.jana_strategi_penganjur_ajax, name='jana_strategi_penganjur_ajax'),
    path('<int:pk>/simpan-idea-strategi/', views.simpan_idea_strategi_ajax, name='simpan_idea_strategi_ajax'),

    # Laluan baharu untuk AJAX Pelan Tindakan (Action Plan) - Node 6
    path('<int:pk>/jana-action-plan-penganjur/', views.jana_action_plan_penganjur_ajax, name='jana_action_plan_penganjur_ajax'),
    path('<int:pk>/simpan-idea-action-plan/', views.simpan_idea_action_plan_ajax, name='simpan_idea_action_plan_ajax'),

    # Laluan baharu untuk AJAX Indikator KPI - Node 7
    path('<int:pk>/jana-indikator-penganjur/', views.jana_indikator_penganjur_ajax, name='jana_indikator_penganjur_ajax'),

    # LOKASI TAMBAHAN BARU UNTUK PERUNTUKAN SUMBER (NODE 8):
    path('<int:pk>/jana-peruntukan-penganjur/', views.jana_peruntukan_penganjur_ajax, name='jana_peruntukan_penganjur_ajax'),
    path('<int:pk>/simpan-idea-peruntukan/', views.simpan_idea_peruntukan_ajax, name='simpan_idea_peruntukan_ajax'),

    # Laluan Penutup - Node 9: Laporan Eksekutif
    path('<int:pk>/laporan-eksekutif/', views.laporan_eksekutif, name='laporan_eksekutif'),
    # Laluan untuk mengemaskini kapasiti meja secara dinamik (Peta Lantai)
    path('<int:pk>/kemaskini-kapasiti-meja-ajax/', views.kemaskini_kapasiti_meja_ajax, name='kemaskini_kapasiti_meja_ajax'),
    # Laluan untuk butang kunci sistem (Tamat Bengkel)
    path('<int:pk>/kunci-bengkel-ajax/', views.kunci_bengkel_ajax, name='kunci_bengkel_ajax'),

    path('<int:pk>/jana-master-problem-statement/', views.jana_master_problem_statement, name='jana_master_problem_statement'),
    path('simpan-maklumbalas-ajax/<int:pk>/', views.simpan_maklumbalas_ajax, name='simpan_maklumbalas_ajax'),
    path("<int:pk>/blueprint/spaf/problem/simpan-komen/", views.simpan_komen_pembaikan_ajax, name="simpan_komen_pembaikan_ajax"),
    path("<int:pk>/blueprint/spaf/problem/sintesis-komen/", views.sintesis_semula_komen_ajax, name="sintesis_semula_komen_ajax"),
    path('<int:pk>/blueprint/situational/jana-rumusan/', views.jana_rumusan_situasi_ajax, name='jana_rumusan_situasi_ajax'),
    path('<int:pk>/blueprint/rca-validation/sintesis-bantahan/', views.sintesis_bantahan_ai_ajax, name='sintesis_bantahan_ai_ajax'),
    path('<int:pk>/blueprint/risk/sintesis-mitigasi/', views.sintesis_mitigasi_ai_ajax, name='sintesis_mitigasi_ai_ajax'),
    path('<int:pk>/blueprint/theme/murnikan/', views.murnikan_tema_ai_ajax, name='murnikan_tema_ai_ajax'),
    path('<int:pk>/blueprint/pillar/murnikan/', views.murnikan_pillar_ai_ajax, name='murnikan_pillar_ai_ajax'),
    path('<int:pk>/blueprint/strategi/murnikan/', views.murnikan_strategi_ai_ajax, name='murnikan_strategi_ai_ajax'),
    path('<int:pk>/blueprint/indikator/kalibrasi/', views.simpan_kpi_calibration_ajax, name='simpan_kpi_calibration_ajax'),
    path('<int:pk>/blueprint/peruntukan/kalibrasi/', views.simpan_peruntukan_calibration_ajax, name='simpan_peruntukan_calibration_ajax'),
    path('<int:pk>/blueprint/peruntukan/murnikan/', views.murnikan_peruntukan_ai_ajax, name='murnikan_peruntukan_ai_ajax'),
    path('<int:pk>/analisis-rca/jana-kluster/', views.jana_rumusan_rca_ajax, name='jana_rumusan_rca_ajax'),

    path("<int:pk>/spaf/unlock/", views.unlock_spaf_step_ajax, name="unlock_spaf_step"),
    path("<int:pk>/blueprint/unlock/", views.unlock_blueprint_step_ajax, name="unlock_blueprint_step"),
    path('api/jana-tentatif-ai/', views.jana_tentatif_ai_ajax, name='jana_tentatif_ai'),

    


]
