hyperframes 0.6.84 → 0.6.86
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/dist/cli.js +53338 -53213
- package/dist/hyperframe-runtime.js +1 -1
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +1 -1
- package/dist/studio/assets/{hyperframes-player-WXAuftNy.js → hyperframes-player-0esDKGRk.js} +1 -1
- package/dist/studio/assets/{index-Cw-8psGW.js → index-BT9VHgSy.js} +34 -34
- package/dist/studio/index.html +1 -1
- package/package.json +1 -1
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
`;)e--;this.css=this.css.slice(0,e)+this.css.slice(n+2)}}}}generate(){if(this.clearAnnotation(),ha&&pa&&this.isMap())return this.generateMap();{let e="";return this.stringify(this.root,n=>{e+=n}),[e]}}generateMap(){if(this.root)this.generateString();else if(this.previous().length===1){let e=this.previous()[0].consumer();e.file=this.outputFile(),this.map=Zt.fromSourceMap(e,{ignoreInvalidMapping:!0})}else this.map=new Zt({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]}generateString(){this.css="",this.map=new Zt({file:this.outputFile(),ignoreInvalidMapping:!0});let e=1,n=1,i="<no source>",r={generated:{column:0,line:0},original:{column:0,line:0},source:""},o,s;this.stringify(this.root,(l,a,c)=>{if(this.css+=l,a&&c!=="end"&&(r.generated.line=e,r.generated.column=n-1,a.source&&a.source.start?(r.source=this.sourcePath(a),r.original.line=a.source.start.line,r.original.column=a.source.start.column-1,this.map.addMapping(r)):(r.source=i,r.original.line=1,r.original.column=0,this.map.addMapping(r))),s=l.match(/\n/g),s?(e+=s.length,o=l.lastIndexOf(`
|
|
27
27
|
`),n=l.length-o):n+=l.length,a&&c!=="start"){let u=a.parent||{raws:{}};(!(a.type==="decl"||a.type==="atrule"&&!a.nodes)||a!==u.last||u.raws.semicolon)&&(a.source&&a.source.end?(r.source=this.sourcePath(a),r.original.line=a.source.end.line,r.original.column=a.source.end.column-1,r.generated.line=e,r.generated.column=n-2,this.map.addMapping(r)):(r.source=i,r.original.line=1,r.original.column=0,r.generated.line=e,r.generated.column=n-1,this.map.addMapping(r)))}})}isAnnotation(){return this.isInline()?!0:typeof this.mapOpts.annotation<"u"?this.mapOpts.annotation:this.previous().length?this.previous().some(e=>e.annotation):!0}isInline(){if(typeof this.mapOpts.inline<"u")return this.mapOpts.inline;let e=this.mapOpts.annotation;return typeof e<"u"&&e!==!0?!1:this.previous().length?this.previous().some(n=>n.inline):!0}isMap(){return typeof this.opts.map<"u"?!!this.opts.map:this.previous().length>0}isSourcesContent(){return typeof this.mapOpts.sourcesContent<"u"?this.mapOpts.sourcesContent:this.previous().length?this.previous().some(e=>e.withContent()):!0}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(e){if(this.mapOpts.absolute||e.charCodeAt(0)===60||/^\w+:\/\//.test(e))return e;let n=this.memoizedPaths.get(e);if(n)return n;let i=this.opts.to?Yt(this.opts.to):".";typeof this.mapOpts.annotation=="string"&&(i=Yt(Ir(i,this.mapOpts.annotation)));let r=Br(i,e);return this.memoizedPaths.set(e,r),r}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(e=>{if(e.source&&e.source.input.map){let n=e.source.input.map;this.previousMaps.includes(n)||this.previousMaps.push(n)}});else{let e=new ma(this.originalCSS,this.opts);e.map&&this.previousMaps.push(e.map)}return this.previousMaps}setSourcesContent(){let e={};if(this.root)this.root.walk(n=>{if(n.source){let i=n.source.input.from;if(i&&!e[i]){e[i]=!0;let r=this.usesFileUrls?this.toFileUrl(i):this.toUrl(this.path(i));this.map.setSourceContent(r,n.source.input.css)}}});else if(this.css){let n=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(n,this.css)}}sourcePath(e){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(e.source.input.from):this.toUrl(this.path(e.source.input.from))}toBase64(e){return Buffer?Buffer.from(e).toString("base64"):window.btoa(unescape(encodeURIComponent(e)))}toFileUrl(e){let n=this.memoizedFileURLs.get(e);if(n)return n;if(Dr){let i=Dr(e).toString();return this.memoizedFileURLs.set(e,i),i}else throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(e){let n=this.memoizedURLs.get(e);if(n)return n;Or==="\\"&&(e=e.replace(/\\/g,"/"));let i=encodeURI(e).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(e,i),i}};Wr.exports=Vn});var Vr=X((Gc,qr)=>{"use strict";var Xt=/[\t\n\f\r "#'()/;[\\\]{}]/g,en=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,xa=/.[\r\n"'(/\\]/,Hr=/[\da-f]/i;qr.exports=function(e,n={}){let i=e.css.valueOf(),r=n.ignoreErrors,o,s,l,a,c,u,m,f,x,F,E=i.length,S=0,B=[],D=[],v=-1;function te(){return S}function q(N){throw e.error("Unclosed "+N,S)}function C(){return D.length===0&&S>=E}function g(N){if(D.length)return D.pop();if(S>=E)return;let w=N?N.ignoreUnclosed:!1;switch(o=i.charCodeAt(S),o){case 10:case 32:case 9:case 13:case 12:{a=S;do a+=1,o=i.charCodeAt(a);while(o===32||o===10||o===9||o===13||o===12);u=["space",i.slice(S,a)],S=a-1;break}case 91:case 93:case 123:case 125:case 58:case 59:case 41:{let M=String.fromCharCode(o);u=[M,M,S];break}case 40:{if(F=B.length?B.pop()[1]:"",x=i.charCodeAt(S+1),F==="url"&&x!==39&&x!==34&&x!==32&&x!==10&&x!==9&&x!==12&&x!==13){a=S;do{if(m=!1,a=i.indexOf(")",a+1),a===-1)if(r||w){a=S;break}else q("bracket");for(f=a;i.charCodeAt(f-1)===92;)f-=1,m=!m}while(m);u=["brackets",i.slice(S,a+1),S,a],S=a}else S<=v?u=["(","(",S]:(a=i.indexOf(")",S+1),s=i.slice(S,a+1),a===-1||xa.test(s)?(v=a===-1?E:a,u=["(","(",S]):(u=["brackets",s,S,a],S=a));break}case 39:case 34:{c=o===39?"'":'"',a=S;do{if(m=!1,a=i.indexOf(c,a+1),a===-1)if(r||w){a=S+1;break}else q("string");for(f=a;i.charCodeAt(f-1)===92;)f-=1,m=!m}while(m);u=["string",i.slice(S,a+1),S,a],S=a;break}case 64:{Xt.lastIndex=S+1,Xt.test(i),Xt.lastIndex===0?a=i.length-1:a=Xt.lastIndex-2,u=["at-word",i.slice(S,a+1),S,a],S=a;break}case 92:{for(a=S,l=!0;i.charCodeAt(a+1)===92;)a+=1,l=!l;if(o=i.charCodeAt(a+1),l&&o!==47&&o!==32&&o!==10&&o!==9&&o!==13&&o!==12&&(a+=1,Hr.test(i.charAt(a)))){for(;Hr.test(i.charAt(a+1));)a+=1;i.charCodeAt(a+1)===32&&(a+=1)}u=["word",i.slice(S,a+1),S,a],S=a;break}default:{o===47&&i.charCodeAt(S+1)===42?(a=i.indexOf("*/",S+2)+1,a===0&&(r||w?a=i.length:q("comment")),u=["comment",i.slice(S,a+1),S,a],S=a):(en.lastIndex=S+1,en.test(i),en.lastIndex===0?a=i.length-1:a=en.lastIndex-2,u=["word",i.slice(S,a+1),S,a],B.push(u),S=a);break}}return S++,u}function A(N){D.push(N)}return{back:A,endOfFile:C,nextToken:g,position:te}}});var $r=X((Kc,jr)=>{"use strict";var ga=jt(),ya=Mt(),Sa=kt(),ba=ot(),Ur=Qt(),Aa=Vr(),zr={empty:!0,space:!0};function Ea(t){for(let e=t.length-1;e>=0;e--){let n=t[e],i=n[3]||n[2];if(i)return i}}var zn=class{constructor(e){this.input=e,this.root=new ba,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let n=new ga;n.name=e[1].slice(1),n.name===""&&this.unnamedAtrule(n,e),this.init(n,e[2]);let i,r,o,s=!1,l=!1,a=[],c=[];for(;!this.tokenizer.endOfFile();){if(e=this.tokenizer.nextToken(),i=e[0],i==="("||i==="["?c.push(i==="("?")":"]"):i==="{"&&c.length>0?c.push("}"):i===c[c.length-1]&&c.pop(),c.length===0)if(i===";"){n.source.end=this.getPosition(e[2]),n.source.end.offset++,this.semicolon=!0;break}else if(i==="{"){l=!0;break}else if(i==="}"){if(a.length>0){for(o=a.length-1,r=a[o];r&&r[0]==="space";)r=a[--o];r&&(n.source.end=this.getPosition(r[3]||r[2]),n.source.end.offset++)}this.end(e);break}else a.push(e);else a.push(e);if(this.tokenizer.endOfFile()){s=!0;break}}n.raws.between=this.spacesAndCommentsFromEnd(a),a.length?(n.raws.afterName=this.spacesAndCommentsFromStart(a),this.raw(n,"params",a),s&&(e=a[a.length-1],n.source.end=this.getPosition(e[3]||e[2]),n.source.end.offset++,this.spaces=n.raws.between,n.raws.between="")):(n.raws.afterName="",n.params=""),l&&(n.nodes=[],this.current=n)}checkMissedSemicolon(e){let n=this.colon(e);if(n===!1)return;let i=0,r;for(let o=n-1;o>=0&&(r=e[o],!(r[0]!=="space"&&(i+=1,i===2)));o--);throw this.input.error("Missed semicolon",r[0]==="word"?r[3]+1:r[2])}colon(e){let n=0,i,r,o;for(let[s,l]of e.entries()){if(r=l,o=r[0],o==="("&&(n+=1),o===")"&&(n-=1),n===0&&o===":")if(!i)this.doubleColon(r);else{if(i[0]==="word"&&i[1]==="progid")continue;return s}i=r}return!1}comment(e){let n=new ya;this.init(n,e[2]),n.source.end=this.getPosition(e[3]||e[2]),n.source.end.offset++;let i=e[1].slice(2,-2);if(!i.trim())n.text="",n.raws.left=i,n.raws.right="";else{let r=i.match(/^(\s*)([^]*\S)(\s*)$/);n.text=r[2],n.raws.left=r[1],n.raws.right=r[3]}}createTokenizer(){this.tokenizer=Aa(this.input)}decl(e,n){let i=new Sa;this.init(i,e[0][2]);let r=e[e.length-1];for(r[0]===";"&&(this.semicolon=!0,e.pop()),i.source.end=this.getPosition(r[3]||r[2]||Ea(e)),i.source.end.offset++;e[0][0]!=="word";)e.length===1&&this.unknownWord(e),i.raws.before+=e.shift()[1];for(i.source.start=this.getPosition(e[0][2]),i.prop="";e.length;){let c=e[0][0];if(c===":"||c==="space"||c==="comment")break;i.prop+=e.shift()[1]}i.raws.between="";let o;for(;e.length;)if(o=e.shift(),o[0]===":"){i.raws.between+=o[1];break}else o[0]==="word"&&/\w/.test(o[1])&&this.unknownWord([o]),i.raws.between+=o[1];(i.prop[0]==="_"||i.prop[0]==="*")&&(i.raws.before+=i.prop[0],i.prop=i.prop.slice(1));let s=[],l;for(;e.length&&(l=e[0][0],!(l!=="space"&&l!=="comment"));)s.push(e.shift());this.precheckMissedSemicolon(e);for(let c=e.length-1;c>=0;c--){if(o=e[c],o[1].toLowerCase()==="!important"){i.important=!0;let u=this.stringFrom(e,c);u=this.spacesFromEnd(e)+u,u!==" !important"&&(i.raws.important=u);break}else if(o[1].toLowerCase()==="important"){let u=e.slice(0),m="";for(let f=c;f>0;f--){let x=u[f][0];if(m.trim().startsWith("!")&&x!=="space")break;m=u.pop()[1]+m}m.trim().startsWith("!")&&(i.important=!0,i.raws.important=m,e=u)}if(o[0]!=="space"&&o[0]!=="comment")break}e.some(c=>c[0]!=="space"&&c[0]!=="comment")&&(i.raws.between+=s.map(c=>c[1]).join(""),s=[]),this.raw(i,"value",s.concat(e),n),i.value.includes(":")&&!n&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error("Double colon",{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let n=new Ur;this.init(n,e[2]),n.selector="",n.raws.between="",this.current=n}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let n=this.current.nodes[this.current.nodes.length-1];n&&n.type==="rule"&&!n.raws.ownSemicolon&&(n.raws.ownSemicolon=this.spaces,this.spaces="",n.source.end=this.getPosition(e[2]),n.source.end.offset+=n.raws.ownSemicolon.length)}}getPosition(e){let n=this.input.fromOffset(e);return{column:n.col,line:n.line,offset:e}}init(e,n){this.current.push(e),e.source={input:this.input,start:this.getPosition(n)},e.raws.before=this.spaces,this.spaces="",e.type!=="comment"&&(this.semicolon=!1)}other(e){let n=!1,i=null,r=!1,o=null,s=[],l=e[1].startsWith("--"),a=[],c=e;for(;c;){if(i=c[0],a.push(c),i==="("||i==="[")o||(o=c),s.push(i==="("?")":"]");else if(l&&r&&i==="{")o||(o=c),s.push("}");else if(s.length===0)if(i===";")if(r){this.decl(a,l);return}else break;else if(i==="{"){this.rule(a);return}else if(i==="}"){this.tokenizer.back(a.pop()),n=!0;break}else i===":"&&(r=!0);else i===s[s.length-1]&&(s.pop(),s.length===0&&(o=null));c=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(n=!0),s.length>0&&this.unclosedBracket(o),n&&r){if(!l)for(;a.length&&(c=a[a.length-1][0],!(c!=="space"&&c!=="comment"));)this.tokenizer.back(a.pop());this.decl(a,l)}else this.unknownWord(a)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case"space":this.spaces+=e[1];break;case";":this.freeSemicolon(e);break;case"}":this.end(e);break;case"comment":this.comment(e);break;case"at-word":this.atrule(e);break;case"{":this.emptyRule(e);break;default:this.other(e);break}this.endFile()}precheckMissedSemicolon(){}raw(e,n,i,r){let o,s,l=i.length,a="",c=!0,u,m;for(let f=0;f<l;f+=1)o=i[f],s=o[0],s==="space"&&f===l-1&&!r?c=!1:s==="comment"?(m=i[f-1]?i[f-1][0]:"empty",u=i[f+1]?i[f+1][0]:"empty",!zr[m]&&!zr[u]?a.slice(-1)===","?c=!1:a+=o[1]:c=!1):a+=o[1];if(!c){let f=i.reduce((x,F)=>x+F[1],"");e.raws[n]={raw:f,value:a}}e[n]=a}rule(e){e.pop();let n=new Ur;this.init(n,e[0][2]),n.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(n,"selector",e),this.current=n}spacesAndCommentsFromEnd(e){let n,i="";for(;e.length&&(n=e[e.length-1][0],!(n!=="space"&&n!=="comment"));)i=e.pop()[1]+i;return i}spacesAndCommentsFromStart(e){let n,i="";for(;e.length&&(n=e[0][0],!(n!=="space"&&n!=="comment"));)i+=e.shift()[1];return i}spacesFromEnd(e){let n,i="";for(;e.length&&(n=e[e.length-1][0],n==="space");)i=e.pop()[1]+i;return i}stringFrom(e,n){let i="";for(let r=n;r<e.length;r++)i+=e[r][1];return e.splice(n,e.length-n),i}unclosedBlock(){let e=this.current.source.start;throw this.input.error("Unclosed block",e.line,e.column)}unclosedBracket(e){throw this.input.error("Unclosed bracket",{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error("Unexpected }",{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error("Unknown word "+e[0][1],{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,n){throw this.input.error("At-rule without name",{offset:n[2]},{offset:n[2]+n[1].length})}};jr.exports=zn});var nn=X((Jc,Gr)=>{"use strict";var Fa=qe(),wa=_t(),Na=$r();function tn(t,e){let n=new wa(t,e),i=new Na(n);try{i.parse()}catch(r){throw r}return i.root}Gr.exports=tn;tn.default=tn;Fa.registerParse(tn)});var jn=X((Qc,Kr)=>{"use strict";var Dt=class{constructor(e,n={}){if(this.type="warning",this.text=e,n.node&&n.node.source){let i=n.node.rangeBy(n);this.line=i.start.line,this.column=i.start.column,this.endLine=i.end.line,this.endColumn=i.end.column}for(let i in n)this[i]=n[i]}toString(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text}};Kr.exports=Dt;Dt.default=Dt});var rn=X((Yc,Jr)=>{"use strict";var Ca=jn(),Bt=class{get content(){return this.css}constructor(e,n,i){this.processor=e,this.messages=[],this.root=n,this.opts=i,this.css="",this.map=void 0}toString(){return this.css}warn(e,n={}){n.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(n.plugin=this.lastPlugin.postcssPlugin);let i=new Ca(e,n);return this.messages.push(i),i}warnings(){return this.messages.filter(e=>e.type==="warning")}};Jr.exports=Bt;Bt.default=Bt});var $n=X((Zc,Yr)=>{"use strict";var Qr={};Yr.exports=function(e){Qr[e]||(Qr[e]=!0,typeof console<"u"&&console.warn&&console.warn(e))}});var Jn=X((ed,to)=>{"use strict";var Ma=qe(),Ta=$t(),ka=Un(),va=nn(),Zr=rn(),_a=ot(),Ra=Et(),{isClean:Be,my:La}=zt(),Xc=$n(),Da={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},Ba={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},Ia={Once:!0,postcssPlugin:!0,prepare:!0},at=0;function It(t){return typeof t=="object"&&typeof t.then=="function"}function eo(t){let e=!1,n=Da[t.type];return t.type==="decl"?e=t.prop.toLowerCase():t.type==="atrule"&&(e=t.name.toLowerCase()),e&&t.append?[n,n+"-"+e,at,n+"Exit",n+"Exit-"+e]:e?[n,n+"-"+e,n+"Exit",n+"Exit-"+e]:t.append?[n,at,n+"Exit"]:[n,n+"Exit"]}function Xr(t){let e;return t.type==="document"?e=["Document",at,"DocumentExit"]:t.type==="root"?e=["Root",at,"RootExit"]:e=eo(t),{eventIndex:0,events:e,iterator:0,node:t,visitorIndex:0,visitors:[]}}function Gn(t){return t[Be]=!1,t.nodes&&t.nodes.forEach(e=>Gn(e)),t}var Kn={},Ue=class t{get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return"LazyResult"}constructor(e,n,i){this.stringified=!1,this.processed=!1;let r;if(typeof n=="object"&&n!==null&&(n.type==="root"||n.type==="document"))r=Gn(n);else if(n instanceof t||n instanceof Zr)r=Gn(n.root),n.map&&(typeof i.map>"u"&&(i.map={}),i.map.inline||(i.map.inline=!1),i.map.prev=n.map);else{let o=va;i.syntax&&(o=i.syntax.parse),i.parser&&(o=i.parser),o.parse&&(o=o.parse);try{r=o(n,i)}catch(s){this.processed=!0,this.error=s}r&&!r[La]&&Ma.rebuild(r)}this.result=new Zr(e,r,i),this.helpers={...Kn,postcss:Kn,result:this.result},this.plugins=this.processor.plugins.map(o=>typeof o=="object"&&o.prepare?{...o,...o.prepare(this.result)}:o)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(e,n){let i=this.result.lastPlugin;try{n&&n.addToError(e),this.error=e,e.name==="CssSyntaxError"&&!e.plugin?(e.plugin=i.postcssPlugin,e.setMessage()):i.postcssVersion}catch(r){console&&console.error&&console.error(r)}return e}prepareVisitors(){this.listeners={};let e=(n,i,r)=>{this.listeners[i]||(this.listeners[i]=[]),this.listeners[i].push([n,r])};for(let n of this.plugins)if(typeof n=="object")for(let i in n){if(!Ba[i]&&/^[A-Z]/.test(i))throw new Error(`Unknown event ${i} in ${n.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`);if(!Ia[i])if(typeof n[i]=="object")for(let r in n[i])r==="*"?e(n,i,n[i][r]):e(n,i+"-"+r.toLowerCase(),n[i][r]);else typeof n[i]=="function"&&e(n,i,n[i])}this.hasListener=Object.keys(this.listeners).length>0}async runAsync(){this.plugin=0;for(let e=0;e<this.plugins.length;e++){let n=this.plugins[e],i=this.runOnRoot(n);if(It(i))try{await i}catch(r){throw this.handleError(r)}}if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[Be];){e[Be]=!0;let n=[Xr(e)];for(;n.length>0;){let i=this.visitTick(n);if(It(i))try{await i}catch(r){let o=n[n.length-1].node;throw this.handleError(r,o)}}}if(this.listeners.OnceExit)for(let[n,i]of this.listeners.OnceExit){this.result.lastPlugin=n;try{if(e.type==="document"){let r=e.nodes.map(o=>i(o,this.helpers));await Promise.all(r)}else await i(e,this.helpers)}catch(r){throw this.handleError(r)}}}return this.processed=!0,this.stringify()}runOnRoot(e){this.result.lastPlugin=e;try{if(typeof e=="object"&&e.Once){if(this.result.root.type==="document"){let n=this.result.root.nodes.map(i=>e.Once(i,this.helpers));return It(n[0])?Promise.all(n):n}return e.Once(this.result.root,this.helpers)}else if(typeof e=="function")return e(this.result.root,this.result)}catch(n){throw this.handleError(n)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();let e=this.result.opts,n=Ra;e.syntax&&(n=e.syntax.stringify),e.stringifier&&(n=e.stringifier),n.stringify&&(n=n.stringify);let i=this.result.root.source;if(e.map===void 0&&!(i&&i.input&&i.input.map)){let s="";return n(this.result.root,l=>{s+=l}),this.result.css=s,this.result}let o=new ka(n,this.result.root,this.result.opts).generate();return this.result.css=o[0],this.result.map=o[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(let e of this.plugins){let n=this.runOnRoot(e);if(It(n))throw this.getAsyncError()}if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[Be];)e[Be]=!0,this.walkSync(e);if(this.listeners.OnceExit)if(e.type==="document")for(let n of e.nodes)this.visitSync(this.listeners.OnceExit,n);else this.visitSync(this.listeners.OnceExit,e)}return this.result}then(e,n){return this.async().then(e,n)}toString(){return this.css}visitSync(e,n){for(let[i,r]of e){this.result.lastPlugin=i;let o;try{o=r(n,this.helpers)}catch(s){throw this.handleError(s,n.proxyOf)}if(n.type!=="root"&&n.type!=="document"&&!n.parent)return!0;if(It(o))throw this.getAsyncError()}}visitTick(e){let n=e[e.length-1],{node:i,visitors:r}=n;if(i.type!=="root"&&i.type!=="document"&&!i.parent){e.pop();return}if(r.length>0&&n.visitorIndex<r.length){let[s,l]=r[n.visitorIndex];n.visitorIndex+=1,n.visitorIndex===r.length&&(n.visitors=[],n.visitorIndex=0),this.result.lastPlugin=s;try{return l(i.toProxy(),this.helpers)}catch(a){throw this.handleError(a,i)}}if(n.iterator!==0){let s=n.iterator,l;for(;l=i.nodes[i.indexes[s]];)if(i.indexes[s]+=1,!l[Be]){l[Be]=!0,e.push(Xr(l));return}n.iterator=0,delete i.indexes[s]}let o=n.events;for(;n.eventIndex<o.length;){let s=o[n.eventIndex];if(n.eventIndex+=1,s===at){i.nodes&&i.nodes.length&&(i[Be]=!0,n.iterator=i.getIterator());return}else if(this.listeners[s]){n.visitors=this.listeners[s];return}}e.pop()}walkSync(e){e[Be]=!0;let n=eo(e);for(let i of n)if(i===at)e.nodes&&e.each(r=>{r[Be]||this.walkSync(r)});else{let r=this.listeners[i];if(r&&this.visitSync(r,e.toProxy()))return}}warnings(){return this.sync().warnings()}};Ue.registerPostcss=t=>{Kn=t};to.exports=Ue;Ue.default=Ue;_a.registerLazyResult(Ue);Ta.registerLazyResult(Ue)});var io=X((nd,no)=>{"use strict";var Oa=Un(),Pa=nn(),Wa=rn(),Ha=Et(),td=$n(),Ot=class{get content(){return this.result.css}get css(){return this.result.css}get map(){return this.result.map}get messages(){return[]}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){if(this._root)return this._root;let e,n=Pa;try{e=n(this._css,this._opts)}catch(i){this.error=i}if(this.error)throw this.error;return this._root=e,e}get[Symbol.toStringTag](){return"NoWorkResult"}constructor(e,n,i){n=n.toString(),this.stringified=!1,this._processor=e,this._css=n,this._opts=i,this._map=void 0;let r=Ha;this.result=new Wa(this._processor,void 0,this._opts),this.result.css=n;let o=this;Object.defineProperty(this.result,"root",{get(){return o.root}});let s=new Oa(r,void 0,this._opts,n);if(s.isMap()){let[l,a]=s.generate();l&&(this.result.css=l),a&&(this.result.map=a)}else s.clearAnnotation(),this.result.css=s.css}async(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}sync(){if(this.error)throw this.error;return this.result}then(e,n){return this.async().then(e,n)}toString(){return this._css}warnings(){return[]}};no.exports=Ot;Ot.default=Ot});var oo=X((id,ro)=>{"use strict";var qa=$t(),Va=Jn(),Ua=io(),za=ot(),Xe=class{constructor(e=[]){this.version="8.5.14",this.plugins=this.normalize(e)}normalize(e){let n=[];for(let i of e)if(i.postcss===!0?i=i():i.postcss&&(i=i.postcss),typeof i=="object"&&Array.isArray(i.plugins))n=n.concat(i.plugins);else if(typeof i=="object"&&i.postcssPlugin)n.push(i);else if(typeof i=="function")n.push(i);else if(!(typeof i=="object"&&(i.parse||i.stringify)))throw new Error(i+" is not a PostCSS plugin");return n}process(e,n={}){return!this.plugins.length&&!n.parser&&!n.stringifier&&!n.syntax?new Ua(this,e,n):new Va(this,e,n)}use(e){return this.plugins=this.plugins.concat(this.normalize([e])),this}};ro.exports=Xe;Xe.default=Xe;za.registerProcessor(Xe);qa.registerProcessor(Xe)});var po=X((rd,mo)=>{"use strict";var so=jt(),ao=Mt(),ja=qe(),$a=Ut(),lo=kt(),uo=$t(),Ga=Lr(),Ka=_t(),Ja=Jn(),Qa=qn(),Ya=Nt(),Za=nn(),Qn=oo(),Xa=rn(),co=ot(),fo=Qt(),el=Et(),tl=jn();function re(...t){return t.length===1&&Array.isArray(t[0])&&(t=t[0]),new Qn(t)}re.plugin=function(e,n){let i=!1;function r(...s){console&&console.warn&&!i&&(i=!0,console.warn(e+`: postcss.plugin was deprecated. Migration guide:
|
|
28
28
|
https://evilmartians.com/chronicles/postcss-8-plugin-migration`),process.env.LANG&&process.env.LANG.startsWith("cn")&&console.warn(e+`: \u91CC\u9762 postcss.plugin \u88AB\u5F03\u7528. \u8FC1\u79FB\u6307\u5357:
|
|
29
|
-
https://www.w3ctech.com/topic/2226`));let l=n(...s);return l.postcssPlugin=e,l.postcssVersion=new Qn().version,l}let o;return Object.defineProperty(r,"postcss",{get(){return o||(o=r()),o}}),r.process=function(s,l,a){return re([r(a)]).process(s,l)},r};re.stringify=el;re.parse=Za;re.fromJSON=Ga;re.list=Qa;re.comment=t=>new ao(t);re.atRule=t=>new so(t);re.decl=t=>new lo(t);re.rule=t=>new fo(t);re.root=t=>new co(t);re.document=t=>new uo(t);re.CssSyntaxError=$a;re.Declaration=lo;re.Container=ja;re.Processor=Qn;re.Document=uo;re.Comment=ao;re.Warning=tl;re.AtRule=so;re.Result=Xa;re.Input=Ka;re.Rule=fo;re.Root=co;re.Node=Ya;Ja.registerPostcss(re);mo.exports=re;re.default=re});function _(t,e){if(typeof window>"u")return;let n=window,i=n.__hf?.onSwallowed;if(i)try{i({label:t,error:e})}catch(r){}(n.__hfDebug||n.__HYPERFRAMES_DEBUG)&&console.debug(`[hyperframes] ${t} swallowed:`,e)}function Ae(t){try{window.parent.postMessage(t,"*")}catch(e){_("bridge.postMessage",e)}}function yi(t){let e=n=>{let i=n.data;if(!i||i.source!=="hf-parent"||i.type!=="control")return;let r=i.action;if(r==="play"){t.onPlay();return}if(r==="pause"){t.onPause();return}if(r==="seek"){t.onSeek(Number(i.frame??0),i.seekMode??"commit");return}if(r==="tick"){t.onTick();return}if(r==="set-muted"){t.onSetMuted(!!i.muted);return}if(r==="set-volume"){t.onSetVolume(Math.max(0,Math.min(1,Number(i.volume??1))));return}if(r==="set-media-output-muted"){t.onSetMediaOutputMuted(!!i.muted);return}if(r==="set-playback-rate"){t.onSetPlaybackRate(Number(i.playbackRate??1));return}if(r==="enable-pick-mode"){t.onEnablePickMode();return}if(r==="disable-pick-mode"){t.onDisablePickMode();return}if(r==="flash-elements"){let o=i.selectors,s=i.duration||800;o&&ps(o,s)}};return window.addEventListener("message",e),e}function ps(t,e){if(!document.getElementById("__hf-flash-styles")){let n=document.createElement("style");n.id="__hf-flash-styles",n.textContent=`
|
|
29
|
+
https://www.w3ctech.com/topic/2226`));let l=n(...s);return l.postcssPlugin=e,l.postcssVersion=new Qn().version,l}let o;return Object.defineProperty(r,"postcss",{get(){return o||(o=r()),o}}),r.process=function(s,l,a){return re([r(a)]).process(s,l)},r};re.stringify=el;re.parse=Za;re.fromJSON=Ga;re.list=Qa;re.comment=t=>new ao(t);re.atRule=t=>new so(t);re.decl=t=>new lo(t);re.rule=t=>new fo(t);re.root=t=>new co(t);re.document=t=>new uo(t);re.CssSyntaxError=$a;re.Declaration=lo;re.Container=ja;re.Processor=Qn;re.Document=uo;re.Comment=ao;re.Warning=tl;re.AtRule=so;re.Result=Xa;re.Input=Ka;re.Rule=fo;re.Root=co;re.Node=Ya;Ja.registerPostcss(re);mo.exports=re;re.default=re});function _(t,e){if(typeof window>"u")return;let n=window,i=n.__hf?.onSwallowed;if(i)try{i({label:t,error:e})}catch(r){}(n.__hfDebug||n.__HYPERFRAMES_DEBUG)&&console.debug(`[hyperframes] ${t} swallowed:`,e)}function Ae(t){try{window.parent.postMessage(t,"*")}catch(e){_("bridge.postMessage",e)}}function yi(t){let e=n=>{let i=n.data;if(!i||i.source!=="hf-parent"||i.type!=="control")return;let r=i.action;if(r==="play"){t.onPlay();return}if(r==="pause"){t.onPause();return}if(r==="seek"){t.onSeek(Number(i.frame??0),i.seekMode??"commit");return}if(r==="tick"){t.onTick();return}if(r==="set-muted"){t.onSetMuted(!!i.muted);return}if(r==="set-volume"){t.onSetVolume(Math.max(0,Math.min(1,Number(i.volume??1))));return}if(r==="set-media-output-muted"){t.onSetMediaOutputMuted(!!i.muted);return}if(r==="set-playback-rate"){t.onSetPlaybackRate(Number(i.playbackRate??1));return}if(r==="enable-pick-mode"){t.onEnablePickMode();return}if(r==="disable-pick-mode"){t.onDisablePickMode();return}if(r==="flash-elements"){let o=i.selectors,s=i.duration||800;o&&ps(o,s)}};return window.addEventListener("message",e),Ae({source:"hf-preview",type:"ready"}),e}function ps(t,e){if(!document.getElementById("__hf-flash-styles")){let n=document.createElement("style");n.id="__hf-flash-styles",n.textContent=`
|
|
30
30
|
.__hf-flash {
|
|
31
31
|
outline: 2px solid rgba(59, 130, 246, 0.6) !important;
|
|
32
32
|
outline-offset: 2px !important;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "0.1.0",
|
|
3
3
|
"buildId": "dev",
|
|
4
|
-
"sha256": "
|
|
4
|
+
"sha256": "a0f14df76c77d6eea7892e65814ca5c9a3873b0443902680b22b712fff875db1",
|
|
5
5
|
"artifacts": {
|
|
6
6
|
"iife": "hyperframe.runtime.iife.js",
|
|
7
7
|
"esm": "hyperframe.runtime.mjs"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
`;)e--;this.css=this.css.slice(0,e)+this.css.slice(n+2)}}}}generate(){if(this.clearAnnotation(),ha&&pa&&this.isMap())return this.generateMap();{let e="";return this.stringify(this.root,n=>{e+=n}),[e]}}generateMap(){if(this.root)this.generateString();else if(this.previous().length===1){let e=this.previous()[0].consumer();e.file=this.outputFile(),this.map=Zt.fromSourceMap(e,{ignoreInvalidMapping:!0})}else this.map=new Zt({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]}generateString(){this.css="",this.map=new Zt({file:this.outputFile(),ignoreInvalidMapping:!0});let e=1,n=1,i="<no source>",r={generated:{column:0,line:0},original:{column:0,line:0},source:""},o,s;this.stringify(this.root,(l,a,c)=>{if(this.css+=l,a&&c!=="end"&&(r.generated.line=e,r.generated.column=n-1,a.source&&a.source.start?(r.source=this.sourcePath(a),r.original.line=a.source.start.line,r.original.column=a.source.start.column-1,this.map.addMapping(r)):(r.source=i,r.original.line=1,r.original.column=0,this.map.addMapping(r))),s=l.match(/\n/g),s?(e+=s.length,o=l.lastIndexOf(`
|
|
27
27
|
`),n=l.length-o):n+=l.length,a&&c!=="start"){let u=a.parent||{raws:{}};(!(a.type==="decl"||a.type==="atrule"&&!a.nodes)||a!==u.last||u.raws.semicolon)&&(a.source&&a.source.end?(r.source=this.sourcePath(a),r.original.line=a.source.end.line,r.original.column=a.source.end.column-1,r.generated.line=e,r.generated.column=n-2,this.map.addMapping(r)):(r.source=i,r.original.line=1,r.original.column=0,r.generated.line=e,r.generated.column=n-1,this.map.addMapping(r)))}})}isAnnotation(){return this.isInline()?!0:typeof this.mapOpts.annotation<"u"?this.mapOpts.annotation:this.previous().length?this.previous().some(e=>e.annotation):!0}isInline(){if(typeof this.mapOpts.inline<"u")return this.mapOpts.inline;let e=this.mapOpts.annotation;return typeof e<"u"&&e!==!0?!1:this.previous().length?this.previous().some(n=>n.inline):!0}isMap(){return typeof this.opts.map<"u"?!!this.opts.map:this.previous().length>0}isSourcesContent(){return typeof this.mapOpts.sourcesContent<"u"?this.mapOpts.sourcesContent:this.previous().length?this.previous().some(e=>e.withContent()):!0}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(e){if(this.mapOpts.absolute||e.charCodeAt(0)===60||/^\w+:\/\//.test(e))return e;let n=this.memoizedPaths.get(e);if(n)return n;let i=this.opts.to?Yt(this.opts.to):".";typeof this.mapOpts.annotation=="string"&&(i=Yt(Ir(i,this.mapOpts.annotation)));let r=Br(i,e);return this.memoizedPaths.set(e,r),r}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(e=>{if(e.source&&e.source.input.map){let n=e.source.input.map;this.previousMaps.includes(n)||this.previousMaps.push(n)}});else{let e=new ma(this.originalCSS,this.opts);e.map&&this.previousMaps.push(e.map)}return this.previousMaps}setSourcesContent(){let e={};if(this.root)this.root.walk(n=>{if(n.source){let i=n.source.input.from;if(i&&!e[i]){e[i]=!0;let r=this.usesFileUrls?this.toFileUrl(i):this.toUrl(this.path(i));this.map.setSourceContent(r,n.source.input.css)}}});else if(this.css){let n=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(n,this.css)}}sourcePath(e){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(e.source.input.from):this.toUrl(this.path(e.source.input.from))}toBase64(e){return Buffer?Buffer.from(e).toString("base64"):window.btoa(unescape(encodeURIComponent(e)))}toFileUrl(e){let n=this.memoizedFileURLs.get(e);if(n)return n;if(Dr){let i=Dr(e).toString();return this.memoizedFileURLs.set(e,i),i}else throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(e){let n=this.memoizedURLs.get(e);if(n)return n;Or==="\\"&&(e=e.replace(/\\/g,"/"));let i=encodeURI(e).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(e,i),i}};Wr.exports=Vn});var Vr=X((Gc,qr)=>{"use strict";var Xt=/[\t\n\f\r "#'()/;[\\\]{}]/g,en=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,xa=/.[\r\n"'(/\\]/,Hr=/[\da-f]/i;qr.exports=function(e,n={}){let i=e.css.valueOf(),r=n.ignoreErrors,o,s,l,a,c,u,m,f,x,F,E=i.length,S=0,B=[],D=[],v=-1;function te(){return S}function q(N){throw e.error("Unclosed "+N,S)}function C(){return D.length===0&&S>=E}function g(N){if(D.length)return D.pop();if(S>=E)return;let w=N?N.ignoreUnclosed:!1;switch(o=i.charCodeAt(S),o){case 10:case 32:case 9:case 13:case 12:{a=S;do a+=1,o=i.charCodeAt(a);while(o===32||o===10||o===9||o===13||o===12);u=["space",i.slice(S,a)],S=a-1;break}case 91:case 93:case 123:case 125:case 58:case 59:case 41:{let M=String.fromCharCode(o);u=[M,M,S];break}case 40:{if(F=B.length?B.pop()[1]:"",x=i.charCodeAt(S+1),F==="url"&&x!==39&&x!==34&&x!==32&&x!==10&&x!==9&&x!==12&&x!==13){a=S;do{if(m=!1,a=i.indexOf(")",a+1),a===-1)if(r||w){a=S;break}else q("bracket");for(f=a;i.charCodeAt(f-1)===92;)f-=1,m=!m}while(m);u=["brackets",i.slice(S,a+1),S,a],S=a}else S<=v?u=["(","(",S]:(a=i.indexOf(")",S+1),s=i.slice(S,a+1),a===-1||xa.test(s)?(v=a===-1?E:a,u=["(","(",S]):(u=["brackets",s,S,a],S=a));break}case 39:case 34:{c=o===39?"'":'"',a=S;do{if(m=!1,a=i.indexOf(c,a+1),a===-1)if(r||w){a=S+1;break}else q("string");for(f=a;i.charCodeAt(f-1)===92;)f-=1,m=!m}while(m);u=["string",i.slice(S,a+1),S,a],S=a;break}case 64:{Xt.lastIndex=S+1,Xt.test(i),Xt.lastIndex===0?a=i.length-1:a=Xt.lastIndex-2,u=["at-word",i.slice(S,a+1),S,a],S=a;break}case 92:{for(a=S,l=!0;i.charCodeAt(a+1)===92;)a+=1,l=!l;if(o=i.charCodeAt(a+1),l&&o!==47&&o!==32&&o!==10&&o!==9&&o!==13&&o!==12&&(a+=1,Hr.test(i.charAt(a)))){for(;Hr.test(i.charAt(a+1));)a+=1;i.charCodeAt(a+1)===32&&(a+=1)}u=["word",i.slice(S,a+1),S,a],S=a;break}default:{o===47&&i.charCodeAt(S+1)===42?(a=i.indexOf("*/",S+2)+1,a===0&&(r||w?a=i.length:q("comment")),u=["comment",i.slice(S,a+1),S,a],S=a):(en.lastIndex=S+1,en.test(i),en.lastIndex===0?a=i.length-1:a=en.lastIndex-2,u=["word",i.slice(S,a+1),S,a],B.push(u),S=a);break}}return S++,u}function A(N){D.push(N)}return{back:A,endOfFile:C,nextToken:g,position:te}}});var $r=X((Kc,jr)=>{"use strict";var ga=jt(),ya=Mt(),Sa=kt(),ba=ot(),Ur=Qt(),Aa=Vr(),zr={empty:!0,space:!0};function Ea(t){for(let e=t.length-1;e>=0;e--){let n=t[e],i=n[3]||n[2];if(i)return i}}var zn=class{constructor(e){this.input=e,this.root=new ba,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let n=new ga;n.name=e[1].slice(1),n.name===""&&this.unnamedAtrule(n,e),this.init(n,e[2]);let i,r,o,s=!1,l=!1,a=[],c=[];for(;!this.tokenizer.endOfFile();){if(e=this.tokenizer.nextToken(),i=e[0],i==="("||i==="["?c.push(i==="("?")":"]"):i==="{"&&c.length>0?c.push("}"):i===c[c.length-1]&&c.pop(),c.length===0)if(i===";"){n.source.end=this.getPosition(e[2]),n.source.end.offset++,this.semicolon=!0;break}else if(i==="{"){l=!0;break}else if(i==="}"){if(a.length>0){for(o=a.length-1,r=a[o];r&&r[0]==="space";)r=a[--o];r&&(n.source.end=this.getPosition(r[3]||r[2]),n.source.end.offset++)}this.end(e);break}else a.push(e);else a.push(e);if(this.tokenizer.endOfFile()){s=!0;break}}n.raws.between=this.spacesAndCommentsFromEnd(a),a.length?(n.raws.afterName=this.spacesAndCommentsFromStart(a),this.raw(n,"params",a),s&&(e=a[a.length-1],n.source.end=this.getPosition(e[3]||e[2]),n.source.end.offset++,this.spaces=n.raws.between,n.raws.between="")):(n.raws.afterName="",n.params=""),l&&(n.nodes=[],this.current=n)}checkMissedSemicolon(e){let n=this.colon(e);if(n===!1)return;let i=0,r;for(let o=n-1;o>=0&&(r=e[o],!(r[0]!=="space"&&(i+=1,i===2)));o--);throw this.input.error("Missed semicolon",r[0]==="word"?r[3]+1:r[2])}colon(e){let n=0,i,r,o;for(let[s,l]of e.entries()){if(r=l,o=r[0],o==="("&&(n+=1),o===")"&&(n-=1),n===0&&o===":")if(!i)this.doubleColon(r);else{if(i[0]==="word"&&i[1]==="progid")continue;return s}i=r}return!1}comment(e){let n=new ya;this.init(n,e[2]),n.source.end=this.getPosition(e[3]||e[2]),n.source.end.offset++;let i=e[1].slice(2,-2);if(!i.trim())n.text="",n.raws.left=i,n.raws.right="";else{let r=i.match(/^(\s*)([^]*\S)(\s*)$/);n.text=r[2],n.raws.left=r[1],n.raws.right=r[3]}}createTokenizer(){this.tokenizer=Aa(this.input)}decl(e,n){let i=new Sa;this.init(i,e[0][2]);let r=e[e.length-1];for(r[0]===";"&&(this.semicolon=!0,e.pop()),i.source.end=this.getPosition(r[3]||r[2]||Ea(e)),i.source.end.offset++;e[0][0]!=="word";)e.length===1&&this.unknownWord(e),i.raws.before+=e.shift()[1];for(i.source.start=this.getPosition(e[0][2]),i.prop="";e.length;){let c=e[0][0];if(c===":"||c==="space"||c==="comment")break;i.prop+=e.shift()[1]}i.raws.between="";let o;for(;e.length;)if(o=e.shift(),o[0]===":"){i.raws.between+=o[1];break}else o[0]==="word"&&/\w/.test(o[1])&&this.unknownWord([o]),i.raws.between+=o[1];(i.prop[0]==="_"||i.prop[0]==="*")&&(i.raws.before+=i.prop[0],i.prop=i.prop.slice(1));let s=[],l;for(;e.length&&(l=e[0][0],!(l!=="space"&&l!=="comment"));)s.push(e.shift());this.precheckMissedSemicolon(e);for(let c=e.length-1;c>=0;c--){if(o=e[c],o[1].toLowerCase()==="!important"){i.important=!0;let u=this.stringFrom(e,c);u=this.spacesFromEnd(e)+u,u!==" !important"&&(i.raws.important=u);break}else if(o[1].toLowerCase()==="important"){let u=e.slice(0),m="";for(let f=c;f>0;f--){let x=u[f][0];if(m.trim().startsWith("!")&&x!=="space")break;m=u.pop()[1]+m}m.trim().startsWith("!")&&(i.important=!0,i.raws.important=m,e=u)}if(o[0]!=="space"&&o[0]!=="comment")break}e.some(c=>c[0]!=="space"&&c[0]!=="comment")&&(i.raws.between+=s.map(c=>c[1]).join(""),s=[]),this.raw(i,"value",s.concat(e),n),i.value.includes(":")&&!n&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error("Double colon",{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let n=new Ur;this.init(n,e[2]),n.selector="",n.raws.between="",this.current=n}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let n=this.current.nodes[this.current.nodes.length-1];n&&n.type==="rule"&&!n.raws.ownSemicolon&&(n.raws.ownSemicolon=this.spaces,this.spaces="",n.source.end=this.getPosition(e[2]),n.source.end.offset+=n.raws.ownSemicolon.length)}}getPosition(e){let n=this.input.fromOffset(e);return{column:n.col,line:n.line,offset:e}}init(e,n){this.current.push(e),e.source={input:this.input,start:this.getPosition(n)},e.raws.before=this.spaces,this.spaces="",e.type!=="comment"&&(this.semicolon=!1)}other(e){let n=!1,i=null,r=!1,o=null,s=[],l=e[1].startsWith("--"),a=[],c=e;for(;c;){if(i=c[0],a.push(c),i==="("||i==="[")o||(o=c),s.push(i==="("?")":"]");else if(l&&r&&i==="{")o||(o=c),s.push("}");else if(s.length===0)if(i===";")if(r){this.decl(a,l);return}else break;else if(i==="{"){this.rule(a);return}else if(i==="}"){this.tokenizer.back(a.pop()),n=!0;break}else i===":"&&(r=!0);else i===s[s.length-1]&&(s.pop(),s.length===0&&(o=null));c=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(n=!0),s.length>0&&this.unclosedBracket(o),n&&r){if(!l)for(;a.length&&(c=a[a.length-1][0],!(c!=="space"&&c!=="comment"));)this.tokenizer.back(a.pop());this.decl(a,l)}else this.unknownWord(a)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case"space":this.spaces+=e[1];break;case";":this.freeSemicolon(e);break;case"}":this.end(e);break;case"comment":this.comment(e);break;case"at-word":this.atrule(e);break;case"{":this.emptyRule(e);break;default:this.other(e);break}this.endFile()}precheckMissedSemicolon(){}raw(e,n,i,r){let o,s,l=i.length,a="",c=!0,u,m;for(let f=0;f<l;f+=1)o=i[f],s=o[0],s==="space"&&f===l-1&&!r?c=!1:s==="comment"?(m=i[f-1]?i[f-1][0]:"empty",u=i[f+1]?i[f+1][0]:"empty",!zr[m]&&!zr[u]?a.slice(-1)===","?c=!1:a+=o[1]:c=!1):a+=o[1];if(!c){let f=i.reduce((x,F)=>x+F[1],"");e.raws[n]={raw:f,value:a}}e[n]=a}rule(e){e.pop();let n=new Ur;this.init(n,e[0][2]),n.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(n,"selector",e),this.current=n}spacesAndCommentsFromEnd(e){let n,i="";for(;e.length&&(n=e[e.length-1][0],!(n!=="space"&&n!=="comment"));)i=e.pop()[1]+i;return i}spacesAndCommentsFromStart(e){let n,i="";for(;e.length&&(n=e[0][0],!(n!=="space"&&n!=="comment"));)i+=e.shift()[1];return i}spacesFromEnd(e){let n,i="";for(;e.length&&(n=e[e.length-1][0],n==="space");)i=e.pop()[1]+i;return i}stringFrom(e,n){let i="";for(let r=n;r<e.length;r++)i+=e[r][1];return e.splice(n,e.length-n),i}unclosedBlock(){let e=this.current.source.start;throw this.input.error("Unclosed block",e.line,e.column)}unclosedBracket(e){throw this.input.error("Unclosed bracket",{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error("Unexpected }",{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error("Unknown word "+e[0][1],{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,n){throw this.input.error("At-rule without name",{offset:n[2]},{offset:n[2]+n[1].length})}};jr.exports=zn});var nn=X((Jc,Gr)=>{"use strict";var Fa=qe(),wa=_t(),Na=$r();function tn(t,e){let n=new wa(t,e),i=new Na(n);try{i.parse()}catch(r){throw r}return i.root}Gr.exports=tn;tn.default=tn;Fa.registerParse(tn)});var jn=X((Qc,Kr)=>{"use strict";var Dt=class{constructor(e,n={}){if(this.type="warning",this.text=e,n.node&&n.node.source){let i=n.node.rangeBy(n);this.line=i.start.line,this.column=i.start.column,this.endLine=i.end.line,this.endColumn=i.end.column}for(let i in n)this[i]=n[i]}toString(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text}};Kr.exports=Dt;Dt.default=Dt});var rn=X((Yc,Jr)=>{"use strict";var Ca=jn(),Bt=class{get content(){return this.css}constructor(e,n,i){this.processor=e,this.messages=[],this.root=n,this.opts=i,this.css="",this.map=void 0}toString(){return this.css}warn(e,n={}){n.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(n.plugin=this.lastPlugin.postcssPlugin);let i=new Ca(e,n);return this.messages.push(i),i}warnings(){return this.messages.filter(e=>e.type==="warning")}};Jr.exports=Bt;Bt.default=Bt});var $n=X((Zc,Yr)=>{"use strict";var Qr={};Yr.exports=function(e){Qr[e]||(Qr[e]=!0,typeof console<"u"&&console.warn&&console.warn(e))}});var Jn=X((ed,to)=>{"use strict";var Ma=qe(),Ta=$t(),ka=Un(),va=nn(),Zr=rn(),_a=ot(),Ra=Et(),{isClean:Be,my:La}=zt(),Xc=$n(),Da={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},Ba={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},Ia={Once:!0,postcssPlugin:!0,prepare:!0},at=0;function It(t){return typeof t=="object"&&typeof t.then=="function"}function eo(t){let e=!1,n=Da[t.type];return t.type==="decl"?e=t.prop.toLowerCase():t.type==="atrule"&&(e=t.name.toLowerCase()),e&&t.append?[n,n+"-"+e,at,n+"Exit",n+"Exit-"+e]:e?[n,n+"-"+e,n+"Exit",n+"Exit-"+e]:t.append?[n,at,n+"Exit"]:[n,n+"Exit"]}function Xr(t){let e;return t.type==="document"?e=["Document",at,"DocumentExit"]:t.type==="root"?e=["Root",at,"RootExit"]:e=eo(t),{eventIndex:0,events:e,iterator:0,node:t,visitorIndex:0,visitors:[]}}function Gn(t){return t[Be]=!1,t.nodes&&t.nodes.forEach(e=>Gn(e)),t}var Kn={},Ue=class t{get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return"LazyResult"}constructor(e,n,i){this.stringified=!1,this.processed=!1;let r;if(typeof n=="object"&&n!==null&&(n.type==="root"||n.type==="document"))r=Gn(n);else if(n instanceof t||n instanceof Zr)r=Gn(n.root),n.map&&(typeof i.map>"u"&&(i.map={}),i.map.inline||(i.map.inline=!1),i.map.prev=n.map);else{let o=va;i.syntax&&(o=i.syntax.parse),i.parser&&(o=i.parser),o.parse&&(o=o.parse);try{r=o(n,i)}catch(s){this.processed=!0,this.error=s}r&&!r[La]&&Ma.rebuild(r)}this.result=new Zr(e,r,i),this.helpers={...Kn,postcss:Kn,result:this.result},this.plugins=this.processor.plugins.map(o=>typeof o=="object"&&o.prepare?{...o,...o.prepare(this.result)}:o)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(e,n){let i=this.result.lastPlugin;try{n&&n.addToError(e),this.error=e,e.name==="CssSyntaxError"&&!e.plugin?(e.plugin=i.postcssPlugin,e.setMessage()):i.postcssVersion}catch(r){console&&console.error&&console.error(r)}return e}prepareVisitors(){this.listeners={};let e=(n,i,r)=>{this.listeners[i]||(this.listeners[i]=[]),this.listeners[i].push([n,r])};for(let n of this.plugins)if(typeof n=="object")for(let i in n){if(!Ba[i]&&/^[A-Z]/.test(i))throw new Error(`Unknown event ${i} in ${n.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`);if(!Ia[i])if(typeof n[i]=="object")for(let r in n[i])r==="*"?e(n,i,n[i][r]):e(n,i+"-"+r.toLowerCase(),n[i][r]);else typeof n[i]=="function"&&e(n,i,n[i])}this.hasListener=Object.keys(this.listeners).length>0}async runAsync(){this.plugin=0;for(let e=0;e<this.plugins.length;e++){let n=this.plugins[e],i=this.runOnRoot(n);if(It(i))try{await i}catch(r){throw this.handleError(r)}}if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[Be];){e[Be]=!0;let n=[Xr(e)];for(;n.length>0;){let i=this.visitTick(n);if(It(i))try{await i}catch(r){let o=n[n.length-1].node;throw this.handleError(r,o)}}}if(this.listeners.OnceExit)for(let[n,i]of this.listeners.OnceExit){this.result.lastPlugin=n;try{if(e.type==="document"){let r=e.nodes.map(o=>i(o,this.helpers));await Promise.all(r)}else await i(e,this.helpers)}catch(r){throw this.handleError(r)}}}return this.processed=!0,this.stringify()}runOnRoot(e){this.result.lastPlugin=e;try{if(typeof e=="object"&&e.Once){if(this.result.root.type==="document"){let n=this.result.root.nodes.map(i=>e.Once(i,this.helpers));return It(n[0])?Promise.all(n):n}return e.Once(this.result.root,this.helpers)}else if(typeof e=="function")return e(this.result.root,this.result)}catch(n){throw this.handleError(n)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();let e=this.result.opts,n=Ra;e.syntax&&(n=e.syntax.stringify),e.stringifier&&(n=e.stringifier),n.stringify&&(n=n.stringify);let i=this.result.root.source;if(e.map===void 0&&!(i&&i.input&&i.input.map)){let s="";return n(this.result.root,l=>{s+=l}),this.result.css=s,this.result}let o=new ka(n,this.result.root,this.result.opts).generate();return this.result.css=o[0],this.result.map=o[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(let e of this.plugins){let n=this.runOnRoot(e);if(It(n))throw this.getAsyncError()}if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[Be];)e[Be]=!0,this.walkSync(e);if(this.listeners.OnceExit)if(e.type==="document")for(let n of e.nodes)this.visitSync(this.listeners.OnceExit,n);else this.visitSync(this.listeners.OnceExit,e)}return this.result}then(e,n){return this.async().then(e,n)}toString(){return this.css}visitSync(e,n){for(let[i,r]of e){this.result.lastPlugin=i;let o;try{o=r(n,this.helpers)}catch(s){throw this.handleError(s,n.proxyOf)}if(n.type!=="root"&&n.type!=="document"&&!n.parent)return!0;if(It(o))throw this.getAsyncError()}}visitTick(e){let n=e[e.length-1],{node:i,visitors:r}=n;if(i.type!=="root"&&i.type!=="document"&&!i.parent){e.pop();return}if(r.length>0&&n.visitorIndex<r.length){let[s,l]=r[n.visitorIndex];n.visitorIndex+=1,n.visitorIndex===r.length&&(n.visitors=[],n.visitorIndex=0),this.result.lastPlugin=s;try{return l(i.toProxy(),this.helpers)}catch(a){throw this.handleError(a,i)}}if(n.iterator!==0){let s=n.iterator,l;for(;l=i.nodes[i.indexes[s]];)if(i.indexes[s]+=1,!l[Be]){l[Be]=!0,e.push(Xr(l));return}n.iterator=0,delete i.indexes[s]}let o=n.events;for(;n.eventIndex<o.length;){let s=o[n.eventIndex];if(n.eventIndex+=1,s===at){i.nodes&&i.nodes.length&&(i[Be]=!0,n.iterator=i.getIterator());return}else if(this.listeners[s]){n.visitors=this.listeners[s];return}}e.pop()}walkSync(e){e[Be]=!0;let n=eo(e);for(let i of n)if(i===at)e.nodes&&e.each(r=>{r[Be]||this.walkSync(r)});else{let r=this.listeners[i];if(r&&this.visitSync(r,e.toProxy()))return}}warnings(){return this.sync().warnings()}};Ue.registerPostcss=t=>{Kn=t};to.exports=Ue;Ue.default=Ue;_a.registerLazyResult(Ue);Ta.registerLazyResult(Ue)});var io=X((nd,no)=>{"use strict";var Oa=Un(),Pa=nn(),Wa=rn(),Ha=Et(),td=$n(),Ot=class{get content(){return this.result.css}get css(){return this.result.css}get map(){return this.result.map}get messages(){return[]}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){if(this._root)return this._root;let e,n=Pa;try{e=n(this._css,this._opts)}catch(i){this.error=i}if(this.error)throw this.error;return this._root=e,e}get[Symbol.toStringTag](){return"NoWorkResult"}constructor(e,n,i){n=n.toString(),this.stringified=!1,this._processor=e,this._css=n,this._opts=i,this._map=void 0;let r=Ha;this.result=new Wa(this._processor,void 0,this._opts),this.result.css=n;let o=this;Object.defineProperty(this.result,"root",{get(){return o.root}});let s=new Oa(r,void 0,this._opts,n);if(s.isMap()){let[l,a]=s.generate();l&&(this.result.css=l),a&&(this.result.map=a)}else s.clearAnnotation(),this.result.css=s.css}async(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}sync(){if(this.error)throw this.error;return this.result}then(e,n){return this.async().then(e,n)}toString(){return this._css}warnings(){return[]}};no.exports=Ot;Ot.default=Ot});var oo=X((id,ro)=>{"use strict";var qa=$t(),Va=Jn(),Ua=io(),za=ot(),Xe=class{constructor(e=[]){this.version="8.5.14",this.plugins=this.normalize(e)}normalize(e){let n=[];for(let i of e)if(i.postcss===!0?i=i():i.postcss&&(i=i.postcss),typeof i=="object"&&Array.isArray(i.plugins))n=n.concat(i.plugins);else if(typeof i=="object"&&i.postcssPlugin)n.push(i);else if(typeof i=="function")n.push(i);else if(!(typeof i=="object"&&(i.parse||i.stringify)))throw new Error(i+" is not a PostCSS plugin");return n}process(e,n={}){return!this.plugins.length&&!n.parser&&!n.stringifier&&!n.syntax?new Ua(this,e,n):new Va(this,e,n)}use(e){return this.plugins=this.plugins.concat(this.normalize([e])),this}};ro.exports=Xe;Xe.default=Xe;za.registerProcessor(Xe);qa.registerProcessor(Xe)});var po=X((rd,mo)=>{"use strict";var so=jt(),ao=Mt(),ja=qe(),$a=Ut(),lo=kt(),uo=$t(),Ga=Lr(),Ka=_t(),Ja=Jn(),Qa=qn(),Ya=Nt(),Za=nn(),Qn=oo(),Xa=rn(),co=ot(),fo=Qt(),el=Et(),tl=jn();function re(...t){return t.length===1&&Array.isArray(t[0])&&(t=t[0]),new Qn(t)}re.plugin=function(e,n){let i=!1;function r(...s){console&&console.warn&&!i&&(i=!0,console.warn(e+`: postcss.plugin was deprecated. Migration guide:
|
|
28
28
|
https://evilmartians.com/chronicles/postcss-8-plugin-migration`),process.env.LANG&&process.env.LANG.startsWith("cn")&&console.warn(e+`: \u91CC\u9762 postcss.plugin \u88AB\u5F03\u7528. \u8FC1\u79FB\u6307\u5357:
|
|
29
|
-
https://www.w3ctech.com/topic/2226`));let l=n(...s);return l.postcssPlugin=e,l.postcssVersion=new Qn().version,l}let o;return Object.defineProperty(r,"postcss",{get(){return o||(o=r()),o}}),r.process=function(s,l,a){return re([r(a)]).process(s,l)},r};re.stringify=el;re.parse=Za;re.fromJSON=Ga;re.list=Qa;re.comment=t=>new ao(t);re.atRule=t=>new so(t);re.decl=t=>new lo(t);re.rule=t=>new fo(t);re.root=t=>new co(t);re.document=t=>new uo(t);re.CssSyntaxError=$a;re.Declaration=lo;re.Container=ja;re.Processor=Qn;re.Document=uo;re.Comment=ao;re.Warning=tl;re.AtRule=so;re.Result=Xa;re.Input=Ka;re.Rule=fo;re.Root=co;re.Node=Ya;Ja.registerPostcss(re);mo.exports=re;re.default=re});function _(t,e){if(typeof window>"u")return;let n=window,i=n.__hf?.onSwallowed;if(i)try{i({label:t,error:e})}catch(r){}(n.__hfDebug||n.__HYPERFRAMES_DEBUG)&&console.debug(`[hyperframes] ${t} swallowed:`,e)}function Ae(t){try{window.parent.postMessage(t,"*")}catch(e){_("bridge.postMessage",e)}}function yi(t){let e=n=>{let i=n.data;if(!i||i.source!=="hf-parent"||i.type!=="control")return;let r=i.action;if(r==="play"){t.onPlay();return}if(r==="pause"){t.onPause();return}if(r==="seek"){t.onSeek(Number(i.frame??0),i.seekMode??"commit");return}if(r==="tick"){t.onTick();return}if(r==="set-muted"){t.onSetMuted(!!i.muted);return}if(r==="set-volume"){t.onSetVolume(Math.max(0,Math.min(1,Number(i.volume??1))));return}if(r==="set-media-output-muted"){t.onSetMediaOutputMuted(!!i.muted);return}if(r==="set-playback-rate"){t.onSetPlaybackRate(Number(i.playbackRate??1));return}if(r==="enable-pick-mode"){t.onEnablePickMode();return}if(r==="disable-pick-mode"){t.onDisablePickMode();return}if(r==="flash-elements"){let o=i.selectors,s=i.duration||800;o&&ps(o,s)}};return window.addEventListener("message",e),e}function ps(t,e){if(!document.getElementById("__hf-flash-styles")){let n=document.createElement("style");n.id="__hf-flash-styles",n.textContent=`
|
|
29
|
+
https://www.w3ctech.com/topic/2226`));let l=n(...s);return l.postcssPlugin=e,l.postcssVersion=new Qn().version,l}let o;return Object.defineProperty(r,"postcss",{get(){return o||(o=r()),o}}),r.process=function(s,l,a){return re([r(a)]).process(s,l)},r};re.stringify=el;re.parse=Za;re.fromJSON=Ga;re.list=Qa;re.comment=t=>new ao(t);re.atRule=t=>new so(t);re.decl=t=>new lo(t);re.rule=t=>new fo(t);re.root=t=>new co(t);re.document=t=>new uo(t);re.CssSyntaxError=$a;re.Declaration=lo;re.Container=ja;re.Processor=Qn;re.Document=uo;re.Comment=ao;re.Warning=tl;re.AtRule=so;re.Result=Xa;re.Input=Ka;re.Rule=fo;re.Root=co;re.Node=Ya;Ja.registerPostcss(re);mo.exports=re;re.default=re});function _(t,e){if(typeof window>"u")return;let n=window,i=n.__hf?.onSwallowed;if(i)try{i({label:t,error:e})}catch(r){}(n.__hfDebug||n.__HYPERFRAMES_DEBUG)&&console.debug(`[hyperframes] ${t} swallowed:`,e)}function Ae(t){try{window.parent.postMessage(t,"*")}catch(e){_("bridge.postMessage",e)}}function yi(t){let e=n=>{let i=n.data;if(!i||i.source!=="hf-parent"||i.type!=="control")return;let r=i.action;if(r==="play"){t.onPlay();return}if(r==="pause"){t.onPause();return}if(r==="seek"){t.onSeek(Number(i.frame??0),i.seekMode??"commit");return}if(r==="tick"){t.onTick();return}if(r==="set-muted"){t.onSetMuted(!!i.muted);return}if(r==="set-volume"){t.onSetVolume(Math.max(0,Math.min(1,Number(i.volume??1))));return}if(r==="set-media-output-muted"){t.onSetMediaOutputMuted(!!i.muted);return}if(r==="set-playback-rate"){t.onSetPlaybackRate(Number(i.playbackRate??1));return}if(r==="enable-pick-mode"){t.onEnablePickMode();return}if(r==="disable-pick-mode"){t.onDisablePickMode();return}if(r==="flash-elements"){let o=i.selectors,s=i.duration||800;o&&ps(o,s)}};return window.addEventListener("message",e),Ae({source:"hf-preview",type:"ready"}),e}function ps(t,e){if(!document.getElementById("__hf-flash-styles")){let n=document.createElement("style");n.id="__hf-flash-styles",n.textContent=`
|
|
30
30
|
.__hf-flash {
|
|
31
31
|
outline: 2px solid rgba(59, 130, 246, 0.6) !important;
|
|
32
32
|
outline-offset: 2px !important;
|
package/dist/studio/assets/{hyperframes-player-WXAuftNy.js → hyperframes-player-0esDKGRk.js}
RENAMED
|
@@ -415,4 +415,4 @@ var le=Object.defineProperty;var he=(n,t,e)=>t in n?le(n,t,{enumerable:!0,config
|
|
|
415
415
|
background: var(--hfp-accent, #fff);
|
|
416
416
|
pointer-events: none;
|
|
417
417
|
}
|
|
418
|
-
`,te='<svg width="24" height="24" viewBox="0 0 18 18" fill="currentColor"><polygon points="4,2 16,9 4,16"/></svg>',be='<svg width="24" height="24" viewBox="0 0 18 18" fill="currentColor"><rect x="3" y="2" width="4" height="14"/><rect x="11" y="2" width="4" height="14"/></svg>',ie='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/><path d="M14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></svg>',re='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/></svg>',ve='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z" opacity="0.3"/><line x1="18" y1="7" x2="14" y2="17" stroke="currentColor" stroke-width="2"/></svg>',ye=[.25,.5,1,1.5,2,4];function N(n){return Number.isInteger(n)?`${n}x`:`${n}x`}function ne(n){if(!Number.isFinite(n)||n<0)return"0:00";const t=Math.floor(n),e=Math.floor(t/60),i=t%60;return`${e}:${i.toString().padStart(2,"0")}`}function we(n,t,e={}){const i=e.speedPresets??ye,r=document.createElement("div");r.className="hfp-controls",r.addEventListener("click",o=>{o.stopPropagation()});const s=document.createElement("button");s.className="hfp-play-btn",s.type="button",s.innerHTML=te,s.setAttribute("aria-label","Play");const a=document.createElement("div");a.className="hfp-scrubber";const d=document.createElement("div");d.className="hfp-progress",d.style.width="0%",a.appendChild(d);const c=document.createElement("span");c.className="hfp-time",c.textContent="0:00 / 0:00";const m=document.createElement("div");m.className="hfp-speed-wrap";const u=document.createElement("button");u.className="hfp-speed-btn",u.type="button",u.textContent="1x",u.setAttribute("aria-label","Playback speed");const p=document.createElement("div");p.className="hfp-speed-menu",p.setAttribute("role","menu");for(const o of i){const l=document.createElement("button");l.className="hfp-speed-option",l.type="button",l.setAttribute("role","menuitem"),l.dataset.speed=String(o),l.textContent=N(o),o===1&&l.classList.add("hfp-active"),p.appendChild(l)}m.appendChild(p),m.appendChild(u);const g=document.createElement("div");g.className="hfp-volume-wrap";const f=document.createElement("button");f.className="hfp-mute-btn",f.type="button",f.innerHTML=ie,f.setAttribute("aria-label","Mute");const b=document.createElement("div");b.className="hfp-volume-slider-wrap";const _=document.createElement("div");_.className="hfp-volume-slider",_.setAttribute("role","slider"),_.setAttribute("aria-label","Volume"),_.setAttribute("aria-valuemin","0"),_.setAttribute("aria-valuemax","100"),_.setAttribute("aria-valuenow","100"),_.tabIndex=0;const y=document.createElement("div");y.className="hfp-volume-fill",y.style.width="100%",_.appendChild(y),b.appendChild(_),g.appendChild(b),g.appendChild(f),e.audioLocked&&(g.style.display="none"),r.appendChild(s),r.appendChild(a),r.appendChild(c),r.appendChild(g),r.appendChild(m),n.appendChild(r);let L=!1,A=!1,w=1,k=null;i.indexOf(1);const M=(o,l)=>o?ve:l===0||l<.5?re:ie;s.addEventListener("click",o=>{o.stopPropagation(),L?t.onPause():t.onPlay()}),f.addEventListener("click",o=>{o.stopPropagation(),t.onMuteToggle()});let E=!1;const P=o=>{const l=_.getBoundingClientRect(),v=Math.max(0,Math.min(1,(o-l.left)/l.width));w=v,y.style.width=`${v*100}%`,_.setAttribute("aria-valuenow",String(Math.round(v*100))),A&&v>0&&t.onMuteToggle(),f.innerHTML=M(A,v),t.onVolumeChange(v)};_.addEventListener("mousedown",o=>{o.stopPropagation(),E=!0,P(o.clientX)});const $=o=>{E&&P(o.clientX)},z=()=>{E=!1};document.addEventListener("mousemove",$),document.addEventListener("mouseup",z),_.addEventListener("touchstart",o=>{E=!0;const l=o.touches[0];l&&P(l.clientX)},{passive:!0});const j=o=>{if(E){const l=o.touches[0];l&&P(l.clientX)}},q=()=>{E=!1};document.addEventListener("touchmove",j,{passive:!0}),document.addEventListener("touchend",q);const B=.05;_.addEventListener("keydown",o=>{let l=w;if(o.key==="ArrowRight"||o.key==="ArrowUp")l=Math.min(1,w+B);else if(o.key==="ArrowLeft"||o.key==="ArrowDown")l=Math.max(0,w-B);else return;o.preventDefault(),o.stopPropagation(),w=l,y.style.width=`${l*100}%`,_.setAttribute("aria-valuenow",String(Math.round(l*100))),A&&l>0&&t.onMuteToggle(),f.innerHTML=M(A,l),t.onVolumeChange(l)});const W=o=>{for(const l of p.querySelectorAll(".hfp-speed-option"))l.classList.toggle("hfp-active",l.dataset.speed===String(o))};u.addEventListener("click",o=>{o.stopPropagation();const l=p.classList.toggle("hfp-open");u.setAttribute("aria-expanded",String(l))}),p.addEventListener("click",o=>{o.stopPropagation();const l=o.target.closest(".hfp-speed-option");if(!l)return;const v=parseFloat(l.dataset.speed);i.indexOf(v),u.textContent=N(v),W(v),p.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false"),t.onSpeedChange(v)});const X=()=>{p.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false")};document.addEventListener("click",X);const R=o=>{const l=a.getBoundingClientRect(),v=Math.max(0,Math.min(1,(o-l.left)/l.width));t.onSeek(v)};let T=!1;a.addEventListener("mousedown",o=>{o.stopPropagation(),T=!0,R(o.clientX)});const G=o=>{T&&R(o.clientX)},Y=()=>{T=!1};document.addEventListener("mousemove",G),document.addEventListener("mouseup",Y),a.addEventListener("touchstart",o=>{T=!0;const l=o.touches[0];l&&R(l.clientX)},{passive:!0});const Q=o=>{if(T){const l=o.touches[0];l&&R(l.clientX)}},J=()=>{T=!1};document.addEventListener("touchmove",Q,{passive:!0}),document.addEventListener("touchend",J);const K=()=>{k&&clearTimeout(k),k=setTimeout(()=>{L&&r.classList.add("hfp-hidden")},3e3)},Z=n instanceof ShadowRoot?n.host:n;return Z.addEventListener("mousemove",()=>{r.classList.remove("hfp-hidden"),K()}),Z.addEventListener("mouseleave",()=>{L&&r.classList.add("hfp-hidden")}),{updateTime(o,l){const v=l>0?Math.min(o,l):o,de=l>0?v/l*100:0;d.style.width=`${de}%`,c.textContent=`${ne(v)} / ${ne(l)}`},updatePlaying(o){L=o,s.innerHTML=o?be:te,s.setAttribute("aria-label",o?"Pause":"Play"),o?K():r.classList.remove("hfp-hidden")},updateSpeed(o){i.indexOf(o),u.textContent=N(o),W(o)},updateMuted(o){A=o,f.innerHTML=M(o,w),f.setAttribute("aria-label",o?"Unmute":"Mute")},updateVolume(o){w=o,y.style.width=`${o*100}%`,_.setAttribute("aria-valuenow",String(Math.round(o*100))),f.innerHTML=M(A,o)},setVolumeControlsHidden(o){g.style.display=o?"none":""},show(){r.style.display=""},hide(){r.style.display="none"},destroy(){document.removeEventListener("mousemove",G),document.removeEventListener("mouseup",Y),document.removeEventListener("touchmove",Q),document.removeEventListener("touchend",J),document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",j),document.removeEventListener("touchend",q),document.removeEventListener("click",X),k&&clearTimeout(k)}}}function Ae(n,t,e,i,r,s=!1){const a=i?i.split(",").map(Number).filter(m=>!isNaN(m)&&m>0):void 0,d={...a?{speedPresets:a}:{},audioLocked:s},c=we(n,r,d);return c.updateMuted(t),c.updateVolume(e),c}function se(n,t,e){return t?(e||(e=document.createElement("img"),e.className="hfp-poster",n.appendChild(e)),e.src=t,e):(e==null||e.remove(),null)}function Ee(n){return n.composedPath().some(t=>t instanceof HTMLElement&&t.classList.contains("hfp-controls"))}let I=null;function Te(n,t){if(typeof CSSStyleSheet<"u")try{I||(I=new CSSStyleSheet,I.replaceSync(t)),n.adoptedStyleSheets=[I];return}catch{}const e=document.createElement("style");e.textContent=t,n.appendChild(e)}function Ce(){const n=document.createElement("div");n.className="hfp-container";const t=document.createElement("iframe");return t.className="hfp-iframe",t.sandbox.add("allow-scripts","allow-same-origin"),t.allow="autoplay; fullscreen",t.referrerPolicy="no-referrer",t.title="HyperFrames Composition",n.appendChild(t),{container:n,iframe:t}}function ke(n,t,e,i){const r=n.offsetWidth,s=n.offsetHeight;if(r===0||s===0)return;const a=Math.min(r/e,s/i);t.style.width=`${e}px`,t.style.height=`${i}px`,t.style.transform=`translate(-50%, -50%) scale(${a})`}const xe=100;class Se{constructor(t){h(this,"_raf",null);h(this,"_lastUpdateMs",0);this._callbacks=t}start(t,e,i,r){this.stop();const s=()=>{if(r()){this._raf=null;return}let a;try{a=t.time()}catch{this._raf=null;return}const d=i();d>0&&(a=Math.min(a,d));const c=d>0&&a>=d,m=performance.now();if((m-this._lastUpdateMs>xe||c)&&(this._lastUpdateMs=m,this._callbacks.onTimeUpdate(a,d)),c){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{t.pause()}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(s)};this._raf=requestAnimationFrame(s)}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}}function Le(n){const t=Array.from(n.querySelectorAll("[data-composition-id]"));if(t.length===0)return n.body?[n.body]:[];const e=[];for(const i of t)Pe(i)||e.push(i);return Me(n),e}function Me(n){const t=n.body;if(!t||typeof console>"u"||typeof console.warn!="function")return;const e=t.querySelectorAll("audio[data-start], video[data-start]");if(e.length===0)return;const i=[];for(const r of e)r.closest("[data-composition-id]")||i.push(r);i.length!==0&&console.warn(`[hyperframes-player] selectMediaObserverTargets: composition hosts are present, but ${i.length} body-level timed media element(s) sit outside every [data-composition-id] subtree and will not be observed. Move them inside a composition host or the parent-frame proxy will never adopt them.`,i)}function Pe(n){let t=n.parentElement;for(;t;){if(t.hasAttribute("data-composition-id"))return!0;t=t.parentElement}return!1}const Re=.05,Ie=2;class Oe{constructor(t){h(this,"_entries",[]);h(this,"_mediaObserver");h(this,"_playbackErrorPosted",!1);h(this,"_audioOwner","runtime");h(this,"_dispatchEvent");h(this,"_getMuted");h(this,"_getVolume");h(this,"_getPlaybackRate");h(this,"_getCurrentTime");h(this,"_isPaused");this._dispatchEvent=t.dispatchEvent,this._getMuted=t.getMuted,this._getVolume=t.getVolume,this._getPlaybackRate=t.getPlaybackRate,this._getCurrentTime=t.getCurrentTime,this._isPaused=t.isPaused}get audioOwner(){return this._audioOwner}get entries(){return this._entries}get playbackErrorPosted(){return this._playbackErrorPosted}resetForIframeLoad(){this._playbackErrorPosted=!1;const t=this._audioOwner==="parent";this._audioOwner="runtime",this.pauseAll(),this.teardownObserver(),t&&this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"runtime",reason:"iframe-reload"}}))}destroy(){this.teardownObserver();for(const t of this._entries)t.el.pause(),t.el.src="";this._entries=[]}updateMuted(t){for(const e of this._entries)e.el.muted=t}updateVolume(t){for(const e of this._entries)e.el.volume=t}updatePlaybackRate(t){for(const e of this._entries)e.el.playbackRate=t}playAll(){for(const t of this._entries)t.el.src&&t.el.play().catch(e=>this._reportPlaybackError(e))}pauseAll(){for(const t of this._entries)t.el.pause()}seekAll(t){for(const e of this._entries){const i=t-e.start;i>=0&&i<e.duration&&(e.el.currentTime=i)}}mirrorTime(t,e){const i=(e==null?void 0:e.force)===!0;for(const r of this._entries){const s=t-r.start;if(s<0||s>=r.duration){r.driftSamples=0;continue}Math.abs(r.el.currentTime-s)>Re?(r.driftSamples+=1,(i||r.driftSamples>=Ie)&&(r.el.currentTime=s,r.driftSamples=0)):r.driftSamples=0}}promoteToParentProxy(t,e){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",t)for(const r of t.querySelectorAll("video, audio"))r.muted=!0;const i=this._getCurrentTime();e?e(i,{force:!0}):this.mirrorTime(i,{force:!0}),this._isPaused()||this.playAll(),this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"parent",reason:"autoplay-blocked"}}))}setupFromIframe(t){const e=t.querySelectorAll("audio[data-start], video[data-start]");for(const i of e)this._adoptIframeMedia(i);this._observeDynamicMedia(t)}setupFromUrl(t){this._createEntry(t,"audio",0,1/0)}teardownObserver(){var t;(t=this._mediaObserver)==null||t.disconnect(),this._mediaObserver=void 0}_reportPlaybackError(t){this._playbackErrorPosted||(this._playbackErrorPosted=!0,this._dispatchEvent(new CustomEvent("playbackerror",{detail:{source:"parent-proxy",error:t}})))}_createEntry(t,e,i,r){if(this._entries.some(c=>c.el.src===t))return null;const s=e==="video"?document.createElement("video"):new Audio;s.preload="auto",s.src=t,s.load(),s.muted=this._getMuted(),s.volume=this._getVolume();const a=this._getPlaybackRate();a!==1&&(s.playbackRate=a);const d={el:s,start:i,duration:r,driftSamples:0};return this._entries.push(d),d}_adoptIframeMedia(t){var c;if(t.preload==="metadata"||t.preload==="none")return;const e=t.getAttribute("src")||((c=t.querySelector("source"))==null?void 0:c.getAttribute("src"));if(!e)return;const i=new URL(e,t.ownerDocument.baseURI).href,r=parseFloat(t.getAttribute("data-start")||"0"),s=parseFloat(t.getAttribute("data-duration")||"Infinity"),a=t.tagName==="VIDEO"?"video":"audio",d=this._createEntry(i,a,r,s);d&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),!this._isPaused()&&d.el.src&&d.el.play().catch(m=>this._reportPlaybackError(m)))}_detachIframeMedia(t){var a;const e=t.getAttribute("src")||((a=t.querySelector("source"))==null?void 0:a.getAttribute("src"));if(!e)return;const i=new URL(e,t.ownerDocument.baseURI).href,r=this._entries.findIndex(d=>d.el.src===i);if(r===-1)return;const s=this._entries[r];s.el.pause(),s.el.src="",this._entries.splice(r,1)}_observeDynamicMedia(t){if(this.teardownObserver(),typeof MutationObserver>"u"||!t.body)return;const e=new MutationObserver(s=>{var a,d,c,m;for(const u of s){if(u.type==="attributes"&&u.attributeName==="preload"){const p=u.target;p instanceof HTMLMediaElement&&p.matches("audio[data-start], video[data-start]")&&p.preload==="auto"&&this._adoptIframeMedia(p);continue}for(const p of u.addedNodes){if(!(p instanceof Element))continue;const g=[];(a=p.matches)!=null&&a.call(p,"audio[data-start], video[data-start]")&&g.push(p);const f=(d=p.querySelectorAll)==null?void 0:d.call(p,"audio[data-start], video[data-start]");if(f)for(const b of f)g.push(b);for(const b of g)this._adoptIframeMedia(b)}for(const p of u.removedNodes){if(!(p instanceof Element))continue;const g=[];(c=p.matches)!=null&&c.call(p,"audio[data-start], video[data-start]")&&g.push(p);const f=(m=p.querySelectorAll)==null?void 0:m.call(p,"audio[data-start], video[data-start]");if(f)for(const b of f)g.push(b);for(const b of g)this._detachIframeMedia(b)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload"]},r=Le(t);for(const s of r)e.observe(s,i);this._mediaObserver=e}}const De=100;function Ne(n,t,e,i){const r=(n.frame??0)/t,s=e.duration>0?Math.min(r,e.duration):r,a=!e.paused,d=!n.isPlaying,c=e.duration>0&&s>=e.duration&&(a||n.isPlaying);if(c&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(0),i.play(),{...e,currentTime:s,paused:!1};const m={...e,currentTime:s,paused:d};i.media.audioOwner==="parent"&&(a&&d?i.media.pauseAll():!a&&!d&&i.media.playAll(),i.media.mirrorTime(s));const u=performance.now(),p=d!==e.paused;return(u-e.lastUpdateMs>De||p)&&(m.lastUpdateMs=u,i.updateControlsTime(s,e.duration),i.updateControlsPlaying(!d),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:s}}))),c&&(i.media.audioOwner==="parent"&&i.media.pauseAll(),m.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),m}const oe=30;function Fe(n,t,e){if(n.source!==t)return;const i=n.data;if(!(!i||i.source!=="hf-preview")){if(i.type==="shader-transition-state"){const r=i.state&&typeof i.state=="object"?i.state:{};e.shaderLoader.update(r,e.getShaderLoadingMode()),e.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:i.compositionId,state:r}}));return}if(i.type==="state"){e.setPlaybackState(Ne({frame:i.frame??0,isPlaying:!!i.isPlaying},oe,e.getPlaybackState(),e));return}if(i.type==="media-autoplay-blocked"){let r=null;try{r=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(r,(s,a)=>e.media.mirrorTime(s,a)),e.sendControl("set-media-output-muted",{muted:!0});return}if(i.type==="timeline"&&i.durationInFrames>0){if(Number.isFinite(i.durationInFrames)){const r=e.getPlaybackState(),s=i.durationInFrames/oe;e.setPlaybackState({...r,duration:s}),e.updateControlsTime(r.currentTime,s)}return}i.type==="stage-size"&&i.width>0&&i.height>0&&e.setCompositionSize(i.width,i.height)}}const C="shader-capture-scale",x="shader-loading",Ue="__hf_shader_capture_scale",Ve="__hf_shader_loading",O=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function H(n){if(n===null)return null;const t=Number(n);return!Number.isFinite(t)||t<=0?null:String(Math.min(1,Math.max(.25,t)))}function He(n){if(n===null||n.trim()==="")return"composition";const t=n.trim().toLowerCase();return t==="none"||t==="false"||t==="0"||t==="off"?"none":t==="player"||t==="true"||t==="1"||t==="on"?"player":"composition"}function ae(n,t,e){e===null?n.delete(t):n.set(t,e)}function $e(n,t,e){const i=n.indexOf("#"),r=i>=0?n.slice(0,i):n,s=i>=0?n.slice(i):"",a=r.indexOf("?"),d=a>=0?r.slice(0,a):r,c=a>=0?r.slice(a+1):"",m=new URLSearchParams(c);ae(m,Ue,t),ae(m,Ve,e==="composition"?null:e);const u=m.toString();return`${d}${u?`?${u}`:""}${s}`}function ze(n,t,e){if(t===null&&e==="composition")return n;const i=[];t!==null&&i.push(`window.__HF_SHADER_CAPTURE_SCALE=${JSON.stringify(t)};`),e!=="composition"&&i.push(`window.__HF_SHADER_LOADING=${JSON.stringify(e)};`);const r=`<script data-hyperframes-player-shader-options>${i.join("")}<\/script>`;return/<head\b[^>]*>/i.test(n)?n.replace(/<head\b[^>]*>/i,s=>`${s}${r}`):/<html\b[^>]*>/i.test(n)?n.replace(/<html\b[^>]*>/i,s=>`${s}${r}`):`${r}${n}`}function S(n){return He(n.getAttribute(x))}function je(n){return Number(H(n.getAttribute(C))??"1")}function F(n,t){return $e(t,H(n.getAttribute(C)),S(n))}function U(n,t){return ze(t,H(n.getAttribute(C)),S(n))}function qe(){const n=document.createElement("div");n.className="hfp-shader-loader",n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-label","Preparing scene transitions"),n.setAttribute("data-hyperframes-ignore",""),n.draggable=!1;const t=f=>{f.preventDefault(),f.stopPropagation()};for(const f of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])n.addEventListener(f,t,{capture:!0});const e=document.createElement("div");e.className="hfp-shader-loader-panel",e.draggable=!1;const i=document.createElement("div");i.className="hfp-shader-loader-mark",i.draggable=!1,i.innerHTML=['<svg width="78" height="78" viewBox="0 0 100 100" fill="none" aria-hidden="true" draggable="false">','<path d="M10.1851 57.8021L33.1145 73.8313C36.2202 75.9978 41.5173 73.5433 42.4816 69.4984L51.7611 30.4271C52.7253 26.3822 48.5802 23.9277 44.4602 26.0942L13.917 42.1235C6.96677 45.7676 4.97564 54.1579 10.1851 57.8021Z" fill="url(#hfp-shader-loader-grad-left)"/>','<path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z" fill="url(#hfp-shader-loader-grad-right)"/>',"<defs>",'<linearGradient id="hfp-shader-loader-grad-left" x1="48.5676" y1="25" x2="44.7804" y2="71.9384" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>",'<linearGradient id="hfp-shader-loader-grad-right" x1="54.8282" y1="73.8392" x2="72.0989" y2="32.8932" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>","</defs>","</svg>"].join("");const r=document.createElement("div");r.className="hfp-shader-loader-title";const s=document.createElement("span");s.className="hfp-shader-loader-title-text",s.textContent=O[0],r.appendChild(s);const a=document.createElement("div");a.className="hfp-shader-loader-detail",a.textContent="Rendering animated scene samples for shader transitions.";const d=document.createElement("div");d.className="hfp-shader-loader-track",d.setAttribute("aria-hidden","true");const c=document.createElement("div");c.className="hfp-shader-loader-fill",d.appendChild(c);const m=document.createElement("div");m.className="hfp-shader-loader-progress";const u=f=>{const b=document.createElement("div");b.className="hfp-shader-loader-row";const _=document.createElement("span");_.className="hfp-shader-loader-label",_.textContent=f;const y=document.createElement("span");return y.className="hfp-shader-loader-value",b.appendChild(_),b.appendChild(y),m.appendChild(b),{row:b,label:_,value:y}},p=u("transition"),g=u("transition frame");return e.appendChild(i),e.appendChild(r),e.appendChild(a),e.appendChild(d),e.appendChild(m),n.appendChild(e),{root:n,fill:c,title:s,detail:a,transitionValue:p.value,frameLabel:g.label,frameValue:g.value,frameRow:g.row}}const Be=420;class We{constructor(t){h(this,"_el");h(this,"_hideTimeout",null);this._el=t}show(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-hiding"),this._el.root.classList.add("hfp-visible")}hide(){if(this._el.root.classList.contains("hfp-hiding")){this._hideTimeout||this._scheduleCleanup();return}this._el.root.classList.contains("hfp-visible")&&(this._el.root.classList.add("hfp-hiding"),this._el.root.classList.remove("hfp-visible"),this._scheduleCleanup())}reset(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-visible","hfp-hiding"),this._el.fill.style.transform="scaleX(0)",this._el.transitionValue.textContent="",this._el.frameValue.textContent="",this._el.frameRow.style.visibility="hidden"}update(t,e){if(e!=="player"){this.reset();return}if(t.ready||!t.loading){this.hide();return}const i=typeof t.progress=="number"&&Number.isFinite(t.progress)?t.progress:0,r=typeof t.total=="number"&&Number.isFinite(t.total)?t.total:0,s=r>0?Math.min(1,Math.max(0,i/r)):0,a=Math.min(O.length-1,Math.floor(s*O.length));this._el.title.textContent=O[a]||"Preparing scene transitions",this._el.detail.textContent=t.phase==="cached"?"Loading cached transition frames before playback.":t.phase==="finalizing"?"Uploading transition textures for smooth playback.":"Rendering animated scene samples for shader transitions.",this._el.fill.style.transform=`scaleX(${s})`,this._el.transitionValue.textContent=t.currentTransition!==void 0&&t.transitionTotal!==void 0?`${t.currentTransition}/${t.transitionTotal}`:r>0?`${i}/${r}`:"";const d=t.transitionFrame!==void 0&&t.transitionFrames!==void 0?`${t.transitionFrame}/${t.transitionFrames}`:"";this._el.frameLabel.textContent=t.phase==="cached"?"cached transition frames":t.phase==="finalizing"?"finalizing transition frames":"rendering transition frames",this._el.frameValue.textContent=d,this._el.frameRow.style.visibility=d?"visible":"hidden",this._el.root.setAttribute("aria-valuenow",String(Math.round(s*100))),this.show()}get hideTimeout(){return this._hideTimeout}destroy(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null)}_scheduleCleanup(){this._hideTimeout&&clearTimeout(this._hideTimeout),this._hideTimeout=setTimeout(()=>{this._el.root.classList.remove("hfp-hiding"),this._hideTimeout=null},Be)}}const Xe=.1,Ge=5;function V(n){return!Number.isFinite(n)||n<=0?1:Math.max(Xe,Math.min(Ge,n))}class Ye extends HTMLElement{constructor(){super();h(this,"shadow");h(this,"container");h(this,"iframe");h(this,"posterEl",null);h(this,"controlsApi",null);h(this,"resizeObserver");h(this,"shaderLoader");h(this,"probe");h(this,"_ready",!1);h(this,"_currentTime",0);h(this,"_duration",0);h(this,"_paused",!0);h(this,"_lastUpdateMs",0);h(this,"_volume",1);h(this,"_compositionWidth",1920);h(this,"_compositionHeight",1080);h(this,"_directTimelineAdapter",null);h(this,"_directTimelineClock");h(this,"_parentTickRaf",null);h(this,"_media");this.shadow=this.attachShadow({mode:"open"}),Te(this.shadow,ge),{container:this.container,iframe:this.iframe}=Ce(),this.shadow.appendChild(this.container);const e=qe();this.shadow.appendChild(e.root),this.shaderLoader=new We(e),this._media=new Oe({dispatchEvent:i=>this.dispatchEvent(i),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Se({onTimeUpdate:(i,r)=>{var s;this._currentTime=i,(s=this.controlsApi)==null||s.updateTime(i,r),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:i}}))},getLoop:()=>this.loop,restart:()=>{this.seek(0),this.play()},onPaused:()=>{var i;this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(i=this.controlsApi)==null||i.updatePlaying(!1),this.dispatchEvent(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new _e(this.iframe,{onReady:i=>this._onProbeReady(i),onError:i=>this.dispatchEvent(new CustomEvent("error",{detail:{message:i}}))}),this.addEventListener("click",i=>{Ee(i)||(this._paused?this.play():this.pause())}),this.resizeObserver=new ResizeObserver(()=>this._rescale()),this._onMessage=this._onMessage.bind(this),this._onIframeLoad=this._onIframeLoad.bind(this)}static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src",C,x]}connectedCallback(){this.resizeObserver.observe(this),window.addEventListener("message",this._onMessage),this.iframe.addEventListener("load",this._onIframeLoad),this.hasAttribute("controls")&&this._setupControls(),this.hasAttribute("poster")&&(this.posterEl=se(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=U(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&(this.iframe.src=F(this,this.getAttribute("src")))}disconnectedCallback(){var e;this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),this.iframe.removeEventListener("load",this._onIframeLoad),this.probe.stop(),this._directTimelineClock.stop(),this._stopParentTickClock(),this._directTimelineAdapter=null,this.shaderLoader.destroy(),this._media.destroy(),(e=this.controlsApi)==null||e.destroy()}attributeChangedCallback(e,i,r){var s,a,d,c,m;switch(e){case"src":r&&(this._ready=!1,this.iframe.src=F(this,r));break;case"srcdoc":this._ready=!1,r!==null?this.iframe.srcdoc=U(this,r):this.iframe.removeAttribute("srcdoc");break;case"width":this._compositionWidth=parseInt(r||"1920",10),this._rescale();break;case"height":this._compositionHeight=parseInt(r||"1080",10),this._rescale();break;case"controls":r!==null?this._setupControls():((s=this.controlsApi)==null||s.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=se(this.shadow,r,this.posterEl);break;case"playback-rate":{const u=V(parseFloat(r||"1"));this._media.updatePlaybackRate(u),this._sendControl("set-playback-rate",{playbackRate:u}),(d=(a=this._directTimelineAdapter)==null?void 0:a.timeScale)==null||d.call(a,u),(c=this.controlsApi)==null||c.updateSpeed(u),this.dispatchEvent(new Event("ratechange"));break}case"muted":this._handleMutedChange(r);break;case"audio-locked":this._applyAudioLock(r!==null);break;case"volume":{const u=Math.max(0,Math.min(1,parseFloat(r||"1")));this._volume=u,this._media.updateVolume(u),this._sendControl("set-volume",{volume:u}),(m=this.controlsApi)==null||m.updateVolume(u),this.dispatchEvent(new Event("volumechange"));break}case"audio-src":r&&this._media.setupFromUrl(r);break;case C:case x:this._reloadShaderOptions();break}}get iframeElement(){return this.iframe}play(){var i,r;(i=this.posterEl)==null||i.remove(),this.posterEl=null,this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;const e=this._tryDirectTimelinePlay();e||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter&&this._startParentTickClock()),this._media.audioOwner==="parent"&&this._media.playAll(),(r=this.controlsApi)==null||r.updatePlaying(!0),this.dispatchEvent(new Event("play")),e&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused)}pause(){var e;this._tryDirectTimelinePause()||this._sendControl("pause"),this._directTimelineClock.stop(),this._stopParentTickClock(),this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(e=this.controlsApi)==null||e.updatePlaying(!1),this.dispatchEvent(new Event("pause"))}seek(e){var i,r;!this._trySyncSeek(e)&&!this._tryDirectTimelineSeek(e)&&this._sendControl("seek",{frame:Math.round(e*30)}),this._directTimelineClock.stop(),this._stopParentTickClock(),this._currentTime=e,this._media.audioOwner==="parent"&&(this._media.pauseAll(),this._media.seekAll(e)),this._paused=!0,(i=this.controlsApi)==null||i.updatePlaying(!1),(r=this.controlsApi)==null||r.updateTime(this._currentTime,this._duration)}get currentTime(){return this._currentTime}set currentTime(e){this.seek(e)}get duration(){return this._duration}get paused(){return this._paused}get ready(){return this._ready}get playbackRate(){return V(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(V(e)))}get shaderCaptureScale(){return je(this)}set shaderCaptureScale(e){this.setAttribute(C,String(e))}get shaderLoading(){return S(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(x):this.setAttribute(x,e)}get muted(){return this.hasAttribute("muted")}set muted(e){e?this.setAttribute("muted",""):this.removeAttribute("muted")}get audioLocked(){return this.hasAttribute("audio-locked")}set audioLocked(e){e?this.setAttribute("audio-locked",""):this.removeAttribute("audio-locked")}_handleMutedChange(e){var i;if(e===null&&this.hasAttribute("audio-locked")){this.setAttribute("muted","");return}this._media.updateMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),(i=this.controlsApi)==null||i.updateMuted(e!==null),this.dispatchEvent(new Event("volumechange"))}_applyAudioLock(e){var i;e&&(this.muted=!0),(i=this.controlsApi)==null||i.setVolumeControlsHidden(e)}get volume(){return this._volume}set volume(e){this.setAttribute("volume",String(Math.max(0,Math.min(1,e))))}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}_sendControl(e,i={}){var r;try{(r=this.iframe.contentWindow)==null||r.postMessage({source:"hf-parent",type:"control",action:e,...i},"*")}catch{}}_reloadShaderOptions(){if(S(this)!=="player"&&this.shaderLoader.reset(),this.hasAttribute("srcdoc")){this.iframe.srcdoc=U(this,this.getAttribute("srcdoc")||"");return}this.hasAttribute("src")&&(this.iframe.src=F(this,this.getAttribute("src")||""))}_trySyncSeek(e){try{const i=this.iframe.contentWindow,r=i==null?void 0:i.__player;return typeof(r==null?void 0:r.seek)!="function"?!1:(r.seek.call(r,e),!0)}catch{return!1}}_withDirectTimeline(e){const i=this._directTimelineAdapter||this.probe.resolveDirectTimelineAdapter();if(!i)return!1;try{return e(i),this._directTimelineAdapter=i,!0}catch{return!1}}_tryDirectTimelineSeek(e){return this._withDirectTimeline(i=>{i.seek(e),i.pause()})}_tryDirectTimelinePlay(){return this._withDirectTimeline(e=>void e.play())}_tryDirectTimelinePause(){return this._withDirectTimeline(e=>void e.pause())}_startParentTickClock(){this._stopParentTickClock();const e=()=>{if(this._paused){this._parentTickRaf=null;return}this._sendControl("tick"),this._parentTickRaf=requestAnimationFrame(e)};this._parentTickRaf=requestAnimationFrame(e)}_stopParentTickClock(){this._parentTickRaf!==null&&(cancelAnimationFrame(this._parentTickRaf),this._parentTickRaf=null)}_onMessage(e){Fe(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs}),setPlaybackState:({currentTime:i,duration:r,paused:s,lastUpdateMs:a})=>{this._currentTime=i,this._duration=r,this._paused=s,this._lastUpdateMs=a},getShaderLoadingMode:()=>S(this),shaderLoader:this.shaderLoader,setCompositionSize:(i,r)=>{this._compositionWidth=i,this._compositionHeight=r,this._rescale()},sendControl:(i,r)=>this._sendControl(i,r),getIframeDoc:()=>this.iframe.contentDocument,updateControlsTime:(i,r)=>{var s;return(s=this.controlsApi)==null?void 0:s.updateTime(i,r)},updateControlsPlaying:i=>{var r;return(r=this.controlsApi)==null?void 0:r.updatePlaying(i)},dispatchEvent:i=>this.dispatchEvent(i),seek:i=>this.seek(i),play:()=>this.play(),getLoop:()=>this.loop,media:this._media})}_onProbeReady({duration:e,adapter:i,compositionSize:r}){var s;this._duration=e,this._directTimelineAdapter=i.kind==="direct-timeline"?i.timeline:null,this._ready=!0,(s=this.controlsApi)==null||s.updateTime(0,e),this.dispatchEvent(new CustomEvent("ready",{detail:{duration:e}})),r&&(this._compositionWidth=r.width,this._compositionHeight=r.height,this._rescale());try{const a=this.iframe.contentDocument;a&&this._media.setupFromIframe(a)}catch{}this.hasAttribute("autoplay")&&this.play()}_rescale(){ke(this,this.iframe,this._compositionWidth,this._compositionHeight)}_onIframeLoad(){this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this.shaderLoader.reset(),this._media.resetForIframeLoad(),this.probe.start()}_setupControls(){this.controlsApi||(this.controlsApi=Ae(this.shadow,this.muted,this._volume,this.getAttribute("speed-presets"),{onPlay:()=>this.play(),onPause:()=>this.pause(),onSeek:e=>this.seek(e*this._duration),onSpeedChange:e=>void(this.playbackRate=e),onMuteToggle:()=>void(this.muted=!this.muted),onVolumeChange:e=>void(this.volume=e)},this.audioLocked))}get _audioOwner(){return this._media.audioOwner}get _parentMedia(){return this._media.entries}_mirrorParentMediaTime(e,i){this._media.mirrorTime(e,i)}_promoteToParentProxy(){let e=null;try{e=this.iframe.contentDocument}catch{}this._media.promoteToParentProxy(e,(i,r)=>this._mirrorParentMediaTime(i,r)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}}customElements.get("hyperframes-player")||customElements.define("hyperframes-player",Ye);export{Ye as HyperframesPlayer,ye as SPEED_PRESETS,N as formatSpeed,ne as formatTime};
|
|
418
|
+
`,te='<svg width="24" height="24" viewBox="0 0 18 18" fill="currentColor"><polygon points="4,2 16,9 4,16"/></svg>',be='<svg width="24" height="24" viewBox="0 0 18 18" fill="currentColor"><rect x="3" y="2" width="4" height="14"/><rect x="11" y="2" width="4" height="14"/></svg>',ie='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/><path d="M14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></svg>',re='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/></svg>',ve='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z" opacity="0.3"/><line x1="18" y1="7" x2="14" y2="17" stroke="currentColor" stroke-width="2"/></svg>',ye=[.25,.5,1,1.5,2,4];function N(n){return Number.isInteger(n)?`${n}x`:`${n}x`}function ne(n){if(!Number.isFinite(n)||n<0)return"0:00";const t=Math.floor(n),e=Math.floor(t/60),i=t%60;return`${e}:${i.toString().padStart(2,"0")}`}function we(n,t,e={}){const i=e.speedPresets??ye,r=document.createElement("div");r.className="hfp-controls",r.addEventListener("click",o=>{o.stopPropagation()});const s=document.createElement("button");s.className="hfp-play-btn",s.type="button",s.innerHTML=te,s.setAttribute("aria-label","Play");const a=document.createElement("div");a.className="hfp-scrubber";const d=document.createElement("div");d.className="hfp-progress",d.style.width="0%",a.appendChild(d);const c=document.createElement("span");c.className="hfp-time",c.textContent="0:00 / 0:00";const m=document.createElement("div");m.className="hfp-speed-wrap";const u=document.createElement("button");u.className="hfp-speed-btn",u.type="button",u.textContent="1x",u.setAttribute("aria-label","Playback speed");const p=document.createElement("div");p.className="hfp-speed-menu",p.setAttribute("role","menu");for(const o of i){const l=document.createElement("button");l.className="hfp-speed-option",l.type="button",l.setAttribute("role","menuitem"),l.dataset.speed=String(o),l.textContent=N(o),o===1&&l.classList.add("hfp-active"),p.appendChild(l)}m.appendChild(p),m.appendChild(u);const g=document.createElement("div");g.className="hfp-volume-wrap";const f=document.createElement("button");f.className="hfp-mute-btn",f.type="button",f.innerHTML=ie,f.setAttribute("aria-label","Mute");const b=document.createElement("div");b.className="hfp-volume-slider-wrap";const _=document.createElement("div");_.className="hfp-volume-slider",_.setAttribute("role","slider"),_.setAttribute("aria-label","Volume"),_.setAttribute("aria-valuemin","0"),_.setAttribute("aria-valuemax","100"),_.setAttribute("aria-valuenow","100"),_.tabIndex=0;const y=document.createElement("div");y.className="hfp-volume-fill",y.style.width="100%",_.appendChild(y),b.appendChild(_),g.appendChild(b),g.appendChild(f),e.audioLocked&&(g.style.display="none"),r.appendChild(s),r.appendChild(a),r.appendChild(c),r.appendChild(g),r.appendChild(m),n.appendChild(r);let S=!1,A=!1,w=1,k=null;i.indexOf(1);const M=(o,l)=>o?ve:l===0||l<.5?re:ie;s.addEventListener("click",o=>{o.stopPropagation(),S?t.onPause():t.onPlay()}),f.addEventListener("click",o=>{o.stopPropagation(),t.onMuteToggle()});let E=!1;const P=o=>{const l=_.getBoundingClientRect(),v=Math.max(0,Math.min(1,(o-l.left)/l.width));w=v,y.style.width=`${v*100}%`,_.setAttribute("aria-valuenow",String(Math.round(v*100))),A&&v>0&&t.onMuteToggle(),f.innerHTML=M(A,v),t.onVolumeChange(v)};_.addEventListener("mousedown",o=>{o.stopPropagation(),E=!0,P(o.clientX)});const $=o=>{E&&P(o.clientX)},z=()=>{E=!1};document.addEventListener("mousemove",$),document.addEventListener("mouseup",z),_.addEventListener("touchstart",o=>{E=!0;const l=o.touches[0];l&&P(l.clientX)},{passive:!0});const j=o=>{if(E){const l=o.touches[0];l&&P(l.clientX)}},B=()=>{E=!1};document.addEventListener("touchmove",j,{passive:!0}),document.addEventListener("touchend",B);const q=.05;_.addEventListener("keydown",o=>{let l=w;if(o.key==="ArrowRight"||o.key==="ArrowUp")l=Math.min(1,w+q);else if(o.key==="ArrowLeft"||o.key==="ArrowDown")l=Math.max(0,w-q);else return;o.preventDefault(),o.stopPropagation(),w=l,y.style.width=`${l*100}%`,_.setAttribute("aria-valuenow",String(Math.round(l*100))),A&&l>0&&t.onMuteToggle(),f.innerHTML=M(A,l),t.onVolumeChange(l)});const W=o=>{for(const l of p.querySelectorAll(".hfp-speed-option"))l.classList.toggle("hfp-active",l.dataset.speed===String(o))};u.addEventListener("click",o=>{o.stopPropagation();const l=p.classList.toggle("hfp-open");u.setAttribute("aria-expanded",String(l))}),p.addEventListener("click",o=>{o.stopPropagation();const l=o.target.closest(".hfp-speed-option");if(!l)return;const v=parseFloat(l.dataset.speed);i.indexOf(v),u.textContent=N(v),W(v),p.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false"),t.onSpeedChange(v)});const X=()=>{p.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false")};document.addEventListener("click",X);const R=o=>{const l=a.getBoundingClientRect(),v=Math.max(0,Math.min(1,(o-l.left)/l.width));t.onSeek(v)};let T=!1;a.addEventListener("mousedown",o=>{o.stopPropagation(),T=!0,R(o.clientX)});const G=o=>{T&&R(o.clientX)},Y=()=>{T=!1};document.addEventListener("mousemove",G),document.addEventListener("mouseup",Y),a.addEventListener("touchstart",o=>{T=!0;const l=o.touches[0];l&&R(l.clientX)},{passive:!0});const Q=o=>{if(T){const l=o.touches[0];l&&R(l.clientX)}},J=()=>{T=!1};document.addEventListener("touchmove",Q,{passive:!0}),document.addEventListener("touchend",J);const K=()=>{k&&clearTimeout(k),k=setTimeout(()=>{S&&r.classList.add("hfp-hidden")},3e3)},Z=n instanceof ShadowRoot?n.host:n;return Z.addEventListener("mousemove",()=>{r.classList.remove("hfp-hidden"),K()}),Z.addEventListener("mouseleave",()=>{S&&r.classList.add("hfp-hidden")}),{updateTime(o,l){const v=l>0?Math.min(o,l):o,de=l>0?v/l*100:0;d.style.width=`${de}%`,c.textContent=`${ne(v)} / ${ne(l)}`},updatePlaying(o){S=o,s.innerHTML=o?be:te,s.setAttribute("aria-label",o?"Pause":"Play"),o?K():r.classList.remove("hfp-hidden")},updateSpeed(o){i.indexOf(o),u.textContent=N(o),W(o)},updateMuted(o){A=o,f.innerHTML=M(o,w),f.setAttribute("aria-label",o?"Unmute":"Mute")},updateVolume(o){w=o,y.style.width=`${o*100}%`,_.setAttribute("aria-valuenow",String(Math.round(o*100))),f.innerHTML=M(A,o)},setVolumeControlsHidden(o){g.style.display=o?"none":""},show(){r.style.display=""},hide(){r.style.display="none"},destroy(){document.removeEventListener("mousemove",G),document.removeEventListener("mouseup",Y),document.removeEventListener("touchmove",Q),document.removeEventListener("touchend",J),document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",j),document.removeEventListener("touchend",B),document.removeEventListener("click",X),k&&clearTimeout(k)}}}function Ae(n,t,e,i,r,s=!1){const a=i?i.split(",").map(Number).filter(m=>!isNaN(m)&&m>0):void 0,d={...a?{speedPresets:a}:{},audioLocked:s},c=we(n,r,d);return c.updateMuted(t),c.updateVolume(e),c}function se(n,t,e){return t?(e||(e=document.createElement("img"),e.className="hfp-poster",n.appendChild(e)),e.src=t,e):(e==null||e.remove(),null)}function Ee(n){return n.composedPath().some(t=>t instanceof HTMLElement&&t.classList.contains("hfp-controls"))}let I=null;function Te(n,t){if(typeof CSSStyleSheet<"u")try{I||(I=new CSSStyleSheet,I.replaceSync(t)),n.adoptedStyleSheets=[I];return}catch{}const e=document.createElement("style");e.textContent=t,n.appendChild(e)}function Ce(){const n=document.createElement("div");n.className="hfp-container";const t=document.createElement("iframe");return t.className="hfp-iframe",t.sandbox.add("allow-scripts","allow-same-origin"),t.allow="autoplay; fullscreen",t.referrerPolicy="no-referrer",t.title="HyperFrames Composition",n.appendChild(t),{container:n,iframe:t}}function ke(n,t,e,i){const r=n.offsetWidth,s=n.offsetHeight;if(r===0||s===0)return;const a=Math.min(r/e,s/i);t.style.width=`${e}px`,t.style.height=`${i}px`,t.style.transform=`translate(-50%, -50%) scale(${a})`}const xe=100;class Le{constructor(t){h(this,"_raf",null);h(this,"_lastUpdateMs",0);this._callbacks=t}start(t,e,i,r){this.stop();const s=()=>{if(r()){this._raf=null;return}let a;try{a=t.time()}catch{this._raf=null;return}const d=i();d>0&&(a=Math.min(a,d));const c=d>0&&a>=d,m=performance.now();if((m-this._lastUpdateMs>xe||c)&&(this._lastUpdateMs=m,this._callbacks.onTimeUpdate(a,d)),c){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{t.pause()}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(s)};this._raf=requestAnimationFrame(s)}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}}function Se(n){const t=Array.from(n.querySelectorAll("[data-composition-id]"));if(t.length===0)return n.body?[n.body]:[];const e=[];for(const i of t)Pe(i)||e.push(i);return Me(n),e}function Me(n){const t=n.body;if(!t||typeof console>"u"||typeof console.warn!="function")return;const e=t.querySelectorAll("audio[data-start], video[data-start]");if(e.length===0)return;const i=[];for(const r of e)r.closest("[data-composition-id]")||i.push(r);i.length!==0&&console.warn(`[hyperframes-player] selectMediaObserverTargets: composition hosts are present, but ${i.length} body-level timed media element(s) sit outside every [data-composition-id] subtree and will not be observed. Move them inside a composition host or the parent-frame proxy will never adopt them.`,i)}function Pe(n){let t=n.parentElement;for(;t;){if(t.hasAttribute("data-composition-id"))return!0;t=t.parentElement}return!1}const Re=.05,Ie=2;class Oe{constructor(t){h(this,"_entries",[]);h(this,"_mediaObserver");h(this,"_playbackErrorPosted",!1);h(this,"_audioOwner","runtime");h(this,"_dispatchEvent");h(this,"_getMuted");h(this,"_getVolume");h(this,"_getPlaybackRate");h(this,"_getCurrentTime");h(this,"_isPaused");this._dispatchEvent=t.dispatchEvent,this._getMuted=t.getMuted,this._getVolume=t.getVolume,this._getPlaybackRate=t.getPlaybackRate,this._getCurrentTime=t.getCurrentTime,this._isPaused=t.isPaused}get audioOwner(){return this._audioOwner}get entries(){return this._entries}get playbackErrorPosted(){return this._playbackErrorPosted}resetForIframeLoad(){this._playbackErrorPosted=!1;const t=this._audioOwner==="parent";this._audioOwner="runtime",this.pauseAll(),this.teardownObserver(),t&&this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"runtime",reason:"iframe-reload"}}))}destroy(){this.teardownObserver();for(const t of this._entries)t.el.pause(),t.el.src="";this._entries=[]}updateMuted(t){for(const e of this._entries)e.el.muted=t}updateVolume(t){for(const e of this._entries)e.el.volume=t}updatePlaybackRate(t){for(const e of this._entries)e.el.playbackRate=t}playAll(){for(const t of this._entries)t.el.src&&t.el.play().catch(e=>this._reportPlaybackError(e))}pauseAll(){for(const t of this._entries)t.el.pause()}seekAll(t){for(const e of this._entries){const i=t-e.start;i>=0&&i<e.duration&&(e.el.currentTime=i)}}mirrorTime(t,e){const i=(e==null?void 0:e.force)===!0;for(const r of this._entries){const s=t-r.start;if(s<0||s>=r.duration){r.driftSamples=0;continue}Math.abs(r.el.currentTime-s)>Re?(r.driftSamples+=1,(i||r.driftSamples>=Ie)&&(r.el.currentTime=s,r.driftSamples=0)):r.driftSamples=0}}promoteToParentProxy(t,e){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",t)for(const r of t.querySelectorAll("video, audio"))r.muted=!0;const i=this._getCurrentTime();e?e(i,{force:!0}):this.mirrorTime(i,{force:!0}),this._isPaused()||this.playAll(),this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"parent",reason:"autoplay-blocked"}}))}setupFromIframe(t){const e=t.querySelectorAll("audio[data-start], video[data-start]");for(const i of e)this._adoptIframeMedia(i);this._observeDynamicMedia(t)}setupFromUrl(t){this._createEntry(t,"audio",0,1/0)}teardownObserver(){var t;(t=this._mediaObserver)==null||t.disconnect(),this._mediaObserver=void 0}_reportPlaybackError(t){this._playbackErrorPosted||(this._playbackErrorPosted=!0,this._dispatchEvent(new CustomEvent("playbackerror",{detail:{source:"parent-proxy",error:t}})))}_createEntry(t,e,i,r){if(this._entries.some(c=>c.el.src===t))return null;const s=e==="video"?document.createElement("video"):new Audio;s.preload="auto",s.src=t,s.load(),s.muted=this._getMuted(),s.volume=this._getVolume();const a=this._getPlaybackRate();a!==1&&(s.playbackRate=a);const d={el:s,start:i,duration:r,driftSamples:0};return this._entries.push(d),d}_adoptIframeMedia(t){var c;if(t.preload==="metadata"||t.preload==="none")return;const e=t.getAttribute("src")||((c=t.querySelector("source"))==null?void 0:c.getAttribute("src"));if(!e)return;const i=new URL(e,t.ownerDocument.baseURI).href,r=parseFloat(t.getAttribute("data-start")||"0"),s=parseFloat(t.getAttribute("data-duration")||"Infinity"),a=t.tagName==="VIDEO"?"video":"audio",d=this._createEntry(i,a,r,s);d&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),!this._isPaused()&&d.el.src&&d.el.play().catch(m=>this._reportPlaybackError(m)))}_detachIframeMedia(t){var a;const e=t.getAttribute("src")||((a=t.querySelector("source"))==null?void 0:a.getAttribute("src"));if(!e)return;const i=new URL(e,t.ownerDocument.baseURI).href,r=this._entries.findIndex(d=>d.el.src===i);if(r===-1)return;const s=this._entries[r];s.el.pause(),s.el.src="",this._entries.splice(r,1)}_observeDynamicMedia(t){if(this.teardownObserver(),typeof MutationObserver>"u"||!t.body)return;const e=new MutationObserver(s=>{var a,d,c,m;for(const u of s){if(u.type==="attributes"&&u.attributeName==="preload"){const p=u.target;p instanceof HTMLMediaElement&&p.matches("audio[data-start], video[data-start]")&&p.preload==="auto"&&this._adoptIframeMedia(p);continue}for(const p of u.addedNodes){if(!(p instanceof Element))continue;const g=[];(a=p.matches)!=null&&a.call(p,"audio[data-start], video[data-start]")&&g.push(p);const f=(d=p.querySelectorAll)==null?void 0:d.call(p,"audio[data-start], video[data-start]");if(f)for(const b of f)g.push(b);for(const b of g)this._adoptIframeMedia(b)}for(const p of u.removedNodes){if(!(p instanceof Element))continue;const g=[];(c=p.matches)!=null&&c.call(p,"audio[data-start], video[data-start]")&&g.push(p);const f=(m=p.querySelectorAll)==null?void 0:m.call(p,"audio[data-start], video[data-start]");if(f)for(const b of f)g.push(b);for(const b of g)this._detachIframeMedia(b)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload"]},r=Se(t);for(const s of r)e.observe(s,i);this._mediaObserver=e}}const De=100;function Ne(n,t,e,i){const r=(n.frame??0)/t,s=e.duration>0?Math.min(r,e.duration):r,a=!e.paused,d=!n.isPlaying,c=e.duration>0&&s>=e.duration&&(a||n.isPlaying);if(c&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(0),i.play(),{...e,currentTime:s,paused:!1};const m={...e,currentTime:s,paused:d};i.media.audioOwner==="parent"&&(a&&d?i.media.pauseAll():!a&&!d&&i.media.playAll(),i.media.mirrorTime(s));const u=performance.now(),p=d!==e.paused;return(u-e.lastUpdateMs>De||p)&&(m.lastUpdateMs=u,i.updateControlsTime(s,e.duration),i.updateControlsPlaying(!d),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:s}}))),c&&(i.media.audioOwner==="parent"&&i.media.pauseAll(),m.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),m}const oe=30;function Fe(n,t,e){if(n.source!==t)return;const i=n.data;if(!(!i||i.source!=="hf-preview")){if(i.type==="shader-transition-state"){const r=i.state&&typeof i.state=="object"?i.state:{};e.shaderLoader.update(r,e.getShaderLoadingMode()),e.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:i.compositionId,state:r}}));return}if(i.type==="ready"){e.onRuntimeReady();return}if(i.type==="state"){e.setPlaybackState(Ne({frame:i.frame??0,isPlaying:!!i.isPlaying},oe,e.getPlaybackState(),e));return}if(i.type==="media-autoplay-blocked"){let r=null;try{r=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(r,(s,a)=>e.media.mirrorTime(s,a)),e.sendControl("set-media-output-muted",{muted:!0});return}if(i.type==="timeline"&&i.durationInFrames>0){if(Number.isFinite(i.durationInFrames)){const r=e.getPlaybackState(),s=i.durationInFrames/oe;e.setPlaybackState({...r,duration:s}),e.updateControlsTime(r.currentTime,s)}return}i.type==="stage-size"&&i.width>0&&i.height>0&&e.setCompositionSize(i.width,i.height)}}const C="shader-capture-scale",x="shader-loading",Ue="__hf_shader_capture_scale",He="__hf_shader_loading",O=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function V(n){if(n===null)return null;const t=Number(n);return!Number.isFinite(t)||t<=0?null:String(Math.min(1,Math.max(.25,t)))}function Ve(n){if(n===null||n.trim()==="")return"composition";const t=n.trim().toLowerCase();return t==="none"||t==="false"||t==="0"||t==="off"?"none":t==="player"||t==="true"||t==="1"||t==="on"?"player":"composition"}function ae(n,t,e){e===null?n.delete(t):n.set(t,e)}function $e(n,t,e){const i=n.indexOf("#"),r=i>=0?n.slice(0,i):n,s=i>=0?n.slice(i):"",a=r.indexOf("?"),d=a>=0?r.slice(0,a):r,c=a>=0?r.slice(a+1):"",m=new URLSearchParams(c);ae(m,Ue,t),ae(m,He,e==="composition"?null:e);const u=m.toString();return`${d}${u?`?${u}`:""}${s}`}function ze(n,t,e){if(t===null&&e==="composition")return n;const i=[];t!==null&&i.push(`window.__HF_SHADER_CAPTURE_SCALE=${JSON.stringify(t)};`),e!=="composition"&&i.push(`window.__HF_SHADER_LOADING=${JSON.stringify(e)};`);const r=`<script data-hyperframes-player-shader-options>${i.join("")}<\/script>`;return/<head\b[^>]*>/i.test(n)?n.replace(/<head\b[^>]*>/i,s=>`${s}${r}`):/<html\b[^>]*>/i.test(n)?n.replace(/<html\b[^>]*>/i,s=>`${s}${r}`):`${r}${n}`}function L(n){return Ve(n.getAttribute(x))}function je(n){return Number(V(n.getAttribute(C))??"1")}function F(n,t){return $e(t,V(n.getAttribute(C)),L(n))}function U(n,t){return ze(t,V(n.getAttribute(C)),L(n))}function Be(){const n=document.createElement("div");n.className="hfp-shader-loader",n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-label","Preparing scene transitions"),n.setAttribute("data-hyperframes-ignore",""),n.draggable=!1;const t=f=>{f.preventDefault(),f.stopPropagation()};for(const f of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])n.addEventListener(f,t,{capture:!0});const e=document.createElement("div");e.className="hfp-shader-loader-panel",e.draggable=!1;const i=document.createElement("div");i.className="hfp-shader-loader-mark",i.draggable=!1,i.innerHTML=['<svg width="78" height="78" viewBox="0 0 100 100" fill="none" aria-hidden="true" draggable="false">','<path d="M10.1851 57.8021L33.1145 73.8313C36.2202 75.9978 41.5173 73.5433 42.4816 69.4984L51.7611 30.4271C52.7253 26.3822 48.5802 23.9277 44.4602 26.0942L13.917 42.1235C6.96677 45.7676 4.97564 54.1579 10.1851 57.8021Z" fill="url(#hfp-shader-loader-grad-left)"/>','<path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z" fill="url(#hfp-shader-loader-grad-right)"/>',"<defs>",'<linearGradient id="hfp-shader-loader-grad-left" x1="48.5676" y1="25" x2="44.7804" y2="71.9384" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>",'<linearGradient id="hfp-shader-loader-grad-right" x1="54.8282" y1="73.8392" x2="72.0989" y2="32.8932" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>","</defs>","</svg>"].join("");const r=document.createElement("div");r.className="hfp-shader-loader-title";const s=document.createElement("span");s.className="hfp-shader-loader-title-text",s.textContent=O[0],r.appendChild(s);const a=document.createElement("div");a.className="hfp-shader-loader-detail",a.textContent="Rendering animated scene samples for shader transitions.";const d=document.createElement("div");d.className="hfp-shader-loader-track",d.setAttribute("aria-hidden","true");const c=document.createElement("div");c.className="hfp-shader-loader-fill",d.appendChild(c);const m=document.createElement("div");m.className="hfp-shader-loader-progress";const u=f=>{const b=document.createElement("div");b.className="hfp-shader-loader-row";const _=document.createElement("span");_.className="hfp-shader-loader-label",_.textContent=f;const y=document.createElement("span");return y.className="hfp-shader-loader-value",b.appendChild(_),b.appendChild(y),m.appendChild(b),{row:b,label:_,value:y}},p=u("transition"),g=u("transition frame");return e.appendChild(i),e.appendChild(r),e.appendChild(a),e.appendChild(d),e.appendChild(m),n.appendChild(e),{root:n,fill:c,title:s,detail:a,transitionValue:p.value,frameLabel:g.label,frameValue:g.value,frameRow:g.row}}const qe=420;class We{constructor(t){h(this,"_el");h(this,"_hideTimeout",null);this._el=t}show(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-hiding"),this._el.root.classList.add("hfp-visible")}hide(){if(this._el.root.classList.contains("hfp-hiding")){this._hideTimeout||this._scheduleCleanup();return}this._el.root.classList.contains("hfp-visible")&&(this._el.root.classList.add("hfp-hiding"),this._el.root.classList.remove("hfp-visible"),this._scheduleCleanup())}reset(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-visible","hfp-hiding"),this._el.fill.style.transform="scaleX(0)",this._el.transitionValue.textContent="",this._el.frameValue.textContent="",this._el.frameRow.style.visibility="hidden"}update(t,e){if(e!=="player"){this.reset();return}if(t.ready||!t.loading){this.hide();return}const i=typeof t.progress=="number"&&Number.isFinite(t.progress)?t.progress:0,r=typeof t.total=="number"&&Number.isFinite(t.total)?t.total:0,s=r>0?Math.min(1,Math.max(0,i/r)):0,a=Math.min(O.length-1,Math.floor(s*O.length));this._el.title.textContent=O[a]||"Preparing scene transitions",this._el.detail.textContent=t.phase==="cached"?"Loading cached transition frames before playback.":t.phase==="finalizing"?"Uploading transition textures for smooth playback.":"Rendering animated scene samples for shader transitions.",this._el.fill.style.transform=`scaleX(${s})`,this._el.transitionValue.textContent=t.currentTransition!==void 0&&t.transitionTotal!==void 0?`${t.currentTransition}/${t.transitionTotal}`:r>0?`${i}/${r}`:"";const d=t.transitionFrame!==void 0&&t.transitionFrames!==void 0?`${t.transitionFrame}/${t.transitionFrames}`:"";this._el.frameLabel.textContent=t.phase==="cached"?"cached transition frames":t.phase==="finalizing"?"finalizing transition frames":"rendering transition frames",this._el.frameValue.textContent=d,this._el.frameRow.style.visibility=d?"visible":"hidden",this._el.root.setAttribute("aria-valuenow",String(Math.round(s*100))),this.show()}get hideTimeout(){return this._hideTimeout}destroy(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null)}_scheduleCleanup(){this._hideTimeout&&clearTimeout(this._hideTimeout),this._hideTimeout=setTimeout(()=>{this._el.root.classList.remove("hfp-hiding"),this._hideTimeout=null},qe)}}const Xe=.1,Ge=5;function H(n){return!Number.isFinite(n)||n<=0?1:Math.max(Xe,Math.min(Ge,n))}class Ye extends HTMLElement{constructor(){super();h(this,"shadow");h(this,"container");h(this,"iframe");h(this,"posterEl",null);h(this,"controlsApi",null);h(this,"resizeObserver");h(this,"shaderLoader");h(this,"probe");h(this,"_ready",!1);h(this,"_currentTime",0);h(this,"_duration",0);h(this,"_paused",!0);h(this,"_lastUpdateMs",0);h(this,"_volume",1);h(this,"_compositionWidth",1920);h(this,"_compositionHeight",1080);h(this,"_directTimelineAdapter",null);h(this,"_directTimelineClock");h(this,"_parentTickRaf",null);h(this,"_media");this.shadow=this.attachShadow({mode:"open"}),Te(this.shadow,ge),{container:this.container,iframe:this.iframe}=Ce(),this.shadow.appendChild(this.container);const e=Be();this.shadow.appendChild(e.root),this.shaderLoader=new We(e),this._media=new Oe({dispatchEvent:i=>this.dispatchEvent(i),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Le({onTimeUpdate:(i,r)=>{var s;this._currentTime=i,(s=this.controlsApi)==null||s.updateTime(i,r),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:i}}))},getLoop:()=>this.loop,restart:()=>{this.seek(0),this.play()},onPaused:()=>{var i;this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(i=this.controlsApi)==null||i.updatePlaying(!1),this.dispatchEvent(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new _e(this.iframe,{onReady:i=>this._onProbeReady(i),onError:i=>this.dispatchEvent(new CustomEvent("error",{detail:{message:i}}))}),this.addEventListener("click",i=>{Ee(i)||(this._paused?this.play():this.pause())}),this.resizeObserver=new ResizeObserver(()=>this._rescale()),this._onMessage=this._onMessage.bind(this),this._onIframeLoad=this._onIframeLoad.bind(this)}static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src",C,x]}connectedCallback(){this.resizeObserver.observe(this),window.addEventListener("message",this._onMessage),this.iframe.addEventListener("load",this._onIframeLoad),this.hasAttribute("controls")&&this._setupControls(),this.hasAttribute("poster")&&(this.posterEl=se(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=U(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&(this.iframe.src=F(this,this.getAttribute("src"))),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){var e;this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),this.iframe.removeEventListener("load",this._onIframeLoad),this.probe.stop(),this._directTimelineClock.stop(),this._stopParentTickClock(),this._directTimelineAdapter=null,this.shaderLoader.destroy(),this._media.destroy(),(e=this.controlsApi)==null||e.destroy()}attributeChangedCallback(e,i,r){var s,a,d,c,m;switch(e){case"src":r&&(this._ready=!1,this.iframe.src=F(this,r));break;case"srcdoc":this._ready=!1,r!==null?this.iframe.srcdoc=U(this,r):this.iframe.removeAttribute("srcdoc");break;case"width":this._compositionWidth=parseInt(r||"1920",10),this._rescale();break;case"height":this._compositionHeight=parseInt(r||"1080",10),this._rescale();break;case"controls":r!==null?this._setupControls():((s=this.controlsApi)==null||s.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=se(this.shadow,r,this.posterEl);break;case"playback-rate":{const u=H(parseFloat(r||"1"));this._media.updatePlaybackRate(u),this._sendControl("set-playback-rate",{playbackRate:u}),(d=(a=this._directTimelineAdapter)==null?void 0:a.timeScale)==null||d.call(a,u),(c=this.controlsApi)==null||c.updateSpeed(u),this.dispatchEvent(new Event("ratechange"));break}case"muted":this._handleMutedChange(r);break;case"audio-locked":this._applyAudioLock(r!==null);break;case"volume":{const u=Math.max(0,Math.min(1,parseFloat(r||"1")));this._volume=u,this._media.updateVolume(u),this._sendControl("set-volume",{volume:u}),(m=this.controlsApi)==null||m.updateVolume(u),this.dispatchEvent(new Event("volumechange"));break}case"audio-src":r&&this._media.setupFromUrl(r);break;case C:case x:this._reloadShaderOptions();break}}get iframeElement(){return this.iframe}play(){var i,r;(i=this.posterEl)==null||i.remove(),this.posterEl=null,this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;const e=this._tryDirectTimelinePlay();e||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter&&this._startParentTickClock()),this._media.audioOwner==="parent"&&this._media.playAll(),(r=this.controlsApi)==null||r.updatePlaying(!0),this.dispatchEvent(new Event("play")),e&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused)}pause(){var e;this._tryDirectTimelinePause()||this._sendControl("pause"),this._directTimelineClock.stop(),this._stopParentTickClock(),this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(e=this.controlsApi)==null||e.updatePlaying(!1),this.dispatchEvent(new Event("pause"))}seek(e){var i,r;!this._trySyncSeek(e)&&!this._tryDirectTimelineSeek(e)&&this._sendControl("seek",{frame:Math.round(e*30)}),this._directTimelineClock.stop(),this._stopParentTickClock(),this._currentTime=e,this._media.audioOwner==="parent"&&(this._media.pauseAll(),this._media.seekAll(e)),this._paused=!0,(i=this.controlsApi)==null||i.updatePlaying(!1),(r=this.controlsApi)==null||r.updateTime(this._currentTime,this._duration)}get currentTime(){return this._currentTime}set currentTime(e){this.seek(e)}get duration(){return this._duration}get paused(){return this._paused}get ready(){return this._ready}get playbackRate(){return H(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(H(e)))}get shaderCaptureScale(){return je(this)}set shaderCaptureScale(e){this.setAttribute(C,String(e))}get shaderLoading(){return L(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(x):this.setAttribute(x,e)}get muted(){return this.hasAttribute("muted")}set muted(e){e?this.setAttribute("muted",""):this.removeAttribute("muted")}get audioLocked(){return this.hasAttribute("audio-locked")}set audioLocked(e){e?this.setAttribute("audio-locked",""):this.removeAttribute("audio-locked")}_isLockedHostEnvironment(){if(typeof navigator>"u")return!1;const e=navigator.userAgent||"";return/\bClaude\/\d/.test(e)&&/\bElectron\b/.test(e)}_isAudioLocked(){return this.hasAttribute("audio-locked")||this._isLockedHostEnvironment()}_handleMutedChange(e){var i;if(e===null&&this._isAudioLocked()){this.setAttribute("muted","");return}this._media.updateMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),(i=this.controlsApi)==null||i.updateMuted(e!==null),this.dispatchEvent(new Event("volumechange"))}_applyAudioLock(e){var i;e&&(this.muted=!0),(i=this.controlsApi)==null||i.setVolumeControlsHidden(e)}get volume(){return this._volume}set volume(e){this.setAttribute("volume",String(Math.max(0,Math.min(1,e))))}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}_sendControl(e,i={}){var r;try{(r=this.iframe.contentWindow)==null||r.postMessage({source:"hf-parent",type:"control",action:e,...i},"*")}catch{}}_replayBridgeState(){this._sendControl("set-muted",{muted:this.muted}),this._sendControl("set-volume",{volume:this._volume}),this._sendControl("set-playback-rate",{playbackRate:this.playbackRate})}_reloadShaderOptions(){if(L(this)!=="player"&&this.shaderLoader.reset(),this.hasAttribute("srcdoc")){this.iframe.srcdoc=U(this,this.getAttribute("srcdoc")||"");return}this.hasAttribute("src")&&(this.iframe.src=F(this,this.getAttribute("src")||""))}_trySyncSeek(e){try{const i=this.iframe.contentWindow,r=i==null?void 0:i.__player;return typeof(r==null?void 0:r.seek)!="function"?!1:(r.seek.call(r,e),!0)}catch{return!1}}_withDirectTimeline(e){const i=this._directTimelineAdapter||this.probe.resolveDirectTimelineAdapter();if(!i)return!1;try{return e(i),this._directTimelineAdapter=i,!0}catch{return!1}}_tryDirectTimelineSeek(e){return this._withDirectTimeline(i=>{i.seek(e),i.pause()})}_tryDirectTimelinePlay(){return this._withDirectTimeline(e=>void e.play())}_tryDirectTimelinePause(){return this._withDirectTimeline(e=>void e.pause())}_startParentTickClock(){this._stopParentTickClock();const e=()=>{if(this._paused){this._parentTickRaf=null;return}this._sendControl("tick"),this._parentTickRaf=requestAnimationFrame(e)};this._parentTickRaf=requestAnimationFrame(e)}_stopParentTickClock(){this._parentTickRaf!==null&&(cancelAnimationFrame(this._parentTickRaf),this._parentTickRaf=null)}_onMessage(e){Fe(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs}),setPlaybackState:({currentTime:i,duration:r,paused:s,lastUpdateMs:a})=>{this._currentTime=i,this._duration=r,this._paused=s,this._lastUpdateMs=a},getShaderLoadingMode:()=>L(this),shaderLoader:this.shaderLoader,setCompositionSize:(i,r)=>{this._compositionWidth=i,this._compositionHeight=r,this._rescale()},sendControl:(i,r)=>this._sendControl(i,r),getIframeDoc:()=>this.iframe.contentDocument,onRuntimeReady:()=>this._replayBridgeState(),updateControlsTime:(i,r)=>{var s;return(s=this.controlsApi)==null?void 0:s.updateTime(i,r)},updateControlsPlaying:i=>{var r;return(r=this.controlsApi)==null?void 0:r.updatePlaying(i)},dispatchEvent:i=>this.dispatchEvent(i),seek:i=>this.seek(i),play:()=>this.play(),getLoop:()=>this.loop,media:this._media})}_onProbeReady({duration:e,adapter:i,compositionSize:r}){var s;this._duration=e,this._directTimelineAdapter=i.kind==="direct-timeline"?i.timeline:null,this._ready=!0,(s=this.controlsApi)==null||s.updateTime(0,e),this.dispatchEvent(new CustomEvent("ready",{detail:{duration:e}})),r&&(this._compositionWidth=r.width,this._compositionHeight=r.height,this._rescale());try{const a=this.iframe.contentDocument;a&&this._media.setupFromIframe(a)}catch{}this.hasAttribute("autoplay")&&this.play()}_rescale(){ke(this,this.iframe,this._compositionWidth,this._compositionHeight)}_onIframeLoad(){this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this.shaderLoader.reset(),this._media.resetForIframeLoad(),this.probe.start()}_setupControls(){this.controlsApi||(this.controlsApi=Ae(this.shadow,this.muted,this._volume,this.getAttribute("speed-presets"),{onPlay:()=>this.play(),onPause:()=>this.pause(),onSeek:e=>this.seek(e*this._duration),onSpeedChange:e=>void(this.playbackRate=e),onMuteToggle:()=>void(this.muted=!this.muted),onVolumeChange:e=>void(this.volume=e)},this._isAudioLocked()))}get _audioOwner(){return this._media.audioOwner}get _parentMedia(){return this._media.entries}_mirrorParentMediaTime(e,i){this._media.mirrorTime(e,i)}_promoteToParentProxy(){let e=null;try{e=this.iframe.contentDocument}catch{}this._media.promoteToParentProxy(e,(i,r)=>this._mirrorParentMediaTime(i,r)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}}customElements.get("hyperframes-player")||customElements.define("hyperframes-player",Ye);export{Ye as HyperframesPlayer,ye as SPEED_PRESETS,N as formatSpeed,ne as formatTime};
|