1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/js/bcv-core-D6w0EXi8.js","assets/js/utils-DUc9fQ3R.js","assets/js/shared-api-EKsgZBbW.js","assets/js/vite-preload-BXl3LOEh.js","assets/js/bcv-share-CzjZ8vyH.js","assets/js/encryption-DCmpUEbF.js","assets/css/bcv-share-DxSIxjtm.css","assets/js/bcv-preview-C7cF4qqs.js","assets/js/bcv-seal-N3GEJ-jJ.js"])))=>i.map(i=>d[i]); 2import"./modulepreload-polyfill-B5Qt9EMX.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{_ as Xe}from"./vite-preload-BXl3LOEh.js";import{_ as r,p as me,m as Ce}from"./utils-DUc9fQ3R.js";import{E as F}from"./encryption-DCmpUEbF.js";import{installSealCeremonyDevTrigger as Ye}from"./SealCeremony-Ca9AfGIf.js";let se=null;async function We(){return se||({BagContentViewer:se}=await Xe(()=>import("./bcv-core-D6w0EXi8.js").then(t=>t.B),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),se}Ye();let Q=null;function x(t){Q=t,document.title=t()}document.addEventListener("vr-lang-change",()=>{Q&&(document.title=Q())});document.addEventListener("vr-i18n-ready",()=>{Q&&(document.title=Q())});function ce(t){return t=t||3e3,new Promise(function(e){if(!window.firebase||!firebase.auth){e(null);return}let n=!1;const i=firebase.auth().onAuthStateChanged(function(o){n||(n=!0,i(),e(o))});setTimeout(function(){n||(n=!0,e(null))},t)})}const Je=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,Ze=/^[0-9a-f]{32}$/i,Se=/^[0-9a-f]{64}$/i;function Ee(t){return t&&(Je.test(t)||Ze.test(t))}function et(t){return t&&Se.test(t)}function le(t){const e=t.toUpperCase().replace(/[-\s]/g,"");return e.length===12&&/^[23456789ABCDEFGHJKMNPQRSTUVWXYZ]{12}$/.test(e)}const $=new URLSearchParams(window.location.search);let P=null;window.location.pathname.startsWith("/cert/")?P=decodeURIComponent(window.location.pathname.slice(6).replace(/\/+$/,"")):window.location.pathname.startsWith("/c/")&&(P=decodeURIComponent(window.location.pathname.slice(3).replace(/\/+$/,"")));function Be(t){try{document.documentElement.setAttribute("data-i18n-desc",t),window.I18n?.applyPageMeta?.()}catch{}}P&&Be("page.cert.desc");let xe=!1;if(P&&le(P)){xe=!0;const t=P.toUpperCase().replace(/[-\s]/g,"").replace(/(.{4})(.{4})(.{4})/,"$1-$2-$3");fetch(`/api/receipt/by-short/${encodeURIComponent(t)}`,{signal:AbortSignal.timeout(12e3)}).then(e=>e.ok?e.json():null).then(e=>{e?.receipt_id?window.location.replace(`/cert.html?rid=${encodeURIComponent(e.receipt_id)}&proof=1`):(y&&(y.style.display="none"),j&&(j.textContent=r("cert.noDocMatchCode","No sealed document found matching this code")),_&&(_.style.display=""))}).catch(()=>{y&&(y.style.display="none"),j&&(j.textContent=r("cert.loadError","Sertifika yüklenemedi.")),_&&(_.style.display="")}),P=null}const ee=$.get("rid")||$.get("id")||P||null,U=$.get("hash"),te=$.get("sid"),tt=$.get("open")||null,D=$.get("share");let X=$.get("proof")==="1";const Te=$.get("verify")==="1"||$.get("mode")==="verify"||typeof window<"u"&&window.location&&window.location.pathname==="/verify";D&&!ee&&!U&&!te&&typeof document<"u"&&document.body&&document.body.classList.add("vr-share-view");window._vrCertReady=!0;typeof window._vrClearFallback=="function"&&window._vrClearFallback();const y=document.getElementById("loadingState"),_=document.getElementById("errorState"),j=document.getElementById("errorMessage"),T=document.getElementById("deletedState"),B=document.getElementById("searchForm"),f=document.getElementById("certContent");function S(t){const e=document.getElementById("homeIntroSection");if(e){if(!t){e.style.display="none";return}if(localStorage.getItem("vr-intro-dismissed")==="1"){e.style.display="none";return}if(e.style.display="",!e.querySelector(".home-intro-dismiss")){const n=document.createElement("button");n.className="home-intro-dismiss",n.setAttribute("aria-label","Close"),n.textContent="Ã",n.addEventListener("click",()=>{localStorage.setItem("vr-intro-dismissed","1"),e.style.display="none"}),e.style.position="relative",e.appendChild(n)}}}let he=!1;async function A(t,e={}){const n=await We(),i={mode:t,container:f,...e};return t==="owner"&&(i.onError||(i.onError=o=>{console.error("[Cert] Viewer error:",o),typeof showAppNotification=="function"&&showAppNotification("error",r("bags.viewerError","Error"),r("cert.loadError","Sertifika yüklenemedi."))})),new n(i)}async function rt(t){const e=f?.querySelector(".bcv-panel");e&&(e.classList.add("bcv-switching"),await new Promise(i=>setTimeout(i,200))),await t();const n=f?.querySelector(".bcv-panel");n&&(n.classList.add("bcv-switching"),requestAnimationFrame(()=>{n.classList.remove("bcv-switching")}))}async function de(t,e={}){document.querySelectorAll(".bcv-seal-success-overlay").forEach(a=>a.remove());const n=window.bagViewer||null,i=a=>
2{if(n&&n!==a){n._retired=!0;try{n._stopViewersPolling?.()}catch{}}},o=f?.querySelector(".bcv-panel");o&&(o.classList.add("bcv-switching"),await new Promise(a=>setTimeout(a,180)));const c=document.createElement("div"),s=await A("owner",{bagId:t,container:c});try{if(await s.load(),s.data?.__bag_destroyed===!0&&e?.preflightReceipt&&e?.receiptId){f.innerHTML="",R(!1),i(s),await M(e.preflightReceipt,e.receiptId,{destructive:!0,consumed_at:s.data?.destructive_consumed_at||null,is_owner:!0});return}if(s.mode==="owner"&&s.data?.status==="draft"){s.mode="create",s.isOwner=!1,s.isCreate=!0;try{await s._mergeDraftIfAny()}catch(l){console.warn("[cert] draft merge after flip failed",l?.message||l)}}for(s.render(),f.innerHTML="";c.firstChild;)f.appendChild(c.firstChild);window.bagViewer=s,s.container=f,window.__vrDraftVisRefresh||(window.__vrDraftVisRefresh=!0,document.addEventListener("visibilitychange",()=>{if(document.hidden)return;const l=window.bagViewer;l&&l.bagId&&(l.mode==="create"||l.data?.status==="draft")&&typeof l.refreshFileList=="function"&&l.refreshFileList()})),s._cspDelegatedBound=!1,s._encryptedUnlockContentBound=!1,s._swipeGestureBound=!1,s._gridClearSelectionBound=!1,s._imgFallbackBound=!1,s._formPreventBound=!1,s._linkLogToggleBound=!1,s._copyLinkUrlBound=!1,s._clearBagDelegationAttached=!1,s._verifyResultDelegationAttached=!1,s.attachEventListeners(),i(s),x(()=>`${s.getBagName()} â VerityRecord`),window.history.replaceState({},"",`/upload#bag/${t}`);const a=f.querySelector(".bcv-panel");a&&(a.classList.add("bcv-switching"),requestAnimationFrame(()=>a.classList.remove("bcv-switching")))}catch(a){console.error("[Cert] Switch to bag failed:",a),f.innerHTML="",typeof showAppNotification=="function"&&showAppNotification("error",r("bags.loadFailed","Load Failed"),r("cert.loadError","Sertifika yüklenemedi."))}}async function nt(){await rt(async()=>{f.innerHTML="";const t=window.firebase?.auth?.()?.currentUser;let e;if(t)try{const n={Authorization:`Bearer ${await t.getIdToken()}`},i=await fetch("/api/bags?status=draft",{headers:n});if(i.ok){const o=await i.json(),c=o.bags&&o.bags[0];c&&c.id&&(e=await A("create",{bagId:c.id}),await e.load())}}catch(n){console.warn("[Cert] Draft load failed",n?.message)}e||(e=await A("create"),await e.load()),e.render(),window.bagViewer=e,x(()=>`${e.getBagName()} â VerityRecord`),window.history.replaceState({},"","/upload")})}function R(t){const e=document.getElementById("globalNav");e&&(e.style.display=t?"":"none",e.setAttribute("aria-hidden",t?"false":"true"))}window.showSearchForm=function(){window.location.href="/verify"};let V=null;function $e(){return V||(typeof window<"u"&&window.jsQR?(V=Promise.resolve(window.jsQR),V):(V=new Promise((t,e)=>{const n=document.createElement("script");n.src="/vendor/jsqr/jsQR.js",n.async=!0,n.onload=()=>t(window.jsQR),n.onerror=()=>{V=null,e(new Error("jsQR load failed"))},document.head.appendChild(n)}),V))}async function be(t,e,n){try{if(typeof window<"u"&&"BarcodeDetector"in window&&(await window.BarcodeDetector.getSupportedFormats()).includes("qr_code")){const l=await new window.BarcodeDetector({formats:["qr_code"]}).detect(t);if(l&&l.length)return l[0].rawValue}}catch{}let i;if(t instanceof ImageData)i=t;else{const s=document.createElement("canvas");s.width=e||t.width||t.videoWidth,s.height=n||t.height||t.videoHeight;const a=s.getContext("2d",{willReadFrequently:!0});a.drawImage(t,0,0,s.width,s.height),i=a.getImageData(0,0,s.width,s.height)}const c=(await $e())(i.data,i.width,i.height,{inversionAttempts:"attemptBoth"});return c?c.data:null}async function Le(){R(!1),y&&(y.style.display="none"),_&&(_.style.display="none"),T&&(T.style.display="none");const t=document.querySelector(".cert-container");if(t&&t.classList.add("cert-verify-page","cert-verify-standalone-page"),B&&(B.style.display="none"),!f){y&&(y.style.display="none"),k(r("cert.loadError","Sayfa hazır deÄil. Yenileyin."));return}f.style.display="block",f.className="cert-verify-standalone",f.innerHTML=` 3 <div class="cert-verify-brand-row"> 4 <a class="cert-verify-brand" href="/" aria-label="VerityRecord"> 5 <img src="/logo.webp" alt="" class="cert-verify-brand-logo" width="24" height="24" />
6 <span class="cert-verify-brand-name">VerityRecord</span> 7 </a> 8 </div> 9 <div class="cert-verify-hero"> 10 <div class="cert-verify-hero-icon" aria-hidden="true"> 11 <svg width="26" height="26" viewBox="0 0 32 32" fill="none"><path d="M16 2.5 27 6.5V15c0 7.5-5 12.5-11 14.5C10 27.5 5 22.5 5 15V6.5Z" fill="var(--accent-soft, rgba(123,97,255,.14))" stroke="currentColor" stroke-width="1.7" stroke-linejoin="round"/><path d="M10.8 16.1 14.3 19.6 21.4 11.8" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></svg> 12 </div> 13 <h1 class="cert-verify-hero-title">${r("cert.verifyTitle","Belge DoÄrulama")}</h1> 14 <p class="cert-verify-hero-sub">${r("cert.verifySubtitleNew","Bir mührün gerçekliÄini ve kayıt zamanını matematiksel olarak kontrol edin.")}</p> 15 </div> 16 17 <div class="cert-verify-tabs" role="tablist"> 18 <button type="button" class="cert-verify-tab is-active" data-vr-tab="code" role="tab" aria-selected="true">${r("cert.verifyTabCode","Kod / Link")}</button> 19 <button type="button" class="cert-verify-tab" data-vr-tab="qr" role="tab" aria-selected="false">${r("cert.verifyTabQr","QR kod")}</button> 20 <button type="button" class="cert-verify-tab" data-vr-tab="off" role="tab" aria-selected="false">${r("cert.verifyTabOffline","ÃevrimdıÅı")}</button> 21 </div> 22 23 <div class="cert-verify-panels" id="certVerifyCard"> 24 <div class="cert-verify-panel is-active" data-vr-panel="code" role="tabpanel"> 25 <p class="cert-verify-panel-hint">${r("cert.verifyHintCode","Belge kodunu girin veya sertifika linkini yapıÅtırın.")}</p> 26 <div class="cert-verify-row"> 27 <input type="text" id="certVerifyInput" class="cert-verify-card-input" placeholder="XXXX-XXXX-XXXX" autocomplete="off" spellcheck="false" aria-label="${r("cert.searchPlaceholder","Belge kodu")}" /> 28 <button type="button" class="cert-verify-card-btn" id="certVerifyBtn"> 29 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg> 30 ${r("cert.fetchDoc","Belgeyi Getir")} 31 </button> 32 </div> 33 </div> 34 35 <div class="cert-verify-panel" data-vr-panel="qr" role="tabpanel" hidden> 36 <p class="cert-verify-panel-hint">${r("cert.verifyQrPrompt","Sertifikadaki QR kodu kameranızla okutun veya QR resmini yükleyin.")}</p> 37 <div class="cert-verify-qr-stage" id="certVerifyQrStage"> 38 <video id="certVerifyQrVideo" class="cert-verify-qr-video" playsinline muted></video> 39 <div class="cert-verify-qr-frame" aria-hidden="true"></div> 40 <div class="cert-verify-qr-status" id="certVerifyQrStatus" hidden></div> 41 </div> 42 <div class="cert-verify-qr-actions"> 43 <button type="button" class="cert-verify-qr-btn" id="certVerifyQrCamBtn"> 44 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg> 45 <span id="certVerifyQrCamLabel">${r("cert.verifyQrCameraStart","Kamerayı aç")}</span> 46 </button> 47 <button type="button" class="cert-verify-qr-btn cert-verify-qr-btn--ghost" id="certVerifyQrUploadBtn"> 48 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg> 49 ${r("cert.verifyQrUploadFile","QR resmi yükle")} 50 </button> 51 <input type="file" id="certVerifyQrFile" accept="image/*" hidden /> 52 </div> 53 </div> 54 55 <div class="cert-verify-panel" data-vr-panel="off" role="tabpanel" hidden> 56 <div class="cert-verify-offline-card"> 57 <p class="cert-verify-offline-heading">${r("cert.verifyOfflineHeading","İnternet baÄlantısı olmadan doÄrulama")}</p> 58 <p class="cert-verify-offline-desc">${r("cert.verifyOfflineDesc","ZIP kanıt paketini tarayıcıda doÄrulayın; hiçbir veri cihazınızdan çıkmaz.")}</p> 59 <a class="cert-verify-offline-link" href="/verify-offline">${r("cert.verifyOfflineLink","ÃevrimdıÅı doÄrulama sayfasını aç")} 60 <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg> 61 </a> 62 </div> 63 </div> 64 65 <p id="certVerifyCardError" class="cert-verify-card-error vr-hidden" role="alert"></p> 66 </div> 67 68 <div class="cert-verify-tagline-row"> 69 <p class="cert-verify-tagline">${r("cert.verifyTagline","DoÄrulama herkese açıktır · hesap gerektirmez · ücretsizdir")}</p> 70 </div> 71 `,x(()=>`${r("cert.verifyTitle","Belge DoÄrulama")} â VerityRecord`),S(!1);
71const e=document.getElementById("certVerifyInput"),n=document.getElementById("certVerifyBtn"),i=document.getElementById("certVerifyCard"),o=document.getElementById("certVerifyCardError");function c(){o&&(o.style.display="none",o.textContent=""),i&&i.classList.remove("cert-verify-card--error")}function s(v){o&&(o.textContent=v,o.style.display="block"),i&&i.classList.add("cert-verify-card--error")}async function a(v){if(!v)return!1;let w=v.rid||null;try{if(!w&&v.short){const C=v.short.match(/.{1,4}/g).join("-"),E=await fetch(`/api/receipt/by-short/${encodeURIComponent(C)}`);E.ok&&(w=(await E.json()).receipt_id)}else if(!w&&v.hash){const C=await fetch(`/api/receipt/by-hash/${encodeURIComponent(v.hash)}`);C.ok&&(w=(await C.json()).receipt_id)}}catch(C){console.warn("[cert] resolve",C)}return w?(window.location.href=`/cert.html?rid=${encodeURIComponent(w)}`,!0):!1}const l=f.querySelectorAll("[data-vr-tab]"),d=f.querySelectorAll("[data-vr-panel]");function u(v){c(),l.forEach(w=>{const C=w.getAttribute("data-vr-tab")===v;w.classList.toggle("is-active",C),w.setAttribute("aria-selected",C?"true":"false")}),d.forEach(w=>{const C=w.getAttribute("data-vr-panel")===v;w.classList.toggle("is-active",C),C?w.removeAttribute("hidden"):w.setAttribute("hidden","")}),v!=="qr"&&G(),v==="code"&&e&&setTimeout(()=>e.focus(),50)}l.forEach(v=>v.addEventListener("click",()=>u(v.getAttribute("data-vr-tab"))));async function p(){const v=e&&e.value?e.value.trim().replace(/[<>"'&]/g,""):"";if(!v){typeof showAppNotification=="function"&&showAppNotification("warning",r("cert.search","Ara"),r("cert.enterDocCode","Lütfen belge kodu girin."));return}c(),n&&(n.disabled=!0,n.classList.add("loading"));try{const w=me(v);if(!w){s(r("cert.documentNotFoundHint","Kodu kontrol edin veya farklı bir belge kodu girin."));return}await a(w)||s(r("cert.documentNotFoundHint","Kodu kontrol edin veya farklı bir belge kodu girin."))}catch(w){console.warn("[cert] verify search",w),s(r("cert.errorMessage","AradıÄınız mühür belgesi bulunamadı."))}finally{n&&(n.disabled=!1,n.classList.remove("loading"))}}e&&(e.focus(),e.addEventListener("keydown",function(v){v.key==="Enter"&&p()}),e.addEventListener("input",function(){if(/[:/.]/.test(e.value))return;const v=e.value.replace(/[^A-Za-z0-9]/g,"").toUpperCase();if(v.length>12)return;const w=[];for(let E=0;E<v.length;E+=4)w.push(v.slice(E,E+4));const C=w.join("-");if(e.value!==C){const E=e.selectionStart,O=C.length-e.value.length;e.value=C,e.setSelectionRange(Math.min(E+O,C.length),Math.min(E+O,C.length))}})),n&&n.addEventListener("click",p);let m=null,b=0;const g=document.getElementById("certVerifyQrVideo"),h=document.getElementById("certVerifyQrStage"),L=document.getElementById("certVerifyQrStatus"),fe=document.getElementById("certVerifyQrCamBtn"),J=document.getElementById("certVerifyQrCamLabel"),ye=document.getElementById("certVerifyQrUploadBtn"),Z=document.getElementById("certVerifyQrFile");function oe(v){L&&(v?(L.textContent=v,L.removeAttribute("hidden")):(L.setAttribute("hidden",""),L.textContent=""))}async function ve(v){const w=me(v);if(!w){s(r("cert.verifyQrInvalid","QR kod tanındı ama geçerli bir VerityRecord belgesine ait deÄil."));return}oe(null),await a(w)||s(r("cert.documentNotFoundHint","Kodu kontrol edin veya farklı bir belge kodu girin."))}function G(){b&&(cancelAnimationFrame(b),b=0),m&&(m.getTracks().forEach(v=>v.stop()),m=null),h&&h.classList.remove("is-active"),J&&(J.textContent=r("cert.verifyQrCameraStart","Kamerayı aç")),oe(null)}async function Ge(){if(c(),m){G();return}if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){s(r("cert.verifyQrNoCamera","Kamera eriÅimi reddedildi veya yok."));return}try{m=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"}},audio:!1}),g&&(g.srcObject=m,await g.play()),h&&h.classList.add("is-active"),J&&(J.textContent=r("cert.verifyQrCameraStop","Kamerayı kapat")),oe(r("cert.verifyQrScanning","QR kod aranıyorâ¦")),$e().catch(()=>{});const v=async()=>{if(!m||!g||g.readyState!==g.HAVE_ENOUGH_DATA){b=requestAnimationFrame(v);return}try{const w=await be(g,g.videoWidth,g.videoHeight);if(w){G(),await ve(w);return}}catch{}b=requestAnimationFrame(v)};b=requestAnimationFrame(v)}catch(v){console.warn("[cert] camera",v),G(),s(r("cert.verifyQrNoCamera","Kamera eriÅimi reddedildi veya yok. Lütfen QR resmi yükleyin."))}}fe&&fe.addEventListener("click",Ge),ye&&Z&&ye.addEventListener("click",()=>Z.click()),Z&&Z.addEventListener("change",async v=>{c();const w=v.target.files&&v.target.files[0];if(v.target.value="",!!w)try{const C=URL.createObjectURL(w),E=new Image;await new Promise((Fe,Qe)=>{E.onload=Fe,E.onerror=Qe,E.src=C});
71const O=await be(E,E.naturalWidth,E.naturalHeight);if(URL.revokeObjectURL(C),!O){s(r("cert.verifyQrNotFound","Resimde QR kod bulunamadı."));return}await ve(O)}catch(C){console.warn("[cert] qr file",C),s(r("cert.verifyQrNotFound","Resimde QR kod bulunamadı."))}}),window.addEventListener("beforeunload",G,{once:!0})}async function it(){if(R(!0),_&&(_.style.display="none"),B&&(B.style.display="none"),y){y.style.display="flex";const i=y.querySelector(".loading-text");i&&(i.textContent=r("index.loadingBag","Yükleniyorâ¦"))}f&&(f.style.display="block",f.innerHTML=""),await ce();const t=window.firebase?.auth?.()?.currentUser,e=Ae()||tt;if(!t&&e){y&&(y.style.display="none"),S(!1),f&&(f.innerHTML=` 72 <div class="vr-empty-state vr-owner-link-auth" style="max-width:520px;margin:60px auto;text-align:center;"> 73 <div style="font-size:34px;margin-bottom:12px;">ð</div> 74 <h2 style="font-size:17px;margin:0 0 8px;">${r("bags.ownerLinkAuthTitle","Bu, sahibe özel bir baÄlantı")}</h2> 75 <p class="vr-muted" style="font-size:13px;line-height:1.55;margin:0 0 18px;">${r("bags.ownerLinkAuthDesc","Görüntülemek için sahibin hesabıyla giriÅ gerekir. Sana çanta paylaÅıldıysa sahibinden paylaÅım linkini iste; bu baÄlantı o deÄil.")}</p> 76 <button type="button" id="vrOwnerLinkLoginBtn" class="btn btn-primary">${r("auth.signIn","GiriÅ Yap")}</button> 77 </div>`,document.getElementById("vrOwnerLinkLoginBtn")?.addEventListener("click",async()=>{await ne()&&window.location.reload()}));return}if(t){if(Ie(),e){y&&(y.style.display="none"),await de(e),S(!1);return}try{const o=await window.draftStore?.getSealInProgress?.();if(o?.bagId){const c=await A("create",{bagId:o.bagId});window.bagViewer=c,await c.load(),y&&(y.style.display="none"),c.render(),x(()=>`${c.getBagName()} â VerityRecord`),S(!1),await window.draftStore?.clearSealInProgress?.(),typeof showAppNotification=="function"&&showAppNotification("warning",r("bags.sealInterruptedTitle","Mühürleme durduruldu"),r("bags.sealInterruptedMessage","Sayfa kapandıÄı için mühürleme tamamlanmadı. Ãanta mühürsüz kaldı; devam etmek için yeniden Mühürle'ye basın."),{duration:1e4});return}}catch(o){console.warn("[cert] seal-in-progress restore failed",o?.message||o)}let i;try{const o=await q(),c=new AbortController;i=setTimeout(()=>c.abort(),2e4);const s=await fetch("/api/bags?status=draft",{headers:o,signal:c.signal});if(clearTimeout(i),s.ok){const a=await s.json(),l=a.bags&&a.bags[0];if(l&&l.id){const d=await A("create",{bagId:l.id});window.bagViewer=d,await d.load(),y&&(y.style.display="none"),d.render(),x(()=>`${d.getBagName()} â VerityRecord`),S(!1);return}}}catch(o){i&&clearTimeout(i),console.warn("[cert] Draft load failed",o?.message||o)}}const n=await A("create");window.bagViewer=n;try{await n.load(),y&&(y.style.display="none"),n.render()}catch(i){console.error("[cert] BCV create load/render",i),y&&(y.style.display="none"),typeof showAppNotification=="function"&&showAppNotification("error",r("cert.verifyTitle","Belge doÄrulama"),r("cert.loadError","Sertifika yüklenemedi."));return}t?x(()=>`${r("index.newBag","Yeni Ãanta")} â VerityRecord`):(x(()=>r("page.home.title","VerityRecord â Timestamped Records")),Be("page.home.desc")),S(!t)}function Ae(){const e=(window.location.hash||"").match(/^#bag\/(.+)$/);return e?e[1]:null}function Ie(){he||(he=!0,(async()=>{try{if(localStorage.getItem("vr-intro-dismissed")==="1")return;const t=window.firebase?.auth?.().currentUser;if(!t||typeof window.__vrGetJSON!="function")return;const e=await t.getIdToken(),n=await window.__vrGetJSON("/api/bags",{Authorization:"Bearer "+e});(Array.isArray(n?.bags)?n.bags.filter(o=>o.status==="sealed").length:0)>=3&&(localStorage.setItem("vr-intro-dismissed","1"),S(!1))}catch{}})(),window.addEventListener("hashchange",()=>{const t=Ae();t?de(t):nt(),S(!1)}))}async function at(t){S(!1),y.style.display="flex",f.style.display="none";try{f.innerHTML="";const e=await A("public",{receiptId:t});window.bagViewer=e,await e.load(),e.render(),e.data?.encrypted&&!e._encryptionUnlocked&&(await e.promptForPassword(),e._encryptionUnlocked&&e.render()),x(()=>`${r("cert.verifyTitle","Belge DoÄrulama")} â VerityRecord`)}catch(e){console.error("[cert] loadReceiptIntoVerifyView",e);const n=I(e)?r("cert.connectionError","Connection lost. Check your connection and try again."):r("cert.errorMessage","The seal certificate could not be found.");showAppNotification("error",I(e)?r("cert.connectionErrorTitle","Connection lost"):r("cert.errorTitle","Document Not Found"),n),Le()}finally{y.style.display="none",f.style.display="block"}}window.searchReceipt=async function(){const e=(document.getElementById("searchInput")?.value??"").trim().replace(/[<>"'&]/g,"");if(!e){showAppNotification("warning",r("cert.search","Search"),r("cert.enterDocCode","Please enter a document code."));return}let n=null;if(le(e)){const i=await fetch(`/api/receipt/by-short/${encodeURIComponent(e.toUpperCase())}`);if(i.ok&&(n=(await i.json()).receipt_id),!n){showAppNotification("warning",r("cert.search","Search"),r("cert.noDocMatchCode","No sealed document found matching this code"));return}}else if(Se.test(e)){const i=await fetch(`/api/receipt/by-hash/${encodeURIComponent(e)}`);
77if(i.ok&&(n=(await i.json()).receipt_id),!n){showAppNotification("warning",r("cert.search","Search"),r("cert.noDocMatchHash","No sealed document found matching this hash"));return}}else if(Ee(e))n=e;else{showAppNotification("warning",r("cert.search","Search"),r("cert.invalidFormat","Invalid document code format. Please enter in XXXX-XXXX-XXXX format."));return}Te?await at(n):window.location.href=`/cert.html?rid=${encodeURIComponent(n)}`};function ot(t,e=null){return new Promise(n=>{document.querySelector(".vr-modal-backdrop[data-destructive-open]")?.remove();const i=document.createElement("div");i.setAttribute("data-destructive-open","1"),i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-label",r("cert.destructiveOpenTitle","İmha Ãantası")),i.className="vr-modal-backdrop",i.innerHTML=` 78 <div class="vr-modal-card"> 79 <button id="vrDestCancel" class="bcv-seal-confirm-close vr-pw-modal-close" title="${r("common.close","Kapat")}" aria-label="${r("common.cancel","İptal")}">Ã</button> 80 81 <div class="vr-pw-modal-header"> 82 <div class="vr-pw-modal-icon">ð</div> 83 <h2 class="vr-pw-modal-title">${r("encrypt.encryptedBag","Åifreli Ãanta")}</h2> 84 </div> 85 86 <div style="background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:14px 16px;margin-bottom:20px;font-size:13px;line-height:1.55;color:var(--muted);"> 87 <div style="padding:4px 0;">ð ${r("cert.destructiveOpenBullet1",'İçeriÄi <strong style="color:var(--text);">1 kez</strong> göreceksiniz.')}</div> 88 <div style="padding:6px 0 4px;border-top:1px solid var(--border);margin-top:4px;">â ${r("cert.destructiveOpenBullet2",'Sayfa kapanınca çanta <strong style="color:var(--text);">kalıcı olarak imha edilir</strong>')}</div> 89 <div style="padding:6px 0 4px;border-top:1px solid var(--border);margin-top:4px;">ð¡ ${r("cert.destructiveOpenBullet3",'Sertifika ve kanıt zinciri <strong style="color:var(--text);">korunur</strong>')}</div> 90 </div> 91 92 <div class="vr-pw-modal-field"> 93 <label class="vr-pw-modal-label" for="vrDestPwd">${r("encrypt.bagPassword","Ãanta Åifresi")}</label> 94 <input type="password" id="vrDestPwd" autocomplete="off" placeholder="${r("encrypt.enterPassword","Åifre girin")}" class="vr-pw-modal-input" /> 95 </div> 96 97 <div id="vrDestPwdError" role="alert" class="vr-pw-modal-error"></div> 98 99 <label style="display:flex;align-items:flex-start;gap:10px;padding:12px 14px;background:var(--surface);border:1px solid var(--border);border-radius:12px;cursor:pointer;margin-bottom:16px;"> 100 <input type="checkbox" id="vrDestAck" style="margin-top:2px;flex-shrink:0;width:16px;height:16px;accent-color:var(--accent);cursor:pointer;" /> 101 <span style="font-size:13px;line-height:1.5;color:var(--text);">${r("cert.destructiveOpenAck","Bu çantanın bir kez görüleceÄini ve <strong>geri alınamayacaÄını</strong> anladım.")}</span> 102 </label> 103 104 <button id="vrDestConfirm" type="button" disabled class="vr-pw-modal-submit" style="opacity:0.5;cursor:not-allowed;"> 105 <span id="vrDestConfirmLabel">${r("cert.destructiveOpenConfirm","Aç ve çantayı imha et")}</span> 106 </button> 107 </div> 108 `,document.body.appendChild(i);const o=i.querySelector("#vrDestPwd"),c=i.querySelector("#vrDestPwdError"),s=i.querySelector("#vrDestAck"),a=i.querySelector("#vrDestConfirm"),l=i.querySelector("#vrDestConfirmLabel"),d=i.querySelector("#vrDestCancel");let u=null;function p(h){a.disabled=!h,a.style.opacity=h?"1":"0.5",a.style.cursor=h?"pointer":"not-allowed"}function m(){u&&(clearInterval(u),u=null),l.textContent=r("cert.destructiveOpenConfirm","Aç ve çantayı imha et")}function b(){if(c.style.display="none",!(o.value.length>0&&s.checked)){m(),p(!1);return}m(),p(!1);let L=3;l.textContent=`${r("cert.destructiveOpenConfirm","Aç ve çantayı imha et")} (${L})`,u=setInterval(()=>{L-=1,L<=0?(clearInterval(u),u=null,o.value.length>0&&s.checked&&(l.textContent=r("cert.destructiveOpenConfirm","Aç ve çantayı imha et"),p(!0))):l.textContent=`${r("cert.destructiveOpenConfirm","Aç ve çantayı imha et")} (${L})`},1e3)}o.addEventListener("input",b),s.addEventListener("change",b);function g(h){u&&(clearInterval(u),u=null),i.remove(),n(h)}i.addEventListener("click",h=>{h.target===i&&g(null)}),e&&(c.textContent=e,c.style.display="block"),a.addEventListener("click",()=>{if(a.disabled)return;const h=o.value;l.textContent=r("dashboard.verifying","DoÄrulanıyor..."),g({password:h,consent:!0})}),d.addEventListener("click",()=>g(null)),i.addEventListener("keydown",h=>{h.key==="Escape"&&g(null)}),o.addEventListener("keypress",h=>{h.key==="Enter"&&!a.disabled&&a.click()}),o.focus()})}function st(t,e=null){return new Promise(n=>{document.querySelector(".vr-modal-backdrop[data-burn-kasa-open]")?.remove();const i=document.createElement("div");i.setAttribute("data-burn-kasa-open","1"),i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-label",r("cert.burnKasaPromptTitle","Åifreli Tek Görüntülemeli Link"));const o=b=>String(b||"").replace(/[<>&"]/g,g=>({"<":"<",">":">","&":"&",'"':"""})[g]),c=t?.name?o(t.name):r("cert.destructiveOpenNoName","Bu çanta");i.className="vr-modal-backdrop",i.innerHTML=` 109 <div class="vr-modal-card"> 110 <button id="vrBurnKasaCancel" class="bcv-seal-confirm-close vr-pw-modal-close" title="${r("common.close","Kapat")}" aria-label="${r("common.cancel","İptal")}">Ã</button> 111 112 <div class="vr-pw-modal-header"> 113 <div class="vr-pw-modal-icon">ð</div> 114 <h2 class="vr-pw-modal-title">${r("cert.burnKasaPromptTitle","Åifreli Tek Görüntülemeli Link")}</h2> 115 <p class="vr-pw-modal-subtitle">${c}<br/><span style="display:inline-block;margin-top:6px;font-size:12px;font-weight:600;letter-spacing:0.04em;color:var(--accent);">${r("cert.burnKasaPromptSubtitle","Tek seferlik açılır · Åifre doÄru olunca tüketilir")}</span></p> 116 </div> 117 118 <div style="background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:14px 16px;margin-bottom:20px;font-size:13px;line-height:1.55;color:var(--muted);"> 119 <div style="padding:4px 0;">ð ${r("cert.burnKasaPromptBullet1","Bu bir <strong>
119Åifreli Ãanta</strong> · Ãanta Åifresini girince link tek seferlik açılır")}</div> 120 <div style="padding:6px 0 4px;border-top:1px solid var(--border);margin-top:4px;">â» ${r("cert.burnKasaPromptBullet2","Åifre <strong>yanlıÅsa link tüketilmez</strong> · Tekrar deneyebilirsiniz")}</div> 121 <div style="padding:6px 0 4px;border-top:1px solid var(--border);margin-top:4px;">ð¡ ${r("cert.burnKasaPromptBullet3","İptal ederseniz link <strong>aktif kalır</strong> · İçerik korunur")}</div> 122 </div> 123 124 <div class="vr-pw-modal-field"> 125 <label class="vr-pw-modal-label" for="vrBurnKasaPwd">${r("encrypt.bagPassword","Ãanta Åifresi")}</label> 126 <input type="password" id="vrBurnKasaPwd" autocomplete="off" placeholder="${r("encrypt.enterPassword","Åifre girin")}" class="vr-pw-modal-input" /> 127 <p style="font-size:12px;color:var(--muted);margin:8px 2px 0;line-height:1.5;">${r("cert.burnKasaPromptPasswordHint","Ãanta Åifresi · DoÄru olana kadar link tüketilmez")}</p> 128 </div> 129 130 <div id="vrBurnKasaPwdError" role="alert" class="vr-pw-modal-error"></div> 131 132 <button id="vrBurnKasaConfirm" type="button" disabled class="vr-pw-modal-submit" style="opacity:0.5;cursor:not-allowed;"> 133 <span id="vrBurnKasaConfirmLabel">${r("cert.burnKasaPromptConfirm","Aç")}</span> 134 </button> 135 </div> 136 `,document.body.appendChild(i);const s=i.querySelector("#vrBurnKasaPwd"),a=i.querySelector("#vrBurnKasaPwdError"),l=i.querySelector("#vrBurnKasaConfirm"),d=i.querySelector("#vrBurnKasaCancel");function u(b){l.disabled=!b,l.style.opacity=b?"1":"0.5",l.style.cursor=b?"pointer":"not-allowed"}function p(){a.style.display="none",u(s.value.length>0)}s.addEventListener("input",p);function m(b){i.remove(),n(b)}i.addEventListener("click",b=>{b.target===i&&m(null)}),e&&(a.textContent=e,a.style.display="block"),l.addEventListener("click",()=>{if(l.disabled)return;const b=s.value;l.querySelector("#vrBurnKasaConfirmLabel").textContent=r("dashboard.verifying","DoÄrulanıyor..."),m({password:b,consent:!0})}),d.addEventListener("click",()=>m(null)),i.addEventListener("keydown",b=>{b.key==="Escape"&&m(null)}),s.addEventListener("keypress",b=>{b.key==="Enter"&&!l.disabled&&l.click()}),s.focus()})}function Re(t){return new Promise(e=>{const n=document.createElement("div");n.className="app-notif-overlay",n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("aria-label",r("bags.accessPassword","EriÅim Parolası")),n.innerHTML=` 137 <div class="app-notif vr-cert-pw-card"> 138 <div class="vr-cert-pw-header"> 139 <div class="vr-cert-pw-icon" aria-hidden="true">ð</div> 140 <h3 class="vr-cert-pw-title">${r("bags.accessPassword","EriÅim Parolası")}</h3> 141 <p class="vr-cert-pw-desc">${r("bags.enterSharePassword","Bu link parola korumalıdır. Devam etmek için parolayı girin.")}</p> 142 </div> 143 <div class="vr-cert-pw-field"> 144 <input type="password" id="vrSharePwInput" autocomplete="off" placeholder="${r("share.accessPassword","EriÅim parolası")}" class="vr-cert-pw-input" /> 145 </div> 146 <div id="vrSharePwError" role="alert" class="vr-cert-pw-error"></div> 147 <div class="vr-cert-pw-actions"> 148 <button id="vrSharePwCancel" class="app-notif-btn app-notif-btn-secondary vr-flex-1">${r("common.cancel","İptal")}</button> 149 <button id="vrSharePwSubmit" class="app-notif-btn app-notif-btn-primary vr-flex-1">${r("bags.continueShareLink","Devam et")}</button> 150 </div> 151 </div> 152 `,document.body.appendChild(n),requestAnimationFrame(()=>n.classList.add("show"));const i=n.querySelector("#vrSharePwInput"),o=n.querySelector("#vrSharePwSubmit"),c=n.querySelector("#vrSharePwCancel"),s=n.querySelector("#vrSharePwError");t&&(s.textContent=t,s.style.display="block"),i?.focus(),n.addEventListener("keydown",l=>{if(l.key==="Escape"){a(null);return}if(l.key!=="Tab")return;const d=n.querySelectorAll("input, button"),u=d[0],p=d[d.length-1];l.shiftKey&&document.activeElement===u?(l.preventDefault(),p.focus()):!l.shiftKey&&document.activeElement===p&&
152(l.preventDefault(),u.focus())});function a(l){n.classList.remove("show"),setTimeout(()=>n.remove(),250),e(l)}o.addEventListener("click",()=>{const l=i.value.trim();if(!l){s.textContent=r("encrypt.pleaseEnterPassword","Please enter a password"),s.style.display="block";return}a(l)}),c.addEventListener("click",()=>a(null)),i.addEventListener("keypress",l=>{l.key==="Enter"&&o.click()})})}function ne(t){return new Promise(e=>{let n=!1;const i=o=>{n||(n=!0,e(o))};try{if(window.firebase&&firebase.auth?firebase.auth().currentUser:null){i(!0);return}}catch{}if(window.showAuthModal){window.showAuthModal(function(){i(!0)});const o=()=>{let c=null;try{c=window.firebase&&firebase.auth?firebase.auth().currentUser:null}catch{}i(!!c)};document.addEventListener("vr-auth-modal-closed",o,{once:!0}),setTimeout(()=>{document.removeEventListener("vr-auth-modal-closed",o),i(!1)},12e4)}else showAppNotification("warning",r("bags.memberOnlyTitle","Login Required"),t?r("bags.memberOnlyPhoneRequired","This link is only available to SMS-verified members."):r("bags.memberOnlyLoginRequired","This link is only available to signed-in members."),{actionText:r("nav.signIn","Sign In"),onAction:()=>{location.reload()}}),i(!1)})}async function De(t,e,n,i){if(t)try{const o=i&&typeof i.getAuthHeaders=="function"?await i.getAuthHeaders():{...await q(),...D?{"X-Share-Token":D}:{}};o["Content-Type"]="application/json",await fetch(`/api/bags/${encodeURIComponent(t)}/track`,{method:"POST",headers:o,body:JSON.stringify({action:e,meta:{source:"receipt_page",...n}})})}catch(o){console.warn("[Cert] Tracking failed:",o.message||o)}}async function q(){try{const t=window.firebase&&firebase.auth?firebase.auth().currentUser:null;if(!t)return{};const e=await t.getIdToken();return e?{Authorization:`Bearer ${e}`}:{}}catch(t){return console.warn("[Cert] Auth header failed:",t.message||t),{}}}function I(t){if(!t)return!1;const e=(t.message||String(t)).toLowerCase(),n=(t.name||"").toLowerCase();return n==="aborterror"||e.includes("failed to fetch")||e.includes("load failed")||e.includes("network error")||e.includes("networkrequestfailed")||e.includes("connection refused")||e.includes("load timeout")||e.includes("yükleme uzun sürüyor")||e.includes("loading is taking too long")||n==="typeerror"&&(e.includes("fetch")||e.includes("network"))}function ct(t,e,n=!1){try{if(typeof window.__vrTrackJourneyEvent!="function")return;window.__vrTrackJourneyEvent("api_error",{action:t||"cert_connection_issue",message:(e||"").toString().slice(0,500)},{useBeacon:!!n,dedupeKey:`cert:${t||"connection"}`,minIntervalMs:3e4})}catch{}}function lt(t){return t?t.time_restricted&&(t.visible_from||t.visible_until)?r("cert.bagShellInactiveMessage","Bu link aktif deÄil. EriÅim için sahibiyle iletiÅime geçin."):t.requires_password?"ð "+r("cert.contentPasswordProtected","İçerik parola ile korunmaktadır."):t.requires_member?"ð¤ "+r("cert.contentMemberOnly","İçerik yalnızca doÄrulanmıŠüyelere açıktır. Görüntülemek için giriÅ yapın."):r("cert.verifyMetaPrivateHint","Bu çantanın içeriÄi gizlidir."):r("cert.verifyMetaPrivateHint","Bu çantanın içeriÄi gizlidir.")}async function M(t,e,n,i){if(i=i||{},t?.destructive_consumed_at&&n?.destructive!==!0&&(n={...n||{},destructive:!0,consumed_at:typeof t.destructive_consumed_at=="string"?t.destructive_consumed_at:n?.consumed_at||null}),R(!1),S(!1),y&&(y.style.display="none"),_&&(_.style.display="none"),T&&(T.style.display="none"),B&&(B.style.display="none"),!f)return;f.style.display="block",f.innerHTML="";const o=await A("public",{receiptId:e}),c=n?.destructive===!0;o.data={...t,name:c?null:r("cert.sealedDocument","Mühürlü Belge"),receipt_id:e,status:"sealed",hide_file_details:!0,hide_file_actions:!0,_restriction:n||null,...c?{encrypted:!1,sharing_open:!1,_destructive_consumed_view:!0,_destructive_consumed_at:n?.consumed_at||null}:{}},o.receiptId=e,o.bagId=null,o._usePreloadedCert=!0;try{if(o.render(),window.bagViewer=o,n&&!c&&!n.time_restricted&&(n.requires_password||n.requires_member||n.requires_destructive_consent)){const a=f.querySelector("#vrCertProofUnlockBtn");a&&a.addEventListener("click",l=>{if(l.preventDefault(),typeof i.onUnlock=="function"){i.onUnlock();return}if(n.requires_password)Ue(e,D||null);else{const d=window.firebase&&firebase.auth?firebase.auth().currentUser:null;n.requires_email_verification||d&&!d.emailVerified?N(n):He(e,D||null,
152n)}})}}catch(a){console.error("[cert] public cert render failed",a)}const s=f.querySelector(".bcv-panel");if(s&&n?.destructive!==!0&&(o.files?.length||0)>0){const a=n?.destructive===!0,l=document.createElement("div");l.className=a?"bcv-private-notice bcv-private-notice--destructive":"bcv-private-notice";const d=a?r("share.destructiveConsumedBanner","Bu çanta imha edildi. İçerik yok, kanıt zinciri korunuyor."):lt(n),u=a?r("cert.verifyProofTitle","Mühür DoÄrulandı"):r("cert.verifyProofTitle","Mühür DoÄrulandı"),p=a?'<svg width="20" height="20" viewBox="0 0 20 20" fill="none" aria-hidden="true"><path d="M10 2c-.4 0-.77.22-.95.58l-7 13.5A1.06 1.06 0 0 0 3 17.5h14a1.06 1.06 0 0 0 .95-1.42l-7-13.5A1.06 1.06 0 0 0 10 2Zm0 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 7Zm0 7.25a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z" fill="currentColor"/></svg>':'<svg width="20" height="20" viewBox="0 0 20 20" fill="none"><path d="M10 1.5a3.5 3.5 0 0 0-3.5 3.5v2h-1A1.5 1.5 0 0 0 4 8.5v8A1.5 1.5 0 0 0 5.5 18h9a1.5 1.5 0 0 0 1.5-1.5v-8A1.5 1.5 0 0 0 14.5 7h-1V5A3.5 3.5 0 0 0 10 1.5ZM8 5a2 2 0 1 1 4 0v2H8V5Zm2 6.25a1.25 1.25 0 0 1 .5 2.4V15a.5.5 0 0 1-1 0v-1.35A1.25 1.25 0 0 1 10 11.25Z" fill="currentColor"/></svg>';l.innerHTML=` 153 <div class="bcv-private-notice-icon"> 154 ${p} 155 </div> 156 <div class="bcv-private-notice-body"> 157 <span class="bcv-private-notice-seal">â ${u}</span> 158 <span class="bcv-private-notice-sep">·</span> 159 <span class="bcv-private-notice-msg">${d}</span> 160 </div> 161 `;const m=s.querySelector(".bcv-content");m?m.insertAdjacentElement("beforebegin",l):s.appendChild(l)}x(()=>`${r("cert.verifyProofTitle","Belge DoÄrulama")} â VerityRecord`)}function k(t,e,n){typeof document<"u"&&document.body&&document.body.classList.remove("vr-share-view"),R(!1),S(!1),y&&(y.style.display="none"),f&&(f.style.display="none"),B&&(B.style.display="none"),T&&(T.style.display="none"),_&&(_.style.display="flex"),_&&_.classList.remove("error-container--share","error-container--share-expired","error-container--share-limit","error-container--share-revoked","error-container--share-invalid"),j&&(j.textContent=t||r("cert.loadError","An error occurred while loading the document"));const i=(e||"").toString().toLowerCase(),o=(t||"").toString().toLowerCase();if((i.includes("connection")||i.includes("iletiÅim")||o.includes("connection")||o.includes("baÄlantı"))&&ct("cert_show_error_connection",t||e||"connection_error"),_){const c=_.querySelector(".error-title"),s=_.querySelector(".error-icon");e&&c&&(c.textContent=e),n&&s&&(s.textContent=n)}}async function Y(t){x(()=>`${r("share.destructiveConsumedTitle","Bu çanta 1 kere görüntülendi ve imha edildi")} â VerityRecord`);const e=t?.evidence||{},n=e.receipt_id||null,i={destructive:!0,consumed_at:t?.consumed_at||null};if(n)try{const s=await(await fetch(`/api/receipt/${encodeURIComponent(n)}`)).json();if(s?.ok&&s.receipt){await M(s.receipt,n,i);return}}catch(c){console.error("[cert] destructive consumed receipt fetch failed",c)}const o=e.transparency_log_url||(n?`/c/${n}`:null);yt({variant:"destroyed",svg:dt,title:r("share.destructiveConsumedTitle","Bu çanta 1 kere görüntülendi ve imha edildi"),message:r("share.destructiveConsumedDesc","İçerik imha edildi. Kanıt zinciri korunmaktadır."),modeBadges:[`<span class="bcv-badge bcv-badge-encrypted" style="background:rgba(107,114,128,0.12);color:#4b5563;border-color:rgba(107,114,128,0.25);">${r("encrypt.encryptedDestructiveBag","İmha Ãantası")}</span>`],sealUrl:o})}const dt=`<svg viewBox="0 0 24 24" width="64" height="64" fill="none" stroke="#6b7280" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> 162 <path d="M7 19 H17"/> 163 <path d="M9 19 Q12 13 15 19" opacity=".55"/> 164 <path d="M12 11 Q14.4 8.5 12 6 Q9.6 3.5 12.4 1.5" stroke-width="1.5" opacity=".7"/> 165</svg>`;function ut(){R(!1),S(!1),y&&(y.style.display="none"),_&&(_.style.display="none"),B&&(B.style.display="none"),T&&(T.style.display="none")}function K(t){if(ut(),!f)return!1;f.style.display="block";const{variant:e,badgesHtml:n,sealedIso:i,metaExtraHtml:o,bodyHtml:c,sealUrl:s,phi:a=!0,onBag:l=!1,ghost:d=!1}=t||{},u=[];i&&u.push(`<span>${Ce(i,void 0,{withSeconds:!0})}</span>`),o&&u.push(o);const p=u.join('<span class="bcv-meta-sep"></span>'),m=s?(s.split("/c/")[1]||s.split("/").pop()||"").split(/[?#]/)[0]:"",b=s&&m?`<div class="bcv-cert-section bcv-cert-section--inline"> 166 <button type="button" class="bcv-cert-toggle" id="vrShellCertToggle" aria-expanded="false" aria-controls="vrShellCertBody"> 167 <div class="bcv-cert-toggle-left"> 168 <img class="vr-foot-logo" src="/icon-192.png" alt="VerityRecord" loading="lazy" />
169 <span class="bcv-cert-toggle-label">${r("bags.sealCertificate","Mühür Sertifikası")}</span> 170 </div> 171 <span class="bcv-cert-toggle-hint" id="vrShellCertHintText">${r("common.show","Göster")}</span> 172 </button> 173 <div class="bcv-certificate-body" id="vrShellCertBody" hidden></div> 174 </div>`:"";return f.innerHTML=` 175 <div class="bcv-panel-wrapper bcv-shell-state${d?" bcv-shell-state--ghost":""}"> 176 <div class="bcv-panel${a?" bcv-shell--phi":""}${d?" bcv-shell--ghost":""}"> 177 <div class="bcv-header"> 178 <div class="bcv-header-left"> 179 <div class="bcv-title-row">${n||""}</div> 180 <div class="bcv-meta">${p}</div> 181 </div> 182 </div> 183 <div class="bcv-content"> 184 <div class="bcv-content-encrypted-locked vr-encrypted-locked vr-encrypted-locked--${e}${l?" vr-encrypted-locked--onbag":""}"> 185 <div class="vr-encrypted-locked-inner">${c||""}</div> 186 </div> 187 </div> 188 ${b} 189 </div> 190 </div> 191 `,s&&m&&pt(m),!0}function pt(t){const e=f.querySelector("#vrShellCertToggle"),n=f.querySelector("#vrShellCertBody"),i=f.querySelector("#vrShellCertHintText");if(!e||!n)return;let o=!1,c=!1;e.addEventListener("click",async()=>{if(e.getAttribute("aria-expanded")==="true"){e.classList.remove("is-open"),e.setAttribute("aria-expanded","false"),n.hidden=!0,i&&(i.textContent=r("common.show","Göster"));return}if(e.classList.add("is-open"),e.setAttribute("aria-expanded","true"),n.hidden=!1,i&&(i.textContent=r("common.hide","Gizle")),!(o||c)){c=!0,n.innerHTML=`<div class="bcv-cert-inline-msg">${r("common.loading","Yükleniyorâ¦")}</div>`;try{const l=await(await fetch(`/api/receipt/${encodeURIComponent(t)}/verify-meta`)).json();l?.ok&&l.receipt?(n.innerHTML=ft(l.receipt),o=!0):n.innerHTML=`<div class="bcv-cert-inline-msg">${r("cert.loadError","Sertifika yüklenemedi.")}</div>`}catch{n.innerHTML=`<div class="bcv-cert-inline-msg">${r("cert.loadError","Sertifika yüklenemedi.")}</div>`}finally{c=!1}}})}function ft(t){const e=d=>String(d??"").replace(/[&<>"]/g,u=>({"&":"&","<":"<",">":">",'"':"""})[u]),n=(d,u=8,p=6)=>(d=String(d||""),d.length>u+p+1?`${d.slice(0,u)}â¦${d.slice(-p)}`:d||"â"),i=t.sealed_at?Ce(t.sealed_at,void 0,{withSeconds:!0}):"â",o=t.ed25519_valid===!0?!0:t.ed25519_valid===!1?!1:t.signature_valid===void 0?null:t.signature_valid,c=o===!0?` <span class="bcv-cc-ok">â ${r("cert.valid","Geçerli")}</span>`:o===!1?` <span class="bcv-cc-bad">${r("cert.invalid","Geçersiz")}</span>`:t.signature_state==="unverifiable_legacy_key"?` <span class="bcv-cc-warn">${r("cert.legacyKeyEra","DoÄrulanamıyor â eski imza anahtarı")}</span>`:"",s=t.tsa?t.tsa.tsa_verified===void 0?null:t.tsa.tsa_verified:null,a=s===!0?` <span class="bcv-cc-ok">â ${r("cert.tsaVerified","TSA DoÄrulandı")}</span>`:s===!1?` <span class="bcv-cc-bad">${r("cert.invalid","Geçersiz")}</span>`:"",l=!!(t.encrypted||t.encryption_version);return` 192 <div class="bcv-cert-grid"> 193 <div class="bcv-cc-cell"><span class="bcv-cc-k">${r("cert.sealedAt","Mühür tarihi")}</span><span class="bcv-cc-v">${e(i)}</span></div> 194 <div class="bcv-cc-cell"><span class="bcv-cc-k">${r("cert.contentHash","İçerik Ãzeti")} (SHA3-256)</span><span class="bcv-cc-v bcv-cc-mono">${e(n(t.merkle_root))}</span></div> 195 <div class="bcv-cc-cell"><span class="bcv-cc-k">${r("cert.digitalSignature","Dijital İmza")}</span><span class="bcv-cc-v bcv-cc-mono">${e(n(t.receipt_signature))}${c}</span></div> 196 <div class="bcv-cc-cell"><span class="bcv-cc-k">${r("cert.tsa","Zaman Damgası Otoritesi")}</span><span class="bcv-cc-v">RFC 3161${a}</span></div> 197 <div class="bcv-cc-cell"><span class="bcv-cc-k">${r("cert.encryption","Åifreleme")}</span><span class="bcv-cc-v">${l?`ð ${r("dashboard.vault","Åifreli Ãanta")}`:`<span class="bcv-cc-muted">${r("cert.encNone","Yok")}</span>`}</span></div> 198 <div class="bcv-cc-cell"><span class="bcv-cc-k">${r("cert.receiptId","Belge Kodu")}</span><span class="bcv-cc-v bcv-cc-mono">${e(t.short_id||"â")}</span></div> 199 </div>`}function yt(t){const{variant:e,svg:n,title:i,message:o,modeBadges:c,sealUrl:s}=t||{};K({variant:e,badgesHtml:(c||[]).join(""),bodyHtml:` 200 <div class="vr-encrypted-locked-icon vr-encrypted-locked-icon--bag-shell">${n}</div> 201 <h2 class="vr-encrypted-locked-title">${i||""}</h2> 202 <p class="vr-encrypted-locked-desc">${o||""}</p>`,sealUrl:s,ghost:!0})}const Pe=new Set(["NOT_DESTRUCTIVE","WRONG_ENDPOINT","NOT_BURN_LINK","NOT_ENCRYPTED","LINK_REVOKED","LINK_EXPIRED"]);function Me(t){showAppNotification("info",r("cert.shareStateChangedTitle","PaylaÅım ayarı deÄiÅti"),r("cert.shareStateChangedMsg","Sayfa güncel duruma yenileniyor."),{duration:3500}),W(t)}const vt={cancelled:{iconSvg:'<svg viewBox="0 0 24 24" width="64" height="64" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/>
202<line x1="12" y1="16" x2="12.01" y2="16"/></svg>',badgeKey:"cert.shareCancelledBadge",badgeFallback:"İptal"},expired:{iconSvg:'<svg viewBox="0 0 24 24" width="64" height="64" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 2h12"/><path d="M6 22h12"/><path d="M6 2v6a6 6 0 0 0 12 0V2"/><path d="M6 22v-6a6 6 0 0 1 12 0v6"/></svg>',badgeKey:"cert.shareExpiredBadge",badgeFallback:"Süresi doldu"},limit:{iconSvg:'<svg viewBox="0 0 24 24" width="64" height="64" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="13" r="8"/><path d="M12 9v4l2 2"/><path d="M5 3 2 6"/><path d="M22 6l-3-3"/></svg>',badgeKey:"cert.shareLimitBadge",badgeFallback:"Oturum bitti"},revoked:{iconSvg:'<svg viewBox="0 0 24 24" width="64" height="64" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/><path d="M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"/></svg>',badgeKey:"cert.shareRevokedBadge",badgeFallback:"Kaldırıldı"},invalid:{iconSvg:'<svg viewBox="0 0 24 24" width="64" height="64" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',badgeKey:"cert.shareInvalidBadge",badgeFallback:"Geçersiz"}};function qe(t,e){const n=vt[t];if(!n)return;const{title:i,message:o,modeBadgeHtml:c,retryLabel:s,onRetry:a,sealEvidence:l}=e||{},d=`<span class="bcv-badge bcv-badge-state--${t}">${r(n.badgeKey,n.badgeFallback)}</span>`,u=s&&typeof a=="function"?`<button type="button" class="btn btn-primary vr-encrypted-locked-btn" id="vrShareRetryBtn">${s}</button>`:"";K({variant:t,badgesHtml:`${c||""}${d}`,bodyHtml:` 203 <div class="vr-encrypted-locked-icon vr-encrypted-locked-icon--svg">${n.iconSvg}</div> 204 <h2 class="vr-encrypted-locked-title">${i||""}</h2> 205 <p class="vr-encrypted-locked-desc">${o||""}</p> 206 ${u}`,sealUrl:l?.transparency_log_url||null,onBag:!0})&&u&&f.querySelector("#vrShareRetryBtn")?.addEventListener("click",a)}function mt(t){qe("cancelled",{title:r("cert.burnKasaCancelledTitle","İÅlem iptal edildi"),message:r("cert.burnKasaCancelledMsg","Link hâlâ aktif, istediÄinizde tekrar deneyebilirsiniz."),modeBadgeHtml:`<span class="bcv-badge bcv-badge-encrypted">ð ${r("encrypt.encrypted","Åifreli Ãanta")}</span><span class="bcv-badge bcv-badge-encrypted" style="background:rgba(168,85,247,0.12);color:#9333ea;">ð ${r("bags.singleView","Tek görüntü")}</span>`,retryLabel:r("cert.shareLinkCancelledRetry","Tekrar Aç"),onRetry:()=>W(t)})}async function Ve(t,e,n){const i=()=>ge(t,e,n),o=e?.seal_evidence?.transparency_log_url||null,c=o?(o.split("/c/")[1]||o.split("/").pop()||"").split(/[?#]/)[0]:"";if(c)try{const l=await(await fetch(`/api/receipt/${encodeURIComponent(c)}/verify-meta`)).json().catch(()=>null),d=l?.ok&&l.receipt?l.receipt:null;if(d&&(d.receipt_id||d.short_id)){await M(d,d.receipt_id||d.short_id,{requires_destructive_consent:!0},{onUnlock:i});return}}catch{}K({variant:"destructive",badgesHtml:`<span class="bcv-badge bcv-badge-encrypted" style="background:rgba(239,68,68,0.12);color:#dc2626;">ð¥ ${r("encrypt.encryptedDestructiveBag","İmha Ãantası")}</span>`,sealedIso:e?.bag_preview?.sealed_at||null,bodyHtml:` 207 <div class="vr-encrypted-locked-icon">ð¥</div> 208 <h2 class="vr-encrypted-locked-title">${r("encrypt.encryptedDestructiveBag","İmha Ãantası")}</h2> 209 <p class="vr-encrypted-locked-desc">${r("encrypt.fileListEncryptedDestructive","Bu çanta İmha Ãantası olarak paylaÅılmıÅtır. Açıldıktan sonra içerik kalıcı olarak imha edilecek. Görüntülemek için çanta Åifresini girin.")}</p> 210 <button type="button" class="btn btn-primary vr-encrypted-locked-btn" id="vrDestructiveOpenBtn">${r("bags.unlockBag","Åifreyi Ãöz")}</button>`,sealUrl:e?.seal_evidence?.transparency_log_url||null,onBag:!0})&&f.querySelector("#vrDestructiveOpenBtn")?.addEventListener("click",()=>{ge(t,e,n)})}async function ge(t,e,n){const i=e.bag_preview?.encryption_preview||null;if(!i?.salt){k(r("cert.destructiveNoPreview","İmha Ãantası meta bilgisi alınamadı. Linki tekrar deneyin."));return}let o=null;for(;;){const c=await ot(e.bag_preview||null,o);if(!c)return;try{const s=F.fromHex(i.salt),{keyCheck:a,cryptoKey:l}
210=await F.computeKeyCheckAndDeriveKey(c.password,s),d=await fetch(`${n}/destructive-consume`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key_check:a,consent:!0})}),u=await d.json();if(!d.ok||!u.ok){if(u?.code==="WRONG_PASSWORD"){o=r("cert.destructiveOpenWrongPassword","Åifre yanlıÅ. Tekrar deneyin.");continue}if(u?.code==="BAG_DESTROYED"){Y(u);return}if(Pe.has(u?.code)){Me(t);return}k(u?.error||r("cert.loadError","Yüklenemedi."));return}window.__vrDestructivePreUnlock={cryptoKey:l,keyCheck:a,encryptionParams:u.destructive_artifacts?.encryption_params||null,encryptedMetadata:u.destructive_artifacts?.encrypted_metadata||null,accessToken:u.access_token||null,accessTokenExpiresAtMs:Number(u.expires_at_ms||0)},await z(u,t,u.session_token||null);return}catch(s){console.error("[Cert/Destructive] verify error:",s),k(r("cert.loadError","Yüklenemedi."));return}}}const ue={password:'<svg width="60" height="60" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="8" r="3.6" fill="currentColor" fill-opacity=".16"/><path d="M10.6 10.6 L19 19"/><path d="M16.1 16.1 L18.3 13.9"/><path d="M18.5 18.5 L20.1 16.9"/></svg>
210',member:'<svg width="60" height="60" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9" fill="currentColor" fill-opacity=".16"/><circle cx="12" cy="10" r="2.7"/><path d="M7 17.5 a5 4.4 0 0 1 10 0"/></svg>',email:'<svg width="60" height="60" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5.5" width="18" height="13" rx="2.4" fill="currentColor" fill-opacity=".16"/><path d="M3.6 6.9 L12 12.8 L20.4 6.9"/><circle cx="18.4" cy="17.6" r="4.2" fill="currentColor" fill-opacity=".16"/><path d="M16.5 17.6 l1.4 1.4 l2.6 -2.9" stroke-width="1.8"/></svg>'};async function pe(t,e,n,i,o){const c=()=>{if(typeof o=="function"){o();return}we(t,e,n,i)},s=e?.seal_evidence?.transparency_log_url||null,a=s?(s.split("/c/")[1]||s.split("/").pop()||"").split(/[?#]/)[0]:"";if(a)try{const u=await(await fetch(`/api/receipt/${encodeURIComponent(a)}/verify-meta`)).json().catch(()=>null),p=u?.ok&&u.receipt?u.receipt:null;if(p&&(p.receipt_id||p.short_id)){await M(p,p.receipt_id||p.short_id,{requires_password:!0},{onUnlock:c});return}}catch{}K({variant:"password",badgesHtml:`<span class="bcv-badge bcv-badge-encrypted"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:3px"><circle cx="8" cy="8" r="3.6" fill="currentColor" fill-opacity=".16"/><path d="M10.6 10.6 L19 19"/><path d="M16.1 16.1 L18.3 13.9"/><path d="M18.5 18.5 L20.1 16.9"/></svg>${r("bags.accessPassword","EriÅim Parolası")}</span>`,sealedIso:e?.bag_preview?.sealed_at||null,bodyHtml:` 211 <div class="vr-encrypted-locked-icon vr-encrypted-locked-icon--svg" style="color:#7c3aed">${ue.password}</div> 212 <h2 class="vr-encrypted-locked-title">${r("cert.contentPasswordProtected","İçerik parola ile korunmaktadır.")}</h2> 213 <p class="vr-encrypted-locked-desc">${r("bags.enterSharePassword","Bu link parola korumalıdır. Devam etmek için parolayı girin.")}</p> 214 <button type="button" class="btn btn-primary vr-encrypted-locked-btn" id="vrPasswordGateBtn">${r("bags.continueShareLink","Devam et")}</button>`,sealUrl:e?.seal_evidence?.transparency_log_url||null,onBag:!0})&&f.querySelector("#vrPasswordGateBtn")?.addEventListener("click",()=>{if(typeof o=="function"){o();return}we(t,e,n,i)})}async function we(t,e,n,i){let o=null;for(;;){const c=await Re(o);if(!c)return;const s={...i||{},"X-Share-Password":c};let a,l;try{a=await fetch(n,{headers:s}),l=await a.json()}catch(d){console.error("[Cert/PasswordGate] fetch error:",d),I(d)?k(r("cert.connectionError","Connection lost. Check your connection and try again."),r("cert.connectionErrorTitle","Connection lost")):k(r("cert.loadError","Failed to load certificate."));return}if(l.ok){await z(l,t,l.session_token||null,c);return}if(l.requires_password){o=r("bags.wrongPassword","Wrong password. Please try again.");continue}if(l?.code==="BAG_DESTROYED"){Y(l);return}if(l.requires_member){const d=window.firebase&&firebase.auth?firebase.auth().currentUser:null;if(l.requires_email_verification||d&&!d.emailVerified){N(l);return}ie(t,l,async()=>{const u=!!l.requires_phone_verification;if(!await ne(u))return;const m=await q();m["X-Share-Password"]=c;let b,g;try{b=await fetch(n,{headers:m}),g=await b.json().catch(()=>({}))}catch(h){console.error("[Cert/PasswordGate] member re-fetch error:",h),k(r("cert.loadError","Failed to load certificate."));return}if(g.ok){await z(g,t,g.session_token||null,c);return}if(g.requires_email_verification){N(g);return}H(g)});return}H(l);return}}async function ie(t,e,n){const i=()=>{if(typeof n=="function"){n();return}ke(t,e)},o=e?.seal_evidence?.transparency_log_url||null,c=o?(o.split("/c/")[1]||o.split("/").pop()||"").split(/[?#]/)[0]:"";if(c)try{const u=await(await fetch(`/api/receipt/${encodeURIComponent(c)}/verify-meta`)).json().catch(()=>null),p=u?.ok&&u.receipt?u.receipt:null;if(p&&(p.receipt_id||p.short_id)){await M(p,p.receipt_id||p.short_id,{requires_member:!0,requires_phone_verification:!!e.requires_phone_verification},{onUnlock:i});return}}catch{}const a=!!e.requires_phone_verification?r("bags.memberOnlyPhoneRequired","This link is only available to SMS-ver
214ified members."):r("cert.memberLoginNotice","Sign in is required to view this content.");K({variant:"member",badgesHtml:`<span class="bcv-badge bcv-badge-encrypted"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:3px"><circle cx="12" cy="12" r="9" fill="currentColor" fill-opacity=".16"/><circle cx="12" cy="10" r="2.7"/><path d="M7 17.5 a5 4.4 0 0 1 10 0"/></svg>${r("bags.memberOnlyVerified","Sadece Ãyeler")}</span>`,sealedIso:e?.bag_preview?.sealed_at||null,bodyHtml:` 215 <div class="vr-encrypted-locked-icon vr-encrypted-locked-icon--svg" style="color:#7c3aed">${ue.member}</div> 216 <h2 class="vr-encrypted-locked-title">${r("bags.memberOnlyTitle","GiriÅ Gerekli")}</h2> 217 <p class="vr-encrypted-locked-desc">${a}</p> 218 <button type="button" class="btn btn-primary vr-encrypted-locked-btn" id="vrMemberGateBtn">${r("nav.signIn","GiriÅ Yap")}</button>`,sealUrl:e?.seal_evidence?.transparency_log_url||null,onBag:!0})&&f.querySelector("#vrMemberGateBtn")?.addEventListener("click",()=>{if(typeof n=="function"){n();return}ke(t,e)})}async function ke(t,e){const n=!!e.requires_phone_verification;await ne(n)&&W(t)}function ht(t,e,n){pe(null,n,null,null,()=>Ue(t,e))}async function Ue(t,e){let n=null;for(;;){const i=await Re(n);if(!i)return;const o=await q();e&&(o["X-Share-Token"]=e),o["X-Share-Password"]=i;let c,s;try{c=await fetch(`/api/receipt/${encodeURIComponent(t)}`,{headers:o,cache:"no-store"}),s=await c.json().catch(()=>({}))}catch(a){console.error("[Cert/RidPasswordGate] fetch error:",a),I(a)?k(r("cert.connectionError","Connection lost. Check your connection and try again."),r("cert.connectionErrorTitle","Connection lost")):k(r("cert.loadError","Failed to load certificate."));return}if(c.ok){X=!1,window.__vrRidSharePassword=i,ae();return}if(s.requires_password){n=r("bags.wrongPassword","Wrong password. Please try again.");continue}if(s?.code==="BAG_DESTROYED"){Y(s);return}if(s.requires_member){X=!1,window.__vrRidSharePassword=i;const a=window.firebase&&firebase.auth?firebase.auth().currentUser:null;s.requires_email_verification||a&&!a.emailVerified?N(s):Ne(t,e,s);return}H(s);return}}function Ne(t,e,n){ie(null,n,()=>He(t,e,n))}async function He(t,e,n){const i=!!n.requires_phone_verification;await ne(i)&&ae()}async function N(t){const e=()=>{window.open("/dashboard","_blank")},n=t?.seal_evidence?.transparency_log_url||null,i=n?(n.split("/c/")[1]||n.split("/").pop()||"").split(/[?#]/)[0]:"";if(i)try{const s=await(await fetch(`/api/receipt/${encodeURIComponent(i)}/verify-meta`)).json().catch(()=>null),a=s?.ok&&s.receipt?s.receipt:null;if(a&&(a.receipt_id||a.short_id)){await M(a,a.receipt_id||a.short_id,{requires_member:!0,requires_email_verification:!0},{onUnlock:e});return}}catch{}K({variant:"member",badgesHtml:`<span class="bcv-badge bcv-badge-encrypted"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:3px"><circle cx="12" cy="12" r="9" fill="currentColor" fill-opacity=".16"/><circle cx="12" cy="10" r="2.7"/><path d="M7 17.5 a5 4.4 0 0 1 10 0"/></svg>${r("bags.memberOnlyVerified","Sadece Ãyeler")}</span>`,sealedIso:t?.bag_preview?.sealed_at||null,bodyHtml:` 219 <div class="vr-encrypted-locked-icon vr-encrypted-locked-icon--svg" style="color:#7c3aed">${ue.email}</div> 220 <h2 class="vr-encrypted-locked-title">${r("cert.emailVerifyTitle","E-posta doÄrulaması gerekli")}</h2> 221 <p class="vr-encrypted-locked-desc">${r("cert.emailVerifyMsg","Bu içerik yalnızca doÄrulanmıŠüyelere açıktır. Hesabınızın e-postası henüz doÄrulanmamıÅ. DoÄruladıktan sonra bu sayfayı yenileyin.")}</p> 222 <button type="button" class="btn btn-primary vr-encrypted-locked-btn" id="vrEmailVerifyBtn">${r("cert.emailVerifyAction","E-postamı doÄrula")}</button>`,sealUrl:t?.seal_evidence?.transparency_log_url||null,onBag:!0})&&f.querySelector("#vrEmailVerifyBtn")?.addEventListener("click",()=>{window.open("/dashboard","_blank")})}function Oe(){if(typeof document<"u"&&document.body&&document.body.classList.remove("vr-share-view"),R(!1),S(!1),y&&(y.style.display="none"),_&&(_.style.display="none"),B&&(B.style.display="none"),T&&(T.style.display="none"),!f)return;f.style.display="block";const t=r("cert.linkUnavailableTitle","Bu baÄlantı eriÅilebilir deÄil"),e=r("cert.linkUnavailableMessage","BaÄlantının doÄru olduÄunu düÅünüyorsanız sahibine baÅvurun."),n=r("cert.linkUnavailableVerify","Belge kodunuz varsa verityrecord.com/c/ adresinden doÄrulayabilirsiniz.");x(()=>`${r("cert.linkUnavailableTitle","Bu baÄlantı eriÅilebilir deÄil")} â VerityRecord`),f.innerHTML=` 223 <div class="vr-neutral-note vr-link-unavailable"> 224 <h2 class="vr-neutral-note-title">${t}</h2> 225 <p class="vr-neutral-note-desc">${e}</p> 226 <p class="vr-neutral-note-verify vr-link-unavailable-verify">${n}</p> 227 </div> 228 `}function je(){if(typeof document<"u"&&document.body&&document.body.classList.remove("vr-share-view"),R(!1),S(!1),y&&(y.style.display="none"),_&&(_.style.display="none"),B&&(B.style.display="none"),!f)return;f.style.display="block";const t=r("cert.takedownTitle","Bu kayıt eriÅime kapatıldı"),e=r("cert.takedownDesc","Bu kayıt, kötüye kullanım bildirimi üzerine yönetim tarafından eriÅime kapatılmıÅtır. Kriptografik kayıt izi korunmaktadır.");x(()=>`${t} â VerityRecord`),f.innerHTML=` 229 <div class="vr-neutral-note vr-content-takedown"> 230 <h2 class="vr-neutral-note-title">${t}</h2> 231 <p class="vr-neutral-note-desc">${e}</p> 232 </div> 233 `}function ze(){if(window.__vrAbuseCode)return window.__vrAbuseCode;const t=location.pathname.match(/^\/c\/([^/]+)/);return t?decodeURIComponent(t[1]):""}function re(){const t=document.getElementById("vrAbuseReportLink");if(!ze()){t&&t.remove();return}if(t)return;const e=document.createElement("button");e.id="vrAbuseReportLink",e.type="button",e.className="vr-abuse-report-link",e.textContent="â "+r("abuse.reportLink","İçeriÄi bildir"),e.addEventListener("click",bt),document.body.appendChild(e)}function bt(){let t=document.getElementById("vrAbuseModal");if(t){t.style.display="flex";return}const e=a=>String(a||"").replace(/[<>&"]/g,l=>({"<":"<",">":">","&":"&",'"':"""})[l]),n=ze(),i=(window.__vrAbuseBagName||"").toString().trim(),o=!!(window.firebase?.auth?.()&&firebase.auth().currentUser);t=document.createElement("div"),t.id="vrAbuseModal",t.className="vr-abuse-modal-overlay";const c=[["copyright",r("abuse.catCopyright","Telif / fikri mülkiyet ihlali")],["privacy",r("abuse.catPrivacy","Gizlilik / kiÅisel veri")],["illegal",r("abuse.catIllegal","YasadıÅı içerik")],["csam",r("abuse.catCsam","Ãocuk istismarı içeriÄi (acil)")],["fraud",r("abuse.catFraud","Dolandırıcılık / kimlik taklidi")],["other",r("abuse.catOther","DiÄer")]],s=o?"":` 234 <label class="vr-abuse-label">${e(r("abuse.emailLabel","E-posta (isteÄe baÄlı, dönüŠiçin)"))} 235 <input type="email" id="vrAbuseEmail" class="vr-abuse-input" maxlength="200" autocomplete="email" /> 236 </label>`;t.innerHTML=` 237 <div class="vr-abuse-modal" role="dialog" aria-modal="true" aria-labelledby="vrAbuseTitle"> 238 <h3 class="vr-abuse-modal-title" id="vrAbuseTitle">${e(r("abuse.modalTitle","İçerik bildirimi"))}</h3> 239 <div class="vr-abuse-target">
240 <span class="vr-abuse-target-label">${e(r("abuse.reportedBag","Bildirilen çanta"))}</span> 241 <span class="vr-abuse-target-value">${i?e(i)+" · ":""}<code>${e(n)}</code></span> 242 </div> 243 <label class="vr-abuse-label">${e(r("abuse.categoryLabel","Kategori"))} 244 <select id="vrAbuseCategory" class="vr-abuse-input"> 245 ${c.map(([a,l])=>`<option value="${a}">${e(l)}</option>`).join("")} 246 </select> 247 </label> 248 <label class="vr-abuse-label">${e(r("abuse.detailsLabel","Açıklama"))} <span class="vr-abuse-optional">${e(r("abuse.optionalHint","(isteÄe baÄlı)"))}</span> 249 <textarea id="vrAbuseDetails" class="vr-abuse-input" rows="4" maxlength="2000" placeholder="${e(r("abuse.detailsPlaceholder2","Sorunu kısaca açıklayabilirsiniz"))}"></textarea> 250 </label> 251 ${s} 252 <input type="text" id="vrAbuseHp" name="website" class="vr-abuse-hp" tabindex="-1" autocomplete="off" aria-hidden="true" /> 253 <div id="vrAbuseMsg" class="vr-abuse-msg" aria-live="polite"></div> 254 <div class="vr-abuse-actions"> 255 <button type="button" class="vr-abuse-btn-cancel" id="vrAbuseCancel">${e(r("abuse.cancel","Vazgeç"))}</button> 256 <button type="button" class="vr-abuse-btn-submit" id="vrAbuseSubmit">${e(r("abuse.submit","Gönder"))}</button> 257 </div> 258 </div>`,document.body.appendChild(t),t.addEventListener("click",a=>{a.target===t&&(t.style.display="none")}),t.querySelector("#vrAbuseCancel")?.addEventListener("click",()=>{t.style.display="none"}),t.querySelector("#vrAbuseSubmit")?.addEventListener("click",async()=>{const a=t.querySelector("#vrAbuseMsg"),l=t.querySelector("#vrAbuseSubmit"),d=t.querySelector("#vrAbuseCategory")?.value||"other",u=t.querySelector("#vrAbuseDetails")?.value?.trim()||"",p=t.querySelector("#vrAbuseHp")?.value?.trim()||"",m={code:n,category:d,details:u,reporter_email:t.querySelector("#vrAbuseEmail")?.value?.trim()||"",lang:window._currentLang==="tr"?"tr":"en",hp:p};if(p){a&&(a.textContent=r("abuse.sent","Bildiriminiz alındı. TeÅekkürler.")),setTimeout(()=>{t.style.display="none"},1200);return}if(!m.code){a&&(a.textContent=r("abuse.error","Gönderilemedi. Lütfen tekrar deneyin."));return}if(d==="other"&&u.length<10){a&&(a.textContent=r("abuse.validationOther",'"DiÄer" için lütfen en az 10 karakterlik bir açıklama girin.'));return}try{l.disabled=!0;const b=await fetch("/api/abuse-reports",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)}),g=await b.json().catch(()=>({}));b.ok&&g.ok?(a&&(a.textContent=r("abuse.sent","Bildiriminiz alındı. TeÅekkürler.")),setTimeout(()=>{t.style.display="none"},1800)):b.status===429?a&&(a.textContent=r("abuse.rateLimited","Ãok sık bildirim gönderildi. Lütfen daha sonra deneyin.")):a&&(a.textContent=g?.error||r("abuse.error","Gönderilemedi. Lütfen tekrar deneyin."))}catch{a&&(a.textContent=r("abuse.error","Gönderilemedi. Lütfen tekrar deneyin."))}finally{l.disabled=!1}})}function H(t){const e=(t?.code||"").toString().toUpperCase();if(e==="CONTENT_TAKEDOWN"){je(),re();return}if(e==="SESSION_EXPIRED"){qe("limit",{title:r("cert.sessionExpiredTitle","Görüntüleme oturumunuz sona erdi"),message:r("cert.sessionExpiredDesc","Görüntüleme oturumunuz sona erdi. GüvenliÄiniz için içerik artık görüntülenemez. Yeni bir link için sahibine baÅvurun."),sealEvidence:t?.seal_evidence});return}Oe()}function Ke(){Oe()}async function gt(t,e){if(!(!t||!e))try{if(!(window.firebase&&firebase.auth?firebase.auth().currentUser:null))return;const i=await q();if(!i.Authorization||!(await fetch(`/api/bags/${encodeURIComponent(t)}`,{headers:i,cache:"no-store"})).ok||e.querySelector(".bcv-owner-share-banner"))return;const c=p=>String(p||"").replace(/[<>&"]/g,m=>({"<":"<",">":">","&":"&",'"':"""})[m]),s=document.createElement("div");s.className="bcv-owner-share-banner";const a=r("cert.ownerShareBanner","Bu sizin çantanız"),l=r("cert.ownerShareBannerLink","Yönetim panelinde aç"),d=`/upload#bag/${encodeURIComponent(t)}`;s.innerHTML=`<span class="bcv-owner-share-banner-text">${c(a)}</span> <a href="${d}" class="bcv-owner-share-banner-link">${c(l)}</a>`;const u=e.querySelector(".bcv-panel");u?u.insertBefore(s,u.firstChild):e.insertBefore(s,e.firstChild)}catch(n){console.warn("[Cert/OwnerBanner] check failed:",n?.message||n)}}const _e="vr-guest-conv-dismissed";function wt(t){try{if(!t||(window.firebase&&firebase.auth?firebase.auth().currentUser:null))return;try{if(localStorage.getItem(_e)==="1")return}catch{}if(t.querySelector(".bcv-guest-conv-bar"))return;const n=o=>String(o||"").replace(/[<>&"]/g,c=>({"<":"<",">":">","&":"&",'"':"""})[c]),i=document.createElement("div");i.className="bcv-guest-conv-bar",i.setAttribute("aria-label",r("share.convTitle","Sen de içeriÄini kanıtla")),i.innerHTML=`
259 <span class="bcv-guest-conv-ico" aria-hidden="true"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><path d="M5 12.5V7a7 7 0 0 1 14 0v5.5"/><rect x="4" y="12.5" width="16" height="8.5" rx="2"/></svg></span> 260 <div class="bcv-guest-conv-txt"> 261 <div class="bcv-guest-conv-title">${n(r("share.convTitle","Sen de içeriÄini kanıtla"))}</div> 262 <div class="bcv-guest-conv-sub">${n(r("share.convEyebrow","Bu kayıt VerityRecord ile mühürlendi"))}</div> 263 </div> 264 <a class="bcv-guest-conv-btn" href="/upload">${n(r("share.convCta","Kendi çantanı oluÅtur"))}</a> 265 <button type="button" class="bcv-guest-conv-x" aria-label="${n(r("common.close","Kapat"))}">×</button>`,t.insertBefore(i,t.firstChild),i.querySelector(".bcv-guest-conv-x")?.addEventListener("click",()=>{try{localStorage.setItem(_e,"1")}catch{}i.remove()})}catch(e){console.warn("[Cert/GuestConv] inject failed:",e?.message||e)}}async function z(t,e,n,i){const o=t.bag;if(!o||!o.receipt_id){k(r("cert.noDocMatchCode","No sealed document found."));return}_&&(_.style.display="none"),T&&(T.style.display="none"),B&&(B.style.display="none");const c=await A("public",{receiptId:o.receipt_id,shareToken:e||null,shareSession:n||null,sharePassword:i||null}),s=!!t.burn_after_reading;if(t.burned,s){S(!1),y.style.display="none",f.style.display="block",f.innerHTML="";const a=document.createElement("div");if(a.className="bcv-burn-gate",a.innerHTML=` 266 <div class="bcv-burn-gate-card"> 267 <h2 class="bcv-burn-gate-title">${r("cert.singleViewGateTitle","Tek Görüntülemeli Link")}</h2> 268 <p class="bcv-burn-gate-desc">${r("cert.singleViewGateDesc","Sekmeyi kapatırsan bu link bir daha açılmaz.")}</p> 269 <button type="button" class="btn btn-primary bcv-burn-gate-btn" id="bcvBurnGateAccept">${r("cert.singleViewGateAccept","İçeriÄi Göster")}</button> 270 </div> 271 `,f.appendChild(a),await new Promise(l=>{a.querySelector("#bcvBurnGateAccept")?.addEventListener("click",()=>{a.remove(),l()})}),f.innerHTML="",n&&e){const l=`/api/share-links/${encodeURIComponent(e)}/close`,d=JSON.stringify({session_token:n}),u=()=>{try{if(navigator.sendBeacon){const p=new Blob([d],{type:"application/json"});navigator.sendBeacon(l,p)}else fetch(l,{method:"POST",headers:{"Content-Type":"application/json"},body:d,keepalive:!0}).catch(()=>{})}catch{}};window.addEventListener("beforeunload",u,{once:!1})}}try{const a=window.__vrBurnKasaPreUnlock;if((t.destructive===!0||!!a)&&t.bag&&Array.isArray(t.files)){c.data=t.bag,c.receiptId=o.receipt_id,c.bagId=t.bag.id||o.id||null,c.files=t.files;const d=window.__vrDestructivePreUnlock||a;if(d?.cryptoKey&&c.data?.encrypted){if(c.encryptionSession=c.encryptionSession||{},c.encryptionSession.unlocked=!0,c.encryptionSession.decryptKey=d.cryptoKey,c.encryptionSession.encryptionVersion=c.data.encryption_version||"2",d.accessToken&&(c.encryptionSession.accessToken=d.accessToken,c.encryptionSession.accessTokenExpiresAtMs=d.accessTokenExpiresAtMs||0),d.encryptionParams&&(c.data.encryption_params=d.encryptionParams),d.encryptedMetadata)try{const u=await F.decryptMetadata(d.cryptoKey,d.encryptedMetadata);c.encryptionSession.decryptedMetadata=u,u&&u.length>0&&typeof c._applyDecryptedMetadata=="function"&&c._applyDecryptedMetadata()}catch(u){console.warn("[Destructive] metadata decrypt failed",u)}else console.warn("[Destructive cert-inline] encrypted_metadata missing from preUnlock snapshot â recipient will see fallback filenames");try{delete window.__vrDestructivePreUnlock}catch{}try{delete window.__vrBurnKasaPreUnlock}catch{}}}else{const d={...await q()};n?d["X-Share-Session"]=n:e&&(d["X-Share-Token"]=e),i&&(d["X-Share-Password"]=i);const u=await fetch(`/api/receipt/${encodeURIComponent(o.receipt_id)}`,{headers:d}),p=await u.json().catch(()=>({}));if(!u.ok&&(p?.code==="SESSION_EXPIRED"||p?.code==="CONTENT_TAKEDOWN")){S(!1),y.style.display="none",H(p);return}if(u.ok&&p.ok&&p.receipt){c.data={...p.receipt,name:p.receipt.bag_name??p.receipt.name??null},c.receiptId=o.receipt_id,c.bagId=p.receipt?.bag_id||o.id||null,c.files=p.receipt?.files||p.receipt?.meta?.files||[];const m=p.is_owner===!0,b=c.data?.encrypted===!0||c.data?.encryption_version==="1"||c.data?.encryption_version==="2";if(m&&b){const g=h=>({id:h.id,mime_type:h.mime_type?"application/octet-stream":void 0,is_link:h.is_link,sha3_256:h.sha3_256,position:h.position});c.data.name=null,c.data.bag_name=null,c.data.file_count=null,c.data.total_bytes=null,c.data.meta&&typeof c.data.meta=="object"&&(c.data.meta={...c.data.meta,bag_name:null,file_count:null,total_bytes:null,files:Array.isArray(c.data.meta.files)?c.data.meta.files.map(g):c.data.meta.files}),c.files=Array.isArray(c.files)?c.files.map(g):[]}}else await c.load()}if(S(!1),y.style.display="none",f.style.display="block",c.render(),x(()=>`${c.getBagName()} â VerityRecord`),s){const d=document.createElement("div");d.className="bcv-burn-banner",d.innerHTML=`<span class="bcv-burn-banner-text">${r("cert.singleViewBanner","Tek görüntülemeli link. Bu sekme açık olduÄu sürece içeriÄi inceleyebilirsiniz; baÅka kimse aynı linkle eriÅemez.")}</span>`;const u=f.querySelector(".bcv-panel");u?u.insertBefore(d,u.firstChild):f.insertBefore(d,f.firstChild)}De(o.id,"viewed",void 0,c),gt(o.id||null,f),wt(f)}catch(a){console.error("[Cert/ShareLink] Viewer error:",a),I(a)?k(r("cert.connectionError","Connection lost. Check your connection and try again."),r("cert.connectionErrorTitle","Connection lost")):k(r("cert.loadError","Failed to load certificate."))}}async function W(t){try{await ce(3e3);const e=await q(),n=`/api/share-links/${encodeURIComponent(t)}`,i=10;for(let o=0;o<i;o++){const c={...e},a=await(await fetch(n,{headers:c})).json();if(a.ok){await z(a,t,a.session_token||null,null);return}if(a.requires_destructive_consent){Ve(t,a,n);return}if(a.requires_burn_kasa_consent){const l=a.bag_preview?.encryption_preview||null;if(!l?.salt){k(r("cert.burnKasaNoPreview","Åifreli link meta bilgisi alınamadı. Linki tekrar deneyin."));return}let d=null;for(;;){const u=await st(a.bag_preview||null,d);if(!u){showAppNotification("info",r("cert.burnKasaCancelledTitle","İÅlem iptal edildi"),r("cert.burnKasaCancelledMsg","Link hâlâ aktif, istediÄinizde tekrar deneyebilirsiniz."),{duration:4e3}),mt(t);return}try{const p=F.fromHex(l.salt),{keyCheck:m,cryptoKey:b}
271=await F.computeKeyCheckAndDeriveKey(u.password,p),g=await fetch(`${n}/confirm-view`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key_check:m,consent:!0})}),h=await g.json();if(!g.ok||!h.ok){if(h?.code==="WRONG_PASSWORD"){d=r("cert.burnKasaWrongPassword","Åifre yanlıŠ· Link hâlâ aktif, tekrar deneyin");continue}if(h?.code==="LINK_BURNED"){H(h);return}if(Pe.has(h?.code)){Me(t);return}k(h?.error||r("cert.loadError","Yüklenemedi."));return}window.__vrBurnKasaPreUnlock={cryptoKey:b,keyCheck:m,encryptionParams:h.encryption_artifacts?.encryption_params||null,encryptedMetadata:h.encryption_artifacts?.encrypted_metadata||null,accessToken:h.access_token||null,accessTokenExpiresAtMs:Number(h.expires_at_ms||0)},await z(h,t,h.session_token||null);return}catch(p){console.error("[Cert/BurnKasa] verify error:",p),k(r("cert.loadError","Yüklenemedi."));return}}}if(a.requires_password){pe(t,a,n,e);return}if(a.requires_member){const l=window.firebase&&firebase.auth?firebase.auth().currentUser:null;if(a.requires_email_verification||l&&!l.emailVerified){N(a);return}ie(t,a);return}if(a?.code==="BAG_DESTROYED"){Y(a);return}H(a);return}k(r("cert.loadError","Failed to load certificate."))}catch(e){console.error("[Cert/ShareLink] Error:",e),I(e)?k(r("cert.connectionError","Connection lost. Check your connection and try again."),r("cert.connectionErrorTitle","Connection lost")):k(r("cert.loadError","Failed to load certificate."))}}async function kt(t,e=null){const n=window.__vrRidSharePassword||null,i=await q();e&&(i["X-Share-Token"]=e),n&&(i["X-Share-Password"]=n);const o=new AbortController,c=setTimeout(()=>o.abort(),25e3);let s,a={};try{s=await fetch(`/api/receipt/${encodeURIComponent(t)}`,{headers:i,signal:o.signal,cache:"no-store"}),clearTimeout(c),a=await s.json().catch(()=>({}))}catch(l){throw clearTimeout(c),l.name==="AbortError"?new Error(r("cert.loadTimeout","Yükleme uzun sürüyor. Sayfayı yenileyip tekrar deneyin.")):l}if(s.ok){window.__vrRidSharePassword=n||null,window.__vrAbuseCode=a?.receipt?.short_id||a?.short_id||t,window.__vrAbuseBagName=a?.receipt?.bag_name||a?.receipt?.name||"";try{re()}catch{}return{ok:!0,response:s,data:a,password:n||null}}if(a?.code==="CONTENT_TAKEDOWN")return je(),re(),{ok:!1,response:s,data:a,gateRendered:!0};if(a?.requires_password)return X?{ok:!1,response:s,data:a}:(ht(t,e,a),{ok:!1,response:s,data:a,gateRendered:!0});if(a?.time_restricted){const l=a.visible_from?new Date(a.visible_from).toLocaleDateString(navigator.language||"tr-TR",{day:"numeric",month:"long",year:"numeric"}):null;a.visible_until&&new Date(a.visible_until).toLocaleDateString(navigator.language||"tr-TR",{day:"numeric",month:"long",year:"numeric"});const d=l?r("cert.notYetAvailable","This document will be available from")+" "+l:r("cert.noLongerAvailable","This document is no longer available.");return{ok:!1,response:s,data:a,time_restricted:!0,time_message:d}}if(a?.requires_member){if(X)return{ok:!1,response:s,data:a};const l=window.firebase&&firebase.auth?firebase.auth().currentUser:null;return a.requires_email_verification||l&&!l.emailVerified?N(a):Ne(t,e,a),{ok:!1,response:s,data:a,gateRendered:!0}}return{ok:!1,response:s,data:a}}function _t(t){let e=document.getElementById("vrSimBanner");e||(e=document.createElement("div"),e.id="vrSimBanner",e.style.cssText="position:fixed;top:0;left:0;right:0;z-index:99999;background:#7c3aed;color:#fff;font:600 12px/1.5 system-ui,sans-serif;padding:6px 12px;text-align:center;box-shadow:0 1px 8px rgba(0,0,0,.35);letter-spacing:.2px",document.body.appendChild(e),document.body.style.paddingTop="32px"),e.textContent="𧪠SİMÃLASYON â "+(t.label||t.id)+" · "+(t.canonRef||"")+" ("+(t.status||"")+")"}async function Ct(t){try{typeof y<"u"&&y&&(y.style.display="none");try{S(!1)}catch{}_t(t);const e=t.data||{};switch(t.kind){case"deny":H(e);break;case"deleted":Ke();break;case"destroyed":await Y(e);break;case"destructive_consent":Ve("SIM",e,"/api/share-links/SIM");break;case"password":pe("SIM",e,"/api/share-links/SIM",{});break;case"member_signin":ie("SIM",e);break;case"member_verify":N(e);break;case"content":e.demoShareToken?await W(e.demoShareToken):e.demoRid?await z({ok:!0,bag:{receipt_id:e.demoRid}},"SIM",null,null):k("Bu senaryo gerçek içerik gerektirir â cert-sim-scenarios.js
271içinde demoRid veya demoShareToken doldurun + backend (deploy/emulator) gerekir (Faz 2).","Sim: içerik (Faz 2)","ð");break;default:k("Bilinmeyen simülasyon türü: "+t.kind,"Sim hatası","â ï¸")}}catch(e){k("Sim render hatası: "+(e&&e.message?e.message:String(e)),"Sim hatası","â ï¸")}}async function St(t){window.CERT_SIM_SCENARIOS||await new Promise((i,o)=>{const c=document.createElement("script");c.src="/js/cert-sim-scenarios.js?ts="+Date.now(),c.onload=i,c.onerror=()=>o(new Error("cert-sim-scenarios.js yüklenemedi")),document.head.appendChild(c)}).catch(i=>{k(i.message,"Sim hatası","â ï¸")});const n=(window.CERT_SIM_SCENARIOS||[]).find(i=>i.id===t);if(!n){k("Bilinmeyen simülasyon senaryosu: "+t,"Sim hatası","â ï¸");return}await Ct(n)}async function Et(){const t=$.get("sim");if(t){await St(t);return}R(!1);try{if(D&&!ee&&!U&&!te){await W(D);return}let e=ee;if(e&&!Ee(e))throw new Error(r("cert.invalidDocFormat","Invalid document code format"));if(U&&!et(U)&&!le(U))throw new Error(r("cert.invalidHashFormat","Invalid hash format"));if(te&&!ee){const l={},d=new AbortController,u=setTimeout(()=>d.abort(),25e3);try{const p=await fetch(`/api/receipt/by-short/${encodeURIComponent(te)}`,{headers:l,signal:d.signal});if(clearTimeout(u),p.ok)e=(await p.json()).receipt_id,window.history.replaceState({},"",`/cert.html?rid=${encodeURIComponent(e)}`);else throw new Error(r("cert.noDocMatchCode","No sealed document found matching this code"))}catch(p){throw clearTimeout(u),p.name==="AbortError"?new Error(r("cert.loadTimeout","Yükleme uzun sürüyor. Sayfayı yenileyip tekrar deneyin.")):p}}if(U&&!e){const l={},d=new AbortController,u=setTimeout(()=>d.abort(),25e3);try{const p=await fetch(`/api/receipt/by-hash/${encodeURIComponent(U)}`,{headers:l,signal:d.signal});if(clearTimeout(u),p.ok)e=(await p.json()).receipt_id,window.history.replaceState({},"",`/cert.html?rid=${encodeURIComponent(e)}`);else throw new Error(r("cert.noDocMatchHash","No sealed document found matching this hash"))}catch(p){throw clearTimeout(u),p.name==="AbortError"?new Error(r("cert.loadTimeout","Yükleme uzun sürüyor. Sayfayı yenileyip tekrar deneyin.")):p}}if(!e){if(xe){y&&(y.style.display="");return}if(Te){try{await Le()}catch(l){y&&(y.style.display="none"),I(l)?k(r("cert.connectionError","Connection lost. Check your connection and try again."),r("cert.connectionErrorTitle","Connection lost")):k(r("cert.loadError","Yüklenemedi."))}return}try{await it()}catch(l){y&&(y.style.display="none"),I(l)?k(r("cert.connectionError","Connection lost. Check your connection and try again."),r("cert.connectionErrorTitle","Connection lost")):k(r("cert.loadError","Yüklenemedi."))}return}await ce();const n=await kt(e,D||null),i=n.response,o=n.data||{};if(!n.ok){if(n.gateRendered){y&&(y.style.display="none");return}if(n.cancelled){y.style.display="none",k(r("cert.accessDenied","Access Denied"),r("cert.accessDenied","Access Denied"),"ð");return}const l=o||null;try{const p=await fetch(`/api/receipt/${encodeURIComponent(e)}/verify-meta`,{cache:"no-store"}),m=await p.json().catch(()=>({}));if(p.ok&&m.ok&&m.receipt){y.style.display="none",await M(m.receipt,e,l);return}}catch(p){console.warn("[cert] verify-meta fallback failed",p?.message)}y.style.display="none";const d=r("cert.errorMessage","The seal certificate you are looking for could not be found. Please check the link."),u=o?.error||o?.message||d;k(u,r("cert.errorTitle","Document Not Found"));return}if(o.unavailable&&o.reason==="deleted"){y.style.display="none",Ke();return}const c=o.is_owner&&o.receipt?.bag_id;if(c){R(!0),Ie(),y&&(y.style.display="none"),f.style.display="block",f.innerHTML="",S(!1),await de(c,{preflightReceipt:o.receipt||null,receiptId:e});return}if(X&&!o.is_owner&&o.receipt?.encrypted===!0)try{const l=await fetch(`/api/receipt/${encodeURIComponent(e)}/verify-meta`,{cache:"no-store"}),d=await l.json().catch(()=>({}));if(l.ok&&d.ok&&d.receipt){y.style.display="none",await M(d.receipt,e,null);return}}catch(l){console.warn("[cert] proof verify-meta failed",l?.message)}const s=await A("public",{receiptId:e,shareToken:D||null,sharePassword:n.password||null});try{await s.load()}catch(l){throw y.style.display="none",l}S(!1),y.style.display="none",f.style.display="block",s.render(),s.data?.encrypted&&s.mode==="public"&&!s._encryptionUnlocked&&await s.promptForPassword(),x(()=>`${s.getBagName()} â VerityRecord`);const a=s.data?.bag_id||s.data?.id;De(a,"viewed",void 0,s)}
271catch(e){console.error("[Cert] Error:",e),I(e)?k(r("cert.connectionError","Connection lost. Check your connection and try again."),r("cert.connectionErrorTitle","Connection lost")):k(r("cert.loadError","Sertifika yüklenemedi."))}}const Bt=15e3;function ae(){if(y){y.style.display="flex";const o=y.querySelector(".loading-text");o&&(o.textContent=r("cert.loading","Mühür belgesi yükleniyor..."))}_&&(_.style.display="none"),f&&(f.style.display="none");let t=null;const e=Et().then(function(){t&&clearTimeout(t),typeof window._vrClearFallback=="function"&&window._vrClearFallback()}),n=function(){return!!(document.querySelector(".vr-modal-backdrop")||document.querySelector(".app-notif-overlay")||document.querySelector(".auth-modal-overlay")||document.querySelector('[role="dialog"]'))},i=new Promise(function(o,c){t=setTimeout(function(){n()||c(new Error(r("cert.loadTimeout","Yükleme uzun sürüyor. Sayfayı yenileyip tekrar deneyin.")))},Bt)});return Promise.race([e,i]).catch(function(o){t&&clearTimeout(t),typeof window._vrClearFallback=="function"&&window._vrClearFallback(),!n()&&(y&&(y.style.display="none"),I(o)?k(r("cert.connectionError","BaÄlantı kesildi. BaÄlantınızı kontrol edip Tekrar Dene ile yenileyin."),r("cert.connectionErrorTitle","İletiÅim kesildi")):k(o?.message||String(o)))})}window.retryCertLoad=function(){ae()};ae();try{re()}catch{}$.get("print")==="1"&&window.addEventListener("load",function(){setTimeout(function(){window.bagViewer&&window.bagViewer.printCertificate?window.bagViewer.printCertificate():window.print()},1500)});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.