PageSourceSearch

https://upflix.pl/dist/react/releases/60e03420cdf5d4a5ede9d6881ae4…/chunks/NativeCommentsApp-803862a7.js

js upflix.pl collected 2026-10-02 12:11:34 UTC 15,050 bytes, 1 lines download raw bytes

1import{aa as ne,j as t,ab as se,b as m,c as o,u as oe,F as H,ac as re}from"../index.js";function ee({url:r}){const z=ne("avatar");return t("img",{className:"comments-avatar",src:r||z,alt:"",width:40,height:40,onError:i=>se(i.currentTarget,z)},r||z)}const A={body:"",spoiler:!1};function le({draft:r,onChange:z,onSubmit:i,onCancel:L,busy:u,submitting:P,viewerName:F,viewerAvatar:Z,recipient:$}){const E=m.exports.useRef(null);m.exports.useEffect(()=>{var w;(r.parentId||r.id)&&((w=E.current)==null||w.focus())},[r.parentId,r.id]);function R(w){const f=E.current;if(!f)return;const g=f.selectionStart,p=f.selectionEnd,T=r.body.slice(g,p)||"tekst",s=r.body.slice(0,g)+w+T+w+r.body.slice(p);s.length>5e3||(z({...r,body:s}),requestAnimationFrame(()=>{f.focus(),f.setSelectionRange(g+w.length,g+w.length+T.length)}))}return o("form",{className:`comments-composer${r.parentId?" comments-composer--reply":""}`,onSubmit:w=>{w.preventDefault(),i()},children:[o("div",{className:"comments-author",children:[t(ee,{url:Z}),t("strong",{children:F})]}),o("label",{className:"comments-draft-label",children:[r.id?"Edytuj komentarz":$?`Odpowied\u017A do ${$}`:"Tw\xF3j komentarz",t("textarea",{ref:E,placeholder:"Podziel si\u0119 swoj\u0105 opini\u0105\u2026",value:r.body,maxLength:5e3,required:!0,disabled:u,rows:4,onChange:w=>z({...r,body:w.target.value})})]}),o("div",{className:"comments-composer-tools",children:[o("div",{className:"comments-formatting",role:"group","aria-label":"Narz\u0119dzia komentarza",children:[t("button",{type:"button",title:"Pogrubienie","aria-label":"Pogrubienie",disabled:u,onClick:()=>R("**"),children:t("strong",{children:"B"})}),t("button",{type:"button",title:"Kursywa","aria-label":"Kursywa",disabled:u,onClick:()=>R("*"),children:t("em",{children:"I"})}),t("button",{type:"button",title:"Oznacz ca\u0142y komentarz jako spoiler","aria-pressed":r.spoiler,disabled:u,onClick:()=>z({...r,spoiler:!r.spoiler}),children:"Spoiler"})]}),o("span",{className:"comments-counter",children:[r.body.length," / 5000"]})]}),o("div",{className:"comments-composer-actions",children:[o("button",{className:"comments-submit","aria-busy":P,disabled:u||!r.body.trim(),children:[P&&t("span",{className:"comments-spinner","aria-hidden":"true"}),P?"Wysy\u0142anie\u2026":"Zapisz"]}),t("button",{type:"button",disabled:u,onClick:L,children:"Anuluj"})]})]})}function de({container:r,showAuthorControls:z=!1}){var Q,Y;const[i,L]=m.exports.useState(null),[u,P]=m.exports.useState("target"),[F,Z]=m.exports.useState([]),[$,E]=m.exports.useState(null),[R,w]=m.exports.useState({}),[f,g]=m.exports.useState(A),[p,T]=m.exports.useState(!1),[s,X]=m.exports.useState(null),[te,ae]=m.exports.useState(null),{enqueueSnackbar:B}=oe(),O=m.exports.useRef(!1),D=m.exports.useRef(new Set),q=m.exports.useRef(new Map),y=m.exports.useRef(!0),C=Number((Q=r.dataset.viewer)!=null?Q:0),ie=r.dataset.viewerName||"Ty",M=r.dataset.writable==="1",j=!!(f.id||f.parentId),U={targetType:(Y=r.dataset.type)!=null?Y:"",targetId:Number(r.dataset.targetId)};async function J(e,a={}){var l;const n=new AbortController;D.current.add(n);const c=setTimeout(()=>n.abort(),15e3);try{const h={...a,signal:n.signal,credentials:"same-origin",cache:"no-store"};let k=await fetch(e,h);if(k.status===400&&a.method==="POST"){const b=await fetch("/csrf-token",{signal:n.signal,credentials:"same-origin",cache:"no-store",headers:{Accept:"application/json"}});if(b.ok){const x=await b.json();if(typeof x.token=="string"&&x.token){const N=document.querySelector('meta[name="csrf-token"]');N&&(N.content=x.token);const d=new Headers(a.headers);d.set("X-CSRF-Token",x.token),k=await fetch(e,{...h,headers:d})}}}if(!k.ok){const b={401:"Zaloguj si\u0119 ponownie.",403:"Ta operacja nie jest dost\u0119pna dla Twojego konta.",404:"Komentarz nie jest ju\u017C dost\u0119pny.",409:"Komentarz zosta\u0142 zmieniony. Od\u015Bwie\u017C dyskusj\u0119 przed edycj\u0105.",428:"Zaakceptuj aktualny regulamin w ustawieniach konta.",429:"Zbyt wiele operacji. Spr\xF3buj ponownie p\xF3\u017Aniej.",503:"Publikowanie jest chwilowo wy\u0142\u0105czone."};throw new Error((l=b[k.status])!=null?l:`Nie uda\u0142o si\u0119 wykona\u0107 operacji (${k.status}).`)}return await k.json()}finally{clearTimeout(c),D.current.delete(n)}}async function S(e=u,a,n){const c=new URLSearchParams({scope:n?"replies":e,targetType:U.targetType,targetId:String(U.targetId)});a&&c.set("cursor",a),n&&c.set("id",String(n));const l=await J(`/comment/data?${c}`);!y.current||(e==="blocks"&&!n?(Z(h=>a?[...h,...l.items]:l.items),E(l.nextCursor)):n?w(h=>{var b,x,N,d;const k=(d=(N=(b=h[n])==null?void 0:b.items)!=null?N:(x=i==null?void 0:i.items.find(K=>K.id===n))==null?void 0:x.replyPreview)!=null?d:[];return{...h,[n]:{...l,items:a?[...k,...l.items]:l.items}}}):L(h=>{var k;return{...l,items:a?[...(k=h==null?void 0:h.items)!=null?k:[],...l.items]:l.items}}))}async function v(e,a={kind:"action"}){if(!O.current){O.current=!0,T(!0),X(a);try{await e()}catch(n){y.current&&B(n instanceof Error&&n.name!=="AbortError"&&!(n instanceof TypeError)?n.message:"Nie otrzymano odpowiedzi. Spr\xF3buj ponownie.",{variant:"error"})}finally{O.current=!1,y.current&&(T(!1),X(null))}}}async function I(e,a){var h,k,b;const n=JSON.stringify({operation:e,...a}),c=(h=q.current.get(n))!=null?h:re();q.current.set(n,c);const l=await J("/comment/mutate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-CSRF-Token":(b=(k=document.querySelector('meta[name="csrf-token"]'))==null?void 0:k.content)!=null?b:"","Idempotency-Key":c},body:n});if(!y.current)return l;q.current.delete(n);try{await S(),w({})}catch{y.current&&B("Zapisano zmian\u0119, ale nie uda\u0142o si\u0119 od\u015Bwie\u017Cy\u0107 listy. Od\u015Bwie\u017C stron\u0119.",{variant:"warning"})}return l}m.exports.useEffect(()=>{y.current=!0;const e=/^#comment-([0-9]{1,30})$/.exec(location.hash);return e&&location.replace(`/comment/legacy?sourceId=${e[1]}`),v(()=>S("target"),{kind:"initial"}),()=>{y.current=!1,D.current.forEach(a=>a.abort())}},[]),m.exports.useEffect(()=>{var a;const e=(a=r.parentElement)==null?void 0:a.querySelector("[data-comments-ssr]");return e&&i&&(e.hidden=!0),()=>{e&&(e.hidden=!1)}},[!!i]),m.exports.useEffect(()=>{var e;if(i&&u==="target"){const a=(e=r.parentElement)==null?void 0:e.querySelector("h2");a&&(a.textContent=`Komentarze (${i.publicCount})`)}},[i==null?void 0:i.publicCount,u]);function V(e){return o("div",{className:"comments-body",children:[e.content.map((a,n)=>a.type==="link"&&a.url&&/^https?:\/\//i.test(a.url)?t("a",{href:a.url,rel:"ugc nofollow noopener noreferrer",children:a.text},n):a.type==="strong"?t("strong",{children:a.text},n):a.type==="em"?t("em",{children:a.text},n):t("span",{children:a.text},n)),e.media.map(a=>t("img",{src:a.url,alt:"Za\u0142\u0105cznik do komentarza",loading:"lazy",style:{maxWidth:"100%"}},a.url))]})}function _(e,a=!1,n){var N;const c=R[e.id],l=(N=c==null?void 0:c.items)!=null?N:e.replyPreview,h=Math.max(0,e.replyCount-l.length),k=(s==null?void 0:s.kind)==="like"&&s.id===e.id,b=e.likes+e.legacyLikes,x=t("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:e.liked?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:t("path",{d:"M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1.1-1.1a5.5 5.5 0 0 0-7.8 7.8L12 21l8.8-8.6a5.5 5.5 0 0 0 0-7.8Z"})});return o("article",{id:`comment-${e.id}
1`,tabIndex:-1,className:`comments-entry${a?" comments-entry--reply":""}${te===e.id?" comments-entry--highlighted":""}`,children:[o("div",{className:"comments-author",children:[t(ee,{url:e.author.avatarUrl}),o("div",{className:"comments-author-info",children:[t("strong",{children:e.author.profileUrl&&e.status!=="deleted"?t("a",{href:e.author.profileUrl,children:e.author.name}):e.author.name}),t("time",{dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleString("pl",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})})]})]}),e.parentId&&e.parentId!==n&&o("div",{className:"comments-parent-context",children:[o("a",{href:`/comment/permalink?id=${e.parentId}`,title:"Przejd\u017A do wpisu, na kt\xF3ry odpowiada ten komentarz",onClick:d=>{if(d.ctrlKey||d.metaKey||d.shiftKey||d.altKey)return;const K=r.querySelector(`#comment-${e.parentId}`);K&&(d.preventDefault(),ae(e.parentId),K.scrollIntoView({block:"center"}),K.focus({preventScroll:!0}))},children:["\u21B3 ",e.parentContext?`W odpowiedzi do: ${e.parentContext.name}`:"Odpowied\u017A na niedost\u0119pny komentarz"]}),e.parentContext&&t("p",{children:e.parentContext.excerpt})]}),e.status==="deleted"?t("p",{children:"Komentarz usuni\u0119ty."}):e.spoiler?o("details",{"data-nosnippet":!0,children:[t("summary",{children:"Poka\u017C spoiler"}),V(e)]}):V(e),e.status==="pending"&&t("p",{className:"comments-notice",children:"Oczekuje na moderacj\u0119."}),o("footer",{className:"comments-actions",children:[o("a",{href:e.permalink,className:"comments-permalink",title:"Link do tego komentarza","aria-label":"Link do tego komentarza",children:[t("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",focusable:"false",children:t("path",{d:"M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-2 2M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l2-2"})}),"Link"]}),C>0&&M&&e.status==="published"&&!e.canDelete?o("button",{className:"comments-likes","aria-label":e.liked?"Cofnij polubienie":"Lubi\u0119",title:`${e.liked?"Cofnij polubienie":"Lubi\u0119"} \xB7 Polubienia: ${b}`,"aria-pressed":e.liked,"aria-busy":k,disabled:p||j,onClick:()=>void v(()=>I(e.liked?"unlike":"like",{id:e.id}),{kind:"like",id:e.id}),children:[k?t("span",{className:"comments-spinner","aria-hidden":"true"}):x,t("span",{"aria-label":`Polubienia: ${b}`,children:b})]}):o("span",{className:"comments-likes","aria-label":`Polubienia: ${b}`,children:[x," ",b]}),C>0&&M&&o(H,{children:[u==="target"&&(i==null?void 0:i.canPost)&&t("button",{disabled:p,onClick:()=>g({...A,parentId:e.id}),children:"Odpowiedz"}),e.canEdit&&t("button",{disabled:p,onClick:()=>g({id:e.id,version:e.version,body:e.body,spoiler:e.spoiler}),children:"Edytuj"}),e.canDelete&&t("button",{disabled:p||j,onClick:()=>{confirm("Usun\u0105\u0107 tre\u015B\u0107 komentarza? Odpowiedzi pozostan\u0105.")&&v(()=>I("delete",{id:e.id}))},children:"Usu\u0144"}),e.status!=="deleted"&&t("button",{disabled:p||j,onClick:()=>{const d=prompt("Pow\xF3d zg\u0142oszenia (maks. 1000 znak\xF3w)");d!=null&&d.trim()&&v(async()=>{await I("report",{id:e.id,reason:d}),y.current&&B("Zg\u0142oszenie przekazano moderatorom.",{variant:"success"})})},children:"Zg\u0142o\u015B"}),z&&!e.canDelete&&e.status!=="deleted"&&t("button",{disabled:p||j,onClick:()=>void v(()=>I("block",{id:e.author.id})),children:"Ukryj autora"})]})]}),(f.parentId===e.id||f.id===e.id)&&G(e.author.name),!a&&l.map(d=>_(d,!0,e.id)),!a&&h>0&&(!c||c.nextCursor)&&t("button",{className:"comments-more",disabled:p,onClick:()=>void v(()=>{var d;return S(u,(d=c==null?void 0:c.nextCursor)!=null?d:l.length?String(l[l.length-1].id):void 0,e.id)},{kind:"more",id:e.id}),children:(s==null?void 0:s.kind)==="more"&&s.id===e.id?"\u0141adowanie odpowiedzi\u2026":`Poka\u017C kolejne odpowiedzi (${h})`})]},e.id)}function G(e){return t(le,{draft:f,viewerName:ie,viewerAvatar:r.dataset.viewerAvatar,recipient:e,busy:p,submitting:(s==null?void 0:s.kind)==="submit",onChange:g,onCancel:()=>g(A),onSubmit:()=>void v(async()=>{const a=await I(f.id?"edit":"create",{...U,...f});!y.current||(g(A),B((a==null?void 0:a.status)==="pending"?"Komentarz czeka na akceptacj\u0119. Znajdziesz go w \u201EMoje komentarze\u201D.":"Zapisano komentarz.",{variant:"success"}))},{kind:"submit"})})}function W(e,a=!1){var n;return o("div",{className:`comments-skeleton-entry${a?" comments-skeleton-entry--reply":""}`,"aria-hidden":"true",children:[o("div",{className:"comments-author",children:[t("span",{className:"comments-skeleton-avatar"}),o("div",{className:"comments-skeleton-meta",children:[t("span",{}),t("span",{})]})]}),t("div",{className:"comments-skeleton-body",children:Array.from({length:Math.min(6,Math.max(2,Math.ceil(((n=e==null?void 0:e.body.length)!=null?n:120)/80)))},(c,l)=>t("span",{},l))}),o("div",{className:"comments-skeleton-actions",children:[t("span",{}),t("span",{}),t("span",{}),t("span",{})]}),!a&&(e==null?void 0:e.replyPreview.map(c=>t("div",{children:W(c,!0)},c.id)))]})}return o("div",{className:"comments-interactive",children:[o("div",{className:"comments-loading",role:"status","aria-live":"polite",hidden:(s==null?void 0:s.kind)!=="initial",children:[t("span",{className:"comments-spinner","aria-hidden":"true"}),"\u0141adowanie\u2026"]}),o("div",{"aria-busy":p,children:[C>0&&((i==null?void 0:i.viewerHasComments)||u==="mine"||z)&&t("div",{className:"comments-toolbar",children:C>0&&t("nav",{"aria-label":"Widok komentarzy",children:[["target","Dyskusja"],["mine","Moje komentarze"],...z?[["blocks","Ukryci autorzy"]]:[]].map(([e,a])=>t("button",{"aria-current":u===e?"page":void 0,disabled:p||j||u===e,onClick:()=>void v(async()=>{await S(e),y.current&&(P(e),g(A))},{kind:"list"}),children:a},e))})}),(s==null?void 0:s.kind)==="action"&&t("p",{role:"status",className:"comments-operation",children:"Zapisywanie zmiany\u2026"}),o("div",{className:"comments-list-region",children:[(s==null?void 0:s.kind)==="list"&&o("div",{className:"comments-skeleton",role:"status","aria-label":"\u0141adowanie komentarzy",children:[t("span",{className:"comments-visually-hidden",children:"\u0141adowanie komentarzy\u2026"}),i!=null&&i.items.length?i.items.map(e=>t("div",{children:W(e)}
1,e.id)):W()]}),t("div",{className:(s==null?void 0:s.kind)==="list"?"comments-list--loading":void 0,"aria-hidden":(s==null?void 0:s.kind)==="list"||void 0,children:u==="blocks"?o(H,{children:[!F.length&&!p&&t("p",{className:"comments-empty",children:"Nie ukrywasz \u017Cadnych autor\xF3w."}),F.map(e=>o("p",{className:"comments-blocked",children:[e.name," ",t("button",{disabled:p||j,onClick:()=>void v(()=>I("unblock",{id:e.id})),children:"Przywr\xF3\u0107 autora"})]},e.id)),$&&t("button",{disabled:p,onClick:()=>void v(()=>S("blocks",$)),children:"Kolejni ukryci autorzy"})]}):o(H,{children:[i&&!i.items.length&&t("p",{className:"comments-empty",children:u==="mine"?"Nie masz jeszcze komentarzy.":"Rozpocznij dyskusj\u0119. Napisz pierwszy komentarz."}),i==null?void 0:i.items.map(e=>_(e)),(i==null?void 0:i.nextCursor)&&t("button",{className:"comments-more",disabled:p,onClick:()=>void v(()=>{var e;return S(u,(e=i.nextCursor)!=null?e:void 0)},{kind:"more"}),children:(s==null?void 0:s.kind)==="more"&&!s.id?"\u0141adowanie komentarzy\u2026":"Kolejne komentarze"})]})})]}),!C&&o("p",{className:"comments-notice",children:[t("a",{href:"/user/security/login",children:"Zaloguj si\u0119"}),", aby komentowa\u0107."]}),C>0&&M&&(i==null?void 0:i.canPost)&&!f.id&&!f.parentId&&G(),(i==null?void 0:i.closed)&&t("p",{children:"Dyskusja jest zamkni\u0119ta."})]})]})}export{de as default};

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.