live-quiz 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +256 -0
- package/dist/live-quiz.css +1 -0
- package/dist/live-quiz.js +3391 -0
- package/dist/live-quiz.umd.js +8 -0
- package/dist/participant/index.d.ts +48 -0
- package/dist/participant/index.d.ts.map +1 -0
- package/dist/participant.css +1 -0
- package/dist/participant.js +1772 -0
- package/dist/participant.umd.js +1 -0
- package/dist/src/dom/animate.d.ts +3 -0
- package/dist/src/dom/animate.d.ts.map +1 -0
- package/dist/src/dom/render-qr.d.ts +6 -0
- package/dist/src/dom/render-qr.d.ts.map +1 -0
- package/dist/src/dom/render-question.d.ts +6 -0
- package/dist/src/dom/render-question.d.ts.map +1 -0
- package/dist/src/dom/render-results.d.ts +15 -0
- package/dist/src/dom/render-results.d.ts.map +1 -0
- package/dist/src/index.d.ts +26 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/plugin.d.ts +33 -0
- package/dist/src/plugin.d.ts.map +1 -0
- package/dist/src/quiz-manager.d.ts +74 -0
- package/dist/src/quiz-manager.d.ts.map +1 -0
- package/dist/src/quiz-types.d.ts +33 -0
- package/dist/src/quiz-types.d.ts.map +1 -0
- package/functions/README.md +33 -0
- package/functions/netlify/package.json +6 -0
- package/functions/netlify/quiz-answer.mts +43 -0
- package/functions/netlify/quiz-sync.mts +41 -0
- package/functions/netlify/shared.mts +38 -0
- package/functions/vercel/package.json +6 -0
- package/functions/vercel/quiz-answer.ts +37 -0
- package/functions/vercel/quiz-sync.ts +35 -0
- package/functions/vercel/shared.ts +34 -0
- package/package.json +71 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
(function(A,M){typeof exports=="object"&&typeof module<"u"?M(exports):typeof define=="function"&&define.amd?define(["exports"],M):(A=typeof globalThis<"u"?globalThis:A||self,M(A.RevealLiveQuiz={}))})(this,(function(A){"use strict";var On=Object.defineProperty;var jn=(A,M,z)=>M in A?On(A,M,{enumerable:!0,configurable:!0,writable:!0,value:z}):A[M]=z;var Me=(A,M,z)=>jn(A,typeof M!="symbol"?M+"":M,z);let M=()=>({emit(s,...e){for(let t=this.events[s]||[],n=0,i=t.length;n<i;n++)t[n](...e)},events:{},on(s,e){var t;return((t=this.events)[s]||(t[s]=[])).push(e),()=>{var n;this.events[s]=(n=this.events[s])==null?void 0:n.filter(i=>e!==i)}}});class z extends Error{constructor(e,t){e instanceof Error?(super(e.message),this.cause=e):super(e),this.reason=t,this.name="ReasonError"}}class Be extends z{constructor(e){super("Rejected",e),this.name="SubscriptionRejectedError"}}class Rt extends z{constructor(e){super(e||"Timed out to receive subscription ack"),this.name="SubscriptionTimeoutError"}}class B extends z{constructor(e,t){t?super(e,t):super("Disconnected",e),this.name="DisconnectedError"}}class Tt extends B{constructor(e){super(e,"stale_connection"),this.name="StaleConnectionError"}}function ze(s){return s?`{${Object.keys(s).sort().filter(t=>s[t]!==void 0).map(t=>{let n=JSON.stringify(s[t]);return`${JSON.stringify(t)}:${n}`}).join(",")}}`:""}class Nt{constructor(e){this.channel=e,this.listeners=[]}watch(){this.listeners.push(this.channel.on("presence",e=>{if(e.type==="info"){this._state||(this._state=this.stateFromInfo(e));return}this._state&&(e.type==="join"?this._state[e.id]=e.info:e.type==="leave"&&delete this._state[e.id])}))}reset(){delete this._state}dispose(){delete this._info,delete this._state,this.listeners.forEach(e=>e()),this.listeners.length=0}async join(e,t){if(!this._info)return this._info={id:String(e),info:t},this.channel.perform("$presence:join",this._info)}async leave(){if(!this._info)return;let e=await this.channel.perform("$presence:leave");return delete this._info,e}async info(){return this._state?this._state:(this._promise||(this._promise=this._sync()),await this._promise,this._state)}async _sync(){this.watch();try{let e=await this.channel.perform("$presence:info",{});return this._state=this.stateFromInfo(e),this._state}finally{delete this._promise}}stateFromInfo(e){return e.records?e.records.reduce((t,{id:n,info:i})=>(t[n]=i,t),{}):{}}}const O=Symbol("state");class ke{constructor(e={}){this.emitter=M(),this.params=Object.freeze(e),this.presence=new Nt(this),this.initialConnect=!0,this[O]="idle"}get identifier(){return this._identifier?this._identifier:(this._identifier=ze({channel:this.channelId,...this.params}),this._identifier)}get channelId(){return this.constructor.identifier}get state(){return this[O]}attached(e){if(this.receiver){if(this.receiver!==e)throw Error("Already connected to a different receiver");return!1}return this.receiver=e,!0}connecting(){this[O]="connecting"}connected(){if(this.state==="connected"||this.state==="closed")return;this[O]="connected";let e=!1;this.initialConnect?(this.initialConnect=!1,this.emit("connect",{reconnect:!1,restored:e})):this.emit("connect",{reconnect:!0,restored:e})}restored(){if(this.state==="connected")throw Error("Already connected");this[O]="connected";let e=!0,t=!0;this.initialConnect=!1,this.emit("connect",{reconnect:t,restored:e})}disconnected(e){this.state==="disconnected"||this.state==="closed"||(this[O]="disconnected",this.presence.reset(),this.emit("disconnect",e))}closed(e){this.state!=="closed"&&(this[O]="closed",delete this.receiver,this.initialConnect=!0,this.presence.dispose(),this.emit("close",e))}disconnect(){this.state==="idle"||this.state==="closed"||this.receiver.unsubscribe(this)}async perform(e,t){if(this.state==="idle"||this.state==="closed")throw Error("Channel is not subscribed");return this.receiver.perform(this.identifier,e,t)}async send(e){return this.perform(void 0,e)}async whisper(e){try{await this.perform("$whisper",e)}catch(t){let n=this.receiver?this.receiver.logger:null;n&&n.warn("whisper failed: ",t)}}receive(e,t){this.emit("message",e,t)}on(e,t){return this.emitter.on(e,t)}once(e,t){let n=this.emitter.on(e,(...i)=>{n(),t(...i)});return n}emit(e,...t){return this.emitter.emit(e,...t)}ensureSubscribed(){return this.state==="connected"?Promise.resolve():this.state==="closed"?Promise.reject(Error("Channel is unsubscribed")):this.pendingSubscribe()}pendingSubscribe(){return this._pendingSubscribe?this._pendingSubscribe:(this._pendingSubscribe=new Promise((e,t)=>{let n=[()=>delete this._pendingSubscribe];n.push(this.on("connect",()=>{n.forEach(i=>i()),e()})),n.push(this.on("close",i=>{n.forEach(r=>r()),t(i||new z("Channel was disconnected before subscribing","canceled"))}))}),this._pendingSubscribe)}}class At{constructor(e){this.id=e,this.intent="unsubscribed",this.state="idle",this.channels=[],this.disposed=!1,this._pendings=[]}add(e){this.channels.includes(e)||this.channels.push(e)}remove(e){let t=this.channels.indexOf(e);t>-1&&this.channels.splice(t,1)}notify(e,...t){this.state=e==="restored"?"connected":e,t.length===1?this.channels.forEach(n=>n[e](t[0])):this.channels.forEach(n=>n[e]())}pending(e){this._checkIntent(e);let t=this._pendings[0];return!t||t.intent!==e?Promise.resolve():t.promise}ensureResubscribed(){this.disposed||(this.intent=void 0,this.ensureSubscribed())}ensureSubscribed(){if(this.intent==="subscribed")return;if(this.disposed)throw Error("Subscription is disposed");this.intent="subscribed",!this._mergeWithPending("unsubscribed")&&this.subscriber(this)}maybeUnsubscribe(){this.disposed||this.intent==="unsubscribed"||this.channels.length>0||(this.intent="unsubscribed",this._mergeWithPending("subscribed"))||this.unsubscriber(this)}async acquire(e){this._checkIntent(e);let t,i={promise:new Promise(o=>{t=o}),intent:e,release:()=>{this._pendings.splice(this._pendings.indexOf(i),1),t(i)},canceled:!1,acquired:!1},r=this._pendingTop;return this._pendings.push(i),r&&await r.promise,this.gvl&&await this.gvl.acquire(i,e),i.acquired=!0,i}close(e){this.disposed=!0,this.intent=void 0,this.notify("closed",e)}_checkIntent(e){if(!(e==="unsubscribed"||e==="subscribed"))throw Error(`Unknown subscription intent: ${e}`)}get _pendingTop(){return this._pendings.length?this._pendings[this._pendings.length-1]:void 0}_mergeWithPending(e){let t=this._pendingTop;return!t||t.acquired||t.intent!==e?!1:(this._pendings.pop(),t.canceled=!0,!0)}}class Mt{constructor(){this.queue=[]}async acquire(e,t){t==="subscribed"&&(this.queue.push(e.promise.then(()=>{this.queue.splice(this.queue.indexOf(e),1)})),this.queue.length>1&&await this.queue[this.queue.length-2])}}class Bt{constructor(e){e.concurrentSubscribes===!1&&(this.glv=new Mt),this._subscriptions={},this._localToRemote={}}all(){return Object.values(this._subscriptions)}get(e){return this._subscriptions[e]}create(e,{subscribe:t,unsubscribe:n}){let i=this._subscriptions[e]=new At(e);return i.remoteId=this._localToRemote[e],i.subscriber=t,i.unsubscriber=n,i.gvl=this.glv,i}remove(e){delete this._subscriptions[e],delete this._localToRemote[e]}storeRemoteId(e,t){this._localToRemote[e]=t;let n=this.get(e);n&&(n.remoteId=t)}}class zt{constructor(e={}){this.subscriptions=new Bt(e),this._pendingMessages=[],this._remoteToLocal={}}subscribe(e,t){this._remoteToLocal[t]=e,this.subscriptions.storeRemoteId(e,t),this.flush(t)}unsubscribe(e){let t=this.subscriptions.get(e);if(!t)return;let n=t.remoteId;n&&delete this._remoteToLocal[n],this.subscriptions.remove(e)}transmit(e,t,n){let i=this._remoteToLocal[e];if(!i){this._pendingMessages.push([e,t,n]);return}let r=this.subscriptions.get(i);r&&r.channels.forEach(o=>{o.receive(t,n)})}notify(e,t,n){let i=this._remoteToLocal[e];if(!i)return;let r=this.subscriptions.get(i);r&&r.channels.forEach(o=>o.emit(t,n))}close(){this._pendingMessages.length=0}get size(){return this.channels.length}get channels(){return this.subscriptions.all().flatMap(e=>e.channels)}flush(e){let t=[];for(let n of this._pendingMessages)n[0]===e?this.transmit(n[0],n[1],n[2]):t.push(n);this._pendingMessages=t}}const Le={debug:0,info:1,warn:2,error:3};class Ue{constructor(e){this.level=e||"warn"}log(e,t,n){Le[e]<Le[this.level]||this.writeLogEntry(e,t,n)}writeLogEntry(){throw Error("Not implemented")}debug(e,t){this.log("debug",e,t)}info(e,t){this.log("info",e,t)}warn(e,t){this.log("warn",e,t)}error(e,t){this.log("error",e,t)}}class H extends Ue{writeLogEntry(){}}class kt{encode(e){return JSON.stringify(e)}decode(e){try{return JSON.parse(e)}catch{}}}let Lt=0;class De{constructor(e={}){let{logger:t}=e;this.logger=t||new H,this.pendingSubscriptions={},this.pendingUnsubscriptions={},this.subscribeCooldownInterval=e.subscribeCooldownInterval||250,this.subscribeRetryInterval=e.subscribeRetryInterval||5e3}attached(e){this.cable=e}subscribe(e,t){let n={channel:e};t&&Object.assign(n,t);let i=ze(n);if(this.pendingUnsubscriptions[i]){let o=this.subscribeCooldownInterval*1.5;return this.logger.debug(`unsubscribed recently, cooldown for ${o}`,i),new Promise(c=>{setTimeout(()=>{c(this.subscribe(e,t))},o)})}if(this.pendingSubscriptions[i])return this.logger.warn("subscription is already pending, skipping",i),Promise.reject(Error("Already subscribing"));let r=this.subscribeRetryInterval;return new Promise((o,c)=>{let a=++Lt;this.pendingSubscriptions[i]={resolve:o,reject:c,id:a},this.cable.send(this.buildSubscribeRequest(i)),this.maybeRetrySubscribe(a,i,r)})}buildSubscribeRequest(e){return{command:"subscribe",identifier:e}}maybeRetrySubscribe(e,t,n){setTimeout(()=>{let i=this.pendingSubscriptions[t];i&&i.id===e&&(this.logger.warn(`no subscription ack received in ${n}ms, retrying subscribe`,t),this.cable.send(this.buildSubscribeRequest(t)),this.maybeExpireSubscribe(e,t,n))},n)}maybeExpireSubscribe(e,t,n){setTimeout(()=>{let i=this.pendingSubscriptions[t];i&&i.id===e&&(delete this.pendingSubscriptions[t],i.reject(new Rt(`Haven't received subscription ack in ${n*2}ms for ${t}`)))},n)}unsubscribe(e){return this.cable.send({command:"unsubscribe",identifier:e}),this.pendingUnsubscriptions[e]=!0,setTimeout(()=>{delete this.pendingUnsubscriptions[e]},this.subscribeCooldownInterval),Promise.resolve()}perform(e,t,n){return t==="$whisper"?this.whisper(e,n):(n||(n={}),n.action||(n.action=t),this.cable.send({command:"message",identifier:e,data:JSON.stringify(n)}),Promise.resolve())}whisper(e,t){return this.cable.send({command:"whisper",identifier:e,data:t}),Promise.resolve()}receive(e){if(typeof e!="object"){this.logger.error("unsupported message format",{message:e});return}let{type:t,identifier:n,message:i,reason:r,reconnect:o}=e;if(t==="ping")return this.cable.keepalive(e.message);if(this.cable.keepalive(),t==="welcome"){let c=e.sid;return c&&this.cable.setSessionId(c),this.cable.connected()}if(t==="disconnect"){let c=new B(r);this.reset(c),o===!1?this.cable.closed(c):this.cable.disconnected(c);return}if(t==="confirm_subscription"){let c=this.pendingSubscriptions[n];if(!c){this.logger.error("subscription not found, unsubscribing",{type:t,identifier:n}),this.unsubscribe(n);return}return delete this.pendingSubscriptions[n],c.resolve(n)}if(t==="reject_subscription"){let c=this.pendingSubscriptions[n];return c?(delete this.pendingSubscriptions[n],c.reject(new Be)):this.logger.error("subscription not found",{type:t,identifier:n})}if(i)return{identifier:n,message:i};this.logger.warn(`unknown message type: ${t}`,{message:e})}reset(e){for(let t in this.pendingSubscriptions)this.pendingSubscriptions[t].reject(e);this.pendingSubscriptions={}}recoverableClosure(){return!1}}const Fe=()=>Date.now()/1e3|0;class Ut extends De{constructor(e={}){super(e),this.streamsPositions={},this.subscriptionStreams={},this.pendingHistory={},this.pendingPresence={},this.presenceInfo={},this.restoreSince=e.historyTimestamp,this.disableSessionRecovery=e.disableSessionRecovery,this.restoreSince===void 0&&(this.restoreSince=Fe()),this.sessionId=void 0,this.sendPongs=e.pongs}reset(e){for(let t in this.pendingPresence)this.pendingPresence[t].reject(e);return this.pendingPresence={},super.reset()}receive(e){if(typeof e!="object"){this.logger.error("unsupported message format",{message:e});return}let{type:t,identifier:n,message:i}=e;if(t==="disconnect")return delete this.sessionId,this.cable.setSessionId(""),super.receive(e);if(t==="reject_subscription")return super.receive(e);if(t==="confirm_subscription")return this.subscriptionStreams[n]||(this.subscriptionStreams[n]=new Set),super.receive(e);if(t==="ping")return this.restoreSince&&(this.restoreSince=Fe()),this.sendPongs&&this.sendPong(),this.cable.keepalive(e.message);if(this.cable.keepalive(),t==="confirm_history"){this.logger.debug("history result received",e),this.cable.notify("history_received",n);return}if(t==="reject_history"){this.logger.warn("failed to retrieve history",e),this.cable.notify("history_not_found",n);return}if(t==="welcome"){if(this.disableSessionRecovery||(this.sessionId=e.sid,this.sessionId&&this.cable.setSessionId(this.sessionId)),e.restored){let r=e.restored_ids||Object.keys(this.subscriptionStreams);for(let o of r)this.cable.send({identifier:o,command:"history",history:this.historyRequestFor(o)}),this.presenceInfo[o]&&this.cable.send({identifier:o,command:"join",presence:this.presenceInfo[o]});return this.cable.restored(r)}return this.cable.connected(this.sessionId)}if(t==="presence"){let r=i.type;if(r==="info"){let o=this.pendingPresence[n];o&&(delete this.pendingPresence[n],o.resolve(i))}else if(r==="error"){let o=this.pendingPresence[n];o&&(delete this.pendingPresence[n],o.reject(new Error("failed to retrieve presence")))}return{type:t,identifier:n,message:i}}if(i){let r=this.trackStreamPosition(n,e.stream_id,e.epoch,e.offset);return{identifier:n,message:i,meta:r}}this.logger.warn(`unknown message type: ${t}`,{message:e})}perform(e,t,n){switch(t){case"$presence:join":return this.join(e,n);case"$presence:leave":return this.leave(e,n);case"$presence:info":return this.presence(e,n)}return super.perform(e,t,n)}unsubscribe(e){return delete this.presenceInfo[e],super.unsubscribe(e)}buildSubscribeRequest(e){let t=super.buildSubscribeRequest(e),n=this.historyRequestFor(e);n&&(t.history=n,this.pendingHistory[e]=!0);let i=this.presenceInfo[e];return i&&(t.presence=i),t}recoverableClosure(){return!!this.sessionId}historyRequestFor(e){let t={},n=!1;if(this.subscriptionStreams[e])for(let i of this.subscriptionStreams[e]){let r=this.streamsPositions[i];r&&(n=!0,t[i]=r)}if(!(!n&&!this.restoreSince))return{since:this.restoreSince,streams:t}}trackStreamPosition(e,t,n,i){if(!(!t||!n))return this.subscriptionStreams[e]||(this.subscriptionStreams[e]=new Set),this.subscriptionStreams[e].add(t),this.streamsPositions[t]={epoch:n,offset:i},{stream:t,epoch:n,offset:i}}async sendPong(){await new Promise(e=>setTimeout(e,0)),this.cable.state==="connected"&&this.cable.send({command:"pong"})}async join(e,t){return this.presenceInfo[e]=t,this.cable.send({command:"join",identifier:e,presence:t}),Promise.resolve()}async leave(e,t){return delete this.presenceInfo[e],this.cable.send({command:"leave",identifier:e,presence:t}),Promise.resolve()}presence(e,t){return this.pendingPresence[e]?(this.logger.warn("presence is already pending, skipping",e),Promise.reject(Error("presence request is already pending"))):new Promise((n,i)=>{this.pendingPresence[e]={resolve:n,reject:i},this.cable.send({command:"presence",identifier:e,data:t})})}}class Dt extends z{constructor(){super("No connection","closed"),this.name="NoConnectionError"}}class Oe extends ke{constructor(e,t){super(t),this.channelId=e}set channelId(e){this._channelId=e}get channelId(){return this._channelId}}Me(Oe,"identifier","__ghost__");const Ft="$pubsub";class te extends ke{async perform(e,t){if(e.startsWith("$"))return super.perform(e,t);throw Error("not implemented")}}Me(te,"identifier",Ft);const j=Symbol("state");class Ot{constructor({transport:e,protocol:t,encoder:n,logger:i,lazy:r,hubOptions:o,performFailures:c,transportConfigurator:a}){this.emitter=M(),this.transport=e,this.encoder=n,this.logger=i||new H,this.protocol=t,this.performFailures=c||"throw",this.protocol.attached(this),this.hub=new zt(o||{}),this[j]="idle",this.handleClose=this.handleClose.bind(this),this.handleIncoming=this.handleIncoming.bind(this),this.transportConfigurator=a,this.transport.on("close",this.handleClose),this.transport.on("data",this.handleIncoming),this.initialConnect=!0,this.recovering=!1,r===!1&&this.connect().catch(()=>{})}get state(){return this[j]}async connect(){if(this.state==="connected")return Promise.resolve();if(this.state==="connecting")return this.pendingConnect();let e=this.state==="idle";this[j]="connecting";let t=this.pendingConnect();this.logger.debug("connecting");try{this.transportConfigurator&&await this.transportConfigurator(this.transport,{initial:e}),await this.transport.open()}catch(n){this.handleClose(n)}return t}setSessionId(e){this.sessionId=e,this.transport.setParam("sid",e)}connected(){if(this.state==="connected")return;this.logger.info("connected"),this[j]="connected",this.recovering&&this.hub.subscriptions.all().forEach(t=>t.notify("disconnected",new B("recovery_failed"))),this.hub.subscriptions.all().forEach(t=>this._resubscribe(t));let e=!1;this.recovering=!1,this.initialConnect?(this.initialConnect=!1,this.emit("connect",{reconnect:!1,restored:e})):this.emit("connect",{reconnect:!0,restored:e})}restored(e){this.logger.info("connection recovered",{remoteIds:e}),this[j]="connected",this.hub.subscriptions.all().forEach(i=>{e&&i.remoteId&&e.includes(i.remoteId)?i.notify("restored"):(i.notify("disconnected",new B("recovery_failed")),this._resubscribe(i))});let t=!this.initialConnect,n=!0;this.recovering=!1,this.initialConnect=!1,this.emit("connect",{reconnect:t,restored:n})}notify(e,t,n){t&&typeof t!="string"&&(n=t,t=void 0),t?this.hub.notify(t,"info",{type:e,data:n}):this.emit("info",{type:e,data:n})}handleClose(e){this.logger.debug("transport closed",{error:e}),this.disconnected(new B(e,"transport_closed"))}disconnected(e){(this.state==="connected"||this.state==="connecting")&&(this.logger.info("disconnected",{reason:e}),this[j]="disconnected",this.recovering=this.protocol.recoverableClosure(e),this.recovering?this.hub.subscriptions.all().forEach(t=>t.notify("connecting")):this.hub.subscriptions.all().forEach(t=>{t.notify("disconnected",e)}),this.protocol.reset(e),this.hub.close(),this.transport.close(),this.emit("disconnect",e))}closed(e){if(this.state==="closed"||this.state==="idle")return;let t;e&&(t=e instanceof B?e:new B(e,void 0)),this.logger.info("closed",{reason:e||"user"}),this[j]="closed";let n=t||new B("cable_closed");this.hub.subscriptions.all().forEach(i=>i.notify("disconnected",n)),this.hub.close(),this.protocol.reset(),this.transport.close(),this.initialConnect=!0,this.emit("close",t)}disconnect(){this.closed()}handleIncoming(e){if(this.state==="closed"||this.state==="idle")return;let t=this.encoder.decode(e);if(t===void 0){this.logger.error("failed to decode message",{message:e});return}this.logger.debug("incoming data",t);let n=this.protocol.receive(t);if(n){this.logger.debug("processed incoming message",n);let{type:i,identifier:r,message:o,meta:c}=n;i?this.hub.notify(r,i,o):this.hub.transmit(r,o,c)}}send(e){if(this.state==="closed")throw Error("Cable is closed");let t=this.encoder.encode(e);if(t===void 0){this.logger.error("failed to encode message",{message:e});return}this.logger.debug("outgoing message",e),this.transport.send(t)}keepalive(e){this.emit("keepalive",e)}streamFrom(e){let t=new te({stream_name:e});return this.subscribe(t)}streamFromSigned(e){let t=new te({signed_stream_name:e});return this.subscribe(t)}subscribeTo(e,t){let n,i;return typeof e=="string"&&(i=e,e=Oe),n=i?new e(i,t):new e(t),this.subscribe(n)}subscribe(e){if(!e.attached(this))return e;let t=e.identifier;e.connecting();let n=this.hub.subscriptions.get(t)||this.hub.subscriptions.create(t,{subscribe:i=>this._subscribe(i,e.channelId,e.params),unsubscribe:i=>this._unsubscribe(i)});return n.add(e),n.intent==="subscribed"&&n.state==="connected"&&e.connected(),n.ensureSubscribed(),e}async _resubscribe(e){e.intent!=="subscribed"||!e.channels[0]||(e.notify("connecting"),e.ensureResubscribed())}async _subscribe(e,t,n){let i=e.id;if(this.state==="idle"&&this.connect().catch(()=>{}),this.state!=="connected"){this.logger.debug("cancel subscribe, no connection",{identifier:i});return}this.logger.debug("acquiring subscribe lock",{identifier:i});let r=await e.acquire("subscribed");if(r.canceled){this.logger.debug("subscribe lock has been canceled",{identifier:i}),r.release();return}if(this.logger.debug("subscribe lock has been acquired",{identifier:i}),e.intent!=="subscribed"){this.logger.debug("cancel subscribe request, already unsubscribed"),r.release();return}if(this.state!=="connected"){this.logger.debug("cancel subscribe, no connection",{identifier:i}),r.release();return}if(e.state==="connected"){this.logger.debug("already connected, skip subscribe command",{identifier:i}),e.notify("connected"),r.release();return}let o={identifier:t,params:n};this.logger.debug("subscribing",o);try{let c=await this.protocol.subscribe(t,n);this.hub.subscribe(i,c),this.logger.debug("subscribed",{...o,remoteId:c}),e.notify("connected")}catch(c){if(c){if(c instanceof Be&&this.logger.warn("rejected",o),c instanceof B){this.logger.debug("disconnected during subscription; will retry on connect",o),r.release();return}this.logger.error("failed to subscribe",{error:c,...o})}e.close(c),this.hub.unsubscribe(i)}r.release()}unsubscribe(e){let t=e.identifier,n=this.hub.subscriptions.get(t);if(!n)throw Error(`Subscription not found: ${t}`);n.remove(e),e.closed(),n.maybeUnsubscribe()}async _unsubscribe(e){let t=e.id;this.logger.debug("acquiring unsubscribe lock",{identifier:t});let n=await e.acquire("unsubscribed");if(n.canceled){this.logger.debug("unsubscribe lock has been canceled",{identifier:t}),n.release();return}if(this.logger.debug("unsubscribe lock has been acquired",{identifier:t}),e.intent!=="unsubscribed"){this.logger.debug("cancel unsubscribe, no longer needed",{identifier:t,intent:e.intent}),n.release();return}if(e.state==="disconnected"||e.state==="closed"){this.logger.debug(`already ${e.state} connected, skip unsubscribe command`,{identifier:t}),n.release();return}let i=e.remoteId;if(this.logger.debug("unsubscribing...",{remoteId:i}),this.state!=="connected"){this.logger.debug("unsubscribe skipped (cable is not connected)",{id:t}),e.close(),this.hub.unsubscribe(t),n.release();return}try{await this.protocol.unsubscribe(i),this.logger.debug("unsubscribed remotely",{id:t})}catch(r){r&&(r instanceof B?this.logger.debug("cable disconnected during the unsubscribe command execution",{id:t,error:r}):this.logger.error("unsubscribe failed",{id:t,error:r}))}e.intent==="unsubscribed"?(e.close(),this.hub.unsubscribe(t)):e.state="closed",n.release()}async perform(e,t,n){if(this.performFailures==="throw")return this._perform(e,t,n);try{return await this._perform(e,t,n)}catch(i){this.performFailures==="warn"&&this.logger.warn("perform failed",{error:i});return}}async _perform(e,t,n){if(this.state==="connecting"&&await this.pendingConnect(),this.state==="closed"||this.state==="disconnected")throw new Dt;let i=this.hub.subscriptions.get(e);if(!i)throw Error(`Subscription not found: ${e}`);if(await i.pending("subscribed"),i.intent!=="subscribed")throw Error(`Subscription is closed: ${e}`);let r=i.remoteId,o={id:r,action:t,payload:n};this.logger.debug("perform",o);try{let c=await this.protocol.perform(r,t,n);return c&&this.logger.debug("perform result",{message:c,request:o}),c}catch(c){throw this.logger.error("perform failed",{error:c,request:o}),c}}on(e,t){return this.emitter.on(e,t)}once(e,t){let n=this.emitter.on(e,(...i)=>{n(),t(...i)});return n}emit(e,...t){return this.emitter.emit(e,...t)}pendingConnect(){return this._pendingConnect?this._pendingConnect:(this._pendingConnect=new Promise((e,t)=>{let n=[()=>delete this._pendingConnect];n.push(this.on("connect",()=>{n.forEach(i=>i()),e()})),n.push(this.on("close",i=>{n.forEach(r=>r()),t(i)})),n.push(this.on("disconnect",i=>{n.forEach(r=>r()),t(i)}))}),this._pendingConnect)}}const jt={maxMissingPings:2,maxReconnectAttempts:1/0},G=()=>Date.now(),je=(s,e)=>{e=e||{};let{backoffRate:t,jitterRatio:n,maxInterval:i}=e;return t=t||2,n===void 0&&(n=.5),r=>{let o=s*t**r,c=o*t,a=o+(c-o)*Math.random(),u=2*(Math.random()-.5)*n;return a=a*(1+u),i&&i<a&&(a=i),a}};let xe=class{constructor({pingInterval:e,...t}){if(this.pingInterval=e,!this.pingInterval)throw Error(`Incorrect pingInterval is provided: ${e}`);if(t=Object.assign({},jt,t),this.strategy=t.reconnectStrategy,!this.strategy)throw Error("Reconnect strategy must be provided");this.maxMissingPings=t.maxMissingPings,this.maxReconnectAttempts=t.maxReconnectAttempts,this.logger=t.logger||new H,this.state="pending_connect",this.attempts=0,this.disconnectedAt=G()}watch(e){this.target=e,this.initListeners()}reconnectNow(){return this.state==="connected"||this.state==="pending_connect"||this.state==="closed"?!1:(this.cancelReconnect(),this.state="pending_connect",this.target.connect().catch(e=>{this.logger.info("Failed at reconnecting: "+e)}),!0)}initListeners(){this.unbind=[],this.unbind.push(this.target.on("connect",()=>{this.attempts=0,this.pingedAt=G(),this.state="connected",this.cancelReconnect(),this.startPolling()})),this.unbind.push(this.target.on("disconnect",()=>{this.disconnectedAt=G(),this.state="disconnected",this.stopPolling(),this.scheduleReconnect()})),this.unbind.push(this.target.on("close",()=>{this.disconnectedAt=G(),this.state="closed",this.cancelReconnect(),this.stopPolling()})),this.unbind.push(this.target.on("keepalive",()=>{this.pingedAt=G()})),this.unbind.push(()=>{this.cancelReconnect(),this.stopPolling()})}dispose(){delete this.target,this.unbind&&this.unbind.forEach(e=>e()),delete this.unbind}startPolling(){this.pollId&&clearTimeout(this.pollId);let e=this.pingInterval+(Math.random()-.5)*this.pingInterval*.5;this.pollId=setTimeout(()=>{this.checkStale(),this.state==="connected"&&this.startPolling()},e)}stopPolling(){this.pollId&&clearTimeout(this.pollId)}checkStale(){let e=G()-this.pingedAt;e>this.maxMissingPings*this.pingInterval&&(this.logger.warn(`Stale connection: ${e}ms without pings`),this.state="pending_disconnect",this.target.disconnected(new Tt))}scheduleReconnect(){if(this.attempts>=this.maxReconnectAttempts){this.target.close();return}let e=this.strategy(this.attempts);this.attempts++,this.logger.info(`Reconnecting in ${e}ms (${this.attempts} attempt)`),this.state="pending_reconnect",this.reconnnectId=setTimeout(()=>this.reconnectNow(),e)}cancelReconnect(){this.reconnnectId&&(clearTimeout(this.reconnnectId),delete this.reconnnectId)}};class xt{constructor(e,t={}){this.transports=e,this.transport=null,this.emitter=M(),this.unbind=[],this.logger=t.logger||new H}displayName(){return"fallbacked transport"}async open(){for(let e=0;e<this.transports.length;e++){let t=this.transports[e];try{this.transport=t,this.resetListeners(),this.logger.debug(`Trying to connect via ${t.displayName()}`),await t.open(),this.logger.debug(`Connected via ${t.displayName()}`);return}catch(n){this.logger.debug(`Failed to connect via ${t.displayName()}: ${n.message}`)}}throw this.transport=null,this.resetListeners(),new Error("Couldn't connect via any available transport")}send(e){if(!this.transport)throw new Error("No transport is open");this.transport.send(e)}async close(){if(!this.transport)throw new Error("No transport is open");await this.transport.close(),this.transport=null}setURL(){throw new Error("Not implemented. Set URL for each transport separately")}setParam(e,t){this.transports.forEach(n=>{n.setParam(e,t)})}setToken(e,t){this.transports.forEach(n=>{n.setToken(e,t)})}on(e,t){return this.emitter.on(e,t)}once(e,t){let n=this.emitter.on(e,(...i)=>{n(),t(...i)});return n}get url(){return this.transport?this.transport.url:""}resetListeners(){this.unbind.forEach(e=>e()),this.unbind.length=0,this.transport&&this.unbind.push(this.transport.on("open",()=>{this.emitter.emit("open")}),this.transport.on("data",e=>{this.emitter.emit("data",e)}),this.transport.on("close",e=>{this.emitter.emit("close",e)}),this.transport.on("error",e=>{this.emitter.emit("error",e)}))}}class Qt{constructor(e,t={}){this.url=e;let n=t.websocketImplementation;if(n)this.Impl=n;else if(typeof WebSocket<"u")this.Impl=WebSocket;else throw new Error("No WebSocket support");this.connected=!1,this.emitter=M();let{format:i,subprotocol:r,authStrategy:o}=t;this.format=i||"text",this.connectionOptions=t.websocketOptions,this.authStrategy=o||"param",this.authProtocol="",this.subprotocol=r}displayName(){return"WebSocket("+this.url+")"}open(){let e=this.subprotocol;return this.authStrategy==="sub-protocol"&&(e=[this.subprotocol,this.authProtocol]),this.connectionOptions?this.ws=new this.Impl(this.url,e,this.connectionOptions):this.ws=new this.Impl(this.url,e),this.ws.binaryType="arraybuffer",this.initListeners(),new Promise((t,n)=>{let i=[];i.push(this.once("open",()=>{i.forEach(r=>r()),t()})),i.push(this.once("close",()=>{i.forEach(r=>r()),n(Error("WS connection closed"))}))})}setURL(e){this.url=e}setParam(e,t){let n=new URL(this.url);n.searchParams.set(e,t);let i=`${n.protocol}//${n.host}${n.pathname}?${n.searchParams}`;this.setURL(i)}setToken(e,t="jid"){if(this.authStrategy==="param")this.setParam(t,e);else if(this.authStrategy==="header"){this.connectionOptions=this.connectionOptions||{},this.connectionOptions.headers=this.connectionOptions.headers||{};let n=`x-${t}`.toLowerCase();n=Object.keys(this.connectionOptions.headers).find(r=>r.toLowerCase()===n)||n,this.connectionOptions.headers[n]=e}else if(this.authStrategy==="sub-protocol")this.authProtocol=`anycable-token.${e}`;else throw new Error("Unknown auth strategy: "+this.authStrategy)}send(e){if(!this.ws||!this.connected)throw Error("WebSocket is not connected");this.ws.send(e)}close(){this.ws?this.onclose():this.connected=!1}on(e,t){return this.emitter.on(e,t)}once(e,t){let n=this.emitter.on(e,(...i)=>{n(),t(...i)});return n}initListeners(){this.ws.onerror=e=>{this.connected&&this.emitter.emit("error",e.error||new Error("WS Error"))},this.ws.onclose=()=>{this.onclose()},this.ws.onmessage=e=>{let t=e.data;this.format==="binary"&&(t=new Uint8Array(t)),this.emitter.emit("data",t)},this.ws.onopen=()=>{this.connected=!0,this.emitter.emit("open")}}onclose(){this.ws.onclose=void 0,this.ws.onmessage=void 0,this.ws.onopen=void 0,this.ws.close(),delete this.ws,this.connected=!1,this.emitter.emit("close")}}const Qe={protocol:"actioncable-v1-json",pingInterval:3e3,maxReconnectAttempts:1/0,maxMissingPings:2,logLevel:"warn",lazy:!0};function Gt(s,e){if(typeof s=="object"&&typeof e>"u"&&(e=s,s=void 0),e=e||{},!s&&!e.transport)throw Error("URL or transport must be specified");e=Object.assign({},Qe,e);let{protocol:t,websocketImplementation:n,websocketFormat:i,websocketOptions:r,websocketAuthStrategy:o,fallbacks:c,logLevel:a,logger:u,transport:l,encoder:d,lazy:f,monitor:h,pingInterval:E,reconnectStrategy:b,maxMissingPings:T,maxReconnectAttempts:w,subprotocol:P,tokenRefresher:_,historyTimestamp:I,protocolOptions:N,concurrentSubscribes:p,performFailures:v,transportConfigurator:C,auth:g}=e;if(u=u||new H(a),typeof t=="string"){P=P||t;let S=t.substring(0,t.lastIndexOf("-")),y=t.substring(t.lastIndexOf("-")+1);if(N=N||{},S==="actioncable-v1")t=new De({logger:u,...N});else if(S==="actioncable-v1-ext")t=new Ut({logger:u,historyTimestamp:I,...N});else throw Error(`Protocol is not supported yet: ${t}`);if(y==="json")d=d||new kt,i=i||"text";else if(y==="msgpack"){if(i="binary",!d)throw Error("Msgpack encoder must be specified explicitly. Use `@anycable/msgpack-encoder` package or build your own")}else if(y==="protobuf"){if(i=i||"binary",!d)throw Error("Protobuf encoder must be specified explicitly. Use `@anycable/protobuf-encoder` package or build your own")}else throw Error(`Protocol is not supported yet: ${t}`)}if(!t)throw Error("Protocol must be specified");l=l||new Qt(s,{websocketImplementation:n,websocketOptions:r,subprotocol:P,authStrategy:o,format:i}),c&&(l=new xt([l,...c],{logger:u})),g&&g.token&&l.setToken(g.token,g.param||"jid"),b=b||je(E),h!==!1&&(h=h||new xe({pingInterval:E,reconnectStrategy:b,maxMissingPings:T,maxReconnectAttempts:w,logger:u}));let q={concurrentSubscribes:p},m=new Ot({protocol:t,transport:l,encoder:d,logger:u,lazy:f,hubOptions:q,performFailures:v,transportConfigurator:C});return h&&(h.watch(m),m.monitor=h),_&&Vt(m,async()=>{try{await _(l)}catch(S){return u.error("Failed to refresh authentication token: "+S),!1}return m.connect().catch(()=>{}),!0}),m}function Vt(s,e){let t=!1;s.on("connect",()=>t=!1),s.on("close",async n=>{if(n){if(t){s.logger.warn("Token auto-refresh is disabled",n);return}n.reason==="token_expired"&&(t=!0,await e())}})}class Jt extends Ue{writeLogEntry(e,t,n){n?console[e](t,n):console[e](t)}}class Ht extends xe{watch(e){super.watch(e),this.initActivityListeners()}initActivityListeners(){if(typeof document<"u"&&typeof window<"u"&&document.addEventListener&&window.addEventListener){let e=()=>{document.hidden||this.reconnectNow()&&this.logger.debug("Trigger reconnect due to visibility change")},t=i=>{this.reconnectNow()&&this.logger.debug("Trigger reconnect",{event:i})},n=()=>this.disconnect(new B("page_frozen"));document.addEventListener("visibilitychange",e,!1),window.addEventListener("focus",t,!1),window.addEventListener("online",t,!1),window.addEventListener("resume",t,!1),window.addEventListener("freeze",n,!1),this.unbind.push(()=>{document.removeEventListener("visibilitychange",e,!1),window.removeEventListener("focus",t,!1),window.removeEventListener("online",t,!1),window.removeEventListener("resume",t,!1),window.removeEventListener("freeze",n,!1)})}}disconnect(e){this.state==="disconnected"||this.state==="closed"||(this.logger.info("Disconnecting",{reason:e.message}),this.cancelReconnect(),this.stopPolling(),this.state="pending_disconnect",this.target.disconnected(e))}}const Kt=["cable","action-cable"],Yt="/cable",W=(s,e)=>{for(let t of Kt){let n=s.head.querySelector(`meta[name='${t}-${e}']`);if(n)return n.getAttribute("content")}},Ge=s=>s.match(/wss?:\/\//)?s:typeof window<"u"?`${window.location.protocol.replace("http","ws")}//${window.location.host}${s}`:s,Wt=()=>{if(typeof document<"u"&&document.head){let s=W(document,"url");if(s)return Ge(s)}return Ge(Yt)},Zt=()=>{if(typeof document<"u"&&document.head){let s=W(document,"history-timestamp");if(s)return s|0}},$t=()=>{if(typeof document<"u"&&document.head)return W(document,"token")},Xt=()=>{if(typeof document<"u"&&document.head)return W(document,"token-param")};function en(s,e){typeof s=="object"&&typeof e>"u"&&(e=s,s=void 0),s=s||Wt(),e=e||{},e.historyTimestamp||(e.historyTimestamp=Zt());let t=$t();if(t){let u=Xt();e.auth=Object.assign({token:t,param:u},e.auth||{})}e=Object.assign({},Qe,e);let{logLevel:n,logger:i,pingInterval:r,reconnectStrategy:o,maxMissingPings:c,maxReconnectAttempts:a}=e;return i=e.logger=e.logger||new Jt(n),o=e.reconnectStrategy=e.reconnectStrategy||je(r),e.monitor!==!1&&(e.monitor=e.monitor||new Ht({pingInterval:r,reconnectStrategy:o,maxMissingPings:c,maxReconnectAttempts:a,logger:i})),Gt(s,e)}const tn={answer:"/.netlify/functions/quiz-answer",sync:"/.netlify/functions/quiz-sync"};function nn(s){if(typeof s!="object"||s===null)return!1;const e=s;return typeof e.sessionId=="string"&&(e.activeQuizId===null||typeof e.activeQuizId=="string")&&typeof e.results=="object"&&e.results!==null}function sn(s){if(typeof s!="object"||s===null)return!1;const e=s;return typeof e.quizId=="string"&&typeof e.answer=="string"&&typeof e.sessionId=="string"}class ne{constructor(e){this.resultsChannel=null,this.activeQuizId=null,this.results={},this.voters={},this.online=0,this.submitted={},this.listeners=[],this.syncTimer=null,this.syncPending=!1,this.incomingSyncTimer=null,this.incomingSyncData=null,this.role=e.role,this.quizGroupId=e.quizGroupId,this.sessionId=e.sessionId||this.getOrCreateSessionId(),this.endpoints={...tn,...e.endpoints};const t=e.role==="participant"?6e4:3e5;this.cable=en(e.wsUrl,{protocol:"actioncable-v1-ext-json",protocolOptions:{historyTimestamp:Math.floor((Date.now()-t)/1e3)}}),this.syncChannel=this.cable.streamFrom(`quiz:${e.quizGroupId}:sync`),this.syncChannel.on("message",this.onSyncMessage.bind(this));const n=this.syncChannel.presence;if(typeof n.stateFromInfo=="function"){const i=n.stateFromInfo.bind(n);n.stateFromInfo=r=>{if(!(r!=null&&r.records)){if(r&&typeof r=="object"){const{type:o,...c}=r;return c}return{}}return i(r)}}this.syncChannel.on("presence",this.onPresence.bind(this)),e.role==="participant"&&this.syncChannel.presence.join(this.sessionId,{id:this.sessionId}),this.syncChannel.presence.info().then(i=>{i&&(this.online=Object.keys(i).length,this.notifyStateChange())}).catch(()=>{}),e.role==="presenter"&&(this.resultsChannel=this.cable.streamFrom(`quiz:${e.quizGroupId}:results`),this.resultsChannel.on("message",this.onResultsMessage.bind(this)),this.restoreState(),this.activeQuizId&&this.sendSync()),e.role==="participant"&&this.restoreSubmitted()}subscribe(e){return this.listeners.push(e),e(this.getState()),()=>{const t=this.listeners.indexOf(e);t!==-1&&this.listeners.splice(t,1)}}getState(){return{activeQuizId:this.activeQuizId,results:structuredClone(this.results),online:this.online,submitted:{...this.submitted}}}getQuizState(e){return this.results[e]||{votes:{},total:0}}hasVoted(e){return e in this.submitted}getVotedAnswer(e){return this.submitted[e]??null}setActiveQuiz(e){this.role==="presenter"&&this.activeQuizId!==e&&(this.activeQuizId=e,this.saveState(),this.sendSync())}async submitAnswer(e,t){if(this.hasVoted(e))return!1;try{const n=await fetch(this.endpoints.answer,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({quizId:e,answer:t,sessionId:this.sessionId,quizGroupId:this.quizGroupId})});return n.ok&&(this.submitted[e]=t,this.saveSubmitted(),this.notifyStateChange()),n.ok}catch{return!1}}disconnect(){this.role==="participant"&&this.syncChannel.presence.leave(),this.cable.disconnect()}onSyncMessage(e){const t=this.parse(e);nn(t)&&t.sessionId!==this.sessionId&&this.role==="participant"&&this.applySyncThrottled(t)}applySyncThrottled(e){if(this.incomingSyncTimer){this.incomingSyncData=e;return}this.applySync(e),this.incomingSyncData=null,this.incomingSyncTimer=setTimeout(()=>{this.incomingSyncTimer=null,this.incomingSyncData&&(this.applySync(this.incomingSyncData),this.incomingSyncData=null)},200)}applySync(e){var t;this.activeQuizId=e.activeQuizId,this.results=e.results;for(const n of Object.keys(this.submitted))(((t=e.results[n])==null?void 0:t.total)??0)===0&&this.clearVotedAnswer(n);this.notifyStateChange()}onResultsMessage(e){if(this.role!=="presenter")return;const t=this.parse(e);if(!sn(t)||t.sessionId===this.sessionId)return;const{quizId:n,answer:i,sessionId:r}=t;this.voters[n]||(this.voters[n]=new Set),!this.voters[n].has(r)&&(this.voters[n].add(r),this.results[n]||(this.results[n]={votes:{},total:0}),this.results[n].votes[i]=(this.results[n].votes[i]||0)+1,this.results[n].total+=1,this.saveState(),this.notifyStateChange(),this.sendSyncThrottled())}async onPresence(){try{const e=await this.syncChannel.presence.info();e&&(this.online=Object.keys(e).length,this.notifyStateChange(),this.role==="presenter"&&this.activeQuizId&&this.sendSyncThrottled())}catch{}}sendSyncThrottled(){if(this.syncTimer){this.syncPending=!0;return}this.sendSync(),this.syncTimer=setTimeout(()=>{this.syncTimer=null,this.syncPending&&(this.syncPending=!1,this.sendSync())},200)}async sendSync(){if(this.role==="presenter")try{await fetch(this.endpoints.sync,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({activeQuizId:this.activeQuizId,sessionId:this.sessionId,quizGroupId:this.quizGroupId,results:this.results})})}catch{}}getOrCreateSessionId(){const e=`quiz-session-${this.quizGroupId}`;let t=sessionStorage.getItem(e);return t||(t=crypto.randomUUID(),sessionStorage.setItem(e,t)),t}saveState(){if(this.role==="presenter")try{sessionStorage.setItem(`quiz-presenter-${this.quizGroupId}`,JSON.stringify({activeQuizId:this.activeQuizId,results:this.results,voters:Object.fromEntries(Object.entries(this.voters).map(([e,t])=>[e,[...t]]))}))}catch(e){console.warn("[QuizManager] saveState failed:",e)}}restoreState(){try{const e=sessionStorage.getItem(`quiz-presenter-${this.quizGroupId}`);if(!e)return;const t=JSON.parse(e);if(t.activeQuizId&&(this.activeQuizId=t.activeQuizId),t.results&&(this.results=t.results),t.voters)for(const[n,i]of Object.entries(t.voters))this.voters[n]=new Set(i)}catch{}}saveSubmitted(){try{sessionStorage.setItem(`quiz-submitted-${this.quizGroupId}`,JSON.stringify(this.submitted))}catch{}}restoreSubmitted(){try{const e=sessionStorage.getItem(`quiz-submitted-${this.quizGroupId}`);if(!e)return;this.submitted=JSON.parse(e)}catch{}}clearVotedAnswer(e){delete this.submitted[e],this.saveSubmitted()}notifyStateChange(){const e=this.getState();for(const t of this.listeners)t(e)}parse(e){if(typeof e=="string")try{return JSON.parse(e)}catch{return{}}return e&&typeof e=="object"?e:{}}}const Z=new Map;function Ve(s){return Z.has(s.quizGroupId)||Z.set(s.quizGroupId,new ne({...s,role:"presenter"})),Z.get(s.quizGroupId)}function Je(s){Z.delete(s)}const $=new Map;function rn(s){return $.has(s.quizGroupId)||$.set(s.quizGroupId,new ne({...s,role:"participant"})),$.get(s.quizGroupId)}function on(s){$.delete(s)}function ie(s,e){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){s.textContent=String(e);return}const n=parseInt(s.textContent||"0",10);if(n===e)return;const i=300,r=performance.now(),o=n;function c(a){const u=a-r,l=Math.min(u/i,1),d=1-Math.pow(1-l,3),f=Math.round(o+(e-o)*d);s.textContent=String(f),l<1&&requestAnimationFrame(c)}requestAnimationFrame(c)}function cn(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var V={},se,He;function an(){return He||(He=1,se=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),se}var re={},D={},Ke;function x(){if(Ke)return D;Ke=1;let s;const e=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return D.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17},D.getSymbolTotalCodewords=function(n){return e[n]},D.getBCHDigit=function(t){let n=0;for(;t!==0;)n++,t>>>=1;return n},D.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');s=n},D.isKanjiModeEnabled=function(){return typeof s<"u"},D.toSJIS=function(n){return s(n)},D}var oe={},Ye;function ce(){return Ye||(Ye=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function e(t){if(typeof t!="string")throw new Error("Param is not a string");switch(t.toLowerCase()){case"l":case"low":return s.L;case"m":case"medium":return s.M;case"q":case"quartile":return s.Q;case"h":case"high":return s.H;default:throw new Error("Unknown EC Level: "+t)}}s.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},s.from=function(n,i){if(s.isValid(n))return n;try{return e(n)}catch{return i}}})(oe)),oe}var ae,We;function un(){if(We)return ae;We=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},ae=s,ae}var ue,Ze;function ln(){if(Ze)return ue;Ze=1;function s(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}return s.prototype.set=function(e,t,n,i){const r=e*this.size+t;this.data[r]=n,i&&(this.reservedBit[r]=!0)},s.prototype.get=function(e,t){return this.data[e*this.size+t]},s.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},s.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},ue=s,ue}var le={},$e;function hn(){return $e||($e=1,(function(s){const e=x().getSymbolSize;s.getRowColCoords=function(n){if(n===1)return[];const i=Math.floor(n/7)+2,r=e(n),o=r===145?26:Math.ceil((r-13)/(2*i-2))*2,c=[r-7];for(let a=1;a<i-1;a++)c[a]=c[a-1]-o;return c.push(6),c.reverse()},s.getPositions=function(n){const i=[],r=s.getRowColCoords(n),o=r.length;for(let c=0;c<o;c++)for(let a=0;a<o;a++)c===0&&a===0||c===0&&a===o-1||c===o-1&&a===0||i.push([r[c],r[a]]);return i}})(le)),le}var he={},Xe;function dn(){if(Xe)return he;Xe=1;const s=x().getSymbolSize,e=7;return he.getPositions=function(n){const i=s(n);return[[0,0],[i-e,0],[0,i-e]]},he}var de={},et;function fn(){return et||(et=1,(function(s){s.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e={N1:3,N2:3,N3:40,N4:10};s.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},s.from=function(i){return s.isValid(i)?parseInt(i,10):void 0},s.getPenaltyN1=function(i){const r=i.size;let o=0,c=0,a=0,u=null,l=null;for(let d=0;d<r;d++){c=a=0,u=l=null;for(let f=0;f<r;f++){let h=i.get(d,f);h===u?c++:(c>=5&&(o+=e.N1+(c-5)),u=h,c=1),h=i.get(f,d),h===l?a++:(a>=5&&(o+=e.N1+(a-5)),l=h,a=1)}c>=5&&(o+=e.N1+(c-5)),a>=5&&(o+=e.N1+(a-5))}return o},s.getPenaltyN2=function(i){const r=i.size;let o=0;for(let c=0;c<r-1;c++)for(let a=0;a<r-1;a++){const u=i.get(c,a)+i.get(c,a+1)+i.get(c+1,a)+i.get(c+1,a+1);(u===4||u===0)&&o++}return o*e.N2},s.getPenaltyN3=function(i){const r=i.size;let o=0,c=0,a=0;for(let u=0;u<r;u++){c=a=0;for(let l=0;l<r;l++)c=c<<1&2047|i.get(u,l),l>=10&&(c===1488||c===93)&&o++,a=a<<1&2047|i.get(l,u),l>=10&&(a===1488||a===93)&&o++}return o*e.N3},s.getPenaltyN4=function(i){let r=0;const o=i.data.length;for(let a=0;a<o;a++)r+=i.data[a];return Math.abs(Math.ceil(r*100/o/5)-10)*e.N4};function t(n,i,r){switch(n){case s.Patterns.PATTERN000:return(i+r)%2===0;case s.Patterns.PATTERN001:return i%2===0;case s.Patterns.PATTERN010:return r%3===0;case s.Patterns.PATTERN011:return(i+r)%3===0;case s.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(r/3))%2===0;case s.Patterns.PATTERN101:return i*r%2+i*r%3===0;case s.Patterns.PATTERN110:return(i*r%2+i*r%3)%2===0;case s.Patterns.PATTERN111:return(i*r%3+(i+r)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}s.applyMask=function(i,r){const o=r.size;for(let c=0;c<o;c++)for(let a=0;a<o;a++)r.isReserved(a,c)||r.xor(a,c,t(i,a,c))},s.getBestMask=function(i,r){const o=Object.keys(s.Patterns).length;let c=0,a=1/0;for(let u=0;u<o;u++){r(u),s.applyMask(u,i);const l=s.getPenaltyN1(i)+s.getPenaltyN2(i)+s.getPenaltyN3(i)+s.getPenaltyN4(i);s.applyMask(u,i),l<a&&(a=l,c=u)}return c}})(de)),de}var X={},tt;function nt(){if(tt)return X;tt=1;const s=ce(),e=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],t=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return X.getBlocksCount=function(i,r){switch(r){case s.L:return e[(i-1)*4+0];case s.M:return e[(i-1)*4+1];case s.Q:return e[(i-1)*4+2];case s.H:return e[(i-1)*4+3];default:return}},X.getTotalCodewordsCount=function(i,r){switch(r){case s.L:return t[(i-1)*4+0];case s.M:return t[(i-1)*4+1];case s.Q:return t[(i-1)*4+2];case s.H:return t[(i-1)*4+3];default:return}},X}var fe={},K={},it;function gn(){if(it)return K;it=1;const s=new Uint8Array(512),e=new Uint8Array(256);return(function(){let n=1;for(let i=0;i<255;i++)s[i]=n,e[n]=i,n<<=1,n&256&&(n^=285);for(let i=255;i<512;i++)s[i]=s[i-255]})(),K.log=function(n){if(n<1)throw new Error("log("+n+")");return e[n]},K.exp=function(n){return s[n]},K.mul=function(n,i){return n===0||i===0?0:s[e[n]+e[i]]},K}var st;function pn(){return st||(st=1,(function(s){const e=gn();s.mul=function(n,i){const r=new Uint8Array(n.length+i.length-1);for(let o=0;o<n.length;o++)for(let c=0;c<i.length;c++)r[o+c]^=e.mul(n[o],i[c]);return r},s.mod=function(n,i){let r=new Uint8Array(n);for(;r.length-i.length>=0;){const o=r[0];for(let a=0;a<i.length;a++)r[a]^=e.mul(i[a],o);let c=0;for(;c<r.length&&r[c]===0;)c++;r=r.slice(c)}return r},s.generateECPolynomial=function(n){let i=new Uint8Array([1]);for(let r=0;r<n;r++)i=s.mul(i,new Uint8Array([1,e.exp(r)]));return i}})(fe)),fe}var ge,rt;function mn(){if(rt)return ge;rt=1;const s=pn();function e(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}return e.prototype.initialize=function(n){this.degree=n,this.genPoly=s.generateECPolynomial(this.degree)},e.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const i=new Uint8Array(n.length+this.degree);i.set(n);const r=s.mod(i,this.genPoly),o=this.degree-r.length;if(o>0){const c=new Uint8Array(this.degree);return c.set(r,o),c}return r},ge=e,ge}var pe={},me={},be={},ot;function ct(){return ot||(ot=1,be.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),be}var k={},at;function ut(){if(at)return k;at=1;const s="[0-9]+",e="[A-Z $%*+\\-./:]+";let t="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";t=t.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+t+`)(?:.|[\r
|
|
2
|
+
]))+`;k.KANJI=new RegExp(t,"g"),k.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),k.BYTE=new RegExp(n,"g"),k.NUMERIC=new RegExp(s,"g"),k.ALPHANUMERIC=new RegExp(e,"g");const i=new RegExp("^"+t+"$"),r=new RegExp("^"+s+"$"),o=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return k.testKanji=function(a){return i.test(a)},k.testNumeric=function(a){return r.test(a)},k.testAlphanumeric=function(a){return o.test(a)},k}var lt;function Q(){return lt||(lt=1,(function(s){const e=ct(),t=ut();s.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},s.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},s.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},s.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},s.MIXED={bit:-1},s.getCharCountIndicator=function(r,o){if(!r.ccBits)throw new Error("Invalid mode: "+r);if(!e.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?r.ccBits[0]:o<27?r.ccBits[1]:r.ccBits[2]},s.getBestModeForData=function(r){return t.testNumeric(r)?s.NUMERIC:t.testAlphanumeric(r)?s.ALPHANUMERIC:t.testKanji(r)?s.KANJI:s.BYTE},s.toString=function(r){if(r&&r.id)return r.id;throw new Error("Invalid mode")},s.isValid=function(r){return r&&r.bit&&r.ccBits};function n(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return s.NUMERIC;case"alphanumeric":return s.ALPHANUMERIC;case"kanji":return s.KANJI;case"byte":return s.BYTE;default:throw new Error("Unknown mode: "+i)}}s.from=function(r,o){if(s.isValid(r))return r;try{return n(r)}catch{return o}}})(me)),me}var ht;function bn(){return ht||(ht=1,(function(s){const e=x(),t=nt(),n=ce(),i=Q(),r=ct(),o=7973,c=e.getBCHDigit(o);function a(f,h,E){for(let b=1;b<=40;b++)if(h<=s.getCapacity(b,E,f))return b}function u(f,h){return i.getCharCountIndicator(f,h)+4}function l(f,h){let E=0;return f.forEach(function(b){const T=u(b.mode,h);E+=T+b.getBitsLength()}),E}function d(f,h){for(let E=1;E<=40;E++)if(l(f,E)<=s.getCapacity(E,h,i.MIXED))return E}s.from=function(h,E){return r.isValid(h)?parseInt(h,10):E},s.getCapacity=function(h,E,b){if(!r.isValid(h))throw new Error("Invalid QR Code version");typeof b>"u"&&(b=i.BYTE);const T=e.getSymbolTotalCodewords(h),w=t.getTotalCodewordsCount(h,E),P=(T-w)*8;if(b===i.MIXED)return P;const _=P-u(b,h);switch(b){case i.NUMERIC:return Math.floor(_/10*3);case i.ALPHANUMERIC:return Math.floor(_/11*2);case i.KANJI:return Math.floor(_/13);case i.BYTE:default:return Math.floor(_/8)}},s.getBestVersionForData=function(h,E){let b;const T=n.from(E,n.M);if(Array.isArray(h)){if(h.length>1)return d(h,T);if(h.length===0)return 1;b=h[0]}else b=h;return a(b.mode,b.getLength(),T)},s.getEncodedBits=function(h){if(!r.isValid(h)||h<7)throw new Error("Invalid QR Code version");let E=h<<12;for(;e.getBCHDigit(E)-c>=0;)E^=o<<e.getBCHDigit(E)-c;return h<<12|E}})(pe)),pe}var ye={},dt;function yn(){if(dt)return ye;dt=1;const s=x(),e=1335,t=21522,n=s.getBCHDigit(e);return ye.getEncodedBits=function(r,o){const c=r.bit<<3|o;let a=c<<10;for(;s.getBCHDigit(a)-n>=0;)a^=e<<s.getBCHDigit(a)-n;return(c<<10|a)^t},ye}var we={},Se,ft;function wn(){if(ft)return Se;ft=1;const s=Q();function e(t){this.mode=s.NUMERIC,this.data=t.toString()}return e.getBitsLength=function(n){return 10*Math.floor(n/3)+(n%3?n%3*3+1:0)},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(n){let i,r,o;for(i=0;i+3<=this.data.length;i+=3)r=this.data.substr(i,3),o=parseInt(r,10),n.put(o,10);const c=this.data.length-i;c>0&&(r=this.data.substr(i),o=parseInt(r,10),n.put(o,c*3+1))},Se=e,Se}var Ee,gt;function Sn(){if(gt)return Ee;gt=1;const s=Q(),e=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function t(n){this.mode=s.ALPHANUMERIC,this.data=n}return t.getBitsLength=function(i){return 11*Math.floor(i/2)+6*(i%2)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(i){let r;for(r=0;r+2<=this.data.length;r+=2){let o=e.indexOf(this.data[r])*45;o+=e.indexOf(this.data[r+1]),i.put(o,11)}this.data.length%2&&i.put(e.indexOf(this.data[r]),6)},Ee=t,Ee}var Ce,pt;function En(){if(pt)return Ce;pt=1;const s=Q();function e(t){this.mode=s.BYTE,typeof t=="string"?this.data=new TextEncoder().encode(t):this.data=new Uint8Array(t)}return e.getBitsLength=function(n){return n*8},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(t){for(let n=0,i=this.data.length;n<i;n++)t.put(this.data[n],8)},Ce=e,Ce}var ve,mt;function Cn(){if(mt)return ve;mt=1;const s=Q(),e=x();function t(n){this.mode=s.KANJI,this.data=n}return t.getBitsLength=function(i){return i*13},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(n){let i;for(i=0;i<this.data.length;i++){let r=e.toSJIS(this.data[i]);if(r>=33088&&r<=40956)r-=33088;else if(r>=57408&&r<=60351)r-=49472;else throw new Error("Invalid SJIS character: "+this.data[i]+`
|
|
3
|
+
Make sure your charset is UTF-8`);r=(r>>>8&255)*192+(r&255),n.put(r,13)}},ve=t,ve}var Ie={exports:{}},bt;function vn(){return bt||(bt=1,(function(s){var e={single_source_shortest_paths:function(t,n,i){var r={},o={};o[n]=0;var c=e.PriorityQueue.make();c.push(n,0);for(var a,u,l,d,f,h,E,b,T;!c.empty();){a=c.pop(),u=a.value,d=a.cost,f=t[u]||{};for(l in f)f.hasOwnProperty(l)&&(h=f[l],E=d+h,b=o[l],T=typeof o[l]>"u",(T||b>E)&&(o[l]=E,c.push(l,E),r[l]=u))}if(typeof i<"u"&&typeof o[i]>"u"){var w=["Could not find a path from ",n," to ",i,"."].join("");throw new Error(w)}return r},extract_shortest_path_from_predecessor_list:function(t,n){for(var i=[],r=n;r;)i.push(r),t[r],r=t[r];return i.reverse(),i},find_path:function(t,n,i){var r=e.single_source_shortest_paths(t,n,i);return e.extract_shortest_path_from_predecessor_list(r,i)},PriorityQueue:{make:function(t){var n=e.PriorityQueue,i={},r;t=t||{};for(r in n)n.hasOwnProperty(r)&&(i[r]=n[r]);return i.queue=[],i.sorter=t.sorter||n.default_sorter,i},default_sorter:function(t,n){return t.cost-n.cost},push:function(t,n){var i={value:t,cost:n};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};s.exports=e})(Ie)),Ie.exports}var yt;function In(){return yt||(yt=1,(function(s){const e=Q(),t=wn(),n=Sn(),i=En(),r=Cn(),o=ut(),c=x(),a=vn();function u(w){return unescape(encodeURIComponent(w)).length}function l(w,P,_){const I=[];let N;for(;(N=w.exec(_))!==null;)I.push({data:N[0],index:N.index,mode:P,length:N[0].length});return I}function d(w){const P=l(o.NUMERIC,e.NUMERIC,w),_=l(o.ALPHANUMERIC,e.ALPHANUMERIC,w);let I,N;return c.isKanjiModeEnabled()?(I=l(o.BYTE,e.BYTE,w),N=l(o.KANJI,e.KANJI,w)):(I=l(o.BYTE_KANJI,e.BYTE,w),N=[]),P.concat(_,I,N).sort(function(v,C){return v.index-C.index}).map(function(v){return{data:v.data,mode:v.mode,length:v.length}})}function f(w,P){switch(P){case e.NUMERIC:return t.getBitsLength(w);case e.ALPHANUMERIC:return n.getBitsLength(w);case e.KANJI:return r.getBitsLength(w);case e.BYTE:return i.getBitsLength(w)}}function h(w){return w.reduce(function(P,_){const I=P.length-1>=0?P[P.length-1]:null;return I&&I.mode===_.mode?(P[P.length-1].data+=_.data,P):(P.push(_),P)},[])}function E(w){const P=[];for(let _=0;_<w.length;_++){const I=w[_];switch(I.mode){case e.NUMERIC:P.push([I,{data:I.data,mode:e.ALPHANUMERIC,length:I.length},{data:I.data,mode:e.BYTE,length:I.length}]);break;case e.ALPHANUMERIC:P.push([I,{data:I.data,mode:e.BYTE,length:I.length}]);break;case e.KANJI:P.push([I,{data:I.data,mode:e.BYTE,length:u(I.data)}]);break;case e.BYTE:P.push([{data:I.data,mode:e.BYTE,length:u(I.data)}])}}return P}function b(w,P){const _={},I={start:{}};let N=["start"];for(let p=0;p<w.length;p++){const v=w[p],C=[];for(let g=0;g<v.length;g++){const q=v[g],m=""+p+g;C.push(m),_[m]={node:q,lastCount:0},I[m]={};for(let S=0;S<N.length;S++){const y=N[S];_[y]&&_[y].node.mode===q.mode?(I[y][m]=f(_[y].lastCount+q.length,q.mode)-f(_[y].lastCount,q.mode),_[y].lastCount+=q.length):(_[y]&&(_[y].lastCount=q.length),I[y][m]=f(q.length,q.mode)+4+e.getCharCountIndicator(q.mode,P))}}N=C}for(let p=0;p<N.length;p++)I[N[p]].end=0;return{map:I,table:_}}function T(w,P){let _;const I=e.getBestModeForData(w);if(_=e.from(P,I),_!==e.BYTE&&_.bit<I.bit)throw new Error('"'+w+'" cannot be encoded with mode '+e.toString(_)+`.
|
|
4
|
+
Suggested mode is: `+e.toString(I));switch(_===e.KANJI&&!c.isKanjiModeEnabled()&&(_=e.BYTE),_){case e.NUMERIC:return new t(w);case e.ALPHANUMERIC:return new n(w);case e.KANJI:return new r(w);case e.BYTE:return new i(w)}}s.fromArray=function(P){return P.reduce(function(_,I){return typeof I=="string"?_.push(T(I,null)):I.data&&_.push(T(I.data,I.mode)),_},[])},s.fromString=function(P,_){const I=d(P,c.isKanjiModeEnabled()),N=E(I),p=b(N,_),v=a.find_path(p.map,"start","end"),C=[];for(let g=1;g<v.length-1;g++)C.push(p.table[v[g]].node);return s.fromArray(h(C))},s.rawSplit=function(P){return s.fromArray(d(P,c.isKanjiModeEnabled()))}})(we)),we}var wt;function qn(){if(wt)return re;wt=1;const s=x(),e=ce(),t=un(),n=ln(),i=hn(),r=dn(),o=fn(),c=nt(),a=mn(),u=bn(),l=yn(),d=Q(),f=In();function h(p,v){const C=p.size,g=r.getPositions(v);for(let q=0;q<g.length;q++){const m=g[q][0],S=g[q][1];for(let y=-1;y<=7;y++)if(!(m+y<=-1||C<=m+y))for(let R=-1;R<=7;R++)S+R<=-1||C<=S+R||(y>=0&&y<=6&&(R===0||R===6)||R>=0&&R<=6&&(y===0||y===6)||y>=2&&y<=4&&R>=2&&R<=4?p.set(m+y,S+R,!0,!0):p.set(m+y,S+R,!1,!0))}}function E(p){const v=p.size;for(let C=8;C<v-8;C++){const g=C%2===0;p.set(C,6,g,!0),p.set(6,C,g,!0)}}function b(p,v){const C=i.getPositions(v);for(let g=0;g<C.length;g++){const q=C[g][0],m=C[g][1];for(let S=-2;S<=2;S++)for(let y=-2;y<=2;y++)S===-2||S===2||y===-2||y===2||S===0&&y===0?p.set(q+S,m+y,!0,!0):p.set(q+S,m+y,!1,!0)}}function T(p,v){const C=p.size,g=u.getEncodedBits(v);let q,m,S;for(let y=0;y<18;y++)q=Math.floor(y/3),m=y%3+C-8-3,S=(g>>y&1)===1,p.set(q,m,S,!0),p.set(m,q,S,!0)}function w(p,v,C){const g=p.size,q=l.getEncodedBits(v,C);let m,S;for(m=0;m<15;m++)S=(q>>m&1)===1,m<6?p.set(m,8,S,!0):m<8?p.set(m+1,8,S,!0):p.set(g-15+m,8,S,!0),m<8?p.set(8,g-m-1,S,!0):m<9?p.set(8,15-m-1+1,S,!0):p.set(8,15-m-1,S,!0);p.set(g-8,8,1,!0)}function P(p,v){const C=p.size;let g=-1,q=C-1,m=7,S=0;for(let y=C-1;y>0;y-=2)for(y===6&&y--;;){for(let R=0;R<2;R++)if(!p.isReserved(q,y-R)){let F=!1;S<v.length&&(F=(v[S]>>>m&1)===1),p.set(q,y-R,F),m--,m===-1&&(S++,m=7)}if(q+=g,q<0||C<=q){q-=g,g=-g;break}}}function _(p,v,C){const g=new t;C.forEach(function(R){g.put(R.mode.bit,4),g.put(R.getLength(),d.getCharCountIndicator(R.mode,p)),R.write(g)});const q=s.getSymbolTotalCodewords(p),m=c.getTotalCodewordsCount(p,v),S=(q-m)*8;for(g.getLengthInBits()+4<=S&&g.put(0,4);g.getLengthInBits()%8!==0;)g.putBit(0);const y=(S-g.getLengthInBits())/8;for(let R=0;R<y;R++)g.put(R%2?17:236,8);return I(g,p,v)}function I(p,v,C){const g=s.getSymbolTotalCodewords(v),q=c.getTotalCodewordsCount(v,C),m=g-q,S=c.getBlocksCount(v,C),y=g%S,R=S-y,F=Math.floor(g/S),Y=Math.floor(m/S),Un=Y+1,qt=F-Y,Dn=new a(qt);let Re=0;const ee=new Array(S),_t=new Array(S);let Te=0;const Fn=new Uint8Array(p.buffer);for(let J=0;J<S;J++){const Ae=J<R?Y:Un;ee[J]=Fn.slice(Re,Re+Ae),_t[J]=Dn.encode(ee[J]),Re+=Ae,Te=Math.max(Te,Ae)}const Ne=new Uint8Array(g);let Pt=0,L,U;for(L=0;L<Te;L++)for(U=0;U<S;U++)L<ee[U].length&&(Ne[Pt++]=ee[U][L]);for(L=0;L<qt;L++)for(U=0;U<S;U++)Ne[Pt++]=_t[U][L];return Ne}function N(p,v,C,g){let q;if(Array.isArray(p))q=f.fromArray(p);else if(typeof p=="string"){let F=v;if(!F){const Y=f.rawSplit(p);F=u.getBestVersionForData(Y,C)}q=f.fromString(p,F||40)}else throw new Error("Invalid data");const m=u.getBestVersionForData(q,C);if(!m)throw new Error("The amount of data is too big to be stored in a QR Code");if(!v)v=m;else if(v<m)throw new Error(`
|
|
5
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
6
|
+
Minimum version required to store current data is: `+m+`.
|
|
7
|
+
`);const S=_(v,C,q),y=s.getSymbolSize(v),R=new n(y);return h(R,v),E(R),b(R,v),w(R,C,0),v>=7&&T(R,v),P(R,S),isNaN(g)&&(g=o.getBestMask(R,w.bind(null,R,C))),o.applyMask(g,R),w(R,C,g),{modules:R,version:v,errorCorrectionLevel:C,maskPattern:g,segments:q}}return re.create=function(v,C){if(typeof v>"u"||v==="")throw new Error("No input text");let g=e.M,q,m;return typeof C<"u"&&(g=e.from(C.errorCorrectionLevel,e.M),q=u.from(C.version),m=o.from(C.maskPattern),C.toSJISFunc&&s.setToSJISFunction(C.toSJISFunc)),N(v,q,g,m)},re}var qe={},_e={},St;function Et(){return St||(St=1,(function(s){function e(t){if(typeof t=="number"&&(t=t.toString()),typeof t!="string")throw new Error("Color should be defined as hex string");let n=t.slice().replace("#","").split("");if(n.length<3||n.length===5||n.length>8)throw new Error("Invalid hex color: "+t);(n.length===3||n.length===4)&&(n=Array.prototype.concat.apply([],n.map(function(r){return[r,r]}))),n.length===6&&n.push("F","F");const i=parseInt(n.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+n.slice(0,6).join("")}}s.getOptions=function(n){n||(n={}),n.color||(n.color={});const i=typeof n.margin>"u"||n.margin===null||n.margin<0?4:n.margin,r=n.width&&n.width>=21?n.width:void 0,o=n.scale||4;return{width:r,scale:r?4:o,margin:i,color:{dark:e(n.color.dark||"#000000ff"),light:e(n.color.light||"#ffffffff")},type:n.type,rendererOpts:n.rendererOpts||{}}},s.getScale=function(n,i){return i.width&&i.width>=n+i.margin*2?i.width/(n+i.margin*2):i.scale},s.getImageWidth=function(n,i){const r=s.getScale(n,i);return Math.floor((n+i.margin*2)*r)},s.qrToImageData=function(n,i,r){const o=i.modules.size,c=i.modules.data,a=s.getScale(o,r),u=Math.floor((o+r.margin*2)*a),l=r.margin*a,d=[r.color.light,r.color.dark];for(let f=0;f<u;f++)for(let h=0;h<u;h++){let E=(f*u+h)*4,b=r.color.light;if(f>=l&&h>=l&&f<u-l&&h<u-l){const T=Math.floor((f-l)/a),w=Math.floor((h-l)/a);b=d[c[T*o+w]?1:0]}n[E++]=b.r,n[E++]=b.g,n[E++]=b.b,n[E]=b.a}}})(_e)),_e}var Ct;function _n(){return Ct||(Ct=1,(function(s){const e=Et();function t(i,r,o){i.clearRect(0,0,r.width,r.height),r.style||(r.style={}),r.height=o,r.width=o,r.style.height=o+"px",r.style.width=o+"px"}function n(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}s.render=function(r,o,c){let a=c,u=o;typeof a>"u"&&(!o||!o.getContext)&&(a=o,o=void 0),o||(u=n()),a=e.getOptions(a);const l=e.getImageWidth(r.modules.size,a),d=u.getContext("2d"),f=d.createImageData(l,l);return e.qrToImageData(f.data,r,a),t(d,u,l),d.putImageData(f,0,0),u},s.renderToDataURL=function(r,o,c){let a=c;typeof a>"u"&&(!o||!o.getContext)&&(a=o,o=void 0),a||(a={});const u=s.render(r,o,a),l=a.type||"image/png",d=a.rendererOpts||{};return u.toDataURL(l,d.quality)}})(qe)),qe}var Pe={},vt;function Pn(){if(vt)return Pe;vt=1;const s=Et();function e(i,r){const o=i.a/255,c=r+'="'+i.hex+'"';return o<1?c+" "+r+'-opacity="'+o.toFixed(2).slice(1)+'"':c}function t(i,r,o){let c=i+r;return typeof o<"u"&&(c+=" "+o),c}function n(i,r,o){let c="",a=0,u=!1,l=0;for(let d=0;d<i.length;d++){const f=Math.floor(d%r),h=Math.floor(d/r);!f&&!u&&(u=!0),i[d]?(l++,d>0&&f>0&&i[d-1]||(c+=u?t("M",f+o,.5+h+o):t("m",a,0),a=0,u=!1),f+1<r&&i[d+1]||(c+=t("h",l),l=0)):a++}return c}return Pe.render=function(r,o,c){const a=s.getOptions(o),u=r.modules.size,l=r.modules.data,d=u+a.margin*2,f=a.color.light.a?"<path "+e(a.color.light,"fill")+' d="M0 0h'+d+"v"+d+'H0z"/>':"",h="<path "+e(a.color.dark,"stroke")+' d="'+n(l,u,a.margin)+'"/>',E='viewBox="0 0 '+d+" "+d+'"',T='<svg xmlns="http://www.w3.org/2000/svg" '+(a.width?'width="'+a.width+'" height="'+a.width+'" ':"")+E+' shape-rendering="crispEdges">'+f+h+`</svg>
|
|
8
|
+
`;return typeof c=="function"&&c(null,T),T},Pe}var It;function Rn(){if(It)return V;It=1;const s=an(),e=qn(),t=_n(),n=Pn();function i(r,o,c,a,u){const l=[].slice.call(arguments,1),d=l.length,f=typeof l[d-1]=="function";if(!f&&!s())throw new Error("Callback required as last argument");if(f){if(d<2)throw new Error("Too few arguments provided");d===2?(u=c,c=o,o=a=void 0):d===3&&(o.getContext&&typeof u>"u"?(u=a,a=void 0):(u=a,a=c,c=o,o=void 0))}else{if(d<1)throw new Error("Too few arguments provided");return d===1?(c=o,o=a=void 0):d===2&&!o.getContext&&(a=c,c=o,o=void 0),new Promise(function(h,E){try{const b=e.create(c,a);h(r(b,o,a))}catch(b){E(b)}})}try{const h=e.create(c,a);u(null,r(h,o,a))}catch(h){u(h)}}return V.create=e.create,V.toCanvas=i.bind(null,t.render),V.toDataURL=i.bind(null,t.renderToDataURL),V.toString=i.bind(null,function(r,o,c){return n.render(r,c)}),V}var Tn=Rn();const Nn=cn(Tn);async function An(s,e=240){const t=await Nn.toDataURL(s,{width:e,margin:1,color:{dark:"#ffffff",light:"#00000000"}}),n=document.createElement("img");return n.src=t,n.alt=`Scan to join: ${s}`,n.className="lq-qr",n.width=e,n.height=e,n}async function Mn(s,e,t="Pop quiz!"){const n=s.dataset.quizId,i=s.dataset.quizQuestion||"";let r=[];try{r=JSON.parse(s.dataset.quizOptions||"[]")}catch{console.warn(`[live-quiz] Invalid data-quiz-options on quiz "${n}"`);return}const o=document.createElement("div");o.className="lq-question";const c=document.createElement("h2");c.className="lq-question__title",c.textContent=t,o.appendChild(c);const a=document.createElement("div");if(a.className="lq-question__body",e){const b=document.createElement("div");b.className="lq-question__qr-side";const T=await An(e);b.appendChild(T);const w=document.createElement("p");w.className="lq-question__url",w.textContent=e.replace(/^https?:\/\//,""),b.appendChild(w),a.appendChild(b)}const u=document.createElement("div");u.className="lq-question__content";const l=document.createElement("p");l.className="lq-question__text",l.textContent=i,u.appendChild(l);const d=document.createElement("div");d.className="lq-question__options";for(const b of r){const T=document.createElement("div");T.className="lq-question__option";const w=document.createElement("span");w.className="lq-question__option-label",w.textContent=b.label;const P=document.createElement("span");P.className="lq-question__option-text",P.textContent=b.text,T.appendChild(w),T.appendChild(P),d.appendChild(T)}u.appendChild(d);const f=document.createElement("div");f.className="lq-question__counter";const h=document.createElement("span");h.className="lq-online",h.dataset.lqQuiz=n,h.textContent="0";const E=document.createElement("span");E.className="lq-answered",E.dataset.lqQuiz=n,E.textContent="0",f.append(h," online · ",E," answered"),u.appendChild(f),a.appendChild(u),o.appendChild(a),s.appendChild(o)}function Bn(s){const e=s.dataset.quizResults,t=s.dataset.quizQuestion||"";let n=[];try{n=JSON.parse(s.dataset.quizOptions||"[]")}catch{console.warn(`[live-quiz] Invalid data-quiz-options on results "${e}"`);return}const i=document.createElement("div");if(i.className="lq-results",i.dataset.lqQuiz=e,t){const o=document.createElement("h2");o.className="lq-results__title",o.textContent=t,i.appendChild(o)}const r=document.createElement("div");r.className="lq-results__bars";for(const o of n){const c=document.createElement("div");c.className="lq-result-bar",o.correct&&c.classList.add("lq-result-bar--correct"),c.dataset.option=o.label;const a=document.createElement("div");a.className="lq-result-bar__label";const u=document.createElement("span");u.className="lq-result-bar__letter",u.textContent=o.label;const l=document.createElement("span");l.className="lq-result-bar__text",l.textContent=o.text,a.append(u,l);const d=document.createElement("div");d.className="lq-result-bar__track";const f=document.createElement("div");f.className="lq-result-bar__fill",f.style.width="0%",d.appendChild(f);const h=document.createElement("div");h.className="lq-result-bar__stats";const E=document.createElement("span");E.className="lq-result-bar__pct",E.textContent="0%";const b=document.createElement("span");b.className="lq-result-bar__count",b.textContent="0",h.append(E,b),c.append(a,d,h),r.appendChild(c)}i.appendChild(r),s.appendChild(i)}function zn(s,e){const t=s.querySelectorAll(".lq-result-bar"),n=e.total||1;for(const i of t){const r=i.dataset.option||"",o=e.votes[r]||0,c=Math.round(o/n*100),a=i.querySelector(".lq-result-bar__fill"),u=i.querySelector(".lq-result-bar__pct"),l=i.querySelector(".lq-result-bar__count");a&&(a.style.width=`${c}%`),u&&(u.textContent=`${c}%`),l&&(l.textContent=String(o))}}function kn(s,e){const t=window.matchMedia("(prefers-reduced-motion: reduce)").matches,n=s.querySelectorAll(".lq-result-bar"),i=e.total||1;let r=0;for(const o of n){const c=o.dataset.option||"",a=e.votes[c]||0,u=Math.round(a/i*100),l=o.querySelector(".lq-result-bar__fill"),d=o.querySelector(".lq-result-bar__pct"),f=o.querySelector(".lq-result-bar__count");l&&(t?l.style.width=`${u}%`:(l.style.transitionDelay=`${r*.15}s`,requestAnimationFrame(()=>{l.style.width=`${u}%`}))),d&&(d.textContent=`${u}%`),f&&(f.textContent=String(a)),r++}}function Ln(){let s=null,e,t=null,n=null;const i=new Set;function r(c){if(!t)return;const{currentSlide:a}=c,u=a.dataset.quizId;u&&t.setActiveQuiz(u);const l=a.dataset.quizResults;if(l&&!i.has(l)){i.add(l);const d=a.querySelector(`[data-lq-quiz="${l}"]`);if(d){const f=t.getQuizState(l);kn(d,f)}}}function o(){if(!t||!s)return;const c=t.getState(),a=s.getRevealElement();for(const u of a.querySelectorAll(".lq-online"))ie(u,c.online);for(const[u,l]of Object.entries(c.results)){for(const d of a.querySelectorAll(`.lq-answered[data-lq-quiz="${u}"]`))ie(d,l.total);if(i.has(u))for(const d of a.querySelectorAll(`.lq-results[data-lq-quiz="${u}"]`))zn(d,l)}}return{id:"live-quiz",init:async c=>{if(s=c,e=s.getConfig().liveQuiz??{},!e.wsUrl||!e.quizGroupId){console.warn("[live-quiz] Missing required config: wsUrl and quizGroupId. Pass them in Reveal.initialize({ liveQuiz: { wsUrl, quizGroupId } }).");return}t=Ve({wsUrl:e.wsUrl,quizGroupId:e.quizGroupId,endpoints:e.endpoints});const a=s.getRevealElement(),u=a.querySelectorAll("section[data-quiz-id]"),l=[];for(const d of u){const f=Mn(d,e.quizUrl,e.titleText).catch(h=>console.warn("[live-quiz] Failed to render question slide:",h));l.push(f)}for(const d of a.querySelectorAll("section[data-quiz-results]"))Bn(d);await Promise.all(l),n=t.subscribe(o),s.on("slidechanged",r)},destroy:()=>{if(!s)return;s.off("slidechanged",r),n&&(n(),n=null),t&&(Je(e.quizGroupId),t.disconnect(),t=null);const c=s.getRevealElement();for(const a of c.querySelectorAll(".lq-question, .lq-results"))a.remove();i.clear(),s=null}}}A.QuizManager=ne,A.animateCount=ie,A.default=Ln,A.getQuizParticipant=rn,A.getQuizPresenter=Ve,A.removeQuizParticipant=on,A.removeQuizPresenter=Je,Object.defineProperties(A,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standalone participant widget for live-quiz.
|
|
3
|
+
* No Reveal.js dependency — designed for a mobile-friendly audience page.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* import { createParticipantUI } from 'live-quiz/participant';
|
|
7
|
+
* import 'live-quiz/participant.css';
|
|
8
|
+
*
|
|
9
|
+
* createParticipantUI('#quiz-root', {
|
|
10
|
+
* wsUrl: 'wss://your-cable.fly.dev/cable',
|
|
11
|
+
* quizGroupId: 'my-talk',
|
|
12
|
+
* questions: [
|
|
13
|
+
* {
|
|
14
|
+
* quizId: 'q1',
|
|
15
|
+
* question: 'Which metric is NOT included?',
|
|
16
|
+
* options: [
|
|
17
|
+
* { label: 'A', text: 'Time to First Value' },
|
|
18
|
+
* { label: 'B', text: 'GitHub stars' },
|
|
19
|
+
* ]
|
|
20
|
+
* }
|
|
21
|
+
* ]
|
|
22
|
+
* });
|
|
23
|
+
*/
|
|
24
|
+
import "./participant.css";
|
|
25
|
+
import type { QuizEndpoints } from "../src/quiz-manager";
|
|
26
|
+
export interface ParticipantQuestion {
|
|
27
|
+
quizId: string;
|
|
28
|
+
question: string;
|
|
29
|
+
options: {
|
|
30
|
+
label: string;
|
|
31
|
+
text: string;
|
|
32
|
+
}[];
|
|
33
|
+
}
|
|
34
|
+
export interface ParticipantConfig {
|
|
35
|
+
wsUrl: string;
|
|
36
|
+
quizGroupId: string;
|
|
37
|
+
questions: ParticipantQuestion[];
|
|
38
|
+
/** Custom endpoint URLs for answer/sync functions */
|
|
39
|
+
endpoints?: Partial<QuizEndpoints>;
|
|
40
|
+
/** Brand text shown at top (default: none) */
|
|
41
|
+
brandText?: string;
|
|
42
|
+
/** Footer text (default: "Powered by AnyCable") */
|
|
43
|
+
footerText?: string;
|
|
44
|
+
}
|
|
45
|
+
export declare function createParticipantUI(selector: string, config: ParticipantConfig): {
|
|
46
|
+
destroy: () => void;
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../participant/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEtE,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC5C;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,mBAAmB,EAAE,CAAC;IACjC,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACnC,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,iBAAiB,GACxB;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CA+OzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--lq-p-bg: #1a1a2e;--lq-p-text: #f0f0f0;--lq-p-text-muted: #9ca3af;--lq-p-text-dim: #6b7280;--lq-p-text-faint: #4b5563;--lq-p-accent: #f59e0b;--lq-p-accent-bright: oklch(62% .28 65);--lq-p-brand: #9ca3af;--lq-p-status-text: #d1d5db;--lq-p-btn-border: rgba(156, 163, 175, .3);--lq-p-btn-bg: rgba(30, 30, 50, .6);--lq-p-btn-selected-bg: rgba(245, 158, 11, .15);--lq-p-btn-selected-glow: 0 0 8px rgba(245, 158, 11, .3), 0 0 20px rgba(245, 158, 11, .15);--lq-p-font: system-ui, -apple-system, sans-serif;--lq-p-border-radius: .75rem}.lq-participant{display:flex;flex-direction:column;align-items:center;min-height:100%;padding:1.5rem;gap:2rem;background:var(--lq-p-bg);color:var(--lq-p-text);font-family:var(--lq-p-font);-webkit-tap-highlight-color:transparent;-webkit-font-smoothing:antialiased}.lq-participant__brand{font-size:.75rem;font-weight:500;color:var(--lq-p-brand);letter-spacing:.1em;text-transform:uppercase;padding-top:.5rem}.lq-participant__stats{font-size:.8rem;color:var(--lq-p-text-muted);font-variant-numeric:tabular-nums}.lq-participant__online,.lq-participant__answered{color:var(--lq-p-accent);font-weight:700}.lq-participant__waiting{font-size:clamp(.9rem,3.5vw,1.1rem);color:var(--lq-p-text-muted);text-align:center;padding:3rem 0}.lq-participant__section.lq-participant__section--hidden{display:none}.lq-participant__section{display:flex;flex-direction:column;align-items:center;gap:1rem;width:100%;max-width:28rem}.lq-participant__number{font-size:.7rem;font-weight:600;color:var(--lq-p-text-dim);letter-spacing:.12em;text-transform:uppercase}.lq-participant__question{font-size:clamp(1rem,4vw,1.4rem);font-weight:600;line-height:1.3;text-align:center}.lq-participant__options{display:flex;flex-direction:column;gap:.6rem;width:100%}.lq-participant__btn{display:flex;align-items:center;gap:1rem;width:100%;padding:.85rem 1.1rem;border:1px solid var(--lq-p-btn-border);border-radius:var(--lq-p-border-radius);background:var(--lq-p-btn-bg);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);color:var(--lq-p-text);font-family:var(--lq-p-font);font-size:clamp(.9rem,3.5vw,1.1rem);font-weight:500;cursor:pointer;transition:all .2s ease;text-align:left}.lq-participant__btn:active{transform:scale(.97)}.lq-participant__btn-label{font-weight:700;color:var(--lq-p-accent);flex-shrink:0;font-size:.9em}.lq-participant__btn--selected{border-color:var(--lq-p-accent-bright);background:var(--lq-p-btn-selected-bg);box-shadow:var(--lq-p-btn-selected-glow)}.lq-participant__btn--faded{opacity:.35}.lq-participant__status{font-size:clamp(.8rem,3vw,.95rem);color:var(--lq-p-status-text);text-align:center;line-height:1.5;min-height:1.5em}.lq-participant__status strong{color:var(--lq-p-accent)}.lq-participant__footer{font-size:.7rem;color:var(--lq-p-text-faint);text-align:center;padding-bottom:1rem}
|