index.7100b17a.js (18173B)
1 var L=Object.defineProperty;var j=(c,e,n)=>e in c?L(c,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):c[e]=n;var d=(c,e,n)=>(j(c,typeof e!="symbol"?e+"":e,n),n);import{B as z,w as D,o as t,L as _,P as k,l as a,b as s,W as S,M as b,D as R,a as F,c as U,O as W,d as G,e as X,R as Q,f as C,g as V,h as Y,i as J}from"./vendor.8ab614fa.js";const Z=function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))o(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const r of l.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&o(r)}).observe(document,{childList:!0,subtree:!0});function n(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerpolicy&&(l.referrerPolicy=i.referrerpolicy),i.crossorigin==="use-credentials"?l.credentials="include":i.crossorigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}};Z();const q="modulepreload",T={},$="/pr-121/",K=function(e,n){return!n||n.length===0?e():Promise.all(n.map(o=>{if(o=`${$}${o}`,o in T)return;T[o]=!0;const i=o.endsWith(".css"),l=i?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${l}`))return;const r=document.createElement("link");if(r.rel=i?"stylesheet":q,i||(r.as="script",r.crossOrigin=""),r.href=o,document.head.appendChild(r),i)return new Promise((m,h)=>{r.addEventListener("load",m),r.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${o}`)))})})).then(()=>e())},N=z(void 0);class I extends D{render(){const e=this.context;return t("div",{class:"m-12 flex flex-col lg:flex-row items-center justify-between",children:[t(_,{to:"/",children:t("img",{alt:"Matrix Art",src:"Logo_colored.svg",class:"ease-in-out hover:scale-105 trandform transition-transform duration-300"})}),t("div",{class:"flex items-center mt-8 lg:mt-0 flex-col sm:flex-row",children:[t("div",{class:"flex items-center justify-between w-80 max-w-80 mx-6 ease-in-out hover:scale-105 trandform transition-transform duration-300",children:[t("div",{class:"absolute ml-4",children:t("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#AAB3CF",children:[t("path",{d:"M0 0h24v24H0V0z",fill:"none"}),t("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]})}),t("input",{class:"search-bg shadow rounded-2xl border-0 py-3 px-4 pl-10 text-data",placeholder:"Search"})]}),e!=null&&e.isLoggedIn()?t(_,{to:"/",class:"text-white font-bold text-1xl logo-bg rounded-2xl py-3 px-12 shadow mt-4 sm:mt-0 transform transition-transform ease-in-out duration-300 hover:scale-105",children:"Post"}):t(_,{to:"/join",class:"text-white font-bold text-1xl logo-bg rounded-2xl py-3 px-12 shadow mt-4 sm:mt-0 transform transition-transform ease-in-out duration-300 hover:scale-105",children:"Join"})]})]})}}I.contextType=N;class g extends D{constructor(e){super(e)}render({user:e,post:n}){return t("div",{class:"flex flex-col",children:[t("a",{id:"gallery_click",href:n.content.file.url,class:"w-full",target:"_blank",rel:"noreferrer",children:t("img",{decoding:"async",loading:"lazy",class:"rounded-3xl shadow object-cover transform transition-transform ease-in-out duration-300 hover:scale-105",src:n.content.file.url})}),t("div",{class:"flex items-center justify-between py-4",children:[t("a",{class:"flex items-center",href:"#",children:[t("img",{class:"w-11 h-11 rounded-full mr-4 border-2 border-[#AAB3CF]",src:e.avatar_url}),t("p",{class:"text-data shadow text-lg font-medium",children:e.display_name})]}),t("div",{class:"flex text-data text-lg items-center",children:[t("a",{class:"mr-4 flex items-center",href:"#",children:[t("span",{class:"mr-2",children:t("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#AAB3CF",children:[t("path",{d:"M0 0h24v24H0V0z",fill:"none"}),t("path",{d:"M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55l-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z"})]})}),t("span",{children:"5"})]}),t("a",{class:"flex items-center",href:"#",children:[t("span",{class:"mr-2",children:t("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#AAB3CF",children:[t("path",{d:"M0 0h24v24H0V0z",fill:"none"}),t("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"})]})}),t("span",{children:"11"})]})]})]})]})}}class p{constructor(e,n,o){d(this,"mxid");d(this,"display_name");d(this,"avatar_url");this.mxid=e,this.display_name=n,this.avatar_url=o}}class y{constructor(e,n){d(this,"event_id");d(this,"content");this.event_id=e,this.content=n}}class ee extends D{constructor(){super(),this.state={columns:this.settingColumns()}}settingColumns(){return window.innerWidth>=1400?4:window.innerWidth>=800?3:window.innerWidth>=500?2:1}componentDidMount(){window.addEventListener("resize",()=>this.setState({columns:this.settingColumns()}))}componentWillUnmount(){window.removeEventListener("resize",()=>this.setState({columns:this.settingColumns()}))}render(){return t("div",{class:"flex flex-col",children:[t("header",{children:t(I,{})}),t("main",{class:"m-12 mt-6",children:[t("h1",{class:"text-3xl font-bold mb-4 text-white",children:"Explore"}),t("div",{class:"flex justify-center",id:"gallery",children:t(k,{gap:24,nColumns:this.state.columns,children:[t(g,{user:new p("","Person A","https://unsplash.com/photos/_cvwXhGqG-o/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8OHx8ZmFjZXxlbnwwfDJ8fHwxNjQ4Nzc5NzYx"),post:new y("",{file:{url:"https://unsplash.com/photos/UWmrTAQ75iA/download?ixid=MnwxMjA3fDB8MXxhbGx8Mnx8fHx8fDJ8fDE2NDg4MzI0Njg"}})}),t(g,{user:new p("","Person B","https://unsplash.com/photos/uJ8LNVCBjFQ/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8MTN8fGZhY2V8ZW58MHwyfHx8MTY0ODc3OTc2MQ"),post:new y("",{file:{url:"https://unsplash.com/photos/7ptbiEPxKMQ/download?ixid=MnwxMjA3fDB8MXxhbGx8OXx8fHx8fDJ8fDE2NDg4MzI0Njg"}})}),t(g,{user:new p("","Person C","https://unsplash.com/photos/u3pi6HhSYew/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8MTd8fGZhY2V8ZW58MHwyfHx8MTY0ODc3OTc2MQ"),post:new y("",{file:{url:"https://unsplash.com/photos/ZiPlVmmKEYA/download?ixid=MnwxMjA3fDB8MXxhbGx8Mzl8fHx8fHwyfHwxNjQ4ODM2MDIz"}})}),t(g,{user:new p("","Person D","https://unsplash.com/photos/TW_z_iUD_bQ/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8ODR8fHBvcnRyYWl0fGVufDB8Mnx8fDE2NDg4NDQ3MjQ"),post:new y("",{file:{url:"https://unsplash.com/photos/FTQJBGDxKXg/download?ixid=MnwxMjA3fDB8MXxhbGx8M3x8fHx8fDJ8fDE2NDg4NDMyNDY"}})}),t(g,{user:new p("","Person E","https://unsplash.com/photos/kYtN89E5ce4/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8MTA0fHxwb3J0cmFpdHxlbnwwfDJ8fHwxNjQ4ODQ0NzQy"),post:new y("",{file:{url:"https://unsplash.com/photos/zfhxiaZO3JE/download?ixid=MnwxMjA3fDB8MXxhbGx8Mjl8fHx8fHwyfHwxNjQ4ODQzMjQ1"}})}),t(g,{user:new p("","Person E","https://unsplash.com/photos/kBonaevi3yA/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8MTE5fHxwb3J0cmFpdHxlbnwwfDJ8fHwxNjQ4ODQ0NzQy"),post:new y("",{file:{url:"https://unsplash.com/photos/jm-JKqrAXsA/download?ixid=MnwxMjA3fDB8MXxhbGx8MTAyfHx8fHx8Mnx8MTY0ODg0MzI1NQ"}})})]})})]})]})}}const v=new a.UnstableValue("m.image","org.matrix.msc1767.image"),B=new a.UnstableValue("m.file","org.matrix.msc1767.file"),P=new a.UnstableValue("m.thumbnail","org.matrix.msc1767.thumbnail"),O=new a.UnstableValue("blurhash","xyz.amorgan.blurhash"),te=new a.NamespacedValue("matrixart.description"),ne=new a.NamespacedValue("matrixart.tags"),ie=new a.NamespacedValue("matrixart.nsfw"),oe=new a.NamespacedValue("matrixart.license");class re extends a.ExtensibleEvent{constructor(n){super(n);d(this,"image");d(this,"text");d(this,"thumbnails");d(this,"blurhash");d(this,"file");d(this,"description");d(this,"tags");d(this,"nsfw",!1);d(this,"license");const o=v.findIn(this.wireContent),i=a.M_TEXT.findIn(this.wireContent),l=B.findIn(this.wireContent),r=P.findIn(this.wireContent),m=O.findIn(this.wireContent),h=te.findIn(this.wireContent),x=ne.findIn(this.wireContent),w=ie.findIn(this.wireContent),u=oe.findIn(this.wireContent);if(a.isProvided(o)){if(!o)throw new a.InvalidEventError("m.image is required to be present");this.image=o}if(a.isProvided(l)){if(!l)throw new a.InvalidEventError("m.file is required to be present");this.file=l}if(a.isOptionalAString(i)){if(!o)throw new a.InvalidEventError("m.text is required to be present");this.text=i}if(a.isProvided(r)){if(!Array.isArray(r))throw new a.InvalidEventError("m.thumbnail contents must be an array");this.thumbnails=r}if(a.isOptionalAString(m)&&(this.blurhash=m),a.isOptionalAString(h)&&(this.description=h),a.isProvided(x)){if(!Array.isArray(x))throw new a.InvalidEventError("matrixart.tags contents must be an array");this.tags=x}if(a.isProvided(w)){if(typeof w!="boolean")throw new a.InvalidEventError("matrixart.tags contents must be an boolean");this.nsfw=w}a.isOptionalAString(u)&&(this.license=u)}isEquivalentTo(n){return a.isEventTypeSame(n,v)}serialize(){const n={[a.M_TEXT.name]:this.text,[B.name]:this.file,[v.name]:this.image,[P.name]:this.thumbnails,[O.name]:this.blurhash,["matrixart.description"]:this.description,["matrixart.tags"]:this.tags,["matrixart.nsfw"]:this.nsfw,["matrixart.license"]:this.license};return{type:"m.image",content:n}}}function se(c){const e=c;return new re(e)}a.ExtensibleEvents.registerInterpreter(v,se);a.ExtensibleEvents.unknownInterpretOrder.push(v);function M(){return new Worker("/pr-121/assets/indexeddb.worker.c669c402.js",{type:"module"})}class E{constructor(e){d(this,"events",[]);d(this,"currentUserDirectory");d(this,"rootDirectory");this.client=e}static async new(){var i,l,r,m,h,x;global.Olm||console.error("global.Olm does not seem to be present. Did you forget to add olm in the out directory?");let e;if(window.localStorage.getItem("server")!==null?e=window.localStorage.getItem("server"):e="https://matrix.art.midnightthoughts.space",!e)throw new Error("No matrix server URL defined");let n;if(window.localStorage.getItem("mxid_guest")!==null){const w=(i=window.localStorage.getItem("mxid_guest"))!=null?i:void 0,u=(l=window.localStorage.getItem("access_token_guest"))!=null?l:void 0,f=(r=window.localStorage.getItem("device_id_guest"))!=null?r:void 0;n=s.createClient({useAuthorizationHeader:!0,baseUrl:e,userId:w,accessToken:u,deviceId:f,sessionStore:new S(window.localStorage),store:new s.IndexedDBStore({indexedDB:window.indexedDB,dbName:"matrix-art-sync:guest",localStorage:window.localStorage,workerFactory:()=>new M}),cryptoStore:new s.IndexedDBCryptoStore(window.indexedDB,"matrix-art:crypto")}),n.setGuest(!0)}{const w=s.createClient("https://matrix.art.midnightthoughts.space"),{user_id:u,device_id:f,access_token:A}=await w.registerGuest();n=s.createClient({useAuthorizationHeader:!0,baseUrl:e,userId:u,accessToken:A,deviceId:f,sessionStore:new S(window.localStorage),store:new s.IndexedDBStore({indexedDB:window.indexedDB,dbName:"matrix-art-sync:guest",localStorage:window.localStorage,workerFactory:()=>new M}),cryptoStore:new s.IndexedDBCryptoStore(window.indexedDB,"matrix-art:crypto")}),n.setGuest(!0),window.localStorage.setItem("mxid_guest",u),window.localStorage.setItem("access_token_guest",A),window.localStorage.setItem("device_id_guest",f),window.localStorage.setItem("server",e)}let o;if(window.localStorage.getItem("mxid")!==null){const w=(m=window.localStorage.getItem("mxid"))!=null?m:void 0,u=(h=window.localStorage.getItem("access_token"))!=null?h:void 0,f=(x=window.localStorage.getItem("device_id"))!=null?x:void 0;o=s.createClient({useAuthorizationHeader:!0,baseUrl:e,userId:w,accessToken:u,deviceId:f,sessionStore:new S(window.localStorage),store:new s.IndexedDBStore({indexedDB:window.indexedDB,dbName:"matrix-art-sync:guest",localStorage:window.localStorage,workerFactory:()=>new M}),cryptoStore:new s.IndexedDBCryptoStore(window.indexedDB,"matrix-art:crypto")}),o.setGuest(!1)}return new E(o!=null?o:n)}isLoggedIn(){return this.client.isLoggedIn()&&!this.client.isGuest()}async start(){this.client.on(s.MatrixEventEvent.Decrypted,(n,o)=>{const i=n.unstableExtensibleEvent;i!=null&&i.isEquivalentTo(v)&&this.events.push(n)}),console.log("start"),await this.client.store.startup(),await this.client.initCrypto(),await this.client.startClient();const e=await this.client.joinRoom("#Matrix_Art:art.midnightthoughts.space");await H(1e3),this.rootDirectory=new b(this.client,e.roomId),console.log("started")}async register(e="https://matrix.art.midnightthoughts.space",n,o,i=!1){var l;if(this.client.stopClient(),this.client=s.createClient({useAuthorizationHeader:!0,baseUrl:e,userId:n,deviceId:"Matrix Art",sessionStore:new S(window.localStorage),store:new s.IndexedDBStore({indexedDB:window.indexedDB,dbName:"matrix-art-sync:loggedin",localStorage:window.localStorage,workerFactory:()=>new M}),cryptoStore:new s.IndexedDBCryptoStore(window.indexedDB,"matrix-art:crypto")}),await this.client.register(n,o,null,{type:"m.login.dummy"}),window.localStorage.setItem("server",e),window.localStorage.setItem("mxid",n),window.localStorage.setItem("access_token",this.client.getAccessToken()),window.localStorage.setItem("device_id","Matrix Art"),await this.start(),i){const r=(l=this.rootDirectory)==null?void 0:l.getDirectories(),m=this.client.getUserId().replace(":","_");r!=null&&r.some(h=>h.room.name===m)?this.rootDirectory=r==null?void 0:r.find(h=>h.room.name===m):await this.createProfileFolder()}}async login(e,n,o,i=!1){var l;if(this.client.stopClient(),this.client=s.createClient({useAuthorizationHeader:!0,baseUrl:e,userId:n,deviceId:"Matrix Art",sessionStore:new S(window.localStorage),store:new s.IndexedDBStore({indexedDB:window.indexedDB,dbName:"matrix-art-sync:loggedin",localStorage:window.localStorage,workerFactory:()=>new M}),cryptoStore:new s.IndexedDBCryptoStore(window.indexedDB,"matrix-art:crypto")}),await this.client.loginWithPassword(n,o),window.localStorage.setItem("server",e),window.localStorage.setItem("mxid",n),window.localStorage.setItem("access_token",this.client.getAccessToken()),window.localStorage.setItem("device_id","Matrix Art"),await this.start(),i){const r=(l=this.rootDirectory)==null?void 0:l.getDirectories();console.log(r);const m=this.client.getUserId().replace(":","_");r!=null&&r.some(h=>h.room.name===m)?this.rootDirectory=r==null?void 0:r.find(h=>h.room.name===m):await this.createProfileFolder()}}async createProfileFolder(){if(this.client.isGuest())throw new Error("Cannot create a file tree space as a guest");const e=await this.client.joinRoom("#Matrix_Art:art.midnightthoughts.space");await H(1e3),this.rootDirectory=new b(this.client,e.roomId);const n=this.client.getUserId().replace(":","_");this.currentUserDirectory=await this.createPublicSubDirectory(this.rootDirectory,n),await this.createPublicSubDirectory(this.currentUserDirectory,"Timeline")}async createPublicFileTree(e){if(this.client.isGuest())throw new Error("Cannot create a file tree space as a guest");const{room_id:n}=await this.client.createRoom({name:e,preset:s.Preset.PublicChat,power_level_content_override:{...R,users:{["@administrator:art.midnightthoughts.space"]:100,[this.client.getUserId()]:100}},invite:["@administrator:art.midnightthoughts.space"],creation_content:{[s.RoomCreateTypeField]:s.RoomType.Space},initial_state:[{type:s.UNSTABLE_MSC3088_PURPOSE.name,state_key:s.UNSTABLE_MSC3089_TREE_SUBTYPE.name,content:{[s.UNSTABLE_MSC3088_ENABLED.name]:!0}},{type:s.EventType.RoomEncryption,state_key:"",content:{algorithm:F}},{type:s.EventType.RoomGuestAccess,state_key:"",content:{guest_access:"can_join"}},{type:s.EventType.RoomHistoryVisibility,state_key:"",content:{history_visibility:"world_readable"}}]}),o=this.client.getRoom(n),i=o==null?void 0:o.getLiveTimeline().getState(s.EventTimeline.FORWARDS).getStateEvents(s.EventType.RoomPowerLevels,"");if(!i)throw new Error("Failed to find PL event");return await this.client.setPowerLevel(n,this.client.getUserId(),50,i),new b(this.client,n)}async createPublicSubDirectory(e,n){const o=await this.createPublicFileTree(n);return await this.client.sendStateEvent(e.roomId,s.EventType.SpaceChild,{via:[this.client.getDomain()]},o.roomId),await this.client.sendStateEvent(o.roomId,s.EventType.SpaceParent,{via:[this.client.getDomain()]},e.roomId),o}}function H(c){return new Promise(e=>setTimeout(e,c))}const ae=U(()=>K(()=>import("./Join.95fe70ce.js"),["assets/Join.95fe70ce.js","assets/vendor.8ab614fa.js"]));class le extends D{constructor(){super(),this.state={client:void 0}}loadOlm(){return W.init({locateFile:()=>G}).then(()=>{console.log("Using WebAssembly Olm")}).catch(e=>(console.log("Failed to load Olm: trying legacy version",e),new Promise((n,o)=>{const i=document.createElement("script");i.src=X,i.onload=n,i.onerror=o,document.body.appendChild(i)}).then(()=>window.Olm.init()).then(()=>{console.log("Using legacy Olm")}).catch(n=>{console.log("Both WebAssembly and asm.js Olm failed!",n)})))}async loadMatrixClient(){var n;let e=await E.new();this.setState({client:e}),console.log("Client loaded"),await((n=this.state.client)==null?void 0:n.start()),console.log("Client started")}async componentDidMount(){try{await this.loadOlm(),console.log("Olm loaded")}catch{console.log("Olm not loaded")}await this.loadMatrixClient()}render(){return t(N.Provider,{value:this.state.client,children:t(Q,{children:[t(C,{path:"/",element:t(ee,{})}),t(C,{path:"join",element:t(V,{fallback:t("div",{class:"flex flex-col",children:[t("header",{children:t(I,{})}),t("main",{class:"m-12 mt-6 flex items-center justify-center",children:t("p",{class:"text-lg text-data font-bold",children:"Loading..."})})]}),children:t(ae,{})})})]})})}}Y(t(J,{basename:"/pr-121/",children:t(le,{})}),document.querySelector("#app"));export{N as C,I as H};