@phin-tech/dottie 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compile.js +1 -1
- package/dist/dottie-compile.mjs +2 -2
- package/dist/dottie-player.js +2 -2
- package/dist/dottie-player.min.js +2 -2
- package/dist/dottie.js +2 -2
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/compile.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! dottie.js 0.
|
|
1
|
+
/*! dottie.js 0.5.0 | Apache-2.0 | https://github.com/phin-tech/dottie */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
package/dist/dottie-compile.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/*! dottie.js 0.
|
|
2
|
+
/*! dottie.js 0.5.0 | Apache-2.0 | https://github.com/phin-tech/dottie */
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
5
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -393,7 +393,7 @@ function compile(source2, runtime, options2 = {}) {
|
|
|
393
393
|
}
|
|
394
394
|
|
|
395
395
|
// src/index.ts
|
|
396
|
-
var VERSION = "0.
|
|
396
|
+
var VERSION = "0.5.0";
|
|
397
397
|
|
|
398
398
|
// src/cli.ts
|
|
399
399
|
var usage = `dottie-compile ${VERSION}: a Dottie drawing as one script that plays it on any page.
|
package/dist/dottie-player.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! dottie.js 0.
|
|
1
|
+
/*! dottie.js 0.5.0 | Apache-2.0 | https://github.com/phin-tech/dottie */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value2) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
|
|
4
4
|
var __export = (target, all) => {
|
|
@@ -3079,7 +3079,7 @@ function render(source, options = {}) {
|
|
|
3079
3079
|
function isFile(v) {
|
|
3080
3080
|
return typeof v === "object" && v !== null && Array.isArray(v.pages) && Array.isArray(v.warnings);
|
|
3081
3081
|
}
|
|
3082
|
-
var VERSION = "0.
|
|
3082
|
+
var VERSION = "0.5.0";
|
|
3083
3083
|
|
|
3084
3084
|
// src/player-entry.ts
|
|
3085
3085
|
definePlayer();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! dottie.js 0.
|
|
1
|
+
/*! dottie.js 0.5.0 | Apache-2.0 | https://github.com/phin-tech/dottie */
|
|
2
2
|
"use strict";(()=>{var He=Object.defineProperty;var Zn=(t,e,n)=>e in t?He(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Jn=(t,e)=>{for(var n in e)He(t,n,{get:e[n],enumerable:!0})};var k=(t,e,n)=>Zn(t,typeof e!="symbol"?e+"":e,n);var Fe={};Jn(Fe,{BOIL_DRAWINGS:()=>he,DottieFormatError:()=>q,DottiePlayer:()=>wt,KINDS:()=>je,KNOWN_FIELDS:()=>_e,MAX_DURATION:()=>mt,MAX_MARCH:()=>ce,Playback:()=>Vt,SUPPORTED_VERSION:()=>or,VERSION:()=>ir,black:()=>st,bounds:()=>rt,cameraView:()=>bt,clampFPS:()=>ft,clampMarch:()=>qe,clampTime:()=>ot,clear:()=>Ue,cloneElement:()=>B,definePlayer:()=>oe,elementIndex:()=>ni,frameTimes:()=>ne,inkOnDark:()=>Ke,inspect:()=>Qn,inspectFrame:()=>Ge,inspectPage:()=>Be,isAutomaticInk:()=>me,luminance:()=>pt,orderedElements:()=>At,pageIndex:()=>Dt,parseDottie:()=>Rt,plan:()=>kt,posterTime:()=>it,render:()=>er,repeatIsValid:()=>Ct,resolved:()=>W,sameColor:()=>dt,sampleTimes:()=>Ce,sceneAt:()=>qn,stableSortBy:()=>zt,still:()=>_n,svg:()=>re,svgParts:()=>Lt,themeNamed:()=>ht,themes:()=>De,transientElements:()=>Un,withRoughness:()=>Wt});var or=2,je=["rectangle","ellipse","diamond","text","connector","freehand","path","note","image"],ti=["linear","easeIn","easeOut","easeInOut","hold","spring","bounce","elastic"],_e={file:["version","pages","images"],page:["id","name","layers","elements","theme","guidesX","guidesY","guidesLocked","timeline"],layer:["id","name","visible","locked"],rgba:["r","g","b","a"],style:["stroke","fill","fillStyle","strokeWidth","dash","roughness","bowing","fontSize","gridSize","opacity","dashOffset"],element:["id","kind","x","y","width","height","style","seed","layerID","text","connector","groupID","points","path","subpaths","evenOdd","rotation","link","anchor","image","reveal"],strokePoint:["x","y"],subpath:["closed","coords"],inlineImage:["data","format"],endpoint:["elementID","port","x","y"],connector:["start","end","routing","startHead","endHead"],timeline:["fps","duration","boil","settle","poster","tracks","camera","markers"],track:["element","keys","boil","follow","repeats","march"],keyframe:["t","x","y","width","height","rotation","strokeWidth","stroke","fill","visible","reveal","opacity","ease"],follow:["path","start","end","ease","reverse","orient","laps"],repeat:["start","end","count"],cameraKey:["t","x","y","width","height","ease"],marker:["t","name"]},mt=3600,ce=1e4,qe=t=>t===void 0||!Number.isFinite(t)||t===0?null:Math.min(Math.max(t,-ce),ce),he=3,st={r:.12,g:.12,b:.13,a:1},Ue={r:0,g:0,b:0,a:0},Ke={r:.93,g:.93,b:.94,a:1},q=class extends Error{},E=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),w=t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,$=t=>typeof t=="string"?t:void 0,j=t=>typeof t=="boolean"?t:void 0,_=t=>typeof t=="string"?t.toUpperCase():void 0;function ot(t){return Number.isFinite(t)?Math.min(Math.max(t,0),mt):t===1/0?mt:0}function ft(t){return Number.isFinite(t)?Math.min(Math.max(t,1),60):12}function Ot(t){if(!E(t))return;let e=w(t.r),n=w(t.g),i=w(t.b);if(!(e===void 0||n===void 0||i===void 0))return{r:e,g:n,b:i,a:w(t.a)??1}}var ue=class{constructor(){k(this,"warnings",[]);k(this,"seen",new Set)}warn(e){this.seen.has(e)||(this.seen.add(e),this.warnings.push(e))}fields(e,n){let i=_e[n];for(let r of Object.keys(e))i.includes(r)||this.warn(`Unknown field "${r}" on ${n}, ignored`)}style(e){let n=E(e)?e:{};this.fields(n,"style");let i=$(n.fillStyle)??"solid",r=$(n.dash)??"solid";return["solid","hachure","crossHatch","grid"].includes(i)||this.warn(`Unknown fill style "${i}", drawn solid`),["solid","dashed","dotted"].includes(r)||this.warn(`Unknown dash "${r}", drawn solid`),{stroke:Ot(n.stroke)??{...st},fill:Ot(n.fill)??{...Ue},fillStyle:["solid","hachure","crossHatch","grid"].includes(i)?i:"solid",strokeWidth:w(n.strokeWidth)??2,dash:["solid","dashed","dotted"].includes(r)?r:"solid",roughness:w(n.roughness)??1,bowing:w(n.bowing)??1,fontSize:w(n.fontSize)??18,gridSize:w(n.gridSize)??null,opacity:w(n.opacity)??null,dashOffset:w(n.dashOffset)??null}}endpoint(e){let n=E(e)?e:{},i=$(n.port);return{elementID:_(n.elementID)??null,port:i&&["top","right","bottom","left"].includes(i)?i:null,x:w(n.x)??0,y:w(n.y)??0}}connector(e){if(!E(e))return null;this.fields(e,"connector");let n=(r,o)=>{let s=$(r);return s&&["none","arrow","triangle","dot","bar"].includes(s)?s:o},i=$(e.routing);return{start:this.endpoint(e.start),end:this.endpoint(e.end),routing:i&&["straight","curved","elbow"].includes(i)?i:"straight",startHead:n(e.startHead,"none"),endHead:n(e.endHead,"arrow")}}image(e,n){if(!E(e))return null;let i=$(e.ref);if(i!==void 0)return n[i]??{data:"",format:"png"};let r=$(e.data);return r===void 0?null:this.picture(r,$(e.format))}picture(e,n){return ei.test(e)?{data:e.replace(/\s+/g,""),format:n==="jpeg"?"jpeg":"png"}:(this.warn("Skipped a picture whose data isn't base64"),{data:"",format:"png"})}element(e,n){if(!E(e))return null;this.fields(e,"element");let i=_(e.id),r=$(e.kind),o=_(e.layerID);if(!i||!r||!o)return this.warn("Skipped an element without an id, kind or layer"),null;je.includes(r)||this.warn(`Unknown element kind "${r}", drawn as a placeholder`);let s=Array.isArray(e.subpaths)?e.subpaths.filter(E).map(l=>({closed:j(l.closed)??!1,coords:Array.isArray(l.coords)?l.coords.filter(a=>typeof a=="number"):[]})):null;return{id:i,kind:r,layerID:o,x:w(e.x)??0,y:w(e.y)??0,width:w(e.width)??0,height:w(e.height)??0,style:this.style(e.style),seed:(w(e.seed)??1)>>>0,text:$(e.text)??null,connector:this.connector(e.connector),groupID:_(e.groupID)??null,points:Array.isArray(e.points)?e.points.filter(E).map(l=>({x:w(l.x)??0,y:w(l.y)??0})):null,path:Array.isArray(e.path)?e.path.filter(l=>typeof l=="number"):null,subpaths:s,evenOdd:j(e.evenOdd)??null,rotation:w(e.rotation)??null,link:_(e.link)??null,anchor:$(e.anchor)??null,image:this.image(e.image,n),reveal:w(e.reveal)??null}}ease(e){let n=$(e);return n===void 0?null:ti.includes(n)?n:(this.warn(`Unknown ease "${n}", played linear`),null)}keyframe(e){if(!E(e))return null;this.fields(e,"keyframe");let n=w(e.t);if(n===void 0)return null;let i={t:n};for(let a of["x","y","width","height","rotation","strokeWidth","reveal","opacity"]){let c=w(e[a]);c!==void 0&&(i[a]=c)}let r=Ot(e.stroke),o=Ot(e.fill),s=j(e.visible),l=this.ease(e.ease);return r&&(i.stroke=r),o&&(i.fill=o),s!==void 0&&(i.visible=s),l&&(i.ease=l),i}track(e){if(!E(e))return null;this.fields(e,"track");let n=_(e.element);if(!n)return null;let i=(Array.isArray(e.keys)?e.keys:[]).map(s=>this.keyframe(s)).filter(s=>s!==null&&s.t>=0&&s.t<=mt);zt(i,s=>s.t);let r=Array.isArray(e.follow)?e.follow.filter(E).flatMap(s=>{let l=_(s.path),a=w(s.start),c=w(s.end);return!l||a===void 0||c===void 0||a<0||c>mt?[]:[{path:l,start:a,end:c,ease:this.ease(s.ease),reverse:j(s.reverse)??null,orient:j(s.orient)??null,laps:w(s.laps)??null}]}):null,o=Array.isArray(e.repeats)?e.repeats.filter(E).flatMap(s=>{let l=w(s.start),a=w(s.end);if(l===void 0||a===void 0)return[];let c=w(s.count),u={start:l,end:a,count:c===void 0?null:Math.trunc(c)};return Ct(u)?[u]:[]}):null;return{element:n,keys:i,boil:j(e.boil)??null,follow:r,repeats:o,march:qe(w(e.march))}}timeline(e){if(!E(e))return null;this.fields(e,"timeline");let n=w(e.boil),i=Array.isArray(e.camera)?e.camera.filter(E).flatMap(s=>{let l=w(s.t),a=w(s.x),c=w(s.y),u=w(s.width),d=w(s.height);return l===void 0||a===void 0||c===void 0||u===void 0||d===void 0?[]:u>1&&d>1&&l>=0?[{t:l,x:a,y:c,width:u,height:d,ease:this.ease(s.ease)}]:[]}):null;i&&zt(i,s=>s.t);let r=Array.isArray(e.markers)?e.markers.filter(E).flatMap(s=>{let l=w(s.t);return l!==void 0&&l>=0?[{t:l,name:$(s.name)??""}]:[]}):null;r&&zt(r,s=>s.t);let o=w(e.poster);return{fps:ft(w(e.fps)??12),duration:ot(w(e.duration)??0),boil:n!==void 0&&Number.isInteger(n)&&n>0?Math.min(n,1e4):null,settle:j(e.settle)??null,poster:o===void 0?null:ot(o),tracks:(Array.isArray(e.tracks)?e.tracks:[]).map(s=>this.track(s)).filter(s=>s!==null),camera:i,markers:r}}page(e,n,i){if(!E(e))throw new q(`Page ${i} is not an object`);this.fields(e,"page");let r=(Array.isArray(e.layers)?e.layers:[]).filter(E).flatMap(o=>{let s=_(o.id);return s?[{id:s,name:$(o.name)??"",visible:j(o.visible)??!0,locked:j(o.locked)??!1}]:[]});return r.length===0&&(this.warn(`Page ${i} has no layers`),r.push({id:"LAYER",name:"Layer 1",visible:!0,locked:!1})),{id:_(e.id)??`PAGE-${i}`,name:$(e.name)??`Page ${i}`,layers:r,elements:(Array.isArray(e.elements)?e.elements:[]).map(o=>this.element(o,n)).filter(o=>o!==null),theme:$(e.theme)??null,timeline:this.timeline(e.timeline)}}},ei=/^[A-Za-z0-9+/=\s]*$/;function Ct(t){return Number.isFinite(t.start)&&Number.isFinite(t.end)&&t.start>=0&&t.end-t.start>.001&&t.end<=mt&&(t.count===null||t.count>=1&&t.count<=1e4)}function zt(t,e){let n=t.map((i,r)=>[i,r]);n.sort((i,r)=>e(i[0])-e(r[0])||i[1]-r[1]);for(let i=0;i<t.length;i++)t[i]=n[i][0]}function Rt(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(s){throw new q(`Not JSON: ${s.message}`)}if(!E(e))throw new q("Not a Dottie drawing");let n=w(e.version);if(n===void 0)throw new q("Not a Dottie drawing (no version)");if(!Array.isArray(e.pages)||e.pages.length===0)throw new q("A drawing needs at least one page");let i=new ue;i.fields(e,"file"),n>2&&i.warn(`File version ${n} is newer than this player knows (2); some things may not show`);let r={};if(E(e.images))for(let[s,l]of Object.entries(e.images))E(l)&&typeof l.data=="string"&&(r[s]=i.picture(l.data,$(l.format)));let o=e.pages.map((s,l)=>i.page(s,r,l+1));if(new Set(o.map(s=>s.id)).size!==o.length)throw new q("Two pages share an id");return{version:n,pages:o,warnings:i.warnings}}function pt(t){return .2126*t.r+.7152*t.g+.0722*t.b}function dt(t,e){return t.r===e.r&&t.g===e.g&&t.b===e.b&&t.a===e.a}function me(t){return dt(t,st)||dt(t,Ke)}function B(t){return{...t,style:{...t.style,stroke:{...t.style.stroke},fill:{...t.style.fill}},connector:t.connector?{...t.connector,start:{...t.connector.start},end:{...t.connector.end}}:null}}function At(t){if(t.layers.length<=1)return t.elements;let e=new Map;t.layers.forEach((i,r)=>{e.has(i.id)||e.set(i.id,r)});let n=t.layers.map(()=>[]);for(let i of t.elements)n[e.get(i.layerID)??0].push(i);return n.flat()}function ni(t){let e=new Map;for(let n of t.elements)e.has(n.id)||e.set(n.id,n);return e}var Xe=.5522847498307936,R=class t{constructor(){k(this,"segments",[])}get isEmpty(){return this.segments.length===0}moveTo(e){return this.segments.push({op:"M",p:e}),this}lineTo(e){return this.segments.push({op:"L",p:e}),this}quadTo(e,n){return this.segments.push({op:"Q",c:n,p:e}),this}curveTo(e,n,i){return this.segments.push({op:"C",c1:n,c2:i,p:e}),this}close(){return this.segments.push({op:"Z"}),this}addPath(e){return this.segments.push(...e.segments),this}addLines(e){return e.forEach((n,i)=>i===0?this.moveTo(n):this.lineTo(n)),this}static rect(e){return new t().addLines([{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}]).close()}addEllipse(e){let n=e.x+e.width/2,i=e.y+e.height/2,r=e.width/2,o=e.height/2,s=r*Xe,l=o*Xe;return this.moveTo({x:n+r,y:i}),this.curveTo({x:n,y:i+o},{x:n+r,y:i+l},{x:n+s,y:i+o}),this.curveTo({x:n-r,y:i},{x:n-s,y:i+o},{x:n-r,y:i+l}),this.curveTo({x:n,y:i-o},{x:n-r,y:i-l},{x:n-s,y:i-o}),this.curveTo({x:n+r,y:i},{x:n+s,y:i-o},{x:n+r,y:i-l}),this.close()}static ellipse(e){return new t().addEllipse(e)}translated(e,n){let i=o=>({x:o.x+e,y:o.y+n}),r=new t;return r.segments=this.segments.map(o=>{switch(o.op){case"M":case"L":return{op:o.op,p:i(o.p)};case"Q":return{op:"Q",c:i(o.c),p:i(o.p)};case"C":return{op:"C",c1:i(o.c1),c2:i(o.c2),p:i(o.p)};case"Z":return o}}),r}contours(){let e=[],n=[],i={x:0,y:0};for(let r of this.segments){let o=n.length?n[n.length-1]:i;switch(r.op){case"M":n.length>1&&e.push(n),i=r.p,n=[r.p];break;case"L":n.push(r.p);break;case"Q":for(let s=1;s<=12;s++){let l=s/12,a=1-l;n.push({x:a*a*o.x+2*a*l*r.c.x+l*l*r.p.x,y:a*a*o.y+2*a*l*r.c.y+l*l*r.p.y})}break;case"C":for(let s=1;s<=16;s++){let l=s/16,a=1-l;n.push({x:a*a*a*o.x+3*a*a*l*r.c1.x+3*a*l*l*r.c2.x+l*l*l*r.p.x,y:a*a*a*o.y+3*a*a*l*r.c1.y+3*a*l*l*r.c2.y+l*l*l*r.p.y})}break;case"Z":n.push(i),n.length>1&&e.push(n),n=[i];break}}return n.length>1&&e.push(n),e}trimmed(e){let n=this.contours().map(o=>new yt(o)),i=Math.min(Math.max(e,0),1)*n.reduce((o,s)=>o+s.length,0),r=new t;for(let o of n){if(!(i>0))break;r.moveTo(o.points[0]);for(let s=1;s<o.points.length;s++){let l=o.lengths[s]-o.lengths[s-1];if(l<=i){r.lineTo(o.points[s]),i-=l;continue}let a=o.points[s-1],c=o.points[s],u=i/l;r.lineTo({x:a.x+(c.x-a.x)*u,y:a.y+(c.y-a.y)*u}),i=0;break}}return r}data(){let e=[];for(let n of this.segments)switch(n.op){case"M":e.push(`M${y(n.p.x)} ${y(n.p.y)}`);break;case"L":e.push(`L${y(n.p.x)} ${y(n.p.y)}`);break;case"Q":e.push(`Q${y(n.c.x)} ${y(n.c.y)} ${y(n.p.x)} ${y(n.p.y)}`);break;case"C":e.push(`C${y(n.c1.x)} ${y(n.c1.y)} ${y(n.c2.x)} ${y(n.c2.y)} ${y(n.p.x)} ${y(n.p.y)}`);break;case"Z":e.push("Z");break}return e.join(" ")}};function Tt(t){return t<0?-Math.round(-t):Math.round(t)}function y(t){let e=Tt(t*100)/100;return Number.isInteger(e)?String(e===0?0:e):String(e)}var yt=class{constructor(e){k(this,"points");k(this,"lengths");this.points=e;let n=0;this.lengths=e.map((i,r)=>(r>0&&(n+=Math.hypot(i.x-e[r-1].x,i.y-e[r-1].y)),n))}get length(){return this.lengths.length?this.lengths[this.lengths.length-1]:0}point(e){if(this.points.length<=1||!(this.length>0))return this.points[0]??{x:0,y:0};let n=Math.min(Math.max(e,0),1)*this.length,i=1;for(;i<this.lengths.length-1&&this.lengths[i]<n;)i++;let r=this.lengths[i]-this.lengths[i-1],o=r>0?(n-this.lengths[i-1])/r:0,s=this.points[i-1],l=this.points[i];return{x:s.x+(l.x-s.x)*o,y:s.y+(l.y-s.y)*o}}},z=t=>t.x+t.width/2,C=t=>t.y+t.height/2,Y=t=>t.x+t.width,O=t=>t.y+t.height;function de(t,e){if(!t)return{...e};let n=Math.min(t.x,e.x),i=Math.min(t.y,e.y);return{x:n,y:i,width:Math.max(Y(t),Y(e))-n,height:Math.max(O(t),O(e))-i}}function gt(t,e,n){return{x:t.x+e,y:t.y+n,width:t.width-2*e,height:t.height-2*n}}function fe(t,e,n){if(n===0)return t;let i=t.x-e.x,r=t.y-e.y;return{x:e.x+i*Math.cos(n)-r*Math.sin(n),y:e.y+i*Math.sin(n)+r*Math.cos(n)}}function ii(t,e){let n=1-e;return{x:t[0].x*(n*n*n)+t[1].x*(3*e*n*n)+t[2].x*(3*e*e*n)+t[3].x*(e*e*e),y:t[0].y*(n*n*n)+t[1].y*(3*e*n*n)+t[2].y*(3*e*e*n)+t[3].y*(e*e*e)}}function Qe(t,e){let n=[t[0]];for(let i=0;i<Math.floor((t.length-1)/3);i++){let r=t.slice(3*i,3*i+4),o=0;for(let l=1;l<r.length;l++)o+=Math.hypot(r[l].x-r[l-1].x,r[l].y-r[l-1].y);let s=Math.min(400,Math.max(4,Math.ceil(o/Math.max(e,.5))));for(let l=1;l<=s;l++)n.push(ii(r,l/s))}return n}var L=t=>({x:t.x,y:t.y,width:t.width,height:t.height}),F=t=>t.rotation??0,vt=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),Q=(t,e)=>fe(e,vt(t),F(t)),Ze=(t,e)=>fe(e,vt(t),-F(t));function Je(t){let e=L(t);if(F(t)===0)return e;let n=[{x:e.x,y:e.y},{x:Y(e),y:e.y},{x:Y(e),y:O(e)},{x:e.x,y:O(e)}].map(l=>Q(t,l)),i=n.map(l=>l.x),r=n.map(l=>l.y),o=Math.min(...i),s=Math.min(...r);return{x:o,y:s,width:Math.max(...i)-o,height:Math.max(...r)-s}}function tn(t,e){if(!me(t.style.stroke))return t;let n=B(t),r=(t.style.fillStyle==="solid"||t.style.fillStyle==="grid")&&t.style.fill.a>=.5&&pt(t.style.fill)>.5;return n.style.stroke=pt(e)>.5&&r?{...st}:{...e},n}function Gt(t){if(t.kind!=="path"||!t.subpaths)return[];let e=[];for(let n of t.subpaths){if(n.coords.length<8||(n.coords.length-2)%6!==0)continue;let i=[];for(let r=0;r<n.coords.length;r+=2)i.push({x:t.x+n.coords[r]*t.width,y:t.y+n.coords[r+1]*t.height});e.push({closed:n.closed,points:i})}return e}function pe(t){let e=new R;for(let n of Gt(t)){e.moveTo(n.points[0]);for(let i=0;i<(n.points.length-1)/3;i++)e.curveTo(n.points[3*i+3],n.points[3*i+1],n.points[3*i+2]);n.closed&&e.close()}return e}function ri(t,e){let n=L(t),i=e==="top"?{x:z(n),y:n.y}:e==="right"?{x:Y(n),y:C(n)}:e==="bottom"?{x:z(n),y:O(n)}:{x:n.x,y:C(n)};return Q(t,i)}function oi(t,e){let n=L(t),i=vt(t),r=Ze(t,e),o=r.x-i.x,s=r.y-i.y;if(!((o!==0||s!==0)&&n.width>0&&n.height>0))return i;let l=n.width/2,a=n.height/2,c;return t.kind==="ellipse"?c=1/Math.sqrt(o*o/(l*l)+s*s/(a*a)):t.kind==="diamond"?c=1/(Math.abs(o)/l+Math.abs(s)/a):c=Math.min(o!==0?l/Math.abs(o):1/0,s!==0?a/Math.abs(s):1/0),Q(t,{x:i.x+o*c,y:i.y+s*c})}function en(t,e){let n=t.elementID?e.get(t.elementID):void 0;return n?vt(n):{x:t.x,y:t.y}}function nn(t,e,n){let i=t.elementID?n.get(t.elementID):void 0;return i?t.port?ri(i,t.port):oi(i,e):{x:t.x,y:t.y}}function lt(t,e){let n=t.connector;return n?[nn(n.start,en(n.end,e),e),nn(n.end,en(n.start,e),e)]:[{x:0,y:0},{x:0,y:0}]}function Z(t){if(t.kind==="polyline")return t.points;let e=[];for(let n=0;n<=24;n++){let i=n/24,r=1-i;e.push({x:r*r*r*t.a.x+3*r*r*i*t.b.x+3*r*i*i*t.c.x+i*i*i*t.d.x,y:r*r*r*t.a.y+3*r*r*i*t.b.y+3*r*i*i*t.c.y+i*i*i*t.d.y})}return e}function J(t,e){let n=t.connector;if(!n)return{kind:"polyline",points:[]};let[i,r]=lt(t,e),o=r.x-i.x,s=r.y-i.y,l=Math.abs(o)>=Math.abs(s);switch(n.routing){case"straight":return{kind:"polyline",points:[i,r]};case"curved":return l?{kind:"cubic",a:i,b:{x:i.x+o/2,y:i.y},c:{x:r.x-o/2,y:r.y},d:r}:{kind:"cubic",a:i,b:{x:i.x,y:i.y+s/2},c:{x:r.x,y:r.y-s/2},d:r};case"elbow":{let a=d=>d===null?null:d==="top"||d==="bottom",c=a(n.start.port)??!l,u=a(n.end.port)??!l;if(c&&u){let d=i.y+s/2;return{kind:"polyline",points:[i,{x:i.x,y:d},{x:r.x,y:d},r]}}if(!c&&!u){let d=i.x+o/2;return{kind:"polyline",points:[i,{x:d,y:i.y},{x:d,y:r.y},r]}}return c?{kind:"polyline",points:[i,{x:i.x,y:r.y},r]}:{kind:"polyline",points:[i,{x:r.x,y:i.y},r]}}}}function rn(t,e,n){let i=Math.atan2(t.y-e.y,t.x-e.x),r=Math.PI/7,o=s=>({x:t.x-n*Math.cos(i+s),y:t.y-n*Math.sin(i+s)});return[o(r),o(-r)]}function on(t,e){let n=Z(J(t,e));if(n.length===0)return{x:0,y:0,width:0,height:0};let i=n[0].x,r=n[0].y,o=i,s=r;for(let l of n)i=Math.min(i,l.x),r=Math.min(r,l.y),o=Math.max(o,l.x),s=Math.max(s,l.y);return{x:i,y:r,width:o-i,height:s-r}}function sn(t,e){let n=Z(J(t,e));if(n.length<=1)return n[0]??{x:0,y:0};let i=[],r=0;for(let s=0;s<n.length-1;s++){let l=Math.hypot(n[s+1].x-n[s].x,n[s+1].y-n[s].y);i.push(l),r+=l}let o=r/2;for(let s=0;s<i.length;s++){let l=i[s];if(o<=l||s===i.length-1){let a=l===0?0:o/l;return{x:n[s].x+(n[s+1].x-n[s].x)*a,y:n[s].y+(n[s+1].y-n[s].y)*a}}o-=l}return n[0]}function tt(t){let e=new Map;for(let n of t.elements)e.has(n.id)||e.set(n.id,n);return e}function ge(t,e,n){let i=t[1]+n>>>0,r=i<t[1]?1:0;return[t[0]+e+r>>>0,i]}function si(t,e){let n=t&65535,i=t>>>16,r=e&65535,o=e>>>16,s=n*r,l=n*o,a=i*r,c=i*o,u=l+a,d=s+u%65536*65536;return[c+Math.floor(u/65536)+Math.floor(d/4294967296)>>>0,d>>>0]}function xe(t,e,n){let i=si(t[1],n);return[i[0]+Math.imul(t[0],n)+Math.imul(t[1],e)>>>0,i[1]]}function ye(t,e){let n=(t[1]>>>e|t[0]<<32-e)>>>0;return[(t[0]^t[0]>>>e)>>>0,(t[1]^n)>>>0]}function ln(t){return t=xe(ye(t,30),3210233709,484763065),t=xe(ye(t,27),2496678331,321982955),ye(t,31)}var et=class{constructor(e){k(this,"state");this.state=ge([0,e>>>0],2654435769,2135587861)}next(){return this.state=ge(this.state,2654435769,2135587861),ln(this.state)}top53(){let[e,n]=this.next();return e*2097152+(n>>>11)}signed(){return Math.floor(this.top53())/2**52-1}unit(){return this.top53()/2**53}};function an(t,e){let n=ge([0,t>>>0],...li(e));return n=ln(n),Math.max(1,n[1]>>>0)}function li(t){let e=xe([0,t>>>0],2654435769,2135587861);return[e[0],e[1]]}var cn=(t,e,n)=>t.signed()*e*n;function U(t,e,n,i,r,o,s){let l=Math.hypot(e.x-t.x,e.y-t.y);if(!(l>.5))return;let a=l<200?1:l>500?.4:-.0016668*l+1.233334,c=l<20?l/10:2;for(let u=0;u<2;u++){let d=(u===0?1:.5)*a,f=()=>cn(n,c,i)*d,m=n.unit()*.4+.3,h=cn(n,l/60,i)*r*a,p=e.x-t.x,x=e.y-t.y,M=-x/l,b=p/l,g=o?t:{x:t.x+f(),y:t.y+f()},A=o?e:{x:e.x+f(),y:e.y+f()},v=t.x+p*m*.66+M*h+f()*.5,S=t.y+x*m*.66+b*h+f()*.5,P=t.x+p*(.5+m*.5)+M*h+f()*.5,I=t.y+x*(.5+m*.5)+b*h+f()*.5;s.moveTo(g),s.curveTo(A,{x:v,y:S},{x:P,y:I})}}function be(t,e,n,i){let r=new R;for(let o=0;o<t.length;o++)U(t[o],t[(o+1)%t.length],e,n,i,!1,r);return r}function un(t,e,n){let i=new R,r=t.x+t.width/2,o=t.y+t.height/2,s=t.width/2,l=t.height/2;if(!(s>.5&&l>.5))return i;let a=Math.max(8,Math.min(24,Math.trunc((s+l)/6))),c=Math.min(2.5,(s+l)/25)*n;for(let u=0;u<2;u++){let d=e.unit()*2*Math.PI,f=2*Math.PI*(u===0?1:1.04),m=Math.trunc(a*f/(2*Math.PI))+1,h=[];for(let p=0;p<m;p++){let x=d+f*p/a,M=e.signed()*c,b=e.signed()*c;h.push({x:r+s*Math.cos(x)+M,y:o+l*Math.sin(x)+b})}ai(h,i)}return i}function ai(t,e){if(!(t.length<=2)){e.moveTo(t[0]);for(let n=0;n<t.length-1;n++){let i=t[Math.max(n-1,0)],r=t[n],o=t[n+1],s=t[Math.min(n+2,t.length-1)];e.curveTo(o,{x:r.x+(o.x-i.x)/6,y:r.y+(o.y-i.y)/6},{x:o.x-(s.x-r.x)/6,y:o.y-(s.y-r.y)/6})}}}var ke=-41*Math.PI/180;function hn(t,e,n){if(!(n>0))return[];let i=Math.cos(e),r=Math.sin(e),o=t.filter(f=>f.length>=3).map(f=>f.map(m=>({x:m.x*i+m.y*r,y:-m.x*r+m.y*i}))),s=o.flat();if(s.length===0)return[];let l=1/0,a=-1/0;for(let f of s)l=Math.min(l,f.y),a=Math.max(a,f.y);let c=(f,m)=>({x:f*i-m*r,y:f*r+m*i}),u=[],d=l+n/2;for(;d<a;){let f=[];for(let m of o)for(let h=0;h<m.length;h++){let p=m[h],x=m[(h+1)%m.length];(p.y<=d&&d<x.y||x.y<=d&&d<p.y)&&f.push(p.x+(d-p.y)/(x.y-p.y)*(x.x-p.x))}f.sort((m,h)=>m-h);for(let m=0;m+1<f.length;m+=2)f[m+1]-f[m]>.5&&u.push([c(f[m],d),c(f[m+1],d)]);d+=n}return u}var Bt=class{constructor(e=6e3){k(this,"map",new Map);k(this,"limit");this.limit=e}get(e,n){let i=this.map.get(e);if(i!==void 0)return i;let r=n();return this.map.size>=this.limit&&this.map.clear(),this.map.set(e,r),r}},fn=new Bt,ci=new Bt;function pn(t,e){let n=t.style;return[e,t.kind,t.x,t.y,t.width,t.height,t.seed,n.roughness,n.bowing,n.strokeWidth,n.fillStyle,n.fillStyle==="grid"?at(t):0,t.path?t.path.join(","):t.subpaths?JSON.stringify(t.subpaths):""].join("|")}var at=t=>Math.max(8,t.style.gridSize??50);function ct(t){return t.kind==="freehand"&&t.path===null?dn(t):fn.get(pn(t,0),()=>dn(t))}function yn(t){return[{x:t.x,y:t.y},{x:Y(t),y:t.y},{x:Y(t),y:O(t)},{x:t.x,y:O(t)}]}function Ft(t){return[{x:z(t),y:t.y},{x:Y(t),y:C(t)},{x:z(t),y:O(t)},{x:t.x,y:C(t)}]}function dn(t){let e=L(t),n=new et(t.seed),i=t.style.roughness;switch(t.kind){case"ellipse":return i<=0?R.ellipse(e):un(e,n,i);case"diamond":return i<=0?new R().addLines(Ft(e)).close():be(Ft(e),n,i,t.style.bowing);case"text":case"connector":return R.rect(e);case"freehand":return hi(t);case"path":return i<=0?pe(t):ui(t,n);default:return i<=0?R.rect(e):be(yn(e),n,i,t.style.bowing)}}function ui(t,e){let n=t.style.roughness,i=new R;for(let r of Gt(t)){let o=r.points;for(let s=0;s<(o.length-1)/3;s++){let l=o[3*s],a=o[3*s+1],c=o[3*s+2],u=o[3*s+3];if(a.x===l.x&&a.y===l.y&&c.x===u.x&&c.y===u.y){U(l,u,e,n,t.style.bowing,!0,i);continue}let d=Math.hypot(a.x-l.x,a.y-l.y)+Math.hypot(c.x-a.x,c.y-a.y)+Math.hypot(u.x-c.x,u.y-c.y),f=Math.min(2.5,d/30)*n;for(let m=0;m<2;m++){let h=m===0?1:.5,p=()=>e.signed()*f*h;i.moveTo(l);let x=a.x+p(),M=a.y+p(),b=c.x+p(),g=c.y+p();i.curveTo(u,{x,y:M},{x:b,y:g})}}}return i}function hi(t){let e=L(t),n=t.path;if(n&&n.length>=8&&(n.length-2)%6===0){let o=l=>({x:e.x+n[2*l]*e.width,y:e.y+n[2*l+1]*e.height}),s=new R().moveTo(o(0));for(let l=0;l<Math.floor((n.length/2-1)/3);l++)s.curveTo(o(3*l+3),o(3*l+1),o(3*l+2));return s}let i=(t.points??[]).map(o=>({x:e.x+o.x*e.width,y:e.y+o.y*e.height})),r=new R;if(i.length===0)return r;if(r.moveTo(i[0]),i.length===1)return r.lineTo(i[0]);if(i.length===2)return r.lineTo(i[1]);for(let o=1;o<i.length-1;o++)r.quadTo({x:(i[o].x+i[o+1].x)/2,y:(i[o].y+i[o+1].y)/2},i[o]);return r.lineTo(i[i.length-1])}function we(t){return t.kind!=="path"?[mi(t)]:Gt(t).map(e=>Qe(e.points,3))}function mi(t){let e=L(t);if(t.kind==="ellipse"){let n=[];for(let i=0;i<48;i++){let r=2*Math.PI*i/48;n.push({x:z(e)+e.width/2*Math.cos(r),y:C(e)+e.height/2*Math.sin(r)})}return n}return t.kind==="diamond"?Ft(e):yn(e)}function Nt(t){let e=L(t);return t.kind==="ellipse"?R.ellipse(e):t.kind==="path"?pe(t):t.kind==="diamond"?new R().addLines(Ft(e)).close():R.rect(e)}function Pe(t){return t.style.fillStyle==="solid"||["freehand","connector","text","image"].includes(t.kind)?new R:fn.get(pn(t,1),()=>di(t))}function di(t){let e=we(t),n=new et((t.seed^1540483477)>>>0),i=new R;if(t.style.fillStyle==="grid"){for(let[s,l]of gn(e,at(t)))t.style.roughness<=0?i.moveTo(s).lineTo(l):U(s,l,n,t.style.roughness*.3,.3,!1,i);return i}let r=Math.max(4,t.style.strokeWidth*4),o=[ke];t.style.fillStyle==="crossHatch"&&o.push(ke+Math.PI/2);for(let s of o)for(let[l,a]of hn(e,s,r))t.style.roughness<=0?i.moveTo(l).lineTo(a):U(l,a,n,t.style.roughness*.6,.5,!1,i);return i}function Ht(t,e){switch(t){case"solid":return null;case"dashed":return[Math.max(8,e*4),Math.max(6,e*3)];case"dotted":return[.01,Math.max(5,e*2.6)]}}function Me(t,e){let n=t.connector;if(!n)return[new R,new R];let[i,r]=lt(t,e),o=[t.seed,t.style.roughness,t.style.bowing,t.style.strokeWidth,n.routing,n.startHead,n.endHead,n.start.port,n.end.port,i.x,i.y,r.x,r.y].join("|");return ci.get(o,()=>fi(t,e))}function fi(t,e){let n=t.connector,i=new et(t.seed),r=t.style.roughness,o=t.style.bowing,s=new R,l=new R,a=J(t,e);if(a.kind==="polyline"){let m=a.points;for(let h=0;h<Math.max(m.length-1,0);h++)r<=0?s.moveTo(m[h]).lineTo(m[h+1]):U(m[h],m[h+1],i,r,o,!0,s)}else{s.moveTo(a.a);let m=r*3,h=()=>i.signed()*m,p=a.b.x+h(),x=a.b.y+h(),M=a.c.x+h(),b=a.c.y+h();s.curveTo(a.d,{x:p,y:x},{x:M,y:b})}let c=Z(a),u=Math.max(10,t.style.strokeWidth*5),d=(m,h)=>{r<=0?s.moveTo(m).lineTo(h):U(m,h,i,r*.5,0,!0,s)},f=(m,h,p)=>{let[x,M]=rn(h,p,u);switch(m){case"arrow":d(x,h),d(M,h);break;case"triangle":d(x,h),d(M,h),d(x,M),l.moveTo(h).lineTo(x).lineTo(M).close();break;case"dot":{let b=u*.32,g=Math.atan2(h.y-p.y,h.x-p.x),A=h.x-b*Math.cos(g),v=h.y-b*Math.sin(g);l.addEllipse({x:A-b,y:v-b,width:2*b,height:2*b});break}case"bar":{let b=Math.atan2(h.y-p.y,h.x-p.x)+Math.PI/2,g=u*.5;d({x:h.x-g*Math.cos(b),y:h.y-g*Math.sin(b)},{x:h.x+g*Math.cos(b),y:h.y+g*Math.sin(b)});break}}};return c.length>1&&(f(n.endHead,c[c.length-1],c[c.length-2]),f(n.startHead,c[0],c[1])),[s,l]}var kn=2,Re=.75,pi=.8,xn=.6;function gn(t,e){return[...bn(t,e,!1),...bn(t,e,!0)]}function bn(t,e,n){if(!(e>0))return[];let i=c=>n?{x:c.y,y:c.x}:c,r=t.filter(c=>c.length>=3).map(c=>c.map(i)),o=r.flat().map(c=>c.y);if(o.length===0)return[];let s=Math.min(...o),l=Math.max(...o),a=[];for(let c=Math.floor(s/e)*e;c<l-.5;c+=e){if(!(c>s+.5))continue;let u=[];for(let d of r)for(let f=0;f<d.length;f++){let m=d[f],h=d[(f+1)%d.length];(m.y<=c&&c<h.y||h.y<=c&&c<m.y)&&u.push(m.x+(c-m.y)/(h.y-m.y)*(h.x-m.x))}u.sort((d,f)=>d-f);for(let d=0;d+1<u.length;d+=2)u[d+1]-u[d]>.5&&a.push([i({x:u[d],y:c}),i({x:u[d+1],y:c})])}return a}function wn(t){return .2126*t.r+.7152*t.g+.0722*t.b>.5?{r:t.r*.84,g:t.g*.84,b:t.b*.8,a:t.a}:{r:t.r+(1-t.r)*.25,g:t.g+(1-t.g)*.25,b:t.b+(1-t.b)*.25,a:t.a}}function Ae(t){return t.style.fillStyle==="grid"&&t.style.fill.a>0&&["rectangle","ellipse","diamond","path"].includes(t.kind)}function _t(t,e,n){let i=(Math.imul(t,668265261)^Math.imul(e,374761393)^Math.imul(n,2654435761))>>>0;return i=Math.imul(i^i>>>15,2246822507)>>>0,i=Math.imul(i^i>>>13,3266489909)>>>0,i=(i^i>>>16)>>>0,i/4294967296}function Pn(t,e,n){let i=n/kn;return{x:(t+.5+(_t(t,e,1)-.5)*xn)*i,y:(e+.5+(_t(t,e,2)-.5)*xn)*i}}function yi(t,e,n,i){let r=1/0;for(let o=-1;o<=1;o++)for(let s=-1;s<=1;s++){if(o===0&&s===0)continue;let l=Pn(t+o,e+s,i);r=Math.min(r,Math.hypot(l.x-n.x,l.y-n.y))}return r*pi}function gi(t,e,n){let i=Math.cos(e),r=Math.sin(e),o=n*.8,s=n*.5;return[-1,0,1].map(l=>{let a=t.x-r*s*l,c=t.y+i*s*l;return[{x:a-i*o,y:c-r*o},{x:a+i*o,y:c+r*o}]})}function xi(t,e){let n=!1;for(let i of t){if(i.length<3)continue;let r=i.length-1;for(let o=0;o<i.length;o++){let s=i[o],l=i[r];s.y>e.y!=l.y>e.y&&e.x<(l.x-s.x)*(e.y-s.y)/(l.y-s.y)+s.x&&(n=!n),r=o}}return n}function bi(t,e){let n=1/0;for(let i of e)if(!(i.length<2))for(let r=0;r<i.length;r++){let o=i[r],s=i[(r+1)%i.length],l=s.x-o.x,a=s.y-o.y,c=l*l+a*a,u=c>0?Math.max(0,Math.min(1,((t.x-o.x)*l+(t.y-o.y)*a)/c)):0;n=Math.min(n,Math.hypot(t.x-(o.x+u*l),t.y-(o.y+u*a)))}return n}var ki=(t,e)=>e.x>=t.x&&e.x<t.x+t.width&&e.y>=t.y&&e.y<t.y+t.height,jt=new Map;function Mn(t){if(t.length===0)return[];let e=t.map(r=>[r.kind,r.x,r.y,r.width,r.height,r.rotation??0,at(r),JSON.stringify(r.subpaths??null),r.style.stroke.r,r.style.stroke.g,r.style.stroke.b,r.style.stroke.a,r.style.roughness,r.style.strokeWidth].join(",")).join(";"),n=jt.get(e);if(n)return n;let i=wi(t);return jt.size>=16&&jt.clear(),jt.set(e,i),i}function wi(t){let e=t.map(o=>{let s=we(o).map(m=>m.map(h=>Q(o,h))),l=s.flat(),a=l.map(m=>m.x),c=l.map(m=>m.y),u=a.length?Math.min(...a):0,d=c.length?Math.min(...c):0,f={x:u,y:d,width:(a.length?Math.max(...a):0)-u,height:(c.length?Math.max(...c):0)-d};return{contours:s,box:f,cell:at(o),element:o}}),n=e.map(()=>[]),i=new Set;for(let o of e){let s=o.cell/kn,l=gt(o.box,-o.cell,-o.cell),a=Math.floor(l.x/s),c=Math.ceil((l.x+l.width)/s),u=Math.floor(l.y/s),d=Math.ceil((l.y+l.height)/s),f=Re*o.cell;for(let m=a;m<c;m++)for(let h=u;h<d;h++){let p=`${o.cell}|${m}|${h}`;if(i.has(p))continue;i.add(p);let x=Pn(m,h,o.cell),M=1/0,b=-1;for(let S=0;S<e.length;S++){let P=e[S];if(!ki(gt(P.box,-f,-f),x))continue;if(xi(P.contours,x)){M=0;break}let I=bi(x,P.contours);I<M&&(M=I,b=S)}if(!(M>0&&M<=f&&b>=0))continue;let g=_t(m,h,3)*Math.PI,A=yi(m,h,x,o.cell),v=Math.trunc(_t(m,h,4)*4294967296)>>>0;for(let[S,P]of gi(x,g,A))n[b].push([S,P,v])}}let r=[];return e.forEach((o,s)=>{if(n[s].length===0)return;let l=o.element,a=new R;for(let[c,u,d]of n[s])l.style.roughness<=0?a.moveTo(c).lineTo(u):U(c,u,new et(d),l.style.roughness*.35,.2,!1,a);r.push({ink:{...l.style.stroke,a:l.style.stroke.a*.6},width:Math.max(.8,l.style.strokeWidth*.45),path:a})}),r}var qt=.951995849609375,Ut=.2129974365234375,Kt=.0279998779296875,Rn=.975006103515625,An=.2169952392578125,Tn=.0290069580078125,vn=.957000732421875,En=.2129974365234375,Sn=.0279998779296875,In=.975006103515625,$n=.2169952392578125,Ln=.0290069580078125,Vn=.60205078125,Dn=.92822265625,Wn=.23583984375,xt={bold:{k:{"\u2018\u2018":-95,"\u2019\u2019":-95,"\u2019s":-74,"\u2019t":-18,"A\u2019":-74,AT:-92,Av:-18,AV:-46,Aw:-18,AW:-24,Ay:-18,AY:-74,"F,":-157,"F.":-157,"f\u2019":18,FA:-55,ff:-30,fi:20,fl:20,"L\u2019":-74,LT:-92,LV:-92,LW:-55,Ly:-37,LY:-111,"P,":-179,"P.":-179,PA:-74,"r-":-55,"r,":-92,"r.":-92,rc:-18,rd:-18,re:-18,rg:-28,rn:18,ro:-18,rq:-18,RT:-18,RV:-18,RW:-18,RY:-37,"T-":-129,"T,":-111,"T;":-111,"T:":-111,"T.":-111,Ta:-111,TA:-92,Tc:-111,Te:-111,To:-111,Tr:-92,Ts:-111,Tu:-92,Tw:-111,Ty:-111,"V-":-55,"v,":-74,"V,":-129,"V;":-46,"V:":-46,"v.":-74,"V.":-129,Va:-55,VA:-46,Ve:-55,Vi:-18,Vo:-55,Vr:-37,Vu:-37,Vy:-18,"w,":-55,"W,":-74,"W;":-18,"W:":-18,"w.":-55,"W.":-74,Wa:-37,WA:-24,We:-57,Wo:-57,Wr:-18,Wu:-18,"Y-":-111,"y,":-74,"Y,":-139,"Y;":-92,"Y:":-92,"y.":-74,"Y.":-139,Ya:-92,YA:-74,Ye:-111,Yi:-37,Yo:-111,Yp:-74,Yq:-92,Yu:-74,Yv:-55},w:{" ":278,_:500,"-":407,"\u2013":500,"\u2014":1e3,",":278,";":278,":":278,"!":278,"?":556,".":278,"\u2026":1e3,"\xB7":278,"'":278,"\u2018":278,"\u2019":278,'"':463,"\u201C":463,"\u201D":463,"(":296,")":296,"[":333,"]":333,"{":333,"}":333,"@":800,"*":407,"/":371,"\\":371,"&":685,"#":556,"%":1e3,"\u2022":350,"`":259,"^":600,"\u2190":1e3,"\u2192":1e3,"\u2191":722.66,"\u2193":722.66,"+":600,"\xD7":600,"<":600,"=":600,">":600,"|":223,"~":600,"\u25E6":608.4,"\u2610":830.08,"\u2611":830.08,"\u2713":764.16,$:556,0:556,1:556,2:556,3:556,4:556,5:556,6:556,7:556,8:556,9:556,a:574,A:685,b:611,B:704,c:574,C:741,d:611,D:741,e:574,E:648,\u00E9:574,f:333,F:593,g:611,G:759,h:593,H:741,i:258,I:295,j:278,J:556,k:574,K:722,l:258,L:593,m:906,M:907,n:593,N:741,o:611,O:778,p:611,P:667,q:611,Q:778,r:389,R:722,s:537,S:649,t:352,T:611,u:593,U:741,v:520,V:630,w:814,W:944,x:537,X:667,y:519,Y:667,z:519,Z:648}},boldItalic:{k:{"\u2018\u2018":-95,"\u2019\u2019":-95,"\u2019s":-74,"\u2019t":-18,"A\u2019":-74,AT:-92,Av:-18,AV:-46,Aw:-18,AW:-24,Ay:-18,AY:-74,"F,":-157,"F.":-157,"f\u2019":18,FA:-55,ff:-68,"L\u2019":-74,LT:-92,LV:-92,LW:-55,Ly:-37,LY:-111,"P,":-179,"P.":-179,PA:-74,"r-":-55,"r,":-92,"r.":-92,rc:-18,rd:-18,re:-18,rg:-28,rn:18,ro:-18,rq:-18,RT:-18,RV:-18,RW:-18,RY:-37,"T-":-129,"T,":-111,"T;":-111,"T:":-111,"T.":-111,Ta:-111,TA:-92,Tc:-111,Te:-111,To:-111,Tr:-92,Ts:-111,Tu:-92,Tw:-111,Ty:-111,"V-":-55,"v,":-74,"V,":-129,"V;":-46,"V:":-46,"v.":-74,"V.":-129,Va:-55,VA:-46,Ve:-55,Vi:-18,Vo:-55,Vr:-37,Vu:-37,Vy:-18,"w,":-55,"W,":-74,"W;":-18,"W:":-18,"w.":-55,"W.":-74,Wa:-37,WA:-24,We:-57,Wo:-57,Wr:-18,Wu:-18,"Y-":-111,"y,":-74,"Y,":-139,"Y;":-92,"Y:":-92,"y.":-74,"Y.":-139,Ya:-92,YA:-74,Ye:-111,Yi:-37,Yo:-111,Yp:-74,Yq:-92,Yu:-74,Yv:-55},w:{" ":278,_:500,"-":407,"\u2013":500,"\u2014":1e3,",":278,";":278,":":278,"!":296,"?":574,".":278,"\u2026":1e3,"\xB7":278,"'":278,"\u2018":278,"\u2019":278,'"':481,"\u201C":481,"\u201D":481,"(":296,")":296,"[":333,"]":333,"{":333,"}":333,"@":800,"*":407,"/":389,"\\":389,"&":685,"#":556,"%":963,"\u2022":350,"`":259,"^":600,"\u2190":1e3,"\u2192":1e3,"\u2191":722.66,"\u2193":722.66,"+":600,"\xD7":600,"<":600,"=":600,">":600,"|":222,"~":600,"\u25E6":608.4,"\u2610":830.08,"\u2611":830.08,"\u2713":764.16,$:556,0:556,1:556,2:556,3:556,4:556,5:556,6:556,7:556,8:556,9:556,a:574,A:685,b:611,B:722,c:556,C:741,d:611,D:741,e:574,E:667,\u00E9:574,f:352,F:593,g:611,G:759,h:611,H:741,i:259,I:296,j:259,J:556,k:556,K:722,l:259,L:574,m:907,M:907,n:611,N:741,o:593,O:778,p:611,P:667,q:611,Q:778,r:389,R:722,s:519,S:648,t:370,T:611,u:611,U:741,v:519,V:630,w:815,W:944,x:519,X:667,y:519,Y:648,z:500,Z:648}},italic:{k:{"\u2018\u2018":-95,"\u2019\u2019":-95,"\u2019s":-74,"\u2019t":-18,"A\u2019":-74,AT:-92,Av:-18,AV:-46,Aw:-18,AW:-24,Ay:-18,AY:-74,"F,":-157,"F.":-157,"f\u2019":18,FA:-55,ff:-15,fi:1,fl:1,"L\u2019":-74,LT:-92,LV:-92,LW:-55,Ly:-37,LY:-111,"P,":-179,"P.":-179,PA:-74,"r-":-55,"r,":-92,"r.":-92,rc:-18,rd:-18,re:-18,rg:-28,rn:18,ro:-18,rq:-18,RT:-18,RV:-18,RW:-18,RY:-37,"T-":-129,"T,":-111,"T;":-111,"T:":-111,"T.":-111,Ta:-111,TA:-92,Tc:-111,Te:-111,To:-111,Tr:-92,Ts:-111,Tu:-92,Tw:-111,Ty:-111,"V-":-55,"v,":-74,"V,":-129,"V;":-46,"V:":-46,"v.":-74,"V.":-129,Va:-55,VA:-46,Ve:-55,Vi:-18,Vo:-55,Vr:-37,Vu:-37,Vy:-18,"w,":-55,"W,":-74,"W;":-18,"W:":-18,"w.":-55,"W.":-74,Wa:-37,WA:-24,We:-57,Wo:-57,Wr:-18,Wu:-18,"Y-":-111,"y,":-74,"Y,":-139,"Y;":-92,"Y:":-92,"y.":-74,"Y.":-139,Ya:-92,YA:-74,Ye:-111,Yi:-37,Yo:-111,Yp:-74,Yq:-92,Yu:-74,Yv:-55},w:{" ":278,_:500,"-":389,"\u2013":500,"\u2014":1e3,",":278,";":278,":":278,"!":259,"?":556,".":278,"\u2026":1e3,"\xB7":278,"'":278,"\u2018":278,"\u2019":278,'"':426,"\u201C":426,"\u201D":426,"(":259,")":259,"[":259,"]":259,"{":333,"}":333,"@":800,"*":352,"/":333,"\\":333,"&":630,"#":556,"%":926,"\u2022":500,"`":222,"^":600,"\u2190":1e3,"\u2192":1e3,"\u2191":645.02,"\u2193":645.02,"+":600,"\xD7":600,"<":600,"=":600,">":600,"|":222,"~":600,"\u25E6":578.13,"\u2610":830.08,"\u2611":830.08,"\u2713":764.16,$:556,0:556,1:556,2:556,3:556,4:556,5:556,6:556,7:556,8:556,9:556,a:519,A:667,b:593,B:685,c:537,C:722,d:593,D:704,e:537,E:611,\u00E9:537,f:296,F:574,g:574,G:759,h:556,H:722,i:222,I:259,j:222,J:519,k:481,K:667,l:222,L:556,m:852,M:870,n:556,N:722,o:574,O:759,p:593,P:648,q:593,Q:759,r:333,R:685,s:481,S:648,t:315,T:574,u:556,U:722,v:481,V:611,w:759,W:926,x:481,X:611,y:481,Y:611,z:444,Z:611}},regular:{k:{"\u2018\u2018":-95,"\u2019\u2019":-95,"\u2019s":-74,"\u2019t":-18,"A\u2019":-74,AT:-92,Av:-18,AV:-46,Aw:-18,AW:-24,Ay:-18,AY:-74,"F,":-157,"F.":-157,"f\u2019":18,FA:-55,ff:-15,"L\u2019":-74,LT:-92,LV:-92,LW:-55,Ly:-37,LY:-111,"P,":-179,"P.":-179,PA:-74,"r-":-55,"r,":-92,"r.":-92,rc:-18,rd:-18,re:-18,rg:-28,rn:18,ro:-18,rq:-18,RT:-18,RV:-18,RW:-18,RY:-37,"T-":-129,"T,":-111,"T;":-111,"T:":-111,"T.":-111,Ta:-111,TA:-92,Tc:-111,Te:-111,To:-111,Tr:-92,Ts:-111,Tu:-92,Tw:-111,Ty:-111,"V-":-55,"v,":-74,"V,":-129,"V;":-46,"V:":-46,"v.":-74,"V.":-129,Va:-55,VA:-46,Ve:-55,Vi:-18,Vo:-55,Vr:-37,Vu:-37,Vy:-18,"w,":-55,"W,":-74,"W;":-18,"W:":-18,"w.":-55,"W.":-74,Wa:-37,WA:-24,We:-57,Wo:-57,Wr:-18,Wu:-18,"Y-":-111,"y,":-74,"Y,":-139,"Y;":-92,"Y:":-92,"y.":-74,"Y.":-139,Ya:-92,YA:-74,Ye:-111,Yi:-37,Yo:-111,Yp:-74,Yq:-92,Yu:-74,Yv:-55},w:{" ":278,_:500,"-":389,"\u2013":500,"\u2014":1e3,",":278,";":278,":":278,"!":259,"?":556,".":278,"\u2026":1e3,"\xB7":278,"'":278,"\u2018":278,"\u2019":278,'"':426,"\u201C":426,"\u201D":426,"(":259,")":259,"[":259,"]":259,"{":333,"}":333,"@":800,"*":352,"/":333,"\\":333,"&":630,"#":556,"%":1e3,"\u2022":350,"`":222,"^":600,"\u2190":1e3,"\u2192":1e3,"\u2191":645.02,"\u2193":645.02,"+":600,"\xD7":600,"<":600,"=":600,">":600,"|":222,"~":600,"\u25E6":578.13,"\u2610":830.08,"\u2611":830.08,"\u2713":764.16,$:556,0:556,1:556,2:556,3:556,4:556,5:556,6:556,7:556,8:556,9:556,a:537,A:648,b:593,B:685,c:537,C:722,d:593,D:704,e:537,E:611,\u00E9:537,f:296,F:574,g:574,G:759,h:556,H:722,i:222,I:259,j:222,J:519,k:519,K:667,l:222,L:556,m:853,M:871,n:556,N:722,o:574,O:760,p:593,P:648,q:593,Q:760,r:333,R:685,s:500,S:648,t:315,T:574,u:556,U:722,v:500,V:611,w:758,W:926,x:518,X:611,y:500,Y:648,z:480,Z:611}}},Xt={"\u2190":[.966796875,.2109375,0],"\u2192":[.966796875,.2109375,0],"\u2191":[.966796875,.2109375,0],"\u2193":[.966796875,.2109375,0],"\u25E6":[.966796875,.2109375,0],"\u2610":[.66650390625,.25,.08349609375],"\u2611":[.66650390625,.25,.08349609375],"\u2713":[.966796875,.2109375,0]};function V(t){let e=n=>Math.round(Math.min(Math.max(n,0),1)*255).toString(16).padStart(2,"0");return`#${e(t.r)}${e(t.g)}${e(t.b)}`}function Qt(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Zt(t,e,n="regular"){let i=xt[n],r=i.w.n,o=0,s="";for(let l of t)o+=i.w[l]??r,s&&(o+=i.k[s+l]??0),s=l;return o*e/1e3}function Pi(t){let e=Math.round(qt*t),n=Math.round(Ut*t),i=Math.round(Kt*t);return[e+n,e+n+i]}function Te(t,e){return t===" "?!0:(t==="/"||t==="-")&&e!==""&&!/[\d\s/-]/.test(e)}function Mi(t){let e=[...t],n=[],i="";return e.forEach((r,o)=>{i+=r;let s=e[o+1]??"";Te(r,s)&&s!==" "&&(n.push(i),i="")}),(i||n.length===0)&&n.push(i),n}function Ri(t,e,n,i="regular"){let r=[];for(let o of t.split(/\r\n|\n|\r|\u2028|\u2029/)){let s="";for(let l of Mi(o)){let a=s+l;for(s===""||Zt(a.trimEnd(),e,i)<=n?s=a:(r.push(s),s=l);Zt(s.trimEnd(),e,i)>n&&[...s.trimEnd()].length>1;){let c=[...s],u=c.length-1;for(;u>1&&Zt(c.slice(0,u).join(""),e,i)>n;)u--;r.push(c.slice(0,u).join("")),s=c.slice(u).join("")}}r.push(s)}return r}function Yn(t,e,n){if(t==="")return{width:0,height:0};let i=Ri(t,e,n),r=Math.max(...i.map(l=>Zt(l.trimEnd(),e))),[o,s]=Pi(e);return{width:Math.ceil(r-1e-9),height:Math.ceil(o+s*(i.length-1)-1e-9)}}var On=12,ut="\u2028";function Ai(t){let e=Math.min(On,t.width/2),n=Math.min(On,t.height/2);return{x:t.x+e,y:t.y+n,width:t.width-2*e,height:t.height-2*n}}var Ee=/^ {0,3}(#{1,6})(?:[ \t]+(.*?))?(?:[ \t]+#+)?[ \t]*$/,Bn=/^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/,Se=/^ {0,3}(`{3,}|~{3,})/,Et=/^( *)([-*+]|\d{1,9}[.)])([ \t]+|$)(.*)$/,Jt=/^ {0,3}> ?(.*)$/,Ti=/^ *\|? *:?-+:? *(\| *:?-+:? *)*\|? *$/;function ve(t){let e=t.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&!e.endsWith("\\|")&&(e=e.slice(0,-1)),e.split(/(?<!\\)\|/).map(n=>n.trim())}function vi(t){return Ve(t.replace(/\r\n?/g,`
|
|
3
3
|
`).split(`
|
|
4
4
|
`))}function Ve(t){let e=[],n=0,i=null,r=()=>{i&&(e.push({kind:"paragraph",inline:N(i.join(`
|
|
@@ -60,4 +60,4 @@ output { font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: right
|
|
|
60
60
|
<button class="next" aria-label="Next scene" hidden>\u23ED</button>
|
|
61
61
|
<input class="scrub" type="range" min="0" max="0" value="0" aria-label="Frame">
|
|
62
62
|
<output class="time">0.0s</output>
|
|
63
|
-
</div>`;let n=i=>this.root.querySelector(i);this.stage=n(".stage"),this.bar=n(".bar"),this.playButton=n(".play"),this.scrub=n(".scrub"),this.time=n(".time"),this.sceneLabel=n(".scene"),this.prev=n(".prev"),this.next=n(".next"),this.playButton.onclick=()=>{let i=this.playback;i&&!this.playing&&i.scenes.length&&i.frame>=i.frameCount-1&&i.show(0),this.setPlaying(!this.playing)},this.scrub.oninput=()=>{this.setPlaying(!1),this.playback?.show(Number(this.scrub.value))},this.next.onclick=()=>this.nextScene(),this.prev.onclick=()=>this.prevScene(),this.addEventListener("keydown",i=>this.key(i))}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),"IntersectionObserver"in window&&(this.observer=new IntersectionObserver(n=>{this.visible=n.some(i=>i.isIntersecting),this.schedule()}),this.observer.observe(this)),this.load()}disconnectedCallback(){cancelAnimationFrame(this.raf),this.raf=0,this.observer?.disconnect()}attributeChangedCallback(n,i,r){i===r||!this.isConnected||(n==="src"?this.load():n==="label"?this.stage.setAttribute("aria-label",r??""):this.file&&this.mount())}async load(){let n=++this.loadToken;try{let i,r=this.getAttribute("src");if(r){let o=await fetch(r);if(!o.ok)throw new Error(`${r}: ${o.status} ${o.statusText}`);i=await o.text()}else{let o=this.querySelector('script[type="application/json"], script[type="application/vnd.dottie+json"]');if(!o)return;i=o.textContent??""}if(n!==this.loadToken)return;this.setFile(Rt(i))}catch(i){if(n!==this.loadToken)return;this.stage.innerHTML="";let r=document.createElement("div");r.className="error",r.textContent=`Couldn't show this drawing: ${i.message}`,this.stage.append(r),this.dispatchEvent(new CustomEvent("error",{detail:i}))}}setFile(n){this.file=n;for(let i of n.warnings)console.warn(`dottie-player: ${i}`);this.mount(),this.dispatchEvent(new CustomEvent("load",{detail:{file:n}}))}mount(){let n=this.file,i=n.pages[Dt(n,this.getAttribute("page"))],r=new Vt(i,this.stage,{clean:this.hasAttribute("clean")});this.playback=r,this.style.setProperty("--dottie-page",V(r.background)),this.style.setProperty("--dottie-ink",V(r.ink)),this.style.colorScheme=pt(r.background)<.5?"dark":"light",this.stage.setAttribute("aria-label",this.getAttribute("label")??i.name);let o=this.getAttribute("at"),s=i.timeline!==null&&r.frameCount>1&&o===null;this.bar.hidden=!s||this.hasAttribute("no-controls");let l=r.scenes.length>0;if(this.prev.hidden=this.next.hidden=this.sceneLabel.hidden=!l,this.scrub.max=String(r.frameCount-1),r.onFrame=c=>{if(this.scrub.value=String(c),this.time.textContent=`${r.plan.times[c].toFixed(1)}s`,l){let u=r.sceneAt(c);this.sceneLabel.textContent=u<0?"":r.sceneNames[u]}this.dispatchEvent(new CustomEvent("frame",{detail:{frame:c,time:r.plan.times[c]}}))},!s){r.drawAt(o!==null?Number(o)||0:it(i),o!==null?Kn(r,Number(o)||0):r.posterFrame),this.setPlaying(!1);return}if(r.show(0),typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches){r.show(r.posterFrame),this.setPlaying(!1);return}this.setPlaying(!this.hasAttribute("no-autoplay")&&!r.scenes.includes(0))}get paused(){return!this.playing}get currentTime(){let n=this.playback;return n&&n.frame>=0?n.plan.times[n.frame]:0}set currentTime(n){let i=this.playback;i&&(this.setPlaying(!1),i.show(Kn(i,n)))}get duration(){return this.playback?.page.timeline?.duration??0}play(){this.setPlaying(!0)}pause(){this.setPlaying(!1)}nextScene(){let n=this.playback;n&&(n.frame>=n.frameCount-1&&n.show(0),this.setPlaying(!0))}prevScene(){let n=this.playback;if(!n)return;let i=n.sceneAt(n.frame);i>=0&&n.scenes[i]===n.frame&&(i-=1),this.setPlaying(!1),n.show(i>=0?n.scenes[i]:0)}setPlaying(n){let i=this.playback;this.playing=n&&!!i&&i.frameCount>1&&i.page.timeline!==null,this.playButton.textContent=this.playing?"\u275A\u275A":"\u25B6",this.playButton.setAttribute("aria-label",this.playing?"Pause":"Play"),this.last=0,this.acc=0,this.schedule()}schedule(){this.playing&&this.visible&&!this.raf&&this.isConnected&&(this.raf=requestAnimationFrame(n=>this.tick(n)))}tick(n){this.raf=0;let i=this.playback;if(!this.playing||!i)return;let r=1e3/(i.page.timeline?.fps??12);this.last&&(this.acc+=Math.min(n-this.last,1e3)),this.last=n;let o=!1;for(;this.playing&&this.acc>=r;){this.acc-=r;let s=i.frame+1;if(s>=i.frameCount&&(i.scenes.length||this.hasAttribute("no-loop"))){this.setPlaying(!1);break}if(i.frame=s%i.frameCount,o=!0,i.scenes.includes(i.frame)){this.setPlaying(!1);break}}o&&i.show(i.frame),this.playing&&!this.visible&&(this.last=0),this.schedule()}key(n){let i=this.playback;if(!i||i.page.timeline===null||i.frameCount<=1||this.hasAttribute("at")||n.target===this.scrub&&n.key!==" ")return;let r=i.scenes.length>0,o=!0;n.key===" "?r?this.playing?this.setPlaying(!1):this.nextScene():this.setPlaying(!this.playing):n.key==="ArrowRight"?r?this.nextScene():(this.setPlaying(!1),i.show(i.frame+1)):n.key==="ArrowLeft"?r?this.prevScene():(this.setPlaying(!1),i.show(i.frame-1)):n.key==="."?(this.setPlaying(!1),i.show(i.frame+1)):n.key===","?(this.setPlaying(!1),i.show(i.frame-1)):o=!1,o&&n.preventDefault()}};k(wt,"observedAttributes",["src","page","at","clean","no-controls","label"]);function Kn(t,e){let n=0;return t.plan.times.forEach((i,r)=>{Math.abs(i-e)<Math.abs(t.plan.times[n]-e)&&(n=r)}),n}function oe(t="dottie-player"){typeof customElements<"u"&&!customElements.get(t)&&customElements.define(t,class extends wt{})}var T=t=>{let e=Tt(t*1e4)/1e4;return e===0?0:e},ze=t=>[T(t.x),T(t.y)],Yt=t=>[T(t.x),T(t.y),T(t.width),T(t.height)],Xn=t=>[T(t.r),T(t.g),T(t.b),T(t.a)];function Ce(t){let e=t.timeline;if(!e)return[0];let n=e.duration,i=[0,n];for(let r=1;r<16;r++)i.push(n*(r+.37)/16);for(let r of e.markers??[])i.push(r.t);return e.poster!==null&&i.push(e.poster),[...new Set(i.map(T))].filter(r=>r>=0&&r<=n).sort((r,o)=>r-o)}function Ge(t,e){let n=W(t,e),i=tt(n),r=new Set(n.layers.filter(l=>l.visible).map(l=>l.id)),o={t:T(e)},s=t.timeline;if(s){let l=bt(s,e);o.view=l?Yt(l):null;let a=-1;(s.markers??[]).forEach((c,u)=>{c.t<=e&&(a=u)}),o.scene=a}return s?.camera?.length||(o.bounds=Yt(rt(n))),o.elements=At(n).map((l,a)=>{let c={id:l.id,kind:l.kind,z:a,seed:l.seed,frame:Yt({x:l.x,y:l.y,width:l.width,height:l.height})};if(r.has(l.layerID)||(c.hiddenLayer=!0),l.rotation!==null&&(c.rotation=T(l.rotation)),l.style.opacity!==null&&(c.opacity=T(l.style.opacity)),l.reveal!==null&&(c.reveal=T(l.reveal)),l.style.dashOffset!==null&&(c.dashOffset=T(l.style.dashOffset)),c.strokeWidth=T(l.style.strokeWidth),c.stroke=Xn(l.style.stroke),c.fill=Xn(l.style.fill),l.kind==="connector"){let[u,d]=lt(l,i);c.start=ze(u),c.end=ze(d),c.route=Z(J(l,i)).map(ze)}return c}),o}function Be(t,e,n){let i={page:e+1,name:t.name,id:t.id},r=t.timeline;if(r){let o=kt(t);i.duration=T(r.duration),i.fps=T(r.fps),i.frameCount=o.times.length,i.poster=T(r.poster??r.duration),i.size=[T(o.size.width),T(o.size.height)],r.camera?.length||(i.bounds=Yt(o.rects[0])),i.markers=(r.markers??[]).map(s=>({t:T(s.t),name:s.name}))}else i.bounds=Yt(rt(t));return i.frames=n.map(o=>Ge(t,o)),i}function Qn(t,e){return{version:t.version,pages:t.pages.map((n,i)=>Be(n,i,e??Ce(n)))}}function er(t,e={}){let n=nr(t)?t:Rt(t),i=n.pages[Dt(n,e.page===void 0?null:String(e.page))];return i=W(i,e.at??it(i)),e.clean&&(i=Wt(i,0)),re(i,e.background===void 0?{r:1,g:1,b:1,a:1}:e.background)}function nr(t){return typeof t=="object"&&t!==null&&Array.isArray(t.pages)&&Array.isArray(t.warnings)}var ir="0.
|
|
63
|
+
</div>`;let n=i=>this.root.querySelector(i);this.stage=n(".stage"),this.bar=n(".bar"),this.playButton=n(".play"),this.scrub=n(".scrub"),this.time=n(".time"),this.sceneLabel=n(".scene"),this.prev=n(".prev"),this.next=n(".next"),this.playButton.onclick=()=>{let i=this.playback;i&&!this.playing&&i.scenes.length&&i.frame>=i.frameCount-1&&i.show(0),this.setPlaying(!this.playing)},this.scrub.oninput=()=>{this.setPlaying(!1),this.playback?.show(Number(this.scrub.value))},this.next.onclick=()=>this.nextScene(),this.prev.onclick=()=>this.prevScene(),this.addEventListener("keydown",i=>this.key(i))}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),"IntersectionObserver"in window&&(this.observer=new IntersectionObserver(n=>{this.visible=n.some(i=>i.isIntersecting),this.schedule()}),this.observer.observe(this)),this.load()}disconnectedCallback(){cancelAnimationFrame(this.raf),this.raf=0,this.observer?.disconnect()}attributeChangedCallback(n,i,r){i===r||!this.isConnected||(n==="src"?this.load():n==="label"?this.stage.setAttribute("aria-label",r??""):this.file&&this.mount())}async load(){let n=++this.loadToken;try{let i,r=this.getAttribute("src");if(r){let o=await fetch(r);if(!o.ok)throw new Error(`${r}: ${o.status} ${o.statusText}`);i=await o.text()}else{let o=this.querySelector('script[type="application/json"], script[type="application/vnd.dottie+json"]');if(!o)return;i=o.textContent??""}if(n!==this.loadToken)return;this.setFile(Rt(i))}catch(i){if(n!==this.loadToken)return;this.stage.innerHTML="";let r=document.createElement("div");r.className="error",r.textContent=`Couldn't show this drawing: ${i.message}`,this.stage.append(r),this.dispatchEvent(new CustomEvent("error",{detail:i}))}}setFile(n){this.file=n;for(let i of n.warnings)console.warn(`dottie-player: ${i}`);this.mount(),this.dispatchEvent(new CustomEvent("load",{detail:{file:n}}))}mount(){let n=this.file,i=n.pages[Dt(n,this.getAttribute("page"))],r=new Vt(i,this.stage,{clean:this.hasAttribute("clean")});this.playback=r,this.style.setProperty("--dottie-page",V(r.background)),this.style.setProperty("--dottie-ink",V(r.ink)),this.style.colorScheme=pt(r.background)<.5?"dark":"light",this.stage.setAttribute("aria-label",this.getAttribute("label")??i.name);let o=this.getAttribute("at"),s=i.timeline!==null&&r.frameCount>1&&o===null;this.bar.hidden=!s||this.hasAttribute("no-controls");let l=r.scenes.length>0;if(this.prev.hidden=this.next.hidden=this.sceneLabel.hidden=!l,this.scrub.max=String(r.frameCount-1),r.onFrame=c=>{if(this.scrub.value=String(c),this.time.textContent=`${r.plan.times[c].toFixed(1)}s`,l){let u=r.sceneAt(c);this.sceneLabel.textContent=u<0?"":r.sceneNames[u]}this.dispatchEvent(new CustomEvent("frame",{detail:{frame:c,time:r.plan.times[c]}}))},!s){r.drawAt(o!==null?Number(o)||0:it(i),o!==null?Kn(r,Number(o)||0):r.posterFrame),this.setPlaying(!1);return}if(r.show(0),typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches){r.show(r.posterFrame),this.setPlaying(!1);return}this.setPlaying(!this.hasAttribute("no-autoplay")&&!r.scenes.includes(0))}get paused(){return!this.playing}get currentTime(){let n=this.playback;return n&&n.frame>=0?n.plan.times[n.frame]:0}set currentTime(n){let i=this.playback;i&&(this.setPlaying(!1),i.show(Kn(i,n)))}get duration(){return this.playback?.page.timeline?.duration??0}play(){this.setPlaying(!0)}pause(){this.setPlaying(!1)}nextScene(){let n=this.playback;n&&(n.frame>=n.frameCount-1&&n.show(0),this.setPlaying(!0))}prevScene(){let n=this.playback;if(!n)return;let i=n.sceneAt(n.frame);i>=0&&n.scenes[i]===n.frame&&(i-=1),this.setPlaying(!1),n.show(i>=0?n.scenes[i]:0)}setPlaying(n){let i=this.playback;this.playing=n&&!!i&&i.frameCount>1&&i.page.timeline!==null,this.playButton.textContent=this.playing?"\u275A\u275A":"\u25B6",this.playButton.setAttribute("aria-label",this.playing?"Pause":"Play"),this.last=0,this.acc=0,this.schedule()}schedule(){this.playing&&this.visible&&!this.raf&&this.isConnected&&(this.raf=requestAnimationFrame(n=>this.tick(n)))}tick(n){this.raf=0;let i=this.playback;if(!this.playing||!i)return;let r=1e3/(i.page.timeline?.fps??12);this.last&&(this.acc+=Math.min(n-this.last,1e3)),this.last=n;let o=!1;for(;this.playing&&this.acc>=r;){this.acc-=r;let s=i.frame+1;if(s>=i.frameCount&&(i.scenes.length||this.hasAttribute("no-loop"))){this.setPlaying(!1);break}if(i.frame=s%i.frameCount,o=!0,i.scenes.includes(i.frame)){this.setPlaying(!1);break}}o&&i.show(i.frame),this.playing&&!this.visible&&(this.last=0),this.schedule()}key(n){let i=this.playback;if(!i||i.page.timeline===null||i.frameCount<=1||this.hasAttribute("at")||n.target===this.scrub&&n.key!==" ")return;let r=i.scenes.length>0,o=!0;n.key===" "?r?this.playing?this.setPlaying(!1):this.nextScene():this.setPlaying(!this.playing):n.key==="ArrowRight"?r?this.nextScene():(this.setPlaying(!1),i.show(i.frame+1)):n.key==="ArrowLeft"?r?this.prevScene():(this.setPlaying(!1),i.show(i.frame-1)):n.key==="."?(this.setPlaying(!1),i.show(i.frame+1)):n.key===","?(this.setPlaying(!1),i.show(i.frame-1)):o=!1,o&&n.preventDefault()}};k(wt,"observedAttributes",["src","page","at","clean","no-controls","label"]);function Kn(t,e){let n=0;return t.plan.times.forEach((i,r)=>{Math.abs(i-e)<Math.abs(t.plan.times[n]-e)&&(n=r)}),n}function oe(t="dottie-player"){typeof customElements<"u"&&!customElements.get(t)&&customElements.define(t,class extends wt{})}var T=t=>{let e=Tt(t*1e4)/1e4;return e===0?0:e},ze=t=>[T(t.x),T(t.y)],Yt=t=>[T(t.x),T(t.y),T(t.width),T(t.height)],Xn=t=>[T(t.r),T(t.g),T(t.b),T(t.a)];function Ce(t){let e=t.timeline;if(!e)return[0];let n=e.duration,i=[0,n];for(let r=1;r<16;r++)i.push(n*(r+.37)/16);for(let r of e.markers??[])i.push(r.t);return e.poster!==null&&i.push(e.poster),[...new Set(i.map(T))].filter(r=>r>=0&&r<=n).sort((r,o)=>r-o)}function Ge(t,e){let n=W(t,e),i=tt(n),r=new Set(n.layers.filter(l=>l.visible).map(l=>l.id)),o={t:T(e)},s=t.timeline;if(s){let l=bt(s,e);o.view=l?Yt(l):null;let a=-1;(s.markers??[]).forEach((c,u)=>{c.t<=e&&(a=u)}),o.scene=a}return s?.camera?.length||(o.bounds=Yt(rt(n))),o.elements=At(n).map((l,a)=>{let c={id:l.id,kind:l.kind,z:a,seed:l.seed,frame:Yt({x:l.x,y:l.y,width:l.width,height:l.height})};if(r.has(l.layerID)||(c.hiddenLayer=!0),l.rotation!==null&&(c.rotation=T(l.rotation)),l.style.opacity!==null&&(c.opacity=T(l.style.opacity)),l.reveal!==null&&(c.reveal=T(l.reveal)),l.style.dashOffset!==null&&(c.dashOffset=T(l.style.dashOffset)),c.strokeWidth=T(l.style.strokeWidth),c.stroke=Xn(l.style.stroke),c.fill=Xn(l.style.fill),l.kind==="connector"){let[u,d]=lt(l,i);c.start=ze(u),c.end=ze(d),c.route=Z(J(l,i)).map(ze)}return c}),o}function Be(t,e,n){let i={page:e+1,name:t.name,id:t.id},r=t.timeline;if(r){let o=kt(t);i.duration=T(r.duration),i.fps=T(r.fps),i.frameCount=o.times.length,i.poster=T(r.poster??r.duration),i.size=[T(o.size.width),T(o.size.height)],r.camera?.length||(i.bounds=Yt(o.rects[0])),i.markers=(r.markers??[]).map(s=>({t:T(s.t),name:s.name}))}else i.bounds=Yt(rt(t));return i.frames=n.map(o=>Ge(t,o)),i}function Qn(t,e){return{version:t.version,pages:t.pages.map((n,i)=>Be(n,i,e??Ce(n)))}}function er(t,e={}){let n=nr(t)?t:Rt(t),i=n.pages[Dt(n,e.page===void 0?null:String(e.page))];return i=W(i,e.at??it(i)),e.clean&&(i=Wt(i,0)),re(i,e.background===void 0?{r:1,g:1,b:1,a:1}:e.background)}function nr(t){return typeof t=="object"&&t!==null&&Array.isArray(t.pages)&&Array.isArray(t.warnings)}var ir="0.5.0";oe();globalThis.Dottie??(globalThis.Dottie=Fe);})();
|
package/dist/dottie.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! dottie.js 0.
|
|
1
|
+
/*! dottie.js 0.5.0 | Apache-2.0 | https://github.com/phin-tech/dottie */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value2) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
|
|
4
4
|
var __publicField = (obj, key, value2) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value2);
|
|
@@ -3024,7 +3024,7 @@ function render(source, options = {}) {
|
|
|
3024
3024
|
function isFile(v) {
|
|
3025
3025
|
return typeof v === "object" && v !== null && Array.isArray(v.pages) && Array.isArray(v.warnings);
|
|
3026
3026
|
}
|
|
3027
|
-
var VERSION = "0.
|
|
3027
|
+
var VERSION = "0.5.0";
|
|
3028
3028
|
export {
|
|
3029
3029
|
BOIL_DRAWINGS,
|
|
3030
3030
|
DottieFormatError,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -18,4 +18,4 @@ export interface RenderOptions {
|
|
|
18
18
|
/** One page of a drawing as an SVG document, as Dottie's own SVG export draws it. */
|
|
19
19
|
export declare function render(source: string | DottieFile | unknown, options?: RenderOptions): string;
|
|
20
20
|
/** The library's version. */
|
|
21
|
-
export declare const VERSION = "0.
|
|
21
|
+
export declare const VERSION = "0.5.0";
|